@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,359 @@
|
|
|
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
|
+
GITHUB_COPILOT_MODELS
|
|
14
|
+
} from "./chunk-RJR7DJJK.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/github-copilot.js
|
|
18
|
+
var decode = (s) => atob(s);
|
|
19
|
+
var CLIENT_ID = decode("SXYxLmI1MDdhMDhjODdlY2ZlOTg=");
|
|
20
|
+
var COPILOT_HEADERS = {
|
|
21
|
+
"User-Agent": "GitHubCopilotChat/0.35.0",
|
|
22
|
+
"Editor-Version": "vscode/1.107.0",
|
|
23
|
+
"Editor-Plugin-Version": "copilot-chat/0.35.0",
|
|
24
|
+
"Copilot-Integration-Id": "vscode-chat"
|
|
25
|
+
};
|
|
26
|
+
var COPILOT_API_VERSION = "2026-06-01";
|
|
27
|
+
function normalizeDomain(input) {
|
|
28
|
+
const trimmed = input.trim();
|
|
29
|
+
if (!trimmed)
|
|
30
|
+
return null;
|
|
31
|
+
try {
|
|
32
|
+
const url = trimmed.includes("://") ? new URL(trimmed) : new URL(`https://${trimmed}`);
|
|
33
|
+
return url.hostname;
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function getUrls(domain) {
|
|
39
|
+
return {
|
|
40
|
+
deviceCodeUrl: `https://${domain}/login/device/code`,
|
|
41
|
+
accessTokenUrl: `https://${domain}/login/oauth/access_token`,
|
|
42
|
+
copilotTokenUrl: `https://api.${domain}/copilot_internal/v2/token`
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function getBaseUrlFromToken(token) {
|
|
46
|
+
const match = token.match(/proxy-ep=([^;]+)/);
|
|
47
|
+
if (!match)
|
|
48
|
+
return null;
|
|
49
|
+
const proxyHost = match[1];
|
|
50
|
+
const apiHost = proxyHost.replace(/^proxy\./, "api.");
|
|
51
|
+
return `https://${apiHost}`;
|
|
52
|
+
}
|
|
53
|
+
function getGitHubCopilotBaseUrl(token, enterpriseDomain) {
|
|
54
|
+
if (token) {
|
|
55
|
+
const urlFromToken = getBaseUrlFromToken(token);
|
|
56
|
+
if (urlFromToken)
|
|
57
|
+
return urlFromToken;
|
|
58
|
+
}
|
|
59
|
+
if (enterpriseDomain)
|
|
60
|
+
return `https://copilot-api.${enterpriseDomain}`;
|
|
61
|
+
return "https://api.individual.githubcopilot.com";
|
|
62
|
+
}
|
|
63
|
+
function asRecord(value) {
|
|
64
|
+
return value && typeof value === "object" ? value : void 0;
|
|
65
|
+
}
|
|
66
|
+
function parseGitHubCopilotModelCatalog(raw, allowPolicyFallback) {
|
|
67
|
+
const data = asRecord(raw)?.data;
|
|
68
|
+
if (!Array.isArray(data)) {
|
|
69
|
+
throw new Error("Invalid Copilot models response");
|
|
70
|
+
}
|
|
71
|
+
const accountModels = data.flatMap((rawItem) => {
|
|
72
|
+
const item = asRecord(rawItem);
|
|
73
|
+
const id = item?.id;
|
|
74
|
+
if (!item || typeof id !== "string")
|
|
75
|
+
return [];
|
|
76
|
+
const capabilities = asRecord(item.capabilities);
|
|
77
|
+
const supports = asRecord(capabilities?.supports);
|
|
78
|
+
if (supports?.tool_calls === false)
|
|
79
|
+
return [];
|
|
80
|
+
return [
|
|
81
|
+
{
|
|
82
|
+
id,
|
|
83
|
+
pickerEnabled: item.model_picker_enabled === true,
|
|
84
|
+
policyState: asRecord(item.policy)?.state
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
});
|
|
88
|
+
const pickerModelIds = accountModels.filter((model) => model.pickerEnabled && model.policyState !== "disabled").map((model) => model.id);
|
|
89
|
+
const usePolicyFallback = allowPolicyFallback && pickerModelIds.length === 0;
|
|
90
|
+
const availableModelIds = pickerModelIds.length > 0 || !allowPolicyFallback ? pickerModelIds : accountModels.filter((model) => model.policyState === "enabled").map((model) => model.id);
|
|
91
|
+
const policyModelIds = accountModels.filter((model) => model.policyState === "unconfigured" && Object.hasOwn(GITHUB_COPILOT_MODELS, model.id) && (model.pickerEnabled || usePolicyFallback)).map((model) => model.id);
|
|
92
|
+
return { availableModelIds, policyModelIds };
|
|
93
|
+
}
|
|
94
|
+
async function fetchWithRateLimitRetry(url, init, signal, retryPolicy) {
|
|
95
|
+
const retryBudgetSignal = retryPolicy.maxRetries > 0 && retryPolicy.maxElapsedMs > 0 ? AbortSignal.timeout(retryPolicy.maxElapsedMs) : void 0;
|
|
96
|
+
const requestSignal = retryBudgetSignal ? AbortSignal.any([signal, retryBudgetSignal]) : signal;
|
|
97
|
+
const retryDeadline = retryBudgetSignal ? Date.now() + retryPolicy.maxElapsedMs : void 0;
|
|
98
|
+
for (let retry = 0; ; retry++) {
|
|
99
|
+
const response = await fetch(url, {
|
|
100
|
+
...init,
|
|
101
|
+
signal: AbortSignal.any([requestSignal, AbortSignal.timeout(5e3)])
|
|
102
|
+
});
|
|
103
|
+
if (response.status !== 429 || retry === retryPolicy.maxRetries)
|
|
104
|
+
return response;
|
|
105
|
+
const retryAfter = response.headers.get("retry-after");
|
|
106
|
+
let delayMs = 500 * 2 ** retry;
|
|
107
|
+
if (retryAfter) {
|
|
108
|
+
const seconds = Number.parseFloat(retryAfter);
|
|
109
|
+
delayMs = Number.isNaN(seconds) ? Date.parse(retryAfter) - Date.now() : seconds * 1e3;
|
|
110
|
+
if (!Number.isFinite(delayMs))
|
|
111
|
+
return response;
|
|
112
|
+
}
|
|
113
|
+
delayMs = Math.max(0, delayMs);
|
|
114
|
+
if (retryDeadline !== void 0 && delayMs >= retryDeadline - Date.now())
|
|
115
|
+
return response;
|
|
116
|
+
await response.body?.cancel();
|
|
117
|
+
await sleep(delayMs, requestSignal);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async function fetchGitHubCopilotModels(copilotToken, enterpriseDomain, signal, retryPolicy) {
|
|
121
|
+
const baseUrl = getGitHubCopilotBaseUrl(copilotToken, enterpriseDomain);
|
|
122
|
+
const allowPolicyFallback = baseUrl === "https://api.individual.githubcopilot.com";
|
|
123
|
+
const response = await fetchWithRateLimitRetry(`${baseUrl}/models`, {
|
|
124
|
+
headers: {
|
|
125
|
+
Accept: "application/json",
|
|
126
|
+
Authorization: `Bearer ${copilotToken}`,
|
|
127
|
+
...COPILOT_HEADERS,
|
|
128
|
+
"X-GitHub-Api-Version": COPILOT_API_VERSION
|
|
129
|
+
}
|
|
130
|
+
}, signal, retryPolicy);
|
|
131
|
+
if (!response.ok) {
|
|
132
|
+
throw new Error(`${response.status} ${response.statusText}: ${await response.text()}`);
|
|
133
|
+
}
|
|
134
|
+
return parseGitHubCopilotModelCatalog(await response.json(), allowPolicyFallback);
|
|
135
|
+
}
|
|
136
|
+
async function fetchJson(url, init) {
|
|
137
|
+
const response = await fetch(url, init);
|
|
138
|
+
if (!response.ok) {
|
|
139
|
+
const text = await response.text();
|
|
140
|
+
throw new Error(`${response.status} ${response.statusText}: ${text}`);
|
|
141
|
+
}
|
|
142
|
+
return response.json();
|
|
143
|
+
}
|
|
144
|
+
async function startDeviceFlow(domain, signal) {
|
|
145
|
+
const urls = getUrls(domain);
|
|
146
|
+
const data = await fetchJson(urls.deviceCodeUrl, {
|
|
147
|
+
method: "POST",
|
|
148
|
+
headers: {
|
|
149
|
+
Accept: "application/json",
|
|
150
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
151
|
+
"User-Agent": "GitHubCopilotChat/0.35.0"
|
|
152
|
+
},
|
|
153
|
+
body: new URLSearchParams({
|
|
154
|
+
client_id: CLIENT_ID,
|
|
155
|
+
scope: "read:user"
|
|
156
|
+
}),
|
|
157
|
+
signal
|
|
158
|
+
});
|
|
159
|
+
if (!data || typeof data !== "object") {
|
|
160
|
+
throw new Error("Invalid device code response");
|
|
161
|
+
}
|
|
162
|
+
const deviceCode = data.device_code;
|
|
163
|
+
const userCode = data.user_code;
|
|
164
|
+
const verificationUri = data.verification_uri;
|
|
165
|
+
const interval = data.interval;
|
|
166
|
+
const expiresIn = data.expires_in;
|
|
167
|
+
if (typeof deviceCode !== "string" || typeof userCode !== "string" || typeof verificationUri !== "string" || interval !== void 0 && typeof interval !== "number" || typeof expiresIn !== "number") {
|
|
168
|
+
throw new Error("Invalid device code response fields");
|
|
169
|
+
}
|
|
170
|
+
const trustedVerificationUri = trustedHttpUrl(verificationUri);
|
|
171
|
+
if (!trustedVerificationUri) {
|
|
172
|
+
throw new Error("Untrusted verification_uri in device code response");
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
device_code: deviceCode,
|
|
176
|
+
user_code: userCode,
|
|
177
|
+
verification_uri: trustedVerificationUri,
|
|
178
|
+
interval,
|
|
179
|
+
expires_in: expiresIn
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
async function pollForGitHubAccessToken(domain, device, signal) {
|
|
183
|
+
const urls = getUrls(domain);
|
|
184
|
+
return pollOAuthDeviceCodeFlow({
|
|
185
|
+
intervalSeconds: device.interval,
|
|
186
|
+
expiresInSeconds: device.expires_in,
|
|
187
|
+
waitBeforeFirstPoll: true,
|
|
188
|
+
signal,
|
|
189
|
+
poll: async () => {
|
|
190
|
+
const raw = await fetchJson(urls.accessTokenUrl, {
|
|
191
|
+
method: "POST",
|
|
192
|
+
headers: {
|
|
193
|
+
Accept: "application/json",
|
|
194
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
195
|
+
"User-Agent": "GitHubCopilotChat/0.35.0"
|
|
196
|
+
},
|
|
197
|
+
body: new URLSearchParams({
|
|
198
|
+
client_id: CLIENT_ID,
|
|
199
|
+
device_code: device.device_code,
|
|
200
|
+
grant_type: "urn:ietf:params:oauth:grant-type:device_code"
|
|
201
|
+
}),
|
|
202
|
+
signal
|
|
203
|
+
});
|
|
204
|
+
if (raw && typeof raw === "object" && typeof raw.access_token === "string") {
|
|
205
|
+
return { status: "complete", value: raw.access_token };
|
|
206
|
+
}
|
|
207
|
+
if (raw && typeof raw === "object" && typeof raw.error === "string") {
|
|
208
|
+
const { error, error_description: description, interval } = raw;
|
|
209
|
+
if (error === "authorization_pending") {
|
|
210
|
+
return { status: "pending" };
|
|
211
|
+
}
|
|
212
|
+
if (error === "slow_down") {
|
|
213
|
+
return { status: "slow_down", intervalSeconds: typeof interval === "number" ? interval : void 0 };
|
|
214
|
+
}
|
|
215
|
+
const descriptionSuffix = description ? `: ${description}` : "";
|
|
216
|
+
return { status: "failed", message: `Device flow failed: ${error}${descriptionSuffix}` };
|
|
217
|
+
}
|
|
218
|
+
return { status: "failed", message: "Invalid device token response" };
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
async function refreshGitHubCopilotAccessToken(refreshToken, enterpriseDomain, signal) {
|
|
223
|
+
const domain = enterpriseDomain || "github.com";
|
|
224
|
+
const urls = getUrls(domain);
|
|
225
|
+
const raw = await fetchJson(urls.copilotTokenUrl, {
|
|
226
|
+
headers: {
|
|
227
|
+
Accept: "application/json",
|
|
228
|
+
Authorization: `Bearer ${refreshToken}`,
|
|
229
|
+
...COPILOT_HEADERS
|
|
230
|
+
},
|
|
231
|
+
signal
|
|
232
|
+
});
|
|
233
|
+
if (!raw || typeof raw !== "object") {
|
|
234
|
+
throw new Error("Invalid Copilot token response");
|
|
235
|
+
}
|
|
236
|
+
const token = raw.token;
|
|
237
|
+
const expiresAt = raw.expires_at;
|
|
238
|
+
if (typeof token !== "string" || typeof expiresAt !== "number") {
|
|
239
|
+
throw new Error("Invalid Copilot token response fields");
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
type: "oauth",
|
|
243
|
+
refresh: refreshToken,
|
|
244
|
+
access: token,
|
|
245
|
+
expires: expiresAt * 1e3 - 5 * 60 * 1e3,
|
|
246
|
+
enterpriseUrl: enterpriseDomain
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
async function refreshGitHubCopilotToken(refreshToken, enterpriseDomain, signal) {
|
|
250
|
+
const credentials = await refreshGitHubCopilotAccessToken(refreshToken, enterpriseDomain, signal);
|
|
251
|
+
const { availableModelIds } = await fetchGitHubCopilotModels(credentials.access, enterpriseDomain, signal, {
|
|
252
|
+
maxRetries: 0,
|
|
253
|
+
maxElapsedMs: 0
|
|
254
|
+
});
|
|
255
|
+
return {
|
|
256
|
+
...credentials,
|
|
257
|
+
availableModelIds
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
async function enableGitHubCopilotModel(token, modelId, enterpriseDomain, signal) {
|
|
261
|
+
const baseUrl = getGitHubCopilotBaseUrl(token, enterpriseDomain);
|
|
262
|
+
const url = `${baseUrl}/models/${modelId}/policy`;
|
|
263
|
+
let response;
|
|
264
|
+
try {
|
|
265
|
+
response = await fetchWithRateLimitRetry(url, {
|
|
266
|
+
method: "POST",
|
|
267
|
+
headers: {
|
|
268
|
+
"Content-Type": "application/json",
|
|
269
|
+
Authorization: `Bearer ${token}`,
|
|
270
|
+
...COPILOT_HEADERS,
|
|
271
|
+
"openai-intent": "chat-policy",
|
|
272
|
+
"x-interaction-type": "chat-policy"
|
|
273
|
+
},
|
|
274
|
+
body: JSON.stringify({ state: "enabled" })
|
|
275
|
+
}, signal, { maxRetries: 2, maxElapsedMs: 5e3 });
|
|
276
|
+
} catch (error) {
|
|
277
|
+
if (signal.aborted)
|
|
278
|
+
throw error;
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
if (response.status === 429) {
|
|
282
|
+
throw new Error(`${response.status} ${response.statusText}: ${await response.text()}`);
|
|
283
|
+
}
|
|
284
|
+
return response.ok;
|
|
285
|
+
}
|
|
286
|
+
async function enableGitHubCopilotModels(token, modelIds, enterpriseDomain, signal) {
|
|
287
|
+
const enabledModelIds = [];
|
|
288
|
+
for (const modelId of modelIds) {
|
|
289
|
+
try {
|
|
290
|
+
if (await enableGitHubCopilotModel(token, modelId, enterpriseDomain, signal)) {
|
|
291
|
+
enabledModelIds.push(modelId);
|
|
292
|
+
}
|
|
293
|
+
} catch (error) {
|
|
294
|
+
if (signal.aborted)
|
|
295
|
+
throw error;
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return enabledModelIds;
|
|
300
|
+
}
|
|
301
|
+
async function loginGitHubCopilot(interaction) {
|
|
302
|
+
const input = await interaction.prompt({
|
|
303
|
+
type: "text",
|
|
304
|
+
message: "GitHub Enterprise URL/domain (blank for github.com)",
|
|
305
|
+
placeholder: "company.ghe.com"
|
|
306
|
+
});
|
|
307
|
+
if (interaction.signal.aborted)
|
|
308
|
+
throw new Error("Login cancelled");
|
|
309
|
+
const trimmed = input.trim();
|
|
310
|
+
const enterpriseDomain = normalizeDomain(input);
|
|
311
|
+
if (trimmed && !enterpriseDomain)
|
|
312
|
+
throw new Error("Invalid GitHub Enterprise URL/domain");
|
|
313
|
+
const domain = enterpriseDomain || "github.com";
|
|
314
|
+
const device = await startDeviceFlow(domain, interaction.signal);
|
|
315
|
+
interaction.notify({
|
|
316
|
+
type: "device_code",
|
|
317
|
+
userCode: device.user_code,
|
|
318
|
+
verificationUri: device.verification_uri,
|
|
319
|
+
intervalSeconds: device.interval,
|
|
320
|
+
expiresInSeconds: device.expires_in
|
|
321
|
+
});
|
|
322
|
+
const githubAccessToken = await pollForGitHubAccessToken(domain, device, interaction.signal);
|
|
323
|
+
const credentials = await refreshGitHubCopilotAccessToken(githubAccessToken, enterpriseDomain ?? void 0, interaction.signal);
|
|
324
|
+
const models = await fetchGitHubCopilotModels(credentials.access, enterpriseDomain ?? void 0, interaction.signal, {
|
|
325
|
+
maxRetries: 2,
|
|
326
|
+
maxElapsedMs: 5e3
|
|
327
|
+
});
|
|
328
|
+
let enabledModelIds = [];
|
|
329
|
+
if (models.policyModelIds.length > 0) {
|
|
330
|
+
interaction.notify({ type: "progress", message: "Enabling models..." });
|
|
331
|
+
enabledModelIds = await enableGitHubCopilotModels(credentials.access, models.policyModelIds, enterpriseDomain ?? void 0, interaction.signal);
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
...credentials,
|
|
335
|
+
availableModelIds: [.../* @__PURE__ */ new Set([...models.availableModelIds, ...enabledModelIds])]
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
function copilotEnterpriseDomain(credential) {
|
|
339
|
+
const enterpriseUrl = credential.enterpriseUrl;
|
|
340
|
+
if (typeof enterpriseUrl !== "string" || !enterpriseUrl)
|
|
341
|
+
return void 0;
|
|
342
|
+
return normalizeDomain(enterpriseUrl) ?? void 0;
|
|
343
|
+
}
|
|
344
|
+
var githubCopilotOAuth = {
|
|
345
|
+
name: "GitHub Copilot",
|
|
346
|
+
isSubscription: true,
|
|
347
|
+
login: loginGitHubCopilot,
|
|
348
|
+
refresh: (credential, signal) => refreshGitHubCopilotToken(credential.refresh, copilotEnterpriseDomain(credential), signal),
|
|
349
|
+
/** Derive the credential-specific proxy endpoint for each request. */
|
|
350
|
+
async toAuth(credential) {
|
|
351
|
+
return {
|
|
352
|
+
apiKey: credential.access,
|
|
353
|
+
baseUrl: getGitHubCopilotBaseUrl(credential.access, copilotEnterpriseDomain(credential))
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
export {
|
|
358
|
+
githubCopilotOAuth
|
|
359
|
+
};
|
|
@@ -2,31 +2,33 @@ import { createRequire as __nerveCreateRequire } from "node:module";
|
|
|
2
2
|
const require = __nerveCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
shortHash
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import {
|
|
7
|
-
parseStreamingJson,
|
|
8
|
-
parseToolCallArguments
|
|
9
|
-
} from "./chunk-RUZ2UAYH.js";
|
|
5
|
+
} from "./chunk-LP4APBBQ.js";
|
|
10
6
|
import {
|
|
11
7
|
appendGrammarToolInputJsonDelta,
|
|
8
|
+
closeGrammarToolInputJson,
|
|
12
9
|
getGrammarToolInput,
|
|
13
10
|
getJsonSchemaToolParameters,
|
|
14
11
|
resolveGrammarConstrainedSampling,
|
|
15
12
|
resolveJsonSchemaStrictSampling,
|
|
16
13
|
transformMessages
|
|
17
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-Z6AY5VOZ.js";
|
|
18
15
|
import {
|
|
19
16
|
sanitizeSurrogates
|
|
20
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-TSAUBRRU.js";
|
|
18
|
+
import {
|
|
19
|
+
ToolCallArgumentsStream
|
|
20
|
+
} from "./chunk-BG2KGLIA.js";
|
|
21
21
|
import {
|
|
22
22
|
calculateCost,
|
|
23
|
-
getSystemMessageText,
|
|
24
|
-
renderSystemMessageUpdate,
|
|
25
23
|
resolveTranscript,
|
|
26
24
|
resolveTranscriptTools
|
|
27
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-W7LEYYFH.js";
|
|
26
|
+
import {
|
|
27
|
+
getSystemMessageText,
|
|
28
|
+
renderSystemMessageUpdate
|
|
29
|
+
} from "./chunk-U5KGV63C.js";
|
|
28
30
|
|
|
29
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
31
|
+
// 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-responses-shared.js
|
|
30
32
|
function encodeTextSignatureV1(id, phase) {
|
|
31
33
|
const payload = { v: 1, id };
|
|
32
34
|
if (phase)
|
|
@@ -338,24 +340,10 @@ function convertResponsesTools(tools, options) {
|
|
|
338
340
|
return functionTool;
|
|
339
341
|
});
|
|
340
342
|
}
|
|
341
|
-
function getCustomToolCallInput(block) {
|
|
342
|
-
const property = block.customInput?.property;
|
|
343
|
-
if (property === void 0)
|
|
344
|
-
return "";
|
|
345
|
-
const value = block.arguments[property];
|
|
346
|
-
return typeof value === "string" ? value : "";
|
|
347
|
-
}
|
|
348
|
-
function appendCustomToolCallInput(block, nextInput, close) {
|
|
349
|
-
const customInput = block.customInput;
|
|
350
|
-
if (!customInput)
|
|
351
|
-
return void 0;
|
|
352
|
-
const delta = appendGrammarToolInputJsonDelta(customInput.jsonBuffer, customInput.property, nextInput, close);
|
|
353
|
-
block.arguments = { [customInput.property]: nextInput };
|
|
354
|
-
return delta;
|
|
355
|
-
}
|
|
356
343
|
async function processResponsesStream(openaiStream, output, stream, model, options) {
|
|
357
344
|
let sawTerminalResponseEvent = false;
|
|
358
345
|
const outputSlots = /* @__PURE__ */ new Map();
|
|
346
|
+
const unfinishedToolCalls = /* @__PURE__ */ new Set();
|
|
359
347
|
const reasoningBlocksById = /* @__PURE__ */ new Map();
|
|
360
348
|
const applyMessagePhaseStopReason = (item) => {
|
|
361
349
|
if (item.type === "message" && item.phase === "final_answer") {
|
|
@@ -399,19 +387,21 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
|
|
|
399
387
|
return slot;
|
|
400
388
|
}
|
|
401
389
|
if (item.type === "function_call") {
|
|
390
|
+
const args = new ToolCallArgumentsStream();
|
|
402
391
|
const block = {
|
|
403
392
|
type: "toolCall",
|
|
404
393
|
id: `${item.call_id}|${item.id}`,
|
|
405
394
|
name: item.name,
|
|
406
|
-
arguments: {},
|
|
407
|
-
...item.namespace !== void 0 ? { namespace: item.namespace } : {}
|
|
408
|
-
partialJson: item.arguments || ""
|
|
395
|
+
arguments: item.arguments ? args.append(item.arguments) : {},
|
|
396
|
+
...item.namespace !== void 0 ? { namespace: item.namespace } : {}
|
|
409
397
|
};
|
|
410
398
|
output.content.push(block);
|
|
399
|
+
unfinishedToolCalls.add(block);
|
|
411
400
|
const slot = {
|
|
412
401
|
type: "toolCall",
|
|
413
402
|
block,
|
|
414
|
-
contentIndex: output.content.length - 1
|
|
403
|
+
contentIndex: output.content.length - 1,
|
|
404
|
+
input: { kind: "json", arguments: args }
|
|
415
405
|
};
|
|
416
406
|
outputSlots.set(outputIndex, slot);
|
|
417
407
|
stream.push({ type: "toolcall_start", contentIndex: slot.contentIndex, partial: output });
|
|
@@ -425,17 +415,15 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
|
|
|
425
415
|
id: `${item.call_id}|${item.id}`,
|
|
426
416
|
name: item.name,
|
|
427
417
|
arguments: { [inputProperty]: input },
|
|
428
|
-
...item.namespace !== void 0 ? { namespace: item.namespace } : {}
|
|
429
|
-
customInput: {
|
|
430
|
-
property: inputProperty,
|
|
431
|
-
jsonBuffer: { input: "", started: false, closed: false }
|
|
432
|
-
}
|
|
418
|
+
...item.namespace !== void 0 ? { namespace: item.namespace } : {}
|
|
433
419
|
};
|
|
434
420
|
output.content.push(block);
|
|
421
|
+
unfinishedToolCalls.add(block);
|
|
435
422
|
const slot = {
|
|
436
423
|
type: "toolCall",
|
|
437
424
|
block,
|
|
438
|
-
contentIndex: output.content.length - 1
|
|
425
|
+
contentIndex: output.content.length - 1,
|
|
426
|
+
input: customInput(inputProperty, input)
|
|
439
427
|
};
|
|
440
428
|
outputSlots.set(outputIndex, slot);
|
|
441
429
|
stream.push({ type: "toolcall_start", contentIndex: slot.contentIndex, partial: output });
|
|
@@ -565,33 +553,28 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
|
|
|
565
553
|
});
|
|
566
554
|
} else if (event.type === "response.function_call_arguments.delta") {
|
|
567
555
|
const slot = getSlot(event.output_index, "toolCall");
|
|
568
|
-
if (
|
|
556
|
+
if (slot?.input.kind !== "json")
|
|
569
557
|
continue;
|
|
570
|
-
slot.block.
|
|
571
|
-
slot.block.arguments = parseStreamingJson(slot.block.partialJson);
|
|
558
|
+
slot.block.arguments = slot.input.arguments.append(event.delta);
|
|
572
559
|
pushToolCallDelta(slot, event.delta);
|
|
573
560
|
} else if (event.type === "response.function_call_arguments.done") {
|
|
574
561
|
const slot = getSlot(event.output_index, "toolCall");
|
|
575
|
-
if (
|
|
562
|
+
if (slot?.input.kind !== "json")
|
|
576
563
|
continue;
|
|
577
|
-
const
|
|
578
|
-
slot.block.
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
const delta = event.arguments.slice(previousPartialJson.length);
|
|
582
|
-
if (delta.length > 0)
|
|
583
|
-
pushToolCallDelta(slot, delta);
|
|
584
|
-
}
|
|
564
|
+
const replaced = slot.input.arguments.replace(event.arguments);
|
|
565
|
+
slot.block.arguments = replaced.arguments;
|
|
566
|
+
if (replaced.delta)
|
|
567
|
+
pushToolCallDelta(slot, replaced.delta);
|
|
585
568
|
} else if (event.type === "response.custom_tool_call_input.delta") {
|
|
586
569
|
const slot = getSlot(event.output_index, "toolCall");
|
|
587
|
-
if (
|
|
570
|
+
if (slot?.input.kind !== "custom")
|
|
588
571
|
continue;
|
|
589
|
-
pushToolCallDelta(slot,
|
|
572
|
+
pushToolCallDelta(slot, appendCustomInput(slot.block, slot.input, event.delta));
|
|
590
573
|
} else if (event.type === "response.custom_tool_call_input.done") {
|
|
591
574
|
const slot = getSlot(event.output_index, "toolCall");
|
|
592
|
-
if (
|
|
575
|
+
if (slot?.input.kind !== "custom")
|
|
593
576
|
continue;
|
|
594
|
-
pushToolCallDelta(slot,
|
|
577
|
+
pushToolCallDelta(slot, closeCustomInput(slot.block, slot.input, event.input));
|
|
595
578
|
} else if (event.type === "response.output_item.done") {
|
|
596
579
|
const item = event.item;
|
|
597
580
|
applyMessagePhaseStopReason(item);
|
|
@@ -619,11 +602,13 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
|
|
|
619
602
|
partial: output
|
|
620
603
|
});
|
|
621
604
|
outputSlots.delete(event.output_index);
|
|
622
|
-
} else if (item.type === "function_call" && slot?.type === "toolCall" && slot.
|
|
623
|
-
|
|
605
|
+
} else if (item.type === "function_call" && slot?.type === "toolCall" && slot.input.kind === "json") {
|
|
606
|
+
if (item.arguments)
|
|
607
|
+
slot.input.arguments.replace(item.arguments);
|
|
608
|
+
Object.assign(slot.block, slot.input.arguments.finish());
|
|
624
609
|
if (item.namespace !== void 0)
|
|
625
610
|
slot.block.namespace = item.namespace;
|
|
626
|
-
delete
|
|
611
|
+
unfinishedToolCalls.delete(slot.block);
|
|
627
612
|
stream.push({
|
|
628
613
|
type: "toolcall_end",
|
|
629
614
|
contentIndex: slot.contentIndex,
|
|
@@ -631,11 +616,11 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
|
|
|
631
616
|
partial: output
|
|
632
617
|
});
|
|
633
618
|
outputSlots.delete(event.output_index);
|
|
634
|
-
} else if (item.type === "custom_tool_call" && slot?.type === "toolCall" && slot.
|
|
635
|
-
pushToolCallDelta(slot,
|
|
619
|
+
} else if (item.type === "custom_tool_call" && slot?.type === "toolCall" && slot.input.kind === "custom") {
|
|
620
|
+
pushToolCallDelta(slot, closeCustomInput(slot.block, slot.input, item.input));
|
|
636
621
|
if (item.namespace !== void 0)
|
|
637
622
|
slot.block.namespace = item.namespace;
|
|
638
|
-
delete
|
|
623
|
+
unfinishedToolCalls.delete(slot.block);
|
|
639
624
|
stream.push({
|
|
640
625
|
type: "toolcall_end",
|
|
641
626
|
contentIndex: slot.contentIndex,
|
|
@@ -661,16 +646,34 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
|
|
|
661
646
|
throw new Error("OpenAI Responses stream ended before a terminal response event");
|
|
662
647
|
}
|
|
663
648
|
if (output.stopReason === "toolUse") {
|
|
664
|
-
for (const
|
|
665
|
-
|
|
666
|
-
continue;
|
|
667
|
-
const toolCall = block;
|
|
668
|
-
if (toolCall.partialJson !== void 0 || toolCall.customInput !== void 0) {
|
|
669
|
-
throw new Error(`OpenAI Responses stream completed with an unfinished tool call: ${toolCall.name} (${toolCall.id})`);
|
|
670
|
-
}
|
|
649
|
+
for (const toolCall of unfinishedToolCalls) {
|
|
650
|
+
throw new Error(`OpenAI Responses stream completed with an unfinished tool call: ${toolCall.name} (${toolCall.id})`);
|
|
671
651
|
}
|
|
672
652
|
}
|
|
673
653
|
}
|
|
654
|
+
function customInput(property, initialInput) {
|
|
655
|
+
const buffer = { input: "", started: false, closed: false };
|
|
656
|
+
return {
|
|
657
|
+
kind: "custom",
|
|
658
|
+
property,
|
|
659
|
+
buffer,
|
|
660
|
+
unsent: appendGrammarToolInputJsonDelta(buffer, property, initialInput) ?? ""
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
function appendCustomInput(block, input, delta) {
|
|
664
|
+
return sendCustomInput(block, input, appendGrammarToolInputJsonDelta(input.buffer, input.property, delta));
|
|
665
|
+
}
|
|
666
|
+
function closeCustomInput(block, input, finalInput) {
|
|
667
|
+
return sendCustomInput(block, input, closeGrammarToolInputJson(input.buffer, input.property, finalInput));
|
|
668
|
+
}
|
|
669
|
+
function sendCustomInput(block, input, jsonDelta) {
|
|
670
|
+
block.arguments = { [input.property]: input.buffer.input };
|
|
671
|
+
if (input.unsent === "")
|
|
672
|
+
return jsonDelta;
|
|
673
|
+
const sent = input.unsent + (jsonDelta ?? "");
|
|
674
|
+
input.unsent = "";
|
|
675
|
+
return sent;
|
|
676
|
+
}
|
|
674
677
|
function mapStopReason(status, incompleteReason) {
|
|
675
678
|
if (!status)
|
|
676
679
|
return { stopReason: "stop" };
|