@cartanova/qgrid-cli 2.15.2 → 2.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/dist/application/qgrid/qgrid.frame.js +154 -8
- package/bundle/dist/application/qgrid/qgrid.types.js +6 -3
- package/bundle/dist/i18n/en.js +2 -1
- package/bundle/dist/i18n/ko.js +2 -1
- package/bundle/dist/utils/providers/openai/openai-backend-protocol.js +6 -54
- package/bundle/dist/utils/providers/openai/openai-direct-client.js +2 -2
- package/bundle/dist/utils/providers/openai/openai-dispatcher.js +47 -19
- package/bundle/dist/utils/providers/openai/openai-image-generation.js +1 -2
- package/bundle/dist/utils/providers/openai/openai-realtime-protocol.js +389 -0
- package/bundle/dist/utils/providers/openai/openai-voice-client.js +456 -0
- package/bundle/src/application/qgrid/qgrid.frame.test.ts +6 -6
- package/bundle/src/application/qgrid/qgrid.frame.ts +213 -9
- package/bundle/src/application/qgrid/qgrid.types.ts +14 -2
- package/bundle/src/application/sonamu.generated.http +2 -0
- package/bundle/src/i18n/en.ts +1 -0
- package/bundle/src/i18n/ko.ts +1 -0
- package/bundle/src/utils/providers/openai/openai-backend-protocol.test.ts +8 -69
- package/bundle/src/utils/providers/openai/openai-backend-protocol.ts +7 -86
- package/bundle/src/utils/providers/openai/openai-direct-client.test.ts +0 -15
- package/bundle/src/utils/providers/openai/openai-direct-client.ts +3 -1
- package/bundle/src/utils/providers/openai/openai-dispatcher.test.ts +19 -93
- package/bundle/src/utils/providers/openai/openai-dispatcher.ts +98 -47
- package/bundle/src/utils/providers/openai/openai-image-generation.test.ts +6 -4
- package/bundle/src/utils/providers/openai/openai-image-generation.ts +0 -6
- package/bundle/src/utils/providers/openai/openai-realtime-protocol.ts +550 -0
- package/bundle/src/utils/providers/openai/openai-voice-client.test.ts +576 -0
- package/bundle/src/utils/providers/openai/openai-voice-client.ts +738 -0
- package/bundle/web-dist/client/assets/{index-VhUpqKIg.js → index-CRdZwZsw.js} +3 -3
- package/bundle/web-dist/client/assets/{logs-BwSzVf_A.js → logs-DyLC_2Rf.js} +1 -1
- package/bundle/web-dist/client/assets/{monit-B2CVdIml.js → monit-C0hO3Fy6.js} +1 -1
- package/bundle/web-dist/client/assets/{routes-BOOXpy3Q.js → routes-DTw4jsHI.js} +1 -1
- package/bundle/web-dist/client/assets/{settings-B_a3Nr0H.js → settings-Dg-1zSMq.js} +1 -1
- package/bundle/web-dist/client/assets/{show-D5Uxcb4a.js → show-BmqUEs1O.js} +1 -1
- package/bundle/web-dist/client/assets/{tokens-zlrqnP63.js → tokens-FQ82u55y.js} +1 -1
- package/bundle/web-dist/client/assets/{use-oauth-login-flow-qR-56G2w.js → use-oauth-login-flow-BXmbUSjc.js} +1 -1
- package/bundle/web-dist/client/assets/{use-update-token-mutation-B-vcLRx-.js → use-update-token-mutation-BWlMl3qg.js} +1 -1
- package/bundle/web-dist/client/index.html +1 -1
- package/bundle/web-dist/server/assets/{logs-6289J29J.js → logs-WZMx5ErO.js} +3 -3
- package/bundle/web-dist/server/assets/{monit-YVvwJuAF.js → monit-Bf6U1Xp5.js} +2 -2
- package/bundle/web-dist/server/assets/{plus-z5Hy__3C.js → plus-BwpfWi3W.js} +1 -1
- package/bundle/web-dist/server/assets/{refresh-cw-CNm0CERy.js → refresh-cw-Xk9nLu8E.js} +1 -1
- package/bundle/web-dist/server/assets/{request-model-DIuPZZwu.js → request-model-ByadPBS5.js} +1 -1
- package/bundle/web-dist/server/assets/{routes-CCdBJqP_.js → routes-WFysbWfc.js} +3 -3
- package/bundle/web-dist/server/assets/{services.generated-CqS8DCjT.js → services.generated-Bej_fJ74.js} +2 -0
- package/bundle/web-dist/server/assets/{settings-CXwnKiMG.js → settings-DnAbfheS.js} +3 -3
- package/bundle/web-dist/server/assets/{show-G1t8dOEh.js → show-DvpdOIGn.js} +2 -2
- package/bundle/web-dist/server/assets/{tokens-C4D67FBX.js → tokens-CAc4t_kZ.js} +4 -4
- package/bundle/web-dist/server/assets/{use-oauth-login-flow-CFzShQtp.js → use-oauth-login-flow-Cxm_7Qg6.js} +4 -4
- package/bundle/web-dist/server/assets/{use-update-token-mutation-oH0O0n-g.js → use-update-token-mutation-DnxqIThp.js} +1 -1
- package/bundle/web-dist/server/entry-server.generated.js +25 -25
- package/dist/cli.js +9 -38
- package/package.json +2 -2
- package/skills/qgrid/SKILL.md +5 -5
- package/skills/qgrid/references/ai-sdk-provider-contract.md +4 -0
- package/skills/qgrid/references/decision-rationale.md +13 -3
- package/skills/qgrid/references/openai-codex-runtime.md +17 -5
- package/skills/qgrid/references/request-log-run-lifecycle.md +2 -2
- package/skills/qgrid/references/sonamu-api-web-flow.md +1 -1
- package/skills/qgrid/references/verification-and-debugging.md +3 -3
package/dist/cli.js
CHANGED
|
@@ -27,7 +27,6 @@ function applyQgridDatabaseEnv(env) {
|
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/self-update.ts
|
|
29
29
|
const SELF_UPDATE_CHECK_TIMEOUT_MS = 15e3;
|
|
30
|
-
const SELF_UPDATE_INSTALL_TIMEOUT_MS = 12e4;
|
|
31
30
|
function parseVersion(output) {
|
|
32
31
|
return output?.match(/\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?/)?.[0] ?? null;
|
|
33
32
|
}
|
|
@@ -154,9 +153,9 @@ function readCliPackage() {
|
|
|
154
153
|
const pkg = readCliPackage();
|
|
155
154
|
const RUNTIME_CLI_DEPENDENCIES = [{
|
|
156
155
|
command: "claude",
|
|
157
|
-
packageName: "@anthropic-ai/claude-code",
|
|
158
156
|
label: "Claude Code",
|
|
159
|
-
missingReason: "Anthropic tokens require Claude Code."
|
|
157
|
+
missingReason: "Anthropic tokens require Claude Code.",
|
|
158
|
+
installGuide: "https://code.claude.com/docs/en/setup"
|
|
160
159
|
}];
|
|
161
160
|
function commandVersion(command, env = process.env) {
|
|
162
161
|
try {
|
|
@@ -192,40 +191,12 @@ function commandPath(command) {
|
|
|
192
191
|
return "";
|
|
193
192
|
}
|
|
194
193
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
console.warn(`Install: npm i -g ${dep.packageName}`);
|
|
198
|
-
}
|
|
199
|
-
function installRuntimeCliDependency(dep) {
|
|
200
|
-
execFileSync("npm", [
|
|
201
|
-
"i",
|
|
202
|
-
"-g",
|
|
203
|
-
`${dep.packageName}@latest`
|
|
204
|
-
], {
|
|
205
|
-
stdio: "inherit",
|
|
206
|
-
timeout: SELF_UPDATE_INSTALL_TIMEOUT_MS
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
function ensureLatestRuntimeCliDependencies() {
|
|
194
|
+
/** 런타임 CLI는 사용하는 쪽이 설치·업데이트를 관리한다. qgrid는 없을 때 경고만 한다. */
|
|
195
|
+
function warnMissingRuntimeCliDependencies() {
|
|
210
196
|
for (const dep of RUNTIME_CLI_DEPENDENCIES) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (installed) {
|
|
215
|
-
const latest = packageLatestVersion(dep.packageName);
|
|
216
|
-
if (installed === latest) continue;
|
|
217
|
-
console.log(`Updating ${dep.label}: ${installed} → ${latest}`);
|
|
218
|
-
installRuntimeCliDependency(dep);
|
|
219
|
-
installedOutput = commandVersion(dep.command);
|
|
220
|
-
} else {
|
|
221
|
-
console.log(`Updating ${dep.label}: installing latest`);
|
|
222
|
-
installRuntimeCliDependency(dep);
|
|
223
|
-
installedOutput = commandVersion(dep.command);
|
|
224
|
-
}
|
|
225
|
-
} catch (e) {
|
|
226
|
-
console.warn(`Warning: failed to update ${dep.label}: ${e instanceof Error ? e.message : String(e)}`);
|
|
227
|
-
}
|
|
228
|
-
if (!installedOutput) warnMissingRuntimeCliDependency(dep);
|
|
197
|
+
if (commandVersion(dep.command)) continue;
|
|
198
|
+
console.warn(`Warning: ${dep.command} CLI not found. ${dep.missingReason}`);
|
|
199
|
+
console.warn(`Install ${dep.label}: ${dep.installGuide}`);
|
|
229
200
|
}
|
|
230
201
|
}
|
|
231
202
|
function normalizePort(value) {
|
|
@@ -266,7 +237,7 @@ program.name("qgrid").version(pkg.version).description("Qgrid — LLM subscripti
|
|
|
266
237
|
});
|
|
267
238
|
if (outcome.kind === "exit") process.exit(outcome.exitCode);
|
|
268
239
|
}
|
|
269
|
-
|
|
240
|
+
warnMissingRuntimeCliDependencies();
|
|
270
241
|
if (opts.db) {
|
|
271
242
|
const m = opts.db.match(/^postgres(?:ql)?:\/\/([^:]+):(.+)@([^:]+):(\d+)\/(.+)$/);
|
|
272
243
|
if (!m) {
|
|
@@ -329,4 +300,4 @@ program.name("qgrid").version(pkg.version).description("Qgrid — LLM subscripti
|
|
|
329
300
|
});
|
|
330
301
|
program.parse();
|
|
331
302
|
//#endregion
|
|
332
|
-
export {
|
|
303
|
+
export { warnMissingRuntimeCliDependencies };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cartanova/qgrid-cli",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/cartanova-ai/qgrid"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"knex": "^3.3.0",
|
|
37
37
|
"pg": "^8.23.1",
|
|
38
38
|
"pngjs": "^7.0.0",
|
|
39
|
-
"sonamu": "0.13.
|
|
39
|
+
"sonamu": "0.13.6",
|
|
40
40
|
"typescript": "7.1.0-dev.20260831.1",
|
|
41
41
|
"ws": "8.20.0",
|
|
42
42
|
"zod": "^4.6.7"
|
package/skills/qgrid/SKILL.md
CHANGED
|
@@ -55,7 +55,7 @@ Request logging is enabled by default. Use `providerOptions.qgrid.logger: false`
|
|
|
55
55
|
- Prefer `getPuri()` for Sonamu model queries. Treat `getDB()` as a legacy escape hatch only when Puri cannot express the required query. Inside `@transactional` methods, all participating queries must use `getPuri()`; `getDB()` does not reuse Sonamu's ambient transaction connection.
|
|
56
56
|
- Never hand-author migration files for Sonamu-managed schema. In the qgrid source repository, change the entity definition, inspect `sonamu migrate status`, and create migration files with `mise exec -- pnpm --dir packages/api sonamu migrate generate`. Inspect the generated files before applying them. If Sonamu cannot express a required schema change, stop and ask rather than silently replacing its workflow with a custom migration.
|
|
57
57
|
- Keep OpenAI Codex built-in tools, apps, plugins, skills, web search, shell, and environment instruction blocks disabled unless the user explicitly asks for agentic Codex behavior.
|
|
58
|
-
- Treat OpenAI image generation as opt-in outside dashboard chat. OpenAI `qgrid_chat` opts into raw API `imageGeneration: "auto"` on every turn. Auto mode registers only the server-executed `generate_image` function and calls Codex standalone Images for ordinary or transparent output.
|
|
58
|
+
- Treat OpenAI image generation as opt-in outside dashboard chat. OpenAI `qgrid_chat` opts into raw API `imageGeneration: "auto"` on every turn. Auto mode registers only the server-executed `generate_image` function and calls Codex standalone Images for ordinary or transparent output. Raw explicit `imageGeneration: true` on a chat model also calls standalone Images directly, without a text driver; never register the hosted Responses `image_generation` tool, which fails whenever the driver carries reasoning effort (2026-11-09). The public SDK uses only `qgrid.image()` / `generateImage` for images, calling standalone Images for every background. Do not expose the raw `imageGeneration` or `imageGenerationOptions` fields as language-model options or retain deprecated shims. Do not reintroduce a client decision tool followed by another GPT generation request. Image costs use reported image usage at public token rates when available; otherwise estimate per image from the requested quality/size table. Auto or unsupported sizes use the 1536x1024 price; omitted quality uses medium. Display combined driver and image costs as dollar amounts without Cost labels. Do not show Known/Estimated labels, pricing disclaimers, or cost-source metadata in the dashboard.
|
|
59
59
|
|
|
60
60
|
## Request log IDs (2.10.0+)
|
|
61
61
|
|
|
@@ -74,11 +74,11 @@ Request logging is enabled by default. Use `providerOptions.qgrid.logger: false`
|
|
|
74
74
|
|
|
75
75
|
## Image output formats (2.9.6+)
|
|
76
76
|
|
|
77
|
-
-
|
|
78
|
-
- Preserve the actual returned MIME type in qgrid content, AI SDK files, and request-log image URLs; do not relabel bytes as the requested format.
|
|
79
|
-
-
|
|
77
|
+
- Every OpenAI image request (explicit chat-model `imageGeneration: true`, auto chat, and public `generateImage`) uses standalone Images and supports PNG only. The raw `imageGenerationOptions.outputFormat` enum still lists `jpeg`/`webp`, but the API rejects them before generation. Public image options use flat `QgridImageProviderOptions`.
|
|
78
|
+
- Preserve the actual returned MIME type in qgrid content, AI SDK files, and request-log image URLs; do not relabel bytes as the requested format. Replayed history may still contain JPEG/WebP images from the former hosted route.
|
|
79
|
+
- Do not convert output or fall back to another route.
|
|
80
80
|
- Keep the AI SDK standard `GeneratedFile.mediaType: string` contract. Do not add a qgrid-specific image wrapper or conditional return type.
|
|
81
|
-
-
|
|
81
|
+
- Model prose is not format evidence; inspect file bytes. Chat does not infer output format from prose.
|
|
82
82
|
|
|
83
83
|
## Verification
|
|
84
84
|
|
|
@@ -258,3 +258,7 @@ Do not store or replay `sessionKey` affinity coordinates for `anthropic/*` model
|
|
|
258
258
|
`createQgridLogger` records external provider calls into qgrid request logs. Callers pass it as AI SDK 7's `telemetry` option. It skips qgrid provider calls to avoid double-logging, and it skips any external-provider generation whose `providerOptions.qgrid.logger` is `false`. This makes `logger: false` a single opt-out that produces zero native or telemetry request logs without changing the model call itself. Runs are keyed by the AI SDK `callId` and finish on `onEnd`, `onError` (an `AbortError` is recorded as `aborted`), or `onAbort`. When changing logger behavior, preserve the stale-run fallback for generations that never report a terminal event, such as an unconsumed stream.
|
|
259
259
|
|
|
260
260
|
For external providers, the logger reads AI SDK's provider-neutral `onStart.output.responseFormat`. JSON output modes send `isStructured: true` plus the serialized schema when present; ordinary text sends `isStructured: false` and `jsonSchema: null`. A succeeded structured run also sends `responseJsonOk`, based only on whether the final response text parses as JSON. Qgrid does not duplicate caller-side Zod/schema validation. These lifecycle fields are optional on the server so older SDK clients remain compatible.
|
|
261
|
+
|
|
262
|
+
## OpenAI voice models
|
|
263
|
+
|
|
264
|
+
`qgrid.transcription("openai/<id>")` and `qgrid.speech("openai/<id>")` share the Grok voice factories; the `openai/` prefix selects the realtime route and switches the option namespace to `providerOptions.openai`, whose schemas are copied field-for-field from `@ai-sdk/openai` (`openAITranscriptionModelOptions`, `openaiSpeechModelOptionsSchema`, vercel/ai `fce9210`). Honored: transcription `language`, `prompt` (`gpt-realtime-whisper` rejects `prompt` with HTTP 400 from the server; `whisper-1` accepts it but the upstream ignores it); speech `voice` (one of OpenAI realtime's 10 preset voices: `alloy ash ballad coral echo sage shimmer verse marin cedar`, default `marin`; others fail with HTTP 400), `instructions`/`openai.instructions`, `outputFormat` `wav` (default) or `pcm`. Every other set key emits the AI SDK `unsupported` warning; `language` on speech reuses the official provider's warning text and an unknown `outputFormat` falls back to `wav` with a warning (the official provider falls back to `mp3`). `providerOptions.qgrid.tokenName` must carry the `openai/` prefix. Transcription input must be PCM16 WAV or raw PCM; `segments` is empty, `durationInSeconds` is computed server-side from the audio, `language` echoes the request. Speech `providerMetadata.qgrid.mediaType` is `audio/wav` or `audio/pcm;rate=24000`. Keep model unions equal to the server's candidate lists and prune both from the live matrix (`openai-codex-runtime.md`, "Realtime voice").
|
|
@@ -136,6 +136,16 @@ Key decisions:
|
|
|
136
136
|
- `--setting-sources project` is required for shared-service isolation. User/local Claude settings can load hooks or memory and leak context across requests.
|
|
137
137
|
- Claude Code OAuth prompt cache sharing across tokens in the same workspace is an observed cost behavior, not a product contract. Monitor it; do not promise it.
|
|
138
138
|
|
|
139
|
+
## OpenAI Realtime Voice
|
|
140
|
+
|
|
141
|
+
Sources: `docs/plans/2026-10-17-openai-realtime-audio-plan.md`, `docs/diagnosis/2026-10-17-openai-realtime-audio-probe.md`, `docs/diagnosis/2026-11-06-openai-realtime-tts-prompt.md`, `packages/api/src/utils/providers/openai/openai-realtime-protocol.ts`.
|
|
142
|
+
|
|
143
|
+
- STT mirrors Codex’s subscription path (`/realtime/calls` + sideband) rather than the simpler ChatGPT-web `/backend-api/transcribe`: the latter was removed from Codex (PR #16114), ignores model/language/prompt, and retains uploads for 30 days.
|
|
144
|
+
- TTS uses the direct realtime socket, which Codex treats as API-key-only, because the `/calls` sideband carries no audio and qgrid has no RTP stack. It is the one deliberate non-Codex path; a 401/403 there means the path is gated and must fail, not fall back.
|
|
145
|
+
- The TTS prompt is a sectioned system prompt (role, capitalized never-answer rules, sample exchanges) with only the text, inside `<script>` tags, as the user item. The realtime models are conversational: the original one-sentence prompt let `gpt-realtime-2.1` answer 7 of 12 question-form lines, and a read-aloud instruction placed in the user item was spoken by both models. The structure follows the OpenAI Realtime Prompting Guide and the prompt engineering guide's XML delimiters; the wording is qgrid's own.
|
|
146
|
+
- No image-model ids were added for GPT-Image-2.5: the subscription Images route ignores the `model` field (a nonsense id returns 200 with identical usage, hosted tools echo `gpt-image-2-codex`). Re-check by sending a nonsense id; a 400 means selection became real. Rechecked 2026-11-09 for GPT-Image-2.6 Flare/Sunburst: still 200 with identical usage, and C2PA metadata names only `ChatGPT / gpt-image` (`docs/diagnosis/2026-11-09-gpt-image-2-6-probe.md`).
|
|
147
|
+
- Model ids are candidates pruned by the live matrix, not promises from the catalog: raw probes passed, but only the production client through qgrid decides what ships.
|
|
148
|
+
|
|
139
149
|
## Grok (xAI Subscription) Runtime
|
|
140
150
|
|
|
141
151
|
Sources:
|
|
@@ -259,7 +269,7 @@ Sources:
|
|
|
259
269
|
|
|
260
270
|
Key decisions:
|
|
261
271
|
|
|
262
|
-
- Image generation is OpenAI/Codex-only and request-level opt-in outside dashboard chat. Chat explicitly opts into raw `imageGeneration: "auto"` each turn. Auto mode registers one internal `generate_image` function and calls standalone Images for ordinary and transparent backgrounds. Raw explicit chat-model `imageGeneration: true`
|
|
272
|
+
- Image generation is OpenAI/Codex-only and request-level opt-in outside dashboard chat. Chat explicitly opts into raw `imageGeneration: "auto"` each turn. Auto mode registers one internal `generate_image` function and calls standalone Images for ordinary and transparent backgrounds. Raw explicit chat-model `imageGeneration: true` also uses standalone Images for every background (2026-11-09). The hosted Responses image tool began receiving the driver's reasoning effort as an unsupported `complexity` and failing; one route keeps behavior predictable at the cost of JPEG/WebP output. Public SDK image requests use `qgrid.image()` / `generateImage` and standalone Images for any background, following AI SDK's separate `ImageModelV3` contract. The language-model SDK has no image-generation options; the former boolean and nested options are removed without deprecated shims. Do not add a public image-tool factory or globally enable image tools for other callers: that would change their tool framing and cache behavior.
|
|
263
273
|
- It is non-stream only. Codex returns completed base64 image payloads, not useful image deltas.
|
|
264
274
|
- Image turns send full input directly and retain no provider conversation state. This prevents base64 payloads from entering reusable state.
|
|
265
275
|
- qgrid performs preflight capability/model gates. Raw `imageGeneration: true` requires an image; `"auto"` allows normal text replies but still rejects attempted image generation without a completed image. Public `generateImage` requires one direct Images output per provider call; AI SDK batches requests for `n` outputs.
|
|
@@ -273,6 +283,6 @@ The current chat design registers `generate_image` for both ordinary and transpa
|
|
|
273
283
|
|
|
274
284
|
Image edits need complete prior image bytes, not just text history or an assumption that the backend remembers earlier outputs. Chat replays uploaded and generated images, representing generated images as user visual references because assistant `input_image` blocks are invalid. Image previews report actual extension, decoded byte size, and natural dimensions. Uploaded images describe the existing resized JPEG sent to the model; generated images retain their returned bytes.
|
|
275
285
|
|
|
276
|
-
Model labels show requested model to image model using serving metadata or the image model encoded in the logged cost method. The cost-method fallback remains an accounting assumption, not new evidence of the upstream model version. The UI has no image-generation or assumption badge and never fixes the name to `gpt-image-2.5`. The `gpt-image-2` wire ID also does not prove Images 2.0 serving weights or selectable 2.5 variants.
|
|
286
|
+
Model labels show requested model to image model using serving metadata or the image model encoded in the logged cost method. The cost-method fallback remains an accounting assumption, not new evidence of the upstream model version. The UI has no image-generation or assumption badge and never fixes the name to `gpt-image-2.5`. The `gpt-image-2` wire ID also does not prove Images 2.0 serving weights or selectable 2.5 variants. Auto image logs retain driver identity and token costs separately from image metadata/cost; explicit `imageGeneration: true` and direct `qgrid.image()` requests have no driver cost. Older hosted-route logs (`codex-responses`) keep their recorded driver costs.
|
|
277
287
|
|
|
278
|
-
Prompt wording alone is not a reliable format control: a 2026-09-29 hosted-route probe returned PNG for a WebP prompt and WebP with explicit `outputFormat: "webp"`. Model prose contradicted the output and must not be used as evidence.
|
|
288
|
+
Prompt wording alone is not a reliable format control: a 2026-09-29 hosted-route probe returned PNG for a WebP prompt and WebP with explicit `outputFormat: "webp"`. Model prose contradicted the output and must not be used as evidence. All OpenAI image routes are PNG-only and reject explicit non-PNG options. Do not infer format from chat prose or introduce post-generation conversion or a hosted fallback.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenAI Direct Codex Runtime
|
|
2
2
|
|
|
3
|
-
Use this reference before changing OpenAI transport, concurrency, routing, prompt-cache affinity, OAuth, quota lookup, image generation, or cancellation.
|
|
3
|
+
Use this reference before changing OpenAI transport, concurrency, routing, prompt-cache affinity, OAuth, quota lookup, image generation, realtime voice, or cancellation.
|
|
4
4
|
|
|
5
5
|
## Source files
|
|
6
6
|
|
|
@@ -10,6 +10,7 @@ Use this reference before changing OpenAI transport, concurrency, routing, promp
|
|
|
10
10
|
- SSE decoding: `openai-sse.ts`.
|
|
11
11
|
- Direct PKCE OAuth and refresh: `openai-oauth.ts`, `openai-refresh.ts`, `openai-callback-relay.ts`.
|
|
12
12
|
- Direct quota lookup: `openai-quota.ts`.
|
|
13
|
+
- Realtime voice (STT/TTS): `openai-realtime-protocol.ts`, `openai-voice-client.ts`.
|
|
13
14
|
- Provider integration and history: `packages/api/src/application/qgrid/qgrid.dispatcher.ts`, `conv-routing.ts`.
|
|
14
15
|
|
|
15
16
|
## Thinking control
|
|
@@ -199,15 +200,15 @@ Quota is fetched directly from `https://chatgpt.com/backend-api/wham/usage` with
|
|
|
199
200
|
|
|
200
201
|
OpenAI usage reports total input, cached input, output, reasoning, and total tokens for the request. Preserve cached input as a subset of input; do not add it to input again when computing cache-hit rate.
|
|
201
202
|
|
|
202
|
-
Raw/server
|
|
203
|
+
Raw/server image requests are opt-in and non-stream to the caller. Every OpenAI image request uses standalone Images: the image model `openai/gpt-image-2`, explicit chat-model `imageGeneration: true`, and the auto chat function. These are not public language-model SDK options: SDK image generation uses `qgrid.image()` / `generateImage`. Output is PNG only. The raw `imageGenerationOptions.outputFormat` enum still accepts `jpeg`/`webp` for schema compatibility, but the API rejects them before generation. Returned bytes determine the MIME type when recognizable, with the reported format as fallback; preserve that type through qgrid content and request-log image data URLs. Image costs use reported image usage when available, otherwise the requested quality/size price table. Auto or unsupported sizes use the 1536x1024 price, and omitted quality uses medium. These are API-price estimates, not observed output settings or subscription charges.
|
|
203
204
|
|
|
204
|
-
|
|
205
|
+
Until 2026-11-09, explicit chat-model requests without transparency used the hosted Responses `image_generation` tool, read image usage from `response.completed.response.tool_usage.image_gen`, and stored route `codex-responses`. A 2026-11-09 live probe found that the backend passes the driver's `reasoning.effort` to that tool as `complexity`, which the effective tool model `gpt-image-2-codex` rejects for low, medium, and high (`Complexity 'low' is not supported for this image model`). The same request without effort succeeded. qgrid therefore sends explicit chat-model requests to standalone Images and no longer registers or parses the hosted tool. Older request logs may still show route `codex-responses` and JPEG/WebP output. Evidence: `docs/diagnosis/2026-11-09-gpt-image-2-6-probe.md`.
|
|
205
206
|
|
|
206
207
|
### Standalone image routes
|
|
207
208
|
|
|
208
209
|
The explicit image-model route `openai/gpt-image-2` with raw `imageGeneration: true` uses standalone Images for opaque, auto, or transparent backgrounds. It is exposed by `qgrid.image()` / AI SDK `generateImage`; the raw flag is an internal transport detail. Public `generateText` has no image-generation options. Reference inputs select `images/edits`, otherwise `images/generations`. Direct image output is PNG-only; decode and validate returned dimensions, applying the transparent-and-visible pixel requirement only when transparency was explicitly requested. Preserve returned background, quality, model, and image usage without claiming requested hints were honored. Image-model requests cannot use chat tools, structured output, auto-image mode, or streaming. The `gpt-image-2` wire identifier does not establish the serving Images version or selectable 2.5 variant.
|
|
209
210
|
|
|
210
|
-
Raw/server chat-model requests with explicit `imageGeneration: true`
|
|
211
|
+
Raw/server chat-model requests with explicit `imageGeneration: true` use Codex `images/generations` or `images/edits` for every background. The same selected subscription token, cancellation deadline, in-flight tracking, and one definitive 401 refresh apply. Use JSON content negotiation; do not reuse the Responses SSE Accept header. Never replay an ambiguous generation or fall back to opaque output/IS-Net. This explicit route runs `gpt-image-2` directly, so actual model metadata differs from the requested driver ID, ordinary driver usage stays zero, and driver controls such as effort, verbosity, and prompt cache keys are not sent. Image response usage and actual settings are preserved on `generation`; usage belongs to the first output only. Costs remain explicitly estimated from public prices.
|
|
211
212
|
|
|
212
213
|
The direct image request adapter preserves text/system context and reference images (maximum five), rejects unsupported structured/tool requests before generation, and validates PNG contents with pngjs. Explicit transparency requires both a fully transparent pixel and visible content; opaque or entirely empty results fail that requirement. Invalid or oversized results fail for every background. Returned dimensions come from the decoded PNG; qgrid never silently resizes. A 2026-09-08 live request returned 1254x1254/medium for requested 1024x1024/high. Do not promise exact size/quality enforcement. See `openai-image-generation.ts` and opt-in `transparent`/`transparent-edit` cases in the image smoke script.
|
|
213
214
|
|
|
@@ -221,8 +222,19 @@ Auto mode accepts text-only completion when no image tool was attempted. Explici
|
|
|
221
222
|
|
|
222
223
|
Auto image turns preserve the Responses driver model and token usage; image model, settings, and usage remain separate generation metadata. Their combined cost is a chat-driver estimate plus an image-usage estimate. If the image stage fails after the driver completed, carry that completed driver result internally so error/aborted logs still record its usage and price once. Do not attach partial image output or claim a successful image cost. Do not apply the explicit standalone route's zero-driver accounting to auto turns. Full image history is replayed on each turn without reusable provider conversation state. Global image-tool opt-in remains unchanged outside chat to preserve regular callers' tool framing and cache behavior.
|
|
223
224
|
|
|
224
|
-
|
|
225
|
+
Standalone Images returns PNG. Verify bytes rather than model claims, and add no format conversion. See `docs/solutions/architecture-patterns/qgrid-native-auto-image-generation-2.9.8.md`.
|
|
225
226
|
|
|
226
227
|
### Size hints and observed dimensions (2026-10-13)
|
|
227
228
|
|
|
228
229
|
`size` accepts `auto` or positive-integer WIDTHxHEIGHT hints. Keep the requested value separate from observed output metadata; do not promise exact dimensions or inject a resize. Prompt for the desired ratio. Twelve live subscription requests across hosted Responses and standalone generation/edit returned 841x1870 for 9:20, 941x1672 for 4K portrait, and 2172x724 for 4:1 (clamped to 3:1). Explicit 1152x2560 and even 1x1 hints returned 1254x1254 for a neutral prompt. These approximately 1.57MP observations are not a universal limit. Public API limits (16-pixel multiples, up to 4K) are not the private backend contract. Latest upstream Codex at `12cca49c81c8aa6a37a5cc4e39964ee3b70f9458` hardcodes `size: auto` for image generation/editing and saves bytes without resizing.
|
|
230
|
+
|
|
231
|
+
## Realtime voice (speech-to-text, text-to-speech)
|
|
232
|
+
|
|
233
|
+
Sources: `openai-realtime-protocol.ts` (wire constants, session builders, PCM helpers), `openai-voice-client.ts` (one-shot STT/TTS client), `OpenAIDispatcher.transcribe/speak`, `qgrid.frame.ts` `transcribeOpenAI`/`speakOpenAI`, plan `docs/plans/2026-10-17-openai-realtime-audio-plan.md`, matrix `docs/diagnosis/2026-10-17-openai-realtime-audio-probe.md`.
|
|
234
|
+
|
|
235
|
+
`openai/<id>` on `POST /api/qgrid/transcribe` and `/speak` runs OpenAI realtime sessions with the same ChatGPT subscription tokens as Codex. The request shape mirrors `openai/codex` main (2026-10-17); each constant in `openai-realtime-protocol.ts` cites its Codex source line. Keep that fidelity: no `OpenAI-Beta` header (the server answers `beta_api_shape_disabled` for `realtime=v1`), no `openai-alpha`, no `intent=quicksilver` query. Headers are `Authorization`, `ChatGPT-Account-Id`, `originator`, `User-Agent`, `x-session-id`, `voice-session-id`, `session-id`, `thread-id`, identical on the POST and both WebSockets.
|
|
236
|
+
|
|
237
|
+
- STT is the Codex subscription path: `POST https://chatgpt.com/backend-api/codex/realtime/calls` with `{sdp, session}` (synthetic Opus-only SDP offer; the transcription session is Codex's exact V2 shape), `201` + `Location: /v1/realtime/calls/rtc_…`, then a sideband `wss://api.openai.com/v1/realtime?call_id=…`. Per-request `language`/`prompt` and `turn_detection: null` go in a sideband `session.update`; audio goes as 1 s `input_audio_buffer.append` chunks plus one `commit`; the result is `conversation.item.input_audio_transcription.completed`. A call with no ICE connection is torn down about 30 s after creation (25 s idle fine, 31 s gone), so the client enforces a 25 s deadline from the POST. When that attempt ends in teardown (deadline, sideband closed/errored or handshake rejected before the transcript — `isSidebandTeardownError`), the client retries once on the direct `wss://api.openai.com/v1/realtime?intent=transcription` socket with the same headers and session (`OpenAIVoiceClientOptions.sttDirectFallback`, default on; 60 s bound). Server `error` events and `/calls` 4xx never trigger the fallback. The request log records `transport` (`realtime-calls` | `realtime-ws`) and `fallbackReason`; `callId` and quota headers are absent after a fallback. The direct socket is the same non-Codex path as TTS, so a 401/403 there means it was gated. Input must already be PCM16: WAV (`audio/wav`) or raw PCM (`audio/pcm;rate=…;channels=…`), downmixed and linearly resampled to 24 kHz mono like Codex's `convert_pcm16`; compressed input is a 400. The server reports no language or duration: `durationSec` is computed from the PCM sent and `language` echoes the request.
|
|
238
|
+
- TTS is the one deviation from Codex. The `/calls` sideband never carries `response.output_audio.delta` (media stays on RTP, verified twice), and qgrid has no RTP stack, so speech uses the direct `wss://api.openai.com/v1/realtime?model=<id>` socket, which Codex itself treats as API-key-only (`realtime_conversation.rs:1931-1955`) but which accepts the ChatGPT bearer today. The session is Codex's V2 conversational payload minus `tools`, with a verbatim-reading system prompt (labeled `# Role & Objective` / `# Rules` / `# Examples` sections with capitalized never-answer rules; the caller's `instructions` follow as `# Style`), the text wrapped in `<script>…</script>` as the one `conversation.item.create` user item, and `response.create`; the output is concatenated PCM16 24 kHz returned as WAV (default) or raw PCM. OpenAI realtime has 10 preset voices, matching the Codex v2 list (`alloy ash ballad coral echo sage shimmer verse marin cedar`, default `marin`); others fail with 400. The model's own `response.output_audio_transcript.done` and `response.done.usage` audio/text tokens are logged with the request for fidelity checks. Treat a 401/403 on this socket as the path being gated: fail with the upstream error, do not fall back.
|
|
239
|
+
- Dispatcher: `OpenAIDispatcher.runVoice` selects a token with the same quota gate as Responses, refreshes once on a 401 and retries once, and invalidates the rate-limit cache afterwards. `OpenAIVoiceInputError` (unsupported audio, bad voice, empty text) becomes HTTP 400 `qgrid.openaiVoiceInvalidRequest`; everything else propagates as an upstream failure.
|
|
240
|
+
- Exposed ids (user decision 2026-10-17: keep every reachable id, document limits): STT `gpt-4o-mini-transcribe`, `gpt-4o-transcribe`, `gpt-transcribe` (4/4 on the matrix), `gpt-live-transcribe` and `gpt-realtime-whisper` (return about half of a 60 s clip; whisper also mangles Korean), `whisper-1` (ignores `prompt`). `gpt-realtime-whisper` rejects `prompt` upstream, so `OPENAI_TRANSCRIPTION_MODELS_WITHOUT_PROMPT` makes the client fail with a 400 before the realtime call. TTS `gpt-realtime-2.1-mini` (13/13 verbatim, default), `gpt-realtime-2.1` (12/13), `gpt-realtime-1.5` (6/13, often answers instead of repeating) on the 2026-10-17 statement texts. Realtime models are conversational and answer text addressed to the listener: on question-form character lines the original one-sentence prompt let `gpt-realtime-2.1` answer 7 of 12, while the current sectioned prompt with `<script>` delimiters read 12/12 on both 2.1 and 2.1-mini (`docs/diagnosis/2026-11-06-openai-realtime-tts-prompt.md`; 1.5 not re-run). Keep every instruction in the system prompt: an instruction placed in the user item was read aloud. Model behavior is tracked by the live matrix (`OPENAI_LIVE=1 pnpm tsx scripts/live-openai-voice-matrix.ts`, results in `docs/diagnosis/2026-10-17-openai-realtime-audio-probe.md`). Remove an id from `OPENAI_TRANSCRIPTION_MODELS`/`OPENAI_SPEECH_MODELS`, the SDK unions, and the READMEs together when it stops passing. Unavailable on subscription (verified 2026-10-17): `/backend-api/codex/audio/transcriptions`, `/audio/speech`, `gpt-4o-mini-tts`, `tts-1*`, `gpt-transcribe` via `/codex/responses`, Responses `input_audio`. The ChatGPT-web `POST /backend-api/transcribe` works but is not used (removed from Codex in PR #16114, ignores model/language, retains uploads 30 days).
|
|
@@ -94,9 +94,9 @@ OpenAI uses the completed Responses event's per-request usage fields.
|
|
|
94
94
|
|
|
95
95
|
Anthropic normalizes native mutually exclusive categories by summing input + cache creation + cache read into total input. Prefer positive Claude Code `total_cost_usd`; otherwise calculate from the actual serving model and TTL split.
|
|
96
96
|
|
|
97
|
-
For image requests, keep `cost_usd` as the Codex driver model token cost.
|
|
97
|
+
For image requests, keep `cost_usd` as the Codex driver model token cost. Explicit image requests, whether a chat model with `imageGeneration: true` or `qgrid.image()`, call standalone Images, run no driver, and report zero driver usage/cost. Older hosted-route rows (`codex-responses`) recorded image usage from `response.tool_usage.image_gen` alongside the driver's usage. Auto image turns preserve the Responses driver model and usage for every background while keeping standalone image usage/settings separately. Image usage and actual settings are preserved as `observedGeneration` alongside `requestedOptions` in the synthetic tool log. Price reported image usage at public token rates; only fall back to requested quality/size estimates when usage is absent. Display combined driver and image costs as dollar amounts without Cost labels; omit pricing disclaimers and cost-source metadata from the dashboard. Treat `image_cost_usd` as an API-price estimate, not subscription billing.
|
|
98
98
|
|
|
99
|
-
For `imageGeneration: "auto"`, set `is_image_generation` only when returned content actually contains an image; offering the `generate_image` function is not sufficient. Keep stored `model_name` as the driver for
|
|
99
|
+
For `imageGeneration: "auto"`, set `is_image_generation` only when returned content actually contains an image; offering the `generate_image` function is not sufficient. Keep stored `model_name` as the driver for auto image turns and older hosted-route rows. Dashboard requested-to-image labels can derive the image model from serving/image-cost metadata without changing the stored driver or adding image-generation/assumption badges.
|
|
100
100
|
|
|
101
101
|
If the auto image stage fails or is cancelled after the chat driver has completed, preserve the completed driver result as internal failure metadata. The frame converts it with the same usage/pricing mapper used on success; terminal logging writes one generate step before aggregating the run and retains the actual/requested model and token. The parent remains `error` or `aborted` with the original error message. Do not write a completed image step, invent an image cost, expose failure metadata in the HTTP error, or record this step again on success. A driver that never completed and a direct image-only call have no completed chat usage to retain. `logger: false` still creates no logs. Log-writing failures must not replace the original generation failure.
|
|
102
102
|
|
|
@@ -58,7 +58,7 @@ Provider-qualified ids widen `model_name` and `requested_model_name` from 50 to
|
|
|
58
58
|
|
|
59
59
|
Image-generation request logs add `is_image_generation`, `image_cost_usd`, and `image_cost_method`. The list view displays driver plus image cost as the total cost cell; the detail view shows driver cost and image cost separately and renders generated image data URLs from response/tool-step content.
|
|
60
60
|
|
|
61
|
-
In 2.9.8, list and detail model labels show requested model to image model for generated-image results, using an image serving model or the model recorded in `image_cost_method`. The cost fallback is an estimate, not an upstream version guarantee. Preserve the actual driver in stored `model_name` for
|
|
61
|
+
In 2.9.8, list and detail model labels show requested model to image model for generated-image results, using an image serving model or the model recorded in `image_cost_method`. The cost fallback is an estimate, not an upstream version guarantee. Preserve the actual driver in stored `model_name` for auto turns and older hosted-route rows. Do not hardcode a display version or render an image-generation/assumption badge. Auto text-only replies are not marked `is_image_generation`.
|
|
62
62
|
|
|
63
63
|
The list header ends its filter row with a reload button (2.10.2+) that calls the generated hooks' `refresh()` for the list and the total-cost query with the current filters; it does not refetch the token/project/model filter options, and TanStack Query's `isRefreshing` disables it while a reload is in flight.
|
|
64
64
|
|
|
@@ -139,11 +139,11 @@ Image generation:
|
|
|
139
139
|
- Human-initiated only.
|
|
140
140
|
- Requires active OpenAI token with image entitlement and applicable migration.
|
|
141
141
|
- For 2.9.8 chat, verify the actual browser POST and served bundle, not only a direct function test. A globally installed CLI on port 44900 can serve stale assets while repository tests pass; identify the listening process and its executable before assuming a rebuild or refresh affects it.
|
|
142
|
-
- Cover auto text-only replies and the single server-side `generate_image` function for ordinary generation and transparent editing. Zero selected references must create a fresh image despite older history; positive counts must select only the last N conversation images in order, up to five. Explicit raw `true` must
|
|
143
|
-
- Verify extension, decoded bytes, and natural dimensions in chat image previews. A format request in prose is not evidence
|
|
142
|
+
- Cover auto text-only replies and the single server-side `generate_image` function for ordinary generation and transparent editing. Zero selected references must create a fresh image despite older history; positive counts must select only the last N conversation images in order, up to five. Explicit raw `true` on a chat model must still require an image and call standalone Images directly, including when the request carries `effort`. Verify driver usage stays separate from image usage and auto text replies are not image logs.
|
|
143
|
+
- Verify extension, decoded bytes, and natural dimensions in chat image previews. A format request in prose is not evidence. All OpenAI image routes are PNG-only and must reject explicit non-PNG options.
|
|
144
144
|
- Requires `QGRID_REAL_PROVIDER_ACCEPTANCE=1`, explicit `QGRID_URL` and `QGRID_OPENAI_MODEL`. Optional `QGRID_TOKEN_NAME` pins a subscription token. `QGRID_IMAGE_SMOKE_CASES` selects named cases; the default covers eight images plus text, rejected inputs, and cancellation. Optional `batch`, `logger-off`, and `cancel-direct` cover SDK batching, no-log calls, and cancellation during direct Images requests. Never replay generations automatically.
|
|
145
145
|
- Set `QGRID_IMAGE_E2E_OUTPUT` for PNGs and sanitized usage/cost/log evidence; `QGRID_IMAGE_E2E_PROJECT` groups test logs. Use an isolated DB and access-only test token, with notifications and keepalive disabled. For final acceptance, build the current API and cold-start `sonamu start` against that isolated DB rather than relying on HMR. HMR can leave a fresh dispatcher uninitialized; readiness alone does not prove the intended module version. The suite checks readiness before live calls.
|
|
146
|
-
- Subscription `response.completed.tool_usage.image_gen` can be present with all-zero usage for text-only or function-tool replies.
|
|
146
|
+
- Subscription `response.completed.tool_usage.image_gen` can be present with all-zero usage for text-only or function-tool replies. qgrid no longer parses it. Keep the regression test that auto text replies carrying this metadata stay text-only, and verify auto text against the real backend.
|
|
147
147
|
- Run auto text and generation with both Luna and Astra when changing the internal tool schema. Astra's private backend failed with `strict: true` even with bounds removed, while the same schema succeeded with `strict: false`. Keep `strict: false` and server-side validation; do not add a runtime fallback/retry.
|
|
148
148
|
- Not part of CI; it consumes ChatGPT subscription quota.
|
|
149
149
|
|