@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,600 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Plan-Execute-Refine Graph - Ready-to-use workflow pattern
|
|
4
|
+
* @module @wundr.io/langgraph-orchestrator
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.PlanSchema = void 0;
|
|
8
|
+
exports.createPlanExecuteRefineGraph = createPlanExecuteRefineGraph;
|
|
9
|
+
exports.createSimpleTaskGraph = createSimpleTaskGraph;
|
|
10
|
+
const uuid_1 = require("uuid");
|
|
11
|
+
const zod_1 = require("zod");
|
|
12
|
+
const decision_node_1 = require("../nodes/decision-node");
|
|
13
|
+
const human_node_1 = require("../nodes/human-node");
|
|
14
|
+
const llm_node_1 = require("../nodes/llm-node");
|
|
15
|
+
const tool_node_1 = require("../nodes/tool-node");
|
|
16
|
+
const state_graph_1 = require("../state-graph");
|
|
17
|
+
/**
|
|
18
|
+
* Schema for plan validation
|
|
19
|
+
*/
|
|
20
|
+
exports.PlanSchema = zod_1.z.array(zod_1.z.object({
|
|
21
|
+
id: zod_1.z.string(),
|
|
22
|
+
description: zod_1.z.string(),
|
|
23
|
+
tool: zod_1.z.string().optional(),
|
|
24
|
+
toolArgs: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
25
|
+
dependsOn: zod_1.z.array(zod_1.z.string()).optional(),
|
|
26
|
+
expectedOutput: zod_1.z.string().optional(),
|
|
27
|
+
}));
|
|
28
|
+
/**
|
|
29
|
+
* Create a plan-execute-refine workflow graph
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const graph = createPlanExecuteRefineGraph({
|
|
34
|
+
* llmProvider: myLLMProvider,
|
|
35
|
+
* tools: [searchTool, calculatorTool],
|
|
36
|
+
* maxRefinements: 3,
|
|
37
|
+
* requireApproval: true,
|
|
38
|
+
* humanHandler: myHumanHandler
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* const result = await graph.execute({
|
|
42
|
+
* initialState: {
|
|
43
|
+
* data: { task: 'Research and summarize the latest AI developments' }
|
|
44
|
+
* }
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @param config - Graph configuration
|
|
49
|
+
* @returns Configured StateGraph
|
|
50
|
+
*/
|
|
51
|
+
function createPlanExecuteRefineGraph(config) {
|
|
52
|
+
const graph = new state_graph_1.StateGraph('plan-execute-refine');
|
|
53
|
+
// Set up services
|
|
54
|
+
const toolRegistry = (0, tool_node_1.createToolRegistry)();
|
|
55
|
+
config.tools?.forEach(tool => toolRegistry.register(tool));
|
|
56
|
+
graph.setServices({
|
|
57
|
+
llmProvider: config.llmProvider,
|
|
58
|
+
toolRegistry,
|
|
59
|
+
});
|
|
60
|
+
// =========================================================================
|
|
61
|
+
// Node: Planner - Creates the initial plan
|
|
62
|
+
// =========================================================================
|
|
63
|
+
const plannerNode = (0, llm_node_1.createLLMNode)({
|
|
64
|
+
id: 'planner',
|
|
65
|
+
name: 'Planner',
|
|
66
|
+
config: {
|
|
67
|
+
model: config.model,
|
|
68
|
+
systemPrompt: config.plannerPrompt ?? DEFAULT_PLANNER_PROMPT,
|
|
69
|
+
promptTemplate: state => {
|
|
70
|
+
const task = state.data.task ?? 'No task specified';
|
|
71
|
+
const tools = config.tools?.map(t => `- ${t.name}: ${t.description}`).join('\n') ??
|
|
72
|
+
'No tools available';
|
|
73
|
+
return `Task: ${task}\n\nAvailable Tools:\n${tools}\n\nCreate a detailed plan to accomplish this task.`;
|
|
74
|
+
},
|
|
75
|
+
postProcess: (response, state) => {
|
|
76
|
+
// Parse plan from response
|
|
77
|
+
const plan = extractPlanFromResponse(response.message.content);
|
|
78
|
+
return {
|
|
79
|
+
data: {
|
|
80
|
+
...state.data,
|
|
81
|
+
plan,
|
|
82
|
+
currentStepIndex: 0,
|
|
83
|
+
stepResults: [],
|
|
84
|
+
executionStatus: 'planning',
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
// =========================================================================
|
|
91
|
+
// Node: Plan Validator - Validates the generated plan
|
|
92
|
+
// =========================================================================
|
|
93
|
+
const validatorNode = {
|
|
94
|
+
id: 'validator',
|
|
95
|
+
name: 'Plan Validator',
|
|
96
|
+
type: 'transform',
|
|
97
|
+
config: {},
|
|
98
|
+
execute: async (state, context) => {
|
|
99
|
+
const plan = state.data.plan;
|
|
100
|
+
if (!plan || plan.length === 0) {
|
|
101
|
+
context.services.logger.warn('Empty or invalid plan generated');
|
|
102
|
+
return {
|
|
103
|
+
state: {
|
|
104
|
+
...state,
|
|
105
|
+
data: {
|
|
106
|
+
...state.data,
|
|
107
|
+
executionStatus: 'failed',
|
|
108
|
+
},
|
|
109
|
+
error: {
|
|
110
|
+
code: 'INVALID_PLAN',
|
|
111
|
+
message: 'Failed to generate a valid plan',
|
|
112
|
+
recoverable: true,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
next: 'refiner',
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
// Validate plan structure
|
|
119
|
+
try {
|
|
120
|
+
exports.PlanSchema.parse(plan);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
context.services.logger.error('Plan validation failed', { error });
|
|
124
|
+
return {
|
|
125
|
+
state: {
|
|
126
|
+
...state,
|
|
127
|
+
data: {
|
|
128
|
+
...state.data,
|
|
129
|
+
executionStatus: 'failed',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
next: 'refiner',
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
// Validate tool references
|
|
136
|
+
for (const step of plan) {
|
|
137
|
+
if (step.tool && !toolRegistry.get(step.tool)) {
|
|
138
|
+
context.services.logger.warn(`Unknown tool referenced: ${step.tool}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
context.services.logger.info(`Plan validated with ${plan.length} steps`);
|
|
142
|
+
return {
|
|
143
|
+
state: {
|
|
144
|
+
...state,
|
|
145
|
+
data: {
|
|
146
|
+
...state.data,
|
|
147
|
+
executionStatus: 'executing',
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
next: config.requireApproval ? 'approval' : 'executor',
|
|
151
|
+
};
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
// =========================================================================
|
|
155
|
+
// Node: Approval - Human approval before execution (optional)
|
|
156
|
+
// =========================================================================
|
|
157
|
+
let approvalNode;
|
|
158
|
+
if (config.humanHandler) {
|
|
159
|
+
approvalNode = (0, human_node_1.createHumanNode)({
|
|
160
|
+
id: 'approval',
|
|
161
|
+
name: 'Plan Approval',
|
|
162
|
+
config: {
|
|
163
|
+
inputHandler: config.humanHandler,
|
|
164
|
+
prompt: state => {
|
|
165
|
+
const plan = state.data['plan'] ?? [];
|
|
166
|
+
const planText = plan
|
|
167
|
+
.map((s, i) => `${i + 1}. ${s.description}`)
|
|
168
|
+
.join('\n');
|
|
169
|
+
return `Please review the following plan:\n\n${planText}\n\nDo you approve this plan?`;
|
|
170
|
+
},
|
|
171
|
+
choices: [
|
|
172
|
+
{
|
|
173
|
+
value: 'approve',
|
|
174
|
+
label: 'Approve',
|
|
175
|
+
description: 'Proceed with execution',
|
|
176
|
+
},
|
|
177
|
+
{ value: 'reject', label: 'Reject', description: 'Request new plan' },
|
|
178
|
+
{
|
|
179
|
+
value: 'modify',
|
|
180
|
+
label: 'Modify',
|
|
181
|
+
description: 'Provide feedback for refinement',
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
processResponse: (response, _state) => {
|
|
185
|
+
if (response.value === 'reject') {
|
|
186
|
+
return { planRejected: true };
|
|
187
|
+
}
|
|
188
|
+
if (response.value === 'modify') {
|
|
189
|
+
return { planFeedback: response.metadata?.feedback };
|
|
190
|
+
}
|
|
191
|
+
return { planApproved: true };
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
// =========================================================================
|
|
197
|
+
// Node: Approval Router - Routes based on approval decision
|
|
198
|
+
// =========================================================================
|
|
199
|
+
const approvalRouterNode = (0, decision_node_1.createDecisionNode)({
|
|
200
|
+
id: 'approval-router',
|
|
201
|
+
name: 'Approval Router',
|
|
202
|
+
config: {
|
|
203
|
+
branches: [
|
|
204
|
+
{
|
|
205
|
+
name: 'approved',
|
|
206
|
+
target: 'executor',
|
|
207
|
+
condition: {
|
|
208
|
+
type: 'equals',
|
|
209
|
+
field: 'data.planApproved',
|
|
210
|
+
value: true,
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: 'rejected',
|
|
215
|
+
target: 'planner',
|
|
216
|
+
condition: {
|
|
217
|
+
type: 'equals',
|
|
218
|
+
field: 'data.planRejected',
|
|
219
|
+
value: true,
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
defaultBranch: 'refiner',
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
// =========================================================================
|
|
227
|
+
// Node: Executor - Executes plan steps
|
|
228
|
+
// =========================================================================
|
|
229
|
+
const executorNode = {
|
|
230
|
+
id: 'executor',
|
|
231
|
+
name: 'Step Executor',
|
|
232
|
+
type: 'transform',
|
|
233
|
+
config: {},
|
|
234
|
+
execute: async (state, context) => {
|
|
235
|
+
const plan = state.data.plan ?? [];
|
|
236
|
+
const currentIndex = state.data.currentStepIndex ?? 0;
|
|
237
|
+
const stepResults = state.data.stepResults ?? [];
|
|
238
|
+
if (currentIndex >= plan.length) {
|
|
239
|
+
context.services.logger.info('All steps executed');
|
|
240
|
+
return {
|
|
241
|
+
state: {
|
|
242
|
+
...state,
|
|
243
|
+
data: {
|
|
244
|
+
...state.data,
|
|
245
|
+
executionStatus: 'refining',
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
next: 'evaluator',
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
const step = plan[currentIndex];
|
|
252
|
+
if (!step) {
|
|
253
|
+
return {
|
|
254
|
+
state: {
|
|
255
|
+
...state,
|
|
256
|
+
data: {
|
|
257
|
+
...state.data,
|
|
258
|
+
currentStepIndex: currentIndex + 1,
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
next: 'executor', // Continue to next step
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
context.services.logger.info(`Executing step ${currentIndex + 1}: ${step.description}`);
|
|
265
|
+
let result;
|
|
266
|
+
try {
|
|
267
|
+
// Check dependencies
|
|
268
|
+
if (step.dependsOn?.length) {
|
|
269
|
+
for (const depId of step.dependsOn) {
|
|
270
|
+
const depResult = stepResults.find(r => r.stepId === depId);
|
|
271
|
+
if (!depResult?.success) {
|
|
272
|
+
throw new Error(`Dependency ${depId} not satisfied`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
// Execute tool if specified
|
|
277
|
+
let stepOutput;
|
|
278
|
+
if (step.tool) {
|
|
279
|
+
const tool = toolRegistry.get(step.tool);
|
|
280
|
+
if (!tool) {
|
|
281
|
+
throw new Error(`Tool ${step.tool} not found`);
|
|
282
|
+
}
|
|
283
|
+
stepOutput = await tool.execute(step.toolArgs ?? {});
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
// For non-tool steps, use LLM
|
|
287
|
+
const llmResponse = await config.llmProvider.generate({
|
|
288
|
+
messages: [
|
|
289
|
+
...state.messages,
|
|
290
|
+
{
|
|
291
|
+
id: (0, uuid_1.v4)(),
|
|
292
|
+
role: 'user',
|
|
293
|
+
content: `Execute step: ${step.description}`,
|
|
294
|
+
timestamp: new Date(),
|
|
295
|
+
},
|
|
296
|
+
],
|
|
297
|
+
model: config.model,
|
|
298
|
+
});
|
|
299
|
+
stepOutput = llmResponse.message.content;
|
|
300
|
+
}
|
|
301
|
+
result = {
|
|
302
|
+
stepId: step.id,
|
|
303
|
+
success: true,
|
|
304
|
+
result: stepOutput,
|
|
305
|
+
timestamp: new Date(),
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
310
|
+
context.services.logger.error(`Step ${step.id} failed`, {
|
|
311
|
+
error: err.message,
|
|
312
|
+
});
|
|
313
|
+
result = {
|
|
314
|
+
stepId: step.id,
|
|
315
|
+
success: false,
|
|
316
|
+
error: err.message,
|
|
317
|
+
timestamp: new Date(),
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
return {
|
|
321
|
+
state: {
|
|
322
|
+
...state,
|
|
323
|
+
data: {
|
|
324
|
+
...state.data,
|
|
325
|
+
currentStepIndex: currentIndex + 1,
|
|
326
|
+
stepResults: [...stepResults, result],
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
next: 'executor', // Continue to next step
|
|
330
|
+
};
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
// =========================================================================
|
|
334
|
+
// Node: Evaluator - Evaluates execution results
|
|
335
|
+
// =========================================================================
|
|
336
|
+
const evaluatorNode = (0, llm_node_1.createLLMNode)({
|
|
337
|
+
id: 'evaluator',
|
|
338
|
+
name: 'Result Evaluator',
|
|
339
|
+
config: {
|
|
340
|
+
model: config.model,
|
|
341
|
+
systemPrompt: 'You are an expert at evaluating task execution results.',
|
|
342
|
+
promptTemplate: state => {
|
|
343
|
+
const task = state.data['task'] ?? 'Unknown task';
|
|
344
|
+
const results = state.data['stepResults'] ?? [];
|
|
345
|
+
const resultsText = results
|
|
346
|
+
.map((r) => `Step ${r.stepId}: ${r.success ? 'Success' : 'Failed'}\n${r.success ? JSON.stringify(r.result) : r.error}`)
|
|
347
|
+
.join('\n\n');
|
|
348
|
+
return `Original Task: ${task}\n\nExecution Results:\n${resultsText}\n\nEvaluate if the task was completed successfully. If not, identify what needs to be refined.`;
|
|
349
|
+
},
|
|
350
|
+
postProcess: (response, state) => {
|
|
351
|
+
const content = response.message.content.toLowerCase();
|
|
352
|
+
const isComplete = content.includes('complete') || content.includes('success');
|
|
353
|
+
return {
|
|
354
|
+
data: {
|
|
355
|
+
...state.data,
|
|
356
|
+
executionStatus: isComplete
|
|
357
|
+
? 'complete'
|
|
358
|
+
: 'refining',
|
|
359
|
+
evaluationResult: response.message.content,
|
|
360
|
+
},
|
|
361
|
+
};
|
|
362
|
+
},
|
|
363
|
+
router: (response, _state) => {
|
|
364
|
+
const content = response.message.content.toLowerCase();
|
|
365
|
+
if (content.includes('complete') || content.includes('success')) {
|
|
366
|
+
return 'complete';
|
|
367
|
+
}
|
|
368
|
+
return 'refiner';
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
});
|
|
372
|
+
// =========================================================================
|
|
373
|
+
// Node: Refiner - Refines the plan based on execution results
|
|
374
|
+
// =========================================================================
|
|
375
|
+
const refinerNode = (0, llm_node_1.createLLMNode)({
|
|
376
|
+
id: 'refiner',
|
|
377
|
+
name: 'Plan Refiner',
|
|
378
|
+
config: {
|
|
379
|
+
model: config.model,
|
|
380
|
+
systemPrompt: config.refinerPrompt ?? DEFAULT_REFINER_PROMPT,
|
|
381
|
+
promptTemplate: state => {
|
|
382
|
+
const task = state.data.task ?? 'Unknown task';
|
|
383
|
+
const plan = state.data['plan'] ?? [];
|
|
384
|
+
const results = state.data['stepResults'] ?? [];
|
|
385
|
+
const evaluation = state.data['evaluationResult'] ?? '';
|
|
386
|
+
const feedback = state.data['planFeedback'] ?? '';
|
|
387
|
+
return `Original Task: ${task}
|
|
388
|
+
|
|
389
|
+
Previous Plan:
|
|
390
|
+
${plan.map((s, i) => `${i + 1}. ${s.description}`).join('\n')}
|
|
391
|
+
|
|
392
|
+
Execution Results:
|
|
393
|
+
${results.map((r) => `${r.stepId}: ${r.success ? 'Success' : 'Failed - ' + r.error}`).join('\n')}
|
|
394
|
+
|
|
395
|
+
Evaluation: ${evaluation}
|
|
396
|
+
${feedback ? `Human Feedback: ${feedback}` : ''}
|
|
397
|
+
|
|
398
|
+
Please refine the plan to address any issues and ensure task completion.`;
|
|
399
|
+
},
|
|
400
|
+
postProcess: (response, state) => {
|
|
401
|
+
const refinedPlan = extractPlanFromResponse(response.message.content);
|
|
402
|
+
const refinementCount = (state.data['refinementCount'] ?? 0) + 1;
|
|
403
|
+
return {
|
|
404
|
+
data: {
|
|
405
|
+
...state.data,
|
|
406
|
+
plan: refinedPlan,
|
|
407
|
+
currentStepIndex: 0,
|
|
408
|
+
stepResults: [],
|
|
409
|
+
refinementCount,
|
|
410
|
+
executionStatus: 'planning',
|
|
411
|
+
},
|
|
412
|
+
};
|
|
413
|
+
},
|
|
414
|
+
},
|
|
415
|
+
});
|
|
416
|
+
// =========================================================================
|
|
417
|
+
// Node: Refinement Check - Checks if we've exceeded max refinements
|
|
418
|
+
// =========================================================================
|
|
419
|
+
const refinementCheckNode = (0, decision_node_1.createIfElseNode)({
|
|
420
|
+
id: 'refinement-check',
|
|
421
|
+
name: 'Refinement Check',
|
|
422
|
+
condition: {
|
|
423
|
+
type: 'custom',
|
|
424
|
+
evaluate: async (state) => {
|
|
425
|
+
const count = state.data.refinementCount ?? 0;
|
|
426
|
+
const max = state.data.maxRefinements ?? config.maxRefinements ?? 3;
|
|
427
|
+
return count < max;
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
ifTrue: 'validator',
|
|
431
|
+
ifFalse: 'failed',
|
|
432
|
+
});
|
|
433
|
+
// =========================================================================
|
|
434
|
+
// Node: Complete - Final success node
|
|
435
|
+
// =========================================================================
|
|
436
|
+
const completeNode = {
|
|
437
|
+
id: 'complete',
|
|
438
|
+
name: 'Complete',
|
|
439
|
+
type: 'end',
|
|
440
|
+
config: {},
|
|
441
|
+
execute: async (state, context) => {
|
|
442
|
+
context.services.logger.info('Workflow completed successfully');
|
|
443
|
+
// Compile final result from step results
|
|
444
|
+
const finalResult = state.data.stepResults?.map(r => r.result);
|
|
445
|
+
return {
|
|
446
|
+
state: {
|
|
447
|
+
...state,
|
|
448
|
+
data: {
|
|
449
|
+
...state.data,
|
|
450
|
+
executionStatus: 'complete',
|
|
451
|
+
finalResult,
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
terminate: true,
|
|
455
|
+
};
|
|
456
|
+
},
|
|
457
|
+
};
|
|
458
|
+
// =========================================================================
|
|
459
|
+
// Node: Failed - Final failure node
|
|
460
|
+
// =========================================================================
|
|
461
|
+
const failedNode = {
|
|
462
|
+
id: 'failed',
|
|
463
|
+
name: 'Failed',
|
|
464
|
+
type: 'end',
|
|
465
|
+
config: {},
|
|
466
|
+
execute: async (state, context) => {
|
|
467
|
+
context.services.logger.error('Workflow failed after max refinements');
|
|
468
|
+
return {
|
|
469
|
+
state: {
|
|
470
|
+
...state,
|
|
471
|
+
data: {
|
|
472
|
+
...state.data,
|
|
473
|
+
executionStatus: 'failed',
|
|
474
|
+
},
|
|
475
|
+
error: {
|
|
476
|
+
code: 'MAX_REFINEMENTS',
|
|
477
|
+
message: `Failed to complete task after ${state.data.refinementCount} refinement attempts`,
|
|
478
|
+
recoverable: false,
|
|
479
|
+
},
|
|
480
|
+
},
|
|
481
|
+
terminate: true,
|
|
482
|
+
};
|
|
483
|
+
},
|
|
484
|
+
};
|
|
485
|
+
// =========================================================================
|
|
486
|
+
// Build the graph
|
|
487
|
+
// =========================================================================
|
|
488
|
+
graph
|
|
489
|
+
.addNode('planner', plannerNode)
|
|
490
|
+
.addNode('validator', validatorNode)
|
|
491
|
+
.addNode('executor', executorNode)
|
|
492
|
+
.addNode('evaluator', evaluatorNode)
|
|
493
|
+
.addNode('refiner', refinerNode)
|
|
494
|
+
.addNode('refinement-check', refinementCheckNode)
|
|
495
|
+
.addNode('complete', completeNode)
|
|
496
|
+
.addNode('failed', failedNode);
|
|
497
|
+
if (approvalNode) {
|
|
498
|
+
graph.addNode('approval', approvalNode);
|
|
499
|
+
graph.addNode('approval-router', approvalRouterNode);
|
|
500
|
+
}
|
|
501
|
+
// Add edges
|
|
502
|
+
graph.addEdge('planner', 'validator').addEdge('refiner', 'refinement-check');
|
|
503
|
+
if (config.requireApproval && approvalNode) {
|
|
504
|
+
graph
|
|
505
|
+
.addEdge('validator', 'approval')
|
|
506
|
+
.addEdge('approval', 'approval-router');
|
|
507
|
+
}
|
|
508
|
+
// Set entry point
|
|
509
|
+
graph.setEntryPoint('planner');
|
|
510
|
+
return graph;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Extract plan from LLM response
|
|
514
|
+
*/
|
|
515
|
+
function extractPlanFromResponse(content) {
|
|
516
|
+
const steps = [];
|
|
517
|
+
// Try to parse JSON if present
|
|
518
|
+
const jsonMatch = content.match(/\[[\s\S]*\]/);
|
|
519
|
+
if (jsonMatch) {
|
|
520
|
+
try {
|
|
521
|
+
const parsed = JSON.parse(jsonMatch[0]);
|
|
522
|
+
if (Array.isArray(parsed)) {
|
|
523
|
+
return parsed.map((item, index) => ({
|
|
524
|
+
id: item.id ?? `step-${index + 1}`,
|
|
525
|
+
description: item.description ?? item.step ?? String(item),
|
|
526
|
+
tool: item.tool,
|
|
527
|
+
toolArgs: item.toolArgs ?? item.args,
|
|
528
|
+
dependsOn: item.dependsOn ?? item.dependencies,
|
|
529
|
+
expectedOutput: item.expectedOutput ?? item.expected,
|
|
530
|
+
}));
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
catch {
|
|
534
|
+
// Fall through to text parsing
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
// Parse numbered list format
|
|
538
|
+
const lines = content.split('\n');
|
|
539
|
+
let stepIndex = 0;
|
|
540
|
+
for (const line of lines) {
|
|
541
|
+
const match = line.match(/^\d+\.\s*(.+)$/);
|
|
542
|
+
if (match && match[1]) {
|
|
543
|
+
stepIndex++;
|
|
544
|
+
steps.push({
|
|
545
|
+
id: `step-${stepIndex}`,
|
|
546
|
+
description: match[1].trim(),
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return steps;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Default planner system prompt
|
|
554
|
+
*/
|
|
555
|
+
const DEFAULT_PLANNER_PROMPT = `You are an expert planner. Given a task, create a detailed step-by-step plan to accomplish it.
|
|
556
|
+
|
|
557
|
+
Your plan should:
|
|
558
|
+
1. Break down the task into clear, actionable steps
|
|
559
|
+
2. Identify which tools to use for each step (if applicable)
|
|
560
|
+
3. Consider dependencies between steps
|
|
561
|
+
4. Be specific about expected outputs
|
|
562
|
+
|
|
563
|
+
Output your plan as a JSON array of steps, each with:
|
|
564
|
+
- id: unique identifier
|
|
565
|
+
- description: what this step does
|
|
566
|
+
- tool: (optional) tool name to use
|
|
567
|
+
- toolArgs: (optional) arguments for the tool
|
|
568
|
+
- dependsOn: (optional) array of step IDs this depends on
|
|
569
|
+
- expectedOutput: (optional) description of expected result`;
|
|
570
|
+
/**
|
|
571
|
+
* Default refiner system prompt
|
|
572
|
+
*/
|
|
573
|
+
const DEFAULT_REFINER_PROMPT = `You are an expert at analyzing execution results and refining plans.
|
|
574
|
+
|
|
575
|
+
Based on the execution results and any feedback, create an improved plan that:
|
|
576
|
+
1. Addresses any failed steps
|
|
577
|
+
2. Incorporates lessons learned
|
|
578
|
+
3. Optimizes the approach based on what worked
|
|
579
|
+
4. Includes any additional steps needed for success
|
|
580
|
+
|
|
581
|
+
Output your refined plan in the same JSON format as the original.`;
|
|
582
|
+
/**
|
|
583
|
+
* Create a simple task executor graph (simplified version)
|
|
584
|
+
*
|
|
585
|
+
* @example
|
|
586
|
+
* ```typescript
|
|
587
|
+
* const graph = createSimpleTaskGraph({
|
|
588
|
+
* llmProvider: myProvider,
|
|
589
|
+
* tools: [searchTool]
|
|
590
|
+
* });
|
|
591
|
+
* ```
|
|
592
|
+
*/
|
|
593
|
+
function createSimpleTaskGraph(config) {
|
|
594
|
+
return createPlanExecuteRefineGraph({
|
|
595
|
+
...config,
|
|
596
|
+
requireApproval: false,
|
|
597
|
+
maxRefinements: config.maxRefinements ?? 2,
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
//# sourceMappingURL=plan-execute-refine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-execute-refine.js","sourceRoot":"","sources":["../../src/prebuilt-graphs/plan-execute-refine.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAiJH,oEA2gBC;AAyFD,sDAQC;AA3vBD,+BAAoC;AACpC,6BAAwB;AAExB,0DAA8E;AAC9E,oDAAsD;AACtD,gDAAkD;AAClD,kDAAwD;AACxD,gDAA4C;AAmG5C;;GAEG;AACU,QAAA,UAAU,GAAG,OAAC,CAAC,KAAK,CAC/B,OAAC,CAAC,MAAM,CAAC;IACP,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;IACd,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE;IACvB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,QAAQ,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC1C,SAAS,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACzC,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACtC,CAAC,CACH,CAA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