@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,394 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Human Node - Human-in-the-loop interaction node
|
|
4
|
+
* @module @wundr.io/langgraph-orchestrator
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.HumanNodeConfigSchema = void 0;
|
|
8
|
+
exports.createHumanNode = createHumanNode;
|
|
9
|
+
exports.createConsoleInputHandler = createConsoleInputHandler;
|
|
10
|
+
exports.createCallbackInputHandler = createCallbackInputHandler;
|
|
11
|
+
exports.createConfirmationNode = createConfirmationNode;
|
|
12
|
+
exports.createFeedbackNode = createFeedbackNode;
|
|
13
|
+
const uuid_1 = require("uuid");
|
|
14
|
+
const zod_1 = require("zod");
|
|
15
|
+
/**
|
|
16
|
+
* Schema for human node configuration validation
|
|
17
|
+
*/
|
|
18
|
+
exports.HumanNodeConfigSchema = zod_1.z.object({
|
|
19
|
+
prompt: zod_1.z.union([zod_1.z.string(), zod_1.z.function()]).optional(),
|
|
20
|
+
timeout: zod_1.z.number().min(0).optional(),
|
|
21
|
+
onTimeout: zod_1.z.enum(['error', 'skip', 'default']).optional(),
|
|
22
|
+
choices: zod_1.z
|
|
23
|
+
.array(zod_1.z.object({
|
|
24
|
+
value: zod_1.z.string(),
|
|
25
|
+
label: zod_1.z.string(),
|
|
26
|
+
description: zod_1.z.string().optional(),
|
|
27
|
+
default: zod_1.z.boolean().optional(),
|
|
28
|
+
}))
|
|
29
|
+
.optional(),
|
|
30
|
+
requireConfirmation: zod_1.z.boolean().optional(),
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Create a human-in-the-loop node
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const humanNode = createHumanNode({
|
|
38
|
+
* id: 'approval',
|
|
39
|
+
* name: 'Human Approval',
|
|
40
|
+
* config: {
|
|
41
|
+
* prompt: 'Please review and approve the generated content.',
|
|
42
|
+
* inputHandler: myInputHandler,
|
|
43
|
+
* choices: [
|
|
44
|
+
* { value: 'approve', label: 'Approve' },
|
|
45
|
+
* { value: 'reject', label: 'Reject' },
|
|
46
|
+
* { value: 'modify', label: 'Request Modifications' }
|
|
47
|
+
* ],
|
|
48
|
+
* timeout: 300000 // 5 minutes
|
|
49
|
+
* }
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* graph.addNode('approval', humanNode);
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @param options - Node creation options
|
|
56
|
+
* @returns NodeDefinition for use in StateGraph
|
|
57
|
+
*/
|
|
58
|
+
function createHumanNode(options) {
|
|
59
|
+
const { id, name, config, nodeConfig = {} } = options;
|
|
60
|
+
return {
|
|
61
|
+
id,
|
|
62
|
+
name,
|
|
63
|
+
type: 'human',
|
|
64
|
+
config: nodeConfig,
|
|
65
|
+
execute: async (state, context) => {
|
|
66
|
+
const requestId = (0, uuid_1.v4)();
|
|
67
|
+
// Build prompt
|
|
68
|
+
const prompt = typeof config.prompt === 'function'
|
|
69
|
+
? config.prompt(state)
|
|
70
|
+
: (config.prompt ?? 'Please provide input:');
|
|
71
|
+
context.services.logger.info('Requesting human input', {
|
|
72
|
+
requestId,
|
|
73
|
+
hasChoices: Boolean(config.choices?.length),
|
|
74
|
+
});
|
|
75
|
+
// Build input context
|
|
76
|
+
const inputContext = {
|
|
77
|
+
requestId,
|
|
78
|
+
prompt,
|
|
79
|
+
choices: config.choices,
|
|
80
|
+
state: sanitizeStateForHuman(state),
|
|
81
|
+
timeout: config.timeout,
|
|
82
|
+
metadata: {
|
|
83
|
+
nodeId: id,
|
|
84
|
+
nodeName: name,
|
|
85
|
+
executionId: context.executionId,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
let response;
|
|
89
|
+
try {
|
|
90
|
+
// Request input with timeout if configured
|
|
91
|
+
if (config.timeout) {
|
|
92
|
+
response = await Promise.race([
|
|
93
|
+
config.inputHandler.request(inputContext),
|
|
94
|
+
createTimeoutPromise(config.timeout, requestId),
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
response = await config.inputHandler.request(inputContext);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
// Handle timeout
|
|
103
|
+
if (error.message === 'TIMEOUT') {
|
|
104
|
+
response = {
|
|
105
|
+
value: config.defaultValue,
|
|
106
|
+
type: 'timeout',
|
|
107
|
+
timestamp: new Date(),
|
|
108
|
+
};
|
|
109
|
+
if (config.onTimeout === 'error') {
|
|
110
|
+
throw new Error(`Human input timed out after ${config.timeout}ms`);
|
|
111
|
+
}
|
|
112
|
+
if (config.onTimeout === 'skip') {
|
|
113
|
+
context.services.logger.warn('Human input timed out, skipping');
|
|
114
|
+
return { state };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
context.services.logger.debug('Received human response', {
|
|
122
|
+
requestId,
|
|
123
|
+
type: response.type,
|
|
124
|
+
});
|
|
125
|
+
// Handle cancellation
|
|
126
|
+
if (response.type === 'cancel') {
|
|
127
|
+
context.services.logger.info('Human cancelled input');
|
|
128
|
+
return {
|
|
129
|
+
state,
|
|
130
|
+
terminate: true,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
// Validate response if schema provided
|
|
134
|
+
if (config.validation && response.type !== 'timeout') {
|
|
135
|
+
try {
|
|
136
|
+
config.validation.parse(response.value);
|
|
137
|
+
}
|
|
138
|
+
catch (validationError) {
|
|
139
|
+
throw new Error(`Human input validation failed: ${validationError instanceof Error ? validationError.message : String(validationError)}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Build human message
|
|
143
|
+
const humanMessage = {
|
|
144
|
+
id: (0, uuid_1.v4)(),
|
|
145
|
+
role: 'user',
|
|
146
|
+
content: formatResponseContent(response),
|
|
147
|
+
timestamp: response.timestamp,
|
|
148
|
+
metadata: {
|
|
149
|
+
requestId,
|
|
150
|
+
responseType: response.type,
|
|
151
|
+
...response.metadata,
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
// Build updated state
|
|
155
|
+
let newData = { ...state.data };
|
|
156
|
+
newData['lastHumanResponse'] = response;
|
|
157
|
+
// Apply custom response processor
|
|
158
|
+
if (config.processResponse) {
|
|
159
|
+
const processed = config.processResponse(response, state);
|
|
160
|
+
newData = { ...newData, ...processed };
|
|
161
|
+
}
|
|
162
|
+
const newState = {
|
|
163
|
+
...state,
|
|
164
|
+
messages: [...state.messages, humanMessage],
|
|
165
|
+
data: newData,
|
|
166
|
+
};
|
|
167
|
+
return {
|
|
168
|
+
state: newState,
|
|
169
|
+
metadata: {
|
|
170
|
+
duration: 0,
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Sanitize state for human viewing
|
|
178
|
+
*/
|
|
179
|
+
function sanitizeStateForHuman(state) {
|
|
180
|
+
return {
|
|
181
|
+
currentStep: state.currentStep,
|
|
182
|
+
data: state.data,
|
|
183
|
+
messages: state.messages.slice(-5), // Only show recent messages
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Create a timeout promise
|
|
188
|
+
*/
|
|
189
|
+
function createTimeoutPromise(timeout, _requestId) {
|
|
190
|
+
return new Promise((_, reject) => {
|
|
191
|
+
setTimeout(() => reject(new Error('TIMEOUT')), timeout);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Format response content as string
|
|
196
|
+
*/
|
|
197
|
+
function formatResponseContent(response) {
|
|
198
|
+
if (response.type === 'timeout') {
|
|
199
|
+
return '[Timed out - using default]';
|
|
200
|
+
}
|
|
201
|
+
if (response.type === 'cancel') {
|
|
202
|
+
return '[Cancelled]';
|
|
203
|
+
}
|
|
204
|
+
if (typeof response.value === 'string') {
|
|
205
|
+
return response.value;
|
|
206
|
+
}
|
|
207
|
+
return JSON.stringify(response.value);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Create a console-based human input handler
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* const handler = createConsoleInputHandler();
|
|
215
|
+
*
|
|
216
|
+
* const humanNode = createHumanNode({
|
|
217
|
+
* id: 'input',
|
|
218
|
+
* name: 'User Input',
|
|
219
|
+
* config: {
|
|
220
|
+
* inputHandler: handler,
|
|
221
|
+
* prompt: 'Enter your response:'
|
|
222
|
+
* }
|
|
223
|
+
* });
|
|
224
|
+
* ```
|
|
225
|
+
*
|
|
226
|
+
* @returns HumanInputHandler for console input
|
|
227
|
+
*/
|
|
228
|
+
function createConsoleInputHandler() {
|
|
229
|
+
// Note: This is a placeholder - actual console input would need readline
|
|
230
|
+
// In production, use a proper event-based input handler
|
|
231
|
+
return {
|
|
232
|
+
async request(_context) {
|
|
233
|
+
// In a real implementation, this would read from stdin
|
|
234
|
+
// For now, return a placeholder response
|
|
235
|
+
return {
|
|
236
|
+
value: 'placeholder-response',
|
|
237
|
+
type: 'input',
|
|
238
|
+
timestamp: new Date(),
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Create a callback-based human input handler
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* const pendingRequests = new Map();
|
|
249
|
+
*
|
|
250
|
+
* const handler = createCallbackInputHandler({
|
|
251
|
+
* onRequest: (context) => {
|
|
252
|
+
* pendingRequests.set(context.requestId, context);
|
|
253
|
+
* // Notify UI or external system
|
|
254
|
+
* },
|
|
255
|
+
* onResolve: (requestId) => pendingRequests.delete(requestId)
|
|
256
|
+
* });
|
|
257
|
+
*
|
|
258
|
+
* // External system resolves:
|
|
259
|
+
* handler.resolve(requestId, { value: 'user input', type: 'input', timestamp: new Date() });
|
|
260
|
+
* ```
|
|
261
|
+
*
|
|
262
|
+
* @param options - Handler options
|
|
263
|
+
* @returns HumanInputHandler with resolve capability
|
|
264
|
+
*/
|
|
265
|
+
function createCallbackInputHandler(options) {
|
|
266
|
+
const pending = new Map();
|
|
267
|
+
return {
|
|
268
|
+
async request(context) {
|
|
269
|
+
return new Promise((resolve, reject) => {
|
|
270
|
+
pending.set(context.requestId, { resolve, reject });
|
|
271
|
+
options.onRequest?.(context);
|
|
272
|
+
});
|
|
273
|
+
},
|
|
274
|
+
async cancel(requestId) {
|
|
275
|
+
const handlers = pending.get(requestId);
|
|
276
|
+
if (handlers) {
|
|
277
|
+
handlers.resolve({
|
|
278
|
+
value: null,
|
|
279
|
+
type: 'cancel',
|
|
280
|
+
timestamp: new Date(),
|
|
281
|
+
});
|
|
282
|
+
pending.delete(requestId);
|
|
283
|
+
options.onCancel?.(requestId);
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
resolve(requestId, response) {
|
|
287
|
+
const handlers = pending.get(requestId);
|
|
288
|
+
if (handlers) {
|
|
289
|
+
handlers.resolve(response);
|
|
290
|
+
pending.delete(requestId);
|
|
291
|
+
options.onResolve?.(requestId);
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
reject(requestId, error) {
|
|
295
|
+
const handlers = pending.get(requestId);
|
|
296
|
+
if (handlers) {
|
|
297
|
+
handlers.reject(error);
|
|
298
|
+
pending.delete(requestId);
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Create a confirmation node for human approval
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```typescript
|
|
308
|
+
* const confirmNode = createConfirmationNode({
|
|
309
|
+
* id: 'confirm-action',
|
|
310
|
+
* name: 'Confirm Action',
|
|
311
|
+
* inputHandler: myHandler,
|
|
312
|
+
* message: (state) => `Are you sure you want to ${state.data.action}?`,
|
|
313
|
+
* onConfirm: 'execute-action',
|
|
314
|
+
* onReject: 'cancel-action'
|
|
315
|
+
* });
|
|
316
|
+
* ```
|
|
317
|
+
*
|
|
318
|
+
* @param options - Confirmation node options
|
|
319
|
+
* @returns NodeDefinition for use in StateGraph
|
|
320
|
+
*/
|
|
321
|
+
function createConfirmationNode(options) {
|
|
322
|
+
return createHumanNode({
|
|
323
|
+
id: options.id,
|
|
324
|
+
name: options.name,
|
|
325
|
+
config: {
|
|
326
|
+
prompt: options.message,
|
|
327
|
+
inputHandler: options.inputHandler,
|
|
328
|
+
choices: [
|
|
329
|
+
{ value: 'confirm', label: 'Confirm', default: false },
|
|
330
|
+
{ value: 'reject', label: 'Reject', default: false },
|
|
331
|
+
],
|
|
332
|
+
timeout: options.timeout,
|
|
333
|
+
onTimeout: 'error',
|
|
334
|
+
processResponse: response => ({
|
|
335
|
+
confirmationResult: response.value,
|
|
336
|
+
}),
|
|
337
|
+
},
|
|
338
|
+
nodeConfig: options.nodeConfig,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Create a feedback collection node
|
|
343
|
+
*
|
|
344
|
+
* @example
|
|
345
|
+
* ```typescript
|
|
346
|
+
* const feedbackNode = createFeedbackNode({
|
|
347
|
+
* id: 'collect-feedback',
|
|
348
|
+
* name: 'Collect Feedback',
|
|
349
|
+
* inputHandler: myHandler,
|
|
350
|
+
* questions: [
|
|
351
|
+
* { id: 'rating', prompt: 'Rate this response (1-5):', type: 'number' },
|
|
352
|
+
* { id: 'comments', prompt: 'Any additional comments?', type: 'text' }
|
|
353
|
+
* ]
|
|
354
|
+
* });
|
|
355
|
+
* ```
|
|
356
|
+
*
|
|
357
|
+
* @param options - Feedback node options
|
|
358
|
+
* @returns NodeDefinition for use in StateGraph
|
|
359
|
+
*/
|
|
360
|
+
function createFeedbackNode(options) {
|
|
361
|
+
return {
|
|
362
|
+
id: options.id,
|
|
363
|
+
name: options.name,
|
|
364
|
+
type: 'human',
|
|
365
|
+
config: options.nodeConfig ?? {},
|
|
366
|
+
execute: async (state, _context) => {
|
|
367
|
+
const feedback = {};
|
|
368
|
+
for (const question of options.questions) {
|
|
369
|
+
const requestId = (0, uuid_1.v4)();
|
|
370
|
+
const inputContext = {
|
|
371
|
+
requestId,
|
|
372
|
+
prompt: question.prompt,
|
|
373
|
+
choices: question.choices?.map(c => ({ value: c, label: c })),
|
|
374
|
+
state: sanitizeStateForHuman(state),
|
|
375
|
+
timeout: options.timeout,
|
|
376
|
+
};
|
|
377
|
+
const response = await options.inputHandler.request(inputContext);
|
|
378
|
+
if (response.type === 'cancel') {
|
|
379
|
+
return { state, terminate: true };
|
|
380
|
+
}
|
|
381
|
+
feedback[question.id] = response.value;
|
|
382
|
+
}
|
|
383
|
+
const newState = {
|
|
384
|
+
...state,
|
|
385
|
+
data: {
|
|
386
|
+
...state.data,
|
|
387
|
+
feedback,
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
return { state: newState };
|
|
391
|
+
},
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
//# sourceMappingURL=human-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"human-node.js","sourceRoot":"","sources":["../../src/nodes/human-node.ts"],"names":[],"mappings":";AAAA;;;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CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;oBAC7D,KAAK,EAAE,qBAAqB,CAAC,KAAK,CAAC;oBACnC,OAAO,EAAE,OAAO,CAAC,OAAO;iBACzB,CAAC;gBAEF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;gBAElE,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC/B,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;gBACpC,CAAC;gBAED,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;YACzC,CAAC;YAED,MAAM,QAAQ,GAAW;gBACvB,GAAG,KAAK;gBACR,IAAI,EAAE;oBACJ,GAAG,KAAK,CAAC,IAAI;oBACb,QAAQ;iBACT;aACQ,CAAC;YAEZ,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Node - LLM-based decision and generation node
|
|
3
|
+
* @module @wundr.io/langgraph-orchestrator
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import type { AgentState, NodeDefinition, LLMResponse, Tool } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for LLM node
|
|
9
|
+
*/
|
|
10
|
+
export interface LLMNodeConfig {
|
|
11
|
+
/** Model to use (provider-specific) */
|
|
12
|
+
readonly model?: string;
|
|
13
|
+
/** System prompt for the LLM */
|
|
14
|
+
readonly systemPrompt?: string;
|
|
15
|
+
/** Temperature for generation */
|
|
16
|
+
readonly temperature?: number;
|
|
17
|
+
/** Maximum tokens to generate */
|
|
18
|
+
readonly maxTokens?: number;
|
|
19
|
+
/** Stop sequences */
|
|
20
|
+
readonly stop?: string[];
|
|
21
|
+
/** Available tools for the LLM */
|
|
22
|
+
readonly tools?: Tool[];
|
|
23
|
+
/** Whether to stream the response */
|
|
24
|
+
readonly stream?: boolean;
|
|
25
|
+
/** Custom prompt template */
|
|
26
|
+
readonly promptTemplate?: (state: AgentState) => string;
|
|
27
|
+
/** Post-processing function for response */
|
|
28
|
+
readonly postProcess?: (response: LLMResponse, state: AgentState) => Partial<AgentState>;
|
|
29
|
+
/** Routing function to determine next node based on response */
|
|
30
|
+
readonly router?: (response: LLMResponse, state: AgentState) => string | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Schema for LLM node configuration validation
|
|
34
|
+
*/
|
|
35
|
+
export declare const LLMNodeConfigSchema: z.ZodObject<{
|
|
36
|
+
model: z.ZodOptional<z.ZodString>;
|
|
37
|
+
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
38
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
stop: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
41
|
+
stream: z.ZodOptional<z.ZodBoolean>;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
stop?: string[] | undefined;
|
|
44
|
+
model?: string | undefined;
|
|
45
|
+
systemPrompt?: string | undefined;
|
|
46
|
+
temperature?: number | undefined;
|
|
47
|
+
maxTokens?: number | undefined;
|
|
48
|
+
stream?: boolean | undefined;
|
|
49
|
+
}, {
|
|
50
|
+
stop?: string[] | undefined;
|
|
51
|
+
model?: string | undefined;
|
|
52
|
+
systemPrompt?: string | undefined;
|
|
53
|
+
temperature?: number | undefined;
|
|
54
|
+
maxTokens?: number | undefined;
|
|
55
|
+
stream?: boolean | undefined;
|
|
56
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* Create an LLM node for the workflow graph
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const llmNode = createLLMNode({
|
|
63
|
+
* id: 'agent',
|
|
64
|
+
* name: 'Agent Node',
|
|
65
|
+
* config: {
|
|
66
|
+
* model: 'claude-3-sonnet-20240229',
|
|
67
|
+
* systemPrompt: 'You are a helpful assistant.',
|
|
68
|
+
* temperature: 0.7
|
|
69
|
+
* }
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* graph.addNode('agent', llmNode);
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @param options - Node creation options
|
|
76
|
+
* @returns NodeDefinition for use in StateGraph
|
|
77
|
+
*/
|
|
78
|
+
export declare function createLLMNode<TState extends AgentState = AgentState>(options: {
|
|
79
|
+
id: string;
|
|
80
|
+
name: string;
|
|
81
|
+
config: LLMNodeConfig;
|
|
82
|
+
nodeConfig?: NodeDefinition<TState>['config'];
|
|
83
|
+
}): NodeDefinition<TState>;
|
|
84
|
+
/**
|
|
85
|
+
* Create a router function for LLM decision-making
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const router = createLLMRouter({
|
|
90
|
+
* routes: {
|
|
91
|
+
* 'continue': 'process-node',
|
|
92
|
+
* 'finish': 'end-node',
|
|
93
|
+
* 'error': 'error-handler'
|
|
94
|
+
* },
|
|
95
|
+
* defaultRoute: 'continue',
|
|
96
|
+
* extractDecision: (response) => {
|
|
97
|
+
* const content = response.message.content;
|
|
98
|
+
* if (content.includes('DONE')) return 'finish';
|
|
99
|
+
* if (content.includes('ERROR')) return 'error';
|
|
100
|
+
* return 'continue';
|
|
101
|
+
* }
|
|
102
|
+
* });
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @param options - Router configuration
|
|
106
|
+
* @returns Router function for use in LLM node config
|
|
107
|
+
*/
|
|
108
|
+
export declare function createLLMRouter<TState extends AgentState = AgentState>(options: {
|
|
109
|
+
routes: Record<string, string>;
|
|
110
|
+
defaultRoute?: string;
|
|
111
|
+
extractDecision: (response: LLMResponse, state: TState) => string;
|
|
112
|
+
}): (response: LLMResponse, state: TState) => string | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* Create a structured output LLM node that validates responses
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const responseSchema = z.object({
|
|
119
|
+
* action: z.enum(['search', 'answer', 'clarify']),
|
|
120
|
+
* content: z.string(),
|
|
121
|
+
* confidence: z.number()
|
|
122
|
+
* });
|
|
123
|
+
*
|
|
124
|
+
* const structuredNode = createStructuredLLMNode({
|
|
125
|
+
* id: 'structured-agent',
|
|
126
|
+
* name: 'Structured Agent',
|
|
127
|
+
* config: {
|
|
128
|
+
* model: 'claude-3-sonnet-20240229',
|
|
129
|
+
* systemPrompt: 'Respond in JSON format with action, content, and confidence fields.'
|
|
130
|
+
* },
|
|
131
|
+
* outputSchema: responseSchema,
|
|
132
|
+
* stateMapper: (parsed) => ({ agentDecision: parsed })
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @param options - Structured node options
|
|
137
|
+
* @returns NodeDefinition for use in StateGraph
|
|
138
|
+
*/
|
|
139
|
+
export declare function createStructuredLLMNode<TState extends AgentState = AgentState, TOutput = unknown>(options: {
|
|
140
|
+
id: string;
|
|
141
|
+
name: string;
|
|
142
|
+
config: LLMNodeConfig;
|
|
143
|
+
outputSchema: z.ZodSchema<TOutput>;
|
|
144
|
+
stateMapper: (parsed: TOutput) => Partial<TState['data']>;
|
|
145
|
+
nodeConfig?: NodeDefinition<TState>['config'];
|
|
146
|
+
}): NodeDefinition<TState>;
|
|
147
|
+
/**
|
|
148
|
+
* Create a conversational LLM node that maintains chat history
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* const chatNode = createConversationalLLMNode({
|
|
153
|
+
* id: 'chat',
|
|
154
|
+
* name: 'Chat Node',
|
|
155
|
+
* config: {
|
|
156
|
+
* model: 'claude-3-sonnet-20240229',
|
|
157
|
+
* systemPrompt: 'You are a helpful assistant.'
|
|
158
|
+
* },
|
|
159
|
+
* maxHistoryLength: 10
|
|
160
|
+
* });
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
163
|
+
* @param options - Conversational node options
|
|
164
|
+
* @returns NodeDefinition for use in StateGraph
|
|
165
|
+
*/
|
|
166
|
+
export declare function createConversationalLLMNode<TState extends AgentState = AgentState>(options: {
|
|
167
|
+
id: string;
|
|
168
|
+
name: string;
|
|
169
|
+
config: LLMNodeConfig;
|
|
170
|
+
maxHistoryLength?: number;
|
|
171
|
+
nodeConfig?: NodeDefinition<TState>['config'];
|
|
172
|
+
}): NodeDefinition<TState>;
|
|
173
|
+
//# sourceMappingURL=llm-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-node.d.ts","sourceRoot":"","sources":["../../src/nodes/llm-node.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EAKd,WAAW,EACX,IAAI,EACL,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,gCAAgC;IAChC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,iCAAiC;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,iCAAiC;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,qBAAqB;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,kCAAkC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACxB,qCAAqC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,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