From 1a090af2ebcde3c13db1e13b69cb91e021036d6c Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Fri, 10 Apr 2026 15:53:07 +0900 Subject: [PATCH] feat(tools): add tools for session manager and skill refresh Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- src/plugin/tool-registry.ts | 84 +++++++++++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 18 deletions(-) diff --git a/src/plugin/tool-registry.ts b/src/plugin/tool-registry.ts index 98bd4c9a9..6d04e7e1c 100644 --- a/src/plugin/tool-registry.ts +++ b/src/plugin/tool-registry.ts @@ -37,6 +37,48 @@ import type { Managers } from "../create-managers" import type { SkillContext } from "./skill-context" import { normalizeToolArgSchemas } from "./normalize-tool-arg-schemas" +type ToolRegistryFactories = { + builtinTools: typeof builtinTools + createBackgroundTools: typeof createBackgroundTools + createCallOmoAgent: typeof createCallOmoAgent + createLookAt: typeof createLookAt + createSkillMcpTool: typeof createSkillMcpTool + createSkillTool: typeof createSkillTool + createGrepTools: typeof createGrepTools + createGlobTools: typeof createGlobTools + createAstGrepTools: typeof createAstGrepTools + createSessionManagerTools: typeof createSessionManagerTools + createDelegateTask: typeof createDelegateTask + discoverCommandsSync: typeof discoverCommandsSync + interactive_bash: typeof interactive_bash + createTaskCreateTool: typeof createTaskCreateTool + createTaskGetTool: typeof createTaskGetTool + createTaskList: typeof createTaskList + createTaskUpdateTool: typeof createTaskUpdateTool + createHashlineEditTool: typeof createHashlineEditTool +} + +const defaultToolRegistryFactories: ToolRegistryFactories = { + builtinTools, + createBackgroundTools, + createCallOmoAgent, + createLookAt, + createSkillMcpTool, + createSkillTool, + createGrepTools, + createGlobTools, + createAstGrepTools, + createSessionManagerTools, + createDelegateTask, + discoverCommandsSync, + interactive_bash, + createTaskCreateTool, + createTaskGetTool, + createTaskList, + createTaskUpdateTool, + createHashlineEditTool, +} + export type ToolRegistryResult = { filteredTools: ToolsRecord taskSystemEnabled: boolean @@ -106,6 +148,7 @@ export function createToolRegistry(args: { skillContext: SkillContext availableCategories: AvailableCategory[] interactiveBashEnabled?: boolean + toolFactories?: Partial }): ToolRegistryResult { const { ctx, @@ -114,9 +157,14 @@ export function createToolRegistry(args: { skillContext, availableCategories, interactiveBashEnabled = isInteractiveBashEnabled(), + toolFactories, } = args - const backgroundTools = createBackgroundTools(managers.backgroundManager, ctx.client) - const callOmoAgent = createCallOmoAgent( + const factories: ToolRegistryFactories = { + ...defaultToolRegistryFactories, + ...toolFactories, + } + const backgroundTools = factories.createBackgroundTools(managers.backgroundManager, ctx.client) + const callOmoAgent = factories.createCallOmoAgent( ctx, managers.backgroundManager, pluginConfig.disabled_agents ?? [], @@ -127,9 +175,9 @@ export function createToolRegistry(args: { const isMultimodalLookerEnabled = !(pluginConfig.disabled_agents ?? []).some( (agent) => agent.toLowerCase() === "multimodal-looker", ) - const lookAt = isMultimodalLookerEnabled ? createLookAt(ctx) : null + const lookAt = isMultimodalLookerEnabled ? factories.createLookAt(ctx) : null - const delegateTask = createDelegateTask({ + const delegateTask = factories.createDelegateTask({ manager: managers.backgroundManager, client: ctx.client, directory: ctx.directory, @@ -176,17 +224,17 @@ export function createToolRegistry(args: { const getSessionIDForMcp = (): string | undefined => getMainSessionID() - const skillMcpTool = createSkillMcpTool({ + const skillMcpTool = factories.createSkillMcpTool({ manager: managers.skillMcpManager, getLoadedSkills: () => skillContext.mergedSkills, getSessionID: getSessionIDForMcp, }) - const commands = discoverCommandsSync(ctx.directory, { + const commands = factories.discoverCommandsSync(ctx.directory, { pluginsEnabled: pluginConfig.claude_code?.plugins ?? true, enabledPluginsOverride: pluginConfig.claude_code?.plugins_override, }) - const skillTool = createSkillTool({ + const skillTool = factories.createSkillTool({ commands, skills: skillContext.mergedSkills, mcpManager: managers.skillMcpManager, @@ -199,31 +247,31 @@ export function createToolRegistry(args: { const taskSystemEnabled = isTaskSystemEnabled(pluginConfig) const taskToolsRecord: Record = taskSystemEnabled ? { - task_create: createTaskCreateTool(pluginConfig, ctx), - task_get: createTaskGetTool(pluginConfig), - task_list: createTaskList(pluginConfig), - task_update: createTaskUpdateTool(pluginConfig, ctx), + task_create: factories.createTaskCreateTool(pluginConfig, ctx), + task_get: factories.createTaskGetTool(pluginConfig), + task_list: factories.createTaskList(pluginConfig), + task_update: factories.createTaskUpdateTool(pluginConfig, ctx), } : {} const hashlineEnabled = pluginConfig.hashline_edit ?? false const hashlineToolsRecord: Record = hashlineEnabled - ? { edit: createHashlineEditTool(ctx) } + ? { edit: factories.createHashlineEditTool(ctx) } : {} const allTools: Record = { - ...builtinTools, - ...createGrepTools(ctx), - ...createGlobTools(ctx), - ...createAstGrepTools(ctx), - ...createSessionManagerTools(ctx), + ...factories.builtinTools, + ...factories.createGrepTools(ctx), + ...factories.createGlobTools(ctx), + ...factories.createAstGrepTools(ctx), + ...factories.createSessionManagerTools(ctx), ...backgroundTools, call_omo_agent: callOmoAgent, ...(lookAt ? { look_at: lookAt } : {}), task: delegateTask, skill_mcp: skillMcpTool, skill: skillTool, - ...(interactiveBashEnabled ? { interactive_bash } : {}), + ...(interactiveBashEnabled ? { interactive_bash: factories.interactive_bash } : {}), ...taskToolsRecord, ...hashlineToolsRecord, }