/** * Session State Management * Track current session context for auto-injecting into recall calls * Track surfaced scars for auto-bridging Q6 answers to scar_usage records * * Maintains in-memory state of the current active session including: * - session_id from session_start * - linear_issue if working on a Linear issue * - agent identity * - surfaced scars (accumulated from session_start + recall calls) * * This allows recall() to always assign variants even without explicit parameters. */ import type { SurfacedScar, ScarConfirmation, ScarReflection, Observation, SessionChild, ThreadObject } from "../types/index.js"; interface SessionContext { sessionId: string; linearIssue?: string; agent?: string; project?: string; startedAt: Date; recallCalled: boolean; surfacedScars: SurfacedScar[]; confirmations: ScarConfirmation[]; reflections: ScarReflection[]; observations: Observation[]; children: SessionChild[]; threads: ThreadObject[]; feedbackSubmitCount: number; } /** * Set the current active session * Called by session_start */ export declare function setCurrentSession(context: Omit & { surfacedScars?: SurfacedScar[]; observations?: Observation[]; children?: SessionChild[]; threads?: ThreadObject[]; }): void; /** * Get the current active session * Returns null if no session active */ export declare function getCurrentSession(): SessionContext | null; /** * Clear the current session * Called by session_close */ export declare function clearCurrentSession(): void; /** * Get the active session's project, or null if no session. * Used by list_threads to inherit the correct project default. */ export declare function getProject(): string | null; /** * Check if currently working on a Linear issue */ export declare function hasActiveIssue(): boolean; /** * Mark that recall() was called this session (independent of whether it returned scars). * Called by recall tool before any early return. */ export declare function setRecallCalled(): void; /** * Check if recall() was called this session. * Used by enforcement to avoid false positives when recall returns 0 scars. */ export declare function isRecallCalled(): boolean; /** * Add surfaced scars to tracking (deduplicates by scar_id) * Called by session_start and recall when scars are surfaced. */ export declare function addSurfacedScars(scars: SurfacedScar[]): void; /** * Get all surfaced scars for the current session */ export declare function getSurfacedScars(): SurfacedScar[]; /** * Add scar confirmations (refute-or-obey) to the current session. * Called by confirm_scars tool after validation. */ export declare function addConfirmations(confirmations: ScarConfirmation[]): void; /** * Get all scar confirmations for the current session. */ export declare function getConfirmations(): ScarConfirmation[]; /** * Add end-of-session scar reflections (OBEYED/REFUTED) to the current session. * Called by reflect_scars tool after validation. */ export declare function addReflections(reflections: ScarReflection[]): void; /** * Get all end-of-session scar reflections for the current session. */ export declare function getReflections(): ScarReflection[]; /** * Check if there are recall-surfaced scars that haven't been confirmed. * Only checks scars with source "recall" — session_start scars don't require confirmation. */ export declare function hasUnconfirmedScars(): boolean; /** * v2 Phase 2: Add observations from sub-agents/teammates */ export declare function addObservations(newObs: Observation[]): number; /** * v2 Phase 2: Get all observations for the current session */ export declare function getObservations(): Observation[]; /** * v2 Phase 2: Register a child agent in the current session */ export declare function addChild(child: SessionChild): void; /** * v2 Phase 2: Get all children for the current session */ export declare function getChildren(): SessionChild[]; /** * Compute session activity signals for close type validation. * Returns null if no active session (e.g., recovered from registry). */ export interface SessionActivity { duration_min: number; recall_count: number; observation_count: number; children_count: number; thread_count: number; } export declare function getSessionActivity(): SessionActivity | null; /** * : Set threads for the current session */ export declare function setThreads(threads: ThreadObject[]): void; /** * : Get threads for the current session */ export declare function getThreads(): ThreadObject[]; /** * Get the current feedback submission count for rate limiting. */ export declare function getFeedbackCount(): number; /** * Increment and return the feedback submission count. */ export declare function incrementFeedbackCount(): number; /** * : Resolve a thread in session state by ID. * Returns the resolved thread or null if not found. */ export declare function resolveThreadInState(threadId: string, resolutionNote?: string): ThreadObject | null; export {}; //# sourceMappingURL=session-state.d.ts.map