@codemation/core 0.0.16 → 0.0.18

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.
@@ -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 {
@@ -3464,4 +3464,4 @@ Object.defineProperty(exports, 'tool', {
3464
3464
  return tool;
3465
3465
  }
3466
3466
  });
3467
- //# sourceMappingURL=RunIntentService-DlQH5eZ2.cjs.map
3467
+ //# sourceMappingURL=RunIntentService-nRx-m0Xs.cjs.map