@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,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file AgentGraph.ts
|
|
3
|
+
* @description Fluent builder for constructing compiled agent execution graphs.
|
|
4
|
+
*
|
|
5
|
+
* `AgentGraph` provides a type-safe, chainable API for declaring nodes and edges —
|
|
6
|
+
* including static, conditional, discovery-based, and personality-driven routing —
|
|
7
|
+
* and then compiling the resulting graph into a `CompiledExecutionGraph` IR object
|
|
8
|
+
* that the `GraphRuntime` can execute.
|
|
9
|
+
*
|
|
10
|
+
* ```
|
|
11
|
+
* AgentGraph (builder)
|
|
12
|
+
* → GraphCompiler.compile() → CompiledExecutionGraph (IR)
|
|
13
|
+
* → GraphValidator.validate() → validation gate
|
|
14
|
+
* → CompiledAgentGraph → GraphRuntime.invoke() / stream() / resume()
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Typical usage:
|
|
18
|
+
* ```ts
|
|
19
|
+
* const graph = new AgentGraph({ input: z.object({ topic: z.string() }), ... })
|
|
20
|
+
* .addNode('search', toolNode('web_search'))
|
|
21
|
+
* .addEdge(START, 'search')
|
|
22
|
+
* .addEdge('search', END)
|
|
23
|
+
* .compile();
|
|
24
|
+
*
|
|
25
|
+
* const result = await graph.invoke({ topic: 'AgentOS' });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
import { START, END } from '../ir/types.js';
|
|
29
|
+
import { InMemoryCheckpointStore } from '../checkpoint/InMemoryCheckpointStore.js';
|
|
30
|
+
import { GraphCompiler } from '../compiler/GraphCompiler.js';
|
|
31
|
+
import { GraphValidator } from '../compiler/Validator.js';
|
|
32
|
+
import { GraphRuntime } from '../runtime/GraphRuntime.js';
|
|
33
|
+
import { NodeExecutor } from '../runtime/NodeExecutor.js';
|
|
34
|
+
// Re-export sentinels so callers can import them from this module without reaching into ir/.
|
|
35
|
+
export { START, END };
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// AgentGraph (builder)
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
/**
|
|
40
|
+
* Fluent builder for agent execution graphs.
|
|
41
|
+
*
|
|
42
|
+
* Each mutating method returns `this` to support method chaining. All state is held
|
|
43
|
+
* in private Maps/arrays; nothing is compiled or validated until `.compile()` is called.
|
|
44
|
+
*
|
|
45
|
+
* @template TState - Narrows the `GraphState` type used in conditional-edge callbacks.
|
|
46
|
+
* Defaults to the base `GraphState` when not specified.
|
|
47
|
+
*/
|
|
48
|
+
export class AgentGraph {
|
|
49
|
+
/**
|
|
50
|
+
* @param stateSchema - Zod schemas for the three `GraphState` generic partitions.
|
|
51
|
+
* - `input` — shape of the frozen user-provided input passed to `invoke()`.
|
|
52
|
+
* - `scratch` — shape of the mutable node-to-node communication bag.
|
|
53
|
+
* - `artifacts` — shape of the accumulated external outputs returned by `invoke()`.
|
|
54
|
+
* @param config - Optional graph-wide configuration overrides.
|
|
55
|
+
*/
|
|
56
|
+
constructor(stateSchema, config) {
|
|
57
|
+
this.stateSchema = stateSchema;
|
|
58
|
+
this.config = config;
|
|
59
|
+
/** All user-declared nodes, keyed by their assigned id. */
|
|
60
|
+
this.nodes = new Map();
|
|
61
|
+
/** All directed edges declared via `addEdge`, `addConditionalEdge`, etc. */
|
|
62
|
+
this.edges = [];
|
|
63
|
+
/** Monotonically increasing counter used to generate unique edge ids. */
|
|
64
|
+
this.edgeCounter = 0;
|
|
65
|
+
}
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
// Node declaration
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
/**
|
|
70
|
+
* Add a node to the graph.
|
|
71
|
+
*
|
|
72
|
+
* The node's `id` field is overridden with the supplied `id` argument so the
|
|
73
|
+
* user-declared identifier is always canonical.
|
|
74
|
+
*
|
|
75
|
+
* @param id - Unique node identifier within this graph. Must not equal `START` or `END`.
|
|
76
|
+
* @param node - A `GraphNode` produced by one of the factory helpers in `builders/nodes.ts`.
|
|
77
|
+
* @returns `this` for chaining.
|
|
78
|
+
* @throws {Error} When `id` has already been registered.
|
|
79
|
+
*/
|
|
80
|
+
addNode(id, node) {
|
|
81
|
+
if (this.nodes.has(id)) {
|
|
82
|
+
throw new Error(`Duplicate node ID: "${id}" — each node must have a unique identifier`);
|
|
83
|
+
}
|
|
84
|
+
// Override the factory-generated id with the user-supplied one.
|
|
85
|
+
node.id = id;
|
|
86
|
+
this.nodes.set(id, node);
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// Edge declaration
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
/**
|
|
93
|
+
* Add an unconditional (static) edge that is always followed at runtime.
|
|
94
|
+
*
|
|
95
|
+
* Either `source` or `target` (or both) may be the `START` / `END` sentinels.
|
|
96
|
+
*
|
|
97
|
+
* @param source - Source node id (or `START`).
|
|
98
|
+
* @param target - Target node id (or `END`).
|
|
99
|
+
* @returns `this` for chaining.
|
|
100
|
+
*/
|
|
101
|
+
addEdge(source, target) {
|
|
102
|
+
this.edges.push({
|
|
103
|
+
id: `edge-${++this.edgeCounter}`,
|
|
104
|
+
source,
|
|
105
|
+
target,
|
|
106
|
+
type: 'static',
|
|
107
|
+
});
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Add a conditional edge whose target is determined at runtime by a callback.
|
|
112
|
+
*
|
|
113
|
+
* The `condition` function receives the current `GraphState` and returns the id of
|
|
114
|
+
* the next node to activate. The returned id is resolved against the edge list at
|
|
115
|
+
* runtime; no compile-time validation of the returned id is performed.
|
|
116
|
+
*
|
|
117
|
+
* Because conditional edges encode the target resolution in a closure, the `target`
|
|
118
|
+
* field stored in the IR is set to the placeholder `'__CONDITIONAL__'`.
|
|
119
|
+
*
|
|
120
|
+
* @param source - Source node id (or `START`).
|
|
121
|
+
* @param condition - Pure function `(state: TState) => string` returning the next node id.
|
|
122
|
+
* @returns `this` for chaining.
|
|
123
|
+
*/
|
|
124
|
+
addConditionalEdge(source, condition) {
|
|
125
|
+
this.edges.push({
|
|
126
|
+
id: `edge-${++this.edgeCounter}`,
|
|
127
|
+
source,
|
|
128
|
+
// Placeholder target — the actual target is resolved by the condition function at runtime.
|
|
129
|
+
target: '__CONDITIONAL__',
|
|
130
|
+
type: 'conditional',
|
|
131
|
+
condition: {
|
|
132
|
+
type: 'function',
|
|
133
|
+
// Cast: the condition function accepts TState but the IR stores GraphState.
|
|
134
|
+
fn: condition,
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
return this;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Add a discovery edge whose target is resolved at runtime via the capability discovery engine.
|
|
141
|
+
*
|
|
142
|
+
* When discovery returns no result, execution falls back to `config.fallbackTarget` (if provided)
|
|
143
|
+
* or the placeholder `'__DISCOVERY__'`.
|
|
144
|
+
*
|
|
145
|
+
* @param source - Source node id.
|
|
146
|
+
* @param config - Discovery configuration.
|
|
147
|
+
* @param config.query - Semantic search query forwarded to `CapabilityDiscoveryEngine`.
|
|
148
|
+
* @param config.kind - Optional filter: restrict discovery to a specific capability kind.
|
|
149
|
+
* @param config.fallbackTarget - Node id to route to when discovery resolves no target.
|
|
150
|
+
* @returns `this` for chaining.
|
|
151
|
+
*/
|
|
152
|
+
addDiscoveryEdge(source, config) {
|
|
153
|
+
this.edges.push({
|
|
154
|
+
id: `edge-${++this.edgeCounter}`,
|
|
155
|
+
source,
|
|
156
|
+
// Default target: the fallback when provided, otherwise a sentinel.
|
|
157
|
+
target: config.fallbackTarget ?? '__DISCOVERY__',
|
|
158
|
+
type: 'discovery',
|
|
159
|
+
discoveryQuery: config.query,
|
|
160
|
+
discoveryKind: config.kind,
|
|
161
|
+
discoveryFallback: config.fallbackTarget,
|
|
162
|
+
});
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Add a personality edge whose target is chosen based on the agent's current trait value.
|
|
167
|
+
*
|
|
168
|
+
* At runtime the engine reads `config.trait` from the agent's HEXACO/PAD state and routes
|
|
169
|
+
* to `config.above` when the value is ≥ `config.threshold`, or `config.below` otherwise.
|
|
170
|
+
*
|
|
171
|
+
* @param source - Source node id.
|
|
172
|
+
* @param config - Personality routing configuration.
|
|
173
|
+
* @param config.trait - HEXACO/PAD trait name to inspect (e.g. `'conscientiousness'`).
|
|
174
|
+
* @param config.threshold - Decision boundary (0–1).
|
|
175
|
+
* @param config.above - Target node id when trait value ≥ threshold.
|
|
176
|
+
* @param config.below - Target node id when trait value < threshold.
|
|
177
|
+
* @returns `this` for chaining.
|
|
178
|
+
*/
|
|
179
|
+
addPersonalityEdge(source, config) {
|
|
180
|
+
// Emit two edges — one per branch — so the reachability checker can see both targets.
|
|
181
|
+
// The runtime selects between them by evaluating `personalityCondition` at execution time.
|
|
182
|
+
const baseId = ++this.edgeCounter;
|
|
183
|
+
this.edges.push({
|
|
184
|
+
id: `edge-${baseId}`,
|
|
185
|
+
source,
|
|
186
|
+
target: config.above,
|
|
187
|
+
type: 'personality',
|
|
188
|
+
personalityCondition: config,
|
|
189
|
+
});
|
|
190
|
+
this.edges.push({
|
|
191
|
+
id: `edge-${++this.edgeCounter}`,
|
|
192
|
+
source,
|
|
193
|
+
target: config.below,
|
|
194
|
+
type: 'personality',
|
|
195
|
+
personalityCondition: config,
|
|
196
|
+
});
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
// ---------------------------------------------------------------------------
|
|
200
|
+
// Compilation
|
|
201
|
+
// ---------------------------------------------------------------------------
|
|
202
|
+
/**
|
|
203
|
+
* Compile the builder state into a `CompiledAgentGraph` ready for execution.
|
|
204
|
+
*
|
|
205
|
+
* Compilation steps:
|
|
206
|
+
* 1. Call `GraphCompiler.compile()` to produce the raw `CompiledExecutionGraph` IR.
|
|
207
|
+
* 2. (Optional, default: enabled) Call `GraphValidator.validate()` to assert structural
|
|
208
|
+
* correctness — any validation error or warning causes an exception.
|
|
209
|
+
* 3. Wrap the IR and a checkpoint store in a `CompiledAgentGraph` instance.
|
|
210
|
+
*
|
|
211
|
+
* Pass `{ validate: false }` to skip validation (e.g. for cyclic graphs under construction).
|
|
212
|
+
*
|
|
213
|
+
* @param options - Optional compilation flags.
|
|
214
|
+
* @param options.checkpointStore - Custom checkpoint store; defaults to `InMemoryCheckpointStore`.
|
|
215
|
+
* @param options.validate - Set to `false` to skip structural validation (default: `true`).
|
|
216
|
+
* @returns A `CompiledAgentGraph` instance ready for `invoke()` / `stream()` / `resume()`.
|
|
217
|
+
* @throws {Error} When validation is enabled and the graph contains structural errors or warnings.
|
|
218
|
+
*/
|
|
219
|
+
compile(options) {
|
|
220
|
+
// Step 1 — Compile builder state to IR.
|
|
221
|
+
const ir = GraphCompiler.compile({
|
|
222
|
+
name: 'agent-graph',
|
|
223
|
+
nodes: this.nodes,
|
|
224
|
+
edges: this.edges,
|
|
225
|
+
stateSchema: this.stateSchema,
|
|
226
|
+
reducers: this.config?.reducers ?? {},
|
|
227
|
+
memoryConsistency: this.config?.memoryConsistency ?? 'snapshot',
|
|
228
|
+
checkpointPolicy: this.config?.checkpointPolicy ?? 'none',
|
|
229
|
+
});
|
|
230
|
+
// Step 2 — Structural validation (opt-out with { validate: false }).
|
|
231
|
+
if (options?.validate !== false) {
|
|
232
|
+
// AgentGraph explicitly allows cycles (agent loops are a first-class pattern).
|
|
233
|
+
const result = GraphValidator.validate(ir, { requireAcyclic: false });
|
|
234
|
+
if (!result.valid) {
|
|
235
|
+
throw new Error(`Graph validation failed:\n ${result.errors.join('\n ')}`);
|
|
236
|
+
}
|
|
237
|
+
if (result.warnings.length > 0) {
|
|
238
|
+
// Promote warnings to compile-time errors for maximum safety.
|
|
239
|
+
// Authors who intentionally want orphan nodes must pass { validate: false }.
|
|
240
|
+
throw new Error(`Graph validation warnings (treated as errors at compile time):\n ${result.warnings.join('\n ')}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// Step 3 — Wrap in an executable CompiledAgentGraph.
|
|
244
|
+
const store = options?.checkpointStore ?? new InMemoryCheckpointStore();
|
|
245
|
+
return new CompiledAgentGraph(ir, store);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// ---------------------------------------------------------------------------
|
|
249
|
+
// CompiledAgentGraph (execution wrapper)
|
|
250
|
+
// ---------------------------------------------------------------------------
|
|
251
|
+
/**
|
|
252
|
+
* A compiled, execution-ready agent graph.
|
|
253
|
+
*
|
|
254
|
+
* Returned by `AgentGraph.compile()` — do not instantiate directly.
|
|
255
|
+
*
|
|
256
|
+
* Wraps a `CompiledExecutionGraph` IR object and a `GraphRuntime` instance, exposing
|
|
257
|
+
* the three execution modes: synchronous `invoke()`, streaming `stream()`, and
|
|
258
|
+
* checkpoint-based `resume()`.
|
|
259
|
+
*
|
|
260
|
+
* @template TState - Type parameter threaded from the parent `AgentGraph`.
|
|
261
|
+
*/
|
|
262
|
+
export class CompiledAgentGraph {
|
|
263
|
+
/**
|
|
264
|
+
* @param ir - Compiled execution graph IR produced by `GraphCompiler`.
|
|
265
|
+
* @param checkpointStore - Persistence backend for checkpoint snapshots.
|
|
266
|
+
*/
|
|
267
|
+
constructor(ir, checkpointStore) {
|
|
268
|
+
this.ir = ir;
|
|
269
|
+
this.runtime = new GraphRuntime({
|
|
270
|
+
checkpointStore,
|
|
271
|
+
nodeExecutor: new NodeExecutor({}),
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
// ---------------------------------------------------------------------------
|
|
275
|
+
// Execution API
|
|
276
|
+
// ---------------------------------------------------------------------------
|
|
277
|
+
/**
|
|
278
|
+
* Execute the graph to completion and return the final `artifacts` payload.
|
|
279
|
+
*
|
|
280
|
+
* This is the simplest execution mode — it buffers all events internally and returns
|
|
281
|
+
* only the terminal output. Use `stream()` when you need real-time progress updates.
|
|
282
|
+
*
|
|
283
|
+
* @param input - Initial user-provided input frozen into `GraphState.input`.
|
|
284
|
+
* @returns The `GraphState.artifacts` value after the last node completes.
|
|
285
|
+
*/
|
|
286
|
+
async invoke(input) {
|
|
287
|
+
return this.runtime.invoke(this.ir, input);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Execute the graph while yielding `GraphEvent` values at each significant step.
|
|
291
|
+
*
|
|
292
|
+
* Events are emitted in strict causal order:
|
|
293
|
+
* `run_start` → (`node_start` → `node_end` → `edge_transition`?)+ → `run_end`
|
|
294
|
+
*
|
|
295
|
+
* @param input - Initial user-provided input frozen into `GraphState.input`.
|
|
296
|
+
* @yields {GraphEvent} Runtime events in causal order.
|
|
297
|
+
*/
|
|
298
|
+
async *stream(input) {
|
|
299
|
+
yield* this.runtime.stream(this.ir, input);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Resume a previously interrupted run from its latest persisted checkpoint.
|
|
303
|
+
*
|
|
304
|
+
* The `patch` argument is accepted for API compatibility with future resume-with-patch
|
|
305
|
+
* support; it is not forwarded to the runtime in the current implementation.
|
|
306
|
+
*
|
|
307
|
+
* @param checkpointId - The run id returned by the original `stream()` call.
|
|
308
|
+
* @param patch - Reserved for future use: optional partial state override.
|
|
309
|
+
* @returns The final `GraphState.artifacts` value after resumption completes.
|
|
310
|
+
* @throws {Error} When no checkpoint exists for the given `checkpointId`.
|
|
311
|
+
*/
|
|
312
|
+
async resume(checkpointId, patch) {
|
|
313
|
+
// `patch` is not yet forwarded — tracked for implementation in a future PR.
|
|
314
|
+
void patch;
|
|
315
|
+
return this.runtime.resume(this.ir, checkpointId);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Inspect execution state for a completed or in-progress run.
|
|
319
|
+
*
|
|
320
|
+
* @param runId - The unique run identifier assigned at `stream()` call-time.
|
|
321
|
+
* @returns A stub object — full inspection support is tracked separately.
|
|
322
|
+
*
|
|
323
|
+
* @todo Implement with full runtime inspection once the run-registry subsystem lands.
|
|
324
|
+
*/
|
|
325
|
+
async inspect(_runId) {
|
|
326
|
+
// Stub — run registry not yet implemented.
|
|
327
|
+
return {};
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Return the underlying `CompiledExecutionGraph` IR.
|
|
331
|
+
*
|
|
332
|
+
* Useful for serialisation, debugging, or forwarding to external tooling.
|
|
333
|
+
*/
|
|
334
|
+
toIR() {
|
|
335
|
+
return this.ir;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
//# sourceMappingURL=AgentGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentGraph.js","sourceRoot":"","sources":["../../../src/orchestration/builders/AgentGraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAUH,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,C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,EAAE,CAAC;IACZ,CAAC;IAED;;;;OAIG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file MissionBuilder.ts
|
|
3
|
+
* @description Fluent builder API for goal-oriented mission authoring.
|
|
4
|
+
*
|
|
5
|
+
* The `mission()` factory function returns a `MissionBuilder` that collects
|
|
6
|
+
* configuration through a chainable interface before compiling the mission into
|
|
7
|
+
* a `CompiledMission` — the execution-ready wrapper that exposes `invoke()`,
|
|
8
|
+
* `stream()`, `resume()`, `explain()`, and `toIR()`.
|
|
9
|
+
*
|
|
10
|
+
* Typical usage:
|
|
11
|
+
* ```ts
|
|
12
|
+
* const researchMission = mission('research')
|
|
13
|
+
* .input(z.object({ topic: z.string() }))
|
|
14
|
+
* .goal('Research {{topic}} and produce a concise summary')
|
|
15
|
+
* .returns(z.object({ summary: z.string() }))
|
|
16
|
+
* .planner({ strategy: 'linear', maxSteps: 6 })
|
|
17
|
+
* .policy({ guardrails: ['content-safety'] })
|
|
18
|
+
* .compile();
|
|
19
|
+
*
|
|
20
|
+
* const result = await researchMission.invoke({ topic: 'quantum computing' });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import type { GraphNode, CompiledExecutionGraph, GraphState } from '../ir/types.js';
|
|
24
|
+
import type { ICheckpointStore } from '../checkpoint/ICheckpointStore.js';
|
|
25
|
+
import { type MissionConfig } from '../compiler/MissionCompiler.js';
|
|
26
|
+
import type { GraphEvent } from '../events/GraphEvent.js';
|
|
27
|
+
/**
|
|
28
|
+
* Create a new `MissionBuilder` for the named mission.
|
|
29
|
+
*
|
|
30
|
+
* @param name - Human-readable mission name; used as the compiled graph's display name
|
|
31
|
+
* and as a stable slug prefix for run ids and checkpoint keys.
|
|
32
|
+
* @returns A fresh `MissionBuilder` instance ready to be configured.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const m = mission('summarise-article')
|
|
37
|
+
* .input(inputSchema)
|
|
38
|
+
* .goal('Summarise {{url}} in three bullet points')
|
|
39
|
+
* .returns(outputSchema)
|
|
40
|
+
* .planner({ strategy: 'linear', maxSteps: 4 })
|
|
41
|
+
* .compile();
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function mission(name: string): MissionBuilder;
|
|
45
|
+
/**
|
|
46
|
+
* Fluent builder that collects mission configuration and validates it at `.compile()` time.
|
|
47
|
+
*
|
|
48
|
+
* All setter methods return `this` for chaining. No compilation work is performed until
|
|
49
|
+
* `.compile()` is called, ensuring fast construction of mission objects at module load time.
|
|
50
|
+
*/
|
|
51
|
+
export declare class MissionBuilder {
|
|
52
|
+
private readonly name;
|
|
53
|
+
/** @internal Zod or JSON-Schema describing the mission's input payload. */
|
|
54
|
+
private _inputSchema;
|
|
55
|
+
/** @internal Goal prompt template with optional `{{variable}}` placeholders. */
|
|
56
|
+
private _goalTemplate;
|
|
57
|
+
/** @internal Zod or JSON-Schema describing the mission's output artifacts. */
|
|
58
|
+
private _returnsSchema;
|
|
59
|
+
/** @internal Planner configuration (strategy, step budget, iteration caps). */
|
|
60
|
+
private _plannerConfig;
|
|
61
|
+
/** @internal Optional mission-level policy overrides. */
|
|
62
|
+
private _policyConfig;
|
|
63
|
+
/** @internal Declarative anchor node splice descriptors. */
|
|
64
|
+
private _anchors;
|
|
65
|
+
/**
|
|
66
|
+
* @param name - Display name for this mission; passed through to the compiled graph.
|
|
67
|
+
*/
|
|
68
|
+
constructor(name: string);
|
|
69
|
+
/**
|
|
70
|
+
* Declare the input schema for this mission.
|
|
71
|
+
*
|
|
72
|
+
* Accepts a Zod schema object or a plain JSON-Schema `Record<string, unknown>`.
|
|
73
|
+
* The schema is stored in the compiled graph's `stateSchema.input` field and used
|
|
74
|
+
* by the runtime for optional input validation.
|
|
75
|
+
*
|
|
76
|
+
* @param schema - Zod or JSON-Schema object describing the expected input payload.
|
|
77
|
+
*/
|
|
78
|
+
input(schema: any): this;
|
|
79
|
+
/**
|
|
80
|
+
* Set the goal template for this mission.
|
|
81
|
+
*
|
|
82
|
+
* The template is a free-form string that describes what the mission should achieve.
|
|
83
|
+
* It may include `{{variable}}` placeholders that will be interpolated with values
|
|
84
|
+
* from the input payload at plan generation time.
|
|
85
|
+
*
|
|
86
|
+
* Example: `'Research {{topic}} and produce a concise summary'`
|
|
87
|
+
*
|
|
88
|
+
* @param template - Goal prompt template string.
|
|
89
|
+
*/
|
|
90
|
+
goal(template: string): this;
|
|
91
|
+
/**
|
|
92
|
+
* Declare the output (return) schema for this mission.
|
|
93
|
+
*
|
|
94
|
+
* Accepts a Zod schema object or a plain JSON-Schema `Record<string, unknown>`.
|
|
95
|
+
* The schema is stored in the compiled graph's `stateSchema.artifacts` field.
|
|
96
|
+
*
|
|
97
|
+
* @param schema - Zod or JSON-Schema object describing the expected artifact payload.
|
|
98
|
+
*/
|
|
99
|
+
returns(schema: any): this;
|
|
100
|
+
/**
|
|
101
|
+
* Configure the planner used to decompose the goal into execution steps.
|
|
102
|
+
*
|
|
103
|
+
* @param config - Planner settings including strategy name, step budget, and
|
|
104
|
+
* per-node iteration and tool-parallelism caps.
|
|
105
|
+
*/
|
|
106
|
+
planner(config: MissionConfig['plannerConfig']): this;
|
|
107
|
+
/**
|
|
108
|
+
* Apply mission-level policy overrides.
|
|
109
|
+
*
|
|
110
|
+
* Policies declared here are applied to **all** compiled nodes unless a node already
|
|
111
|
+
* carries its own policy declaration. This is the preferred mechanism for setting
|
|
112
|
+
* blanket guardrails, memory consistency modes, or persona settings across a mission.
|
|
113
|
+
*
|
|
114
|
+
* @param config - Policy configuration object.
|
|
115
|
+
*/
|
|
116
|
+
policy(config: NonNullable<MissionConfig['policyConfig']>): this;
|
|
117
|
+
/**
|
|
118
|
+
* Declare an anchor node that will be spliced into the execution order.
|
|
119
|
+
*
|
|
120
|
+
* Anchors let callers inject pre-built `GraphNode` objects (e.g. specialised tool
|
|
121
|
+
* invocations, human-in-the-loop checkpoints, or validation guardrails) at precise
|
|
122
|
+
* positions within the phase-ordered plan without modifying the planner output.
|
|
123
|
+
*
|
|
124
|
+
* @param id - Unique node id assigned to the anchor in the compiled graph.
|
|
125
|
+
* @param node - Pre-built `GraphNode` (from `gmiNode`, `toolNode`, etc.).
|
|
126
|
+
* @param constraints - Placement constraints: phase, `after` / `before` ordering.
|
|
127
|
+
*/
|
|
128
|
+
anchor(id: string, node: GraphNode, constraints: MissionConfig['anchors'][0]['constraints']): this;
|
|
129
|
+
/**
|
|
130
|
+
* Validate configuration and compile this mission into a `CompiledMission`.
|
|
131
|
+
*
|
|
132
|
+
* Required fields: `input`, `goal`, `returns`, `planner`.
|
|
133
|
+
* Throws with a descriptive message if any required field is missing.
|
|
134
|
+
*
|
|
135
|
+
* @param options - Optional compilation overrides.
|
|
136
|
+
* @param options.checkpointStore - Custom checkpoint store; defaults to `InMemoryCheckpointStore`.
|
|
137
|
+
* @returns A `CompiledMission` ready to `invoke()`, `stream()`, or `explain()`.
|
|
138
|
+
* @throws {Error} When required builder fields are missing.
|
|
139
|
+
*/
|
|
140
|
+
compile(options?: {
|
|
141
|
+
checkpointStore?: ICheckpointStore;
|
|
142
|
+
}): CompiledMission;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Execution wrapper for a compiled mission.
|
|
146
|
+
*
|
|
147
|
+
* Lazily re-compiles the IR on each call so that changes to the underlying
|
|
148
|
+
* config are reflected without needing to rebuild the mission object. In
|
|
149
|
+
* production callers typically compile once and reuse the `CompiledMission`
|
|
150
|
+
* for many invocations.
|
|
151
|
+
*/
|
|
152
|
+
export declare class CompiledMission {
|
|
153
|
+
private readonly config;
|
|
154
|
+
private readonly checkpointStore;
|
|
155
|
+
/**
|
|
156
|
+
* @param config - Frozen mission configuration snapshot.
|
|
157
|
+
* @param checkpointStore - Checkpoint persistence backend.
|
|
158
|
+
*/
|
|
159
|
+
constructor(config: MissionConfig, checkpointStore: ICheckpointStore);
|
|
160
|
+
/**
|
|
161
|
+
* Run `MissionCompiler.compile()` to produce a fresh `CompiledExecutionGraph`.
|
|
162
|
+
* Called lazily by each execution method so the IR is always up-to-date.
|
|
163
|
+
*/
|
|
164
|
+
private compileIR;
|
|
165
|
+
/**
|
|
166
|
+
* Create a new `GraphRuntime` bound to this mission's checkpoint store.
|
|
167
|
+
* A fresh runtime is created per invocation to ensure full call isolation.
|
|
168
|
+
*/
|
|
169
|
+
private createRuntime;
|
|
170
|
+
/**
|
|
171
|
+
* Execute the mission to completion and return the final artifacts.
|
|
172
|
+
*
|
|
173
|
+
* @param input - Input payload conforming to the mission's `inputSchema`.
|
|
174
|
+
* @returns The final `GraphState.artifacts` value once all nodes have completed.
|
|
175
|
+
*/
|
|
176
|
+
invoke(input: unknown): Promise<unknown>;
|
|
177
|
+
/**
|
|
178
|
+
* Execute the mission while yielding `GraphEvent` values at each step.
|
|
179
|
+
*
|
|
180
|
+
* Useful for streaming progress updates to a UI or logging pipeline.
|
|
181
|
+
*
|
|
182
|
+
* @param input - Input payload conforming to the mission's `inputSchema`.
|
|
183
|
+
* @yields `GraphEvent` objects emitted by the runtime at each node lifecycle point.
|
|
184
|
+
*/
|
|
185
|
+
stream(input: unknown): AsyncIterable<GraphEvent>;
|
|
186
|
+
/**
|
|
187
|
+
* Resume a previously interrupted run from its latest checkpoint.
|
|
188
|
+
*
|
|
189
|
+
* @param checkpointId - Id of the checkpoint to restore (from `GraphState.checkpointId`).
|
|
190
|
+
* @param _patch - Optional partial `GraphState` to merge before resuming (reserved).
|
|
191
|
+
* @returns The final `GraphState.artifacts` value once execution completes.
|
|
192
|
+
*/
|
|
193
|
+
resume(checkpointId: string, _patch?: Partial<GraphState>): Promise<unknown>;
|
|
194
|
+
/**
|
|
195
|
+
* Retrieve a diagnostic snapshot of a completed or in-progress run.
|
|
196
|
+
*
|
|
197
|
+
* @param _runId - Run id assigned by the runtime at invocation time.
|
|
198
|
+
* @returns A `RunInspection`-shaped object (stub — full implementation in Task 17+).
|
|
199
|
+
*/
|
|
200
|
+
inspect(_runId: string): Promise<unknown>;
|
|
201
|
+
/**
|
|
202
|
+
* Return a human-readable execution plan without actually running the mission.
|
|
203
|
+
*
|
|
204
|
+
* Useful for debugging, testing, and displaying "what will happen" summaries in UIs.
|
|
205
|
+
*
|
|
206
|
+
* @param _input - Input payload (currently unused; reserved for future goal interpolation).
|
|
207
|
+
* @returns An object containing:
|
|
208
|
+
* - `steps`: flat array of `{ id, type, config }` descriptors for each node.
|
|
209
|
+
* - `ir`: the full `CompiledExecutionGraph` for deeper inspection.
|
|
210
|
+
*/
|
|
211
|
+
explain(_input: unknown): Promise<{
|
|
212
|
+
steps: any[];
|
|
213
|
+
ir: CompiledExecutionGraph;
|
|
214
|
+
}>;
|
|
215
|
+
/**
|
|
216
|
+
* Export the compiled plan as a static `CompiledExecutionGraph`.
|
|
217
|
+
*
|
|
218
|
+
* Allows callers to "graduate" a dynamically-planned mission to a fixed workflow or
|
|
219
|
+
* graph for performance-sensitive deployments where replanning is not desired.
|
|
220
|
+
*
|
|
221
|
+
* @returns The compiled IR, suitable for passing directly to `GraphRuntime`.
|
|
222
|
+
*/
|
|
223
|
+
toWorkflow(): CompiledExecutionGraph;
|
|
224
|
+
/**
|
|
225
|
+
* Alias of `toWorkflow()` — returns the compiled `CompiledExecutionGraph` IR.
|
|
226
|
+
*
|
|
227
|
+
* @returns The compiled IR.
|
|
228
|
+
*/
|
|
229
|
+
toIR(): CompiledExecutionGraph;
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=MissionBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MissionBuilder.d.ts","sourceRoot":"","sources":["../../../src/orchestration/builders/MissionBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CA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