import { c as Clock, e as DurableClient, 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, E as Execution, O as Operation } from '../context-KxOnV70t.js'; import 'zod'; /** * Configuration management for the Durable SDK. * * Environment variables: * - ZAPIER_DURABLE_ADAPTER: "filesystem" (default) or "zapier" * - ZAPIER_DURABLE_FS_DIR: Directory for filesystem adapter (default: ~/.config/zapier-sdk/durable) * - ZAPIER_DURABLE_DETERMINISM_GUARD: "on" (default) or "off" * - ZAPIER_DURABLE_API_URL: Base URL for the API (default: https://sdkapi.zapier.com/api/v0/sdk/code-substrate-runner) * - ZAPIER_DURABLE_API_JWT: JWT token for API authentication (auto-generated for localhost) * - ZAPIER_DURABLE_WAIT_INPROCESS_THRESHOLD_SECONDS: a ctx.wait whose time * remaining at first await is at or below this sleeps in-process instead * of suspending the tick (default: 0, disabled) * - ZAPIER_DURABLE_WAIT_INPROCESS_BUDGET_SECONDS: per-tick cap on total * seconds absorbed by in-process waits (default: 120) */ type AdapterType = "filesystem" | "zapier" | "memory"; interface DurableConfig { /** Adapter type: "filesystem", "zapier", or "memory" */ adapter: AdapterType; /** Directory for filesystem adapter */ fsDir: string; /** Enable determinism guard */ guardEnabled: boolean; /** Base URL for Zapier API */ apiUrl: string; /** JWT token for Zapier API */ apiToken?: string; /** Enable debug logging */ logging: boolean; /** * A wait is always journaled pending at the call. If the time remaining * until resume_at is at or below this threshold when the wait is first * awaited, it sleeps out the remainder in-process and journals completed * instead of suspending. 0 disables in-process waits (the default). */ waitInProcessThresholdSeconds: number; /** * Per-tick cap on total seconds absorbed by in-process waits. Once a * tick's cumulative in-process sleep would exceed this, further waits * fall back to the checkpoint-and-suspend path even if under threshold. */ waitInProcessBudgetSeconds: number; } /** * Get current configuration. If not explicitly set, reads from environment. */ declare function getConfig(): DurableConfig; /** * Set global configuration. Call this at startup if you need custom config. */ declare function configureDurable(config: Partial): DurableConfig; /** * Reset configuration to defaults (mainly for testing). */ declare function resetConfig(): void; /** * Create a DurableClient based on current configuration. */ declare function createClient(configOverrides?: Partial, clientOptions?: { /** Client-side clock injection is intended for local adapters (memory, * filesystem) and tests; pass the same instance to runTick / * DurableCallOptions for deterministic timing. The zapier adapter does * not receive it. */ clock?: Clock; }): DurableClient; /** * Filesystem-based DurableClient implementation for local development and CLI. * * Storage structure: * .zapier-durable/ * executions/ * {execution_id}/ * execution.json * operations.json * callbacks/ * {callback_token}.json */ interface FilesystemClientOptions { /** Base directory for storage (default: .zapier-durable) */ baseDir?: string; /** Enable debug logging */ logging?: boolean; /** Clock used for wait auto-completion at checkout and for callback * expiry / completed_at. When using a mock clock in tests, pass the * same instance to runTick(). */ clock?: Clock; wireVersion?: number; } declare class FilesystemClient implements DurableClient { private baseDir; private logging; private clock; private wireVersion; /** * Base URL for constructing callback URLs. * For filesystem client, uses file:// protocol. */ get callbackBaseUrl(): string; constructor(options?: FilesystemClientOptions); setLogging(enabled: boolean): void; private log; private ensureDirectories; private executionDir; private executionFile; private operationsFile; private callbackFile; private readExecution; private writeExecution; private readOperations; private writeOperations; private readCallback; private writeCallback; 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; /** * Get an execution by ID. Returns null if not found. */ getExecution(executionId: string): Execution | null; /** * Get all operations for an execution. */ getOperations(executionId: string): Operation[]; /** * List all execution IDs in the store. */ listExecutions(): string[]; /** * Delete an execution and its operations. */ deleteExecution(executionId: string): boolean; /** * Clean up all data (useful for tests). */ clear(): void; } export { type AdapterType, type DurableConfig, FilesystemClient, type FilesystemClientOptions, configureDurable, createClient, getConfig, resetConfig };