import { z } from '#compiled/zod/index.js'; export type QueueKind = 'workflow'; /** * Pattern matching valid queue prefixes: * - `__wkf_workflow_` (default, no namespace) * - `__{namespace}_wkf_workflow_` (namespaced) * * Namespace must be lowercase alphanumeric starting with a letter. */ export declare const QueuePrefix: z.ZodString; export type QueuePrefix = z.infer; export declare const ValidQueueName: z.ZodString; export type ValidQueueName = z.infer; /** * Resolves the active queue namespace from an explicit argument or the * `WORKFLOW_QUEUE_NAMESPACE` env var. */ export declare function resolveQueueNamespace(namespace?: string): string | undefined; /** * Builds the workflow queue topic prefix for an optional namespace. * * The literal kind argument is retained so existing workflow-only callers keep * their meaning after removal of the former `'step'` variant. * * - `getQueueTopicPrefix('workflow')` → `'__wkf_workflow_'` * - `getQueueTopicPrefix('workflow', 'custom')` → `'__custom_wkf_workflow_'` */ export declare function getQueueTopicPrefix(kind: QueueKind, namespace?: string): QueuePrefix; export declare function parseQueueName(name: ValidQueueName): { prefix: QueuePrefix; id: string; }; export declare const MessageId: z.core.$ZodBranded; export type MessageId = z.infer; /** * OpenTelemetry trace context for distributed tracing */ export declare const TraceCarrierSchema: z.ZodRecord; export type TraceCarrier = z.infer; /** * Run creation data carried through the queue for resilient start. * Only present on the first queue delivery — re-enqueues omit this. * When the runtime processes the message, it passes this data to the * run_started event so the server can create the run if it doesn't exist yet. */ export declare const RunInputSchema: z.ZodObject<{ input: z.ZodUnknown; deploymentId: z.ZodString; workflowName: z.ZodString; specVersion: z.ZodNumber; executionContext: z.ZodOptional>; attributes: z.ZodOptional>; allowReservedAttributes: z.ZodOptional>; environment: z.ZodOptional; }, z.core.$strip>; export type RunInput = z.infer; /** * Lazy hook resume data carried through the queue alongside a workflow * invocation. Present only when `resumeHook()` takes the parallel fast path: * the producer persists the `hook_received` event and publishes this invocation * concurrently. On receipt, a consumer that understands `hookInput` idempotently * ensures the `hook_received` event exists — keyed by `resumeId` — before * replaying, so the two concurrent writes converge on exactly one event. * * The `payload` is the already-serialized (and possibly encrypted) resume * payload — the identical bytes the producer also sent on the direct * `events.create`, so both server receipts hash to the same digest under the * `(runId, resumeId)` constraint. */ export declare const HookResumeInputSchema: z.ZodObject<{ resumeId: z.ZodString; hookId: z.ZodString; token: z.ZodString; payload: z.ZodUnknown; payloadDigest: z.ZodString; }, z.core.$strip>; export type HookResumeInput = z.infer; export declare const WorkflowInvokePayloadSchema: z.ZodObject<{ runId: z.ZodString; traceCarrier: z.ZodOptional>; requestedAt: z.ZodOptional>; replayDivergence: z.ZodOptional>; preconditionReinvocations: z.ZodOptional; serverErrorRetryCount: z.ZodOptional; deploymentMismatchRetryCount: z.ZodOptional; stepId: z.ZodOptional; stepName: z.ZodOptional; runInput: z.ZodOptional>; attributes: z.ZodOptional>; allowReservedAttributes: z.ZodOptional>; environment: z.ZodOptional; }, z.core.$strip>>; hookInput: z.ZodOptional>; }, z.core.$strip>; export type WorkflowInvokePayload = z.infer; export type HealthCheckPayload = z.infer; /** * Health check payload - used to verify that the queue pipeline * can deliver messages to the combined workflow endpoint. */ export declare const HealthCheckPayloadSchema: z.ZodObject<{ __healthCheck: z.ZodLiteral; correlationId: z.ZodString; runId: z.ZodOptional; }, z.core.$strip>; /** * Health check MUST come first. * * Zod unions return the first matching member's output, and `z.object` strips * keys the matching member doesn't declare. `HealthCheckPayloadSchema` carries * an optional `runId`, so a probe payload also satisfies * `WorkflowInvokePayloadSchema` (whose only required field is `runId`). With * the invoke member first, parsing a runId-bearing probe silently dropped * `__healthCheck` and `correlationId`, and the runtime — which dispatches on * `__healthCheck` before falling through to the invoke schema — reinterpreted * the probe as "replay this run". That made the queue handler POST * `run_started` for a run that doesn't exist yet (404), fail, and retry * forever, so the probe never answered and `start()` timed out. * * Ordering health check first is safe in the other direction: it requires * `__healthCheck: true`, which an invoke payload never carries. */ export declare const QueuePayloadSchema: z.ZodUnion; correlationId: z.ZodString; runId: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ runId: z.ZodString; traceCarrier: z.ZodOptional>; requestedAt: z.ZodOptional>; replayDivergence: z.ZodOptional>; preconditionReinvocations: z.ZodOptional; serverErrorRetryCount: z.ZodOptional; deploymentMismatchRetryCount: z.ZodOptional; stepId: z.ZodOptional; stepName: z.ZodOptional; runInput: z.ZodOptional>; attributes: z.ZodOptional>; allowReservedAttributes: z.ZodOptional>; environment: z.ZodOptional; }, z.core.$strip>>; hookInput: z.ZodOptional>; }, z.core.$strip>]>; export type QueuePayload = z.infer; export interface QueueOptions { deploymentId?: string; idempotencyKey?: string; headers?: Record; /** Delay message delivery by this many seconds */ delaySeconds?: number; /** Spec version of the target run. Used to select the queue transport format. */ specVersion?: number; /** * World-specific routing hint identifying the region the message should * be sent to (e.g. a Vercel compute region code such as `'iad1'`). * * Worlds that don't have a regional dimension ignore this field. For * `@workflow/world-vercel`, this overrides the region the underlying * `@vercel/queue` client uses to route the message; when omitted, the * region is resolved from the payload's tagged run ID, then from the * `VERCEL_REGION` environment variable, and finally defaults to `'iad1'` * (the pre-regional-routing behaviour). */ region?: string; } export interface Queue { getDeploymentId(): Promise; /** * Returns true only when a queue error definitively means the explicitly * targeted deployment cannot receive the message. Unknown and transient * errors must return false so the current delivery can be retried safely. */ isDeploymentUnavailableError?(error: unknown): boolean; /** * Enqueues a message to the specified queue. * * @param queueName - The name of the queue to which the message will be sent. * @param message - The content of the message to be sent to the queue. * @param opts - Optional parameters for the queue operation. */ queue(queueName: ValidQueueName, message: QueuePayload, opts?: QueueOptions): Promise<{ messageId: MessageId | null; }>; /** * Creates an HTTP queue handler for processing messages from a specific queue. * * `meta.messageId` SHOULD be stable across redeliveries of the same message * (one ID per enqueued message, reused on every delivery attempt). The * runtime's inline step ownership uses it as a liveness lease: the lazy * `step_started` records the handling invocation's messageId, and only a * delivery of that same message may re-execute the step before the * ownership lease expires (crash recovery via queue redelivery). A World * whose queue mints a fresh ID per delivery degrades gracefully — owner * redeliveries fall back to the delayed-backstop path instead of executing * immediately, adding recovery latency but never wedging or duplicating. */ createQueueHandler(queueNamePrefix: QueuePrefix, handler: (message: unknown, meta: { attempt: number; queueName: ValidQueueName; messageId: MessageId; requestId?: string; }) => Promise): (req: Request) => Promise; } //# sourceMappingURL=queue.d.ts.map