feat(agent): make coordination routes opt-in and address review

Gate inspect, stage and submit behind the synced agentCoordinationEnabled
setting (default OFF, App Settings > Cross-session features, zh-CN
strings). While off, all three routes answer 403 FORBIDDEN naming the
setting, checked before session lookup; the CLI verbs print it verbatim.

Remember the attributed Codex rollout per session and re-verify only its
head on later calls, rescanning only date directories not older than it
for a /new conflict. The first walk reads 1 KiB prefixes first, so a
store of 2,100+ unrelated rollouts still attributes.

Answer unexpected inspection errors with 422 OPERATION_FAILED and log
the session id and error code only.

Read the guarded composer glyph and footer from the CLI registry: codex
workDetect.promptGlyph and a new workDetect.composerFooterLine
capability, compiled through compileVersionRegex. Codex footer effort
words are one shared list with modelDetect.screenLine.

Fix the wiki API reference link, frame the versioning policy entry as a
case of the experimental rule, join the CLAUDE.md Agent CLI paragraph,
and update the changeset, skill reference and architecture notes.
This commit is contained in:
Aamer Akhter committed 2026-10-24 22:54:17 -04:00
1 parent 1a2c3be0ea
commit c78635a3d3
32 files changed
+848 -124

No files matched your search

+25
View File
@@ -45,8 +45,32 @@ describe('WebServer on an ephemeral port', () => {
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);
const { mkdirSync, rmSync, writeFileSync } = await import('node:fs');
const { dirname } = await import('node:path');
const { SETTINGS_PATH } = await import('../src/web/route-helpers.js');
const setEnabled = (on: boolean) => {
mkdirSync(dirname(SETTINGS_PATH), { recursive: true });
writeFileSync(SETTINGS_PATH, JSON.stringify({ agentCoordinationEnabled: on }));
};
try {
const prefix = `http://127.0.0.1:${server.boundPort}/api/v1/sessions/${session.id}`;
// Opt-in: off, the /api/v1 alias of every route refuses with 403 FORBIDDEN.
setEnabled(false);
for (const [method, verb] of [
['GET', 'inspect'],
['POST', 'stage'],
['POST', 'submit'],
] as const) {
const refused = await fetch(prefix + '/' + verb, {
method,
...(method === 'POST' ? { headers: { 'Content-Type': 'application/json' }, body: '{}' } : {}),
});
expect(refused.status).toBe(403);
const body = await refused.json();
expect(body.errorCode).toBe('FORBIDDEN');
expect(body.error).toContain('agentCoordinationEnabled');
}
setEnabled(true);
const inspected = await fetch(prefix + '/inspect');
expect(inspected.status).toBe(200);
expect((await inspected.json()).data.source).toBe('pane-snapshot');
@@ -63,6 +87,7 @@ describe('WebServer on an ephemeral port', () => {
expect((await response.json()).errorCode).toBe('CONFLICT');
}
} finally {
rmSync(SETTINGS_PATH, { force: true });
sessions.delete(session.id);
await session.stop(false);
}