experimental-ash 0.22.2 → 0.24.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 +36 -0
- package/dist/docs/internals/hooks.md +13 -16
- package/dist/docs/internals/message-runtime.md +1 -1
- package/dist/docs/public/auth-and-route-protection.md +3 -3
- package/dist/docs/public/faqs.md +67 -0
- package/dist/docs/public/meta.json +1 -0
- package/dist/docs/public/schedules.md +11 -0
- package/dist/docs/public/session-context.md +46 -89
- package/dist/docs/public/skills.md +13 -0
- package/dist/docs/public/subagents.md +12 -6
- package/dist/docs/public/tools.md +9 -13
- package/dist/docs/public/typescript-api.md +4 -4
- package/dist/src/channel/types.d.ts +10 -12
- package/dist/src/chunks/{client-CKsU8Li3.js → client-nshDsWNF.js} +1 -1
- package/dist/src/chunks/{dev-authored-source-watcher-BLzYWh05.js → dev-authored-source-watcher-B4PaZGUr.js} +1 -1
- package/dist/src/chunks/host-DsW72Q-w.js +65 -0
- package/dist/src/chunks/paths-OknjaYR8.js +89 -0
- package/dist/src/chunks/prewarm-B4YblQ5m.js +6 -0
- package/dist/src/cli/commands/info.js +1 -1
- package/dist/src/cli/dev/repl.js +2 -2
- package/dist/src/cli/run.js +1 -1
- package/dist/src/client/session.js +8 -0
- package/dist/src/client/types.d.ts +12 -1
- package/dist/src/compiled/.vendor-stamp.json +3 -3
- package/dist/src/compiled/@workflow/core/_ms.d.ts +4 -0
- package/dist/src/compiled/@workflow/core/_workflow-serde.d.ts +5 -0
- package/dist/src/compiled/@workflow/core/_workflow-utils.d.ts +8 -0
- package/dist/src/compiled/@workflow/core/_workflow-world.d.ts +59 -0
- package/dist/src/compiled/@workflow/core/capabilities.d.ts +45 -0
- package/dist/src/compiled/@workflow/core/capture-stack.d.ts +16 -0
- package/dist/src/compiled/@workflow/core/class-serialization.d.ts +31 -0
- package/dist/src/compiled/@workflow/core/classify-error.d.ts +20 -0
- package/dist/src/compiled/@workflow/core/context-errors.d.ts +27 -0
- package/dist/src/compiled/@workflow/core/context-violation-error.d.ts +97 -0
- package/dist/src/compiled/@workflow/core/create-hook.d.ts +179 -0
- package/dist/src/compiled/@workflow/core/define-hook.d.ts +68 -0
- package/dist/src/compiled/@workflow/core/describe-error.d.ts +70 -0
- package/dist/src/compiled/@workflow/core/encryption.d.ts +51 -0
- package/dist/src/compiled/@workflow/core/events-consumer.d.ts +64 -0
- package/dist/src/compiled/@workflow/core/flushable-stream.d.ts +82 -0
- package/dist/src/compiled/@workflow/core/global.d.ts +48 -0
- package/dist/src/compiled/@workflow/core/index.d.ts +19 -38
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/log-format.d.ts +25 -0
- package/dist/src/compiled/@workflow/core/logger.d.ts +29 -0
- package/dist/src/compiled/@workflow/core/package.json +1 -1
- package/dist/src/compiled/@workflow/core/private.d.ts +59 -10
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +51 -0
- package/dist/src/compiled/@workflow/core/runtime/get-port-lazy.d.ts +10 -0
- package/dist/src/compiled/@workflow/core/runtime/get-world-lazy.d.ts +32 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +97 -0
- package/dist/src/compiled/@workflow/core/runtime/replay-budget.d.ts +98 -0
- package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +77 -0
- package/dist/src/compiled/@workflow/core/runtime/run.d.ts +134 -0
- package/dist/src/compiled/@workflow/core/runtime/runs.d.ts +50 -0
- package/dist/src/compiled/@workflow/core/runtime/start.d.ts +59 -0
- package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +40 -0
- package/dist/src/compiled/@workflow/core/runtime/step-handler.d.ts +2 -0
- package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +42 -0
- package/dist/src/compiled/@workflow/core/runtime/world-init.d.ts +75 -0
- package/dist/src/compiled/@workflow/core/runtime/world.d.ts +32 -0
- package/dist/src/compiled/@workflow/core/runtime.d.ts +22 -67
- package/dist/src/compiled/@workflow/core/runtime.js +27 -27
- package/dist/src/compiled/@workflow/core/schemas.d.ts +15 -0
- package/dist/src/compiled/@workflow/core/serialization/client.d.ts +17 -0
- package/dist/src/compiled/@workflow/core/serialization/codec-devalue.d.ts +14 -0
- package/dist/src/compiled/@workflow/core/serialization/codec.d.ts +90 -0
- package/dist/src/compiled/@workflow/core/serialization/encryption.d.ts +32 -0
- package/dist/src/compiled/@workflow/core/serialization/errors.d.ts +21 -0
- package/dist/src/compiled/@workflow/core/serialization/format.d.ts +60 -0
- package/dist/src/compiled/@workflow/core/serialization/index.d.ts +18 -0
- package/dist/src/compiled/@workflow/core/serialization/reducers/class.d.ts +11 -0
- package/dist/src/compiled/@workflow/core/serialization/reducers/common.d.ts +16 -0
- package/dist/src/compiled/@workflow/core/serialization/reducers/step-function.d.ts +35 -0
- package/dist/src/compiled/@workflow/core/serialization/step.d.ts +17 -0
- package/dist/src/compiled/@workflow/core/serialization/types.d.ts +215 -0
- package/dist/src/compiled/@workflow/core/serialization/workflow.d.ts +29 -0
- package/dist/src/compiled/@workflow/core/serialization-format.d.ts +171 -0
- package/dist/src/compiled/@workflow/core/serialization.d.ts +337 -0
- package/dist/src/compiled/@workflow/core/sleep.d.ts +33 -0
- package/dist/src/compiled/@workflow/core/source-map.d.ts +10 -0
- package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +13 -0
- package/dist/src/compiled/@workflow/core/step/get-closure-vars.d.ts +9 -0
- package/dist/src/compiled/@workflow/core/step/get-step-metadata.d.ts +42 -0
- package/dist/src/compiled/@workflow/core/step/get-workflow-metadata.d.ts +7 -0
- package/dist/src/compiled/@workflow/core/step/writable-stream.d.ts +22 -0
- package/dist/src/compiled/@workflow/core/step.d.ts +4 -0
- package/dist/src/compiled/@workflow/core/symbols.d.ts +36 -0
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +283 -0
- package/dist/src/compiled/@workflow/core/telemetry.d.ts +53 -0
- package/dist/src/compiled/@workflow/core/types.d.ts +14 -0
- package/dist/src/compiled/@workflow/core/util.d.ts +40 -0
- package/dist/src/compiled/@workflow/core/version.d.ts +2 -0
- package/dist/src/compiled/@workflow/core/vm/index.d.ts +17 -0
- package/dist/src/compiled/@workflow/core/vm/uint8array-base64.d.ts +21 -0
- package/dist/src/compiled/@workflow/core/vm/uuid.d.ts +10 -0
- package/dist/src/compiled/@workflow/core/workflow/abort-controller.d.ts +65 -0
- package/dist/src/compiled/@workflow/core/workflow/create-hook.d.ts +7 -0
- package/dist/src/compiled/@workflow/core/workflow/define-hook.d.ts +10 -0
- package/dist/src/compiled/@workflow/core/workflow/get-workflow-metadata.d.ts +32 -0
- package/dist/src/compiled/@workflow/core/workflow/hook.d.ts +4 -0
- package/dist/src/compiled/@workflow/core/workflow/index.d.ts +11 -0
- package/dist/src/compiled/@workflow/core/workflow/sleep.d.ts +4 -0
- package/dist/src/compiled/@workflow/core/workflow/world-init-stub.d.ts +15 -0
- package/dist/src/compiled/@workflow/core/workflow/writable-stream.d.ts +3 -0
- package/dist/src/compiled/@workflow/core/workflow.d.ts +1 -38
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/error-codes.d.ts +5 -1
- package/dist/src/compiled/@workflow/errors/index.d.ts +15 -1
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/errors/package.json +1 -1
- package/dist/src/compiled/_chunks/workflow/{context-errors-zbKocOyk.js → context-errors-Bbvvp-li.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/{dist-0iNBqPYp.js → dist-C7wPwOI9.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/{dist-D774SUM4.js → dist-C_oiE-l7.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-C3VWUPii.js +12 -0
- package/dist/src/compiled/_chunks/workflow/sleep-QTkC1VFe.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{symbols-D-4tVV8x.js → symbols-QezhMuLg.js} +1 -1
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/execution/await-authorization-orchestrator.d.ts +2 -1
- package/dist/src/execution/await-authorization-orchestrator.js +4 -0
- package/dist/src/execution/connection-auth-steps.d.ts +4 -0
- package/dist/src/execution/connection-auth-steps.js +9 -11
- package/dist/src/execution/node-step.d.ts +4 -5
- package/dist/src/execution/subagent-adapter.d.ts +0 -27
- package/dist/src/execution/subagent-adapter.js +2 -66
- package/dist/src/execution/subagent-hitl-proxy.d.ts +2 -2
- package/dist/src/execution/subagent-hitl-proxy.js +2 -2
- package/dist/src/execution/task-mode.d.ts +3 -3
- package/dist/src/execution/task-mode.js +3 -3
- package/dist/src/execution/turn-workflow.d.ts +41 -0
- package/dist/src/execution/turn-workflow.js +96 -0
- package/dist/src/execution/workflow-entry.js +77 -87
- package/dist/src/execution/workflow-errors.d.ts +14 -0
- package/dist/src/execution/workflow-errors.js +54 -0
- package/dist/src/execution/workflow-runtime.d.ts +34 -3
- package/dist/src/execution/workflow-runtime.js +52 -10
- package/dist/src/execution/workflow-steps.d.ts +27 -2
- package/dist/src/execution/workflow-steps.js +31 -26
- package/dist/src/harness/instrumentation-config.js +14 -7
- package/dist/src/harness/messages.d.ts +7 -7
- package/dist/src/harness/messages.js +4 -4
- package/dist/src/harness/runtime-actions.d.ts +4 -4
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-builders.d.ts +1 -1
- package/dist/src/internal/workflow-bundle/workflow-builders.js +20 -8
- package/dist/src/internal/workflow-bundle/workflow-transformer.d.ts +13 -0
- package/dist/src/internal/workflow-bundle/workflow-transformer.js +10 -4
- package/dist/src/protocol/message.d.ts +6 -1
- package/dist/src/public/channels/ash.js +50 -3
- package/dist/src/public/context/index.d.ts +4 -7
- package/dist/src/public/context/index.js +4 -5
- package/dist/src/public/definitions/state.d.ts +33 -0
- package/dist/src/public/definitions/state.js +34 -0
- package/dist/src/public/next/index.d.ts +7 -0
- package/dist/src/public/next/index.js +2 -0
- package/dist/src/public/next/vercel-json.d.ts +1 -0
- package/dist/src/public/next/vercel-json.js +1 -0
- package/dist/src/react/index.d.ts +1 -1
- package/dist/src/react/use-ash-agent.d.ts +8 -0
- package/dist/src/react/use-ash-agent.js +26 -4
- package/dist/src/services/dev-client.d.ts +4 -1
- package/dist/src/services/dev-client.js +1 -0
- package/package.json +4 -4
- package/dist/src/chunks/host-DREC8e8Z.js +0 -65
- package/dist/src/chunks/paths-C6sp4T2U.js +0 -88
- package/dist/src/chunks/prewarm-hz8p2jlZ.js +0 -6
- package/dist/src/compiled/_chunks/workflow/resume-hook-CL8Ed91K.js +0 -12
- package/dist/src/compiled/_chunks/workflow/sleep-Dn3i9nxI.js +0 -1
- package/dist/src/execution/continuous-entry.d.ts +0 -59
- package/dist/src/execution/continuous-entry.js +0 -487
- package/dist/src/execution/continuous-runtime.d.ts +0 -17
- package/dist/src/execution/continuous-runtime.js +0 -123
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type RunErrorCode } from '#compiled/@workflow/errors/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Attribution of a workflow/step failure for presentation.
|
|
4
|
+
*
|
|
5
|
+
* - `user`: the error came from customer code (a step or workflow function
|
|
6
|
+
* threw, or a value they passed across a boundary wasn't serializable).
|
|
7
|
+
* - `sdk`: the SDK produced the error itself — an internal invariant broke,
|
|
8
|
+
* or a runtime guard rejected the call. These should be rare; when they
|
|
9
|
+
* happen we want to frame the terminal output as "this is us, not you."
|
|
10
|
+
*/
|
|
11
|
+
export type ErrorAttribution = 'user' | 'sdk';
|
|
12
|
+
export interface ErrorDescription {
|
|
13
|
+
attribution: ErrorAttribution;
|
|
14
|
+
errorCode: RunErrorCode;
|
|
15
|
+
/**
|
|
16
|
+
* Short, class-aware hint to help a user understand what the error means.
|
|
17
|
+
* Only set for well-known SDK error classes (SerializationError,
|
|
18
|
+
* WorkflowRuntimeError, context-violation errors); `undefined` for plain
|
|
19
|
+
* user errors, where the stack is already the most useful thing to show.
|
|
20
|
+
*/
|
|
21
|
+
hint?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Error signal fields carried on persisted failure events (e.g.
|
|
25
|
+
* `run_failed` / `step_failed`). The shape is intentionally loose:
|
|
26
|
+
*
|
|
27
|
+
* - `errorCode` is typed as `string` rather than `RunErrorCode` because
|
|
28
|
+
* the value comes from stored JSON/CBOR and may predate the current
|
|
29
|
+
* enum — callers should not narrow on it blindly. Values that don't
|
|
30
|
+
* match a known `RUN_ERROR_CODES` entry fall through to USER_ERROR.
|
|
31
|
+
* - `errorName` is the thrown `Error#name`. It is not universally
|
|
32
|
+
* persisted today; callers that have access to it (either via an
|
|
33
|
+
* in-memory throw or a richer payload) can pass it in to sharpen
|
|
34
|
+
* the attribution and hint. When absent, `describeRunError` still
|
|
35
|
+
* returns a sensible attribution from `errorCode` alone.
|
|
36
|
+
*/
|
|
37
|
+
export interface PersistedErrorSignal {
|
|
38
|
+
errorCode?: string;
|
|
39
|
+
errorName?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Data-driven variant of {@link describeError} that works from persisted
|
|
43
|
+
* event fields instead of a live `Error` instance. Intended for CLI/web
|
|
44
|
+
* renderers that read failure events and no longer have the original
|
|
45
|
+
* thrown object.
|
|
46
|
+
*/
|
|
47
|
+
export declare function describeRunError(signal: PersistedErrorSignal): ErrorDescription;
|
|
48
|
+
/**
|
|
49
|
+
* Describe an error for user-facing presentation. Purely informational —
|
|
50
|
+
* does not change any persisted event data or error classification used by
|
|
51
|
+
* the runtime.
|
|
52
|
+
*
|
|
53
|
+
* The attribution here is more nuanced than `classifyRunError`:
|
|
54
|
+
*
|
|
55
|
+
* - `SerializationError` is technically raised by the SDK, but it almost
|
|
56
|
+
* always points at something the caller did (passed a non-serializable
|
|
57
|
+
* value, didn't register a class). We attribute it to the user.
|
|
58
|
+
* - Context-violation errors (`NotInWorkflowContextError`, etc.) likewise
|
|
59
|
+
* describe a user mistake.
|
|
60
|
+
* - `WorkflowRuntimeError` (and subclasses like `StepNotRegisteredError`)
|
|
61
|
+
* indicates an internal SDK invariant broke — surface that as `sdk`.
|
|
62
|
+
*
|
|
63
|
+
* @param err The error value thrown by the workflow / step.
|
|
64
|
+
* @param errorCode Optional precomputed error code. Callers that already
|
|
65
|
+
* know the code (e.g. `REPLAY_TIMEOUT` or `MAX_DELIVERIES_EXCEEDED`, which
|
|
66
|
+
* `classifyRunError` can't derive from the error alone) should pass it so
|
|
67
|
+
* the attribution and hint reflect the actual failure category.
|
|
68
|
+
*/
|
|
69
|
+
export declare function describeError(err: unknown, errorCode?: RunErrorCode): ErrorDescription;
|
|
70
|
+
//# sourceMappingURL=describe-error.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-compatible AES-256-GCM encryption module.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Web Crypto API (`globalThis.crypto.subtle`) which works in
|
|
5
|
+
* both modern browsers and Node.js 20+. This module is intentionally
|
|
6
|
+
* free of Node.js-specific imports so it can be bundled for the browser.
|
|
7
|
+
*
|
|
8
|
+
* The World interface (`getEncryptionKeyForRun`) returns a raw 32-byte
|
|
9
|
+
* AES-256 key. Callers should use `importKey()` once to convert it to a
|
|
10
|
+
* `CryptoKey`, then pass that to `encrypt()`/`decrypt()` for all
|
|
11
|
+
* operations within the same run. This avoids repeated `importKey()`
|
|
12
|
+
* calls on every encrypt/decrypt invocation.
|
|
13
|
+
*
|
|
14
|
+
* Wire format: `[nonce (12 bytes)][ciphertext + auth tag]`
|
|
15
|
+
* The `encr` format prefix is NOT part of this module — it's added/stripped
|
|
16
|
+
* by the serialization layer in `maybeEncrypt`/`maybeDecrypt`.
|
|
17
|
+
*/
|
|
18
|
+
export type CryptoKey = import('node:crypto').webcrypto.CryptoKey;
|
|
19
|
+
/**
|
|
20
|
+
* Import a raw AES-256 key as a `CryptoKey` for use with `encrypt()`/`decrypt()`.
|
|
21
|
+
*
|
|
22
|
+
* Callers should call this once per run (after `getEncryptionKeyForRun()`)
|
|
23
|
+
* and pass the resulting `CryptoKey` to all subsequent encrypt/decrypt calls.
|
|
24
|
+
*
|
|
25
|
+
* Pass `usages: ['encrypt']` (or `['decrypt']`) for cross-run scenarios
|
|
26
|
+
* where the caller should not be able to perform the inverse operation
|
|
27
|
+
* with the key — for example a child workflow writing into a parent
|
|
28
|
+
* run's forwarded WritableStream only needs to encrypt, never decrypt.
|
|
29
|
+
*
|
|
30
|
+
* @param raw - Raw 32-byte AES-256 key (from World.getEncryptionKeyForRun)
|
|
31
|
+
* @param usages - Key usages. Defaults to `['encrypt', 'decrypt']`.
|
|
32
|
+
* @returns CryptoKey ready for AES-GCM operations
|
|
33
|
+
*/
|
|
34
|
+
export declare function importKey(raw: Uint8Array, usages?: ReadonlyArray<'encrypt' | 'decrypt'>): Promise<import("crypto").webcrypto.CryptoKey>;
|
|
35
|
+
/**
|
|
36
|
+
* Encrypt data using AES-256-GCM.
|
|
37
|
+
*
|
|
38
|
+
* @param key - CryptoKey from `importKey()`
|
|
39
|
+
* @param data - Plaintext to encrypt
|
|
40
|
+
* @returns `[nonce (12 bytes)][ciphertext + GCM auth tag]`
|
|
41
|
+
*/
|
|
42
|
+
export declare function encrypt(key: CryptoKey, data: Uint8Array): Promise<Uint8Array>;
|
|
43
|
+
/**
|
|
44
|
+
* Decrypt data using AES-256-GCM.
|
|
45
|
+
*
|
|
46
|
+
* @param key - CryptoKey from `importKey()`
|
|
47
|
+
* @param data - `[nonce (12 bytes)][ciphertext + GCM auth tag]`
|
|
48
|
+
* @returns Decrypted plaintext
|
|
49
|
+
*/
|
|
50
|
+
export declare function decrypt(key: CryptoKey, data: Uint8Array): Promise<Uint8Array>;
|
|
51
|
+
//# sourceMappingURL=encryption.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Event } from './_workflow-world.js';
|
|
2
|
+
/**
|
|
3
|
+
* Delay before firing the deferred unconsumed-event check after the promise
|
|
4
|
+
* queue has drained. Must be long enough for cross-VM microtask chains to
|
|
5
|
+
* propagate (resolve in host → workflow code in VM → subscribe call back
|
|
6
|
+
* in host). Any subscribe() arriving during this window cancels the check.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFERRED_CHECK_DELAY_MS = 100;
|
|
9
|
+
export declare enum EventConsumerResult {
|
|
10
|
+
/**
|
|
11
|
+
* Callback consumed the event, but should not be removed from the callbacks list
|
|
12
|
+
*/
|
|
13
|
+
Consumed = 0,
|
|
14
|
+
/**
|
|
15
|
+
* Callback did not consume the event, so it should be passed to the next callback
|
|
16
|
+
*/
|
|
17
|
+
NotConsumed = 1,
|
|
18
|
+
/**
|
|
19
|
+
* Callback consumed the event, and should be removed from the callbacks list
|
|
20
|
+
*/
|
|
21
|
+
Finished = 2
|
|
22
|
+
}
|
|
23
|
+
type EventConsumerCallback = (event: Event | null) => EventConsumerResult;
|
|
24
|
+
export interface EventsConsumerOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Callback invoked when a non-null event cannot be consumed by any registered
|
|
27
|
+
* callback, indicating an orphaned or invalid event in the event log. The
|
|
28
|
+
* check is deferred until after the promise queue has drained, ensuring that
|
|
29
|
+
* any pending async work (e.g., deserialization/decryption) completes and
|
|
30
|
+
* downstream subscribe() calls have a chance to cancel the check first.
|
|
31
|
+
*/
|
|
32
|
+
onUnconsumedEvent: (event: Event) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the current promise queue. The unconsumed event check is chained
|
|
35
|
+
* onto this queue so it only fires after all pending async work (e.g.,
|
|
36
|
+
* deserialization) has completed. This prevents false positives when async
|
|
37
|
+
* deserialization delays the resolve() that triggers the next subscribe().
|
|
38
|
+
*/
|
|
39
|
+
getPromiseQueue: () => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export declare class EventsConsumer {
|
|
42
|
+
eventIndex: number;
|
|
43
|
+
readonly events: Event[];
|
|
44
|
+
readonly callbacks: EventConsumerCallback[];
|
|
45
|
+
private onUnconsumedEvent;
|
|
46
|
+
private getPromiseQueue;
|
|
47
|
+
private pendingUnconsumedCheck;
|
|
48
|
+
private pendingUnconsumedTimeout;
|
|
49
|
+
private unconsumedCheckVersion;
|
|
50
|
+
constructor(events: Event[], options: EventsConsumerOptions);
|
|
51
|
+
/**
|
|
52
|
+
* Registers a callback function to be called after an event has been consumed
|
|
53
|
+
* by a different callback. The callback can return:
|
|
54
|
+
* - `EventConsumerResult.Consumed` the event is considered consumed and will not be passed to any other callback, but the callback will remain in the callbacks list
|
|
55
|
+
* - `EventConsumerResult.NotConsumed` the event is passed to the next callback
|
|
56
|
+
* - `EventConsumerResult.Finished` the event is considered consumed and the callback is removed from the callbacks list
|
|
57
|
+
*
|
|
58
|
+
* @param fn - The callback function to register.
|
|
59
|
+
*/
|
|
60
|
+
subscribe(fn: EventConsumerCallback): void;
|
|
61
|
+
private consume;
|
|
62
|
+
}
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=events-consumer.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type PromiseWithResolvers } from './_workflow-utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* Polling interval (in ms) for lock release detection.
|
|
4
|
+
*
|
|
5
|
+
* The Web Streams API does not expose an event for "lock released but stream
|
|
6
|
+
* still open"; we can only distinguish that state by periodically attempting
|
|
7
|
+
* to acquire a reader/writer. For that reason we use polling instead of a
|
|
8
|
+
* fully event-driven approach here.
|
|
9
|
+
*
|
|
10
|
+
* 10ms is chosen so the polling tick almost never sits on the critical path:
|
|
11
|
+
* the V2 step-executor's `opsSettled` race waits for this state to resolve
|
|
12
|
+
* after each step body returns, so a coarser interval (the previous 100ms)
|
|
13
|
+
* adds visible per-step latency to streaming workflows. With a uniformly
|
|
14
|
+
* distributed offset between step return and the next tick, the expected
|
|
15
|
+
* wait is half the interval — so 10ms means ~5ms average wait per step
|
|
16
|
+
* instead of ~50ms. The per-tick work is `writable.locked` plus a
|
|
17
|
+
* `getWriter()`/`releaseLock()` probe, both microsecond-scale; 10× more
|
|
18
|
+
* ticks during a stream's lifetime is not measurable in practice.
|
|
19
|
+
*/
|
|
20
|
+
export declare const LOCK_POLL_INTERVAL_MS = 10;
|
|
21
|
+
/**
|
|
22
|
+
* State tracker for flushable stream operations.
|
|
23
|
+
* Resolves when either:
|
|
24
|
+
* 1. Stream completes (close/error), OR
|
|
25
|
+
* 2. Lock is released AND all pending operations are flushed
|
|
26
|
+
*
|
|
27
|
+
* Note: `doneResolved` and `streamEnded` are separate:
|
|
28
|
+
* - `doneResolved`: The `done` promise has been resolved (step can complete)
|
|
29
|
+
* - `streamEnded`: The underlying stream has actually closed/errored
|
|
30
|
+
*
|
|
31
|
+
* Once `doneResolved` is set to true, the `done` promise will not resolve
|
|
32
|
+
* again. Re-acquiring locks after release is not supported as a way to
|
|
33
|
+
* trigger additional completion signaling.
|
|
34
|
+
*/
|
|
35
|
+
export interface FlushableStreamState extends PromiseWithResolvers<void> {
|
|
36
|
+
/** Number of write operations currently in flight to the server */
|
|
37
|
+
pendingOps: number;
|
|
38
|
+
/** Whether the `done` promise has been resolved */
|
|
39
|
+
doneResolved: boolean;
|
|
40
|
+
/** Whether the underlying stream has actually closed/errored */
|
|
41
|
+
streamEnded: boolean;
|
|
42
|
+
/** Interval ID for writable lock polling (if active) */
|
|
43
|
+
writablePollingInterval?: ReturnType<typeof setInterval>;
|
|
44
|
+
/** Interval ID for readable lock polling (if active) */
|
|
45
|
+
readablePollingInterval?: ReturnType<typeof setInterval>;
|
|
46
|
+
}
|
|
47
|
+
export declare function createFlushableState(): FlushableStreamState;
|
|
48
|
+
/**
|
|
49
|
+
* Polls a WritableStream to check if the user has released their lock.
|
|
50
|
+
* Resolves the done promise when lock is released and no pending ops remain.
|
|
51
|
+
*
|
|
52
|
+
* Note: Only resolves if stream is unlocked but NOT closed. If the user closes
|
|
53
|
+
* the stream, the pump will handle resolution via the stream ending naturally.
|
|
54
|
+
*
|
|
55
|
+
* Protection: If polling is already active on this state, the existing interval
|
|
56
|
+
* is used to avoid creating multiple simultaneous polling operations.
|
|
57
|
+
*/
|
|
58
|
+
export declare function pollWritableLock(writable: WritableStream, state: FlushableStreamState): void;
|
|
59
|
+
/**
|
|
60
|
+
* Polls a ReadableStream to check if the user has released their lock.
|
|
61
|
+
* Resolves the done promise when lock is released and no pending ops remain.
|
|
62
|
+
*
|
|
63
|
+
* Note: Only resolves if stream is unlocked but NOT closed. If the user closes
|
|
64
|
+
* the stream, the pump will handle resolution via the stream ending naturally.
|
|
65
|
+
*
|
|
66
|
+
* Protection: If polling is already active on this state, the existing interval
|
|
67
|
+
* is used to avoid creating multiple simultaneous polling operations.
|
|
68
|
+
*/
|
|
69
|
+
export declare function pollReadableLock(readable: ReadableStream, state: FlushableStreamState): void;
|
|
70
|
+
/**
|
|
71
|
+
* Creates a flushable pipe from a ReadableStream to a WritableStream.
|
|
72
|
+
* Unlike pipeTo(), this resolves when:
|
|
73
|
+
* 1. The source stream completes (close/error), OR
|
|
74
|
+
* 2. The user releases their lock on userStream AND all pending writes are flushed
|
|
75
|
+
*
|
|
76
|
+
* @param source - The readable stream to read from (e.g., transform's readable)
|
|
77
|
+
* @param sink - The writable stream to write to (e.g., server writable)
|
|
78
|
+
* @param state - The flushable state tracker
|
|
79
|
+
* @returns Promise that resolves when stream ends (not when done promise resolves)
|
|
80
|
+
*/
|
|
81
|
+
export declare function flushablePipe(source: ReadableStream, sink: WritableStream, state: FlushableStreamState): Promise<void>;
|
|
82
|
+
//# sourceMappingURL=flushable-stream.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Serializable } from './schemas.js';
|
|
2
|
+
export interface StepInvocationQueueItem {
|
|
3
|
+
type: 'step';
|
|
4
|
+
correlationId: string;
|
|
5
|
+
stepName: string;
|
|
6
|
+
args: Serializable[];
|
|
7
|
+
closureVars?: Record<string, Serializable>;
|
|
8
|
+
thisVal?: Serializable;
|
|
9
|
+
hasCreatedEvent?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface HookInvocationQueueItem {
|
|
12
|
+
type: 'hook';
|
|
13
|
+
correlationId: string;
|
|
14
|
+
token: string;
|
|
15
|
+
metadata?: Serializable;
|
|
16
|
+
hasCreatedEvent?: boolean;
|
|
17
|
+
disposed?: boolean;
|
|
18
|
+
isWebhook?: boolean;
|
|
19
|
+
isSystem?: boolean;
|
|
20
|
+
abortRequested?: boolean;
|
|
21
|
+
abortReason?: unknown;
|
|
22
|
+
}
|
|
23
|
+
export interface WaitInvocationQueueItem {
|
|
24
|
+
type: 'wait';
|
|
25
|
+
correlationId: string;
|
|
26
|
+
resumeAt: Date;
|
|
27
|
+
hasCreatedEvent?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export type QueueItem = StepInvocationQueueItem | HookInvocationQueueItem | WaitInvocationQueueItem;
|
|
30
|
+
/**
|
|
31
|
+
* An error that is thrown when one or more operations (steps/hooks/etc.) are called but do
|
|
32
|
+
* not yet have corresponding entries in the event log. The workflow
|
|
33
|
+
* dispatcher will catch this error and push the operations
|
|
34
|
+
* onto the queue.
|
|
35
|
+
*/
|
|
36
|
+
export declare class WorkflowSuspension extends Error {
|
|
37
|
+
steps: QueueItem[];
|
|
38
|
+
globalThis: typeof globalThis;
|
|
39
|
+
stepCount: number;
|
|
40
|
+
hookCount: number;
|
|
41
|
+
waitCount: number;
|
|
42
|
+
hookDisposedCount: number;
|
|
43
|
+
abortCount: number;
|
|
44
|
+
constructor(stepsInput: Map<string, QueueItem>, global: typeof globalThis);
|
|
45
|
+
static is(value: unknown): value is WorkflowSuspension;
|
|
46
|
+
}
|
|
47
|
+
export declare function ENOTSUP(): never;
|
|
48
|
+
//# sourceMappingURL=global.d.ts.map
|
|
@@ -1,38 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export type
|
|
13
|
-
export type
|
|
14
|
-
export type
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
readonly url: string;
|
|
21
|
-
readonly workflowRunId: string;
|
|
22
|
-
readonly workflowName: string;
|
|
23
|
-
readonly workflowStartedAt: Date;
|
|
24
|
-
[key: string]: unknown;
|
|
25
|
-
}
|
|
26
|
-
export declare class FatalError extends Error {}
|
|
27
|
-
export declare class RetryableError extends Error {
|
|
28
|
-
constructor(message: string, options?: RetryableErrorOptions);
|
|
29
|
-
}
|
|
30
|
-
export declare function createHook<T = unknown>(options?: HookOptions): Hook<T>;
|
|
31
|
-
export declare function createWebhook<T = unknown>(options?: WebhookOptions): Webhook<T>;
|
|
32
|
-
export declare function defineHook<T = unknown>(): Hook<T>;
|
|
33
|
-
export declare function getStepMetadata(): StepMetadata;
|
|
34
|
-
export declare function getWorkflowMetadata(): WorkflowMetadata;
|
|
35
|
-
export declare function getWritable<T = unknown>(
|
|
36
|
-
options?: WorkflowWritableStreamOptions,
|
|
37
|
-
): WritableStream<T>;
|
|
38
|
-
export declare function sleep(duration: string | number): Promise<void>;
|
|
1
|
+
/**
|
|
2
|
+
* Just the core utilities that are meant to be imported by user
|
|
3
|
+
* steps/workflows. This allows the bundler to tree-shake and limit what goes
|
|
4
|
+
* into the final user bundles. Logic for running/handling steps/workflows
|
|
5
|
+
* should live in runtime. Eventually these might be separate packages
|
|
6
|
+
* `workflow` and `workflow/runtime`?
|
|
7
|
+
*
|
|
8
|
+
* Everything here will get re-exported under the 'workflow' top level package.
|
|
9
|
+
* This should be a minimal set of APIs so **do not anything here** unless it's
|
|
10
|
+
* needed for userland workflow code.
|
|
11
|
+
*/
|
|
12
|
+
export { FatalError, RetryableError, type RetryableErrorOptions, } from '#compiled/@workflow/errors/index.js';
|
|
13
|
+
export { createHook, createWebhook, type Hook, type HookOptions, type RequestWithResponse, type Webhook, type WebhookOptions, } from './create-hook.js';
|
|
14
|
+
export { defineHook, type TypedHook } from './define-hook.js';
|
|
15
|
+
export { sleep } from './sleep.js';
|
|
16
|
+
export { getStepMetadata, type StepMetadata, } from './step/get-step-metadata.js';
|
|
17
|
+
export { getWorkflowMetadata, type WorkflowMetadata, } from './step/get-workflow-metadata.js';
|
|
18
|
+
export { getWritable, type WorkflowWritableStreamOptions, } from './step/writable-stream.js';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)}`)}return await
|
|
1
|
+
import{i as e,s as t}from"../../_chunks/workflow/dist-C7wPwOI9.js";import{i as n,n as r,r as i}from"../../_chunks/workflow/context-errors-Bbvvp-li.js";import{c as a,s as o}from"../../_chunks/workflow/symbols-QezhMuLg.js";import{Bt as s,Ht as c,L as l,S as u,Vt as d,h as f,n as p,w as m,z as h}from"../../_chunks/workflow/resume-hook-C3VWUPii.js";import{t as g}from"../../_chunks/workflow/sleep-QTkC1VFe.js";function _(e){i(`createHook()`,`https://workflow-sdk.dev/docs/api-reference/workflow/create-hook`,_)}function v(e){i(`createWebhook()`,`https://workflow-sdk.dev/docs/api-reference/workflow/create-webhook`,v)}function y({schema:e}={}){function t(e){i(`defineHook().create()`,`https://workflow-sdk.dev/docs/api-reference/workflow/define-hook`,t)}return{create:t,async resume(t,n){if(!e?.[`~standard`])return await p(t,n);let r=e[`~standard`].validate(n);if(r instanceof Promise&&(r=await r),r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>String(typeof e==`object`&&e?e.key:e)).join(`.`);return t?` at "${t}": ${e.message}`:` ${e.message}`});throw Error(`Hook payload did not match the defined schema:\n${e.join(`
|
|
2
|
+
`)}`)}return await p(t,r.value)}}}function b(){let e=h.getStore();return e||r(`getStepMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-step-metadata`,b),e.stepMetadata}function x(){let e=h.getStore();return e||n(`getWorkflowMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-workflow-metadata`,x),e.workflowMetadata}function S(e={}){let t=h.getStore();t||n(`getWritable()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-writable`,S);let{namespace:r}=e,i=t.workflowMetadata.workflowRunId,p=l(i,r),g=m(u(globalThis,t.ops,i,t.encryptionKey),t.encryptionKey),_=new f(i,p),v=s();return t.ops.push(v.promise),d(g.readable,_,v).catch(()=>{}),c(g.writable,v),Object.defineProperty(g.writable,o,{value:p,writable:!1}),Object.defineProperty(g.writable,a,{value:i,writable:!1}),g.writable}export{e as FatalError,t as RetryableError,_ as createHook,v as createWebhook,y as defineHook,b as getStepMetadata,x as getWorkflowMetadata,S as getWritable,g as sleep};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured-log composition for `console.error` / `console.warn`. Emits
|
|
3
|
+
* one string in three sections so the most useful information is at the
|
|
4
|
+
* top, stack trace at the bottom:
|
|
5
|
+
*
|
|
6
|
+
* [workflow-sdk] <framing line>
|
|
7
|
+
* user error · FatalError
|
|
8
|
+
* run wrun_…
|
|
9
|
+
* step step_… · add (./workflows/x)
|
|
10
|
+
* hint: Move the call to a step function.
|
|
11
|
+
* FatalError: …
|
|
12
|
+
* at … (trimmed stack — internals collapsed)
|
|
13
|
+
*
|
|
14
|
+
* Without this composition, callers passing `${framing}\n${stack}` as the
|
|
15
|
+
* message and structured fields as the metadata object got `util.inspect`'s
|
|
16
|
+
* default object dump appended *after* the stack, which buries the run ID
|
|
17
|
+
* and attribution badge under 30+ lines of `node_modules/.pnpm/...` frames.
|
|
18
|
+
*
|
|
19
|
+
* The same metadata is also emitted as structured OTel span events from
|
|
20
|
+
* the logger itself, so backends that want JSON-shaped data still get it.
|
|
21
|
+
* web/web-shared do not consume stderr at all — they read CBOR/JSON event
|
|
22
|
+
* payloads from the World event log.
|
|
23
|
+
*/
|
|
24
|
+
export declare function composeLogLine(prefix: string, message: string, metadata: Record<string, unknown> | undefined): string;
|
|
25
|
+
//# sourceMappingURL=log-format.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type LogMetadata = Record<string, unknown>;
|
|
2
|
+
type LogFn = (message: string, metadata?: LogMetadata) => void;
|
|
3
|
+
export interface Logger {
|
|
4
|
+
debug: LogFn;
|
|
5
|
+
info: LogFn;
|
|
6
|
+
warn: LogFn;
|
|
7
|
+
error: LogFn;
|
|
8
|
+
/**
|
|
9
|
+
* Returns a child logger that merges the given metadata into every call.
|
|
10
|
+
* Useful for attaching stable context (e.g. `workflowRunId`, `workflowName`,
|
|
11
|
+
* `stepId`) so callers don't have to repeat it on every log.
|
|
12
|
+
*
|
|
13
|
+
* Call-site metadata wins on conflict, so children can still override.
|
|
14
|
+
*/
|
|
15
|
+
child: (metadata: LogMetadata) => Logger;
|
|
16
|
+
/**
|
|
17
|
+
* Convenience child logger for a workflow run. Equivalent to
|
|
18
|
+
* `logger.child({ workflowRunId, workflowName })`, but centralized so all
|
|
19
|
+
* runtime code structures run metadata consistently.
|
|
20
|
+
*/
|
|
21
|
+
forRun: (workflowRunId: string, workflowName?: string, extra?: LogMetadata) => Logger;
|
|
22
|
+
}
|
|
23
|
+
export declare const stepLogger: Logger;
|
|
24
|
+
export declare const runtimeLogger: Logger;
|
|
25
|
+
export declare const webhookLogger: Logger;
|
|
26
|
+
export declare const eventsLogger: Logger;
|
|
27
|
+
export declare const adapterLogger: Logger;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1,14 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Utils used by the bundler when transforming code
|
|
3
|
+
*/
|
|
4
|
+
import type { CryptoKey } from './encryption.js';
|
|
5
|
+
import type { EventsConsumer } from './events-consumer.js';
|
|
6
|
+
import type { QueueItem } from './global.js';
|
|
7
|
+
import type { Serializable } from './schemas.js';
|
|
8
|
+
export type StepFunction<Args extends Serializable[] = any[], Result extends Serializable | unknown = unknown> = ((...args: Args) => Promise<Result>) & {
|
|
9
|
+
maxRetries?: number;
|
|
10
|
+
stepId?: string;
|
|
7
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Register a step function to be served in the server bundle.
|
|
14
|
+
* Also sets the stepId property on the function for serialization support.
|
|
15
|
+
*
|
|
16
|
+
* Note: The SWC compiler plugin no longer generates calls to this function.
|
|
17
|
+
* Step registration is now inlined as a self-contained IIFE that writes
|
|
18
|
+
* directly to the global Map at Symbol.for("@workflow/core//registeredSteps").
|
|
19
|
+
* This function is kept for internal/test use only.
|
|
20
|
+
*/
|
|
21
|
+
export declare function registerStepFunction(stepId: string, stepFn: StepFunction): void;
|
|
22
|
+
/**
|
|
23
|
+
* Find a registered step function by name
|
|
24
|
+
*/
|
|
25
|
+
export declare function getStepFunction(stepId: string): StepFunction | undefined;
|
|
8
26
|
export interface WorkflowOrchestratorContext {
|
|
9
|
-
|
|
27
|
+
runId: string;
|
|
28
|
+
encryptionKey: CryptoKey | undefined;
|
|
29
|
+
globalThis: typeof globalThis;
|
|
30
|
+
eventsConsumer: EventsConsumer;
|
|
31
|
+
/**
|
|
32
|
+
* Map of pending invocations keyed by correlationId.
|
|
33
|
+
* Using Map instead of Array for O(1) lookup/delete operations.
|
|
34
|
+
*/
|
|
35
|
+
invocationsQueue: Map<string, QueueItem>;
|
|
36
|
+
onWorkflowError: (error: Error) => void;
|
|
37
|
+
generateUlid: () => string;
|
|
38
|
+
generateNanoid: () => string;
|
|
39
|
+
/**
|
|
40
|
+
* Sequential promise queue that ensures all event-driven promise resolutions
|
|
41
|
+
* (step results, hook payloads, failures, suspensions) happen in event log
|
|
42
|
+
* order. Every resolve, reject, or workflow error is chained through this
|
|
43
|
+
* queue so that even if individual operations take variable time (e.g.,
|
|
44
|
+
* async decryption), promises resolve deterministically.
|
|
45
|
+
*/
|
|
46
|
+
promiseQueue: Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Counter of in-flight async data delivery operations (step result
|
|
49
|
+
* hydration, hook payload hydration). Suspensions must wait for this
|
|
50
|
+
* to reach 0 before firing, to avoid preempting data delivery.
|
|
51
|
+
*/
|
|
52
|
+
pendingDeliveries: number;
|
|
10
53
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Schedule a callback to fire only after all pending data deliveries
|
|
56
|
+
* (step results, hook payloads) and async deserialization have completed.
|
|
57
|
+
* Uses a polling loop: setTimeout(0) → check pendingDeliveries →
|
|
58
|
+
* if > 0, wait for promiseQueue → repeat. This handles the multi-round
|
|
59
|
+
* delivery pattern where each hook payload delivery cycle appends new
|
|
60
|
+
* async work to the promiseQueue.
|
|
61
|
+
*/
|
|
14
62
|
export declare function scheduleWhenIdle(ctx: WorkflowOrchestratorContext, fn: () => void): void;
|
|
63
|
+
//# sourceMappingURL=private.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export declare const MAX_QUEUE_DELIVERIES = 48;
|
|
2
|
+
/**
|
|
3
|
+
* Default maximum time allowed for the *replay* portion of a single workflow
|
|
4
|
+
* handler invocation (in ms). This budget only covers deterministic-replay
|
|
5
|
+
* and workflow-VM execution between step boundaries — inline step bodies
|
|
6
|
+
* (`"use step"` functions invoked via `executeStep`) do NOT count against
|
|
7
|
+
* it. Step bodies are bounded separately by the platform's function
|
|
8
|
+
* `maxDuration` (e.g. 800s on Vercel Pro Fluid) and `NO_INLINE_REPLAY_AFTER_MS`.
|
|
9
|
+
*
|
|
10
|
+
* If the non-step ("replay") time within a single invocation exceeds this
|
|
11
|
+
* budget, the handler exits so the queue can retry. After
|
|
12
|
+
* `REPLAY_TIMEOUT_MAX_RETRIES` exhausted attempts the run is failed with
|
|
13
|
+
* `RUN_ERROR_CODES.REPLAY_TIMEOUT`.
|
|
14
|
+
*
|
|
15
|
+
* Note that on Vercel Hobby (standard functions), the platform `maxDuration`
|
|
16
|
+
* is 60s — well below this budget, so the platform SIGTERM will fire first
|
|
17
|
+
* and the queue will re-deliver until the visibility window expires. With
|
|
18
|
+
* Fluid Compute on Hobby the per-function ceiling rises to 300s, still
|
|
19
|
+
* under the default budget.
|
|
20
|
+
*
|
|
21
|
+
* Override via the `WORKFLOW_REPLAY_TIMEOUT_MS` env var (clamped to
|
|
22
|
+
* `MIN_REPLAY_TIMEOUT_MS`..`MAX_REPLAY_TIMEOUT_MS`).
|
|
23
|
+
*/
|
|
24
|
+
export declare const REPLAY_TIMEOUT_MS = 240000;
|
|
25
|
+
/** Lower bound for the replay-timeout env var override. */
|
|
26
|
+
export declare const MIN_REPLAY_TIMEOUT_MS = 30000;
|
|
27
|
+
/**
|
|
28
|
+
* Upper bound for the replay-timeout env var override. 780s leaves ≥20s of
|
|
29
|
+
* headroom under Vercel Pro Fluid's 800s function ceiling so the handler
|
|
30
|
+
* can write `run_failed` before SIGTERM.
|
|
31
|
+
*/
|
|
32
|
+
export declare const MAX_REPLAY_TIMEOUT_MS = 780000;
|
|
33
|
+
/**
|
|
34
|
+
* Resolve the effective replay-timeout budget for the current process.
|
|
35
|
+
*
|
|
36
|
+
* Reads `process.env.WORKFLOW_REPLAY_TIMEOUT_MS` lazily so tests and
|
|
37
|
+
* deployments can override per invocation. Invalid / out-of-range values
|
|
38
|
+
* fall back to a safe value (no throw — the env var is an escape hatch,
|
|
39
|
+
* not a hard requirement) and emit a one-time warning so misconfiguration
|
|
40
|
+
* is observable.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getReplayTimeoutMs(): number;
|
|
43
|
+
/**
|
|
44
|
+
* Reset the warn-once cache. Test-only — exported so unit tests can
|
|
45
|
+
* exercise the warn path repeatedly without sharing state.
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export declare function _resetReplayTimeoutWarnCacheForTests(): void;
|
|
50
|
+
export declare const REPLAY_TIMEOUT_MAX_RETRIES = 3;
|
|
51
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy loader for getPort that prevents bundlers (Turbopack, esbuild)
|
|
3
|
+
* from statically tracing @workflow/utils/get-port and its filesystem
|
|
4
|
+
* operations (readdir, readFile, readlink) into the flow route bundle.
|
|
5
|
+
*
|
|
6
|
+
* Uses createRequire with a dynamically constructed specifier so the
|
|
7
|
+
* dependency is invisible to bundler static analysis.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getPortLazy(): Promise<number | undefined>;
|
|
10
|
+
//# sourceMappingURL=get-port-lazy.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy accessor for the World singleton via globalThis symbols.
|
|
3
|
+
*
|
|
4
|
+
* This module exists to break the static import chain from step-side
|
|
5
|
+
* modules (serialization, run, helpers, start) to world.ts. Without it,
|
|
6
|
+
* esbuild bundles world.ts (and its transitive deps: world-local,
|
|
7
|
+
* world-vercel, process.cwd(), etc.) into the step registrations bundle,
|
|
8
|
+
* which triggers Turbopack NFT tracing errors in the V2 combined flow route.
|
|
9
|
+
*
|
|
10
|
+
* Resolution order, in priority:
|
|
11
|
+
*
|
|
12
|
+
* 1. `globalThis[WorldCacheKey]` — populated by a successful prior
|
|
13
|
+
* `getWorld()` call. This is the steady-state hot path.
|
|
14
|
+
* 2. `globalThis[GetWorldFnKey]` — populated by the module-load side
|
|
15
|
+
* effect at the bottom of `./world.ts`. Fires on every server bundle
|
|
16
|
+
* that reaches this file via `workflow/api` (which imports
|
|
17
|
+
* `./world-init.ts` for its side effect; see that file for the full
|
|
18
|
+
* rationale). This is the cold-start path for routes that consume
|
|
19
|
+
* `start` without any prior workflow run.
|
|
20
|
+
* 3. Dynamic `import('./world.js')` — last-resort fallback for
|
|
21
|
+
* environments where neither (1) nor (2) is available (CJS test
|
|
22
|
+
* runners, scripts that import deeply into `@workflow/core` without
|
|
23
|
+
* going through `workflow/api`, future bundlers we haven't validated).
|
|
24
|
+
* The specifier is built at runtime so esbuild can't trace it into
|
|
25
|
+
* step bundles. Note: this branch is unreliable in webpack-bundled
|
|
26
|
+
* routes because webpack inlines this module into the route file and
|
|
27
|
+
* the relative path resolves against the bundle location — paths (1)
|
|
28
|
+
* and (2) cover those cases instead.
|
|
29
|
+
*/
|
|
30
|
+
import type { World } from '../_workflow-world.js';
|
|
31
|
+
export declare function getWorldLazy(): Promise<World>;
|
|
32
|
+
//# sourceMappingURL=get-world-lazy.d.ts.map
|