mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 21:03:08 +00:00
fix: Resolve TypeScript error assigning part.result to string field
Fix TS2322 error where finishEvent.part?.result (typed as {}) was being
assigned to result.result (typed as string).
Solution: Safely handle arbitrary result payloads by:
1. Reading raw value as unknown from Record<string, unknown>
2. Checking if it's a string, otherwise JSON.stringify()
This ensures type safety while supporting both string and object results
from the OpenCode CLI.
This commit is contained in:
@@ -382,9 +382,11 @@ export class OpencodeProvider extends CliProvider {
|
|||||||
result.session_id = finishEvent.sessionID;
|
result.session_id = finishEvent.sessionID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include result text if provided
|
// Safely handle arbitrary result payloads from CLI: ensure we assign a string.
|
||||||
if (finishEvent.part?.result) {
|
const rawResult =
|
||||||
result.result = finishEvent.part.result;
|
(finishEvent.part && (finishEvent.part as Record<string, unknown>).result) ?? undefined;
|
||||||
|
if (rawResult !== undefined) {
|
||||||
|
result.result = typeof rawResult === 'string' ? rawResult : JSON.stringify(rawResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user