import { type AgentBindingContract, type ApprovalOutcome, type ApprovalRequestContract, type AttemptCheckpoint, type AttemptLease, type AttemptRetryState, type EvidenceContract, type ExecutionGrant, type ObjectiveContract, type OrchestrationDispatchRequest, type TaskContract, type WorkerResultContract } from "./contracts.ts"; import { type OrchestrationEventStore } from "./event-store.ts"; import { type VerificationTransitionInput } from "./task-runtime-reducer.ts"; import { type ApprovalRuntimeState, type AttemptDispatchReadiness, type AttemptRuntimeState, type CreateObjectiveInput, type CreateTaskInput, type NotificationRuntimeState, type OrchestrationProjectionCapacity, type OrchestrationProjectionHeadroomRequest, type PreparedTaskAttempt, type RegisterAgentInput, type TaskRuntimeProjection, type TaskRuntimeState } from "./task-runtime-state.ts"; export { validateTaskDependencyIds } from "./task-runtime-codecs.ts"; export { projectOrchestrationEvents, reduceOrchestrationEvent, } from "./task-runtime-reducer.ts"; export { type ApprovalRuntimeState, type AttemptDispatchReadiness, type AttemptRuntimeState, type CreateObjectiveInput, type CreateTaskInput, DurableTaskRuntimeError, type NotificationRuntimeState, type ObjectiveRuntimeState, type OrchestrationProjectionCapacity, type OrchestrationProjectionHeadroomRequest, type OrchestrationProjectionSlotCounts, type PreparedTaskAttempt, type RegisterAgentInput, type TaskRuntimeProjection, type TaskRuntimeState, } from "./task-runtime-state.ts"; export interface DurableTaskRuntimeOptions { store: OrchestrationEventStore; now?: () => number; createId?: () => string; } export declare class DurableTaskRuntime { private readonly store; private readonly now; private readonly createId; private state; constructor(options: DurableTaskRuntimeOptions); getSnapshot(): TaskRuntimeProjection; /** Read-only retained-record counts and remaining lifetime slots for orchestration admission. */ getProjectionCapacity(): OrchestrationProjectionCapacity; /** * Preflight every record needed by a multi-event operation before its first append. Callers use * this to reserve implementation and mandatory-verifier task/attempt pairs atomically. */ assertProjectionHeadroom(required: OrchestrationProjectionHeadroomRequest): OrchestrationProjectionCapacity; /** * Preflight the idempotent evidence batch for one objective before synchronizing any member. * The objective may be absent when its creation is part of the same compound operation. */ assertObjectiveEvidenceHeadroom(objectiveId: string, evidenceIds: readonly string[]): number; /** * Preflight the final retained objective record for a multi-event owner synchronization. This * validates the objective metadata and the complete idempotently merged evidence batch before * ensureObjective can append the first event, so a later byte rejection cannot leave a prefix. */ assertObjectiveSynchronizationHeadroom(input: CreateObjectiveInput & { objectiveId: string; }, evidence: readonly EvidenceContract[]): void; registerAgent(input: RegisterAgentInput): AgentBindingContract; /** * Retire one idle persistent identity without deleting its binding, lineage, transcript pointers, * or attempt history. A repeated call is inert and returns the durable retired binding. */ retireAgent(agentId: string): AgentBindingContract; createObjective(input: CreateObjectiveInput): ObjectiveContract; /** Create or synchronize owner-authored objective metadata without disturbing lifecycle or task state. */ ensureObjective(input: CreateObjectiveInput & { objectiveId: string; }): ObjectiveContract; recordObjectiveEvidence(objectiveId: string, evidence: EvidenceContract): EvidenceContract; createTask(input: CreateTaskInput): TaskContract; /** Atomically create a new task and its first queued attempt in one durable transition. */ prepareTaskAttempt(input: CreateTaskInput, dispatch: OrchestrationDispatchRequest, grantId?: string): PreparedTaskAttempt; queueAttempt(taskId: string, dispatch: OrchestrationDispatchRequest, grantId?: string): AttemptRuntimeState; /** Read-only controller seam for deciding whether one durable queued or suspended attempt may run. */ getAttemptDispatchReadiness(attemptId: string): AttemptDispatchReadiness; bindAttemptGrant(attemptId: string, grant: ExecutionGrant): AttemptRuntimeState; leaseAttempt(attemptId: string, ownerId: string, ttlMs: number, agentId?: string): AttemptLease; startAttempt(attemptId: string, leaseId: string, fencingToken: number): AttemptRuntimeState; renewAttemptLease(attemptId: string, leaseId: string, fencingToken: number, ttlMs: number): AttemptLease; checkpointAttempt(args: { attemptId: string; leaseId: string; fencingToken: number; summary: string; artifactIds?: readonly string[]; evidenceIds?: readonly string[]; usage?: AttemptCheckpoint["usage"]; }): AttemptCheckpoint; finishAttempt(result: WorkerResultContract): AttemptRuntimeState; finishVerification(args: VerificationTransitionInput): TaskRuntimeState; cancelAttempt(attemptId: string, reasonCode: string): AttemptRuntimeState; /** * The only runtime suspension transition. Callers must present the exact current owner and lease * fence; liveness/restart policy stays outside this deterministic runtime. */ suspendBoundAttempt(args: { attemptId: string; ownerId: string; leaseId: string; fencingToken: number; reasonCode: string; retry?: AttemptRetryState; }): AttemptRuntimeState; failTask(taskId: string, reasonCode: string): TaskContract; /** * Recover unbound in-process work after a process restart. A completion has no resumable model * transcript, so its old lease is fenced and the task becomes dispatchable for a fresh attempt. * Agent-bound attempts are intentionally excluded: those must wake the same logical agent. */ recoverInterruptedUnboundAttempts(shouldRecover?: (attempt: AttemptRuntimeState) => boolean): string[]; expireLeases(at?: number): string[]; requestAgentResume(agentId: string, attemptId: string): AgentBindingContract; /** Read-only guard used before changing agent state; resumeAttempt repeats it authoritatively. */ assertAttemptReadyForResume(attemptId: string): void; resumeAttempt(attemptId: string, agentId: string, ttlMs: number, ownerId?: string): AttemptLease; pauseObjective(objectiveId: string): void; resumeObjective(objectiveId: string): void; cancelObjective(objectiveId: string): void; completeObjective(objectiveId: string): void; completeObjectiveFromOwner(objectiveId: string, acceptanceOverride: boolean): void; requestApproval(approval: ApprovalRequestContract): ApprovalRuntimeState; resolveApproval(approvalId: string, outcome: ApprovalOutcome, reasonCode: string): ApprovalRuntimeState; enqueueNotification(args: { notificationId?: string; objectiveId: string; attemptId?: string; message: string; }): NotificationRuntimeState; markNotificationDelivered(notificationId: string): NotificationRuntimeState; private buildTask; private normalizeDispatchForTask; private assertTaskAttemptBudget; private transitionObjective; private requireObjective; private requireDispatchableTask; private requireAttempt; private issueLease; private pendingApprovalForTask; private requireActiveObjectiveForAttempt; private assertRetryBackoffElapsed; private requireLiveLease; private refresh; private commit; private compactCurrentProjection; private nowIso; } //# sourceMappingURL=task-runtime.d.ts.map