fix(opencode): import custom tools via file URL (#14971)
This commit is contained in:
parent
29ddd55088
commit
3af12c53c4
1 changed files with 2 additions and 1 deletions
|
|
@ -28,6 +28,7 @@ import { Truncate } from "./truncation"
|
||||||
import { PlanExitTool, PlanEnterTool } from "./plan"
|
import { PlanExitTool, PlanEnterTool } from "./plan"
|
||||||
import { ApplyPatchTool } from "./apply_patch"
|
import { ApplyPatchTool } from "./apply_patch"
|
||||||
import { Glob } from "../util/glob"
|
import { Glob } from "../util/glob"
|
||||||
|
import { pathToFileURL } from "url"
|
||||||
|
|
||||||
export namespace ToolRegistry {
|
export namespace ToolRegistry {
|
||||||
const log = Log.create({ service: "tool.registry" })
|
const log = Log.create({ service: "tool.registry" })
|
||||||
|
|
@ -43,7 +44,7 @@ export namespace ToolRegistry {
|
||||||
if (matches.length) await Config.waitForDependencies()
|
if (matches.length) await Config.waitForDependencies()
|
||||||
for (const match of matches) {
|
for (const match of matches) {
|
||||||
const namespace = path.basename(match, path.extname(match))
|
const namespace = path.basename(match, path.extname(match))
|
||||||
const mod = await import(match)
|
const mod = await import(pathToFileURL(match).href)
|
||||||
for (const [id, def] of Object.entries<ToolDefinition>(mod)) {
|
for (const [id, def] of Object.entries<ToolDefinition>(mod)) {
|
||||||
custom.push(fromPlugin(id === "default" ? namespace : `${namespace}_${id}`, def))
|
custom.push(fromPlugin(id === "default" ? namespace : `${namespace}_${id}`, def))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue