remove builtintoolnames
This commit is contained in:
parent
8381812d92
commit
d510de946b
6 changed files with 27 additions and 40 deletions
|
|
@ -5,7 +5,7 @@ import {
|
|||
ToolPermissionPolicy,
|
||||
ToolPermissions,
|
||||
} from "../permissions/types.js";
|
||||
import { BUILT_IN_TOOL_NAMES } from "../tools/builtInToolNames.js";
|
||||
import { ALL_BUILT_IN_TOOLS } from "../tools/allBuiltIns.js";
|
||||
import { logger } from "../util/logger.js";
|
||||
|
||||
import { BaseService, ServiceWithDependencies } from "./BaseService.js";
|
||||
|
|
@ -142,7 +142,7 @@ export class ToolPermissionService
|
|||
}));
|
||||
policies.push(...allowed);
|
||||
const specificBuiltInSet = new Set(specificBuiltIns);
|
||||
const notMentioned = BUILT_IN_TOOL_NAMES.filter(
|
||||
const notMentioned = ALL_BUILT_IN_TOOLS.map((t) => t.name).filter(
|
||||
(name) => !specificBuiltInSet.has(name),
|
||||
);
|
||||
const disallowed: ToolPermissionPolicy[] = notMentioned.map((tool) => ({
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export const ALL_BUILT_IN_TOOLS = [
|
|||
runTerminalCommandTool,
|
||||
fetchTool,
|
||||
writeChecklistTool,
|
||||
subagentTool,
|
||||
subagentTool(),
|
||||
exitTool,
|
||||
reportFailureTool,
|
||||
uploadArtifactTool,
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
/**
|
||||
* List of built-in tool names
|
||||
* Kept separate from allBuiltIns.ts to avoid circular dependencies
|
||||
*/
|
||||
export const BUILT_IN_TOOL_NAMES = [
|
||||
"Read",
|
||||
"Edit",
|
||||
"MultiEdit",
|
||||
"Write",
|
||||
"List",
|
||||
"Search",
|
||||
"Bash",
|
||||
"Fetch",
|
||||
"Checklist",
|
||||
"Subagent",
|
||||
"Exit",
|
||||
"ReportFailure",
|
||||
"UploadArtifact",
|
||||
] as const;
|
||||
|
||||
export type BuiltInToolName = (typeof BUILT_IN_TOOL_NAMES)[number];
|
||||
|
|
@ -132,9 +132,6 @@ export async function getAllAvailableTools(
|
|||
|
||||
export function getToolDisplayName(toolName: string): string {
|
||||
const tool = ALL_BUILT_IN_TOOLS.find((t) => t.name === toolName);
|
||||
if (typeof tool === "function") {
|
||||
return toolName;
|
||||
}
|
||||
return tool?.displayName || toolName;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { services } from "../services/index.js";
|
||||
import { executeSubAgent } from "../subagent/executor.js";
|
||||
import {
|
||||
generateSubagentToolDescription,
|
||||
|
|
@ -11,7 +12,9 @@ import { GetTool } from "./types.js";
|
|||
export const subagentTool: GetTool = (params) => ({
|
||||
name: "Subagent",
|
||||
displayName: "Subagent",
|
||||
description: generateSubagentToolDescription(params.modelServiceState),
|
||||
description: params
|
||||
? generateSubagentToolDescription(params.modelServiceState)
|
||||
: "Use a subagent to handle a specialized task.",
|
||||
readonly: false,
|
||||
isBuiltIn: true,
|
||||
|
||||
|
|
@ -29,14 +32,26 @@ export const subagentTool: GetTool = (params) => ({
|
|||
},
|
||||
subagent_name: {
|
||||
type: "string",
|
||||
description: `The type of specialized agent to use for this task. Available agents: ${getSubagentNames(
|
||||
params.modelServiceState,
|
||||
).join(", ")}`,
|
||||
description: `The type of specialized agent to use for this task. Available agents: ${
|
||||
params ? getSubagentNames(params.modelServiceState).join(", ") : ""
|
||||
}`,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
preprocess: async (args: any) => {
|
||||
if (!params) {
|
||||
return {
|
||||
args,
|
||||
preview: [
|
||||
{
|
||||
type: "text",
|
||||
content: "Subagent not found",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const { description, subagent_name } = args;
|
||||
|
||||
const agent = getSubagent(params.modelServiceState, subagent_name);
|
||||
|
|
@ -60,23 +75,19 @@ export const subagentTool: GetTool = (params) => ({
|
|||
},
|
||||
|
||||
run: async (args: any, context?: { toolCallId: string }) => {
|
||||
if (!params) return "";
|
||||
|
||||
const { prompt, subagent_name } = args;
|
||||
|
||||
logger.debug("subagent args", { args, context });
|
||||
|
||||
// Get agent configuration
|
||||
// get agent configuration
|
||||
const agent = getSubagent(params.modelServiceState, subagent_name);
|
||||
if (!agent) {
|
||||
throw new Error(`Unknown agent type: ${subagent_name}`);
|
||||
}
|
||||
|
||||
// Lazy import services to avoid circular dependency
|
||||
const { services } = await import("../services/index.js");
|
||||
|
||||
// Get parent session ID from chat history service
|
||||
const chatHistoryService = services.chatHistory;
|
||||
const parentSessionId = chatHistoryService.getSessionId();
|
||||
|
||||
const parentSessionId = services.chatHistory.getSessionId();
|
||||
if (!parentSessionId) {
|
||||
throw new Error("No active session found");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export interface Tool {
|
|||
) => ToolPolicy;
|
||||
}
|
||||
|
||||
export type GetTool = (params: {
|
||||
export type GetTool = (params?: {
|
||||
modelServiceState: ModelServiceState;
|
||||
}) => Tool;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue