@bian-womp/spark-graph 0.3.32 → 0.3.34
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 +152 -42
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/index.d.ts +3 -0
- package/lib/cjs/src/index.d.ts.map +1 -1
- package/lib/cjs/src/runtime/GraphRuntime.d.ts +17 -2
- package/lib/cjs/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/cjs/src/runtime/components/NodeExecutor.d.ts +1 -1
- package/lib/cjs/src/runtime/components/NodeExecutor.d.ts.map +1 -1
- package/lib/cjs/src/runtime/components/RuntimeValidatorManager.d.ts +31 -0
- package/lib/cjs/src/runtime/components/RuntimeValidatorManager.d.ts.map +1 -0
- package/lib/cjs/src/runtime/components/graph-utils.d.ts +11 -0
- package/lib/cjs/src/runtime/components/graph-utils.d.ts.map +1 -1
- package/lib/cjs/src/runtime/components/interfaces.d.ts +25 -2
- package/lib/cjs/src/runtime/components/interfaces.d.ts.map +1 -1
- package/lib/esm/index.js +151 -43
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/index.d.ts +3 -0
- package/lib/esm/src/index.d.ts.map +1 -1
- package/lib/esm/src/runtime/GraphRuntime.d.ts +17 -2
- package/lib/esm/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/esm/src/runtime/components/NodeExecutor.d.ts +1 -1
- package/lib/esm/src/runtime/components/NodeExecutor.d.ts.map +1 -1
- package/lib/esm/src/runtime/components/RuntimeValidatorManager.d.ts +31 -0
- package/lib/esm/src/runtime/components/RuntimeValidatorManager.d.ts.map +1 -0
- package/lib/esm/src/runtime/components/graph-utils.d.ts +11 -0
- package/lib/esm/src/runtime/components/graph-utils.d.ts.map +1 -1
- package/lib/esm/src/runtime/components/interfaces.d.ts +25 -2
- package/lib/esm/src/runtime/components/interfaces.d.ts.map +1 -1
- package/package.json +2 -2
package/lib/cjs/src/index.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export type { ValidationIssue, ValidationReport } from "./builder/GraphBuilder";
|
|
|
7
7
|
export { GraphRuntime } from "./runtime/GraphRuntime";
|
|
8
8
|
export type { RuntimeEventName, RuntimeEventMap } from "./runtime/GraphRuntime";
|
|
9
9
|
export type { RuntimeNode, RuntimeEdge } from "./runtime/components/types";
|
|
10
|
+
export type { RuntimeValidator, RuntimeValidationError } from "./runtime/components/interfaces";
|
|
11
|
+
export { Graph } from "./runtime/components/Graph";
|
|
12
|
+
export { getEffectiveInputs } from "./runtime/components/graph-utils";
|
|
10
13
|
export type { Engine, EngineEventListener, EngineEventMap, EngineEventName, } from "./runtime/Engine";
|
|
11
14
|
export { LocalEngine } from "./runtime/LocalEngine";
|
|
12
15
|
export type { GraphLifecycleApi } from "./runtime/GraphLifecycleApi";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,EACL,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,eAAe,EACf,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,YAAY,EAAE,gBAAgB,EAAE,e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,EACxB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,6BAA6B,EAC7B,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,cAAc,GACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,aAAa,EACb,cAAc,EACd,cAAc,EACd,0BAA0B,EAC1B,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RuntimeValue, RuntimeInvalidate, RuntimeError, RuntimeStats, GraphDefinition, RunMode } from "@bian-womp/spark-protocol";
|
|
2
2
|
import type { RuntimeNodeStats } from "../core/types";
|
|
3
3
|
import { Registry } from "../builder/Registry";
|
|
4
|
-
import type { INodeExecutor, IRuntime, IEdgePropagator } from "./components/interfaces";
|
|
4
|
+
import type { INodeExecutor, IRuntime, IEdgePropagator, RuntimeValidator, RuntimeValidationError } from "./components/interfaces";
|
|
5
5
|
import type { RunContextId } from "./components/types";
|
|
6
6
|
export type RuntimeEventListener<K extends RuntimeEventName> = (e: RuntimeEventMap[K]) => void;
|
|
7
7
|
export type RuntimeEventName = "value" | "invalidate" | "error" | "stats";
|
|
@@ -18,6 +18,7 @@ export declare class GraphRuntime implements IRuntime, INodeExecutor, IEdgePropa
|
|
|
18
18
|
private handleResolver;
|
|
19
19
|
private edgePropagator;
|
|
20
20
|
private nodeExecutor;
|
|
21
|
+
private runtimeValidatorManager;
|
|
21
22
|
private environment;
|
|
22
23
|
private runMode;
|
|
23
24
|
private pauseRefCount;
|
|
@@ -48,6 +49,20 @@ export declare class GraphRuntime implements IRuntime, INodeExecutor, IEdgePropa
|
|
|
48
49
|
} | undefined;
|
|
49
50
|
getEnvironment(): Record<string, unknown>;
|
|
50
51
|
setEnvironment(env: Record<string, unknown>): void;
|
|
52
|
+
/**
|
|
53
|
+
* Register a runtime validator that will be called before node execution.
|
|
54
|
+
* Validators are called in registration order - if any returns true, execution is blocked.
|
|
55
|
+
*/
|
|
56
|
+
registerRuntimeValidator(validator: RuntimeValidator): void;
|
|
57
|
+
/**
|
|
58
|
+
* Unregister a runtime validator.
|
|
59
|
+
*/
|
|
60
|
+
unregisterRuntimeValidator(validator: RuntimeValidator): void;
|
|
61
|
+
/**
|
|
62
|
+
* Check if any runtime validator blocks execution for this node.
|
|
63
|
+
* Returns RuntimeValidationError if execution should be blocked, null otherwise.
|
|
64
|
+
*/
|
|
65
|
+
hasRuntimeValidationBlock(nodeId: string): RuntimeValidationError | null;
|
|
51
66
|
getGraphDef(): GraphDefinition;
|
|
52
67
|
whenIdle(): Promise<void>;
|
|
53
68
|
runFromHereContext(startNodeId: string, options?: {
|
|
@@ -71,7 +86,7 @@ export declare class GraphRuntime implements IRuntime, INodeExecutor, IEdgePropa
|
|
|
71
86
|
}): void;
|
|
72
87
|
update(def: GraphDefinition, registry: Registry): void;
|
|
73
88
|
dispose(): void;
|
|
74
|
-
execute(nodeId: string, runContextIds?: Set<RunContextId
|
|
89
|
+
execute(nodeId: string, runContextIds?: Set<RunContextId>, resolveHandles?: boolean): void;
|
|
75
90
|
propagate(srcNodeId: string, srcHandle: string, value: unknown, runContextIds?: Set<RunContextId>): void;
|
|
76
91
|
invalidateDownstream(nodeId: string): void;
|
|
77
92
|
}
|
|
@@ -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;
|
|
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;AAQ/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;AAGpE,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,gBAAgB,IAAI,CAC7D,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,KAClB,IAAI,CAAC;AAEV,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,YAAY,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1E,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,YAAY,CAAC;IACpB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,EAAE,YAAY,CAAC;CACrB;AAGD,qBAAa,YAAa,YAAW,QAAQ,EAAE,aAAa,EAAE,eAAe;IAE3E,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,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,OAAO,CAAC,CAAC,CAAC;QACjD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;KACnD,EACD,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GAC9B,IAAI;IA0DP,MAAM,CAAC,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IA4QtD,OAAO,IAAI,IAAI;IAcf,OAAO,CACL,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,EACjC,cAAc,CAAC,EAAE,OAAO,GACvB,IAAI;IAIP,SAAS,CACP,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,OAAO,EACd,aAAa,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,GAChC,IAAI;IAIP,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAG3C"}
|
|
@@ -31,7 +31,7 @@ export declare class NodeExecutor implements INodeExecutor {
|
|
|
31
31
|
/**
|
|
32
32
|
* Internal method for executing inputs changed (also used by GraphRuntime)
|
|
33
33
|
*/
|
|
34
|
-
execute(nodeId: string, runContextIds?: Set<RunContextId
|
|
34
|
+
execute(nodeId: string, runContextIds?: Set<RunContextId>, canSkipHandleResolution?: boolean): void;
|
|
35
35
|
/**
|
|
36
36
|
* Check if execution should be debounced
|
|
37
37
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeExecutor.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/components/NodeExecutor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAe,MAAM,SAAS,CAAC;AACtE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACr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,6BAA6B;IAyCrC;;OAEG;IACH,OAAO,CAAC,WAAW;IAuEnB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA6ExB;;OAEG;IACH,oBAAoB,CAClB,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,UAAU,GAAG,cAAc,GAAG,gBAAgB,GACrD,IAAI;IAiCP;;;OAGG;IACH,cAAc,CACZ,OAAO,EAAE,MAAM,EAAE,EACjB,MAAM,GAAE,UAAU,GAAG,gBAAmC,GACvD,IAAI;CA8CR"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Graph } from "./Graph";
|
|
2
|
+
import type { Registry } from "../../builder/Registry";
|
|
3
|
+
import type { RuntimeValidator, RuntimeValidationError } from "./interfaces";
|
|
4
|
+
/**
|
|
5
|
+
* RuntimeValidatorManager component - manages runtime validators
|
|
6
|
+
*/
|
|
7
|
+
export declare class RuntimeValidatorManager {
|
|
8
|
+
private readonly graph;
|
|
9
|
+
private registry?;
|
|
10
|
+
private validators;
|
|
11
|
+
constructor(graph: Graph, registry?: Registry | undefined);
|
|
12
|
+
/**
|
|
13
|
+
* Set the registry (called when registry changes)
|
|
14
|
+
*/
|
|
15
|
+
setRegistry(registry: Registry): void;
|
|
16
|
+
/**
|
|
17
|
+
* Register a runtime validator that will be called before node execution.
|
|
18
|
+
* Validators are called in registration order - if any returns true, execution is blocked.
|
|
19
|
+
*/
|
|
20
|
+
registerValidator(validator: RuntimeValidator): void;
|
|
21
|
+
/**
|
|
22
|
+
* Unregister a runtime validator.
|
|
23
|
+
*/
|
|
24
|
+
unregisterValidator(validator: RuntimeValidator): void;
|
|
25
|
+
/**
|
|
26
|
+
* Check if any runtime validator blocks execution for this node.
|
|
27
|
+
* Returns RuntimeValidationError if execution should be blocked, null otherwise.
|
|
28
|
+
*/
|
|
29
|
+
hasBlock(nodeId: string): RuntimeValidationError | null;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=RuntimeValidatorManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RuntimeValidatorManager.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/components/RuntimeValidatorManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE7E;;GAEG;AACH,qBAAa,uBAAuB;IAGtB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAS,OAAO,CAAC,QAAQ,CAAC;IAF5D,OAAO,CAAC,UAAU,CAA0B;gBAEf,KAAK,EAAE,KAAK,EAAU,QAAQ,CAAC,EAAE,QAAQ,YAAA;IAEtE;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAIrC;;;OAGG;IACH,iBAAiB,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI;IAIpD;;OAEG;IACH,mBAAmB,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI;IAOtD;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,sBAAsB,GAAG,IAAI;CAiBxD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { GraphDefinition, ResolvedHandles } from "@bian-womp/spark-protocol";
|
|
2
2
|
import { Registry } from "../../builder/Registry";
|
|
3
3
|
import type { RuntimeEdge } from "./types";
|
|
4
|
+
import type { Graph } from "./Graph";
|
|
4
5
|
export declare function tryHandleResolving(def: GraphDefinition, registry: Registry, environment?: Record<string, unknown>): {
|
|
5
6
|
resolved: Map<string, ResolvedHandles>;
|
|
6
7
|
pending: Set<string>;
|
|
@@ -19,4 +20,14 @@ export declare function buildEdgeConverters(srcDeclared: string | string[] | und
|
|
|
19
20
|
convert?: (v: unknown) => unknown;
|
|
20
21
|
convertAsync?: (v: unknown, signal: AbortSignal) => Promise<unknown>;
|
|
21
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Compute effective inputs for a node by merging real inputs with defaults.
|
|
25
|
+
* This is a shared utility used by both NodeExecutor and runtime validators.
|
|
26
|
+
*
|
|
27
|
+
* @param nodeId - The node ID to compute effective inputs for
|
|
28
|
+
* @param graph - Graph component to access node and handle information
|
|
29
|
+
* @param registry - Registry to access node type descriptors and defaults
|
|
30
|
+
* @returns Record of effective input values (real inputs merged with defaults)
|
|
31
|
+
*/
|
|
32
|
+
export declare function getEffectiveInputs(nodeId: string, graph: Graph, registry: Registry): Record<string, unknown>;
|
|
22
33
|
//# sourceMappingURL=graph-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-utils.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/components/graph-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EAEhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAyB,MAAM,wBAAwB,CAAC;AAQzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"graph-utils.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/components/graph-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EAEhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAyB,MAAM,wBAAwB,CAAC;AAQzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGrC,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,eAAe,EACpB,QAAQ,EAAE,QAAQ,EAClB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACpC;IAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,CA4ElE;AAED,wBAAgB,UAAU,CACxB,GAAG,EAAE,eAAe,EACpB,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GAC3C,WAAW,EAAE,CAkCf;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GAC3C;IACD,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IAC3C,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;CAC5C,CAeA;AAID,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EAC1C,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EAC1C,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,GAChB;IACD,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;IAClC,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACtE,CAgKA;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA4CzB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { RunMode } from "@bian-womp/spark-protocol";
|
|
2
2
|
import type { RunContextId } from "./types";
|
|
3
|
+
import type { Graph } from "./Graph";
|
|
4
|
+
import type { Registry } from "../../builder/Registry";
|
|
3
5
|
/**
|
|
4
6
|
* Interface for edge propagation operations
|
|
5
7
|
*/
|
|
@@ -11,7 +13,7 @@ export interface IEdgePropagator {
|
|
|
11
13
|
* Interface for node execution operations
|
|
12
14
|
*/
|
|
13
15
|
export interface INodeExecutor {
|
|
14
|
-
execute(nodeId: string, runContextIds?: Set<RunContextId
|
|
16
|
+
execute(nodeId: string, runContextIds?: Set<RunContextId>, resolveHandles?: boolean): void;
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* Interface for handle resolution operations
|
|
@@ -20,11 +22,32 @@ export interface IHandleResolver {
|
|
|
20
22
|
scheduleRecomputeHandles(nodeId: string): void;
|
|
21
23
|
getPendingResolution(nodeId: string): Promise<void> | null;
|
|
22
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Error details returned by a runtime validator when execution should be blocked
|
|
27
|
+
*/
|
|
28
|
+
export interface RuntimeValidationError {
|
|
29
|
+
message: string;
|
|
30
|
+
code?: string;
|
|
31
|
+
details?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Runtime validator function that checks current runtime state before node execution.
|
|
35
|
+
* Returns false to allow execution, or RuntimeValidationError to block execution with details.
|
|
36
|
+
*
|
|
37
|
+
* @param nodeId - The node about to execute
|
|
38
|
+
* @param graph - Graph component to access all nodes and their current state
|
|
39
|
+
* @param registry - Registry to access node type information
|
|
40
|
+
* @returns false to allow execution, or RuntimeValidationError to block with details
|
|
41
|
+
*/
|
|
42
|
+
export type RuntimeValidator = (nodeId: string, graph: Graph, registry: Registry) => false | RuntimeValidationError;
|
|
43
|
+
export interface IRuntimeValidator {
|
|
44
|
+
hasRuntimeValidationBlock(nodeId: string): RuntimeValidationError | null;
|
|
45
|
+
}
|
|
23
46
|
/**
|
|
24
47
|
* Interface for runtime coordination operations
|
|
25
48
|
* Implemented by GraphRuntime to coordinate cross-component operations
|
|
26
49
|
*/
|
|
27
|
-
export interface IRuntime {
|
|
50
|
+
export interface IRuntime extends IRuntimeValidator {
|
|
28
51
|
isPaused(): boolean;
|
|
29
52
|
getRunMode(): RunMode | null;
|
|
30
53
|
}
|
|
@@ -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,MAAM,SAAS,CAAC;AAC5C,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,CACP,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,OAAO,EACd,aAAa,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,GAChC,IAAI,CAAC;IACR,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,EAAE,cAAc,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC5F;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,CAC7B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,KACf,KAAK,GAAG,sBAAsB,CAAC;AAEpC,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;CAC9B"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1615,6 +1615,55 @@ function buildEdgeConverters(srcDeclared, dstDeclared, registry, edgeLabel) {
|
|
|
1615
1615
|
},
|
|
1616
1616
|
};
|
|
1617
1617
|
}
|
|
1618
|
+
/**
|
|
1619
|
+
* Compute effective inputs for a node by merging real inputs with defaults.
|
|
1620
|
+
* This is a shared utility used by both NodeExecutor and runtime validators.
|
|
1621
|
+
*
|
|
1622
|
+
* @param nodeId - The node ID to compute effective inputs for
|
|
1623
|
+
* @param graph - Graph component to access node and handle information
|
|
1624
|
+
* @param registry - Registry to access node type descriptors and defaults
|
|
1625
|
+
* @returns Record of effective input values (real inputs merged with defaults)
|
|
1626
|
+
*/
|
|
1627
|
+
function getEffectiveInputs(nodeId, graph, registry) {
|
|
1628
|
+
const node = graph.getNode(nodeId);
|
|
1629
|
+
if (!node)
|
|
1630
|
+
return {};
|
|
1631
|
+
const desc = registry.nodes.get(node.typeId);
|
|
1632
|
+
if (!desc)
|
|
1633
|
+
return {};
|
|
1634
|
+
const resolved = graph.getResolvedHandles(nodeId);
|
|
1635
|
+
const regDefaults = desc.inputDefaults ?? {};
|
|
1636
|
+
const dynDefaults = resolved?.inputDefaults ?? {};
|
|
1637
|
+
// Identify which handles are dynamically resolved (not in registry statics)
|
|
1638
|
+
const staticHandles = new Set(Object.keys(desc.inputs ?? {}));
|
|
1639
|
+
const dynamicHandles = new Set(Object.keys(resolved?.inputs ?? {}).filter((h) => !staticHandles.has(h)));
|
|
1640
|
+
// Precedence: dynamic > registry
|
|
1641
|
+
const mergedDefaults = {
|
|
1642
|
+
...regDefaults,
|
|
1643
|
+
...dynDefaults,
|
|
1644
|
+
};
|
|
1645
|
+
// Start with real inputs only (no defaults)
|
|
1646
|
+
const effective = { ...node.inputs };
|
|
1647
|
+
// Build set of inbound handles (wired inputs)
|
|
1648
|
+
const inboundEdges = graph.getInboundEdges(nodeId);
|
|
1649
|
+
const inbound = new Set(inboundEdges.map((e) => e.target.handle));
|
|
1650
|
+
// Apply defaults only for:
|
|
1651
|
+
// 1. Unbound handles that have no explicit value
|
|
1652
|
+
// 2. Static handles (not dynamically resolved)
|
|
1653
|
+
for (const [handle, defaultValue] of Object.entries(mergedDefaults)) {
|
|
1654
|
+
if (defaultValue === undefined)
|
|
1655
|
+
continue;
|
|
1656
|
+
if (inbound.has(handle))
|
|
1657
|
+
continue; // Don't override wired inputs
|
|
1658
|
+
if (effective[handle] !== undefined)
|
|
1659
|
+
continue; // Already has value
|
|
1660
|
+
if (dynamicHandles.has(handle))
|
|
1661
|
+
continue; // Skip defaults for dynamic handles
|
|
1662
|
+
// Clone to avoid shared references
|
|
1663
|
+
effective[handle] = structuredClone(defaultValue);
|
|
1664
|
+
}
|
|
1665
|
+
return effective;
|
|
1666
|
+
}
|
|
1618
1667
|
|
|
1619
1668
|
/**
|
|
1620
1669
|
* HandleResolver component - manages dynamic handle resolution
|
|
@@ -2251,47 +2300,10 @@ class NodeExecutor {
|
|
|
2251
2300
|
* Compute effective inputs for a node by merging real inputs with defaults
|
|
2252
2301
|
*/
|
|
2253
2302
|
getEffectiveInputs(nodeId) {
|
|
2254
|
-
const node = this.graph.getNode(nodeId);
|
|
2255
|
-
if (!node)
|
|
2256
|
-
return {};
|
|
2257
2303
|
const registry = this.graph.getRegistry();
|
|
2258
2304
|
if (!registry)
|
|
2259
2305
|
return {};
|
|
2260
|
-
|
|
2261
|
-
if (!desc)
|
|
2262
|
-
return {};
|
|
2263
|
-
const resolved = this.graph.getResolvedHandles(nodeId);
|
|
2264
|
-
const regDefaults = desc.inputDefaults ?? {};
|
|
2265
|
-
const dynDefaults = resolved?.inputDefaults ?? {};
|
|
2266
|
-
// Identify which handles are dynamically resolved (not in registry statics)
|
|
2267
|
-
const staticHandles = new Set(Object.keys(desc.inputs ?? {}));
|
|
2268
|
-
const dynamicHandles = new Set(Object.keys(resolved?.inputs ?? {}).filter((h) => !staticHandles.has(h)));
|
|
2269
|
-
// Precedence: dynamic > registry
|
|
2270
|
-
const mergedDefaults = {
|
|
2271
|
-
...regDefaults,
|
|
2272
|
-
...dynDefaults,
|
|
2273
|
-
};
|
|
2274
|
-
// Start with real inputs only (no defaults)
|
|
2275
|
-
const effective = { ...node.inputs };
|
|
2276
|
-
// Build set of inbound handles (wired inputs)
|
|
2277
|
-
const inboundEdges = this.graph.getInboundEdges(nodeId);
|
|
2278
|
-
const inbound = new Set(inboundEdges.map((e) => e.target.handle));
|
|
2279
|
-
// Apply defaults only for:
|
|
2280
|
-
// 1. Unbound handles that have no explicit value
|
|
2281
|
-
// 2. Static handles (not dynamically resolved)
|
|
2282
|
-
for (const [handle, defaultValue] of Object.entries(mergedDefaults)) {
|
|
2283
|
-
if (defaultValue === undefined)
|
|
2284
|
-
continue;
|
|
2285
|
-
if (inbound.has(handle))
|
|
2286
|
-
continue; // Don't override wired inputs
|
|
2287
|
-
if (effective[handle] !== undefined)
|
|
2288
|
-
continue; // Already has value
|
|
2289
|
-
if (dynamicHandles.has(handle))
|
|
2290
|
-
continue; // Skip defaults for dynamic handles
|
|
2291
|
-
// Clone to avoid shared references
|
|
2292
|
-
effective[handle] = structuredClone(defaultValue);
|
|
2293
|
-
}
|
|
2294
|
-
return effective;
|
|
2306
|
+
return getEffectiveInputs(nodeId, this.graph, registry);
|
|
2295
2307
|
}
|
|
2296
2308
|
/**
|
|
2297
2309
|
* Create an execution context for a node
|
|
@@ -2366,7 +2378,7 @@ class NodeExecutor {
|
|
|
2366
2378
|
/**
|
|
2367
2379
|
* Internal method for executing inputs changed (also used by GraphRuntime)
|
|
2368
2380
|
*/
|
|
2369
|
-
execute(nodeId, runContextIds) {
|
|
2381
|
+
execute(nodeId, runContextIds, canSkipHandleResolution) {
|
|
2370
2382
|
const node = this.graph.getNode(nodeId);
|
|
2371
2383
|
if (!node)
|
|
2372
2384
|
return;
|
|
@@ -2397,11 +2409,29 @@ class NodeExecutor {
|
|
|
2397
2409
|
// Early validation for auto-mode paused state
|
|
2398
2410
|
if (this.runtime.isPaused())
|
|
2399
2411
|
return;
|
|
2412
|
+
// Check runtime validators (check current state, not just graph definition)
|
|
2413
|
+
const runtimeValidationError = this.runtime.hasRuntimeValidationBlock(nodeId);
|
|
2414
|
+
if (runtimeValidationError) {
|
|
2415
|
+
this.eventEmitter.emit("error", {
|
|
2416
|
+
kind: "system",
|
|
2417
|
+
message: runtimeValidationError.message,
|
|
2418
|
+
code: runtimeValidationError.code || "RUNTIME_VALIDATION_BLOCKED",
|
|
2419
|
+
details: {
|
|
2420
|
+
nodeId,
|
|
2421
|
+
...runtimeValidationError.details,
|
|
2422
|
+
},
|
|
2423
|
+
});
|
|
2424
|
+
return;
|
|
2425
|
+
}
|
|
2400
2426
|
// Attach run-context IDs if provided - do this BEFORE checking for pending resolution
|
|
2401
2427
|
// so that handle resolution can track these run contexts
|
|
2402
2428
|
if (runContextIds) {
|
|
2403
2429
|
this.graph.addNodeRunContextIds(nodeId, runContextIds);
|
|
2404
2430
|
}
|
|
2431
|
+
if (!canSkipHandleResolution &&
|
|
2432
|
+
!this.handleResolver.getPendingResolution(nodeId)) {
|
|
2433
|
+
this.handleResolver.scheduleRecomputeHandles(nodeId);
|
|
2434
|
+
}
|
|
2405
2435
|
// Check if handles are being resolved - wait for resolution before executing
|
|
2406
2436
|
// Do this AFTER setting up run contexts so handle resolution can track them
|
|
2407
2437
|
const pendingResolution = this.handleResolver.getPendingResolution(nodeId);
|
|
@@ -2416,7 +2446,7 @@ class NodeExecutor {
|
|
|
2416
2446
|
// Re-check node still exists and conditions
|
|
2417
2447
|
const nodeAfter = this.graph.getNode(nodeId);
|
|
2418
2448
|
if (nodeAfter) {
|
|
2419
|
-
this.execute(nodeId, runContextIds);
|
|
2449
|
+
this.execute(nodeId, runContextIds, true);
|
|
2420
2450
|
}
|
|
2421
2451
|
if (runContextIds && runContextIds.size > 0) {
|
|
2422
2452
|
for (const id of runContextIds) {
|
|
@@ -2855,6 +2885,61 @@ class NodeExecutor {
|
|
|
2855
2885
|
}
|
|
2856
2886
|
}
|
|
2857
2887
|
|
|
2888
|
+
/**
|
|
2889
|
+
* RuntimeValidatorManager component - manages runtime validators
|
|
2890
|
+
*/
|
|
2891
|
+
class RuntimeValidatorManager {
|
|
2892
|
+
constructor(graph, registry) {
|
|
2893
|
+
this.graph = graph;
|
|
2894
|
+
this.registry = registry;
|
|
2895
|
+
this.validators = [];
|
|
2896
|
+
}
|
|
2897
|
+
/**
|
|
2898
|
+
* Set the registry (called when registry changes)
|
|
2899
|
+
*/
|
|
2900
|
+
setRegistry(registry) {
|
|
2901
|
+
this.registry = registry;
|
|
2902
|
+
}
|
|
2903
|
+
/**
|
|
2904
|
+
* Register a runtime validator that will be called before node execution.
|
|
2905
|
+
* Validators are called in registration order - if any returns true, execution is blocked.
|
|
2906
|
+
*/
|
|
2907
|
+
registerValidator(validator) {
|
|
2908
|
+
this.validators.push(validator);
|
|
2909
|
+
}
|
|
2910
|
+
/**
|
|
2911
|
+
* Unregister a runtime validator.
|
|
2912
|
+
*/
|
|
2913
|
+
unregisterValidator(validator) {
|
|
2914
|
+
const index = this.validators.indexOf(validator);
|
|
2915
|
+
if (index >= 0) {
|
|
2916
|
+
this.validators.splice(index, 1);
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
/**
|
|
2920
|
+
* Check if any runtime validator blocks execution for this node.
|
|
2921
|
+
* Returns RuntimeValidationError if execution should be blocked, null otherwise.
|
|
2922
|
+
*/
|
|
2923
|
+
hasBlock(nodeId) {
|
|
2924
|
+
if (!this.registry)
|
|
2925
|
+
return null;
|
|
2926
|
+
for (const validator of this.validators) {
|
|
2927
|
+
try {
|
|
2928
|
+
const result = validator(nodeId, this.graph, this.registry);
|
|
2929
|
+
if (result !== false) {
|
|
2930
|
+
// Validator returned an error object
|
|
2931
|
+
return result;
|
|
2932
|
+
}
|
|
2933
|
+
}
|
|
2934
|
+
catch (err) {
|
|
2935
|
+
// Don't let validator errors break execution - log and continue
|
|
2936
|
+
console.error(`Runtime validator error for node ${nodeId}:`, err);
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
return null;
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
|
|
2858
2943
|
// Types are now imported from components/types.ts (re-exported above)
|
|
2859
2944
|
class GraphRuntime {
|
|
2860
2945
|
constructor() {
|
|
@@ -2871,6 +2956,8 @@ class GraphRuntime {
|
|
|
2871
2956
|
this.edgePropagator = new EdgePropagator(this.graph, this.eventEmitter, this.runContextManager, this.handleResolver, this);
|
|
2872
2957
|
// Create NodeExecutor with EdgePropagator and HandleResolver
|
|
2873
2958
|
this.nodeExecutor = new NodeExecutor(this.graph, this.eventEmitter, this.runContextManager, this.handleResolver, this, this);
|
|
2959
|
+
// Create RuntimeValidatorManager
|
|
2960
|
+
this.runtimeValidatorManager = new RuntimeValidatorManager(this.graph);
|
|
2874
2961
|
}
|
|
2875
2962
|
static create(def, registry, opts) {
|
|
2876
2963
|
const gr = new GraphRuntime();
|
|
@@ -2882,6 +2969,7 @@ class GraphRuntime {
|
|
|
2882
2969
|
gr.handleResolver.setRegistry(registry);
|
|
2883
2970
|
gr.handleResolver.setEnvironment(gr.environment);
|
|
2884
2971
|
gr.nodeExecutor.setEnvironment(gr.environment);
|
|
2972
|
+
gr.runtimeValidatorManager.setRegistry(registry);
|
|
2885
2973
|
// Precompute per-node resolved handles (use def-provided overrides; do not compute dynamically here)
|
|
2886
2974
|
const initial = gr.isPaused()
|
|
2887
2975
|
? {
|
|
@@ -3099,6 +3187,26 @@ class GraphRuntime {
|
|
|
3099
3187
|
this.handleResolver.scheduleRecomputeHandles(nodeId);
|
|
3100
3188
|
}
|
|
3101
3189
|
}
|
|
3190
|
+
/**
|
|
3191
|
+
* Register a runtime validator that will be called before node execution.
|
|
3192
|
+
* Validators are called in registration order - if any returns true, execution is blocked.
|
|
3193
|
+
*/
|
|
3194
|
+
registerRuntimeValidator(validator) {
|
|
3195
|
+
this.runtimeValidatorManager.registerValidator(validator);
|
|
3196
|
+
}
|
|
3197
|
+
/**
|
|
3198
|
+
* Unregister a runtime validator.
|
|
3199
|
+
*/
|
|
3200
|
+
unregisterRuntimeValidator(validator) {
|
|
3201
|
+
this.runtimeValidatorManager.unregisterValidator(validator);
|
|
3202
|
+
}
|
|
3203
|
+
/**
|
|
3204
|
+
* Check if any runtime validator blocks execution for this node.
|
|
3205
|
+
* Returns RuntimeValidationError if execution should be blocked, null otherwise.
|
|
3206
|
+
*/
|
|
3207
|
+
hasRuntimeValidationBlock(nodeId) {
|
|
3208
|
+
return this.runtimeValidatorManager.hasBlock(nodeId);
|
|
3209
|
+
}
|
|
3102
3210
|
getGraphDef() {
|
|
3103
3211
|
const nodes = [];
|
|
3104
3212
|
this.graph.forEachNode((n) => {
|
|
@@ -3532,8 +3640,8 @@ class GraphRuntime {
|
|
|
3532
3640
|
});
|
|
3533
3641
|
this.graph.clear();
|
|
3534
3642
|
}
|
|
3535
|
-
execute(nodeId, runContextIds) {
|
|
3536
|
-
this.nodeExecutor.execute(nodeId, runContextIds);
|
|
3643
|
+
execute(nodeId, runContextIds, resolveHandles) {
|
|
3644
|
+
this.nodeExecutor.execute(nodeId, runContextIds, resolveHandles);
|
|
3537
3645
|
}
|
|
3538
3646
|
propagate(srcNodeId, srcHandle, value, runContextIds) {
|
|
3539
3647
|
this.edgePropagator.propagate(srcNodeId, srcHandle, value, runContextIds);
|
|
@@ -6151,5 +6259,5 @@ function buildValueConverter(config) {
|
|
|
6151
6259
|
};
|
|
6152
6260
|
}
|
|
6153
6261
|
|
|
6154
|
-
export { BaseCompareOperation, BaseLogicOperation, BaseMathOperation, CompositeCategory, ComputeCategory, GraphBuilder, GraphRuntime, LevelLogger, LocalEngine, Registry, buildValueConverter, computeGraphCenter, convertSnapshot, createAsyncGraphDef, createAsyncGraphRegistry, createProgressGraphDef, createProgressGraphRegistry, createSimpleGraphDef, createSimpleGraphRegistry, createValidationGraphDef, createValidationGraphRegistry, findMatchingPaths, generateId, getInputDeclaredTypes, getInputHandleMetadata, getInputTypeId, getTypedOutputTypeId, getTypedOutputValue, getValueAtPath, installLogging, isInputPrivate, isTypedOutput, mergeInputHandleDescriptors, mergeRuntimeState, mergeSnapshots, offsetImportedPositions, parseJsonPath, registerDelayNode, registerProgressNodes, setValueAtPath, setValueAtPathWithCreation, typed };
|
|
6262
|
+
export { BaseCompareOperation, BaseLogicOperation, BaseMathOperation, CompositeCategory, ComputeCategory, Graph, GraphBuilder, GraphRuntime, LevelLogger, LocalEngine, Registry, buildValueConverter, computeGraphCenter, convertSnapshot, createAsyncGraphDef, createAsyncGraphRegistry, createProgressGraphDef, createProgressGraphRegistry, createSimpleGraphDef, createSimpleGraphRegistry, createValidationGraphDef, createValidationGraphRegistry, findMatchingPaths, generateId, getEffectiveInputs, getInputDeclaredTypes, getInputHandleMetadata, getInputTypeId, getTypedOutputTypeId, getTypedOutputValue, getValueAtPath, installLogging, isInputPrivate, isTypedOutput, mergeInputHandleDescriptors, mergeRuntimeState, mergeSnapshots, offsetImportedPositions, parseJsonPath, registerDelayNode, registerProgressNodes, setValueAtPath, setValueAtPathWithCreation, typed };
|
|
6155
6263
|
//# sourceMappingURL=index.js.map
|