@gaunt-sloth/agent 0.1.8 → 2.0.0-alpha.0
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 +14 -5
- package/cli-acp.js +35 -0
- package/cli.js +35 -0
- package/dist/builtInToolsConfig.d.ts +26 -0
- package/dist/builtInToolsConfig.js +148 -0
- package/dist/builtInToolsConfig.js.map +1 -0
- package/dist/core/GthDeepAgent.d.ts +76 -0
- package/dist/core/GthDeepAgent.js +368 -0
- package/dist/core/GthDeepAgent.js.map +1 -0
- package/dist/core/debugCapture.d.ts +51 -0
- package/dist/core/debugCapture.js +2 -0
- package/dist/core/debugCapture.js.map +1 -0
- package/dist/core/deepAgentPermissions.d.ts +55 -0
- package/dist/core/deepAgentPermissions.js +120 -0
- package/dist/core/deepAgentPermissions.js.map +1 -0
- package/dist/core/gthAcpServer.d.ts +27 -0
- package/dist/core/gthAcpServer.js +71 -0
- package/dist/core/gthAcpServer.js.map +1 -0
- package/dist/core/gthDeepAgentFactory.d.ts +8 -0
- package/dist/core/gthDeepAgentFactory.js +9 -0
- package/dist/core/gthDeepAgentFactory.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/OAuthClientProviderImpl.d.ts +37 -0
- package/dist/mcp/OAuthClientProviderImpl.js +223 -0
- package/dist/mcp/OAuthClientProviderImpl.js.map +1 -0
- package/dist/middleware/binaryContentInjectionMiddleware.d.ts +22 -0
- package/dist/middleware/binaryContentInjectionMiddleware.js +125 -0
- package/dist/middleware/binaryContentInjectionMiddleware.js.map +1 -0
- package/dist/middleware/registry.d.ts +34 -0
- package/dist/middleware/registry.js +124 -0
- package/dist/middleware/registry.js.map +1 -0
- package/dist/middleware/types.d.ts +89 -0
- package/dist/middleware/types.js +9 -0
- package/dist/middleware/types.js.map +1 -0
- package/dist/modules/a2a/A2AClientWrapper.d.ts +22 -0
- package/dist/modules/a2a/A2AClientWrapper.js +63 -0
- package/dist/modules/a2a/A2AClientWrapper.js.map +1 -0
- package/dist/modules/acpModule.d.ts +37 -0
- package/dist/modules/acpModule.js +67 -0
- package/dist/modules/acpModule.js.map +1 -0
- package/dist/modules/apiAgUiModule.d.ts +2 -0
- package/dist/modules/apiAgUiModule.js +417 -0
- package/dist/modules/apiAgUiModule.js.map +1 -0
- package/dist/modules/interactiveSessionModule.d.ts +9 -0
- package/dist/modules/interactiveSessionModule.js +99 -0
- package/dist/modules/interactiveSessionModule.js.map +1 -0
- package/dist/resolvers.d.ts +18 -0
- package/dist/resolvers.js +140 -0
- package/dist/resolvers.js.map +1 -0
- package/dist/tools/A2AAgentTool.d.ts +24 -0
- package/dist/tools/A2AAgentTool.js +37 -0
- package/dist/tools/A2AAgentTool.js.map +1 -0
- package/dist/tools/GthCustomToolkit.d.ts +41 -0
- package/dist/tools/GthCustomToolkit.js +289 -0
- package/dist/tools/GthCustomToolkit.js.map +1 -0
- package/dist/tools/GthDevToolkit.d.ts +24 -0
- package/dist/tools/GthDevToolkit.js +189 -0
- package/dist/tools/GthDevToolkit.js.map +1 -0
- package/dist/tools/GthFileSystemToolkit.d.ts +36 -0
- package/dist/tools/GthFileSystemToolkit.js +775 -0
- package/dist/tools/GthFileSystemToolkit.js.map +1 -0
- package/dist/tools/binaryUtils.d.ts +13 -0
- package/dist/tools/binaryUtils.js +55 -0
- package/dist/tools/binaryUtils.js.map +1 -0
- package/dist/tools/gthStatusUpdateTool.d.ts +2 -0
- package/dist/tools/gthStatusUpdateTool.js +15 -0
- package/dist/tools/gthStatusUpdateTool.js.map +1 -0
- package/dist/tools/gthWebFetchTool.d.ts +2 -0
- package/dist/tools/gthWebFetchTool.js +47 -0
- package/dist/tools/gthWebFetchTool.js.map +1 -0
- package/dist/tools/showA2UISurfaceTool.d.ts +9 -0
- package/dist/tools/showA2UISurfaceTool.js +25 -0
- package/dist/tools/showA2UISurfaceTool.js.map +1 -0
- package/dist/utils/mcpUtils.d.ts +13 -0
- package/dist/utils/mcpUtils.js +225 -0
- package/dist/utils/mcpUtils.js.map +1 -0
- package/package.json +49 -10
- package/index.js +0 -6
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { EventEncoder } from '@ag-ui/encoder';
|
|
4
|
+
import { EventType } from '@ag-ui/core';
|
|
5
|
+
import { GthDeepAgent } from '#src/core/GthDeepAgent.js';
|
|
6
|
+
import { defaultStatusCallback, displayInfo, displayWarning, } from '@gaunt-sloth/core/utils/consoleUtils.js';
|
|
7
|
+
import { getNewRunnableConfig } from '@gaunt-sloth/core/utils/llmUtils.js';
|
|
8
|
+
import { HumanMessage, AIMessage, SystemMessage, ToolMessage } from '@langchain/core/messages';
|
|
9
|
+
import { MemorySaver } from '@langchain/langgraph';
|
|
10
|
+
import { tool } from '@langchain/core/tools';
|
|
11
|
+
import { createResolvers } from '#src/resolvers.js';
|
|
12
|
+
/**
|
|
13
|
+
* Convert a run-input frontend tool into a client-fulfilled LangChain tool.
|
|
14
|
+
* Marking `metadata.client = true` is all that's required: the agent's
|
|
15
|
+
* `extractAndFlattenTools` already swaps such a tool's `invoke`/`call` for an
|
|
16
|
+
* `interrupt({ name })` stub, so the model can *call* the tool and the graph
|
|
17
|
+
* suspends for the browser to fulfil it — the exact mechanism Pukeko's
|
|
18
|
+
* server-side client tools use, now driven by client-declared tools.
|
|
19
|
+
*/
|
|
20
|
+
function buildClientToolStub(t) {
|
|
21
|
+
const stub = tool(async () => '', {
|
|
22
|
+
name: t.name,
|
|
23
|
+
description: t.description ?? '',
|
|
24
|
+
// The JSON Schema from the run-input is passed straight through so the model
|
|
25
|
+
// sees the real parameter shape. The stub body never runs (it interrupts).
|
|
26
|
+
schema: t.parameters ?? { type: 'object', properties: {} },
|
|
27
|
+
});
|
|
28
|
+
stub.metadata = { client: true };
|
|
29
|
+
return stub;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Return the first complete JSON value at the start of `s`, ignoring any
|
|
33
|
+
* trailing characters. Used to recover from streamed tool-call argument
|
|
34
|
+
* reassembly that concatenates objects (e.g. `{}{}` or `{"steps":3}{}`) when a
|
|
35
|
+
* model emits parallel tool calls — local models like Ollama/Gemma don't honor
|
|
36
|
+
* `disable_parallel_tool_use`, and their delta streams can merge sibling calls'
|
|
37
|
+
* argument buffers. Returns `undefined` if no complete leading value is found.
|
|
38
|
+
*/
|
|
39
|
+
function extractFirstJsonValue(s) {
|
|
40
|
+
let depth = 0;
|
|
41
|
+
let inString = false;
|
|
42
|
+
let escaped = false;
|
|
43
|
+
for (let i = 0; i < s.length; i++) {
|
|
44
|
+
const c = s[i];
|
|
45
|
+
if (inString) {
|
|
46
|
+
if (escaped)
|
|
47
|
+
escaped = false;
|
|
48
|
+
else if (c === '\\')
|
|
49
|
+
escaped = true;
|
|
50
|
+
else if (c === '"')
|
|
51
|
+
inString = false;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (c === '"') {
|
|
55
|
+
inString = true;
|
|
56
|
+
}
|
|
57
|
+
else if (c === '{' || c === '[') {
|
|
58
|
+
depth++;
|
|
59
|
+
}
|
|
60
|
+
else if (c === '}' || c === ']') {
|
|
61
|
+
depth--;
|
|
62
|
+
if (depth === 0) {
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(s.slice(0, i + 1));
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Parse a tool call's `arguments` string defensively. A single malformed
|
|
76
|
+
* argument payload must not abort the whole run — the message is part of the
|
|
77
|
+
* persisted history and would otherwise poison every subsequent turn on the
|
|
78
|
+
* thread.
|
|
79
|
+
*/
|
|
80
|
+
function parseToolArguments(raw, toolName) {
|
|
81
|
+
const s = (raw ?? '').trim();
|
|
82
|
+
if (!s)
|
|
83
|
+
return {};
|
|
84
|
+
try {
|
|
85
|
+
return JSON.parse(s);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
const recovered = extractFirstJsonValue(s);
|
|
89
|
+
if (recovered && typeof recovered === 'object') {
|
|
90
|
+
displayWarning(`Recovered malformed tool arguments for ${toolName} (${JSON.stringify(s)} -> ${JSON.stringify(recovered)}). ` +
|
|
91
|
+
'Likely parallel tool calls from a model that ignores disable_parallel_tool_use.');
|
|
92
|
+
return recovered;
|
|
93
|
+
}
|
|
94
|
+
displayWarning(`Unparseable tool arguments for ${toolName} (${JSON.stringify(s)}); defaulting to {}.`);
|
|
95
|
+
return {};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Convert AG-UI message format to LangChain BaseMessage
|
|
100
|
+
*/
|
|
101
|
+
function convertMessage(msg) {
|
|
102
|
+
const content = typeof msg.content === 'string' ? msg.content : '';
|
|
103
|
+
switch (msg.role) {
|
|
104
|
+
case 'user':
|
|
105
|
+
return new HumanMessage(content);
|
|
106
|
+
case 'assistant': {
|
|
107
|
+
if (msg.toolCalls && msg.toolCalls.length > 0) {
|
|
108
|
+
return new AIMessage({
|
|
109
|
+
content: content,
|
|
110
|
+
tool_calls: msg.toolCalls.map((tc) => ({
|
|
111
|
+
id: tc.id,
|
|
112
|
+
name: tc.function.name,
|
|
113
|
+
args: parseToolArguments(tc.function.arguments, tc.function.name),
|
|
114
|
+
type: 'tool_call',
|
|
115
|
+
})),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return new AIMessage(content);
|
|
119
|
+
}
|
|
120
|
+
case 'system':
|
|
121
|
+
case 'developer':
|
|
122
|
+
return new SystemMessage(content);
|
|
123
|
+
case 'tool':
|
|
124
|
+
return new ToolMessage({ content, tool_call_id: msg.toolCallId || msg.id });
|
|
125
|
+
default:
|
|
126
|
+
return new HumanMessage(content);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export async function startAgUiServer(config, port) {
|
|
130
|
+
const app = express();
|
|
131
|
+
app.use(express.json({ limit: '5mb' }));
|
|
132
|
+
displayInfo('WARNING: AG-UI server is intended for local clients only. Do not expose to public networks.');
|
|
133
|
+
// CORS — configured via commands.api.cors in config
|
|
134
|
+
const corsOrigin = config.commands?.api?.cors?.allowOrigin ?? 'http://localhost:3000';
|
|
135
|
+
const corsMethods = config.commands?.api?.cors?.allowMethods ?? 'POST, GET, OPTIONS';
|
|
136
|
+
const corsHeaders = config.commands?.api?.cors?.allowHeaders ?? 'Content-Type, Accept';
|
|
137
|
+
app.use((_req, res, next) => {
|
|
138
|
+
res.setHeader('Access-Control-Allow-Origin', corsOrigin);
|
|
139
|
+
res.setHeader('Access-Control-Allow-Methods', corsMethods);
|
|
140
|
+
res.setHeader('Access-Control-Allow-Headers', corsHeaders);
|
|
141
|
+
if (_req.method === 'OPTIONS') {
|
|
142
|
+
res.status(204).end();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
next();
|
|
146
|
+
});
|
|
147
|
+
// Initialize agent.
|
|
148
|
+
// Note this would need a refactoring if it is to be used for a public web server,
|
|
149
|
+
// For connecting local WEB to local CLI agent, this is absolutely OK, since one thread is OK.
|
|
150
|
+
const checkpointSaver = new MemorySaver();
|
|
151
|
+
const agent = new GthDeepAgent(defaultStatusCallback, createResolvers());
|
|
152
|
+
await agent.init('api', config, checkpointSaver);
|
|
153
|
+
displayInfo(`AG-UI agent initialized`);
|
|
154
|
+
// C-a (spike): agents that additionally bind the client-declared run-input
|
|
155
|
+
// `tools`. Keyed by a stable signature of the toolset so the initial run and
|
|
156
|
+
// its resume share ONE compiled graph — LangGraph resumes from the
|
|
157
|
+
// checkpointer, but the graph shape must match the suspended one. Built lazily
|
|
158
|
+
// on first sighting of a given toolset.
|
|
159
|
+
const toolAgentCache = new Map();
|
|
160
|
+
function toolSignature(tools) {
|
|
161
|
+
return JSON.stringify(tools
|
|
162
|
+
.map((t) => [t.name, t.parameters ?? {}])
|
|
163
|
+
.sort((a, b) => String(a[0]).localeCompare(String(b[0]))));
|
|
164
|
+
}
|
|
165
|
+
async function getAgentForTools(tools) {
|
|
166
|
+
const sig = toolSignature(tools);
|
|
167
|
+
const cached = toolAgentCache.get(sig);
|
|
168
|
+
if (cached)
|
|
169
|
+
return cached;
|
|
170
|
+
const clientStubs = tools.map(buildClientToolStub);
|
|
171
|
+
// Run-input client tools are authoritative. Drop any config.tools entry that
|
|
172
|
+
// collides by name so we never register two client-tool instances of the
|
|
173
|
+
// same name: LangChain v1's AgentNode rejects a same-name/different-instance
|
|
174
|
+
// client tool ("You have modified a tool ..."). This lets a server config
|
|
175
|
+
// also declare the (client-fulfilled) tools — as pukeko's robot tools do —
|
|
176
|
+
// without breaking; the run-input stub is the one actually used.
|
|
177
|
+
const clientStubNames = new Set(clientStubs.map((t) => t.name).filter(Boolean));
|
|
178
|
+
const baseTools = (config.tools ?? []).filter((t) => !(t?.name && clientStubNames.has(t.name)));
|
|
179
|
+
const reqConfig = {
|
|
180
|
+
...config,
|
|
181
|
+
tools: [...baseTools, ...clientStubs],
|
|
182
|
+
};
|
|
183
|
+
const reqAgent = new GthDeepAgent(defaultStatusCallback, createResolvers());
|
|
184
|
+
await reqAgent.init('api', reqConfig, checkpointSaver);
|
|
185
|
+
toolAgentCache.set(sig, reqAgent);
|
|
186
|
+
displayInfo(`AG-UI: bound ${clientStubs.length} client tool(s): ${tools.map((t) => t.name).join(', ')}`);
|
|
187
|
+
return reqAgent;
|
|
188
|
+
}
|
|
189
|
+
// AG-UI endpoint — standard path per AG-UI protocol
|
|
190
|
+
app.post('/agents/:agentId/run', async (req, res) => {
|
|
191
|
+
const { threadId, runId, messages, forwardedProps, tools } = req.body;
|
|
192
|
+
const effectiveThreadId = threadId || randomUUID();
|
|
193
|
+
const effectiveRunId = runId || randomUUID();
|
|
194
|
+
// C-a (spike): if the client declared frontend tools in the run-input, serve
|
|
195
|
+
// this run from an agent that binds them as interrupt stubs. Otherwise use
|
|
196
|
+
// the server's statically-configured agent.
|
|
197
|
+
const hasClientTools = Array.isArray(tools) && tools.length > 0;
|
|
198
|
+
const activeAgent = hasClientTools ? await getAgentForTools(tools) : agent;
|
|
199
|
+
const encoder = new EventEncoder({ accept: req.headers.accept });
|
|
200
|
+
res.setHeader('Content-Type', encoder.getContentType());
|
|
201
|
+
res.setHeader('Cache-Control', 'no-cache');
|
|
202
|
+
res.setHeader('Connection', 'keep-alive');
|
|
203
|
+
// Cancel in-flight inference when the client goes away (e.g. the frontend's
|
|
204
|
+
// Stop button calls HttpAgent.abortRun(), which aborts the fetch). Without
|
|
205
|
+
// this the LangGraph run — and the local model — keeps generating into a
|
|
206
|
+
// dead socket.
|
|
207
|
+
//
|
|
208
|
+
// Listen on the *response* 'close', not the request's: req 'close' fires as
|
|
209
|
+
// soon as the POST body is consumed (right after express.json() reads it),
|
|
210
|
+
// which would abort every run instantly. res 'close' fires when the
|
|
211
|
+
// connection actually goes away. `finished`, set just before res.end(),
|
|
212
|
+
// distinguishes a normal completion (close after we're done) from a real
|
|
213
|
+
// client disconnect (close while still streaming).
|
|
214
|
+
const ac = new AbortController();
|
|
215
|
+
let finished = false;
|
|
216
|
+
res.on('close', () => {
|
|
217
|
+
if (!finished)
|
|
218
|
+
ac.abort();
|
|
219
|
+
});
|
|
220
|
+
try {
|
|
221
|
+
// RUN_STARTED
|
|
222
|
+
res.write(encoder.encode({
|
|
223
|
+
type: EventType.RUN_STARTED,
|
|
224
|
+
threadId: effectiveThreadId,
|
|
225
|
+
runId: effectiveRunId,
|
|
226
|
+
}));
|
|
227
|
+
const messageId = randomUUID();
|
|
228
|
+
// Get runnable config with thread_id for checkpointing. config.recursionLimit
|
|
229
|
+
// (when set by the consumer) caps the agent's super-steps per run.
|
|
230
|
+
const runConfig = {
|
|
231
|
+
...getNewRunnableConfig(config.recursionLimit),
|
|
232
|
+
configurable: { thread_id: effectiveThreadId },
|
|
233
|
+
};
|
|
234
|
+
// Stream the response with typed events
|
|
235
|
+
let textMessageStarted = false;
|
|
236
|
+
let reasoningMessageId = null;
|
|
237
|
+
// C-a (spike): detect CopilotKit's resume shape. CopilotKit fulfils a
|
|
238
|
+
// frontend tool client-side and then RE-RUNS the agent with the full
|
|
239
|
+
// message history, the tool result appended as a trailing `tool` message
|
|
240
|
+
// — it does NOT send `forwardedProps.command.resume`. When that lands on a
|
|
241
|
+
// thread whose graph is suspended at our interrupt() stub, translate the
|
|
242
|
+
// trailing tool result into a graph resume so the suspended run continues
|
|
243
|
+
// (instead of starting a fresh run that just re-calls the tool).
|
|
244
|
+
const lastMsg = Array.isArray(messages) && messages.length > 0 ? messages[messages.length - 1] : undefined;
|
|
245
|
+
const isCopilotToolResume = hasClientTools && forwardedProps?.command?.resume === undefined && lastMsg?.role === 'tool';
|
|
246
|
+
let eventStream;
|
|
247
|
+
if (isCopilotToolResume) {
|
|
248
|
+
const resumeContent = typeof lastMsg.content === 'string' ? lastMsg.content : JSON.stringify(lastMsg.content);
|
|
249
|
+
eventStream = activeAgent.streamWithEventsResume(resumeContent, runConfig, [], ac.signal);
|
|
250
|
+
}
|
|
251
|
+
else if (forwardedProps?.command?.resume !== undefined) {
|
|
252
|
+
// Follow-up messages piggy-backed on the resume: deliver them to the
|
|
253
|
+
// agent on its next decision turn via Command.update (see
|
|
254
|
+
// GthLangChainAgent.streamWithEventsResume). Accepts plain strings or
|
|
255
|
+
// AG-UI message objects.
|
|
256
|
+
const queued = forwardedProps.command.queuedMessages;
|
|
257
|
+
const queuedMessages = Array.isArray(queued)
|
|
258
|
+
? queued
|
|
259
|
+
.map((s) => typeof s === 'string'
|
|
260
|
+
? new HumanMessage(s)
|
|
261
|
+
: convertMessage(s))
|
|
262
|
+
.filter((m) => Boolean(m))
|
|
263
|
+
: [];
|
|
264
|
+
eventStream = activeAgent.streamWithEventsResume(forwardedProps.command.resume, runConfig, queuedMessages, ac.signal);
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
// The system prompt (backstory + guidelines + mode prompt + identity) lives in the
|
|
268
|
+
// deep-agent graph via createDeepAgent({ systemPrompt }) — see GthDeepAgent — so it is no
|
|
269
|
+
// longer prepended here. A separate, non-first SystemMessage would be rejected by Anthropic.
|
|
270
|
+
const langChainMessages = (messages || []).map(convertMessage);
|
|
271
|
+
eventStream = activeAgent.streamWithEvents(langChainMessages, runConfig, ac.signal);
|
|
272
|
+
}
|
|
273
|
+
for await (const event of eventStream) {
|
|
274
|
+
switch (event.type) {
|
|
275
|
+
case 'text': {
|
|
276
|
+
if (!textMessageStarted) {
|
|
277
|
+
res.write(encoder.encode({
|
|
278
|
+
type: EventType.TEXT_MESSAGE_START,
|
|
279
|
+
messageId,
|
|
280
|
+
role: 'assistant',
|
|
281
|
+
}));
|
|
282
|
+
textMessageStarted = true;
|
|
283
|
+
}
|
|
284
|
+
res.write(encoder.encode({
|
|
285
|
+
type: EventType.TEXT_MESSAGE_CONTENT,
|
|
286
|
+
messageId,
|
|
287
|
+
delta: event.delta,
|
|
288
|
+
}));
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
case 'tool_start': {
|
|
292
|
+
res.write(encoder.encode({
|
|
293
|
+
type: EventType.TOOL_CALL_START,
|
|
294
|
+
toolCallId: event.id,
|
|
295
|
+
toolCallName: event.name,
|
|
296
|
+
parentMessageId: messageId,
|
|
297
|
+
}));
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
case 'tool_args': {
|
|
301
|
+
res.write(encoder.encode({
|
|
302
|
+
type: EventType.TOOL_CALL_ARGS,
|
|
303
|
+
toolCallId: event.id,
|
|
304
|
+
delta: event.delta,
|
|
305
|
+
}));
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
case 'tool_end': {
|
|
309
|
+
res.write(encoder.encode({
|
|
310
|
+
type: EventType.TOOL_CALL_END,
|
|
311
|
+
toolCallId: event.id,
|
|
312
|
+
}));
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
case 'tool_result': {
|
|
316
|
+
res.write(encoder.encode({
|
|
317
|
+
type: EventType.TOOL_CALL_RESULT,
|
|
318
|
+
toolCallId: event.id,
|
|
319
|
+
content: event.content,
|
|
320
|
+
role: 'tool',
|
|
321
|
+
messageId: randomUUID(),
|
|
322
|
+
}));
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
case 'reasoning_start': {
|
|
326
|
+
reasoningMessageId = randomUUID();
|
|
327
|
+
res.write(encoder.encode({
|
|
328
|
+
type: EventType.REASONING_MESSAGE_START,
|
|
329
|
+
messageId: reasoningMessageId,
|
|
330
|
+
role: 'reasoning',
|
|
331
|
+
}));
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
case 'reasoning_delta': {
|
|
335
|
+
if (reasoningMessageId) {
|
|
336
|
+
res.write(encoder.encode({
|
|
337
|
+
type: EventType.REASONING_MESSAGE_CONTENT,
|
|
338
|
+
messageId: reasoningMessageId,
|
|
339
|
+
delta: event.delta,
|
|
340
|
+
}));
|
|
341
|
+
}
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
case 'reasoning_end': {
|
|
345
|
+
if (reasoningMessageId) {
|
|
346
|
+
res.write(encoder.encode({
|
|
347
|
+
type: EventType.REASONING_MESSAGE_END,
|
|
348
|
+
messageId: reasoningMessageId,
|
|
349
|
+
}));
|
|
350
|
+
reasoningMessageId = null;
|
|
351
|
+
}
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
// TEXT_MESSAGE_END (only if a text message was started)
|
|
357
|
+
if (textMessageStarted) {
|
|
358
|
+
res.write(encoder.encode({
|
|
359
|
+
type: EventType.TEXT_MESSAGE_END,
|
|
360
|
+
messageId,
|
|
361
|
+
}));
|
|
362
|
+
}
|
|
363
|
+
// RUN_FINISHED
|
|
364
|
+
res.write(encoder.encode({
|
|
365
|
+
type: EventType.RUN_FINISHED,
|
|
366
|
+
threadId: effectiveThreadId,
|
|
367
|
+
runId: effectiveRunId,
|
|
368
|
+
}));
|
|
369
|
+
finished = true;
|
|
370
|
+
res.end();
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
// A client-initiated abort isn't an error — the socket is already gone, so
|
|
374
|
+
// there's nothing to write to. Only surface RUN_ERROR for real failures.
|
|
375
|
+
if (ac.signal.aborted) {
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
379
|
+
res.write(encoder.encode({
|
|
380
|
+
type: EventType.RUN_ERROR,
|
|
381
|
+
message: errorMessage,
|
|
382
|
+
}));
|
|
383
|
+
res.end();
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
// Health check
|
|
387
|
+
app.get('/health', (_req, res) => {
|
|
388
|
+
res.json({ status: 'ok' });
|
|
389
|
+
});
|
|
390
|
+
// Agent metadata — lets clients display which model/provider is serving them.
|
|
391
|
+
// provider is read from the LangChain model's _llmType() (e.g. "ollama",
|
|
392
|
+
// "anthropic"); model from config.modelDisplayName, falling back to the
|
|
393
|
+
// chat model's own `model` field.
|
|
394
|
+
app.get('/info', (_req, res) => {
|
|
395
|
+
const llm = config.llm;
|
|
396
|
+
let provider = null;
|
|
397
|
+
try {
|
|
398
|
+
provider = typeof llm?._llmType === 'function' ? llm._llmType() : null;
|
|
399
|
+
}
|
|
400
|
+
catch {
|
|
401
|
+
provider = null;
|
|
402
|
+
}
|
|
403
|
+
res.json({
|
|
404
|
+
status: 'ok',
|
|
405
|
+
provider,
|
|
406
|
+
model: config.modelDisplayName ?? llm?.model ?? null,
|
|
407
|
+
});
|
|
408
|
+
});
|
|
409
|
+
return new Promise((resolve) => {
|
|
410
|
+
app.listen(port, () => {
|
|
411
|
+
displayInfo(`AG-UI server listening at http://localhost:${port}`);
|
|
412
|
+
displayInfo(`AG-UI endpoint: POST http://localhost:${port}/agents/{agentId}/run`);
|
|
413
|
+
resolve();
|
|
414
|
+
});
|
|
415
|
+
});
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,CAAC;YACH,QAAQ,GAAG,OAAO,GAAG,EAAE,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACzE,CAAC;QAAC,MAAM,CAAC;YACP,QAAQ,GAAG,IAAI,CAAC;QAClB,CAAC;QACD,GAAG,CAAC,IAAI,CAAC;YACP,MAAM,EAAE,IAAI;YACZ,QAAQ;YACR,KAAK,EAAE,MAAM,CAAC,gBAAgB,IAAI,GAAG,EAAE,KAAK,IAAI,IAAI;SACrD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;YACpB,WAAW,CAAC,8CAA8C,IAAI,EAAE,CAAC,CAAC;YAClE,WAAW,CAAC,yCAAyC,IAAI,uBAAuB,CAAC,CAAC;YAClF,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CommandLineConfigOverrides, GthConfig } from '@gaunt-sloth/core/config.js';
|
|
2
|
+
export interface SessionConfig {
|
|
3
|
+
mode: 'chat' | 'code';
|
|
4
|
+
readModePrompt: (config: Pick<GthConfig, 'identityProfile'>) => string | null;
|
|
5
|
+
description: string;
|
|
6
|
+
readyMessage: string;
|
|
7
|
+
exitMessage: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function createInteractiveSession(sessionConfig: SessionConfig, commandLineConfigOverrides: CommandLineConfigOverrides, message?: string): Promise<void>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { initConfig } from '@gaunt-sloth/core/config.js';
|
|
2
|
+
import { defaultStatusCallback, display, displayInfo, flushSessionLog, formatInputPrompt, initSessionLogging, stopSessionLogging, } from '@gaunt-sloth/core/utils/consoleUtils.js';
|
|
3
|
+
import { GthAgentRunner } from '@gaunt-sloth/core/core/GthAgentRunner.js';
|
|
4
|
+
import { appendToFile, getCommandOutputFilePath } from '@gaunt-sloth/core/utils/fileUtils.js';
|
|
5
|
+
import { createInterface, error, exit, setRawMode, stdin as input, stdout as output, } from '@gaunt-sloth/core/utils/systemUtils.js';
|
|
6
|
+
import { HumanMessage } from '@langchain/core/messages';
|
|
7
|
+
import { MemorySaver } from '@langchain/langgraph';
|
|
8
|
+
import { createResolvers } from '#src/resolvers.js';
|
|
9
|
+
import { gthDeepAgentFactory } from '#src/core/gthDeepAgentFactory.js';
|
|
10
|
+
export async function createInteractiveSession(sessionConfig, commandLineConfigOverrides, message) {
|
|
11
|
+
const config = { ...(await initConfig(commandLineConfigOverrides)) };
|
|
12
|
+
const checkpointSaver = new MemorySaver();
|
|
13
|
+
// Initialize Runner
|
|
14
|
+
const logFileName = getCommandOutputFilePath(config, sessionConfig.mode);
|
|
15
|
+
if (logFileName) {
|
|
16
|
+
initSessionLogging(logFileName, config.streamSessionInferenceLog);
|
|
17
|
+
}
|
|
18
|
+
const runner = new GthAgentRunner(defaultStatusCallback, createResolvers(), gthDeepAgentFactory);
|
|
19
|
+
try {
|
|
20
|
+
await runner.init(sessionConfig.mode, config, checkpointSaver);
|
|
21
|
+
const rl = createInterface({ input, output });
|
|
22
|
+
let shouldExit = false;
|
|
23
|
+
if (logFileName) {
|
|
24
|
+
displayInfo(`${sessionConfig.mode} session will be logged to ${logFileName}\n`);
|
|
25
|
+
}
|
|
26
|
+
const processMessage = async (userInput) => {
|
|
27
|
+
const logEntry = `## User\n\n${userInput}\n\n## Assistant\n\n`;
|
|
28
|
+
if (logFileName) {
|
|
29
|
+
appendToFile(logFileName, logEntry);
|
|
30
|
+
}
|
|
31
|
+
flushSessionLog(); // Ensure user input is immediately written to file
|
|
32
|
+
// The system prompt (backstory + guidelines + mode prompt + identity) now lives in the
|
|
33
|
+
// deep-agent graph via createDeepAgent({ systemPrompt }) — see GthDeepAgent — so it is no
|
|
34
|
+
// longer injected here as a per-turn SystemMessage (which yielded a second, non-first system
|
|
35
|
+
// message that Anthropic rejects).
|
|
36
|
+
const messages = [new HumanMessage(userInput)];
|
|
37
|
+
await runner.processMessages(messages);
|
|
38
|
+
};
|
|
39
|
+
const askQuestion = async () => {
|
|
40
|
+
while (!shouldExit) {
|
|
41
|
+
setRawMode(true); // resume raw mode for user input (without it every user input is parroted)
|
|
42
|
+
const userInput = await rl.question(formatInputPrompt(' > '));
|
|
43
|
+
if (!userInput.trim()) {
|
|
44
|
+
continue; // Skip inference if no input
|
|
45
|
+
}
|
|
46
|
+
const lowerInput = userInput.toLowerCase();
|
|
47
|
+
if (lowerInput === 'exit' || lowerInput === '/exit') {
|
|
48
|
+
display('Exiting...');
|
|
49
|
+
shouldExit = true;
|
|
50
|
+
await runner.cleanup();
|
|
51
|
+
stopSessionLogging();
|
|
52
|
+
rl.close();
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
let shouldRetry = false;
|
|
56
|
+
do {
|
|
57
|
+
try {
|
|
58
|
+
await processMessage(userInput);
|
|
59
|
+
shouldRetry = false;
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
display(`\n❌ Error processing message: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
63
|
+
const retryResponse = await rl.question('Do you want to try again with the same prompt? (y/n): ');
|
|
64
|
+
shouldRetry = retryResponse.toLowerCase().trim().startsWith('y');
|
|
65
|
+
if (!shouldRetry) {
|
|
66
|
+
display('\nSkipping to next prompt...');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
} while (shouldRetry && !shouldExit);
|
|
70
|
+
if (!shouldExit) {
|
|
71
|
+
display('\n\n');
|
|
72
|
+
displayInfo(sessionConfig.exitMessage);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
rl.close();
|
|
76
|
+
};
|
|
77
|
+
if (message) {
|
|
78
|
+
await processMessage(message);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
display(sessionConfig.readyMessage);
|
|
82
|
+
displayInfo(sessionConfig.exitMessage);
|
|
83
|
+
}
|
|
84
|
+
if (!shouldExit)
|
|
85
|
+
await askQuestion();
|
|
86
|
+
if (shouldExit) {
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
exit();
|
|
89
|
+
}, 500);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
await runner.cleanup();
|
|
94
|
+
stopSessionLogging();
|
|
95
|
+
error(`Error in ${sessionConfig.mode} command: ${err}`);
|
|
96
|
+
exit(1);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=interactiveSessionModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactiveSessionModule.js","sourceRoot":"","sources":["../../src/modules/interactiveSessionModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyC,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAChG,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EACL,eAAe,EACf,KAAK,EACL,IAAI,EACJ,UAAU,EACV,KAAK,IAAI,KAAK,EACd,MAAM,IAAI,MAAM,GACjB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAoB,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAUvE,MAAM,CAAC,KAAK,UAAU,w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CAAC;4BACjB,OAAO,CAAC,8BAA8B,CAAC,CAAC;wBAC1C,CAAC;oBACH,CAAC;gBACH,CAAC,QAAQ,WAAW,IAAI,CAAC,UAAU,EAAE;gBAErC,IAAI,CAAC,UAAU,EAAE,CAAC;oBAChB,OAAO,CAAC,MAAM,CAAC,CAAC;oBAChB,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;gBACzC,CAAC;YACH,CAAC;YACD,EAAE,CAAC,KAAK,EAAE,CAAC;QACb,CAAC,CAAC;QAEF,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;YACpC,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,CAAC,UAAU;YAAE,MAAM,WAAW,EAAE,CAAC;QACrC,IAAI,UAAU,EAAE,CAAC;YACf,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,EAAE,CAAC;YACT,CAAC,EAAE,GAAG,CAAC,CAAC;QACV,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACvB,kBAAkB,EAAE,CAAC;QACrB,KAAK,CAAC,YAAY,aAAa,CAAC,IAAI,aAAa,GAAG,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,CAAC,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Resolver implementations for the AgentResolvers pattern.
|
|
4
|
+
*
|
|
5
|
+
* Provides `resolveTools` / `cleanupTools` that wire up built-in tools
|
|
6
|
+
* (filesystem, dev, custom), MCP servers, and A2A agents.
|
|
7
|
+
*
|
|
8
|
+
* Provides `resolveMiddleware` / `cleanupMiddleware` that delegate to the
|
|
9
|
+
* agent middleware registry.
|
|
10
|
+
*/
|
|
11
|
+
import type { AgentResolvers } from '@gaunt-sloth/core/core/types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Create a full set of resolvers for the GthLangChainAgent.
|
|
14
|
+
*
|
|
15
|
+
* Each call returns a fresh set of resolvers with their own MCP client
|
|
16
|
+
* instance, avoiding shared module-level state and race conditions.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createResolvers(): AgentResolvers;
|