/** * AI Enrichment for Observations and Session Summaries * * Uses pluggable AI providers (Claude CLI, OpenAI-compatible, Gemini) to * generate richer subtitle, narrative, facts, and concepts from tool * observations, and to enhance session summaries using transcript data. * Falls back to template-based extraction when the provider is not available. * * @module @agentkits/memory/hooks/ai-enrichment */ import { type AIProviderConfig } from './ai-provider.js'; /** * Enriched observation data from AI extraction */ export interface EnrichedObservation { subtitle: string; narrative: string; facts: string[]; concepts: string[]; /** Confidence score 0.0-1.0 indicating extraction quality */ confidence: number; } /** * Set AI provider config from settings.json. * Called by service.ts after loading settings. Forces re-resolution on next use. */ export declare function setAIProviderConfig(config?: AIProviderConfig): void; /** * Synchronous check: is AI enrichment potentially enabled? * Used by observation hook to decide whether to spawn background process. * Does NOT check provider availability (that may be slow). Just checks env var. */ export declare function isAIEnrichmentEnabled(): boolean; /** * Build the extraction prompt for a tool observation */ export declare function buildExtractionPrompt(toolName: string, toolInput: string, toolResponse: string): string; /** * Parse JSON from AI response, handling common formatting issues */ export declare function parseAIResponse(text: string): EnrichedObservation | null; /** * Enrich an observation using the configured AI provider. * * Returns enriched data if provider is available and succeeds, * or null to signal fallback to template-based extraction. */ export declare function enrichWithAI(toolName: string, toolInput: string, toolResponse: string, timeoutMs?: number): Promise; /** * Check if AI enrichment is available (provider configured and reachable) */ export declare function isAIEnrichmentAvailable(): Promise; /** * Reset cached provider and mock state (for testing) */ export declare function resetAIEnrichmentCache(): void; /** * Override provider availability for testing (inject mock). * Sets the mock which makes isProviderAvailable() return true. */ export declare function _setCliAvailableForTesting(available: boolean): void; /** * Inject a mock for the AI provider run function (for testing). * The mock receives (prompt, systemPrompt, timeoutMs) and returns string | null. * Pass null to clear the mock. */ export declare function _setRunClaudePrintMockForTesting(fn: ((prompt: string, systemPrompt: string, timeoutMs: number) => string | null) | null): void; /** * Enriched session summary data from AI extraction */ export interface EnrichedSummary { completed: string; nextSteps: string; decisions: string[]; } /** * Build prompt for enriching a session summary using transcript context */ export declare function buildSummaryPrompt(templateSummary: string, lastAssistantMessage: string): string; /** * Parse enriched summary from AI response */ export declare function parseSummaryResponse(text: string): EnrichedSummary | null; /** * Enrich a session summary using the configured AI provider. * * Takes template-based summary + last assistant message from transcript, * returns AI-enhanced completed/nextSteps fields. */ export declare function enrichSummaryWithAI(templateSummary: string, lastAssistantMessage: string, timeoutMs?: number): Promise; /** * Compressed observation data */ export interface CompressedObservation { compressed_summary: string; } /** * Build prompt for compressing a single observation into a dense summary. * Uses existing subtitle/narrative as hints for faster, more accurate compression. */ export declare function buildCompressionPrompt(toolName: string, toolInput: string, toolResponse: string, subtitle?: string, narrative?: string): string; /** * Parse compression response from AI */ export declare function parseCompressionResponse(text: string): CompressedObservation | null; /** * Compress a single observation using the configured AI provider. * Returns a dense 50-150 char summary suitable for context injection. */ export declare function compressObservationWithAI(toolName: string, toolInput: string, toolResponse: string, subtitle?: string, narrative?: string, timeoutMs?: number): Promise; /** * Session digest data from AI compression */ export interface SessionDigest { digest: string; } /** * Build prompt for generating a compressed session digest. * Takes the session's request, observation summaries, and completion info. */ export declare function buildSessionDigestPrompt(request: string, observationSummaries: string[], completed: string, filesModified: string[]): string; /** * Parse session digest response from AI */ export declare function parseSessionDigestResponse(text: string): SessionDigest | null; /** * Generate a session-level digest using the configured AI provider. * Compresses an entire session into a 200-500 char digest. */ export declare function generateSessionDigestWithAI(request: string, observationSummaries: string[], completed: string, filesModified: string[], timeoutMs?: number): Promise; //# sourceMappingURL=ai-enrichment.d.ts.map