Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/codex-responses-ws.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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}`);
Expand Down Expand Up @@ -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(); }
});
9 changes: 5 additions & 4 deletions tests/issue1987-preflight-baseline-anchor.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
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";
// One attempt per summarization call: this test is about the post-fold baseline, not retries.
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";
Expand Down Expand Up @@ -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" };

Expand Down
3 changes: 2 additions & 1 deletion tests/issue1993-preflight-400.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions tests/ws-bridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>(resolve => server.listen(0, "127.0.0.1", resolve));
return { server, handler, logs, port: (server.address() as AddressInfo).port };
Expand Down Expand Up @@ -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<void>(resolve => upstream.close(() => resolve()));
}
});
Loading