/** * Session Tracker feature module. * * Owns session knowledge capture under `.hivemind/session-tracker/`. * Hooks observe OpenCode lifecycle events and route to this module; * the module owns persistence logic and error handling. * * Architecture: Read-side observer (hooks) → SessionTracker → persistence layer. * CQRS compliance: hooks must NEVER write files directly (REQ-ST-11). * * CANONICAL SOURCE: Session-tracker (`.hivemind/session-tracker/`) is the * canonical source for delegation/hierarchy state (REQ-P41D-01). * Continuity's `session-continuity.json` (Q6) is the canonical source for * continuity session state (metadata, lifecycle, delegation meta). * * Event handler logic is extracted to `session-event-handler.ts` (GA-4 ≤500 LOC). * * @module session-tracker */ export type { SessionTrackerConfig, SessionRecord, ChildSessionRecord, SessionContinuityIndex, ProjectContinuityIndex, ProjectSessionEntry, DelegatedBy, MainAgent, Turn, ToolRecord, ChildRef, ChildHierarchyEntry, } from "./types.js"; export { readRawDelegations } from "./read-delegations.js"; export { isValidSessionID, isValidHookPayload } from "./types.js"; export { SessionRecovery } from "./recovery/session-recovery.js"; export type { ReconsumptionResult, SessionContext } from "./recovery/session-recovery.js"; /** * P58 G5: Read the per-session manualOverride state. */ export declare function getManualOverrideState(sessionId: string | undefined): { manualOverride: boolean; takenAt?: number; takenBy?: string; } | undefined; /** * P58 G5: Write the per-session manualOverride state. */ export declare function setManualOverrideState(sessionId: string, state: { manualOverride: boolean; takenAt?: number; takenBy?: string; }): void; import type { OpenCodeClient } from "../../shared/session-api.js"; import type { InitializedDeps } from "./initialization.js"; /** * Central session tracker class. * * Hook callbacks call the public handler methods; each delegates to the * extracted functions in `session-event-handler.ts`. */ export declare class SessionTracker { private client; private projectRoot; private eventCapture; private lastMessageCapture; private messageCapture; private toolCapture; private childWriter; private sessionIndexWriter; private projectIndexWriter; private hierarchyIndex; private pendingRegistry; private manifestWriter; private recovery; private retryQueue; private bootstrap; private classifier; private sessionRouter; private childRecorder; private orphanCleanup; private toolDelegation; private projectContinuityChecker; private bootstrappedSessions; private retryFlushInterval; constructor(deps: { client: OpenCodeClient; projectRoot: string; }); /** Returns the LastMessageCapture instance for event observer wiring. */ getLastMessageCapture(): InitializedDeps["lastMessageCapture"]; /** * Returns the session continuity record for a given session ID. * * Added to support typed `sessionTracker.get()` calls from the sidecar * (eliminates `(sessionTracker as any).get` cast). Delegates to the * continuity store which is the canonical source for session state. * * @param sessionId - The session identifier. * @returns The continuity record, or undefined if not found. */ get(sessionId: string): unknown; /** Builds the handler context for delegation to session-event-handler.ts. */ private ctx; /** Lazy-bootstrap a pre-existing session (idempotent). */ private ensureSessionReady; /** Safely retrieves a session via the SDK client without throwing. */ private getSessionSafely; /** Handles session lifecycle events from the OpenCode `event` hook. */ handleSessionEvent(event: { eventType: string; sessionID: string; event: unknown; }): Promise; /** Handles chat message events from the OpenCode `chat.message` hook. */ handleChatMessage(input: { sessionID: string; agent?: string; model?: { providerID: string; modelID: string; }; messageID?: string; variant?: string; }, output: { message: unknown; parts: unknown[]; }): Promise; /** Handles tool execution events from the OpenCode `tool.execute.after` hook. */ handleToolExecuteAfter(input: { tool: string; sessionID: string; callID: string; args: unknown; }, output: { title: string; output: unknown; metadata: unknown; }): Promise; /** * Ensures a child write can resolve to the root main directory. * * Delegates to `ensureAncestorRoute` from session-event-handler.ts. * Kept as a class method because constructCoreDependencies passes it * as a callback during dependency construction. */ private ensureChildRoute; /** * Handles the tool.execute.before hook — proactive child session discovery. * * Must NOT block tool execution — fire-and-forget polling only. */ handleToolExecuteBefore(params: { sessionID: string; callID: string; subagentType: string; description: string; taskId?: string; tool?: string; }): Promise; /** * Synchronously constructs all session-tracker dependencies. * * Must be called BEFORE delegation wiring so that `onChildSessionCreated` * callbacks immediately find critical deps available (D-01, REQ-01). */ constructCoreDependencies(): void; /** * Initializes the session tracker module. * * Called once during plugin startup. Creates all persistence writers, * capture handlers, and recovery infrastructure. */ initialize(): Promise; /** Performs cleanup when the plugin is shutting down. */ cleanup(): Promise; /** Starts the periodic child-write retry flush loop. */ private startRetryFlushLoop; } //# sourceMappingURL=index.d.ts.map