import { z } from 'zod'; import { D as DurableContext, e as DurableClient, c as Clock, j as CreateExecutionRequest, k as CreateExecutionResponse, l as CheckoutRequest, m as CheckoutResponse, n as CheckpointRequest, o as CheckpointResponse, q as ReleaseRequest, r as ReleaseResponse, s as CallbackRequest, t as CallbackResponse, u as DeferredFieldsResponse } from './context-KxOnV70t.js'; export { K as CallbackConflictError, J as CallbackExpiredError, C as CallbackOptions, a as CallbackOptionsWithTimeout, b as CallbackResult, i as CheckpointOperationStatus, V as DeterminismGuard, X as DeterminismViolation, a1 as DormancyTracker, v as DuplicateNameError, p as ErrorMetadata, E as Execution, f as ExecutionStatus, M as ExecutionTerminalError, $ as GlobalGuardConfig, H as HeldReason, Q as IdempotencyConflictError, L as LeaseConflictError, a0 as ModuleShimConfig, N as NestedStepError, O as Operation, h as OperationStatus, g as OperationType, z as OperationTypeMismatchError, P as PresignedBlock, y as RequestOutcomeUnknownError, G as ReservedOperationNameError, F as ResultCorruptError, B as ResultNotFoundError, A as ResultTooLargeError, R as RunStateDirective, x as StepExhaustedError, S as StepOptions, w as SuspendInsideStepError, a3 as TerminationResult, T as TickReleasedError, a2 as TrackedPromise, W as WaitOptions, I as WireVersionMismatchError, d as defaultClock, _ as generatePreloadSource, Z as generateShimSource, Y as guardedImportsPlugin, U as isSdkError } from './context-KxOnV70t.js'; import { D as DurableDefinition, a as DurableResult } from './index-BKVeJTHh.js'; export { E as ExecuteTickOptions, R as RunTickOptions, S as SDK_WIRE_VERSION_MAX, W as WIRE_VERSION_HEADER, e as executeTick, r as runTick } from './index-BKVeJTHh.js'; export { AdapterType, DurableConfig, FilesystemClient, FilesystemClientOptions, configureDurable, createClient, getConfig, resetConfig } from './node/index.js'; export { MemoryClient } from './testing/index.js'; /** * Entry point for defining durable executions. */ /** * Options for defining a durable execution. */ interface DefineDurableOptions, TOutput> { /** Unique name for this durable type */ name: string; /** Optional description */ description?: string; /** Optional Zod schema for input validation */ inputSchema?: z.ZodSchema; /** Optional Zod schema for output validation */ outputSchema?: z.ZodSchema; /** The execution function */ run: (ctx: DurableContext, input: TInput) => Promise; } /** * Options for calling a durable (second argument). All fields are optional; * client defaults to createClient(). */ interface DurableCallOptions { client?: DurableClient; logging?: boolean; guardEnabled?: boolean; settleDelayMs?: number; /** Clock used by runTick. If `client` is omitted, this clock is also * forwarded to the default local client so wait/callback expiry stay * in sync. If you pass an explicit `client`, construct it with the same * clock instance. */ clock?: Clock; inbox?: string; idempotencyKey?: string; leaseToken?: string; } /** * A callable durable that can be invoked directly. * * Pass an object as the first argument to start a new execution. * Pass a string (execution ID) to resume an existing one. */ interface CallableDurable, TOutput> extends DurableDefinition { (input: TInput, options?: DurableCallOptions): Promise>; (executionId: string, options?: DurableCallOptions): Promise>; } /** * Define a durable execution. * * Supports two call signatures: * - defineDurable(name, run) - Simple form * - defineDurable({ name, run, inputSchema?, outputSchema?, description? }) - Full options * * Returns a callable that can be invoked directly: * const myDurable = defineDurable("my-durable", async (ctx, input) => {...}); * const result = await myDurable({ userId: "123" }); * * @example * // Simple form * const myDurable = defineDurable("my-durable", async (ctx, input) => { * const data = await ctx.step("fetch", async () => {...}); * return data; * }); * const result = await myDurable({ userId: "123" }); * * @example * // Resume an existing execution * const result = await myDurable("exec-abc"); * * @example * // Full options with schemas * const myDurable = defineDurable({ * name: "my-durable", * inputSchema: z.object({ userId: z.string() }), * run: async (ctx, input) => { * const data = await ctx.step("fetch", async () => {...}); * return data; * }, * }); */ declare function defineDurable = Record, TOutput = unknown>(name: string, run: (ctx: DurableContext, input: TInput) => Promise): CallableDurable; declare function defineDurable = Record, TOutput = unknown>(options: DefineDurableOptions): CallableDurable; /** * REST API DurableClient implementation for production use. * * Communicates with the Zapier-hosted durable execution backend. * Uses openapi-fetch for type-safe API requests. */ interface HttpRetryConfig { /** Maximum number of attempts (default: 3) */ maxAttempts: number; /** Base delay in milliseconds (default: 500) */ baseDelayMs: number; /** Maximum delay cap in milliseconds (default: 5000) */ maxDelayMs: number; /** Jitter factor 0-1 (default: 0.5) */ jitterFactor: number; } interface RestClientOptions { /** Base URL for the API (default: https://sdkapi.zapier.com/api/v0/sdk/code-substrate-runner) */ baseUrl?: string; /** Base URL for callback URLs shown to users (may differ from API baseUrl) */ callbackBaseUrl?: string; /** Authorization token (JWT). Auto-generated for localhost if not provided. */ token?: string; /** Enable debug logging */ logging?: boolean; /** HTTP retry configuration for transient failures (false to disable) */ httpRetry?: Partial | false; /** * Opt out of advertising the `presigned-result-v1` capability. With the * header absent, the server omits `presigned` blocks on externalized * operations and the SDK falls back to `fetchDeferred` for every read. * Use for restricted-egress environments that cannot reach S3 directly. * * Note: this does *not* disable the read-side hydration pass — the SDK * still scans checkout responses for sentinel-prefixed fields and * resolves them via `fetchDeferred`. Sentinels in user data would * otherwise leak through as raw strings. */ disablePresignedCapability?: boolean; } declare class RestClient implements DurableClient { private client; private _callbackBaseUrl; private logging; private httpRetryConfig; get callbackBaseUrl(): string; constructor(options?: RestClientOptions); setLogging(enabled: boolean): void; private log; /** * Execute an operation with HTTP retry logic for transient failures. * Retries on 5xx, 408, 429, timeouts, and network errors. */ private withHttpRetry; create(req: CreateExecutionRequest): Promise; checkout(executionId: string, req?: CheckoutRequest): Promise; checkpoint(executionId: string, req: CheckpointRequest): Promise; release(executionId: string, req: ReleaseRequest): Promise; callback(token: string, req: CallbackRequest): Promise; /** * Universal fallback for externalized results: the server fetches and * decompresses the S3 bundle and returns the full field bag inline. * Used when the SDK has no capability header, when the presigned URL * has expired/403'd, or when verification of the presigned path failed. */ fetchDeferred(executionId: string, operationId: string, leaseToken: string): Promise; } /** * Durable Execution Limits * * Sanity bounds for user-controllable fields. These limits must stay in * sync with the server-side schema; changes here require a coordinated * server change. */ /** Duration limits in seconds */ declare const DURATION_LIMITS: { /** Minimum duration for any timed operation */ readonly MIN_SECONDS: 1; /** Maximum duration: 1 year (365 days) */ readonly MAX_SECONDS: number; }; /** Retry attempt limits */ declare const RETRY_LIMITS: { /** Minimum retry attempts (must try at least once) */ readonly MIN_ATTEMPTS: 1; /** Maximum retry attempts */ readonly MAX_ATTEMPTS: 100; /** Default retry attempts */ readonly DEFAULT_ATTEMPTS: 5; }; /** Wait operation limits (ctx.wait) */ declare const WAIT_LIMITS: { /** Minimum wait duration in seconds */ readonly MIN_SECONDS: 1; /** Maximum wait duration in seconds (1 year) */ readonly MAX_SECONDS: number; }; /** Callback operation limits (ctx.createCallback) */ declare const CALLBACK_LIMITS: { /** Minimum callback TTL in seconds (1 minute) */ readonly MIN_SECONDS: 60; /** Maximum callback TTL in seconds (1 year) */ readonly MAX_SECONDS: number; /** Default callback TTL in seconds (30 days) */ readonly DEFAULT_SECONDS: number; }; /** Retry delay limits (exponential backoff) */ declare const RETRY_DELAY_LIMITS: { /** Minimum retry delay in milliseconds */ readonly MIN_MS: 1000; /** Maximum retry delay in milliseconds (5 minutes) */ readonly MAX_MS: number; /** Default base retry delay in milliseconds */ readonly DEFAULT_BASE_MS: 5000; }; export { CALLBACK_LIMITS, type CallableDurable, CallbackRequest, CallbackResponse, CheckoutRequest, CheckoutResponse, CheckpointRequest, CheckpointResponse, Clock, CreateExecutionRequest, CreateExecutionResponse, DURATION_LIMITS, DeferredFieldsResponse, type DefineDurableOptions, type DurableCallOptions, DurableClient, DurableContext, DurableDefinition, DurableResult, RETRY_DELAY_LIMITS, RETRY_LIMITS, ReleaseRequest, ReleaseResponse, RestClient, type RestClientOptions, WAIT_LIMITS, defineDurable };