GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test(codex-proxy): answer model catalog lookup · developing-today/code@ce6757f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • bin
    • codex-proxy.test.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎bin/codex-proxy.test.mjs‎

Copy file name to clipboardExpand all lines: bin/codex-proxy.test.mjs
+29-1Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// host-installed codex can never shadow it, #694.)
1212
// partial output.
1313
import assert from 'node:assert/strict';
14-
import { spawn, execFileSync } from 'node:child_process';
14+
import { spawn, execFile, execFileSync } from 'node:child_process';
1515
import crypto from 'node:crypto';
1616
import fs from 'node:fs';
1717
import net from 'node:net';
@@ -23,6 +23,13 @@ import { fileURLToPath } from 'node:url';
2323
const binDir = path.dirname(fileURLToPath(import.meta.url));
2424

2525
const STUB = `#!/bin/sh
26+
# The proxy runs this through execFile before accepting chat turns. Handle it
27+
# before reading stdin: execFile leaves the child's stdin open, so cat would
28+
# otherwise wait for the 30-second command timeout on every request.
29+
if [ "$1" = "debug" ] && [ "$2" = "models" ]; then
30+
printf '%s\\n' '{"models":[{"slug":"gpt-6.1-sol","display_name":"GPT-6.1 Sol","supported_reasoning_levels":[{"effort":"low"},{"effort":"medium"},{"effort":"high"}],"default_reasoning_level":"medium"},{"slug":"gpt-6-luna","display_name":"GPT-6 Luna","supported_reasoning_levels":[{"effort":"low"},{"effort":"medium"}],"default_reasoning_level":"low"},{"slug":"gpt-5.6-luna","display_name":"GPT-5.6 Luna","supported_reasoning_levels":[{"effort":"low"},{"effort":"medium"}],"default_reasoning_level":"low"}]}'
31+
exit 0
32+
fi
2633
prompt="$(cat)"
2734
resume=0
2835
for a in "$@"; do [ "$a" = "resume" ] && resume=1; done
@@ -78,6 +85,27 @@ case "$prompt" in
7885
esac
7986
`;
8087

88+
test('Codex stub answers live model lookup without blocking on stdin', async (t) => {
89+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'codex-proxy-stub-test-'));
90+
t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));
91+
const stubPath = path.join(tmp, 'codex');
92+
fs.writeFileSync(stubPath, STUB, { mode: 0o755 });
93+
94+
const stdout = await new Promise((resolve, reject) => {
95+
execFile(stubPath, ['debug', 'models'], { timeout: 1000 }, (err, out, stderr) => {
96+
if (err) {
97+
reject(new Error(`codex debug models stub failed: ${err.message}; stderr=${stderr}`));
98+
} else {
99+
resolve(out);
100+
}
101+
});
102+
});
103+
const catalog = JSON.parse(stdout);
104+
assert.ok(Array.isArray(catalog.models));
105+
assert.ok(catalog.models.length >= 3);
106+
assert.ok(catalog.models.some((model) => model.slug === 'gpt-6.1-sol'));
107+
});
108+
81109

82110
// ---------------------------------------------------------------------------
83111
// Fake app-server daemon (#480): a real WebSocket-over-Unix-socket server

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.