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:
DhanushSantosh
2026-01-11 01:35:32 +05:30
parent 7cc092cd59
commit e34e4a59e9

View File

@@ -382,9 +382,11 @@ export class OpencodeProvider extends CliProvider {
result.session_id = finishEvent.sessionID;
}
// Include result text if provided
if (finishEvent.part?.result) {
result.result = finishEvent.part.result;
// Safely handle arbitrary result payloads from CLI: ensure we assign a string.
const rawResult =
(finishEvent.part && (finishEvent.part as Record<string, unknown>).result) ?? undefined;
if (rawResult !== undefined) {
result.result = typeof rawResult === 'string' ? rawResult : JSON.stringify(rawResult);
}
return result;