@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,1051 +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/diTokens/index.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
- WorkflowCatalog: Symbol.for("codemation.core.WorkflowCatalog"),
128
- LiveWorkflowRepository: Symbol.for("codemation.core.WorkflowCatalog"),
129
- WorkflowRepository: Symbol.for("codemation.core.WorkflowRepository"),
130
- ServiceContainer: Symbol.for("codemation.core.ServiceContainer"),
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
- RunStateStore: Symbol.for("codemation.core.RunStateStore"),
136
- WorkflowExecutionRepository: Symbol.for("codemation.core.RunStateStore"),
137
- TriggerSetupStateStore: Symbol.for("codemation.core.TriggerSetupStateStore"),
138
- TriggerSetupStateRepository: Symbol.for("codemation.core.TriggerSetupStateStore"),
139
- NodeActivationScheduler: Symbol.for("codemation.core.NodeActivationScheduler"),
140
- RunDataFactory: Symbol.for("codemation.core.RunDataFactory"),
141
- ExecutionContextFactory: Symbol.for("codemation.core.ExecutionContextFactory"),
142
- RunEventBus: Symbol.for("codemation.core.RunEventBus"),
143
- BinaryStorage: Symbol.for("codemation.core.BinaryStorage"),
144
- WebhookBasePath: Symbol.for("codemation.core.WebhookBasePath"),
145
- EngineExecutionLimitsPolicy: Symbol.for("codemation.core.EngineExecutionLimitsPolicy"),
146
- WorkflowActivationPolicy: Symbol.for("codemation.core.WorkflowActivationPolicy")
147
- };
148
-
149
- //#endregion
150
- //#region src/events/NodeEventPublisher.ts
151
- /** Publishes node lifecycle snapshots onto the run {@link RunEventBus}. */
152
- var NodeEventPublisher = class {
153
- constructor(eventBus) {
154
- this.eventBus = eventBus;
155
- }
156
- async publish(kind, snapshot) {
157
- if (!this.eventBus) return;
158
- await this.eventBus.publish({
159
- kind,
160
- runId: snapshot.runId,
161
- workflowId: snapshot.workflowId,
162
- parent: snapshot.parent,
163
- at: snapshot.updatedAt,
164
- snapshot
165
- });
166
- }
167
- };
168
-
169
- //#endregion
170
- //#region src/runtime-types/persistedRuntimeTypeModelRegistry.ts
171
- /** Shared metadata key used to attach persisted runtime-type information to decorated classes. */
172
- const persistedRuntimeTypeMetadataKey = Symbol.for("codemation.core.persistedRuntimeTypeMetadata");
173
- /** Normalizes decorator options so persistence metadata has stable defaults. */
174
- var PersistedRuntimeTypeDecoratorDefaults = class {
175
- static appPackageName = "app";
176
- static apply(options) {
177
- return {
178
- ...options,
179
- packageName: options.packageName ?? this.appPackageName
180
- };
181
- }
182
- };
183
-
184
- //#endregion
185
- //#region src/runtime-types/PersistedRuntimeTypeNameResolver.ts
186
- /** Resolves the persisted type name from either an explicit override or the class name itself. */
187
- var PersistedRuntimeTypeNameResolver = class {
188
- static resolve(target, override) {
189
- const resolved = override ?? target.name;
190
- if (!resolved) throw new Error("Persisted runtime token metadata requires a named class or an explicit decorator name override.");
191
- return resolved;
192
- }
193
- };
194
-
195
- //#endregion
196
- //#region src/runtime-types/StackTraceCallSitePathResolver.ts
197
- var StackTraceCallSitePathResolver = class {
198
- static resolve(decoratorFileUrl) {
199
- const stack = (/* @__PURE__ */ new Error()).stack ?? "";
200
- for (const line of stack.split("\n")) {
201
- const candidate = this.extractPath(line.trim());
202
- if (!candidate) continue;
203
- if (candidate === decoratorFileUrl || candidate.includes("runtimeTypeDecorators")) continue;
204
- return candidate;
205
- }
206
- }
207
- static extractPath(line) {
208
- const fileUrlMatch = line.match(/file:\/\/[^\s)]+/);
209
- if (fileUrlMatch) return fileUrlMatch[0];
210
- const parenMatch = line.match(/\((\/[^)]+)\)/);
211
- if (parenMatch) return parenMatch[1];
212
- return line.match(/at (\/[^\s]+)/)?.[1];
213
- }
214
- };
215
-
216
- //#endregion
217
- //#region src/runtime-types/PersistedRuntimeTypeMetadataStoreRegistry.ts
218
- /**
219
- * Defines and retrieves persisted runtime metadata on decorated classes.
220
- * The metadata is attached as a non-enumerable property so runtime objects stay serializable.
221
- */
222
- var PersistedRuntimeTypeMetadataStore = class {
223
- static define(target, kind, options, decoratorFileUrl) {
224
- const normalizedOptions = PersistedRuntimeTypeDecoratorDefaults.apply(options);
225
- const metadata = {
226
- persistedName: PersistedRuntimeTypeNameResolver.resolve(target, normalizedOptions.name),
227
- kind,
228
- packageName: normalizedOptions.packageName ?? PersistedRuntimeTypeDecoratorDefaults.appPackageName,
229
- sourceHint: normalizedOptions.moduleUrl ?? StackTraceCallSitePathResolver.resolve(decoratorFileUrl)
230
- };
231
- Object.defineProperty(target, persistedRuntimeTypeMetadataKey, {
232
- configurable: false,
233
- enumerable: false,
234
- writable: false,
235
- value: metadata
236
- });
237
- }
238
- static get(target) {
239
- if (!target || typeof target !== "function" && typeof target !== "object") return;
240
- return target[persistedRuntimeTypeMetadataKey];
241
- }
242
- };
243
-
244
- //#endregion
245
- //#region src/runtime-types/InjectableRuntimeDecoratorComposerRegistry.ts
246
- /**
247
- * Applies both tsyringe injectability and persisted runtime metadata in one decorator.
248
- * This keeps runtime-type decorators thin while still recording enough data for snapshot hydration.
249
- */
250
- var InjectableRuntimeDecoratorComposer = class {
251
- static compose(kind, options, decoratorFileUrl) {
252
- return (target) => {
253
- (0, tsyringe.injectable)()(target);
254
- PersistedRuntimeTypeMetadataStore.define(target, kind, options, decoratorFileUrl);
255
- };
256
- }
257
- };
258
-
259
- //#endregion
260
- //#region src/runtime-types/runtimeTypeDecorators.types.ts
261
- /** Reads persisted runtime metadata from a decorated class or object. */
262
- function getPersistedRuntimeTypeMetadata(target) {
263
- return PersistedRuntimeTypeMetadataStore.get(target);
264
- }
265
- /** Marks a class as a persisted node runtime type and an injectable tsyringe service. */
266
- function node(options = {}) {
267
- return InjectableRuntimeDecoratorComposer.compose("node", options, require("url").pathToFileURL(__filename).href);
268
- }
269
- /** Marks a class as a persisted tool runtime type and an injectable tsyringe service. */
270
- function tool(options = {}) {
271
- return InjectableRuntimeDecoratorComposer.compose("tool", options, require("url").pathToFileURL(__filename).href);
272
- }
273
- /** Marks a class as a persisted chat-model runtime type and an injectable tsyringe service. */
274
- function chatModel(options = {}) {
275
- return InjectableRuntimeDecoratorComposer.compose("chatModel", options, require("url").pathToFileURL(__filename).href);
276
- }
277
-
278
- //#endregion
279
- //#region src/binaries/DefaultNodeBinaryAttachmentServiceFactory.ts
280
- var DefaultNodeBinaryAttachmentService = class DefaultNodeBinaryAttachmentService {
281
- constructor(storage, workflowId, runId, nodeId, activationId, now) {
282
- this.storage = storage;
283
- this.workflowId = workflowId;
284
- this.runId = runId;
285
- this.nodeId = nodeId;
286
- this.activationId = activationId;
287
- this.now = now;
288
- }
289
- async attach(args) {
290
- const attachmentId = this.createAttachmentId();
291
- const createdAt = this.now().toISOString();
292
- const storageKey = this.createStorageKey(args, attachmentId);
293
- const stored = await this.storage.write({
294
- storageKey,
295
- body: args.body
296
- });
297
- return {
298
- id: attachmentId,
299
- storageKey: stored.storageKey,
300
- mimeType: args.mimeType,
301
- size: stored.size,
302
- storageDriver: this.storage.driverName,
303
- previewKind: args.previewKind ?? this.resolvePreviewKind(args.mimeType),
304
- createdAt,
305
- runId: this.runId,
306
- workflowId: this.workflowId,
307
- nodeId: this.nodeId,
308
- activationId: this.activationId,
309
- filename: args.filename,
310
- sha256: stored.sha256
311
- };
312
- }
313
- withAttachment(item, name, attachment) {
314
- return {
315
- ...item,
316
- binary: {
317
- ...item.binary ?? {},
318
- [name]: attachment
319
- }
320
- };
321
- }
322
- forNode(args) {
323
- return new DefaultNodeBinaryAttachmentService(this.storage, this.workflowId, this.runId, args.nodeId, args.activationId, this.now);
324
- }
325
- async openReadStream(attachment) {
326
- return await this.storage.openReadStream(attachment.storageKey);
327
- }
328
- createAttachmentId() {
329
- return DefaultNodeBinaryAttachmentService.createAttachmentIdValue(`${this.activationId}-${this.now().getTime()}`);
330
- }
331
- static createAttachmentIdValue(fallbackValue) {
332
- const cryptoObject = globalThis.crypto;
333
- if (cryptoObject && typeof cryptoObject.randomUUID === "function") return cryptoObject.randomUUID();
334
- return fallbackValue;
335
- }
336
- createStorageKey(args, attachmentId) {
337
- const safeName = this.sanitizeSegment(args.name);
338
- const safeFilename = this.sanitizeFilename(args.filename);
339
- const filenameSuffix = safeFilename ? `-${safeFilename}` : "";
340
- return `${this.sanitizeSegment(this.workflowId)}/${this.sanitizeSegment(this.runId)}/${this.sanitizeSegment(this.nodeId)}/${this.sanitizeSegment(this.activationId)}/${attachmentId}-${safeName}${filenameSuffix}`;
341
- }
342
- sanitizeSegment(value) {
343
- const normalized = value.trim();
344
- if (!normalized) return "item";
345
- return normalized.replace(/[^a-zA-Z0-9._-]+/g, "_");
346
- }
347
- sanitizeFilename(value) {
348
- if (!value) return;
349
- const normalized = value.trim().split("/").at(-1)?.split("\\").at(-1) ?? value.trim();
350
- if (!normalized) return;
351
- return normalized.replace(/[^a-zA-Z0-9._-]+/g, "_");
352
- }
353
- resolvePreviewKind(mimeType) {
354
- if (mimeType.startsWith("image/")) return "image";
355
- if (mimeType.startsWith("audio/")) return "audio";
356
- if (mimeType.startsWith("video/")) return "video";
357
- return "download";
358
- }
359
- };
360
-
361
- //#endregion
362
- //#region src/binaries/UnavailableBinaryStorage.ts
363
- var UnavailableBinaryStorage = class {
364
- driverName = "unavailable";
365
- async write() {
366
- throw new Error("Binary storage is not configured for this runtime.");
367
- }
368
- async openReadStream() {}
369
- async stat() {
370
- return { exists: false };
371
- }
372
- async delete() {}
373
- };
374
-
375
- //#endregion
376
- //#region src/binaries/DefaultExecutionBinaryServiceFactory.ts
377
- var DefaultExecutionBinaryService = class {
378
- constructor(storage, workflowId, runId, now) {
379
- this.storage = storage;
380
- this.workflowId = workflowId;
381
- this.runId = runId;
382
- this.now = now;
383
- }
384
- forNode(args) {
385
- return new DefaultNodeBinaryAttachmentService(this.storage, this.workflowId, this.runId, args.nodeId, args.activationId, this.now);
386
- }
387
- async openReadStream(attachment) {
388
- return await this.storage.openReadStream(attachment.storageKey);
389
- }
390
- };
391
-
392
- //#endregion
393
- //#region src/execution/CredentialResolverFactory.ts
394
- var CredentialResolverFactory = class {
395
- constructor(credentialSessions) {
396
- this.credentialSessions = credentialSessions;
397
- }
398
- create(workflowId, nodeId, config) {
399
- const acceptedTypesBySlot = /* @__PURE__ */ new Map();
400
- for (const requirement of config?.getCredentialRequirements?.() ?? []) acceptedTypesBySlot.set(requirement.slotKey, requirement.acceptedTypes);
401
- return async (slotKey) => {
402
- try {
403
- return await this.credentialSessions.getSession({
404
- workflowId,
405
- nodeId,
406
- slotKey
407
- });
408
- } catch (error) {
409
- const acceptedTypes = acceptedTypesBySlot.get(slotKey) ?? [];
410
- const message = error instanceof Error ? error.message : String(error);
411
- const alreadyListsAcceptedTypes = message.includes("Accepted types:") || message.includes("Accepted credential types:") || message.includes("binding points at an unknown type");
412
- const acceptedTypesSuffix = acceptedTypes.length > 0 && !alreadyListsAcceptedTypes ? ` Accepted types: ${acceptedTypes.join(", ")}.` : "";
413
- throw new Error(`Failed to resolve credential for workflow ${workflowId} node ${nodeId} slot "${slotKey}". ${message}${acceptedTypesSuffix}`, { cause: error });
414
- }
415
- };
416
- }
417
- };
418
-
419
- //#endregion
420
- //#region src/execution/DefaultAsyncSleeper.ts
421
- var DefaultAsyncSleeper = class {
422
- sleep(ms) {
423
- return new Promise((resolve) => {
424
- setTimeout(resolve, ms);
425
- });
426
- }
427
- };
428
-
429
- //#endregion
430
- //#region src/execution/DefaultExecutionContextFactory.ts
431
- var DefaultExecutionContextFactory = class {
432
- constructor(binaryStorage = new UnavailableBinaryStorage(), currentDate = () => /* @__PURE__ */ new Date()) {
433
- this.binaryStorage = binaryStorage;
434
- this.currentDate = currentDate;
435
- }
436
- create(args) {
437
- return {
438
- runId: args.runId,
439
- workflowId: args.workflowId,
440
- parent: args.parent,
441
- subworkflowDepth: args.subworkflowDepth,
442
- engineMaxNodeActivations: args.engineMaxNodeActivations,
443
- engineMaxSubworkflowDepth: args.engineMaxSubworkflowDepth,
444
- now: this.currentDate,
445
- data: args.data,
446
- nodeState: args.nodeState,
447
- binary: new DefaultExecutionBinaryService(this.binaryStorage, args.workflowId, args.runId, this.currentDate),
448
- getCredential: args.getCredential
449
- };
450
- }
451
- };
452
-
453
- //#endregion
454
- //#region src/execution/InProcessRetryRunner.ts
455
- var InProcessRetryRunner = class InProcessRetryRunner {
456
- constructor(sleeper) {
457
- this.sleeper = sleeper;
458
- }
459
- async run(policy, work) {
460
- const spec = InProcessRetryRunner.normalizePolicy(policy);
461
- let lastError;
462
- for (let attempt = 1; attempt <= spec.maxAttempts; attempt++) try {
463
- return await work();
464
- } catch (error) {
465
- lastError = error;
466
- if (attempt >= spec.maxAttempts) break;
467
- const delayMs = InProcessRetryRunner.delayAfterFailureMs(spec, attempt);
468
- await this.sleeper.sleep(delayMs);
469
- }
470
- throw lastError instanceof Error ? lastError : new Error(String(lastError));
471
- }
472
- static delayAfterFailureMs(spec, failedAttempt) {
473
- if (spec.kind === "none") return 0;
474
- if (spec.kind === "fixed") return spec.delayMs;
475
- const exponent = failedAttempt - 1;
476
- let ms = spec.initialDelayMs * Math.pow(spec.multiplier, exponent);
477
- if (spec.jitter === true) ms *= 1 + Math.random() * .2;
478
- if (spec.maxDelayMs !== void 0 && ms > spec.maxDelayMs) ms = spec.maxDelayMs;
479
- return Math.max(0, Math.floor(ms));
480
- }
481
- static normalizePolicy(policy) {
482
- if (policy === void 0) return {
483
- kind: "none",
484
- maxAttempts: 1
485
- };
486
- if (typeof policy !== "object" || policy === null) return {
487
- kind: "none",
488
- maxAttempts: 1
489
- };
490
- const kind = policy.kind;
491
- if (kind === "none") return {
492
- kind: "none",
493
- maxAttempts: 1
494
- };
495
- if (kind === "fixed") {
496
- const p = policy;
497
- return {
498
- kind: "fixed",
499
- maxAttempts: InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "fixed.maxAttempts"),
500
- delayMs: InProcessRetryRunner.assertNonNegativeFinite(p.delayMs, "fixed.delayMs")
501
- };
502
- }
503
- if (kind === "exponential") {
504
- const p = policy;
505
- return {
506
- kind: "exponential",
507
- maxAttempts: InProcessRetryRunner.assertPositiveInt(p.maxAttempts, "exponential.maxAttempts"),
508
- initialDelayMs: InProcessRetryRunner.assertNonNegativeFinite(p.initialDelayMs, "exponential.initialDelayMs"),
509
- multiplier: InProcessRetryRunner.assertMultiplier(p.multiplier),
510
- maxDelayMs: p.maxDelayMs === void 0 ? void 0 : InProcessRetryRunner.assertNonNegativeFinite(p.maxDelayMs, "exponential.maxDelayMs"),
511
- jitter: p.jitter === true
512
- };
513
- }
514
- return {
515
- kind: "none",
516
- maxAttempts: 1
517
- };
518
- }
519
- static assertPositiveInt(value, label) {
520
- if (typeof value !== "number" || !Number.isFinite(value) || value < 1 || !Number.isInteger(value)) throw new Error(`Retry policy ${label} must be a positive integer`);
521
- return value;
522
- }
523
- static assertNonNegativeFinite(value, label) {
524
- if (typeof value !== "number" || !Number.isFinite(value) || value < 0) throw new Error(`Retry policy ${label} must be a non-negative finite number`);
525
- return value;
526
- }
527
- static assertMultiplier(value) {
528
- if (typeof value !== "number" || !Number.isFinite(value) || value < 1) throw new Error(`Retry policy exponential.multiplier must be >= 1`);
529
- return value;
530
- }
531
- };
532
-
533
- //#endregion
534
- //#region src/policies/executionLimits/EngineExecutionLimitsPolicy.ts
535
- /** Framework defaults for {@link EngineExecutionLimitsPolicy} (merged with host `runtime.engineExecutionLimits`). */
536
- const ENGINE_EXECUTION_LIMITS_DEFAULTS = {
537
- defaultMaxNodeActivations: 1e5,
538
- hardMaxNodeActivations: 1e5,
539
- defaultMaxSubworkflowDepth: 32,
540
- hardMaxSubworkflowDepth: 32
541
- };
542
- /**
543
- * Resolves per-run execution limits: defaults, hard ceilings, and subworkflow depth for new runs.
544
- */
545
- var EngineExecutionLimitsPolicy = class {
546
- constructor(config = ENGINE_EXECUTION_LIMITS_DEFAULTS) {
547
- this.config = config;
548
- }
549
- /**
550
- * Effective options for a new root run (depth 0): defaults merged with engine ceilings.
551
- * Replaces a separate one-method factory for root-run bootstrap.
552
- */
553
- createRootExecutionOptions() {
554
- return this.mergeExecutionOptionsForNewRun(void 0, void 0);
555
- }
556
- mergeExecutionOptionsForNewRun(parent, user) {
557
- const subworkflowDepth = parent === void 0 ? 0 : (parent.subworkflowDepth ?? 0) + 1;
558
- const inheritedMaxNode = parent?.engineMaxNodeActivations;
559
- const inheritedMaxSub = parent?.engineMaxSubworkflowDepth;
560
- const maxNodeActivations = this.capNumber(user?.maxNodeActivations ?? inheritedMaxNode, this.config.defaultMaxNodeActivations, this.config.hardMaxNodeActivations);
561
- const maxSubworkflowDepth = this.capNumber(user?.maxSubworkflowDepth ?? inheritedMaxSub, this.config.defaultMaxSubworkflowDepth, this.config.hardMaxSubworkflowDepth);
562
- if (subworkflowDepth > maxSubworkflowDepth) throw new Error(`Subworkflow nesting depth ${subworkflowDepth} exceeds maxSubworkflowDepth ${maxSubworkflowDepth} (run would be a child of parent run).`);
563
- return {
564
- ...user,
565
- subworkflowDepth,
566
- maxNodeActivations,
567
- maxSubworkflowDepth
568
- };
569
- }
570
- capNumber(requested, defaultValue, hardCeiling) {
571
- const base = requested === void 0 ? defaultValue : requested;
572
- return Math.min(base, hardCeiling);
573
- }
574
- };
575
-
576
- //#endregion
577
- //#region src/runStorage/BinaryBodyBufferReader.ts
578
- var BinaryBodyBufferReader = class {
579
- async read(body) {
580
- if (body instanceof Uint8Array) return body;
581
- if (body instanceof ArrayBuffer) return new Uint8Array(body);
582
- if (body instanceof node_stream_web.ReadableStream) return await this.readReadableStream(body);
583
- return await this.readAsyncIterable(body);
584
- }
585
- async readReadableStream(body) {
586
- const reader = body.getReader();
587
- const chunks = [];
588
- let totalSize = 0;
589
- try {
590
- while (true) {
591
- const result = await reader.read();
592
- if (result.done) break;
593
- chunks.push(result.value);
594
- totalSize += result.value.byteLength;
595
- }
596
- } finally {
597
- reader.releaseLock();
598
- }
599
- return this.joinChunks(chunks, totalSize);
600
- }
601
- async readAsyncIterable(body) {
602
- const chunks = [];
603
- let totalSize = 0;
604
- for await (const chunk of body) {
605
- chunks.push(chunk);
606
- totalSize += chunk.byteLength;
607
- }
608
- return this.joinChunks(chunks, totalSize);
609
- }
610
- joinChunks(chunks, totalSize) {
611
- const bytes = new Uint8Array(totalSize);
612
- let offset = 0;
613
- for (const chunk of chunks) {
614
- bytes.set(chunk, offset);
615
- offset += chunk.byteLength;
616
- }
617
- return bytes;
618
- }
619
- };
620
-
621
- //#endregion
622
- //#region src/runStorage/BinaryBodyReadableStreamFactory.ts
623
- var BinaryBodyReadableStreamFactory = class {
624
- constructor(bytes) {
625
- this.bytes = bytes;
626
- }
627
- create() {
628
- const value = this.bytes;
629
- let consumed = false;
630
- return new node_stream_web.ReadableStream({ pull(controller) {
631
- if (consumed) {
632
- controller.close();
633
- return;
634
- }
635
- consumed = true;
636
- controller.enqueue(value);
637
- controller.close();
638
- } });
639
- }
640
- };
641
-
642
- //#endregion
643
- //#region src/runStorage/InMemoryBinaryStorageRegistry.ts
644
- var InMemoryBinaryStorage = class {
645
- driverName = "memory";
646
- values = /* @__PURE__ */ new Map();
647
- async write(args) {
648
- const bytes = await new BinaryBodyBufferReader().read(args.body);
649
- this.values.set(args.storageKey, bytes);
650
- return {
651
- storageKey: args.storageKey,
652
- size: bytes.byteLength,
653
- sha256: (0, node_crypto.createHash)("sha256").update(bytes).digest("hex")
654
- };
655
- }
656
- async openReadStream(storageKey) {
657
- const bytes = this.values.get(storageKey);
658
- if (!bytes) return;
659
- return {
660
- body: new BinaryBodyReadableStreamFactory(bytes).create(),
661
- size: bytes.byteLength
662
- };
663
- }
664
- async stat(storageKey) {
665
- const bytes = this.values.get(storageKey);
666
- if (!bytes) return { exists: false };
667
- return {
668
- exists: true,
669
- size: bytes.byteLength
670
- };
671
- }
672
- async delete(storageKey) {
673
- this.values.delete(storageKey);
674
- }
675
- };
676
-
677
- //#endregion
678
- //#region src/runStorage/InMemoryRunData.ts
679
- var InMemoryRunData = class {
680
- byNode = /* @__PURE__ */ new Map();
681
- constructor(initial) {
682
- if (initial) for (const [nodeId, outputs] of Object.entries(initial)) this.byNode.set(nodeId, outputs);
683
- }
684
- setOutputs(nodeId, outputs) {
685
- this.byNode.set(nodeId, outputs);
686
- }
687
- getOutputs(nodeId) {
688
- return this.byNode.get(nodeId);
689
- }
690
- getOutputItems(nodeId, output = "main") {
691
- return this.byNode.get(nodeId)?.[output] ?? [];
692
- }
693
- getOutputItem(nodeId, itemIndex, output = "main") {
694
- return this.getOutputItems(nodeId, output)[itemIndex];
695
- }
696
- dump() {
697
- const out = {};
698
- for (const [nodeId, outputs] of this.byNode.entries()) out[nodeId] = outputs;
699
- return out;
700
- }
701
- };
702
-
703
- //#endregion
704
- //#region src/runStorage/InMemoryRunDataFactory.ts
705
- var InMemoryRunDataFactory = class {
706
- create(initial) {
707
- return new InMemoryRunData(initial);
708
- }
709
- };
710
-
711
- //#endregion
712
- //#region src/contracts/runFinishedAtFactory.ts
713
- /** Derives workflow end time from node snapshots for run listings. */
714
- var RunFinishedAtFactory = class {
715
- static resolveIso(state) {
716
- if (state.status === "running" || state.status === "pending") return;
717
- let max;
718
- for (const snap of Object.values(state.nodeSnapshotsByNodeId)) if (snap?.finishedAt && (!max || snap.finishedAt > max)) max = snap.finishedAt;
719
- return max;
720
- }
721
- };
722
-
723
- //#endregion
724
- //#region src/runStorage/RunSummaryMapper.ts
725
- /** Maps persisted run state to API run summaries for listings. */
726
- var RunSummaryMapper = class {
727
- static fromPersistedState(state) {
728
- return {
729
- runId: state.runId,
730
- workflowId: state.workflowId,
731
- startedAt: state.startedAt,
732
- status: state.status,
733
- finishedAt: RunFinishedAtFactory.resolveIso(state),
734
- parent: state.parent,
735
- executionOptions: state.executionOptions
736
- };
737
- }
738
- };
739
-
740
- //#endregion
741
- //#region src/runStorage/InMemoryWorkflowExecutionRepository.ts
742
- var InMemoryWorkflowExecutionRepository = class {
743
- runs = /* @__PURE__ */ new Map();
744
- async createRun(args) {
745
- this.runs.set(args.runId, {
746
- runId: args.runId,
747
- workflowId: args.workflowId,
748
- startedAt: args.startedAt,
749
- parent: args.parent,
750
- executionOptions: args.executionOptions,
751
- control: args.control,
752
- workflowSnapshot: args.workflowSnapshot,
753
- mutableState: args.mutableState,
754
- policySnapshot: args.policySnapshot,
755
- engineCounters: args.engineCounters,
756
- status: "running",
757
- queue: [],
758
- outputsByNode: {},
759
- nodeSnapshotsByNodeId: {},
760
- connectionInvocations: []
761
- });
762
- }
763
- async load(runId) {
764
- return this.runs.get(runId);
765
- }
766
- async save(state) {
767
- this.runs.set(state.runId, state);
768
- }
769
- async deleteRun(runId) {
770
- this.runs.delete(runId);
771
- }
772
- async listRuns(args) {
773
- const limit = args?.limit ?? 50;
774
- return [...this.runs.values()].filter((s) => args?.workflowId ? s.workflowId === args.workflowId : true).sort((a, b) => b.startedAt.localeCompare(a.startedAt)).slice(0, limit).map((s) => RunSummaryMapper.fromPersistedState(s));
775
- }
776
- async listRunsOlderThan(args) {
777
- const limit = args.limit ?? 100;
778
- const out = [];
779
- for (const s of this.runs.values()) {
780
- if (s.status !== "completed" && s.status !== "failed") continue;
781
- const finishedAt = RunFinishedAtFactory.resolveIso(s);
782
- if (!finishedAt || finishedAt >= args.beforeIso) continue;
783
- out.push({
784
- runId: s.runId,
785
- workflowId: s.workflowId,
786
- startedAt: s.startedAt,
787
- finishedAt
788
- });
789
- }
790
- out.sort((a, b) => a.finishedAt.localeCompare(b.finishedAt));
791
- return out.slice(0, limit);
792
- }
793
- };
794
-
795
- //#endregion
796
- //#region src/runtime/RunIntentService.ts
797
- var RunIntentService = class {
798
- constructor(engine, workflowRepository) {
799
- this.engine = engine;
800
- this.workflowRepository = workflowRepository;
801
- }
802
- async startWorkflow(args) {
803
- if (args.startAt && !args.currentState && !args.stopCondition && !args.reset) return await this.engine.runWorkflow(args.workflow, args.startAt, args.items, args.parent, args.executionOptions, {
804
- workflowSnapshot: args.workflowSnapshot,
805
- mutableState: args.mutableState
806
- });
807
- return await this.engine.runWorkflowFromState({
808
- workflow: args.workflow,
809
- items: args.items,
810
- parent: args.parent,
811
- executionOptions: args.executionOptions,
812
- workflowSnapshot: args.workflowSnapshot,
813
- mutableState: args.mutableState,
814
- currentState: args.currentState,
815
- stopCondition: args.stopCondition ?? { kind: "workflowCompleted" },
816
- reset: args.reset
817
- });
818
- }
819
- async rerunFromNode(args) {
820
- if (args.items) return await this.engine.runWorkflow(args.workflow, args.nodeId, args.items, args.parent, args.executionOptions, {
821
- workflowSnapshot: args.workflowSnapshot,
822
- mutableState: args.mutableState
823
- });
824
- return await this.engine.runWorkflowFromState({
825
- workflow: args.workflow,
826
- parent: args.parent,
827
- executionOptions: args.executionOptions,
828
- workflowSnapshot: args.workflowSnapshot,
829
- mutableState: args.mutableState,
830
- currentState: args.currentState,
831
- stopCondition: { kind: "workflowCompleted" },
832
- reset: { clearFromNodeId: args.nodeId }
833
- });
834
- }
835
- resolveWebhookTrigger(args) {
836
- return this.engine.resolveWebhookTrigger(args);
837
- }
838
- async runMatchedWebhook(args) {
839
- const resolution = this.resolveWebhookTrigger(args);
840
- if (resolution.status === "notFound") throw new Error("Unknown webhook endpoint");
841
- if (resolution.status === "methodNotAllowed") throw new Error("Method not allowed");
842
- return await this.runWebhookMatch({
843
- match: resolution.match,
844
- requestItem: args.requestItem
845
- });
846
- }
847
- async runWebhookMatch(args) {
848
- const workflow = this.workflowRepository.get(args.match.workflowId);
849
- if (!workflow) throw new Error(`Unknown workflowId: ${args.match.workflowId}`);
850
- const scheduled = await this.engine.runWorkflow(workflow, args.match.nodeId, [args.requestItem], void 0, this.createWebhookExecutionOptions());
851
- if (scheduled.status === "failed") throw new Error(scheduled.error.message);
852
- if (scheduled.status === "completed") return {
853
- runId: scheduled.runId,
854
- workflowId: scheduled.workflowId,
855
- startedAt: scheduled.startedAt,
856
- runStatus: "completed",
857
- response: scheduled.outputs
858
- };
859
- return await Promise.race([this.engine.waitForWebhookResponse(scheduled.runId), this.engine.waitForCompletion(scheduled.runId).then((completed) => {
860
- if (completed.status === "failed") throw new Error(completed.error.message);
861
- return {
862
- runId: completed.runId,
863
- workflowId: completed.workflowId,
864
- startedAt: completed.startedAt,
865
- runStatus: "completed",
866
- response: completed.outputs
867
- };
868
- })]);
869
- }
870
- /**
871
- * Webhook-triggered runs always force inline execution first.
872
- * This is the highest-precedence scheduler override: it wins over node hints and container defaults.
873
- */
874
- createWebhookExecutionOptions() {
875
- return {
876
- localOnly: true,
877
- webhook: true
878
- };
879
- }
880
- };
881
-
882
- //#endregion
883
- Object.defineProperty(exports, 'ConnectionNodeIdFactory', {
884
- enumerable: true,
885
- get: function () {
886
- return ConnectionNodeIdFactory;
887
- }
888
- });
889
- Object.defineProperty(exports, 'CoreTokens', {
890
- enumerable: true,
891
- get: function () {
892
- return CoreTokens;
893
- }
894
- });
895
- Object.defineProperty(exports, 'CredentialResolverFactory', {
896
- enumerable: true,
897
- get: function () {
898
- return CredentialResolverFactory;
899
- }
900
- });
901
- Object.defineProperty(exports, 'DefaultAsyncSleeper', {
902
- enumerable: true,
903
- get: function () {
904
- return DefaultAsyncSleeper;
905
- }
906
- });
907
- Object.defineProperty(exports, 'DefaultExecutionBinaryService', {
908
- enumerable: true,
909
- get: function () {
910
- return DefaultExecutionBinaryService;
911
- }
912
- });
913
- Object.defineProperty(exports, 'DefaultExecutionContextFactory', {
914
- enumerable: true,
915
- get: function () {
916
- return DefaultExecutionContextFactory;
917
- }
918
- });
919
- Object.defineProperty(exports, 'ENGINE_EXECUTION_LIMITS_DEFAULTS', {
920
- enumerable: true,
921
- get: function () {
922
- return ENGINE_EXECUTION_LIMITS_DEFAULTS;
923
- }
924
- });
925
- Object.defineProperty(exports, 'EngineExecutionLimitsPolicy', {
926
- enumerable: true,
927
- get: function () {
928
- return EngineExecutionLimitsPolicy;
929
- }
930
- });
931
- Object.defineProperty(exports, 'InMemoryBinaryStorage', {
932
- enumerable: true,
933
- get: function () {
934
- return InMemoryBinaryStorage;
935
- }
936
- });
937
- Object.defineProperty(exports, 'InMemoryRunDataFactory', {
938
- enumerable: true,
939
- get: function () {
940
- return InMemoryRunDataFactory;
941
- }
942
- });
943
- Object.defineProperty(exports, 'InMemoryWorkflowExecutionRepository', {
944
- enumerable: true,
945
- get: function () {
946
- return InMemoryWorkflowExecutionRepository;
947
- }
948
- });
949
- Object.defineProperty(exports, 'InProcessRetryRunner', {
950
- enumerable: true,
951
- get: function () {
952
- return InProcessRetryRunner;
953
- }
954
- });
955
- Object.defineProperty(exports, 'InjectableRuntimeDecoratorComposer', {
956
- enumerable: true,
957
- get: function () {
958
- return InjectableRuntimeDecoratorComposer;
959
- }
960
- });
961
- Object.defineProperty(exports, 'NodeEventPublisher', {
962
- enumerable: true,
963
- get: function () {
964
- return NodeEventPublisher;
965
- }
966
- });
967
- Object.defineProperty(exports, 'PersistedRuntimeTypeMetadataStore', {
968
- enumerable: true,
969
- get: function () {
970
- return PersistedRuntimeTypeMetadataStore;
971
- }
972
- });
973
- Object.defineProperty(exports, 'PersistedRuntimeTypeNameResolver', {
974
- enumerable: true,
975
- get: function () {
976
- return PersistedRuntimeTypeNameResolver;
977
- }
978
- });
979
- Object.defineProperty(exports, 'RunFinishedAtFactory', {
980
- enumerable: true,
981
- get: function () {
982
- return RunFinishedAtFactory;
983
- }
984
- });
985
- Object.defineProperty(exports, 'RunIntentService', {
986
- enumerable: true,
987
- get: function () {
988
- return RunIntentService;
989
- }
990
- });
991
- Object.defineProperty(exports, 'RunSummaryMapper', {
992
- enumerable: true,
993
- get: function () {
994
- return RunSummaryMapper;
995
- }
996
- });
997
- Object.defineProperty(exports, 'StackTraceCallSitePathResolver', {
998
- enumerable: true,
999
- get: function () {
1000
- return StackTraceCallSitePathResolver;
1001
- }
1002
- });
1003
- Object.defineProperty(exports, 'UnavailableBinaryStorage', {
1004
- enumerable: true,
1005
- get: function () {
1006
- return UnavailableBinaryStorage;
1007
- }
1008
- });
1009
- Object.defineProperty(exports, 'WorkflowExecutableNodeClassifier', {
1010
- enumerable: true,
1011
- get: function () {
1012
- return WorkflowExecutableNodeClassifier;
1013
- }
1014
- });
1015
- Object.defineProperty(exports, '__toESM', {
1016
- enumerable: true,
1017
- get: function () {
1018
- return __toESM;
1019
- }
1020
- });
1021
- Object.defineProperty(exports, 'chatModel', {
1022
- enumerable: true,
1023
- get: function () {
1024
- return chatModel;
1025
- }
1026
- });
1027
- Object.defineProperty(exports, 'createWorkflowExecutableNodeClassifier', {
1028
- enumerable: true,
1029
- get: function () {
1030
- return createWorkflowExecutableNodeClassifier;
1031
- }
1032
- });
1033
- Object.defineProperty(exports, 'getPersistedRuntimeTypeMetadata', {
1034
- enumerable: true,
1035
- get: function () {
1036
- return getPersistedRuntimeTypeMetadata;
1037
- }
1038
- });
1039
- Object.defineProperty(exports, 'node', {
1040
- enumerable: true,
1041
- get: function () {
1042
- return node;
1043
- }
1044
- });
1045
- Object.defineProperty(exports, 'tool', {
1046
- enumerable: true,
1047
- get: function () {
1048
- return tool;
1049
- }
1050
- });
1051
- //# sourceMappingURL=RunIntentService-BsBOwpVN.cjs.map