@nervekit/desktop 0.40.1 → 0.41.0
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 +5 -2
- package/THIRD-PARTY-LICENSES.txt +968 -30
- package/dist/bin.js +1 -0
- package/dist/{chunk-OY6PIAR7.js → chunk-2ICPO4UM.js} +5 -5
- package/dist/{chunk-SQ7CWNIT.js → chunk-3CZXUKLG.js} +1 -1
- package/dist/{chunk-QFXKQNMT.js → chunk-4OCDR4DU.js} +14 -17
- package/dist/chunk-62DQXVPO.js +69 -0
- package/dist/chunk-6GUJQURI.js +142 -0
- package/dist/{chunk-CEX2GWGZ.js → chunk-6IHXVT5H.js} +1 -1
- package/dist/{chunk-MH3SUHI2.js → chunk-6ZS7TA6E.js} +2 -2
- package/dist/chunk-7FSH3ABG.js +249 -0
- package/dist/chunk-7HGFEQSD.js +224 -0
- package/dist/chunk-7RPHIJT3.js +153 -0
- package/dist/{chunk-5Y3NEEOK.js → chunk-AAEIGAGD.js} +9 -9
- package/dist/{chunk-HKLAYK2Z.js → chunk-APY4TUR3.js} +210 -0
- package/dist/chunk-BACYVEE6.js +128 -0
- package/dist/chunk-BG2KGLIA.js +783 -0
- package/dist/{chunk-XBHEYY65.js → chunk-BN5YDZUZ.js} +1205 -326
- package/dist/chunk-BUD4JHBZ.js +7017 -0
- package/dist/{chunk-MN7PZ2PH.js → chunk-DDBE2VLT.js} +2 -2
- package/dist/chunk-EF7ZZKA3.js +168 -0
- package/dist/{chunk-TJR6ASRW.js → chunk-EUT45AKW.js} +22 -24
- package/dist/{chunk-L3YB2QLN.js → chunk-FCAIYPDJ.js} +2 -2
- package/dist/{chunk-AJGPULMX.js → chunk-FZ557YWE.js} +47603 -55411
- package/dist/chunk-HPINJGBO.js +359 -0
- package/dist/{chunk-H5UKINTD.js → chunk-IRRR3PWN.js} +68 -65
- package/dist/{chunk-CWHAK2HX.js → chunk-IVBMHEPK.js} +33 -55
- package/dist/{chunk-FESN7DND.js → chunk-JBEWFFOK.js} +1 -1
- package/dist/{chunk-CKVFGRVV.js → chunk-KEXKZKN4.js} +54 -7
- package/dist/{chunk-UGDIHDAR.js → chunk-KUFIFCB4.js} +1 -1
- package/dist/chunk-L5WGVYXM.js +42 -0
- package/dist/{chunk-ONWQH2W6.js → chunk-LGIIT2NF.js} +15 -18
- package/dist/{chunk-KSZJ3HGD.js → chunk-LP4APBBQ.js} +1 -1
- package/dist/{chunk-DBXMYYPJ.js → chunk-M3ELKCNA.js} +1 -1
- package/dist/chunk-MI6L5CEA.js +183 -0
- package/dist/chunk-N4OXAS3A.js +40 -0
- package/dist/chunk-N6BUYKF3.js +340 -0
- package/dist/{chunk-KIGB3FK6.js → chunk-NVVW3MWJ.js} +9 -8
- package/dist/{chunk-V53CETNZ.js → chunk-O5JHHRFN.js} +242 -105
- package/dist/{chunk-KQPEOUCA.js → chunk-O6FDXE54.js} +19 -23
- package/dist/{chunk-QWTKCUIZ.js → chunk-OMCM3MHS.js} +11 -9
- package/dist/{chunk-55OGZFNA.js → chunk-P72Y5ZBH.js} +31 -15
- package/dist/{chunk-AON37AL2.js → chunk-PVPJAGWR.js} +29 -4
- package/dist/{chunk-24GQ74HM.js → chunk-Q3C7TQ2M.js} +3 -3
- package/dist/chunk-Q5E4ZL2R.js +14 -0
- package/dist/chunk-QFK2SWD2.js +258 -0
- package/dist/chunk-RJR7DJJK.js +32 -0
- package/dist/{chunk-BXVRC3HF.js → chunk-RL52LSTV.js} +1 -1
- package/dist/{chunk-KAZFF2RD.js → chunk-RTB6CF7F.js} +137 -113
- package/dist/{chunk-TW6FURZ7.js → chunk-SDDKYMIP.js} +18313 -4317
- package/dist/{chunk-S2PITDVA.js → chunk-TQURLRHD.js} +1 -1
- package/dist/{chunk-2Z5FLMLE.js → chunk-TSAUBRRU.js} +1 -1
- package/dist/chunk-U3TEC52G.js +64 -0
- package/dist/chunk-U5KGV63C.js +39 -0
- package/dist/{chunk-FOFVPPPV.js → chunk-UVRULOOP.js} +10 -9
- package/dist/{chunk-QVHYARC2.js → chunk-VOATSLRG.js} +5 -1
- package/dist/{chunk-WXRYBXYR.js → chunk-W7LEYYFH.js} +53 -65
- package/dist/chunk-WC5HHPPM.js +22 -0
- package/dist/{chunk-3DGBM7UW.js → chunk-WG62RHZ2.js} +3 -3
- package/dist/{chunk-D7WIIZAV.js → chunk-WIQEPAUG.js} +10 -9
- package/dist/chunk-XM27UVWN.js +250 -0
- package/dist/{chunk-4MMJDHFX.js → chunk-XTUSLUQ7.js} +70 -71
- package/dist/{chunk-N5B2RRSS.js → chunk-Z6AY5VOZ.js} +47 -26
- package/dist/{chunk-I6NVW4NX.js → chunk-ZGWXLG5X.js} +29 -33
- package/dist/{chunk-XNYZEQ3U.js → chunk-ZUWBEV2O.js} +1 -1
- package/dist/chunk-ZVH6EB7S.js +29 -0
- package/dist/daemon.js +65 -26
- package/dist/extension-assets/atlassian/docs/confluence-raw.md +31 -0
- package/dist/extension-assets/atlassian/docs/confluence-writing.md +101 -0
- package/dist/extension-assets/atlassian/docs/jira-raw.md +16 -0
- package/dist/extension-assets/atlassian/docs/jira-workflows.md +77 -0
- package/dist/extension-assets/atlassian/docs/project-knowledge.md +25 -0
- package/dist/extension-assets/atlassian/docs/storage.md +58 -0
- package/dist/extension-assets/atlassian/icon.svg +20 -0
- package/dist/extension-assets/diagram/docs/diagrams.md +12 -0
- package/dist/extension-assets/imagegen/docs/imagegen.md +17 -0
- package/dist/extension-assets/web-search/icon.svg +1 -0
- package/dist/git-isolated-reader-helper.js +1 -1
- package/dist/html-to-markdown.worker.js +6 -7028
- package/dist/main.js +583 -164
- package/dist/preload.cjs +45 -2
- package/dist/quick-script-docs/runtime/documents.md +54 -0
- package/dist/quick-script-docs/runtime/files.md +11 -0
- package/dist/quick-script-docs/runtime/images.md +10 -0
- package/dist/sandbox-libraries/docx.LICENSE +21 -0
- package/dist/sandbox-libraries/docx.min.js +9 -0
- package/dist/sandbox-libraries/jszip.LICENSE +651 -0
- package/dist/sandbox-libraries/jszip.min.js +13 -0
- package/dist/sandbox-libraries/mammoth.LICENSE +22 -0
- package/dist/sandbox-libraries/mammoth.browser.min.js +13 -0
- package/dist/sandbox-libraries/papaparse.LICENSE +20 -0
- package/dist/sandbox-libraries/papaparse.min.js +7 -0
- package/dist/sandbox-libraries/pptxgen.bundle.js +96 -0
- package/dist/sandbox-libraries/pptxgenjs.LICENSE +21 -0
- package/dist/sandbox-libraries/xlsx.LICENSE +201 -0
- package/dist/sandbox-libraries/xlsx.full.min.js +24 -0
- package/dist/web/assets/{AsyncBashCenterHost-HGsdxUJ3.js → AsyncBashCenterHost-D2Sy43Ub.js} +1 -1
- package/dist/web/assets/ConversationListItem-DvxCcAYm.js +3 -0
- package/dist/web/assets/ConversationsWorkbenchPanel-YeNq9LRn.js +1 -0
- package/dist/web/assets/DiscoverCenterHost-B6K-QnBF.js +1 -0
- package/dist/web/assets/{FileCenterHost-DigJOU5M.js → FileCenterHost-Dlk53K5G.js} +1 -1
- package/dist/web/assets/FilesWorkbenchPanel-PeCu12oU.js +12 -0
- package/dist/web/assets/{GitDiffCenterHost-IuZfF3hG.js → GitDiffCenterHost-3_Ea0RyG.js} +1 -1
- package/dist/web/assets/{GitWorkbenchPanel-CScC0CfH.js → GitWorkbenchPanel-CYvCkOAW.js} +1 -1
- package/dist/web/assets/{LaunchCenterHost-CIu7bcoZ.js → LaunchCenterHost-CP773N_3.js} +1 -1
- package/dist/web/assets/LaunchConfigurationNotice-CtmZ1uIQ.js +1 -0
- package/dist/web/assets/{LaunchesWorkbenchPanel-Vy0Gm7gg.js → LaunchesWorkbenchPanel-DP3yVfkO.js} +1 -1
- package/dist/web/assets/LogsCenterHost-BFP0doQf.js +1 -0
- package/dist/web/assets/{MermaidCenterHost-DDh4ArdK.js → MermaidCenterHost-Bjl6Dvrq.js} +1 -1
- package/dist/web/assets/MobileFilesBody-CDp21MGZ.js +1 -0
- package/dist/web/assets/{MobileFilesHost-C1jev2Un.js → MobileFilesHost-DlJI_yau.js} +1 -1
- package/dist/web/assets/MobileLaunchOutputHost-y3TehLWF.js +1 -0
- package/dist/web/assets/MobileLaunchesHost-CBNtDTrs.js +2 -0
- package/dist/web/assets/MobileLogsHost-BSb2lydK.js +1 -0
- package/dist/web/assets/MobileNoteEditorHost-7yW7hIC2.js +1 -0
- package/dist/web/assets/{MobileNotesHost-BZeYpK9H.js → MobileNotesHost-CvDHzpAh.js} +1 -1
- package/dist/web/assets/{MobileProjectSettingsHost-U3Mx3EN8.js → MobileProjectSettingsHost-CjtPfyKT.js} +1 -1
- package/dist/web/assets/{MobileProjectSettingsPageHost-CMvxbjfs.js → MobileProjectSettingsPageHost-j_7N-B9L.js} +1 -1
- package/dist/web/assets/{MobileSettingsHost-CP8Z_-gH.js → MobileSettingsHost-DXIKNF01.js} +1 -1
- package/dist/web/assets/{MobileSettingsPageHost-BPjXKTMV.js → MobileSettingsPageHost-CEzo7J9p.js} +1 -1
- package/dist/web/assets/MobileSettingsPageScreen-99wMLRsn.js +1 -0
- package/dist/web/assets/NotesWorkbenchPanel-DqTwXBBv.js +1 -0
- package/dist/web/assets/ProjectSettingsCenterHost-D96cL0uH.js +1 -0
- package/dist/web/assets/{PullRequestCenterHost-CZhXfCX2.js → PullRequestCenterHost-DY0yPDK2.js} +1 -1
- package/dist/web/assets/PullRequestsWorkbenchPanel-D07LE8vJ.js +1 -0
- package/dist/web/assets/{SearchWorkbenchPanel-qLgszneN.js → SearchWorkbenchPanel-D2_3iXo8.js} +1 -1
- package/dist/web/assets/SettingsCenter-BQWc24di.js +1 -0
- package/dist/web/assets/SettingsCenterHost-BvgNfeZN.js +1 -0
- package/dist/web/assets/{SystemPromptCenterHost-ya5AvXsd.js → SystemPromptCenterHost-BLHkB7lp.js} +1 -1
- package/dist/web/assets/activity-notices-C9aphS1s.js +1 -0
- package/dist/web/assets/adapters-DNU88KT0.js +1 -0
- package/dist/web/assets/agent-profiles.svelte-DgI8wSS2.js +1 -0
- package/dist/web/assets/api-CHNbLvvY.js +1 -0
- package/dist/web/assets/center-tabs.svelte-CyhCD_6b.js +1 -0
- package/dist/web/assets/channel-6wGoOwGx.js +57 -0
- package/dist/web/assets/circle-question-mark-C7NgqbLL.js +1 -0
- package/dist/web/assets/code-DJR0pnqV.js +7 -0
- package/dist/web/assets/{confirm-dialog-Bw_IxcZD.js → confirm-dialog-BDjzMiC4.js} +1 -1
- package/dist/web/assets/{conversation-connection-3GxIuhbS.js → conversation-connection-mLNyfV2d.js} +1 -1
- package/dist/web/assets/dialog-CkRcLEJT.js +1 -0
- package/dist/web/assets/discover-Dh4m7djO.js +4 -0
- package/dist/web/assets/dist-DSApqEag.js +1 -0
- package/dist/web/assets/file-tabs.svelte-cX3MMyG6.js +2 -0
- package/dist/web/assets/filesystem-BbIXrkGB.js +1 -0
- package/dist/web/assets/{git-store.svelte-CM5k7yRU.js → git-store.svelte-D3uwRVnj.js} +1 -1
- package/dist/web/assets/{git.api-D2CfUXZW.js → git.api-CTu-tG8A.js} +1 -1
- package/dist/web/assets/index-BrxjAwg0.js +46 -0
- package/dist/web/assets/index-yEOHI1Z7.css +1 -0
- package/dist/web/assets/launches-CC4gLnSa.js +5 -0
- package/dist/web/assets/{launches.api-BZxyWF8t.js → launches.api-CaotSs6l.js} +1 -1
- package/dist/web/assets/launches.svelte-DDA5J-RZ.js +2 -0
- package/dist/web/assets/{message-square-CqLxHJuW.js → list-checks-zV9Dp7Cu.js} +1 -1
- package/dist/web/assets/{logs.api-Coi8HJuy.js → logs.api-DMmVlkSz.js} +1 -1
- package/dist/web/assets/{maintenance-state.svelte-CDO9i4dk.js → maintenance-state.svelte-l9v7Hg3i.js} +2 -2
- package/dist/web/assets/notify.svelte-BTEXJZ8P.js +1 -0
- package/dist/web/assets/popover-panel-C-weKOk3.js +5 -0
- package/dist/web/assets/pr-view-loader.svelte-C0NClMS6.js +1 -0
- package/dist/web/assets/progress-CKEsTSOk.js +1 -0
- package/dist/web/assets/scratch-notes-state.svelte-B_rY_-9q.js +1 -0
- package/dist/web/assets/{scratch-notes.api-Cbvag3bv.js → scratch-notes.api-B2gOOK6Z.js} +1 -1
- package/dist/web/assets/search-input-CEr0SmAB.js +1 -0
- package/dist/web/assets/settings-2-CWd8Y06n.js +1 -0
- package/dist/web/assets/settings-CRmC19nG.js +1 -0
- package/dist/web/assets/settings-CXoAzSmm.js +1 -0
- package/dist/web/assets/settings-actions.svelte-BB6u_lQ0.js +1 -0
- package/dist/web/assets/settings-page-controllers.svelte-al78EDTL.js +29 -0
- package/dist/web/assets/sheet-content-DauQ7hPL.js +1 -0
- package/dist/web/assets/shell-CYbWnH52.js +4 -0
- package/dist/web/assets/shell-layout.svelte-CmEWk428.js +2 -0
- package/dist/web/assets/textarea-BEZ65po_.js +1 -0
- package/dist/web/assets/views-BumCSQ3W.js +2 -0
- package/dist/web/assets/{workbench-connection-gGGv4o8i.js → workbench-connection-CGHdORw3.js} +1 -1
- package/dist/web/assets/{workspace-Cc47dGjw.js → workspace-CW738NJG.js} +1 -1
- package/dist/web/assets/{workspace-actions.svelte-B3oum_9S.js → workspace-actions.svelte-DL9xv7lJ.js} +1 -1
- package/dist/web/assets/workspace-selectors.svelte-BRJvPEBh.js +105 -0
- package/dist/web/index.html +142 -83
- 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/guides/confluence/SKILL.md +0 -36
- package/dist/guides/jira/SKILL.md +0 -34
- package/dist/resize-worker.js +0 -168
- package/dist/web/assets/ConversationListItem-Caz2KiJH.js +0 -3
- package/dist/web/assets/ConversationsWorkbenchPanel-B6dzWkG1.js +0 -1
- package/dist/web/assets/DiscoverCenterHost-B186WBRA.js +0 -1
- package/dist/web/assets/FilesWorkbenchPanel-VPvx3Bmi.js +0 -12
- package/dist/web/assets/LaunchConfigurationNotice-5yb4cH27.js +0 -1
- package/dist/web/assets/LogsCenterHost-BXBozCYw.js +0 -1
- package/dist/web/assets/MobileFilesBody-Cda_7gDp.js +0 -1
- package/dist/web/assets/MobileLaunchOutputHost-Bsv12o2H.js +0 -1
- package/dist/web/assets/MobileLaunchesHost-C9VH-2bn.js +0 -2
- package/dist/web/assets/MobileLogsHost-BMDXc-WC.js +0 -1
- package/dist/web/assets/MobileNoteEditorHost-BA6WIY1Y.js +0 -1
- package/dist/web/assets/MobileSettingsPageScreen-C5rHdrUU.js +0 -1
- package/dist/web/assets/NotesWorkbenchPanel-Bf6rySTL.js +0 -1
- package/dist/web/assets/ProjectSettingsCenterHost-BVXpBixy.js +0 -1
- package/dist/web/assets/PullRequestsWorkbenchPanel-BBnZJVnI.js +0 -1
- package/dist/web/assets/SettingsCenter-7BfrBfiy.js +0 -1
- package/dist/web/assets/SettingsCenterHost-Ck5uHILP.js +0 -1
- package/dist/web/assets/adapters-DxJoo6Za.js +0 -1
- package/dist/web/assets/agent-profiles.svelte-D5YHPc90.js +0 -1
- package/dist/web/assets/api-eaGLre0q.js +0 -1
- package/dist/web/assets/center-tabs.svelte-JJGozG_H.js +0 -1
- package/dist/web/assets/channel-B503YLZR.js +0 -57
- package/dist/web/assets/chevron-left-DPEFG6UJ.js +0 -1
- package/dist/web/assets/circle-alert-Cp2l2jcj.js +0 -5
- package/dist/web/assets/clock-Db6f9HtS.js +0 -1
- package/dist/web/assets/code-BRQC0Tpn.js +0 -7
- package/dist/web/assets/dialog-DU4gXD1J.js +0 -1
- package/dist/web/assets/discover-B3I5g1_G.js +0 -4
- package/dist/web/assets/dist-B_NFPhKV.js +0 -1
- package/dist/web/assets/file-tabs.svelte-DKtVVVCq.js +0 -2
- package/dist/web/assets/filesystem-ReGivxAC.js +0 -1
- package/dist/web/assets/index-DIQuyMVT.css +0 -1
- package/dist/web/assets/index-FJEmK_L5.js +0 -48
- package/dist/web/assets/launches-DiAl56ED.js +0 -5
- package/dist/web/assets/launches.svelte-BVs1pAhl.js +0 -2
- package/dist/web/assets/notebook-pen-lVsLYSe4.js +0 -1
- package/dist/web/assets/notify.svelte-BKVBraTJ.js +0 -1
- package/dist/web/assets/pencil-BrlypebI.js +0 -1
- package/dist/web/assets/pr-view-loader.svelte-DcIwqDJV.js +0 -1
- package/dist/web/assets/progress-DBCSpVPn.js +0 -1
- package/dist/web/assets/scratch-notes-state.svelte-Br_WiMEp.js +0 -1
- package/dist/web/assets/search-input-zU4WCZiz.js +0 -1
- package/dist/web/assets/settings-2-8MSBUGAl.js +0 -1
- package/dist/web/assets/settings-9LBrw4Nv.js +0 -1
- package/dist/web/assets/settings-B7uXsflY.js +0 -1
- package/dist/web/assets/settings-actions.svelte-B8psX3cj.js +0 -1
- package/dist/web/assets/settings-page-controllers.svelte-CU0i08wo.js +0 -30
- package/dist/web/assets/shell-DB5Db5-E.js +0 -4
- package/dist/web/assets/shell-layout.svelte-BT2508sa.js +0 -2
- package/dist/web/assets/textarea-CeoFJ0-t.js +0 -1
- package/dist/web/assets/views-Z-n-GTYY.js +0 -2
- package/dist/web/assets/workspace-selectors.svelte-DLUlSgEE.js +0 -131
- /package/dist/{html-to-markdown.worker.js.LEGAL.txt → chunk-BUD4JHBZ.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-CKVFGRVV.js.LEGAL.txt → chunk-KEXKZKN4.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-TW6FURZ7.js.LEGAL.txt → chunk-SDDKYMIP.js.LEGAL.txt} +0 -0
package/dist/bin.js
CHANGED
|
@@ -49,6 +49,7 @@ if (forwardedArgs.includes("--help") || forwardedArgs.includes("-h")) {
|
|
|
49
49
|
"Environment:",
|
|
50
50
|
" NERVE_ELECTRON_OZONE_PLATFORM=x11|wayland|auto (Linux only)",
|
|
51
51
|
" NERVE_ELECTRON_FONT_RENDER_HINTING=system|none|slight|medium|full (Linux only; default: slight)",
|
|
52
|
+
" NERVE_ELECTRON_REMOTE_DEBUGGING_PORT=<port> Expose Chrome DevTools Protocol on 127.0.0.1",
|
|
52
53
|
" ELECTRON_GET_USE_PROXY=true with HTTPS_PROXY/HTTP_PROXY/NO_PROXY (corporate proxy downloads)",
|
|
53
54
|
" NODE_USE_ENV_PROXY=1 and NODE_USE_SYSTEM_CA=1 are enabled automatically when needed",
|
|
54
55
|
" NODE_EXTRA_CA_CERTS=/path/to/corporate-ca.pem (explicit TLS interception CA bundle)",
|
|
@@ -2,19 +2,19 @@ import { createRequire as __nerveCreateRequire } from "node:module";
|
|
|
2
2
|
const require = __nerveCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
retryProviderRequest
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-3CZXUKLG.js";
|
|
6
6
|
import {
|
|
7
7
|
headersToRecord,
|
|
8
8
|
providerHeadersToRecord
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6IHXVT5H.js";
|
|
10
10
|
import {
|
|
11
11
|
calculateCost
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-W7LEYYFH.js";
|
|
13
13
|
import {
|
|
14
14
|
getIdentityHeaders
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-Q3C7TQ2M.js";
|
|
16
16
|
|
|
17
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
17
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.2_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_b842a8cec34a633ed5f728049ae89b72/node_modules/@earendil-works/pi-ai/dist/api/classifier-shared.js
|
|
18
18
|
function httpError(label, response, body) {
|
|
19
19
|
const error = new Error(`${label} returned ${response.status}`);
|
|
20
20
|
error.status = response.status;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
2
|
const require = __nerveCreateRequire(import.meta.url);
|
|
3
3
|
|
|
4
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
4
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.2_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_b842a8cec34a633ed5f728049ae89b72/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js
|
|
5
5
|
var DEFAULT_MAX_RETRY_DELAY_MS = 6e4;
|
|
6
6
|
function isProviderError(error) {
|
|
7
7
|
if (!(error instanceof Error) || !("status" in error) || !("headers" in error))
|
|
@@ -15,39 +15,41 @@ import {
|
|
|
15
15
|
toGoogleSdkThinkingLevel,
|
|
16
16
|
toGoogleThinkingLevel,
|
|
17
17
|
usesGoogleThinkingLevel
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-KEXKZKN4.js";
|
|
19
19
|
import "./chunk-MXYQOFZ5.js";
|
|
20
20
|
import {
|
|
21
21
|
buildBaseOptions
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-Z6AY5VOZ.js";
|
|
23
23
|
import {
|
|
24
24
|
sanitizeSurrogates
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-TSAUBRRU.js";
|
|
26
|
+
import "./chunk-3CZXUKLG.js";
|
|
26
27
|
import {
|
|
27
28
|
formatProviderError,
|
|
28
29
|
normalizeProviderError
|
|
29
|
-
} from "./chunk-
|
|
30
|
-
import "./chunk-SQ7CWNIT.js";
|
|
30
|
+
} from "./chunk-PVPJAGWR.js";
|
|
31
31
|
import {
|
|
32
32
|
providerHeadersToRecord
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-6IHXVT5H.js";
|
|
34
34
|
import {
|
|
35
35
|
calculateCost,
|
|
36
36
|
clampThinkingLevel,
|
|
37
37
|
collapseSystemMessages,
|
|
38
38
|
getCurrentTools,
|
|
39
|
-
getInitialSystemMessage
|
|
40
|
-
|
|
41
|
-
} from "./chunk-WXRYBXYR.js";
|
|
39
|
+
getInitialSystemMessage
|
|
40
|
+
} from "./chunk-W7LEYYFH.js";
|
|
42
41
|
import {
|
|
43
42
|
AssistantMessageEventStream
|
|
44
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-DDBE2VLT.js";
|
|
45
44
|
import {
|
|
46
45
|
getIdentityHeaders
|
|
47
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-Q3C7TQ2M.js";
|
|
47
|
+
import {
|
|
48
|
+
getSystemMessageText
|
|
49
|
+
} from "./chunk-U5KGV63C.js";
|
|
48
50
|
import "./chunk-CWESUMYQ.js";
|
|
49
51
|
|
|
50
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
52
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.2_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_b842a8cec34a633ed5f728049ae89b72/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js
|
|
51
53
|
var toolCallCounter = 0;
|
|
52
54
|
var stream = (model, context, options) => {
|
|
53
55
|
const stream2 = new AssistantMessageEventStream();
|
|
@@ -242,11 +244,6 @@ var stream = (model, context, options) => {
|
|
|
242
244
|
stream2.push({ type: "done", reason: output.stopReason, message: output });
|
|
243
245
|
stream2.end();
|
|
244
246
|
} catch (error) {
|
|
245
|
-
for (const block of output.content) {
|
|
246
|
-
if ("index" in block) {
|
|
247
|
-
delete block.index;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
247
|
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
251
248
|
output.errorMessage = formatProviderError(normalizeProviderError(error));
|
|
252
249
|
stream2.push({ type: "error", reason: output.stopReason, error: output });
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
|
+
const require = __nerveCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
ownedSlice
|
|
5
|
+
} from "./chunk-U5KGV63C.js";
|
|
6
|
+
|
|
7
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.2_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_b842a8cec34a633ed5f728049ae89b72/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js
|
|
8
|
+
var DEFAULT_RADIUS_GATEWAY = "https://radius.pi.dev";
|
|
9
|
+
function isRadiusGatewayModel(value) {
|
|
10
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
11
|
+
return false;
|
|
12
|
+
const model = value;
|
|
13
|
+
return typeof model.id === "string" && typeof model.name === "string" && typeof model.reasoning === "boolean" && Array.isArray(model.input) && typeof model.cost === "object" && model.cost !== null && !Array.isArray(model.cost) && typeof model.contextWindow === "number" && typeof model.maxTokens === "number";
|
|
14
|
+
}
|
|
15
|
+
function sanitizeRadiusGatewayConfig(config) {
|
|
16
|
+
if (typeof config !== "object" || config === null || Array.isArray(config))
|
|
17
|
+
return void 0;
|
|
18
|
+
const { baseUrl, models } = config;
|
|
19
|
+
if (typeof baseUrl !== "string" || !Array.isArray(models))
|
|
20
|
+
return void 0;
|
|
21
|
+
return {
|
|
22
|
+
baseUrl,
|
|
23
|
+
models: models.filter(isRadiusGatewayModel).map((model) => ({ ...model }))
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function normalizeRadiusGatewayUrl(value) {
|
|
27
|
+
const withScheme = /^https?:\/\//iu.test(value) ? value : `https://${value}`;
|
|
28
|
+
return withScheme.replace(/\/+$/u, "");
|
|
29
|
+
}
|
|
30
|
+
function getRadiusCredentialConfig(credential) {
|
|
31
|
+
return sanitizeRadiusGatewayConfig(credential?.gatewayConfig);
|
|
32
|
+
}
|
|
33
|
+
function getRadiusModelsFromConfig(providerId, config) {
|
|
34
|
+
return config.models.map((model) => ({
|
|
35
|
+
...model,
|
|
36
|
+
api: "pi-messages",
|
|
37
|
+
provider: providerId,
|
|
38
|
+
baseUrl: config.baseUrl
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
function getRadiusModels(providerId, credential) {
|
|
42
|
+
const config = getRadiusCredentialConfig(credential);
|
|
43
|
+
return config ? getRadiusModelsFromConfig(providerId, config) : [];
|
|
44
|
+
}
|
|
45
|
+
function truncateHttpBody(body) {
|
|
46
|
+
const trimmed = body.trim();
|
|
47
|
+
return trimmed.length > 512 ? `${ownedSlice(trimmed, 0, 512)}\u2026` : trimmed;
|
|
48
|
+
}
|
|
49
|
+
async function loadRadiusGatewayConfig(gateway, apiKey, signal) {
|
|
50
|
+
const headers = { accept: "application/json" };
|
|
51
|
+
if (apiKey)
|
|
52
|
+
headers.authorization = `Bearer ${apiKey}`;
|
|
53
|
+
const response = await fetch(new URL("/v1/config", gateway), { headers, signal });
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
throw new Error(`Could not load Radius config from ${gateway}: ${response.status}: ${truncateHttpBody(await response.text())}`);
|
|
56
|
+
}
|
|
57
|
+
const config = sanitizeRadiusGatewayConfig(await response.json());
|
|
58
|
+
if (!config)
|
|
59
|
+
throw new Error(`Invalid Radius config from ${gateway}`);
|
|
60
|
+
return config;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
DEFAULT_RADIUS_GATEWAY,
|
|
65
|
+
normalizeRadiusGatewayUrl,
|
|
66
|
+
getRadiusModelsFromConfig,
|
|
67
|
+
getRadiusModels,
|
|
68
|
+
loadRadiusGatewayConfig
|
|
69
|
+
};
|
|
@@ -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-BACYVEE6.js";
|
|
7
|
+
|
|
8
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.2_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_b842a8cec34a633ed5f728049ae89b72/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
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
2
|
const require = __nerveCreateRequire(import.meta.url);
|
|
3
3
|
|
|
4
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
4
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.2_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_b842a8cec34a633ed5f728049ae89b72/node_modules/@earendil-works/pi-ai/dist/utils/headers.js
|
|
5
5
|
function headersToRecord(headers) {
|
|
6
6
|
const result = {};
|
|
7
7
|
for (const [key, value] of headers.entries()) {
|
|
@@ -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-JBEWFFOK.js";
|
|
6
6
|
|
|
7
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
7
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.2_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_b842a8cec34a633ed5f728049ae89b72/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,249 @@
|
|
|
1
|
+
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
|
+
const require = __nerveCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
startOAuthCallbackServer,
|
|
5
|
+
waitForCallbackOrManualInput
|
|
6
|
+
} from "./chunk-6GUJQURI.js";
|
|
7
|
+
import {
|
|
8
|
+
generatePKCE
|
|
9
|
+
} from "./chunk-BACYVEE6.js";
|
|
10
|
+
import {
|
|
11
|
+
getProviderEnvValue
|
|
12
|
+
} from "./chunk-JBEWFFOK.js";
|
|
13
|
+
import "./chunk-CWESUMYQ.js";
|
|
14
|
+
|
|
15
|
+
// node_modules/.pnpm/@earendil-works+pi-ai@1.5.2_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_b842a8cec34a633ed5f728049ae89b72/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.js
|
|
16
|
+
var decode = (s) => atob(s);
|
|
17
|
+
var CLIENT_ID = decode("OWQxYzI1MGEtZTYxYi00NGQ5LTg4ZWQtNTk0NGQxOTYyZjVl");
|
|
18
|
+
var AUTHORIZE_URL = "https://claude.ai/oauth/authorize";
|
|
19
|
+
var TOKEN_URL = "https://platform.claude.com/v1/oauth/token";
|
|
20
|
+
var CALLBACK_HOST = getProviderEnvValue("PI_OAUTH_CALLBACK_HOST") || "127.0.0.1";
|
|
21
|
+
var CALLBACK_PORT = 53692;
|
|
22
|
+
var CALLBACK_PATH = "/callback";
|
|
23
|
+
var REDIRECT_URI = `http://localhost:${CALLBACK_PORT}${CALLBACK_PATH}`;
|
|
24
|
+
var COPY_CODE_REDIRECT_URI = "https://platform.claude.com/oauth/code/callback";
|
|
25
|
+
var ANTHROPIC_BROWSER_LOGIN_METHOD = "browser";
|
|
26
|
+
var ANTHROPIC_COPY_CODE_LOGIN_METHOD = "copy_code";
|
|
27
|
+
var SCOPES = "org:create_api_key user:profile user:inference user:sessions:claude_code user:mcp_servers user:file_upload";
|
|
28
|
+
function parseAuthorizationInput(input) {
|
|
29
|
+
const value = input.trim();
|
|
30
|
+
if (!value)
|
|
31
|
+
return {};
|
|
32
|
+
try {
|
|
33
|
+
const url = new URL(value);
|
|
34
|
+
return {
|
|
35
|
+
code: url.searchParams.get("code") ?? void 0,
|
|
36
|
+
state: url.searchParams.get("state") ?? void 0
|
|
37
|
+
};
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
40
|
+
if (value.includes("#")) {
|
|
41
|
+
const [code, state] = value.split("#", 2);
|
|
42
|
+
return { code, state };
|
|
43
|
+
}
|
|
44
|
+
if (value.includes("code=")) {
|
|
45
|
+
const params = new URLSearchParams(value);
|
|
46
|
+
return {
|
|
47
|
+
code: params.get("code") ?? void 0,
|
|
48
|
+
state: params.get("state") ?? void 0
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return { code: value };
|
|
52
|
+
}
|
|
53
|
+
function formatErrorDetails(error) {
|
|
54
|
+
if (error instanceof Error) {
|
|
55
|
+
const details = [`${error.name}: ${error.message}`];
|
|
56
|
+
const errorWithCode = error;
|
|
57
|
+
if (errorWithCode.code)
|
|
58
|
+
details.push(`code=${errorWithCode.code}`);
|
|
59
|
+
if (typeof errorWithCode.errno !== "undefined")
|
|
60
|
+
details.push(`errno=${String(errorWithCode.errno)}`);
|
|
61
|
+
if (typeof error.cause !== "undefined") {
|
|
62
|
+
details.push(`cause=${formatErrorDetails(error.cause)}`);
|
|
63
|
+
}
|
|
64
|
+
if (error.stack) {
|
|
65
|
+
details.push(`stack=${error.stack}`);
|
|
66
|
+
}
|
|
67
|
+
return details.join("; ");
|
|
68
|
+
}
|
|
69
|
+
return String(error);
|
|
70
|
+
}
|
|
71
|
+
async function postJson(url, body, signal) {
|
|
72
|
+
const response = await fetch(url, {
|
|
73
|
+
method: "POST",
|
|
74
|
+
headers: {
|
|
75
|
+
"Content-Type": "application/json",
|
|
76
|
+
Accept: "application/json"
|
|
77
|
+
},
|
|
78
|
+
body: JSON.stringify(body),
|
|
79
|
+
signal: AbortSignal.any([signal, AbortSignal.timeout(3e4)])
|
|
80
|
+
});
|
|
81
|
+
const responseBody = await response.text();
|
|
82
|
+
if (!response.ok) {
|
|
83
|
+
throw new Error(`HTTP request failed. status=${response.status}; url=${url}; body=${responseBody}`);
|
|
84
|
+
}
|
|
85
|
+
return responseBody;
|
|
86
|
+
}
|
|
87
|
+
async function exchangeAuthorizationCode(code, state, verifier, redirectUri, signal) {
|
|
88
|
+
let responseBody;
|
|
89
|
+
try {
|
|
90
|
+
responseBody = await postJson(TOKEN_URL, {
|
|
91
|
+
grant_type: "authorization_code",
|
|
92
|
+
client_id: CLIENT_ID,
|
|
93
|
+
code,
|
|
94
|
+
state,
|
|
95
|
+
redirect_uri: redirectUri,
|
|
96
|
+
code_verifier: verifier
|
|
97
|
+
}, signal);
|
|
98
|
+
} catch (error) {
|
|
99
|
+
throw new Error(`Token exchange request failed. url=${TOKEN_URL}; redirect_uri=${redirectUri}; response_type=authorization_code; details=${formatErrorDetails(error)}`);
|
|
100
|
+
}
|
|
101
|
+
let tokenData;
|
|
102
|
+
try {
|
|
103
|
+
tokenData = JSON.parse(responseBody);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
throw new Error(`Token exchange returned invalid JSON. url=${TOKEN_URL}; body=${responseBody}; details=${formatErrorDetails(error)}`);
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
type: "oauth",
|
|
109
|
+
refresh: tokenData.refresh_token,
|
|
110
|
+
access: tokenData.access_token,
|
|
111
|
+
expires: Date.now() + tokenData.expires_in * 1e3 - 5 * 60 * 1e3
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async function loginAnthropic(interaction) {
|
|
115
|
+
const { verifier, challenge } = await generatePKCE();
|
|
116
|
+
const startCallbackServer = (port) => startOAuthCallbackServer({
|
|
117
|
+
providerName: "Anthropic",
|
|
118
|
+
host: CALLBACK_HOST,
|
|
119
|
+
port,
|
|
120
|
+
path: CALLBACK_PATH,
|
|
121
|
+
redirectHost: "localhost",
|
|
122
|
+
state: verifier,
|
|
123
|
+
complete: async (code) => code,
|
|
124
|
+
signal: interaction.signal
|
|
125
|
+
});
|
|
126
|
+
const callback = await startCallbackServer(CALLBACK_PORT).catch(() => startCallbackServer(0)).catch(() => void 0);
|
|
127
|
+
const redirectUri = callback?.redirectUri ?? REDIRECT_URI;
|
|
128
|
+
try {
|
|
129
|
+
const authParams = new URLSearchParams({
|
|
130
|
+
code: "true",
|
|
131
|
+
client_id: CLIENT_ID,
|
|
132
|
+
response_type: "code",
|
|
133
|
+
redirect_uri: redirectUri,
|
|
134
|
+
scope: SCOPES,
|
|
135
|
+
code_challenge: challenge,
|
|
136
|
+
code_challenge_method: "S256",
|
|
137
|
+
state: verifier
|
|
138
|
+
});
|
|
139
|
+
interaction.notify({
|
|
140
|
+
type: "auth_url",
|
|
141
|
+
url: `${AUTHORIZE_URL}?${authParams.toString()}`,
|
|
142
|
+
instructions: "Complete login in your browser. If the browser is on another machine, paste the final redirect URL here."
|
|
143
|
+
});
|
|
144
|
+
const result = await waitForCallbackOrManualInput(interaction, callback, {
|
|
145
|
+
message: "Complete login in your browser, or paste the authorization code / redirect URL here:",
|
|
146
|
+
placeholder: redirectUri
|
|
147
|
+
});
|
|
148
|
+
let code;
|
|
149
|
+
let state = verifier;
|
|
150
|
+
if (result.type === "callback") {
|
|
151
|
+
code = result.value;
|
|
152
|
+
} else {
|
|
153
|
+
const parsed = parseAuthorizationInput(result.input);
|
|
154
|
+
if (parsed.state && parsed.state !== verifier)
|
|
155
|
+
throw new Error("OAuth state mismatch");
|
|
156
|
+
code = parsed.code;
|
|
157
|
+
state = parsed.state ?? verifier;
|
|
158
|
+
}
|
|
159
|
+
if (!code)
|
|
160
|
+
throw new Error("Missing authorization code");
|
|
161
|
+
interaction.notify({ type: "progress", message: "Exchanging authorization code for tokens..." });
|
|
162
|
+
return await exchangeAuthorizationCode(code, state, verifier, redirectUri, interaction.signal);
|
|
163
|
+
} finally {
|
|
164
|
+
callback?.close();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
async function loginAnthropicCopyCode(interaction) {
|
|
168
|
+
const { verifier, challenge } = await generatePKCE();
|
|
169
|
+
const authParams = new URLSearchParams({
|
|
170
|
+
code: "true",
|
|
171
|
+
client_id: CLIENT_ID,
|
|
172
|
+
response_type: "code",
|
|
173
|
+
redirect_uri: COPY_CODE_REDIRECT_URI,
|
|
174
|
+
scope: SCOPES,
|
|
175
|
+
code_challenge: challenge,
|
|
176
|
+
code_challenge_method: "S256",
|
|
177
|
+
state: verifier
|
|
178
|
+
});
|
|
179
|
+
interaction.notify({
|
|
180
|
+
type: "auth_url",
|
|
181
|
+
url: `${AUTHORIZE_URL}?${authParams.toString()}`,
|
|
182
|
+
instructions: "Complete login in your browser, then copy the code Anthropic shows and paste it here."
|
|
183
|
+
});
|
|
184
|
+
const input = await interaction.prompt({
|
|
185
|
+
type: "manual_code",
|
|
186
|
+
message: "Paste the code Anthropic shows after you sign in:",
|
|
187
|
+
placeholder: "code#state",
|
|
188
|
+
signal: interaction.signal
|
|
189
|
+
});
|
|
190
|
+
const parsed = parseAuthorizationInput(input);
|
|
191
|
+
if (parsed.state && parsed.state !== verifier)
|
|
192
|
+
throw new Error("OAuth state mismatch");
|
|
193
|
+
if (!parsed.code)
|
|
194
|
+
throw new Error("Missing authorization code");
|
|
195
|
+
interaction.notify({ type: "progress", message: "Exchanging authorization code for tokens..." });
|
|
196
|
+
return await exchangeAuthorizationCode(parsed.code, parsed.state ?? verifier, verifier, COPY_CODE_REDIRECT_URI, interaction.signal);
|
|
197
|
+
}
|
|
198
|
+
async function refreshAnthropicToken(refreshToken, signal) {
|
|
199
|
+
let responseBody;
|
|
200
|
+
try {
|
|
201
|
+
responseBody = await postJson(TOKEN_URL, {
|
|
202
|
+
grant_type: "refresh_token",
|
|
203
|
+
client_id: CLIENT_ID,
|
|
204
|
+
refresh_token: refreshToken
|
|
205
|
+
}, signal);
|
|
206
|
+
} catch (error) {
|
|
207
|
+
throw new Error(`Anthropic token refresh request failed. url=${TOKEN_URL}; details=${formatErrorDetails(error)}`);
|
|
208
|
+
}
|
|
209
|
+
let data;
|
|
210
|
+
try {
|
|
211
|
+
data = JSON.parse(responseBody);
|
|
212
|
+
} catch (error) {
|
|
213
|
+
throw new Error(`Anthropic token refresh returned invalid JSON. url=${TOKEN_URL}; body=${responseBody}; details=${formatErrorDetails(error)}`);
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
type: "oauth",
|
|
217
|
+
refresh: data.refresh_token,
|
|
218
|
+
access: data.access_token,
|
|
219
|
+
expires: Date.now() + data.expires_in * 1e3 - 5 * 60 * 1e3
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
var anthropicOAuth = {
|
|
223
|
+
name: "Anthropic (Claude Pro/Max)",
|
|
224
|
+
isSubscription: true,
|
|
225
|
+
async login(interaction) {
|
|
226
|
+
const method = await interaction.prompt({
|
|
227
|
+
type: "select",
|
|
228
|
+
message: "Select Anthropic login method:",
|
|
229
|
+
options: [
|
|
230
|
+
{ id: ANTHROPIC_BROWSER_LOGIN_METHOD, label: "Browser login (default)" },
|
|
231
|
+
{ id: ANTHROPIC_COPY_CODE_LOGIN_METHOD, label: "Copy code login (headless)" }
|
|
232
|
+
]
|
|
233
|
+
});
|
|
234
|
+
if (method === ANTHROPIC_COPY_CODE_LOGIN_METHOD) {
|
|
235
|
+
return loginAnthropicCopyCode(interaction);
|
|
236
|
+
}
|
|
237
|
+
if (method !== ANTHROPIC_BROWSER_LOGIN_METHOD) {
|
|
238
|
+
throw new Error(`Unknown Anthropic login method: ${method}`);
|
|
239
|
+
}
|
|
240
|
+
return loginAnthropic(interaction);
|
|
241
|
+
},
|
|
242
|
+
refresh: (credential, signal) => refreshAnthropicToken(credential.refresh, signal),
|
|
243
|
+
async toAuth(credential) {
|
|
244
|
+
return { apiKey: credential.access };
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
export {
|
|
248
|
+
anthropicOAuth
|
|
249
|
+
};
|