Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): prefer extractCodexAssistantTail for newer codex CLI output format
Adam Eivy31868d8c9f77
diff --git a/server/services/visionCli.js b/server/services/visionCli.jsindex 03afdf7901..116dec0fe7 100644--- a/server/services/visionCli.js+++ b/server/services/visionCli.js@@ -29,7 +29,7 @@ import { tmpdir } from 'os';import { join } from 'path';import { buildCliArgs } from '../lib/cliProviderArgs.js';import { resolveCliModel } from '../lib/providerModels.js';-import { extractCodexAssistant } from '../lib/codexAssistantExtract.js';+import { extractCodexAssistant, extractCodexAssistantTail } from '../lib/codexAssistantExtract.js';const CLI_VISION_TIMEOUT_MS = 120000;const IMAGE_BASENAME = 'vision-input.png';@@ -145,9 +145,11 @@ export async function describeImageViaCli({// `codex exec` prints the whole session transcript (banner, echoed// prompt, tool sections, `tokens used` footer) to stdout — carve out// the assistant reply so captioning doesn't persist the transcript as- // the caption. A no-op for non-codex output (extractCodexAssistant- // returns its input unless it starts with the Codex banner).- if (code === 0) return resolve(extractCodexAssistant(out).trim());+ // the caption. Newer Codex emits the final reply AFTER the `tokens used`+ // footer (extractCodexAssistantTail), older versions before it+ // (extractCodexAssistant); try tail first, then the legacy extractor,+ // both no-ops for non-codex output (tail → null, legacy → input).+ if (code === 0) return resolve((extractCodexAssistantTail(out) ?? extractCodexAssistant(out)).trim());const tail = err.trim().split('\n').slice(-4).join('\n');reject(new Error(`${command} vision call exited ${code}${tail ? `: ${tail}` : ''}`));});diff --git a/server/services/visionCli.test.js b/server/services/visionCli.test.jsindex 91a3135234..404bff4295 100644--- a/server/services/visionCli.test.js+++ b/server/services/visionCli.test.js@@ -121,6 +121,31 @@ describe('describeImageViaCli', () => {expect(result.text).toBe('a woman in a red cloak, bust shot');});+ it('extracts the assistant reply when codex emits it AFTER the tokens-used footer', async () => {+ const child = makeFakeChild();+ const spawnImpl = vi.fn(() => child);+ const promise = describeImageViaCli({+ provider: { id: 'codex', command: 'codex', args: [] },+ dataUrl: PNG_DATA_URL,+ prompt: 'caption',+ spawnImpl,+ });+ await new Promise((r) => setTimeout(r, 10));+ // Newer codex format: the final reply follows the `tokens used\n<count>` footer.+ const transcript = [+ 'OpenAI Codex v0.141.0',+ 'codex',+ '(intermediate working notes)',+ 'tokens used',+ '1234',+ '{"boxes":[{"x":0,"y":0,"w":0.5,"h":1}]}',+ ].join('\n');+ child.stdout.emit('data', Buffer.from(transcript));+ child.emit('close', 0);+ const result = await promise;+ expect(result.text).toBe('{"boxes":[{"x":0,"y":0,"w":0.5,"h":1}]}');+ });+it('rejects with a tail of stderr on a non-zero exit', async () => {const child = makeFakeChild();const spawnImpl = vi.fn(() => child);