import type { AgentSession } from "../session/agent-session"; import { type BankScope } from "./bank"; import type { HindsightApi } from "./client"; import type { HindsightConfig } from "./config"; import { type HindsightMessage } from "./content"; interface RecallOutcome { context: string | null; ok: boolean; } export interface HindsightSessionStateOptions { /** Session id used for retain-queue metadata. */ sessionId: string; client: HindsightApi; bankId: string; /** Tags applied to every retain — non-empty in per-project-tagged mode. */ retainTags?: string[]; /** Tag filter applied to every recall/reflect — non-empty in per-project-tagged mode. */ recallTags?: string[]; recallTagsMatch?: "any" | "all" | "any_strict" | "all_strict"; config: HindsightConfig; session: AgentSession; missionsSet: Set; lastRetainedTurn?: number; hasRecalledForFirstTurn?: boolean; /** * When set, this entry is a subagent alias that reuses the parent's bank, * scope, config, client, and missionsSet. Aliases skip auto-recall and * auto-retain — those run on the parent only — but the recall/retain/reflect * tools resolve via the alias so they persist to the same bank as the parent. */ aliasOf?: HindsightSessionState; } /** * Debounced batch queue for tool-initiated `retain` calls owned by one * Hindsight session state instance. * * Auto-retain (`HindsightSessionState.retainSession`) is intentionally not * routed through this queue — it submits a full transcript as one large item * and already runs `async: true` server-side. */ export declare class HindsightRetainQueue { #private; constructor(state: HindsightSessionState); get depth(): number; enqueue(content: string, context?: string): void; flush(): Promise; dispose(): void; } /** Per-session Hindsight runtime state owned by its AgentSession. */ export declare class HindsightSessionState { #private; /** Session id used for retain-queue metadata. */ sessionId: string; client: HindsightApi; bankId: string; /** Tags applied to every retain — non-empty in per-project-tagged mode. */ retainTags?: string[]; /** Tag filter applied to every recall/reflect — non-empty in per-project-tagged mode. */ recallTags?: string[]; recallTagsMatch?: "any" | "all" | "any_strict" | "all_strict"; config: HindsightConfig; session: AgentSession; missionsSet: Set; lastRetainedTurn: number; hasRecalledForFirstTurn: boolean; lastRecallSnippet?: string; /** Cached `` block injected into developer instructions. */ mentalModelsSnippet?: string; /** When the cached snippet was last refreshed; gates the agent_end re-list. */ mentalModelsLoadedAt?: number; /** * In-flight ensure+load promise. `beforeAgentStartPrompt` awaits this on * the first turn so the MM block lands in the system prompt before the * LLM generates, even though `start()` returns before the load completes. */ mentalModelsLoadPromise?: Promise; unsubscribe?: () => void; /** Alias states delegate persistence config to a primary parent state. */ aliasOf?: HindsightSessionState; readonly retainQueue: HindsightRetainQueue; constructor(options: HindsightSessionStateOptions); setSessionId(sessionId: string): void; resetConversationTracking(): void; enqueueRetain(content: string, context?: string): void; flushRetainQueue(): Promise; recallForContext(query: string, signal?: AbortSignal): Promise; retainSession(messages: HindsightMessage[]): Promise; maybeRetainOnAgentEnd(): Promise; forceRetainCurrentSession(): Promise; maybeRecallOnAgentStart(): Promise; beforeAgentStartPrompt(promptText: string): Promise; recallForCompaction(messages: HindsightMessage[]): Promise; runMentalModelLoad(scope: BankScope): Promise; refreshMentalModelsSnippet(): Promise; reloadMentalModels(): Promise; attachSessionListeners(): void; dispose(): void; } export {};