@codemation/core 0.0.7 → 0.0.11

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 (195) hide show
  1. package/package.json +6 -1
  2. package/dist/EngineExecutionLimitsPolicy-8MEFIYx1.d.cts +0 -160
  3. package/dist/EngineExecutionLimitsPolicy-BWAXW9D6.d.cts +0 -160
  4. package/dist/EngineExecutionLimitsPolicy-Bp8PS1Ss.d.cts +0 -159
  5. package/dist/EngineExecutionLimitsPolicy-CLxcN-D2.d.ts +0 -159
  6. package/dist/EngineExecutionLimitsPolicy-DZXuix51.d.ts +0 -160
  7. package/dist/EngineExecutionLimitsPolicy-Gfz6ngFd.d.ts +0 -160
  8. package/dist/EngineFactory-CBnntY3J.cjs +0 -3152
  9. package/dist/EngineFactory-CBnntY3J.cjs.map +0 -1
  10. package/dist/EngineFactory-Cwn3R2YA.js +0 -3087
  11. package/dist/EngineFactory-Cwn3R2YA.js.map +0 -1
  12. package/dist/EngineFactory-DWCnNocp.js +0 -3063
  13. package/dist/EngineFactory-DWCnNocp.js.map +0 -1
  14. package/dist/EngineFactory-DhPFou4p.cjs +0 -3188
  15. package/dist/EngineFactory-DhPFou4p.cjs.map +0 -1
  16. package/dist/EngineFactory-l_9xmBtv.cjs +0 -3190
  17. package/dist/EngineFactory-l_9xmBtv.cjs.map +0 -1
  18. package/dist/EngineFactory-w-aOWuqh.js +0 -3089
  19. package/dist/EngineFactory-w-aOWuqh.js.map +0 -1
  20. package/dist/InMemoryLiveWorkflowRepository-1J9MHN_I.js +0 -18
  21. package/dist/InMemoryLiveWorkflowRepository-1J9MHN_I.js.map +0 -1
  22. package/dist/InMemoryLiveWorkflowRepository-CULNqv96.d.ts +0 -1300
  23. package/dist/InMemoryLiveWorkflowRepository-D6eiiXxF.d.cts +0 -1168
  24. package/dist/InMemoryLiveWorkflowRepository-D7l8cjdZ.d.cts +0 -1130
  25. package/dist/InMemoryLiveWorkflowRepository-DL7LmC9S.d.ts +0 -1340
  26. package/dist/InMemoryLiveWorkflowRepository-jnv-OnOP.d.ts +0 -1300
  27. package/dist/InMemoryLiveWorkflowRepository-xny1_Z6i.cjs +0 -24
  28. package/dist/InMemoryLiveWorkflowRepository-xny1_Z6i.cjs.map +0 -1
  29. package/dist/InMemoryLiveWorkflowRepository-xr7b4kvi.d.ts +0 -1338
  30. package/dist/InMemoryWorkflowCatalog-BIdFpwbK.d.ts +0 -1205
  31. package/dist/InMemoryWorkflowCatalog-BW00_3N3.d.cts +0 -12
  32. package/dist/InMemoryWorkflowCatalog-BiYHGoPw.cjs +0 -24
  33. package/dist/InMemoryWorkflowCatalog-BiYHGoPw.cjs.map +0 -1
  34. package/dist/InMemoryWorkflowCatalog-BrG0ApMO.d.cts +0 -1115
  35. package/dist/InMemoryWorkflowCatalog-BzrAr--Y.js +0 -139
  36. package/dist/InMemoryWorkflowCatalog-BzrAr--Y.js.map +0 -1
  37. package/dist/InMemoryWorkflowCatalog-C-EJlJ7y.d.cts +0 -1120
  38. package/dist/InMemoryWorkflowCatalog-C4482bpw.cjs +0 -24
  39. package/dist/InMemoryWorkflowCatalog-C4482bpw.cjs.map +0 -1
  40. package/dist/InMemoryWorkflowCatalog-CZ0kZpOv.d.ts +0 -1289
  41. package/dist/InMemoryWorkflowCatalog-C_ACeLyW.d.cts +0 -1119
  42. package/dist/InMemoryWorkflowCatalog-CiHWIu5E.d.cts +0 -12
  43. package/dist/InMemoryWorkflowCatalog-CkH7gkya.js +0 -18
  44. package/dist/InMemoryWorkflowCatalog-CkH7gkya.js.map +0 -1
  45. package/dist/InMemoryWorkflowCatalog-CnpZVJM9.d.ts +0 -1205
  46. package/dist/InMemoryWorkflowCatalog-Cu68S8YR.js +0 -18
  47. package/dist/InMemoryWorkflowCatalog-Cu68S8YR.js.map +0 -1
  48. package/dist/InMemoryWorkflowCatalog-D2w9nMj2.cjs +0 -151
  49. package/dist/InMemoryWorkflowCatalog-D2w9nMj2.cjs.map +0 -1
  50. package/dist/InMemoryWorkflowCatalog-D5eMxEf7.js +0 -18
  51. package/dist/InMemoryWorkflowCatalog-D5eMxEf7.js.map +0 -1
  52. package/dist/InMemoryWorkflowCatalog-D5nCp2yZ.d.ts +0 -1267
  53. package/dist/InMemoryWorkflowCatalog-DIq0bjqN.d.ts +0 -12
  54. package/dist/InMemoryWorkflowCatalog-DLgaEaw_.d.ts +0 -1288
  55. package/dist/InMemoryWorkflowCatalog-DNBFdK-x.d.cts +0 -1120
  56. package/dist/InMemoryWorkflowCatalog-DQBkCzb7.cjs +0 -24
  57. package/dist/InMemoryWorkflowCatalog-DQBkCzb7.cjs.map +0 -1
  58. package/dist/InMemoryWorkflowCatalog-DS4-eX6i.d.cts +0 -1118
  59. package/dist/InMemoryWorkflowCatalog-DdVfy8MY.d.ts +0 -12
  60. package/dist/InMemoryWorkflowCatalog-DeVZu3g8.d.ts +0 -12
  61. package/dist/InMemoryWorkflowCatalog-GxkQjvt5.d.ts +0 -1200
  62. package/dist/InMemoryWorkflowCatalog-qaVRn1Lc.d.cts +0 -1115
  63. package/dist/InMemoryWorkflowCatalog-z1aIT4TC.d.cts +0 -12
  64. package/dist/InMemoryWorkflowRegistry-BBuOovLL.d.ts +0 -1007
  65. package/dist/InMemoryWorkflowRegistry-BIFnSl3k.d.ts +0 -1201
  66. package/dist/InMemoryWorkflowRegistry-BnGilthz.d.ts +0 -1137
  67. package/dist/InMemoryWorkflowRegistry-CEp5I8No.d.ts +0 -1146
  68. package/dist/InMemoryWorkflowRegistry-CHyMB9jW.d.cts +0 -976
  69. package/dist/InMemoryWorkflowRegistry-CUN7K86m.d.cts +0 -1061
  70. package/dist/InMemoryWorkflowRegistry-CVfHyELh.d.cts +0 -971
  71. package/dist/InMemoryWorkflowRegistry-CXXJrwAr.d.cts +0 -1052
  72. package/dist/InMemoryWorkflowRegistry-DDGfPTJy.d.ts +0 -1013
  73. package/dist/InMemoryWorkflowRegistry-DnYSOoT5.d.ts +0 -1120
  74. package/dist/InMemoryWorkflowRegistry-Dp5GiFF2.d.cts +0 -1035
  75. package/dist/InMemoryWorkflowRegistry-DypDBeOw.d.cts +0 -1116
  76. package/dist/InMemoryWorkflowRegistry-SzwJCAxT.d.ts +0 -1012
  77. package/dist/InMemoryWorkflowRegistry-jupvqyGc.d.cts +0 -977
  78. package/dist/InMemoryWorkflowRegistry-rAdKVWYT.d.ts +0 -1117
  79. package/dist/InProcessRetryRunner-BBNPkXjy.d.cts +0 -292
  80. package/dist/PersistedWorkflowSnapshotFactory-7RkOL3Kg.d.ts +0 -14
  81. package/dist/PersistedWorkflowSnapshotFactory-BmANa46W.cjs +0 -141
  82. package/dist/PersistedWorkflowSnapshotFactory-BmANa46W.cjs.map +0 -1
  83. package/dist/PersistedWorkflowSnapshotFactory-Bwb_etSt.js +0 -118
  84. package/dist/PersistedWorkflowSnapshotFactory-Bwb_etSt.js.map +0 -1
  85. package/dist/PersistedWorkflowSnapshotFactory-CRkKGNV6.js +0 -123
  86. package/dist/PersistedWorkflowSnapshotFactory-CRkKGNV6.js.map +0 -1
  87. package/dist/PersistedWorkflowSnapshotFactory-CZolnGy5.js +0 -101
  88. package/dist/PersistedWorkflowSnapshotFactory-CZolnGy5.js.map +0 -1
  89. package/dist/PersistedWorkflowSnapshotFactory-Ca_oysOv.cjs +0 -131
  90. package/dist/PersistedWorkflowSnapshotFactory-Ca_oysOv.cjs.map +0 -1
  91. package/dist/PersistedWorkflowSnapshotFactory-CqIcShnX.js +0 -103
  92. package/dist/PersistedWorkflowSnapshotFactory-CqIcShnX.js.map +0 -1
  93. package/dist/PersistedWorkflowSnapshotFactory-D-tBk4_G.js +0 -119
  94. package/dist/PersistedWorkflowSnapshotFactory-D-tBk4_G.js.map +0 -1
  95. package/dist/PersistedWorkflowSnapshotFactory-D4cXl2e2.cjs +0 -131
  96. package/dist/PersistedWorkflowSnapshotFactory-D4cXl2e2.cjs.map +0 -1
  97. package/dist/PersistedWorkflowSnapshotFactory-DINoP12r.cjs +0 -131
  98. package/dist/PersistedWorkflowSnapshotFactory-DINoP12r.cjs.map +0 -1
  99. package/dist/PersistedWorkflowSnapshotFactory-DJAwSuHU.js +0 -103
  100. package/dist/PersistedWorkflowSnapshotFactory-DJAwSuHU.js.map +0 -1
  101. package/dist/PersistedWorkflowSnapshotFactory-DSUjVCcf.cjs +0 -131
  102. package/dist/PersistedWorkflowSnapshotFactory-DSUjVCcf.cjs.map +0 -1
  103. package/dist/PersistedWorkflowSnapshotFactory-DdHuhkDb.cjs +0 -107
  104. package/dist/PersistedWorkflowSnapshotFactory-DdHuhkDb.cjs.map +0 -1
  105. package/dist/PersistedWorkflowSnapshotFactory-Dqc6NHis.js +0 -119
  106. package/dist/PersistedWorkflowSnapshotFactory-Dqc6NHis.js.map +0 -1
  107. package/dist/PersistedWorkflowSnapshotFactory-Dxa2dSrw.cjs +0 -130
  108. package/dist/PersistedWorkflowSnapshotFactory-Dxa2dSrw.cjs.map +0 -1
  109. package/dist/PersistedWorkflowSnapshotFactory-Ep79Ah1G.js +0 -123
  110. package/dist/PersistedWorkflowSnapshotFactory-Ep79Ah1G.js.map +0 -1
  111. package/dist/PersistedWorkflowSnapshotFactory-GyLfRuiJ.js +0 -119
  112. package/dist/PersistedWorkflowSnapshotFactory-GyLfRuiJ.js.map +0 -1
  113. package/dist/PersistedWorkflowSnapshotFactory-HTpBsBzn.js +0 -102
  114. package/dist/PersistedWorkflowSnapshotFactory-HTpBsBzn.js.map +0 -1
  115. package/dist/PersistedWorkflowSnapshotFactory-LVmaaf3t.cjs +0 -141
  116. package/dist/PersistedWorkflowSnapshotFactory-LVmaaf3t.cjs.map +0 -1
  117. package/dist/PersistedWorkflowSnapshotFactory-PZCpo2ZS.js +0 -119
  118. package/dist/PersistedWorkflowSnapshotFactory-PZCpo2ZS.js.map +0 -1
  119. package/dist/PersistedWorkflowSnapshotFactory-UjQ1SJev.cjs +0 -109
  120. package/dist/PersistedWorkflowSnapshotFactory-UjQ1SJev.cjs.map +0 -1
  121. package/dist/PersistedWorkflowSnapshotFactory-Y8kCrhcy.cjs +0 -109
  122. package/dist/PersistedWorkflowSnapshotFactory-Y8kCrhcy.cjs.map +0 -1
  123. package/dist/PersistedWorkflowSnapshotFactory-Z_nB-fmB.cjs +0 -108
  124. package/dist/PersistedWorkflowSnapshotFactory-Z_nB-fmB.cjs.map +0 -1
  125. package/dist/RunIntentService-1EE6N8ZL.cjs +0 -963
  126. package/dist/RunIntentService-1EE6N8ZL.cjs.map +0 -1
  127. package/dist/RunIntentService-2ivFmNQh.cjs +0 -3462
  128. package/dist/RunIntentService-2ivFmNQh.cjs.map +0 -1
  129. package/dist/RunIntentService-B0sUL5q-.js +0 -761
  130. package/dist/RunIntentService-B0sUL5q-.js.map +0 -1
  131. package/dist/RunIntentService-BFVbsOcg.js +0 -3131
  132. package/dist/RunIntentService-BFVbsOcg.js.map +0 -1
  133. package/dist/RunIntentService-BsBOwpVN.cjs +0 -1051
  134. package/dist/RunIntentService-BsBOwpVN.cjs.map +0 -1
  135. package/dist/RunIntentService-CSk3ETyn.js +0 -858
  136. package/dist/RunIntentService-CSk3ETyn.js.map +0 -1
  137. package/dist/RunIntentService-Ckn3u3tA.d.cts +0 -326
  138. package/dist/RunIntentService-DEo6GTTo.d.cts +0 -289
  139. package/dist/RunIntentService-DKrGtL0B.js +0 -782
  140. package/dist/RunIntentService-DKrGtL0B.js.map +0 -1
  141. package/dist/RunIntentService-DNOJc1R7.cjs +0 -942
  142. package/dist/RunIntentService-DNOJc1R7.cjs.map +0 -1
  143. package/dist/RunIntentService-Dq3pV53j.d.cts +0 -289
  144. package/dist/RunIntentService-NKobsfMQ.d.cts +0 -274
  145. package/dist/WorkflowSnapshotCodec-C3fuuS_R.d.cts +0 -22
  146. package/dist/WorkflowSnapshotCodec-CUudUo6f.js +0 -123
  147. package/dist/WorkflowSnapshotCodec-CUudUo6f.js.map +0 -1
  148. package/dist/WorkflowSnapshotCodec-CuCPQZTc.cjs +0 -129
  149. package/dist/WorkflowSnapshotCodec-CuCPQZTc.cjs.map +0 -1
  150. package/dist/WorkflowSnapshotCodec-DLiXQNvV.d.cts +0 -22
  151. package/dist/WorkflowSnapshotCodec-DNtdrZ7l.d.cts +0 -22
  152. package/dist/WorkflowSnapshotCodec-DTdWkoW_.d.cts +0 -22
  153. package/dist/credentialTypes-B5h3dI7r.d.cts +0 -1107
  154. package/dist/credentialTypes-B9okPCVo.d.cts +0 -963
  155. package/dist/credentialTypes-BFL70rgZ.d.cts +0 -964
  156. package/dist/credentialTypes-BGkh1O07.d.ts +0 -1010
  157. package/dist/credentialTypes-BNLi4Q7u.d.ts +0 -1030
  158. package/dist/credentialTypes-CeSoZGj3.d.cts +0 -994
  159. package/dist/credentialTypes-CpHc32Ig.d.cts +0 -984
  160. package/dist/credentialTypes-D0m7MQQl.d.cts +0 -1107
  161. package/dist/credentialTypes-D4nL2sUd.d.ts +0 -1000
  162. package/dist/credentialTypes-DBYK2Qbu.d.ts +0 -999
  163. package/dist/credentialTypes-DMJVy0r1.d.ts +0 -1000
  164. package/dist/credentialTypes-DhUAjYQp.d.ts +0 -1020
  165. package/dist/credentialTypes-gGITj5KL.d.cts +0 -964
  166. package/dist/credentialTypes-r3KVBJBE.d.cts +0 -974
  167. package/dist/diTokens-ClO27tjK.cjs +0 -34
  168. package/dist/diTokens-ClO27tjK.cjs.map +0 -1
  169. package/dist/diTokens-CoHBkwG6.js +0 -28
  170. package/dist/diTokens-CoHBkwG6.js.map +0 -1
  171. package/dist/index-6Doxmfnd.d.ts +0 -857
  172. package/dist/index-9g6Pfe9Z.d.ts +0 -689
  173. package/dist/index-AZ72Ej-K.d.ts +0 -920
  174. package/dist/index-BEk9V-q-.d.ts +0 -667
  175. package/dist/index-Bjt7_7oS.d.ts +0 -1192
  176. package/dist/index-CFGxsYXy.d.ts +0 -708
  177. package/dist/index-C_u8xFgn.d.ts +0 -690
  178. package/dist/index-CpbfsvOJ.d.ts +0 -1192
  179. package/dist/index-CsReNJN_.d.ts +0 -859
  180. package/dist/index-D5iNnXaW.d.ts +0 -667
  181. package/dist/index-DD_Eft1q.d.ts +0 -708
  182. package/dist/index-DiSYUe0G.d.ts +0 -1192
  183. package/dist/index-gIcH60sp.d.ts +0 -674
  184. package/dist/runtime-BIvd-1JA.cjs +0 -4112
  185. package/dist/runtime-BIvd-1JA.cjs.map +0 -1
  186. package/dist/runtime-D3eWKSQK.cjs +0 -3986
  187. package/dist/runtime-D3eWKSQK.cjs.map +0 -1
  188. package/dist/runtime-Dvp4xAjg.js +0 -3799
  189. package/dist/runtime-Dvp4xAjg.js.map +0 -1
  190. package/dist/runtime-vc76SSAa.js +0 -3685
  191. package/dist/runtime-vc76SSAa.js.map +0 -1
  192. package/dist/runtimeTypes-BK0b8SaG.d.cts +0 -884
  193. package/dist/runtimeTypes-CoYZkYQq.d.cts +0 -851
  194. package/dist/runtimeTypes-D-Pm0Uas.d.cts +0 -849
  195. package/dist/types-Cb5UK7Y6.d.ts +0 -857
@@ -1,3462 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
24
- let node_crypto = require("node:crypto");
25
- node_crypto = __toESM(node_crypto);
26
- require("reflect-metadata");
27
- let tsyringe = require("tsyringe");
28
- tsyringe = __toESM(tsyringe);
29
- let node_stream_web = require("node:stream/web");
30
- node_stream_web = __toESM(node_stream_web);
31
-
32
- //#region src/workflow/definition/ConnectionNodeIdFactory.ts
33
- /**
34
- * Deterministic ids for workflow connection-owned child nodes (LLM slot, tools, etc.).
35
- * These are stable across loads.
36
- */
37
- var ConnectionNodeIdFactory = class {
38
- static connectionSegment = "__conn__";
39
- static languageModelConnectionNodeId(parentNodeId) {
40
- return `${parentNodeId}${this.connectionSegment}llm`;
41
- }
42
- static toolConnectionNodeId(parentNodeId, toolName) {
43
- const normalized = this.normalizeToolName(toolName);
44
- return `${parentNodeId}${this.connectionSegment}tool${this.connectionSegment}${normalized}`;
45
- }
46
- static isLanguageModelConnectionNodeId(nodeId) {
47
- return nodeId.endsWith(`${this.connectionSegment}llm`);
48
- }
49
- static isToolConnectionNodeId(nodeId) {
50
- return nodeId.includes(`${this.connectionSegment}tool${this.connectionSegment}`);
51
- }
52
- /** True when `nodeId` is a connection-owned child of `parentNodeId` (LLM or tool slot). */
53
- static isConnectionOwnedDescendantOf(parentNodeId, nodeId) {
54
- return nodeId.startsWith(`${parentNodeId}${this.connectionSegment}`);
55
- }
56
- /** Normalizes a tool display name to a stable id segment. */
57
- static normalizeToolName(toolName) {
58
- return toolName.trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "") || "tool";
59
- }
60
- };
61
-
62
- //#endregion
63
- //#region src/workflow/definition/WorkflowExecutableNodeClassifier.ts
64
- /**
65
- * Derives which workflow nodes participate in the main execution graph vs connection-only children.
66
- */
67
- var WorkflowExecutableNodeClassifier = class {
68
- connectionOwnedIds;
69
- constructor(workflow) {
70
- this.connectionOwnedIds = this.collectConnectionOwnedIds(workflow);
71
- }
72
- isConnectionOwnedNodeId(nodeId) {
73
- return this.connectionOwnedIds.has(nodeId);
74
- }
75
- isExecutableNodeId(nodeId) {
76
- return !this.connectionOwnedIds.has(nodeId);
77
- }
78
- filterExecutableNodeDefinitions(nodes) {
79
- return nodes.filter((n) => this.isExecutableNodeId(n.id));
80
- }
81
- collectConnectionOwnedIds(workflow) {
82
- const ids = /* @__PURE__ */ new Set();
83
- for (const connection of workflow.connections ?? []) for (const childId of connection.childNodeIds) ids.add(childId);
84
- return ids;
85
- }
86
- /**
87
- * Resolves the default start node: first trigger, else first executable node with no incoming edges from executable nodes.
88
- */
89
- findDefaultExecutableStartNodeId(workflow) {
90
- const firstTrigger = workflow.nodes.find((n) => n.kind === "trigger" && this.isExecutableNodeId(n.id))?.id;
91
- if (firstTrigger) return firstTrigger;
92
- const incoming = /* @__PURE__ */ new Map();
93
- for (const n of workflow.nodes) if (this.isExecutableNodeId(n.id)) incoming.set(n.id, 0);
94
- for (const e of workflow.edges) {
95
- if (!this.isExecutableNodeId(e.from.nodeId) || !this.isExecutableNodeId(e.to.nodeId)) continue;
96
- incoming.set(e.to.nodeId, (incoming.get(e.to.nodeId) ?? 0) + 1);
97
- }
98
- return workflow.nodes.find((n) => this.isExecutableNodeId(n.id) && (incoming.get(n.id) ?? 0) === 0)?.id ?? workflow.nodes.find((n) => this.isExecutableNodeId(n.id))?.id ?? (() => {
99
- throw new Error(`Workflow ${workflow.id} has no executable nodes`);
100
- })();
101
- }
102
- firstExecutableNodeIdInDefinitionOrder(workflow) {
103
- return workflow.nodes.find((n) => this.isExecutableNodeId(n.id))?.id;
104
- }
105
- lastExecutableNodeIdInDefinitionOrder(workflow) {
106
- for (let i = workflow.nodes.length - 1; i >= 0; i--) {
107
- const n = workflow.nodes[i];
108
- if (this.isExecutableNodeId(n.id)) return n.id;
109
- }
110
- throw new Error(`Workflow ${workflow.id} has no executable nodes`);
111
- }
112
- };
113
-
114
- //#endregion
115
- //#region src/workflow/definition/WorkflowExecutableNodeClassifierFactory.ts
116
- var WorkflowExecutableNodeClassifierFactory = class {
117
- static create(workflow) {
118
- return new WorkflowExecutableNodeClassifier(workflow);
119
- }
120
- };
121
-
122
- //#endregion
123
- //#region src/di/CoreTokens.ts
124
- const CoreTokens = {
125
- PersistedWorkflowTokenRegistry: Symbol.for("codemation.core.PersistedWorkflowTokenRegistry"),
126
- CredentialSessionService: Symbol.for("codemation.core.CredentialSessionService"),
127
- CredentialTypeRegistry: Symbol.for("codemation.core.CredentialTypeRegistry"),
128
- WorkflowRunnerService: Symbol.for("codemation.core.WorkflowRunnerService"),
129
- LiveWorkflowRepository: Symbol.for("codemation.core.LiveWorkflowRepository"),
130
- WorkflowRepository: Symbol.for("codemation.core.WorkflowRepository"),
131
- NodeResolver: Symbol.for("codemation.core.NodeResolver"),
132
- WorkflowNodeInstanceFactory: Symbol.for("codemation.core.WorkflowNodeInstanceFactory"),
133
- RunIdFactory: Symbol.for("codemation.core.RunIdFactory"),
134
- ActivationIdFactory: Symbol.for("codemation.core.ActivationIdFactory"),
135
- WorkflowExecutionRepository: Symbol.for("codemation.core.WorkflowExecutionRepository"),
136
- TriggerSetupStateRepository: Symbol.for("codemation.core.TriggerSetupStateRepository"),
137
- NodeActivationScheduler: Symbol.for("codemation.core.NodeActivationScheduler"),
138
- RunDataFactory: Symbol.for("codemation.core.RunDataFactory"),
139
- ExecutionContextFactory: Symbol.for("codemation.core.ExecutionContextFactory"),
140
- RunEventBus: Symbol.for("codemation.core.RunEventBus"),
141
- BinaryStorage: Symbol.for("codemation.core.BinaryStorage"),
142
- WebhookBasePath: Symbol.for("codemation.core.WebhookBasePath"),
143
- EngineExecutionLimitsPolicy: Symbol.for("codemation.core.EngineExecutionLimitsPolicy"),
144
- WorkflowActivationPolicy: Symbol.for("codemation.core.WorkflowActivationPolicy")
145
- };
146
-
147
- //#endregion
148
- //#region src/events/NodeEventPublisher.ts
149
- /** Publishes node lifecycle snapshots onto the run {@link RunEventBus}. */
150
- var NodeEventPublisher = class {
151
- constructor(eventBus) {
152
- this.eventBus = eventBus;
153
- }
154
- async publish(kind, snapshot) {
155
- if (!this.eventBus) return;
156
- await this.eventBus.publish({
157
- kind,
158
- runId: snapshot.runId,
159
- workflowId: snapshot.workflowId,
160
- parent: snapshot.parent,
161
- at: snapshot.updatedAt,
162
- snapshot
163
- });
164
- }
165
- };
166
-
167
- //#endregion
168
- //#region src/runtime-types/persistedRuntimeTypeModelRegistry.ts
169
- /** Shared metadata key used to attach persisted runtime-type information to decorated classes. */
170
- const persistedRuntimeTypeMetadataKey = Symbol.for("codemation.core.persistedRuntimeTypeMetadata");
171
- /** Normalizes decorator options so persistence metadata has stable defaults. */
172
- var PersistedRuntimeTypeDecoratorDefaults = class {
173
- static appPackageName = "app";
174
- static apply(options) {
175
- return {
176
- ...options,
177
- packageName: options.packageName ?? this.appPackageName
178
- };
179
- }
180
- };
181
-
182
- //#endregion
183
- //#region src/runtime-types/PersistedRuntimeTypeNameResolver.ts
184
- /** Resolves the persisted type name from either an explicit override or the class name itself. */
185
- var PersistedRuntimeTypeNameResolver = class {
186
- static resolve(target, override) {
187
- const resolved = override ?? target.name;
188
- if (!resolved) throw new Error("Persisted runtime token metadata requires a named class or an explicit decorator name override.");
189
- return resolved;
190
- }
191
- };
192
-
193
- //#endregion
194
- //#region src/runtime-types/StackTraceCallSitePathResolver.ts
195
- var StackTraceCallSitePathResolver = class {
196
- static resolve(decoratorFileUrl) {
197
- const stack = (/* @__PURE__ */ new Error()).stack ?? "";
198
- for (const line of stack.split("\n")) {
199
- const candidate = this.extractPath(line.trim());
200
- if (!candidate) continue;
201
- if (candidate === decoratorFileUrl || candidate.includes("runtimeTypeDecorators")) continue;
202
- return candidate;
203
- }
204
- }
205
- static extractPath(line) {
206
- const fileUrlMatch = line.match(/file:\/\/[^\s)]+/);
207
- if (fileUrlMatch) return fileUrlMatch[0];
208
- const parenMatch = line.match(/\((\/[^)]+)\)/);
209
- if (parenMatch) return parenMatch[1];
210
- return line.match(/at (\/[^\s]+)/)?.[1];
211
- }
212
- };
213
-
214
- //#endregion
215
- //#region src/runtime-types/PersistedRuntimeTypeMetadataStoreRegistry.ts
216
- /**
217
- * Defines and retrieves persisted runtime metadata on decorated classes.
218
- * The metadata is attached as a non-enumerable property so runtime objects stay serializable.
219
- */
220
- var PersistedRuntimeTypeMetadataStore = class {
221
- static define(target, kind, options, decoratorFileUrl) {
222
- const normalizedOptions = PersistedRuntimeTypeDecoratorDefaults.apply(options);
223
- const metadata = {
224
- persistedName: PersistedRuntimeTypeNameResolver.resolve(target, normalizedOptions.name),
225
- kind,
226
- packageName: normalizedOptions.packageName ?? PersistedRuntimeTypeDecoratorDefaults.appPackageName,
227
- sourceHint: normalizedOptions.moduleUrl ?? StackTraceCallSitePathResolver.resolve(decoratorFileUrl)
228
- };
229
- Object.defineProperty(target, persistedRuntimeTypeMetadataKey, {
230
- configurable: false,
231
- enumerable: false,
232
- writable: false,
233
- value: metadata
234
- });
235
- }
236
- static get(target) {
237
- if (!target || typeof target !== "function" && typeof target !== "object") return;
238
- return target[persistedRuntimeTypeMetadataKey];
239
- }
240
- };
241
-
242
- //#endregion
243
- //#region src/runtime-types/InjectableRuntimeDecoratorComposerRegistry.ts
244
- /**
245
- * Applies both tsyringe injectability and persisted runtime metadata in one decorator.
246
- * This keeps runtime-type decorators thin while still recording enough data for snapshot hydration.
247
- */
248
- var InjectableRuntimeDecoratorComposer = class {
249
- static compose(kind, options, decoratorFileUrl) {
250
- return (target) => {
251
- (0, tsyringe.injectable)()(target);
252
- PersistedRuntimeTypeMetadataStore.define(target, kind, options, decoratorFileUrl);
253
- };
254
- }
255
- };
256
-
257
- //#endregion
258
- //#region src/runtime-types/runtimeTypeDecorators.types.ts
259
- /** Reads persisted runtime metadata from a decorated class or object. */
260
- function getPersistedRuntimeTypeMetadata(target) {
261
- return PersistedRuntimeTypeMetadataStore.get(target);
262
- }
263
- /** Marks a class as a persisted node runtime type and an injectable tsyringe service. */
264
- function node(options = {}) {
265
- return InjectableRuntimeDecoratorComposer.compose("node", options, require("url").pathToFileURL(__filename).href);
266
- }
267
- /** Marks a class as a persisted tool runtime type and an injectable tsyringe service. */
268
- function tool(options = {}) {
269
- return InjectableRuntimeDecoratorComposer.compose("tool", options, require("url").pathToFileURL(__filename).href);
270
- }
271
- /** Marks a class as a persisted chat-model runtime type and an injectable tsyringe service. */
272
- function chatModel(options = {}) {
273
- return InjectableRuntimeDecoratorComposer.compose("chatModel", options, require("url").pathToFileURL(__filename).href);
274
- }
275
-
276
- //#endregion
277
- //#region src/binaries/DefaultNodeBinaryAttachmentServiceFactory.ts
278
- var DefaultNodeBinaryAttachmentService = class DefaultNodeBinaryAttachmentService {
279
- constructor(storage, workflowId, runId, nodeId, activationId, now) {
280
- this.storage = storage;
281
- this.workflowId = workflowId;
282
- this.runId = runId;
283
- this.nodeId = nodeId;
284
- this.activationId = activationId;
285
- this.now = now;
286
- }
287
- async attach(args) {
288
- const attachmentId = this.createAttachmentId();
289
- const createdAt = this.now().toISOString();
290
- const storageKey = this.createStorageKey(args, attachmentId);
291
- const stored = await this.storage.write({
292
- storageKey,
293
- body: args.body
294
- });
295
- return {
296
- id: attachmentId,
297
- storageKey: stored.storageKey,
298
- mimeType: args.mimeType,
299
- size: stored.size,
300
- storageDriver: this.storage.driverName,
301
- previewKind: args.previewKind ?? this.resolvePreviewKind(args.mimeType),
302
- createdAt,
303
- runId: this.runId,
304
- workflowId: this.workflowId,
305
- nodeId: this.nodeId,
306
- activationId: this.activationId,
307
- filename: args.filename,
308
- sha256: stored.sha256
309
- };
310
- }
311
- withAttachment(item, name, attachment) {
312
- return {
313
- ...item,
314
- binary: {
315
- ...item.binary ?? {},
316
- [name]: attachment
317
- }
318
- };
319
- }
320
- forNode(args) {
321
- return new DefaultNodeBinaryAttachmentService(this.storage, this.workflowId, this.runId, args.nodeId, args.activationId, this.now);
322
- }
323
- async openReadStream(attachment) {
324
- return await this.storage.openReadStream(attachment.storageKey);
325
- }
326
- createAttachmentId() {
327
- return DefaultNodeBinaryAttachmentService.createAttachmentIdValue(`${this.activationId}-${this.now().getTime()}`);
328
- }
329
- static createAttachmentIdValue(fallbackValue) {
330
- const cryptoObject = globalThis.crypto;
331
- if (cryptoObject && typeof cryptoObject.randomUUID === "function") return cryptoObject.randomUUID();
332
- return fallbackValue;
333
- }
334
- createStorageKey(args, attachmentId) {
335
- const safeName = this.sanitizeSegment(args.name);
336
- const safeFilename = this.sanitizeFilename(args.filename);
337
- const filenameSuffix = safeFilename ? `-${safeFilename}` : "";
338
- return `${this.sanitizeSegment(this.workflowId)}/${this.sanitizeSegment(this.runId)}/${this.sanitizeSegment(this.nodeId)}/${this.sanitizeSegment(this.activationId)}/${attachmentId}-${safeName}${filenameSuffix}`;
339
- }
340
- sanitizeSegment(value) {
341
- const normalized = value.trim();
342
- if (!normalized) return "item";
343
- return normalized.replace(/[^a-zA-Z0-9._-]+/g, "_");
344
- }
345
- sanitizeFilename(value) {
346
- if (!value) return;
347
- const normalized = value.trim().split("/").at(-1)?.split("\\").at(-1) ?? value.trim();
348
- if (!normalized) return;
349
- return normalized.replace(/[^a-zA-Z0-9._-]+/g, "_");
350
- }
351
- resolvePreviewKind(mimeType) {
352
- if (mimeType.startsWith("image/")) return "image";
353
- if (mimeType.startsWith("audio/")) return "audio";
354
- if (mimeType.startsWith("video/")) return "video";
355
- return "download";
356
- }
357
- };
358
-
359
- //#endregion
360
- //#region src/binaries/UnavailableBinaryStorage.ts
361
- var UnavailableBinaryStorage = class {
362
- driverName = "unavailable";
363
- async write() {
364
- throw new Error("Binary storage is not configured for this runtime.");
365
- }
366
- async openReadStream() {}
367
- async stat() {
368
- return { exists: false };
369
- }
370
- async delete() {}
371
- };
372
-
373
- //#endregion
374
- //#region src/binaries/DefaultExecutionBinaryServiceFactory.ts
375
- var DefaultExecutionBinaryService = class {
376
- constructor(storage, workflowId, runId, now) {
377
- this.storage = storage;
378
- this.workflowId = workflowId;
379
- this.runId = runId;
380
- this.now = now;
381
- }
382
- forNode(args) {
383
- return new DefaultNodeBinaryAttachmentService(this.storage, this.workflowId, this.runId, args.nodeId, args.activationId, this.now);
384
- }
385
- async openReadStream(attachment) {
386
- return await this.storage.openReadStream(attachment.storageKey);
387
- }
388
- };
389
-
390
- //#endregion
391
- //#region src/execution/NodeExecutionSnapshotFactory.ts
392
- var NodeExecutionSnapshotFactory = class {
393
- static queued(args) {
394
- return {
395
- runId: args.runId,
396
- workflowId: args.workflowId,
397
- nodeId: args.nodeId,
398
- activationId: args.activationId,
399
- parent: args.parent,
400
- status: "queued",
401
- queuedAt: args.queuedAt,
402
- updatedAt: args.queuedAt,
403
- inputsByPort: args.inputsByPort
404
- };
405
- }
406
- static running(args) {
407
- return {
408
- runId: args.runId,
409
- workflowId: args.workflowId,
410
- nodeId: args.nodeId,
411
- activationId: args.activationId,
412
- parent: args.parent,
413
- status: "running",
414
- queuedAt: args.previous?.queuedAt,
415
- startedAt: args.startedAt,
416
- updatedAt: args.startedAt,
417
- inputsByPort: args.inputsByPort,
418
- outputs: args.previous?.outputs,
419
- error: void 0
420
- };
421
- }
422
- static completed(args) {
423
- const fromPinnedOutput = args.fromPinnedOutput ?? false;
424
- const startedAt = fromPinnedOutput ? args.previous?.startedAt ?? args.finishedAt : args.previous?.startedAt;
425
- return {
426
- runId: args.runId,
427
- workflowId: args.workflowId,
428
- nodeId: args.nodeId,
429
- activationId: args.activationId,
430
- parent: args.parent,
431
- status: "completed",
432
- queuedAt: args.previous?.queuedAt,
433
- startedAt,
434
- finishedAt: args.finishedAt,
435
- updatedAt: args.finishedAt,
436
- inputsByPort: args.inputsByPort,
437
- outputs: args.outputs,
438
- usedPinnedOutput: fromPinnedOutput,
439
- error: void 0
440
- };
441
- }
442
- static skipped(args) {
443
- return {
444
- runId: args.runId,
445
- workflowId: args.workflowId,
446
- nodeId: args.nodeId,
447
- activationId: args.activationId,
448
- parent: args.parent,
449
- status: "skipped",
450
- queuedAt: args.previous?.queuedAt,
451
- startedAt: args.previous?.startedAt,
452
- finishedAt: args.finishedAt,
453
- updatedAt: args.finishedAt,
454
- inputsByPort: args.inputsByPort,
455
- outputs: args.outputs,
456
- error: void 0
457
- };
458
- }
459
- static failed(args) {
460
- return {
461
- runId: args.runId,
462
- workflowId: args.workflowId,
463
- nodeId: args.nodeId,
464
- activationId: args.activationId,
465
- parent: args.parent,
466
- status: "failed",
467
- queuedAt: args.previous?.queuedAt,
468
- startedAt: args.previous?.startedAt,
469
- finishedAt: args.finishedAt,
470
- updatedAt: args.finishedAt,
471
- inputsByPort: args.inputsByPort,
472
- outputs: void 0,
473
- error: {
474
- message: args.error.message,
475
- name: args.error.name,
476
- stack: args.error.stack
477
- }
478
- };
479
- }
480
- };
481
-
482
- //#endregion
483
- //#region src/execution/NodeInputsByPortFactory.ts
484
- var NodeInputsByPortFactory = class {
485
- static empty() {
486
- return {};
487
- }
488
- static fromRequest(request) {
489
- if (request.kind === "multi") return request.inputsByPort;
490
- return { in: request.input };
491
- }
492
- };
493
-
494
- //#endregion
495
- //#region src/execution/ActivationEnqueueService.ts
496
- var ActivationEnqueueService = class {
497
- constructor(activationScheduler, workflowExecutionRepository, nodeEventPublisher) {
498
- this.activationScheduler = activationScheduler;
499
- this.workflowExecutionRepository = workflowExecutionRepository;
500
- this.nodeEventPublisher = nodeEventPublisher;
501
- }
502
- async enqueueActivation(args) {
503
- const { result, queuedSnapshot } = await this.enqueueActivationWithSnapshot(args);
504
- await this.nodeEventPublisher.publish("nodeQueued", queuedSnapshot);
505
- return result;
506
- }
507
- async enqueueActivationWithSnapshot(args) {
508
- const receipt = await this.activationScheduler.enqueue(args.request);
509
- const inputsByPort = NodeInputsByPortFactory.fromRequest(args.request);
510
- const itemsIn = args.request.kind === "multi" ? args.planner.sumItemsByPort(args.request.inputsByPort) : args.request.input.length;
511
- const enqueuedAt = (/* @__PURE__ */ new Date()).toISOString();
512
- const pending = {
513
- runId: args.runId,
514
- activationId: args.request.activationId,
515
- workflowId: args.workflowId,
516
- nodeId: args.request.nodeId,
517
- itemsIn,
518
- inputsByPort,
519
- receiptId: receipt.receiptId,
520
- queue: receipt.queue,
521
- batchId: args.request.batchId,
522
- enqueuedAt
523
- };
524
- const queuedSnapshot = NodeExecutionSnapshotFactory.queued({
525
- runId: args.runId,
526
- workflowId: args.workflowId,
527
- nodeId: args.request.nodeId,
528
- activationId: args.request.activationId,
529
- parent: args.parent,
530
- queuedAt: enqueuedAt,
531
- inputsByPort
532
- });
533
- await this.workflowExecutionRepository.save({
534
- runId: args.runId,
535
- workflowId: args.workflowId,
536
- startedAt: args.startedAt,
537
- parent: args.parent,
538
- executionOptions: args.executionOptions,
539
- control: args.control,
540
- workflowSnapshot: args.workflowSnapshot,
541
- mutableState: args.mutableState,
542
- policySnapshot: args.policySnapshot,
543
- engineCounters: args.engineCounters,
544
- connectionInvocations: args.connectionInvocations ? [...args.connectionInvocations] : [],
545
- status: "pending",
546
- pending,
547
- queue: args.pendingQueue.map((entry) => ({ ...entry })),
548
- outputsByNode: args.request.ctx.data.dump(),
549
- nodeSnapshotsByNodeId: {
550
- ...args.previousNodeSnapshotsByNodeId,
551
- [args.request.nodeId]: queuedSnapshot
552
- }
553
- });
554
- this.notifyPendingStatePersisted(args.runId);
555
- return {
556
- result: {
557
- runId: args.runId,
558
- workflowId: args.workflowId,
559
- startedAt: args.startedAt,
560
- status: "pending",
561
- pending
562
- },
563
- queuedSnapshot
564
- };
565
- }
566
- notifyPendingStatePersisted(runId) {
567
- this.activationScheduler.notifyPendingStatePersisted?.(runId);
568
- }
569
- };
570
-
571
- //#endregion
572
- //#region src/execution/CredentialResolverFactory.ts
573
- var CredentialResolverFactory = class {
574
- constructor(credentialSessions) {
575
- this.credentialSessions = credentialSessions;
576
- }
577
- create(workflowId, nodeId, config) {
578
- const acceptedTypesBySlot = /* @__PURE__ */ new Map();
579
- for (const requirement of config?.getCredentialRequirements?.() ?? []) acceptedTypesBySlot.set(requirement.slotKey, requirement.acceptedTypes);
580
- return async (slotKey) => {
581
- try {
582
- return await this.credentialSessions.getSession({
583
- workflowId,
584
- nodeId,
585
- slotKey
586
- });
587
- } catch (error) {
588
- const acceptedTypes = acceptedTypesBySlot.get(slotKey) ?? [];
589
- const message = error instanceof Error ? error.message : String(error);
590
- const alreadyListsAcceptedTypes = message.includes("Accepted types:") || message.includes("Accepted credential types:") || message.includes("binding points at an unknown type");
591
- const acceptedTypesSuffix = acceptedTypes.length > 0 && !alreadyListsAcceptedTypes ? ` Accepted types: ${acceptedTypes.join(", ")}.` : "";
592
- throw new Error(`Failed to resolve credential for workflow ${workflowId} node ${nodeId} slot "${slotKey}". ${message}${acceptedTypesSuffix}`, { cause: error });
593
- }
594
- };
595
- }
596
- };
597
-
598
- //#endregion
599
- //#region src/execution/DefaultAsyncSleeper.ts
600
- var DefaultAsyncSleeper = class {
601
- sleep(ms) {
602
- return new Promise((resolve) => {
603
- setTimeout(resolve, ms);
604
- });
605
- }
606
- };
607
-
608
- //#endregion
609
- //#region src/execution/DefaultExecutionContextFactory.ts
610
- var DefaultExecutionContextFactory = class {
611
- constructor(binaryStorage = new UnavailableBinaryStorage(), currentDate = () => /* @__PURE__ */ new Date()) {
612
- this.binaryStorage = binaryStorage;
613
- this.currentDate = currentDate;
614
- }
615
- create(args) {
616
- return {
617
- runId: args.runId,
618
- workflowId: args.workflowId,
619
- parent: args.parent,
620
- subworkflowDepth: args.subworkflowDepth,
621
- engineMaxNodeActivations: args.engineMaxNodeActivations,
622
- engineMaxSubworkflowDepth: args.engineMaxSubworkflowDepth,
623
- now: this.currentDate,
624
- data: args.data,
625
- nodeState: args.nodeState,
626
- binary: new DefaultExecutionBinaryService(this.binaryStorage, args.workflowId, args.runId, this.currentDate),
627
- getCredential: args.getCredential
628
- };
629
- }
630
- };
631
-
632
- //#endregion
633
- //#region src/execution/InProcessRetryRunner.ts
634
- var InProcessRetryRunner = class InProcessRetryRunner {
635
- constructor(sleeper) {
636
- this.sleeper = sleeper;
637
- }
638
- async run(policy, work) {
639
- const spec = InProcessRetryRunner.normalizePolicy(policy);
640
- let lastError;
641
- for (let attempt = 1; attempt <= spec.maxAttempts; attempt++) try {
642
- return await work();
643
- } catch (error) {
644
- lastError = error;
645
- if (attempt >= spec.maxAttempts) break;
646
- const delayMs = InProcessRetryRunner.delayAfterFailureMs(spec, attempt);
647
- await this.sleeper.sleep(delayMs);
648
- }
649
- throw lastError instanceof Error ? lastError : new Error(String(lastError));
650
- }
651
- static delayAfterFailureMs(spec, failedAttempt) {
652
- if (spec.kind === "none") return 0;
653
- if (spec.kind === "fixed") return spec.delayMs;
654
- const exponent = failedAttempt - 1;
655
- let ms = spec.initialDelayMs * Math.pow(spec.multiplier, exponent);
656
- if (spec.jitter === true) ms *= 1 + Math.random() * .2;
657
- if (spec.maxDelayMs !== void 0 && ms > spec.maxDelayMs) ms = spec.maxDelayMs;
658
- return Math.max(0, Math.floor(ms));
659
- }
660
- static normalizePolicy(policy) {
661
- if (policy === void 0) return {
662
- kind: "none",
663
- maxAttempts: 1
664
- };
665
- if (typeof policy !== "object" || policy === null) return {
666
- kind: "none",
667
- maxAttempts: 1
668
- };
669
- const kind = policy.kind;
670
- if (kind === "none") return {
671
- kind: "none",
672
- maxAttempts: 1
673
- };
674
- if (kind === "fixed") {
675
- const p = policy;
676
- return {
677
- kind: "fixed",
678
- maxAttempts: InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "fixed.maxAttempts"),
679
- delayMs: InProcessRetryRunner.assertNonNegativeFinite(p.delayMs, "fixed.delayMs")
680
- };
681
- }
682
- if (kind === "exponential") {
683
- const p = policy;
684
- return {
685
- kind: "exponential",
686
- maxAttempts: InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "exponential.maxAttempts"),
687
- initialDelayMs: InProcessRetryRunner.assertNonNegativeFinite(p.initialDelayMs, "exponential.initialDelayMs"),
688
- multiplier: InProcessRetryRunner.assertMultiplier(p.multiplier),
689
- maxDelayMs: p.maxDelayMs === void 0 ? void 0 : InProcessRetryRunner.assertNonNegativeFinite(p.maxDelayMs, "exponential.maxDelayMs"),
690
- jitter: p.jitter === true
691
- };
692
- }
693
- return {
694
- kind: "none",
695
- maxAttempts: 1
696
- };
697
- }
698
- static assertPositiveInt(value, label) {
699
- if (typeof value !== "number" || !Number.isFinite(value) || value < 1 || !Number.isInteger(value)) throw new Error(`Retry policy ${label} must be a positive integer`);
700
- return value;
701
- }
702
- static assertNonNegativeFinite(value, label) {
703
- if (typeof value !== "number" || !Number.isFinite(value) || value < 0) throw new Error(`Retry policy ${label} must be a non-negative finite number`);
704
- return value;
705
- }
706
- static assertMultiplier(value) {
707
- if (typeof value !== "number" || !Number.isFinite(value) || value < 1) throw new Error(`Retry policy exponential.multiplier must be >= 1`);
708
- return value;
709
- }
710
- };
711
-
712
- //#endregion
713
- //#region src/execution/InProcessRetryRunnerFactory.ts
714
- var InProcessRetryRunnerFactory = class {
715
- create(defaultAsyncSleeper) {
716
- return new InProcessRetryRunner(defaultAsyncSleeper);
717
- }
718
- };
719
-
720
- //#endregion
721
- //#region src/execution/NodeActivationRequestComposer.ts
722
- /**
723
- * Builds {@link NodeActivationRequest} values shared by workflow starters and continuation.
724
- */
725
- var NodeActivationRequestComposer = class {
726
- constructor(activationIdFactory, credentialResolverFactory) {
727
- this.activationIdFactory = activationIdFactory;
728
- this.credentialResolverFactory = credentialResolverFactory;
729
- }
730
- createSingleFromDefinition(args) {
731
- const activationId = this.activationIdFactory.makeActivationId();
732
- const ctx = this.createNodeExecutionContext(args, args.definition, activationId);
733
- return {
734
- kind: "single",
735
- runId: args.runId,
736
- activationId,
737
- workflowId: args.workflowId,
738
- nodeId: args.definition.id,
739
- parent: args.parent,
740
- executionOptions: args.executionOptions,
741
- batchId: args.batchId,
742
- input: args.input,
743
- ctx
744
- };
745
- }
746
- createFromPlannedActivation(args) {
747
- const activationId = this.activationIdFactory.makeActivationId();
748
- const ctx = this.createNodeExecutionContext(args, args.nodeDefinition, activationId);
749
- if (args.next.kind === "multi") return {
750
- kind: "multi",
751
- runId: args.runId,
752
- activationId,
753
- workflowId: args.workflowId,
754
- nodeId: args.nodeDefinition.id,
755
- parent: args.parent,
756
- executionOptions: args.executionOptions,
757
- batchId: args.next.batchId,
758
- inputsByPort: args.next.inputsByPort,
759
- ctx
760
- };
761
- return {
762
- kind: "single",
763
- runId: args.runId,
764
- activationId,
765
- workflowId: args.workflowId,
766
- nodeId: args.nodeDefinition.id,
767
- parent: args.parent,
768
- executionOptions: args.executionOptions,
769
- batchId: args.next.batchId,
770
- input: args.next.input,
771
- ctx
772
- };
773
- }
774
- createNodeExecutionContext(args, definition, activationId) {
775
- return {
776
- ...args.base,
777
- data: args.data,
778
- nodeId: definition.id,
779
- activationId,
780
- config: definition.config,
781
- binary: args.base.binary.forNode({
782
- nodeId: definition.id,
783
- activationId
784
- }),
785
- getCredential: this.credentialResolverFactory.create(args.workflowId, definition.id, definition.config)
786
- };
787
- }
788
- };
789
-
790
- //#endregion
791
- //#region src/execution/NodeExecutor.ts
792
- var NodeExecutor = class {
793
- constructor(nodeInstanceFactory, retryRunner) {
794
- this.nodeInstanceFactory = nodeInstanceFactory;
795
- this.retryRunner = retryRunner;
796
- }
797
- async execute(request) {
798
- const policy = request.ctx.config.retryPolicy;
799
- return await this.retryRunner.run(policy, async () => {
800
- const nodeInstance = this.nodeInstanceFactory.createByType(request.ctx.config.type);
801
- if (request.kind === "multi") return await this.executeMultiInputNode(request, nodeInstance);
802
- return await this.executeSingleInputNode(request, nodeInstance);
803
- });
804
- }
805
- async executeMultiInputNode(request, node$1) {
806
- const multiInputNode = node$1;
807
- if (typeof multiInputNode.executeMulti !== "function") throw new Error(`Node ${request.nodeId} does not support executeMulti but received multi-input activation`);
808
- return await multiInputNode.executeMulti(request.inputsByPort, request.ctx);
809
- }
810
- async executeSingleInputNode(request, node$1) {
811
- const singleInputNode = node$1;
812
- if (typeof singleInputNode.execute !== "function") throw new Error(`Node ${request.nodeId} does not support execute but received single-input activation`);
813
- return await singleInputNode.execute(request.input, request.ctx);
814
- }
815
- };
816
-
817
- //#endregion
818
- //#region src/execution/NodeExecutorFactory.ts
819
- var NodeExecutorFactory = class {
820
- create(workflowNodeInstanceFactory, retryRunner) {
821
- return new NodeExecutor(workflowNodeInstanceFactory, retryRunner);
822
- }
823
- };
824
-
825
- //#endregion
826
- //#region src/workflowSnapshots/MissingRuntimeExecutionMarker.ts
827
- var MissingRuntimeExecutionMarker = class {
828
- isMarked(config) {
829
- return Boolean(config?.missingRuntime);
830
- }
831
- };
832
-
833
- //#endregion
834
- //#region src/workflowSnapshots/MissingRuntimeNodeToken.ts
835
- var MissingRuntimeNodeToken = class {};
836
-
837
- //#endregion
838
- //#region src/workflowSnapshots/MissingRuntimeNodeConfig.ts
839
- var MissingRuntimeNodeConfig = class {
840
- kind = "node";
841
- type = MissingRuntimeNodeToken;
842
- constructor(name, missingTokenId, missingRuntime = true) {
843
- this.name = name;
844
- this.missingTokenId = missingTokenId;
845
- this.missingRuntime = missingRuntime;
846
- }
847
- };
848
-
849
- //#endregion
850
- //#region src/workflowSnapshots/MissingRuntimeTriggerToken.ts
851
- var MissingRuntimeTriggerToken = class {};
852
-
853
- //#endregion
854
- //#region src/workflowSnapshots/MissingRuntimeTriggerConfig.ts
855
- var MissingRuntimeTriggerConfig = class {
856
- kind = "trigger";
857
- type = MissingRuntimeTriggerToken;
858
- constructor(name, missingTokenId, missingRuntime = true) {
859
- this.name = name;
860
- this.missingTokenId = missingTokenId;
861
- this.missingRuntime = missingRuntime;
862
- }
863
- };
864
-
865
- //#endregion
866
- //#region src/workflowSnapshots/MissingRuntimeFallbacksFactory.ts
867
- var MissingRuntimeFallbacks = class {
868
- createDefinition(snapshotNode) {
869
- if (snapshotNode.kind === "trigger") return {
870
- id: snapshotNode.id,
871
- kind: "trigger",
872
- name: snapshotNode.name,
873
- type: MissingRuntimeTriggerToken,
874
- config: new MissingRuntimeTriggerConfig(snapshotNode.name ?? snapshotNode.id, snapshotNode.nodeTokenId)
875
- };
876
- return {
877
- id: snapshotNode.id,
878
- kind: "node",
879
- name: snapshotNode.name,
880
- type: MissingRuntimeNodeToken,
881
- config: new MissingRuntimeNodeConfig(snapshotNode.name ?? snapshotNode.id, snapshotNode.nodeTokenId)
882
- };
883
- }
884
- };
885
-
886
- //#endregion
887
- //#region src/workflowSnapshots/MissingRuntimeNode.ts
888
- var MissingRuntimeNode = class {
889
- kind = "node";
890
- outputPorts = ["main"];
891
- async execute(items) {
892
- return { main: items };
893
- }
894
- };
895
-
896
- //#endregion
897
- //#region src/workflowSnapshots/MissingRuntimeTrigger.ts
898
- var MissingRuntimeTrigger = class {
899
- kind = "trigger";
900
- outputPorts = ["main"];
901
- async setup(_ctx) {}
902
- async execute(items) {
903
- return { main: items };
904
- }
905
- };
906
-
907
- //#endregion
908
- //#region src/workflowSnapshots/PersistedRuntimeTypeIdFactory.ts
909
- var PersistedRuntimeTypeIdFactory = class {
910
- static fromMetadata(args) {
911
- const metadata = getPersistedRuntimeTypeMetadata(args.type);
912
- if (!metadata) return;
913
- const packageName = metadata.packageName;
914
- if (!packageName) return;
915
- return `${packageName}::${metadata.persistedName}`;
916
- }
917
- };
918
-
919
- //#endregion
920
- //#region src/workflowSnapshots/PersistedWorkflowTokenRegistry.ts
921
- var PersistedWorkflowTokenRegistry = class {
922
- tokensById = /* @__PURE__ */ new Map();
923
- tokenIdsByToken = /* @__PURE__ */ new Map();
924
- /**
925
- * Register a token with its package ID. Token ID is inferred as `packageId::tokenName`.
926
- */
927
- register(type, packageId, persistedNameOverride) {
928
- const tokenId = `${packageId}::${persistedNameOverride ?? this.displayNameForTypeToken(type)}`;
929
- this.tokensById.set(tokenId, type);
930
- this.tokenIdsByToken.set(type, tokenId);
931
- return tokenId;
932
- }
933
- /**
934
- * Register all decorated runtime types discovered in workflows.
935
- */
936
- registerFromWorkflows(workflows) {
937
- for (const workflow of workflows) for (const node$1 of workflow.nodes) {
938
- this.registerDecoratedType(node$1.type);
939
- this.registerDecoratedType(node$1.config.type);
940
- this.registerNestedTypes(node$1.config);
941
- }
942
- }
943
- registerDecoratedType(type) {
944
- if (this.tokenIdsByToken.has(type)) return;
945
- const tokenId = PersistedRuntimeTypeIdFactory.fromMetadata({ type });
946
- if (!tokenId) return;
947
- this.tokensById.set(tokenId, type);
948
- this.tokenIdsByToken.set(type, tokenId);
949
- }
950
- registerNestedTypes(value) {
951
- if (Array.isArray(value)) {
952
- for (const entry of value) this.registerNestedTypes(entry);
953
- return;
954
- }
955
- if (!value || typeof value !== "object") return;
956
- const record = value;
957
- const type = this.asTypeToken(record.type);
958
- if (type) this.registerDecoratedType(type);
959
- for (const v of Object.values(record)) this.registerNestedTypes(v);
960
- }
961
- displayNameForTypeToken(token) {
962
- if (typeof token === "function" && token.name) return token.name;
963
- if (typeof token === "string") return token;
964
- return "";
965
- }
966
- asTypeToken(value) {
967
- if (typeof value === "function" || typeof value === "string" || typeof value === "symbol") return value;
968
- }
969
- getTokenId(token) {
970
- const existing = this.tokenIdsByToken.get(token);
971
- if (existing) return existing;
972
- const tokenId = PersistedRuntimeTypeIdFactory.fromMetadata({ type: token });
973
- if (!tokenId) return;
974
- this.tokensById.set(tokenId, token);
975
- this.tokenIdsByToken.set(token, tokenId);
976
- return tokenId;
977
- }
978
- resolve(tokenId) {
979
- return this.tokensById.get(tokenId);
980
- }
981
- };
982
-
983
- //#endregion
984
- //#region src/workflowSnapshots/WorkflowSnapshotResolver.ts
985
- var WorkflowSnapshotResolver = class {
986
- constructor(workflowRepository, tokenRegistry, codec, missingRuntimeFallbacks) {
987
- this.workflowRepository = workflowRepository;
988
- this.tokenRegistry = tokenRegistry;
989
- this.codec = codec;
990
- this.missingRuntimeFallbacks = missingRuntimeFallbacks;
991
- }
992
- resolve(args) {
993
- const liveWorkflow = this.workflowRepository.get(args.workflowId);
994
- if (!args.workflowSnapshot) return liveWorkflow;
995
- if (!liveWorkflow) return this.rebuildWorkflow(args.workflowSnapshot, void 0);
996
- return this.rebuildWorkflow(args.workflowSnapshot, liveWorkflow);
997
- }
998
- rebuildWorkflow(snapshot, liveWorkflow) {
999
- const liveNodesById = new Map((liveWorkflow?.nodes ?? []).map((node$1) => [node$1.id, node$1]));
1000
- const nodes = snapshot.nodes.map((snapshotNode) => {
1001
- const liveNode = liveNodesById.get(snapshotNode.id);
1002
- if (!this.isCompatibleLiveNode(liveNode, snapshotNode)) return this.missingRuntimeFallbacks.createDefinition(snapshotNode);
1003
- return {
1004
- id: snapshotNode.id,
1005
- kind: snapshotNode.kind,
1006
- name: snapshotNode.name ?? liveNode.name,
1007
- type: liveNode.type,
1008
- config: this.codec.hydrate(snapshotNode, liveNode.config)
1009
- };
1010
- });
1011
- const nodeIds = new Set(nodes.map((node$1) => node$1.id));
1012
- const connectionsFromSnapshot = snapshot.connections?.map((connection) => ({
1013
- ...connection,
1014
- childNodeIds: connection.childNodeIds.filter((childId) => nodeIds.has(childId))
1015
- })).filter((connection) => connection.childNodeIds.length > 0) ?? [];
1016
- return {
1017
- id: snapshot.id,
1018
- name: snapshot.name,
1019
- nodes,
1020
- edges: snapshot.edges.filter((edge) => nodeIds.has(edge.from.nodeId) && nodeIds.has(edge.to.nodeId)),
1021
- ...connectionsFromSnapshot.length > 0 ? { connections: connectionsFromSnapshot } : {},
1022
- ...liveWorkflow?.discoveryPathSegments !== void 0 ? { discoveryPathSegments: liveWorkflow.discoveryPathSegments } : {}
1023
- };
1024
- }
1025
- isCompatibleLiveNode(liveNode, snapshotNode) {
1026
- if (!liveNode || liveNode.kind !== snapshotNode.kind) return false;
1027
- if (!snapshotNode.nodeTokenId || !snapshotNode.configTokenId) throw new Error(`Persisted workflow snapshot node "${snapshotNode.id}" is missing stable token ids.`);
1028
- const liveNodeTokenId = this.resolveLiveTokenId(liveNode.type);
1029
- const liveConfigTokenId = this.resolveLiveTokenId(liveNode.config.type);
1030
- return liveNodeTokenId === snapshotNode.nodeTokenId && liveConfigTokenId === snapshotNode.configTokenId;
1031
- }
1032
- resolveLiveTokenId(type) {
1033
- const registeredTokenId = this.tokenRegistry.getTokenId(type);
1034
- if (registeredTokenId) return registeredTokenId;
1035
- if (typeof type === "function" && type.name) return type.name;
1036
- if (typeof type === "string") return type;
1037
- }
1038
- };
1039
-
1040
- //#endregion
1041
- //#region src/execution/NodeInstanceFactory.ts
1042
- var NodeInstanceFactory = class {
1043
- constructor(nodeResolver) {
1044
- this.nodeResolver = nodeResolver;
1045
- }
1046
- createNodes(workflow) {
1047
- const nodeInstances = /* @__PURE__ */ new Map();
1048
- for (const definition of workflow.nodes) nodeInstances.set(definition.id, this.createNode(definition));
1049
- return nodeInstances;
1050
- }
1051
- createNode(definition) {
1052
- return this.createByType(definition.type);
1053
- }
1054
- createByType(type) {
1055
- if (type === MissingRuntimeNodeToken) return new MissingRuntimeNode();
1056
- if (type === MissingRuntimeTriggerToken) return new MissingRuntimeTrigger();
1057
- return this.nodeResolver.resolve(type);
1058
- }
1059
- };
1060
-
1061
- //#endregion
1062
- //#region src/execution/NodeInstanceFactoryFactory.ts
1063
- var NodeInstanceFactoryFactory = class {
1064
- create(nodeResolver) {
1065
- return new NodeInstanceFactory(nodeResolver);
1066
- }
1067
- };
1068
-
1069
- //#endregion
1070
- //#region src/execution/NodeRunStateWriter.ts
1071
- var NodeRunStateWriter = class {
1072
- chain = Promise.resolve();
1073
- constructor(workflowExecutionRepository, runId, workflowId, parent, publishNodeEvent) {
1074
- this.workflowExecutionRepository = workflowExecutionRepository;
1075
- this.runId = runId;
1076
- this.workflowId = workflowId;
1077
- this.parent = parent;
1078
- this.publishNodeEvent = publishNodeEvent;
1079
- }
1080
- markQueued(args) {
1081
- return this.enqueue(async () => {
1082
- const state = await this.loadState();
1083
- const previous = state.nodeSnapshotsByNodeId?.[args.nodeId];
1084
- const queuedAt = (/* @__PURE__ */ new Date()).toISOString();
1085
- const snapshot = NodeExecutionSnapshotFactory.queued({
1086
- runId: this.runId,
1087
- workflowId: this.workflowId,
1088
- nodeId: args.nodeId,
1089
- activationId: args.activationId ?? previous?.activationId ?? `synthetic_${args.nodeId}`,
1090
- parent: this.parent,
1091
- queuedAt,
1092
- inputsByPort: args.inputsByPort ?? previous?.inputsByPort ?? NodeInputsByPortFactory.empty()
1093
- });
1094
- await this.saveSnapshot(state, snapshot);
1095
- await this.publishNodeEvent("nodeQueued", snapshot);
1096
- });
1097
- }
1098
- markRunning(args) {
1099
- return this.enqueue(async () => {
1100
- const state = await this.loadState();
1101
- const previous = state.nodeSnapshotsByNodeId?.[args.nodeId];
1102
- const startedAt = (/* @__PURE__ */ new Date()).toISOString();
1103
- const snapshot = NodeExecutionSnapshotFactory.running({
1104
- previous,
1105
- runId: this.runId,
1106
- workflowId: this.workflowId,
1107
- nodeId: args.nodeId,
1108
- activationId: args.activationId ?? previous?.activationId ?? `synthetic_${args.nodeId}`,
1109
- parent: this.parent,
1110
- startedAt,
1111
- inputsByPort: args.inputsByPort ?? previous?.inputsByPort ?? NodeInputsByPortFactory.empty()
1112
- });
1113
- await this.saveSnapshot(state, snapshot);
1114
- await this.publishNodeEvent("nodeStarted", snapshot);
1115
- });
1116
- }
1117
- markCompleted(args) {
1118
- return this.enqueue(async () => {
1119
- const state = await this.loadState();
1120
- const previous = state.nodeSnapshotsByNodeId?.[args.nodeId];
1121
- const finishedAt = (/* @__PURE__ */ new Date()).toISOString();
1122
- const snapshot = NodeExecutionSnapshotFactory.completed({
1123
- previous,
1124
- runId: this.runId,
1125
- workflowId: this.workflowId,
1126
- nodeId: args.nodeId,
1127
- activationId: args.activationId ?? previous?.activationId ?? `synthetic_${args.nodeId}`,
1128
- parent: this.parent,
1129
- finishedAt,
1130
- inputsByPort: args.inputsByPort ?? previous?.inputsByPort ?? NodeInputsByPortFactory.empty(),
1131
- outputs: args.outputs ?? previous?.outputs ?? {}
1132
- });
1133
- await this.saveSnapshot(state, snapshot);
1134
- await this.publishNodeEvent("nodeCompleted", snapshot);
1135
- });
1136
- }
1137
- markFailed(args) {
1138
- return this.enqueue(async () => {
1139
- const state = await this.loadState();
1140
- const previous = state.nodeSnapshotsByNodeId?.[args.nodeId];
1141
- const finishedAt = (/* @__PURE__ */ new Date()).toISOString();
1142
- const snapshot = NodeExecutionSnapshotFactory.failed({
1143
- previous,
1144
- runId: this.runId,
1145
- workflowId: this.workflowId,
1146
- nodeId: args.nodeId,
1147
- activationId: args.activationId ?? previous?.activationId ?? `synthetic_${args.nodeId}`,
1148
- parent: this.parent,
1149
- finishedAt,
1150
- inputsByPort: args.inputsByPort ?? previous?.inputsByPort ?? NodeInputsByPortFactory.empty(),
1151
- error: args.error
1152
- });
1153
- await this.saveSnapshot(state, snapshot);
1154
- await this.publishNodeEvent("nodeFailed", snapshot);
1155
- });
1156
- }
1157
- appendConnectionInvocation(args) {
1158
- return this.enqueue(async () => {
1159
- const state = await this.loadState();
1160
- const updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1161
- const record = {
1162
- invocationId: args.invocationId,
1163
- runId: this.runId,
1164
- workflowId: this.workflowId,
1165
- connectionNodeId: args.connectionNodeId,
1166
- parentAgentNodeId: args.parentAgentNodeId,
1167
- parentAgentActivationId: args.parentAgentActivationId,
1168
- status: args.status,
1169
- managedInput: args.managedInput,
1170
- managedOutput: args.managedOutput,
1171
- error: args.error,
1172
- queuedAt: args.queuedAt,
1173
- startedAt: args.startedAt,
1174
- finishedAt: args.finishedAt,
1175
- updatedAt
1176
- };
1177
- await this.workflowExecutionRepository.save({
1178
- ...state,
1179
- connectionInvocations: [...state.connectionInvocations ?? [], record]
1180
- });
1181
- });
1182
- }
1183
- enqueue(work) {
1184
- const next = this.chain.then(work);
1185
- this.chain = next.catch(() => void 0);
1186
- return next;
1187
- }
1188
- async loadState() {
1189
- const state = await this.workflowExecutionRepository.load(this.runId);
1190
- if (!state) throw new Error(`Unknown runId: ${this.runId}`);
1191
- return state;
1192
- }
1193
- async saveSnapshot(state, snapshot) {
1194
- await this.workflowExecutionRepository.save({
1195
- ...state,
1196
- nodeSnapshotsByNodeId: {
1197
- ...state.nodeSnapshotsByNodeId ?? {},
1198
- [snapshot.nodeId]: snapshot
1199
- }
1200
- });
1201
- }
1202
- };
1203
-
1204
- //#endregion
1205
- //#region src/execution/NodeRunStateWriterFactory.ts
1206
- var NodeRunStateWriterFactory = class {
1207
- constructor(workflowExecutionRepository, nodeEventPublisher) {
1208
- this.workflowExecutionRepository = workflowExecutionRepository;
1209
- this.nodeEventPublisher = nodeEventPublisher;
1210
- }
1211
- create(runId, workflowId, parent) {
1212
- return new NodeRunStateWriter(this.workflowExecutionRepository, runId, workflowId, parent, async (kind, snapshot) => {
1213
- await this.nodeEventPublisher.publish(kind, snapshot);
1214
- });
1215
- }
1216
- };
1217
-
1218
- //#endregion
1219
- //#region src/execution/PersistedRunStateTerminalBuilder.ts
1220
- /**
1221
- * Merges common terminal-run fields onto a loaded {@link PersistedRunState} without repeating object literals.
1222
- */
1223
- var PersistedRunStateTerminalBuilder = class {
1224
- mergeTerminal(args) {
1225
- return {
1226
- ...args.state,
1227
- engineCounters: args.engineCounters,
1228
- status: args.status,
1229
- pending: void 0,
1230
- queue: args.queue,
1231
- outputsByNode: args.outputsByNode,
1232
- nodeSnapshotsByNodeId: args.nodeSnapshotsByNodeId
1233
- };
1234
- }
1235
- };
1236
-
1237
- //#endregion
1238
- //#region src/execution/RunStateSemantics.ts
1239
- var RunStateSemantics = class {
1240
- constructor(missingRuntimeExecutionMarker) {
1241
- this.missingRuntimeExecutionMarker = missingRuntimeExecutionMarker;
1242
- }
1243
- isStopConditionSatisfied(stopCondition, nodeId) {
1244
- if (!stopCondition || stopCondition.kind === "workflowCompleted") return false;
1245
- return stopCondition.nodeId === nodeId;
1246
- }
1247
- resolveResultOutputs(workflow, stopCondition, outputsByNode) {
1248
- if (stopCondition?.kind === "nodeCompleted") return outputsByNode[stopCondition.nodeId]?.main ?? [];
1249
- return outputsByNode[WorkflowExecutableNodeClassifierFactory.create(workflow).lastExecutableNodeIdInDefinitionOrder(workflow)]?.main ?? [];
1250
- }
1251
- applySkippedSnapshots(args) {
1252
- const snapshots = { ...args.currentState.nodeSnapshotsByNodeId };
1253
- const skippedPinnedNodeIds = new Set(args.preservedPinnedNodeIds.filter((nodeId) => args.skippedNodeIds.includes(nodeId)));
1254
- for (const nodeId of args.skippedNodeIds) if (args.currentState.mutableState?.nodesById?.[nodeId]?.pinnedOutputsByPort) skippedPinnedNodeIds.add(nodeId);
1255
- for (const nodeId of skippedPinnedNodeIds) {
1256
- const previous = snapshots[nodeId];
1257
- snapshots[nodeId] = NodeExecutionSnapshotFactory.completed({
1258
- previous,
1259
- runId: args.runId,
1260
- workflowId: args.workflowId,
1261
- nodeId,
1262
- activationId: previous?.activationId ?? `synthetic_${nodeId}`,
1263
- parent: args.parent,
1264
- finishedAt: args.finishedAt,
1265
- inputsByPort: previous?.inputsByPort ?? NodeInputsByPortFactory.empty(),
1266
- outputs: args.currentState.outputsByNode[nodeId] ?? {},
1267
- fromPinnedOutput: true
1268
- });
1269
- }
1270
- return snapshots;
1271
- }
1272
- applyPinnedQueueSkips(args) {
1273
- let changed = true;
1274
- while (changed) {
1275
- changed = false;
1276
- for (let index = 0; index < args.queue.length; index += 1) {
1277
- const queueEntry = args.queue[index];
1278
- const pinnedOutputs = args.mutableState?.nodesById?.[queueEntry.nodeId]?.pinnedOutputsByPort;
1279
- if (!pinnedOutputs) continue;
1280
- args.queue.splice(index, 1);
1281
- const previous = args.nodeSnapshotsByNodeId[queueEntry.nodeId];
1282
- args.nodeSnapshotsByNodeId[queueEntry.nodeId] = NodeExecutionSnapshotFactory.completed({
1283
- previous,
1284
- runId: args.runId,
1285
- workflowId: args.workflowId,
1286
- nodeId: queueEntry.nodeId,
1287
- activationId: previous?.activationId ?? `synthetic_${queueEntry.nodeId}`,
1288
- parent: args.parent,
1289
- finishedAt: args.finishedAt,
1290
- inputsByPort: this.resolveQueueEntryInputsByPort(queueEntry),
1291
- outputs: pinnedOutputs,
1292
- fromPinnedOutput: true
1293
- });
1294
- args.data.setOutputs(queueEntry.nodeId, pinnedOutputs);
1295
- args.planner.applyOutputs(args.queue, {
1296
- fromNodeId: queueEntry.nodeId,
1297
- outputs: pinnedOutputs,
1298
- batchId: queueEntry.batchId ?? "batch_1"
1299
- });
1300
- changed = true;
1301
- break;
1302
- }
1303
- }
1304
- }
1305
- createFinishedSnapshot(args) {
1306
- const definition = args.workflow.nodes.find((node$1) => node$1.id === args.nodeId);
1307
- if (this.missingRuntimeExecutionMarker.isMarked(definition?.config)) return NodeExecutionSnapshotFactory.skipped(args);
1308
- return NodeExecutionSnapshotFactory.completed(args);
1309
- }
1310
- resolveQueueEntryInputsByPort(queueEntry) {
1311
- if (queueEntry.collect) return queueEntry.collect.received;
1312
- return { [queueEntry.toInput ?? "in"]: queueEntry.input };
1313
- }
1314
- };
1315
-
1316
- //#endregion
1317
- //#region src/execution/WorkflowRunExecutionContextFactory.ts
1318
- /**
1319
- * Shared {@link ExecutionContextFactory#create} wiring for workflow runners (base context before node-specific fields).
1320
- */
1321
- var WorkflowRunExecutionContextFactory = class {
1322
- constructor(executionContextFactory, credentialResolverFactory) {
1323
- this.executionContextFactory = executionContextFactory;
1324
- this.credentialResolverFactory = credentialResolverFactory;
1325
- }
1326
- create(args) {
1327
- return this.executionContextFactory.create({
1328
- runId: args.runId,
1329
- workflowId: args.workflowId,
1330
- parent: args.parent,
1331
- subworkflowDepth: args.subworkflowDepth,
1332
- engineMaxNodeActivations: args.engineMaxNodeActivations,
1333
- engineMaxSubworkflowDepth: args.engineMaxSubworkflowDepth,
1334
- data: args.data,
1335
- nodeState: args.nodeState,
1336
- getCredential: this.credentialResolverFactory.create(args.workflowId, args.nodeId)
1337
- });
1338
- }
1339
- };
1340
-
1341
- //#endregion
1342
- //#region src/planning/WorkflowTopologyPlanner.ts
1343
- var WorkflowTopology = class WorkflowTopology {
1344
- constructor(defsById, outgoingByNode, incomingByNode, expectedInputsByNode, rootNodeIds) {
1345
- this.defsById = defsById;
1346
- this.outgoingByNode = outgoingByNode;
1347
- this.incomingByNode = incomingByNode;
1348
- this.expectedInputsByNode = expectedInputsByNode;
1349
- this.rootNodeIds = rootNodeIds;
1350
- }
1351
- static fromWorkflow(wf) {
1352
- const classifier = WorkflowExecutableNodeClassifierFactory.create(wf);
1353
- const defs = /* @__PURE__ */ new Map();
1354
- for (const n of wf.nodes) if (classifier.isExecutableNodeId(n.id)) defs.set(n.id, n);
1355
- const outgoing = /* @__PURE__ */ new Map();
1356
- for (const e of wf.edges) {
1357
- if (!classifier.isExecutableNodeId(e.from.nodeId) || !classifier.isExecutableNodeId(e.to.nodeId)) continue;
1358
- const list = outgoing.get(e.from.nodeId) ?? [];
1359
- list.push({
1360
- output: e.from.output,
1361
- to: {
1362
- nodeId: e.to.nodeId,
1363
- input: e.to.input
1364
- }
1365
- });
1366
- outgoing.set(e.from.nodeId, list);
1367
- }
1368
- const incomingByNode = /* @__PURE__ */ new Map();
1369
- for (const e of wf.edges) {
1370
- if (!classifier.isExecutableNodeId(e.from.nodeId) || !classifier.isExecutableNodeId(e.to.nodeId)) continue;
1371
- const list = incomingByNode.get(e.to.nodeId) ?? [];
1372
- list.push({
1373
- from: {
1374
- nodeId: e.from.nodeId,
1375
- output: e.from.output
1376
- },
1377
- input: e.to.input
1378
- });
1379
- incomingByNode.set(e.to.nodeId, list);
1380
- }
1381
- const expected = /* @__PURE__ */ new Map();
1382
- for (const [toNodeId, inputs] of incomingByNode.entries()) {
1383
- const counts = /* @__PURE__ */ new Map();
1384
- for (const edge of inputs) counts.set(edge.input, (counts.get(edge.input) ?? 0) + 1);
1385
- for (const [k, n] of counts.entries()) if (n > 1) throw new Error(`Node ${toNodeId} has multiple edges into input '${k}'. Use a Merge node upstream.`);
1386
- const order = [];
1387
- const seen = /* @__PURE__ */ new Set();
1388
- for (const edge of inputs) {
1389
- if (seen.has(edge.input)) continue;
1390
- seen.add(edge.input);
1391
- order.push(edge.input);
1392
- }
1393
- expected.set(toNodeId, order);
1394
- }
1395
- return new WorkflowTopology(defs, outgoing, incomingByNode, expected, wf.nodes.filter((node$1) => classifier.isExecutableNodeId(node$1.id) && !incomingByNode.has(node$1.id)).map((node$1) => node$1.id));
1396
- }
1397
- };
1398
-
1399
- //#endregion
1400
- //#region src/orchestration/RunContinuationService.ts
1401
- var RunContinuationService = class {
1402
- constructor(activationIdFactory, workflowExecutionRepository, runDataFactory, runExecutionContextFactory, workflowSnapshotResolver, planningFactory, nodeStatePublisherFactory, credentialResolverFactory, nodeActivationRequestComposer, persistedRunStateTerminalBuilder, activationEnqueueService, nodeEventPublisher, semantics, waiters, policyErrorServices, terminalPersistence, executionLimitsPolicy) {
1403
- this.activationIdFactory = activationIdFactory;
1404
- this.workflowExecutionRepository = workflowExecutionRepository;
1405
- this.runDataFactory = runDataFactory;
1406
- this.runExecutionContextFactory = runExecutionContextFactory;
1407
- this.workflowSnapshotResolver = workflowSnapshotResolver;
1408
- this.planningFactory = planningFactory;
1409
- this.nodeStatePublisherFactory = nodeStatePublisherFactory;
1410
- this.credentialResolverFactory = credentialResolverFactory;
1411
- this.nodeActivationRequestComposer = nodeActivationRequestComposer;
1412
- this.persistedRunStateTerminalBuilder = persistedRunStateTerminalBuilder;
1413
- this.activationEnqueueService = activationEnqueueService;
1414
- this.nodeEventPublisher = nodeEventPublisher;
1415
- this.semantics = semantics;
1416
- this.waiters = waiters;
1417
- this.policyErrorServices = policyErrorServices;
1418
- this.terminalPersistence = terminalPersistence;
1419
- this.executionLimitsPolicy = executionLimitsPolicy;
1420
- }
1421
- async markNodeRunning(args) {
1422
- const state = await this.workflowExecutionRepository.load(args.runId);
1423
- if (!state?.pending) return;
1424
- if (state.pending.activationId !== args.activationId || state.pending.nodeId !== args.nodeId) return;
1425
- const startedAt = (/* @__PURE__ */ new Date()).toISOString();
1426
- const previous = state.nodeSnapshotsByNodeId?.[args.nodeId];
1427
- const snapshot = NodeExecutionSnapshotFactory.running({
1428
- previous,
1429
- runId: state.runId,
1430
- workflowId: state.workflowId,
1431
- nodeId: args.nodeId,
1432
- activationId: args.activationId,
1433
- parent: state.parent,
1434
- startedAt,
1435
- inputsByPort: args.inputsByPort
1436
- });
1437
- await this.workflowExecutionRepository.save({
1438
- ...state,
1439
- nodeSnapshotsByNodeId: {
1440
- ...state.nodeSnapshotsByNodeId ?? {},
1441
- [args.nodeId]: snapshot
1442
- }
1443
- });
1444
- await this.nodeEventPublisher.publish("nodeStarted", snapshot);
1445
- }
1446
- async resumeFromNodeResult(args) {
1447
- const state = await this.workflowExecutionRepository.load(args.runId);
1448
- if (!state) throw new Error(`Unknown runId: ${args.runId}`);
1449
- if (state.status !== "pending" || !state.pending) throw new Error(`Run ${args.runId} is not pending`);
1450
- if (state.pending.activationId !== args.activationId) throw new Error(`activationId mismatch for run ${args.runId}`);
1451
- if (state.pending.nodeId !== args.nodeId) throw new Error(`nodeId mismatch for run ${args.runId}`);
1452
- const wf = this.resolvePersistedWorkflow(state);
1453
- if (!wf) throw new Error(`Unknown workflowId: ${state.workflowId}`);
1454
- const { topology, planner } = this.planningFactory.create(wf);
1455
- const data = this.runDataFactory.create(state.outputsByNode);
1456
- const limits = this.resolveEngineLimitsFromState(state);
1457
- const base = this.runExecutionContextFactory.create({
1458
- runId: state.runId,
1459
- workflowId: state.workflowId,
1460
- nodeId: args.nodeId,
1461
- parent: state.parent,
1462
- subworkflowDepth: state.executionOptions?.subworkflowDepth ?? 0,
1463
- engineMaxNodeActivations: limits.engineMaxNodeActivations,
1464
- engineMaxSubworkflowDepth: limits.engineMaxSubworkflowDepth,
1465
- data,
1466
- nodeState: this.nodeStatePublisherFactory.create(state.runId, state.workflowId, state.parent)
1467
- });
1468
- data.setOutputs(args.nodeId, args.outputs);
1469
- const completedAt = (/* @__PURE__ */ new Date()).toISOString();
1470
- const completedSnapshot = this.semantics.createFinishedSnapshot({
1471
- workflow: wf,
1472
- previous: state.nodeSnapshotsByNodeId?.[args.nodeId],
1473
- runId: state.runId,
1474
- workflowId: state.workflowId,
1475
- nodeId: args.nodeId,
1476
- activationId: args.activationId,
1477
- parent: state.parent,
1478
- finishedAt: completedAt,
1479
- inputsByPort: state.pending.inputsByPort,
1480
- outputs: args.outputs
1481
- });
1482
- const completedActivations = (state.engineCounters?.completedNodeActivations ?? 0) + 1;
1483
- const engineCounters = { completedNodeActivations: completedActivations };
1484
- const maxNodeActivations = state.executionOptions?.maxNodeActivations ?? Number.MAX_SAFE_INTEGER;
1485
- if (this.semantics.isStopConditionSatisfied(state.control?.stopCondition, args.nodeId)) {
1486
- const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({
1487
- state,
1488
- engineCounters,
1489
- status: "completed",
1490
- queue: [],
1491
- outputsByNode: data.dump(),
1492
- nodeSnapshotsByNodeId: {
1493
- ...state.nodeSnapshotsByNodeId ?? {},
1494
- [args.nodeId]: completedSnapshot
1495
- }
1496
- });
1497
- await this.workflowExecutionRepository.save(completedState);
1498
- await this.nodeEventPublisher.publish("nodeCompleted", completedSnapshot);
1499
- await this.terminalPersistence.maybeDeleteAfterTerminalState({
1500
- workflow: wf,
1501
- state: completedState,
1502
- finalStatus: "completed",
1503
- finishedAt: completedAt
1504
- });
1505
- const result$1 = {
1506
- runId: state.runId,
1507
- workflowId: state.workflowId,
1508
- startedAt: state.startedAt,
1509
- status: "completed",
1510
- outputs: this.semantics.resolveResultOutputs(wf, state.control?.stopCondition, data.dump())
1511
- };
1512
- this.waiters.resolveRunCompletion(result$1);
1513
- return result$1;
1514
- }
1515
- const batchId = state.pending.batchId ?? "batch_1";
1516
- const queue = (state.queue ?? []).map((q) => ({
1517
- ...q,
1518
- batchId: q.batchId ?? batchId
1519
- }));
1520
- const nextNodeSnapshotsByNodeId = {
1521
- ...state.nodeSnapshotsByNodeId ?? {},
1522
- [args.nodeId]: completedSnapshot
1523
- };
1524
- planner.applyOutputs(queue, {
1525
- fromNodeId: args.nodeId,
1526
- outputs: args.outputs,
1527
- batchId
1528
- });
1529
- this.semantics.applyPinnedQueueSkips({
1530
- runId: state.runId,
1531
- workflowId: state.workflowId,
1532
- parent: state.parent,
1533
- mutableState: state.mutableState,
1534
- planner,
1535
- queue,
1536
- data,
1537
- nodeSnapshotsByNodeId: nextNodeSnapshotsByNodeId,
1538
- finishedAt: completedAt
1539
- });
1540
- let next;
1541
- try {
1542
- next = planner.nextActivation(queue);
1543
- } catch (cause) {
1544
- const completedDefinition = topology.defsById.get(args.nodeId);
1545
- const completedNodeLabel = this.formatNodeLabel({
1546
- definition: completedDefinition,
1547
- nodeId: args.nodeId
1548
- });
1549
- const reason = cause instanceof Error ? cause.message : String(cause);
1550
- throw new Error(`After completing ${completedNodeLabel}, the engine could not plan the next activation. ${reason} Outputs: ${this.formatOutputCounts(args.outputs)}.`, { cause });
1551
- }
1552
- if (!next) {
1553
- const lastNodeId = WorkflowExecutableNodeClassifierFactory.create(wf).lastExecutableNodeIdInDefinitionOrder(wf);
1554
- const outputs = data.getOutputItems(lastNodeId, "main");
1555
- const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({
1556
- state,
1557
- engineCounters,
1558
- status: "completed",
1559
- queue: [],
1560
- outputsByNode: data.dump(),
1561
- nodeSnapshotsByNodeId: nextNodeSnapshotsByNodeId
1562
- });
1563
- await this.workflowExecutionRepository.save(completedState);
1564
- await this.nodeEventPublisher.publish("nodeCompleted", completedSnapshot);
1565
- await this.terminalPersistence.maybeDeleteAfterTerminalState({
1566
- workflow: wf,
1567
- state: completedState,
1568
- finalStatus: "completed",
1569
- finishedAt: completedAt
1570
- });
1571
- const result$1 = {
1572
- runId: state.runId,
1573
- workflowId: state.workflowId,
1574
- startedAt: state.startedAt,
1575
- status: "completed",
1576
- outputs
1577
- };
1578
- this.waiters.resolveRunCompletion(result$1);
1579
- return result$1;
1580
- }
1581
- if (completedActivations >= maxNodeActivations) {
1582
- const message = `Run exceeded maxNodeActivations (${maxNodeActivations}) after ${completedActivations} completed node activations (next would be ${next.nodeId}).`;
1583
- const failedState = this.persistedRunStateTerminalBuilder.mergeTerminal({
1584
- state,
1585
- engineCounters,
1586
- status: "failed",
1587
- queue: queue.map((q) => ({ ...q })),
1588
- outputsByNode: data.dump(),
1589
- nodeSnapshotsByNodeId: nextNodeSnapshotsByNodeId
1590
- });
1591
- await this.workflowExecutionRepository.save(failedState);
1592
- await this.nodeEventPublisher.publish("nodeCompleted", completedSnapshot);
1593
- await this.terminalPersistence.maybeDeleteAfterTerminalState({
1594
- workflow: wf,
1595
- state: failedState,
1596
- finalStatus: "failed",
1597
- finishedAt: completedAt
1598
- });
1599
- const result$1 = {
1600
- runId: state.runId,
1601
- workflowId: state.workflowId,
1602
- startedAt: state.startedAt,
1603
- status: "failed",
1604
- error: { message }
1605
- };
1606
- this.waiters.resolveRunCompletion(result$1);
1607
- return result$1;
1608
- }
1609
- const def = topology.defsById.get(next.nodeId);
1610
- if (!def || def.kind !== "node") throw new Error(`Node ${next.nodeId} is not a runnable node`);
1611
- const request = this.nodeActivationRequestComposer.createFromPlannedActivation({
1612
- next,
1613
- base,
1614
- data,
1615
- runId: state.runId,
1616
- workflowId: state.workflowId,
1617
- parent: state.parent,
1618
- executionOptions: state.executionOptions,
1619
- nodeDefinition: def
1620
- });
1621
- const { queuedSnapshot, result } = await this.activationEnqueueService.enqueueActivationWithSnapshot({
1622
- runId: state.runId,
1623
- workflowId: state.workflowId,
1624
- startedAt: state.startedAt,
1625
- parent: state.parent,
1626
- executionOptions: state.executionOptions,
1627
- control: state.control,
1628
- workflowSnapshot: state.workflowSnapshot,
1629
- mutableState: state.mutableState,
1630
- policySnapshot: state.policySnapshot,
1631
- pendingQueue: queue,
1632
- request,
1633
- previousNodeSnapshotsByNodeId: nextNodeSnapshotsByNodeId,
1634
- planner,
1635
- engineCounters,
1636
- connectionInvocations: state.connectionInvocations ?? []
1637
- });
1638
- await this.nodeEventPublisher.publish("nodeCompleted", completedSnapshot);
1639
- await this.nodeEventPublisher.publish("nodeQueued", queuedSnapshot);
1640
- return result;
1641
- }
1642
- async resumeFromNodeError(args) {
1643
- const state = await this.workflowExecutionRepository.load(args.runId);
1644
- if (!state) throw new Error(`Unknown runId: ${args.runId}`);
1645
- if (state.status !== "pending" || !state.pending) throw new Error(`Run ${args.runId} is not pending`);
1646
- if (state.pending.activationId !== args.activationId) throw new Error(`activationId mismatch for run ${args.runId}`);
1647
- if (state.pending.nodeId !== args.nodeId) throw new Error(`nodeId mismatch for run ${args.runId}`);
1648
- const wf = this.resolvePersistedWorkflow(state);
1649
- if (!wf) throw new Error(`Unknown workflowId: ${state.workflowId}`);
1650
- const failedDefinition = WorkflowTopology.fromWorkflow(wf).defsById.get(args.nodeId);
1651
- const webhookControlSignal = state.executionOptions?.webhook && failedDefinition?.kind === "trigger" ? this.asWebhookControlSignal(args.error) : void 0;
1652
- if (webhookControlSignal) return await this.resumeFromWebhookControl({
1653
- state,
1654
- workflow: wf,
1655
- args,
1656
- signal: webhookControlSignal
1657
- });
1658
- if (failedDefinition && failedDefinition.kind === "node") {
1659
- const nodeHandler = this.policyErrorServices.resolveNodeErrorHandler(failedDefinition.config.nodeErrorHandler);
1660
- if (nodeHandler) try {
1661
- const ctx = this.buildNodeExecutionContextForPending(state, wf, failedDefinition, args.nodeId);
1662
- const inputsByPort = state.pending.inputsByPort;
1663
- const portKeys = Object.keys(inputsByPort);
1664
- const kind = portKeys.length === 1 && portKeys[0] === "in" ? "single" : "multi";
1665
- const items = inputsByPort.in ?? [];
1666
- const recovered = await nodeHandler.handle({
1667
- kind,
1668
- items,
1669
- inputsByPort: kind === "multi" ? inputsByPort : void 0,
1670
- ctx,
1671
- error: args.error
1672
- });
1673
- return await this.resumeFromNodeResult({
1674
- runId: args.runId,
1675
- activationId: args.activationId,
1676
- nodeId: args.nodeId,
1677
- outputs: recovered
1678
- });
1679
- } catch {}
1680
- }
1681
- const finishedAt = (/* @__PURE__ */ new Date()).toISOString();
1682
- const message = args.error?.message ?? String(args.error);
1683
- const failedSnapshot = NodeExecutionSnapshotFactory.failed({
1684
- previous: state.nodeSnapshotsByNodeId?.[args.nodeId],
1685
- runId: state.runId,
1686
- workflowId: state.workflowId,
1687
- nodeId: args.nodeId,
1688
- activationId: args.activationId,
1689
- parent: state.parent,
1690
- finishedAt,
1691
- inputsByPort: state.pending.inputsByPort,
1692
- error: args.error
1693
- });
1694
- const failedState = this.persistedRunStateTerminalBuilder.mergeTerminal({
1695
- state,
1696
- engineCounters: state.engineCounters ?? { completedNodeActivations: 0 },
1697
- status: "failed",
1698
- queue: (state.queue ?? []).map((q) => ({ ...q })),
1699
- outputsByNode: state.outputsByNode,
1700
- nodeSnapshotsByNodeId: {
1701
- ...state.nodeSnapshotsByNodeId ?? {},
1702
- [args.nodeId]: failedSnapshot
1703
- }
1704
- });
1705
- await this.workflowExecutionRepository.save(failedState);
1706
- await this.nodeEventPublisher.publish("nodeFailed", failedSnapshot);
1707
- const wfErr = this.policyErrorServices.resolveWorkflowErrorHandler(wf.workflowErrorHandler);
1708
- if (wfErr) await Promise.resolve(wfErr.onError({
1709
- runId: state.runId,
1710
- workflowId: state.workflowId,
1711
- workflow: wf,
1712
- failedNodeId: args.nodeId,
1713
- error: args.error,
1714
- startedAt: state.startedAt,
1715
- finishedAt
1716
- }));
1717
- await this.terminalPersistence.maybeDeleteAfterTerminalState({
1718
- workflow: wf,
1719
- state: failedState,
1720
- finalStatus: "failed",
1721
- finishedAt
1722
- });
1723
- const result = {
1724
- runId: state.runId,
1725
- workflowId: state.workflowId,
1726
- startedAt: state.startedAt,
1727
- status: "failed",
1728
- error: { message }
1729
- };
1730
- this.waiters.resolveRunCompletion(result);
1731
- return result;
1732
- }
1733
- async resumeFromStepResult(args) {
1734
- return await this.resumeFromNodeResult(args);
1735
- }
1736
- async resumeFromStepError(args) {
1737
- return await this.resumeFromNodeError(args);
1738
- }
1739
- async waitForCompletion(runId) {
1740
- const existing = await this.workflowExecutionRepository.load(runId);
1741
- if (existing?.status === "completed") {
1742
- const wf = this.resolvePersistedWorkflow(existing);
1743
- const outputs = wf ? this.semantics.resolveResultOutputs(wf, existing.control?.stopCondition, existing.outputsByNode) : [];
1744
- return {
1745
- runId: existing.runId,
1746
- workflowId: existing.workflowId,
1747
- startedAt: existing.startedAt,
1748
- status: "completed",
1749
- outputs
1750
- };
1751
- }
1752
- if (existing?.status === "failed") return {
1753
- runId: existing.runId,
1754
- workflowId: existing.workflowId,
1755
- startedAt: existing.startedAt,
1756
- status: "failed",
1757
- error: { message: "Run failed" }
1758
- };
1759
- const result = await this.waiters.waitForCompletion(runId);
1760
- if (result.status !== "completed" && result.status !== "failed") throw new Error(`Unexpected run completion status: ${result.status}`);
1761
- return result;
1762
- }
1763
- async waitForWebhookResponse(runId) {
1764
- return await this.waiters.waitForWebhookResponse(runId);
1765
- }
1766
- async resumeFromWebhookControl(args) {
1767
- const data = this.runDataFactory.create(args.state.outputsByNode);
1768
- const { topology, planner } = this.planningFactory.create(args.workflow);
1769
- const triggerOutputs = { main: args.signal.kind === "respondNowAndContinue" ? args.signal.continueItems ?? [] : args.signal.responseItems };
1770
- data.setOutputs(args.args.nodeId, triggerOutputs);
1771
- const completedSnapshot = this.semantics.createFinishedSnapshot({
1772
- workflow: args.workflow,
1773
- previous: args.state.nodeSnapshotsByNodeId?.[args.args.nodeId],
1774
- runId: args.state.runId,
1775
- workflowId: args.state.workflowId,
1776
- nodeId: args.args.nodeId,
1777
- activationId: args.args.activationId,
1778
- parent: args.state.parent,
1779
- finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
1780
- inputsByPort: args.state.pending?.inputsByPort ?? NodeInputsByPortFactory.empty(),
1781
- outputs: triggerOutputs
1782
- });
1783
- const completedActivations = (args.state.engineCounters?.completedNodeActivations ?? 0) + 1;
1784
- const engineCounters = { completedNodeActivations: completedActivations };
1785
- const maxNodeActivations = args.state.executionOptions?.maxNodeActivations ?? Number.MAX_SAFE_INTEGER;
1786
- if (this.semantics.isStopConditionSatisfied(args.state.control?.stopCondition, args.args.nodeId)) {
1787
- const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({
1788
- state: args.state,
1789
- engineCounters,
1790
- status: "completed",
1791
- queue: [],
1792
- outputsByNode: data.dump(),
1793
- nodeSnapshotsByNodeId: {
1794
- ...args.state.nodeSnapshotsByNodeId ?? {},
1795
- [args.args.nodeId]: completedSnapshot
1796
- }
1797
- });
1798
- await this.workflowExecutionRepository.save(completedState);
1799
- await this.nodeEventPublisher.publish("nodeCompleted", completedSnapshot);
1800
- await this.terminalPersistence.maybeDeleteAfterTerminalState({
1801
- workflow: args.workflow,
1802
- state: completedState,
1803
- finalStatus: "completed",
1804
- finishedAt: completedSnapshot.finishedAt ?? completedSnapshot.updatedAt
1805
- });
1806
- this.waiters.resolveWebhookResponse({
1807
- runId: args.state.runId,
1808
- workflowId: args.state.workflowId,
1809
- startedAt: args.state.startedAt,
1810
- runStatus: "completed",
1811
- response: args.signal.responseItems
1812
- });
1813
- const result$1 = {
1814
- runId: args.state.runId,
1815
- workflowId: args.state.workflowId,
1816
- startedAt: args.state.startedAt,
1817
- status: "completed",
1818
- outputs: this.semantics.resolveResultOutputs(args.workflow, args.state.control?.stopCondition, data.dump())
1819
- };
1820
- this.waiters.resolveRunCompletion(result$1);
1821
- return result$1;
1822
- }
1823
- if (args.signal.kind === "respondNow") {
1824
- const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({
1825
- state: args.state,
1826
- engineCounters,
1827
- status: "completed",
1828
- queue: [],
1829
- outputsByNode: data.dump(),
1830
- nodeSnapshotsByNodeId: {
1831
- ...args.state.nodeSnapshotsByNodeId ?? {},
1832
- [args.args.nodeId]: completedSnapshot
1833
- }
1834
- });
1835
- await this.workflowExecutionRepository.save(completedState);
1836
- await this.nodeEventPublisher.publish("nodeCompleted", completedSnapshot);
1837
- await this.terminalPersistence.maybeDeleteAfterTerminalState({
1838
- workflow: args.workflow,
1839
- state: completedState,
1840
- finalStatus: "completed",
1841
- finishedAt: completedSnapshot.finishedAt ?? completedSnapshot.updatedAt
1842
- });
1843
- const result$1 = {
1844
- runId: args.state.runId,
1845
- workflowId: args.state.workflowId,
1846
- startedAt: args.state.startedAt,
1847
- status: "completed",
1848
- outputs: args.signal.responseItems
1849
- };
1850
- this.waiters.resolveWebhookResponse({
1851
- runId: args.state.runId,
1852
- workflowId: args.state.workflowId,
1853
- startedAt: args.state.startedAt,
1854
- runStatus: "completed",
1855
- response: args.signal.responseItems
1856
- });
1857
- this.waiters.resolveRunCompletion(result$1);
1858
- return result$1;
1859
- }
1860
- const batchId = args.state.pending?.batchId ?? "batch_1";
1861
- const queue = (args.state.queue ?? []).map((entry) => ({
1862
- ...entry,
1863
- batchId: entry.batchId ?? batchId
1864
- }));
1865
- planner.applyOutputs(queue, {
1866
- fromNodeId: args.args.nodeId,
1867
- outputs: triggerOutputs,
1868
- batchId
1869
- });
1870
- const next = planner.nextActivation(queue);
1871
- if (!next) {
1872
- const lastNodeId = WorkflowExecutableNodeClassifierFactory.create(args.workflow).lastExecutableNodeIdInDefinitionOrder(args.workflow);
1873
- const outputs = data.getOutputItems(lastNodeId, "main");
1874
- const completedState = this.persistedRunStateTerminalBuilder.mergeTerminal({
1875
- state: args.state,
1876
- engineCounters,
1877
- status: "completed",
1878
- queue: [],
1879
- outputsByNode: data.dump(),
1880
- nodeSnapshotsByNodeId: {
1881
- ...args.state.nodeSnapshotsByNodeId ?? {},
1882
- [args.args.nodeId]: completedSnapshot
1883
- }
1884
- });
1885
- await this.workflowExecutionRepository.save(completedState);
1886
- await this.nodeEventPublisher.publish("nodeCompleted", completedSnapshot);
1887
- await this.terminalPersistence.maybeDeleteAfterTerminalState({
1888
- workflow: args.workflow,
1889
- state: completedState,
1890
- finalStatus: "completed",
1891
- finishedAt: completedSnapshot.finishedAt ?? completedSnapshot.updatedAt
1892
- });
1893
- const result$1 = {
1894
- runId: args.state.runId,
1895
- workflowId: args.state.workflowId,
1896
- startedAt: args.state.startedAt,
1897
- status: "completed",
1898
- outputs
1899
- };
1900
- this.waiters.resolveWebhookResponse({
1901
- runId: args.state.runId,
1902
- workflowId: args.state.workflowId,
1903
- startedAt: args.state.startedAt,
1904
- runStatus: "completed",
1905
- response: args.signal.responseItems
1906
- });
1907
- this.waiters.resolveRunCompletion(result$1);
1908
- return result$1;
1909
- }
1910
- if (completedActivations >= maxNodeActivations) {
1911
- const message = `Run exceeded maxNodeActivations (${maxNodeActivations}) after ${completedActivations} completed node activations (next would be ${next.nodeId}).`;
1912
- const failedState = this.persistedRunStateTerminalBuilder.mergeTerminal({
1913
- state: args.state,
1914
- engineCounters,
1915
- status: "failed",
1916
- queue: queue.map((q) => ({ ...q })),
1917
- outputsByNode: data.dump(),
1918
- nodeSnapshotsByNodeId: {
1919
- ...args.state.nodeSnapshotsByNodeId ?? {},
1920
- [args.args.nodeId]: completedSnapshot
1921
- }
1922
- });
1923
- await this.workflowExecutionRepository.save(failedState);
1924
- await this.nodeEventPublisher.publish("nodeCompleted", completedSnapshot);
1925
- await this.terminalPersistence.maybeDeleteAfterTerminalState({
1926
- workflow: args.workflow,
1927
- state: failedState,
1928
- finalStatus: "failed",
1929
- finishedAt: completedSnapshot.finishedAt ?? completedSnapshot.updatedAt
1930
- });
1931
- const result$1 = {
1932
- runId: args.state.runId,
1933
- workflowId: args.state.workflowId,
1934
- startedAt: args.state.startedAt,
1935
- status: "failed",
1936
- error: { message }
1937
- };
1938
- this.waiters.resolveWebhookResponse({
1939
- runId: args.state.runId,
1940
- workflowId: args.state.workflowId,
1941
- startedAt: args.state.startedAt,
1942
- runStatus: "pending",
1943
- response: args.signal.responseItems
1944
- });
1945
- this.waiters.resolveRunCompletion(result$1);
1946
- return result$1;
1947
- }
1948
- const nextDefinition = topology.defsById.get(next.nodeId);
1949
- if (!nextDefinition || nextDefinition.kind !== "node") throw new Error(`Node ${next.nodeId} is not a runnable node`);
1950
- const webhookLimits = this.resolveEngineLimitsFromState(args.state);
1951
- const base = this.runExecutionContextFactory.create({
1952
- runId: args.state.runId,
1953
- workflowId: args.state.workflowId,
1954
- nodeId: nextDefinition.id,
1955
- parent: args.state.parent,
1956
- subworkflowDepth: args.state.executionOptions?.subworkflowDepth ?? 0,
1957
- engineMaxNodeActivations: webhookLimits.engineMaxNodeActivations,
1958
- engineMaxSubworkflowDepth: webhookLimits.engineMaxSubworkflowDepth,
1959
- data,
1960
- nodeState: this.nodeStatePublisherFactory.create(args.state.runId, args.state.workflowId, args.state.parent)
1961
- });
1962
- const request = this.nodeActivationRequestComposer.createFromPlannedActivation({
1963
- next,
1964
- base,
1965
- data,
1966
- runId: args.state.runId,
1967
- workflowId: args.state.workflowId,
1968
- parent: args.state.parent,
1969
- executionOptions: args.state.executionOptions,
1970
- nodeDefinition: nextDefinition
1971
- });
1972
- const { queuedSnapshot, result } = await this.activationEnqueueService.enqueueActivationWithSnapshot({
1973
- runId: args.state.runId,
1974
- workflowId: args.state.workflowId,
1975
- startedAt: args.state.startedAt,
1976
- parent: args.state.parent,
1977
- executionOptions: args.state.executionOptions,
1978
- control: args.state.control,
1979
- workflowSnapshot: args.state.workflowSnapshot,
1980
- mutableState: args.state.mutableState,
1981
- policySnapshot: args.state.policySnapshot,
1982
- pendingQueue: queue,
1983
- request,
1984
- previousNodeSnapshotsByNodeId: {
1985
- ...args.state.nodeSnapshotsByNodeId ?? {},
1986
- [args.args.nodeId]: completedSnapshot
1987
- },
1988
- planner,
1989
- engineCounters,
1990
- connectionInvocations: args.state.connectionInvocations ?? []
1991
- });
1992
- await this.nodeEventPublisher.publish("nodeCompleted", completedSnapshot);
1993
- await this.nodeEventPublisher.publish("nodeQueued", queuedSnapshot);
1994
- this.waiters.resolveWebhookResponse({
1995
- runId: args.state.runId,
1996
- workflowId: args.state.workflowId,
1997
- startedAt: args.state.startedAt,
1998
- runStatus: "pending",
1999
- response: args.signal.responseItems
2000
- });
2001
- return result;
2002
- }
2003
- asWebhookControlSignal(error) {
2004
- const candidate = error;
2005
- if (!candidate || candidate.__webhookControl !== true) return void 0;
2006
- if (candidate.kind !== "respondNow" && candidate.kind !== "respondNowAndContinue") return void 0;
2007
- if (!Array.isArray(candidate.responseItems)) return void 0;
2008
- return candidate;
2009
- }
2010
- resolvePersistedWorkflow(state) {
2011
- return this.workflowSnapshotResolver.resolve({
2012
- workflowId: state.workflowId,
2013
- workflowSnapshot: state.workflowSnapshot
2014
- });
2015
- }
2016
- buildNodeExecutionContextForPending(state, wf, def, nodeId) {
2017
- const data = this.runDataFactory.create(state.outputsByNode);
2018
- const limits = this.resolveEngineLimitsFromState(state);
2019
- const base = this.runExecutionContextFactory.create({
2020
- runId: state.runId,
2021
- workflowId: state.workflowId,
2022
- nodeId,
2023
- parent: state.parent,
2024
- subworkflowDepth: state.executionOptions?.subworkflowDepth ?? 0,
2025
- engineMaxNodeActivations: limits.engineMaxNodeActivations,
2026
- engineMaxSubworkflowDepth: limits.engineMaxSubworkflowDepth,
2027
- data,
2028
- nodeState: this.nodeStatePublisherFactory.create(state.runId, state.workflowId, state.parent)
2029
- });
2030
- const activationId = state.pending.activationId;
2031
- return {
2032
- ...base,
2033
- data,
2034
- nodeId,
2035
- activationId,
2036
- config: def.config,
2037
- binary: base.binary.forNode({
2038
- nodeId,
2039
- activationId
2040
- }),
2041
- getCredential: this.credentialResolverFactory.create(wf.id, nodeId, def.config)
2042
- };
2043
- }
2044
- resolveEngineLimitsFromState(state) {
2045
- const fb = this.executionLimitsPolicy.createRootExecutionOptions();
2046
- return {
2047
- engineMaxNodeActivations: state.executionOptions?.maxNodeActivations ?? fb.maxNodeActivations,
2048
- engineMaxSubworkflowDepth: state.executionOptions?.maxSubworkflowDepth ?? fb.maxSubworkflowDepth
2049
- };
2050
- }
2051
- formatNodeLabel(args) {
2052
- const tokenName = typeof args.definition?.type === "function" ? args.definition.type.name : "Node";
2053
- return args.definition?.name ? `"${args.definition.name}" (${tokenName}:${args.nodeId})` : `${tokenName}:${args.nodeId}`;
2054
- }
2055
- formatOutputCounts(outputs) {
2056
- const entries = Object.entries(outputs ?? {});
2057
- if (entries.length === 0) return "no outputs";
2058
- return entries.map(([port, items]) => `${port}=${items?.length ?? 0}`).join(", ");
2059
- }
2060
- };
2061
-
2062
- //#endregion
2063
- //#region src/planning/CurrentStateFrontierPlanner.ts
2064
- var CurrentStateFrontierPlanner = class CurrentStateFrontierPlanner {
2065
- constructor(topology) {
2066
- this.topology = topology;
2067
- }
2068
- /** Composition-root-friendly factory (avoids `new` at orchestration call sites under ESLint manual-DI rules). */
2069
- static createFromTopology(topology) {
2070
- return new CurrentStateFrontierPlanner(topology);
2071
- }
2072
- plan(args) {
2073
- const stopCondition = args.stopCondition ?? { kind: "workflowCompleted" };
2074
- const baseState = this.cloneCurrentState(args.currentState);
2075
- const normalizedState = this.overlayPinnedOutputs(baseState);
2076
- const resetResult = this.applyReset({
2077
- currentState: normalizedState,
2078
- reset: args.reset
2079
- });
2080
- const requiredNodeIds = this.collectRequiredNodeIds(stopCondition, resetResult.currentState);
2081
- const satisfiedNodeIds = this.collectSatisfiedNodeIds(resetResult.currentState);
2082
- const skippedNodeIds = [...new Set([...[...requiredNodeIds].filter((nodeId) => this.isNodeSatisfied(resetResult.currentState, nodeId)), ...resetResult.preservedPinnedNodeIds.filter((nodeId) => requiredNodeIds.has(nodeId))])];
2083
- const frontierNodeIds = this.collectFrontierNodeIds(requiredNodeIds, resetResult.currentState);
2084
- const rootNodeIds = frontierNodeIds.filter((nodeId) => (this.topology.incomingByNode.get(nodeId) ?? []).length === 0);
2085
- if (rootNodeIds.length > 1) throw new Error(`Ambiguous execution frontier. Multiple root nodes require input: ${rootNodeIds.join(", ")}`);
2086
- if (frontierNodeIds.length === 0) return {
2087
- queue: [],
2088
- currentState: resetResult.currentState,
2089
- stopCondition,
2090
- satisfiedNodeIds,
2091
- skippedNodeIds,
2092
- clearedNodeIds: resetResult.clearedNodeIds,
2093
- preservedPinnedNodeIds: resetResult.preservedPinnedNodeIds
2094
- };
2095
- if (rootNodeIds.length === 1) {
2096
- const rootNodeId = rootNodeIds[0];
2097
- const definition = this.topology.defsById.get(rootNodeId);
2098
- if (!definition) throw new Error(`Unknown frontier nodeId: ${rootNodeId}`);
2099
- return {
2100
- rootNodeId,
2101
- rootNodeInput: this.resolveRootNodeInput({
2102
- nodeKind: definition.kind,
2103
- items: args.items
2104
- }),
2105
- queue: [],
2106
- currentState: resetResult.currentState,
2107
- stopCondition,
2108
- satisfiedNodeIds,
2109
- skippedNodeIds,
2110
- clearedNodeIds: resetResult.clearedNodeIds,
2111
- preservedPinnedNodeIds: resetResult.preservedPinnedNodeIds
2112
- };
2113
- }
2114
- const queue = [];
2115
- for (const nodeId of frontierNodeIds) queue.push(...this.buildFrontierQueue(nodeId, resetResult.currentState));
2116
- return {
2117
- queue,
2118
- currentState: resetResult.currentState,
2119
- stopCondition,
2120
- satisfiedNodeIds,
2121
- skippedNodeIds,
2122
- clearedNodeIds: resetResult.clearedNodeIds,
2123
- preservedPinnedNodeIds: resetResult.preservedPinnedNodeIds
2124
- };
2125
- }
2126
- cloneCurrentState(currentState) {
2127
- if (!currentState) return {
2128
- outputsByNode: {},
2129
- nodeSnapshotsByNodeId: {},
2130
- connectionInvocations: [],
2131
- mutableState: void 0
2132
- };
2133
- return {
2134
- outputsByNode: { ...currentState.outputsByNode },
2135
- nodeSnapshotsByNodeId: { ...currentState.nodeSnapshotsByNodeId },
2136
- connectionInvocations: currentState.connectionInvocations ? [...currentState.connectionInvocations] : void 0,
2137
- mutableState: currentState.mutableState
2138
- };
2139
- }
2140
- overlayPinnedOutputs(currentState) {
2141
- const outputsByNode = { ...currentState.outputsByNode };
2142
- for (const [nodeId, nodeState] of Object.entries(currentState.mutableState?.nodesById ?? {})) {
2143
- const pinnedOutputs = nodeState.pinnedOutputsByPort;
2144
- if (!pinnedOutputs) continue;
2145
- outputsByNode[nodeId] = pinnedOutputs;
2146
- }
2147
- return {
2148
- outputsByNode,
2149
- nodeSnapshotsByNodeId: { ...currentState.nodeSnapshotsByNodeId },
2150
- connectionInvocations: currentState.connectionInvocations,
2151
- mutableState: currentState.mutableState
2152
- };
2153
- }
2154
- applyReset(args) {
2155
- if (!args.reset) return {
2156
- currentState: args.currentState,
2157
- clearedNodeIds: [],
2158
- preservedPinnedNodeIds: []
2159
- };
2160
- const outputsByNode = { ...args.currentState.outputsByNode };
2161
- const nodeSnapshotsByNodeId = { ...args.currentState.nodeSnapshotsByNodeId };
2162
- const clearedNodeIds = [];
2163
- const preservedPinnedNodeIds = [];
2164
- const descendants = this.collectDescendants(args.reset.clearFromNodeId);
2165
- const runtimeDescendants = this.collectRuntimeDescendants(args.currentState, descendants);
2166
- const clearedIdSet = new Set([...descendants, ...runtimeDescendants]);
2167
- for (const nodeId of [...descendants, ...runtimeDescendants]) {
2168
- const pinnedOutputs = this.getPinnedOutputs(args.currentState, nodeId);
2169
- if (pinnedOutputs) {
2170
- outputsByNode[nodeId] = pinnedOutputs;
2171
- delete nodeSnapshotsByNodeId[nodeId];
2172
- preservedPinnedNodeIds.push(nodeId);
2173
- continue;
2174
- }
2175
- delete outputsByNode[nodeId];
2176
- delete nodeSnapshotsByNodeId[nodeId];
2177
- clearedNodeIds.push(nodeId);
2178
- }
2179
- return {
2180
- currentState: {
2181
- outputsByNode,
2182
- nodeSnapshotsByNodeId,
2183
- connectionInvocations: this.filterConnectionInvocations(args.currentState.connectionInvocations, clearedIdSet),
2184
- mutableState: args.currentState.mutableState
2185
- },
2186
- clearedNodeIds,
2187
- preservedPinnedNodeIds
2188
- };
2189
- }
2190
- collectSatisfiedNodeIds(currentState) {
2191
- const satisfiedNodeIds = [];
2192
- for (const nodeId of this.topology.defsById.keys()) if (this.isNodeSatisfied(currentState, nodeId)) satisfiedNodeIds.push(nodeId);
2193
- return satisfiedNodeIds;
2194
- }
2195
- collectFrontierNodeIds(requiredNodeIds, currentState) {
2196
- const frontierNodeIds = [];
2197
- for (const nodeId of this.topology.defsById.keys()) {
2198
- if (!requiredNodeIds.has(nodeId) || this.isNodeSatisfied(currentState, nodeId)) continue;
2199
- if ((this.topology.incomingByNode.get(nodeId) ?? []).every((edge) => this.isEdgeSatisfied(currentState, nodeId, edge.input))) frontierNodeIds.push(nodeId);
2200
- }
2201
- return frontierNodeIds;
2202
- }
2203
- collectRequiredNodeIds(stopCondition, currentState) {
2204
- const requiredNodeIds = /* @__PURE__ */ new Set();
2205
- if (stopCondition.kind === "workflowCompleted") {
2206
- for (const nodeId of this.topology.defsById.keys()) if (!this.isNodeSatisfied(currentState, nodeId)) this.collectRequiredNode(requiredNodeIds, currentState, nodeId);
2207
- return requiredNodeIds;
2208
- }
2209
- if (!this.topology.defsById.has(stopCondition.nodeId)) throw new Error(`Unknown stop nodeId: ${stopCondition.nodeId}`);
2210
- this.collectRequiredNode(requiredNodeIds, currentState, stopCondition.nodeId);
2211
- return requiredNodeIds;
2212
- }
2213
- collectRequiredNode(requiredNodeIds, currentState, nodeId) {
2214
- if (requiredNodeIds.has(nodeId)) return;
2215
- if (this.isNodeSatisfied(currentState, nodeId) && !this.isNodeSatisfiedByOutputsOnly(currentState, nodeId)) return;
2216
- requiredNodeIds.add(nodeId);
2217
- for (const edge of this.topology.incomingByNode.get(nodeId) ?? []) if (!this.isEdgeSatisfied(currentState, nodeId, edge.input) || this.isNodeSatisfiedByOutputsOnly(currentState, edge.from.nodeId)) this.collectRequiredNode(requiredNodeIds, currentState, edge.from.nodeId);
2218
- }
2219
- buildFrontierQueue(nodeId, currentState) {
2220
- const incomingEdges = this.topology.incomingByNode.get(nodeId) ?? [];
2221
- if (incomingEdges.length === 0) return [];
2222
- const expectedInputs = this.topology.expectedInputsByNode.get(nodeId) ?? [];
2223
- if (expectedInputs.length !== 1 || expectedInputs[0] !== "in") {
2224
- const received = {};
2225
- for (const input$1 of expectedInputs) received[input$1] = this.resolveInput(currentState, nodeId, input$1);
2226
- return [{
2227
- nodeId,
2228
- input: [],
2229
- batchId: "batch_1",
2230
- collect: {
2231
- expectedInputs,
2232
- received
2233
- }
2234
- }];
2235
- }
2236
- const input = expectedInputs[0] ?? "in";
2237
- const incomingEdge = incomingEdges.find((edge) => edge.input === input);
2238
- return [{
2239
- nodeId,
2240
- input: this.resolveInput(currentState, nodeId, input),
2241
- toInput: input,
2242
- batchId: "batch_1",
2243
- from: incomingEdge?.from
2244
- }];
2245
- }
2246
- resolveRootNodeInput(args) {
2247
- if (args.items) return args.items;
2248
- if (args.nodeKind === "trigger") return [];
2249
- return [{ json: {} }];
2250
- }
2251
- isNodeSatisfied(currentState, nodeId) {
2252
- return this.hasOutputs(currentState, nodeId) || this.hasCompletedSnapshot(currentState, nodeId);
2253
- }
2254
- isNodeSatisfiedByOutputsOnly(currentState, nodeId) {
2255
- return this.hasOutputs(currentState, nodeId) && !this.hasCompletedSnapshot(currentState, nodeId);
2256
- }
2257
- isEdgeSatisfied(currentState, nodeId, input) {
2258
- const incomingEdge = (this.topology.incomingByNode.get(nodeId) ?? []).find((edge) => edge.input === input);
2259
- if (!incomingEdge) return false;
2260
- return this.hasOutputPort(currentState, incomingEdge.from.nodeId, incomingEdge.from.output);
2261
- }
2262
- resolveInput(currentState, nodeId, input) {
2263
- const incomingEdge = (this.topology.incomingByNode.get(nodeId) ?? []).find((edge) => edge.input === input);
2264
- if (!incomingEdge) return [];
2265
- return this.resolveOutputItems(currentState, incomingEdge.from.nodeId, incomingEdge.from.output);
2266
- }
2267
- hasOutputs(currentState, nodeId) {
2268
- return Object.prototype.hasOwnProperty.call(currentState.outputsByNode, nodeId);
2269
- }
2270
- hasCompletedSnapshot(currentState, nodeId) {
2271
- const snapshot = currentState.nodeSnapshotsByNodeId[nodeId];
2272
- return snapshot?.status === "completed" || snapshot?.status === "skipped";
2273
- }
2274
- hasOutputPort(currentState, nodeId, output) {
2275
- const outputs = currentState.outputsByNode[nodeId];
2276
- if (!outputs) return false;
2277
- return Object.prototype.hasOwnProperty.call(outputs, output);
2278
- }
2279
- resolveOutputItems(currentState, nodeId, output) {
2280
- return currentState.outputsByNode[nodeId]?.[output] ?? [];
2281
- }
2282
- getPinnedOutputs(currentState, nodeId) {
2283
- return currentState.mutableState?.nodesById?.[nodeId]?.pinnedOutputsByPort;
2284
- }
2285
- filterConnectionInvocations(invocations, clearedIdSet) {
2286
- if (!invocations || invocations.length === 0) return invocations;
2287
- const kept = invocations.filter((invocation) => !clearedIdSet.has(invocation.parentAgentNodeId) && !clearedIdSet.has(invocation.connectionNodeId));
2288
- return kept.length === invocations.length ? invocations : kept;
2289
- }
2290
- collectDescendants(startNodeId) {
2291
- const pendingNodeIds = [startNodeId];
2292
- const descendants = /* @__PURE__ */ new Set();
2293
- while (pendingNodeIds.length > 0) {
2294
- const nodeId = pendingNodeIds.pop();
2295
- if (!nodeId || descendants.has(nodeId)) continue;
2296
- descendants.add(nodeId);
2297
- for (const edge of this.topology.outgoingByNode.get(nodeId) ?? []) pendingNodeIds.push(edge.to.nodeId);
2298
- }
2299
- return [...descendants];
2300
- }
2301
- collectRuntimeDescendants(currentState, descendantNodeIds) {
2302
- const descendantSet = new Set(descendantNodeIds);
2303
- const runtimeNodeIds = /* @__PURE__ */ new Set();
2304
- for (const nodeId of [
2305
- ...Object.keys(currentState.outputsByNode),
2306
- ...Object.keys(currentState.nodeSnapshotsByNodeId),
2307
- ...Object.keys(currentState.mutableState?.nodesById ?? {})
2308
- ]) if (this.isRuntimeDescendant(nodeId, descendantSet)) runtimeNodeIds.add(nodeId);
2309
- return [...runtimeNodeIds];
2310
- }
2311
- isRuntimeDescendant(nodeId, descendantNodeIds) {
2312
- for (const descendantNodeId of descendantNodeIds) {
2313
- if (nodeId === descendantNodeId) return false;
2314
- if (ConnectionNodeIdFactory.isConnectionOwnedDescendantOf(descendantNodeId, nodeId)) return true;
2315
- }
2316
- return false;
2317
- }
2318
- };
2319
-
2320
- //#endregion
2321
- //#region src/policies/storage/RunPolicySnapshotFactory.ts
2322
- var RunPolicySnapshotFactory = class {
2323
- static create(workflow, defaults) {
2324
- const prune = workflow.prunePolicy;
2325
- return {
2326
- retentionSeconds: prune?.runDataRetentionSeconds ?? defaults?.retentionSeconds,
2327
- binaryRetentionSeconds: prune?.binaryRetentionSeconds ?? defaults?.binaryRetentionSeconds,
2328
- storagePolicy: typeof workflow.storagePolicy === "string" ? workflow.storagePolicy : defaults?.storagePolicy ?? "ALL"
2329
- };
2330
- }
2331
- };
2332
-
2333
- //#endregion
2334
- //#region src/orchestration/RunStartService.ts
2335
- var RunStartService = class {
2336
- constructor(runIdFactory, workflowExecutionRepository, runDataFactory, workflowSnapshotFactory, planningFactory, nodeStatePublisherFactory, runExecutionContextFactory, nodeActivationRequestComposer, activationEnqueueService, semantics, waiters, workflowPolicyRuntimeDefaults, executionLimitsPolicy) {
2337
- this.runIdFactory = runIdFactory;
2338
- this.workflowExecutionRepository = workflowExecutionRepository;
2339
- this.runDataFactory = runDataFactory;
2340
- this.workflowSnapshotFactory = workflowSnapshotFactory;
2341
- this.planningFactory = planningFactory;
2342
- this.nodeStatePublisherFactory = nodeStatePublisherFactory;
2343
- this.runExecutionContextFactory = runExecutionContextFactory;
2344
- this.nodeActivationRequestComposer = nodeActivationRequestComposer;
2345
- this.activationEnqueueService = activationEnqueueService;
2346
- this.semantics = semantics;
2347
- this.waiters = waiters;
2348
- this.workflowPolicyRuntimeDefaults = workflowPolicyRuntimeDefaults;
2349
- this.executionLimitsPolicy = executionLimitsPolicy;
2350
- }
2351
- async runWorkflow(workflow, startAt, items, parent, executionOptions, persistedStateOverrides) {
2352
- const runId = this.runIdFactory.makeRunId();
2353
- const startedAt = (/* @__PURE__ */ new Date()).toISOString();
2354
- const workflowSnapshot = persistedStateOverrides?.workflowSnapshot ?? this.workflowSnapshotFactory.create(workflow);
2355
- const mutableState = persistedStateOverrides?.mutableState;
2356
- const policySnapshot = RunPolicySnapshotFactory.create(workflow, this.workflowPolicyRuntimeDefaults);
2357
- const mergedExecutionOptions = this.executionLimitsPolicy.mergeExecutionOptionsForNewRun(parent, executionOptions);
2358
- await this.workflowExecutionRepository.createRun({
2359
- runId,
2360
- workflowId: workflow.id,
2361
- startedAt,
2362
- parent,
2363
- executionOptions: mergedExecutionOptions,
2364
- workflowSnapshot,
2365
- mutableState,
2366
- policySnapshot,
2367
- engineCounters: { completedNodeActivations: 0 }
2368
- });
2369
- const data = this.runDataFactory.create();
2370
- const base = this.runExecutionContextFactory.create({
2371
- runId,
2372
- workflowId: workflow.id,
2373
- nodeId: startAt,
2374
- parent,
2375
- subworkflowDepth: mergedExecutionOptions.subworkflowDepth ?? 0,
2376
- engineMaxNodeActivations: mergedExecutionOptions.maxNodeActivations,
2377
- engineMaxSubworkflowDepth: mergedExecutionOptions.maxSubworkflowDepth,
2378
- data,
2379
- nodeState: this.nodeStatePublisherFactory.create(runId, workflow.id, parent)
2380
- });
2381
- const { topology, planner } = this.planningFactory.create(workflow);
2382
- const startDefinition = topology.defsById.get(startAt);
2383
- if (!startDefinition) throw new Error(`Unknown start nodeId: ${startAt}`);
2384
- const initialNodeSnapshotsByNodeId = {};
2385
- if (startDefinition.kind === "trigger") {
2386
- const request = this.nodeActivationRequestComposer.createSingleFromDefinition({
2387
- runId,
2388
- workflowId: workflow.id,
2389
- definition: startDefinition,
2390
- parent,
2391
- executionOptions: mergedExecutionOptions,
2392
- batchId: "batch_1",
2393
- input: items,
2394
- base,
2395
- data
2396
- });
2397
- return await this.activationEnqueueService.enqueueActivation({
2398
- runId,
2399
- workflowId: workflow.id,
2400
- startedAt,
2401
- parent,
2402
- executionOptions: mergedExecutionOptions,
2403
- workflowSnapshot,
2404
- mutableState,
2405
- policySnapshot,
2406
- control: void 0,
2407
- pendingQueue: [],
2408
- request,
2409
- previousNodeSnapshotsByNodeId: initialNodeSnapshotsByNodeId,
2410
- planner,
2411
- engineCounters: { completedNodeActivations: 0 },
2412
- connectionInvocations: []
2413
- });
2414
- }
2415
- const queue = [{
2416
- nodeId: startAt,
2417
- input: items,
2418
- toInput: "in",
2419
- batchId: "batch_1"
2420
- }];
2421
- return await this.scheduleQueuedPlan({
2422
- runId,
2423
- workflowId: workflow.id,
2424
- startedAt,
2425
- parent,
2426
- executionOptions: mergedExecutionOptions,
2427
- control: void 0,
2428
- workflowSnapshot,
2429
- mutableState,
2430
- policySnapshot,
2431
- workflow,
2432
- planner,
2433
- queue,
2434
- base,
2435
- data,
2436
- nodeSnapshotsByNodeId: initialNodeSnapshotsByNodeId,
2437
- connectionInvocations: []
2438
- });
2439
- }
2440
- async runWorkflowFromState(request) {
2441
- const runId = this.runIdFactory.makeRunId();
2442
- const startedAt = (/* @__PURE__ */ new Date()).toISOString();
2443
- const workflowSnapshot = request.workflowSnapshot ?? this.workflowSnapshotFactory.create(request.workflow);
2444
- const mutableState = request.mutableState ?? request.currentState?.mutableState;
2445
- const policySnapshot = RunPolicySnapshotFactory.create(request.workflow, this.workflowPolicyRuntimeDefaults);
2446
- const control = { stopCondition: request.stopCondition ?? { kind: "workflowCompleted" } };
2447
- const mergedExecutionOptions = this.executionLimitsPolicy.mergeExecutionOptionsForNewRun(request.parent, request.executionOptions);
2448
- await this.workflowExecutionRepository.createRun({
2449
- runId,
2450
- workflowId: request.workflow.id,
2451
- startedAt,
2452
- parent: request.parent,
2453
- executionOptions: mergedExecutionOptions,
2454
- control,
2455
- workflowSnapshot,
2456
- mutableState,
2457
- policySnapshot,
2458
- engineCounters: { completedNodeActivations: 0 }
2459
- });
2460
- const { topology, planner } = this.planningFactory.create(request.workflow);
2461
- const plan = CurrentStateFrontierPlanner.createFromTopology(topology).plan({
2462
- currentState: this.createRunCurrentState(request.currentState, mutableState),
2463
- stopCondition: control.stopCondition,
2464
- reset: request.reset,
2465
- items: request.items
2466
- });
2467
- const data = this.runDataFactory.create(plan.currentState.outputsByNode);
2468
- const base = this.runExecutionContextFactory.create({
2469
- runId,
2470
- workflowId: request.workflow.id,
2471
- nodeId: WorkflowExecutableNodeClassifierFactory.create(request.workflow).firstExecutableNodeIdInDefinitionOrder(request.workflow) ?? "unknown_node",
2472
- parent: request.parent,
2473
- subworkflowDepth: mergedExecutionOptions.subworkflowDepth ?? 0,
2474
- engineMaxNodeActivations: mergedExecutionOptions.maxNodeActivations,
2475
- engineMaxSubworkflowDepth: mergedExecutionOptions.maxSubworkflowDepth,
2476
- data,
2477
- nodeState: this.nodeStatePublisherFactory.create(runId, request.workflow.id, request.parent)
2478
- });
2479
- return await this.scheduleInitialPlan({
2480
- runId,
2481
- startedAt,
2482
- workflow: request.workflow,
2483
- workflowSnapshot,
2484
- mutableState,
2485
- policySnapshot,
2486
- executionOptions: mergedExecutionOptions,
2487
- control,
2488
- parent: request.parent,
2489
- planner,
2490
- plan,
2491
- base,
2492
- data
2493
- });
2494
- }
2495
- createRunCurrentState(currentState, mutableState) {
2496
- return {
2497
- outputsByNode: { ...currentState?.outputsByNode ?? {} },
2498
- nodeSnapshotsByNodeId: { ...currentState?.nodeSnapshotsByNodeId ?? {} },
2499
- connectionInvocations: currentState?.connectionInvocations ? [...currentState.connectionInvocations] : void 0,
2500
- mutableState: mutableState ?? currentState?.mutableState
2501
- };
2502
- }
2503
- async scheduleInitialPlan(args) {
2504
- const initialNodeSnapshotsByNodeId = this.semantics.applySkippedSnapshots({
2505
- runId: args.runId,
2506
- workflowId: args.workflow.id,
2507
- parent: args.parent,
2508
- currentState: args.plan.currentState,
2509
- skippedNodeIds: args.plan.skippedNodeIds,
2510
- preservedPinnedNodeIds: args.plan.preservedPinnedNodeIds,
2511
- finishedAt: args.startedAt
2512
- });
2513
- if (args.plan.rootNodeId) {
2514
- const startDef = WorkflowTopology.fromWorkflow(args.workflow).defsById.get(args.plan.rootNodeId);
2515
- if (!startDef) throw new Error(`Unknown frontier nodeId: ${args.plan.rootNodeId}`);
2516
- const startItems = args.plan.rootNodeInput ?? [];
2517
- const request = this.nodeActivationRequestComposer.createSingleFromDefinition({
2518
- runId: args.runId,
2519
- workflowId: args.workflow.id,
2520
- definition: startDef,
2521
- parent: args.parent,
2522
- executionOptions: args.executionOptions,
2523
- batchId: "batch_1",
2524
- input: startItems,
2525
- base: args.base,
2526
- data: args.data
2527
- });
2528
- return await this.activationEnqueueService.enqueueActivation({
2529
- runId: args.runId,
2530
- workflowId: args.workflow.id,
2531
- startedAt: args.startedAt,
2532
- parent: args.parent,
2533
- executionOptions: args.executionOptions,
2534
- control: args.control,
2535
- workflowSnapshot: args.workflowSnapshot,
2536
- mutableState: args.mutableState,
2537
- policySnapshot: args.policySnapshot,
2538
- pendingQueue: [],
2539
- request,
2540
- previousNodeSnapshotsByNodeId: initialNodeSnapshotsByNodeId,
2541
- planner: args.planner,
2542
- engineCounters: { completedNodeActivations: 0 },
2543
- connectionInvocations: args.plan.currentState.connectionInvocations ?? []
2544
- });
2545
- }
2546
- return await this.scheduleQueuedPlan({
2547
- runId: args.runId,
2548
- workflowId: args.workflow.id,
2549
- startedAt: args.startedAt,
2550
- parent: args.parent,
2551
- executionOptions: args.executionOptions,
2552
- control: args.control,
2553
- workflowSnapshot: args.workflowSnapshot,
2554
- mutableState: args.mutableState,
2555
- policySnapshot: args.policySnapshot,
2556
- workflow: args.workflow,
2557
- planner: args.planner,
2558
- queue: [...args.plan.queue],
2559
- base: args.base,
2560
- data: args.data,
2561
- nodeSnapshotsByNodeId: initialNodeSnapshotsByNodeId,
2562
- connectionInvocations: args.plan.currentState.connectionInvocations ?? []
2563
- });
2564
- }
2565
- async scheduleQueuedPlan(args) {
2566
- this.semantics.applyPinnedQueueSkips({
2567
- runId: args.runId,
2568
- workflowId: args.workflowId,
2569
- parent: args.parent,
2570
- mutableState: args.mutableState,
2571
- planner: args.planner,
2572
- queue: args.queue,
2573
- data: args.data,
2574
- nodeSnapshotsByNodeId: args.nodeSnapshotsByNodeId,
2575
- finishedAt: args.startedAt
2576
- });
2577
- const next = args.planner.nextActivation(args.queue);
2578
- if (!next) return await this.completeRun({
2579
- runId: args.runId,
2580
- workflowId: args.workflowId,
2581
- startedAt: args.startedAt,
2582
- parent: args.parent,
2583
- executionOptions: args.executionOptions,
2584
- control: args.control,
2585
- workflowSnapshot: args.workflowSnapshot,
2586
- mutableState: args.mutableState,
2587
- policySnapshot: args.policySnapshot,
2588
- workflow: args.workflow,
2589
- data: args.data,
2590
- nodeSnapshotsByNodeId: args.nodeSnapshotsByNodeId,
2591
- connectionInvocations: args.connectionInvocations
2592
- });
2593
- const definition = WorkflowTopology.fromWorkflow(args.workflow).defsById.get(next.nodeId);
2594
- if (!definition || definition.kind !== "node") throw new Error(`Node ${next.nodeId} is not a runnable node`);
2595
- const request = this.nodeActivationRequestComposer.createFromPlannedActivation({
2596
- next,
2597
- base: args.base,
2598
- data: args.data,
2599
- runId: args.runId,
2600
- workflowId: args.workflowId,
2601
- parent: args.parent,
2602
- executionOptions: args.executionOptions,
2603
- nodeDefinition: definition
2604
- });
2605
- return await this.activationEnqueueService.enqueueActivation({
2606
- runId: args.runId,
2607
- workflowId: args.workflowId,
2608
- startedAt: args.startedAt,
2609
- parent: args.parent,
2610
- executionOptions: args.executionOptions,
2611
- control: args.control,
2612
- workflowSnapshot: args.workflowSnapshot,
2613
- mutableState: args.mutableState,
2614
- policySnapshot: args.policySnapshot,
2615
- pendingQueue: args.queue,
2616
- request,
2617
- previousNodeSnapshotsByNodeId: args.nodeSnapshotsByNodeId,
2618
- planner: args.planner,
2619
- engineCounters: { completedNodeActivations: 0 },
2620
- connectionInvocations: args.connectionInvocations ?? []
2621
- });
2622
- }
2623
- async completeRun(args) {
2624
- await this.workflowExecutionRepository.save({
2625
- runId: args.runId,
2626
- workflowId: args.workflowId,
2627
- startedAt: args.startedAt,
2628
- parent: args.parent,
2629
- executionOptions: args.executionOptions,
2630
- control: args.control,
2631
- workflowSnapshot: args.workflowSnapshot,
2632
- mutableState: args.mutableState,
2633
- policySnapshot: args.policySnapshot,
2634
- engineCounters: { completedNodeActivations: 0 },
2635
- connectionInvocations: args.connectionInvocations ? [...args.connectionInvocations] : [],
2636
- status: "completed",
2637
- pending: void 0,
2638
- queue: [],
2639
- outputsByNode: args.data.dump(),
2640
- nodeSnapshotsByNodeId: args.nodeSnapshotsByNodeId
2641
- });
2642
- const result = {
2643
- runId: args.runId,
2644
- workflowId: args.workflowId,
2645
- startedAt: args.startedAt,
2646
- status: "completed",
2647
- outputs: this.semantics.resolveResultOutputs(args.workflow, args.control?.stopCondition, args.data.dump())
2648
- };
2649
- this.waiters.resolveRunCompletion(result);
2650
- return result;
2651
- }
2652
- };
2653
-
2654
- //#endregion
2655
- //#region src/scheduler/ConfigDrivenOffloadPolicy.ts
2656
- var ConfigDrivenOffloadPolicy = class {
2657
- defaultMode;
2658
- constructor(defaultMode = "worker") {
2659
- this.defaultMode = defaultMode;
2660
- }
2661
- decide(args) {
2662
- const hint = args.config.execution?.hint;
2663
- const queue = args.config.execution?.queue;
2664
- if (hint === "local") return { mode: "local" };
2665
- if (hint === "worker") return {
2666
- mode: "worker",
2667
- queue
2668
- };
2669
- if (queue) return {
2670
- mode: "worker",
2671
- queue
2672
- };
2673
- return { mode: this.defaultMode };
2674
- }
2675
- };
2676
-
2677
- //#endregion
2678
- //#region src/scheduler/DefaultDrivingScheduler.ts
2679
- var DefaultDrivingScheduler = class {
2680
- constructor(offloadPolicy, workerScheduler, inline) {
2681
- this.offloadPolicy = offloadPolicy;
2682
- this.workerScheduler = workerScheduler;
2683
- this.inline = inline;
2684
- }
2685
- setContinuation(continuation) {
2686
- this.inline.setContinuation(continuation);
2687
- }
2688
- async enqueue(request) {
2689
- const selection = await this.selectScheduler(request);
2690
- if (selection.mode === "worker") {
2691
- if (request.kind === "multi") throw new Error(`Multi-input node ${request.nodeId} cannot be scheduled to worker (insert local placement)`);
2692
- const workerRequest = {
2693
- runId: request.runId,
2694
- activationId: request.activationId,
2695
- workflowId: request.workflowId,
2696
- nodeId: request.nodeId,
2697
- input: request.input,
2698
- parent: request.parent,
2699
- queue: selection.queue,
2700
- executionOptions: request.executionOptions
2701
- };
2702
- return {
2703
- receiptId: (await this.workerScheduler.enqueue(workerRequest)).receiptId,
2704
- mode: "worker",
2705
- queue: selection.queue
2706
- };
2707
- }
2708
- return await this.enqueueInline(request);
2709
- }
2710
- notifyPendingStatePersisted(runId) {
2711
- this.inline.notifyPendingStatePersisted(runId);
2712
- }
2713
- /**
2714
- * Scheduler precedence is explicit:
2715
- * 1. run-intent override (`executionOptions.localOnly`)
2716
- * 2. node-level execution hint / queue policy
2717
- * 3. container-default scheduler policy fallback
2718
- */
2719
- async selectScheduler(request) {
2720
- if (request.executionOptions?.localOnly) return {
2721
- mode: "local",
2722
- decision: "runIntentOverride"
2723
- };
2724
- const decision = this.offloadPolicy.decide({
2725
- workflowId: request.workflowId,
2726
- nodeId: request.nodeId,
2727
- config: request.ctx.config
2728
- });
2729
- if (this.hasNodeSchedulingPreference(request)) return {
2730
- mode: decision.mode,
2731
- queue: decision.queue,
2732
- decision: "nodePolicy"
2733
- };
2734
- return {
2735
- mode: decision.mode,
2736
- queue: decision.queue,
2737
- decision: "containerDefault"
2738
- };
2739
- }
2740
- hasNodeSchedulingPreference(request) {
2741
- return request.ctx.config.execution?.hint !== void 0 || request.ctx.config.execution?.queue !== void 0;
2742
- }
2743
- async enqueueInline(request) {
2744
- return {
2745
- ...await this.inline.enqueue(request),
2746
- mode: "local"
2747
- };
2748
- }
2749
- };
2750
-
2751
- //#endregion
2752
- //#region src/scheduler/HintOnlyOffloadPolicy.ts
2753
- var HintOnlyOffloadPolicy = class {
2754
- decide(args) {
2755
- if (args.config.execution?.hint === "worker") return {
2756
- mode: "worker",
2757
- queue: args.config.execution?.queue
2758
- };
2759
- return { mode: "local" };
2760
- }
2761
- };
2762
-
2763
- //#endregion
2764
- //#region src/scheduler/InlineDrivingScheduler.ts
2765
- var InlineDrivingScheduler = class {
2766
- continuation;
2767
- drainingRuns = /* @__PURE__ */ new Set();
2768
- queuesByRunId = /* @__PURE__ */ new Map();
2769
- scheduledRuns = /* @__PURE__ */ new Set();
2770
- seq = 0;
2771
- constructor(nodeExecutor) {
2772
- this.nodeExecutor = nodeExecutor;
2773
- }
2774
- setContinuation(continuation) {
2775
- this.continuation = continuation;
2776
- }
2777
- async enqueue(request) {
2778
- const receipt = {
2779
- receiptId: `inline_${++this.seq}`,
2780
- mode: "local"
2781
- };
2782
- const q = this.queuesByRunId.get(request.runId) ?? [];
2783
- q.push({
2784
- request,
2785
- receipt
2786
- });
2787
- this.queuesByRunId.set(request.runId, q);
2788
- return receipt;
2789
- }
2790
- notifyPendingStatePersisted(runId) {
2791
- if ((this.queuesByRunId.get(runId)?.length ?? 0) === 0) return;
2792
- this.scheduleDrain(runId);
2793
- }
2794
- async drainRun(runId) {
2795
- if (this.drainingRuns.has(runId)) return;
2796
- this.drainingRuns.add(runId);
2797
- this.scheduledRuns.delete(runId);
2798
- try {
2799
- const q = this.queuesByRunId.get(runId) ?? [];
2800
- while (q.length > 0) {
2801
- const { request } = q.shift();
2802
- const cont = this.continuation;
2803
- if (!cont) throw new Error("InlineDrivingScheduler is missing a continuation (setContinuation was not called)");
2804
- await cont.markNodeRunning({
2805
- runId: request.runId,
2806
- activationId: request.activationId,
2807
- nodeId: request.nodeId,
2808
- inputsByPort: request.kind === "multi" ? request.inputsByPort : { in: request.input }
2809
- });
2810
- let outputs;
2811
- try {
2812
- outputs = await this.nodeExecutor.execute(request);
2813
- } catch (e) {
2814
- await this.resumeAfterExecutionError(cont, request, this.asError(e));
2815
- continue;
2816
- }
2817
- await this.resumeAfterExecutionResult(cont, request, outputs ?? {});
2818
- }
2819
- } finally {
2820
- if ((this.queuesByRunId.get(runId)?.length ?? 0) === 0) this.queuesByRunId.delete(runId);
2821
- this.drainingRuns.delete(runId);
2822
- if ((this.queuesByRunId.get(runId)?.length ?? 0) > 0) this.scheduleDrain(runId);
2823
- }
2824
- }
2825
- scheduleDrain(runId) {
2826
- if (this.drainingRuns.has(runId) || this.scheduledRuns.has(runId)) return;
2827
- this.scheduledRuns.add(runId);
2828
- setTimeout(() => {
2829
- this.scheduledRuns.delete(runId);
2830
- this.drainRun(runId);
2831
- }, 0);
2832
- }
2833
- async resumeAfterExecutionResult(continuation, request, outputs) {
2834
- try {
2835
- await continuation.resumeFromNodeResult({
2836
- runId: request.runId,
2837
- activationId: request.activationId,
2838
- nodeId: request.nodeId,
2839
- outputs
2840
- });
2841
- } catch (e) {
2842
- this.rethrowUnlessIgnorableContinuationError(e);
2843
- }
2844
- }
2845
- async resumeAfterExecutionError(continuation, request, error) {
2846
- try {
2847
- await continuation.resumeFromNodeError({
2848
- runId: request.runId,
2849
- activationId: request.activationId,
2850
- nodeId: request.nodeId,
2851
- error
2852
- });
2853
- } catch (e) {
2854
- this.rethrowUnlessIgnorableContinuationError(e);
2855
- }
2856
- }
2857
- asError(e) {
2858
- return e instanceof Error ? e : new Error(String(e));
2859
- }
2860
- rethrowUnlessIgnorableContinuationError(e) {
2861
- if (this.isIgnorableContinuationError(e)) return;
2862
- throw this.asError(e);
2863
- }
2864
- isIgnorableContinuationError(e) {
2865
- const message = this.asError(e).message;
2866
- return message.includes(" is not pending") || message.includes("activationId mismatch") || message.includes("nodeId mismatch");
2867
- }
2868
- };
2869
-
2870
- //#endregion
2871
- //#region src/scheduler/LocalOnlyScheduler.ts
2872
- var LocalOnlyScheduler = class {
2873
- async enqueue(_request) {
2874
- throw new Error("No worker scheduler configured");
2875
- }
2876
- };
2877
-
2878
- //#endregion
2879
- //#region src/policies/executionLimits/EngineExecutionLimitsPolicy.ts
2880
- /** Framework defaults for {@link EngineExecutionLimitsPolicy} (merged with host `runtime.engineExecutionLimits`). */
2881
- const ENGINE_EXECUTION_LIMITS_DEFAULTS = {
2882
- defaultMaxNodeActivations: 1e5,
2883
- hardMaxNodeActivations: 1e5,
2884
- defaultMaxSubworkflowDepth: 32,
2885
- hardMaxSubworkflowDepth: 32
2886
- };
2887
- /**
2888
- * Resolves per-run execution limits: defaults, hard ceilings, and subworkflow depth for new runs.
2889
- */
2890
- var EngineExecutionLimitsPolicy = class {
2891
- constructor(config = ENGINE_EXECUTION_LIMITS_DEFAULTS) {
2892
- this.config = config;
2893
- }
2894
- /**
2895
- * Effective options for a new root run (depth 0): defaults merged with engine ceilings.
2896
- * Replaces a separate one-method factory for root-run bootstrap.
2897
- */
2898
- createRootExecutionOptions() {
2899
- return this.mergeExecutionOptionsForNewRun(void 0, void 0);
2900
- }
2901
- mergeExecutionOptionsForNewRun(parent, user) {
2902
- const subworkflowDepth = parent === void 0 ? 0 : (parent.subworkflowDepth ?? 0) + 1;
2903
- const inheritedMaxNode = parent?.engineMaxNodeActivations;
2904
- const inheritedMaxSub = parent?.engineMaxSubworkflowDepth;
2905
- const maxNodeActivations = this.capNumber(user?.maxNodeActivations ?? inheritedMaxNode, this.config.defaultMaxNodeActivations, this.config.hardMaxNodeActivations);
2906
- const maxSubworkflowDepth = this.capNumber(user?.maxSubworkflowDepth ?? inheritedMaxSub, this.config.defaultMaxSubworkflowDepth, this.config.hardMaxSubworkflowDepth);
2907
- if (subworkflowDepth > maxSubworkflowDepth) throw new Error(`Subworkflow nesting depth ${subworkflowDepth} exceeds maxSubworkflowDepth ${maxSubworkflowDepth} (run would be a child of parent run).`);
2908
- return {
2909
- ...user,
2910
- subworkflowDepth,
2911
- maxNodeActivations,
2912
- maxSubworkflowDepth
2913
- };
2914
- }
2915
- capNumber(requested, defaultValue, hardCeiling) {
2916
- const base = requested === void 0 ? defaultValue : requested;
2917
- return Math.min(base, hardCeiling);
2918
- }
2919
- };
2920
-
2921
- //#endregion
2922
- //#region src/runStorage/BinaryBodyBufferReader.ts
2923
- var BinaryBodyBufferReader = class {
2924
- async read(body) {
2925
- if (body instanceof Uint8Array) return body;
2926
- if (body instanceof ArrayBuffer) return new Uint8Array(body);
2927
- if (body instanceof node_stream_web.ReadableStream) return await this.readReadableStream(body);
2928
- return await this.readAsyncIterable(body);
2929
- }
2930
- async readReadableStream(body) {
2931
- const reader = body.getReader();
2932
- const chunks = [];
2933
- let totalSize = 0;
2934
- try {
2935
- while (true) {
2936
- const result = await reader.read();
2937
- if (result.done) break;
2938
- chunks.push(result.value);
2939
- totalSize += result.value.byteLength;
2940
- }
2941
- } finally {
2942
- reader.releaseLock();
2943
- }
2944
- return this.joinChunks(chunks, totalSize);
2945
- }
2946
- async readAsyncIterable(body) {
2947
- const chunks = [];
2948
- let totalSize = 0;
2949
- for await (const chunk of body) {
2950
- chunks.push(chunk);
2951
- totalSize += chunk.byteLength;
2952
- }
2953
- return this.joinChunks(chunks, totalSize);
2954
- }
2955
- joinChunks(chunks, totalSize) {
2956
- const bytes = new Uint8Array(totalSize);
2957
- let offset = 0;
2958
- for (const chunk of chunks) {
2959
- bytes.set(chunk, offset);
2960
- offset += chunk.byteLength;
2961
- }
2962
- return bytes;
2963
- }
2964
- };
2965
-
2966
- //#endregion
2967
- //#region src/runStorage/BinaryBodyReadableStreamFactory.ts
2968
- var BinaryBodyReadableStreamFactory = class {
2969
- constructor(bytes) {
2970
- this.bytes = bytes;
2971
- }
2972
- create() {
2973
- const value = this.bytes;
2974
- let consumed = false;
2975
- return new node_stream_web.ReadableStream({ pull(controller) {
2976
- if (consumed) {
2977
- controller.close();
2978
- return;
2979
- }
2980
- consumed = true;
2981
- controller.enqueue(value);
2982
- controller.close();
2983
- } });
2984
- }
2985
- };
2986
-
2987
- //#endregion
2988
- //#region src/runStorage/InMemoryBinaryStorageRegistry.ts
2989
- var InMemoryBinaryStorage = class {
2990
- driverName = "memory";
2991
- values = /* @__PURE__ */ new Map();
2992
- async write(args) {
2993
- const bytes = await new BinaryBodyBufferReader().read(args.body);
2994
- this.values.set(args.storageKey, bytes);
2995
- return {
2996
- storageKey: args.storageKey,
2997
- size: bytes.byteLength,
2998
- sha256: (0, node_crypto.createHash)("sha256").update(bytes).digest("hex")
2999
- };
3000
- }
3001
- async openReadStream(storageKey) {
3002
- const bytes = this.values.get(storageKey);
3003
- if (!bytes) return;
3004
- return {
3005
- body: new BinaryBodyReadableStreamFactory(bytes).create(),
3006
- size: bytes.byteLength
3007
- };
3008
- }
3009
- async stat(storageKey) {
3010
- const bytes = this.values.get(storageKey);
3011
- if (!bytes) return { exists: false };
3012
- return {
3013
- exists: true,
3014
- size: bytes.byteLength
3015
- };
3016
- }
3017
- async delete(storageKey) {
3018
- this.values.delete(storageKey);
3019
- }
3020
- };
3021
-
3022
- //#endregion
3023
- //#region src/runStorage/InMemoryRunData.ts
3024
- var InMemoryRunData = class {
3025
- byNode = /* @__PURE__ */ new Map();
3026
- constructor(initial) {
3027
- if (initial) for (const [nodeId, outputs] of Object.entries(initial)) this.byNode.set(nodeId, outputs);
3028
- }
3029
- setOutputs(nodeId, outputs) {
3030
- this.byNode.set(nodeId, outputs);
3031
- }
3032
- getOutputs(nodeId) {
3033
- return this.byNode.get(nodeId);
3034
- }
3035
- getOutputItems(nodeId, output = "main") {
3036
- return this.byNode.get(nodeId)?.[output] ?? [];
3037
- }
3038
- getOutputItem(nodeId, itemIndex, output = "main") {
3039
- return this.getOutputItems(nodeId, output)[itemIndex];
3040
- }
3041
- dump() {
3042
- const out = {};
3043
- for (const [nodeId, outputs] of this.byNode.entries()) out[nodeId] = outputs;
3044
- return out;
3045
- }
3046
- };
3047
-
3048
- //#endregion
3049
- //#region src/runStorage/InMemoryRunDataFactory.ts
3050
- var InMemoryRunDataFactory = class {
3051
- create(initial) {
3052
- return new InMemoryRunData(initial);
3053
- }
3054
- };
3055
-
3056
- //#endregion
3057
- //#region src/contracts/runFinishedAtFactory.ts
3058
- /** Derives workflow end time from node snapshots for run listings. */
3059
- var RunFinishedAtFactory = class {
3060
- static resolveIso(state) {
3061
- if (state.status === "running" || state.status === "pending") return;
3062
- let max;
3063
- for (const snap of Object.values(state.nodeSnapshotsByNodeId)) if (snap?.finishedAt && (!max || snap.finishedAt > max)) max = snap.finishedAt;
3064
- return max;
3065
- }
3066
- };
3067
-
3068
- //#endregion
3069
- //#region src/runtime/RunIntentService.ts
3070
- var RunIntentService = class {
3071
- constructor(engine, workflowRepository) {
3072
- this.engine = engine;
3073
- this.workflowRepository = workflowRepository;
3074
- }
3075
- async startWorkflow(args) {
3076
- if (args.startAt && !args.currentState && !args.stopCondition && !args.reset) return await this.engine.runWorkflow(args.workflow, args.startAt, args.items, args.parent, args.executionOptions, {
3077
- workflowSnapshot: args.workflowSnapshot,
3078
- mutableState: args.mutableState
3079
- });
3080
- return await this.engine.runWorkflowFromState({
3081
- workflow: args.workflow,
3082
- items: args.items,
3083
- parent: args.parent,
3084
- executionOptions: args.executionOptions,
3085
- workflowSnapshot: args.workflowSnapshot,
3086
- mutableState: args.mutableState,
3087
- currentState: args.currentState,
3088
- stopCondition: args.stopCondition ?? { kind: "workflowCompleted" },
3089
- reset: args.reset
3090
- });
3091
- }
3092
- async rerunFromNode(args) {
3093
- if (args.items) return await this.engine.runWorkflow(args.workflow, args.nodeId, args.items, args.parent, args.executionOptions, {
3094
- workflowSnapshot: args.workflowSnapshot,
3095
- mutableState: args.mutableState
3096
- });
3097
- return await this.engine.runWorkflowFromState({
3098
- workflow: args.workflow,
3099
- parent: args.parent,
3100
- executionOptions: args.executionOptions,
3101
- workflowSnapshot: args.workflowSnapshot,
3102
- mutableState: args.mutableState,
3103
- currentState: args.currentState,
3104
- stopCondition: { kind: "workflowCompleted" },
3105
- reset: { clearFromNodeId: args.nodeId }
3106
- });
3107
- }
3108
- resolveWebhookTrigger(args) {
3109
- return this.engine.resolveWebhookTrigger(args);
3110
- }
3111
- async runMatchedWebhook(args) {
3112
- const resolution = this.resolveWebhookTrigger(args);
3113
- if (resolution.status === "notFound") throw new Error("Unknown webhook endpoint");
3114
- if (resolution.status === "methodNotAllowed") throw new Error("Method not allowed");
3115
- return await this.runWebhookMatch({
3116
- match: resolution.match,
3117
- requestItem: args.requestItem
3118
- });
3119
- }
3120
- async runWebhookMatch(args) {
3121
- const workflow = this.workflowRepository.get(args.match.workflowId);
3122
- if (!workflow) throw new Error(`Unknown workflowId: ${args.match.workflowId}`);
3123
- const scheduled = await this.engine.runWorkflow(workflow, args.match.nodeId, [args.requestItem], void 0, this.createWebhookExecutionOptions());
3124
- if (scheduled.status === "failed") throw new Error(scheduled.error.message);
3125
- if (scheduled.status === "completed") return {
3126
- runId: scheduled.runId,
3127
- workflowId: scheduled.workflowId,
3128
- startedAt: scheduled.startedAt,
3129
- runStatus: "completed",
3130
- response: scheduled.outputs
3131
- };
3132
- return await Promise.race([this.engine.waitForWebhookResponse(scheduled.runId), this.engine.waitForCompletion(scheduled.runId).then((completed) => {
3133
- if (completed.status === "failed") throw new Error(completed.error.message);
3134
- return {
3135
- runId: completed.runId,
3136
- workflowId: completed.workflowId,
3137
- startedAt: completed.startedAt,
3138
- runStatus: "completed",
3139
- response: completed.outputs
3140
- };
3141
- })]);
3142
- }
3143
- /**
3144
- * Webhook-triggered runs always force inline execution first.
3145
- * This is the highest-precedence scheduler override: it wins over node hints and container defaults.
3146
- */
3147
- createWebhookExecutionOptions() {
3148
- return {
3149
- localOnly: true,
3150
- webhook: true
3151
- };
3152
- }
3153
- };
3154
-
3155
- //#endregion
3156
- Object.defineProperty(exports, 'ActivationEnqueueService', {
3157
- enumerable: true,
3158
- get: function () {
3159
- return ActivationEnqueueService;
3160
- }
3161
- });
3162
- Object.defineProperty(exports, 'ConfigDrivenOffloadPolicy', {
3163
- enumerable: true,
3164
- get: function () {
3165
- return ConfigDrivenOffloadPolicy;
3166
- }
3167
- });
3168
- Object.defineProperty(exports, 'ConnectionNodeIdFactory', {
3169
- enumerable: true,
3170
- get: function () {
3171
- return ConnectionNodeIdFactory;
3172
- }
3173
- });
3174
- Object.defineProperty(exports, 'CoreTokens', {
3175
- enumerable: true,
3176
- get: function () {
3177
- return CoreTokens;
3178
- }
3179
- });
3180
- Object.defineProperty(exports, 'CredentialResolverFactory', {
3181
- enumerable: true,
3182
- get: function () {
3183
- return CredentialResolverFactory;
3184
- }
3185
- });
3186
- Object.defineProperty(exports, 'DefaultAsyncSleeper', {
3187
- enumerable: true,
3188
- get: function () {
3189
- return DefaultAsyncSleeper;
3190
- }
3191
- });
3192
- Object.defineProperty(exports, 'DefaultDrivingScheduler', {
3193
- enumerable: true,
3194
- get: function () {
3195
- return DefaultDrivingScheduler;
3196
- }
3197
- });
3198
- Object.defineProperty(exports, 'DefaultExecutionBinaryService', {
3199
- enumerable: true,
3200
- get: function () {
3201
- return DefaultExecutionBinaryService;
3202
- }
3203
- });
3204
- Object.defineProperty(exports, 'DefaultExecutionContextFactory', {
3205
- enumerable: true,
3206
- get: function () {
3207
- return DefaultExecutionContextFactory;
3208
- }
3209
- });
3210
- Object.defineProperty(exports, 'ENGINE_EXECUTION_LIMITS_DEFAULTS', {
3211
- enumerable: true,
3212
- get: function () {
3213
- return ENGINE_EXECUTION_LIMITS_DEFAULTS;
3214
- }
3215
- });
3216
- Object.defineProperty(exports, 'EngineExecutionLimitsPolicy', {
3217
- enumerable: true,
3218
- get: function () {
3219
- return EngineExecutionLimitsPolicy;
3220
- }
3221
- });
3222
- Object.defineProperty(exports, 'HintOnlyOffloadPolicy', {
3223
- enumerable: true,
3224
- get: function () {
3225
- return HintOnlyOffloadPolicy;
3226
- }
3227
- });
3228
- Object.defineProperty(exports, 'InMemoryBinaryStorage', {
3229
- enumerable: true,
3230
- get: function () {
3231
- return InMemoryBinaryStorage;
3232
- }
3233
- });
3234
- Object.defineProperty(exports, 'InMemoryRunDataFactory', {
3235
- enumerable: true,
3236
- get: function () {
3237
- return InMemoryRunDataFactory;
3238
- }
3239
- });
3240
- Object.defineProperty(exports, 'InProcessRetryRunner', {
3241
- enumerable: true,
3242
- get: function () {
3243
- return InProcessRetryRunner;
3244
- }
3245
- });
3246
- Object.defineProperty(exports, 'InProcessRetryRunnerFactory', {
3247
- enumerable: true,
3248
- get: function () {
3249
- return InProcessRetryRunnerFactory;
3250
- }
3251
- });
3252
- Object.defineProperty(exports, 'InjectableRuntimeDecoratorComposer', {
3253
- enumerable: true,
3254
- get: function () {
3255
- return InjectableRuntimeDecoratorComposer;
3256
- }
3257
- });
3258
- Object.defineProperty(exports, 'InlineDrivingScheduler', {
3259
- enumerable: true,
3260
- get: function () {
3261
- return InlineDrivingScheduler;
3262
- }
3263
- });
3264
- Object.defineProperty(exports, 'LocalOnlyScheduler', {
3265
- enumerable: true,
3266
- get: function () {
3267
- return LocalOnlyScheduler;
3268
- }
3269
- });
3270
- Object.defineProperty(exports, 'MissingRuntimeExecutionMarker', {
3271
- enumerable: true,
3272
- get: function () {
3273
- return MissingRuntimeExecutionMarker;
3274
- }
3275
- });
3276
- Object.defineProperty(exports, 'MissingRuntimeFallbacks', {
3277
- enumerable: true,
3278
- get: function () {
3279
- return MissingRuntimeFallbacks;
3280
- }
3281
- });
3282
- Object.defineProperty(exports, 'MissingRuntimeTriggerToken', {
3283
- enumerable: true,
3284
- get: function () {
3285
- return MissingRuntimeTriggerToken;
3286
- }
3287
- });
3288
- Object.defineProperty(exports, 'NodeActivationRequestComposer', {
3289
- enumerable: true,
3290
- get: function () {
3291
- return NodeActivationRequestComposer;
3292
- }
3293
- });
3294
- Object.defineProperty(exports, 'NodeEventPublisher', {
3295
- enumerable: true,
3296
- get: function () {
3297
- return NodeEventPublisher;
3298
- }
3299
- });
3300
- Object.defineProperty(exports, 'NodeExecutor', {
3301
- enumerable: true,
3302
- get: function () {
3303
- return NodeExecutor;
3304
- }
3305
- });
3306
- Object.defineProperty(exports, 'NodeExecutorFactory', {
3307
- enumerable: true,
3308
- get: function () {
3309
- return NodeExecutorFactory;
3310
- }
3311
- });
3312
- Object.defineProperty(exports, 'NodeInstanceFactory', {
3313
- enumerable: true,
3314
- get: function () {
3315
- return NodeInstanceFactory;
3316
- }
3317
- });
3318
- Object.defineProperty(exports, 'NodeInstanceFactoryFactory', {
3319
- enumerable: true,
3320
- get: function () {
3321
- return NodeInstanceFactoryFactory;
3322
- }
3323
- });
3324
- Object.defineProperty(exports, 'NodeRunStateWriterFactory', {
3325
- enumerable: true,
3326
- get: function () {
3327
- return NodeRunStateWriterFactory;
3328
- }
3329
- });
3330
- Object.defineProperty(exports, 'PersistedRunStateTerminalBuilder', {
3331
- enumerable: true,
3332
- get: function () {
3333
- return PersistedRunStateTerminalBuilder;
3334
- }
3335
- });
3336
- Object.defineProperty(exports, 'PersistedRuntimeTypeMetadataStore', {
3337
- enumerable: true,
3338
- get: function () {
3339
- return PersistedRuntimeTypeMetadataStore;
3340
- }
3341
- });
3342
- Object.defineProperty(exports, 'PersistedRuntimeTypeNameResolver', {
3343
- enumerable: true,
3344
- get: function () {
3345
- return PersistedRuntimeTypeNameResolver;
3346
- }
3347
- });
3348
- Object.defineProperty(exports, 'PersistedWorkflowTokenRegistry', {
3349
- enumerable: true,
3350
- get: function () {
3351
- return PersistedWorkflowTokenRegistry;
3352
- }
3353
- });
3354
- Object.defineProperty(exports, 'RunContinuationService', {
3355
- enumerable: true,
3356
- get: function () {
3357
- return RunContinuationService;
3358
- }
3359
- });
3360
- Object.defineProperty(exports, 'RunFinishedAtFactory', {
3361
- enumerable: true,
3362
- get: function () {
3363
- return RunFinishedAtFactory;
3364
- }
3365
- });
3366
- Object.defineProperty(exports, 'RunIntentService', {
3367
- enumerable: true,
3368
- get: function () {
3369
- return RunIntentService;
3370
- }
3371
- });
3372
- Object.defineProperty(exports, 'RunPolicySnapshotFactory', {
3373
- enumerable: true,
3374
- get: function () {
3375
- return RunPolicySnapshotFactory;
3376
- }
3377
- });
3378
- Object.defineProperty(exports, 'RunStartService', {
3379
- enumerable: true,
3380
- get: function () {
3381
- return RunStartService;
3382
- }
3383
- });
3384
- Object.defineProperty(exports, 'RunStateSemantics', {
3385
- enumerable: true,
3386
- get: function () {
3387
- return RunStateSemantics;
3388
- }
3389
- });
3390
- Object.defineProperty(exports, 'StackTraceCallSitePathResolver', {
3391
- enumerable: true,
3392
- get: function () {
3393
- return StackTraceCallSitePathResolver;
3394
- }
3395
- });
3396
- Object.defineProperty(exports, 'UnavailableBinaryStorage', {
3397
- enumerable: true,
3398
- get: function () {
3399
- return UnavailableBinaryStorage;
3400
- }
3401
- });
3402
- Object.defineProperty(exports, 'WorkflowExecutableNodeClassifier', {
3403
- enumerable: true,
3404
- get: function () {
3405
- return WorkflowExecutableNodeClassifier;
3406
- }
3407
- });
3408
- Object.defineProperty(exports, 'WorkflowExecutableNodeClassifierFactory', {
3409
- enumerable: true,
3410
- get: function () {
3411
- return WorkflowExecutableNodeClassifierFactory;
3412
- }
3413
- });
3414
- Object.defineProperty(exports, 'WorkflowRunExecutionContextFactory', {
3415
- enumerable: true,
3416
- get: function () {
3417
- return WorkflowRunExecutionContextFactory;
3418
- }
3419
- });
3420
- Object.defineProperty(exports, 'WorkflowSnapshotResolver', {
3421
- enumerable: true,
3422
- get: function () {
3423
- return WorkflowSnapshotResolver;
3424
- }
3425
- });
3426
- Object.defineProperty(exports, 'WorkflowTopology', {
3427
- enumerable: true,
3428
- get: function () {
3429
- return WorkflowTopology;
3430
- }
3431
- });
3432
- Object.defineProperty(exports, '__toESM', {
3433
- enumerable: true,
3434
- get: function () {
3435
- return __toESM;
3436
- }
3437
- });
3438
- Object.defineProperty(exports, 'chatModel', {
3439
- enumerable: true,
3440
- get: function () {
3441
- return chatModel;
3442
- }
3443
- });
3444
- Object.defineProperty(exports, 'getPersistedRuntimeTypeMetadata', {
3445
- enumerable: true,
3446
- get: function () {
3447
- return getPersistedRuntimeTypeMetadata;
3448
- }
3449
- });
3450
- Object.defineProperty(exports, 'node', {
3451
- enumerable: true,
3452
- get: function () {
3453
- return node;
3454
- }
3455
- });
3456
- Object.defineProperty(exports, 'tool', {
3457
- enumerable: true,
3458
- get: function () {
3459
- return tool;
3460
- }
3461
- });
3462
- //# sourceMappingURL=RunIntentService-2ivFmNQh.cjs.map