@ljoukov/llm 7.0.19 → 7.0.20

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.js CHANGED
@@ -1690,8 +1690,8 @@ function resolveChatGptCodexEndpoint() {
1690
1690
  }
1691
1691
  function resolveChatGptCodexProxyConfig() {
1692
1692
  loadLocalEnv();
1693
- const url = process.env[CHATGPT_CODEX_PROXY_URL_ENV]?.trim();
1694
- if (!url) {
1693
+ const rawUrl = process.env[CHATGPT_CODEX_PROXY_URL_ENV]?.trim();
1694
+ if (!rawUrl) {
1695
1695
  return null;
1696
1696
  }
1697
1697
  const apiKey = process.env[CHATGPT_CODEX_PROXY_API_KEY_ENV]?.trim();
@@ -1702,10 +1702,21 @@ function resolveChatGptCodexProxyConfig() {
1702
1702
  }
1703
1703
  return {
1704
1704
  kind: "proxy",
1705
- url,
1705
+ url: normalizeChatGptCodexProxyUrl(rawUrl),
1706
1706
  apiKey
1707
1707
  };
1708
1708
  }
1709
+ function normalizeChatGptCodexProxyUrl(rawUrl) {
1710
+ try {
1711
+ const url = new URL(rawUrl);
1712
+ if (url.pathname === "" || url.pathname === "/") {
1713
+ url.pathname = "/api/codex/responses";
1714
+ }
1715
+ return url.toString();
1716
+ } catch {
1717
+ return rawUrl;
1718
+ }
1719
+ }
1709
1720
  function buildChatGptCodexHeaders(options) {
1710
1721
  const openAiBeta = options.useWebSocket ? mergeOpenAiBetaHeader(
1711
1722
  CHATGPT_RESPONSES_EXPERIMENTAL_HEADER,