@fluidgrids/workflows 2026.1028.2 → 2026.1030.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 (154) hide show
  1. package/README.md +181 -11
  2. package/dist/{activation-BBh1p82z.d.cts → activation-DqUfpHzk.d.cts} +1 -1
  3. package/dist/{activation-DnhG7SmF.d.ts → activation-xpx1oWuo.d.ts} +1 -1
  4. package/dist/{chunk-VRHHBPT6.js → chunk-2D3MYIIF.js} +1212 -128
  5. package/dist/chunk-3U2NU7YC.cjs +124 -0
  6. package/dist/{chunk-NEIUQASE.cjs → chunk-4QKB4ARC.cjs} +3 -3
  7. package/dist/{chunk-GBQ33SIZ.cjs → chunk-54FLQNUM.cjs} +12 -1
  8. package/dist/chunk-5HIVIV53.js +330 -0
  9. package/dist/chunk-5MFVJM76.js +1222 -0
  10. package/dist/{chunk-JD2VQIDZ.cjs → chunk-672KMMBK.cjs} +2 -2
  11. package/dist/{chunk-C5OLWZ42.js → chunk-6A2FGSUS.js} +22 -14
  12. package/dist/{chunk-XKJA7KX3.js → chunk-6OLN6BMB.js} +52 -3
  13. package/dist/{chunk-6FSHT5IL.js → chunk-7EZIANC7.js} +1 -1
  14. package/dist/{chunk-2J6TF7YI.cjs → chunk-A5SXCA62.cjs} +10 -3
  15. package/dist/{chunk-BO6OVILK.js → chunk-AC6ZEXVR.js} +10 -4
  16. package/dist/{chunk-ABFZWYHT.js → chunk-AE5Q6ZAJ.js} +315 -50
  17. package/dist/chunk-C4F5KJTI.js +293 -0
  18. package/dist/{chunk-IISBRUWJ.js → chunk-G5H32GIG.js} +1 -1
  19. package/dist/chunk-GEQDGUGB.cjs +2719 -0
  20. package/dist/{chunk-XHXIDVEC.js → chunk-HCM7ZC7Q.js} +1 -1
  21. package/dist/chunk-HMZUGSMU.cjs +1554 -0
  22. package/dist/{chunk-SAOBPYYJ.cjs → chunk-IQPXHQQQ.cjs} +8 -4
  23. package/dist/{chunk-P6TA5EZT.cjs → chunk-ISOIA7NV.cjs} +335 -58
  24. package/dist/chunk-JSC75O5C.cjs +167 -0
  25. package/dist/chunk-M272AHEX.js +25 -0
  26. package/dist/{chunk-BD7ZPG53.js → chunk-NWQ5WRLE.js} +10 -2
  27. package/dist/chunk-ODZ2IAR2.cjs +1247 -0
  28. package/dist/chunk-Q4MWQNJK.cjs +28 -0
  29. package/dist/{chunk-HWJZVOG7.js → chunk-SR7TR5KX.js} +6 -2
  30. package/dist/{chunk-FEW3JBYA.cjs → chunk-TCTE7DX5.cjs} +3 -3
  31. package/dist/{chunk-623FVQSN.cjs → chunk-TYF56RGB.cjs} +123 -0
  32. package/dist/chunk-VA4OFR72.cjs +324 -0
  33. package/dist/chunk-VU5S5A7V.js +150 -0
  34. package/dist/chunk-YEHR4NNE.js +1522 -0
  35. package/dist/{chunk-FMSW2HDF.cjs → chunk-ZCGKGDCL.cjs} +23 -15
  36. package/dist/codegen/index.d.cts +2 -2
  37. package/dist/codegen/index.d.ts +2 -2
  38. package/dist/collect-6NIEufHd.d.ts +103 -0
  39. package/dist/collect-CcTCKqx6.d.cts +103 -0
  40. package/dist/{file-BOoHZgoQ.d.cts → file-BxYpwjRQ.d.cts} +1007 -21
  41. package/dist/{file-yuPCFU5b.d.ts → file-CFdPQJI9.d.ts} +1007 -21
  42. package/dist/history/index.cjs +375 -86
  43. package/dist/history/index.d.cts +590 -12
  44. package/dist/history/index.d.ts +590 -12
  45. package/dist/history/index.js +50 -4
  46. package/dist/index.cjs +156 -50
  47. package/dist/index.d.cts +38 -58
  48. package/dist/index.d.ts +38 -58
  49. package/dist/index.js +6 -4
  50. package/dist/interceptors-CNcr2dlk.d.ts +159 -0
  51. package/dist/interceptors-CqkNZVfI.d.cts +159 -0
  52. package/dist/ir/index.cjs +362 -38
  53. package/dist/ir/index.d.cts +282 -7
  54. package/dist/ir/index.d.ts +282 -7
  55. package/dist/ir/index.js +329 -23
  56. package/dist/{lower-BzmUz0sq.d.cts → lower-BtRfIW2A.d.cts} +56 -8
  57. package/dist/{lower-_-iT4HYs.d.ts → lower-CpsMFOFX.d.ts} +56 -8
  58. package/dist/{manifest-C8N6HDYl.d.ts → manifest-D-I_twys.d.ts} +1 -1
  59. package/dist/{manifest-0OLw0i7k.d.cts → manifest-DahBQVM8.d.cts} +1 -1
  60. package/dist/node-evaluator-DGQDPSPI.cjs +24 -0
  61. package/dist/node-evaluator-LEEVD7H7.js +14 -0
  62. package/dist/payload-fields-BVRQn2yH.d.cts +122 -0
  63. package/dist/payload-fields-oOBWxDiG.d.ts +122 -0
  64. package/dist/quickjs/index.cjs +28 -27
  65. package/dist/quickjs/index.d.cts +6 -6
  66. package/dist/quickjs/index.d.ts +6 -6
  67. package/dist/quickjs/index.js +10 -9
  68. package/dist/roundtrip/index.cjs +259 -51
  69. package/dist/roundtrip/index.d.cts +100 -9
  70. package/dist/roundtrip/index.d.ts +100 -9
  71. package/dist/roundtrip/index.js +177 -11
  72. package/dist/runtime/index.cjs +21 -20
  73. package/dist/runtime/index.d.cts +184 -15
  74. package/dist/runtime/index.d.ts +184 -15
  75. package/dist/runtime/index.js +8 -7
  76. package/dist/testing/index.cjs +1122 -115
  77. package/dist/testing/index.d.cts +294 -13
  78. package/dist/testing/index.d.ts +294 -13
  79. package/dist/testing/index.js +1086 -84
  80. package/dist/{types-DV-HX_Gt.d.ts → types-Bv2i4cBX.d.cts} +244 -33
  81. package/dist/{types-CpBBjaGX.d.cts → types-DGx-b9eq.d.ts} +244 -33
  82. package/dist/{types-BGoPzgcl.d.ts → types-V7jEEUaL.d.cts} +20 -1
  83. package/dist/{types-BGoPzgcl.d.cts → types-V7jEEUaL.d.ts} +20 -1
  84. package/dist/{workflow-Bpr3vnA_.d.ts → workflow-B18OeF7g.d.ts} +2 -2
  85. package/dist/workflow-BGnv8SS6.d.ts +803 -0
  86. package/dist/{workflow-FXUkpIBc.d.cts → workflow-BJPFv3cp.d.cts} +2 -2
  87. package/dist/workflow-DS32Gtws.d.cts +803 -0
  88. package/fixtures/histories/activity-options-updated.history.json +159 -0
  89. package/fixtures/histories/activity-paused-unpaused.history.json +160 -0
  90. package/fixtures/histories/auto-upgrade-patched.history.json +276 -0
  91. package/fixtures/histories/benign-failure.history.json +146 -0
  92. package/fixtures/histories/cancel-activity-try-cancel.history.json +150 -0
  93. package/fixtures/histories/child-cancel-wait-requested.history.json +217 -0
  94. package/fixtures/histories/child-options-roundtrip.history.json +192 -0
  95. package/fixtures/histories/codec-opaque.history.json +229 -0
  96. package/fixtures/histories/continue-as-new-last-result.history.json +86 -0
  97. package/fixtures/histories/continue-as-new-options.history.json +99 -0
  98. package/fixtures/histories/continue-as-new-r1-long-task-queue.history.json +78 -0
  99. package/fixtures/histories/continue-as-new-r1-retry-options.history.json +83 -0
  100. package/fixtures/histories/dynamic-workflow.history.json +150 -0
  101. package/fixtures/histories/execution-timeout-chain.history.json +98 -0
  102. package/fixtures/histories/external-cancel-resolved.history.json +123 -0
  103. package/fixtures/histories/external-cancel-unknown-target.history.json +127 -0
  104. package/fixtures/histories/failure-error-types-fails-run.history.json +144 -0
  105. package/fixtures/histories/handler-drain-warn.history.json +222 -0
  106. package/fixtures/histories/heartbeat-details-on-retry.history.json +145 -0
  107. package/fixtures/histories/interceptor-headers.history.json +339 -0
  108. package/fixtures/histories/local-activity-abandoned-at-completion.history.json +73 -0
  109. package/fixtures/histories/local-activity-cancelled-in-scope.history.json +118 -0
  110. package/fixtures/histories/local-activity-completed.history.json +157 -0
  111. package/fixtures/histories/local-activity-failed.history.json +93 -0
  112. package/fixtures/histories/local-activity-retry-in-task.history.json +88 -0
  113. package/fixtures/histories/query-custom.history.json +213 -0
  114. package/fixtures/histories/query-default-handler.history.json +120 -0
  115. package/fixtures/histories/reset-forked-reapplied-signals.history.json +239 -0
  116. package/fixtures/histories/reset-reapplied-update-admitted.history.json +228 -0
  117. package/fixtures/histories/run-retry-last-failure.history.json +90 -0
  118. package/fixtures/histories/run-timeout.history.json +159 -0
  119. package/fixtures/histories/schedule-to-start-timeout.history.json +132 -0
  120. package/fixtures/histories/search-attributes-upserted.history.json +177 -0
  121. package/fixtures/histories/start-delay-signal-ends-delay.history.json +155 -0
  122. package/fixtures/histories/typeerror-task-retry-100.history.json +137 -0
  123. package/fixtures/histories/update-accepted-completed.history.json +45 -30
  124. package/fixtures/histories/update-default-handler.history.json +246 -0
  125. package/fixtures/histories/update-handler-awaits-activity.history.json +196 -0
  126. package/fixtures/histories/update-not-handled.history.json +138 -0
  127. package/fixtures/histories/update-rejected-no-event.history.json +190 -0
  128. package/fixtures/histories/update-with-start-admitted.history.json +150 -0
  129. package/fixtures/histories/user-activity-cancel.history.json +149 -0
  130. package/fixtures/histories/user-activity-retry.history.json +143 -0
  131. package/fixtures/histories/user-activity.history.json +149 -0
  132. package/package.json +1 -1
  133. package/schema/bridge-v2.schema.json +1062 -0
  134. package/schema/history-file.schema.json +538 -83
  135. package/schema/ir-v2.schema.json +290 -0
  136. package/schema/payload-fields.json +162 -0
  137. package/schema/run-event.schema.json +503 -82
  138. package/schema/workflow-command.schema.json +372 -69
  139. package/schema/workflow-task.schema.json +924 -171
  140. package/dist/assemble-BLqQ8lSu.d.cts +0 -39
  141. package/dist/assemble-DWgaXHd-.d.ts +0 -39
  142. package/dist/chunk-DHTLALBL.cjs +0 -80
  143. package/dist/chunk-DJYMDLV5.js +0 -227
  144. package/dist/chunk-I5LR3D2K.js +0 -869
  145. package/dist/chunk-M4BBAERY.cjs +0 -1635
  146. package/dist/chunk-N23SKIG4.js +0 -73
  147. package/dist/chunk-PZCVF76Q.cjs +0 -868
  148. package/dist/chunk-QQ6ULXHI.cjs +0 -885
  149. package/dist/chunk-UK3WM7YZ.cjs +0 -75
  150. package/dist/chunk-VOKMAAJP.js +0 -848
  151. package/dist/node-evaluator-4MSDKWOG.cjs +0 -22
  152. package/dist/node-evaluator-SX4LEYQC.js +0 -12
  153. package/dist/workflow-C2a05WUJ.d.ts +0 -444
  154. package/dist/workflow-J-yYixny.d.cts +0 -444
@@ -4,7 +4,7 @@ var chunkG4UEPUGO_cjs = require('./chunk-G4UEPUGO.cjs');
4
4
  var chunkGVTZMA5C_cjs = require('./chunk-GVTZMA5C.cjs');
5
5
  var chunkTBDXTV22_cjs = require('./chunk-TBDXTV22.cjs');
6
6
  var chunkSAENRNBJ_cjs = require('./chunk-SAENRNBJ.cjs');
7
- var chunkDHTLALBL_cjs = require('./chunk-DHTLALBL.cjs');
7
+ var chunkVA4OFR72_cjs = require('./chunk-VA4OFR72.cjs');
8
8
 
9
9
  // src/builder/descriptors.ts
10
10
  function op(nodeType, version, operation) {
@@ -63,7 +63,11 @@ var internalNodes = {
63
63
  respondToWebhook: op("internal:respond-to-webhook"),
64
64
  sendAndWait: op("internal:send-and-wait"),
65
65
  codeWorkflow: op("internal:code-workflow"),
66
- waitForSignal: op("internal:wait-for-signal")
66
+ waitForSignal: op("internal:wait-for-signal"),
67
+ /** Phase C: signal another run (`fluidgrids.run-control`). */
68
+ signalRun: op("internal:signal-run"),
69
+ /** Phase C: upsert the run's search attributes (`fluidgrids.search-attributes`). */
70
+ setSearchAttributes: op("internal:set-search-attributes")
67
71
  };
68
72
  var nodes = {
69
73
  internal: internalNodes,
@@ -334,7 +338,7 @@ var WorkflowBuilder = class {
334
338
  let workflowFn;
335
339
  let definition;
336
340
  if (typeof fn === "string" && fn !== "") workflowFn = fn;
337
- else if (chunkDHTLALBL_cjs.isDurableWorkflow(fn)) {
341
+ else if (chunkVA4OFR72_cjs.isDurableWorkflow(fn)) {
338
342
  definition = fn;
339
343
  workflowFn = fn.name;
340
344
  } else throw new chunkGVTZMA5C_cjs.BuilderError("wf.codeWorkflow needs a workflow() function or its export name");
@@ -755,7 +759,7 @@ function assembleRecording(recording, options = {}) {
755
759
  const authoring = options.authoring ?? {
756
760
  mode: "canvas",
757
761
  generator: "sdk-ts",
758
- generatorVersion: chunkDHTLALBL_cjs.SDK_VERSION
762
+ generatorVersion: chunkVA4OFR72_cjs.SDK_VERSION
759
763
  };
760
764
  const out = { schemaVersion: 2 };
761
765
  for (const key of ["key", "name", "description", "interface", "code"]) {
@@ -1,17 +1,204 @@
1
1
  'use strict';
2
2
 
3
- var chunk623FVQSN_cjs = require('./chunk-623FVQSN.cjs');
4
- var chunk2J6TF7YI_cjs = require('./chunk-2J6TF7YI.cjs');
3
+ var chunkA5SXCA62_cjs = require('./chunk-A5SXCA62.cjs');
4
+ var chunkTYF56RGB_cjs = require('./chunk-TYF56RGB.cjs');
5
5
 
6
6
  // src/history/commands.ts
7
+ var COMMAND_FEATURES = [
8
+ "core",
9
+ "parity.can",
10
+ "parity.context",
11
+ "parity.localActivity",
12
+ "parity.externalCancel",
13
+ "parity.childOptions",
14
+ "parity.canOptions",
15
+ "parity.workflowIdTarget",
16
+ "c.updates",
17
+ "c.searchAttributes",
18
+ "c.userActivity"
19
+ ];
20
+ var PHASE_B_CORE_FEATURES = /* @__PURE__ */ new Set([
21
+ "core",
22
+ "parity.can",
23
+ "parity.context"
24
+ ]);
25
+ var PHASE_B_PARITY_FEATURES = /* @__PURE__ */ new Set([
26
+ "core",
27
+ "parity.can",
28
+ "parity.context",
29
+ "parity.localActivity",
30
+ "parity.externalCancel",
31
+ "parity.childOptions",
32
+ "parity.canOptions",
33
+ "parity.workflowIdTarget"
34
+ ]);
35
+ var PHASE_C_FEATURES = [
36
+ "c.updates",
37
+ "c.searchAttributes",
38
+ "c.userActivity"
39
+ ];
40
+ var PHASE_C_FEATURE_FLAGS = {
41
+ "c.updates": "fluidgrids.run-control",
42
+ "c.searchAttributes": "fluidgrids.search-attributes",
43
+ "c.userActivity": "fluidgrids.self-hosted-workers"
44
+ };
45
+ var CODE_FEATURE_FLAGS = {
46
+ localActivity: "fluidgrids.durable-parity",
47
+ externalCancel: "fluidgrids.durable-parity",
48
+ childOptions: "fluidgrids.durable-parity",
49
+ canOptions: "fluidgrids.durable-parity",
50
+ autoUpgrade: "fluidgrids.durable-parity",
51
+ runRetry: "fluidgrids.durable-parity",
52
+ timeouts: "fluidgrids.durable-parity",
53
+ userActivity: "fluidgrids.self-hosted-workers",
54
+ updates: "fluidgrids.run-control",
55
+ queries: "fluidgrids.run-control",
56
+ dynamic: "fluidgrids.run-control",
57
+ interceptors: "fluidgrids.run-control",
58
+ searchAttributes: "fluidgrids.search-attributes"
59
+ };
60
+ var PHASE_C_CODE_FEATURES = [
61
+ "userActivity",
62
+ "updates",
63
+ "queries",
64
+ "searchAttributes",
65
+ "dynamic",
66
+ "interceptors"
67
+ ];
68
+ var CORE_CHILD_OPTIONS = /* @__PURE__ */ new Set([
69
+ "parentClosePolicy",
70
+ "cancellationType",
71
+ "taskQueue",
72
+ "workflowId",
73
+ "priority",
74
+ "summary",
75
+ "details",
76
+ "context",
77
+ "startDelay",
78
+ "executionTimeout",
79
+ "runTimeout",
80
+ "workflowTaskTimeout",
81
+ "fairnessKey",
82
+ "fairnessWeight"
83
+ ]);
84
+ var CORE_CAN_OPTIONS = /* @__PURE__ */ new Set([
85
+ "taskQueue",
86
+ "retry",
87
+ "workflowTaskTimeout",
88
+ "context",
89
+ "versioningBehavior"
90
+ ]);
91
+ var LEGACY_RETRY_KEYS = ["retryDelay", "maxRetries", "maxDelay"];
92
+ var RUN_RETRY_KEYS = ["initialDelayMs", "maxAttempts", "maxDelayMs"];
93
+ function continueAsNewRetryShape(options) {
94
+ const retry = options["retry"];
95
+ if (retry === void 0) return "none";
96
+ if (typeof retry !== "object" || retry === null || Array.isArray(retry)) return "invalid";
97
+ const keys = Object.keys(retry);
98
+ const run = keys.some((key) => RUN_RETRY_KEYS.includes(key));
99
+ const legacy = keys.some((key) => LEGACY_RETRY_KEYS.includes(key));
100
+ if (run === legacy) return "invalid";
101
+ return run ? "run" : "legacy";
102
+ }
103
+ function hasOtherKeys(value, allowed) {
104
+ return Object.entries(value).some(([key, entry]) => entry !== void 0 && !allowed.has(key));
105
+ }
106
+ function commandFeatures(command) {
107
+ const needed = /* @__PURE__ */ new Set();
108
+ switch (command.type) {
109
+ case "SCHEDULE_ACTIVITY":
110
+ needed.add(command.kind === "user" ? "c.userActivity" : "core");
111
+ break;
112
+ case "START_CHILD_RUN":
113
+ needed.add("core");
114
+ if (hasOtherKeys(command.options, CORE_CHILD_OPTIONS)) needed.add("parity.childOptions");
115
+ break;
116
+ case "SIGNAL_RUN":
117
+ needed.add("core");
118
+ if ("workflowId" in command.target) needed.add("parity.workflowIdTarget");
119
+ break;
120
+ case "REQUEST_CANCEL_EXTERNAL_RUN":
121
+ if ("childId" in command.target) needed.add("core");
122
+ else needed.add("parity.externalCancel");
123
+ if ("workflowId" in command.target) needed.add("parity.workflowIdTarget");
124
+ break;
125
+ case "CONTINUE_AS_NEW":
126
+ needed.add("parity.can");
127
+ if (hasOtherKeys(command.options, CORE_CAN_OPTIONS) || continueAsNewRetryShape(command.options) === "run")
128
+ needed.add("parity.canOptions");
129
+ break;
130
+ case "UPSERT_CONTEXT":
131
+ needed.add("parity.context");
132
+ break;
133
+ case "RECORD_LOCAL_ACTIVITY":
134
+ needed.add("parity.localActivity");
135
+ break;
136
+ case "UPSERT_SEARCH_ATTRIBUTES":
137
+ needed.add("c.searchAttributes");
138
+ break;
139
+ case "ACCEPT_UPDATE":
140
+ case "REJECT_UPDATE":
141
+ case "COMPLETE_UPDATE":
142
+ needed.add("c.updates");
143
+ break;
144
+ default:
145
+ needed.add("core");
146
+ }
147
+ return COMMAND_FEATURES.filter((feature) => needed.has(feature));
148
+ }
7
149
  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);
150
+ if (chunkTYF56RGB_cjs.PHASE_C_COMMANDS.has(type)) return false;
151
+ if (chunkTYF56RGB_cjs.PHASE_B_CORE_COMMANDS.has(type)) return true;
152
+ return enabled === "parity" && chunkTYF56RGB_cjs.PHASE_B_PARITY_COMMANDS.has(type);
153
+ }
154
+ function phaseCFeaturesOf(command) {
155
+ return commandFeatures(command).filter((feature) => feature.startsWith("c."));
11
156
  }
12
157
  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);
158
+ if (typeof enabled === "string") {
159
+ if (phaseCFeaturesOf(command).length > 0) return false;
160
+ if (command.type === "REQUEST_CANCEL_EXTERNAL_RUN" && "childId" in command.target) return true;
161
+ return isCommandEnabled(command.type, enabled);
162
+ }
163
+ return commandFeatures(command).every((feature) => enabled.has(feature));
164
+ }
165
+ function codeFeaturesEnabledBy(enabled) {
166
+ if (typeof enabled === "string") return [];
167
+ const flags = /* @__PURE__ */ new Set(["fluidgrids.durable-functions"]);
168
+ for (const feature of enabled) {
169
+ if (PHASE_B_PARITY_FEATURES.has(feature) && !PHASE_B_CORE_FEATURES.has(feature))
170
+ flags.add("fluidgrids.durable-parity");
171
+ const flag = PHASE_C_FEATURE_FLAGS[feature];
172
+ if (flag !== void 0) flags.add(flag);
173
+ }
174
+ return Object.keys(CODE_FEATURE_FLAGS).filter((feature) => flags.has(CODE_FEATURE_FLAGS[feature] ?? "")).sort();
175
+ }
176
+ function unsupportedMessage(command, enabled = "core") {
177
+ const missing = typeof enabled === "string" ? phaseCFeaturesOf(command) : commandFeatures(command).filter((feature) => !enabled.has(feature));
178
+ if (missing.length === 0) return `${command.type} is not supported in this release`;
179
+ const flags = /* @__PURE__ */ new Set();
180
+ if (missing.some((feature) => feature.startsWith("parity.")))
181
+ flags.add("fluidgrids.durable-parity");
182
+ for (const feature of missing) {
183
+ const flag2 = PHASE_C_FEATURE_FLAGS[feature];
184
+ if (flag2 !== void 0) flags.add(flag2);
185
+ }
186
+ const names = [...flags];
187
+ const flag = names.length === 0 ? "" : ` (needs the ${names.join(" and ")} flag${names.length === 1 ? "" : "s"})`;
188
+ return `${command.type} needs ${missing.join(", ")}, which this workspace does not enable${flag}`;
189
+ }
190
+ function isReliefCommand(command, lease) {
191
+ switch (command.type) {
192
+ case "RECORD_LOCAL_ACTIVITY":
193
+ return lease.grantedLocalActivityIds.includes(command.localActivityId);
194
+ case "ACCEPT_UPDATE":
195
+ case "REJECT_UPDATE":
196
+ return lease.deliveredUpdateIds.includes(command.updateId);
197
+ case "COMPLETE_UPDATE":
198
+ return true;
199
+ default:
200
+ return false;
201
+ }
15
202
  }
16
203
 
17
204
  // src/history/activation.ts
@@ -64,10 +251,10 @@ function walk(history) {
64
251
  continue;
65
252
  }
66
253
  }
67
- if (chunk623FVQSN_cjs.isInputEvent(event)) {
254
+ if (chunkTYF56RGB_cjs.isInputEvent(event)) {
68
255
  if (started) afterStarted.push(event);
69
256
  else pending.push(event);
70
- } else if (chunk623FVQSN_cjs.isCommandEvent(event) && last?.recorded) {
257
+ } else if (chunkTYF56RGB_cjs.isCommandEvent(event) && last?.recorded) {
71
258
  last.recorded.push(event);
72
259
  }
73
260
  }
@@ -109,12 +296,23 @@ function initialRunState() {
109
296
  timers: {},
110
297
  children: {},
111
298
  externals: {},
299
+ localActivities: {},
112
300
  sideEffects: {},
113
301
  markers: {},
114
302
  signalsReceived: 0,
115
- context: {}
303
+ context: {},
304
+ updates: {},
305
+ searchAttributes: {}
116
306
  };
117
307
  }
308
+ function mergeSearchAttributes(current, entries) {
309
+ const out = { ...current };
310
+ for (const [key, value] of Object.entries(entries)) {
311
+ if (value === null) delete out[key];
312
+ else out[key] = value;
313
+ }
314
+ return out;
315
+ }
118
316
  function utf8Bytes(text) {
119
317
  let bytes = 0;
120
318
  for (let index = 0; index < text.length; index++) {
@@ -189,6 +387,8 @@ function applyEvent(state, event) {
189
387
  state.input = p["input"] ?? null;
190
388
  if (typeof p["context"] === "object" && p["context"] !== null && !Array.isArray(p["context"]))
191
389
  state.context = { ...p["context"] };
390
+ if (typeof p["searchAttributes"] === "object" && p["searchAttributes"] !== null && !Array.isArray(p["searchAttributes"]))
391
+ state.searchAttributes = mergeSearchAttributes({}, p["searchAttributes"]);
192
392
  break;
193
393
  case "WORKFLOW_TASK_SCHEDULED":
194
394
  state.task = { state: "SCHEDULED", taskId: str(p, "taskId"), attempt: state.task.attempt };
@@ -213,11 +413,14 @@ function applyEvent(state, event) {
213
413
  const id = str(p, "activityId");
214
414
  if (state.activities[id])
215
415
  throw new HistoryStateError(`Activity "${id}" is scheduled twice`, event.seq);
416
+ const user = p["kind"] === "user";
216
417
  state.activities[id] = {
217
418
  status: "SCHEDULED",
218
419
  attempt: 0,
420
+ kind: user ? "user" : "node",
219
421
  nodeType: str(p, "nodeType"),
220
422
  operation: str(p, "operation"),
423
+ ...user ? { activityName: str(p, "activityName"), taskQueue: str(p, "taskQueue") } : {},
221
424
  scheduledSeq: event.seq,
222
425
  ...typeof p["cancellationType"] === "string" ? { cancellationType: p["cancellationType"] } : {},
223
426
  ...typeof p["summary"] === "string" ? { summary: p["summary"] } : {}
@@ -348,9 +551,61 @@ function applyEvent(state, event) {
348
551
  case "SIDE_EFFECT_RECORDED":
349
552
  state.sideEffects[str(p, "sideEffectId")] = p["value"] ?? null;
350
553
  break;
554
+ case "LOCAL_ACTIVITY_COMPLETED":
555
+ case "LOCAL_ACTIVITY_FAILED": {
556
+ const id = str(p, "localActivityId");
557
+ if (state.localActivities[id])
558
+ throw new HistoryStateError(`Local activity "${id}" is recorded twice`, event.seq);
559
+ state.localActivities[id] = {
560
+ status: event.type === "LOCAL_ACTIVITY_COMPLETED" ? "COMPLETED" : "FAILED",
561
+ attempts: typeof p["attempts"] === "number" ? p["attempts"] : 1,
562
+ recordedSeq: event.seq,
563
+ ...typeof p["nodeType"] === "string" ? { nodeType: p["nodeType"] } : {},
564
+ ...typeof p["operation"] === "string" ? { operation: p["operation"] } : {},
565
+ ...typeof p["summary"] === "string" ? { summary: p["summary"] } : {}
566
+ };
567
+ break;
568
+ }
351
569
  case "MARKER_RECORDED":
352
570
  state.markers[str(p, "markerId")] = p["data"] ?? null;
353
571
  break;
572
+ case "UPDATE_ADMITTED": {
573
+ const id = str(p, "updateId");
574
+ if (state.updates[id])
575
+ throw new HistoryStateError(`Update "${id}" is admitted twice`, event.seq);
576
+ state.updates[id] = { status: "ADMITTED", name: str(p, "name"), seq: event.seq };
577
+ break;
578
+ }
579
+ case "UPDATE_ACCEPTED": {
580
+ const id = str(p, "updateId");
581
+ const found = state.updates[id];
582
+ if (found && found.status !== "ADMITTED")
583
+ throw new HistoryStateError(`Update "${id}" is accepted twice`, event.seq);
584
+ state.updates[id] = {
585
+ status: "ACCEPTED",
586
+ name: found?.name ?? str(p, "name"),
587
+ seq: found?.seq ?? event.seq
588
+ };
589
+ break;
590
+ }
591
+ case "UPDATE_COMPLETED": {
592
+ const id = str(p, "updateId");
593
+ const found = state.updates[id];
594
+ if (!found || found.status !== "ACCEPTED")
595
+ throw new HistoryStateError(
596
+ `UPDATE_COMPLETED for update "${id}" that is not accepted`,
597
+ event.seq
598
+ );
599
+ found.status = "COMPLETED";
600
+ if (failureOf(p)) found.failed = true;
601
+ break;
602
+ }
603
+ case "SEARCH_ATTRIBUTES_UPSERTED": {
604
+ const attributes = p["attributes"];
605
+ if (typeof attributes === "object" && attributes !== null && !Array.isArray(attributes))
606
+ state.searchAttributes = mergeSearchAttributes(state.searchAttributes, attributes);
607
+ break;
608
+ }
354
609
  case "CONTEXT_UPSERTED": {
355
610
  const entries = p["entries"];
356
611
  if (typeof entries === "object" && entries !== null && !Array.isArray(entries))
@@ -406,6 +661,11 @@ function payloadOf(command) {
406
661
  }
407
662
  return out;
408
663
  }
664
+ function completedPayload(command) {
665
+ if (command.failure !== void 0)
666
+ return { updateId: command.updateId, failure: command.failure };
667
+ return { updateId: command.updateId, result: command.result ?? null };
668
+ }
409
669
  function eventsForCommands(state, commands, context) {
410
670
  const issues = [];
411
671
  const events = [];
@@ -423,21 +683,24 @@ function eventsForCommands(state, commands, context) {
423
683
  const children = new Set(Object.keys(state.children));
424
684
  const externals = new Set(Object.keys(state.externals));
425
685
  const sideEffects = new Set(Object.keys(state.sideEffects));
686
+ const localActivities = new Set(Object.keys(state.localActivities));
687
+ const updates = new Map(Object.entries(state.updates).map(([id, u]) => [id, u.status]));
688
+ const answered = /* @__PURE__ */ new Set();
426
689
  let unsupported = false;
427
690
  commands.forEach((command, index) => {
428
- if (!isWorkflowCommandEnabled(command, context.enabled)) {
691
+ if (!isWorkflowCommandEnabled(command, context.enabled) && !(context.relief !== void 0 && isReliefCommand(command, context.relief))) {
429
692
  unsupported = true;
430
- reject(index, "commands.unsupported", `${command.type} is not supported in this release`);
693
+ reject(index, "commands.unsupported", unsupportedMessage(command, context.enabled));
431
694
  return;
432
695
  }
433
- if (chunk623FVQSN_cjs.TERMINAL_COMMANDS.has(command.type) && index !== commands.length - 1)
696
+ if (chunkTYF56RGB_cjs.TERMINAL_COMMANDS.has(command.type) && index !== commands.length - 1)
434
697
  reject(index, "commands.terminalNotLast", `${command.type} must be last`);
435
698
  const base = { taskId: context.taskId };
436
699
  switch (command.type) {
437
700
  case "SCHEDULE_ACTIVITY":
438
701
  if (activities.has(command.activityId))
439
702
  reject(index, "activity.duplicate", `Activity "${command.activityId}" already exists`);
440
- if (!chunk2J6TF7YI_cjs.isActivityNodeTypeAllowed(command.nodeType))
703
+ if (command.kind === "node" && !chunkA5SXCA62_cjs.isActivityNodeTypeAllowed(command.nodeType))
441
704
  reject(
442
705
  index,
443
706
  "durable.activityTypeNotAllowed",
@@ -518,6 +781,13 @@ function eventsForCommands(state, commands, context) {
518
781
  events.push({ ...base, type: "CONTEXT_UPSERTED", payload: payloadOf(command) });
519
782
  break;
520
783
  case "RECORD_LOCAL_ACTIVITY":
784
+ if (localActivities.has(command.localActivityId))
785
+ reject(
786
+ index,
787
+ "localActivity.duplicate",
788
+ `Local activity "${command.localActivityId}" is already recorded`
789
+ );
790
+ localActivities.add(command.localActivityId);
521
791
  events.push({
522
792
  ...base,
523
793
  type: command.failure ? "LOCAL_ACTIVITY_FAILED" : "LOCAL_ACTIVITY_COMPLETED",
@@ -527,6 +797,42 @@ function eventsForCommands(state, commands, context) {
527
797
  case "CONTINUE_AS_NEW":
528
798
  events.push({ ...base, type: "WORKFLOW_CONTINUED_AS_NEW", payload: payloadOf(command) });
529
799
  break;
800
+ case "UPSERT_SEARCH_ATTRIBUTES":
801
+ events.push({ ...base, type: "SEARCH_ATTRIBUTES_UPSERTED", payload: payloadOf(command) });
802
+ break;
803
+ case "ACCEPT_UPDATE":
804
+ case "REJECT_UPDATE": {
805
+ const id = command.updateId;
806
+ const status = updates.get(id);
807
+ const delivered = context.updates?.[id];
808
+ if (answered.has(id) || status !== void 0 && status !== "ADMITTED") {
809
+ reject(index, "update.answered", `Update "${id}" is already answered`);
810
+ break;
811
+ }
812
+ if (status === void 0 && delivered === void 0) {
813
+ reject(index, "update.unknown", `Update "${id}" was not delivered to this task`);
814
+ break;
815
+ }
816
+ answered.add(id);
817
+ if (command.type === "REJECT_UPDATE") break;
818
+ updates.set(id, "ACCEPTED");
819
+ const admitted = state.updates[id];
820
+ const payload = { updateId: id, name: admitted?.name ?? delivered?.name ?? "" };
821
+ if (delivered?.args !== void 0) payload["args"] = delivered.args;
822
+ if (delivered?.headers !== void 0) payload["headers"] = { ...delivered.headers };
823
+ events.push({ ...base, type: "UPDATE_ACCEPTED", payload });
824
+ break;
825
+ }
826
+ case "COMPLETE_UPDATE": {
827
+ const id = command.updateId;
828
+ if (updates.get(id) !== "ACCEPTED") {
829
+ reject(index, "update.notAccepted", `Update "${id}" is not accepted`);
830
+ break;
831
+ }
832
+ updates.set(id, "COMPLETED");
833
+ events.push({ ...base, type: "UPDATE_COMPLETED", payload: completedPayload(command) });
834
+ break;
835
+ }
530
836
  }
531
837
  });
532
838
  if (issues.length > 0)
@@ -561,47 +867,6 @@ function hasUnprocessedInput(history) {
561
867
  return unseenInputs(history).length > 0;
562
868
  }
563
869
 
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
870
  // src/history/defaults.ts
606
871
  function codeWorkflowParentClosePolicy(state) {
607
872
  const policy = state.parentClosePolicy;
@@ -613,22 +878,34 @@ var CHILD_DEFAULT_CANCELLATION_TYPE = "WAIT_CANCELLATION_COMPLETED";
613
878
 
614
879
  exports.CHILD_DEFAULT_CANCELLATION_TYPE = CHILD_DEFAULT_CANCELLATION_TYPE;
615
880
  exports.CHILD_DEFAULT_PARENT_CLOSE_POLICY = CHILD_DEFAULT_PARENT_CLOSE_POLICY;
616
- exports.DEFAULT_ACTIVITY_RETRY = DEFAULT_ACTIVITY_RETRY;
881
+ exports.CODE_FEATURE_FLAGS = CODE_FEATURE_FLAGS;
882
+ exports.COMMAND_FEATURES = COMMAND_FEATURES;
883
+ exports.CORE_CAN_OPTIONS = CORE_CAN_OPTIONS;
884
+ exports.CORE_CHILD_OPTIONS = CORE_CHILD_OPTIONS;
617
885
  exports.HistoryStateError = HistoryStateError;
886
+ exports.PHASE_B_CORE_FEATURES = PHASE_B_CORE_FEATURES;
887
+ exports.PHASE_B_PARITY_FEATURES = PHASE_B_PARITY_FEATURES;
888
+ exports.PHASE_C_CODE_FEATURES = PHASE_C_CODE_FEATURES;
889
+ exports.PHASE_C_FEATURES = PHASE_C_FEATURES;
890
+ exports.PHASE_C_FEATURE_FLAGS = PHASE_C_FEATURE_FLAGS;
618
891
  exports.applyEvent = applyEvent;
892
+ exports.codeFeaturesEnabledBy = codeFeaturesEnabledBy;
619
893
  exports.codeWorkflowParentClosePolicy = codeWorkflowParentClosePolicy;
620
- exports.computeRetryDelay = computeRetryDelay;
894
+ exports.commandFeatures = commandFeatures;
895
+ exports.continueAsNewRetryShape = continueAsNewRetryShape;
621
896
  exports.eventsForCommands = eventsForCommands;
622
- exports.explicitRetryPolicy = explicitRetryPolicy;
623
897
  exports.hasUnprocessedInput = hasUnprocessedInput;
624
898
  exports.initialRunState = initialRunState;
625
899
  exports.isActivityOpen = isActivityOpen;
626
900
  exports.isChildOpen = isChildOpen;
627
901
  exports.isCommandEnabled = isCommandEnabled;
902
+ exports.isReliefCommand = isReliefCommand;
628
903
  exports.isWorkflowCommandEnabled = isWorkflowCommandEnabled;
904
+ exports.mergeSearchAttributes = mergeSearchAttributes;
629
905
  exports.pendingCounts = pendingCounts;
630
906
  exports.projectRunState = projectRunState;
631
907
  exports.splitActivations = splitActivations;
632
908
  exports.taskCompletedEvents = taskCompletedEvents;
633
909
  exports.unseenInputs = unseenInputs;
910
+ exports.unsupportedMessage = unsupportedMessage;
634
911
  exports.utf8Bytes = utf8Bytes;