Skip to content

fix: Add missing Inference.ts module for hook LLM calls#419

Closed
b1ackmartian wants to merge 1 commit intodanielmiessler:mainfrom
b1ackmartian:fix/add-inference-module
Closed

fix: Add missing Inference.ts module for hook LLM calls#419
b1ackmartian wants to merge 1 commit intodanielmiessler:mainfrom
b1ackmartian:fix/add-inference-module

Conversation

@b1ackmartian
Copy link
Copy Markdown

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>
@kaimagnus
Copy link
Copy Markdown
Collaborator

Thank you for the Inference.ts module, @b1ackmartian! Clean implementation with the three-tier model approach (fast/standard/complex).

v3.0 already includes an Inference.ts utility and the target path (Packs/pai-core-install/) no longer exists. Closing as this is superseded by the v3.0 tooling. Appreciate the solid API design!

@kaimagnus kaimagnus closed this Feb 15, 2026
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

2 participants