@gaunt-sloth/core 0.1.8 → 2.0.0-alpha.1
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/.gsloth.exec.md +26 -0
- package/dist/config.d.ts +81 -1
- package/dist/config.js +118 -3
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/core/GthAbstractAgent.d.ts +73 -0
- package/dist/core/GthAbstractAgent.js +448 -0
- package/dist/core/GthAbstractAgent.js.map +1 -0
- package/dist/core/GthAgentRunner.d.ts +31 -2
- package/dist/core/GthAgentRunner.js +43 -2
- package/dist/core/GthAgentRunner.js.map +1 -1
- package/dist/core/GthLangChainAgent.d.ts +9 -75
- package/dist/core/GthLangChainAgent.js +13 -433
- package/dist/core/GthLangChainAgent.js.map +1 -1
- package/dist/core/types.d.ts +63 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic.js +2 -2
- package/dist/providers/deepseek.js +2 -2
- package/dist/providers/deepseek.js.map +1 -1
- package/dist/providers/google-genai.js +2 -2
- package/dist/providers/google-genai.js.map +1 -1
- package/dist/providers/modelDiscovery.d.ts +196 -0
- package/dist/providers/modelDiscovery.js +362 -0
- package/dist/providers/modelDiscovery.js.map +1 -0
- package/dist/providers/ollama.d.ts +5 -0
- package/dist/providers/ollama.js +79 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/openai.js +28 -2
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/vertexai.js +2 -2
- package/dist/providers/vertexai.js.map +1 -1
- package/dist/providers/xai.js +2 -2
- package/dist/providers/xai.js.map +1 -1
- package/dist/runtime/singleShot.d.ts +19 -0
- package/dist/runtime/singleShot.js +62 -0
- package/dist/runtime/singleShot.js.map +1 -0
- package/dist/utils/fileUtils.d.ts +6 -0
- package/dist/utils/fileUtils.js +17 -0
- package/dist/utils/fileUtils.js.map +1 -1
- package/dist/utils/globalConfigUtils.d.ts +21 -0
- package/dist/utils/globalConfigUtils.js +25 -0
- package/dist/utils/globalConfigUtils.js.map +1 -1
- package/dist/utils/llmUtils.d.ts +1 -0
- package/dist/utils/llmUtils.js +4 -1
- package/dist/utils/llmUtils.js.map +1 -1
- package/dist/utils/systemUtils.d.ts +10 -0
- package/dist/utils/systemUtils.js +8 -0
- package/dist/utils/systemUtils.js.map +1 -1
- package/package.json +17 -14
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
import { StatusLevel, } from '#src/core/types.js';
|
|
2
|
+
import { debugLog, debugLogError, debugLogObject } from '#src/utils/debugUtils.js';
|
|
3
|
+
import { ProgressIndicator } from '#src/utils/ProgressIndicator.js';
|
|
4
|
+
import { stopWaitingForEscape, waitForEscape } from '#src/utils/systemUtils.js';
|
|
5
|
+
import { AIMessage, AIMessageChunk, ToolMessage } from '@langchain/core/messages';
|
|
6
|
+
import { IterableReadableStream } from '@langchain/core/utils/stream';
|
|
7
|
+
import { interrupt, Command, GraphInterrupt } from '@langchain/langgraph';
|
|
8
|
+
import { extractInlineBinaryBlocks, materializeBinaryOutputs, renderAssistantContent, } from '#src/utils/binaryOutputUtils.js';
|
|
9
|
+
/**
|
|
10
|
+
* Shared, graph-agnostic agent plumbing.
|
|
11
|
+
*
|
|
12
|
+
* Both the lean {@link GthLangChainAgent} (`createAgent`, in core) and the deep
|
|
13
|
+
* `GthDeepAgent` (`createDeepAgent`, in `@gaunt-sloth/agent`) differ only in how they
|
|
14
|
+
* build the compiled LangGraph in {@link init}; everything downstream — invoking,
|
|
15
|
+
* streaming to the console, emitting typed {@link AgentStreamEvent}s, client-tool
|
|
16
|
+
* `interrupt()` stubbing, suspend/resume, and cleanup — is identical and lives here.
|
|
17
|
+
*
|
|
18
|
+
* The base operates solely on the structural {@link GthCompiledGraph} surface, so it
|
|
19
|
+
* does NOT import `langchain`/`deepagents` graph builders. Subclasses construct the
|
|
20
|
+
* graph and assign it to {@link agent} in their `init()`.
|
|
21
|
+
*/
|
|
22
|
+
export class GthAbstractAgent {
|
|
23
|
+
statusUpdate;
|
|
24
|
+
resolvers;
|
|
25
|
+
agent = null;
|
|
26
|
+
config = null;
|
|
27
|
+
command = undefined;
|
|
28
|
+
constructor(statusUpdate, resolvers) {
|
|
29
|
+
this.statusUpdate = (level, message) => {
|
|
30
|
+
statusUpdate(level, message);
|
|
31
|
+
};
|
|
32
|
+
this.resolvers = resolvers;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Invoke LLM with a message and runnable config.
|
|
36
|
+
* For streaming use {@link #stream} method, streaming is preferred if model API supports it.
|
|
37
|
+
* Please note that this when tools are involved, this method will anyway do multiple LLM
|
|
38
|
+
* calls within LangChain dependency.
|
|
39
|
+
*/
|
|
40
|
+
async invoke(messages, runConfig) {
|
|
41
|
+
if (!this.agent || !this.config) {
|
|
42
|
+
throw new Error('Agent not initialized. Call init() first.');
|
|
43
|
+
}
|
|
44
|
+
debugLog('=== Starting non-streaming invoke ===');
|
|
45
|
+
debugLogObject('LLM Input Messages', messages);
|
|
46
|
+
debugLogObject('Invoke RunConfig', runConfig);
|
|
47
|
+
try {
|
|
48
|
+
const progress = new ProgressIndicator('Thinking.');
|
|
49
|
+
try {
|
|
50
|
+
debugLog('Calling agent.invoke...');
|
|
51
|
+
const response = await this.agent.invoke({ messages }, runConfig);
|
|
52
|
+
const finalMessage = response.messages[response.messages.length - 1];
|
|
53
|
+
const finalContent = finalMessage?.content;
|
|
54
|
+
const processedContent = !this.config.writeBinaryOutputsToFile
|
|
55
|
+
? {
|
|
56
|
+
renderedContent: renderAssistantContent(finalContent),
|
|
57
|
+
successMessages: [],
|
|
58
|
+
}
|
|
59
|
+
: materializeBinaryOutputs(finalContent, this.command);
|
|
60
|
+
if (processedContent.renderedContent.trim().length > 0) {
|
|
61
|
+
this.statusUpdate(StatusLevel.DISPLAY, processedContent.renderedContent);
|
|
62
|
+
}
|
|
63
|
+
for (const successMessage of processedContent.successMessages) {
|
|
64
|
+
this.statusUpdate(StatusLevel.SUCCESS, successMessage);
|
|
65
|
+
}
|
|
66
|
+
return [processedContent.renderedContent, ...processedContent.successMessages]
|
|
67
|
+
.filter((part) => part.trim().length > 0)
|
|
68
|
+
.join('\n');
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
debugLogError('invoke inner', e);
|
|
72
|
+
if (e instanceof Error && e?.name === 'ToolException') {
|
|
73
|
+
throw e; // Re-throw ToolException to be handled by outer catch
|
|
74
|
+
}
|
|
75
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
76
|
+
this.statusUpdate(StatusLevel.ERROR, `LLM invocation failed: ${message}`);
|
|
77
|
+
throw e;
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
progress.stop();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
debugLogError('invoke outer', error);
|
|
85
|
+
if (error instanceof Error) {
|
|
86
|
+
if (error?.name === 'ToolException') {
|
|
87
|
+
this.statusUpdate(StatusLevel.ERROR, `Tool execution failed: ${error?.message}`);
|
|
88
|
+
return `Tool execution failed: ${error?.message}`;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Induce LLM to stream AI messages with a user message and runnable config.
|
|
96
|
+
* When stream is not appropriate use {@link invoke}.
|
|
97
|
+
*/
|
|
98
|
+
async stream(messages, runConfig) {
|
|
99
|
+
if (!this.agent || !this.config) {
|
|
100
|
+
throw new Error('Agent not initialized. Call init() first.');
|
|
101
|
+
}
|
|
102
|
+
debugLog('=== Starting streaming invoke ===');
|
|
103
|
+
debugLogObject('LLM Input Messages', messages);
|
|
104
|
+
debugLogObject('Stream RunConfig', runConfig);
|
|
105
|
+
this.statusUpdate(StatusLevel.INFO, '\nThinking...\n');
|
|
106
|
+
const statusUpdate = this.statusUpdate;
|
|
107
|
+
const config = this.config;
|
|
108
|
+
const command = this.command;
|
|
109
|
+
const interruptState = { escape: false, messageShown: false };
|
|
110
|
+
const abortController = new AbortController();
|
|
111
|
+
const showInterruptMessage = () => {
|
|
112
|
+
if (!interruptState.messageShown) {
|
|
113
|
+
interruptState.messageShown = true;
|
|
114
|
+
statusUpdate(StatusLevel.WARNING, '\n\nInterrupted by user, exiting\n\n');
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
waitForEscape(() => {
|
|
118
|
+
interruptState.escape = true;
|
|
119
|
+
showInterruptMessage();
|
|
120
|
+
if (!abortController.signal.aborted) {
|
|
121
|
+
abortController.abort();
|
|
122
|
+
}
|
|
123
|
+
}, this.config.canInterruptInferenceWithEsc);
|
|
124
|
+
let stream;
|
|
125
|
+
try {
|
|
126
|
+
stream = await this.agent.stream({ messages }, { ...runConfig, streamMode: 'messages', signal: abortController.signal });
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
// If stream creation fails (e.g. an auth error), the IterableReadableStream below -
|
|
130
|
+
// whose finally/cancel are what normally unregister the Escape listener - is never
|
|
131
|
+
// constructed. Without this cleanup the raw-mode keypress listener keeps stdin ref'd,
|
|
132
|
+
// the process hangs after the error, and Esc/Ctrl+C only print "Interrupting..."
|
|
133
|
+
// (raw mode swallows SIGINT, so Ctrl+C cannot kill the process either).
|
|
134
|
+
stopWaitingForEscape();
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
return new IterableReadableStream({
|
|
138
|
+
async start(controller) {
|
|
139
|
+
try {
|
|
140
|
+
debugLog('Starting stream processing...');
|
|
141
|
+
let totalChunks = 0;
|
|
142
|
+
const seenBinaryBlocks = new Set();
|
|
143
|
+
const binaryBlocks = [];
|
|
144
|
+
for await (const [chunk, _metadata] of stream) {
|
|
145
|
+
debugLogObject('Stream chunk', { chunk, _metadata });
|
|
146
|
+
if (AIMessage.isInstance(chunk)) {
|
|
147
|
+
const text = chunk.text ?? '';
|
|
148
|
+
totalChunks++;
|
|
149
|
+
if (text.length > 0) {
|
|
150
|
+
statusUpdate(StatusLevel.STREAM, text);
|
|
151
|
+
controller.enqueue(text);
|
|
152
|
+
}
|
|
153
|
+
if (config?.writeBinaryOutputsToFile) {
|
|
154
|
+
for (const block of extractInlineBinaryBlocks(chunk.content)) {
|
|
155
|
+
const binaryKey = `${block.mimeType}:${block.data.length}:${block.data}`;
|
|
156
|
+
if (seenBinaryBlocks.has(binaryKey)) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
seenBinaryBlocks.add(binaryKey);
|
|
160
|
+
binaryBlocks.push({ mimeType: block.mimeType, data: block.data });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (interruptState.escape) {
|
|
165
|
+
if (typeof stream.cancel === 'function') {
|
|
166
|
+
await stream.cancel();
|
|
167
|
+
}
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (config?.writeBinaryOutputsToFile && binaryBlocks.length > 0) {
|
|
172
|
+
const processedContent = materializeBinaryOutputs(binaryBlocks.map((block) => ({
|
|
173
|
+
type: 'inlineData',
|
|
174
|
+
inlineData: block,
|
|
175
|
+
})), command);
|
|
176
|
+
for (const successMessage of processedContent.successMessages) {
|
|
177
|
+
statusUpdate(StatusLevel.SUCCESS, successMessage);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
debugLog(`Stream completed. Total chunks: ${totalChunks}`);
|
|
181
|
+
controller.close();
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
if (interruptState.escape || (error instanceof Error && error.name === 'AbortError')) {
|
|
185
|
+
showInterruptMessage();
|
|
186
|
+
controller.close();
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
debugLogError('stream processing', error);
|
|
190
|
+
if (error instanceof Error) {
|
|
191
|
+
if (error?.name === 'ToolException') {
|
|
192
|
+
statusUpdate(StatusLevel.ERROR, `Tool execution failed: ${error?.message}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
controller.error(error);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
finally {
|
|
199
|
+
stopWaitingForEscape();
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
async cancel() {
|
|
203
|
+
stopWaitingForEscape();
|
|
204
|
+
if (!abortController.signal.aborted) {
|
|
205
|
+
abortController.abort();
|
|
206
|
+
}
|
|
207
|
+
// Clean up the underlying stream if it has a cancel method
|
|
208
|
+
if (stream && typeof stream.cancel === 'function') {
|
|
209
|
+
await stream.cancel();
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Stream agent events as typed AgentStreamEvent objects.
|
|
216
|
+
* Yields text deltas, tool call lifecycle events, and tool results.
|
|
217
|
+
*
|
|
218
|
+
* If a tool with `metadata.client === true` triggers `interrupt()`, the underlying
|
|
219
|
+
* graph throws `GraphInterrupt`; this generator catches it and ends cleanly so the
|
|
220
|
+
* caller's transport (e.g. AG-UI SSE) can finish the run with the tool call hanging.
|
|
221
|
+
* Resume the suspended graph via {@link streamWithEventsResume} on the same thread id.
|
|
222
|
+
*/
|
|
223
|
+
async *streamWithEvents(messages, runConfig, signal) {
|
|
224
|
+
if (!this.agent || !this.config) {
|
|
225
|
+
throw new Error('Agent not initialized. Call init() first.');
|
|
226
|
+
}
|
|
227
|
+
debugLog('=== Starting streamWithEvents ===');
|
|
228
|
+
debugLogObject('LLM Input Messages', messages);
|
|
229
|
+
try {
|
|
230
|
+
// `signal` lets the transport (e.g. the AG-UI server on client disconnect)
|
|
231
|
+
// cancel the in-flight LLM generation, not just stop reading from it.
|
|
232
|
+
const stream = await this.agent.stream({ messages }, { ...runConfig, streamMode: 'messages', signal });
|
|
233
|
+
yield* this.processEventStream(stream);
|
|
234
|
+
}
|
|
235
|
+
catch (e) {
|
|
236
|
+
if (e instanceof GraphInterrupt ||
|
|
237
|
+
e.name === 'GraphInterrupt' ||
|
|
238
|
+
e.name === 'AbortError') {
|
|
239
|
+
debugLog('Graph suspended (GraphInterrupt) or aborted by caller');
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
throw e;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Resume a graph that was suspended via `interrupt()` with the supplied value.
|
|
247
|
+
*
|
|
248
|
+
* The runnable config must carry the same `thread_id` used when the graph was
|
|
249
|
+
* suspended (the checkpointer keys state by thread). The resume value is whatever
|
|
250
|
+
* the suspending tool needs back — for frontend-fulfilled tools this is the value
|
|
251
|
+
* the client sends in `forwardedProps.command.resume`.
|
|
252
|
+
*/
|
|
253
|
+
async *streamWithEventsResume(resumeValue, runConfig, queuedMessages, signal) {
|
|
254
|
+
if (!this.agent || !this.config) {
|
|
255
|
+
throw new Error('Agent not initialized. Call init() first.');
|
|
256
|
+
}
|
|
257
|
+
debugLog('=== Starting streamWithEventsResume ===');
|
|
258
|
+
try {
|
|
259
|
+
// Queued follow-up messages: when the client sends mid-task input
|
|
260
|
+
// alongside the resume, append it to the graph's `messages` state via
|
|
261
|
+
// Command.update so the agent sees it on its next decision turn — no
|
|
262
|
+
// separate run, no dangling tool calls. (Ordering note: the update lands
|
|
263
|
+
// around the resumed tool result; lenient local models tolerate this,
|
|
264
|
+
// strict tool-call/result adjacency providers may not.)
|
|
265
|
+
const command = queuedMessages && queuedMessages.length > 0
|
|
266
|
+
? new Command({ resume: resumeValue, update: { messages: queuedMessages } })
|
|
267
|
+
: new Command({ resume: resumeValue });
|
|
268
|
+
const stream = await this.agent.stream(command, {
|
|
269
|
+
...runConfig,
|
|
270
|
+
streamMode: 'messages',
|
|
271
|
+
signal,
|
|
272
|
+
});
|
|
273
|
+
yield* this.processEventStream(stream);
|
|
274
|
+
}
|
|
275
|
+
catch (e) {
|
|
276
|
+
if (e instanceof GraphInterrupt ||
|
|
277
|
+
e.name === 'GraphInterrupt' ||
|
|
278
|
+
e.name === 'AbortError') {
|
|
279
|
+
debugLog('Graph suspended (GraphInterrupt) or aborted by caller');
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
throw e;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
async *processEventStream(stream) {
|
|
286
|
+
// Aggregate AIMessageChunks via concat so tool_call_chunks collapse into
|
|
287
|
+
// tool_calls with complete args (per-chunk tool_calls only ever sees that
|
|
288
|
+
// chunk's slice of the args JSON, which is rarely valid on its own).
|
|
289
|
+
let aggregatedAIChunk = null;
|
|
290
|
+
let reasoningOpen = false;
|
|
291
|
+
const flushed = new Set();
|
|
292
|
+
function* flushAggregated() {
|
|
293
|
+
if (!aggregatedAIChunk)
|
|
294
|
+
return;
|
|
295
|
+
const toolCalls = aggregatedAIChunk.tool_calls ?? [];
|
|
296
|
+
const invalidToolCalls = aggregatedAIChunk.invalid_tool_calls ?? [];
|
|
297
|
+
for (const tc of toolCalls) {
|
|
298
|
+
const id = tc.id;
|
|
299
|
+
if (!id || flushed.has(id))
|
|
300
|
+
continue;
|
|
301
|
+
flushed.add(id);
|
|
302
|
+
yield { type: 'tool_start', id, name: tc.name };
|
|
303
|
+
yield { type: 'tool_args', id, delta: JSON.stringify(tc.args ?? {}) };
|
|
304
|
+
yield { type: 'tool_end', id };
|
|
305
|
+
}
|
|
306
|
+
// Surface invalid tool calls too so the client at least sees the raw args
|
|
307
|
+
// string the model produced, instead of silently dropping them.
|
|
308
|
+
for (const tc of invalidToolCalls) {
|
|
309
|
+
const id = tc.id;
|
|
310
|
+
if (!id || flushed.has(id))
|
|
311
|
+
continue;
|
|
312
|
+
flushed.add(id);
|
|
313
|
+
yield { type: 'tool_start', id, name: tc.name ?? '' };
|
|
314
|
+
yield { type: 'tool_args', id, delta: tc.args ?? '' };
|
|
315
|
+
yield { type: 'tool_end', id };
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
for await (const [chunk, _metadata] of stream) {
|
|
319
|
+
debugLogObject('streamWithEvents chunk', { chunk, _metadata });
|
|
320
|
+
if (AIMessageChunk.isInstance(chunk)) {
|
|
321
|
+
aggregatedAIChunk = aggregatedAIChunk ? aggregatedAIChunk.concat(chunk) : chunk;
|
|
322
|
+
// Reasoning deltas — Ollama (Qwen3, deepseek-r1) and Anthropic surface
|
|
323
|
+
// thinking text in additional_kwargs.reasoning_content. Stream it as a
|
|
324
|
+
// separate event series so clients can render it apart from the answer.
|
|
325
|
+
const reasoningDelta = chunk.additional_kwargs?.reasoning_content;
|
|
326
|
+
if (typeof reasoningDelta === 'string' && reasoningDelta.length > 0) {
|
|
327
|
+
if (!reasoningOpen) {
|
|
328
|
+
reasoningOpen = true;
|
|
329
|
+
yield { type: 'reasoning_start' };
|
|
330
|
+
}
|
|
331
|
+
yield { type: 'reasoning_delta', delta: reasoningDelta };
|
|
332
|
+
}
|
|
333
|
+
// Yield text incrementally — use this chunk's text (delta), not the
|
|
334
|
+
// aggregated content which is cumulative.
|
|
335
|
+
if (chunk.text) {
|
|
336
|
+
if (reasoningOpen) {
|
|
337
|
+
reasoningOpen = false;
|
|
338
|
+
yield { type: 'reasoning_end' };
|
|
339
|
+
}
|
|
340
|
+
yield { type: 'text', delta: chunk.text };
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
else if (AIMessage.isInstance(chunk)) {
|
|
344
|
+
// Non-chunk AIMessage (e.g. on resumed runs) carries final tool_calls
|
|
345
|
+
// directly; merge them into the aggregate so flushAggregated emits them.
|
|
346
|
+
if (chunk.tool_calls && chunk.tool_calls.length > 0) {
|
|
347
|
+
const synthetic = new AIMessageChunk({
|
|
348
|
+
content: '',
|
|
349
|
+
tool_calls: chunk.tool_calls,
|
|
350
|
+
});
|
|
351
|
+
aggregatedAIChunk = aggregatedAIChunk ? aggregatedAIChunk.concat(synthetic) : synthetic;
|
|
352
|
+
}
|
|
353
|
+
if (chunk.text) {
|
|
354
|
+
if (reasoningOpen) {
|
|
355
|
+
reasoningOpen = false;
|
|
356
|
+
yield { type: 'reasoning_end' };
|
|
357
|
+
}
|
|
358
|
+
yield { type: 'text', delta: chunk.text };
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
if (chunk instanceof ToolMessage) {
|
|
362
|
+
if (reasoningOpen) {
|
|
363
|
+
reasoningOpen = false;
|
|
364
|
+
yield { type: 'reasoning_end' };
|
|
365
|
+
}
|
|
366
|
+
yield* flushAggregated();
|
|
367
|
+
// Reset between rounds. OpenAI restarts tool_call_chunks.index at 0
|
|
368
|
+
// for each new LLM round; without this reset the next round's chunks
|
|
369
|
+
// collide with the previous round's groups in collapseToolCallChunks
|
|
370
|
+
// and end up with empty args.
|
|
371
|
+
aggregatedAIChunk = null;
|
|
372
|
+
const content = typeof chunk.content === 'string' ? chunk.content : JSON.stringify(chunk.content);
|
|
373
|
+
yield { type: 'tool_result', id: chunk.tool_call_id, content };
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
// Close any still-open reasoning block before flushing tool calls.
|
|
377
|
+
if (reasoningOpen) {
|
|
378
|
+
yield { type: 'reasoning_end' };
|
|
379
|
+
}
|
|
380
|
+
// Flush any tool calls not followed by a ToolMessage (e.g. terminal tool calls).
|
|
381
|
+
yield* flushAggregated();
|
|
382
|
+
}
|
|
383
|
+
async cleanup() {
|
|
384
|
+
debugLog('Cleaning up agent...');
|
|
385
|
+
if (this.resolvers?.cleanupTools) {
|
|
386
|
+
await this.resolvers.cleanupTools();
|
|
387
|
+
}
|
|
388
|
+
if (this.resolvers?.cleanupMiddleware) {
|
|
389
|
+
await this.resolvers.cleanupMiddleware();
|
|
390
|
+
}
|
|
391
|
+
this.agent = null;
|
|
392
|
+
this.config = null;
|
|
393
|
+
this.command = undefined;
|
|
394
|
+
debugLog('Agent cleanup complete');
|
|
395
|
+
}
|
|
396
|
+
getEffectiveConfig(config, command) {
|
|
397
|
+
debugLog(`Getting effective config for command: ${command || 'default'}`);
|
|
398
|
+
const supportsTools = !!config.llm.bindTools;
|
|
399
|
+
if (!supportsTools) {
|
|
400
|
+
this.statusUpdate(StatusLevel.WARNING, 'Model does not seem to support tools.');
|
|
401
|
+
debugLog('Warning: Model does not support tools');
|
|
402
|
+
}
|
|
403
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
404
|
+
const cmdConfig = (command && config.commands?.[command]);
|
|
405
|
+
return {
|
|
406
|
+
...config,
|
|
407
|
+
filesystem: cmdConfig?.filesystem !== undefined ? cmdConfig.filesystem : config.filesystem,
|
|
408
|
+
builtInTools: cmdConfig?.builtInTools !== undefined ? cmdConfig.builtInTools : config.builtInTools,
|
|
409
|
+
allowedTools: cmdConfig?.allowedTools !== undefined ? cmdConfig.allowedTools : config.allowedTools,
|
|
410
|
+
binaryFormats: cmdConfig?.binaryFormats !== undefined ? cmdConfig.binaryFormats : config.binaryFormats,
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Extract and flatten tools from toolkits, applying client-tool `interrupt()` stubbing.
|
|
415
|
+
* A tool with `metadata.client === true` has its body swapped for an `interrupt()` call
|
|
416
|
+
* so the run suspends and the client fulfils it (the C-a AG-UI bridge depends on this).
|
|
417
|
+
*/
|
|
418
|
+
extractAndFlattenTools(tools) {
|
|
419
|
+
const flattenedTools = [];
|
|
420
|
+
for (const toolOrToolkit of tools) {
|
|
421
|
+
// eslint-disable-next-line
|
|
422
|
+
if (toolOrToolkit['getTools'] instanceof Function) {
|
|
423
|
+
// This is a toolkit
|
|
424
|
+
flattenedTools.push(...toolOrToolkit.getTools());
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
// This is a regular tool
|
|
428
|
+
let singleTool = toolOrToolkit;
|
|
429
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
430
|
+
if (singleTool.metadata?.client === true) {
|
|
431
|
+
// Clone the tool to avoid mutating the original
|
|
432
|
+
singleTool = Object.assign(Object.create(Object.getPrototypeOf(singleTool)), singleTool);
|
|
433
|
+
const stubFunc = async (_input, _config) => {
|
|
434
|
+
const value = await interrupt({ name: singleTool.name });
|
|
435
|
+
return typeof value === 'string' ? value : JSON.stringify(value);
|
|
436
|
+
};
|
|
437
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
438
|
+
singleTool.invoke = stubFunc;
|
|
439
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
440
|
+
singleTool.call = stubFunc;
|
|
441
|
+
}
|
|
442
|
+
flattenedTools.push(singleTool);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return flattenedTools;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
//# sourceMappingURL=GthAbstractAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GthAbstractAgent.js","sourceRoot":"","sources":["../../src/core/GthAbstractAgent.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,WAAW,GAEZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAe,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAG/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAuB,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,iCAAiC,CAAC;AAEzC;;;;;;;;;;;;GAYG;AACH,MAAM,OAAgB,gBAAgB;IAC1B,YAAY,CAAuB;IACnC,SAAS,CAA6B;IACtC,KAAK,GAA4B,IAAI,CAAC;IACtC,MAAM,GAAqB,IAAI,CAAC;IAChC,O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AAU,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QACD,OAAO,cAAc,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GthConfig } from '#src/config.js';
|
|
2
2
|
import { BaseCheckpointSaver } from '@langchain/langgraph';
|
|
3
|
-
import { AgentResolvers, GthAgentInterface, GthCommand, Message, StatusUpdateCallback } from '#src/core/types.js';
|
|
3
|
+
import { AgentResolvers, AgentStreamEvent, GthAgentFactory, GthAgentInterface, GthCommand, Message, StatusUpdateCallback } from '#src/core/types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Agent simplifies interaction with LLM and reduces it to calling a few methods
|
|
6
6
|
* {@link GthAgentRunner#init} and {@link GthAgentRunner#processMessages}.
|
|
@@ -11,7 +11,14 @@ export declare class GthAgentRunner {
|
|
|
11
11
|
private agent;
|
|
12
12
|
private config;
|
|
13
13
|
private runConfig;
|
|
14
|
-
|
|
14
|
+
private agentFactory;
|
|
15
|
+
/**
|
|
16
|
+
* @param agentFactory Produces the {@link GthAgentInterface} the runner drives.
|
|
17
|
+
* Defaults to the lean {@link GthLangChainAgent} (core). `@gaunt-sloth/agent`
|
|
18
|
+
* passes a factory returning a deep `GthDeepAgent` so the same runner can drive a
|
|
19
|
+
* `createDeepAgent` graph without core depending on deepagents.
|
|
20
|
+
*/
|
|
21
|
+
constructor(statusUpdate: StatusUpdateCallback, resolvers?: AgentResolvers, agentFactory?: GthAgentFactory);
|
|
15
22
|
/**
|
|
16
23
|
* Init is split into a separate method. This may create a number of connections,
|
|
17
24
|
* and we'd better have an instance by that moment, for the case things will go wrong,
|
|
@@ -22,6 +29,28 @@ export declare class GthAgentRunner {
|
|
|
22
29
|
* processMessages deals with both streaming and non-streaming approaches.
|
|
23
30
|
*/
|
|
24
31
|
processMessages(messages: Message[]): Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Event-stream counterpart to {@link processMessages}: drives the agent's typed
|
|
34
|
+
* {@link AgentStreamEvent} path using the runner's own thread-bound `runConfig`, so a
|
|
35
|
+
* renderer (the Ink TUI) can present the same run the readline path renders via
|
|
36
|
+
* `consoleUtils` while sharing the checkpointer thread for cross-turn memory.
|
|
37
|
+
*
|
|
38
|
+
* Cancellation is via the supplied `signal` (the TUI's Esc → `AbortController`); the
|
|
39
|
+
* underlying `streamWithEvents` ends cleanly on abort or `interrupt()`. The string
|
|
40
|
+
* path's empty-stream retry/`invoke` fallback is intentionally NOT duplicated here — the
|
|
41
|
+
* TUI renders the live event stream directly; revisit if empty-stream retries are needed.
|
|
42
|
+
*/
|
|
43
|
+
processMessagesWithEvents(messages: Message[], signal?: AbortSignal): AsyncGenerator<AgentStreamEvent>;
|
|
25
44
|
getAgent(): GthAgentInterface | null;
|
|
45
|
+
/**
|
|
46
|
+
* Rotate the thread the runner drives by minting a fresh `runConfig` (new `thread_id`),
|
|
47
|
+
* so subsequent turns start from an empty checkpointer thread rather than retrieving the
|
|
48
|
+
* prior conversation. Used by the TUI's `/clear`, which clears the on-screen transcript;
|
|
49
|
+
* without this the model would still see the full history persisted under the old thread.
|
|
50
|
+
*
|
|
51
|
+
* Rotating the thread_id (rather than deleting from the checkpointer) keeps this independent
|
|
52
|
+
* of any checkpointer-specific delete API, mirroring how `init()` mints the initial config.
|
|
53
|
+
*/
|
|
54
|
+
resetThread(): void;
|
|
26
55
|
cleanup(): Promise<void>;
|
|
27
56
|
}
|
|
@@ -12,9 +12,18 @@ export class GthAgentRunner {
|
|
|
12
12
|
agent = null;
|
|
13
13
|
config = null;
|
|
14
14
|
runConfig = null;
|
|
15
|
-
|
|
15
|
+
agentFactory;
|
|
16
|
+
/**
|
|
17
|
+
* @param agentFactory Produces the {@link GthAgentInterface} the runner drives.
|
|
18
|
+
* Defaults to the lean {@link GthLangChainAgent} (core). `@gaunt-sloth/agent`
|
|
19
|
+
* passes a factory returning a deep `GthDeepAgent` so the same runner can drive a
|
|
20
|
+
* `createDeepAgent` graph without core depending on deepagents.
|
|
21
|
+
*/
|
|
22
|
+
constructor(statusUpdate, resolvers, agentFactory) {
|
|
16
23
|
this.statusUpdate = statusUpdate;
|
|
17
24
|
this.resolvers = resolvers;
|
|
25
|
+
this.agentFactory =
|
|
26
|
+
agentFactory ?? ((status, agentResolvers) => new GthLangChainAgent(status, agentResolvers));
|
|
18
27
|
}
|
|
19
28
|
/**
|
|
20
29
|
* Init is split into a separate method. This may create a number of connections,
|
|
@@ -28,7 +37,7 @@ export class GthAgentRunner {
|
|
|
28
37
|
debugLog(`Initializing GthAgentRunner with command: ${command || 'default'}`);
|
|
29
38
|
this.runConfig = getNewRunnableConfig();
|
|
30
39
|
debugLogObject('Runnable Config', this.runConfig);
|
|
31
|
-
this.agent =
|
|
40
|
+
this.agent = this.agentFactory(this.statusUpdate, this.resolvers);
|
|
32
41
|
// Initialize the agent
|
|
33
42
|
debugLog('Initializing agent...');
|
|
34
43
|
await this.agent.init(command, configIn, checkpointSaver);
|
|
@@ -92,10 +101,42 @@ export class GthAgentRunner {
|
|
|
92
101
|
throw new Error(`Agent processing failed: ${enhancedMessage}`, error instanceof Error ? { cause: error } : undefined);
|
|
93
102
|
}
|
|
94
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Event-stream counterpart to {@link processMessages}: drives the agent's typed
|
|
106
|
+
* {@link AgentStreamEvent} path using the runner's own thread-bound `runConfig`, so a
|
|
107
|
+
* renderer (the Ink TUI) can present the same run the readline path renders via
|
|
108
|
+
* `consoleUtils` while sharing the checkpointer thread for cross-turn memory.
|
|
109
|
+
*
|
|
110
|
+
* Cancellation is via the supplied `signal` (the TUI's Esc → `AbortController`); the
|
|
111
|
+
* underlying `streamWithEvents` ends cleanly on abort or `interrupt()`. The string
|
|
112
|
+
* path's empty-stream retry/`invoke` fallback is intentionally NOT duplicated here — the
|
|
113
|
+
* TUI renders the live event stream directly; revisit if empty-stream retries are needed.
|
|
114
|
+
*/
|
|
115
|
+
async *processMessagesWithEvents(messages, signal) {
|
|
116
|
+
if (!this.agent || !this.config || !this.runConfig) {
|
|
117
|
+
throw new Error('AgentRunner not initialized. Call init() first.');
|
|
118
|
+
}
|
|
119
|
+
debugLog('Processing messages (event stream)...');
|
|
120
|
+
debugLogObject('Input Messages', messages);
|
|
121
|
+
yield* this.agent.streamWithEvents(messages, this.runConfig, signal);
|
|
122
|
+
}
|
|
95
123
|
// noinspection JSUnusedGlobalSymbols
|
|
96
124
|
getAgent() {
|
|
97
125
|
return this.agent;
|
|
98
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Rotate the thread the runner drives by minting a fresh `runConfig` (new `thread_id`),
|
|
129
|
+
* so subsequent turns start from an empty checkpointer thread rather than retrieving the
|
|
130
|
+
* prior conversation. Used by the TUI's `/clear`, which clears the on-screen transcript;
|
|
131
|
+
* without this the model would still see the full history persisted under the old thread.
|
|
132
|
+
*
|
|
133
|
+
* Rotating the thread_id (rather than deleting from the checkpointer) keeps this independent
|
|
134
|
+
* of any checkpointer-specific delete API, mirroring how `init()` mints the initial config.
|
|
135
|
+
*/
|
|
136
|
+
resetThread() {
|
|
137
|
+
this.runConfig = getNewRunnableConfig();
|
|
138
|
+
debugLogObject('Reset Runnable Config', this.runConfig);
|
|
139
|
+
}
|
|
99
140
|
async cleanup() {
|
|
100
141
|
debugLog('Cleaning up GthAgentRunner...');
|
|
101
142
|
if (this.agent && 'cleanup' in this.agent && typeof this.agent.cleanup === 'function') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GthAgentRunner.js","sourceRoot":"","sources":["../../src/core/GthAgentRunner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GthAgentRunner.js","sourceRoot":"","sources":["../../src/core/GthAgentRunner.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAE/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAA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