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
3 changes: 2 additions & 1 deletion app/api/auth/login/[provider]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ export async function GET(
req.signal.addEventListener("abort", cleanup);

try {
await child.waitReady(READY_TIMEOUT_MS);
const ready = await child.waitReady(READY_TIMEOUT_MS);
await child.negotiateProtocol(ready);
await child.sendCommand({ type: "login", providerId: provider }, LOGIN_TIMEOUT_MS);
enableProvider(provider);
invalidateModelsCache();
Expand Down
11 changes: 11 additions & 0 deletions lib/api-contract.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ test("agent command routes reject malformed commands and map RPC failures to 400
assert.match(newRoute, /newSessionErrorResponse/);
});

test("interactive login negotiates RPC v2 before sending the login command", async () => {
const route = await readFile(new URL("../app/api/auth/login/[provider]/route.ts", import.meta.url), "utf8");
const waitReady = route.indexOf("await child.waitReady(READY_TIMEOUT_MS)");
const negotiate = route.indexOf("await child.negotiateProtocol(ready)");
const login = route.indexOf('await child.sendCommand({ type: "login"');

assert.ok(waitReady >= 0);
assert.ok(negotiate > waitReady);
assert.ok(login > negotiate);
});

test("session archive route stops live children and maps missing sessions", async () => {
const route = await readFile(new URL("../app/api/sessions/[id]/archive/route.ts", import.meta.url), "utf8");
const utils = await readFile(new URL("../lib/api-utils.ts", import.meta.url), "utf8");
Expand Down