/** * Context Injector for proactive decision retrieval * * Searches MAMA's decision graph for relevant context * and formats it for injection into system prompts. */ import type { RelatedDecision, MessageRouterConfig } from './types.js'; /** * Checkpoint data from MAMA */ export interface Checkpoint { id: number; timestamp: number; summary: string; next_steps?: string; open_files?: string[]; } /** * Decision data from MAMA */ export interface Decision { id: string; topic: string; decision: string; reasoning?: string; outcome?: string; confidence?: number; created_at?: string; } /** * MAMA API interface for context injection * * This interface abstracts the MAMA API calls, * allowing for easy mocking in tests. */ export interface MamaApiClient { /** * Search for decisions related to a query */ search(query: string, limit?: number): Promise; /** * Load the last active checkpoint */ loadCheckpoint?(): Promise; /** * List recent decisions */ listDecisions?(options?: { limit?: number; }): Promise; /** * Save a new decision or fact */ save?(input: Record): Promise; /** * Recall memory v2 bundle */ recallMemory?(query: string, options?: { scopes?: Array<{ kind: string; id: string; }>; includeProfile?: boolean; }): Promise; /** * Ingest raw content into memory v2 */ ingestMemory?(input: Record): Promise; /** * Build compact bootstrap packet for memory agents */ buildMemoryBootstrap?(input: { scopes: Array<{ kind: string; id: string; }>; currentGoal?: string; mainAgentState?: MemoryAgentBootstrap['main_agent_state']; }): Promise; /** * Read the rolling summary for a channel */ getChannelSummary?(channelKey: string): Promise<{ channel_key: string; summary_markdown: string; updated_at: number; } | null>; /** * Update the rolling summary for a channel */ upsertChannelSummary?(input: { channelKey: string; summaryMarkdown: string; deltaHash?: string; }): Promise; } /** * Search result from MAMA API */ export interface SearchResult { id: string; topic?: string; decision?: string; reasoning?: string; outcome?: string; similarity: number; } export interface RecallBundleMemory { id: string; topic: string; summary: string; details?: string; } export interface RecallBundle { profile: { static: Array<{ summary: string; }>; dynamic: Array<{ summary: string; }>; evidence: Array<{ memory_id: string; topic: string; why_included: string; }>; }; memories: RecallBundleMemory[]; graph_context: { primary: RecallBundleMemory[]; expanded: RecallBundleMemory[]; edges: Array<{ from_id: string; to_id: string; type: string; reason?: string; }>; }; search_meta: { query: string; scope_order: string[]; retrieval_sources: string[]; }; } export interface MemoryAgentBootstrap { current_goal?: string; scope_context: Array<{ kind: string; id: string; }>; truth_snapshot: Array<{ id: string; topic: string; summary: string; trust_score: number; }>; open_audit_findings: Array<{ id: string; kind: string; severity: string; summary: string; }>; recent_memory_events: Array<{ id: string; type: string; topic?: string; created_at: number; }>; profile_snapshot?: { static: Array<{ id: string; summary: string; }>; dynamic: Array<{ id: string; summary: string; }>; }; main_agent_state?: { active_goal?: string; active_channel?: string; active_user?: string; }; } /** * Context injection result */ export interface InjectedContext { /** Formatted context string for system prompt */ prompt: string; /** Related decisions that were found */ decisions: RelatedDecision[]; /** Whether any relevant context was found */ hasContext: boolean; } /** * Context Injector class * * Retrieves relevant decisions from MAMA memory and formats * them for injection into the agent's system prompt. */ export declare class ContextInjector { private mamaApi; private similarityThreshold; private maxDecisions; constructor(mamaApi: MamaApiClient, config?: Pick); /** * Get relevant context for a user message */ getRelevantContext(query: string): Promise; /** * Format decisions into a system prompt section */ private formatPrompt; /** * Parse outcome string to typed value */ private parseOutcome; /** * Update configuration */ setConfig(config: Pick): void; /** * Get session startup context (equivalent to SessionStart hook) * Includes checkpoint, recent decisions, and greeting instructions */ getSessionStartupContext(input?: { source: string; channelId: string; }): Promise; /** * Format milliseconds to human-readable time ago */ private formatTimeAgo; /** * Truncate text to max length */ private truncate; } /** * Create a mock MAMA API client for testing */ export declare function createMockMamaApi(decisions?: SearchResult[]): MamaApiClient; //# sourceMappingURL=context-injector.d.ts.map