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.
Files changed (172) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/docs/internals/hooks.md +13 -16
  3. package/dist/docs/internals/message-runtime.md +1 -1
  4. package/dist/docs/public/auth-and-route-protection.md +3 -3
  5. package/dist/docs/public/faqs.md +67 -0
  6. package/dist/docs/public/meta.json +1 -0
  7. package/dist/docs/public/schedules.md +11 -0
  8. package/dist/docs/public/session-context.md +46 -89
  9. package/dist/docs/public/skills.md +13 -0
  10. package/dist/docs/public/subagents.md +12 -6
  11. package/dist/docs/public/tools.md +9 -13
  12. package/dist/docs/public/typescript-api.md +4 -4
  13. package/dist/src/channel/types.d.ts +10 -12
  14. package/dist/src/chunks/{client-CKsU8Li3.js → client-nshDsWNF.js} +1 -1
  15. package/dist/src/chunks/{dev-authored-source-watcher-BLzYWh05.js → dev-authored-source-watcher-B4PaZGUr.js} +1 -1
  16. package/dist/src/chunks/host-DsW72Q-w.js +65 -0
  17. package/dist/src/chunks/paths-OknjaYR8.js +89 -0
  18. package/dist/src/chunks/prewarm-B4YblQ5m.js +6 -0
  19. package/dist/src/cli/commands/info.js +1 -1
  20. package/dist/src/cli/dev/repl.js +2 -2
  21. package/dist/src/cli/run.js +1 -1
  22. package/dist/src/client/session.js +8 -0
  23. package/dist/src/client/types.d.ts +12 -1
  24. package/dist/src/compiled/.vendor-stamp.json +3 -3
  25. package/dist/src/compiled/@workflow/core/_ms.d.ts +4 -0
  26. package/dist/src/compiled/@workflow/core/_workflow-serde.d.ts +5 -0
  27. package/dist/src/compiled/@workflow/core/_workflow-utils.d.ts +8 -0
  28. package/dist/src/compiled/@workflow/core/_workflow-world.d.ts +59 -0
  29. package/dist/src/compiled/@workflow/core/capabilities.d.ts +45 -0
  30. package/dist/src/compiled/@workflow/core/capture-stack.d.ts +16 -0
  31. package/dist/src/compiled/@workflow/core/class-serialization.d.ts +31 -0
  32. package/dist/src/compiled/@workflow/core/classify-error.d.ts +20 -0
  33. package/dist/src/compiled/@workflow/core/context-errors.d.ts +27 -0
  34. package/dist/src/compiled/@workflow/core/context-violation-error.d.ts +97 -0
  35. package/dist/src/compiled/@workflow/core/create-hook.d.ts +179 -0
  36. package/dist/src/compiled/@workflow/core/define-hook.d.ts +68 -0
  37. package/dist/src/compiled/@workflow/core/describe-error.d.ts +70 -0
  38. package/dist/src/compiled/@workflow/core/encryption.d.ts +51 -0
  39. package/dist/src/compiled/@workflow/core/events-consumer.d.ts +64 -0
  40. package/dist/src/compiled/@workflow/core/flushable-stream.d.ts +82 -0
  41. package/dist/src/compiled/@workflow/core/global.d.ts +48 -0
  42. package/dist/src/compiled/@workflow/core/index.d.ts +19 -38
  43. package/dist/src/compiled/@workflow/core/index.js +2 -2
  44. package/dist/src/compiled/@workflow/core/log-format.d.ts +25 -0
  45. package/dist/src/compiled/@workflow/core/logger.d.ts +29 -0
  46. package/dist/src/compiled/@workflow/core/package.json +1 -1
  47. package/dist/src/compiled/@workflow/core/private.d.ts +59 -10
  48. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +51 -0
  49. package/dist/src/compiled/@workflow/core/runtime/get-port-lazy.d.ts +10 -0
  50. package/dist/src/compiled/@workflow/core/runtime/get-world-lazy.d.ts +32 -0
  51. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +97 -0
  52. package/dist/src/compiled/@workflow/core/runtime/replay-budget.d.ts +98 -0
  53. package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +77 -0
  54. package/dist/src/compiled/@workflow/core/runtime/run.d.ts +134 -0
  55. package/dist/src/compiled/@workflow/core/runtime/runs.d.ts +50 -0
  56. package/dist/src/compiled/@workflow/core/runtime/start.d.ts +59 -0
  57. package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +40 -0
  58. package/dist/src/compiled/@workflow/core/runtime/step-handler.d.ts +2 -0
  59. package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +42 -0
  60. package/dist/src/compiled/@workflow/core/runtime/world-init.d.ts +75 -0
  61. package/dist/src/compiled/@workflow/core/runtime/world.d.ts +32 -0
  62. package/dist/src/compiled/@workflow/core/runtime.d.ts +22 -67
  63. package/dist/src/compiled/@workflow/core/runtime.js +27 -27
  64. package/dist/src/compiled/@workflow/core/schemas.d.ts +15 -0
  65. package/dist/src/compiled/@workflow/core/serialization/client.d.ts +17 -0
  66. package/dist/src/compiled/@workflow/core/serialization/codec-devalue.d.ts +14 -0
  67. package/dist/src/compiled/@workflow/core/serialization/codec.d.ts +90 -0
  68. package/dist/src/compiled/@workflow/core/serialization/encryption.d.ts +32 -0
  69. package/dist/src/compiled/@workflow/core/serialization/errors.d.ts +21 -0
  70. package/dist/src/compiled/@workflow/core/serialization/format.d.ts +60 -0
  71. package/dist/src/compiled/@workflow/core/serialization/index.d.ts +18 -0
  72. package/dist/src/compiled/@workflow/core/serialization/reducers/class.d.ts +11 -0
  73. package/dist/src/compiled/@workflow/core/serialization/reducers/common.d.ts +16 -0
  74. package/dist/src/compiled/@workflow/core/serialization/reducers/step-function.d.ts +35 -0
  75. package/dist/src/compiled/@workflow/core/serialization/step.d.ts +17 -0
  76. package/dist/src/compiled/@workflow/core/serialization/types.d.ts +215 -0
  77. package/dist/src/compiled/@workflow/core/serialization/workflow.d.ts +29 -0
  78. package/dist/src/compiled/@workflow/core/serialization-format.d.ts +171 -0
  79. package/dist/src/compiled/@workflow/core/serialization.d.ts +337 -0
  80. package/dist/src/compiled/@workflow/core/sleep.d.ts +33 -0
  81. package/dist/src/compiled/@workflow/core/source-map.d.ts +10 -0
  82. package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +13 -0
  83. package/dist/src/compiled/@workflow/core/step/get-closure-vars.d.ts +9 -0
  84. package/dist/src/compiled/@workflow/core/step/get-step-metadata.d.ts +42 -0
  85. package/dist/src/compiled/@workflow/core/step/get-workflow-metadata.d.ts +7 -0
  86. package/dist/src/compiled/@workflow/core/step/writable-stream.d.ts +22 -0
  87. package/dist/src/compiled/@workflow/core/step.d.ts +4 -0
  88. package/dist/src/compiled/@workflow/core/symbols.d.ts +36 -0
  89. package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +283 -0
  90. package/dist/src/compiled/@workflow/core/telemetry.d.ts +53 -0
  91. package/dist/src/compiled/@workflow/core/types.d.ts +14 -0
  92. package/dist/src/compiled/@workflow/core/util.d.ts +40 -0
  93. package/dist/src/compiled/@workflow/core/version.d.ts +2 -0
  94. package/dist/src/compiled/@workflow/core/vm/index.d.ts +17 -0
  95. package/dist/src/compiled/@workflow/core/vm/uint8array-base64.d.ts +21 -0
  96. package/dist/src/compiled/@workflow/core/vm/uuid.d.ts +10 -0
  97. package/dist/src/compiled/@workflow/core/workflow/abort-controller.d.ts +65 -0
  98. package/dist/src/compiled/@workflow/core/workflow/create-hook.d.ts +7 -0
  99. package/dist/src/compiled/@workflow/core/workflow/define-hook.d.ts +10 -0
  100. package/dist/src/compiled/@workflow/core/workflow/get-workflow-metadata.d.ts +32 -0
  101. package/dist/src/compiled/@workflow/core/workflow/hook.d.ts +4 -0
  102. package/dist/src/compiled/@workflow/core/workflow/index.d.ts +11 -0
  103. package/dist/src/compiled/@workflow/core/workflow/sleep.d.ts +4 -0
  104. package/dist/src/compiled/@workflow/core/workflow/world-init-stub.d.ts +15 -0
  105. package/dist/src/compiled/@workflow/core/workflow/writable-stream.d.ts +3 -0
  106. package/dist/src/compiled/@workflow/core/workflow.d.ts +1 -38
  107. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  108. package/dist/src/compiled/@workflow/errors/error-codes.d.ts +5 -1
  109. package/dist/src/compiled/@workflow/errors/index.d.ts +15 -1
  110. package/dist/src/compiled/@workflow/errors/index.js +1 -1
  111. package/dist/src/compiled/@workflow/errors/package.json +1 -1
  112. package/dist/src/compiled/_chunks/workflow/{context-errors-zbKocOyk.js → context-errors-Bbvvp-li.js} +2 -2
  113. package/dist/src/compiled/_chunks/workflow/{dist-0iNBqPYp.js → dist-C7wPwOI9.js} +2 -2
  114. package/dist/src/compiled/_chunks/workflow/{dist-D774SUM4.js → dist-C_oiE-l7.js} +1 -1
  115. package/dist/src/compiled/_chunks/workflow/resume-hook-C3VWUPii.js +12 -0
  116. package/dist/src/compiled/_chunks/workflow/sleep-QTkC1VFe.js +1 -0
  117. package/dist/src/compiled/_chunks/workflow/{symbols-D-4tVV8x.js → symbols-QezhMuLg.js} +1 -1
  118. package/dist/src/evals/cli/eval.js +1 -1
  119. package/dist/src/execution/await-authorization-orchestrator.d.ts +2 -1
  120. package/dist/src/execution/await-authorization-orchestrator.js +4 -0
  121. package/dist/src/execution/connection-auth-steps.d.ts +4 -0
  122. package/dist/src/execution/connection-auth-steps.js +9 -11
  123. package/dist/src/execution/node-step.d.ts +4 -5
  124. package/dist/src/execution/subagent-adapter.d.ts +0 -27
  125. package/dist/src/execution/subagent-adapter.js +2 -66
  126. package/dist/src/execution/subagent-hitl-proxy.d.ts +2 -2
  127. package/dist/src/execution/subagent-hitl-proxy.js +2 -2
  128. package/dist/src/execution/task-mode.d.ts +3 -3
  129. package/dist/src/execution/task-mode.js +3 -3
  130. package/dist/src/execution/turn-workflow.d.ts +41 -0
  131. package/dist/src/execution/turn-workflow.js +96 -0
  132. package/dist/src/execution/workflow-entry.js +77 -87
  133. package/dist/src/execution/workflow-errors.d.ts +14 -0
  134. package/dist/src/execution/workflow-errors.js +54 -0
  135. package/dist/src/execution/workflow-runtime.d.ts +34 -3
  136. package/dist/src/execution/workflow-runtime.js +52 -10
  137. package/dist/src/execution/workflow-steps.d.ts +27 -2
  138. package/dist/src/execution/workflow-steps.js +31 -26
  139. package/dist/src/harness/instrumentation-config.js +14 -7
  140. package/dist/src/harness/messages.d.ts +7 -7
  141. package/dist/src/harness/messages.js +4 -4
  142. package/dist/src/harness/runtime-actions.d.ts +4 -4
  143. package/dist/src/internal/application/package.js +1 -1
  144. package/dist/src/internal/workflow-bundle/workflow-builders.d.ts +1 -1
  145. package/dist/src/internal/workflow-bundle/workflow-builders.js +20 -8
  146. package/dist/src/internal/workflow-bundle/workflow-transformer.d.ts +13 -0
  147. package/dist/src/internal/workflow-bundle/workflow-transformer.js +10 -4
  148. package/dist/src/protocol/message.d.ts +6 -1
  149. package/dist/src/public/channels/ash.js +50 -3
  150. package/dist/src/public/context/index.d.ts +4 -7
  151. package/dist/src/public/context/index.js +4 -5
  152. package/dist/src/public/definitions/state.d.ts +33 -0
  153. package/dist/src/public/definitions/state.js +34 -0
  154. package/dist/src/public/next/index.d.ts +7 -0
  155. package/dist/src/public/next/index.js +2 -0
  156. package/dist/src/public/next/vercel-json.d.ts +1 -0
  157. package/dist/src/public/next/vercel-json.js +1 -0
  158. package/dist/src/react/index.d.ts +1 -1
  159. package/dist/src/react/use-ash-agent.d.ts +8 -0
  160. package/dist/src/react/use-ash-agent.js +26 -4
  161. package/dist/src/services/dev-client.d.ts +4 -1
  162. package/dist/src/services/dev-client.js +1 -0
  163. package/package.json +4 -4
  164. package/dist/src/chunks/host-DREC8e8Z.js +0 -65
  165. package/dist/src/chunks/paths-C6sp4T2U.js +0 -88
  166. package/dist/src/chunks/prewarm-hz8p2jlZ.js +0 -6
  167. package/dist/src/compiled/_chunks/workflow/resume-hook-CL8Ed91K.js +0 -12
  168. package/dist/src/compiled/_chunks/workflow/sleep-Dn3i9nxI.js +0 -1
  169. package/dist/src/execution/continuous-entry.d.ts +0 -59
  170. package/dist/src/execution/continuous-entry.js +0 -487
  171. package/dist/src/execution/continuous-runtime.d.ts +0 -17
  172. package/dist/src/execution/continuous-runtime.js +0 -123
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Browser-safe serialization format utilities.
3
+ *
4
+ * This module contains the format prefix handling, generic hydrate/dehydrate
5
+ * dispatch, and shared types/classes used by all environments (runtime, web
6
+ * o11y, CLI o11y). It has NO Node.js dependencies.
7
+ */
8
+ export declare const SerializationFormat: {
9
+ /** devalue stringify/parse with TextEncoder/TextDecoder */
10
+ readonly DEVALUE_V1: "devl";
11
+ /** Encrypted payload (inner payload has its own format prefix after decryption) */
12
+ readonly ENCRYPTED: "encr";
13
+ };
14
+ export type SerializationFormatType = (typeof SerializationFormat)[keyof typeof SerializationFormat];
15
+ /**
16
+ * Encode a payload with a format prefix.
17
+ */
18
+ export declare function encodeWithFormatPrefix(format: SerializationFormatType, payload: Uint8Array | unknown): Uint8Array | unknown;
19
+ /**
20
+ * Decode a format-prefixed payload.
21
+ */
22
+ export declare function decodeFormatPrefix(data: Uint8Array | unknown): {
23
+ format: SerializationFormatType;
24
+ payload: Uint8Array;
25
+ };
26
+ /**
27
+ * Placeholder string displayed when data is encrypted and decryption
28
+ * has not been requested. Used by both CLI and web o11y.
29
+ */
30
+ export declare const ENCRYPTED_PLACEHOLDER = "\uD83D\uDD12 Encrypted";
31
+ /**
32
+ * Check if a hydrated value is an expired data stub from the server.
33
+ *
34
+ * The server replaces expired ref fields with a devalue-encoded stub
35
+ * (`makeExpiredStub`) that deserializes to `[{ expiredAt: "<ISO date>" }]`
36
+ * after `unflatten` (array-wrapped due to backwards-compatible encoding).
37
+ * Also matches the unwrapped `{ expiredAt: "..." }` form for robustness.
38
+ */
39
+ export declare function isExpiredStub(data: unknown): boolean;
40
+ /**
41
+ * Check if a binary value has the 'encr' format prefix indicating encryption.
42
+ * Browser-safe — does not depend on the full serialization module.
43
+ */
44
+ export declare function isEncryptedData(data: unknown): boolean;
45
+ /**
46
+ * A map of type name → reviver function, used by devalue's `parse`/`unflatten`.
47
+ * Each environment (runtime, web, CLI) provides its own set.
48
+ */
49
+ export type Revivers = Record<string, (value: any) => any>;
50
+ /**
51
+ * Hydrate (deserialize) a value that was stored in the database.
52
+ *
53
+ * Handles four data shapes:
54
+ * 1. `Uint8Array` with 'encr' prefix → returned as-is (encrypted, not yet decrypted)
55
+ * 2. `Uint8Array` with a format prefix (specVersion 2+) → decode prefix, parse
56
+ * 3. `Array` (legacy specVersion 1, "revived devalue") → unflatten
57
+ * 4. Other (already a plain JS value) → return as-is
58
+ *
59
+ * Encrypted data is intentionally left as a `Uint8Array` so that consumers
60
+ * (CLI, web UI) can detect it with `isEncryptedData()` and decide how to
61
+ * handle it — the CLI replaces it with a styled placeholder, the web UI
62
+ * renders an "Encrypted" card with a Decrypt button that triggers
63
+ * client-side decryption on demand.
64
+ */
65
+ export declare function hydrateData(value: unknown, revivers: Revivers): unknown;
66
+ /**
67
+ * Hydrate a value, decrypting it first if an encryption key is provided.
68
+ *
69
+ * This is the async version of `hydrateData` that supports transparent
70
+ * decryption. Used by o11y tooling (web UI, CLI) when the user requests
71
+ * decryption.
72
+ *
73
+ * @param value - The value to hydrate (may be encrypted)
74
+ * @param revivers - Devalue revivers for deserialization
75
+ * @param key - AES-256 encryption key (if provided, encrypted data will be decrypted)
76
+ */
77
+ export declare function hydrateDataWithKey(value: unknown, revivers: Revivers, key: import('./encryption.js').CryptoKey | undefined): Promise<unknown>;
78
+ /** Marker for stream reference objects rendered as links in the UI */
79
+ export declare const STREAM_REF_TYPE = "__workflow_stream_ref__";
80
+ /** A stream reference for UI display */
81
+ export interface StreamRef {
82
+ __type: typeof STREAM_REF_TYPE;
83
+ streamId: string;
84
+ }
85
+ /** Marker for Run reference objects rendered as links in the UI */
86
+ export declare const RUN_REF_TYPE = "__workflow_run_ref__";
87
+ /** A Run reference for UI display */
88
+ export interface RunRef {
89
+ __type: typeof RUN_REF_TYPE;
90
+ runId: string;
91
+ }
92
+ /** Check if a value is a RunRef object */
93
+ export declare const isRunRef: (value: unknown) => value is RunRef;
94
+ /** Convert a serialized Run value to a RunRef for display */
95
+ export declare const serializedRunToRunRef: (value: {
96
+ runId: string;
97
+ }) => RunRef;
98
+ /** Marker for custom class instance references */
99
+ export declare const CLASS_INSTANCE_REF_TYPE = "__workflow_class_instance_ref__";
100
+ /**
101
+ * A class instance reference for o11y display.
102
+ *
103
+ * Browser-safe base class — no `util.inspect.custom`. Environment-specific
104
+ * rendering (CLI inspect, web component) is handled by each consumer.
105
+ */
106
+ export declare class ClassInstanceRef {
107
+ readonly className: string;
108
+ readonly classId: string;
109
+ readonly data: unknown;
110
+ readonly __type = "__workflow_class_instance_ref__";
111
+ constructor(className: string, classId: string, data: unknown);
112
+ toJSON(): {
113
+ __type: string;
114
+ className: string;
115
+ classId: string;
116
+ data: unknown;
117
+ };
118
+ }
119
+ /** Check if a value is a ClassInstanceRef object */
120
+ export declare const isClassInstanceRef: (value: unknown) => value is ClassInstanceRef;
121
+ /** Check if a value is a stream ID string */
122
+ export declare const isStreamId: (value: unknown) => boolean;
123
+ /** Check if a value is a StreamRef object */
124
+ export declare const isStreamRef: (value: unknown) => value is StreamRef;
125
+ /**
126
+ * Convert a serialized stream value to a StreamRef for display.
127
+ */
128
+ export declare const streamToStreamRef: (value: any) => StreamRef;
129
+ /** Convert a serialized step function to a display string */
130
+ export declare const serializedStepFunctionToString: (value: unknown) => string;
131
+ /** Extract the class name from a classId */
132
+ export declare const extractClassName: (classId: string) => string;
133
+ /** Convert a serialized class instance to a ClassInstanceRef for display.
134
+ * Run instances are special-cased to a RunRef for clickable rendering. */
135
+ export declare const serializedInstanceToRef: (value: {
136
+ classId: string;
137
+ data: unknown;
138
+ }) => ClassInstanceRef | RunRef;
139
+ /** Convert a serialized class reference to a display string */
140
+ export declare const serializedClassToString: (value: {
141
+ classId: string;
142
+ }) => string;
143
+ /**
144
+ * Standard o11y revivers that override runtime-specific types with
145
+ * display-friendly values. Used by both web and CLI hydration.
146
+ */
147
+ export declare const observabilityRevivers: Revivers;
148
+ /**
149
+ * Hydrate the serialized data fields of any resource for o11y display.
150
+ *
151
+ * Dispatches by resource type (step, hook, event, workflow) and calls
152
+ * `hydrateData` with the provided revivers for each data field.
153
+ *
154
+ * Each environment (web, CLI) provides its own revivers — this function
155
+ * only handles the dispatch logic and field mapping.
156
+ */
157
+ export declare function hydrateResourceIO<T extends {
158
+ stepId?: string;
159
+ hookId?: string;
160
+ eventId?: string;
161
+ input?: any;
162
+ output?: any;
163
+ metadata?: any;
164
+ eventData?: any;
165
+ executionContext?: any;
166
+ }>(resource: T, revivers: Revivers): T;
167
+ /** Extract all stream IDs from a value (recursively traverses objects/arrays) */
168
+ export declare function extractStreamIds(obj: unknown): string[];
169
+ /** Truncate a string to a maximum length, adding ellipsis if needed */
170
+ export declare function truncateId(id: string, maxLength?: number): string;
171
+ //# sourceMappingURL=serialization-format.d.ts.map
@@ -0,0 +1,337 @@
1
+ import { type CryptoKey } from './encryption.js';
2
+ import { decrypt, type EncryptionKeyParam, encrypt } from './serialization/encryption.js';
3
+ import { decodeFormatPrefix, encodeWithFormatPrefix, isEncrypted, peekFormatPrefix } from './serialization/format.js';
4
+ import { type FormatPrefix, isFormatPrefix, SerializationFormat } from './serialization/types.js';
5
+ export { SerializationFormat, type FormatPrefix, isFormatPrefix, encodeWithFormatPrefix, decodeFormatPrefix, peekFormatPrefix, isEncrypted, encrypt, decrypt, type EncryptionKeyParam, };
6
+ export type SerializationFormatType = (typeof SerializationFormat)[keyof typeof SerializationFormat];
7
+ /**
8
+ * Detect if a readable stream is a byte stream.
9
+ *
10
+ * @param stream
11
+ * @returns `"bytes"` if the stream is a byte stream, `undefined` otherwise
12
+ */
13
+ export declare function getStreamType(stream: ReadableStream): 'bytes' | undefined;
14
+ export declare function getSerializeStream(reducers: Partial<Reducers>, cryptoKey: EncryptionKeyParam): TransformStream<any, Uint8Array>;
15
+ export declare function getDeserializeStream(revivers: Partial<Revivers>, cryptoKey: EncryptionKeyParam): TransformStream<Uint8Array, any>;
16
+ export declare class WorkflowServerReadableStream extends ReadableStream<Uint8Array> {
17
+ #private;
18
+ constructor(runId: string, name: string, startIndex?: number);
19
+ }
20
+ export declare class WorkflowServerWritableStream extends WritableStream<Uint8Array> {
21
+ constructor(runId: string, name: string);
22
+ }
23
+ export type { Reducers, Revivers, SerializableSpecial, } from './serialization/types.js';
24
+ import type { Reducers, Revivers } from './serialization/types.js';
25
+ /**
26
+ * Reducers for serialization boundary from the client side, passing arguments
27
+ * to the workflow handler.
28
+ *
29
+ * @param global
30
+ * @param ops
31
+ * @returns
32
+ */
33
+ export declare function getExternalReducers(global: Record<string, any> | undefined, ops: Promise<void>[], runId: string, cryptoKey: EncryptionKeyParam): Partial<Reducers>;
34
+ /**
35
+ * Reducers for serialization boundary from within the workflow execution
36
+ * environment, passing return value to the client side and into step arguments.
37
+ *
38
+ * @param global
39
+ * @returns
40
+ */
41
+ export declare function getWorkflowReducers(global?: Record<string, any>): Partial<Reducers>;
42
+ /**
43
+ * Cancel dangling abort-stream readers on any AbortController instances found
44
+ * in the hydrated step arguments. Called after the step function returns
45
+ * (success or failure) to prevent reader promises from keeping the serverless
46
+ * function alive indefinitely.
47
+ */
48
+ export declare function cancelAbortReaders(...values: unknown[]): void;
49
+ /**
50
+ * Base revivers shared across all serialization boundaries.
51
+ * Composes: class + common revivers from the modular modules.
52
+ *
53
+ * This is exported because serialization-format.ts and other files reference it.
54
+ */
55
+ export declare function getCommonRevivers(global?: Record<string, any>): {
56
+ ArrayBuffer?: ((value: string) => any) | undefined;
57
+ BigInt?: ((value: string) => any) | undefined;
58
+ BigInt64Array?: ((value: string) => any) | undefined;
59
+ BigUint64Array?: ((value: string) => any) | undefined;
60
+ Date?: ((value: string) => any) | undefined;
61
+ DOMException?: ((value: {
62
+ message: string;
63
+ name: string;
64
+ stack?: string;
65
+ cause?: unknown;
66
+ }) => any) | undefined;
67
+ FatalError?: ((value: {
68
+ message: string;
69
+ stack?: string;
70
+ cause?: unknown;
71
+ }) => any) | undefined;
72
+ Float32Array?: ((value: string) => any) | undefined;
73
+ Float64Array?: ((value: string) => any) | undefined;
74
+ Error?: ((value: {
75
+ name: string;
76
+ message: string;
77
+ stack?: string;
78
+ cause?: unknown;
79
+ }) => any) | undefined;
80
+ EvalError?: ((value: {
81
+ message: string;
82
+ stack?: string;
83
+ cause?: unknown;
84
+ }) => any) | undefined;
85
+ Headers?: ((value: [string, string][]) => any) | undefined;
86
+ HookConflictError?: ((value: {
87
+ message: string;
88
+ stack?: string;
89
+ cause?: unknown;
90
+ token: string;
91
+ conflictingRunId?: string;
92
+ }) => any) | undefined;
93
+ Int8Array?: ((value: string) => any) | undefined;
94
+ Int16Array?: ((value: string) => any) | undefined;
95
+ Int32Array?: ((value: string) => any) | undefined;
96
+ Map?: ((value: [any, any][]) => any) | undefined;
97
+ RangeError?: ((value: {
98
+ message: string;
99
+ stack?: string;
100
+ cause?: unknown;
101
+ }) => any) | undefined;
102
+ ReadableStream?: ((value: {
103
+ name: string;
104
+ type?: "bytes";
105
+ startIndex?: number;
106
+ } | {
107
+ bodyInit: any;
108
+ }) => any) | undefined;
109
+ ReferenceError?: ((value: {
110
+ message: string;
111
+ stack?: string;
112
+ cause?: unknown;
113
+ }) => any) | undefined;
114
+ RegExp?: ((value: {
115
+ source: string;
116
+ flags: string;
117
+ }) => any) | undefined;
118
+ RetryableError?: ((value: {
119
+ message: string;
120
+ stack?: string;
121
+ cause?: unknown;
122
+ retryAfter: number;
123
+ }) => any) | undefined;
124
+ Request?: ((value: {
125
+ method: string;
126
+ url: string;
127
+ headers: Headers;
128
+ body: Request["body"];
129
+ duplex: Request["duplex"];
130
+ responseWritable?: WritableStream<Response>;
131
+ signal?: AbortSignal;
132
+ }) => any) | undefined;
133
+ Response?: ((value: {
134
+ type: Response["type"];
135
+ url: string;
136
+ status: number;
137
+ statusText: string;
138
+ headers: Headers;
139
+ body: Response["body"];
140
+ redirected: boolean;
141
+ }) => any) | undefined;
142
+ Class?: ((value: {
143
+ classId: string;
144
+ }) => any) | undefined;
145
+ Instance?: ((value: {
146
+ classId: string;
147
+ data: unknown;
148
+ }) => any) | undefined;
149
+ Set?: ((value: any[]) => any) | undefined;
150
+ SyntaxError?: ((value: {
151
+ message: string;
152
+ stack?: string;
153
+ cause?: unknown;
154
+ }) => any) | undefined;
155
+ StepFunction?: ((value: {
156
+ stepId: string;
157
+ closureVars?: Record<string, any>;
158
+ boundThis?: unknown;
159
+ boundArgs?: unknown[];
160
+ }) => any) | undefined;
161
+ TypeError?: ((value: {
162
+ message: string;
163
+ stack?: string;
164
+ cause?: unknown;
165
+ }) => any) | undefined;
166
+ URIError?: ((value: {
167
+ message: string;
168
+ stack?: string;
169
+ cause?: unknown;
170
+ }) => any) | undefined;
171
+ URL?: ((value: string) => any) | undefined;
172
+ WorkflowFunction?: ((value: {
173
+ workflowId: string;
174
+ }) => any) | undefined;
175
+ URLSearchParams?: ((value: string) => any) | undefined;
176
+ Uint8Array?: ((value: string) => any) | undefined;
177
+ Uint8ClampedArray?: ((value: string) => any) | undefined;
178
+ Uint16Array?: ((value: string) => any) | undefined;
179
+ Uint32Array?: ((value: string) => any) | undefined;
180
+ AggregateError?: ((value: {
181
+ message: string;
182
+ stack?: string;
183
+ cause?: unknown;
184
+ errors: unknown[];
185
+ }) => any) | undefined;
186
+ WritableStream?: ((value: {
187
+ name: string;
188
+ runId?: string;
189
+ }) => any) | undefined;
190
+ AbortController?: ((value: {
191
+ streamName: string;
192
+ hookToken: string;
193
+ aborted: boolean;
194
+ reason?: unknown;
195
+ }) => any) | undefined;
196
+ AbortSignal?: ((value: {
197
+ streamName: string;
198
+ hookToken: string;
199
+ aborted: boolean;
200
+ reason?: unknown;
201
+ }) => any) | undefined;
202
+ };
203
+ /**
204
+ * Revivers for deserialization boundary from the client side,
205
+ * receiving the return value from the workflow handler.
206
+ *
207
+ * @param global
208
+ * @param ops
209
+ * @param runId
210
+ */
211
+ export declare function getExternalRevivers(global: Record<string, any> | undefined, ops: Promise<void>[], runId: string, cryptoKey: EncryptionKeyParam): Partial<Revivers>;
212
+ /**
213
+ * Revivers for deserialization boundary from within the workflow execution
214
+ * environment, receiving arguments from the client side, and return values
215
+ * from the steps.
216
+ *
217
+ * @param global
218
+ * @returns
219
+ */
220
+ export declare function getWorkflowRevivers(global?: Record<string, any>): Partial<Revivers>;
221
+ /**
222
+ * Encrypt data if the world supports encryption.
223
+ * Returns original data if encryption is not available.
224
+ *
225
+ * @deprecated Use `encrypt` from `./serialization/encryption.js` instead.
226
+ */
227
+ export declare function maybeEncrypt(data: Uint8Array, key: CryptoKey | undefined): Promise<Uint8Array>;
228
+ /**
229
+ * Decrypt data if it has the 'encr' prefix.
230
+ *
231
+ * @deprecated Use `decrypt` from `./serialization/encryption.js` instead.
232
+ */
233
+ export declare function maybeDecrypt(data: Uint8Array | unknown, key: CryptoKey | undefined): Promise<Uint8Array | unknown>;
234
+ /**
235
+ * Called from the `start()` function to serialize the workflow arguments
236
+ * into a format that can be saved to the database and then hydrated from
237
+ * within the workflow execution environment.
238
+ */
239
+ export declare function dehydrateWorkflowArguments(value: unknown, runId: string, key: CryptoKey | undefined, ops?: Promise<void>[], global?: Record<string, any>, v1Compat?: boolean): Promise<Uint8Array | unknown>;
240
+ /**
241
+ * Called from workflow execution environment to hydrate the workflow
242
+ * arguments from the database at the start of workflow execution.
243
+ */
244
+ export declare function hydrateWorkflowArguments(value: Uint8Array | unknown, _runId: string, key: CryptoKey | undefined, global?: Record<string, any>, extraRevivers?: Record<string, (value: any) => any>): Promise<any>;
245
+ /**
246
+ * Dehydrate workflow return value for storage.
247
+ */
248
+ export declare function dehydrateWorkflowReturnValue(value: unknown, _runId: string, key: CryptoKey | undefined, global?: Record<string, any>, v1Compat?: boolean): Promise<Uint8Array | unknown>;
249
+ /**
250
+ * Called from the client side to hydrate the workflow return value
251
+ * of a completed workflow run.
252
+ */
253
+ export declare function hydrateWorkflowReturnValue(value: Uint8Array | unknown, runId: string, key: CryptoKey | undefined, ops?: Promise<void>[], global?: Record<string, any>, extraRevivers?: Record<string, (value: any) => any>): Promise<any>;
254
+ /**
255
+ * Called from the workflow handler when a step is being created.
256
+ * Dehydrates values from within the workflow execution environment.
257
+ */
258
+ export declare function dehydrateStepArguments(value: unknown, _runId: string, key: CryptoKey | undefined, global?: Record<string, any>, v1Compat?: boolean): Promise<Uint8Array | unknown>;
259
+ /**
260
+ * Called from the step handler to hydrate the arguments of a step
261
+ * from the database at the start of the step execution.
262
+ */
263
+ export declare function hydrateStepArguments(value: Uint8Array | unknown, runId: string, key: CryptoKey | undefined, ops?: Promise<any>[], global?: Record<string, any>, extraRevivers?: Record<string, (value: any) => any>): Promise<any>;
264
+ /**
265
+ * Called from the step handler when a step has completed.
266
+ * Dehydrates values from within the step execution environment.
267
+ */
268
+ export declare function dehydrateStepReturnValue(value: unknown, runId: string, key: CryptoKey | undefined, ops?: Promise<any>[], global?: Record<string, any>, v1Compat?: boolean): Promise<Uint8Array | unknown>;
269
+ /**
270
+ * Called from the step handler when a step throws. Dehydrates the thrown
271
+ * value from within the step execution environment into a format that can
272
+ * be saved to the database in a `step_failed` or `step_retrying` event.
273
+ *
274
+ * Any JavaScript value can be thrown (strings, numbers, objects, Errors,
275
+ * Error subclasses), so the same serialization pipeline used for step
276
+ * arguments and return values is applied here.
277
+ *
278
+ * @param value - The thrown value to serialize (can be any type)
279
+ * @param runId - Run ID for encryption context
280
+ * @param key - Encryption key (undefined to skip encryption)
281
+ * @param ops - Promise array for stream operations
282
+ * @param global - Global object for serialization context
283
+ * @returns The dehydrated value as binary data (Uint8Array) with format prefix
284
+ */
285
+ export declare function dehydrateStepError(value: unknown, runId: string, key: CryptoKey | undefined, ops?: Promise<any>[], global?: Record<string, any>): Promise<Uint8Array>;
286
+ /**
287
+ * Called from the workflow handler when replaying the event log of a
288
+ * `step_failed` or `step_retrying` event. Hydrates the thrown value from
289
+ * the database so the workflow can see the original thrown value.
290
+ *
291
+ * @param value - Binary serialized data (Uint8Array) with format prefix
292
+ * @param runId - Run ID for decryption context
293
+ * @param key - Encryption key (undefined to skip decryption)
294
+ * @param global - Global object for deserialization context
295
+ * @param extraRevivers - Additional revivers for custom types
296
+ * @returns The hydrated thrown value, ready to reject the step promise
297
+ */
298
+ export declare function hydrateStepError(value: Uint8Array | unknown, _runId: string, key: CryptoKey | undefined, global?: Record<string, any>, extraRevivers?: Record<string, (value: any) => any>): Promise<unknown>;
299
+ /**
300
+ * Called from the workflow handler when the workflow itself throws.
301
+ * Dehydrates the thrown value from within the workflow execution environment
302
+ * into a format that can be saved to the database in a `run_failed` event.
303
+ *
304
+ * @param value - The thrown value to serialize (can be any type)
305
+ * @param runId - Run ID for encryption context
306
+ * @param key - Encryption key (undefined to skip encryption)
307
+ * @param global - Global object for serialization context
308
+ * @returns The dehydrated value as binary data (Uint8Array) with format prefix
309
+ */
310
+ export declare function dehydrateRunError(value: unknown, _runId: string, key: CryptoKey | undefined, global?: Record<string, any>): Promise<Uint8Array>;
311
+ /**
312
+ * Called from the client side (or observability tools) to hydrate the run
313
+ * error value of a failed workflow run.
314
+ *
315
+ * @param value - Binary serialized data (Uint8Array) with format prefix
316
+ * @param runId - Run ID for decryption context
317
+ * @param key - Encryption key (undefined to skip decryption)
318
+ * @param ops - Promise array for stream operations
319
+ * @param global - Global object for deserialization context
320
+ * @param extraRevivers - Additional revivers for custom types
321
+ * @returns The hydrated thrown value, ready to be consumed by the client
322
+ */
323
+ export declare function hydrateRunError(value: Uint8Array | unknown, runId: string, key: CryptoKey | undefined, ops?: Promise<void>[], global?: Record<string, any>, extraRevivers?: Record<string, (value: any) => any>): Promise<unknown>;
324
+ /**
325
+ * Called from the workflow handler when replaying the event log of a `step_completed` event.
326
+ * Hydrates the return value of a step from the database.
327
+ *
328
+ * @param value - Binary serialized data (Uint8Array) with format prefix
329
+ * @param runId - Run ID for decryption context
330
+ * @param key - Encryption key (undefined to skip decryption)
331
+ * @param global - Global object for deserialization context
332
+ * @param extraRevivers - Additional revivers for custom types
333
+ * Called from the workflow handler when replaying the event log
334
+ * of a `step_completed` event.
335
+ */
336
+ export declare function hydrateStepReturnValue(value: Uint8Array | unknown, _runId: string, key: CryptoKey | undefined, global?: Record<string, any>, extraRevivers?: Record<string, (value: any) => any>): Promise<any>;
337
+ //# sourceMappingURL=serialization.d.ts.map
@@ -0,0 +1,33 @@
1
+ import type { StringValue } from './_ms.js';
2
+ /**
3
+ * Sleep within a workflow for a given duration.
4
+ *
5
+ * This is a built-in runtime function that uses timer events in the event log.
6
+ *
7
+ * @param duration - The duration to sleep for, this is a string in the format
8
+ * of `"1000ms"`, `"1s"`, `"1m"`, `"1h"`, or `"1d"`.
9
+ * @overload
10
+ * @returns A promise that resolves when the sleep is complete.
11
+ */
12
+ export declare function sleep(duration: StringValue): Promise<void>;
13
+ /**
14
+ * Sleep within a workflow until a specific date.
15
+ *
16
+ * This is a built-in runtime function that uses timer events in the event log.
17
+ *
18
+ * @param date - The date to sleep until, this must be a future date.
19
+ * @overload
20
+ * @returns A promise that resolves when the sleep is complete.
21
+ */
22
+ export declare function sleep(date: Date): Promise<void>;
23
+ /**
24
+ * Sleep within a workflow for a given duration in milliseconds.
25
+ *
26
+ * This is a built-in runtime function that uses timer events in the event log.
27
+ *
28
+ * @param durationMs - The duration to sleep for in milliseconds.
29
+ * @overload
30
+ * @returns A promise that resolves when the sleep is complete.
31
+ */
32
+ export declare function sleep(durationMs: number): Promise<void>;
33
+ //# sourceMappingURL=sleep.d.ts.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Remaps an error stack trace using inline source maps to show original source locations.
3
+ *
4
+ * @param stack - The error stack trace to remap
5
+ * @param filename - The workflow filename to match in stack frames
6
+ * @param workflowCode - The workflow bundle code containing inline source maps
7
+ * @returns The remapped stack trace with original source locations
8
+ */
9
+ export declare function remapErrorStack(stack: string, filename: string, workflowCode: string): string;
10
+ //# sourceMappingURL=source-map.d.ts.map
@@ -0,0 +1,13 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ import type { CryptoKey } from '../encryption.js';
3
+ import type { WorkflowMetadata } from '../workflow/get-workflow-metadata.js';
4
+ import type { StepMetadata } from './get-step-metadata.js';
5
+ export type StepContext = {
6
+ stepMetadata: StepMetadata;
7
+ workflowMetadata: WorkflowMetadata;
8
+ ops: Promise<void>[];
9
+ closureVars?: Record<string, any>;
10
+ encryptionKey?: CryptoKey;
11
+ };
12
+ export declare const contextStorage: AsyncLocalStorage<StepContext>;
13
+ //# sourceMappingURL=context-storage.d.ts.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Returns the closure variables for the current step function.
3
+ * This is an internal function used by the SWC transform to access
4
+ * variables from the parent workflow scope.
5
+ *
6
+ * @internal
7
+ */
8
+ export declare function __private_getClosureVars(): Record<string, any>;
9
+ //# sourceMappingURL=get-closure-vars.d.ts.map
@@ -0,0 +1,42 @@
1
+ export interface StepMetadata {
2
+ /**
3
+ * The name of the step.
4
+ */
5
+ stepName: string;
6
+ /**
7
+ * Unique identifier for the currently executing step.
8
+ * Useful to use as part of an idempotency key for critical
9
+ * operations that must only be executed once (such as charging a customer).
10
+ *
11
+ * @remarks
12
+ *
13
+ * Only available inside a step function.
14
+ * Accessing this property in a workflow function will throw an error.
15
+ */
16
+ stepId: string;
17
+ /**
18
+ * Timestamp when the current step started.
19
+ *
20
+ * @remarks
21
+ *
22
+ * Only available inside a step function.
23
+ * Accessing this property in a workflow function will throw an error.
24
+ */
25
+ stepStartedAt: Date;
26
+ /**
27
+ * The number of times the current step has been executed. This will increase with each retry.
28
+ *
29
+ * @remarks
30
+ *
31
+ * Only available inside a step function.
32
+ * Accessing this property in a workflow function will throw an error.
33
+ */
34
+ attempt: number;
35
+ }
36
+ /**
37
+ * Returns metadata available in the current step function.
38
+ * It uses `AsyncLocalStorage` to store the context and
39
+ * retrieve it in the step function.
40
+ */
41
+ export declare function getStepMetadata(): StepMetadata;
42
+ //# sourceMappingURL=get-step-metadata.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { WorkflowMetadata } from '../workflow/get-workflow-metadata.js';
2
+ export type { WorkflowMetadata };
3
+ /**
4
+ * Returns metadata available in the current workflow run inside a step function.
5
+ */
6
+ export declare function getWorkflowMetadata(): WorkflowMetadata;
7
+ //# sourceMappingURL=get-workflow-metadata.d.ts.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The options for {@link getWritable}.
3
+ */
4
+ export interface WorkflowWritableStreamOptions {
5
+ /**
6
+ * An optional namespace to distinguish between multiple streams associated
7
+ * with the same workflow run.
8
+ */
9
+ namespace?: string;
10
+ }
11
+ /**
12
+ * Retrieves a writable stream that is associated with the current workflow.
13
+ *
14
+ * The writable stream is intended to be used within step functions to write
15
+ * data that can be read outside the workflow by using the readable method of getRun.
16
+ *
17
+ * @param options - Optional configuration for the writable stream
18
+ * @returns The writable stream associated with the current workflow run
19
+ * @throws Error if called outside a workflow or step function
20
+ */
21
+ export declare function getWritable<W = any>(options?: WorkflowWritableStreamOptions): WritableStream<W>;
22
+ //# sourceMappingURL=writable-stream.d.ts.map
@@ -0,0 +1,4 @@
1
+ import { type WorkflowOrchestratorContext } from './private.js';
2
+ import type { Serializable } from './schemas.js';
3
+ export declare function createUseStep(ctx: WorkflowOrchestratorContext): <Args extends Serializable[], Result>(stepName: string, closureVarsFn?: () => Record<string, Serializable>) => (this: unknown, ...args: Args) => Promise<Result>;
4
+ //# sourceMappingURL=step.d.ts.map