@amodalai/runtime 0.3.48 → 0.3.50
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/dist/src/agent/completion-tools.integration.test.d.ts +6 -0
- package/dist/src/agent/completion-tools.integration.test.js +263 -0
- package/dist/src/agent/completion-tools.integration.test.js.map +1 -0
- package/dist/src/agent/load-template-plan.integration.test.d.ts +6 -0
- package/dist/src/agent/load-template-plan.integration.test.js +152 -0
- package/dist/src/agent/load-template-plan.integration.test.js.map +1 -0
- package/dist/src/agent/local-server.js +64 -9
- package/dist/src/agent/local-server.js.map +1 -1
- package/dist/src/agent/loop-types.d.ts +12 -2
- package/dist/src/agent/loop.test.js +5 -2
- package/dist/src/agent/loop.test.js.map +1 -1
- package/dist/src/agent/propose-plan.integration.test.d.ts +6 -0
- package/dist/src/agent/propose-plan.integration.test.js +186 -0
- package/dist/src/agent/propose-plan.integration.test.js.map +1 -0
- package/dist/src/agent/routes/package-updates.d.ts +42 -0
- package/dist/src/agent/routes/package-updates.js +207 -0
- package/dist/src/agent/routes/package-updates.js.map +1 -0
- package/dist/src/agent/routes/package-updates.test.d.ts +6 -0
- package/dist/src/agent/routes/package-updates.test.js +25 -0
- package/dist/src/agent/routes/package-updates.test.js.map +1 -0
- package/dist/src/agent/setup-state.integration.test.d.ts +6 -0
- package/dist/src/agent/setup-state.integration.test.js +182 -0
- package/dist/src/agent/setup-state.integration.test.js.map +1 -0
- package/dist/src/agent/snapshot-server.js +1 -0
- package/dist/src/agent/snapshot-server.js.map +1 -1
- package/dist/src/agent/states/executing.d.ts +6 -0
- package/dist/src/agent/states/executing.js +63 -27
- package/dist/src/agent/states/executing.js.map +1 -1
- package/dist/src/agent/states/streaming.js +18 -2
- package/dist/src/agent/states/streaming.js.map +1 -1
- package/dist/src/agent/tool-executor-local.js +11 -2
- package/dist/src/agent/tool-executor-local.js.map +1 -1
- package/dist/src/agent/validate-connection.integration.test.d.ts +6 -0
- package/dist/src/agent/validate-connection.integration.test.js +160 -0
- package/dist/src/agent/validate-connection.integration.test.js.map +1 -0
- package/dist/src/api/create-agent.js +1 -0
- package/dist/src/api/create-agent.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/intent/executor.d.ts +48 -0
- package/dist/src/intent/executor.js +420 -0
- package/dist/src/intent/executor.js.map +1 -0
- package/dist/src/intent/executor.test.d.ts +6 -0
- package/dist/src/intent/executor.test.js +543 -0
- package/dist/src/intent/executor.test.js.map +1 -0
- package/dist/src/intent/index.d.ts +10 -0
- package/dist/src/intent/index.js +9 -0
- package/dist/src/intent/index.js.map +1 -0
- package/dist/src/intent/loader.d.ts +16 -0
- package/dist/src/intent/loader.js +112 -0
- package/dist/src/intent/loader.js.map +1 -0
- package/dist/src/intent/loader.test.d.ts +6 -0
- package/dist/src/intent/loader.test.js +86 -0
- package/dist/src/intent/loader.test.js.map +1 -0
- package/dist/src/intent/matcher.d.ts +26 -0
- package/dist/src/intent/matcher.js +29 -0
- package/dist/src/intent/matcher.js.map +1 -0
- package/dist/src/intent/matcher.test.d.ts +6 -0
- package/dist/src/intent/matcher.test.js +53 -0
- package/dist/src/intent/matcher.test.js.map +1 -0
- package/dist/src/intent/onboarding.e2e.test.d.ts +6 -0
- package/dist/src/intent/onboarding.e2e.test.js +394 -0
- package/dist/src/intent/onboarding.e2e.test.js.map +1 -0
- package/dist/src/routes/ai-stream.js +96 -3
- package/dist/src/routes/ai-stream.js.map +1 -1
- package/dist/src/routes/session-resolver.js +16 -0
- package/dist/src/routes/session-resolver.js.map +1 -1
- package/dist/src/session/credential-scrubber.d.ts +35 -0
- package/dist/src/session/credential-scrubber.js +150 -0
- package/dist/src/session/credential-scrubber.js.map +1 -0
- package/dist/src/session/credential-scrubber.test.d.ts +6 -0
- package/dist/src/session/credential-scrubber.test.js +192 -0
- package/dist/src/session/credential-scrubber.test.js.map +1 -0
- package/dist/src/session/manager.intent.test.d.ts +6 -0
- package/dist/src/session/manager.intent.test.js +197 -0
- package/dist/src/session/manager.intent.test.js.map +1 -0
- package/dist/src/session/manager.js +114 -0
- package/dist/src/session/manager.js.map +1 -1
- package/dist/src/session/session-builder.d.ts +16 -1
- package/dist/src/session/session-builder.js +209 -40
- package/dist/src/session/session-builder.js.map +1 -1
- package/dist/src/session/store.js +48 -2
- package/dist/src/session/store.js.map +1 -1
- package/dist/src/session/tool-context-factory.js +12 -0
- package/dist/src/session/tool-context-factory.js.map +1 -1
- package/dist/src/session/types.d.ts +12 -1
- package/dist/src/setup/commit-setup.d.ts +94 -0
- package/dist/src/setup/commit-setup.js +154 -0
- package/dist/src/setup/commit-setup.js.map +1 -0
- package/dist/src/setup/commit-setup.test.d.ts +6 -0
- package/dist/src/setup/commit-setup.test.js +310 -0
- package/dist/src/setup/commit-setup.test.js.map +1 -0
- package/dist/src/tools/README.md +270 -0
- package/dist/src/tools/admin-tools.d.ts +27 -0
- package/dist/src/tools/admin-tools.js +734 -0
- package/dist/src/tools/admin-tools.js.map +1 -0
- package/dist/src/tools/agent-package-discovery.test.d.ts +6 -0
- package/dist/src/tools/agent-package-discovery.test.js +90 -0
- package/dist/src/tools/agent-package-discovery.test.js.map +1 -0
- package/dist/src/tools/builtin/ask-choice.d.ts +8 -0
- package/dist/src/tools/builtin/ask-choice.js +54 -0
- package/dist/src/tools/builtin/ask-choice.js.map +1 -0
- package/dist/src/tools/context.d.ts +154 -0
- package/dist/src/tools/context.js +30 -0
- package/dist/src/tools/context.js.map +1 -0
- package/dist/src/tools/custom-tool-adapter.d.ts +33 -2
- package/dist/src/tools/custom-tool-adapter.js +38 -1
- package/dist/src/tools/custom-tool-adapter.js.map +1 -1
- package/dist/src/tools/custom-tool-adapter.test.js +48 -0
- package/dist/src/tools/custom-tool-adapter.test.js.map +1 -1
- package/dist/src/tools/fetch-url-tool.js +2 -0
- package/dist/src/tools/fetch-url-tool.js.map +1 -1
- package/dist/src/tools/file-tools.js +16 -0
- package/dist/src/tools/file-tools.js.map +1 -1
- package/dist/src/tools/fs/local.test.d.ts +6 -0
- package/dist/src/tools/fs/local.test.js +126 -0
- package/dist/src/tools/fs/local.test.js.map +1 -0
- package/dist/src/tools/index.d.ts +35 -0
- package/dist/src/tools/index.js +11 -0
- package/dist/src/tools/index.js.map +1 -0
- package/dist/src/tools/mcp-tool-adapter.js +2 -0
- package/dist/src/tools/mcp-tool-adapter.js.map +1 -1
- package/dist/src/tools/memory-tool.js +23 -1
- package/dist/src/tools/memory-tool.js.map +1 -1
- package/dist/src/tools/permissions.d.ts +36 -0
- package/dist/src/tools/permissions.js +97 -0
- package/dist/src/tools/permissions.js.map +1 -0
- package/dist/src/tools/permissions.test.d.ts +6 -0
- package/dist/src/tools/permissions.test.js +62 -0
- package/dist/src/tools/permissions.test.js.map +1 -0
- package/dist/src/tools/request-tool.js +2 -0
- package/dist/src/tools/request-tool.js.map +1 -1
- package/dist/src/tools/sdk-context.d.ts +43 -0
- package/dist/src/tools/sdk-context.js +94 -0
- package/dist/src/tools/sdk-context.js.map +1 -0
- package/dist/src/tools/sdk-context.test.d.ts +6 -0
- package/dist/src/tools/sdk-context.test.js +134 -0
- package/dist/src/tools/sdk-context.test.js.map +1 -0
- package/dist/src/tools/store-tools.js +6 -0
- package/dist/src/tools/store-tools.js.map +1 -1
- package/dist/src/tools/types.d.ts +53 -14
- package/dist/src/tools/web-search-tool.js +2 -0
- package/dist/src/tools/web-search-tool.js.map +1 -1
- package/dist/src/types.d.ts +164 -28
- package/dist/src/types.js +9 -3
- package/dist/src/types.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -4
- package/dist/src/tools/agent-config-tool.d.ts +0 -7
- package/dist/src/tools/agent-config-tool.js +0 -78
- package/dist/src/tools/agent-config-tool.js.map +0 -1
- package/dist/src/tools/collect-secret-tool.d.ts +0 -7
- package/dist/src/tools/collect-secret-tool.js +0 -47
- package/dist/src/tools/collect-secret-tool.js.map +0 -1
- package/dist/src/tools/fs/http.d.ts +0 -37
- package/dist/src/tools/fs/http.js +0 -88
- package/dist/src/tools/fs/http.js.map +0 -1
- package/dist/src/tools/http-file-tools.d.ts +0 -13
- package/dist/src/tools/http-file-tools.js +0 -146
- package/dist/src/tools/http-file-tools.js.map +0 -1
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Amodal Labs, Inc.
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The bypass executor for matched intents.
|
|
8
|
+
*
|
|
9
|
+
* Drives a handler from start to finish, emitting SSE events as tools
|
|
10
|
+
* fire and assembling the synthetic assistant + tool result messages
|
|
11
|
+
* that get appended to `session.messages` at the end. The shape of
|
|
12
|
+
* those messages mirrors what the agent loop produces for the
|
|
13
|
+
* equivalent LLM-driven turn — same tool-call parts, same tool result
|
|
14
|
+
* messages — so chat rehydration on reload renders the cards
|
|
15
|
+
* identically without any client-side branching.
|
|
16
|
+
*
|
|
17
|
+
* Concurrency model: `runIntent` is an async generator. The handler
|
|
18
|
+
* runs in parallel via a chained promise; each `ctx.callTool(...)`
|
|
19
|
+
* pushes events into a queue, the generator yields them as they
|
|
20
|
+
* arrive, then waits for the handler to settle. This lets the user
|
|
21
|
+
* see tool-call cards stream in one at a time instead of all at the
|
|
22
|
+
* end.
|
|
23
|
+
*/
|
|
24
|
+
import { randomUUID } from 'node:crypto';
|
|
25
|
+
import { SSEEventType } from '../types.js';
|
|
26
|
+
import { ToolExecutionError } from '../errors.js';
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Shared queue used by callTool to push events that runIntent yields
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
/**
|
|
31
|
+
* Single-producer / single-consumer event queue. callTool pushes
|
|
32
|
+
* events as the tool runs; runIntent's outer loop awaits next() and
|
|
33
|
+
* yields each event onto the SSE stream. `finish()` is called when
|
|
34
|
+
* the handler resolves so the consumer can exit the loop.
|
|
35
|
+
*
|
|
36
|
+
* `next()` returns `SSEEvent | null` (null = stream closed) instead
|
|
37
|
+
* of an IteratorResult — this isn't an Iterator itself, just an
|
|
38
|
+
* internal queue, and the simpler signature avoids casting around
|
|
39
|
+
* the IteratorResult value-when-done quirk.
|
|
40
|
+
*/
|
|
41
|
+
class IntentEventQueue {
|
|
42
|
+
buffer = [];
|
|
43
|
+
waiters = [];
|
|
44
|
+
done = false;
|
|
45
|
+
push(event) {
|
|
46
|
+
const w = this.waiters.shift();
|
|
47
|
+
if (w) {
|
|
48
|
+
w(event);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
this.buffer.push(event);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
finish() {
|
|
55
|
+
this.done = true;
|
|
56
|
+
let w = this.waiters.shift();
|
|
57
|
+
while (w !== undefined) {
|
|
58
|
+
w(null);
|
|
59
|
+
w = this.waiters.shift();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
next() {
|
|
63
|
+
const buffered = this.buffer.shift();
|
|
64
|
+
if (buffered !== undefined)
|
|
65
|
+
return Promise.resolve(buffered);
|
|
66
|
+
if (this.done)
|
|
67
|
+
return Promise.resolve(null);
|
|
68
|
+
return new Promise((resolve) => this.waiters.push(resolve));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
// Label resolution (mirrors the helper in executing.ts)
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
/**
|
|
75
|
+
* Resolve `{{paramName}}` placeholders in a label template against the
|
|
76
|
+
* call's params. Same semantics as the executing-state helper —
|
|
77
|
+
* missing/non-string params drop out, adjacent whitespace collapses.
|
|
78
|
+
* Duplicated here rather than imported to keep the executing-state
|
|
79
|
+
* helper internal; if a third caller appears we pull it up to a
|
|
80
|
+
* shared module.
|
|
81
|
+
*/
|
|
82
|
+
function resolveLabelTemplate(template, params) {
|
|
83
|
+
const filled = template.replace(/\{\{(\w+)\}\}/g, (_match, key) => {
|
|
84
|
+
const v = params[key];
|
|
85
|
+
return typeof v === 'string' ? v : typeof v === 'number' || typeof v === 'boolean' ? String(v) : '';
|
|
86
|
+
});
|
|
87
|
+
return filled.replace(/\s+/g, ' ').trim();
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Mirrors `sanitizeParams` in executing.ts — strips token/secret/etc.
|
|
91
|
+
* fields from tool params before they leave the runtime as SSE
|
|
92
|
+
* events. Synthetic tool calls from intents go through the same wire
|
|
93
|
+
* as agent-loop tool calls; secret keys would leak otherwise.
|
|
94
|
+
*/
|
|
95
|
+
function sanitizeParams(params) {
|
|
96
|
+
const sanitized = {};
|
|
97
|
+
for (const [key, value] of Object.entries(params)) {
|
|
98
|
+
if (/token|secret|password|key|auth/i.test(key)) {
|
|
99
|
+
sanitized[key] = '[REDACTED]';
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
sanitized[key] = value;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return sanitized;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Render a tool's raw output as a JSON-or-text string suitable for
|
|
109
|
+
* the AI SDK's text-typed tool-result content. Mirrors the
|
|
110
|
+
* `buildToolResultMessage` path in executing.ts: strings pass
|
|
111
|
+
* through, everything else gets JSON-stringified. Keeps the
|
|
112
|
+
* synthetic tool result message identical in shape to what the
|
|
113
|
+
* agent loop would have appended.
|
|
114
|
+
*/
|
|
115
|
+
function stringifyToolOutput(output) {
|
|
116
|
+
if (typeof output === 'string')
|
|
117
|
+
return output;
|
|
118
|
+
try {
|
|
119
|
+
return JSON.stringify(output);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return String(output);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Drive a matched intent and yield SSE events as the handler runs.
|
|
127
|
+
*
|
|
128
|
+
* Returns (via the generator's return value) one of:
|
|
129
|
+
* - `completed` with the synthetic messages to append to session.messages
|
|
130
|
+
* - `fellThrough` when the handler returned null BEFORE any tool ran
|
|
131
|
+
* (caller falls through to the LLM)
|
|
132
|
+
* - `errored` when the handler threw or a tool throw bubbled
|
|
133
|
+
*/
|
|
134
|
+
export async function* runIntent(opts) {
|
|
135
|
+
const startedAt = Date.now();
|
|
136
|
+
const queue = new IntentEventQueue();
|
|
137
|
+
const messageParts = [];
|
|
138
|
+
const toolMessages = [];
|
|
139
|
+
let textContent = '';
|
|
140
|
+
let toolCallsStarted = 0;
|
|
141
|
+
opts.logger.info('intent_matched', {
|
|
142
|
+
intentId: opts.match.intent.id,
|
|
143
|
+
sessionId: opts.sessionId,
|
|
144
|
+
});
|
|
145
|
+
/** Reject reason used internally when an intent should abort BUT not
|
|
146
|
+
* fall through (e.g. a tool gates on confirmation). The runtime
|
|
147
|
+
* catches this and emits an error SSE so the user sees what
|
|
148
|
+
* happened, rather than silently skipping to the LLM after we've
|
|
149
|
+
* potentially emitted other events. */
|
|
150
|
+
class IntentAbortError extends Error {
|
|
151
|
+
constructor(message) {
|
|
152
|
+
super(message);
|
|
153
|
+
this.name = 'IntentAbortError';
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const ctx = {
|
|
157
|
+
match: opts.match.match,
|
|
158
|
+
userMessage: opts.userMessage,
|
|
159
|
+
sessionId: opts.sessionId,
|
|
160
|
+
scopeId: opts.scopeId,
|
|
161
|
+
async callTool(toolName, params) {
|
|
162
|
+
const tool = opts.toolRegistry.get(toolName);
|
|
163
|
+
if (!tool) {
|
|
164
|
+
throw new IntentAbortError(`Intent "${opts.match.intent.id}" tried to call unknown tool "${toolName}".`);
|
|
165
|
+
}
|
|
166
|
+
// Confirmation gate: intents are restricted to the deterministic
|
|
167
|
+
// happy path. Anything that needs user judgment (a tool flagged
|
|
168
|
+
// as `requiresConfirmation` or any connection-tool ACL gate)
|
|
169
|
+
// routes through the agent loop where CONFIRMING handles it.
|
|
170
|
+
if (toolGatesOnConfirmation(tool)) {
|
|
171
|
+
opts.logger.warn('intent_blocked_by_confirmation', {
|
|
172
|
+
intentId: opts.match.intent.id,
|
|
173
|
+
sessionId: opts.sessionId,
|
|
174
|
+
toolName,
|
|
175
|
+
});
|
|
176
|
+
throw new IntentAbortError(`Tool "${toolName}" requires confirmation; intents can't bypass that gate.`);
|
|
177
|
+
}
|
|
178
|
+
// Validate params via the tool's Zod schema (skipped silently
|
|
179
|
+
// for jsonSchema()-defined tools, same as the agent loop).
|
|
180
|
+
if ('safeParse' in tool.parameters) {
|
|
181
|
+
const validation = tool.parameters.safeParse(params);
|
|
182
|
+
if (!validation.success) {
|
|
183
|
+
throw new IntentAbortError(`Intent "${opts.match.intent.id}" emitted invalid params for "${toolName}": ${validation.error.message}`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
toolCallsStarted++;
|
|
187
|
+
const toolCallId = `intent_${randomUUID()}`;
|
|
188
|
+
const toolContext = opts.buildToolContext(toolCallId);
|
|
189
|
+
const startedAt = Date.now();
|
|
190
|
+
// Sanitized params for the wire — labels resolve from the
|
|
191
|
+
// ORIGINAL params (a redacted token in a label is fine; a label
|
|
192
|
+
// built off `[REDACTED]` looks weird).
|
|
193
|
+
const sanitizedParams = sanitizeParams(params);
|
|
194
|
+
const startEvent = {
|
|
195
|
+
type: SSEEventType.ToolCallStart,
|
|
196
|
+
tool_name: toolName,
|
|
197
|
+
tool_id: toolCallId,
|
|
198
|
+
parameters: sanitizedParams,
|
|
199
|
+
...(tool.runningLabel
|
|
200
|
+
? { running_label: resolveLabelTemplate(tool.runningLabel, params) }
|
|
201
|
+
: {}),
|
|
202
|
+
...(tool.completedLabel
|
|
203
|
+
? { completed_label: resolveLabelTemplate(tool.completedLabel, params) }
|
|
204
|
+
: {}),
|
|
205
|
+
timestamp: new Date().toISOString(),
|
|
206
|
+
};
|
|
207
|
+
queue.push(startEvent);
|
|
208
|
+
let output;
|
|
209
|
+
try {
|
|
210
|
+
output = await tool.execute(params, toolContext);
|
|
211
|
+
}
|
|
212
|
+
catch (err) {
|
|
213
|
+
const duration_ms = Date.now() - startedAt;
|
|
214
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
215
|
+
// Drain any inline events the tool managed to emit before throwing.
|
|
216
|
+
// ToolInlineEvent is a structural subset of SSEEvent (same SSE
|
|
217
|
+
// discriminated-union members), but they live in different files
|
|
218
|
+
// — go through unknown to satisfy strict variance.
|
|
219
|
+
for (const e of toolContext.inlineEvents ?? []) {
|
|
220
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- ToolInlineEvent is a structural subset of SSEEvent (same shapes, two declaration sites)
|
|
221
|
+
queue.push(e);
|
|
222
|
+
}
|
|
223
|
+
queue.push({
|
|
224
|
+
type: SSEEventType.ToolCallResult,
|
|
225
|
+
tool_id: toolCallId,
|
|
226
|
+
status: 'error',
|
|
227
|
+
duration_ms,
|
|
228
|
+
error: message,
|
|
229
|
+
timestamp: new Date().toISOString(),
|
|
230
|
+
});
|
|
231
|
+
throw new ToolExecutionError(`Intent "${opts.match.intent.id}" tool "${toolName}" failed: ${message}`, { toolName, callId: toolCallId, cause: err instanceof Error ? err : undefined });
|
|
232
|
+
}
|
|
233
|
+
const duration_ms = Date.now() - startedAt;
|
|
234
|
+
// Drain inline events the tool emitted via ctx.emit (panels,
|
|
235
|
+
// ask_choice, plan_summary, tool_label_update, etc.). Same
|
|
236
|
+
// semantics as the agent loop — these arrive between the tool's
|
|
237
|
+
// start and result so the chat renders them in the right order.
|
|
238
|
+
for (const e of toolContext.inlineEvents ?? []) {
|
|
239
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- ToolInlineEvent is a structural subset of SSEEvent (same shapes, two declaration sites)
|
|
240
|
+
queue.push(e);
|
|
241
|
+
}
|
|
242
|
+
const resultEvent = buildSuccessResultEvent(toolCallId, output, duration_ms);
|
|
243
|
+
queue.push(resultEvent);
|
|
244
|
+
messageParts.push({
|
|
245
|
+
type: 'tool-call',
|
|
246
|
+
toolCallId,
|
|
247
|
+
toolName,
|
|
248
|
+
input: params,
|
|
249
|
+
});
|
|
250
|
+
// Match the agent loop's `buildToolResultMessage` shape: text-as-string.
|
|
251
|
+
// The AI SDK accepts either {type:'text',value:string} or
|
|
252
|
+
// {type:'json',value:JSON}, but the agent loop always uses text so
|
|
253
|
+
// session.messages stays uniform across intent-driven and LLM-driven
|
|
254
|
+
// turns. Without this, rehydration would render two different shapes
|
|
255
|
+
// depending on which path produced the turn.
|
|
256
|
+
toolMessages.push({
|
|
257
|
+
role: 'tool',
|
|
258
|
+
content: [
|
|
259
|
+
{
|
|
260
|
+
type: 'tool-result',
|
|
261
|
+
toolCallId,
|
|
262
|
+
toolName,
|
|
263
|
+
output: { type: 'text', value: stringifyToolOutput(output) },
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
});
|
|
267
|
+
return output;
|
|
268
|
+
},
|
|
269
|
+
emitText(text) {
|
|
270
|
+
textContent += text;
|
|
271
|
+
queue.push({
|
|
272
|
+
type: SSEEventType.TextDelta,
|
|
273
|
+
content: text,
|
|
274
|
+
timestamp: new Date().toISOString(),
|
|
275
|
+
});
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
// Drive the handler in parallel; the `finally` always closes the queue.
|
|
279
|
+
// Wrapped in a state object because TS can't follow assignments to
|
|
280
|
+
// bare `let` variables across the IIFE's closure boundary.
|
|
281
|
+
const handlerState = { error: null, result: undefined };
|
|
282
|
+
const handlerPromise = (async () => {
|
|
283
|
+
try {
|
|
284
|
+
handlerState.result = await opts.match.intent.handle(ctx);
|
|
285
|
+
}
|
|
286
|
+
catch (err) {
|
|
287
|
+
handlerState.error = err instanceof Error ? err : new Error(String(err));
|
|
288
|
+
}
|
|
289
|
+
finally {
|
|
290
|
+
queue.finish();
|
|
291
|
+
}
|
|
292
|
+
})();
|
|
293
|
+
// Yield events as they're produced by callTool / emitText.
|
|
294
|
+
// The loop exits when queue.finish() runs (in the handler's finally).
|
|
295
|
+
let event = await queue.next();
|
|
296
|
+
while (event !== null) {
|
|
297
|
+
yield event;
|
|
298
|
+
event = await queue.next();
|
|
299
|
+
}
|
|
300
|
+
// Make sure the handler promise is fully settled before we read state.
|
|
301
|
+
await handlerPromise;
|
|
302
|
+
// Errors: emit an error SSE for the user and report the outcome to
|
|
303
|
+
// the caller. We don't fall through after errors — the user saw the
|
|
304
|
+
// failure mid-flight and the next user turn can do whatever they
|
|
305
|
+
// want (retry, type something more general → LLM).
|
|
306
|
+
if (handlerState.error !== null) {
|
|
307
|
+
const err = handlerState.error;
|
|
308
|
+
opts.logger.warn('intent_errored', {
|
|
309
|
+
intentId: opts.match.intent.id,
|
|
310
|
+
sessionId: opts.sessionId,
|
|
311
|
+
toolCallsStarted,
|
|
312
|
+
durationMs: Date.now() - startedAt,
|
|
313
|
+
error: err.message,
|
|
314
|
+
});
|
|
315
|
+
yield {
|
|
316
|
+
type: SSEEventType.Error,
|
|
317
|
+
message: err.message,
|
|
318
|
+
timestamp: new Date().toISOString(),
|
|
319
|
+
};
|
|
320
|
+
return { kind: 'errored', error: err };
|
|
321
|
+
}
|
|
322
|
+
// Handler returned null → fall through, but only if no tool calls
|
|
323
|
+
// ran. If callTool was invoked, we've emitted SSE events to the
|
|
324
|
+
// user; falling through to the LLM at this point would double-fire
|
|
325
|
+
// the turn. Treat post-commit nulls as completions and warn.
|
|
326
|
+
if (handlerState.result === null) {
|
|
327
|
+
if (toolCallsStarted === 0) {
|
|
328
|
+
opts.logger.info('intent_fell_through', {
|
|
329
|
+
intentId: opts.match.intent.id,
|
|
330
|
+
sessionId: opts.sessionId,
|
|
331
|
+
durationMs: Date.now() - startedAt,
|
|
332
|
+
});
|
|
333
|
+
return { kind: 'fellThrough' };
|
|
334
|
+
}
|
|
335
|
+
opts.logger.warn('intent_returned_null_after_committing', {
|
|
336
|
+
intentId: opts.match.intent.id,
|
|
337
|
+
sessionId: opts.sessionId,
|
|
338
|
+
toolCallsStarted,
|
|
339
|
+
});
|
|
340
|
+
// Fall through to completion — same as a normal success.
|
|
341
|
+
}
|
|
342
|
+
// Compose the synthetic assistant message. Always emit a Done
|
|
343
|
+
// event so the SSE stream terminates the same way it does for an
|
|
344
|
+
// LLM-driven turn.
|
|
345
|
+
const assistantContent = [
|
|
346
|
+
...(textContent ? [{ type: 'text', text: textContent }] : []),
|
|
347
|
+
...messageParts,
|
|
348
|
+
];
|
|
349
|
+
const assistantMessage = {
|
|
350
|
+
role: 'assistant',
|
|
351
|
+
content: assistantContent.length > 0 ? assistantContent : '',
|
|
352
|
+
};
|
|
353
|
+
// Don't emit Done for completedContinue — the agent loop will emit
|
|
354
|
+
// its own Done after the LLM turn finishes. Emitting two Done
|
|
355
|
+
// events would tear down the SSE stream client-side prematurely.
|
|
356
|
+
const wantsContinue = handlerState.result !== null &&
|
|
357
|
+
handlerState.result !== undefined &&
|
|
358
|
+
'continue' in handlerState.result &&
|
|
359
|
+
handlerState.result.continue === true;
|
|
360
|
+
if (!wantsContinue) {
|
|
361
|
+
yield { type: SSEEventType.Done, timestamp: new Date().toISOString() };
|
|
362
|
+
}
|
|
363
|
+
opts.logger.info('intent_completed', {
|
|
364
|
+
intentId: opts.match.intent.id,
|
|
365
|
+
sessionId: opts.sessionId,
|
|
366
|
+
toolCount: toolCallsStarted,
|
|
367
|
+
hasText: textContent.length > 0,
|
|
368
|
+
durationMs: Date.now() - startedAt,
|
|
369
|
+
continueToLlm: wantsContinue,
|
|
370
|
+
});
|
|
371
|
+
return {
|
|
372
|
+
kind: wantsContinue ? 'completedContinue' : 'completed',
|
|
373
|
+
assistantMessage,
|
|
374
|
+
toolMessages,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
// ---------------------------------------------------------------------------
|
|
378
|
+
// Helpers
|
|
379
|
+
// ---------------------------------------------------------------------------
|
|
380
|
+
/**
|
|
381
|
+
* True when invoking this tool would normally route through CONFIRMING
|
|
382
|
+
* (tool-level flag or connection ACL gates). Intents can't honor that
|
|
383
|
+
* loop without re-implementing the agent state machine, so we refuse
|
|
384
|
+
* and fall through to the LLM.
|
|
385
|
+
*/
|
|
386
|
+
function toolGatesOnConfirmation(tool) {
|
|
387
|
+
if (tool.requiresConfirmation === true)
|
|
388
|
+
return true;
|
|
389
|
+
// Connection tools are ACL-gated; the gate decision lives in the
|
|
390
|
+
// PermissionChecker which we don't run from the intent path.
|
|
391
|
+
// Conservative default: refuse all connection-category tools.
|
|
392
|
+
if (tool.metadata?.category === 'connection')
|
|
393
|
+
return true;
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
/** Max size for tool result content sent via SSE (mirrors executing.ts). */
|
|
397
|
+
const MAX_SSE_RESULT_SIZE = 50_000;
|
|
398
|
+
function buildSuccessResultEvent(toolCallId, output, duration_ms) {
|
|
399
|
+
const stringified = typeof output === 'string' ? output : safeJsonStringify(output);
|
|
400
|
+
const result = stringified.length > MAX_SSE_RESULT_SIZE
|
|
401
|
+
? stringified.slice(0, MAX_SSE_RESULT_SIZE) + '\n[... truncated]'
|
|
402
|
+
: stringified;
|
|
403
|
+
return {
|
|
404
|
+
type: SSEEventType.ToolCallResult,
|
|
405
|
+
tool_id: toolCallId,
|
|
406
|
+
status: 'success',
|
|
407
|
+
duration_ms,
|
|
408
|
+
result,
|
|
409
|
+
timestamp: new Date().toISOString(),
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
function safeJsonStringify(value) {
|
|
413
|
+
try {
|
|
414
|
+
return JSON.stringify(value);
|
|
415
|
+
}
|
|
416
|
+
catch {
|
|
417
|
+
return String(value);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/intent/executor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAC,UAAU,EAAC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