@aexol/spectral 0.9.231 → 0.9.240
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 +47 -0
- package/dist/agent/index.d.ts +32 -5
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +209 -36
- package/dist/backend/generated-images.d.ts +1 -1
- package/dist/backend/generated-images.d.ts.map +1 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +18 -4
- package/dist/commands/desktop.d.ts +167 -0
- package/dist/commands/desktop.d.ts.map +1 -0
- package/dist/commands/desktop.js +540 -0
- package/dist/commands/serve.d.ts +9 -1
- package/dist/commands/serve.d.ts.map +1 -1
- package/dist/commands/serve.js +90 -2
- package/dist/commands/update.d.ts +85 -5
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +288 -58
- package/dist/extensions/desktop-control/macos.d.ts.map +1 -1
- package/dist/extensions/desktop-control/macos.js +2 -2
- package/dist/extensions/logic-trace.d.ts +1 -1
- package/dist/extensions/logic-trace.d.ts.map +1 -1
- package/dist/extensions/logic-trace.js +199 -70
- package/dist/extensions/video-generation/index.d.ts +3 -0
- package/dist/extensions/video-generation/index.d.ts.map +1 -0
- package/dist/extensions/video-generation/index.js +299 -0
- package/dist/generated/zeus/const.d.ts.map +1 -1
- package/dist/generated/zeus/const.js +30 -0
- package/dist/generated/zeus/index.d.ts +140 -0
- package/dist/generated/zeus/index.d.ts.map +1 -1
- package/dist/generated/zeus/index.js +5 -0
- package/dist/mcp/server-manager.d.ts.map +1 -1
- package/dist/mcp/server-manager.js +6 -0
- package/dist/memory/tools/receive-agent-observations.d.ts.map +1 -1
- package/dist/memory/tools/receive-agent-observations.js +12 -2
- package/dist/relay/dispatcher.d.ts +13 -1
- package/dist/relay/dispatcher.d.ts.map +1 -1
- package/dist/relay/dispatcher.js +41 -2
- package/dist/sdk/agent-core/agent-loop.js +13 -3
- package/dist/sdk/agent-core/agent.d.ts +11 -4
- package/dist/sdk/agent-core/agent.d.ts.map +1 -1
- package/dist/sdk/agent-core/agent.js +16 -4
- package/dist/sdk/agent-core/tool-call-registry.d.ts +75 -0
- package/dist/sdk/agent-core/tool-call-registry.d.ts.map +1 -0
- package/dist/sdk/agent-core/tool-call-registry.js +131 -0
- package/dist/sdk/agent-core/tool-execution.d.ts.map +1 -1
- package/dist/sdk/agent-core/tool-execution.js +103 -4
- package/dist/sdk/agent-core/types.d.ts +15 -4
- package/dist/sdk/agent-core/types.d.ts.map +1 -1
- package/dist/sdk/ai/index.d.ts +3 -0
- package/dist/sdk/ai/index.d.ts.map +1 -1
- package/dist/sdk/ai/index.js +3 -0
- package/dist/sdk/ai/providers/faux.d.ts.map +1 -1
- package/dist/sdk/ai/providers/faux.js +3 -0
- package/dist/sdk/ai/providers/leaked-tool-call-parser.d.ts +39 -6
- package/dist/sdk/ai/providers/leaked-tool-call-parser.d.ts.map +1 -1
- package/dist/sdk/ai/providers/leaked-tool-call-parser.js +159 -18
- package/dist/sdk/ai/providers/openai-completions.d.ts.map +1 -1
- package/dist/sdk/ai/providers/openai-completions.js +22 -8
- package/dist/sdk/ai/providers/openrouter-videos.d.ts +3 -0
- package/dist/sdk/ai/providers/openrouter-videos.d.ts.map +1 -0
- package/dist/sdk/ai/providers/openrouter-videos.js +412 -0
- package/dist/sdk/ai/providers/register-builtins.d.ts.map +1 -1
- package/dist/sdk/ai/providers/register-builtins.js +6 -0
- package/dist/sdk/ai/providers/simple-options.d.ts +1 -6
- package/dist/sdk/ai/providers/simple-options.d.ts.map +1 -1
- package/dist/sdk/ai/providers/simple-options.js +0 -22
- package/dist/sdk/ai/providers/transform-messages.d.ts.map +1 -1
- package/dist/sdk/ai/providers/transform-messages.js +52 -1
- package/dist/sdk/ai/types.d.ts +91 -10
- package/dist/sdk/ai/types.d.ts.map +1 -1
- package/dist/sdk/ai/video-models.d.ts +10 -0
- package/dist/sdk/ai/video-models.d.ts.map +1 -0
- package/dist/sdk/ai/video-models.generated.d.ts +440 -0
- package/dist/sdk/ai/video-models.generated.d.ts.map +1 -0
- package/dist/sdk/ai/video-models.generated.js +441 -0
- package/dist/sdk/ai/video-models.js +22 -0
- package/dist/sdk/ai/videos-api-registry.d.ts +14 -0
- package/dist/sdk/ai/videos-api-registry.d.ts.map +1 -0
- package/dist/sdk/ai/videos-api-registry.js +21 -0
- package/dist/sdk/ai/videos.d.ts +4 -0
- package/dist/sdk/ai/videos.d.ts.map +1 -0
- package/dist/sdk/ai/videos.js +13 -0
- package/dist/sdk/coding-agent/core/agent-session.d.ts +8 -0
- package/dist/sdk/coding-agent/core/agent-session.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/agent-session.js +11 -0
- package/dist/sdk/coding-agent/core/extensions/loader.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/extensions/loader.js +14 -0
- package/dist/sdk/coding-agent/core/extensions/native-extensions.d.ts +26 -0
- package/dist/sdk/coding-agent/core/extensions/native-extensions.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/extensions/native-extensions.js +23 -0
- package/dist/sdk/coding-agent/core/extensions/session-events.d.ts +2 -2
- package/dist/sdk/coding-agent/core/extensions/session-events.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/extensions/types.d.ts +12 -2
- package/dist/sdk/coding-agent/core/extensions/types.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/messages.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/messages.js +42 -2
- package/dist/sdk/coding-agent/core/resource-loader.d.ts +11 -0
- package/dist/sdk/coding-agent/core/resource-loader.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/resource-loader.js +23 -6
- package/dist/sdk/coding-agent/core/sdk.d.ts +24 -2
- package/dist/sdk/coding-agent/core/sdk.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/sdk.js +15 -3
- package/dist/sdk/coding-agent/core/settings-manager.d.ts +0 -8
- package/dist/sdk/coding-agent/core/settings-manager.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/settings-manager.js +3 -3
- package/dist/sdk/coding-agent/core/system-prompt.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/system-prompt.js +5 -0
- package/dist/sdk/coding-agent/index.d.ts +2 -2
- package/dist/sdk/coding-agent/index.d.ts.map +1 -1
- package/dist/sdk/coding-agent/index.js +1 -1
- package/dist/sdk-public.d.ts +96 -0
- package/dist/sdk-public.d.ts.map +1 -0
- package/dist/sdk-public.js +109 -0
- package/dist/server/agent-bridge/rehydrate.d.ts +2 -2
- package/dist/server/agent-bridge/rehydrate.d.ts.map +1 -1
- package/dist/server/agent-bridge/rehydrate.js +14 -0
- package/dist/server/agent-bridge/tps-metrics.d.ts +34 -0
- package/dist/server/agent-bridge/tps-metrics.d.ts.map +1 -1
- package/dist/server/agent-bridge/tps-metrics.js +22 -0
- package/dist/server/agent-bridge.d.ts +17 -2
- package/dist/server/agent-bridge.d.ts.map +1 -1
- package/dist/server/agent-bridge.js +108 -5
- package/dist/server/handlers/paths-list.d.ts +1 -1
- package/dist/server/handlers/paths-list.js +1 -1
- package/dist/server/inter-agent-broker.d.ts +12 -0
- package/dist/server/inter-agent-broker.d.ts.map +1 -1
- package/dist/server/inter-agent-broker.js +1 -0
- package/dist/server/preset-chain.d.ts +151 -0
- package/dist/server/preset-chain.d.ts.map +1 -0
- package/dist/server/preset-chain.js +250 -0
- package/dist/server/session-stream.d.ts +74 -1
- package/dist/server/session-stream.d.ts.map +1 -1
- package/dist/server/session-stream.js +238 -24
- package/dist/server/storage/rows.d.ts +2 -0
- package/dist/server/storage/rows.d.ts.map +1 -1
- package/dist/server/storage/schema.d.ts +2 -2
- package/dist/server/storage/schema.d.ts.map +1 -1
- package/dist/server/storage/schema.js +2 -1
- package/dist/server/storage.d.ts +7 -0
- package/dist/server/storage.d.ts.map +1 -1
- package/dist/server/storage.js +142 -9
- package/dist/server/wire.d.ts +84 -0
- package/dist/server/wire.d.ts.map +1 -1
- package/dist/utils/augment-path.d.ts +51 -0
- package/dist/utils/augment-path.d.ts.map +1 -0
- package/dist/utils/augment-path.js +234 -0
- package/dist/utils/open-browser.d.ts +55 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +163 -0
- package/dist/utils/serve-state.d.ts +264 -0
- package/dist/utils/serve-state.d.ts.map +1 -0
- package/dist/utils/serve-state.js +563 -0
- package/dist/utils/standalone.d.ts +14 -0
- package/dist/utils/standalone.d.ts.map +1 -0
- package/dist/utils/standalone.js +23 -0
- package/package.json +7 -3
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* working.
|
|
12
12
|
*/
|
|
13
13
|
import { validateToolArguments, } from "../ai/index.js";
|
|
14
|
+
import { USER_STOP_TOOL_RESULT_TEXT, } from "./tool-call-registry.js";
|
|
14
15
|
/**
|
|
15
16
|
* Execute tool calls from an assistant message.
|
|
16
17
|
*/
|
|
@@ -26,6 +27,7 @@ export async function executeToolCalls(currentContext, assistantMessage, config,
|
|
|
26
27
|
async function executeToolCallsSequential(currentContext, assistantMessage, toolCalls, config, signal, emit) {
|
|
27
28
|
const finalizedCalls = [];
|
|
28
29
|
const messages = [];
|
|
30
|
+
const startedToolCallIds = new Set();
|
|
29
31
|
for (const toolCall of toolCalls) {
|
|
30
32
|
await emit({
|
|
31
33
|
type: "tool_execution_start",
|
|
@@ -33,6 +35,7 @@ async function executeToolCallsSequential(currentContext, assistantMessage, tool
|
|
|
33
35
|
toolName: toolCall.name,
|
|
34
36
|
args: toolCall.arguments,
|
|
35
37
|
});
|
|
38
|
+
startedToolCallIds.add(toolCall.id);
|
|
36
39
|
const preparation = await prepareToolCall(currentContext, assistantMessage, toolCall, config, signal);
|
|
37
40
|
let finalized;
|
|
38
41
|
if (preparation.kind === "immediate") {
|
|
@@ -43,7 +46,7 @@ async function executeToolCallsSequential(currentContext, assistantMessage, tool
|
|
|
43
46
|
};
|
|
44
47
|
}
|
|
45
48
|
else {
|
|
46
|
-
const executed = await executePreparedToolCall(preparation, signal, emit);
|
|
49
|
+
const executed = await executePreparedToolCall(preparation, signal, emit, config.toolCallRegistry);
|
|
47
50
|
finalized = await finalizeExecutedToolCall(currentContext, assistantMessage, preparation, executed, config, signal);
|
|
48
51
|
}
|
|
49
52
|
await emitToolExecutionEnd(finalized, emit);
|
|
@@ -55,6 +58,17 @@ async function executeToolCallsSequential(currentContext, assistantMessage, tool
|
|
|
55
58
|
break;
|
|
56
59
|
}
|
|
57
60
|
}
|
|
61
|
+
// Protocol repair: on a turn abort, tool calls skipped by the loop above
|
|
62
|
+
// never executed and would otherwise remain orphaned tool_calls (no
|
|
63
|
+
// matching tool_result in the transcript). Synthesize an error tool result
|
|
64
|
+
// for each so the next LLM request stays well-formed.
|
|
65
|
+
const synthesized = await synthesizeAbortedToolResults(toolCalls, finalizedCalls, startedToolCallIds, signal, emit);
|
|
66
|
+
for (const finalized of synthesized) {
|
|
67
|
+
const toolResultMessage = createToolResultMessage(finalized);
|
|
68
|
+
await emitToolResultMessage(toolResultMessage, emit);
|
|
69
|
+
finalizedCalls.push(finalized);
|
|
70
|
+
messages.push(toolResultMessage);
|
|
71
|
+
}
|
|
58
72
|
return {
|
|
59
73
|
messages,
|
|
60
74
|
terminate: shouldTerminateToolBatch(finalizedCalls),
|
|
@@ -62,6 +76,7 @@ async function executeToolCallsSequential(currentContext, assistantMessage, tool
|
|
|
62
76
|
}
|
|
63
77
|
async function executeToolCallsParallel(currentContext, assistantMessage, toolCalls, config, signal, emit) {
|
|
64
78
|
const finalizedCalls = [];
|
|
79
|
+
const startedToolCallIds = new Set();
|
|
65
80
|
for (const toolCall of toolCalls) {
|
|
66
81
|
await emit({
|
|
67
82
|
type: "tool_execution_start",
|
|
@@ -69,6 +84,7 @@ async function executeToolCallsParallel(currentContext, assistantMessage, toolCa
|
|
|
69
84
|
toolName: toolCall.name,
|
|
70
85
|
args: toolCall.arguments,
|
|
71
86
|
});
|
|
87
|
+
startedToolCallIds.add(toolCall.id);
|
|
72
88
|
const preparation = await prepareToolCall(currentContext, assistantMessage, toolCall, config, signal);
|
|
73
89
|
if (preparation.kind === "immediate") {
|
|
74
90
|
const finalized = {
|
|
@@ -84,7 +100,7 @@ async function executeToolCallsParallel(currentContext, assistantMessage, toolCa
|
|
|
84
100
|
continue;
|
|
85
101
|
}
|
|
86
102
|
finalizedCalls.push(async () => {
|
|
87
|
-
const executed = await executePreparedToolCall(preparation, signal, emit);
|
|
103
|
+
const executed = await executePreparedToolCall(preparation, signal, emit, config.toolCallRegistry);
|
|
88
104
|
const finalized = await finalizeExecutedToolCall(currentContext, assistantMessage, preparation, executed, config, signal);
|
|
89
105
|
await emitToolExecutionEnd(finalized, emit);
|
|
90
106
|
return finalized;
|
|
@@ -100,6 +116,17 @@ async function executeToolCallsParallel(currentContext, assistantMessage, toolCa
|
|
|
100
116
|
await emitToolResultMessage(toolResultMessage, emit);
|
|
101
117
|
messages.push(toolResultMessage);
|
|
102
118
|
}
|
|
119
|
+
// Protocol repair (same as the sequential path): on a turn abort, tool
|
|
120
|
+
// calls the preflight loop never pushed would remain orphaned tool_calls.
|
|
121
|
+
const synthesized = await synthesizeAbortedToolResults(toolCalls, orderedFinalizedCalls, startedToolCallIds, signal, emit);
|
|
122
|
+
for (const finalized of synthesized) {
|
|
123
|
+
const toolResultMessage = createToolResultMessage(finalized);
|
|
124
|
+
await emitToolResultMessage(toolResultMessage, emit);
|
|
125
|
+
messages.push(toolResultMessage);
|
|
126
|
+
}
|
|
127
|
+
if (synthesized.length > 0) {
|
|
128
|
+
orderedFinalizedCalls.push(...synthesized);
|
|
129
|
+
}
|
|
103
130
|
return {
|
|
104
131
|
messages,
|
|
105
132
|
terminate: shouldTerminateToolBatch(orderedFinalizedCalls),
|
|
@@ -192,10 +219,17 @@ async function prepareToolCall(currentContext, assistantMessage, toolCall, confi
|
|
|
192
219
|
};
|
|
193
220
|
}
|
|
194
221
|
}
|
|
195
|
-
async function executePreparedToolCall(prepared, signal, emit) {
|
|
222
|
+
async function executePreparedToolCall(prepared, signal, emit, registry) {
|
|
196
223
|
const updateEvents = [];
|
|
224
|
+
// Per-call kill handle: registers this execution so a user-initiated
|
|
225
|
+
// `stopToolCall` can abort ONLY this call. The returned controller's signal
|
|
226
|
+
// also aborts when the run-level signal aborts (turn cancel propagates).
|
|
227
|
+
// When no registry is configured, tools receive the run signal directly
|
|
228
|
+
// (existing behavior).
|
|
229
|
+
const handle = registry?.register(prepared.toolCall.id, prepared.toolCall.name, signal);
|
|
230
|
+
const callSignal = handle ? handle.controller.signal : signal;
|
|
197
231
|
try {
|
|
198
|
-
const result = await prepared.tool.execute(prepared.toolCall.id, prepared.args,
|
|
232
|
+
const result = await prepared.tool.execute(prepared.toolCall.id, prepared.args, callSignal, (partialResult) => {
|
|
199
233
|
updateEvents.push(Promise.resolve(emit({
|
|
200
234
|
type: "tool_execution_update",
|
|
201
235
|
toolCallId: prepared.toolCall.id,
|
|
@@ -209,15 +243,29 @@ async function executePreparedToolCall(prepared, signal, emit) {
|
|
|
209
243
|
}
|
|
210
244
|
catch (error) {
|
|
211
245
|
await Promise.all(updateEvents);
|
|
246
|
+
// User-initiated per-call stop: replace the raw "aborted"/transport error
|
|
247
|
+
// text with the exactly-matching synthesized user-stop result so the agent
|
|
248
|
+
// loop CONTINUES the turn with a well-formed tool result.
|
|
249
|
+
if (handle?.userStopRequested) {
|
|
250
|
+
return {
|
|
251
|
+
result: createUserStopToolResult(handle.userStopReason),
|
|
252
|
+
isError: true,
|
|
253
|
+
stoppedByUser: true,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
212
256
|
return {
|
|
213
257
|
result: createErrorToolResult(error instanceof Error ? error.message : String(error)),
|
|
214
258
|
isError: true,
|
|
215
259
|
};
|
|
216
260
|
}
|
|
261
|
+
finally {
|
|
262
|
+
registry?.settle(prepared.toolCall.id);
|
|
263
|
+
}
|
|
217
264
|
}
|
|
218
265
|
async function finalizeExecutedToolCall(currentContext, assistantMessage, prepared, executed, config, signal) {
|
|
219
266
|
let result = executed.result;
|
|
220
267
|
let isError = executed.isError;
|
|
268
|
+
let stoppedByUser = executed.stoppedByUser;
|
|
221
269
|
if (config.afterToolCall) {
|
|
222
270
|
try {
|
|
223
271
|
const afterResult = await config.afterToolCall({
|
|
@@ -235,6 +283,12 @@ async function finalizeExecutedToolCall(currentContext, assistantMessage, prepar
|
|
|
235
283
|
terminate: afterResult.terminate ?? result.terminate,
|
|
236
284
|
};
|
|
237
285
|
isError = afterResult.isError ?? isError;
|
|
286
|
+
// An afterToolCall override replaces the executed result; the
|
|
287
|
+
// user-stop marker only survives when the override is not replacing
|
|
288
|
+
// the error with a different outcome.
|
|
289
|
+
if (afterResult.isError === false) {
|
|
290
|
+
stoppedByUser = undefined;
|
|
291
|
+
}
|
|
238
292
|
}
|
|
239
293
|
}
|
|
240
294
|
catch (error) {
|
|
@@ -246,6 +300,7 @@ async function finalizeExecutedToolCall(currentContext, assistantMessage, prepar
|
|
|
246
300
|
toolCall: prepared.toolCall,
|
|
247
301
|
result,
|
|
248
302
|
isError,
|
|
303
|
+
stoppedByUser,
|
|
249
304
|
};
|
|
250
305
|
}
|
|
251
306
|
function createErrorToolResult(message) {
|
|
@@ -254,6 +309,48 @@ function createErrorToolResult(message) {
|
|
|
254
309
|
details: {},
|
|
255
310
|
};
|
|
256
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* Synthesized tool result for a user-initiated per-call stop. Content is the
|
|
314
|
+
* exactly-matching contract string; details carry the marker for the wire.
|
|
315
|
+
*/
|
|
316
|
+
function createUserStopToolResult(reason) {
|
|
317
|
+
return {
|
|
318
|
+
content: [{ type: "text", text: USER_STOP_TOOL_RESULT_TEXT }],
|
|
319
|
+
details: { stoppedByUser: true, ...(reason ? { reason } : {}) },
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
/** Synthesized tool result for a tool call the turn abort skipped entirely. */
|
|
323
|
+
function createAbortedBeforeStartToolResult() {
|
|
324
|
+
return createErrorToolResult("Tool call aborted before start");
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Protocol repair: synthesize tool results for tool calls that never produced
|
|
328
|
+
* one because the run-level abort skipped them. Without this, a turn abort
|
|
329
|
+
* leaves orphaned tool_calls in the transcript (assistant toolCall content
|
|
330
|
+
* blocks with no matching tool_result), which breaks the next LLM request.
|
|
331
|
+
* Calls that already emitted `tool_execution_start` also get a matching
|
|
332
|
+
* `tool_execution_end` so the event stream stays paired.
|
|
333
|
+
*/
|
|
334
|
+
async function synthesizeAbortedToolResults(toolCalls, finalizedCalls, startedToolCallIds, signal, emit) {
|
|
335
|
+
if (!signal?.aborted)
|
|
336
|
+
return [];
|
|
337
|
+
const finalizedIds = new Set(finalizedCalls.map((f) => f.toolCall.id));
|
|
338
|
+
const synthesized = [];
|
|
339
|
+
for (const toolCall of toolCalls) {
|
|
340
|
+
if (finalizedIds.has(toolCall.id))
|
|
341
|
+
continue;
|
|
342
|
+
const finalized = {
|
|
343
|
+
toolCall,
|
|
344
|
+
result: createAbortedBeforeStartToolResult(),
|
|
345
|
+
isError: true,
|
|
346
|
+
};
|
|
347
|
+
if (startedToolCallIds.has(toolCall.id)) {
|
|
348
|
+
await emitToolExecutionEnd(finalized, emit);
|
|
349
|
+
}
|
|
350
|
+
synthesized.push(finalized);
|
|
351
|
+
}
|
|
352
|
+
return synthesized;
|
|
353
|
+
}
|
|
257
354
|
/**
|
|
258
355
|
* Detects whether a tool call is missing any required parameter, indicating the
|
|
259
356
|
* provider truncated the response before the tool arguments were fully emitted.
|
|
@@ -281,6 +378,7 @@ async function emitToolExecutionEnd(finalized, emit) {
|
|
|
281
378
|
toolName: finalized.toolCall.name,
|
|
282
379
|
result: finalized.result,
|
|
283
380
|
isError: finalized.isError,
|
|
381
|
+
...(finalized.stoppedByUser ? { stoppedByUser: true } : {}),
|
|
284
382
|
});
|
|
285
383
|
}
|
|
286
384
|
function createToolResultMessage(finalized) {
|
|
@@ -291,6 +389,7 @@ function createToolResultMessage(finalized) {
|
|
|
291
389
|
content: finalized.result.content,
|
|
292
390
|
details: finalized.result.details,
|
|
293
391
|
isError: finalized.isError,
|
|
392
|
+
...(finalized.stoppedByUser ? { stoppedByUser: true } : {}),
|
|
294
393
|
timestamp: Date.now(),
|
|
295
394
|
};
|
|
296
395
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { AssistantMessage, AssistantMessageEvent, ImageContent, Message, Model, SimpleStreamOptions, streamSimple, TextContent, Tool, ToolResultMessage } from "../ai/index.js";
|
|
1
|
+
import type { AssistantMessage, AssistantMessageEvent, ImageContent, Message, Model, SimpleStreamOptions, streamSimple, TextContent, Tool, ToolResultMessage, VideoContent } from "../ai/index.js";
|
|
2
2
|
import type { Static, TSchema } from "typebox";
|
|
3
|
+
import type { ToolCallRegistry } from "./tool-call-registry.js";
|
|
3
4
|
/**
|
|
4
5
|
* Stream function used by the agent loop.
|
|
5
6
|
*
|
|
@@ -53,7 +54,7 @@ export interface BeforeToolCallResult {
|
|
|
53
54
|
* There is no deep merge for `content` or `details`.
|
|
54
55
|
*/
|
|
55
56
|
export interface AfterToolCallResult {
|
|
56
|
-
content?: (TextContent | ImageContent)[];
|
|
57
|
+
content?: (TextContent | ImageContent | VideoContent)[];
|
|
57
58
|
details?: unknown;
|
|
58
59
|
isError?: boolean;
|
|
59
60
|
/**
|
|
@@ -240,6 +241,15 @@ export interface AgentLoopConfig extends SimpleStreamOptions {
|
|
|
240
241
|
* The hook receives the agent abort signal and is responsible for honoring it.
|
|
241
242
|
*/
|
|
242
243
|
afterToolCall?: (context: AfterToolCallContext, signal?: AbortSignal) => Promise<AfterToolCallResult | undefined>;
|
|
244
|
+
/**
|
|
245
|
+
* Killable registry of in-flight tool executions for this run.
|
|
246
|
+
*
|
|
247
|
+
* Enables user-initiated per-call stops (`Agent.stopToolCall`): the executor
|
|
248
|
+
* registers each tool call here and passes the per-call abort signal to
|
|
249
|
+
* `tool.execute()`. Optional — when omitted, tools receive the run-level
|
|
250
|
+
* signal directly and per-call stops are unsupported.
|
|
251
|
+
*/
|
|
252
|
+
toolCallRegistry?: ToolCallRegistry;
|
|
243
253
|
}
|
|
244
254
|
/**
|
|
245
255
|
* Thinking/reasoning level for models that support it.
|
|
@@ -303,8 +313,8 @@ export interface AgentState {
|
|
|
303
313
|
}
|
|
304
314
|
/** Final or partial result produced by a tool. */
|
|
305
315
|
export interface AgentToolResult<T> {
|
|
306
|
-
/** Text or
|
|
307
|
-
content: (TextContent | ImageContent)[];
|
|
316
|
+
/** Text, image, or video content returned to the model/UI. */
|
|
317
|
+
content: (TextContent | ImageContent | VideoContent)[];
|
|
308
318
|
/** Arbitrary structured details for logs or UI rendering. */
|
|
309
319
|
details: T;
|
|
310
320
|
/**
|
|
@@ -390,5 +400,6 @@ export type AgentEvent = {
|
|
|
390
400
|
toolName: string;
|
|
391
401
|
result: any;
|
|
392
402
|
isError: boolean;
|
|
403
|
+
stoppedByUser?: boolean;
|
|
393
404
|
};
|
|
394
405
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/sdk/agent-core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,OAAO,EACP,KAAK,EACL,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,iBAAiB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/sdk/agent-core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,OAAO,EACP,KAAK,EACL,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,iBAAiB,EACjB,YAAY,EACZ,MAAM,gBAAgB,CAAC;AACxB,OAA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AAE,YAAY,CAAC;IAAC,qBAAqB,EAAE,qBAAqB,CAAA;CAAE,GAC/F;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,GAE9C;IAAE,IAAI,EAAE,sBAAsB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,GACjF;IAAE,IAAI,EAAE,uBAAuB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC;IAAC,aAAa,EAAE,GAAG,CAAA;CAAE,GACtG;IAAE,IAAI,EAAE,oBAAoB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC"}
|
package/dist/sdk/ai/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from "./providers/register-builtins.js";
|
|
|
11
11
|
export * from "./session-resources.js";
|
|
12
12
|
export * from "./stream.js";
|
|
13
13
|
export * from "./types.js";
|
|
14
|
+
export * from "./video-models.js";
|
|
14
15
|
export * from "./utils/diagnostics.js";
|
|
15
16
|
export * from "./utils/event-stream.js";
|
|
16
17
|
export * from "./utils/json-parse.js";
|
|
@@ -20,4 +21,6 @@ export * from "./utils/rate-limit-retry.js";
|
|
|
20
21
|
export * from "./utils/transient-error.js";
|
|
21
22
|
export * from "./utils/typebox-helpers.js";
|
|
22
23
|
export * from "./utils/validation.js";
|
|
24
|
+
export * from "./videos.js";
|
|
25
|
+
export * from "./videos-api-registry.js";
|
|
23
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sdk/ai/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,YAAY,EACX,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,GACjB,MAAM,wBAAwB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sdk/ai/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,YAAY,EACX,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,GACjB,MAAM,wBAAwB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC"}
|
package/dist/sdk/ai/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export * from "./providers/register-builtins.js";
|
|
|
10
10
|
export * from "./session-resources.js";
|
|
11
11
|
export * from "./stream.js";
|
|
12
12
|
export * from "./types.js";
|
|
13
|
+
export * from "./video-models.js";
|
|
13
14
|
export * from "./utils/diagnostics.js";
|
|
14
15
|
export * from "./utils/event-stream.js";
|
|
15
16
|
export * from "./utils/json-parse.js";
|
|
@@ -18,3 +19,5 @@ export * from "./utils/rate-limit-retry.js";
|
|
|
18
19
|
export * from "./utils/transient-error.js";
|
|
19
20
|
export * from "./utils/typebox-helpers.js";
|
|
20
21
|
export * from "./utils/validation.js";
|
|
22
|
+
export * from "./videos.js";
|
|
23
|
+
export * from "./videos-api-registry.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faux.d.ts","sourceRoot":"","sources":["../../../../src/sdk/ai/providers/faux.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,gBAAgB,EAEhB,OAAO,EAGP,KAAK,EAGL,aAAa,EACb,WAAW,EACX,eAAe,EACf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CAAC;IACtC,UAAU,EAAE,MAAM,IAAI,CAAC;CACvB;AA4QD,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,2BAAgC,GAAG,wBAAwB,CAqHxG"}
|
|
@@ -64,6 +64,9 @@ function contentToText(content) {
|
|
|
64
64
|
if (block.type === "text") {
|
|
65
65
|
return block.text;
|
|
66
66
|
}
|
|
67
|
+
if (block.type === "video") {
|
|
68
|
+
return `[video:${block.mimeType}:${block.url ?? `${block.data?.length ?? 0} bytes base64`}]`;
|
|
69
|
+
}
|
|
67
70
|
return `[image:${block.mimeType}:${block.data?.length ?? 0}${block.url ? `:${block.url}` : ""}]`;
|
|
68
71
|
})
|
|
69
72
|
.join("\n");
|
|
@@ -15,10 +15,22 @@
|
|
|
15
15
|
* where the wrapper tag is `function_calls` (optionally with an `antml:`
|
|
16
16
|
* namespace prefix) and invoke/parameter tags follow the same convention.
|
|
17
17
|
*
|
|
18
|
+
* Models also emit the same markup WITHOUT the wrapper — orphan
|
|
19
|
+
* `<invoke name="x">…</invoke>` blocks straight in prose (pi-style) — or
|
|
20
|
+
* truncated blocks that never receive their closing tags before the stream
|
|
21
|
+
* ends. Both shapes are recovered: orphan blocks during streaming, truncated
|
|
22
|
+
* parameter-complete tails at end of stream (see salvageLeakedToolCallTail).
|
|
23
|
+
*
|
|
18
24
|
* Everything here is pure string logic — no provider imports — so the tests
|
|
19
25
|
* cover it without any streaming harness.
|
|
20
26
|
*/
|
|
21
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Floor for how much tail a caller should expect a partial opener to occupy
|
|
29
|
+
* (the longest opener tag is the antml-prefixed one, 22 chars, plus margin).
|
|
30
|
+
* Partial detection anchors at the last `<` of the buffered text, so an
|
|
31
|
+
* invoke opener whose name attribute is still open can hold back more than
|
|
32
|
+
* this when the tool name is long — it is a floor, not a cap.
|
|
33
|
+
*/
|
|
22
34
|
export declare const LEAK_TAIL_LENGTH = 32;
|
|
23
35
|
export type LeakedToolCall = {
|
|
24
36
|
name: string;
|
|
@@ -26,10 +38,14 @@ export type LeakedToolCall = {
|
|
|
26
38
|
};
|
|
27
39
|
export type LeakOpenerMatch = "full" | "partial" | "none";
|
|
28
40
|
/**
|
|
29
|
-
* Locate a leaked
|
|
41
|
+
* Locate a leaked opener tag in `text` — either the wrapper
|
|
42
|
+
* (`<function_calls>`) or an orphan invoke (`<invoke name="x">`, pi-style
|
|
43
|
+
* markup emitted without the wrapper).
|
|
30
44
|
* - "full": a complete opener tag exists; `index` points at its `<`.
|
|
31
|
-
* - "partial": the text ENDS
|
|
32
|
-
*
|
|
45
|
+
* - "partial": the text ENDS mid-opener (an opener split across streaming
|
|
46
|
+
* deltas); `index` points at the start of that tail. A partial always
|
|
47
|
+
* starts at the last `<` — the tail matcher admits no further `<` — so the
|
|
48
|
+
* scan is a single anchored match there instead of a prefix enumeration.
|
|
33
49
|
* - "none": no opener, complete or partial.
|
|
34
50
|
*/
|
|
35
51
|
export declare function findLeakedToolCallOpener(text: string): {
|
|
@@ -45,8 +61,12 @@ export declare function findLeakedToolCallOpener(text: string): {
|
|
|
45
61
|
* before + after). `consumed` is the raw block text (opener→closer
|
|
46
62
|
* inclusive) so callers can fall back to emitting it as text when the
|
|
47
63
|
* parsed tool names turn out to be unknown.
|
|
48
|
-
*
|
|
49
|
-
*
|
|
64
|
+
* When no wrapper opener exists at all, orphan invoke blocks (pi-style, no
|
|
65
|
+
* wrapper) are parsed instead — but only when EVERY invoke opener has a
|
|
66
|
+
* matching closer; otherwise `complete: false` and `remaining`/`consumed`
|
|
67
|
+
* echo the input so nothing is cut prematurely. (A wrapper opener blocks the
|
|
68
|
+
* orphan path: wrapper-less invokes around a wrapper block are picked up
|
|
69
|
+
* later from `remaining`, once the wrapper block itself is consumed.)
|
|
50
70
|
*/
|
|
51
71
|
export declare function extractLeakedToolCalls(text: string): {
|
|
52
72
|
calls: LeakedToolCall[];
|
|
@@ -54,6 +74,19 @@ export declare function extractLeakedToolCalls(text: string): {
|
|
|
54
74
|
remaining: string;
|
|
55
75
|
consumed: string;
|
|
56
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* End-of-stream recovery for a leaked buffer that never received its closing
|
|
79
|
+
* tags (stream cut off, or a model that forgets `</invoke>` / the wrapper
|
|
80
|
+
* closer). Parses invoke blocks tolerantly: a missing closer is fine as long
|
|
81
|
+
* as every `<parameter>` value is fully closed. A truncated parameter value
|
|
82
|
+
* means the model was cut mid-argument — guessing at the value is unsafe, so
|
|
83
|
+
* the whole tail degrades to plain text (null).
|
|
84
|
+
*
|
|
85
|
+
* Returns the parsed calls (leading wrapper skeleton dropped), or null when
|
|
86
|
+
* nothing salvageable remains. Callers still validate tool names before
|
|
87
|
+
* emitting synthetic tool calls.
|
|
88
|
+
*/
|
|
89
|
+
export declare function salvageLeakedToolCallTail(text: string): LeakedToolCall[] | null;
|
|
57
90
|
/**
|
|
58
91
|
* Coerce a leaked parameter string into a JSON value when it clearly parses
|
|
59
92
|
* as one — native `tool_calls` arguments are real JSON, so a leaked
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leaked-tool-call-parser.d.ts","sourceRoot":"","sources":["../../../../src/sdk/ai/providers/leaked-tool-call-parser.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"leaked-tool-call-parser.d.ts","sourceRoot":"","sources":["../../../../src/sdk/ai/providers/leaked-tool-call-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAoBH;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,MAAM,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;AAgC1D;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACvC,IAAI,EAAE,MAAM,GACV;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAuB3C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG;IACrD,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CACjB,CAoCA;AAoDD;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,MAAM,GACV,cAAc,EAAE,GAAG,IAAI,CAuCzB;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAW/D"}
|