@codemation/core 0.0.5 → 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 (215) hide show
  1. package/dist/{InMemoryLiveWorkflowRepository-DL7LmC9S.d.ts → InMemoryLiveWorkflowRepository-DxoualoC.d.ts} +6 -2
  2. package/dist/{InMemoryLiveWorkflowRepository-D6eiiXxF.d.cts → InMemoryLiveWorkflowRepository-orY1VsWG.d.cts} +6 -2
  3. package/dist/{RunIntentService-NKobsfMQ.d.cts → RunIntentService-ByuUYsAL.d.cts} +8 -3
  4. package/dist/{RunIntentService-BFVbsOcg.js → RunIntentService-CYnn140t.js} +9 -4
  5. package/dist/RunIntentService-CYnn140t.js.map +1 -0
  6. package/dist/{RunIntentService-2ivFmNQh.cjs → RunIntentService-DlQH5eZ2.cjs} +9 -4
  7. package/dist/RunIntentService-DlQH5eZ2.cjs.map +1 -0
  8. package/dist/{WorkflowSnapshotCodec-DTdWkoW_.d.cts → WorkflowSnapshotCodec-DSEzKyt3.d.cts} +2 -2
  9. package/dist/bootstrap/index.cjs +133 -4
  10. package/dist/bootstrap/index.cjs.map +1 -1
  11. package/dist/bootstrap/index.d.cts +4 -3
  12. package/dist/bootstrap/index.d.ts +3 -2
  13. package/dist/bootstrap/index.js +133 -4
  14. package/dist/bootstrap/index.js.map +1 -1
  15. package/dist/{index-9g6Pfe9Z.d.ts → index-CTjfVHJh.d.ts} +8 -3
  16. package/dist/index.cjs +1 -1
  17. package/dist/index.d.cts +3 -3
  18. package/dist/index.d.ts +3 -3
  19. package/dist/index.js +1 -1
  20. package/dist/testing.d.cts +2 -2
  21. package/dist/testing.d.ts +1 -1
  22. package/package.json +6 -1
  23. package/src/bootstrap/runtime/EngineRuntimeRegistrar.ts +10 -2
  24. package/src/contracts/runtimeTypes.ts +5 -0
  25. package/src/execution/NodeActivationRequestComposer.ts +15 -4
  26. package/src/orchestration/Engine.ts +12 -1
  27. package/src/orchestration/NodeExecutionRequestHandlerService.ts +179 -0
  28. package/src/runtime/EngineFactory.ts +13 -0
  29. package/dist/EngineExecutionLimitsPolicy-8MEFIYx1.d.cts +0 -160
  30. package/dist/EngineExecutionLimitsPolicy-BWAXW9D6.d.cts +0 -160
  31. package/dist/EngineExecutionLimitsPolicy-Bp8PS1Ss.d.cts +0 -159
  32. package/dist/EngineExecutionLimitsPolicy-CLxcN-D2.d.ts +0 -159
  33. package/dist/EngineExecutionLimitsPolicy-DZXuix51.d.ts +0 -160
  34. package/dist/EngineExecutionLimitsPolicy-Gfz6ngFd.d.ts +0 -160
  35. package/dist/EngineFactory-CBnntY3J.cjs +0 -3152
  36. package/dist/EngineFactory-CBnntY3J.cjs.map +0 -1
  37. package/dist/EngineFactory-Cwn3R2YA.js +0 -3087
  38. package/dist/EngineFactory-Cwn3R2YA.js.map +0 -1
  39. package/dist/EngineFactory-DWCnNocp.js +0 -3063
  40. package/dist/EngineFactory-DWCnNocp.js.map +0 -1
  41. package/dist/EngineFactory-DhPFou4p.cjs +0 -3188
  42. package/dist/EngineFactory-DhPFou4p.cjs.map +0 -1
  43. package/dist/EngineFactory-l_9xmBtv.cjs +0 -3190
  44. package/dist/EngineFactory-l_9xmBtv.cjs.map +0 -1
  45. package/dist/EngineFactory-w-aOWuqh.js +0 -3089
  46. package/dist/EngineFactory-w-aOWuqh.js.map +0 -1
  47. package/dist/InMemoryLiveWorkflowRepository-1J9MHN_I.js +0 -18
  48. package/dist/InMemoryLiveWorkflowRepository-1J9MHN_I.js.map +0 -1
  49. package/dist/InMemoryLiveWorkflowRepository-CULNqv96.d.ts +0 -1300
  50. package/dist/InMemoryLiveWorkflowRepository-D7l8cjdZ.d.cts +0 -1130
  51. package/dist/InMemoryLiveWorkflowRepository-jnv-OnOP.d.ts +0 -1300
  52. package/dist/InMemoryLiveWorkflowRepository-xny1_Z6i.cjs +0 -24
  53. package/dist/InMemoryLiveWorkflowRepository-xny1_Z6i.cjs.map +0 -1
  54. package/dist/InMemoryLiveWorkflowRepository-xr7b4kvi.d.ts +0 -1338
  55. package/dist/InMemoryWorkflowCatalog-BIdFpwbK.d.ts +0 -1205
  56. package/dist/InMemoryWorkflowCatalog-BW00_3N3.d.cts +0 -12
  57. package/dist/InMemoryWorkflowCatalog-BiYHGoPw.cjs +0 -24
  58. package/dist/InMemoryWorkflowCatalog-BiYHGoPw.cjs.map +0 -1
  59. package/dist/InMemoryWorkflowCatalog-BrG0ApMO.d.cts +0 -1115
  60. package/dist/InMemoryWorkflowCatalog-BzrAr--Y.js +0 -139
  61. package/dist/InMemoryWorkflowCatalog-BzrAr--Y.js.map +0 -1
  62. package/dist/InMemoryWorkflowCatalog-C-EJlJ7y.d.cts +0 -1120
  63. package/dist/InMemoryWorkflowCatalog-C4482bpw.cjs +0 -24
  64. package/dist/InMemoryWorkflowCatalog-C4482bpw.cjs.map +0 -1
  65. package/dist/InMemoryWorkflowCatalog-CZ0kZpOv.d.ts +0 -1289
  66. package/dist/InMemoryWorkflowCatalog-C_ACeLyW.d.cts +0 -1119
  67. package/dist/InMemoryWorkflowCatalog-CiHWIu5E.d.cts +0 -12
  68. package/dist/InMemoryWorkflowCatalog-CkH7gkya.js +0 -18
  69. package/dist/InMemoryWorkflowCatalog-CkH7gkya.js.map +0 -1
  70. package/dist/InMemoryWorkflowCatalog-CnpZVJM9.d.ts +0 -1205
  71. package/dist/InMemoryWorkflowCatalog-Cu68S8YR.js +0 -18
  72. package/dist/InMemoryWorkflowCatalog-Cu68S8YR.js.map +0 -1
  73. package/dist/InMemoryWorkflowCatalog-D2w9nMj2.cjs +0 -151
  74. package/dist/InMemoryWorkflowCatalog-D2w9nMj2.cjs.map +0 -1
  75. package/dist/InMemoryWorkflowCatalog-D5eMxEf7.js +0 -18
  76. package/dist/InMemoryWorkflowCatalog-D5eMxEf7.js.map +0 -1
  77. package/dist/InMemoryWorkflowCatalog-D5nCp2yZ.d.ts +0 -1267
  78. package/dist/InMemoryWorkflowCatalog-DIq0bjqN.d.ts +0 -12
  79. package/dist/InMemoryWorkflowCatalog-DLgaEaw_.d.ts +0 -1288
  80. package/dist/InMemoryWorkflowCatalog-DNBFdK-x.d.cts +0 -1120
  81. package/dist/InMemoryWorkflowCatalog-DQBkCzb7.cjs +0 -24
  82. package/dist/InMemoryWorkflowCatalog-DQBkCzb7.cjs.map +0 -1
  83. package/dist/InMemoryWorkflowCatalog-DS4-eX6i.d.cts +0 -1118
  84. package/dist/InMemoryWorkflowCatalog-DdVfy8MY.d.ts +0 -12
  85. package/dist/InMemoryWorkflowCatalog-DeVZu3g8.d.ts +0 -12
  86. package/dist/InMemoryWorkflowCatalog-GxkQjvt5.d.ts +0 -1200
  87. package/dist/InMemoryWorkflowCatalog-qaVRn1Lc.d.cts +0 -1115
  88. package/dist/InMemoryWorkflowCatalog-z1aIT4TC.d.cts +0 -12
  89. package/dist/InMemoryWorkflowRegistry-BBuOovLL.d.ts +0 -1007
  90. package/dist/InMemoryWorkflowRegistry-BIFnSl3k.d.ts +0 -1201
  91. package/dist/InMemoryWorkflowRegistry-BnGilthz.d.ts +0 -1137
  92. package/dist/InMemoryWorkflowRegistry-CEp5I8No.d.ts +0 -1146
  93. package/dist/InMemoryWorkflowRegistry-CHyMB9jW.d.cts +0 -976
  94. package/dist/InMemoryWorkflowRegistry-CUN7K86m.d.cts +0 -1061
  95. package/dist/InMemoryWorkflowRegistry-CVfHyELh.d.cts +0 -971
  96. package/dist/InMemoryWorkflowRegistry-CXXJrwAr.d.cts +0 -1052
  97. package/dist/InMemoryWorkflowRegistry-DDGfPTJy.d.ts +0 -1013
  98. package/dist/InMemoryWorkflowRegistry-DnYSOoT5.d.ts +0 -1120
  99. package/dist/InMemoryWorkflowRegistry-Dp5GiFF2.d.cts +0 -1035
  100. package/dist/InMemoryWorkflowRegistry-DypDBeOw.d.cts +0 -1116
  101. package/dist/InMemoryWorkflowRegistry-SzwJCAxT.d.ts +0 -1012
  102. package/dist/InMemoryWorkflowRegistry-jupvqyGc.d.cts +0 -977
  103. package/dist/InMemoryWorkflowRegistry-rAdKVWYT.d.ts +0 -1117
  104. package/dist/InProcessRetryRunner-BBNPkXjy.d.cts +0 -292
  105. package/dist/PersistedWorkflowSnapshotFactory-7RkOL3Kg.d.ts +0 -14
  106. package/dist/PersistedWorkflowSnapshotFactory-BmANa46W.cjs +0 -141
  107. package/dist/PersistedWorkflowSnapshotFactory-BmANa46W.cjs.map +0 -1
  108. package/dist/PersistedWorkflowSnapshotFactory-Bwb_etSt.js +0 -118
  109. package/dist/PersistedWorkflowSnapshotFactory-Bwb_etSt.js.map +0 -1
  110. package/dist/PersistedWorkflowSnapshotFactory-CRkKGNV6.js +0 -123
  111. package/dist/PersistedWorkflowSnapshotFactory-CRkKGNV6.js.map +0 -1
  112. package/dist/PersistedWorkflowSnapshotFactory-CZolnGy5.js +0 -101
  113. package/dist/PersistedWorkflowSnapshotFactory-CZolnGy5.js.map +0 -1
  114. package/dist/PersistedWorkflowSnapshotFactory-Ca_oysOv.cjs +0 -131
  115. package/dist/PersistedWorkflowSnapshotFactory-Ca_oysOv.cjs.map +0 -1
  116. package/dist/PersistedWorkflowSnapshotFactory-CqIcShnX.js +0 -103
  117. package/dist/PersistedWorkflowSnapshotFactory-CqIcShnX.js.map +0 -1
  118. package/dist/PersistedWorkflowSnapshotFactory-D-tBk4_G.js +0 -119
  119. package/dist/PersistedWorkflowSnapshotFactory-D-tBk4_G.js.map +0 -1
  120. package/dist/PersistedWorkflowSnapshotFactory-D4cXl2e2.cjs +0 -131
  121. package/dist/PersistedWorkflowSnapshotFactory-D4cXl2e2.cjs.map +0 -1
  122. package/dist/PersistedWorkflowSnapshotFactory-DINoP12r.cjs +0 -131
  123. package/dist/PersistedWorkflowSnapshotFactory-DINoP12r.cjs.map +0 -1
  124. package/dist/PersistedWorkflowSnapshotFactory-DJAwSuHU.js +0 -103
  125. package/dist/PersistedWorkflowSnapshotFactory-DJAwSuHU.js.map +0 -1
  126. package/dist/PersistedWorkflowSnapshotFactory-DSUjVCcf.cjs +0 -131
  127. package/dist/PersistedWorkflowSnapshotFactory-DSUjVCcf.cjs.map +0 -1
  128. package/dist/PersistedWorkflowSnapshotFactory-DdHuhkDb.cjs +0 -107
  129. package/dist/PersistedWorkflowSnapshotFactory-DdHuhkDb.cjs.map +0 -1
  130. package/dist/PersistedWorkflowSnapshotFactory-Dqc6NHis.js +0 -119
  131. package/dist/PersistedWorkflowSnapshotFactory-Dqc6NHis.js.map +0 -1
  132. package/dist/PersistedWorkflowSnapshotFactory-Dxa2dSrw.cjs +0 -130
  133. package/dist/PersistedWorkflowSnapshotFactory-Dxa2dSrw.cjs.map +0 -1
  134. package/dist/PersistedWorkflowSnapshotFactory-Ep79Ah1G.js +0 -123
  135. package/dist/PersistedWorkflowSnapshotFactory-Ep79Ah1G.js.map +0 -1
  136. package/dist/PersistedWorkflowSnapshotFactory-GyLfRuiJ.js +0 -119
  137. package/dist/PersistedWorkflowSnapshotFactory-GyLfRuiJ.js.map +0 -1
  138. package/dist/PersistedWorkflowSnapshotFactory-HTpBsBzn.js +0 -102
  139. package/dist/PersistedWorkflowSnapshotFactory-HTpBsBzn.js.map +0 -1
  140. package/dist/PersistedWorkflowSnapshotFactory-LVmaaf3t.cjs +0 -141
  141. package/dist/PersistedWorkflowSnapshotFactory-LVmaaf3t.cjs.map +0 -1
  142. package/dist/PersistedWorkflowSnapshotFactory-PZCpo2ZS.js +0 -119
  143. package/dist/PersistedWorkflowSnapshotFactory-PZCpo2ZS.js.map +0 -1
  144. package/dist/PersistedWorkflowSnapshotFactory-UjQ1SJev.cjs +0 -109
  145. package/dist/PersistedWorkflowSnapshotFactory-UjQ1SJev.cjs.map +0 -1
  146. package/dist/PersistedWorkflowSnapshotFactory-Y8kCrhcy.cjs +0 -109
  147. package/dist/PersistedWorkflowSnapshotFactory-Y8kCrhcy.cjs.map +0 -1
  148. package/dist/PersistedWorkflowSnapshotFactory-Z_nB-fmB.cjs +0 -108
  149. package/dist/PersistedWorkflowSnapshotFactory-Z_nB-fmB.cjs.map +0 -1
  150. package/dist/RunIntentService-1EE6N8ZL.cjs +0 -963
  151. package/dist/RunIntentService-1EE6N8ZL.cjs.map +0 -1
  152. package/dist/RunIntentService-2ivFmNQh.cjs.map +0 -1
  153. package/dist/RunIntentService-B0sUL5q-.js +0 -761
  154. package/dist/RunIntentService-B0sUL5q-.js.map +0 -1
  155. package/dist/RunIntentService-BFVbsOcg.js.map +0 -1
  156. package/dist/RunIntentService-BsBOwpVN.cjs +0 -1051
  157. package/dist/RunIntentService-BsBOwpVN.cjs.map +0 -1
  158. package/dist/RunIntentService-CSk3ETyn.js +0 -858
  159. package/dist/RunIntentService-CSk3ETyn.js.map +0 -1
  160. package/dist/RunIntentService-Ckn3u3tA.d.cts +0 -326
  161. package/dist/RunIntentService-DEo6GTTo.d.cts +0 -289
  162. package/dist/RunIntentService-DKrGtL0B.js +0 -782
  163. package/dist/RunIntentService-DKrGtL0B.js.map +0 -1
  164. package/dist/RunIntentService-DNOJc1R7.cjs +0 -942
  165. package/dist/RunIntentService-DNOJc1R7.cjs.map +0 -1
  166. package/dist/RunIntentService-Dq3pV53j.d.cts +0 -289
  167. package/dist/WorkflowSnapshotCodec-C3fuuS_R.d.cts +0 -22
  168. package/dist/WorkflowSnapshotCodec-CUudUo6f.js +0 -123
  169. package/dist/WorkflowSnapshotCodec-CUudUo6f.js.map +0 -1
  170. package/dist/WorkflowSnapshotCodec-CuCPQZTc.cjs +0 -129
  171. package/dist/WorkflowSnapshotCodec-CuCPQZTc.cjs.map +0 -1
  172. package/dist/WorkflowSnapshotCodec-DLiXQNvV.d.cts +0 -22
  173. package/dist/WorkflowSnapshotCodec-DNtdrZ7l.d.cts +0 -22
  174. package/dist/credentialTypes-B5h3dI7r.d.cts +0 -1107
  175. package/dist/credentialTypes-B9okPCVo.d.cts +0 -963
  176. package/dist/credentialTypes-BFL70rgZ.d.cts +0 -964
  177. package/dist/credentialTypes-BGkh1O07.d.ts +0 -1010
  178. package/dist/credentialTypes-BNLi4Q7u.d.ts +0 -1030
  179. package/dist/credentialTypes-CeSoZGj3.d.cts +0 -994
  180. package/dist/credentialTypes-CpHc32Ig.d.cts +0 -984
  181. package/dist/credentialTypes-D0m7MQQl.d.cts +0 -1107
  182. package/dist/credentialTypes-D4nL2sUd.d.ts +0 -1000
  183. package/dist/credentialTypes-DBYK2Qbu.d.ts +0 -999
  184. package/dist/credentialTypes-DMJVy0r1.d.ts +0 -1000
  185. package/dist/credentialTypes-DhUAjYQp.d.ts +0 -1020
  186. package/dist/credentialTypes-gGITj5KL.d.cts +0 -964
  187. package/dist/credentialTypes-r3KVBJBE.d.cts +0 -974
  188. package/dist/diTokens-ClO27tjK.cjs +0 -34
  189. package/dist/diTokens-ClO27tjK.cjs.map +0 -1
  190. package/dist/diTokens-CoHBkwG6.js +0 -28
  191. package/dist/diTokens-CoHBkwG6.js.map +0 -1
  192. package/dist/index-6Doxmfnd.d.ts +0 -857
  193. package/dist/index-AZ72Ej-K.d.ts +0 -920
  194. package/dist/index-BEk9V-q-.d.ts +0 -667
  195. package/dist/index-Bjt7_7oS.d.ts +0 -1192
  196. package/dist/index-CFGxsYXy.d.ts +0 -708
  197. package/dist/index-C_u8xFgn.d.ts +0 -690
  198. package/dist/index-CpbfsvOJ.d.ts +0 -1192
  199. package/dist/index-CsReNJN_.d.ts +0 -859
  200. package/dist/index-D5iNnXaW.d.ts +0 -667
  201. package/dist/index-DD_Eft1q.d.ts +0 -708
  202. package/dist/index-DiSYUe0G.d.ts +0 -1192
  203. package/dist/index-gIcH60sp.d.ts +0 -674
  204. package/dist/runtime-BIvd-1JA.cjs +0 -4112
  205. package/dist/runtime-BIvd-1JA.cjs.map +0 -1
  206. package/dist/runtime-D3eWKSQK.cjs +0 -3986
  207. package/dist/runtime-D3eWKSQK.cjs.map +0 -1
  208. package/dist/runtime-Dvp4xAjg.js +0 -3799
  209. package/dist/runtime-Dvp4xAjg.js.map +0 -1
  210. package/dist/runtime-vc76SSAa.js +0 -3685
  211. package/dist/runtime-vc76SSAa.js.map +0 -1
  212. package/dist/runtimeTypes-BK0b8SaG.d.cts +0 -884
  213. package/dist/runtimeTypes-CoYZkYQq.d.cts +0 -851
  214. package/dist/runtimeTypes-D-Pm0Uas.d.cts +0 -849
  215. package/dist/types-Cb5UK7Y6.d.ts +0 -857
@@ -1,963 +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
- function createWorkflowExecutableNodeClassifier(workflow) {
117
- return new WorkflowExecutableNodeClassifier(workflow);
118
- }
119
-
120
- //#endregion
121
- //#region src/di/CoreTokens.ts
122
- const CoreTokens = {
123
- PersistedWorkflowTokenRegistry: Symbol.for("codemation.core.PersistedWorkflowTokenRegistry"),
124
- CredentialSessionService: Symbol.for("codemation.core.CredentialSessionService"),
125
- CredentialTypeRegistry: Symbol.for("codemation.core.CredentialTypeRegistry"),
126
- WorkflowRunnerService: Symbol.for("codemation.core.WorkflowRunnerService"),
127
- LiveWorkflowRepository: Symbol.for("codemation.core.LiveWorkflowRepository"),
128
- WorkflowRepository: Symbol.for("codemation.core.WorkflowRepository"),
129
- NodeResolver: Symbol.for("codemation.core.NodeResolver"),
130
- WorkflowNodeInstanceFactory: Symbol.for("codemation.core.WorkflowNodeInstanceFactory"),
131
- RunIdFactory: Symbol.for("codemation.core.RunIdFactory"),
132
- ActivationIdFactory: Symbol.for("codemation.core.ActivationIdFactory"),
133
- WorkflowExecutionRepository: Symbol.for("codemation.core.WorkflowExecutionRepository"),
134
- TriggerSetupStateRepository: Symbol.for("codemation.core.TriggerSetupStateRepository"),
135
- NodeActivationScheduler: Symbol.for("codemation.core.NodeActivationScheduler"),
136
- RunDataFactory: Symbol.for("codemation.core.RunDataFactory"),
137
- ExecutionContextFactory: Symbol.for("codemation.core.ExecutionContextFactory"),
138
- RunEventBus: Symbol.for("codemation.core.RunEventBus"),
139
- BinaryStorage: Symbol.for("codemation.core.BinaryStorage"),
140
- WebhookBasePath: Symbol.for("codemation.core.WebhookBasePath"),
141
- EngineExecutionLimitsPolicy: Symbol.for("codemation.core.EngineExecutionLimitsPolicy"),
142
- WorkflowActivationPolicy: Symbol.for("codemation.core.WorkflowActivationPolicy")
143
- };
144
-
145
- //#endregion
146
- //#region src/events/NodeEventPublisher.ts
147
- /** Publishes node lifecycle snapshots onto the run {@link RunEventBus}. */
148
- var NodeEventPublisher = class {
149
- constructor(eventBus) {
150
- this.eventBus = eventBus;
151
- }
152
- async publish(kind, snapshot) {
153
- if (!this.eventBus) return;
154
- await this.eventBus.publish({
155
- kind,
156
- runId: snapshot.runId,
157
- workflowId: snapshot.workflowId,
158
- parent: snapshot.parent,
159
- at: snapshot.updatedAt,
160
- snapshot
161
- });
162
- }
163
- };
164
-
165
- //#endregion
166
- //#region src/runtime-types/persistedRuntimeTypeModelRegistry.ts
167
- /** Shared metadata key used to attach persisted runtime-type information to decorated classes. */
168
- const persistedRuntimeTypeMetadataKey = Symbol.for("codemation.core.persistedRuntimeTypeMetadata");
169
- /** Normalizes decorator options so persistence metadata has stable defaults. */
170
- var PersistedRuntimeTypeDecoratorDefaults = class {
171
- static appPackageName = "app";
172
- static apply(options) {
173
- return {
174
- ...options,
175
- packageName: options.packageName ?? this.appPackageName
176
- };
177
- }
178
- };
179
-
180
- //#endregion
181
- //#region src/runtime-types/PersistedRuntimeTypeNameResolver.ts
182
- /** Resolves the persisted type name from either an explicit override or the class name itself. */
183
- var PersistedRuntimeTypeNameResolver = class {
184
- static resolve(target, override) {
185
- const resolved = override ?? target.name;
186
- if (!resolved) throw new Error("Persisted runtime token metadata requires a named class or an explicit decorator name override.");
187
- return resolved;
188
- }
189
- };
190
-
191
- //#endregion
192
- //#region src/runtime-types/StackTraceCallSitePathResolver.ts
193
- var StackTraceCallSitePathResolver = class {
194
- static resolve(decoratorFileUrl) {
195
- const stack = (/* @__PURE__ */ new Error()).stack ?? "";
196
- for (const line of stack.split("\n")) {
197
- const candidate = this.extractPath(line.trim());
198
- if (!candidate) continue;
199
- if (candidate === decoratorFileUrl || candidate.includes("runtimeTypeDecorators")) continue;
200
- return candidate;
201
- }
202
- }
203
- static extractPath(line) {
204
- const fileUrlMatch = line.match(/file:\/\/[^\s)]+/);
205
- if (fileUrlMatch) return fileUrlMatch[0];
206
- const parenMatch = line.match(/\((\/[^)]+)\)/);
207
- if (parenMatch) return parenMatch[1];
208
- return line.match(/at (\/[^\s]+)/)?.[1];
209
- }
210
- };
211
-
212
- //#endregion
213
- //#region src/runtime-types/PersistedRuntimeTypeMetadataStoreRegistry.ts
214
- /**
215
- * Defines and retrieves persisted runtime metadata on decorated classes.
216
- * The metadata is attached as a non-enumerable property so runtime objects stay serializable.
217
- */
218
- var PersistedRuntimeTypeMetadataStore = class {
219
- static define(target, kind, options, decoratorFileUrl) {
220
- const normalizedOptions = PersistedRuntimeTypeDecoratorDefaults.apply(options);
221
- const metadata = {
222
- persistedName: PersistedRuntimeTypeNameResolver.resolve(target, normalizedOptions.name),
223
- kind,
224
- packageName: normalizedOptions.packageName ?? PersistedRuntimeTypeDecoratorDefaults.appPackageName,
225
- sourceHint: normalizedOptions.moduleUrl ?? StackTraceCallSitePathResolver.resolve(decoratorFileUrl)
226
- };
227
- Object.defineProperty(target, persistedRuntimeTypeMetadataKey, {
228
- configurable: false,
229
- enumerable: false,
230
- writable: false,
231
- value: metadata
232
- });
233
- }
234
- static get(target) {
235
- if (!target || typeof target !== "function" && typeof target !== "object") return;
236
- return target[persistedRuntimeTypeMetadataKey];
237
- }
238
- };
239
-
240
- //#endregion
241
- //#region src/runtime-types/InjectableRuntimeDecoratorComposerRegistry.ts
242
- /**
243
- * Applies both tsyringe injectability and persisted runtime metadata in one decorator.
244
- * This keeps runtime-type decorators thin while still recording enough data for snapshot hydration.
245
- */
246
- var InjectableRuntimeDecoratorComposer = class {
247
- static compose(kind, options, decoratorFileUrl) {
248
- return (target) => {
249
- (0, tsyringe.injectable)()(target);
250
- PersistedRuntimeTypeMetadataStore.define(target, kind, options, decoratorFileUrl);
251
- };
252
- }
253
- };
254
-
255
- //#endregion
256
- //#region src/runtime-types/runtimeTypeDecorators.types.ts
257
- /** Reads persisted runtime metadata from a decorated class or object. */
258
- function getPersistedRuntimeTypeMetadata(target) {
259
- return PersistedRuntimeTypeMetadataStore.get(target);
260
- }
261
- /** Marks a class as a persisted node runtime type and an injectable tsyringe service. */
262
- function node(options = {}) {
263
- return InjectableRuntimeDecoratorComposer.compose("node", options, require("url").pathToFileURL(__filename).href);
264
- }
265
- /** Marks a class as a persisted tool runtime type and an injectable tsyringe service. */
266
- function tool(options = {}) {
267
- return InjectableRuntimeDecoratorComposer.compose("tool", options, require("url").pathToFileURL(__filename).href);
268
- }
269
- /** Marks a class as a persisted chat-model runtime type and an injectable tsyringe service. */
270
- function chatModel(options = {}) {
271
- return InjectableRuntimeDecoratorComposer.compose("chatModel", options, require("url").pathToFileURL(__filename).href);
272
- }
273
-
274
- //#endregion
275
- //#region src/binaries/DefaultNodeBinaryAttachmentServiceFactory.ts
276
- var DefaultNodeBinaryAttachmentService = class DefaultNodeBinaryAttachmentService {
277
- constructor(storage, workflowId, runId, nodeId, activationId, now) {
278
- this.storage = storage;
279
- this.workflowId = workflowId;
280
- this.runId = runId;
281
- this.nodeId = nodeId;
282
- this.activationId = activationId;
283
- this.now = now;
284
- }
285
- async attach(args) {
286
- const attachmentId = this.createAttachmentId();
287
- const createdAt = this.now().toISOString();
288
- const storageKey = this.createStorageKey(args, attachmentId);
289
- const stored = await this.storage.write({
290
- storageKey,
291
- body: args.body
292
- });
293
- return {
294
- id: attachmentId,
295
- storageKey: stored.storageKey,
296
- mimeType: args.mimeType,
297
- size: stored.size,
298
- storageDriver: this.storage.driverName,
299
- previewKind: args.previewKind ?? this.resolvePreviewKind(args.mimeType),
300
- createdAt,
301
- runId: this.runId,
302
- workflowId: this.workflowId,
303
- nodeId: this.nodeId,
304
- activationId: this.activationId,
305
- filename: args.filename,
306
- sha256: stored.sha256
307
- };
308
- }
309
- withAttachment(item, name, attachment) {
310
- return {
311
- ...item,
312
- binary: {
313
- ...item.binary ?? {},
314
- [name]: attachment
315
- }
316
- };
317
- }
318
- forNode(args) {
319
- return new DefaultNodeBinaryAttachmentService(this.storage, this.workflowId, this.runId, args.nodeId, args.activationId, this.now);
320
- }
321
- async openReadStream(attachment) {
322
- return await this.storage.openReadStream(attachment.storageKey);
323
- }
324
- createAttachmentId() {
325
- return DefaultNodeBinaryAttachmentService.createAttachmentIdValue(`${this.activationId}-${this.now().getTime()}`);
326
- }
327
- static createAttachmentIdValue(fallbackValue) {
328
- const cryptoObject = globalThis.crypto;
329
- if (cryptoObject && typeof cryptoObject.randomUUID === "function") return cryptoObject.randomUUID();
330
- return fallbackValue;
331
- }
332
- createStorageKey(args, attachmentId) {
333
- const safeName = this.sanitizeSegment(args.name);
334
- const safeFilename = this.sanitizeFilename(args.filename);
335
- const filenameSuffix = safeFilename ? `-${safeFilename}` : "";
336
- return `${this.sanitizeSegment(this.workflowId)}/${this.sanitizeSegment(this.runId)}/${this.sanitizeSegment(this.nodeId)}/${this.sanitizeSegment(this.activationId)}/${attachmentId}-${safeName}${filenameSuffix}`;
337
- }
338
- sanitizeSegment(value) {
339
- const normalized = value.trim();
340
- if (!normalized) return "item";
341
- return normalized.replace(/[^a-zA-Z0-9._-]+/g, "_");
342
- }
343
- sanitizeFilename(value) {
344
- if (!value) return;
345
- const normalized = value.trim().split("/").at(-1)?.split("\\").at(-1) ?? value.trim();
346
- if (!normalized) return;
347
- return normalized.replace(/[^a-zA-Z0-9._-]+/g, "_");
348
- }
349
- resolvePreviewKind(mimeType) {
350
- if (mimeType.startsWith("image/")) return "image";
351
- if (mimeType.startsWith("audio/")) return "audio";
352
- if (mimeType.startsWith("video/")) return "video";
353
- return "download";
354
- }
355
- };
356
-
357
- //#endregion
358
- //#region src/binaries/UnavailableBinaryStorage.ts
359
- var UnavailableBinaryStorage = class {
360
- driverName = "unavailable";
361
- async write() {
362
- throw new Error("Binary storage is not configured for this runtime.");
363
- }
364
- async openReadStream() {}
365
- async stat() {
366
- return { exists: false };
367
- }
368
- async delete() {}
369
- };
370
-
371
- //#endregion
372
- //#region src/binaries/DefaultExecutionBinaryServiceFactory.ts
373
- var DefaultExecutionBinaryService = class {
374
- constructor(storage, workflowId, runId, now) {
375
- this.storage = storage;
376
- this.workflowId = workflowId;
377
- this.runId = runId;
378
- this.now = now;
379
- }
380
- forNode(args) {
381
- return new DefaultNodeBinaryAttachmentService(this.storage, this.workflowId, this.runId, args.nodeId, args.activationId, this.now);
382
- }
383
- async openReadStream(attachment) {
384
- return await this.storage.openReadStream(attachment.storageKey);
385
- }
386
- };
387
-
388
- //#endregion
389
- //#region src/execution/CredentialResolverFactory.ts
390
- var CredentialResolverFactory = class {
391
- constructor(credentialSessions) {
392
- this.credentialSessions = credentialSessions;
393
- }
394
- create(workflowId, nodeId, config) {
395
- const acceptedTypesBySlot = /* @__PURE__ */ new Map();
396
- for (const requirement of config?.getCredentialRequirements?.() ?? []) acceptedTypesBySlot.set(requirement.slotKey, requirement.acceptedTypes);
397
- return async (slotKey) => {
398
- try {
399
- return await this.credentialSessions.getSession({
400
- workflowId,
401
- nodeId,
402
- slotKey
403
- });
404
- } catch (error) {
405
- const acceptedTypes = acceptedTypesBySlot.get(slotKey) ?? [];
406
- const message = error instanceof Error ? error.message : String(error);
407
- const alreadyListsAcceptedTypes = message.includes("Accepted types:") || message.includes("Accepted credential types:") || message.includes("binding points at an unknown type");
408
- const acceptedTypesSuffix = acceptedTypes.length > 0 && !alreadyListsAcceptedTypes ? ` Accepted types: ${acceptedTypes.join(", ")}.` : "";
409
- throw new Error(`Failed to resolve credential for workflow ${workflowId} node ${nodeId} slot "${slotKey}". ${message}${acceptedTypesSuffix}`, { cause: error });
410
- }
411
- };
412
- }
413
- };
414
-
415
- //#endregion
416
- //#region src/execution/DefaultAsyncSleeper.ts
417
- var DefaultAsyncSleeper = class {
418
- sleep(ms) {
419
- return new Promise((resolve) => {
420
- setTimeout(resolve, ms);
421
- });
422
- }
423
- };
424
-
425
- //#endregion
426
- //#region src/execution/DefaultExecutionContextFactory.ts
427
- var DefaultExecutionContextFactory = class {
428
- constructor(binaryStorage = new UnavailableBinaryStorage(), currentDate = () => /* @__PURE__ */ new Date()) {
429
- this.binaryStorage = binaryStorage;
430
- this.currentDate = currentDate;
431
- }
432
- create(args) {
433
- return {
434
- runId: args.runId,
435
- workflowId: args.workflowId,
436
- parent: args.parent,
437
- subworkflowDepth: args.subworkflowDepth,
438
- engineMaxNodeActivations: args.engineMaxNodeActivations,
439
- engineMaxSubworkflowDepth: args.engineMaxSubworkflowDepth,
440
- now: this.currentDate,
441
- data: args.data,
442
- nodeState: args.nodeState,
443
- binary: new DefaultExecutionBinaryService(this.binaryStorage, args.workflowId, args.runId, this.currentDate),
444
- getCredential: args.getCredential
445
- };
446
- }
447
- };
448
-
449
- //#endregion
450
- //#region src/execution/InProcessRetryRunner.ts
451
- var InProcessRetryRunner = class InProcessRetryRunner {
452
- constructor(sleeper) {
453
- this.sleeper = sleeper;
454
- }
455
- async run(policy, work) {
456
- const spec = InProcessRetryRunner.normalizePolicy(policy);
457
- let lastError;
458
- for (let attempt = 1; attempt <= spec.maxAttempts; attempt++) try {
459
- return await work();
460
- } catch (error) {
461
- lastError = error;
462
- if (attempt >= spec.maxAttempts) break;
463
- const delayMs = InProcessRetryRunner.delayAfterFailureMs(spec, attempt);
464
- await this.sleeper.sleep(delayMs);
465
- }
466
- throw lastError instanceof Error ? lastError : new Error(String(lastError));
467
- }
468
- static delayAfterFailureMs(spec, failedAttempt) {
469
- if (spec.kind === "none") return 0;
470
- if (spec.kind === "fixed") return spec.delayMs;
471
- const exponent = failedAttempt - 1;
472
- let ms = spec.initialDelayMs * Math.pow(spec.multiplier, exponent);
473
- if (spec.jitter === true) ms *= 1 + Math.random() * .2;
474
- if (spec.maxDelayMs !== void 0 && ms > spec.maxDelayMs) ms = spec.maxDelayMs;
475
- return Math.max(0, Math.floor(ms));
476
- }
477
- static normalizePolicy(policy) {
478
- if (policy === void 0) return {
479
- kind: "none",
480
- maxAttempts: 1
481
- };
482
- if (typeof policy !== "object" || policy === null) return {
483
- kind: "none",
484
- maxAttempts: 1
485
- };
486
- const kind = policy.kind;
487
- if (kind === "none") return {
488
- kind: "none",
489
- maxAttempts: 1
490
- };
491
- if (kind === "fixed") {
492
- const p = policy;
493
- return {
494
- kind: "fixed",
495
- maxAttempts: InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "fixed.maxAttempts"),
496
- delayMs: InProcessRetryRunner.assertNonNegativeFinite(p.delayMs, "fixed.delayMs")
497
- };
498
- }
499
- if (kind === "exponential") {
500
- const p = policy;
501
- return {
502
- kind: "exponential",
503
- maxAttempts: InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "exponential.maxAttempts"),
504
- initialDelayMs: InProcessRetryRunner.assertNonNegativeFinite(p.initialDelayMs, "exponential.initialDelayMs"),
505
- multiplier: InProcessRetryRunner.assertMultiplier(p.multiplier),
506
- maxDelayMs: p.maxDelayMs === void 0 ? void 0 : InProcessRetryRunner.assertNonNegativeFinite(p.maxDelayMs, "exponential.maxDelayMs"),
507
- jitter: p.jitter === true
508
- };
509
- }
510
- return {
511
- kind: "none",
512
- maxAttempts: 1
513
- };
514
- }
515
- static assertPositiveInt(value, label) {
516
- if (typeof value !== "number" || !Number.isFinite(value) || value < 1 || !Number.isInteger(value)) throw new Error(`Retry policy ${label} must be a positive integer`);
517
- return value;
518
- }
519
- static assertNonNegativeFinite(value, label) {
520
- if (typeof value !== "number" || !Number.isFinite(value) || value < 0) throw new Error(`Retry policy ${label} must be a non-negative finite number`);
521
- return value;
522
- }
523
- static assertMultiplier(value) {
524
- if (typeof value !== "number" || !Number.isFinite(value) || value < 1) throw new Error(`Retry policy exponential.multiplier must be >= 1`);
525
- return value;
526
- }
527
- };
528
-
529
- //#endregion
530
- //#region src/policies/executionLimits/EngineExecutionLimitsPolicy.ts
531
- /** Framework defaults for {@link EngineExecutionLimitsPolicy} (merged with host `runtime.engineExecutionLimits`). */
532
- const ENGINE_EXECUTION_LIMITS_DEFAULTS = {
533
- defaultMaxNodeActivations: 1e5,
534
- hardMaxNodeActivations: 1e5,
535
- defaultMaxSubworkflowDepth: 32,
536
- hardMaxSubworkflowDepth: 32
537
- };
538
- /**
539
- * Resolves per-run execution limits: defaults, hard ceilings, and subworkflow depth for new runs.
540
- */
541
- var EngineExecutionLimitsPolicy = class {
542
- constructor(config = ENGINE_EXECUTION_LIMITS_DEFAULTS) {
543
- this.config = config;
544
- }
545
- /**
546
- * Effective options for a new root run (depth 0): defaults merged with engine ceilings.
547
- * Replaces a separate one-method factory for root-run bootstrap.
548
- */
549
- createRootExecutionOptions() {
550
- return this.mergeExecutionOptionsForNewRun(void 0, void 0);
551
- }
552
- mergeExecutionOptionsForNewRun(parent, user) {
553
- const subworkflowDepth = parent === void 0 ? 0 : (parent.subworkflowDepth ?? 0) + 1;
554
- const inheritedMaxNode = parent?.engineMaxNodeActivations;
555
- const inheritedMaxSub = parent?.engineMaxSubworkflowDepth;
556
- const maxNodeActivations = this.capNumber(user?.maxNodeActivations ?? inheritedMaxNode, this.config.defaultMaxNodeActivations, this.config.hardMaxNodeActivations);
557
- const maxSubworkflowDepth = this.capNumber(user?.maxSubworkflowDepth ?? inheritedMaxSub, this.config.defaultMaxSubworkflowDepth, this.config.hardMaxSubworkflowDepth);
558
- if (subworkflowDepth > maxSubworkflowDepth) throw new Error(`Subworkflow nesting depth ${subworkflowDepth} exceeds maxSubworkflowDepth ${maxSubworkflowDepth} (run would be a child of parent run).`);
559
- return {
560
- ...user,
561
- subworkflowDepth,
562
- maxNodeActivations,
563
- maxSubworkflowDepth
564
- };
565
- }
566
- capNumber(requested, defaultValue, hardCeiling) {
567
- const base = requested === void 0 ? defaultValue : requested;
568
- return Math.min(base, hardCeiling);
569
- }
570
- };
571
-
572
- //#endregion
573
- //#region src/runStorage/BinaryBodyBufferReader.ts
574
- var BinaryBodyBufferReader = class {
575
- async read(body) {
576
- if (body instanceof Uint8Array) return body;
577
- if (body instanceof ArrayBuffer) return new Uint8Array(body);
578
- if (body instanceof node_stream_web.ReadableStream) return await this.readReadableStream(body);
579
- return await this.readAsyncIterable(body);
580
- }
581
- async readReadableStream(body) {
582
- const reader = body.getReader();
583
- const chunks = [];
584
- let totalSize = 0;
585
- try {
586
- while (true) {
587
- const result = await reader.read();
588
- if (result.done) break;
589
- chunks.push(result.value);
590
- totalSize += result.value.byteLength;
591
- }
592
- } finally {
593
- reader.releaseLock();
594
- }
595
- return this.joinChunks(chunks, totalSize);
596
- }
597
- async readAsyncIterable(body) {
598
- const chunks = [];
599
- let totalSize = 0;
600
- for await (const chunk of body) {
601
- chunks.push(chunk);
602
- totalSize += chunk.byteLength;
603
- }
604
- return this.joinChunks(chunks, totalSize);
605
- }
606
- joinChunks(chunks, totalSize) {
607
- const bytes = new Uint8Array(totalSize);
608
- let offset = 0;
609
- for (const chunk of chunks) {
610
- bytes.set(chunk, offset);
611
- offset += chunk.byteLength;
612
- }
613
- return bytes;
614
- }
615
- };
616
-
617
- //#endregion
618
- //#region src/runStorage/BinaryBodyReadableStreamFactory.ts
619
- var BinaryBodyReadableStreamFactory = class {
620
- constructor(bytes) {
621
- this.bytes = bytes;
622
- }
623
- create() {
624
- const value = this.bytes;
625
- let consumed = false;
626
- return new node_stream_web.ReadableStream({ pull(controller) {
627
- if (consumed) {
628
- controller.close();
629
- return;
630
- }
631
- consumed = true;
632
- controller.enqueue(value);
633
- controller.close();
634
- } });
635
- }
636
- };
637
-
638
- //#endregion
639
- //#region src/runStorage/InMemoryBinaryStorageRegistry.ts
640
- var InMemoryBinaryStorage = class {
641
- driverName = "memory";
642
- values = /* @__PURE__ */ new Map();
643
- async write(args) {
644
- const bytes = await new BinaryBodyBufferReader().read(args.body);
645
- this.values.set(args.storageKey, bytes);
646
- return {
647
- storageKey: args.storageKey,
648
- size: bytes.byteLength,
649
- sha256: (0, node_crypto.createHash)("sha256").update(bytes).digest("hex")
650
- };
651
- }
652
- async openReadStream(storageKey) {
653
- const bytes = this.values.get(storageKey);
654
- if (!bytes) return;
655
- return {
656
- body: new BinaryBodyReadableStreamFactory(bytes).create(),
657
- size: bytes.byteLength
658
- };
659
- }
660
- async stat(storageKey) {
661
- const bytes = this.values.get(storageKey);
662
- if (!bytes) return { exists: false };
663
- return {
664
- exists: true,
665
- size: bytes.byteLength
666
- };
667
- }
668
- async delete(storageKey) {
669
- this.values.delete(storageKey);
670
- }
671
- };
672
-
673
- //#endregion
674
- //#region src/runStorage/InMemoryRunData.ts
675
- var InMemoryRunData = class {
676
- byNode = /* @__PURE__ */ new Map();
677
- constructor(initial) {
678
- if (initial) for (const [nodeId, outputs] of Object.entries(initial)) this.byNode.set(nodeId, outputs);
679
- }
680
- setOutputs(nodeId, outputs) {
681
- this.byNode.set(nodeId, outputs);
682
- }
683
- getOutputs(nodeId) {
684
- return this.byNode.get(nodeId);
685
- }
686
- getOutputItems(nodeId, output = "main") {
687
- return this.byNode.get(nodeId)?.[output] ?? [];
688
- }
689
- getOutputItem(nodeId, itemIndex, output = "main") {
690
- return this.getOutputItems(nodeId, output)[itemIndex];
691
- }
692
- dump() {
693
- const out = {};
694
- for (const [nodeId, outputs] of this.byNode.entries()) out[nodeId] = outputs;
695
- return out;
696
- }
697
- };
698
-
699
- //#endregion
700
- //#region src/runStorage/InMemoryRunDataFactory.ts
701
- var InMemoryRunDataFactory = class {
702
- create(initial) {
703
- return new InMemoryRunData(initial);
704
- }
705
- };
706
-
707
- //#endregion
708
- //#region src/contracts/runFinishedAtFactory.ts
709
- /** Derives workflow end time from node snapshots for run listings. */
710
- var RunFinishedAtFactory = class {
711
- static resolveIso(state) {
712
- if (state.status === "running" || state.status === "pending") return;
713
- let max;
714
- for (const snap of Object.values(state.nodeSnapshotsByNodeId)) if (snap?.finishedAt && (!max || snap.finishedAt > max)) max = snap.finishedAt;
715
- return max;
716
- }
717
- };
718
-
719
- //#endregion
720
- //#region src/runtime/RunIntentService.ts
721
- var RunIntentService = class {
722
- constructor(engine, workflowRepository) {
723
- this.engine = engine;
724
- this.workflowRepository = workflowRepository;
725
- }
726
- async startWorkflow(args) {
727
- if (args.startAt && !args.currentState && !args.stopCondition && !args.reset) return await this.engine.runWorkflow(args.workflow, args.startAt, args.items, args.parent, args.executionOptions, {
728
- workflowSnapshot: args.workflowSnapshot,
729
- mutableState: args.mutableState
730
- });
731
- return await this.engine.runWorkflowFromState({
732
- workflow: args.workflow,
733
- items: args.items,
734
- parent: args.parent,
735
- executionOptions: args.executionOptions,
736
- workflowSnapshot: args.workflowSnapshot,
737
- mutableState: args.mutableState,
738
- currentState: args.currentState,
739
- stopCondition: args.stopCondition ?? { kind: "workflowCompleted" },
740
- reset: args.reset
741
- });
742
- }
743
- async rerunFromNode(args) {
744
- if (args.items) return await this.engine.runWorkflow(args.workflow, args.nodeId, args.items, args.parent, args.executionOptions, {
745
- workflowSnapshot: args.workflowSnapshot,
746
- mutableState: args.mutableState
747
- });
748
- return await this.engine.runWorkflowFromState({
749
- workflow: args.workflow,
750
- parent: args.parent,
751
- executionOptions: args.executionOptions,
752
- workflowSnapshot: args.workflowSnapshot,
753
- mutableState: args.mutableState,
754
- currentState: args.currentState,
755
- stopCondition: { kind: "workflowCompleted" },
756
- reset: { clearFromNodeId: args.nodeId }
757
- });
758
- }
759
- resolveWebhookTrigger(args) {
760
- return this.engine.resolveWebhookTrigger(args);
761
- }
762
- async runMatchedWebhook(args) {
763
- const resolution = this.resolveWebhookTrigger(args);
764
- if (resolution.status === "notFound") throw new Error("Unknown webhook endpoint");
765
- if (resolution.status === "methodNotAllowed") throw new Error("Method not allowed");
766
- return await this.runWebhookMatch({
767
- match: resolution.match,
768
- requestItem: args.requestItem
769
- });
770
- }
771
- async runWebhookMatch(args) {
772
- const workflow = this.workflowRepository.get(args.match.workflowId);
773
- if (!workflow) throw new Error(`Unknown workflowId: ${args.match.workflowId}`);
774
- const scheduled = await this.engine.runWorkflow(workflow, args.match.nodeId, [args.requestItem], void 0, this.createWebhookExecutionOptions());
775
- if (scheduled.status === "failed") throw new Error(scheduled.error.message);
776
- if (scheduled.status === "completed") return {
777
- runId: scheduled.runId,
778
- workflowId: scheduled.workflowId,
779
- startedAt: scheduled.startedAt,
780
- runStatus: "completed",
781
- response: scheduled.outputs
782
- };
783
- return await Promise.race([this.engine.waitForWebhookResponse(scheduled.runId), this.engine.waitForCompletion(scheduled.runId).then((completed) => {
784
- if (completed.status === "failed") throw new Error(completed.error.message);
785
- return {
786
- runId: completed.runId,
787
- workflowId: completed.workflowId,
788
- startedAt: completed.startedAt,
789
- runStatus: "completed",
790
- response: completed.outputs
791
- };
792
- })]);
793
- }
794
- /**
795
- * Webhook-triggered runs always force inline execution first.
796
- * This is the highest-precedence scheduler override: it wins over node hints and container defaults.
797
- */
798
- createWebhookExecutionOptions() {
799
- return {
800
- localOnly: true,
801
- webhook: true
802
- };
803
- }
804
- };
805
-
806
- //#endregion
807
- Object.defineProperty(exports, 'ConnectionNodeIdFactory', {
808
- enumerable: true,
809
- get: function () {
810
- return ConnectionNodeIdFactory;
811
- }
812
- });
813
- Object.defineProperty(exports, 'CoreTokens', {
814
- enumerable: true,
815
- get: function () {
816
- return CoreTokens;
817
- }
818
- });
819
- Object.defineProperty(exports, 'CredentialResolverFactory', {
820
- enumerable: true,
821
- get: function () {
822
- return CredentialResolverFactory;
823
- }
824
- });
825
- Object.defineProperty(exports, 'DefaultAsyncSleeper', {
826
- enumerable: true,
827
- get: function () {
828
- return DefaultAsyncSleeper;
829
- }
830
- });
831
- Object.defineProperty(exports, 'DefaultExecutionBinaryService', {
832
- enumerable: true,
833
- get: function () {
834
- return DefaultExecutionBinaryService;
835
- }
836
- });
837
- Object.defineProperty(exports, 'DefaultExecutionContextFactory', {
838
- enumerable: true,
839
- get: function () {
840
- return DefaultExecutionContextFactory;
841
- }
842
- });
843
- Object.defineProperty(exports, 'ENGINE_EXECUTION_LIMITS_DEFAULTS', {
844
- enumerable: true,
845
- get: function () {
846
- return ENGINE_EXECUTION_LIMITS_DEFAULTS;
847
- }
848
- });
849
- Object.defineProperty(exports, 'EngineExecutionLimitsPolicy', {
850
- enumerable: true,
851
- get: function () {
852
- return EngineExecutionLimitsPolicy;
853
- }
854
- });
855
- Object.defineProperty(exports, 'InMemoryBinaryStorage', {
856
- enumerable: true,
857
- get: function () {
858
- return InMemoryBinaryStorage;
859
- }
860
- });
861
- Object.defineProperty(exports, 'InMemoryRunDataFactory', {
862
- enumerable: true,
863
- get: function () {
864
- return InMemoryRunDataFactory;
865
- }
866
- });
867
- Object.defineProperty(exports, 'InProcessRetryRunner', {
868
- enumerable: true,
869
- get: function () {
870
- return InProcessRetryRunner;
871
- }
872
- });
873
- Object.defineProperty(exports, 'InjectableRuntimeDecoratorComposer', {
874
- enumerable: true,
875
- get: function () {
876
- return InjectableRuntimeDecoratorComposer;
877
- }
878
- });
879
- Object.defineProperty(exports, 'NodeEventPublisher', {
880
- enumerable: true,
881
- get: function () {
882
- return NodeEventPublisher;
883
- }
884
- });
885
- Object.defineProperty(exports, 'PersistedRuntimeTypeMetadataStore', {
886
- enumerable: true,
887
- get: function () {
888
- return PersistedRuntimeTypeMetadataStore;
889
- }
890
- });
891
- Object.defineProperty(exports, 'PersistedRuntimeTypeNameResolver', {
892
- enumerable: true,
893
- get: function () {
894
- return PersistedRuntimeTypeNameResolver;
895
- }
896
- });
897
- Object.defineProperty(exports, 'RunFinishedAtFactory', {
898
- enumerable: true,
899
- get: function () {
900
- return RunFinishedAtFactory;
901
- }
902
- });
903
- Object.defineProperty(exports, 'RunIntentService', {
904
- enumerable: true,
905
- get: function () {
906
- return RunIntentService;
907
- }
908
- });
909
- Object.defineProperty(exports, 'StackTraceCallSitePathResolver', {
910
- enumerable: true,
911
- get: function () {
912
- return StackTraceCallSitePathResolver;
913
- }
914
- });
915
- Object.defineProperty(exports, 'UnavailableBinaryStorage', {
916
- enumerable: true,
917
- get: function () {
918
- return UnavailableBinaryStorage;
919
- }
920
- });
921
- Object.defineProperty(exports, 'WorkflowExecutableNodeClassifier', {
922
- enumerable: true,
923
- get: function () {
924
- return WorkflowExecutableNodeClassifier;
925
- }
926
- });
927
- Object.defineProperty(exports, '__toESM', {
928
- enumerable: true,
929
- get: function () {
930
- return __toESM;
931
- }
932
- });
933
- Object.defineProperty(exports, 'chatModel', {
934
- enumerable: true,
935
- get: function () {
936
- return chatModel;
937
- }
938
- });
939
- Object.defineProperty(exports, 'createWorkflowExecutableNodeClassifier', {
940
- enumerable: true,
941
- get: function () {
942
- return createWorkflowExecutableNodeClassifier;
943
- }
944
- });
945
- Object.defineProperty(exports, 'getPersistedRuntimeTypeMetadata', {
946
- enumerable: true,
947
- get: function () {
948
- return getPersistedRuntimeTypeMetadata;
949
- }
950
- });
951
- Object.defineProperty(exports, 'node', {
952
- enumerable: true,
953
- get: function () {
954
- return node;
955
- }
956
- });
957
- Object.defineProperty(exports, 'tool', {
958
- enumerable: true,
959
- get: function () {
960
- return tool;
961
- }
962
- });
963
- //# sourceMappingURL=RunIntentService-1EE6N8ZL.cjs.map