import type { WorkerDelegationTaskContext } from "../delegation/worker-delegation-request.ts"; import type { GoalState } from "../goals/goal-state.ts"; import type { AttemptUsageSnapshot, HarnessCapability, RiskBudget, WorkerExecutionContract, WorkerRole } from "./contracts.ts"; import { OrchestrationEventStore } from "./event-store.ts"; import { type AttemptRuntimeState, DurableTaskRuntime } from "./task-runtime.ts"; import { type WorkerContextForkReference } from "./worker-context-fork-reference.ts"; export interface DelegationLedgerOptions { agentDir: string; sessionId: string; now?: () => number; store?: OrchestrationEventStore; } export interface PrepareDelegationInput { laneId: string; instructions: string; parentAgentId?: string; executionContract: WorkerExecutionContract; requiredCapabilities: readonly HarnessCapability[]; goal?: GoalState; verificationOfTaskId?: string; taskContext?: WorkerDelegationTaskContext; birthContextForkReference?: WorkerContextForkReference; } export interface PrepareManagedDelegationInput { laneId: string; dispatchSequence: number; instructions: string; profileId: string; provider: string; authorizationId: string; role: WorkerRole; riskBudget: RiskBudget; goal?: GoalState; goalId?: string; worktreeLaneKey?: string; } export interface StartedDelegationAttempt { objectiveId: string; taskId: string; attemptId: string; leaseId: string; fencingToken: number; expiresAt: string; } export interface PrepareAgentTurnInput { agentId: string; instructions: string; controlMessageId?: string; dependsOnTaskIds?: readonly string[]; } /** * Durable adapter for in-process delegated completions. It records the dispatch before execution, * fences interrupted completions on restart, and returns queued work for event-driven re-dispatch. * It deliberately does not pretend an isolated completion has a resumable model transcript. */ export declare class DelegationOrchestrationLedger { readonly runtime: DurableTaskRuntime; private readonly sessionId; constructor(options: DelegationLedgerOptions); prepare(input: PrepareDelegationInput): AttemptRuntimeState; prepareManaged(input: PrepareManagedDelegationInput): AttemptRuntimeState; /** * Queue one new turn for an existing logical agent. The agent identity and its immutable * execution contract are inherited from the last bound turn. Each distinct control message owns * one deterministic task/attempt identity; exact retries adopt it instead of minting new work. */ prepareAgentTurn(input: PrepareAgentTurnInput): AttemptRuntimeState; private prepareNormalized; synchronizeGoalState(goal: GoalState): void; start(attemptId: string, leaseTtlMs: number, ownerId?: string, agentId?: string): StartedDelegationAttempt; cancel(attemptId: string, reasonCode: string): void; /** Latest fenced cumulative usage, if this attempt has crossed a durable checkpoint boundary. */ getAttemptUsage(attemptId: string): AttemptUsageSnapshot | undefined; /** Fence interrupted isolated completions and queue one replacement attempt per task. */ recoverQueuedDispatches(): AttemptRuntimeState[]; } //# sourceMappingURL=delegation-ledger.d.ts.map