fix(cli/run): properly serialize error objects to prevent [object Object] output

- Add serializeError utility to handle Error instances, plain objects, and nested message paths
- Fix handleSessionError to use serializeError instead of naive String() conversion
- Fix runner.ts catch block to use serializeError for detailed error messages
- Add session.error case to logEventVerbose for better error visibility
- Add comprehensive tests for serializeError function

Fixes error logging in sisyphus-agent workflow where errors were displayed as '[object Object]'
This commit is contained in:
YeonGyu-Kim
2026-01-12 14:49:07 +09:00
parent 965bb2dd10
commit f83b22c4de
3 changed files with 113 additions and 6 deletions
+2 -2
View File
@@ -2,7 +2,7 @@ import { createOpencode } from "@opencode-ai/sdk"
import pc from "picocolors"
import type { RunOptions, RunContext } from "./types"
import { checkCompletionConditions } from "./completion"
import { createEventState, processEvents } from "./events"
import { createEventState, processEvents, serializeError } from "./events"
const POLL_INTERVAL_MS = 500
const DEFAULT_TIMEOUT_MS = 0
@@ -115,7 +115,7 @@ export async function run(options: RunOptions): Promise<number> {
if (err instanceof Error && err.name === "AbortError") {
return 130
}
console.error(pc.red(`Error: ${err}`))
console.error(pc.red(`Error: ${serializeError(err)}`))
return 1
}
}