@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
@@ -0,0 +1,81 @@
1
+ // src/history/retry.ts
2
+ var DEFAULT_ACTIVITY_RETRY = Object.freeze({
3
+ retryDelay: 1e3,
4
+ backoffMultiplier: 2,
5
+ maxDelay: 1e5
6
+ });
7
+ var FINAL_TIMEOUTS = /* @__PURE__ */ new Set(["SCHEDULE_TO_START", "SCHEDULE_TO_CLOSE"]);
8
+ function computeRetryDelay(policy, attempt, failure) {
9
+ if (failure?.nonRetryable === true) return { retry: false, reason: "nonRetryable" };
10
+ if (failure?.timeoutType !== void 0 && FINAL_TIMEOUTS.has(failure.timeoutType))
11
+ return { retry: false, reason: "finalTimeout" };
12
+ if (failure?.type !== void 0 && policy.nonRetryableErrorTypes !== void 0 && policy.nonRetryableErrorTypes.includes(failure.type))
13
+ return { retry: false, reason: "typeDenied" };
14
+ if (failure !== void 0 && policy.retryOnErrorTypes !== void 0 && policy.retryOnErrorTypes.length > 0 && !policy.retryOnErrorTypes.includes(failure.errorType))
15
+ return { retry: false, reason: "errorTypeNotListed" };
16
+ if (policy.maxRetries !== void 0 && attempt > policy.maxRetries)
17
+ return { retry: false, reason: "maxRetries" };
18
+ if (failure?.nextRetryDelayMs !== void 0)
19
+ return { retry: true, delayMs: Math.max(0, Math.round(failure.nextRetryDelayMs)) };
20
+ const base = Math.max(0, policy.retryDelay);
21
+ const multiplier = policy.backoffMultiplier ?? 2;
22
+ const cap = policy.maxDelay ?? base * 100;
23
+ const exponent = Math.max(0, attempt - 1);
24
+ const delay = Math.min(base * Math.pow(multiplier, exponent), cap);
25
+ return { retry: true, delayMs: Math.round(Number.isFinite(delay) ? delay : cap) };
26
+ }
27
+ function explicitRetryPolicy(policy) {
28
+ const retryDelay = policy?.retryDelay ?? DEFAULT_ACTIVITY_RETRY.retryDelay;
29
+ const out = {
30
+ retryDelay,
31
+ backoffMultiplier: policy?.backoffMultiplier ?? DEFAULT_ACTIVITY_RETRY.backoffMultiplier ?? 2,
32
+ maxDelay: policy?.maxDelay ?? (policy?.retryDelay === void 0 ? 1e5 : Math.max(retryDelay, retryDelay * 100))
33
+ };
34
+ if (policy?.maxRetries !== void 0) out.maxRetries = policy.maxRetries;
35
+ if (policy?.retryOnErrorTypes !== void 0)
36
+ out.retryOnErrorTypes = [...policy.retryOnErrorTypes];
37
+ if (policy?.nonRetryableErrorTypes !== void 0)
38
+ out.nonRetryableErrorTypes = [...policy.nonRetryableErrorTypes];
39
+ return out;
40
+ }
41
+ function computeRunRetryDelay(policy, attempt, failure) {
42
+ if (policy === void 0) return { retry: false, reason: "noPolicy" };
43
+ if (failure.timeoutType === "WORKFLOW_EXECUTION")
44
+ return { retry: false, reason: "executionTimeout" };
45
+ if (policy.maxAttempts !== void 0 && attempt >= policy.maxAttempts)
46
+ return { retry: false, reason: "maxAttempts" };
47
+ const activityPolicy = {
48
+ retryDelay: policy.initialDelayMs,
49
+ ...policy.backoffMultiplier !== void 0 ? { backoffMultiplier: policy.backoffMultiplier } : {},
50
+ ...policy.maxDelayMs !== void 0 ? { maxDelay: policy.maxDelayMs } : {},
51
+ ...policy.retryOnErrorTypes !== void 0 ? { retryOnErrorTypes: policy.retryOnErrorTypes } : {},
52
+ ...policy.nonRetryableErrorTypes !== void 0 ? { nonRetryableErrorTypes: policy.nonRetryableErrorTypes } : {}
53
+ };
54
+ const classified = { ...failure };
55
+ if (classified.timeoutType === "WORKFLOW_RUN") delete classified.timeoutType;
56
+ const decision = computeRetryDelay(activityPolicy, attempt, classified);
57
+ if (decision.retry) return decision;
58
+ switch (decision.reason) {
59
+ case "nonRetryable":
60
+ case "typeDenied":
61
+ case "errorTypeNotListed":
62
+ return { retry: false, reason: decision.reason };
63
+ default:
64
+ return { retry: false, reason: "maxAttempts" };
65
+ }
66
+ }
67
+ function explicitRunRetryPolicy(policy) {
68
+ const initialDelayMs = policy.initialDelayMs ?? DEFAULT_ACTIVITY_RETRY.retryDelay;
69
+ const out = {
70
+ initialDelayMs,
71
+ backoffMultiplier: policy.backoffMultiplier ?? 2,
72
+ maxDelayMs: policy.maxDelayMs ?? (policy.initialDelayMs === void 0 ? 1e5 : Math.max(initialDelayMs, initialDelayMs * 100))
73
+ };
74
+ if (policy.maxAttempts !== void 0) out.maxAttempts = policy.maxAttempts;
75
+ if (policy.retryOnErrorTypes !== void 0) out.retryOnErrorTypes = [...policy.retryOnErrorTypes];
76
+ if (policy.nonRetryableErrorTypes !== void 0)
77
+ out.nonRetryableErrorTypes = [...policy.nonRetryableErrorTypes];
78
+ return out;
79
+ }
80
+
81
+ export { DEFAULT_ACTIVITY_RETRY, computeRetryDelay, computeRunRetryDelay, explicitRetryPolicy, explicitRunRetryPolicy };
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ // src/runtime/stack.ts
4
+ var RUNTIME_FRAME = /fluidgrids-runtime|\/runtime\/(scheduler|index)\.|WorkflowExecution|RuntimeContext/;
5
+ function captureStack() {
6
+ const stack = new Error("stack").stack ?? "";
7
+ return stack.split("\n").slice(1).filter((line) => line.trim() !== "" && !RUNTIME_FRAME.test(line)).join("\n");
8
+ }
9
+ var V8_FRAME = /^\s*at (?:(.*?) \()?(.*?):(\d+):(\d+)\)?$/;
10
+ var QUICKJS_FRAME = /^\s*at (?:(.*?) )?\(?(.*?)(?::(\d+))?(?::(\d+))?\)?$/;
11
+ function parseStack(stack) {
12
+ const locations = [];
13
+ for (const line of stack.split("\n")) {
14
+ if (line.trim() === "") continue;
15
+ const match = V8_FRAME.exec(line) ?? QUICKJS_FRAME.exec(line);
16
+ if (!match) continue;
17
+ const location = {};
18
+ if (match[1]) location.functionName = match[1];
19
+ if (match[2]) location.filePath = match[2];
20
+ if (match[3]) location.line = Number(match[3]);
21
+ if (match[4]) location.column = Number(match[4]);
22
+ locations.push(location);
23
+ }
24
+ return locations;
25
+ }
26
+
27
+ exports.captureStack = captureStack;
28
+ exports.parseStack = parseStack;
@@ -1,17 +1,142 @@
1
1
  'use strict';
2
2
 
3
- var chunk623FVQSN_cjs = require('./chunk-623FVQSN.cjs');
4
- var chunk2J6TF7YI_cjs = require('./chunk-2J6TF7YI.cjs');
3
+ var chunk3FIDHONL_cjs = require('./chunk-3FIDHONL.cjs');
5
4
 
6
5
  // src/history/commands.ts
6
+ var COMMAND_FEATURES = [
7
+ "core",
8
+ "parity.can",
9
+ "parity.context",
10
+ "parity.localActivity",
11
+ "parity.externalCancel",
12
+ "parity.childOptions",
13
+ "parity.canOptions",
14
+ "parity.workflowIdTarget",
15
+ "c.updates",
16
+ "c.searchAttributes",
17
+ "c.userActivity"
18
+ ];
19
+ var PHASE_B_CORE_FEATURES = /* @__PURE__ */ new Set([
20
+ "core",
21
+ "parity.can",
22
+ "parity.context"
23
+ ]);
24
+ var PHASE_B_PARITY_FEATURES = /* @__PURE__ */ new Set([
25
+ "core",
26
+ "parity.can",
27
+ "parity.context",
28
+ "parity.localActivity",
29
+ "parity.externalCancel",
30
+ "parity.childOptions",
31
+ "parity.canOptions",
32
+ "parity.workflowIdTarget"
33
+ ]);
34
+ var CORE_CHILD_OPTIONS = /* @__PURE__ */ new Set([
35
+ "parentClosePolicy",
36
+ "cancellationType",
37
+ "taskQueue",
38
+ "workflowId",
39
+ "priority",
40
+ "summary",
41
+ "details",
42
+ "context",
43
+ "startDelay",
44
+ "executionTimeout",
45
+ "runTimeout",
46
+ "workflowTaskTimeout"
47
+ ]);
48
+ var CORE_CAN_OPTIONS = /* @__PURE__ */ new Set([
49
+ "taskQueue",
50
+ "retry",
51
+ "workflowTaskTimeout",
52
+ "context",
53
+ "versioningBehavior"
54
+ ]);
55
+ var LEGACY_RETRY_KEYS = ["retryDelay", "maxRetries", "maxDelay"];
56
+ var RUN_RETRY_KEYS = ["initialDelayMs", "maxAttempts", "maxDelayMs"];
57
+ function continueAsNewRetryShape(options) {
58
+ const retry = options["retry"];
59
+ if (retry === void 0) return "none";
60
+ if (typeof retry !== "object" || retry === null || Array.isArray(retry)) return "invalid";
61
+ const keys = Object.keys(retry);
62
+ const run = keys.some((key) => RUN_RETRY_KEYS.includes(key));
63
+ const legacy = keys.some((key) => LEGACY_RETRY_KEYS.includes(key));
64
+ if (run === legacy) return "invalid";
65
+ return run ? "run" : "legacy";
66
+ }
67
+ function hasOtherKeys(value, allowed) {
68
+ return Object.entries(value).some(([key, entry]) => entry !== void 0 && !allowed.has(key));
69
+ }
70
+ function commandFeatures(command) {
71
+ const needed = /* @__PURE__ */ new Set();
72
+ switch (command.type) {
73
+ case "START_CHILD_RUN":
74
+ needed.add("core");
75
+ if (hasOtherKeys(command.options, CORE_CHILD_OPTIONS)) needed.add("parity.childOptions");
76
+ break;
77
+ case "SIGNAL_RUN":
78
+ needed.add("core");
79
+ if ("workflowId" in command.target) needed.add("parity.workflowIdTarget");
80
+ break;
81
+ case "REQUEST_CANCEL_EXTERNAL_RUN":
82
+ if ("childId" in command.target) needed.add("core");
83
+ else needed.add("parity.externalCancel");
84
+ if ("workflowId" in command.target) needed.add("parity.workflowIdTarget");
85
+ break;
86
+ case "CONTINUE_AS_NEW":
87
+ needed.add("parity.can");
88
+ if (hasOtherKeys(command.options, CORE_CAN_OPTIONS) || continueAsNewRetryShape(command.options) === "run")
89
+ needed.add("parity.canOptions");
90
+ break;
91
+ case "UPSERT_CONTEXT":
92
+ needed.add("parity.context");
93
+ break;
94
+ case "RECORD_LOCAL_ACTIVITY":
95
+ needed.add("parity.localActivity");
96
+ break;
97
+ case "UPSERT_SEARCH_ATTRIBUTES":
98
+ needed.add("c.searchAttributes");
99
+ break;
100
+ case "ACCEPT_UPDATE":
101
+ case "REJECT_UPDATE":
102
+ case "COMPLETE_UPDATE":
103
+ needed.add("c.updates");
104
+ break;
105
+ default:
106
+ needed.add("core");
107
+ }
108
+ return COMMAND_FEATURES.filter((feature) => needed.has(feature));
109
+ }
7
110
  function isCommandEnabled(type, enabled = "core") {
8
- if (chunk623FVQSN_cjs.PHASE_C_COMMANDS.has(type)) return false;
9
- if (chunk623FVQSN_cjs.PHASE_B_CORE_COMMANDS.has(type)) return true;
10
- return enabled === "parity" && chunk623FVQSN_cjs.PHASE_B_PARITY_COMMANDS.has(type);
111
+ if (chunk3FIDHONL_cjs.PHASE_C_COMMANDS.has(type)) return false;
112
+ if (chunk3FIDHONL_cjs.PHASE_B_CORE_COMMANDS.has(type)) return true;
113
+ return enabled === "parity" && chunk3FIDHONL_cjs.PHASE_B_PARITY_COMMANDS.has(type);
11
114
  }
12
115
  function isWorkflowCommandEnabled(command, enabled = "core") {
13
- if (command.type === "REQUEST_CANCEL_EXTERNAL_RUN" && "childId" in command.target) return true;
14
- return isCommandEnabled(command.type, enabled);
116
+ if (typeof enabled === "string") {
117
+ if (command.type === "REQUEST_CANCEL_EXTERNAL_RUN" && "childId" in command.target) return true;
118
+ return isCommandEnabled(command.type, enabled);
119
+ }
120
+ return commandFeatures(command).every((feature) => enabled.has(feature));
121
+ }
122
+ function unsupportedMessage(command, enabled = "core") {
123
+ if (typeof enabled === "string") return `${command.type} is not supported in this release`;
124
+ const missing = commandFeatures(command).filter((feature) => !enabled.has(feature));
125
+ const parity = missing.filter((feature) => feature.startsWith("parity."));
126
+ const flag = parity.length > 0 ? " (needs the fluidgrids.durable-parity flag)" : "";
127
+ return `${command.type} needs ${missing.join(", ")}, which this workspace does not enable${flag}`;
128
+ }
129
+ function isReliefCommand(command, lease) {
130
+ switch (command.type) {
131
+ case "RECORD_LOCAL_ACTIVITY":
132
+ return lease.grantedLocalActivityIds.includes(command.localActivityId);
133
+ case "ACCEPT_UPDATE":
134
+ case "REJECT_UPDATE":
135
+ case "COMPLETE_UPDATE":
136
+ return lease.deliveredUpdateIds.includes(command.updateId);
137
+ default:
138
+ return false;
139
+ }
15
140
  }
16
141
 
17
142
  // src/history/activation.ts
@@ -64,10 +189,10 @@ function walk(history) {
64
189
  continue;
65
190
  }
66
191
  }
67
- if (chunk623FVQSN_cjs.isInputEvent(event)) {
192
+ if (chunk3FIDHONL_cjs.isInputEvent(event)) {
68
193
  if (started) afterStarted.push(event);
69
194
  else pending.push(event);
70
- } else if (chunk623FVQSN_cjs.isCommandEvent(event) && last?.recorded) {
195
+ } else if (chunk3FIDHONL_cjs.isCommandEvent(event) && last?.recorded) {
71
196
  last.recorded.push(event);
72
197
  }
73
198
  }
@@ -109,6 +234,7 @@ function initialRunState() {
109
234
  timers: {},
110
235
  children: {},
111
236
  externals: {},
237
+ localActivities: {},
112
238
  sideEffects: {},
113
239
  markers: {},
114
240
  signalsReceived: 0,
@@ -348,6 +474,21 @@ function applyEvent(state, event) {
348
474
  case "SIDE_EFFECT_RECORDED":
349
475
  state.sideEffects[str(p, "sideEffectId")] = p["value"] ?? null;
350
476
  break;
477
+ case "LOCAL_ACTIVITY_COMPLETED":
478
+ case "LOCAL_ACTIVITY_FAILED": {
479
+ const id = str(p, "localActivityId");
480
+ if (state.localActivities[id])
481
+ throw new HistoryStateError(`Local activity "${id}" is recorded twice`, event.seq);
482
+ state.localActivities[id] = {
483
+ status: event.type === "LOCAL_ACTIVITY_COMPLETED" ? "COMPLETED" : "FAILED",
484
+ attempts: typeof p["attempts"] === "number" ? p["attempts"] : 1,
485
+ recordedSeq: event.seq,
486
+ ...typeof p["nodeType"] === "string" ? { nodeType: p["nodeType"] } : {},
487
+ ...typeof p["operation"] === "string" ? { operation: p["operation"] } : {},
488
+ ...typeof p["summary"] === "string" ? { summary: p["summary"] } : {}
489
+ };
490
+ break;
491
+ }
351
492
  case "MARKER_RECORDED":
352
493
  state.markers[str(p, "markerId")] = p["data"] ?? null;
353
494
  break;
@@ -423,21 +564,22 @@ function eventsForCommands(state, commands, context) {
423
564
  const children = new Set(Object.keys(state.children));
424
565
  const externals = new Set(Object.keys(state.externals));
425
566
  const sideEffects = new Set(Object.keys(state.sideEffects));
567
+ const localActivities = new Set(Object.keys(state.localActivities));
426
568
  let unsupported = false;
427
569
  commands.forEach((command, index) => {
428
- if (!isWorkflowCommandEnabled(command, context.enabled)) {
570
+ if (!isWorkflowCommandEnabled(command, context.enabled) && !(context.relief !== void 0 && isReliefCommand(command, context.relief))) {
429
571
  unsupported = true;
430
- reject(index, "commands.unsupported", `${command.type} is not supported in this release`);
572
+ reject(index, "commands.unsupported", unsupportedMessage(command, context.enabled));
431
573
  return;
432
574
  }
433
- if (chunk623FVQSN_cjs.TERMINAL_COMMANDS.has(command.type) && index !== commands.length - 1)
575
+ if (chunk3FIDHONL_cjs.TERMINAL_COMMANDS.has(command.type) && index !== commands.length - 1)
434
576
  reject(index, "commands.terminalNotLast", `${command.type} must be last`);
435
577
  const base = { taskId: context.taskId };
436
578
  switch (command.type) {
437
579
  case "SCHEDULE_ACTIVITY":
438
580
  if (activities.has(command.activityId))
439
581
  reject(index, "activity.duplicate", `Activity "${command.activityId}" already exists`);
440
- if (!chunk2J6TF7YI_cjs.isActivityNodeTypeAllowed(command.nodeType))
582
+ if (!chunk3FIDHONL_cjs.isActivityNodeTypeAllowed(command.nodeType))
441
583
  reject(
442
584
  index,
443
585
  "durable.activityTypeNotAllowed",
@@ -518,6 +660,13 @@ function eventsForCommands(state, commands, context) {
518
660
  events.push({ ...base, type: "CONTEXT_UPSERTED", payload: payloadOf(command) });
519
661
  break;
520
662
  case "RECORD_LOCAL_ACTIVITY":
663
+ if (localActivities.has(command.localActivityId))
664
+ reject(
665
+ index,
666
+ "localActivity.duplicate",
667
+ `Local activity "${command.localActivityId}" is already recorded`
668
+ );
669
+ localActivities.add(command.localActivityId);
521
670
  events.push({
522
671
  ...base,
523
672
  type: command.failure ? "LOCAL_ACTIVITY_FAILED" : "LOCAL_ACTIVITY_COMPLETED",
@@ -561,47 +710,6 @@ function hasUnprocessedInput(history) {
561
710
  return unseenInputs(history).length > 0;
562
711
  }
563
712
 
564
- // src/history/retry.ts
565
- var DEFAULT_ACTIVITY_RETRY = Object.freeze({
566
- retryDelay: 1e3,
567
- backoffMultiplier: 2,
568
- maxDelay: 1e5
569
- });
570
- var FINAL_TIMEOUTS = /* @__PURE__ */ new Set(["SCHEDULE_TO_START", "SCHEDULE_TO_CLOSE"]);
571
- function computeRetryDelay(policy, attempt, failure) {
572
- if (failure?.nonRetryable === true) return { retry: false, reason: "nonRetryable" };
573
- if (failure?.timeoutType !== void 0 && FINAL_TIMEOUTS.has(failure.timeoutType))
574
- return { retry: false, reason: "finalTimeout" };
575
- if (failure?.type !== void 0 && policy.nonRetryableErrorTypes !== void 0 && policy.nonRetryableErrorTypes.includes(failure.type))
576
- return { retry: false, reason: "typeDenied" };
577
- if (failure !== void 0 && policy.retryOnErrorTypes !== void 0 && policy.retryOnErrorTypes.length > 0 && !policy.retryOnErrorTypes.includes(failure.errorType))
578
- return { retry: false, reason: "errorTypeNotListed" };
579
- if (policy.maxRetries !== void 0 && attempt > policy.maxRetries)
580
- return { retry: false, reason: "maxRetries" };
581
- if (failure?.nextRetryDelayMs !== void 0)
582
- return { retry: true, delayMs: Math.max(0, Math.round(failure.nextRetryDelayMs)) };
583
- const base = Math.max(0, policy.retryDelay);
584
- const multiplier = policy.backoffMultiplier ?? 2;
585
- const cap = policy.maxDelay ?? base * 100;
586
- const exponent = Math.max(0, attempt - 1);
587
- const delay = Math.min(base * Math.pow(multiplier, exponent), cap);
588
- return { retry: true, delayMs: Math.round(Number.isFinite(delay) ? delay : cap) };
589
- }
590
- function explicitRetryPolicy(policy) {
591
- const retryDelay = policy?.retryDelay ?? DEFAULT_ACTIVITY_RETRY.retryDelay;
592
- const out = {
593
- retryDelay,
594
- backoffMultiplier: policy?.backoffMultiplier ?? DEFAULT_ACTIVITY_RETRY.backoffMultiplier ?? 2,
595
- maxDelay: policy?.maxDelay ?? (policy?.retryDelay === void 0 ? 1e5 : Math.max(retryDelay, retryDelay * 100))
596
- };
597
- if (policy?.maxRetries !== void 0) out.maxRetries = policy.maxRetries;
598
- if (policy?.retryOnErrorTypes !== void 0)
599
- out.retryOnErrorTypes = [...policy.retryOnErrorTypes];
600
- if (policy?.nonRetryableErrorTypes !== void 0)
601
- out.nonRetryableErrorTypes = [...policy.nonRetryableErrorTypes];
602
- return out;
603
- }
604
-
605
713
  // src/history/defaults.ts
606
714
  function codeWorkflowParentClosePolicy(state) {
607
715
  const policy = state.parentClosePolicy;
@@ -613,22 +721,28 @@ var CHILD_DEFAULT_CANCELLATION_TYPE = "WAIT_CANCELLATION_COMPLETED";
613
721
 
614
722
  exports.CHILD_DEFAULT_CANCELLATION_TYPE = CHILD_DEFAULT_CANCELLATION_TYPE;
615
723
  exports.CHILD_DEFAULT_PARENT_CLOSE_POLICY = CHILD_DEFAULT_PARENT_CLOSE_POLICY;
616
- exports.DEFAULT_ACTIVITY_RETRY = DEFAULT_ACTIVITY_RETRY;
724
+ exports.COMMAND_FEATURES = COMMAND_FEATURES;
725
+ exports.CORE_CAN_OPTIONS = CORE_CAN_OPTIONS;
726
+ exports.CORE_CHILD_OPTIONS = CORE_CHILD_OPTIONS;
617
727
  exports.HistoryStateError = HistoryStateError;
728
+ exports.PHASE_B_CORE_FEATURES = PHASE_B_CORE_FEATURES;
729
+ exports.PHASE_B_PARITY_FEATURES = PHASE_B_PARITY_FEATURES;
618
730
  exports.applyEvent = applyEvent;
619
731
  exports.codeWorkflowParentClosePolicy = codeWorkflowParentClosePolicy;
620
- exports.computeRetryDelay = computeRetryDelay;
732
+ exports.commandFeatures = commandFeatures;
733
+ exports.continueAsNewRetryShape = continueAsNewRetryShape;
621
734
  exports.eventsForCommands = eventsForCommands;
622
- exports.explicitRetryPolicy = explicitRetryPolicy;
623
735
  exports.hasUnprocessedInput = hasUnprocessedInput;
624
736
  exports.initialRunState = initialRunState;
625
737
  exports.isActivityOpen = isActivityOpen;
626
738
  exports.isChildOpen = isChildOpen;
627
739
  exports.isCommandEnabled = isCommandEnabled;
740
+ exports.isReliefCommand = isReliefCommand;
628
741
  exports.isWorkflowCommandEnabled = isWorkflowCommandEnabled;
629
742
  exports.pendingCounts = pendingCounts;
630
743
  exports.projectRunState = projectRunState;
631
744
  exports.splitActivations = splitActivations;
632
745
  exports.taskCompletedEvents = taskCompletedEvents;
633
746
  exports.unseenInputs = unseenInputs;
747
+ exports.unsupportedMessage = unsupportedMessage;
634
748
  exports.utf8Bytes = utf8Bytes;
@@ -1,4 +1,4 @@
1
- import { HISTORY_PROTOCOL } from './chunk-DJYMDLV5.js';
1
+ import { HISTORY_PROTOCOL } from './chunk-2DDULZFM.js';
2
2
 
3
3
  function failedTaskResult(cause, message) {
4
4
  return {
@@ -0,0 +1,87 @@
1
+ 'use strict';
2
+
3
+ // src/history/retry.ts
4
+ var DEFAULT_ACTIVITY_RETRY = Object.freeze({
5
+ retryDelay: 1e3,
6
+ backoffMultiplier: 2,
7
+ maxDelay: 1e5
8
+ });
9
+ var FINAL_TIMEOUTS = /* @__PURE__ */ new Set(["SCHEDULE_TO_START", "SCHEDULE_TO_CLOSE"]);
10
+ function computeRetryDelay(policy, attempt, failure) {
11
+ if (failure?.nonRetryable === true) return { retry: false, reason: "nonRetryable" };
12
+ if (failure?.timeoutType !== void 0 && FINAL_TIMEOUTS.has(failure.timeoutType))
13
+ return { retry: false, reason: "finalTimeout" };
14
+ if (failure?.type !== void 0 && policy.nonRetryableErrorTypes !== void 0 && policy.nonRetryableErrorTypes.includes(failure.type))
15
+ return { retry: false, reason: "typeDenied" };
16
+ if (failure !== void 0 && policy.retryOnErrorTypes !== void 0 && policy.retryOnErrorTypes.length > 0 && !policy.retryOnErrorTypes.includes(failure.errorType))
17
+ return { retry: false, reason: "errorTypeNotListed" };
18
+ if (policy.maxRetries !== void 0 && attempt > policy.maxRetries)
19
+ return { retry: false, reason: "maxRetries" };
20
+ if (failure?.nextRetryDelayMs !== void 0)
21
+ return { retry: true, delayMs: Math.max(0, Math.round(failure.nextRetryDelayMs)) };
22
+ const base = Math.max(0, policy.retryDelay);
23
+ const multiplier = policy.backoffMultiplier ?? 2;
24
+ const cap = policy.maxDelay ?? base * 100;
25
+ const exponent = Math.max(0, attempt - 1);
26
+ const delay = Math.min(base * Math.pow(multiplier, exponent), cap);
27
+ return { retry: true, delayMs: Math.round(Number.isFinite(delay) ? delay : cap) };
28
+ }
29
+ function explicitRetryPolicy(policy) {
30
+ const retryDelay = policy?.retryDelay ?? DEFAULT_ACTIVITY_RETRY.retryDelay;
31
+ const out = {
32
+ retryDelay,
33
+ backoffMultiplier: policy?.backoffMultiplier ?? DEFAULT_ACTIVITY_RETRY.backoffMultiplier ?? 2,
34
+ maxDelay: policy?.maxDelay ?? (policy?.retryDelay === void 0 ? 1e5 : Math.max(retryDelay, retryDelay * 100))
35
+ };
36
+ if (policy?.maxRetries !== void 0) out.maxRetries = policy.maxRetries;
37
+ if (policy?.retryOnErrorTypes !== void 0)
38
+ out.retryOnErrorTypes = [...policy.retryOnErrorTypes];
39
+ if (policy?.nonRetryableErrorTypes !== void 0)
40
+ out.nonRetryableErrorTypes = [...policy.nonRetryableErrorTypes];
41
+ return out;
42
+ }
43
+ function computeRunRetryDelay(policy, attempt, failure) {
44
+ if (policy === void 0) return { retry: false, reason: "noPolicy" };
45
+ if (failure.timeoutType === "WORKFLOW_EXECUTION")
46
+ return { retry: false, reason: "executionTimeout" };
47
+ if (policy.maxAttempts !== void 0 && attempt >= policy.maxAttempts)
48
+ return { retry: false, reason: "maxAttempts" };
49
+ const activityPolicy = {
50
+ retryDelay: policy.initialDelayMs,
51
+ ...policy.backoffMultiplier !== void 0 ? { backoffMultiplier: policy.backoffMultiplier } : {},
52
+ ...policy.maxDelayMs !== void 0 ? { maxDelay: policy.maxDelayMs } : {},
53
+ ...policy.retryOnErrorTypes !== void 0 ? { retryOnErrorTypes: policy.retryOnErrorTypes } : {},
54
+ ...policy.nonRetryableErrorTypes !== void 0 ? { nonRetryableErrorTypes: policy.nonRetryableErrorTypes } : {}
55
+ };
56
+ const classified = { ...failure };
57
+ if (classified.timeoutType === "WORKFLOW_RUN") delete classified.timeoutType;
58
+ const decision = computeRetryDelay(activityPolicy, attempt, classified);
59
+ if (decision.retry) return decision;
60
+ switch (decision.reason) {
61
+ case "nonRetryable":
62
+ case "typeDenied":
63
+ case "errorTypeNotListed":
64
+ return { retry: false, reason: decision.reason };
65
+ default:
66
+ return { retry: false, reason: "maxAttempts" };
67
+ }
68
+ }
69
+ function explicitRunRetryPolicy(policy) {
70
+ const initialDelayMs = policy.initialDelayMs ?? DEFAULT_ACTIVITY_RETRY.retryDelay;
71
+ const out = {
72
+ initialDelayMs,
73
+ backoffMultiplier: policy.backoffMultiplier ?? 2,
74
+ maxDelayMs: policy.maxDelayMs ?? (policy.initialDelayMs === void 0 ? 1e5 : Math.max(initialDelayMs, initialDelayMs * 100))
75
+ };
76
+ if (policy.maxAttempts !== void 0) out.maxAttempts = policy.maxAttempts;
77
+ if (policy.retryOnErrorTypes !== void 0) out.retryOnErrorTypes = [...policy.retryOnErrorTypes];
78
+ if (policy.nonRetryableErrorTypes !== void 0)
79
+ out.nonRetryableErrorTypes = [...policy.nonRetryableErrorTypes];
80
+ return out;
81
+ }
82
+
83
+ exports.DEFAULT_ACTIVITY_RETRY = DEFAULT_ACTIVITY_RETRY;
84
+ exports.computeRetryDelay = computeRetryDelay;
85
+ exports.computeRunRetryDelay = computeRunRetryDelay;
86
+ exports.explicitRetryPolicy = explicitRetryPolicy;
87
+ exports.explicitRunRetryPolicy = explicitRunRetryPolicy;
@@ -1,5 +1,5 @@
1
- import { N as NodeManifest } from '../manifest-0OLw0i7k.cjs';
2
- import '../types-BGoPzgcl.cjs';
1
+ import { N as NodeManifest } from '../manifest-gRI2Q5Fj.cjs';
2
+ import '../types-Bb2wRnJ5.cjs';
3
3
 
4
4
  interface GeneratedClients {
5
5
  path: string;
@@ -1,5 +1,5 @@
1
- import { N as NodeManifest } from '../manifest-C8N6HDYl.js';
2
- import '../types-BGoPzgcl.js';
1
+ import { N as NodeManifest } from '../manifest-BJjrQt77.js';
2
+ import '../types-Bb2wRnJ5.js';
3
3
 
4
4
  interface GeneratedClients {
5
5
  path: string;
@@ -0,0 +1,86 @@
1
+ import { P as Position, a as JsonObject, d as ConnectionRef, i as WorkflowAuthoring, W as WorkflowDefinition, b as WorkflowInterface, k as WorkflowConfig } from './types-Bb2wRnJ5.js';
2
+ import { T as Tier1Recording, x as Tier1Workflow } from './workflow-8uRU9rhL.js';
3
+
4
+ declare const LAYOUT_FORMAT = "fluidgrids.layout";
5
+ declare const LAYOUT_FORMAT_VERSION = 1;
6
+ /**
7
+ * The layout sidecar (`workflows/<key>.layout.json`): canvas positions, sticky
8
+ * notes and `meta.layout`, kept out of the code so it stays readable.
9
+ */
10
+ interface LayoutSidecar {
11
+ format: typeof LAYOUT_FORMAT;
12
+ formatVersion: typeof LAYOUT_FORMAT_VERSION;
13
+ positions: Record<string, Position>;
14
+ stickyNotes?: JsonObject[];
15
+ metaLayout?: JsonObject;
16
+ }
17
+ /** How connection names in code resolve to connection references. */
18
+ type ConnectionResolver = Readonly<Record<string, ConnectionRef>> | ((name: string) => ConnectionRef | undefined);
19
+ interface AssembleOptions {
20
+ layout?: LayoutSidecar;
21
+ connections?: ConnectionResolver;
22
+ /** TEST-only pinned data (`workflows/<key>.pinned.json`). */
23
+ pinnedData?: JsonObject;
24
+ /** Provenance; defaults to `{ mode: 'canvas', generator: 'sdk-ts', generatorVersion }`. */
25
+ authoring?: WorkflowAuthoring;
26
+ }
27
+ /** Connection names used in code that the target workspace does not have. */
28
+ declare class UnresolvedConnectionsError extends Error {
29
+ readonly names: string[];
30
+ constructor(names: string[]);
31
+ }
32
+ /** Validate a parsed layout sidecar. */
33
+ declare function parseLayoutSidecar(value: unknown): LayoutSidecar;
34
+ /** Assemble IR v2 from a recording. */
35
+ declare function assembleRecording(recording: Tier1Recording, options?: AssembleOptions): WorkflowDefinition;
36
+ /** Lower a tier-1 workflow to IR v2 (spec 10 §1 `toIR`). */
37
+ declare function toIR(workflow: Tier1Workflow, options?: AssembleOptions): WorkflowDefinition;
38
+
39
+ /**
40
+ * Runs inside the evaluation isolate at the end of a bundle: gathers the
41
+ * recordings of every exported `defineWorkflow` value and the declarations of
42
+ * every exported tier-2 `workflow()` as one JSON string, the only thing that
43
+ * leaves the isolate.
44
+ */
45
+
46
+ declare const COLLECTION_FORMAT = "fluidgrids.tier1-collection";
47
+ interface CollectedWorkflow {
48
+ module: string;
49
+ exportName: string;
50
+ recording: Tier1Recording;
51
+ }
52
+ /** The trigger a standalone tier-2 workflow declares. */
53
+ interface CollectedTrigger {
54
+ nodeType: string;
55
+ version?: string;
56
+ operation?: string;
57
+ args?: JsonObject;
58
+ id?: string;
59
+ }
60
+ /** One exported tier-2 workflow (C-ABI `durable` entries of the collection). */
61
+ interface CollectedDurableWorkflow {
62
+ module: string;
63
+ exportName: string;
64
+ /** The workflow key it gets when standalone. */
65
+ name: string;
66
+ title?: string;
67
+ description?: string;
68
+ taskQueue: string;
69
+ interface: WorkflowInterface;
70
+ standalone?: boolean;
71
+ trigger?: CollectedTrigger;
72
+ /** Run-level settings the declaration lowers into `config` (R2). */
73
+ config?: WorkflowConfig;
74
+ /** Runtime features its options use (C-FEATURES): `autoUpgrade`, `runRetry`, `timeouts`. */
75
+ features?: string[];
76
+ }
77
+ interface Tier1Collection {
78
+ format: typeof COLLECTION_FORMAT;
79
+ workflows: CollectedWorkflow[];
80
+ /** Tier-2 functions; absent when the bundle has none. */
81
+ durable?: CollectedDurableWorkflow[];
82
+ }
83
+ /** Collect the workflows exported by each module, as JSON. */
84
+ declare function collectWorkflowExports(modules: ReadonlyArray<readonly [string, Record<string, unknown>]>): string;
85
+
86
+ export { type AssembleOptions as A, COLLECTION_FORMAT as C, LAYOUT_FORMAT as L, type Tier1Collection as T, UnresolvedConnectionsError as U, type CollectedDurableWorkflow as a, type CollectedTrigger as b, type CollectedWorkflow as c, type ConnectionResolver as d, LAYOUT_FORMAT_VERSION as e, type LayoutSidecar as f, assembleRecording as g, collectWorkflowExports as h, parseLayoutSidecar as p, toIR as t };