@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
|
@@ -2,43 +2,47 @@ import { createRequire as __nerveCreateRequire } from "node:module";
|
|
|
2
2
|
const require = __nerveCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
combineAbortSignals
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ZUWBEV2O.js";
|
|
6
6
|
import {
|
|
7
7
|
shortHash
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import {
|
|
10
|
-
parseStreamingJson,
|
|
11
|
-
parseToolCallArguments
|
|
12
|
-
} from "./chunk-RUZ2UAYH.js";
|
|
8
|
+
} from "./chunk-LP4APBBQ.js";
|
|
13
9
|
import {
|
|
14
10
|
buildBaseOptions,
|
|
15
11
|
getJsonSchemaToolParameters,
|
|
16
12
|
resolveJsonSchemaStrictSampling,
|
|
17
13
|
transformMessages
|
|
18
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-Z6AY5VOZ.js";
|
|
19
15
|
import {
|
|
20
16
|
sanitizeSurrogates
|
|
21
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-TSAUBRRU.js";
|
|
18
|
+
import {
|
|
19
|
+
truncateErrorText
|
|
20
|
+
} from "./chunk-PVPJAGWR.js";
|
|
22
21
|
import {
|
|
23
22
|
headersToRecord
|
|
24
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-6IHXVT5H.js";
|
|
24
|
+
import {
|
|
25
|
+
ToolCallArgumentsStream
|
|
26
|
+
} from "./chunk-BG2KGLIA.js";
|
|
25
27
|
import {
|
|
26
28
|
calculateCost,
|
|
27
29
|
clampThinkingLevel,
|
|
28
30
|
getCurrentTools,
|
|
29
|
-
getSystemMessageText,
|
|
30
|
-
renderSystemMessageUpdate,
|
|
31
31
|
resolveTranscript
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-W7LEYYFH.js";
|
|
33
33
|
import {
|
|
34
34
|
AssistantMessageEventStream
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-DDBE2VLT.js";
|
|
36
36
|
import {
|
|
37
37
|
getIdentityHeaders
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-Q3C7TQ2M.js";
|
|
39
|
+
import {
|
|
40
|
+
getSystemMessageText,
|
|
41
|
+
renderSystemMessageUpdate
|
|
42
|
+
} from "./chunk-U5KGV63C.js";
|
|
39
43
|
import "./chunk-CWESUMYQ.js";
|
|
40
44
|
|
|
41
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
45
|
+
// 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/mistral-conversations.js
|
|
42
46
|
var MISTRAL_TOOL_CALL_ID_LENGTH = 9;
|
|
43
47
|
var MAX_MISTRAL_ERROR_BODY_CHARS = 4e3;
|
|
44
48
|
var stream = (model, context, options) => {
|
|
@@ -73,9 +77,6 @@ var stream = (model, context, options) => {
|
|
|
73
77
|
stream2.push({ type: "done", reason: output.stopReason, message: output });
|
|
74
78
|
stream2.end();
|
|
75
79
|
} catch (error) {
|
|
76
|
-
for (const block of output.content) {
|
|
77
|
-
delete block.partialArgs;
|
|
78
|
-
}
|
|
79
80
|
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
80
81
|
output.errorMessage = formatMistralError(error);
|
|
81
82
|
stream2.push({ type: "error", reason: output.stopReason, error: output });
|
|
@@ -164,11 +165,6 @@ function formatMistralError(error) {
|
|
|
164
165
|
}
|
|
165
166
|
return safeJsonStringify(error);
|
|
166
167
|
}
|
|
167
|
-
function truncateErrorText(text, maxChars) {
|
|
168
|
-
if (text.length <= maxChars)
|
|
169
|
-
return text;
|
|
170
|
-
return `${text.slice(0, maxChars)}... [truncated ${text.length - maxChars} chars]`;
|
|
171
|
-
}
|
|
172
168
|
function safeJsonStringify(value) {
|
|
173
169
|
try {
|
|
174
170
|
const serialized = JSON.stringify(value);
|
|
@@ -414,7 +410,7 @@ async function consumeChatStream(model, output, stream2, mistralStream, onProvid
|
|
|
414
410
|
let currentBlock = null;
|
|
415
411
|
const blocks = output.content;
|
|
416
412
|
const blockIndex = () => blocks.length - 1;
|
|
417
|
-
const
|
|
413
|
+
const toolCallsByKey = /* @__PURE__ */ new Map();
|
|
418
414
|
const finishCurrentBlock = (block) => {
|
|
419
415
|
if (!block)
|
|
420
416
|
return;
|
|
@@ -532,49 +528,31 @@ async function consumeChatStream(model, output, stream2, mistralStream, onProvid
|
|
|
532
528
|
}
|
|
533
529
|
const callId = toolCall.id && toolCall.id !== "null" ? toolCall.id : deriveMistralToolCallId(`toolcall:${toolCall.index ?? 0}`, 0);
|
|
534
530
|
const key = toolCall.index ?? callId;
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
if (!block) {
|
|
544
|
-
block = {
|
|
545
|
-
type: "toolCall",
|
|
546
|
-
id: callId,
|
|
547
|
-
name: toolCall.function.name,
|
|
548
|
-
arguments: {},
|
|
549
|
-
partialArgs: ""
|
|
550
|
-
};
|
|
551
|
-
output.content.push(block);
|
|
552
|
-
toolBlocksByKey.set(key, output.content.length - 1);
|
|
553
|
-
stream2.push({ type: "toolcall_start", contentIndex: output.content.length - 1, partial: output });
|
|
531
|
+
let open = toolCallsByKey.get(key);
|
|
532
|
+
if (!open) {
|
|
533
|
+
output.content.push({ type: "toolCall", id: callId, name: toolCall.function.name, arguments: {} });
|
|
534
|
+
open = { contentIndex: output.content.length - 1, arguments: new ToolCallArgumentsStream() };
|
|
535
|
+
toolCallsByKey.set(key, open);
|
|
536
|
+
stream2.push({ type: "toolcall_start", contentIndex: open.contentIndex, partial: output });
|
|
554
537
|
}
|
|
555
538
|
const argsDelta = typeof toolCall.function.arguments === "string" ? toolCall.function.arguments : JSON.stringify(toolCall.function.arguments || {});
|
|
556
|
-
|
|
557
|
-
block.arguments = parseStreamingJson(block.partialArgs);
|
|
539
|
+
output.content[open.contentIndex].arguments = open.arguments.append(argsDelta);
|
|
558
540
|
stream2.push({
|
|
559
541
|
type: "toolcall_delta",
|
|
560
|
-
contentIndex:
|
|
542
|
+
contentIndex: open.contentIndex,
|
|
561
543
|
delta: argsDelta,
|
|
562
544
|
partial: output
|
|
563
545
|
});
|
|
564
546
|
}
|
|
565
547
|
}
|
|
566
548
|
finishCurrentBlock(currentBlock);
|
|
567
|
-
for (const
|
|
568
|
-
const block = output.content[
|
|
569
|
-
|
|
570
|
-
continue;
|
|
571
|
-
const toolBlock = block;
|
|
572
|
-
Object.assign(toolBlock, parseToolCallArguments(toolBlock.partialArgs));
|
|
573
|
-
delete toolBlock.partialArgs;
|
|
549
|
+
for (const open of toolCallsByKey.values()) {
|
|
550
|
+
const block = output.content[open.contentIndex];
|
|
551
|
+
Object.assign(block, open.arguments.finish());
|
|
574
552
|
stream2.push({
|
|
575
553
|
type: "toolcall_end",
|
|
576
|
-
contentIndex:
|
|
577
|
-
toolCall:
|
|
554
|
+
contentIndex: open.contentIndex,
|
|
555
|
+
toolCall: block,
|
|
578
556
|
partial: output
|
|
579
557
|
});
|
|
580
558
|
}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
__require
|
|
5
5
|
} from "./chunk-CWESUMYQ.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/provider-env.js
|
|
8
8
|
var procEnvCache = null;
|
|
9
9
|
function getBunSandboxEnvValue(name) {
|
|
10
10
|
if (typeof process === "undefined" || !process.versions?.bun || Object.keys(process.env).length > 0) {
|
|
@@ -7,18 +7,18 @@ import {
|
|
|
7
7
|
getJsonSchemaToolParameters,
|
|
8
8
|
resolveJsonSchemaStrictSampling,
|
|
9
9
|
transformMessages
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-Z6AY5VOZ.js";
|
|
11
11
|
import {
|
|
12
12
|
sanitizeSurrogates
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-TSAUBRRU.js";
|
|
14
14
|
import {
|
|
15
15
|
retryProviderRequest
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-3CZXUKLG.js";
|
|
17
17
|
import {
|
|
18
18
|
clampThinkingLevel,
|
|
19
19
|
collapseSystemMessages,
|
|
20
20
|
withoutInitialSystemMessage
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-W7LEYYFH.js";
|
|
22
22
|
import {
|
|
23
23
|
__commonJS,
|
|
24
24
|
__require,
|
|
@@ -33283,7 +33283,7 @@ function getApiKeyFromEnv() {
|
|
|
33283
33283
|
return envGoogleApiKey || envGeminiApiKey || void 0;
|
|
33284
33284
|
}
|
|
33285
33285
|
|
|
33286
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
33286
|
+
// 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-shared.js
|
|
33287
33287
|
var GOOGLE_SDK_THINKING_LEVEL_MAP = {
|
|
33288
33288
|
THINKING_LEVEL_UNSPECIFIED: ThinkingLevel.THINKING_LEVEL_UNSPECIFIED,
|
|
33289
33289
|
MINIMAL: ThinkingLevel.MINIMAL,
|
|
@@ -33524,6 +33524,53 @@ function sanitizeForOpenApi(schema) {
|
|
|
33524
33524
|
}
|
|
33525
33525
|
return result;
|
|
33526
33526
|
}
|
|
33527
|
+
var JSON_SCHEMA_NAME_MAPS = /* @__PURE__ */ new Set([
|
|
33528
|
+
"properties",
|
|
33529
|
+
"patternProperties",
|
|
33530
|
+
"$defs",
|
|
33531
|
+
"definitions",
|
|
33532
|
+
"dependentSchemas",
|
|
33533
|
+
"dependencies"
|
|
33534
|
+
]);
|
|
33535
|
+
var JSON_SCHEMA_SUBSCHEMAS = /* @__PURE__ */ new Set([
|
|
33536
|
+
"additionalProperties",
|
|
33537
|
+
"unevaluatedProperties",
|
|
33538
|
+
"propertyNames",
|
|
33539
|
+
"items",
|
|
33540
|
+
"prefixItems",
|
|
33541
|
+
"additionalItems",
|
|
33542
|
+
"unevaluatedItems",
|
|
33543
|
+
"contains",
|
|
33544
|
+
"allOf",
|
|
33545
|
+
"anyOf",
|
|
33546
|
+
"oneOf",
|
|
33547
|
+
"not",
|
|
33548
|
+
"if",
|
|
33549
|
+
"then",
|
|
33550
|
+
"else",
|
|
33551
|
+
"contentSchema"
|
|
33552
|
+
]);
|
|
33553
|
+
function rewriteConstAsEnum(schema, isNameMap = false) {
|
|
33554
|
+
if (Array.isArray(schema))
|
|
33555
|
+
return schema.map((item) => rewriteConstAsEnum(item));
|
|
33556
|
+
if (typeof schema !== "object" || schema === null)
|
|
33557
|
+
return schema;
|
|
33558
|
+
const result = Object.fromEntries(Object.entries(schema).map(([key, value]) => {
|
|
33559
|
+
if (isNameMap || JSON_SCHEMA_SUBSCHEMAS.has(key))
|
|
33560
|
+
return [key, rewriteConstAsEnum(value)];
|
|
33561
|
+
if (JSON_SCHEMA_NAME_MAPS.has(key))
|
|
33562
|
+
return [key, rewriteConstAsEnum(value, true)];
|
|
33563
|
+
return [key, value];
|
|
33564
|
+
}));
|
|
33565
|
+
if (!isNameMap && "const" in result && result.enum === void 0) {
|
|
33566
|
+
const value = result.const;
|
|
33567
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
33568
|
+
delete result.const;
|
|
33569
|
+
result.enum = [value];
|
|
33570
|
+
}
|
|
33571
|
+
}
|
|
33572
|
+
return result;
|
|
33573
|
+
}
|
|
33527
33574
|
function convertTools(tools, useParameters = false, supportsStrictMode = true) {
|
|
33528
33575
|
if (tools.length === 0)
|
|
33529
33576
|
return void 0;
|
|
@@ -33535,7 +33582,7 @@ function convertTools(tools, useParameters = false, supportsStrictMode = true) {
|
|
|
33535
33582
|
return {
|
|
33536
33583
|
name: tool.name,
|
|
33537
33584
|
description: tool.description,
|
|
33538
|
-
...useParameters ? { parameters: sanitizeForOpenApi(parameters) } : { parametersJsonSchema: parameters }
|
|
33585
|
+
...useParameters ? { parameters: sanitizeForOpenApi(parameters) } : { parametersJsonSchema: rewriteConstAsEnum(parameters) }
|
|
33539
33586
|
};
|
|
33540
33587
|
})
|
|
33541
33588
|
}
|
|
@@ -33630,4 +33677,4 @@ export {
|
|
|
33630
33677
|
mapStopReason,
|
|
33631
33678
|
retryGoogleRequest
|
|
33632
33679
|
};
|
|
33633
|
-
/*! For license information please see chunk-
|
|
33680
|
+
/*! For license information please see chunk-KEXKZKN4.js.LEGAL.txt */
|
|
@@ -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/api/openai-prompt-cache.js
|
|
5
5
|
var OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH = 64;
|
|
6
6
|
function clampOpenAIPromptCacheKey(key) {
|
|
7
7
|
if (key === void 0)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
|
+
const require = __nerveCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
registerSessionResourceCleanup
|
|
5
|
+
} from "./chunk-ZVH6EB7S.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/api/strict-tool-limits.js
|
|
8
|
+
var STRICT_TOOL_LIMIT_ERROR_MESSAGES = [
|
|
9
|
+
"The compiled grammar is too large",
|
|
10
|
+
"Too many strict tools (",
|
|
11
|
+
"Schemas contains too many parameters with union types ("
|
|
12
|
+
];
|
|
13
|
+
function isStrictToolLimitErrorMessage(message) {
|
|
14
|
+
return STRICT_TOOL_LIMIT_ERROR_MESSAGES.some((limitMessage) => message.includes(limitMessage));
|
|
15
|
+
}
|
|
16
|
+
var sessionsOverStrictToolLimits = /* @__PURE__ */ new Set();
|
|
17
|
+
var MAX_SESSIONS_OVER_STRICT_TOOL_LIMITS = 1e4;
|
|
18
|
+
function markStrictToolLimitsExceeded(sessionId) {
|
|
19
|
+
if (sessionId === void 0)
|
|
20
|
+
return;
|
|
21
|
+
sessionsOverStrictToolLimits.add(sessionId);
|
|
22
|
+
if (sessionsOverStrictToolLimits.size > MAX_SESSIONS_OVER_STRICT_TOOL_LIMITS) {
|
|
23
|
+
const oldest = sessionsOverStrictToolLimits.values().next().value;
|
|
24
|
+
if (oldest !== void 0)
|
|
25
|
+
sessionsOverStrictToolLimits.delete(oldest);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function hasExceededStrictToolLimits(sessionId) {
|
|
29
|
+
return sessionId !== void 0 && sessionsOverStrictToolLimits.has(sessionId);
|
|
30
|
+
}
|
|
31
|
+
registerSessionResourceCleanup((sessionId) => {
|
|
32
|
+
if (sessionId)
|
|
33
|
+
sessionsOverStrictToolLimits.delete(sessionId);
|
|
34
|
+
else
|
|
35
|
+
sessionsOverStrictToolLimits.clear();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
isStrictToolLimitErrorMessage,
|
|
40
|
+
markStrictToolLimitsExceeded,
|
|
41
|
+
hasExceededStrictToolLimits
|
|
42
|
+
};
|
|
@@ -16,42 +16,44 @@ import {
|
|
|
16
16
|
toGoogleSdkThinkingLevel,
|
|
17
17
|
toGoogleThinkingLevel,
|
|
18
18
|
usesGoogleThinkingLevel
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-KEXKZKN4.js";
|
|
20
20
|
import "./chunk-MXYQOFZ5.js";
|
|
21
21
|
import {
|
|
22
22
|
buildBaseOptions
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-Z6AY5VOZ.js";
|
|
24
24
|
import {
|
|
25
25
|
sanitizeSurrogates
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-TSAUBRRU.js";
|
|
27
|
+
import "./chunk-3CZXUKLG.js";
|
|
27
28
|
import {
|
|
28
29
|
formatProviderError,
|
|
29
30
|
normalizeProviderError
|
|
30
|
-
} from "./chunk-
|
|
31
|
-
import "./chunk-SQ7CWNIT.js";
|
|
31
|
+
} from "./chunk-PVPJAGWR.js";
|
|
32
32
|
import {
|
|
33
33
|
providerHeadersToRecord
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-6IHXVT5H.js";
|
|
35
35
|
import {
|
|
36
36
|
getProviderEnvValue
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-JBEWFFOK.js";
|
|
38
38
|
import {
|
|
39
39
|
calculateCost,
|
|
40
40
|
clampThinkingLevel,
|
|
41
41
|
collapseSystemMessages,
|
|
42
42
|
getCurrentTools,
|
|
43
|
-
getInitialSystemMessage
|
|
44
|
-
|
|
45
|
-
} from "./chunk-WXRYBXYR.js";
|
|
43
|
+
getInitialSystemMessage
|
|
44
|
+
} from "./chunk-W7LEYYFH.js";
|
|
46
45
|
import {
|
|
47
46
|
AssistantMessageEventStream
|
|
48
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-DDBE2VLT.js";
|
|
49
48
|
import {
|
|
50
49
|
getIdentityHeaders
|
|
51
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-Q3C7TQ2M.js";
|
|
51
|
+
import {
|
|
52
|
+
getSystemMessageText
|
|
53
|
+
} from "./chunk-U5KGV63C.js";
|
|
52
54
|
import "./chunk-CWESUMYQ.js";
|
|
53
55
|
|
|
54
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
56
|
+
// 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-vertex.js
|
|
55
57
|
var API_VERSION = "v1";
|
|
56
58
|
var GCP_VERTEX_CREDENTIALS_MARKER = "gcp-vertex-credentials";
|
|
57
59
|
var toolCallCounter = 0;
|
|
@@ -245,11 +247,6 @@ var stream = (model, context, options) => {
|
|
|
245
247
|
stream2.push({ type: "done", reason: output.stopReason, message: output });
|
|
246
248
|
stream2.end();
|
|
247
249
|
} catch (error) {
|
|
248
|
-
for (const block of output.content) {
|
|
249
|
-
if ("index" in block) {
|
|
250
|
-
delete block.index;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
250
|
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
254
251
|
output.errorMessage = formatProviderError(normalizeProviderError(error));
|
|
255
252
|
stream2.push({ type: "error", reason: output.stopReason, error: output });
|
|
@@ -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/hash.js
|
|
5
5
|
function shortHash(str) {
|
|
6
6
|
let h1 = 3735928559;
|
|
7
7
|
let h2 = 1103547991;
|
|
@@ -5539,7 +5539,7 @@ var EnvironmentWorker = /* @__PURE__ */ (() => {
|
|
|
5539
5539
|
const ctrl = new AbortController();
|
|
5540
5540
|
const detachExternal = linkAbort(externalSignal, ctrl);
|
|
5541
5541
|
const lease = new Lease(ctrl);
|
|
5542
|
-
const agentToolset = await import("./chunk-
|
|
5542
|
+
const agentToolset = await import("./chunk-AAEIGAGD.js");
|
|
5543
5543
|
let leaseTtlMs;
|
|
5544
5544
|
let runner;
|
|
5545
5545
|
const heartbeatPromise = heartbeatLoop(sessionClient, work, lease, log, this.requestOptions, (ttlMs) => {
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
|
+
const require = __nerveCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
pollOAuthDeviceCodeFlow
|
|
5
|
+
} from "./chunk-U3TEC52G.js";
|
|
6
|
+
import "./chunk-CWESUMYQ.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/xai.js
|
|
9
|
+
var XAI_CLIENT_ID = "b1a00492-073a-47ea-816f-4c329264a828";
|
|
10
|
+
var XAI_SCOPE = "openid profile email offline_access grok-cli:access api:access";
|
|
11
|
+
var XAI_DEVICE_CODE_URL = "https://auth.x.ai/oauth2/device/code";
|
|
12
|
+
var XAI_TOKEN_URL = "https://auth.x.ai/oauth2/token";
|
|
13
|
+
var REFRESH_SKEW_MS = 5 * 60 * 1e3;
|
|
14
|
+
var DEFAULT_TOKEN_LIFETIME_SECONDS = 3600;
|
|
15
|
+
function requiredString(body, field) {
|
|
16
|
+
const value = body[field];
|
|
17
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
18
|
+
throw new Error(`Invalid xAI OAuth response field: ${field}`);
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
function positiveNumber(body, field) {
|
|
23
|
+
const value = body[field];
|
|
24
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
25
|
+
throw new Error(`Invalid xAI OAuth response field: ${field}`);
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
function validateVerificationUri(raw) {
|
|
30
|
+
let url;
|
|
31
|
+
try {
|
|
32
|
+
url = new URL(raw);
|
|
33
|
+
} catch {
|
|
34
|
+
throw new Error("Untrusted verification URI in xAI OAuth response");
|
|
35
|
+
}
|
|
36
|
+
if (url.protocol !== "https:") {
|
|
37
|
+
throw new Error("Untrusted verification URI in xAI OAuth response");
|
|
38
|
+
}
|
|
39
|
+
return url.href;
|
|
40
|
+
}
|
|
41
|
+
async function postForm(url, fields, signal) {
|
|
42
|
+
let response;
|
|
43
|
+
try {
|
|
44
|
+
response = await fetch(url, {
|
|
45
|
+
method: "POST",
|
|
46
|
+
headers: {
|
|
47
|
+
Accept: "application/json",
|
|
48
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
49
|
+
},
|
|
50
|
+
body: new URLSearchParams(fields),
|
|
51
|
+
signal
|
|
52
|
+
});
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (signal.aborted) {
|
|
55
|
+
throw new Error("Login cancelled");
|
|
56
|
+
}
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
let body;
|
|
60
|
+
try {
|
|
61
|
+
const parsed = await response.json();
|
|
62
|
+
body = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
63
|
+
} catch {
|
|
64
|
+
if (signal.aborted) {
|
|
65
|
+
throw new Error("Login cancelled");
|
|
66
|
+
}
|
|
67
|
+
throw new Error(`xAI OAuth returned invalid JSON (HTTP ${response.status})`);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
ok: response.ok,
|
|
71
|
+
status: response.status,
|
|
72
|
+
body
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function requestFailure(action, response) {
|
|
76
|
+
const error = typeof response.body.error === "string" ? response.body.error : void 0;
|
|
77
|
+
const description = typeof response.body.error_description === "string" ? response.body.error_description : void 0;
|
|
78
|
+
const detail = [error, description].filter(Boolean).join(": ");
|
|
79
|
+
return new Error(`xAI OAuth ${action} failed (HTTP ${response.status})${detail ? `: ${detail}` : ""}`);
|
|
80
|
+
}
|
|
81
|
+
function parseDeviceCode(body) {
|
|
82
|
+
const interval = body.interval;
|
|
83
|
+
const intervalSeconds = typeof interval === "number" && Number.isFinite(interval) && interval > 0 ? interval : void 0;
|
|
84
|
+
const verificationUriComplete = typeof body.verification_uri_complete === "string" && body.verification_uri_complete.length > 0 ? validateVerificationUri(body.verification_uri_complete) : void 0;
|
|
85
|
+
return {
|
|
86
|
+
deviceCode: requiredString(body, "device_code"),
|
|
87
|
+
userCode: requiredString(body, "user_code"),
|
|
88
|
+
verificationUri: validateVerificationUri(requiredString(body, "verification_uri")),
|
|
89
|
+
verificationUriComplete,
|
|
90
|
+
intervalSeconds,
|
|
91
|
+
expiresInSeconds: positiveNumber(body, "expires_in")
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function credentialsFromTokenResponse(body, previousRefreshToken) {
|
|
95
|
+
const access = requiredString(body, "access_token");
|
|
96
|
+
const refresh = body.refresh_token === void 0 && previousRefreshToken ? previousRefreshToken : requiredString(body, "refresh_token");
|
|
97
|
+
const expiresInSeconds = body.expires_in === void 0 ? DEFAULT_TOKEN_LIFETIME_SECONDS : positiveNumber(body, "expires_in");
|
|
98
|
+
return {
|
|
99
|
+
type: "oauth",
|
|
100
|
+
access,
|
|
101
|
+
refresh,
|
|
102
|
+
expires: Date.now() + expiresInSeconds * 1e3 - REFRESH_SKEW_MS
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
async function requestDeviceCode(signal) {
|
|
106
|
+
const response = await postForm(XAI_DEVICE_CODE_URL, {
|
|
107
|
+
client_id: XAI_CLIENT_ID,
|
|
108
|
+
scope: XAI_SCOPE,
|
|
109
|
+
referrer: "pi"
|
|
110
|
+
}, signal);
|
|
111
|
+
if (!response.ok) {
|
|
112
|
+
throw requestFailure("device authorization", response);
|
|
113
|
+
}
|
|
114
|
+
return parseDeviceCode(response.body);
|
|
115
|
+
}
|
|
116
|
+
async function pollForTokens(device, signal) {
|
|
117
|
+
return pollOAuthDeviceCodeFlow({
|
|
118
|
+
intervalSeconds: device.intervalSeconds,
|
|
119
|
+
expiresInSeconds: device.expiresInSeconds,
|
|
120
|
+
waitBeforeFirstPoll: true,
|
|
121
|
+
signal,
|
|
122
|
+
poll: async () => {
|
|
123
|
+
const response = await postForm(XAI_TOKEN_URL, {
|
|
124
|
+
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
125
|
+
client_id: XAI_CLIENT_ID,
|
|
126
|
+
device_code: device.deviceCode
|
|
127
|
+
}, signal);
|
|
128
|
+
if (response.ok) {
|
|
129
|
+
return { status: "complete", value: credentialsFromTokenResponse(response.body) };
|
|
130
|
+
}
|
|
131
|
+
const error = response.body.error;
|
|
132
|
+
if (error === "authorization_pending") {
|
|
133
|
+
return { status: "pending" };
|
|
134
|
+
}
|
|
135
|
+
if (error === "slow_down") {
|
|
136
|
+
const interval = response.body.interval;
|
|
137
|
+
return { status: "slow_down", intervalSeconds: typeof interval === "number" ? interval : void 0 };
|
|
138
|
+
}
|
|
139
|
+
if (error === "access_denied" || error === "authorization_denied") {
|
|
140
|
+
return { status: "failed", message: "xAI device authorization was denied" };
|
|
141
|
+
}
|
|
142
|
+
if (error === "expired_token") {
|
|
143
|
+
return { status: "failed", message: "xAI device code expired" };
|
|
144
|
+
}
|
|
145
|
+
return { status: "failed", message: requestFailure("device token polling", response).message };
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
async function loginXai(interaction) {
|
|
150
|
+
const device = await requestDeviceCode(interaction.signal);
|
|
151
|
+
interaction.notify({
|
|
152
|
+
type: "device_code",
|
|
153
|
+
userCode: device.userCode,
|
|
154
|
+
verificationUri: device.verificationUriComplete ?? device.verificationUri,
|
|
155
|
+
intervalSeconds: device.intervalSeconds,
|
|
156
|
+
expiresInSeconds: device.expiresInSeconds
|
|
157
|
+
});
|
|
158
|
+
return pollForTokens(device, interaction.signal);
|
|
159
|
+
}
|
|
160
|
+
async function refreshXaiToken(refreshToken, signal) {
|
|
161
|
+
const response = await postForm(XAI_TOKEN_URL, {
|
|
162
|
+
grant_type: "refresh_token",
|
|
163
|
+
client_id: XAI_CLIENT_ID,
|
|
164
|
+
refresh_token: refreshToken
|
|
165
|
+
}, signal);
|
|
166
|
+
if (!response.ok) {
|
|
167
|
+
throw requestFailure("token refresh", response);
|
|
168
|
+
}
|
|
169
|
+
return credentialsFromTokenResponse(response.body, refreshToken);
|
|
170
|
+
}
|
|
171
|
+
var xaiOAuth = {
|
|
172
|
+
name: "xAI (Grok/X subscription)",
|
|
173
|
+
isSubscription: true,
|
|
174
|
+
loginLabel: "Sign in with SuperGrok or X Premium",
|
|
175
|
+
login: loginXai,
|
|
176
|
+
refresh: (credential, signal) => refreshXaiToken(credential.refresh, signal),
|
|
177
|
+
async toAuth(credential) {
|
|
178
|
+
return { apiKey: credential.access };
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
export {
|
|
182
|
+
xaiOAuth
|
|
183
|
+
};
|
|
@@ -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.2_@aws-sdk+credential-provider-node@3.972.83_@smithy+signatur_b842a8cec34a633ed5f728049ae89b72/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
|
+
};
|