Skip to content

Commit 492ab85

Browse files
kirbyhoodSawyerHood
authored andcommitted
Work around TypeScript 7.1 regressions and skip typecheck on Windows
tsrs follows TypeScript 7.1-dev, which reports TS5115 on zod's z.json() (microsoft/TypeScript#64605) and TS7031 on a contextually typed destructured parameter with a `= {}` default (microsoft/TypeScript#64431). - Core code uses @bb/domain's jsonValueSchema/jsonObjectSchema instead of z.json(); forkable plugins define the same z.lazy schema locally, typed with the SDK's JsonValue. Runtime validation matches z.json(). - Annotate the abort-signal mock parameter in the system-config atoms test. - tsrs ships no Windows binary through 0.18.0, so the Windows CI jobs (windows-foundation, desktop build, nightly desktop) stop typechecking and the doc-examples compile test skips on win32. Linux CI still typechecks every package.
1 parent 132e7b0 commit 492ab85

17 files changed

Lines changed: 124 additions & 65 deletions

File tree

‎.github/workflows/build-desktop.yml‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,6 @@ jobs:
273273
echo "has_signing_secrets=true" >> "$GITHUB_OUTPUT"
274274
fi
275275
276-
- name: Typecheck desktop and launcher
277-
run: pnpm exec turbo run typecheck --filter=@bb/desktop --filter=bb-app --output-logs=new-only
278-
279276
- name: Package x64 installer
280277
env:
281278
WIN_CSC_LINK: ${{ secrets.WINDOWS_CERTIFICATE_PFX }}

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ jobs:
120120
TURBO_CACHE_RESTORE_OUTCOME: ${{ steps.cache.outcome }}
121121
run: bash .github/actions/setup-workspace/install-dependencies.sh --ignore-scripts --filter bb --filter "@bb/process-utils..." --filter "@bb/host-workspace..." --filter "@bb/host-watcher..." --filter "@bb/agent-runtime..." --filter "@bb/provider-bridge-protocol..." --filter "@bb/provider-bridge-acp..." --filter "@bb/host-daemon-contract..." --filter "@bb/config..." --filter "@bb/db..." --filter "bb-plugin-provider-acp..." --filter "bb-plugin-provider-codex..." --filter "bb-plugin-provider-claude-code..." --filter "bb-plugin-echo-provider..." --filter "@bb/app..."
122122

123-
- name: Typecheck and test foundation packages
123+
- name: Lint and test foundation packages
124124
shell: bash
125-
run: pnpm exec turbo run lint typecheck test --filter=@bb/process-utils --filter=@bb/host-workspace --filter=@bb/host-watcher --filter=@bb/agent-runtime --filter=@bb/provider-bridge-protocol --filter=@bb/provider-bridge-acp --filter=@bb/host-daemon-contract --filter=@bb/config --filter=@bb/db --cache-dir="${TURBO_CACHE_DIR:-.turbo/cache}" --continue --concurrency=2 --output-logs=new-only --summarize
125+
run: pnpm exec turbo run lint test --filter=@bb/process-utils --filter=@bb/host-workspace --filter=@bb/host-watcher --filter=@bb/agent-runtime --filter=@bb/provider-bridge-protocol --filter=@bb/provider-bridge-acp --filter=@bb/host-daemon-contract --filter=@bb/config --filter=@bb/db --cache-dir="${TURBO_CACHE_DIR:-.turbo/cache}" --continue --concurrency=2 --output-logs=new-only --summarize
126126

127127
- name: Bound saved Turbo cache
128128
run: node scripts/prune-turbo-cache.mjs --dir .turbo/cache --max-size-mb 256 --keep-run-summaries .turbo/runs

‎.github/workflows/publish-bb-app.yml‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,9 +811,6 @@ jobs:
811811
echo "version=${NIGHTLY_VERSION}" >> "$GITHUB_OUTPUT"
812812
echo "Applied bb-app and desktop version ${NIGHTLY_VERSION}."
813813
814-
- name: Typecheck desktop and launcher
815-
run: pnpm exec turbo run typecheck --filter=@bb/desktop --filter=bb-app --output-logs=new-only
816-
817814
- name: Package x64 nightly installer
818815
# Signs when the Windows certificate secrets exist; without them the
819816
# installer is unsigned and Windows SmartScreen warns before running it.

‎apps/app/src/lib/system-config-atoms.local-access.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ describe("local host daemon access atoms", () => {
157157
await store.get(localHostDaemonAccessStateAtom);
158158
expect(mocks.fetchSdkSystemConfig).not.toHaveBeenCalled();
159159
mocks.fetchSdkSystemConfig.mockImplementation(
160-
({ signal } = {}) =>
160+
({ signal }: { signal?: AbortSignal } = {}) =>
161161
new Promise((resolve) => {
162162
requests.push({ resolve });
163163
signal?.addEventListener(

‎apps/desktop/src/desktop-browser-capture.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { nativeImage, type NativeImage, type WebContents } from "electron";
2+
import { jsonObjectSchema } from "@bb/domain";
23
import { z } from "zod";
34
import type { DesktopBrowserCdpPage } from "./desktop-browser-cdp.js";
45
import {
@@ -27,7 +28,7 @@ export async function captureDesktopBrowserCdpScreenshot(
2728
let frameTimer: ReturnType<typeof setTimeout> | undefined;
2829
const command = contents.debugger
2930
.sendCommand("Page.captureScreenshot", params, sessionId)
30-
.then((result) => z.record(z.string(), z.json()).parse(result))
31+
.then((result) => jsonObjectSchema.parse(result))
3132
.finally(() => {
3233
finished = true;
3334
finish();
@@ -107,10 +108,11 @@ export async function captureDesktopBrowserPage(
107108
if (!debuggerApi.isAttached()) {
108109
debuggerApi.attach("1.3");
109110
ownsAttachment = true;
110-
previousBackgroundThrottling = getDesktopBrowserThrottling(contents);
111+
previousBackgroundThrottling =
112+
getDesktopBrowserThrottling(contents);
111113
setDesktopBrowserThrottling(contents, false);
112114
debuggerApi.on("detach", detached);
113-
z.record(z.string(), z.json()).parse(
115+
jsonObjectSchema.parse(
114116
await debuggerApi.sendCommand(
115117
"Emulation.setFocusEmulationEnabled",
116118
{ enabled: true },

‎apps/desktop/src/desktop-browser-cdp-adapter.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Event, WebContents } from "electron";
2+
import { jsonObjectSchema } from "@bb/domain";
23
import { z } from "zod";
34
import { captureDesktopBrowserCdpScreenshot } from "./desktop-browser-capture.js";
45
import type {
@@ -12,10 +13,9 @@ import {
1213
setDesktopBrowserThrottling,
1314
} from "./desktop-browser-throttling.js";
1415

15-
const cdpObjectSchema = z.record(z.string(), z.json());
1616
const cdpMessageSchema = z.object({
1717
method: z.string().min(1),
18-
params: cdpObjectSchema,
18+
params: jsonObjectSchema,
1919
sessionId: z.string(),
2020
});
2121

@@ -99,7 +99,7 @@ function createPage(
9999
const ready = nativeDebugger
100100
.sendCommand("Emulation.setFocusEmulationEnabled", { enabled: true })
101101
.then((result) => {
102-
cdpObjectSchema.parse(result);
102+
jsonObjectSchema.parse(result);
103103
if (generation === attachmentGeneration) attachmentReady = null;
104104
});
105105
attachmentReady = ready;
@@ -152,7 +152,7 @@ function createPage(
152152
}
153153
}
154154
signal?.throwIfAborted();
155-
const result = cdpObjectSchema.parse(
155+
const result = jsonObjectSchema.parse(
156156
await (method === "Page.captureScreenshot"
157157
? captureDesktopBrowserCdpScreenshot(webContents, params, sessionId)
158158
: nativeDebugger.sendCommand(method, params, sessionId)),

‎apps/desktop/src/desktop-browser-cdp.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { createHash, randomBytes, randomUUID } from "node:crypto";
22
import { createServer } from "node:http";
33
import { WebSocket, WebSocketServer } from "ws";
4+
import { jsonObjectSchema } from "@bb/domain";
45
import { z } from "zod";
56

6-
const objectSchema = z.record(z.string(), z.json());
7-
type CdpObject = z.infer<typeof objectSchema>;
7+
type CdpObject = z.infer<typeof jsonObjectSchema>;
88
const commandSchema = z
99
.object({
1010
id: z.number().int().nonnegative(),
1111
method: z.string().min(1).max(256),
12-
params: objectSchema.default({}),
12+
params: jsonObjectSchema.default({}),
1313
sessionId: z.string().min(1).max(256).optional(),
1414
})
1515
.strict();

‎apps/desktop/test/desktop-browser-cdp.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { once } from "node:events";
22
import { afterEach, describe, expect, it, vi } from "vitest";
33
import { WebSocket } from "ws";
4+
import { jsonObjectSchema } from "@bb/domain";
45
import { z } from "zod";
56
import {
67
createDesktopBrowserCdpBridge,
@@ -11,8 +12,7 @@ import {
1112
} from "../src/desktop-browser-cdp.js";
1213
import { createDeferredPromise } from "@bb/test-helpers";
1314

14-
const messageSchema = z.record(z.string(), z.json());
15-
type Message = z.infer<typeof messageSchema>;
15+
type Message = z.infer<typeof jsonObjectSchema>;
1616
const disposers: Array<() => Promise<void>> = [];
1717

1818
afterEach(async () => {
@@ -143,7 +143,7 @@ async function connect(endpoint: string) {
143143
await once(socket, "open");
144144
const messages: Message[] = [];
145145
socket.on("message", (data) =>
146-
messages.push(messageSchema.parse(JSON.parse(data.toString()))),
146+
messages.push(jsonObjectSchema.parse(JSON.parse(data.toString()))),
147147
);
148148
disposers.push(async () => {
149149
if (socket.readyState === WebSocket.CLOSED) return;
@@ -164,7 +164,7 @@ async function connect(endpoint: string) {
164164
2000,
165165
);
166166
const onMessage = (data: Buffer) => {
167-
const message = messageSchema.parse(JSON.parse(data.toString()));
167+
const message = jsonObjectSchema.parse(JSON.parse(data.toString()));
168168
if (message.id !== requestId) return;
169169
clearTimeout(timer);
170170
socket.off("message", onMessage);

‎apps/desktop/test/fixtures/browser-cdp-smoke.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { join } from "node:path";
88
import { promisify } from "node:util";
99
import { app, BrowserWindow, nativeImage } from "electron";
1010
import { WebSocket, WebSocketServer } from "ws";
11+
import { jsonObjectSchema } from "@bb/domain";
1112
import { z } from "zod";
1213
import { desktopBrowserResultSchemas } from "@bb/host-daemon-contract";
1314
import {
@@ -22,8 +23,7 @@ import { createDesktopBrowserBroker } from "../../src/desktop-browser-broker.js"
2223
const execute = promisify(execFile);
2324
const keepAlive = setInterval(() => {}, 1000);
2425
app.once("quit", () => clearInterval(keepAlive));
25-
const objectSchema = z.record(z.string(), z.json());
26-
type CdpObject = z.infer<typeof objectSchema>;
26+
type CdpObject = z.infer<typeof jsonObjectSchema>;
2727
const configSchema = z.object({
2828
artifacts: z.string().min(1),
2929
devBrowser: z.string().min(1),
@@ -37,7 +37,7 @@ const targetListSchema = z.object({
3737
});
3838
const responseSchema = z.object({
3939
id: z.number().optional(),
40-
result: objectSchema.optional(),
40+
result: jsonObjectSchema.optional(),
4141
error: z.object({ message: z.string() }).optional(),
4242
method: z.string().optional(),
4343
});
@@ -275,7 +275,7 @@ async function main() {
275275
.object({
276276
id: z.number(),
277277
method: z.string(),
278-
params: objectSchema.optional(),
278+
params: jsonObjectSchema.optional(),
279279
sessionId: z.string().optional(),
280280
})
281281
.parse(JSON.parse(bytes.toString()));
@@ -296,7 +296,7 @@ async function main() {
296296
else queued.push(bytes);
297297
});
298298
upstream.on("message", (data) => {
299-
const message = objectSchema.parse(JSON.parse(data.toString()));
299+
const message = jsonObjectSchema.parse(JSON.parse(data.toString()));
300300
if (message.method === "Target.attachedToTarget") {
301301
const info = z
302302
.object({
@@ -594,7 +594,7 @@ async function main() {
594594
);
595595
assert.deepEqual(
596596
z
597-
.object({ result: z.object({ value: objectSchema }) })
597+
.object({ result: z.object({ value: jsonObjectSchema }) })
598598
.parse(hiddenResult).result.value,
599599
{
600600
title: "Other thread sentinel",

‎apps/server/test/services/plugins/plugin-authoring-doc-examples.test.ts‎

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -147,28 +147,32 @@ describe("bb-plugin-authoring skill examples", () => {
147147
await rm(workDir, { recursive: true, force: true });
148148
});
149149

150-
it("resolves every SDK reference and compiles every TypeScript example", async () => {
151-
const skill = readSkillTree();
152-
const references = sdkReferences(skill);
153-
const fences = sdkFences(skill);
154-
expect(references.length).toBeGreaterThan(0);
155-
expect(fences.length).toBeGreaterThan(0);
156-
157-
await writeFile(
158-
join(workDir, "probe.ts"),
159-
`${probeSource(references, fences)}\n`,
160-
"utf8",
161-
);
162-
await writeFile(
163-
join(workDir, "tsconfig.json"),
164-
`${JSON.stringify(PROBE_TSCONFIG, null, 2)}\n`,
165-
"utf8",
166-
);
167-
168-
const result = spawnSync(process.execPath, [tsrs, "--project", workDir], {
169-
encoding: "utf8",
170-
});
171-
if (result.error !== undefined) throw result.error;
172-
expect(result.status, `${result.stdout}${result.stderr}`).toBe(0);
173-
}, 60_000);
150+
it.skipIf(process.platform === "win32")(
151+
"resolves every SDK reference and compiles every TypeScript example",
152+
async () => {
153+
const skill = readSkillTree();
154+
const references = sdkReferences(skill);
155+
const fences = sdkFences(skill);
156+
expect(references.length).toBeGreaterThan(0);
157+
expect(fences.length).toBeGreaterThan(0);
158+
159+
await writeFile(
160+
join(workDir, "probe.ts"),
161+
`${probeSource(references, fences)}\n`,
162+
"utf8",
163+
);
164+
await writeFile(
165+
join(workDir, "tsconfig.json"),
166+
`${JSON.stringify(PROBE_TSCONFIG, null, 2)}\n`,
167+
"utf8",
168+
);
169+
170+
const result = spawnSync(process.execPath, [tsrs, "--project", workDir], {
171+
encoding: "utf8",
172+
});
173+
if (result.error !== undefined) throw result.error;
174+
expect(result.status, `${result.stdout}${result.stderr}`).toBe(0);
175+
},
176+
60_000,
177+
);
174178
});

0 commit comments

Comments
 (0)