@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
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
|
+
const require = __nerveCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
sleep
|
|
5
|
+
} from "./chunk-WC5HHPPM.js";
|
|
6
|
+
import {
|
|
7
|
+
trustedHttpUrl
|
|
8
|
+
} from "./chunk-Q5E4ZL2R.js";
|
|
9
|
+
import {
|
|
10
|
+
pollOAuthDeviceCodeFlow
|
|
11
|
+
} from "./chunk-U3TEC52G.js";
|
|
12
|
+
import {
|
|
13
|
+
getProviderEnvValue
|
|
14
|
+
} from "./chunk-JBEWFFOK.js";
|
|
15
|
+
import "./chunk-CWESUMYQ.js";
|
|
16
|
+
|
|
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/auth/oauth/kimi-coding.js
|
|
18
|
+
var CLIENT_ID = "17e5f671-d194-4dfb-9706-5516cb48c098";
|
|
19
|
+
var DEFAULT_OAUTH_HOST = "https://auth.kimi.com";
|
|
20
|
+
var DEVICE_CODE_TIMEOUT_SECONDS = 15 * 60;
|
|
21
|
+
var DEFAULT_POLL_INTERVAL_SECONDS = 5;
|
|
22
|
+
var REQUEST_TIMEOUT_MS = 30 * 1e3;
|
|
23
|
+
var REFRESH_MAX_RETRIES = 3;
|
|
24
|
+
function getOauthHost() {
|
|
25
|
+
const override = getProviderEnvValue("KIMI_CODE_OAUTH_HOST") || getProviderEnvValue("KIMI_OAUTH_HOST");
|
|
26
|
+
return (override || DEFAULT_OAUTH_HOST).replace(/\/+$/, "");
|
|
27
|
+
}
|
|
28
|
+
function requestSignal(signal) {
|
|
29
|
+
return AbortSignal.any([AbortSignal.timeout(REQUEST_TIMEOUT_MS), signal]);
|
|
30
|
+
}
|
|
31
|
+
function formUrlEncode(fields) {
|
|
32
|
+
return new URLSearchParams(fields).toString();
|
|
33
|
+
}
|
|
34
|
+
async function readJson(response) {
|
|
35
|
+
try {
|
|
36
|
+
const json = await response.json();
|
|
37
|
+
return json && typeof json === "object" ? json : null;
|
|
38
|
+
} catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function startDeviceAuthorization(oauthHost, signal) {
|
|
43
|
+
const response = await fetch(`${oauthHost}/api/oauth/device_authorization`, {
|
|
44
|
+
method: "POST",
|
|
45
|
+
headers: {
|
|
46
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
47
|
+
Accept: "application/json"
|
|
48
|
+
},
|
|
49
|
+
body: formUrlEncode({ client_id: CLIENT_ID }),
|
|
50
|
+
signal: requestSignal(signal)
|
|
51
|
+
});
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
const text = await response.text().catch(() => "");
|
|
54
|
+
throw new Error(`Kimi Code device authorization failed with status ${response.status}${text ? `: ${text}` : ""}`);
|
|
55
|
+
}
|
|
56
|
+
const json = await readJson(response);
|
|
57
|
+
const deviceCode = json?.device_code;
|
|
58
|
+
const userCode = json?.user_code;
|
|
59
|
+
const verificationUri = trustedHttpUrl(json?.verification_uri);
|
|
60
|
+
const verificationUriComplete = trustedHttpUrl(json?.verification_uri_complete);
|
|
61
|
+
if (typeof deviceCode !== "string" || typeof userCode !== "string" || !verificationUri || !verificationUriComplete) {
|
|
62
|
+
throw new Error(`Invalid Kimi Code device authorization response: ${JSON.stringify(json)}`);
|
|
63
|
+
}
|
|
64
|
+
const interval = json?.interval;
|
|
65
|
+
const expiresIn = json?.expires_in;
|
|
66
|
+
return {
|
|
67
|
+
deviceCode,
|
|
68
|
+
userCode,
|
|
69
|
+
verificationUri,
|
|
70
|
+
verificationUriComplete,
|
|
71
|
+
intervalSeconds: typeof interval === "number" && Number.isFinite(interval) && interval > 0 ? interval : DEFAULT_POLL_INTERVAL_SECONDS,
|
|
72
|
+
expiresInSeconds: typeof expiresIn === "number" && Number.isFinite(expiresIn) && expiresIn > 0 ? expiresIn : DEVICE_CODE_TIMEOUT_SECONDS
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function parseTokenResponse(json, operation) {
|
|
76
|
+
const accessToken = json?.access_token;
|
|
77
|
+
const refreshToken2 = json?.refresh_token;
|
|
78
|
+
const expiresIn = json?.expires_in;
|
|
79
|
+
if (typeof accessToken !== "string" || !accessToken || typeof refreshToken2 !== "string" || !refreshToken2 || typeof expiresIn !== "number" || !Number.isFinite(expiresIn) || expiresIn <= 0) {
|
|
80
|
+
throw new Error(`Kimi Code token ${operation} response missing fields: ${JSON.stringify(json)}`);
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
access: accessToken,
|
|
84
|
+
refresh: refreshToken2,
|
|
85
|
+
expires: Date.now() + expiresIn * 1e3
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
async function pollForToken(oauthHost, device, signal) {
|
|
89
|
+
return pollOAuthDeviceCodeFlow({
|
|
90
|
+
intervalSeconds: device.intervalSeconds,
|
|
91
|
+
expiresInSeconds: device.expiresInSeconds,
|
|
92
|
+
waitBeforeFirstPoll: true,
|
|
93
|
+
signal,
|
|
94
|
+
poll: async () => {
|
|
95
|
+
const response = await fetch(`${oauthHost}/api/oauth/token`, {
|
|
96
|
+
method: "POST",
|
|
97
|
+
headers: {
|
|
98
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
99
|
+
Accept: "application/json"
|
|
100
|
+
},
|
|
101
|
+
body: formUrlEncode({
|
|
102
|
+
client_id: CLIENT_ID,
|
|
103
|
+
device_code: device.deviceCode,
|
|
104
|
+
grant_type: "urn:ietf:params:oauth:grant-type:device_code"
|
|
105
|
+
}),
|
|
106
|
+
signal: requestSignal(signal)
|
|
107
|
+
});
|
|
108
|
+
if (response.status >= 500) {
|
|
109
|
+
const text = await response.text().catch(() => "");
|
|
110
|
+
return {
|
|
111
|
+
status: "failed",
|
|
112
|
+
message: `Kimi Code device token request failed with status ${response.status}${text ? `: ${text}` : ""}`
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const json = await readJson(response);
|
|
116
|
+
if (response.ok && typeof json?.access_token === "string") {
|
|
117
|
+
try {
|
|
118
|
+
return { status: "complete", value: parseTokenResponse(json, "poll") };
|
|
119
|
+
} catch (error2) {
|
|
120
|
+
return { status: "failed", message: error2 instanceof Error ? error2.message : String(error2) };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const error = json?.error;
|
|
124
|
+
const description = typeof json?.error_description === "string" ? `: ${json.error_description}` : "";
|
|
125
|
+
if (error === "authorization_pending") {
|
|
126
|
+
return { status: "pending" };
|
|
127
|
+
}
|
|
128
|
+
if (error === "slow_down") {
|
|
129
|
+
const interval = json?.interval;
|
|
130
|
+
return {
|
|
131
|
+
status: "slow_down",
|
|
132
|
+
intervalSeconds: typeof interval === "number" && interval > 0 ? interval : void 0
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
if (error === "expired_token") {
|
|
136
|
+
return { status: "failed", message: "Kimi Code device authorization expired. Please restart login." };
|
|
137
|
+
}
|
|
138
|
+
if (error === "access_denied") {
|
|
139
|
+
return { status: "failed", message: "Kimi Code login was denied." };
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
status: "failed",
|
|
143
|
+
message: `Kimi Code device token request failed (status ${response.status})${typeof error === "string" ? `: ${error}${description}` : ""}`
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function isRetryableRefreshFailure(response) {
|
|
149
|
+
return response.status === 429 || response.status >= 500;
|
|
150
|
+
}
|
|
151
|
+
async function refreshToken(oauthHost, refreshTokenValue, signal) {
|
|
152
|
+
let lastError;
|
|
153
|
+
for (let attempt = 0; attempt <= REFRESH_MAX_RETRIES; attempt++) {
|
|
154
|
+
if (attempt > 0) {
|
|
155
|
+
await sleep(1e3 * 2 ** (attempt - 1), signal);
|
|
156
|
+
}
|
|
157
|
+
if (signal.aborted) {
|
|
158
|
+
throw new Error("Kimi Code token refresh aborted");
|
|
159
|
+
}
|
|
160
|
+
let response;
|
|
161
|
+
try {
|
|
162
|
+
response = await fetch(`${oauthHost}/api/oauth/token`, {
|
|
163
|
+
method: "POST",
|
|
164
|
+
headers: {
|
|
165
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
166
|
+
Accept: "application/json"
|
|
167
|
+
},
|
|
168
|
+
body: formUrlEncode({
|
|
169
|
+
client_id: CLIENT_ID,
|
|
170
|
+
grant_type: "refresh_token",
|
|
171
|
+
refresh_token: refreshTokenValue
|
|
172
|
+
}),
|
|
173
|
+
signal: requestSignal(signal)
|
|
174
|
+
});
|
|
175
|
+
} catch (error) {
|
|
176
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
const json = await readJson(response);
|
|
180
|
+
if (response.ok) {
|
|
181
|
+
return parseTokenResponse(json, "refresh");
|
|
182
|
+
}
|
|
183
|
+
if (response.status === 401 || response.status === 403 || json?.error === "invalid_grant") {
|
|
184
|
+
const description = typeof json?.error_description === "string" ? `: ${json.error_description}` : "";
|
|
185
|
+
throw new Error(`Kimi Code token refresh unauthorized (status ${response.status})${description}`);
|
|
186
|
+
}
|
|
187
|
+
if (isRetryableRefreshFailure(response) && attempt < REFRESH_MAX_RETRIES) {
|
|
188
|
+
lastError = new Error(`Kimi Code token refresh failed with status ${response.status}`);
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
const text = JSON.stringify(json);
|
|
192
|
+
throw new Error(`Kimi Code token refresh failed with status ${response.status}${text ? `: ${text}` : ""}`);
|
|
193
|
+
}
|
|
194
|
+
throw lastError ?? new Error("Kimi Code token refresh failed");
|
|
195
|
+
}
|
|
196
|
+
async function loginKimiCoding(interaction) {
|
|
197
|
+
const oauthHost = getOauthHost();
|
|
198
|
+
const device = await startDeviceAuthorization(oauthHost, interaction.signal);
|
|
199
|
+
interaction.notify({
|
|
200
|
+
type: "device_code",
|
|
201
|
+
userCode: device.userCode,
|
|
202
|
+
verificationUri: device.verificationUriComplete,
|
|
203
|
+
intervalSeconds: device.intervalSeconds,
|
|
204
|
+
expiresInSeconds: device.expiresInSeconds
|
|
205
|
+
});
|
|
206
|
+
const token = await pollForToken(oauthHost, device, interaction.signal);
|
|
207
|
+
return { type: "oauth", access: token.access, refresh: token.refresh, expires: token.expires };
|
|
208
|
+
}
|
|
209
|
+
var kimiCodingOAuth = {
|
|
210
|
+
name: "Kimi Code (subscription)",
|
|
211
|
+
isSubscription: true,
|
|
212
|
+
loginLabel: "Sign in with Kimi Code",
|
|
213
|
+
login: loginKimiCoding,
|
|
214
|
+
refresh: async (credential, signal) => {
|
|
215
|
+
const token = await refreshToken(getOauthHost(), credential.refresh, signal);
|
|
216
|
+
return { type: "oauth", access: token.access, refresh: token.refresh, expires: token.expires };
|
|
217
|
+
},
|
|
218
|
+
async toAuth(credential) {
|
|
219
|
+
return { headers: { Authorization: `Bearer ${credential.access}` } };
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
export {
|
|
223
|
+
kimiCodingOAuth
|
|
224
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
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/openrouter.js
|
|
16
|
+
var AUTHORIZE_URL = "https://openrouter.ai/auth";
|
|
17
|
+
var TOKEN_URL = "https://openrouter.ai/api/v1/auth/keys";
|
|
18
|
+
var LOGIN_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
19
|
+
var TOKEN_EXCHANGE_TIMEOUT_MS = 3e4;
|
|
20
|
+
function getCallbackHost() {
|
|
21
|
+
return getProviderEnvValue("PI_OAUTH_CALLBACK_HOST") || "127.0.0.1";
|
|
22
|
+
}
|
|
23
|
+
function parseAuthorizationInput(input) {
|
|
24
|
+
const value = input.trim();
|
|
25
|
+
if (!value)
|
|
26
|
+
return void 0;
|
|
27
|
+
try {
|
|
28
|
+
return new URL(value).searchParams.get("code") ?? void 0;
|
|
29
|
+
} catch {
|
|
30
|
+
}
|
|
31
|
+
if (value.includes("code=")) {
|
|
32
|
+
return new URLSearchParams(value).get("code") ?? void 0;
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
function errorDetail(body) {
|
|
37
|
+
if (typeof body.error_description === "string")
|
|
38
|
+
return body.error_description;
|
|
39
|
+
if (typeof body.message === "string")
|
|
40
|
+
return body.message;
|
|
41
|
+
if (typeof body.error === "string")
|
|
42
|
+
return body.error;
|
|
43
|
+
if (body.error && typeof body.error === "object" && !Array.isArray(body.error)) {
|
|
44
|
+
const message = body.error.message;
|
|
45
|
+
if (typeof message === "string")
|
|
46
|
+
return message;
|
|
47
|
+
}
|
|
48
|
+
return void 0;
|
|
49
|
+
}
|
|
50
|
+
async function exchangeAuthorizationCode(code, verifier, signal) {
|
|
51
|
+
if (signal.aborted)
|
|
52
|
+
throw new Error("Login cancelled");
|
|
53
|
+
const controller = new AbortController();
|
|
54
|
+
const onAbort = () => controller.abort(signal.reason);
|
|
55
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
56
|
+
const timeout = setTimeout(() => controller.abort(new Error("OpenRouter OAuth token exchange timed out")), TOKEN_EXCHANGE_TIMEOUT_MS);
|
|
57
|
+
let response;
|
|
58
|
+
let body = {};
|
|
59
|
+
try {
|
|
60
|
+
response = await fetch(TOKEN_URL, {
|
|
61
|
+
method: "POST",
|
|
62
|
+
headers: { accept: "application/json", "content-type": "application/json" },
|
|
63
|
+
body: JSON.stringify({ code, code_verifier: verifier, code_challenge_method: "S256" }),
|
|
64
|
+
signal: controller.signal
|
|
65
|
+
});
|
|
66
|
+
try {
|
|
67
|
+
const parsed = await response.json();
|
|
68
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed))
|
|
69
|
+
body = parsed;
|
|
70
|
+
} catch {
|
|
71
|
+
if (response.ok)
|
|
72
|
+
throw new Error("OpenRouter OAuth returned invalid JSON");
|
|
73
|
+
}
|
|
74
|
+
} catch (error) {
|
|
75
|
+
if (signal.aborted)
|
|
76
|
+
throw new Error("Login cancelled");
|
|
77
|
+
if (controller.signal.aborted)
|
|
78
|
+
throw new Error("OpenRouter OAuth token exchange timed out");
|
|
79
|
+
throw error;
|
|
80
|
+
} finally {
|
|
81
|
+
clearTimeout(timeout);
|
|
82
|
+
signal.removeEventListener("abort", onAbort);
|
|
83
|
+
}
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
const detail = errorDetail(body);
|
|
86
|
+
throw new Error(`OpenRouter OAuth key exchange failed (HTTP ${response.status})${detail ? `: ${detail}` : ""}`);
|
|
87
|
+
}
|
|
88
|
+
if (typeof body.key !== "string" || body.key.length === 0) {
|
|
89
|
+
throw new Error('OpenRouter OAuth response carries no "key"');
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
type: "oauth",
|
|
93
|
+
access: body.key,
|
|
94
|
+
refresh: "",
|
|
95
|
+
expires: Number.MAX_SAFE_INTEGER
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async function loginOpenRouter(interaction) {
|
|
99
|
+
const { verifier, challenge } = await generatePKCE();
|
|
100
|
+
const callback = await startOAuthCallbackServer({
|
|
101
|
+
providerName: "OpenRouter",
|
|
102
|
+
host: getCallbackHost(),
|
|
103
|
+
port: 0,
|
|
104
|
+
path: `/oauth/callback/${crypto.randomUUID()}`,
|
|
105
|
+
complete: (code) => exchangeAuthorizationCode(code, verifier, interaction.signal),
|
|
106
|
+
signal: interaction.signal,
|
|
107
|
+
timeoutMs: LOGIN_TIMEOUT_MS
|
|
108
|
+
});
|
|
109
|
+
try {
|
|
110
|
+
const authorizeUrl = new URL(AUTHORIZE_URL);
|
|
111
|
+
authorizeUrl.search = new URLSearchParams({
|
|
112
|
+
callback_url: callback.redirectUri,
|
|
113
|
+
code_challenge: challenge,
|
|
114
|
+
code_challenge_method: "S256"
|
|
115
|
+
}).toString();
|
|
116
|
+
interaction.notify({
|
|
117
|
+
type: "progress",
|
|
118
|
+
message: `Listening for OpenRouter OAuth callback on ${callback.redirectUri}`
|
|
119
|
+
});
|
|
120
|
+
interaction.notify({
|
|
121
|
+
type: "auth_url",
|
|
122
|
+
url: authorizeUrl.toString(),
|
|
123
|
+
instructions: "Complete sign-in in your browser. If the browser is on another machine, paste the final redirect URL here."
|
|
124
|
+
});
|
|
125
|
+
const result = await waitForCallbackOrManualInput(interaction, callback, {
|
|
126
|
+
message: "Complete sign-in in your browser, or paste the authorization code / redirect URL here:",
|
|
127
|
+
placeholder: callback.redirectUri
|
|
128
|
+
});
|
|
129
|
+
if (result.type === "callback")
|
|
130
|
+
return result.value;
|
|
131
|
+
const code = parseAuthorizationInput(result.input);
|
|
132
|
+
if (!code)
|
|
133
|
+
throw new Error("Missing authorization code");
|
|
134
|
+
interaction.notify({ type: "progress", message: "Exchanging authorization code for an API key..." });
|
|
135
|
+
return await exchangeAuthorizationCode(code, verifier, interaction.signal);
|
|
136
|
+
} finally {
|
|
137
|
+
callback.close();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
var openRouterOAuth = {
|
|
141
|
+
name: "OpenRouter OAuth",
|
|
142
|
+
loginLabel: "Sign in with OpenRouter",
|
|
143
|
+
login: loginOpenRouter,
|
|
144
|
+
async refresh(credential, _signal) {
|
|
145
|
+
return credential;
|
|
146
|
+
},
|
|
147
|
+
async toAuth(credential) {
|
|
148
|
+
return { apiKey: credential.access };
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
export {
|
|
152
|
+
openRouterOAuth
|
|
153
|
+
};
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
2
|
const require = __nerveCreateRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
child_process,
|
|
5
|
-
crypto,
|
|
6
|
-
fs,
|
|
7
|
-
path,
|
|
8
|
-
stream,
|
|
9
|
-
util
|
|
10
|
-
} from "./chunk-RPEWYMBU.js";
|
|
11
3
|
import {
|
|
12
4
|
AnthropicError,
|
|
13
5
|
DEFAULT_MEMORY_SYNC_INTERVAL_MS,
|
|
@@ -21,7 +13,15 @@ import {
|
|
|
21
13
|
isStatus,
|
|
22
14
|
loggerFor,
|
|
23
15
|
promiseWithResolvers
|
|
24
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-M3ELKCNA.js";
|
|
17
|
+
import {
|
|
18
|
+
child_process,
|
|
19
|
+
crypto,
|
|
20
|
+
fs,
|
|
21
|
+
path,
|
|
22
|
+
stream,
|
|
23
|
+
util
|
|
24
|
+
} from "./chunk-RPEWYMBU.js";
|
|
25
25
|
import "./chunk-CWESUMYQ.js";
|
|
26
26
|
|
|
27
27
|
// node_modules/.pnpm/@anthropic-ai+sdk@0.129.0_zod@4.6.7/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.mjs
|
|
@@ -554,6 +554,214 @@ async function searchContent(root, options) {
|
|
|
554
554
|
}
|
|
555
555
|
}
|
|
556
556
|
|
|
557
|
+
// packages/native/dist/image/index.js
|
|
558
|
+
var image_exports = {};
|
|
559
|
+
__export(image_exports, {
|
|
560
|
+
imageInfo: () => imageInfo,
|
|
561
|
+
isAvailable: () => isAvailable2,
|
|
562
|
+
prepareImage: () => prepareImage,
|
|
563
|
+
transformImage: () => transformImage
|
|
564
|
+
});
|
|
565
|
+
var native = binding;
|
|
566
|
+
function isAvailable2() {
|
|
567
|
+
return typeof native.prepareModelImage === "function";
|
|
568
|
+
}
|
|
569
|
+
async function prepareImage(data, options) {
|
|
570
|
+
if (typeof native.prepareModelImage !== "function") {
|
|
571
|
+
throw new Error("Native image support is not available");
|
|
572
|
+
}
|
|
573
|
+
return await native.prepareModelImage(data, {
|
|
574
|
+
maxDimension: options.maxDimension,
|
|
575
|
+
maxBase64Bytes: options.maxBase64Bytes,
|
|
576
|
+
acceptedFormats: [...options.acceptedFormats ?? ["png", "jpeg", "webp"]],
|
|
577
|
+
outputFormats: [...options.outputFormats ?? ["png", "jpeg"]]
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
async function transformImage(data, ops) {
|
|
581
|
+
if (typeof native.transformImageNative !== "function") {
|
|
582
|
+
throw new Error("Native image support is not available");
|
|
583
|
+
}
|
|
584
|
+
return await native.transformImageNative(data, ops);
|
|
585
|
+
}
|
|
586
|
+
async function imageInfo(data) {
|
|
587
|
+
if (typeof native.imageInfoNative !== "function") {
|
|
588
|
+
throw new Error("Native image support is not available");
|
|
589
|
+
}
|
|
590
|
+
return await native.imageInfoNative(data);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// packages/native/dist/sandbox/index.js
|
|
594
|
+
var sandbox_exports = {};
|
|
595
|
+
__export(sandbox_exports, {
|
|
596
|
+
isAvailable: () => isAvailable3,
|
|
597
|
+
runSandboxScript: () => runSandboxScript
|
|
598
|
+
});
|
|
599
|
+
import { stripTypeScriptTypes } from "node:module";
|
|
600
|
+
|
|
601
|
+
// packages/native/dist/sandbox/prelude.js
|
|
602
|
+
var BASE_PRELUDE = String.raw`
|
|
603
|
+
(() => {
|
|
604
|
+
const print = __print;
|
|
605
|
+
const hostCall = __hostCall;
|
|
606
|
+
delete globalThis.__print;
|
|
607
|
+
delete globalThis.__hostCall;
|
|
608
|
+
|
|
609
|
+
const format = (value, depth = 0) => {
|
|
610
|
+
if (typeof value === "string") return depth === 0 ? value : JSON.stringify(value);
|
|
611
|
+
if (value instanceof Error) return value.stack ? value.name + ": " + value.message + "\n" + value.stack : String(value);
|
|
612
|
+
if (typeof value === "undefined" || typeof value === "function" || typeof value === "symbol") return String(value);
|
|
613
|
+
if (typeof value === "bigint") return value + "n";
|
|
614
|
+
try { return JSON.stringify(value, null, 2) ?? String(value); } catch { return String(value); }
|
|
615
|
+
};
|
|
616
|
+
const write = (...values) => print(values.map((v) => format(v)).join(" "));
|
|
617
|
+
globalThis.console = Object.freeze({
|
|
618
|
+
log: write, info: write, warn: write, error: write, debug: write,
|
|
619
|
+
table: (rows) => print(format(rows)),
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
globalThis.host = Object.freeze({
|
|
623
|
+
async call(method, args) {
|
|
624
|
+
let json;
|
|
625
|
+
try {
|
|
626
|
+
json = await hostCall(String(method), JSON.stringify(args ?? null));
|
|
627
|
+
} catch (message) {
|
|
628
|
+
const error = new Error(String(message));
|
|
629
|
+
error.name = "HostError";
|
|
630
|
+
throw error;
|
|
631
|
+
}
|
|
632
|
+
return JSON.parse(json);
|
|
633
|
+
},
|
|
634
|
+
});
|
|
635
|
+
})();
|
|
636
|
+
`;
|
|
637
|
+
|
|
638
|
+
// packages/native/dist/sandbox/index.js
|
|
639
|
+
var EXIT_GRACE_MS = 5e3;
|
|
640
|
+
var native2 = binding;
|
|
641
|
+
function isAvailable3() {
|
|
642
|
+
return typeof native2.startSandboxScript === "function";
|
|
643
|
+
}
|
|
644
|
+
async function runSandboxScript(options) {
|
|
645
|
+
if (typeof native2.startSandboxScript !== "function") {
|
|
646
|
+
throw new Error("Native sandbox support is not available");
|
|
647
|
+
}
|
|
648
|
+
let code = options.code;
|
|
649
|
+
if (options.typescript) {
|
|
650
|
+
try {
|
|
651
|
+
code = stripTypeScriptTypes(code, { mode: "strip" });
|
|
652
|
+
} catch (error) {
|
|
653
|
+
return failedBeforeStart(error);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
if (options.signal?.aborted) {
|
|
657
|
+
return {
|
|
658
|
+
status: "cancelled",
|
|
659
|
+
output: "",
|
|
660
|
+
outputTruncated: false,
|
|
661
|
+
hostCalls: [],
|
|
662
|
+
durationMs: 0,
|
|
663
|
+
memoryUsedBytes: 0
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
const records = [];
|
|
667
|
+
return await new Promise((resolve, reject) => {
|
|
668
|
+
let script;
|
|
669
|
+
let hostFailure;
|
|
670
|
+
let settled = false;
|
|
671
|
+
const onAbort = () => script?.cancel();
|
|
672
|
+
const finish = (settle) => {
|
|
673
|
+
if (settled)
|
|
674
|
+
return;
|
|
675
|
+
settled = true;
|
|
676
|
+
clearTimeout(watchdog);
|
|
677
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
678
|
+
settle();
|
|
679
|
+
};
|
|
680
|
+
const watchdog = setTimeout(() => {
|
|
681
|
+
script?.cancel();
|
|
682
|
+
finish(() => resolve(failed("The sandbox did not exit after its deadline")));
|
|
683
|
+
}, (options.timeoutMs ?? 12e4) + EXIT_GRACE_MS);
|
|
684
|
+
watchdog.unref();
|
|
685
|
+
try {
|
|
686
|
+
script = native2.startSandboxScript({
|
|
687
|
+
name: options.typescript ? "script.ts" : "script.js",
|
|
688
|
+
code,
|
|
689
|
+
preludes: [
|
|
690
|
+
{ name: "nerve:base", source: BASE_PRELUDE },
|
|
691
|
+
...options.preludes ?? []
|
|
692
|
+
],
|
|
693
|
+
memoryBytes: options.memoryBytes ?? 256 * 1024 * 1024,
|
|
694
|
+
timeoutMs: options.timeoutMs ?? 12e4,
|
|
695
|
+
maxHostCalls: options.maxHostCalls ?? 200,
|
|
696
|
+
uncountedHostMethods: options.uncountedHostMethods,
|
|
697
|
+
maxOutputBytes: options.maxOutputBytes ?? 256 * 1024
|
|
698
|
+
}, (error, call) => {
|
|
699
|
+
if (error) {
|
|
700
|
+
hostFailure ??= errorText(error);
|
|
701
|
+
script?.cancel();
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
const started = performance.now();
|
|
705
|
+
void handle(call.method, call.args).then((value) => {
|
|
706
|
+
records.push({
|
|
707
|
+
method: call.method,
|
|
708
|
+
ok: true,
|
|
709
|
+
durationMs: performance.now() - started
|
|
710
|
+
});
|
|
711
|
+
script.reply(call.id, true, JSON.stringify(value ?? null));
|
|
712
|
+
}, (failure) => {
|
|
713
|
+
records.push({
|
|
714
|
+
method: call.method,
|
|
715
|
+
ok: false,
|
|
716
|
+
durationMs: performance.now() - started
|
|
717
|
+
});
|
|
718
|
+
script.reply(call.id, false, errorText(failure));
|
|
719
|
+
});
|
|
720
|
+
}, (error, outcome) => {
|
|
721
|
+
if (error)
|
|
722
|
+
return finish(() => reject(error));
|
|
723
|
+
if (hostFailure) {
|
|
724
|
+
const message = `Host call transport failed: ${hostFailure}`;
|
|
725
|
+
return finish(() => resolve({ ...failed(message), hostCalls: records }));
|
|
726
|
+
}
|
|
727
|
+
finish(() => resolve({
|
|
728
|
+
status: outcome.status,
|
|
729
|
+
...outcome.error ? { error: outcome.error } : {},
|
|
730
|
+
output: outcome.output,
|
|
731
|
+
outputTruncated: outcome.outputTruncated,
|
|
732
|
+
hostCalls: records,
|
|
733
|
+
durationMs: outcome.durationMs,
|
|
734
|
+
memoryUsedBytes: outcome.memoryUsedBytes
|
|
735
|
+
}));
|
|
736
|
+
});
|
|
737
|
+
} catch (error) {
|
|
738
|
+
finish(() => reject(error));
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
742
|
+
});
|
|
743
|
+
async function handle(method, args) {
|
|
744
|
+
return await options.onHostCall(method, JSON.parse(args));
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
function failedBeforeStart(error) {
|
|
748
|
+
return failed(errorText(error));
|
|
749
|
+
}
|
|
750
|
+
function failed(error) {
|
|
751
|
+
return {
|
|
752
|
+
status: "failed",
|
|
753
|
+
error,
|
|
754
|
+
output: "",
|
|
755
|
+
outputTruncated: false,
|
|
756
|
+
hostCalls: [],
|
|
757
|
+
durationMs: 0,
|
|
758
|
+
memoryUsedBytes: 0
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
function errorText(error) {
|
|
762
|
+
return error instanceof Error ? error.message : String(error);
|
|
763
|
+
}
|
|
764
|
+
|
|
557
765
|
// packages/native/dist/git/git-client.js
|
|
558
766
|
var NativeGitReadError = class extends Error {
|
|
559
767
|
category;
|
|
@@ -1151,6 +1359,8 @@ export {
|
|
|
1151
1359
|
nativeRuntimeCapabilities,
|
|
1152
1360
|
createSearchIndex,
|
|
1153
1361
|
files_exports,
|
|
1362
|
+
image_exports,
|
|
1363
|
+
sandbox_exports,
|
|
1154
1364
|
NativeGitReadError,
|
|
1155
1365
|
readGitRepositoryInfo,
|
|
1156
1366
|
readGitSnapshot,
|