@tyvm/knowhow 0.0.128 → 0.0.130
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/package.json +5 -4
- package/scripts/cache-miss-debug.ts +365 -0
- package/src/agents/base/base.ts +159 -59
- package/src/agents/tools/execCommand.ts +26 -6
- package/src/agents/tools/index.ts +1 -0
- package/src/agents/tools/list.ts +2 -0
- package/src/agents/tools/minimal/callTool.ts +45 -0
- package/src/agents/tools/minimal/definitions.ts +50 -0
- package/src/agents/tools/minimal/index.ts +3 -0
- package/src/agents/tools/minimal/inspectTools.ts +27 -0
- package/src/agents/tools/skills.ts +79 -0
- package/src/chat/modules/AgentModule.ts +111 -9
- package/src/cli.ts +4 -0
- package/src/clients/anthropic.ts +59 -1
- package/src/clients/contextLimits.ts +9 -0
- package/src/clients/index.ts +6 -0
- package/src/clients/meta.ts +18 -0
- package/src/clients/openai.ts +28 -5
- package/src/clients/pricing/anthropic.ts +13 -0
- package/src/clients/pricing/fireworks.ts +18 -12
- package/src/clients/pricing/index.ts +1 -0
- package/src/clients/pricing/meta.ts +12 -0
- package/src/clients/pricing/openai.ts +16 -0
- package/src/clients/pricing/xai.ts +3 -0
- package/src/clients/types.ts +27 -4
- package/src/clients/xai.ts +2 -2
- package/src/commands/agent.ts +19 -0
- package/src/commands/behaviors.ts +47 -0
- package/src/commands/services.ts +7 -3
- package/src/commands/skills.ts +71 -0
- package/src/index.ts +2 -0
- package/src/plugins/PluginBase.ts +0 -2
- package/src/plugins/SkillsPlugin.ts +11 -124
- package/src/plugins/language.ts +0 -1
- package/src/plugins/plugins.ts +24 -13
- package/src/plugins/types.ts +8 -2
- package/src/processors/MinimalToolsMessageProcessor.ts +113 -0
- package/src/processors/TokenCompressor.ts +21 -4
- package/src/processors/index.ts +7 -1
- package/src/services/AgentSyncFs.ts +49 -0
- package/src/services/AgentSyncKnowhowWeb.ts +1 -1
- package/src/services/BehaviorsService.ts +432 -0
- package/src/services/KnowhowClient.ts +62 -1
- package/src/services/LazyToolsService.ts +12 -0
- package/src/services/MinimalToolsService.ts +167 -0
- package/src/services/SkillsService.ts +622 -0
- package/src/services/Tools.ts +11 -0
- package/src/services/index.ts +9 -2
- package/src/services/modules/types.ts +2 -0
- package/src/worker.ts +7 -0
- package/tests/processors/TokenCompressor.test.ts +45 -0
- package/tests/unit/services/MinimalToolsService.test.ts +424 -0
- package/ts_build/package.json +5 -4
- package/ts_build/src/agents/base/base.d.ts +13 -2
- package/ts_build/src/agents/base/base.js +91 -35
- package/ts_build/src/agents/base/base.js.map +1 -1
- package/ts_build/src/agents/tools/execCommand.d.ts +1 -1
- package/ts_build/src/agents/tools/execCommand.js +18 -5
- package/ts_build/src/agents/tools/execCommand.js.map +1 -1
- package/ts_build/src/agents/tools/index.d.ts +1 -0
- package/ts_build/src/agents/tools/index.js +1 -0
- package/ts_build/src/agents/tools/index.js.map +1 -1
- package/ts_build/src/agents/tools/list.js +2 -0
- package/ts_build/src/agents/tools/list.js.map +1 -1
- package/ts_build/src/agents/tools/minimal/callTool.d.ts +5 -0
- package/ts_build/src/agents/tools/minimal/callTool.js +28 -0
- package/ts_build/src/agents/tools/minimal/callTool.js.map +1 -0
- package/ts_build/src/agents/tools/minimal/definitions.d.ts +4 -0
- package/ts_build/src/agents/tools/minimal/definitions.js +46 -0
- package/ts_build/src/agents/tools/minimal/definitions.js.map +1 -0
- package/ts_build/src/agents/tools/minimal/index.d.ts +3 -0
- package/ts_build/src/agents/tools/minimal/index.js +20 -0
- package/ts_build/src/agents/tools/minimal/index.js.map +1 -0
- package/ts_build/src/agents/tools/minimal/inspectTools.d.ts +2 -0
- package/ts_build/src/agents/tools/minimal/inspectTools.js +15 -0
- package/ts_build/src/agents/tools/minimal/inspectTools.js.map +1 -0
- package/ts_build/src/agents/tools/skills.d.ts +33 -0
- package/ts_build/src/agents/tools/skills.js +62 -0
- package/ts_build/src/agents/tools/skills.js.map +1 -0
- package/ts_build/src/chat/modules/AgentModule.d.ts +2 -0
- package/ts_build/src/chat/modules/AgentModule.js +77 -2
- package/ts_build/src/chat/modules/AgentModule.js.map +1 -1
- package/ts_build/src/chat/modules/CustomCommandsModule.d.ts +1 -1
- package/ts_build/src/cli.js +4 -0
- package/ts_build/src/cli.js.map +1 -1
- package/ts_build/src/clients/anthropic.d.ts +2 -0
- package/ts_build/src/clients/anthropic.js +35 -0
- package/ts_build/src/clients/anthropic.js.map +1 -1
- package/ts_build/src/clients/contextLimits.js +8 -0
- package/ts_build/src/clients/contextLimits.js.map +1 -1
- package/ts_build/src/clients/index.d.ts +1 -0
- package/ts_build/src/clients/index.js +6 -0
- package/ts_build/src/clients/index.js.map +1 -1
- package/ts_build/src/clients/meta.d.ts +4 -0
- package/ts_build/src/clients/meta.js +15 -0
- package/ts_build/src/clients/meta.js.map +1 -0
- package/ts_build/src/clients/openai.d.ts +1 -0
- package/ts_build/src/clients/openai.js +25 -5
- package/ts_build/src/clients/openai.js.map +1 -1
- package/ts_build/src/clients/pricing/anthropic.d.ts +4 -0
- package/ts_build/src/clients/pricing/anthropic.js +12 -0
- package/ts_build/src/clients/pricing/anthropic.js.map +1 -1
- package/ts_build/src/clients/pricing/fireworks.d.ts +2 -5
- package/ts_build/src/clients/pricing/fireworks.js +13 -11
- package/ts_build/src/clients/pricing/fireworks.js.map +1 -1
- package/ts_build/src/clients/pricing/index.d.ts +1 -0
- package/ts_build/src/clients/pricing/index.js +5 -2
- package/ts_build/src/clients/pricing/index.js.map +1 -1
- package/ts_build/src/clients/pricing/meta.d.ts +6 -0
- package/ts_build/src/clients/pricing/meta.js +8 -0
- package/ts_build/src/clients/pricing/meta.js.map +1 -0
- package/ts_build/src/clients/pricing/openai.d.ts +3 -0
- package/ts_build/src/clients/pricing/openai.js +15 -0
- package/ts_build/src/clients/pricing/openai.js.map +1 -1
- package/ts_build/src/clients/pricing/xai.d.ts +1 -0
- package/ts_build/src/clients/pricing/xai.js +3 -0
- package/ts_build/src/clients/pricing/xai.js.map +1 -1
- package/ts_build/src/clients/types.d.ts +6 -1
- package/ts_build/src/clients/xai.js +1 -1
- package/ts_build/src/clients/xai.js.map +1 -1
- package/ts_build/src/commands/agent.js +16 -0
- package/ts_build/src/commands/agent.js.map +1 -1
- package/ts_build/src/commands/behaviors.d.ts +2 -0
- package/ts_build/src/commands/behaviors.js +43 -0
- package/ts_build/src/commands/behaviors.js.map +1 -0
- package/ts_build/src/commands/services.js +4 -2
- package/ts_build/src/commands/services.js.map +1 -1
- package/ts_build/src/commands/skills.d.ts +2 -0
- package/ts_build/src/commands/skills.js +61 -0
- package/ts_build/src/commands/skills.js.map +1 -0
- package/ts_build/src/index.d.ts +2 -0
- package/ts_build/src/index.js +5 -1
- package/ts_build/src/index.js.map +1 -1
- package/ts_build/src/plugins/PluginBase.d.ts +0 -2
- package/ts_build/src/plugins/PluginBase.js.map +1 -1
- package/ts_build/src/plugins/SkillsPlugin.d.ts +1 -6
- package/ts_build/src/plugins/SkillsPlugin.js +6 -135
- package/ts_build/src/plugins/SkillsPlugin.js.map +1 -1
- package/ts_build/src/plugins/language.js.map +1 -1
- package/ts_build/src/plugins/plugins.d.ts +4 -1
- package/ts_build/src/plugins/plugins.js +17 -11
- package/ts_build/src/plugins/plugins.js.map +1 -1
- package/ts_build/src/plugins/types.d.ts +3 -2
- package/ts_build/src/processors/MinimalToolsMessageProcessor.d.ts +7 -0
- package/ts_build/src/processors/MinimalToolsMessageProcessor.js +61 -0
- package/ts_build/src/processors/MinimalToolsMessageProcessor.js.map +1 -0
- package/ts_build/src/processors/TokenCompressor.js +5 -2
- package/ts_build/src/processors/TokenCompressor.js.map +1 -1
- package/ts_build/src/processors/index.d.ts +2 -1
- package/ts_build/src/processors/index.js +3 -1
- package/ts_build/src/processors/index.js.map +1 -1
- package/ts_build/src/services/AgentSyncFs.d.ts +2 -0
- package/ts_build/src/services/AgentSyncFs.js +30 -0
- package/ts_build/src/services/AgentSyncFs.js.map +1 -1
- package/ts_build/src/services/AgentSyncKnowhowWeb.js +1 -1
- package/ts_build/src/services/BehaviorsService.d.ts +46 -0
- package/ts_build/src/services/BehaviorsService.js +358 -0
- package/ts_build/src/services/BehaviorsService.js.map +1 -0
- package/ts_build/src/services/KnowhowClient.d.ts +9 -1
- package/ts_build/src/services/KnowhowClient.js +20 -0
- package/ts_build/src/services/KnowhowClient.js.map +1 -1
- package/ts_build/src/services/LazyToolsService.js.map +1 -1
- package/ts_build/src/services/MinimalToolsService.d.ts +14 -0
- package/ts_build/src/services/MinimalToolsService.js +80 -0
- package/ts_build/src/services/MinimalToolsService.js.map +1 -0
- package/ts_build/src/services/SkillsService.d.ts +53 -0
- package/ts_build/src/services/SkillsService.js +478 -0
- package/ts_build/src/services/SkillsService.js.map +1 -0
- package/ts_build/src/services/Tools.d.ts +2 -0
- package/ts_build/src/services/Tools.js.map +1 -1
- package/ts_build/src/services/index.d.ts +4 -0
- package/ts_build/src/services/index.js +9 -2
- package/ts_build/src/services/index.js.map +1 -1
- package/ts_build/src/services/modules/index.d.ts +4 -2
- package/ts_build/src/services/modules/types.d.ts +2 -0
- package/ts_build/src/types.d.ts +8 -0
- package/ts_build/src/worker.js +5 -0
- package/ts_build/src/worker.js.map +1 -1
- package/ts_build/tests/processors/TokenCompressor.test.js +27 -0
- package/ts_build/tests/processors/TokenCompressor.test.js.map +1 -1
- package/ts_build/tests/unit/services/MinimalToolsService.test.d.ts +1 -0
- package/ts_build/tests/unit/services/MinimalToolsService.test.js +320 -0
- package/ts_build/tests/unit/services/MinimalToolsService.test.js.map +1 -0
|
@@ -61,7 +61,7 @@ export interface CreateMessageTaskResponse {
|
|
|
61
61
|
|
|
62
62
|
export interface UpdateOrgTaskRequest {
|
|
63
63
|
threads: Message[][];
|
|
64
|
-
|
|
64
|
+
totalUsdCost: number;
|
|
65
65
|
inProgress: boolean;
|
|
66
66
|
result?: string;
|
|
67
67
|
}
|
|
@@ -799,4 +799,65 @@ export class KnowhowSimpleClient {
|
|
|
799
799
|
);
|
|
800
800
|
return response.data;
|
|
801
801
|
}
|
|
802
|
+
|
|
803
|
+
// ============================================
|
|
804
|
+
// Org Behaviors Methods
|
|
805
|
+
// ============================================
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* List all behaviors for the current org
|
|
809
|
+
*/
|
|
810
|
+
async getOrgBehaviors() {
|
|
811
|
+
await this.checkJwt();
|
|
812
|
+
return http.get<Record<string, unknown>[]>(
|
|
813
|
+
`${this.baseUrl}/api/org-behaviors`,
|
|
814
|
+
{ headers: this.headers }
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* List all skills (isSkill=true) for the current org
|
|
820
|
+
*/
|
|
821
|
+
async getOrgSkills(includeInternal = true) {
|
|
822
|
+
await this.checkJwt();
|
|
823
|
+
return http.get<Record<string, unknown>[]>(
|
|
824
|
+
`${this.baseUrl}/api/org-behaviors/skills?includeInternal=${includeInternal}`,
|
|
825
|
+
{ headers: this.headers }
|
|
826
|
+
);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Create a new org behavior
|
|
831
|
+
*/
|
|
832
|
+
async createOrgBehavior(data: Record<string, unknown>) {
|
|
833
|
+
await this.checkJwt();
|
|
834
|
+
return http.post<Record<string, unknown>>(
|
|
835
|
+
`${this.baseUrl}/api/org-behaviors`,
|
|
836
|
+
data,
|
|
837
|
+
{ headers: this.headers }
|
|
838
|
+
);
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* Update an existing org behavior by ID
|
|
843
|
+
*/
|
|
844
|
+
async updateOrgBehavior(id: string, data: Record<string, unknown>) {
|
|
845
|
+
await this.checkJwt();
|
|
846
|
+
return http.put<Record<string, unknown>>(
|
|
847
|
+
`${this.baseUrl}/api/org-behaviors/${id}`,
|
|
848
|
+
data,
|
|
849
|
+
{ headers: this.headers }
|
|
850
|
+
);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* Get triggered behaviors for a given user input string
|
|
855
|
+
*/
|
|
856
|
+
async getTriggeredBehaviors(userInput: string) {
|
|
857
|
+
await this.checkJwt();
|
|
858
|
+
return http.get<{ triggered: Record<string, unknown>[]; trigger_type: string }>(
|
|
859
|
+
`${this.baseUrl}/api/org-behaviors/triggered?userInput=${encodeURIComponent(userInput)}`,
|
|
860
|
+
{ headers: this.headers }
|
|
861
|
+
);
|
|
862
|
+
}
|
|
802
863
|
}
|
|
@@ -9,6 +9,18 @@ import {
|
|
|
9
9
|
} from "../agents/tools/lazy";
|
|
10
10
|
import { definitions } from "../agents/tools/lazy/definitions";
|
|
11
11
|
|
|
12
|
+
/*
|
|
13
|
+
*
|
|
14
|
+
* This ToolService design allows an agent to start with a few enabled tools,
|
|
15
|
+
* search and enable additional tools
|
|
16
|
+
*
|
|
17
|
+
* One drawback: enabling a tool will bust the cache, causing you to have to pay extra after enabling new tools
|
|
18
|
+
* Benefit: for providers with limits on how many tools you can support, this tool service allows you to have the minimal set of tools you need to use in the tools array. Smaller context usage
|
|
19
|
+
*
|
|
20
|
+
* In a longer running session, where the agent's tools accumulate over multiple interactions, the cache busting is minimized
|
|
21
|
+
* In web sessions where you get a new ToolService each interaction, then the cache busting is going to happen with each enable
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
12
24
|
export class LazyToolsService extends ToolsService {
|
|
13
25
|
private allTools: Tool[] = [];
|
|
14
26
|
// Start with lazy tools enabled by default
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { ToolsService, ToolContext } from "./Tools";
|
|
2
|
+
import { Tool, ToolCall } from "../clients/types";
|
|
3
|
+
import { callTool } from "../agents/tools/minimal/callTool";
|
|
4
|
+
import { inspectTools } from "../agents/tools/minimal/inspectTools";
|
|
5
|
+
import { minimalDefinitions } from "../agents/tools/minimal/definitions";
|
|
6
|
+
import { finalAnswer } from "../agents/tools/finalAnswer";
|
|
7
|
+
import { includedTools } from "../agents/tools/list";
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* MinimalToolsService
|
|
11
|
+
*
|
|
12
|
+
* A cache-stable ToolService: the `tools:` array sent to the AI is always the
|
|
13
|
+
* same small set of base tools (callTool, inspectTools, finalAnswer + any
|
|
14
|
+
* explicitly registered base tools). All other tools live in `allTools` and
|
|
15
|
+
* are callable via callTool(name, args).
|
|
16
|
+
*
|
|
17
|
+
* Benefits over LazyToolsService:
|
|
18
|
+
* - The `tools:` array NEVER changes during a session → zero cache busts from tool changes.
|
|
19
|
+
* - Works on all providers and older models (no provider-specific defer_loading needed).
|
|
20
|
+
* - Agents discover tools via inspectTools() and call them via callTool().
|
|
21
|
+
*/
|
|
22
|
+
export class MinimalToolsService extends ToolsService {
|
|
23
|
+
/** Full catalog of every registered tool (base + extended). */
|
|
24
|
+
private allToolsCatalog: Tool[] = [];
|
|
25
|
+
|
|
26
|
+
constructor(context?: ToolContext) {
|
|
27
|
+
super(context);
|
|
28
|
+
this.registerMinimalTools();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Registers the immutable base tools.
|
|
33
|
+
* These are the only tools that ever appear in the `tools:` array.
|
|
34
|
+
*/
|
|
35
|
+
private registerMinimalTools(): void {
|
|
36
|
+
// finalAnswer definition is sourced from the included tools list
|
|
37
|
+
const finalAnswerDef = includedTools.find(
|
|
38
|
+
(t) => t.function.name === "finalAnswer"
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const baseDefs: Tool[] = [
|
|
42
|
+
...(finalAnswerDef ? [finalAnswerDef as Tool] : []),
|
|
43
|
+
...minimalDefinitions,
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
// Add base tool defs to both catalogs
|
|
47
|
+
this.allToolsCatalog.push(...baseDefs);
|
|
48
|
+
super.addTools(baseDefs);
|
|
49
|
+
|
|
50
|
+
// Register implementations
|
|
51
|
+
this.addFunctions({
|
|
52
|
+
finalAnswer: finalAnswer.bind(this),
|
|
53
|
+
callTool: callTool.bind(this),
|
|
54
|
+
inspectTools: inspectTools.bind(this),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Override addTools so that newly-registered tools go into the full catalog
|
|
60
|
+
* but NOT into the visible `tools` array (which stays stable).
|
|
61
|
+
*/
|
|
62
|
+
addTools(tools: Tool[]): void {
|
|
63
|
+
const existingNames = this.allToolsCatalog.map((t) => t.function.name);
|
|
64
|
+
const newTools = tools.filter(
|
|
65
|
+
(t) => !existingNames.includes(t.function.name)
|
|
66
|
+
);
|
|
67
|
+
this.allToolsCatalog.push(...newTools);
|
|
68
|
+
// Do NOT call super.addTools() — base tools array stays frozen.
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
addTool(tool: Tool): void {
|
|
72
|
+
this.addTools([tool]);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns only the stable base tools (what gets sent in `tools:` to the AI).
|
|
77
|
+
*/
|
|
78
|
+
getTools(): Tool[] {
|
|
79
|
+
return super.getTools();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Returns every tool in the catalog (base + extended). Used by callTool /
|
|
84
|
+
* inspectTools for dispatching and schema lookup.
|
|
85
|
+
*/
|
|
86
|
+
getAllTools(): Tool[] {
|
|
87
|
+
return this.allToolsCatalog;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Calls a tool by its resolved name, bypassing the enabled-tools check that
|
|
92
|
+
* the base class applies. Used internally by the callTool dispatch function.
|
|
93
|
+
* Returns the raw functionResp (unwrapped), used by the callTool meta-tool.
|
|
94
|
+
*/
|
|
95
|
+
async callToolByName(
|
|
96
|
+
toolCall: ToolCall,
|
|
97
|
+
resolvedName: string
|
|
98
|
+
): Promise<any> {
|
|
99
|
+
const result = await this.dispatchToTool(toolCall, resolvedName);
|
|
100
|
+
return result.functionResp;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Shared dispatch logic: temporarily surfaces the target tool (if it's not
|
|
105
|
+
* already visible) so the base ToolsService.callTool can find its
|
|
106
|
+
* definition and implementation, then restores the visible set.
|
|
107
|
+
* Used both by direct calls (agent calls the tool by its real name) and by
|
|
108
|
+
* the callTool meta-tool (agent calls callTool({ name, args })).
|
|
109
|
+
*/
|
|
110
|
+
private async dispatchToTool(toolCall: ToolCall, resolvedName: string) {
|
|
111
|
+
// Temporarily surface the target tool in the visible list so base
|
|
112
|
+
// ToolsService.callTool can find its definition, then restore state.
|
|
113
|
+
const alreadyVisible = super
|
|
114
|
+
.getTools()
|
|
115
|
+
.some((t) => t.function.name === resolvedName);
|
|
116
|
+
|
|
117
|
+
if (!alreadyVisible) {
|
|
118
|
+
const toolDef = this.allToolsCatalog.find(
|
|
119
|
+
(t) => t.function.name === resolvedName
|
|
120
|
+
);
|
|
121
|
+
if (toolDef) {
|
|
122
|
+
super.addTools([toolDef]);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const result = await super.callTool(toolCall, [resolvedName]);
|
|
127
|
+
|
|
128
|
+
// Remove the temporarily-added tool to keep the visible set stable
|
|
129
|
+
if (!alreadyVisible) {
|
|
130
|
+
this.tools = this.tools.filter((t) => t.function.name !== resolvedName);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Delegates to the full catalog for resolution, then runs via callToolByName.
|
|
138
|
+
*/
|
|
139
|
+
async callTool(toolCall: ToolCall, enabledTools?: string[]): Promise<any> {
|
|
140
|
+
const functionName = toolCall.function.name;
|
|
141
|
+
|
|
142
|
+
// Base tools (callTool, inspectTools, finalAnswer) → standard dispatch
|
|
143
|
+
const isBaseTool = super
|
|
144
|
+
.getTools()
|
|
145
|
+
.some((t) => t.function.name === functionName);
|
|
146
|
+
|
|
147
|
+
if (isBaseTool) {
|
|
148
|
+
return super.callTool(toolCall, this.getToolNames());
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Extended tools: called directly by name (not via the callTool meta-tool).
|
|
152
|
+
// These live only in allToolsCatalog, not in the frozen visible `tools`
|
|
153
|
+
// array, so we must temporarily surface them the same way callToolByName
|
|
154
|
+
// does, otherwise base ToolsService.getTool() won't find the definition
|
|
155
|
+
// and will throw "Tool ... not found" even though it's a registered tool.
|
|
156
|
+
const existsInCatalog = this.allToolsCatalog.some(
|
|
157
|
+
(t) => t.function.name === functionName
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
if (existsInCatalog) {
|
|
161
|
+
return this.dispatchToTool(toolCall, functionName);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Not found anywhere - let the base class produce the standard error.
|
|
165
|
+
return super.callTool(toolCall, [functionName]);
|
|
166
|
+
}
|
|
167
|
+
}
|