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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user