@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
|
@@ -5,51 +5,52 @@ import {
|
|
|
5
5
|
convertResponsesTools,
|
|
6
6
|
getResponsesToolSupport,
|
|
7
7
|
processResponsesStream
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-IRRR3PWN.js";
|
|
9
9
|
import {
|
|
10
10
|
resolveAzureConfig,
|
|
11
11
|
resolveDeploymentName
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-FCAIYPDJ.js";
|
|
13
13
|
import {
|
|
14
14
|
clampOpenAIPromptCacheKey
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-KSZJ3HGD.js";
|
|
15
|
+
} from "./chunk-KUFIFCB4.js";
|
|
17
16
|
import {
|
|
18
17
|
AzureOpenAI
|
|
19
18
|
} from "./chunk-NW3DH7IK.js";
|
|
20
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-LP4APBBQ.js";
|
|
21
20
|
import {
|
|
22
21
|
buildBaseOptions,
|
|
23
22
|
createGrammarToolInputProperties,
|
|
24
23
|
resolveSamplingParams
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-Z6AY5VOZ.js";
|
|
25
|
+
import "./chunk-TSAUBRRU.js";
|
|
26
|
+
import {
|
|
27
|
+
retryProviderRequest
|
|
28
|
+
} from "./chunk-3CZXUKLG.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-PVPJAGWR.js";
|
|
34
33
|
import {
|
|
35
34
|
headersToRecord
|
|
36
|
-
} from "./chunk-
|
|
37
|
-
import "./chunk-
|
|
35
|
+
} from "./chunk-6IHXVT5H.js";
|
|
36
|
+
import "./chunk-JBEWFFOK.js";
|
|
37
|
+
import "./chunk-BG2KGLIA.js";
|
|
38
38
|
import {
|
|
39
39
|
clampThinkingLevel,
|
|
40
40
|
getDeclaredTools,
|
|
41
41
|
resolveTranscript,
|
|
42
42
|
resolveTranscriptTools
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-W7LEYYFH.js";
|
|
44
44
|
import {
|
|
45
45
|
AssistantMessageEventStream
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-DDBE2VLT.js";
|
|
47
47
|
import {
|
|
48
48
|
getIdentityHeaders
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-Q3C7TQ2M.js";
|
|
50
|
+
import "./chunk-U5KGV63C.js";
|
|
50
51
|
import "./chunk-CWESUMYQ.js";
|
|
51
52
|
|
|
52
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
53
|
+
// 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/azure-openai-responses.js
|
|
53
54
|
var AZURE_TOOL_CALL_PROVIDERS = /* @__PURE__ */ new Set(["openai", "openai-codex", "opencode", "azure"]);
|
|
54
55
|
var OPENAI_RESPONSES_MIN_OUTPUT_TOKENS = 16;
|
|
55
56
|
function formatAzureOpenAIError(error) {
|
|
@@ -117,11 +118,6 @@ var stream = (model, context, options) => {
|
|
|
117
118
|
stream2.push({ type: "done", reason: output.stopReason, message: output });
|
|
118
119
|
stream2.end();
|
|
119
120
|
} catch (error) {
|
|
120
|
-
for (const block of output.content) {
|
|
121
|
-
delete block.index;
|
|
122
|
-
delete block.partialJson;
|
|
123
|
-
delete block.customInput;
|
|
124
|
-
}
|
|
125
121
|
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
126
122
|
output.errorMessage = formatAzureOpenAIError(error);
|
|
127
123
|
stream2.push({ type: "error", reason: output.stopReason, error: output });
|
|
@@ -183,7 +179,7 @@ function buildParams(model, context, options, deploymentName, grammarToolInputPr
|
|
|
183
179
|
model: deploymentName,
|
|
184
180
|
input: messages,
|
|
185
181
|
stream: true,
|
|
186
|
-
prompt_cache_key: clampOpenAIPromptCacheKey(options?.sessionId),
|
|
182
|
+
prompt_cache_key: model.compat?.promptCacheKeyMode === "disabled" ? void 0 : clampOpenAIPromptCacheKey(options?.sessionId),
|
|
187
183
|
store: false
|
|
188
184
|
};
|
|
189
185
|
if (options?.maxTokens) {
|
|
@@ -5,24 +5,25 @@ import {
|
|
|
5
5
|
} from "./chunk-NW3DH7IK.js";
|
|
6
6
|
import {
|
|
7
7
|
sanitizeSurrogates
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TSAUBRRU.js";
|
|
9
|
+
import {
|
|
10
|
+
retryProviderRequest
|
|
11
|
+
} from "./chunk-3CZXUKLG.js";
|
|
9
12
|
import {
|
|
10
13
|
formatProviderError,
|
|
11
14
|
normalizeProviderError
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import {
|
|
14
|
-
retryProviderRequest
|
|
15
|
-
} from "./chunk-SQ7CWNIT.js";
|
|
15
|
+
} from "./chunk-PVPJAGWR.js";
|
|
16
16
|
import {
|
|
17
17
|
headersToRecord,
|
|
18
18
|
providerHeadersToRecord
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-6IHXVT5H.js";
|
|
20
20
|
import {
|
|
21
21
|
getIdentityHeaders
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-Q3C7TQ2M.js";
|
|
23
|
+
import "./chunk-U5KGV63C.js";
|
|
23
24
|
import "./chunk-CWESUMYQ.js";
|
|
24
25
|
|
|
25
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
26
|
+
// 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/openrouter-images.js
|
|
26
27
|
var generateImages = async (model, context, options) => {
|
|
27
28
|
const output = {
|
|
28
29
|
api: model.api,
|
|
@@ -140,7 +141,8 @@ function parseUsage(rawUsage, model) {
|
|
|
140
141
|
output: model.cost.output / 1e6 * output,
|
|
141
142
|
cacheRead: model.cost.cacheRead / 1e6 * cacheReadTokens,
|
|
142
143
|
cacheWrite: model.cost.cacheWrite / 1e6 * cacheWriteTokens,
|
|
143
|
-
total: 0
|
|
144
|
+
total: 0,
|
|
145
|
+
totalFromProvider: false
|
|
144
146
|
}
|
|
145
147
|
};
|
|
146
148
|
usage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
2
|
const require = __nerveCreateRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
parseStreamingJson
|
|
5
|
-
} from "./chunk-RUZ2UAYH.js";
|
|
6
3
|
import {
|
|
7
4
|
headersToRecord,
|
|
8
5
|
providerHeadersToRecord
|
|
9
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6IHXVT5H.js";
|
|
10
7
|
import {
|
|
11
8
|
getProviderEnvValue
|
|
12
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JBEWFFOK.js";
|
|
10
|
+
import {
|
|
11
|
+
ToolCallArgumentsStream
|
|
12
|
+
} from "./chunk-BG2KGLIA.js";
|
|
13
13
|
import {
|
|
14
14
|
AssistantMessageEventStream,
|
|
15
15
|
appendAssistantMessageDiagnostic,
|
|
16
16
|
createAssistantMessageDiagnostic
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-DDBE2VLT.js";
|
|
18
18
|
import {
|
|
19
19
|
getIdentityHeaders
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-Q3C7TQ2M.js";
|
|
21
|
+
import {
|
|
22
|
+
ownedSlice
|
|
23
|
+
} from "./chunk-U5KGV63C.js";
|
|
21
24
|
import "./chunk-CWESUMYQ.js";
|
|
22
25
|
|
|
23
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
26
|
+
// 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/pi-messages.js
|
|
24
27
|
var PiMessagesResponseError = class extends Error {
|
|
25
28
|
code;
|
|
26
29
|
diagnosticDetails;
|
|
@@ -42,7 +45,7 @@ function parsePiMessagesErrorBody(body) {
|
|
|
42
45
|
}
|
|
43
46
|
function truncateDiagnosticString(value) {
|
|
44
47
|
const maxLength = 8192;
|
|
45
|
-
return value.length > maxLength ? `${value
|
|
48
|
+
return value.length > maxLength ? `${ownedSlice(value, 0, maxLength)}\u2026` : value;
|
|
46
49
|
}
|
|
47
50
|
function formatPiMessagesResponseError(response, body, errorBody) {
|
|
48
51
|
const message = typeof errorBody?.error?.message === "string" ? errorBody.error.message : void 0;
|
|
@@ -97,8 +100,15 @@ function createEventConverter(model) {
|
|
|
97
100
|
stopReason: "pending",
|
|
98
101
|
timestamp: Date.now()
|
|
99
102
|
};
|
|
100
|
-
const
|
|
103
|
+
const toolArguments = /* @__PURE__ */ new Map();
|
|
101
104
|
return (event) => {
|
|
105
|
+
if ("contentIndex" in event) {
|
|
106
|
+
const index = event.contentIndex;
|
|
107
|
+
const limit = event.type.endsWith("_start") ? partial.content.length : partial.content.length - 1;
|
|
108
|
+
if (typeof index !== "number" || !Number.isInteger(index) || index < 0 || index > limit) {
|
|
109
|
+
throw new Error(`Invalid contentIndex ${JSON.stringify(index)} in pi-messages ${event.type} event`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
102
112
|
switch (event.type) {
|
|
103
113
|
case "done":
|
|
104
114
|
Object.assign(partial, {
|
|
@@ -106,6 +116,9 @@ function createEventConverter(model) {
|
|
|
106
116
|
usage: event.usage,
|
|
107
117
|
responseId: event.responseId
|
|
108
118
|
});
|
|
119
|
+
if (event.responseModel !== void 0) {
|
|
120
|
+
partial.responseModel = event.responseModel;
|
|
121
|
+
}
|
|
109
122
|
if (event.providerThinkingLevel !== void 0) {
|
|
110
123
|
partial.providerThinkingLevel = event.providerThinkingLevel;
|
|
111
124
|
}
|
|
@@ -118,6 +131,9 @@ function createEventConverter(model) {
|
|
|
118
131
|
errorMessage: event.errorMessage,
|
|
119
132
|
responseId: event.responseId
|
|
120
133
|
});
|
|
134
|
+
if (event.responseModel !== void 0) {
|
|
135
|
+
partial.responseModel = event.responseModel;
|
|
136
|
+
}
|
|
121
137
|
if (event.providerThinkingLevel !== void 0) {
|
|
122
138
|
partial.providerThinkingLevel = event.providerThinkingLevel;
|
|
123
139
|
}
|
|
@@ -157,17 +173,17 @@ function createEventConverter(model) {
|
|
|
157
173
|
name: event.toolName,
|
|
158
174
|
arguments: {}
|
|
159
175
|
};
|
|
160
|
-
|
|
176
|
+
toolArguments.set(event.contentIndex, new ToolCallArgumentsStream());
|
|
161
177
|
break;
|
|
162
178
|
case "toolcall_delta": {
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
179
|
+
const args = toolArguments.get(event.contentIndex);
|
|
180
|
+
if (args !== void 0)
|
|
181
|
+
partial.content[event.contentIndex].arguments = args.append(event.delta);
|
|
166
182
|
break;
|
|
167
183
|
}
|
|
168
184
|
case "toolcall_end":
|
|
169
185
|
Object.assign(partial.content[event.contentIndex], event.toolCall);
|
|
170
|
-
|
|
186
|
+
toolArguments.delete(event.contentIndex);
|
|
171
187
|
return {
|
|
172
188
|
type: "toolcall_end",
|
|
173
189
|
contentIndex: event.contentIndex,
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
2
|
const require = __nerveCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
ownedSlice
|
|
5
|
+
} from "./chunk-U5KGV63C.js";
|
|
3
6
|
|
|
4
|
-
// 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/error-body.js
|
|
5
8
|
var MAX_PROVIDER_ERROR_BODY_CHARS = 4e3;
|
|
6
9
|
function normalizeProviderError(error) {
|
|
7
10
|
if (!(error instanceof Error)) {
|
|
@@ -11,13 +14,33 @@ function normalizeProviderError(error) {
|
|
|
11
14
|
const status = extractStatus(sdkError);
|
|
12
15
|
const body = extractBody(sdkError);
|
|
13
16
|
const messageCarriesBody = body === void 0 || error.message.includes(body);
|
|
17
|
+
const message = status === void 0 && body === void 0 ? withCauseDetail(error) : error.message;
|
|
14
18
|
return {
|
|
15
19
|
status,
|
|
16
20
|
body,
|
|
17
|
-
message
|
|
21
|
+
message,
|
|
18
22
|
messageCarriesBody
|
|
19
23
|
};
|
|
20
24
|
}
|
|
25
|
+
var MAX_CAUSE_DEPTH = 5;
|
|
26
|
+
function withCauseDetail(error) {
|
|
27
|
+
let deepest;
|
|
28
|
+
let current = error.cause;
|
|
29
|
+
for (let depth = 0; depth < MAX_CAUSE_DEPTH && current instanceof Error; depth++) {
|
|
30
|
+
deepest = current;
|
|
31
|
+
current = current.cause;
|
|
32
|
+
}
|
|
33
|
+
if (!deepest)
|
|
34
|
+
return error.message;
|
|
35
|
+
let detail = (deepest.message || deepest.name).trim();
|
|
36
|
+
const code = deepest.code;
|
|
37
|
+
if ((typeof code === "string" || typeof code === "number") && !detail.includes(String(code))) {
|
|
38
|
+
detail = detail ? `${detail} (${code})` : String(code);
|
|
39
|
+
}
|
|
40
|
+
if (!detail || error.message.includes(detail))
|
|
41
|
+
return error.message;
|
|
42
|
+
return error.message ? `${error.message}: ${detail}` : detail;
|
|
43
|
+
}
|
|
21
44
|
function extractStatus(error) {
|
|
22
45
|
if (typeof error.statusCode === "number")
|
|
23
46
|
return error.statusCode;
|
|
@@ -72,7 +95,7 @@ function formatProviderError(norm, prefix) {
|
|
|
72
95
|
function truncateErrorText(text, maxChars) {
|
|
73
96
|
if (text.length <= maxChars)
|
|
74
97
|
return text;
|
|
75
|
-
return `${text
|
|
98
|
+
return `${ownedSlice(text, 0, maxChars)}... [truncated ${text.length - maxChars} chars]`;
|
|
76
99
|
}
|
|
77
100
|
function safeJsonStringify(value) {
|
|
78
101
|
try {
|
|
@@ -85,5 +108,7 @@ function safeJsonStringify(value) {
|
|
|
85
108
|
|
|
86
109
|
export {
|
|
87
110
|
normalizeProviderError,
|
|
88
|
-
|
|
111
|
+
withCauseDetail,
|
|
112
|
+
formatProviderError,
|
|
113
|
+
truncateErrorText
|
|
89
114
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
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.
|
|
5
|
-
var PI_AI_VERSION = "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/version.js
|
|
5
|
+
var PI_AI_VERSION = "1.5.2";
|
|
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/identity.js
|
|
8
8
|
var NVIDIA_NIM_HOST = "integrate.api.nvidia.com";
|
|
9
9
|
var OPENCODE_HOST = "opencode.ai";
|
|
10
10
|
function mergeClientIdentity(...sources) {
|
|
@@ -0,0 +1,14 @@
|
|
|
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.2_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_b842a8cec34a633ed5f728049ae89b72/node_modules/@earendil-works/pi-ai/dist/auth/oauth/trusted-url.js
|
|
5
|
+
function trustedHttpUrl(value) {
|
|
6
|
+
if (typeof value !== "string" || !URL.canParse(value))
|
|
7
|
+
return null;
|
|
8
|
+
const url = new URL(value);
|
|
9
|
+
return url.protocol === "https:" || url.protocol === "http:" ? url.href : null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
trustedHttpUrl
|
|
14
|
+
};
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
|
+
const require = __nerveCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
trustedHttpUrl
|
|
5
|
+
} from "./chunk-Q5E4ZL2R.js";
|
|
6
|
+
import {
|
|
7
|
+
pollOAuthDeviceCodeFlow
|
|
8
|
+
} from "./chunk-U3TEC52G.js";
|
|
9
|
+
import {
|
|
10
|
+
startOAuthCallbackServer
|
|
11
|
+
} from "./chunk-6GUJQURI.js";
|
|
12
|
+
import {
|
|
13
|
+
generatePKCE
|
|
14
|
+
} from "./chunk-BACYVEE6.js";
|
|
15
|
+
import {
|
|
16
|
+
normalizeRadiusGatewayUrl
|
|
17
|
+
} from "./chunk-62DQXVPO.js";
|
|
18
|
+
import "./chunk-U5KGV63C.js";
|
|
19
|
+
import "./chunk-CWESUMYQ.js";
|
|
20
|
+
|
|
21
|
+
// 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/radius.js
|
|
22
|
+
var CALLBACK_HOST = "127.0.0.1";
|
|
23
|
+
var CALLBACK_PORT = 1456;
|
|
24
|
+
var CALLBACK_PATH = "/oauth/callback";
|
|
25
|
+
var REDIRECT_URI = `http://${CALLBACK_HOST}:${CALLBACK_PORT}${CALLBACK_PATH}`;
|
|
26
|
+
var TOKEN_EXPIRY_SKEW_MS = 6e4;
|
|
27
|
+
var LOGIN_METHOD_BROWSER = "browser";
|
|
28
|
+
var LOGIN_METHOD_DEVICE_CODE = "device-code";
|
|
29
|
+
var OAUTH_CLIENT_ID = "pi-gateway";
|
|
30
|
+
var OAUTH_SCOPE = "gateway offline_access";
|
|
31
|
+
var OAUTH_DEVICE_CODE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
32
|
+
async function loadRadiusOAuthDiscovery(gateway, signal) {
|
|
33
|
+
const response = await fetch(new URL("/v1/oauth", gateway), {
|
|
34
|
+
headers: { accept: "application/json" },
|
|
35
|
+
signal
|
|
36
|
+
});
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
throw new Error(`Could not load Radius OAuth config from ${gateway}: ${response.status} ${await response.text()}`);
|
|
39
|
+
}
|
|
40
|
+
const discovery = await response.json();
|
|
41
|
+
const authorizationEndpoint = trustedHttpUrl(discovery.authorizationEndpoint);
|
|
42
|
+
if (!authorizationEndpoint) {
|
|
43
|
+
throw new Error(`Invalid Radius OAuth config from ${gateway}`);
|
|
44
|
+
}
|
|
45
|
+
return { authorizationEndpoint };
|
|
46
|
+
}
|
|
47
|
+
var OAuthResponseError = class extends Error {
|
|
48
|
+
status;
|
|
49
|
+
oauthError;
|
|
50
|
+
constructor(status, oauthError, description, message) {
|
|
51
|
+
const detail = oauthError ? description ? `${oauthError}: ${description}` : oauthError : description || String(status);
|
|
52
|
+
super(`${message}: ${detail}`);
|
|
53
|
+
this.status = status;
|
|
54
|
+
this.oauthError = oauthError;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
async function readOAuthResponseError(response, message) {
|
|
58
|
+
const text = await response.text().catch(() => "");
|
|
59
|
+
let oauthError;
|
|
60
|
+
let description;
|
|
61
|
+
if (text) {
|
|
62
|
+
try {
|
|
63
|
+
const data = JSON.parse(text);
|
|
64
|
+
oauthError = typeof data.error === "string" ? data.error : void 0;
|
|
65
|
+
description = typeof data.error_description === "string" ? data.error_description : void 0;
|
|
66
|
+
} catch {
|
|
67
|
+
description = text;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return new OAuthResponseError(response.status, oauthError, description, message);
|
|
71
|
+
}
|
|
72
|
+
async function requestOAuthToken(gateway, body, signal) {
|
|
73
|
+
let response;
|
|
74
|
+
try {
|
|
75
|
+
response = await fetch(new URL("/v1/oauth/token", gateway), {
|
|
76
|
+
method: "POST",
|
|
77
|
+
headers: { accept: "application/json", "content-type": "application/x-www-form-urlencoded" },
|
|
78
|
+
body,
|
|
79
|
+
signal
|
|
80
|
+
});
|
|
81
|
+
} catch (error) {
|
|
82
|
+
if (signal.aborted) {
|
|
83
|
+
throw new Error("Login cancelled");
|
|
84
|
+
}
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
if (!response.ok) {
|
|
88
|
+
throw await readOAuthResponseError(response, "Radius OAuth token request failed");
|
|
89
|
+
}
|
|
90
|
+
const data = await response.json();
|
|
91
|
+
return {
|
|
92
|
+
type: "oauth",
|
|
93
|
+
access: data.access_token,
|
|
94
|
+
refresh: data.refresh_token,
|
|
95
|
+
expires: Date.now() + data.expires_in * 1e3 - TOKEN_EXPIRY_SKEW_MS,
|
|
96
|
+
scope: data.scope
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
async function loginWithBrowser(gateway, authorizationEndpoint, interaction) {
|
|
100
|
+
const { verifier, challenge } = await generatePKCE();
|
|
101
|
+
const state = crypto.randomUUID();
|
|
102
|
+
const authorizeUrl = new URL(authorizationEndpoint);
|
|
103
|
+
authorizeUrl.search = new URLSearchParams({
|
|
104
|
+
response_type: "code",
|
|
105
|
+
client_id: OAUTH_CLIENT_ID,
|
|
106
|
+
redirect_uri: REDIRECT_URI,
|
|
107
|
+
scope: OAUTH_SCOPE,
|
|
108
|
+
code_challenge: challenge,
|
|
109
|
+
code_challenge_method: "S256",
|
|
110
|
+
handoff: "url",
|
|
111
|
+
state
|
|
112
|
+
}).toString();
|
|
113
|
+
const callback = await startOAuthCallbackServer({
|
|
114
|
+
providerName: "Radius",
|
|
115
|
+
host: CALLBACK_HOST,
|
|
116
|
+
port: CALLBACK_PORT,
|
|
117
|
+
path: CALLBACK_PATH,
|
|
118
|
+
state,
|
|
119
|
+
complete: (code) => requestOAuthToken(gateway, new URLSearchParams({
|
|
120
|
+
grant_type: "authorization_code",
|
|
121
|
+
client_id: OAUTH_CLIENT_ID,
|
|
122
|
+
redirect_uri: REDIRECT_URI,
|
|
123
|
+
code,
|
|
124
|
+
code_verifier: verifier
|
|
125
|
+
}), interaction.signal),
|
|
126
|
+
signal: interaction.signal
|
|
127
|
+
});
|
|
128
|
+
interaction.notify({ type: "progress", message: `Listening for OAuth callback on ${REDIRECT_URI}` });
|
|
129
|
+
interaction.notify({
|
|
130
|
+
type: "auth_url",
|
|
131
|
+
url: authorizeUrl.toString(),
|
|
132
|
+
instructions: "Continue in your browser."
|
|
133
|
+
});
|
|
134
|
+
try {
|
|
135
|
+
const credential = await callback.wait();
|
|
136
|
+
if (!credential)
|
|
137
|
+
throw new Error("OAuth callback did not complete.");
|
|
138
|
+
return credential;
|
|
139
|
+
} finally {
|
|
140
|
+
callback.close();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function requestDeviceAuthorization(gateway, signal) {
|
|
144
|
+
let response;
|
|
145
|
+
try {
|
|
146
|
+
response = await fetch(new URL("/v1/oauth/device", gateway), {
|
|
147
|
+
method: "POST",
|
|
148
|
+
headers: { accept: "application/json", "content-type": "application/x-www-form-urlencoded" },
|
|
149
|
+
body: new URLSearchParams({ client_id: OAUTH_CLIENT_ID, scope: OAUTH_SCOPE }),
|
|
150
|
+
signal
|
|
151
|
+
});
|
|
152
|
+
} catch (error) {
|
|
153
|
+
if (signal.aborted) {
|
|
154
|
+
throw new Error("Login cancelled");
|
|
155
|
+
}
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
if (!response.ok) {
|
|
159
|
+
throw await readOAuthResponseError(response, "Radius OAuth device authorization failed");
|
|
160
|
+
}
|
|
161
|
+
const data = await response.json();
|
|
162
|
+
if (!data.device_code || !data.user_code || !data.verification_uri || !data.expires_in) {
|
|
163
|
+
throw new Error("Radius OAuth device authorization response is missing required fields");
|
|
164
|
+
}
|
|
165
|
+
const verificationUri = trustedHttpUrl(data.verification_uri);
|
|
166
|
+
if (!verificationUri) {
|
|
167
|
+
throw new Error("Untrusted verification_uri in Radius OAuth device authorization response");
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
device_code: data.device_code,
|
|
171
|
+
user_code: data.user_code,
|
|
172
|
+
verification_uri: verificationUri,
|
|
173
|
+
expires_in: data.expires_in,
|
|
174
|
+
interval: data.interval
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
async function loginWithDeviceCode(gateway, interaction) {
|
|
178
|
+
const device = await requestDeviceAuthorization(gateway, interaction.signal);
|
|
179
|
+
interaction.notify({
|
|
180
|
+
type: "device_code",
|
|
181
|
+
userCode: device.user_code,
|
|
182
|
+
verificationUri: device.verification_uri,
|
|
183
|
+
intervalSeconds: device.interval,
|
|
184
|
+
expiresInSeconds: device.expires_in
|
|
185
|
+
});
|
|
186
|
+
return pollOAuthDeviceCodeFlow({
|
|
187
|
+
intervalSeconds: device.interval,
|
|
188
|
+
expiresInSeconds: device.expires_in,
|
|
189
|
+
signal: interaction.signal,
|
|
190
|
+
poll: async () => {
|
|
191
|
+
try {
|
|
192
|
+
const credentials = await requestOAuthToken(gateway, new URLSearchParams({
|
|
193
|
+
grant_type: OAUTH_DEVICE_CODE_GRANT_TYPE,
|
|
194
|
+
client_id: OAUTH_CLIENT_ID,
|
|
195
|
+
device_code: device.device_code
|
|
196
|
+
}), interaction.signal);
|
|
197
|
+
return { status: "complete", value: credentials };
|
|
198
|
+
} catch (error) {
|
|
199
|
+
if (!(error instanceof OAuthResponseError)) {
|
|
200
|
+
throw error;
|
|
201
|
+
}
|
|
202
|
+
switch (error.oauthError) {
|
|
203
|
+
case "authorization_pending":
|
|
204
|
+
return { status: "pending" };
|
|
205
|
+
case "slow_down":
|
|
206
|
+
return { status: "slow_down" };
|
|
207
|
+
case "expired_token":
|
|
208
|
+
return { status: "failed", message: "Device authorization expired." };
|
|
209
|
+
case "access_denied":
|
|
210
|
+
return { status: "failed", message: "Device authorization was denied." };
|
|
211
|
+
default:
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function createRadiusOAuth(options) {
|
|
219
|
+
const gateway = normalizeRadiusGatewayUrl(options.gateway);
|
|
220
|
+
return {
|
|
221
|
+
name: options.name,
|
|
222
|
+
async login(interaction) {
|
|
223
|
+
const loginMethod = await interaction.prompt({
|
|
224
|
+
type: "select",
|
|
225
|
+
message: `Sign in to ${options.name}:`,
|
|
226
|
+
options: [
|
|
227
|
+
{ id: LOGIN_METHOD_BROWSER, label: "Sign in with browser (recommended)" },
|
|
228
|
+
{
|
|
229
|
+
id: LOGIN_METHOD_DEVICE_CODE,
|
|
230
|
+
label: "Sign in with device code (when signing in from another device)"
|
|
231
|
+
}
|
|
232
|
+
]
|
|
233
|
+
});
|
|
234
|
+
if (loginMethod === LOGIN_METHOD_DEVICE_CODE) {
|
|
235
|
+
return loginWithDeviceCode(gateway, interaction);
|
|
236
|
+
}
|
|
237
|
+
if (loginMethod === LOGIN_METHOD_BROWSER) {
|
|
238
|
+
const discovery = await loadRadiusOAuthDiscovery(gateway, interaction.signal);
|
|
239
|
+
return loginWithBrowser(gateway, discovery.authorizationEndpoint, interaction);
|
|
240
|
+
}
|
|
241
|
+
throw new Error(`Unknown ${options.name} sign-in method: ${loginMethod}`);
|
|
242
|
+
},
|
|
243
|
+
async refresh(credential, signal) {
|
|
244
|
+
const refreshed = await requestOAuthToken(gateway, new URLSearchParams({
|
|
245
|
+
grant_type: "refresh_token",
|
|
246
|
+
client_id: OAUTH_CLIENT_ID,
|
|
247
|
+
refresh_token: credential.refresh
|
|
248
|
+
}), signal);
|
|
249
|
+
return refreshed;
|
|
250
|
+
},
|
|
251
|
+
async toAuth(credential) {
|
|
252
|
+
return { apiKey: credential.access };
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
export {
|
|
257
|
+
createRadiusOAuth
|
|
258
|
+
};
|