@bian-womp/spark-graph 0.3.42 → 0.3.44

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/lib/cjs/index.cjs CHANGED
@@ -926,8 +926,10 @@ class Graph {
926
926
  if (inbound.length === 0)
927
927
  return true;
928
928
  for (const e of inbound) {
929
- if (!(e.target.handle in node.inputs))
929
+ if (node.resolvedHandles?.inputs?.[e.target.handle] &&
930
+ !node.inputs[e.target.handle]) {
930
931
  return false;
932
+ }
931
933
  }
932
934
  return true;
933
935
  }
@@ -2428,7 +2430,7 @@ class NodeExecutor {
2428
2430
  return;
2429
2431
  const runMode = this.runtime.getRunMode();
2430
2432
  if (!runMode) {
2431
- console.warn("NodeExecutor.execute: no runMode, skipping execution");
2433
+ console.trace("NodeExecutor.execute: no runMode, skipping execution");
2432
2434
  return;
2433
2435
  }
2434
2436
  // In manual mode, require runContextIds unless autoRun policy is set
@@ -2442,12 +2444,12 @@ class NodeExecutor {
2442
2444
  ]);
2443
2445
  }
2444
2446
  else {
2445
- console.warn("NodeExecutor.execute: no runContextIds provided in manual mode, skipping execution");
2447
+ console.trace("NodeExecutor.execute: no runContextIds provided in manual mode, skipping execution");
2446
2448
  return;
2447
2449
  }
2448
2450
  }
2449
2451
  if (runMode === "auto" && runContextIds && runContextIds.size > 0) {
2450
- console.warn("NodeExecutor.execute: runContextIds provided in auto mode, ignoring");
2452
+ console.trace("NodeExecutor.execute: runContextIds provided in auto mode, ignoring");
2451
2453
  runContextIds = undefined;
2452
2454
  }
2453
2455
  // Early validation for auto-mode paused state
@@ -3133,7 +3135,7 @@ class GraphRuntime {
3133
3135
  if (hasInbound)
3134
3136
  continue;
3135
3137
  // Validate input value against declared type
3136
- if (value !== undefined && registry) {
3138
+ if (registry) {
3137
3139
  const desc = registry.nodes.get(node.typeId);
3138
3140
  const resolved = this.graph.getResolvedHandles(nodeId);
3139
3141
  // Get declared types (may be union); prefer resolved handles over registry statics
@@ -3155,7 +3157,7 @@ class GraphRuntime {
3155
3157
  return true;
3156
3158
  return typeDesc.validate(value);
3157
3159
  });
3158
- if (!isValidForAny) {
3160
+ if (value !== undefined && !isValidForAny) {
3159
3161
  const typeLabel = typeIds.join("|");
3160
3162
  const errorMessage = `Invalid value for input ${nodeId}.${handle} (type ${typeLabel}): ${JSON.stringify(value)}`;
3161
3163
  this.eventEmitter.emit("error", {
@@ -3184,11 +3186,7 @@ class GraphRuntime {
3184
3186
  // However, if autoRun policy is set, nodes run automatically even in manual mode.
3185
3187
  if (anyChanged) {
3186
3188
  this.handleResolver.scheduleRecomputeHandles(nodeId);
3187
- const node = this.graph.getNode(nodeId);
3188
- const shouldAutoRun = this.runMode === "auto" || node?.policy?.autoRun === true;
3189
- if (shouldAutoRun && this.graph.allInboundHaveValue(nodeId)) {
3190
- this.execute(nodeId);
3191
- }
3189
+ this.executeNodeAutoRun(nodeId);
3192
3190
  }
3193
3191
  }
3194
3192
  getOutput(nodeId, output) {
@@ -3403,12 +3401,28 @@ class GraphRuntime {
3403
3401
  }
3404
3402
  }
3405
3403
  }
3404
+ executeNodeAutoRun(nodeId) {
3405
+ const node = this.graph.getNode(nodeId);
3406
+ const shouldAutoRun = this.runMode === "auto" || node?.policy?.autoRun === true;
3407
+ let runContextIdsToUse = undefined;
3408
+ if (this.runMode === "manual") {
3409
+ runContextIdsToUse = new Set([
3410
+ this.runContextManager.createRunContext(nodeId, undefined, {
3411
+ propagate: false,
3412
+ }),
3413
+ ]);
3414
+ }
3415
+ if (shouldAutoRun && this.graph.allInboundHaveValue(nodeId)) {
3416
+ this.execute(nodeId, runContextIdsToUse);
3417
+ }
3418
+ }
3406
3419
  copyOutputs(fromNodeId, toNodeId, options) {
3407
3420
  const fromNode = this.getNodeData(fromNodeId);
3408
3421
  if (!fromNode?.outputs)
3409
3422
  return;
3410
3423
  this.hydrate({ outputs: { [toNodeId]: { ...fromNode.outputs } } }, { invalidate: !options?.dry });
3411
3424
  this.handleResolver.scheduleRecomputeHandles(toNodeId);
3425
+ this.executeNodeAutoRun(toNodeId);
3412
3426
  }
3413
3427
  hydrate(payload, opts) {
3414
3428
  const releasePause = this.requestPause();
@@ -3652,10 +3666,7 @@ class GraphRuntime {
3652
3666
  this.edgePropagator.clearArrayBuckets(nodeId);
3653
3667
  // Trigger handle resolution when inputs are removed
3654
3668
  this.handleResolver.scheduleRecomputeHandles(nodeId);
3655
- if (this.runMode === "auto" &&
3656
- this.graph.allInboundHaveValue(nodeId)) {
3657
- this.execute(nodeId);
3658
- }
3669
+ this.executeNodeAutoRun(nodeId);
3659
3670
  }
3660
3671
  }
3661
3672
  // Propagate changes on edges added