fix: prevent opencode run crash on malformed tool inputs (#13051)
Co-authored-by: 0xK3vin <kevin@git-pu.sh>
This commit is contained in:
@@ -406,6 +406,7 @@ export const RunCommand = cmd({
|
|||||||
|
|
||||||
async function execute(sdk: OpencodeClient) {
|
async function execute(sdk: OpencodeClient) {
|
||||||
function tool(part: ToolPart) {
|
function tool(part: ToolPart) {
|
||||||
|
try {
|
||||||
if (part.tool === "bash") return bash(props<typeof BashTool>(part))
|
if (part.tool === "bash") return bash(props<typeof BashTool>(part))
|
||||||
if (part.tool === "glob") return glob(props<typeof GlobTool>(part))
|
if (part.tool === "glob") return glob(props<typeof GlobTool>(part))
|
||||||
if (part.tool === "grep") return grep(props<typeof GrepTool>(part))
|
if (part.tool === "grep") return grep(props<typeof GrepTool>(part))
|
||||||
@@ -420,6 +421,9 @@ export const RunCommand = cmd({
|
|||||||
if (part.tool === "todowrite") return todo(props<typeof TodoWriteTool>(part))
|
if (part.tool === "todowrite") return todo(props<typeof TodoWriteTool>(part))
|
||||||
if (part.tool === "skill") return skill(props<typeof SkillTool>(part))
|
if (part.tool === "skill") return skill(props<typeof SkillTool>(part))
|
||||||
return fallback(part)
|
return fallback(part)
|
||||||
|
} catch {
|
||||||
|
return fallback(part)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function emit(type: string, data: Record<string, unknown>) {
|
function emit(type: string, data: Record<string, unknown>) {
|
||||||
|
|||||||
Reference in New Issue
Block a user