codex-mobile-re 0.1.94 → 0.1.95

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/index.html CHANGED
@@ -12,8 +12,8 @@
12
12
  <link rel="icon" type="image/png" sizes="192x192" href="/icons/pwa-192x192.png" />
13
13
  <link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png" />
14
14
  <title>Codex Web</title>
15
- <script type="module" crossorigin src="/assets/index-DzPfsKYl.js"></script>
16
- <link rel="stylesheet" crossorigin href="/assets/index-0DXJVzPV.css">
15
+ <script type="module" crossorigin src="/assets/index-BItdblN0.js"></script>
16
+ <link rel="stylesheet" crossorigin href="/assets/index-Cu7x4SXC.css">
17
17
  </head>
18
18
  <body class="bg-slate-950">
19
19
  <div id="app"></div>
package/dist-cli/index.js CHANGED
@@ -8626,6 +8626,34 @@ async function fetchCustomEndpointDefaultModel(baseUrl, apiKey) {
8626
8626
  return "";
8627
8627
  }
8628
8628
  }
8629
+ var CUSTOM_ENDPOINT_PATH_SUFFIXES = ["/chat/completions", "/responses"];
8630
+ function normalizeCustomEndpointBaseUrl(input) {
8631
+ let url = input.trim();
8632
+ if (!url) return "";
8633
+ url = url.replace(/\/+$/u, "");
8634
+ const lowered = url.toLowerCase();
8635
+ for (const suffix of CUSTOM_ENDPOINT_PATH_SUFFIXES) {
8636
+ if (lowered.endsWith(suffix)) {
8637
+ url = url.slice(0, url.length - suffix.length);
8638
+ break;
8639
+ }
8640
+ }
8641
+ return url.replace(/\/+$/u, "");
8642
+ }
8643
+ async function fetchCustomEndpointModelIds(customBaseUrl, apiKey) {
8644
+ try {
8645
+ const modelsUrl = customBaseUrl.replace(/\/+$/, "") + "/models";
8646
+ const headers = {};
8647
+ if (apiKey && apiKey !== "dummy") {
8648
+ headers["Authorization"] = `Bearer ${apiKey}`;
8649
+ }
8650
+ const resp = await fetch(modelsUrl, { headers, signal: AbortSignal.timeout(8e3) });
8651
+ if (!resp.ok) return [];
8652
+ return normalizeProviderModelsData(await resp.json());
8653
+ } catch {
8654
+ return [];
8655
+ }
8656
+ }
8629
8657
  async function fetchOpenCodeZenModelIds(apiKey) {
8630
8658
  const headers = {};
8631
8659
  if (apiKey && apiKey !== "dummy") {
@@ -13356,7 +13384,8 @@ function createCodexBridgeMiddleware() {
13356
13384
  if (req.method === "POST" && url.pathname === "/codex-api/free-mode/custom-provider") {
13357
13385
  try {
13358
13386
  const body = await readJsonBody2(req);
13359
- const baseUrl = typeof body?.baseUrl === "string" ? body.baseUrl.trim() : "";
13387
+ const rawBaseUrl = typeof body?.baseUrl === "string" ? body.baseUrl.trim() : "";
13388
+ const baseUrl = normalizeCustomEndpointBaseUrl(rawBaseUrl);
13360
13389
  const apiKey = typeof body?.apiKey === "string" ? body.apiKey.trim() : "";
13361
13390
  const wireApi = body?.wireApi === "chat" ? "chat" : "responses";
13362
13391
  const providerType = body?.provider === "opencode-zen" ? "opencode-zen" : body?.provider === "openrouter" ? "openrouter" : "custom";
@@ -13944,6 +13973,31 @@ function createCodexBridgeMiddleware() {
13944
13973
  try {
13945
13974
  const requestedProvider = url.searchParams.get("provider")?.trim() ?? "";
13946
13975
  if (requestedProvider) {
13976
+ const normalizedRequestedProvider = requestedProvider.replace(/_/g, "-");
13977
+ const fmState2 = ensureDefaultFreeModeStateForMissingAuthSync(join9(getCodexHomeDir5(), FREE_MODE_STATE_FILE));
13978
+ if (fmState2?.enabled && normalizedRequestedProvider === CUSTOM_RUNTIME_PROVIDER_ID.replace(/_/g, "-") && fmState2.provider === "custom" && fmState2.customBaseUrl) {
13979
+ setJson4(res, 200, {
13980
+ data: await fetchCustomEndpointModelIds(fmState2.customBaseUrl, fmState2.apiKey ?? ""),
13981
+ exclusive: true,
13982
+ source: "custom"
13983
+ });
13984
+ return;
13985
+ }
13986
+ if (fmState2?.enabled && normalizedRequestedProvider === OPENCODE_ZEN_RUNTIME_PROVIDER_ID.replace(/_/g, "-") && fmState2.provider === "opencode-zen") {
13987
+ setJson4(res, 200, {
13988
+ data: filterOpenCodeZenModelsForAuthState(
13989
+ sortOpenCodeZenModelIds(await fetchOpenCodeZenModelIds(fmState2.apiKey)),
13990
+ fmState2.apiKey
13991
+ ),
13992
+ exclusive: true,
13993
+ source: "opencode-zen"
13994
+ });
13995
+ return;
13996
+ }
13997
+ if (fmState2?.enabled && normalizedRequestedProvider === FREE_MODE_RUNTIME_PROVIDER_ID.replace(/_/g, "-") && fmState2.provider === "openrouter") {
13998
+ setJson4(res, 200, { data: await getFreeModels(), exclusive: true, source: "openrouter" });
13999
+ return;
14000
+ }
13947
14001
  setJson4(res, 200, {
13948
14002
  ...await readProviderModelIdsForProvider(appServer, requestedProvider),
13949
14003
  exclusive: true
@@ -13968,24 +14022,10 @@ function createCodexBridgeMiddleware() {
13968
14022
  return;
13969
14023
  }
13970
14024
  if (fmState.provider === "custom" && fmState.customBaseUrl) {
13971
- try {
13972
- const modelsUrl = fmState.customBaseUrl.replace(/\/+$/, "") + "/models";
13973
- const headers = {};
13974
- if (fmState.apiKey && fmState.apiKey !== "dummy") {
13975
- headers["Authorization"] = `Bearer ${fmState.apiKey}`;
13976
- }
13977
- const resp = await fetch(modelsUrl, { headers, signal: AbortSignal.timeout(8e3) });
13978
- if (resp.ok) {
13979
- const json = await resp.json();
13980
- const ids = normalizeProviderModelsData(json);
13981
- const currentModel = fmState.model?.trim() ?? "";
13982
- const orderedIds = currentModel && ids.includes(currentModel) ? [currentModel, ...ids.filter((id) => id !== currentModel)] : ids;
13983
- setJson4(res, 200, { data: orderedIds, exclusive: true, source: "custom" });
13984
- return;
13985
- }
13986
- } catch {
13987
- }
13988
- setJson4(res, 200, { data: [], exclusive: true, source: "custom" });
14025
+ const ids = await fetchCustomEndpointModelIds(fmState.customBaseUrl, fmState.apiKey ?? "");
14026
+ const currentModel = fmState.model?.trim() ?? "";
14027
+ const orderedIds = currentModel && ids.includes(currentModel) ? [currentModel, ...ids.filter((id) => id !== currentModel)] : ids;
14028
+ setJson4(res, 200, { data: orderedIds, exclusive: true, source: "custom" });
13989
14029
  return;
13990
14030
  }
13991
14031
  const freeModels = await getFreeModels();