@opengeni/codex 0.2.20 → 0.2.21-canary.1
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/dist/{chunk-UNB34NLA.js → chunk-OJCCJBUL.js} +8 -3
- package/dist/chunk-OJCCJBUL.js.map +1 -0
- package/dist/constants.d.ts +2 -2
- package/dist/constants.js +1 -1
- package/dist/images.d.ts +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/request-context.d.ts +11 -0
- package/package.json +2 -2
- package/src/constants.ts +16 -11
- package/src/fetch.ts +1 -0
- package/src/images.ts +5 -1
- package/src/request-context.ts +12 -0
- package/dist/chunk-UNB34NLA.js.map +0 -1
|
@@ -12,7 +12,12 @@ var CODEX_ID_TOKEN_AUTH_CLAIM = "https://api.openai.com/auth";
|
|
|
12
12
|
var CODEX_PROVIDER_ID = "codex-subscription";
|
|
13
13
|
var CODEX_PROVIDER_BASE_URL = "https://chatgpt.com/backend-api";
|
|
14
14
|
var CODEX_MODEL_ID_PREFIX = "codex/";
|
|
15
|
-
var CODEX_FALLBACK_MODEL_SLUGS = [
|
|
15
|
+
var CODEX_FALLBACK_MODEL_SLUGS = [
|
|
16
|
+
"gpt-5.6-sol",
|
|
17
|
+
"gpt-5.6-terra",
|
|
18
|
+
"gpt-5.6-luna",
|
|
19
|
+
"gpt-6-astra"
|
|
20
|
+
];
|
|
16
21
|
var CODEX_MODEL_CONTEXT_WINDOW_TOKENS = 272e3;
|
|
17
22
|
var CODEX_EFFECTIVE_CONTEXT_WINDOW_PERCENT = 95;
|
|
18
23
|
var CODEX_MODEL_EFFECTIVE_CONTEXT_WINDOW_TOKENS = Math.floor(
|
|
@@ -22,7 +27,7 @@ var CODEX_AUTO_COMPACTION_PERCENT = 90;
|
|
|
22
27
|
var CODEX_MODEL_AUTO_COMPACT_TOKEN_LIMIT = Math.floor(
|
|
23
28
|
CODEX_MODEL_CONTEXT_WINDOW_TOKENS * CODEX_AUTO_COMPACTION_PERCENT / 100
|
|
24
29
|
);
|
|
25
|
-
var CODEX_CLIENT_VERSION = "0.
|
|
30
|
+
var CODEX_CLIENT_VERSION = "0.153.2";
|
|
26
31
|
var CODEX_REALTIME_MODEL = "gpt-live-1-boulder-alpha";
|
|
27
32
|
var CODEX_REALTIME_VERSION = "v3";
|
|
28
33
|
var CODEX_REALTIME_DEFAULT_VOICE = "cove";
|
|
@@ -88,4 +93,4 @@ export {
|
|
|
88
93
|
CODEX_APPS_STARTUP_TIMEOUT_MS,
|
|
89
94
|
CODEX_APPS_REQUIRED_SCOPES
|
|
90
95
|
};
|
|
91
|
-
//# sourceMappingURL=chunk-
|
|
96
|
+
//# sourceMappingURL=chunk-OJCCJBUL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts"],"sourcesContent":["// Wire constants for the ChatGPT/Codex subscription backend.\n// Source: CODEX-SUBSCRIPTION-SPEC.md (verified against openai/codex codex-rs).\n\nexport const CODEX_ISSUER = \"https://auth.openai.com\";\nexport const CODEX_CLIENT_ID = \"app_EMoamEEZ73f0CkXaXp7hrann\"; // spec §1.1 (manager.rs:1444)\nexport const CODEX_AUTH_BASE = `${CODEX_ISSUER}/api/accounts`; // device endpoints (device_code_auth.rs:164)\nexport const CODEX_TOKEN_URL = `${CODEX_ISSUER}/oauth/token`; // exchange (form) + refresh (json)\nexport const CODEX_DEVICE_VERIFICATION_URL = `${CODEX_ISSUER}/codex/device`;\nexport const CODEX_DEVICE_REDIRECT_URI = `${CODEX_ISSUER}/deviceauth/callback`;\n\n// Model requests: base already includes /codex; client appends /responses, /models.\nexport const CODEX_RESPONSES_BASE = \"https://chatgpt.com/backend-api/codex\";\n// Usage lives on the WHAM base — NOT under /codex (verified, spec §1.8a).\nexport const CODEX_WHAM_BASE = \"https://chatgpt.com/backend-api\";\n\nexport const CODEX_ORIGINATOR = \"codex_cli_rs\"; // whitelisted originator (spec §1.2)\nexport const CODEX_ID_TOKEN_AUTH_CLAIM = \"https://api.openai.com/auth\";\n\n// Synthetic registry-provider identity. The provider's baseURL is the bare\n// /backend-api (NOT /codex) — codexSubscriptionFetch rewrites /responses ->\n// /codex/responses. Codex model ids are namespaced `codex/<slug>` so they never\n// collide with the built-in OpenAI provider's model ids; the fetch's resolveModel\n// strips the prefix before the slug reaches the backend.\nexport const CODEX_PROVIDER_ID = \"codex-subscription\";\nexport const CODEX_PROVIDER_BASE_URL = \"https://chatgpt.com/backend-api\";\nexport const CODEX_MODEL_ID_PREFIX = \"codex/\";\n\n// The only Codex subscription models OpenGeni exposes. Astra is deliberately\n// pre-advertised before an account receives provider rollout access so the\n// picker becomes runnable without another OpenGeni release once access arrives.\n// Older or internal live models never broaden this product allowlist.\nexport const CODEX_FALLBACK_MODEL_SLUGS = [\n \"gpt-5.6-sol\",\n \"gpt-5.6-terra\",\n \"gpt-5.6-luna\",\n \"gpt-6-astra\",\n] as const;\n\n// Live Codex model-catalog values for every exposed subscription slug.\n// Verified 2026-09-04 against Codex CLI 0.153.2's bundled model catalog:\n// raw context window = 272,000\n// effective input window (95%) = 258,400\n// automatic compaction limit (90%) = 244,800\n// Keep all three explicit: the effective ceiling is a hard input guard while\n// the lower auto-compact limit is the proactive checkpoint trigger.\nexport const CODEX_MODEL_CONTEXT_WINDOW_TOKENS = 272_000;\nexport const CODEX_EFFECTIVE_CONTEXT_WINDOW_PERCENT = 95;\nexport const CODEX_MODEL_EFFECTIVE_CONTEXT_WINDOW_TOKENS = Math.floor(\n (CODEX_MODEL_CONTEXT_WINDOW_TOKENS * CODEX_EFFECTIVE_CONTEXT_WINDOW_PERCENT) / 100,\n);\nexport const CODEX_AUTO_COMPACTION_PERCENT = 90;\nexport const CODEX_MODEL_AUTO_COMPACT_TOKEN_LIMIT = Math.floor(\n (CODEX_MODEL_CONTEXT_WINDOW_TOKENS * CODEX_AUTO_COMPACTION_PERCENT) / 100,\n);\n\n// Sent as the `version` header and inside the User-Agent. Staging-proven on\n// 2026-07-09: 0.142.4 filtered every GPT-5.6 slug out of GET /models. Keep this\n// pinned to the latest stable Codex release whose bundled catalog and transport\n// contract have been reviewed here.\nexport const CODEX_CLIENT_VERSION = \"0.153.2\";\n\n// Public OpenGeni selector for native ChatGPT/Codex subscription WebRTC. This\n// remains stable for persisted sessions; the provider's remotely configured\n// model is resolved separately before call creation.\nexport const CODEX_REALTIME_MODEL = \"gpt-live-1-boulder-alpha\";\nexport const CODEX_REALTIME_VERSION = \"v3\";\nexport const CODEX_REALTIME_DEFAULT_VOICE = \"cove\";\nexport const CODEX_REALTIME_CALL_TIMEOUT_MS = 15_000;\nexport const CODEX_REALTIME_CONFIG_TIMEOUT_MS = 5_000;\nexport const CODEX_REALTIME_CONFIG_ID = \"3566525122\";\n// Verified live on 2026-08-23. Used only when the authenticated remote config\n// is transiently unavailable or malformed; it is not the persisted model id.\nexport const CODEX_REALTIME_PROVIDER_MODEL_FALLBACK = \"gpt-live-1-codex\";\nexport const CODEX_REALTIME_PROVIDER_ARCHITECTURE_FALLBACK = \"avas\";\n\nexport const CODEX_REFRESH_WINDOW_MS = 5 * 60 * 1000; // proactive refresh when within 5 min of exp (spec §1.1)\nexport const CODEX_REFRESH_FALLBACK_MS = 8 * 24 * 60 * 60 * 1000; // 8 days when exp is unparseable\n\n// Codex Responses transport deadlines. The OpenAI SDK's own timeout only covers\n// the wait for response headers and erases the underlying timeout class into the\n// bare `Request timed out.` error. Keep the provider-specific budgets here so\n// the transport can enforce and durably report them without enabling the SDK's\n// blind request replay.\nexport const CODEX_RESPONSE_HEADERS_TIMEOUT_MS = 4 * 60_000;\nexport const CODEX_RESPONSE_STREAM_IDLE_TIMEOUT_MS = 5 * 60_000;\nexport const CODEX_RESPONSE_WHOLE_TIMEOUT_MS = 30 * 60_000;\n// Kept as a compatibility-shaped policy field, but automatic replay is disabled\n// until a provider-specific operation receipt can prove non-acceptance or resume\n// the same operation identity. An absent response does not prove that the\n// provider never accepted the request.\nexport const CODEX_RESPONSE_NO_BYTE_RETRIES = 0;\nexport const CODEX_RESPONSE_RETRY_BACKOFF_MS = 1_000;\n// Must exceed the transport-owned whole-response deadline. This SDK guard is a\n// last-resort envelope; the inner transport emits the typed/durable failure.\nexport const CODEX_RESPONSE_SDK_OUTER_TIMEOUT_MS = 35 * 60_000;\n\n// ── Apps / connectors MCP (spec §1.10, §E) ───────────────────────────────────\n// One server-side MCP exposes ALL the user's ChatGPT/Codex connectors\n// (gmail/github/linear/slack/sentry/drive/calendar/…). Streamable HTTP, always.\nexport const CODEX_APPS_MCP_SERVER_ID = \"codex_apps\"; // tools surface as mcp__codex_apps__<tool>\nexport const CODEX_APPS_MCP_SERVER_NAME = \"codex_apps\"; // MCP `name` — MUST equal the id so the SDK namespaces tools as mcp__codex_apps__*\nexport const CODEX_APPS_MCP_URL = \"https://chatgpt.com/backend-api/ps/mcp\"; // live URL (NOT /codex, NOT the legacy /wham/apps)\nexport const CODEX_APPS_STARTUP_TIMEOUT_MS = 30_000; // startup_timeout 30s (spec §1.10) — maps to timeoutMs on this server only\n// Connector scopes that the apps MCP requires. Present ONLY when granted at\n// browser-authorize time; the device-code path CANNOT be confirmed to grant\n// them, so treat connector availability as runtime-discovered (spec §1.10 / §E).\nexport const CODEX_APPS_REQUIRED_SCOPES = [\"api.connectors.read\", \"api.connectors.invoke\"] as const;\n"],"mappings":";AAGO,IAAM,eAAe;AACrB,IAAM,kBAAkB;AACxB,IAAM,kBAAkB,GAAG,YAAY;AACvC,IAAM,kBAAkB,GAAG,YAAY;AACvC,IAAM,gCAAgC,GAAG,YAAY;AACrD,IAAM,4BAA4B,GAAG,YAAY;AAGjD,IAAM,uBAAuB;AAE7B,IAAM,kBAAkB;AAExB,IAAM,mBAAmB;AACzB,IAAM,4BAA4B;AAOlC,IAAM,oBAAoB;AAC1B,IAAM,0BAA0B;AAChC,IAAM,wBAAwB;AAM9B,IAAM,6BAA6B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AASO,IAAM,oCAAoC;AAC1C,IAAM,yCAAyC;AAC/C,IAAM,8CAA8C,KAAK;AAAA,EAC7D,oCAAoC,yCAA0C;AACjF;AACO,IAAM,gCAAgC;AACtC,IAAM,uCAAuC,KAAK;AAAA,EACtD,oCAAoC,gCAAiC;AACxE;AAMO,IAAM,uBAAuB;AAK7B,IAAM,uBAAuB;AAC7B,IAAM,yBAAyB;AAC/B,IAAM,+BAA+B;AACrC,IAAM,iCAAiC;AACvC,IAAM,mCAAmC;AACzC,IAAM,2BAA2B;AAGjC,IAAM,yCAAyC;AAC/C,IAAM,gDAAgD;AAEtD,IAAM,0BAA0B,IAAI,KAAK;AACzC,IAAM,4BAA4B,IAAI,KAAK,KAAK,KAAK;AAOrD,IAAM,oCAAoC,IAAI;AAC9C,IAAM,wCAAwC,IAAI;AAClD,IAAM,kCAAkC,KAAK;AAK7C,IAAM,iCAAiC;AACvC,IAAM,kCAAkC;AAGxC,IAAM,sCAAsC,KAAK;AAKjD,IAAM,2BAA2B;AACjC,IAAM,6BAA6B;AACnC,IAAM,qBAAqB;AAC3B,IAAM,gCAAgC;AAItC,IAAM,6BAA6B,CAAC,uBAAuB,uBAAuB;","names":[]}
|
package/dist/constants.d.ts
CHANGED
|
@@ -11,13 +11,13 @@ export declare const CODEX_ID_TOKEN_AUTH_CLAIM = "https://api.openai.com/auth";
|
|
|
11
11
|
export declare const CODEX_PROVIDER_ID = "codex-subscription";
|
|
12
12
|
export declare const CODEX_PROVIDER_BASE_URL = "https://chatgpt.com/backend-api";
|
|
13
13
|
export declare const CODEX_MODEL_ID_PREFIX = "codex/";
|
|
14
|
-
export declare const CODEX_FALLBACK_MODEL_SLUGS: readonly ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna"];
|
|
14
|
+
export declare const CODEX_FALLBACK_MODEL_SLUGS: readonly ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-6-astra"];
|
|
15
15
|
export declare const CODEX_MODEL_CONTEXT_WINDOW_TOKENS = 272000;
|
|
16
16
|
export declare const CODEX_EFFECTIVE_CONTEXT_WINDOW_PERCENT = 95;
|
|
17
17
|
export declare const CODEX_MODEL_EFFECTIVE_CONTEXT_WINDOW_TOKENS: number;
|
|
18
18
|
export declare const CODEX_AUTO_COMPACTION_PERCENT = 90;
|
|
19
19
|
export declare const CODEX_MODEL_AUTO_COMPACT_TOKEN_LIMIT: number;
|
|
20
|
-
export declare const CODEX_CLIENT_VERSION = "0.
|
|
20
|
+
export declare const CODEX_CLIENT_VERSION = "0.153.2";
|
|
21
21
|
export declare const CODEX_REALTIME_MODEL = "gpt-live-1-boulder-alpha";
|
|
22
22
|
export declare const CODEX_REALTIME_VERSION = "v3";
|
|
23
23
|
export declare const CODEX_REALTIME_DEFAULT_VOICE = "cove";
|
package/dist/constants.js
CHANGED
package/dist/images.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare function generateCodexSubscriptionImage(input: {
|
|
|
26
26
|
prompt: string;
|
|
27
27
|
references?: readonly CodexImageReferenceInput[];
|
|
28
28
|
turnId: string;
|
|
29
|
-
context: Pick<CodexRequestContext, "clientVersion" | "getToken" | "refresh">;
|
|
29
|
+
context: Pick<CodexRequestContext, "clientVersion" | "getToken" | "refresh" | "beforeProviderDispatch">;
|
|
30
30
|
abortSignal?: AbortSignal;
|
|
31
31
|
fetch?: FetchLike;
|
|
32
32
|
/** Internal test/host override; one absolute budget covers auth retry and body streaming. */
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
CODEX_RESPONSE_WHOLE_TIMEOUT_MS,
|
|
41
41
|
CODEX_TOKEN_URL,
|
|
42
42
|
CODEX_WHAM_BASE
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-OJCCJBUL.js";
|
|
44
44
|
import {
|
|
45
45
|
CODEX_REALTIME_CONTEXT_APPEND_MAX_BYTES,
|
|
46
46
|
CODEX_REALTIME_INITIAL_ITEMS_MAX_COUNT,
|
|
@@ -1352,6 +1352,7 @@ function codexSubscriptionFetch(base = globalThis.fetch) {
|
|
|
1352
1352
|
deferTransportTerminal: !callerWantsStream
|
|
1353
1353
|
};
|
|
1354
1354
|
try {
|
|
1355
|
+
await ctx.beforeProviderDispatch?.();
|
|
1355
1356
|
res = await fetchBeforeHeaders(base, rewritten, nextInit, audit);
|
|
1356
1357
|
const upstreamRequestId = providerRequestId(res.headers);
|
|
1357
1358
|
await emitRequestEvent(audit, {
|
|
@@ -2543,6 +2544,7 @@ async function generateCodexSubscriptionImage(input) {
|
|
|
2543
2544
|
const signal = input.abortSignal ? AbortSignal.any([input.abortSignal, deadline.signal]) : deadline.signal;
|
|
2544
2545
|
const request = async (auth) => {
|
|
2545
2546
|
const headers = codexImageHeaders(auth, input.context.clientVersion, input.turnId);
|
|
2547
|
+
await input.context.beforeProviderDispatch?.();
|
|
2546
2548
|
return await fetchImpl(
|
|
2547
2549
|
`${CODEX_RESPONSES_BASE}/${references.length > 0 ? "images/edits" : "images/generations"}`,
|
|
2548
2550
|
{
|