decocms 4.240.0 → 4.241.1

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.
Files changed (261) hide show
  1. package/dist/client/assets/{AlertCircle-Cg3fHuBn.js → AlertCircle-DM41S5Z5.js} +1 -1
  2. package/dist/client/assets/{AreaChart-Dahh-4-C.js → AreaChart-CeS7wdSU.js} +1 -1
  3. package/dist/client/assets/{ArrowLeft-CKDBuIH0.js → ArrowLeft-_2CMEHl-.js} +1 -1
  4. package/dist/client/assets/{ArrowUp-CNSXQcbu.js → ArrowUp-BakohXbr.js} +1 -1
  5. package/dist/client/assets/{ArrowUpRight-CiPprS4P.js → ArrowUpRight-CTpe7RIn.js} +1 -1
  6. package/dist/client/assets/{Check-BajQzgjU.js → Check-D1jXHJCh.js} +1 -1
  7. package/dist/client/assets/{CheckCircle-jMq_LGKl.js → CheckCircle-AYtQ59q6.js} +1 -1
  8. package/dist/client/assets/{ChevronDown-B1SP4Q2f.js → ChevronDown-CQzgTDWg.js} +1 -1
  9. package/dist/client/assets/{ChevronRight-DYzmp5S1.js → ChevronRight-zOukHN5J.js} +1 -1
  10. package/dist/client/assets/{ChevronUp-CmjfaMFY.js → ChevronUp-CxLYLOrv.js} +1 -1
  11. package/dist/client/assets/{Copy01-1rF1hHQA.js → Copy01-C1bOkt0L.js} +1 -1
  12. package/dist/client/assets/{CreditCard01-ClLSYbqv.js → CreditCard01-CRr1X6M_.js} +1 -1
  13. package/dist/client/assets/{DotsVertical-wRY0m847.js → DotsVertical-P-X5Mufl.js} +1 -1
  14. package/dist/client/assets/Download01-BzRrEOnM.js +1 -0
  15. package/dist/client/assets/{Eye-BX-sf9wy.js → Eye-C0KTKKJF.js} +1 -1
  16. package/dist/client/assets/{FilterLines-ClJ_YJto.js → FilterLines-CfXZWnlF.js} +1 -1
  17. package/dist/client/assets/Globe01-Cou3ky_5.js +1 -0
  18. package/dist/client/assets/{Globe04-Bqrij7bv.js → Globe04-BAURDfvu.js} +1 -1
  19. package/dist/client/assets/{HardDrive-DJgL_JOo.js → HardDrive-Cd282Mai.js} +1 -1
  20. package/dist/client/assets/{Key01-WmVZ8QXt.js → Key01-mbqRH6mK.js} +1 -1
  21. package/dist/client/assets/{LayoutLeft-Cxosu4Vt.js → LayoutLeft-DC6WJh9Y.js} +1 -1
  22. package/dist/client/assets/{LinkExternal01-BjhdSnR3.js → LinkExternal01-DhYqUjKN.js} +1 -1
  23. package/dist/client/assets/{LockUnlocked01-BSzBmosQ.js → LockUnlocked01-EXLocz58.js} +1 -1
  24. package/dist/client/assets/{LogOut01-M0Karp0_.js → LogOut01-C0GCrbOu.js} +1 -1
  25. package/dist/client/assets/{Monitor01-D8Oqtnh3.js → Monitor01-D1Ywzeig.js} +1 -1
  26. package/dist/client/assets/{Palette-BU4Si7Wh.js → Palette-DBmNDW91.js} +1 -1
  27. package/dist/client/assets/{Play-XYqRlm8a.js → Play-BvFv415E.js} +1 -1
  28. package/dist/client/assets/{Plus-Beu31VvD.js → Plus-183giWYf.js} +1 -1
  29. package/dist/client/assets/{SearchLg-ctNZwaUj.js → SearchLg-B7BxifEX.js} +1 -1
  30. package/dist/client/assets/{SearchMd-CrfRVVNu.js → SearchMd-CM8BurdL.js} +1 -1
  31. package/dist/client/assets/{Settings02-DjCcM4YH.js → Settings02-CDCqmH2y.js} +1 -1
  32. package/dist/client/assets/{Share07-_nwKmR9H.js → Share07-4wiqviev.js} +1 -1
  33. package/dist/client/assets/{Shield01-w6inEe2u.js → Shield01-BpVwYc8W.js} +1 -1
  34. package/dist/client/assets/{Stars01-C_iarf2U.js → Stars01-BNF996_E.js} +1 -1
  35. package/dist/client/assets/{Stars02-CzGdY2r0.js → Stars02-DK8tfpbc.js} +1 -1
  36. package/dist/client/assets/{Sun-BuLGisqZ.js → Sun-GtaTfxOx.js} +1 -1
  37. package/dist/client/assets/{SwitchHorizontal01-Ai8WkF2C.js → SwitchHorizontal01-SB503joS.js} +1 -1
  38. package/dist/client/assets/{Tool01-CmewmN8z.js → Tool01-D0IxVPmR.js} +1 -1
  39. package/dist/client/assets/{Tool02-CIq5KPgH.js → Tool02-Dw-UoNMF.js} +1 -1
  40. package/dist/client/assets/{Trash01-_QtQD9Y8.js → Trash01-xAMG4igT.js} +1 -1
  41. package/dist/client/assets/{TrendUp01-DFsn-nmD.js → TrendUp01-CyDskMTc.js} +1 -1
  42. package/dist/client/assets/{Upload01-C7JN7_i1.js → Upload01-CXYdms2a.js} +1 -1
  43. package/dist/client/assets/{User01-Dv8gliJ8.js → User01-BuGMrYkY.js} +1 -1
  44. package/dist/client/assets/{Users01-BNRCLVLR.js → Users01-B4ufXHfS.js} +1 -1
  45. package/dist/client/assets/{Users03-Ps3JKhNc.js → Users03-C8lJ4QPE.js} +1 -1
  46. package/dist/client/assets/{X-Bc21exsC.js → X-CFtahbse.js} +1 -1
  47. package/dist/client/assets/{XCircle-D3PkxCJR.js → XCircle-CjCSqvRp.js} +1 -1
  48. package/dist/client/assets/{XClose-C-dp2TW3.js → XClose-hFhPw2cX.js} +1 -1
  49. package/dist/client/assets/{YAxis-D06Q-cZ8.js → YAxis-BVXr0BmV.js} +1 -1
  50. package/dist/client/assets/{Zap-xSjXNKoR.js → Zap-DSqgHmL9.js} +1 -1
  51. package/dist/client/assets/{ZapSquare-DdmGlJDv.js → ZapSquare-OwtsgqsS.js} +1 -1
  52. package/dist/client/assets/{access-gate-DT76HnbT.js → access-gate-fjV0y2jb.js} +1 -1
  53. package/dist/client/assets/agent-icon-JCSxz6gi.js +1 -0
  54. package/dist/client/assets/agents-list-DaGM2H7k.js +1 -0
  55. package/dist/client/assets/ai-providers-DHcZaksx.js +1 -0
  56. package/dist/client/assets/{alert-dialog-C5aixBa-.js → alert-dialog-BaeQkFB7.js} +1 -1
  57. package/dist/client/assets/{alert-B5SrlnQS.js → alert-v-t6mrgX.js} +1 -1
  58. package/dist/client/assets/{api-keys-Cfkis4BG.js → api-keys-CkkVYEIe.js} +1 -1
  59. package/dist/client/assets/app-editor-Emo1wnmS.js +1 -0
  60. package/dist/client/assets/{auth-DSeANwkS.js → auth-M5FlCsXs.js} +1 -1
  61. package/dist/client/assets/{auth-catchall-DH3MdMMP.js → auth-catchall-OfwbBs9h.js} +1 -1
  62. package/dist/client/assets/{auth-entry-ovq7tYcR.js → auth-entry-DUucydDK.js} +1 -1
  63. package/dist/client/assets/{auth-split-layout-QkUaJV5m.js → auth-split-layout-DYzg1Qc8.js} +1 -1
  64. package/dist/client/assets/{authenticate-and-persist-oauth-BjwtT0ab.js → authenticate-and-persist-oauth-DoSR4iKF.js} +1 -1
  65. package/dist/client/assets/{automation-list-row-CFqmtzgR.js → automation-list-row-Ba1IUTNo.js} +1 -1
  66. package/dist/client/assets/{automation-runs-ZYVEpsZX.js → automation-runs-BbcZJUyD.js} +16 -16
  67. package/dist/client/assets/automations-OOI7bWx-.js +1 -0
  68. package/dist/client/assets/{avatar-BGP-avp4.js → avatar-6w4t2nGf.js} +1 -1
  69. package/dist/client/assets/{badge-D0q0tCmx.js → badge-t-2thrpZ.js} +1 -1
  70. package/dist/client/assets/{billing-Cx1PkhRS.js → billing-Bzj9k8ua.js} +1 -1
  71. package/dist/client/assets/{block-document-DlfPvomd.js → block-document-BRRPfXBO.js} +1 -1
  72. package/dist/client/assets/{buckets-Bn1jTc51.js → buckets-DTAYBoD2.js} +1 -1
  73. package/dist/client/assets/bulk-category-panel-BJEYlps2.js +1 -0
  74. package/dist/client/assets/{capability-load-error-CKdQNufy.js → capability-load-error-C0ztJ_Ig.js} +1 -1
  75. package/dist/client/assets/{card-B6s-X_7q.js → card-CZLDmlyM.js} +1 -1
  76. package/dist/client/assets/cards-CxicMSJC.js +9 -0
  77. package/dist/client/assets/category-editor-DLPuKHh-.js +1 -0
  78. package/dist/client/assets/{chart-B7nZ8pjs.js → chart-CAto47lg.js} +1 -1
  79. package/dist/client/assets/{chat-context-CkD6Rm1l.js → chat-context-CVRXzKpr.js} +1 -1
  80. package/dist/client/assets/{checkbox-SU4x7etH.js → checkbox-CvQFDXhk.js} +1 -1
  81. package/dist/client/assets/{cli-auth-success-DbLb2lL3.js → cli-auth-success-CsuxPjv_.js} +1 -1
  82. package/dist/client/assets/collection-detail-BfyX0et5.js +1 -0
  83. package/dist/client/assets/{collection-display-button-o0ZpnDLT.js → collection-display-button-CeJFFjyk.js} +1 -1
  84. package/dist/client/assets/{collection-search-B9FHnrlK.js → collection-search-B-SPD0Km.js} +1 -1
  85. package/dist/client/assets/{collection-table-wrapper-CHuYWW3f.js → collection-table-wrapper-C0hCnz6-.js} +1 -1
  86. package/dist/client/assets/{collection-tabs-CTztoi_L.js → collection-tabs-C-XFHKK4.js} +1 -1
  87. package/dist/client/assets/{command-9SJIiMMJ.js → command-C0az0b8t.js} +1 -1
  88. package/dist/client/assets/commerce-onboarding-Bj8hKn97.js +1 -0
  89. package/dist/client/assets/{connect-D3SR0gqF.js → connect-CxV3qWBq.js} +1 -1
  90. package/dist/client/assets/{connection-CcZxGNbF.js → connection-X8aleug0.js} +1 -1
  91. package/dist/client/assets/{connection-card-CSTEPEAl.js → connection-card-BAXxPPFo.js} +1 -1
  92. package/dist/client/assets/connection-detail-7KM4tc3e.js +1 -0
  93. package/dist/client/assets/{connection-form-helpers-CAWuRDfe.js → connection-form-helpers-DA7t7XXZ.js} +1 -1
  94. package/dist/client/assets/connections-NHAu-l0D.js +1 -0
  95. package/dist/client/assets/{decopilot-sse-pool-DPwEBX2U.js → decopilot-sse-pool-DIk3pxOB.js} +1 -1
  96. package/dist/client/assets/{dialog-CRQLMTBJ.js → dialog-DV18W6Yx.js} +1 -1
  97. package/dist/client/assets/{domain-settings-Bpc-HBB5.js → domain-settings-Degjs_Ra.js} +1 -1
  98. package/dist/client/assets/{drawer-DYhKMhrd.js → drawer-YXQaX_y_.js} +1 -1
  99. package/dist/client/assets/{dropdown-menu-0pSlZu2s.js → dropdown-menu-Bz4edgHd.js} +1 -1
  100. package/dist/client/assets/{empty-state-CTZGG5L9.js → empty-state-DAwc227L.js} +1 -1
  101. package/dist/client/assets/{extract-connection-data-D2Rvpp_3.js → extract-connection-data-BOM-VC2a.js} +1 -1
  102. package/dist/client/assets/file-explorer-DgaCxj63.js +2 -0
  103. package/dist/client/assets/{file-type-icon-BStuf1sH.js → file-type-icon-BiDvFSRa.js} +1 -1
  104. package/dist/client/assets/{form-CAuMNyGV.js → form-B9M2sKi3.js} +1 -1
  105. package/dist/client/assets/general-CIC9nSes.js +1 -0
  106. package/dist/client/assets/{github-repo-picker-CpkkHZIF.js → github-repo-picker-CYAs_tSm.js} +1 -1
  107. package/dist/client/assets/{hooks-Dconqo8e.js → hooks-Dhj1Xj9t.js} +1 -1
  108. package/dist/client/assets/{index-CU49llDJ.js → index-5w9oF367.js} +2 -2
  109. package/dist/client/assets/{index-DkG1WKnv.js → index-BIngEGJF.js} +1 -1
  110. package/dist/client/assets/{index-DinNtldY.js → index-BrXlWoMq.js} +1 -1
  111. package/dist/client/assets/{index-CzE82-fO.js → index-C6ebGaw_.js} +1 -1
  112. package/dist/client/assets/{index-SQAL2Po3.js → index-CCAGgYK0.js} +1 -1
  113. package/dist/client/assets/{index-CWW_VhWW.js → index-CbHqDGBA.js} +36 -36
  114. package/dist/client/assets/{index-DALKCDkR.js → index-CtW1djEc.js} +1 -1
  115. package/dist/client/assets/{index-CvbvPSw1.js → index-H2VxcyQH.js} +1 -1
  116. package/dist/client/assets/index-PRPKuR9Q.js +1 -0
  117. package/dist/client/assets/{index-Ckn2SAtv.js → index-rP33bQlN.js} +12 -12
  118. package/dist/client/assets/{index-redirect-DZqCPWrl.js → index-redirect-DwkhDSou.js} +1 -1
  119. package/dist/client/assets/{infra-billing-X97xqG8z.js → infra-billing-DUmrumkB.js} +1 -1
  120. package/dist/client/assets/{input-033UIAd3.js → input-BkCJTDrP.js} +1 -1
  121. package/dist/client/assets/{integration-icon-CW3TfCPl.js → integration-icon-q-JlSkbf.js} +1 -1
  122. package/dist/client/assets/{invite-member-dialog-DSuSH2Bn.js → invite-member-dialog-C-5Nd4zW.js} +1 -1
  123. package/dist/client/assets/{label-BlznzMhv.js → label-DQKQ8lEd.js} +1 -1
  124. package/dist/client/assets/{layout-B-zy_djv.js → layout-X8EQrkUX.js} +1 -1
  125. package/dist/client/assets/{login-D7Ayb_mN.js → login-DcHBdKPJ.js} +1 -1
  126. package/dist/client/assets/{mcp-oauth-DVQQO3hY.js → mcp-oauth-B5CECs49.js} +1 -1
  127. package/dist/client/assets/{members-BREd8-zu.js → members-CfPp8RcB.js} +1 -1
  128. package/dist/client/assets/{monaco-editor-7mkphsHS.js → monaco-editor-CHK_WTN1.js} +1 -1
  129. package/dist/client/assets/{monitoring-stats-row-CCLMpVuV.js → monitoring-stats-row-CVEWE4Fd.js} +1 -1
  130. package/dist/client/assets/{multi-select-BRyr0E5T.js → multi-select-BUKy42et.js} +1 -1
  131. package/dist/client/assets/{oauth-callback-kzl5SlVO.js → oauth-callback-BDPrRF-o.js} +1 -1
  132. package/dist/client/assets/{oauth-callback-ai-provider-DqhbuYc1.js → oauth-callback-ai-provider-DLXIVnfM.js} +1 -1
  133. package/dist/client/assets/{onboarding-BofSB4PB.js → onboarding-TVyuaga-.js} +1 -1
  134. package/dist/client/assets/{org-layout-BWXXOPjv.js → org-layout-fQ1dxK8S.js} +1 -1
  135. package/dist/client/assets/{organization-choice-BvVEAsXL.js → organization-choice-CiaOuZu3.js} +1 -1
  136. package/dist/client/assets/{orgs-CZ7w4IkX.js → orgs-ar044Xjk.js} +1 -1
  137. package/dist/client/assets/{page-seo-form-C4DmOsVu.js → page-seo-form-VfWsE88H.js} +1 -1
  138. package/dist/client/assets/{popover-BjnUzD6X.js → popover-BFqFQf4f.js} +1 -1
  139. package/dist/client/assets/post-editor-DSjVWBl5.js +1 -0
  140. package/dist/client/assets/{primitives-2hE7GOVH.js → primitives-C0bsPQWu.js} +1 -1
  141. package/dist/client/assets/{profile-Cp0MQE5c.js → profile-DUsq9NF5.js} +1 -1
  142. package/dist/client/assets/project-app-view-DAA6fQeU.js +1 -0
  143. package/dist/client/assets/record-editor-S54mYWvP.js +1 -0
  144. package/dist/client/assets/redirect-editor-OoYwc6vQ.js +1 -0
  145. package/dist/client/assets/registry-DC4p8qDH.js +2 -0
  146. package/dist/client/assets/{registry-layout-DJKdYnZG.js → registry-layout-0D8i2a-K.js} +3 -3
  147. package/dist/client/assets/{reports-yJiJoqyv.js → reports-CuKybDwh.js} +1 -1
  148. package/dist/client/assets/{require-capability-Fzrnw44H.js → require-capability-BxGw2L90.js} +1 -1
  149. package/dist/client/assets/{required-auth-layout-CKO-W8hh.js → required-auth-layout-BIBsXtMo.js} +1 -1
  150. package/dist/client/assets/{reset-password-3zlCasG5.js → reset-password-DjY9EA4m.js} +1 -1
  151. package/dist/client/assets/roles-Bmd9cdRT.js +1 -0
  152. package/dist/client/assets/{search-input-BWqunmRq.js → search-input-CdEt0Dpt.js} +1 -1
  153. package/dist/client/assets/{secrets-C-c-qjgQ.js → secrets-CT9FyUhf.js} +1 -1
  154. package/dist/client/assets/{sections-editor-XJGfoB4V.js → sections-editor-DTGUO4Z6.js} +2 -2
  155. package/dist/client/assets/{select-CJxHvEHm.js → select-CA9WZQjc.js} +1 -1
  156. package/dist/client/assets/select-model-8Tx2fyM5.js +4 -0
  157. package/dist/client/assets/{self-tool-result-BxC3b6xs.js → self-tool-result-Dd3iJBUw.js} +1 -1
  158. package/dist/client/assets/seo-editor-DCZL7FmV.js +1 -0
  159. package/dist/client/assets/{settings-layout-Gjf7WBFi.js → settings-layout-CITrZViJ.js} +1 -1
  160. package/dist/client/assets/{settings-section-3mgQUekG.js → settings-section-U_d9SZ5z.js} +1 -1
  161. package/dist/client/assets/{settings-subnav-ByjVZ9_c.js → settings-subnav-CU4zvN8b.js} +1 -1
  162. package/dist/client/assets/{shell-controls-DkVuUh-D.js → shell-controls-OYFwRgxx.js} +1 -1
  163. package/dist/client/assets/{shell-layout-B48CP4qv.js → shell-layout-DZNAvGub.js} +1 -1
  164. package/dist/client/assets/{sidebar-DoSaJzfh.js → sidebar-CbAXZRty.js} +1 -1
  165. package/dist/client/assets/{skeleton-DESj-M-E.js → skeleton-Baz5nFrz.js} +1 -1
  166. package/dist/client/assets/{spinner-BUSgQvV9.js → spinner-DxScZBKB.js} +1 -1
  167. package/dist/client/assets/{sso-Al9ETsbg.js → sso-6nyhXisL.js} +1 -1
  168. package/dist/client/assets/{store-9WOeRNsD.js → store-C2pKj8sd.js} +1 -1
  169. package/dist/client/assets/store-registry-CSkrVbdj.js +2 -0
  170. package/dist/client/assets/{studio-tools-B9Ct3_YC.js → studio-tools-VUr_6R55.js} +1 -1
  171. package/dist/client/assets/{switch-DBix4dGe.js → switch-gXErSebn.js} +1 -1
  172. package/dist/client/assets/synced-repos-CBjsmnWh.js +1 -0
  173. package/dist/client/assets/tab-id-CcDWY6Z5.js +1 -0
  174. package/dist/client/assets/{table-B2oaMHDO.js → table-BomvPzw1.js} +1 -1
  175. package/dist/client/assets/{tabs-IZkuMTkN.js → tabs-ByC6UswV.js} +1 -1
  176. package/dist/client/assets/tasks-CuhWDed7.js +1 -0
  177. package/dist/client/assets/{textarea-D8uJ17IC.js → textarea-Cmbx33e9.js} +1 -1
  178. package/dist/client/assets/{toggle-group-CY8Vk8gH.js → toggle-group-D4zn64EK.js} +1 -1
  179. package/dist/client/assets/{toolbar-B1fZNVFp.js → toolbar-Db9EKJVj.js} +1 -1
  180. package/dist/client/assets/{tooltip-BLoH72H_.js → tooltip-CjWdSuMr.js} +1 -1
  181. package/dist/client/assets/{track-DJo1DwOE.js → track-Bb2qAfNZ.js} +1 -1
  182. package/dist/client/assets/{types-DeLO2iP6.js → types-BOZwIefN.js} +1 -1
  183. package/dist/client/assets/{use-ai-providers-DFB4FltD.js → use-ai-providers-k4pjcS3t.js} +1 -1
  184. package/dist/client/assets/{use-api-keys-D23iLtT8.js → use-api-keys-Cw-Cv09b.js} +1 -1
  185. package/dist/client/assets/{use-automations-DSxQRe0A.js → use-automations-CV8c2KIQ.js} +1 -1
  186. package/dist/client/assets/{use-autosave-DQimJC28.js → use-autosave-HbmpHR38.js} +1 -1
  187. package/dist/client/assets/{use-capability-BS9lZAmO.js → use-capability-BxvzMTBW.js} +1 -1
  188. package/dist/client/assets/{use-clock-tick-CDVao7cr.js → use-clock-tick-bYeZWlWy.js} +1 -1
  189. package/dist/client/assets/{use-commerce-diagnostic-C75dfvGU.js → use-commerce-diagnostic-DZ8-RWdI.js} +1 -1
  190. package/dist/client/assets/{use-connection-CtbwqEgR.js → use-connection-CYuunbtf.js} +1 -1
  191. package/dist/client/assets/{use-copy-BQc_zaTa.js → use-copy-CD6Jpi9s.js} +1 -1
  192. package/dist/client/assets/{use-create-virtual-mcp-C9Bsz2lP.js → use-create-virtual-mcp-ALSzfOtx.js} +1 -1
  193. package/dist/client/assets/{use-debounced-autosave-76bcg_cg.js → use-debounced-autosave-CuQc51JO.js} +1 -1
  194. package/dist/client/assets/{use-debounced-value-gZF3WfW1.js → use-debounced-value-9IZFnJOd.js} +1 -1
  195. package/dist/client/assets/{use-decopilot-events-BN4-nZxC.js → use-decopilot-events-CnEWes5G.js} +1 -1
  196. package/dist/client/assets/{use-delete-connection-M3bsidfz.js → use-delete-connection-NUz645Q2.js} +1 -1
  197. package/dist/client/assets/{use-deployment-admin-CH7xJf3e.js → use-deployment-admin-Cy9b9FZ0.js} +1 -1
  198. package/dist/client/assets/{use-file-configs-Dx7xwSzN.js → use-file-configs-S1p6BPLy.js} +1 -1
  199. package/dist/client/assets/{use-infinite-scroll-BYVKlMFT.js → use-infinite-scroll-2P9IYhHm.js} +1 -1
  200. package/dist/client/assets/{use-join-requests-UvImlwy9.js → use-join-requests-D0I_MKin.js} +1 -1
  201. package/dist/client/assets/{use-mcp-client-fJDYDlU9.js → use-mcp-client-BE_e-uEm.js} +1 -1
  202. package/dist/client/assets/{use-mcp-tools-CWf9IZJb.js → use-mcp-tools-C_DeYZLk.js} +1 -1
  203. package/dist/client/assets/{use-members-2MwYNAyl.js → use-members-BlkVgAkC.js} +1 -1
  204. package/dist/client/assets/{use-mobile-C_wE74fy.js → use-mobile-CcypTxrj.js} +1 -1
  205. package/dist/client/assets/{use-navigate-to-agent-FbpYb5Qu.js → use-navigate-to-agent-DXBflHYS.js} +1 -1
  206. package/dist/client/assets/{use-open-billing-url-SAk7c31b.js → use-open-billing-url-Bz2NF5sP.js} +1 -1
  207. package/dist/client/assets/{use-org-auth-client-Dsqqo9TA.js → use-org-auth-client-DDrK6a1L.js} +1 -1
  208. package/dist/client/assets/{use-org-repo-syncs-rIsglk2d.js → use-org-repo-syncs-VOmFIF6x.js} +1 -1
  209. package/dist/client/assets/{use-org-sso-CwtFlYvS.js → use-org-sso-ZlmQXdwK.js} +1 -1
  210. package/dist/client/assets/{use-organization-roles-DcEcqFQc.js → use-organization-roles-BR-sb5ep.js} +1 -1
  211. package/dist/client/assets/{use-organization-settings-51Vgj4aH.js → use-organization-settings-CigEU-nL.js} +1 -1
  212. package/dist/client/assets/{use-registry-connections-Cr2-nQsF.js → use-registry-connections-DpPGnRab.js} +1 -1
  213. package/dist/client/assets/{use-secrets-D8qcP46x.js → use-secrets-DziYD0M6.js} +1 -1
  214. package/dist/client/assets/{use-section-preview-base-9Ic0FJS_.js → use-section-preview-base-09B4aWt-.js} +1 -1
  215. package/dist/client/assets/{use-settings-tabs-BJvLsXvA.js → use-settings-tabs-BGK4ZoR5.js} +1 -1
  216. package/dist/client/assets/{use-status-sounds-bXYnEckM.js → use-status-sounds-kD8SM-pB.js} +1 -1
  217. package/dist/client/assets/{use-tags-DtlP3bNr.js → use-tags-CUJjaXC6.js} +1 -1
  218. package/dist/client/assets/{use-view-mode-PlD_tVP0.js → use-view-mode-Bln07e-3.js} +1 -1
  219. package/dist/client/assets/{use-virtual-mcp-BX9f53BJ.js → use-virtual-mcp-DhY25Szl.js} +1 -1
  220. package/dist/client/assets/useInfiniteQuery-sIgcqV0U.js +1 -0
  221. package/dist/client/assets/{useRouterState-ZW2MxINW.js → useRouterState-B7wg4Z59.js} +1 -1
  222. package/dist/client/assets/useSuspenseInfiniteQuery-xXNO1vN3.js +1 -0
  223. package/dist/client/assets/{users-CNeiktS7.js → users-BW9rR2JN.js} +1 -1
  224. package/dist/client/assets/variant-calendar-D77dQCtJ.js +1 -0
  225. package/dist/client/assets/{view-mode-toggle-CU01TMfv.js → view-mode-toggle-hhxSebBr.js} +1 -1
  226. package/dist/client/index.html +1 -1
  227. package/dist/client/install.sh +443 -45
  228. package/dist/server/cli.js +3 -3
  229. package/dist/server/server.js +3 -3
  230. package/package.json +1 -1
  231. package/dist/client/assets/Globe01-D_2HJX-I.js +0 -1
  232. package/dist/client/assets/agent-icon-CRyupzh3.js +0 -1
  233. package/dist/client/assets/agents-list-cVl-UZFI.js +0 -1
  234. package/dist/client/assets/ai-providers-D9tdPwkm.js +0 -1
  235. package/dist/client/assets/app-editor-BqpUNh9_.js +0 -1
  236. package/dist/client/assets/automations-Dk6ZV6Eb.js +0 -1
  237. package/dist/client/assets/bulk-category-panel-DMni3s7V.js +0 -1
  238. package/dist/client/assets/cards-D3ylftrl.js +0 -9
  239. package/dist/client/assets/category-editor-BFcnjGRo.js +0 -1
  240. package/dist/client/assets/collection-detail-BxSstYra.js +0 -1
  241. package/dist/client/assets/commerce-onboarding-BhswfRNb.js +0 -1
  242. package/dist/client/assets/connection-detail-ZgJQ7OvZ.js +0 -1
  243. package/dist/client/assets/connections-ZotNV6n8.js +0 -1
  244. package/dist/client/assets/file-explorer-BLHd0BVU.js +0 -2
  245. package/dist/client/assets/general-CD1AT3tQ.js +0 -1
  246. package/dist/client/assets/index-DiJ_A5BP.js +0 -1
  247. package/dist/client/assets/post-editor-GruQqpeL.js +0 -1
  248. package/dist/client/assets/project-app-view-dQmr9egb.js +0 -1
  249. package/dist/client/assets/record-editor-CuQ7aMF4.js +0 -1
  250. package/dist/client/assets/redirect-editor-BtP9Suy0.js +0 -1
  251. package/dist/client/assets/registry-DvcPDCWO.js +0 -2
  252. package/dist/client/assets/roles-CGQqEhv-.js +0 -1
  253. package/dist/client/assets/select-model-Bwc94yCX.js +0 -4
  254. package/dist/client/assets/seo-editor-CnXY0_68.js +0 -1
  255. package/dist/client/assets/store-registry-Dh0rL2Qs.js +0 -2
  256. package/dist/client/assets/synced-repos-BbnsPm_Q.js +0 -1
  257. package/dist/client/assets/tab-id-BkooGyuQ.js +0 -1
  258. package/dist/client/assets/tasks-TdSCx-Ct.js +0 -1
  259. package/dist/client/assets/useInfiniteQuery-QYDYXkJa.js +0 -1
  260. package/dist/client/assets/useSuspenseInfiniteQuery-CbXYLrJc.js +0 -1
  261. package/dist/client/assets/variant-calendar-1ktwOI__.js +0 -1
@@ -1371,7 +1371,7 @@ Usage: deco services <up|down|status>`),process.exit(1)}}var Gi1=w(()=>{Of()});f
1371
1371
  `.execute($);if(Number(W.rows[0]?.cnt)===0){console.warn(`Failed to migrate ${J}/${K}, keeping in old table`);continue}}await lb`
1372
1372
  DELETE FROM kysely_migration WHERE name = ${X}
1373
1373
  `.execute($)}}async function To1($){await Np6($),await Up6($);let Z=new Po1({db:$,provider:{getMigrations:()=>Promise.resolve(Ei0)}}),{error:X,results:Q}=await Z.migrateToLatest(),Y=0;if(Q?.forEach((G)=>{if(G.status==="Success")Y++;else if(G.status==="Error")console.error(`Failed to execute migration "${G.migrationName}"`)}),X)throw console.error("Failed to migrate"),console.error(X),X;return Y}async function Fp6($){let{keepOpen:Z=!1,database:X,skipBetterAuth:Q=!1}=$??{},Y="skipped";if(!Q&&!X)Y=await cc0();let G=X??F6(),J=async()=>{if(!Z&&!X)await yB(G).catch((K)=>{console.warn("Warning: Error closing database:",K)})};try{let K=await To1(G.db);return await J(),{betterAuth:Y,kysely:K}}catch(K){throw await J(),K}}async function Bp6(){let $=F6(),Z=new Po1({db:$.db,provider:{getMigrations:()=>Promise.resolve(Ei0)}}),{error:X,results:Q}=await Z.migrateDown();if(Q?.forEach((Y)=>{if(Y.status==="Success")console.log(`\u2705 Migration "${Y.migrationName}" rolled back successfully`);else if(Y.status==="Error")console.error(`\u274C Failed to rollback migration "${Y.migrationName}"`)}),X)throw console.error("Failed to rollback migration"),console.error(X),X}var Io1=w(()=>{jo1();lc0();XX()});async function EZ0($){let Z={...process.env},X=H80($,Z);console.log(hw1(X.settings.encryptionKey));let Q=X.settings.betterAuthSecret||(X.settings.localMode?fn1(X.settings.dataDir):""),{ensureServices:Y}=await Promise.resolve().then(() => (q90(),I90)),{outputs:G,services:J}=await Y({home:X.settings.dataDir,externalDatabaseUrl:X.externalDatabaseUrl,externalNatsUrl:X.externalNatsUrl});if(!X.skipMigrations){let{migrateBetterAuth:W}=await Promise.resolve().then(() => (lc0(),yn1));await W(G.databaseUrl);let{createDatabase:H}=await Promise.resolve().then(() => (XX(),$n1)),{migrateToLatest:N}=await Promise.resolve().then(() => (Io1(),Ro1)),U=H(G.databaseUrl);await N({keepOpen:!0,database:U,skipBetterAuth:!0})}let K={...X.settings,betterAuthSecret:Q,databaseUrl:G.databaseUrl,natsUrls:G.natsUrls,...G.s3?{s3Endpoint:G.s3.endpoint,s3Bucket:G.s3.bucket,s3AccessKeyId:G.s3.accessKeyId,s3SecretAccessKey:G.s3.secretAccessKey,s3ForcePathStyle:G.s3.forcePathStyle}:{},...G.natsTunnel?{natsPublicUrl:G.natsTunnel.publicUrl,natsAccountJwt:G.natsTunnel.accountJwt,natsAccountSigningKey:G.natsTunnel.accountSigningKey,natsOperatorJwt:G.natsTunnel.operatorJwt,natsTunnelPublicEnabled:!0,natsCredsPath:G.natsTunnel.credsPath}:{}};return Ji1(K),{settings:K,services:J.map((W)=>({name:W.name==="PostgreSQL"?"Postgres":W.name,port:W.port})),managedServiceNames:J.filter((W)=>W.owner==="managed").map((W)=>W.name)}}var zi0=w(()=>{Of();bn1();C8()});var Vo1={};F0(Vo1,{updateService:()=>DE,subscribeCliState:()=>Ai0,setTuiConsoleIntercepted:()=>zZ0,setServerUrl:()=>Ci,setMigrationsDone:()=>Si,setDevMode:()=>Lp6,resetCliStateForTests:()=>Op6,isTuiConsoleIntercepted:()=>jZ0,getCliState:()=>Pi0,addLogEntry:()=>lB});function qo1(){return{services:[{name:"Postgres",status:"pending",port:0},{name:"NATS",status:"pending",port:0}],migrationsStatus:"pending",serverUrl:null,logs:[]}}function Op6(){cQ=qo1()}function wp6(){return[{name:"Postgres",status:"pending",port:0},{name:"NATS",status:"pending",port:0}]}function ki(){for(let $ of ji0)$()}function Pi0(){return cQ}function Ai0($){return ji0.add($),()=>ji0.delete($)}function DE($){cQ={...cQ,services:cQ.services.map((Z)=>Z.name===$.name?$:Z)},ki()}function Si(){cQ={...cQ,migrationsStatus:"done"},ki()}function Ci($){cQ={...cQ,serverUrl:$},ki()}function lB($){let Z=[...cQ.logs,$];cQ={...cQ,logs:Z.length>500?Z.slice(-500):Z},ki()}function Lp6(){cQ={...cQ,services:[...wp6(),{name:"API",status:"pending",port:0},{name:"Vite",status:"pending",port:0}]},ki()}function zZ0($){Mo1=$}function jZ0(){return Mo1}var cQ,ji0,Mo1=!1;var EE=w(()=>{cQ=qo1();ji0=new Set});import{createServer as ko1}from"net";function Dp6($){return new Promise((Z)=>{let X=ko1();X.once("error",()=>Z(!1)),X.listen($,"0.0.0.0",()=>{X.close(()=>Z(!0))})})}async function _i($){if(await Dp6($))return $;let Z=await new Promise((X,Q)=>{let Y=ko1();Y.once("error",Q),Y.listen(0,"0.0.0.0",()=>{let G=Y.address(),J=typeof G==="object"&&G?G.port:0;Y.close(()=>X(J))})});return console.warn(`Port ${$} is in use, using port ${Z} instead.`),Z}var Ti0=()=>{};function vi($){return $.replace(/\x1b\[[0-9;]*m/g,"")}var Ri0={};F0(Ri0,{startDevServer:()=>zp6});import{join as Ep6}from"path";function So1($){let Z=$.getReader(),X=new TextDecoder,Q="";function Y(){let G=Q.split(`
1374
- `);Q=G.pop()??"";for(let J of G){let K=vi(J).replace(/^\[\d+\]\s*/,"").trim();if(!K)continue;lB({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:K})}}(async()=>{for(;;){let{done:G,value:J}=await Z.read();if(G)break;Q+=X.decode(J,{stream:!0}),Y()}if(Q.trim()){let G=vi(Q).replace(/^\[\d+\]\s*/,"").trim();if(G)lB({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:G})}})()}async function zp6($){let{baseUrl:Z,noTui:X}=$,Q=process.env.HOST==="0.0.0.0"&&Boolean(process.env.PORT),Y=Q?process.env.PORT:$.vitePort,G=Z||`http://localhost:${Y}`,J=Q?await _i(Number(Y)+1):await _i(Number($.port)),{settings:K,services:W,managedServiceNames:H}=await EZ0({port:String(J),home:$.home,baseUrl:$.baseUrl,localMode:$.localMode,skipMigrations:$.skipMigrations,noTui:$.noTui,vitePort:$.vitePort});for(let L of W)DE({name:L.name,status:"ready",port:L.port});Si();let N=Ep6(import.meta.dir,"..","..","..","..",".."),U=X===!0,F=Bun.spawn(["bun","run","dev:servers"],{cwd:N,env:{...process.env,PORT:String(K.port),VITE_PORT:String(Y),DATABASE_URL:K.databaseUrl,NATS_URL:K.natsUrls.join(","),NODE_ENV:K.nodeEnv,BASE_URL:G,DECOCMS_LOCAL_MODE:String(K.localMode),DECOCMS_HOME:K.dataDir,DATA_DIR:K.dataDir,DECO_CLI:"1",...K.betterAuthSecret?{BETTER_AUTH_SECRET:K.betterAuthSecret}:{},...K.s3Endpoint?{S3_ENDPOINT:K.s3Endpoint,S3_BUCKET:K.s3Bucket??"",S3_ACCESS_KEY_ID:K.s3AccessKeyId??"",S3_SECRET_ACCESS_KEY:K.s3SecretAccessKey??"",S3_FORCE_PATH_STYLE:String(K.s3ForcePathStyle)}:{},...K.natsPublicUrl&&K.natsAccountJwt&&K.natsAccountSigningKey?{NATS_PUBLIC_URL:K.natsPublicUrl,NATS_ACCOUNT_JWT:K.natsAccountJwt,NATS_ACCOUNT_SIGNING_KEY:K.natsAccountSigningKey,NATS_OPERATOR_JWT:K.natsOperatorJwt??"",NATS_TUNNEL_PUBLIC_ENABLED:"true",...K.natsCredsPath?{NATS_CREDS:K.natsCredsPath}:{}}:{}},stdio:["inherit",U?"inherit":"pipe",U?"inherit":"pipe"]});if(!U)So1(F.stdout),So1(F.stderr);Ci(G),DE({name:"Vite",status:"ready",port:Number(Y)}),DE({name:"API",status:"ready",port:Number(K.port)});let O=async(L)=>{if(F.kill(L),await F.exited,H.length>0){let{stopServices:D}=await Promise.resolve().then(() => (q90(),I90));await D(K.dataDir)}};return process.on("SIGINT",()=>O("SIGINT")),process.on("SIGTERM",()=>O("SIGTERM")),{port:Number(Y),process:F}}var Ii0=w(()=>{zi0();EE();Ti0()});var PZ0;var qi0=w(()=>{PZ0={name:"decocms",version:"4.240.0",description:"Deco CMS \u2014 Self-hostable MCP Gateway for managing AI connections and tools",author:"Deco team",repository:{type:"git",url:"git+https://github.com/decocms/studio.git",directory:"apps/api"},bugs:{url:"https://github.com/decocms/studio/issues"},type:"module",bin:{deco:"./dist/server/cli.js"},files:["dist/**/*"],scripts:{dev:"bun run migrate && bun run dev:server","dev:server":"bun run --cwd=../../packages/sandbox build && NODE_ENV=development bun --env-file=.env --hot run src/index.ts",build:"bun run build:server","build:server":"bun run scripts/bundle-server-script.ts --dist ./dist/server","generate:tool-contracts":"bun run scripts/generate-tool-contracts.ts","db:migrate":"bun run ./dist/server/migrate.js","db:migrate:dbos":"bun run ./dist/server/migrate-dbos.js",check:"tsc --noEmit",start:"bun run ./dist/server/server.js",migrate:"bun run src/database/migrate.ts","migrate:dbos":"bun run src/database/migrate-dbos.ts",test:"bun test src","better-auth:migrate":"bunx --bun @better-auth/cli migrate -y --config src/auth/index.ts",prepublishOnly:"bun run --cwd=../.. build:studio"},optionalDependencies:{"@duckdb/node-api":"^1.5.0-r.1"},dependencies:{"@ai-sdk/anthropic":"^3.0.85","@ai-sdk/google":"^3.0.83","@ai-sdk/openai":"^3.0.73","@anthropic-ai/sdk":"^0.105.0","@aws-sdk/client-s3":"^3.1013.0","@aws-sdk/client-sts":"^3.1013.0","@aws-sdk/lib-storage":"^3.1013.0","@aws-sdk/s3-request-presigner":"^3.1013.0","@clickhouse/client":"^1.8.1","@dbos-inc/dbos-sdk":"^4.21.6","@inkjs/ui":"^2.0.0","@nats-io/jetstream":"3.4.0","@nats-io/kv":"3.4.0","@nats-io/nats-core":"3.4.0","@nats-io/transport-node":"3.4.0","@openrouter/ai-sdk-provider":"^2.9.1","@opentelemetry/core":"^2.6.0","embedded-postgres":"^18.3.0-beta.16",ink:"^6.8.0",kysely:"^0.28.12","posthog-node":"^5.0.0",react:"^19.2.6","react-dom":"^19.2.6"},devDependencies:{"@ai-sdk/provider":"^3.0.10","@better-auth/sso":"1.4.1","@decocms/better-auth":"1.5.17","@decocms/bindings":"workspace:*","@decocms/mcp-utils":"workspace:*","@decocms/runtime":"workspace:*","@decocms/sandbox":"workspace:*","@decocms/shared":"workspace:*","@jitl/quickjs-wasmfile-release-sync":"0.31.0","@modelcontextprotocol/sdk":"1.29.0","@nats-io/jwt":"0.0.10-5","@opentelemetry/api":"^1.9.0","@opentelemetry/api-logs":"^0.211.0","@opentelemetry/exporter-logs-otlp-proto":"^0.211.0","@opentelemetry/exporter-prometheus":"^0.208.0","@opentelemetry/exporter-trace-otlp-proto":"^0.207.0","@opentelemetry/instrumentation-runtime-node":"^0.24.0","@opentelemetry/resources":"^2.6.0","@opentelemetry/sdk-logs":"^0.211.0","@opentelemetry/sdk-metrics":"^2.2.0","@opentelemetry/sdk-node":"^0.207.0","@opentelemetry/sdk-trace-base":"^2.5.0","@types/bun":"^1.3.1","@types/google.maps":"^3.65.2","@types/pg":"^8.15.6","@types/react-syntax-highlighter":"^15.5.13","@vercel/nft":"^1.1.1",ai:"^6.0.208","better-auth":"1.4.22",croner:"^9.1.0",degit:"^2.8.4",hono:"^4.10.7",jose:"^6.0.11",nanoid:"^5.1.6",pg:"^8.16.3",typescript:"^7.0.2",typescript5:"npm:typescript@^5.9.3",zod:"4.3.6"},homepage:"https://github.com/decocms/studio",keywords:["mcp","model-context-protocol","ai","gateway","self-hosted","tools"],license:"MIT",publishConfig:{access:"public"}}});import{Box as Pp6,Text as Co1}from"ink";import{jsx as Ap6,jsxs as _o1}from"react/jsx-runtime";function vo1({version:$}){return _o1(Pp6,{flexDirection:"column",marginTop:1,children:[o90.map((Z,X)=>Ap6(Co1,{color:r90[X],children:Z},X)),_o1(Co1,{dimColor:!0,children:[" v",$]})]})}var xo1=w(()=>{Ei()});import{Box as zE,Text as dB}from"ink";import{Spinner as Tp6}from"@inkjs/ui";import{jsx as sY,jsxs as db}from"react/jsx-runtime";function fo1({status:$}){if($==="pending")return sY(Tp6,{label:""});return sY(dB,{color:"green",children:"\u2713"})}function Rp6($){return`${$.name}: ${$.port||"...."}`}function bo1({services:$,migrationsStatus:Z,home:X,serverUrl:Q}){return db(zE,{flexDirection:"column",paddingBottom:1,children:[sY(vo1,{version:PZ0.version}),sY(zE,{marginBottom:1,children:sY(dB,{dimColor:!0,children:"\u2500".repeat(80)})}),sY(zE,{children:db(dB,{dimColor:!0,children:["Home: ",X]})}),db(zE,{gap:2,children:[$.map((Y)=>db(zE,{gap:1,children:[sY(dB,{children:Rp6(Y)}),sY(fo1,{status:Y.status})]},Y.name)),db(zE,{gap:1,children:[sY(dB,{children:"Migrations"}),sY(fo1,{status:Z})]})]}),sY(zE,{children:Q?db(dB,{children:["Open in browser: ",sY(dB,{color:"cyan",children:Q})]}):sY(dB,{dimColor:!0,children:"Starting..."})})]})}var yo1=w(()=>{qi0();xo1()});import{Box as Ip6,Text as xi}from"ink";import{jsx as Mi0,jsxs as Vi0}from"react/jsx-runtime";function qp6($){if($>=500)return"red";if($>=400)return"yellow";if($>=300)return"cyan";return"green"}function go1({logs:$}){return Mi0(Ip6,{flexDirection:"column",children:$.map((Z,X)=>{if(Z.rawLine)return Mi0(xi,{dimColor:!0,children:Z.rawLine},X);let Q=Z.duration<1000?`${Z.duration}ms`:`${(Z.duration/1000).toFixed(1)}s`;return Vi0(xi,{children:[Vi0(xi,{dimColor:!0,children:[Z.method.padEnd(6)," ",Z.path.padEnd(30)," "]}),Mi0(xi,{color:qp6(Z.status),children:Z.status}),Vi0(xi,{dimColor:!0,children:[" ",Q.padStart(8)]})]},X)})})}var ho1=()=>{};var ki0={};F0(ki0,{App:()=>kp6});import{Box as Mp6}from"ink";import{useSyncExternalStore as Vp6}from"react";import{jsx as uo1,jsxs as Sp6}from"react/jsx-runtime";function kp6({home:$}){let Z=Vp6(Ai0,Pi0);return Sp6(Mp6,{flexDirection:"column",children:[uo1(bo1,{services:Z.services,migrationsStatus:Z.migrationsStatus,home:$,serverUrl:Z.serverUrl}),uo1(go1,{logs:Z.logs})]})}var Si0=w(()=>{yo1();ho1();EE()});var vJ="thread-gate",rN="decopilot-hosted-harness",aN="decopilot-hosted-harness-sandboxed",F3="automations",mB="background-tools",jE="task-board-github-reads",PE="jira-push";var co1="7";function lo1($){return{name:"decocms",systemDatabaseUrl:$.systemDatabaseUrl,systemDatabaseSchemaName:"dbos",systemDatabasePoolSize:$.poolSize,runAdminServer:!1,executorID:$.executorID,applicationVersion:co1,...$.listenQueues!==void 0?{listenQueues:$.listenQueues}:{}}}var do1=()=>{};function Cp6(){let $=(process.env.BUN_OPTIONS??"").split(/\s+/).filter(Boolean);return[...process.argv.slice(1),...$]}function Ci0($,Z){for(let X=0;X<$.length;X++){let Q=$[X];if(Q===void 0)continue;if(Q===Z)return $[X+1];if(Q.startsWith(`${Z}=`))return Q.slice(Z.length+1)}return}function mo1(){let $=Cp6();if($.includes("--cpu-prof")){console.log(JSON.stringify({msg:"cpu-profiling-active",dir:Ci0($,"--cpu-prof-dir")??process.cwd(),name:Ci0($,"--cpu-prof-name"),markdown:$.includes("--cpu-prof-md"),intervalUs:Number(Ci0($,"--cpu-prof-interval")??1000),note:"profile is written on process exit"}));return}if(process.env.CPU_PROFILE)console.warn(JSON.stringify({msg:"cpu-profiling-requested-but-inactive",hint:'CPU profiling is a Bun launch flag. Set BUN_OPTIONS="--cpu-prof --cpu-prof-md --cpu-prof-dir=/tmp" before starting the process.'}))}function io1(){if(process.env.HEAP_WATCH!=="1")return()=>{};let $=Number(process.env.HEAP_WATCH_INTERVAL_MS??60000),Z=async()=>{let X=BE();if(!X)return;let Q={};try{let{heapStats:Y}=await import("bun:jsc"),G=Y(),J=Object.entries(G.objectTypeCounts).sort((K,W)=>W[1]-K[1]).slice(0,20);Q={objectCount:G.objectCount,heapSize:G.heapSize,top:Object.fromEntries(J)}}catch{}console.log(JSON.stringify({msg:"heap-watch",ts:new Date().toISOString(),uptimeS:Math.round(process.uptime()),rss:X.rss,heapUsed:X.heapUsed,heapTotal:X.heapTotal,external:X.external,arrayBuffers:X.arrayBuffers,...Q}))};return Z().catch(()=>{}),AZ0=setInterval(()=>void Z().catch(()=>{}),$),AZ0.unref?.(),process.on("SIGUSR2",()=>{try{let X=Bun.generateHeapSnapshot("v8"),Q=typeof X==="string"?X:JSON.stringify(X),Y=`/tmp/heap-${process.pid}-${Date.now()}.heapsnapshot`;Bun.write(Y,Q),console.log(JSON.stringify({msg:"heap-snapshot-written",path:Y}))}catch(X){console.error("[heap-watch] snapshot failed:",X)}}),()=>{if(AZ0)clearInterval(AZ0)}}var AZ0;var no1=()=>{};import*as _p6 from"bun:jsc";function po1(){if(process.env.STALL_WATCHDOG!=="1")return()=>{};let $=Number(process.env.STALL_WATCHDOG_MS??100),Z=Number(process.env.STALL_WATCHDOG_TICK_MS??50);try{vp6()}catch(G){return console.error("[stall-watchdog] failed to start sampling profiler:",G),()=>{}}let X,Q=performance.now()+Z,Y=()=>{let G=performance.now(),J=G-Q;Q=G+Z;let K=[];try{K=xp6()?.traces??[]}catch{}if(J>$&&K.length>0){let W=new Map;for(let N of K){let U=N.frames.find((O)=>O.sourceURL&&!/Unknown Executable/.test(O.category??""))??N.frames[0];if(!U)continue;let F=(U.sourceURL??"?").replace(/^.*\/node_modules\//,"node_modules/"),B=`${U.name??"?"} @ ${F}:${U.line??"?"}`;W.set(B,(W.get(B)??0)+1)}let H=[...W.entries()].sort((N,U)=>U[1]-N[1]).slice(0,8).map(([N,U])=>({frame:N,count:U}));console.warn(JSON.stringify({msg:"stall-stack",ts:new Date().toISOString(),lagMs:Math.round(J),samplesInWindow:K.length,top:H}))}X=setTimeout(Y,Z),X.unref?.()};return X=setTimeout(Y,Z),X.unref?.(),()=>{if(X)clearTimeout(X)}}var vp6,xp6;var to1=w(()=>{({startSamplingProfiler:vp6,samplingProfilerStackTraces:xp6}=_p6)});function oo1(){mo1();let $=[io1(),ni1(),po1()];return()=>{for(let Z of $)Z()}}var ro1=w(()=>{Cc0();no1();to1()});var AE=_((ao1)=>{Object.defineProperty(ao1,"__esModule",{value:!0});ao1.RepublishHeaders=ao1.DirectMsgHeaders=ao1.JsHeaders=ao1.AdvisoryKind=void 0;ao1.isOrderedPushConsumerOptions=fp6;ao1.isPullConsumer=bp6;ao1.isPushConsumer=yp6;ao1.isBoundPushConsumerOptions=gp6;function fp6($){if($&&typeof $==="object")return"name_prefix"in $||"deliver_subject_prefix"in $||"filter_subjects"in $||"filter_subject"in $||"deliver_policy"in $||"opt_start_seq"in $||"opt_start_time"in $||"replay_policy"in $||"inactive_threshold"in $||"headers_only"in $||"deliver_prefix"in $;return!1}function bp6($){return $.isPullConsumer()}function yp6($){return $.isPushConsumer()}function gp6($){if($&&typeof $==="object")return"deliver_subject"in $||"deliver_group"in $||"idle_heartbeat"in $;return!1}ao1.AdvisoryKind={API:"api_audit",StreamAction:"stream_action",ConsumerAction:"consumer_action",SnapshotCreate:"snapshot_create",SnapshotComplete:"snapshot_complete",RestoreCreate:"restore_create",RestoreComplete:"restore_complete",MaxDeliver:"max_deliver",Terminated:"terminated",Ack:"consumer_ack",StreamLeaderElected:"stream_leader_elected",StreamQuorumLost:"stream_quorum_lost",ConsumerLeaderElected:"consumer_leader_elected",ConsumerQuorumLost:"consumer_quorum_lost"};ao1.JsHeaders={StreamSourceHdr:"Nats-Stream-Source",LastConsumerSeqHdr:"Nats-Last-Consumer",LastStreamSeqHdr:"Nats-Last-Stream",ConsumerStalledHdr:"Nats-Consumer-Stalled",MessageSizeHdr:"Nats-Msg-Size",RollupHdr:"Nats-Rollup",RollupValueSubject:"sub",RollupValueAll:"all",PendingMessagesHdr:"Nats-Pending-Messages",PendingBytesHdr:"Nats-Pending-Bytes",RequiredApiLevel:"Nats-Required-Api-Level"};ao1.DirectMsgHeaders={Stream:"Nats-Stream",Sequence:"Nats-Sequence",TimeStamp:"Nats-Time-Stamp",Subject:"Nats-Subject",LastSequence:"Nats-Last-Sequence",NumPending:"Nats-Num-Pending"};ao1.RepublishHeaders={Stream:"Nats-Stream",Subject:"Nats-Subject",Sequence:"Nats-Sequence",LastSequence:"Nats-Last-Sequence",Size:"Nats-Msg-Size"}});var eY=_((eo1)=>{Object.defineProperty(eo1,"__esModule",{value:!0});eo1.TD=eo1.TE=eo1.Empty=void 0;eo1.encode=pp6;eo1.decode=tp6;eo1.Empty=new Uint8Array(0);eo1.TE=new TextEncoder;eo1.TD=new TextDecoder;function np6(...$){let Z=0;for(let Y=0;Y<$.length;Y++)Z+=$[Y].length;let X=new Uint8Array(Z),Q=0;for(let Y=0;Y<$.length;Y++)X.set($[Y],Q),Q+=$[Y].length;return X}function pp6(...$){let Z=[];for(let X=0;X<$.length;X++)Z.push(eo1.TE.encode($[X]));if(Z.length===0)return eo1.Empty;if(Z.length===1)return Z[0];return np6(...Z)}function tp6($){if(!$||$.length===0)return"";return eo1.TD.decode($)}});var $G=_((Xr1)=>{Object.defineProperty(Xr1,"__esModule",{value:!0});Xr1.errors=Xr1.PermissionViolationError=Xr1.NoRespondersError=Xr1.TimeoutError=Xr1.RequestError=Xr1.ProtocolError=Xr1.ConnectionError=Xr1.DrainingConnectionError=Xr1.ClosedConnectionError=Xr1.AuthorizationError=Xr1.UserAuthenticationExpiredError=Xr1.InvalidOperationError=Xr1.InvalidArgumentError=Xr1.InvalidSubjectError=void 0;class vi0 extends Error{constructor($,Z){super(`illegal subject: '${$}'`,Z);this.name="InvalidSubjectError"}}Xr1.InvalidSubjectError=vi0;class TZ0 extends Error{constructor($,Z){super($,Z);this.name="InvalidArgumentError"}static format($,Z,X){if(Array.isArray(Z)&&Z.length>1)Z=Z[0];if(Array.isArray($))$=$.map((Q)=>`'${Q}'`),$=$.join(",");else $=`'${$}'`;return new TZ0(`${$} ${Z}`,X)}}Xr1.InvalidArgumentError=TZ0;class xi0 extends Error{constructor($,Z){super($,Z);this.name="InvalidOperationError"}}Xr1.InvalidOperationError=xi0;class RZ0 extends Error{constructor($,Z){super($,Z);this.name="UserAuthenticationExpiredError"}static parse($){if($.toLowerCase().indexOf("user authentication expired")!==-1)return new RZ0($);return null}}Xr1.UserAuthenticationExpiredError=RZ0;class IZ0 extends Error{constructor($,Z){super($,Z);this.name="AuthorizationError"}static parse($){let Z=["authorization violation","account authentication expired","authentication timeout"],X=$.toLowerCase();for(let Q=0;Q<Z.length;Q++)if(X.indexOf(Z[Q])!==-1)return new IZ0($);return null}}Xr1.AuthorizationError=IZ0;class fi0 extends Error{constructor(){super("closed connection");this.name="ClosedConnectionError"}}Xr1.ClosedConnectionError=fi0;class bi0 extends Error{constructor(){super("connection draining");this.name="DrainingConnectionError"}}Xr1.DrainingConnectionError=bi0;class yi0 extends Error{constructor($,Z){super($,Z);this.name="ConnectionError"}}Xr1.ConnectionError=yi0;class gi0 extends Error{constructor($,Z){super($,Z);this.name="ProtocolError"}}Xr1.ProtocolError=gi0;class hi0 extends Error{constructor($="",Z){super($,Z);this.name="RequestError"}isNoResponders(){return this.cause instanceof qZ0}}Xr1.RequestError=hi0;class ui0 extends Error{constructor($){super("timeout",$);this.name="TimeoutError"}}Xr1.TimeoutError=ui0;class qZ0 extends Error{subject;constructor($,Z){super(`no responders: '${$}'`,Z);this.subject=$,this.name="NoResponders"}}Xr1.NoRespondersError=qZ0;class MZ0 extends Error{operation;subject;queue;constructor($,Z,X,Q,Y){super($,Y);this.name="PermissionViolationError",this.operation=Z,this.subject=X,this.queue=Q}static parse($){if(($?$.toLowerCase():"").indexOf("permissions violation")===-1)return null;let X="publish",Q="",Y=void 0,G=$.match(/(Publish|Subscription) to "(\S+)"/);if(G){if(X=G[1].toLowerCase(),Q=G[2],X==="subscription"){let J=$.match(/using queue "(\S+)"/);if(J)Y=J[1]}}return new MZ0($,X,Q,Y)}}Xr1.PermissionViolationError=MZ0;Xr1.errors={AuthorizationError:IZ0,ClosedConnectionError:fi0,ConnectionError:yi0,DrainingConnectionError:bi0,InvalidArgumentError:TZ0,InvalidOperationError:xi0,InvalidSubjectError:vi0,NoRespondersError:qZ0,PermissionViolationError:MZ0,ProtocolError:gi0,RequestError:hi0,TimeoutError:ui0,UserAuthenticationExpiredError:RZ0}});var xJ=_((Kr1)=>{Object.defineProperty(Kr1,"__esModule",{value:!0});Kr1.SimpleMutex=Kr1.Perf=void 0;Kr1.extend=Ut6;Kr1.render=Ft6;Kr1.timeout=Bt6;Kr1.delay=Ot6;Kr1.deadline=wt6;Kr1.deferred=li0;Kr1.debugDeferred=Lt6;Kr1.shuffle=Dt6;Kr1.collect=Et6;Kr1.jitter=Jr1;Kr1.backoff=zt6;Kr1.nanos=jt6;Kr1.millis=Pt6;Kr1.randomToken=Rt6;var Nt6=eY(),ci0=$G();function Ut6($,...Z){for(let X=0;X<Z.length;X++){let Q=Z[X];Object.keys(Q).forEach(function(Y){$[Y]=Q[Y]})}return $}function Ft6($){return Nt6.TD.decode($).replace(/\n/g,"\u240A").replace(/\r/g,"\u240D")}function Bt6($,Z=!0){let X=Z?new ci0.TimeoutError:null,Q,Y,G=new Promise((J,K)=>{Q={cancel:()=>{if(Y)clearTimeout(Y)}},Y=setTimeout(()=>{if(X===null)K(new ci0.TimeoutError);else K(X)},$)});return Object.assign(G,Q)}function Ot6($=0){let Z,X=new Promise((Q)=>{let Y=setTimeout(()=>{Q()},$);Z={cancel:()=>{if(Y)clearTimeout(Y),Q()}}});return Object.assign(X,Z)}async function wt6($,Z=1000){let X=li0(),Q=setTimeout(()=>{X.reject(new ci0.TimeoutError)},Z);try{return await Promise.race([$,X])}finally{clearTimeout(Q)}}function li0(){let $={},Z=new Promise((X,Q)=>{$={resolve:X,reject:Q}});return Object.assign(Z,$)}function Lt6(){let $={},Z=new Promise((X,Q)=>{$={resolve:(Y)=>{console.trace("resolve",Y),X(Y)},reject:(Y)=>{console.trace("reject"),Q(Y)}}});return Object.assign(Z,$)}function Dt6($){for(let Z=$.length-1;Z>0;Z--){let X=Math.floor(Math.random()*(Z+1));[$[Z],$[X]]=[$[X],$[Z]]}return $}async function Et6($){let Z=[];for await(let X of $)Z.push(X);return Z}class Yr1{timers;measures;constructor(){this.timers=new Map,this.measures=new Map}mark($){this.timers.set($,performance.now())}measure($,Z,X){let Q=this.timers.get(Z);if(Q===void 0)throw Error(`${Z} is not defined`);let Y=this.timers.get(X);if(Y===void 0)throw Error(`${X} is not defined`);this.measures.set($,Y-Q)}getEntries(){let $=[];return this.measures.forEach((Z,X)=>{$.push({name:X,duration:Z})}),$}}Kr1.Perf=Yr1;class Gr1{max;current;waiting;constructor($=1){this.max=$,this.current=0,this.waiting=[]}lock(){if(this.current++,this.current<=this.max)return Promise.resolve();let $=li0();return this.waiting.push($),$}unlock(){this.current--,this.waiting.pop()?.resolve()}}Kr1.SimpleMutex=Gr1;function Jr1($){if($===0)return 0;return Math.floor($/2+Math.random()*$)}function zt6($=[0,250,250,500,500,3000,5000]){if(!Array.isArray($))$=[0,250,250,500,500,3000,5000];let Z=$.length-1;return{backoff(X){return Jr1(X>Z?$[Z]:$[X])}}}function jt6($){return $*1e6}function Pt6($){return Math.floor($/1e6)}var At6="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",sN=new Uint8Array(62);for(let $=0;$<62;$++)sN[$]=At6.charCodeAt($);var Tt6=218340105584896;function Rt6(){let $=Math.floor(Math.random()*Tt6),Z=$%62,X=sN[Z];$=($-Z)/62,Z=$%62;let Q=sN[Z];$=($-Z)/62,Z=$%62;let Y=sN[Z];$=($-Z)/62,Z=$%62;let G=sN[Z];$=($-Z)/62,Z=$%62;let J=sN[Z];$=($-Z)/62,Z=$%62;let K=sN[Z];$=($-Z)/62,Z=$%62;let W=sN[Z];$=($-Z)/62;let H=sN[$];return String.fromCharCode(X,Q,Y,G,J,K,W,H)}});var wr1=_((Br1)=>{Object.defineProperty(Br1,"__esModule",{value:!0});Br1.nuid=Br1.NuidImpl=void 0;var ut6="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",iB=62,kZ0=12,Ur1=10,Hr1=33,ct6=333,Nr1=kZ0+Ur1,mi0=new Uint8Array(iB);for(let $=0;$<iB;$++)mi0[$]=ut6.charCodeAt($);var VZ0=4294967296,Fr1=BigInt(iB)**BigInt(Ur1),fi=Number(Fr1/(1n<<32n)),di0=Number(Fr1%(1n<<32n));function lt6($){for(let Z=0;Z<$.length;Z++)$[Z]=Math.floor(Math.random()*256)}function dt6($){if(globalThis?.crypto?.getRandomValues)globalThis.crypto.getRandomValues($);else lt6($)}class ii0{buf;cbuf;seqHi;seqLo;inc;inited;constructor(){this.buf=new Uint8Array(Nr1),this.cbuf=new Uint8Array(kZ0),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){let $=0;do this.seqHi=Math.floor(Math.random()*(fi+1)),this.seqLo=Math.floor(Math.random()*VZ0);while($++<8&&this.seqHi===fi&&this.seqLo>=di0);if(this.seqHi===fi&&this.seqLo>=di0)this.seqLo=0;this.inc=Math.random()*(ct6-Hr1)+Hr1|0}setPre(){dt6(this.cbuf);for(let $=0;$<kZ0;$++)this.buf[$]=mi0[this.cbuf[$]%iB]}fillSeq(){let $=this.seqHi,Z=this.seqLo;for(let X=Nr1-1;X>=kZ0;X--){let Q=Math.floor($/iB),G=($-Q*iB)*VZ0+Z,J=Math.floor(G/iB),K=G-J*iB;this.buf[X]=mi0[K],$=Q,Z=J}}next(){if(!this.inited)this.init();if(this.seqLo+=this.inc,this.seqLo>=VZ0)this.seqLo-=VZ0,this.seqHi+=1;if(this.seqHi>fi||this.seqHi===fi&&this.seqLo>=di0)this.setPre(),this.initSeqAndInc();this.fillSeq();let $=this.buf;return String.fromCharCode($[0],$[1],$[2],$[3],$[4],$[5],$[6],$[7],$[8],$[9],$[10],$[11],$[12],$[13],$[14],$[15],$[16],$[17],$[18],$[19],$[20],$[21])}reset(){this.init()}}Br1.NuidImpl=ii0;Br1.nuid=new ii0});var zr1=_((Dr1)=>{Object.defineProperty(Dr1,"__esModule",{value:!0});Dr1.nuid=Dr1.Nuid=void 0;var Lr1=wr1();Dr1.Nuid=Lr1.NuidImpl;Dr1.nuid=Lr1.nuid});var CZ0=_((SZ0)=>{Object.defineProperty(SZ0,"__esModule",{value:!0});SZ0.nuid=SZ0.Nuid=void 0;var jr1=zr1();Object.defineProperty(SZ0,"Nuid",{enumerable:!0,get:function(){return jr1.Nuid}});Object.defineProperty(SZ0,"nuid",{enumerable:!0,get:function(){return jr1.nuid}})});var nB=_((Pr1)=>{Object.defineProperty(Pr1,"__esModule",{value:!0});Pr1.DEFAULT_HOST=Pr1.DEFAULT_PORT=Pr1.Match=void 0;Pr1.syncIterator=ot6;Pr1.createInbox=rt6;var pt6=CZ0(),tt6=$G();Pr1.Match={Exact:"exact",CanonicalMIME:"canonical",IgnoreCase:"insensitive"};function ot6($){let Z=$[Symbol.asyncIterator]();return{async next(){let X=await Z.next();if(X.done)return Promise.resolve(null);return Promise.resolve(X.value)}}}function rt6($=""){if($=$||"_INBOX",typeof $!=="string")throw TypeError("prefix must be a string");return $.split(".").forEach((Z)=>{if(Z==="*"||Z===">")throw tt6.InvalidArgumentError.format("prefix",`cannot have wildcards ('${$}')`)}),`${$}.${pt6.nuid.next()}`}Pr1.DEFAULT_PORT=4222;Pr1.DEFAULT_HOST="127.0.0.1"});var bi=_((Ir1)=>{Object.defineProperty(Ir1,"__esModule",{value:!0});Ir1.DataBuffer=void 0;var Tr1=eY();class Rr1{buffers;byteLength;constructor(){this.buffers=[],this.byteLength=0}static concat(...$){let Z=0;for(let Y=0;Y<$.length;Y++)Z+=$[Y].length;let X=new Uint8Array(Z),Q=0;for(let Y=0;Y<$.length;Y++)X.set($[Y],Q),Q+=$[Y].length;return X}static fromAscii($){if(!$)$="";return Tr1.TE.encode($)}static toAscii($){return Tr1.TD.decode($)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){let $=new Uint8Array(this.byteLength),Z=0;for(let X=0;X<this.buffers.length;X++)$.set(this.buffers[X],Z),Z+=this.buffers[X].length;this.buffers.length=0,this.buffers.push($)}}shift(){if(this.buffers.length){let $=this.buffers.shift();if($)return this.byteLength-=$.length,$}return new Uint8Array(0)}drain($){if(this.buffers.length){this.pack();let Z=this.buffers.pop();if(Z){let X=this.byteLength;if($===void 0||$>X)$=X;let Q=Z.subarray(0,$);if(X>$)this.buffers.push(Z.subarray($));return this.byteLength=X-$,Q}}return new Uint8Array(0)}fill($,...Z){if($)this.buffers.push($),this.byteLength+=$.length;for(let X=0;X<Z.length;X++)if(Z[X]&&Z[X].length)this.buffers.push(Z[X]),this.byteLength+=Z[X].length}peek(){if(this.buffers.length)return this.pack(),this.buffers[0];return new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}Ir1.DataBuffer=Rr1});var TE=_((Vr1)=>{Object.defineProperty(Vr1,"__esModule",{value:!0});Vr1.LF=Vr1.CR=Vr1.CRLF=Vr1.CR_LF_LEN=Vr1.CR_LF=void 0;Vr1.setTransportFactory=Yo6;Vr1.defaultPort=Go6;Vr1.getUrlParseFn=Jo6;Vr1.newTransport=Ko6;Vr1.getResolveFn=Wo6;Vr1.protoLen=Mr1;Vr1.extractProtocolMessage=Ho6;var Zo6=eY(),Xo6=nB(),Qo6=bi(),ZG;function Yo6($){ZG=$}function Go6(){return ZG!==void 0&&ZG.defaultPort!==void 0?ZG.defaultPort:Xo6.DEFAULT_PORT}function Jo6(){return ZG!==void 0&&ZG.urlParseFn?ZG.urlParseFn:void 0}function Ko6(){if(!ZG||typeof ZG.factory!=="function")throw Error("transport fn is not set");return ZG.factory()}function Wo6(){return ZG!==void 0&&ZG.dnsResolveFn?ZG.dnsResolveFn:void 0}Vr1.CR_LF=`\r
1374
+ `);Q=G.pop()??"";for(let J of G){let K=vi(J).replace(/^\[\d+\]\s*/,"").trim();if(!K)continue;lB({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:K})}}(async()=>{for(;;){let{done:G,value:J}=await Z.read();if(G)break;Q+=X.decode(J,{stream:!0}),Y()}if(Q.trim()){let G=vi(Q).replace(/^\[\d+\]\s*/,"").trim();if(G)lB({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:G})}})()}async function zp6($){let{baseUrl:Z,noTui:X}=$,Q=process.env.HOST==="0.0.0.0"&&Boolean(process.env.PORT),Y=Q?process.env.PORT:$.vitePort,G=Z||`http://localhost:${Y}`,J=Q?await _i(Number(Y)+1):await _i(Number($.port)),{settings:K,services:W,managedServiceNames:H}=await EZ0({port:String(J),home:$.home,baseUrl:$.baseUrl,localMode:$.localMode,skipMigrations:$.skipMigrations,noTui:$.noTui,vitePort:$.vitePort});for(let L of W)DE({name:L.name,status:"ready",port:L.port});Si();let N=Ep6(import.meta.dir,"..","..","..","..",".."),U=X===!0,F=Bun.spawn(["bun","run","dev:servers"],{cwd:N,env:{...process.env,PORT:String(K.port),VITE_PORT:String(Y),DATABASE_URL:K.databaseUrl,NATS_URL:K.natsUrls.join(","),NODE_ENV:K.nodeEnv,BASE_URL:G,DECOCMS_LOCAL_MODE:String(K.localMode),DECOCMS_HOME:K.dataDir,DATA_DIR:K.dataDir,DECO_CLI:"1",...K.betterAuthSecret?{BETTER_AUTH_SECRET:K.betterAuthSecret}:{},...K.s3Endpoint?{S3_ENDPOINT:K.s3Endpoint,S3_BUCKET:K.s3Bucket??"",S3_ACCESS_KEY_ID:K.s3AccessKeyId??"",S3_SECRET_ACCESS_KEY:K.s3SecretAccessKey??"",S3_FORCE_PATH_STYLE:String(K.s3ForcePathStyle)}:{},...K.natsPublicUrl&&K.natsAccountJwt&&K.natsAccountSigningKey?{NATS_PUBLIC_URL:K.natsPublicUrl,NATS_ACCOUNT_JWT:K.natsAccountJwt,NATS_ACCOUNT_SIGNING_KEY:K.natsAccountSigningKey,NATS_OPERATOR_JWT:K.natsOperatorJwt??"",NATS_TUNNEL_PUBLIC_ENABLED:"true",...K.natsCredsPath?{NATS_CREDS:K.natsCredsPath}:{}}:{}},stdio:["inherit",U?"inherit":"pipe",U?"inherit":"pipe"]});if(!U)So1(F.stdout),So1(F.stderr);Ci(G),DE({name:"Vite",status:"ready",port:Number(Y)}),DE({name:"API",status:"ready",port:Number(K.port)});let O=async(L)=>{if(F.kill(L),await F.exited,H.length>0){let{stopServices:D}=await Promise.resolve().then(() => (q90(),I90));await D(K.dataDir)}};return process.on("SIGINT",()=>O("SIGINT")),process.on("SIGTERM",()=>O("SIGTERM")),{port:Number(Y),process:F}}var Ii0=w(()=>{zi0();EE();Ti0()});var PZ0;var qi0=w(()=>{PZ0={name:"decocms",version:"4.241.1",description:"Deco CMS \u2014 Self-hostable MCP Gateway for managing AI connections and tools",author:"Deco team",repository:{type:"git",url:"git+https://github.com/decocms/studio.git",directory:"apps/api"},bugs:{url:"https://github.com/decocms/studio/issues"},type:"module",bin:{deco:"./dist/server/cli.js"},files:["dist/**/*"],scripts:{dev:"bun run migrate && bun run dev:server","dev:server":"bun run --cwd=../../packages/sandbox build && NODE_ENV=development bun --env-file=.env --hot run src/index.ts",build:"bun run build:server","build:server":"bun run scripts/bundle-server-script.ts --dist ./dist/server","generate:tool-contracts":"bun run scripts/generate-tool-contracts.ts","db:migrate":"bun run ./dist/server/migrate.js","db:migrate:dbos":"bun run ./dist/server/migrate-dbos.js",check:"tsc --noEmit",start:"bun run ./dist/server/server.js",migrate:"bun run src/database/migrate.ts","migrate:dbos":"bun run src/database/migrate-dbos.ts",test:"bun test src","better-auth:migrate":"bunx --bun @better-auth/cli migrate -y --config src/auth/index.ts",prepublishOnly:"bun run --cwd=../.. build:studio"},optionalDependencies:{"@duckdb/node-api":"^1.5.0-r.1"},dependencies:{"@ai-sdk/anthropic":"^3.0.85","@ai-sdk/google":"^3.0.83","@ai-sdk/openai":"^3.0.73","@anthropic-ai/sdk":"^0.105.0","@aws-sdk/client-s3":"^3.1013.0","@aws-sdk/client-sts":"^3.1013.0","@aws-sdk/lib-storage":"^3.1013.0","@aws-sdk/s3-request-presigner":"^3.1013.0","@clickhouse/client":"^1.8.1","@dbos-inc/dbos-sdk":"^4.21.6","@inkjs/ui":"^2.0.0","@nats-io/jetstream":"3.4.0","@nats-io/kv":"3.4.0","@nats-io/nats-core":"3.4.0","@nats-io/transport-node":"3.4.0","@openrouter/ai-sdk-provider":"^2.9.1","@opentelemetry/core":"^2.6.0","embedded-postgres":"^18.3.0-beta.16",ink:"^6.8.0",kysely:"^0.28.12","posthog-node":"^5.0.0",react:"^19.2.6","react-dom":"^19.2.6"},devDependencies:{"@ai-sdk/provider":"^3.0.10","@better-auth/sso":"1.4.1","@decocms/better-auth":"1.5.17","@decocms/bindings":"workspace:*","@decocms/mcp-utils":"workspace:*","@decocms/runtime":"workspace:*","@decocms/sandbox":"workspace:*","@decocms/shared":"workspace:*","@jitl/quickjs-wasmfile-release-sync":"0.31.0","@modelcontextprotocol/sdk":"1.29.0","@nats-io/jwt":"0.0.10-5","@opentelemetry/api":"^1.9.0","@opentelemetry/api-logs":"^0.211.0","@opentelemetry/exporter-logs-otlp-proto":"^0.211.0","@opentelemetry/exporter-prometheus":"^0.208.0","@opentelemetry/exporter-trace-otlp-proto":"^0.207.0","@opentelemetry/instrumentation-runtime-node":"^0.24.0","@opentelemetry/resources":"^2.6.0","@opentelemetry/sdk-logs":"^0.211.0","@opentelemetry/sdk-metrics":"^2.2.0","@opentelemetry/sdk-node":"^0.207.0","@opentelemetry/sdk-trace-base":"^2.5.0","@types/bun":"^1.3.1","@types/google.maps":"^3.65.2","@types/pg":"^8.15.6","@types/react-syntax-highlighter":"^15.5.13","@vercel/nft":"^1.1.1",ai:"^6.0.208","better-auth":"1.4.22",croner:"^9.1.0",degit:"^2.8.4",hono:"^4.10.7",jose:"^6.0.11",nanoid:"^5.1.6",pg:"^8.16.3",typescript:"^7.0.2",typescript5:"npm:typescript@^5.9.3",zod:"4.3.6"},homepage:"https://github.com/decocms/studio",keywords:["mcp","model-context-protocol","ai","gateway","self-hosted","tools"],license:"MIT",publishConfig:{access:"public"}}});import{Box as Pp6,Text as Co1}from"ink";import{jsx as Ap6,jsxs as _o1}from"react/jsx-runtime";function vo1({version:$}){return _o1(Pp6,{flexDirection:"column",marginTop:1,children:[o90.map((Z,X)=>Ap6(Co1,{color:r90[X],children:Z},X)),_o1(Co1,{dimColor:!0,children:[" v",$]})]})}var xo1=w(()=>{Ei()});import{Box as zE,Text as dB}from"ink";import{Spinner as Tp6}from"@inkjs/ui";import{jsx as sY,jsxs as db}from"react/jsx-runtime";function fo1({status:$}){if($==="pending")return sY(Tp6,{label:""});return sY(dB,{color:"green",children:"\u2713"})}function Rp6($){return`${$.name}: ${$.port||"...."}`}function bo1({services:$,migrationsStatus:Z,home:X,serverUrl:Q}){return db(zE,{flexDirection:"column",paddingBottom:1,children:[sY(vo1,{version:PZ0.version}),sY(zE,{marginBottom:1,children:sY(dB,{dimColor:!0,children:"\u2500".repeat(80)})}),sY(zE,{children:db(dB,{dimColor:!0,children:["Home: ",X]})}),db(zE,{gap:2,children:[$.map((Y)=>db(zE,{gap:1,children:[sY(dB,{children:Rp6(Y)}),sY(fo1,{status:Y.status})]},Y.name)),db(zE,{gap:1,children:[sY(dB,{children:"Migrations"}),sY(fo1,{status:Z})]})]}),sY(zE,{children:Q?db(dB,{children:["Open in browser: ",sY(dB,{color:"cyan",children:Q})]}):sY(dB,{dimColor:!0,children:"Starting..."})})]})}var yo1=w(()=>{qi0();xo1()});import{Box as Ip6,Text as xi}from"ink";import{jsx as Mi0,jsxs as Vi0}from"react/jsx-runtime";function qp6($){if($>=500)return"red";if($>=400)return"yellow";if($>=300)return"cyan";return"green"}function go1({logs:$}){return Mi0(Ip6,{flexDirection:"column",children:$.map((Z,X)=>{if(Z.rawLine)return Mi0(xi,{dimColor:!0,children:Z.rawLine},X);let Q=Z.duration<1000?`${Z.duration}ms`:`${(Z.duration/1000).toFixed(1)}s`;return Vi0(xi,{children:[Vi0(xi,{dimColor:!0,children:[Z.method.padEnd(6)," ",Z.path.padEnd(30)," "]}),Mi0(xi,{color:qp6(Z.status),children:Z.status}),Vi0(xi,{dimColor:!0,children:[" ",Q.padStart(8)]})]},X)})})}var ho1=()=>{};var ki0={};F0(ki0,{App:()=>kp6});import{Box as Mp6}from"ink";import{useSyncExternalStore as Vp6}from"react";import{jsx as uo1,jsxs as Sp6}from"react/jsx-runtime";function kp6({home:$}){let Z=Vp6(Ai0,Pi0);return Sp6(Mp6,{flexDirection:"column",children:[uo1(bo1,{services:Z.services,migrationsStatus:Z.migrationsStatus,home:$,serverUrl:Z.serverUrl}),uo1(go1,{logs:Z.logs})]})}var Si0=w(()=>{yo1();ho1();EE()});var vJ="thread-gate",rN="decopilot-hosted-harness",aN="decopilot-hosted-harness-sandboxed",F3="automations",mB="background-tools",jE="task-board-github-reads",PE="jira-push";var co1="7";function lo1($){return{name:"decocms",systemDatabaseUrl:$.systemDatabaseUrl,systemDatabaseSchemaName:"dbos",systemDatabasePoolSize:$.poolSize,runAdminServer:!1,executorID:$.executorID,applicationVersion:co1,...$.listenQueues!==void 0?{listenQueues:$.listenQueues}:{}}}var do1=()=>{};function Cp6(){let $=(process.env.BUN_OPTIONS??"").split(/\s+/).filter(Boolean);return[...process.argv.slice(1),...$]}function Ci0($,Z){for(let X=0;X<$.length;X++){let Q=$[X];if(Q===void 0)continue;if(Q===Z)return $[X+1];if(Q.startsWith(`${Z}=`))return Q.slice(Z.length+1)}return}function mo1(){let $=Cp6();if($.includes("--cpu-prof")){console.log(JSON.stringify({msg:"cpu-profiling-active",dir:Ci0($,"--cpu-prof-dir")??process.cwd(),name:Ci0($,"--cpu-prof-name"),markdown:$.includes("--cpu-prof-md"),intervalUs:Number(Ci0($,"--cpu-prof-interval")??1000),note:"profile is written on process exit"}));return}if(process.env.CPU_PROFILE)console.warn(JSON.stringify({msg:"cpu-profiling-requested-but-inactive",hint:'CPU profiling is a Bun launch flag. Set BUN_OPTIONS="--cpu-prof --cpu-prof-md --cpu-prof-dir=/tmp" before starting the process.'}))}function io1(){if(process.env.HEAP_WATCH!=="1")return()=>{};let $=Number(process.env.HEAP_WATCH_INTERVAL_MS??60000),Z=async()=>{let X=BE();if(!X)return;let Q={};try{let{heapStats:Y}=await import("bun:jsc"),G=Y(),J=Object.entries(G.objectTypeCounts).sort((K,W)=>W[1]-K[1]).slice(0,20);Q={objectCount:G.objectCount,heapSize:G.heapSize,top:Object.fromEntries(J)}}catch{}console.log(JSON.stringify({msg:"heap-watch",ts:new Date().toISOString(),uptimeS:Math.round(process.uptime()),rss:X.rss,heapUsed:X.heapUsed,heapTotal:X.heapTotal,external:X.external,arrayBuffers:X.arrayBuffers,...Q}))};return Z().catch(()=>{}),AZ0=setInterval(()=>void Z().catch(()=>{}),$),AZ0.unref?.(),process.on("SIGUSR2",()=>{try{let X=Bun.generateHeapSnapshot("v8"),Q=typeof X==="string"?X:JSON.stringify(X),Y=`/tmp/heap-${process.pid}-${Date.now()}.heapsnapshot`;Bun.write(Y,Q),console.log(JSON.stringify({msg:"heap-snapshot-written",path:Y}))}catch(X){console.error("[heap-watch] snapshot failed:",X)}}),()=>{if(AZ0)clearInterval(AZ0)}}var AZ0;var no1=()=>{};import*as _p6 from"bun:jsc";function po1(){if(process.env.STALL_WATCHDOG!=="1")return()=>{};let $=Number(process.env.STALL_WATCHDOG_MS??100),Z=Number(process.env.STALL_WATCHDOG_TICK_MS??50);try{vp6()}catch(G){return console.error("[stall-watchdog] failed to start sampling profiler:",G),()=>{}}let X,Q=performance.now()+Z,Y=()=>{let G=performance.now(),J=G-Q;Q=G+Z;let K=[];try{K=xp6()?.traces??[]}catch{}if(J>$&&K.length>0){let W=new Map;for(let N of K){let U=N.frames.find((O)=>O.sourceURL&&!/Unknown Executable/.test(O.category??""))??N.frames[0];if(!U)continue;let F=(U.sourceURL??"?").replace(/^.*\/node_modules\//,"node_modules/"),B=`${U.name??"?"} @ ${F}:${U.line??"?"}`;W.set(B,(W.get(B)??0)+1)}let H=[...W.entries()].sort((N,U)=>U[1]-N[1]).slice(0,8).map(([N,U])=>({frame:N,count:U}));console.warn(JSON.stringify({msg:"stall-stack",ts:new Date().toISOString(),lagMs:Math.round(J),samplesInWindow:K.length,top:H}))}X=setTimeout(Y,Z),X.unref?.()};return X=setTimeout(Y,Z),X.unref?.(),()=>{if(X)clearTimeout(X)}}var vp6,xp6;var to1=w(()=>{({startSamplingProfiler:vp6,samplingProfilerStackTraces:xp6}=_p6)});function oo1(){mo1();let $=[io1(),ni1(),po1()];return()=>{for(let Z of $)Z()}}var ro1=w(()=>{Cc0();no1();to1()});var AE=_((ao1)=>{Object.defineProperty(ao1,"__esModule",{value:!0});ao1.RepublishHeaders=ao1.DirectMsgHeaders=ao1.JsHeaders=ao1.AdvisoryKind=void 0;ao1.isOrderedPushConsumerOptions=fp6;ao1.isPullConsumer=bp6;ao1.isPushConsumer=yp6;ao1.isBoundPushConsumerOptions=gp6;function fp6($){if($&&typeof $==="object")return"name_prefix"in $||"deliver_subject_prefix"in $||"filter_subjects"in $||"filter_subject"in $||"deliver_policy"in $||"opt_start_seq"in $||"opt_start_time"in $||"replay_policy"in $||"inactive_threshold"in $||"headers_only"in $||"deliver_prefix"in $;return!1}function bp6($){return $.isPullConsumer()}function yp6($){return $.isPushConsumer()}function gp6($){if($&&typeof $==="object")return"deliver_subject"in $||"deliver_group"in $||"idle_heartbeat"in $;return!1}ao1.AdvisoryKind={API:"api_audit",StreamAction:"stream_action",ConsumerAction:"consumer_action",SnapshotCreate:"snapshot_create",SnapshotComplete:"snapshot_complete",RestoreCreate:"restore_create",RestoreComplete:"restore_complete",MaxDeliver:"max_deliver",Terminated:"terminated",Ack:"consumer_ack",StreamLeaderElected:"stream_leader_elected",StreamQuorumLost:"stream_quorum_lost",ConsumerLeaderElected:"consumer_leader_elected",ConsumerQuorumLost:"consumer_quorum_lost"};ao1.JsHeaders={StreamSourceHdr:"Nats-Stream-Source",LastConsumerSeqHdr:"Nats-Last-Consumer",LastStreamSeqHdr:"Nats-Last-Stream",ConsumerStalledHdr:"Nats-Consumer-Stalled",MessageSizeHdr:"Nats-Msg-Size",RollupHdr:"Nats-Rollup",RollupValueSubject:"sub",RollupValueAll:"all",PendingMessagesHdr:"Nats-Pending-Messages",PendingBytesHdr:"Nats-Pending-Bytes",RequiredApiLevel:"Nats-Required-Api-Level"};ao1.DirectMsgHeaders={Stream:"Nats-Stream",Sequence:"Nats-Sequence",TimeStamp:"Nats-Time-Stamp",Subject:"Nats-Subject",LastSequence:"Nats-Last-Sequence",NumPending:"Nats-Num-Pending"};ao1.RepublishHeaders={Stream:"Nats-Stream",Subject:"Nats-Subject",Sequence:"Nats-Sequence",LastSequence:"Nats-Last-Sequence",Size:"Nats-Msg-Size"}});var eY=_((eo1)=>{Object.defineProperty(eo1,"__esModule",{value:!0});eo1.TD=eo1.TE=eo1.Empty=void 0;eo1.encode=pp6;eo1.decode=tp6;eo1.Empty=new Uint8Array(0);eo1.TE=new TextEncoder;eo1.TD=new TextDecoder;function np6(...$){let Z=0;for(let Y=0;Y<$.length;Y++)Z+=$[Y].length;let X=new Uint8Array(Z),Q=0;for(let Y=0;Y<$.length;Y++)X.set($[Y],Q),Q+=$[Y].length;return X}function pp6(...$){let Z=[];for(let X=0;X<$.length;X++)Z.push(eo1.TE.encode($[X]));if(Z.length===0)return eo1.Empty;if(Z.length===1)return Z[0];return np6(...Z)}function tp6($){if(!$||$.length===0)return"";return eo1.TD.decode($)}});var $G=_((Xr1)=>{Object.defineProperty(Xr1,"__esModule",{value:!0});Xr1.errors=Xr1.PermissionViolationError=Xr1.NoRespondersError=Xr1.TimeoutError=Xr1.RequestError=Xr1.ProtocolError=Xr1.ConnectionError=Xr1.DrainingConnectionError=Xr1.ClosedConnectionError=Xr1.AuthorizationError=Xr1.UserAuthenticationExpiredError=Xr1.InvalidOperationError=Xr1.InvalidArgumentError=Xr1.InvalidSubjectError=void 0;class vi0 extends Error{constructor($,Z){super(`illegal subject: '${$}'`,Z);this.name="InvalidSubjectError"}}Xr1.InvalidSubjectError=vi0;class TZ0 extends Error{constructor($,Z){super($,Z);this.name="InvalidArgumentError"}static format($,Z,X){if(Array.isArray(Z)&&Z.length>1)Z=Z[0];if(Array.isArray($))$=$.map((Q)=>`'${Q}'`),$=$.join(",");else $=`'${$}'`;return new TZ0(`${$} ${Z}`,X)}}Xr1.InvalidArgumentError=TZ0;class xi0 extends Error{constructor($,Z){super($,Z);this.name="InvalidOperationError"}}Xr1.InvalidOperationError=xi0;class RZ0 extends Error{constructor($,Z){super($,Z);this.name="UserAuthenticationExpiredError"}static parse($){if($.toLowerCase().indexOf("user authentication expired")!==-1)return new RZ0($);return null}}Xr1.UserAuthenticationExpiredError=RZ0;class IZ0 extends Error{constructor($,Z){super($,Z);this.name="AuthorizationError"}static parse($){let Z=["authorization violation","account authentication expired","authentication timeout"],X=$.toLowerCase();for(let Q=0;Q<Z.length;Q++)if(X.indexOf(Z[Q])!==-1)return new IZ0($);return null}}Xr1.AuthorizationError=IZ0;class fi0 extends Error{constructor(){super("closed connection");this.name="ClosedConnectionError"}}Xr1.ClosedConnectionError=fi0;class bi0 extends Error{constructor(){super("connection draining");this.name="DrainingConnectionError"}}Xr1.DrainingConnectionError=bi0;class yi0 extends Error{constructor($,Z){super($,Z);this.name="ConnectionError"}}Xr1.ConnectionError=yi0;class gi0 extends Error{constructor($,Z){super($,Z);this.name="ProtocolError"}}Xr1.ProtocolError=gi0;class hi0 extends Error{constructor($="",Z){super($,Z);this.name="RequestError"}isNoResponders(){return this.cause instanceof qZ0}}Xr1.RequestError=hi0;class ui0 extends Error{constructor($){super("timeout",$);this.name="TimeoutError"}}Xr1.TimeoutError=ui0;class qZ0 extends Error{subject;constructor($,Z){super(`no responders: '${$}'`,Z);this.subject=$,this.name="NoResponders"}}Xr1.NoRespondersError=qZ0;class MZ0 extends Error{operation;subject;queue;constructor($,Z,X,Q,Y){super($,Y);this.name="PermissionViolationError",this.operation=Z,this.subject=X,this.queue=Q}static parse($){if(($?$.toLowerCase():"").indexOf("permissions violation")===-1)return null;let X="publish",Q="",Y=void 0,G=$.match(/(Publish|Subscription) to "(\S+)"/);if(G){if(X=G[1].toLowerCase(),Q=G[2],X==="subscription"){let J=$.match(/using queue "(\S+)"/);if(J)Y=J[1]}}return new MZ0($,X,Q,Y)}}Xr1.PermissionViolationError=MZ0;Xr1.errors={AuthorizationError:IZ0,ClosedConnectionError:fi0,ConnectionError:yi0,DrainingConnectionError:bi0,InvalidArgumentError:TZ0,InvalidOperationError:xi0,InvalidSubjectError:vi0,NoRespondersError:qZ0,PermissionViolationError:MZ0,ProtocolError:gi0,RequestError:hi0,TimeoutError:ui0,UserAuthenticationExpiredError:RZ0}});var xJ=_((Kr1)=>{Object.defineProperty(Kr1,"__esModule",{value:!0});Kr1.SimpleMutex=Kr1.Perf=void 0;Kr1.extend=Ut6;Kr1.render=Ft6;Kr1.timeout=Bt6;Kr1.delay=Ot6;Kr1.deadline=wt6;Kr1.deferred=li0;Kr1.debugDeferred=Lt6;Kr1.shuffle=Dt6;Kr1.collect=Et6;Kr1.jitter=Jr1;Kr1.backoff=zt6;Kr1.nanos=jt6;Kr1.millis=Pt6;Kr1.randomToken=Rt6;var Nt6=eY(),ci0=$G();function Ut6($,...Z){for(let X=0;X<Z.length;X++){let Q=Z[X];Object.keys(Q).forEach(function(Y){$[Y]=Q[Y]})}return $}function Ft6($){return Nt6.TD.decode($).replace(/\n/g,"\u240A").replace(/\r/g,"\u240D")}function Bt6($,Z=!0){let X=Z?new ci0.TimeoutError:null,Q,Y,G=new Promise((J,K)=>{Q={cancel:()=>{if(Y)clearTimeout(Y)}},Y=setTimeout(()=>{if(X===null)K(new ci0.TimeoutError);else K(X)},$)});return Object.assign(G,Q)}function Ot6($=0){let Z,X=new Promise((Q)=>{let Y=setTimeout(()=>{Q()},$);Z={cancel:()=>{if(Y)clearTimeout(Y),Q()}}});return Object.assign(X,Z)}async function wt6($,Z=1000){let X=li0(),Q=setTimeout(()=>{X.reject(new ci0.TimeoutError)},Z);try{return await Promise.race([$,X])}finally{clearTimeout(Q)}}function li0(){let $={},Z=new Promise((X,Q)=>{$={resolve:X,reject:Q}});return Object.assign(Z,$)}function Lt6(){let $={},Z=new Promise((X,Q)=>{$={resolve:(Y)=>{console.trace("resolve",Y),X(Y)},reject:(Y)=>{console.trace("reject"),Q(Y)}}});return Object.assign(Z,$)}function Dt6($){for(let Z=$.length-1;Z>0;Z--){let X=Math.floor(Math.random()*(Z+1));[$[Z],$[X]]=[$[X],$[Z]]}return $}async function Et6($){let Z=[];for await(let X of $)Z.push(X);return Z}class Yr1{timers;measures;constructor(){this.timers=new Map,this.measures=new Map}mark($){this.timers.set($,performance.now())}measure($,Z,X){let Q=this.timers.get(Z);if(Q===void 0)throw Error(`${Z} is not defined`);let Y=this.timers.get(X);if(Y===void 0)throw Error(`${X} is not defined`);this.measures.set($,Y-Q)}getEntries(){let $=[];return this.measures.forEach((Z,X)=>{$.push({name:X,duration:Z})}),$}}Kr1.Perf=Yr1;class Gr1{max;current;waiting;constructor($=1){this.max=$,this.current=0,this.waiting=[]}lock(){if(this.current++,this.current<=this.max)return Promise.resolve();let $=li0();return this.waiting.push($),$}unlock(){this.current--,this.waiting.pop()?.resolve()}}Kr1.SimpleMutex=Gr1;function Jr1($){if($===0)return 0;return Math.floor($/2+Math.random()*$)}function zt6($=[0,250,250,500,500,3000,5000]){if(!Array.isArray($))$=[0,250,250,500,500,3000,5000];let Z=$.length-1;return{backoff(X){return Jr1(X>Z?$[Z]:$[X])}}}function jt6($){return $*1e6}function Pt6($){return Math.floor($/1e6)}var At6="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",sN=new Uint8Array(62);for(let $=0;$<62;$++)sN[$]=At6.charCodeAt($);var Tt6=218340105584896;function Rt6(){let $=Math.floor(Math.random()*Tt6),Z=$%62,X=sN[Z];$=($-Z)/62,Z=$%62;let Q=sN[Z];$=($-Z)/62,Z=$%62;let Y=sN[Z];$=($-Z)/62,Z=$%62;let G=sN[Z];$=($-Z)/62,Z=$%62;let J=sN[Z];$=($-Z)/62,Z=$%62;let K=sN[Z];$=($-Z)/62,Z=$%62;let W=sN[Z];$=($-Z)/62;let H=sN[$];return String.fromCharCode(X,Q,Y,G,J,K,W,H)}});var wr1=_((Br1)=>{Object.defineProperty(Br1,"__esModule",{value:!0});Br1.nuid=Br1.NuidImpl=void 0;var ut6="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",iB=62,kZ0=12,Ur1=10,Hr1=33,ct6=333,Nr1=kZ0+Ur1,mi0=new Uint8Array(iB);for(let $=0;$<iB;$++)mi0[$]=ut6.charCodeAt($);var VZ0=4294967296,Fr1=BigInt(iB)**BigInt(Ur1),fi=Number(Fr1/(1n<<32n)),di0=Number(Fr1%(1n<<32n));function lt6($){for(let Z=0;Z<$.length;Z++)$[Z]=Math.floor(Math.random()*256)}function dt6($){if(globalThis?.crypto?.getRandomValues)globalThis.crypto.getRandomValues($);else lt6($)}class ii0{buf;cbuf;seqHi;seqLo;inc;inited;constructor(){this.buf=new Uint8Array(Nr1),this.cbuf=new Uint8Array(kZ0),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){let $=0;do this.seqHi=Math.floor(Math.random()*(fi+1)),this.seqLo=Math.floor(Math.random()*VZ0);while($++<8&&this.seqHi===fi&&this.seqLo>=di0);if(this.seqHi===fi&&this.seqLo>=di0)this.seqLo=0;this.inc=Math.random()*(ct6-Hr1)+Hr1|0}setPre(){dt6(this.cbuf);for(let $=0;$<kZ0;$++)this.buf[$]=mi0[this.cbuf[$]%iB]}fillSeq(){let $=this.seqHi,Z=this.seqLo;for(let X=Nr1-1;X>=kZ0;X--){let Q=Math.floor($/iB),G=($-Q*iB)*VZ0+Z,J=Math.floor(G/iB),K=G-J*iB;this.buf[X]=mi0[K],$=Q,Z=J}}next(){if(!this.inited)this.init();if(this.seqLo+=this.inc,this.seqLo>=VZ0)this.seqLo-=VZ0,this.seqHi+=1;if(this.seqHi>fi||this.seqHi===fi&&this.seqLo>=di0)this.setPre(),this.initSeqAndInc();this.fillSeq();let $=this.buf;return String.fromCharCode($[0],$[1],$[2],$[3],$[4],$[5],$[6],$[7],$[8],$[9],$[10],$[11],$[12],$[13],$[14],$[15],$[16],$[17],$[18],$[19],$[20],$[21])}reset(){this.init()}}Br1.NuidImpl=ii0;Br1.nuid=new ii0});var zr1=_((Dr1)=>{Object.defineProperty(Dr1,"__esModule",{value:!0});Dr1.nuid=Dr1.Nuid=void 0;var Lr1=wr1();Dr1.Nuid=Lr1.NuidImpl;Dr1.nuid=Lr1.nuid});var CZ0=_((SZ0)=>{Object.defineProperty(SZ0,"__esModule",{value:!0});SZ0.nuid=SZ0.Nuid=void 0;var jr1=zr1();Object.defineProperty(SZ0,"Nuid",{enumerable:!0,get:function(){return jr1.Nuid}});Object.defineProperty(SZ0,"nuid",{enumerable:!0,get:function(){return jr1.nuid}})});var nB=_((Pr1)=>{Object.defineProperty(Pr1,"__esModule",{value:!0});Pr1.DEFAULT_HOST=Pr1.DEFAULT_PORT=Pr1.Match=void 0;Pr1.syncIterator=ot6;Pr1.createInbox=rt6;var pt6=CZ0(),tt6=$G();Pr1.Match={Exact:"exact",CanonicalMIME:"canonical",IgnoreCase:"insensitive"};function ot6($){let Z=$[Symbol.asyncIterator]();return{async next(){let X=await Z.next();if(X.done)return Promise.resolve(null);return Promise.resolve(X.value)}}}function rt6($=""){if($=$||"_INBOX",typeof $!=="string")throw TypeError("prefix must be a string");return $.split(".").forEach((Z)=>{if(Z==="*"||Z===">")throw tt6.InvalidArgumentError.format("prefix",`cannot have wildcards ('${$}')`)}),`${$}.${pt6.nuid.next()}`}Pr1.DEFAULT_PORT=4222;Pr1.DEFAULT_HOST="127.0.0.1"});var bi=_((Ir1)=>{Object.defineProperty(Ir1,"__esModule",{value:!0});Ir1.DataBuffer=void 0;var Tr1=eY();class Rr1{buffers;byteLength;constructor(){this.buffers=[],this.byteLength=0}static concat(...$){let Z=0;for(let Y=0;Y<$.length;Y++)Z+=$[Y].length;let X=new Uint8Array(Z),Q=0;for(let Y=0;Y<$.length;Y++)X.set($[Y],Q),Q+=$[Y].length;return X}static fromAscii($){if(!$)$="";return Tr1.TE.encode($)}static toAscii($){return Tr1.TD.decode($)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){let $=new Uint8Array(this.byteLength),Z=0;for(let X=0;X<this.buffers.length;X++)$.set(this.buffers[X],Z),Z+=this.buffers[X].length;this.buffers.length=0,this.buffers.push($)}}shift(){if(this.buffers.length){let $=this.buffers.shift();if($)return this.byteLength-=$.length,$}return new Uint8Array(0)}drain($){if(this.buffers.length){this.pack();let Z=this.buffers.pop();if(Z){let X=this.byteLength;if($===void 0||$>X)$=X;let Q=Z.subarray(0,$);if(X>$)this.buffers.push(Z.subarray($));return this.byteLength=X-$,Q}}return new Uint8Array(0)}fill($,...Z){if($)this.buffers.push($),this.byteLength+=$.length;for(let X=0;X<Z.length;X++)if(Z[X]&&Z[X].length)this.buffers.push(Z[X]),this.byteLength+=Z[X].length}peek(){if(this.buffers.length)return this.pack(),this.buffers[0];return new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}Ir1.DataBuffer=Rr1});var TE=_((Vr1)=>{Object.defineProperty(Vr1,"__esModule",{value:!0});Vr1.LF=Vr1.CR=Vr1.CRLF=Vr1.CR_LF_LEN=Vr1.CR_LF=void 0;Vr1.setTransportFactory=Yo6;Vr1.defaultPort=Go6;Vr1.getUrlParseFn=Jo6;Vr1.newTransport=Ko6;Vr1.getResolveFn=Wo6;Vr1.protoLen=Mr1;Vr1.extractProtocolMessage=Ho6;var Zo6=eY(),Xo6=nB(),Qo6=bi(),ZG;function Yo6($){ZG=$}function Go6(){return ZG!==void 0&&ZG.defaultPort!==void 0?ZG.defaultPort:Xo6.DEFAULT_PORT}function Jo6(){return ZG!==void 0&&ZG.urlParseFn?ZG.urlParseFn:void 0}function Ko6(){if(!ZG||typeof ZG.factory!=="function")throw Error("transport fn is not set");return ZG.factory()}function Wo6(){return ZG!==void 0&&ZG.dnsResolveFn?ZG.dnsResolveFn:void 0}Vr1.CR_LF=`\r
1375
1375
  `;Vr1.CR_LF_LEN=Vr1.CR_LF.length;Vr1.CRLF=Qo6.DataBuffer.fromAscii(Vr1.CR_LF);Vr1.CR=new Uint8Array(Vr1.CRLF)[0];Vr1.LF=new Uint8Array(Vr1.CRLF)[1];function Mr1($){for(let Z=0;Z<$.length;Z++){let X=Z+1;if($.byteLength>X&&$[Z]===Vr1.CR&&$[X]===Vr1.LF)return X+1}return 0}function Ho6($){let Z=Mr1($);if(Z>0){let Q=new Uint8Array($).slice(0,Z);return Zo6.TD.decode(Q)}return""}});var ri0=_((br1)=>{Object.defineProperty(br1,"__esModule",{value:!0});br1.ipV4=vr1;br1.isIP=jo6;br1.parseIP=xr1;var yi=4,RE=16,_Z0=48,_r1=57,Sr1=65,Eo6=70,Cr1=97,zo6=102,oi0=16777215;function vr1($,Z,X,Q){let Y=new Uint8Array(RE);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((J,K)=>{Y[K]=J}),Y[12]=$,Y[13]=Z,Y[14]=X,Y[15]=Q,Y}function jo6($){return xr1($)!==void 0}function xr1($){for(let Z=0;Z<$.length;Z++)switch($[Z]){case".":return fr1($);case":":return Po6($)}return}function fr1($){let Z=new Uint8Array(yi);for(let X=0;X<yi;X++){if($.length===0)return;if(X>0){if($[0]!==".")return;$=$.substring(1)}let{n:Q,c:Y,ok:G}=Ao6($);if(!G||Q>255)return;$=$.substring(Y),Z[X]=Q}return vr1(Z[0],Z[1],Z[2],Z[3])}function Po6($){let Z=new Uint8Array(RE),X=-1;if($.length>=2&&$[0]===":"&&$[1]===":"){if(X=0,$=$.substring(2),$.length===0)return Z}let Q=0;while(Q<RE){let{n:Y,c:G,ok:J}=To6($);if(!J||Y>65535)return;if(G<$.length&&$[G]==="."){if(X<0&&Q!=RE-yi)return;if(Q+yi>RE)return;let K=fr1($);if(K===void 0)return;Z[Q]=K[12],Z[Q+1]=K[13],Z[Q+2]=K[14],Z[Q+3]=K[15],$="",Q+=yi;break}if(Z[Q]=Y>>8,Z[Q+1]=Y,Q+=2,$=$.substring(G),$.length===0)break;if($[0]!==":"||$.length==1)return;if($=$.substring(1),$[0]===":"){if(X>=0)return;if(X=Q,$=$.substring(1),$.length===0)break}}if($.length!==0)return;if(Q<RE){if(X<0)return;let Y=RE-Q;for(let G=Q-1;G>=X;G--)Z[G+Y]=Z[G];for(let G=X+Y-1;G>=X;G--)Z[G]=0}else if(X>=0)return;return Z}function Ao6($){let Z=0,X=0;for(Z=0;Z<$.length&&_Z0<=$.charCodeAt(Z)&&$.charCodeAt(Z)<=_r1;Z++)if(X=X*10+($.charCodeAt(Z)-_Z0),X>=oi0)return{n:oi0,c:Z,ok:!1};if(Z===0)return{n:0,c:0,ok:!1};return{n:X,c:Z,ok:!0}}function To6($){let Z=0,X=0;for(X=0;X<$.length;X++){if(_Z0<=$.charCodeAt(X)&&$.charCodeAt(X)<=_r1)Z*=16,Z+=$.charCodeAt(X)-_Z0;else if(Cr1<=$.charCodeAt(X)&&$.charCodeAt(X)<=zo6)Z*=16,Z+=$.charCodeAt(X)-Cr1+10;else if(Sr1<=$.charCodeAt(X)&&$.charCodeAt(X)<=Eo6)Z*=16,Z+=$.charCodeAt(X)-Sr1+10;else break;if(Z>=oi0)return{n:0,c:X,ok:!1}}if(X===0)return{n:0,c:X,ok:!1};return{n:Z,c:X,ok:!0}}});var Xn0=_((gr1)=>{Object.defineProperty(gr1,"__esModule",{value:!0});gr1.Servers=gr1.ServerImpl=void 0;gr1.isIPV4OrHostname=yr1;gr1.hostPort=Zn0;var ai0=TE(),si0=xJ(),ei0=ri0(),Mo6=nB(),Vo6=$G();function yr1($){if($.indexOf("[")!==-1||$.indexOf("::")!==-1)return!1;if($.indexOf(".")!==-1)return!0;if($.split(":").length<=2)return!0;return!1}function $n0($){return!yr1($)}function ko6($){let X=$.toUpperCase().indexOf("::FFFF:");if(X!==-1&&$.indexOf(".")!==-1){let Q=$.substring(X+7);return Q=Q.replace("[",""),Q.replace("]","")}return $}function Zn0($){if($=$.trim(),$.match(/^(.*:\/\/)(.*)/m))$=$.replace(/^(.*:\/\/)(.*)/gm,"$2");if($=ko6($),$n0($)&&$.indexOf("[")===-1)$=`[${$}]`;let Z=$n0($)?$.match(/(]:)(\d+)/):$.match(/(:)(\d+)/),X=Z&&Z.length===3&&Z[1]&&Z[2]?parseInt(Z[2]):Mo6.DEFAULT_PORT,Y=new URL(`${X===80?"https":"http"}://${$}`);Y.port=`${X}`;let G=Y.hostname;if(G.charAt(0)==="[")G=G.substring(1,G.length-1);return{listen:Y.host,hostname:G,port:X}}class mb{src;listen;hostname;port;didConnect;reconnects;lastConnect;gossiped;tlsName;resolves;constructor($,Z=!1){this.src=$,this.tlsName="";let X=Zn0($);this.listen=X.listen,this.hostname=X.hostname,this.port=X.port,this.didConnect=!1,this.reconnects=0,this.lastConnect=0,this.gossiped=Z}toString(){return this.listen}async resolve($){if(!$.fn||$.resolve===!1)return[this];let Z=[];if((0,ei0.isIP)(this.hostname))return[this];else{let X=await $.fn(this.hostname);if($.debug)console.log(`resolve ${this.hostname} = ${X.join(",")}`);for(let Q of X){let Y=this.port===80?"https":"http",G=new URL(`${Y}://${$n0(Q)?"["+Q+"]":Q}`);G.port=`${this.port}`;let J=new mb(G.host,!1);J.tlsName=this.hostname,Z.push(J)}}if($.randomize)(0,si0.shuffle)(Z);return this.resolves=Z,Z}}gr1.ServerImpl=mb;class vZ0{firstSelect;servers;currentServer;tlsName;randomize;constructor($={}){this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=$.randomize||!1}setServers($){if(!Array.isArray($)||$.length===0)throw Vo6.InvalidArgumentError.format("servers","cannot be empty");let Z=(0,ai0.getUrlParseFn)(),X=new Map;for(let Y of this.servers)X.set(Y.listen,Y);let Q=[];for(let Y of $){Y=Z?Z(Y):Y;let{listen:G}=Zn0(Y),J=X.get(G);if(J)J.gossiped=!1,Q.push(J);else Q.push(new mb(Y))}if(this.randomize)(0,si0.shuffle)(Q);if(this.servers=Q,this.currentServer===void 0||!Q.includes(this.currentServer))this.currentServer=Q[0],this.firstSelect=!0}clear(){this.servers.length=0}updateTLSName(){let $=this.getCurrentServer();if(!(0,ei0.isIP)($.hostname))this.tlsName=$.hostname,this.servers.forEach((Z)=>{if(Z.gossiped)Z.tlsName=this.tlsName})}getCurrentServer(){return this.currentServer}addServer($,Z=!1){let X=(0,ai0.getUrlParseFn)();$=X?X($):$;let Q=new mb($,Z);if((0,ei0.isIP)(Q.hostname))Q.tlsName=this.tlsName;this.servers.push(Q)}selectServer(){if(this.firstSelect)return this.firstSelect=!1,this.currentServer;let $=this.servers.shift();if($)this.servers.push($),this.currentServer=$;return $}removeCurrentServer(){this.removeServer(this.currentServer)}removeServer($){if($){let Z=this.servers.indexOf($);this.servers.splice(Z,1)}}snapshot(){return vZ0.freezeAll(this.servers)}snapshotForHandler(){let $=this.currentServer;if(!$)return this.snapshot();let Z=this.servers.indexOf($);if(Z<=0)return this.snapshot();return vZ0.freezeAll([$,...this.servers.slice(0,Z),...this.servers.slice(Z+1)])}static freezeAll($){return $.map((Z)=>Object.freeze({hostname:Z.hostname,port:Z.port,listen:Z.listen,src:Z.src,tlsName:Z.tlsName,reconnects:Z.reconnects,lastConnect:Z.lastConnect,gossiped:Z.gossiped,didConnect:Z.didConnect}))}find($){return this.servers.find((Z)=>Z.listen===$.listen)}setCurrent($){this.currentServer=$}length(){return this.servers.length}next(){return this.servers.length?this.servers[0]:void 0}getServers(){return this.servers}update($,Z){let X=[],Q=[],Y=(0,ai0.getUrlParseFn)(),G=new Map;if($.connect_urls&&$.connect_urls.length>0)$.connect_urls.forEach((K)=>{K=Y?Y(K,Z):K;let W=new mb(K,!0);G.set(K,W)});let J=[];if(this.servers.forEach((K,W)=>{let H=K.listen;if(K.gossiped&&this.currentServer.listen!==H&&G.get(H)===void 0)J.push(W);G.delete(H)}),J.reverse(),J.forEach((K)=>{let W=this.servers.splice(K,1);Q=Q.concat(W[0].listen)}),G.forEach((K,W)=>{this.servers.push(K),X.push(W)}),this.randomize&&X.length>0){let K=this.currentServer,W=this.servers.filter((H)=>H!==K);(0,si0.shuffle)(W),this.servers=K?[K,...W]:W}return{added:X,deleted:Q}}}gr1.Servers=vZ0});var xZ0=_((lr1)=>{Object.defineProperty(lr1,"__esModule",{value:!0});lr1.QueuedIteratorImpl=void 0;var Qn0=xJ(),ur1=$G();class cr1{inflight;processed;received;noIterator;iterClosed;done;signal;yields;filtered;pendingFiltered;ctx;_data;err;time;profile;yielding;didBreak;constructor(){this.inflight=0,this.filtered=0,this.pendingFiltered=0,this.processed=0,this.received=0,this.noIterator=!1,this.done=!1,this.signal=(0,Qn0.deferred)(),this.yields=[],this.iterClosed=(0,Qn0.deferred)(),this.time=0,this.yielding=!1,this.didBreak=!1,this.profile=!1}[Symbol.asyncIterator](){return this.iterate()}push($){if(this.done)return;if(this.didBreak){if(typeof $==="function"){let Z=$;try{Z()}catch(X){}}return}if(typeof $==="function")this.pendingFiltered++;this.yields.push($),this.signal.resolve()}async*iterate(){if(this.noIterator)throw new ur1.InvalidOperationError("iterator cannot be used when a callback is registered");if(this.yielding)throw new ur1.InvalidOperationError("iterator is already yielding");this.yielding=!0;try{while(!0){if(this.yields.length===0)await this.signal;if(this.err)throw this.err;let $=this.yields;this.inflight=$.length,this.yields=[];for(let Z=0;Z<$.length;Z++){if(typeof $[Z]==="function"){this.pendingFiltered--;let Q=$[Z];try{Q()}catch(Y){throw Y}if(this.err)throw this.err;continue}this.processed++,this.inflight--;let X=this.profile?Date.now():0;yield $[Z],this.time=this.profile?Date.now()-X:0}if(this.done)break;else if(this.yields.length===0)$.length=0,this.yields=$,this.signal=(0,Qn0.deferred)()}}finally{this.didBreak=!0,this.stop()}}stop($){if(this.done)return;this.err=$,this.done=!0,this.signal.resolve(),this.iterClosed.resolve($)}getProcessed(){return this.noIterator?this.received:this.processed}getPending(){return this.yields.length+this.inflight-this.pendingFiltered}getReceived(){return this.received-this.filtered}}lr1.QueuedIteratorImpl=cr1});var Yn0=_((nr1)=>{Object.defineProperty(nr1,"__esModule",{value:!0});nr1.MuxSubscription=void 0;var vo6=nB(),mr1=$G();class ir1{baseInbox;reqs;constructor(){this.reqs=new Map}size(){return this.reqs.size}init($){return this.baseInbox=`${(0,vo6.createInbox)($)}.`,this.baseInbox}add($){if(!isNaN($.received))$.received=0;this.reqs.set($.token,$)}get($){return this.reqs.get($)}cancel($){this.reqs.delete($.token)}getToken($){let Z=$.subject||"";if(Z.indexOf(this.baseInbox)===0)return Z.substring(this.baseInbox.length);return null}all(){return Array.from(this.reqs.values())}handleError($,Z){if($)return this.all().forEach((X)=>{X.resolver(Z,{})}),!0;if(Z.operation==="publish"){let X=this.all().find((Q)=>{return Q.requestSubject===Z.subject});if(X)return X.resolver(Z,{}),!0}return!1}dispatcher(){return($,Z)=>{let X=this.getToken(Z);if(X){let Q=this.get(X);if(Q){if($===null)$=Z?.data?.length===0&&Z.headers?.code===503?new mr1.NoRespondersError(Q.requestSubject):null;Q.resolver($,Z)}}}}close(){let $=new mr1.RequestError("connection closed");this.reqs.forEach((Z)=>{Z.resolver($,{})})}}nr1.MuxSubscription=ir1});var Gn0=_((or1)=>{Object.defineProperty(or1,"__esModule",{value:!0});or1.Heartbeat=void 0;var xo6=xJ();class tr1{ph;interval;maxOut;timer;pendings;constructor($,Z,X){this.ph=$,this.interval=Z,this.maxOut=X,this.pendings=[]}start(){this.cancel(),this._schedule()}cancel($){if(this.timer)clearTimeout(this.timer),this.timer=void 0;if(this._reset(),$)this.ph.disconnect()}_schedule(){this.timer=setTimeout(()=>{if(this.ph.dispatchStatus({type:"ping",pendingPings:this.pendings.length+1}),this.pendings.length===this.maxOut){this.cancel(!0);return}let $=(0,xo6.deferred)();this.ph.flush($).then(()=>{this._reset()}).catch(()=>{this.cancel()}),this.pendings.push($),this._schedule()},this.interval)}_reset(){this.pendings=this.pendings.filter(($)=>{return $.resolve(),!1})}}or1.Heartbeat=tr1});var Wn0=_(($a1)=>{Object.defineProperty($a1,"__esModule",{value:!0});$a1.DenoBuffer=$a1.MAX_SIZE=$a1.AssertionError=void 0;$a1.assert=sr1;$a1.concat=er1;$a1.append=bo6;$a1.readAll=yo6;$a1.writeAll=go6;var fo6=eY();class Jn0 extends Error{constructor($){super($);this.name="AssertionError"}}$a1.AssertionError=Jn0;function sr1($,Z="Assertion failed."){if(!$)throw new Jn0(Z)}var ar1=32768;$a1.MAX_SIZE=4294967294;function fZ0($,Z,X=0){let Q=Z.byteLength-X;if($.byteLength>Q)$=$.subarray(0,Q);return Z.set($,X),$.byteLength}function er1($,Z){if($===void 0&&Z===void 0)return new Uint8Array(0);if($===void 0)return Z;if(Z===void 0)return $;let X=new Uint8Array($.length+Z.length);return X.set($,0),X.set(Z,$.length),X}function bo6($,Z){return er1($,Uint8Array.of(Z))}class Kn0{_buf;_off;constructor($){if(this._off=0,$==null){this._buf=new Uint8Array(0);return}this._buf=new Uint8Array($)}bytes($={copy:!0}){if($.copy===!1)return this._buf.subarray(this._off);return this._buf.slice(this._off)}empty(){return this._buf.byteLength<=this._off}get length(){return this._buf.byteLength-this._off}get capacity(){return this._buf.buffer.byteLength}truncate($){if($===0){this.reset();return}if($<0||$>this.length)throw Error("bytes.Buffer: truncation out of range");this._reslice(this._off+$)}reset(){this._reslice(0),this._off=0}_tryGrowByReslice($){let Z=this._buf.byteLength;if($<=this.capacity-Z)return this._reslice(Z+$),Z;return-1}_reslice($){sr1($<=this._buf.buffer.byteLength),this._buf=new Uint8Array(this._buf.buffer,0,$)}readByte(){let $=new Uint8Array(1);if(this.read($))return $[0];return null}read($){if(this.empty()){if(this.reset(),$.byteLength===0)return 0;return null}let Z=fZ0(this._buf.subarray(this._off),$);return this._off+=Z,Z}writeByte($){return this.write(Uint8Array.of($))}writeString($){return this.write(fo6.TE.encode($))}write($){let Z=this._grow($.byteLength);return fZ0($,this._buf,Z)}_grow($){let Z=this.length;if(Z===0&&this._off!==0)this.reset();let X=this._tryGrowByReslice($);if(X>=0)return X;let Q=this.capacity;if($<=Math.floor(Q/2)-Z)fZ0(this._buf.subarray(this._off),this._buf);else if(Q+$>$a1.MAX_SIZE)throw Error("The buffer cannot be grown beyond the maximum size.");else{let Y=new Uint8Array(Math.min(2*Q+$,$a1.MAX_SIZE));fZ0(this._buf.subarray(this._off),Y),this._buf=Y}return this._off=0,this._reslice(Math.min(Z+$,$a1.MAX_SIZE)),Z}grow($){if($<0)throw Error("Buffer._grow: negative count");let Z=this._grow($);this._reslice(Z)}readFrom($){let Z=0,X=new Uint8Array(ar1);while(!0){let Q=this.capacity-this.length<ar1,Y=Q?X:new Uint8Array(this._buf.buffer,this.length),G=$.read(Y);if(G===null)return Z;if(Q)this.write(Y.subarray(0,G));else this._reslice(this.length+G);Z+=G}}}$a1.DenoBuffer=Kn0;function yo6($){let Z=new Kn0;return Z.readFrom($),Z.bytes()}function go6($,Z){let X=0;while(X<Z.length)X+=$.write(Z.subarray(X))}});var Un0=_((Ga1)=>{Object.defineProperty(Ga1,"__esModule",{value:!0});Ga1.cc=Ga1.State=Ga1.Parser=Ga1.Kind=void 0;Ga1.describe=io6;var Hn0=Wn0(),Nn0=eY();Ga1.Kind={OK:0,ERR:1,MSG:2,INFO:3,PING:4,PONG:5};function io6($){let Z,X="";switch($.kind){case Ga1.Kind.MSG:Z="MSG";break;case Ga1.Kind.OK:Z="OK";break;case Ga1.Kind.ERR:Z="ERR",X=Nn0.TD.decode($.data);break;case Ga1.Kind.PING:Z="PING";break;case Ga1.Kind.PONG:Z="PONG";break;case Ga1.Kind.INFO:Z="INFO",X=Nn0.TD.decode($.data)}return`${Z}: ${X}`}function Xa1(){let $={};return $.sid=-1,$.hdr=-1,$.size=-1,$}var Qa1=48,no6=57,ib=67108864;class Ya1{dispatcher;state;as;drop;hdr;ma;argBuf;msgBuf;constructor($){this.dispatcher=$,this.state=Ga1.State.OP_START,this.as=0,this.drop=0,this.hdr=0}parse($){let Z;for(Z=0;Z<$.length;Z++){let X=$[Z];switch(this.state){case Ga1.State.OP_START:switch(X){case Ga1.cc.M:case Ga1.cc.m:this.state=Ga1.State.OP_M,this.hdr=-1,this.ma=Xa1();break;case Ga1.cc.H:case Ga1.cc.h:this.state=Ga1.State.OP_H,this.hdr=0,this.ma=Xa1();break;case Ga1.cc.P:case Ga1.cc.p:this.state=Ga1.State.OP_P;break;case Ga1.cc.PLUS:this.state=Ga1.State.OP_PLUS;break;case Ga1.cc.MINUS:this.state=Ga1.State.OP_MINUS;break;case Ga1.cc.I:case Ga1.cc.i:this.state=Ga1.State.OP_I;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_H:switch(X){case Ga1.cc.M:case Ga1.cc.m:this.state=Ga1.State.OP_M;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_M:switch(X){case Ga1.cc.S:case Ga1.cc.s:this.state=Ga1.State.OP_MS;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_MS:switch(X){case Ga1.cc.G:case Ga1.cc.g:this.state=Ga1.State.OP_MSG;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_MSG:switch(X){case Ga1.cc.SPACE:case Ga1.cc.TAB:this.state=Ga1.State.OP_MSG_SPC;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_MSG_SPC:switch(X){case Ga1.cc.SPACE:case Ga1.cc.TAB:continue;default:this.state=Ga1.State.MSG_ARG,this.as=Z}break;case Ga1.State.MSG_ARG:switch(X){case Ga1.cc.CR:this.drop=1;break;case Ga1.cc.NL:{let Q=this.argBuf?this.argBuf.bytes():$.subarray(this.as,Z-this.drop);this.processMsgArgs(Q),this.drop=0,this.as=Z+1,this.state=Ga1.State.MSG_PAYLOAD,Z=this.as+this.ma.size-1;break}default:if(this.argBuf)this.argBuf.writeByte(X)}break;case Ga1.State.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){let Q=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:Ga1.Kind.MSG,msg:this.ma,data:Q}),this.argBuf=void 0,this.msgBuf=void 0,this.state=Ga1.State.MSG_END}else{let Q=this.ma.size-this.msgBuf.length,Y=$.length-Z;if(Y<Q)Q=Y;if(Q>0)this.msgBuf.write($.subarray(Z,Z+Q)),Z=Z+Q-1;else this.msgBuf.writeByte(X)}else if(Z-this.as>=this.ma.size)this.dispatcher.push({kind:Ga1.Kind.MSG,msg:this.ma,data:$.subarray(this.as,Z)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=Ga1.State.MSG_END;break;case Ga1.State.MSG_END:switch(X){case Ga1.cc.NL:this.drop=0,this.as=Z+1,this.state=Ga1.State.OP_START;break;default:continue}break;case Ga1.State.OP_PLUS:switch(X){case Ga1.cc.O:case Ga1.cc.o:this.state=Ga1.State.OP_PLUS_O;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_PLUS_O:switch(X){case Ga1.cc.K:case Ga1.cc.k:this.state=Ga1.State.OP_PLUS_OK;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_PLUS_OK:switch(X){case Ga1.cc.NL:this.dispatcher.push({kind:Ga1.Kind.OK}),this.drop=0,this.state=Ga1.State.OP_START;break}break;case Ga1.State.OP_MINUS:switch(X){case Ga1.cc.E:case Ga1.cc.e:this.state=Ga1.State.OP_MINUS_E;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_MINUS_E:switch(X){case Ga1.cc.R:case Ga1.cc.r:this.state=Ga1.State.OP_MINUS_ER;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_MINUS_ER:switch(X){case Ga1.cc.R:case Ga1.cc.r:this.state=Ga1.State.OP_MINUS_ERR;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_MINUS_ERR:switch(X){case Ga1.cc.SPACE:case Ga1.cc.TAB:this.state=Ga1.State.OP_MINUS_ERR_SPC;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_MINUS_ERR_SPC:switch(X){case Ga1.cc.SPACE:case Ga1.cc.TAB:continue;default:this.state=Ga1.State.MINUS_ERR_ARG,this.as=Z}break;case Ga1.State.MINUS_ERR_ARG:switch(X){case Ga1.cc.CR:this.drop=1;break;case Ga1.cc.NL:{let Q;if(this.argBuf)Q=this.argBuf.bytes(),this.argBuf=void 0;else Q=$.subarray(this.as,Z-this.drop);this.dispatcher.push({kind:Ga1.Kind.ERR,data:Q}),this.drop=0,this.as=Z+1,this.state=Ga1.State.OP_START;break}default:if(this.argBuf)this.argBuf.write(Uint8Array.of(X))}break;case Ga1.State.OP_P:switch(X){case Ga1.cc.I:case Ga1.cc.i:this.state=Ga1.State.OP_PI;break;case Ga1.cc.O:case Ga1.cc.o:this.state=Ga1.State.OP_PO;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_PO:switch(X){case Ga1.cc.N:case Ga1.cc.n:this.state=Ga1.State.OP_PON;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_PON:switch(X){case Ga1.cc.G:case Ga1.cc.g:this.state=Ga1.State.OP_PONG;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_PONG:switch(X){case Ga1.cc.NL:this.dispatcher.push({kind:Ga1.Kind.PONG}),this.drop=0,this.state=Ga1.State.OP_START;break}break;case Ga1.State.OP_PI:switch(X){case Ga1.cc.N:case Ga1.cc.n:this.state=Ga1.State.OP_PIN;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_PIN:switch(X){case Ga1.cc.G:case Ga1.cc.g:this.state=Ga1.State.OP_PING;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_PING:switch(X){case Ga1.cc.NL:this.dispatcher.push({kind:Ga1.Kind.PING}),this.drop=0,this.state=Ga1.State.OP_START;break}break;case Ga1.State.OP_I:switch(X){case Ga1.cc.N:case Ga1.cc.n:this.state=Ga1.State.OP_IN;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_IN:switch(X){case Ga1.cc.F:case Ga1.cc.f:this.state=Ga1.State.OP_INF;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_INF:switch(X){case Ga1.cc.O:case Ga1.cc.o:this.state=Ga1.State.OP_INFO;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_INFO:switch(X){case Ga1.cc.SPACE:case Ga1.cc.TAB:this.state=Ga1.State.OP_INFO_SPC;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_INFO_SPC:switch(X){case Ga1.cc.SPACE:case Ga1.cc.TAB:continue;default:this.state=Ga1.State.INFO_ARG,this.as=Z}break;case Ga1.State.INFO_ARG:switch(X){case Ga1.cc.CR:this.drop=1;break;case Ga1.cc.NL:{let Q;if(this.argBuf)Q=this.argBuf.bytes(),this.argBuf=void 0;else Q=$.subarray(this.as,Z-this.drop);this.dispatcher.push({kind:Ga1.Kind.INFO,data:Q}),this.drop=0,this.as=Z+1,this.state=Ga1.State.OP_START;break}default:if(this.argBuf)this.argBuf.writeByte(X)}break;default:throw this.fail($.subarray(Z))}}if((this.state===Ga1.State.MSG_ARG||this.state===Ga1.State.MINUS_ERR_ARG||this.state===Ga1.State.INFO_ARG)&&!this.argBuf)this.argBuf=new Hn0.DenoBuffer($.subarray(this.as,Z-this.drop));if(this.state===Ga1.State.MSG_PAYLOAD&&!this.msgBuf){if(!this.argBuf)this.cloneMsgArg();this.msgBuf=new Hn0.DenoBuffer($.subarray(this.as))}}cloneMsgArg(){let $=this.ma.subject.length,Z=this.ma.reply?this.ma.reply.length:0,X=new Uint8Array($+Z);if(X.set(this.ma.subject),this.ma.reply)X.set(this.ma.reply,$);if(this.argBuf=new Hn0.DenoBuffer(X),this.ma.subject=X.subarray(0,$),this.ma.reply)this.ma.reply=X.subarray($)}processMsgArgs($){if(this.hdr>=0)return this.processHeaderMsgArgs($);let Z=[],X=-1;for(let Q=0;Q<$.length;Q++)switch($[Q]){case Ga1.cc.SPACE:case Ga1.cc.TAB:case Ga1.cc.CR:case Ga1.cc.NL:if(X>=0)Z.push($.subarray(X,Q)),X=-1;break;default:if(X<0)X=Q}if(X>=0)Z.push($.subarray(X));switch(Z.length){case 3:this.ma.subject=Z[0],this.ma.sid=this.protoParseInt(Z[1]),this.ma.reply=void 0,this.ma.size=this.protoParseInt(Z[2],ib);break;case 4:this.ma.subject=Z[0],this.ma.sid=this.protoParseInt(Z[1]),this.ma.reply=Z[2],this.ma.size=this.protoParseInt(Z[3],ib);break;default:throw this.fail($,"processMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail($,"processMsgArgs Bad or Missing Sid Error");if(this.ma.size<0)throw this.fail($,"processMsgArgs Bad or Missing Size Error")}fail($,Z=""){if(!Z)Z=`parse error [${this.state}]`;else Z=`${Z} [${this.state}]`;return Error(`${Z}: ${Nn0.TD.decode($)}`)}processHeaderMsgArgs($){let Z=[],X=-1;for(let Q=0;Q<$.length;Q++)switch($[Q]){case Ga1.cc.SPACE:case Ga1.cc.TAB:case Ga1.cc.CR:case Ga1.cc.NL:if(X>=0)Z.push($.subarray(X,Q)),X=-1;break;default:if(X<0)X=Q}if(X>=0)Z.push($.subarray(X));switch(Z.length){case 4:this.ma.subject=Z[0],this.ma.sid=this.protoParseInt(Z[1]),this.ma.reply=void 0,this.ma.hdr=this.protoParseInt(Z[2],ib),this.ma.size=this.protoParseInt(Z[3],ib);break;case 5:this.ma.subject=Z[0],this.ma.sid=this.protoParseInt(Z[1]),this.ma.reply=Z[2],this.ma.hdr=this.protoParseInt(Z[3],ib),this.ma.size=this.protoParseInt(Z[4],ib);break;default:throw this.fail($,"processHeaderMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail($,"processHeaderMsgArgs Bad or Missing Sid Error");if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail($,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail($,"processHeaderMsgArgs Bad or Missing Size Error")}protoParseInt($,Z){if($.length===0||$.length>15)return-1;let X=0;for(let Q=0;Q<$.length;Q++){if($[Q]<Qa1||$[Q]>no6)return-1;X=X*10+($[Q]-Qa1)}return Z!==void 0&&X>Z?-1:X}}Ga1.Parser=Ya1;Ga1.State={OP_START:0,OP_PLUS:1,OP_PLUS_O:2,OP_PLUS_OK:3,OP_MINUS:4,OP_MINUS_E:5,OP_MINUS_ER:6,OP_MINUS_ERR:7,OP_MINUS_ERR_SPC:8,MINUS_ERR_ARG:9,OP_M:10,OP_MS:11,OP_MSG:12,OP_MSG_SPC:13,MSG_ARG:14,MSG_PAYLOAD:15,MSG_END:16,OP_H:17,OP_P:18,OP_PI:19,OP_PIN:20,OP_PING:21,OP_PO:22,OP_PON:23,OP_PONG:24,OP_I:25,OP_IN:26,OP_INF:27,OP_INFO:28,OP_INFO_SPC:29,INFO_ARG:30};Ga1.cc={CR:13,E:69,e:101,F:70,f:102,G:71,g:103,H:72,h:104,I:73,i:105,K:75,k:107,M:77,m:109,MINUS:45,N:78,n:110,NL:10,O:79,o:111,P:80,p:112,PLUS:43,R:82,r:114,S:83,s:115,SPACE:32,TAB:9}});var gZ0=_((Ka1)=>{Object.defineProperty(Ka1,"__esModule",{value:!0});Ka1.MsgHdrsImpl=void 0;Ka1.canonicalMIMEHeaderKey=Bn0;Ka1.headers=oo6;var Ja1=eY(),fJ=nB(),yZ0=$G();function Bn0($){let N=!0,U=Array($.length);for(let F=0;F<$.length;F++){let B=$.charCodeAt(F);if(B===58||B<33||B>126)throw yZ0.InvalidArgumentError.format("header",`'${$[F]}' is not a valid character in a header name`);if(N&&97<=B&&B<=122)B-=32;else if(!N&&65<=B&&B<=90)B+=32;U[F]=B,N=B==45}return String.fromCharCode(...U)}function oo6($=0,Z=""){if($===0&&Z!=="")throw yZ0.InvalidArgumentError.format("code","is required");else if($>0&&Z==="")throw yZ0.InvalidArgumentError.format("description","is required");return new nb($,Z)}var Fn0="NATS/1.0";class nb{_code;headers;_description;constructor($=0,Z=""){this._code=$,this._description=Z,this.headers=new Map}[Symbol.iterator](){return this.headers.entries()}size(){return this.headers.size}equals($){if($&&this.headers.size===$.headers.size&&this._code===$._code){for(let[Z,X]of this.headers){let Q=$.values(Z);if(X.length!==Q.length)return!1;let Y=[...X].sort(),G=[...Q].sort();for(let J=0;J<Y.length;J++)if(Y[J]!==G[J])return!1}return!0}return!1}static decode($){let Z=new nb,Q=Ja1.TD.decode($).split(`\r
1376
1376
  `),Y=Q[0];if(Y!==Fn0){let G=Y.replace(Fn0,"").trim();if(G.length>0){if(Z._code=parseInt(G,10),isNaN(Z._code))Z._code=0;let J=Z._code.toString();G=G.replace(J,""),Z._description=G.trim()}}if(Q.length>=1)Q.slice(1).map((G)=>{if(G){let J=G.indexOf(":");if(J>-1){let K=G.slice(0,J),W=G.slice(J+1).trim();Z.append(K,W)}}});return Z}toString(){if(this.headers.size===0&&this._code===0)return"";let $=Fn0;if(this._code>0&&this._description!=="")$+=` ${this._code} ${this._description}`;for(let[Z,X]of this.headers)for(let Q=0;Q<X.length;Q++)$=`${$}\r
1377
1377
  ${Z}: ${X[Q]}`;return`${$}\r
@@ -2365,8 +2365,8 @@ ${X}
2365
2365
  Pass the connectionId of the repo to load.`}async function Wq8($){let{ctx:Z,orgId:X,virtualMcpId:Q,userId:Y,threadId:G,writer:J,rebindFs:K}=$;if(!z3(Q))return null;let W=await Vg4(Z,X);if(W.length===0)return null;let H=new Map(W.map((N)=>[N.connectionId,N]));return m8({description:Sg4(W),inputSchema:W0(Gq8.object({connectionId:Gq8.string().describe("connectionId of the imported repository to load (see the list in this tool's description).")})),execute:async({connectionId:N})=>{let U=H.get(N);if(!U)return{success:!1,error:`No imported repository found for connectionId "${N}". Available: ${W.map((S)=>S.connectionId).join(", ")||"none"}.`};let F=tU(G,U.connectionId),B={url:`https://github.com/${U.owner}/${U.repo}`,owner:U.owner,name:U.repo,installationId:U.installationId,connectionId:U.connectionId},O=await Z.storage.threads.get(G);await Z.storage.threads.update(G,{metadata:{...O?.metadata??{},githubRepo:B},branch:F,updated_by:Y});let{kind:L}=await PQ(Z,{userId:Y,branch:F,virtualMcpMetadata:null}),D=await Qu({virtualMcpId:Q,branch:F,sandboxProviderKind:L},Z),E=Wr(k5(O?.metadata),Y,F,L,D);J.write({type:"data-open-preview",id:G,data:{previewUrl:D.previewUrl??null,branch:F,githubRepo:B,sandboxMap:E,sandboxProviderKind:L}});let z=await Yu(Z,{virtualMcpId:Q,branch:F,userId:Y,threadId:G}),j=Date.now()+Jq8,P="",A=!1,I=0,q=null;while(Date.now()<j){let S=await z.onBash("if git -C /app/repo rev-parse HEAD >/dev/null 2>&1; then echo __CLONED__; fi; ls -A /app/repo 2>/dev/null").then((f)=>({ok:!0,stdout:f.stdout})).catch(()=>({ok:!1,stdout:""}));if(!S.ok){if(++I>=Mg4)break;await z8(Kq8);continue}I=0;let d=kg4(S.stdout);if(d.cloned&&d.listing===q){A=!0,P=d.listing;break}q=d.cloned?d.listing:null,await z8(Kq8)}let M=!1;if(A&&K)try{await K(F),M=!0}catch(S){console.warn("[load_repo] live fs rebind failed",S)}return{success:!0,repo:`${U.owner}/${U.repo}`,previewUrl:D.previewUrl??null,cloned:A,files:P,message:!A?`Loaded ${U.owner}/${U.repo} and opened the Preview, but the clone did not finish within ${Math.round(Jq8/1000)}s. It may still be in progress \u2014 your file tools will use it next message.`:M?`Loaded ${U.owner}/${U.repo} and opened the Preview. The repo is cloned and its dev server is booting. Your file tools (read/write/edit/bash/grep/glob) now operate on it \u2014 you can use it right away.`:`Loaded ${U.owner}/${U.repo} and opened the Preview. The repo is cloned and its dev server is booting. Your file tools operate on it from your next message.`}}})}var Jq8=120000,Kq8=1500,Mg4=5;var KP0=w(()=>{f4();m4();pw();ZY();A6();wQ();dr();VK();JP0()});import{AsyncLocalStorage as Cg4}from"async_hooks";function WP0(){let $=p_.getStore();if(!$)throw Error("This tool is only available on a task run's MCP endpoint (/api/<org>/mcp/task-run/<threadId>).");return $}function Nq8($){return C30.some((X)=>bo($,X))?_g4:Hq8}var p_,Hq8,_g4;var Ju=w(()=>{y9();p_=new Cg4;Hq8=["TASK_ADD_REPO","TASK_BOARD_ITEM_LIST","TASK_BOARD_ITEM_UPDATE","TASK_BOARD_ITEM_PRS_GET","TASK_BOARD_ITEM_PR_LINK","TASK_BOARD_ACTIVITY_LIST","TASK_BOARD_COMMENT_LIST","TASK_BOARD_COMMENT_CREATE","TASK_BOARD_COMMENT_UPDATE"],_g4=[...Hq8,"TASK_BOARD_REVIEW_DECISION"]});import{z as y3}from"zod";async function yg4($,Z,X,Q,Y){return j5(async()=>{let G=DH(await sj0($,Z),X,Q,Y);if(!G)throw Error("sandbox record not written yet");return G},{maxAttempts:xg4,minTimeout:fg4,maxTimeout:bg4,jitter:0}).catch(()=>null)}async function Bq8($,Z,X,Q){let Y=await $.proxyDaemonRequest(Z,"/_sandbox/bash",{method:"POST",headers:new Headers({"content-type":"application/json","x-thread-id":X}),body:JSON.stringify({command:Q})});if(!Y.ok)throw Error(`sandbox bash failed (${Y.status} ${Y.statusText})`);let G=await Y.json();return{stdout:G.stdout??"",exitCode:G.exitCode??0}}function hg4($){let Z=$.split(`
2366
2366
  `).map((X)=>X.trim()).filter((X)=>X&&X!==".git"&&X!=="__CLONED__");return{cloned:Z.length>0,listing:Z.join(`
2367
2367
  `)}}async function cg4($,Z){let{items:X}=await $.storage.connections.list(Z,{slug:"mcp-github"});return Gu(X)}var vg4=3300000,xg4=4,fg4=250,bg4=2000,Uq8=180000,Fq8=1500,gg4=5,ug4,U51;var Oq8=w(()=>{p0();KP0();YP0();pw();gh();wQ();VK();f4();Ju();ug4=['token=$(git remote get-url origin | sed -n "s|.*x-access-token:\\([^@]*\\)@.*|\\1|p")','[ -n "$token" ] || exit 0','mkdir -p "${HOME:-/root}/.config/gh"',"umask 077",'printf "github.com:\\n oauth_token: %s\\n git_protocol: https\\n" "$token" > "${HOME:-/root}/.config/gh/hosts.yml"'].join(`
2368
- `);U51=i({name:"TASK_ADD_REPO",description:"Clone one of this organization's repositories into your working directory. "+"Your working directory is EMPTY until you call this \u2014 do not look for "+"files, and do not run git, before it returns. Call it once, with the repository the task is about; it waits for the checkout and returns the repository root listing, so you can start reading files immediately after. `git` and `gh` are authenticated once it returns. Call TASK_ADD_REPO with no arguments to list the repositories available.",annotations:{title:"Add Repository",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0},inputSchema:y3.object({connectionId:y3.string().optional().describe("connectionId of the repository to clone. Omit to list the available repositories.")}),outputSchema:y3.object({success:y3.boolean(),repositories:y3.array(y3.object({connectionId:y3.string(),repo:y3.string()})).optional(),repo:y3.string().optional(),cloned:y3.boolean().optional(),files:y3.string().optional(),message:y3.string()}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=X0(Z),Q=E1(Z);if(!Q)throw Error("User ID required");let{threadId:Y}=WP0(),G=await cg4(Z,X.id),J=$.connectionId?G.find((q)=>q.connectionId===$.connectionId):void 0;if(!J){let q=G.map((M)=>({connectionId:M.connectionId,repo:`${M.owner}/${M.repo}`}));return{success:!1,repositories:q,message:$.connectionId?`No imported repository for connectionId "${$.connectionId}". Pick one of the repositories listed.`:q.length===0?"This organization has no repositories imported, so none can be cloned.":"Pick a repository and call TASK_ADD_REPO again with its connectionId."}}let K=await Z.storage.threads.get(Y);if(!K)throw Error(`Thread not found: ${Y}`);let W=await aj0(Z,{threadId:Y}),H=await rU(Z,W,Q),{provider:N,kind:U}=await PQ(Z,{userId:H,branch:W,virtualMcpMetadata:null}),F=await yg4(Z,Y,H,W,U);if(!F)throw Error(`No sandbox is registered for this run (thread ${Y}), so there is nowhere to clone into.`);await _w({ctx:Z,connectionId:J.connectionId,organizationId:X.id,forceRefresh:!0,onLegacyMintError:(q)=>console.error("[TASK_ADD_REPO] legacy repo-scoped mint failed",{connectionId:J.connectionId,error:q.message})});let{cloneUrl:B,gitUserName:O,gitUserEmail:L}=await vw(J.connectionId,J.owner,J.repo,Z.db,Z.vault,{bufferMs:vg4});await Z.storage.threads.update(Y,{metadata:{...K.metadata??{},githubRepo:{url:`https://github.com/${J.owner}/${J.repo}`,owner:J.owner,name:J.repo,installationId:J.installationId,connectionId:J.connectionId}},updated_by:Q});let D=QP0({branch:W,derivedRef:oU(W),recordedHeadRef:null,sticky:!1}),E=await N.proxyDaemonRequest(F.sandboxHandle,"/_sandbox/config",{method:"PUT",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify({git:{repository:{cloneUrl:B,branch:D,repoName:`${J.owner}/${J.repo}`},identity:{userName:O,userEmail:L}}})});if(!E.ok)throw Error(`the sandbox rejected the repository (${E.status} ${E.statusText})`);await N.proxyDaemonRequest(F.sandboxHandle,"/_sandbox/setup/clone",{method:"POST",headers:new Headers({"content-type":"application/json"}),body:"{}"}).catch((q)=>{console.warn("[TASK_ADD_REPO] explicit clone kick failed",q)});let z=Date.now()+Uq8,j=!1,P="",A=0,I=null;while(Date.now()<z){let q=await Bq8(N,F.sandboxHandle,Y,"if git rev-parse HEAD >/dev/null 2>&1; then echo __CLONED__; fi; ls -A 2>/dev/null").catch(()=>null);if(!q){if(++A>=gg4)break;await z8(Fq8);continue}A=0;let M=hg4(q.stdout);if(M.cloned&&M.listing===I){j=!0,P=M.listing;break}I=M.cloned?M.listing:null,await z8(Fq8)}if(j)await Bq8(N,F.sandboxHandle,Y,ug4).catch((q)=>console.warn("[TASK_ADD_REPO] gh auth setup failed",q));return{success:j,repo:`${J.owner}/${J.repo}`,cloned:j,files:P,message:j?`${J.owner}/${J.repo} is checked out at your working directory on branch ${D}. \`git\` and \`gh\` are authenticated. Start working.`:`The clone of ${J.owner}/${J.repo} did not finish within ${Math.round(Uq8/1000)}s. It may still be in progress \u2014 check your working directory before calling this again.`}}})});import{z as J8}from"zod";var kK,t_,lg4,dg4,wq8,Ku,mg4,ig4,Lq8;var SK=w(()=>{y9();kK=J8.enum(["triage","todo","in_progress","in_review","done","archived"]),t_=J8.enum(["none","low","medium","high","urgent"]),lg4=J8.object({threadId:J8.string(),virtualMcpId:J8.string().nullable(),status:J8.enum(["in_progress","requires_action","failed","completed","expired"]).nullable(),title:J8.string().nullable(),lastMessage:J8.string().nullable(),hasPreview:J8.boolean(),failureKind:J8.string().nullable(),hasMessages:J8.boolean(),costUsd:J8.number().nullable(),createdAt:J8.string()}),dg4=J8.object({id:J8.string(),name:J8.string(),color:J8.string().nullable().describe('Hex color, e.g. "#3b82f6"'),createdBy:J8.string(),createdAt:J8.string().datetime()}),wq8=J8.object({url:J8.string(),number:J8.number(),repoOwner:J8.string(),repoName:J8.string(),createdAt:J8.string(),title:J8.string().nullable(),body:J8.string().nullable(),state:J8.enum(["open","closed"]).nullable(),draft:J8.boolean().nullable(),merged:J8.boolean().nullable(),mergeable:J8.boolean().nullable(),checksStatus:J8.enum(["pending","passing","failing"]).nullable(),checks:J8.array(J8.object({name:J8.string(),status:J8.string(),conclusion:J8.string().nullable(),detailsUrl:J8.string().nullable(),summary:J8.string().nullable()})),previewUrl:J8.string().nullable()}),Ku=J8.object({id:J8.string(),organizationId:J8.string(),title:J8.string(),description:J8.string().nullable(),status:kK,priority:t_,assigneeId:J8.string().nullable(),assignedBy:J8.string().nullable(),repo:J8.string().nullable(),dueDate:J8.string().datetime().nullable(),sortOrder:J8.number(),threads:J8.array(lg4),tags:J8.array(dg4),createdBy:J8.string(),createdAt:J8.string().datetime(),updatedBy:J8.string(),updatedAt:J8.string().datetime()}),mg4=["created","status_changed","assignee_changed","priority_changed","due_date_changed","title_changed","description_changed","tags_changed","review_requested","review_approved","review_changes_requested","merge_conflict_resolution","merge_failed"],ig4=J8.enum(mg4),Lq8=J8.object({id:J8.string(),taskBoardItemId:J8.string(),action:ig4,actorId:J8.string().nullable(),data:J8.record(J8.string(),J8.unknown()),occurredAt:J8.string().datetime()})});async function HP0($,Z,X){if(X===G4)return;let{members:Q}=await $.boundAuth.organization.listMembers({organizationId:Z,filterField:"userId",filterValue:X});if(!Q.some((Y)=>Y.userId===X))throw Error("assigneeId is not a member of the organization")}var F51=w(()=>{SK()});function zq8($){let Z={};for(let[X,Q]of Object.entries($)){if(X.startsWith(ng4))continue;Z[X]=Q}return Z}function NP0($){return{taskBoardItemId:$.id,...JY($)&&{[Dq8]:Eq8}}}function pg4($){return $?.[Dq8]===Eq8}function tg4($){if(/[:\s]/.test($))throw Error("organization id unsuitable for the subsidy key scheme");return`subsidy:${$}`}async function og4($,Z){let X=o0();try{let Q=await $.storage.subsidizedGatewayKeys.get(Z);if(Q)return Q;let Y=$.auth?.user?.id;if(Y&&X.aiGatewayEnabled&&X.studioProvisionSecretKey&&Qw.provisionKey){let G=await _W(Y,$.auth?.user?.email),J=await Qw.provisionKey(G,tg4(Z));return await $.storage.subsidizedGatewayKeys.put(Z,J),J}}catch(Q){console.error("[subsidized-runs] subsidy key unavailable \u2014 run stays on the org's key:",Q)}return}async function jq8($,Z,X){if(!o0().taskQuotaEnforced)return;if(!pg4(X))return;let Q=X?.taskBoardItemId;if(!Q)return;let Y=await $.storage.taskBoard.getById(Q,Z);if(!Y||!JY(Y))return;if(!await JB8($,Q))return;return await og4($,Z)}function Pq8($,Z){if(!Z)return $;if($.providerId!=="deco")return $;return{...$,apiKey:Z}}var ng4="srv.",Dq8="srv.billing",Eq8="subscription";var mr=w(()=>{SG0();$O();C8();wK()});function FP0($){let Z=$?.runClass;return Z&&Z in B51?B51[Z]:B51.interactive}var B51,UP0="runClass";var ir=w(()=>{B51={interactive:10,reviewer:20,retry:30,new_task:40}});async function O51($,Z,X){let Q;try{return await Promise.race([$.aiProviders.listModels(Z,X),new Promise((G,J)=>{Q=setTimeout(()=>J(Error("listModels timeout")),rg4)})])}finally{if(Q)clearTimeout(Q)}}function ag4($,Z){switch($){case"fast":return Z.chat.fast;case"smart":return Z.chat.smart;case"thinking":return Z.chat.thinking;case"image":return Z.image;case"web_search":return Z.webSearch;case"deep_research":return Z.deepResearch}}function w51($,Z,X){let Q=$.find((Y)=>Y.modelId===Z);return{title:Q?.title??X??Z,providerId:Q?.providerId,capabilities:Q?.capabilities,limits:Q?.limits??null}}async function TX($,Z,X){let Q=$.organization?.id;if(!Q)throw Error("resolveTier called without an organization");let G=(await $.storage.organizationSettings.get(Q))?.simple_mode?.tiers?.[Z]??null,J=$.auth?.user?.id,K=ww.safeParse(Z),W=X?.applyUserPrefs&&K.success&&J?(await $.storage.userModelPreferences.get(J,Q))?.tiers?.[K.data]??null:null,H=(await $.storage.aiProviderKeys.list({organizationId:Q})).filter((O)=>hE(O.providerId));for(let O of[W,G])if(O&&H.some((L)=>L.id===O.keyId)){let L=await O51($,O.keyId,Q).catch(()=>[]);return{credentialId:O.keyId,modelId:O.modelId,modelMeta:w51(L,O.modelId,O.title)}}if(H.length===0)throw new Wu(Z);let N={};await Promise.all(H.map(async(O)=>{N[O.id]=await O51($,O.id,Q).catch(()=>[])}));let U=H.map((O)=>({id:O.id,providerId:O.providerId,label:O.label,presetId:O.presetId,createdBy:O.createdBy,createdAt:O.createdAt})),F=A98(U,N),B=ag4(Z,F);if(!B)throw new Wu(Z);return{credentialId:B.keyId,modelId:B.modelId,modelMeta:w51(N[B.keyId]??[],B.modelId,B.title)}}async function Aq8($,Z,X){let Q=$.organization?.id;if(!Q)throw Error("resolveSpecificModel called without an organization");let Y=await $.storage.aiProviderKeys.findById(Z,Q).catch((J)=>{if(J instanceof Error&&J.message==="Provider key not found")throw new nr(`AI provider credential "${Z}" was not found`,{cause:J});throw J});if(!hE(Y.providerId))throw new nr(`AI provider credential "${Z}" uses native-only provider "${Y.providerId}" and cannot run a hosted model`);let G=await O51($,Z,Q).catch(()=>[]);return{credentialId:Z,modelId:X,modelMeta:w51(G,X)}}async function g3($,Z){try{return await TX($,Z)}catch(X){if(X instanceof Wu)return null;return console.warn(`[resolveTier] tier "${Z}" resolution failed:`,X),null}}var Wu,nr,rg4=5000;var sw=w(()=>{QY();A6();Wu=class Wu extends Error{tier;constructor($){super(`No model available for tier "${$}". Connect a provider or configure the tier in organization settings.`);this.tier=$;this.name="TierUnavailableError"}};nr=class nr extends Error{constructor($,Z){super($,Z);this.name="SpecificModelCredentialUnavailableError"}}});function Tq8($){return $ instanceof RH||typeof $==="object"&&$!==null&&$.permanent===!0}var RH;var L51=w(()=>{RH=class RH extends Error{permanent=!0;code;constructor($,Z){super(Z);this.name="PermanentRunError",this.code=$}}});import{z as pr}from"zod/v4";import{z as V}from"zod/v4";import{z as j1}from"zod/v4";import{z as IZ}from"zod/v4";import{z as u3}from"zod/v4";import{z as d9}from"zod/v4";import{z as m9}from"zod/v4";import{z as S$}from"zod/v4";import{z as C$}from"zod/v4";import{z as CK}from"zod/v4";import{z as G8}from"zod/v4";import{z as i1}from"zod/v4";import{z as o_}from"zod/v4";import{z as j51}from"zod/v4";import{z as P51}from"zod/v4";import{z as tr}from"zod/v4";import{z as h3}from"zod/v4";import{z as k7}from"zod/v4";import{z as m$}from"zod/v4";import{z as IH}from"zod/v4";import{z as qH}from"zod/v4";import{z as MH}from"zod/v4";import{z as r_}from"zod/v4";function Qh4($){var Z;let X=$==null?void 0:$.anthropic;return(Z=X==null?void 0:X.cacheControl)!=null?Z:X==null?void 0:X.cache_control}async function Sh4({tools:$,toolChoice:Z,disableParallelToolUse:X,cacheControlValidator:Q,supportsStructuredOutput:Y,supportsStrictTools:G,defaultEagerInputStreaming:J=!1}){var K,W;$=($==null?void 0:$.length)?$:void 0;let H=[],N=new Set,U=Q||new A51;if($==null)return{tools:void 0,toolChoice:void 0,toolWarnings:H,betas:N};let F=[];for(let O of $)switch(O.type){case"function":{let L=U.getCacheControl(O.providerOptions,{type:"tool definition",canCache:!0}),D=(K=O.providerOptions)==null?void 0:K.anthropic,E=(W=D==null?void 0:D.eagerInputStreaming)!=null?W:J,z=D==null?void 0:D.deferLoading,j=D==null?void 0:D.allowedCallers;if(!G&&O.strict!=null)H.push({type:"unsupported",feature:"strict",details:`Tool '${O.name}' has strict: ${O.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`});if(F.push({name:O.name,description:O.description,input_schema:O.inputSchema,cache_control:L,...E?{eager_input_streaming:!0}:{},...G===!0&&O.strict!=null?{strict:O.strict}:{},...z!=null?{defer_loading:z}:{},...j!=null?{allowed_callers:j}:{},...O.inputExamples!=null?{input_examples:O.inputExamples.map((P)=>P.input)}:{}}),Y===!0)N.add("structured-outputs-2025-11-13");if(O.inputExamples!=null||j!=null)N.add("advanced-tool-use-2025-11-20");break}case"provider":{switch(O.id){case"anthropic.code_execution_20250522":{N.add("code-execution-2025-05-22"),F.push({type:"code_execution_20250522",name:"code_execution",cache_control:void 0});break}case"anthropic.code_execution_20250825":{N.add("code-execution-2025-08-25"),F.push({type:"code_execution_20250825",name:"code_execution"});break}case"anthropic.code_execution_20260120":{F.push({type:"code_execution_20260120",name:"code_execution"});break}case"anthropic.computer_20250124":{N.add("computer-use-2025-01-24"),F.push({name:"computer",type:"computer_20250124",display_width_px:O.args.displayWidthPx,display_height_px:O.args.displayHeightPx,display_number:O.args.displayNumber,cache_control:void 0});break}case"anthropic.computer_20251124":{N.add("computer-use-2025-11-24"),F.push({name:"computer",type:"computer_20251124",display_width_px:O.args.displayWidthPx,display_height_px:O.args.displayHeightPx,display_number:O.args.displayNumber,enable_zoom:O.args.enableZoom,cache_control:void 0});break}case"anthropic.computer_20241022":{N.add("computer-use-2024-10-22"),F.push({name:"computer",type:"computer_20241022",display_width_px:O.args.displayWidthPx,display_height_px:O.args.displayHeightPx,display_number:O.args.displayNumber,cache_control:void 0});break}case"anthropic.text_editor_20250124":{N.add("computer-use-2025-01-24"),F.push({name:"str_replace_editor",type:"text_editor_20250124",cache_control:void 0});break}case"anthropic.text_editor_20241022":{N.add("computer-use-2024-10-22"),F.push({name:"str_replace_editor",type:"text_editor_20241022",cache_control:void 0});break}case"anthropic.text_editor_20250429":{N.add("computer-use-2025-01-24"),F.push({name:"str_replace_based_edit_tool",type:"text_editor_20250429",cache_control:void 0});break}case"anthropic.text_editor_20250728":{let L=await n8({value:O.args,schema:Wh4});F.push({name:"str_replace_based_edit_tool",type:"text_editor_20250728",max_characters:L.maxCharacters,cache_control:void 0});break}case"anthropic.bash_20250124":{N.add("computer-use-2025-01-24"),F.push({name:"bash",type:"bash_20250124",cache_control:void 0});break}case"anthropic.bash_20241022":{N.add("computer-use-2024-10-22"),F.push({name:"bash",type:"bash_20241022",cache_control:void 0});break}case"anthropic.memory_20250818":{N.add("context-management-2025-06-27"),F.push({name:"memory",type:"memory_20250818"});break}case"anthropic.web_fetch_20250910":{N.add("web-fetch-2025-09-10");let L=await n8({value:O.args,schema:qh4});F.push({type:"web_fetch_20250910",name:"web_fetch",max_uses:L.maxUses,allowed_domains:L.allowedDomains,blocked_domains:L.blockedDomains,citations:L.citations,max_content_tokens:L.maxContentTokens,cache_control:void 0});break}case"anthropic.web_fetch_20260209":{N.add("code-execution-web-tools-2026-02-09");let L=await n8({value:O.args,schema:Ph4});F.push({type:"web_fetch_20260209",name:"web_fetch",max_uses:L.maxUses,allowed_domains:L.allowedDomains,blocked_domains:L.blockedDomains,citations:L.citations,max_content_tokens:L.maxContentTokens,cache_control:void 0});break}case"anthropic.web_search_20250305":{let L=await n8({value:O.args,schema:Dh4});F.push({type:"web_search_20250305",name:"web_search",max_uses:L.maxUses,allowed_domains:L.allowedDomains,blocked_domains:L.blockedDomains,user_location:L.userLocation,cache_control:void 0});break}case"anthropic.web_search_20260209":{N.add("code-execution-web-tools-2026-02-09");let L=await n8({value:O.args,schema:Fh4});F.push({type:"web_search_20260209",name:"web_search",max_uses:L.maxUses,allowed_domains:L.allowedDomains,blocked_domains:L.blockedDomains,user_location:L.userLocation,cache_control:void 0});break}case"anthropic.tool_search_regex_20251119":{F.push({type:"tool_search_tool_regex_20251119",name:"tool_search_tool_regex"});break}case"anthropic.tool_search_bm25_20251119":{F.push({type:"tool_search_tool_bm25_20251119",name:"tool_search_tool_bm25"});break}case"anthropic.advisor_20260301":{N.add("advisor-tool-2026-03-01");let L=await n8({value:O.args,schema:Yh4});F.push({type:"advisor_20260301",name:"advisor",model:L.model,...L.maxUses!==void 0&&{max_uses:L.maxUses},...L.caching!==void 0&&{caching:L.caching}});break}default:{H.push({type:"unsupported",feature:`provider-defined tool ${O.id}`});break}}break}default:{H.push({type:"unsupported",feature:`tool ${O}`});break}}if(Z==null)return{tools:F,toolChoice:X?{type:"auto",disable_parallel_tool_use:X}:void 0,toolWarnings:H,betas:N};let B=Z.type;switch(B){case"auto":return{tools:F,toolChoice:{type:"auto",disable_parallel_tool_use:X},toolWarnings:H,betas:N};case"required":return{tools:F,toolChoice:{type:"any",disable_parallel_tool_use:X},toolWarnings:H,betas:N};case"none":return{tools:void 0,toolChoice:void 0,toolWarnings:H,betas:N};case"tool":return{tools:F,toolChoice:{type:"tool",name:Z.toolName,disable_parallel_tool_use:X},toolWarnings:H,betas:N};default:throw new c4({functionality:`tool choice type: ${B}`})}}function Vq8({usage:$,rawUsage:Z}){var X,Q,Y;let G=(X=$.cache_creation_input_tokens)!=null?X:0,J=(Q=$.cache_read_input_tokens)!=null?Q:0,K,W,H=(Y=$.iterations)==null?void 0:Y.some((N)=>N.type==="fallback_message");if($.iterations&&$.iterations.length>0&&!H){let N=$.iterations.filter((U)=>U.type==="compaction"||U.type==="message");if(N.length>0){let U=N.reduce((F,B)=>({input:F.input+B.input_tokens,output:F.output+B.output_tokens}),{input:0,output:0});K=U.input,W=U.output}else K=$.input_tokens,W=$.output_tokens}else K=$.input_tokens,W=$.output_tokens;return{inputTokens:{total:K+G+J,noCache:K,cacheRead:J,cacheWrite:G},outputTokens:{total:W,text:void 0,reasoning:void 0},raw:Z!=null?Z:$}}function dh4($){if(typeof $==="string")return new TextDecoder().decode(g9($));if($ instanceof Uint8Array)return new TextDecoder().decode($);if($ instanceof URL)throw new c4({functionality:"URL-based text documents are not supported for citations"});throw new c4({functionality:`unsupported data type for text documents: ${typeof $}`})}function D51($){return $ instanceof URL||mh4($)}function mh4($){return typeof $==="string"&&/^https?:\/\//i.test($)}function E51($){return $ instanceof URL?$.toString():$}async function kq8($){if(typeof $==="string"){let Z=await $7({text:$});if(Z.success&&typeof Z.value==="object"&&Z.value!==null)return Z.value;return{errorCode:"unavailable"}}if(typeof $==="object"&&$!==null)return $;return{}}async function ih4({prompt:$,sendReasoning:Z,warnings:X,cacheControlValidator:Q,toolNameMapping:Y}){var G,J,K,W,H,N,U,F,B,O,L,D,E,z,j,P,A,I,q,M,S;let d=new Set,f=nh4($),y=Q||new A51,o=void 0,b=[];async function r(E0){var Z0,e;let A0=await J4({provider:"anthropic",providerOptions:E0,schema:Iq8});return(e=(Z0=A0==null?void 0:A0.citations)==null?void 0:Z0.enabled)!=null?e:!1}async function B0(E0){let Z0=await J4({provider:"anthropic",providerOptions:E0,schema:Iq8});return{title:Z0==null?void 0:Z0.title,context:Z0==null?void 0:Z0.context}}for(let E0=0;E0<f.length;E0++){let Z0=f[E0],e=E0===f.length-1,A0=Z0.type;switch(A0){case"system":{let Y0=Z0.messages.map(({content:q0,providerOptions:t0})=>({type:"text",text:q0,cache_control:y.getCacheControl(t0,{type:"system message",canCache:!0})}));if(o==null)o=Y0;else b.push({role:"system",content:Y0}),d.add("mid-conversation-system-2026-04-07");break}case"user":{let Y0=[];for(let q0 of Z0.messages){let{role:t0,content:d0}=q0;switch(t0){case"user":{for(let s0=0;s0<d0.length;s0++){let H0=d0[s0],V0=s0===d0.length-1,S0=(G=y.getCacheControl(H0.providerOptions,{type:"user message part",canCache:!0}))!=null?G:V0?y.getCacheControl(q0.providerOptions,{type:"user message",canCache:!0}):void 0;switch(H0.type){case"text":{Y0.push({type:"text",text:H0.text,cache_control:S0});break}case"file":{if(H0.mediaType.startsWith("image/"))Y0.push({type:"image",source:D51(H0.data)?{type:"url",url:E51(H0.data)}:{type:"base64",media_type:H0.mediaType==="image/*"?"image/jpeg":H0.mediaType,data:AZ(H0.data)},cache_control:S0});else if(H0.mediaType==="application/pdf"){d.add("pdfs-2024-09-25");let I0=await r(H0.providerOptions),Q0=await B0(H0.providerOptions);Y0.push({type:"document",source:D51(H0.data)?{type:"url",url:E51(H0.data)}:{type:"base64",media_type:"application/pdf",data:AZ(H0.data)},title:(J=Q0.title)!=null?J:H0.filename,...Q0.context&&{context:Q0.context},...I0&&{citations:{enabled:!0}},cache_control:S0})}else if(H0.mediaType==="text/plain"){let I0=await r(H0.providerOptions),Q0=await B0(H0.providerOptions);Y0.push({type:"document",source:D51(H0.data)?{type:"url",url:E51(H0.data)}:{type:"text",media_type:"text/plain",data:dh4(H0.data)},title:(K=Q0.title)!=null?K:H0.filename,...Q0.context&&{context:Q0.context},...I0&&{citations:{enabled:!0}},cache_control:S0})}else throw new c4({functionality:`media type: ${H0.mediaType}`});break}}}break}case"tool":{for(let s0=0;s0<d0.length;s0++){let H0=d0[s0];if(H0.type==="tool-approval-response")continue;let V0=H0.output,S0="providerOptions"in V0?V0.providerOptions:V0.type==="content"?(W=V0.value.find((g0)=>g0.providerOptions!=null))==null?void 0:W.providerOptions:void 0,I0=s0===d0.length-1,Q0=(N=(H=y.getCacheControl(H0.providerOptions,{type:"tool result part",canCache:!0}))!=null?H:y.getCacheControl(S0,{type:"tool result output",canCache:!0}))!=null?N:I0?y.getCacheControl(q0.providerOptions,{type:"tool result message",canCache:!0}):void 0,N0;switch(V0.type){case"content":N0=V0.value.map((g0)=>{var O0;switch(g0.type){case"text":return{type:"text",text:g0.text};case"image-data":return{type:"image",source:{type:"base64",media_type:g0.mediaType,data:g0.data}};case"image-url":return{type:"image",source:{type:"url",url:g0.url}};case"file-url":return{type:"document",source:{type:"url",url:g0.url}};case"file-data":{if(g0.mediaType==="application/pdf")return d.add("pdfs-2024-09-25"),{type:"document",source:{type:"base64",media_type:g0.mediaType,data:g0.data}};X.push({type:"other",message:`unsupported tool content part type: ${g0.type} with media type: ${g0.mediaType}`});return}case"custom":{let P0=(O0=g0.providerOptions)==null?void 0:O0.anthropic;if((P0==null?void 0:P0.type)==="tool-reference")return{type:"tool_reference",tool_name:P0.toolName};X.push({type:"other",message:"unsupported custom tool content part"});return}default:{X.push({type:"other",message:`unsupported tool content part type: ${g0.type}`});return}}}).filter($j);break;case"text":case"error-text":N0=V0.value;break;case"execution-denied":N0=(U=V0.reason)!=null?U:"Tool execution denied.";break;case"json":case"error-json":default:N0=JSON.stringify(V0.value);break}Y0.push({type:"tool_result",tool_use_id:H0.toolCallId,content:N0,is_error:V0.type==="error-text"||V0.type==="error-json"?!0:void 0,cache_control:Q0})}break}default:throw Error(`Unsupported role: ${t0}`)}}b.push({role:"user",content:Y0});break}case"assistant":{let Y0=[],q0=new Set;for(let t0=0;t0<Z0.messages.length;t0++){let d0=Z0.messages[t0],s0=t0===Z0.messages.length-1,{content:H0}=d0;for(let V0=0;V0<H0.length;V0++){let S0=H0[V0],I0=V0===H0.length-1,Q0=(F=y.getCacheControl(S0.providerOptions,{type:"assistant message part",canCache:!0}))!=null?F:I0?y.getCacheControl(d0.providerOptions,{type:"assistant message",canCache:!0}):void 0;switch(S0.type){case"text":{let N0=(B=S0.providerOptions)==null?void 0:B.anthropic;if((N0==null?void 0:N0.type)==="compaction")Y0.push({type:"compaction",content:S0.text,cache_control:Q0});else Y0.push({type:"text",text:e&&s0&&I0?S0.text.trim():S0.text,cache_control:Q0});break}case"reasoning":{if(Z){let N0=await J4({provider:"anthropic",providerOptions:S0.providerOptions,schema:Xh4});if(N0!=null)if(N0.signature!=null)y.getCacheControl(S0.providerOptions,{type:"thinking block",canCache:!1}),Y0.push({type:"thinking",thinking:S0.text,signature:N0.signature});else if(N0.redactedData!=null)y.getCacheControl(S0.providerOptions,{type:"redacted thinking block",canCache:!1}),Y0.push({type:"redacted_thinking",data:N0.redactedData});else X.push({type:"other",message:"unsupported reasoning metadata"});else X.push({type:"other",message:"unsupported reasoning metadata"})}else X.push({type:"other",message:"sending reasoning content is disabled for this model"});break}case"tool-call":{if(S0.providerExecuted){let O0=Y.toProviderToolName(S0.toolName);if(((L=(O=S0.providerOptions)==null?void 0:O.anthropic)==null?void 0:L.type)==="mcp-tool-use"){q0.add(S0.toolCallId);let S1=(E=(D=S0.providerOptions)==null?void 0:D.anthropic)==null?void 0:E.serverName;if(S1==null||typeof S1!=="string"){X.push({type:"other",message:"mcp tool use server name is required and must be a string"});break}Y0.push({type:"mcp_tool_use",id:S0.toolCallId,name:S0.toolName,input:S0.input,server_name:S1,cache_control:Q0})}else if(O0==="code_execution"&&S0.input!=null&&typeof S0.input==="object"&&"type"in S0.input&&typeof S0.input.type==="string"&&(S0.input.type==="bash_code_execution"||S0.input.type==="text_editor_code_execution"))Y0.push({type:"server_tool_use",id:S0.toolCallId,name:S0.input.type,input:S0.input,cache_control:Q0});else if(O0==="code_execution"&&S0.input!=null&&typeof S0.input==="object"&&"type"in S0.input&&S0.input.type==="programmatic-tool-call"){let{type:S1,...G1}=S0.input;Y0.push({type:"server_tool_use",id:S0.toolCallId,name:"code_execution",input:G1,cache_control:Q0})}else if(O0==="code_execution"||O0==="web_fetch"||O0==="web_search")Y0.push({type:"server_tool_use",id:S0.toolCallId,name:O0,input:S0.input,cache_control:Q0});else if(O0==="tool_search_tool_regex"||O0==="tool_search_tool_bm25")Y0.push({type:"server_tool_use",id:S0.toolCallId,name:O0,input:S0.input,cache_control:Q0});else if(O0==="advisor")Y0.push({type:"server_tool_use",id:S0.toolCallId,name:"advisor",input:{},cache_control:Q0});else X.push({type:"other",message:`provider executed tool call for tool ${S0.toolName} is not supported`});break}let N0=(z=S0.providerOptions)==null?void 0:z.anthropic,g0=(N0==null?void 0:N0.caller)?(N0.caller.type==="code_execution_20250825"||N0.caller.type==="code_execution_20260120")&&N0.caller.toolId?{type:N0.caller.type,tool_id:N0.caller.toolId}:N0.caller.type==="direct"?{type:"direct"}:void 0:void 0;Y0.push({type:"tool_use",id:S0.toolCallId,name:S0.toolName,input:S0.input,...g0&&{caller:g0},cache_control:Q0});break}case"tool-result":{let N0=Y.toProviderToolName(S0.toolName);if(q0.has(S0.toolCallId)){let g0=S0.output;if(g0.type!=="json"&&g0.type!=="error-json"){X.push({type:"other",message:`provider executed tool result output type ${g0.type} for tool ${S0.toolName} is not supported`});break}Y0.push({type:"mcp_tool_result",tool_use_id:S0.toolCallId,is_error:g0.type==="error-json",content:g0.value,cache_control:Q0})}else if(N0==="code_execution"){let g0=S0.output;if(g0.type==="error-text"||g0.type==="error-json"){let O0={};try{if(typeof g0.value==="string")O0=JSON.parse(g0.value);else if(typeof g0.value==="object"&&g0.value!==null)O0=g0.value}catch(P0){}if(O0.type==="code_execution_tool_result_error")Y0.push({type:"code_execution_tool_result",tool_use_id:S0.toolCallId,content:{type:"code_execution_tool_result_error",error_code:(j=O0.errorCode)!=null?j:"unknown"},cache_control:Q0});else Y0.push({type:"bash_code_execution_tool_result",tool_use_id:S0.toolCallId,cache_control:Q0,content:{type:"bash_code_execution_tool_result_error",error_code:(P=O0.errorCode)!=null?P:"unknown"}});break}if(g0.type!=="json"){X.push({type:"other",message:`provider executed tool result output type ${g0.type} for tool ${S0.toolName} is not supported`});break}if(g0.value==null||typeof g0.value!=="object"||!("type"in g0.value)||typeof g0.value.type!=="string"){X.push({type:"other",message:`provider executed tool result output value is not a valid code execution result for tool ${S0.toolName}`});break}if(g0.value.type==="code_execution_result"){let O0=await n8({value:g0.value,schema:gq8});Y0.push({type:"code_execution_tool_result",tool_use_id:S0.toolCallId,content:{type:O0.type,stdout:O0.stdout,stderr:O0.stderr,return_code:O0.return_code,content:(A=O0.content)!=null?A:[]},cache_control:Q0})}else if(g0.value.type==="encrypted_code_execution_result"){let O0=await n8({value:g0.value,schema:uq8});if(O0.type==="encrypted_code_execution_result")Y0.push({type:"code_execution_tool_result",tool_use_id:S0.toolCallId,content:{type:O0.type,encrypted_stdout:O0.encrypted_stdout,stderr:O0.stderr,return_code:O0.return_code,content:(I=O0.content)!=null?I:[]},cache_control:Q0})}else{let O0=await n8({value:g0.value,schema:hq8});if(O0.type==="code_execution_result")Y0.push({type:"code_execution_tool_result",tool_use_id:S0.toolCallId,content:{type:O0.type,stdout:O0.stdout,stderr:O0.stderr,return_code:O0.return_code,content:(q=O0.content)!=null?q:[]},cache_control:Q0});else if(O0.type==="bash_code_execution_result"||O0.type==="bash_code_execution_tool_result_error")Y0.push({type:"bash_code_execution_tool_result",tool_use_id:S0.toolCallId,cache_control:Q0,content:O0});else Y0.push({type:"text_editor_code_execution_tool_result",tool_use_id:S0.toolCallId,cache_control:Q0,content:O0})}break}if(N0==="web_fetch"){let g0=S0.output;if(g0.type==="error-json"){Y0.push({type:"web_fetch_tool_result",tool_use_id:S0.toolCallId,content:{type:"web_fetch_tool_result_error",error_code:(M=(await kq8(g0.value)).errorCode)!=null?M:"unavailable"},cache_control:Q0});break}if(g0.type!=="json"){X.push({type:"other",message:`provider executed tool result output type ${g0.type} for tool ${S0.toolName} is not supported`});break}let O0=await n8({value:g0.value,schema:yq8});Y0.push({type:"web_fetch_tool_result",tool_use_id:S0.toolCallId,content:{type:"web_fetch_result",url:O0.url,retrieved_at:O0.retrievedAt,content:{type:"document",title:O0.content.title,citations:O0.content.citations,source:{type:O0.content.source.type,media_type:O0.content.source.mediaType,data:O0.content.source.data}}},cache_control:Q0});break}if(N0==="web_search"){let g0=S0.output;if(g0.type==="error-json"){Y0.push({type:"web_search_tool_result",tool_use_id:S0.toolCallId,content:{type:"web_search_tool_result_error",error_code:(S=(await kq8(g0.value)).errorCode)!=null?S:"unavailable"},cache_control:Q0});break}if(g0.type!=="json"){X.push({type:"other",message:`provider executed tool result output type ${g0.type} for tool ${S0.toolName} is not supported`});break}let O0=await n8({value:g0.value,schema:bq8});Y0.push({type:"web_search_tool_result",tool_use_id:S0.toolCallId,content:O0.map((P0)=>({url:P0.url,title:P0.title,page_age:P0.pageAge,encrypted_content:P0.encryptedContent,type:P0.type})),cache_control:Q0});break}if(N0==="tool_search_tool_regex"||N0==="tool_search_tool_bm25"){let g0=S0.output;if(g0.type!=="json"){X.push({type:"other",message:`provider executed tool result output type ${g0.type} for tool ${S0.toolName} is not supported`});break}let P0=(await n8({value:g0.value,schema:cq8})).map((S1)=>({type:"tool_reference",tool_name:S1.toolName}));Y0.push({type:"tool_search_tool_result",tool_use_id:S0.toolCallId,content:{type:"tool_search_tool_search_result",tool_references:P0},cache_control:Q0});break}if(N0==="advisor"){let g0=S0.output;if(g0.type!=="json"&&g0.type!=="error-json"){X.push({type:"other",message:`provider executed tool result output type ${g0.type} for tool ${S0.toolName} is not supported`});break}let O0=await n8({value:g0.value,schema:fq8});if(O0.type==="advisor_result")Y0.push({type:"advisor_tool_result",tool_use_id:S0.toolCallId,content:{type:"advisor_result",text:O0.text},cache_control:Q0});else if(O0.type==="advisor_redacted_result")Y0.push({type:"advisor_tool_result",tool_use_id:S0.toolCallId,content:{type:"advisor_redacted_result",encrypted_content:O0.encryptedContent},cache_control:Q0});else Y0.push({type:"advisor_tool_result",tool_use_id:S0.toolCallId,content:{type:"advisor_tool_result_error",error_code:O0.errorCode},cache_control:Q0});break}X.push({type:"other",message:`provider executed tool result for tool ${S0.toolName} is not supported`});break}}}}b.push({role:"assistant",content:Y0});break}default:throw Error(`content type: ${A0}`)}}return{prompt:{system:o,messages:b},betas:d}}function nh4($){let Z=[],X=void 0;for(let Q of $){let{role:Y}=Q;switch(Y){case"system":{if((X==null?void 0:X.type)!=="system")X={type:"system",messages:[]},Z.push(X);X.messages.push(Q);break}case"assistant":{if((X==null?void 0:X.type)!=="assistant")X={type:"assistant",messages:[]},Z.push(X);X.messages.push(Q);break}case"user":{if((X==null?void 0:X.type)!=="user")X={type:"user",messages:[]},Z.push(X);X.messages.push(Q);break}case"tool":{if((X==null?void 0:X.type)!=="user")X={type:"user",messages:[]},Z.push(X);X.messages.push(Q);break}default:throw Error(`Unsupported role: ${Y}`)}}return Z}function z51({finishReason:$,isJsonResponseFromTool:Z}){switch($){case"pause_turn":case"end_turn":case"stop_sequence":return"stop";case"refusal":return"content-filter";case"tool_use":return Z?"stop":"tool-calls";case"max_tokens":case"model_context_window_exceeded":return"length";case"compaction":return"other";default:return"other"}}function th4($){return dq8($)}function ew($){if(typeof $==="boolean"||!sh4($))return $;return dq8($)}function dq8($){let Z={},X=$;if($.$ref!=null)return{$ref:$.$ref};if($.$schema!=null)Z.$schema=$.$schema;if($.$id!=null)Z.$id=$.$id;if($.title!=null)Z.title=$.title;if($.description!=null)Z.description=$.description;if($.default!==void 0)Z.default=$.default;if($.const!==void 0)Z.const=$.const;if($.enum!=null)Z.enum=$.enum;if($.type!=null)Z.type=$.type;if($.anyOf!=null)Z.anyOf=$.anyOf.map(ew);else if($.oneOf!=null)Z.anyOf=$.oneOf.map(ew);if($.allOf!=null)Z.allOf=$.allOf.map(ew);if($.definitions!=null)Z.definitions=Object.fromEntries(Object.entries($.definitions).map(([Y,G])=>[Y,ew(G)]));if(X.$defs!=null){let Y=Z;Y.$defs=Object.fromEntries(Object.entries(X.$defs).map(([G,J])=>[G,ew(J)]))}if($.type==="object"||$.properties!=null){if($.properties!=null)Z.properties=Object.fromEntries(Object.entries($.properties).map(([Y,G])=>[Y,ew(G)]));if(Z.additionalProperties=!1,$.required!=null)Z.required=$.required}if($.items!=null)Z.items=Array.isArray($.items)?$.items.map(ew):ew($.items);if(typeof $.format==="string"&&lq8.has($.format))Z.format=$.format;let Q=oh4($);if(Q!=null)Z.description=Z.description==null?Q:`${Z.description}
2369
- ${Q}`;return Z}function oh4($){let Z=ph4.flatMap((X)=>{let Q=$[X];if(Q==null||Q===!1)return[];return`${rh4(X)}: ${ah4(Q)}`});if(typeof $.format==="string"&&!lq8.has($.format))Z.push(`format: ${$.format}`);return Z.length===0?void 0:`${Z.join("; ")}.`}function rh4($){return $.replace(/[A-Z]/g,(Z)=>` ${Z.toLowerCase()}`)}function ah4($){if(typeof $==="string")return $;return JSON.stringify($)}function sh4($){return typeof $==="object"&&$!==null&&!Array.isArray($)}function Sq8($,Z,X){var Q;if($.type==="web_search_result_location")return{type:"source",sourceType:"url",id:X(),url:$.url,title:$.title,providerMetadata:{anthropic:{citedText:$.cited_text,encryptedIndex:$.encrypted_index}}};if($.type!=="page_location"&&$.type!=="char_location")return;let Y=Z[$.document_index];if(!Y)return;return{type:"source",sourceType:"document",id:X(),mediaType:Y.mediaType,title:(Q=$.document_title)!=null?Q:Y.title,filename:Y.filename,providerMetadata:{anthropic:$.type==="page_location"?{citedText:$.cited_text,startPageNumber:$.start_page_number,endPageNumber:$.end_page_number}:{citedText:$.cited_text,startCharIndex:$.start_char_index,endCharIndex:$.end_char_index}}}}function $u4($){if($.includes("claude-opus-4-8")||$.includes("claude-opus-4-7")||$.includes("claude-fable-5"))return{maxOutputTokens:128000,supportsStructuredOutput:!0,rejectsSamplingParameters:!0,isKnownModel:!0};else if($.includes("claude-sonnet-4-6")||$.includes("claude-opus-4-6"))return{maxOutputTokens:128000,supportsStructuredOutput:!0,rejectsSamplingParameters:!1,isKnownModel:!0};else if($.includes("claude-sonnet-4-5")||$.includes("claude-opus-4-5")||$.includes("claude-haiku-4-5"))return{maxOutputTokens:64000,supportsStructuredOutput:!0,rejectsSamplingParameters:!1,isKnownModel:!0};else if($.includes("claude-opus-4-1"))return{maxOutputTokens:32000,supportsStructuredOutput:!0,rejectsSamplingParameters:!1,isKnownModel:!0};else if($.includes("claude-sonnet-4-"))return{maxOutputTokens:64000,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,isKnownModel:!0};else if($.includes("claude-opus-4-"))return{maxOutputTokens:32000,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,isKnownModel:!0};else if($.includes("claude-3-haiku"))return{maxOutputTokens:4096,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,isKnownModel:!0};else return{maxOutputTokens:4096,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,isKnownModel:!1}}function Cq8($){if(!$)return!1;let Z=!1,X=!1;for(let Q of $){if("type"in Q&&(Q.type==="web_fetch_20260209"||Q.type==="web_search_20260209")){Z=!0;continue}if(Q.name==="code_execution"){X=!0;break}}return Z&&!X}function _q8($){return $?{appliedEdits:$.applied_edits.map((Z)=>{switch(Z.type){case"clear_tool_uses_20250919":return{type:Z.type,clearedToolUses:Z.cleared_tool_uses,clearedInputTokens:Z.cleared_input_tokens};case"clear_thinking_20251015":return{type:Z.type,clearedThinkingTurns:Z.cleared_thinking_turns,clearedInputTokens:Z.cleared_input_tokens};case"compact_20260112":return{type:Z.type}}}).filter((Z)=>Z!==void 0)}:null}function vq8($){if($==null)return;return{type:$.type,...$.category!=null?{category:$.category}:{},...$.explanation!=null?{explanation:$.explanation}:{},...$.recommended_model!=null?{recommendedModel:$.recommended_model}:{}}}function or($={}){var Z,X;let Q=(Z=Tw(UH({settingValue:$.baseURL,environmentVariableName:"ANTHROPIC_BASE_URL"})))!=null?Z:"https://api.anthropic.com/v1",Y=(X=$.name)!=null?X:"anthropic.messages";if($.apiKey&&$.authToken)throw new jw({argument:"apiKey/authToken",message:"Both apiKey and authToken were provided. Please use only one authentication method."});let G=()=>{let W=$.authToken?{Authorization:`Bearer ${$.authToken}`}:{"x-api-key":Mh({apiKey:$.apiKey,environmentVariableName:"ANTHROPIC_API_KEY",description:"Anthropic"})};return Y$({"anthropic-version":"2023-06-01",...W,...$.headers},`ai-sdk/anthropic/${sg4}`)},J=(W)=>{var H;return new eh4(W,{provider:Y,baseURL:Q,headers:G,fetch:$.fetch,generateId:(H=$.generateId)!=null?H:n6,supportedUrls:()=>({"image/*":[/^https?:\/\/.*$/],"application/pdf":[/^https?:\/\/.*$/]})})},K=function(W){if(new.target)throw Error("The Anthropic model function cannot be called with the new keyword.");return J(W)};return K.specificationVersion="v3",K.languageModel=J,K.chat=J,K.messages=J,K.embeddingModel=(W)=>{throw new e5({modelId:W,modelType:"embeddingModel"})},K.textEmbeddingModel=K.embeddingModel,K.imageModel=(W)=>{throw new e5({modelId:W,modelType:"imageModel"})},K.tools=Tu4,K}var sg4="3.0.85",eg4,Rq8,xq8,$h4,Zh4,Xh4,Iq8,qq8,Mq8=4,A51=class{constructor(){this.breakpointCount=0,this.warnings=[]}getCacheControl($,Z){let X=Qh4($);if(!X)return;if(!Z.canCache){this.warnings.push({type:"unsupported",feature:"cache_control on non-cacheable context",details:`cache_control cannot be set on ${Z.type}. It will be ignored.`});return}if(this.breakpointCount++,this.breakpointCount>Mq8){this.warnings.push({type:"unsupported",feature:"cacheControl breakpoint limit",details:`Maximum ${Mq8} cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`});return}return X}getWarnings(){return this.warnings}},Yh4,fq8,Gh4,Jh4,Kh4=($)=>{return Jh4($)},Wh4,Hh4,Nh4,Uh4=($={})=>{return Nh4($)},Fh4,Bh4,Oh4,wh4,Lh4=($={})=>{return wh4($)},Dh4,bq8,Eh4,zh4,jh4=($={})=>{return zh4($)},Ph4,Ah4,Th4,Rh4,Ih4=($={})=>{return Rh4($)},qh4,yq8,Mh4,Vh4,kh4=($={})=>{return Vh4($)},gq8,Ch4,_h4,vh4=($={})=>{return _h4($)},hq8,xh4,fh4,bh4=($={})=>{return fh4($)},uq8,yh4,gh4,hh4=($={})=>{return gh4($)},cq8,uh4,ch4,lh4=($={})=>{return ch4($)},lq8,ph4,eh4=class{constructor($,Z){this.specificationVersion="v3";var X;this.modelId=$,this.config=Z,this.generateId=(X=Z.generateId)!=null?X:n6}supportsUrl($){return $.protocol==="https:"}get provider(){return this.config.provider}get providerOptionsName(){let $=this.config.provider,Z=$.indexOf(".");return Z===-1?$:$.substring(0,Z)}get supportedUrls(){var $,Z,X;return(X=(Z=($=this.config).supportedUrls)==null?void 0:Z.call($))!=null?X:{}}async getArgs({userSuppliedBetas:$,prompt:Z,maxOutputTokens:X,temperature:Q,topP:Y,topK:G,frequencyPenalty:J,presencePenalty:K,stopSequences:W,responseFormat:H,seed:N,tools:U,toolChoice:F,providerOptions:B,stream:O}){var L,D,E,z,j,P,A,I,q,M;let S=[];if(J!=null)S.push({type:"unsupported",feature:"frequencyPenalty"});if(K!=null)S.push({type:"unsupported",feature:"presencePenalty"});if(N!=null)S.push({type:"unsupported",feature:"seed"});if(Q!=null&&Q>1)S.push({type:"unsupported",feature:"temperature",details:`${Q} exceeds anthropic maximum of 1.0. clamped to 1.0`}),Q=1;else if(Q!=null&&Q<0)S.push({type:"unsupported",feature:"temperature",details:`${Q} is below anthropic minimum of 0. clamped to 0`}),Q=0;if((H==null?void 0:H.type)==="json"){if(H.schema==null)S.push({type:"unsupported",feature:"responseFormat",details:"JSON response format requires a schema. The response format is ignored."})}let d=this.providerOptionsName,f=await J4({provider:"anthropic",providerOptions:B,schema:qq8}),y=d!=="anthropic"?await J4({provider:d,providerOptions:B,schema:qq8}):null,o=y!=null,b=Object.assign({},f!=null?f:{},y!=null?y:{}),{maxOutputTokens:r,supportsStructuredOutput:B0,rejectsSamplingParameters:E0,isKnownModel:Z0}=$u4(this.modelId);if(E0){if(Q!=null)S.push({type:"unsupported",feature:"temperature",details:`temperature is not supported by ${this.modelId} and will be ignored`}),Q=void 0;if(G!=null)S.push({type:"unsupported",feature:"topK",details:`topK is not supported by ${this.modelId} and will be ignored`}),G=void 0;if(Y!=null)S.push({type:"unsupported",feature:"topP",details:`topP is not supported by ${this.modelId} and will be ignored`}),Y=void 0}let e=Z0||this.modelId.startsWith("claude-"),A0=((L=this.config.supportsNativeStructuredOutput)!=null?L:!0)&&B0,Y0=((D=this.config.supportsStrictTools)!=null?D:!0)&&B0,q0=(E=b==null?void 0:b.structuredOutputMode)!=null?E:"auto",t0=q0==="outputFormat"||q0==="auto"&&A0,d0=(H==null?void 0:H.type)==="json"&&H.schema!=null&&!t0?{type:"function",name:"json",description:"Respond with a JSON object.",inputSchema:H.schema}:void 0,s0=b==null?void 0:b.contextManagement,H0=new A51,V0=y30({tools:U,providerToolNames:{"anthropic.code_execution_20250522":"code_execution","anthropic.code_execution_20250825":"code_execution","anthropic.code_execution_20260120":"code_execution","anthropic.computer_20241022":"computer","anthropic.computer_20250124":"computer","anthropic.text_editor_20241022":"str_replace_editor","anthropic.text_editor_20250124":"str_replace_editor","anthropic.text_editor_20250429":"str_replace_based_edit_tool","anthropic.text_editor_20250728":"str_replace_based_edit_tool","anthropic.bash_20241022":"bash","anthropic.bash_20250124":"bash","anthropic.memory_20250818":"memory","anthropic.web_search_20250305":"web_search","anthropic.web_search_20260209":"web_search","anthropic.web_fetch_20250910":"web_fetch","anthropic.web_fetch_20260209":"web_fetch","anthropic.tool_search_regex_20251119":"tool_search_tool_regex","anthropic.tool_search_bm25_20251119":"tool_search_tool_bm25","anthropic.advisor_20260301":"advisor"}}),{prompt:S0,betas:I0}=await ih4({prompt:Z,sendReasoning:(z=b==null?void 0:b.sendReasoning)!=null?z:!0,warnings:S,cacheControlValidator:H0,toolNameMapping:V0}),Q0=(j=b==null?void 0:b.thinking)==null?void 0:j.type,N0=Q0==="enabled"||Q0==="adaptive",g0=Q0==="enabled"?(P=b==null?void 0:b.thinking)==null?void 0:P.budgetTokens:void 0,O0=Q0==="adaptive"?(A=b==null?void 0:b.thinking)==null?void 0:A.display:void 0,P0=X!=null?X:r,S1={model:this.modelId,max_tokens:P0,temperature:Q,top_k:G,top_p:Y,stop_sequences:W,...N0&&{thinking:{type:Q0,...g0!=null&&{budget_tokens:g0},...O0!=null&&{display:O0}}},...((b==null?void 0:b.effort)||(b==null?void 0:b.taskBudget)||t0&&(H==null?void 0:H.type)==="json"&&H.schema!=null)&&{output_config:{...(b==null?void 0:b.effort)&&{effort:b.effort},...(b==null?void 0:b.taskBudget)&&{task_budget:{type:b.taskBudget.type,total:b.taskBudget.total,...b.taskBudget.remaining!=null&&{remaining:b.taskBudget.remaining}}},...t0&&(H==null?void 0:H.type)==="json"&&H.schema!=null&&{format:{type:"json_schema",schema:th4(H.schema)}}}},...(b==null?void 0:b.speed)&&{speed:b.speed},...(b==null?void 0:b.inferenceGeo)&&{inference_geo:b.inferenceGeo},...(b==null?void 0:b.fallbacks)&&b.fallbacks.length>0&&{fallbacks:b.fallbacks},...(b==null?void 0:b.cacheControl)&&{cache_control:b.cacheControl},...((I=b==null?void 0:b.metadata)==null?void 0:I.userId)!=null&&{metadata:{user_id:b.metadata.userId}},...(b==null?void 0:b.mcpServers)&&b.mcpServers.length>0&&{mcp_servers:b.mcpServers.map((u0)=>({type:u0.type,name:u0.name,url:u0.url,authorization_token:u0.authorizationToken,tool_configuration:u0.toolConfiguration?{allowed_tools:u0.toolConfiguration.allowedTools,enabled:u0.toolConfiguration.enabled}:void 0}))},...(b==null?void 0:b.container)&&{container:b.container.skills&&b.container.skills.length>0?{id:b.container.id,skills:b.container.skills.map((u0)=>({type:u0.type,skill_id:u0.skillId,version:u0.version}))}:b.container.id},system:S0.system,messages:S0.messages,...s0&&{context_management:{edits:s0.edits.map((u0)=>{let l1=u0.type;switch(l1){case"clear_tool_uses_20250919":return{type:u0.type,...u0.trigger!==void 0&&{trigger:u0.trigger},...u0.keep!==void 0&&{keep:u0.keep},...u0.clearAtLeast!==void 0&&{clear_at_least:u0.clearAtLeast},...u0.clearToolInputs!==void 0&&{clear_tool_inputs:u0.clearToolInputs},...u0.excludeTools!==void 0&&{exclude_tools:u0.excludeTools}};case"clear_thinking_20251015":return{type:u0.type,...u0.keep!==void 0&&{keep:u0.keep}};case"compact_20260112":return{type:u0.type,...u0.trigger!==void 0&&{trigger:u0.trigger},...u0.pauseAfterCompaction!==void 0&&{pause_after_compaction:u0.pauseAfterCompaction},...u0.instructions!==void 0&&{instructions:u0.instructions}};default:S.push({type:"other",message:`Unknown context management strategy: ${l1}`});return}}).filter((u0)=>u0!==void 0)}}};if(N0){if(Q0==="enabled"&&g0==null)S.push({type:"compatibility",feature:"extended thinking",details:"thinking budget is required when thinking is enabled. using default budget of 1024 tokens."}),S1.thinking={type:"enabled",budget_tokens:1024},g0=1024;if(S1.temperature!=null)S1.temperature=void 0,S.push({type:"unsupported",feature:"temperature",details:"temperature is not supported when thinking is enabled"});if(G!=null)S1.top_k=void 0,S.push({type:"unsupported",feature:"topK",details:"topK is not supported when thinking is enabled"});if(Y!=null)S1.top_p=void 0,S.push({type:"unsupported",feature:"topP",details:"topP is not supported when thinking is enabled"});S1.max_tokens=P0+(g0!=null?g0:0)}else if(e&&Y!=null&&Q!=null)S.push({type:"unsupported",feature:"topP",details:"topP is not supported when temperature is set. topP is ignored."}),S1.top_p=void 0;if(Z0&&S1.max_tokens>r){if(X!=null)S.push({type:"unsupported",feature:"maxOutputTokens",details:`${S1.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${this.modelId} ${r} max output tokens. The max output tokens have been limited to ${r}.`});S1.max_tokens=r}if((b==null?void 0:b.mcpServers)&&b.mcpServers.length>0)I0.add("mcp-client-2025-04-04");if(s0){if(I0.add("context-management-2025-06-27"),s0.edits.some((u0)=>u0.type==="compact_20260112"))I0.add("compact-2026-01-12")}if((b==null?void 0:b.container)&&b.container.skills&&b.container.skills.length>0){if(I0.add("code-execution-2025-08-25"),I0.add("skills-2025-10-02"),I0.add("files-api-2025-04-14"),!(U==null?void 0:U.some((u0)=>u0.type==="provider"&&(u0.id==="anthropic.code_execution_20250825"||u0.id==="anthropic.code_execution_20260120"))))S.push({type:"other",message:"code execution tool is required when using skills"})}if(b==null?void 0:b.taskBudget)I0.add("task-budgets-2026-03-13");if((b==null?void 0:b.speed)==="fast")I0.add("fast-mode-2026-02-01");if((b==null?void 0:b.fallbacks)&&b.fallbacks.length>0)I0.add("server-side-fallback-2026-06-01");let G1=O&&((q=b==null?void 0:b.toolStreaming)!=null?q:!0),{tools:r0,toolChoice:a,toolWarnings:m0,betas:B1}=await Sh4(d0!=null?{tools:[...U!=null?U:[],d0],toolChoice:{type:"required"},disableParallelToolUse:!0,cacheControlValidator:H0,supportsStructuredOutput:!1,supportsStrictTools:Y0,defaultEagerInputStreaming:G1}:{tools:U!=null?U:[],toolChoice:F,disableParallelToolUse:b==null?void 0:b.disableParallelToolUse,cacheControlValidator:H0,supportsStructuredOutput:A0,supportsStrictTools:Y0,defaultEagerInputStreaming:G1}),k1=H0.getWarnings();return{args:{...S1,tools:r0,tool_choice:a,stream:O===!0?!0:void 0},warnings:[...S,...m0,...k1],betas:new Set([...I0,...B1,...$,...(M=b==null?void 0:b.anthropicBeta)!=null?M:[]]),usesJsonResponseTool:d0!=null,toolNameMapping:V0,providerOptionsName:d,usedCustomProviderKey:o}}async getHeaders({betas:$,headers:Z}){return Z6(await c8(this.config.headers),Z,$.size>0?{"anthropic-beta":Array.from($).join(",")}:{})}async getBetasFromHeaders($){var Z,X;let Y=(Z=(await c8(this.config.headers))["anthropic-beta"])!=null?Z:"",G=(X=$==null?void 0:$["anthropic-beta"])!=null?X:"";return new Set([...Y.toLowerCase().split(","),...G.toLowerCase().split(",")].map((J)=>J.trim()).filter((J)=>J!==""))}buildRequestUrl($){var Z,X,Q;return(Q=(X=(Z=this.config).buildRequestUrl)==null?void 0:X.call(Z,this.config.baseURL,$))!=null?Q:`${this.config.baseURL}/messages`}transformRequestBody($,Z){var X,Q,Y;return(Y=(Q=(X=this.config).transformRequestBody)==null?void 0:Q.call(X,$,Z))!=null?Y:$}extractCitationDocuments($){let Z=(X)=>{var Q,Y;if(X.type!=="file")return!1;if(X.mediaType!=="application/pdf"&&X.mediaType!=="text/plain")return!1;let G=(Q=X.providerOptions)==null?void 0:Q.anthropic,J=G==null?void 0:G.citations;return(Y=J==null?void 0:J.enabled)!=null?Y:!1};return $.filter((X)=>X.role==="user").flatMap((X)=>X.content).filter(Z).map((X)=>{var Q;let Y=X;return{title:(Q=Y.filename)!=null?Q:"Untitled Document",filename:Y.filename,mediaType:Y.mediaType}})}async doGenerate($){var Z,X,Q,Y,G,J,K;let{args:W,warnings:H,betas:N,usesJsonResponseTool:U,toolNameMapping:F,providerOptionsName:B,usedCustomProviderKey:O}=await this.getArgs({...$,stream:!1,userSuppliedBetas:await this.getBetasFromHeaders($.headers)}),L=[...this.extractCitationDocuments($.prompt)],D=Cq8(W.tools),{responseHeaders:E,value:z,rawValue:j}=await z6({url:this.buildRequestUrl(!1),headers:await this.getHeaders({betas:N,headers:$.headers}),body:this.transformRequestBody(W,N),failedResponseHandler:Rq8,successfulResponseHandler:W6($h4),abortSignal:$.abortSignal,fetch:this.config.fetch}),P=[],A={},I={},q=!1;for(let M of z.content)switch(M.type){case"text":{if(!U){if(P.push({type:"text",text:M.text}),M.citations)for(let S of M.citations){let d=Sq8(S,L,this.generateId);if(d)P.push(d)}}break}case"thinking":{P.push({type:"reasoning",text:M.thinking,providerMetadata:{anthropic:{signature:M.signature}}});break}case"redacted_thinking":{P.push({type:"reasoning",text:"",providerMetadata:{anthropic:{redactedData:M.data}}});break}case"compaction":{P.push({type:"text",text:M.content,providerMetadata:{anthropic:{type:"compaction"}}});break}case"tool_use":{if(U&&M.name==="json")q=!0,P.push({type:"text",text:JSON.stringify(M.input)});else{let d=M.caller,f=d?{type:d.type,toolId:"tool_id"in d?d.tool_id:void 0}:void 0;P.push({type:"tool-call",toolCallId:M.id,toolName:M.name,input:JSON.stringify(M.input),...f&&{providerMetadata:{anthropic:{caller:f}}}})}break}case"server_tool_use":{if(M.name==="text_editor_code_execution"||M.name==="bash_code_execution")P.push({type:"tool-call",toolCallId:M.id,toolName:F.toCustomToolName("code_execution"),input:JSON.stringify({type:M.name,...M.input}),providerExecuted:!0,...D?{dynamic:!0}:{}});else if(M.name==="web_search"||M.name==="code_execution"||M.name==="web_fetch"){let S=M.name==="code_execution"&&M.input!=null&&typeof M.input==="object"&&"code"in M.input&&!("type"in M.input)?{type:"programmatic-tool-call",...M.input}:M.input;P.push({type:"tool-call",toolCallId:M.id,toolName:F.toCustomToolName(M.name),input:JSON.stringify(S),providerExecuted:!0,...D&&M.name==="code_execution"?{dynamic:!0}:{}})}else if(M.name==="tool_search_tool_regex"||M.name==="tool_search_tool_bm25")I[M.id]=M.name,P.push({type:"tool-call",toolCallId:M.id,toolName:F.toCustomToolName(M.name),input:JSON.stringify(M.input),providerExecuted:!0});else if(M.name==="advisor")P.push({type:"tool-call",toolCallId:M.id,toolName:F.toCustomToolName("advisor"),input:JSON.stringify(M.input),providerExecuted:!0});break}case"mcp_tool_use":{A[M.id]={type:"tool-call",toolCallId:M.id,toolName:M.name,input:JSON.stringify(M.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:"mcp-tool-use",serverName:M.server_name}}},P.push(A[M.id]);break}case"mcp_tool_result":{P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:A[M.tool_use_id].toolName,isError:M.is_error,result:M.content,dynamic:!0,providerMetadata:A[M.tool_use_id].providerMetadata});break}case"web_fetch_tool_result":{if(M.content.type==="web_fetch_result")L.push({title:(Z=M.content.content.title)!=null?Z:M.content.url,mediaType:M.content.content.source.media_type}),P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName("web_fetch"),result:{type:"web_fetch_result",url:M.content.url,retrievedAt:M.content.retrieved_at,content:{type:M.content.content.type,title:M.content.content.title,citations:M.content.content.citations,source:{type:M.content.content.source.type,mediaType:M.content.content.source.media_type,data:M.content.content.source.data}}}});else if(M.content.type==="web_fetch_tool_result_error")P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName("web_fetch"),isError:!0,result:{type:"web_fetch_tool_result_error",errorCode:M.content.error_code}});break}case"web_search_tool_result":{if(Array.isArray(M.content)){P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName("web_search"),result:M.content.map((S)=>{var d;return{url:S.url,title:S.title,pageAge:(d=S.page_age)!=null?d:null,encryptedContent:S.encrypted_content,type:S.type}})});for(let S of M.content)P.push({type:"source",sourceType:"url",id:this.generateId(),url:S.url,title:S.title,providerMetadata:{anthropic:{pageAge:(X=S.page_age)!=null?X:null}}})}else P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName("web_search"),isError:!0,result:{type:"web_search_tool_result_error",errorCode:M.content.error_code}});break}case"code_execution_tool_result":{if(M.content.type==="code_execution_result")P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName("code_execution"),result:{type:M.content.type,stdout:M.content.stdout,stderr:M.content.stderr,return_code:M.content.return_code,content:(Q=M.content.content)!=null?Q:[]}});else if(M.content.type==="encrypted_code_execution_result")P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName("code_execution"),result:{type:M.content.type,encrypted_stdout:M.content.encrypted_stdout,stderr:M.content.stderr,return_code:M.content.return_code,content:(Y=M.content.content)!=null?Y:[]}});else if(M.content.type==="code_execution_tool_result_error")P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName("code_execution"),isError:!0,result:{type:"code_execution_tool_result_error",errorCode:M.content.error_code}});break}case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":{P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName("code_execution"),result:M.content});break}case"tool_search_tool_result":{let S=I[M.tool_use_id];if(S==null){let d=F.toCustomToolName("tool_search_tool_bm25"),f=F.toCustomToolName("tool_search_tool_regex");if(d!=="tool_search_tool_bm25")S="tool_search_tool_bm25";else if(f!=="tool_search_tool_regex")S="tool_search_tool_regex";else S="tool_search_tool_regex"}if(M.content.type==="tool_search_tool_search_result")P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName(S),result:M.content.tool_references.map((d)=>({type:d.type,toolName:d.tool_name}))});else P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName(S),isError:!0,result:{type:"tool_search_tool_result_error",errorCode:M.content.error_code}});break}case"advisor_tool_result":{let S=F.toCustomToolName("advisor");if(M.content.type==="advisor_result")P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:S,result:{type:"advisor_result",text:M.content.text}});else if(M.content.type==="advisor_redacted_result")P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:S,result:{type:"advisor_redacted_result",encryptedContent:M.content.encrypted_content}});else P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:S,isError:!0,result:{type:"advisor_tool_result_error",errorCode:M.content.error_code}});break}case"fallback":break}return{content:P,finishReason:{unified:z51({finishReason:z.stop_reason,isJsonResponseFromTool:q}),raw:(G=z.stop_reason)!=null?G:void 0},usage:Vq8({usage:z.usage}),request:{body:W},response:{id:(J=z.id)!=null?J:void 0,modelId:(K=z.model)!=null?K:void 0,headers:E,body:j},warnings:H,providerMetadata:(()=>{var M,S,d,f,y;let o=vq8(z.stop_details),b={usage:z.usage,cacheCreationInputTokens:(M=z.usage.cache_creation_input_tokens)!=null?M:null,stopSequence:(S=z.stop_sequence)!=null?S:null,...o!=null?{stopDetails:o}:{},iterations:z.usage.iterations?z.usage.iterations.map((B0)=>({type:B0.type,...B0.model!=null?{model:B0.model}:{},inputTokens:B0.input_tokens,outputTokens:B0.output_tokens,...B0.cache_creation_input_tokens?{cacheCreationInputTokens:B0.cache_creation_input_tokens}:{},...B0.cache_read_input_tokens?{cacheReadInputTokens:B0.cache_read_input_tokens}:{}})):null,container:z.container?{expiresAt:z.container.expires_at,id:z.container.id,skills:(f=(d=z.container.skills)==null?void 0:d.map((B0)=>({type:B0.type,skillId:B0.skill_id,version:B0.version})))!=null?f:null}:null,contextManagement:(y=_q8(z.context_management))!=null?y:null},r={anthropic:b};if(O&&B!=="anthropic")r[B]=b;return r})()}}async doStream($){var Z,X;let{args:Q,warnings:Y,betas:G,usesJsonResponseTool:J,toolNameMapping:K,providerOptionsName:W,usedCustomProviderKey:H}=await this.getArgs({...$,stream:!0,userSuppliedBetas:await this.getBetasFromHeaders($.headers)}),N=[...this.extractCitationDocuments($.prompt)],U=Cq8(Q.tools),F=this.buildRequestUrl(!0),{responseHeaders:B,value:O}=await z6({url:F,headers:await this.getHeaders({betas:G,headers:$.headers}),body:this.transformRequestBody(Q,G),failedResponseHandler:Rq8,successfulResponseHandler:EX(Zh4),abortSignal:$.abortSignal,fetch:this.config.fetch}),L={unified:"other",raw:void 0},D={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,iterations:null},E={},z={},j={},P=null,A=void 0,I=null,q=null,M=void 0,S=null,d=!1,f=void 0,y=this.generateId,o=O.pipeThrough(new TransformStream({start(E0){E0.enqueue({type:"stream-start",warnings:Y})},transform(E0,Z0){var e,A0,Y0,q0,t0,d0,s0,H0,V0,S0,I0,Q0,N0,g0;if($.includeRawChunks)Z0.enqueue({type:"raw",rawValue:E0.rawValue});if(!E0.success){Z0.enqueue({type:"error",error:E0.error});return}let O0=E0.value;switch(O0.type){case"ping":return;case"content_block_start":{let P0=O0.content_block,S1=P0.type;if(S1==="fallback")return;switch(f=S1,S1){case"text":{if(J)return;E[O0.index]={type:"text"},Z0.enqueue({type:"text-start",id:String(O0.index)});return}case"thinking":{E[O0.index]={type:"reasoning"},Z0.enqueue({type:"reasoning-start",id:String(O0.index)});return}case"redacted_thinking":{E[O0.index]={type:"reasoning"},Z0.enqueue({type:"reasoning-start",id:String(O0.index),providerMetadata:{anthropic:{redactedData:P0.data}}});return}case"compaction":{E[O0.index]={type:"text"},Z0.enqueue({type:"text-start",id:String(O0.index),providerMetadata:{anthropic:{type:"compaction"}}});return}case"tool_use":{if(J&&P0.name==="json")d=!0,E[O0.index]={type:"text"},Z0.enqueue({type:"text-start",id:String(O0.index)});else{let r0=P0.caller,a=r0?{type:r0.type,toolId:"tool_id"in r0?r0.tool_id:void 0}:void 0,B1=P0.input&&Object.keys(P0.input).length>0?JSON.stringify(P0.input):"";E[O0.index]={type:"tool-call",toolCallId:P0.id,toolName:P0.name,input:B1,firstDelta:B1.length===0,...a&&{caller:a}},Z0.enqueue({type:"tool-input-start",id:P0.id,toolName:P0.name})}return}case"server_tool_use":{if(["web_fetch","web_search","code_execution","text_editor_code_execution","bash_code_execution"].includes(P0.name)){let G1=P0.name==="text_editor_code_execution"||P0.name==="bash_code_execution"?"code_execution":P0.name,r0=K.toCustomToolName(G1),a=P0.input!=null&&typeof P0.input==="object"&&Object.keys(P0.input).length>0?JSON.stringify(P0.input):"";E[O0.index]={type:"tool-call",toolCallId:P0.id,toolName:r0,input:a,providerExecuted:!0,...U&&G1==="code_execution"?{dynamic:!0}:{},firstDelta:!0,providerToolName:G1},Z0.enqueue({type:"tool-input-start",id:P0.id,toolName:r0,providerExecuted:!0,...U&&G1==="code_execution"?{dynamic:!0}:{}})}else if(P0.name==="tool_search_tool_regex"||P0.name==="tool_search_tool_bm25"){j[P0.id]=P0.name;let G1=K.toCustomToolName(P0.name);E[O0.index]={type:"tool-call",toolCallId:P0.id,toolName:G1,input:"",providerExecuted:!0,firstDelta:!0,providerToolName:P0.name},Z0.enqueue({type:"tool-input-start",id:P0.id,toolName:G1,providerExecuted:!0})}else if(P0.name==="advisor"){let G1=K.toCustomToolName("advisor");E[O0.index]={type:"tool-call",toolCallId:P0.id,toolName:G1,input:"{}",providerExecuted:!0,firstDelta:!0,providerToolName:P0.name},Z0.enqueue({type:"tool-input-start",id:P0.id,toolName:G1,providerExecuted:!0})}return}case"web_fetch_tool_result":{if(P0.content.type==="web_fetch_result")N.push({title:(e=P0.content.content.title)!=null?e:P0.content.url,mediaType:P0.content.content.source.media_type}),Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName("web_fetch"),result:{type:"web_fetch_result",url:P0.content.url,retrievedAt:P0.content.retrieved_at,content:{type:P0.content.content.type,title:P0.content.content.title,citations:P0.content.content.citations,source:{type:P0.content.content.source.type,mediaType:P0.content.content.source.media_type,data:P0.content.content.source.data}}}});else if(P0.content.type==="web_fetch_tool_result_error")Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName("web_fetch"),isError:!0,result:{type:"web_fetch_tool_result_error",errorCode:P0.content.error_code}});return}case"web_search_tool_result":{if(Array.isArray(P0.content)){Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName("web_search"),result:P0.content.map((G1)=>{var r0;return{url:G1.url,title:G1.title,pageAge:(r0=G1.page_age)!=null?r0:null,encryptedContent:G1.encrypted_content,type:G1.type}})});for(let G1 of P0.content)Z0.enqueue({type:"source",sourceType:"url",id:y(),url:G1.url,title:G1.title,providerMetadata:{anthropic:{pageAge:(A0=G1.page_age)!=null?A0:null}}})}else Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName("web_search"),isError:!0,result:{type:"web_search_tool_result_error",errorCode:P0.content.error_code}});return}case"code_execution_tool_result":{if(P0.content.type==="code_execution_result")Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName("code_execution"),result:{type:P0.content.type,stdout:P0.content.stdout,stderr:P0.content.stderr,return_code:P0.content.return_code,content:(Y0=P0.content.content)!=null?Y0:[]}});else if(P0.content.type==="encrypted_code_execution_result")Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName("code_execution"),result:{type:P0.content.type,encrypted_stdout:P0.content.encrypted_stdout,stderr:P0.content.stderr,return_code:P0.content.return_code,content:(q0=P0.content.content)!=null?q0:[]}});else if(P0.content.type==="code_execution_tool_result_error")Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName("code_execution"),isError:!0,result:{type:"code_execution_tool_result_error",errorCode:P0.content.error_code}});return}case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":{Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName("code_execution"),result:P0.content});return}case"tool_search_tool_result":{let G1=j[P0.tool_use_id];if(G1==null){let r0=K.toCustomToolName("tool_search_tool_bm25"),a=K.toCustomToolName("tool_search_tool_regex");if(r0!=="tool_search_tool_bm25")G1="tool_search_tool_bm25";else if(a!=="tool_search_tool_regex")G1="tool_search_tool_regex";else G1="tool_search_tool_regex"}if(P0.content.type==="tool_search_tool_search_result")Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName(G1),result:P0.content.tool_references.map((r0)=>({type:r0.type,toolName:r0.tool_name}))});else Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName(G1),isError:!0,result:{type:"tool_search_tool_result_error",errorCode:P0.content.error_code}});return}case"advisor_tool_result":{let G1=K.toCustomToolName("advisor");if(P0.content.type==="advisor_result")Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:G1,result:{type:"advisor_result",text:P0.content.text}});else if(P0.content.type==="advisor_redacted_result")Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:G1,result:{type:"advisor_redacted_result",encryptedContent:P0.content.encrypted_content}});else Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:G1,isError:!0,result:{type:"advisor_tool_result_error",errorCode:P0.content.error_code}});return}case"mcp_tool_use":{z[P0.id]={type:"tool-call",toolCallId:P0.id,toolName:P0.name,input:JSON.stringify(P0.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:"mcp-tool-use",serverName:P0.server_name}}},Z0.enqueue(z[P0.id]);return}case"mcp_tool_result":{Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:z[P0.tool_use_id].toolName,isError:P0.is_error,result:P0.content,dynamic:!0,providerMetadata:z[P0.tool_use_id].providerMetadata});return}default:throw Error(`Unsupported content block type: ${S1}`)}}case"content_block_stop":{if(E[O0.index]!=null){let P0=E[O0.index];switch(P0.type){case"text":{Z0.enqueue({type:"text-end",id:String(O0.index)});break}case"reasoning":{Z0.enqueue({type:"reasoning-end",id:String(O0.index)});break}case"tool-call":if(!(J&&P0.toolName==="json")){Z0.enqueue({type:"tool-input-end",id:P0.toolCallId});let G1=P0.input===""?"{}":P0.input;if(P0.providerToolName==="code_execution")try{let r0=JSON.parse(G1);if(r0!=null&&typeof r0==="object"&&"code"in r0&&!("type"in r0))G1=JSON.stringify({type:"programmatic-tool-call",...r0})}catch(r0){}Z0.enqueue({type:"tool-call",toolCallId:P0.toolCallId,toolName:P0.toolName,input:G1,providerExecuted:P0.providerExecuted,...U&&P0.providerToolName==="code_execution"?{dynamic:!0}:{},...P0.caller&&{providerMetadata:{anthropic:{caller:P0.caller}}}})}break}delete E[O0.index]}f=void 0;return}case"content_block_delta":{let P0=O0.delta.type;switch(P0){case"text_delta":{if(J)return;Z0.enqueue({type:"text-delta",id:String(O0.index),delta:O0.delta.text});return}case"thinking_delta":{Z0.enqueue({type:"reasoning-delta",id:String(O0.index),delta:O0.delta.thinking});return}case"signature_delta":{if(f==="thinking")Z0.enqueue({type:"reasoning-delta",id:String(O0.index),delta:"",providerMetadata:{anthropic:{signature:O0.delta.signature}}});return}case"compaction_delta":{if(O0.delta.content!=null)Z0.enqueue({type:"text-delta",id:String(O0.index),delta:O0.delta.content});return}case"input_json_delta":{let S1=E[O0.index],G1=O0.delta.partial_json;if(G1.length===0)return;if(d){if((S1==null?void 0:S1.type)!=="text")return;Z0.enqueue({type:"text-delta",id:String(O0.index),delta:G1})}else{if((S1==null?void 0:S1.type)!=="tool-call")return;if(S1.firstDelta&&S1.providerToolName==="code_execution")G1=`{"type": "programmatic-tool-call",${G1.substring(1)}`;Z0.enqueue({type:"tool-input-delta",id:S1.toolCallId,delta:G1}),S1.input+=G1,S1.firstDelta=!1}return}case"citations_delta":{let S1=O0.delta.citation,G1=Sq8(S1,N,y);if(G1)Z0.enqueue(G1);return}default:throw Error(`Unsupported delta type: ${P0}`)}}case"message_start":{if(D.input_tokens=O0.message.usage.input_tokens,D.cache_read_input_tokens=(t0=O0.message.usage.cache_read_input_tokens)!=null?t0:0,D.cache_creation_input_tokens=(d0=O0.message.usage.cache_creation_input_tokens)!=null?d0:0,A={...O0.message.usage},I=(s0=O0.message.usage.cache_creation_input_tokens)!=null?s0:null,O0.message.container!=null)S={expiresAt:O0.message.container.expires_at,id:O0.message.container.id,skills:null};if(O0.message.stop_reason!=null)L={unified:z51({finishReason:O0.message.stop_reason,isJsonResponseFromTool:d}),raw:O0.message.stop_reason};if(Z0.enqueue({type:"response-metadata",id:(H0=O0.message.id)!=null?H0:void 0,modelId:(V0=O0.message.model)!=null?V0:void 0}),O0.message.content!=null)for(let P0=0;P0<O0.message.content.length;P0++){let S1=O0.message.content[P0];if(S1.type==="tool_use"){let G1=S1.caller,r0=G1?{type:G1.type,toolId:"tool_id"in G1?G1.tool_id:void 0}:void 0;Z0.enqueue({type:"tool-input-start",id:S1.id,toolName:S1.name});let a=JSON.stringify((S0=S1.input)!=null?S0:{});Z0.enqueue({type:"tool-input-delta",id:S1.id,delta:a}),Z0.enqueue({type:"tool-input-end",id:S1.id}),Z0.enqueue({type:"tool-call",toolCallId:S1.id,toolName:S1.name,input:a,...r0&&{providerMetadata:{anthropic:{caller:r0}}}})}}return}case"message_delta":{if(O0.usage.input_tokens!=null&&D.input_tokens!==O0.usage.input_tokens)D.input_tokens=O0.usage.input_tokens;if(D.output_tokens=O0.usage.output_tokens,O0.usage.cache_read_input_tokens!=null)D.cache_read_input_tokens=O0.usage.cache_read_input_tokens;if(O0.usage.cache_creation_input_tokens!=null)D.cache_creation_input_tokens=O0.usage.cache_creation_input_tokens,I=O0.usage.cache_creation_input_tokens;if(O0.usage.iterations!=null)D.iterations=O0.usage.iterations;if(L={unified:z51({finishReason:O0.delta.stop_reason,isJsonResponseFromTool:d}),raw:(I0=O0.delta.stop_reason)!=null?I0:void 0},q=(Q0=O0.delta.stop_sequence)!=null?Q0:null,M=vq8(O0.delta.stop_details),S=O0.delta.container!=null?{expiresAt:O0.delta.container.expires_at,id:O0.delta.container.id,skills:(g0=(N0=O0.delta.container.skills)==null?void 0:N0.map((P0)=>({type:P0.type,skillId:P0.skill_id,version:P0.version})))!=null?g0:null}:null,O0.context_management)P=_q8(O0.context_management);A={...A,...O0.usage};return}case"message_stop":{let P0={usage:A!=null?A:null,cacheCreationInputTokens:I,stopSequence:q,...M!=null?{stopDetails:M}:{},iterations:D.iterations?D.iterations.map((G1)=>({type:G1.type,...G1.model!=null?{model:G1.model}:{},inputTokens:G1.input_tokens,outputTokens:G1.output_tokens,...G1.cache_creation_input_tokens?{cacheCreationInputTokens:G1.cache_creation_input_tokens}:{},...G1.cache_read_input_tokens?{cacheReadInputTokens:G1.cache_read_input_tokens}:{}})):null,container:S,contextManagement:P},S1={anthropic:P0};if(H&&W!=="anthropic")S1[W]=P0;Z0.enqueue({type:"finish",finishReason:L,usage:Vq8({usage:D,rawUsage:A}),providerMetadata:S1});return}case"error":{Z0.enqueue({type:"error",error:O0.error});return}default:throw Error(`Unsupported chunk type: ${O0}`)}}})),[b,r]=o.tee(),B0=b.getReader();try{await B0.read();let E0=await B0.read();if(((Z=E0.value)==null?void 0:Z.type)==="raw")E0=await B0.read();if(((X=E0.value)==null?void 0:X.type)==="error"){let Z0=E0.value.error;throw new O4({message:Z0.message,url:F,requestBodyValues:Q,statusCode:Z0.type==="overloaded_error"?529:500,responseHeaders:B,responseBody:JSON.stringify(Z0),isRetryable:Z0.type==="overloaded_error"})}}finally{B0.cancel().catch(()=>{}),B0.releaseLock()}return{stream:r,request:{body:Q},response:{headers:B}}}},Zu4,Xu4,Qu4,Yu4,Gu4,Ju4,Ku4,Wu4,Hu4,Nu4,Uu4,Fu4,Bu4,Ou4,wu4,Lu4,Du4,Eu4,zu4,ju4,Pu4,Au4=($={})=>{return Pu4($)},Tu4,f1Z;var T51=w(()=>{Q8();a0();Q8();a0();a0();a0();Q8();a0();a0();a0();a0();a0();a0();a0();Q8();a0();a0();a0();a0();a0();a0();a0();a0();a0();a0();a0();a0();a0();a0();a0();eg4=k0(()=>W0(pr.object({type:pr.literal("error"),error:pr.object({type:pr.string(),message:pr.string()})}))),Rq8=c5({errorSchema:eg4,errorToMessage:($)=>$.error.message}),xq8=V.object({type:V.string(),category:V.string().nullish(),explanation:V.string().nullish(),recommended_model:V.string().nullish()}),$h4=k0(()=>W0(V.object({type:V.literal("message"),id:V.string().nullish(),model:V.string().nullish(),content:V.array(V.discriminatedUnion("type",[V.object({type:V.literal("text"),text:V.string(),citations:V.array(V.discriminatedUnion("type",[V.object({type:V.literal("web_search_result_location"),cited_text:V.string(),url:V.string(),title:V.string(),encrypted_index:V.string()}),V.object({type:V.literal("page_location"),cited_text:V.string(),document_index:V.number(),document_title:V.string().nullable(),start_page_number:V.number(),end_page_number:V.number()}),V.object({type:V.literal("char_location"),cited_text:V.string(),document_index:V.number(),document_title:V.string().nullable(),start_char_index:V.number(),end_char_index:V.number()})])).optional()}),V.object({type:V.literal("thinking"),thinking:V.string(),signature:V.string()}),V.object({type:V.literal("redacted_thinking"),data:V.string()}),V.object({type:V.literal("compaction"),content:V.string()}),V.object({type:V.literal("tool_use"),id:V.string(),name:V.string(),input:V.unknown(),caller:V.union([V.object({type:V.literal("code_execution_20250825"),tool_id:V.string()}),V.object({type:V.literal("code_execution_20260120"),tool_id:V.string()}),V.object({type:V.literal("direct")})]).optional()}),V.object({type:V.literal("server_tool_use"),id:V.string(),name:V.string(),input:V.record(V.string(),V.unknown()).nullish(),caller:V.union([V.object({type:V.literal("code_execution_20260120"),tool_id:V.string()}),V.object({type:V.literal("direct")})]).optional()}),V.object({type:V.literal("mcp_tool_use"),id:V.string(),name:V.string(),input:V.unknown(),server_name:V.string()}),V.object({type:V.literal("mcp_tool_result"),tool_use_id:V.string(),is_error:V.boolean(),content:V.array(V.union([V.string(),V.object({type:V.literal("text"),text:V.string()})]))}),V.object({type:V.literal("web_fetch_tool_result"),tool_use_id:V.string(),content:V.union([V.object({type:V.literal("web_fetch_result"),url:V.string(),retrieved_at:V.string(),content:V.object({type:V.literal("document"),title:V.string().nullable(),citations:V.object({enabled:V.boolean()}).optional(),source:V.union([V.object({type:V.literal("base64"),media_type:V.literal("application/pdf"),data:V.string()}),V.object({type:V.literal("text"),media_type:V.literal("text/plain"),data:V.string()})])})}),V.object({type:V.literal("web_fetch_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("web_search_tool_result"),tool_use_id:V.string(),content:V.union([V.array(V.object({type:V.literal("web_search_result"),url:V.string(),title:V.string(),encrypted_content:V.string(),page_age:V.string().nullish()})),V.object({type:V.literal("web_search_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("code_execution_tool_result"),tool_use_id:V.string(),content:V.union([V.object({type:V.literal("code_execution_result"),stdout:V.string(),stderr:V.string(),return_code:V.number(),content:V.array(V.object({type:V.literal("code_execution_output"),file_id:V.string()})).optional().default([])}),V.object({type:V.literal("encrypted_code_execution_result"),encrypted_stdout:V.string(),stderr:V.string(),return_code:V.number(),content:V.array(V.object({type:V.literal("code_execution_output"),file_id:V.string()})).optional().default([])}),V.object({type:V.literal("code_execution_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("bash_code_execution_tool_result"),tool_use_id:V.string(),content:V.discriminatedUnion("type",[V.object({type:V.literal("bash_code_execution_result"),content:V.array(V.object({type:V.literal("bash_code_execution_output"),file_id:V.string()})),stdout:V.string(),stderr:V.string(),return_code:V.number()}),V.object({type:V.literal("bash_code_execution_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("text_editor_code_execution_tool_result"),tool_use_id:V.string(),content:V.discriminatedUnion("type",[V.object({type:V.literal("text_editor_code_execution_tool_result_error"),error_code:V.string()}),V.object({type:V.literal("text_editor_code_execution_view_result"),content:V.string(),file_type:V.string(),num_lines:V.number().nullable(),start_line:V.number().nullable(),total_lines:V.number().nullable()}),V.object({type:V.literal("text_editor_code_execution_create_result"),is_file_update:V.boolean()}),V.object({type:V.literal("text_editor_code_execution_str_replace_result"),lines:V.array(V.string()).nullable(),new_lines:V.number().nullable(),new_start:V.number().nullable(),old_lines:V.number().nullable(),old_start:V.number().nullable()})])}),V.object({type:V.literal("tool_search_tool_result"),tool_use_id:V.string(),content:V.union([V.object({type:V.literal("tool_search_tool_search_result"),tool_references:V.array(V.object({type:V.literal("tool_reference"),tool_name:V.string()}))}),V.object({type:V.literal("tool_search_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("advisor_tool_result"),tool_use_id:V.string(),content:V.discriminatedUnion("type",[V.object({type:V.literal("advisor_result"),text:V.string()}),V.object({type:V.literal("advisor_redacted_result"),encrypted_content:V.string()}),V.object({type:V.literal("advisor_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("fallback")})])),stop_reason:V.string().nullish(),stop_sequence:V.string().nullish(),stop_details:xq8.nullish(),usage:V.looseObject({input_tokens:V.number(),output_tokens:V.number(),cache_creation_input_tokens:V.number().nullish(),cache_read_input_tokens:V.number().nullish(),iterations:V.array(V.object({type:V.union([V.literal("compaction"),V.literal("message"),V.literal("advisor_message"),V.literal("fallback_message")]),model:V.string().nullish(),input_tokens:V.number(),output_tokens:V.number(),cache_creation_input_tokens:V.number().nullish(),cache_read_input_tokens:V.number().nullish()})).nullish()}),container:V.object({expires_at:V.string(),id:V.string(),skills:V.array(V.object({type:V.union([V.literal("anthropic"),V.literal("custom")]),skill_id:V.string(),version:V.string()})).nullish()}).nullish(),context_management:V.object({applied_edits:V.array(V.union([V.object({type:V.literal("clear_tool_uses_20250919"),cleared_tool_uses:V.number(),cleared_input_tokens:V.number()}),V.object({type:V.literal("clear_thinking_20251015"),cleared_thinking_turns:V.number(),cleared_input_tokens:V.number()}),V.object({type:V.literal("compact_20260112")})]))}).nullish()}))),Zh4=k0(()=>W0(V.discriminatedUnion("type",[V.object({type:V.literal("message_start"),message:V.object({id:V.string().nullish(),model:V.string().nullish(),role:V.string().nullish(),usage:V.looseObject({input_tokens:V.number(),cache_creation_input_tokens:V.number().nullish(),cache_read_input_tokens:V.number().nullish()}),content:V.array(V.discriminatedUnion("type",[V.object({type:V.literal("tool_use"),id:V.string(),name:V.string(),input:V.unknown(),caller:V.union([V.object({type:V.literal("code_execution_20250825"),tool_id:V.string()}),V.object({type:V.literal("code_execution_20260120"),tool_id:V.string()}),V.object({type:V.literal("direct")})]).optional()})])).nullish(),stop_reason:V.string().nullish(),container:V.object({expires_at:V.string(),id:V.string()}).nullish()})}),V.object({type:V.literal("content_block_start"),index:V.number(),content_block:V.discriminatedUnion("type",[V.object({type:V.literal("text"),text:V.string()}),V.object({type:V.literal("thinking"),thinking:V.string()}),V.object({type:V.literal("tool_use"),id:V.string(),name:V.string(),input:V.record(V.string(),V.unknown()).optional(),caller:V.union([V.object({type:V.literal("code_execution_20250825"),tool_id:V.string()}),V.object({type:V.literal("code_execution_20260120"),tool_id:V.string()}),V.object({type:V.literal("direct")})]).optional()}),V.object({type:V.literal("redacted_thinking"),data:V.string()}),V.object({type:V.literal("compaction"),content:V.string().nullish()}),V.object({type:V.literal("server_tool_use"),id:V.string(),name:V.string(),input:V.record(V.string(),V.unknown()).nullish(),caller:V.union([V.object({type:V.literal("code_execution_20260120"),tool_id:V.string()}),V.object({type:V.literal("direct")})]).optional()}),V.object({type:V.literal("mcp_tool_use"),id:V.string(),name:V.string(),input:V.unknown(),server_name:V.string()}),V.object({type:V.literal("mcp_tool_result"),tool_use_id:V.string(),is_error:V.boolean(),content:V.array(V.union([V.string(),V.object({type:V.literal("text"),text:V.string()})]))}),V.object({type:V.literal("web_fetch_tool_result"),tool_use_id:V.string(),content:V.union([V.object({type:V.literal("web_fetch_result"),url:V.string(),retrieved_at:V.string(),content:V.object({type:V.literal("document"),title:V.string().nullable(),citations:V.object({enabled:V.boolean()}).optional(),source:V.union([V.object({type:V.literal("base64"),media_type:V.literal("application/pdf"),data:V.string()}),V.object({type:V.literal("text"),media_type:V.literal("text/plain"),data:V.string()})])})}),V.object({type:V.literal("web_fetch_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("web_search_tool_result"),tool_use_id:V.string(),content:V.union([V.array(V.object({type:V.literal("web_search_result"),url:V.string(),title:V.string(),encrypted_content:V.string(),page_age:V.string().nullish()})),V.object({type:V.literal("web_search_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("code_execution_tool_result"),tool_use_id:V.string(),content:V.union([V.object({type:V.literal("code_execution_result"),stdout:V.string(),stderr:V.string(),return_code:V.number(),content:V.array(V.object({type:V.literal("code_execution_output"),file_id:V.string()})).optional().default([])}),V.object({type:V.literal("encrypted_code_execution_result"),encrypted_stdout:V.string(),stderr:V.string(),return_code:V.number(),content:V.array(V.object({type:V.literal("code_execution_output"),file_id:V.string()})).optional().default([])}),V.object({type:V.literal("code_execution_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("bash_code_execution_tool_result"),tool_use_id:V.string(),content:V.discriminatedUnion("type",[V.object({type:V.literal("bash_code_execution_result"),content:V.array(V.object({type:V.literal("bash_code_execution_output"),file_id:V.string()})),stdout:V.string(),stderr:V.string(),return_code:V.number()}),V.object({type:V.literal("bash_code_execution_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("text_editor_code_execution_tool_result"),tool_use_id:V.string(),content:V.discriminatedUnion("type",[V.object({type:V.literal("text_editor_code_execution_tool_result_error"),error_code:V.string()}),V.object({type:V.literal("text_editor_code_execution_view_result"),content:V.string(),file_type:V.string(),num_lines:V.number().nullable(),start_line:V.number().nullable(),total_lines:V.number().nullable()}),V.object({type:V.literal("text_editor_code_execution_create_result"),is_file_update:V.boolean()}),V.object({type:V.literal("text_editor_code_execution_str_replace_result"),lines:V.array(V.string()).nullable(),new_lines:V.number().nullable(),new_start:V.number().nullable(),old_lines:V.number().nullable(),old_start:V.number().nullable()})])}),V.object({type:V.literal("tool_search_tool_result"),tool_use_id:V.string(),content:V.union([V.object({type:V.literal("tool_search_tool_search_result"),tool_references:V.array(V.object({type:V.literal("tool_reference"),tool_name:V.string()}))}),V.object({type:V.literal("tool_search_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("advisor_tool_result"),tool_use_id:V.string(),content:V.discriminatedUnion("type",[V.object({type:V.literal("advisor_result"),text:V.string()}),V.object({type:V.literal("advisor_redacted_result"),encrypted_content:V.string()}),V.object({type:V.literal("advisor_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("fallback")})])}),V.object({type:V.literal("content_block_delta"),index:V.number(),delta:V.discriminatedUnion("type",[V.object({type:V.literal("input_json_delta"),partial_json:V.string()}),V.object({type:V.literal("text_delta"),text:V.string()}),V.object({type:V.literal("thinking_delta"),thinking:V.string()}),V.object({type:V.literal("signature_delta"),signature:V.string()}),V.object({type:V.literal("compaction_delta"),content:V.string().nullish()}),V.object({type:V.literal("citations_delta"),citation:V.discriminatedUnion("type",[V.object({type:V.literal("web_search_result_location"),cited_text:V.string(),url:V.string(),title:V.string(),encrypted_index:V.string()}),V.object({type:V.literal("page_location"),cited_text:V.string(),document_index:V.number(),document_title:V.string().nullable(),start_page_number:V.number(),end_page_number:V.number()}),V.object({type:V.literal("char_location"),cited_text:V.string(),document_index:V.number(),document_title:V.string().nullable(),start_char_index:V.number(),end_char_index:V.number()})])})])}),V.object({type:V.literal("content_block_stop"),index:V.number()}),V.object({type:V.literal("error"),error:V.object({type:V.string(),message:V.string()})}),V.object({type:V.literal("message_delta"),delta:V.object({stop_reason:V.string().nullish(),stop_sequence:V.string().nullish(),stop_details:xq8.nullish(),container:V.object({expires_at:V.string(),id:V.string(),skills:V.array(V.object({type:V.union([V.literal("anthropic"),V.literal("custom")]),skill_id:V.string(),version:V.string()})).nullish()}).nullish()}),usage:V.looseObject({input_tokens:V.number().nullish(),output_tokens:V.number(),cache_creation_input_tokens:V.number().nullish(),cache_read_input_tokens:V.number().nullish(),iterations:V.array(V.object({type:V.union([V.literal("compaction"),V.literal("message"),V.literal("advisor_message"),V.literal("fallback_message")]),model:V.string().nullish(),input_tokens:V.number(),output_tokens:V.number(),cache_creation_input_tokens:V.number().nullish(),cache_read_input_tokens:V.number().nullish()})).nullish()}),context_management:V.object({applied_edits:V.array(V.union([V.object({type:V.literal("clear_tool_uses_20250919"),cleared_tool_uses:V.number(),cleared_input_tokens:V.number()}),V.object({type:V.literal("clear_thinking_20251015"),cleared_thinking_turns:V.number(),cleared_input_tokens:V.number()}),V.object({type:V.literal("compact_20260112")})]))}).nullish()}),V.object({type:V.literal("message_stop")}),V.object({type:V.literal("ping")})]))),Xh4=k0(()=>W0(V.object({signature:V.string().optional(),redactedData:V.string().optional()}))),Iq8=j1.object({citations:j1.object({enabled:j1.boolean()}).optional(),title:j1.string().optional(),context:j1.string().optional()}),qq8=j1.object({sendReasoning:j1.boolean().optional(),structuredOutputMode:j1.enum(["outputFormat","jsonTool","auto"]).optional(),thinking:j1.discriminatedUnion("type",[j1.object({type:j1.literal("adaptive"),display:j1.enum(["omitted","summarized"]).optional()}),j1.object({type:j1.literal("enabled"),budgetTokens:j1.number().optional()}),j1.object({type:j1.literal("disabled")})]).optional(),disableParallelToolUse:j1.boolean().optional(),cacheControl:j1.object({type:j1.literal("ephemeral"),ttl:j1.union([j1.literal("5m"),j1.literal("1h")]).optional()}).optional(),metadata:j1.object({userId:j1.string().optional()}).optional(),mcpServers:j1.array(j1.object({type:j1.literal("url"),name:j1.string(),url:j1.string(),authorizationToken:j1.string().nullish(),toolConfiguration:j1.object({enabled:j1.boolean().nullish(),allowedTools:j1.array(j1.string()).nullish()}).nullish()})).optional(),container:j1.object({id:j1.string().optional(),skills:j1.array(j1.object({type:j1.union([j1.literal("anthropic"),j1.literal("custom")]),skillId:j1.string(),version:j1.string().optional()})).optional()}).optional(),toolStreaming:j1.boolean().optional(),effort:j1.enum(["low","medium","high","xhigh","max"]).optional(),taskBudget:j1.object({type:j1.literal("tokens"),total:j1.number().int().min(20000),remaining:j1.number().int().min(0).optional()}).optional(),speed:j1.enum(["fast","standard"]).optional(),inferenceGeo:j1.enum(["us","global"]).optional(),fallbacks:j1.array(j1.object({model:j1.string(),max_tokens:j1.number().int().optional(),thinking:j1.record(j1.string(),j1.unknown()).optional(),output_config:j1.record(j1.string(),j1.unknown()).optional(),speed:j1.enum(["fast","standard"]).optional()})).optional(),anthropicBeta:j1.array(j1.string()).optional(),contextManagement:j1.object({edits:j1.array(j1.discriminatedUnion("type",[j1.object({type:j1.literal("clear_tool_uses_20250919"),trigger:j1.discriminatedUnion("type",[j1.object({type:j1.literal("input_tokens"),value:j1.number()}),j1.object({type:j1.literal("tool_uses"),value:j1.number()})]).optional(),keep:j1.object({type:j1.literal("tool_uses"),value:j1.number()}).optional(),clearAtLeast:j1.object({type:j1.literal("input_tokens"),value:j1.number()}).optional(),clearToolInputs:j1.boolean().optional(),excludeTools:j1.array(j1.string()).optional()}),j1.object({type:j1.literal("clear_thinking_20251015"),keep:j1.union([j1.literal("all"),j1.object({type:j1.literal("thinking_turns"),value:j1.number()})]).optional()}),j1.object({type:j1.literal("compact_20260112"),trigger:j1.object({type:j1.literal("input_tokens"),value:j1.number()}).optional(),pauseAfterCompaction:j1.boolean().optional(),instructions:j1.string().optional()})]))}).optional()});Yh4=k0(()=>W0(IZ.object({model:IZ.string(),maxUses:IZ.number().optional(),caching:IZ.object({type:IZ.literal("ephemeral"),ttl:IZ.union([IZ.literal("5m"),IZ.literal("1h")])}).optional()}))),fq8=k0(()=>W0(IZ.discriminatedUnion("type",[IZ.object({type:IZ.literal("advisor_result"),text:IZ.string()}),IZ.object({type:IZ.literal("advisor_redacted_result"),encryptedContent:IZ.string()}),IZ.object({type:IZ.literal("advisor_tool_result_error"),errorCode:IZ.string()})]))),Gh4=k0(()=>W0(IZ.object({}).strict())),Jh4=X6({id:"anthropic.advisor_20260301",inputSchema:Gh4,outputSchema:fq8,supportsDeferredResults:!0}),Wh4=k0(()=>W0(u3.object({maxCharacters:u3.number().optional()}))),Hh4=k0(()=>W0(u3.object({command:u3.enum(["view","create","str_replace","insert"]),path:u3.string(),file_text:u3.string().optional(),insert_line:u3.number().int().optional(),new_str:u3.string().optional(),insert_text:u3.string().optional(),old_str:u3.string().optional(),view_range:u3.array(u3.number().int()).optional()}))),Nh4=l4({id:"anthropic.text_editor_20250728",inputSchema:Hh4}),Fh4=k0(()=>W0(d9.object({maxUses:d9.number().optional(),allowedDomains:d9.array(d9.string()).optional(),blockedDomains:d9.array(d9.string()).optional(),userLocation:d9.object({type:d9.literal("approximate"),city:d9.string().optional(),region:d9.string().optional(),country:d9.string().optional(),timezone:d9.string().optional()}).optional()}))),Bh4=k0(()=>W0(d9.array(d9.object({url:d9.string(),title:d9.string().nullable(),pageAge:d9.string().nullable(),encryptedContent:d9.string(),type:d9.literal("web_search_result")})))),Oh4=k0(()=>W0(d9.object({query:d9.string()}))),wh4=X6({id:"anthropic.web_search_20260209",inputSchema:Oh4,outputSchema:Bh4,supportsDeferredResults:!0}),Dh4=k0(()=>W0(m9.object({maxUses:m9.number().optional(),allowedDomains:m9.array(m9.string()).optional(),blockedDomains:m9.array(m9.string()).optional(),userLocation:m9.object({type:m9.literal("approximate"),city:m9.string().optional(),region:m9.string().optional(),country:m9.string().optional(),timezone:m9.string().optional()}).optional()}))),bq8=k0(()=>W0(m9.array(m9.object({url:m9.string(),title:m9.string().nullable(),pageAge:m9.string().nullable(),encryptedContent:m9.string(),type:m9.literal("web_search_result")})))),Eh4=k0(()=>W0(m9.object({query:m9.string()}))),zh4=X6({id:"anthropic.web_search_20250305",inputSchema:Eh4,outputSchema:bq8,supportsDeferredResults:!0}),Ph4=k0(()=>W0(S$.object({maxUses:S$.number().optional(),allowedDomains:S$.array(S$.string()).optional(),blockedDomains:S$.array(S$.string()).optional(),citations:S$.object({enabled:S$.boolean()}).optional(),maxContentTokens:S$.number().optional()}))),Ah4=k0(()=>W0(S$.object({type:S$.literal("web_fetch_result"),url:S$.string(),content:S$.object({type:S$.literal("document"),title:S$.string().nullable(),citations:S$.object({enabled:S$.boolean()}).optional(),source:S$.union([S$.object({type:S$.literal("base64"),mediaType:S$.literal("application/pdf"),data:S$.string()}),S$.object({type:S$.literal("text"),mediaType:S$.literal("text/plain"),data:S$.string()})])}),retrievedAt:S$.string().nullable()}))),Th4=k0(()=>W0(S$.object({url:S$.string()}))),Rh4=X6({id:"anthropic.web_fetch_20260209",inputSchema:Th4,outputSchema:Ah4,supportsDeferredResults:!0}),qh4=k0(()=>W0(C$.object({maxUses:C$.number().optional(),allowedDomains:C$.array(C$.string()).optional(),blockedDomains:C$.array(C$.string()).optional(),citations:C$.object({enabled:C$.boolean()}).optional(),maxContentTokens:C$.number().optional()}))),yq8=k0(()=>W0(C$.object({type:C$.literal("web_fetch_result"),url:C$.string(),content:C$.object({type:C$.literal("document"),title:C$.string().nullable(),citations:C$.object({enabled:C$.boolean()}).optional(),source:C$.union([C$.object({type:C$.literal("base64"),mediaType:C$.literal("application/pdf"),data:C$.string()}),C$.object({type:C$.literal("text"),mediaType:C$.literal("text/plain"),data:C$.string()})])}),retrievedAt:C$.string().nullable()}))),Mh4=k0(()=>W0(C$.object({url:C$.string()}))),Vh4=X6({id:"anthropic.web_fetch_20250910",inputSchema:Mh4,outputSchema:yq8,supportsDeferredResults:!0});gq8=k0(()=>W0(CK.object({type:CK.literal("code_execution_result"),stdout:CK.string(),stderr:CK.string(),return_code:CK.number(),content:CK.array(CK.object({type:CK.literal("code_execution_output"),file_id:CK.string()})).optional().default([])}))),Ch4=k0(()=>W0(CK.object({code:CK.string()}))),_h4=X6({id:"anthropic.code_execution_20250522",inputSchema:Ch4,outputSchema:gq8}),hq8=k0(()=>W0(G8.discriminatedUnion("type",[G8.object({type:G8.literal("code_execution_result"),stdout:G8.string(),stderr:G8.string(),return_code:G8.number(),content:G8.array(G8.object({type:G8.literal("code_execution_output"),file_id:G8.string()})).optional().default([])}),G8.object({type:G8.literal("bash_code_execution_result"),content:G8.array(G8.object({type:G8.literal("bash_code_execution_output"),file_id:G8.string()})),stdout:G8.string(),stderr:G8.string(),return_code:G8.number()}),G8.object({type:G8.literal("bash_code_execution_tool_result_error"),error_code:G8.string()}),G8.object({type:G8.literal("text_editor_code_execution_tool_result_error"),error_code:G8.string()}),G8.object({type:G8.literal("text_editor_code_execution_view_result"),content:G8.string(),file_type:G8.string(),num_lines:G8.number().nullable(),start_line:G8.number().nullable(),total_lines:G8.number().nullable()}),G8.object({type:G8.literal("text_editor_code_execution_create_result"),is_file_update:G8.boolean()}),G8.object({type:G8.literal("text_editor_code_execution_str_replace_result"),lines:G8.array(G8.string()).nullable(),new_lines:G8.number().nullable(),new_start:G8.number().nullable(),old_lines:G8.number().nullable(),old_start:G8.number().nullable()})]))),xh4=k0(()=>W0(G8.discriminatedUnion("type",[G8.object({type:G8.literal("programmatic-tool-call"),code:G8.string()}),G8.object({type:G8.literal("bash_code_execution"),command:G8.string()}),G8.discriminatedUnion("command",[G8.object({type:G8.literal("text_editor_code_execution"),command:G8.literal("view"),path:G8.string()}),G8.object({type:G8.literal("text_editor_code_execution"),command:G8.literal("create"),path:G8.string(),file_text:G8.string().nullish()}),G8.object({type:G8.literal("text_editor_code_execution"),command:G8.literal("str_replace"),path:G8.string(),old_str:G8.string(),new_str:G8.string()})])]))),fh4=X6({id:"anthropic.code_execution_20250825",inputSchema:xh4,outputSchema:hq8,supportsDeferredResults:!0}),uq8=k0(()=>W0(i1.discriminatedUnion("type",[i1.object({type:i1.literal("code_execution_result"),stdout:i1.string(),stderr:i1.string(),return_code:i1.number(),content:i1.array(i1.object({type:i1.literal("code_execution_output"),file_id:i1.string()})).optional().default([])}),i1.object({type:i1.literal("encrypted_code_execution_result"),encrypted_stdout:i1.string(),stderr:i1.string(),return_code:i1.number(),content:i1.array(i1.object({type:i1.literal("code_execution_output"),file_id:i1.string()})).optional().default([])}),i1.object({type:i1.literal("bash_code_execution_result"),content:i1.array(i1.object({type:i1.literal("bash_code_execution_output"),file_id:i1.string()})),stdout:i1.string(),stderr:i1.string(),return_code:i1.number()}),i1.object({type:i1.literal("bash_code_execution_tool_result_error"),error_code:i1.string()}),i1.object({type:i1.literal("text_editor_code_execution_tool_result_error"),error_code:i1.string()}),i1.object({type:i1.literal("text_editor_code_execution_view_result"),content:i1.string(),file_type:i1.string(),num_lines:i1.number().nullable(),start_line:i1.number().nullable(),total_lines:i1.number().nullable()}),i1.object({type:i1.literal("text_editor_code_execution_create_result"),is_file_update:i1.boolean()}),i1.object({type:i1.literal("text_editor_code_execution_str_replace_result"),lines:i1.array(i1.string()).nullable(),new_lines:i1.number().nullable(),new_start:i1.number().nullable(),old_lines:i1.number().nullable(),old_start:i1.number().nullable()})]))),yh4=k0(()=>W0(i1.discriminatedUnion("type",[i1.object({type:i1.literal("programmatic-tool-call"),code:i1.string()}),i1.object({type:i1.literal("bash_code_execution"),command:i1.string()}),i1.discriminatedUnion("command",[i1.object({type:i1.literal("text_editor_code_execution"),command:i1.literal("view"),path:i1.string()}),i1.object({type:i1.literal("text_editor_code_execution"),command:i1.literal("create"),path:i1.string(),file_text:i1.string().nullish()}),i1.object({type:i1.literal("text_editor_code_execution"),command:i1.literal("str_replace"),path:i1.string(),old_str:i1.string(),new_str:i1.string()})])]))),gh4=X6({id:"anthropic.code_execution_20260120",inputSchema:yh4,outputSchema:uq8,supportsDeferredResults:!0}),cq8=k0(()=>W0(o_.array(o_.object({type:o_.literal("tool_reference"),toolName:o_.string()})))),uh4=k0(()=>W0(o_.object({pattern:o_.string(),limit:o_.number().optional()}))),ch4=X6({id:"anthropic.tool_search_regex_20251119",inputSchema:uh4,outputSchema:cq8,supportsDeferredResults:!0});lq8=new Set(["date-time","time","date","duration","email","hostname","uri","ipv4","ipv6","uuid"]),ph4=["minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","minLength","maxLength","pattern","minItems","maxItems","uniqueItems","minProperties","maxProperties","not"];Zu4=k0(()=>W0(j51.object({command:j51.string(),restart:j51.boolean().optional()}))),Xu4=l4({id:"anthropic.bash_20241022",inputSchema:Zu4}),Qu4=k0(()=>W0(P51.object({command:P51.string(),restart:P51.boolean().optional()}))),Yu4=l4({id:"anthropic.bash_20250124",inputSchema:Qu4}),Gu4=k0(()=>W0(tr.object({action:tr.enum(["key","type","mouse_move","left_click","left_click_drag","right_click","middle_click","double_click","screenshot","cursor_position"]),coordinate:tr.array(tr.number().int()).optional(),text:tr.string().optional()}))),Ju4=l4({id:"anthropic.computer_20241022",inputSchema:Gu4}),Ku4=k0(()=>W0(h3.object({action:h3.enum(["key","hold_key","type","cursor_position","mouse_move","left_mouse_down","left_mouse_up","left_click","left_click_drag","right_click","middle_click","double_click","triple_click","scroll","wait","screenshot"]),coordinate:h3.tuple([h3.number().int(),h3.number().int()]).optional(),duration:h3.number().optional(),scroll_amount:h3.number().optional(),scroll_direction:h3.enum(["up","down","left","right"]).optional(),start_coordinate:h3.tuple([h3.number().int(),h3.number().int()]).optional(),text:h3.string().optional()}))),Wu4=l4({id:"anthropic.computer_20250124",inputSchema:Ku4}),Hu4=k0(()=>W0(k7.object({action:k7.enum(["key","hold_key","type","cursor_position","mouse_move","left_mouse_down","left_mouse_up","left_click","left_click_drag","right_click","middle_click","double_click","triple_click","scroll","wait","screenshot","zoom"]),coordinate:k7.tuple([k7.number().int(),k7.number().int()]).optional(),duration:k7.number().optional(),region:k7.tuple([k7.number().int(),k7.number().int(),k7.number().int(),k7.number().int()]).optional(),scroll_amount:k7.number().optional(),scroll_direction:k7.enum(["up","down","left","right"]).optional(),start_coordinate:k7.tuple([k7.number().int(),k7.number().int()]).optional(),text:k7.string().optional()}))),Nu4=l4({id:"anthropic.computer_20251124",inputSchema:Hu4}),Uu4=k0(()=>W0(m$.discriminatedUnion("command",[m$.object({command:m$.literal("view"),path:m$.string(),view_range:m$.tuple([m$.number(),m$.number()]).optional()}),m$.object({command:m$.literal("create"),path:m$.string(),file_text:m$.string()}),m$.object({command:m$.literal("str_replace"),path:m$.string(),old_str:m$.string(),new_str:m$.string()}),m$.object({command:m$.literal("insert"),path:m$.string(),insert_line:m$.number(),insert_text:m$.string()}),m$.object({command:m$.literal("delete"),path:m$.string()}),m$.object({command:m$.literal("rename"),old_path:m$.string(),new_path:m$.string()})]))),Fu4=l4({id:"anthropic.memory_20250818",inputSchema:Uu4}),Bu4=k0(()=>W0(IH.object({command:IH.enum(["view","create","str_replace","insert","undo_edit"]),path:IH.string(),file_text:IH.string().optional(),insert_line:IH.number().int().optional(),new_str:IH.string().optional(),insert_text:IH.string().optional(),old_str:IH.string().optional(),view_range:IH.array(IH.number().int()).optional()}))),Ou4=l4({id:"anthropic.text_editor_20241022",inputSchema:Bu4}),wu4=k0(()=>W0(qH.object({command:qH.enum(["view","create","str_replace","insert","undo_edit"]),path:qH.string(),file_text:qH.string().optional(),insert_line:qH.number().int().optional(),new_str:qH.string().optional(),insert_text:qH.string().optional(),old_str:qH.string().optional(),view_range:qH.array(qH.number().int()).optional()}))),Lu4=l4({id:"anthropic.text_editor_20250124",inputSchema:wu4}),Du4=k0(()=>W0(MH.object({command:MH.enum(["view","create","str_replace","insert"]),path:MH.string(),file_text:MH.string().optional(),insert_line:MH.number().int().optional(),new_str:MH.string().optional(),insert_text:MH.string().optional(),old_str:MH.string().optional(),view_range:MH.array(MH.number().int()).optional()}))),Eu4=l4({id:"anthropic.text_editor_20250429",inputSchema:Du4}),zu4=k0(()=>W0(r_.array(r_.object({type:r_.literal("tool_reference"),toolName:r_.string()})))),ju4=k0(()=>W0(r_.object({query:r_.string(),limit:r_.number().optional()}))),Pu4=X6({id:"anthropic.tool_search_bm25_20251119",inputSchema:ju4,outputSchema:zu4,supportsDeferredResults:!0}),Tu4={advisor_20260301:Kh4,bash_20241022:Xu4,bash_20250124:Yu4,codeExecution_20250522:vh4,codeExecution_20250825:bh4,codeExecution_20260120:hh4,computer_20241022:Ju4,computer_20250124:Wu4,computer_20251124:Nu4,memory_20250818:Fu4,textEditor_20241022:Ou4,textEditor_20250124:Lu4,textEditor_20250429:Eu4,textEditor_20250728:Uh4,webFetch_20250910:kh4,webFetch_20260209:Ih4,webSearch_20250305:jh4,webSearch_20260209:Lh4,toolSearchRegex_20251119:lh4,toolSearchBm25_20251119:Au4};f1Z=or()});import{z as sU}from"zod/v4";import{z as rr}from"zod/v4";import{z as RX}from"zod/v4";import{z as $1}from"zod/v4";import{z as z$}from"zod/v4";import{z as Hu}from"zod/v4";import{z as ou4}from"zod/v4";import{z as ar}from"zod/v4";import{z as $c4}from"zod/v4";import{z as a_}from"zod/v4";import{z as Yc4}from"zod/v4";import{z as R51}from"zod/v4";import{z as s_}from"zod/v4";import{z as j9}from"zod/v4";import{z as R0}from"zod/v4";import{z as a1}from"zod/v4";function mq8($){var Z,X,Q,Y;if($==null)return{inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0},raw:void 0};let G=(Z=$.promptTokenCount)!=null?Z:0,J=(X=$.candidatesTokenCount)!=null?X:0,K=(Q=$.cachedContentTokenCount)!=null?Q:0,W=(Y=$.thoughtsTokenCount)!=null?Y:0;return{inputTokens:{total:G,noCache:G-K,cacheRead:K,cacheWrite:void 0},outputTokens:{total:J+W,text:J,reasoning:W},raw:$}}function _K($,Z=!0){if($==null)return;if(Cu4($)){if(Z)return;if(typeof $==="object"&&$.description)return{type:"object",description:$.description};return{type:"object"}}if(typeof $==="boolean")return{type:"boolean",properties:{}};let{type:X,description:Q,required:Y,properties:G,items:J,allOf:K,anyOf:W,oneOf:H,format:N,const:U,minLength:F,enum:B}=$,O={};if(Q)O.description=Q;if(Y)O.required=Y;if(N)O.format=N;if(U!==void 0)O.enum=[U];if(X)if(Array.isArray(X)){let L=X.includes("null"),D=X.filter((E)=>E!=="null");if(D.length===0)O.type="null";else if(O.anyOf=D.map((E)=>({type:E})),L)O.nullable=!0}else O.type=X;if(B!==void 0)O.enum=B;if(G!=null)O.properties=Object.entries(G).reduce((L,[D,E])=>{return L[D]=_K(E,!1),L},{});if(J)O.items=Array.isArray(J)?J.map((L)=>_K(L,!1)):_K(J,!1);if(K)O.allOf=K.map((L)=>_K(L,!1));if(W)if(W.some((L)=>typeof L==="object"&&(L==null?void 0:L.type)==="null")){let L=W.filter((D)=>!(typeof D==="object"&&(D==null?void 0:D.type)==="null"));if(L.length===1){let D=_K(L[0],!1);if(typeof D==="object")O.nullable=!0,Object.assign(O,D)}else O.anyOf=L.map((D)=>_K(D,!1)),O.nullable=!0}else O.anyOf=W.map((L)=>_K(L,!1));if(H)O.oneOf=H.map((L)=>_K(L,!1));if(F!==void 0)O.minLength=F;return O}function Cu4($){return $!=null&&typeof $==="object"&&$.type==="object"&&($.properties==null||Object.keys($.properties).length===0)&&!$.additionalProperties}function iq8($,Z){let X=[Z,"google","googleVertex","vertex"].filter((Q,Y,G)=>{return G.indexOf(Q)===Y});for(let Q of X){let Y=$==null?void 0:$[Q];if(Y!=null)return Y}}function xu4($){let Z=vu4.exec($);if(Z==null)return;return{mediaType:Z[1],data:Z[2]}}function fu4($){let Z=xu4($);if(Z==null)return;return{inlineData:{mimeType:Z.mediaType,data:Z.data}}}function bu4($,Z,X,Q){let Y=[],G=[];for(let J of X)switch(J.type){case"text":{G.push(J.text);break}case"image-data":case"file-data":{Y.push({inlineData:{mimeType:J.mediaType,data:J.data}});break}case"image-url":case"file-url":{let K=fu4(J.url);if(K!=null)Y.push(K);else G.push(JSON.stringify(J));break}default:{G.push(JSON.stringify(J));break}}$.push({functionResponse:{...Q!=null?{id:Q}:{},name:Z,response:{name:Z,content:G.length>0?G.join(`
2368
+ `);U51=i({name:"TASK_ADD_REPO",description:"Clone one of this organization's repositories into your working directory. "+"Your working directory is EMPTY until you call this \u2014 do not look for "+"files, and do not run git, before it returns. Call it once, with the repository the task is about; it waits for the checkout and returns the repository root listing, so you can start reading files immediately after. `git` and `gh` are authenticated once it returns. Call TASK_ADD_REPO with no arguments to list the repositories available.",annotations:{title:"Add Repository",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0},inputSchema:y3.object({connectionId:y3.string().optional().describe("connectionId of the repository to clone. Omit to list the available repositories.")}),outputSchema:y3.object({success:y3.boolean(),repositories:y3.array(y3.object({connectionId:y3.string(),repo:y3.string()})).optional(),repo:y3.string().optional(),cloned:y3.boolean().optional(),files:y3.string().optional(),message:y3.string()}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=X0(Z),Q=E1(Z);if(!Q)throw Error("User ID required");let{threadId:Y}=WP0(),G=await cg4(Z,X.id),J=$.connectionId?G.find((q)=>q.connectionId===$.connectionId):void 0;if(!J){let q=G.map((M)=>({connectionId:M.connectionId,repo:`${M.owner}/${M.repo}`}));return{success:!1,repositories:q,message:$.connectionId?`No imported repository for connectionId "${$.connectionId}". Pick one of the repositories listed.`:q.length===0?"This organization has no repositories imported, so none can be cloned.":"Pick a repository and call TASK_ADD_REPO again with its connectionId."}}let K=await Z.storage.threads.get(Y);if(!K)throw Error(`Thread not found: ${Y}`);let W=await aj0(Z,{threadId:Y}),H=await rU(Z,W,Q),{provider:N,kind:U}=await PQ(Z,{userId:H,branch:W,virtualMcpMetadata:null}),F=await yg4(Z,Y,H,W,U);if(!F)throw Error(`No sandbox is registered for this run (thread ${Y}), so there is nowhere to clone into.`);await _w({ctx:Z,connectionId:J.connectionId,organizationId:X.id,forceRefresh:!0,onLegacyMintError:(q)=>console.error("[TASK_ADD_REPO] legacy repo-scoped mint failed",{connectionId:J.connectionId,error:q.message})});let{cloneUrl:B,gitUserName:O,gitUserEmail:L}=await vw(J.connectionId,J.owner,J.repo,Z.db,Z.vault,{bufferMs:vg4});await Z.storage.threads.update(Y,{metadata:{...K.metadata??{},githubRepo:{url:`https://github.com/${J.owner}/${J.repo}`,owner:J.owner,name:J.repo,installationId:J.installationId,connectionId:J.connectionId}},updated_by:Q});let D=QP0({branch:W,derivedRef:oU(W),recordedHeadRef:null,sticky:!1}),E=await N.proxyDaemonRequest(F.sandboxHandle,"/_sandbox/config",{method:"PUT",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify({git:{repository:{cloneUrl:B,branch:D,repoName:`${J.owner}/${J.repo}`},identity:{userName:O,userEmail:L}}})});if(!E.ok)throw Error(`the sandbox rejected the repository (${E.status} ${E.statusText})`);await N.proxyDaemonRequest(F.sandboxHandle,"/_sandbox/setup/clone",{method:"POST",headers:new Headers({"content-type":"application/json"}),body:"{}"}).catch((q)=>{console.warn("[TASK_ADD_REPO] explicit clone kick failed",q)});let z=Date.now()+Uq8,j=!1,P="",A=0,I=null;while(Date.now()<z){let q=await Bq8(N,F.sandboxHandle,Y,"if git rev-parse HEAD >/dev/null 2>&1; then echo __CLONED__; fi; ls -A 2>/dev/null").catch(()=>null);if(!q){if(++A>=gg4)break;await z8(Fq8);continue}A=0;let M=hg4(q.stdout);if(M.cloned&&M.listing===I){j=!0,P=M.listing;break}I=M.cloned?M.listing:null,await z8(Fq8)}if(j)await Bq8(N,F.sandboxHandle,Y,ug4).catch((q)=>console.warn("[TASK_ADD_REPO] gh auth setup failed",q));return{success:j,repo:`${J.owner}/${J.repo}`,cloned:j,files:P,message:j?`${J.owner}/${J.repo} is checked out at your working directory on branch ${D}. \`git\` and \`gh\` are authenticated. Start working.`:`The clone of ${J.owner}/${J.repo} did not finish within ${Math.round(Uq8/1000)}s. It may still be in progress \u2014 check your working directory before calling this again.`}}})});import{z as G8}from"zod";var kK,t_,lg4,dg4,wq8,Ku,mg4,ig4,Lq8;var SK=w(()=>{y9();kK=G8.enum(["triage","todo","in_progress","in_review","done","archived"]),t_=G8.enum(["none","low","medium","high","urgent"]),lg4=G8.object({threadId:G8.string(),virtualMcpId:G8.string().nullable(),status:G8.enum(["in_progress","requires_action","failed","completed","expired"]).nullable(),title:G8.string().nullable(),lastMessage:G8.string().nullable(),hasPreview:G8.boolean(),failureKind:G8.string().nullable(),hasMessages:G8.boolean(),costUsd:G8.number().nullable(),createdAt:G8.string()}),dg4=G8.object({id:G8.string(),name:G8.string(),color:G8.string().nullable().describe('Hex color, e.g. "#3b82f6"'),createdBy:G8.string(),createdAt:G8.string().datetime()}),wq8=G8.object({url:G8.string(),number:G8.number(),repoOwner:G8.string(),repoName:G8.string(),createdAt:G8.string(),title:G8.string().nullable(),body:G8.string().nullable(),state:G8.enum(["open","closed"]).nullable(),draft:G8.boolean().nullable(),merged:G8.boolean().nullable(),mergeable:G8.boolean().nullable(),checksStatus:G8.enum(["pending","passing","failing"]).nullable(),checks:G8.array(G8.object({name:G8.string(),status:G8.string(),conclusion:G8.string().nullable(),detailsUrl:G8.string().nullable(),summary:G8.string().nullable()})),previewUrl:G8.string().nullable()}),Ku=G8.object({id:G8.string(),organizationId:G8.string(),title:G8.string(),description:G8.string().nullable(),status:kK,priority:t_,assigneeId:G8.string().nullable(),assignedBy:G8.string().nullable(),repo:G8.string().nullable(),dueDate:G8.string().datetime().nullable(),sortOrder:G8.number(),retryAttempts:G8.number(),threads:G8.array(lg4),tags:G8.array(dg4),createdBy:G8.string(),createdAt:G8.string().datetime(),updatedBy:G8.string(),updatedAt:G8.string().datetime()}),mg4=["created","status_changed","assignee_changed","priority_changed","due_date_changed","title_changed","description_changed","tags_changed","review_requested","review_approved","review_changes_requested","merge_conflict_resolution","merge_failed"],ig4=G8.enum(mg4),Lq8=G8.object({id:G8.string(),taskBoardItemId:G8.string(),action:ig4,actorId:G8.string().nullable(),data:G8.record(G8.string(),G8.unknown()),occurredAt:G8.string().datetime()})});async function HP0($,Z,X){if(X===G4)return;let{members:Q}=await $.boundAuth.organization.listMembers({organizationId:Z,filterField:"userId",filterValue:X});if(!Q.some((Y)=>Y.userId===X))throw Error("assigneeId is not a member of the organization")}var F51=w(()=>{SK()});function zq8($){let Z={};for(let[X,Q]of Object.entries($)){if(X.startsWith(ng4))continue;Z[X]=Q}return Z}function NP0($){return{taskBoardItemId:$.id,...JY($)&&{[Dq8]:Eq8}}}function pg4($){return $?.[Dq8]===Eq8}function tg4($){if(/[:\s]/.test($))throw Error("organization id unsuitable for the subsidy key scheme");return`subsidy:${$}`}async function og4($,Z){let X=o0();try{let Q=await $.storage.subsidizedGatewayKeys.get(Z);if(Q)return Q;let Y=$.auth?.user?.id;if(Y&&X.aiGatewayEnabled&&X.studioProvisionSecretKey&&Qw.provisionKey){let G=await _W(Y,$.auth?.user?.email),J=await Qw.provisionKey(G,tg4(Z));return await $.storage.subsidizedGatewayKeys.put(Z,J),J}}catch(Q){console.error("[subsidized-runs] subsidy key unavailable \u2014 run stays on the org's key:",Q)}return}async function jq8($,Z,X){if(!o0().taskQuotaEnforced)return;if(!pg4(X))return;let Q=X?.taskBoardItemId;if(!Q)return;let Y=await $.storage.taskBoard.getById(Q,Z);if(!Y||!JY(Y))return;if(!await JB8($,Q))return;return await og4($,Z)}function Pq8($,Z){if(!Z)return $;if($.providerId!=="deco")return $;return{...$,apiKey:Z}}var ng4="srv.",Dq8="srv.billing",Eq8="subscription";var mr=w(()=>{SG0();$O();C8();wK()});function FP0($){let Z=$?.runClass;return Z&&Z in B51?B51[Z]:B51.interactive}var B51,UP0="runClass";var ir=w(()=>{B51={interactive:10,reviewer:20,retry:30,new_task:40}});async function O51($,Z,X){let Q;try{return await Promise.race([$.aiProviders.listModels(Z,X),new Promise((G,J)=>{Q=setTimeout(()=>J(Error("listModels timeout")),rg4)})])}finally{if(Q)clearTimeout(Q)}}function ag4($,Z){switch($){case"fast":return Z.chat.fast;case"smart":return Z.chat.smart;case"thinking":return Z.chat.thinking;case"image":return Z.image;case"web_search":return Z.webSearch;case"deep_research":return Z.deepResearch}}function w51($,Z,X){let Q=$.find((Y)=>Y.modelId===Z);return{title:Q?.title??X??Z,providerId:Q?.providerId,capabilities:Q?.capabilities,limits:Q?.limits??null}}async function TX($,Z,X){let Q=$.organization?.id;if(!Q)throw Error("resolveTier called without an organization");let G=(await $.storage.organizationSettings.get(Q))?.simple_mode?.tiers?.[Z]??null,J=$.auth?.user?.id,K=ww.safeParse(Z),W=X?.applyUserPrefs&&K.success&&J?(await $.storage.userModelPreferences.get(J,Q))?.tiers?.[K.data]??null:null,H=(await $.storage.aiProviderKeys.list({organizationId:Q})).filter((O)=>hE(O.providerId));for(let O of[W,G])if(O&&H.some((L)=>L.id===O.keyId)){let L=await O51($,O.keyId,Q).catch(()=>[]);return{credentialId:O.keyId,modelId:O.modelId,modelMeta:w51(L,O.modelId,O.title)}}if(H.length===0)throw new Wu(Z);let N={};await Promise.all(H.map(async(O)=>{N[O.id]=await O51($,O.id,Q).catch(()=>[])}));let U=H.map((O)=>({id:O.id,providerId:O.providerId,label:O.label,presetId:O.presetId,createdBy:O.createdBy,createdAt:O.createdAt})),F=A98(U,N),B=ag4(Z,F);if(!B)throw new Wu(Z);return{credentialId:B.keyId,modelId:B.modelId,modelMeta:w51(N[B.keyId]??[],B.modelId,B.title)}}async function Aq8($,Z,X){let Q=$.organization?.id;if(!Q)throw Error("resolveSpecificModel called without an organization");let Y=await $.storage.aiProviderKeys.findById(Z,Q).catch((J)=>{if(J instanceof Error&&J.message==="Provider key not found")throw new nr(`AI provider credential "${Z}" was not found`,{cause:J});throw J});if(!hE(Y.providerId))throw new nr(`AI provider credential "${Z}" uses native-only provider "${Y.providerId}" and cannot run a hosted model`);let G=await O51($,Z,Q).catch(()=>[]);return{credentialId:Z,modelId:X,modelMeta:w51(G,X)}}async function g3($,Z){try{return await TX($,Z)}catch(X){if(X instanceof Wu)return null;return console.warn(`[resolveTier] tier "${Z}" resolution failed:`,X),null}}var Wu,nr,rg4=5000;var sw=w(()=>{QY();A6();Wu=class Wu extends Error{tier;constructor($){super(`No model available for tier "${$}". Connect a provider or configure the tier in organization settings.`);this.tier=$;this.name="TierUnavailableError"}};nr=class nr extends Error{constructor($,Z){super($,Z);this.name="SpecificModelCredentialUnavailableError"}}});function Tq8($){return $ instanceof RH||typeof $==="object"&&$!==null&&$.permanent===!0}var RH;var L51=w(()=>{RH=class RH extends Error{permanent=!0;code;constructor($,Z){super(Z);this.name="PermanentRunError",this.code=$}}});import{z as pr}from"zod/v4";import{z as V}from"zod/v4";import{z as j1}from"zod/v4";import{z as IZ}from"zod/v4";import{z as u3}from"zod/v4";import{z as d9}from"zod/v4";import{z as m9}from"zod/v4";import{z as S$}from"zod/v4";import{z as C$}from"zod/v4";import{z as CK}from"zod/v4";import{z as J8}from"zod/v4";import{z as i1}from"zod/v4";import{z as o_}from"zod/v4";import{z as j51}from"zod/v4";import{z as P51}from"zod/v4";import{z as tr}from"zod/v4";import{z as h3}from"zod/v4";import{z as k7}from"zod/v4";import{z as m$}from"zod/v4";import{z as IH}from"zod/v4";import{z as qH}from"zod/v4";import{z as MH}from"zod/v4";import{z as r_}from"zod/v4";function Qh4($){var Z;let X=$==null?void 0:$.anthropic;return(Z=X==null?void 0:X.cacheControl)!=null?Z:X==null?void 0:X.cache_control}async function Sh4({tools:$,toolChoice:Z,disableParallelToolUse:X,cacheControlValidator:Q,supportsStructuredOutput:Y,supportsStrictTools:G,defaultEagerInputStreaming:J=!1}){var K,W;$=($==null?void 0:$.length)?$:void 0;let H=[],N=new Set,U=Q||new A51;if($==null)return{tools:void 0,toolChoice:void 0,toolWarnings:H,betas:N};let F=[];for(let O of $)switch(O.type){case"function":{let L=U.getCacheControl(O.providerOptions,{type:"tool definition",canCache:!0}),D=(K=O.providerOptions)==null?void 0:K.anthropic,E=(W=D==null?void 0:D.eagerInputStreaming)!=null?W:J,z=D==null?void 0:D.deferLoading,j=D==null?void 0:D.allowedCallers;if(!G&&O.strict!=null)H.push({type:"unsupported",feature:"strict",details:`Tool '${O.name}' has strict: ${O.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`});if(F.push({name:O.name,description:O.description,input_schema:O.inputSchema,cache_control:L,...E?{eager_input_streaming:!0}:{},...G===!0&&O.strict!=null?{strict:O.strict}:{},...z!=null?{defer_loading:z}:{},...j!=null?{allowed_callers:j}:{},...O.inputExamples!=null?{input_examples:O.inputExamples.map((P)=>P.input)}:{}}),Y===!0)N.add("structured-outputs-2025-11-13");if(O.inputExamples!=null||j!=null)N.add("advanced-tool-use-2025-11-20");break}case"provider":{switch(O.id){case"anthropic.code_execution_20250522":{N.add("code-execution-2025-05-22"),F.push({type:"code_execution_20250522",name:"code_execution",cache_control:void 0});break}case"anthropic.code_execution_20250825":{N.add("code-execution-2025-08-25"),F.push({type:"code_execution_20250825",name:"code_execution"});break}case"anthropic.code_execution_20260120":{F.push({type:"code_execution_20260120",name:"code_execution"});break}case"anthropic.computer_20250124":{N.add("computer-use-2025-01-24"),F.push({name:"computer",type:"computer_20250124",display_width_px:O.args.displayWidthPx,display_height_px:O.args.displayHeightPx,display_number:O.args.displayNumber,cache_control:void 0});break}case"anthropic.computer_20251124":{N.add("computer-use-2025-11-24"),F.push({name:"computer",type:"computer_20251124",display_width_px:O.args.displayWidthPx,display_height_px:O.args.displayHeightPx,display_number:O.args.displayNumber,enable_zoom:O.args.enableZoom,cache_control:void 0});break}case"anthropic.computer_20241022":{N.add("computer-use-2024-10-22"),F.push({name:"computer",type:"computer_20241022",display_width_px:O.args.displayWidthPx,display_height_px:O.args.displayHeightPx,display_number:O.args.displayNumber,cache_control:void 0});break}case"anthropic.text_editor_20250124":{N.add("computer-use-2025-01-24"),F.push({name:"str_replace_editor",type:"text_editor_20250124",cache_control:void 0});break}case"anthropic.text_editor_20241022":{N.add("computer-use-2024-10-22"),F.push({name:"str_replace_editor",type:"text_editor_20241022",cache_control:void 0});break}case"anthropic.text_editor_20250429":{N.add("computer-use-2025-01-24"),F.push({name:"str_replace_based_edit_tool",type:"text_editor_20250429",cache_control:void 0});break}case"anthropic.text_editor_20250728":{let L=await n8({value:O.args,schema:Wh4});F.push({name:"str_replace_based_edit_tool",type:"text_editor_20250728",max_characters:L.maxCharacters,cache_control:void 0});break}case"anthropic.bash_20250124":{N.add("computer-use-2025-01-24"),F.push({name:"bash",type:"bash_20250124",cache_control:void 0});break}case"anthropic.bash_20241022":{N.add("computer-use-2024-10-22"),F.push({name:"bash",type:"bash_20241022",cache_control:void 0});break}case"anthropic.memory_20250818":{N.add("context-management-2025-06-27"),F.push({name:"memory",type:"memory_20250818"});break}case"anthropic.web_fetch_20250910":{N.add("web-fetch-2025-09-10");let L=await n8({value:O.args,schema:qh4});F.push({type:"web_fetch_20250910",name:"web_fetch",max_uses:L.maxUses,allowed_domains:L.allowedDomains,blocked_domains:L.blockedDomains,citations:L.citations,max_content_tokens:L.maxContentTokens,cache_control:void 0});break}case"anthropic.web_fetch_20260209":{N.add("code-execution-web-tools-2026-02-09");let L=await n8({value:O.args,schema:Ph4});F.push({type:"web_fetch_20260209",name:"web_fetch",max_uses:L.maxUses,allowed_domains:L.allowedDomains,blocked_domains:L.blockedDomains,citations:L.citations,max_content_tokens:L.maxContentTokens,cache_control:void 0});break}case"anthropic.web_search_20250305":{let L=await n8({value:O.args,schema:Dh4});F.push({type:"web_search_20250305",name:"web_search",max_uses:L.maxUses,allowed_domains:L.allowedDomains,blocked_domains:L.blockedDomains,user_location:L.userLocation,cache_control:void 0});break}case"anthropic.web_search_20260209":{N.add("code-execution-web-tools-2026-02-09");let L=await n8({value:O.args,schema:Fh4});F.push({type:"web_search_20260209",name:"web_search",max_uses:L.maxUses,allowed_domains:L.allowedDomains,blocked_domains:L.blockedDomains,user_location:L.userLocation,cache_control:void 0});break}case"anthropic.tool_search_regex_20251119":{F.push({type:"tool_search_tool_regex_20251119",name:"tool_search_tool_regex"});break}case"anthropic.tool_search_bm25_20251119":{F.push({type:"tool_search_tool_bm25_20251119",name:"tool_search_tool_bm25"});break}case"anthropic.advisor_20260301":{N.add("advisor-tool-2026-03-01");let L=await n8({value:O.args,schema:Yh4});F.push({type:"advisor_20260301",name:"advisor",model:L.model,...L.maxUses!==void 0&&{max_uses:L.maxUses},...L.caching!==void 0&&{caching:L.caching}});break}default:{H.push({type:"unsupported",feature:`provider-defined tool ${O.id}`});break}}break}default:{H.push({type:"unsupported",feature:`tool ${O}`});break}}if(Z==null)return{tools:F,toolChoice:X?{type:"auto",disable_parallel_tool_use:X}:void 0,toolWarnings:H,betas:N};let B=Z.type;switch(B){case"auto":return{tools:F,toolChoice:{type:"auto",disable_parallel_tool_use:X},toolWarnings:H,betas:N};case"required":return{tools:F,toolChoice:{type:"any",disable_parallel_tool_use:X},toolWarnings:H,betas:N};case"none":return{tools:void 0,toolChoice:void 0,toolWarnings:H,betas:N};case"tool":return{tools:F,toolChoice:{type:"tool",name:Z.toolName,disable_parallel_tool_use:X},toolWarnings:H,betas:N};default:throw new c4({functionality:`tool choice type: ${B}`})}}function Vq8({usage:$,rawUsage:Z}){var X,Q,Y;let G=(X=$.cache_creation_input_tokens)!=null?X:0,J=(Q=$.cache_read_input_tokens)!=null?Q:0,K,W,H=(Y=$.iterations)==null?void 0:Y.some((N)=>N.type==="fallback_message");if($.iterations&&$.iterations.length>0&&!H){let N=$.iterations.filter((U)=>U.type==="compaction"||U.type==="message");if(N.length>0){let U=N.reduce((F,B)=>({input:F.input+B.input_tokens,output:F.output+B.output_tokens}),{input:0,output:0});K=U.input,W=U.output}else K=$.input_tokens,W=$.output_tokens}else K=$.input_tokens,W=$.output_tokens;return{inputTokens:{total:K+G+J,noCache:K,cacheRead:J,cacheWrite:G},outputTokens:{total:W,text:void 0,reasoning:void 0},raw:Z!=null?Z:$}}function dh4($){if(typeof $==="string")return new TextDecoder().decode(g9($));if($ instanceof Uint8Array)return new TextDecoder().decode($);if($ instanceof URL)throw new c4({functionality:"URL-based text documents are not supported for citations"});throw new c4({functionality:`unsupported data type for text documents: ${typeof $}`})}function D51($){return $ instanceof URL||mh4($)}function mh4($){return typeof $==="string"&&/^https?:\/\//i.test($)}function E51($){return $ instanceof URL?$.toString():$}async function kq8($){if(typeof $==="string"){let Z=await $7({text:$});if(Z.success&&typeof Z.value==="object"&&Z.value!==null)return Z.value;return{errorCode:"unavailable"}}if(typeof $==="object"&&$!==null)return $;return{}}async function ih4({prompt:$,sendReasoning:Z,warnings:X,cacheControlValidator:Q,toolNameMapping:Y}){var G,J,K,W,H,N,U,F,B,O,L,D,E,z,j,P,A,I,q,M,S;let d=new Set,f=nh4($),y=Q||new A51,o=void 0,b=[];async function r(E0){var Z0,e;let A0=await J4({provider:"anthropic",providerOptions:E0,schema:Iq8});return(e=(Z0=A0==null?void 0:A0.citations)==null?void 0:Z0.enabled)!=null?e:!1}async function B0(E0){let Z0=await J4({provider:"anthropic",providerOptions:E0,schema:Iq8});return{title:Z0==null?void 0:Z0.title,context:Z0==null?void 0:Z0.context}}for(let E0=0;E0<f.length;E0++){let Z0=f[E0],e=E0===f.length-1,A0=Z0.type;switch(A0){case"system":{let Y0=Z0.messages.map(({content:q0,providerOptions:t0})=>({type:"text",text:q0,cache_control:y.getCacheControl(t0,{type:"system message",canCache:!0})}));if(o==null)o=Y0;else b.push({role:"system",content:Y0}),d.add("mid-conversation-system-2026-04-07");break}case"user":{let Y0=[];for(let q0 of Z0.messages){let{role:t0,content:d0}=q0;switch(t0){case"user":{for(let s0=0;s0<d0.length;s0++){let H0=d0[s0],V0=s0===d0.length-1,S0=(G=y.getCacheControl(H0.providerOptions,{type:"user message part",canCache:!0}))!=null?G:V0?y.getCacheControl(q0.providerOptions,{type:"user message",canCache:!0}):void 0;switch(H0.type){case"text":{Y0.push({type:"text",text:H0.text,cache_control:S0});break}case"file":{if(H0.mediaType.startsWith("image/"))Y0.push({type:"image",source:D51(H0.data)?{type:"url",url:E51(H0.data)}:{type:"base64",media_type:H0.mediaType==="image/*"?"image/jpeg":H0.mediaType,data:AZ(H0.data)},cache_control:S0});else if(H0.mediaType==="application/pdf"){d.add("pdfs-2024-09-25");let I0=await r(H0.providerOptions),Q0=await B0(H0.providerOptions);Y0.push({type:"document",source:D51(H0.data)?{type:"url",url:E51(H0.data)}:{type:"base64",media_type:"application/pdf",data:AZ(H0.data)},title:(J=Q0.title)!=null?J:H0.filename,...Q0.context&&{context:Q0.context},...I0&&{citations:{enabled:!0}},cache_control:S0})}else if(H0.mediaType==="text/plain"){let I0=await r(H0.providerOptions),Q0=await B0(H0.providerOptions);Y0.push({type:"document",source:D51(H0.data)?{type:"url",url:E51(H0.data)}:{type:"text",media_type:"text/plain",data:dh4(H0.data)},title:(K=Q0.title)!=null?K:H0.filename,...Q0.context&&{context:Q0.context},...I0&&{citations:{enabled:!0}},cache_control:S0})}else throw new c4({functionality:`media type: ${H0.mediaType}`});break}}}break}case"tool":{for(let s0=0;s0<d0.length;s0++){let H0=d0[s0];if(H0.type==="tool-approval-response")continue;let V0=H0.output,S0="providerOptions"in V0?V0.providerOptions:V0.type==="content"?(W=V0.value.find((g0)=>g0.providerOptions!=null))==null?void 0:W.providerOptions:void 0,I0=s0===d0.length-1,Q0=(N=(H=y.getCacheControl(H0.providerOptions,{type:"tool result part",canCache:!0}))!=null?H:y.getCacheControl(S0,{type:"tool result output",canCache:!0}))!=null?N:I0?y.getCacheControl(q0.providerOptions,{type:"tool result message",canCache:!0}):void 0,N0;switch(V0.type){case"content":N0=V0.value.map((g0)=>{var O0;switch(g0.type){case"text":return{type:"text",text:g0.text};case"image-data":return{type:"image",source:{type:"base64",media_type:g0.mediaType,data:g0.data}};case"image-url":return{type:"image",source:{type:"url",url:g0.url}};case"file-url":return{type:"document",source:{type:"url",url:g0.url}};case"file-data":{if(g0.mediaType==="application/pdf")return d.add("pdfs-2024-09-25"),{type:"document",source:{type:"base64",media_type:g0.mediaType,data:g0.data}};X.push({type:"other",message:`unsupported tool content part type: ${g0.type} with media type: ${g0.mediaType}`});return}case"custom":{let P0=(O0=g0.providerOptions)==null?void 0:O0.anthropic;if((P0==null?void 0:P0.type)==="tool-reference")return{type:"tool_reference",tool_name:P0.toolName};X.push({type:"other",message:"unsupported custom tool content part"});return}default:{X.push({type:"other",message:`unsupported tool content part type: ${g0.type}`});return}}}).filter($j);break;case"text":case"error-text":N0=V0.value;break;case"execution-denied":N0=(U=V0.reason)!=null?U:"Tool execution denied.";break;case"json":case"error-json":default:N0=JSON.stringify(V0.value);break}Y0.push({type:"tool_result",tool_use_id:H0.toolCallId,content:N0,is_error:V0.type==="error-text"||V0.type==="error-json"?!0:void 0,cache_control:Q0})}break}default:throw Error(`Unsupported role: ${t0}`)}}b.push({role:"user",content:Y0});break}case"assistant":{let Y0=[],q0=new Set;for(let t0=0;t0<Z0.messages.length;t0++){let d0=Z0.messages[t0],s0=t0===Z0.messages.length-1,{content:H0}=d0;for(let V0=0;V0<H0.length;V0++){let S0=H0[V0],I0=V0===H0.length-1,Q0=(F=y.getCacheControl(S0.providerOptions,{type:"assistant message part",canCache:!0}))!=null?F:I0?y.getCacheControl(d0.providerOptions,{type:"assistant message",canCache:!0}):void 0;switch(S0.type){case"text":{let N0=(B=S0.providerOptions)==null?void 0:B.anthropic;if((N0==null?void 0:N0.type)==="compaction")Y0.push({type:"compaction",content:S0.text,cache_control:Q0});else Y0.push({type:"text",text:e&&s0&&I0?S0.text.trim():S0.text,cache_control:Q0});break}case"reasoning":{if(Z){let N0=await J4({provider:"anthropic",providerOptions:S0.providerOptions,schema:Xh4});if(N0!=null)if(N0.signature!=null)y.getCacheControl(S0.providerOptions,{type:"thinking block",canCache:!1}),Y0.push({type:"thinking",thinking:S0.text,signature:N0.signature});else if(N0.redactedData!=null)y.getCacheControl(S0.providerOptions,{type:"redacted thinking block",canCache:!1}),Y0.push({type:"redacted_thinking",data:N0.redactedData});else X.push({type:"other",message:"unsupported reasoning metadata"});else X.push({type:"other",message:"unsupported reasoning metadata"})}else X.push({type:"other",message:"sending reasoning content is disabled for this model"});break}case"tool-call":{if(S0.providerExecuted){let O0=Y.toProviderToolName(S0.toolName);if(((L=(O=S0.providerOptions)==null?void 0:O.anthropic)==null?void 0:L.type)==="mcp-tool-use"){q0.add(S0.toolCallId);let S1=(E=(D=S0.providerOptions)==null?void 0:D.anthropic)==null?void 0:E.serverName;if(S1==null||typeof S1!=="string"){X.push({type:"other",message:"mcp tool use server name is required and must be a string"});break}Y0.push({type:"mcp_tool_use",id:S0.toolCallId,name:S0.toolName,input:S0.input,server_name:S1,cache_control:Q0})}else if(O0==="code_execution"&&S0.input!=null&&typeof S0.input==="object"&&"type"in S0.input&&typeof S0.input.type==="string"&&(S0.input.type==="bash_code_execution"||S0.input.type==="text_editor_code_execution"))Y0.push({type:"server_tool_use",id:S0.toolCallId,name:S0.input.type,input:S0.input,cache_control:Q0});else if(O0==="code_execution"&&S0.input!=null&&typeof S0.input==="object"&&"type"in S0.input&&S0.input.type==="programmatic-tool-call"){let{type:S1,...G1}=S0.input;Y0.push({type:"server_tool_use",id:S0.toolCallId,name:"code_execution",input:G1,cache_control:Q0})}else if(O0==="code_execution"||O0==="web_fetch"||O0==="web_search")Y0.push({type:"server_tool_use",id:S0.toolCallId,name:O0,input:S0.input,cache_control:Q0});else if(O0==="tool_search_tool_regex"||O0==="tool_search_tool_bm25")Y0.push({type:"server_tool_use",id:S0.toolCallId,name:O0,input:S0.input,cache_control:Q0});else if(O0==="advisor")Y0.push({type:"server_tool_use",id:S0.toolCallId,name:"advisor",input:{},cache_control:Q0});else X.push({type:"other",message:`provider executed tool call for tool ${S0.toolName} is not supported`});break}let N0=(z=S0.providerOptions)==null?void 0:z.anthropic,g0=(N0==null?void 0:N0.caller)?(N0.caller.type==="code_execution_20250825"||N0.caller.type==="code_execution_20260120")&&N0.caller.toolId?{type:N0.caller.type,tool_id:N0.caller.toolId}:N0.caller.type==="direct"?{type:"direct"}:void 0:void 0;Y0.push({type:"tool_use",id:S0.toolCallId,name:S0.toolName,input:S0.input,...g0&&{caller:g0},cache_control:Q0});break}case"tool-result":{let N0=Y.toProviderToolName(S0.toolName);if(q0.has(S0.toolCallId)){let g0=S0.output;if(g0.type!=="json"&&g0.type!=="error-json"){X.push({type:"other",message:`provider executed tool result output type ${g0.type} for tool ${S0.toolName} is not supported`});break}Y0.push({type:"mcp_tool_result",tool_use_id:S0.toolCallId,is_error:g0.type==="error-json",content:g0.value,cache_control:Q0})}else if(N0==="code_execution"){let g0=S0.output;if(g0.type==="error-text"||g0.type==="error-json"){let O0={};try{if(typeof g0.value==="string")O0=JSON.parse(g0.value);else if(typeof g0.value==="object"&&g0.value!==null)O0=g0.value}catch(P0){}if(O0.type==="code_execution_tool_result_error")Y0.push({type:"code_execution_tool_result",tool_use_id:S0.toolCallId,content:{type:"code_execution_tool_result_error",error_code:(j=O0.errorCode)!=null?j:"unknown"},cache_control:Q0});else Y0.push({type:"bash_code_execution_tool_result",tool_use_id:S0.toolCallId,cache_control:Q0,content:{type:"bash_code_execution_tool_result_error",error_code:(P=O0.errorCode)!=null?P:"unknown"}});break}if(g0.type!=="json"){X.push({type:"other",message:`provider executed tool result output type ${g0.type} for tool ${S0.toolName} is not supported`});break}if(g0.value==null||typeof g0.value!=="object"||!("type"in g0.value)||typeof g0.value.type!=="string"){X.push({type:"other",message:`provider executed tool result output value is not a valid code execution result for tool ${S0.toolName}`});break}if(g0.value.type==="code_execution_result"){let O0=await n8({value:g0.value,schema:gq8});Y0.push({type:"code_execution_tool_result",tool_use_id:S0.toolCallId,content:{type:O0.type,stdout:O0.stdout,stderr:O0.stderr,return_code:O0.return_code,content:(A=O0.content)!=null?A:[]},cache_control:Q0})}else if(g0.value.type==="encrypted_code_execution_result"){let O0=await n8({value:g0.value,schema:uq8});if(O0.type==="encrypted_code_execution_result")Y0.push({type:"code_execution_tool_result",tool_use_id:S0.toolCallId,content:{type:O0.type,encrypted_stdout:O0.encrypted_stdout,stderr:O0.stderr,return_code:O0.return_code,content:(I=O0.content)!=null?I:[]},cache_control:Q0})}else{let O0=await n8({value:g0.value,schema:hq8});if(O0.type==="code_execution_result")Y0.push({type:"code_execution_tool_result",tool_use_id:S0.toolCallId,content:{type:O0.type,stdout:O0.stdout,stderr:O0.stderr,return_code:O0.return_code,content:(q=O0.content)!=null?q:[]},cache_control:Q0});else if(O0.type==="bash_code_execution_result"||O0.type==="bash_code_execution_tool_result_error")Y0.push({type:"bash_code_execution_tool_result",tool_use_id:S0.toolCallId,cache_control:Q0,content:O0});else Y0.push({type:"text_editor_code_execution_tool_result",tool_use_id:S0.toolCallId,cache_control:Q0,content:O0})}break}if(N0==="web_fetch"){let g0=S0.output;if(g0.type==="error-json"){Y0.push({type:"web_fetch_tool_result",tool_use_id:S0.toolCallId,content:{type:"web_fetch_tool_result_error",error_code:(M=(await kq8(g0.value)).errorCode)!=null?M:"unavailable"},cache_control:Q0});break}if(g0.type!=="json"){X.push({type:"other",message:`provider executed tool result output type ${g0.type} for tool ${S0.toolName} is not supported`});break}let O0=await n8({value:g0.value,schema:yq8});Y0.push({type:"web_fetch_tool_result",tool_use_id:S0.toolCallId,content:{type:"web_fetch_result",url:O0.url,retrieved_at:O0.retrievedAt,content:{type:"document",title:O0.content.title,citations:O0.content.citations,source:{type:O0.content.source.type,media_type:O0.content.source.mediaType,data:O0.content.source.data}}},cache_control:Q0});break}if(N0==="web_search"){let g0=S0.output;if(g0.type==="error-json"){Y0.push({type:"web_search_tool_result",tool_use_id:S0.toolCallId,content:{type:"web_search_tool_result_error",error_code:(S=(await kq8(g0.value)).errorCode)!=null?S:"unavailable"},cache_control:Q0});break}if(g0.type!=="json"){X.push({type:"other",message:`provider executed tool result output type ${g0.type} for tool ${S0.toolName} is not supported`});break}let O0=await n8({value:g0.value,schema:bq8});Y0.push({type:"web_search_tool_result",tool_use_id:S0.toolCallId,content:O0.map((P0)=>({url:P0.url,title:P0.title,page_age:P0.pageAge,encrypted_content:P0.encryptedContent,type:P0.type})),cache_control:Q0});break}if(N0==="tool_search_tool_regex"||N0==="tool_search_tool_bm25"){let g0=S0.output;if(g0.type!=="json"){X.push({type:"other",message:`provider executed tool result output type ${g0.type} for tool ${S0.toolName} is not supported`});break}let P0=(await n8({value:g0.value,schema:cq8})).map((S1)=>({type:"tool_reference",tool_name:S1.toolName}));Y0.push({type:"tool_search_tool_result",tool_use_id:S0.toolCallId,content:{type:"tool_search_tool_search_result",tool_references:P0},cache_control:Q0});break}if(N0==="advisor"){let g0=S0.output;if(g0.type!=="json"&&g0.type!=="error-json"){X.push({type:"other",message:`provider executed tool result output type ${g0.type} for tool ${S0.toolName} is not supported`});break}let O0=await n8({value:g0.value,schema:fq8});if(O0.type==="advisor_result")Y0.push({type:"advisor_tool_result",tool_use_id:S0.toolCallId,content:{type:"advisor_result",text:O0.text},cache_control:Q0});else if(O0.type==="advisor_redacted_result")Y0.push({type:"advisor_tool_result",tool_use_id:S0.toolCallId,content:{type:"advisor_redacted_result",encrypted_content:O0.encryptedContent},cache_control:Q0});else Y0.push({type:"advisor_tool_result",tool_use_id:S0.toolCallId,content:{type:"advisor_tool_result_error",error_code:O0.errorCode},cache_control:Q0});break}X.push({type:"other",message:`provider executed tool result for tool ${S0.toolName} is not supported`});break}}}}b.push({role:"assistant",content:Y0});break}default:throw Error(`content type: ${A0}`)}}return{prompt:{system:o,messages:b},betas:d}}function nh4($){let Z=[],X=void 0;for(let Q of $){let{role:Y}=Q;switch(Y){case"system":{if((X==null?void 0:X.type)!=="system")X={type:"system",messages:[]},Z.push(X);X.messages.push(Q);break}case"assistant":{if((X==null?void 0:X.type)!=="assistant")X={type:"assistant",messages:[]},Z.push(X);X.messages.push(Q);break}case"user":{if((X==null?void 0:X.type)!=="user")X={type:"user",messages:[]},Z.push(X);X.messages.push(Q);break}case"tool":{if((X==null?void 0:X.type)!=="user")X={type:"user",messages:[]},Z.push(X);X.messages.push(Q);break}default:throw Error(`Unsupported role: ${Y}`)}}return Z}function z51({finishReason:$,isJsonResponseFromTool:Z}){switch($){case"pause_turn":case"end_turn":case"stop_sequence":return"stop";case"refusal":return"content-filter";case"tool_use":return Z?"stop":"tool-calls";case"max_tokens":case"model_context_window_exceeded":return"length";case"compaction":return"other";default:return"other"}}function th4($){return dq8($)}function ew($){if(typeof $==="boolean"||!sh4($))return $;return dq8($)}function dq8($){let Z={},X=$;if($.$ref!=null)return{$ref:$.$ref};if($.$schema!=null)Z.$schema=$.$schema;if($.$id!=null)Z.$id=$.$id;if($.title!=null)Z.title=$.title;if($.description!=null)Z.description=$.description;if($.default!==void 0)Z.default=$.default;if($.const!==void 0)Z.const=$.const;if($.enum!=null)Z.enum=$.enum;if($.type!=null)Z.type=$.type;if($.anyOf!=null)Z.anyOf=$.anyOf.map(ew);else if($.oneOf!=null)Z.anyOf=$.oneOf.map(ew);if($.allOf!=null)Z.allOf=$.allOf.map(ew);if($.definitions!=null)Z.definitions=Object.fromEntries(Object.entries($.definitions).map(([Y,G])=>[Y,ew(G)]));if(X.$defs!=null){let Y=Z;Y.$defs=Object.fromEntries(Object.entries(X.$defs).map(([G,J])=>[G,ew(J)]))}if($.type==="object"||$.properties!=null){if($.properties!=null)Z.properties=Object.fromEntries(Object.entries($.properties).map(([Y,G])=>[Y,ew(G)]));if(Z.additionalProperties=!1,$.required!=null)Z.required=$.required}if($.items!=null)Z.items=Array.isArray($.items)?$.items.map(ew):ew($.items);if(typeof $.format==="string"&&lq8.has($.format))Z.format=$.format;let Q=oh4($);if(Q!=null)Z.description=Z.description==null?Q:`${Z.description}
2369
+ ${Q}`;return Z}function oh4($){let Z=ph4.flatMap((X)=>{let Q=$[X];if(Q==null||Q===!1)return[];return`${rh4(X)}: ${ah4(Q)}`});if(typeof $.format==="string"&&!lq8.has($.format))Z.push(`format: ${$.format}`);return Z.length===0?void 0:`${Z.join("; ")}.`}function rh4($){return $.replace(/[A-Z]/g,(Z)=>` ${Z.toLowerCase()}`)}function ah4($){if(typeof $==="string")return $;return JSON.stringify($)}function sh4($){return typeof $==="object"&&$!==null&&!Array.isArray($)}function Sq8($,Z,X){var Q;if($.type==="web_search_result_location")return{type:"source",sourceType:"url",id:X(),url:$.url,title:$.title,providerMetadata:{anthropic:{citedText:$.cited_text,encryptedIndex:$.encrypted_index}}};if($.type!=="page_location"&&$.type!=="char_location")return;let Y=Z[$.document_index];if(!Y)return;return{type:"source",sourceType:"document",id:X(),mediaType:Y.mediaType,title:(Q=$.document_title)!=null?Q:Y.title,filename:Y.filename,providerMetadata:{anthropic:$.type==="page_location"?{citedText:$.cited_text,startPageNumber:$.start_page_number,endPageNumber:$.end_page_number}:{citedText:$.cited_text,startCharIndex:$.start_char_index,endCharIndex:$.end_char_index}}}}function $u4($){if($.includes("claude-opus-4-8")||$.includes("claude-opus-4-7")||$.includes("claude-fable-5"))return{maxOutputTokens:128000,supportsStructuredOutput:!0,rejectsSamplingParameters:!0,isKnownModel:!0};else if($.includes("claude-sonnet-4-6")||$.includes("claude-opus-4-6"))return{maxOutputTokens:128000,supportsStructuredOutput:!0,rejectsSamplingParameters:!1,isKnownModel:!0};else if($.includes("claude-sonnet-4-5")||$.includes("claude-opus-4-5")||$.includes("claude-haiku-4-5"))return{maxOutputTokens:64000,supportsStructuredOutput:!0,rejectsSamplingParameters:!1,isKnownModel:!0};else if($.includes("claude-opus-4-1"))return{maxOutputTokens:32000,supportsStructuredOutput:!0,rejectsSamplingParameters:!1,isKnownModel:!0};else if($.includes("claude-sonnet-4-"))return{maxOutputTokens:64000,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,isKnownModel:!0};else if($.includes("claude-opus-4-"))return{maxOutputTokens:32000,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,isKnownModel:!0};else if($.includes("claude-3-haiku"))return{maxOutputTokens:4096,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,isKnownModel:!0};else return{maxOutputTokens:4096,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,isKnownModel:!1}}function Cq8($){if(!$)return!1;let Z=!1,X=!1;for(let Q of $){if("type"in Q&&(Q.type==="web_fetch_20260209"||Q.type==="web_search_20260209")){Z=!0;continue}if(Q.name==="code_execution"){X=!0;break}}return Z&&!X}function _q8($){return $?{appliedEdits:$.applied_edits.map((Z)=>{switch(Z.type){case"clear_tool_uses_20250919":return{type:Z.type,clearedToolUses:Z.cleared_tool_uses,clearedInputTokens:Z.cleared_input_tokens};case"clear_thinking_20251015":return{type:Z.type,clearedThinkingTurns:Z.cleared_thinking_turns,clearedInputTokens:Z.cleared_input_tokens};case"compact_20260112":return{type:Z.type}}}).filter((Z)=>Z!==void 0)}:null}function vq8($){if($==null)return;return{type:$.type,...$.category!=null?{category:$.category}:{},...$.explanation!=null?{explanation:$.explanation}:{},...$.recommended_model!=null?{recommendedModel:$.recommended_model}:{}}}function or($={}){var Z,X;let Q=(Z=Tw(UH({settingValue:$.baseURL,environmentVariableName:"ANTHROPIC_BASE_URL"})))!=null?Z:"https://api.anthropic.com/v1",Y=(X=$.name)!=null?X:"anthropic.messages";if($.apiKey&&$.authToken)throw new jw({argument:"apiKey/authToken",message:"Both apiKey and authToken were provided. Please use only one authentication method."});let G=()=>{let W=$.authToken?{Authorization:`Bearer ${$.authToken}`}:{"x-api-key":Mh({apiKey:$.apiKey,environmentVariableName:"ANTHROPIC_API_KEY",description:"Anthropic"})};return Y$({"anthropic-version":"2023-06-01",...W,...$.headers},`ai-sdk/anthropic/${sg4}`)},J=(W)=>{var H;return new eh4(W,{provider:Y,baseURL:Q,headers:G,fetch:$.fetch,generateId:(H=$.generateId)!=null?H:n6,supportedUrls:()=>({"image/*":[/^https?:\/\/.*$/],"application/pdf":[/^https?:\/\/.*$/]})})},K=function(W){if(new.target)throw Error("The Anthropic model function cannot be called with the new keyword.");return J(W)};return K.specificationVersion="v3",K.languageModel=J,K.chat=J,K.messages=J,K.embeddingModel=(W)=>{throw new e5({modelId:W,modelType:"embeddingModel"})},K.textEmbeddingModel=K.embeddingModel,K.imageModel=(W)=>{throw new e5({modelId:W,modelType:"imageModel"})},K.tools=Tu4,K}var sg4="3.0.85",eg4,Rq8,xq8,$h4,Zh4,Xh4,Iq8,qq8,Mq8=4,A51=class{constructor(){this.breakpointCount=0,this.warnings=[]}getCacheControl($,Z){let X=Qh4($);if(!X)return;if(!Z.canCache){this.warnings.push({type:"unsupported",feature:"cache_control on non-cacheable context",details:`cache_control cannot be set on ${Z.type}. It will be ignored.`});return}if(this.breakpointCount++,this.breakpointCount>Mq8){this.warnings.push({type:"unsupported",feature:"cacheControl breakpoint limit",details:`Maximum ${Mq8} cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`});return}return X}getWarnings(){return this.warnings}},Yh4,fq8,Gh4,Jh4,Kh4=($)=>{return Jh4($)},Wh4,Hh4,Nh4,Uh4=($={})=>{return Nh4($)},Fh4,Bh4,Oh4,wh4,Lh4=($={})=>{return wh4($)},Dh4,bq8,Eh4,zh4,jh4=($={})=>{return zh4($)},Ph4,Ah4,Th4,Rh4,Ih4=($={})=>{return Rh4($)},qh4,yq8,Mh4,Vh4,kh4=($={})=>{return Vh4($)},gq8,Ch4,_h4,vh4=($={})=>{return _h4($)},hq8,xh4,fh4,bh4=($={})=>{return fh4($)},uq8,yh4,gh4,hh4=($={})=>{return gh4($)},cq8,uh4,ch4,lh4=($={})=>{return ch4($)},lq8,ph4,eh4=class{constructor($,Z){this.specificationVersion="v3";var X;this.modelId=$,this.config=Z,this.generateId=(X=Z.generateId)!=null?X:n6}supportsUrl($){return $.protocol==="https:"}get provider(){return this.config.provider}get providerOptionsName(){let $=this.config.provider,Z=$.indexOf(".");return Z===-1?$:$.substring(0,Z)}get supportedUrls(){var $,Z,X;return(X=(Z=($=this.config).supportedUrls)==null?void 0:Z.call($))!=null?X:{}}async getArgs({userSuppliedBetas:$,prompt:Z,maxOutputTokens:X,temperature:Q,topP:Y,topK:G,frequencyPenalty:J,presencePenalty:K,stopSequences:W,responseFormat:H,seed:N,tools:U,toolChoice:F,providerOptions:B,stream:O}){var L,D,E,z,j,P,A,I,q,M;let S=[];if(J!=null)S.push({type:"unsupported",feature:"frequencyPenalty"});if(K!=null)S.push({type:"unsupported",feature:"presencePenalty"});if(N!=null)S.push({type:"unsupported",feature:"seed"});if(Q!=null&&Q>1)S.push({type:"unsupported",feature:"temperature",details:`${Q} exceeds anthropic maximum of 1.0. clamped to 1.0`}),Q=1;else if(Q!=null&&Q<0)S.push({type:"unsupported",feature:"temperature",details:`${Q} is below anthropic minimum of 0. clamped to 0`}),Q=0;if((H==null?void 0:H.type)==="json"){if(H.schema==null)S.push({type:"unsupported",feature:"responseFormat",details:"JSON response format requires a schema. The response format is ignored."})}let d=this.providerOptionsName,f=await J4({provider:"anthropic",providerOptions:B,schema:qq8}),y=d!=="anthropic"?await J4({provider:d,providerOptions:B,schema:qq8}):null,o=y!=null,b=Object.assign({},f!=null?f:{},y!=null?y:{}),{maxOutputTokens:r,supportsStructuredOutput:B0,rejectsSamplingParameters:E0,isKnownModel:Z0}=$u4(this.modelId);if(E0){if(Q!=null)S.push({type:"unsupported",feature:"temperature",details:`temperature is not supported by ${this.modelId} and will be ignored`}),Q=void 0;if(G!=null)S.push({type:"unsupported",feature:"topK",details:`topK is not supported by ${this.modelId} and will be ignored`}),G=void 0;if(Y!=null)S.push({type:"unsupported",feature:"topP",details:`topP is not supported by ${this.modelId} and will be ignored`}),Y=void 0}let e=Z0||this.modelId.startsWith("claude-"),A0=((L=this.config.supportsNativeStructuredOutput)!=null?L:!0)&&B0,Y0=((D=this.config.supportsStrictTools)!=null?D:!0)&&B0,q0=(E=b==null?void 0:b.structuredOutputMode)!=null?E:"auto",t0=q0==="outputFormat"||q0==="auto"&&A0,d0=(H==null?void 0:H.type)==="json"&&H.schema!=null&&!t0?{type:"function",name:"json",description:"Respond with a JSON object.",inputSchema:H.schema}:void 0,s0=b==null?void 0:b.contextManagement,H0=new A51,V0=y30({tools:U,providerToolNames:{"anthropic.code_execution_20250522":"code_execution","anthropic.code_execution_20250825":"code_execution","anthropic.code_execution_20260120":"code_execution","anthropic.computer_20241022":"computer","anthropic.computer_20250124":"computer","anthropic.text_editor_20241022":"str_replace_editor","anthropic.text_editor_20250124":"str_replace_editor","anthropic.text_editor_20250429":"str_replace_based_edit_tool","anthropic.text_editor_20250728":"str_replace_based_edit_tool","anthropic.bash_20241022":"bash","anthropic.bash_20250124":"bash","anthropic.memory_20250818":"memory","anthropic.web_search_20250305":"web_search","anthropic.web_search_20260209":"web_search","anthropic.web_fetch_20250910":"web_fetch","anthropic.web_fetch_20260209":"web_fetch","anthropic.tool_search_regex_20251119":"tool_search_tool_regex","anthropic.tool_search_bm25_20251119":"tool_search_tool_bm25","anthropic.advisor_20260301":"advisor"}}),{prompt:S0,betas:I0}=await ih4({prompt:Z,sendReasoning:(z=b==null?void 0:b.sendReasoning)!=null?z:!0,warnings:S,cacheControlValidator:H0,toolNameMapping:V0}),Q0=(j=b==null?void 0:b.thinking)==null?void 0:j.type,N0=Q0==="enabled"||Q0==="adaptive",g0=Q0==="enabled"?(P=b==null?void 0:b.thinking)==null?void 0:P.budgetTokens:void 0,O0=Q0==="adaptive"?(A=b==null?void 0:b.thinking)==null?void 0:A.display:void 0,P0=X!=null?X:r,S1={model:this.modelId,max_tokens:P0,temperature:Q,top_k:G,top_p:Y,stop_sequences:W,...N0&&{thinking:{type:Q0,...g0!=null&&{budget_tokens:g0},...O0!=null&&{display:O0}}},...((b==null?void 0:b.effort)||(b==null?void 0:b.taskBudget)||t0&&(H==null?void 0:H.type)==="json"&&H.schema!=null)&&{output_config:{...(b==null?void 0:b.effort)&&{effort:b.effort},...(b==null?void 0:b.taskBudget)&&{task_budget:{type:b.taskBudget.type,total:b.taskBudget.total,...b.taskBudget.remaining!=null&&{remaining:b.taskBudget.remaining}}},...t0&&(H==null?void 0:H.type)==="json"&&H.schema!=null&&{format:{type:"json_schema",schema:th4(H.schema)}}}},...(b==null?void 0:b.speed)&&{speed:b.speed},...(b==null?void 0:b.inferenceGeo)&&{inference_geo:b.inferenceGeo},...(b==null?void 0:b.fallbacks)&&b.fallbacks.length>0&&{fallbacks:b.fallbacks},...(b==null?void 0:b.cacheControl)&&{cache_control:b.cacheControl},...((I=b==null?void 0:b.metadata)==null?void 0:I.userId)!=null&&{metadata:{user_id:b.metadata.userId}},...(b==null?void 0:b.mcpServers)&&b.mcpServers.length>0&&{mcp_servers:b.mcpServers.map((u0)=>({type:u0.type,name:u0.name,url:u0.url,authorization_token:u0.authorizationToken,tool_configuration:u0.toolConfiguration?{allowed_tools:u0.toolConfiguration.allowedTools,enabled:u0.toolConfiguration.enabled}:void 0}))},...(b==null?void 0:b.container)&&{container:b.container.skills&&b.container.skills.length>0?{id:b.container.id,skills:b.container.skills.map((u0)=>({type:u0.type,skill_id:u0.skillId,version:u0.version}))}:b.container.id},system:S0.system,messages:S0.messages,...s0&&{context_management:{edits:s0.edits.map((u0)=>{let l1=u0.type;switch(l1){case"clear_tool_uses_20250919":return{type:u0.type,...u0.trigger!==void 0&&{trigger:u0.trigger},...u0.keep!==void 0&&{keep:u0.keep},...u0.clearAtLeast!==void 0&&{clear_at_least:u0.clearAtLeast},...u0.clearToolInputs!==void 0&&{clear_tool_inputs:u0.clearToolInputs},...u0.excludeTools!==void 0&&{exclude_tools:u0.excludeTools}};case"clear_thinking_20251015":return{type:u0.type,...u0.keep!==void 0&&{keep:u0.keep}};case"compact_20260112":return{type:u0.type,...u0.trigger!==void 0&&{trigger:u0.trigger},...u0.pauseAfterCompaction!==void 0&&{pause_after_compaction:u0.pauseAfterCompaction},...u0.instructions!==void 0&&{instructions:u0.instructions}};default:S.push({type:"other",message:`Unknown context management strategy: ${l1}`});return}}).filter((u0)=>u0!==void 0)}}};if(N0){if(Q0==="enabled"&&g0==null)S.push({type:"compatibility",feature:"extended thinking",details:"thinking budget is required when thinking is enabled. using default budget of 1024 tokens."}),S1.thinking={type:"enabled",budget_tokens:1024},g0=1024;if(S1.temperature!=null)S1.temperature=void 0,S.push({type:"unsupported",feature:"temperature",details:"temperature is not supported when thinking is enabled"});if(G!=null)S1.top_k=void 0,S.push({type:"unsupported",feature:"topK",details:"topK is not supported when thinking is enabled"});if(Y!=null)S1.top_p=void 0,S.push({type:"unsupported",feature:"topP",details:"topP is not supported when thinking is enabled"});S1.max_tokens=P0+(g0!=null?g0:0)}else if(e&&Y!=null&&Q!=null)S.push({type:"unsupported",feature:"topP",details:"topP is not supported when temperature is set. topP is ignored."}),S1.top_p=void 0;if(Z0&&S1.max_tokens>r){if(X!=null)S.push({type:"unsupported",feature:"maxOutputTokens",details:`${S1.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${this.modelId} ${r} max output tokens. The max output tokens have been limited to ${r}.`});S1.max_tokens=r}if((b==null?void 0:b.mcpServers)&&b.mcpServers.length>0)I0.add("mcp-client-2025-04-04");if(s0){if(I0.add("context-management-2025-06-27"),s0.edits.some((u0)=>u0.type==="compact_20260112"))I0.add("compact-2026-01-12")}if((b==null?void 0:b.container)&&b.container.skills&&b.container.skills.length>0){if(I0.add("code-execution-2025-08-25"),I0.add("skills-2025-10-02"),I0.add("files-api-2025-04-14"),!(U==null?void 0:U.some((u0)=>u0.type==="provider"&&(u0.id==="anthropic.code_execution_20250825"||u0.id==="anthropic.code_execution_20260120"))))S.push({type:"other",message:"code execution tool is required when using skills"})}if(b==null?void 0:b.taskBudget)I0.add("task-budgets-2026-03-13");if((b==null?void 0:b.speed)==="fast")I0.add("fast-mode-2026-02-01");if((b==null?void 0:b.fallbacks)&&b.fallbacks.length>0)I0.add("server-side-fallback-2026-06-01");let G1=O&&((q=b==null?void 0:b.toolStreaming)!=null?q:!0),{tools:r0,toolChoice:a,toolWarnings:m0,betas:B1}=await Sh4(d0!=null?{tools:[...U!=null?U:[],d0],toolChoice:{type:"required"},disableParallelToolUse:!0,cacheControlValidator:H0,supportsStructuredOutput:!1,supportsStrictTools:Y0,defaultEagerInputStreaming:G1}:{tools:U!=null?U:[],toolChoice:F,disableParallelToolUse:b==null?void 0:b.disableParallelToolUse,cacheControlValidator:H0,supportsStructuredOutput:A0,supportsStrictTools:Y0,defaultEagerInputStreaming:G1}),k1=H0.getWarnings();return{args:{...S1,tools:r0,tool_choice:a,stream:O===!0?!0:void 0},warnings:[...S,...m0,...k1],betas:new Set([...I0,...B1,...$,...(M=b==null?void 0:b.anthropicBeta)!=null?M:[]]),usesJsonResponseTool:d0!=null,toolNameMapping:V0,providerOptionsName:d,usedCustomProviderKey:o}}async getHeaders({betas:$,headers:Z}){return Z6(await c8(this.config.headers),Z,$.size>0?{"anthropic-beta":Array.from($).join(",")}:{})}async getBetasFromHeaders($){var Z,X;let Y=(Z=(await c8(this.config.headers))["anthropic-beta"])!=null?Z:"",G=(X=$==null?void 0:$["anthropic-beta"])!=null?X:"";return new Set([...Y.toLowerCase().split(","),...G.toLowerCase().split(",")].map((J)=>J.trim()).filter((J)=>J!==""))}buildRequestUrl($){var Z,X,Q;return(Q=(X=(Z=this.config).buildRequestUrl)==null?void 0:X.call(Z,this.config.baseURL,$))!=null?Q:`${this.config.baseURL}/messages`}transformRequestBody($,Z){var X,Q,Y;return(Y=(Q=(X=this.config).transformRequestBody)==null?void 0:Q.call(X,$,Z))!=null?Y:$}extractCitationDocuments($){let Z=(X)=>{var Q,Y;if(X.type!=="file")return!1;if(X.mediaType!=="application/pdf"&&X.mediaType!=="text/plain")return!1;let G=(Q=X.providerOptions)==null?void 0:Q.anthropic,J=G==null?void 0:G.citations;return(Y=J==null?void 0:J.enabled)!=null?Y:!1};return $.filter((X)=>X.role==="user").flatMap((X)=>X.content).filter(Z).map((X)=>{var Q;let Y=X;return{title:(Q=Y.filename)!=null?Q:"Untitled Document",filename:Y.filename,mediaType:Y.mediaType}})}async doGenerate($){var Z,X,Q,Y,G,J,K;let{args:W,warnings:H,betas:N,usesJsonResponseTool:U,toolNameMapping:F,providerOptionsName:B,usedCustomProviderKey:O}=await this.getArgs({...$,stream:!1,userSuppliedBetas:await this.getBetasFromHeaders($.headers)}),L=[...this.extractCitationDocuments($.prompt)],D=Cq8(W.tools),{responseHeaders:E,value:z,rawValue:j}=await z6({url:this.buildRequestUrl(!1),headers:await this.getHeaders({betas:N,headers:$.headers}),body:this.transformRequestBody(W,N),failedResponseHandler:Rq8,successfulResponseHandler:W6($h4),abortSignal:$.abortSignal,fetch:this.config.fetch}),P=[],A={},I={},q=!1;for(let M of z.content)switch(M.type){case"text":{if(!U){if(P.push({type:"text",text:M.text}),M.citations)for(let S of M.citations){let d=Sq8(S,L,this.generateId);if(d)P.push(d)}}break}case"thinking":{P.push({type:"reasoning",text:M.thinking,providerMetadata:{anthropic:{signature:M.signature}}});break}case"redacted_thinking":{P.push({type:"reasoning",text:"",providerMetadata:{anthropic:{redactedData:M.data}}});break}case"compaction":{P.push({type:"text",text:M.content,providerMetadata:{anthropic:{type:"compaction"}}});break}case"tool_use":{if(U&&M.name==="json")q=!0,P.push({type:"text",text:JSON.stringify(M.input)});else{let d=M.caller,f=d?{type:d.type,toolId:"tool_id"in d?d.tool_id:void 0}:void 0;P.push({type:"tool-call",toolCallId:M.id,toolName:M.name,input:JSON.stringify(M.input),...f&&{providerMetadata:{anthropic:{caller:f}}}})}break}case"server_tool_use":{if(M.name==="text_editor_code_execution"||M.name==="bash_code_execution")P.push({type:"tool-call",toolCallId:M.id,toolName:F.toCustomToolName("code_execution"),input:JSON.stringify({type:M.name,...M.input}),providerExecuted:!0,...D?{dynamic:!0}:{}});else if(M.name==="web_search"||M.name==="code_execution"||M.name==="web_fetch"){let S=M.name==="code_execution"&&M.input!=null&&typeof M.input==="object"&&"code"in M.input&&!("type"in M.input)?{type:"programmatic-tool-call",...M.input}:M.input;P.push({type:"tool-call",toolCallId:M.id,toolName:F.toCustomToolName(M.name),input:JSON.stringify(S),providerExecuted:!0,...D&&M.name==="code_execution"?{dynamic:!0}:{}})}else if(M.name==="tool_search_tool_regex"||M.name==="tool_search_tool_bm25")I[M.id]=M.name,P.push({type:"tool-call",toolCallId:M.id,toolName:F.toCustomToolName(M.name),input:JSON.stringify(M.input),providerExecuted:!0});else if(M.name==="advisor")P.push({type:"tool-call",toolCallId:M.id,toolName:F.toCustomToolName("advisor"),input:JSON.stringify(M.input),providerExecuted:!0});break}case"mcp_tool_use":{A[M.id]={type:"tool-call",toolCallId:M.id,toolName:M.name,input:JSON.stringify(M.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:"mcp-tool-use",serverName:M.server_name}}},P.push(A[M.id]);break}case"mcp_tool_result":{P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:A[M.tool_use_id].toolName,isError:M.is_error,result:M.content,dynamic:!0,providerMetadata:A[M.tool_use_id].providerMetadata});break}case"web_fetch_tool_result":{if(M.content.type==="web_fetch_result")L.push({title:(Z=M.content.content.title)!=null?Z:M.content.url,mediaType:M.content.content.source.media_type}),P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName("web_fetch"),result:{type:"web_fetch_result",url:M.content.url,retrievedAt:M.content.retrieved_at,content:{type:M.content.content.type,title:M.content.content.title,citations:M.content.content.citations,source:{type:M.content.content.source.type,mediaType:M.content.content.source.media_type,data:M.content.content.source.data}}}});else if(M.content.type==="web_fetch_tool_result_error")P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName("web_fetch"),isError:!0,result:{type:"web_fetch_tool_result_error",errorCode:M.content.error_code}});break}case"web_search_tool_result":{if(Array.isArray(M.content)){P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName("web_search"),result:M.content.map((S)=>{var d;return{url:S.url,title:S.title,pageAge:(d=S.page_age)!=null?d:null,encryptedContent:S.encrypted_content,type:S.type}})});for(let S of M.content)P.push({type:"source",sourceType:"url",id:this.generateId(),url:S.url,title:S.title,providerMetadata:{anthropic:{pageAge:(X=S.page_age)!=null?X:null}}})}else P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName("web_search"),isError:!0,result:{type:"web_search_tool_result_error",errorCode:M.content.error_code}});break}case"code_execution_tool_result":{if(M.content.type==="code_execution_result")P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName("code_execution"),result:{type:M.content.type,stdout:M.content.stdout,stderr:M.content.stderr,return_code:M.content.return_code,content:(Q=M.content.content)!=null?Q:[]}});else if(M.content.type==="encrypted_code_execution_result")P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName("code_execution"),result:{type:M.content.type,encrypted_stdout:M.content.encrypted_stdout,stderr:M.content.stderr,return_code:M.content.return_code,content:(Y=M.content.content)!=null?Y:[]}});else if(M.content.type==="code_execution_tool_result_error")P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName("code_execution"),isError:!0,result:{type:"code_execution_tool_result_error",errorCode:M.content.error_code}});break}case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":{P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName("code_execution"),result:M.content});break}case"tool_search_tool_result":{let S=I[M.tool_use_id];if(S==null){let d=F.toCustomToolName("tool_search_tool_bm25"),f=F.toCustomToolName("tool_search_tool_regex");if(d!=="tool_search_tool_bm25")S="tool_search_tool_bm25";else if(f!=="tool_search_tool_regex")S="tool_search_tool_regex";else S="tool_search_tool_regex"}if(M.content.type==="tool_search_tool_search_result")P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName(S),result:M.content.tool_references.map((d)=>({type:d.type,toolName:d.tool_name}))});else P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:F.toCustomToolName(S),isError:!0,result:{type:"tool_search_tool_result_error",errorCode:M.content.error_code}});break}case"advisor_tool_result":{let S=F.toCustomToolName("advisor");if(M.content.type==="advisor_result")P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:S,result:{type:"advisor_result",text:M.content.text}});else if(M.content.type==="advisor_redacted_result")P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:S,result:{type:"advisor_redacted_result",encryptedContent:M.content.encrypted_content}});else P.push({type:"tool-result",toolCallId:M.tool_use_id,toolName:S,isError:!0,result:{type:"advisor_tool_result_error",errorCode:M.content.error_code}});break}case"fallback":break}return{content:P,finishReason:{unified:z51({finishReason:z.stop_reason,isJsonResponseFromTool:q}),raw:(G=z.stop_reason)!=null?G:void 0},usage:Vq8({usage:z.usage}),request:{body:W},response:{id:(J=z.id)!=null?J:void 0,modelId:(K=z.model)!=null?K:void 0,headers:E,body:j},warnings:H,providerMetadata:(()=>{var M,S,d,f,y;let o=vq8(z.stop_details),b={usage:z.usage,cacheCreationInputTokens:(M=z.usage.cache_creation_input_tokens)!=null?M:null,stopSequence:(S=z.stop_sequence)!=null?S:null,...o!=null?{stopDetails:o}:{},iterations:z.usage.iterations?z.usage.iterations.map((B0)=>({type:B0.type,...B0.model!=null?{model:B0.model}:{},inputTokens:B0.input_tokens,outputTokens:B0.output_tokens,...B0.cache_creation_input_tokens?{cacheCreationInputTokens:B0.cache_creation_input_tokens}:{},...B0.cache_read_input_tokens?{cacheReadInputTokens:B0.cache_read_input_tokens}:{}})):null,container:z.container?{expiresAt:z.container.expires_at,id:z.container.id,skills:(f=(d=z.container.skills)==null?void 0:d.map((B0)=>({type:B0.type,skillId:B0.skill_id,version:B0.version})))!=null?f:null}:null,contextManagement:(y=_q8(z.context_management))!=null?y:null},r={anthropic:b};if(O&&B!=="anthropic")r[B]=b;return r})()}}async doStream($){var Z,X;let{args:Q,warnings:Y,betas:G,usesJsonResponseTool:J,toolNameMapping:K,providerOptionsName:W,usedCustomProviderKey:H}=await this.getArgs({...$,stream:!0,userSuppliedBetas:await this.getBetasFromHeaders($.headers)}),N=[...this.extractCitationDocuments($.prompt)],U=Cq8(Q.tools),F=this.buildRequestUrl(!0),{responseHeaders:B,value:O}=await z6({url:F,headers:await this.getHeaders({betas:G,headers:$.headers}),body:this.transformRequestBody(Q,G),failedResponseHandler:Rq8,successfulResponseHandler:EX(Zh4),abortSignal:$.abortSignal,fetch:this.config.fetch}),L={unified:"other",raw:void 0},D={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,iterations:null},E={},z={},j={},P=null,A=void 0,I=null,q=null,M=void 0,S=null,d=!1,f=void 0,y=this.generateId,o=O.pipeThrough(new TransformStream({start(E0){E0.enqueue({type:"stream-start",warnings:Y})},transform(E0,Z0){var e,A0,Y0,q0,t0,d0,s0,H0,V0,S0,I0,Q0,N0,g0;if($.includeRawChunks)Z0.enqueue({type:"raw",rawValue:E0.rawValue});if(!E0.success){Z0.enqueue({type:"error",error:E0.error});return}let O0=E0.value;switch(O0.type){case"ping":return;case"content_block_start":{let P0=O0.content_block,S1=P0.type;if(S1==="fallback")return;switch(f=S1,S1){case"text":{if(J)return;E[O0.index]={type:"text"},Z0.enqueue({type:"text-start",id:String(O0.index)});return}case"thinking":{E[O0.index]={type:"reasoning"},Z0.enqueue({type:"reasoning-start",id:String(O0.index)});return}case"redacted_thinking":{E[O0.index]={type:"reasoning"},Z0.enqueue({type:"reasoning-start",id:String(O0.index),providerMetadata:{anthropic:{redactedData:P0.data}}});return}case"compaction":{E[O0.index]={type:"text"},Z0.enqueue({type:"text-start",id:String(O0.index),providerMetadata:{anthropic:{type:"compaction"}}});return}case"tool_use":{if(J&&P0.name==="json")d=!0,E[O0.index]={type:"text"},Z0.enqueue({type:"text-start",id:String(O0.index)});else{let r0=P0.caller,a=r0?{type:r0.type,toolId:"tool_id"in r0?r0.tool_id:void 0}:void 0,B1=P0.input&&Object.keys(P0.input).length>0?JSON.stringify(P0.input):"";E[O0.index]={type:"tool-call",toolCallId:P0.id,toolName:P0.name,input:B1,firstDelta:B1.length===0,...a&&{caller:a}},Z0.enqueue({type:"tool-input-start",id:P0.id,toolName:P0.name})}return}case"server_tool_use":{if(["web_fetch","web_search","code_execution","text_editor_code_execution","bash_code_execution"].includes(P0.name)){let G1=P0.name==="text_editor_code_execution"||P0.name==="bash_code_execution"?"code_execution":P0.name,r0=K.toCustomToolName(G1),a=P0.input!=null&&typeof P0.input==="object"&&Object.keys(P0.input).length>0?JSON.stringify(P0.input):"";E[O0.index]={type:"tool-call",toolCallId:P0.id,toolName:r0,input:a,providerExecuted:!0,...U&&G1==="code_execution"?{dynamic:!0}:{},firstDelta:!0,providerToolName:G1},Z0.enqueue({type:"tool-input-start",id:P0.id,toolName:r0,providerExecuted:!0,...U&&G1==="code_execution"?{dynamic:!0}:{}})}else if(P0.name==="tool_search_tool_regex"||P0.name==="tool_search_tool_bm25"){j[P0.id]=P0.name;let G1=K.toCustomToolName(P0.name);E[O0.index]={type:"tool-call",toolCallId:P0.id,toolName:G1,input:"",providerExecuted:!0,firstDelta:!0,providerToolName:P0.name},Z0.enqueue({type:"tool-input-start",id:P0.id,toolName:G1,providerExecuted:!0})}else if(P0.name==="advisor"){let G1=K.toCustomToolName("advisor");E[O0.index]={type:"tool-call",toolCallId:P0.id,toolName:G1,input:"{}",providerExecuted:!0,firstDelta:!0,providerToolName:P0.name},Z0.enqueue({type:"tool-input-start",id:P0.id,toolName:G1,providerExecuted:!0})}return}case"web_fetch_tool_result":{if(P0.content.type==="web_fetch_result")N.push({title:(e=P0.content.content.title)!=null?e:P0.content.url,mediaType:P0.content.content.source.media_type}),Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName("web_fetch"),result:{type:"web_fetch_result",url:P0.content.url,retrievedAt:P0.content.retrieved_at,content:{type:P0.content.content.type,title:P0.content.content.title,citations:P0.content.content.citations,source:{type:P0.content.content.source.type,mediaType:P0.content.content.source.media_type,data:P0.content.content.source.data}}}});else if(P0.content.type==="web_fetch_tool_result_error")Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName("web_fetch"),isError:!0,result:{type:"web_fetch_tool_result_error",errorCode:P0.content.error_code}});return}case"web_search_tool_result":{if(Array.isArray(P0.content)){Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName("web_search"),result:P0.content.map((G1)=>{var r0;return{url:G1.url,title:G1.title,pageAge:(r0=G1.page_age)!=null?r0:null,encryptedContent:G1.encrypted_content,type:G1.type}})});for(let G1 of P0.content)Z0.enqueue({type:"source",sourceType:"url",id:y(),url:G1.url,title:G1.title,providerMetadata:{anthropic:{pageAge:(A0=G1.page_age)!=null?A0:null}}})}else Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName("web_search"),isError:!0,result:{type:"web_search_tool_result_error",errorCode:P0.content.error_code}});return}case"code_execution_tool_result":{if(P0.content.type==="code_execution_result")Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName("code_execution"),result:{type:P0.content.type,stdout:P0.content.stdout,stderr:P0.content.stderr,return_code:P0.content.return_code,content:(Y0=P0.content.content)!=null?Y0:[]}});else if(P0.content.type==="encrypted_code_execution_result")Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName("code_execution"),result:{type:P0.content.type,encrypted_stdout:P0.content.encrypted_stdout,stderr:P0.content.stderr,return_code:P0.content.return_code,content:(q0=P0.content.content)!=null?q0:[]}});else if(P0.content.type==="code_execution_tool_result_error")Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName("code_execution"),isError:!0,result:{type:"code_execution_tool_result_error",errorCode:P0.content.error_code}});return}case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":{Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName("code_execution"),result:P0.content});return}case"tool_search_tool_result":{let G1=j[P0.tool_use_id];if(G1==null){let r0=K.toCustomToolName("tool_search_tool_bm25"),a=K.toCustomToolName("tool_search_tool_regex");if(r0!=="tool_search_tool_bm25")G1="tool_search_tool_bm25";else if(a!=="tool_search_tool_regex")G1="tool_search_tool_regex";else G1="tool_search_tool_regex"}if(P0.content.type==="tool_search_tool_search_result")Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName(G1),result:P0.content.tool_references.map((r0)=>({type:r0.type,toolName:r0.tool_name}))});else Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:K.toCustomToolName(G1),isError:!0,result:{type:"tool_search_tool_result_error",errorCode:P0.content.error_code}});return}case"advisor_tool_result":{let G1=K.toCustomToolName("advisor");if(P0.content.type==="advisor_result")Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:G1,result:{type:"advisor_result",text:P0.content.text}});else if(P0.content.type==="advisor_redacted_result")Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:G1,result:{type:"advisor_redacted_result",encryptedContent:P0.content.encrypted_content}});else Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:G1,isError:!0,result:{type:"advisor_tool_result_error",errorCode:P0.content.error_code}});return}case"mcp_tool_use":{z[P0.id]={type:"tool-call",toolCallId:P0.id,toolName:P0.name,input:JSON.stringify(P0.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:"mcp-tool-use",serverName:P0.server_name}}},Z0.enqueue(z[P0.id]);return}case"mcp_tool_result":{Z0.enqueue({type:"tool-result",toolCallId:P0.tool_use_id,toolName:z[P0.tool_use_id].toolName,isError:P0.is_error,result:P0.content,dynamic:!0,providerMetadata:z[P0.tool_use_id].providerMetadata});return}default:throw Error(`Unsupported content block type: ${S1}`)}}case"content_block_stop":{if(E[O0.index]!=null){let P0=E[O0.index];switch(P0.type){case"text":{Z0.enqueue({type:"text-end",id:String(O0.index)});break}case"reasoning":{Z0.enqueue({type:"reasoning-end",id:String(O0.index)});break}case"tool-call":if(!(J&&P0.toolName==="json")){Z0.enqueue({type:"tool-input-end",id:P0.toolCallId});let G1=P0.input===""?"{}":P0.input;if(P0.providerToolName==="code_execution")try{let r0=JSON.parse(G1);if(r0!=null&&typeof r0==="object"&&"code"in r0&&!("type"in r0))G1=JSON.stringify({type:"programmatic-tool-call",...r0})}catch(r0){}Z0.enqueue({type:"tool-call",toolCallId:P0.toolCallId,toolName:P0.toolName,input:G1,providerExecuted:P0.providerExecuted,...U&&P0.providerToolName==="code_execution"?{dynamic:!0}:{},...P0.caller&&{providerMetadata:{anthropic:{caller:P0.caller}}}})}break}delete E[O0.index]}f=void 0;return}case"content_block_delta":{let P0=O0.delta.type;switch(P0){case"text_delta":{if(J)return;Z0.enqueue({type:"text-delta",id:String(O0.index),delta:O0.delta.text});return}case"thinking_delta":{Z0.enqueue({type:"reasoning-delta",id:String(O0.index),delta:O0.delta.thinking});return}case"signature_delta":{if(f==="thinking")Z0.enqueue({type:"reasoning-delta",id:String(O0.index),delta:"",providerMetadata:{anthropic:{signature:O0.delta.signature}}});return}case"compaction_delta":{if(O0.delta.content!=null)Z0.enqueue({type:"text-delta",id:String(O0.index),delta:O0.delta.content});return}case"input_json_delta":{let S1=E[O0.index],G1=O0.delta.partial_json;if(G1.length===0)return;if(d){if((S1==null?void 0:S1.type)!=="text")return;Z0.enqueue({type:"text-delta",id:String(O0.index),delta:G1})}else{if((S1==null?void 0:S1.type)!=="tool-call")return;if(S1.firstDelta&&S1.providerToolName==="code_execution")G1=`{"type": "programmatic-tool-call",${G1.substring(1)}`;Z0.enqueue({type:"tool-input-delta",id:S1.toolCallId,delta:G1}),S1.input+=G1,S1.firstDelta=!1}return}case"citations_delta":{let S1=O0.delta.citation,G1=Sq8(S1,N,y);if(G1)Z0.enqueue(G1);return}default:throw Error(`Unsupported delta type: ${P0}`)}}case"message_start":{if(D.input_tokens=O0.message.usage.input_tokens,D.cache_read_input_tokens=(t0=O0.message.usage.cache_read_input_tokens)!=null?t0:0,D.cache_creation_input_tokens=(d0=O0.message.usage.cache_creation_input_tokens)!=null?d0:0,A={...O0.message.usage},I=(s0=O0.message.usage.cache_creation_input_tokens)!=null?s0:null,O0.message.container!=null)S={expiresAt:O0.message.container.expires_at,id:O0.message.container.id,skills:null};if(O0.message.stop_reason!=null)L={unified:z51({finishReason:O0.message.stop_reason,isJsonResponseFromTool:d}),raw:O0.message.stop_reason};if(Z0.enqueue({type:"response-metadata",id:(H0=O0.message.id)!=null?H0:void 0,modelId:(V0=O0.message.model)!=null?V0:void 0}),O0.message.content!=null)for(let P0=0;P0<O0.message.content.length;P0++){let S1=O0.message.content[P0];if(S1.type==="tool_use"){let G1=S1.caller,r0=G1?{type:G1.type,toolId:"tool_id"in G1?G1.tool_id:void 0}:void 0;Z0.enqueue({type:"tool-input-start",id:S1.id,toolName:S1.name});let a=JSON.stringify((S0=S1.input)!=null?S0:{});Z0.enqueue({type:"tool-input-delta",id:S1.id,delta:a}),Z0.enqueue({type:"tool-input-end",id:S1.id}),Z0.enqueue({type:"tool-call",toolCallId:S1.id,toolName:S1.name,input:a,...r0&&{providerMetadata:{anthropic:{caller:r0}}}})}}return}case"message_delta":{if(O0.usage.input_tokens!=null&&D.input_tokens!==O0.usage.input_tokens)D.input_tokens=O0.usage.input_tokens;if(D.output_tokens=O0.usage.output_tokens,O0.usage.cache_read_input_tokens!=null)D.cache_read_input_tokens=O0.usage.cache_read_input_tokens;if(O0.usage.cache_creation_input_tokens!=null)D.cache_creation_input_tokens=O0.usage.cache_creation_input_tokens,I=O0.usage.cache_creation_input_tokens;if(O0.usage.iterations!=null)D.iterations=O0.usage.iterations;if(L={unified:z51({finishReason:O0.delta.stop_reason,isJsonResponseFromTool:d}),raw:(I0=O0.delta.stop_reason)!=null?I0:void 0},q=(Q0=O0.delta.stop_sequence)!=null?Q0:null,M=vq8(O0.delta.stop_details),S=O0.delta.container!=null?{expiresAt:O0.delta.container.expires_at,id:O0.delta.container.id,skills:(g0=(N0=O0.delta.container.skills)==null?void 0:N0.map((P0)=>({type:P0.type,skillId:P0.skill_id,version:P0.version})))!=null?g0:null}:null,O0.context_management)P=_q8(O0.context_management);A={...A,...O0.usage};return}case"message_stop":{let P0={usage:A!=null?A:null,cacheCreationInputTokens:I,stopSequence:q,...M!=null?{stopDetails:M}:{},iterations:D.iterations?D.iterations.map((G1)=>({type:G1.type,...G1.model!=null?{model:G1.model}:{},inputTokens:G1.input_tokens,outputTokens:G1.output_tokens,...G1.cache_creation_input_tokens?{cacheCreationInputTokens:G1.cache_creation_input_tokens}:{},...G1.cache_read_input_tokens?{cacheReadInputTokens:G1.cache_read_input_tokens}:{}})):null,container:S,contextManagement:P},S1={anthropic:P0};if(H&&W!=="anthropic")S1[W]=P0;Z0.enqueue({type:"finish",finishReason:L,usage:Vq8({usage:D,rawUsage:A}),providerMetadata:S1});return}case"error":{Z0.enqueue({type:"error",error:O0.error});return}default:throw Error(`Unsupported chunk type: ${O0}`)}}})),[b,r]=o.tee(),B0=b.getReader();try{await B0.read();let E0=await B0.read();if(((Z=E0.value)==null?void 0:Z.type)==="raw")E0=await B0.read();if(((X=E0.value)==null?void 0:X.type)==="error"){let Z0=E0.value.error;throw new O4({message:Z0.message,url:F,requestBodyValues:Q,statusCode:Z0.type==="overloaded_error"?529:500,responseHeaders:B,responseBody:JSON.stringify(Z0),isRetryable:Z0.type==="overloaded_error"})}}finally{B0.cancel().catch(()=>{}),B0.releaseLock()}return{stream:r,request:{body:Q},response:{headers:B}}}},Zu4,Xu4,Qu4,Yu4,Gu4,Ju4,Ku4,Wu4,Hu4,Nu4,Uu4,Fu4,Bu4,Ou4,wu4,Lu4,Du4,Eu4,zu4,ju4,Pu4,Au4=($={})=>{return Pu4($)},Tu4,f1Z;var T51=w(()=>{Q8();a0();Q8();a0();a0();a0();Q8();a0();a0();a0();a0();a0();a0();a0();Q8();a0();a0();a0();a0();a0();a0();a0();a0();a0();a0();a0();a0();a0();a0();a0();eg4=k0(()=>W0(pr.object({type:pr.literal("error"),error:pr.object({type:pr.string(),message:pr.string()})}))),Rq8=c5({errorSchema:eg4,errorToMessage:($)=>$.error.message}),xq8=V.object({type:V.string(),category:V.string().nullish(),explanation:V.string().nullish(),recommended_model:V.string().nullish()}),$h4=k0(()=>W0(V.object({type:V.literal("message"),id:V.string().nullish(),model:V.string().nullish(),content:V.array(V.discriminatedUnion("type",[V.object({type:V.literal("text"),text:V.string(),citations:V.array(V.discriminatedUnion("type",[V.object({type:V.literal("web_search_result_location"),cited_text:V.string(),url:V.string(),title:V.string(),encrypted_index:V.string()}),V.object({type:V.literal("page_location"),cited_text:V.string(),document_index:V.number(),document_title:V.string().nullable(),start_page_number:V.number(),end_page_number:V.number()}),V.object({type:V.literal("char_location"),cited_text:V.string(),document_index:V.number(),document_title:V.string().nullable(),start_char_index:V.number(),end_char_index:V.number()})])).optional()}),V.object({type:V.literal("thinking"),thinking:V.string(),signature:V.string()}),V.object({type:V.literal("redacted_thinking"),data:V.string()}),V.object({type:V.literal("compaction"),content:V.string()}),V.object({type:V.literal("tool_use"),id:V.string(),name:V.string(),input:V.unknown(),caller:V.union([V.object({type:V.literal("code_execution_20250825"),tool_id:V.string()}),V.object({type:V.literal("code_execution_20260120"),tool_id:V.string()}),V.object({type:V.literal("direct")})]).optional()}),V.object({type:V.literal("server_tool_use"),id:V.string(),name:V.string(),input:V.record(V.string(),V.unknown()).nullish(),caller:V.union([V.object({type:V.literal("code_execution_20260120"),tool_id:V.string()}),V.object({type:V.literal("direct")})]).optional()}),V.object({type:V.literal("mcp_tool_use"),id:V.string(),name:V.string(),input:V.unknown(),server_name:V.string()}),V.object({type:V.literal("mcp_tool_result"),tool_use_id:V.string(),is_error:V.boolean(),content:V.array(V.union([V.string(),V.object({type:V.literal("text"),text:V.string()})]))}),V.object({type:V.literal("web_fetch_tool_result"),tool_use_id:V.string(),content:V.union([V.object({type:V.literal("web_fetch_result"),url:V.string(),retrieved_at:V.string(),content:V.object({type:V.literal("document"),title:V.string().nullable(),citations:V.object({enabled:V.boolean()}).optional(),source:V.union([V.object({type:V.literal("base64"),media_type:V.literal("application/pdf"),data:V.string()}),V.object({type:V.literal("text"),media_type:V.literal("text/plain"),data:V.string()})])})}),V.object({type:V.literal("web_fetch_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("web_search_tool_result"),tool_use_id:V.string(),content:V.union([V.array(V.object({type:V.literal("web_search_result"),url:V.string(),title:V.string(),encrypted_content:V.string(),page_age:V.string().nullish()})),V.object({type:V.literal("web_search_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("code_execution_tool_result"),tool_use_id:V.string(),content:V.union([V.object({type:V.literal("code_execution_result"),stdout:V.string(),stderr:V.string(),return_code:V.number(),content:V.array(V.object({type:V.literal("code_execution_output"),file_id:V.string()})).optional().default([])}),V.object({type:V.literal("encrypted_code_execution_result"),encrypted_stdout:V.string(),stderr:V.string(),return_code:V.number(),content:V.array(V.object({type:V.literal("code_execution_output"),file_id:V.string()})).optional().default([])}),V.object({type:V.literal("code_execution_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("bash_code_execution_tool_result"),tool_use_id:V.string(),content:V.discriminatedUnion("type",[V.object({type:V.literal("bash_code_execution_result"),content:V.array(V.object({type:V.literal("bash_code_execution_output"),file_id:V.string()})),stdout:V.string(),stderr:V.string(),return_code:V.number()}),V.object({type:V.literal("bash_code_execution_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("text_editor_code_execution_tool_result"),tool_use_id:V.string(),content:V.discriminatedUnion("type",[V.object({type:V.literal("text_editor_code_execution_tool_result_error"),error_code:V.string()}),V.object({type:V.literal("text_editor_code_execution_view_result"),content:V.string(),file_type:V.string(),num_lines:V.number().nullable(),start_line:V.number().nullable(),total_lines:V.number().nullable()}),V.object({type:V.literal("text_editor_code_execution_create_result"),is_file_update:V.boolean()}),V.object({type:V.literal("text_editor_code_execution_str_replace_result"),lines:V.array(V.string()).nullable(),new_lines:V.number().nullable(),new_start:V.number().nullable(),old_lines:V.number().nullable(),old_start:V.number().nullable()})])}),V.object({type:V.literal("tool_search_tool_result"),tool_use_id:V.string(),content:V.union([V.object({type:V.literal("tool_search_tool_search_result"),tool_references:V.array(V.object({type:V.literal("tool_reference"),tool_name:V.string()}))}),V.object({type:V.literal("tool_search_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("advisor_tool_result"),tool_use_id:V.string(),content:V.discriminatedUnion("type",[V.object({type:V.literal("advisor_result"),text:V.string()}),V.object({type:V.literal("advisor_redacted_result"),encrypted_content:V.string()}),V.object({type:V.literal("advisor_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("fallback")})])),stop_reason:V.string().nullish(),stop_sequence:V.string().nullish(),stop_details:xq8.nullish(),usage:V.looseObject({input_tokens:V.number(),output_tokens:V.number(),cache_creation_input_tokens:V.number().nullish(),cache_read_input_tokens:V.number().nullish(),iterations:V.array(V.object({type:V.union([V.literal("compaction"),V.literal("message"),V.literal("advisor_message"),V.literal("fallback_message")]),model:V.string().nullish(),input_tokens:V.number(),output_tokens:V.number(),cache_creation_input_tokens:V.number().nullish(),cache_read_input_tokens:V.number().nullish()})).nullish()}),container:V.object({expires_at:V.string(),id:V.string(),skills:V.array(V.object({type:V.union([V.literal("anthropic"),V.literal("custom")]),skill_id:V.string(),version:V.string()})).nullish()}).nullish(),context_management:V.object({applied_edits:V.array(V.union([V.object({type:V.literal("clear_tool_uses_20250919"),cleared_tool_uses:V.number(),cleared_input_tokens:V.number()}),V.object({type:V.literal("clear_thinking_20251015"),cleared_thinking_turns:V.number(),cleared_input_tokens:V.number()}),V.object({type:V.literal("compact_20260112")})]))}).nullish()}))),Zh4=k0(()=>W0(V.discriminatedUnion("type",[V.object({type:V.literal("message_start"),message:V.object({id:V.string().nullish(),model:V.string().nullish(),role:V.string().nullish(),usage:V.looseObject({input_tokens:V.number(),cache_creation_input_tokens:V.number().nullish(),cache_read_input_tokens:V.number().nullish()}),content:V.array(V.discriminatedUnion("type",[V.object({type:V.literal("tool_use"),id:V.string(),name:V.string(),input:V.unknown(),caller:V.union([V.object({type:V.literal("code_execution_20250825"),tool_id:V.string()}),V.object({type:V.literal("code_execution_20260120"),tool_id:V.string()}),V.object({type:V.literal("direct")})]).optional()})])).nullish(),stop_reason:V.string().nullish(),container:V.object({expires_at:V.string(),id:V.string()}).nullish()})}),V.object({type:V.literal("content_block_start"),index:V.number(),content_block:V.discriminatedUnion("type",[V.object({type:V.literal("text"),text:V.string()}),V.object({type:V.literal("thinking"),thinking:V.string()}),V.object({type:V.literal("tool_use"),id:V.string(),name:V.string(),input:V.record(V.string(),V.unknown()).optional(),caller:V.union([V.object({type:V.literal("code_execution_20250825"),tool_id:V.string()}),V.object({type:V.literal("code_execution_20260120"),tool_id:V.string()}),V.object({type:V.literal("direct")})]).optional()}),V.object({type:V.literal("redacted_thinking"),data:V.string()}),V.object({type:V.literal("compaction"),content:V.string().nullish()}),V.object({type:V.literal("server_tool_use"),id:V.string(),name:V.string(),input:V.record(V.string(),V.unknown()).nullish(),caller:V.union([V.object({type:V.literal("code_execution_20260120"),tool_id:V.string()}),V.object({type:V.literal("direct")})]).optional()}),V.object({type:V.literal("mcp_tool_use"),id:V.string(),name:V.string(),input:V.unknown(),server_name:V.string()}),V.object({type:V.literal("mcp_tool_result"),tool_use_id:V.string(),is_error:V.boolean(),content:V.array(V.union([V.string(),V.object({type:V.literal("text"),text:V.string()})]))}),V.object({type:V.literal("web_fetch_tool_result"),tool_use_id:V.string(),content:V.union([V.object({type:V.literal("web_fetch_result"),url:V.string(),retrieved_at:V.string(),content:V.object({type:V.literal("document"),title:V.string().nullable(),citations:V.object({enabled:V.boolean()}).optional(),source:V.union([V.object({type:V.literal("base64"),media_type:V.literal("application/pdf"),data:V.string()}),V.object({type:V.literal("text"),media_type:V.literal("text/plain"),data:V.string()})])})}),V.object({type:V.literal("web_fetch_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("web_search_tool_result"),tool_use_id:V.string(),content:V.union([V.array(V.object({type:V.literal("web_search_result"),url:V.string(),title:V.string(),encrypted_content:V.string(),page_age:V.string().nullish()})),V.object({type:V.literal("web_search_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("code_execution_tool_result"),tool_use_id:V.string(),content:V.union([V.object({type:V.literal("code_execution_result"),stdout:V.string(),stderr:V.string(),return_code:V.number(),content:V.array(V.object({type:V.literal("code_execution_output"),file_id:V.string()})).optional().default([])}),V.object({type:V.literal("encrypted_code_execution_result"),encrypted_stdout:V.string(),stderr:V.string(),return_code:V.number(),content:V.array(V.object({type:V.literal("code_execution_output"),file_id:V.string()})).optional().default([])}),V.object({type:V.literal("code_execution_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("bash_code_execution_tool_result"),tool_use_id:V.string(),content:V.discriminatedUnion("type",[V.object({type:V.literal("bash_code_execution_result"),content:V.array(V.object({type:V.literal("bash_code_execution_output"),file_id:V.string()})),stdout:V.string(),stderr:V.string(),return_code:V.number()}),V.object({type:V.literal("bash_code_execution_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("text_editor_code_execution_tool_result"),tool_use_id:V.string(),content:V.discriminatedUnion("type",[V.object({type:V.literal("text_editor_code_execution_tool_result_error"),error_code:V.string()}),V.object({type:V.literal("text_editor_code_execution_view_result"),content:V.string(),file_type:V.string(),num_lines:V.number().nullable(),start_line:V.number().nullable(),total_lines:V.number().nullable()}),V.object({type:V.literal("text_editor_code_execution_create_result"),is_file_update:V.boolean()}),V.object({type:V.literal("text_editor_code_execution_str_replace_result"),lines:V.array(V.string()).nullable(),new_lines:V.number().nullable(),new_start:V.number().nullable(),old_lines:V.number().nullable(),old_start:V.number().nullable()})])}),V.object({type:V.literal("tool_search_tool_result"),tool_use_id:V.string(),content:V.union([V.object({type:V.literal("tool_search_tool_search_result"),tool_references:V.array(V.object({type:V.literal("tool_reference"),tool_name:V.string()}))}),V.object({type:V.literal("tool_search_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("advisor_tool_result"),tool_use_id:V.string(),content:V.discriminatedUnion("type",[V.object({type:V.literal("advisor_result"),text:V.string()}),V.object({type:V.literal("advisor_redacted_result"),encrypted_content:V.string()}),V.object({type:V.literal("advisor_tool_result_error"),error_code:V.string()})])}),V.object({type:V.literal("fallback")})])}),V.object({type:V.literal("content_block_delta"),index:V.number(),delta:V.discriminatedUnion("type",[V.object({type:V.literal("input_json_delta"),partial_json:V.string()}),V.object({type:V.literal("text_delta"),text:V.string()}),V.object({type:V.literal("thinking_delta"),thinking:V.string()}),V.object({type:V.literal("signature_delta"),signature:V.string()}),V.object({type:V.literal("compaction_delta"),content:V.string().nullish()}),V.object({type:V.literal("citations_delta"),citation:V.discriminatedUnion("type",[V.object({type:V.literal("web_search_result_location"),cited_text:V.string(),url:V.string(),title:V.string(),encrypted_index:V.string()}),V.object({type:V.literal("page_location"),cited_text:V.string(),document_index:V.number(),document_title:V.string().nullable(),start_page_number:V.number(),end_page_number:V.number()}),V.object({type:V.literal("char_location"),cited_text:V.string(),document_index:V.number(),document_title:V.string().nullable(),start_char_index:V.number(),end_char_index:V.number()})])})])}),V.object({type:V.literal("content_block_stop"),index:V.number()}),V.object({type:V.literal("error"),error:V.object({type:V.string(),message:V.string()})}),V.object({type:V.literal("message_delta"),delta:V.object({stop_reason:V.string().nullish(),stop_sequence:V.string().nullish(),stop_details:xq8.nullish(),container:V.object({expires_at:V.string(),id:V.string(),skills:V.array(V.object({type:V.union([V.literal("anthropic"),V.literal("custom")]),skill_id:V.string(),version:V.string()})).nullish()}).nullish()}),usage:V.looseObject({input_tokens:V.number().nullish(),output_tokens:V.number(),cache_creation_input_tokens:V.number().nullish(),cache_read_input_tokens:V.number().nullish(),iterations:V.array(V.object({type:V.union([V.literal("compaction"),V.literal("message"),V.literal("advisor_message"),V.literal("fallback_message")]),model:V.string().nullish(),input_tokens:V.number(),output_tokens:V.number(),cache_creation_input_tokens:V.number().nullish(),cache_read_input_tokens:V.number().nullish()})).nullish()}),context_management:V.object({applied_edits:V.array(V.union([V.object({type:V.literal("clear_tool_uses_20250919"),cleared_tool_uses:V.number(),cleared_input_tokens:V.number()}),V.object({type:V.literal("clear_thinking_20251015"),cleared_thinking_turns:V.number(),cleared_input_tokens:V.number()}),V.object({type:V.literal("compact_20260112")})]))}).nullish()}),V.object({type:V.literal("message_stop")}),V.object({type:V.literal("ping")})]))),Xh4=k0(()=>W0(V.object({signature:V.string().optional(),redactedData:V.string().optional()}))),Iq8=j1.object({citations:j1.object({enabled:j1.boolean()}).optional(),title:j1.string().optional(),context:j1.string().optional()}),qq8=j1.object({sendReasoning:j1.boolean().optional(),structuredOutputMode:j1.enum(["outputFormat","jsonTool","auto"]).optional(),thinking:j1.discriminatedUnion("type",[j1.object({type:j1.literal("adaptive"),display:j1.enum(["omitted","summarized"]).optional()}),j1.object({type:j1.literal("enabled"),budgetTokens:j1.number().optional()}),j1.object({type:j1.literal("disabled")})]).optional(),disableParallelToolUse:j1.boolean().optional(),cacheControl:j1.object({type:j1.literal("ephemeral"),ttl:j1.union([j1.literal("5m"),j1.literal("1h")]).optional()}).optional(),metadata:j1.object({userId:j1.string().optional()}).optional(),mcpServers:j1.array(j1.object({type:j1.literal("url"),name:j1.string(),url:j1.string(),authorizationToken:j1.string().nullish(),toolConfiguration:j1.object({enabled:j1.boolean().nullish(),allowedTools:j1.array(j1.string()).nullish()}).nullish()})).optional(),container:j1.object({id:j1.string().optional(),skills:j1.array(j1.object({type:j1.union([j1.literal("anthropic"),j1.literal("custom")]),skillId:j1.string(),version:j1.string().optional()})).optional()}).optional(),toolStreaming:j1.boolean().optional(),effort:j1.enum(["low","medium","high","xhigh","max"]).optional(),taskBudget:j1.object({type:j1.literal("tokens"),total:j1.number().int().min(20000),remaining:j1.number().int().min(0).optional()}).optional(),speed:j1.enum(["fast","standard"]).optional(),inferenceGeo:j1.enum(["us","global"]).optional(),fallbacks:j1.array(j1.object({model:j1.string(),max_tokens:j1.number().int().optional(),thinking:j1.record(j1.string(),j1.unknown()).optional(),output_config:j1.record(j1.string(),j1.unknown()).optional(),speed:j1.enum(["fast","standard"]).optional()})).optional(),anthropicBeta:j1.array(j1.string()).optional(),contextManagement:j1.object({edits:j1.array(j1.discriminatedUnion("type",[j1.object({type:j1.literal("clear_tool_uses_20250919"),trigger:j1.discriminatedUnion("type",[j1.object({type:j1.literal("input_tokens"),value:j1.number()}),j1.object({type:j1.literal("tool_uses"),value:j1.number()})]).optional(),keep:j1.object({type:j1.literal("tool_uses"),value:j1.number()}).optional(),clearAtLeast:j1.object({type:j1.literal("input_tokens"),value:j1.number()}).optional(),clearToolInputs:j1.boolean().optional(),excludeTools:j1.array(j1.string()).optional()}),j1.object({type:j1.literal("clear_thinking_20251015"),keep:j1.union([j1.literal("all"),j1.object({type:j1.literal("thinking_turns"),value:j1.number()})]).optional()}),j1.object({type:j1.literal("compact_20260112"),trigger:j1.object({type:j1.literal("input_tokens"),value:j1.number()}).optional(),pauseAfterCompaction:j1.boolean().optional(),instructions:j1.string().optional()})]))}).optional()});Yh4=k0(()=>W0(IZ.object({model:IZ.string(),maxUses:IZ.number().optional(),caching:IZ.object({type:IZ.literal("ephemeral"),ttl:IZ.union([IZ.literal("5m"),IZ.literal("1h")])}).optional()}))),fq8=k0(()=>W0(IZ.discriminatedUnion("type",[IZ.object({type:IZ.literal("advisor_result"),text:IZ.string()}),IZ.object({type:IZ.literal("advisor_redacted_result"),encryptedContent:IZ.string()}),IZ.object({type:IZ.literal("advisor_tool_result_error"),errorCode:IZ.string()})]))),Gh4=k0(()=>W0(IZ.object({}).strict())),Jh4=X6({id:"anthropic.advisor_20260301",inputSchema:Gh4,outputSchema:fq8,supportsDeferredResults:!0}),Wh4=k0(()=>W0(u3.object({maxCharacters:u3.number().optional()}))),Hh4=k0(()=>W0(u3.object({command:u3.enum(["view","create","str_replace","insert"]),path:u3.string(),file_text:u3.string().optional(),insert_line:u3.number().int().optional(),new_str:u3.string().optional(),insert_text:u3.string().optional(),old_str:u3.string().optional(),view_range:u3.array(u3.number().int()).optional()}))),Nh4=l4({id:"anthropic.text_editor_20250728",inputSchema:Hh4}),Fh4=k0(()=>W0(d9.object({maxUses:d9.number().optional(),allowedDomains:d9.array(d9.string()).optional(),blockedDomains:d9.array(d9.string()).optional(),userLocation:d9.object({type:d9.literal("approximate"),city:d9.string().optional(),region:d9.string().optional(),country:d9.string().optional(),timezone:d9.string().optional()}).optional()}))),Bh4=k0(()=>W0(d9.array(d9.object({url:d9.string(),title:d9.string().nullable(),pageAge:d9.string().nullable(),encryptedContent:d9.string(),type:d9.literal("web_search_result")})))),Oh4=k0(()=>W0(d9.object({query:d9.string()}))),wh4=X6({id:"anthropic.web_search_20260209",inputSchema:Oh4,outputSchema:Bh4,supportsDeferredResults:!0}),Dh4=k0(()=>W0(m9.object({maxUses:m9.number().optional(),allowedDomains:m9.array(m9.string()).optional(),blockedDomains:m9.array(m9.string()).optional(),userLocation:m9.object({type:m9.literal("approximate"),city:m9.string().optional(),region:m9.string().optional(),country:m9.string().optional(),timezone:m9.string().optional()}).optional()}))),bq8=k0(()=>W0(m9.array(m9.object({url:m9.string(),title:m9.string().nullable(),pageAge:m9.string().nullable(),encryptedContent:m9.string(),type:m9.literal("web_search_result")})))),Eh4=k0(()=>W0(m9.object({query:m9.string()}))),zh4=X6({id:"anthropic.web_search_20250305",inputSchema:Eh4,outputSchema:bq8,supportsDeferredResults:!0}),Ph4=k0(()=>W0(S$.object({maxUses:S$.number().optional(),allowedDomains:S$.array(S$.string()).optional(),blockedDomains:S$.array(S$.string()).optional(),citations:S$.object({enabled:S$.boolean()}).optional(),maxContentTokens:S$.number().optional()}))),Ah4=k0(()=>W0(S$.object({type:S$.literal("web_fetch_result"),url:S$.string(),content:S$.object({type:S$.literal("document"),title:S$.string().nullable(),citations:S$.object({enabled:S$.boolean()}).optional(),source:S$.union([S$.object({type:S$.literal("base64"),mediaType:S$.literal("application/pdf"),data:S$.string()}),S$.object({type:S$.literal("text"),mediaType:S$.literal("text/plain"),data:S$.string()})])}),retrievedAt:S$.string().nullable()}))),Th4=k0(()=>W0(S$.object({url:S$.string()}))),Rh4=X6({id:"anthropic.web_fetch_20260209",inputSchema:Th4,outputSchema:Ah4,supportsDeferredResults:!0}),qh4=k0(()=>W0(C$.object({maxUses:C$.number().optional(),allowedDomains:C$.array(C$.string()).optional(),blockedDomains:C$.array(C$.string()).optional(),citations:C$.object({enabled:C$.boolean()}).optional(),maxContentTokens:C$.number().optional()}))),yq8=k0(()=>W0(C$.object({type:C$.literal("web_fetch_result"),url:C$.string(),content:C$.object({type:C$.literal("document"),title:C$.string().nullable(),citations:C$.object({enabled:C$.boolean()}).optional(),source:C$.union([C$.object({type:C$.literal("base64"),mediaType:C$.literal("application/pdf"),data:C$.string()}),C$.object({type:C$.literal("text"),mediaType:C$.literal("text/plain"),data:C$.string()})])}),retrievedAt:C$.string().nullable()}))),Mh4=k0(()=>W0(C$.object({url:C$.string()}))),Vh4=X6({id:"anthropic.web_fetch_20250910",inputSchema:Mh4,outputSchema:yq8,supportsDeferredResults:!0});gq8=k0(()=>W0(CK.object({type:CK.literal("code_execution_result"),stdout:CK.string(),stderr:CK.string(),return_code:CK.number(),content:CK.array(CK.object({type:CK.literal("code_execution_output"),file_id:CK.string()})).optional().default([])}))),Ch4=k0(()=>W0(CK.object({code:CK.string()}))),_h4=X6({id:"anthropic.code_execution_20250522",inputSchema:Ch4,outputSchema:gq8}),hq8=k0(()=>W0(J8.discriminatedUnion("type",[J8.object({type:J8.literal("code_execution_result"),stdout:J8.string(),stderr:J8.string(),return_code:J8.number(),content:J8.array(J8.object({type:J8.literal("code_execution_output"),file_id:J8.string()})).optional().default([])}),J8.object({type:J8.literal("bash_code_execution_result"),content:J8.array(J8.object({type:J8.literal("bash_code_execution_output"),file_id:J8.string()})),stdout:J8.string(),stderr:J8.string(),return_code:J8.number()}),J8.object({type:J8.literal("bash_code_execution_tool_result_error"),error_code:J8.string()}),J8.object({type:J8.literal("text_editor_code_execution_tool_result_error"),error_code:J8.string()}),J8.object({type:J8.literal("text_editor_code_execution_view_result"),content:J8.string(),file_type:J8.string(),num_lines:J8.number().nullable(),start_line:J8.number().nullable(),total_lines:J8.number().nullable()}),J8.object({type:J8.literal("text_editor_code_execution_create_result"),is_file_update:J8.boolean()}),J8.object({type:J8.literal("text_editor_code_execution_str_replace_result"),lines:J8.array(J8.string()).nullable(),new_lines:J8.number().nullable(),new_start:J8.number().nullable(),old_lines:J8.number().nullable(),old_start:J8.number().nullable()})]))),xh4=k0(()=>W0(J8.discriminatedUnion("type",[J8.object({type:J8.literal("programmatic-tool-call"),code:J8.string()}),J8.object({type:J8.literal("bash_code_execution"),command:J8.string()}),J8.discriminatedUnion("command",[J8.object({type:J8.literal("text_editor_code_execution"),command:J8.literal("view"),path:J8.string()}),J8.object({type:J8.literal("text_editor_code_execution"),command:J8.literal("create"),path:J8.string(),file_text:J8.string().nullish()}),J8.object({type:J8.literal("text_editor_code_execution"),command:J8.literal("str_replace"),path:J8.string(),old_str:J8.string(),new_str:J8.string()})])]))),fh4=X6({id:"anthropic.code_execution_20250825",inputSchema:xh4,outputSchema:hq8,supportsDeferredResults:!0}),uq8=k0(()=>W0(i1.discriminatedUnion("type",[i1.object({type:i1.literal("code_execution_result"),stdout:i1.string(),stderr:i1.string(),return_code:i1.number(),content:i1.array(i1.object({type:i1.literal("code_execution_output"),file_id:i1.string()})).optional().default([])}),i1.object({type:i1.literal("encrypted_code_execution_result"),encrypted_stdout:i1.string(),stderr:i1.string(),return_code:i1.number(),content:i1.array(i1.object({type:i1.literal("code_execution_output"),file_id:i1.string()})).optional().default([])}),i1.object({type:i1.literal("bash_code_execution_result"),content:i1.array(i1.object({type:i1.literal("bash_code_execution_output"),file_id:i1.string()})),stdout:i1.string(),stderr:i1.string(),return_code:i1.number()}),i1.object({type:i1.literal("bash_code_execution_tool_result_error"),error_code:i1.string()}),i1.object({type:i1.literal("text_editor_code_execution_tool_result_error"),error_code:i1.string()}),i1.object({type:i1.literal("text_editor_code_execution_view_result"),content:i1.string(),file_type:i1.string(),num_lines:i1.number().nullable(),start_line:i1.number().nullable(),total_lines:i1.number().nullable()}),i1.object({type:i1.literal("text_editor_code_execution_create_result"),is_file_update:i1.boolean()}),i1.object({type:i1.literal("text_editor_code_execution_str_replace_result"),lines:i1.array(i1.string()).nullable(),new_lines:i1.number().nullable(),new_start:i1.number().nullable(),old_lines:i1.number().nullable(),old_start:i1.number().nullable()})]))),yh4=k0(()=>W0(i1.discriminatedUnion("type",[i1.object({type:i1.literal("programmatic-tool-call"),code:i1.string()}),i1.object({type:i1.literal("bash_code_execution"),command:i1.string()}),i1.discriminatedUnion("command",[i1.object({type:i1.literal("text_editor_code_execution"),command:i1.literal("view"),path:i1.string()}),i1.object({type:i1.literal("text_editor_code_execution"),command:i1.literal("create"),path:i1.string(),file_text:i1.string().nullish()}),i1.object({type:i1.literal("text_editor_code_execution"),command:i1.literal("str_replace"),path:i1.string(),old_str:i1.string(),new_str:i1.string()})])]))),gh4=X6({id:"anthropic.code_execution_20260120",inputSchema:yh4,outputSchema:uq8,supportsDeferredResults:!0}),cq8=k0(()=>W0(o_.array(o_.object({type:o_.literal("tool_reference"),toolName:o_.string()})))),uh4=k0(()=>W0(o_.object({pattern:o_.string(),limit:o_.number().optional()}))),ch4=X6({id:"anthropic.tool_search_regex_20251119",inputSchema:uh4,outputSchema:cq8,supportsDeferredResults:!0});lq8=new Set(["date-time","time","date","duration","email","hostname","uri","ipv4","ipv6","uuid"]),ph4=["minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","minLength","maxLength","pattern","minItems","maxItems","uniqueItems","minProperties","maxProperties","not"];Zu4=k0(()=>W0(j51.object({command:j51.string(),restart:j51.boolean().optional()}))),Xu4=l4({id:"anthropic.bash_20241022",inputSchema:Zu4}),Qu4=k0(()=>W0(P51.object({command:P51.string(),restart:P51.boolean().optional()}))),Yu4=l4({id:"anthropic.bash_20250124",inputSchema:Qu4}),Gu4=k0(()=>W0(tr.object({action:tr.enum(["key","type","mouse_move","left_click","left_click_drag","right_click","middle_click","double_click","screenshot","cursor_position"]),coordinate:tr.array(tr.number().int()).optional(),text:tr.string().optional()}))),Ju4=l4({id:"anthropic.computer_20241022",inputSchema:Gu4}),Ku4=k0(()=>W0(h3.object({action:h3.enum(["key","hold_key","type","cursor_position","mouse_move","left_mouse_down","left_mouse_up","left_click","left_click_drag","right_click","middle_click","double_click","triple_click","scroll","wait","screenshot"]),coordinate:h3.tuple([h3.number().int(),h3.number().int()]).optional(),duration:h3.number().optional(),scroll_amount:h3.number().optional(),scroll_direction:h3.enum(["up","down","left","right"]).optional(),start_coordinate:h3.tuple([h3.number().int(),h3.number().int()]).optional(),text:h3.string().optional()}))),Wu4=l4({id:"anthropic.computer_20250124",inputSchema:Ku4}),Hu4=k0(()=>W0(k7.object({action:k7.enum(["key","hold_key","type","cursor_position","mouse_move","left_mouse_down","left_mouse_up","left_click","left_click_drag","right_click","middle_click","double_click","triple_click","scroll","wait","screenshot","zoom"]),coordinate:k7.tuple([k7.number().int(),k7.number().int()]).optional(),duration:k7.number().optional(),region:k7.tuple([k7.number().int(),k7.number().int(),k7.number().int(),k7.number().int()]).optional(),scroll_amount:k7.number().optional(),scroll_direction:k7.enum(["up","down","left","right"]).optional(),start_coordinate:k7.tuple([k7.number().int(),k7.number().int()]).optional(),text:k7.string().optional()}))),Nu4=l4({id:"anthropic.computer_20251124",inputSchema:Hu4}),Uu4=k0(()=>W0(m$.discriminatedUnion("command",[m$.object({command:m$.literal("view"),path:m$.string(),view_range:m$.tuple([m$.number(),m$.number()]).optional()}),m$.object({command:m$.literal("create"),path:m$.string(),file_text:m$.string()}),m$.object({command:m$.literal("str_replace"),path:m$.string(),old_str:m$.string(),new_str:m$.string()}),m$.object({command:m$.literal("insert"),path:m$.string(),insert_line:m$.number(),insert_text:m$.string()}),m$.object({command:m$.literal("delete"),path:m$.string()}),m$.object({command:m$.literal("rename"),old_path:m$.string(),new_path:m$.string()})]))),Fu4=l4({id:"anthropic.memory_20250818",inputSchema:Uu4}),Bu4=k0(()=>W0(IH.object({command:IH.enum(["view","create","str_replace","insert","undo_edit"]),path:IH.string(),file_text:IH.string().optional(),insert_line:IH.number().int().optional(),new_str:IH.string().optional(),insert_text:IH.string().optional(),old_str:IH.string().optional(),view_range:IH.array(IH.number().int()).optional()}))),Ou4=l4({id:"anthropic.text_editor_20241022",inputSchema:Bu4}),wu4=k0(()=>W0(qH.object({command:qH.enum(["view","create","str_replace","insert","undo_edit"]),path:qH.string(),file_text:qH.string().optional(),insert_line:qH.number().int().optional(),new_str:qH.string().optional(),insert_text:qH.string().optional(),old_str:qH.string().optional(),view_range:qH.array(qH.number().int()).optional()}))),Lu4=l4({id:"anthropic.text_editor_20250124",inputSchema:wu4}),Du4=k0(()=>W0(MH.object({command:MH.enum(["view","create","str_replace","insert"]),path:MH.string(),file_text:MH.string().optional(),insert_line:MH.number().int().optional(),new_str:MH.string().optional(),insert_text:MH.string().optional(),old_str:MH.string().optional(),view_range:MH.array(MH.number().int()).optional()}))),Eu4=l4({id:"anthropic.text_editor_20250429",inputSchema:Du4}),zu4=k0(()=>W0(r_.array(r_.object({type:r_.literal("tool_reference"),toolName:r_.string()})))),ju4=k0(()=>W0(r_.object({query:r_.string(),limit:r_.number().optional()}))),Pu4=X6({id:"anthropic.tool_search_bm25_20251119",inputSchema:ju4,outputSchema:zu4,supportsDeferredResults:!0}),Tu4={advisor_20260301:Kh4,bash_20241022:Xu4,bash_20250124:Yu4,codeExecution_20250522:vh4,codeExecution_20250825:bh4,codeExecution_20260120:hh4,computer_20241022:Ju4,computer_20250124:Wu4,computer_20251124:Nu4,memory_20250818:Fu4,textEditor_20241022:Ou4,textEditor_20250124:Lu4,textEditor_20250429:Eu4,textEditor_20250728:Uh4,webFetch_20250910:kh4,webFetch_20260209:Ih4,webSearch_20250305:jh4,webSearch_20260209:Lh4,toolSearchRegex_20251119:lh4,toolSearchBm25_20251119:Au4};f1Z=or()});import{z as sU}from"zod/v4";import{z as rr}from"zod/v4";import{z as RX}from"zod/v4";import{z as $1}from"zod/v4";import{z as z$}from"zod/v4";import{z as Hu}from"zod/v4";import{z as ou4}from"zod/v4";import{z as ar}from"zod/v4";import{z as $c4}from"zod/v4";import{z as a_}from"zod/v4";import{z as Yc4}from"zod/v4";import{z as R51}from"zod/v4";import{z as s_}from"zod/v4";import{z as j9}from"zod/v4";import{z as R0}from"zod/v4";import{z as a1}from"zod/v4";function mq8($){var Z,X,Q,Y;if($==null)return{inputTokens:{total:void 0,noCache:void 0,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:void 0,text:void 0,reasoning:void 0},raw:void 0};let G=(Z=$.promptTokenCount)!=null?Z:0,J=(X=$.candidatesTokenCount)!=null?X:0,K=(Q=$.cachedContentTokenCount)!=null?Q:0,W=(Y=$.thoughtsTokenCount)!=null?Y:0;return{inputTokens:{total:G,noCache:G-K,cacheRead:K,cacheWrite:void 0},outputTokens:{total:J+W,text:J,reasoning:W},raw:$}}function _K($,Z=!0){if($==null)return;if(Cu4($)){if(Z)return;if(typeof $==="object"&&$.description)return{type:"object",description:$.description};return{type:"object"}}if(typeof $==="boolean")return{type:"boolean",properties:{}};let{type:X,description:Q,required:Y,properties:G,items:J,allOf:K,anyOf:W,oneOf:H,format:N,const:U,minLength:F,enum:B}=$,O={};if(Q)O.description=Q;if(Y)O.required=Y;if(N)O.format=N;if(U!==void 0)O.enum=[U];if(X)if(Array.isArray(X)){let L=X.includes("null"),D=X.filter((E)=>E!=="null");if(D.length===0)O.type="null";else if(O.anyOf=D.map((E)=>({type:E})),L)O.nullable=!0}else O.type=X;if(B!==void 0)O.enum=B;if(G!=null)O.properties=Object.entries(G).reduce((L,[D,E])=>{return L[D]=_K(E,!1),L},{});if(J)O.items=Array.isArray(J)?J.map((L)=>_K(L,!1)):_K(J,!1);if(K)O.allOf=K.map((L)=>_K(L,!1));if(W)if(W.some((L)=>typeof L==="object"&&(L==null?void 0:L.type)==="null")){let L=W.filter((D)=>!(typeof D==="object"&&(D==null?void 0:D.type)==="null"));if(L.length===1){let D=_K(L[0],!1);if(typeof D==="object")O.nullable=!0,Object.assign(O,D)}else O.anyOf=L.map((D)=>_K(D,!1)),O.nullable=!0}else O.anyOf=W.map((L)=>_K(L,!1));if(H)O.oneOf=H.map((L)=>_K(L,!1));if(F!==void 0)O.minLength=F;return O}function Cu4($){return $!=null&&typeof $==="object"&&$.type==="object"&&($.properties==null||Object.keys($.properties).length===0)&&!$.additionalProperties}function iq8($,Z){let X=[Z,"google","googleVertex","vertex"].filter((Q,Y,G)=>{return G.indexOf(Q)===Y});for(let Q of X){let Y=$==null?void 0:$[Q];if(Y!=null)return Y}}function xu4($){let Z=vu4.exec($);if(Z==null)return;return{mediaType:Z[1],data:Z[2]}}function fu4($){let Z=xu4($);if(Z==null)return;return{inlineData:{mimeType:Z.mediaType,data:Z.data}}}function bu4($,Z,X,Q){let Y=[],G=[];for(let J of X)switch(J.type){case"text":{G.push(J.text);break}case"image-data":case"file-data":{Y.push({inlineData:{mimeType:J.mediaType,data:J.data}});break}case"image-url":case"file-url":{let K=fu4(J.url);if(K!=null)Y.push(K);else G.push(JSON.stringify(J));break}default:{G.push(JSON.stringify(J));break}}$.push({functionResponse:{...Q!=null?{id:Q}:{},name:Z,response:{name:Z,content:G.length>0?G.join(`
2370
2370
  `):"Tool executed successfully."},...Y.length>0?{parts:Y}:{}}})}function yu4($,Z,X,Q){for(let Y of X)switch(Y.type){case"text":$.push({functionResponse:{...Q!=null?{id:Q}:{},name:Z,response:{name:Z,content:Y.text}}});break;case"image-data":$.push({inlineData:{mimeType:String(Y.mediaType),data:String(Y.data)}},{text:"Tool executed successfully and returned this image as a response"});break;default:$.push({text:JSON.stringify(Y)});break}}function gu4($,Z){var X,Q,Y,G,J;let K=[],W=[],H=!0,N=(X=Z==null?void 0:Z.isGemmaModel)!=null?X:!1,U=(Q=Z==null?void 0:Z.isGemini3Model)!=null?Q:!1,F=(Y=Z==null?void 0:Z.providerOptionsName)!=null?Y:"google",B=(G=Z==null?void 0:Z.supportsFunctionResponseParts)!=null?G:!0,O=Z==null?void 0:Z.onWarning,L=!1,D=[],E=(z)=>{return D.push(z),L=!0,_u4};for(let{role:z,content:j}of $)switch(z){case"system":{if(!H)throw new c4({functionality:"system messages are only supported at the beginning of the conversation"});K.push({text:j});break}case"user":{H=!1;let P=[];for(let A of j)switch(A.type){case"text":{P.push({text:A.text});break}case"file":{let I=A.mediaType==="image/*"?"image/jpeg":A.mediaType;P.push(A.data instanceof URL?{fileData:{mimeType:I,fileUri:A.data.toString()}}:{inlineData:{mimeType:I,data:AZ(A.data)}});break}}W.push({role:"user",parts:P});break}case"assistant":{H=!1,W.push({role:"model",parts:j.map((P)=>{let A=iq8(P.providerOptions,F),I=(A==null?void 0:A.thoughtSignature)!=null?String(A.thoughtSignature):void 0;switch(P.type){case"text":return P.text.length===0?void 0:{text:P.text,thoughtSignature:I};case"reasoning":return P.text.length===0?void 0:{text:P.text,thought:!0,thoughtSignature:I};case"file":{if(P.data instanceof URL)throw new c4({functionality:"File data URLs in assistant messages are not supported"});return{inlineData:{mimeType:P.mediaType,data:AZ(P.data)},...(A==null?void 0:A.thought)===!0?{thought:!0}:{},thoughtSignature:I}}case"tool-call":{let q=(A==null?void 0:A.serverToolCallId)!=null?String(A.serverToolCallId):void 0,M=(A==null?void 0:A.serverToolType)!=null?String(A.serverToolType):void 0,S=I!=null?I:U?E(P.toolName):void 0;if(q&&M)return{toolCall:{toolType:M,args:typeof P.input==="string"?JSON.parse(P.input):P.input,id:q},thoughtSignature:S};return{functionCall:{...P.toolCallId!=null?{id:P.toolCallId}:{},name:P.toolName,args:P.input},thoughtSignature:S}}case"tool-result":{let q=(A==null?void 0:A.serverToolCallId)!=null?String(A.serverToolCallId):void 0,M=(A==null?void 0:A.serverToolType)!=null?String(A.serverToolType):void 0;if(q&&M)return{toolResponse:{toolType:M,response:P.output.type==="json"?P.output.value:{},id:q},thoughtSignature:I};return}}}).filter((P)=>P!==void 0)});break}case"tool":{H=!1;let P=[];for(let A of j){if(A.type==="tool-approval-response")continue;let I=iq8(A.providerOptions,F),q=(I==null?void 0:I.serverToolCallId)!=null?String(I.serverToolCallId):void 0,M=(I==null?void 0:I.serverToolType)!=null?String(I.serverToolType):void 0;if(q&&M){let d=(I==null?void 0:I.thoughtSignature)!=null?String(I.thoughtSignature):void 0;if(W.length>0){let f=W[W.length-1];if(f.role==="model"){f.parts.push({toolResponse:{toolType:M,response:A.output.type==="json"?A.output.value:{},id:q},thoughtSignature:d});continue}}}let S=A.output;if(S.type==="content")if(B)bu4(P,A.toolName,S.value,A.toolCallId);else yu4(P,A.toolName,S.value,A.toolCallId);else P.push({functionResponse:{...A.toolCallId!=null?{id:A.toolCallId}:{},name:A.toolName,response:{name:A.toolName,content:S.type==="execution-denied"?(J=S.reason)!=null?J:"Tool execution denied.":S.value}}})}W.push({role:"user",parts:P});break}}if(N&&K.length>0&&W.length>0&&W[0].role==="user"){let z=K.map((j)=>j.text).join(`
2371
2371
 
2372
2372
  `);W[0].parts.unshift({text:z+`