fix(agent): address inspection and staging review feedback

This commit is contained in:
Aamer Akhter committed 2026-10-24 22:37:18 -04:00
1 parent a24b0ec7bb
commit 4c2f050a96
24 files changed
+517 -116

No files matched your search

+28
View File
@@ -40,6 +40,34 @@ describe('WebServer on an ephemeral port', () => {
expect(ctx.port).toBe(socketPort());
});
it('registers bounded agent routes with the server route modules', async () => {
const { Session } = await import('../src/session.js');
const session = new Session({ id: 'agent-route-wiring', workingDir: process.env.HOME!, mode: 'shell' });
const sessions = (server as unknown as { sessions: Map<string, typeof session> }).sessions;
sessions.set(session.id, session);
try {
const prefix = `http://127.0.0.1:${server.boundPort}/api/v1/sessions/${session.id}`;
const inspected = await fetch(prefix + '/inspect');
expect(inspected.status).toBe(200);
expect((await inspected.json()).data.source).toBe('pane-snapshot');
for (const [verb, body] of [
['stage', { message: 'hello' }],
['submit', { stageId: '11111111-1111-4111-8111-111111111111', confirmSha: 'a'.repeat(64) }],
] as const) {
const response = await fetch(prefix + '/' + verb, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
expect(response.status).toBe(409);
expect((await response.json()).errorCode).toBe('CONFLICT');
}
} finally {
sessions.delete(session.id);
await session.stop(false);
}
});
it('exports the real port to the panes as CODEMAN_API_URL', () => {
expect(process.env.CODEMAN_API_URL).toBe(`http://127.0.0.1:${socketPort()}`);
});