@framers/agentos 0.1.69 → 0.1.70
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 +95 -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,321 @@
|
|
|
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 { InMemoryCheckpointStore } from '../checkpoint/InMemoryCheckpointStore.js';
|
|
24
|
+
import { MissionCompiler } from '../compiler/MissionCompiler.js';
|
|
25
|
+
import { GraphRuntime } from '../runtime/GraphRuntime.js';
|
|
26
|
+
import { NodeExecutor } from '../runtime/NodeExecutor.js';
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Factory function
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
/**
|
|
31
|
+
* Create a new `MissionBuilder` for the named mission.
|
|
32
|
+
*
|
|
33
|
+
* @param name - Human-readable mission name; used as the compiled graph's display name
|
|
34
|
+
* and as a stable slug prefix for run ids and checkpoint keys.
|
|
35
|
+
* @returns A fresh `MissionBuilder` instance ready to be configured.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const m = mission('summarise-article')
|
|
40
|
+
* .input(inputSchema)
|
|
41
|
+
* .goal('Summarise {{url}} in three bullet points')
|
|
42
|
+
* .returns(outputSchema)
|
|
43
|
+
* .planner({ strategy: 'linear', maxSteps: 4 })
|
|
44
|
+
* .compile();
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export function mission(name) {
|
|
48
|
+
return new MissionBuilder(name);
|
|
49
|
+
}
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
// MissionBuilder
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
/**
|
|
54
|
+
* Fluent builder that collects mission configuration and validates it at `.compile()` time.
|
|
55
|
+
*
|
|
56
|
+
* All setter methods return `this` for chaining. No compilation work is performed until
|
|
57
|
+
* `.compile()` is called, ensuring fast construction of mission objects at module load time.
|
|
58
|
+
*/
|
|
59
|
+
export class MissionBuilder {
|
|
60
|
+
/**
|
|
61
|
+
* @param name - Display name for this mission; passed through to the compiled graph.
|
|
62
|
+
*/
|
|
63
|
+
constructor(name) {
|
|
64
|
+
this.name = name;
|
|
65
|
+
/** @internal Goal prompt template with optional `{{variable}}` placeholders. */
|
|
66
|
+
this._goalTemplate = '';
|
|
67
|
+
/** @internal Declarative anchor node splice descriptors. */
|
|
68
|
+
this._anchors = [];
|
|
69
|
+
}
|
|
70
|
+
// -------------------------------------------------------------------------
|
|
71
|
+
// Builder setters
|
|
72
|
+
// -------------------------------------------------------------------------
|
|
73
|
+
/**
|
|
74
|
+
* Declare the input schema for this mission.
|
|
75
|
+
*
|
|
76
|
+
* Accepts a Zod schema object or a plain JSON-Schema `Record<string, unknown>`.
|
|
77
|
+
* The schema is stored in the compiled graph's `stateSchema.input` field and used
|
|
78
|
+
* by the runtime for optional input validation.
|
|
79
|
+
*
|
|
80
|
+
* @param schema - Zod or JSON-Schema object describing the expected input payload.
|
|
81
|
+
*/
|
|
82
|
+
input(schema) {
|
|
83
|
+
this._inputSchema = schema;
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Set the goal template for this mission.
|
|
88
|
+
*
|
|
89
|
+
* The template is a free-form string that describes what the mission should achieve.
|
|
90
|
+
* It may include `{{variable}}` placeholders that will be interpolated with values
|
|
91
|
+
* from the input payload at plan generation time.
|
|
92
|
+
*
|
|
93
|
+
* Example: `'Research {{topic}} and produce a concise summary'`
|
|
94
|
+
*
|
|
95
|
+
* @param template - Goal prompt template string.
|
|
96
|
+
*/
|
|
97
|
+
goal(template) {
|
|
98
|
+
this._goalTemplate = template;
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Declare the output (return) schema for this mission.
|
|
103
|
+
*
|
|
104
|
+
* Accepts a Zod schema object or a plain JSON-Schema `Record<string, unknown>`.
|
|
105
|
+
* The schema is stored in the compiled graph's `stateSchema.artifacts` field.
|
|
106
|
+
*
|
|
107
|
+
* @param schema - Zod or JSON-Schema object describing the expected artifact payload.
|
|
108
|
+
*/
|
|
109
|
+
returns(schema) {
|
|
110
|
+
this._returnsSchema = schema;
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Configure the planner used to decompose the goal into execution steps.
|
|
115
|
+
*
|
|
116
|
+
* @param config - Planner settings including strategy name, step budget, and
|
|
117
|
+
* per-node iteration and tool-parallelism caps.
|
|
118
|
+
*/
|
|
119
|
+
planner(config) {
|
|
120
|
+
this._plannerConfig = config;
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Apply mission-level policy overrides.
|
|
125
|
+
*
|
|
126
|
+
* Policies declared here are applied to **all** compiled nodes unless a node already
|
|
127
|
+
* carries its own policy declaration. This is the preferred mechanism for setting
|
|
128
|
+
* blanket guardrails, memory consistency modes, or persona settings across a mission.
|
|
129
|
+
*
|
|
130
|
+
* @param config - Policy configuration object.
|
|
131
|
+
*/
|
|
132
|
+
policy(config) {
|
|
133
|
+
this._policyConfig = config;
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Declare an anchor node that will be spliced into the execution order.
|
|
138
|
+
*
|
|
139
|
+
* Anchors let callers inject pre-built `GraphNode` objects (e.g. specialised tool
|
|
140
|
+
* invocations, human-in-the-loop checkpoints, or validation guardrails) at precise
|
|
141
|
+
* positions within the phase-ordered plan without modifying the planner output.
|
|
142
|
+
*
|
|
143
|
+
* @param id - Unique node id assigned to the anchor in the compiled graph.
|
|
144
|
+
* @param node - Pre-built `GraphNode` (from `gmiNode`, `toolNode`, etc.).
|
|
145
|
+
* @param constraints - Placement constraints: phase, `after` / `before` ordering.
|
|
146
|
+
*/
|
|
147
|
+
anchor(id, node, constraints) {
|
|
148
|
+
this._anchors.push({ id, node, constraints });
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
// -------------------------------------------------------------------------
|
|
152
|
+
// Compile
|
|
153
|
+
// -------------------------------------------------------------------------
|
|
154
|
+
/**
|
|
155
|
+
* Validate configuration and compile this mission into a `CompiledMission`.
|
|
156
|
+
*
|
|
157
|
+
* Required fields: `input`, `goal`, `returns`, `planner`.
|
|
158
|
+
* Throws with a descriptive message if any required field is missing.
|
|
159
|
+
*
|
|
160
|
+
* @param options - Optional compilation overrides.
|
|
161
|
+
* @param options.checkpointStore - Custom checkpoint store; defaults to `InMemoryCheckpointStore`.
|
|
162
|
+
* @returns A `CompiledMission` ready to `invoke()`, `stream()`, or `explain()`.
|
|
163
|
+
* @throws {Error} When required builder fields are missing.
|
|
164
|
+
*/
|
|
165
|
+
compile(options) {
|
|
166
|
+
if (!this._inputSchema) {
|
|
167
|
+
throw new Error('mission() requires .input() — input schema is required');
|
|
168
|
+
}
|
|
169
|
+
if (!this._goalTemplate) {
|
|
170
|
+
throw new Error('mission() requires .goal() — goal template is required');
|
|
171
|
+
}
|
|
172
|
+
if (!this._returnsSchema) {
|
|
173
|
+
throw new Error('mission() requires .returns() — returns schema is required');
|
|
174
|
+
}
|
|
175
|
+
if (!this._plannerConfig) {
|
|
176
|
+
throw new Error('mission() requires .planner() — planner config is required');
|
|
177
|
+
}
|
|
178
|
+
const config = {
|
|
179
|
+
name: this.name,
|
|
180
|
+
inputSchema: this._inputSchema,
|
|
181
|
+
goalTemplate: this._goalTemplate,
|
|
182
|
+
returnsSchema: this._returnsSchema,
|
|
183
|
+
plannerConfig: this._plannerConfig,
|
|
184
|
+
policyConfig: this._policyConfig,
|
|
185
|
+
anchors: this._anchors,
|
|
186
|
+
};
|
|
187
|
+
const store = options?.checkpointStore ?? new InMemoryCheckpointStore();
|
|
188
|
+
return new CompiledMission(config, store);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// ---------------------------------------------------------------------------
|
|
192
|
+
// CompiledMission
|
|
193
|
+
// ---------------------------------------------------------------------------
|
|
194
|
+
/**
|
|
195
|
+
* Execution wrapper for a compiled mission.
|
|
196
|
+
*
|
|
197
|
+
* Lazily re-compiles the IR on each call so that changes to the underlying
|
|
198
|
+
* config are reflected without needing to rebuild the mission object. In
|
|
199
|
+
* production callers typically compile once and reuse the `CompiledMission`
|
|
200
|
+
* for many invocations.
|
|
201
|
+
*/
|
|
202
|
+
export class CompiledMission {
|
|
203
|
+
/**
|
|
204
|
+
* @param config - Frozen mission configuration snapshot.
|
|
205
|
+
* @param checkpointStore - Checkpoint persistence backend.
|
|
206
|
+
*/
|
|
207
|
+
constructor(config, checkpointStore) {
|
|
208
|
+
this.config = config;
|
|
209
|
+
this.checkpointStore = checkpointStore;
|
|
210
|
+
}
|
|
211
|
+
// -------------------------------------------------------------------------
|
|
212
|
+
// Private helpers
|
|
213
|
+
// -------------------------------------------------------------------------
|
|
214
|
+
/**
|
|
215
|
+
* Run `MissionCompiler.compile()` to produce a fresh `CompiledExecutionGraph`.
|
|
216
|
+
* Called lazily by each execution method so the IR is always up-to-date.
|
|
217
|
+
*/
|
|
218
|
+
compileIR() {
|
|
219
|
+
return MissionCompiler.compile(this.config);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Create a new `GraphRuntime` bound to this mission's checkpoint store.
|
|
223
|
+
* A fresh runtime is created per invocation to ensure full call isolation.
|
|
224
|
+
*/
|
|
225
|
+
createRuntime() {
|
|
226
|
+
return new GraphRuntime({
|
|
227
|
+
checkpointStore: this.checkpointStore,
|
|
228
|
+
nodeExecutor: new NodeExecutor({}),
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
// -------------------------------------------------------------------------
|
|
232
|
+
// Execution API
|
|
233
|
+
// -------------------------------------------------------------------------
|
|
234
|
+
/**
|
|
235
|
+
* Execute the mission to completion and return the final artifacts.
|
|
236
|
+
*
|
|
237
|
+
* @param input - Input payload conforming to the mission's `inputSchema`.
|
|
238
|
+
* @returns The final `GraphState.artifacts` value once all nodes have completed.
|
|
239
|
+
*/
|
|
240
|
+
async invoke(input) {
|
|
241
|
+
const ir = this.compileIR();
|
|
242
|
+
return this.createRuntime().invoke(ir, input);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Execute the mission while yielding `GraphEvent` values at each step.
|
|
246
|
+
*
|
|
247
|
+
* Useful for streaming progress updates to a UI or logging pipeline.
|
|
248
|
+
*
|
|
249
|
+
* @param input - Input payload conforming to the mission's `inputSchema`.
|
|
250
|
+
* @yields `GraphEvent` objects emitted by the runtime at each node lifecycle point.
|
|
251
|
+
*/
|
|
252
|
+
async *stream(input) {
|
|
253
|
+
const ir = this.compileIR();
|
|
254
|
+
yield* this.createRuntime().stream(ir, input);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Resume a previously interrupted run from its latest checkpoint.
|
|
258
|
+
*
|
|
259
|
+
* @param checkpointId - Id of the checkpoint to restore (from `GraphState.checkpointId`).
|
|
260
|
+
* @param _patch - Optional partial `GraphState` to merge before resuming (reserved).
|
|
261
|
+
* @returns The final `GraphState.artifacts` value once execution completes.
|
|
262
|
+
*/
|
|
263
|
+
async resume(checkpointId, _patch) {
|
|
264
|
+
const ir = this.compileIR();
|
|
265
|
+
return this.createRuntime().resume(ir, checkpointId);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Retrieve a diagnostic snapshot of a completed or in-progress run.
|
|
269
|
+
*
|
|
270
|
+
* @param _runId - Run id assigned by the runtime at invocation time.
|
|
271
|
+
* @returns A `RunInspection`-shaped object (stub — full implementation in Task 17+).
|
|
272
|
+
*/
|
|
273
|
+
async inspect(_runId) {
|
|
274
|
+
// Stub — RunInspection API wired in a future task
|
|
275
|
+
return {};
|
|
276
|
+
}
|
|
277
|
+
// -------------------------------------------------------------------------
|
|
278
|
+
// Introspection utilities
|
|
279
|
+
// -------------------------------------------------------------------------
|
|
280
|
+
/**
|
|
281
|
+
* Return a human-readable execution plan without actually running the mission.
|
|
282
|
+
*
|
|
283
|
+
* Useful for debugging, testing, and displaying "what will happen" summaries in UIs.
|
|
284
|
+
*
|
|
285
|
+
* @param _input - Input payload (currently unused; reserved for future goal interpolation).
|
|
286
|
+
* @returns An object containing:
|
|
287
|
+
* - `steps`: flat array of `{ id, type, config }` descriptors for each node.
|
|
288
|
+
* - `ir`: the full `CompiledExecutionGraph` for deeper inspection.
|
|
289
|
+
*/
|
|
290
|
+
async explain(_input) {
|
|
291
|
+
const ir = this.compileIR();
|
|
292
|
+
return {
|
|
293
|
+
steps: ir.nodes.map(n => ({
|
|
294
|
+
id: n.id,
|
|
295
|
+
type: n.type,
|
|
296
|
+
config: n.executorConfig,
|
|
297
|
+
})),
|
|
298
|
+
ir,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Export the compiled plan as a static `CompiledExecutionGraph`.
|
|
303
|
+
*
|
|
304
|
+
* Allows callers to "graduate" a dynamically-planned mission to a fixed workflow or
|
|
305
|
+
* graph for performance-sensitive deployments where replanning is not desired.
|
|
306
|
+
*
|
|
307
|
+
* @returns The compiled IR, suitable for passing directly to `GraphRuntime`.
|
|
308
|
+
*/
|
|
309
|
+
toWorkflow() {
|
|
310
|
+
return this.compileIR();
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Alias of `toWorkflow()` — returns the compiled `CompiledExecutionGraph` IR.
|
|
314
|
+
*
|
|
315
|
+
* @returns The compiled IR.
|
|
316
|
+
*/
|
|
317
|
+
toIR() {
|
|
318
|
+
return this.compileIR();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
//# sourceMappingURL=MissionBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MissionBuilder.js","sourceRoot":"","sources":["../../../src/orchestration/builders/MissionBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAE,eAAe,EAAsB,MAAM,gCAAgC,CAAC;AACrF,OAA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B;IAC1B,4EAA4E;IAE5E;;;;;;;;;OASG;IACH,KAAK,CAAC,OAAO,CAAC,MAAe;QAC3B,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC5B,OAAO;YACL,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBACxB,EAAE,EAAE,CAAC,CAAC,EAAE;gBACR,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,MAAM,EAAE,CAAC,CAAC,cAAc;aACzB,CAAC,CAAC;YACH,EAAE;SACH,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file WorkflowBuilder.ts
|
|
3
|
+
* @description Fluent DSL for authoring deterministic, acyclic workflow graphs.
|
|
4
|
+
*
|
|
5
|
+
* `workflow()` is the sequential/pipeline-oriented authoring API in the AgentOS
|
|
6
|
+
* Unified Orchestration Layer. Unlike `AgentGraph` (which allows arbitrary directed
|
|
7
|
+
* graphs including cycles), every workflow is a strict DAG — cycles are detected and
|
|
8
|
+
* rejected at compile time.
|
|
9
|
+
*
|
|
10
|
+
* Supported step primitives:
|
|
11
|
+
* - `step()` / `then()` — a single named node (tool, GMI, or human).
|
|
12
|
+
* - `branch()` — a router + fan-out; branches rejoin at the next step.
|
|
13
|
+
* - `parallel()` — fan-out to N concurrent nodes that rejoin via merge reducers.
|
|
14
|
+
*
|
|
15
|
+
* All GMI steps default to `executionMode: 'single_turn'` to keep workflows
|
|
16
|
+
* deterministic and cost-bounded.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const wf = workflow('summarize-and-tag')
|
|
21
|
+
* .input(z.object({ text: z.string() }))
|
|
22
|
+
* .returns(z.object({ summary: z.string(), tags: z.array(z.string()) }))
|
|
23
|
+
* .step('fetch', { tool: 'web_fetch' })
|
|
24
|
+
* .step('summarize', { gmi: { instructions: 'Summarize the document.' } })
|
|
25
|
+
* .compile();
|
|
26
|
+
*
|
|
27
|
+
* const result = await wf.invoke({ text: 'hello world' });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
import type { CompiledExecutionGraph, MemoryPolicy, DiscoveryPolicy, GuardrailPolicy, BuiltinReducer, ReducerFn } from '../ir/types.js';
|
|
31
|
+
import type { ICheckpointStore } from '../checkpoint/ICheckpointStore.js';
|
|
32
|
+
import type { GraphEvent } from '../events/GraphEvent.js';
|
|
33
|
+
/**
|
|
34
|
+
* Configuration for a single workflow step node.
|
|
35
|
+
*
|
|
36
|
+
* Exactly one of `tool`, `gmi`, `human`, `extension`, or `subgraph` must be provided
|
|
37
|
+
* to specify the execution strategy. All remaining fields are optional policies.
|
|
38
|
+
*/
|
|
39
|
+
export interface StepConfig {
|
|
40
|
+
/** Name of a registered `ITool` to invoke. */
|
|
41
|
+
tool?: string;
|
|
42
|
+
/**
|
|
43
|
+
* General Model Invocation config. `executionMode` is always overridden to
|
|
44
|
+
* `'single_turn'` inside a workflow to keep execution deterministic.
|
|
45
|
+
*/
|
|
46
|
+
gmi?: {
|
|
47
|
+
instructions: string;
|
|
48
|
+
/** Ignored at runtime — always coerced to `'single_turn'` by the workflow compiler. */
|
|
49
|
+
executionMode?: 'single_turn';
|
|
50
|
+
/** Hard cap on LLM output tokens for this step. */
|
|
51
|
+
maxTokens?: number;
|
|
52
|
+
};
|
|
53
|
+
/** Human-in-the-loop step; suspends the run until a human provides a response. */
|
|
54
|
+
human?: {
|
|
55
|
+
prompt: string;
|
|
56
|
+
};
|
|
57
|
+
/** Call a method on a registered extension. */
|
|
58
|
+
extension?: {
|
|
59
|
+
extensionId: string;
|
|
60
|
+
method: string;
|
|
61
|
+
};
|
|
62
|
+
/** Delegate to a previously compiled sub-workflow or agent graph. */
|
|
63
|
+
subgraph?: CompiledExecutionGraph;
|
|
64
|
+
/** Memory read/write policy for this step. */
|
|
65
|
+
memory?: MemoryPolicy;
|
|
66
|
+
/** Capability discovery policy applied before execution. */
|
|
67
|
+
discovery?: DiscoveryPolicy;
|
|
68
|
+
/** Declarative guardrail policy applied to input and/or output. */
|
|
69
|
+
guardrails?: GuardrailPolicy;
|
|
70
|
+
/** When `true`, execution suspends and waits for human approval before proceeding. */
|
|
71
|
+
requiresApproval?: boolean;
|
|
72
|
+
/** What to do when the step fails. */
|
|
73
|
+
onFailure?: 'abort' | 'skip' | 'retry';
|
|
74
|
+
/** Automatic retry configuration. Only used when `onFailure` is `'retry'`. */
|
|
75
|
+
retryPolicy?: {
|
|
76
|
+
maxAttempts: number;
|
|
77
|
+
backoff: 'fixed' | 'linear' | 'exponential';
|
|
78
|
+
backoffMs: number;
|
|
79
|
+
};
|
|
80
|
+
/** Maximum wall-clock execution time in milliseconds. */
|
|
81
|
+
timeout?: number;
|
|
82
|
+
/** Side-effect classification used by the runtime for scheduling decisions. */
|
|
83
|
+
effectClass?: 'pure' | 'read' | 'write' | 'external' | 'human';
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Create a new `WorkflowBuilder` with the given human-readable name.
|
|
87
|
+
*
|
|
88
|
+
* @param name - Display name embedded in the compiled `CompiledExecutionGraph`.
|
|
89
|
+
* @returns A fresh `WorkflowBuilder` instance.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* const wf = workflow('my-pipeline')
|
|
94
|
+
* .input(z.object({ query: z.string() }))
|
|
95
|
+
* .returns(z.object({ answer: z.string() }))
|
|
96
|
+
* .step('search', { tool: 'web_search' })
|
|
97
|
+
* .step('answer', { gmi: { instructions: 'Answer the question.' } })
|
|
98
|
+
* .compile();
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare function workflow(name: string): WorkflowBuilder;
|
|
102
|
+
/**
|
|
103
|
+
* Fluent builder for deterministic DAG workflows.
|
|
104
|
+
*
|
|
105
|
+
* Steps are appended in declaration order and connected sequentially. Branch and
|
|
106
|
+
* parallel primitives fan out and automatically rejoin at the next declared step.
|
|
107
|
+
*
|
|
108
|
+
* Call `.compile()` to validate the graph (must be acyclic) and obtain a
|
|
109
|
+
* `CompiledWorkflow` ready for `invoke()`, `stream()`, or `resume()`.
|
|
110
|
+
*/
|
|
111
|
+
export declare class WorkflowBuilder {
|
|
112
|
+
/** Zod schema (or any plain object) representing `GraphState.input`. */
|
|
113
|
+
private inputSchema;
|
|
114
|
+
/** Zod schema (or any plain object) representing `GraphState.artifacts`. */
|
|
115
|
+
private returnsSchema;
|
|
116
|
+
/** Ordered list of steps declared by the author. */
|
|
117
|
+
private steps;
|
|
118
|
+
/** Human-readable name forwarded to the compiled graph. */
|
|
119
|
+
private readonly name;
|
|
120
|
+
/**
|
|
121
|
+
* @param name - Human-readable workflow name.
|
|
122
|
+
*/
|
|
123
|
+
constructor(name: string);
|
|
124
|
+
/**
|
|
125
|
+
* Declare the input schema for this workflow.
|
|
126
|
+
*
|
|
127
|
+
* Accepts a Zod schema or any plain object; the value is forwarded to
|
|
128
|
+
* `GraphCompiler` which lowers it to JSON Schema via `lowerZodToJsonSchema`.
|
|
129
|
+
*
|
|
130
|
+
* @param schema - Input schema (Zod instance or plain JSON Schema object).
|
|
131
|
+
*/
|
|
132
|
+
input(schema: any): this;
|
|
133
|
+
/**
|
|
134
|
+
* Declare the return (output artifacts) schema for this workflow.
|
|
135
|
+
*
|
|
136
|
+
* @param schema - Output schema (Zod instance or plain JSON Schema object).
|
|
137
|
+
*/
|
|
138
|
+
returns(schema: any): this;
|
|
139
|
+
/**
|
|
140
|
+
* Append a single named step to the workflow.
|
|
141
|
+
*
|
|
142
|
+
* The step is connected from all current tail nodes and becomes the new
|
|
143
|
+
* single-element tail after it is added.
|
|
144
|
+
*
|
|
145
|
+
* @param id - Unique step identifier within this workflow.
|
|
146
|
+
* @param config - Execution and policy configuration for the step.
|
|
147
|
+
*/
|
|
148
|
+
step(id: string, config: StepConfig): this;
|
|
149
|
+
/**
|
|
150
|
+
* Alias for `step()` — reads more naturally when chaining sequential steps.
|
|
151
|
+
*
|
|
152
|
+
* @param id - Unique step identifier.
|
|
153
|
+
* @param config - Execution and policy configuration.
|
|
154
|
+
*/
|
|
155
|
+
then(id: string, config: StepConfig): this;
|
|
156
|
+
/**
|
|
157
|
+
* Append a conditional branch to the workflow.
|
|
158
|
+
*
|
|
159
|
+
* The `condition` function is evaluated at runtime against `GraphState` and must
|
|
160
|
+
* return one of the keys of `routes`. Each route becomes its own branch node; all
|
|
161
|
+
* branches become the collective tail that the next declared step connects from.
|
|
162
|
+
*
|
|
163
|
+
* @param condition - Routing function; return value must match a key in `routes`.
|
|
164
|
+
* @param routes - Map of route key → step config for each branch arm.
|
|
165
|
+
*/
|
|
166
|
+
branch(condition: (state: any) => string, routes: Record<string, StepConfig>): this;
|
|
167
|
+
/**
|
|
168
|
+
* Append a parallel fan-out to the workflow.
|
|
169
|
+
*
|
|
170
|
+
* All `steps` execute concurrently (subject to runtime scheduling). After all
|
|
171
|
+
* branches complete, their outputs are merged using the `join.merge` reducers.
|
|
172
|
+
* The parallel branch nodes collectively become the new tail.
|
|
173
|
+
*
|
|
174
|
+
* @param steps - Array of step configs to execute concurrently.
|
|
175
|
+
* @param join - Fan-in configuration including merge strategy and reducers.
|
|
176
|
+
*/
|
|
177
|
+
parallel(steps: StepConfig[], join: {
|
|
178
|
+
strategy: 'all' | 'any' | 'quorum';
|
|
179
|
+
quorumCount?: number;
|
|
180
|
+
merge: Record<string, BuiltinReducer | ReducerFn>;
|
|
181
|
+
timeout?: number;
|
|
182
|
+
}): this;
|
|
183
|
+
/**
|
|
184
|
+
* Compile the workflow into an executable `CompiledWorkflow`.
|
|
185
|
+
*
|
|
186
|
+
* Compilation steps:
|
|
187
|
+
* 1. Validate that `.input()` and `.returns()` schemas were declared.
|
|
188
|
+
* 2. Lower each `InternalStep` into `GraphNode` + `GraphEdge` IR objects,
|
|
189
|
+
* threading `tailNodeIds` to connect steps sequentially.
|
|
190
|
+
* 3. Connect all final tail nodes to `END`.
|
|
191
|
+
* 4. Run `GraphCompiler.compile()` to produce a `CompiledExecutionGraph`.
|
|
192
|
+
* 5. Run `GraphValidator.validate()` with `{ requireAcyclic: true }` — throws on cycle.
|
|
193
|
+
* 6. Wrap in a `CompiledWorkflow` with a `GraphRuntime` backed by the given store.
|
|
194
|
+
*
|
|
195
|
+
* @param options - Optional compilation options.
|
|
196
|
+
* @param options.checkpointStore - Custom checkpoint backend; defaults to `InMemoryCheckpointStore`.
|
|
197
|
+
* @throws {Error} When `.input()` or `.returns()` was not called.
|
|
198
|
+
* @throws {Error} When the compiled graph contains a cycle (should never happen via this API).
|
|
199
|
+
*/
|
|
200
|
+
compile(options?: {
|
|
201
|
+
checkpointStore?: ICheckpointStore;
|
|
202
|
+
}): CompiledWorkflow;
|
|
203
|
+
/**
|
|
204
|
+
* Lower a `StepConfig` into a `GraphNode` with the given `id`.
|
|
205
|
+
*
|
|
206
|
+
* Priority order for executor type selection:
|
|
207
|
+
* `tool` → `gmi` → `human` → `extension` → `subgraph` → fallback tool node.
|
|
208
|
+
*
|
|
209
|
+
* GMI nodes always receive `executionMode: 'single_turn'` regardless of what
|
|
210
|
+
* the author specified in `config.gmi.executionMode`.
|
|
211
|
+
*
|
|
212
|
+
* @param id - Node id to assign.
|
|
213
|
+
* @param config - Caller-supplied step configuration.
|
|
214
|
+
* @returns A fully constructed `GraphNode` ready for the IR.
|
|
215
|
+
*/
|
|
216
|
+
private configToNode;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* An execution-ready workflow produced by `WorkflowBuilder.compile()`.
|
|
220
|
+
*
|
|
221
|
+
* Wraps a `CompiledExecutionGraph` and a `GraphRuntime`, exposing the same
|
|
222
|
+
* three execution modes as the raw runtime:
|
|
223
|
+
*
|
|
224
|
+
* - `invoke(input)` — run to completion and return final artifacts.
|
|
225
|
+
* - `stream(input)` — run while yielding `GraphEvent` values at each step.
|
|
226
|
+
* - `resume(checkpointId)` — restore an interrupted run from a checkpoint.
|
|
227
|
+
*/
|
|
228
|
+
export declare class CompiledWorkflow {
|
|
229
|
+
private readonly ir;
|
|
230
|
+
/** Underlying execution runtime. */
|
|
231
|
+
private readonly runtime;
|
|
232
|
+
/**
|
|
233
|
+
* @param ir - The compiled execution graph (produced by `GraphCompiler`).
|
|
234
|
+
* @param checkpointStore - Checkpoint persistence backend.
|
|
235
|
+
*/
|
|
236
|
+
constructor(ir: CompiledExecutionGraph, checkpointStore: ICheckpointStore);
|
|
237
|
+
/**
|
|
238
|
+
* Execute the workflow to completion and return the final `artifacts` payload.
|
|
239
|
+
*
|
|
240
|
+
* @param input - Must conform to the schema declared via `.input()`.
|
|
241
|
+
* @returns The `GraphState.artifacts` value after all nodes complete.
|
|
242
|
+
*/
|
|
243
|
+
invoke(input: unknown): Promise<unknown>;
|
|
244
|
+
/**
|
|
245
|
+
* Execute the workflow while yielding `GraphEvent` values at each step boundary.
|
|
246
|
+
*
|
|
247
|
+
* @param input - Must conform to the schema declared via `.input()`.
|
|
248
|
+
* @yields {GraphEvent} Runtime events in causal order.
|
|
249
|
+
*/
|
|
250
|
+
stream(input: unknown): AsyncIterable<GraphEvent>;
|
|
251
|
+
/**
|
|
252
|
+
* Resume a previously interrupted workflow run from its latest checkpoint.
|
|
253
|
+
*
|
|
254
|
+
* @param checkpointId - The run identifier returned when the original run was interrupted.
|
|
255
|
+
* @returns The final `GraphState.artifacts` value after resumption completes.
|
|
256
|
+
*/
|
|
257
|
+
resume(checkpointId: string): Promise<unknown>;
|
|
258
|
+
/**
|
|
259
|
+
* Expose the compiled IR for inspection, serialisation, or subgraph composition.
|
|
260
|
+
*
|
|
261
|
+
* @returns The underlying `CompiledExecutionGraph`.
|
|
262
|
+
*/
|
|
263
|
+
toIR(): CompiledExecutionGraph;
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=WorkflowBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkflowBuilder.d.ts","sourceRoot":"","sources":["../../../src/orchestration/builders/WorkflowBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAGV,sBAAsB,EAEtB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,cAAc,EACd,SAAS,EACV,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAM1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM1D;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,GAAG,CAAC,EAAE;QACJ,YAAY,EAAE,MAAM,CAAC;QACrB,uFAAuF;QACvF,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,mDAAmD;QACnD,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,kFAAkF;IAClF,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3B,+CAA+C;IAC/C,SAAS,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACpD,qEAAqE;IACrE,QAAQ,CAAC,EAAE,sBAAsB,CAAC;IAClC,8CAA8C;IAC9C,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,mEAAmE;IACnE,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,sFAAsF;IACtF,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,sCAAs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