@ljoukov/llm 7.0.19 → 7.0.21
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/README.md +2 -2
- package/dist/index.cjs +32 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +31 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -108,7 +108,7 @@ refresh-token rotation and serves short-lived access tokens.
|
|
|
108
108
|
- `CHATGPT_AUTH_TOKEN_PROVIDER_URL` (example: `https://chatgpt-auth.<your-domain>`)
|
|
109
109
|
- `CHATGPT_AUTH_API_KEY` (shared secret; sent as `Authorization: Bearer ...` and `x-chatgpt-auth: ...`)
|
|
110
110
|
- `CHATGPT_AUTH_TOKEN_PROVIDER_STORE` (`kv` or `d1`, defaults to `kv`)
|
|
111
|
-
- `CHATGPT_CODEX_PROXY_URL` (optional Vercel proxy endpoint
|
|
111
|
+
- `CHATGPT_CODEX_PROXY_URL` (optional Vercel proxy endpoint; accepts either `https://<project>.vercel.app` or `https://<project>.vercel.app/api/codex/responses`)
|
|
112
112
|
- `CHATGPT_CODEX_PROXY_API_KEY` (bearer token for `CHATGPT_CODEX_PROXY_URL`)
|
|
113
113
|
- `CHATGPT_CODEX_ENDPOINT` (optional direct endpoint override; defaults to `https://chatgpt.com/backend-api/codex/responses`)
|
|
114
114
|
- `CHATGPT_RESPONSES_WEBSOCKET_MODE` (`auto` | `off` | `only`, default: `auto`)
|
|
@@ -122,7 +122,7 @@ token provider and will not read the local Codex auth store.
|
|
|
122
122
|
If `CHATGPT_CODEX_PROXY_URL` + `CHATGPT_CODEX_PROXY_API_KEY` are set, `chatgpt-*` text requests are sent through that
|
|
123
123
|
proxy and the local process does not need access to the Codex auth store or token provider. The Vercel proxy fetches
|
|
124
124
|
short-lived ChatGPT access tokens from `workers/chatgpt-auth` and streams the upstream Codex response body back to the
|
|
125
|
-
caller.
|
|
125
|
+
caller. These proxy bearer tokens should be server-side environment variables; do not expose them in browser bundles.
|
|
126
126
|
|
|
127
127
|
### Responses transport
|
|
128
128
|
|
package/dist/index.cjs
CHANGED
|
@@ -65,6 +65,7 @@ __export(index_exports, {
|
|
|
65
65
|
OPENAI_MODEL_IDS: () => OPENAI_MODEL_IDS,
|
|
66
66
|
appendMarkdownSourcesSection: () => appendMarkdownSourcesSection,
|
|
67
67
|
applyPatch: () => applyPatch,
|
|
68
|
+
configureChatGptCodexProxy: () => configureChatGptCodexProxy,
|
|
68
69
|
configureGemini: () => configureGemini,
|
|
69
70
|
configureModelConcurrency: () => configureModelConcurrency,
|
|
70
71
|
configureTelemetry: () => configureTelemetry,
|
|
@@ -1724,7 +1725,8 @@ var CHATGPT_CODEX_PROXY_API_KEY_ENV = "CHATGPT_CODEX_PROXY_API_KEY";
|
|
|
1724
1725
|
var CHATGPT_RESPONSES_EXPERIMENTAL_HEADER = "responses=experimental";
|
|
1725
1726
|
var chatGptCodexState = getRuntimeSingleton(/* @__PURE__ */ Symbol.for("@ljoukov/llm.chatGptCodexState"), () => ({
|
|
1726
1727
|
cachedResponsesWebSocketMode: null,
|
|
1727
|
-
chatGptResponsesWebSocketDisabled: false
|
|
1728
|
+
chatGptResponsesWebSocketDisabled: false,
|
|
1729
|
+
configuredProxy: null
|
|
1728
1730
|
}));
|
|
1729
1731
|
async function streamChatGptCodexResponse(options) {
|
|
1730
1732
|
const endpointConfig = await resolveChatGptCodexEndpointConfig();
|
|
@@ -1772,6 +1774,13 @@ async function streamChatGptCodexResponse(options) {
|
|
|
1772
1774
|
}
|
|
1773
1775
|
});
|
|
1774
1776
|
}
|
|
1777
|
+
function configureChatGptCodexProxy(configuration) {
|
|
1778
|
+
chatGptCodexState.configuredProxy = configuration ? {
|
|
1779
|
+
url: normalizeChatGptCodexProxyUrl(configuration.url),
|
|
1780
|
+
apiKey: configuration.apiKey
|
|
1781
|
+
} : null;
|
|
1782
|
+
chatGptCodexState.cachedResponsesWebSocketMode = null;
|
|
1783
|
+
}
|
|
1775
1784
|
async function streamChatGptCodexResponseSse(options) {
|
|
1776
1785
|
const headers = buildChatGptCodexHeaders({
|
|
1777
1786
|
endpointConfig: options.endpointConfig,
|
|
@@ -1826,9 +1835,16 @@ function resolveChatGptCodexEndpoint() {
|
|
|
1826
1835
|
return process.env[CHATGPT_CODEX_ENDPOINT_ENV]?.trim() || CHATGPT_CODEX_ENDPOINT;
|
|
1827
1836
|
}
|
|
1828
1837
|
function resolveChatGptCodexProxyConfig() {
|
|
1838
|
+
if (chatGptCodexState.configuredProxy) {
|
|
1839
|
+
return {
|
|
1840
|
+
kind: "proxy",
|
|
1841
|
+
url: chatGptCodexState.configuredProxy.url,
|
|
1842
|
+
apiKey: chatGptCodexState.configuredProxy.apiKey
|
|
1843
|
+
};
|
|
1844
|
+
}
|
|
1829
1845
|
loadLocalEnv();
|
|
1830
|
-
const
|
|
1831
|
-
if (!
|
|
1846
|
+
const rawUrl = process.env[CHATGPT_CODEX_PROXY_URL_ENV]?.trim();
|
|
1847
|
+
if (!rawUrl) {
|
|
1832
1848
|
return null;
|
|
1833
1849
|
}
|
|
1834
1850
|
const apiKey = process.env[CHATGPT_CODEX_PROXY_API_KEY_ENV]?.trim();
|
|
@@ -1839,10 +1855,21 @@ function resolveChatGptCodexProxyConfig() {
|
|
|
1839
1855
|
}
|
|
1840
1856
|
return {
|
|
1841
1857
|
kind: "proxy",
|
|
1842
|
-
url,
|
|
1858
|
+
url: normalizeChatGptCodexProxyUrl(rawUrl),
|
|
1843
1859
|
apiKey
|
|
1844
1860
|
};
|
|
1845
1861
|
}
|
|
1862
|
+
function normalizeChatGptCodexProxyUrl(rawUrl) {
|
|
1863
|
+
try {
|
|
1864
|
+
const url = new URL(rawUrl);
|
|
1865
|
+
if (url.pathname === "" || url.pathname === "/") {
|
|
1866
|
+
url.pathname = "/api/codex/responses";
|
|
1867
|
+
}
|
|
1868
|
+
return url.toString();
|
|
1869
|
+
} catch {
|
|
1870
|
+
return rawUrl;
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1846
1873
|
function buildChatGptCodexHeaders(options) {
|
|
1847
1874
|
const openAiBeta = options.useWebSocket ? mergeOpenAiBetaHeader(
|
|
1848
1875
|
CHATGPT_RESPONSES_EXPERIMENTAL_HEADER,
|
|
@@ -15107,6 +15134,7 @@ async function runCandidateEvolution(options) {
|
|
|
15107
15134
|
OPENAI_MODEL_IDS,
|
|
15108
15135
|
appendMarkdownSourcesSection,
|
|
15109
15136
|
applyPatch,
|
|
15137
|
+
configureChatGptCodexProxy,
|
|
15110
15138
|
configureGemini,
|
|
15111
15139
|
configureModelConcurrency,
|
|
15112
15140
|
configureTelemetry,
|