@bian-womp/spark-graph 0.3.72 → 0.3.74
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 +184 -115
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/runtime/GraphRuntime.d.ts +7 -6
- package/lib/cjs/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/cjs/src/runtime/components/EdgePropagator.d.ts +2 -7
- package/lib/cjs/src/runtime/components/EdgePropagator.d.ts.map +1 -1
- package/lib/cjs/src/runtime/components/NodeExecutor.d.ts.map +1 -1
- package/lib/cjs/src/runtime/components/RunContextManager.d.ts +6 -0
- package/lib/cjs/src/runtime/components/RunContextManager.d.ts.map +1 -1
- package/lib/cjs/src/runtime/components/interfaces.d.ts +2 -1
- package/lib/cjs/src/runtime/components/interfaces.d.ts.map +1 -1
- package/lib/esm/index.js +184 -115
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/runtime/GraphRuntime.d.ts +7 -6
- package/lib/esm/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/esm/src/runtime/components/EdgePropagator.d.ts +2 -7
- package/lib/esm/src/runtime/components/EdgePropagator.d.ts.map +1 -1
- package/lib/esm/src/runtime/components/NodeExecutor.d.ts.map +1 -1
- package/lib/esm/src/runtime/components/RunContextManager.d.ts +6 -0
- package/lib/esm/src/runtime/components/RunContextManager.d.ts.map +1 -1
- package/lib/esm/src/runtime/components/interfaces.d.ts +2 -1
- package/lib/esm/src/runtime/components/interfaces.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@ import type { RuntimeValue, RuntimeInvalidate, RuntimeError, RuntimeStats, Graph
|
|
|
2
2
|
import type { RuntimeNodeStats } from "../core/types";
|
|
3
3
|
import { Registry } from "../builder/Registry";
|
|
4
4
|
import type { INodeExecutor, IRuntime, IEdgePropagator, RuntimeValidator, RuntimeValidationError } from "./components/interfaces";
|
|
5
|
-
import type { RunContextId } from "./components/types";
|
|
5
|
+
import type { RunContextId, RuntimeEdge } from "./components/types";
|
|
6
6
|
export type RuntimeEventListener<K extends RuntimeEventName> = (e: RuntimeEventMap[K]) => void;
|
|
7
7
|
export type RuntimeEventName = "value" | "invalidate" | "error" | "stats";
|
|
8
8
|
export interface RuntimeEventMap {
|
|
@@ -31,14 +31,15 @@ export declare class GraphRuntime implements IRuntime, INodeExecutor, IEdgePropa
|
|
|
31
31
|
startPaused?: boolean;
|
|
32
32
|
}): GraphRuntime;
|
|
33
33
|
on<K extends RuntimeEventName>(event: K, handler: RuntimeEventListener<K>): () => void;
|
|
34
|
-
setInputs(nodeId: string, inputs: Record<string, unknown>): void;
|
|
35
|
-
getOutput(nodeId: string, output: string): unknown;
|
|
36
|
-
launch(invalidate?: boolean, startPaused?: boolean): void;
|
|
37
|
-
triggerExternal(nodeId: string, event: unknown): void;
|
|
38
34
|
/**
|
|
39
35
|
* Check if an event is an invalidate event that should trigger re-execution
|
|
40
36
|
*/
|
|
41
37
|
private isInvalidateEvent;
|
|
38
|
+
private executeNodeAutoRun;
|
|
39
|
+
setInputs(nodeId: string, inputs: Record<string, unknown>): void;
|
|
40
|
+
getOutput(nodeId: string, output: string): unknown;
|
|
41
|
+
launch(invalidate?: boolean, startPaused?: boolean): void;
|
|
42
|
+
triggerExternal(nodeId: string, event: unknown): void;
|
|
42
43
|
cancelNodeRuns(nodeIds: string[]): void;
|
|
43
44
|
getNodeIds(): string[];
|
|
44
45
|
getNodeData(nodeId: string): {
|
|
@@ -79,7 +80,7 @@ export declare class GraphRuntime implements IRuntime, INodeExecutor, IEdgePropa
|
|
|
79
80
|
isPaused(): boolean;
|
|
80
81
|
pause(): void;
|
|
81
82
|
resume(): void;
|
|
82
|
-
|
|
83
|
+
setTargetInput(edge: RuntimeEdge, value: unknown, reason: string): void;
|
|
83
84
|
copyOutputs(fromNodeId: string, toNodeId: string, options?: {
|
|
84
85
|
dry?: boolean;
|
|
85
86
|
}): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphRuntime.d.ts","sourceRoot":"","sources":["../../../../src/runtime/GraphRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,YAAY,EAEZ,eAAe,EAGf,OAAO,EACR,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAS/C,OAAO,KAAK,EACV,aAAa,EACb,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"GraphRuntime.d.ts","sourceRoot":"","sources":["../../../../src/runtime/GraphRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,YAAY,EAEZ,eAAe,EAGf,OAAO,EACR,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAS/C,OAAO,KAAK,EACV,aAAa,EACb,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAe,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjF,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,gBAAgB,IAAI,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAE/F,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,YAAY,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1E,MAAM,WAAW,eAAe;I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,aAAa,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,IAAI;IAIxG,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAG3C"}
|
|
@@ -2,7 +2,7 @@ import type { RunContextId } from "./types";
|
|
|
2
2
|
import type { Graph } from "./Graph";
|
|
3
3
|
import type { EventEmitter } from "./EventEmitter";
|
|
4
4
|
import type { RunContextManager } from "./RunContextManager";
|
|
5
|
-
import { INodeExecutor,
|
|
5
|
+
import { INodeExecutor, IEdgePropagator, IRuntime } from "./interfaces";
|
|
6
6
|
/**
|
|
7
7
|
* EdgePropagator component - handles value propagation through edges
|
|
8
8
|
*/
|
|
@@ -10,11 +10,10 @@ export declare class EdgePropagator implements IEdgePropagator {
|
|
|
10
10
|
private readonly graph;
|
|
11
11
|
private readonly eventEmitter;
|
|
12
12
|
private readonly runContextManager;
|
|
13
|
-
private readonly handleResolver;
|
|
14
13
|
private readonly nodeExecutor;
|
|
15
14
|
private readonly runtime;
|
|
16
15
|
private arrayInputBuckets;
|
|
17
|
-
constructor(graph: Graph, eventEmitter: EventEmitter, runContextManager: RunContextManager,
|
|
16
|
+
constructor(graph: Graph, eventEmitter: EventEmitter, runContextManager: RunContextManager, nodeExecutor: INodeExecutor, runtime: IRuntime);
|
|
18
17
|
/**
|
|
19
18
|
* Set source output value and emit event
|
|
20
19
|
*/
|
|
@@ -55,10 +54,6 @@ export declare class EdgePropagator implements IEdgePropagator {
|
|
|
55
54
|
* Check if input value should be set (respecting skipPropagateValues)
|
|
56
55
|
*/
|
|
57
56
|
private shouldSetInputValue;
|
|
58
|
-
/**
|
|
59
|
-
* Set target input value and emit event
|
|
60
|
-
*/
|
|
61
|
-
private setTargetInput;
|
|
62
57
|
/**
|
|
63
58
|
* Execute downstream if conditions are met
|
|
64
59
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EdgePropagator.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/components/EdgePropagator.ts"],"names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;IACH,OAAO,CAAC,oBAAoB;IAU5B;;OAEG;IACH,OAAO,CAAC,YAAY;IAQpB;;OAEG;IACH,OAAO,CAAC,6BAA6B;IAmCrC;;OAEG;IACH,OAAO,CAAC,WAAW;IAoEnB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAqExB;;OAEG;IACH,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,cAAc,GAAG,gBAAgB,GAAG,IAAI;IAsClG;;;OAGG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,MAAM,GAAE,UAAU,GAAG,gBAAmC,GAAG,IAAI;CAwClG"}
|
|
@@ -5,6 +5,7 @@ export interface RunContext {
|
|
|
5
5
|
id: RunContextId;
|
|
6
6
|
startNodes: Set<string>;
|
|
7
7
|
cancelledNodes: Set<string>;
|
|
8
|
+
pendingScheduling: number;
|
|
8
9
|
pendingNodes: number;
|
|
9
10
|
pendingEdges: number;
|
|
10
11
|
pendingResolvers: number;
|
|
@@ -46,6 +47,11 @@ export declare class RunContextManager {
|
|
|
46
47
|
* Check if there are any active run-contexts
|
|
47
48
|
*/
|
|
48
49
|
hasActiveRunContexts(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Release one scheduling hold from a run-context.
|
|
52
|
+
* Must be called once by the creator when scheduling decisions are complete.
|
|
53
|
+
*/
|
|
54
|
+
releaseScheduling(id: RunContextId): void;
|
|
49
55
|
/**
|
|
50
56
|
* Increment queued work count for a run-context.
|
|
51
57
|
* Used by asyncConcurrency: "queue" to keep contexts alive while work is queued.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RunContextManager.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/components/RunContextManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGrC,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,YAAY,CAAC;IACjB,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACxB,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,iBAAiB;IAM1B,OAAO,CAAC,QAAQ,CAAC,KAAK;IALxB,OAAO,CAAC,WAAW,CAAuC;IAC1D,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAGlB,KAAK,EAAE,KAAK,EAC7B,QAAQ,CAAC,EAAE,QAAQ;IAMrB;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAIrC;;OAEG;IACH,gBAAgB,CACd,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;QACrB,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAC9B,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,GACA,YAAY;
|
|
1
|
+
{"version":3,"file":"RunContextManager.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/components/RunContextManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGrC,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,YAAY,CAAC;I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H,eAAe,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAkBvD,YAAY,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAiBpD,aAAa,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAkBrD,mBAAmB,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAiB3D,oBAAoB,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAkB5D,qBAAqB,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAiB7D,sBAAsB,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAkB9D;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAiClC;;;;;;OAMG;IACH,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,GAAG,IAAI;IA0CzE;;OAEG;IACH,UAAU,IAAI,IAAI;IAWlB;;OAEG;IACH,KAAK,IAAI,IAAI;CAKd"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RunMode } from "@bian-womp/spark-protocol";
|
|
2
|
-
import type { RunContextId } from "./types";
|
|
2
|
+
import type { RunContextId, RuntimeEdge } from "./types";
|
|
3
3
|
import type { Graph } from "./Graph";
|
|
4
4
|
import type { Registry } from "../../builder/Registry";
|
|
5
5
|
/**
|
|
@@ -54,5 +54,6 @@ export interface IRuntimeValidator {
|
|
|
54
54
|
export interface IRuntime extends IRuntimeValidator {
|
|
55
55
|
isPaused(): boolean;
|
|
56
56
|
getRunMode(): RunMode | null;
|
|
57
|
+
setTargetInput(edge: RuntimeEdge, value: unknown, reason: string): void;
|
|
57
58
|
}
|
|
58
59
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/components/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/components/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;IACzG,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,CACL,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE;QACL,aAAa,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;QAClC,uBAAuB,CAAC,EAAE,OAAO,CAAC;QAClC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GACA,IAAI,CAAC;CACT;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/C,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC5D;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,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"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1682,6 +1682,7 @@ class RunContextManager {
|
|
|
1682
1682
|
id,
|
|
1683
1683
|
startNodes: new Set([startNodeId]),
|
|
1684
1684
|
cancelledNodes: new Set(),
|
|
1685
|
+
pendingScheduling: 1,
|
|
1685
1686
|
pendingNodes: 0,
|
|
1686
1687
|
pendingEdges: 0,
|
|
1687
1688
|
pendingResolvers: 0,
|
|
@@ -1717,6 +1718,33 @@ class RunContextManager {
|
|
|
1717
1718
|
hasActiveRunContexts() {
|
|
1718
1719
|
return this.runContexts.size > 0;
|
|
1719
1720
|
}
|
|
1721
|
+
/**
|
|
1722
|
+
* Release one scheduling hold from a run-context.
|
|
1723
|
+
* Must be called once by the creator when scheduling decisions are complete.
|
|
1724
|
+
*/
|
|
1725
|
+
releaseScheduling(id) {
|
|
1726
|
+
const ctx = this.runContexts.get(id);
|
|
1727
|
+
if (!ctx) {
|
|
1728
|
+
this.logger.debug("release-scheduling-context-not-found", {
|
|
1729
|
+
runContextId: id,
|
|
1730
|
+
});
|
|
1731
|
+
return;
|
|
1732
|
+
}
|
|
1733
|
+
if (ctx.pendingScheduling > 0) {
|
|
1734
|
+
ctx.pendingScheduling--;
|
|
1735
|
+
}
|
|
1736
|
+
else {
|
|
1737
|
+
this.logger.warn("release-scheduling-underflow", {
|
|
1738
|
+
runContextId: id,
|
|
1739
|
+
pendingScheduling: ctx.pendingScheduling,
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1742
|
+
this.logger.debug("release-scheduling", {
|
|
1743
|
+
runContextId: id,
|
|
1744
|
+
pendingScheduling: ctx.pendingScheduling,
|
|
1745
|
+
});
|
|
1746
|
+
this.finishRunContextIfPossible(id);
|
|
1747
|
+
}
|
|
1720
1748
|
/**
|
|
1721
1749
|
* Increment queued work count for a run-context.
|
|
1722
1750
|
* Used by asyncConcurrency: "queue" to keep contexts alive while work is queued.
|
|
@@ -1868,7 +1896,11 @@ class RunContextManager {
|
|
|
1868
1896
|
});
|
|
1869
1897
|
return;
|
|
1870
1898
|
}
|
|
1871
|
-
if (ctx.
|
|
1899
|
+
if (ctx.pendingScheduling > 0 ||
|
|
1900
|
+
ctx.pendingNodes > 0 ||
|
|
1901
|
+
ctx.pendingEdges > 0 ||
|
|
1902
|
+
ctx.pendingResolvers > 0 ||
|
|
1903
|
+
ctx.pendingQueued > 0) {
|
|
1872
1904
|
return; // Still has pending work
|
|
1873
1905
|
}
|
|
1874
1906
|
this.logger.info("finish-run-context", {
|
|
@@ -2521,11 +2553,10 @@ class HandleResolver {
|
|
|
2521
2553
|
* EdgePropagator component - handles value propagation through edges
|
|
2522
2554
|
*/
|
|
2523
2555
|
class EdgePropagator {
|
|
2524
|
-
constructor(graph, eventEmitter, runContextManager,
|
|
2556
|
+
constructor(graph, eventEmitter, runContextManager, nodeExecutor, runtime) {
|
|
2525
2557
|
this.graph = graph;
|
|
2526
2558
|
this.eventEmitter = eventEmitter;
|
|
2527
2559
|
this.runContextManager = runContextManager;
|
|
2528
|
-
this.handleResolver = handleResolver;
|
|
2529
2560
|
this.nodeExecutor = nodeExecutor;
|
|
2530
2561
|
this.runtime = runtime;
|
|
2531
2562
|
this.arrayInputBuckets = new Map();
|
|
@@ -2714,7 +2745,7 @@ class EdgePropagator {
|
|
|
2714
2745
|
// Set input value (respecting skipPropagateValues)
|
|
2715
2746
|
const shouldSetValue = this.shouldSetInputValue(effectiveRunContexts);
|
|
2716
2747
|
if (shouldSetValue && valueChanged) {
|
|
2717
|
-
this.setTargetInput(edge, processedValue);
|
|
2748
|
+
this.runtime.setTargetInput(edge, processedValue, "applyToTarget");
|
|
2718
2749
|
}
|
|
2719
2750
|
else if (shouldSetValue && !valueChanged) {
|
|
2720
2751
|
// Even if value didn't change, update timestamp if we're forcing execution
|
|
@@ -2770,13 +2801,6 @@ class EdgePropagator {
|
|
|
2770
2801
|
}
|
|
2771
2802
|
return true;
|
|
2772
2803
|
}
|
|
2773
|
-
/**
|
|
2774
|
-
* Set target input value and emit event
|
|
2775
|
-
*/
|
|
2776
|
-
setTargetInput(edge, value) {
|
|
2777
|
-
this.graph.updateNodeInput(edge.target.nodeId, edge.target.handle, value);
|
|
2778
|
-
this.handleResolver.scheduleRecomputeHandles(edge.target.nodeId);
|
|
2779
|
-
}
|
|
2780
2804
|
/**
|
|
2781
2805
|
* Execute downstream if conditions are met
|
|
2782
2806
|
*/
|
|
@@ -2986,13 +3010,22 @@ class NodeExecutor {
|
|
|
2986
3010
|
execute: (opts) => {
|
|
2987
3011
|
if (this.graph.allInboundHaveValue(nodeId)) {
|
|
2988
3012
|
let runContextIdsToUse = this.runtime.getRunMode() === "auto" ? undefined : runContextIds;
|
|
3013
|
+
let runContextIdToRelease;
|
|
2989
3014
|
if (this.runtime.getRunMode() === "manual" && (!runContextIds || runContextIds.size === 0)) {
|
|
2990
|
-
|
|
3015
|
+
runContextIdToRelease = this.runContextManager.createRunContext(nodeId, opts);
|
|
3016
|
+
runContextIdsToUse = new Set([runContextIdToRelease]);
|
|
3017
|
+
}
|
|
3018
|
+
try {
|
|
3019
|
+
this.execute(nodeId, {
|
|
3020
|
+
runContextIds: runContextIdsToUse,
|
|
3021
|
+
reason: opts?.reason ?? "executeFromContext",
|
|
3022
|
+
});
|
|
3023
|
+
}
|
|
3024
|
+
finally {
|
|
3025
|
+
if (runContextIdToRelease) {
|
|
3026
|
+
this.runContextManager.releaseScheduling(runContextIdToRelease);
|
|
3027
|
+
}
|
|
2991
3028
|
}
|
|
2992
|
-
this.execute(nodeId, {
|
|
2993
|
-
runContextIds: runContextIdsToUse,
|
|
2994
|
-
reason: opts?.reason ?? "executeFromContext",
|
|
2995
|
-
});
|
|
2996
3029
|
}
|
|
2997
3030
|
},
|
|
2998
3031
|
getInput: (handle) => inputs[handle],
|
|
@@ -3018,6 +3051,7 @@ class NodeExecutor {
|
|
|
3018
3051
|
*/
|
|
3019
3052
|
execute(nodeId, opts) {
|
|
3020
3053
|
let { runContextIds, canSkipHandleResolution, reason = "" } = opts ?? {};
|
|
3054
|
+
let autoCreatedRunContextId;
|
|
3021
3055
|
const node = this.graph.getNode(nodeId);
|
|
3022
3056
|
if (!node)
|
|
3023
3057
|
return;
|
|
@@ -3030,81 +3064,89 @@ class NodeExecutor {
|
|
|
3030
3064
|
if (runMode === "manual" && (!runContextIds || runContextIds.size === 0)) {
|
|
3031
3065
|
// If autoRun is true, auto-generate a run context (similar to createExecutionContext pattern)
|
|
3032
3066
|
if (node.policy?.autoRun === true) {
|
|
3033
|
-
|
|
3067
|
+
autoCreatedRunContextId = this.runContextManager.createRunContext(nodeId, { propagate: false });
|
|
3068
|
+
runContextIds = new Set([autoCreatedRunContextId]);
|
|
3034
3069
|
}
|
|
3035
3070
|
else {
|
|
3036
3071
|
console.trace(`NodeExecutor.execute[${formatNodeRef(this.graph, nodeId)}:${reason}]: no runContextIds provided in manual mode, skipping execution`);
|
|
3037
3072
|
return;
|
|
3038
3073
|
}
|
|
3039
3074
|
}
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
// Early validation for auto-mode paused state
|
|
3045
|
-
if (this.runtime.isPaused())
|
|
3046
|
-
return;
|
|
3047
|
-
// Check runtime validators (check current state, not just graph definition)
|
|
3048
|
-
const runtimeValidationError = this.runtime.hasRuntimeValidationBlock(nodeId);
|
|
3049
|
-
if (runtimeValidationError) {
|
|
3050
|
-
this.eventEmitter.emit("error", {
|
|
3051
|
-
kind: "system",
|
|
3052
|
-
message: runtimeValidationError.message,
|
|
3053
|
-
code: runtimeValidationError.code || "RUNTIME_VALIDATION_BLOCKED",
|
|
3054
|
-
details: {
|
|
3055
|
-
nodeId,
|
|
3056
|
-
nodeTypeId: node?.typeId,
|
|
3057
|
-
...runtimeValidationError.details,
|
|
3058
|
-
},
|
|
3059
|
-
});
|
|
3060
|
-
return;
|
|
3061
|
-
}
|
|
3062
|
-
// Attach run-context IDs if provided - do this BEFORE checking for pending resolution
|
|
3063
|
-
// so that handle resolution can track these run contexts
|
|
3064
|
-
if (runContextIds) {
|
|
3065
|
-
this.graph.addNodeRunContextIds(nodeId, runContextIds);
|
|
3066
|
-
}
|
|
3067
|
-
if (!canSkipHandleResolution && !this.handleResolver.getPendingResolution(nodeId)) {
|
|
3068
|
-
this.handleResolver.scheduleRecomputeHandles(nodeId);
|
|
3069
|
-
}
|
|
3070
|
-
// Check if handles are being resolved - wait for resolution before executing
|
|
3071
|
-
// Do this AFTER setting up run contexts so handle resolution can track them
|
|
3072
|
-
const pendingResolution = this.handleResolver.getPendingResolution(nodeId);
|
|
3073
|
-
if (pendingResolution) {
|
|
3074
|
-
if (runContextIds && runContextIds.size > 0) {
|
|
3075
|
-
for (const id of runContextIds) {
|
|
3076
|
-
this.runContextManager.startHandleResolution(id, nodeId);
|
|
3077
|
-
}
|
|
3075
|
+
try {
|
|
3076
|
+
if (runMode === "auto" && runContextIds && runContextIds.size > 0) {
|
|
3077
|
+
console.trace(`NodeExecutor.execute[${formatNodeRef(this.graph, nodeId)}:${reason}]: runContextIds provided in auto mode, ignoring`);
|
|
3078
|
+
runContextIds = undefined;
|
|
3078
3079
|
}
|
|
3079
|
-
//
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3080
|
+
// Early validation for auto-mode paused state
|
|
3081
|
+
if (this.runtime.isPaused())
|
|
3082
|
+
return;
|
|
3083
|
+
// Check runtime validators (check current state, not just graph definition)
|
|
3084
|
+
const runtimeValidationError = this.runtime.hasRuntimeValidationBlock(nodeId);
|
|
3085
|
+
if (runtimeValidationError) {
|
|
3086
|
+
this.eventEmitter.emit("error", {
|
|
3087
|
+
kind: "system",
|
|
3088
|
+
message: runtimeValidationError.message,
|
|
3089
|
+
code: runtimeValidationError.code || "RUNTIME_VALIDATION_BLOCKED",
|
|
3090
|
+
details: {
|
|
3091
|
+
nodeId,
|
|
3092
|
+
nodeTypeId: node?.typeId,
|
|
3093
|
+
...runtimeValidationError.details,
|
|
3094
|
+
},
|
|
3095
|
+
});
|
|
3096
|
+
return;
|
|
3097
|
+
}
|
|
3098
|
+
// Attach run-context IDs if provided - do this BEFORE checking for pending resolution
|
|
3099
|
+
// so that handle resolution can track these run contexts
|
|
3100
|
+
if (runContextIds) {
|
|
3101
|
+
this.graph.addNodeRunContextIds(nodeId, runContextIds);
|
|
3102
|
+
}
|
|
3103
|
+
if (!canSkipHandleResolution && !this.handleResolver.getPendingResolution(nodeId)) {
|
|
3104
|
+
this.handleResolver.scheduleRecomputeHandles(nodeId);
|
|
3105
|
+
}
|
|
3106
|
+
// Check if handles are being resolved - wait for resolution before executing
|
|
3107
|
+
// Do this AFTER setting up run contexts so handle resolution can track them
|
|
3108
|
+
const pendingResolution = this.handleResolver.getPendingResolution(nodeId);
|
|
3109
|
+
if (pendingResolution) {
|
|
3090
3110
|
if (runContextIds && runContextIds.size > 0) {
|
|
3091
3111
|
for (const id of runContextIds) {
|
|
3092
|
-
this.runContextManager.
|
|
3112
|
+
this.runContextManager.startHandleResolution(id, nodeId);
|
|
3093
3113
|
}
|
|
3094
3114
|
}
|
|
3095
|
-
|
|
3096
|
-
|
|
3115
|
+
// Wait for resolution to complete, then re-execute
|
|
3116
|
+
pendingResolution.then(() => {
|
|
3117
|
+
// Re-check node still exists and conditions
|
|
3118
|
+
const nodeAfter = this.graph.getNode(nodeId);
|
|
3119
|
+
if (nodeAfter) {
|
|
3120
|
+
this.execute(nodeId, {
|
|
3121
|
+
runContextIds,
|
|
3122
|
+
canSkipHandleResolution: true,
|
|
3123
|
+
reason: opts?.reason,
|
|
3124
|
+
});
|
|
3125
|
+
}
|
|
3126
|
+
if (runContextIds && runContextIds.size > 0) {
|
|
3127
|
+
for (const id of runContextIds) {
|
|
3128
|
+
this.runContextManager.finishHandleResolution(id, nodeId);
|
|
3129
|
+
}
|
|
3130
|
+
}
|
|
3131
|
+
});
|
|
3132
|
+
return;
|
|
3133
|
+
}
|
|
3134
|
+
// Handle debouncing
|
|
3135
|
+
const now = Date.now();
|
|
3136
|
+
if (this.shouldDebounce(nodeId, now)) {
|
|
3137
|
+
this.handleDebouncedSchedule(nodeId, now, runContextIds, reason);
|
|
3138
|
+
return;
|
|
3139
|
+
}
|
|
3140
|
+
// Prepare execution plan
|
|
3141
|
+
const executionPlan = this.prepareExecutionPlan(nodeId, runContextIds, now, reason);
|
|
3142
|
+
// Route to appropriate concurrency handler
|
|
3143
|
+
this.routeToConcurrencyHandler(nodeId, executionPlan);
|
|
3097
3144
|
}
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
return;
|
|
3145
|
+
finally {
|
|
3146
|
+
if (autoCreatedRunContextId) {
|
|
3147
|
+
this.runContextManager.releaseScheduling(autoCreatedRunContextId);
|
|
3148
|
+
}
|
|
3103
3149
|
}
|
|
3104
|
-
// Prepare execution plan
|
|
3105
|
-
const executionPlan = this.prepareExecutionPlan(nodeId, runContextIds, now, reason);
|
|
3106
|
-
// Route to appropriate concurrency handler
|
|
3107
|
-
this.routeToConcurrencyHandler(nodeId, executionPlan);
|
|
3108
3150
|
}
|
|
3109
3151
|
/**
|
|
3110
3152
|
* Check if execution should be debounced
|
|
@@ -3620,7 +3662,7 @@ class GraphRuntime {
|
|
|
3620
3662
|
this.graph = new Graph(this.eventEmitter);
|
|
3621
3663
|
this.runContextManager = new RunContextManager(this.graph, "warn");
|
|
3622
3664
|
this.handleResolver = new HandleResolver(this.graph, this.eventEmitter, this.runContextManager, this);
|
|
3623
|
-
this.edgePropagator = new EdgePropagator(this.graph, this.eventEmitter, this.runContextManager, this
|
|
3665
|
+
this.edgePropagator = new EdgePropagator(this.graph, this.eventEmitter, this.runContextManager, this, this);
|
|
3624
3666
|
// Create NodeExecutor with EdgePropagator and HandleResolver
|
|
3625
3667
|
this.nodeExecutor = new NodeExecutor(this.graph, this.eventEmitter, this.runContextManager, this.handleResolver, this, this);
|
|
3626
3668
|
// Create RuntimeValidatorManager
|
|
@@ -3709,6 +3751,40 @@ class GraphRuntime {
|
|
|
3709
3751
|
on(event, handler) {
|
|
3710
3752
|
return this.eventEmitter.on(event, handler);
|
|
3711
3753
|
}
|
|
3754
|
+
/**
|
|
3755
|
+
* Check if an event is an invalidate event that should trigger re-execution
|
|
3756
|
+
*/
|
|
3757
|
+
isInvalidateEvent(event) {
|
|
3758
|
+
if (!event || typeof event !== "object")
|
|
3759
|
+
return false;
|
|
3760
|
+
// Check if event has action === "invalidate"
|
|
3761
|
+
const e = event;
|
|
3762
|
+
return e.action === "invalidate";
|
|
3763
|
+
}
|
|
3764
|
+
executeNodeAutoRun(nodeId, opts) {
|
|
3765
|
+
const node = this.graph.getNode(nodeId);
|
|
3766
|
+
const shouldAutoRun = this.runMode === "auto" || node?.policy?.autoRun === true;
|
|
3767
|
+
const canExecute = this.graph.allInboundHaveValue(nodeId);
|
|
3768
|
+
if (!shouldAutoRun || !canExecute)
|
|
3769
|
+
return;
|
|
3770
|
+
let runContextIdsToUse = undefined;
|
|
3771
|
+
let runContextIdToRelease;
|
|
3772
|
+
if (this.runMode === "manual") {
|
|
3773
|
+
runContextIdToRelease = this.runContextManager.createRunContext(nodeId, { propagate: false });
|
|
3774
|
+
runContextIdsToUse = new Set([runContextIdToRelease]);
|
|
3775
|
+
}
|
|
3776
|
+
try {
|
|
3777
|
+
this.execute(nodeId, {
|
|
3778
|
+
runContextIds: runContextIdsToUse,
|
|
3779
|
+
reason: opts?.reason ?? "executeNodeAutoRun",
|
|
3780
|
+
});
|
|
3781
|
+
}
|
|
3782
|
+
finally {
|
|
3783
|
+
if (runContextIdToRelease) {
|
|
3784
|
+
this.runContextManager.releaseScheduling(runContextIdToRelease);
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
}
|
|
3712
3788
|
setInputs(nodeId, inputs) {
|
|
3713
3789
|
const node = this.graph.getNode(nodeId);
|
|
3714
3790
|
if (!node)
|
|
@@ -3764,8 +3840,6 @@ class GraphRuntime {
|
|
|
3764
3840
|
const same = valuesEqual(prev, value);
|
|
3765
3841
|
if (!same) {
|
|
3766
3842
|
this.graph.updateNodeInput(nodeId, handle, value);
|
|
3767
|
-
// Emit value event for input updates
|
|
3768
|
-
this.eventEmitter.emit("value", { nodeId, handle, value, io: "input" });
|
|
3769
3843
|
anyChanged = true;
|
|
3770
3844
|
}
|
|
3771
3845
|
}
|
|
@@ -3794,8 +3868,9 @@ class GraphRuntime {
|
|
|
3794
3868
|
});
|
|
3795
3869
|
if (this.runMode === "auto" && invalidate) {
|
|
3796
3870
|
for (const nodeId of this.graph.getNodeIds()) {
|
|
3797
|
-
if (this.graph.allInboundHaveValue(nodeId))
|
|
3871
|
+
if (this.graph.allInboundHaveValue(nodeId)) {
|
|
3798
3872
|
this.execute(nodeId, { reason: "launch" });
|
|
3873
|
+
}
|
|
3799
3874
|
}
|
|
3800
3875
|
}
|
|
3801
3876
|
if (startPaused) {
|
|
@@ -3817,16 +3892,6 @@ class GraphRuntime {
|
|
|
3817
3892
|
// Forward event to node's onExternalEvent handler for custom actions
|
|
3818
3893
|
node.runtime.onExternalEvent?.(event, node.state);
|
|
3819
3894
|
}
|
|
3820
|
-
/**
|
|
3821
|
-
* Check if an event is an invalidate event that should trigger re-execution
|
|
3822
|
-
*/
|
|
3823
|
-
isInvalidateEvent(event) {
|
|
3824
|
-
if (!event || typeof event !== "object")
|
|
3825
|
-
return false;
|
|
3826
|
-
// Check if event has action === "invalidate"
|
|
3827
|
-
const e = event;
|
|
3828
|
-
return e.action === "invalidate";
|
|
3829
|
-
}
|
|
3830
3895
|
cancelNodeRuns(nodeIds) {
|
|
3831
3896
|
this.nodeExecutor.cancelNodeRuns(nodeIds);
|
|
3832
3897
|
}
|
|
@@ -3854,6 +3919,7 @@ class GraphRuntime {
|
|
|
3854
3919
|
this.nodeExecutor.setEnvironment(this.environment);
|
|
3855
3920
|
for (const nodeId of this.graph.getNodeIds()) {
|
|
3856
3921
|
this.handleResolver.scheduleRecomputeHandles(nodeId);
|
|
3922
|
+
this.executeNodeAutoRun(nodeId, { reason: "setEnvironment" });
|
|
3857
3923
|
}
|
|
3858
3924
|
}
|
|
3859
3925
|
setCustomNodeData(customNodeData) {
|
|
@@ -3951,10 +4017,15 @@ class GraphRuntime {
|
|
|
3951
4017
|
...opts,
|
|
3952
4018
|
});
|
|
3953
4019
|
this.graph.addNodeRunContextId(startNodeId, id);
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
4020
|
+
try {
|
|
4021
|
+
this.execute(startNodeId, {
|
|
4022
|
+
runContextIds: new Set([id]),
|
|
4023
|
+
reason: opts?.reason ?? "runFromHereContext",
|
|
4024
|
+
});
|
|
4025
|
+
}
|
|
4026
|
+
finally {
|
|
4027
|
+
this.runContextManager.releaseScheduling(id);
|
|
4028
|
+
}
|
|
3958
4029
|
});
|
|
3959
4030
|
}
|
|
3960
4031
|
setRunMode(runMode) {
|
|
@@ -4001,19 +4072,10 @@ class GraphRuntime {
|
|
|
4001
4072
|
}
|
|
4002
4073
|
}
|
|
4003
4074
|
}
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
if (this.runMode === "manual") {
|
|
4009
|
-
runContextIdsToUse = new Set([this.runContextManager.createRunContext(nodeId, { propagate: false })]);
|
|
4010
|
-
}
|
|
4011
|
-
if (shouldAutoRun && this.graph.allInboundHaveValue(nodeId)) {
|
|
4012
|
-
this.execute(nodeId, {
|
|
4013
|
-
runContextIds: runContextIdsToUse,
|
|
4014
|
-
reason: opts?.reason ?? "executeNodeAutoRun",
|
|
4015
|
-
});
|
|
4016
|
-
}
|
|
4075
|
+
setTargetInput(edge, value, reason) {
|
|
4076
|
+
this.graph.updateNodeInput(edge.target.nodeId, edge.target.handle, value);
|
|
4077
|
+
this.handleResolver.scheduleRecomputeHandles(edge.target.nodeId);
|
|
4078
|
+
this.executeNodeAutoRun(edge.target.nodeId, { reason });
|
|
4017
4079
|
}
|
|
4018
4080
|
copyOutputs(fromNodeId, toNodeId, options) {
|
|
4019
4081
|
const fromNode = this.getNodeData(fromNodeId);
|
|
@@ -4284,14 +4346,21 @@ class GraphRuntime {
|
|
|
4284
4346
|
const val = this.getOutput(nodeId, handle);
|
|
4285
4347
|
if (val !== undefined) {
|
|
4286
4348
|
let runContextIdsToUse = undefined;
|
|
4349
|
+
let runContextIdToRelease;
|
|
4287
4350
|
if (this.runMode === "manual") {
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4351
|
+
runContextIdToRelease = this.runContextManager.createRunContext(nodeId, {
|
|
4352
|
+
propagate: false,
|
|
4353
|
+
});
|
|
4354
|
+
runContextIdsToUse = new Set([runContextIdToRelease]);
|
|
4355
|
+
}
|
|
4356
|
+
try {
|
|
4357
|
+
this.propagate(nodeId, handle, val, runContextIdsToUse);
|
|
4358
|
+
}
|
|
4359
|
+
finally {
|
|
4360
|
+
if (runContextIdToRelease) {
|
|
4361
|
+
this.runContextManager.releaseScheduling(runContextIdToRelease);
|
|
4362
|
+
}
|
|
4293
4363
|
}
|
|
4294
|
-
this.propagate(nodeId, handle, val, runContextIdsToUse);
|
|
4295
4364
|
}
|
|
4296
4365
|
}
|
|
4297
4366
|
}
|