/** * Durable Child AgentSession Restore (2.6.0). * * Closes the boundary between a durable delegated child *mission* and a durable * child *AgentSession*. A delegated child no longer executes through the * ephemeral `--no-session` path: it acquires a stable `childSessionId` (stored * on the immutable MissionRequest) BEFORE external execution, persists its * conversation/todo/memory/evidence state through the standard SessionManager, * binds that session to exactly one mission, and can be explicitly resumed * after process interruption as the SAME mission + SAME session with a NEW * execution attempt. * * Invariants: * - child process lifetime != child AgentSession lifetime != child mission lifetime. * - resume != rerun from scratch. * - The DurableMissionStore remains the authority for mission lifecycle and * terminal result; the session can never fabricate SUCCEEDED. */ import { type MissionContextCheckpoint } from "../context-runtime/index.js"; import type { DurableMissionDelegator } from "../durable-delegation/durable-delegation.js"; import type { DurableMissionRecord, DurableMissionStore } from "../mission-domain/durable-store.js"; import type { MissionExecutor } from "../mission-domain/mission-executor.js"; import { type ProcessMissionLaunch, type ProcessMissionVerifier } from "../mission-domain/process-mission-executor.js"; import { type ChildMissionBinding, SessionManager } from "../session-manager.js"; export type { ChildMissionBinding } from "../session-manager.js"; /** Dedicated directory for durable child AgentSessions (discoverable by id). */ export declare function defaultChildSessionDir(agentDir?: string): string; export type ChildSessionRestoreErrorCode = "MISSION_NOT_FOUND" | "MISSION_CORRUPT" | "MISSION_NOT_RESUMABLE" | "MISSION_TERMINAL" | "NOT_A_DURABLE_CHILD" | "CHILD_SESSION_NOT_FOUND" | "CHILD_SESSION_CORRUPT" | "CHILD_SESSION_BINDING_MISMATCH"; export declare class ChildSessionRestoreError extends Error { readonly code: ChildSessionRestoreErrorCode; readonly details: Record; constructor(code: ChildSessionRestoreErrorCode, message: string, details?: Record); } /** * Establish or validate the durable child session<->mission binding. * * On first execution no binding exists: it is persisted (identity correlation * only, never mission state). On restore the binding must already match; * otherwise the load fails closed and the session is never silently rebound. */ export declare function bindChildSession(sessionManager: SessionManager, missionId: string, parentMissionId?: string): ChildMissionBinding; export interface ResolvedChildSession { record: DurableMissionRecord; sessionManager: SessionManager; childSessionId: string; binding: ChildMissionBinding; } /** * Load a durable child mission and resolve + validate its bound AgentSession. * * Fails conservatively (never fabricates or rebinds) for: missing/corrupt * mission, terminal mission, mission without a durable child session id, missing * session file, corrupt session file, or a binding mismatch. */ export declare function resolveChildSessionForResume(options: { store: DurableMissionStore; missionId: string; sessionDir?: string; }): Promise; /** * Rebuild a bounded operational checkpoint from the durable session state plus * the immutable mission request. This is the same projection the live * ContextGovernor uses; here it is rebuilt from a cold SessionManager so a * resumed child continues the same mission rather than replaying it. */ export declare function buildChildResumeCheckpoint(record: DurableMissionRecord, sessionManager: SessionManager): MissionContextCheckpoint; /** The explicit-resume prompt a child receives to CONTINUE rather than replay. */ export declare function buildChildResumePrompt(record: DurableMissionRecord, sessionManager: SessionManager): string; export interface ResumeChildMissionOptions { store: DurableMissionStore; missionId: string; sessionDir?: string; /** Builds the concrete child CLI launch for the resume execution attempt. */ buildResumeLaunch: (input: { request: DurableMissionRecord["request"]; resumePrompt: string; childSessionId: string; }) => ProcessMissionLaunch; /** Executor identity (tests). */ executorId?: string; /** Optional verifier that can promote a clean exit-0 child to SUCCEEDED. */ verifier?: ProcessMissionVerifier; /** Attempt identity factory (tests). */ attemptIdFactory?: () => string; now?: () => number; } export interface BuiltChildResume { childSessionId: string; resumePrompt: string; executor: MissionExecutor; } /** * Build the continue-not-replay child executor from a resolved session. This is * the single executor-construction path shared by the direct resume helper and * the Mission Control plane, so the two can never drift in how a resume launch * is produced. */ export declare function buildChildResumeExecutor(options: { record: DurableMissionRecord; sessionManager: SessionManager; childSessionId: string; buildResumeLaunch: ResumeChildMissionOptions["buildResumeLaunch"]; executorId?: string; verifier?: ProcessMissionVerifier; }): BuiltChildResume; /** * Explicitly resume an interrupted durable child to terminal state. * * Resolves the SAME mission + SAME session, validates the binding, builds a * continue-not-replay prompt from the durable checkpoint, and drives the * coordinator to allocate a NEW attempt/execution before launching the child. */ export declare function resumeChildMission(delegator: DurableMissionDelegator, options: ResumeChildMissionOptions): Promise>; //# sourceMappingURL=child-session-restore.d.ts.map