From baa45e9a67a2f510bd75df0deab655aeab66af76 Mon Sep 17 00:00:00 2001 From: Markus Hartung Date: Wed, 2 Sep 2026 01:25:34 -0300 Subject: [PATCH] feat(providers): add chatgpt-session model route table --- open-sse/executors/chatgpt-session/models.ts | 47 +++++++++++++++++++ tests/unit/chatgpt-session-models.test.ts | 48 ++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 open-sse/executors/chatgpt-session/models.ts create mode 100644 tests/unit/chatgpt-session-models.test.ts diff --git a/open-sse/executors/chatgpt-session/models.ts b/open-sse/executors/chatgpt-session/models.ts new file mode 100644 index 0000000000..e2745212d6 --- /dev/null +++ b/open-sse/executors/chatgpt-session/models.ts @@ -0,0 +1,47 @@ +/** + * Public model routes for the ChatGPT Session provider. + * + * Each public slug pins one backend model plus one reasoning effort. The vendored browser + * adapter accepts only the two backend ids and reads the effort from + * `CodexParsedRequest.options.reasoning`, so the slug is the only knob a client turns. + */ + +export type ChatGptSessionEffort = "low" | "medium" | "high" | "xhigh" | "max"; + +export interface ChatGptSessionRoute { + id: string; + backendModel: "gpt-5.6-sol" | "gpt-5.6-luna"; + effort: ChatGptSessionEffort; + /** Requires an account whose browser probe reported Pro. */ + pro: boolean; + /** Requires the Sol model selector; Luna-only accounts get the luna/think routes. */ + sol: boolean; +} + +const ROUTES: ReadonlyMap = new Map([ + ["luna", { id: "luna", backendModel: "gpt-5.6-luna", effort: "low", pro: false, sol: false }], + [ + "think", + { id: "think", backendModel: "gpt-5.6-luna", effort: "medium", pro: false, sol: false }, + ], + ["instant", { id: "instant", backendModel: "gpt-5.6-sol", effort: "low", pro: false, sol: true }], + [ + "medium", + { id: "medium", backendModel: "gpt-5.6-sol", effort: "medium", pro: false, sol: true }, + ], + ["high", { id: "high", backendModel: "gpt-5.6-sol", effort: "high", pro: false, sol: true }], + [ + "extra-high", + { id: "extra-high", backendModel: "gpt-5.6-sol", effort: "xhigh", pro: true, sol: true }, + ], + ["pro", { id: "pro", backendModel: "gpt-5.6-sol", effort: "max", pro: true, sol: true }], +] as const); + +export const CHATGPT_SESSION_ROUTE_IDS: readonly string[] = [...ROUTES.keys()]; + +export function requireChatGptSessionRoute(model: string): ChatGptSessionRoute { + const normalized = model.trim().replace(/^(?:chatgpt-session|cgpt-session)\//, ""); + const route = ROUTES.get(normalized); + if (!route) throw new Error(`Unsupported ChatGPT Session model: ${model}`); + return route; +} diff --git a/tests/unit/chatgpt-session-models.test.ts b/tests/unit/chatgpt-session-models.test.ts new file mode 100644 index 0000000000..8289c37fa7 --- /dev/null +++ b/tests/unit/chatgpt-session-models.test.ts @@ -0,0 +1,48 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; + +import { + CHATGPT_SESSION_ROUTE_IDS, + requireChatGptSessionRoute, +} from "../../open-sse/executors/chatgpt-session/models.ts"; + +test("exposes the seven public routes", () => { + assert.deepEqual( + [...CHATGPT_SESSION_ROUTE_IDS], + ["luna", "think", "instant", "medium", "high", "extra-high", "pro"] + ); +}); + +test("maps a slug to its backend model and effort", () => { + assert.deepEqual(requireChatGptSessionRoute("high"), { + id: "high", + backendModel: "gpt-5.6-sol", + effort: "high", + pro: false, + sol: true, + }); +}); + +test("strips the provider prefix from a qualified model id", () => { + assert.equal(requireChatGptSessionRoute("chatgpt-session/pro").id, "pro"); + assert.equal(requireChatGptSessionRoute("cgpt-session/pro").id, "pro"); +}); + +test("luna routes target the luna backend and never require sol", () => { + const luna = requireChatGptSessionRoute("luna"); + assert.equal(luna.backendModel, "gpt-5.6-luna"); + assert.equal(luna.sol, false); + assert.equal(requireChatGptSessionRoute("think").effort, "medium"); +}); + +test("pro routes are flagged pro", () => { + assert.equal(requireChatGptSessionRoute("pro").pro, true); + assert.equal(requireChatGptSessionRoute("extra-high").pro, true); +}); + +test("rejects an unknown slug", () => { + assert.throws( + () => requireChatGptSessionRoute("gpt-4"), + /Unsupported ChatGPT Session model: gpt-4/ + ); +});