@nervekit/desktop 0.40.1 → 0.40.2
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/THIRD-PARTY-LICENSES.txt +7 -29
- package/dist/{chunk-KSZJ3HGD.js → chunk-2BKMOJYJ.js} +1 -1
- package/dist/{chunk-4MMJDHFX.js → chunk-3JJN36GV.js} +70 -71
- package/dist/{chunk-2Z5FLMLE.js → chunk-3SSNDIQT.js} +1 -1
- package/dist/{chunk-CKVFGRVV.js → chunk-3VZR3ZUY.js} +54 -7
- package/dist/{chunk-BXVRC3HF.js → chunk-4H3WR7IT.js} +1 -1
- package/dist/{chunk-QVHYARC2.js → chunk-4VPX67B7.js} +3 -1
- package/dist/chunk-5NN7JAJ2.js +258 -0
- package/dist/{chunk-AJGPULMX.js → chunk-6FSDDGFZ.js} +815 -3108
- package/dist/chunk-6PACEIUY.js +183 -0
- package/dist/{chunk-XNYZEQ3U.js → chunk-6TAN6WG6.js} +1 -1
- package/dist/{chunk-55OGZFNA.js → chunk-7FLZA2BD.js} +31 -15
- package/dist/{chunk-XBHEYY65.js → chunk-7JQBECUL.js} +1 -1
- package/dist/{chunk-5Y3NEEOK.js → chunk-AAEIGAGD.js} +9 -9
- package/dist/{chunk-H5UKINTD.js → chunk-ANI6J75M.js} +68 -65
- package/dist/chunk-B4IE2GAM.js +14 -0
- package/dist/chunk-BNVMNV4O.js +69 -0
- package/dist/{chunk-L3YB2QLN.js → chunk-C6RO4LP3.js} +2 -2
- package/dist/chunk-DTGL5P2V.js +250 -0
- package/dist/{chunk-QWTKCUIZ.js → chunk-E4JNHQGT.js} +11 -9
- package/dist/chunk-ER2ES2RH.js +64 -0
- package/dist/{chunk-SQ7CWNIT.js → chunk-EX63VKXY.js} +1 -1
- package/dist/{chunk-KQPEOUCA.js → chunk-F3MHINI6.js} +19 -23
- package/dist/{chunk-KAZFF2RD.js → chunk-FGZX4Q7W.js} +137 -113
- package/dist/{chunk-I6NVW4NX.js → chunk-FZ5N6WXF.js} +29 -33
- package/dist/chunk-H2G55ZPG.js +783 -0
- package/dist/chunk-HDBDYGJQ.js +40 -0
- package/dist/{chunk-TJR6ASRW.js → chunk-HOCODVKL.js} +22 -24
- package/dist/chunk-K2J2VZXO.js +142 -0
- package/dist/{chunk-MH3SUHI2.js → chunk-KBNEZR7T.js} +2 -2
- package/dist/chunk-KSSM6LUI.js +340 -0
- package/dist/{chunk-QFXKQNMT.js → chunk-KTGSBL6T.js} +14 -17
- package/dist/chunk-L2DHKP5C.js +42 -0
- package/dist/{chunk-DBXMYYPJ.js → chunk-M3ELKCNA.js} +1 -1
- package/dist/{chunk-KIGB3FK6.js → chunk-MWIKZIAI.js} +9 -8
- package/dist/{chunk-AON37AL2.js → chunk-O2652RWY.js} +29 -4
- package/dist/chunk-O6U226AI.js +249 -0
- package/dist/{chunk-N5B2RRSS.js → chunk-OAEV22IW.js} +47 -26
- package/dist/chunk-OANTMDXI.js +29 -0
- package/dist/{chunk-UGDIHDAR.js → chunk-ODS5QROC.js} +1 -1
- package/dist/{chunk-TW6FURZ7.js → chunk-PST63OUS.js} +5 -5
- package/dist/{chunk-S2PITDVA.js → chunk-QBAIDKF6.js} +1 -1
- package/dist/chunk-RPLBWENJ.js +224 -0
- package/dist/{chunk-CWHAK2HX.js → chunk-S62LLS4I.js} +33 -55
- package/dist/chunk-SHEU5KLD.js +32 -0
- package/dist/{chunk-FESN7DND.js → chunk-SU2USXTD.js} +1 -1
- package/dist/chunk-T6NRMNLQ.js +22 -0
- package/dist/{chunk-WXRYBXYR.js → chunk-TGKIV3F4.js} +53 -65
- package/dist/{chunk-MN7PZ2PH.js → chunk-TSV3PFU2.js} +2 -2
- package/dist/{chunk-24GQ74HM.js → chunk-UDC7NPQJ.js} +3 -3
- package/dist/{chunk-CEX2GWGZ.js → chunk-VBM7TD3X.js} +1 -1
- package/dist/chunk-VC6TX2Y2.js +359 -0
- package/dist/{chunk-V53CETNZ.js → chunk-VTDI5KP7.js} +241 -104
- package/dist/{chunk-ONWQH2W6.js → chunk-WIN7KHMV.js} +15 -18
- package/dist/chunk-WJULIJOU.js +168 -0
- package/dist/{chunk-HKLAYK2Z.js → chunk-WRTA5G57.js} +23 -0
- package/dist/{chunk-FOFVPPPV.js → chunk-WYPVD3HW.js} +10 -9
- package/dist/{chunk-D7WIIZAV.js → chunk-XE2E2KBP.js} +10 -9
- package/dist/chunk-XY53EFK3.js +39 -0
- package/dist/chunk-XZYFB566.js +153 -0
- package/dist/{chunk-OY6PIAR7.js → chunk-YJT4NXMV.js} +5 -5
- package/dist/{chunk-3DGBM7UW.js → chunk-YQFENES6.js} +3 -3
- package/dist/chunk-YUO5V75X.js +128 -0
- package/dist/daemon.js +15 -10
- package/dist/git-isolated-reader-helper.js +1 -1
- package/dist/main.js +14 -9
- package/dist/web/assets/{AsyncBashCenterHost-HGsdxUJ3.js → AsyncBashCenterHost-BvXKoCVr.js} +1 -1
- package/dist/web/assets/{ConversationsWorkbenchPanel-B6dzWkG1.js → ConversationsWorkbenchPanel-CIfK_e3I.js} +1 -1
- package/dist/web/assets/{DiscoverCenterHost-B186WBRA.js → DiscoverCenterHost-Ep8EN9iJ.js} +1 -1
- package/dist/web/assets/{FileCenterHost-DigJOU5M.js → FileCenterHost-C_7XZAFZ.js} +1 -1
- package/dist/web/assets/{FilesWorkbenchPanel-VPvx3Bmi.js → FilesWorkbenchPanel-CtXo7ywG.js} +1 -1
- package/dist/web/assets/{GitDiffCenterHost-IuZfF3hG.js → GitDiffCenterHost-Cr7lqGI_.js} +1 -1
- package/dist/web/assets/{GitWorkbenchPanel-CScC0CfH.js → GitWorkbenchPanel-BFbwUgIN.js} +1 -1
- package/dist/web/assets/{LaunchConfigurationNotice-5yb4cH27.js → LaunchConfigurationNotice-CJjWkMhv.js} +1 -1
- package/dist/web/assets/{LaunchesWorkbenchPanel-Vy0Gm7gg.js → LaunchesWorkbenchPanel-BqzJvsrj.js} +1 -1
- package/dist/web/assets/{LogsCenterHost-BXBozCYw.js → LogsCenterHost-BI1fSxFW.js} +1 -1
- package/dist/web/assets/{MermaidCenterHost-DDh4ArdK.js → MermaidCenterHost-DVsZB8nB.js} +1 -1
- package/dist/web/assets/{MobileFilesBody-Cda_7gDp.js → MobileFilesBody-BJMoaP9I.js} +1 -1
- package/dist/web/assets/{MobileFilesHost-C1jev2Un.js → MobileFilesHost-D843vkDF.js} +1 -1
- package/dist/web/assets/{MobileLaunchOutputHost-Bsv12o2H.js → MobileLaunchOutputHost-vpltMcar.js} +1 -1
- package/dist/web/assets/{MobileLaunchesHost-C9VH-2bn.js → MobileLaunchesHost-CdDrKASg.js} +1 -1
- package/dist/web/assets/{MobileLogsHost-BMDXc-WC.js → MobileLogsHost-qK7N-C1y.js} +1 -1
- package/dist/web/assets/{MobileNoteEditorHost-BA6WIY1Y.js → MobileNoteEditorHost-Bg1N8o54.js} +1 -1
- package/dist/web/assets/{MobileNotesHost-BZeYpK9H.js → MobileNotesHost-meLV39Yw.js} +1 -1
- package/dist/web/assets/{MobileProjectSettingsHost-U3Mx3EN8.js → MobileProjectSettingsHost-A49Fdn54.js} +1 -1
- package/dist/web/assets/{MobileProjectSettingsPageHost-CMvxbjfs.js → MobileProjectSettingsPageHost-BXpUqS_N.js} +1 -1
- package/dist/web/assets/{MobileSettingsHost-CP8Z_-gH.js → MobileSettingsHost-DPKPajzI.js} +1 -1
- package/dist/web/assets/{MobileSettingsPageHost-BPjXKTMV.js → MobileSettingsPageHost-izNWGN0i.js} +1 -1
- package/dist/web/assets/{MobileSettingsPageScreen-C5rHdrUU.js → MobileSettingsPageScreen-DWMg4fDo.js} +1 -1
- package/dist/web/assets/{ProjectSettingsCenterHost-BVXpBixy.js → ProjectSettingsCenterHost-DHeb274m.js} +1 -1
- package/dist/web/assets/{PullRequestCenterHost-CZhXfCX2.js → PullRequestCenterHost-BYkWxXQe.js} +1 -1
- package/dist/web/assets/{PullRequestsWorkbenchPanel-BBnZJVnI.js → PullRequestsWorkbenchPanel-ZvGbi1Cr.js} +1 -1
- package/dist/web/assets/{SearchWorkbenchPanel-qLgszneN.js → SearchWorkbenchPanel-DaC0smfe.js} +1 -1
- package/dist/web/assets/{SettingsCenter-7BfrBfiy.js → SettingsCenter-C_NLBsi6.js} +1 -1
- package/dist/web/assets/{SettingsCenterHost-Ck5uHILP.js → SettingsCenterHost-jP8MULEj.js} +1 -1
- package/dist/web/assets/{SystemPromptCenterHost-ya5AvXsd.js → SystemPromptCenterHost-B1hfsfAn.js} +1 -1
- package/dist/web/assets/{discover-B3I5g1_G.js → discover-B-aZ504j.js} +1 -1
- package/dist/web/assets/{index-FJEmK_L5.js → index-TZ1KAAsX.js} +34 -34
- package/dist/web/assets/{settings-page-controllers.svelte-CU0i08wo.js → settings-page-controllers.svelte-D_ydJF8u.js} +1 -1
- package/dist/web/assets/{shell-layout.svelte-BT2508sa.js → shell-layout.svelte-OoLFwzzJ.js} +2 -2
- package/dist/web/assets/{views-Z-n-GTYY.js → views-ByPCKDiZ.js} +1 -1
- package/dist/web/index.html +3 -3
- package/dist/web/sw.js +1 -1
- package/dist/worker.js +14 -9
- package/package.json +8 -9
- package/dist/chunk-RUZ2UAYH.js +0 -365
- package/dist/resize-worker.js +0 -168
- /package/dist/{chunk-CKVFGRVV.js.LEGAL.txt → chunk-3VZR3ZUY.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-TW6FURZ7.js.LEGAL.txt → chunk-PST63OUS.js.LEGAL.txt} +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
|
+
const require = __nerveCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.1_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_e7d72008f907c45a36788e380ed24019/node_modules/@earendil-works/pi-ai/dist/utils/openrouter-cost.js
|
|
5
|
+
function isValidCost(value) {
|
|
6
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
7
|
+
}
|
|
8
|
+
function isOpenRouterModel(model) {
|
|
9
|
+
return model.provider === "openrouter" || model.baseUrl.includes("openrouter.ai");
|
|
10
|
+
}
|
|
11
|
+
function applyOpenRouterReportedCost(usage, reported) {
|
|
12
|
+
if (!isValidCost(reported.cost))
|
|
13
|
+
return;
|
|
14
|
+
if (reported.is_byok === false) {
|
|
15
|
+
usage.cost.total = reported.cost;
|
|
16
|
+
usage.cost.totalFromProvider = true;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (reported.is_byok === true) {
|
|
20
|
+
const details = reported.cost_details;
|
|
21
|
+
if (!details)
|
|
22
|
+
return;
|
|
23
|
+
let upstreamCost = details.upstream_inference_cost;
|
|
24
|
+
if (upstreamCost === null) {
|
|
25
|
+
if (!isValidCost(details.upstream_inference_prompt_cost) || !isValidCost(details.upstream_inference_completions_cost)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
upstreamCost = details.upstream_inference_prompt_cost + details.upstream_inference_completions_cost;
|
|
29
|
+
}
|
|
30
|
+
if (!isValidCost(upstreamCost))
|
|
31
|
+
return;
|
|
32
|
+
usage.cost.total = reported.cost + upstreamCost;
|
|
33
|
+
usage.cost.totalFromProvider = true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
isOpenRouterModel,
|
|
39
|
+
applyOpenRouterReportedCost
|
|
40
|
+
};
|
|
@@ -5,53 +5,54 @@ import {
|
|
|
5
5
|
convertResponsesTools,
|
|
6
6
|
getResponsesToolSupport,
|
|
7
7
|
processResponsesStream
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ANI6J75M.js";
|
|
9
9
|
import {
|
|
10
10
|
buildCopilotDynamicHeaders,
|
|
11
11
|
hasCopilotVisionInput
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-QBAIDKF6.js";
|
|
13
13
|
import {
|
|
14
14
|
clampOpenAIPromptCacheKey
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-KSZJ3HGD.js";
|
|
15
|
+
} from "./chunk-ODS5QROC.js";
|
|
17
16
|
import {
|
|
18
17
|
OpenAI
|
|
19
18
|
} from "./chunk-NW3DH7IK.js";
|
|
20
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-2BKMOJYJ.js";
|
|
21
20
|
import {
|
|
22
21
|
buildBaseOptions,
|
|
23
22
|
createGrammarToolInputProperties,
|
|
24
23
|
resolveSamplingParams
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-OAEV22IW.js";
|
|
25
|
+
import "./chunk-3SSNDIQT.js";
|
|
26
|
+
import {
|
|
27
|
+
retryProviderRequest
|
|
28
|
+
} from "./chunk-EX63VKXY.js";
|
|
27
29
|
import {
|
|
28
30
|
formatProviderError,
|
|
29
31
|
normalizeProviderError
|
|
30
|
-
} from "./chunk-
|
|
31
|
-
import {
|
|
32
|
-
retryProviderRequest
|
|
33
|
-
} from "./chunk-SQ7CWNIT.js";
|
|
32
|
+
} from "./chunk-O2652RWY.js";
|
|
34
33
|
import {
|
|
35
34
|
headersToRecord
|
|
36
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-VBM7TD3X.js";
|
|
37
36
|
import {
|
|
38
37
|
getProviderEnvValue
|
|
39
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-SU2USXTD.js";
|
|
39
|
+
import "./chunk-H2G55ZPG.js";
|
|
40
40
|
import {
|
|
41
41
|
clampThinkingLevel,
|
|
42
42
|
getDeclaredTools,
|
|
43
43
|
resolveTranscript,
|
|
44
44
|
resolveTranscriptTools
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-TGKIV3F4.js";
|
|
46
46
|
import {
|
|
47
47
|
AssistantMessageEventStream
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-TSV3PFU2.js";
|
|
49
49
|
import {
|
|
50
50
|
getIdentityHeaders
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-UDC7NPQJ.js";
|
|
52
|
+
import "./chunk-XY53EFK3.js";
|
|
52
53
|
import "./chunk-CWESUMYQ.js";
|
|
53
54
|
|
|
54
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
55
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.1_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_e7d72008f907c45a36788e380ed24019/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js
|
|
55
56
|
var OPENAI_TOOL_CALL_PROVIDERS = /* @__PURE__ */ new Set(["openai", "openai-codex", "opencode"]);
|
|
56
57
|
var OPENAI_RESPONSES_MIN_OUTPUT_TOKENS = 16;
|
|
57
58
|
var CHATGPT_USAGE_URL = "https://chatgpt.com/settings/usage";
|
|
@@ -94,6 +95,7 @@ function getCompat(model) {
|
|
|
94
95
|
supportsDeveloperRole: model.compat?.supportsDeveloperRole ?? true,
|
|
95
96
|
supportsMidConvoSystemMessages: model.compat?.supportsMidConvoSystemMessages ?? false,
|
|
96
97
|
sessionAffinityFormat: model.compat?.sessionAffinityFormat ?? detectSessionAffinityFormat(model),
|
|
98
|
+
promptCacheKeyMode: model.compat?.promptCacheKeyMode ?? "auto",
|
|
97
99
|
supportsLongCacheRetention: model.compat?.supportsLongCacheRetention ?? true,
|
|
98
100
|
supportsStrictMode: model.compat?.supportsStrictMode ?? false,
|
|
99
101
|
supportsOpenAIGrammarTools: model.compat?.supportsOpenAIGrammarTools ?? false,
|
|
@@ -188,11 +190,6 @@ var stream = (model, context, options) => {
|
|
|
188
190
|
stream2.push({ type: "done", reason: output.stopReason, message: output });
|
|
189
191
|
stream2.end();
|
|
190
192
|
} catch (error) {
|
|
191
|
-
for (const block of output.content) {
|
|
192
|
-
delete block.index;
|
|
193
|
-
delete block.partialJson;
|
|
194
|
-
delete block.customInput;
|
|
195
|
-
}
|
|
196
193
|
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
197
194
|
const errorMessage = formatProviderError(normalizeProviderError(error), `${model.provider === "openai" ? "OpenAI" : model.provider} API error`);
|
|
198
195
|
if (errorMessage.includes("subscription_sharing_usage_limit_exceeded")) {
|
|
@@ -239,7 +236,7 @@ function createClient(model, context, apiKey, optionsHeaders, identity, fetch, s
|
|
|
239
236
|
headers["x-session-id"] = sessionId;
|
|
240
237
|
} else {
|
|
241
238
|
if (compat.sessionAffinityFormat === "openai") {
|
|
242
|
-
headers
|
|
239
|
+
headers["session-id"] = sessionId;
|
|
243
240
|
}
|
|
244
241
|
headers["x-client-request-id"] = sessionId;
|
|
245
242
|
}
|
|
@@ -269,12 +266,13 @@ function buildParams(model, context, options, compat, grammarToolInputProperties
|
|
|
269
266
|
configurationUpdateEffort
|
|
270
267
|
});
|
|
271
268
|
const cacheRetention = resolveCacheRetention(options?.cacheRetention, options?.env);
|
|
269
|
+
const sendPromptCacheKey = cacheRetention !== "none" && compat.promptCacheKeyMode !== "disabled";
|
|
272
270
|
const omitUnsupportedFields = isChatGPTSignIn(model, options?.apiKey);
|
|
273
271
|
const params = {
|
|
274
272
|
model: model.id,
|
|
275
273
|
input: messages,
|
|
276
274
|
stream: true,
|
|
277
|
-
prompt_cache_key:
|
|
275
|
+
prompt_cache_key: sendPromptCacheKey ? clampOpenAIPromptCacheKey(options?.sessionId) : void 0,
|
|
278
276
|
prompt_cache_retention: omitUnsupportedFields ? void 0 : getPromptCacheRetention(compat, cacheRetention),
|
|
279
277
|
prompt_cache_options: omitUnsupportedFields ? void 0 : getPromptCacheOptions(compat, cacheRetention),
|
|
280
278
|
store: false
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
|
+
const require = __nerveCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
oauthErrorHtml,
|
|
5
|
+
oauthSuccessHtml
|
|
6
|
+
} from "./chunk-YUO5V75X.js";
|
|
7
|
+
|
|
8
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.1_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_e7d72008f907c45a36788e380ed24019/node_modules/@earendil-works/pi-ai/dist/auth/oauth/callback-server.js
|
|
9
|
+
import { createServer } from "node:http";
|
|
10
|
+
function sendPage(response, status, html) {
|
|
11
|
+
response.writeHead(status, { "content-type": "text/html; charset=utf-8", "cache-control": "no-store" });
|
|
12
|
+
response.end(html);
|
|
13
|
+
}
|
|
14
|
+
async function startOAuthCallbackServer(options) {
|
|
15
|
+
const { providerName, signal } = options;
|
|
16
|
+
if (signal?.aborted)
|
|
17
|
+
throw new Error("Login cancelled");
|
|
18
|
+
let resolveWait = () => {
|
|
19
|
+
};
|
|
20
|
+
let rejectWait = () => {
|
|
21
|
+
};
|
|
22
|
+
const waitPromise = new Promise((resolve, reject) => {
|
|
23
|
+
resolveWait = resolve;
|
|
24
|
+
rejectWait = reject;
|
|
25
|
+
});
|
|
26
|
+
waitPromise.catch(() => void 0);
|
|
27
|
+
let claimed = false;
|
|
28
|
+
let settled = false;
|
|
29
|
+
let timer;
|
|
30
|
+
const onAbort = () => finish({ error: new Error("Login cancelled") });
|
|
31
|
+
const finish = (result) => {
|
|
32
|
+
if (settled)
|
|
33
|
+
return;
|
|
34
|
+
settled = true;
|
|
35
|
+
if (timer)
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
signal?.removeEventListener("abort", onAbort);
|
|
38
|
+
if ("error" in result)
|
|
39
|
+
rejectWait(result.error);
|
|
40
|
+
else
|
|
41
|
+
resolveWait(result.value);
|
|
42
|
+
};
|
|
43
|
+
const server = createServer((request, response) => {
|
|
44
|
+
void (async () => {
|
|
45
|
+
const url = new URL(request.url ?? "/", "http://localhost");
|
|
46
|
+
if (request.method !== "GET" || url.pathname !== options.path) {
|
|
47
|
+
sendPage(response, 404, oauthErrorHtml("Callback route not found."));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (options.state !== void 0 && url.searchParams.get("state") !== options.state) {
|
|
51
|
+
sendPage(response, 400, oauthErrorHtml("State mismatch."));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (claimed || settled) {
|
|
55
|
+
sendPage(response, 409, oauthErrorHtml("This sign-in has already been handled."));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const error = url.searchParams.get("error");
|
|
59
|
+
if (error) {
|
|
60
|
+
const description = url.searchParams.get("error_description") ?? error;
|
|
61
|
+
sendPage(response, 400, oauthErrorHtml(`${providerName} authorization failed.`, description));
|
|
62
|
+
finish({ error: new Error(`${providerName} authorization failed: ${description}`) });
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const code = url.searchParams.get("code");
|
|
66
|
+
if (!code) {
|
|
67
|
+
sendPage(response, 400, oauthErrorHtml("Missing authorization code."));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
claimed = true;
|
|
71
|
+
try {
|
|
72
|
+
const value = await options.complete(code);
|
|
73
|
+
sendPage(response, 200, oauthSuccessHtml(`Signed in to ${providerName}. You may now close this page.`));
|
|
74
|
+
finish({ value });
|
|
75
|
+
} catch (error2) {
|
|
76
|
+
const failure = error2 instanceof Error ? error2 : new Error(String(error2));
|
|
77
|
+
sendPage(response, 502, oauthErrorHtml(`${providerName} sign-in failed.`, failure.message));
|
|
78
|
+
finish({ error: failure });
|
|
79
|
+
}
|
|
80
|
+
})();
|
|
81
|
+
});
|
|
82
|
+
await new Promise((resolve, reject) => {
|
|
83
|
+
server.once("error", reject);
|
|
84
|
+
server.listen(options.port, options.host, () => {
|
|
85
|
+
server.off("error", reject);
|
|
86
|
+
resolve();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
const address = server.address();
|
|
90
|
+
if (!address || typeof address === "string") {
|
|
91
|
+
server.close();
|
|
92
|
+
throw new Error("OAuth callback server did not bind to TCP");
|
|
93
|
+
}
|
|
94
|
+
server.on("error", (error) => finish({ error }));
|
|
95
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
96
|
+
if (options.timeoutMs !== void 0) {
|
|
97
|
+
timer = setTimeout(() => finish({ error: new Error(`${providerName} sign-in timed out`) }), options.timeoutMs);
|
|
98
|
+
}
|
|
99
|
+
const redirectHost = options.redirectHost ?? options.host;
|
|
100
|
+
return {
|
|
101
|
+
redirectUri: `http://${redirectHost.includes(":") ? `[${redirectHost}]` : redirectHost}:${address.port}${options.path}`,
|
|
102
|
+
wait: () => waitPromise,
|
|
103
|
+
cancel: () => {
|
|
104
|
+
if (!claimed)
|
|
105
|
+
finish({ value: void 0 });
|
|
106
|
+
},
|
|
107
|
+
close: () => {
|
|
108
|
+
finish({ error: new Error("OAuth callback server closed") });
|
|
109
|
+
server.close();
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
async function waitForCallbackOrManualInput(interaction, callback, prompt) {
|
|
114
|
+
const manualAbort = new AbortController();
|
|
115
|
+
let manualError;
|
|
116
|
+
const manual = interaction.prompt({ type: "manual_code", ...prompt, signal: manualAbort.signal }).then((input) => {
|
|
117
|
+
callback?.cancel();
|
|
118
|
+
return input;
|
|
119
|
+
}).catch((error) => {
|
|
120
|
+
manualError = error instanceof Error ? error : new Error(String(error));
|
|
121
|
+
callback?.cancel();
|
|
122
|
+
return void 0;
|
|
123
|
+
});
|
|
124
|
+
try {
|
|
125
|
+
const value = await callback?.wait();
|
|
126
|
+
if (manualError)
|
|
127
|
+
throw manualError;
|
|
128
|
+
if (value !== void 0)
|
|
129
|
+
return { type: "callback", value };
|
|
130
|
+
const input = await manual;
|
|
131
|
+
if (manualError)
|
|
132
|
+
throw manualError;
|
|
133
|
+
return { type: "manual", input: input ?? "" };
|
|
134
|
+
} finally {
|
|
135
|
+
manualAbort.abort();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export {
|
|
140
|
+
startOAuthCallbackServer,
|
|
141
|
+
waitForCallbackOrManualInput
|
|
142
|
+
};
|
|
@@ -2,9 +2,9 @@ import { createRequire as __nerveCreateRequire } from "node:module";
|
|
|
2
2
|
const require = __nerveCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
getProviderEnvValue
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-SU2USXTD.js";
|
|
6
6
|
|
|
7
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
7
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.1_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_e7d72008f907c45a36788e380ed24019/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js
|
|
8
8
|
var DEFAULT_PROXY_PORTS = {
|
|
9
9
|
ftp: 21,
|
|
10
10
|
gopher: 70,
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
|
+
const require = __nerveCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
pollOAuthDeviceCodeFlow
|
|
5
|
+
} from "./chunk-ER2ES2RH.js";
|
|
6
|
+
import {
|
|
7
|
+
startOAuthCallbackServer,
|
|
8
|
+
waitForCallbackOrManualInput
|
|
9
|
+
} from "./chunk-K2J2VZXO.js";
|
|
10
|
+
import {
|
|
11
|
+
generatePKCE
|
|
12
|
+
} from "./chunk-YUO5V75X.js";
|
|
13
|
+
import {
|
|
14
|
+
getProviderEnvValue
|
|
15
|
+
} from "./chunk-SU2USXTD.js";
|
|
16
|
+
import "./chunk-CWESUMYQ.js";
|
|
17
|
+
|
|
18
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.1_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_e7d72008f907c45a36788e380ed24019/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js
|
|
19
|
+
var _randomBytes = null;
|
|
20
|
+
if (typeof process !== "undefined" && (process.versions?.node || process.versions?.bun)) {
|
|
21
|
+
import("node:crypto").then((m) => {
|
|
22
|
+
_randomBytes = m.randomBytes;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
var CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
26
|
+
var AUTH_BASE_URL = "https://auth.openai.com";
|
|
27
|
+
var AUTHORIZE_URL = `${AUTH_BASE_URL}/oauth/authorize`;
|
|
28
|
+
var TOKEN_URL = `${AUTH_BASE_URL}/oauth/token`;
|
|
29
|
+
var REDIRECT_URI = "http://localhost:1455/auth/callback";
|
|
30
|
+
var DEVICE_USER_CODE_URL = `${AUTH_BASE_URL}/api/accounts/deviceauth/usercode`;
|
|
31
|
+
var DEVICE_TOKEN_URL = `${AUTH_BASE_URL}/api/accounts/deviceauth/token`;
|
|
32
|
+
var DEVICE_VERIFICATION_URI = `${AUTH_BASE_URL}/codex/device`;
|
|
33
|
+
var DEVICE_REDIRECT_URI = `${AUTH_BASE_URL}/deviceauth/callback`;
|
|
34
|
+
var DEVICE_CODE_TIMEOUT_SECONDS = 15 * 60;
|
|
35
|
+
var OPENAI_CODEX_BROWSER_LOGIN_METHOD = "browser";
|
|
36
|
+
var OPENAI_CODEX_DEVICE_CODE_LOGIN_METHOD = "device_code";
|
|
37
|
+
var SCOPE = "openid profile email offline_access";
|
|
38
|
+
var JWT_CLAIM_PATH = "https://api.openai.com/auth";
|
|
39
|
+
function getCallbackHost() {
|
|
40
|
+
return getProviderEnvValue("PI_OAUTH_CALLBACK_HOST") || "127.0.0.1";
|
|
41
|
+
}
|
|
42
|
+
function createState() {
|
|
43
|
+
if (!_randomBytes) {
|
|
44
|
+
throw new Error("OpenAI Codex OAuth is only available in Node.js environments");
|
|
45
|
+
}
|
|
46
|
+
return _randomBytes(16).toString("hex");
|
|
47
|
+
}
|
|
48
|
+
function parseAuthorizationInput(input) {
|
|
49
|
+
const value = input.trim();
|
|
50
|
+
if (!value)
|
|
51
|
+
return {};
|
|
52
|
+
try {
|
|
53
|
+
const url = new URL(value);
|
|
54
|
+
return {
|
|
55
|
+
code: url.searchParams.get("code") ?? void 0,
|
|
56
|
+
state: url.searchParams.get("state") ?? void 0
|
|
57
|
+
};
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
if (value.includes("#")) {
|
|
61
|
+
const [code, state] = value.split("#", 2);
|
|
62
|
+
return { code, state };
|
|
63
|
+
}
|
|
64
|
+
if (value.includes("code=")) {
|
|
65
|
+
const params = new URLSearchParams(value);
|
|
66
|
+
return {
|
|
67
|
+
code: params.get("code") ?? void 0,
|
|
68
|
+
state: params.get("state") ?? void 0
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return { code: value };
|
|
72
|
+
}
|
|
73
|
+
function decodeJwt(token) {
|
|
74
|
+
try {
|
|
75
|
+
const parts = token.split(".");
|
|
76
|
+
if (parts.length !== 3)
|
|
77
|
+
return null;
|
|
78
|
+
const payload = parts[1] ?? "";
|
|
79
|
+
const decoded = atob(payload);
|
|
80
|
+
return JSON.parse(decoded);
|
|
81
|
+
} catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function fetchWithLoginCancellation(input, init) {
|
|
86
|
+
try {
|
|
87
|
+
return await fetch(input, init);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (init.signal?.aborted) {
|
|
90
|
+
throw new Error("Login cancelled");
|
|
91
|
+
}
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function readTokenResponse(response, operation) {
|
|
96
|
+
if (!response.ok) {
|
|
97
|
+
const text = await response.text().catch(() => "");
|
|
98
|
+
throw new Error(`OpenAI Codex token ${operation} failed (${response.status}): ${text || response.statusText}`);
|
|
99
|
+
}
|
|
100
|
+
const rawJson = await response.json();
|
|
101
|
+
const json = rawJson;
|
|
102
|
+
if (!json?.access_token || !json.refresh_token || typeof json.expires_in !== "number") {
|
|
103
|
+
throw new Error(`OpenAI Codex token ${operation} response missing fields: ${JSON.stringify(json)}`);
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
access: json.access_token,
|
|
107
|
+
refresh: json.refresh_token,
|
|
108
|
+
expires: Date.now() + json.expires_in * 1e3
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
async function exchangeAuthorizationCode(code, verifier, redirectUri, signal) {
|
|
112
|
+
const response = await fetchWithLoginCancellation(TOKEN_URL, {
|
|
113
|
+
method: "POST",
|
|
114
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
115
|
+
body: new URLSearchParams({
|
|
116
|
+
grant_type: "authorization_code",
|
|
117
|
+
client_id: CLIENT_ID,
|
|
118
|
+
code,
|
|
119
|
+
code_verifier: verifier,
|
|
120
|
+
redirect_uri: redirectUri
|
|
121
|
+
}),
|
|
122
|
+
signal
|
|
123
|
+
});
|
|
124
|
+
return readTokenResponse(response, "exchange");
|
|
125
|
+
}
|
|
126
|
+
async function refreshAccessToken(refreshToken, signal) {
|
|
127
|
+
let response;
|
|
128
|
+
try {
|
|
129
|
+
response = await fetch(TOKEN_URL, {
|
|
130
|
+
method: "POST",
|
|
131
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
132
|
+
body: new URLSearchParams({
|
|
133
|
+
grant_type: "refresh_token",
|
|
134
|
+
refresh_token: refreshToken,
|
|
135
|
+
client_id: CLIENT_ID
|
|
136
|
+
}),
|
|
137
|
+
signal
|
|
138
|
+
});
|
|
139
|
+
} catch (error) {
|
|
140
|
+
throw new Error(`OpenAI Codex token refresh error: ${error instanceof Error ? error.message : String(error)}`);
|
|
141
|
+
}
|
|
142
|
+
return readTokenResponse(response, "refresh");
|
|
143
|
+
}
|
|
144
|
+
async function startOpenAICodexDeviceAuth(signal) {
|
|
145
|
+
const response = await fetchWithLoginCancellation(DEVICE_USER_CODE_URL, {
|
|
146
|
+
method: "POST",
|
|
147
|
+
headers: { "Content-Type": "application/json" },
|
|
148
|
+
body: JSON.stringify({ client_id: CLIENT_ID }),
|
|
149
|
+
signal
|
|
150
|
+
});
|
|
151
|
+
if (!response.ok) {
|
|
152
|
+
if (response.status === 404) {
|
|
153
|
+
throw new Error("OpenAI Codex device code login is not enabled for this server. Use browser login or verify the server URL.");
|
|
154
|
+
}
|
|
155
|
+
const responseBody = await response.text().catch(() => "");
|
|
156
|
+
throw new Error(`OpenAI Codex device code request failed with status ${response.status}${responseBody ? `: ${responseBody}` : ""}`);
|
|
157
|
+
}
|
|
158
|
+
const rawJson = await response.json();
|
|
159
|
+
const json = rawJson;
|
|
160
|
+
const intervalSeconds = typeof json?.interval === "string" ? Number(json.interval.trim()) : json?.interval;
|
|
161
|
+
if (!json?.device_auth_id || !json.user_code || typeof intervalSeconds !== "number" || !Number.isFinite(intervalSeconds) || intervalSeconds < 0) {
|
|
162
|
+
throw new Error(`Invalid OpenAI Codex device code response: ${JSON.stringify(json)}`);
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
deviceAuthId: json.device_auth_id,
|
|
166
|
+
userCode: json.user_code,
|
|
167
|
+
intervalSeconds
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
async function pollOpenAICodexDeviceAuth(device, signal) {
|
|
171
|
+
return pollOAuthDeviceCodeFlow({
|
|
172
|
+
intervalSeconds: device.intervalSeconds,
|
|
173
|
+
expiresInSeconds: DEVICE_CODE_TIMEOUT_SECONDS,
|
|
174
|
+
signal,
|
|
175
|
+
poll: async () => {
|
|
176
|
+
const response = await fetchWithLoginCancellation(DEVICE_TOKEN_URL, {
|
|
177
|
+
method: "POST",
|
|
178
|
+
headers: { "Content-Type": "application/json" },
|
|
179
|
+
body: JSON.stringify({
|
|
180
|
+
device_auth_id: device.deviceAuthId,
|
|
181
|
+
user_code: device.userCode
|
|
182
|
+
}),
|
|
183
|
+
signal
|
|
184
|
+
});
|
|
185
|
+
if (response.ok) {
|
|
186
|
+
const rawJson = await response.json();
|
|
187
|
+
const json = rawJson;
|
|
188
|
+
if (!json?.authorization_code || !json.code_verifier) {
|
|
189
|
+
return {
|
|
190
|
+
status: "failed",
|
|
191
|
+
message: `Invalid OpenAI Codex device auth token response: ${JSON.stringify(json)}`
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
status: "complete",
|
|
196
|
+
value: { authorizationCode: json.authorization_code, codeVerifier: json.code_verifier }
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (response.status === 403 || response.status === 404) {
|
|
200
|
+
return { status: "pending" };
|
|
201
|
+
}
|
|
202
|
+
const responseBody = await response.text().catch(() => "");
|
|
203
|
+
let errorCode;
|
|
204
|
+
try {
|
|
205
|
+
const json = JSON.parse(responseBody);
|
|
206
|
+
const error = json?.error;
|
|
207
|
+
errorCode = typeof error === "object" ? error?.code : error;
|
|
208
|
+
} catch {
|
|
209
|
+
}
|
|
210
|
+
if (errorCode === "deviceauth_authorization_pending") {
|
|
211
|
+
return { status: "pending" };
|
|
212
|
+
}
|
|
213
|
+
if (errorCode === "slow_down") {
|
|
214
|
+
return { status: "slow_down" };
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
status: "failed",
|
|
218
|
+
message: `OpenAI Codex device auth failed with status ${response.status}${responseBody ? `: ${responseBody}` : ""}`
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
async function createAuthorizationFlow(originator = "pi") {
|
|
224
|
+
const { verifier, challenge } = await generatePKCE();
|
|
225
|
+
const state = createState();
|
|
226
|
+
const url = new URL(AUTHORIZE_URL);
|
|
227
|
+
url.searchParams.set("response_type", "code");
|
|
228
|
+
url.searchParams.set("client_id", CLIENT_ID);
|
|
229
|
+
url.searchParams.set("redirect_uri", REDIRECT_URI);
|
|
230
|
+
url.searchParams.set("scope", SCOPE);
|
|
231
|
+
url.searchParams.set("code_challenge", challenge);
|
|
232
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
233
|
+
url.searchParams.set("state", state);
|
|
234
|
+
url.searchParams.set("id_token_add_organizations", "true");
|
|
235
|
+
url.searchParams.set("codex_cli_simplified_flow", "true");
|
|
236
|
+
url.searchParams.set("originator", originator);
|
|
237
|
+
return { verifier, state, url: url.toString() };
|
|
238
|
+
}
|
|
239
|
+
function getAccountId(accessToken) {
|
|
240
|
+
const payload = decodeJwt(accessToken);
|
|
241
|
+
const auth = payload?.[JWT_CLAIM_PATH];
|
|
242
|
+
const accountId = auth?.chatgpt_account_id;
|
|
243
|
+
return typeof accountId === "string" && accountId.length > 0 ? accountId : null;
|
|
244
|
+
}
|
|
245
|
+
function credentialsFromToken(token) {
|
|
246
|
+
const accountId = getAccountId(token.access);
|
|
247
|
+
if (!accountId) {
|
|
248
|
+
throw new Error("Failed to extract accountId from token");
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
type: "oauth",
|
|
252
|
+
access: token.access,
|
|
253
|
+
refresh: token.refresh,
|
|
254
|
+
expires: token.expires,
|
|
255
|
+
accountId
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
async function exchangeAuthorizationCodeForCredentials(code, verifier, redirectUri, signal) {
|
|
259
|
+
return credentialsFromToken(await exchangeAuthorizationCode(code, verifier, redirectUri, signal));
|
|
260
|
+
}
|
|
261
|
+
async function loginOpenAICodexDeviceCode(interaction) {
|
|
262
|
+
const device = await startOpenAICodexDeviceAuth(interaction.signal);
|
|
263
|
+
interaction.notify({
|
|
264
|
+
type: "device_code",
|
|
265
|
+
userCode: device.userCode,
|
|
266
|
+
verificationUri: DEVICE_VERIFICATION_URI,
|
|
267
|
+
intervalSeconds: device.intervalSeconds,
|
|
268
|
+
expiresInSeconds: DEVICE_CODE_TIMEOUT_SECONDS
|
|
269
|
+
});
|
|
270
|
+
const code = await pollOpenAICodexDeviceAuth(device, interaction.signal);
|
|
271
|
+
return exchangeAuthorizationCodeForCredentials(code.authorizationCode, code.codeVerifier, DEVICE_REDIRECT_URI, interaction.signal);
|
|
272
|
+
}
|
|
273
|
+
async function loginOpenAICodex(interaction, options) {
|
|
274
|
+
const { verifier, state, url } = await createAuthorizationFlow(options?.agentName);
|
|
275
|
+
const callback = await startOAuthCallbackServer({
|
|
276
|
+
providerName: "OpenAI",
|
|
277
|
+
host: getCallbackHost(),
|
|
278
|
+
port: 1455,
|
|
279
|
+
path: "/auth/callback",
|
|
280
|
+
state,
|
|
281
|
+
complete: async (code) => code,
|
|
282
|
+
signal: interaction.signal
|
|
283
|
+
}).catch(() => void 0);
|
|
284
|
+
interaction.notify({
|
|
285
|
+
type: "auth_url",
|
|
286
|
+
url,
|
|
287
|
+
instructions: "A browser window should open. Complete login to finish."
|
|
288
|
+
});
|
|
289
|
+
try {
|
|
290
|
+
const result = await waitForCallbackOrManualInput(interaction, callback, {
|
|
291
|
+
message: "Complete login in your browser, or paste the authorization code / redirect URL here:",
|
|
292
|
+
placeholder: REDIRECT_URI
|
|
293
|
+
});
|
|
294
|
+
let code;
|
|
295
|
+
if (result.type === "callback") {
|
|
296
|
+
code = result.value;
|
|
297
|
+
} else {
|
|
298
|
+
const parsed = parseAuthorizationInput(result.input);
|
|
299
|
+
if (parsed.state && parsed.state !== state)
|
|
300
|
+
throw new Error("State mismatch");
|
|
301
|
+
code = parsed.code;
|
|
302
|
+
}
|
|
303
|
+
if (!code)
|
|
304
|
+
throw new Error("Missing authorization code");
|
|
305
|
+
return await exchangeAuthorizationCodeForCredentials(code, verifier, REDIRECT_URI, interaction.signal);
|
|
306
|
+
} finally {
|
|
307
|
+
callback?.close();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
async function refreshOpenAICodexToken(refreshToken, signal) {
|
|
311
|
+
return credentialsFromToken(await refreshAccessToken(refreshToken, signal));
|
|
312
|
+
}
|
|
313
|
+
var openaiCodexOAuth = {
|
|
314
|
+
name: "OpenAI (ChatGPT Plus/Pro)",
|
|
315
|
+
isSubscription: true,
|
|
316
|
+
async login(interaction, options) {
|
|
317
|
+
const method = await interaction.prompt({
|
|
318
|
+
type: "select",
|
|
319
|
+
message: "Select OpenAI Codex login method:",
|
|
320
|
+
options: [
|
|
321
|
+
{ id: OPENAI_CODEX_BROWSER_LOGIN_METHOD, label: "Browser login (default)" },
|
|
322
|
+
{ id: OPENAI_CODEX_DEVICE_CODE_LOGIN_METHOD, label: "Device code login (headless)" }
|
|
323
|
+
]
|
|
324
|
+
});
|
|
325
|
+
if (method === OPENAI_CODEX_DEVICE_CODE_LOGIN_METHOD) {
|
|
326
|
+
return loginOpenAICodexDeviceCode(interaction);
|
|
327
|
+
}
|
|
328
|
+
if (method !== OPENAI_CODEX_BROWSER_LOGIN_METHOD) {
|
|
329
|
+
throw new Error(`Unknown OpenAI Codex login method: ${method}`);
|
|
330
|
+
}
|
|
331
|
+
return loginOpenAICodex(interaction, options);
|
|
332
|
+
},
|
|
333
|
+
refresh: (credential, signal) => refreshOpenAICodexToken(credential.refresh, signal),
|
|
334
|
+
async toAuth(credential) {
|
|
335
|
+
return { apiKey: credential.access };
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
export {
|
|
339
|
+
openaiCodexOAuth
|
|
340
|
+
};
|