@bian-womp/spark-graph 0.3.43 → 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
@@ -2430,7 +2430,7 @@ class NodeExecutor {
2430
2430
  return;
2431
2431
  const runMode = this.runtime.getRunMode();
2432
2432
  if (!runMode) {
2433
- console.warn("NodeExecutor.execute: no runMode, skipping execution");
2433
+ console.trace("NodeExecutor.execute: no runMode, skipping execution");
2434
2434
  return;
2435
2435
  }
2436
2436
  // In manual mode, require runContextIds unless autoRun policy is set
@@ -2444,12 +2444,12 @@ class NodeExecutor {
2444
2444
  ]);
2445
2445
  }
2446
2446
  else {
2447
- 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");
2448
2448
  return;
2449
2449
  }
2450
2450
  }
2451
2451
  if (runMode === "auto" && runContextIds && runContextIds.size > 0) {
2452
- console.warn("NodeExecutor.execute: runContextIds provided in auto mode, ignoring");
2452
+ console.trace("NodeExecutor.execute: runContextIds provided in auto mode, ignoring");
2453
2453
  runContextIds = undefined;
2454
2454
  }
2455
2455
  // Early validation for auto-mode paused state
@@ -3135,7 +3135,7 @@ class GraphRuntime {
3135
3135
  if (hasInbound)
3136
3136
  continue;
3137
3137
  // Validate input value against declared type
3138
- if (value !== undefined && registry) {
3138
+ if (registry) {
3139
3139
  const desc = registry.nodes.get(node.typeId);
3140
3140
  const resolved = this.graph.getResolvedHandles(nodeId);
3141
3141
  // Get declared types (may be union); prefer resolved handles over registry statics
@@ -3157,7 +3157,7 @@ class GraphRuntime {
3157
3157
  return true;
3158
3158
  return typeDesc.validate(value);
3159
3159
  });
3160
- if (!isValidForAny) {
3160
+ if (value !== undefined && !isValidForAny) {
3161
3161
  const typeLabel = typeIds.join("|");
3162
3162
  const errorMessage = `Invalid value for input ${nodeId}.${handle} (type ${typeLabel}): ${JSON.stringify(value)}`;
3163
3163
  this.eventEmitter.emit("error", {
@@ -3186,11 +3186,7 @@ class GraphRuntime {
3186
3186
  // However, if autoRun policy is set, nodes run automatically even in manual mode.
3187
3187
  if (anyChanged) {
3188
3188
  this.handleResolver.scheduleRecomputeHandles(nodeId);
3189
- const node = this.graph.getNode(nodeId);
3190
- const shouldAutoRun = this.runMode === "auto" || node?.policy?.autoRun === true;
3191
- if (shouldAutoRun && this.graph.allInboundHaveValue(nodeId)) {
3192
- this.execute(nodeId);
3193
- }
3189
+ this.executeNodeAutoRun(nodeId);
3194
3190
  }
3195
3191
  }
3196
3192
  getOutput(nodeId, output) {
@@ -3405,17 +3401,28 @@ class GraphRuntime {
3405
3401
  }
3406
3402
  }
3407
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
+ }
3408
3419
  copyOutputs(fromNodeId, toNodeId, options) {
3409
3420
  const fromNode = this.getNodeData(fromNodeId);
3410
3421
  if (!fromNode?.outputs)
3411
3422
  return;
3412
3423
  this.hydrate({ outputs: { [toNodeId]: { ...fromNode.outputs } } }, { invalidate: !options?.dry });
3413
3424
  this.handleResolver.scheduleRecomputeHandles(toNodeId);
3414
- const node = this.graph.getNode(toNodeId);
3415
- const shouldAutoRun = this.runMode === "auto" || node?.policy?.autoRun === true;
3416
- if (shouldAutoRun && this.graph.allInboundHaveValue(toNodeId)) {
3417
- this.execute(toNodeId);
3418
- }
3425
+ this.executeNodeAutoRun(toNodeId);
3419
3426
  }
3420
3427
  hydrate(payload, opts) {
3421
3428
  const releasePause = this.requestPause();
@@ -3659,11 +3666,7 @@ class GraphRuntime {
3659
3666
  this.edgePropagator.clearArrayBuckets(nodeId);
3660
3667
  // Trigger handle resolution when inputs are removed
3661
3668
  this.handleResolver.scheduleRecomputeHandles(nodeId);
3662
- const node = this.graph.getNode(nodeId);
3663
- const shouldAutoRun = this.runMode === "auto" || node?.policy?.autoRun === true;
3664
- if (shouldAutoRun && this.graph.allInboundHaveValue(nodeId)) {
3665
- this.execute(nodeId);
3666
- }
3669
+ this.executeNodeAutoRun(nodeId);
3667
3670
  }
3668
3671
  }
3669
3672
  // Propagate changes on edges added