eve 0.13.3 → 0.13.5
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 +21 -0
- package/dist/src/channel/schedule-auth.d.ts +7 -0
- package/dist/src/channel/schedule-auth.js +1 -0
- package/dist/src/channel/schedule.d.ts +2 -6
- package/dist/src/channel/schedule.js +1 -1
- package/dist/src/chunks/use-eve-agent-BjAM8_a3.js +1499 -0
- package/dist/src/chunks/use-eve-agent-_dbX0ASK.js +1529 -0
- package/dist/src/client/agent-info-schema.d.ts +1 -1
- package/dist/src/client/agent-info-schema.js +1 -1
- package/dist/src/client/message-reducer.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +3 -3
- package/dist/src/compiled/@ai-sdk/anthropic/index.js +2 -2
- package/dist/src/compiled/@ai-sdk/google/index.js +6 -6
- package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/openai/index.js +2 -2
- package/dist/src/compiled/@workflow/core/create-hook.d.ts +3 -1
- package/dist/src/compiled/@workflow/core/events-consumer.d.ts +9 -0
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/logger.d.ts +1 -0
- package/dist/src/compiled/@workflow/core/private.d.ts +35 -2
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +73 -0
- package/dist/src/compiled/@workflow/core/runtime/get-port-lazy.d.ts +15 -0
- package/dist/src/compiled/@workflow/core/runtime/run-id-time.d.ts +10 -0
- package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +61 -1
- package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +38 -2
- package/dist/src/compiled/@workflow/core/runtime.d.ts +1 -0
- package/dist/src/compiled/@workflow/core/runtime.js +28 -28
- package/dist/src/compiled/@workflow/core/source-map.d.ts +5 -0
- package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +27 -0
- package/dist/src/compiled/@workflow/core/step-hydration-cache.d.ts +148 -0
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +28 -0
- package/dist/src/compiled/@workflow/core/telemetry.d.ts +9 -6
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/vm/script-cache.d.ts +28 -0
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/world/events.d.ts +78 -3
- package/dist/src/compiled/@workflow/world/index.d.ts +1 -1
- package/dist/src/compiled/@workflow/world/spec-version.d.ts +11 -1
- package/dist/src/compiled/_chunks/{workflow/core-CXJbIkCL.js → client/core-Bm8azZA6.js} +5 -5
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-Bi5DLT8S.js → attribute-changes-DUxG-Gic.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/dist-C9PV_vnE.js +77 -0
- package/dist/src/compiled/_chunks/workflow/resume-hook-CUCPW67D.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{run-XM8dTRAo.js → run-CVlF84yI.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/sleep-Dxuzj5to.js +1 -0
- package/dist/src/compiled/zod/index.js +1 -1
- package/dist/src/compiled/zod-validation-error/index.js +1 -1
- package/dist/src/execution/hook-ownership.d.ts +7 -0
- package/dist/src/execution/hook-ownership.js +1 -0
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/harness/action-result-helpers.d.ts +2 -3
- package/dist/src/harness/action-result-helpers.js +1 -1
- package/dist/src/harness/authorization.d.ts +1 -0
- package/dist/src/harness/authorization.js +1 -1
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/messages.js +1 -1
- package/dist/src/harness/provider-tools.d.ts +4 -27
- package/dist/src/harness/provider-tools.js +1 -1
- package/dist/src/harness/step-hooks.d.ts +0 -13
- package/dist/src/harness/step-hooks.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/harness/tool-output-serialization.d.ts +17 -0
- package/dist/src/harness/tool-output-serialization.js +1 -0
- package/dist/src/harness/tools.js +1 -1
- package/dist/src/internal/application/optional-package-install.js +15 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-core-shim.d.ts +10 -8
- package/dist/src/public/channels/slack/defaults.js +1 -1
- package/dist/src/runtime/framework-tools/web-search.d.ts +2 -2
- package/dist/src/runtime/framework-tools/web-search.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/empty-delivery.d.ts +3 -0
- package/dist/src/shared/empty-delivery.js +1 -0
- 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 +1 -1
- package/docs/channels/eve.mdx +1 -1
- package/docs/concepts/execution-model-and-durability.md +2 -0
- package/docs/guides/client/continuations.mdx +4 -0
- package/docs/guides/client/streaming.mdx +6 -0
- package/docs/guides/frontend/overview.mdx +28 -8
- package/docs/schedules.mdx +5 -3
- package/docs/tools/overview.mdx +2 -0
- package/package.json +4 -4
- package/dist/src/chunks/use-eve-agent-B18LYpfZ.js +0 -5765
- package/dist/src/chunks/use-eve-agent-BPI1nbo5.js +0 -5795
- package/dist/src/compiled/_chunks/workflow/coerce-B-Ro4Nfe.js +0 -1
- package/dist/src/compiled/_chunks/workflow/compat-DLpWymPP.js +0 -1
- package/dist/src/compiled/_chunks/workflow/dist-DTchiX0N.js +0 -14
- package/dist/src/compiled/_chunks/workflow/resume-hook-CKTw-lb5.js +0 -1
- package/dist/src/compiled/_chunks/workflow/schemas-iG9Z4s4o.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-DPjVkRY-.js +0 -1
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Remaps an error stack trace using inline source maps to show original source locations.
|
|
3
3
|
*
|
|
4
|
+
* Degrades gracefully when the bundle has no inline source map (e.g. production
|
|
5
|
+
* builds, where maps are off by default): the original stack is returned
|
|
6
|
+
* unchanged. A cheap `filename` presence check skips all work when no frame
|
|
7
|
+
* references the workflow file, and parsed source maps are memoized per bundle.
|
|
8
|
+
*
|
|
4
9
|
* @param stack - The error stack trace to remap
|
|
5
10
|
* @param filename - The workflow filename to match in stack frames
|
|
6
11
|
* @param workflowCode - The workflow bundle code containing inline source maps
|
|
@@ -21,6 +21,33 @@ export type StepContext = {
|
|
|
21
21
|
/** Deployment that owns the current workflow run, used for forwarded streams. */
|
|
22
22
|
workflowDeploymentId?: string;
|
|
23
23
|
ops: Promise<void>[];
|
|
24
|
+
/**
|
|
25
|
+
* Operations that MUST be durably committed before the step's
|
|
26
|
+
* `step_completed`/`step_failed` event is written, because the workflow
|
|
27
|
+
* continuation triggered by that event depends on them.
|
|
28
|
+
*
|
|
29
|
+
* The canonical case is a step-initiated `AbortController.abort()`: the
|
|
30
|
+
* durable `hook_received` event records the cancellation in the workflow's
|
|
31
|
+
* event log. If it is flushed in the background (like `ops`), the workflow
|
|
32
|
+
* continuation enqueued by `step_completed` can run — and advance past the
|
|
33
|
+
* abort, dispatching a later step with a stale, non-aborted `signal` — before
|
|
34
|
+
* the `hook_received` event exists. Awaiting these inline before completion
|
|
35
|
+
* guarantees the abort is ordered ahead of any continuation that observes the
|
|
36
|
+
* step's result. Unlike these, `ops` holds best-effort real-time stream
|
|
37
|
+
* writes that should fire ASAP and are intentionally left in the background.
|
|
38
|
+
*
|
|
39
|
+
* Contract: producers MUST NOT push a promise that can reject — these are
|
|
40
|
+
* awaited only to enforce ordering, never to surface an outcome. A rejection
|
|
41
|
+
* here would propagate as an infra error (queue re-delivery), not the
|
|
42
|
+
* user-code failure path, so each producer swallows its own errors (see
|
|
43
|
+
* `reviveAbortController` in serialization.ts). The await sites also
|
|
44
|
+
* defensively `.catch()` so ordering is all this bucket can ever enforce.
|
|
45
|
+
*
|
|
46
|
+
* Required (not optional) so a new step-context construction site that
|
|
47
|
+
* forgets to wire it fails at compile time, rather than silently regressing
|
|
48
|
+
* the ordering guarantee back to background-flush behavior.
|
|
49
|
+
*/
|
|
50
|
+
preCompletionOps: Promise<void>[];
|
|
24
51
|
closureVars?: Record<string, any>;
|
|
25
52
|
encryptionKey?: CryptoKey;
|
|
26
53
|
writables?: Map<string, CachedWritable>;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-run memoization cache for hydrated step return values.
|
|
3
|
+
*
|
|
4
|
+
* ## Why
|
|
5
|
+
*
|
|
6
|
+
* The inline replay loop (`runtime.ts`) re-runs the workflow body from the top
|
|
7
|
+
* on every iteration, re-consuming the full event log each time. For every
|
|
8
|
+
* already-completed step, the step consumer (`step.ts`) re-runs
|
|
9
|
+
* `hydrateStepReturnValue` — which AES-GCM-decrypts and devalue-parses the
|
|
10
|
+
* serialized result — even though that exact result was already hydrated on
|
|
11
|
+
* every prior replay. For a sequential workflow of N steps, replay K hydrates
|
|
12
|
+
* K results, so the total work across a single invocation is O(N²)
|
|
13
|
+
* decrypt+parse operations.
|
|
14
|
+
*
|
|
15
|
+
* This cache makes a completed step's hydrated result available in O(1) on
|
|
16
|
+
* subsequent replays within the SAME invocation, turning the aggregate cost
|
|
17
|
+
* into O(N).
|
|
18
|
+
*
|
|
19
|
+
* ## Scope / lifetime
|
|
20
|
+
*
|
|
21
|
+
* The cache is owned by the inline loop in `runtime.ts` (one per workflow run
|
|
22
|
+
* invocation) and passed into `runWorkflow` so it survives across the loop's
|
|
23
|
+
* iterations but never leaks across unrelated runs or process-level
|
|
24
|
+
* invocations. A fresh `runWorkflow` / `WorkflowOrchestratorContext` is created
|
|
25
|
+
* each iteration, so the cache must live OUTSIDE the per-iteration context.
|
|
26
|
+
*
|
|
27
|
+
* ## Keying
|
|
28
|
+
*
|
|
29
|
+
* Entries are keyed by the persisted event's `eventId` — a stable,
|
|
30
|
+
* world-assigned identifier for the `step_completed` event whose serialized
|
|
31
|
+
* `result` is being hydrated. The same event (same `eventId`) carries the same
|
|
32
|
+
* immutable serialized bytes across every replay, so a hit is guaranteed to
|
|
33
|
+
* correspond to the identical input.
|
|
34
|
+
*
|
|
35
|
+
* ## Identity safety (why primitives only)
|
|
36
|
+
*
|
|
37
|
+
* `hydrateStepReturnValue` (devalue.parse) produces a FRESH object graph on
|
|
38
|
+
* every call, and each replay iteration runs in a FRESH workflow VM. The
|
|
39
|
+
* current (uncached) behavior therefore hands the workflow a brand-new value
|
|
40
|
+
* on every replay. If we cached and returned the SAME object reference across
|
|
41
|
+
* replays, workflow code that mutates a step result (`const r = await step();
|
|
42
|
+
* r.count++`) would observe the mutation from a previous replay on the next
|
|
43
|
+
* replay — a non-deterministic divergence. Structured-cloning on each hit is
|
|
44
|
+
* both lossy (revivers reconstruct stream handles, step-function proxies,
|
|
45
|
+
* Request/Response, and AbortController/AbortSignal class instances that don't
|
|
46
|
+
* survive a structured clone) and still O(size).
|
|
47
|
+
*
|
|
48
|
+
* So we only cache values for which returning the same reference on every
|
|
49
|
+
* replay is provably indistinguishable from re-hydrating: JavaScript
|
|
50
|
+
* primitives (string, number, boolean, bigint, symbol, null, undefined).
|
|
51
|
+
* Primitives are immutable and compared by value, so sharing the reference is
|
|
52
|
+
* byte-for-byte equivalent to re-parsing. Any non-primitive result falls
|
|
53
|
+
* through to a full re-hydrate every replay, preserving current behavior
|
|
54
|
+
* exactly. This trades some of the optimization away in the object-returning
|
|
55
|
+
* case in exchange for keeping deterministic replay airtight.
|
|
56
|
+
*
|
|
57
|
+
* ## Memory characteristic
|
|
58
|
+
*
|
|
59
|
+
* Cached entries hold the decrypted/devalue-parsed *plaintext* of a step
|
|
60
|
+
* result, which is retained for the rest of the invocation on top of the
|
|
61
|
+
* serialized bytes already held in `cachedEvents`. So the residual cost is:
|
|
62
|
+
*
|
|
63
|
+
* - **Scoped to one workflow-run invocation.** A fresh `Map` is created per
|
|
64
|
+
* invocation (in `runtime.ts`) and is unreachable / GC'd when the invocation
|
|
65
|
+
* returns. Nothing accumulates across runs or across process-level
|
|
66
|
+
* invocations.
|
|
67
|
+
* - **Bounded by the number of primitive-returning completed steps in that
|
|
68
|
+
* run** — at most one small entry per such step.
|
|
69
|
+
* - **Primitives only, and additionally byte-bounded.** Most primitives
|
|
70
|
+
* (numbers, booleans, null/undefined, symbols, short ids/strings) are tiny
|
|
71
|
+
* and fixed-size. The only primitive that can be large is a string (or a
|
|
72
|
+
* pathologically long bigint), so to keep the doubled-residency worst case
|
|
73
|
+
* bounded we *do not* memoize string/bigint results whose character length
|
|
74
|
+
* exceeds {@link MAX_MEMOIZED_PRIMITIVE_LENGTH}. A large string is cheap to
|
|
75
|
+
* re-hydrate relative to its footprint, so letting it fall through to the
|
|
76
|
+
* existing per-replay re-hydrate path costs little and caps peak retained
|
|
77
|
+
* memory.
|
|
78
|
+
*
|
|
79
|
+
* (This is a much weaker concern than a *process-wide* cache: the dominant
|
|
80
|
+
* residency — the full event log in `cachedEvents` — already exists for the
|
|
81
|
+
* same lifetime, and everything here is freed together with it when the
|
|
82
|
+
* invocation ends.)
|
|
83
|
+
*/
|
|
84
|
+
/**
|
|
85
|
+
* Upper bound, in characters, on a string/bigint primitive that may be
|
|
86
|
+
* memoized. Beyond this, the value falls through to a fresh re-hydrate on every
|
|
87
|
+
* replay so the cache never holds a large plaintext payload for the lifetime of
|
|
88
|
+
* the invocation. 4 KiB comfortably covers ids, counts, flags, and typical
|
|
89
|
+
* short string results while excluding the large-payload case the bound exists
|
|
90
|
+
* to guard. Other primitive types (number, boolean, symbol, null, undefined)
|
|
91
|
+
* are inherently small and are never length-checked.
|
|
92
|
+
*/
|
|
93
|
+
export declare const MAX_MEMOIZED_PRIMITIVE_LENGTH = 4096;
|
|
94
|
+
/**
|
|
95
|
+
* Returns true for values that are safe to memoize and return by reference
|
|
96
|
+
* across replays: JS primitives. Objects and functions are excluded because
|
|
97
|
+
* sharing a mutable reference across replays could change observable behavior.
|
|
98
|
+
*
|
|
99
|
+
* Strings and bigints are additionally bounded by length: a value longer than
|
|
100
|
+
* {@link MAX_MEMOIZED_PRIMITIVE_LENGTH} characters is treated as non-memoizable
|
|
101
|
+
* so the cache never retains a large plaintext payload for the whole invocation
|
|
102
|
+
* (see the module-level "Memory characteristic" docs). It re-hydrates fresh on
|
|
103
|
+
* every replay instead — cheap relative to its footprint.
|
|
104
|
+
*
|
|
105
|
+
* Note: `typeof null === 'object'`, so it is handled explicitly. `undefined`,
|
|
106
|
+
* `string`, `number`, `boolean`, `bigint`, and `symbol` are all primitives.
|
|
107
|
+
*/
|
|
108
|
+
export declare function isMemoizablePrimitive(value: unknown): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Cache of hydrated step return values for a single workflow run invocation.
|
|
111
|
+
*
|
|
112
|
+
* Keyed by `step_completed` event id; the value is the already-hydrated
|
|
113
|
+
* primitive result. Only successful, primitive hydrations are stored (see
|
|
114
|
+
* {@link getOrHydrateStepReturnValue}), so a non-`undefined` `has(eventId)`
|
|
115
|
+
* always means "this step completed with a memoizable primitive value".
|
|
116
|
+
*/
|
|
117
|
+
export type StepHydrationCache = Map<string, unknown>;
|
|
118
|
+
/**
|
|
119
|
+
* Create an empty per-invocation step hydration cache.
|
|
120
|
+
*/
|
|
121
|
+
export declare function createStepHydrationCache(): StepHydrationCache;
|
|
122
|
+
/**
|
|
123
|
+
* Return the hydrated step result for `eventId`, using `cache` as a per-run
|
|
124
|
+
* memo. On a hit, the cached primitive is returned without re-running the
|
|
125
|
+
* expensive decrypt + devalue-parse. On a miss, `hydrate()` runs and its
|
|
126
|
+
* result is memoized only when it is a small primitive (see the module docs for
|
|
127
|
+
* the identity-safety rationale and the length bound on string/bigint results).
|
|
128
|
+
*
|
|
129
|
+
* This always returns a `Promise` and `await`s `hydrate()` even on the miss
|
|
130
|
+
* path, so the caller's `await` inside its serial `promiseQueue` slot keeps the
|
|
131
|
+
* same scheduling on both hit and miss — a cache hit resolves through the exact
|
|
132
|
+
* same promise-chain position a re-hydrate would have, preserving the
|
|
133
|
+
* deterministic delivery order that `pendingDeliveries`, the delivery barriers,
|
|
134
|
+
* and `Promise.race`/`Promise.all` replay all depend on.
|
|
135
|
+
*
|
|
136
|
+
* `has(eventId)` is used rather than `get(eventId) !== undefined` so that a
|
|
137
|
+
* legitimately memoized `undefined` step result still registers as a hit.
|
|
138
|
+
*
|
|
139
|
+
* When `cache` or `eventId` is absent (lightweight test harnesses, or a context
|
|
140
|
+
* that predates this plumbing), this degrades to calling `hydrate()` directly
|
|
141
|
+
* with no memoization — identical to the previous behavior.
|
|
142
|
+
*
|
|
143
|
+
* Errors are intentionally never cached: a rejected hydrate propagates to the
|
|
144
|
+
* caller (which rejects the step promise) and the next replay re-attempts it,
|
|
145
|
+
* matching the uncached behavior and avoiding a parked rejected promise.
|
|
146
|
+
*/
|
|
147
|
+
export declare function getOrHydrateStepReturnValue(cache: StepHydrationCache | undefined, eventId: string | undefined, hydrate: () => Promise<unknown>): Promise<unknown>;
|
|
148
|
+
//# sourceMappingURL=step-hydration-cache.d.ts.map
|
|
@@ -76,6 +76,10 @@ export declare const WorkflowTracePropagated: (value: boolean) => {
|
|
|
76
76
|
export declare const WorkflowTraceMode: (value: "linked" | "continuous") => {
|
|
77
77
|
[k: string]: "linked" | "continuous";
|
|
78
78
|
};
|
|
79
|
+
/** Whether this workflow invocation is using the turbo first-delivery path */
|
|
80
|
+
export declare const WorkflowTurbo: (value: boolean) => {
|
|
81
|
+
[k: string]: boolean;
|
|
82
|
+
};
|
|
79
83
|
/** Name of the error that caused workflow failure */
|
|
80
84
|
export declare const WorkflowErrorName: (value: string) => {
|
|
81
85
|
[k: string]: string;
|
|
@@ -100,6 +104,26 @@ export declare const WorkflowHooksCreated: (value: number) => {
|
|
|
100
104
|
export declare const WorkflowWaitsCreated: (value: number) => {
|
|
101
105
|
[k: string]: number;
|
|
102
106
|
};
|
|
107
|
+
/** The workflow runtime route being handled */
|
|
108
|
+
export declare const WorkflowRouteType: (value: "step" | "flow") => {
|
|
109
|
+
[k: string]: "step" | "flow";
|
|
110
|
+
};
|
|
111
|
+
/** Whether this route invocation reused an already-created request handler */
|
|
112
|
+
export declare const WorkflowRouteHandlerCached: (value: boolean) => {
|
|
113
|
+
[k: string]: boolean;
|
|
114
|
+
};
|
|
115
|
+
/** Number of times this in-memory route handler has been invoked */
|
|
116
|
+
export declare const WorkflowRouteInvocationCount: (value: number) => {
|
|
117
|
+
[k: string]: number;
|
|
118
|
+
};
|
|
119
|
+
/** Time since this route entrypoint was constructed, in milliseconds */
|
|
120
|
+
export declare const WorkflowRouteEntrypointAgeMs: (value: number) => {
|
|
121
|
+
[k: string]: number;
|
|
122
|
+
};
|
|
123
|
+
/** Time spent evaluating the generated route module body before creating the entrypoint */
|
|
124
|
+
export declare const WorkflowRouteModuleBodyInitMs: (value: number) => {
|
|
125
|
+
[k: string]: number;
|
|
126
|
+
};
|
|
103
127
|
/** Name of the step function being executed */
|
|
104
128
|
export declare const StepName: (value: string) => {
|
|
105
129
|
[k: string]: string;
|
|
@@ -220,6 +244,10 @@ export declare const WorkflowSuspensionWaitCount: (value: number) => {
|
|
|
220
244
|
export declare const HttpRequestMethod: (value: string) => {
|
|
221
245
|
[k: string]: string;
|
|
222
246
|
};
|
|
247
|
+
/** Route pattern for the request (standard OTEL: http.route) */
|
|
248
|
+
export declare const HttpRoute: (value: string) => {
|
|
249
|
+
[k: string]: string;
|
|
250
|
+
};
|
|
223
251
|
/** Full URL of the request (standard OTEL: url.full) */
|
|
224
252
|
export declare const UrlFull: (value: string) => {
|
|
225
253
|
[k: string]: string;
|
|
@@ -42,12 +42,15 @@ export declare function getNextTraceCarrier(traceMode: WorkflowTraceMode, incomi
|
|
|
42
42
|
* Builds the span links for a queue-delivered invocation span
|
|
43
43
|
* (`workflow.execute` / `step.execute`):
|
|
44
44
|
*
|
|
45
|
-
* -
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
45
|
+
* - In `linked` mode the invocation span is a CHILD of the local delivery
|
|
46
|
+
* (flow-route) context, so the only link is to the run-origin context
|
|
47
|
+
* from the message's trace carrier — connecting this bounded per-invocation
|
|
48
|
+
* trace back to where the run was started. The run-origin context is a
|
|
49
|
+
* link, never a parent, and re-enqueues forward the original carrier
|
|
50
|
+
* unchanged, so the whole run is never stitched into one giant trace.
|
|
51
|
+
* The link is skipped when the carrier is absent, empty, or invalid.
|
|
52
|
+
* - In `continuous` mode the run-origin context is restored as the parent
|
|
53
|
+
* instead, and the link points at the incoming delivery context.
|
|
51
54
|
*/
|
|
52
55
|
export declare function buildInvocationSpanLinks(traceMode: WorkflowTraceMode, incomingCarrier: Record<string, string> | undefined): Promise<api.Link[] | undefined>;
|
|
53
56
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "5.0.0-beta.
|
|
1
|
+
export declare const version = "5.0.0-beta.24";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Context, Script } from 'node:vm';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a compiled `vm.Script` for the given workflow bundle code and
|
|
4
|
+
* filename, compiling and caching it on first use. Subsequent calls with the
|
|
5
|
+
* same `(code, filename)` return the cached `Script`.
|
|
6
|
+
*
|
|
7
|
+
* The returned `Script` is not yet bound to any context; the caller runs it
|
|
8
|
+
* against a specific VM context via `script.runInContext(context)`. This is
|
|
9
|
+
* equivalent to `vm.runInContext(code, context, { filename })` but skips the
|
|
10
|
+
* recompile.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getCachedWorkflowScript(code: string, filename: string): Script;
|
|
13
|
+
/**
|
|
14
|
+
* Runs the cached workflow-bundle `Script` against `context`. Compiles and
|
|
15
|
+
* caches the `Script` on first use for the given `(code, filename)`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function runCachedWorkflowScript(code: string, filename: string, context: Context): unknown;
|
|
18
|
+
/**
|
|
19
|
+
* Clears the compiled-script cache. Intended for tests that want to assert
|
|
20
|
+
* compile-vs-cache behaviour in isolation; not used on the hot path.
|
|
21
|
+
*/
|
|
22
|
+
export declare function clearWorkflowScriptCache(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Number of distinct bundle (`code`) versions currently retained. Exposed for
|
|
25
|
+
* tests asserting the LRU bound; not used on the hot path.
|
|
26
|
+
*/
|
|
27
|
+
export declare function workflowScriptCacheSize(): number;
|
|
28
|
+
//# sourceMappingURL=script-cache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,i as t}from"../../_chunks/workflow/dist-Dxrjttr2.js";import{
|
|
1
|
+
import{c as e,i as t}from"../../_chunks/workflow/dist-Dxrjttr2.js";import{dn as n,fn as r,fr as i,lr as a,mr as o,nn as s,on as c,t as l,tn as u,un as d,ur as f}from"../../_chunks/workflow/attribute-changes-DUxG-Gic.js";import{t as p}from"../../_chunks/workflow/sleep-Dxuzj5to.js";import{t as m}from"../../_chunks/workflow/run-CVlF84yI.js";async function h(e,n={}){let i=l(e,n);if(i.length===0)return;let a=n.allowReservedAttributes===!0,o=globalThis[r];if(!o)throw new t("experimental_setAttributes() called outside a workflow runtime context. It must be called from within a workflow body (`use workflow`).");await o(i,a?{allowReservedAttributes:!0}:{})}s(u,m);function g(e){let t=globalThis[d];return t||f(`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}=o();return a.url=`${s}/.well-known/workflow/v1/webhook/${encodeURIComponent(a.token)}`,a}function v(){function e(t,n){i(`defineHook().resume()`,`https://workflow-sdk.dev/docs/api-reference/workflow-api/resume-hook`,e)}return{create(e){return g(e)},resume:e}}function y(e={}){let{namespace:t}=e,r=globalThis[n](t);return Object.create(globalThis.WritableStream.prototype,{[c]:{value:r,writable:!1}})}function b(){a(`getStepMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-step-metadata`,b)}function x(){i(`resumeHook()`,`https://workflow-sdk.dev/docs/api-reference/workflow-api/resume-hook`,x)}export{t as FatalError,e as RetryableError,g as createHook,_ as createWebhook,v as defineHook,h as experimental_setAttributes,b as getStepMetadata,o as getWorkflowMetadata,y as getWritable,x as resumeHook,p as sleep};
|
|
@@ -164,6 +164,7 @@ export declare const CreateEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
164
164
|
correlationId: z.ZodString;
|
|
165
165
|
eventData: z.ZodObject<{
|
|
166
166
|
stepName: z.ZodString;
|
|
167
|
+
workflowName: z.ZodOptional<z.ZodString>;
|
|
167
168
|
input: z.ZodUnion<readonly [z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>]>;
|
|
168
169
|
}, z.core.$strip>;
|
|
169
170
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -172,6 +173,7 @@ export declare const CreateEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
172
173
|
correlationId: z.ZodString;
|
|
173
174
|
eventData: z.ZodObject<{
|
|
174
175
|
stepName: z.ZodOptional<z.ZodString>;
|
|
176
|
+
workflowName: z.ZodOptional<z.ZodString>;
|
|
175
177
|
result: z.ZodUnion<readonly [z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>]>;
|
|
176
178
|
}, z.core.$strip>;
|
|
177
179
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -198,6 +200,8 @@ export declare const CreateEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
198
200
|
eventData: z.ZodOptional<z.ZodObject<{
|
|
199
201
|
stepName: z.ZodOptional<z.ZodString>;
|
|
200
202
|
attempt: z.ZodOptional<z.ZodNumber>;
|
|
203
|
+
workflowName: z.ZodOptional<z.ZodString>;
|
|
204
|
+
input: z.ZodOptional<z.ZodUnion<readonly [z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>]>>;
|
|
201
205
|
}, z.core.$strip>>;
|
|
202
206
|
}, z.core.$strip>, z.ZodObject<{
|
|
203
207
|
specVersion: z.ZodOptional<z.ZodNumber>;
|
|
@@ -306,6 +310,7 @@ export declare const EventSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<[z.Z
|
|
|
306
310
|
correlationId: z.ZodString;
|
|
307
311
|
eventData: z.ZodObject<{
|
|
308
312
|
stepName: z.ZodString;
|
|
313
|
+
workflowName: z.ZodOptional<z.ZodString>;
|
|
309
314
|
input: z.ZodUnion<readonly [z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>]>;
|
|
310
315
|
}, z.core.$strip>;
|
|
311
316
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -314,6 +319,7 @@ export declare const EventSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<[z.Z
|
|
|
314
319
|
correlationId: z.ZodString;
|
|
315
320
|
eventData: z.ZodObject<{
|
|
316
321
|
stepName: z.ZodOptional<z.ZodString>;
|
|
322
|
+
workflowName: z.ZodOptional<z.ZodString>;
|
|
317
323
|
result: z.ZodUnion<readonly [z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>]>;
|
|
318
324
|
}, z.core.$strip>;
|
|
319
325
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -340,6 +346,8 @@ export declare const EventSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<[z.Z
|
|
|
340
346
|
eventData: z.ZodOptional<z.ZodObject<{
|
|
341
347
|
stepName: z.ZodOptional<z.ZodString>;
|
|
342
348
|
attempt: z.ZodOptional<z.ZodNumber>;
|
|
349
|
+
workflowName: z.ZodOptional<z.ZodString>;
|
|
350
|
+
input: z.ZodOptional<z.ZodUnion<readonly [z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>]>>;
|
|
343
351
|
}, z.core.$strip>>;
|
|
344
352
|
}, z.core.$strip>, z.ZodObject<{
|
|
345
353
|
specVersion: z.ZodOptional<z.ZodNumber>;
|
|
@@ -392,6 +400,7 @@ export declare const EventSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<[z.Z
|
|
|
392
400
|
runId: z.ZodString;
|
|
393
401
|
eventId: z.ZodString;
|
|
394
402
|
createdAt: z.ZodCoercedDate<unknown>;
|
|
403
|
+
occurredAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
395
404
|
specVersion: z.ZodOptional<z.ZodNumber>;
|
|
396
405
|
}, z.core.$strip>>;
|
|
397
406
|
export type Event = z.infer<typeof EventSchema>;
|
|
@@ -417,6 +426,55 @@ export interface CreateEventParams {
|
|
|
417
426
|
resolveData?: ResolveData;
|
|
418
427
|
/** Request ID (x-vercel-id when on Vercel) for correlating request logs with workflow events. */
|
|
419
428
|
requestId?: string;
|
|
429
|
+
/**
|
|
430
|
+
* Timestamp for when the event occurred on the client side. Worlds that
|
|
431
|
+
* support this can persist it separately from `createdAt`, which represents
|
|
432
|
+
* when the backing service accepted or stored the event.
|
|
433
|
+
*/
|
|
434
|
+
occurredAt?: Date;
|
|
435
|
+
/**
|
|
436
|
+
* Inline-delta optimization (opt-in). When set, the World MAY return,
|
|
437
|
+
* on the resulting {@link EventResult}, the first page of events written
|
|
438
|
+
* strictly after this cursor (via `events`/`cursor`/`hasMore`) — the
|
|
439
|
+
* same page an `events.list({ cursor: sinceCursor, sortOrder: 'asc' })`
|
|
440
|
+
* call would return immediately after this write. The inline runtime
|
|
441
|
+
* loop uses this to skip a redundant `events.list` round-trip between
|
|
442
|
+
* sequential steps: instead of re-reading its own just-written events
|
|
443
|
+
* (and any events interleaved in-band, such as `hook_received`), it
|
|
444
|
+
* consumes the authoritative delta the write already had to compute.
|
|
445
|
+
*
|
|
446
|
+
* The cursor MUST share `events.list` semantics: the returned `events`
|
|
447
|
+
* are everything sorted strictly after `sinceCursor`, `cursor` is the
|
|
448
|
+
* position past the last returned event, and `hasMore` indicates a
|
|
449
|
+
* further page exists. A World MAY return a single page and set
|
|
450
|
+
* `hasMore: true` rather than paginating to exhaustion — the runtime
|
|
451
|
+
* does not consume a truncated delta, it falls back to a full
|
|
452
|
+
* incremental fetch whenever `hasMore` is true. (For that reason a step
|
|
453
|
+
* body emitting more in-band events than one page silently bypasses this
|
|
454
|
+
* fast path, which is correct but forgoes the saved round-trip.)
|
|
455
|
+
* Returning these fields at all is OPTIONAL — a World that omits them is
|
|
456
|
+
* fully supported; the runtime falls back to `events.list`. This
|
|
457
|
+
* preserves the same divergence guarantees as the fetch path because the
|
|
458
|
+
* delta is computed atomically against the same log the fetch would read.
|
|
459
|
+
*/
|
|
460
|
+
sinceCursor?: string;
|
|
461
|
+
/**
|
|
462
|
+
* Run-started preload opt-out (advisory). On a `run_started` write a World
|
|
463
|
+
* MAY preload the run's event log onto the {@link EventResult}
|
|
464
|
+
* (`events`/`cursor`/`hasMore`) so the runtime can skip its initial
|
|
465
|
+
* `events.list`. The turbo first invocation backgrounds `run_started`
|
|
466
|
+
* purely as a write barrier and never reads that preload, so it sets this
|
|
467
|
+
* to tell the World to skip the wasted list+resolve — trimming the
|
|
468
|
+
* `run_started` round-trip that the chained first `step_started` waits on.
|
|
469
|
+
* A World that ignores it (or doesn't preload) remains fully correct: the
|
|
470
|
+
* runtime falls back to `events.list` whenever it actually needs the log.
|
|
471
|
+
* Only honored for `run_started`; ignored for other event types.
|
|
472
|
+
*
|
|
473
|
+
* Named to match the World boundary, the wire frame meta, and the backend
|
|
474
|
+
* option end-to-end (cf. {@link sinceCursor}) so the single name greps
|
|
475
|
+
* across the SDK and the backend.
|
|
476
|
+
*/
|
|
477
|
+
skipPreload?: boolean;
|
|
420
478
|
}
|
|
421
479
|
/**
|
|
422
480
|
* Result of creating an event. Includes the created event and optionally
|
|
@@ -436,15 +494,32 @@ export interface EventResult {
|
|
|
436
494
|
/** The wait entity (for wait_created/wait_completed events) */
|
|
437
495
|
wait?: import('./waits.js').Wait;
|
|
438
496
|
/**
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
-
*
|
|
497
|
+
* Events with data resolved. Two producers populate this:
|
|
498
|
+
*
|
|
499
|
+
* - On a `run_started` response: all events up to this point, so the
|
|
500
|
+
* runtime can skip the initial `events.list` call and reduce TTFB.
|
|
501
|
+
* - On a step-terminal write (`step_completed` / `step_failed`) when
|
|
502
|
+
* the caller passed {@link CreateEventParams.sinceCursor}: the delta
|
|
503
|
+
* of events written strictly after that cursor, so the inline loop
|
|
504
|
+
* can skip the per-step incremental `events.list` round-trip.
|
|
442
505
|
*/
|
|
443
506
|
events?: Event[];
|
|
444
507
|
/** Pagination cursor for `events`, matching events.list semantics. */
|
|
445
508
|
cursor?: string | null;
|
|
446
509
|
/** Whether additional event pages are available for `events`. */
|
|
447
510
|
hasMore?: boolean;
|
|
511
|
+
/**
|
|
512
|
+
* Lazy step start: set to `true` only when a `step_started` event with
|
|
513
|
+
* step-creation data atomically *created* the step on this call (the
|
|
514
|
+
* caller won the create-claim), as opposed to transitioning a step that
|
|
515
|
+
* already existed. The owned-inline runtime path uses this as the
|
|
516
|
+
* exactly-once ownership signal — it runs the step body inline only when
|
|
517
|
+
* it created the step, so a concurrent handler that lost the create race
|
|
518
|
+
* (and gets `EntityConflictError`/skipped) never double-executes. Absent
|
|
519
|
+
* (undefined) on the legacy path and from older servers/worlds, which is
|
|
520
|
+
* the safe default (treated as "not the lazy creator").
|
|
521
|
+
*/
|
|
522
|
+
stepCreated?: boolean;
|
|
448
523
|
}
|
|
449
524
|
export interface GetEventParams {
|
|
450
525
|
resolveData?: ResolveData;
|
|
@@ -16,7 +16,7 @@ export type * from './shared.js';
|
|
|
16
16
|
export type { GetChunksOptions, StreamChunk, StreamChunksResponse, StreamInfoResponse, } from './shared.js';
|
|
17
17
|
export { PaginatedResponseSchema, StructuredErrorSchema, } from './shared.js';
|
|
18
18
|
export type { SpecVersion } from './spec-version.js';
|
|
19
|
-
export { isLegacySpecVersion, requiresNewerWorld, SPEC_VERSION_CURRENT, SPEC_VERSION_LEGACY, SPEC_VERSION_SUPPORTS_ATTRIBUTES, SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT, SPEC_VERSION_SUPPORTS_EVENT_SOURCING, } from './spec-version.js';
|
|
19
|
+
export { isLegacySpecVersion, requiresNewerWorld, SPEC_VERSION_CURRENT, SPEC_VERSION_LEGACY, SPEC_VERSION_SUPPORTS_ATTRIBUTES, SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT, SPEC_VERSION_SUPPORTS_COMPRESSION, SPEC_VERSION_SUPPORTS_EVENT_SOURCING, } from './spec-version.js';
|
|
20
20
|
export type * from './steps.js';
|
|
21
21
|
export { StepSchema, StepStatusSchema } from './steps.js';
|
|
22
22
|
export { DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS, DEFAULT_TIMESTAMP_THRESHOLD_MS, DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS, ulidToDate, validateUlidTimestamp, } from './ulid.js';
|
|
@@ -20,7 +20,17 @@ export declare const SPEC_VERSION_LEGACY: SpecVersion;
|
|
|
20
20
|
export declare const SPEC_VERSION_SUPPORTS_EVENT_SOURCING: SpecVersion;
|
|
21
21
|
export declare const SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT: SpecVersion;
|
|
22
22
|
export declare const SPEC_VERSION_SUPPORTS_ATTRIBUTES: SpecVersion;
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Runs at this spec version or later may contain gzip-compressed payloads
|
|
25
|
+
* ('gzip' format prefix). Readers older than this version cannot decode
|
|
26
|
+
* such payloads and reject the run via `requiresNewerWorld()` instead of
|
|
27
|
+
* failing on individual payloads.
|
|
28
|
+
*/
|
|
29
|
+
export declare const SPEC_VERSION_SUPPORTS_COMPRESSION: SpecVersion;
|
|
30
|
+
/**
|
|
31
|
+
* Current spec version (event-sourced architecture with native attributes
|
|
32
|
+
* and compressed payloads).
|
|
33
|
+
*/
|
|
24
34
|
export declare const SPEC_VERSION_CURRENT: SpecVersion;
|
|
25
35
|
/**
|
|
26
36
|
* Check if a spec version is legacy (<= SPEC_VERSION_LEGACY or undefined).
|