/** * Session handoff computation and persistence. * * Creates structured handoff data when a session ends, containing: * - Last focused task * - Tasks completed and created * - Decisions recorded * - Next suggested tasks * - Open blockers and bugs * - Human override notes * * @task T4915 * @epic T4914 */ import type { SessionHandoffShowParams } from '@cleocode/contracts'; /** * Handoff data schema - structured state for session transition. */ export interface HandoffData { /** Last task being worked on */ lastTask: string | null; /** Tasks completed in session */ tasksCompleted: string[]; /** Tasks created in session */ tasksCreated: string[]; /** Count of decisions recorded */ decisionsRecorded: number; /** Top-3 from tasks.next */ nextSuggested: string[]; /** Tasks with blockers */ openBlockers: string[]; /** Open bugs */ openBugs: string[]; /** Human override note */ note?: string; /** Human override next action */ nextAction?: string; } /** * Options for computing handoff data. */ export interface ComputeHandoffOptions { sessionId: string; /** Optional human note override */ note?: string; /** Optional human next action override */ nextAction?: string; } /** * Compute handoff data for a session. * Gathers all session statistics and auto-computes structured state. */ export declare function computeHandoff(projectRoot: string, options: ComputeHandoffOptions): Promise; /** * Persist handoff data to a session (write-once, append-only). * * Writes the handoff JSON into `session_handoff_entries` via an INSERT. * The table enforces write-once semantics at the SQL level: * - A UNIQUE constraint on `session_id` rejects duplicate calls. * - A BEFORE UPDATE trigger makes rows physically immutable. * - An AFTER INSERT trigger mirrors the value to `sessions.handoff_json` * so all existing read paths continue to work without modification. * * Throws `CleoError(SESSION_NOT_FOUND)` when the session does not exist. * Throws `CleoError(HANDOFF_ALREADY_PERSISTED)` when a handoff was already * written for this session (surfaced from the UNIQUE constraint violation). * * @task T1609 */ export declare function persistHandoff(projectRoot: string, sessionId: string, handoff: HandoffData): Promise; /** * Get handoff data for a session. */ export declare function getHandoff(projectRoot: string, sessionId: string): Promise; /** * Get handoff data for the most recent ended session. * Filters by scope if provided. */ export declare function getLastHandoff(projectRoot: string, scope?: { type: string; epicId?: string; rootTaskId?: string; }): Promise<{ sessionId: string; handoff: HandoffData; } | null>; /** * Git state snapshot captured at session end. */ export interface GitState { branch: string; commitCount: number; lastCommitHash: string | null; uncommittedChanges: boolean; } /** * Decision summary for debrief output. */ export interface DebriefDecision { id: string; decision: string; rationale: string; taskId: string; } /** * Rich debrief data — superset of HandoffData. * Captures comprehensive session state for cross-conversation continuity. * * @epic T4959 */ export interface DebriefData { /** Standard handoff data (backward compat). */ handoff: HandoffData; /** Session that produced this debrief. */ sessionId: string; /** Agent/conversation identifier (if known). */ agentIdentifier: string | null; /** Session start time. */ startedAt: string; /** Session end time. */ endedAt: string; /** Duration in minutes. */ durationMinutes: number; /** Decisions made during the session. */ decisions: DebriefDecision[]; /** Git state at session end (best-effort). */ gitState: GitState | null; /** Position in the session chain (1-based). */ chainPosition: number; /** Total length of the session chain. */ chainLength: number; } /** * Options for computing debrief data. */ export interface ComputeDebriefOptions extends ComputeHandoffOptions { /** Agent/conversation identifier. */ agentIdentifier?: string | null; /** Session start time. */ startedAt?: string; /** Session end time. */ endedAt?: string; } /** * Compute rich debrief data for a session. * Builds on computeHandoff() and adds decisions, git state, chain position. * * @epic T4959 */ export declare function computeDebrief(projectRoot: string, options: ComputeDebriefOptions): Promise; /** * Normalized Core entry point for session.handoff.show dispatch op. * Converts the wire-format scope string to the internal scope object, * then delegates to getLastHandoff. * @task T1450 */ export declare function sessionHandoffShow(projectRoot: string, params: SessionHandoffShowParams): Promise<{ sessionId: string; handoff: HandoffData; } | null>; //# sourceMappingURL=handoff.d.ts.map