evOo-local/packages/adapters/src/executor-tools.ts
Claude 728d78001a
Merge user profile: readable, writable and forgettable user model
Both branches gave the main bot its own tools, so the main-only filter now
covers delegate_task and update_user_profile, and the main bot's role test
expects the profile tool instead of remember.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MRtGG9ARfqqhma3t85Ro2u
2026-10-02 23:05:28 +00:00

63 lines
2.1 KiB
TypeScript

import { builtinAgentTools } from "./builtin-tools.js";
import { selectCloudAgentTools } from "./cloud-agent-tools-select.js";
import { selectMemoryTools } from "./memory-tools.js";
import { filterImageReturningComputerTools } from "./model-vision.js";
import { filterBuiltinToolsForRun, filterBuiltinToolsForThread } from "./schedule-tools.js";
/** Browser tools that require a graphical computer (Chrome). */
export const PAGE_BROWSER_TOOL_NAMES = new Set([
"browser_navigate",
"browser_snapshot",
"browser_act",
]);
export function filterPageBrowserTools<T extends { name: string }>(
tools: T[],
pageBrowserAllowed: boolean,
): T[] {
if (pageBrowserAllowed) return tools;
return tools.filter((tool) => !PAGE_BROWSER_TOOL_NAMES.has(tool.name));
}
export function selectBuiltinToolsForRun(options: {
graphicalToolsAllowed: boolean;
/** Page browser tools need a graphical computer (Chrome), not model vision. */
pageBrowserAllowed?: boolean;
groupId: string | null;
trigger: string;
semanticMemoryEnabled: boolean;
cloudAgentEnabled?: boolean;
messagingChannelRun: boolean;
/** Only the user's main bot delegates tasks and keeps the user model. */
mainBot?: boolean;
}) {
return selectCloudAgentTools(
selectMemoryTools(
filterBuiltinToolsForRun(
filterBuiltinToolsForThread(
filterPageBrowserTools(
filterImageReturningComputerTools(builtinAgentTools, options.graphicalToolsAllowed),
options.pageBrowserAllowed ?? options.graphicalToolsAllowed,
),
options.groupId,
),
options.trigger,
),
options.semanticMemoryEnabled,
),
Boolean(options.cloudAgentEnabled),
).filter(
(tool) =>
(options.mainBot || !["delegate_task", "update_user_profile"].includes(tool.name)) &&
(!options.messagingChannelRun ||
(![
"remember",
"save_memory",
"recall_memory",
"forget_memory",
"update_user_profile",
].includes(tool.name) &&
!tool.name.startsWith("scratchpad_"))),
);
}