@framers/agentos 0.1.69 → 0.1.71
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/dist/api/agent.d.ts +98 -2
- package/dist/api/agent.d.ts.map +1 -1
- package/dist/api/agent.js +64 -9
- package/dist/api/agent.js.map +1 -1
- package/dist/api/generateImage.d.ts +109 -0
- package/dist/api/generateImage.d.ts.map +1 -0
- package/dist/api/generateImage.js +41 -0
- package/dist/api/generateImage.js.map +1 -0
- package/dist/api/generateText.d.ts +73 -3
- package/dist/api/generateText.d.ts.map +1 -1
- package/dist/api/generateText.js +29 -4
- package/dist/api/generateText.js.map +1 -1
- package/dist/api/model.d.ts +74 -4
- package/dist/api/model.d.ts.map +1 -1
- package/dist/api/model.js +79 -5
- package/dist/api/model.js.map +1 -1
- package/dist/api/streamText.d.ts +37 -1
- package/dist/api/streamText.d.ts.map +1 -1
- package/dist/api/streamText.js +188 -49
- package/dist/api/streamText.js.map +1 -1
- package/dist/api/toolAdapter.d.ts +58 -0
- package/dist/api/toolAdapter.d.ts.map +1 -0
- package/dist/api/{tool-adapter.js → toolAdapter.js} +24 -2
- package/dist/api/toolAdapter.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/orchestration/builders/AgentGraph.d.ts +250 -0
- package/dist/orchestration/builders/AgentGraph.d.ts.map +1 -0
- package/dist/orchestration/builders/AgentGraph.js +338 -0
- package/dist/orchestration/builders/AgentGraph.js.map +1 -0
- package/dist/orchestration/builders/MissionBuilder.d.ts +231 -0
- package/dist/orchestration/builders/MissionBuilder.d.ts.map +1 -0
- package/dist/orchestration/builders/MissionBuilder.js +321 -0
- package/dist/orchestration/builders/MissionBuilder.js.map +1 -0
- package/dist/orchestration/builders/WorkflowBuilder.d.ts +265 -0
- package/dist/orchestration/builders/WorkflowBuilder.d.ts.map +1 -0
- package/dist/orchestration/builders/WorkflowBuilder.js +472 -0
- package/dist/orchestration/builders/WorkflowBuilder.js.map +1 -0
- package/dist/orchestration/builders/index.d.ts +7 -0
- package/dist/orchestration/builders/index.d.ts.map +1 -0
- package/dist/orchestration/builders/index.js +5 -0
- package/dist/orchestration/builders/index.js.map +1 -0
- package/dist/orchestration/builders/nodes.d.ts +36 -0
- package/dist/orchestration/builders/nodes.d.ts.map +1 -0
- package/dist/orchestration/builders/nodes.js +98 -0
- package/dist/orchestration/builders/nodes.js.map +1 -0
- package/dist/orchestration/checkpoint/ICheckpointStore.d.ts +152 -0
- package/dist/orchestration/checkpoint/ICheckpointStore.d.ts.map +1 -0
- package/dist/orchestration/checkpoint/ICheckpointStore.js +8 -0
- package/dist/orchestration/checkpoint/ICheckpointStore.js.map +1 -0
- package/dist/orchestration/checkpoint/InMemoryCheckpointStore.d.ts +89 -0
- package/dist/orchestration/checkpoint/InMemoryCheckpointStore.d.ts.map +1 -0
- package/dist/orchestration/checkpoint/InMemoryCheckpointStore.js +156 -0
- package/dist/orchestration/checkpoint/InMemoryCheckpointStore.js.map +1 -0
- package/dist/orchestration/checkpoint/index.d.ts +10 -0
- package/dist/orchestration/checkpoint/index.d.ts.map +1 -0
- package/dist/orchestration/checkpoint/index.js +10 -0
- package/dist/orchestration/checkpoint/index.js.map +1 -0
- package/dist/orchestration/compiler/GraphCompiler.d.ts +85 -0
- package/dist/orchestration/compiler/GraphCompiler.d.ts.map +1 -0
- package/dist/orchestration/compiler/GraphCompiler.js +71 -0
- package/dist/orchestration/compiler/GraphCompiler.js.map +1 -0
- package/dist/orchestration/compiler/MissionCompiler.d.ts +181 -0
- package/dist/orchestration/compiler/MissionCompiler.d.ts.map +1 -0
- package/dist/orchestration/compiler/MissionCompiler.js +219 -0
- package/dist/orchestration/compiler/MissionCompiler.js.map +1 -0
- package/dist/orchestration/compiler/SchemaLowering.d.ts +37 -0
- package/dist/orchestration/compiler/SchemaLowering.d.ts.map +1 -0
- package/dist/orchestration/compiler/SchemaLowering.js +93 -0
- package/dist/orchestration/compiler/SchemaLowering.js.map +1 -0
- package/dist/orchestration/compiler/Validator.d.ts +61 -0
- package/dist/orchestration/compiler/Validator.d.ts.map +1 -0
- package/dist/orchestration/compiler/Validator.js +96 -0
- package/dist/orchestration/compiler/Validator.js.map +1 -0
- package/dist/orchestration/compiler/index.d.ts +16 -0
- package/dist/orchestration/compiler/index.d.ts.map +1 -0
- package/dist/orchestration/compiler/index.js +13 -0
- package/dist/orchestration/compiler/index.js.map +1 -0
- package/dist/orchestration/events/GraphEvent.d.ts +233 -0
- package/dist/orchestration/events/GraphEvent.d.ts.map +1 -0
- package/dist/orchestration/events/GraphEvent.js +203 -0
- package/dist/orchestration/events/GraphEvent.js.map +1 -0
- package/dist/orchestration/events/index.d.ts +2 -0
- package/dist/orchestration/events/index.d.ts.map +1 -0
- package/dist/orchestration/events/index.js +2 -0
- package/dist/orchestration/events/index.js.map +1 -0
- package/dist/orchestration/index.d.ts +20 -0
- package/dist/orchestration/index.d.ts.map +1 -0
- package/dist/orchestration/index.js +26 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/ir/index.d.ts +2 -0
- package/dist/orchestration/ir/index.d.ts.map +1 -0
- package/dist/orchestration/ir/index.js +2 -0
- package/dist/orchestration/ir/index.js.map +1 -0
- package/dist/orchestration/ir/types.d.ts +540 -0
- package/dist/orchestration/ir/types.d.ts.map +1 -0
- package/dist/orchestration/ir/types.js +20 -0
- package/dist/orchestration/ir/types.js.map +1 -0
- package/dist/orchestration/runtime/GraphRuntime.d.ts +135 -0
- package/dist/orchestration/runtime/GraphRuntime.d.ts.map +1 -0
- package/dist/orchestration/runtime/GraphRuntime.js +381 -0
- package/dist/orchestration/runtime/GraphRuntime.js.map +1 -0
- package/dist/orchestration/runtime/LoopController.d.ts +173 -0
- package/dist/orchestration/runtime/LoopController.d.ts.map +1 -0
- package/dist/orchestration/runtime/LoopController.js +130 -0
- package/dist/orchestration/runtime/LoopController.js.map +1 -0
- package/dist/orchestration/runtime/NodeExecutor.d.ts +206 -0
- package/dist/orchestration/runtime/NodeExecutor.d.ts.map +1 -0
- package/dist/orchestration/runtime/NodeExecutor.js +227 -0
- package/dist/orchestration/runtime/NodeExecutor.js.map +1 -0
- package/dist/orchestration/runtime/NodeScheduler.d.ts +85 -0
- package/dist/orchestration/runtime/NodeScheduler.d.ts.map +1 -0
- package/dist/orchestration/runtime/NodeScheduler.js +180 -0
- package/dist/orchestration/runtime/NodeScheduler.js.map +1 -0
- package/dist/orchestration/runtime/StateManager.d.ts +122 -0
- package/dist/orchestration/runtime/StateManager.d.ts.map +1 -0
- package/dist/orchestration/runtime/StateManager.js +243 -0
- package/dist/orchestration/runtime/StateManager.js.map +1 -0
- package/dist/orchestration/runtime/index.d.ts +16 -0
- package/dist/orchestration/runtime/index.d.ts.map +1 -0
- package/dist/orchestration/runtime/index.js +13 -0
- package/dist/orchestration/runtime/index.js.map +1 -0
- package/package.json +10 -4
- package/dist/api/tool-adapter.d.ts +0 -12
- package/dist/api/tool-adapter.d.ts.map +0 -1
- package/dist/api/tool-adapter.js.map +0 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file GraphRuntime.ts
|
|
3
|
+
* @description Main execution engine for the AgentOS Unified Orchestration Layer.
|
|
4
|
+
*
|
|
5
|
+
* `GraphRuntime` ties together the `StateManager`, `NodeScheduler`, `NodeExecutor`,
|
|
6
|
+
* and `ICheckpointStore` subsystems into a single runnable unit. It supports three
|
|
7
|
+
* execution modes:
|
|
8
|
+
*
|
|
9
|
+
* - **`invoke()`** — execute a graph to completion and return final artifacts.
|
|
10
|
+
* - **`stream()`** — execute a graph while yielding `GraphEvent` values at every step.
|
|
11
|
+
* - **`resume()`** — restore a previously interrupted run from its latest checkpoint.
|
|
12
|
+
*
|
|
13
|
+
* Design principles:
|
|
14
|
+
* - No mutable instance state beyond the injected config; each `invoke`/`stream`/`resume`
|
|
15
|
+
* call is fully isolated.
|
|
16
|
+
* - All state lives in `GraphState`; `StateManager` is the sole authority for mutations.
|
|
17
|
+
* - Checkpointing is always delegated to the injected `ICheckpointStore`.
|
|
18
|
+
* - Edge evaluation is a pure function of `GraphEdge[]`, `GraphState`, and `NodeExecutionResult`.
|
|
19
|
+
*/
|
|
20
|
+
import type { CompiledExecutionGraph } from '../ir/types.js';
|
|
21
|
+
import type { GraphEvent } from '../events/GraphEvent.js';
|
|
22
|
+
import type { ICheckpointStore } from '../checkpoint/ICheckpointStore.js';
|
|
23
|
+
import { NodeExecutor } from './NodeExecutor.js';
|
|
24
|
+
/**
|
|
25
|
+
* Dependencies required to construct a `GraphRuntime`.
|
|
26
|
+
*
|
|
27
|
+
* @property checkpointStore - Persistence backend for checkpoint snapshots.
|
|
28
|
+
* @property nodeExecutor - Dispatcher that runs individual graph nodes.
|
|
29
|
+
*/
|
|
30
|
+
export interface GraphRuntimeConfig {
|
|
31
|
+
/** Persistence backend for checkpoint snapshots. */
|
|
32
|
+
checkpointStore: ICheckpointStore;
|
|
33
|
+
/** Dispatcher that executes individual `GraphNode` instances. */
|
|
34
|
+
nodeExecutor: NodeExecutor;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Main execution engine for compiled AgentOS graphs.
|
|
38
|
+
*
|
|
39
|
+
* Instantiate once and reuse across multiple runs — the runtime itself is stateless
|
|
40
|
+
* between calls. Each `invoke()` / `stream()` / `resume()` call creates isolated local
|
|
41
|
+
* state tracked via closures.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const runtime = new GraphRuntime({ checkpointStore, nodeExecutor });
|
|
46
|
+
* const result = await runtime.invoke(compiledGraph, { query: 'hello' });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare class GraphRuntime {
|
|
50
|
+
private readonly config;
|
|
51
|
+
/**
|
|
52
|
+
* @param config - Injected dependencies shared across all runs handled by this instance.
|
|
53
|
+
*/
|
|
54
|
+
constructor(config: GraphRuntimeConfig);
|
|
55
|
+
/**
|
|
56
|
+
* Execute the graph to completion and return the final `artifacts` payload.
|
|
57
|
+
*
|
|
58
|
+
* This is a convenience wrapper around `stream()` that discards intermediate events
|
|
59
|
+
* and awaits the terminal `run_end` event.
|
|
60
|
+
*
|
|
61
|
+
* @param graph - Compiled execution graph to run.
|
|
62
|
+
* @param input - Initial user-provided input; frozen into `GraphState.input`.
|
|
63
|
+
* @returns The `GraphState.artifacts` value after the last node completes.
|
|
64
|
+
*/
|
|
65
|
+
invoke(graph: CompiledExecutionGraph, input: unknown): Promise<unknown>;
|
|
66
|
+
/**
|
|
67
|
+
* Execute the graph while yielding `GraphEvent` values at each significant step.
|
|
68
|
+
*
|
|
69
|
+
* Events are emitted in strict causal order:
|
|
70
|
+
* `run_start` → (`node_start` → `node_end` → `edge_transition`?)+ → `run_end`
|
|
71
|
+
*
|
|
72
|
+
* Checkpoints are saved according to both the graph-wide `checkpointPolicy` and
|
|
73
|
+
* per-node `checkpoint` settings. An `interrupt` event causes immediate suspension
|
|
74
|
+
* followed by a terminal `run_end`.
|
|
75
|
+
*
|
|
76
|
+
* @param graph - Compiled execution graph to run.
|
|
77
|
+
* @param input - Initial user-provided input; frozen into `GraphState.input`.
|
|
78
|
+
* @yields {GraphEvent} Runtime events in causal order.
|
|
79
|
+
*/
|
|
80
|
+
stream(graph: CompiledExecutionGraph, input: unknown): AsyncGenerator<GraphEvent>;
|
|
81
|
+
/**
|
|
82
|
+
* Resume a previously interrupted run from its latest persisted checkpoint.
|
|
83
|
+
*
|
|
84
|
+
* The runtime restores `GraphState` from the checkpoint and re-executes any nodes
|
|
85
|
+
* that had not yet completed when the run was suspended. Nodes recorded as
|
|
86
|
+
* `write`, `external`, or `human` effect-class are replayed from their stored
|
|
87
|
+
* outputs to avoid duplicate side-effects; all other nodes are re-executed.
|
|
88
|
+
*
|
|
89
|
+
* @param graph - The same compiled graph that was originally invoked.
|
|
90
|
+
* @param runId - The run identifier returned by the original `stream()` call.
|
|
91
|
+
* @returns The final `GraphState.artifacts` value after resumption completes.
|
|
92
|
+
* @throws {Error} When no checkpoint exists for the given `runId`.
|
|
93
|
+
*/
|
|
94
|
+
resume(graph: CompiledExecutionGraph, runId: string): Promise<unknown>;
|
|
95
|
+
/**
|
|
96
|
+
* Continue execution from a restored checkpoint state.
|
|
97
|
+
*
|
|
98
|
+
* Mirrors `stream()` but initialises `completedNodes` / `nodeResults` from the
|
|
99
|
+
* checkpoint so previously-finished work is not repeated. Nodes with side-effectful
|
|
100
|
+
* effect classes are replayed from stored outputs; pure / read nodes are re-executed.
|
|
101
|
+
*
|
|
102
|
+
* @param graph - The compiled execution graph.
|
|
103
|
+
* @param runId - Original run identifier for checkpoint persistence.
|
|
104
|
+
* @param state - `GraphState` restored from the checkpoint.
|
|
105
|
+
* @param checkpoint - Full checkpoint snapshot; provides `nodeResults` and `visitedNodes`.
|
|
106
|
+
* @yields {GraphEvent} Runtime events in causal order, starting from the resume point.
|
|
107
|
+
*/
|
|
108
|
+
private continueFromCheckpoint;
|
|
109
|
+
/**
|
|
110
|
+
* Evaluate the outgoing edges from a just-completed node and return the list of
|
|
111
|
+
* target node ids to activate next.
|
|
112
|
+
*
|
|
113
|
+
* Priority rule: if `result.routeTarget` is set (returned by `router` or `guardrail`
|
|
114
|
+
* nodes) it overrides any edge-derived targets.
|
|
115
|
+
*
|
|
116
|
+
* @param edges - All outgoing edges from the source node.
|
|
117
|
+
* @param state - Current `GraphState` passed to condition functions.
|
|
118
|
+
* @param result - Execution result; `routeTarget` takes precedence when present.
|
|
119
|
+
* @returns Ordered array of target node ids (may include `END`).
|
|
120
|
+
*/
|
|
121
|
+
private evaluateEdges;
|
|
122
|
+
/**
|
|
123
|
+
* Serialize the current execution state into a `Checkpoint` and persist it
|
|
124
|
+
* via the injected `ICheckpointStore`.
|
|
125
|
+
*
|
|
126
|
+
* @param graph - The compiled graph (provides `id`).
|
|
127
|
+
* @param runId - Unique run identifier assigned at `stream()` call-time.
|
|
128
|
+
* @param nodeId - The node at whose boundary the checkpoint is being taken.
|
|
129
|
+
* @param state - Current full `GraphState`.
|
|
130
|
+
* @param nodeResults - Accumulated per-node execution results.
|
|
131
|
+
* @param visitedNodes - Ordered list of completed node ids.
|
|
132
|
+
*/
|
|
133
|
+
private saveCheckpoint;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=GraphRuntime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphRuntime.d.ts","sourceRoot":"","sources":["../../../src/orchestration/runtime/GraphRuntime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAyB,MAAM,gBAAgB,CAAC;AAEpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,mCAAmC,CAAC;AAGtF,OAAO,EAAE,YAAY,EAA4B,MAAM,mBAAmB,CAAC;AAM3E;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,oDAAoD;IACpD,eAAe,EAAE,gBAAgB,CAAC;IAClC,iEAAiE;IACjE,YAAY,EAAE,YAAY,CAAC;CAC5B;AAMD;;;;;;;;;;;;GAYG;AACH,qBAAa,YAAY;IAIX,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC;;OAEG;gBAC0B,MAAM,EAAE,kBAAkB;IAMvD;;;;;;;;;OASG;IACG,MAAM,CAAC,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ7E;;;;;;;;;;;;;OAaG;IACI,MAAM,CAAC,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,OAAO,GAAG,cAAc,CAAC,UAAU,CAAC;IA2HxF;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA0B5E;;;;;;;;;;;;OAYG;YACY,sBAAsB;IA8ErC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,aAAa;IAwDrB;;;;;;;;;;OAUG;YACW,cAAc;CA2B7B"}
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file GraphRuntime.ts
|
|
3
|
+
* @description Main execution engine for the AgentOS Unified Orchestration Layer.
|
|
4
|
+
*
|
|
5
|
+
* `GraphRuntime` ties together the `StateManager`, `NodeScheduler`, `NodeExecutor`,
|
|
6
|
+
* and `ICheckpointStore` subsystems into a single runnable unit. It supports three
|
|
7
|
+
* execution modes:
|
|
8
|
+
*
|
|
9
|
+
* - **`invoke()`** — execute a graph to completion and return final artifacts.
|
|
10
|
+
* - **`stream()`** — execute a graph while yielding `GraphEvent` values at every step.
|
|
11
|
+
* - **`resume()`** — restore a previously interrupted run from its latest checkpoint.
|
|
12
|
+
*
|
|
13
|
+
* Design principles:
|
|
14
|
+
* - No mutable instance state beyond the injected config; each `invoke`/`stream`/`resume`
|
|
15
|
+
* call is fully isolated.
|
|
16
|
+
* - All state lives in `GraphState`; `StateManager` is the sole authority for mutations.
|
|
17
|
+
* - Checkpointing is always delegated to the injected `ICheckpointStore`.
|
|
18
|
+
* - Edge evaluation is a pure function of `GraphEdge[]`, `GraphState`, and `NodeExecutionResult`.
|
|
19
|
+
*/
|
|
20
|
+
import { END } from '../ir/types.js';
|
|
21
|
+
import { StateManager } from './StateManager.js';
|
|
22
|
+
import { NodeScheduler } from './NodeScheduler.js';
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// GraphRuntime
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
/**
|
|
27
|
+
* Main execution engine for compiled AgentOS graphs.
|
|
28
|
+
*
|
|
29
|
+
* Instantiate once and reuse across multiple runs — the runtime itself is stateless
|
|
30
|
+
* between calls. Each `invoke()` / `stream()` / `resume()` call creates isolated local
|
|
31
|
+
* state tracked via closures.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const runtime = new GraphRuntime({ checkpointStore, nodeExecutor });
|
|
36
|
+
* const result = await runtime.invoke(compiledGraph, { query: 'hello' });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export class GraphRuntime {
|
|
40
|
+
/**
|
|
41
|
+
* @param config - Injected dependencies shared across all runs handled by this instance.
|
|
42
|
+
*/
|
|
43
|
+
constructor(config) {
|
|
44
|
+
this.config = config;
|
|
45
|
+
}
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
// Public API
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
/**
|
|
50
|
+
* Execute the graph to completion and return the final `artifacts` payload.
|
|
51
|
+
*
|
|
52
|
+
* This is a convenience wrapper around `stream()` that discards intermediate events
|
|
53
|
+
* and awaits the terminal `run_end` event.
|
|
54
|
+
*
|
|
55
|
+
* @param graph - Compiled execution graph to run.
|
|
56
|
+
* @param input - Initial user-provided input; frozen into `GraphState.input`.
|
|
57
|
+
* @returns The `GraphState.artifacts` value after the last node completes.
|
|
58
|
+
*/
|
|
59
|
+
async invoke(graph, input) {
|
|
60
|
+
let finalOutput;
|
|
61
|
+
for await (const event of this.stream(graph, input)) {
|
|
62
|
+
if (event.type === 'run_end')
|
|
63
|
+
finalOutput = event.finalOutput;
|
|
64
|
+
}
|
|
65
|
+
return finalOutput;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Execute the graph while yielding `GraphEvent` values at each significant step.
|
|
69
|
+
*
|
|
70
|
+
* Events are emitted in strict causal order:
|
|
71
|
+
* `run_start` → (`node_start` → `node_end` → `edge_transition`?)+ → `run_end`
|
|
72
|
+
*
|
|
73
|
+
* Checkpoints are saved according to both the graph-wide `checkpointPolicy` and
|
|
74
|
+
* per-node `checkpoint` settings. An `interrupt` event causes immediate suspension
|
|
75
|
+
* followed by a terminal `run_end`.
|
|
76
|
+
*
|
|
77
|
+
* @param graph - Compiled execution graph to run.
|
|
78
|
+
* @param input - Initial user-provided input; frozen into `GraphState.input`.
|
|
79
|
+
* @yields {GraphEvent} Runtime events in causal order.
|
|
80
|
+
*/
|
|
81
|
+
async *stream(graph, input) {
|
|
82
|
+
const runId = crypto.randomUUID();
|
|
83
|
+
const stateManager = new StateManager(graph.reducers);
|
|
84
|
+
const scheduler = new NodeScheduler(graph.nodes, graph.edges);
|
|
85
|
+
let state = stateManager.initialize(input);
|
|
86
|
+
const startTime = Date.now();
|
|
87
|
+
/** Node ids whose execution has fully completed in this run. */
|
|
88
|
+
const completedNodes = [];
|
|
89
|
+
/** Node ids that were bypassed due to conditional routing. */
|
|
90
|
+
const skippedNodes = [];
|
|
91
|
+
/** Per-node execution results accumulated for checkpoint persistence. */
|
|
92
|
+
const nodeResults = {};
|
|
93
|
+
yield { type: 'run_start', runId, graphId: graph.id };
|
|
94
|
+
while (true) {
|
|
95
|
+
const readyNodes = scheduler.getReadyNodes(completedNodes, skippedNodes);
|
|
96
|
+
if (readyNodes.length === 0)
|
|
97
|
+
break; // All work is done (or no START edge).
|
|
98
|
+
for (const nodeId of readyNodes) {
|
|
99
|
+
const node = graph.nodes.find(n => n.id === nodeId);
|
|
100
|
+
if (!node) {
|
|
101
|
+
// Node declared in edges but missing from nodes array — skip defensively.
|
|
102
|
+
skippedNodes.push(nodeId);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
state = stateManager.recordNodeVisit(state, nodeId);
|
|
106
|
+
// ── Checkpoint BEFORE ────────────────────────────────────────────────
|
|
107
|
+
if (node.checkpoint === 'before' || node.checkpoint === 'both') {
|
|
108
|
+
await this.saveCheckpoint(graph, runId, nodeId, state, nodeResults, completedNodes);
|
|
109
|
+
yield { type: 'checkpoint_saved', checkpointId: `${runId}-${nodeId}-before`, nodeId };
|
|
110
|
+
}
|
|
111
|
+
yield { type: 'node_start', nodeId, state: { input: state.input, scratch: state.scratch } };
|
|
112
|
+
const nodeStart = Date.now();
|
|
113
|
+
// ── Execute ───────────────────────────────────────────────────────────
|
|
114
|
+
const result = await this.config.nodeExecutor.execute(node, state);
|
|
115
|
+
const durationMs = Date.now() - nodeStart;
|
|
116
|
+
nodeResults[nodeId] = {
|
|
117
|
+
effectClass: node.effectClass,
|
|
118
|
+
output: result.output,
|
|
119
|
+
durationMs,
|
|
120
|
+
};
|
|
121
|
+
// Apply state patches produced by the node.
|
|
122
|
+
if (result.scratchUpdate) {
|
|
123
|
+
state = stateManager.updateScratch(state, result.scratchUpdate);
|
|
124
|
+
}
|
|
125
|
+
if (result.artifactsUpdate) {
|
|
126
|
+
state = stateManager.updateArtifacts(state, result.artifactsUpdate);
|
|
127
|
+
}
|
|
128
|
+
yield { type: 'node_end', nodeId, output: result.output, durationMs };
|
|
129
|
+
// ── Human interrupt ───────────────────────────────────────────────────
|
|
130
|
+
if (result.interrupt) {
|
|
131
|
+
yield { type: 'interrupt', nodeId, reason: 'human_approval' };
|
|
132
|
+
// Persist so the run can be resumed later.
|
|
133
|
+
await this.saveCheckpoint(graph, runId, nodeId, state, nodeResults, completedNodes);
|
|
134
|
+
yield {
|
|
135
|
+
type: 'run_end',
|
|
136
|
+
runId,
|
|
137
|
+
finalOutput: state.artifacts,
|
|
138
|
+
totalDurationMs: Date.now() - startTime,
|
|
139
|
+
};
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
completedNodes.push(nodeId);
|
|
143
|
+
// ── Checkpoint AFTER ──────────────────────────────────────────────────
|
|
144
|
+
if (node.checkpoint === 'after' ||
|
|
145
|
+
node.checkpoint === 'both' ||
|
|
146
|
+
graph.checkpointPolicy === 'every_node') {
|
|
147
|
+
await this.saveCheckpoint(graph, runId, nodeId, state, nodeResults, completedNodes);
|
|
148
|
+
yield { type: 'checkpoint_saved', checkpointId: `${runId}-${nodeId}-after`, nodeId };
|
|
149
|
+
}
|
|
150
|
+
// ── Edge routing ──────────────────────────────────────────────────────
|
|
151
|
+
const outEdges = graph.edges.filter(e => e.source === nodeId);
|
|
152
|
+
const targets = this.evaluateEdges(outEdges, state, result);
|
|
153
|
+
// Any conditional-edge target that was NOT selected is marked as skipped
|
|
154
|
+
// so downstream nodes that depend only on the skipped branch do not block.
|
|
155
|
+
for (const edge of outEdges) {
|
|
156
|
+
if (edge.type === 'conditional' || edge.type === 'personality') {
|
|
157
|
+
for (const potentialTarget of outEdges.map(e => e.target)) {
|
|
158
|
+
if (!targets.includes(potentialTarget) &&
|
|
159
|
+
!completedNodes.includes(potentialTarget) &&
|
|
160
|
+
!skippedNodes.includes(potentialTarget)) {
|
|
161
|
+
skippedNodes.push(potentialTarget);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
for (const target of targets) {
|
|
167
|
+
if (target !== END) {
|
|
168
|
+
const edgeType = outEdges.find(e => e.target === target)?.type ?? 'static';
|
|
169
|
+
yield { type: 'edge_transition', sourceId: nodeId, targetId: target, edgeType };
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
yield {
|
|
175
|
+
type: 'run_end',
|
|
176
|
+
runId,
|
|
177
|
+
finalOutput: state.artifacts,
|
|
178
|
+
totalDurationMs: Date.now() - startTime,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Resume a previously interrupted run from its latest persisted checkpoint.
|
|
183
|
+
*
|
|
184
|
+
* The runtime restores `GraphState` from the checkpoint and re-executes any nodes
|
|
185
|
+
* that had not yet completed when the run was suspended. Nodes recorded as
|
|
186
|
+
* `write`, `external`, or `human` effect-class are replayed from their stored
|
|
187
|
+
* outputs to avoid duplicate side-effects; all other nodes are re-executed.
|
|
188
|
+
*
|
|
189
|
+
* @param graph - The same compiled graph that was originally invoked.
|
|
190
|
+
* @param runId - The run identifier returned by the original `stream()` call.
|
|
191
|
+
* @returns The final `GraphState.artifacts` value after resumption completes.
|
|
192
|
+
* @throws {Error} When no checkpoint exists for the given `runId`.
|
|
193
|
+
*/
|
|
194
|
+
async resume(graph, runId) {
|
|
195
|
+
const checkpoint = await this.config.checkpointStore.latest(runId);
|
|
196
|
+
if (!checkpoint)
|
|
197
|
+
throw new Error(`No checkpoint found for run ${runId}`);
|
|
198
|
+
// Reconstruct graph state from the persisted snapshot.
|
|
199
|
+
const stateManager = new StateManager(graph.reducers);
|
|
200
|
+
let state = stateManager.initialize(checkpoint.state.input);
|
|
201
|
+
state = {
|
|
202
|
+
...state,
|
|
203
|
+
scratch: checkpoint.state.scratch,
|
|
204
|
+
artifacts: checkpoint.state.artifacts,
|
|
205
|
+
visitedNodes: [...checkpoint.visitedNodes],
|
|
206
|
+
iteration: checkpoint.visitedNodes.length,
|
|
207
|
+
};
|
|
208
|
+
let finalOutput;
|
|
209
|
+
for await (const event of this.continueFromCheckpoint(graph, runId, state, checkpoint)) {
|
|
210
|
+
if (event.type === 'run_end')
|
|
211
|
+
finalOutput = event.finalOutput;
|
|
212
|
+
}
|
|
213
|
+
return finalOutput;
|
|
214
|
+
}
|
|
215
|
+
// ---------------------------------------------------------------------------
|
|
216
|
+
// Private helpers
|
|
217
|
+
// ---------------------------------------------------------------------------
|
|
218
|
+
/**
|
|
219
|
+
* Continue execution from a restored checkpoint state.
|
|
220
|
+
*
|
|
221
|
+
* Mirrors `stream()` but initialises `completedNodes` / `nodeResults` from the
|
|
222
|
+
* checkpoint so previously-finished work is not repeated. Nodes with side-effectful
|
|
223
|
+
* effect classes are replayed from stored outputs; pure / read nodes are re-executed.
|
|
224
|
+
*
|
|
225
|
+
* @param graph - The compiled execution graph.
|
|
226
|
+
* @param runId - Original run identifier for checkpoint persistence.
|
|
227
|
+
* @param state - `GraphState` restored from the checkpoint.
|
|
228
|
+
* @param checkpoint - Full checkpoint snapshot; provides `nodeResults` and `visitedNodes`.
|
|
229
|
+
* @yields {GraphEvent} Runtime events in causal order, starting from the resume point.
|
|
230
|
+
*/
|
|
231
|
+
async *continueFromCheckpoint(graph, runId, state, checkpoint) {
|
|
232
|
+
const scheduler = new NodeScheduler(graph.nodes, graph.edges);
|
|
233
|
+
const stateManager = new StateManager(graph.reducers);
|
|
234
|
+
const completedNodes = [...checkpoint.visitedNodes];
|
|
235
|
+
const skippedNodes = [];
|
|
236
|
+
const nodeResults = { ...checkpoint.nodeResults };
|
|
237
|
+
const startTime = Date.now();
|
|
238
|
+
yield { type: 'run_start', runId, graphId: graph.id };
|
|
239
|
+
while (true) {
|
|
240
|
+
const readyNodes = scheduler.getReadyNodes(completedNodes, skippedNodes);
|
|
241
|
+
if (readyNodes.length === 0)
|
|
242
|
+
break;
|
|
243
|
+
for (const nodeId of readyNodes) {
|
|
244
|
+
const node = graph.nodes.find(n => n.id === nodeId);
|
|
245
|
+
if (!node) {
|
|
246
|
+
skippedNodes.push(nodeId);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
// Nodes with side-effects that were recorded are replayed from stored output
|
|
250
|
+
// to prevent duplicate writes/calls.
|
|
251
|
+
const recorded = checkpoint.nodeResults[nodeId];
|
|
252
|
+
if (recorded &&
|
|
253
|
+
(recorded.effectClass === 'write' ||
|
|
254
|
+
recorded.effectClass === 'external' ||
|
|
255
|
+
recorded.effectClass === 'human')) {
|
|
256
|
+
completedNodes.push(nodeId);
|
|
257
|
+
yield { type: 'node_end', nodeId, output: recorded.output, durationMs: recorded.durationMs };
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
// Re-execute the node (pure / read effects, or nodes without a stored result).
|
|
261
|
+
state = stateManager.recordNodeVisit(state, nodeId);
|
|
262
|
+
yield { type: 'node_start', nodeId, state: { input: state.input, scratch: state.scratch } };
|
|
263
|
+
const nodeStart = Date.now();
|
|
264
|
+
const result = await this.config.nodeExecutor.execute(node, state);
|
|
265
|
+
const durationMs = Date.now() - nodeStart;
|
|
266
|
+
nodeResults[nodeId] = { effectClass: node.effectClass, output: result.output, durationMs };
|
|
267
|
+
if (result.scratchUpdate)
|
|
268
|
+
state = stateManager.updateScratch(state, result.scratchUpdate);
|
|
269
|
+
if (result.artifactsUpdate)
|
|
270
|
+
state = stateManager.updateArtifacts(state, result.artifactsUpdate);
|
|
271
|
+
yield { type: 'node_end', nodeId, output: result.output, durationMs };
|
|
272
|
+
completedNodes.push(nodeId);
|
|
273
|
+
// Evaluate outgoing edges for the resumed node.
|
|
274
|
+
const outEdges = graph.edges.filter(e => e.source === nodeId);
|
|
275
|
+
const targets = this.evaluateEdges(outEdges, state, result);
|
|
276
|
+
for (const target of targets) {
|
|
277
|
+
if (target !== END) {
|
|
278
|
+
const edgeType = outEdges.find(e => e.target === target)?.type ?? 'static';
|
|
279
|
+
yield { type: 'edge_transition', sourceId: nodeId, targetId: target, edgeType };
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
yield {
|
|
285
|
+
type: 'run_end',
|
|
286
|
+
runId,
|
|
287
|
+
finalOutput: state.artifacts,
|
|
288
|
+
totalDurationMs: Date.now() - startTime,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Evaluate the outgoing edges from a just-completed node and return the list of
|
|
293
|
+
* target node ids to activate next.
|
|
294
|
+
*
|
|
295
|
+
* Priority rule: if `result.routeTarget` is set (returned by `router` or `guardrail`
|
|
296
|
+
* nodes) it overrides any edge-derived targets.
|
|
297
|
+
*
|
|
298
|
+
* @param edges - All outgoing edges from the source node.
|
|
299
|
+
* @param state - Current `GraphState` passed to condition functions.
|
|
300
|
+
* @param result - Execution result; `routeTarget` takes precedence when present.
|
|
301
|
+
* @returns Ordered array of target node ids (may include `END`).
|
|
302
|
+
*/
|
|
303
|
+
evaluateEdges(edges, state, result) {
|
|
304
|
+
// Router / guardrail nodes return an explicit target that takes precedence.
|
|
305
|
+
if (result.routeTarget) {
|
|
306
|
+
return [result.routeTarget];
|
|
307
|
+
}
|
|
308
|
+
const targets = [];
|
|
309
|
+
for (const edge of edges) {
|
|
310
|
+
switch (edge.type) {
|
|
311
|
+
case 'static':
|
|
312
|
+
// Always follow static edges.
|
|
313
|
+
targets.push(edge.target);
|
|
314
|
+
break;
|
|
315
|
+
case 'conditional': {
|
|
316
|
+
if (!edge.condition)
|
|
317
|
+
break;
|
|
318
|
+
let resolvedTarget;
|
|
319
|
+
if (edge.condition.type === 'function') {
|
|
320
|
+
// Call the author-provided TypeScript routing function.
|
|
321
|
+
resolvedTarget = edge.condition.fn(state);
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
// Expression evaluation is a stub; returns the raw expression until the
|
|
325
|
+
// DSL interpreter is implemented (tracked separately).
|
|
326
|
+
resolvedTarget = edge.target;
|
|
327
|
+
}
|
|
328
|
+
// Only add the target if the condition resolved to this edge's target.
|
|
329
|
+
if (resolvedTarget === edge.target && !targets.includes(resolvedTarget)) {
|
|
330
|
+
targets.push(resolvedTarget);
|
|
331
|
+
}
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
case 'personality':
|
|
335
|
+
if (edge.personalityCondition) {
|
|
336
|
+
// Stub: always route to the 'above' branch until personality integration lands.
|
|
337
|
+
targets.push(edge.personalityCondition.above);
|
|
338
|
+
}
|
|
339
|
+
break;
|
|
340
|
+
case 'discovery':
|
|
341
|
+
// Stub: fall back to the declared fallback target until discovery is wired.
|
|
342
|
+
if (edge.discoveryFallback)
|
|
343
|
+
targets.push(edge.discoveryFallback);
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return targets;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Serialize the current execution state into a `Checkpoint` and persist it
|
|
351
|
+
* via the injected `ICheckpointStore`.
|
|
352
|
+
*
|
|
353
|
+
* @param graph - The compiled graph (provides `id`).
|
|
354
|
+
* @param runId - Unique run identifier assigned at `stream()` call-time.
|
|
355
|
+
* @param nodeId - The node at whose boundary the checkpoint is being taken.
|
|
356
|
+
* @param state - Current full `GraphState`.
|
|
357
|
+
* @param nodeResults - Accumulated per-node execution results.
|
|
358
|
+
* @param visitedNodes - Ordered list of completed node ids.
|
|
359
|
+
*/
|
|
360
|
+
async saveCheckpoint(graph, runId, nodeId, state, nodeResults, visitedNodes) {
|
|
361
|
+
const checkpoint = {
|
|
362
|
+
id: `${runId}-${nodeId}-${Date.now()}`,
|
|
363
|
+
graphId: graph.id,
|
|
364
|
+
runId,
|
|
365
|
+
nodeId,
|
|
366
|
+
timestamp: Date.now(),
|
|
367
|
+
state: {
|
|
368
|
+
input: state.input,
|
|
369
|
+
scratch: state.scratch,
|
|
370
|
+
artifacts: state.artifacts,
|
|
371
|
+
diagnostics: state.diagnostics,
|
|
372
|
+
},
|
|
373
|
+
// Cast: checkpoint type requires EffectClass but we store as string for flexibility.
|
|
374
|
+
nodeResults: nodeResults,
|
|
375
|
+
visitedNodes: [...visitedNodes],
|
|
376
|
+
pendingEdges: [],
|
|
377
|
+
};
|
|
378
|
+
await this.config.checkpointStore.save(checkpoint);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
//# sourceMappingURL=GraphRuntime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphRuntime.js","sourceRoot":"","sources":["../../../src/orchestration/runtime/GraphRuntime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAGrC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAoBnD,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,YAAY;IACvB;;OAEG;IACH,YAA6B,MAA0B;QAA1B,WAAM,GAAN,MAAM,CAAoB;IAAG,CAAC;IAE3D,8EAA8E;IAC9E,aAAa;IACb,8EAA8E;IAE9E;;;;;;;;;OASG;IACH,KA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