@anvia/core 1.2.0 → 1.2.2
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/agent/agent-tool.js +8 -8
- package/dist/agent/agent.js +26 -26
- package/dist/agent/index.d.ts +12 -12
- package/dist/agent/index.js +31 -31
- package/dist/agent/interactions/index.d.ts +1 -1
- package/dist/agent/resolve-options.js +13 -13
- package/dist/agent/resolved-agent.js +27 -27
- package/dist/agent/team/agent-team.js +31 -31
- package/dist/agent/team/index.js +31 -31
- package/dist/agent/tool-catalog.js +12 -12
- package/dist/{agent-C9VhENdj.d.ts → agent-CUZdf9G0.d.ts} +9 -9
- package/dist/{chunk-UTAB3XQI.js → chunk-2JZV4LUS.js} +2 -2
- package/dist/{chunk-TSPQD5HW.js → chunk-3EX524LK.js} +36 -27
- package/dist/chunk-3EX524LK.js.map +1 -0
- package/dist/{chunk-UOGM62JL.js → chunk-3P65RSBB.js} +3 -3
- package/dist/{chunk-RT5LUEO3.js → chunk-4PGI5HYY.js} +9 -9
- package/dist/{chunk-QEPBHHAP.js → chunk-54ZZJRP2.js} +19 -3
- package/dist/chunk-54ZZJRP2.js.map +1 -0
- package/dist/{chunk-BDDC72GF.js → chunk-5HFXHKDD.js} +2 -2
- package/dist/{chunk-QHGYCYV6.js → chunk-5KS4SG2U.js} +4 -4
- package/dist/{chunk-RXKUIJ77.js → chunk-5REZFNZ3.js} +5 -5
- package/dist/{chunk-B47EXUHL.js → chunk-5TMN4MYN.js} +2 -2
- package/dist/{chunk-LKIABZNR.js → chunk-63DUKYEG.js} +3 -3
- package/dist/{chunk-MHOJJYDK.js → chunk-647TQE3E.js} +2 -2
- package/dist/{chunk-HP34GRQX.js → chunk-AS7A2LU5.js} +2 -2
- package/dist/{chunk-BDKFFFVX.js → chunk-BD2USPK5.js} +4 -4
- package/dist/{chunk-B5YTCKUJ.js → chunk-BVAQJOZX.js} +9 -9
- package/dist/{chunk-T4KS577P.js → chunk-FSBDE6RF.js} +7 -6
- package/dist/chunk-FSBDE6RF.js.map +1 -0
- package/dist/{chunk-CKKNO4XB.js → chunk-GSVOMQEE.js} +2 -2
- package/dist/{chunk-TIZGADU4.js → chunk-HAVSSHOW.js} +7 -7
- package/dist/{chunk-TIZGADU4.js.map → chunk-HAVSSHOW.js.map} +1 -1
- package/dist/{chunk-IDNL6IH4.js → chunk-HJ6KTQTZ.js} +7 -1
- package/dist/chunk-HJ6KTQTZ.js.map +1 -0
- package/dist/{chunk-IV6YQTY2.js → chunk-ICDPUAKN.js} +2 -2
- package/dist/{chunk-JB3RFK6K.js → chunk-KSVFGXS6.js} +2 -2
- package/dist/{chunk-F3E2RLC7.js → chunk-KSXA7YK7.js} +3 -3
- package/dist/{chunk-5P2YOQSA.js → chunk-KX2TRKO2.js} +2 -2
- package/dist/{chunk-KZGSXJKU.js → chunk-LMZ54UNC.js} +2 -2
- package/dist/{chunk-PYLPLFJZ.js → chunk-N2AQUFGO.js} +4 -4
- package/dist/{chunk-7KAGWJ5M.js → chunk-NA44V5OE.js} +3 -3
- package/dist/{chunk-5AETKC4L.js → chunk-NSWBPKWH.js} +3 -3
- package/dist/{chunk-J4SINPUA.js → chunk-P6IEZWI3.js} +18 -6
- package/dist/chunk-P6IEZWI3.js.map +1 -0
- package/dist/{chunk-PPJ7SYQL.js → chunk-RGYVR4FE.js} +3 -3
- package/dist/{chunk-47NTHIVB.js → chunk-SCFWN3T2.js} +2 -1
- package/dist/chunk-SCFWN3T2.js.map +1 -0
- package/dist/{chunk-JOQ2T3QP.js → chunk-SIXS4CCU.js} +8 -8
- package/dist/{chunk-23GEYG2X.js → chunk-VCMBQTR4.js} +2 -2
- package/dist/{chunk-BUPC72Y2.js → chunk-VPTAGK7G.js} +3 -3
- package/dist/{chunk-PT777EQ3.js → chunk-VQTSZ4ZW.js} +3 -3
- package/dist/{chunk-6N4ENZO4.js → chunk-VU6YTPPH.js} +2 -2
- package/dist/{chunk-XV3DH5GC.js → chunk-WUZG6B3Q.js} +2 -2
- package/dist/{chunk-XJRNBTIV.js → chunk-YNA3UR42.js} +2 -2
- package/dist/completion/generate-completion.js +4 -4
- package/dist/completion/index.d.ts +3 -3
- package/dist/completion/index.js +4 -4
- package/dist/completion/stream-accumulator.js +2 -2
- package/dist/completion/types.js +1 -1
- package/dist/{dynamic-tools-CNHSPXr1.d.ts → dynamic-tools-BXXLc34l.d.ts} +3 -3
- package/dist/embeddings/index.js +1 -1
- package/dist/evals/advanced-metrics.js +8 -8
- package/dist/evals/cli.js +7 -7
- package/dist/evals/index.d.ts +5 -5
- package/dist/evals/index.js +37 -37
- package/dist/evals/judge.js +6 -6
- package/dist/evals/metrics.js +8 -8
- package/dist/evals/runner.js +6 -6
- package/dist/extractor/extractor.js +5 -5
- package/dist/extractor/index.d.ts +1 -1
- package/dist/extractor/index.js +5 -5
- package/dist/guardrails/index.d.ts +4 -4
- package/dist/image-generation/index.d.ts +1 -1
- package/dist/index.d.ts +13 -13
- package/dist/index.js +34 -34
- package/dist/internal/agent-runtime/agent-run.js +22 -22
- package/dist/internal/agent-runtime/continuation-state.js +4 -4
- package/dist/internal/agent-runtime/interaction-suspension.js +4 -4
- package/dist/internal/agent-runtime/memory.js +6 -6
- package/dist/internal/agent-runtime/prepared-tool-call.js +2 -2
- package/dist/internal/agent-runtime/retrieval.js +10 -10
- package/dist/internal/agent-runtime/tool-execution.js +18 -18
- package/dist/internal/agent.d.ts +43 -10
- package/dist/internal/agent.js +27 -27
- package/dist/internal/completion-request.js +2 -2
- package/dist/internal/team-runtime/member.js +5 -5
- package/dist/internal/team-runtime/run.js +30 -30
- package/dist/internal/team-runtime/tools.js +4 -4
- package/dist/mcp/index.d.ts +4 -4
- package/dist/memory/compaction.js +5 -5
- package/dist/memory/index.d.ts +3 -3
- package/dist/memory/index.js +5 -5
- package/dist/{middleware-CWjnMbiH.d.ts → middleware-DORuwSy-.d.ts} +67 -4
- package/dist/observability/group.js +5 -5
- package/dist/observability/index.d.ts +5 -5
- package/dist/observability/index.js +5 -5
- package/dist/pipeline/index.d.ts +10 -10
- package/dist/pipeline/index.js +6 -6
- package/dist/pipeline/pipeline.js +6 -6
- package/dist/{provider-output-error-OQ4fjw5W.d.ts → provider-output-error-CMVoe1xT.d.ts} +1 -1
- package/dist/skills/index.d.ts +4 -4
- package/dist/skills/index.js +15 -15
- package/dist/skills/load.js +15 -15
- package/dist/skills/tools.js +14 -14
- package/dist/speech-generation/index.d.ts +1 -1
- package/dist/speech-generation/index.js +1 -1
- package/dist/streaming/index.js +2 -1
- package/dist/streaming/readable-stream.js +2 -1
- package/dist/{text-GbW4WYMg.d.ts → text-CklbSG7K.d.ts} +1 -1
- package/dist/{think-tool-YWsV98I5.d.ts → think-tool-2unWbq1w.d.ts} +1 -1
- package/dist/tool/create-tool.js +3 -3
- package/dist/tool/dynamic-tools.js +11 -11
- package/dist/tool/index.d.ts +8 -8
- package/dist/tool/index.js +13 -13
- package/dist/tool/question-tool.js +4 -4
- package/dist/tool/think-tool.js +4 -4
- package/dist/tool/tool.js +1 -1
- package/dist/{tool-DQMZpZSS.d.ts → tool-D_jV3cRZ.d.ts} +38 -1
- package/dist/transcription/index.d.ts +1 -1
- package/dist/{types-DfRPfehE.d.ts → types-0t3BczrD.d.ts} +2 -2
- package/dist/{types-CODGMHnp.d.ts → types-ChyQISt-.d.ts} +1 -1
- package/dist/{types-Bqw0AuFl.d.ts → types-CqiX-4_C.d.ts} +1 -1
- package/dist/{types-C1xYKXF2.d.ts → types-Cu2tEf3V.d.ts} +1 -1
- package/dist/{types-CiHjqE6J.d.ts → types-DYqZKDA8.d.ts} +140 -0
- package/dist/{types-CafU6Ux5.d.ts → types-DhWxTobb.d.ts} +37 -1
- package/dist/vector-store/index.d.ts +4 -4
- package/dist/vector-store/index.js +13 -13
- package/dist/vector-store/ingest.js +5 -5
- package/dist/vector-store/retrieve.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-47NTHIVB.js.map +0 -1
- package/dist/chunk-IDNL6IH4.js.map +0 -1
- package/dist/chunk-J4SINPUA.js.map +0 -1
- package/dist/chunk-QEPBHHAP.js.map +0 -1
- package/dist/chunk-T4KS577P.js.map +0 -1
- package/dist/chunk-TSPQD5HW.js.map +0 -1
- /package/dist/{chunk-UTAB3XQI.js.map → chunk-2JZV4LUS.js.map} +0 -0
- /package/dist/{chunk-UOGM62JL.js.map → chunk-3P65RSBB.js.map} +0 -0
- /package/dist/{chunk-RT5LUEO3.js.map → chunk-4PGI5HYY.js.map} +0 -0
- /package/dist/{chunk-BDDC72GF.js.map → chunk-5HFXHKDD.js.map} +0 -0
- /package/dist/{chunk-QHGYCYV6.js.map → chunk-5KS4SG2U.js.map} +0 -0
- /package/dist/{chunk-RXKUIJ77.js.map → chunk-5REZFNZ3.js.map} +0 -0
- /package/dist/{chunk-B47EXUHL.js.map → chunk-5TMN4MYN.js.map} +0 -0
- /package/dist/{chunk-LKIABZNR.js.map → chunk-63DUKYEG.js.map} +0 -0
- /package/dist/{chunk-MHOJJYDK.js.map → chunk-647TQE3E.js.map} +0 -0
- /package/dist/{chunk-HP34GRQX.js.map → chunk-AS7A2LU5.js.map} +0 -0
- /package/dist/{chunk-BDKFFFVX.js.map → chunk-BD2USPK5.js.map} +0 -0
- /package/dist/{chunk-B5YTCKUJ.js.map → chunk-BVAQJOZX.js.map} +0 -0
- /package/dist/{chunk-CKKNO4XB.js.map → chunk-GSVOMQEE.js.map} +0 -0
- /package/dist/{chunk-IV6YQTY2.js.map → chunk-ICDPUAKN.js.map} +0 -0
- /package/dist/{chunk-JB3RFK6K.js.map → chunk-KSVFGXS6.js.map} +0 -0
- /package/dist/{chunk-F3E2RLC7.js.map → chunk-KSXA7YK7.js.map} +0 -0
- /package/dist/{chunk-5P2YOQSA.js.map → chunk-KX2TRKO2.js.map} +0 -0
- /package/dist/{chunk-KZGSXJKU.js.map → chunk-LMZ54UNC.js.map} +0 -0
- /package/dist/{chunk-PYLPLFJZ.js.map → chunk-N2AQUFGO.js.map} +0 -0
- /package/dist/{chunk-7KAGWJ5M.js.map → chunk-NA44V5OE.js.map} +0 -0
- /package/dist/{chunk-5AETKC4L.js.map → chunk-NSWBPKWH.js.map} +0 -0
- /package/dist/{chunk-PPJ7SYQL.js.map → chunk-RGYVR4FE.js.map} +0 -0
- /package/dist/{chunk-JOQ2T3QP.js.map → chunk-SIXS4CCU.js.map} +0 -0
- /package/dist/{chunk-23GEYG2X.js.map → chunk-VCMBQTR4.js.map} +0 -0
- /package/dist/{chunk-BUPC72Y2.js.map → chunk-VPTAGK7G.js.map} +0 -0
- /package/dist/{chunk-PT777EQ3.js.map → chunk-VQTSZ4ZW.js.map} +0 -0
- /package/dist/{chunk-6N4ENZO4.js.map → chunk-VU6YTPPH.js.map} +0 -0
- /package/dist/{chunk-XV3DH5GC.js.map → chunk-WUZG6B3Q.js.map} +0 -0
- /package/dist/{chunk-XJRNBTIV.js.map → chunk-YNA3UR42.js.map} +0 -0
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
} from "./chunk-X6WS3XWL.js";
|
|
4
4
|
import {
|
|
5
5
|
TeamRun
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-3EX524LK.js";
|
|
7
7
|
import {
|
|
8
8
|
TeamStream
|
|
9
9
|
} from "./chunk-3TAQXJBC.js";
|
|
10
10
|
import {
|
|
11
11
|
Agent
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-BVAQJOZX.js";
|
|
13
13
|
import {
|
|
14
14
|
assertPositiveSafeInteger
|
|
15
15
|
} from "./chunk-NPJ2T3L5.js";
|
|
@@ -104,4 +104,4 @@ var AgentTeam = class {
|
|
|
104
104
|
export {
|
|
105
105
|
AgentTeam
|
|
106
106
|
};
|
|
107
|
-
//# sourceMappingURL=chunk-
|
|
107
|
+
//# sourceMappingURL=chunk-NSWBPKWH.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-5IURMWFN.js";
|
|
5
5
|
import {
|
|
6
6
|
isQuestionTool
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ICDPUAKN.js";
|
|
8
8
|
import {
|
|
9
9
|
isSkillTool
|
|
10
10
|
} from "./chunk-2NLINXRF.js";
|
|
@@ -34,16 +34,16 @@ import {
|
|
|
34
34
|
import {
|
|
35
35
|
prepareToolCall,
|
|
36
36
|
prepareToolCallFromInput
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-647TQE3E.js";
|
|
38
38
|
import {
|
|
39
39
|
ToolOutput,
|
|
40
40
|
normalizeToolResultOutput,
|
|
41
41
|
parseToolArgs,
|
|
42
42
|
toolResultContentToText
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-SCFWN3T2.js";
|
|
44
44
|
import {
|
|
45
45
|
Usage
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-HJ6KTQTZ.js";
|
|
47
47
|
import {
|
|
48
48
|
isJsonValue
|
|
49
49
|
} from "./chunk-4C7AXYOM.js";
|
|
@@ -52,6 +52,18 @@ import {
|
|
|
52
52
|
} from "./chunk-USRKPEQN.js";
|
|
53
53
|
|
|
54
54
|
// src/internal/agent-runtime/tool-execution.ts
|
|
55
|
+
function sanitizeToolErrorMessage(error) {
|
|
56
|
+
if (error instanceof Error) {
|
|
57
|
+
return `${error.name}: ${error.message}`;
|
|
58
|
+
}
|
|
59
|
+
if (typeof error === "string") {
|
|
60
|
+
return error;
|
|
61
|
+
}
|
|
62
|
+
if (isJsonValue(error)) {
|
|
63
|
+
return JSON.stringify(error);
|
|
64
|
+
}
|
|
65
|
+
return String(error);
|
|
66
|
+
}
|
|
55
67
|
var ToolCallExecutor = class {
|
|
56
68
|
constructor(agent, activeHook, approvalHandler, lifecycle, runContext, concurrency, requestMiddlewares, abortSignal, cancel) {
|
|
57
69
|
this.agent = agent;
|
|
@@ -660,7 +672,7 @@ var ToolCallExecutor = class {
|
|
|
660
672
|
return {
|
|
661
673
|
output: {
|
|
662
674
|
type: "error-text",
|
|
663
|
-
value:
|
|
675
|
+
value: sanitizeToolErrorMessage(error)
|
|
664
676
|
},
|
|
665
677
|
failed: true,
|
|
666
678
|
error
|
|
@@ -936,4 +948,4 @@ function agentToolEventPayload(toolCall, internalCallId, event) {
|
|
|
936
948
|
export {
|
|
937
949
|
ToolCallExecutor
|
|
938
950
|
};
|
|
939
|
-
//# sourceMappingURL=chunk-
|
|
951
|
+
//# sourceMappingURL=chunk-P6IEZWI3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internal/agent-runtime/tool-execution.ts"],"sourcesContent":["import type { Agent } from \"../../agent/agent\";\nimport { parseAgentQuestionPrompts } from \"../../agent/interactions\";\nimport { type AgentLifecycle, lifecycleSnapshot } from \"../../agent/lifecycle\";\nimport type { AgentChildStreamEvent } from \"../../agent/run-types\";\nimport type {\n JsonObject,\n ToolCallPart,\n ToolDefinition,\n ToolResultContentPart,\n ToolResultOutput,\n ToolResultPart,\n} from \"../../completion\";\nimport { isJsonValue, Usage } from \"../../completion\";\nimport { assertCompletionResponseIntegrity } from \"../../completion/provider-output-error\";\nimport type { AgentHook, ToolApprovalRequestOptions, ToolHookArgs } from \"../../hooks\";\nimport { runControl, toolCallControl } from \"../../hooks\";\nimport { isMcpTool } from \"../../mcp\";\nimport type { ActiveAgentRunObservers, ActiveToolObservers } from \"../../observability/group\";\nimport type {\n AgentToolEndArgs,\n AgentToolErrorArgs,\n AgentToolStartArgs,\n AgentToolStreamEventArgs,\n AgentToolSuspendedArgs,\n} from \"../../observability/types\";\nimport type {\n AnyTool,\n NormalizedToolOutput,\n ToolApprovalContext,\n ToolApprovalRunContext,\n ToolCallContext,\n ToolCallStreamEvent,\n ToolRequiresApproval,\n} from \"../../tool\";\nimport {\n normalizeToolResultOutput,\n parseToolArgs,\n ToolOutput,\n toolResultContentToText,\n} from \"../../tool\";\nimport type {\n AgentMiddleware,\n ToolOutputMiddlewareArgs,\n ToolOutputMiddlewareResult,\n} from \"../../tool/middleware\";\nimport { isQuestionTool } from \"../../tool/question-tool\";\nimport { isSkillTool } from \"../../tool/skill-tool-marker\";\nimport { throwIfAborted } from \"../abort\";\nimport { mapWithConcurrency } from \"../concurrency\";\nimport type { ToolApprovalRequest } from \"./approval-request\";\nimport { assertToolApprovalRequirement, toolMayRequireApproval } from \"./approval-requirement\";\nimport {\n AgentInteractionSignal,\n type PendingToolExecution,\n ToolExecutionSuspension,\n} from \"./interaction-suspension\";\nimport {\n type PreparedToolCall,\n prepareToolCall as prepareRegisteredToolCall,\n prepareToolCallFromInput,\n} from \"./prepared-tool-call\";\n\nexport type ToolResultEventPayload = {\n type: \"tool_result\";\n toolName: string;\n toolCallId: string;\n callId?: string;\n internalCallId: string;\n args: string;\n output: ToolResultOutput;\n result: string;\n structuredResult?: readonly ToolResultContentPart[] | undefined;\n};\n\nexport type AgentToolEventPayload = {\n type: \"agent_tool_event\";\n toolName: string;\n toolCallId?: string;\n internalCallId: string;\n agentId: string;\n agentName?: string;\n event: AgentChildStreamEvent<unknown, unknown>;\n};\n\nexport type ToolExecutionEventPayload = ToolResultEventPayload | AgentToolEventPayload;\n\nexport type ToolExecutionObservation = {\n turn: number;\n runObservers: ActiveAgentRunObservers;\n toolDefinitions?: ToolDefinition[];\n};\n\nexport type ToolExecutionRunContext = {\n runId: string;\n sessionId?: string | undefined;\n metadata?: JsonObject | undefined;\n};\n\nexport type ToolApprovalDecision =\n | { approved: true; reason?: string }\n | { approved: false; reason?: string };\n\nexport type ToolApprovalHandler = (request: ToolApprovalRequest) => Promise<ToolApprovalDecision>;\n\ntype ToolExecutionAgent = Pick<Agent, \"id\" | \"getTool\" | \"callTool\" | \"middlewares\">;\ntype ToolExecutionLifecycle = Pick<AgentLifecycle, \"onToolStart\" | \"onToolFinish\">;\n\nfunction sanitizeToolErrorMessage(error: unknown): string {\n if (error instanceof Error) {\n // Return only name and message, omitting stack traces and internal details\n return `${error.name}: ${error.message}`;\n }\n\n if (typeof error === \"string\") {\n // Strings are JSON values, but JSON.stringify would add surrounding quotes.\n return error;\n }\n\n if (isJsonValue(error)) {\n return JSON.stringify(error);\n }\n\n // Non-Error thrown values\n return String(error);\n}\n\nexport class ToolCallExecutor {\n constructor(\n private readonly agent: ToolExecutionAgent,\n private readonly activeHook: AgentHook | undefined,\n private readonly approvalHandler: ToolApprovalHandler,\n private readonly lifecycle: ToolExecutionLifecycle | undefined,\n private readonly runContext: ToolExecutionRunContext,\n private readonly concurrency: number,\n private readonly requestMiddlewares: readonly AgentMiddleware[],\n private readonly abortSignal: AbortSignal,\n private readonly cancel: (reason: string) => Error,\n ) {}\n\n async execute(\n toolCalls: readonly ToolCallPart[],\n onResult?: (result: ToolResultEventPayload) => void,\n onStreamEvent?: (event: AgentToolEventPayload) => void,\n observation?: ToolExecutionObservation,\n ): Promise<ToolResultPart[]> {\n assertCompletionResponseIntegrity({\n response: {\n choice: [...toolCalls],\n usage: Usage.empty(),\n rawResponse: undefined,\n },\n });\n\n const executeOne = async (toolCall: ToolCallPart): Promise<ToolResultPart> => {\n throwIfAborted(this.abortSignal);\n const args = JSON.stringify(toolCall.input);\n const internalCallId = globalThis.crypto.randomUUID();\n const hookArgs: ToolHookArgs = {\n toolName: toolCall.toolName,\n toolCallId: toolCall.toolCallId,\n internalCallId,\n args,\n };\n if (toolCall.callId !== undefined) {\n hookArgs.callId = toolCall.callId;\n }\n const tool = this.agent.getTool(toolCall.toolName);\n const toolDefinition = observation?.toolDefinitions?.find(\n (definition) => definition.name === toolCall.toolName,\n );\n const toolMetadata = toolTraceMetadata(tool);\n\n let toolStartArgs: AgentToolStartArgs = {\n turn: observation?.turn ?? 0,\n toolCall,\n toolName: toolCall.toolName,\n internalCallId,\n args,\n };\n if (toolCall.callId !== undefined) {\n toolStartArgs = { ...toolStartArgs, toolCallId: toolCall.callId };\n }\n if (toolDefinition !== undefined) toolStartArgs = { ...toolStartArgs, toolDefinition };\n if (toolMetadata !== undefined) toolStartArgs = { ...toolStartArgs, toolMetadata };\n const toolObservers = await observation?.runObservers.startTool(toolStartArgs);\n const toolObservation = new ToolObserverScope(toolObservers);\n\n let output: NormalizedToolOutput | undefined;\n let skipped = false;\n let toolExecutionFailed = false;\n let effectiveArgs = args;\n\n try {\n const callAction = await this.activeHook?.onToolCall?.({\n ...hookArgs,\n tool: toolCallControl,\n });\n if (callAction?.type === \"terminate\") {\n throw this.cancel(callAction.reason);\n }\n if (callAction?.type === \"skip\") {\n output = { type: \"text\", value: callAction.reason };\n skipped = true;\n } else {\n try {\n effectiveArgs = await this.runToolInputMiddlewares({\n ...hookArgs,\n turn: observation?.turn ?? 0,\n originalArgs: args,\n });\n hookArgs.args = effectiveArgs;\n\n let prepared: PreparedToolCall | undefined;\n try {\n prepared = this.prepareToolCall(tool, toolCall.toolName, effectiveArgs);\n } catch (error) {\n const outcome = await this.handleToolError(\n toolCall,\n hookArgs,\n effectiveArgs,\n error,\n toolObservation,\n observation,\n );\n output = outcome.output;\n toolExecutionFailed = outcome.failed;\n }\n if (prepared !== undefined && isQuestionTool(tool)) {\n try {\n const questions = parseAgentQuestionPrompts(\n (prepared.input as { questions?: unknown }).questions,\n );\n const interaction = {\n type: \"tool-question\",\n id: globalThis.crypto.randomUUID(),\n toolName: toolCall.toolName,\n toolCallId: toolCall.toolCallId,\n internalCallId,\n questions,\n } as const;\n if (toolCall.callId !== undefined) {\n Object.assign(interaction, { callId: toolCall.callId });\n }\n throw new AgentInteractionSignal(interaction);\n } catch (error) {\n if (error instanceof AgentInteractionSignal) throw error;\n const outcome = await this.handleToolError(\n toolCall,\n hookArgs,\n effectiveArgs,\n error,\n toolObservation,\n observation,\n );\n output = outcome.output;\n toolExecutionFailed = outcome.failed;\n prepared = undefined;\n }\n }\n if (prepared !== undefined) {\n const approvalContext = createApprovalContext(\n prepared.input,\n hookArgs,\n this.agent,\n this.runContext,\n );\n const approvalDecision =\n callAction?.type === \"approval_request\"\n ? await this.requestApproval(approvalContext, callAction, observation)\n : ((await this.evaluateToolApproval(tool, approvalContext, observation)) ?? {\n approved: true as const,\n });\n if (!approvalDecision.approved) {\n output = { type: \"execution-denied\", reason: approvalDecision.result };\n skipped = true;\n } else {\n const step = observation?.turn ?? 0;\n const lifecycleEvent = {\n runId: this.runContext.runId,\n step,\n toolName: toolCall.toolName,\n input: lifecycleSnapshot(prepared.input),\n };\n if (toolCall.callId !== undefined) {\n Object.assign(lifecycleEvent, { toolCallId: toolCall.callId });\n }\n await this.lifecycle?.onToolStart?.(lifecycleEvent);\n const startedAt = Date.now();\n const outcome = await this.runApprovedToolCall(\n prepared,\n toolCall,\n hookArgs,\n effectiveArgs,\n toolObservation,\n observation,\n onStreamEvent,\n );\n output = outcome.output;\n toolExecutionFailed = outcome.failed;\n const durationMs = Date.now() - startedAt;\n await this.lifecycle?.onToolFinish?.(\n outcome.failed\n ? {\n ...lifecycleEvent,\n durationMs,\n success: false,\n error: lifecycleSnapshot(outcome.error),\n }\n : {\n ...lifecycleEvent,\n durationMs,\n success: true,\n output: lifecycleSnapshot(output),\n },\n );\n }\n }\n } catch (error) {\n if (error instanceof AgentInteractionSignal) {\n await toolObservation.suspend({\n ...toolStartArgs,\n interaction: error.interaction,\n });\n throw error;\n }\n await toolObservation.error(\n toolErrorArgs(observation?.turn ?? 0, toolCall, internalCallId, effectiveArgs, error),\n );\n throw error;\n }\n }\n\n if (output === undefined) {\n throw new Error(`Tool \"${toolCall.toolName}\" did not produce an execution result.`);\n }\n let result = toolOutputToText(output);\n let structuredResult = toolOutputToStructuredResult(output);\n if (!isSkillTool(tool)) {\n const middlewareReplacement = await this.runToolResultMiddlewares({\n ...hookArgs,\n args: effectiveArgs,\n result,\n originalResult: result,\n structuredResult,\n originalStructuredResult: structuredResult,\n turn: observation?.turn ?? 0,\n });\n if (middlewareReplacement !== undefined) {\n output = middlewareReplacement;\n result = toolOutputToText(middlewareReplacement);\n structuredResult = toolOutputToStructuredResult(middlewareReplacement);\n }\n }\n\n const resultAction = await this.activeHook?.onToolResult?.({\n ...hookArgs,\n args: effectiveArgs,\n result,\n structuredResult,\n run: runControl,\n });\n if (!toolExecutionFailed) {\n await toolObservation.end({\n turn: observation?.turn ?? 0,\n toolCall,\n toolName: toolCall.toolName,\n internalCallId,\n args: effectiveArgs,\n result,\n structuredResult,\n skipped,\n toolCallId: toolCall.callId,\n });\n }\n if (resultAction?.type === \"terminate\") {\n throw this.cancel(resultAction.reason);\n }\n\n const resultPayload: ToolResultEventPayload = {\n type: \"tool_result\",\n toolName: toolCall.toolName,\n toolCallId: toolCall.toolCallId,\n internalCallId,\n args: effectiveArgs,\n output,\n result,\n structuredResult,\n };\n if (toolCall.callId !== undefined) resultPayload.callId = toolCall.callId;\n onResult?.(resultPayload);\n let resultPart: ToolResultPart = {\n type: \"tool-result\" as const,\n toolCallId: toolCall.toolCallId,\n toolName: toolCall.toolName,\n output,\n };\n if (toolCall.callId !== undefined) {\n resultPart = { ...resultPart, callId: toolCall.callId };\n }\n return resultPart;\n } catch (error) {\n if (error instanceof AgentInteractionSignal) {\n const pending: PendingToolExecution = {\n toolCall,\n effectiveArgs,\n input:\n error.interaction.type === \"tool-approval\"\n ? error.interaction.input\n : parseToolArgs(effectiveArgs),\n internalCallId,\n };\n if (error.rejectMessage !== undefined) pending.rejectMessage = error.rejectMessage;\n throw new ToolExecutionSuspension(error.interaction, pending);\n }\n await toolObservation.error(\n toolErrorArgs(observation?.turn ?? 0, toolCall, internalCallId, effectiveArgs, error),\n );\n throw error;\n }\n };\n\n if (this.concurrency === 1) {\n const results: ToolResultPart[] = [];\n for (const toolCall of toolCalls) {\n try {\n results.push(await executeOne(toolCall));\n } catch (error) {\n if (error instanceof ToolExecutionSuspension) {\n error.completedResults = [...results];\n error.remainingToolCalls = toolCalls.slice(results.length + 1);\n }\n throw error;\n }\n }\n return results;\n }\n return mapWithConcurrency(toolCalls, this.concurrency, executeOne);\n }\n\n async executeResumed(\n pending: PendingToolExecution,\n onResult?: (result: ToolResultEventPayload) => void,\n onStreamEvent?: (event: AgentToolEventPayload) => void,\n observation?: ToolExecutionObservation,\n ): Promise<ToolResultPart> {\n throwIfAborted(this.abortSignal);\n const { toolCall, internalCallId, effectiveArgs } = pending;\n const tool = this.agent.getTool(toolCall.toolName);\n if (tool === undefined) {\n throw new Error(\n `Cannot resume tool interaction because tool \"${toolCall.toolName}\" is no longer registered.`,\n );\n }\n if (isQuestionTool(tool)) {\n throw new TypeError(\"Question interactions are resolved from their submitted answers.\");\n }\n\n const hookArgs: ToolHookArgs = {\n toolName: toolCall.toolName,\n toolCallId: toolCall.toolCallId,\n internalCallId,\n args: effectiveArgs,\n };\n if (toolCall.callId !== undefined) hookArgs.callId = toolCall.callId;\n const toolDefinition = observation?.toolDefinitions?.find(\n (definition) => definition.name === toolCall.toolName,\n );\n const toolMetadata = toolTraceMetadata(tool);\n let toolStartArgs: AgentToolStartArgs = {\n turn: observation?.turn ?? 0,\n toolCall,\n toolName: toolCall.toolName,\n internalCallId,\n args: effectiveArgs,\n };\n if (toolCall.callId !== undefined) {\n toolStartArgs = { ...toolStartArgs, toolCallId: toolCall.callId };\n }\n if (toolDefinition !== undefined) toolStartArgs = { ...toolStartArgs, toolDefinition };\n if (toolMetadata !== undefined) toolStartArgs = { ...toolStartArgs, toolMetadata };\n const observers = await observation?.runObservers.startTool(toolStartArgs);\n const toolObservation = new ToolObserverScope(observers);\n let output: NormalizedToolOutput;\n let failed = false;\n\n try {\n const prepared = prepareToolCallFromInput(tool, pending.input);\n const step = observation?.turn ?? 0;\n const lifecycleEvent = {\n runId: this.runContext.runId,\n step,\n toolName: toolCall.toolName,\n input: lifecycleSnapshot(prepared.input),\n };\n if (toolCall.callId !== undefined) {\n Object.assign(lifecycleEvent, { toolCallId: toolCall.callId });\n }\n await this.lifecycle?.onToolStart?.(lifecycleEvent);\n const startedAt = Date.now();\n const outcome = await this.runApprovedToolCall(\n prepared,\n toolCall,\n hookArgs,\n effectiveArgs,\n toolObservation,\n observation,\n onStreamEvent,\n );\n output = outcome.output;\n failed = outcome.failed;\n const durationMs = Date.now() - startedAt;\n await this.lifecycle?.onToolFinish?.(\n outcome.failed\n ? {\n ...lifecycleEvent,\n durationMs,\n success: false,\n error: lifecycleSnapshot(outcome.error),\n }\n : {\n ...lifecycleEvent,\n durationMs,\n success: true,\n output: lifecycleSnapshot(output),\n },\n );\n\n let result = toolOutputToText(output);\n let structuredResult = toolOutputToStructuredResult(output);\n if (!isSkillTool(tool)) {\n const replacement = await this.runToolResultMiddlewares({\n ...hookArgs,\n args: effectiveArgs,\n result,\n originalResult: result,\n structuredResult,\n originalStructuredResult: structuredResult,\n turn: step,\n });\n if (replacement !== undefined) {\n output = replacement;\n result = toolOutputToText(replacement);\n structuredResult = toolOutputToStructuredResult(replacement);\n }\n }\n const resultAction = await this.activeHook?.onToolResult?.({\n ...hookArgs,\n result,\n structuredResult,\n run: runControl,\n });\n if (!failed) {\n await toolObservation.end({\n turn: step,\n toolCall,\n toolName: toolCall.toolName,\n internalCallId,\n args: effectiveArgs,\n result,\n structuredResult,\n skipped: false,\n toolCallId: toolCall.callId,\n });\n }\n if (resultAction?.type === \"terminate\") {\n throw this.cancel(resultAction.reason);\n }\n const resultPayload: ToolResultEventPayload = {\n type: \"tool_result\",\n toolName: toolCall.toolName,\n toolCallId: toolCall.toolCallId,\n internalCallId,\n args: effectiveArgs,\n output,\n result,\n structuredResult,\n };\n if (toolCall.callId !== undefined) resultPayload.callId = toolCall.callId;\n onResult?.(resultPayload);\n let resultPart: ToolResultPart = {\n type: \"tool-result\",\n toolName: toolCall.toolName,\n toolCallId: toolCall.toolCallId,\n output,\n };\n if (toolCall.callId !== undefined) resultPart = { ...resultPart, callId: toolCall.callId };\n return resultPart;\n } catch (error) {\n await toolObservation.error(\n toolErrorArgs(observation?.turn ?? 0, toolCall, internalCallId, effectiveArgs, error),\n );\n throw error;\n }\n }\n\n async resolveResumed(\n pending: PendingToolExecution,\n initialOutput: NormalizedToolOutput,\n onResult?: (result: ToolResultEventPayload) => void,\n observation?: ToolExecutionObservation,\n ): Promise<ToolResultPart> {\n throwIfAborted(this.abortSignal);\n const { toolCall, internalCallId, effectiveArgs } = pending;\n const tool = this.agent.getTool(toolCall.toolName);\n if (tool === undefined) {\n throw new Error(\n `Cannot resume tool interaction because tool \"${toolCall.toolName}\" is no longer registered.`,\n );\n }\n\n const hookArgs: ToolHookArgs = {\n toolName: toolCall.toolName,\n toolCallId: toolCall.toolCallId,\n internalCallId,\n args: effectiveArgs,\n };\n if (toolCall.callId !== undefined) hookArgs.callId = toolCall.callId;\n const toolDefinition = observation?.toolDefinitions?.find(\n (definition) => definition.name === toolCall.toolName,\n );\n const toolMetadata = toolTraceMetadata(tool);\n let toolStartArgs: AgentToolStartArgs = {\n turn: observation?.turn ?? 0,\n toolCall,\n toolName: toolCall.toolName,\n internalCallId,\n args: effectiveArgs,\n };\n if (toolCall.callId !== undefined) {\n toolStartArgs = { ...toolStartArgs, toolCallId: toolCall.callId };\n }\n if (toolDefinition !== undefined) toolStartArgs = { ...toolStartArgs, toolDefinition };\n if (toolMetadata !== undefined) toolStartArgs = { ...toolStartArgs, toolMetadata };\n const observers = await observation?.runObservers.startTool(toolStartArgs);\n const toolObservation = new ToolObserverScope(observers);\n\n try {\n let output = initialOutput;\n let result = toolOutputToText(output);\n let structuredResult = toolOutputToStructuredResult(output);\n if (!isSkillTool(tool)) {\n const replacement = await this.runToolResultMiddlewares({\n ...hookArgs,\n args: effectiveArgs,\n result,\n originalResult: result,\n structuredResult,\n originalStructuredResult: structuredResult,\n turn: observation?.turn ?? 0,\n });\n if (replacement !== undefined) {\n output = replacement;\n result = toolOutputToText(replacement);\n structuredResult = toolOutputToStructuredResult(replacement);\n }\n }\n const resultAction = await this.activeHook?.onToolResult?.({\n ...hookArgs,\n result,\n structuredResult,\n run: runControl,\n });\n await toolObservation.end({\n turn: observation?.turn ?? 0,\n toolCall,\n toolName: toolCall.toolName,\n internalCallId,\n args: effectiveArgs,\n result,\n structuredResult,\n skipped: true,\n toolCallId: toolCall.callId,\n });\n if (resultAction?.type === \"terminate\") {\n throw this.cancel(resultAction.reason);\n }\n const resultPayload: ToolResultEventPayload = {\n type: \"tool_result\",\n toolName: toolCall.toolName,\n toolCallId: toolCall.toolCallId,\n internalCallId,\n args: effectiveArgs,\n output,\n result,\n structuredResult,\n };\n if (toolCall.callId !== undefined) resultPayload.callId = toolCall.callId;\n onResult?.(resultPayload);\n let resultPart: ToolResultPart = {\n type: \"tool-result\",\n toolName: toolCall.toolName,\n toolCallId: toolCall.toolCallId,\n output,\n };\n if (toolCall.callId !== undefined) resultPart = { ...resultPart, callId: toolCall.callId };\n return resultPart;\n } catch (error) {\n await toolObservation.error(\n toolErrorArgs(observation?.turn ?? 0, toolCall, internalCallId, effectiveArgs, error),\n );\n throw error;\n }\n }\n\n private async runApprovedToolCall(\n prepared: PreparedToolCall,\n toolCall: ToolCallPart,\n hookArgs: ToolHookArgs,\n effectiveArgs: string,\n toolObservation: ToolObserverScope,\n observation: ToolExecutionObservation | undefined,\n onStreamEvent?: (event: AgentToolEventPayload) => void,\n ): Promise<\n | { output: NormalizedToolOutput; failed: false }\n | { output: NormalizedToolOutput; failed: true; error: unknown }\n > {\n try {\n const toolContext: ToolCallContext = {\n abortSignal: this.abortSignal,\n emitStreamEvent: async (event) => {\n let streamEventArgs: AgentToolStreamEventArgs = {\n turn: observation?.turn ?? 0,\n toolCall,\n toolName: toolCall.toolName,\n internalCallId: hookArgs.internalCallId,\n args: effectiveArgs,\n event,\n };\n if (toolCall.callId !== undefined) {\n streamEventArgs = { ...streamEventArgs, toolCallId: toolCall.callId };\n }\n await toolObservation.streamEvent(streamEventArgs);\n const payload = agentToolEventPayload(toolCall, hookArgs.internalCallId, event);\n if (payload !== undefined) {\n onStreamEvent?.(payload);\n }\n },\n };\n return {\n output: await prepared.call(toolContext),\n failed: false,\n };\n } catch (error) {\n return this.handleToolError(\n toolCall,\n hookArgs,\n effectiveArgs,\n error,\n toolObservation,\n observation,\n );\n }\n }\n\n private prepareToolCall(\n tool: AnyTool | undefined,\n toolName: string,\n args: string,\n ): PreparedToolCall {\n if (tool !== undefined) {\n return prepareRegisteredToolCall(tool, args);\n }\n const input = parseToolArgs(args);\n return {\n input,\n call: (context) => this.agent.callTool(toolName, args, context),\n };\n }\n\n private async handleToolError(\n toolCall: ToolCallPart,\n hookArgs: ToolHookArgs,\n args: string,\n error: unknown,\n toolObservation: ToolObserverScope,\n observation: ToolExecutionObservation | undefined,\n ): Promise<{ output: NormalizedToolOutput; failed: true; error: unknown }> {\n const errorAction = await this.activeHook?.onToolError?.({\n ...hookArgs,\n args,\n error,\n run: runControl,\n });\n await toolObservation.error(\n toolErrorArgs(observation?.turn ?? 0, toolCall, hookArgs.internalCallId, args, error),\n );\n if (errorAction?.type === \"terminate\") {\n throw this.cancel(errorAction.reason);\n }\n return {\n output: {\n type: \"error-text\",\n value: sanitizeToolErrorMessage(error),\n },\n failed: true,\n error,\n };\n }\n\n private async runToolResultMiddlewares(\n args: ToolOutputMiddlewareArgs,\n ): Promise<NormalizedToolOutput | undefined> {\n let result = args.result;\n let structuredResult = args.structuredResult;\n let replaced = false;\n for (const middleware of this.activeMiddlewares()) {\n const outputReplacement = await middleware.onToolOutput?.({\n ...args,\n result,\n structuredResult,\n });\n if (outputReplacement !== undefined) {\n const normalized = normalizeToolOutputMiddlewareResult(outputReplacement);\n if (normalized.result !== undefined) {\n result = normalized.result;\n structuredResult = undefined;\n }\n if (normalized.structuredResult !== undefined) {\n structuredResult = normalized.structuredResult;\n result = toolResultContentToText(normalized.structuredResult);\n }\n replaced = true;\n }\n }\n return replaced\n ? structuredResult === undefined\n ? { type: \"text\", value: result }\n : { type: \"content\", value: structuredResult }\n : undefined;\n }\n\n private async runToolInputMiddlewares(\n args: ToolHookArgs & { turn: number; originalArgs: string },\n ): Promise<string> {\n let current = args.args;\n for (const middleware of this.activeMiddlewares()) {\n const replacement = await middleware.onToolInput?.({\n ...args,\n args: current,\n });\n if (replacement?.args !== undefined) {\n if (typeof replacement.args === \"string\") {\n current = replacement.args;\n } else {\n if (!isJsonValue(replacement.args)) {\n throw new TypeError(\"Tool input middleware args must be a strict JSON value.\");\n }\n current = JSON.stringify(replacement.args);\n }\n }\n }\n return current;\n }\n\n private activeMiddlewares(): AgentMiddleware[] {\n return [...this.agent.middlewares, ...this.requestMiddlewares];\n }\n\n private async evaluateToolApproval(\n tool: AnyTool | undefined,\n context: ToolApprovalContext,\n observation: ToolExecutionObservation | undefined,\n ): Promise<{ approved: true } | { approved: false; result: string } | undefined> {\n const requirement = tool?.requiresApproval as ToolRequiresApproval<unknown> | undefined;\n if (requirement === undefined) return undefined;\n const resolved =\n typeof requirement === \"function\" ? await requirement(context.args, context) : requirement;\n assertToolApprovalRequirement(resolved, { allowFunction: false });\n if (resolved === false) return { approved: true };\n const reason = resolved === true ? undefined : resolved.reason;\n return this.requestApproval(context, reason === undefined ? {} : { reason }, observation);\n }\n\n private async requestApproval(\n context: ToolApprovalContext,\n options: ToolApprovalRequestOptions,\n observation: ToolExecutionObservation | undefined,\n ): Promise<{ approved: true } | { approved: false; result: string }> {\n const request: ToolApprovalRequest = {\n ...context,\n id: globalThis.crypto.randomUUID(),\n };\n if (options.reason !== undefined) {\n request.reason = options.reason;\n }\n if (options.rejectMessage !== undefined) {\n request.rejectMessage = options.rejectMessage;\n }\n await observation?.runObservers.event({\n name: \"tool.approval_requested\",\n attributes: approvalEventAttributes(request, observation.turn),\n });\n let decision: ToolApprovalDecision;\n try {\n decision = await this.approvalHandler(request);\n } catch (error) {\n if (error instanceof AgentInteractionSignal) {\n throw error;\n }\n await observation?.runObservers.event({\n name: \"tool.approval_failed\",\n level: \"ERROR\",\n attributes: {\n ...approvalEventAttributes(request, observation.turn),\n errorName: error instanceof Error ? error.name : typeof error,\n },\n });\n throw error;\n }\n const attributes: JsonObject = {\n ...approvalEventAttributes(request, observation?.turn ?? 0),\n approved: decision.approved,\n };\n if (decision.reason !== undefined) attributes.decisionReason = decision.reason;\n await observation?.runObservers.event({\n name: \"tool.approval_resolved\",\n attributes,\n });\n if (decision.approved) {\n return { approved: true };\n }\n return {\n approved: false,\n result: decision.reason ?? request.rejectMessage ?? \"Tool approval was rejected.\",\n };\n }\n}\n\nfunction createApprovalContext(\n input: unknown,\n hookArgs: ToolHookArgs,\n agent: Pick<Agent, \"id\">,\n run: ToolExecutionRunContext,\n): ToolApprovalContext {\n const approvalRun: ToolApprovalRunContext = {\n agentId: agent.id,\n runId: run.runId,\n };\n if (run.sessionId !== undefined) {\n approvalRun.sessionId = run.sessionId;\n }\n if (run.metadata !== undefined) {\n approvalRun.metadata = run.metadata;\n }\n const context: ToolApprovalContext = {\n toolName: hookArgs.toolName,\n args: lifecycleSnapshot(input),\n rawArgs: hookArgs.args,\n toolCallId: hookArgs.toolCallId,\n internalCallId: hookArgs.internalCallId,\n run: approvalRun,\n };\n if (hookArgs.callId !== undefined) {\n context.callId = hookArgs.callId;\n }\n return context;\n}\n\nfunction approvalEventAttributes(request: ToolApprovalRequest, turn: number): JsonObject {\n const attributes: JsonObject = {\n turn,\n approvalId: request.id,\n toolName: request.toolName,\n internalCallId: request.internalCallId,\n };\n if (request.toolCallId !== undefined) attributes.toolCallId = request.toolCallId;\n if (request.reason !== undefined) attributes.reason = request.reason;\n return attributes;\n}\n\nfunction normalizeToolOutputMiddlewareResult(result: ToolOutputMiddlewareResult): {\n result?: string | undefined;\n structuredResult?: readonly ToolResultContentPart[] | undefined;\n} {\n if (typeof result === \"string\") {\n return { result };\n }\n if (typeof result !== \"object\" || result === null) {\n throw new TypeError(\"Tool output middleware must return text or structured content.\");\n }\n const prototype = Object.getPrototypeOf(result);\n if (prototype !== Object.prototype && prototype !== null) {\n throw new TypeError(\"Tool output middleware must return text or structured content.\");\n }\n const keys = Reflect.ownKeys(result);\n const hasResult = keys.includes(\"result\");\n const hasStructuredResult = keys.includes(\"structuredResult\");\n if (\n hasResult === hasStructuredResult ||\n keys.some((key) => key !== \"result\" && key !== \"structuredResult\")\n ) {\n throw new TypeError(\n \"Tool output middleware must return exactly one of result or structuredResult.\",\n );\n }\n if (hasResult) {\n const descriptor = Object.getOwnPropertyDescriptor(result, \"result\");\n if (\n descriptor === undefined ||\n !(\"value\" in descriptor) ||\n typeof descriptor.value !== \"string\"\n ) {\n throw new TypeError(\"Tool output middleware result must be a string.\");\n }\n return { result: descriptor.value };\n }\n const descriptor = Object.getOwnPropertyDescriptor(result, \"structuredResult\");\n if (descriptor === undefined || !(\"value\" in descriptor)) {\n throw new TypeError(\"Tool output middleware structuredResult must be valid tool content.\");\n }\n const normalized = normalizeToolResultOutput(ToolOutput.content(descriptor.value as never));\n if (normalized.type !== \"content\") {\n throw new TypeError(\"Tool output middleware structuredResult must be valid tool content.\");\n }\n return { structuredResult: normalized.value };\n}\n\nfunction toolTraceMetadata(tool: AnyTool | undefined): JsonObject | undefined {\n if (tool === undefined) {\n return undefined;\n }\n const result: JsonObject = {\n approvalRequired: toolMayRequireApproval(tool.requiresApproval),\n };\n if (isMcpTool(tool)) {\n result.mcpServerName = tool.mcp.serverName;\n result.mcpRemoteName = tool.mcp.remoteName;\n }\n return result;\n}\n\nfunction toolErrorArgs(\n turn: number,\n toolCall: ToolCallPart,\n internalCallId: string,\n args: string,\n error: unknown,\n): AgentToolErrorArgs {\n let observerArgs: AgentToolErrorArgs = {\n turn,\n toolCall,\n toolName: toolCall.toolName,\n internalCallId,\n args,\n error,\n };\n if (toolCall.callId !== undefined) {\n observerArgs = { ...observerArgs, toolCallId: toolCall.callId };\n }\n return observerArgs;\n}\n\nclass ToolObserverScope {\n private terminal = false;\n\n constructor(private readonly observers: ActiveToolObservers | undefined) {}\n\n streamEvent(args: AgentToolStreamEventArgs): Promise<void> | undefined {\n return this.observers?.streamEvent(args);\n }\n\n async end(args: AgentToolEndArgs): Promise<void> {\n if (this.terminal) return;\n this.terminal = true;\n await this.observers?.end(args);\n }\n\n async suspend(args: AgentToolSuspendedArgs): Promise<void> {\n if (this.terminal) return;\n this.terminal = true;\n await this.observers?.suspend(args);\n }\n\n async error(args: AgentToolErrorArgs): Promise<void> {\n if (this.terminal) return;\n this.terminal = true;\n await this.observers?.error(args);\n }\n}\n\nfunction toolOutputToText(output: NormalizedToolOutput): string {\n switch (output.type) {\n case \"text\":\n case \"error-text\":\n return output.value;\n case \"json\":\n case \"error-json\":\n return JSON.stringify(output.value);\n case \"content\":\n return toolResultContentToText(output.value);\n case \"execution-denied\":\n return output.reason ?? \"Tool execution was denied.\";\n }\n}\n\nfunction toolOutputToStructuredResult(\n output: NormalizedToolOutput,\n): readonly ToolResultContentPart[] | undefined {\n return output.type === \"content\" ? output.value : undefined;\n}\n\nfunction agentToolEventPayload(\n toolCall: ToolCallPart,\n internalCallId: string,\n event: ToolCallStreamEvent,\n): AgentToolEventPayload | undefined {\n if (typeof event.agentId !== \"string\" || event.agentId.length === 0) {\n return undefined;\n }\n const payload: AgentToolEventPayload = {\n type: \"agent_tool_event\" as const,\n toolName: toolCall.toolName,\n internalCallId,\n agentId: event.agentId,\n event: event.event as AgentChildStreamEvent<unknown, unknown>,\n };\n if (toolCall.callId !== undefined) {\n payload.toolCallId = toolCall.callId;\n }\n if (event.agentName !== undefined) {\n payload.agentName = event.agentName;\n }\n return payload;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2GA,SAAS,yBAAyB,OAAwB;AACxD,MAAI,iBAAiB,OAAO;AAE1B,WAAO,GAAG,MAAM,IAAI,KAAK,MAAM,OAAO;AAAA,EACxC;AAEA,MAAI,OAAO,UAAU,UAAU;AAE7B,WAAO;AAAA,EACT;AAEA,MAAI,YAAY,KAAK,GAAG;AACtB,WAAO,KAAK,UAAU,KAAK;AAAA,EAC7B;AAGA,SAAO,OAAO,KAAK;AACrB;AAEO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YACmB,OACA,YACA,iBACA,WACA,YACA,aACA,oBACA,aACA,QACjB;AATiB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EAChB;AAAA,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WAAW,GAAG;AACnE,WAAO;AAAA,EACT;AACA,QAAM,UAAiC;AAAA,IACrC,MAAM;AAAA,IACN,UAAU,SAAS;AAAA,IACnB;AAAA,IACA,SAAS,MAAM;AAAA,IACf,OAAO,MAAM;AAAA,EACf;AACA,MAAI,SAAS,WAAW,QAAW;AACjC,YAAQ,aAAa,SAAS;AAAA,EAChC;AACA,MAAI,MAAM,cAAc,QAAW;AACjC,YAAQ,YAAY,MAAM;AAAA,EAC5B;AACA,SAAO;AACT;","names":["descriptor"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isStreamingCompletionModel
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BD2USPK5.js";
|
|
4
4
|
import {
|
|
5
5
|
createTool
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WUZG6B3Q.js";
|
|
7
7
|
import {
|
|
8
8
|
AgentRunBlockedError,
|
|
9
9
|
AgentToolSuspensionError
|
|
@@ -78,4 +78,4 @@ function createAgentTool(agent, options) {
|
|
|
78
78
|
export {
|
|
79
79
|
createAgentTool
|
|
80
80
|
};
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
81
|
+
//# sourceMappingURL=chunk-RGYVR4FE.js.map
|
|
@@ -16,6 +16,7 @@ var ToolResultSerializationError = class extends TypeError {
|
|
|
16
16
|
output;
|
|
17
17
|
};
|
|
18
18
|
var ToolOutput = {
|
|
19
|
+
/** Wraps content parts so a tool can return text and files together. */
|
|
19
20
|
content(content) {
|
|
20
21
|
return { [richToolOutput]: true, content };
|
|
21
22
|
}
|
|
@@ -73,4 +74,4 @@ export {
|
|
|
73
74
|
toolResultContentToText,
|
|
74
75
|
parseToolArgs
|
|
75
76
|
};
|
|
76
|
-
//# sourceMappingURL=chunk-
|
|
77
|
+
//# sourceMappingURL=chunk-SCFWN3T2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tool/tool.ts"],"sourcesContent":["import { isJsonValue } from \"../completion/json\";\nimport { parseMessage } from \"../completion/message-schema\";\nimport type {\n JsonObject,\n JsonValue,\n ToolDefinition,\n ToolResultContentPart,\n ToolResultOutput,\n} from \"../completion/types\";\n\n/** Identifies the agent run that requested a tool approval. */\nexport type ToolApprovalRunContext = {\n agentId: string;\n runId: string;\n sessionId?: string;\n metadata?: JsonObject;\n};\n\n/** Details of the pending tool call being evaluated for approval. */\nexport type ToolApprovalContext<Args = unknown> = {\n toolName: string;\n args: Args;\n /** The serialized argument string passed to hooks and approval checks. */\n rawArgs: string;\n toolCallId: string;\n callId?: string;\n internalCallId: string;\n run: ToolApprovalRunContext;\n};\n\n/** An approval demand, with an optional human-readable reason. */\nexport type ToolApprovalRequirement = {\n reason?: string | undefined;\n};\n\n/**\n * Whether a tool call needs human approval before execution:\n *\n * - `boolean`: a static requirement\n * - `ToolApprovalRequirement`: a requirement with a reason\n * - a function: evaluated per call, receiving the parsed args and call context\n */\nexport type ToolRequiresApproval<Args = unknown> =\n | boolean\n | ToolApprovalRequirement\n | ((\n args: Args,\n context: ToolApprovalContext<Args>,\n ) => boolean | ToolApprovalRequirement | Promise<boolean | ToolApprovalRequirement>);\n\n/** A child-agent event forwarded through a tool into the parent run's stream. */\nexport type ToolCallStreamEvent = {\n agentId: string;\n agentName?: string | undefined;\n event: unknown;\n};\n\n/** Execution context handed to a tool when the run invokes it. */\nexport type ToolCallContext = {\n /** Emits a child-agent event into the parent run's stream. */\n emitStreamEvent?(event: ToolCallStreamEvent): void | Promise<void>;\n /** Aborted when the run is cancelled or the stream consumer leaves. */\n abortSignal?: AbortSignal | undefined;\n};\n\n/**\n * A model-callable tool. `definition` builds the model-facing JSON description,\n * `call` executes it, and the optional `parseInput` converts raw model-supplied\n * JSON arguments into the typed `Args` before `call` runs.\n */\nexport interface Tool<Args = unknown, Output = unknown> {\n readonly name: string;\n readonly requiresApproval?: ToolRequiresApproval<Args>;\n definition(prompt: string): ToolDefinition | Promise<ToolDefinition>;\n call(args: Args, context?: ToolCallContext): Output | Promise<Output>;\n parseInput?(args: JsonValue): Args;\n}\n\n/** A tool with its argument and output types erased, e.g. as stored in an agent's catalog. */\nexport type AnyTool = Omit<Tool<unknown, unknown>, \"requiresApproval\"> & {\n readonly requiresApproval?: unknown;\n};\n\nconst richToolOutput: unique symbol = Symbol.for(\"anvia.tool-output.content\");\n\n/**\n * A tool result carrying mixed content parts (text, files), created with\n * {@link ToolOutput.content}. The brand symbol keeps plain objects from\n * impersonating rich outputs.\n */\nexport type RichToolOutput = Readonly<{\n [richToolOutput]: true;\n content: readonly ToolResultContentPart[];\n}>;\n\n/** Normalized tool result as stored in tool messages. */\nexport type NormalizedToolOutput = ToolResultOutput;\n\n/** Thrown when a tool returns a value that cannot be represented as a tool result. */\nexport class ToolResultSerializationError extends TypeError {\n constructor(readonly output: unknown) {\n super(\"Tool output must be a string, a strict JSON value, or ToolOutput.content(...).\");\n this.name = \"ToolResultSerializationError\";\n }\n}\n\n/** Helpers for building tool results. */\nexport const ToolOutput = {\n /** Wraps content parts so a tool can return text and files together. */\n content(content: readonly ToolResultContentPart[]): RichToolOutput {\n return { [richToolOutput]: true, content };\n },\n};\n\n/**\n * Coerces a tool's return value into a normalized result: strings become text,\n * rich outputs are validated, and strict JSON values become JSON results.\n * Anything else throws {@link ToolResultSerializationError}.\n */\nexport function normalizeToolResultOutput(output: unknown): NormalizedToolOutput {\n if (typeof output === \"string\") {\n return { type: \"text\", value: output };\n }\n if (isRichToolOutput(output)) {\n try {\n const message = parseMessage({\n role: \"tool\",\n content: [\n {\n type: \"tool-result\",\n toolCallId: \"validation\",\n toolName: \"validation\",\n output: { type: \"content\", value: output.content },\n },\n ],\n });\n if (message.role !== \"tool\") throw new TypeError(\"Unexpected message role\");\n const result = message.content[0];\n if (result?.type !== \"tool-result\") throw new TypeError(\"Unexpected tool result part\");\n if (result?.output.type !== \"content\") throw new TypeError(\"Unexpected tool output\");\n return result.output;\n } catch {\n throw new ToolResultSerializationError(output);\n }\n }\n if (isJsonValue(output)) {\n return { type: \"json\", value: output };\n }\n throw new ToolResultSerializationError(output);\n}\n\n/** Renders tool result content as text; file parts become `[file:<mediaType>]` placeholders. */\nexport function toolResultContentToText(content: readonly ToolResultContentPart[]): string {\n return content\n .map((item) => (item.type === \"text\" ? item.text : `[file:${item.mediaType}]`))\n .join(\"\\n\");\n}\n\nfunction isRichToolOutput(value: unknown): value is RichToolOutput {\n if (typeof value !== \"object\" || value === null) return false;\n return Object.getOwnPropertyDescriptor(value, richToolOutput)?.value === true;\n}\n\n/** Parses and JSON-validates the raw argument string supplied by the model. */\nexport function parseToolArgs(args: string): JsonValue {\n const value: unknown = JSON.parse(args);\n if (!isJsonValue(value)) {\n throw new TypeError(\"Tool arguments must be a JSON value.\");\n }\n return value;\n}\n"],"mappings":";;;;;;;;AAmFA,IAAM,iBAAgC,uBAAO,IAAI,2BAA2B;AAgBrE,IAAM,+BAAN,cAA2C,UAAU;AAAA,EAC1D,YAAqB,QAAiB;AACpC,UAAM,gFAAgF;AADnE;AAEnB,SAAK,OAAO;AAAA,EACd;AAAA,EAHqB;AAIvB;AAGO,IAAM,aAAa;AAAA;AAAA,EAExB,QAAQ,SAA2D;AACjE,WAAO,EAAE,CAAC,cAAc,GAAG,MAAM,QAAQ;AAAA,EAC3C;AACF;AAOO,SAAS,0BAA0B,QAAuC;AAC/E,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO,EAAE,MAAM,QAAQ,OAAO,OAAO;AAAA,EACvC;AACA,MAAI,iBAAiB,MAAM,GAAG;AAC5B,QAAI;AACF,YAAM,UAAU,aAAa;AAAA,QAC3B,MAAM;AAAA,QACN,SAAS;AAAA,UACP;AAAA,YACE,MAAM;AAAA,YACN,YAAY;AAAA,YACZ,UAAU;AAAA,YACV,QAAQ,EAAE,MAAM,WAAW,OAAO,OAAO,QAAQ;AAAA,UACnD;AAAA,QACF;AAAA,MACF,CAAC;AACD,UAAI,QAAQ,SAAS,OAAQ,OAAM,IAAI,UAAU,yBAAyB;AAC1E,YAAM,SAAS,QAAQ,QAAQ,CAAC;AAChC,UAAI,QAAQ,SAAS,cAAe,OAAM,IAAI,UAAU,6BAA6B;AACrF,UAAI,QAAQ,OAAO,SAAS,UAAW,OAAM,IAAI,UAAU,wBAAwB;AACnF,aAAO,OAAO;AAAA,IAChB,QAAQ;AACN,YAAM,IAAI,6BAA6B,MAAM;AAAA,IAC/C;AAAA,EACF;AACA,MAAI,YAAY,MAAM,GAAG;AACvB,WAAO,EAAE,MAAM,QAAQ,OAAO,OAAO;AAAA,EACvC;AACA,QAAM,IAAI,6BAA6B,MAAM;AAC/C;AAGO,SAAS,wBAAwB,SAAmD;AACzF,SAAO,QACJ,IAAI,CAAC,SAAU,KAAK,SAAS,SAAS,KAAK,OAAO,SAAS,KAAK,SAAS,GAAI,EAC7E,KAAK,IAAI;AACd;AAEA,SAAS,iBAAiB,OAAyC;AACjE,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AACxD,SAAO,OAAO,yBAAyB,OAAO,cAAc,GAAG,UAAU;AAC3E;AAGO,SAAS,cAAc,MAAyB;AACrD,QAAM,QAAiB,KAAK,MAAM,IAAI;AACtC,MAAI,CAAC,YAAY,KAAK,GAAG;AACvB,UAAM,IAAI,UAAU,sCAAsC;AAAA,EAC5D;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defaultEvalTraceSelector
|
|
3
3
|
} from "./chunk-PHLGGRHC.js";
|
|
4
|
+
import {
|
|
5
|
+
errorMessage
|
|
6
|
+
} from "./chunk-ZYXMWEL4.js";
|
|
7
|
+
import {
|
|
8
|
+
EvalOutcome
|
|
9
|
+
} from "./chunk-EJR6VVB3.js";
|
|
4
10
|
import {
|
|
5
11
|
EvalAbortError,
|
|
6
12
|
EvalTimeoutError,
|
|
@@ -8,15 +14,9 @@ import {
|
|
|
8
14
|
createConcurrencyLimiter,
|
|
9
15
|
createEvalCaseSignal
|
|
10
16
|
} from "./chunk-JMMZICU7.js";
|
|
11
|
-
import {
|
|
12
|
-
errorMessage
|
|
13
|
-
} from "./chunk-ZYXMWEL4.js";
|
|
14
|
-
import {
|
|
15
|
-
EvalOutcome
|
|
16
|
-
} from "./chunk-EJR6VVB3.js";
|
|
17
17
|
import {
|
|
18
18
|
Usage
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-HJ6KTQTZ.js";
|
|
20
20
|
|
|
21
21
|
// src/evals/runner.ts
|
|
22
22
|
var EvalReporterDispatchError = class extends AggregateError {
|
|
@@ -660,4 +660,4 @@ export {
|
|
|
660
660
|
EvalFailFastError,
|
|
661
661
|
runEvalSuite
|
|
662
662
|
};
|
|
663
|
-
//# sourceMappingURL=chunk-
|
|
663
|
+
//# sourceMappingURL=chunk-SIXS4CCU.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
InMemoryVectorStore
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5REZFNZ3.js";
|
|
4
4
|
import {
|
|
5
5
|
retrieveDocuments
|
|
6
6
|
} from "./chunk-HAAGSIZH.js";
|
|
@@ -108,4 +108,4 @@ export {
|
|
|
108
108
|
createToolIndex,
|
|
109
109
|
isToolIndex
|
|
110
110
|
};
|
|
111
|
-
//# sourceMappingURL=chunk-
|
|
111
|
+
//# sourceMappingURL=chunk-VCMBQTR4.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
addUsage,
|
|
3
3
|
evaluationMetadata,
|
|
4
4
|
runJudge
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-63DUKYEG.js";
|
|
6
6
|
import {
|
|
7
7
|
resolveActualText,
|
|
8
8
|
resolveExpected
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from "./chunk-4FIVU53H.js";
|
|
20
20
|
import {
|
|
21
21
|
Usage
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-HJ6KTQTZ.js";
|
|
23
23
|
import {
|
|
24
24
|
isJsonValue
|
|
25
25
|
} from "./chunk-4C7AXYOM.js";
|
|
@@ -1004,4 +1004,4 @@ export {
|
|
|
1004
1004
|
turnRelevancy,
|
|
1005
1005
|
knowledgeRetention
|
|
1006
1006
|
};
|
|
1007
|
-
//# sourceMappingURL=chunk-
|
|
1007
|
+
//# sourceMappingURL=chunk-VPTAGK7G.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Agent
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BVAQJOZX.js";
|
|
4
4
|
import {
|
|
5
5
|
getAgentToolState
|
|
6
6
|
} from "./chunk-A7BXVZXZ.js";
|
|
7
7
|
import {
|
|
8
8
|
markResolvedAgentOptions
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-NA44V5OE.js";
|
|
10
10
|
|
|
11
11
|
// src/agent/resolved-agent.ts
|
|
12
12
|
function createResolvedAgent(options) {
|
|
@@ -45,4 +45,4 @@ export {
|
|
|
45
45
|
createResolvedAgent,
|
|
46
46
|
getResolvedAgentOptions
|
|
47
47
|
};
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
//# sourceMappingURL=chunk-VQTSZ4ZW.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createTool
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WUZG6B3Q.js";
|
|
4
4
|
|
|
5
5
|
// src/tool/think-tool.ts
|
|
6
6
|
import { z } from "zod";
|
|
@@ -21,4 +21,4 @@ function createThinkTool(options = {}) {
|
|
|
21
21
|
export {
|
|
22
22
|
createThinkTool
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
24
|
+
//# sourceMappingURL=chunk-VU6YTPPH.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
attachPreparedToolOwner,
|
|
6
6
|
preparedToolInput,
|
|
7
7
|
withoutPreparedToolInput
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-647TQE3E.js";
|
|
9
9
|
import {
|
|
10
10
|
toProviderJsonSchema
|
|
11
11
|
} from "./chunk-SQAAVYJG.js";
|
|
@@ -55,4 +55,4 @@ function snapshotApprovalRequirement(requirement) {
|
|
|
55
55
|
export {
|
|
56
56
|
createTool
|
|
57
57
|
};
|
|
58
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-WUZG6B3Q.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-H3H74RWJ.js";
|
|
4
4
|
import {
|
|
5
5
|
Usage
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HJ6KTQTZ.js";
|
|
7
7
|
|
|
8
8
|
// src/observability/group.ts
|
|
9
9
|
var AgentObserverDispatchError = class extends AggregateError {
|
|
@@ -245,4 +245,4 @@ export {
|
|
|
245
245
|
ActiveGenerationObservers,
|
|
246
246
|
ActiveToolObservers
|
|
247
247
|
};
|
|
248
|
-
//# sourceMappingURL=chunk-
|
|
248
|
+
//# sourceMappingURL=chunk-YNA3UR42.js.map
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
generateCompletion,
|
|
4
4
|
isStreamingCompletionModel,
|
|
5
5
|
streamCompletion
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-BD2USPK5.js";
|
|
7
|
+
import "../chunk-GSVOMQEE.js";
|
|
8
8
|
import "../chunk-4ONUNWGC.js";
|
|
9
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-2JZV4LUS.js";
|
|
10
10
|
import "../chunk-XQV3XNVT.js";
|
|
11
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-HJ6KTQTZ.js";
|
|
12
12
|
import "../chunk-BONQTXRQ.js";
|
|
13
13
|
import "../chunk-4C7AXYOM.js";
|
|
14
14
|
import "../chunk-SQAAVYJG.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { M as ModelCallOptions } from '../model-call-options-CZkSw_xN.js';
|
|
2
2
|
export { R as RetryContext, a as RetryOptions, b as RetrySetting } from '../retry-CjvSlKGW.js';
|
|
3
|
-
export { C as COMPLETION_PROVIDER_OUTPUT_ERROR_CODE, a as CompletionBaseOptions, b as CompletionInput, c as CompletionProviderOutputError, d as CompletionProviderOutputErrorKind, e as CompletionProviderOutputErrorOptions, f as CompletionStructuredOutputError, g as CompletionStructuredOutputPhase, G as GenerateCompletionOptions, h as GenerateStructuredCompletionOptions, M as MessageMetadataSchema, R as REASONING_EFFORT_CONTROL_ID, i as ReasoningEffortControls, S as StreamCompletionOptions, j as StreamStructuredCompletionOptions, k as createMessageSchema, l as defineCompletionModelControls, m as generateCompletion, n as isJsonValue, o as isMessage, u as isStreamingCompletionModel, v as mergeCompletionControlValues, p as messageSchema, q as messagesSchema, r as parseMessage, s as parseMessages, t as streamCompletion } from '../provider-output-error-
|
|
4
|
-
import { D as Document, M as Message } from '../types-
|
|
5
|
-
export { A as AssistantContentPart, a as AssistantGenerationMetadata, b as AssistantMessage, Z as CompletionCapabilityError, C as CompletionControlValues, c as CompletionFinishReason, d as CompletionModel, _ as CompletionModelCapabilities, e as CompletionModelControls, f as CompletionModelControlsOf, g as CompletionModelInfo, h as CompletionModelSelectControl, i as CompletionModelStreamEvent, j as CompletionRequest, k as CompletionResponse, l as CompletionResult, m as CompletionSource, n as CompletionStreamEvent, $ as CompletionStreamPart, o as CompletionTool, p as ContextUsage, F as FileData, q as FilePart, I as ImageDetail, r as ImagePart, J as JsonObject, s as JsonPrimitive, t as JsonValue, u as ModelContextLimits, N as NoCompletionModelControls, P as ProviderTool, v as ProviderToolCall, R as ReasoningContentType, w as ReasoningDetail, x as ReasoningPart, a0 as StreamingCompletionModel, S as SystemMessage, T as TextPart, a1 as ToolApprovalResponsePart, a2 as ToolCallArgumentsMode, y as ToolCallPart, z as ToolChoice, B as ToolDefinition, a3 as ToolInteractionResponsePart, E as ToolMessage, a4 as ToolQuestionAnswer, a5 as ToolQuestionResponsePart, G as ToolResultContentPart, H as ToolResultOutput, K as ToolResultPart, U as Usage, a6 as UsageDetails, L as UserContentPart, O as UserMessage, a7 as assertCompletionControlsSupported, a8 as assertCompletionRequestSupported, Q as calculateContextUsage, V as getAssistantGenerationMetadata, W as isProviderTool, a9 as reasoningDisplayText, X as resolveModelContextLimits, aa as textFromAssistantContent, Y as withContextUsage } from '../types-
|
|
3
|
+
export { C as COMPLETION_PROVIDER_OUTPUT_ERROR_CODE, a as CompletionBaseOptions, b as CompletionInput, c as CompletionProviderOutputError, d as CompletionProviderOutputErrorKind, e as CompletionProviderOutputErrorOptions, f as CompletionStructuredOutputError, g as CompletionStructuredOutputPhase, G as GenerateCompletionOptions, h as GenerateStructuredCompletionOptions, M as MessageMetadataSchema, R as REASONING_EFFORT_CONTROL_ID, i as ReasoningEffortControls, S as StreamCompletionOptions, j as StreamStructuredCompletionOptions, k as createMessageSchema, l as defineCompletionModelControls, m as generateCompletion, n as isJsonValue, o as isMessage, u as isStreamingCompletionModel, v as mergeCompletionControlValues, p as messageSchema, q as messagesSchema, r as parseMessage, s as parseMessages, t as streamCompletion } from '../provider-output-error-CMVoe1xT.js';
|
|
4
|
+
import { D as Document, M as Message } from '../types-DYqZKDA8.js';
|
|
5
|
+
export { A as AssistantContentPart, a as AssistantGenerationMetadata, b as AssistantMessage, Z as CompletionCapabilityError, C as CompletionControlValues, c as CompletionFinishReason, d as CompletionModel, _ as CompletionModelCapabilities, e as CompletionModelControls, f as CompletionModelControlsOf, g as CompletionModelInfo, h as CompletionModelSelectControl, i as CompletionModelStreamEvent, j as CompletionRequest, k as CompletionResponse, l as CompletionResult, m as CompletionSource, n as CompletionStreamEvent, $ as CompletionStreamPart, o as CompletionTool, p as ContextUsage, F as FileData, q as FilePart, I as ImageDetail, r as ImagePart, J as JsonObject, s as JsonPrimitive, t as JsonValue, u as ModelContextLimits, N as NoCompletionModelControls, P as ProviderTool, v as ProviderToolCall, R as ReasoningContentType, w as ReasoningDetail, x as ReasoningPart, a0 as StreamingCompletionModel, S as SystemMessage, T as TextPart, a1 as ToolApprovalResponsePart, a2 as ToolCallArgumentsMode, y as ToolCallPart, z as ToolChoice, B as ToolDefinition, a3 as ToolInteractionResponsePart, E as ToolMessage, a4 as ToolQuestionAnswer, a5 as ToolQuestionResponsePart, G as ToolResultContentPart, H as ToolResultOutput, K as ToolResultPart, U as Usage, a6 as UsageDetails, L as UserContentPart, O as UserMessage, a7 as assertCompletionControlsSupported, a8 as assertCompletionRequestSupported, Q as calculateContextUsage, V as getAssistantGenerationMetadata, W as isProviderTool, a9 as reasoningDisplayText, X as resolveModelContextLimits, aa as textFromAssistantContent, Y as withContextUsage } from '../types-DYqZKDA8.js';
|
|
6
6
|
import '../zod-schema-C7F4clpm.js';
|
|
7
7
|
import 'zod';
|
|
8
8
|
|
package/dist/completion/index.js
CHANGED
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
generateCompletion,
|
|
14
14
|
isStreamingCompletionModel,
|
|
15
15
|
streamCompletion
|
|
16
|
-
} from "../chunk-
|
|
17
|
-
import "../chunk-
|
|
16
|
+
} from "../chunk-BD2USPK5.js";
|
|
17
|
+
import "../chunk-GSVOMQEE.js";
|
|
18
18
|
import "../chunk-4ONUNWGC.js";
|
|
19
|
-
import "../chunk-
|
|
19
|
+
import "../chunk-2JZV4LUS.js";
|
|
20
20
|
import {
|
|
21
21
|
COMPLETION_PROVIDER_OUTPUT_ERROR_CODE,
|
|
22
22
|
CompletionProviderOutputError
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
resolveModelContextLimits,
|
|
34
34
|
textFromAssistantContent,
|
|
35
35
|
withContextUsage
|
|
36
|
-
} from "../chunk-
|
|
36
|
+
} from "../chunk-HJ6KTQTZ.js";
|
|
37
37
|
import {
|
|
38
38
|
createMessageSchema,
|
|
39
39
|
isMessage,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CompletionStreamAccumulator
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-2JZV4LUS.js";
|
|
4
4
|
import "../chunk-XQV3XNVT.js";
|
|
5
|
-
import "../chunk-
|
|
5
|
+
import "../chunk-HJ6KTQTZ.js";
|
|
6
6
|
import "../chunk-4C7AXYOM.js";
|
|
7
7
|
export {
|
|
8
8
|
CompletionStreamAccumulator
|
package/dist/completion/types.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { b as RetrySetting } from './retry-CjvSlKGW.js';
|
|
2
|
-
import { B as ToolDefinition } from './types-
|
|
2
|
+
import { B as ToolDefinition } from './types-DYqZKDA8.js';
|
|
3
3
|
import { V as VectorMetadata, E as EmbeddingModel, a as EmbeddedDocument } from './types-Cr4uiYo5.js';
|
|
4
|
-
import { A as AnyTool } from './tool-
|
|
5
|
-
import { V as VectorFilter, a as VectorSearchResult, b as VectorInspectRequest, c as VectorInspectPage } from './types-
|
|
4
|
+
import { A as AnyTool } from './tool-D_jV3cRZ.js';
|
|
5
|
+
import { V as VectorFilter, a as VectorSearchResult, b as VectorInspectRequest, c as VectorInspectPage } from './types-ChyQISt-.js';
|
|
6
6
|
|
|
7
7
|
type ToolSearchDocument<Metadata extends VectorMetadata = VectorMetadata> = {
|
|
8
8
|
toolName: string;
|
package/dist/embeddings/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "../chunk-ERN7P6Q4.js";
|
|
2
|
+
import "../chunk-DU4WA6LQ.js";
|
|
2
3
|
import {
|
|
3
4
|
angularDistance,
|
|
4
5
|
chebyshevDistance,
|
|
@@ -14,7 +15,6 @@ import {
|
|
|
14
15
|
embedText,
|
|
15
16
|
embedTexts
|
|
16
17
|
} from "../chunk-HHMLE3TZ.js";
|
|
17
|
-
import "../chunk-DU4WA6LQ.js";
|
|
18
18
|
import "../chunk-4FIVU53H.js";
|
|
19
19
|
import "../chunk-POXHJF3H.js";
|
|
20
20
|
import "../chunk-USRKPEQN.js";
|
|
@@ -9,23 +9,23 @@ import {
|
|
|
9
9
|
promptAlignment,
|
|
10
10
|
summarization,
|
|
11
11
|
turnRelevancy
|
|
12
|
-
} from "../chunk-
|
|
13
|
-
import "../chunk-
|
|
12
|
+
} from "../chunk-VPTAGK7G.js";
|
|
13
|
+
import "../chunk-63DUKYEG.js";
|
|
14
14
|
import "../chunk-ZPXOBQDS.js";
|
|
15
|
+
import "../chunk-3P3YVJ7V.js";
|
|
16
|
+
import "../chunk-3P65RSBB.js";
|
|
15
17
|
import "../chunk-ZYXMWEL4.js";
|
|
16
18
|
import "../chunk-EJR6VVB3.js";
|
|
17
|
-
import "../chunk-3P3YVJ7V.js";
|
|
18
|
-
import "../chunk-UOGM62JL.js";
|
|
19
19
|
import "../chunk-TP3MCUXS.js";
|
|
20
20
|
import "../chunk-6RQYWZI3.js";
|
|
21
21
|
import "../chunk-NF6WBPFG.js";
|
|
22
22
|
import "../chunk-4FIVU53H.js";
|
|
23
|
-
import "../chunk-
|
|
24
|
-
import "../chunk-
|
|
23
|
+
import "../chunk-BD2USPK5.js";
|
|
24
|
+
import "../chunk-GSVOMQEE.js";
|
|
25
25
|
import "../chunk-4ONUNWGC.js";
|
|
26
|
-
import "../chunk-
|
|
26
|
+
import "../chunk-2JZV4LUS.js";
|
|
27
27
|
import "../chunk-XQV3XNVT.js";
|
|
28
|
-
import "../chunk-
|
|
28
|
+
import "../chunk-HJ6KTQTZ.js";
|
|
29
29
|
import "../chunk-BONQTXRQ.js";
|
|
30
30
|
import "../chunk-4C7AXYOM.js";
|
|
31
31
|
import "../chunk-SQAAVYJG.js";
|
package/dist/evals/cli.js
CHANGED
|
@@ -7,21 +7,21 @@ import {
|
|
|
7
7
|
formatEvalResult,
|
|
8
8
|
printEvalResult,
|
|
9
9
|
runEvalCli
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import "../chunk-
|
|
10
|
+
} from "../chunk-KX2TRKO2.js";
|
|
11
|
+
import "../chunk-SIXS4CCU.js";
|
|
12
12
|
import "../chunk-PHLGGRHC.js";
|
|
13
|
-
import "../chunk-JMMZICU7.js";
|
|
14
13
|
import "../chunk-ZYXMWEL4.js";
|
|
15
14
|
import "../chunk-EJR6VVB3.js";
|
|
15
|
+
import "../chunk-JMMZICU7.js";
|
|
16
16
|
import "../chunk-TP3MCUXS.js";
|
|
17
17
|
import "../chunk-6RQYWZI3.js";
|
|
18
18
|
import "../chunk-NF6WBPFG.js";
|
|
19
|
-
import "../chunk-
|
|
20
|
-
import "../chunk-
|
|
19
|
+
import "../chunk-BD2USPK5.js";
|
|
20
|
+
import "../chunk-GSVOMQEE.js";
|
|
21
21
|
import "../chunk-4ONUNWGC.js";
|
|
22
|
-
import "../chunk-
|
|
22
|
+
import "../chunk-2JZV4LUS.js";
|
|
23
23
|
import "../chunk-XQV3XNVT.js";
|
|
24
|
-
import "../chunk-
|
|
24
|
+
import "../chunk-HJ6KTQTZ.js";
|
|
25
25
|
import "../chunk-BONQTXRQ.js";
|
|
26
26
|
import "../chunk-4C7AXYOM.js";
|
|
27
27
|
import "../chunk-SQAAVYJG.js";
|
package/dist/evals/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { U as Usage, J as JsonObject, d as CompletionModel, M as Message } from '../types-
|
|
1
|
+
import { U as Usage, J as JsonObject, d as CompletionModel, M as Message } from '../types-DYqZKDA8.js';
|
|
2
2
|
import { Z as ZodSchema } from '../zod-schema-C7F4clpm.js';
|
|
3
|
-
import { Z as AgentRunPromptRef, g as AgentInteractionOutcome, n as AgentResponse, o as AgentRunOptions, l as AgentOutcome } from '../middleware-
|
|
3
|
+
import { Z as AgentRunPromptRef, g as AgentInteractionOutcome, n as AgentResponse, o as AgentRunOptions, l as AgentOutcome } from '../middleware-DORuwSy-.js';
|
|
4
4
|
import { AgentInteractionRequest, AgentInteractionResponse } from '../agent/interactions/index.js';
|
|
5
5
|
import { E as EmbeddingModel } from '../types-Cr4uiYo5.js';
|
|
6
6
|
import '../model-call-options-CZkSw_xN.js';
|
|
7
7
|
import 'zod';
|
|
8
|
-
import '../types-
|
|
8
|
+
import '../types-CqiX-4_C.js';
|
|
9
9
|
import '../retry-CjvSlKGW.js';
|
|
10
|
-
import '../types-
|
|
11
|
-
import '../tool-
|
|
10
|
+
import '../types-DhWxTobb.js';
|
|
11
|
+
import '../tool-D_jV3cRZ.js';
|
|
12
12
|
|
|
13
13
|
type EvalOutcomeOptions = {
|
|
14
14
|
comment?: string | undefined;
|