declare const XENO_COORDINATION_SCHEMA_VERSION: 1; declare const XENO_COORDINATION_MANAGED_SESSION_SCHEMA_VERSION: 2; declare const XENO_COORDINATION_BUDGET_SESSION_SCHEMA_VERSION: 3; declare const XENO_COORDINATION_TURN_SESSION_SCHEMA_VERSION: 4; type XenoGoalStatus = "active" | "paused" | "waiting" | "blocked" | "completed" | "failed" | "cancelled"; type XenoGoalTaskStatus = "pending" | "ready" | "running" | "blocked" | "failed" | "completed" | "cancelled" | "interrupted"; interface XenoGoalCriterion { id: string; description: string; required: boolean; } interface XenoGoalCriterionResult { criterionId: string; satisfied: boolean; evidence: string[]; reason: string; evaluatedAt: string; } interface XenoGoalVerification { status: "pending" | "running" | "passed" | "failed"; criteria: XenoGoalCriterionResult[]; evidence: string[]; summary?: string; verifiedAt?: string; verifiedBy?: string; } interface XenoGoalTask { id: string; milestoneId: string; parentTaskId?: string; title: string; description?: string; status: XenoGoalTaskStatus; assignedAgentId?: string; dependsOn?: string[]; progress?: string; resultEventId?: string; createdAt: string; updatedAt: string; completedAt?: string; } interface XenoGoalMilestone { id: string; title: string; description?: string; status: "pending" | "active" | "blocked" | "completed" | "cancelled"; taskIds: string[]; createdAt: string; updatedAt: string; completedAt?: string; } interface XenoGoalProgress { summary: string; currentMilestoneId?: string; currentTaskId?: string; completedTaskCount: number; totalTaskCount: number; percent?: number; outstanding: string[]; decisions: string[]; updatedAt: string; } interface XenoGoalRecord { schemaVersion: typeof XENO_COORDINATION_SCHEMA_VERSION; id: string; version: number; sessionId: string; objective: string; why?: string; successCriteria: XenoGoalCriterion[]; constraints: string[]; limits?: { maxIterations?: number; maxTokens?: number; maxWallClockMs?: number; }; metadata: Record; status: XenoGoalStatus; milestones: XenoGoalMilestone[]; tasks: XenoGoalTask[]; progress: XenoGoalProgress; verification: XenoGoalVerification; steering: Array<{ id: string; instruction: string; createdAt: string; consumedAt?: string; }>; createdAt: string; updatedAt: string; completedAt?: string; } type XenoLoopKind = "agentic-development" | "goal-continuation" | "scheduled"; type XenoLoopStatus = "running" | "paused" | "waiting" | "stopped" | "completed" | "failed"; interface XenoLoopSchedule { kind: "fixed-interval" | "dynamic"; intervalMs?: number; nextRunAt?: string; expiresAt?: string; } interface XenoLoopIteration { number: number; startedAt: string; completedAt?: string; status: "running" | "completed" | "failed" | "interrupted"; activity: string; taskId?: string; verificationEventId?: string; error?: string; goalTurn?: { requestId: string; requestHash: string; executor: { kind: "local-sdk"; processId: number; host: string; } | { kind: "external"; }; }; goalAccountingVersion?: 1; } interface XenoGoalTurnRequest { sessionId: string; goalId: string; expectedGoalVersion: number; expectedLoopId?: string; expectedLoopVersion?: number; requestId: string; requestHash: string; executionKind?: "local-sdk" | "external"; } interface XenoGoalTurnState { goal: XenoGoalRecord; admittedTurns: number; accountingCoverage: "complete" | "partial"; loopId?: string; loopVersion?: number; loopStatus?: XenoLoopStatus; requestId?: string; requestHash?: string; iterationNumber?: number; iterationStatus?: XenoLoopIteration["status"]; resumeRequested?: boolean; canRecover?: boolean; } interface XenoGoalTurnAdmission extends XenoGoalTurnState { admitted: boolean; } interface XenoLoopRecord { schemaVersion: typeof XENO_COORDINATION_SCHEMA_VERSION; id: string; version: number; sessionId: string; goalId?: string; kind: XenoLoopKind; status: XenoLoopStatus; currentActivity?: string; resumeRequested?: boolean; iterations: XenoLoopIteration[]; schedule?: XenoLoopSchedule; stopReason?: string; createdAt: string; updatedAt: string; stoppedAt?: string; } type XenoHandoffStatus = "prepared" | "available" | "claimed" | "completed" | "failed" | "cancelled"; interface XenoHandoffOperation { operationId: string; kind: "tool" | "command" | "build" | "subagent" | "other"; status: "running" | "completed" | "interrupted"; sideEffecting: boolean; recovery: "waited" | "resume" | "retry" | "manual"; } interface XenoHandoffRecord { schemaVersion: typeof XENO_COORDINATION_SCHEMA_VERSION; id: string; version: number; sessionId: string; goalId?: string; loopId?: string; status: XenoHandoffStatus; sourceOwnerId: string; targetOwnerId?: string; claimedBy?: string; claimRequestId?: string; prepareRequestId?: string; sourceLeaseEpoch: number; targetLeaseEpoch?: number; workspace?: string; branch?: string; currentMilestoneId?: string; currentTaskId?: string; agentIds: string[]; operations: XenoHandoffOperation[]; contextDigest?: string; createdAt: string; updatedAt: string; claimedAt?: string; completedAt?: string; failedAt?: string; failureReason?: string; } interface XenoExecutionOwner { ownerId: string; leaseId: string; epoch: number; acquiredAt: string; heartbeatAt: string; expiresAt: string; processId?: number; host?: string; } type XenoCoordinationEventType = "goal.created" | "goal.updated" | "goal.steered" | "goal.completed" | "goal.cancelled" | "loop.started" | "loop.iteration" | "loop.paused" | "loop.waiting" | "loop.resumed" | "loop.stopped" | "loop.completed" | "loop.failed" | "handoff.created" | "handoff.claimed" | "handoff.completed" | "handoff.failed" | "ownership.acquired" | "admission.fenced" | "admission.restored" | "ownership.renewed" | "ownership.released"; interface XenoCoordinationEvent { schemaVersion: typeof XENO_COORDINATION_SCHEMA_VERSION; id: string; sequence: number; type: XenoCoordinationEventType; sessionId: string; goalId?: string; loopId?: string; handoffId?: string; ownerId?: string; timestamp: string; data: Record; } interface XenoCoordinationSessionState { schemaVersion: typeof XENO_COORDINATION_SCHEMA_VERSION | typeof XENO_COORDINATION_MANAGED_SESSION_SCHEMA_VERSION | typeof XENO_COORDINATION_BUDGET_SESSION_SCHEMA_VERSION | typeof XENO_COORDINATION_TURN_SESSION_SCHEMA_VERSION; sessionId: string; version: number; ownershipEpoch: number; admissionFence?: XenoCoordinationAdmissionFence; owner?: XenoExecutionOwner; goals: XenoGoalRecord[]; goalTurnAccounting?: Record; loops: XenoLoopRecord[]; handoffs: XenoHandoffRecord[]; events: XenoCoordinationEvent[]; createdAt: string; updatedAt: string; } interface XenoCoordinationAdmissionFence { schemaVersion: 1; authorityId: string; operationId: string; action: "archive" | "delete"; createdAt: string; } interface XenoCoordinationStoreOptions { rootDirectory?: string; now?: () => string; idFactory?: (prefix: string) => string; ownerLeaseMs?: number; lockTimeoutMs?: number; lockStaleMs?: number; maximumEventsPerSession?: number; } interface CreateXenoGoalInput { sessionId: string; objective: string; why?: string; successCriteria?: Array & { id?: string; }>; constraints?: string[]; limits?: XenoGoalRecord["limits"]; metadata?: Record; } interface CreateXenoHandoffInput { sessionId: string; sourceOwnerId: string; sourceLeaseId: string; prepareRequestId?: string; goalId?: string; loopId?: string; targetOwnerId?: string; workspace?: string; branch?: string; currentMilestoneId?: string; currentTaskId?: string; agentIds?: string[]; operations?: XenoHandoffOperation[]; contextDigest?: string; } declare class XenoCoordinationError extends Error { readonly code: "INVALID" | "NOT_FOUND" | "CONFLICT" | "NOT_OWNER" | "LEASE_EXPIRED" | "BUDGET_EXCEEDED" | "BUDGET_UNAVAILABLE" | "UNSAFE_HANDOFF" | "VERIFICATION_REQUIRED"; readonly details: Record; constructor(code: "INVALID" | "NOT_FOUND" | "CONFLICT" | "NOT_OWNER" | "LEASE_EXPIRED" | "BUDGET_EXCEEDED" | "BUDGET_UNAVAILABLE" | "UNSAFE_HANDOFF" | "VERIFICATION_REQUIRED", message: string, details?: Record); } interface UpdateXenoGoalInput { objective?: string; why?: string; constraints?: string[]; successCriteria?: XenoGoalCriterion[]; status?: Exclude; progress?: Partial>; verification?: XenoGoalVerification; metadata?: Record; } interface StartXenoLoopInput { sessionId: string; goalId?: string; kind: XenoLoopKind; activity?: string; schedule?: XenoLoopSchedule; } interface ClaimXenoHandoffInput { sessionId: string; handoffId: string; targetOwnerId: string; processId?: number; host?: string; leaseMs?: number; claimRequestId?: string; } declare class DurableXenoCoordinationStore { get goalTurnAdmissionVersion(): 1; private readonly rootDirectory; private readonly now; private readonly idFactory; private readonly ownerLeaseMs; private readonly lockTimeoutMs; private readonly lockStaleMs; private readonly maximumEventsPerSession; constructor(options?: XenoCoordinationStoreOptions); getSessionState(sessionId: string): Promise; fenceAdmission(sessionId: string, expectedVersion: number, input: Omit): Promise; clearAdmissionFence(sessionId: string, expectedVersion: number, authorityId: string, operationId: string): Promise; releaseDeadLifecycleOwner(sessionId: string, expectedVersion: number, authorityId: string, operationId: string): Promise; listSessionStates(): Promise; createGoal(input: CreateXenoGoalInput): Promise; getGoal(sessionId: string, goalId?: string): Promise; updateGoal(sessionId: string, goalId: string, expectedVersion: number, update: UpdateXenoGoalInput): Promise; addMilestone(sessionId: string, goalId: string, expectedVersion: number, input: { title: string; description?: string; }): Promise; addTask(sessionId: string, goalId: string, expectedVersion: number, input: { milestoneId: string; parentTaskId?: string; title: string; description?: string; assignedAgentId?: string; dependsOn?: string[]; }): Promise; updateTask(sessionId: string, goalId: string, taskId: string, expectedVersion: number, update: Pick & Partial>): Promise; steerGoal(sessionId: string, goalId: string, expectedVersion: number, instruction: string): Promise; consumeGoalSteering(sessionId: string, goalId: string, expectedVersion: number): Promise<{ goal: XenoGoalRecord; instructions: Array<{ id: string; instruction: string; createdAt: string; }>; }>; completeGoal(sessionId: string, goalId: string, expectedVersion: number, verification: XenoGoalVerification): Promise; cancelGoal(sessionId: string, goalId: string, expectedVersion: number, reason: string): Promise; startLoop(input: StartXenoLoopInput): Promise; private createLoopRecord; getLoop(sessionId: string, loopId?: string): Promise; beginLoopIteration(sessionId: string, loopId: string, expectedVersion: number, activity: string, taskId?: string): Promise; private appendLoopIteration; admitGoalTurn(input: XenoGoalTurnRequest): Promise; admitOwnedGoalTurn(input: XenoGoalTurnRequest, authority: Pick): Promise; private admitGoalTurnWithOwner; getGoalTurnState(sessionId: string, goalId?: string, requestId?: string): Promise; finishGoalTurn(input: Omit & { status: "completed" | "failed" | "interrupted"; }): Promise; recoverGoalTurn(sessionId: string, goalId: string, requestId: string): Promise; finishLoopIteration(sessionId: string, loopId: string, expectedVersion: number, result: { status: "completed" | "failed" | "interrupted"; verificationEventId?: string; error?: string; nextStatus?: Extract; }): Promise; private settleLoopIteration; setLoopStatus(sessionId: string, loopId: string, expectedVersion: number, status: Extract, reason?: string): Promise; acquireOwnership(sessionId: string, ownerId: string, options?: { processId?: number; host?: string; leaseMs?: number; }): Promise; renewOwnership(sessionId: string, ownerId: string, leaseId: string, leaseMs?: number): Promise; releaseOwnership(sessionId: string, ownerId: string, leaseId: string): Promise; createHandoff(input: CreateXenoHandoffInput): Promise; claimHandoff(input: ClaimXenoHandoffInput): Promise<{ handoff: XenoHandoffRecord; owner: XenoExecutionOwner; }>; completeHandoff(sessionId: string, handoffId: string, ownerId: string, leaseId: string): Promise; failHandoff(sessionId: string, handoffId: string, reason: string): Promise; private mutateGoal; private mutateLoop; private assertGoalIterationAdmission; private isCliGoal; private goalIterationCount; private resolveGoalTurnAccounting; private initializeGoalTurnAccounting; private goalTurnHash; private goalTurnState; private goalTurnOwnerExited; private recalculateProgress; private requireGoal; private requireOwner; private assertVersion; private newOwner; private ownerExpired; private appendEvent; private mutate; private statePath; private lockPath; private readState; private promoteGoalBudgetEnvelope; private writeState; private renameReplacing; private withSessionLock; private staleLockOwner; private quarantineLock; } type XenoCoordinationAction = "state.get" | "goal.create" | "goal.update" | "goal.complete" | "goal.cancel" | "goal.steer" | "loop.start" | "loop.get" | "loop.begin" | "loop.finish" | "loop.set_status" | "ownership.acquire" | "ownership.renew" | "ownership.release" | "handoff.create" | "handoff.claim" | "handoff.complete" | "handoff.fail"; interface ExecuteXenoCoordinationActionInput { action: XenoCoordinationAction; sessionId: string; payload?: Record; } interface ExecuteXenoCoordinationActionResult { action: XenoCoordinationAction; sessionId: string; result: unknown; state: XenoCoordinationSessionState; event?: XenoCoordinationEvent; } declare function executeXenoCoordinationAction(store: DurableXenoCoordinationStore, input: ExecuteXenoCoordinationActionInput): Promise; type XenoExecutionLeaseStore = Pick; interface XenoExecutionLeaseSessionOptions { store?: XenoExecutionLeaseStore; sessionId: string; ownerId?: string; processId?: number; host?: string; leaseMs?: number; heartbeatMs?: number; claimHandoffId?: string; claimRequestId?: string; prepareDestination?: (input: { handoff: XenoHandoffRecord; signal: AbortSignal; }) => Promise; destinationTimeoutMs?: number; onOwnershipLost?: (error: unknown) => void; } declare class XenoExecutionLeaseSession { readonly sessionId: string; readonly ownerId: string; private readonly store; private readonly processId; private readonly host; private readonly leaseMs; private readonly heartbeatMs; private readonly claimHandoffId?; private readonly claimRequestId?; private readonly onOwnershipLost?; private readonly prepareDestination?; private readonly destinationTimeoutMs; private readonly initializationAbort; private timer?; private heartbeatInFlight; private owner?; private ready; private starting?; private stopping?; private stopped; private lostError?; private preparedHandoffId?; private preparingHandoff; private handoffOutcomeUncertain; constructor(options: XenoExecutionLeaseSessionOptions); get currentOwner(): XenoExecutionOwner | undefined; get active(): boolean; start(): Promise; private initialize; private prepareClaimedDestination; assertOwned(): Promise; private assertExecutionAllowed; private renewHeldLease; prepareHandoff(input?: Omit): Promise; stop(options?: { release?: boolean; }): Promise; private finishStop; private heartbeat; private markLost; } interface XenoHandoffStatusInput { sessionId: string; handoffId: string; sinceRevision?: string; waitMs?: number; signal?: AbortSignal; } interface XenoHandoffStatusReceipt { sessionId: string; handoffId: string; revision: string; changed: boolean; status: XenoHandoffRecord["status"]; handoffVersion: number; ownershipEpoch: number; sourceOwnerId: string; targetOwnerId?: string; } declare function waitForXenoHandoffStatus(store: Pick, input: XenoHandoffStatusInput): Promise; interface XenoHandoffSnapshotFile { path: string; size: number; sha256: string; executable: boolean; } interface XenoHandoffSnapshotManifest { schemaVersion: 1; sessionId: string; files: XenoHandoffSnapshotFile[]; totalBytes: number; digest: string; } interface XenoHandoffSnapshot { manifest: XenoHandoffSnapshotManifest; blobs: ReadonlyMap; } declare function captureXenoHandoffSnapshot(input: { root: string; sessionId: string; paths: readonly string[]; authorizeFile(path: string): boolean | Promise; signal?: AbortSignal; }): Promise; declare function restoreXenoHandoffSnapshot(input: { destination: string; sessionId: string; manifest: XenoHandoffSnapshotManifest; authorizeManifest(manifest: XenoHandoffSnapshotManifest): boolean | Promise; readBlob(sha256: string, expectedBytes: number): Promise; signal?: AbortSignal; }): Promise<{ directory: string; digest: string; files: number; bytes: number; }>; export { type ClaimXenoHandoffInput, type CreateXenoGoalInput, type CreateXenoHandoffInput, DurableXenoCoordinationStore, type ExecuteXenoCoordinationActionInput, type ExecuteXenoCoordinationActionResult, type StartXenoLoopInput, type UpdateXenoGoalInput, XENO_COORDINATION_BUDGET_SESSION_SCHEMA_VERSION, XENO_COORDINATION_MANAGED_SESSION_SCHEMA_VERSION, XENO_COORDINATION_SCHEMA_VERSION, XENO_COORDINATION_TURN_SESSION_SCHEMA_VERSION, type XenoCoordinationAction, type XenoCoordinationAdmissionFence, XenoCoordinationError, type XenoCoordinationEvent, type XenoCoordinationEventType, type XenoCoordinationSessionState, type XenoCoordinationStoreOptions, XenoExecutionLeaseSession, type XenoExecutionLeaseSessionOptions, type XenoExecutionLeaseStore, type XenoExecutionOwner, type XenoGoalCriterion, type XenoGoalCriterionResult, type XenoGoalMilestone, type XenoGoalProgress, type XenoGoalRecord, type XenoGoalStatus, type XenoGoalTask, type XenoGoalTaskStatus, type XenoGoalTurnAdmission, type XenoGoalTurnRequest, type XenoGoalTurnState, type XenoGoalVerification, type XenoHandoffOperation, type XenoHandoffRecord, type XenoHandoffSnapshot, type XenoHandoffSnapshotFile, type XenoHandoffSnapshotManifest, type XenoHandoffStatus, type XenoHandoffStatusInput, type XenoHandoffStatusReceipt, type XenoLoopIteration, type XenoLoopKind, type XenoLoopRecord, type XenoLoopSchedule, type XenoLoopStatus, captureXenoHandoffSnapshot, executeXenoCoordinationAction, restoreXenoHandoffSnapshot, waitForXenoHandoffStatus };