@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.
Files changed (128) hide show
  1. package/dist/api/agent.d.ts +98 -2
  2. package/dist/api/agent.d.ts.map +1 -1
  3. package/dist/api/agent.js +64 -9
  4. package/dist/api/agent.js.map +1 -1
  5. package/dist/api/generateImage.d.ts +109 -0
  6. package/dist/api/generateImage.d.ts.map +1 -0
  7. package/dist/api/generateImage.js +41 -0
  8. package/dist/api/generateImage.js.map +1 -0
  9. package/dist/api/generateText.d.ts +73 -3
  10. package/dist/api/generateText.d.ts.map +1 -1
  11. package/dist/api/generateText.js +29 -4
  12. package/dist/api/generateText.js.map +1 -1
  13. package/dist/api/model.d.ts +74 -4
  14. package/dist/api/model.d.ts.map +1 -1
  15. package/dist/api/model.js +79 -5
  16. package/dist/api/model.js.map +1 -1
  17. package/dist/api/streamText.d.ts +37 -1
  18. package/dist/api/streamText.d.ts.map +1 -1
  19. package/dist/api/streamText.js +188 -49
  20. package/dist/api/streamText.js.map +1 -1
  21. package/dist/api/toolAdapter.d.ts +58 -0
  22. package/dist/api/toolAdapter.d.ts.map +1 -0
  23. package/dist/api/{tool-adapter.js → toolAdapter.js} +24 -2
  24. package/dist/api/toolAdapter.js.map +1 -0
  25. package/dist/index.d.ts +5 -2
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +5 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/orchestration/builders/AgentGraph.d.ts +250 -0
  30. package/dist/orchestration/builders/AgentGraph.d.ts.map +1 -0
  31. package/dist/orchestration/builders/AgentGraph.js +338 -0
  32. package/dist/orchestration/builders/AgentGraph.js.map +1 -0
  33. package/dist/orchestration/builders/MissionBuilder.d.ts +231 -0
  34. package/dist/orchestration/builders/MissionBuilder.d.ts.map +1 -0
  35. package/dist/orchestration/builders/MissionBuilder.js +321 -0
  36. package/dist/orchestration/builders/MissionBuilder.js.map +1 -0
  37. package/dist/orchestration/builders/WorkflowBuilder.d.ts +265 -0
  38. package/dist/orchestration/builders/WorkflowBuilder.d.ts.map +1 -0
  39. package/dist/orchestration/builders/WorkflowBuilder.js +472 -0
  40. package/dist/orchestration/builders/WorkflowBuilder.js.map +1 -0
  41. package/dist/orchestration/builders/index.d.ts +7 -0
  42. package/dist/orchestration/builders/index.d.ts.map +1 -0
  43. package/dist/orchestration/builders/index.js +5 -0
  44. package/dist/orchestration/builders/index.js.map +1 -0
  45. package/dist/orchestration/builders/nodes.d.ts +36 -0
  46. package/dist/orchestration/builders/nodes.d.ts.map +1 -0
  47. package/dist/orchestration/builders/nodes.js +98 -0
  48. package/dist/orchestration/builders/nodes.js.map +1 -0
  49. package/dist/orchestration/checkpoint/ICheckpointStore.d.ts +152 -0
  50. package/dist/orchestration/checkpoint/ICheckpointStore.d.ts.map +1 -0
  51. package/dist/orchestration/checkpoint/ICheckpointStore.js +8 -0
  52. package/dist/orchestration/checkpoint/ICheckpointStore.js.map +1 -0
  53. package/dist/orchestration/checkpoint/InMemoryCheckpointStore.d.ts +89 -0
  54. package/dist/orchestration/checkpoint/InMemoryCheckpointStore.d.ts.map +1 -0
  55. package/dist/orchestration/checkpoint/InMemoryCheckpointStore.js +156 -0
  56. package/dist/orchestration/checkpoint/InMemoryCheckpointStore.js.map +1 -0
  57. package/dist/orchestration/checkpoint/index.d.ts +10 -0
  58. package/dist/orchestration/checkpoint/index.d.ts.map +1 -0
  59. package/dist/orchestration/checkpoint/index.js +10 -0
  60. package/dist/orchestration/checkpoint/index.js.map +1 -0
  61. package/dist/orchestration/compiler/GraphCompiler.d.ts +85 -0
  62. package/dist/orchestration/compiler/GraphCompiler.d.ts.map +1 -0
  63. package/dist/orchestration/compiler/GraphCompiler.js +71 -0
  64. package/dist/orchestration/compiler/GraphCompiler.js.map +1 -0
  65. package/dist/orchestration/compiler/MissionCompiler.d.ts +181 -0
  66. package/dist/orchestration/compiler/MissionCompiler.d.ts.map +1 -0
  67. package/dist/orchestration/compiler/MissionCompiler.js +219 -0
  68. package/dist/orchestration/compiler/MissionCompiler.js.map +1 -0
  69. package/dist/orchestration/compiler/SchemaLowering.d.ts +37 -0
  70. package/dist/orchestration/compiler/SchemaLowering.d.ts.map +1 -0
  71. package/dist/orchestration/compiler/SchemaLowering.js +95 -0
  72. package/dist/orchestration/compiler/SchemaLowering.js.map +1 -0
  73. package/dist/orchestration/compiler/Validator.d.ts +61 -0
  74. package/dist/orchestration/compiler/Validator.d.ts.map +1 -0
  75. package/dist/orchestration/compiler/Validator.js +96 -0
  76. package/dist/orchestration/compiler/Validator.js.map +1 -0
  77. package/dist/orchestration/compiler/index.d.ts +16 -0
  78. package/dist/orchestration/compiler/index.d.ts.map +1 -0
  79. package/dist/orchestration/compiler/index.js +13 -0
  80. package/dist/orchestration/compiler/index.js.map +1 -0
  81. package/dist/orchestration/events/GraphEvent.d.ts +233 -0
  82. package/dist/orchestration/events/GraphEvent.d.ts.map +1 -0
  83. package/dist/orchestration/events/GraphEvent.js +203 -0
  84. package/dist/orchestration/events/GraphEvent.js.map +1 -0
  85. package/dist/orchestration/events/index.d.ts +2 -0
  86. package/dist/orchestration/events/index.d.ts.map +1 -0
  87. package/dist/orchestration/events/index.js +2 -0
  88. package/dist/orchestration/events/index.js.map +1 -0
  89. package/dist/orchestration/index.d.ts +20 -0
  90. package/dist/orchestration/index.d.ts.map +1 -0
  91. package/dist/orchestration/index.js +26 -0
  92. package/dist/orchestration/index.js.map +1 -0
  93. package/dist/orchestration/ir/index.d.ts +2 -0
  94. package/dist/orchestration/ir/index.d.ts.map +1 -0
  95. package/dist/orchestration/ir/index.js +2 -0
  96. package/dist/orchestration/ir/index.js.map +1 -0
  97. package/dist/orchestration/ir/types.d.ts +540 -0
  98. package/dist/orchestration/ir/types.d.ts.map +1 -0
  99. package/dist/orchestration/ir/types.js +20 -0
  100. package/dist/orchestration/ir/types.js.map +1 -0
  101. package/dist/orchestration/runtime/GraphRuntime.d.ts +135 -0
  102. package/dist/orchestration/runtime/GraphRuntime.d.ts.map +1 -0
  103. package/dist/orchestration/runtime/GraphRuntime.js +381 -0
  104. package/dist/orchestration/runtime/GraphRuntime.js.map +1 -0
  105. package/dist/orchestration/runtime/LoopController.d.ts +173 -0
  106. package/dist/orchestration/runtime/LoopController.d.ts.map +1 -0
  107. package/dist/orchestration/runtime/LoopController.js +130 -0
  108. package/dist/orchestration/runtime/LoopController.js.map +1 -0
  109. package/dist/orchestration/runtime/NodeExecutor.d.ts +206 -0
  110. package/dist/orchestration/runtime/NodeExecutor.d.ts.map +1 -0
  111. package/dist/orchestration/runtime/NodeExecutor.js +227 -0
  112. package/dist/orchestration/runtime/NodeExecutor.js.map +1 -0
  113. package/dist/orchestration/runtime/NodeScheduler.d.ts +85 -0
  114. package/dist/orchestration/runtime/NodeScheduler.d.ts.map +1 -0
  115. package/dist/orchestration/runtime/NodeScheduler.js +180 -0
  116. package/dist/orchestration/runtime/NodeScheduler.js.map +1 -0
  117. package/dist/orchestration/runtime/StateManager.d.ts +122 -0
  118. package/dist/orchestration/runtime/StateManager.d.ts.map +1 -0
  119. package/dist/orchestration/runtime/StateManager.js +243 -0
  120. package/dist/orchestration/runtime/StateManager.js.map +1 -0
  121. package/dist/orchestration/runtime/index.d.ts +16 -0
  122. package/dist/orchestration/runtime/index.d.ts.map +1 -0
  123. package/dist/orchestration/runtime/index.js +13 -0
  124. package/dist/orchestration/runtime/index.js.map +1 -0
  125. package/package.json +10 -4
  126. package/dist/api/tool-adapter.d.ts +0 -12
  127. package/dist/api/tool-adapter.d.ts.map +0 -1
  128. package/dist/api/tool-adapter.js.map +0 -1
@@ -0,0 +1,472 @@
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 { START, END } from '../ir/types.js';
31
+ import { gmiNode, toolNode, humanNode } from './nodes.js';
32
+ import { InMemoryCheckpointStore } from '../checkpoint/InMemoryCheckpointStore.js';
33
+ import { GraphCompiler } from '../compiler/GraphCompiler.js';
34
+ import { GraphValidator } from '../compiler/Validator.js';
35
+ import { GraphRuntime } from '../runtime/GraphRuntime.js';
36
+ import { NodeExecutor } from '../runtime/NodeExecutor.js';
37
+ // ---------------------------------------------------------------------------
38
+ // Factory
39
+ // ---------------------------------------------------------------------------
40
+ /**
41
+ * Create a new `WorkflowBuilder` with the given human-readable name.
42
+ *
43
+ * @param name - Display name embedded in the compiled `CompiledExecutionGraph`.
44
+ * @returns A fresh `WorkflowBuilder` instance.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * const wf = workflow('my-pipeline')
49
+ * .input(z.object({ query: z.string() }))
50
+ * .returns(z.object({ answer: z.string() }))
51
+ * .step('search', { tool: 'web_search' })
52
+ * .step('answer', { gmi: { instructions: 'Answer the question.' } })
53
+ * .compile();
54
+ * ```
55
+ */
56
+ export function workflow(name) {
57
+ return new WorkflowBuilder(name);
58
+ }
59
+ // ---------------------------------------------------------------------------
60
+ // WorkflowBuilder
61
+ // ---------------------------------------------------------------------------
62
+ /**
63
+ * Fluent builder for deterministic DAG workflows.
64
+ *
65
+ * Steps are appended in declaration order and connected sequentially. Branch and
66
+ * parallel primitives fan out and automatically rejoin at the next declared step.
67
+ *
68
+ * Call `.compile()` to validate the graph (must be acyclic) and obtain a
69
+ * `CompiledWorkflow` ready for `invoke()`, `stream()`, or `resume()`.
70
+ */
71
+ export class WorkflowBuilder {
72
+ /**
73
+ * @param name - Human-readable workflow name.
74
+ */
75
+ constructor(name) {
76
+ /** Ordered list of steps declared by the author. */
77
+ this.steps = [];
78
+ this.name = name;
79
+ }
80
+ // -------------------------------------------------------------------------
81
+ // Schema declarations
82
+ // -------------------------------------------------------------------------
83
+ /**
84
+ * Declare the input schema for this workflow.
85
+ *
86
+ * Accepts a Zod schema or any plain object; the value is forwarded to
87
+ * `GraphCompiler` which lowers it to JSON Schema via `lowerZodToJsonSchema`.
88
+ *
89
+ * @param schema - Input schema (Zod instance or plain JSON Schema object).
90
+ */
91
+ input(schema) {
92
+ this.inputSchema = schema;
93
+ return this;
94
+ }
95
+ /**
96
+ * Declare the return (output artifacts) schema for this workflow.
97
+ *
98
+ * @param schema - Output schema (Zod instance or plain JSON Schema object).
99
+ */
100
+ returns(schema) {
101
+ this.returnsSchema = schema;
102
+ return this;
103
+ }
104
+ // -------------------------------------------------------------------------
105
+ // Step primitives
106
+ // -------------------------------------------------------------------------
107
+ /**
108
+ * Append a single named step to the workflow.
109
+ *
110
+ * The step is connected from all current tail nodes and becomes the new
111
+ * single-element tail after it is added.
112
+ *
113
+ * @param id - Unique step identifier within this workflow.
114
+ * @param config - Execution and policy configuration for the step.
115
+ */
116
+ step(id, config) {
117
+ this.steps.push({ kind: 'step', id, config });
118
+ return this;
119
+ }
120
+ /**
121
+ * Alias for `step()` — reads more naturally when chaining sequential steps.
122
+ *
123
+ * @param id - Unique step identifier.
124
+ * @param config - Execution and policy configuration.
125
+ */
126
+ then(id, config) {
127
+ return this.step(id, config);
128
+ }
129
+ /**
130
+ * Append a conditional branch to the workflow.
131
+ *
132
+ * The `condition` function is evaluated at runtime against `GraphState` and must
133
+ * return one of the keys of `routes`. Each route becomes its own branch node; all
134
+ * branches become the collective tail that the next declared step connects from.
135
+ *
136
+ * @param condition - Routing function; return value must match a key in `routes`.
137
+ * @param routes - Map of route key → step config for each branch arm.
138
+ */
139
+ branch(condition, routes) {
140
+ this.steps.push({ kind: 'branch', condition, routes });
141
+ return this;
142
+ }
143
+ /**
144
+ * Append a parallel fan-out to the workflow.
145
+ *
146
+ * All `steps` execute concurrently (subject to runtime scheduling). After all
147
+ * branches complete, their outputs are merged using the `join.merge` reducers.
148
+ * The parallel branch nodes collectively become the new tail.
149
+ *
150
+ * @param steps - Array of step configs to execute concurrently.
151
+ * @param join - Fan-in configuration including merge strategy and reducers.
152
+ */
153
+ parallel(steps, join) {
154
+ this.steps.push({ kind: 'parallel', steps, join });
155
+ return this;
156
+ }
157
+ // -------------------------------------------------------------------------
158
+ // Compilation
159
+ // -------------------------------------------------------------------------
160
+ /**
161
+ * Compile the workflow into an executable `CompiledWorkflow`.
162
+ *
163
+ * Compilation steps:
164
+ * 1. Validate that `.input()` and `.returns()` schemas were declared.
165
+ * 2. Lower each `InternalStep` into `GraphNode` + `GraphEdge` IR objects,
166
+ * threading `tailNodeIds` to connect steps sequentially.
167
+ * 3. Connect all final tail nodes to `END`.
168
+ * 4. Run `GraphCompiler.compile()` to produce a `CompiledExecutionGraph`.
169
+ * 5. Run `GraphValidator.validate()` with `{ requireAcyclic: true }` — throws on cycle.
170
+ * 6. Wrap in a `CompiledWorkflow` with a `GraphRuntime` backed by the given store.
171
+ *
172
+ * @param options - Optional compilation options.
173
+ * @param options.checkpointStore - Custom checkpoint backend; defaults to `InMemoryCheckpointStore`.
174
+ * @throws {Error} When `.input()` or `.returns()` was not called.
175
+ * @throws {Error} When the compiled graph contains a cycle (should never happen via this API).
176
+ */
177
+ compile(options) {
178
+ if (!this.inputSchema) {
179
+ throw new Error('workflow() requires .input() schema — input is required');
180
+ }
181
+ if (!this.returnsSchema) {
182
+ throw new Error('workflow() requires .returns() schema — returns is required');
183
+ }
184
+ const nodes = new Map();
185
+ const edges = [];
186
+ const reducers = {};
187
+ let edgeCounter = 0;
188
+ const nextEdgeId = () => `we-${++edgeCounter}`;
189
+ /**
190
+ * The set of node ids that the *next* step should connect FROM.
191
+ * Starts at [START]; branches and parallel steps update this to fan-out tails.
192
+ */
193
+ let tailNodeIds = [START];
194
+ for (const internalStep of this.steps) {
195
+ if (internalStep.kind === 'step') {
196
+ // ── Sequential step ────────────────────────────────────────────────
197
+ const node = this.configToNode(internalStep.id, internalStep.config);
198
+ nodes.set(internalStep.id, node);
199
+ for (const tail of tailNodeIds) {
200
+ edges.push({
201
+ id: nextEdgeId(),
202
+ source: tail,
203
+ target: internalStep.id,
204
+ type: 'static',
205
+ });
206
+ }
207
+ tailNodeIds = [internalStep.id];
208
+ }
209
+ else if (internalStep.kind === 'branch') {
210
+ // ── Router + fan-out ───────────────────────────────────────────────
211
+ // Insert a pure router node that evaluates the condition.
212
+ const routerId = `router-${++edgeCounter}`;
213
+ const routerNode = {
214
+ id: routerId,
215
+ type: 'router',
216
+ executorConfig: {
217
+ type: 'router',
218
+ condition: { type: 'function', fn: internalStep.condition },
219
+ },
220
+ executionMode: 'single_turn',
221
+ effectClass: 'pure',
222
+ checkpoint: 'none',
223
+ };
224
+ nodes.set(routerId, routerNode);
225
+ // Connect all current tails to the router.
226
+ for (const tail of tailNodeIds) {
227
+ edges.push({
228
+ id: nextEdgeId(),
229
+ source: tail,
230
+ target: routerId,
231
+ type: 'static',
232
+ });
233
+ }
234
+ // Create a branch node per route and wire conditional edges from the router.
235
+ const branchTails = [];
236
+ for (const [routeKey, config] of Object.entries(internalStep.routes)) {
237
+ const branchId = `branch-${routeKey}-${++edgeCounter}`;
238
+ const branchNode = this.configToNode(branchId, config);
239
+ nodes.set(branchId, branchNode);
240
+ // Capture routeKey for the closure.
241
+ const capturedRouteKey = routeKey;
242
+ const capturedCondition = internalStep.condition;
243
+ edges.push({
244
+ id: nextEdgeId(),
245
+ source: routerId,
246
+ target: branchId,
247
+ type: 'conditional',
248
+ condition: {
249
+ type: 'function',
250
+ /**
251
+ * Returns `branchId` only when the router condition resolves to this
252
+ * branch's route key; otherwise returns an empty string so the runtime
253
+ * skips this edge.
254
+ */
255
+ fn: (state) => {
256
+ const resolved = capturedCondition(state);
257
+ return resolved === capturedRouteKey ? branchId : '';
258
+ },
259
+ },
260
+ });
261
+ branchTails.push(branchId);
262
+ }
263
+ // All branch leaves become the new tail for the next step.
264
+ tailNodeIds = branchTails;
265
+ }
266
+ else if (internalStep.kind === 'parallel') {
267
+ // ── Parallel fan-out ───────────────────────────────────────────────
268
+ const parallelTails = [];
269
+ for (let i = 0; i < internalStep.steps.length; i++) {
270
+ const pId = `parallel-${i}-${++edgeCounter}`;
271
+ const pNode = this.configToNode(pId, internalStep.steps[i]);
272
+ nodes.set(pId, pNode);
273
+ // Each parallel branch connects from all current tails.
274
+ for (const tail of tailNodeIds) {
275
+ edges.push({
276
+ id: nextEdgeId(),
277
+ source: tail,
278
+ target: pId,
279
+ type: 'static',
280
+ });
281
+ }
282
+ parallelTails.push(pId);
283
+ }
284
+ // Register field-level merge reducers from the join config.
285
+ for (const [field, reducer] of Object.entries(internalStep.join.merge)) {
286
+ reducers[field] = reducer;
287
+ }
288
+ // All parallel branches become the new tail.
289
+ tailNodeIds = parallelTails;
290
+ }
291
+ }
292
+ // Connect all remaining tail nodes to the END sentinel.
293
+ for (const tail of tailNodeIds) {
294
+ edges.push({
295
+ id: nextEdgeId(),
296
+ source: tail,
297
+ target: END,
298
+ type: 'static',
299
+ });
300
+ }
301
+ // ── Compile ────────────────────────────────────────────────────────────
302
+ const ir = GraphCompiler.compile({
303
+ name: this.name,
304
+ nodes,
305
+ edges,
306
+ stateSchema: {
307
+ input: this.inputSchema,
308
+ scratch: this.inputSchema, // scratch mirrors input shape by default
309
+ artifacts: this.returnsSchema,
310
+ },
311
+ reducers,
312
+ memoryConsistency: 'snapshot',
313
+ checkpointPolicy: 'every_node',
314
+ });
315
+ // ── Validate: workflows MUST be acyclic ───────────────────────────────
316
+ const result = GraphValidator.validate(ir, { requireAcyclic: true });
317
+ if (!result.valid) {
318
+ throw new Error(`Workflow validation failed: ${result.errors.join('; ')}`);
319
+ }
320
+ const store = options?.checkpointStore ?? new InMemoryCheckpointStore();
321
+ return new CompiledWorkflow(ir, store);
322
+ }
323
+ // -------------------------------------------------------------------------
324
+ // Private helpers
325
+ // -------------------------------------------------------------------------
326
+ /**
327
+ * Lower a `StepConfig` into a `GraphNode` with the given `id`.
328
+ *
329
+ * Priority order for executor type selection:
330
+ * `tool` → `gmi` → `human` → `extension` → `subgraph` → fallback tool node.
331
+ *
332
+ * GMI nodes always receive `executionMode: 'single_turn'` regardless of what
333
+ * the author specified in `config.gmi.executionMode`.
334
+ *
335
+ * @param id - Node id to assign.
336
+ * @param config - Caller-supplied step configuration.
337
+ * @returns A fully constructed `GraphNode` ready for the IR.
338
+ */
339
+ configToNode(id, config) {
340
+ if (config.tool) {
341
+ return {
342
+ ...toolNode(config.tool, {
343
+ timeout: config.timeout,
344
+ retryPolicy: config.retryPolicy,
345
+ }, {
346
+ effectClass: config.effectClass,
347
+ memory: config.memory,
348
+ discovery: config.discovery,
349
+ guardrails: config.guardrails,
350
+ }),
351
+ id,
352
+ };
353
+ }
354
+ if (config.gmi) {
355
+ return {
356
+ ...gmiNode({
357
+ instructions: config.gmi.instructions,
358
+ executionMode: 'single_turn', // Always single_turn in workflow()
359
+ maxTokens: config.gmi.maxTokens,
360
+ }, {
361
+ memory: config.memory,
362
+ guardrails: config.guardrails,
363
+ }),
364
+ id,
365
+ };
366
+ }
367
+ if (config.human) {
368
+ return {
369
+ ...humanNode({ prompt: config.human.prompt, timeout: config.timeout }),
370
+ id,
371
+ };
372
+ }
373
+ if (config.extension) {
374
+ // Extension nodes are represented as GraphNode with extension executorConfig.
375
+ return {
376
+ id,
377
+ type: 'extension',
378
+ executorConfig: {
379
+ type: 'extension',
380
+ extensionId: config.extension.extensionId,
381
+ method: config.extension.method,
382
+ },
383
+ executionMode: 'single_turn',
384
+ effectClass: config.effectClass ?? 'external',
385
+ timeout: config.timeout,
386
+ checkpoint: 'none',
387
+ memoryPolicy: config.memory,
388
+ guardrailPolicy: config.guardrails,
389
+ };
390
+ }
391
+ if (config.subgraph) {
392
+ return {
393
+ id,
394
+ type: 'subgraph',
395
+ executorConfig: {
396
+ type: 'subgraph',
397
+ graphId: config.subgraph.id,
398
+ },
399
+ executionMode: 'single_turn',
400
+ effectClass: config.effectClass ?? 'read',
401
+ checkpoint: 'none',
402
+ };
403
+ }
404
+ // Fallback: treat as a no-op tool node.
405
+ return {
406
+ ...toolNode('unknown', { timeout: config.timeout }),
407
+ id,
408
+ };
409
+ }
410
+ }
411
+ // ---------------------------------------------------------------------------
412
+ // CompiledWorkflow
413
+ // ---------------------------------------------------------------------------
414
+ /**
415
+ * An execution-ready workflow produced by `WorkflowBuilder.compile()`.
416
+ *
417
+ * Wraps a `CompiledExecutionGraph` and a `GraphRuntime`, exposing the same
418
+ * three execution modes as the raw runtime:
419
+ *
420
+ * - `invoke(input)` — run to completion and return final artifacts.
421
+ * - `stream(input)` — run while yielding `GraphEvent` values at each step.
422
+ * - `resume(checkpointId)` — restore an interrupted run from a checkpoint.
423
+ */
424
+ export class CompiledWorkflow {
425
+ /**
426
+ * @param ir - The compiled execution graph (produced by `GraphCompiler`).
427
+ * @param checkpointStore - Checkpoint persistence backend.
428
+ */
429
+ constructor(ir, checkpointStore) {
430
+ this.ir = ir;
431
+ this.runtime = new GraphRuntime({
432
+ checkpointStore,
433
+ nodeExecutor: new NodeExecutor({}),
434
+ });
435
+ }
436
+ /**
437
+ * Execute the workflow to completion and return the final `artifacts` payload.
438
+ *
439
+ * @param input - Must conform to the schema declared via `.input()`.
440
+ * @returns The `GraphState.artifacts` value after all nodes complete.
441
+ */
442
+ async invoke(input) {
443
+ return this.runtime.invoke(this.ir, input);
444
+ }
445
+ /**
446
+ * Execute the workflow while yielding `GraphEvent` values at each step boundary.
447
+ *
448
+ * @param input - Must conform to the schema declared via `.input()`.
449
+ * @yields {GraphEvent} Runtime events in causal order.
450
+ */
451
+ async *stream(input) {
452
+ yield* this.runtime.stream(this.ir, input);
453
+ }
454
+ /**
455
+ * Resume a previously interrupted workflow run from its latest checkpoint.
456
+ *
457
+ * @param checkpointId - The run identifier returned when the original run was interrupted.
458
+ * @returns The final `GraphState.artifacts` value after resumption completes.
459
+ */
460
+ async resume(checkpointId) {
461
+ return this.runtime.resume(this.ir, checkpointId);
462
+ }
463
+ /**
464
+ * Expose the compiled IR for inspection, serialisation, or subgraph composition.
465
+ *
466
+ * @returns The underlying `CompiledExecutionGraph`.
467
+ */
468
+ toIR() {
469
+ return this.ir;
470
+ }
471
+ }
472
+ //# sourceMappingURL=WorkflowBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkflowBuilder.js","sourceRoot":"","sources":["../../../src/orchestration/builders/WorkflowBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAaH,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAmF1D,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,Q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OAAO,GAAG,IAAI,YAAY,CAAC;YAC9B,eAAe;YACf,YAAY,EAAE,IAAI,YAAY,CAAC,EAAE,CAAC;SACnC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CAAC,KAAc;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,CAAC,MAAM,CAAC,KAAc;QAC1B,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CAAC,YAAoB;QAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ export { gmiNode, toolNode, humanNode, routerNode, guardrailNode, subgraphNode } from './nodes.js';
2
+ export type { NodePolicies } from './nodes.js';
3
+ export { AgentGraph, CompiledAgentGraph } from './AgentGraph.js';
4
+ export { workflow, WorkflowBuilder, CompiledWorkflow } from './WorkflowBuilder.js';
5
+ export type { StepConfig } from './WorkflowBuilder.js';
6
+ export { mission, MissionBuilder, CompiledMission } from './MissionBuilder.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/orchestration/builders/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACnG,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnF,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { gmiNode, toolNode, humanNode, routerNode, guardrailNode, subgraphNode } from './nodes.js';
2
+ export { AgentGraph, CompiledAgentGraph } from './AgentGraph.js';
3
+ export { workflow, WorkflowBuilder, CompiledWorkflow } from './WorkflowBuilder.js';
4
+ export { mission, MissionBuilder, CompiledMission } from './MissionBuilder.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/orchestration/builders/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEnG,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEnF,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { GraphNode, NodeExecutionMode, EffectClass, MemoryPolicy, DiscoveryPolicy, PersonaPolicy, GuardrailPolicy, RetryPolicy, CompiledExecutionGraph } from '../ir/types.js';
2
+ export interface NodePolicies {
3
+ memory?: MemoryPolicy;
4
+ discovery?: DiscoveryPolicy;
5
+ persona?: PersonaPolicy;
6
+ guardrails?: GuardrailPolicy;
7
+ checkpoint?: 'before' | 'after' | 'both' | 'none';
8
+ effectClass?: EffectClass;
9
+ }
10
+ export declare function gmiNode(config: {
11
+ instructions: string;
12
+ executionMode?: NodeExecutionMode;
13
+ maxInternalIterations?: number;
14
+ parallelTools?: boolean;
15
+ temperature?: number;
16
+ maxTokens?: number;
17
+ }, policies?: NodePolicies): GraphNode;
18
+ export declare function toolNode(toolName: string, config?: {
19
+ timeout?: number;
20
+ retryPolicy?: RetryPolicy;
21
+ args?: Record<string, unknown>;
22
+ }, policies?: NodePolicies): GraphNode;
23
+ export declare function humanNode(config: {
24
+ prompt: string;
25
+ timeout?: number;
26
+ }, policies?: NodePolicies): GraphNode;
27
+ export declare function routerNode(routeFn: ((state: any) => string) | string): GraphNode;
28
+ export declare function guardrailNode(guardrailIds: string[], config: {
29
+ onViolation: 'block' | 'reroute' | 'warn' | 'sanitize';
30
+ rerouteTarget?: string;
31
+ }): GraphNode;
32
+ export declare function subgraphNode(compiledGraph: CompiledExecutionGraph, config?: {
33
+ inputMapping?: Record<string, string>;
34
+ outputMapping?: Record<string, string>;
35
+ }): GraphNode;
36
+ //# sourceMappingURL=nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../src/orchestration/builders/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAkB,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAEpM,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,UAAU,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAClD,WAAW,CAAC,EAAE,WAAW,CAAC;C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AM,EAAE,MAAM,CAAC,CAAC;CACxC,GAAG,SAAS,CAcZ"}
@@ -0,0 +1,98 @@
1
+ let nodeCounter = 0;
2
+ function nextId(prefix) {
3
+ return `${prefix}-${++nodeCounter}`;
4
+ }
5
+ export function gmiNode(config, policies) {
6
+ return {
7
+ id: nextId('gmi'),
8
+ type: 'gmi',
9
+ executorConfig: {
10
+ type: 'gmi',
11
+ instructions: config.instructions,
12
+ maxInternalIterations: config.maxInternalIterations,
13
+ parallelTools: config.parallelTools,
14
+ temperature: config.temperature,
15
+ maxTokens: config.maxTokens,
16
+ },
17
+ executionMode: config.executionMode ?? 'react_bounded',
18
+ effectClass: policies?.effectClass ?? 'read',
19
+ checkpoint: policies?.checkpoint ?? 'none',
20
+ memoryPolicy: policies?.memory,
21
+ discoveryPolicy: policies?.discovery,
22
+ personaPolicy: policies?.persona,
23
+ guardrailPolicy: policies?.guardrails,
24
+ };
25
+ }
26
+ export function toolNode(toolName, config, policies) {
27
+ return {
28
+ id: nextId('tool'),
29
+ type: 'tool',
30
+ executorConfig: { type: 'tool', toolName, args: config?.args },
31
+ executionMode: 'single_turn',
32
+ effectClass: policies?.effectClass ?? 'external',
33
+ timeout: config?.timeout,
34
+ retryPolicy: config?.retryPolicy,
35
+ checkpoint: policies?.checkpoint ?? 'none',
36
+ memoryPolicy: policies?.memory,
37
+ discoveryPolicy: policies?.discovery,
38
+ personaPolicy: policies?.persona,
39
+ guardrailPolicy: policies?.guardrails,
40
+ };
41
+ }
42
+ export function humanNode(config, policies) {
43
+ return {
44
+ id: nextId('human'),
45
+ type: 'human',
46
+ executorConfig: { type: 'human', prompt: config.prompt },
47
+ executionMode: 'single_turn',
48
+ effectClass: 'human',
49
+ timeout: config.timeout,
50
+ checkpoint: policies?.checkpoint ?? 'after',
51
+ memoryPolicy: policies?.memory,
52
+ guardrailPolicy: policies?.guardrails,
53
+ };
54
+ }
55
+ export function routerNode(routeFn) {
56
+ const condition = typeof routeFn === 'string'
57
+ ? { type: 'expression', expr: routeFn }
58
+ : { type: 'function', fn: routeFn };
59
+ return {
60
+ id: nextId('router'),
61
+ type: 'router',
62
+ executorConfig: { type: 'router', condition },
63
+ executionMode: 'single_turn',
64
+ effectClass: 'pure',
65
+ checkpoint: 'none',
66
+ };
67
+ }
68
+ export function guardrailNode(guardrailIds, config) {
69
+ return {
70
+ id: nextId('guardrail'),
71
+ type: 'guardrail',
72
+ executorConfig: {
73
+ type: 'guardrail',
74
+ guardrailIds,
75
+ onViolation: config.onViolation,
76
+ rerouteTarget: config.rerouteTarget,
77
+ },
78
+ executionMode: 'single_turn',
79
+ effectClass: 'pure',
80
+ checkpoint: 'none',
81
+ };
82
+ }
83
+ export function subgraphNode(compiledGraph, config) {
84
+ return {
85
+ id: nextId('subgraph'),
86
+ type: 'subgraph',
87
+ executorConfig: {
88
+ type: 'subgraph',
89
+ graphId: compiledGraph.id,
90
+ inputMapping: config?.inputMapping,
91
+ outputMapping: config?.outputMapping,
92
+ },
93
+ executionMode: 'single_turn',
94
+ effectClass: 'read',
95
+ checkpoint: 'none',
96
+ };
97
+ }
98
+ //# sourceMappingURL=nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../src/orchestration/builders/nodes.ts"],"names":[],"mappings":"AAWA,IAAI,WAAW,GAAG,CAAC,CAAC;AACpB,SAAS,MAAM,CAAC,MAAc;IAC5B,OAAO,GAAG,MAAM,IAAI,EAAE,WAAW,EAAE,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,MAOvB,EAAE,QAAuB;IACxB,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC;QACjB,IAAI,EAAE,KAAK;QACX,cAAc,EAAE;YACd,IAAI,EAAE,KAAK;YACX,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;YACnD,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,WAAW,EAAE,MAAM,CA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