@codemation/core 0.0.16 → 0.0.19
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/CHANGELOG.md +15 -0
- package/LICENSE +37 -0
- package/dist/{RunIntentService-CYnn140t.js → RunIntentService-C1nu_YwM.js} +170 -118
- package/dist/RunIntentService-C1nu_YwM.js.map +1 -0
- package/dist/{RunIntentService-ByuUYsAL.d.cts → RunIntentService-DjbxzBBP.d.cts} +10 -1
- package/dist/{RunIntentService-DlQH5eZ2.cjs → RunIntentService-ZkjpY7MS.cjs} +170 -118
- package/dist/RunIntentService-ZkjpY7MS.cjs.map +1 -0
- package/dist/bootstrap/index.cjs +1 -1
- package/dist/bootstrap/index.d.cts +1 -1
- package/dist/bootstrap/index.d.ts +1 -1
- package/dist/bootstrap/index.js +1 -1
- package/dist/{index-k0hwnJyT.d.ts → index-BIewO9-9.d.ts} +89 -10
- package/dist/index.cjs +181 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -12
- package/dist/index.d.ts +2 -2
- package/dist/index.js +180 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/authoring/DefinedNodeRegistry.ts +16 -0
- package/src/authoring/defineCredential.types.ts +172 -0
- package/src/authoring/defineNode.types.ts +227 -0
- package/src/authoring/index.ts +12 -0
- package/src/index.ts +1 -0
- package/src/planning/CurrentStateFrontierPlanner.ts +24 -1
- package/src/runtime/RunIntentService.ts +68 -14
- package/dist/RunIntentService-CYnn140t.js.map +0 -1
- package/dist/RunIntentService-DlQH5eZ2.cjs.map +0 -1
|
@@ -229,6 +229,7 @@ type StartWorkflowIntent = {
|
|
|
229
229
|
workflow: WorkflowDefinition;
|
|
230
230
|
startAt?: string;
|
|
231
231
|
items: Items;
|
|
232
|
+
synthesizeTriggerItems?: boolean;
|
|
232
233
|
parent?: CurrentStateExecutionRequest["parent"];
|
|
233
234
|
executionOptions?: RunExecutionOptions;
|
|
234
235
|
workflowSnapshot?: CurrentStateExecutionRequest["workflowSnapshot"];
|
|
@@ -242,6 +243,7 @@ type RerunFromNodeIntent = {
|
|
|
242
243
|
nodeId: NodeId;
|
|
243
244
|
currentState: RunCurrentState;
|
|
244
245
|
items?: Items;
|
|
246
|
+
synthesizeTriggerItems?: boolean;
|
|
245
247
|
parent?: CurrentStateExecutionRequest["parent"];
|
|
246
248
|
executionOptions?: RunExecutionOptions;
|
|
247
249
|
workflowSnapshot?: CurrentStateExecutionRequest["workflowSnapshot"];
|
|
@@ -262,6 +264,13 @@ declare class RunIntentService {
|
|
|
262
264
|
constructor(engine: Engine, workflowRepository: WorkflowRepository);
|
|
263
265
|
startWorkflow(args: StartWorkflowIntent): Promise<RunResult>;
|
|
264
266
|
rerunFromNode(args: RerunFromNodeIntent): Promise<RunResult>;
|
|
267
|
+
private resolveStartWorkflowItems;
|
|
268
|
+
private resolveRerunItems;
|
|
269
|
+
private resolveStartWorkflowTriggerNodeId;
|
|
270
|
+
private resolveRerunTriggerNodeId;
|
|
271
|
+
private firstTriggerNodeId;
|
|
272
|
+
private isTriggerNode;
|
|
273
|
+
private hasNonEmptyItems;
|
|
265
274
|
resolveWebhookTrigger(args: {
|
|
266
275
|
endpointPath: string;
|
|
267
276
|
method: HttpMethod;
|
|
@@ -276,4 +285,4 @@ declare class RunIntentService {
|
|
|
276
285
|
}
|
|
277
286
|
//#endregion
|
|
278
287
|
export { UnavailableBinaryStorage as a, DefaultAsyncSleeper as c, Engine as d, DefaultExecutionBinaryService as i, AsyncSleeper as l, InMemoryRunDataFactory as n, InProcessRetryRunner as o, InMemoryBinaryStorage as r, DefaultExecutionContextFactory as s, RunIntentService as t, CredentialResolverFactory as u };
|
|
279
|
-
//# sourceMappingURL=RunIntentService-
|
|
288
|
+
//# sourceMappingURL=RunIntentService-DjbxzBBP.d.cts.map
|
|
@@ -21,105 +21,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
}) : target, mod));
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
|
-
let node_crypto = require("node:crypto");
|
|
25
|
-
node_crypto = __toESM(node_crypto);
|
|
26
24
|
require("reflect-metadata");
|
|
27
25
|
let tsyringe = require("tsyringe");
|
|
28
26
|
tsyringe = __toESM(tsyringe);
|
|
27
|
+
let node_crypto = require("node:crypto");
|
|
28
|
+
node_crypto = __toESM(node_crypto);
|
|
29
29
|
let node_stream_web = require("node:stream/web");
|
|
30
30
|
node_stream_web = __toESM(node_stream_web);
|
|
31
31
|
|
|
32
|
-
//#region src/workflow/definition/ConnectionNodeIdFactory.ts
|
|
33
|
-
/**
|
|
34
|
-
* Deterministic ids for workflow connection-owned child nodes (LLM slot, tools, etc.).
|
|
35
|
-
* These are stable across loads.
|
|
36
|
-
*/
|
|
37
|
-
var ConnectionNodeIdFactory = class {
|
|
38
|
-
static connectionSegment = "__conn__";
|
|
39
|
-
static languageModelConnectionNodeId(parentNodeId) {
|
|
40
|
-
return `${parentNodeId}${this.connectionSegment}llm`;
|
|
41
|
-
}
|
|
42
|
-
static toolConnectionNodeId(parentNodeId, toolName) {
|
|
43
|
-
const normalized = this.normalizeToolName(toolName);
|
|
44
|
-
return `${parentNodeId}${this.connectionSegment}tool${this.connectionSegment}${normalized}`;
|
|
45
|
-
}
|
|
46
|
-
static isLanguageModelConnectionNodeId(nodeId) {
|
|
47
|
-
return nodeId.endsWith(`${this.connectionSegment}llm`);
|
|
48
|
-
}
|
|
49
|
-
static isToolConnectionNodeId(nodeId) {
|
|
50
|
-
return nodeId.includes(`${this.connectionSegment}tool${this.connectionSegment}`);
|
|
51
|
-
}
|
|
52
|
-
/** True when `nodeId` is a connection-owned child of `parentNodeId` (LLM or tool slot). */
|
|
53
|
-
static isConnectionOwnedDescendantOf(parentNodeId, nodeId) {
|
|
54
|
-
return nodeId.startsWith(`${parentNodeId}${this.connectionSegment}`);
|
|
55
|
-
}
|
|
56
|
-
/** Normalizes a tool display name to a stable id segment. */
|
|
57
|
-
static normalizeToolName(toolName) {
|
|
58
|
-
return toolName.trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "") || "tool";
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region src/workflow/definition/WorkflowExecutableNodeClassifier.ts
|
|
64
|
-
/**
|
|
65
|
-
* Derives which workflow nodes participate in the main execution graph vs connection-only children.
|
|
66
|
-
*/
|
|
67
|
-
var WorkflowExecutableNodeClassifier = class {
|
|
68
|
-
connectionOwnedIds;
|
|
69
|
-
constructor(workflow) {
|
|
70
|
-
this.connectionOwnedIds = this.collectConnectionOwnedIds(workflow);
|
|
71
|
-
}
|
|
72
|
-
isConnectionOwnedNodeId(nodeId) {
|
|
73
|
-
return this.connectionOwnedIds.has(nodeId);
|
|
74
|
-
}
|
|
75
|
-
isExecutableNodeId(nodeId) {
|
|
76
|
-
return !this.connectionOwnedIds.has(nodeId);
|
|
77
|
-
}
|
|
78
|
-
filterExecutableNodeDefinitions(nodes) {
|
|
79
|
-
return nodes.filter((n) => this.isExecutableNodeId(n.id));
|
|
80
|
-
}
|
|
81
|
-
collectConnectionOwnedIds(workflow) {
|
|
82
|
-
const ids = /* @__PURE__ */ new Set();
|
|
83
|
-
for (const connection of workflow.connections ?? []) for (const childId of connection.childNodeIds) ids.add(childId);
|
|
84
|
-
return ids;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Resolves the default start node: first trigger, else first executable node with no incoming edges from executable nodes.
|
|
88
|
-
*/
|
|
89
|
-
findDefaultExecutableStartNodeId(workflow) {
|
|
90
|
-
const firstTrigger = workflow.nodes.find((n) => n.kind === "trigger" && this.isExecutableNodeId(n.id))?.id;
|
|
91
|
-
if (firstTrigger) return firstTrigger;
|
|
92
|
-
const incoming = /* @__PURE__ */ new Map();
|
|
93
|
-
for (const n of workflow.nodes) if (this.isExecutableNodeId(n.id)) incoming.set(n.id, 0);
|
|
94
|
-
for (const e of workflow.edges) {
|
|
95
|
-
if (!this.isExecutableNodeId(e.from.nodeId) || !this.isExecutableNodeId(e.to.nodeId)) continue;
|
|
96
|
-
incoming.set(e.to.nodeId, (incoming.get(e.to.nodeId) ?? 0) + 1);
|
|
97
|
-
}
|
|
98
|
-
return workflow.nodes.find((n) => this.isExecutableNodeId(n.id) && (incoming.get(n.id) ?? 0) === 0)?.id ?? workflow.nodes.find((n) => this.isExecutableNodeId(n.id))?.id ?? (() => {
|
|
99
|
-
throw new Error(`Workflow ${workflow.id} has no executable nodes`);
|
|
100
|
-
})();
|
|
101
|
-
}
|
|
102
|
-
firstExecutableNodeIdInDefinitionOrder(workflow) {
|
|
103
|
-
return workflow.nodes.find((n) => this.isExecutableNodeId(n.id))?.id;
|
|
104
|
-
}
|
|
105
|
-
lastExecutableNodeIdInDefinitionOrder(workflow) {
|
|
106
|
-
for (let i = workflow.nodes.length - 1; i >= 0; i--) {
|
|
107
|
-
const n = workflow.nodes[i];
|
|
108
|
-
if (this.isExecutableNodeId(n.id)) return n.id;
|
|
109
|
-
}
|
|
110
|
-
throw new Error(`Workflow ${workflow.id} has no executable nodes`);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
//#endregion
|
|
115
|
-
//#region src/workflow/definition/WorkflowExecutableNodeClassifierFactory.ts
|
|
116
|
-
var WorkflowExecutableNodeClassifierFactory = class {
|
|
117
|
-
static create(workflow) {
|
|
118
|
-
return new WorkflowExecutableNodeClassifier(workflow);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
//#endregion
|
|
123
32
|
//#region src/di/CoreTokens.ts
|
|
124
33
|
const CoreTokens = {
|
|
125
34
|
PersistedWorkflowTokenRegistry: Symbol.for("codemation.core.PersistedWorkflowTokenRegistry"),
|
|
@@ -144,26 +53,6 @@ const CoreTokens = {
|
|
|
144
53
|
WorkflowActivationPolicy: Symbol.for("codemation.core.WorkflowActivationPolicy")
|
|
145
54
|
};
|
|
146
55
|
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region src/events/NodeEventPublisher.ts
|
|
149
|
-
/** Publishes node lifecycle snapshots onto the run {@link RunEventBus}. */
|
|
150
|
-
var NodeEventPublisher = class {
|
|
151
|
-
constructor(eventBus) {
|
|
152
|
-
this.eventBus = eventBus;
|
|
153
|
-
}
|
|
154
|
-
async publish(kind, snapshot) {
|
|
155
|
-
if (!this.eventBus) return;
|
|
156
|
-
await this.eventBus.publish({
|
|
157
|
-
kind,
|
|
158
|
-
runId: snapshot.runId,
|
|
159
|
-
workflowId: snapshot.workflowId,
|
|
160
|
-
parent: snapshot.parent,
|
|
161
|
-
at: snapshot.updatedAt,
|
|
162
|
-
snapshot
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
|
|
167
56
|
//#endregion
|
|
168
57
|
//#region src/runtime-types/persistedRuntimeTypeModelRegistry.ts
|
|
169
58
|
/** Shared metadata key used to attach persisted runtime-type information to decorated classes. */
|
|
@@ -273,6 +162,117 @@ function chatModel(options = {}) {
|
|
|
273
162
|
return InjectableRuntimeDecoratorComposer.compose("chatModel", options, require("url").pathToFileURL(__filename).href);
|
|
274
163
|
}
|
|
275
164
|
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/workflow/definition/ConnectionNodeIdFactory.ts
|
|
167
|
+
/**
|
|
168
|
+
* Deterministic ids for workflow connection-owned child nodes (LLM slot, tools, etc.).
|
|
169
|
+
* These are stable across loads.
|
|
170
|
+
*/
|
|
171
|
+
var ConnectionNodeIdFactory = class {
|
|
172
|
+
static connectionSegment = "__conn__";
|
|
173
|
+
static languageModelConnectionNodeId(parentNodeId) {
|
|
174
|
+
return `${parentNodeId}${this.connectionSegment}llm`;
|
|
175
|
+
}
|
|
176
|
+
static toolConnectionNodeId(parentNodeId, toolName) {
|
|
177
|
+
const normalized = this.normalizeToolName(toolName);
|
|
178
|
+
return `${parentNodeId}${this.connectionSegment}tool${this.connectionSegment}${normalized}`;
|
|
179
|
+
}
|
|
180
|
+
static isLanguageModelConnectionNodeId(nodeId) {
|
|
181
|
+
return nodeId.endsWith(`${this.connectionSegment}llm`);
|
|
182
|
+
}
|
|
183
|
+
static isToolConnectionNodeId(nodeId) {
|
|
184
|
+
return nodeId.includes(`${this.connectionSegment}tool${this.connectionSegment}`);
|
|
185
|
+
}
|
|
186
|
+
/** True when `nodeId` is a connection-owned child of `parentNodeId` (LLM or tool slot). */
|
|
187
|
+
static isConnectionOwnedDescendantOf(parentNodeId, nodeId) {
|
|
188
|
+
return nodeId.startsWith(`${parentNodeId}${this.connectionSegment}`);
|
|
189
|
+
}
|
|
190
|
+
/** Normalizes a tool display name to a stable id segment. */
|
|
191
|
+
static normalizeToolName(toolName) {
|
|
192
|
+
return toolName.trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "") || "tool";
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/workflow/definition/WorkflowExecutableNodeClassifier.ts
|
|
198
|
+
/**
|
|
199
|
+
* Derives which workflow nodes participate in the main execution graph vs connection-only children.
|
|
200
|
+
*/
|
|
201
|
+
var WorkflowExecutableNodeClassifier = class {
|
|
202
|
+
connectionOwnedIds;
|
|
203
|
+
constructor(workflow) {
|
|
204
|
+
this.connectionOwnedIds = this.collectConnectionOwnedIds(workflow);
|
|
205
|
+
}
|
|
206
|
+
isConnectionOwnedNodeId(nodeId) {
|
|
207
|
+
return this.connectionOwnedIds.has(nodeId);
|
|
208
|
+
}
|
|
209
|
+
isExecutableNodeId(nodeId) {
|
|
210
|
+
return !this.connectionOwnedIds.has(nodeId);
|
|
211
|
+
}
|
|
212
|
+
filterExecutableNodeDefinitions(nodes) {
|
|
213
|
+
return nodes.filter((n) => this.isExecutableNodeId(n.id));
|
|
214
|
+
}
|
|
215
|
+
collectConnectionOwnedIds(workflow) {
|
|
216
|
+
const ids = /* @__PURE__ */ new Set();
|
|
217
|
+
for (const connection of workflow.connections ?? []) for (const childId of connection.childNodeIds) ids.add(childId);
|
|
218
|
+
return ids;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Resolves the default start node: first trigger, else first executable node with no incoming edges from executable nodes.
|
|
222
|
+
*/
|
|
223
|
+
findDefaultExecutableStartNodeId(workflow) {
|
|
224
|
+
const firstTrigger = workflow.nodes.find((n) => n.kind === "trigger" && this.isExecutableNodeId(n.id))?.id;
|
|
225
|
+
if (firstTrigger) return firstTrigger;
|
|
226
|
+
const incoming = /* @__PURE__ */ new Map();
|
|
227
|
+
for (const n of workflow.nodes) if (this.isExecutableNodeId(n.id)) incoming.set(n.id, 0);
|
|
228
|
+
for (const e of workflow.edges) {
|
|
229
|
+
if (!this.isExecutableNodeId(e.from.nodeId) || !this.isExecutableNodeId(e.to.nodeId)) continue;
|
|
230
|
+
incoming.set(e.to.nodeId, (incoming.get(e.to.nodeId) ?? 0) + 1);
|
|
231
|
+
}
|
|
232
|
+
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 ?? (() => {
|
|
233
|
+
throw new Error(`Workflow ${workflow.id} has no executable nodes`);
|
|
234
|
+
})();
|
|
235
|
+
}
|
|
236
|
+
firstExecutableNodeIdInDefinitionOrder(workflow) {
|
|
237
|
+
return workflow.nodes.find((n) => this.isExecutableNodeId(n.id))?.id;
|
|
238
|
+
}
|
|
239
|
+
lastExecutableNodeIdInDefinitionOrder(workflow) {
|
|
240
|
+
for (let i = workflow.nodes.length - 1; i >= 0; i--) {
|
|
241
|
+
const n = workflow.nodes[i];
|
|
242
|
+
if (this.isExecutableNodeId(n.id)) return n.id;
|
|
243
|
+
}
|
|
244
|
+
throw new Error(`Workflow ${workflow.id} has no executable nodes`);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/workflow/definition/WorkflowExecutableNodeClassifierFactory.ts
|
|
250
|
+
var WorkflowExecutableNodeClassifierFactory = class {
|
|
251
|
+
static create(workflow) {
|
|
252
|
+
return new WorkflowExecutableNodeClassifier(workflow);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/events/NodeEventPublisher.ts
|
|
258
|
+
/** Publishes node lifecycle snapshots onto the run {@link RunEventBus}. */
|
|
259
|
+
var NodeEventPublisher = class {
|
|
260
|
+
constructor(eventBus) {
|
|
261
|
+
this.eventBus = eventBus;
|
|
262
|
+
}
|
|
263
|
+
async publish(kind, snapshot) {
|
|
264
|
+
if (!this.eventBus) return;
|
|
265
|
+
await this.eventBus.publish({
|
|
266
|
+
kind,
|
|
267
|
+
runId: snapshot.runId,
|
|
268
|
+
workflowId: snapshot.workflowId,
|
|
269
|
+
parent: snapshot.parent,
|
|
270
|
+
at: snapshot.updatedAt,
|
|
271
|
+
snapshot
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
|
|
276
276
|
//#endregion
|
|
277
277
|
//#region src/binaries/DefaultNodeBinaryAttachmentServiceFactory.ts
|
|
278
278
|
var DefaultNodeBinaryAttachmentService = class DefaultNodeBinaryAttachmentService {
|
|
@@ -2262,7 +2262,10 @@ var CurrentStateFrontierPlanner = class CurrentStateFrontierPlanner {
|
|
|
2262
2262
|
isEdgeSatisfied(currentState, nodeId, input) {
|
|
2263
2263
|
const incomingEdge = (this.topology.incomingByNode.get(nodeId) ?? []).find((edge) => edge.input === input);
|
|
2264
2264
|
if (!incomingEdge) return false;
|
|
2265
|
-
|
|
2265
|
+
if (!this.hasOutputPort(currentState, incomingEdge.from.nodeId, incomingEdge.from.output)) return false;
|
|
2266
|
+
if (this.usesCollect(nodeId)) return true;
|
|
2267
|
+
if (this.resolveOutputItems(currentState, incomingEdge.from.nodeId, incomingEdge.from.output).length > 0) return true;
|
|
2268
|
+
return this.shouldContinueAfterEmptyOutputFromSource(incomingEdge.from.nodeId);
|
|
2266
2269
|
}
|
|
2267
2270
|
resolveInput(currentState, nodeId, input) {
|
|
2268
2271
|
const incomingEdge = (this.topology.incomingByNode.get(nodeId) ?? []).find((edge) => edge.input === input);
|
|
@@ -2284,6 +2287,15 @@ var CurrentStateFrontierPlanner = class CurrentStateFrontierPlanner {
|
|
|
2284
2287
|
resolveOutputItems(currentState, nodeId, output) {
|
|
2285
2288
|
return currentState.outputsByNode[nodeId]?.[output] ?? [];
|
|
2286
2289
|
}
|
|
2290
|
+
usesCollect(nodeId) {
|
|
2291
|
+
const expectedInputs = this.topology.expectedInputsByNode.get(nodeId) ?? [];
|
|
2292
|
+
return expectedInputs.length !== 1 || expectedInputs[0] !== "in";
|
|
2293
|
+
}
|
|
2294
|
+
shouldContinueAfterEmptyOutputFromSource(nodeId) {
|
|
2295
|
+
const definition = this.topology.defsById.get(nodeId);
|
|
2296
|
+
if (!definition) return false;
|
|
2297
|
+
return definition.config.continueWhenEmptyOutput === true;
|
|
2298
|
+
}
|
|
2287
2299
|
getPinnedOutputs(currentState, nodeId) {
|
|
2288
2300
|
return currentState.mutableState?.nodesById?.[nodeId]?.pinnedOutputsByPort;
|
|
2289
2301
|
}
|
|
@@ -3078,13 +3090,14 @@ var RunIntentService = class {
|
|
|
3078
3090
|
this.workflowRepository = workflowRepository;
|
|
3079
3091
|
}
|
|
3080
3092
|
async startWorkflow(args) {
|
|
3081
|
-
|
|
3093
|
+
const items = await this.resolveStartWorkflowItems(args);
|
|
3094
|
+
if (args.startAt && !args.currentState && !args.stopCondition && !args.reset) return await this.engine.runWorkflow(args.workflow, args.startAt, items, args.parent, args.executionOptions, {
|
|
3082
3095
|
workflowSnapshot: args.workflowSnapshot,
|
|
3083
3096
|
mutableState: args.mutableState
|
|
3084
3097
|
});
|
|
3085
3098
|
return await this.engine.runWorkflowFromState({
|
|
3086
3099
|
workflow: args.workflow,
|
|
3087
|
-
items
|
|
3100
|
+
items,
|
|
3088
3101
|
parent: args.parent,
|
|
3089
3102
|
executionOptions: args.executionOptions,
|
|
3090
3103
|
workflowSnapshot: args.workflowSnapshot,
|
|
@@ -3095,7 +3108,8 @@ var RunIntentService = class {
|
|
|
3095
3108
|
});
|
|
3096
3109
|
}
|
|
3097
3110
|
async rerunFromNode(args) {
|
|
3098
|
-
|
|
3111
|
+
const items = await this.resolveRerunItems(args);
|
|
3112
|
+
if (items) return await this.engine.runWorkflow(args.workflow, args.nodeId, items, args.parent, args.executionOptions, {
|
|
3099
3113
|
workflowSnapshot: args.workflowSnapshot,
|
|
3100
3114
|
mutableState: args.mutableState
|
|
3101
3115
|
});
|
|
@@ -3110,6 +3124,44 @@ var RunIntentService = class {
|
|
|
3110
3124
|
reset: { clearFromNodeId: args.nodeId }
|
|
3111
3125
|
});
|
|
3112
3126
|
}
|
|
3127
|
+
async resolveStartWorkflowItems(args) {
|
|
3128
|
+
if (this.hasNonEmptyItems(args.items)) return args.items;
|
|
3129
|
+
const triggerNodeId = this.resolveStartWorkflowTriggerNodeId(args);
|
|
3130
|
+
if (!triggerNodeId) return args.items;
|
|
3131
|
+
return await this.engine.createTriggerTestItems({
|
|
3132
|
+
workflow: args.workflow,
|
|
3133
|
+
nodeId: triggerNodeId
|
|
3134
|
+
}) ?? args.items;
|
|
3135
|
+
}
|
|
3136
|
+
async resolveRerunItems(args) {
|
|
3137
|
+
if (this.hasNonEmptyItems(args.items)) return args.items;
|
|
3138
|
+
const triggerNodeId = this.resolveRerunTriggerNodeId(args);
|
|
3139
|
+
if (!triggerNodeId) return args.items;
|
|
3140
|
+
return await this.engine.createTriggerTestItems({
|
|
3141
|
+
workflow: args.workflow,
|
|
3142
|
+
nodeId: triggerNodeId
|
|
3143
|
+
}) ?? args.items;
|
|
3144
|
+
}
|
|
3145
|
+
resolveStartWorkflowTriggerNodeId(args) {
|
|
3146
|
+
if (args.stopCondition?.kind === "nodeCompleted" && this.isTriggerNode(args.workflow, args.stopCondition.nodeId)) return args.stopCondition.nodeId;
|
|
3147
|
+
if (!args.synthesizeTriggerItems) return;
|
|
3148
|
+
if (args.startAt && this.isTriggerNode(args.workflow, args.startAt)) return args.startAt;
|
|
3149
|
+
return this.firstTriggerNodeId(args.workflow);
|
|
3150
|
+
}
|
|
3151
|
+
resolveRerunTriggerNodeId(args) {
|
|
3152
|
+
if (this.isTriggerNode(args.workflow, args.nodeId)) return args.nodeId;
|
|
3153
|
+
if (!args.synthesizeTriggerItems) return;
|
|
3154
|
+
return this.firstTriggerNodeId(args.workflow);
|
|
3155
|
+
}
|
|
3156
|
+
firstTriggerNodeId(workflow) {
|
|
3157
|
+
return workflow.nodes.find((node$1) => node$1.kind === "trigger")?.id;
|
|
3158
|
+
}
|
|
3159
|
+
isTriggerNode(workflow, nodeId) {
|
|
3160
|
+
return workflow.nodes.find((node$1) => node$1.id === nodeId)?.kind === "trigger";
|
|
3161
|
+
}
|
|
3162
|
+
hasNonEmptyItems(items) {
|
|
3163
|
+
return (items?.length ?? 0) > 0;
|
|
3164
|
+
}
|
|
3113
3165
|
resolveWebhookTrigger(args) {
|
|
3114
3166
|
return this.engine.resolveWebhookTrigger(args);
|
|
3115
3167
|
}
|
|
@@ -3464,4 +3516,4 @@ Object.defineProperty(exports, 'tool', {
|
|
|
3464
3516
|
return tool;
|
|
3465
3517
|
}
|
|
3466
3518
|
});
|
|
3467
|
-
//# sourceMappingURL=RunIntentService-
|
|
3519
|
+
//# sourceMappingURL=RunIntentService-ZkjpY7MS.cjs.map
|