eve 0.48.0 → 0.49.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/dist/src/channel/channel-address.js +1 -1
- package/dist/src/channel/types.d.ts +10 -0
- package/dist/src/cli/commands/integration-setup.d.ts +1 -0
- package/dist/src/cli/commands/integration-setup.js +1 -1
- package/dist/src/cli/commands/register-integration-commands.d.ts +1 -1
- package/dist/src/cli/commands/register-integration-commands.js +1 -1
- package/dist/src/cli/commands/registry-declared-setups.d.ts +1 -0
- package/dist/src/cli/commands/registry-declared-setups.js +1 -1
- package/dist/src/cli/commands/registry-metadata.d.ts +30 -0
- package/dist/src/cli/commands/registry-metadata.js +1 -1
- package/dist/src/cli/commands/registry-package.d.ts +6 -0
- package/dist/src/cli/commands/registry-package.js +1 -1
- package/dist/src/cli/commands/registry-pnpm-build-policy-flow.d.ts +30 -0
- package/dist/src/cli/commands/registry-pnpm-build-policy-flow.js +1 -0
- package/dist/src/cli/commands/registry-pnpm-build-policy.d.ts +12 -0
- package/dist/src/cli/commands/registry-pnpm-build-policy.js +6 -0
- package/dist/src/cli/commands/registry-recovery.d.ts +4 -0
- package/dist/src/cli/commands/registry-recovery.js +1 -1
- package/dist/src/cli/commands/registry.d.ts +1 -1
- package/dist/src/cli/commands/registry.js +1 -1
- package/dist/src/cli/dev/tui/setup-commands.js +2 -2
- package/dist/src/compiled/.vendor-stamp.json +7 -7
- package/dist/src/compiled/@workflow/core/attribute-changes.d.ts +2 -4
- package/dist/src/compiled/@workflow/core/capabilities.d.ts +10 -9
- package/dist/src/compiled/@workflow/core/capture-stack.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/class-serialization.d.ts +8 -8
- package/dist/src/compiled/@workflow/core/context-violation-error.d.ts +5 -5
- package/dist/src/compiled/@workflow/core/create-hook.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/describe-error.d.ts +7 -7
- package/dist/src/compiled/@workflow/core/encryption.d.ts +5 -5
- package/dist/src/compiled/@workflow/core/events-consumer.d.ts +49 -14
- package/dist/src/compiled/@workflow/core/flushable-stream.d.ts +4 -4
- package/dist/src/compiled/@workflow/core/global.d.ts +4 -2
- package/dist/src/compiled/@workflow/core/index.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/log-format.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/private.d.ts +40 -78
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/replay-payload-cache.d.ts +13 -17
- package/dist/src/compiled/@workflow/core/runtime/compute-instance.d.ts +4 -3
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +27 -27
- package/dist/src/compiled/@workflow/core/runtime/count-step-started-events.d.ts +7 -7
- package/dist/src/compiled/@workflow/core/runtime/deployment-guard.d.ts +7 -7
- package/dist/src/compiled/@workflow/core/runtime/get-port-lazy.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/runtime/get-world-lazy.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +30 -49
- package/dist/src/compiled/@workflow/core/runtime/quickjs-entrypoint.d.ts +21 -10
- package/dist/src/compiled/@workflow/core/runtime/quickjs-runtime.d.ts +31 -15
- package/dist/src/compiled/@workflow/core/runtime/quickjs-serde.d.ts +10 -10
- package/dist/src/compiled/@workflow/core/runtime/replay-budget.d.ts +4 -4
- package/dist/src/compiled/@workflow/core/runtime/replay-recovery-reporter.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +20 -12
- package/dist/src/compiled/@workflow/core/runtime/resume-latency.d.ts +37 -30
- package/dist/src/compiled/@workflow/core/runtime/run-id-time.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/runtime/run.d.ts +22 -5
- package/dist/src/compiled/@workflow/core/runtime/runs.d.ts +4 -4
- package/dist/src/compiled/@workflow/core/runtime/start.d.ts +3 -3
- package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +14 -14
- package/dist/src/compiled/@workflow/core/runtime/step-latency.d.ts +42 -25
- package/dist/src/compiled/@workflow/core/runtime/step-ownership.d.ts +6 -6
- package/dist/src/compiled/@workflow/core/runtime/step-single-flight.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +38 -24
- package/dist/src/compiled/@workflow/core/runtime/unserializable-step.d.ts +34 -0
- package/dist/src/compiled/@workflow/core/runtime/vm-mode.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/runtime/wait-continuation.d.ts +31 -9
- package/dist/src/compiled/@workflow/core/runtime/wait-until.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/runtime/world-compatibility.d.ts +20 -9
- package/dist/src/compiled/@workflow/core/runtime/world-init.d.ts +5 -5
- package/dist/src/compiled/@workflow/core/runtime.js +3 -3
- package/dist/src/compiled/@workflow/core/sealed-box.d.ts +7 -7
- package/dist/src/compiled/@workflow/core/serialization/codec-devalue-vm.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization/codec-devalue.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization/codec.d.ts +4 -4
- package/dist/src/compiled/@workflow/core/serialization/compression.d.ts +12 -11
- package/dist/src/compiled/@workflow/core/serialization/encryption.d.ts +7 -7
- package/dist/src/compiled/@workflow/core/serialization/format.d.ts +6 -6
- package/dist/src/compiled/@workflow/core/serialization/hardened.d.ts +23 -22
- package/dist/src/compiled/@workflow/core/serialization/index.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization/reducers/class-vm.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization/reducers/step-function-vm.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization/types.d.ts +5 -5
- package/dist/src/compiled/@workflow/core/serialization/workflow-vm.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization-format.d.ts +11 -11
- package/dist/src/compiled/@workflow/core/serialization.d.ts +18 -19
- package/dist/src/compiled/@workflow/core/source-map.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +5 -5
- package/dist/src/compiled/@workflow/core/step/writable-stream.d.ts +3 -3
- package/dist/src/compiled/@workflow/core/symbols.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +71 -20
- package/dist/src/compiled/@workflow/core/telemetry.d.ts +15 -3
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/vm/script-cache.d.ts +9 -11
- package/dist/src/compiled/@workflow/core/workflow/abort-controller.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow/set-attributes.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow/world-init-stub.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/index.d.ts +18 -18
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world/analytics.d.ts +3 -2
- package/dist/src/compiled/@workflow/world/attributes-validation.d.ts +28 -0
- package/dist/src/compiled/@workflow/world/attributes.d.ts +8 -107
- package/dist/src/compiled/@workflow/world/env-config.d.ts +5 -5
- package/dist/src/compiled/@workflow/world/event-metadata.d.ts +132 -0
- package/dist/src/compiled/@workflow/world/events.d.ts +42 -96
- package/dist/src/compiled/@workflow/world/hooks.d.ts +12 -11
- package/dist/src/compiled/@workflow/world/index.d.ts +3 -3
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +94 -39
- package/dist/src/compiled/@workflow/world/queue.d.ts +29 -22
- package/dist/src/compiled/@workflow/world/runs.d.ts +20 -0
- package/dist/src/compiled/@workflow/world/slot-identity.d.ts +3 -3
- package/dist/src/compiled/@workflow/world/spec-version.d.ts +82 -15
- package/dist/src/compiled/@workflow/world/ulid.d.ts +2 -2
- package/dist/src/compiled/@workflow/world-local/index.js +5 -5
- package/dist/src/compiled/@workflow/world-vercel/index.js +12 -12
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-DXbpwBdw.js → attribute-changes-BwAadFfB.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/debug-log-CVPstO1D.js +1 -0
- package/dist/src/compiled/_chunks/workflow/dist-CgbVZs5l.js +40 -0
- package/dist/src/compiled/_chunks/workflow/dist-DjojkP5e.js +3 -0
- package/dist/src/compiled/_chunks/workflow/frames-CZ9eHShe.js +3 -0
- package/dist/src/compiled/_chunks/workflow/global-singleton-BNinwFrL.js +1 -0
- package/dist/src/compiled/_chunks/workflow/private-CZFMABEf.js +1 -0
- package/dist/src/compiled/_chunks/workflow/resume-hook-BToMtPbH.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-DzyAoGh4.js +1 -0
- package/dist/src/compiled/_chunks/workflow/sleep-3_A5uOp-.js +1 -0
- package/dist/src/compiled/_chunks/workflow/undici-DfxNX5og.js +95 -0
- package/dist/src/compiled/_chunks/workflow/wait-until-BtySPYD0.js +15 -0
- package/dist/src/compiled/_chunks/workflow/ws-transport-PnVVxT0R.js +1 -0
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/execution/agent-handle-dispatch.js +1 -1
- package/dist/src/execution/continuation-conflict-step.d.ts +10 -0
- package/dist/src/execution/continuation-conflict-step.js +1 -0
- package/dist/src/execution/delegated-parent-notification.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-shared.d.ts +7 -29
- package/dist/src/execution/dispatch-runtime-actions-shared.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-start.d.ts +33 -0
- package/dist/src/execution/dispatch-runtime-actions-start.js +1 -0
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
- package/dist/src/execution/dispatch-turn-step.js +1 -1
- package/dist/src/execution/dynamic-connections.js +1 -1
- package/dist/src/execution/inline-turn.js +1 -1
- package/dist/src/execution/next-driver-action.d.ts +5 -4
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/runtime-errors.d.ts +0 -12
- package/dist/src/execution/runtime-errors.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker-options.d.ts +1 -1
- package/dist/src/execution/sandbox/bindings/docker-options.js +1 -1
- package/dist/src/execution/sandbox/bindings/eve-image.d.ts +4 -0
- package/dist/src/execution/sandbox/bindings/eve-image.js +1 -0
- package/dist/src/execution/sandbox/bindings/microsandbox-options.d.ts +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-options.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-create-sdk.js +1 -1
- package/dist/src/execution/session-timeout-steps.js +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/stable-workflow-names.d.ts +2 -2
- package/dist/src/execution/subagent-start-local.js +1 -1
- package/dist/src/execution/tasks/parent/dispatch-task-step.js +1 -1
- package/dist/src/execution/tasks/parent/run-parent.js +1 -1
- package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
- package/dist/src/execution/tool-run/start.js +1 -1
- package/dist/src/execution/tools/subagent/local.js +1 -1
- package/dist/src/execution/turn-workflow.js +1 -1
- package/dist/src/execution/workflow-entry.d.ts +5 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +12 -12
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/workflow/development-world-client.js +1 -1
- package/dist/src/packages/eve-catalog/src/index.js +1 -1
- package/dist/src/public/channels/slack/activity.d.ts +18 -0
- package/dist/src/public/channels/slack/activity.js +1 -0
- package/dist/src/public/channels/slack/api.js +1 -1
- package/dist/src/public/channels/slack/index.d.ts +1 -0
- package/dist/src/public/channels/slack/index.js +1 -1
- package/dist/src/public/channels/slack/interaction-cards.js +1 -1
- package/dist/src/public/channels/slack/interactions.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +12 -1
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/memory/file/backends/default.js +1 -1
- package/dist/src/public/sandbox/docker-sandbox.d.ts +5 -4
- package/dist/src/public/sandbox/microsandbox-sandbox.d.ts +1 -1
- package/dist/src/public/sandbox/vercel-sandbox.d.ts +3 -1
- package/dist/src/setup/flows/registry.js +1 -1
- package/dist/src/setup/integrations/file-memory/setup.d.ts +15 -0
- package/dist/src/setup/integrations/file-memory/setup.js +2 -0
- package/dist/src/setup/integrations/file-memory/vercel.d.ts +103 -0
- package/dist/src/setup/integrations/file-memory/vercel.js +1 -0
- package/dist/src/setup/integrations/registry.js +1 -1
- package/dist/src/setup/integrations/shared/vercel-project.js +1 -1
- package/dist/src/setup/scaffold/connections/catalog.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/docs/channels/custom.mdx +4 -0
- package/docs/channels/eve.mdx +12 -8
- package/docs/channels/mcp.mdx +4 -1
- package/docs/channels/slack.mdx +1 -1
- package/docs/guides/instrumentation.md +1 -1
- package/docs/install-integrations.mdx +5 -0
- package/docs/instructions.mdx +1 -1
- package/docs/memory/custom-provider.md +214 -0
- package/docs/memory/file.md +168 -0
- package/docs/memory/meta.json +5 -0
- package/docs/memory/overview.mdx +282 -0
- package/docs/patterns/multi-tenant-memory.md +12 -20
- package/docs/reference/cli.md +28 -23
- package/docs/sandbox.mdx +5 -3
- package/package.json +8 -8
- package/dist/src/compiled/_chunks/workflow/dist-CqvWKNQv.js +0 -3
- package/dist/src/compiled/_chunks/workflow/dist-Dk0aQqFO.js +0 -40
- package/dist/src/compiled/_chunks/workflow/dist-DpYyXbJv.js +0 -1
- package/dist/src/compiled/_chunks/workflow/env-config-L94XftKz.js +0 -1
- package/dist/src/compiled/_chunks/workflow/frames-Dl2Hcma4.js +0 -3
- package/dist/src/compiled/_chunks/workflow/private-CuQ4HTFC.js +0 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-E-Nkx8q_.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-cIeex2KF.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-CxFsdxB_.js +0 -1
- package/dist/src/compiled/_chunks/workflow/spec-version-DBUVfF_R.js +0 -1
- package/dist/src/compiled/_chunks/workflow/undici-DznrXKcM.js +0 -95
- package/dist/src/compiled/_chunks/workflow/wait-until-BZHmJCAW.js +0 -15
- package/dist/src/compiled/_chunks/workflow/ws-transport-Ct6yyRWZ.js +0 -1
- package/docs/memory.md +0 -408
|
@@ -3,7 +3,7 @@ import type { AttributeChange, ExperimentalSetAttributesResult } from './attribu
|
|
|
3
3
|
import type { BatchEventRequest, CreateEventBatchParams, CreateEventParams, CreateEventRequest, Event, EventBatchResult, EventResult, GetEventParams, ListEventsByCorrelationIdParams, ListEventsParams, RunCreatedEventRequest } from './events.js';
|
|
4
4
|
import type { GetHookParams, Hook, ListHooksParams } from './hooks.js';
|
|
5
5
|
import type { Queue } from './queue.js';
|
|
6
|
-
import type { BulkCancelWorkflowRunsRequest, BulkCancelWorkflowRunsResult, GetWorkflowRunParams, ListWorkflowRunsParams, WorkflowRun, WorkflowRunWithoutData } from './runs.js';
|
|
6
|
+
import type { BulkCancelWorkflowRunsRequest, BulkCancelWorkflowRunsResult, GetWorkflowRunParams, ListWorkflowRunsParams, WaitForTerminalRunStatusParams, WorkflowRun, WorkflowRunWithoutData } from './runs.js';
|
|
7
7
|
import type { GetChunksOptions, PaginatedResponse, StreamChunksResponse, StreamInfoResponse } from './shared.js';
|
|
8
8
|
import type { GetStepParams, ListWorkflowRunStepsParams, Step, StepWithoutData } from './steps.js';
|
|
9
9
|
export interface Streamer {
|
|
@@ -94,6 +94,57 @@ export interface Storage {
|
|
|
94
94
|
resolveData?: 'all';
|
|
95
95
|
}): Promise<WorkflowRun>;
|
|
96
96
|
get(id: string, params?: GetWorkflowRunParams): Promise<WorkflowRun | WorkflowRunWithoutData>;
|
|
97
|
+
/**
|
|
98
|
+
* Long poll for a run to reach a terminal status (`completed`, `failed`,
|
|
99
|
+
* or `cancelled`), returning the same entity `get` returns.
|
|
100
|
+
*
|
|
101
|
+
* This is how a caller awaiting a run's outcome (`await run.returnValue`)
|
|
102
|
+
* avoids paying interval-poll quantization for it: instead of asking
|
|
103
|
+
* "is it done yet?" every second, it asks once and the World answers the
|
|
104
|
+
* moment the run finishes.
|
|
105
|
+
*
|
|
106
|
+
* The contract:
|
|
107
|
+
*
|
|
108
|
+
* - **Resolve as soon as the run is terminal**, with the run entity in
|
|
109
|
+
* the shape `params.resolveData` asks for.
|
|
110
|
+
* - **Resolve no later than roughly `params.timeoutMs`** with the latest
|
|
111
|
+
* snapshot, whatever its status. A timeout is a normal return, never an
|
|
112
|
+
* error: a run that is still running is a legitimate answer.
|
|
113
|
+
* - **`timeoutMs` is an upper bound, not a lower one.** An
|
|
114
|
+
* implementation MAY resolve earlier with a non-terminal snapshot. For
|
|
115
|
+
* example, `@workflow/world-vercel` does when the backend it is talking
|
|
116
|
+
* to has no long-poll route and it degrades to a plain read. Callers
|
|
117
|
+
* must therefore pace their own retries rather than assume one call per
|
|
118
|
+
* `timeoutMs` (the runtime's `Run#pollReturnValue` keeps consecutive
|
|
119
|
+
* non-terminal observations at least one poll interval apart).
|
|
120
|
+
* - **Fail exactly like `get`.** A missing run throws
|
|
121
|
+
* `WorkflowRunNotFoundError`; transport failures surface as they would
|
|
122
|
+
* on any other read.
|
|
123
|
+
*
|
|
124
|
+
* OPTIONAL. Omit it entirely when the World has no way to wait (a
|
|
125
|
+
* deterministic simulator, a store with no change notification) and the
|
|
126
|
+
* runtime keeps interval-polling `get` on
|
|
127
|
+
* `WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS`. There is nothing to declare
|
|
128
|
+
* beyond the method's presence, and no behavior degrades when it is
|
|
129
|
+
* absent: the fast path is strictly additive.
|
|
130
|
+
*
|
|
131
|
+
* Implementations are free to satisfy this however their backend allows,
|
|
132
|
+
* such as a server-side long poll (`world-vercel` holds
|
|
133
|
+
* `GET /v2/runs/:runId/status` open), a change notification
|
|
134
|
+
* (`world-postgres` uses `LISTEN`/`NOTIFY`, `world-local` an in-process
|
|
135
|
+
* emitter), or a tight internal poll, as long as a lost or missing
|
|
136
|
+
* notification degrades to returning a snapshot rather than hanging past
|
|
137
|
+
* the budget.
|
|
138
|
+
*/
|
|
139
|
+
waitForTerminalStatus?: {
|
|
140
|
+
(id: string, params: WaitForTerminalRunStatusParams & {
|
|
141
|
+
resolveData: 'none';
|
|
142
|
+
}): Promise<WorkflowRunWithoutData>;
|
|
143
|
+
(id: string, params?: WaitForTerminalRunStatusParams & {
|
|
144
|
+
resolveData?: 'all';
|
|
145
|
+
}): Promise<WorkflowRun>;
|
|
146
|
+
(id: string, params?: WaitForTerminalRunStatusParams): Promise<WorkflowRun | WorkflowRunWithoutData>;
|
|
147
|
+
};
|
|
97
148
|
/**
|
|
98
149
|
* Retrieves several runs as one snapshot. The result preserves the input
|
|
99
150
|
* order and contains `null` for run IDs that do not exist.
|
|
@@ -179,7 +230,7 @@ export interface Storage {
|
|
|
179
230
|
/**
|
|
180
231
|
* The event log, and the one part of this interface with a requirement the
|
|
181
232
|
* types cannot express: **the World allocates every event id, and every id
|
|
182
|
-
* is a slot
|
|
233
|
+
* is a slot**: `evnt_` followed by the event's dense, 1-based position in
|
|
183
234
|
* its run's log, zero-padded to 26 characters. Use `slotToEventId()` to
|
|
184
235
|
* format one.
|
|
185
236
|
*
|
|
@@ -197,7 +248,7 @@ export interface Storage {
|
|
|
197
248
|
* taken. The World advances to the next free slot, commits there, and
|
|
198
249
|
* returns the events occupying the slots it skipped over on the success
|
|
199
250
|
* response (see {@link EventResult.events}). The writer learns its
|
|
200
|
-
* snapshot was stale without the write being rejected
|
|
251
|
+
* snapshot was stale without the write being rejected, which is why no
|
|
201
252
|
* World needs a precondition guard.
|
|
202
253
|
*
|
|
203
254
|
* Allocating at the commit is what makes a reader's log a *prefix* of the
|
|
@@ -227,7 +278,7 @@ export interface Storage {
|
|
|
227
278
|
*/
|
|
228
279
|
create<T extends CreateEventRequest>(runId: string, data: T, params?: CreateEventParams): Promise<EventResult<T['eventType']>>;
|
|
229
280
|
/**
|
|
230
|
-
* OPTIONAL batch write
|
|
281
|
+
* OPTIONAL batch write: append an ordered list of events to the run's
|
|
231
282
|
* log in one durable, atomic-per-attempt write, with a per-event outcome
|
|
232
283
|
* for each (see {@link BatchEventItemResult}). The events land in request
|
|
233
284
|
* order at consecutive slots. A concurrent writer may push the whole
|
|
@@ -235,14 +286,14 @@ export interface Storage {
|
|
|
235
286
|
* report accompanies the result, so a position-tracking caller compares
|
|
236
287
|
* the committed slots against its expectation and reloads the log to
|
|
237
288
|
* observe what landed in between. Its local view stays a strict PREFIX
|
|
238
|
-
* of the log
|
|
289
|
+
* of the log (never a hole), so replaying it stays correct and the
|
|
239
290
|
* next reload self-corrects.
|
|
240
291
|
*
|
|
241
292
|
* Presence of the method IS the capability declaration: the core runtime
|
|
242
293
|
* batches only when the World implements it (and the run's spec version
|
|
243
294
|
* supports slot identity); absent, every write takes the single-event
|
|
244
295
|
* `create` path unchanged. A World must implement it with real
|
|
245
|
-
* atomicity per attempt
|
|
296
|
+
* atomicity per attempt (a lost race must leave nothing behind) or not
|
|
246
297
|
* implement it at all.
|
|
247
298
|
*
|
|
248
299
|
* Size limits are the caller's problem: Worlds enforce their own caps
|
|
@@ -255,11 +306,11 @@ export interface Storage {
|
|
|
255
306
|
* `hook_created`, `hook_disposed`, `attr_set`, and more events targeting
|
|
256
307
|
* one entity than a single write can express (the one legal combination
|
|
257
308
|
* is `step_created` followed by `step_started` for the same step, which
|
|
258
|
-
* creates the step born-running
|
|
309
|
+
* creates the step born-running: the step's input MUST ride the
|
|
259
310
|
* `step_created`; a `step_started` carrying a payload rejects the whole
|
|
260
311
|
* batch). Events outside this list keep their own ordering requirements:
|
|
261
312
|
* a caller mixing a batch with single writes (hook or attribute events)
|
|
262
|
-
* owns those barriers itself
|
|
313
|
+
* owns those barriers itself: the core runtime never batches a
|
|
263
314
|
* suspension that carries hook or attribute writes.
|
|
264
315
|
*/
|
|
265
316
|
createBatch?(runId: string, events: BatchEventRequest[], params?: CreateEventBatchParams): Promise<EventBatchResult>;
|
|
@@ -289,7 +340,7 @@ export interface Storage {
|
|
|
289
340
|
* Optional feature capabilities a World implementation declares so the core
|
|
290
341
|
* runtime can enable optimizations that depend on backend behavior, instead
|
|
291
342
|
* of inferring support from environment variables alone. Every capability
|
|
292
|
-
* defaults to "unsupported" when absent
|
|
343
|
+
* defaults to "unsupported" when absent: runtime fast paths that rely on
|
|
293
344
|
* one must fail closed (keep their conservative behavior) unless the World
|
|
294
345
|
* explicitly declares it.
|
|
295
346
|
*/
|
|
@@ -302,7 +353,7 @@ export interface WorldCapabilities {
|
|
|
302
353
|
active: boolean;
|
|
303
354
|
};
|
|
304
355
|
/**
|
|
305
|
-
* The World's queue supports `maxConcurrency`-limited consumption
|
|
356
|
+
* The World's queue supports `maxConcurrency`-limited consumption, in
|
|
306
357
|
* particular the per-run flow topics consumed with `maxConcurrency: 1`
|
|
307
358
|
* that `WORKFLOW_SEQUENTIAL_REPLAYS=1` uses to serialize a run's
|
|
308
359
|
* orchestrator invocations. Worlds whose queue has no concurrency-limit
|
|
@@ -312,25 +363,29 @@ export interface WorldCapabilities {
|
|
|
312
363
|
* serialization also requires the build-time half (a flow trigger emitted
|
|
313
364
|
* with `maxConcurrency: 1`), which a runtime process cannot verify today.
|
|
314
365
|
* The core runtime therefore does not yet take any fast path from this
|
|
315
|
-
* capability alone
|
|
366
|
+
* capability alone: it exists so a future build-verified signal can be
|
|
316
367
|
* combined with it (and so Worlds document the contract explicitly).
|
|
317
368
|
*/
|
|
318
369
|
maxConcurrency?: boolean;
|
|
319
370
|
/**
|
|
320
371
|
* The World's `events.create` deduplicates concurrent `hook_received` writes
|
|
321
|
-
* that carry the same `(runId, resumeId)
|
|
322
|
-
* committed event and returning the canonical one to every caller.
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
372
|
+
* that carry the same `(runId, resumeId)`, collapsing them onto a single
|
|
373
|
+
* committed event and returning the canonical one to every caller. Two
|
|
374
|
+
* writers rely on it: `resumeHook()`'s durable write attaches a `resumeId` +
|
|
375
|
+
* payload digest so transport-level retries of one write converge on exactly
|
|
376
|
+
* one event, and legacy `hookInput` queue redeliveries (from older
|
|
377
|
+
* producers) converge through the same constraint.
|
|
378
|
+
*
|
|
379
|
+
* The core runtime fails closed on this: a `resumeId` is attached ONLY when
|
|
380
|
+
* the World declares `hookResumeDedup === true` (or the live backend attests
|
|
381
|
+
* it per-lookup, below). A World that accepts a `resumeId` but does not
|
|
382
|
+
* enforce the `(runId, resumeId)` constraint must leave this unset so the
|
|
383
|
+
* runtime keeps the plain single-shot write.
|
|
327
384
|
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
* does not enforce the `(runId, resumeId)` constraint must leave this unset
|
|
333
|
-
* so the runtime keeps the sequential single-writer path.
|
|
385
|
+
* Declaring this also commits the World to ROUND-TRIPPING the key:
|
|
386
|
+
* `events.list` must return `resumeId` on `hook_received` events it
|
|
387
|
+
* persisted with one, because the legacy `hookInput` consumer path detects
|
|
388
|
+
* an already-materialized resume by matching `resumeId` in the loaded log.
|
|
334
389
|
*
|
|
335
390
|
* Enabled statically for `world-local` (filesystem sidecar claim keyed on
|
|
336
391
|
* `(runId, resumeId)`; the adapter and its backend ship together, so a static
|
|
@@ -338,8 +393,8 @@ export interface WorldCapabilities {
|
|
|
338
393
|
* leaves this UNSET and instead attests support per-lookup via the
|
|
339
394
|
* server-computed, response-only `Hook.resumeCapabilities.hookResumeDedupVersion`
|
|
340
395
|
* (see `HookResumeCapabilitiesSchema`), so a server rollback or kill switch
|
|
341
|
-
* degrades new resumes to
|
|
342
|
-
* the adapter. `world-postgres` leaves it unset for now
|
|
396
|
+
* degrades new resumes to plain writes immediately without redeploying
|
|
397
|
+
* the adapter. `world-postgres` leaves it unset for now.
|
|
343
398
|
*
|
|
344
399
|
* The resume gate treats EITHER signal as backend support (see
|
|
345
400
|
* `resume-hook.ts`): this static capability OR a current
|
|
@@ -387,7 +442,7 @@ export interface World extends Queue, Streamer, Storage {
|
|
|
387
442
|
*/
|
|
388
443
|
specVersion: number;
|
|
389
444
|
/**
|
|
390
|
-
* Feature capabilities this World implementation supports
|
|
445
|
+
* Feature capabilities this World implementation supports. See
|
|
391
446
|
* {@link WorldCapabilities}. Absent (or absent members) means
|
|
392
447
|
* "unsupported": runtime optimizations gated on a capability fail closed.
|
|
393
448
|
*/
|
|
@@ -418,7 +473,7 @@ export interface World extends Queue, Streamer, Storage {
|
|
|
418
473
|
* "production" target or same git branch for "preview" deployments) as the
|
|
419
474
|
* current deployment.
|
|
420
475
|
*
|
|
421
|
-
* Not all World implementations support this
|
|
476
|
+
* Not all World implementations support this: it is only implemented by
|
|
422
477
|
* world-vercel where deployment routing is meaningful.
|
|
423
478
|
*/
|
|
424
479
|
resolveLatestDeploymentId?(): Promise<string>;
|
|
@@ -432,18 +487,18 @@ export interface World extends Queue, Streamer, Storage {
|
|
|
432
487
|
*
|
|
433
488
|
* Two overloads:
|
|
434
489
|
*
|
|
435
|
-
* - `getEncryptionKeyForRun(run)
|
|
490
|
+
* - `getEncryptionKeyForRun(run)`: Preferred. Pass a `WorkflowRun` when
|
|
436
491
|
* the run entity already exists. The World reads any context it needs
|
|
437
492
|
* (e.g., `deploymentId`) directly from the run.
|
|
438
493
|
*
|
|
439
|
-
* - `getEncryptionKeyForRun(runId, context?)
|
|
494
|
+
* - `getEncryptionKeyForRun(runId, context?)`: Used when the run entity
|
|
440
495
|
* is not locally available, such as `start()` before run creation or a
|
|
441
496
|
* forwarded writable stream carrying its owning deployment context. The
|
|
442
497
|
* `context` parameter carries opaque world-specific data (e.g.,
|
|
443
498
|
* `{ deploymentId }` for world-vercel) needed to resolve the correct key.
|
|
444
499
|
* When `context` is omitted, the World assumes the current deployment.
|
|
445
500
|
*
|
|
446
|
-
* When not implemented, encryption is disabled
|
|
501
|
+
* When not implemented, encryption is disabled: data is stored unencrypted.
|
|
447
502
|
*/
|
|
448
503
|
getEncryptionKeyForRun?(run: WorkflowRun): Promise<Uint8Array | undefined>;
|
|
449
504
|
getEncryptionKeyForRun?(runId: string, context?: Record<string, unknown>): Promise<Uint8Array | undefined>;
|
|
@@ -462,8 +517,8 @@ export interface World extends Queue, Streamer, Storage {
|
|
|
462
517
|
* @param options - The full options bag passed to `start()` (typed as
|
|
463
518
|
* `Record<string, unknown>` here to avoid a circular dependency with
|
|
464
519
|
* `@workflow/core`). Worlds should read only the fields they
|
|
465
|
-
*
|
|
466
|
-
* `options.region` to embed a region identifier.
|
|
520
|
+
* recognize. For example, `@workflow/world-vercel` reads
|
|
521
|
+
* `options.region` to embed a region identifier. Unrecognized keys
|
|
467
522
|
* must be ignored. `start()` always passes an object (an empty one
|
|
468
523
|
* when it was called with no options), but implementations should
|
|
469
524
|
* tolerate `undefined` for direct callers.
|
|
@@ -478,7 +533,7 @@ export interface World extends Queue, Streamer, Storage {
|
|
|
478
533
|
* network call. Return `undefined` when the environment can't be determined.
|
|
479
534
|
*
|
|
480
535
|
* The value MUST match the attribution the backend will actually apply to
|
|
481
|
-
* this client's writes
|
|
536
|
+
* this client's writes: for `world-vercel` that means keeping it in lockstep
|
|
482
537
|
* with the `x-vercel-environment` header (proxy path) and the OIDC token's
|
|
483
538
|
* `environment` claim (in-deployment path). A value that merely looks
|
|
484
539
|
* plausible is worse than `undefined`, because callers use it to detect
|
|
@@ -487,14 +542,14 @@ export interface World extends Queue, Streamer, Storage {
|
|
|
487
542
|
* `start()` stamps this into the queue message's `runInput` so the consuming
|
|
488
543
|
* deployment can tell that a message it was handed was created against a
|
|
489
544
|
* different environment than its own. Not all Worlds have an environment
|
|
490
|
-
* dimension
|
|
545
|
+
* dimension: local dev and Postgres have exactly one tenant, so they omit
|
|
491
546
|
* this and the check is skipped.
|
|
492
547
|
*/
|
|
493
548
|
getEnvironment?(): string | undefined;
|
|
494
549
|
/**
|
|
495
550
|
* World-specific display fields for a run.
|
|
496
551
|
*
|
|
497
|
-
* Tooling
|
|
552
|
+
* Tooling (e.g. the `workflow inspect` CLI) calls this to enrich a
|
|
498
553
|
* run's listing row / detail output with fields only the world can
|
|
499
554
|
* derive: a region decoded from the run ID, placement read off the
|
|
500
555
|
* run's `executionContext`, a shard, a billing tier, etc. Consumers
|
|
@@ -502,11 +557,11 @@ export interface World extends Queue, Streamer, Storage {
|
|
|
502
557
|
* hook is absent, no extra fields appear at all.
|
|
503
558
|
*
|
|
504
559
|
* The contract:
|
|
505
|
-
* - **Cheap and pure.** Called once per displayed run, so avoid I/O
|
|
506
|
-
*
|
|
507
|
-
* - **Read only what you
|
|
560
|
+
* - **Cheap and pure.** Called once per displayed run, so avoid I/O.
|
|
561
|
+
* Prefer deriving fields from the entity you are given.
|
|
562
|
+
* - **Read only what you recognize.** The argument is the run entity
|
|
508
563
|
* as the caller has it (a full storage run, or a leaner analytics
|
|
509
|
-
* row)
|
|
564
|
+
* row), typed loosely for the same reason as {@link createRunId}.
|
|
510
565
|
* Tolerate missing fields.
|
|
511
566
|
* - **Must not throw.**
|
|
512
567
|
* - A `null` field value means "applicable but undeterminable" and is
|
|
@@ -39,7 +39,7 @@ export declare const TraceCarrierSchema: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
|
39
39
|
export type TraceCarrier = z.infer<typeof TraceCarrierSchema>;
|
|
40
40
|
/**
|
|
41
41
|
* Run creation data carried through the queue for resilient start.
|
|
42
|
-
* Only present on the first queue delivery
|
|
42
|
+
* Only present on the first queue delivery: re-enqueues omit this.
|
|
43
43
|
* When the runtime processes the message, it passes this data to the
|
|
44
44
|
* run_started event so the server can create the run if it doesn't exist yet.
|
|
45
45
|
*/
|
|
@@ -55,35 +55,34 @@ export declare const RunInputSchema: z.ZodObject<{
|
|
|
55
55
|
}, z.core.$strip>;
|
|
56
56
|
export type RunInput = z.infer<typeof RunInputSchema>;
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
59
|
-
* invocation.
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* replaying, so the two concurrent writes converge on exactly one event.
|
|
58
|
+
* Legacy lazy hook resume data carried through the queue alongside a workflow
|
|
59
|
+
* invocation. Older producers publish this invocation and write no event of
|
|
60
|
+
* their own. On receipt, a consumer that understands `hookInput` idempotently
|
|
61
|
+
* ensures the `hook_received` event exists (keyed by `resumeId`) before
|
|
62
|
+
* replaying, so repeated deliveries converge on exactly one event.
|
|
64
63
|
*
|
|
65
64
|
* The `payload` is the already-serialized (and possibly encrypted) resume
|
|
66
|
-
* payload
|
|
67
|
-
*
|
|
65
|
+
* payload, and on this path the queue message is its only carrier. Every write
|
|
66
|
+
* derived from this message therefore hashes to the same digest under the
|
|
68
67
|
* `(runId, resumeId)` constraint.
|
|
69
68
|
*/
|
|
70
69
|
/**
|
|
71
70
|
* Resilient step dispatch data carried through the queue alongside a
|
|
72
71
|
* step-execution message ({@link WorkflowInvokePayload.stepId}). Present when
|
|
73
72
|
* the producer (the suspension handler dispatching a newly created step)
|
|
74
|
-
* parallelized the `step_created` event write with the queue publish
|
|
73
|
+
* parallelized the `step_created` event write with the queue publish: the
|
|
75
74
|
* same shape as resilient start (`runInput`) and the resilient hook resume
|
|
76
75
|
* (`hookInput`).
|
|
77
76
|
*
|
|
78
77
|
* When the producer's `step_created` write fails transiently (429 / 5xx /
|
|
79
78
|
* transport), the step entity may not exist when this message is consumed. A
|
|
80
79
|
* consumer that understands `stepInput` idempotently re-ensures the
|
|
81
|
-
* `step_created` event
|
|
82
|
-
* correlation id, unique per `(runId, correlationId)`)
|
|
80
|
+
* `step_created` event, keyed by the message's `stepId` (the step's
|
|
81
|
+
* correlation id, unique per `(runId, correlationId)`), before executing, so
|
|
83
82
|
* the producer's write and the consumer's re-ensure converge on exactly one
|
|
84
83
|
* event.
|
|
85
84
|
*
|
|
86
|
-
* The `input` is the already-serialized (and possibly encrypted) step input
|
|
85
|
+
* The `input` is the already-serialized (and possibly encrypted) step input:
|
|
87
86
|
* the identical bytes the producer also sent on the direct `events.create`.
|
|
88
87
|
*/
|
|
89
88
|
export declare const StepDispatchInputSchema: z.ZodObject<{
|
|
@@ -101,8 +100,8 @@ export declare const HookResumeInputSchema: z.ZodObject<{
|
|
|
101
100
|
export type HookResumeInput = z.infer<typeof HookResumeInputSchema>;
|
|
102
101
|
/**
|
|
103
102
|
* Wall-clock boundaries of a hook-triggered resume, carried on the queue
|
|
104
|
-
* message so the SDK can report end-to-end time-to-resume (TTR
|
|
105
|
-
* `resumeHook()` through to the first line of the next durable step
|
|
103
|
+
* message so the SDK can report end-to-end time-to-resume (TTR, entry into
|
|
104
|
+
* `resumeHook()` through to the first line of the next durable step) and its
|
|
106
105
|
* non-overlapping phase breakdown, as span attributes on that step's
|
|
107
106
|
* `step.execute` span. See `runtime/resume-latency.ts` in `@workflow/core`.
|
|
108
107
|
*
|
|
@@ -120,13 +119,13 @@ export type HookResumeInput = z.infer<typeof HookResumeInputSchema>;
|
|
|
120
119
|
*
|
|
121
120
|
* Every field is advisory and the whole object is optional, in all three
|
|
122
121
|
* directions that matter for a rolling deploy: a new producer's timing is
|
|
123
|
-
* ignored by an old consumer, a new consumer
|
|
122
|
+
* ignored by an old consumer, a new consumer reports no TTR for an old
|
|
124
123
|
* message, and workflow-server never reads it at all.
|
|
125
124
|
*
|
|
126
125
|
* `strategy` and `setupSource` are deliberately typed as plain strings rather
|
|
127
126
|
* than enums: an unrecognized value from a newer producer must not fail the
|
|
128
|
-
* parse of the whole invocation payload (which would wedge the run)
|
|
129
|
-
* only ever forwarded to a span attribute.
|
|
127
|
+
* parse of the whole invocation payload (which would wedge the run), since it
|
|
128
|
+
* is only ever forwarded to a span attribute.
|
|
130
129
|
*/
|
|
131
130
|
export declare const HookResumeTimingSchema: z.ZodObject<{
|
|
132
131
|
resumeRequestedAtMs: z.ZodNumber;
|
|
@@ -149,6 +148,10 @@ export declare const WorkflowInvokePayloadSchema: z.ZodObject<{
|
|
|
149
148
|
preconditionReinvocations: z.ZodOptional<z.ZodNumber>;
|
|
150
149
|
serverErrorRetryCount: z.ZodOptional<z.ZodNumber>;
|
|
151
150
|
deploymentMismatchRetryCount: z.ZodOptional<z.ZodNumber>;
|
|
151
|
+
waitContinuation: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
152
|
+
correlationId: z.ZodString;
|
|
153
|
+
attempt: z.ZodNumber;
|
|
154
|
+
}, z.core.$strip>>>;
|
|
152
155
|
stepId: z.ZodOptional<z.ZodString>;
|
|
153
156
|
stepName: z.ZodOptional<z.ZodString>;
|
|
154
157
|
runInput: z.ZodOptional<z.ZodObject<{
|
|
@@ -201,8 +204,8 @@ export declare const HealthCheckPayloadSchema: z.ZodObject<{
|
|
|
201
204
|
* an optional `runId`, so a probe payload also satisfies
|
|
202
205
|
* `WorkflowInvokePayloadSchema` (whose only required field is `runId`). With
|
|
203
206
|
* the invoke member first, parsing a runId-bearing probe silently dropped
|
|
204
|
-
* `__healthCheck` and `correlationId`, and the runtime
|
|
205
|
-
* `__healthCheck` before falling through to the invoke schema
|
|
207
|
+
* `__healthCheck` and `correlationId`, and the runtime (which dispatches on
|
|
208
|
+
* `__healthCheck` before falling through to the invoke schema) reinterpreted
|
|
206
209
|
* the probe as "replay this run". That made the queue handler POST
|
|
207
210
|
* `run_started` for a run that doesn't exist yet (404), fail, and retry
|
|
208
211
|
* forever, so the probe never answered and `start()` timed out.
|
|
@@ -225,6 +228,10 @@ export declare const QueuePayloadSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
225
228
|
preconditionReinvocations: z.ZodOptional<z.ZodNumber>;
|
|
226
229
|
serverErrorRetryCount: z.ZodOptional<z.ZodNumber>;
|
|
227
230
|
deploymentMismatchRetryCount: z.ZodOptional<z.ZodNumber>;
|
|
231
|
+
waitContinuation: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
232
|
+
correlationId: z.ZodString;
|
|
233
|
+
attempt: z.ZodNumber;
|
|
234
|
+
}, z.core.$strip>>>;
|
|
228
235
|
stepId: z.ZodOptional<z.ZodString>;
|
|
229
236
|
stepName: z.ZodOptional<z.ZodString>;
|
|
230
237
|
runInput: z.ZodOptional<z.ZodObject<{
|
|
@@ -276,7 +283,7 @@ export interface QueueOptions {
|
|
|
276
283
|
* `@vercel/queue` client uses to route the message; when omitted, the
|
|
277
284
|
* region is resolved from the payload's tagged run ID, then from the
|
|
278
285
|
* `VERCEL_REGION` environment variable, and finally defaults to `'iad1'`
|
|
279
|
-
* (the pre-regional-routing
|
|
286
|
+
* (the pre-regional-routing behavior).
|
|
280
287
|
*/
|
|
281
288
|
region?: string;
|
|
282
289
|
}
|
|
@@ -308,7 +315,7 @@ export interface Queue {
|
|
|
308
315
|
* `step_started` records the handling invocation's messageId, and only a
|
|
309
316
|
* delivery of that same message may re-execute the step before the
|
|
310
317
|
* ownership lease expires (crash recovery via queue redelivery). A World
|
|
311
|
-
* whose queue mints a fresh ID per delivery degrades gracefully
|
|
318
|
+
* whose queue mints a fresh ID per delivery degrades gracefully: owner
|
|
312
319
|
* redeliveries fall back to the delayed-backstop path instead of executing
|
|
313
320
|
* immediately, adding recovery latency but never wedging or duplicating.
|
|
314
321
|
*/
|
|
@@ -151,6 +151,26 @@ export interface CreateWorkflowRunRequest {
|
|
|
151
151
|
export interface GetWorkflowRunParams {
|
|
152
152
|
resolveData?: ResolveData;
|
|
153
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Params for the optional `runs.waitForTerminalStatus` long poll.
|
|
156
|
+
*/
|
|
157
|
+
export interface WaitForTerminalRunStatusParams extends GetWorkflowRunParams {
|
|
158
|
+
/**
|
|
159
|
+
* How long the caller is willing to wait, in milliseconds. Treat it as an
|
|
160
|
+
* upper bound on the wait, not a promise about the duration: the call
|
|
161
|
+
* resolves as soon as the run is terminal, and a World may also resolve
|
|
162
|
+
* early with a non-terminal snapshot (see
|
|
163
|
+
* {@link Storage.runs.waitForTerminalStatus}).
|
|
164
|
+
*
|
|
165
|
+
* Implementations clamp this to whatever their backend can hold open.
|
|
166
|
+
*/
|
|
167
|
+
timeoutMs?: number;
|
|
168
|
+
/**
|
|
169
|
+
* Abandon the wait when this signal aborts. Implementations that cannot
|
|
170
|
+
* observe it may ignore it; callers must not rely on it to bound the call.
|
|
171
|
+
*/
|
|
172
|
+
signal?: AbortSignal;
|
|
173
|
+
}
|
|
154
174
|
export interface ListWorkflowRunsParams {
|
|
155
175
|
workflowName?: string;
|
|
156
176
|
status?: WorkflowRunStatus;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* The one thing that does *not* survive: a slot id's leading characters are
|
|
16
16
|
* zeros, so decoding it as a ULID timestamp yields the Unix epoch. Nothing may
|
|
17
|
-
* derive a time from an event id without first ruling out a slot id
|
|
17
|
+
* derive a time from an event id without first ruling out a slot id. See
|
|
18
18
|
* {@link isSlotBody} and the guard in `ulidToDate`.
|
|
19
19
|
*/
|
|
20
20
|
/** Characters in an event id body, ULID or slot alike. */
|
|
@@ -41,7 +41,7 @@ export declare function isSlotEventId(eventId: string): boolean;
|
|
|
41
41
|
/**
|
|
42
42
|
* Formats a slot as a prefixed event id.
|
|
43
43
|
*
|
|
44
|
-
* @throws if the slot is outside the representable range
|
|
44
|
+
* @throws if the slot is outside the representable range: a caller that
|
|
45
45
|
* overflows must fail loudly rather than mint an id that sorts wrong.
|
|
46
46
|
*/
|
|
47
47
|
export declare function slotToEventId(slot: number): string;
|
|
@@ -57,7 +57,7 @@ export declare function eventIdToSlot(eventId: string): number | null;
|
|
|
57
57
|
* Separate from {@link eventIdToSlot} because the two failures are different
|
|
58
58
|
* problems. A caller that can act on either scheme asks the question and takes
|
|
59
59
|
* `null` as an answer; a caller whose whole computation is positional (a
|
|
60
|
-
* precondition snapshot, a density audit) has no correct
|
|
60
|
+
* precondition snapshot, a density audit) has no correct behavior to fall back
|
|
61
61
|
* on, and silently skipping the id would make it report a position it never
|
|
62
62
|
* verified. Throwing names the id instead.
|
|
63
63
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Spec version utilities for
|
|
2
|
+
* Spec version utilities for backward compatibility.
|
|
3
3
|
*
|
|
4
4
|
* Uses a branded type to ensure packages import the version constants
|
|
5
5
|
* from @workflow/world rather than using arbitrary numbers.
|
|
@@ -14,7 +14,7 @@ export type SpecVersion = number & {
|
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
16
|
* Legacy spec version (pre-event-sourcing). Also used for runs without specVersion.
|
|
17
|
-
* This is the only true legacy version
|
|
17
|
+
* This is the only true legacy version: specVersion 2+ all use the event-sourced model.
|
|
18
18
|
*/
|
|
19
19
|
export declare const SPEC_VERSION_LEGACY: SpecVersion;
|
|
20
20
|
export declare const SPEC_VERSION_SUPPORTS_EVENT_SOURCING: SpecVersion;
|
|
@@ -44,17 +44,41 @@ export declare const SPEC_VERSION_SUPPORTS_COMPRESSION: SpecVersion;
|
|
|
44
44
|
* all. See `SPEC_VERSION_CURRENT`.
|
|
45
45
|
*/
|
|
46
46
|
export declare const SPEC_VERSION_SUPPORTS_SLOT_IDENTITY: SpecVersion;
|
|
47
|
+
/**
|
|
48
|
+
* Runs at this spec version or later live in a "sealed log": their slot
|
|
49
|
+
* positions are pre-assigned by a per-run sequencer on the World's backend,
|
|
50
|
+
* so concurrent writers never race each other for a position. A position
|
|
51
|
+
* whose writer died is filled ("sealed") by the backend with a `noop` event.
|
|
52
|
+
* What the version gates is the READER contract that makes that safe: a
|
|
53
|
+
* reader at this version knows a `noop` occupies its slot and carries no
|
|
54
|
+
* workflow meaning, and skips it during replay without advancing the
|
|
55
|
+
* deterministic clock (see `EventsConsumer`). A reader below this version
|
|
56
|
+
* would fail to parse the unknown event type, which is exactly what
|
|
57
|
+
* `requiresNewerWorld` exists to catch.
|
|
58
|
+
*
|
|
59
|
+
* Note this is the READER contract only, so a World is spec-7 compliant by
|
|
60
|
+
* construction if it allocates each position at the commit that occupies it:
|
|
61
|
+
* no write can then leave a position empty, so it has no holes to seal and
|
|
62
|
+
* will never emit a `noop`. Pre-assigning positions ahead of the commit is
|
|
63
|
+
* what creates the obligation (see `building-a-world.mdx`), and only a World
|
|
64
|
+
* that does so needs the sealing half.
|
|
65
|
+
*/
|
|
66
|
+
export declare const SPEC_VERSION_SUPPORTS_SEALED_LOG: SpecVersion;
|
|
47
67
|
/**
|
|
48
68
|
* Current spec version: event-sourced architecture with native attributes,
|
|
49
|
-
* compressed payloads
|
|
69
|
+
* compressed payloads, slot-numbered event ids, and sealed-log sequencing.
|
|
50
70
|
*
|
|
51
71
|
* This is both the version a World stamps on the runs it creates and the
|
|
52
72
|
* *lowest* one this runtime accepts from a World (see
|
|
53
|
-
* `assertWorldSupportsRuntimeProtocol`).
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
73
|
+
* `assertWorldSupportsRuntimeProtocol`). Slot numbering is a requirement of
|
|
74
|
+
* the World contract rather than a capability to opt into: a World declaring
|
|
75
|
+
* anything below this allocates event ids the runtime cannot read positions
|
|
76
|
+
* out of, so admitting it would only move the failure from startup to the
|
|
77
|
+
* middle of a run.
|
|
78
|
+
*
|
|
79
|
+
* This is the FLOOR, not necessarily what gets stamped. Sealed-log runs sit
|
|
80
|
+
* one version above it and are opt-in, so what a World actually stamps comes
|
|
81
|
+
* from {@link mintedSpecVersion}; this is what that falls back to.
|
|
58
82
|
*
|
|
59
83
|
* A World therefore declares this constant rather than a literal, so a bump
|
|
60
84
|
* moves the declaration and the floor together. Pinning a literal would leave
|
|
@@ -66,16 +90,59 @@ export declare const SPEC_VERSION_SUPPORTS_SLOT_IDENTITY: SpecVersion;
|
|
|
66
90
|
* run's identity scheme from what is stored rather than from this constant.
|
|
67
91
|
*/
|
|
68
92
|
export declare const SPEC_VERSION_CURRENT: SpecVersion;
|
|
93
|
+
/**
|
|
94
|
+
* Environment variable that opts new runs OUT of the sealed log.
|
|
95
|
+
*
|
|
96
|
+
* Read per `createWorld()` call rather than at module load, so a test or a
|
|
97
|
+
* single process can create worlds in both modes.
|
|
98
|
+
*/
|
|
99
|
+
export declare const SEALED_LOG_ENV_VAR = "WORKFLOW_SEALED_LOG";
|
|
100
|
+
/**
|
|
101
|
+
* The spec version a World should stamp on the runs it creates: the sealed log
|
|
102
|
+
* unless {@link SEALED_LOG_ENV_VAR} switches it off, in which case the
|
|
103
|
+
* slot-identity version it supersedes.
|
|
104
|
+
*
|
|
105
|
+
* Same shape, and the same reasoning, as the flag slot identity itself shipped
|
|
106
|
+
* behind before going unconditional: default on, with one env var to put a
|
|
107
|
+
* deployment back on the previous scheme without a release.
|
|
108
|
+
*
|
|
109
|
+
* What default-on rests on is the density requirement in
|
|
110
|
+
* `Storage['events']`: a reader's log must be a PREFIX of the run's log, so
|
|
111
|
+
* that the number of events it holds tells it whether it has the whole thing.
|
|
112
|
+
* A sealed log satisfies that by repair rather than by construction — a
|
|
113
|
+
* position is handed out before its write commits, so a read can land while
|
|
114
|
+
* one is still empty — and it is only equivalent if a read that cannot see
|
|
115
|
+
* past such a position waits for it to be filled or sealed instead of
|
|
116
|
+
* reporting a log that ends there. It has to be the READ that waits, because
|
|
117
|
+
* a shorter prefix is a legal log state and nothing downstream can tell the
|
|
118
|
+
* two apart. The first rollout of this default shipped without that: the
|
|
119
|
+
* backend's in-request poll budget was shorter than the age a position must
|
|
120
|
+
* reach before it can be sealed, so the read always gave up and truncated,
|
|
121
|
+
* and a replay took a step whose completion sat above the gap to be still
|
|
122
|
+
* running — then sat on it for a full inline-ownership lease.
|
|
123
|
+
*
|
|
124
|
+
* The fallback is a real fallback, not a formality. Turning this off has to
|
|
125
|
+
* leave a World the runtime still admits, which is why
|
|
126
|
+
* `assertWorldSupportsRuntimeProtocol` floors at the slot-identity version
|
|
127
|
+
* rather than at {@link SPEC_VERSION_CURRENT} because a kill switch that made
|
|
128
|
+
* the runtime reject its own World would be no kill switch at all.
|
|
129
|
+
*
|
|
130
|
+
* Every World reads runs up to {@link SPEC_VERSION_MAX_SUPPORTED} whatever
|
|
131
|
+
* this returns, so switching it off here does not make runs another process
|
|
132
|
+
* created unreadable.
|
|
133
|
+
*/
|
|
134
|
+
export declare function mintedSpecVersion(env?: Record<string, string | undefined>): SpecVersion;
|
|
69
135
|
/**
|
|
70
136
|
* The highest spec version this SDK can read.
|
|
71
137
|
*
|
|
72
|
-
* Kept distinct from `SPEC_VERSION_CURRENT
|
|
73
|
-
*
|
|
74
|
-
* we still read?", and they come apart in the release order a spec
|
|
75
|
-
* follows: a reader that can already handle the next version raises this
|
|
76
|
-
* ceiling first, and
|
|
77
|
-
*
|
|
78
|
-
*
|
|
138
|
+
* Kept distinct from `SPEC_VERSION_CURRENT`, and right now they genuinely
|
|
139
|
+
* differ. They answer different questions, "what do we write?" versus "what
|
|
140
|
+
* can we still read?", and they come apart in exactly the release order a spec
|
|
141
|
+
* bump follows: a reader that can already handle the next version raises this
|
|
142
|
+
* ceiling first, and stamping follows only once the version is safe to mint
|
|
143
|
+
* everywhere. Sealed-log support is at that first stage. Every build reads
|
|
144
|
+
* spec 7 and skips `noop`, while {@link mintedSpecVersion} still has to be
|
|
145
|
+
* turned on before anything creates a spec-7 run.
|
|
79
146
|
*/
|
|
80
147
|
export declare const SPEC_VERSION_MAX_SUPPORTED: SpecVersion;
|
|
81
148
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from '#compiled/zod/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* A workflow run ID: the `wrun_` prefix followed by a 26-char ULID (minted
|
|
4
|
-
* client-side in core's `start()`). Validates the exact shape
|
|
5
|
-
* well-formed ULID
|
|
4
|
+
* client-side in core's `start()`). Validates the exact shape (prefix plus a
|
|
5
|
+
* well-formed ULID) rather than a loose length bound, so callers can't smuggle
|
|
6
6
|
* arbitrary strings through APIs that persist a run ID verbatim.
|
|
7
7
|
*/
|
|
8
8
|
export declare const workflowRunIdSchema: z.ZodTemplateLiteral<`wrun_${string}`>;
|