@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
|
@@ -1,63 +1,83 @@
|
|
|
1
1
|
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
2
|
const require = __nerveCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
hasExceededStrictToolLimits,
|
|
5
|
+
isStrictToolLimitErrorMessage,
|
|
6
|
+
markStrictToolLimitsExceeded
|
|
7
|
+
} from "./chunk-L5WGVYXM.js";
|
|
3
8
|
import {
|
|
4
9
|
Anthropic
|
|
5
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-M3ELKCNA.js";
|
|
6
11
|
import {
|
|
7
12
|
ANTHROPIC_FEDERATION_RULE_ID_ENV,
|
|
8
13
|
ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,
|
|
9
14
|
ANTHROPIC_ORGANIZATION_ID_ENV,
|
|
10
15
|
ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,
|
|
11
16
|
ANTHROPIC_WORKSPACE_ID_ENV
|
|
12
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-RL52LSTV.js";
|
|
18
|
+
import {
|
|
19
|
+
registerSessionResourceCleanup
|
|
20
|
+
} from "./chunk-ZVH6EB7S.js";
|
|
21
|
+
import {
|
|
22
|
+
applyOpenRouterReportedCost,
|
|
23
|
+
isOpenRouterModel
|
|
24
|
+
} from "./chunk-N4OXAS3A.js";
|
|
13
25
|
import {
|
|
14
26
|
buildCopilotDynamicHeaders,
|
|
15
27
|
hasCopilotVisionInput
|
|
16
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-TQURLRHD.js";
|
|
17
29
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
parseToolCallArguments
|
|
21
|
-
} from "./chunk-RUZ2UAYH.js";
|
|
30
|
+
shortHash
|
|
31
|
+
} from "./chunk-LP4APBBQ.js";
|
|
22
32
|
import {
|
|
23
33
|
adjustMaxTokensForThinking,
|
|
24
34
|
buildBaseOptions,
|
|
25
35
|
clampMaxTokensToContext,
|
|
26
36
|
getJsonSchemaToolParameters,
|
|
37
|
+
prefersJsonSchemaStrictSampling,
|
|
27
38
|
resolveJsonSchemaStrictSampling,
|
|
28
39
|
splitErrorToolResultImages,
|
|
29
40
|
transformMessages
|
|
30
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-Z6AY5VOZ.js";
|
|
31
42
|
import {
|
|
32
43
|
sanitizeSurrogates
|
|
33
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-TSAUBRRU.js";
|
|
34
45
|
import {
|
|
35
46
|
retryProviderRequest
|
|
36
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-3CZXUKLG.js";
|
|
48
|
+
import {
|
|
49
|
+
withCauseDetail
|
|
50
|
+
} from "./chunk-PVPJAGWR.js";
|
|
37
51
|
import {
|
|
38
52
|
headersToRecord
|
|
39
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-6IHXVT5H.js";
|
|
40
54
|
import {
|
|
41
55
|
getProviderEnvValue
|
|
42
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-JBEWFFOK.js";
|
|
57
|
+
import {
|
|
58
|
+
ToolCallArgumentsStream,
|
|
59
|
+
parseJsonWithRepair
|
|
60
|
+
} from "./chunk-BG2KGLIA.js";
|
|
43
61
|
import {
|
|
44
62
|
calculateCost,
|
|
45
63
|
getCurrentTools,
|
|
46
64
|
getInitialSystemMessage,
|
|
47
|
-
getSystemMessageText,
|
|
48
|
-
renderSystemMessageUpdate,
|
|
49
65
|
resolveTranscript
|
|
50
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-W7LEYYFH.js";
|
|
51
67
|
import {
|
|
52
68
|
AssistantMessageEventStream,
|
|
53
69
|
appendAssistantMessageDiagnostic
|
|
54
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-DDBE2VLT.js";
|
|
55
71
|
import {
|
|
56
72
|
getIdentityHeaders
|
|
57
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-Q3C7TQ2M.js";
|
|
74
|
+
import {
|
|
75
|
+
getSystemMessageText,
|
|
76
|
+
renderSystemMessageUpdate
|
|
77
|
+
} from "./chunk-U5KGV63C.js";
|
|
58
78
|
import "./chunk-CWESUMYQ.js";
|
|
59
79
|
|
|
60
|
-
// node_modules/.pnpm/@earendil-works+pi-ai@1.
|
|
80
|
+
// 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/anthropic-messages.js
|
|
61
81
|
function resolveCacheRetention(cacheRetention, env) {
|
|
62
82
|
if (cacheRetention) {
|
|
63
83
|
return cacheRetention;
|
|
@@ -78,7 +98,7 @@ function getCacheControl(model, cacheRetention, env) {
|
|
|
78
98
|
cacheControl: { type: "ephemeral", ...ttl && { ttl } }
|
|
79
99
|
};
|
|
80
100
|
}
|
|
81
|
-
var claudeCodeVersion = "2.1.
|
|
101
|
+
var claudeCodeVersion = "2.1.322";
|
|
82
102
|
var claudeCodeTools = [
|
|
83
103
|
"Read",
|
|
84
104
|
"Write",
|
|
@@ -148,6 +168,7 @@ var SERVER_SIDE_FALLBACK_BETA = "server-side-fallback-2026-07-01";
|
|
|
148
168
|
var MID_CONVERSATION_OUTPUT_CONFIG_BETA = "mid-conversation-output-config-2026-07-01";
|
|
149
169
|
var THINKING_BINDING_CONTROLS_BETA = "thinking-binding-controls-2026-08-01";
|
|
150
170
|
var INLINE_TOOLS_BETA = "inline-tools-2026-09-15";
|
|
171
|
+
var MESSAGE_THREADS_BETA = "message-threads-2026-08-12";
|
|
151
172
|
var DEFERRED_TOOL_PLACEHOLDER = {
|
|
152
173
|
name: "__pi_deferred_placeholder__",
|
|
153
174
|
description: "Reserved placeholder. Never available. Never call this.",
|
|
@@ -169,9 +190,122 @@ function getAnthropicCompat(model) {
|
|
|
169
190
|
allowEmptySignature: model.compat?.allowEmptySignature ?? false,
|
|
170
191
|
supportsStrictTools: model.compat?.supportsStrictTools ?? false,
|
|
171
192
|
supportsMidConvoSystemMessages: model.compat?.supportsMidConvoSystemMessages ?? false,
|
|
172
|
-
supportsMidConvoToolChanges: model.compat?.supportsMidConvoToolChanges ?? false
|
|
193
|
+
supportsMidConvoToolChanges: model.compat?.supportsMidConvoToolChanges ?? false,
|
|
194
|
+
// Gateways that drop unknown request fields would silently turn a `continue` into a request
|
|
195
|
+
// without the earlier conversation, so the default is limited to Anthropic's own endpoint.
|
|
196
|
+
// Widen or remove this restriction once proxies generally forward the `thread` field.
|
|
197
|
+
supportsMessageThreads: model.compat?.supportsMessageThreads ?? (model.provider === "anthropic" && model.baseUrl.includes("api.anthropic.com"))
|
|
173
198
|
};
|
|
174
199
|
}
|
|
200
|
+
var threadState = /* @__PURE__ */ new Map();
|
|
201
|
+
var MAX_THREAD_STATE_ENTRIES = 1e4;
|
|
202
|
+
var NEW_THREAD_ERRORS = /* @__PURE__ */ new Set([
|
|
203
|
+
"thread_not_found",
|
|
204
|
+
"thread_already_continued",
|
|
205
|
+
"thread_continue_in_flight",
|
|
206
|
+
"thread_fingerprint_mismatch"
|
|
207
|
+
]);
|
|
208
|
+
function setThreadState(sessionId, value) {
|
|
209
|
+
threadState.delete(sessionId);
|
|
210
|
+
threadState.set(sessionId, value);
|
|
211
|
+
if (threadState.size > MAX_THREAD_STATE_ENTRIES) {
|
|
212
|
+
const oldest = threadState.keys().next().value;
|
|
213
|
+
if (oldest !== void 0)
|
|
214
|
+
threadState.delete(oldest);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
registerSessionResourceCleanup((sessionId) => {
|
|
218
|
+
if (sessionId)
|
|
219
|
+
threadState.delete(sessionId);
|
|
220
|
+
else
|
|
221
|
+
threadState.clear();
|
|
222
|
+
});
|
|
223
|
+
function hashThreadPrefix(model, params, messages) {
|
|
224
|
+
const { system, tools, thinking, output_config, tool_choice, betas, fallbacks } = params;
|
|
225
|
+
const settings = JSON.stringify([
|
|
226
|
+
model.provider,
|
|
227
|
+
model.baseUrl,
|
|
228
|
+
params.model,
|
|
229
|
+
system,
|
|
230
|
+
tools,
|
|
231
|
+
thinking,
|
|
232
|
+
output_config,
|
|
233
|
+
tool_choice,
|
|
234
|
+
betas,
|
|
235
|
+
fallbacks
|
|
236
|
+
]);
|
|
237
|
+
const conversation = JSON.stringify(messages, (key, value) => {
|
|
238
|
+
if (key === "cache_control")
|
|
239
|
+
return void 0;
|
|
240
|
+
if (key === "content" && typeof value === "string")
|
|
241
|
+
return [{ type: "text", text: value }];
|
|
242
|
+
return value;
|
|
243
|
+
});
|
|
244
|
+
return shortHash(settings + conversation);
|
|
245
|
+
}
|
|
246
|
+
function createThreadRequest(sessionId, params) {
|
|
247
|
+
return { sessionId, body: { ...params, thread: { type: "create" } } };
|
|
248
|
+
}
|
|
249
|
+
function prepareThreadRequest(model, sessionId, params) {
|
|
250
|
+
const state = threadState.get(sessionId);
|
|
251
|
+
if (state === "off")
|
|
252
|
+
return void 0;
|
|
253
|
+
if (state !== void 0 && params.messages.length > state.prefixCount && hashThreadPrefix(model, params, params.messages.slice(0, state.prefixCount)) === state.prefixHash) {
|
|
254
|
+
threadState.delete(sessionId);
|
|
255
|
+
const { system: _system, tools: _tools, ...rest } = params;
|
|
256
|
+
return {
|
|
257
|
+
body: {
|
|
258
|
+
...rest,
|
|
259
|
+
messages: params.messages.slice(state.prefixCount),
|
|
260
|
+
thread: { type: "continue", previous_message_id: state.replyId }
|
|
261
|
+
},
|
|
262
|
+
sessionId
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
return createThreadRequest(sessionId, params);
|
|
266
|
+
}
|
|
267
|
+
function getThreadErrorCode(error) {
|
|
268
|
+
const body = error.error;
|
|
269
|
+
const code = body?.error?.details?.error_code;
|
|
270
|
+
return typeof code === "string" ? code : void 0;
|
|
271
|
+
}
|
|
272
|
+
async function sendThreadRequest(thread, params, send, output, signal) {
|
|
273
|
+
try {
|
|
274
|
+
return { response: await send(thread.body), thread };
|
|
275
|
+
} catch (error) {
|
|
276
|
+
if (signal?.aborted || !(error instanceof Anthropic.APIError))
|
|
277
|
+
throw error;
|
|
278
|
+
const errorCode = getThreadErrorCode(error);
|
|
279
|
+
const startNewThread = errorCode !== void 0 && NEW_THREAD_ERRORS.has(errorCode);
|
|
280
|
+
const threadsUnsupported = errorCode === "thread_unsupported_request" || errorCode === void 0 && error.status === 400 && error.message.includes("thread");
|
|
281
|
+
if (!startNewThread && !threadsUnsupported)
|
|
282
|
+
throw error;
|
|
283
|
+
appendAssistantMessageDiagnostic(output, {
|
|
284
|
+
type: "anthropic_thread_fallback",
|
|
285
|
+
timestamp: Date.now(),
|
|
286
|
+
error: { message: error.message },
|
|
287
|
+
details: { reason: errorCode ?? String(error.status) }
|
|
288
|
+
});
|
|
289
|
+
if (startNewThread) {
|
|
290
|
+
const created = createThreadRequest(thread.sessionId, params);
|
|
291
|
+
return { response: await send(created.body), thread: created };
|
|
292
|
+
}
|
|
293
|
+
const response = await send(params);
|
|
294
|
+
setThreadState(thread.sessionId, "off");
|
|
295
|
+
return { response, thread: void 0 };
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function recordThreadReply(model, thread, params, output, isOAuth, allowEmptySignature) {
|
|
299
|
+
if (output.responseId === void 0 || output.responseModel !== void 0)
|
|
300
|
+
return;
|
|
301
|
+
const reply = convertMessages(transformMessages([output], model, normalizeToolCallId), isOAuth, void 0, allowEmptySignature).messages.filter((message) => message.role === "assistant");
|
|
302
|
+
const prefix = [...params.messages, ...reply];
|
|
303
|
+
setThreadState(thread.sessionId, {
|
|
304
|
+
prefixCount: prefix.length,
|
|
305
|
+
prefixHash: hashThreadPrefix(model, params, prefix),
|
|
306
|
+
replyId: output.responseId
|
|
307
|
+
});
|
|
308
|
+
}
|
|
175
309
|
function mergeHeaders(...headerSources) {
|
|
176
310
|
const merged = {};
|
|
177
311
|
for (const headers of headerSources) {
|
|
@@ -372,7 +506,8 @@ async function* iterateAnthropicEvents(response, signal) {
|
|
|
372
506
|
}
|
|
373
507
|
var stream = (model, context, options) => {
|
|
374
508
|
const stream2 = new AssistantMessageEventStream();
|
|
375
|
-
const
|
|
509
|
+
const compat = getAnthropicCompat(model);
|
|
510
|
+
const normalizedContext = resolveTranscript(context, compat.supportsMidConvoSystemMessages);
|
|
376
511
|
const currentTools = getCurrentTools(normalizedContext.messages);
|
|
377
512
|
(async () => {
|
|
378
513
|
const output = {
|
|
@@ -397,6 +532,9 @@ var stream = (model, context, options) => {
|
|
|
397
532
|
let isOAuth;
|
|
398
533
|
let usageModel = model;
|
|
399
534
|
let inputTransformations;
|
|
535
|
+
const cacheRetention = resolveCacheRetention(options?.cacheRetention, options?.env);
|
|
536
|
+
const cacheSessionId = cacheRetention === "none" ? void 0 : options?.sessionId;
|
|
537
|
+
const threadSessionId = compat.supportsMessageThreads ? cacheSessionId : void 0;
|
|
400
538
|
if (options?.client) {
|
|
401
539
|
client = options.client;
|
|
402
540
|
isOAuth = false;
|
|
@@ -413,8 +551,6 @@ var stream = (model, context, options) => {
|
|
|
413
551
|
hasImages
|
|
414
552
|
});
|
|
415
553
|
}
|
|
416
|
-
const cacheRetention = resolveCacheRetention(options?.cacheRetention, options?.env);
|
|
417
|
-
const cacheSessionId = cacheRetention === "none" ? void 0 : options?.sessionId;
|
|
418
554
|
const created = createClient(model, apiKey, options?.headers, options?.fetch, copilotDynamicHeaders, cacheSessionId, federation, options?.identity);
|
|
419
555
|
client = created.client;
|
|
420
556
|
isOAuth = created.isOAuthToken;
|
|
@@ -424,34 +560,40 @@ var stream = (model, context, options) => {
|
|
|
424
560
|
...options?.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {},
|
|
425
561
|
maxRetries: 0
|
|
426
562
|
};
|
|
427
|
-
|
|
563
|
+
const send = (body) => retryProviderRequest(() => client.beta.messages.create(body, requestOptions).asResponse(), {
|
|
564
|
+
maxRetries: options?.maxRetries,
|
|
565
|
+
maxRetryDelayMs: options?.maxRetryDelayMs,
|
|
566
|
+
signal: options?.signal
|
|
567
|
+
});
|
|
568
|
+
let disablePreferredStrictTools = hasExceededStrictToolLimits(options?.sessionId);
|
|
428
569
|
let response;
|
|
570
|
+
let params;
|
|
571
|
+
let thread;
|
|
429
572
|
for (; ; ) {
|
|
430
573
|
options?.signal?.throwIfAborted();
|
|
431
|
-
const built = buildParams(model, normalizedContext, isOAuth, options,
|
|
574
|
+
const built = buildParams(model, normalizedContext, isOAuth, options, {
|
|
575
|
+
disablePreferredStrictTools,
|
|
576
|
+
messageThreads: threadSessionId !== void 0
|
|
577
|
+
});
|
|
432
578
|
if (built.providerThinkingLevel)
|
|
433
579
|
output.providerThinkingLevel = built.providerThinkingLevel;
|
|
434
|
-
|
|
580
|
+
params = built.params;
|
|
435
581
|
const nextParams = await options?.onPayload?.(params, model);
|
|
436
582
|
if (nextParams !== void 0) {
|
|
437
583
|
params = { ...nextParams, stream: true };
|
|
438
584
|
}
|
|
585
|
+
const prepared = threadSessionId !== void 0 && options?.disableContinuation !== true ? prepareThreadRequest(model, threadSessionId, params) : void 0;
|
|
439
586
|
try {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
signal: options?.signal
|
|
444
|
-
});
|
|
587
|
+
const sent = prepared ? await sendThreadRequest(prepared, params, send, output, options?.signal) : { response: await send(params), thread: void 0 };
|
|
588
|
+
response = sent.response;
|
|
589
|
+
thread = sent.thread;
|
|
445
590
|
break;
|
|
446
591
|
} catch (error) {
|
|
447
|
-
if (options?.signal?.aborted || disablePreferredStrictTools || !built.hasPreferredStrictTools || !(error instanceof Anthropic.APIError) || error.status !== 400 || error.type !== "invalid_request_error" || !
|
|
448
|
-
"The compiled grammar is too large",
|
|
449
|
-
"Too many strict tools (",
|
|
450
|
-
"Schemas contains too many parameters with union types ("
|
|
451
|
-
].some((message) => error.message.includes(message))) {
|
|
592
|
+
if (options?.signal?.aborted || disablePreferredStrictTools || !built.hasPreferredStrictTools || !(error instanceof Anthropic.APIError) || error.status !== 400 || error.type !== "invalid_request_error" || !isStrictToolLimitErrorMessage(error.message)) {
|
|
452
593
|
throw error;
|
|
453
594
|
}
|
|
454
595
|
disablePreferredStrictTools = true;
|
|
596
|
+
markStrictToolLimitsExceeded(options?.sessionId);
|
|
455
597
|
appendAssistantMessageDiagnostic(output, {
|
|
456
598
|
type: "anthropic_strict_tools_fallback",
|
|
457
599
|
timestamp: Date.now(),
|
|
@@ -462,7 +604,11 @@ var stream = (model, context, options) => {
|
|
|
462
604
|
}
|
|
463
605
|
await options?.onResponse?.({ status: response.status, headers: headersToRecord(response.headers) }, model);
|
|
464
606
|
stream2.push({ type: "start", partial: output });
|
|
465
|
-
const
|
|
607
|
+
const openBlocks = /* @__PURE__ */ new Map();
|
|
608
|
+
const openBlock = (anthropicIndex) => {
|
|
609
|
+
const open = openBlocks.get(anthropicIndex);
|
|
610
|
+
return open === void 0 ? void 0 : { ...open, block: output.content[open.contentIndex] };
|
|
611
|
+
};
|
|
466
612
|
for await (const event of iterateAnthropicEvents(response, options?.signal)) {
|
|
467
613
|
await options?.onProviderStreamEvent?.(event, model);
|
|
468
614
|
if (event.type === "message_start") {
|
|
@@ -490,95 +636,82 @@ var stream = (model, context, options) => {
|
|
|
490
636
|
continue;
|
|
491
637
|
}
|
|
492
638
|
if (event.content_block.type === "text") {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
text: event.content_block.text ?? "",
|
|
496
|
-
index: event.index
|
|
497
|
-
};
|
|
498
|
-
output.content.push(block);
|
|
639
|
+
output.content.push({ type: "text", text: event.content_block.text ?? "" });
|
|
640
|
+
openBlocks.set(event.index, { contentIndex: output.content.length - 1 });
|
|
499
641
|
stream2.push({ type: "text_start", contentIndex: output.content.length - 1, partial: output });
|
|
500
642
|
} else if (event.content_block.type === "thinking") {
|
|
501
|
-
|
|
643
|
+
output.content.push({
|
|
502
644
|
type: "thinking",
|
|
503
645
|
thinking: event.content_block.thinking ?? "",
|
|
504
|
-
thinkingSignature: event.content_block.signature ?? ""
|
|
505
|
-
|
|
506
|
-
};
|
|
507
|
-
output.content.push(block);
|
|
646
|
+
thinkingSignature: event.content_block.signature ?? ""
|
|
647
|
+
});
|
|
648
|
+
openBlocks.set(event.index, { contentIndex: output.content.length - 1 });
|
|
508
649
|
stream2.push({ type: "thinking_start", contentIndex: output.content.length - 1, partial: output });
|
|
509
650
|
} else if (event.content_block.type === "redacted_thinking") {
|
|
510
|
-
|
|
651
|
+
output.content.push({
|
|
511
652
|
type: "thinking",
|
|
512
653
|
thinking: "[Reasoning redacted]",
|
|
513
654
|
thinkingSignature: event.content_block.data,
|
|
514
|
-
redacted: true
|
|
515
|
-
|
|
516
|
-
};
|
|
517
|
-
output.content.push(block);
|
|
655
|
+
redacted: true
|
|
656
|
+
});
|
|
657
|
+
openBlocks.set(event.index, { contentIndex: output.content.length - 1 });
|
|
518
658
|
stream2.push({ type: "thinking_start", contentIndex: output.content.length - 1, partial: output });
|
|
519
659
|
} else if (event.content_block.type === "tool_use") {
|
|
520
|
-
|
|
660
|
+
output.content.push({
|
|
521
661
|
type: "toolCall",
|
|
522
662
|
id: event.content_block.id,
|
|
523
663
|
name: isOAuth ? fromClaudeCodeName(event.content_block.name, currentTools) : event.content_block.name,
|
|
524
|
-
arguments: event.content_block.input ?? {}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
664
|
+
arguments: event.content_block.input ?? {}
|
|
665
|
+
});
|
|
666
|
+
openBlocks.set(event.index, {
|
|
667
|
+
contentIndex: output.content.length - 1,
|
|
668
|
+
arguments: new ToolCallArgumentsStream()
|
|
669
|
+
});
|
|
529
670
|
stream2.push({ type: "toolcall_start", contentIndex: output.content.length - 1, partial: output });
|
|
530
671
|
}
|
|
531
672
|
} else if (event.type === "content_block_delta") {
|
|
673
|
+
const open = openBlock(event.index);
|
|
532
674
|
if (event.delta.type === "text_delta") {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
if (block && block.type === "text") {
|
|
536
|
-
block.text += event.delta.text;
|
|
675
|
+
if (open?.block.type === "text") {
|
|
676
|
+
open.block.text += event.delta.text;
|
|
537
677
|
stream2.push({
|
|
538
678
|
type: "text_delta",
|
|
539
|
-
contentIndex:
|
|
679
|
+
contentIndex: open.contentIndex,
|
|
540
680
|
delta: event.delta.text,
|
|
541
681
|
partial: output
|
|
542
682
|
});
|
|
543
683
|
}
|
|
544
684
|
} else if (event.delta.type === "thinking_delta") {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
if (block && block.type === "thinking") {
|
|
548
|
-
block.thinking += event.delta.thinking;
|
|
685
|
+
if (open?.block.type === "thinking") {
|
|
686
|
+
open.block.thinking += event.delta.thinking;
|
|
549
687
|
stream2.push({
|
|
550
688
|
type: "thinking_delta",
|
|
551
|
-
contentIndex:
|
|
689
|
+
contentIndex: open.contentIndex,
|
|
552
690
|
delta: event.delta.thinking,
|
|
553
691
|
partial: output
|
|
554
692
|
});
|
|
555
693
|
}
|
|
556
694
|
} else if (event.delta.type === "input_json_delta") {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
if (block && block.type === "toolCall") {
|
|
560
|
-
block.partialJson += event.delta.partial_json;
|
|
561
|
-
block.arguments = parseStreamingJson(block.partialJson);
|
|
695
|
+
if (open?.block.type === "toolCall" && open.arguments !== void 0) {
|
|
696
|
+
open.block.arguments = open.arguments.append(event.delta.partial_json);
|
|
562
697
|
stream2.push({
|
|
563
698
|
type: "toolcall_delta",
|
|
564
|
-
contentIndex:
|
|
699
|
+
contentIndex: open.contentIndex,
|
|
565
700
|
delta: event.delta.partial_json,
|
|
566
701
|
partial: output
|
|
567
702
|
});
|
|
568
703
|
}
|
|
569
704
|
} else if (event.delta.type === "signature_delta") {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
block.thinkingSignature = block.thinkingSignature || "";
|
|
574
|
-
block.thinkingSignature += event.delta.signature;
|
|
705
|
+
if (open?.block.type === "thinking") {
|
|
706
|
+
open.block.thinkingSignature = open.block.thinkingSignature || "";
|
|
707
|
+
open.block.thinkingSignature += event.delta.signature;
|
|
575
708
|
}
|
|
576
709
|
}
|
|
577
710
|
} else if (event.type === "content_block_stop") {
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
if (
|
|
581
|
-
|
|
711
|
+
const open = openBlock(event.index);
|
|
712
|
+
openBlocks.delete(event.index);
|
|
713
|
+
if (open) {
|
|
714
|
+
const { block, contentIndex: index } = open;
|
|
582
715
|
if (block.type === "text") {
|
|
583
716
|
stream2.push({
|
|
584
717
|
type: "text_end",
|
|
@@ -593,9 +726,8 @@ var stream = (model, context, options) => {
|
|
|
593
726
|
content: block.thinking,
|
|
594
727
|
partial: output
|
|
595
728
|
});
|
|
596
|
-
} else if (block.type === "toolCall") {
|
|
597
|
-
Object.assign(block,
|
|
598
|
-
delete block.partialJson;
|
|
729
|
+
} else if (block.type === "toolCall" && open.arguments !== void 0) {
|
|
730
|
+
Object.assign(block, open.arguments.finish());
|
|
599
731
|
stream2.push({
|
|
600
732
|
type: "toolcall_end",
|
|
601
733
|
contentIndex: index,
|
|
@@ -640,6 +772,9 @@ var stream = (model, context, options) => {
|
|
|
640
772
|
}
|
|
641
773
|
output.usage.totalTokens = output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
|
|
642
774
|
calculateCost(usageModel, output.usage);
|
|
775
|
+
if (isOpenRouterModel(model) && event.usage) {
|
|
776
|
+
applyOpenRouterReportedCost(output.usage, event.usage);
|
|
777
|
+
}
|
|
643
778
|
}
|
|
644
779
|
}
|
|
645
780
|
if (options?.signal?.aborted) {
|
|
@@ -651,6 +786,8 @@ var stream = (model, context, options) => {
|
|
|
651
786
|
if (output.stopReason === "aborted" || output.stopReason === "error") {
|
|
652
787
|
throw new Error(output.errorMessage || "An unknown error occurred");
|
|
653
788
|
}
|
|
789
|
+
if (thread)
|
|
790
|
+
recordThreadReply(model, thread, params, output, isOAuth, compat.allowEmptySignature);
|
|
654
791
|
if (inputTransformations && inputTransformations.length > 0) {
|
|
655
792
|
appendAssistantMessageDiagnostic(output, {
|
|
656
793
|
type: "anthropic_input_transformations",
|
|
@@ -667,12 +804,8 @@ var stream = (model, context, options) => {
|
|
|
667
804
|
stream2.push({ type: "done", reason: output.stopReason, message: output });
|
|
668
805
|
stream2.end();
|
|
669
806
|
} catch (error) {
|
|
670
|
-
for (const block of output.content) {
|
|
671
|
-
delete block.index;
|
|
672
|
-
delete block.partialJson;
|
|
673
|
-
}
|
|
674
807
|
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
675
|
-
output.errorMessage = error instanceof Error ? error
|
|
808
|
+
output.errorMessage = error instanceof Error ? withCauseDetail(error) : JSON.stringify(error);
|
|
676
809
|
stream2.push({ type: "error", reason: output.stopReason, error: output });
|
|
677
810
|
stream2.end();
|
|
678
811
|
}
|
|
@@ -795,7 +928,7 @@ function createClient(model, apiKey, optionsHeaders, fetch, dynamicHeaders, sess
|
|
|
795
928
|
});
|
|
796
929
|
return { client, isOAuthToken: false };
|
|
797
930
|
}
|
|
798
|
-
function getBetaFeatures(model, context, isOAuthToken2, nativeToolChanges,
|
|
931
|
+
function getBetaFeatures(model, context, options, { isOAuthToken: isOAuthToken2, nativeToolChanges, messageThreads }) {
|
|
799
932
|
let configuredFeatures;
|
|
800
933
|
for (const headers of [model.headers, options?.headers]) {
|
|
801
934
|
for (const [name, value] of Object.entries(headers ?? {})) {
|
|
@@ -825,9 +958,11 @@ function getBetaFeatures(model, context, isOAuthToken2, nativeToolChanges, optio
|
|
|
825
958
|
}
|
|
826
959
|
if (nativeToolChanges)
|
|
827
960
|
features.push(INLINE_TOOLS_BETA);
|
|
961
|
+
if (messageThreads)
|
|
962
|
+
features.push(MESSAGE_THREADS_BETA);
|
|
828
963
|
return [...new Set(features)];
|
|
829
964
|
}
|
|
830
|
-
function buildParams(model, context, isOAuthToken2, options,
|
|
965
|
+
function buildParams(model, context, isOAuthToken2, options, flags) {
|
|
831
966
|
const { cacheControl } = getCacheControl(model, options?.cacheRetention, options?.env);
|
|
832
967
|
const compat = getAnthropicCompat(model);
|
|
833
968
|
const initialSystemMessage = getInitialSystemMessage(context.messages);
|
|
@@ -836,11 +971,8 @@ function buildParams(model, context, isOAuthToken2, options, disablePreferredStr
|
|
|
836
971
|
const conversationMessages = initialSystemMessage ? transformedMessages.slice(1) : transformedMessages;
|
|
837
972
|
let hasPreferredStrictTools = false;
|
|
838
973
|
const convertToolDefinitions = (tools, toolCacheControl2) => {
|
|
839
|
-
const definitions = convertTools(tools, isOAuthToken2, compat.supportsEagerToolInputStreaming, compat.supportsStrictTools, toolCacheControl2, disablePreferredStrictTools);
|
|
840
|
-
if (definitions.some((definition, index) => {
|
|
841
|
-
const config = tools[index].constrainedSampling;
|
|
842
|
-
return definition.strict === true && config && config.type === "json_schema" && config.strict === "prefer";
|
|
843
|
-
})) {
|
|
974
|
+
const definitions = convertTools(tools, isOAuthToken2, compat.supportsEagerToolInputStreaming, compat.supportsStrictTools, toolCacheControl2, flags.disablePreferredStrictTools);
|
|
975
|
+
if (definitions.some((definition, index) => definition.strict === true && prefersJsonSchemaStrictSampling(tools[index]))) {
|
|
844
976
|
hasPreferredStrictTools = true;
|
|
845
977
|
}
|
|
846
978
|
return definitions;
|
|
@@ -851,7 +983,11 @@ function buildParams(model, context, isOAuthToken2, options, disablePreferredStr
|
|
|
851
983
|
const effortMessages = model.compat?.supportsMidConvoEffort === true && !thinkingDisabled;
|
|
852
984
|
const converted = convertMessages(conversationMessages, isOAuthToken2, cacheControl, compat.allowEmptySignature, effortMessages ? model.provider : void 0, nativeToolChanges ? convertToolDefinitions : void 0);
|
|
853
985
|
const activeEffort = options?.effort ?? "high";
|
|
854
|
-
const betaFeatures = getBetaFeatures(model, context,
|
|
986
|
+
const betaFeatures = getBetaFeatures(model, context, options, {
|
|
987
|
+
isOAuthToken: isOAuthToken2,
|
|
988
|
+
nativeToolChanges,
|
|
989
|
+
messageThreads: flags.messageThreads
|
|
990
|
+
});
|
|
855
991
|
const params = {
|
|
856
992
|
model: model.id,
|
|
857
993
|
messages: effortMessages ? insertThinkingLevelMessages(converted, activeEffort) : converted.messages,
|
|
@@ -903,7 +1039,7 @@ function buildParams(model, context, isOAuthToken2, options, disablePreferredStr
|
|
|
903
1039
|
display: options?.thinkingDisplay ?? "summarized",
|
|
904
1040
|
block_binding: { prefix_mismatch_behavior: "drop_block" }
|
|
905
1041
|
};
|
|
906
|
-
params.output_config = { effort: "
|
|
1042
|
+
params.output_config = { effort: "low" };
|
|
907
1043
|
} else if (model.reasoning && options?.thinkingEnabled) {
|
|
908
1044
|
const display = options.thinkingDisplay ?? "summarized";
|
|
909
1045
|
if (model.compat?.forceAdaptiveThinking === true) {
|
|
@@ -1014,7 +1150,6 @@ function convertMessages(transformedMessages, isOAuthToken2, cacheControl, allow
|
|
|
1014
1150
|
});
|
|
1015
1151
|
}
|
|
1016
1152
|
} else if (msg.role === "assistant") {
|
|
1017
|
-
flushPendingSystemMessages();
|
|
1018
1153
|
const blocks = [];
|
|
1019
1154
|
for (const block of msg.content) {
|
|
1020
1155
|
if (block.type === "text") {
|
|
@@ -1063,6 +1198,7 @@ function convertMessages(transformedMessages, isOAuthToken2, cacheControl, allow
|
|
|
1063
1198
|
}
|
|
1064
1199
|
if (blocks.length === 0)
|
|
1065
1200
|
continue;
|
|
1201
|
+
flushPendingSystemMessages();
|
|
1066
1202
|
const messageIndex = params.length;
|
|
1067
1203
|
params.push({
|
|
1068
1204
|
role: "assistant",
|
|
@@ -1169,14 +1305,15 @@ function convertTools(tools, isOAuthToken2, supportsEagerToolInputStreaming, sup
|
|
|
1169
1305
|
if (!tools)
|
|
1170
1306
|
return [];
|
|
1171
1307
|
return tools.map((tool, index) => {
|
|
1172
|
-
const
|
|
1173
|
-
const strict = disablePreferredStrictTools && config && config.type === "json_schema" && config.strict === "prefer" ? void 0 : resolveJsonSchemaStrictSampling(tool, supportsStrictTools, isAnthropicStrictUnsupportedKeyword);
|
|
1308
|
+
const strict = disablePreferredStrictTools && prefersJsonSchemaStrictSampling(tool) ? void 0 : resolveJsonSchemaStrictSampling(tool, supportsStrictTools, isAnthropicStrictUnsupportedKeyword);
|
|
1174
1309
|
const parameters = getJsonSchemaToolParameters(tool, strict);
|
|
1175
1310
|
const schema = parameters;
|
|
1176
1311
|
const legacyInputSchema = {
|
|
1177
1312
|
type: "object",
|
|
1178
1313
|
properties: schema.properties ?? {},
|
|
1179
|
-
required: schema.required ?? []
|
|
1314
|
+
required: schema.required ?? [],
|
|
1315
|
+
...schema.$defs === void 0 ? {} : { $defs: schema.$defs },
|
|
1316
|
+
...schema.definitions === void 0 ? {} : { definitions: schema.definitions }
|
|
1180
1317
|
};
|
|
1181
1318
|
const inputSchema = strict === true ? {
|
|
1182
1319
|
...parameters,
|