import { D as DurableContext, a4 as RetryingStep, e as DurableClient, c as Clock } from './context-KxOnV70t.js'; /** * Runner - Executes a tick of a durable execution. */ interface DurableResult { done: boolean; result?: T; error?: Error; executionId?: string; /** * Steps that failed on this tick with attempts remaining, so the execution * suspended to retry. Present (non-empty) only on a suspended (`waiting`) * tick where at least one step burned an attempt; absent on completed and * failed returns and on suspends with no step failure (e.g. a `ctx.wait`). * Lets a host observe the error that occurred without waiting for the step * to exhaust. * * Entries record events, not state: each corresponds 1:1 with an attempt * burned during this tick, so a failure is reported exactly once, on the * tick it happened. A step still in retry backoff on a later tick is not * re-reported; the journal remains the authoritative view of which steps * are currently scheduled to retry. */ retrying?: RetryingStep[]; } interface DurableDefinition { name: string; description?: string; run: (ctx: DurableContext, input: TInput) => Promise; } interface RunTickOptions { client: DurableClient; executionId?: string; input?: unknown; inbox?: string; idempotencyKey?: string; leaseToken?: string; settleDelayMs?: number; logging?: boolean; guardEnabled?: boolean; /** * Clock for time operations. Defaults to Date.now(). Inject a mock for * testing. When using a mock clock, pass the same instance to the client * (e.g., MemoryClient) so wait auto-completion at checkout uses the same * time source. */ clock?: Clock; } interface ExecuteTickOptions { client: DurableClient; executionId: string; leaseToken: string; input: unknown; logging?: boolean; guardEnabled?: boolean; } /** * Execute the tick lifecycle on a pre-built DurableContext. * * This is the lower-level primitive that both runTick() and the SDK's * defineDurable use. The caller is responsible for: * - Creating/checking out the execution * - Constructing the DurableContext (possibly with extra fields via Object.assign) * * executeTick handles: * - Guard setup (logging, global guards, violation detection) * - Racing user code against dormancy and violations * - Releasing the execution with the correct status * * The ctx parameter accepts DurableContext or any subtype (e.g. with extra * fields Object.assigned by the SDK's define layer). */ declare function executeTick(run: (ctx: TContext, input: unknown) => Promise, ctx: TContext, options: ExecuteTickOptions): Promise>; /** * Execute a single tick of a durable execution. * * A tick runs user code until it either completes or goes dormant (all work done, * waiting on external events). Multiple ticks may be needed to complete an * execution - each tick resumes from where the previous left off. * * @param durable - The durable definition to execute * @param options - Execution options * @returns Result containing done status, result/error, and executionId */ declare function runTick(durable: DurableDefinition, options: RunTickOptions): Promise>; /** * Execution wire versioning. * * `executions.wire_version` is stamped once by the server as * min(server_current, sdk_declared_max) at the execution's first checkout * (before any operations exist) and echoed on every checkout thereafter. * The SDK dispatches callback-resolution behavior on it: v0 replays the * legacy behavior byte-identically; v1 resolves callbacks created with * `timeoutSeconds` to a CallbackResult. * * The server rejects a checkout with 426 wire-version-mismatch when an * SDK declares a lower max than the execution's stamped version — that * direction is unrecoverable (the SDK cannot know how to replay a newer * wire version). The opposite direction is safe: a newer SDK replays older * executions under their stamped version. * * Bump criterion: bump only when an execution created yesterday would * observe a different value at the same await under the new code. * Wire-protocol additions and new columns don't bump; the CallbackResult * wrapper does. */ /** Highest execution wire version this SDK understands. */ declare const SDK_WIRE_VERSION_MAX = 1; /** * Dedicated header the SDK uses to advertise its max wire version. * It rides every request, but the server reads it only at an execution's * first checkout, where it negotiates min(server_max, advertised) and * stamps `executions.wire_version` once. A later checkout by an SDK whose * max is below the stamped version gets a 426 wire-version-mismatch. */ declare const WIRE_VERSION_HEADER = "x-zapier-durable-wire-version"; export { type DurableDefinition as D, type ExecuteTickOptions as E, type RunTickOptions as R, SDK_WIRE_VERSION_MAX as S, WIRE_VERSION_HEADER as W, type DurableResult as a, executeTick as e, runTick as r };