@bian-womp/spark-graph 0.2.60 → 0.2.62

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
@@ -494,7 +494,6 @@ class GraphRuntime {
494
494
  queued: 0,
495
495
  progress: 0,
496
496
  },
497
- initialInputs: n.initialInputs ?? {},
498
497
  };
499
498
  gr.nodes.set(n.nodeId, rn);
500
499
  }
@@ -683,6 +682,7 @@ class GraphRuntime {
683
682
  }
684
683
  };
685
684
  return {
685
+ nodeId,
686
686
  state: node.state,
687
687
  setState: (next) => Object.assign(node.state, next),
688
688
  emit: emitHandler,
@@ -877,16 +877,14 @@ class GraphRuntime {
877
877
  const resolved = this.resolvedByNode.get(nodeId);
878
878
  const regDefaults = desc.inputDefaults ?? {};
879
879
  const dynDefaults = resolved?.inputDefaults ?? {};
880
- const graphDefaults = node.initialInputs ?? {};
881
880
  // Identify which handles are dynamically resolved (not in registry statics)
882
881
  // Dynamic handles are metadata-only and should not receive defaults in execution
883
882
  const staticHandles = new Set(Object.keys(desc.inputs ?? {}));
884
883
  const dynamicHandles = new Set(Object.keys(resolved?.inputs ?? {}).filter((h) => !staticHandles.has(h)));
885
- // Precedence: graph > dynamic > registry
884
+ // Precedence: dynamic > registry
886
885
  const mergedDefaults = {
887
886
  ...regDefaults,
888
887
  ...dynDefaults,
889
- ...graphDefaults,
890
888
  };
891
889
  // Start with real inputs only (no defaults)
892
890
  const effective = { ...node.inputs };
@@ -1077,6 +1075,7 @@ class GraphRuntime {
1077
1075
  try {
1078
1076
  if (typeof desc.resolveHandles === "function") {
1079
1077
  const maybe = desc.resolveHandles({
1078
+ nodeId: n.nodeId,
1080
1079
  environment: environment || {},
1081
1080
  params: n.params,
1082
1081
  inputs: undefined,
@@ -1294,20 +1293,10 @@ class GraphRuntime {
1294
1293
  getGraphDef() {
1295
1294
  const nodes = Array.from(this.nodes.values()).map((n) => {
1296
1295
  const resolved = this.resolvedByNode.get(n.nodeId);
1297
- // Collect user-provided inputs (inputs without inbound edges)
1298
- const initialInputs = {};
1299
- for (const [handle, value] of Object.entries(n.inputs)) {
1300
- const hasInbound = this.edges.some((e) => e.target.nodeId === n.nodeId && e.target.handle === handle);
1301
- if (!hasInbound && value !== undefined) {
1302
- // Clone to avoid shared references
1303
- initialInputs[handle] = structuredClone(value);
1304
- }
1305
- }
1306
1296
  return {
1307
1297
  nodeId: n.nodeId,
1308
1298
  typeId: n.typeId,
1309
1299
  params: n.params ? { ...n.params } : undefined,
1310
- initialInputs: Object.keys(initialInputs).length > 0 ? initialInputs : undefined,
1311
1300
  resolvedHandles: resolved ? { ...resolved } : undefined,
1312
1301
  };
1313
1302
  });
@@ -1344,6 +1333,9 @@ class GraphRuntime {
1344
1333
  pause() {
1345
1334
  this.paused = true;
1346
1335
  }
1336
+ isPaused() {
1337
+ return this.paused;
1338
+ }
1347
1339
  resume() {
1348
1340
  this.paused = false;
1349
1341
  }
@@ -1461,7 +1453,6 @@ class GraphRuntime {
1461
1453
  queued: 0,
1462
1454
  progress: 0,
1463
1455
  },
1464
- initialInputs: n.initialInputs ?? {},
1465
1456
  };
1466
1457
  this.nodes.set(n.nodeId, rn);
1467
1458
  // Activate new node
@@ -1476,9 +1467,8 @@ class GraphRuntime {
1476
1467
  rn.runtime.onActivated?.();
1477
1468
  }
1478
1469
  else {
1479
- // update params/policy and initialInputs
1470
+ // update params/policy
1480
1471
  existing.params = n.params;
1481
- existing.initialInputs = n.initialInputs ?? {};
1482
1472
  if (!existing.stats) {
1483
1473
  existing.stats = {
1484
1474
  runs: 0,
@@ -1670,6 +1660,7 @@ class GraphRuntime {
1670
1660
  let r;
1671
1661
  try {
1672
1662
  const res = resolveHandles({
1663
+ nodeId,
1673
1664
  environment: this.environment || {},
1674
1665
  params: node.params,
1675
1666
  inputs: node.inputs || {},
@@ -3389,8 +3380,6 @@ function makeBasicGraphDefinition() {
3389
3380
  {
3390
3381
  nodeId: "n2",
3391
3382
  typeId: "base.math",
3392
- // Graph-level defaults override registry if provided
3393
- initialInputs: { Operation: 2, B: [10] }, // Multiply by 10
3394
3383
  },
3395
3384
  // Transitivity demo nodes
3396
3385
  { nodeId: "n3", typeId: "base.compare" },
@@ -3759,26 +3748,6 @@ function mergeGraphDefinitions(target, source, converter) {
3759
3748
  };
3760
3749
  if (converter) {
3761
3750
  const nodeTypeId = transformedNode.typeId;
3762
- if (transformedNode.initialInputs) {
3763
- const transformedInitialInputs = {};
3764
- for (const [handleId, value] of Object.entries(transformedNode.initialInputs)) {
3765
- const handleDataType = transformedNode.resolvedHandles?.inputs?.[handleId]
3766
- ? typeof transformedNode.resolvedHandles.inputs[handleId] ===
3767
- "string"
3768
- ? transformedNode.resolvedHandles.inputs[handleId]
3769
- : transformedNode.resolvedHandles.inputs[handleId]?.typeId
3770
- : undefined;
3771
- transformedInitialInputs[handleId] = converter({
3772
- nodeId: newId,
3773
- handleId,
3774
- value,
3775
- type: "initialInput",
3776
- nodeTypeId,
3777
- handleDataType,
3778
- });
3779
- }
3780
- transformedNode.initialInputs = transformedInitialInputs;
3781
- }
3782
3751
  if (transformedNode.resolvedHandles?.inputDefaults) {
3783
3752
  const transformedInputDefaults = {};
3784
3753
  for (const [handleId, value] of Object.entries(transformedNode.resolvedHandles.inputDefaults)) {