@openrouter/agent 0.9.0 → 0.10.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 +249 -2
- package/THIRD_PARTY_NOTICES.md +25 -0
- package/esm/index.d.ts +3 -3
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/inner-loop/call-model.d.ts.map +1 -1
- package/esm/inner-loop/call-model.js +25 -7
- package/esm/inner-loop/call-model.js.map +1 -1
- package/esm/lib/agent-tool.d.ts +1 -1
- package/esm/lib/agent-tool.d.ts.map +1 -1
- package/esm/lib/agent-tool.js.map +1 -1
- package/esm/lib/async-params.d.ts +14 -0
- package/esm/lib/async-params.d.ts.map +1 -1
- package/esm/lib/async-params.js +25 -1
- package/esm/lib/async-params.js.map +1 -1
- package/esm/lib/model-result.d.ts +3 -3
- package/esm/lib/model-result.d.ts.map +1 -1
- package/esm/lib/model-result.js +45 -21
- package/esm/lib/model-result.js.map +1 -1
- package/esm/lib/next-turn-params.d.ts.map +1 -1
- package/esm/lib/next-turn-params.js +3 -1
- package/esm/lib/next-turn-params.js.map +1 -1
- package/esm/lib/next-turn-params.test.js +72 -0
- package/esm/lib/next-turn-params.test.js.map +1 -1
- package/esm/lib/stream-transformers.d.ts +1 -1
- package/esm/lib/stream-transformers.d.ts.map +1 -1
- package/esm/lib/stream-transformers.js.map +1 -1
- package/esm/lib/tool-set-types.d.ts +298 -0
- package/esm/lib/tool-set-types.d.ts.map +1 -0
- package/esm/lib/tool-set-types.js +2 -0
- package/esm/lib/tool-set-types.js.map +1 -0
- package/esm/lib/tool-set.d.ts +157 -0
- package/esm/lib/tool-set.d.ts.map +1 -0
- package/esm/lib/tool-set.js +473 -0
- package/esm/lib/tool-set.js.map +1 -0
- package/esm/lib/tool-types.d.ts +198 -28
- package/esm/lib/tool-types.d.ts.map +1 -1
- package/esm/lib/tool-types.js.map +1 -1
- package/esm/lib/tool.d.ts +47 -21
- package/esm/lib/tool.d.ts.map +1 -1
- package/esm/lib/tool.js +13 -3
- package/esm/lib/tool.js.map +1 -1
- package/esm/mcp/auth/auth-resolver.d.ts +14 -0
- package/esm/mcp/auth/auth-resolver.d.ts.map +1 -0
- package/esm/mcp/auth/auth-resolver.js +27 -0
- package/esm/mcp/auth/auth-resolver.js.map +1 -0
- package/esm/mcp/auth/auth-types.d.ts +33 -0
- package/esm/mcp/auth/auth-types.d.ts.map +1 -0
- package/esm/mcp/auth/auth-types.js +4 -0
- package/esm/mcp/auth/auth-types.js.map +1 -0
- package/esm/mcp/build-tools.d.ts +29 -0
- package/esm/mcp/build-tools.d.ts.map +1 -0
- package/esm/mcp/build-tools.js +80 -0
- package/esm/mcp/build-tools.js.map +1 -0
- package/esm/mcp/cache/cache-store.d.ts +24 -0
- package/esm/mcp/cache/cache-store.d.ts.map +1 -0
- package/esm/mcp/cache/cache-store.js +20 -0
- package/esm/mcp/cache/cache-store.js.map +1 -0
- package/esm/mcp/cache/cache-types.d.ts +71 -0
- package/esm/mcp/cache/cache-types.d.ts.map +1 -0
- package/esm/mcp/cache/cache-types.js +49 -0
- package/esm/mcp/cache/cache-types.js.map +1 -0
- package/esm/mcp/cache/serialize.d.ts +25 -0
- package/esm/mcp/cache/serialize.d.ts.map +1 -0
- package/esm/mcp/cache/serialize.js +96 -0
- package/esm/mcp/cache/serialize.js.map +1 -0
- package/esm/mcp/close-quietly.d.ts +24 -0
- package/esm/mcp/close-quietly.d.ts.map +1 -0
- package/esm/mcp/close-quietly.js +30 -0
- package/esm/mcp/close-quietly.js.map +1 -0
- package/esm/mcp/create-mcp-tools.d.ts +13 -0
- package/esm/mcp/create-mcp-tools.d.ts.map +1 -0
- package/esm/mcp/create-mcp-tools.js +87 -0
- package/esm/mcp/create-mcp-tools.js.map +1 -0
- package/esm/mcp/elicitation.d.ts +11 -0
- package/esm/mcp/elicitation.d.ts.map +1 -0
- package/esm/mcp/elicitation.js +51 -0
- package/esm/mcp/elicitation.js.map +1 -0
- package/esm/mcp/errors.d.ts +91 -0
- package/esm/mcp/errors.d.ts.map +1 -0
- package/esm/mcp/errors.js +91 -0
- package/esm/mcp/errors.js.map +1 -0
- package/esm/mcp/handle.d.ts +66 -0
- package/esm/mcp/handle.d.ts.map +1 -0
- package/esm/mcp/handle.js +323 -0
- package/esm/mcp/handle.js.map +1 -0
- package/esm/mcp/index.d.ts +13 -0
- package/esm/mcp/index.d.ts.map +1 -0
- package/esm/mcp/index.js +11 -0
- package/esm/mcp/index.js.map +1 -0
- package/esm/mcp/mcp-connection.d.ts +150 -0
- package/esm/mcp/mcp-connection.d.ts.map +1 -0
- package/esm/mcp/mcp-connection.js +478 -0
- package/esm/mcp/mcp-connection.js.map +1 -0
- package/esm/mcp/mcp-sdk.d.ts +10 -0
- package/esm/mcp/mcp-sdk.d.ts.map +1 -0
- package/esm/mcp/mcp-sdk.js +37 -0
- package/esm/mcp/mcp-sdk.js.map +1 -0
- package/esm/mcp/rehydrate.d.ts +76 -0
- package/esm/mcp/rehydrate.d.ts.map +1 -0
- package/esm/mcp/rehydrate.js +505 -0
- package/esm/mcp/rehydrate.js.map +1 -0
- package/esm/mcp/resource-tools.d.ts +17 -0
- package/esm/mcp/resource-tools.d.ts.map +1 -0
- package/esm/mcp/resource-tools.js +155 -0
- package/esm/mcp/resource-tools.js.map +1 -0
- package/esm/mcp/result-mapper.d.ts +19 -0
- package/esm/mcp/result-mapper.d.ts.map +1 -0
- package/esm/mcp/result-mapper.js +40 -0
- package/esm/mcp/result-mapper.js.map +1 -0
- package/esm/mcp/schema/json-schema-guards.d.ts +14 -0
- package/esm/mcp/schema/json-schema-guards.d.ts.map +1 -0
- package/esm/mcp/schema/json-schema-guards.js +19 -0
- package/esm/mcp/schema/json-schema-guards.js.map +1 -0
- package/esm/mcp/schema/json-schema-to-zod.d.ts +20 -0
- package/esm/mcp/schema/json-schema-to-zod.d.ts.map +1 -0
- package/esm/mcp/schema/json-schema-to-zod.js +72 -0
- package/esm/mcp/schema/json-schema-to-zod.js.map +1 -0
- package/esm/mcp/tool-wrapper.d.ts +41 -0
- package/esm/mcp/tool-wrapper.d.ts.map +1 -0
- package/esm/mcp/tool-wrapper.js +131 -0
- package/esm/mcp/tool-wrapper.js.map +1 -0
- package/esm/mcp/transport-types.d.ts +45 -0
- package/esm/mcp/transport-types.d.ts.map +1 -0
- package/esm/mcp/transport-types.js +2 -0
- package/esm/mcp/transport-types.js.map +1 -0
- package/esm/mcp/types.d.ts +119 -0
- package/esm/mcp/types.d.ts.map +1 -0
- package/esm/mcp/types.js +2 -0
- package/esm/mcp/types.js.map +1 -0
- package/esm/mcp/version.d.ts +3 -0
- package/esm/mcp/version.d.ts.map +1 -0
- package/esm/mcp/version.js +5 -0
- package/esm/mcp/version.js.map +1 -0
- package/package.json +44 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-params.js","sourceRoot":"","sources":["../../src/lib/async-params.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,SAAS,mBAAmB,CAC1B,KAAc;IAEd,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,SAAS,oBAAoB,CAC3B,OAKC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAExC,OAAO,GAAoC,CAAC;AAC9C,CAAC;
|
|
1
|
+
{"version":3,"file":"async-params.js","sourceRoot":"","sources":["../../src/lib/async-params.ts"],"names":[],"mappings":"AAmBA,mEAAmE;AACnE,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;AAEnF,MAAM,+BAA+B,GAAwB,IAAI,GAAG,CAAC;IACnE,SAAS;IACT,UAAU;IACV,cAAc;IACd,WAAW;CACZ,CAAC,CAAC;AAEH,4EAA4E;AAC5E,MAAM,UAAU,4BAA4B,CAAC,KAAmC;IAC9E,IAAI,KAAK,CAAC,iBAAiB,C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AAU,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -8,7 +8,7 @@ import type { HooksManager } from './hooks-manager.js';
|
|
|
8
8
|
import type { SessionUsageTotals } from './hooks-types.js';
|
|
9
9
|
import type { StreamableOutputItem } from './stream-transformers.js';
|
|
10
10
|
import type { ContextInput } from './tool-context.js';
|
|
11
|
-
import type { ConversationState,
|
|
11
|
+
import type { ConversationState, CorrelatedResponseStreamEvent, CorrelatedToolStreamEvent, ParsedToolCall, PendingAsyncTool, StateAccessor, StopWhen, Tool, ToolContextMapWithShared, TurnContext } from './tool-types.js';
|
|
12
12
|
/**
|
|
13
13
|
* Default directive appended as a final user message on the forced final
|
|
14
14
|
* turn (`allowFinalResponse` defaulting to on, or explicitly `true`).
|
|
@@ -1089,7 +1089,7 @@ export declare class ModelResult<TTools extends readonly Tool[], TShared extends
|
|
|
1089
1089
|
* Multiple consumers can iterate over this stream concurrently.
|
|
1090
1090
|
* Includes API events, tool events, and turn.start/turn.end delimiters.
|
|
1091
1091
|
*/
|
|
1092
|
-
getFullResponsesStream(): AsyncIterableIterator<
|
|
1092
|
+
getFullResponsesStream(): AsyncIterableIterator<CorrelatedResponseStreamEvent<TTools>>;
|
|
1093
1093
|
/**
|
|
1094
1094
|
* Stream only text deltas as they arrive from all turns.
|
|
1095
1095
|
* This filters the full event stream to only yield text content,
|
|
@@ -1164,7 +1164,7 @@ export declare class ModelResult<TTools extends readonly Tool[], TShared extends
|
|
|
1164
1164
|
* - Tool call argument deltas as { type: "delta", content: string }
|
|
1165
1165
|
* - Preliminary results as { type: "preliminary_result", toolCallId, result }
|
|
1166
1166
|
*/
|
|
1167
|
-
getToolStream(): AsyncIterableIterator<
|
|
1167
|
+
getToolStream(): AsyncIterableIterator<CorrelatedToolStreamEvent<TTools>>;
|
|
1168
1168
|
/**
|
|
1169
1169
|
* Get all tool calls from the completed response (before auto-execution).
|
|
1170
1170
|
* Note: If tools have execute functions, they will be automatically executed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-result.d.ts","sourceRoot":"","sources":["../../src/lib/model-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAA0B,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"model-result.d.ts","sourceRoot":"","sources":["../../src/lib/model-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAA0B,MAAM,mBAAmB,CAAC;AAgChF,OAAO,KAAK,EAGV,cAAc,EAEd,eAAe,EAGhB,MAAM,gBAAgB,CAAC;AAOxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAwC,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAOjG,OAAO,KAAK,EAAkB,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA6BrF,OAAO,KAAK,EAAE,YAAY,EAAuB,MAAM,mBAAmB,CAAC;AAU3E,OAAO,KAAK,EACV,iBAAiB,EAEjB,6BAA6B,EAC7B,yBAAyB,EAGzB,cAAc,EACd,gBAAgB,EAEhB,aAAa,EACb,QAAQ,EACR,IAAI,EAIJ,wBAAwB,EAExB,WAAW,EAIZ,MAAM,iBAAiB,CAAC;AA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C,CAAC,EAAE,CAAC;IAmB/D;;;OAGG;IACH,kBAAkB,IAAI,qBAAqB,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAa3E;;;;;;;;;;;OAWG;IACI,iBAAiB,IAAI,cAAc,CAAC,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IA+DrF;;;;;;OAMG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAO7B;;;OAGG;IACH,aAAa,IAAI,gBAAgB,EAAE;IAInC;;;;;;;;;OASG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO;IAIpD;;;;;;;;;;OAUG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO;IAIrD;;;;;;;;;;;;OAYG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAQpC;;;;;;;;;;;OAWG;IACG,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;IAmB1C;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;IAatE;;;;;OAKG;IACG,QAAQ,IAAI,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAmBpD;;;;;OAKG;IACG,kBAAkB,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAU3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACG,QAAQ,IAAI,OAAO,CAAC,kBAAkB,CAAC;CAwB9C"}
|
package/esm/lib/model-result.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { betaResponsesSend } from '@openrouter/sdk/funcs/betaResponsesSend';
|
|
2
|
-
import { hasAsyncFunctions, resolveAsyncFunctions } from './async-params.js';
|
|
2
|
+
import { hasAsyncFunctions, resolveAsyncFunctions, stripToolSetSnapshotMetadata, } from './async-params.js';
|
|
3
3
|
import { AsyncToolRegistry, acquireAll, buildTaskToolStub, defaultCheckResult, hasTaskToolNameCollision, persistedTaskCheckResult, resolveCheckConfig, Semaphore, TASK_RESULT_BOUNDARY, TASK_TOOL_NAME, TaskToolInputSchema, ToolTask, } from './async-tools.js';
|
|
4
4
|
import { appendToMessages, createInitialState, createRejectedResult, createUnsentResult, extractTextFromResponse as extractTextFromResponseState, normalizeInputToArray, partitionToolCalls, unsentResultsToAPIFormat, updateState, } from './conversation-state.js';
|
|
5
5
|
import { canonicalizeKeyMaterial, DoomLoopMonitor, resolveDoomLoopOption, resolveLoopKeyMaterial, } from './doom-loop.js';
|
|
@@ -563,10 +563,11 @@ export class ModelResult {
|
|
|
563
563
|
* Push a tool result event to both the legacy tool event broadcaster
|
|
564
564
|
* and the unified turn broadcaster.
|
|
565
565
|
*/
|
|
566
|
-
broadcastToolResult(toolCallId, source, result, preliminaryResults) {
|
|
566
|
+
broadcastToolResult(toolCallId, toolName, source, result, preliminaryResults) {
|
|
567
567
|
this.toolEventBroadcaster?.push({
|
|
568
568
|
type: 'tool_result',
|
|
569
569
|
toolCallId,
|
|
570
|
+
toolName,
|
|
570
571
|
source,
|
|
571
572
|
result,
|
|
572
573
|
...(preliminaryResults?.length && {
|
|
@@ -576,6 +577,7 @@ export class ModelResult {
|
|
|
576
577
|
this.turnBroadcaster?.push({
|
|
577
578
|
type: 'tool.result',
|
|
578
579
|
toolCallId,
|
|
580
|
+
toolName,
|
|
579
581
|
source,
|
|
580
582
|
result,
|
|
581
583
|
timestamp: Date.now(),
|
|
@@ -588,15 +590,17 @@ export class ModelResult {
|
|
|
588
590
|
* Push a preliminary result event to both the legacy tool event broadcaster
|
|
589
591
|
* and the unified turn broadcaster.
|
|
590
592
|
*/
|
|
591
|
-
broadcastPreliminaryResult(toolCallId, result) {
|
|
593
|
+
broadcastPreliminaryResult(toolCallId, toolName, result) {
|
|
592
594
|
this.toolEventBroadcaster?.push({
|
|
593
595
|
type: 'preliminary_result',
|
|
594
596
|
toolCallId,
|
|
597
|
+
toolName,
|
|
595
598
|
result,
|
|
596
599
|
});
|
|
597
600
|
this.turnBroadcaster?.push({
|
|
598
601
|
type: 'tool.preliminary_result',
|
|
599
602
|
toolCallId,
|
|
603
|
+
toolName,
|
|
600
604
|
result,
|
|
601
605
|
timestamp: Date.now(),
|
|
602
606
|
});
|
|
@@ -2067,7 +2071,7 @@ export class ModelResult {
|
|
|
2067
2071
|
// JSON-parse failures so hooks never see a malformed payload.
|
|
2068
2072
|
const hookOutcome = await this.runToolWithHooks(tool, tc, turnContext);
|
|
2069
2073
|
if (hookOutcome.type === 'parse_error') {
|
|
2070
|
-
this.broadcastToolResult(tc.id, isMcpTool(tool) ? 'mcp' : 'client', {
|
|
2074
|
+
this.broadcastToolResult(tc.id, String(tc.name), isMcpTool(tool) ? 'mcp' : 'client', {
|
|
2071
2075
|
error: hookOutcome.errorMessage,
|
|
2072
2076
|
});
|
|
2073
2077
|
return createRejectedResult(tc.id, String(tc.name), hookOutcome.errorMessage);
|
|
@@ -2315,7 +2319,7 @@ export class ModelResult {
|
|
|
2315
2319
|
// Emit the canonical tool.result event with the FINAL value so
|
|
2316
2320
|
// consumers watching only tool.result see real results exactly once.
|
|
2317
2321
|
if (task.status === 'completed') {
|
|
2318
|
-
this.broadcastToolResult(task.callId, this.toolSourceByName(task.name), task.result);
|
|
2322
|
+
this.broadcastToolResult(task.callId, String(task.name), this.toolSourceByName(String(task.name)), task.result);
|
|
2319
2323
|
}
|
|
2320
2324
|
// PostToolUse/PostToolUseFailure fire at SETTLEMENT for async tools —
|
|
2321
2325
|
// the observation-only audit surface (secret scanning, output review)
|
|
@@ -2450,7 +2454,7 @@ export class ModelResult {
|
|
|
2450
2454
|
? (callId, resultValue) => {
|
|
2451
2455
|
const typedResult = resultValue;
|
|
2452
2456
|
preliminaryResultsForCall.push(typedResult);
|
|
2453
|
-
this.broadcastPreliminaryResult(callId, typedResult);
|
|
2457
|
+
this.broadcastPreliminaryResult(callId, String(toolCall.name), typedResult);
|
|
2454
2458
|
}
|
|
2455
2459
|
: undefined;
|
|
2456
2460
|
// Compose the per-call abort signal (run signal + tool/run timeout +
|
|
@@ -2503,7 +2507,7 @@ export class ModelResult {
|
|
|
2503
2507
|
return this.buildToolTimeoutOutcome(toolCall, tool, timeoutMs, preliminaryResultsForCall);
|
|
2504
2508
|
}
|
|
2505
2509
|
if (executed.type === 'parse_error') {
|
|
2506
|
-
this.broadcastToolResult(toolCall.id, isMcpTool(tool) ? 'mcp' : 'client', {
|
|
2510
|
+
this.broadcastToolResult(toolCall.id, String(toolCall.name), isMcpTool(tool) ? 'mcp' : 'client', {
|
|
2507
2511
|
error: executed.errorMessage,
|
|
2508
2512
|
});
|
|
2509
2513
|
return executed;
|
|
@@ -2557,7 +2561,7 @@ export class ModelResult {
|
|
|
2557
2561
|
*/
|
|
2558
2562
|
buildToolTimeoutOutcome(toolCall, tool, timeoutMs, preliminaryResultsForCall) {
|
|
2559
2563
|
const message = `Tool "${toolCall.name}" timed out after ${timeoutMs}ms`;
|
|
2560
|
-
this.broadcastToolResult(toolCall.id, isMcpTool(tool) ? 'mcp' : 'client', {
|
|
2564
|
+
this.broadcastToolResult(toolCall.id, String(toolCall.name), isMcpTool(tool) ? 'mcp' : 'client', {
|
|
2561
2565
|
error: message,
|
|
2562
2566
|
});
|
|
2563
2567
|
return {
|
|
@@ -2654,7 +2658,7 @@ export class ModelResult {
|
|
|
2654
2658
|
if (settled.status === 'rejected') {
|
|
2655
2659
|
const errorMessage = settled.reason instanceof Error ? settled.reason.message : String(settled.reason);
|
|
2656
2660
|
// `runToolWithHooks` is the single point of emission for PostToolUseFailure.
|
|
2657
|
-
this.broadcastToolResult(originalToolCall.id, this.toolSourceByName(originalToolCall.name), {
|
|
2661
|
+
this.broadcastToolResult(originalToolCall.id, String(originalToolCall.name), this.toolSourceByName(String(originalToolCall.name)), {
|
|
2658
2662
|
error: errorMessage,
|
|
2659
2663
|
});
|
|
2660
2664
|
const rejectedOutput = {
|
|
@@ -2716,7 +2720,7 @@ export class ModelResult {
|
|
|
2716
2720
|
error: value.result.error.message,
|
|
2717
2721
|
}
|
|
2718
2722
|
: value.result.result);
|
|
2719
|
-
this.broadcastToolResult(value.toolCall.id, isMcpTool(value.tool) ? 'mcp' : 'client', toolResult, value.preliminaryResultsForCall.length > 0 ? value.preliminaryResultsForCall : undefined);
|
|
2723
|
+
this.broadcastToolResult(value.toolCall.id, String(value.toolCall.name), isMcpTool(value.tool) ? 'mcp' : 'client', toolResult, value.preliminaryResultsForCall.length > 0 ? value.preliminaryResultsForCall : undefined);
|
|
2720
2724
|
const outputForModel = await this.computeToolOutputForModel(value);
|
|
2721
2725
|
const executedOutput = {
|
|
2722
2726
|
type: 'function_call_output',
|
|
@@ -2851,7 +2855,7 @@ export class ModelResult {
|
|
|
2851
2855
|
// would be a double delivery).
|
|
2852
2856
|
registry.untrack(toolCall.id);
|
|
2853
2857
|
if (settled.outcome === 'ok') {
|
|
2854
|
-
this.broadcastToolResult(toolCall.id, source, settled.result);
|
|
2858
|
+
this.broadcastToolResult(toolCall.id, String(toolCall.name), source, settled.result);
|
|
2855
2859
|
const outputForModel = await this.computeToolOutputForModel({
|
|
2856
2860
|
toolCall,
|
|
2857
2861
|
tool,
|
|
@@ -2869,7 +2873,7 @@ export class ModelResult {
|
|
|
2869
2873
|
};
|
|
2870
2874
|
}
|
|
2871
2875
|
const message = settled.error instanceof Error ? settled.error.message : String(settled.error);
|
|
2872
|
-
this.broadcastToolResult(toolCall.id, source, {
|
|
2876
|
+
this.broadcastToolResult(toolCall.id, String(toolCall.name), source, {
|
|
2873
2877
|
error: message,
|
|
2874
2878
|
});
|
|
2875
2879
|
return {
|
|
@@ -2914,7 +2918,7 @@ export class ModelResult {
|
|
|
2914
2918
|
return null;
|
|
2915
2919
|
}
|
|
2916
2920
|
const message = `Tool "${toolCall.name}": ctx.defer() taskId "${taskId}" is already in use by another pending task in this conversation (call ${duplicate.callId}). Task ids must be unique per conversation — include a per-call component (e.g. the ticket id plus your callId).`;
|
|
2917
|
-
this.broadcastToolResult(toolCall.id, source, {
|
|
2921
|
+
this.broadcastToolResult(toolCall.id, String(toolCall.name), source, {
|
|
2918
2922
|
error: message,
|
|
2919
2923
|
});
|
|
2920
2924
|
return {
|
|
@@ -3120,7 +3124,7 @@ export class ModelResult {
|
|
|
3120
3124
|
const taskTool = buildTaskToolStub();
|
|
3121
3125
|
const answer = (result, error) => {
|
|
3122
3126
|
if (error === undefined) {
|
|
3123
|
-
this.broadcastToolResult(toolCall.id, 'client', result);
|
|
3127
|
+
this.broadcastToolResult(toolCall.id, String(toolCall.name), 'client', result);
|
|
3124
3128
|
}
|
|
3125
3129
|
return {
|
|
3126
3130
|
type: 'execution',
|
|
@@ -3323,9 +3327,23 @@ export class ModelResult {
|
|
|
3323
3327
|
return;
|
|
3324
3328
|
}
|
|
3325
3329
|
const computedParams = await executeNextTurnParamsFunctions(toolCalls, this.options.tools, this.resolvedRequest);
|
|
3326
|
-
if (Object.keys(computedParams).length
|
|
3327
|
-
|
|
3330
|
+
if (Object.keys(computedParams).length === 0) {
|
|
3331
|
+
return;
|
|
3328
3332
|
}
|
|
3333
|
+
const nextRequest = applyNextTurnParamsToRequest(this.resolvedRequest, computedParams);
|
|
3334
|
+
/*
|
|
3335
|
+
* A tool-computed `toolChoice` becomes the new caller-level policy, not a
|
|
3336
|
+
* one-turn override. Merging it onto the request alone is not enough:
|
|
3337
|
+
* `makeFollowupRequest` re-derives the wire choice from
|
|
3338
|
+
* `configuredToolChoice` via `applyForcedToolChoicePolicy`, which would
|
|
3339
|
+
* discard the tool's value before dispatch. Re-running the resolved-policy
|
|
3340
|
+
* bookkeeping re-stamps the configured choice and its forced-choice
|
|
3341
|
+
* consumption key together, so relaxation stays consistent for later turns.
|
|
3342
|
+
*/
|
|
3343
|
+
this.resolvedRequest =
|
|
3344
|
+
'toolChoice' in computedParams
|
|
3345
|
+
? this.applyResolvedForcedToolChoicePolicy(nextRequest)
|
|
3346
|
+
: nextRequest;
|
|
3329
3347
|
}
|
|
3330
3348
|
/**
|
|
3331
3349
|
* Make a follow-up API request with tool results.
|
|
@@ -3781,8 +3799,12 @@ export class ModelResult {
|
|
|
3781
3799
|
// `clientOnlyFields` in async-params.ts, which handles the async path.
|
|
3782
3800
|
// (`sharedContextSchema` is absent here: call-model.ts destructures it
|
|
3783
3801
|
// before the request reaches ModelResult.)
|
|
3784
|
-
const { stopWhen: _, state: _s, requireApproval: _r, approveToolCalls: _a, rejectToolCalls: _rj, context: _c, onTurnStart: _ots, onTurnEnd: _ote, allowFinalResponse: _afr, strictFinalResponse: _sfr, hooks: _h, doomLoop: _dl, signal: _sig, toolTimeoutMs: _ttm, toolConcurrency: _tc, asyncTools: _at, ...rest } = this.options.request;
|
|
3785
|
-
|
|
3802
|
+
const { stopWhen: _, state: _s, requireApproval: _r, approveToolCalls: _a, rejectToolCalls: _rj, context: _c, onTurnStart: _ots, onTurnEnd: _ote, allowFinalResponse: _afr, strictFinalResponse: _sfr, hooks: _h, doomLoop: _dl, signal: _sig, toolTimeoutMs: _ttm, toolConcurrency: _tc, asyncTools: _at, activeTools: _activeTools, ...rest } = this.options.request;
|
|
3803
|
+
const resolved = {
|
|
3804
|
+
...rest,
|
|
3805
|
+
};
|
|
3806
|
+
stripToolSetSnapshotMetadata(resolved);
|
|
3807
|
+
return this.applyResolvedForcedToolChoicePolicy(resolved);
|
|
3786
3808
|
}
|
|
3787
3809
|
/**
|
|
3788
3810
|
* Record the freshly-resolved caller choice before deriving its wire value.
|
|
@@ -4339,7 +4361,7 @@ export class ModelResult {
|
|
|
4339
4361
|
}
|
|
4340
4362
|
const hookOutcome = await this.runToolWithHooks(tool, toolCall, turnContext);
|
|
4341
4363
|
if (hookOutcome.type === 'parse_error') {
|
|
4342
|
-
this.broadcastToolResult(callId, this.toolSourceByName(String(toolCall.name)), {
|
|
4364
|
+
this.broadcastToolResult(callId, String(toolCall.name), this.toolSourceByName(String(toolCall.name)), {
|
|
4343
4365
|
error: hookOutcome.errorMessage,
|
|
4344
4366
|
});
|
|
4345
4367
|
unsentResults.push(createRejectedResult(callId, String(toolCall.name), hookOutcome.errorMessage));
|
|
@@ -5352,10 +5374,12 @@ export class ModelResult {
|
|
|
5352
5374
|
continue;
|
|
5353
5375
|
}
|
|
5354
5376
|
if (event.type === 'tool.preliminary_result') {
|
|
5377
|
+
const prelim = event;
|
|
5355
5378
|
yield {
|
|
5356
5379
|
type: 'preliminary_result',
|
|
5357
|
-
toolCallId:
|
|
5358
|
-
|
|
5380
|
+
toolCallId: prelim.toolCallId,
|
|
5381
|
+
toolName: prelim.toolName,
|
|
5382
|
+
result: prelim.result,
|
|
5359
5383
|
};
|
|
5360
5384
|
}
|
|
5361
5385
|
}
|