From e34e4a59e9bee1601bcc87bccb82541d18437f84 Mon Sep 17 00:00:00 2001 From: DhanushSantosh Date: Sun, 11 Jan 2026 01:35:32 +0530 Subject: [PATCH] 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 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. --- apps/server/src/providers/opencode-provider.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/server/src/providers/opencode-provider.ts b/apps/server/src/providers/opencode-provider.ts index d0990d16..ecc7fc85 100644 --- a/apps/server/src/providers/opencode-provider.ts +++ b/apps/server/src/providers/opencode-provider.ts @@ -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).result) ?? undefined; + if (rawResult !== undefined) { + result.result = typeof rawResult === 'string' ? rawResult : JSON.stringify(rawResult); } return result;