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