@hotmeshio/hotmesh 0.12.1 → 0.14.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 (202) hide show
  1. package/README.md +18 -22
  2. package/build/modules/enums.d.ts +60 -5
  3. package/build/modules/enums.js +62 -7
  4. package/build/modules/errors.d.ts +15 -2
  5. package/build/modules/errors.js +17 -1
  6. package/build/modules/storage.d.ts +1 -0
  7. package/build/modules/storage.js +2 -1
  8. package/build/package.json +8 -2
  9. package/build/services/activities/activity/context.d.ts +22 -0
  10. package/build/services/activities/activity/context.js +76 -0
  11. package/build/services/activities/activity/index.d.ts +116 -0
  12. package/build/services/activities/activity/index.js +299 -0
  13. package/build/services/activities/activity/mapping.d.ts +12 -0
  14. package/build/services/activities/activity/mapping.js +63 -0
  15. package/build/services/activities/activity/process.d.ts +28 -0
  16. package/build/services/activities/activity/process.js +100 -0
  17. package/build/services/activities/activity/protocol.d.ts +39 -0
  18. package/build/services/activities/activity/protocol.js +151 -0
  19. package/build/services/activities/activity/state.d.ts +40 -0
  20. package/build/services/activities/activity/state.js +143 -0
  21. package/build/services/activities/activity/transition.d.ts +23 -0
  22. package/build/services/activities/activity/transition.js +71 -0
  23. package/build/services/activities/activity/verify.d.ts +22 -0
  24. package/build/services/activities/activity/verify.js +85 -0
  25. package/build/services/activities/await.d.ts +1 -4
  26. package/build/services/activities/await.js +2 -36
  27. package/build/services/activities/cycle.d.ts +1 -11
  28. package/build/services/activities/cycle.js +3 -46
  29. package/build/services/activities/hook.d.ts +2 -11
  30. package/build/services/activities/hook.js +30 -50
  31. package/build/services/activities/interrupt.d.ts +2 -4
  32. package/build/services/activities/interrupt.js +4 -38
  33. package/build/services/activities/signal.d.ts +1 -11
  34. package/build/services/activities/signal.js +3 -48
  35. package/build/services/activities/trigger.d.ts +1 -3
  36. package/build/services/activities/trigger.js +0 -3
  37. package/build/services/activities/worker.d.ts +3 -6
  38. package/build/services/activities/worker.js +4 -40
  39. package/build/services/connector/factory.d.ts +6 -0
  40. package/build/services/connector/factory.js +24 -0
  41. package/build/services/dba/index.d.ts +14 -4
  42. package/build/services/dba/index.js +57 -18
  43. package/build/services/durable/activity.d.ts +30 -0
  44. package/build/services/durable/activity.js +46 -0
  45. package/build/services/durable/client.d.ts +26 -31
  46. package/build/services/durable/client.js +26 -31
  47. package/build/services/durable/connection.d.ts +13 -7
  48. package/build/services/durable/connection.js +13 -7
  49. package/build/services/durable/exporter.d.ts +2 -2
  50. package/build/services/durable/exporter.js +27 -12
  51. package/build/services/durable/handle.d.ts +59 -41
  52. package/build/services/durable/handle.js +61 -41
  53. package/build/services/durable/index.d.ts +152 -283
  54. package/build/services/durable/index.js +161 -289
  55. package/build/services/durable/interceptor.d.ts +43 -33
  56. package/build/services/durable/interceptor.js +59 -39
  57. package/build/services/durable/schemas/factory.d.ts +2 -3
  58. package/build/services/durable/schemas/factory.js +180 -30
  59. package/build/services/durable/telemetry.d.ts +80 -0
  60. package/build/services/durable/telemetry.js +137 -0
  61. package/build/services/durable/worker.d.ts +100 -21
  62. package/build/services/durable/worker.js +314 -60
  63. package/build/services/durable/workflow/all.d.ts +1 -1
  64. package/build/services/durable/workflow/all.js +1 -1
  65. package/build/services/durable/workflow/cancellationScope.d.ts +104 -0
  66. package/build/services/durable/workflow/cancellationScope.js +139 -0
  67. package/build/services/durable/workflow/common.d.ts +5 -4
  68. package/build/services/durable/workflow/common.js +6 -1
  69. package/build/services/durable/workflow/{waitFor.d.ts → condition.d.ts} +9 -8
  70. package/build/services/durable/workflow/{waitFor.js → condition.js} +44 -11
  71. package/build/services/durable/workflow/continueAsNew.d.ts +65 -0
  72. package/build/services/durable/workflow/continueAsNew.js +92 -0
  73. package/build/services/durable/workflow/didRun.d.ts +2 -2
  74. package/build/services/durable/workflow/didRun.js +4 -4
  75. package/build/services/durable/workflow/enrich.d.ts +5 -0
  76. package/build/services/durable/workflow/enrich.js +5 -0
  77. package/build/services/durable/workflow/entityMethods.d.ts +7 -0
  78. package/build/services/durable/workflow/entityMethods.js +7 -0
  79. package/build/services/durable/workflow/execHook.js +3 -3
  80. package/build/services/durable/workflow/execHookBatch.js +2 -2
  81. package/build/services/durable/workflow/{execChild.d.ts → executeChild.d.ts} +4 -40
  82. package/build/services/durable/workflow/{execChild.js → executeChild.js} +36 -45
  83. package/build/services/durable/workflow/hook.d.ts +1 -1
  84. package/build/services/durable/workflow/hook.js +4 -3
  85. package/build/services/durable/workflow/index.d.ts +45 -50
  86. package/build/services/durable/workflow/index.js +46 -51
  87. package/build/services/durable/workflow/interruption.d.ts +7 -6
  88. package/build/services/durable/workflow/interruption.js +11 -7
  89. package/build/services/durable/workflow/patched.d.ts +72 -0
  90. package/build/services/durable/workflow/patched.js +110 -0
  91. package/build/services/durable/workflow/proxyActivities.d.ts +7 -7
  92. package/build/services/durable/workflow/proxyActivities.js +51 -15
  93. package/build/services/durable/workflow/searchMethods.d.ts +7 -0
  94. package/build/services/durable/workflow/searchMethods.js +7 -0
  95. package/build/services/durable/workflow/signal.d.ts +4 -4
  96. package/build/services/durable/workflow/signal.js +4 -4
  97. package/build/services/durable/workflow/{sleepFor.d.ts → sleep.d.ts} +7 -7
  98. package/build/services/durable/workflow/{sleepFor.js → sleep.js} +39 -10
  99. package/build/services/durable/workflow/terminate.d.ts +55 -0
  100. package/build/services/durable/workflow/{interrupt.js → terminate.js} +21 -21
  101. package/build/services/durable/workflow/trace.js +2 -2
  102. package/build/services/durable/workflow/uuid4.d.ts +14 -0
  103. package/build/services/durable/workflow/uuid4.js +39 -0
  104. package/build/services/durable/workflow/{context.d.ts → workflowInfo.d.ts} +5 -5
  105. package/build/services/durable/workflow/{context.js → workflowInfo.js} +7 -7
  106. package/build/services/engine/compiler.d.ts +19 -0
  107. package/build/services/engine/compiler.js +20 -0
  108. package/build/services/engine/completion.d.ts +46 -0
  109. package/build/services/engine/completion.js +145 -0
  110. package/build/services/engine/dispatch.d.ts +24 -0
  111. package/build/services/engine/dispatch.js +98 -0
  112. package/build/services/engine/index.d.ts +49 -81
  113. package/build/services/engine/index.js +175 -573
  114. package/build/services/engine/init.d.ts +42 -0
  115. package/build/services/engine/init.js +74 -0
  116. package/build/services/engine/pubsub.d.ts +50 -0
  117. package/build/services/engine/pubsub.js +118 -0
  118. package/build/services/engine/reporting.d.ts +20 -0
  119. package/build/services/engine/reporting.js +38 -0
  120. package/build/services/engine/schema.d.ts +23 -0
  121. package/build/services/engine/schema.js +62 -0
  122. package/build/services/engine/signal.d.ts +57 -0
  123. package/build/services/engine/signal.js +117 -0
  124. package/build/services/engine/state.d.ts +35 -0
  125. package/build/services/engine/state.js +61 -0
  126. package/build/services/engine/version.d.ts +31 -0
  127. package/build/services/engine/version.js +73 -0
  128. package/build/services/hotmesh/deployment.d.ts +21 -0
  129. package/build/services/hotmesh/deployment.js +25 -0
  130. package/build/services/hotmesh/index.d.ts +142 -533
  131. package/build/services/hotmesh/index.js +223 -674
  132. package/build/services/hotmesh/init.d.ts +42 -0
  133. package/build/services/hotmesh/init.js +93 -0
  134. package/build/services/hotmesh/jobs.d.ts +67 -0
  135. package/build/services/hotmesh/jobs.js +99 -0
  136. package/build/services/hotmesh/pubsub.d.ts +38 -0
  137. package/build/services/hotmesh/pubsub.js +54 -0
  138. package/build/services/hotmesh/quorum.d.ts +30 -0
  139. package/build/services/hotmesh/quorum.js +62 -0
  140. package/build/services/hotmesh/validation.d.ts +6 -0
  141. package/build/services/hotmesh/validation.js +28 -0
  142. package/build/services/quorum/index.js +1 -0
  143. package/build/services/router/consumption/index.d.ts +11 -5
  144. package/build/services/router/consumption/index.js +24 -17
  145. package/build/services/router/error-handling/index.d.ts +2 -2
  146. package/build/services/router/error-handling/index.js +14 -14
  147. package/build/services/router/index.d.ts +1 -1
  148. package/build/services/router/index.js +2 -2
  149. package/build/services/serializer/index.d.ts +22 -0
  150. package/build/services/serializer/index.js +39 -1
  151. package/build/services/store/index.d.ts +1 -0
  152. package/build/services/store/providers/postgres/exporter-sql.d.ts +2 -2
  153. package/build/services/store/providers/postgres/exporter-sql.js +4 -4
  154. package/build/services/store/providers/postgres/kvtables.js +7 -6
  155. package/build/services/store/providers/postgres/kvtypes/hash/basic.js +67 -52
  156. package/build/services/store/providers/postgres/kvtypes/hash/jsonb.js +87 -72
  157. package/build/services/store/providers/postgres/kvtypes/hash/udata.js +106 -79
  158. package/build/services/store/providers/postgres/kvtypes/hash/utils.d.ts +16 -0
  159. package/build/services/store/providers/postgres/kvtypes/hash/utils.js +29 -16
  160. package/build/services/store/providers/postgres/postgres.d.ts +1 -0
  161. package/build/services/store/providers/postgres/postgres.js +14 -4
  162. package/build/services/stream/factory.d.ts +3 -1
  163. package/build/services/stream/factory.js +2 -2
  164. package/build/services/stream/index.d.ts +1 -0
  165. package/build/services/stream/providers/nats/nats.d.ts +1 -0
  166. package/build/services/stream/providers/nats/nats.js +1 -0
  167. package/build/services/stream/providers/postgres/credentials.d.ts +56 -0
  168. package/build/services/stream/providers/postgres/credentials.js +129 -0
  169. package/build/services/stream/providers/postgres/kvtables.js +18 -0
  170. package/build/services/stream/providers/postgres/messages.js +7 -7
  171. package/build/services/stream/providers/postgres/notifications.js +16 -2
  172. package/build/services/stream/providers/postgres/postgres.d.ts +7 -0
  173. package/build/services/stream/providers/postgres/postgres.js +35 -4
  174. package/build/services/stream/providers/postgres/procedures.d.ts +21 -0
  175. package/build/services/stream/providers/postgres/procedures.js +213 -0
  176. package/build/services/stream/providers/postgres/secured.d.ts +34 -0
  177. package/build/services/stream/providers/postgres/secured.js +146 -0
  178. package/build/services/stream/providers/postgres/stats.d.ts +1 -0
  179. package/build/services/stream/providers/postgres/stats.js +1 -0
  180. package/build/services/stream/registry.d.ts +1 -1
  181. package/build/services/stream/registry.js +5 -2
  182. package/build/services/telemetry/index.d.ts +10 -1
  183. package/build/services/telemetry/index.js +40 -7
  184. package/build/services/worker/credentials.d.ts +51 -0
  185. package/build/services/worker/credentials.js +87 -0
  186. package/build/services/worker/index.d.ts +2 -2
  187. package/build/services/worker/index.js +7 -6
  188. package/build/types/codec.d.ts +84 -0
  189. package/build/types/codec.js +2 -0
  190. package/build/types/dba.d.ts +39 -3
  191. package/build/types/durable.d.ts +123 -25
  192. package/build/types/error.d.ts +10 -0
  193. package/build/types/exporter.d.ts +1 -1
  194. package/build/types/hotmesh.d.ts +67 -4
  195. package/build/types/index.d.ts +2 -1
  196. package/build/types/provider.d.ts +2 -2
  197. package/build/types/quorum.d.ts +35 -1
  198. package/build/types/stream.d.ts +12 -6
  199. package/package.json +8 -2
  200. package/build/services/activities/activity.d.ts +0 -192
  201. package/build/services/activities/activity.js +0 -786
  202. package/build/services/durable/workflow/interrupt.d.ts +0 -55
package/README.md CHANGED
@@ -61,13 +61,11 @@ export async function notifyBackorder(itemId: string): Promise<void> {
61
61
  ```typescript
62
62
  // workflows.ts
63
63
  import { Durable } from '@hotmeshio/hotmesh';
64
- import * as activities from './activities';
64
+ import type * as activities from './activities';
65
65
 
66
66
  export async function orderWorkflow(itemId: string, qty: number) {
67
67
  const { checkInventory, reserveItem, notifyBackorder } =
68
- Durable.workflow.proxyActivities<typeof activities>({
69
- taskQueue: 'inventory-tasks'
70
- });
68
+ Durable.workflow.proxyActivities<typeof activities>();
71
69
 
72
70
  const available = await checkInventory(itemId);
73
71
 
@@ -80,20 +78,18 @@ export async function orderWorkflow(itemId: string, qty: number) {
80
78
  }
81
79
 
82
80
  // main.ts
81
+ import * as activities from './activities';
82
+
83
83
  const connection = {
84
84
  class: Postgres,
85
85
  options: { connectionString: 'postgresql://localhost:5432/mydb' }
86
86
  };
87
87
 
88
- await Durable.registerActivityWorker({
89
- connection,
90
- taskQueue: 'inventory-tasks'
91
- }, activities, 'inventory-activities');
92
-
93
88
  await Durable.Worker.create({
94
89
  connection,
95
90
  taskQueue: 'orders',
96
- workflow: orderWorkflow
91
+ workflow: orderWorkflow,
92
+ activities,
97
93
  });
98
94
 
99
95
  const client = new Durable.Client({ connection });
@@ -206,11 +202,11 @@ All snippets below run inside a workflow function (like `orderWorkflow` above).
206
202
  import { Durable } from '@hotmeshio/hotmesh';
207
203
  ```
208
204
 
209
- **Long-running workflows** — `sleepFor` is durable. The process can restart; the timer survives.
205
+ **Long-running workflows** — `sleep` is durable. The process can restart; the timer survives.
210
206
 
211
207
  ```typescript
212
208
  // sendFollowUp is a proxied activity from proxyActivities()
213
- await Durable.workflow.sleepFor('30 days');
209
+ await Durable.workflow.sleep('30 days');
214
210
  await sendFollowUp();
215
211
  ```
216
212
 
@@ -228,18 +224,18 @@ const [payment, inventory, shipment] = await Promise.all([
228
224
  **Child workflows** — compose workflows from other workflows.
229
225
 
230
226
  ```typescript
231
- const childHandle = await Durable.workflow.startChild(validateOrder, {
227
+ const result = await Durable.workflow.executeChild({
232
228
  args: [orderId],
233
229
  taskQueue: 'validation',
234
- workflowId: `validate-${orderId}`
230
+ workflowName: 'validateOrder',
231
+ workflowId: `validate-${orderId}`,
235
232
  });
236
- const validation = await childHandle.result();
237
233
  ```
238
234
 
239
235
  **Signals** — pause a workflow until an external event arrives.
240
236
 
241
237
  ```typescript
242
- const approval = await Durable.workflow.waitFor<{ approved: boolean }>('manager-approval');
238
+ const approval = await Durable.workflow.condition<{ approved: boolean }>('manager-approval');
243
239
  if (!approval.approved) return 'rejected';
244
240
  ```
245
241
 
@@ -248,10 +244,9 @@ if (!approval.approved) return 'rejected';
248
244
  Activities retry automatically on failure. Configure the policy per activity or per worker:
249
245
 
250
246
  ```typescript
251
- // Durable: per-activity retry policy
247
+ // Durable: per-activity retry policy (activities registered at Worker.create)
252
248
  const { reserveItem } = Durable.workflow.proxyActivities<typeof activities>({
253
- taskQueue: 'inventory-tasks',
254
- retryPolicy: {
249
+ retry: {
255
250
  maximumAttempts: 5,
256
251
  backoffCoefficient: 2,
257
252
  maximumInterval: '60s'
@@ -267,7 +262,7 @@ const hotMesh = await HotMesh.init({
267
262
  workers: [{
268
263
  topic: 'inventory.reserve',
269
264
  connection,
270
- retryPolicy: {
265
+ retry: {
271
266
  maximumAttempts: 5,
272
267
  backoffCoefficient: 2,
273
268
  maximumInterval: '60s'
@@ -290,7 +285,8 @@ SELECT
290
285
  j.key AS job_key,
291
286
  j.status AS semaphore,
292
287
  j.entity AS workflow,
293
- a.field AS attribute,
288
+ a.symbol AS attribute,
289
+ a.dimension AS dimension,
294
290
  a.value AS value,
295
291
  j.created_at,
296
292
  j.updated_at
@@ -300,7 +296,7 @@ FROM
300
296
  WHERE
301
297
  j.key = 'order-456'
302
298
  ORDER BY
303
- a.field;
299
+ a.symbol, a.dimension;
304
300
  ```
305
301
 
306
302
  What happened? Consult the database. What's still running? Query the semaphore. What failed? Read the row. The execution state isn't reconstructed from a log — it was committed transactionally as each step ran.
@@ -4,7 +4,51 @@ import { LogLevel } from '../types/logger';
4
4
  */
5
5
  export declare const HMSH_LOGLEVEL: LogLevel;
6
6
  /**
7
- * Determines the log level for telemetry. The default is 'info' which emits worker and trigger spans. 'debug' emits all spans.
7
+ * Controls which OpenTelemetry spans are emitted. Spans are only
8
+ * captured when an OTel SDK (TracerProvider + exporter) is registered
9
+ * before workers start. Without an SDK, all span calls are no-ops.
10
+ *
11
+ * ## Modes
12
+ *
13
+ * | Value | Durable workflows | YAML flows |
14
+ * |-------|-------------------|------------|
15
+ * | `'info'` (default) | `WORKFLOW/START`, `WORKFLOW/COMPLETE`, `WORKFLOW/ERROR`, `ACTIVITY/{name}` | trigger + worker spans |
16
+ * | `'debug'` | All `info` spans + `DISPATCH/{type}/{name}/{idx}`, `RETURN/{type}/{name}/{idx}` + engine internals | All activity types + all stream hops |
17
+ *
18
+ * ## Setup
19
+ *
20
+ * Register an OpenTelemetry SDK with a trace exporter **before**
21
+ * calling `Durable.Worker.create()`. Any OTLP-compatible backend
22
+ * works (Honeycomb, Jaeger, Grafana Tempo, etc.):
23
+ *
24
+ * ```typescript
25
+ * import { NodeSDK } from '@opentelemetry/sdk-node';
26
+ * import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
27
+ * import { resourceFromAttributes } from '@opentelemetry/resources';
28
+ * import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
29
+ *
30
+ * const sdk = new NodeSDK({
31
+ * resource: resourceFromAttributes({
32
+ * [ATTR_SERVICE_NAME]: 'my-service',
33
+ * }),
34
+ * traceExporter: new OTLPTraceExporter({
35
+ * url: 'https://api.honeycomb.io/v1/traces',
36
+ * headers: { 'x-honeycomb-team': process.env.HONEYCOMB_API_KEY },
37
+ * }),
38
+ * });
39
+ * sdk.start();
40
+ *
41
+ * // Then start workers — spans flow automatically
42
+ * await Durable.Worker.create({ ... });
43
+ * ```
44
+ *
45
+ * ```bash
46
+ * # Concise: workflow lifecycle + activity execution only
47
+ * HMSH_TELEMETRY=info node worker.js
48
+ *
49
+ * # Verbose: adds per-operation DISPATCH/RETURN spans + engine internals
50
+ * HMSH_TELEMETRY=debug node worker.js
51
+ * ```
8
52
  */
9
53
  export declare const HMSH_TELEMETRY: "debug" | "info";
10
54
  /**
@@ -34,6 +78,10 @@ export declare const HMSH_CODE_DURABLE_CHILD = 590;
34
78
  * This is thrown when a Durable has been interrupted by a proxyActivity call.
35
79
  */
36
80
  export declare const HMSH_CODE_DURABLE_PROXY = 591;
81
+ /**
82
+ * This is thrown when a Durable has been interrupted by a continueAsNew call.
83
+ */
84
+ export declare const HMSH_CODE_DURABLE_CONTINUE = 592;
37
85
  /**
38
86
  * This is thrown when a Durable has been interrupted by a waitForSignal call.
39
87
  */
@@ -83,9 +131,9 @@ export declare const HMSH_MAX_TIMEOUT_MS: number;
83
131
  export declare const HMSH_GRADUATED_INTERVAL_MS: number;
84
132
  /**
85
133
  * The maximum number of attempts to retry a Durable job before it is considered failed.
86
- * @default 3
134
+ * @default 50
87
135
  */
88
- export declare const HMSH_DURABLE_MAX_ATTEMPTS = 3;
136
+ export declare const HMSH_DURABLE_MAX_ATTEMPTS = 50;
89
137
  /**
90
138
  * The maximum interval to wait before retrying a Durable job.
91
139
  * @default 120s
@@ -93,9 +141,16 @@ export declare const HMSH_DURABLE_MAX_ATTEMPTS = 3;
93
141
  export declare const HMSH_DURABLE_MAX_INTERVAL = "120s";
94
142
  /**
95
143
  * The exponential backoff factor to apply to the interval between retries.
96
- * @default 10
144
+ * @default 5
145
+ */
146
+ export declare const HMSH_DURABLE_EXP_BACKOFF = 5;
147
+ /**
148
+ * The initial interval (in seconds) before the first retry attempt.
149
+ * The retry formula is: initialInterval * backoffCoefficient^retryCount,
150
+ * clamped by maximumInterval.
151
+ * @default 1
97
152
  */
98
- export declare const HMSH_DURABLE_EXP_BACKOFF = 10;
153
+ export declare const HMSH_DURABLE_INITIAL_INTERVAL = 1;
99
154
  export declare const HMSH_BLOCK_TIME_MS: number;
100
155
  export declare const HMSH_XCLAIM_DELAY_MS: number;
101
156
  export declare const HMSH_XCLAIM_COUNT: number;
@@ -1,13 +1,57 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HMSH_NOTIFY_PAYLOAD_LIMIT = exports.DEFAULT_TASK_QUEUE = exports.HMSH_GUID_SIZE = exports.HMSH_ROUTER_SCOUT_INTERVAL_MS = exports.HMSH_ROUTER_SCOUT_INTERVAL_SECONDS = exports.HMSH_SCOUT_INTERVAL_SECONDS = exports.HMSH_FIDELITY_SECONDS = exports.HMSH_EXPIRE_DURATION = exports.HMSH_XPENDING_COUNT = exports.HMSH_XCLAIM_COUNT = exports.HMSH_XCLAIM_DELAY_MS = exports.HMSH_BLOCK_TIME_MS = exports.HMSH_DURABLE_EXP_BACKOFF = exports.HMSH_DURABLE_MAX_INTERVAL = exports.HMSH_DURABLE_MAX_ATTEMPTS = exports.HMSH_GRADUATED_INTERVAL_MS = exports.HMSH_MAX_TIMEOUT_MS = exports.HMSH_POISON_MESSAGE_THRESHOLD = exports.HMSH_MAX_RETRIES = exports.MAX_DELAY = exports.MAX_STREAM_RETRIES = exports.INITIAL_STREAM_BACKOFF = exports.MAX_STREAM_BACKOFF = exports.HMSH_EXPIRE_JOB_SECONDS = exports.HMSH_OTT_WAIT_TIME = exports.HMSH_DEPLOYMENT_PAUSE = exports.HMSH_DEPLOYMENT_DELAY = exports.HMSH_ACTIVATION_MAX_RETRY = exports.HMSH_QUORUM_DELAY_MS = exports.HMSH_QUORUM_ROLLCALL_CYCLES = exports.HMSH_STATUS_UNKNOWN = exports.HMSH_CODE_DURABLE_RETRYABLE = exports.HMSH_CODE_DURABLE_FATAL = exports.HMSH_CODE_DURABLE_MAXED = exports.HMSH_CODE_DURABLE_TIMEOUT = exports.HMSH_CODE_DURABLE_WAIT = exports.HMSH_CODE_DURABLE_PROXY = exports.HMSH_CODE_DURABLE_CHILD = exports.HMSH_CODE_DURABLE_ALL = exports.HMSH_CODE_DURABLE_SLEEP = exports.HMSH_CODE_UNACKED = exports.HMSH_CODE_TIMEOUT = exports.HMSH_CODE_UNKNOWN = exports.HMSH_CODE_INTERRUPT = exports.HMSH_CODE_NOTFOUND = exports.HMSH_CODE_PENDING = exports.HMSH_CODE_SUCCESS = exports.HMSH_SIGNAL_EXPIRE = exports.HMSH_TELEMETRY = exports.HMSH_LOGLEVEL = void 0;
4
- exports.HMSH_ROUTER_POLL_FALLBACK_INTERVAL = void 0;
3
+ exports.HMSH_GUID_SIZE = exports.HMSH_ROUTER_SCOUT_INTERVAL_MS = exports.HMSH_ROUTER_SCOUT_INTERVAL_SECONDS = exports.HMSH_SCOUT_INTERVAL_SECONDS = exports.HMSH_FIDELITY_SECONDS = exports.HMSH_EXPIRE_DURATION = exports.HMSH_XPENDING_COUNT = exports.HMSH_XCLAIM_COUNT = exports.HMSH_XCLAIM_DELAY_MS = exports.HMSH_BLOCK_TIME_MS = exports.HMSH_DURABLE_INITIAL_INTERVAL = exports.HMSH_DURABLE_EXP_BACKOFF = exports.HMSH_DURABLE_MAX_INTERVAL = exports.HMSH_DURABLE_MAX_ATTEMPTS = exports.HMSH_GRADUATED_INTERVAL_MS = exports.HMSH_MAX_TIMEOUT_MS = exports.HMSH_POISON_MESSAGE_THRESHOLD = exports.HMSH_MAX_RETRIES = exports.MAX_DELAY = exports.MAX_STREAM_RETRIES = exports.INITIAL_STREAM_BACKOFF = exports.MAX_STREAM_BACKOFF = exports.HMSH_EXPIRE_JOB_SECONDS = exports.HMSH_OTT_WAIT_TIME = exports.HMSH_DEPLOYMENT_PAUSE = exports.HMSH_DEPLOYMENT_DELAY = exports.HMSH_ACTIVATION_MAX_RETRY = exports.HMSH_QUORUM_DELAY_MS = exports.HMSH_QUORUM_ROLLCALL_CYCLES = exports.HMSH_STATUS_UNKNOWN = exports.HMSH_CODE_DURABLE_RETRYABLE = exports.HMSH_CODE_DURABLE_FATAL = exports.HMSH_CODE_DURABLE_MAXED = exports.HMSH_CODE_DURABLE_TIMEOUT = exports.HMSH_CODE_DURABLE_WAIT = exports.HMSH_CODE_DURABLE_CONTINUE = exports.HMSH_CODE_DURABLE_PROXY = exports.HMSH_CODE_DURABLE_CHILD = exports.HMSH_CODE_DURABLE_ALL = exports.HMSH_CODE_DURABLE_SLEEP = exports.HMSH_CODE_UNACKED = exports.HMSH_CODE_TIMEOUT = exports.HMSH_CODE_UNKNOWN = exports.HMSH_CODE_INTERRUPT = exports.HMSH_CODE_NOTFOUND = exports.HMSH_CODE_PENDING = exports.HMSH_CODE_SUCCESS = exports.HMSH_SIGNAL_EXPIRE = exports.HMSH_TELEMETRY = exports.HMSH_LOGLEVEL = void 0;
4
+ exports.HMSH_ROUTER_POLL_FALLBACK_INTERVAL = exports.HMSH_NOTIFY_PAYLOAD_LIMIT = exports.DEFAULT_TASK_QUEUE = void 0;
5
5
  /**
6
6
  * Determines the log level for the application. The default is 'info'.
7
7
  */
8
8
  exports.HMSH_LOGLEVEL = process.env.HMSH_LOGLEVEL || 'info';
9
9
  /**
10
- * Determines the log level for telemetry. The default is 'info' which emits worker and trigger spans. 'debug' emits all spans.
10
+ * Controls which OpenTelemetry spans are emitted. Spans are only
11
+ * captured when an OTel SDK (TracerProvider + exporter) is registered
12
+ * before workers start. Without an SDK, all span calls are no-ops.
13
+ *
14
+ * ## Modes
15
+ *
16
+ * | Value | Durable workflows | YAML flows |
17
+ * |-------|-------------------|------------|
18
+ * | `'info'` (default) | `WORKFLOW/START`, `WORKFLOW/COMPLETE`, `WORKFLOW/ERROR`, `ACTIVITY/{name}` | trigger + worker spans |
19
+ * | `'debug'` | All `info` spans + `DISPATCH/{type}/{name}/{idx}`, `RETURN/{type}/{name}/{idx}` + engine internals | All activity types + all stream hops |
20
+ *
21
+ * ## Setup
22
+ *
23
+ * Register an OpenTelemetry SDK with a trace exporter **before**
24
+ * calling `Durable.Worker.create()`. Any OTLP-compatible backend
25
+ * works (Honeycomb, Jaeger, Grafana Tempo, etc.):
26
+ *
27
+ * ```typescript
28
+ * import { NodeSDK } from '@opentelemetry/sdk-node';
29
+ * import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
30
+ * import { resourceFromAttributes } from '@opentelemetry/resources';
31
+ * import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
32
+ *
33
+ * const sdk = new NodeSDK({
34
+ * resource: resourceFromAttributes({
35
+ * [ATTR_SERVICE_NAME]: 'my-service',
36
+ * }),
37
+ * traceExporter: new OTLPTraceExporter({
38
+ * url: 'https://api.honeycomb.io/v1/traces',
39
+ * headers: { 'x-honeycomb-team': process.env.HONEYCOMB_API_KEY },
40
+ * }),
41
+ * });
42
+ * sdk.start();
43
+ *
44
+ * // Then start workers — spans flow automatically
45
+ * await Durable.Worker.create({ ... });
46
+ * ```
47
+ *
48
+ * ```bash
49
+ * # Concise: workflow lifecycle + activity execution only
50
+ * HMSH_TELEMETRY=info node worker.js
51
+ *
52
+ * # Verbose: adds per-operation DISPATCH/RETURN spans + engine internals
53
+ * HMSH_TELEMETRY=debug node worker.js
54
+ * ```
11
55
  */
12
56
  exports.HMSH_TELEMETRY = process.env.HMSH_TELEMETRY || 'info';
13
57
  /**
@@ -39,6 +83,10 @@ exports.HMSH_CODE_DURABLE_CHILD = 590;
39
83
  * This is thrown when a Durable has been interrupted by a proxyActivity call.
40
84
  */
41
85
  exports.HMSH_CODE_DURABLE_PROXY = 591;
86
+ /**
87
+ * This is thrown when a Durable has been interrupted by a continueAsNew call.
88
+ */
89
+ exports.HMSH_CODE_DURABLE_CONTINUE = 592;
42
90
  /**
43
91
  * This is thrown when a Durable has been interrupted by a waitForSignal call.
44
92
  */
@@ -94,9 +142,9 @@ exports.HMSH_GRADUATED_INTERVAL_MS = parseInt(process.env.HMSH_GRADUATED_INTERVA
94
142
  // DURABLE
95
143
  /**
96
144
  * The maximum number of attempts to retry a Durable job before it is considered failed.
97
- * @default 3
145
+ * @default 50
98
146
  */
99
- exports.HMSH_DURABLE_MAX_ATTEMPTS = 3;
147
+ exports.HMSH_DURABLE_MAX_ATTEMPTS = 50;
100
148
  /**
101
149
  * The maximum interval to wait before retrying a Durable job.
102
150
  * @default 120s
@@ -104,9 +152,16 @@ exports.HMSH_DURABLE_MAX_ATTEMPTS = 3;
104
152
  exports.HMSH_DURABLE_MAX_INTERVAL = '120s';
105
153
  /**
106
154
  * The exponential backoff factor to apply to the interval between retries.
107
- * @default 10
155
+ * @default 5
156
+ */
157
+ exports.HMSH_DURABLE_EXP_BACKOFF = 5;
158
+ /**
159
+ * The initial interval (in seconds) before the first retry attempt.
160
+ * The retry formula is: initialInterval * backoffCoefficient^retryCount,
161
+ * clamped by maximumInterval.
162
+ * @default 1
108
163
  */
109
- exports.HMSH_DURABLE_EXP_BACKOFF = 10;
164
+ exports.HMSH_DURABLE_INITIAL_INTERVAL = 1;
110
165
  const BASE_BLOCK_DURATION = 10000;
111
166
  const TEST_BLOCK_DURATION = 1000;
112
167
  exports.HMSH_BLOCK_TIME_MS = process.env.HMSH_BLOCK_TIME_MS
@@ -1,6 +1,6 @@
1
1
  import { ActivityDuplex } from '../types/activity';
2
2
  import { CollationFaultType, CollationStage } from '../types/collator';
3
- import { DurableChildErrorType, DurableProxyErrorType, DurableSleepErrorType, DurableWaitForAllErrorType, DurableWaitForErrorType } from '../types/error';
3
+ import { DurableChildErrorType, DurableContinueAsNewErrorType, DurableProxyErrorType, DurableSleepErrorType, DurableWaitForAllErrorType, DurableWaitForErrorType } from '../types/error';
4
4
  declare class GetStateError extends Error {
5
5
  jobId: string;
6
6
  code: number;
@@ -21,14 +21,17 @@ declare class DurableWaitForError extends Error {
21
21
  declare class DurableProxyError extends Error {
22
22
  activityName: string;
23
23
  arguments: string[];
24
+ headers?: Record<string, any>;
24
25
  backoffCoefficient: number;
25
26
  code: number;
26
27
  index: number;
28
+ initialInterval: number;
27
29
  maximumAttempts: number;
28
30
  maximumInterval: number;
29
31
  originJobId: string | null;
30
32
  parentWorkflowId: string;
31
33
  expire: number;
34
+ startToCloseTimeout: number;
32
35
  workflowDimension: string;
33
36
  workflowId: string;
34
37
  workflowTopic: string;
@@ -42,6 +45,7 @@ declare class DurableChildError extends Error {
42
45
  backoffCoefficient: number;
43
46
  code: number;
44
47
  expire: number;
48
+ initialInterval: number;
45
49
  persistent: boolean;
46
50
  signalIn: boolean;
47
51
  workflowDimension: string;
@@ -79,6 +83,15 @@ declare class DurableSleepError extends Error {
79
83
  type: string;
80
84
  constructor(params: DurableSleepErrorType);
81
85
  }
86
+ declare class DurableContinueAsNewError extends Error {
87
+ workflowId: string;
88
+ code: number;
89
+ arguments: any[];
90
+ index: number;
91
+ workflowDimension: string;
92
+ type: string;
93
+ constructor(params: DurableContinueAsNewErrorType);
94
+ }
82
95
  declare class DurableTimeoutError extends Error {
83
96
  code: number;
84
97
  type: string;
@@ -133,4 +146,4 @@ declare class CollationError extends Error {
133
146
  fault: CollationFaultType;
134
147
  constructor(status: number, leg: ActivityDuplex, stage: CollationStage, fault?: CollationFaultType);
135
148
  }
136
- export { CollationError, DurableChildError, DurableFatalError, DurableMaxedError, DurableProxyError, DurableRetryError, DurableSleepError, DurableTimeoutError, DurableWaitForAllError, DurableWaitForError, DuplicateJobError, ExecActivityError, GenerationalError, GetStateError, InactiveJobError, MapDataError, RegisterTimeoutError, SetStateError, };
149
+ export { CollationError, DurableChildError, DurableContinueAsNewError, DurableFatalError, DurableMaxedError, DurableProxyError, DurableRetryError, DurableSleepError, DurableTimeoutError, DurableWaitForAllError, DurableWaitForError, DuplicateJobError, ExecActivityError, GenerationalError, GetStateError, InactiveJobError, MapDataError, RegisterTimeoutError, SetStateError, };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SetStateError = exports.RegisterTimeoutError = exports.MapDataError = exports.InactiveJobError = exports.GetStateError = exports.GenerationalError = exports.ExecActivityError = exports.DuplicateJobError = exports.DurableWaitForError = exports.DurableWaitForAllError = exports.DurableTimeoutError = exports.DurableSleepError = exports.DurableRetryError = exports.DurableProxyError = exports.DurableMaxedError = exports.DurableFatalError = exports.DurableChildError = exports.CollationError = void 0;
3
+ exports.SetStateError = exports.RegisterTimeoutError = exports.MapDataError = exports.InactiveJobError = exports.GetStateError = exports.GenerationalError = exports.ExecActivityError = exports.DuplicateJobError = exports.DurableWaitForError = exports.DurableWaitForAllError = exports.DurableTimeoutError = exports.DurableSleepError = exports.DurableRetryError = exports.DurableProxyError = exports.DurableMaxedError = exports.DurableFatalError = exports.DurableContinueAsNewError = exports.DurableChildError = exports.CollationError = void 0;
4
4
  const enums_1 = require("./enums");
5
5
  class GetStateError extends Error {
6
6
  constructor(jobId) {
@@ -32,6 +32,7 @@ class DurableProxyError extends Error {
32
32
  super(`ProxyActivity Interruption`);
33
33
  this.type = 'DurableProxyError';
34
34
  this.arguments = params.arguments;
35
+ this.headers = params.headers;
35
36
  this.workflowId = params.workflowId;
36
37
  this.workflowTopic = params.workflowTopic;
37
38
  this.parentWorkflowId = params.parentWorkflowId;
@@ -41,8 +42,10 @@ class DurableProxyError extends Error {
41
42
  this.activityName = params.activityName;
42
43
  this.workflowDimension = params.workflowDimension;
43
44
  this.backoffCoefficient = params.backoffCoefficient;
45
+ this.initialInterval = params.initialInterval;
44
46
  this.maximumAttempts = params.maximumAttempts;
45
47
  this.maximumInterval = params.maximumInterval;
48
+ this.startToCloseTimeout = params.startToCloseTimeout;
46
49
  this.code = enums_1.HMSH_CODE_DURABLE_PROXY;
47
50
  }
48
51
  }
@@ -67,6 +70,7 @@ class DurableChildError extends Error {
67
70
  this.code = enums_1.HMSH_CODE_DURABLE_CHILD;
68
71
  this.await = params.await;
69
72
  this.backoffCoefficient = params.backoffCoefficient;
73
+ this.initialInterval = params.initialInterval;
70
74
  this.maximumAttempts = params.maximumAttempts;
71
75
  this.maximumInterval = params.maximumInterval;
72
76
  }
@@ -100,6 +104,18 @@ class DurableSleepError extends Error {
100
104
  }
101
105
  }
102
106
  exports.DurableSleepError = DurableSleepError;
107
+ class DurableContinueAsNewError extends Error {
108
+ constructor(params) {
109
+ super(`ContinueAsNew Interruption`);
110
+ this.type = 'DurableContinueAsNewError';
111
+ this.arguments = params.arguments;
112
+ this.workflowId = params.workflowId;
113
+ this.index = params.index;
114
+ this.workflowDimension = params.workflowDimension;
115
+ this.code = enums_1.HMSH_CODE_DURABLE_CONTINUE;
116
+ }
117
+ }
118
+ exports.DurableContinueAsNewError = DurableContinueAsNewError;
103
119
  class DurableTimeoutError extends Error {
104
120
  constructor(message, stack) {
105
121
  super(message);
@@ -1,3 +1,4 @@
1
1
  /// <reference types="node" />
2
2
  import { AsyncLocalStorage } from 'async_hooks';
3
3
  export declare const asyncLocalStorage: AsyncLocalStorage<Map<string, any>>;
4
+ export declare const activityAsyncLocalStorage: AsyncLocalStorage<Map<string, any>>;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asyncLocalStorage = void 0;
3
+ exports.activityAsyncLocalStorage = exports.asyncLocalStorage = void 0;
4
4
  const async_hooks_1 = require("async_hooks");
5
5
  exports.asyncLocalStorage = new async_hooks_1.AsyncLocalStorage();
6
+ exports.activityAsyncLocalStorage = new async_hooks_1.AsyncLocalStorage();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.12.1",
4
- "description": "Permanent-Memory Workflows & AI Agents",
3
+ "version": "0.14.0",
4
+ "description": "Durable Workflow",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
7
7
  "homepage": "https://github.com/hotmeshio/sdk-typescript/",
@@ -33,7 +33,9 @@
33
33
  "test:durable:fatal": "vitest run tests/durable/fatal",
34
34
  "test:durable:goodbye": "HMSH_LOGLEVEL=debug vitest run tests/durable/goodbye/postgres.test.ts",
35
35
  "test:durable:interceptor": "HMSH_LOGLEVEL=info vitest run tests/durable/interceptor/postgres.test.ts",
36
+ "test:durable:metadata": "HMSH_LOGLEVEL=info vitest run tests/durable/interceptor/postgres.test.ts -t 'argumentMetadata'",
36
37
  "test:durable:entity": "HMSH_LOGLEVEL=debug vitest run tests/durable/entity/postgres.test.ts",
38
+ "test:durable:config": "HMSH_LOGLEVEL=debug vitest run tests/durable/config-parity/postgres.test.ts",
37
39
  "test:durable:agent": "HMSH_LOGLEVEL=debug vitest run tests/durable/agent/postgres.test.ts",
38
40
  "test:durable:hello": "HMSH_TELEMETRY=debug HMSH_LOGLEVEL=info vitest run tests/durable/helloworld/postgres.test.ts",
39
41
  "test:durable:hook": "vitest run tests/durable/hook/postgres.test.ts",
@@ -48,11 +50,15 @@
48
50
  "test:durable:unknown": "vitest run tests/durable/unknown/postgres.test.ts",
49
51
  "test:durable:exporter": "HMSH_LOGLEVEL=info vitest run tests/durable/exporter",
50
52
  "test:durable:exporter:debug": "EXPORT_DEBUG=1 HMSH_LOGLEVEL=error vitest run tests/durable/basic/postgres.test.ts",
53
+ "test:durable:codec": "vitest run tests/durable/codec/postgres.test.ts",
54
+ "test:durable:credentials": "vitest run tests/durable/credentials/postgres.test.ts",
51
55
  "test:dba": "vitest run tests/dba",
52
56
  "test:cycle": "vitest run tests/functional/cycle",
53
57
  "test:functional": "vitest run tests/functional",
54
58
  "test:emit": "vitest run tests/functional/emit",
55
59
  "test:pending": "vitest run tests/functional/pending/index.test.ts",
60
+ "test:codec": "vitest run tests/functional/codec/postgres.test.ts",
61
+ "test:credentials": "vitest run tests/functional/credentials/postgres.test.ts",
56
62
  "test:hmsh": "vitest run tests/functional/postgres.test.ts",
57
63
  "test:hook": "vitest run tests/functional/hook/postgres.test.ts",
58
64
  "test:interrupt": "vitest run tests/functional/interrupt/postgres.test.ts",
@@ -0,0 +1,22 @@
1
+ import { ActivityData, ActivityMetadata, ActivityType } from '../../../types/activity';
2
+ import { JobState } from '../../../types/job';
3
+ import { StringAnyType } from '../../../types/serializer';
4
+ import { StreamStatus } from '../../../types/stream';
5
+ interface ContextInstance {
6
+ config: ActivityType;
7
+ context: JobState;
8
+ metadata: ActivityMetadata;
9
+ data: ActivityData;
10
+ status: StreamStatus;
11
+ adjacentIndex: number;
12
+ }
13
+ export declare function initSelf(instance: ContextInstance, context: StringAnyType): JobState;
14
+ export declare function initPolicies(instance: ContextInstance, context: JobState): void;
15
+ export declare function initDimensionalAddress(instance: ContextInstance, dad: string): void;
16
+ export declare function assertGenerationalId(jobGID: string, msgGID: string, context: JobState): void;
17
+ export declare function resolveDad(instance: ContextInstance): string;
18
+ export declare function resolveAdjacentDad(instance: ContextInstance): string;
19
+ export declare function bindActivityData(instance: ContextInstance, type: 'output' | 'hook'): void;
20
+ export declare function bindActivityError(instance: ContextInstance, data: Record<string, unknown>): void;
21
+ export declare function bindJobError(instance: ContextInstance, data: Record<string, unknown>): void;
22
+ export {};
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bindJobError = exports.bindActivityError = exports.bindActivityData = exports.resolveAdjacentDad = exports.resolveDad = exports.assertGenerationalId = exports.initDimensionalAddress = exports.initPolicies = exports.initSelf = void 0;
4
+ const enums_1 = require("../../../modules/enums");
5
+ const errors_1 = require("../../../modules/errors");
6
+ const utils_1 = require("../../../modules/utils");
7
+ const collator_1 = require("../../collator");
8
+ const pipe_1 = require("../../pipe");
9
+ function initSelf(instance, context) {
10
+ const activityId = instance.metadata.aid;
11
+ if (!context[activityId]) {
12
+ context[activityId] = {};
13
+ }
14
+ const self = context[activityId];
15
+ if (!self.output)
16
+ self.output = {};
17
+ if (!self.input)
18
+ self.input = {};
19
+ if (!self.hook)
20
+ self.hook = {};
21
+ if (!self.output.metadata)
22
+ self.output.metadata = {};
23
+ self.output.metadata.au = (0, utils_1.formatISODate)(new Date());
24
+ context['$self'] = self;
25
+ context['$job'] = context; //NEVER call STRINGIFY! (now circular)
26
+ return context;
27
+ }
28
+ exports.initSelf = initSelf;
29
+ function initPolicies(instance, context) {
30
+ const expire = pipe_1.Pipe.resolve(instance.config.expire ?? enums_1.HMSH_EXPIRE_DURATION, context);
31
+ context.metadata.expire = expire;
32
+ if (instance.config.persistent != undefined) {
33
+ const persistent = pipe_1.Pipe.resolve(instance.config.persistent ?? false, context);
34
+ context.metadata.persistent = persistent;
35
+ }
36
+ }
37
+ exports.initPolicies = initPolicies;
38
+ function initDimensionalAddress(instance, dad) {
39
+ instance.metadata.dad = dad;
40
+ }
41
+ exports.initDimensionalAddress = initDimensionalAddress;
42
+ function assertGenerationalId(jobGID, msgGID, context) {
43
+ if (msgGID !== jobGID) {
44
+ throw new errors_1.GenerationalError(jobGID, msgGID, context?.metadata?.jid ?? '', context?.metadata?.aid ?? '', context?.metadata?.dad ?? '');
45
+ }
46
+ }
47
+ exports.assertGenerationalId = assertGenerationalId;
48
+ function resolveDad(instance) {
49
+ let dad = instance.metadata.dad;
50
+ if (instance.adjacentIndex > 0) {
51
+ dad = `${dad.substring(0, dad.lastIndexOf(','))},${instance.adjacentIndex}`;
52
+ }
53
+ return dad;
54
+ }
55
+ exports.resolveDad = resolveDad;
56
+ function resolveAdjacentDad(instance) {
57
+ return `${resolveDad(instance)}${collator_1.CollatorService.getDimensionalSeed(0)}`;
58
+ }
59
+ exports.resolveAdjacentDad = resolveAdjacentDad;
60
+ function bindActivityData(instance, type) {
61
+ instance.context[instance.metadata.aid][type].data = instance.data;
62
+ }
63
+ exports.bindActivityData = bindActivityData;
64
+ function bindActivityError(instance, data) {
65
+ const md = instance.context[instance.metadata.aid].output.metadata;
66
+ md.err = JSON.stringify(instance.data);
67
+ md.$error = { ...data, is_stream_error: true };
68
+ }
69
+ exports.bindActivityError = bindActivityError;
70
+ function bindJobError(instance, data) {
71
+ instance.context.metadata.err = JSON.stringify({
72
+ ...data,
73
+ is_stream_error: true,
74
+ });
75
+ }
76
+ exports.bindJobError = bindJobError;