diff --git a/packages/core/src/codemode/tool.ts b/packages/core/src/codemode/tool.ts index 7be4ff8898e..e767523dc66 100644 --- a/packages/core/src/codemode/tool.ts +++ b/packages/core/src/codemode/tool.ts @@ -3,7 +3,7 @@ export * as CodeModeTool from "./tool.js" import { CodeMode, Tool, toolError } from "@opencode-ai/codemode" import type { Content, Context, Error, Info, Metadata, Result } from "@opencode-ai/schema/tool" import { Effect, Ref, Schema, Semaphore } from "effect" -import { definition } from "../tool/runtime.js" +import { definition, normalizedName } from "../tool/runtime.js" const ExecuteFile = Schema.Struct({ data: Schema.String, @@ -165,7 +165,7 @@ function runtime( } function qualifiedName(registration: Info) { - const normalized = registration.name.replace(/[^a-zA-Z0-9_-]/g, "_") + const normalized = normalizedName(registration) if (registration.options?.namespace === undefined) return normalized return `${registration.options.namespace}.${normalized}` } diff --git a/packages/core/src/tool.ts b/packages/core/src/tool.ts index b6eb564afaa..d1dc8c581fd 100644 --- a/packages/core/src/tool.ts +++ b/packages/core/src/tool.ts @@ -15,7 +15,7 @@ import { PluginHooks } from "./plugin/hooks.js" import { SessionMessage } from "./session/message.js" import { SessionSchema } from "./session/schema.js" import { State } from "./state.js" -import { definition, execute, normalizeContent } from "./tool/runtime.js" +import { definition, effectiveName, execute, normalizedName, normalizeContent } from "./tool/runtime.js" import { Wildcard } from "./util/wildcard.js" export class RegistrationError extends Schema.TaggedError()("Tool.RegistrationError", { @@ -284,13 +284,6 @@ function registrationError(tool: Tool.Info) { return Result.isFailure(result) ? result.failure : undefined } -const normalizedName = (tool: Tool.Info) => tool.name.replace(/[^a-zA-Z0-9_-]/g, "_") - -const effectiveName = (tool: Tool.Info) => - tool.options?.namespace === undefined - ? normalizedName(tool) - : `${tool.options.namespace.replaceAll(".", "_")}_${normalizedName(tool)}` - export const node = makeLocationNode({ service: Service, layer, diff --git a/packages/core/src/tool/runtime.ts b/packages/core/src/tool/runtime.ts index 20a4cfc75c4..b56d488db03 100644 --- a/packages/core/src/tool/runtime.ts +++ b/packages/core/src/tool/runtime.ts @@ -270,9 +270,9 @@ const stringify = (value: unknown) => { } } -const normalizedName = (tool: Tool.Info) => tool.name.replace(/[^a-zA-Z0-9_-]/g, "_") +export const normalizedName = (tool: Tool.Info) => tool.name.replace(/[^a-zA-Z0-9_-]/g, "_") -const effectiveName = (tool: Tool.Info) => +export const effectiveName = (tool: Tool.Info) => tool.options?.namespace === undefined ? normalizedName(tool) : `${tool.options.namespace.replaceAll(".", "_")}_${normalizedName(tool)}`