summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKevin <[email protected]>2026-02-13 18:54:20 -0800
committerGitHub <[email protected]>2026-02-13 20:54:20 -0600
commitd018903887861c64ec7ee037e60b24a61501c9c6 (patch)
tree51717d820342a62033a320565a438b5d212387ae
parentd30e91738570ee9ea06ca6f2d49bdae65b0ff3ec (diff)
downloadopencode-d018903887861c64ec7ee037e60b24a61501c9c6.tar.gz
opencode-d018903887861c64ec7ee037e60b24a61501c9c6.zip
fix: prevent opencode run crash on malformed tool inputs (#13051)
Co-authored-by: 0xK3vin <[email protected]>
-rw-r--r--packages/opencode/src/cli/cmd/run.ts32
1 files changed, 18 insertions, 14 deletions
diff --git a/packages/opencode/src/cli/cmd/run.ts b/packages/opencode/src/cli/cmd/run.ts
index 0febec3a2..55cf9a2a0 100644
--- a/packages/opencode/src/cli/cmd/run.ts
+++ b/packages/opencode/src/cli/cmd/run.ts
@@ -406,20 +406,24 @@ export const RunCommand = cmd({
async function execute(sdk: OpencodeClient) {
function tool(part: ToolPart) {
- if (part.tool === "bash") return bash(props<typeof BashTool>(part))
- if (part.tool === "glob") return glob(props<typeof GlobTool>(part))
- if (part.tool === "grep") return grep(props<typeof GrepTool>(part))
- if (part.tool === "list") return list(props<typeof ListTool>(part))
- if (part.tool === "read") return read(props<typeof ReadTool>(part))
- if (part.tool === "write") return write(props<typeof WriteTool>(part))
- if (part.tool === "webfetch") return webfetch(props<typeof WebFetchTool>(part))
- if (part.tool === "edit") return edit(props<typeof EditTool>(part))
- if (part.tool === "codesearch") return codesearch(props<typeof CodeSearchTool>(part))
- if (part.tool === "websearch") return websearch(props<typeof WebSearchTool>(part))
- if (part.tool === "task") return task(props<typeof TaskTool>(part))
- if (part.tool === "todowrite") return todo(props<typeof TodoWriteTool>(part))
- if (part.tool === "skill") return skill(props<typeof SkillTool>(part))
- return fallback(part)
+ try {
+ if (part.tool === "bash") return bash(props<typeof BashTool>(part))
+ if (part.tool === "glob") return glob(props<typeof GlobTool>(part))
+ if (part.tool === "grep") return grep(props<typeof GrepTool>(part))
+ if (part.tool === "list") return list(props<typeof ListTool>(part))
+ if (part.tool === "read") return read(props<typeof ReadTool>(part))
+ if (part.tool === "write") return write(props<typeof WriteTool>(part))
+ if (part.tool === "webfetch") return webfetch(props<typeof WebFetchTool>(part))
+ if (part.tool === "edit") return edit(props<typeof EditTool>(part))
+ if (part.tool === "codesearch") return codesearch(props<typeof CodeSearchTool>(part))
+ if (part.tool === "websearch") return websearch(props<typeof WebSearchTool>(part))
+ if (part.tool === "task") return task(props<typeof TaskTool>(part))
+ if (part.tool === "todowrite") return todo(props<typeof TodoWriteTool>(part))
+ if (part.tool === "skill") return skill(props<typeof SkillTool>(part))
+ return fallback(part)
+ } catch {
+ return fallback(part)
+ }
}
function emit(type: string, data: Record<string, unknown>) {