eve 0.29.4 → 0.30.0
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 +28 -0
- package/dist/src/channel/clear-session.d.ts +4 -0
- package/dist/src/channel/clear-session.js +1 -0
- package/dist/src/channel/compact-session.d.ts +4 -0
- package/dist/src/channel/compact-session.js +1 -0
- package/dist/src/channel/routes.d.ts +34 -6
- package/dist/src/channel/types.d.ts +61 -9
- package/dist/src/chunks/{use-eve-agent-8mofdZcO.js → use-eve-agent-BXMIf5fR.js} +85 -1
- package/dist/src/chunks/{use-eve-agent-bKJbH0k4.js → use-eve-agent-k-XHfrJT.js} +85 -1
- package/dist/src/cli/dev/tui/message-queue.d.ts +12 -16
- package/dist/src/cli/dev/tui/message-queue.js +1 -1
- package/dist/src/cli/dev/tui/prompt-commands.d.ts +13 -5
- package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +7 -7
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/setup-panel.js +4 -1
- package/dist/src/cli/dev/tui/subagent-pump.d.ts +5 -5
- package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
- package/dist/src/client/agent-info-schema.d.ts +2 -2
- package/dist/src/client/agent-info-schema.js +1 -1
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/client/session.d.ts +15 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/client/types.d.ts +20 -0
- package/dist/src/compiled/.vendor-stamp.json +6 -6
- package/dist/src/compiled/@workflow/core/_devalue.d.ts +8 -0
- package/dist/src/compiled/@workflow/core/capabilities.d.ts +5 -0
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/replay-payload-cache.d.ts +11 -0
- package/dist/src/compiled/@workflow/core/runtime/compute-instance.d.ts +12 -0
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +18 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +103 -31
- package/dist/src/compiled/@workflow/core/runtime/replay-recovery-reporter.d.ts +36 -0
- package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +22 -2
- package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +17 -13
- package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +13 -8
- package/dist/src/compiled/@workflow/core/runtime.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/runtime.js +3 -3
- package/dist/src/compiled/@workflow/core/serialization/codec.d.ts +17 -0
- package/dist/src/compiled/@workflow/core/serialization/hardened.d.ts +155 -0
- package/dist/src/compiled/@workflow/core/serialization/index.d.ts +2 -1
- package/dist/src/compiled/@workflow/core/serialization/reducers/common.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization.d.ts +13 -9
- package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +41 -0
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/index.d.ts +16 -8
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world/analytics.d.ts +2 -0
- package/dist/src/compiled/@workflow/world/events.d.ts +87 -0
- package/dist/src/compiled/@workflow/world/hooks.d.ts +39 -0
- package/dist/src/compiled/@workflow/world/index.d.ts +1 -1
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +61 -0
- package/dist/src/compiled/@workflow/world/queue.d.ts +40 -0
- package/dist/src/compiled/@workflow/world-local/index.js +3 -3
- package/dist/src/compiled/@workflow/world-vercel/index.js +14 -14
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-1LmTKuTT.js → attribute-changes-DROfGk6l.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/{dist-WjtNsOyf.js → dist-D5bR13zs.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{dist-BeQ_csYA.js → dist-dNxTT6nO.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/resume-hook-bc-OQVI0.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-DM3ouA3U.js +1 -0
- package/dist/src/compiled/_chunks/workflow/sleep-D5iWly6-.js +1 -0
- package/dist/src/compiled/_chunks/workflow/wait-until-DoW76jdb.js +15 -0
- package/dist/src/compiler/extension-compatibility.d.ts +8 -8
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.d.ts +11 -22
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-agent-config.d.ts +3 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/compiler/normalize-subagent.d.ts +1 -0
- package/dist/src/compiler/normalize-subagent.js +1 -1
- package/dist/src/compiler/remote-agent-node.d.ts +3 -0
- package/dist/src/context/dynamic-subagent-lifecycle.d.ts +22 -0
- package/dist/src/context/dynamic-subagent-lifecycle.js +1 -0
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/context/keys.d.ts +21 -2
- package/dist/src/context/keys.js +1 -1
- package/dist/src/context/run-step.js +1 -1
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
- package/dist/src/execution/create-session-step.d.ts +2 -0
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/delegation-tool.d.ts +3 -0
- package/dist/src/execution/delegation-tool.js +1 -0
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
- package/dist/src/execution/dispatch-workflow-runtime-actions-step.js +1 -1
- package/dist/src/execution/effective-agent-config.d.ts +12 -0
- package/dist/src/execution/effective-agent-config.js +1 -0
- package/dist/src/execution/node-step.d.ts +4 -0
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/remote-agent-dispatch.d.ts +3 -1
- package/dist/src/execution/remote-agent-dispatch.js +1 -1
- package/dist/src/execution/runtime-context.d.ts +2 -0
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/session-callback-request.d.ts +5 -0
- package/dist/src/execution/session-callback-request.js +1 -0
- package/dist/src/execution/session-delivery-hook.d.ts +1 -0
- package/dist/src/execution/session-delivery-hook.js +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/subagent-event-proxy-step.js +1 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +2 -0
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/harness/agent-handles.d.ts +238 -0
- package/dist/src/harness/agent-handles.js +2 -0
- package/dist/src/harness/compaction.d.ts +1 -1
- package/dist/src/harness/compaction.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/types.d.ts +16 -0
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/core.js +1 -1
- package/dist/src/internal/authored-module-loader.js +1 -1
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.d.ts +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/vercel-agent-summary.d.ts +1 -1
- package/dist/src/internal/workflow-bundle/dynamic-capability-transform-plugin.d.ts +10 -0
- package/dist/src/internal/workflow-bundle/dynamic-capability-transform-plugin.js +1 -0
- package/dist/src/internal/workflow-bundle/dynamic-remote-agent-transform.d.ts +7 -0
- package/dist/src/internal/workflow-bundle/dynamic-remote-agent-transform.js +3 -0
- package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.d.ts +2 -0
- package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.js +1 -1
- package/dist/src/internal/workflow-bundle/dynamic-tool-transform.js +2 -2
- package/dist/src/protocol/clear-session.d.ts +14 -0
- package/dist/src/protocol/clear-session.js +1 -0
- package/dist/src/protocol/compact-session.d.ts +14 -0
- package/dist/src/protocol/compact-session.js +1 -0
- package/dist/src/protocol/message.d.ts +19 -1
- package/dist/src/protocol/message.js +1 -1
- package/dist/src/protocol/routes.d.ts +10 -0
- package/dist/src/protocol/routes.js +1 -1
- package/dist/src/public/channels/auth.d.ts +11 -25
- package/dist/src/public/channels/auth.js +1 -1
- package/dist/src/public/channels/eve.js +1 -1
- package/dist/src/public/channels/index.d.ts +1 -1
- package/dist/src/public/definitions/agent.d.ts +35 -1
- package/dist/src/public/definitions/agent.js +1 -1
- package/dist/src/public/definitions/channel.d.ts +5 -2
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/definitions/hook.d.ts +1 -0
- package/dist/src/public/definitions/tool.d.ts +4 -1
- package/dist/src/public/index.d.ts +1 -2
- package/dist/src/public/index.js +1 -1
- package/dist/src/runtime/framework-channels/index.js +1 -1
- package/dist/src/runtime/framework-tools/connection-search-dynamic.d.ts +2 -18
- package/dist/src/runtime/framework-tools/connection-search-dynamic.js +2 -2
- package/dist/src/runtime/framework-tools/index.d.ts +7 -2
- package/dist/src/runtime/framework-tools/index.js +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/resolve-dynamic-subagent.d.ts +12 -0
- package/dist/src/runtime/resolve-dynamic-subagent.js +1 -0
- package/dist/src/runtime/resolve-dynamic-tool.d.ts +15 -0
- package/dist/src/runtime/resolve-dynamic-tool.js +1 -1
- package/dist/src/runtime/subagents/dynamic-agent-config.d.ts +22 -0
- package/dist/src/runtime/subagents/dynamic-agent-config.js +1 -0
- package/dist/src/runtime/subagents/dynamic-remote-agent-config.d.ts +13 -0
- package/dist/src/runtime/subagents/dynamic-remote-agent-config.js +1 -0
- package/dist/src/runtime/subagents/registry.d.ts +10 -2
- package/dist/src/runtime/subagents/registry.js +1 -1
- package/dist/src/runtime/types.d.ts +11 -2
- package/dist/src/setup/flows/registry.js +1 -1
- package/dist/src/setup/scaffold/channels-catalog.d.ts +2 -2
- package/dist/src/setup/scaffold/channels-catalog.js +1 -1
- package/dist/src/setup/scaffold/connections/catalog.d.ts +2 -2
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +7 -0
- package/dist/src/shared/agent-turn-outcome.d.ts +47 -0
- package/dist/src/shared/agent-turn-outcome.js +1 -0
- package/dist/src/shared/dynamic-tool-definition.d.ts +1 -5
- package/dist/src/shared/dynamic-tool-definition.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/channels/custom.mdx +41 -1
- package/docs/channels/eve.mdx +27 -2
- package/docs/concepts/default-harness.md +4 -0
- package/docs/concepts/sessions-runs-and-streaming.md +1 -1
- package/docs/guides/auth-and-route-protection.md +13 -13
- package/docs/guides/client/streaming.mdx +14 -0
- package/docs/guides/dev-tui.md +12 -9
- package/docs/guides/dynamic-capabilities.md +74 -6
- package/docs/guides/frontend/nextjs.mdx +1 -1
- package/docs/guides/frontend/nuxt.mdx +1 -1
- package/docs/guides/frontend/sveltekit.mdx +1 -1
- package/docs/guides/remote-agents.md +33 -0
- package/docs/reference/project-layout.md +1 -1
- package/docs/reference/typescript-api.md +48 -48
- package/docs/subagents.mdx +32 -2
- package/package.json +8 -8
- package/dist/src/compiled/_chunks/workflow/resume-hook-D1_5NCZ6.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-C240Ctf4.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-De802yfX.js +0 -1
- package/dist/src/compiled/_chunks/workflow/wait-until-z48sPUjU.js +0 -15
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hardened introspection for serializing values that may originate inside a
|
|
3
|
+
* workflow VM (`node:vm`) sandbox realm.
|
|
4
|
+
*
|
|
5
|
+
* Serialization runs on the host, but the values it inspects were
|
|
6
|
+
* constructed by workflow code — so a naive dynamic operation like
|
|
7
|
+
* `value.toISOString()`, `Array.from(map)`, or `Object.prototype.toString`
|
|
8
|
+
* dispatches into the sandbox realm and executes workflow code (patched
|
|
9
|
+
* prototype methods, getters, proxy traps, `Symbol.toStringTag` accessors).
|
|
10
|
+
* That is a determinism hazard: serialization happens exactly once per
|
|
11
|
+
* payload (never again on replay), so any workflow-visible side effect it
|
|
12
|
+
* triggers exists only on the live execution path and diverges from replay.
|
|
13
|
+
*
|
|
14
|
+
* This module makes serialization side-effect free wherever the data allows
|
|
15
|
+
* it, and *observable* where it does not:
|
|
16
|
+
*
|
|
17
|
+
* - **Classification** uses engine-level brand checks (`node:util` `types`,
|
|
18
|
+
* internal-slot probes) instead of `instanceof` / `Object.prototype.toString`
|
|
19
|
+
* — immune to `Symbol.hasInstance`, `Symbol.toStringTag`, and reassigned
|
|
20
|
+
* globals.
|
|
21
|
+
* - **Extraction** goes through intrinsics captured at module load (host
|
|
22
|
+
* boot, before any workflow code runs). Internal slots are realm-agnostic,
|
|
23
|
+
* so host intrinsics read VM-realm objects without touching the sandbox's
|
|
24
|
+
* (patchable) prototypes.
|
|
25
|
+
* - **Property access** reads through descriptors, so plain data never
|
|
26
|
+
* invokes anything. Where workflow code *must* run because the data itself
|
|
27
|
+
* lives behind it — getters, proxies, custom `[WORKFLOW_SERIALIZE]`
|
|
28
|
+
* methods, `toString()` on toStringTag-branded objects (e.g. Temporal
|
|
29
|
+
* polyfills) — the execution is preserved for compatibility and recorded
|
|
30
|
+
* in the active {@link GuestCodeStats} sink, so callers (e.g. a retained-VM
|
|
31
|
+
* gate) can react.
|
|
32
|
+
*
|
|
33
|
+
* **Recording is not prevention.** For the recorded cases the determinism
|
|
34
|
+
* hazard is still live: a getter that calls `Math.random()` advances the
|
|
35
|
+
* run's seeded PRNG during serialization, and because serialization happens
|
|
36
|
+
* exactly once and is never replayed, every subsequent draw — including the
|
|
37
|
+
* correlation ids derived from that stream — shifts relative to replay. The
|
|
38
|
+
* report is the only trace of that; acting on it (warning, demoting a
|
|
39
|
+
* retained VM to replay) is left to the caller.
|
|
40
|
+
*
|
|
41
|
+
* The recorder is ambient module state, set for the duration of a
|
|
42
|
+
* synchronous `stringify` call via {@link withGuestCodeStats}. devalue's
|
|
43
|
+
* `stringify` is fully synchronous, so this is safe without async context.
|
|
44
|
+
*/
|
|
45
|
+
import type { StringifyOperations } from '../_devalue.js';
|
|
46
|
+
/**
|
|
47
|
+
* A single instance of workflow (guest) code executing during serialization.
|
|
48
|
+
*/
|
|
49
|
+
export interface GuestCodeExecution {
|
|
50
|
+
/**
|
|
51
|
+
* What forced the execution:
|
|
52
|
+
* - `getter`: an accessor property was invoked to read data
|
|
53
|
+
* - `proxy`: a proxy was introspected, firing its traps. Note this also
|
|
54
|
+
* implies a **shape change**: brand checks answer "not that type" for a
|
|
55
|
+
* proxy, so a proxied `Map` serializes as a plain object rather than as a
|
|
56
|
+
* `Map`, and this report is the only evidence of it. (Such values were
|
|
57
|
+
* never serializable before — the internal-slot reads in the previous
|
|
58
|
+
* implementation threw on them — so the shape change replaces a crash,
|
|
59
|
+
* but it is silent.)
|
|
60
|
+
* - `method`: a workflow-defined function was invoked (e.g. a custom
|
|
61
|
+
* `[WORKFLOW_SERIALIZE]` serializer, `toString()` on a
|
|
62
|
+
* `Symbol.toStringTag`-branded object, a duck-typed `getTime()`, or a
|
|
63
|
+
* `__closureVarsFn` this package did not generate)
|
|
64
|
+
*/
|
|
65
|
+
kind: 'getter' | 'proxy' | 'method';
|
|
66
|
+
/** Best-effort context: the property key, method name, or tag involved. */
|
|
67
|
+
detail?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Mutable sink recording every workflow-code execution serialization could
|
|
71
|
+
* not avoid. Pass via `CodecOptions.guestCodeStats`; consumers that retain
|
|
72
|
+
* the VM across steps can use a non-empty `executions` array as a signal
|
|
73
|
+
* that the VM state may have been perturbed by serialization.
|
|
74
|
+
*/
|
|
75
|
+
export interface GuestCodeStats {
|
|
76
|
+
executions: GuestCodeExecution[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Runs `fn` (synchronously) with `stats` as the active guest-code sink.
|
|
80
|
+
* Nested calls stack correctly; a `null`/`undefined` sink disables
|
|
81
|
+
* recording without disabling hardening.
|
|
82
|
+
*/
|
|
83
|
+
export declare function withGuestCodeStats<T>(stats: GuestCodeStats | undefined, fn: () => T): T;
|
|
84
|
+
/** Marks a function as having been passed to `useStep`. */
|
|
85
|
+
export declare function markUseStepClosureFn<T extends object>(fn: T): T;
|
|
86
|
+
/** Whether `fn` was marked by {@link markUseStepClosureFn}. */
|
|
87
|
+
export declare function isUseStepClosureFn(fn: unknown): boolean;
|
|
88
|
+
export declare function recordGuestCode(kind: GuestCodeExecution['kind'], detail?: string): void;
|
|
89
|
+
/** `Date.prototype.getDate`, for invalid-date checks. */
|
|
90
|
+
export declare const dateGetDate: (thisArg: unknown) => number;
|
|
91
|
+
/** `Date.prototype.getTime`. */
|
|
92
|
+
export declare const dateGetTime: (thisArg: unknown) => number;
|
|
93
|
+
/** `Date.prototype.toISOString`. */
|
|
94
|
+
export declare const dateToISOString: (thisArg: unknown) => string;
|
|
95
|
+
/** `RegExp.prototype.source` getter. */
|
|
96
|
+
export declare const regExpSource: (value: unknown) => string;
|
|
97
|
+
/** `RegExp.prototype.flags` getter. */
|
|
98
|
+
export declare const regExpFlags: (value: unknown) => string;
|
|
99
|
+
/** `ArrayBuffer.prototype.byteLength` getter (internal slot read). */
|
|
100
|
+
export declare const arrayBufferByteLength: (value: unknown) => number;
|
|
101
|
+
/**
|
|
102
|
+
* Reads `value[key]` with `[[Get]]` semantics, but through descriptors:
|
|
103
|
+
* plain data properties never invoke anything; accessor properties are
|
|
104
|
+
* invoked (the data lives behind them) and recorded; proxies fall back to
|
|
105
|
+
* a plain read (their traps are the only access path) and are recorded.
|
|
106
|
+
*/
|
|
107
|
+
export declare function readProperty(value: unknown, key: PropertyKey): unknown;
|
|
108
|
+
/**
|
|
109
|
+
* `key in value` semantics without firing proxy traps for ordinary
|
|
110
|
+
* objects. Proxies fall back to the `in` operator and are recorded.
|
|
111
|
+
*/
|
|
112
|
+
export declare function hasProperty(value: unknown, key: PropertyKey): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* `value instanceof C` semantics for a known `C.prototype`, without
|
|
115
|
+
* consulting `Symbol.hasInstance` (which workflow code can define). Used
|
|
116
|
+
* for host classes that are injected into the sandbox (Headers, URL,
|
|
117
|
+
* URLSearchParams, DOMException), where the instances — from any realm the
|
|
118
|
+
* host handed the class to — carry the host prototype in their chain.
|
|
119
|
+
*
|
|
120
|
+
* Proxies are walked rather than rejected: `Reflect.getPrototypeOf` fires
|
|
121
|
+
* the proxy's `getPrototypeOf` trap, matching `instanceof` semantics, and
|
|
122
|
+
* real values depend on that — Next.js hands the runtime a proxied
|
|
123
|
+
* `NextRequest`, and answering "not a Request" for it would silently break
|
|
124
|
+
* webhooks. The traps are guest-observable, so the proxy is recorded.
|
|
125
|
+
*/
|
|
126
|
+
export declare function isInstanceOfPrototype(value: unknown, prototype: object | undefined): boolean;
|
|
127
|
+
/** `URL.prototype.href` getter. */
|
|
128
|
+
export declare function urlHref(value: URL): string;
|
|
129
|
+
/** `URLSearchParams.prototype.toString` — returns `''` iff empty. */
|
|
130
|
+
export declare function urlSearchParamsToString(value: URLSearchParams): string;
|
|
131
|
+
/**
|
|
132
|
+
* Iterates a Headers instance through the captured host iterator, so the
|
|
133
|
+
* iterator object — and its `next` — are host-realm.
|
|
134
|
+
*/
|
|
135
|
+
export declare function headersToEntries(value: Headers): [string, string][];
|
|
136
|
+
/**
|
|
137
|
+
* Iterates a genuine Map's entries entirely through host intrinsics: the
|
|
138
|
+
* iterator object is created by the host `Map.prototype.entries`, so its
|
|
139
|
+
* realm — and therefore its `next` — is the host's, not the sandbox's.
|
|
140
|
+
*/
|
|
141
|
+
export declare function mapToEntries(value: Map<unknown, unknown>): [unknown, unknown][];
|
|
142
|
+
/** See {@link mapToEntries}. */
|
|
143
|
+
export declare function setToValues(value: Set<unknown>): unknown[];
|
|
144
|
+
/**
|
|
145
|
+
* The bytes of an `ArrayBufferView`, read via internal-slot getters —
|
|
146
|
+
* own-property shadowing and prototype patches cannot change which bytes
|
|
147
|
+
* are serialized.
|
|
148
|
+
*/
|
|
149
|
+
export declare function viewInfo(value: ArrayBufferView): {
|
|
150
|
+
buffer: ArrayBufferLike;
|
|
151
|
+
byteOffset: number;
|
|
152
|
+
byteLength: number;
|
|
153
|
+
};
|
|
154
|
+
export declare const hardenedStringifyOperations: Partial<StringifyOperations>;
|
|
155
|
+
//# sourceMappingURL=hardened.d.ts.map
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
* Re-exports the mode-specific serialize/deserialize functions and
|
|
5
5
|
* the codec/format/encryption abstractions.
|
|
6
6
|
*/
|
|
7
|
-
export type { Codec, SerializationMode } from './codec.js';
|
|
7
|
+
export type { Codec, CodecOptions, SerializationMode } from './codec.js';
|
|
8
8
|
export { devalueCodec } from './codec-devalue.js';
|
|
9
9
|
export { COMPRESSION_MIN_BYTES, type CompressionCodec, type CompressionStats, compress, decompress, isCompressed, } from './compression.js';
|
|
10
10
|
export { type CryptoKey, decrypt, type EncryptionKeyParam, encrypt, } from './encryption.js';
|
|
11
11
|
export { decodeFormatPrefix, encodeWithFormatPrefix, isEncrypted, peekFormatPrefix, } from './format.js';
|
|
12
|
+
export type { GuestCodeExecution, GuestCodeStats } from './hardened.js';
|
|
12
13
|
export type { FormatPrefix, Reducers, Revivers, SerializableSpecial, } from './types.js';
|
|
13
14
|
export { isFormatPrefix, SerializationFormat } from './types.js';
|
|
14
15
|
import * as client from './client.js';
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { Reducers, Revivers } from '../types.js';
|
|
12
12
|
declare function revive(str: string): any;
|
|
13
|
-
export declare function getCommonReducers(
|
|
13
|
+
export declare function getCommonReducers(_global?: Record<string, any>): Partial<Reducers>;
|
|
14
14
|
export declare function getCommonRevivers(global?: Record<string, any>): Partial<Revivers>;
|
|
15
15
|
export { revive };
|
|
16
16
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { compress, decompress } from './serialization/compression.js';
|
|
2
2
|
import { aesKeyOf, decrypt, deriveRunPayloadKeys, type EncryptionKeyParam, encrypt, isRunPayloadKeys, isSealTarget, type PayloadKey, type RunPayloadKeys, runPayloadKeys, type SealTarget, sealTo } from './serialization/encryption.js';
|
|
3
3
|
import { decodeFormatPrefix, encodeWithFormatPrefix, isEncrypted, peekFormatPrefix } from './serialization/format.js';
|
|
4
|
+
import { type GuestCodeStats } from './serialization/hardened.js';
|
|
4
5
|
import { type FormatPrefix, isFormatPrefix, SerializationFormat } from './serialization/types.js';
|
|
5
6
|
export { SerializationFormat, type FormatPrefix, isFormatPrefix, encodeWithFormatPrefix, decodeFormatPrefix, peekFormatPrefix, isEncrypted, encrypt, decrypt, compress, decompress, type EncryptionKeyParam, type PayloadKey, type RunPayloadKeys, type SealTarget, sealTo, runPayloadKeys, deriveRunPayloadKeys, isSealTarget, isRunPayloadKeys, aesKeyOf, };
|
|
6
7
|
export type SerializationFormatType = (typeof SerializationFormat)[keyof typeof SerializationFormat];
|
|
@@ -121,13 +122,6 @@ import type { ByteStreamFraming, Reducers, Revivers } from './serialization/type
|
|
|
121
122
|
* @returns
|
|
122
123
|
*/
|
|
123
124
|
export declare function getExternalReducers(global: Record<string, any> | undefined, ops: Promise<void>[], runId: string, cryptoKey: EncryptionKeyParam, framedByteStreams?: boolean, runReadyBarrier?: Promise<unknown>): Partial<Reducers>;
|
|
124
|
-
/**
|
|
125
|
-
* Reducers for serialization boundary from within the workflow execution
|
|
126
|
-
* environment, passing return value to the client side and into step arguments.
|
|
127
|
-
*
|
|
128
|
-
* @param global
|
|
129
|
-
* @returns
|
|
130
|
-
*/
|
|
131
125
|
export declare function getWorkflowReducers(global?: Record<string, any>): Partial<Reducers>;
|
|
132
126
|
/**
|
|
133
127
|
* Cancel dangling abort-stream readers on any AbortController instances found
|
|
@@ -394,7 +388,15 @@ export declare function hydrateWorkflowArguments(value: Uint8Array | unknown, _r
|
|
|
394
388
|
/**
|
|
395
389
|
* Dehydrate workflow return value for storage.
|
|
396
390
|
*/
|
|
397
|
-
export declare function dehydrateWorkflowReturnValue(value: unknown, _runId: string, key: PayloadKey | undefined, global?: Record<string, any>, v1Compat?: boolean, compression?: boolean
|
|
391
|
+
export declare function dehydrateWorkflowReturnValue(value: unknown, _runId: string, key: PayloadKey | undefined, global?: Record<string, any>, v1Compat?: boolean, compression?: boolean,
|
|
392
|
+
/**
|
|
393
|
+
* Optional sink receiving every workflow-code execution serialization could
|
|
394
|
+
* not avoid, for callers that need them programmatically (e.g. a
|
|
395
|
+
* retained-VM gate deciding whether the VM is still reusable). The
|
|
396
|
+
* executions are emitted as span attributes either way, so omitting this
|
|
397
|
+
* loses nothing observability-wise. No runtime caller passes one yet.
|
|
398
|
+
*/
|
|
399
|
+
guestCodeStatsOut?: GuestCodeStats): Promise<Uint8Array | unknown>;
|
|
398
400
|
/**
|
|
399
401
|
* Called from the client side to hydrate the workflow return value
|
|
400
402
|
* of a completed workflow run.
|
|
@@ -404,7 +406,9 @@ export declare function hydrateWorkflowReturnValue(value: Uint8Array | unknown,
|
|
|
404
406
|
* Called from the workflow handler when a step is being created.
|
|
405
407
|
* Dehydrates values from within the workflow execution environment.
|
|
406
408
|
*/
|
|
407
|
-
export declare function dehydrateStepArguments(value: unknown, _runId: string, key: PayloadKey | undefined, global?: Record<string, any>, v1Compat?: boolean, compression?: boolean
|
|
409
|
+
export declare function dehydrateStepArguments(value: unknown, _runId: string, key: PayloadKey | undefined, global?: Record<string, any>, v1Compat?: boolean, compression?: boolean,
|
|
410
|
+
/** See `dehydrateWorkflowReturnValue`. */
|
|
411
|
+
guestCodeStatsOut?: GuestCodeStats): Promise<Uint8Array | unknown>;
|
|
408
412
|
/**
|
|
409
413
|
* Called from the step executor to hydrate the arguments of a step
|
|
410
414
|
* from the database at the start of the step execution.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
-
import type { PayloadKey } from '../serialization/encryption.js';
|
|
3
2
|
import type { FlushableStreamState } from '../flushable-stream.js';
|
|
3
|
+
import type { PayloadKey } from '../serialization/encryption.js';
|
|
4
4
|
import type { WorkflowMetadata } from '../workflow/get-workflow-metadata.js';
|
|
5
5
|
import type { StepMetadata } from './get-step-metadata.js';
|
|
6
6
|
/**
|
|
@@ -140,6 +140,15 @@ export declare const WorkflowRouteEntrypointAgeMs: (value: number) => {
|
|
|
140
140
|
export declare const WorkflowRouteModuleBodyInitMs: (value: number) => {
|
|
141
141
|
[k: string]: number;
|
|
142
142
|
};
|
|
143
|
+
/**
|
|
144
|
+
* Compute instance handling this route — the synthesized `COMPUTE_INSTANCE_ID`.
|
|
145
|
+
* Uses OTEL `faas.instance` (execution-environment id, reused across
|
|
146
|
+
* invocations to the same function):
|
|
147
|
+
* https://opentelemetry.io/docs/specs/semconv/attributes-registry/faas/
|
|
148
|
+
*/
|
|
149
|
+
export declare const FaasInstance: (value: string) => {
|
|
150
|
+
[k: string]: string;
|
|
151
|
+
};
|
|
143
152
|
/** Name of the step function being executed */
|
|
144
153
|
export declare const StepName: (value: string) => {
|
|
145
154
|
[k: string]: string;
|
|
@@ -289,6 +298,24 @@ export declare const HookId: (value: string) => {
|
|
|
289
298
|
export declare const HookFound: (value: boolean) => {
|
|
290
299
|
[k: string]: boolean;
|
|
291
300
|
};
|
|
301
|
+
/**
|
|
302
|
+
* Producer-side signal (on the `hook.resume` span) that the direct
|
|
303
|
+
* `hook_received` write failed transiently but the queue dispatch succeeded, so
|
|
304
|
+
* the resume is recovered via the consumer's re-ensure. Corresponds to
|
|
305
|
+
* `ResumedHook.resilientResume === true`.
|
|
306
|
+
*/
|
|
307
|
+
export declare const HookResilientResume: (value: boolean) => {
|
|
308
|
+
[k: string]: boolean;
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* Consumer-side signal (on the workflow execution span) that this replay
|
|
312
|
+
* materialized the `hook_received` event from the queue message's `hookInput`
|
|
313
|
+
* because the producer's direct write had not landed — the completion of the
|
|
314
|
+
* recovery path {@link HookResilientResume} began.
|
|
315
|
+
*/
|
|
316
|
+
export declare const HookResilientResumeMaterialized: (value: boolean) => {
|
|
317
|
+
[k: string]: boolean;
|
|
318
|
+
};
|
|
292
319
|
/** Number of webhook handlers triggered */
|
|
293
320
|
export declare const WebhookHandlersTriggered: (value: number) => {
|
|
294
321
|
[k: string]: number;
|
|
@@ -377,6 +404,20 @@ export declare const SerializationStoredBytes: (value: number) => {
|
|
|
377
404
|
export declare const SerializationCompressionRatio: (value: number) => {
|
|
378
405
|
[k: string]: number;
|
|
379
406
|
};
|
|
407
|
+
/**
|
|
408
|
+
* Number of workflow (guest) code executions serialization could not avoid
|
|
409
|
+
* (getters, proxies, custom serializers); set only when non-zero.
|
|
410
|
+
*/
|
|
411
|
+
export declare const SerializationGuestCodeExecutions: (value: number) => {
|
|
412
|
+
[k: string]: number;
|
|
413
|
+
};
|
|
414
|
+
/**
|
|
415
|
+
* Deduplicated `kind (detail)` descriptions of the guest-code executions;
|
|
416
|
+
* set only when non-zero.
|
|
417
|
+
*/
|
|
418
|
+
export declare const SerializationGuestCodeDetails: (value: string[]) => {
|
|
419
|
+
[k: string]: string[];
|
|
420
|
+
};
|
|
380
421
|
/** The remote service name for Datadog service maps (Datadog-specific: peer.service) */
|
|
381
422
|
export declare const PeerService: (value: string) => {
|
|
382
423
|
[k: string]: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "5.0.0-beta.
|
|
1
|
+
export declare const version = "5.0.0-beta.39";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Cn as e,Gn as t,Kn as n,Wn as r,wn as i,zn as a}from"../../_chunks/workflow/wait-until-DoW76jdb.js";import"../../_chunks/workflow/dist-B-vbuNqP.js";import{i as o}from"../../_chunks/workflow/workflow-routes-CwqB063q.js";import{i as s,u as c}from"../../_chunks/workflow/dist-dNxTT6nO.js";import{c as l,i as u,o as d,r as f,t as p}from"../../_chunks/workflow/attribute-changes-DROfGk6l.js";import{t as m}from"../../_chunks/workflow/sleep-D5iWly6-.js";import{t as h}from"../../_chunks/workflow/run-DM3ouA3U.js";i(e,h);function g(e){let t=globalThis[r];return t||u(`createHook()`,`https://workflow-sdk.dev/docs/api-reference/workflow/create-hook`,g),t(e)}function _(e){let{respondWith:t,token:n,...r}=e??{};if(n!==void 0)throw Error("`createWebhook()` does not accept a `token` option. Webhook tokens are always randomly generated. Use `createHook()` with `resumeHook()` for deterministic token patterns.");let i;t!==void 0&&(i={respondWith:t});let a=g({...r,metadata:i,isWebhook:!0}),{url:s}=l();return a.url=o(s,{type:`webhook`,token:a.token}),a}function v(){function e(t,n){d(`defineHook().resume()`,`https://workflow-sdk.dev/docs/api-reference/workflow-api/resume-hook`,e)}return{create(e){return g(e)},resume:e}}async function y(e,t={}){let r=p(e,t);if(r.length===0)return;let i=t.allowReservedAttributes===!0,a=globalThis[n];if(!a)throw new s("setAttributes() called outside a workflow runtime context. It must be called from within a workflow body (`use workflow`).");await a(r,i?{allowReservedAttributes:!0}:{})}function b(e={}){let{namespace:n}=e,r=globalThis[t](n);return Object.create(globalThis.WritableStream.prototype,{[a]:{value:r,writable:!1}})}function x(){f(`getStepMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-step-metadata`,x)}function S(){d(`resumeHook()`,`https://workflow-sdk.dev/docs/api-reference/workflow-api/resume-hook`,S)}export{s as FatalError,c as RetryableError,g as createHook,_ as createWebhook,v as defineHook,x as getStepMetadata,l as getWorkflowMetadata,b as getWritable,S as resumeHook,y as setAttributes,m as sleep};
|
|
@@ -446,21 +446,29 @@ export declare class ThrottleError extends WorkflowWorldError {
|
|
|
446
446
|
}
|
|
447
447
|
/**
|
|
448
448
|
* Thrown when the backend rejects an event creation because the client's
|
|
449
|
-
* event-log snapshot is stale —
|
|
450
|
-
*
|
|
451
|
-
* replayed from (HTTP 412).
|
|
449
|
+
* event-log snapshot is stale — the log the client replayed from is missing
|
|
450
|
+
* an event the backend has already recorded (HTTP 412).
|
|
452
451
|
*
|
|
453
|
-
* The workflow runtime handles this automatically: it
|
|
454
|
-
*
|
|
455
|
-
* interacting with world storage backends directly may encounter it.
|
|
452
|
+
* The workflow runtime handles this automatically: it restarts the replay from
|
|
453
|
+
* a corrected event log, ultimately re-enqueueing the run if it cannot catch
|
|
454
|
+
* up. Users interacting with world storage backends directly may encounter it.
|
|
456
455
|
*
|
|
457
456
|
* @property retryAfter - Delay in seconds before retrying. Accepted for
|
|
458
|
-
* forward-compatibility; the runtime
|
|
459
|
-
*
|
|
457
|
+
* forward-compatibility; the runtime restarts its replay immediately and
|
|
458
|
+
* does not read this field.
|
|
459
|
+
* @property details - Optional rejection detail supplied by the World. A World
|
|
460
|
+
* MAY attach the events the client's snapshot was missing so the client can
|
|
461
|
+
* correct its log without a follow-up fetch; see the `stateCursor` contract
|
|
462
|
+
* on `CreateEventParams`. Typed `unknown` because this package cannot depend
|
|
463
|
+
* on the event type — consumers narrow it themselves and must treat a
|
|
464
|
+
* missing or malformed value as "no detail" (a full reload is always
|
|
465
|
+
* correct).
|
|
460
466
|
*/
|
|
461
467
|
export declare class PreconditionFailedError extends WorkflowWorldError {
|
|
468
|
+
readonly details?: unknown;
|
|
462
469
|
constructor(message: string, options?: {
|
|
463
470
|
retryAfter?: number;
|
|
471
|
+
details?: unknown;
|
|
464
472
|
});
|
|
465
473
|
static is(value: unknown): value is PreconditionFailedError;
|
|
466
474
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,D as t,E as n,O as r,S as i,T as a,_ as o,a as s,b as c,c as l,d as u,f as d,g as f,h as p,i as m,l as h,m as g,n as _,o as v,p as y,r as b,s as x,t as S,u as C,v as w,w as T,x as E,y as D}from"../../_chunks/workflow/dist-
|
|
1
|
+
import{C as e,D as t,E as n,O as r,S as i,T as a,_ as o,a as s,b as c,c as l,d as u,f as d,g as f,h as p,i as m,l as h,m as g,n as _,o as v,p as y,r as b,s as x,t as S,u as C,v as w,w as T,x as E,y as D}from"../../_chunks/workflow/dist-dNxTT6nO.js";export{S as CorruptedEventLogError,_ as ERROR_SLUGS,b as EntityConflictError,m as FatalError,s as HookConflictError,v as HookNotFoundError,x as MaxEventsExceededError,l as PreconditionFailedError,r as RUN_ERROR_CODES,h as ReplayDivergenceError,C as RetryableError,u as RunExpiredError,d as RunNotSupportedError,y as RuntimeDecryptionError,g as SerializationError,p as StepNotRegisteredError,f as ThrottleError,o as TooEarlyError,w as VERCEL_403_ERROR_MESSAGE,D as WorkflowBuildError,c as WorkflowError,E as WorkflowNotRegisteredError,i as WorkflowRunCancelledError,e as WorkflowRunFailedError,T as WorkflowRunNotCompletedError,a as WorkflowRunNotFoundError,n as WorkflowRuntimeError,t as WorkflowWorldError};
|
|
@@ -41,6 +41,7 @@ export declare const AnalyticsStepSchema: z.ZodObject<{
|
|
|
41
41
|
errorCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
42
42
|
workflowCoreVersion: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
43
43
|
workflowEncryptionEnabled: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
44
|
+
computeInstanceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
44
45
|
}, z.core.$strip>;
|
|
45
46
|
export declare const AnalyticsEventSchema: z.ZodObject<{
|
|
46
47
|
runId: z.ZodString;
|
|
@@ -75,6 +76,7 @@ export declare const AnalyticsEventSchema: z.ZodObject<{
|
|
|
75
76
|
region: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
76
77
|
vercelId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
77
78
|
requestId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
79
|
+
computeInstanceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
78
80
|
resumeAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedDate<unknown>>>>;
|
|
79
81
|
retryAfter: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedDate<unknown>>>>;
|
|
80
82
|
errorCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -548,6 +548,7 @@ export declare const EventSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<[z.Z
|
|
|
548
548
|
createdAt: z.ZodCoercedDate<unknown>;
|
|
549
549
|
occurredAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
550
550
|
specVersion: z.ZodOptional<z.ZodNumber>;
|
|
551
|
+
resumeId: z.ZodOptional<z.ZodString>;
|
|
551
552
|
}, z.core.$strip>>;
|
|
552
553
|
export type Event = z.infer<typeof EventSchema>;
|
|
553
554
|
export type EventOfType<T extends EventType> = Extract<Event, {
|
|
@@ -586,8 +587,31 @@ export type CreateEventRequest = Exclude<AnyEventRequest, RunCreatedEventRequest
|
|
|
586
587
|
export interface CreateEventParams {
|
|
587
588
|
v1Compat?: boolean;
|
|
588
589
|
resolveData?: ResolveData;
|
|
590
|
+
/**
|
|
591
|
+
* Lazy hook resume idempotency key. Set only by `resumeHook()` when it
|
|
592
|
+
* persists a `hook_received` event whose creation must be deduplicated
|
|
593
|
+
* against a concurrent re-ensure from the queue consumer. The World routes
|
|
594
|
+
* it to the backend's `(runId, resumeId)` constraint so both writers
|
|
595
|
+
* converge on exactly one event. Only meaningful for `hook_received`.
|
|
596
|
+
*/
|
|
597
|
+
resumeId?: string;
|
|
598
|
+
/**
|
|
599
|
+
* Content digest of the serialized resume payload, computed once by
|
|
600
|
+
* `resumeHook()` and forwarded identically on the direct write and the queue
|
|
601
|
+
* re-ensure. The World routes it to the backend so both writers record the
|
|
602
|
+
* same digest on the `(runId, resumeId)` constraint. Only meaningful
|
|
603
|
+
* alongside {@link resumeId}.
|
|
604
|
+
*/
|
|
605
|
+
resumePayloadDigest?: string;
|
|
589
606
|
/** Request ID (x-vercel-id when on Vercel) for correlating request logs with workflow events. */
|
|
590
607
|
requestId?: string;
|
|
608
|
+
/**
|
|
609
|
+
* Compute instance whose handler is writing this event (`COMPUTE_INSTANCE_ID`
|
|
610
|
+
* in @workflow/core). Ambient per-event identity like {@link requestId},
|
|
611
|
+
* which distinguishes invocations *within* an instance. Read back via
|
|
612
|
+
* `AnalyticsEventSchema` / `AnalyticsStepSchema`.
|
|
613
|
+
*/
|
|
614
|
+
computeInstanceId?: string;
|
|
591
615
|
/**
|
|
592
616
|
* Epoch ms (the ULID time of the latest event the runtime has loaded during
|
|
593
617
|
* replay). Sent by replay-context creates so the backend can reject the event
|
|
@@ -604,14 +628,77 @@ export interface CreateEventParams {
|
|
|
604
628
|
* timestamp must pass (anti-livelock, so an up-to-date client is never
|
|
605
629
|
* rejected). A backend that ignores this field simply disables the guard —
|
|
606
630
|
* the client falls open and behaves as before.
|
|
631
|
+
*
|
|
632
|
+
* A watermark alone cannot see an event *missing at or below* it, which is
|
|
633
|
+
* the failure that actually corrupts a replay — see {@link stateEventCount}
|
|
634
|
+
* for the second half of the guard.
|
|
607
635
|
*/
|
|
608
636
|
stateUpdatedAt?: number;
|
|
637
|
+
/**
|
|
638
|
+
* How many loaded events have a ULID time at or below {@link stateUpdatedAt}.
|
|
639
|
+
* Since `stateUpdatedAt` is the *maximum* ULID time in the loaded log, this
|
|
640
|
+
* equals the loaded array's length. Sent **only** together with
|
|
641
|
+
* `stateUpdatedAt`; a World must ignore a count that arrives without one.
|
|
642
|
+
*
|
|
643
|
+
* This closes the hole a watermark cannot: the watermark proves only "no
|
|
644
|
+
* newer event exists", while a replay corrupts its log by missing an event
|
|
645
|
+
* at or *below* its own frontier — a concurrent writer commits in the same
|
|
646
|
+
* ULID millisecond as the client's last loaded event, so the two watermarks
|
|
647
|
+
* compare equal and the write is accepted against a log that is one event
|
|
648
|
+
* short. Because correlation IDs are positional ordinals of a single seeded
|
|
649
|
+
* sequence, that one-event difference renames every entity after it.
|
|
650
|
+
*
|
|
651
|
+
* Backend contract (for World implementers who want to support this half):
|
|
652
|
+
*
|
|
653
|
+
* - Count **every** created event for the run, including replay-origin ones.
|
|
654
|
+
* Unlike the watermark, this is not restricted to out-of-band writes: the
|
|
655
|
+
* race being fenced is one replay against another.
|
|
656
|
+
* - Reject with 412 when the count of recorded events at ULID time
|
|
657
|
+
* `<= stateUpdatedAt` is strictly **greater** than `stateEventCount`.
|
|
658
|
+
* - Compare **at or below** `stateUpdatedAt`, never strictly below (the
|
|
659
|
+
* missing event routinely shares the client's frontier millisecond) and
|
|
660
|
+
* never against a total (all the creates of one suspension share one
|
|
661
|
+
* snapshot, so a total would reject every sibling after the first).
|
|
662
|
+
* - **One-sided safety is mandatory.** Anything that makes the backend's
|
|
663
|
+
* count incomplete, uncomputable, or expired must *allow* the write. A
|
|
664
|
+
* rejection has to imply a real hole, because the client responds to it by
|
|
665
|
+
* discarding and re-deriving its whole replay.
|
|
666
|
+
*
|
|
667
|
+
* See also the millisecond-granularity caveat on `stateUpdatedAt`: the count
|
|
668
|
+
* is what makes an equal-timestamp snapshot safe to accept.
|
|
669
|
+
*/
|
|
670
|
+
stateEventCount?: number;
|
|
671
|
+
/**
|
|
672
|
+
* The client's current event-log cursor (advisory). Sent alongside the other
|
|
673
|
+
* two snapshot fields so a World that rejects the write MAY return the
|
|
674
|
+
* events the client is missing on the 412 itself, saving the client a
|
|
675
|
+
* follow-up `events.list`.
|
|
676
|
+
*
|
|
677
|
+
* Distinct from {@link sinceCursor}: a World must **not** compute a delta for
|
|
678
|
+
* this on the accepted path — it exists purely to make a rejection cheaper.
|
|
679
|
+
* Returning events on a 412 is OPTIONAL, and the returned set must be
|
|
680
|
+
* provably complete (it must account for the entire discrepancy the
|
|
681
|
+
* rejection reported) or omitted entirely: a cursor filters by lexicographic
|
|
682
|
+
* event id while a hole is defined by ULID time, so a naive
|
|
683
|
+
* "everything after the cursor" delta can silently exclude the very event
|
|
684
|
+
* the client is missing. A client that receives nothing does the
|
|
685
|
+
* authoritative full reload, which is always correct.
|
|
686
|
+
*/
|
|
687
|
+
stateCursor?: string;
|
|
609
688
|
/**
|
|
610
689
|
* Timestamp for when the event occurred on the client side. Worlds that
|
|
611
690
|
* support this can persist it separately from `createdAt`, which represents
|
|
612
691
|
* when the backing service accepted or stored the event.
|
|
613
692
|
*/
|
|
614
693
|
occurredAt?: Date;
|
|
694
|
+
/**
|
|
695
|
+
* Number of consecutive replay divergences resolved by this event write.
|
|
696
|
+
*
|
|
697
|
+
* This is request telemetry, not workflow state. Worlds may use it for
|
|
698
|
+
* metrics and diagnostics, but must not require it for event
|
|
699
|
+
* materialization or persist it into the event log.
|
|
700
|
+
*/
|
|
701
|
+
replayDivergenceCount?: number;
|
|
615
702
|
/**
|
|
616
703
|
* Inline-delta optimization (opt-in). When set, the World MAY return,
|
|
617
704
|
* on the resulting {@link EventResult}, the first page of events written
|
|
@@ -18,8 +18,43 @@ export declare const HookResumeContextSchema: z.ZodObject<{
|
|
|
18
18
|
workflowCoreVersion: z.ZodOptional<z.ZodString>;
|
|
19
19
|
traceCarrier: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
20
20
|
encryptionPublicKey: z.ZodOptional<z.ZodString>;
|
|
21
|
+
hookResumeInputVersion: z.ZodOptional<z.ZodNumber>;
|
|
21
22
|
}, z.core.$strip>;
|
|
22
23
|
export type HookResumeContext = z.infer<typeof HookResumeContextSchema>;
|
|
24
|
+
/**
|
|
25
|
+
* Current version of the lazy-hook-resume consumer protocol. A run's creating
|
|
26
|
+
* deployment stamps this into its execution context (and the server mirrors it
|
|
27
|
+
* onto `HookResumeContext.hookResumeInputVersion`) to attest that its
|
|
28
|
+
* `@workflow/core` re-ensures the `hook_received` event from a queue message's
|
|
29
|
+
* `hookInput`. `resumeHook()`'s parallel fast path requires the target run's
|
|
30
|
+
* marker to be at least this value. Bump only on a breaking change to the
|
|
31
|
+
* `hookInput` re-ensure contract.
|
|
32
|
+
*/
|
|
33
|
+
export declare const HOOK_RESUME_INPUT_VERSION = 1;
|
|
34
|
+
/**
|
|
35
|
+
* Current version of the backend lazy-hook-resume dedup contract: the live
|
|
36
|
+
* backend enforces a `(runId, resumeId)` constraint so the direct write and the
|
|
37
|
+
* queue consumer's re-ensure converge on exactly one `hook_received`.
|
|
38
|
+
* `resumeHook()`'s parallel fast path requires the backend to attest at least
|
|
39
|
+
* this version. Bump only on a breaking change to the constraint semantics.
|
|
40
|
+
*/
|
|
41
|
+
export declare const HOOK_RESUME_DEDUP_VERSION = 1;
|
|
42
|
+
/**
|
|
43
|
+
* Backend-attested capabilities for lazy hook resume, computed FRESH on every
|
|
44
|
+
* by-token hook lookup and returned inline on {@link HookSchema.resumeCapabilities}.
|
|
45
|
+
*
|
|
46
|
+
* Response-only and transient: NEVER persisted on the hook entity and NEVER
|
|
47
|
+
* part of {@link HookResumeContextSchema}. Recomputing it per response is what
|
|
48
|
+
* makes a server rollback or kill switch take effect immediately — a rolled-back
|
|
49
|
+
* or kill-switched server simply stops emitting it, dropping new resumes to the
|
|
50
|
+
* sequential path with no stranded hooks. (Contrast with the per-run, persisted
|
|
51
|
+
* `hookResumeInputVersion`, which attests the *consumer* and is fixed at run
|
|
52
|
+
* creation.)
|
|
53
|
+
*/
|
|
54
|
+
export declare const HookResumeCapabilitiesSchema: z.ZodObject<{
|
|
55
|
+
hookResumeDedupVersion: z.ZodNumber;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
export type HookResumeCapabilities = z.infer<typeof HookResumeCapabilitiesSchema>;
|
|
23
58
|
/**
|
|
24
59
|
* Schema for workflow hooks.
|
|
25
60
|
*
|
|
@@ -46,6 +81,10 @@ export declare const HookSchema: z.ZodObject<{
|
|
|
46
81
|
workflowCoreVersion: z.ZodOptional<z.ZodString>;
|
|
47
82
|
traceCarrier: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
48
83
|
encryptionPublicKey: z.ZodOptional<z.ZodString>;
|
|
84
|
+
hookResumeInputVersion: z.ZodOptional<z.ZodNumber>;
|
|
85
|
+
}, z.core.$strip>>;
|
|
86
|
+
resumeCapabilities: z.ZodOptional<z.ZodObject<{
|
|
87
|
+
hookResumeDedupVersion: z.ZodNumber;
|
|
49
88
|
}, z.core.$strip>>;
|
|
50
89
|
}, z.core.$strip>;
|
|
51
90
|
/**
|
|
@@ -6,7 +6,7 @@ export { _resetEnvWarnCacheForTests, type EnvNumberOptions, envNumber, } from '.
|
|
|
6
6
|
export type * from './events.js';
|
|
7
7
|
export { BaseEventSchema, CHILD_ENTITY_CREATION_EVENT_TYPES, CreateEventSchema, EVENT_DATA_PAYLOAD_FIELD_BY_EVENT_TYPE, EVENT_DATA_REF_FIELDS, EventSchema, EventTypeSchema, getEventDataPayloadField, getEventDataRefFields, HOOK_EVENTS_REQUIRING_EXISTENCE, HOOK_LIFECYCLE_EVENT_TYPES, HookCreatedEventSchema, isChildEntityCreationEvent, isChildEntityCreationEventType, isHookEventRequiringExistence, isHookLifecycleEventType, isRunEventType, isStepEventType, isTerminalRunEventType, isTerminalStepEventType, isWaitEventType, RUN_EVENT_TYPES, STEP_EVENT_TYPES, stripEventDataRefs, TERMINAL_RUN_EVENT_TYPES, TERMINAL_STEP_EVENT_TYPES, TerminalRunEventTypeSchema, WAIT_EVENT_TYPES, } from './events.js';
|
|
8
8
|
export type * from './hooks.js';
|
|
9
|
-
export { HookSchema } from './hooks.js';
|
|
9
|
+
export { HOOK_RESUME_DEDUP_VERSION, HOOK_RESUME_INPUT_VERSION, HookResumeCapabilitiesSchema, HookSchema, } from './hooks.js';
|
|
10
10
|
export type * from './interfaces.js';
|
|
11
11
|
export type * from './queue.js';
|
|
12
12
|
export { getQueueTopicPrefix, HealthCheckPayloadSchema, MessageId, parseQueueName, QueuePayloadSchema, QueuePrefix, RunInputSchema, resolveQueueNamespace, ValidQueueName, WorkflowInvokePayloadSchema, } from './queue.js';
|