@fluidgrids/workflows 2026.1028.1 → 2026.1029.1

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 (122) hide show
  1. package/README.md +72 -10
  2. package/dist/{activation-DnhG7SmF.d.ts → activation-BnVQMv9y.d.ts} +1 -1
  3. package/dist/{activation-BBh1p82z.d.cts → activation-CESehfYi.d.cts} +1 -1
  4. package/dist/{chunk-XB53G2DK.js → chunk-25BKWR2O.js} +1 -1
  5. package/dist/{chunk-CBL5JSCC.cjs → chunk-2B37XAFQ.cjs} +44 -8
  6. package/dist/{chunk-DJYMDLV5.js → chunk-2DDULZFM.js} +93 -1
  7. package/dist/{chunk-623FVQSN.cjs → chunk-3FIDHONL.cjs} +104 -0
  8. package/dist/chunk-6QPOJZT6.cjs +1180 -0
  9. package/dist/chunk-7ILGCUI6.js +154 -0
  10. package/dist/chunk-A2OHX3UQ.js +1156 -0
  11. package/dist/{chunk-VOKMAAJP.js → chunk-A36CCOWS.js} +188 -19
  12. package/dist/{chunk-FMSW2HDF.cjs → chunk-ELL2RBML.cjs} +0 -14
  13. package/dist/{chunk-JD2VQIDZ.cjs → chunk-EWYADREB.cjs} +2 -2
  14. package/dist/{chunk-5HDSBTBX.js → chunk-FQSJI5NV.js} +1 -1
  15. package/dist/{chunk-ABFZWYHT.js → chunk-FWBRQWRX.js} +156 -48
  16. package/dist/{chunk-PZCVF76Q.cjs → chunk-I47EENR4.cjs} +209 -40
  17. package/dist/chunk-J3PYFGKA.cjs +166 -0
  18. package/dist/{chunk-C5OLWZ42.js → chunk-KXJDRQ6G.js} +1 -13
  19. package/dist/chunk-M272AHEX.js +25 -0
  20. package/dist/{chunk-3FOTFQ3J.js → chunk-MJ5TGYVG.js} +333 -65
  21. package/dist/{chunk-57MSZ24T.cjs → chunk-NXFBVDOI.cjs} +3 -3
  22. package/dist/{chunk-PDHLTDZB.js → chunk-OIX4O6UR.js} +38 -2
  23. package/dist/{chunk-HR3BN4C4.cjs → chunk-OKX3FYIM.cjs} +3 -3
  24. package/dist/{chunk-CSNWNFKU.cjs → chunk-OMY3CKUZ.cjs} +404 -136
  25. package/dist/chunk-PWIUEWC3.js +81 -0
  26. package/dist/chunk-Q4MWQNJK.cjs +28 -0
  27. package/dist/{chunk-P6TA5EZT.cjs → chunk-RUQIMTN5.cjs} +171 -57
  28. package/dist/{chunk-IISBRUWJ.js → chunk-WXXNCHUY.js} +1 -1
  29. package/dist/chunk-YHBVMOMK.cjs +87 -0
  30. package/dist/codegen/index.d.cts +2 -2
  31. package/dist/codegen/index.d.ts +2 -2
  32. package/dist/collect-BTHjQaSp.d.ts +86 -0
  33. package/dist/collect-CSyOg5XC.d.cts +86 -0
  34. package/dist/{file-yuPCFU5b.d.ts → file-cgL9l9l8.d.cts} +765 -14
  35. package/dist/{file-BOoHZgoQ.d.cts → file-olQudcx5.d.ts} +765 -14
  36. package/dist/history/index.cjs +198 -86
  37. package/dist/history/index.d.cts +49 -10
  38. package/dist/history/index.d.ts +49 -10
  39. package/dist/history/index.js +49 -4
  40. package/dist/index.cjs +64 -51
  41. package/dist/index.d.cts +9 -53
  42. package/dist/index.d.ts +9 -53
  43. package/dist/index.js +5 -4
  44. package/dist/ir/index.cjs +24 -3
  45. package/dist/ir/index.d.cts +43 -4
  46. package/dist/ir/index.d.ts +43 -4
  47. package/dist/ir/index.js +24 -3
  48. package/dist/{lower-BuSvAFqi.d.cts → lower-3S6PsqjJ.d.cts} +41 -7
  49. package/dist/{lower-C_Qv_34S.d.ts → lower-DmZpQ8hJ.d.ts} +41 -7
  50. package/dist/lower-types-DQNBfWQn.d.cts +37 -0
  51. package/dist/lower-types-DQNBfWQn.d.ts +37 -0
  52. package/dist/{manifest-C8N6HDYl.d.ts → manifest-BJjrQt77.d.ts} +1 -1
  53. package/dist/{manifest-0OLw0i7k.d.cts → manifest-gRI2Q5Fj.d.cts} +1 -1
  54. package/dist/node-evaluator-SOADN23V.js +14 -0
  55. package/dist/node-evaluator-YGDEXK4U.cjs +24 -0
  56. package/dist/quickjs/index.cjs +25 -24
  57. package/dist/quickjs/index.d.cts +7 -7
  58. package/dist/quickjs/index.d.ts +7 -7
  59. package/dist/quickjs/index.js +8 -7
  60. package/dist/roundtrip/index.cjs +245 -43
  61. package/dist/roundtrip/index.d.cts +88 -11
  62. package/dist/roundtrip/index.d.ts +88 -11
  63. package/dist/roundtrip/index.js +172 -8
  64. package/dist/runtime/index.cjs +21 -20
  65. package/dist/runtime/index.d.cts +49 -7
  66. package/dist/runtime/index.d.ts +49 -7
  67. package/dist/runtime/index.js +8 -7
  68. package/dist/testing/index.cjs +514 -74
  69. package/dist/testing/index.d.cts +128 -11
  70. package/dist/testing/index.d.ts +128 -11
  71. package/dist/testing/index.js +480 -42
  72. package/dist/{types-BGoPzgcl.d.ts → types-Bb2wRnJ5.d.cts} +20 -1
  73. package/dist/{types-BGoPzgcl.d.cts → types-Bb2wRnJ5.d.ts} +20 -1
  74. package/dist/{types-DV-HX_Gt.d.ts → types-CQKOhPTa.d.cts} +122 -14
  75. package/dist/{types-CpBBjaGX.d.cts → types-CnIOinoz.d.ts} +122 -14
  76. package/dist/{workflow-Bpr3vnA_.d.ts → workflow-8uRU9rhL.d.ts} +2 -2
  77. package/dist/{workflow-FXUkpIBc.d.cts → workflow-CZOXUlQ5.d.cts} +2 -2
  78. package/dist/{workflow-J-yYixny.d.cts → workflow-DWTPHFbt.d.ts} +124 -12
  79. package/dist/{workflow-C2a05WUJ.d.ts → workflow-O6e64ZcG.d.cts} +124 -12
  80. package/fixtures/histories/auto-upgrade-patched.history.json +276 -0
  81. package/fixtures/histories/benign-failure.history.json +146 -0
  82. package/fixtures/histories/cancel-activity-try-cancel.history.json +150 -0
  83. package/fixtures/histories/child-cancel-wait-requested.history.json +217 -0
  84. package/fixtures/histories/child-options-roundtrip.history.json +192 -0
  85. package/fixtures/histories/continue-as-new-last-result.history.json +86 -0
  86. package/fixtures/histories/continue-as-new-options.history.json +99 -0
  87. package/fixtures/histories/continue-as-new-r1-long-task-queue.history.json +78 -0
  88. package/fixtures/histories/continue-as-new-r1-retry-options.history.json +83 -0
  89. package/fixtures/histories/execution-timeout-chain.history.json +98 -0
  90. package/fixtures/histories/external-cancel-resolved.history.json +123 -0
  91. package/fixtures/histories/external-cancel-unknown-target.history.json +127 -0
  92. package/fixtures/histories/failure-error-types-fails-run.history.json +144 -0
  93. package/fixtures/histories/handler-drain-warn.history.json +222 -0
  94. package/fixtures/histories/heartbeat-details-on-retry.history.json +145 -0
  95. package/fixtures/histories/local-activity-abandoned-at-completion.history.json +73 -0
  96. package/fixtures/histories/local-activity-cancelled-in-scope.history.json +118 -0
  97. package/fixtures/histories/local-activity-completed.history.json +157 -0
  98. package/fixtures/histories/local-activity-failed.history.json +93 -0
  99. package/fixtures/histories/local-activity-retry-in-task.history.json +88 -0
  100. package/fixtures/histories/run-retry-last-failure.history.json +90 -0
  101. package/fixtures/histories/run-timeout.history.json +159 -0
  102. package/fixtures/histories/schedule-to-start-timeout.history.json +132 -0
  103. package/fixtures/histories/start-delay-signal-ends-delay.history.json +155 -0
  104. package/fixtures/histories/typeerror-task-retry-100.history.json +137 -0
  105. package/package.json +1 -1
  106. package/schema/history-file.schema.json +283 -2
  107. package/schema/ir-v2.schema.json +45 -0
  108. package/schema/run-event.schema.json +264 -2
  109. package/schema/workflow-command.schema.json +178 -1
  110. package/schema/workflow-task.schema.json +392 -4
  111. package/dist/assemble-BLqQ8lSu.d.cts +0 -39
  112. package/dist/assemble-DWgaXHd-.d.ts +0 -39
  113. package/dist/chunk-2DP2Y6EU.cjs +0 -832
  114. package/dist/chunk-2J6TF7YI.cjs +0 -86
  115. package/dist/chunk-7NQ37GZU.js +0 -73
  116. package/dist/chunk-BO6OVILK.js +0 -79
  117. package/dist/chunk-FQIHX7YI.cjs +0 -80
  118. package/dist/chunk-H7KEVW2M.js +0 -816
  119. package/dist/lower-types-nofRXw9c.d.cts +0 -15
  120. package/dist/lower-types-nofRXw9c.d.ts +0 -15
  121. package/dist/node-evaluator-CJNP4GHX.js +0 -12
  122. package/dist/node-evaluator-DMKPKUWA.cjs +0 -22
package/README.md CHANGED
@@ -226,9 +226,52 @@ export const refundOrder = workflow(
226
226
  `ctx.signalRun` / `ctx.signalParent` / `ctx.getRunHandle`, `ctx.sideEffect`,
227
227
  `ctx.patched` / `ctx.deprecatePatch`, `ctx.now` / `ctx.random` / `ctx.uuid`,
228
228
  `ctx.setCurrentDetails`, cancellation scopes, `ctx.saga()`, and the parity
229
- commands `ctx.upsertContext` and `ctx.continueAsNew`. User activities, local
230
- activities, custom queries, updates and search attributes are Phase C and fail
231
- the workflow task with `UNSUPPORTED_COMMAND`.
229
+ commands `ctx.upsertContext` and `ctx.continueAsNew`. User activities, user
230
+ functions as local activities, custom queries, updates and search attributes
231
+ are Phase C and fail the workflow task with `UNSUPPORTED_COMMAND`.
232
+ - Since R2 (the runtime release `RUNTIME_RELEASE = 2`):
233
+ `ctx.localActivity(op, { args, retry, startToCloseTimeout, summary })` runs a
234
+ short node call inside the workflow task (at most 30 s; the `ctx.run`
235
+ allow-list applies). The task returns `outcome: 'localActivityRequested'`
236
+ with the calls it waits for; the worker runs them and runs the same task
237
+ again with `localActivityResults`, and the task records one
238
+ `RECORD_LOCAL_ACTIVITY` marker per call. A retryable failure is requested
239
+ again with the next `attempt` and its `backoffMs`; a replay returns the
240
+ recorded outcome and never runs the call again. A local activity the first
241
+ execution dropped (its scope was cancelled in the same activation, or the
242
+ run completed without awaiting it) records nothing and replays the same way;
243
+ one that would have been requested but has no marker is a non-determinism.
244
+ - Run handles take a workflow id: `ctx.getRunHandle({ workflowKey, workflowId,
245
+ firstRunId? })`, `ctx.signalRun(target, …)` and `ctx.cancelRun(target)`.
246
+ - `ctx.onSignal(signal, { unfinishedPolicy: 'ABANDON' }, fn)`; a workflow that
247
+ finishes while a `WARN_AND_ABANDON` handler still runs logs one warning and
248
+ reports `unfinishedHandlers` in the task result (never on replay).
249
+ - `ctx.info.lastResult`, `lastFailure`, `workflowId`, `runAttempt`, `summary`,
250
+ `details`, `context` (the memo), the timeouts, `retry`, `priority` and
251
+ `versioningBehavior` come from `WORKFLOW_STARTED`, so a replay sees what the
252
+ first execution saw; histories written before R2 fall back to the lease.
253
+ - `workflow(name, { versioningBehavior, retry, runTimeout, executionTimeout,
254
+ workflowTaskTimeout })` lowers to `config`; `lower()` writes the runtime
255
+ features a bundle uses to `code.features` (`localActivity`, `externalCancel`,
256
+ `childOptions`, `canOptions`, `autoUpgrade`, `runRetry`, `timeouts`) so the
257
+ service can refuse a push whose features its flags do not enable. The call
258
+ sites are read in every module of the project (helpers and vendored packages
259
+ included), and any use of the name `localActivity` counts. Each function's
260
+ settings are also written to `code.exports.workflows[fn].config`: the
261
+ service resolves run options per `workflowFn` from that table, so a
262
+ same-bundle child that runs on its parent's definition gets its own retry
263
+ and timeouts.
264
+ - The command feature gate (`commandFeatures`, `isWorkflowCommandEnabled(cmd,
265
+ features)`, `isReliefCommand`, `PHASE_B_CORE_FEATURES`,
266
+ `PHASE_B_PARITY_FEATURES`) is the one contract the service and the workers use
267
+ to enable parity commands. Every option the R1 runtime wrote stays in the
268
+ core set (`CORE_CHILD_OPTIONS`, `CORE_CAN_OPTIONS`), so a Phase B workflow
269
+ behaves the same with `fluidgrids.durable-parity` off; only the R2 options
270
+ (child `retry`, `versioningBehavior`, `idReusePolicy`, `idConflictPolicy`,
271
+ and a run-retry `continueAsNew` `retry`) need the flag. A continue-as-new
272
+ `retry` in the R1 activity shape (`retryDelay`, `maxRetries`) is still
273
+ written as R1 wrote it and has no effect; `continueAsNewRetryShape` tells
274
+ the shapes apart, and the service must ignore the legacy one; `rolloutBucket(key)` (FNV-1a 32 over UTF-8, modulo 100) is the rollout hash.
232
275
  - Only store and registry nodes and `internal:http`, `internal:datatable`,
233
276
  `internal:set` and `internal:code` may run as activities
234
277
  (`ACTIVITY_NODE_ALLOWLIST`).
@@ -284,12 +327,27 @@ await replay(refundOrder, handle.history()); // throws DeterminismViolation on a
284
327
  ```
285
328
 
286
329
  The test environment appends exactly the events the service appends
287
- (`eventsForCommands`) and retries activities with `computeRetryDelay`. Its
288
- documented differences from the service: workflow tasks run in this process
289
- without the determinism shims (pass `taskExecutor` to run them in an isolate), a
290
- failed workflow task stops the run instead of being retried, activity
291
- start-to-close and heartbeat timeouts are not timed (a mock may throw a
292
- `TimeoutFailure`), and graph children are mocks (`mockChild`).
330
+ (`eventsForCommands`) and retries activities with `computeRetryDelay`. Since R2
331
+ it also runs local activities through `mock` (retried inside the task), start
332
+ delays, run and execution timeouts and run-level retry on the fake clock,
333
+ workflow-id policies (`workflowId`, `idReusePolicy`, `idConflictPolicy`) and
334
+ workflow-id targets, schedule-to-start timeouts while a queue is held
335
+ (`holdActivities`), heartbeat details on retry (`info.heartbeat`,
336
+ `info.heartbeatDetails`), and fails `result()` with `UnfinishedHandlersError`
337
+ when a run finishes while a signal handler still runs
338
+ (`failOnUnfinishedHandlers`, default true). Its documented differences from the
339
+ service: workflow tasks run in this process without the determinism shims (pass
340
+ `taskExecutor` to run them in an isolate), a failed workflow task stops the run
341
+ instead of being retried, activity start-to-close and heartbeat timeouts are not
342
+ timed (a mock may throw a `TimeoutFailure`), local-activity retries do not wait
343
+ for their backoff, the workflow-task timeout is recorded but not enforced, and
344
+ graph children are mocks (`mockChild`).
345
+
346
+ `buildBundle(files, { sourcemap: 'external' })` also returns the bundle's
347
+ source map (`map`) with the same bundle bytes and `buildId`; it travels in the
348
+ source archive (`map`), and `createSourceMapper`, `mapStackTrace` and
349
+ `mapEnhancedStackTrace` turn the bundle positions of `__stack_trace` and
350
+ `__enhanced_stack_trace` into source lines.
293
351
 
294
352
  `simulate(definition, { trigger, mocks, workflows })` walks a tier-1 graph in
295
353
  process. It is a reduced form: no expressions are evaluated, a node without a
@@ -301,7 +359,11 @@ merges are not modelled.
301
359
 
302
360
  `fixtures/histories/` holds the recorded histories of spec 10 §3 (timers,
303
361
  signals, cancellation, child runs, race, gather, continue-as-new, patched,
304
- side effects, activities, task failures, activation boundaries, and updates as
362
+ side effects, activities, task failures, activation boundaries, the 21 R2
363
+ parity histories (local activities, schedule-to-start, heartbeat details,
364
+ cancellation types, child options, run retry, continue-as-new results and
365
+ options, run and execution timeouts, start delay, external cancels, handler
366
+ drain, auto-upgrade, task failures and failure types), and updates as
305
367
  parse-only fixtures), with their workflow sources in `fixtures/histories/src/`
306
368
  and the scenarios that recorded them in `fixtures/histories/scenarios.ts`.
307
369
  `bun run check:histories` re-records every history, replays it in QuickJS and in
@@ -1,4 +1,4 @@
1
- import { U as RunEventRecord } from './types-DV-HX_Gt.js';
1
+ import { Z as RunEventRecord } from './types-CnIOinoz.js';
2
2
 
3
3
  /**
4
4
  * Split a history into activations (C-HIST, spec 04 §2).
@@ -1,4 +1,4 @@
1
- import { U as RunEventRecord } from './types-CpBBjaGX.cjs';
1
+ import { Z as RunEventRecord } from './types-CQKOhPTa.cjs';
2
2
 
3
3
  /**
4
4
  * Split a history into activations (C-HIST, spec 04 §2).
@@ -1,4 +1,4 @@
1
- import { runIsolateWorker, outcomeToCollection } from './chunk-H7KEVW2M.js';
1
+ import { runIsolateWorker, outcomeToCollection } from './chunk-A2OHX3UQ.js';
2
2
 
3
3
  // src/generated/vm-worker-source.ts
4
4
  var VM_WORKER_SOURCE = '"use strict";\n\nvar import_node_worker_threads = require("node:worker_threads");\n\nfunction isRecord(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\n\nvar DETERMINISM_VIOLATION = "DeterminismViolation";\nvar DETERMINISM_PRELUDE = `(() => {\n const NAME = ${JSON.stringify(DETERMINISM_VIOLATION)};\n const fail = (what) => {\n const error = new Error(\n what + " is not allowed in workflow code: lowering must give the same IR on every build. Read times and random values at run time instead (for example wf.now)."\n );\n error.name = NAME;\n throw error;\n };\n const lock = (target, key, value) =>\n Object.defineProperty(target, key, { value, writable: false, enumerable: false, configurable: false });\n const RealDate = Date;\n const LockedDate = function Date(...args) {\n if (new.target === undefined) return fail("Date()");\n if (args.length === 0) return fail("new Date()");\n return Reflect.construct(RealDate, args, new.target);\n };\n lock(LockedDate, "prototype", RealDate.prototype);\n lock(RealDate.prototype, "constructor", LockedDate);\n lock(LockedDate, "now", function now() { return fail("Date.now()"); });\n lock(LockedDate, "parse", RealDate.parse);\n lock(LockedDate, "UTC", RealDate.UTC);\n lock(globalThis, "Date", LockedDate);\n lock(Math, "random", function random() { return fail("Math.random()"); });\n const crypto = globalThis.crypto;\n if (crypto !== null && typeof crypto === "object") {\n for (const name of ["getRandomValues", "randomUUID"]) {\n if (typeof crypto[name] === "function") lock(crypto, name, function () { return fail("crypto." + name + "()"); });\n }\n }\n const DateTimeFormat = typeof Intl === "object" && Intl !== null ? Intl.DateTimeFormat : undefined;\n if (typeof DateTimeFormat === "function") {\n const proto = DateTimeFormat.prototype;\n const format = Object.getOwnPropertyDescriptor(proto, "format");\n if (format && typeof format.get === "function") {\n const get = format.get;\n Object.defineProperty(proto, "format", {\n get() {\n const bound = get.call(this);\n return (date) => (date === undefined ? fail("Intl.DateTimeFormat format()") : bound(date));\n },\n enumerable: false,\n configurable: false,\n });\n }\n const formatToParts = proto.formatToParts;\n if (typeof formatToParts === "function") {\n lock(proto, "formatToParts", function (date) {\n return date === undefined ? fail("Intl.DateTimeFormat formatToParts()") : formatToParts.call(this, date);\n });\n }\n }\n})();\n`;\nfunction failure(kind, message) {\n return { ok: false, failure: kind, message };\n}\n\nvar import_node_vm = require("node:vm");\nvar import_node_util = require("node:util");\nvar BUNDLE_GLOBAL = "__fluidgridsBundle";\nfunction wrap(code) {\n return `(function () {\n const describe = (error) => {\n let name = "Error";\n let message = "";\n try {\n if (error !== null && (typeof error === "object" || typeof error === "function")) {\n const n = error.name;\n if (typeof n === "string") name = n;\n const m = error.message;\n message = typeof m === "string" ? m : m === undefined ? "" + error : "" + m;\n } else {\n message = "" + error;\n }\n } catch (_) {\n message = "a value whose message cannot be read was thrown";\n }\n return (name === ${JSON.stringify(DETERMINISM_VIOLATION)} ? "D" : "E") + message;\n };\n try {\n${code}\n;const __fluidgridsValue = ${BUNDLE_GLOBAL}.__fluidgrids;\n return typeof __fluidgridsValue === "string" ? "R" + __fluidgridsValue : "N";\n } catch (error) {\n try {\n return describe(error);\n } catch (_) {\n return "Ean error that cannot be described was thrown";\n }\n }\n})()`;\n}\nfunction hostErrorFields(error) {\n if (!import_node_util.types.isNativeError(error)) return {};\n const code = Object.getOwnPropertyDescriptor(error, "code")?.value;\n const message = Object.getOwnPropertyDescriptor(error, "message")?.value;\n return {\n ...typeof code === "string" ? { code } : {},\n ...typeof message === "string" ? { message } : {}\n };\n}\nfunction decode(result) {\n const tag = result.charAt(0);\n const rest = result.slice(1);\n if (tag === "R") return { ok: true, value: rest };\n if (tag === "N")\n return failure("no-collection", "The bundle did not export a workflow collection");\n if (tag === "D") return failure("determinism", rest);\n return failure("error", rest);\n}\nfunction runInVmContext(code, timeoutMs) {\n const context = (0, import_node_vm.createContext)(/* @__PURE__ */ Object.create(null), {\n codeGeneration: { strings: false, wasm: false },\n microtaskMode: "afterEvaluate",\n name: "fluidgrids-workflow-lowering"\n });\n const refuseImport = () => {\n throw new Error("Workflow code may not import modules at run time");\n };\n const deadline = Date.now() + timeoutMs;\n const run = (source, filename) => new import_node_vm.Script(source, { filename, importModuleDynamically: refuseImport }).runInContext(context, {\n timeout: Math.max(1, deadline - Date.now()),\n breakOnSigint: true\n });\n try {\n run(DETERMINISM_PRELUDE, "determinism-prelude.js");\n const result = run(wrap(code), "workflow-bundle.js");\n return typeof result === "string" ? decode(result) : failure("no-collection", "The bundle did not export a workflow collection");\n } catch (error) {\n const fields = hostErrorFields(error);\n if (fields.code === "ERR_SCRIPT_EXECUTION_TIMEOUT" || fields.message !== void 0 && /^Script execution timed out/.test(fields.message)) {\n return failure("timeout", `Evaluating the workflow code timed out after ${timeoutMs} ms`);\n }\n return failure("error", fields.message ?? "The workflow code could not be evaluated");\n }\n}\n\nprocess.on("unhandledRejection", () => void 0);\nvar input = import_node_worker_threads.workerData;\nimport_node_worker_threads.parentPort?.postMessage(\n isRecord(input) && typeof input["code"] === "string" && typeof input["timeoutMs"] === "number" ? runInVmContext(input["code"], input["timeoutMs"]) : failure("crashed", "The evaluation worker received no bundle")\n);\n';
@@ -1,21 +1,54 @@
1
1
  'use strict';
2
2
 
3
- var chunk57MSZ24T_cjs = require('./chunk-57MSZ24T.cjs');
3
+ var chunkNXFBVDOI_cjs = require('./chunk-NXFBVDOI.cjs');
4
4
  var chunkGVTZMA5C_cjs = require('./chunk-GVTZMA5C.cjs');
5
5
  var chunkSAENRNBJ_cjs = require('./chunk-SAENRNBJ.cjs');
6
- var chunkFQIHX7YI_cjs = require('./chunk-FQIHX7YI.cjs');
6
+ var chunkJ3PYFGKA_cjs = require('./chunk-J3PYFGKA.cjs');
7
7
 
8
8
  // src/builder/collect.ts
9
9
  var COLLECTION_FORMAT = "fluidgrids.tier1-collection";
10
+ function configDuration(value) {
11
+ return typeof value === "string" ? value : chunkJ3PYFGKA_cjs.toMs(value) / 1e3;
12
+ }
13
+ function runSettingsOf(options) {
14
+ const config = {};
15
+ const features = [];
16
+ if (options.runTimeout !== void 0) config.timeout = chunkJ3PYFGKA_cjs.toMs(options.runTimeout) / 1e3;
17
+ if (options.executionTimeout !== void 0)
18
+ config.executionTimeout = configDuration(options.executionTimeout);
19
+ if (options.workflowTaskTimeout !== void 0)
20
+ config.workflowTaskTimeout = configDuration(options.workflowTaskTimeout);
21
+ if (options.runTimeout !== void 0 || options.executionTimeout !== void 0 || options.workflowTaskTimeout !== void 0)
22
+ features.push("timeouts");
23
+ if (options.versioningBehavior !== void 0) {
24
+ config.versioningBehavior = options.versioningBehavior;
25
+ if (options.versioningBehavior === "AUTO_UPGRADE") features.push("autoUpgrade");
26
+ }
27
+ if (options.retry !== void 0) {
28
+ const retry = {};
29
+ if (options.retry.maxAttempts !== void 0) retry.maxAttempts = options.retry.maxAttempts;
30
+ if (options.retry.initialDelay !== void 0)
31
+ retry.initialDelay = configDuration(options.retry.initialDelay);
32
+ if (options.retry.backoffMultiplier !== void 0)
33
+ retry.backoffMultiplier = options.retry.backoffMultiplier;
34
+ if (options.retry.maxDelay !== void 0)
35
+ retry.maxDelay = configDuration(options.retry.maxDelay);
36
+ if (options.retry.nonRetryableErrorTypes !== void 0)
37
+ retry.nonRetryableErrorTypes = [...options.retry.nonRetryableErrorTypes];
38
+ config.retry = retry;
39
+ features.push("runRetry");
40
+ }
41
+ return { config, features };
42
+ }
10
43
  function triggerOf(spec, where) {
11
44
  if (spec === void 0) return void 0;
12
- const operation = chunk57MSZ24T_cjs.isOperation(spec) ? spec : chunkSAENRNBJ_cjs.isRecord(spec) ? spec.operation : void 0;
13
- if (!chunk57MSZ24T_cjs.isOperation(operation))
45
+ const operation = chunkNXFBVDOI_cjs.isOperation(spec) ? spec : chunkSAENRNBJ_cjs.isRecord(spec) ? spec.operation : void 0;
46
+ if (!chunkNXFBVDOI_cjs.isOperation(operation))
14
47
  throw new chunkGVTZMA5C_cjs.BuilderError(`${where}: trigger must be a trigger operation`);
15
48
  const out = { nodeType: operation.nodeType };
16
49
  if (operation.version !== void 0) out.version = operation.version;
17
50
  if (operation.operation !== void 0) out.operation = operation.operation;
18
- if (!chunk57MSZ24T_cjs.isOperation(spec)) {
51
+ if (!chunkNXFBVDOI_cjs.isOperation(spec)) {
19
52
  if (spec.args !== void 0) out.args = spec.args;
20
53
  if (spec.id !== void 0) out.id = spec.id;
21
54
  }
@@ -27,7 +60,7 @@ function collectWorkflowExports(modules) {
27
60
  for (const [module, namespace] of modules) {
28
61
  for (const exportName of Object.keys(namespace).sort()) {
29
62
  const value = namespace[exportName];
30
- if (!chunkFQIHX7YI_cjs.isDurableWorkflow(value) || exportNames.has(value)) continue;
63
+ if (!chunkJ3PYFGKA_cjs.isDurableWorkflow(value) || exportNames.has(value)) continue;
31
64
  exportNames.set(value, exportName);
32
65
  const options = value.options;
33
66
  const entry = {
@@ -35,13 +68,16 @@ function collectWorkflowExports(modules) {
35
68
  exportName,
36
69
  name: value.name,
37
70
  taskQueue: options.taskQueue ?? "managed",
38
- interface: chunkFQIHX7YI_cjs.interfaceOf(value)
71
+ interface: chunkJ3PYFGKA_cjs.interfaceOf(value)
39
72
  };
40
73
  if (options.title !== void 0) entry.title = options.title;
41
74
  if (options.description !== void 0) entry.description = options.description;
42
75
  if (options.standalone !== void 0) entry.standalone = options.standalone;
43
76
  const trigger = triggerOf(options.trigger, `workflow("${value.name}")`);
44
77
  if (trigger) entry.trigger = trigger;
78
+ const settings = runSettingsOf(options);
79
+ if (Object.keys(settings.config).length > 0) entry.config = settings.config;
80
+ if (settings.features.length > 0) entry.features = settings.features;
45
81
  durable.push(entry);
46
82
  }
47
83
  }
@@ -49,7 +85,7 @@ function collectWorkflowExports(modules) {
49
85
  for (const [module, namespace] of modules) {
50
86
  for (const exportName of Object.keys(namespace).sort()) {
51
87
  const value = namespace[exportName];
52
- if (!chunk57MSZ24T_cjs.isTier1Workflow(value)) continue;
88
+ if (!chunkNXFBVDOI_cjs.isTier1Workflow(value)) continue;
53
89
  for (const ref of value.durableRefs ?? []) {
54
90
  const resolved = exportNames.get(ref.definition);
55
91
  if (resolved === void 0)
@@ -1,5 +1,84 @@
1
+ // src/history/allowlist.ts
2
+ var ACTIVITY_INTERNAL_ALLOWLIST = /* @__PURE__ */ new Set([
3
+ "internal:http",
4
+ "internal:datatable",
5
+ "internal:set",
6
+ "internal:code"
7
+ ]);
8
+ var ACTIVITY_NODE_DENYLIST = /* @__PURE__ */ new Set([
9
+ "internal:end",
10
+ "internal:if",
11
+ "internal:switch",
12
+ "internal:loop",
13
+ "internal:merge",
14
+ "internal:wait",
15
+ "internal:subworkflow",
16
+ "internal:code-workflow",
17
+ "internal:wait-for-signal",
18
+ "internal:send-and-wait",
19
+ "internal:respond-to-webhook",
20
+ "internal:failure-triage"
21
+ ]);
22
+ var ACTIVITY_NODE_ALLOWLIST = {
23
+ internal: ACTIVITY_INTERNAL_ALLOWLIST,
24
+ refused: ACTIVITY_NODE_DENYLIST,
25
+ /** Non-built-in node types (store and registry nodes) are allowed. */
26
+ external: "allowed"
27
+ };
28
+ var LEGACY_SHORT_NAMES = /* @__PURE__ */ new Set([
29
+ "if",
30
+ "switch",
31
+ "loop",
32
+ "merge",
33
+ "set",
34
+ "filter",
35
+ "aggregate",
36
+ "wait",
37
+ "noop",
38
+ "code",
39
+ "http",
40
+ "transform",
41
+ "validate",
42
+ "log",
43
+ "error",
44
+ "subworkflow",
45
+ "end",
46
+ "trigger",
47
+ "webhook",
48
+ "schedule",
49
+ "manual",
50
+ "api"
51
+ ]);
52
+ function canonicalType(nodeType) {
53
+ const lower = nodeType.trim().toLowerCase();
54
+ return LEGACY_SHORT_NAMES.has(lower) ? `internal:${lower}` : lower;
55
+ }
56
+ function isActivityNodeTypeAllowed(nodeType) {
57
+ if (typeof nodeType !== "string" || nodeType.trim() === "") return false;
58
+ const type = canonicalType(nodeType);
59
+ if (!type.startsWith("internal:")) return true;
60
+ return ACTIVITY_INTERNAL_ALLOWLIST.has(type);
61
+ }
62
+ var ActivityNodeTypeNotAllowedError = class extends Error {
63
+ constructor(nodeType) {
64
+ super(
65
+ `${nodeType} cannot run as a durable activity: only store and registry nodes and internal:http, internal:datatable, internal:set and internal:code can`
66
+ );
67
+ this.nodeType = nodeType;
68
+ this.name = "ActivityNodeTypeNotAllowedError";
69
+ }
70
+ nodeType;
71
+ code = "durable.activityTypeNotAllowed";
72
+ errorType = "VALIDATION";
73
+ nonRetryable = true;
74
+ };
75
+ function assertActivityNodeType(nodeType) {
76
+ if (!isActivityNodeTypeAllowed(nodeType)) throw new ActivityNodeTypeNotAllowedError(nodeType);
77
+ }
78
+
1
79
  // src/history/types.ts
2
80
  var HISTORY_PROTOCOL = 1;
81
+ var RUNTIME_RELEASE = 2;
3
82
  var EVENT_TYPES = [
4
83
  "WORKFLOW_STARTED",
5
84
  "WORKFLOW_TASK_SCHEDULED",
@@ -139,6 +218,18 @@ var CHILD_CANCELLATION_TYPES = [
139
218
  "TRY_CANCEL",
140
219
  "ABANDON"
141
220
  ];
221
+ var WORKFLOW_ID_REUSE_POLICIES = [
222
+ "ALLOW_DUPLICATE",
223
+ "ALLOW_DUPLICATE_FAILED_ONLY",
224
+ "REJECT_DUPLICATE"
225
+ ];
226
+ var WORKFLOW_ID_CONFLICT_POLICIES = [
227
+ "FAIL",
228
+ "USE_EXISTING",
229
+ "TERMINATE_EXISTING"
230
+ ];
231
+ var VERSIONING_BEHAVIORS = ["PINNED", "AUTO_UPGRADE"];
232
+ var WORKFLOW_TIMEOUT_TYPES = ["WORKFLOW_RUN", "WORKFLOW_EXECUTION"];
142
233
  var DEFAULT_HISTORY_LIMIT = { events: 1e4, bytes: 16 * 1024 * 1024 };
143
234
  var CONTINUE_AS_NEW_SUGGESTED_RATIO = 0.8;
144
235
  var HISTORY_LIMIT_EXCEEDED_RATIO = 0.95;
@@ -147,6 +238,7 @@ var BUILT_IN_QUERIES = [
147
238
  "__enhanced_stack_trace",
148
239
  "__metadata"
149
240
  ];
241
+ var LOCAL_ACTIVITY_MAX_TIMEOUT_MS = 3e4;
150
242
  var COMMAND_EVENT_TYPES = {
151
243
  SCHEDULE_ACTIVITY: "ACTIVITY_SCHEDULED",
152
244
  REQUEST_CANCEL_ACTIVITY: "ACTIVITY_CANCEL_REQUESTED",
@@ -224,4 +316,4 @@ function isCommandEvent(event) {
224
316
  return COMMAND_EVENTS.has(event.type);
225
317
  }
226
318
 
227
- export { ACTIVITY_CANCELLATION_TYPES, BUILT_IN_QUERIES, CHILD_CANCELLATION_TYPES, COMMAND_EVENTS, COMMAND_EVENT_TYPES, COMMAND_TYPES, CONTINUE_AS_NEW_SUGGESTED_RATIO, DEFAULT_HISTORY_LIMIT, ERROR_TYPES, EVENT_TYPES, EXECUTION_KINDS, HISTORY_LIMIT_EXCEEDED_RATIO, HISTORY_PROTOCOL, INPUT_EVENTS, PARENT_CLOSE_POLICIES, PHASE_B_CORE_COMMANDS, PHASE_B_PARITY_COMMANDS, PHASE_C_COMMANDS, TASK_FAILURE_CAUSES, TERMINAL_COMMANDS, TERMINAL_EVENTS, isCommandEvent, isInputEvent };
319
+ export { ACTIVITY_CANCELLATION_TYPES, ACTIVITY_INTERNAL_ALLOWLIST, ACTIVITY_NODE_ALLOWLIST, ACTIVITY_NODE_DENYLIST, ActivityNodeTypeNotAllowedError, BUILT_IN_QUERIES, CHILD_CANCELLATION_TYPES, COMMAND_EVENTS, COMMAND_EVENT_TYPES, COMMAND_TYPES, CONTINUE_AS_NEW_SUGGESTED_RATIO, DEFAULT_HISTORY_LIMIT, ERROR_TYPES, EVENT_TYPES, EXECUTION_KINDS, HISTORY_LIMIT_EXCEEDED_RATIO, HISTORY_PROTOCOL, INPUT_EVENTS, LOCAL_ACTIVITY_MAX_TIMEOUT_MS, PARENT_CLOSE_POLICIES, PHASE_B_CORE_COMMANDS, PHASE_B_PARITY_COMMANDS, PHASE_C_COMMANDS, RUNTIME_RELEASE, TASK_FAILURE_CAUSES, TERMINAL_COMMANDS, TERMINAL_EVENTS, VERSIONING_BEHAVIORS, WORKFLOW_ID_CONFLICT_POLICIES, WORKFLOW_ID_REUSE_POLICIES, WORKFLOW_TIMEOUT_TYPES, assertActivityNodeType, isActivityNodeTypeAllowed, isCommandEvent, isInputEvent };
@@ -1,7 +1,86 @@
1
1
  'use strict';
2
2
 
3
+ // src/history/allowlist.ts
4
+ var ACTIVITY_INTERNAL_ALLOWLIST = /* @__PURE__ */ new Set([
5
+ "internal:http",
6
+ "internal:datatable",
7
+ "internal:set",
8
+ "internal:code"
9
+ ]);
10
+ var ACTIVITY_NODE_DENYLIST = /* @__PURE__ */ new Set([
11
+ "internal:end",
12
+ "internal:if",
13
+ "internal:switch",
14
+ "internal:loop",
15
+ "internal:merge",
16
+ "internal:wait",
17
+ "internal:subworkflow",
18
+ "internal:code-workflow",
19
+ "internal:wait-for-signal",
20
+ "internal:send-and-wait",
21
+ "internal:respond-to-webhook",
22
+ "internal:failure-triage"
23
+ ]);
24
+ var ACTIVITY_NODE_ALLOWLIST = {
25
+ internal: ACTIVITY_INTERNAL_ALLOWLIST,
26
+ refused: ACTIVITY_NODE_DENYLIST,
27
+ /** Non-built-in node types (store and registry nodes) are allowed. */
28
+ external: "allowed"
29
+ };
30
+ var LEGACY_SHORT_NAMES = /* @__PURE__ */ new Set([
31
+ "if",
32
+ "switch",
33
+ "loop",
34
+ "merge",
35
+ "set",
36
+ "filter",
37
+ "aggregate",
38
+ "wait",
39
+ "noop",
40
+ "code",
41
+ "http",
42
+ "transform",
43
+ "validate",
44
+ "log",
45
+ "error",
46
+ "subworkflow",
47
+ "end",
48
+ "trigger",
49
+ "webhook",
50
+ "schedule",
51
+ "manual",
52
+ "api"
53
+ ]);
54
+ function canonicalType(nodeType) {
55
+ const lower = nodeType.trim().toLowerCase();
56
+ return LEGACY_SHORT_NAMES.has(lower) ? `internal:${lower}` : lower;
57
+ }
58
+ function isActivityNodeTypeAllowed(nodeType) {
59
+ if (typeof nodeType !== "string" || nodeType.trim() === "") return false;
60
+ const type = canonicalType(nodeType);
61
+ if (!type.startsWith("internal:")) return true;
62
+ return ACTIVITY_INTERNAL_ALLOWLIST.has(type);
63
+ }
64
+ var ActivityNodeTypeNotAllowedError = class extends Error {
65
+ constructor(nodeType) {
66
+ super(
67
+ `${nodeType} cannot run as a durable activity: only store and registry nodes and internal:http, internal:datatable, internal:set and internal:code can`
68
+ );
69
+ this.nodeType = nodeType;
70
+ this.name = "ActivityNodeTypeNotAllowedError";
71
+ }
72
+ nodeType;
73
+ code = "durable.activityTypeNotAllowed";
74
+ errorType = "VALIDATION";
75
+ nonRetryable = true;
76
+ };
77
+ function assertActivityNodeType(nodeType) {
78
+ if (!isActivityNodeTypeAllowed(nodeType)) throw new ActivityNodeTypeNotAllowedError(nodeType);
79
+ }
80
+
3
81
  // src/history/types.ts
4
82
  var HISTORY_PROTOCOL = 1;
83
+ var RUNTIME_RELEASE = 2;
5
84
  var EVENT_TYPES = [
6
85
  "WORKFLOW_STARTED",
7
86
  "WORKFLOW_TASK_SCHEDULED",
@@ -141,6 +220,18 @@ var CHILD_CANCELLATION_TYPES = [
141
220
  "TRY_CANCEL",
142
221
  "ABANDON"
143
222
  ];
223
+ var WORKFLOW_ID_REUSE_POLICIES = [
224
+ "ALLOW_DUPLICATE",
225
+ "ALLOW_DUPLICATE_FAILED_ONLY",
226
+ "REJECT_DUPLICATE"
227
+ ];
228
+ var WORKFLOW_ID_CONFLICT_POLICIES = [
229
+ "FAIL",
230
+ "USE_EXISTING",
231
+ "TERMINATE_EXISTING"
232
+ ];
233
+ var VERSIONING_BEHAVIORS = ["PINNED", "AUTO_UPGRADE"];
234
+ var WORKFLOW_TIMEOUT_TYPES = ["WORKFLOW_RUN", "WORKFLOW_EXECUTION"];
144
235
  var DEFAULT_HISTORY_LIMIT = { events: 1e4, bytes: 16 * 1024 * 1024 };
145
236
  var CONTINUE_AS_NEW_SUGGESTED_RATIO = 0.8;
146
237
  var HISTORY_LIMIT_EXCEEDED_RATIO = 0.95;
@@ -149,6 +240,7 @@ var BUILT_IN_QUERIES = [
149
240
  "__enhanced_stack_trace",
150
241
  "__metadata"
151
242
  ];
243
+ var LOCAL_ACTIVITY_MAX_TIMEOUT_MS = 3e4;
152
244
  var COMMAND_EVENT_TYPES = {
153
245
  SCHEDULE_ACTIVITY: "ACTIVITY_SCHEDULED",
154
246
  REQUEST_CANCEL_ACTIVITY: "ACTIVITY_CANCEL_REQUESTED",
@@ -227,6 +319,10 @@ function isCommandEvent(event) {
227
319
  }
228
320
 
229
321
  exports.ACTIVITY_CANCELLATION_TYPES = ACTIVITY_CANCELLATION_TYPES;
322
+ exports.ACTIVITY_INTERNAL_ALLOWLIST = ACTIVITY_INTERNAL_ALLOWLIST;
323
+ exports.ACTIVITY_NODE_ALLOWLIST = ACTIVITY_NODE_ALLOWLIST;
324
+ exports.ACTIVITY_NODE_DENYLIST = ACTIVITY_NODE_DENYLIST;
325
+ exports.ActivityNodeTypeNotAllowedError = ActivityNodeTypeNotAllowedError;
230
326
  exports.BUILT_IN_QUERIES = BUILT_IN_QUERIES;
231
327
  exports.CHILD_CANCELLATION_TYPES = CHILD_CANCELLATION_TYPES;
232
328
  exports.COMMAND_EVENTS = COMMAND_EVENTS;
@@ -240,12 +336,20 @@ exports.EXECUTION_KINDS = EXECUTION_KINDS;
240
336
  exports.HISTORY_LIMIT_EXCEEDED_RATIO = HISTORY_LIMIT_EXCEEDED_RATIO;
241
337
  exports.HISTORY_PROTOCOL = HISTORY_PROTOCOL;
242
338
  exports.INPUT_EVENTS = INPUT_EVENTS;
339
+ exports.LOCAL_ACTIVITY_MAX_TIMEOUT_MS = LOCAL_ACTIVITY_MAX_TIMEOUT_MS;
243
340
  exports.PARENT_CLOSE_POLICIES = PARENT_CLOSE_POLICIES;
244
341
  exports.PHASE_B_CORE_COMMANDS = PHASE_B_CORE_COMMANDS;
245
342
  exports.PHASE_B_PARITY_COMMANDS = PHASE_B_PARITY_COMMANDS;
246
343
  exports.PHASE_C_COMMANDS = PHASE_C_COMMANDS;
344
+ exports.RUNTIME_RELEASE = RUNTIME_RELEASE;
247
345
  exports.TASK_FAILURE_CAUSES = TASK_FAILURE_CAUSES;
248
346
  exports.TERMINAL_COMMANDS = TERMINAL_COMMANDS;
249
347
  exports.TERMINAL_EVENTS = TERMINAL_EVENTS;
348
+ exports.VERSIONING_BEHAVIORS = VERSIONING_BEHAVIORS;
349
+ exports.WORKFLOW_ID_CONFLICT_POLICIES = WORKFLOW_ID_CONFLICT_POLICIES;
350
+ exports.WORKFLOW_ID_REUSE_POLICIES = WORKFLOW_ID_REUSE_POLICIES;
351
+ exports.WORKFLOW_TIMEOUT_TYPES = WORKFLOW_TIMEOUT_TYPES;
352
+ exports.assertActivityNodeType = assertActivityNodeType;
353
+ exports.isActivityNodeTypeAllowed = isActivityNodeTypeAllowed;
250
354
  exports.isCommandEvent = isCommandEvent;
251
355
  exports.isInputEvent = isInputEvent;