From d0a0cfabca4f6f64b20ba76d8af10420ddbd2049 Mon Sep 17 00:00:00 2001 From: hugoboss23-5 Date: Sat, 8 Aug 2026 01:00:27 -0700 Subject: [PATCH] fix(build): repair three type errors that break `pnpm -r build` `pnpm -r build` currently fails on master. Three distinct type errors, each blocking the workspace build at a different package. 1. packages/bots/core and packages/bot/core - TS2345 Both packages contain a duplicated copy of the same SessionManager. In each, the local `finish` callback re-declares its parameter as an inline structural type using widened primitives: type: string; subtype: string; but `AIResult` (declared a few lines above in the same file) requires the string literals `"result"` and `"success" | "error"`. A widened `string` is not assignable to a literal type, so `resolve(result)` is rejected. Fixed by annotating the parameter with the existing `AIResult` interface instead of restating its shape. This also removes a hand-duplicated type that had already drifted from its source, which is what allowed the mismatch. 2. packages/bots/signal - TS2322 The object literal in the timestamp-fallback test does not satisfy `IncomingMessage` in three ways: `groupId: undefined` where the interface declares `string | null`, the required `isGroup` field is missing, and an excess `raw` property is not part of the interface. Corrected all three rather than only the error the compiler reported first. The test's intent (out-of-range timestamp falls back to epoch) is unchanged. Verification - `tsc -p tsconfig.json --noEmit` exits 0 for each package, using the repo's own pinned typescript@5.9.3 from the lockfile. - `vitest run packages/bots/signal` -> 7 passed (7). Behaviour preserved. - No runtime logic changed; net -22/+4 lines, entirely type-level. --- packages/bot/core/src/index.ts | 11 +---------- packages/bots/core/src/index.ts | 11 +---------- packages/bots/signal/src/index.test.ts | 4 ++-- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/packages/bot/core/src/index.ts b/packages/bot/core/src/index.ts index 00073aba..434f6517 100644 --- a/packages/bot/core/src/index.ts +++ b/packages/bot/core/src/index.ts @@ -111,16 +111,7 @@ export class SessionManager { proc.stderr?.on("data", (chunk) => (stderr += chunk.toString())); return new Promise((resolve) => { - const finish = (result: { - type: string; - subtype: string; - is_error: boolean; - result: string; - duration_ms: number; - num_turns: number; - session_id: string; - total_cost_usd: number; - }) => { + const finish = (result: AIResult) => { session.busy = false; session.abortController = null; resolve(result); diff --git a/packages/bots/core/src/index.ts b/packages/bots/core/src/index.ts index 9284cf07..e15d0383 100644 --- a/packages/bots/core/src/index.ts +++ b/packages/bots/core/src/index.ts @@ -111,16 +111,7 @@ export class SessionManager { proc.stderr?.on("data", (chunk) => (stderr += chunk.toString())); return new Promise((resolve) => { - const finish = (result: { - type: string; - subtype: string; - is_error: boolean; - result: string; - duration_ms: number; - num_turns: number; - session_id: string; - total_cost_usd: number; - }) => { + const finish = (result: AIResult) => { session.busy = false; session.abortController = null; resolve(result); diff --git a/packages/bots/signal/src/index.test.ts b/packages/bots/signal/src/index.test.ts index 4a479d93..7b3ca6e2 100644 --- a/packages/bots/signal/src/index.test.ts +++ b/packages/bots/signal/src/index.test.ts @@ -58,9 +58,9 @@ describe('toBotEvent', () => { sourceName: 'User', text: 'hello', timestamp: Number.POSITIVE_INFINITY, - groupId: undefined, + groupId: null, + isGroup: false, attachments: [], - raw: {}, }).timestamp).toBe('1970-01-01T00:00:00.000Z'); }); });