Skip to content
Merged
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 2 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,8 @@ function injectModelsConfig(logger: { info: (msg: string) => void }): void {
needsWrite = true;
}
const allowlist = defaults.models as Record<string, unknown>;
// Clean out old blockrun entries that aren't in TOP_MODELS (from previous versions)
const topSet = new Set(TOP_MODELS.map((id) => `blockrun/${id}`));
for (const key of Object.keys(allowlist)) {
if (key.startsWith("blockrun/") && !topSet.has(key)) {
delete allowlist[key];
needsWrite = true;
}
}
// Additive-only: add TOP_MODELS entries if missing, never delete user-defined entries.
// Preserves any blockrun/* IDs the user has manually added outside this curated list.
let addedCount = 0;
for (const id of TOP_MODELS) {
const key = `blockrun/${id}`;
Expand Down
20 changes: 15 additions & 5 deletions test/integration/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,43 @@
* Integration test setup — programmatically starts ClawRouter proxy.
*
* Shared across all integration test files via beforeAll/afterAll.
* Starts the proxy on port 8402, waits for /health to return 200,
* and caches the handle so multiple test files share one instance.
* Starts the proxy on a worker-scoped port, waits for /health to return 200,
* and caches the handle so test files in the same worker share one instance.
*/

import { startProxy } from "../../src/proxy.js";
import { resolveOrGenerateWalletKey } from "../../src/auth.js";
import type { ProxyHandle } from "../../src/proxy.js";

const TEST_PORT = 8402;
const HEALTH_POLL_INTERVAL_MS = 200;
const HEALTH_TIMEOUT_MS = 5_000;

let proxyHandle: ProxyHandle | undefined;

function getTestPort(): number {
// Keep worker 1 on the historical default (8402), then offset others.
const workerRaw = process.env.VITEST_POOL_ID ?? process.env.VITEST_WORKER_ID ?? "1";
const workerId = Number.parseInt(workerRaw, 10);
if (Number.isInteger(workerId) && workerId >= 1) {
return 8401 + workerId;
}
return 8402;
}

/**
* Start the test proxy on port 8402.
* Start the test proxy on a worker-scoped port.
* Polls /health until it returns 200 (up to 5s), then returns the handle.
* Reuses an existing handle if already started.
*/
export async function startTestProxy(): Promise<ProxyHandle> {
if (proxyHandle) return proxyHandle;

const wallet = await resolveOrGenerateWalletKey();
const testPort = getTestPort();

proxyHandle = await startProxy({
wallet,
port: TEST_PORT,
port: testPort,
skipBalanceCheck: true,
});

Expand Down