/** * Shared Working Context Contract. * * Provides a bounded, serializable surface for the operator-visible working context: * - Memory: persisted session state (snapshot-based, current-branch) * - Todo: persisted session state (current branch) * - Delegated work: ephemeral current-process state (explicitly not persisted) * * This contract is the single source of truth for building working-context data * shared between interactive panel, /session output, and RPC get_working_context. */ import type { DelegatedMode, DelegatedStatus, DelegatedWorkSummary } from "./delegated-work.js"; import type { MemoryItem, Task } from "./memory.js"; /** * Memory summary with explicit provenance marker. * Memory is persisted in session snapshots on the current branch. */ export interface WorkingContextMemorySummary { itemCount: number; staleCount: number; keyPreview: string[]; /** Explicit marker: memory is persisted in session snapshots */ isPersisted: true; /** Explicit scope: current branch session state */ scope: "current_branch_session_state"; } /** * Todo summary with explicit provenance marker. * Todos are persisted in session entries on the current branch. */ export interface WorkingContextTodoSummary { total: number; completed: number; inProgress?: string; /** Explicit marker: todos are persisted in session entries */ isPersisted: true; /** Explicit scope: current branch session state */ scope: "current_branch_session_state"; } /** * Delegated work summary with explicit provenance marker. * Delegated work is live current-process runtime state, not persisted. */ export interface WorkingContextDelegatedFailurePreview { agent: string; task: string; mode: DelegatedMode; status: Extract; childIndex?: number; step?: number; exitCode?: number; errorMessage?: string; } export interface WorkingContextDelegatedWorkSummary { activeCount: number; completedCount: number; failedCount: number; activeAgents: string[]; failurePreview: WorkingContextDelegatedFailurePreview[]; /** Explicit marker: delegated work is ephemeral current-process state */ isPersisted: false; /** Explicit scope: current process runtime state */ scope: "current_process_runtime_state"; note: "live current-process state only; not persisted and resets on session switch/resume"; } /** * Task summary with explicit provenance marker. * Tasks are persisted in session entries on the current branch. */ export interface WorkingContextTaskSummary { total: number; pending: number; inProgress: number; completed: number; /** The task currently marked in_progress, if any */ inProgressTask?: { id: string; subject: string; activeForm?: string; }; /** Explicit marker: tasks are persisted in session entries */ isPersisted: true; /** Explicit scope: current branch session state */ scope: "current_branch_session_state"; } /** * Aggregated working context surface. * This is always a current-state summary, not a history surface. */ export interface WorkingContext { /** Memory summary persisted in current-branch session snapshots. */ memory: WorkingContextMemorySummary; /** Todo summary persisted in current-branch session entries. */ todo: WorkingContextTodoSummary; /** Task summary persisted in current-branch session entries. */ tasks: WorkingContextTaskSummary; /** Delegated work summary from live current-process runtime state. */ delegatedWork: WorkingContextDelegatedWorkSummary; } /** * Build a memory summary from memory items. */ export declare function buildWorkingContextMemorySummary(items: readonly MemoryItem[]): WorkingContextMemorySummary; /** * Build a todo summary from todo items. */ export declare function buildWorkingContextTodoSummary(items: ReadonlyArray<{ content: string; activeForm: string; status: string; }>): WorkingContextTodoSummary; /** * Build a delegated work summary from the session's delegated work state. */ export declare function buildWorkingContextDelegatedWorkSummary(summary: DelegatedWorkSummary): WorkingContextDelegatedWorkSummary; /** * Build a task summary from task items. */ export declare function buildWorkingContextTaskSummary(tasks: readonly Task[]): WorkingContextTaskSummary; /** * Build the complete working context from session state. */ export declare function buildWorkingContext(options: { memoryItems: readonly MemoryItem[]; todos: ReadonlyArray<{ content: string; activeForm: string; status: string; }>; tasks: ReadonlyArray; delegatedWorkSummary: DelegatedWorkSummary; }): WorkingContext; //# sourceMappingURL=working-context.d.ts.map