@anvia/core 1.6.1 → 1.7.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 +4 -0
- package/dist/agent/agent-tool.js +4 -4
- package/dist/agent/agent.js +17 -17
- package/dist/agent/index.d.ts +8 -8
- package/dist/agent/index.js +21 -21
- package/dist/agent/resolve-options.js +6 -6
- package/dist/agent/resolved-agent.js +18 -18
- package/dist/agent/team/agent-team.js +21 -21
- package/dist/agent/team/index.js +21 -21
- package/dist/agent/tool-catalog.js +6 -6
- package/dist/{agent-BUc18r6A.d.ts → agent-BOoZ3jbr.d.ts} +5 -5
- package/dist/chunk-5H5EHU5O.js +7 -0
- package/dist/chunk-5H5EHU5O.js.map +1 -0
- package/dist/{chunk-5CQRCTIN.js → chunk-5ZS3DPPC.js} +4 -4
- package/dist/{chunk-LGMH6PCB.js → chunk-6EJHZEXU.js} +6 -6
- package/dist/{chunk-7G3YQQVE.js → chunk-7NYFTW7I.js} +3 -3
- package/dist/{chunk-B57NNDEF.js → chunk-C36RVQHF.js} +27 -8
- package/dist/chunk-C36RVQHF.js.map +1 -0
- package/dist/{chunk-CJKGTEN4.js → chunk-E5MIZ6Z5.js} +2 -2
- package/dist/{chunk-T3ZOZEAB.js → chunk-IZH2ZAE3.js} +2 -2
- package/dist/{chunk-AQ47TF5K.js → chunk-JJSMONFE.js} +2 -2
- package/dist/{chunk-Y365ABZY.js → chunk-JU3RX364.js} +2 -2
- package/dist/{chunk-O7NN7PF4.js → chunk-KRQ2HFXW.js} +3 -3
- package/dist/{chunk-PV6KJWYO.js → chunk-MYHGOXHQ.js} +2 -2
- package/dist/{chunk-XJ5X3NI4.js → chunk-OBM7JJCK.js} +2 -2
- package/dist/{chunk-LWF6AHDG.js → chunk-OXIK4SIH.js} +2 -2
- package/dist/{chunk-KITX3HDN.js → chunk-SBWSXEIH.js} +1 -1
- package/dist/chunk-SBWSXEIH.js.map +1 -0
- package/dist/{chunk-HILMAFZK.js → chunk-VDHMFJCD.js} +2 -2
- package/dist/{chunk-SCFWN3T2.js → chunk-VHPT2C4P.js} +1 -1
- package/dist/chunk-VHPT2C4P.js.map +1 -0
- package/dist/{chunk-647TQE3E.js → chunk-WCJRGYF7.js} +5 -5
- package/dist/{chunk-5TGVDMGM.js → chunk-XH2CVR4V.js} +2 -2
- package/dist/{chunk-7V3DKQTI.js → chunk-Y7Z5EHJD.js} +5 -5
- package/dist/{chunk-6E6ABRJ6.js → chunk-ZMAF3I4H.js} +2 -2
- package/dist/{chunk-BI3T62GL.js → chunk-ZRW27E32.js} +24 -17
- package/dist/chunk-ZRW27E32.js.map +1 -0
- package/dist/{dynamic-tools-BXXLc34l.d.ts → dynamic-tools-B3OjYyhC.d.ts} +1 -1
- package/dist/evals/index.d.ts +2 -2
- package/dist/index.d.ts +7 -7
- package/dist/index.js +26 -26
- package/dist/internal/agent-runtime/agent-run.js +13 -13
- package/dist/internal/agent-runtime/execution.js +7 -0
- package/dist/internal/agent-runtime/execution.js.map +1 -0
- package/dist/internal/agent-runtime/prepared-tool-call.js +2 -2
- package/dist/internal/agent-runtime/retrieval.js +4 -4
- package/dist/internal/agent-runtime/run-options.js +1 -1
- package/dist/internal/agent-runtime/tool-execution.js +9 -9
- package/dist/internal/agent.d.ts +30 -8
- package/dist/internal/agent.js +22 -18
- package/dist/internal/team-runtime/run.js +20 -20
- package/dist/internal/team-runtime/tools.js +4 -4
- package/dist/mcp/index.d.ts +3 -3
- package/dist/{middleware-BxzML2hK.d.ts → middleware-BNxyEpUX.d.ts} +1 -1
- package/dist/observability/index.d.ts +2 -2
- package/dist/pipeline/index.d.ts +6 -6
- package/dist/skills/index.d.ts +3 -3
- package/dist/skills/index.js +10 -10
- package/dist/skills/load.js +10 -10
- package/dist/skills/tools.js +9 -9
- package/dist/speech-generation/index.js +1 -1
- package/dist/{think-tool-2unWbq1w.d.ts → think-tool-DJbtUDZm.d.ts} +1 -1
- package/dist/tool/create-tool.js +3 -3
- package/dist/tool/dynamic-tools.js +5 -5
- package/dist/tool/index.d.ts +4 -4
- package/dist/tool/index.js +12 -12
- 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-D_jV3cRZ.d.ts → tool-W1cAPuRF.d.ts} +2 -0
- package/dist/{types-0t3BczrD.d.ts → types-94Q2mPRa.d.ts} +1 -1
- package/dist/{types-Cu2tEf3V.d.ts → types-CIG2loIE.d.ts} +1 -1
- package/dist/vector-store/index.d.ts +1 -1
- package/dist/vector-store/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-B57NNDEF.js.map +0 -1
- package/dist/chunk-BI3T62GL.js.map +0 -1
- package/dist/chunk-KITX3HDN.js.map +0 -1
- package/dist/chunk-SCFWN3T2.js.map +0 -1
- /package/dist/{chunk-5CQRCTIN.js.map → chunk-5ZS3DPPC.js.map} +0 -0
- /package/dist/{chunk-LGMH6PCB.js.map → chunk-6EJHZEXU.js.map} +0 -0
- /package/dist/{chunk-7G3YQQVE.js.map → chunk-7NYFTW7I.js.map} +0 -0
- /package/dist/{chunk-CJKGTEN4.js.map → chunk-E5MIZ6Z5.js.map} +0 -0
- /package/dist/{chunk-T3ZOZEAB.js.map → chunk-IZH2ZAE3.js.map} +0 -0
- /package/dist/{chunk-AQ47TF5K.js.map → chunk-JJSMONFE.js.map} +0 -0
- /package/dist/{chunk-Y365ABZY.js.map → chunk-JU3RX364.js.map} +0 -0
- /package/dist/{chunk-O7NN7PF4.js.map → chunk-KRQ2HFXW.js.map} +0 -0
- /package/dist/{chunk-PV6KJWYO.js.map → chunk-MYHGOXHQ.js.map} +0 -0
- /package/dist/{chunk-XJ5X3NI4.js.map → chunk-OBM7JJCK.js.map} +0 -0
- /package/dist/{chunk-LWF6AHDG.js.map → chunk-OXIK4SIH.js.map} +0 -0
- /package/dist/{chunk-HILMAFZK.js.map → chunk-VDHMFJCD.js.map} +0 -0
- /package/dist/{chunk-647TQE3E.js.map → chunk-WCJRGYF7.js.map} +0 -0
- /package/dist/{chunk-5TGVDMGM.js.map → chunk-XH2CVR4V.js.map} +0 -0
- /package/dist/{chunk-7V3DKQTI.js.map → chunk-Y7Z5EHJD.js.map} +0 -0
- /package/dist/{chunk-6E6ABRJ6.js.map → chunk-ZMAF3I4H.js.map} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createSkillTools
|
|
3
|
+
} from "./chunk-OBM7JJCK.js";
|
|
1
4
|
import {
|
|
2
5
|
skillInstructions
|
|
3
6
|
} from "./chunk-JBQNCUXA.js";
|
|
4
|
-
import {
|
|
5
|
-
createSkillTools
|
|
6
|
-
} from "./chunk-XJ5X3NI4.js";
|
|
7
7
|
|
|
8
8
|
// src/skills/load.ts
|
|
9
9
|
async function loadSkills(loaders) {
|
|
@@ -26,4 +26,4 @@ async function loadSkills(loaders) {
|
|
|
26
26
|
export {
|
|
27
27
|
loadSkills
|
|
28
28
|
};
|
|
29
|
-
//# sourceMappingURL=chunk-
|
|
29
|
+
//# sourceMappingURL=chunk-5ZS3DPPC.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentRun
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZRW27E32.js";
|
|
4
4
|
import {
|
|
5
5
|
normalizeMemoryScope
|
|
6
6
|
} from "./chunk-LAIATEUB.js";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./chunk-NPJ2T3L5.js";
|
|
13
13
|
import {
|
|
14
14
|
prepareAgentTools
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-JJSMONFE.js";
|
|
16
16
|
import {
|
|
17
17
|
getRegisteredAgentTool,
|
|
18
18
|
registerAgentToolState
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from "./chunk-GLMYZ6OA.js";
|
|
23
23
|
import {
|
|
24
24
|
resolveAgentOptions
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-OXIK4SIH.js";
|
|
26
26
|
import {
|
|
27
27
|
cloneFrozenPlainData,
|
|
28
28
|
snapshotAgentContext,
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
} from "./chunk-KY4VXIN2.js";
|
|
36
36
|
import {
|
|
37
37
|
createAgentTool
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-VDHMFJCD.js";
|
|
39
39
|
import {
|
|
40
40
|
isStreamingCompletionModel
|
|
41
41
|
} from "./chunk-HG6ASDNI.js";
|
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
} from "./chunk-4ONUNWGC.js";
|
|
45
45
|
import {
|
|
46
46
|
prepareToolCall
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-WCJRGYF7.js";
|
|
48
48
|
import {
|
|
49
49
|
ToolNotFoundError
|
|
50
50
|
} from "./chunk-J6S6MT7O.js";
|
|
@@ -155,4 +155,4 @@ var Agent = class {
|
|
|
155
155
|
export {
|
|
156
156
|
Agent
|
|
157
157
|
};
|
|
158
|
-
//# sourceMappingURL=chunk-
|
|
158
|
+
//# sourceMappingURL=chunk-6EJHZEXU.js.map
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
} from "./chunk-X6WS3XWL.js";
|
|
4
4
|
import {
|
|
5
5
|
TeamRun
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-Y7Z5EHJD.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-6EJHZEXU.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-7NYFTW7I.js.map
|
|
@@ -2,12 +2,12 @@ import {
|
|
|
2
2
|
AgentInteractionSignal,
|
|
3
3
|
ToolExecutionSuspension
|
|
4
4
|
} from "./chunk-5IURMWFN.js";
|
|
5
|
+
import {
|
|
6
|
+
isQuestionTool
|
|
7
|
+
} from "./chunk-IZH2ZAE3.js";
|
|
5
8
|
import {
|
|
6
9
|
isSkillTool
|
|
7
10
|
} from "./chunk-2NLINXRF.js";
|
|
8
|
-
import {
|
|
9
|
-
isQuestionTool
|
|
10
|
-
} from "./chunk-T3ZOZEAB.js";
|
|
11
11
|
import {
|
|
12
12
|
runControl,
|
|
13
13
|
toolCallControl
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
import {
|
|
31
31
|
prepareToolCall,
|
|
32
32
|
prepareToolCallFromInput
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-WCJRGYF7.js";
|
|
34
34
|
import {
|
|
35
35
|
assertToolApprovalRequirement,
|
|
36
36
|
toolMayRequireApproval
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
normalizeToolResultOutput,
|
|
41
41
|
parseToolArgs,
|
|
42
42
|
toolResultContentToText
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-VHPT2C4P.js";
|
|
44
44
|
import {
|
|
45
45
|
Usage
|
|
46
46
|
} from "./chunk-HJ6KTQTZ.js";
|
|
@@ -65,7 +65,7 @@ function sanitizeToolErrorMessage(error) {
|
|
|
65
65
|
return String(error);
|
|
66
66
|
}
|
|
67
67
|
var ToolCallExecutor = class {
|
|
68
|
-
constructor(agent, activeHook, approvalHandler, lifecycle, runContext, concurrency, requestMiddlewares, abortSignal, cancel) {
|
|
68
|
+
constructor(agent, activeHook, approvalHandler, lifecycle, runContext, concurrency, requestMiddlewares, abortSignal, cancel, execution) {
|
|
69
69
|
this.agent = agent;
|
|
70
70
|
this.activeHook = activeHook;
|
|
71
71
|
this.approvalHandler = approvalHandler;
|
|
@@ -75,6 +75,7 @@ var ToolCallExecutor = class {
|
|
|
75
75
|
this.requestMiddlewares = requestMiddlewares;
|
|
76
76
|
this.abortSignal = abortSignal;
|
|
77
77
|
this.cancel = cancel;
|
|
78
|
+
this.execution = execution;
|
|
78
79
|
}
|
|
79
80
|
agent;
|
|
80
81
|
activeHook;
|
|
@@ -85,6 +86,7 @@ var ToolCallExecutor = class {
|
|
|
85
86
|
requestMiddlewares;
|
|
86
87
|
abortSignal;
|
|
87
88
|
cancel;
|
|
89
|
+
execution;
|
|
88
90
|
async execute(toolCalls, onResult, onStreamEvent, observation) {
|
|
89
91
|
assertCompletionResponseIntegrity({
|
|
90
92
|
response: {
|
|
@@ -608,9 +610,26 @@ var ToolCallExecutor = class {
|
|
|
608
610
|
throw error;
|
|
609
611
|
}
|
|
610
612
|
}
|
|
611
|
-
|
|
613
|
+
runApprovedToolCall(prepared, toolCall, hookArgs, effectiveArgs, toolObservation, observation, onStreamEvent) {
|
|
614
|
+
const execute = (context) => this.runUncachedToolCall(
|
|
615
|
+
prepared,
|
|
616
|
+
toolCall,
|
|
617
|
+
hookArgs,
|
|
618
|
+
effectiveArgs,
|
|
619
|
+
toolObservation,
|
|
620
|
+
observation,
|
|
621
|
+
onStreamEvent,
|
|
622
|
+
context
|
|
623
|
+
);
|
|
624
|
+
return this.execution === void 0 ? execute() : this.execution.tool(
|
|
625
|
+
{ turn: observation?.turn ?? 0, toolCall, args: effectiveArgs },
|
|
626
|
+
execute
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
async runUncachedToolCall(prepared, toolCall, hookArgs, effectiveArgs, toolObservation, observation, onStreamEvent, context) {
|
|
612
630
|
try {
|
|
613
631
|
const toolContext = {
|
|
632
|
+
...context,
|
|
614
633
|
abortSignal: this.abortSignal,
|
|
615
634
|
emitStreamEvent: async (event) => {
|
|
616
635
|
let streamEventArgs = {
|
|
@@ -948,4 +967,4 @@ function agentToolEventPayload(toolCall, internalCallId, event) {
|
|
|
948
967
|
export {
|
|
949
968
|
ToolCallExecutor
|
|
950
969
|
};
|
|
951
|
-
//# sourceMappingURL=chunk-
|
|
970
|
+
//# sourceMappingURL=chunk-C36RVQHF.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 type { AgentRunExecution, AgentToolExecutionResult } from \"./execution\";\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 private readonly execution?: AgentRunExecution,\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 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 const execute = (context?: Pick<ToolCallContext, \"operationId\">) =>\n this.runUncachedToolCall(\n prepared,\n toolCall,\n hookArgs,\n effectiveArgs,\n toolObservation,\n observation,\n onStreamEvent,\n context,\n );\n return this.execution === undefined\n ? execute()\n : this.execution.tool(\n { turn: observation?.turn ?? 0, toolCall, args: effectiveArgs },\n execute,\n );\n }\n\n private async runUncachedToolCall(\n prepared: PreparedToolCall,\n toolCall: ToolCallPart,\n hookArgs: ToolHookArgs,\n effectiveArgs: string,\n toolObservation: ToolObserverScope,\n observation: ToolExecutionObservation | undefined,\n onStreamEvent: ((event: AgentToolEventPayload) => void) | undefined,\n context: Pick<ToolCallContext, \"operationId\"> | undefined,\n ): Promise<AgentToolExecutionResult> {\n try {\n const toolContext: ToolCallContext = {\n ...context,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GA,SAAS,yBA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
|
|
4
4
|
|
|
5
5
|
// src/internal/team-runtime/tools.ts
|
|
6
6
|
import { z } from "zod";
|
|
@@ -64,4 +64,4 @@ export {
|
|
|
64
64
|
teamTools,
|
|
65
65
|
TEAM_INSTRUCTIONS
|
|
66
66
|
};
|
|
67
|
-
//# sourceMappingURL=chunk-
|
|
67
|
+
//# sourceMappingURL=chunk-E5MIZ6Z5.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createTool
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JU3RX364.js";
|
|
4
4
|
|
|
5
5
|
// src/tool/question-tool.ts
|
|
6
6
|
import { z } from "zod";
|
|
@@ -44,4 +44,4 @@ export {
|
|
|
44
44
|
createQuestionTool,
|
|
45
45
|
isQuestionTool
|
|
46
46
|
};
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
47
|
+
//# sourceMappingURL=chunk-IZH2ZAE3.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isToolIndex
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XH2CVR4V.js";
|
|
4
4
|
import {
|
|
5
5
|
isMcpTool
|
|
6
6
|
} from "./chunk-PLDJCCVL.js";
|
|
@@ -165,4 +165,4 @@ function snapshotToolIndex(index) {
|
|
|
165
165
|
export {
|
|
166
166
|
prepareAgentTools
|
|
167
167
|
};
|
|
168
|
-
//# sourceMappingURL=chunk-
|
|
168
|
+
//# sourceMappingURL=chunk-JJSMONFE.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
attachPreparedToolOwner,
|
|
3
3
|
preparedToolInput,
|
|
4
4
|
withoutPreparedToolInput
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-WCJRGYF7.js";
|
|
6
6
|
import {
|
|
7
7
|
assertToolApprovalRequirement
|
|
8
8
|
} from "./chunk-YZVFIW5D.js";
|
|
@@ -55,4 +55,4 @@ function snapshotApprovalRequirement(requirement) {
|
|
|
55
55
|
export {
|
|
56
56
|
createTool
|
|
57
57
|
};
|
|
58
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-JU3RX364.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Agent
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6EJHZEXU.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-OXIK4SIH.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-KRQ2HFXW.js.map
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "./chunk-5V533R7F.js";
|
|
17
17
|
import {
|
|
18
18
|
createTool
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-JU3RX364.js";
|
|
20
20
|
|
|
21
21
|
// src/vector-store/index.ts
|
|
22
22
|
import { z } from "zod";
|
|
@@ -233,4 +233,4 @@ export {
|
|
|
233
233
|
InMemoryVectorStore,
|
|
234
234
|
createVectorSearchTool
|
|
235
235
|
};
|
|
236
|
-
//# sourceMappingURL=chunk-
|
|
236
|
+
//# sourceMappingURL=chunk-MYHGOXHQ.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-2NLINXRF.js";
|
|
4
4
|
import {
|
|
5
5
|
createTool
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JU3RX364.js";
|
|
7
7
|
import {
|
|
8
8
|
abortError,
|
|
9
9
|
throwIfAborted
|
|
@@ -245,4 +245,4 @@ function appendLimited(current, chunk) {
|
|
|
245
245
|
export {
|
|
246
246
|
createSkillTools
|
|
247
247
|
};
|
|
248
|
-
//# sourceMappingURL=chunk-
|
|
248
|
+
//# sourceMappingURL=chunk-OBM7JJCK.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-6BTJC3ES.js";
|
|
7
7
|
import {
|
|
8
8
|
isToolIndex
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XH2CVR4V.js";
|
|
10
10
|
import {
|
|
11
11
|
isMcpTool
|
|
12
12
|
} from "./chunk-PLDJCCVL.js";
|
|
@@ -109,4 +109,4 @@ export {
|
|
|
109
109
|
resolveAgentOptions,
|
|
110
110
|
markResolvedAgentOptions
|
|
111
111
|
};
|
|
112
|
-
//# sourceMappingURL=chunk-
|
|
112
|
+
//# sourceMappingURL=chunk-OXIK4SIH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internal/agent-runtime/run-options.ts"],"sourcesContent":["import type { Message } from \"../../completion\";\nimport type { AgentHook } from \"../../hooks\";\nimport type { MemoryCompactionInfo } from \"../../memory\";\nimport type { AgentRunExecution } from \"./execution\";\n\nconst internalAgentRunOptions = Symbol(\"internalAgentRunOptions\");\n\nexport type InternalAgentRunOptions = {\n /** Persistence boundaries for non-streaming execution. */\n execution?: AgentRunExecution | undefined;\n hook?: AgentHook | undefined;\n onFailure?: ((failure: { error: unknown; messages: readonly Message[] }) => void) | undefined;\n onMemoryCompaction?: ((compaction: MemoryCompactionInfo) => void | Promise<void>) | undefined;\n runId?: string | undefined;\n beforeFinish?: (() => void | Promise<void>) | undefined;\n onSteeringApplied?: ((id: string) => void) | undefined;\n};\n\ntype AgentRunOptionsWithInternal = {\n [internalAgentRunOptions]?: InternalAgentRunOptions;\n};\n\nexport function withInternalAgentRunOptions<T extends object>(\n options: T,\n internal: InternalAgentRunOptions,\n): T {\n return {\n ...options,\n [internalAgentRunOptions]: internal,\n };\n}\n\nexport function getInternalAgentRunOptions(options: object): InternalAgentRunOptions | undefined {\n return (options as AgentRunOptionsWithInternal)[internalAgentRunOptions];\n}\n"],"mappings":";AAKA,IAAM,0BAA0B,uBAAO,yBAAyB;AAiBzD,SAAS,4BACd,SACA,UACG;AACH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,CAAC,uBAAuB,GAAG;AAAA,EAC7B;AACF;AAEO,SAAS,2BAA2B,SAAsD;AAC/F,SAAQ,QAAwC,uBAAuB;AACzE;","names":[]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-HG6ASDNI.js";
|
|
4
4
|
import {
|
|
5
5
|
createTool
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JU3RX364.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-VDHMFJCD.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 /** Stable external-operation identity supplied by a durable execution runtime. */\n operationId?: string | undefined;\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":";;;;;;;;AAqFA,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,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
normalizeToolResultOutput,
|
|
3
|
-
parseToolArgs
|
|
4
|
-
} from "./chunk-SCFWN3T2.js";
|
|
5
1
|
import {
|
|
6
2
|
ToolCallError,
|
|
7
3
|
ToolJsonError
|
|
8
4
|
} from "./chunk-J6S6MT7O.js";
|
|
5
|
+
import {
|
|
6
|
+
normalizeToolResultOutput,
|
|
7
|
+
parseToolArgs
|
|
8
|
+
} from "./chunk-VHPT2C4P.js";
|
|
9
9
|
|
|
10
10
|
// src/internal/agent-runtime/prepared-tool-call.ts
|
|
11
11
|
var preparedToolInputSymbol = /* @__PURE__ */ Symbol("preparedToolInput");
|
|
@@ -90,4 +90,4 @@ export {
|
|
|
90
90
|
prepareToolCall,
|
|
91
91
|
prepareToolCallFromInput
|
|
92
92
|
};
|
|
93
|
-
//# sourceMappingURL=chunk-
|
|
93
|
+
//# sourceMappingURL=chunk-WCJRGYF7.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
InMemoryVectorStore
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MYHGOXHQ.js";
|
|
4
4
|
import {
|
|
5
5
|
retrieveDocuments
|
|
6
6
|
} from "./chunk-CB2L2NIQ.js";
|
|
@@ -108,4 +108,4 @@ export {
|
|
|
108
108
|
createToolIndex,
|
|
109
109
|
isToolIndex
|
|
110
110
|
};
|
|
111
|
-
//# sourceMappingURL=chunk-
|
|
111
|
+
//# sourceMappingURL=chunk-XH2CVR4V.js.map
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
TEAM_INSTRUCTIONS,
|
|
13
13
|
teamTools
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-E5MIZ6Z5.js";
|
|
15
15
|
import {
|
|
16
16
|
AgentTeamInteractionError,
|
|
17
17
|
AgentTeamLimitError
|
|
@@ -19,13 +19,13 @@ import {
|
|
|
19
19
|
import {
|
|
20
20
|
createResolvedAgent,
|
|
21
21
|
getResolvedAgentOptions
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-KRQ2HFXW.js";
|
|
23
23
|
import {
|
|
24
24
|
AgentRun
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-ZRW27E32.js";
|
|
26
26
|
import {
|
|
27
27
|
withInternalAgentRunOptions
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-SBWSXEIH.js";
|
|
29
29
|
import {
|
|
30
30
|
assertAgentInteractionResponse,
|
|
31
31
|
parseAgentInteractionResponse
|
|
@@ -619,4 +619,4 @@ var TeamRun = class {
|
|
|
619
619
|
export {
|
|
620
620
|
TeamRun
|
|
621
621
|
};
|
|
622
|
-
//# sourceMappingURL=chunk-
|
|
622
|
+
//# sourceMappingURL=chunk-Y7Z5EHJD.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createTool
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JU3RX364.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-ZMAF3I4H.js.map
|