diff --git a/tests/codex-responses-ws.test.ts b/tests/codex-responses-ws.test.ts index adebd3b3e5..1e41e3ec54 100644 --- a/tests/codex-responses-ws.test.ts +++ b/tests/codex-responses-ws.test.ts @@ -141,7 +141,7 @@ test("codex WS: prewarm probe plus full-replay turns ride the prefix lane throug assert.match(String(f.rows[0].headers["user-agent"]), /^codex_exec\//); // The real turn is a full replay the pipeline processed: bili's ACP // tools ride alongside codex's own (empty) tool list. - assert.ok(Array.isArray(f.rows[1].request.tools) && (f.rows[1].request.tools as Item[]).some(t => t.name === "acp_status" || t.name === "compress"), JSON.stringify(f.rows[1].request.tools?.map?.((t: Item) => t.name))); + assert.ok(Array.isArray(f.rows[1].request.tools) && (f.rows[1].request.tools as Item[]).some(t => t.name === "acp_status" || t.name === "compress"), JSON.stringify((f.rows[1].request.tools as Item[]).map(t => t.name))); assert.ok(JSON.stringify(f.rows[1].request.input).includes("codex-first-turn")); const session = peekSession(f.sid); assert.ok(session); @@ -189,7 +189,7 @@ test("codex WS: folding covered history shrinks the replayed turn", { timeout: 3 }; await play("session purpose: codex prefix-lane ACP integration"); await play("OLD-BULKY-SENTINEL " + "unique filler content ".repeat(1200)); - const firstText = JSON.stringify(f.rows.at(-1)!.request.input.find(item => JSON.stringify(item).includes("OLD-BULKY-SENTINEL"))); + const firstText = JSON.stringify((f.rows.at(-1)!.request.input as Item[]).find((item: Item) => JSON.stringify(item).includes("OLD-BULKY-SENTINEL"))); const ref = firstText.match(/\x3cacp[^\x3e]*\x3e(m\d+)\x3c\/acp\x3e/)?.[1]; assert.ok(ref, firstText.slice(-300)); for (let i = 0; i < 4; i++) await play(`push ${i}`); @@ -239,6 +239,6 @@ test("codex WS: non-streaming transport options are refused with a protocol erro f.peer.send(f.frame([user("nope")], { stream: false })); const error = await done; assert.equal(error.type, "error"); - assert.equal(error.error.code, "invalid_request"); + assert.equal((error.error as { code: string }).code, "invalid_request"); } finally { await f.close(); } }); diff --git a/tests/issue1987-preflight-baseline-anchor.test.ts b/tests/issue1987-preflight-baseline-anchor.test.ts index 9c8a5d9100..dd261ced79 100644 --- a/tests/issue1987-preflight-baseline-anchor.test.ts +++ b/tests/issue1987-preflight-baseline-anchor.test.ts @@ -1,6 +1,7 @@ import assert from "node:assert/strict"; import http from "node:http"; import { once } from "node:events"; +import type { AddressInfo } from "node:net"; import test from "node:test"; process.env.NODE_ENV = "test"; @@ -8,8 +9,8 @@ process.env.NODE_ENV = "test"; process.env.BILI_REPLAY_RETRY_MAX = "1"; import { defaultConfig, type Config } from "acp-kernel"; -import { startServer, type ProxyOptions } from "../src/server.ts"; -import { type CompressSettings } from "../src/config.ts"; +import { startServer } from "../src/server.ts"; +import { type CompressSettings, type ProxyOptions } from "../src/config.ts"; import { SessionStore, _setStoreForTest } from "../src/persist.ts"; import { _setForTest as setRegistryForTest } from "../src/registry.ts"; import { getSession } from "../src/session.ts"; @@ -88,11 +89,11 @@ test("e2e #1987: post-fold usage baseline anchors to the shipped payload, not th const upstream = makeUpstream(calls); upstream.listen(0, "127.0.0.1"); await once(upstream, "listening"); - const upstreamPort = upstream.address().port; + const upstreamPort = (upstream.address() as AddressInfo).port; const proxy = await startProxy(upstreamPort, { "claude-small": { context: 10_000 } }); await once(proxy, "listening"); - const proxyPort = proxy.address().port; + const proxyPort = (proxy.address() as AddressInfo).port; const url = `http://127.0.0.1:${proxyPort}/bili/http://127.0.0.1:${upstreamPort}/v1/messages`; const headers = { "content-type": "application/json", "x-acp-session": "issue1987-anchor-sess" }; diff --git a/tests/issue1993-preflight-400.test.ts b/tests/issue1993-preflight-400.test.ts index c4d5398b24..56e9e76253 100644 --- a/tests/issue1993-preflight-400.test.ts +++ b/tests/issue1993-preflight-400.test.ts @@ -14,7 +14,8 @@ process.env.BILI_REPLAY_RETRY_BASE_MS = "0"; process.env.BILI_PREFLIGHT_DEAD_END_COOLDOWN_MS = "400"; import { defaultConfig } from "acp-kernel"; -import { startServer, type ProxyOptions } from "../src/server.ts"; +import { startServer } from "../src/server.ts"; +import { type ProxyOptions } from "../src/config.ts"; import { SessionStore, _setStoreForTest } from "../src/persist.ts"; import { _setForTest as setRegistryForTest } from "../src/registry.ts"; import { listSessions } from "../src/session.ts"; diff --git a/tests/ws-bridge.test.ts b/tests/ws-bridge.test.ts index 002336faad..6d2a20fa7e 100644 --- a/tests/ws-bridge.test.ts +++ b/tests/ws-bridge.test.ts @@ -42,7 +42,7 @@ const fakeCodec: WsBridgeCodec = { async function harness(codecs: readonly WsBridgeCodec[]) { const server = http.createServer((_req, res) => res.writeHead(404).end()); const logs: string[] = []; - const handler = installWebSocketBridge(server, (_req, res) => Promise.resolve(res.writeHead(200).end()), (level, message) => logs.push(`${level} ${message}`), codecs); + const handler = installWebSocketBridge(server, async (_req, res) => { res.writeHead(200).end(); }, (level, message) => logs.push(`${level} ${message}`), codecs); server.on("upgrade", (req, socket, head) => { if (!handler(req, socket, head)) socket.destroy(); }); await new Promise(resolve => server.listen(0, "127.0.0.1", resolve)); return { server, handler, logs, port: (server.address() as AddressInfo).port }; @@ -108,6 +108,6 @@ test("ws bridge: server close shuts every session down and terminates peers", as assert.deepEqual(session.shutdowns, ["server-close"]); assert.equal(socket.readyState, WebSocket.CLOSED); } finally { - await new Promise(resolve => upstream.close(() => resolve())); + await new Promise(resolve => upstream.close(() => resolve())); } });