Skip to content
Open
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
39 changes: 23 additions & 16 deletions packages/acp-server/test/e2e-turn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ const STDIO_MCP_FIXTURE = fileURLToPath(
new URL('../../agent-core-v2/test/mcpCore/fixtures/mock-stdio-server.mjs', import.meta.url),
);

/**
* Best-effort recursive removal of a test's temp home dir. `fs.rm`'s
* recursive cleanup can transiently ENOTEMPTY/EBUSY right after a file
* handle (or, for the MCP-fixture tests, a child process pipe) in the
* directory closes but the OS hasn't fully released the deletion yet —
* retry with Node's own linear-backoff defaults. Always returns `undefined`
* so call sites can just reassign: `homeDir = await cleanupHomeDir(homeDir);`.
*/
async function cleanupHomeDir(homeDir: string | undefined): Promise<string | undefined> {
if (homeDir !== undefined) {
await rm(homeDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
}
return undefined;
}

describe('acp-server real prompt turn (scripted LLM)', () => {
let homeDir: string | undefined;
let client: TestClient | undefined;
Expand All @@ -38,10 +53,8 @@ describe('acp-server real prompt turn (scripted LLM)', () => {
await client.close();
client = undefined;
}
if (homeDir !== undefined) {
await rm(homeDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
homeDir = undefined;
}

homeDir = await cleanupHomeDir(homeDir);
});

async function boot(clientCapabilities: Record<string, unknown> = {}): Promise<TestClient> {
Expand Down Expand Up @@ -561,10 +574,8 @@ describe('acp-server prompt error hygiene', () => {
await client.close();
client = undefined;
}
if (homeDir !== undefined) {
await rm(homeDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
homeDir = undefined;
}

homeDir = await cleanupHomeDir(homeDir);
});

it('a launch failure settles as a fixed internalError and never leaks the engine message', async () => {
Expand Down Expand Up @@ -608,10 +619,8 @@ describe('acp-server builtin slash commands (local execution, no LLM turn)', ()
await client.close();
client = undefined;
}
if (homeDir !== undefined) {
await rm(homeDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
homeDir = undefined;
}

homeDir = await cleanupHomeDir(homeDir);
});

async function boot(): Promise<TestClient> {
Expand Down Expand Up @@ -825,10 +834,8 @@ describe('acp-server terminal reverse-RPC (clientCapabilities.terminal)', () =>
await client.close();
client = undefined;
}
if (homeDir !== undefined) {
await rm(homeDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
homeDir = undefined;
}

homeDir = await cleanupHomeDir(homeDir);
});

interface FakeTerminal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ describe('config manifest', () => {
const expected = await buildConfigManifest();
const actual = readFileSync(MANIFEST_PATH, 'utf-8');
expect(actual).toBe(expected);
}, 60_000);
}, 120_000);
});
21 changes: 17 additions & 4 deletions packages/agent-core-v2/test/lint/op-uniqueness.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/**
* Scenario: no wire Op type registered via `defineOp` is duplicated across
* `src/`, and a runtime duplicate registration throws `DuplicateOpError`.
*
* The full-`src/`-scan test below does a synchronous, full-tree file read,
* which can exceed the default timeout under slow bind-mounted filesystems
* (e.g. Docker on Windows) — hence its extended timeout.
*/

import { readdirSync, readFileSync, statSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
Expand Down Expand Up @@ -179,10 +188,14 @@ describe('op-uniqueness', () => {
}
});

it('finds no duplicate defineOp types across src/', () => {
const seen = scanDefineOpTypes(SRC_ROOT);
expect(duplicates(seen)).toEqual(new Map());
});
it(
'finds no duplicate defineOp types across src/',
() => {
const seen = scanDefineOpTypes(SRC_ROOT);
expect(duplicates(seen)).toEqual(new Map());
},
20_000,
);

it('flags the planted duplicate in the fixture', () => {
const seen = scanDefineOpTypes(FIXTURE_ROOT);
Expand Down
26 changes: 17 additions & 9 deletions packages/agent-core-v2/test/lint/vendor-name-gates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
* Brand/env names (`KIMI_CODE_*`, `KIMI_MODEL_*`) and `'kimi'` as data
* (config values, telemetry fields, registration ids) do not match the
* patterns — verified against the whole `src/` tree.
*
* The full-`src/`-scan test below does a synchronous, full-tree file read,
* which can exceed the default timeout under slow bind-mounted filesystems
* (e.g. Docker on Windows) — hence its extended timeout.
*/

import { readdirSync, readFileSync, statSync } from 'node:fs';
Expand Down Expand Up @@ -95,13 +99,17 @@ describe('vendor-name gates', () => {
expect(hits).toEqual([]);
});

it('finds no vendor-name gates in src/ outside kosong', () => {
const hits = walk(SRC_ROOT).flatMap((file) =>
findVendorGates(readFileSync(file, 'utf8'), relative(SRC_ROOT, file)),
);
expect(
hits.map((hit) => `${hit.file}:${hit.line} ${hit.text}`),
'vendor-name gate found outside kosong — ask the provider-definition / adapter registries instead',
).toEqual([]);
});
it(
'finds no vendor-name gates in src/ outside kosong',
() => {
const hits = walk(SRC_ROOT).flatMap((file) =>
findVendorGates(readFileSync(file, 'utf8'), relative(SRC_ROOT, file)),
);
expect(
hits.map((hit) => `${hit.file}:${hit.line} ${hit.text}`),
'vendor-name gate found outside kosong — ask the provider-definition / adapter registries instead',
).toEqual([]);
},
20_000,
);
});
10 changes: 9 additions & 1 deletion packages/agent-core-v2/test/tool/tool.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Agent tool execution contract tests.
*
* The background-subagent-spawn scenario below uses pure in-memory stubs,
* but this file's worker can be CPU-starved under parallel load in
* resource-constrained containers, hence its extended timeout.
*/

import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
Expand Down Expand Up @@ -1099,7 +1107,7 @@ describe('Agent tool execution contract', () => {
expect(result.output).toContain('agent_id: agent-child');
expect(result.output).toContain('actual_subagent_type: explore');
expect(result.output).toContain('child result');
});
}, 15_000);

it('spawns the subagent on the configured secondary model by default', async () => {
const lifecycle = createAgentLifecycleStub({ createAgentIds: ['agent-child'] });
Expand Down
2 changes: 1 addition & 1 deletion packages/agent-core-v2/test/wire/wireManifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('wire manifest', () => {
const expected = await buildWireManifest();
const actual = readFileSync(MANIFEST_PATH, 'utf-8');
expect(actual).toBe(expected);
}, 60_000);
}, 120_000);

it('docs/wire-manifest.d.ts parses as TypeScript', () => {
const project = new Project({ useInMemoryFileSystem: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ describe('workspace resource sharing (handler chain)', () => {
afterEach(async () => {
host?.dispose();
host = undefined;
await Promise.all(tmpRoots.map((root) => rm(root, { recursive: true, force: true })));
await Promise.all(
tmpRoots.map((root) => rm(root, { recursive: true, force: true, maxRetries: 3, retryDelay: 10 })),
);
});

async function makeRoot(prefix: string): Promise<string> {
Expand Down
Loading