codex-subscription-oauth-plugin 0.1.4 → 0.1.6
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.ja.md +9 -0
- package/README.md +9 -0
- package/lib/index.js +74 -32
- package/lib/{models-DaqoXO5b.js → models-BdCc9Ab5.js} +9 -9
- package/lib/{openai-codex-responses-DPxdQtbt.js → openai-codex-responses-DKg-2_3a.js} +20 -20
- package/lib/openai-codex.js +5 -5
- package/lib/{provider-env-DRzE1dvc.js → provider-env-BoYS8tP5.js} +1 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -20,6 +20,15 @@ pnpm dsh plugin --profile acp add github:askdkc/dsh-codex
|
|
|
20
20
|
|
|
21
21
|
プラグインはプロファイルごとに読み込まれるため、`web` に導入しただけでは `acp` にモデルは追加されません。ACPクライアントが起動するDSHプロセスを再起動し、モデル選択を開き直してください。別のプロファイルを使っている場合は、`acp` をその名前に置き換えます。
|
|
22
22
|
|
|
23
|
+
既存のACPプロファイルへのインストールが `ERR_PNPM_UNEXPECTED_STORE` で失敗した場合は、現在のpnpmストアを使ってそのプロファイルの依存関係を再インストールしてから、プラグインの追加を再実行します。
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
pnpm --dir ~/.dsh/profiles/acp install --force --frozen-lockfile
|
|
27
|
+
pnpm dsh plugin --profile acp add github:askdkc/dsh-codex
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
最初のコマンドはロックファイルを変更せずに、プロファイルの `node_modules` を作り直します。失敗した場合は、そのエラーを解消してからプラグインの追加を再実行してください。`DSH_HOME` やプロファイル名を変更している場合は、両方のコマンドを合わせて変更します。ストア不一致の後に表示される `allowBuilds` の案内では、このエラーは解消しません。
|
|
31
|
+
|
|
23
32
|
Codex用のChatGPTアカウントでログインします。
|
|
24
33
|
|
|
25
34
|
```text
|
package/README.md
CHANGED
|
@@ -20,6 +20,15 @@ pnpm dsh plugin --profile acp add github:askdkc/dsh-codex
|
|
|
20
20
|
|
|
21
21
|
Profiles load plugins independently: installing into `web` does not add models to `acp`. Restart the DSH process launched by your ACP client, then reopen its model selector. If the client uses a different profile, replace `acp` with that name.
|
|
22
22
|
|
|
23
|
+
If installation into an existing ACP profile fails with `ERR_PNPM_UNEXPECTED_STORE`, reinstall that profile's dependencies using the current pnpm store, then retry:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
pnpm --dir ~/.dsh/profiles/acp install --force --frozen-lockfile
|
|
27
|
+
pnpm dsh plugin --profile acp add github:askdkc/dsh-codex
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The first command rebuilds the profile's `node_modules` without changing its lockfile. If it fails, resolve that error before retrying the plugin installation. If you use a custom `DSH_HOME` or profile name, adjust both commands. The `allowBuilds` hint printed after a store mismatch does not fix this error.
|
|
31
|
+
|
|
23
32
|
Sign in to ChatGPT for Codex:
|
|
24
33
|
|
|
25
34
|
```text
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as lazyApi, i as createProvider, r as createModels } from "./models-
|
|
1
|
+
import { c as lazyApi, i as createProvider, r as createModels } from "./models-BdCc9Ab5.js";
|
|
2
2
|
import AuthorizationService, { AuthorizationDeclinedError } from "@deepseek-ai/dsh-authorization";
|
|
3
3
|
import { credentialKey, credentialKeyId, credentialKeyScope, isCredentialKeySegment } from "@deepseek-ai/dsh-credentials";
|
|
4
4
|
import { LlmError, resolveImageAttachmentAccess, resolveRetryPolicy } from "@deepseek-ai/dsh-llm";
|
|
5
5
|
import { PiAiAdapter, recordKeyFor } from "@deepseek-ai/dsh-llm-pi-ai";
|
|
6
|
-
//#region node_modules/@earendil-works/pi-ai/dist/auth/helpers.js
|
|
6
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/auth/helpers.js
|
|
7
7
|
/**
|
|
8
8
|
* Wraps a dynamically imported `OAuthAuth` so provider definitions can
|
|
9
9
|
* advertise OAuth without importing the implementation. The flow loads on
|
|
@@ -27,10 +27,10 @@ function lazyOAuth(input) {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
//#endregion
|
|
30
|
-
//#region node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.lazy.js
|
|
31
|
-
const openAICodexResponsesApi = () => lazyApi(() => import("./openai-codex-responses-
|
|
30
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.lazy.js
|
|
31
|
+
const openAICodexResponsesApi = () => lazyApi(() => import("./openai-codex-responses-DKg-2_3a.js"));
|
|
32
32
|
//#endregion
|
|
33
|
-
//#region node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js
|
|
33
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js
|
|
34
34
|
var __rewriteRelativeImportExtension = function(path, preserveJsx) {
|
|
35
35
|
if (typeof path === "string" && /^\.\.?\//.test(path)) return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {
|
|
36
36
|
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : d + ext + "." + cm.toLowerCase() + "js";
|
|
@@ -50,7 +50,7 @@ const loadOpenAICodexOAuth = async () => {
|
|
|
50
50
|
return (await importOAuthModule("./openai-codex.ts")).openaiCodexOAuth;
|
|
51
51
|
};
|
|
52
52
|
//#endregion
|
|
53
|
-
//#region node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json
|
|
53
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json
|
|
54
54
|
var openai_codex_default = { "openai-codex-responses": {
|
|
55
55
|
"gpt-5.3-codex-spark": {
|
|
56
56
|
"id": "gpt-5.3-codex-spark",
|
|
@@ -305,15 +305,15 @@ var openai_codex_default = { "openai-codex-responses": {
|
|
|
305
305
|
}
|
|
306
306
|
} };
|
|
307
307
|
//#endregion
|
|
308
|
-
//#region node_modules/@earendil-works/pi-ai/dist/model-catalog.js
|
|
308
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/model-catalog.js
|
|
309
309
|
function flattenModelCatalog(_provider, groups) {
|
|
310
310
|
return Object.assign({}, ...Object.values(groups));
|
|
311
311
|
}
|
|
312
312
|
//#endregion
|
|
313
|
-
//#region node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js
|
|
313
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js
|
|
314
314
|
const OPENAI_CODEX_MODELS = flattenModelCatalog("openai-codex", openai_codex_default);
|
|
315
315
|
//#endregion
|
|
316
|
-
//#region node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.js
|
|
316
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.js
|
|
317
317
|
function openaiCodexProvider() {
|
|
318
318
|
return createProvider({
|
|
319
319
|
id: "openai-codex",
|
|
@@ -723,6 +723,44 @@ function codexAuthContext() {
|
|
|
723
723
|
};
|
|
724
724
|
}
|
|
725
725
|
//#endregion
|
|
726
|
+
//#region src/provider.ts
|
|
727
|
+
/** Replay system deltas into the prompt/tools envelope understood by SDK 0.85. */
|
|
728
|
+
function toBundledCodexContext(context) {
|
|
729
|
+
if (!context.messages.some((message) => message.role === "system")) return context;
|
|
730
|
+
const instructions = context.systemPrompt ? [context.systemPrompt] : [];
|
|
731
|
+
const sections = /* @__PURE__ */ new Map();
|
|
732
|
+
const tools = new Map((context.tools ?? []).map((tool) => [tool.name, tool]));
|
|
733
|
+
const messages = [];
|
|
734
|
+
for (const message of context.messages) {
|
|
735
|
+
if (message.role !== "system") {
|
|
736
|
+
messages.push(message);
|
|
737
|
+
continue;
|
|
738
|
+
}
|
|
739
|
+
const text = typeof message.content === "string" ? message.content : message.content.map((block) => block.text).join("\n");
|
|
740
|
+
if (text.length > 0) instructions.push(text);
|
|
741
|
+
for (const [name, value] of Object.entries(message.sections ?? {})) if (value === null) sections.delete(name);
|
|
742
|
+
else sections.set(name, value);
|
|
743
|
+
for (const tool of message.toolsRemoved ?? []) tools.delete(tool.name);
|
|
744
|
+
for (const tool of message.toolsAdded ?? []) tools.set(tool.name, tool);
|
|
745
|
+
}
|
|
746
|
+
const systemPrompt = [...instructions, ...sections.values()].filter((text) => text.length > 0).join("\n\n");
|
|
747
|
+
return {
|
|
748
|
+
messages,
|
|
749
|
+
...systemPrompt.length === 0 ? {} : { systemPrompt },
|
|
750
|
+
...tools.size === 0 ? {} : { tools: [...tools.values()] }
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
/** Freeze a catalog generation and bridge both provider streaming entry points. */
|
|
754
|
+
function providerWithModels(provider, models) {
|
|
755
|
+
const generation = Object.freeze([...models]);
|
|
756
|
+
return {
|
|
757
|
+
...provider,
|
|
758
|
+
getModels: () => generation,
|
|
759
|
+
stream: (model, context, options) => provider.stream(model, toBundledCodexContext(context), options),
|
|
760
|
+
streamSimple: (model, context, options) => provider.streamSimple(model, toBundledCodexContext(context), options)
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
//#endregion
|
|
726
764
|
//#region src/index.ts
|
|
727
765
|
/** Cordis plugin name. */
|
|
728
766
|
const name = "codex-subscription-oauth";
|
|
@@ -919,40 +957,44 @@ async function execute(invocation, ctx) {
|
|
|
919
957
|
queue.clear();
|
|
920
958
|
}
|
|
921
959
|
}
|
|
922
|
-
/** Bind one immutable catalog generation to the upstream Codex transport. */
|
|
923
|
-
function providerWithModels(provider, models) {
|
|
924
|
-
const generation = Object.freeze([...models]);
|
|
925
|
-
return {
|
|
926
|
-
...provider,
|
|
927
|
-
getModels: () => generation
|
|
928
|
-
};
|
|
929
|
-
}
|
|
930
960
|
/** Supply executable metadata for GPT-6 models missing from the pinned pi-ai catalog. */
|
|
931
961
|
function bundledCodexModels(provider) {
|
|
932
962
|
const models = provider.getModels();
|
|
933
963
|
const astra = models.find((model) => model.id === "gpt-6-astra");
|
|
934
964
|
if (astra === void 0) throw new Error("codex-subscription-oauth: missing GPT-6 transport metadata");
|
|
935
|
-
const additions = [
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
965
|
+
const additions = [
|
|
966
|
+
{
|
|
967
|
+
id: "gpt-6.1-sol",
|
|
968
|
+
name: "GPT-6.1 Sol",
|
|
969
|
+
input: 2,
|
|
970
|
+
output: 10,
|
|
971
|
+
cacheRead: .1,
|
|
972
|
+
cacheWrite: 2.5
|
|
973
|
+
},
|
|
974
|
+
{
|
|
975
|
+
id: "gpt-6-sol",
|
|
976
|
+
name: "GPT-6 Sol",
|
|
977
|
+
input: 2,
|
|
978
|
+
output: 10,
|
|
979
|
+
cacheRead: .2,
|
|
980
|
+
cacheWrite: 2.5
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
id: "gpt-6-luna",
|
|
984
|
+
name: "GPT-6 Luna",
|
|
985
|
+
input: .1,
|
|
986
|
+
output: .5,
|
|
987
|
+
cacheRead: .01,
|
|
988
|
+
cacheWrite: .125
|
|
989
|
+
}
|
|
990
|
+
];
|
|
950
991
|
return Object.freeze([...models, ...additions.filter((entry) => !models.some((model) => model.id === entry.id)).map((entry) => Object.freeze({
|
|
951
992
|
...astra,
|
|
952
993
|
id: entry.id,
|
|
953
994
|
name: entry.name,
|
|
954
995
|
thinkingLevelMap: {
|
|
955
996
|
off: null,
|
|
997
|
+
...entry.id === "gpt-6.1-sol" ? { minimal: null } : {},
|
|
956
998
|
low: "low",
|
|
957
999
|
medium: "medium",
|
|
958
1000
|
high: "high",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js
|
|
1
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js
|
|
2
2
|
var EventStream = class {
|
|
3
3
|
queue = [];
|
|
4
4
|
waiting = [];
|
|
@@ -58,7 +58,7 @@ var AssistantMessageEventStream = class extends EventStream {
|
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
//#endregion
|
|
61
|
-
//#region node_modules/@earendil-works/pi-ai/dist/api/lazy.js
|
|
61
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/api/lazy.js
|
|
62
62
|
function createSetupErrorMessage(model, error) {
|
|
63
63
|
return {
|
|
64
64
|
role: "assistant",
|
|
@@ -128,7 +128,7 @@ function lazyApi(load, capabilities) {
|
|
|
128
128
|
return api;
|
|
129
129
|
}
|
|
130
130
|
//#endregion
|
|
131
|
-
//#region node_modules/@earendil-works/pi-ai/dist/auth/context.js
|
|
131
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/auth/context.js
|
|
132
132
|
var __rewriteRelativeImportExtension = function(path, preserveJsx) {
|
|
133
133
|
if (typeof path === "string" && /^\.\.?\//.test(path)) return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {
|
|
134
134
|
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : d + ext + "." + cm.toLowerCase() + "js";
|
|
@@ -163,7 +163,7 @@ function defaultProviderAuthContext() {
|
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
165
|
//#endregion
|
|
166
|
-
//#region node_modules/@earendil-works/pi-ai/dist/utils/abort.js
|
|
166
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/utils/abort.js
|
|
167
167
|
function abortReason(signal) {
|
|
168
168
|
if (signal.reason !== void 0) return signal.reason;
|
|
169
169
|
const error = /* @__PURE__ */ new Error("The operation was aborted");
|
|
@@ -208,7 +208,7 @@ function raceWithAbortSignal(operation, signal) {
|
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
//#endregion
|
|
211
|
-
//#region node_modules/@earendil-works/pi-ai/dist/auth/credential-store.js
|
|
211
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.js
|
|
212
212
|
/**
|
|
213
213
|
* Default in-memory credential store. Apps inject persistent stores.
|
|
214
214
|
* Keyed by `Provider.id`, one credential per provider; see `CredentialStore`.
|
|
@@ -260,7 +260,7 @@ var InMemoryCredentialStore = class {
|
|
|
260
260
|
}
|
|
261
261
|
};
|
|
262
262
|
//#endregion
|
|
263
|
-
//#region node_modules/@earendil-works/pi-ai/dist/utils/diagnostics.js
|
|
263
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/utils/diagnostics.js
|
|
264
264
|
function formatThrownValue(value) {
|
|
265
265
|
if (value instanceof Error) return value.message || value.name;
|
|
266
266
|
if (typeof value === "string") return value;
|
|
@@ -291,7 +291,7 @@ function appendAssistantMessageDiagnostic(message, diagnostic) {
|
|
|
291
291
|
message.diagnostics = [...message.diagnostics ?? [], diagnostic];
|
|
292
292
|
}
|
|
293
293
|
//#endregion
|
|
294
|
-
//#region node_modules/@earendil-works/pi-ai/dist/auth/resolve.js
|
|
294
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js
|
|
295
295
|
var ModelsError = class extends Error {
|
|
296
296
|
code;
|
|
297
297
|
constructor(code, message, options) {
|
|
@@ -408,7 +408,7 @@ async function readCredential(credentials, providerId, signal) {
|
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
//#endregion
|
|
411
|
-
//#region node_modules/@earendil-works/pi-ai/dist/models-store.js
|
|
411
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/models-store.js
|
|
412
412
|
var InMemoryModelsStore = class {
|
|
413
413
|
entries = /* @__PURE__ */ new Map();
|
|
414
414
|
async read(providerId, options) {
|
|
@@ -426,7 +426,7 @@ var InMemoryModelsStore = class {
|
|
|
426
426
|
}
|
|
427
427
|
};
|
|
428
428
|
//#endregion
|
|
429
|
-
//#region node_modules/@earendil-works/pi-ai/dist/models.js
|
|
429
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/models.js
|
|
430
430
|
function mergeHeaders(base, override) {
|
|
431
431
|
if (!base && !override) return void 0;
|
|
432
432
|
const merged = { ...base };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as __commonJSMin, t as getProviderEnvValue } from "./provider-env-
|
|
2
|
-
import { a as appendAssistantMessageDiagnostic, l as AssistantMessageEventStream, n as clampThinkingLevel, o as createAssistantMessageDiagnostic, s as formatThrownValue, t as calculateCost } from "./models-
|
|
3
|
-
//#region node_modules/@earendil-works/pi-ai/dist/session-resources.js
|
|
1
|
+
import { n as __commonJSMin, t as getProviderEnvValue } from "./provider-env-BoYS8tP5.js";
|
|
2
|
+
import { a as appendAssistantMessageDiagnostic, l as AssistantMessageEventStream, n as clampThinkingLevel, o as createAssistantMessageDiagnostic, s as formatThrownValue, t as calculateCost } from "./models-BdCc9Ab5.js";
|
|
3
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/session-resources.js
|
|
4
4
|
const sessionResourceCleanups = /* @__PURE__ */ new Set();
|
|
5
5
|
function registerSessionResourceCleanup(cleanup) {
|
|
6
6
|
sessionResourceCleanups.add(cleanup);
|
|
@@ -9,7 +9,7 @@ function registerSessionResourceCleanup(cleanup) {
|
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
12
|
-
//#region node_modules/partial-json/dist/options.js
|
|
12
|
+
//#region node_modules/.pnpm/partial-json@0.1.7/node_modules/partial-json/dist/options.js
|
|
13
13
|
var require_options = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
14
14
|
/**
|
|
15
15
|
* Sometimes you don't allow every type to be partially parsed.
|
|
@@ -99,7 +99,7 @@ var require_options = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
99
99
|
exports.default = exports.Allow;
|
|
100
100
|
}));
|
|
101
101
|
//#endregion
|
|
102
|
-
//#region node_modules/@earendil-works/pi-ai/dist/utils/json-parse.js
|
|
102
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.js
|
|
103
103
|
var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
104
104
|
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
105
105
|
if (k2 === void 0) k2 = k;
|
|
@@ -388,7 +388,7 @@ function parseStreamingJson(partialJson) {
|
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
//#endregion
|
|
391
|
-
//#region node_modules/@earendil-works/pi-ai/dist/utils/uuid.js
|
|
391
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/utils/uuid.js
|
|
392
392
|
const MAX_UUID_V7_TIMESTAMP = 0xffffffffffff;
|
|
393
393
|
const MAX_SEQUENCE = (1n << 41n) - 1n;
|
|
394
394
|
let lastOrdinaryTimestamp = -1;
|
|
@@ -418,7 +418,7 @@ function uuidv7(timestampMs) {
|
|
|
418
418
|
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
419
419
|
}
|
|
420
420
|
//#endregion
|
|
421
|
-
//#region node_modules/@earendil-works/pi-ai/dist/utils/abort-signals.js
|
|
421
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/utils/abort-signals.js
|
|
422
422
|
function combineAbortSignals(signals) {
|
|
423
423
|
const activeSignals = signals.filter((signal) => signal !== void 0);
|
|
424
424
|
if (activeSignals.length === 0) return { cleanup: () => {} };
|
|
@@ -451,7 +451,7 @@ function combineAbortSignals(signals) {
|
|
|
451
451
|
};
|
|
452
452
|
}
|
|
453
453
|
//#endregion
|
|
454
|
-
//#region node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js
|
|
454
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js
|
|
455
455
|
const identityToolName = (name) => name;
|
|
456
456
|
/** Split current tools into prefix and transcript-loaded definitions. */
|
|
457
457
|
function splitDeferredTools(context, enabled, normalizeName = identityToolName) {
|
|
@@ -479,7 +479,7 @@ function splitDeferredTools(context, enabled, normalizeName = identityToolName)
|
|
|
479
479
|
};
|
|
480
480
|
}
|
|
481
481
|
//#endregion
|
|
482
|
-
//#region node_modules/@earendil-works/pi-ai/dist/utils/error-body.js
|
|
482
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js
|
|
483
483
|
const MAX_PROVIDER_ERROR_BODY_CHARS = 4e3;
|
|
484
484
|
function normalizeProviderError(error) {
|
|
485
485
|
if (!(error instanceof Error)) return {
|
|
@@ -579,14 +579,14 @@ function safeJsonStringify$1(value) {
|
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
581
|
//#endregion
|
|
582
|
-
//#region node_modules/@earendil-works/pi-ai/dist/utils/headers.js
|
|
582
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/utils/headers.js
|
|
583
583
|
function headersToRecord(headers) {
|
|
584
584
|
const result = {};
|
|
585
585
|
for (const [key, value] of headers.entries()) result[key] = value;
|
|
586
586
|
return result;
|
|
587
587
|
}
|
|
588
588
|
//#endregion
|
|
589
|
-
//#region node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js
|
|
589
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js
|
|
590
590
|
const DEFAULT_PROXY_PORTS = {
|
|
591
591
|
ftp: 21,
|
|
592
592
|
gopher: 70,
|
|
@@ -691,7 +691,7 @@ function resolveHttpProxyUrlForTarget(targetUrl, env) {
|
|
|
691
691
|
return proxyUrl;
|
|
692
692
|
}
|
|
693
693
|
//#endregion
|
|
694
|
-
//#region node_modules/@earendil-works/pi-ai/dist/utils/pi-user-agent.js
|
|
694
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/utils/pi-user-agent.js
|
|
695
695
|
function loadNodeOs() {
|
|
696
696
|
if (typeof process === "undefined" || !(process.versions?.node || process.versions?.bun)) return null;
|
|
697
697
|
return process.getBuiltinModule?.("node:os") ?? null;
|
|
@@ -701,7 +701,7 @@ function getPiUserAgent() {
|
|
|
701
701
|
return nodeOs ? `pi (${nodeOs.platform()} ${nodeOs.release()}; ${nodeOs.arch()})` : "pi (browser)";
|
|
702
702
|
}
|
|
703
703
|
//#endregion
|
|
704
|
-
//#region node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js
|
|
704
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js
|
|
705
705
|
var UnsupportedStrictJsonSchemaError = class extends Error {};
|
|
706
706
|
const UNSUPPORTED_STRICT_SCHEMA_KEYS = [
|
|
707
707
|
"$ref",
|
|
@@ -860,7 +860,7 @@ function clampOpenAIPromptCacheKey(key) {
|
|
|
860
860
|
return chars.slice(0, 64).join("");
|
|
861
861
|
}
|
|
862
862
|
//#endregion
|
|
863
|
-
//#region node_modules/@earendil-works/pi-ai/dist/utils/hash.js
|
|
863
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/utils/hash.js
|
|
864
864
|
/** Fast deterministic hash to shorten long strings */
|
|
865
865
|
function shortHash(str) {
|
|
866
866
|
let h1 = 3735928559;
|
|
@@ -875,7 +875,7 @@ function shortHash(str) {
|
|
|
875
875
|
return (h2 >>> 0).toString(36) + (h1 >>> 0).toString(36);
|
|
876
876
|
}
|
|
877
877
|
//#endregion
|
|
878
|
-
//#region node_modules/@earendil-works/pi-ai/dist/utils/sanitize-unicode.js
|
|
878
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/utils/sanitize-unicode.js
|
|
879
879
|
/**
|
|
880
880
|
* Removes unpaired Unicode surrogate characters from a string.
|
|
881
881
|
*
|
|
@@ -900,7 +900,7 @@ function sanitizeSurrogates(text) {
|
|
|
900
900
|
return text.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "");
|
|
901
901
|
}
|
|
902
902
|
//#endregion
|
|
903
|
-
//#region node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js
|
|
903
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js
|
|
904
904
|
const NON_VISION_USER_IMAGE_PLACEHOLDER = "(image omitted: model does not support images)";
|
|
905
905
|
const NON_VISION_TOOL_IMAGE_PLACEHOLDER = "(tool image omitted: model does not support images)";
|
|
906
906
|
function replaceImagesWithPlaceholder(content, placeholder) {
|
|
@@ -1047,7 +1047,7 @@ function transformMessages(messages, model, normalizeToolCallId) {
|
|
|
1047
1047
|
return result;
|
|
1048
1048
|
}
|
|
1049
1049
|
//#endregion
|
|
1050
|
-
//#region node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js
|
|
1050
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js
|
|
1051
1051
|
function encodeTextSignatureV1(id, phase) {
|
|
1052
1052
|
const payload = {
|
|
1053
1053
|
v: 1,
|
|
@@ -1624,7 +1624,7 @@ function mapStopReason(status, incompleteReason) {
|
|
|
1624
1624
|
}
|
|
1625
1625
|
}
|
|
1626
1626
|
//#endregion
|
|
1627
|
-
//#region node_modules/@earendil-works/pi-ai/dist/utils/estimate.js
|
|
1627
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/utils/estimate.js
|
|
1628
1628
|
const CHARS_PER_TOKEN = 4;
|
|
1629
1629
|
const ESTIMATED_IMAGE_CHARS = 4800;
|
|
1630
1630
|
function calculateContextTokens(usage) {
|
|
@@ -1725,7 +1725,7 @@ function estimateContextTokens(context) {
|
|
|
1725
1725
|
};
|
|
1726
1726
|
}
|
|
1727
1727
|
//#endregion
|
|
1728
|
-
//#region node_modules/@earendil-works/pi-ai/dist/api/simple-options.js
|
|
1728
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js
|
|
1729
1729
|
const CONTEXT_SAFETY_TOKENS = 4096;
|
|
1730
1730
|
const MIN_MAX_TOKENS = 1;
|
|
1731
1731
|
function clampMaxTokensToContext(model, context, maxTokens) {
|
|
@@ -1761,7 +1761,7 @@ function buildBaseOptions(model, context, options, apiKey) {
|
|
|
1761
1761
|
};
|
|
1762
1762
|
}
|
|
1763
1763
|
//#endregion
|
|
1764
|
-
//#region node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js
|
|
1764
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js
|
|
1765
1765
|
const DEFAULT_CODEX_BASE_URL = "https://chatgpt.com/backend-api";
|
|
1766
1766
|
const JWT_CLAIM_PATH = "https://api.openai.com/auth";
|
|
1767
1767
|
const DEFAULT_MAX_RETRIES = 0;
|
package/lib/openai-codex.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as getProviderEnvValue } from "./provider-env-
|
|
2
|
-
//#region node_modules/@earendil-works/pi-ai/dist/auth/oauth/device-code.js
|
|
1
|
+
import { t as getProviderEnvValue } from "./provider-env-BoYS8tP5.js";
|
|
2
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/auth/oauth/device-code.js
|
|
3
3
|
const CANCEL_MESSAGE = "Login cancelled";
|
|
4
4
|
const TIMEOUT_MESSAGE = "Device flow timed out";
|
|
5
5
|
const SLOW_DOWN_TIMEOUT_MESSAGE = "Device flow timed out after one or more slow_down responses. This is often caused by clock drift in WSL or VM environments. Please sync or restart the VM clock and try again.";
|
|
@@ -47,7 +47,7 @@ async function pollOAuthDeviceCodeFlow(options) {
|
|
|
47
47
|
throw new Error(slowDownResponses > 0 ? SLOW_DOWN_TIMEOUT_MESSAGE : TIMEOUT_MESSAGE);
|
|
48
48
|
}
|
|
49
49
|
//#endregion
|
|
50
|
-
//#region node_modules/@earendil-works/pi-ai/dist/auth/oauth/oauth-page.js
|
|
50
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/auth/oauth/oauth-page.js
|
|
51
51
|
const LOGO_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 800" aria-hidden="true"><path fill="#fff" fill-rule="evenodd" d="M165.29 165.29 H517.36 V400 H400 V517.36 H282.65 V634.72 H165.29 Z M282.65 282.65 V400 H400 V282.65 Z"/><path fill="#fff" d="M517.36 400 H634.72 V634.72 H517.36 Z"/></svg>`;
|
|
52
52
|
function escapeHtml(value) {
|
|
53
53
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
@@ -148,7 +148,7 @@ function oauthErrorHtml(message, details) {
|
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
//#endregion
|
|
151
|
-
//#region node_modules/@earendil-works/pi-ai/dist/auth/oauth/pkce.js
|
|
151
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/auth/oauth/pkce.js
|
|
152
152
|
/**
|
|
153
153
|
* PKCE utilities using Web Crypto API.
|
|
154
154
|
* Works in both Node.js 20+ and browsers.
|
|
@@ -177,7 +177,7 @@ async function generatePKCE() {
|
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
//#endregion
|
|
180
|
-
//#region node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js
|
|
180
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js
|
|
181
181
|
/**
|
|
182
182
|
* OpenAI Codex (ChatGPT OAuth) flow
|
|
183
183
|
*
|
|
@@ -3,7 +3,7 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
4
4
|
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
5
5
|
//#endregion
|
|
6
|
-
//#region node_modules/@earendil-works/pi-ai/dist/utils/provider-env.js
|
|
6
|
+
//#region node_modules/.pnpm/@earendil-works+pi-ai@0.85.1_ws@8.21.3_zod@4.6.4/node_modules/@earendil-works/pi-ai/dist/utils/provider-env.js
|
|
7
7
|
let procEnvCache = null;
|
|
8
8
|
/**
|
|
9
9
|
* Fallback for https://github.com/oven-sh/bun/issues/27802.
|