Pre-bootstrap two cursor-agent processes so createSession skips spawn/initialize on the hot path, open SSE before session setup, and log per-stage durations for first-token diagnosis.
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
import { describe, it } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
extractToolNameFromPermission,
|
|
fmtMs,
|
|
nowMs,
|
|
WARM_POOL_SIZE,
|
|
} from "./session-manager.mjs";
|
|
|
|
describe("fmtMs / nowMs", () => {
|
|
it("formats durations to one decimal millisecond", () => {
|
|
assert.equal(fmtMs(12.34), "12.3ms");
|
|
assert.equal(fmtMs(0), "0ms");
|
|
});
|
|
|
|
it("nowMs is monotonic numeric", () => {
|
|
const a = nowMs();
|
|
const b = nowMs();
|
|
assert.equal(typeof a, "number");
|
|
assert.ok(b >= a);
|
|
});
|
|
|
|
it("exposes WARM_POOL_SIZE as a non-negative integer", () => {
|
|
assert.equal(typeof WARM_POOL_SIZE, "number");
|
|
assert.ok(WARM_POOL_SIZE >= 0);
|
|
});
|
|
});
|
|
|
|
describe("extractToolNameFromPermission", () => {
|
|
it("parses client MCP title format", () => {
|
|
const name = extractToolNameFromPermission({
|
|
toolCall: { title: "client-get_weather: get_weather" },
|
|
});
|
|
assert.equal(name, "get_weather");
|
|
});
|
|
|
|
it("strips mcp_client_ prefix from rawInput name", () => {
|
|
const name = extractToolNameFromPermission({
|
|
toolCall: { rawInput: { name: "mcp_client_get_weather" } },
|
|
});
|
|
assert.equal(name, "get_weather");
|
|
});
|
|
|
|
it("uses first token for built-in tools", () => {
|
|
const name = extractToolNameFromPermission({
|
|
toolCall: { title: "Shell: rm -rf /" },
|
|
});
|
|
assert.equal(name, "Shell");
|
|
});
|
|
});
|