feat(codex): support backend-authorized Luna Reserve fallback (#1780)

* feat(codex): reconcile Luna Reserve fallback and conditional usage

* fix(codex): preserve queued settings and reconcile Reserve sessions
This commit is contained in:
SSU-WEI HUANG
2026-09-09 09:27:40 +08:00
committed by GitHub
parent 5c5c8b3a9f
commit 8357da0a9d
18 changed files with 928 additions and 21 deletions
@@ -62,6 +62,26 @@ describe('CodexAppServerClient process cwd', () => {
spawnMock.mockReset();
});
it('uses null for legacy usage reads and opts in only when Reserve is supported', async () => {
const child = fakeChild();
child.stdin.write = vi.fn((_data: unknown, callback?: (error?: Error | null) => void) => {
callback?.();
return true;
});
spawnMock.mockReturnValue(child);
const client = new CodexAppServerClient({ cwd: '/neutral-home' });
await client.connect();
for (const supported of [false, true]) {
const pending = client.readAccountRateLimits(supported);
const request = JSON.parse(child.stdin.write.mock.lastCall![0] as string);
expect(request.method).toBe('account/rateLimits/read');
expect(request.params).toEqual(supported ? { supportsLunaReserve: true } : null);
child.stdout.emit('data', Buffer.from(JSON.stringify({ id: request.id, result: { rateLimits: {} } }) + '\n'));
await expect(pending).resolves.toEqual({ rateLimits: {} });
}
await client.disconnect();
});
it('passes an explicit neutral cwd to the app-server process', async () => {
spawnMock.mockReturnValue(fakeChild());
const client = new CodexAppServerClient({ cwd: '/neutral-home' });