Skip to content

Conversation

@b1ackmartian
Copy link

Summary

  • Adds the missing Inference.ts module that several UserPromptSubmit hooks depend on
  • Uses native fetch to call Anthropic Messages API (no additional dependencies)
  • Supports fast/standard/complex inference levels for different use cases

Fixes #418

Changes

  • Created Packs/pai-core-install/src/skills/CORE/Tools/Inference.ts

API Signature

interface InferenceOptions {
  systemPrompt: string;
  userPrompt: string;
  expectJson?: boolean;
  timeout?: number;
  level?: 'fast' | 'standard' | 'complex';
}

interface InferenceResult {
  success: boolean;
  output?: string;   // Raw text output
  parsed?: any;      // Parsed JSON when expectJson=true
  error?: string;    // Error message
}

Model Mapping

  • fast: claude-3-5-haiku-latest (cheap, fast, good for classification)
  • standard: claude-sonnet-4-20250514 (balanced)
  • complex: claude-opus-4-5-20251101 (complex reasoning)

Test Plan

  • AutoWorkCreation.hook.ts executes without import error
  • ImplicitSentimentCapture.hook.ts executes without import error
  • UpdateTabTitle.hook.ts executes without import error
  • New session starts without hook errors

🤖 Generated with Claude Code

Adds Skills/CORE/Tools/Inference.ts that provides a lightweight wrapper
for making LLM inference calls from hooks using the Anthropic Messages API.

Features:
- Uses native fetch (no external dependencies)
- Supports three inference levels: fast (Haiku), standard (Sonnet), complex (Opus)
- Handles JSON parsing when expectJson: true
- Includes timeout support via AbortController

Required by UserPromptSubmit hooks that need LLM-based classification:
- AutoWorkCreation.hook.ts
- ImplicitSentimentCapture.hook.ts
- UpdateTabTitle.hook.ts

Fixes danielmiessler#418

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Missing Inference.ts module breaks UserPromptSubmit hooks in pai-hook-system

1 participant