import type { ConversationRef, ExternalPrincipalKey, ModelRouteRef } from './types.js'; /** This is an operation journal, not another Agent or task scheduler. */ export type RestartStatus = 'requested' | 'checkpoint' | 'ready' | 'restarting' | 'restarted' | 'resuming' | 'completed' | 'failed' | 'cancelled'; export interface RestartBindingSnapshot { id: string; version: number; generation: number; sessionId: string; workspace: string; preset: string; policyRef: string; authorityHash: string; conversation: ConversationRef; principal: ExternalPrincipalKey; } export interface RestartTaskInput { inboxId: string; eventId: string; binding: RestartBindingSnapshot; owner: { principalRecordId: string; principalVersion: number; }; /** The exact invocation that admitted the original foreground task. */ sourceInvocationId: string; maxModelRequests: number; maxToolCalls: number; maxOutputTokens: number; capabilityDigest: string; deadline: number; } export interface RestartTask extends RestartTaskInput { createdAt: number; model?: ModelRouteRef; modelRequests: number; toolCalls: number; } export interface RestartCheckpoint { sessionEventCount: number; sessionDigest: string; continuationMessageId: string; continuationTextDigest: string; } export interface RestartRecord { id: string; inboxId: string; requestKey: string; reason: string; status: RestartStatus; sourceInvocationId: string; restartInvocationId?: string; restartHolderId?: string; continuationHolderId?: string; checkpoint?: RestartCheckpoint; failureCode?: string; createdAt: number; updatedAt: number; } export type RestartStoreErrorCode = 'invalid' | 'conflict' | 'not-found' | 'deadline' | 'budget' | 'corrupt' | 'closed'; export declare class RestartStoreError extends Error { readonly code: RestartStoreErrorCode; constructor(code: RestartStoreErrorCode, message: string); } interface RestartStoreOptions { path: string; now?: () => number; readOnly?: boolean; } export declare class RestartStore { private readonly database; private readonly now; private readonly readOnly; private closed; constructor(options: RestartStoreOptions); private assertOpen; private write; private task; getTask(inboxId: string): RestartTask | undefined; private ineligibility; private markIneligibleWithinWrite; markIneligible(inboxId: string, reason: string): void; isEligible(inboxId: string): boolean; beginTask(input: RestartTaskInput): RestartTask; captureModel(inboxId: string, input: ModelRouteRef): RestartTask; /** A supplier change ends recovery eligibility without interrupting normal work. */ observeModel(inboxId: string, input: ModelRouteRef): RestartTask; /** Normal foreground calls are observed durably, even after recovery becomes impossible. */ observe(inboxId: string, kind: 'model' | 'tool', operationId: string): RestartTask; /** A held request/tool reservation is never refunded after an unknown result. */ reserve(inboxId: string, kind: 'model' | 'tool', operationId: string): RestartTask; private requestById; getRequest(id: string): RestartRecord | undefined; getRequestForTask(inboxId: string): RestartRecord | undefined; request(inboxId: string, input: { reason: string; requestKey: string; }): RestartRecord; private event; private transition; checkpoint(id: string, input: RestartCheckpoint): RestartRecord; ready(id: string): RestartRecord; claimRestart(id: string, input: { holderId: string; invocationId: string; }): RestartRecord; /** Observation only: this never grants another restart dispatch. */ markRestarted(id: string, input: { invocationId: string; }): RestartRecord; claimContinuation(id: string, input: { holderId: string; invocationId: string; }): RestartRecord; complete(id: string): RestartRecord; fail(id: string, code: string): RestartRecord; cancelForBinding(bindingId: string): RestartRecord[]; listRequests(input?: { statuses?: readonly RestartStatus[]; limit?: number; after?: { createdAt: number; id: string; }; }): RestartRecord[]; /** Count durable restart dispatch claims for an external global circuit breaker. */ countDispatchedSince(sinceMs: number): number; hasReservation(inboxId: string, kind: 'model' | 'tool', operationId: string): boolean; activeRequestForBinding(bindingId: string): RestartRecord | undefined; close(): void; } export {}; //# sourceMappingURL=restart-store.d.ts.map