Files
OmniRoute/tests/unit/chatgpt-web-image-handler-retirement.test.ts
backryun 7ed8ada432 feat(providers): restore ChatGPT Web via clean-room browser transport (#12239)
Restores ChatGPT Web on a clean-room browser transport, merged on the operator's explicit decision.

Worth stating precisely, because this touches a provenance decision: the PR does not revert #11754. It narrows RETIRED_COMMON_CHATGPT_WEB_PROVIDER_IDS to the single GPL-derived alias cgpt-web and registers chatgpt-web as a separate clean-room id. The old implementation stays retired and blocked; the retirement machinery, its error code and its 410 contract are untouched. All four retirement suites agree with that distinction and pass unchanged.

The 44 protected agent-instruction surfaces this PR touches (AGENTS.md, llm.txt and its 42 mirrors, README) were verified rather than trusted: masking digits and comparing the removed and added line sets gives 264 lines on each side, identical — every change is a provider-count substitution, with no sentence added, removed or reworded.

Reconciled on merge: clean against the tip, with the two chat chokepoints this PR grows (src/sse/handlers/chat.ts +40, open-sse/handlers/chatCore.ts +30) recorded in the file-size baseline under an annotation. Verified that exactly those two caps move and nothing else, so the #12411 ratchet holds. The rebaseline is carried on this branch rather than left in a validation worktree — the propagation mistake that put the 2026-09-02 merge waves base-red in #12434.

Verified: 504/504 across the PR's 44 test files plus all four chatgpt-web retirement suites, check:provider-consistency OK (272 REGISTRY entries, 355 canonical providers), check-file-size OK, and every changed TypeScript file parses.

Thanks @backryun — separating the clean-room id from the retired alias, instead of reopening the old one, is what made this reviewable.
2026-09-02 10:31:41 -03:00

65 lines
2.3 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { handleImageGeneration } from "../../open-sse/handlers/imageGeneration.ts";
test("central image handler retires cgpt-web and reports clean-room chatgpt-web as unsupported", async () => {
const originalFetch = globalThis.fetch;
let fetchCalls = 0;
globalThis.fetch = async () => {
fetchCalls += 1;
throw new Error("Retired image providers must not reach the network");
};
try {
for (const provider of ["cgpt-web"]) {
const viaRequestedModel = await handleImageGeneration({
body: { model: `${provider}/gpt-5.5`, prompt: "draw a lighthouse" },
credentials: { apiKey: "unused" },
log: null,
});
assert.deepEqual(viaRequestedModel, {
success: false,
status: 410,
error: "Provider is retired and unavailable.",
code: "PROVIDER_RETIRED",
});
const viaBareProviderId = await handleImageGeneration({
body: { model: provider, prompt: "draw a lighthouse" },
credentials: { apiKey: "unused" },
log: null,
});
assert.deepEqual(viaBareProviderId, viaRequestedModel);
const viaResolvedProvider = await handleImageGeneration({
body: { model: `${provider}/gpt-5.5`, prompt: "draw a lighthouse" },
credentials: { apiKey: "unused" },
resolvedProvider: provider,
log: null,
});
assert.deepEqual(viaResolvedProvider, viaRequestedModel);
}
const cleanRoomTextOnly = await handleImageGeneration({
body: { model: "chatgpt-web/gpt-5-5-thinking", prompt: "draw a lighthouse" },
credentials: { apiKey: "unused" },
log: null,
});
assert.equal(cleanRoomTextOnly.status, 400);
assert.match(cleanRoomTextOnly.error, /invalid image model/i);
assert.notEqual((cleanRoomTextOnly as { code?: string }).code, "PROVIDER_RETIRED");
const similarButDistinct = await handleImageGeneration({
body: { model: "chatgpt-web-preview/gpt-5.5", prompt: "draw a lighthouse" },
credentials: { apiKey: "unused" },
log: null,
});
assert.equal(similarButDistinct.status, 400);
assert.notEqual((similarButDistinct as { code?: string }).code, "PROVIDER_RETIRED");
assert.equal(fetchCalls, 0);
} finally {
globalThis.fetch = originalFetch;
}
});