@bian-womp/spark-graph 0.3.88 → 0.3.90

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 (167) hide show
  1. package/lib/cjs/index.cjs +9 -5
  2. package/lib/cjs/index.cjs.map +1 -1
  3. package/lib/cjs/src/runtime/GraphRuntime.d.ts.map +1 -1
  4. package/lib/cjs/src/runtime/components/HandleResolver.d.ts.map +1 -1
  5. package/lib/cjs/src/runtime/components/NodeExecutor.d.ts.map +1 -1
  6. package/lib/esm/index.js +9 -5
  7. package/lib/esm/index.js.map +1 -1
  8. package/lib/esm/src/runtime/GraphRuntime.d.ts.map +1 -1
  9. package/lib/esm/src/runtime/components/HandleResolver.d.ts.map +1 -1
  10. package/lib/esm/src/runtime/components/NodeExecutor.d.ts.map +1 -1
  11. package/lib/src/builder/GraphBuilder.d.ts +43 -0
  12. package/lib/src/builder/GraphBuilder.d.ts.map +1 -0
  13. package/lib/src/builder/GraphBuilder.js +279 -0
  14. package/lib/src/builder/GraphBuilder.js.map +1 -0
  15. package/lib/src/builder/Registry.d.ts +87 -0
  16. package/lib/src/builder/Registry.d.ts.map +1 -0
  17. package/lib/src/builder/Registry.js +390 -0
  18. package/lib/src/builder/Registry.js.map +1 -0
  19. package/lib/src/core/categories.d.ts +22 -0
  20. package/lib/src/core/categories.d.ts.map +1 -0
  21. package/lib/src/core/categories.js +2 -0
  22. package/lib/src/core/categories.js.map +1 -0
  23. package/lib/src/core/order.d.ts +7 -0
  24. package/lib/src/core/order.d.ts.map +1 -0
  25. package/lib/src/core/order.js +66 -0
  26. package/lib/src/core/order.js.map +1 -0
  27. package/lib/src/core/type-utils.d.ts +29 -0
  28. package/lib/src/core/type-utils.d.ts.map +1 -0
  29. package/lib/src/core/type-utils.js +92 -0
  30. package/lib/src/core/type-utils.js.map +1 -0
  31. package/lib/src/core/types.d.ts +95 -0
  32. package/lib/src/core/types.d.ts.map +1 -0
  33. package/lib/src/core/types.js +2 -0
  34. package/lib/src/core/types.js.map +1 -0
  35. package/lib/src/examples/arrays.d.ts +5 -0
  36. package/lib/src/examples/arrays.d.ts.map +1 -0
  37. package/lib/src/examples/arrays.js +49 -0
  38. package/lib/src/examples/arrays.js.map +1 -0
  39. package/lib/src/examples/async.d.ts +5 -0
  40. package/lib/src/examples/async.d.ts.map +1 -0
  41. package/lib/src/examples/async.js +91 -0
  42. package/lib/src/examples/async.js.map +1 -0
  43. package/lib/src/examples/progress.d.ts +5 -0
  44. package/lib/src/examples/progress.d.ts.map +1 -0
  45. package/lib/src/examples/progress.js +51 -0
  46. package/lib/src/examples/progress.js.map +1 -0
  47. package/lib/src/examples/run.d.ts +2 -0
  48. package/lib/src/examples/run.d.ts.map +1 -0
  49. package/lib/src/examples/run.js +32 -0
  50. package/lib/src/examples/run.js.map +1 -0
  51. package/lib/src/examples/runMode.d.ts +2 -0
  52. package/lib/src/examples/runMode.d.ts.map +1 -0
  53. package/lib/src/examples/runMode.js +223 -0
  54. package/lib/src/examples/runMode.js.map +1 -0
  55. package/lib/src/examples/shared.d.ts +5 -0
  56. package/lib/src/examples/shared.d.ts.map +1 -0
  57. package/lib/src/examples/shared.js +47 -0
  58. package/lib/src/examples/shared.js.map +1 -0
  59. package/lib/src/examples/simple.d.ts +5 -0
  60. package/lib/src/examples/simple.d.ts.map +1 -0
  61. package/lib/src/examples/simple.js +79 -0
  62. package/lib/src/examples/simple.js.map +1 -0
  63. package/lib/src/examples/snapshot.d.ts +4 -0
  64. package/lib/src/examples/snapshot.d.ts.map +1 -0
  65. package/lib/src/examples/snapshot.js +58 -0
  66. package/lib/src/examples/snapshot.js.map +1 -0
  67. package/lib/src/examples/validation.d.ts +5 -0
  68. package/lib/src/examples/validation.d.ts.map +1 -0
  69. package/lib/src/examples/validation.js +105 -0
  70. package/lib/src/examples/validation.js.map +1 -0
  71. package/lib/src/index.d.ts +27 -0
  72. package/lib/src/index.d.ts.map +1 -0
  73. package/lib/src/index.js +19 -0
  74. package/lib/src/index.js.map +1 -0
  75. package/lib/src/misc/base.d.ts +51 -0
  76. package/lib/src/misc/base.d.ts.map +1 -0
  77. package/lib/src/misc/base.js +1091 -0
  78. package/lib/src/misc/base.js.map +1 -0
  79. package/lib/src/misc/utils/LevelLogger.d.ts +150 -0
  80. package/lib/src/misc/utils/LevelLogger.d.ts.map +1 -0
  81. package/lib/src/misc/utils/LevelLogger.js +420 -0
  82. package/lib/src/misc/utils/LevelLogger.js.map +1 -0
  83. package/lib/src/misc/utils/LevelLogger.test.d.ts +2 -0
  84. package/lib/src/misc/utils/LevelLogger.test.d.ts.map +1 -0
  85. package/lib/src/misc/utils/LevelLogger.test.js +283 -0
  86. package/lib/src/misc/utils/LevelLogger.test.js.map +1 -0
  87. package/lib/src/misc/utils/json.d.ts +34 -0
  88. package/lib/src/misc/utils/json.d.ts.map +1 -0
  89. package/lib/src/misc/utils/json.js +471 -0
  90. package/lib/src/misc/utils/json.js.map +1 -0
  91. package/lib/src/misc/utils/merge.d.ts +51 -0
  92. package/lib/src/misc/utils/merge.d.ts.map +1 -0
  93. package/lib/src/misc/utils/merge.js +591 -0
  94. package/lib/src/misc/utils/merge.js.map +1 -0
  95. package/lib/src/misc/utils/test-logger-output.d.ts +7 -0
  96. package/lib/src/misc/utils/test-logger-output.d.ts.map +1 -0
  97. package/lib/src/misc/utils/test-logger-output.js +48 -0
  98. package/lib/src/misc/utils/test-logger-output.js.map +1 -0
  99. package/lib/src/plugins/composite.d.ts +22 -0
  100. package/lib/src/plugins/composite.d.ts.map +1 -0
  101. package/lib/src/plugins/composite.js +59 -0
  102. package/lib/src/plugins/composite.js.map +1 -0
  103. package/lib/src/plugins/compute.d.ts +5 -0
  104. package/lib/src/plugins/compute.d.ts.map +1 -0
  105. package/lib/src/plugins/compute.js +39 -0
  106. package/lib/src/plugins/compute.js.map +1 -0
  107. package/lib/src/runtime/Engine.d.ts +26 -0
  108. package/lib/src/runtime/Engine.d.ts.map +1 -0
  109. package/lib/src/runtime/Engine.js +2 -0
  110. package/lib/src/runtime/Engine.js.map +1 -0
  111. package/lib/src/runtime/GraphLifecycleApi.d.ts +46 -0
  112. package/lib/src/runtime/GraphLifecycleApi.d.ts.map +1 -0
  113. package/lib/src/runtime/GraphLifecycleApi.js +2 -0
  114. package/lib/src/runtime/GraphLifecycleApi.js.map +1 -0
  115. package/lib/src/runtime/GraphRuntime.d.ts +111 -0
  116. package/lib/src/runtime/GraphRuntime.d.ts.map +1 -0
  117. package/lib/src/runtime/GraphRuntime.js +791 -0
  118. package/lib/src/runtime/GraphRuntime.js.map +1 -0
  119. package/lib/src/runtime/LocalEngine.d.ts +41 -0
  120. package/lib/src/runtime/LocalEngine.d.ts.map +1 -0
  121. package/lib/src/runtime/LocalEngine.js +89 -0
  122. package/lib/src/runtime/LocalEngine.js.map +1 -0
  123. package/lib/src/runtime/components/EdgePropagator.d.ts +93 -0
  124. package/lib/src/runtime/components/EdgePropagator.d.ts.map +1 -0
  125. package/lib/src/runtime/components/EdgePropagator.js +378 -0
  126. package/lib/src/runtime/components/EdgePropagator.js.map +1 -0
  127. package/lib/src/runtime/components/EventEmitter.d.ts +12 -0
  128. package/lib/src/runtime/components/EventEmitter.d.ts.map +1 -0
  129. package/lib/src/runtime/components/EventEmitter.js +33 -0
  130. package/lib/src/runtime/components/EventEmitter.js.map +1 -0
  131. package/lib/src/runtime/components/Graph.d.ts +208 -0
  132. package/lib/src/runtime/components/Graph.d.ts.map +1 -0
  133. package/lib/src/runtime/components/Graph.js +452 -0
  134. package/lib/src/runtime/components/Graph.js.map +1 -0
  135. package/lib/src/runtime/components/HandleResolver.d.ts +36 -0
  136. package/lib/src/runtime/components/HandleResolver.d.ts.map +1 -0
  137. package/lib/src/runtime/components/HandleResolver.js +229 -0
  138. package/lib/src/runtime/components/HandleResolver.js.map +1 -0
  139. package/lib/src/runtime/components/NodeExecutor.d.ts +116 -0
  140. package/lib/src/runtime/components/NodeExecutor.d.ts.map +1 -0
  141. package/lib/src/runtime/components/NodeExecutor.js +648 -0
  142. package/lib/src/runtime/components/NodeExecutor.js.map +1 -0
  143. package/lib/src/runtime/components/RunContextManager.d.ts +90 -0
  144. package/lib/src/runtime/components/RunContextManager.d.ts.map +1 -0
  145. package/lib/src/runtime/components/RunContextManager.js +329 -0
  146. package/lib/src/runtime/components/RunContextManager.js.map +1 -0
  147. package/lib/src/runtime/components/RuntimeValidatorManager.d.ts +31 -0
  148. package/lib/src/runtime/components/RuntimeValidatorManager.d.ts.map +1 -0
  149. package/lib/src/runtime/components/RuntimeValidatorManager.js +56 -0
  150. package/lib/src/runtime/components/RuntimeValidatorManager.js.map +1 -0
  151. package/lib/src/runtime/components/graph-utils.d.ts +33 -0
  152. package/lib/src/runtime/components/graph-utils.d.ts.map +1 -0
  153. package/lib/src/runtime/components/graph-utils.js +300 -0
  154. package/lib/src/runtime/components/graph-utils.js.map +1 -0
  155. package/lib/src/runtime/components/interfaces.d.ts +59 -0
  156. package/lib/src/runtime/components/interfaces.d.ts.map +1 -0
  157. package/lib/src/runtime/components/interfaces.js +2 -0
  158. package/lib/src/runtime/components/interfaces.js.map +1 -0
  159. package/lib/src/runtime/components/types.d.ts +57 -0
  160. package/lib/src/runtime/components/types.d.ts.map +1 -0
  161. package/lib/src/runtime/components/types.js +2 -0
  162. package/lib/src/runtime/components/types.js.map +1 -0
  163. package/lib/src/runtime/utils.d.ts +21 -0
  164. package/lib/src/runtime/utils.d.ts.map +1 -0
  165. package/lib/src/runtime/utils.js +41 -0
  166. package/lib/src/runtime/utils.js.map +1 -0
  167. package/package.json +2 -2
@@ -0,0 +1,300 @@
1
+ import { getInputDeclaredTypes, unwrapTypeId, unwrapValue, mergeInputHandleDescriptors, typed, } from "../../core/type-utils";
2
+ import { isPromise } from "../utils";
3
+ export function tryHandleResolving(def, registry, environment) {
4
+ const out = new Map();
5
+ const pending = new Set();
6
+ for (const n of def.nodes) {
7
+ const desc = registry.nodes.get(n.typeId);
8
+ if (!desc)
9
+ continue;
10
+ const overrideInputs = n.resolvedHandles?.inputs;
11
+ const overrideOutputs = n.resolvedHandles?.outputs;
12
+ const overrideDefaults = n.resolvedHandles?.inputDefaults;
13
+ // Resolve dynamic handles if available (initial pass: inputs may be undefined)
14
+ let dyn = {};
15
+ try {
16
+ if (typeof desc.resolveHandles === "function") {
17
+ const maybe = desc.resolveHandles({
18
+ nodeId: n.nodeId,
19
+ environment: environment || {},
20
+ params: n.params,
21
+ inputs: undefined,
22
+ });
23
+ // Only use sync results here; async results are applied via recompute later
24
+ if (isPromise(maybe)) {
25
+ // mark node as pending async recompute
26
+ pending.add(n.nodeId);
27
+ }
28
+ else {
29
+ dyn = maybe || {};
30
+ }
31
+ }
32
+ }
33
+ catch {
34
+ // ignore dynamic resolution errors at this stage
35
+ }
36
+ // Merge base with dynamic and overrides (allow partial resolvedHandles)
37
+ // Merge inputs properly, handling metadata
38
+ const inputs = {};
39
+ // First, add all static handles
40
+ if (desc.inputs) {
41
+ for (const [handle, staticDesc] of Object.entries(desc.inputs)) {
42
+ inputs[handle] = staticDesc;
43
+ }
44
+ }
45
+ // Then, merge dynamic handles
46
+ if (dyn.inputs) {
47
+ for (const [handle, dynamicDesc] of Object.entries(dyn.inputs)) {
48
+ const staticDesc = desc.inputs?.[handle];
49
+ const merged = mergeInputHandleDescriptors(staticDesc, dynamicDesc);
50
+ if (merged) {
51
+ inputs[handle] = merged;
52
+ }
53
+ }
54
+ }
55
+ // Finally, merge overrides
56
+ if (overrideInputs) {
57
+ for (const [handle, overrideDesc] of Object.entries(overrideInputs)) {
58
+ const existingDesc = inputs[handle];
59
+ const merged = mergeInputHandleDescriptors(existingDesc, overrideDesc);
60
+ if (merged) {
61
+ inputs[handle] = merged;
62
+ }
63
+ }
64
+ }
65
+ const outputs = {
66
+ ...desc.outputs,
67
+ ...dyn.outputs,
68
+ ...overrideOutputs,
69
+ };
70
+ const inputDefaults = {
71
+ ...desc.inputDefaults,
72
+ ...dyn.inputDefaults,
73
+ ...overrideDefaults,
74
+ };
75
+ out.set(n.nodeId, { inputs, outputs, inputDefaults });
76
+ }
77
+ return { resolved: out, pending };
78
+ }
79
+ export function buildEdges(def, registry, graph) {
80
+ return def.edges.map((e) => {
81
+ const srcNode = def.nodes.find((n) => n.nodeId === e.source.nodeId);
82
+ const dstNode = def.nodes.find((n) => n.nodeId === e.target.nodeId);
83
+ const { srcDeclared, dstDeclared } = extractEdgeTypes(e.source.nodeId, e.source.handle, e.target.nodeId, e.target.handle, registry, graph);
84
+ const { convert, convertAsync } = buildEdgeConverters(srcDeclared, dstDeclared, registry, `buildEdges: ${srcNode?.typeId || ""}.${e.source.nodeId}.${e.source.handle} -> ${dstNode?.typeId || ""}.${e.target.nodeId}.${e.target.handle}`);
85
+ return {
86
+ id: e.id,
87
+ source: { ...e.source },
88
+ target: { ...e.target },
89
+ typeId: e.typeId, // Preserve original (may be undefined)
90
+ srcDeclared,
91
+ convert,
92
+ convertAsync,
93
+ srcUnionTypes: Array.isArray(srcDeclared) ? [...srcDeclared] : undefined,
94
+ dstDeclared,
95
+ stats: { runs: 0, inFlight: false, progress: 0 },
96
+ };
97
+ });
98
+ }
99
+ /**
100
+ * Extract edge type information from resolved handles
101
+ * Used by both buildEdges and updateNodeHandles to avoid duplication
102
+ * Now supports union types on both source (output) and destination (input) handles
103
+ */
104
+ export function extractEdgeTypes(sourceNodeId, sourceHandle, targetNodeId, targetHandle, registry, graph) {
105
+ const srcResolved = graph.getResolvedHandles(sourceNodeId);
106
+ const dstResolved = graph.getResolvedHandles(targetNodeId);
107
+ const srcDeclared = srcResolved
108
+ ? srcResolved.outputs[sourceHandle]
109
+ : registry.nodes.get(graph.getNode(sourceNodeId)?.typeId || "")?.outputs[sourceHandle];
110
+ const dstDeclared = getInputDeclaredTypes(dstResolved ? dstResolved.inputs : registry.nodes.get(graph.getNode(targetNodeId)?.typeId || "")?.inputs, targetHandle);
111
+ return {
112
+ srcDeclared,
113
+ dstDeclared,
114
+ };
115
+ }
116
+ // Static helper: build edge converters for type coercion
117
+ // Now supports union types on both source (output) and destination (input) handles
118
+ export function buildEdgeConverters(srcDeclared, dstDeclared, registry, edgeLabel) {
119
+ if (!dstDeclared || !srcDeclared) {
120
+ return {};
121
+ }
122
+ const isSrcUnion = Array.isArray(srcDeclared);
123
+ const srcTypes = isSrcUnion ? srcDeclared : [srcDeclared];
124
+ const isDstUnion = Array.isArray(dstDeclared);
125
+ const dstTypes = isDstUnion ? dstDeclared : [dstDeclared];
126
+ // Helper to compare coercion costs (sync preferred, then fewer steps)
127
+ const compareCost = (a, b) => {
128
+ // Prefer sync over async
129
+ if (a.kind === "sync" && b.kind === "async")
130
+ return -1;
131
+ if (a.kind === "async" && b.kind === "sync")
132
+ return 1;
133
+ // If same kind, prefer fewer edges
134
+ if (a.cost.edges !== b.cost.edges)
135
+ return a.cost.edges - b.cost.edges;
136
+ // If same edges, prefer fewer async steps
137
+ return a.cost.async - b.cost.async;
138
+ };
139
+ // Helper to find the best coercion from a source type to any destination type
140
+ const getCoercion = (srcTypeId) => {
141
+ const candidates = [];
142
+ // Try all destination types and collect valid coercions
143
+ for (const dstTypeId of dstTypes) {
144
+ const coercion = registry.resolveCoercion(srcTypeId, dstTypeId);
145
+ if (coercion) {
146
+ candidates.push({
147
+ dstType: dstTypeId,
148
+ coercion,
149
+ });
150
+ }
151
+ }
152
+ if (candidates.length === 0)
153
+ return null;
154
+ // Select best by cost: sync preferred, then fewer edges, then fewer async steps
155
+ const best = candidates.reduce((best, cur) => {
156
+ return compareCost(cur.coercion, best.coercion) < 0 ? cur : best;
157
+ });
158
+ if (best.coercion.kind === "sync") {
159
+ return {
160
+ kind: "sync",
161
+ convert: best.coercion.convert,
162
+ dstType: best.dstType,
163
+ };
164
+ }
165
+ else {
166
+ return {
167
+ kind: "async",
168
+ convert: (v) => v, // placeholder, not used for async
169
+ convertAsync: best.coercion.convertAsync,
170
+ dstType: best.dstType,
171
+ };
172
+ }
173
+ };
174
+ // Resolve coercions for all source types
175
+ const coercions = srcTypes.map(getCoercion);
176
+ const hasAsync = coercions.some((r) => r?.kind === "async");
177
+ // Helper to extract and validate typed output for unions
178
+ const extractPayload = (v) => {
179
+ const typeId = unwrapTypeId(v);
180
+ const payload = unwrapValue(v);
181
+ if (isSrcUnion) {
182
+ if (!typeId) {
183
+ throw new Error(`Typed output required for union source (${edgeLabel}); allowed: ${srcTypes.join("|")}`);
184
+ }
185
+ if (!srcTypes.includes(typeId)) {
186
+ throw new Error(`Invalid typed output ${typeId} (${edgeLabel}); allowed: ${srcTypes.join("|")}`);
187
+ }
188
+ }
189
+ else if (typeId) {
190
+ // Warn if typed output is used for non-union source
191
+ console.warn(`Typed output ${typeId} is fed even though source is not union (${edgeLabel}): ${srcDeclared} -> ${dstDeclared}`);
192
+ }
193
+ return { typeId: typeId || srcTypes[0], payload };
194
+ };
195
+ const wrapIfDstUnion = (dstType, val) => {
196
+ if (!isDstUnion || !dstType)
197
+ return val;
198
+ return typed(dstType, val);
199
+ };
200
+ if (hasAsync) {
201
+ return {
202
+ convertAsync: async (v, signal) => {
203
+ const { typeId, payload } = extractPayload(v);
204
+ const res = getCoercion(typeId);
205
+ if (!res) {
206
+ const fallbackType = isDstUnion && typeId && dstTypes.includes(typeId) ? typeId : undefined;
207
+ return wrapIfDstUnion(fallbackType, payload);
208
+ }
209
+ if (res.kind === "async" && res.convertAsync) {
210
+ const converted = await res.convertAsync(payload, signal);
211
+ return wrapIfDstUnion(res.dstType, converted);
212
+ }
213
+ return wrapIfDstUnion(res.dstType, res.convert(payload));
214
+ },
215
+ };
216
+ }
217
+ // Sync path
218
+ const firstCoercion = coercions.find((r) => r?.kind === "sync");
219
+ if (!firstCoercion) {
220
+ return {};
221
+ }
222
+ return {
223
+ convert: (v) => {
224
+ const { typeId, payload } = extractPayload(v);
225
+ const res = getCoercion(typeId);
226
+ if (!res) {
227
+ const fallbackType = isDstUnion && typeId && dstTypes.includes(typeId) ? typeId : undefined;
228
+ return wrapIfDstUnion(fallbackType, payload);
229
+ }
230
+ if (res.kind === "async") {
231
+ throw new Error(`Async coercion required but convert used (${edgeLabel})`);
232
+ }
233
+ const converted = res.convert(payload);
234
+ return wrapIfDstUnion(res.dstType, converted);
235
+ },
236
+ };
237
+ }
238
+ /**
239
+ * Compute effective inputs for a node by merging real inputs with defaults.
240
+ * This is a shared utility used by both NodeExecutor and runtime validators.
241
+ *
242
+ * @param nodeId - The node ID to compute effective inputs for
243
+ * @param graph - Graph component to access node and handle information
244
+ * @param registry - Registry to access node type descriptors and defaults
245
+ * @returns Record of effective input values (real inputs merged with defaults)
246
+ */
247
+ export function getEffectiveInputs(nodeId, graph, registry) {
248
+ const node = graph.getNode(nodeId);
249
+ if (!node)
250
+ return {};
251
+ const desc = registry.nodes.get(node.typeId);
252
+ if (!desc)
253
+ return {};
254
+ const resolved = graph.getResolvedHandles(nodeId);
255
+ const regDefaults = desc.inputDefaults ?? {};
256
+ const dynDefaults = resolved?.inputDefaults ?? {};
257
+ // Identify which handles are dynamically resolved (not in registry statics)
258
+ const staticHandles = new Set(Object.keys(desc.inputs ?? {}));
259
+ const dynamicHandles = new Set(Object.keys(resolved?.inputs ?? {}).filter((h) => !staticHandles.has(h)));
260
+ // Precedence: dynamic > registry
261
+ const mergedDefaults = {
262
+ ...regDefaults,
263
+ ...dynDefaults,
264
+ };
265
+ // Start with real inputs only (no defaults)
266
+ const effective = { ...node.inputs };
267
+ // Build set of inbound handles (wired inputs)
268
+ const inboundEdges = graph.getInboundEdges(nodeId);
269
+ const inbound = new Set(inboundEdges.map((e) => e.target.handle));
270
+ const getDefaultPolicy = (handle) => {
271
+ const resolvedDesc = resolved?.inputs?.[handle];
272
+ const staticDesc = desc.inputs?.[handle];
273
+ const pick = (d) => d && typeof d === "object" && "typeId" in d ? d.defaultPolicy : undefined;
274
+ return pick(resolvedDesc) ?? pick(staticDesc);
275
+ };
276
+ // Apply defaults only for:
277
+ // 1. Unbound handles that have no explicit value
278
+ // 2. Static handles (not dynamically resolved)
279
+ for (const [handle, defaultValue] of Object.entries(mergedDefaults)) {
280
+ if (defaultValue === undefined)
281
+ continue;
282
+ if (effective[handle] !== undefined)
283
+ continue; // Already has value
284
+ if (dynamicHandles.has(handle))
285
+ continue; // Skip defaults for dynamic handles
286
+ const policy = getDefaultPolicy(handle);
287
+ if (policy === "bound") {
288
+ if (!inbound.has(handle))
289
+ continue;
290
+ }
291
+ else {
292
+ if (inbound.has(handle))
293
+ continue;
294
+ }
295
+ // Clone to avoid shared references
296
+ effective[handle] = structuredClone(defaultValue);
297
+ }
298
+ return effective;
299
+ }
300
+ //# sourceMappingURL=graph-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-utils.js","sourceRoot":"","sources":["../../../../src/runtime/components/graph-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EACrB,YAAY,EACZ,WAAW,EACX,2BAA2B,EAC3B,KAAK,GACN,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,UAAU,kBAAkB,CAChC,GAAoB,EACpB,QAAkB,EAClB,WAAqC;IAErC,MAAM,GAAG,GAAG,IAAI,GAAG,EAA2B,CAAC;IAC/C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAElC,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI;YAAE,SAAS;QACpB,MAAM,cAAc,GAAG,CAAC,CAAC,eAAe,EAAE,MAAM,CAAC;QACjD,MAAM,eAAe,GAAG,CAAC,CAAC,eAAe,EAAE,OAAO,CAAC;QACnD,MAAM,gBAAgB,GAAG,CAAC,CAAC,eAAe,EAAE,aAAa,CAAC;QAC1D,+EAA+E;QAC/E,IAAI,GAAG,GAA6B,EAAE,CAAC;QACvC,IAAI,CAAC;YACH,IAAI,OAAO,IAAI,CA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{ Graph } from "./Graph";
4
+ import type { Registry } from "../../builder/Registry";
5
+ /**
6
+ * Interface for edge propagation operations
7
+ */
8
+ export interface IEdgePropagator {
9
+ propagate(srcNodeId: string, srcHandle: string, value: unknown, runContextIds?: Set<RunContextId>): void;
10
+ invalidateDownstream(nodeId: string): void;
11
+ }
12
+ /**
13
+ * Interface for node execution operations
14
+ */
15
+ export interface INodeExecutor {
16
+ execute(nodeId: string, opts?: {
17
+ runContextIds?: Set<RunContextId>;
18
+ canSkipHandleResolution?: boolean;
19
+ reason?: string;
20
+ }): void;
21
+ }
22
+ /**
23
+ * Interface for handle resolution operations
24
+ */
25
+ export interface IHandleResolver {
26
+ scheduleRecomputeHandles(nodeId: string): void;
27
+ getPendingResolution(nodeId: string): Promise<void> | null;
28
+ }
29
+ /**
30
+ * Error details returned by a runtime validator when execution should be blocked
31
+ */
32
+ export interface RuntimeValidationError {
33
+ message: string;
34
+ code?: string;
35
+ details?: Record<string, unknown>;
36
+ }
37
+ /**
38
+ * Runtime validator function that checks current runtime state before node execution.
39
+ * Returns false to allow execution, or RuntimeValidationError to block execution with details.
40
+ *
41
+ * @param nodeId - The node about to execute
42
+ * @param graph - Graph component to access all nodes and their current state
43
+ * @param registry - Registry to access node type information
44
+ * @returns false to allow execution, or RuntimeValidationError to block with details
45
+ */
46
+ export type RuntimeValidator = (nodeId: string, graph: Graph, registry: Registry) => false | RuntimeValidationError;
47
+ export interface IRuntimeValidator {
48
+ hasRuntimeValidationBlock(nodeId: string): RuntimeValidationError | null;
49
+ }
50
+ /**
51
+ * Interface for runtime coordination operations
52
+ * Implemented by GraphRuntime to coordinate cross-component operations
53
+ */
54
+ export interface IRuntime extends IRuntimeValidator {
55
+ isPaused(): boolean;
56
+ getRunMode(): RunMode | null;
57
+ setTargetInput(edge: RuntimeEdge, value: unknown, reason: string): void;
58
+ }
59
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","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E,KAAK,EAAE,QAAQ,EAAE,QAAQ,KAAK,KAAK,GAAG,sBAAsB,CAAC;AAEpH,MAAM,WAAW,iBAAiB;IAChC,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,sBAAsB,GAAG,IAAI,CAAC;CAC1E;AAED;;;GAGG;AACH,MAAM,WAAW,QAAS,SAAQ,iBAAiB;IACjD,QAAQ,IAAI,OAAO,CAAC;IACpB,UAAU,IAAI,OAAO,GAAG,IAAI,CAAC;IAC7B,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACzE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/runtime/components/interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,57 @@
1
+ import type { GraphNodeDefinition, GraphEdgeDefinition, ExecutionPolicy, LogLevel } from "@bian-womp/spark-protocol";
2
+ import type { NodeTypeDescriptor, RuntimeEdgeStats, RuntimeNodeStats } from "../../core/types";
3
+ import type { CategoryRuntime } from "../../core/categories";
4
+ export interface RuntimeNode<State = any> extends GraphNodeDefinition {
5
+ inputs: Record<string, unknown>;
6
+ outputs: Record<string, unknown>;
7
+ state: State;
8
+ runtime: CategoryRuntime<State>;
9
+ lifecycle: NodeTypeDescriptor<Record<string, string>, Record<string, string>, State, any>["lifecycle"];
10
+ policy?: Partial<ExecutionPolicy>;
11
+ logLevel?: LogLevel;
12
+ latestRunId?: string;
13
+ runSeq: number;
14
+ activeControllers: Set<AbortController>;
15
+ controllerRunIds: Map<AbortController, string>;
16
+ snapshotCancelledRunIds?: Set<string>;
17
+ queue: ExecutionPlan[];
18
+ stats: RuntimeNodeStats;
19
+ activeRunContextIds: Set<string>;
20
+ lastScheduledAt?: number;
21
+ lastInputAt?: Record<string, number>;
22
+ lastSuccessAt?: number;
23
+ }
24
+ /**
25
+ * Readonly version of RuntimeNode for external access.
26
+ * Prevents accidental modifications from outside Graph class.
27
+ */
28
+ export type ReadonlyRuntimeNode<State = any> = Readonly<Omit<RuntimeNode<State>, "inputs" | "outputs" | "state" | "stats" | "lastInputAt">> & {
29
+ readonly inputs: Readonly<Record<string, unknown>>;
30
+ readonly outputs: Readonly<Record<string, unknown>>;
31
+ readonly state: Readonly<State>;
32
+ readonly stats: Readonly<RuntimeNodeStats>;
33
+ readonly lastInputAt?: Readonly<Record<string, number>>;
34
+ };
35
+ export interface RuntimeEdge extends GraphEdgeDefinition {
36
+ convert?: (value: unknown) => unknown;
37
+ convertAsync?: (value: unknown, signal: AbortSignal) => Promise<unknown>;
38
+ stats: RuntimeEdgeStats;
39
+ srcDeclared?: string | string[];
40
+ srcUnionTypes?: string[];
41
+ dstDeclared?: string | string[];
42
+ }
43
+ export type RunContextId = string;
44
+ /**
45
+ * Execution plan containing all information needed to start a node execution.
46
+ * Captures a snapshot of the node's policy at scheduling time so later
47
+ * mutations to `node.policy` don't affect an in-flight run.
48
+ */
49
+ export interface ExecutionPlan {
50
+ runId: string;
51
+ effectiveInputs: Record<string, unknown>;
52
+ runContextIdsForRun?: Set<RunContextId>;
53
+ timestamp: number;
54
+ policy: RuntimeNode["policy"];
55
+ reason?: string;
56
+ }
57
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/runtime/components/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrH,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,WAAW,WAAW,CAAC,KAAK,GA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":"","sources":["../../../../src/runtime/components/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Shared utility functions for runtime components
3
+ */
4
+ import type { Graph } from "./components/Graph";
5
+ /**
6
+ * Type guard to check if a value is a Promise
7
+ */
8
+ export declare function isPromise<T = unknown>(value: unknown): value is Promise<T>;
9
+ /**
10
+ * Unwrap a value that might be a Promise
11
+ */
12
+ export declare function unwrapMaybePromise<T>(value: T | Promise<T>): Promise<T>;
13
+ /**
14
+ * Shallow/deep-ish equality check to avoid unnecessary runs on identical values
15
+ */
16
+ export declare function valuesEqual(a: unknown, b: unknown): boolean;
17
+ /**
18
+ * Format a node reference as <nodeId>[<typeId>] for logs.
19
+ */
20
+ export declare function formatNodeRef(graph: Graph, nodeId: string): string;
21
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAE1E;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE7E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAW3D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGlE"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Shared utility functions for runtime components
3
+ */
4
+ /**
5
+ * Type guard to check if a value is a Promise
6
+ */
7
+ export function isPromise(value) {
8
+ return !!value && typeof value.then === "function";
9
+ }
10
+ /**
11
+ * Unwrap a value that might be a Promise
12
+ */
13
+ export async function unwrapMaybePromise(value) {
14
+ return isPromise(value) ? await value : value;
15
+ }
16
+ /**
17
+ * Shallow/deep-ish equality check to avoid unnecessary runs on identical values
18
+ */
19
+ export function valuesEqual(a, b) {
20
+ if (a === b)
21
+ return true;
22
+ if (typeof a !== typeof b)
23
+ return false;
24
+ if (a && b && typeof a === "object") {
25
+ try {
26
+ return JSON.stringify(a) === JSON.stringify(b);
27
+ }
28
+ catch {
29
+ return false;
30
+ }
31
+ }
32
+ return false;
33
+ }
34
+ /**
35
+ * Format a node reference as <nodeId>[<typeId>] for logs.
36
+ */
37
+ export function formatNodeRef(graph, nodeId) {
38
+ const node = graph.getNode(nodeId);
39
+ return `${nodeId}<${node?.typeId ?? "unknown"}>`;
40
+ }
41
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/runtime/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,MAAM,UAAU,SAAS,CAAc,KAAc;IACnD,OAAO,CAAC,CAAC,KAAK,IAAI,OAAQ,KAAa,CAAC,IAAI,KAAK,UAAU,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAI,KAAqB;IAC/D,OAAO,SAAS,CAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,CAAU,EAAE,CAAU;IAChD,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,OAAO,CAAC,KAAK,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QACpC,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACjD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAY,EAAE,MAAc;IACxD,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,OAAO,GAAG,MAAM,IAAI,IAAI,EAAE,MAAM,IAAI,SAAS,GAAG,CAAC;AACnD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bian-womp/spark-graph",
3
- "version": "0.3.88",
3
+ "version": "0.3.90",
4
4
  "description": "Spark Graph - Node-based computation graph system",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -37,7 +37,7 @@
37
37
  "node": ">=20.0.0"
38
38
  },
39
39
  "dependencies": {
40
- "@bian-womp/spark-protocol": "^0.3.88"
40
+ "@bian-womp/spark-protocol": "^0.3.90"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@rollup/plugin-commonjs": "^28.0.6",