@wundr.io/langgraph-orchestrator 1.0.3
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/README.md +842 -0
- package/dist/checkpointing.d.ts +265 -0
- package/dist/checkpointing.d.ts.map +1 -0
- package/dist/checkpointing.js +577 -0
- package/dist/checkpointing.js.map +1 -0
- package/dist/edges/conditional-edge.d.ts +230 -0
- package/dist/edges/conditional-edge.d.ts.map +1 -0
- package/dist/edges/conditional-edge.js +439 -0
- package/dist/edges/conditional-edge.js.map +1 -0
- package/dist/edges/loop-edge.d.ts +290 -0
- package/dist/edges/loop-edge.d.ts.map +1 -0
- package/dist/edges/loop-edge.js +503 -0
- package/dist/edges/loop-edge.js.map +1 -0
- package/dist/index.d.ts +125 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +269 -0
- package/dist/index.js.map +1 -0
- package/dist/nodes/decision-node.d.ts +276 -0
- package/dist/nodes/decision-node.d.ts.map +1 -0
- package/dist/nodes/decision-node.js +403 -0
- package/dist/nodes/decision-node.js.map +1 -0
- package/dist/nodes/human-node.d.ts +272 -0
- package/dist/nodes/human-node.d.ts.map +1 -0
- package/dist/nodes/human-node.js +394 -0
- package/dist/nodes/human-node.js.map +1 -0
- package/dist/nodes/llm-node.d.ts +173 -0
- package/dist/nodes/llm-node.d.ts.map +1 -0
- package/dist/nodes/llm-node.js +325 -0
- package/dist/nodes/llm-node.js.map +1 -0
- package/dist/nodes/tool-node.d.ts +151 -0
- package/dist/nodes/tool-node.d.ts.map +1 -0
- package/dist/nodes/tool-node.js +373 -0
- package/dist/nodes/tool-node.js.map +1 -0
- package/dist/prebuilt-graphs/plan-execute-refine.d.ts +149 -0
- package/dist/prebuilt-graphs/plan-execute-refine.d.ts.map +1 -0
- package/dist/prebuilt-graphs/plan-execute-refine.js +600 -0
- package/dist/prebuilt-graphs/plan-execute-refine.js.map +1 -0
- package/dist/state-graph.d.ts +158 -0
- package/dist/state-graph.d.ts.map +1 -0
- package/dist/state-graph.js +756 -0
- package/dist/state-graph.js.map +1 -0
- package/dist/types.d.ts +762 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +73 -0
- package/dist/types.js.map +1 -0
- package/package.json +57 -0
- package/src/checkpointing.ts +702 -0
- package/src/edges/conditional-edge.ts +518 -0
- package/src/edges/loop-edge.ts +623 -0
- package/src/index.ts +416 -0
- package/src/nodes/decision-node.ts +538 -0
- package/src/nodes/human-node.ts +572 -0
- package/src/nodes/llm-node.ts +448 -0
- package/src/nodes/tool-node.ts +525 -0
- package/src/prebuilt-graphs/plan-execute-refine.ts +769 -0
- package/src/state-graph.ts +990 -0
- package/src/types.ts +729 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tool Node - Tool execution node for agent workflows
|
|
4
|
+
* @module @wundr.io/langgraph-orchestrator
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ToolNodeConfigSchema = void 0;
|
|
8
|
+
exports.createToolNode = createToolNode;
|
|
9
|
+
exports.createToolRegistry = createToolRegistry;
|
|
10
|
+
exports.createTool = createTool;
|
|
11
|
+
exports.createBatchToolNode = createBatchToolNode;
|
|
12
|
+
const uuid_1 = require("uuid");
|
|
13
|
+
const zod_1 = require("zod");
|
|
14
|
+
/**
|
|
15
|
+
* Schema for tool node configuration validation
|
|
16
|
+
*/
|
|
17
|
+
exports.ToolNodeConfigSchema = zod_1.z.object({
|
|
18
|
+
parallel: zod_1.z.boolean().optional(),
|
|
19
|
+
maxConcurrency: zod_1.z.number().min(1).optional(),
|
|
20
|
+
toolTimeout: zod_1.z.number().min(0).optional(),
|
|
21
|
+
continueOnError: zod_1.z.boolean().optional(),
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Create a tool execution node
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const toolNode = createToolNode({
|
|
29
|
+
* id: 'tools',
|
|
30
|
+
* name: 'Tool Executor',
|
|
31
|
+
* config: {
|
|
32
|
+
* parallel: true,
|
|
33
|
+
* maxConcurrency: 3,
|
|
34
|
+
* continueOnError: true
|
|
35
|
+
* }
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* graph.addNode('tools', toolNode);
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @param options - Node creation options
|
|
42
|
+
* @returns NodeDefinition for use in StateGraph
|
|
43
|
+
*/
|
|
44
|
+
function createToolNode(options) {
|
|
45
|
+
const { id, name, config = {}, nodeConfig = {} } = options;
|
|
46
|
+
return {
|
|
47
|
+
id,
|
|
48
|
+
name,
|
|
49
|
+
type: 'tool',
|
|
50
|
+
config: nodeConfig,
|
|
51
|
+
execute: async (state, context) => {
|
|
52
|
+
// Get pending tool calls from state
|
|
53
|
+
const pendingToolCalls = state.data['pendingToolCalls'];
|
|
54
|
+
if (!pendingToolCalls || pendingToolCalls.length === 0) {
|
|
55
|
+
context.services.logger.warn('Tool node executed with no pending tool calls');
|
|
56
|
+
return { state };
|
|
57
|
+
}
|
|
58
|
+
context.services.logger.debug('Executing tool calls', {
|
|
59
|
+
count: pendingToolCalls.length,
|
|
60
|
+
tools: pendingToolCalls.map(tc => tc.name),
|
|
61
|
+
});
|
|
62
|
+
// Get tools from config or registry
|
|
63
|
+
const tools = config.tools ?? getToolsFromRegistry(context.services.toolRegistry);
|
|
64
|
+
const toolMap = new Map(tools.map(t => [t.name, t]));
|
|
65
|
+
// Execute tool calls
|
|
66
|
+
const results = await executeToolCalls(pendingToolCalls, toolMap, config, context);
|
|
67
|
+
// Build tool result messages
|
|
68
|
+
const toolMessages = results.map(result => ({
|
|
69
|
+
id: (0, uuid_1.v4)(),
|
|
70
|
+
role: 'tool',
|
|
71
|
+
content: result.content,
|
|
72
|
+
toolResult: result,
|
|
73
|
+
timestamp: new Date(),
|
|
74
|
+
}));
|
|
75
|
+
// Build updated state
|
|
76
|
+
let newData = { ...state.data };
|
|
77
|
+
delete newData['pendingToolCalls']; // Clear pending calls
|
|
78
|
+
// Store results in state
|
|
79
|
+
newData['lastToolResults'] = results;
|
|
80
|
+
// Apply post-processing if configured
|
|
81
|
+
if (config.postProcess) {
|
|
82
|
+
const processed = config.postProcess(results, state);
|
|
83
|
+
newData = { ...newData, ...processed };
|
|
84
|
+
}
|
|
85
|
+
const newState = {
|
|
86
|
+
...state,
|
|
87
|
+
messages: [...state.messages, ...toolMessages],
|
|
88
|
+
data: newData,
|
|
89
|
+
};
|
|
90
|
+
// Check if all tools succeeded
|
|
91
|
+
const _allSucceeded = results.every(r => r.success);
|
|
92
|
+
const hasErrors = results.some(r => !r.success);
|
|
93
|
+
context.services.logger.debug('Tool execution complete', {
|
|
94
|
+
total: results.length,
|
|
95
|
+
succeeded: results.filter(r => r.success).length,
|
|
96
|
+
failed: results.filter(r => !r.success).length,
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
state: newState,
|
|
100
|
+
// If there were errors and we're not continuing, route to error handler
|
|
101
|
+
next: hasErrors && !config.continueOnError ? 'error' : undefined,
|
|
102
|
+
metadata: {
|
|
103
|
+
duration: 0,
|
|
104
|
+
toolCalls: pendingToolCalls,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Execute tool calls with concurrency control
|
|
112
|
+
*/
|
|
113
|
+
async function executeToolCalls(toolCalls, toolMap, config, context) {
|
|
114
|
+
if (config.parallel) {
|
|
115
|
+
return executeParallel(toolCalls, toolMap, config, context);
|
|
116
|
+
}
|
|
117
|
+
return executeSequential(toolCalls, toolMap, config, context);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Execute tool calls sequentially
|
|
121
|
+
*/
|
|
122
|
+
async function executeSequential(toolCalls, toolMap, config, context) {
|
|
123
|
+
const results = [];
|
|
124
|
+
for (const toolCall of toolCalls) {
|
|
125
|
+
const result = await executeSingleTool(toolCall, toolMap, config, context);
|
|
126
|
+
results.push(result);
|
|
127
|
+
// Stop if there's an error and we're not continuing on error
|
|
128
|
+
if (!result.success && !config.continueOnError) {
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return results;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Execute tool calls in parallel with concurrency limit
|
|
136
|
+
*/
|
|
137
|
+
async function executeParallel(toolCalls, toolMap, config, context) {
|
|
138
|
+
const maxConcurrency = config.maxConcurrency ?? 5;
|
|
139
|
+
const results = [];
|
|
140
|
+
const executing = [];
|
|
141
|
+
for (const toolCall of toolCalls) {
|
|
142
|
+
const promise = executeSingleTool(toolCall, toolMap, config, context);
|
|
143
|
+
executing.push(promise);
|
|
144
|
+
if (executing.length >= maxConcurrency) {
|
|
145
|
+
const result = await Promise.race(executing);
|
|
146
|
+
results.push(result);
|
|
147
|
+
const index = executing.indexOf(promise);
|
|
148
|
+
if (index > -1) {
|
|
149
|
+
executing.splice(index, 1);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Wait for remaining executions
|
|
154
|
+
const remaining = await Promise.all(executing);
|
|
155
|
+
results.push(...remaining);
|
|
156
|
+
return results;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Execute a single tool call
|
|
160
|
+
*/
|
|
161
|
+
async function executeSingleTool(toolCall, toolMap, config, context) {
|
|
162
|
+
const tool = toolMap.get(toolCall.name);
|
|
163
|
+
if (!tool) {
|
|
164
|
+
const error = new Error(`Tool "${toolCall.name}" not found`);
|
|
165
|
+
if (config.onError) {
|
|
166
|
+
return config.onError(error, toolCall);
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
toolCallId: toolCall.id,
|
|
170
|
+
content: `Error: Tool "${toolCall.name}" not found`,
|
|
171
|
+
success: false,
|
|
172
|
+
error: error.message,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
// Validate input if schema provided
|
|
177
|
+
if (tool.inputSchema) {
|
|
178
|
+
tool.inputSchema.parse(toolCall.arguments);
|
|
179
|
+
}
|
|
180
|
+
// Execute with timeout if configured
|
|
181
|
+
const result = config.toolTimeout
|
|
182
|
+
? await executeWithTimeout(tool, toolCall.arguments, config.toolTimeout)
|
|
183
|
+
: await tool.execute(toolCall.arguments);
|
|
184
|
+
// Validate output if schema provided
|
|
185
|
+
if (tool.outputSchema) {
|
|
186
|
+
tool.outputSchema.parse(result);
|
|
187
|
+
}
|
|
188
|
+
context.services.logger.debug('Tool executed successfully', {
|
|
189
|
+
tool: toolCall.name,
|
|
190
|
+
callId: toolCall.id,
|
|
191
|
+
});
|
|
192
|
+
return {
|
|
193
|
+
toolCallId: toolCall.id,
|
|
194
|
+
content: typeof result === 'string' ? result : JSON.stringify(result),
|
|
195
|
+
success: true,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
200
|
+
context.services.logger.error('Tool execution failed', {
|
|
201
|
+
tool: toolCall.name,
|
|
202
|
+
callId: toolCall.id,
|
|
203
|
+
error: err.message,
|
|
204
|
+
});
|
|
205
|
+
if (config.onError) {
|
|
206
|
+
return config.onError(err, toolCall);
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
toolCallId: toolCall.id,
|
|
210
|
+
content: `Error executing tool "${toolCall.name}": ${err.message}`,
|
|
211
|
+
success: false,
|
|
212
|
+
error: err.message,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Execute tool with timeout
|
|
218
|
+
*/
|
|
219
|
+
async function executeWithTimeout(tool, args, timeout) {
|
|
220
|
+
return Promise.race([
|
|
221
|
+
tool.execute(args),
|
|
222
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error(`Tool execution timed out after ${timeout}ms`)), timeout)),
|
|
223
|
+
]);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Get tools from registry
|
|
227
|
+
*/
|
|
228
|
+
function getToolsFromRegistry(registry) {
|
|
229
|
+
if (!registry) {
|
|
230
|
+
return [];
|
|
231
|
+
}
|
|
232
|
+
return registry.list();
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Create a simple in-memory tool registry
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```typescript
|
|
239
|
+
* const registry = createToolRegistry();
|
|
240
|
+
* registry.register({
|
|
241
|
+
* name: 'search',
|
|
242
|
+
* description: 'Search the web',
|
|
243
|
+
* inputSchema: z.object({ query: z.string() }),
|
|
244
|
+
* execute: async ({ query }) => searchWeb(query)
|
|
245
|
+
* });
|
|
246
|
+
*
|
|
247
|
+
* graph.setServices({ toolRegistry: registry });
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* @returns ToolRegistry implementation
|
|
251
|
+
*/
|
|
252
|
+
function createToolRegistry() {
|
|
253
|
+
const tools = new Map();
|
|
254
|
+
return {
|
|
255
|
+
get(name) {
|
|
256
|
+
return tools.get(name);
|
|
257
|
+
},
|
|
258
|
+
list() {
|
|
259
|
+
return Array.from(tools.values());
|
|
260
|
+
},
|
|
261
|
+
register(tool) {
|
|
262
|
+
if (tools.has(tool.name)) {
|
|
263
|
+
throw new Error(`Tool "${tool.name}" is already registered`);
|
|
264
|
+
}
|
|
265
|
+
tools.set(tool.name, tool);
|
|
266
|
+
},
|
|
267
|
+
unregister(name) {
|
|
268
|
+
tools.delete(name);
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Create a tool definition with type-safe input/output
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```typescript
|
|
277
|
+
* const searchTool = createTool({
|
|
278
|
+
* name: 'search',
|
|
279
|
+
* description: 'Search the web for information',
|
|
280
|
+
* inputSchema: z.object({
|
|
281
|
+
* query: z.string(),
|
|
282
|
+
* maxResults: z.number().optional()
|
|
283
|
+
* }),
|
|
284
|
+
* outputSchema: z.array(z.object({
|
|
285
|
+
* title: z.string(),
|
|
286
|
+
* url: z.string(),
|
|
287
|
+
* snippet: z.string()
|
|
288
|
+
* })),
|
|
289
|
+
* execute: async ({ query, maxResults = 10 }) => {
|
|
290
|
+
* return await searchWeb(query, maxResults);
|
|
291
|
+
* }
|
|
292
|
+
* });
|
|
293
|
+
* ```
|
|
294
|
+
*
|
|
295
|
+
* @param options - Tool definition options
|
|
296
|
+
* @returns Tool definition
|
|
297
|
+
*/
|
|
298
|
+
function createTool(options) {
|
|
299
|
+
return {
|
|
300
|
+
name: options.name,
|
|
301
|
+
description: options.description,
|
|
302
|
+
inputSchema: options.inputSchema,
|
|
303
|
+
outputSchema: options.outputSchema,
|
|
304
|
+
execute: async (input) => {
|
|
305
|
+
const parsed = options.inputSchema.parse(input);
|
|
306
|
+
return options.execute(parsed);
|
|
307
|
+
},
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Create a batch tool node that groups tool calls
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```typescript
|
|
315
|
+
* const batchToolNode = createBatchToolNode({
|
|
316
|
+
* id: 'batch-tools',
|
|
317
|
+
* name: 'Batch Tool Executor',
|
|
318
|
+
* config: {
|
|
319
|
+
* batchSize: 5,
|
|
320
|
+
* batchTimeout: 1000
|
|
321
|
+
* }
|
|
322
|
+
* });
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* @param options - Node creation options
|
|
326
|
+
* @returns NodeDefinition for use in StateGraph
|
|
327
|
+
*/
|
|
328
|
+
function createBatchToolNode(options) {
|
|
329
|
+
const { id, name, config = {}, nodeConfig = {} } = options;
|
|
330
|
+
const batchSize = config.batchSize ?? 10;
|
|
331
|
+
return {
|
|
332
|
+
id,
|
|
333
|
+
name,
|
|
334
|
+
type: 'tool',
|
|
335
|
+
config: nodeConfig,
|
|
336
|
+
execute: async (state, context) => {
|
|
337
|
+
const pendingToolCalls = state.data['pendingToolCalls'];
|
|
338
|
+
if (!pendingToolCalls || pendingToolCalls.length === 0) {
|
|
339
|
+
return { state };
|
|
340
|
+
}
|
|
341
|
+
const tools = config.tools ?? getToolsFromRegistry(context.services.toolRegistry);
|
|
342
|
+
const toolMap = new Map(tools.map(t => [t.name, t]));
|
|
343
|
+
// Process in batches
|
|
344
|
+
const batches = [];
|
|
345
|
+
for (let i = 0; i < pendingToolCalls.length; i += batchSize) {
|
|
346
|
+
batches.push(pendingToolCalls.slice(i, i + batchSize));
|
|
347
|
+
}
|
|
348
|
+
const allResults = [];
|
|
349
|
+
for (const batch of batches) {
|
|
350
|
+
const results = await executeParallel(batch, toolMap, config, context);
|
|
351
|
+
allResults.push(...results);
|
|
352
|
+
}
|
|
353
|
+
// Build tool result messages
|
|
354
|
+
const toolMessages = allResults.map(result => ({
|
|
355
|
+
id: (0, uuid_1.v4)(),
|
|
356
|
+
role: 'tool',
|
|
357
|
+
content: result.content,
|
|
358
|
+
toolResult: result,
|
|
359
|
+
timestamp: new Date(),
|
|
360
|
+
}));
|
|
361
|
+
const newData = { ...state.data };
|
|
362
|
+
delete newData['pendingToolCalls'];
|
|
363
|
+
newData['lastToolResults'] = allResults;
|
|
364
|
+
const newState = {
|
|
365
|
+
...state,
|
|
366
|
+
messages: [...state.messages, ...toolMessages],
|
|
367
|
+
data: newData,
|
|
368
|
+
};
|
|
369
|
+
return { state: newState };
|
|
370
|
+
},
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
//# sourceMappingURL=tool-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-node.js","sourceRoot":"","sources":["../../src/nodes/tool-node.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAuEH,wCAkGC;AAkMD,gDAuBC;AA4BD,gCAiBC;AAoBD,kDAsEC;AAv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
2
|
+
* Plan-Execute-Refine Graph - Ready-to-use workflow pattern
|
|
3
|
+
* @module @wundr.io/langgraph-orchestrator
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { StateGraph } from '../state-graph';
|
|
7
|
+
import type { HumanInputHandler } from '../nodes/human-node';
|
|
8
|
+
import type { AgentState, Tool, LLMProvider } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Extended state for plan-execute-refine workflow
|
|
11
|
+
*/
|
|
12
|
+
export interface PlanExecuteState extends AgentState {
|
|
13
|
+
/** The current plan */
|
|
14
|
+
readonly data: AgentState['data'] & {
|
|
15
|
+
/** Original task/goal */
|
|
16
|
+
task?: string;
|
|
17
|
+
/** Generated plan steps */
|
|
18
|
+
plan?: PlanStep[];
|
|
19
|
+
/** Current step being executed */
|
|
20
|
+
currentStepIndex?: number;
|
|
21
|
+
/** Execution results for each step */
|
|
22
|
+
stepResults?: StepResult[];
|
|
23
|
+
/** Overall execution status */
|
|
24
|
+
executionStatus?: 'planning' | 'executing' | 'refining' | 'complete' | 'failed';
|
|
25
|
+
/** Number of refinement iterations */
|
|
26
|
+
refinementCount?: number;
|
|
27
|
+
/** Maximum refinement iterations */
|
|
28
|
+
maxRefinements?: number;
|
|
29
|
+
/** Final result */
|
|
30
|
+
finalResult?: unknown;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A step in the plan
|
|
35
|
+
*/
|
|
36
|
+
export interface PlanStep {
|
|
37
|
+
/** Step identifier */
|
|
38
|
+
id: string;
|
|
39
|
+
/** Step description */
|
|
40
|
+
description: string;
|
|
41
|
+
/** Tool to use (if any) */
|
|
42
|
+
tool?: string;
|
|
43
|
+
/** Tool arguments */
|
|
44
|
+
toolArgs?: Record<string, unknown>;
|
|
45
|
+
/** Dependencies on other steps */
|
|
46
|
+
dependsOn?: string[];
|
|
47
|
+
/** Expected output description */
|
|
48
|
+
expectedOutput?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Result of executing a step
|
|
52
|
+
*/
|
|
53
|
+
export interface StepResult {
|
|
54
|
+
/** Step ID */
|
|
55
|
+
stepId: string;
|
|
56
|
+
/** Whether step succeeded */
|
|
57
|
+
success: boolean;
|
|
58
|
+
/** Result data */
|
|
59
|
+
result?: unknown;
|
|
60
|
+
/** Error message if failed */
|
|
61
|
+
error?: string;
|
|
62
|
+
/** Execution timestamp */
|
|
63
|
+
timestamp: Date;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Configuration for plan-execute-refine graph
|
|
67
|
+
*/
|
|
68
|
+
export interface PlanExecuteRefineConfig {
|
|
69
|
+
/** LLM provider for planning and refinement */
|
|
70
|
+
llmProvider: LLMProvider;
|
|
71
|
+
/** Available tools */
|
|
72
|
+
tools?: Tool[];
|
|
73
|
+
/** Human input handler for approval steps */
|
|
74
|
+
humanHandler?: HumanInputHandler;
|
|
75
|
+
/** Maximum refinement iterations */
|
|
76
|
+
maxRefinements?: number;
|
|
77
|
+
/** Whether to require human approval before execution */
|
|
78
|
+
requireApproval?: boolean;
|
|
79
|
+
/** Custom planner prompt */
|
|
80
|
+
plannerPrompt?: string;
|
|
81
|
+
/** Custom executor prompt */
|
|
82
|
+
executorPrompt?: string;
|
|
83
|
+
/** Custom refiner prompt */
|
|
84
|
+
refinerPrompt?: string;
|
|
85
|
+
/** Model to use */
|
|
86
|
+
model?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Schema for plan validation
|
|
90
|
+
*/
|
|
91
|
+
export declare const PlanSchema: z.ZodArray<z.ZodObject<{
|
|
92
|
+
id: z.ZodString;
|
|
93
|
+
description: z.ZodString;
|
|
94
|
+
tool: z.ZodOptional<z.ZodString>;
|
|
95
|
+
toolArgs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
96
|
+
dependsOn: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
97
|
+
expectedOutput: z.ZodOptional<z.ZodString>;
|
|
98
|
+
}, "strip", z.ZodTypeAny, {
|
|
99
|
+
id: string;
|
|
100
|
+
description: string;
|
|
101
|
+
tool?: string | undefined;
|
|
102
|
+
toolArgs?: Record<string, unknown> | undefined;
|
|
103
|
+
dependsOn?: string[] | undefined;
|
|
104
|
+
expectedOutput?: string | undefined;
|
|
105
|
+
}, {
|
|
106
|
+
id: string;
|
|
107
|
+
description: string;
|
|
108
|
+
tool?: string | undefined;
|
|
109
|
+
toolArgs?: Record<string, unknown> | undefined;
|
|
110
|
+
dependsOn?: string[] | undefined;
|
|
111
|
+
expectedOutput?: string | undefined;
|
|
112
|
+
}>, "many">;
|
|
113
|
+
/**
|
|
114
|
+
* Create a plan-execute-refine workflow graph
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const graph = createPlanExecuteRefineGraph({
|
|
119
|
+
* llmProvider: myLLMProvider,
|
|
120
|
+
* tools: [searchTool, calculatorTool],
|
|
121
|
+
* maxRefinements: 3,
|
|
122
|
+
* requireApproval: true,
|
|
123
|
+
* humanHandler: myHumanHandler
|
|
124
|
+
* });
|
|
125
|
+
*
|
|
126
|
+
* const result = await graph.execute({
|
|
127
|
+
* initialState: {
|
|
128
|
+
* data: { task: 'Research and summarize the latest AI developments' }
|
|
129
|
+
* }
|
|
130
|
+
* });
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
* @param config - Graph configuration
|
|
134
|
+
* @returns Configured StateGraph
|
|
135
|
+
*/
|
|
136
|
+
export declare function createPlanExecuteRefineGraph(config: PlanExecuteRefineConfig): StateGraph<PlanExecuteState>;
|
|
137
|
+
/**
|
|
138
|
+
* Create a simple task executor graph (simplified version)
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* const graph = createSimpleTaskGraph({
|
|
143
|
+
* llmProvider: myProvider,
|
|
144
|
+
* tools: [searchTool]
|
|
145
|
+
* });
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export declare function createSimpleTaskGraph(config: Omit<PlanExecuteRefineConfig, 'requireApproval' | 'humanHandler'>): StateGraph<PlanExecuteState>;
|
|
149
|
+
//# sourceMappingURL=plan-execute-refine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-execute-refine.d.ts","sourceRoot":"","sources":["../../src/prebuilt-graphs/plan-execute-refine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EACV,UAAU,EACV,IAAI,EACJ,WAAW,EAGZ,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,uBAAuB;IACvB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG;QAClC,yBAAyB;QACzB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,2BAA2B;QAC3B,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;QAClB,kCAAkC;QAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,sCAAsC;QACtC,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;QAC3B,+BAA+B;QAC/B,eAAe,CAAC,EACZ,UAAU,GACV,WAAW,GACX,UAAU,GACV,UAAU,GACV,QAAQ,CAAC;QACb,sCAAsC;QACtC,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,oCAAoC;QACpC,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,mBAAmB;QACnB,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,sBAAsB;IACtB,EAAE,EAAE,MAA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