Cover unknown agent session write and kill runtime behavior

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-10 00:14:14 +00:00
1 parent a9fbb004bf
commit baf36427b3
1 file changed
+52
+52
View File
@@ -1330,6 +1330,58 @@ describe("runtimeApiServer", () => {
client.socket.close();
});
it("returns structured errors when writing to unknown agent session", async () => {
const server = await startRuntimeApiServer({
port: 0,
launchCwd: process.cwd(),
});
servers.push(server);
const client = await connectClient(server.wsUrl);
await client.nextMessage();
const response = await sendRequest(
client.socket,
client.nextMessage,
"agent-write-unknown-1",
"agent.write",
{
sessionId: "missing-session-id",
data: "hello",
},
);
expect(response.ok).toBe(false);
if (response.ok) {
throw new Error("Expected unknown agent.write session to fail.");
}
expect(response.error?.code).toBe("request_failed");
client.socket.close();
});
it("treats agent.kill for unknown session as successful no-op", async () => {
const server = await startRuntimeApiServer({
port: 0,
launchCwd: process.cwd(),
});
servers.push(server);
const client = await connectClient(server.wsUrl);
await client.nextMessage();
const response = await sendRequest(
client.socket,
client.nextMessage,
"agent-kill-unknown-1",
"agent.kill",
"missing-session-id",
);
expect(response.ok).toBe(true);
expect(response.result).toBeNull();
client.socket.close();
});
it("reports runtime health metadata", async () => {
const server = await startRuntimeApiServer({
port: 0,