sliccy 6.248.13 → 6.248.15

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 (199) hide show
  1. package/dist/ui/.vite/manifest.json +473 -473
  2. package/dist/ui/assets/{account-store-D4Humqb-.js → account-store-C8ku_32k.js} +2 -2
  3. package/dist/ui/assets/{account-store-AloIt5Ss.js → account-store-CLrcVXc0.js} +1 -1
  4. package/dist/ui/assets/{adobe-COzZgYMJ.js → adobe-Cpi2aE-H.js} +1 -1
  5. package/dist/ui/assets/{adobe-DzPNN5WH.js → adobe-ZF88lAqt.js} +2 -2
  6. package/dist/ui/assets/{agent-panels-C7WGWk6D.js → agent-panels-BeptN8xj.js} +1 -1
  7. package/dist/ui/assets/{almost-bash-shell-headless--HYnQClo.js → almost-bash-shell-headless-BVria6dz.js} +12 -12
  8. package/dist/ui/assets/{anthropic-messages-BPiITV7m.js → anthropic-messages-pITcoTin.js} +3 -3
  9. package/dist/ui/assets/{apply-layout-C4DLtjYf.js → apply-layout-mZoFZ7NI.js} +1 -1
  10. package/dist/ui/assets/{azure-openai-DCtV7Fk7.js → azure-openai-BuzUN1Zv.js} +1 -1
  11. package/dist/ui/assets/{azure-openai-qBC0T6wP.js → azure-openai-D8taz7yq.js} +1 -1
  12. package/dist/ui/assets/{azure-openai-responses-CYEKOLNU.js → azure-openai-responses-BzfTIQxM.js} +1 -1
  13. package/dist/ui/assets/{backend-hostfs-C_GQqMGj.js → backend-hostfs-BlwgXw0-.js} +1 -1
  14. package/dist/ui/assets/{bedrock-camp-BRe8SyVL.js → bedrock-camp-Drg4mDwe.js} +1 -1
  15. package/dist/ui/assets/{capability-ChjrBUX1.js → capability-COwjFLjM.js} +2 -2
  16. package/dist/ui/assets/{cdp-CCSeAKYa.js → cdp-BECQB1rP.js} +1 -1
  17. package/dist/ui/assets/{cerebras-D05pSaD3.js → cerebras-DZZFW27U.js} +1 -1
  18. package/dist/ui/assets/{cerebras-BlBAjiPm.js → cerebras-DfDfqh_L.js} +1 -1
  19. package/dist/ui/assets/{classifier-shared-2vXBXYjG.js → classifier-shared-1BfNmzbv.js} +1 -1
  20. package/dist/ui/assets/{cloudflare-workers-ai-system-one-gkmS2Nb_.js → cloudflare-workers-ai-system-one-CYstFSnj.js} +1 -1
  21. package/dist/ui/assets/{compat-d34y6SaJ.js → compat-TaBTsXFP.js} +2 -2
  22. package/dist/ui/assets/{composer-speech-ZEQzpxXl.js → composer-speech-B1kWFuju.js} +1 -1
  23. package/dist/ui/assets/{connect-surface-DVe7YnEx.js → connect-surface-CXFbDGll.js} +1 -1
  24. package/dist/ui/assets/{core-DfJhnyZb.js → core-kdG72Y8N.js} +1 -1
  25. package/dist/ui/assets/{directed-approval-DpSG1Fn9.js → directed-approval-LQT_TPqz.js} +1 -1
  26. package/dist/ui/assets/{discovery-preference-DZcZKow3.js → discovery-preference-C-pw_A76.js} +1 -1
  27. package/dist/ui/assets/{dist-BZDZf9iZ.js → dist-AEgtkPbB.js} +1 -1
  28. package/dist/ui/assets/{dist-sPwgAbDH.js → dist-BOzr2Ip-.js} +1 -1
  29. package/dist/ui/assets/{dist-C3U_YVHW.js → dist-CKtiDzqm.js} +1 -1
  30. package/dist/ui/assets/{dist-Dxh_321I.js → dist-Cr80TbAt.js} +1 -1
  31. package/dist/ui/assets/{dist-Bkks4gfH.js → dist-DMTrP4j6.js} +1 -1
  32. package/dist/ui/assets/{dist-CTibI9AZ.js → dist-EaD2nXS1.js} +1 -1
  33. package/dist/ui/assets/{emscripten-vfs-hook-rbqoLuA5.js → emscripten-vfs-hook-CnPmEK30.js} +1 -1
  34. package/dist/ui/assets/{env-api-keys-Ds64PXJ4.js → env-api-keys-Cfrk_k8Z.js} +1 -1
  35. package/dist/ui/assets/esp8266-mbfP83qK.js +1 -0
  36. package/dist/ui/assets/{esptool-operations-CndxwE1S.js → esptool-operations-CTZQdeQU.js} +2 -2
  37. package/dist/ui/assets/{float-topology-PI5i_WsZ.js → float-topology-DJxhvO9u.js} +1 -1
  38. package/dist/ui/assets/{follower-navigate-watcher-B3g-lkMJ.js → follower-navigate-watcher-BThbqvla.js} +1 -1
  39. package/dist/ui/assets/{frozen-archive-writer-D6ckorva.js → frozen-archive-writer-BTbtadrW.js} +1 -1
  40. package/dist/ui/assets/{frozen-archive-writer-ClcpBoUl.js → frozen-archive-writer-CUzf7C3s.js} +1 -1
  41. package/dist/ui/assets/{frozen-session-delete-_74oIhfQ.js → frozen-session-delete-CyRcONHk.js} +1 -1
  42. package/dist/ui/assets/{frozen-session-identity-DW7M6tap.js → frozen-session-identity-BCGVU2K1.js} +1 -1
  43. package/dist/ui/assets/{frozen-session-identity-DRez4L_k.js → frozen-session-identity-DVcpz2HB.js} +1 -1
  44. package/dist/ui/assets/{fs-CQpIxK2e.js → fs-DSnZb1DK.js} +2 -2
  45. package/dist/ui/assets/{gelatiere-unit-DY9kFx7W.js → gelatiere-unit-CLfqVD6U.js} +1 -1
  46. package/dist/ui/assets/{github-BAVQKGLM.js → github--CcFgkAY.js} +2 -2
  47. package/dist/ui/assets/{github-seYRLByd.js → github-ChxmjcJc.js} +1 -1
  48. package/dist/ui/assets/{github-copilot-NuiVJlRe.js → github-copilot-Bt2MljG0.js} +1 -1
  49. package/dist/ui/assets/{github-copilot-B2ui266i.js → github-copilot-DRF3abOV.js} +1 -1
  50. package/dist/ui/assets/{google-generative-ai-y59nuAoz.js → google-generative-ai-_4RGA5R9.js} +1 -1
  51. package/dist/ui/assets/{google-shared-BixQtMJk.js → google-shared-BmjkwexI.js} +1 -1
  52. package/dist/ui/assets/{google-vertex-BuV_pgMi.js → google-vertex-CCT-gmBZ.js} +1 -1
  53. package/dist/ui/assets/{hear-LEawuxbU.js → hear-BGGOzrLe.js} +1 -1
  54. package/dist/ui/assets/icons-CPOTRcvO.js +1 -0
  55. package/dist/ui/assets/{js-realm-worker-BQ2E7b6Z.js → js-realm-worker-Qikr6DIj.js} +2 -2
  56. package/dist/ui/assets/{jsh-executor-BA7Owezg.js → jsh-executor-Cduj8RKN.js} +3 -3
  57. package/dist/ui/assets/{kernel-worker-Bl7wfxQy.js → kernel-worker-DKhuL-SB.js} +8 -8
  58. package/dist/ui/assets/{kokoro-g58mp2Gg.js → kokoro-BZ2oL9at.js} +1 -1
  59. package/dist/ui/assets/{legacy-api-aliases-DZ7QKXPR.js → legacy-api-aliases-BqXqjuwj.js} +1 -1
  60. package/dist/ui/assets/{legacy-styles-CbYwED5J.js → legacy-styles-CGcVbQni.js} +1 -1
  61. package/dist/ui/assets/{lick-ws-bridge-BIajXq6B.js → lick-ws-bridge-Bgd2UUqy.js} +1 -1
  62. package/dist/ui/assets/{lick-ws-bridge-BEHNQbo5.js → lick-ws-bridge-Cy-M-w5Q.js} +1 -1
  63. package/dist/ui/assets/{live-session-curation-BJVU7yfS.js → live-session-curation-DKF46wEh.js} +1 -1
  64. package/dist/ui/assets/{live-session-curation-C8cnTFuk.js → live-session-curation-w6IDH4Wx.js} +1 -1
  65. package/dist/ui/assets/{live-session-snapshot-DB7ATVqO.js → live-session-snapshot-DCT_jWTD.js} +1 -1
  66. package/dist/ui/assets/{local-llm-Dxm6T0ph.js → local-llm-BzQlnS5L.js} +1 -1
  67. package/dist/ui/assets/{local-llm-B72jeBdJ.js → local-llm-DUc-GBj9.js} +1 -1
  68. package/dist/ui/assets/{main-pG2z7nDr.js → main-CWx8ZbOh.js} +3 -3
  69. package/dist/ui/assets/{main-cherry-Cndxk3tr.js → main-cherry-qefabkXK.js} +1 -1
  70. package/dist/ui/assets/{mcp-command-R_syvmA2.js → mcp-command-BMbHOLse.js} +10 -10
  71. package/dist/ui/assets/{memory-curation-seam-xAt4_ZGt.js → memory-curation-seam-DqgqK6CR.js} +1 -1
  72. package/dist/ui/assets/{memory-health-N-Qft3RQ.js → memory-health-CyDp9rny.js} +1 -1
  73. package/dist/ui/assets/{memory-write-execute-CcPwzxh2.js → memory-write-execute-mLtLK-OJ.js} +1 -1
  74. package/dist/ui/assets/{merge-folded-cost-into-frozen-D5QzQftk.js → merge-folded-cost-into-frozen-VpR7-OO_.js} +1 -1
  75. package/dist/ui/assets/{mistral-conversations-BbeDfELF.js → mistral-conversations-BTfu6zaw.js} +1 -1
  76. package/dist/ui/assets/{models-K_BYbYJy.js → models-DuCVW_cU.js} +1 -1
  77. package/dist/ui/assets/{mount-Cvx8MHrJ.js → mount-iiKbRe20.js} +1 -1
  78. package/dist/ui/assets/{new-session-CzmqZfEw.js → new-session-pyHdj7ky.js} +2 -2
  79. package/dist/ui/assets/{node.browser-D-KuY2NZ.js → node.browser-POTNsJTJ.js} +1 -1
  80. package/dist/ui/assets/{oauth-bootstrap-BgBpgpMH.js → oauth-bootstrap-4_xLQ_sb.js} +2 -2
  81. package/dist/ui/assets/{oauth-service-C9_em2OO.js → oauth-service-BTbFz00g.js} +1 -1
  82. package/dist/ui/assets/{onboarding-orchestrator-B0EOdDeN.js → onboarding-orchestrator-CjdNWdMC.js} +1 -1
  83. package/dist/ui/assets/{openai-codex-CBBCnX5G.js → openai-codex-4_vQIXxb.js} +1 -1
  84. package/dist/ui/assets/{openai-codex-responses-CsoNnMnP.js → openai-codex-responses-BQf_Un8s.js} +1 -1
  85. package/dist/ui/assets/{openai-codex-BuzdyFkb.js → openai-codex-uQMjU0_s.js} +1 -1
  86. package/dist/ui/assets/{openai-completions-CwpTiqkV.js → openai-completions-UyX4inUN.js} +1 -1
  87. package/dist/ui/assets/{openai-decisions-C2a995aZ.js → openai-decisions-6D6eupBk.js} +1 -1
  88. package/dist/ui/assets/{openai-responses-CXxDIIaJ.js → openai-responses-Bn1YXtN4.js} +1 -1
  89. package/dist/ui/assets/{openai-responses-shared-Df32ziOu.js → openai-responses-shared-CHC7SqmI.js} +1 -1
  90. package/dist/ui/assets/{openrouter-CajNnUyi.js → openrouter-DneJqayx.js} +1 -1
  91. package/dist/ui/assets/{openrouter-yrPyWZSZ.js → openrouter-TLjYxLOJ.js} +1 -1
  92. package/dist/ui/assets/{openrouter-free-CoKNk8Q9.js → openrouter-free-C9Ks_BoF.js} +1 -1
  93. package/dist/ui/assets/{openrouter-free-DvQSB466.js → openrouter-free-QijswzXp.js} +1 -1
  94. package/dist/ui/assets/{openrouter-oauth-Cwnv6aaR.js → openrouter-oauth-C3NFC0lq.js} +1 -1
  95. package/dist/ui/assets/{openrouter-oauth-Dm2bFG2r.js → openrouter-oauth-CWRFCzx3.js} +1 -1
  96. package/dist/ui/assets/{opfs-mount-DqwXxpJI.js → opfs-mount-DHQkCQyR.js} +1 -1
  97. package/dist/ui/assets/{page-approval-service-BV4pp4cE.js → page-approval-service-1D_bhphG.js} +1 -1
  98. package/dist/ui/assets/{panel-rpc-handlers-0Asc887-.js → panel-rpc-handlers-DJTIyg19.js} +2 -2
  99. package/dist/ui/assets/{panelize-shell-CYWV616_.js → panelize-shell-KnM6qBOd.js} +1 -1
  100. package/dist/ui/assets/{pi-edit-execution-DUHiH3Ek.js → pi-edit-execution-KjYZMQ1M.js} +1 -1
  101. package/dist/ui/assets/{pi-transcript-context-M0uAa_Rs.js → pi-transcript-context-BD-rasES.js} +1 -1
  102. package/dist/ui/assets/preload-helper-BLdHbfdN.js +1 -0
  103. package/dist/ui/assets/{provider-gVV-Tw2o.js → provider-BUOENNXd.js} +1 -1
  104. package/dist/ui/assets/{provider-DQEpec-V.js → provider-C6GKyGbH.js} +2 -2
  105. package/dist/ui/assets/{provider-settings-HdIWRUQi.js → provider-settings-DiWaVtMa.js} +1 -1
  106. package/dist/ui/assets/provider-store-access-BLah3TfA.js +1 -0
  107. package/dist/ui/assets/provider-store-access-DK9jcMFs.js +1 -0
  108. package/dist/ui/assets/{providers-BPtyhTCJ.js → providers-D98KfVHw.js} +2 -2
  109. package/dist/ui/assets/{providers-BqUoo02I.js → providers-DQDxShvT.js} +1 -1
  110. package/dist/ui/assets/{proxied-fetch-Co-YYDT9.js → proxied-fetch-Dcpb4ieV.js} +1 -1
  111. package/dist/ui/assets/{proxied-fetch-raw-C_Y--MLW.js → proxied-fetch-raw-DFOSVEWz.js} +1 -1
  112. package/dist/ui/assets/{quick-llm-DKIeT-Bm.js → quick-llm-BpqDA4jj.js} +1 -1
  113. package/dist/ui/assets/{realm-inprocess-I1Oa37_B.js → realm-inprocess-DB9T1J06.js} +2 -2
  114. package/dist/ui/assets/{realm-unhandled-rejections-5totJ0nZ.js → realm-unhandled-rejections--yhMR2JG.js} +1 -1
  115. package/dist/ui/assets/{realm-unhandled-rejections-Vf408gQs.js → realm-unhandled-rejections-C-dWyWFT.js} +1 -1
  116. package/dist/ui/assets/{recovery-screen-d6N9mctq.js → recovery-screen-DxmS11pP.js} +1 -1
  117. package/dist/ui/assets/{remote-terminal-view-B8EZ4je-.js → remote-terminal-view-CKT9I4xa.js} +3 -3
  118. package/dist/ui/assets/{rest-ops-Bu4Fgr3O.js → rest-ops-DUxY6dMv.js} +1 -1
  119. package/dist/ui/assets/{restore-YHJZnRoZ.js → restore-DBVHFRDn.js} +1 -1
  120. package/dist/ui/assets/{run-Ds5q8C_n.js → run-B2qNRdiQ.js} +2 -2
  121. package/dist/ui/assets/{run-qBD2W0pE.js → run-D6GtWFc7.js} +1 -1
  122. package/dist/ui/assets/{run-QN9mmLnD.js → run-DWu38u8c.js} +1 -1
  123. package/dist/ui/assets/{run-jEnj-WXZ.js → run-DxF2t6YH.js} +2 -2
  124. package/dist/ui/assets/{secret-env-Da2LI-Wl.js → secret-env-BDj2iVgu.js} +1 -1
  125. package/dist/ui/assets/secret-topology-CcM8VDVI.js +1 -0
  126. package/dist/ui/assets/{serve-command-ClUJJ3EB.js → serve-command-Cj91wHBd.js} +2 -2
  127. package/dist/ui/assets/{serve-runtime-WdVepvEi.js → serve-runtime-C6U19az5.js} +1 -1
  128. package/dist/ui/assets/{session-command-memory-CQnSNVmV.js → session-command-memory-DTJrpKQG.js} +2 -2
  129. package/dist/ui/assets/{session-jsonl-BGHEGuWx.js → session-jsonl-CUGtVDjz.js} +1 -1
  130. package/dist/ui/assets/{session-jsonl-BjBaj5ud.js → session-jsonl-PBSNVf5N.js} +1 -1
  131. package/dist/ui/assets/{session-search-index-DFWu63Zi.js → session-search-index-BmWzdxol.js} +1 -1
  132. package/dist/ui/assets/{setup-feature-flags-remote-CUbaBhWB.js → setup-feature-flags-remote-Dcyvcm1c.js} +1 -1
  133. package/dist/ui/assets/{setup-model-catalog-CykSe_Dx.js → setup-model-catalog-9sIjZkxM.js} +1 -1
  134. package/dist/ui/assets/{setup-sprinkle-exec-IU4qWikH.js → setup-sprinkle-exec-CdgElwNt.js} +1 -1
  135. package/dist/ui/assets/{silent-renew-backoff-BMr_pGCU.js → silent-renew-backoff-B9OHOzRe.js} +1 -1
  136. package/dist/ui/assets/{slicc-diff-D8v8ZLu9.js → slicc-diff-BfQJcIZe.js} +1 -1
  137. package/dist/ui/assets/{slicc-editor-CEzmoAZr.js → slicc-editor-CasndIRU.js} +3 -3
  138. package/dist/ui/assets/slicc-editor-tCvqLLxb.js +1 -0
  139. package/dist/ui/assets/slicc-version-QFUwKumj.js +1 -0
  140. package/dist/ui/assets/{soundscape-Blo80kkF.js → soundscape-BotaZrDR.js} +1 -1
  141. package/dist/ui/assets/{speak-DYYfW_FH.js → speak-DHpjynd6.js} +3 -3
  142. package/dist/ui/assets/{sprinkle-manager-6IcFnb1j.js → sprinkle-manager-8dcg9Iza.js} +1 -1
  143. package/dist/ui/assets/{sprinkle-renderer-BnGOcTUx.js → sprinkle-renderer-D0vfMqnl.js} +3 -3
  144. package/dist/ui/assets/{sudo-cs2WnTRn.js → sudo-CNQ60foM.js} +1 -1
  145. package/dist/ui/assets/{supervisor-BULFrqrk.js → supervisor-CPH3uat9.js} +1 -1
  146. package/dist/ui/assets/{sync-dialog-MmcHaZwh.js → sync-dialog-DcHJ8wDd.js} +1 -1
  147. package/dist/ui/assets/{system-one-shared-DLgt2600.js → system-one-shared-sVc-bQkc.js} +1 -1
  148. package/dist/ui/assets/{telemetry-BqfutULb.js → telemetry-kqkj0A7x.js} +1 -1
  149. package/dist/ui/assets/{transform-messages-Bx3wQh2R.js → transform-messages-HTSSP3zz.js} +1 -1
  150. package/dist/ui/assets/{transformers-env-Fm5j4giD.js → transformers-env-C4aTP2JX.js} +1 -1
  151. package/dist/ui/assets/{transformers.web-BR6ghS6P.js → transformers.web-C5VLk0m7.js} +1 -1
  152. package/dist/ui/assets/{tray-leader-CFIVvD5G.js → tray-leader-BO7RLnAz.js} +1 -1
  153. package/dist/ui/assets/{tray-leave-runtime-BSxSDTw5.js → tray-leave-runtime-DrPHvVi6.js} +1 -1
  154. package/dist/ui/assets/{tray-sidecar-DQqVkAjk.js → tray-sidecar-BF8y2nH9.js} +1 -1
  155. package/dist/ui/assets/{typesafe-system-one-CXEHNzQF.js → typesafe-system-one-BdxxnbQu.js} +1 -1
  156. package/dist/ui/assets/{upgrade-detection-MAFg6kZz.js → upgrade-detection-DYeqLwkQ.js} +1 -1
  157. package/dist/ui/assets/{usb-operations-Ccb6x34d.js → usb-operations-DvSWlz_Y.js} +1 -1
  158. package/dist/ui/assets/{voice-reply-Bum2oQcA.js → voice-reply-DVgxPsp4.js} +1 -1
  159. package/dist/ui/assets/{warm-wterm-C7ml3_29.js → warm-wterm-snqvCS0-.js} +1 -1
  160. package/dist/ui/assets/{wc-attach-BJHnH6pd.js → wc-attach-DtB955Cg.js} +3 -3
  161. package/dist/ui/assets/{wc-browser-sNhsHdWm.js → wc-browser-5eX1yDaM.js} +1 -1
  162. package/dist/ui/assets/{wc-computers-CWg9NiMK.js → wc-computers-BQe7QGA5.js} +1 -1
  163. package/dist/ui/assets/{wc-detached-DZvftcPT.js → wc-detached-B448Oceh.js} +1 -1
  164. package/dist/ui/assets/{wc-extension-BaYtWo4q.js → wc-extension-DcxJvbXQ.js} +2 -2
  165. package/dist/ui/assets/{wc-follower-C3skKl26.js → wc-follower-C4HBJRkp.js} +3 -3
  166. package/dist/ui/assets/{wc-follower-oauth-iJKLKYov.js → wc-follower-oauth-DWB_1KrV.js} +1 -1
  167. package/dist/ui/assets/{wc-gelatiere-DaysrnKa.js → wc-gelatiere-DNuoJgyp.js} +1 -1
  168. package/dist/ui/assets/{wc-live-DEo-6NQK.js → wc-live-BMXg1cW0.js} +5 -5
  169. package/dist/ui/assets/{wc-nav-DqmL5N5I.js → wc-nav-C4cQdKiF.js} +2 -2
  170. package/dist/ui/assets/{wc-onboarding-Dg7G2Ykz.js → wc-onboarding-CsrFGEQ2.js} +2 -2
  171. package/dist/ui/assets/{wc-permissions-wBb5q-ot.js → wc-permissions-DMVzE1os.js} +3 -3
  172. package/dist/ui/assets/{wc-permissions-providers-r97Cs0CM.js → wc-permissions-providers-CzfeTK0C.js} +1 -1
  173. package/dist/ui/assets/{wc-placeholder-Dcqr3sQ2.js → wc-placeholder-BSqm7GOK.js} +3 -3
  174. package/dist/ui/assets/{wc-secret-request-DLngmY78.js → wc-secret-request-BMp1_Dqa.js} +1 -1
  175. package/dist/ui/assets/{wc-settings-DhxNLvFd.js → wc-settings-D_rtZFP8.js} +3 -3
  176. package/dist/ui/assets/{wc-shell-RF_bfAGN.js → wc-shell-CbiYuC-u.js} +6 -6
  177. package/dist/ui/assets/{wc-shortcut-config-Cr8zuZad.js → wc-shortcut-config-Dit9NqHJ.js} +1 -1
  178. package/dist/ui/assets/{wc-sprinkles-DyMWm1jp.js → wc-sprinkles-CRU3Bd1x.js} +2 -2
  179. package/dist/ui/assets/{wc-transcript-export-DVyU4B6b.js → wc-transcript-export-CCBgVRIb.js} +2 -2
  180. package/dist/ui/assets/{wc-tray-BjkHiwAE.js → wc-tray-DMpwCD-i.js} +4 -4
  181. package/dist/ui/assets/welcome-detection-CMa9jsjd.js +1 -0
  182. package/dist/ui/assets/{whisper-session-nBcuStI7.js → whisper-session-DOG-n_Gl.js} +2 -2
  183. package/dist/ui/assets/{xai-grok-B0VdJo2K.js → xai-grok-BwRAMV0b.js} +1 -1
  184. package/dist/ui/assets/{xai-grok-B-1EsChx.js → xai-grok-D-s6Eti2.js} +1 -1
  185. package/dist/ui/index.html +12 -12
  186. package/dist/ui/lucide-icons.js +362 -359
  187. package/dist/ui/packages/webapp/index.html +12 -12
  188. package/dist/ui/slicc-diff.js +1 -1
  189. package/dist/ui/slicc-editor.js +1 -1
  190. package/package.json +2 -2
  191. package/dist/ui/assets/esp8266-6UF0nYRf.js +0 -1
  192. package/dist/ui/assets/icons-BUdZEBvI.js +0 -1
  193. package/dist/ui/assets/preload-helper-DjzSQ1t3.js +0 -1
  194. package/dist/ui/assets/provider-store-access-BG9uc1UB.js +0 -1
  195. package/dist/ui/assets/provider-store-access-CkviLtwb.js +0 -1
  196. package/dist/ui/assets/secret-topology-B-7q9k0Q.js +0 -1
  197. package/dist/ui/assets/slicc-editor-CnQU3MQS.js +0 -1
  198. package/dist/ui/assets/slicc-version-D_fWoQ7a.js +0 -1
  199. package/dist/ui/assets/welcome-detection-ZKXELBPe.js +0 -1
@@ -1,10 +1,10 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/node.browser-HQ5SKBOf.js","assets/error-BTdmRKoB.js","assets/node.browser-D-KuY2NZ.js"])))=>i.map(i=>d[i]);
2
- import{n as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{i as n,t as r}from"./diagnostics-B-5VkVir.js";import{c as i,f as a,g as o,h as s,t as c,u as l}from"./models-K_BYbYJy.js";import{t as u}from"./preload-helper-DjzSQ1t3.js";import{n as d,t as f}from"./json-parse-CgFfIg4Q.js";import{t as p}from"./provider-env-CTOcDKrQ.js";import{c as m,i as h,o as g,r as _,s as v}from"./env-api-keys-Ds64PXJ4.js";import{a as y,c as ee,d as te,f as ne,g as b,h as re,i as x,l as ie,m as ae,n as oe,o as se,p as ce,r as le,s as ue,t as de,u as fe}from"./error-BTdmRKoB.js";import{t as pe}from"./headers-FK4rgixo.js";import{i as me,o as he,s as ge}from"./constrained-sampling-DA0j0g9I.js";import{t as _e}from"./provider-retry-RVfYd5Vz.js";import{t as S}from"./sanitize-unicode-DmIE6hZJ.js";import{n as ve,t as ye}from"./github-copilot-headers-DRgtIyTm.js";import{i as be,n as xe,r as Se,t as Ce}from"./transform-messages-Bx3wQh2R.js";var we=15e3,Te=5e3;function Ee(e,t){if(!(e>=5e3))throw new y(`${t} must be at least ${Te}ms (got ${e}); to run without memory sync, pass \`memorySyncIntervalMs: null\` to the worker instead`)}function C(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function w(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var De=/^[a-z][a-z0-9+.-]*:/i,Oe=e=>De.test(e),T=e=>(T=Array.isArray,T(e)),ke=T;function Ae(e){return typeof e==`object`?e??{}:{}}function je(e){if(!e)return!0;for(let t in e)return!1;return!0}function Me(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Pe=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new y(`${e} must be an integer`);if(t<0)throw new y(`${e} must be a positive integer`);return t},Fe=e=>{try{return JSON.parse(e)}catch{return}},Ie=(e,t)=>new Promise(n=>{if(t?.aborted)return n();let r=()=>{clearTimeout(i),n()},i=setTimeout(()=>{t?.removeEventListener(`abort`,r),n()},e);t?.addEventListener(`abort`,r,{once:!0})}),Le=`0.129.0`,Re=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`;function ze(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}var Be=()=>{let e=ze();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":Le,"X-Stainless-OS":Ue(Deno.build.os),"X-Stainless-Arch":He(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":Le,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process?.version??`unknown`};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":Le,"X-Stainless-OS":Ue(globalThis.process.platform??`unknown`),"X-Stainless-Arch":He(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=Ve();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":Le,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":Le,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}};function Ve(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}var He=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,Ue=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`),We,Ge=()=>We??=Be(),Ke=new WeakMap,qe=typeof globalThis.FinalizationRegistry==`function`?new globalThis.FinalizationRegistry(e=>Ze(e)):null;function Je(e,t){return()=>e.removeEventListener(`abort`,t)}function Ye(e,t,n){Ke.set(e,Je(t,n))}function Xe(e,t){Ke.has(t)&&qe?.register(e,t,t)}function Ze(e){let t=Ke.get(e);t&&(Ke.delete(e),qe?.unregister(e),t())}function Qe(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function $e(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function et(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return $e({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function tt(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function nt(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var rt=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)}),it=`RFC3986`,at=e=>String(e),ot={RFC1738:e=>String(e).replace(/%20/g,`+`),RFC3986:at},st=(e,t)=>(st=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),st(e,t)),E=(()=>{let e=[];for(let t=0;t<256;++t)e.push(`%`+((t<16?`0`:``)+t.toString(16)).toUpperCase());return e})(),ct=1024,lt=(e,t,n,r,i)=>{if(e.length===0)return e;let a=e;if(typeof e==`symbol`?a=Symbol.prototype.toString.call(e):typeof e!=`string`&&(a=String(e)),n===`iso-8859-1`)return escape(a).replace(/%u[0-9a-f]{4}/gi,function(e){return`%26%23`+parseInt(e.slice(2),16)+`%3B`});let o=``;for(let e=0;e<a.length;e+=ct){let t=a.length>=ct?a.slice(e,e+ct):a,n=[];for(let e=0;e<t.length;++e){let r=t.charCodeAt(e);if(r===45||r===46||r===95||r===126||r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||i===`RFC1738`&&(r===40||r===41)){n[n.length]=t.charAt(e);continue}if(r<128){n[n.length]=E[r];continue}if(r<2048){n[n.length]=E[192|r>>6]+E[128|r&63];continue}if(r<55296||r>=57344){n[n.length]=E[224|r>>12]+E[128|r>>6&63]+E[128|r&63];continue}e+=1,r=65536+((r&1023)<<10|t.charCodeAt(e)&1023),n[n.length]=E[240|r>>18]+E[128|r>>12&63]+E[128|r>>6&63]+E[128|r&63]}o+=n.join(``)}return o};function ut(e){return!e||typeof e!=`object`?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function dt(e,t){if(T(e)){let n=[];for(let r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)}var ft={brackets(e){return String(e)+`[]`},comma:`comma`,indices(e,t){return String(e)+`[`+t+`]`},repeat(e){return String(e)}},pt=function(e,t){Array.prototype.push.apply(e,T(t)?t:[t])},mt,D={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:`indices`,charset:`utf-8`,charsetSentinel:!1,delimiter:`&`,encode:!0,encodeDotInKeys:!1,encoder:lt,encodeValuesOnly:!1,format:it,formatter:at,indices:!1,serializeDate(e){return(mt??=Function.prototype.call.bind(Date.prototype.toISOString))(e)},skipNulls:!1,strictNullHandling:!1};function ht(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`symbol`||typeof e==`bigint`}var gt={};function _t(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_){let v=e,y=_,ee=0,te=!1;for(;(y=y.get(gt))!==void 0&&!te;){let t=y.get(e);if(ee+=1,t!==void 0){if(t===ee)throw RangeError(`Cyclic object value`);te=!0}y.get(gt)===void 0&&(ee=0)}if(typeof l==`function`?v=l(t,v):v instanceof Date?v=f?.(v):n===`comma`&&T(v)&&(v=dt(v,function(e){return e instanceof Date?f?.(e):e})),v===null){if(a)return c&&!h?c(t,D.encoder,g,`key`,p):t;v=``}if(ht(v)||ut(v)){if(c){let e=h?t:c(t,D.encoder,g,`key`,p);return[m?.(e)+`=`+m?.(c(v,D.encoder,g,`value`,p))]}return[m?.(t)+`=`+m?.(String(v))]}let ne=[];if(v===void 0)return ne;let b;if(n===`comma`&&T(v))h&&c&&(v=dt(v,c)),b=[{value:v.length>0?v.join(`,`)||null:void 0}];else if(T(l))b=l;else{let e=Object.keys(v);b=u?e.sort(u):e}let re=s?String(t).replace(/\./g,`%2E`):String(t),x=r&&T(v)&&v.length===1?re+`[]`:re;if(i&&T(v)&&v.length===0)return x+`[]`;for(let t=0;t<b.length;++t){let y=b[t],te=typeof y==`object`&&y.value!==void 0?y.value:v[y];if(o&&te===null)continue;let re=d&&s?y.replace(/\./g,`%2E`):y,ie=T(v)?typeof n==`function`?n(x,re):x:x+(d?`.`+re:`[`+re+`]`);_.set(e,ee);let ae=new WeakMap;ae.set(gt,_),pt(ne,_t(te,ie,n,r,i,a,o,s,n===`comma`&&h&&T(v)?null:c,l,u,d,f,p,m,h,g,ae))}return ne}function vt(e=D){if(e.allowEmptyArrays!==void 0&&typeof e.allowEmptyArrays!=`boolean`)throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(e.encodeDotInKeys!==void 0&&typeof e.encodeDotInKeys!=`boolean`)throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&e.encoder!==void 0&&typeof e.encoder!=`function`)throw TypeError(`Encoder has to be a function.`);let t=e.charset||D.charset;if(e.charset!==void 0&&e.charset!==`utf-8`&&e.charset!==`iso-8859-1`)throw TypeError(`The charset option must be either utf-8, iso-8859-1, or undefined`);let n=it;if(e.format!==void 0){if(!st(ot,e.format))throw TypeError(`Unknown format option provided.`);n=e.format}let r=ot[n],i=D.filter;(typeof e.filter==`function`||T(e.filter))&&(i=e.filter);let a;if(a=e.arrayFormat&&e.arrayFormat in ft?e.arrayFormat:`indices`in e?e.indices?`indices`:`repeat`:D.arrayFormat,`commaRoundTrip`in e&&typeof e.commaRoundTrip!=`boolean`)throw TypeError("`commaRoundTrip` must be a boolean, or absent");let o=e.allowDots===void 0?e.encodeDotInKeys?!0:D.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix==`boolean`?e.addQueryPrefix:D.addQueryPrefix,allowDots:o,allowEmptyArrays:typeof e.allowEmptyArrays==`boolean`?!!e.allowEmptyArrays:D.allowEmptyArrays,arrayFormat:a,charset:t,charsetSentinel:typeof e.charsetSentinel==`boolean`?e.charsetSentinel:D.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:e.delimiter===void 0?D.delimiter:e.delimiter,encode:typeof e.encode==`boolean`?e.encode:D.encode,encodeDotInKeys:typeof e.encodeDotInKeys==`boolean`?e.encodeDotInKeys:D.encodeDotInKeys,encoder:typeof e.encoder==`function`?e.encoder:D.encoder,encodeValuesOnly:typeof e.encodeValuesOnly==`boolean`?e.encodeValuesOnly:D.encodeValuesOnly,filter:i,format:n,formatter:r,serializeDate:typeof e.serializeDate==`function`?e.serializeDate:D.serializeDate,skipNulls:typeof e.skipNulls==`boolean`?e.skipNulls:D.skipNulls,sort:typeof e.sort==`function`?e.sort:null,strictNullHandling:typeof e.strictNullHandling==`boolean`?e.strictNullHandling:D.strictNullHandling}}function yt(e,t={}){let n=e,r=vt(t),i,a;typeof r.filter==`function`?(a=r.filter,n=a(``,n)):T(r.filter)&&(a=r.filter,i=a);let o=[];if(typeof n!=`object`||!n)return``;let s=ft[r.arrayFormat],c=s===`comma`&&r.commaRoundTrip;i||=Object.keys(n),r.sort&&i.sort(r.sort);let l=new WeakMap;for(let e=0;e<i.length;++e){let t=i[e];r.skipNulls&&n[t]===null||pt(o,_t(n[t],t,s,c,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,l))}let u=o.join(r.delimiter),d=r.addQueryPrefix===!0?`?`:``;return r.charsetSentinel&&(r.charset===`iso-8859-1`?d+=`utf8=%26%2310003%3B&`:d+=`utf8=%E2%9C%93&`),u.length>0?d+u:``}function bt(e){return yt(e,{arrayFormat:`brackets`})}var xt=`urn:ietf:params:oauth:grant-type:jwt-bearer`,St=`refresh_token`,Ct=`/v1/oauth/token`,wt=`oauth-2025-04-20`,Tt=`oidc-federation-2026-04-01`,Et=1<<20;function Dt(e){if(!e)return;let t;try{t=new URL(e)}catch(t){throw new k(`Invalid token endpoint base URL "${e}": ${t}`)}if(t.protocol===`https:`)return;let n=t.hostname.toLowerCase().replace(/^\[|\]$/g,``);if(t.protocol!==`http:`||n!==`localhost`&&n!==`127.0.0.1`&&n!==`::1`)throw new k(`Refusing to send credential over non-https token endpoint "${e}"`)}async function Ot(e,t){let n=await Nt(e),r;try{r=JSON.parse(n)}catch{throw new k(`Token endpoint returned non-JSON response (status ${e.status})`,e.status,O(n),t)}if(!r.access_token)throw new k(`Token endpoint response missing access_token: ${JSON.stringify(O(r))}`,e.status,O(r),t);if(r.token_type&&r.token_type.toLowerCase()!==`bearer`)throw new k(`Token endpoint response: unsupported token_type "${r.token_type}" (want Bearer)`,e.status,O(r),t);return r}var kt=2e3,At=new Set([`error`,`error_description`,`error_uri`]);function O(e){if(e==null)return e;if(typeof e==`string`){let t;try{t=JSON.parse(e)}catch{return e.length<=kt?e:e.slice(0,kt)+`... <${e.length-kt} more chars>`}return JSON.stringify(O(t))}if(typeof e==`object`&&!Array.isArray(e)){let t={};for(let[n,r]of Object.entries(e))At.has(n)&&(t[n]=r);return t}return null}async function jt(e,t=e=>console.warn(`anthropic-sdk: ${e}`)){if(typeof process>`u`||process.platform===`win32`)return;let{fs:n}=await u(async()=>{let{fs:e}=await import(`./node.browser-HQ5SKBOf.js`);return{fs:e}},__vite__mapDeps([0,1])),r=e,i;try{r=await n.promises.realpath(e),i=await n.promises.stat(r)}catch{return}let a=i.mode&511;if(a&18)throw new k(`Credentials file at ${r} is group/world-writable (mode 0o${a.toString(8)}); this allows other local users to plant tokens. Run \`chmod 600 ${r}\`.`);if(a&36)throw new k(`Credentials file at ${r} is group/world-readable (mode 0o${a.toString(8)}); run \`chmod 600 ${r}\` before retrying.`);typeof process.getuid==`function`&&i.uid!==process.getuid()&&t(`credentials file at ${r} is owned by uid ${i.uid} (current process uid ${process.getuid()}); verify this is intentional.`)}async function Mt(e,t){let{fs:n,path:r}=await u(async()=>{let{fs:e,path:t}=await import(`./node.browser-HQ5SKBOf.js`);return{fs:e,path:t}},__vite__mapDeps([0,1])),i=r.dirname(e);await n.promises.mkdir(i,{recursive:!0,mode:448});let a=`${e}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;try{let r=await n.promises.open(a,`w`,384);try{await r.writeFile(JSON.stringify(t,null,2)),await r.sync()}finally{await r.close()}await n.promises.rename(a,e)}catch(e){throw await n.promises.unlink(a).catch(()=>{}),e}try{let e=await n.promises.open(i,`r`);try{await e.sync()}finally{await e.close()}}catch{}}async function Nt(e){if(!e.body)return``;let t=e.body.getReader(),n=[],r=0;for(;;){let{done:e,value:i}=await t.read();if(e)break;if(r+i.length>Et){let e=Et-r;e>0&&n.push(i.subarray(0,e)),await t.cancel();break}n.push(i),r+=i.length}let i;if(n.length===1)i=n[0];else{i=new Uint8Array(n.reduce((e,t)=>e+t.length,0));let e=0;for(let t of n)i.set(t,e),e+=t.length}return new TextDecoder(`utf-8`).decode(i)}var k=class extends y{constructor(e,t=null,n=null,r=null){super(e),this.statusCode=t,this.body=n,this.requestId=r}};function Pt(){return Math.floor(Date.now()/1e3)}var Ft=class{constructor(e,t){this.cached=null,this.pendingRefresh=null,this.nextForce=!1,this.lastAdvisoryError=0,this.provider=e,this.onAdvisoryRefreshError=t}async getToken(){let e=this.nextForce;this.nextForce=!1;let t=this.cached;if(e||t==null)return(await this.refresh(e)).token;if(t.expiresAt==null)return t.token;let n=t.expiresAt-Pt();return n>120?t.token:n>30?(this.backgroundRefresh(),t.token):(await this.refresh()).token}invalidate(){this.cached=null,this.nextForce=!0}refresh(e=!1){return this.pendingRefresh&&!e?this.pendingRefresh:this.doRefresh(e)}backgroundRefresh(){this.pendingRefresh||Pt()-this.lastAdvisoryError<5||this.doRefresh().catch(e=>{this.lastAdvisoryError=Pt(),this.onAdvisoryRefreshError?.(e)})}doRefresh(e=!1){return this.pendingRefresh=this.provider(e?{forceRefresh:!0}:void 0).then(e=>(this.cached=e,this.pendingRefresh=null,e),e=>{throw this.pendingRefresh=null,e}),this.pendingRefresh}},A=e=>{if(globalThis.process!==void 0)return{}[e]?.trim()||void 0;if(globalThis.Deno!==void 0)return globalThis.Deno.env?.get?.(e)?.trim()||void 0};function It(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var Lt;function Rt(e){let t;return(Lt??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var zt;function Bt(e){let t;return(zt??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var Vt=e=>{if(globalThis.Buffer!==void 0){let t=globalThis.Buffer.from(e,`base64`);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}if(typeof atob<`u`){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}throw new y("Cannot decode base64 string; Expected `Buffer` or `atob` to be defined")},Ht=`warn`,Ut={off:0,error:200,warn:300,info:400,debug:500},Wt=(e,t,n)=>{if(e){if(Me(Ut,e))return e;n.warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Ut))}`)}};function Gt(){}function Kt(e,t,n){return!t||Ut[e]>Ut[n]?Gt:t[e].bind(t)}var qt={error:Gt,warn:Gt,info:Gt,debug:Gt},Jt=new WeakMap;function Yt(e,t){let n=Jt.get(e);if(n&&n[0]===t)return n[1];let r={error:Kt(`error`,e,t),warn:Kt(`warn`,e,t),info:Kt(`info`,e,t),debug:Kt(`debug`,e,t)};return Jt.set(e,[t,r]),r}function j(e){let t=e.logger,n=e.logLevel??`off`;return t?Yt(t,n):qt}var Xt,Zt;function Qt(){let e=A(`ANTHROPIC_LOG`);return(!Zt||e!==Xt)&&(Xt=e,Zt=Yt(console,Wt(e,`process.env['ANTHROPIC_LOG']`,Yt(console,`warn`))??`warn`)),Zt}function $t(e,t,n){e.debug!==Gt&&e.debug(t,en(n))}var en=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`authorization`||e.toLowerCase()===`api-key`||e.toLowerCase()===`x-api-key`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e),tn=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return tn=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(+e^n()&15>>e/4).toString(16))},nn=/^[A-Za-z0-9_.-]+$/;function rn(e){if(!e)throw Error(`profile name is empty`);if(e===`.`||e===`..`)throw Error(`profile name "${e}" is not allowed`);if(e.includes(`/`)||e.includes(`\\`))throw Error(`profile name "${e}" must not contain path separators`);if(!nn.test(e))throw Error(`profile name "${e}" contains disallowed characters (allowed: letters, digits, '_', '.', '-')`)}var an=async e=>{var t,n;let r=await sn();if(r===null)return null;let i=e??await ln();if(i===null)return null;rn(i);let{fs:a,path:o}=await u(async()=>{let{fs:e,path:t}=await import(`./node.browser-HQ5SKBOf.js`);return{fs:e,path:t}},__vite__mapDeps([0,1])),s=o.join(r,`configs`,`${i}.json`),c;try{c=await a.promises.readFile(s,`utf-8`)}catch(e){if(e?.code!==`ENOENT`)throw Error(`failed to read config file ${s}: ${e}`);c=null}if(c===null){let e=A(`ANTHROPIC_ORGANIZATION_ID`),t=A(`ANTHROPIC_IDENTITY_TOKEN_FILE`),n=A(`ANTHROPIC_FEDERATION_RULE_ID`);return n&&e?{fromFile:!1,config:{organization_id:e,workspace_id:A(`ANTHROPIC_WORKSPACE_ID`),base_url:A(`ANTHROPIC_BASE_URL`),authentication:{type:`oidc_federation`,federation_rule_id:n,service_account_id:A(`ANTHROPIC_SERVICE_ACCOUNT_ID`),identity_token:t?{source:`file`,path:t}:void 0,scope:A(`ANTHROPIC_SCOPE`)}}}:null}let l;try{l=JSON.parse(c)}catch(e){throw Error(`failed to parse config file ${s}: ${e}`)}if(!l.authentication)throw Error(`config file ${s} is missing "authentication"`);let d=l.authentication.type;if(d!==`oidc_federation`&&d!==`user_oauth`)throw Error(`authentication.type "${d}" is not a known authentication type`);if(l.organization_id??(l.organization_id=A(`ANTHROPIC_ORGANIZATION_ID`)),l.workspace_id??(l.workspace_id=A(`ANTHROPIC_WORKSPACE_ID`)),l.base_url??(l.base_url=A(`ANTHROPIC_BASE_URL`)),(t=l.authentication).scope??(t.scope=A(`ANTHROPIC_SCOPE`)),l.authentication.type===`oidc_federation`){if(!l.authentication.identity_token){let e=A(`ANTHROPIC_IDENTITY_TOKEN_FILE`);e&&(l.authentication.identity_token={source:`file`,path:e})}l.authentication.federation_rule_id||(l.authentication.federation_rule_id=A(`ANTHROPIC_FEDERATION_RULE_ID`)??``),(n=l.authentication).service_account_id??(n.service_account_id=A(`ANTHROPIC_SERVICE_ACCOUNT_ID`))}return{config:l,fromFile:!0}},on=async(e,t)=>{if(e?.authentication.credentials_path)return e.authentication.credentials_path;let n=await sn();if(!n)return null;let r=t??await ln();if(!r)return null;rn(r);let{path:i}=await u(async()=>{let{path:e}=await import(`./node.browser-HQ5SKBOf.js`);return{path:e}},__vite__mapDeps([0,1]));return i.join(n,`credentials`,`${r}.json`)},sn=async()=>{if(!cn())return null;let{path:e}=await u(async()=>{let{path:e}=await import(`./node.browser-HQ5SKBOf.js`);return{path:e}},__vite__mapDeps([0,1])),t=A(`ANTHROPIC_CONFIG_DIR`);if(t)return t;if(Ge()[`X-Stainless-OS`]===`Windows`){let t=A(`APPDATA`);if(t)return e.join(t,`Anthropic`);let n=A(`USERPROFILE`);return n?e.join(n,`AppData`,`Roaming`,`Anthropic`):null}let n=A(`XDG_CONFIG_HOME`);if(n)return e.join(n,`anthropic`);let r=A(`HOME`);return r?e.join(r,`.config`,`anthropic`):null},cn=()=>{let e=Ge()[`X-Stainless-Runtime`];return e===`node`||e===`deno`},ln=async()=>{let e=await sn();if(!e)return null;let t=A(`ANTHROPIC_PROFILE`);if(t)return t;let{fs:n,path:r}=await u(async()=>{let{fs:e,path:t}=await import(`./node.browser-HQ5SKBOf.js`);return{fs:e,path:t}},__vite__mapDeps([0,1])),i=r.join(e,`active_config`);try{return(await n.promises.readFile(i,`utf-8`)).trim()||`default`}catch(e){if(e?.code!==`ENOENT`)throw Error(`failed to read ${i}: ${e}`);return`default`}};function un(e){if(!e)throw new y(`Identity token file path is empty`);return async()=>{let{fs:t}=await u(async()=>{let{fs:e}=await import(`./node.browser-HQ5SKBOf.js`);return{fs:e}},__vite__mapDeps([0,1])),n;try{n=await t.promises.readFile(e,`utf-8`)}catch(t){throw new y(`Failed to read identity token file at ${e}: ${t}`)}let r=n.trim();if(!r)throw new y(`Identity token file at ${e} is empty`);return r}}function dn(e){if(!e)throw new y(`Identity token value is empty`);return()=>e}function fn(e){return async()=>{Dt(e.baseURL);let t=await e.identityTokenProvider();if(t.length>16384)throw new k(`Identity token is ${Math.ceil(t.length/1024)} KiB, exceeds the 16 KiB assertion limit`);let n={grant_type:xt,assertion:t,federation_rule_id:e.federationRuleId,organization_id:e.organizationId};e.serviceAccountId&&(n.service_account_id=e.serviceAccountId),e.workspaceId&&(n.workspace_id=e.workspaceId);let r=`${e.baseURL}${Ct}`,i;try{i=await e.fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,"anthropic-beta":`${wt},${Tt}`,"User-Agent":e.userAgent||`anthropic-sdk-typescript/0.129.0 oidcFederationProvider`},body:JSON.stringify(n)})}catch(e){throw new k(`Failed to reach token endpoint ${r}: ${e}`)}let a=i.headers.get(`Request-Id`);if(!i.ok){let t=O(await i.text().catch(()=>``)),n=``;throw i.status===401&&(n=` Ensure your federation rule matches your identity token. ${e.workspaceId?``:"If your federation rule is scoped to multiple workspaces, set the ANTHROPIC_WORKSPACE_ID environment variable, the 'workspace_id' config key, or the `workspaceId` option. "}View your authentication events in the Workload identity page of Claude Console for more details.`),new k(`Token exchange failed with status ${i.status}${a?` (request-id ${a})`:``}: ${t}${n}`,i.status,t,a)}let o=await Ot(i,a),s=Number(o.expires_in);if(!Number.isFinite(s))throw new k(`Token endpoint response missing required fields: ${JSON.stringify(O(o))}`,i.status,O(o),a);return{token:o.access_token,expiresAt:Pt()+s}}}function pn(e){return async t=>{let{fs:n}=await u(async()=>{let{fs:e}=await import(`./node.browser-HQ5SKBOf.js`);return{fs:e}},__vite__mapDeps([0,1]));await jt(e.credentialsPath,e.onSafetyWarning);let r;try{r=await n.promises.readFile(e.credentialsPath,`utf-8`)}catch(t){throw new k(`Credentials file not found at ${e.credentialsPath}: ${t}`)}let i;try{i=JSON.parse(r)}catch(t){throw new k(`Credentials file at ${e.credentialsPath} is not valid JSON: ${t}`)}let a=i.access_token;if(!a)throw new k(`Credentials file at ${e.credentialsPath} must include 'access_token'`);let o=i.expires_at;if(!t?.forceRefresh&&(o==null||Pt()<o-30))return{token:a,expiresAt:o??null};let s=i.refresh_token;if(!e.clientId||!s)throw new k(`Access token at ${e.credentialsPath} has expired and no refresh is available (client_id ${e.clientId?`set`:`empty`}, refresh_token ${s?`set`:`empty`})`);Dt(e.baseURL);let c={grant_type:St,refresh_token:s,client_id:e.clientId},l=`${e.baseURL}${Ct}`,d;try{d=await e.fetch(l,{method:`POST`,headers:{"Content-Type":`application/json`,"anthropic-beta":wt,"User-Agent":e.userAgent||`anthropic-sdk-typescript/0.129.0 userOAuthProvider`},body:JSON.stringify(c)})}catch(e){throw new k(`User OAuth refresh failed to reach token endpoint: ${e}`)}let f=d.headers.get(`Request-Id`);if(!d.ok){let e=await d.text().catch(()=>``);throw new k(`User OAuth refresh failed (HTTP ${d.status}): ${O(e)}`,d.status,O(e),f)}let p=await Ot(d,f),m=Number(p.expires_in);if(!Number.isFinite(m))throw new k(`User OAuth refresh response missing or invalid expires_in: ${JSON.stringify(O(p))}`,d.status,O(p),f);let h=Pt()+m,g=p.refresh_token||s;return await Mt(e.credentialsPath,{...i,version:`1.0`,type:`oauth_token`,access_token:p.access_token,expires_at:h,refresh_token:g}),{token:p.access_token,expiresAt:h}}}function mn(e,t){let n=gn(e,e.authentication.credentials_path??null,(e.base_url||t.baseURL).replace(/\/+$/,``),t),r={};return e.workspace_id&&e.authentication.type===`user_oauth`&&(r[`anthropic-workspace-id`]=e.workspace_id),{provider:n,extraHeaders:r,baseURL:e.base_url||void 0}}async function hn(e,t){let n=await an(t);if(!n)return null;let{config:r,fromFile:i}=n;return mn(r.authentication.credentials_path||!i?r:{...r,authentication:{...r.authentication,credentials_path:await on(r,t)??void 0}},e)}function gn(e,t,n,r){switch(e.authentication.type){case`oidc_federation`:{let i=e.authentication,a=_n(i);if(!a)throw new k(`oidc_federation config requires an identity token (set authentication.identity_token, ANTHROPIC_IDENTITY_TOKEN_FILE, or ANTHROPIC_IDENTITY_TOKEN)`);if(!i.federation_rule_id)throw new k(`oidc_federation config requires 'federation_rule_id'. Set it in authentication.federation_rule_id in your profile, or via ANTHROPIC_FEDERATION_RULE_ID (profile takes precedence).`);if(!e.organization_id)throw new k(`oidc_federation config requires organization_id (set ANTHROPIC_ORGANIZATION_ID or config.organization_id)`);let o=fn({identityTokenProvider:a,federationRuleId:i.federation_rule_id,organizationId:e.organization_id,serviceAccountId:i.service_account_id,workspaceId:e.workspace_id,baseURL:n,fetch:r.fetch,userAgent:r.userAgent});return t?vn(o,t,r.onCacheWriteError,r.onSafetyWarning):o}case`user_oauth`:if(!t)throw new k(`user_oauth config requires authentication.credentials_path (or load via a profile so it defaults to <config_dir>/credentials/<profile>.json)`);return pn({credentialsPath:t,clientId:e.authentication.client_id,baseURL:n,fetch:r.fetch,userAgent:r.userAgent,onSafetyWarning:r.onSafetyWarning});default:{let t=e.authentication.type;throw new k(`authentication.type "${t}" is not a known authentication type`)}}}function _n(e){if(e.identity_token){let t=e.identity_token.source;if(t!==`file`)throw new k(`identity_token.source "${t}" is not supported by this SDK version (only "file")`);if(!e.identity_token.path)throw new k(`identity_token.source "file" requires a non-empty path`);return un(e.identity_token.path)}let t=A(`ANTHROPIC_IDENTITY_TOKEN_FILE`);if(t)return un(t);let n=A(`ANTHROPIC_IDENTITY_TOKEN`);return n?dn(n):null}function vn(e,t,n,r){return async i=>{let{fs:a}=await u(async()=>{let{fs:e}=await import(`./node.browser-HQ5SKBOf.js`);return{fs:e}},__vite__mapDeps([0,1]));await jt(t,r);let o;try{let e=await a.promises.readFile(t,`utf-8`);o=JSON.parse(e);let n=o?.access_token;if(n&&!i?.forceRefresh){let e=o?.expires_at;if(e==null||Pt()<e-30)return{token:n,expiresAt:e??null}}}catch(e){e?.code!==`ENOENT`&&!(e instanceof SyntaxError)&&n?.(e)}let s=await e(i);try{await Mt(t,{...o??{},version:`1.0`,type:`oauth_token`,access_token:s.token,expires_at:s.expiresAt})}catch(e){n?.(e)}return s}}var M,N,yn=(()=>{class e{constructor(){M.set(this,void 0),N.set(this,void 0),C(this,M,new Uint8Array,`f`),C(this,N,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Rt(e):e;C(this,M,It([w(this,M,`f`),t]),`f`);let n=[],r;for(;(r=bn(w(this,M,`f`),w(this,N,`f`)))!=null;){if(r.carriage&&w(this,N,`f`)==null){C(this,N,r.index,`f`);continue}if(w(this,N,`f`)!=null&&(r.index!==w(this,N,`f`)+1||r.carriage)){n.push(Bt(w(this,M,`f`).subarray(0,w(this,N,`f`)-1))),C(this,M,w(this,M,`f`).subarray(w(this,N,`f`)),`f`),C(this,N,null,`f`);continue}let e=w(this,N,`f`)===null?r.preceding:r.preceding-1,t=Bt(w(this,M,`f`).subarray(0,e));n.push(t),C(this,M,w(this,M,`f`).subarray(r.index),`f`),C(this,N,null,`f`)}return n}flush(){return w(this,M,`f`).length?this.decode(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/node.browser-HQ5SKBOf.js","assets/error-BTdmRKoB.js","assets/node.browser-POTNsJTJ.js"])))=>i.map(i=>d[i]);
2
+ import{n as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{i as n,t as r}from"./diagnostics-B-5VkVir.js";import{c as i,f as a,g as o,h as s,t as c,u as l}from"./models-DuCVW_cU.js";import{t as u}from"./preload-helper-BLdHbfdN.js";import{n as d,t as f}from"./json-parse-CgFfIg4Q.js";import{t as p}from"./provider-env-CTOcDKrQ.js";import{c as m,i as h,o as g,r as _,s as v}from"./env-api-keys-Cfrk_k8Z.js";import{a as y,c as ee,d as te,f as ne,g as b,h as re,i as x,l as ie,m as ae,n as oe,o as se,p as ce,r as le,s as ue,t as de,u as fe}from"./error-BTdmRKoB.js";import{t as pe}from"./headers-FK4rgixo.js";import{i as me,o as he,s as ge}from"./constrained-sampling-DA0j0g9I.js";import{t as _e}from"./provider-retry-RVfYd5Vz.js";import{t as S}from"./sanitize-unicode-DmIE6hZJ.js";import{n as ve,t as ye}from"./github-copilot-headers-DRgtIyTm.js";import{i as be,n as xe,r as Se,t as Ce}from"./transform-messages-HTSSP3zz.js";var we=15e3,Te=5e3;function Ee(e,t){if(!(e>=5e3))throw new y(`${t} must be at least ${Te}ms (got ${e}); to run without memory sync, pass \`memorySyncIntervalMs: null\` to the worker instead`)}function C(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function w(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var De=/^[a-z][a-z0-9+.-]*:/i,Oe=e=>De.test(e),T=e=>(T=Array.isArray,T(e)),ke=T;function Ae(e){return typeof e==`object`?e??{}:{}}function je(e){if(!e)return!0;for(let t in e)return!1;return!0}function Me(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Pe=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new y(`${e} must be an integer`);if(t<0)throw new y(`${e} must be a positive integer`);return t},Fe=e=>{try{return JSON.parse(e)}catch{return}},Ie=(e,t)=>new Promise(n=>{if(t?.aborted)return n();let r=()=>{clearTimeout(i),n()},i=setTimeout(()=>{t?.removeEventListener(`abort`,r),n()},e);t?.addEventListener(`abort`,r,{once:!0})}),Le=`0.129.0`,Re=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`;function ze(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}var Be=()=>{let e=ze();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":Le,"X-Stainless-OS":Ue(Deno.build.os),"X-Stainless-Arch":He(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":Le,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process?.version??`unknown`};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":Le,"X-Stainless-OS":Ue(globalThis.process.platform??`unknown`),"X-Stainless-Arch":He(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=Ve();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":Le,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":Le,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}};function Ve(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}var He=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,Ue=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`),We,Ge=()=>We??=Be(),Ke=new WeakMap,qe=typeof globalThis.FinalizationRegistry==`function`?new globalThis.FinalizationRegistry(e=>Ze(e)):null;function Je(e,t){return()=>e.removeEventListener(`abort`,t)}function Ye(e,t,n){Ke.set(e,Je(t,n))}function Xe(e,t){Ke.has(t)&&qe?.register(e,t,t)}function Ze(e){let t=Ke.get(e);t&&(Ke.delete(e),qe?.unregister(e),t())}function Qe(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function $e(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function et(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return $e({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function tt(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function nt(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var rt=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)}),it=`RFC3986`,at=e=>String(e),ot={RFC1738:e=>String(e).replace(/%20/g,`+`),RFC3986:at},st=(e,t)=>(st=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),st(e,t)),E=(()=>{let e=[];for(let t=0;t<256;++t)e.push(`%`+((t<16?`0`:``)+t.toString(16)).toUpperCase());return e})(),ct=1024,lt=(e,t,n,r,i)=>{if(e.length===0)return e;let a=e;if(typeof e==`symbol`?a=Symbol.prototype.toString.call(e):typeof e!=`string`&&(a=String(e)),n===`iso-8859-1`)return escape(a).replace(/%u[0-9a-f]{4}/gi,function(e){return`%26%23`+parseInt(e.slice(2),16)+`%3B`});let o=``;for(let e=0;e<a.length;e+=ct){let t=a.length>=ct?a.slice(e,e+ct):a,n=[];for(let e=0;e<t.length;++e){let r=t.charCodeAt(e);if(r===45||r===46||r===95||r===126||r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||i===`RFC1738`&&(r===40||r===41)){n[n.length]=t.charAt(e);continue}if(r<128){n[n.length]=E[r];continue}if(r<2048){n[n.length]=E[192|r>>6]+E[128|r&63];continue}if(r<55296||r>=57344){n[n.length]=E[224|r>>12]+E[128|r>>6&63]+E[128|r&63];continue}e+=1,r=65536+((r&1023)<<10|t.charCodeAt(e)&1023),n[n.length]=E[240|r>>18]+E[128|r>>12&63]+E[128|r>>6&63]+E[128|r&63]}o+=n.join(``)}return o};function ut(e){return!e||typeof e!=`object`?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function dt(e,t){if(T(e)){let n=[];for(let r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)}var ft={brackets(e){return String(e)+`[]`},comma:`comma`,indices(e,t){return String(e)+`[`+t+`]`},repeat(e){return String(e)}},pt=function(e,t){Array.prototype.push.apply(e,T(t)?t:[t])},mt,D={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:`indices`,charset:`utf-8`,charsetSentinel:!1,delimiter:`&`,encode:!0,encodeDotInKeys:!1,encoder:lt,encodeValuesOnly:!1,format:it,formatter:at,indices:!1,serializeDate(e){return(mt??=Function.prototype.call.bind(Date.prototype.toISOString))(e)},skipNulls:!1,strictNullHandling:!1};function ht(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`symbol`||typeof e==`bigint`}var gt={};function _t(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_){let v=e,y=_,ee=0,te=!1;for(;(y=y.get(gt))!==void 0&&!te;){let t=y.get(e);if(ee+=1,t!==void 0){if(t===ee)throw RangeError(`Cyclic object value`);te=!0}y.get(gt)===void 0&&(ee=0)}if(typeof l==`function`?v=l(t,v):v instanceof Date?v=f?.(v):n===`comma`&&T(v)&&(v=dt(v,function(e){return e instanceof Date?f?.(e):e})),v===null){if(a)return c&&!h?c(t,D.encoder,g,`key`,p):t;v=``}if(ht(v)||ut(v)){if(c){let e=h?t:c(t,D.encoder,g,`key`,p);return[m?.(e)+`=`+m?.(c(v,D.encoder,g,`value`,p))]}return[m?.(t)+`=`+m?.(String(v))]}let ne=[];if(v===void 0)return ne;let b;if(n===`comma`&&T(v))h&&c&&(v=dt(v,c)),b=[{value:v.length>0?v.join(`,`)||null:void 0}];else if(T(l))b=l;else{let e=Object.keys(v);b=u?e.sort(u):e}let re=s?String(t).replace(/\./g,`%2E`):String(t),x=r&&T(v)&&v.length===1?re+`[]`:re;if(i&&T(v)&&v.length===0)return x+`[]`;for(let t=0;t<b.length;++t){let y=b[t],te=typeof y==`object`&&y.value!==void 0?y.value:v[y];if(o&&te===null)continue;let re=d&&s?y.replace(/\./g,`%2E`):y,ie=T(v)?typeof n==`function`?n(x,re):x:x+(d?`.`+re:`[`+re+`]`);_.set(e,ee);let ae=new WeakMap;ae.set(gt,_),pt(ne,_t(te,ie,n,r,i,a,o,s,n===`comma`&&h&&T(v)?null:c,l,u,d,f,p,m,h,g,ae))}return ne}function vt(e=D){if(e.allowEmptyArrays!==void 0&&typeof e.allowEmptyArrays!=`boolean`)throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(e.encodeDotInKeys!==void 0&&typeof e.encodeDotInKeys!=`boolean`)throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&e.encoder!==void 0&&typeof e.encoder!=`function`)throw TypeError(`Encoder has to be a function.`);let t=e.charset||D.charset;if(e.charset!==void 0&&e.charset!==`utf-8`&&e.charset!==`iso-8859-1`)throw TypeError(`The charset option must be either utf-8, iso-8859-1, or undefined`);let n=it;if(e.format!==void 0){if(!st(ot,e.format))throw TypeError(`Unknown format option provided.`);n=e.format}let r=ot[n],i=D.filter;(typeof e.filter==`function`||T(e.filter))&&(i=e.filter);let a;if(a=e.arrayFormat&&e.arrayFormat in ft?e.arrayFormat:`indices`in e?e.indices?`indices`:`repeat`:D.arrayFormat,`commaRoundTrip`in e&&typeof e.commaRoundTrip!=`boolean`)throw TypeError("`commaRoundTrip` must be a boolean, or absent");let o=e.allowDots===void 0?e.encodeDotInKeys?!0:D.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix==`boolean`?e.addQueryPrefix:D.addQueryPrefix,allowDots:o,allowEmptyArrays:typeof e.allowEmptyArrays==`boolean`?!!e.allowEmptyArrays:D.allowEmptyArrays,arrayFormat:a,charset:t,charsetSentinel:typeof e.charsetSentinel==`boolean`?e.charsetSentinel:D.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:e.delimiter===void 0?D.delimiter:e.delimiter,encode:typeof e.encode==`boolean`?e.encode:D.encode,encodeDotInKeys:typeof e.encodeDotInKeys==`boolean`?e.encodeDotInKeys:D.encodeDotInKeys,encoder:typeof e.encoder==`function`?e.encoder:D.encoder,encodeValuesOnly:typeof e.encodeValuesOnly==`boolean`?e.encodeValuesOnly:D.encodeValuesOnly,filter:i,format:n,formatter:r,serializeDate:typeof e.serializeDate==`function`?e.serializeDate:D.serializeDate,skipNulls:typeof e.skipNulls==`boolean`?e.skipNulls:D.skipNulls,sort:typeof e.sort==`function`?e.sort:null,strictNullHandling:typeof e.strictNullHandling==`boolean`?e.strictNullHandling:D.strictNullHandling}}function yt(e,t={}){let n=e,r=vt(t),i,a;typeof r.filter==`function`?(a=r.filter,n=a(``,n)):T(r.filter)&&(a=r.filter,i=a);let o=[];if(typeof n!=`object`||!n)return``;let s=ft[r.arrayFormat],c=s===`comma`&&r.commaRoundTrip;i||=Object.keys(n),r.sort&&i.sort(r.sort);let l=new WeakMap;for(let e=0;e<i.length;++e){let t=i[e];r.skipNulls&&n[t]===null||pt(o,_t(n[t],t,s,c,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,l))}let u=o.join(r.delimiter),d=r.addQueryPrefix===!0?`?`:``;return r.charsetSentinel&&(r.charset===`iso-8859-1`?d+=`utf8=%26%2310003%3B&`:d+=`utf8=%E2%9C%93&`),u.length>0?d+u:``}function bt(e){return yt(e,{arrayFormat:`brackets`})}var xt=`urn:ietf:params:oauth:grant-type:jwt-bearer`,St=`refresh_token`,Ct=`/v1/oauth/token`,wt=`oauth-2025-04-20`,Tt=`oidc-federation-2026-04-01`,Et=1<<20;function Dt(e){if(!e)return;let t;try{t=new URL(e)}catch(t){throw new k(`Invalid token endpoint base URL "${e}": ${t}`)}if(t.protocol===`https:`)return;let n=t.hostname.toLowerCase().replace(/^\[|\]$/g,``);if(t.protocol!==`http:`||n!==`localhost`&&n!==`127.0.0.1`&&n!==`::1`)throw new k(`Refusing to send credential over non-https token endpoint "${e}"`)}async function Ot(e,t){let n=await Nt(e),r;try{r=JSON.parse(n)}catch{throw new k(`Token endpoint returned non-JSON response (status ${e.status})`,e.status,O(n),t)}if(!r.access_token)throw new k(`Token endpoint response missing access_token: ${JSON.stringify(O(r))}`,e.status,O(r),t);if(r.token_type&&r.token_type.toLowerCase()!==`bearer`)throw new k(`Token endpoint response: unsupported token_type "${r.token_type}" (want Bearer)`,e.status,O(r),t);return r}var kt=2e3,At=new Set([`error`,`error_description`,`error_uri`]);function O(e){if(e==null)return e;if(typeof e==`string`){let t;try{t=JSON.parse(e)}catch{return e.length<=kt?e:e.slice(0,kt)+`... <${e.length-kt} more chars>`}return JSON.stringify(O(t))}if(typeof e==`object`&&!Array.isArray(e)){let t={};for(let[n,r]of Object.entries(e))At.has(n)&&(t[n]=r);return t}return null}async function jt(e,t=e=>console.warn(`anthropic-sdk: ${e}`)){if(typeof process>`u`||process.platform===`win32`)return;let{fs:n}=await u(async()=>{let{fs:e}=await import(`./node.browser-HQ5SKBOf.js`);return{fs:e}},__vite__mapDeps([0,1])),r=e,i;try{r=await n.promises.realpath(e),i=await n.promises.stat(r)}catch{return}let a=i.mode&511;if(a&18)throw new k(`Credentials file at ${r} is group/world-writable (mode 0o${a.toString(8)}); this allows other local users to plant tokens. Run \`chmod 600 ${r}\`.`);if(a&36)throw new k(`Credentials file at ${r} is group/world-readable (mode 0o${a.toString(8)}); run \`chmod 600 ${r}\` before retrying.`);typeof process.getuid==`function`&&i.uid!==process.getuid()&&t(`credentials file at ${r} is owned by uid ${i.uid} (current process uid ${process.getuid()}); verify this is intentional.`)}async function Mt(e,t){let{fs:n,path:r}=await u(async()=>{let{fs:e,path:t}=await import(`./node.browser-HQ5SKBOf.js`);return{fs:e,path:t}},__vite__mapDeps([0,1])),i=r.dirname(e);await n.promises.mkdir(i,{recursive:!0,mode:448});let a=`${e}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;try{let r=await n.promises.open(a,`w`,384);try{await r.writeFile(JSON.stringify(t,null,2)),await r.sync()}finally{await r.close()}await n.promises.rename(a,e)}catch(e){throw await n.promises.unlink(a).catch(()=>{}),e}try{let e=await n.promises.open(i,`r`);try{await e.sync()}finally{await e.close()}}catch{}}async function Nt(e){if(!e.body)return``;let t=e.body.getReader(),n=[],r=0;for(;;){let{done:e,value:i}=await t.read();if(e)break;if(r+i.length>Et){let e=Et-r;e>0&&n.push(i.subarray(0,e)),await t.cancel();break}n.push(i),r+=i.length}let i;if(n.length===1)i=n[0];else{i=new Uint8Array(n.reduce((e,t)=>e+t.length,0));let e=0;for(let t of n)i.set(t,e),e+=t.length}return new TextDecoder(`utf-8`).decode(i)}var k=class extends y{constructor(e,t=null,n=null,r=null){super(e),this.statusCode=t,this.body=n,this.requestId=r}};function Pt(){return Math.floor(Date.now()/1e3)}var Ft=class{constructor(e,t){this.cached=null,this.pendingRefresh=null,this.nextForce=!1,this.lastAdvisoryError=0,this.provider=e,this.onAdvisoryRefreshError=t}async getToken(){let e=this.nextForce;this.nextForce=!1;let t=this.cached;if(e||t==null)return(await this.refresh(e)).token;if(t.expiresAt==null)return t.token;let n=t.expiresAt-Pt();return n>120?t.token:n>30?(this.backgroundRefresh(),t.token):(await this.refresh()).token}invalidate(){this.cached=null,this.nextForce=!0}refresh(e=!1){return this.pendingRefresh&&!e?this.pendingRefresh:this.doRefresh(e)}backgroundRefresh(){this.pendingRefresh||Pt()-this.lastAdvisoryError<5||this.doRefresh().catch(e=>{this.lastAdvisoryError=Pt(),this.onAdvisoryRefreshError?.(e)})}doRefresh(e=!1){return this.pendingRefresh=this.provider(e?{forceRefresh:!0}:void 0).then(e=>(this.cached=e,this.pendingRefresh=null,e),e=>{throw this.pendingRefresh=null,e}),this.pendingRefresh}},A=e=>{if(globalThis.process!==void 0)return{}[e]?.trim()||void 0;if(globalThis.Deno!==void 0)return globalThis.Deno.env?.get?.(e)?.trim()||void 0};function It(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var Lt;function Rt(e){let t;return(Lt??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var zt;function Bt(e){let t;return(zt??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var Vt=e=>{if(globalThis.Buffer!==void 0){let t=globalThis.Buffer.from(e,`base64`);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}if(typeof atob<`u`){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}throw new y("Cannot decode base64 string; Expected `Buffer` or `atob` to be defined")},Ht=`warn`,Ut={off:0,error:200,warn:300,info:400,debug:500},Wt=(e,t,n)=>{if(e){if(Me(Ut,e))return e;n.warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Ut))}`)}};function Gt(){}function Kt(e,t,n){return!t||Ut[e]>Ut[n]?Gt:t[e].bind(t)}var qt={error:Gt,warn:Gt,info:Gt,debug:Gt},Jt=new WeakMap;function Yt(e,t){let n=Jt.get(e);if(n&&n[0]===t)return n[1];let r={error:Kt(`error`,e,t),warn:Kt(`warn`,e,t),info:Kt(`info`,e,t),debug:Kt(`debug`,e,t)};return Jt.set(e,[t,r]),r}function j(e){let t=e.logger,n=e.logLevel??`off`;return t?Yt(t,n):qt}var Xt,Zt;function Qt(){let e=A(`ANTHROPIC_LOG`);return(!Zt||e!==Xt)&&(Xt=e,Zt=Yt(console,Wt(e,`process.env['ANTHROPIC_LOG']`,Yt(console,`warn`))??`warn`)),Zt}function $t(e,t,n){e.debug!==Gt&&e.debug(t,en(n))}var en=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`authorization`||e.toLowerCase()===`api-key`||e.toLowerCase()===`x-api-key`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e),tn=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return tn=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(+e^n()&15>>e/4).toString(16))},nn=/^[A-Za-z0-9_.-]+$/;function rn(e){if(!e)throw Error(`profile name is empty`);if(e===`.`||e===`..`)throw Error(`profile name "${e}" is not allowed`);if(e.includes(`/`)||e.includes(`\\`))throw Error(`profile name "${e}" must not contain path separators`);if(!nn.test(e))throw Error(`profile name "${e}" contains disallowed characters (allowed: letters, digits, '_', '.', '-')`)}var an=async e=>{var t,n;let r=await sn();if(r===null)return null;let i=e??await ln();if(i===null)return null;rn(i);let{fs:a,path:o}=await u(async()=>{let{fs:e,path:t}=await import(`./node.browser-HQ5SKBOf.js`);return{fs:e,path:t}},__vite__mapDeps([0,1])),s=o.join(r,`configs`,`${i}.json`),c;try{c=await a.promises.readFile(s,`utf-8`)}catch(e){if(e?.code!==`ENOENT`)throw Error(`failed to read config file ${s}: ${e}`);c=null}if(c===null){let e=A(`ANTHROPIC_ORGANIZATION_ID`),t=A(`ANTHROPIC_IDENTITY_TOKEN_FILE`),n=A(`ANTHROPIC_FEDERATION_RULE_ID`);return n&&e?{fromFile:!1,config:{organization_id:e,workspace_id:A(`ANTHROPIC_WORKSPACE_ID`),base_url:A(`ANTHROPIC_BASE_URL`),authentication:{type:`oidc_federation`,federation_rule_id:n,service_account_id:A(`ANTHROPIC_SERVICE_ACCOUNT_ID`),identity_token:t?{source:`file`,path:t}:void 0,scope:A(`ANTHROPIC_SCOPE`)}}}:null}let l;try{l=JSON.parse(c)}catch(e){throw Error(`failed to parse config file ${s}: ${e}`)}if(!l.authentication)throw Error(`config file ${s} is missing "authentication"`);let d=l.authentication.type;if(d!==`oidc_federation`&&d!==`user_oauth`)throw Error(`authentication.type "${d}" is not a known authentication type`);if(l.organization_id??(l.organization_id=A(`ANTHROPIC_ORGANIZATION_ID`)),l.workspace_id??(l.workspace_id=A(`ANTHROPIC_WORKSPACE_ID`)),l.base_url??(l.base_url=A(`ANTHROPIC_BASE_URL`)),(t=l.authentication).scope??(t.scope=A(`ANTHROPIC_SCOPE`)),l.authentication.type===`oidc_federation`){if(!l.authentication.identity_token){let e=A(`ANTHROPIC_IDENTITY_TOKEN_FILE`);e&&(l.authentication.identity_token={source:`file`,path:e})}l.authentication.federation_rule_id||(l.authentication.federation_rule_id=A(`ANTHROPIC_FEDERATION_RULE_ID`)??``),(n=l.authentication).service_account_id??(n.service_account_id=A(`ANTHROPIC_SERVICE_ACCOUNT_ID`))}return{config:l,fromFile:!0}},on=async(e,t)=>{if(e?.authentication.credentials_path)return e.authentication.credentials_path;let n=await sn();if(!n)return null;let r=t??await ln();if(!r)return null;rn(r);let{path:i}=await u(async()=>{let{path:e}=await import(`./node.browser-HQ5SKBOf.js`);return{path:e}},__vite__mapDeps([0,1]));return i.join(n,`credentials`,`${r}.json`)},sn=async()=>{if(!cn())return null;let{path:e}=await u(async()=>{let{path:e}=await import(`./node.browser-HQ5SKBOf.js`);return{path:e}},__vite__mapDeps([0,1])),t=A(`ANTHROPIC_CONFIG_DIR`);if(t)return t;if(Ge()[`X-Stainless-OS`]===`Windows`){let t=A(`APPDATA`);if(t)return e.join(t,`Anthropic`);let n=A(`USERPROFILE`);return n?e.join(n,`AppData`,`Roaming`,`Anthropic`):null}let n=A(`XDG_CONFIG_HOME`);if(n)return e.join(n,`anthropic`);let r=A(`HOME`);return r?e.join(r,`.config`,`anthropic`):null},cn=()=>{let e=Ge()[`X-Stainless-Runtime`];return e===`node`||e===`deno`},ln=async()=>{let e=await sn();if(!e)return null;let t=A(`ANTHROPIC_PROFILE`);if(t)return t;let{fs:n,path:r}=await u(async()=>{let{fs:e,path:t}=await import(`./node.browser-HQ5SKBOf.js`);return{fs:e,path:t}},__vite__mapDeps([0,1])),i=r.join(e,`active_config`);try{return(await n.promises.readFile(i,`utf-8`)).trim()||`default`}catch(e){if(e?.code!==`ENOENT`)throw Error(`failed to read ${i}: ${e}`);return`default`}};function un(e){if(!e)throw new y(`Identity token file path is empty`);return async()=>{let{fs:t}=await u(async()=>{let{fs:e}=await import(`./node.browser-HQ5SKBOf.js`);return{fs:e}},__vite__mapDeps([0,1])),n;try{n=await t.promises.readFile(e,`utf-8`)}catch(t){throw new y(`Failed to read identity token file at ${e}: ${t}`)}let r=n.trim();if(!r)throw new y(`Identity token file at ${e} is empty`);return r}}function dn(e){if(!e)throw new y(`Identity token value is empty`);return()=>e}function fn(e){return async()=>{Dt(e.baseURL);let t=await e.identityTokenProvider();if(t.length>16384)throw new k(`Identity token is ${Math.ceil(t.length/1024)} KiB, exceeds the 16 KiB assertion limit`);let n={grant_type:xt,assertion:t,federation_rule_id:e.federationRuleId,organization_id:e.organizationId};e.serviceAccountId&&(n.service_account_id=e.serviceAccountId),e.workspaceId&&(n.workspace_id=e.workspaceId);let r=`${e.baseURL}${Ct}`,i;try{i=await e.fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,"anthropic-beta":`${wt},${Tt}`,"User-Agent":e.userAgent||`anthropic-sdk-typescript/0.129.0 oidcFederationProvider`},body:JSON.stringify(n)})}catch(e){throw new k(`Failed to reach token endpoint ${r}: ${e}`)}let a=i.headers.get(`Request-Id`);if(!i.ok){let t=O(await i.text().catch(()=>``)),n=``;throw i.status===401&&(n=` Ensure your federation rule matches your identity token. ${e.workspaceId?``:"If your federation rule is scoped to multiple workspaces, set the ANTHROPIC_WORKSPACE_ID environment variable, the 'workspace_id' config key, or the `workspaceId` option. "}View your authentication events in the Workload identity page of Claude Console for more details.`),new k(`Token exchange failed with status ${i.status}${a?` (request-id ${a})`:``}: ${t}${n}`,i.status,t,a)}let o=await Ot(i,a),s=Number(o.expires_in);if(!Number.isFinite(s))throw new k(`Token endpoint response missing required fields: ${JSON.stringify(O(o))}`,i.status,O(o),a);return{token:o.access_token,expiresAt:Pt()+s}}}function pn(e){return async t=>{let{fs:n}=await u(async()=>{let{fs:e}=await import(`./node.browser-HQ5SKBOf.js`);return{fs:e}},__vite__mapDeps([0,1]));await jt(e.credentialsPath,e.onSafetyWarning);let r;try{r=await n.promises.readFile(e.credentialsPath,`utf-8`)}catch(t){throw new k(`Credentials file not found at ${e.credentialsPath}: ${t}`)}let i;try{i=JSON.parse(r)}catch(t){throw new k(`Credentials file at ${e.credentialsPath} is not valid JSON: ${t}`)}let a=i.access_token;if(!a)throw new k(`Credentials file at ${e.credentialsPath} must include 'access_token'`);let o=i.expires_at;if(!t?.forceRefresh&&(o==null||Pt()<o-30))return{token:a,expiresAt:o??null};let s=i.refresh_token;if(!e.clientId||!s)throw new k(`Access token at ${e.credentialsPath} has expired and no refresh is available (client_id ${e.clientId?`set`:`empty`}, refresh_token ${s?`set`:`empty`})`);Dt(e.baseURL);let c={grant_type:St,refresh_token:s,client_id:e.clientId},l=`${e.baseURL}${Ct}`,d;try{d=await e.fetch(l,{method:`POST`,headers:{"Content-Type":`application/json`,"anthropic-beta":wt,"User-Agent":e.userAgent||`anthropic-sdk-typescript/0.129.0 userOAuthProvider`},body:JSON.stringify(c)})}catch(e){throw new k(`User OAuth refresh failed to reach token endpoint: ${e}`)}let f=d.headers.get(`Request-Id`);if(!d.ok){let e=await d.text().catch(()=>``);throw new k(`User OAuth refresh failed (HTTP ${d.status}): ${O(e)}`,d.status,O(e),f)}let p=await Ot(d,f),m=Number(p.expires_in);if(!Number.isFinite(m))throw new k(`User OAuth refresh response missing or invalid expires_in: ${JSON.stringify(O(p))}`,d.status,O(p),f);let h=Pt()+m,g=p.refresh_token||s;return await Mt(e.credentialsPath,{...i,version:`1.0`,type:`oauth_token`,access_token:p.access_token,expires_at:h,refresh_token:g}),{token:p.access_token,expiresAt:h}}}function mn(e,t){let n=gn(e,e.authentication.credentials_path??null,(e.base_url||t.baseURL).replace(/\/+$/,``),t),r={};return e.workspace_id&&e.authentication.type===`user_oauth`&&(r[`anthropic-workspace-id`]=e.workspace_id),{provider:n,extraHeaders:r,baseURL:e.base_url||void 0}}async function hn(e,t){let n=await an(t);if(!n)return null;let{config:r,fromFile:i}=n;return mn(r.authentication.credentials_path||!i?r:{...r,authentication:{...r.authentication,credentials_path:await on(r,t)??void 0}},e)}function gn(e,t,n,r){switch(e.authentication.type){case`oidc_federation`:{let i=e.authentication,a=_n(i);if(!a)throw new k(`oidc_federation config requires an identity token (set authentication.identity_token, ANTHROPIC_IDENTITY_TOKEN_FILE, or ANTHROPIC_IDENTITY_TOKEN)`);if(!i.federation_rule_id)throw new k(`oidc_federation config requires 'federation_rule_id'. Set it in authentication.federation_rule_id in your profile, or via ANTHROPIC_FEDERATION_RULE_ID (profile takes precedence).`);if(!e.organization_id)throw new k(`oidc_federation config requires organization_id (set ANTHROPIC_ORGANIZATION_ID or config.organization_id)`);let o=fn({identityTokenProvider:a,federationRuleId:i.federation_rule_id,organizationId:e.organization_id,serviceAccountId:i.service_account_id,workspaceId:e.workspace_id,baseURL:n,fetch:r.fetch,userAgent:r.userAgent});return t?vn(o,t,r.onCacheWriteError,r.onSafetyWarning):o}case`user_oauth`:if(!t)throw new k(`user_oauth config requires authentication.credentials_path (or load via a profile so it defaults to <config_dir>/credentials/<profile>.json)`);return pn({credentialsPath:t,clientId:e.authentication.client_id,baseURL:n,fetch:r.fetch,userAgent:r.userAgent,onSafetyWarning:r.onSafetyWarning});default:{let t=e.authentication.type;throw new k(`authentication.type "${t}" is not a known authentication type`)}}}function _n(e){if(e.identity_token){let t=e.identity_token.source;if(t!==`file`)throw new k(`identity_token.source "${t}" is not supported by this SDK version (only "file")`);if(!e.identity_token.path)throw new k(`identity_token.source "file" requires a non-empty path`);return un(e.identity_token.path)}let t=A(`ANTHROPIC_IDENTITY_TOKEN_FILE`);if(t)return un(t);let n=A(`ANTHROPIC_IDENTITY_TOKEN`);return n?dn(n):null}function vn(e,t,n,r){return async i=>{let{fs:a}=await u(async()=>{let{fs:e}=await import(`./node.browser-HQ5SKBOf.js`);return{fs:e}},__vite__mapDeps([0,1]));await jt(t,r);let o;try{let e=await a.promises.readFile(t,`utf-8`);o=JSON.parse(e);let n=o?.access_token;if(n&&!i?.forceRefresh){let e=o?.expires_at;if(e==null||Pt()<e-30)return{token:n,expiresAt:e??null}}}catch(e){e?.code!==`ENOENT`&&!(e instanceof SyntaxError)&&n?.(e)}let s=await e(i);try{await Mt(t,{...o??{},version:`1.0`,type:`oauth_token`,access_token:s.token,expires_at:s.expiresAt})}catch(e){n?.(e)}return s}}var M,N,yn=(()=>{class e{constructor(){M.set(this,void 0),N.set(this,void 0),C(this,M,new Uint8Array,`f`),C(this,N,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Rt(e):e;C(this,M,It([w(this,M,`f`),t]),`f`);let n=[],r;for(;(r=bn(w(this,M,`f`),w(this,N,`f`)))!=null;){if(r.carriage&&w(this,N,`f`)==null){C(this,N,r.index,`f`);continue}if(w(this,N,`f`)!=null&&(r.index!==w(this,N,`f`)+1||r.carriage)){n.push(Bt(w(this,M,`f`).subarray(0,w(this,N,`f`)-1))),C(this,M,w(this,M,`f`).subarray(w(this,N,`f`)),`f`),C(this,N,null,`f`);continue}let e=w(this,N,`f`)===null?r.preceding:r.preceding-1,t=Bt(w(this,M,`f`).subarray(0,e));n.push(t),C(this,M,w(this,M,`f`).subarray(r.index),`f`),C(this,N,null,`f`)}return n}flush(){return w(this,M,`f`).length?this.decode(`
3
3
  `):[]}}return M=new WeakMap,N=new WeakMap,e.NEWLINE_CHARS=new Set([`
4
4
  `,`\r`]),e.NEWLINE_REGEXP=/\r\n|[\n\r]/g,e})();function bn(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}var xn,Sn=(()=>{class e{constructor(e,t,n){this.iterator=e,xn.set(this,void 0),this.controller=t,C(this,xn,n,`f`)}static rawEvents(e,t=new AbortController){return Cn(e,t)}static fromSSEResponse(t,n,r){let i=!1,a=r?j(r):console;async function*o(){if(i)throw new y("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let e of Cn(t,n)){if(e.event===`completion`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event===`message_start`||e.event===`message_delta`||e.event===`message_stop`||e.event===`content_block_start`||e.event===`content_block_delta`||e.event===`content_block_stop`||e.event===`message`||e.event===`user.message`||e.event===`user.interrupt`||e.event===`user.tool_confirmation`||e.event===`user.custom_tool_result`||e.event===`user.tool_result`||e.event===`agent.message`||e.event===`agent.thinking`||e.event===`agent.tool_use`||e.event===`agent.tool_result`||e.event===`agent.mcp_tool_use`||e.event===`agent.mcp_tool_result`||e.event===`agent.custom_tool_use`||e.event===`agent.thread_context_compacted`||e.event===`session.status_running`||e.event===`session.status_idle`||e.event===`session.status_rescheduled`||e.event===`session.status_terminated`||e.event===`session.error`||e.event===`session.deleted`||e.event===`session.updated`||e.event===`span.model_request_start`||e.event===`span.model_request_end`||e.event===`span.outcome_evaluation_start`||e.event===`span.outcome_evaluation_ongoing`||e.event===`span.outcome_evaluation_end`||e.event===`user.define_outcome`||e.event===`agent.thread_message_received`||e.event===`agent.thread_message_sent`||e.event===`agent.session_thread_message_received`||e.event===`agent.session_thread_message_sent`||e.event===`session.thread_created`||e.event===`session.thread_status_created`||e.event===`session.thread_status_running`||e.event===`session.thread_status_idle`||e.event===`session.thread_status_rescheduled`||e.event===`session.thread_status_terminated`||e.event===`event_start`||e.event===`event_delta`||e.event===`system.message`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event!==`ping`&&e.event===`error`){let n=Fe(e.data)??e.data,r=n?.error?.type;throw new le(void 0,n,void 0,t.headers,r)}}e=!0}catch(e){if(b(e))return;throw e}finally{e||n.abort(),Ze(n)}}return new e(o,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new yn,n=tt(t);for await(let t of n)for(let n of e.decode(t))yield n;for(let t of e.flush())yield t}async function*o(){if(i)throw new y("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of a())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(b(e))return;throw e}finally{e||n.abort(),Ze(n)}}return new e(o,n,r)}[(xn=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,w(this,xn,`f`)),new e(()=>i(n),this.controller,w(this,xn,`f`))]}toReadableStream(){let e=this,t;return $e({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{let{value:n,done:r}=await t.next();if(r)return e.close();let i=Rt(JSON.stringify(n)+`
5
5
  `);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.()}})}}return e})();async function*Cn(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new y(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new y(`Attempted to iterate over a response with no body`);let n=new wn,r=new yn,i=tt(e.body);for await(let e of i)for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}var wn=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
6
6
  `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(`:`))return null;let[t,n,r]=Tn(e,`:`);return r.startsWith(` `)&&(r=r.substring(1)),t===`event`?this.event=r:t===`data`&&this.data.push(r),null}};function Tn(e,t){let n=e.indexOf(t);return n===-1?[e,``,``]:[e.substring(0,n),t,e.substring(n+t.length)]}async function En(e,t){let{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:a}=t,o=await(async()=>{if(t.options.stream)return j(e).debug(`response`,n.status,n.url,n.headers,n.body),Sn.fromSSEResponse(n,t.controller,e);if(n.status===204)return null;if(t.options.__binaryResponse)return n;let r=n.headers.get(`content-type`)?.split(`;`)[0]?.trim();return r?.includes(`application/json`)||r?.endsWith(`+json`)?n.headers.get(`content-length`)===`0`?void 0:Dn(await n.json(),n):await n.text()})().finally(()=>{!t.options.stream&&!t.options.__binaryResponse&&Ze(t.controller)});return $t(j(e),`[${r}] response parsed`,{retryOfRequestLogID:i,url:n.url,status:n.status,body:o,durationMs:Date.now()-a}),o}function Dn(e,t){return!e||typeof e!=`object`||Array.isArray(e)?e:Object.defineProperties(e,{_request_id:{value:t.headers.get(`request-id`),enumerable:!1},_workspace_id:{value:t.headers.get(`anthropic-workspace-id`),enumerable:!1}})}var On=new WeakSet;function kn(e){return typeof e==`object`&&!!e&&On.has(e)}function An(e){let t=new Set;for(;typeof e==`object`&&e&&!t.has(e);){if(t.add(e),kn(e)||b(e)||e instanceof de||e instanceof ce)return!0;e=e.cause}return!1}function jn(e,t,n,r){return async(i,a={})=>{if(t.length===0)return e.call(void 0,i,a);let o=a.headers instanceof Headers?a.headers:new Headers(a.headers),s=await Pn(e,t,n,r)({...a,headers:o,url:typeof i==`string`?i:i instanceof URL?i.href:i.url});if(s.bodyUsed||s.body?.locked)throw new y(`middleware consumed the response body; use response.clone() to inspect it, or return new Response(body, response) to consume and replace it`);return s}}function Mn(e,t){let n=new WeakMap;return{options:e,logger:t?j(t):Qt(),parse(r){if(e?.stream&&r.ok)return Nn(r,e,t);let i=n.get(r);return i||(i=Nn(r,e,t),n.set(r,i)),i}}}async function Nn(e,t,n){if(e.bodyUsed||e.body?.locked)throw new y(`cannot ctx.parse() a response whose body was already consumed; call ctx.parse() instead of reading the body, or read via response.clone()`);if(t?.stream&&e.ok)return Sn.fromSSEResponse(e.clone(),new AbortController,n);if(e.status===204)return null;if(t?.__binaryResponse)return e;let r=e.headers.get(`content-type`)?.split(`;`)[0]?.trim();return r?.includes(`application/json`)||r?.endsWith(`+json`)?e.headers.get(`content-length`)===`0`?void 0:Dn(await e.clone().json(),e):await e.clone().text()}function Pn(e,t,n,r){let i=async({url:t,...n})=>{try{return await e.call(void 0,t,n)}catch(e){let t=re(e);throw On.add(t),t}},a=Mn(n,r);for(let e=t.length-1;e>=0;e--){let n=t[e],r=i;i=async e=>n(e,r,a)}return i}var Fn,In=(()=>{class e extends Promise{constructor(e,t,n=En){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=n,Fn.set(this,void 0),C(this,Fn,e,`f`)}_thenUnwrap(t){return new e(w(this,Fn,`f`),this.responsePromise,async(e,n)=>Dn(t(await this.parseResponse(e,n),n),n.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get(`request-id`),workspace_id:t.headers.get(`anthropic-workspace-id`)}}parse(){return this.parsedPromise||=this.responsePromise.then(e=>this.parseResponse(w(this,Fn,`f`),e)),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}return Fn=new WeakMap,e})(),Ln,Rn=(()=>{class e{constructor(e,t,n,r){Ln.set(this,void 0),C(this,Ln,e,`f`),this.options=r,this.response=t,this.body=n}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new y("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await w(this,Ln,`f`).requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(Ln=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}}return e})(),zn=(()=>{class e extends In{constructor(e,t,n){super(e,t,async(e,t)=>new n(e,t.response,await En(e,t),t.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let t of e)yield t}}return e})(),Bn=class extends Rn{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.has_more=n.has_more||!1,this.first_id=n.first_id||null,this.last_id=n.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more!==!1&&super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){let e=this.first_id;return e?{...this.options,query:{...Ae(this.options.query),before_id:e}}:null}let e=this.last_id;return e?{...this.options,query:{...Ae(this.options.query),after_id:e}}:null}},P=class extends Rn{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.next_page=n.next_page||null}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{...Ae(this.options.query),page:e}}:null}},Vn=class extends Rn{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.next_page=n.next_page||null,this.prev_page=n.prev_page||null}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{...Ae(this.options.query),page:e}}:null}},Hn=()=>{if(typeof File>`u`){let{process:e}=globalThis,t=typeof e?.versions?.node==`string`&&parseInt(e.versions.node.split(`.`))<20;throw Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":``))}};function Un(e,t,n){return Hn(),new File(e,t??``,n)}function Wn(e,t){let n=typeof e==`object`&&!!e&&(`name`in e&&e.name&&String(e.name)||`url`in e&&e.url&&String(e.url)||`filename`in e&&e.filename&&String(e.filename)||`path`in e&&e.path&&String(e.path))||``;return t?n.split(/[\\/]/).pop()||void 0:n}var Gn=e=>typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`,Kn=async(e,t,n=!0)=>({...e,body:await Yn(e.body,t,n)}),qn=new WeakMap;function Jn(e){let t=typeof e==`function`?e:e.fetch,n=qn.get(t);if(n)return n;let r=(async()=>{try{let e=`Response`in t?t.Response:(await t(`data:,`)).constructor,n=new FormData;return n.toString()!==await new e(n).text()}catch{return!0}})();return qn.set(t,r),r}var Yn=async(e,t,n=!0)=>{if(!await Jn(t))throw TypeError(`The provided fetch function does not support file uploads with the current global FormData class.`);let r=new FormData;return await Promise.all(Object.entries(e||{}).map(([e,t])=>Xn(r,e,t,n))),r},Xn=async(e,t,n,r)=>{if(n!==void 0){if(n==null)throw TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if(typeof n==`string`||typeof n==`number`||typeof n==`boolean`)e.append(t,String(n));else if(n instanceof Response){let i={},a=n.headers.get(`Content-Type`);a&&(i={type:a}),e.append(t,Un([await n.blob()],Wn(n,r),i))}else if(Gn(n))e.append(t,Un([await new Response(et(n)).blob()],Wn(n,r)));else if(n instanceof Blob){let i=typeof File<`u`&&n instanceof File?n.name:Wn(n,r);e.append(t,Un([n],i,{type:n.type}))}else if(Array.isArray(n))await Promise.all(n.map(n=>Xn(e,t+`[]`,n,r)));else if(typeof n.then==`function`)throw TypeError(`Received a Promise for "${t}"; await it first, e.g. \`await toFile(...)\``);else if(n instanceof ArrayBuffer||ArrayBuffer.isView(n))throw TypeError(`Received ${n.constructor.name} for "${t}"; to upload raw bytes, wrap them with \`await toFile(bytes, 'filename')\``);else if(typeof n==`object`)await Promise.all(Object.entries(n).map(([n,i])=>Xn(e,`${t}[${n}]`,i,r)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`)}},Zn=e=>typeof e==`object`&&!!e&&typeof e.size==`number`&&typeof e.type==`string`&&typeof e.text==`function`&&typeof e.slice==`function`&&typeof e.arrayBuffer==`function`,Qn=e=>typeof e==`object`&&!!e&&typeof e.name==`string`&&typeof e.lastModified==`number`&&Zn(e),$n=e=>typeof e==`object`&&!!e&&typeof e.url==`string`&&typeof e.blob==`function`;async function er(e,t,n){if(Hn(),e=await e,t||=e instanceof File?e.name:Wn(e,!0),Qn(e))return e instanceof File&&t==null&&n==null?e:Un([await e.arrayBuffer()],t??e.name,{type:e.type,lastModified:e.lastModified,...n});if($n(e)){let r=await e.blob();return t||=new URL(e.url).pathname.split(/[\\/]/).pop(),Un(await tr(r),t,n)}let r=await tr(e);if(!n?.type){let e=r.find(e=>typeof e==`object`&&`type`in e&&e.type);typeof e==`string`&&(n={...n,type:e})}return Un(r,t,n)}async function tr(e){let t=[];if(typeof e==`string`||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(Zn(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(Gn(e))for await(let n of e)t.push(...await tr(n));else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:``}${nr(e)}`)}return t}function nr(e){return typeof e!=`object`||!e?``:`; props: [${Object.getOwnPropertyNames(e).map(e=>`"${e}"`).join(`, `)}]`}var F=class{constructor(e){this._client=e}},rr=Symbol.for(`brand.privateNullableHeaders`);function*ir(e){if(!e)return;if(rr in e){let{values:t,nulls:n}=e;yield*t.entries();for(let e of n)yield[e,null];return}let t=!1,n;e instanceof Headers?n=e.entries():ke(e)?n=e:(t=!0,n=Object.entries(e??{}));for(let e of n){let n=e[0];if(typeof n!=`string`)throw TypeError(`expected header name to be a string`);let r=ke(e[1])?e[1]:[e[1]],i=!1;for(let e of r)e!==void 0&&(t&&!i&&(i=!0,yield[n,ar]),yield[n,e])}}var ar=Symbol(`clear`),or=new Set([`x-stainless-helper`]),sr=(e,t)=>{let n=e?e.split(`,`).map(e=>e.trim()).filter(Boolean):[];for(let e of t.split(`,`).map(e=>e.trim()))e&&!n.includes(e)&&n.push(e);return n.join(`, `)},I=e=>{let t=new Headers,n=new Set;for(let r of e){let e=new Set;for(let[i,a]of ir(r)){let r=i.toLowerCase();if(or.has(r)){if(a===ar)continue;a===null?(t.delete(i),n.add(r)):(t.set(i,sr(t.get(i),a)),n.delete(r));continue}(a===ar||!e.has(r))&&(t.delete(i),e.add(r),a===ar)||(a===null?(t.delete(i),n.add(r)):(t.append(i,a),n.delete(r)))}}return{[rr]:!0,values:t,nulls:n}};function cr(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var lr=Object.freeze(Object.create(null)),L=((e=cr)=>function(t,...n){if(t.length===1)return t[0];let r=!1,i=[],a=t.reduce((t,a,o)=>{/[?#]/.test(a)&&(r=!0);let s=n[o],c=(r?encodeURIComponent:e)(``+s);return o!==n.length&&(s==null||typeof s==`object`&&s.toString===Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty??lr)??lr)?.toString)&&(c=s+``,i.push({start:t.length+a.length,length:c.length,error:`Value of type ${Object.prototype.toString.call(s).slice(8,-1)} is not a valid path parameter`})),t+a+(o===n.length?``:c)},``),o=a.split(/[?#]/,1)[0],s=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,c;for(;(c=s.exec(o))!==null;)i.push({start:c.index,length:c[0].length,error:`Value "${c[0]}" can\'t be safely passed as a path parameter`});if(i.sort((e,t)=>e.start-t.start),i.length>0){let e=0,t=i.reduce((t,n)=>{let r=` `.repeat(n.start-e),i=`^`.repeat(n.length);return e=n.start+n.length,t+r+i},``);throw new y(`Path parameters result in path with invalid segments:\n${i.map(e=>e.error).join(`
7
- `)}\n${a}\n${t}`)}return a})(cr),ur=class extends F{retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/deployment_runs/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/deployment_runs?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}},dr=class extends F{create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/deployments?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/deployments/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}update(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/deployments/${e}?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/deployments?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}archive(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/deployments/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}pause(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/deployments/${e}/pause?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}run(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/deployments/${e}/run?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}unpause(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/deployments/${e}/unpause?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}},fr=class extends F{create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/dreams?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`dreaming-2026-04-21`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/dreams/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`dreaming-2026-04-21`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/dreams?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`dreaming-2026-04-21`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}archive(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/dreams/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`dreaming-2026-04-21`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}cancel(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/dreams/${e}/cancel?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`dreaming-2026-04-21`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}},pr=`x-stainless-helper`,mr=`x-stainless-helper-method`;function hr(e){return{[pr]:e}}var gr=Symbol(`anthropic.sdk.stainlessHelper`);function _r(e){return typeof e==`object`&&!!e&&gr in e}function vr(e,t){let n=new Set;if(e)for(let t of e)_r(t)&&n.add(t[gr]);if(t)for(let e of t){_r(e)&&n.add(e[gr]);let t=e.content;if(Array.isArray(t))for(let e of t){_r(e)&&n.add(e[gr]);let t=e?.tool?.definition;_r(t)&&n.add(t[gr])}}return Array.from(n)}function yr(e,t){let n=vr(e,t);return n.length===0?{}:{[pr]:n.join(`, `)}}function br(e){return _r(e)?{[pr]:e[gr]}:{}}var xr=class extends F{list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/files?beta=true`,P,{query:i,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()},...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}delete(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.delete(L`/v1/files/${e}?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}download(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/files/${e}/content?beta=true`,{...n,headers:I([{Accept:`application/binary`,...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers]),__binaryResponse:!0})}retrieveMetadata(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/files/${e}?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}upload(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/files?beta=true`,Kn({body:i,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()},...r==null?void 0:{"anthropic-workspace-id":r}},br(i.file),t?.headers])},this._client))}},Sr=class extends F{retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/models/${e}?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/models?beta=true`,Bn,{query:i,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()},...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}},Cr=class extends F{create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/user_profiles?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`user-profiles-2026-08-18`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/user_profiles/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`user-profiles-2026-08-18`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}update(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/user_profiles/${e}?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`user-profiles-2026-08-18`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/user_profiles?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`user-profiles-2026-08-18`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}createEnrollmentURL(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/user_profiles/${e}/enrollment_url?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`user-profiles-2026-08-18`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}},wr=t((e=>{var t=e&&e.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();Object.defineProperty(e,"__esModule",{value:!0});var n=256,r=function(){function e(e){e===void 0&&(e=`=`),this._paddingCharacter=e}return e.prototype.encodedLength=function(e){return this._paddingCharacter?(e+2)/3*4|0:(e*8+5)/6|0},e.prototype.encode=function(e){for(var t=``,n=0;n<e.length-2;n+=3){var r=e[n]<<16|e[n+1]<<8|e[n+2];t+=this._encodeByte(r>>>18&63),t+=this._encodeByte(r>>>12&63),t+=this._encodeByte(r>>>6&63),t+=this._encodeByte(r>>>0&63)}var i=e.length-n;if(i>0){var r=e[n]<<16|(i===2?e[n+1]<<8:0);t+=this._encodeByte(r>>>18&63),t+=this._encodeByte(r>>>12&63),t+=i===2?this._encodeByte(r>>>6&63):this._paddingCharacter||``,t+=this._paddingCharacter||``}return t},e.prototype.maxDecodedLength=function(e){return this._paddingCharacter?e/4*3|0:(e*6+7)/8|0},e.prototype.decodedLength=function(e){return this.maxDecodedLength(e.length-this._getPaddingLength(e))},e.prototype.decode=function(e){if(e.length===0)return new Uint8Array;for(var t=this._getPaddingLength(e),r=e.length-t,i=new Uint8Array(this.maxDecodedLength(r)),a=0,o=0,s=0,c=0,l=0,u=0,d=0;o<r-4;o+=4)c=this._decodeChar(e.charCodeAt(o+0)),l=this._decodeChar(e.charCodeAt(o+1)),u=this._decodeChar(e.charCodeAt(o+2)),d=this._decodeChar(e.charCodeAt(o+3)),i[a++]=c<<2|l>>>4,i[a++]=l<<4|u>>>2,i[a++]=u<<6|d,s|=c&n,s|=l&n,s|=u&n,s|=d&n;if(o<r-1&&(c=this._decodeChar(e.charCodeAt(o)),l=this._decodeChar(e.charCodeAt(o+1)),i[a++]=c<<2|l>>>4,s|=c&n,s|=l&n),o<r-2&&(u=this._decodeChar(e.charCodeAt(o+2)),i[a++]=l<<4|u>>>2,s|=u&n),o<r-3&&(d=this._decodeChar(e.charCodeAt(o+3)),i[a++]=u<<6|d,s|=d&n),s!==0)throw Error(`Base64Coder: incorrect characters for decoding`);return i},e.prototype._encodeByte=function(e){var t=e;return t+=65,t+=25-e>>>8&6,t+=51-e>>>8&-75,t+=61-e>>>8&-15,t+=62-e>>>8&3,String.fromCharCode(t)},e.prototype._decodeChar=function(e){var t=n;return t+=(42-e&e-44)>>>8&-n+e-43+62,t+=(46-e&e-48)>>>8&-n+e-47+63,t+=(47-e&e-58)>>>8&-n+e-48+52,t+=(64-e&e-91)>>>8&-n+e-65+0,t+=(96-e&e-123)>>>8&-n+e-97+26,t},e.prototype._getPaddingLength=function(e){var t=0;if(this._paddingCharacter){for(var n=e.length-1;n>=0&&e[n]===this._paddingCharacter;n--)t++;if(e.length<4||t>2)throw Error(`Base64Coder: incorrect padding`)}return t},e}();e.Coder=r;var i=new r;function a(e){return i.encode(e)}e.encode=a;function o(e){return i.decode(e)}e.decode=o;var s=function(e){t(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return r.prototype._encodeByte=function(e){var t=e;return t+=65,t+=25-e>>>8&6,t+=51-e>>>8&-75,t+=61-e>>>8&-13,t+=62-e>>>8&49,String.fromCharCode(t)},r.prototype._decodeChar=function(e){var t=n;return t+=(44-e&e-46)>>>8&-n+e-45+62,t+=(94-e&e-96)>>>8&-n+e-95+63,t+=(47-e&e-58)>>>8&-n+e-48+52,t+=(64-e&e-91)>>>8&-n+e-65+0,t+=(96-e&e-123)>>>8&-n+e-97+26,t},r}(r);e.URLSafeCoder=s;var c=new s;function l(e){return c.encode(e)}e.encodeURLSafe=l;function u(e){return c.decode(e)}e.decodeURLSafe=u,e.encodedLength=function(e){return i.encodedLength(e)},e.maxDecodedLength=function(e){return i.maxDecodedLength(e)},e.decodedLength=function(e){return i.decodedLength(e)}})),Tr=t(((e,t)=>{(function(e,n){var r={};n(r);var i=r.default;for(var a in r)i[a]=r[a];typeof t==`object`&&typeof t.exports==`object`?t.exports=i:typeof define==`function`&&define.amd?define(function(){return i}):e.sha256=i})(e,function(e){e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(e,n,r,i,a){for(var o,s,c,l,u,d,f,p,m,h,g,_,v;a>=64;){for(o=n[0],s=n[1],c=n[2],l=n[3],u=n[4],d=n[5],f=n[6],p=n[7],h=0;h<16;h++)g=i+h*4,e[h]=(r[g]&255)<<24|(r[g+1]&255)<<16|(r[g+2]&255)<<8|r[g+3]&255;for(h=16;h<64;h++)m=e[h-2],_=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,m=e[h-15],v=(m>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,e[h]=(_+e[h-7]|0)+(v+e[h-16]|0);for(h=0;h<64;h++)_=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&d^~u&f)|0)+(p+(t[h]+e[h]|0)|0)|0,v=((o>>>2|o<<30)^(o>>>13|o<<19)^(o>>>22|o<<10))+(o&s^o&c^s&c)|0,p=f,f=d,d=u,u=l+_|0,l=c,c=s,s=o,o=_+v|0;n[0]+=o,n[1]+=s,n[2]+=c,n[3]+=l,n[4]+=u,n[5]+=d,n[6]+=f,n[7]+=p,i+=64,a-=64}return i}var r=function(){function t(){this.digestLength=e.digestLength,this.blockSize=e.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return t.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},t.prototype.clean=function(){for(var e=0;e<this.buffer.length;e++)this.buffer[e]=0;for(var e=0;e<this.temp.length;e++)this.temp[e]=0;this.reset()},t.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this.finished)throw Error(`SHA256: can't update because hash was finished.`);var r=0;if(this.bytesHashed+=t,this.bufferLength>0){for(;this.bufferLength<64&&t>0;)this.buffer[this.bufferLength++]=e[r++],t--;this.bufferLength===64&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(t>=64&&(r=n(this.temp,this.state,e,r,t),t%=64);t>0;)this.buffer[this.bufferLength++]=e[r++],t--;return this},t.prototype.finish=function(e){if(!this.finished){var t=this.bytesHashed,r=this.bufferLength,i=t/536870912|0,a=t<<3,o=t%64<56?64:128;this.buffer[r]=128;for(var s=r+1;s<o-8;s++)this.buffer[s]=0;this.buffer[o-8]=i>>>24&255,this.buffer[o-7]=i>>>16&255,this.buffer[o-6]=i>>>8&255,this.buffer[o-5]=i>>>0&255,this.buffer[o-4]=a>>>24&255,this.buffer[o-3]=a>>>16&255,this.buffer[o-2]=a>>>8&255,this.buffer[o-1]=a>>>0&255,n(this.temp,this.state,this.buffer,0,o),this.finished=!0}for(var s=0;s<8;s++)e[s*4+0]=this.state[s]>>>24&255,e[s*4+1]=this.state[s]>>>16&255,e[s*4+2]=this.state[s]>>>8&255,e[s*4+3]=this.state[s]>>>0&255;return this},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype._saveState=function(e){for(var t=0;t<this.state.length;t++)e[t]=this.state[t]},t.prototype._restoreState=function(e,t){for(var n=0;n<this.state.length;n++)this.state[n]=e[n];this.bytesHashed=t,this.finished=!1,this.bufferLength=0},t}();e.Hash=r;var i=function(){function e(e){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var t=new Uint8Array(this.blockSize);if(e.length>this.blockSize)new r().update(e).finish(t).clean();else for(var n=0;n<e.length;n++)t[n]=e[n];for(var n=0;n<t.length;n++)t[n]^=54;this.inner.update(t);for(var n=0;n<t.length;n++)t[n]^=106;this.outer.update(t),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var n=0;n<t.length;n++)t[n]=0}return e.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},e.prototype.clean=function(){for(var e=0;e<this.istate.length;e++)this.ostate[e]=this.istate[e]=0;this.inner.clean(),this.outer.clean()},e.prototype.update=function(e){return this.inner.update(e),this},e.prototype.finish=function(e){return this.outer.finished?this.outer.finish(e):(this.inner.finish(e),this.outer.update(e,this.digestLength).finish(e)),this},e.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},e}();e.HMAC=i;function a(e){var t=new r().update(e),n=t.digest();return t.clean(),n}e.hash=a,e.default=a;function o(e,t){var n=new i(e).update(t),r=n.digest();return n.clean(),r}e.hmac=o;function s(e,t,n,r){var i=r[0];if(i===0)throw Error(`hkdf: cannot expand more`);t.reset(),i>1&&t.update(e),n&&t.update(n),t.update(r),t.finish(e),r[0]++}var c=new Uint8Array(e.digestLength);function l(e,t,n,r){t===void 0&&(t=c),r===void 0&&(r=32);for(var a=new Uint8Array([1]),l=new i(o(t,e)),u=new Uint8Array(l.digestLength),d=u.length,f=new Uint8Array(r),p=0;p<r;p++)d===u.length&&(s(u,l,n,a),d=0),f[p]=u[d++];return l.clean(),u.fill(0),a.fill(0),f}e.hkdf=l;function u(e,t,n,r){for(var a=new i(e),o=a.digestLength,s=new Uint8Array(4),c=new Uint8Array(o),l=new Uint8Array(o),u=new Uint8Array(r),d=0;d*o<r;d++){var f=d+1;s[0]=f>>>24&255,s[1]=f>>>16&255,s[2]=f>>>8&255,s[3]=f>>>0&255,a.reset(),a.update(t),a.update(s),a.finish(l);for(var p=0;p<o;p++)c[p]=l[p];for(var p=2;p<=n;p++){a.reset(),a.update(l).finish(l);for(var m=0;m<o;m++)c[m]^=l[m]}for(var p=0;p<o&&d*o+p<r;p++)u[d*o+p]=c[p]}for(var d=0;d<o;d++)c[d]=l[d]=0;for(var d=0;d<4;d++)s[d]=0;return a.clean(),u}e.pbkdf2=u})})),Er=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.timingSafeEqual=n;function t(e,t=``){if(!e)throw Error(t)}function n(e,n){if(e.byteLength!==n.byteLength)return!1;e instanceof DataView||(e=new DataView(ArrayBuffer.isView(e)?e.buffer:e)),n instanceof DataView||(n=new DataView(ArrayBuffer.isView(n)?n.buffer:n)),t(e instanceof DataView),t(n instanceof DataView);let r=e.byteLength,i=0,a=-1;for(;++a<r;)i|=e.getUint8(a)^n.getUint8(a);return i===0}})),Dr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Webhook=e.WebhookVerificationError=void 0;var t=wr(),n=Tr(),r=Er(),i=300,a=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name=`ExtendableError`,this.stack=Error(t).stack}},o=class e extends a{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name=`WebhookVerificationError`}};e.WebhookVerificationError=o;var s=class e{constructor(n,r){if(r?.format===`raw`)this.key=n instanceof Uint8Array?n:Uint8Array.from(n,e=>e.charCodeAt(0));else{if(typeof n!=`string`)throw Error(`Expected secret to be of type string`);n.startsWith(e.prefix)&&(n=n.substring(e.prefix.length)),this.key=t.decode(n)}if(this.key.length===0)throw Error(`Secret can't be empty.`)}verify(e,t,n){let i=n?.jsonParse??!0,a={};for(let e of Object.keys(t))a[e.toLowerCase()]=t[e];let s=a[`webhook-id`],c=a[`webhook-signature`],l=a[`webhook-timestamp`];if(!c||!s||!l)throw new o(`Missing required headers`);let u=this.verifyTimestamp(l),d=this.sign(s,u,e).split(`,`)[1],f=c.split(` `),p=new globalThis.TextEncoder;for(let t of f){let[n,a]=t.split(`,`);if(n===`v1`&&(0,r.timingSafeEqual)(p.encode(a),p.encode(d))){let t=e.toString();return t===``?void 0:i?JSON.parse(t):void 0}}throw new o(`No matching signature found`)}sign(e,r,i){if(typeof i!=`string`){if(i.constructor.name===`Buffer`)i=i.toString();else throw Error(`Expected payload to be of type string or Buffer.`)}let a=new TextEncoder,o=Math.floor(r.getTime()/1e3),s=a.encode(`${e}.${o}.${i}`);return`v1,${t.encode(n.hmac(this.key,s))}`}verifyTimestamp(e){let t=Math.floor(Date.now()/1e3),n=parseInt(e,10);if(Number.isNaN(n))throw new o(`Invalid Signature Headers`);if(t-n>i)throw new o(`Message timestamp too old`);if(n>t+i)throw new o(`Message timestamp too new`);return new Date(n*1e3)}};e.Webhook=s,s.prefix=`whsec_`}))(),Or=class extends F{parseUnverified(e){return JSON.parse(e)}unwrap(e,t){let n=t?.headers;if(n==null)throw Error(`Webhook headers are required in order to verify the signature`);let r=t.key===void 0?this._client.webhookKey:t.key;if(!r)throw Error(`Webhook key must not be null or empty in order to unwrap`);return new Dr.Webhook(r).verify(e,n),JSON.parse(e)}},kr=class extends F{list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/agents/${e}/versions?beta=true`,P,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}},Ar=(()=>{class e extends F{constructor(){super(...arguments),this.versions=new kr(this._client)}create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/agents?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.get(L`/v1/agents/${e}?beta=true`,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}update(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/agents/${e}?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/agents?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}archive(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/agents/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}}return e.Versions=kr,e})();function jr(e,t){if(!e)return()=>{};if(e.aborted)return t.abort(),()=>{};let n=()=>t.abort();return e.addEventListener(`abort`,n),()=>e.removeEventListener(`abort`,n)}function Mr(e,t){return e instanceof le&&e.status===t}function Nr(e){return e instanceof le&&typeof e.status==`number`&&e.status>=400&&e.status<500}function Pr(e){return Nr(e)&&!Mr(e,408)&&!Mr(e,409)&&!Mr(e,429)}function Fr(e,t,n){return Math.min(t*2**e,n)}function Ir(e,t){return e+Math.random()*(t-e)}function Lr(e){return e*(1-Math.random()*.25)}function Rr(e,{authToken:t,helper:n}){if(!t)throw new y(`copyClientForHelper: expected a non-empty authToken but received ${JSON.stringify(t)}`);let r=e,i=r._options.defaultHeaders,a=r._authState?.extraHeaders,o=I([a?Object.fromEntries(Object.entries(a).filter(([e])=>{let t=e.toLowerCase();return t!==`authorization`&&t!==`x-api-key`})):void 0,i,{[pr]:n}]);return e.withOptions({apiKey:null,authToken:t,baseURL:e.baseURL,credentials:void 0,defaultHeaders:o})}var zr,Br,R,Vr,Hr,Ur,Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr=1e3,Qr=6e4,$r=3e5,ei=(()=>{class e{constructor(e){zr.set(this,void 0),Br.set(this,!1),R.set(this,void 0),Vr.set(this,void 0),Hr.set(this,void 0),Ur.set(this,void 0),Wr.set(this,void 0),Gr.set(this,void 0),Kr.set(this,void 0),this.client=e.client,this.environmentId=e.environmentId,this.environmentKey=e.environmentKey,this.workerId=e.workerId??ri(),C(this,zr,Rr(e.client,{authToken:e.environmentKey,helper:`environments-work-poller`}),`f`),C(this,Hr,e.autoStop??!0,`f`),C(this,Ur,e.drain??!1,`f`),C(this,Wr,e.blockMs===void 0?999:e.blockMs,`f`),C(this,Gr,e.reclaimOlderThanMs??null,`f`),C(this,Kr,e.requestOptions,`f`),C(this,R,new AbortController,`f`),C(this,Vr,jr(e.signal,w(this,R,`f`)),`f`)}get signal(){return w(this,R,`f`).signal}abort(){w(this,R,`f`).abort()}async*[(zr=new WeakMap,Br=new WeakMap,R=new WeakMap,Vr=new WeakMap,Hr=new WeakMap,Ur=new WeakMap,Wr=new WeakMap,Gr=new WeakMap,Kr=new WeakMap,Symbol.asyncIterator)](){if(w(this,Br,`f`))throw new y(`Cannot iterate over a consumed WorkPoller`);C(this,Br,!0,`f`);let e=j(this.client);e.info(`poller starting`,{component:`work-poller`,environment_id:this.environmentId});let t=new ni(e,this.environmentId);try{let n=0;for(;!w(this,R,`f`).signal.aborted;){let r;try{r=await w(this,zr,`f`).beta.environments.work.poll(this.environmentId,{"Anthropic-Worker-ID":this.workerId,...w(this,Wr,`f`)===null?{}:{block_ms:w(this,Wr,`f`)},...w(this,Gr,`f`)===null?{}:{reclaim_older_than_ms:w(this,Gr,`f`)}},{headers:I([w(this,Kr,`f`)?.headers]),signal:w(this,R,`f`).signal})}catch(t){if(w(this,R,`f`).signal.aborted)return;if(Pr(t))throw e.error(`poll failed permanently, stopping poller`,{error:String(t)}),t;let r=Lr(ti(n));e.warn(`poll failed, backing off`,{error:String(t),backoff_ms:r}),n++,await Ie(r,w(this,R,`f`).signal);continue}if(n=0,r==null){if(w(this,Ur,`f`))return;t.onEmptyPoll(),await Ie(Ir(1e3,3e3),w(this,R,`f`).signal);continue}t.onClaim(),e.info(`claimed work`,{component:`work-poller`,environment_id:this.environmentId,work_id:r.id,work_type:r.data.type});try{await w(this,zr,`f`).beta.environments.work.ack(r.id,{environment_id:r.environment_id},{headers:I([w(this,Kr,`f`)?.headers]),signal:w(this,R,`f`).signal})}catch(t){e.error(`ack failed`,{work_id:r.id,error:String(t)});continue}try{yield r}finally{if(w(this,Hr,`f`))try{await w(this,zr,`f`).beta.environments.work.stop(r.id,{environment_id:r.environment_id},{headers:I([w(this,Kr,`f`)?.headers])})}catch(t){Mr(t,409)||e.warn(`stop failed`,{work_id:r.id,error:String(t)})}}}}finally{w(this,Vr,`f`).call(this)}}}return e})();function ti(e){return Fr(e,Zr,Qr)}var ni=(()=>{class e{constructor(e,t){qr.set(this,void 0),Jr.set(this,void 0),Yr.set(this,void 0),Xr.set(this,0),C(this,qr,e,`f`),C(this,Jr,t,`f`)}onEmptyPoll(){let e=Date.now(),t={component:`work-poller`,environment_id:w(this,Jr,`f`)};w(this,Yr,`f`)===void 0?(C(this,Yr,C(this,Xr,e,`f`),`f`),w(this,qr,`f`).info(`idle; polling for work`,t)):e-w(this,Xr,`f`)>=$r?(C(this,Xr,e,`f`),w(this,qr,`f`).info(`still polling; idle for ${Math.round((e-w(this,Yr,`f`))/1e3)}s`,t)):w(this,qr,`f`).debug(`poll returned no work`,t)}onClaim(){C(this,Yr,void 0,`f`)}}return qr=new WeakMap,Jr=new WeakMap,Yr=new WeakMap,Xr=new WeakMap,e})();function ri(){let e={}.HOSTNAME;return e?`${e}-${tn()}`:tn()}var ii,ai,oi,si=(()=>{class e{constructor(){ii.set(this,[]),ai.set(this,[]),oi.set(this,!1)}push(e){if(w(this,oi,`f`))return!1;let t=w(this,ai,`f`).shift();return t?t({done:!1,value:e}):w(this,ii,`f`).push(e),!0}close(){if(!w(this,oi,`f`))for(C(this,oi,!0,`f`);w(this,ai,`f`).length>0;)w(this,ai,`f`).shift()({done:!0,value:void 0})}next(e){return w(this,ii,`f`).length>0?Promise.resolve({done:!1,value:w(this,ii,`f`).shift()}):w(this,oi,`f`)||e?.aborted?Promise.resolve({done:!0,value:void 0}):new Promise(t=>{let n=n=>{e?.removeEventListener(`abort`,r),t(n)},r=()=>{let e=w(this,ai,`f`).indexOf(n);e>=0&&w(this,ai,`f`).splice(e,1),t({done:!0,value:void 0})};w(this,ai,`f`).push(n),e?.addEventListener(`abort`,r,{once:!0})})}tryShift(){return w(this,ii,`f`).shift()}}return ii=new WeakMap,ai=new WeakMap,oi=new WeakMap,e})(),ci=(()=>{class e extends Error{constructor(e){let t=typeof e==`string`?e:e.map(e=>e.type===`text`?e.text:`[${e.type}]`).join(` `);super(t),this.name=`ToolError`,this.content=e}}return e})();function li(e){return`name`in e?e.name:`mcp_server_name`in e?e.mcp_server_name:e.type}function ui(e){return e instanceof ci?e.content:`Error: ${e instanceof Error?e.message:String(e)}`}async function di(e,t,n){try{let r=e.parse?e.parse(t):t;return{content:await e.run(r,n),isError:!1}}catch(e){return{content:ui(e),isError:!0}}}var fi,pi,mi,hi,z,B,gi,V,_i,vi,yi,H,bi,U,xi,Si,Ci,wi,Ti,Ei,W,Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii,Li,Ri,zi=500,Bi=1e4,Vi=12e4,Hi=3e4,Ui=1e3,Wi=3e4,Gi=3e5;function Ki(e){return e.type===`session.status_idle`&&e.stop_reason?.type===`end_turn`}var qi=(()=>{class e{constructor(e,t){fi.set(this,void 0),pi.set(this,void 0),mi.set(this,new Set),hi.set(this,!1),z.set(this,void 0),C(this,fi,e,`f`),C(this,pi,t,`f`)}noteEvent(e){e.type!==`user.tool_confirmation`&&(Ki(e)?this.arm():this.disarm())}block(e){w(this,mi,`f`).add(e),w(this,z,`f`)!==void 0&&(C(this,hi,!0,`f`),clearTimeout(w(this,z,`f`)),C(this,z,void 0,`f`))}unblock(e){w(this,mi,`f`).delete(e),w(this,mi,`f`).size===0&&w(this,hi,`f`)&&this.arm()}arm(){if(!(w(this,fi,`f`)<=0)){if(w(this,mi,`f`).size>0){C(this,hi,!0,`f`);return}C(this,hi,!1,`f`),w(this,z,`f`)!==void 0&&clearTimeout(w(this,z,`f`)),C(this,z,setTimeout(w(this,pi,`f`),w(this,fi,`f`)),`f`)}}disarm(){C(this,hi,!1,`f`),w(this,z,`f`)!==void 0&&(clearTimeout(w(this,z,`f`)),C(this,z,void 0,`f`))}}return fi=new WeakMap,pi=new WeakMap,mi=new WeakMap,hi=new WeakMap,z=new WeakMap,e})(),Ji=(()=>{class e{constructor(e,t){B.add(this),gi.set(this,!1),V.set(this,void 0),_i.set(this,void 0),vi.set(this,void 0),yi.set(this,void 0),H.set(this,void 0),bi.set(this,new Set),U.set(this,new Set),xi.set(this,new Map),Si.set(this,new Map),Ci.set(this,new si),wi.set(this,0),Ti.set(this,Gi),Ei.set(this,null),W.set(this,void 0),this.client=t.client,this.sessionId=e,this.tools=t.tools,this.maxIdleMs=t.maxIdleMs??6e4,C(this,H,j(t.client),`f`),C(this,yi,new Map(t.tools.map(e=>[li(e),e])),`f`),C(this,V,new AbortController,`f`),C(this,_i,jr(t.signal,w(this,V,`f`)),`f`),C(this,vi,t.requestOptions,`f`),C(this,W,new qi(this.maxIdleMs,()=>{w(this,H,`f`).info(`session idle after end_turn; stopping`,{component:`session-tool-runner`,session_id:this.sessionId,max_idle_ms:this.maxIdleMs}),w(this,V,`f`).abort()}),`f`)}get signal(){return w(this,V,`f`).signal}abort(){w(this,V,`f`).abort()}_setSendRetryWindow(e){C(this,Ti,e,`f`)}async*[(gi=new WeakMap,V=new WeakMap,_i=new WeakMap,vi=new WeakMap,yi=new WeakMap,H=new WeakMap,bi=new WeakMap,U=new WeakMap,xi=new WeakMap,Si=new WeakMap,Ci=new WeakMap,wi=new WeakMap,Ti=new WeakMap,Ei=new WeakMap,W=new WeakMap,B=new WeakSet,Symbol.asyncIterator)](){if(w(this,gi,`f`))throw new y(`Cannot iterate over a consumed SessionToolRunner`);C(this,gi,!0,`f`),w(this,H,`f`).info(`session tool runner starting`,{component:`session-tool-runner`,session_id:this.sessionId});let e=w(this,B,`m`,Oi).call(this).catch(e=>{w(this,V,`f`).signal.aborted||w(this,H,`f`).error(`stream loop failed`,{error:String(e)}),w(this,V,`f`).abort()});try{for(;;){let e=await w(this,Ci,`f`).next(w(this,V,`f`).signal);if(e.done)break;yield e.value}await e;let t;for(;(t=w(this,Ci,`f`).tryShift())!==void 0;)yield t}finally{w(this,V,`f`).abort(),w(this,W,`f`).disarm(),await e;try{await w(this,B,`m`,Ri).call(this)}catch(e){w(this,H,`f`).warn(`drain failed`,{error:String(e)})}w(this,Ci,`f`).close();for(let e of this.tools)try{await e.close?.()}catch(t){w(this,H,`f`).warn(`tool.close failed`,{tool:li(e),error:String(t)})}w(this,_i,`f`).call(this)}}}return Di=function(){return{...w(this,vi,`f`),headers:I([hr(`session-tool-runner`),w(this,vi,`f`)?.headers]),signal:w(this,V,`f`).signal}},Oi=async function(){let e=w(this,V,`f`),t=zi;for(;!e.signal.aborted;){try{let e=await this.client.beta.sessions.events.stream(this.sessionId,{},w(this,B,`m`,Di).call(this));await w(this,B,`m`,ki).call(this);for await(let n of e)if(t=zi,await w(this,B,`m`,ji).call(this,n))return}catch(n){if(e.signal.throwIfAborted(),Pr(n))throw w(this,H,`f`).error(`permanent stream failure, shutting down`,{error:String(n)}),e.abort(),n;w(this,H,`f`).warn(`stream disconnected, reconnecting`,{error:String(n),backoff_ms:t})}e.signal.throwIfAborted(),await Ie(t,e.signal),t=Math.min(t*2,Bi)}},ki=async function(){let e=w(this,V,`f`),t=[],n=!1;try{for await(let e of this.client.beta.sessions.events.list(this.sessionId,{limit:1e3},w(this,B,`m`,Di).call(this)))w(this,B,`m`,Ai).call(this,e,t),n=Ki(e)}catch(n){e.signal.throwIfAborted(),w(this,H,`f`).warn(`reconcile list failed`,{error:String(n)});for(let e of t)w(this,bi,`f`).delete(e.id);return}let r=t.filter(e=>!w(this,U,`f`).has(e.id));w(this,W,`f`).disarm();for(let e of r)await w(this,B,`m`,Mi).call(this,e);for(let e of[...w(this,Si,`f`).values()]){let t=w(this,xi,`f`).get(e.id);t!==void 0&&await w(this,B,`m`,Pi).call(this,e,t)}let i=r.filter(e=>!w(this,U,`f`).has(e.id)&&!w(this,Si,`f`).has(e.id));n&&i.length===0?w(this,W,`f`).arm():w(this,W,`f`).disarm()},Ai=function(e,t){e.type===`agent.tool_use`||e.type===`agent.custom_tool_use`?(w(this,bi,`f`).add(e.id),w(this,U,`f`).has(e.id)||t.push(e)):e.type===`user.tool_result`?w(this,U,`f`).add(e.tool_use_id):e.type===`user.custom_tool_result`?w(this,U,`f`).add(e.custom_tool_use_id):e.type===`user.tool_confirmation`&&(w(this,U,`f`).has(e.tool_use_id)||w(this,xi,`f`).set(e.tool_use_id,e.result))},ji=async function(e){switch(w(this,W,`f`).noteEvent(e),e.type){case`agent.tool_use`:case`agent.custom_tool_use`:return w(this,bi,`f`).has(e.id)||(w(this,bi,`f`).add(e.id),await w(this,B,`m`,Mi).call(this,e)),!1;case`user.tool_confirmation`:return await w(this,B,`m`,Ni).call(this,e),!1;case`user.tool_result`:return w(this,U,`f`).add(e.tool_use_id),!1;case`user.custom_tool_result`:return w(this,U,`f`).add(e.custom_tool_use_id),!1;case`session.status_terminated`:case`session.deleted`:return w(this,H,`f`).info(`session terminated`,{component:`session-tool-runner`,session_id:this.sessionId}),w(this,V,`f`).abort(),!0;default:return!1}},Mi=async function(e){let t=e.evaluated_permission,n=t===`deny`?`deny`:w(this,xi,`f`).get(e.id);if(n===void 0){t===void 0||t===`allow`?await w(this,B,`m`,Ii).call(this,e,void 0):w(this,Si,`f`).has(e.id)||(w(this,H,`f`).info(`tool call awaiting confirmation; holding`,{component:`session-tool-runner`,session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),w(this,Si,`f`).set(e.id,e),w(this,W,`f`).block(e.id));return}await w(this,B,`m`,Pi).call(this,e,n)},Ni=async function(e){w(this,xi,`f`).set(e.tool_use_id,e.result);let t=w(this,Si,`f`).get(e.tool_use_id);t!==void 0&&await w(this,B,`m`,Pi).call(this,t,e.result)},Pi=async function(e,t){let n=w(this,Si,`f`).delete(e.id);if(t===`allow`){w(this,H,`f`).info(`tool call confirmed`,{component:`session-tool-runner`,session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),n||w(this,W,`f`).block(e.id);try{await w(this,B,`m`,Ii).call(this,e,`allow`)}finally{w(this,W,`f`).unblock(e.id)}return}n&&w(this,W,`f`).unblock(e.id),w(this,U,`f`).add(e.id),w(this,H,`f`).info(`tool call denied; not executing`,{component:`session-tool-runner`,session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),w(this,B,`m`,Fi).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:`deny`})},Fi=function(e){w(this,Ci,`f`).push(e)},Ii=async function(e,t){var n,r;if(!w(this,U,`f`).has(e.id)){w(this,H,`f`).info(`executing tool`,{component:`session-tool-runner`,session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),C(this,wi,(n=w(this,wi,`f`),n++,n),`f`);try{let n=w(this,yi,`f`).get(e.name);if(!n){w(this,H,`f`).info(`tool not owned by this runner; leaving the tool_use_id pending for its owner`,{component:`session-tool-runner`,session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),w(this,B,`m`,Fi).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:t});return}let r,i,a=new AbortController,o=jr(w(this,V,`f`).signal,a),s=setTimeout(()=>a.abort(),Vi);try{let t=await di(n,e.input,{toolUse:e,toolUseBlock:e,signal:a.signal});r=t.content,i=t.isError}finally{clearTimeout(s),o()}let c=Yi(e,i,Xi(r)),l=await w(this,B,`m`,Li).call(this,c,e.id);w(this,B,`m`,Fi).call(this,{event:e,result:c,toolUseId:e.id,name:e.name,isError:i,posted:l,confirmation:t})}finally{C(this,wi,(r=w(this,wi,`f`),r--,r),`f`),w(this,wi,`f`)===0&&w(this,Ei,`f`)?.call(this)}}},Li=async function(e,t){let n=w(this,V,`f`),r=Date.now(),i,a=0;for(;;){a++,n.signal.throwIfAborted();try{return await this.client.beta.sessions.events.send(this.sessionId,{events:[e]},w(this,B,`m`,Di).call(this)),w(this,U,`f`).add(t),!0}catch(e){if(i=e,Pr(e))break;let o=w(this,Ti,`f`)-(Date.now()-r);if(o<=0)break;let s=Math.min(Lr(Fr(a-1,Ui,Wi)),o);w(this,H,`f`).warn(`tool result send failed; retrying`,{tool_use_id:t,attempt:a,backoff_ms:s,error:String(e)}),await Ie(s,n.signal)}}return w(this,H,`f`).error(`failed to send tool result`,{tool_use_id:t,attempts:a,error:String(i)}),!1},Ri=async function(){w(this,wi,`f`)!==0&&(await Promise.race([new Promise(e=>C(this,Ei,e,`f`)),Ie(Hi)]),C(this,Ei,null,`f`),w(this,wi,`f`)>0&&w(this,H,`f`).warn(`drain timeout exceeded`))},e})();function Yi(e,t,n){return e.type===`agent.custom_tool_use`?{type:`user.custom_tool_result`,custom_tool_use_id:e.id,is_error:t,content:n}:{type:`user.tool_result`,tool_use_id:e.id,is_error:t,content:n}}function Xi(e){if(typeof e==`string`)return[{type:`text`,text:e||`(no output)`}];let t=e.map(e=>e.type===`text`?{type:`text`,text:e.text||`(no output)`}:e.type===`image`||e.type===`document`?e:e.type===`search_result`?{type:`search_result`,source:e.source,title:e.title,content:e.content.map(e=>({type:`text`,text:e.text})),citations:{enabled:e.citations?.enabled??!1}}:{type:`text`,text:JSON.stringify(e)});return t.length>0?t:[{type:`text`,text:`(no output)`}]}var Zi,Qi,$i,ea,ta,na=3e4,ra=9e4,ia=`NO_HEARTBEAT`;function aa(e){return e.resources.some(e=>e.type===`memory_store`)}function oa(e){if(!e)return null;let t;try{let n=e.replace(/-/g,`+`).replace(/_/g,`/`),r=n.padEnd(Math.ceil(n.length/4)*4,`=`);t=JSON.parse(Bt(Vt(r)))}catch{return null}if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=t.sessions_token;return typeof n==`string`&&n!==``?n:null}var sa=(()=>{class e{constructor(e){if(Zi.add(this),Qi.set(this,void 0),e.unrestrictedPaths!==void 0)throw new y("The `unrestrictedPaths` option you passed to EnvironmentWorker (or client.beta.environments.work.worker()) is no longer supported. The worker's file tools (read, write, edit, glob, grep) are now always confined to `workdir` plus the session's memory folders. Remove `unrestrictedPaths` from your options; to let the file tools reach any other directory, add it to `AgentToolContext.allowedRoots` from a `tools` factory.");this.client=e.client,this.environmentId=e.environmentId,this.environmentKey=e.environmentKey,this.tools=e.tools,this.workdir=e.workdir??process.cwd(),this.maxFileBytes=e.maxFileBytes,this.maxIdleMs=e.maxIdleMs,e.memorySyncIntervalMs!=null&&Ee(e.memorySyncIntervalMs,`memorySyncIntervalMs`),this.memorySyncIntervalMs=e.memorySyncIntervalMs,this.memorySyncDeletions=e.memorySyncDeletions??`enabled`,this.workerId=e.workerId,this.requestOptions=e.requestOptions,C(this,Qi,e.signal,`f`)}async run(e){let{environmentId:t,environmentKey:n}=this;if(t===void 0||n===void 0)throw new y(`EnvironmentWorker.run: environmentId and environmentKey are required to poll for work`);let r=e??w(this,Qi,`f`),i=new ei({client:this.client,environmentId:t,environmentKey:n,...this.workerId===void 0?{}:{workerId:this.workerId},...r?{signal:r}:{},...this.requestOptions===void 0?{}:{requestOptions:this.requestOptions},autoStop:!1});for await(let e of i)try{await w(this,Zi,`m`,$i).call(this,e,n,i.signal)}catch(t){if(i.signal?.aborted)throw t;j(this.client).error(`work item failed`,{work_id:e.id,error:String(t)})}}async handleItem(e){let t=e?.workId??A(`ANTHROPIC_WORK_ID`),n=e?.environmentId??A(`ANTHROPIC_ENVIRONMENT_ID`),r=e?.sessionId??A(`ANTHROPIC_SESSION_ID`),i=(e?.environmentKey??this.environmentKey??A(`ANTHROPIC_ENVIRONMENT_KEY`))||void 0,a=e?.workSecret||A(`ANTHROPIC_WORK_SECRET`)||null;if(!t)throw new y(`handleItem: workId is required — pass it or set ANTHROPIC_WORK_ID`);if(!n)throw new y(`handleItem: environmentId is required — pass it or set ANTHROPIC_ENVIRONMENT_ID`);if(!r)throw new y(`handleItem: sessionId is required — pass it or set ANTHROPIC_SESSION_ID`);if(!i&&!a)throw new y(`handleItem: environmentKey is required when there is no work secret — pass it, construct the worker with it, or set ANTHROPIC_ENVIRONMENT_KEY`);let o={id:t,environment_id:n,secret:a,data:{type:`session`,id:r}};await w(this,Zi,`m`,$i).call(this,o,i,e?.signal??w(this,Qi,`f`))}}return Qi=new WeakMap,Zi=new WeakSet,$i=async function(e,t,n){let r=j(this.client),i=oa(e.secret),a=i??t;if(a===void 0)throw new y("handleItem: the work item carried a secret payload but no sessions token could be extracted, and there is no environment key to fall back to; the poller must issue a secret whose payload carries `sessions_token`, or provide the environment key (pass it, construct the worker with it, or set ANTHROPIC_ENVIRONMENT_KEY)");e.secret&&i===null&&r.warn(`work item carried a secret payload but no sessions token could be extracted; falling back to the environment key`,{work_id:e.id});let o=Rr(this.client,{authToken:a,helper:`environments-worker`}),s=e.data.id,c=new AbortController,l=jr(n,c),d=new ua(c),f=await u(()=>import(`./node.browser-D-KuY2NZ.js`),__vite__mapDeps([2,1])),p,m,h=fa(o,e,d,r,this.requestOptions,e=>{p=e,m?._setSendRetryWindow(e)}).catch(t=>{c.signal.aborted||r.error(`heartbeat loop failed`,{work_id:e.id,error:String(t)}),c.abort()}),g=async()=>{},_,v=!1;try{if(e.data.type!==`session`){r.debug(`skipping non-session work item`,{work_id:e.id,type:e.data.type});return}let t=await o.beta.sessions.retrieve(s);if(i===null&&this.memorySyncIntervalMs!==null&&aa(t))throw new f.SessionMemoryError(`cannot mount the session's memories: the work item carried no sessions token (work_id=${e.id}, session_id=${s}); the memory endpoints reject the environment key, so the poller must issue a per-item \`secret\` carrying \`sessions_token\`, or set \`memorySyncIntervalMs: null\` to run without memory`);let n={workdir:this.workdir,client:o,session:t,...this.maxFileBytes===void 0?{}:{maxFileBytes:this.maxFileBytes}};try{g=await f.setupSkills(n)}catch(t){r.warn(`skill setup failed`,{session_id:s,work_id:e.id,error:String(t)})}i!==null&&this.memorySyncIntervalMs!==null?(_=new f.SessionMemoryStores(o,{workdir:this.workdir,...this.memorySyncIntervalMs===void 0?{}:{syncIntervalMs:this.memorySyncIntervalMs},syncDeletions:this.memorySyncDeletions}),await _.download(t),n.allowedRoots=_.roots,n.readOnlyRoots=_.readOnlyRoots):r.debug(`memory stores disabled for this item`,{work_id:e.id}),m=new Ji(s,{client:o,tools:typeof this.tools==`function`?this.tools(n):this.tools??f.betaAgentToolset20260401(n),...this.maxIdleMs===void 0?{}:{maxIdleMs:this.maxIdleMs},...this.requestOptions===void 0?{}:{requestOptions:this.requestOptions},signal:c.signal}),p!==void 0&&m._setSendRetryWindow(p);for await(let e of m)_&&await _.syncIfDue();v=!c.signal.aborted}finally{try{await g().catch(t=>{r.warn(`skill cleanup failed`,{session_id:s,work_id:e.id,error:String(t)})})}finally{if(_){let t=f.MEMORY_FLUSH_TIMEOUT_MS;v&&await ca(_.finish(),t)&&r.warn(`final memory sync cut off after ${t}ms; the flush that follows still uploads changed files`,{session_id:s,work_id:e.id});let n=new AbortController;await ca(_.flushWrites(n.signal),t)&&(n.abort(),r.warn(`memory flush cut off after ${t}ms; changed files it had not uploaded yet are not saved`,{session_id:s,work_id:e.id})),await _.dispose().catch(t=>{r.warn(`memory store cleanup failed`,{session_id:s,work_id:e.id,error:String(t)})})}}d.finish(`runner_done`),l(),await h,d.lost?r.info(`lease lost; released without stopping it`,{session_id:s,work_id:e.id}):await la(o,e,r,this.requestOptions)}},e})();async function ca(e,t){let n;try{return await Promise.race([e.then(()=>!1,()=>!1),new Promise(e=>{n=setTimeout(()=>e(!0),t)})])}finally{n!==void 0&&clearTimeout(n)}}async function la(e,t,n,r){try{await e.beta.environments.work.stop(t.id,{environment_id:t.environment_id,force:!0},{...r,headers:I([r?.headers])})}catch(e){Mr(e,409)||n.error(`force-stop on exit failed`,{work_id:t.id,error:String(e)})}}var ua=(()=>{class e{constructor(e){ea.set(this,void 0),ta.set(this,void 0),C(this,ea,e,`f`)}get signal(){return w(this,ea,`f`).signal}finish(e){C(this,ta,w(this,ta,`f`)??e,`f`),w(this,ea,`f`).abort()}get lost(){return w(this,ta,`f`)===`lease_lost`||w(this,ta,`f`)===`assumed_lost`}}return ea=new WeakMap,ta=new WeakMap,e})();function da(e){let t=e instanceof le?e.error:void 0;for(let e of[`error`,`details`,`current_state`]){if(!Ne(t))return{};t=t[e]}return Ne(t)?t:{}}async function fa(e,t,n,r,i,a){let o=na,s=ra,c=Date.now(),l=ia,u=async()=>{let u=new AbortController,d=jr(n.signal,u),f=setTimeout(()=>u.abort(),o);try{let d=await e.beta.environments.work.heartbeat(t.id,{environment_id:t.environment_id,expected_last_heartbeat:l},{...i,headers:I([i?.headers]),signal:u.signal});c=Date.now(),l=d.last_heartbeat,d.ttl_seconds>0&&(s=d.ttl_seconds*1e3,o=Math.max(1e3,Math.min(s/2,na)),a?.(s)),(d.state===`stopping`||d.state===`stopped`)&&(r.info(`heartbeat signals shutdown`,{work_id:t.id,state:d.state}),n.finish(`control_plane_stop`)),d.lease_extended||(r.warn(`lease not extended, shutting down`,{work_id:t.id}),n.finish(`control_plane_stop`))}catch(e){if(n.signal.throwIfAborted(),Mr(e,412)){let i=da(e);r.error(`lease lost: heartbeat precondition failed`,{work_id:t.id,server_state:i.state,server_ttl_seconds:i.ttl_seconds,server_last_heartbeat:i.last_heartbeat}),n.finish(`lease_lost`);return}if(Pr(e))throw r.error(`permanent heartbeat failure`,{work_id:t.id,error:String(e)}),n.finish(`heartbeat_rejected`),e;if(Date.now()-c>s){r.error(`lease assumed lost: no successful heartbeat in ttl`,{work_id:t.id,ttl_ms:s,error:String(e)}),n.finish(`assumed_lost`);return}r.warn(`transient heartbeat failure`,{work_id:t.id,error:String(e)})}finally{clearTimeout(f),d()}};for(await u();!n.signal.aborted;)await Ie(o,n.signal),n.signal.throwIfAborted(),await u()}var pa=(()=>{class e extends F{retrieve(e,t,n){let{environment_id:r,betas:i,workspace_id:a}=t;return this._client.get(L`/v1/environments/${r}/work/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}update(e,t,n){let{environment_id:r,betas:i,workspace_id:a,...o}=t;return this._client.post(L`/v1/environments/${r}/work/${e}?beta=true`,{body:o,...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}list(e,t={},n){let{betas:r,...i}=t??{};return this._client.getAPIList(L`/v1/environments/${e}/work?beta=true`,P,{query:i,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString()},n?.headers])})}ack(e,t,n){let{environment_id:r,betas:i}=t;return this._client.post(L`/v1/environments/${r}/work/${e}/ack?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString()},n?.headers])})}heartbeat(e,t,n){let{environment_id:r,desired_ttl_seconds:i,expected_last_heartbeat:a,betas:o}=t;return this._client.post(L`/v1/environments/${r}/work/${e}/heartbeat?beta=true`,{query:{desired_ttl_seconds:i,expected_last_heartbeat:a},...n,headers:I([{"anthropic-beta":[...o??[],`managed-agents-2026-04-01`].toString()},n?.headers])})}poll(e,t={},n){let{betas:r,"Anthropic-Worker-ID":i,...a}=t??{};return this._client.get(L`/v1/environments/${e}/work/poll?beta=true`,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"Anthropic-Worker-ID":i}},n?.headers])})}stats(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/environments/${e}/work/stats?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}stop(e,t,n){let{environment_id:r,betas:i,workspace_id:a,...o}=t;return this._client.post(L`/v1/environments/${r}/work/${e}/stop?beta=true`,{body:o,...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}poller(e){return new ei({...e,client:this._client})}worker(e){return new sa({...e,client:this._client})}}return e.WorkPoller=ei,e.EnvironmentWorker=sa,e})(),ma=(()=>{class e extends F{constructor(){super(...arguments),this.work=new pa(this._client)}create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/environments?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/environments/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}update(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/environments/${e}?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/environments?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}delete(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.delete(L`/v1/environments/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}archive(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/environments/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}}return e.Work=pa,e})(),ha=class extends F{create(e,t,n){let{view:r,betas:i,workspace_id:a,...o}=t;return this._client.post(L`/v1/memory_stores/${e}/memories?beta=true`,{query:{view:r},body:o,...n,headers:I([{"anthropic-beta":[...i??[],`agent-memory-2026-07-22`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}retrieve(e,t,n){let{memory_store_id:r,betas:i,workspace_id:a,...o}=t;return this._client.get(L`/v1/memory_stores/${r}/memories/${e}?beta=true`,{query:o,...n,headers:I([{"anthropic-beta":[...i??[],`agent-memory-2026-07-22`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}update(e,t,n){let{memory_store_id:r,view:i,betas:a,workspace_id:o,...s}=t;return this._client.post(L`/v1/memory_stores/${r}/memories/${e}?beta=true`,{query:{view:i},body:s,...n,headers:I([{"anthropic-beta":[...a??[],`agent-memory-2026-07-22`].toString(),...o==null?void 0:{"anthropic-workspace-id":o}},n?.headers])})}list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/memory_stores/${e}/memories?beta=true`,P,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`agent-memory-2026-07-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}delete(e,t,n){let{memory_store_id:r,expected_content_sha256:i,betas:a,workspace_id:o}=t;return this._client.delete(L`/v1/memory_stores/${r}/memories/${e}?beta=true`,{query:{expected_content_sha256:i},...n,headers:I([{"anthropic-beta":[...a??[],`agent-memory-2026-07-22`].toString(),...o==null?void 0:{"anthropic-workspace-id":o}},n?.headers])})}},ga=class extends F{retrieve(e,t,n){let{memory_store_id:r,betas:i,workspace_id:a,...o}=t;return this._client.get(L`/v1/memory_stores/${r}/memory_versions/${e}?beta=true`,{query:o,...n,headers:I([{"anthropic-beta":[...i??[],`agent-memory-2026-07-22`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/memory_stores/${e}/memory_versions?beta=true`,P,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`agent-memory-2026-07-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}redact(e,t,n){let{memory_store_id:r,betas:i,workspace_id:a}=t;return this._client.post(L`/v1/memory_stores/${r}/memory_versions/${e}/redact?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`agent-memory-2026-07-22`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}},_a=(()=>{class e extends F{constructor(){super(...arguments),this.memories=new ha(this._client),this.memoryVersions=new ga(this._client)}create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/memory_stores?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`agent-memory-2026-07-22`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/memory_stores/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`agent-memory-2026-07-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}update(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/memory_stores/${e}?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`agent-memory-2026-07-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/memory_stores?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`agent-memory-2026-07-22`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}delete(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.delete(L`/v1/memory_stores/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`agent-memory-2026-07-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}archive(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/memory_stores/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`agent-memory-2026-07-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}}return e.Memories=ha,e.MemoryVersions=ga,e})(),va=(()=>{class e{constructor(e,t){this.iterator=e,this.controller=t}async*decoder(){let e=new yn;for await(let t of this.iterator)for(let n of e.decode(t))yield JSON.parse(n);for(let t of e.flush())yield JSON.parse(t)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(t,n){if(!t.body)throw n.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new y(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new y(`Attempted to iterate over a response with no body`);return new e(tt(t.body),n)}}return e})(),ya=class extends F{create(e,t){let{betas:n,user_profile_id:r,workspace_id:i,...a}=e;return this._client.post(`/v1/messages/batches?beta=true`,{body:a,...t,headers:I([{"anthropic-beta":[...n??[],`message-batches-2024-09-24`].toString(),...r==null?void 0:{"anthropic-user-profile-id":r},...i==null?void 0:{"anthropic-workspace-id":i}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/messages/batches/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`message-batches-2024-09-24`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/messages/batches?beta=true`,Bn,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`message-batches-2024-09-24`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}delete(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.delete(L`/v1/messages/batches/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`message-batches-2024-09-24`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}cancel(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/messages/batches/${e}/cancel?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`message-batches-2024-09-24`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}async results(e,t={},n){let r=await this.retrieve(e,t,n);if(!r.results_url)throw new y(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`);let{betas:i,workspace_id:a}=t??{};return this._client.get(r.results_url,{...n,headers:I([{"anthropic-beta":[...i??[],`message-batches-2024-09-24`].toString(),Accept:`application/binary`,...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>va.fromResponse(t.response,t.controller))}},ba={"claude-opus-4@20250514":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192};function xa(e){return e?.output_format??e?.output_config?.format}function Sa(e,t,n){let r=xa(t);return!t||!(`parse`in(r??{}))?{...e,content:e.content.map(e=>{if(e.type===`text`){let t=Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(t,"parsed",{get(){return n.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null},enumerable:!1})}return e}),parsed_output:null}:Ca(e,t,n)}function Ca(e,t,n){let r=null,i=e.content.map(e=>{if(e.type===`text`){let i=wa(t,e.text);r===null&&(r=i);let a=Object.defineProperty({...e},"parsed_output",{value:i,enumerable:!1});return Object.defineProperty(a,"parsed",{get(){return n.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),i},enumerable:!1})}return e});return{...e,content:i,parsed_output:r}}function wa(e,t){let n=xa(e);if(n?.type!==`json_schema`)return null;try{return`parse`in n?n.parse(t):JSON.parse(t)}catch(e){throw new y(`Failed to parse structured output: ${e}`)}}var Ta=e=>{let t=0,n=[];for(;t<e.length;){let r=e[t];if(r===`\\`){t++;continue}if(r===`{`){n.push({type:`brace`,value:`{`}),t++;continue}if(r===`}`){n.push({type:`brace`,value:`}`}),t++;continue}if(r===`[`){n.push({type:`paren`,value:`[`}),t++;continue}if(r===`]`){n.push({type:`paren`,value:`]`}),t++;continue}if(r===`:`){n.push({type:`separator`,value:`:`}),t++;continue}if(r===`,`){n.push({type:`delimiter`,value:`,`}),t++;continue}if(r===`"`){let r=t+1,i=r,a=!1;for(;;){if(i=e.indexOf(`"`,i),i===-1){a=!0;break}let t=0,n=i-1;for(;n>=r&&e[n]===`\\`;)t++,n--;if(t%2==0)break;i++}a?t=e.length:(n.push({type:`string`,value:e.slice(r,i)}),t=i+1);continue}if(r&&/\s/.test(r)){t++;continue}let i=/[0-9]/;if(r&&i.test(r)||r===`-`||r===`.`){let a=``;for(r===`-`&&(a+=r,r=e[++t]);r&&(i.test(r)||r===`.`||r===`e`||r===`E`||(r===`-`||r===`+`)&&(a[a.length-1]===`e`||a[a.length-1]===`E`));)a+=r,r=e[++t];n.push({type:`number`,value:a,unterminated:t===e.length});continue}let a=/[a-z]/i;if(r&&a.test(r)){let i=``;for(;r&&a.test(r)&&t!==e.length;)i+=r,r=e[++t];if(i==`true`||i==`false`||i===`null`)n.push({type:`name`,value:i});else{t++;continue}continue}t++}return n},Ea=e=>{let t=[];for(let n of e)(n.type===`brace`||n.type===`paren`)&&(n.value===`{`||n.value===`[`?t.push(n.value):t.pop());let n=t[t.length-1],r=e.length,i=/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][-+]?[0-9]+)?$/;for(;r>0;){let t=e[r-1];switch(t.type){case`separator`:r--;continue;case`number`:if(t.unterminated||!i.test(t.value)){r--;continue}break;case`string`:let a=e[r-2];if(n===`{`&&(a?.type===`delimiter`||a?.type===`brace`&&a.value===`{`)){r--;continue}break;case`delimiter`:r--}break}return e.slice(0,r)},Da=e=>{let t=[];return e.map(e=>{e.type===`brace`&&(e.value===`{`?t.push(`}`):t.splice(t.lastIndexOf(`}`),1)),e.type===`paren`&&(e.value===`[`?t.push(`]`):t.splice(t.lastIndexOf(`]`),1))}),t.length>0&&t.reverse().map(t=>{t===`}`?e.push({type:`brace`,value:`}`}):t===`]`&&e.push({type:`paren`,value:`]`})}),e},Oa=e=>{let t=``;return e.map(e=>{switch(e.type){case`string`:t+=`"`+e.value+`"`;break;default:t+=e.value}}),t},ka=e=>JSON.parse(Oa(Da(Ea(Ta(e))))),Aa=`__json_buf`;function ja(e,t){let n={};for(let t of Object.keys(e))t!==`input`&&(n[t]=e[t]);Object.defineProperty(n,Aa,{value:t,enumerable:!1,writable:!0});let r,i=!1;return Object.defineProperty(n,"input",{enumerable:!0,configurable:!0,get(){return i||=(r=t?ka(t):{},!0),r}}),n}var G,Ma,Na,Pa,Fa,Ia,La,Ra,za,K,Ba,Va,Ha,Ua,Wa,Ga,Ka,qa,Ja,Ya,Xa,Za,Qa,$a,eo,to;function no(e){return e.type===`tool_use`||e.type===`server_tool_use`||e.type===`mcp_tool_use`}var ro=(()=>{class e{constructor(e,t){G.add(this),this.messages=[],this.receivedMessages=[],Ma.set(this,void 0),Na.set(this,null),this.controller=new AbortController,Pa.set(this,void 0),Fa.set(this,()=>{}),Ia.set(this,()=>{}),La.set(this,void 0),Ra.set(this,()=>{}),za.set(this,()=>{}),K.set(this,{}),Ba.set(this,!1),Va.set(this,!1),Ha.set(this,!1),Ua.set(this,!1),Wa.set(this,void 0),Ga.set(this,void 0),Ka.set(this,void 0),qa.set(this,void 0),Xa.set(this,e=>{if(C(this,Va,!0,`f`),b(e)&&(e=new x),e instanceof x)return C(this,Ha,!0,`f`),this._emit(`abort`,e);if(e instanceof y)return this._emit(`error`,e);if(e instanceof Error){let t=new y(e.message);return t.cause=e,this._emit(`error`,t)}return this._emit(`error`,new y(String(e)))}),C(this,Pa,new Promise((e,t)=>{C(this,Fa,e,`f`),C(this,Ia,t,`f`)}),`f`),C(this,La,new Promise((e,t)=>{C(this,Ra,e,`f`),C(this,za,t,`f`)}),`f`),w(this,Pa,`f`).catch(()=>{}),w(this,La,`f`).catch(()=>{}),C(this,Na,e,`f`),C(this,qa,t?.logger??console,`f`)}get response(){return w(this,Wa,`f`)}get request_id(){return w(this,Ga,`f`)}get workspace_id(){return w(this,Ka,`f`)}async withResponse(){C(this,Ua,!0,`f`);let e=await w(this,Pa,`f`);if(!e)throw Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get(`request-id`),workspace_id:e.headers.get(`anthropic-workspace-id`)}}static fromReadableStream(t){let n=new e(null);return n._run(()=>n._fromReadableStream(t)),n}static createMessage(t,n,r,{logger:i}={}){let a=new e(n,{logger:i});for(let e of n.messages)a._addMessageParam(e);return C(a,Na,{...n,stream:!0},`f`),a._run(()=>a._createMessage(t,{...n,stream:!0},{...r,headers:{...r?.headers,[mr]:`stream`}})),a}_run(e){e().then(()=>{this._emitFinal(),this._emit(`end`)},w(this,Xa,`f`))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit(`message`,e)}async _createMessage(e,t,n){let r=n?.signal,i;r&&(r.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),r.addEventListener(`abort`,i));try{w(this,G,`m`,Za).call(this);let{response:r,data:i}=await e.create({...t,stream:!0},{...n,signal:this.controller.signal}).withResponse();this._connected(r);for await(let e of i)w(this,G,`m`,Qa).call(this,e);if(i.controller.signal?.aborted)throw new x;w(this,G,`m`,$a).call(this)}finally{r&&i&&r.removeEventListener(`abort`,i)}}_connected(e){this.ended||(C(this,Wa,e,`f`),C(this,Ga,e?.headers.get(`request-id`),`f`),C(this,Ka,e?.headers.get(`anthropic-workspace-id`),`f`),w(this,Fa,`f`).call(this,e),this._emit(`connect`))}get ended(){return w(this,Ba,`f`)}get errored(){return w(this,Va,`f`)}get aborted(){return w(this,Ha,`f`)}abort(){this.controller.abort()}on(e,t){return(w(this,K,`f`)[e]||(w(this,K,`f`)[e]=[])).push({listener:t}),this}off(e,t){let n=w(this,K,`f`)[e];if(!n)return this;let r=n.findIndex(e=>e.listener===t);return r>=0&&n.splice(r,1),this}once(e,t){return(w(this,K,`f`)[e]||(w(this,K,`f`)[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{C(this,Ua,!0,`f`),e!==`error`&&this.once(`error`,n),this.once(e,t)})}async done(){C(this,Ua,!0,`f`),await w(this,La,`f`)}get currentMessage(){return w(this,Ma,`f`)}async finalMessage(){return await this.done(),w(this,G,`m`,Ja).call(this)}async finalText(){return await this.done(),w(this,G,`m`,Ya).call(this)}_emit(e,...t){if(w(this,Ba,`f`))return;e===`end`&&(C(this,Ba,!0,`f`),w(this,Ra,`f`).call(this));let n=w(this,K,`f`)[e];if(n&&(w(this,K,`f`)[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),e===`abort`){let e=t[0];!w(this,Ua,`f`)&&!n?.length&&Promise.reject(e),w(this,Ia,`f`).call(this,e),w(this,za,`f`).call(this,e),this._emit(`end`);return}if(e===`error`){let e=t[0];!w(this,Ua,`f`)&&!n?.length&&Promise.reject(e),w(this,Ia,`f`).call(this,e),w(this,za,`f`).call(this,e),this._emit(`end`)}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit(`finalMessage`,w(this,G,`m`,Ja).call(this))}async _fromReadableStream(e,t){let n=t?.signal,r;n&&(n.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),n.addEventListener(`abort`,r));try{w(this,G,`m`,Za).call(this),this._connected(null);let t=Sn.fromReadableStream(e,this.controller);for await(let e of t)w(this,G,`m`,Qa).call(this,e);if(t.controller.signal?.aborted)throw new x;w(this,G,`m`,$a).call(this)}finally{n&&r&&n.removeEventListener(`abort`,r)}}[(Ma=new WeakMap,Na=new WeakMap,Pa=new WeakMap,Fa=new WeakMap,Ia=new WeakMap,La=new WeakMap,Ra=new WeakMap,za=new WeakMap,K=new WeakMap,Ba=new WeakMap,Va=new WeakMap,Ha=new WeakMap,Ua=new WeakMap,Wa=new WeakMap,Ga=new WeakMap,Ka=new WeakMap,qa=new WeakMap,Xa=new WeakMap,G=new WeakSet,Ja=function(){if(this.receivedMessages.length===0)throw new y(`stream ended without producing a Message with role=assistant`);return this.receivedMessages.at(-1)},Ya=function(){if(this.receivedMessages.length===0)throw new y(`stream ended without producing a Message with role=assistant`);let e=this.receivedMessages.at(-1).content.filter(e=>e.type===`text`).map(e=>e.text);if(e.length===0)throw new y(`stream ended without producing a content block with type=text`);return e.join(` `)},Za=function(){this.ended||C(this,Ma,void 0,`f`)},Qa=function(e){if(this.ended)return;let t=w(this,G,`m`,eo).call(this,e);switch(this._emit(`streamEvent`,e,t),e.type){case`content_block_delta`:{let n=t.content.at(-1);switch(e.delta.type){case`text_delta`:n.type===`text`&&this._emit(`text`,e.delta.text,n.text||``);break;case`citations_delta`:n.type===`text`&&this._emit(`citation`,e.delta.citation,n.citations??[]);break;case`input_json_delta`:if(no(n)&&w(this,K,`f`).inputJson?.length){let t;try{t=n.input}catch(e){w(this,Xa,`f`).call(this,w(this,G,`m`,to).call(this,n,e));break}this._emit(`inputJson`,e.delta.partial_json,t)}break;case`thinking_delta`:n.type===`thinking`&&this._emit(`thinking`,e.delta.thinking,n.thinking);break;case`signature_delta`:n.type===`thinking`&&this._emit(`signature`,n.signature);break;case`compaction_delta`:n.type===`compaction`&&n.content&&this._emit(`compaction`,n.content);break;default:e.delta}break}case`message_stop`:this._addMessageParam(t),this._addMessage(Sa(t,w(this,Na,`f`),{logger:w(this,qa,`f`)}),!0);break;case`content_block_stop`:this._emit(`contentBlock`,t.content.at(-1));break;case`message_start`:C(this,Ma,t,`f`)}},$a=function(){if(this.ended)throw new y(`stream has ended, this shouldn't happen`);let e=w(this,Ma,`f`);if(!e)throw new y(`request ended without sending any chunks`);return C(this,Ma,void 0,`f`),Sa(e,w(this,Na,`f`),{logger:w(this,qa,`f`)})},eo=function(e){let t=w(this,Ma,`f`);if(e.type===`message_start`){if(t)throw new y(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(!t)throw new y(`Unexpected event order, got ${e.type} before "message_start"`);switch(e.type){case`message_stop`:return t;case`message_delta`:return t.stop_reason=e.delta.stop_reason,t.stop_sequence=e.delta.stop_sequence,t.stop_details=e.delta.stop_details,t.usage.output_tokens=e.usage.output_tokens,e.delta.container!=null&&(t.container=e.delta.container),e.context_management!=null&&(t.context_management=e.context_management),e.input_transformations!=null&&(t.input_transformations=e.input_transformations),e.usage.input_tokens!=null&&(t.usage.input_tokens=e.usage.input_tokens),e.usage.cache_creation_input_tokens!=null&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),e.usage.cache_read_input_tokens!=null&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),e.usage.server_tool_use!=null&&(t.usage.server_tool_use=e.usage.server_tool_use),e.usage.iterations!=null&&(t.usage.iterations=e.usage.iterations),e.usage.fallback_credit!=null&&(t.usage.fallback_credit=e.usage.fallback_credit),e.usage.output_tokens_details!=null&&(t.usage.output_tokens_details=e.usage.output_tokens_details),t;case`content_block_start`:return t.content.push(e.content_block),e.content_block.type===`fallback`&&(t.model=e.content_block.to.model),t;case`content_block_delta`:{let n=t.content.at(e.index);switch(e.delta.type){case`text_delta`:n?.type===`text`&&(t.content[e.index]={...n,text:(n.text||``)+e.delta.text});break;case`citations_delta`:n?.type===`text`&&(t.content[e.index]={...n,citations:[...n.citations??[],e.delta.citation]});break;case`input_json_delta`:if(n&&no(n)){let r=(n.__json_buf||``)+e.delta.partial_json;t.content[e.index]=ja(n,r)}break;case`thinking_delta`:n?.type===`thinking`&&(t.content[e.index]={...n,thinking:n.thinking+e.delta.thinking});break;case`signature_delta`:n?.type===`thinking`&&(t.content[e.index]={...n,signature:e.delta.signature});break;case`compaction_delta`:if(n?.type===`compaction`){let r={...n,content:e.delta.content};`encrypted_content`in e.delta&&(r.encrypted_content=e.delta.encrypted_content),t.content[e.index]=r}break;default:e.delta}return t}case`content_block_stop`:{let n=t.content.at(e.index);if(n&&no(n)&&`__json_buf`in n){let e;try{e=n.input}catch(t){e={},w(this,Xa,`f`).call(this,w(this,G,`m`,to).call(this,n,t))}Object.defineProperty(n,"input",{value:e,enumerable:!0,configurable:!0,writable:!0})}return t}}},to=function(e,t){let n=e[Aa];return new y(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${t}. JSON: ${n}`)},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`streamEvent`,n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on(`end`,()=>{n=!0;for(let e of t)e.resolve(void 0);t.length=0}),this.on(`abort`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),this.on(`error`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Sn(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}return e})(),io,ao,oo,so,co,lo,uo,fo,po,mo,ho,go=(()=>{class e extends ro{constructor(e,t){super(e),io.add(this),ao.set(this,void 0),oo.set(this,0),so.set(this,[]),co.set(this,[]),lo.set(this,void 0),uo.set(this,[]),fo.set(this,!1),C(this,ao,t,`f`)}get toolCalls(){return w(this,co,`f`)}static start(t,n,r,i){let a=new e({...n,stream:!0},i);for(let e of n.messages)a._addMessageParam(e);return a._run(()=>a._createMessage(t,{...n,stream:!0},{...r,headers:{...r?.headers,[mr]:`stream`}})),a}_emit(e,...t){var n;if(e!==`streamEvent`||this.ended){super._emit(e,...t);return}C(this,oo,(n=w(this,oo,`f`),n++,n),`f`);let[r,i]=t,a=r.type===`content_block_stop`?i.content[r.index]:void 0,o=a?.type===`tool_use`?a:void 0;o&&w(this,co,`f`).push(o),super._emit(e,...t),w(this,io,`m`,po).call(this,r,o),w(this,io,`m`,mo).call(this)}[(ao=new WeakMap,oo=new WeakMap,so=new WeakMap,co=new WeakMap,lo=new WeakMap,uo=new WeakMap,fo=new WeakMap,io=new WeakSet,Symbol.asyncIterator)](){let e=super[Symbol.asyncIterator](),t={handled:w(this,oo,`f`)};w(this,so,`f`).push(t);let n=!1;return{next:async()=>{n&&(n=!1,t.handled++,w(this,io,`m`,mo).call(this));try{let r=await e.next();return n=!r.done,r.done&&w(this,io,`m`,ho).call(this,t),r}catch(e){throw w(this,io,`m`,ho).call(this,t),e}},return:async()=>{let n=e.return?.();return w(this,io,`m`,ho).call(this,t),await n??{value:void 0,done:!0}}}}}return po=function(e,t){if(w(this,fo,`f`))return;if(e.type===`content_block_start`&&e.content_block.type===`fallback`){C(this,fo,!0,`f`),C(this,lo,void 0,`f`);return}let n=e.type===`content_block_start`||e.type===`message_delta`&&e.delta.stop_reason===`tool_use`;w(this,lo,`f`)&&n&&(w(this,uo,`f`).push({toolUse:w(this,lo,`f`),event:w(this,oo,`f`)}),C(this,lo,void 0,`f`)),t&&C(this,lo,t,`f`)},mo=function(){if(this.errored||this.controller.signal.aborted)return;let e=Math.min(w(this,oo,`f`),...w(this,so,`f`).map(e=>e.handled));for(;w(this,uo,`f`)[0]&&w(this,uo,`f`)[0].event<=e;)w(this,ao,`f`).call(this,w(this,uo,`f`).shift().toolUse)},ho=function(e){let t=w(this,so,`f`).indexOf(e);t>=0&&(w(this,so,`f`).splice(t,1),w(this,io,`m`,mo).call(this))},e})();function _o(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}var q,vo,yo,J,Y,X,bo,xo,So,Co,Z,Q,wo,To,Eo,Do,Oo,ko,Ao,jo,Mo,No,Po,Fo,Io,Lo,Ro=(()=>{class e{constructor(e,t,n){q.add(this),this.client=e,vo.set(this,!1),yo.set(this,!1),J.set(this,void 0),Y.set(this,void 0),X.set(this,void 0),bo.set(this,void 0),xo.set(this,void 0),So.set(this,void 0),Co.set(this,0),Z.set(this,{status:`idle`}),Q.set(this,void 0),wo.set(this,null),To.set(this,new Map),Eo.set(this,[]),zo(t),Bo(t),Vo(t),C(this,J,{params:{...t,messages:JSON.parse(JSON.stringify(t.messages))}},`f`);let r=vr(t.tools,t.messages);C(this,Y,{...n,headers:I([hr(`BetaToolRunner`),r.length?{[pr]:r.join(`, `)}:void 0,n?.headers])},`f`),C(this,So,_o(),`f`)}async*[(vo=new WeakMap,yo=new WeakMap,J=new WeakMap,Y=new WeakMap,X=new WeakMap,bo=new WeakMap,xo=new WeakMap,So=new WeakMap,Co=new WeakMap,Z=new WeakMap,Q=new WeakMap,wo=new WeakMap,To=new WeakMap,Eo=new WeakMap,q=new WeakSet,Symbol.asyncIterator)](){var e;if(w(this,vo,`f`))throw new y(`Cannot iterate over a consumed stream`);C(this,vo,!0,`f`),C(this,yo,!0,`f`),C(this,xo,void 0,`f`);try{for(;;)try{if(w(this,J,`f`).params.max_iterations&&w(this,Co,`f`)>=w(this,J,`f`).params.max_iterations)break;if(w(this,q,`m`,Io).call(this),w(this,Z,`f`).status===`scheduled`&&Zo(w(this,wo,`f`))!==`resume`){yield*w(this,q,`m`,Ao).call(this,w(this,Z,`f`).config);continue}C(this,yo,!1,`f`),C(this,xo,void 0,`f`),C(this,Co,(e=w(this,Co,`f`),e++,e),`f`),C(this,X,void 0,`f`);let{max_iterations:t,runToolsEagerly:n,...r}=w(this,J,`f`).params;if(yield*w(this,q,`m`,Do).call(this,r),w(this,yo,`f`))C(this,wo,null,`f`);else{let e=await w(this,X,`f`),t=Zo(e.stop_reason);C(this,wo,e.stop_reason,`f`),w(this,J,`f`).params.messages.push({role:e.role,content:Ko(e.content)});let{container:n}=w(this,J,`f`).params;if(e.container&&(n==null?w(this,J,`f`).params.container=e.container.id:typeof n==`object`&&n.id==null&&(w(this,J,`f`).params.container={...n,id:e.container.id})),t===`stop`){yield*w(this,q,`m`,Po).call(this);break}if(t===`resume`)continue}let i=await w(this,q,`m`,Fo).call(this,w(this,J,`f`).params.messages.at(-1));if(i)w(this,J,`f`).params.messages.push(i);else if(!w(this,yo,`f`)){yield*w(this,q,`m`,Po).call(this);break}}finally{w(this,bo,`f`)?.abort(),C(this,bo,void 0,`f`)}if(await w(this,q,`m`,ko).call(this),!w(this,X,`f`))throw new y(`ToolRunner concluded without a message from the server`);w(this,So,`f`).resolve(await w(this,X,`f`))}catch(e){throw C(this,vo,!1,`f`),w(this,So,`f`).promise.catch(()=>{}),w(this,So,`f`).reject(e),C(this,So,_o(),`f`),e}}setMessagesParams(e){let t=typeof e==`function`?e(w(this,J,`f`).params):e;if(zo(t),Vo(t),w(this,Z,`f`).status!==`idle`&&Ho(t),w(this,Z,`f`).status===`in_flight`&&t.messages!==w(this,J,`f`).params.messages)throw new y(`Message params can't be changed while the conversation is being compacted, because the compaction response is about to replace them. Change them after this iteration instead.`);w(this,J,`f`).params=t,C(this,yo,!0,`f`),C(this,xo,void 0,`f`)}setRequestOptions(e){typeof e==`function`?C(this,Y,e(w(this,Y,`f`)),`f`):C(this,Y,{...w(this,Y,`f`),...e},`f`)}async generateToolResponse(e=w(this,Y,`f`).signal){let t=await w(this,X,`f`)??this.params.messages.at(-1);return t?w(this,q,`m`,Fo).call(this,t,e):null}deferToolCall(e){let t=typeof e==`string`?e:e.id;w(this,Q,`f`)&&!w(this,Q,`f`).has(t)&&w(this,Q,`f`).set(t,{status:`held`})}get deferredToolCalls(){let e=w(this,bo,`f`),t=w(this,Q,`f`);return!(e instanceof go)||!t?[]:e.toolCalls.filter(e=>t.get(e.id)?.status===`held`)}done(){return w(this,So,`f`).promise}async runUntilDone(){if(!w(this,vo,`f`))for await(let e of this);return this.done()}get params(){return w(this,J,`f`).params}pushMessages(...e){this.setMessagesParams(t=>({...t,messages:[...t.messages,...e]}))}compactBeforeNextTurn(e){w(this,Z,`f`).status!==`in_flight`&&(Ho(w(this,J,`f`).params),C(this,Z,{status:`scheduled`,config:e??{type:`summarize`}},`f`))}addTools(...e){for(let t of e)`name`in t&&w(this,To,`f`).set(t.name,`run`in t?t:null),w(this,Eo,`f`).push({type:`addition`,tool:t})}removeTools(...e){for(let t of e){let e=typeof t==`string`?t:t.name;w(this,To,`f`).set(e,null),w(this,Eo,`f`).push({type:`removal`,name:e})}}then(e,t){return this.runUntilDone().then(e,t)}}return Do=async function*(e){await w(this,q,`m`,ko).call(this),C(this,Q,void 0,`f`),e.stream?(C(this,bo,w(this,J,`f`).params.runToolsEagerly?w(this,q,`m`,Oo).call(this,e):this.client.beta.messages.stream({...e},w(this,Y,`f`)),`f`),C(this,X,w(this,bo,`f`).finalMessage(),`f`),w(this,X,`f`).catch(()=>{}),yield w(this,bo,`f`)):(C(this,X,this.client.beta.messages.create({...e,stream:!1},w(this,Y,`f`)),`f`),yield w(this,X,`f`))},Oo=function(e){let t=new Map;return C(this,Q,t,`f`),go.start(this.client.beta.messages,e,w(this,Y,`f`),e=>{if(t.has(e.id))return;let n=Go(w(this,q,`m`,jo).call(this),w(this,q,`m`,Mo).call(this),e,w(this,Y,`f`));n.catch(()=>{}),t.set(e.id,{status:`started`,result:n})})},ko=async function(){let e=[...w(this,Q,`f`)?.values()??[]].filter(e=>e.status===`started`);await Promise.allSettled(e.map(e=>e.result))},Ao=async function*(e){Ho(w(this,J,`f`).params);let{max_iterations:t,runToolsEagerly:n,...r}=w(this,J,`f`).params,i=Uo(r);C(this,Z,{status:`in_flight`},`f`),C(this,xo,void 0,`f`);let a=w(this,X,`f`);try{yield*w(this,q,`m`,Do).call(this,{...i,compaction:e});let t=await w(this,X,`f`);t.content.some(e=>e.type===`compaction`&&e.content)?(w(this,q,`m`,No).call(this),w(this,J,`f`).params.messages=[{role:t.role,content:t.content}]):(j(this.client).warn(`Compaction produced no summary; keeping the conversation as it is.`),C(this,X,a,`f`))}finally{C(this,Z,{status:`idle`},`f`)}},jo=function(){let e=new Map;for(let t of w(this,J,`f`).params.tools)`run`in t&&e.set(t.name,t);for(let[t,n]of w(this,To,`f`))n?e.set(t,n):e.delete(t);return e},Mo=function(){let e=new Set(w(this,q,`m`,jo).call(this).keys());for(let t of[...w(this,J,`f`).params.messages,w(this,q,`m`,Lo).call(this)])if(typeof t.content!=`string`){for(let n of t.content)if(t.role===`system`)Jo(n,e);else if(t.role===`assistant`&&n.type===`compaction`)for(let t of n.tool_changes??[])Jo(t,e)}return e},No=function(){let e=w(this,q,`m`,Mo).call(this);for(let t of w(this,q,`m`,jo).call(this).keys())e.has(t)||w(this,To,`f`).set(t,null)},Po=async function*(){if(w(this,Z,`f`).status!==`scheduled`)return;let e=w(this,J,`f`).params.messages.at(-1)?.content;if(Array.isArray(e)&&e.some(e=>e.type===`tool_use`)){j(this.client).warn("The pending compaction was skipped because the last turn ended with tool calls that were not run. Call `compactBeforeNextTurn()` again if you continue the conversation."),C(this,Z,{status:`idle`},`f`);return}yield*w(this,q,`m`,Ao).call(this,w(this,Z,`f`).config)},Fo=async function(e,t=w(this,Y,`f`).signal){return w(this,xo,`f`)===void 0&&C(this,xo,Wo(w(this,q,`m`,jo).call(this),w(this,q,`m`,Mo).call(this),e,{...w(this,Y,`f`),signal:t},w(this,Q,`f`)),`f`),w(this,xo,`f`)},Io=function(){w(this,wo,`f`)!==`pause_turn`&&w(this,Eo,`f`).length!==0&&(w(this,J,`f`).params.messages.push(w(this,q,`m`,Lo).call(this)),C(this,Eo,[],`f`))},Lo=function(){let e=[];for(let t of w(this,Eo,`f`)){if(t.type===`removal`){e.push({type:`tool_removal`,tool:{type:`tool_reference`,name:t.name}});continue}let n=t.tool;if(`run`in t.tool){let{run:e,parse:r,close:i,...a}=t.tool;n=a}e.push({type:`tool_addition`,tool:{type:`tool_definition`,definition:n}})}return{role:`system`,content:e}},e})();function zo(e){if(`compaction`in e&&e.compaction!=null)throw new y("`compaction` cannot be set on a tool runner: every request in the loop would compact again. Call `runner.compactBeforeNextTurn()` when the conversation should be compacted instead.")}function Bo(e){if(`compactionControl`in e&&e.compactionControl!=null)throw new y("`compactionControl` has been removed from the tool runner. Use server-side compaction instead: call `runner.compactBeforeNextTurn()` when the conversation should be compacted.")}function Vo(e){if(e.runToolsEagerly&&!e.stream)throw TypeError("`runToolsEagerly: true` needs `stream: true` in the tool runner's params, because a reply that isn't streamed arrives whole.")}function Ho(e){if(e.context_management?.edits?.some(e=>e.type.startsWith(`compact_`)))throw new y("`compactBeforeNextTurn()` can't be used while `context_management` has a compaction edit, because the API doesn't accept a compaction block together with one. Remove the edit first.")}function Uo(e){let{context_management:t,stop_sequences:n,output_format:r,...i}=e,a=({format:e,...t})=>t;return(i.tool_choice?.type===`any`||i.tool_choice?.type===`tool`)&&delete i.tool_choice,i.output_config&&=a(i.output_config),Array.isArray(i.fallbacks)&&(i.fallbacks=i.fallbacks.map(e=>e.output_config?{...e,output_config:a(e.output_config)}:e)),i}async function Wo(e,t,n,r,i){if(!n||n.role!==`assistant`||!n.content||typeof n.content==`string`)return null;let a=n.content.filter(e=>e.type===`tool_use`);return a.length===0?null:{role:`user`,content:await Promise.all(a.map(n=>{let a=i?.get(n.id);if(a?.status===`started`)return a.result;let o=Go(e,t,n,r);return i?.set(n.id,{status:`started`,result:o}),o}))}}async function Go(e,t,n,r){let i=t.has(n.name)?e.get(n.name):void 0;if(!i)return qo(n);try{let e=n.input;`parse`in i&&i.parse&&(e=i.parse(e));let t=await i.run(e,{toolUse:n,toolUseBlock:n,signal:r?.signal});return{type:`tool_result`,tool_use_id:n.id,content:t}}catch(e){return{type:`tool_result`,tool_use_id:n.id,content:e instanceof ci?e.content:`Error: ${e instanceof Error?e.message:String(e)}`,is_error:!0}}}function Ko(e){return e}function qo(e){return{type:`tool_result`,tool_use_id:e.id,content:`Error: Tool '${e.name}' not found`,is_error:!0}}function Jo(e,t){switch(e.type){case`tool_removal`:case`tool_addition`:Yo(e,t)}}function Yo(e,t){let n=Xo(e.tool);n!==void 0&&(e.type===`tool_removal`?t.delete(n):t.add(n))}function Xo(e){switch(e.type){case`tool_reference`:return e.name;case`tool_definition`:return`name`in e.definition?e.definition.name:void 0;default:return}}function Zo(e){if(e===null)return`stop`;switch(e){case`tool_use`:return`run_tools`;case`pause_turn`:case`compaction`:return`resume`;case`end_turn`:case`stop_sequence`:case`max_tokens`:case`model_context_window_exceeded`:case`refusal`:return`stop`;default:return`stop`}}var Qo={},$o=[`claude-mythos-preview`,`claude-opus-4-6`],es=(()=>{class e extends F{constructor(){super(...arguments),this.batches=new ya(this._client)}create(e,t){let n=ts(e),{betas:r,user_profile_id:i,workspace_id:a,...o}=n;o.model in Qo&&console.warn(`The model '${o.model}' is deprecated and will reach end-of-life on ${Qo[o.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),$o.includes(o.model)&&o.thinking&&o.thinking.type===`enabled`&&console.warn(`Using Claude with ${o.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let s=t?.timeout??this._client._options.timeout;if(!o.stream&&s==null){let e=ba[o.model]??void 0;s=this._client.calculateNonstreamingTimeout(o.max_tokens,e)}let c=yr(o.tools,o.messages);return this._client.post(`/v1/messages?beta=true`,{body:o,timeout:s??6e5,...t,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-user-profile-id":i},...a==null?void 0:{"anthropic-workspace-id":a}},c,t?.headers]),stream:n.stream??!1})}parse(e,t){return t={...t,headers:I([{"anthropic-beta":[...e.betas??[],`structured-outputs-2025-12-15`].toString()},t?.headers])},this.create(e,t).then(t=>Ca(t,e,{logger:this._client.logger??console}))}stream(e,t){return ro.createMessage(this,e,t)}countTokens(e,t){let{betas:n,user_profile_id:r,workspace_id:i,...a}=ts(e);return this._client.post(`/v1/messages/count_tokens?beta=true`,{body:a,...t,headers:I([{"anthropic-beta":[...n??[],`token-counting-2024-11-01`].toString(),...r==null?void 0:{"anthropic-user-profile-id":r},...i==null?void 0:{"anthropic-workspace-id":i}},t?.headers])})}toolRunner(e,t){return new Ro(this._client,e,t)}}return e.Batches=ya,e.BetaToolRunner=Ro,e.ToolError=ci,e})();function ts(e){if(!e.output_format)return e;if(e.output_config?.format)throw new y(`Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).`);let{output_format:t,...n}=e;return{...n,output_config:{...e.output_config,format:t}}}var ns=class extends F{retrieve(e,t){return this._client.get(L`/v1/organizations/api_keys/${e}?beta=true`,t)}update(e,t,n){return this._client.post(L`/v1/organizations/api_keys/${e}?beta=true`,{body:t,...n})}list(e={},t){return this._client.getAPIList(`/v1/organizations/api_keys?beta=true`,Bn,{query:e,...t})}},rs=class extends F{retrieve(e){return this._client.get(`/v1/organizations/compliance_settings?beta=true`,e)}update(e,t){return this._client.post(`/v1/organizations/compliance_settings?beta=true`,{body:e,...t})}},is=class extends F{create(e,t){return this._client.post(`/v1/organizations/external_keys?beta=true`,{body:e,...t})}retrieve(e,t){return this._client.get(L`/v1/organizations/external_keys/${e}?beta=true`,t)}update(e,t,n){return this._client.post(L`/v1/organizations/external_keys/${e}?beta=true`,{body:t,...n})}list(e={},t){return this._client.getAPIList(`/v1/organizations/external_keys?beta=true`,P,{query:e,...t})}delete(e,t){return this._client.delete(L`/v1/organizations/external_keys/${e}?beta=true`,t)}validate(e,t){return this._client.post(L`/v1/organizations/external_keys/${e}/validate?beta=true`,t)}},as=class extends F{create(e,t){return this._client.post(`/v1/organizations/invites?beta=true`,{body:e,...t})}retrieve(e,t){return this._client.get(L`/v1/organizations/invites/${e}?beta=true`,t)}list(e={},t){return this._client.getAPIList(`/v1/organizations/invites?beta=true`,Bn,{query:e,...t})}delete(e,t){return this._client.delete(L`/v1/organizations/invites/${e}?beta=true`,t)}},os=class extends F{list(e={},t){return this._client.getAPIList(`/v1/organizations/rate_limits?beta=true`,P,{query:e,...t})}},ss=class extends F{retrieve(e,t){return this._client.get(L`/v1/organizations/users/${e}?beta=true`,t)}update(e,t,n){return this._client.post(L`/v1/organizations/users/${e}?beta=true`,{body:t,...n})}list(e={},t){return this._client.getAPIList(`/v1/organizations/users?beta=true`,Bn,{query:e,...t})}remove(e,t){return this._client.delete(L`/v1/organizations/users/${e}?beta=true`,t)}},cs=class extends F{create(e,t){let{betas:n,...r}=e;return this._client.post(`/v1/organizations/federation_issuers?beta=true`,{body:r,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(L`/v1/organizations/federation_issuers/${e}?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}update(e,t,n){let{betas:r,...i}=t;return this._client.post(L`/v1/organizations/federation_issuers/${e}?beta=true`,{body:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/organizations/federation_issuers?beta=true`,P,{query:r,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}archive(e,t={},n){let{betas:r}=t??{};return this._client.post(L`/v1/organizations/federation_issuers/${e}/archive?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}},ls=class extends F{list(e,t={},n){let{betas:r,...i}=t??{};return this._client.getAPIList(L`/v1/organizations/federation_rules/${e}/workspaces?beta=true`,P,{query:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}add(e,t,n){let{betas:r,...i}=t;return this._client.post(L`/v1/organizations/federation_rules/${e}/workspaces?beta=true`,{body:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}remove(e,t,n){let{federation_rule_id:r,betas:i}=t;return this._client.delete(L`/v1/organizations/federation_rules/${r}/workspaces/${e}?beta=true`,{...n,headers:I([{...i?.toString()==null?void 0:{"anthropic-beta":i?.toString()}},n?.headers])})}},us=(()=>{class e extends F{constructor(){super(...arguments),this.workspaces=new ls(this._client)}create(e,t){let{betas:n,...r}=e;return this._client.post(`/v1/organizations/federation_rules?beta=true`,{body:r,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(L`/v1/organizations/federation_rules/${e}?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}update(e,t,n){let{betas:r,...i}=t;return this._client.post(L`/v1/organizations/federation_rules/${e}?beta=true`,{body:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/organizations/federation_rules?beta=true`,P,{query:r,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}archive(e,t={},n){let{betas:r}=t??{};return this._client.post(L`/v1/organizations/federation_rules/${e}/archive?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}}return e.Workspaces=ls,e})(),ds=(()=>{class e extends F{constructor(){super(...arguments),this.issuers=new cs(this._client),this.rules=new us(this._client)}}return e.Issuers=cs,e.Rules=us,e})(),fs=class extends F{list(e,t={},n){let{betas:r,...i}=t??{};return this._client.getAPIList(L`/v1/organizations/service_accounts/${e}/workspaces?beta=true`,P,{query:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}add(e,t,n){let{betas:r,...i}=t;return this._client.post(L`/v1/organizations/service_accounts/${e}/workspaces?beta=true`,{body:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}remove(e,t,n){let{service_account_id:r,betas:i}=t;return this._client.delete(L`/v1/organizations/service_accounts/${r}/workspaces/${e}?beta=true`,{...n,headers:I([{...i?.toString()==null?void 0:{"anthropic-beta":i?.toString()}},n?.headers])})}},ps=(()=>{class e extends F{constructor(){super(...arguments),this.workspaces=new fs(this._client)}create(e,t){let{betas:n,...r}=e;return this._client.post(`/v1/organizations/service_accounts?beta=true`,{body:r,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(L`/v1/organizations/service_accounts/${e}?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}update(e,t,n){let{betas:r,...i}=t;return this._client.post(L`/v1/organizations/service_accounts/${e}?beta=true`,{body:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/organizations/service_accounts?beta=true`,P,{query:r,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}archive(e,t={},n){let{betas:r}=t??{};return this._client.post(L`/v1/organizations/service_accounts/${e}/archive?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}}return e.Workspaces=fs,e})(),ms=class extends F{retrieve(e,t,n){let{workspace_id:r}=t;return this._client.get(L`/v1/organizations/workspaces/${r}/members/${e}?beta=true`,n)}update(e,t,n){let{workspace_id:r,...i}=t;return this._client.post(L`/v1/organizations/workspaces/${r}/members/${e}?beta=true`,{body:i,...n})}list(e,t={},n){return this._client.getAPIList(L`/v1/organizations/workspaces/${e}/members?beta=true`,Bn,{query:t,...n})}add(e,t,n){return this._client.post(L`/v1/organizations/workspaces/${e}/members?beta=true`,{body:t,...n})}remove(e,t,n){let{workspace_id:r}=t;return this._client.delete(L`/v1/organizations/workspaces/${r}/members/${e}?beta=true`,n)}},hs=class extends F{list(e,t={},n){return this._client.getAPIList(L`/v1/organizations/workspaces/${e}/rate_limits?beta=true`,P,{query:t,...n})}},gs=class extends F{retrieve(e,t,n){let{workspace_id:r,betas:i}=t;return this._client.get(L`/v1/organizations/workspaces/${r}/service_accounts/${e}?beta=true`,{...n,headers:I([{...i?.toString()==null?void 0:{"anthropic-beta":i?.toString()}},n?.headers])})}update(e,t,n){let{workspace_id:r,betas:i,...a}=t;return this._client.post(L`/v1/organizations/workspaces/${r}/service_accounts/${e}?beta=true`,{body:a,...n,headers:I([{...i?.toString()==null?void 0:{"anthropic-beta":i?.toString()}},n?.headers])})}list(e,t={},n){let{betas:r,...i}=t??{};return this._client.getAPIList(L`/v1/organizations/workspaces/${e}/service_accounts?beta=true`,P,{query:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}add(e,t,n){let{betas:r,...i}=t;return this._client.post(L`/v1/organizations/workspaces/${e}/service_accounts?beta=true`,{body:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}remove(e,t,n){let{workspace_id:r,betas:i}=t;return this._client.delete(L`/v1/organizations/workspaces/${r}/service_accounts/${e}?beta=true`,{...n,headers:I([{...i?.toString()==null?void 0:{"anthropic-beta":i?.toString()}},n?.headers])})}},_s=(()=>{class e extends F{constructor(){super(...arguments),this.rateLimits=new hs(this._client),this.members=new ms(this._client),this.serviceAccounts=new gs(this._client)}create(e,t){let{betas:n,...r}=e;return this._client.post(`/v1/organizations/workspaces?beta=true`,{body:r,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}retrieve(e,t){return this._client.get(L`/v1/organizations/workspaces/${e}?beta=true`,t)}update(e,t,n){return this._client.post(L`/v1/organizations/workspaces/${e}?beta=true`,{body:t,...n})}list(e={},t){return this._client.getAPIList(`/v1/organizations/workspaces?beta=true`,Bn,{query:e,...t})}archive(e,t){return this._client.post(L`/v1/organizations/workspaces/${e}/archive?beta=true`,t)}}return e.RateLimits=hs,e.Members=ms,e.ServiceAccounts=gs,e})(),vs=(()=>{class e extends F{constructor(){super(...arguments),this.apiKeys=new ns(this._client),this.externalKeys=new is(this._client),this.federation=new ds(this._client),this.invites=new as(this._client),this.serviceAccounts=new ps(this._client),this.users=new ss(this._client),this.workspaces=new _s(this._client),this.rateLimits=new os(this._client),this.complianceSettings=new rs(this._client)}retrieve(e){return this._client.get(`/v1/organizations/me?beta=true`,e)}}return e.APIKeys=ns,e.ExternalKeys=is,e.Federation=ds,e.Invites=as,e.ServiceAccounts=ps,e.Users=ss,e.Workspaces=_s,e.RateLimits=os,e.ComplianceSettings=rs,e})(),ys=(()=>{class e extends F{list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/sessions/${e}/events?beta=true`,P,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}send(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/sessions/${e}/events?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}stream(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.get(L`/v1/sessions/${e}/events/stream?beta=true`,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers]),stream:!0})}toolRunner(e,t){return new Ji(e,{...t,client:this._client})}}return e.SessionToolRunner=Ji,e})(),bs=class extends F{retrieve(e,t,n){let{session_id:r,betas:i,workspace_id:a}=t;return this._client.get(L`/v1/sessions/${r}/resources/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}update(e,t,n){let{session_id:r,betas:i,workspace_id:a,...o}=t;return this._client.post(L`/v1/sessions/${r}/resources/${e}?beta=true`,{body:o,...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/sessions/${e}/resources?beta=true`,P,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}delete(e,t,n){let{session_id:r,betas:i,workspace_id:a}=t;return this._client.delete(L`/v1/sessions/${r}/resources/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}add(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/sessions/${e}/resources?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}},xs=class extends F{list(e,t,n){let{session_id:r,betas:i,workspace_id:a,...o}=t;return this._client.getAPIList(L`/v1/sessions/${r}/threads/${e}/events?beta=true`,P,{query:o,...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}stream(e,t,n){let{session_id:r,betas:i,workspace_id:a,...o}=t;return this._client.get(L`/v1/sessions/${r}/threads/${e}/stream?beta=true`,{query:o,...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers]),stream:!0})}},Ss=(()=>{class e extends F{constructor(){super(...arguments),this.events=new xs(this._client)}retrieve(e,t,n){let{session_id:r,betas:i,workspace_id:a}=t;return this._client.get(L`/v1/sessions/${r}/threads/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/sessions/${e}/threads?beta=true`,P,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}archive(e,t,n){let{session_id:r,betas:i,workspace_id:a}=t;return this._client.post(L`/v1/sessions/${r}/threads/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}}return e.Events=xs,e})(),Cs=(()=>{class e extends F{constructor(){super(...arguments),this.events=new ys(this._client),this.resources=new bs(this._client),this.threads=new Ss(this._client)}create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/sessions?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/sessions/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}update(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/sessions/${e}?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/sessions?beta=true`,Vn,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}delete(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.delete(L`/v1/sessions/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}archive(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/sessions/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}}return e.Events=ys,e.Resources=bs,e.Threads=Ss,e})(),ws=class extends F{create(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/skills/${e}/versions?beta=true`,Kn({body:a,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])},this._client,!1))}retrieve(e,t,n){let{skill_id:r,betas:i,workspace_id:a}=t;return this._client.get(L`/v1/skills/${r}/versions/${e}?beta=true`,{...n,headers:I([{...i?.toString()==null?void 0:{"anthropic-beta":i?.toString()},...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/skills/${e}/versions?beta=true`,P,{query:a,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}delete(e,t,n){let{skill_id:r,betas:i,workspace_id:a}=t;return this._client.delete(L`/v1/skills/${r}/versions/${e}?beta=true`,{...n,headers:I([{...i?.toString()==null?void 0:{"anthropic-beta":i?.toString()},...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}download(e,t,n){let{skill_id:r,betas:i,workspace_id:a}=t;return this._client.get(L`/v1/skills/${r}/versions/${e}/content?beta=true`,{...n,headers:I([{Accept:`application/binary`,...i?.toString()==null?void 0:{"anthropic-beta":i?.toString()},...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers]),__binaryResponse:!0})}},Ts=(()=>{class e extends F{constructor(){super(...arguments),this.versions=new ws(this._client)}create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/skills?beta=true`,Kn({body:i,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()},...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])},this._client,!1))}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/skills/${e}?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/skills?beta=true`,P,{query:i,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()},...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}delete(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.delete(L`/v1/skills/${e}?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}}return e.Versions=ws,e})(),Es=class extends F{create(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/tunnels/${e}/certificates?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`mcp-tunnels-2026-06-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}retrieve(e,t,n){let{tunnel_id:r,betas:i,workspace_id:a}=t;return this._client.get(L`/v1/tunnels/${r}/certificates/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`mcp-tunnels-2026-06-22`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/tunnels/${e}/certificates?beta=true`,P,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`mcp-tunnels-2026-06-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}archive(e,t,n){let{tunnel_id:r,betas:i,workspace_id:a}=t;return this._client.post(L`/v1/tunnels/${r}/certificates/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`mcp-tunnels-2026-06-22`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}},Ds=(()=>{class e extends F{constructor(){super(...arguments),this.certificates=new Es(this._client)}create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/tunnels?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`mcp-tunnels-2026-06-22`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/tunnels/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`mcp-tunnels-2026-06-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/tunnels?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`mcp-tunnels-2026-06-22`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}archive(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/tunnels/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`mcp-tunnels-2026-06-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}revealToken(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/tunnels/${e}/reveal_token?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`mcp-tunnels-2026-06-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}rotateToken(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/tunnels/${e}/rotate_token?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`mcp-tunnels-2026-06-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}}return e.Certificates=Es,e})(),Os=class extends F{create(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/vaults/${e}/credentials?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}retrieve(e,t,n){let{vault_id:r,betas:i,workspace_id:a}=t;return this._client.get(L`/v1/vaults/${r}/credentials/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}update(e,t,n){let{vault_id:r,betas:i,workspace_id:a,...o}=t;return this._client.post(L`/v1/vaults/${r}/credentials/${e}?beta=true`,{body:o,...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/vaults/${e}/credentials?beta=true`,P,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}delete(e,t,n){let{vault_id:r,betas:i,workspace_id:a}=t;return this._client.delete(L`/v1/vaults/${r}/credentials/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}archive(e,t,n){let{vault_id:r,betas:i,workspace_id:a}=t;return this._client.post(L`/v1/vaults/${r}/credentials/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}mcpOAuthValidate(e,t,n){let{vault_id:r,betas:i,workspace_id:a}=t;return this._client.post(L`/v1/vaults/${r}/credentials/${e}/mcp_oauth_validate?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}},ks=(()=>{class e extends F{constructor(){super(...arguments),this.credentials=new Os(this._client)}create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/vaults?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/vaults/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}update(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/vaults/${e}?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/vaults?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}delete(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.delete(L`/v1/vaults/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}archive(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/vaults/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}}return e.Credentials=Os,e})(),As=(()=>{class e extends F{constructor(){super(...arguments),this.models=new Sr(this._client),this.messages=new es(this._client),this.agents=new Ar(this._client),this.environments=new ma(this._client),this.sessions=new Cs(this._client),this.deployments=new dr(this._client),this.deploymentRuns=new ur(this._client),this.vaults=new ks(this._client),this.memoryStores=new _a(this._client),this.files=new xr(this._client),this.skills=new Ts(this._client),this.webhooks=new Or(this._client),this.userProfiles=new Cr(this._client),this.dreams=new fr(this._client),this.tunnels=new Ds(this._client),this.organization=new vs(this._client)}}return e.Models=Sr,e.Messages=es,e.Agents=Ar,e.Environments=ma,e.Sessions=Cs,e.Deployments=dr,e.DeploymentRuns=ur,e.Vaults=ks,e.MemoryStores=_a,e.Files=xr,e.Skills=Ts,e.Webhooks=Or,e.UserProfiles=Cr,e.Dreams=fr,e.Tunnels=Ds,e.Organization=vs,e})(),js=class extends F{create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/complete`,{body:i,timeout:this._client._options.timeout??6e5,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()},...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers]),stream:e.stream??!1})}},Ms=class extends F{list(e={},t){let{workspace_id:n,...r}=e??{};return this._client.getAPIList(`/v1/files`,P,{query:r,...t,headers:I([{...n==null?void 0:{"anthropic-workspace-id":n}},t?.headers])})}delete(e,t={},n){let{workspace_id:r}=t??{};return this._client.delete(L`/v1/files/${e}`,{...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])})}download(e,t={},n){let{workspace_id:r}=t??{};return this._client.get(L`/v1/files/${e}/content`,{...n,headers:I([{Accept:`application/binary`,...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers]),__binaryResponse:!0})}retrieveMetadata(e,t={},n){let{workspace_id:r}=t??{};return this._client.get(L`/v1/files/${e}`,{...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])})}upload(e,t){let{workspace_id:n,...r}=e;return this._client.post(`/v1/files`,Kn({body:r,...t,headers:I([{...n==null?void 0:{"anthropic-workspace-id":n}},br(r.file),t?.headers])},this._client))}};function Ns(e){return e?.output_config?.format}function Ps(e,t,n){let r=Ns(t);return!t||!(`parse`in(r??{}))?{...e,content:e.content.map(e=>e.type===`text`?Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1}):e),parsed_output:null}:Fs(e,t,n)}function Fs(e,t,n){let r=null,i=e.content.map(e=>{if(e.type===`text`){let n=Is(t,e.text);return r===null&&(r=n),Object.defineProperty({...e},"parsed_output",{value:n,enumerable:!1})}return e});return{...e,content:i,parsed_output:r}}function Is(e,t){let n=Ns(e);if(n?.type!==`json_schema`)return null;try{return`parse`in n?n.parse(t):JSON.parse(t)}catch(e){throw new y(`Failed to parse structured output: ${e}`)}}var $,Ls,Rs,zs,Bs,Vs,Hs,Us,Ws,Gs,Ks,qs,Js,Ys,Xs,Zs,Qs,$s,ec,tc,nc,rc,ic,ac,oc;function sc(e){return e.type===`tool_use`||e.type===`server_tool_use`}var cc=(()=>{class e{constructor(e,t){$.add(this),this.messages=[],this.receivedMessages=[],Ls.set(this,void 0),Rs.set(this,null),this.controller=new AbortController,zs.set(this,void 0),Bs.set(this,()=>{}),Vs.set(this,()=>{}),Hs.set(this,void 0),Us.set(this,()=>{}),Ws.set(this,()=>{}),Gs.set(this,{}),Ks.set(this,!1),qs.set(this,!1),Js.set(this,!1),Ys.set(this,!1),Xs.set(this,void 0),Zs.set(this,void 0),Qs.set(this,void 0),$s.set(this,void 0),nc.set(this,e=>{if(C(this,qs,!0,`f`),b(e)&&(e=new x),e instanceof x)return C(this,Js,!0,`f`),this._emit(`abort`,e);if(e instanceof y)return this._emit(`error`,e);if(e instanceof Error){let t=new y(e.message);return t.cause=e,this._emit(`error`,t)}return this._emit(`error`,new y(String(e)))}),C(this,zs,new Promise((e,t)=>{C(this,Bs,e,`f`),C(this,Vs,t,`f`)}),`f`),C(this,Hs,new Promise((e,t)=>{C(this,Us,e,`f`),C(this,Ws,t,`f`)}),`f`),w(this,zs,`f`).catch(()=>{}),w(this,Hs,`f`).catch(()=>{}),C(this,Rs,e,`f`),C(this,$s,t?.logger??console,`f`)}get response(){return w(this,Xs,`f`)}get request_id(){return w(this,Zs,`f`)}get workspace_id(){return w(this,Qs,`f`)}async withResponse(){C(this,Ys,!0,`f`);let e=await w(this,zs,`f`);if(!e)throw Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get(`request-id`),workspace_id:e.headers.get(`anthropic-workspace-id`)}}static fromReadableStream(t){let n=new e(null);return n._run(()=>n._fromReadableStream(t)),n}static createMessage(t,n,r,{logger:i}={}){let a=new e(n,{logger:i});for(let e of n.messages)a._addMessageParam(e);return C(a,Rs,{...n,stream:!0},`f`),a._run(()=>a._createMessage(t,{...n,stream:!0},{...r,headers:{...r?.headers,[mr]:`stream`}})),a}_run(e){e().then(()=>{this._emitFinal(),this._emit(`end`)},w(this,nc,`f`))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit(`message`,e)}async _createMessage(e,t,n){let r=n?.signal,i;r&&(r.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),r.addEventListener(`abort`,i));try{w(this,$,`m`,rc).call(this);let{response:r,data:i}=await e.create({...t,stream:!0},{...n,signal:this.controller.signal}).withResponse();this._connected(r);for await(let e of i)w(this,$,`m`,ic).call(this,e);if(i.controller.signal?.aborted)throw new x;w(this,$,`m`,ac).call(this)}finally{r&&i&&r.removeEventListener(`abort`,i)}}_connected(e){this.ended||(C(this,Xs,e,`f`),C(this,Zs,e?.headers.get(`request-id`),`f`),C(this,Qs,e?.headers.get(`anthropic-workspace-id`),`f`),w(this,Bs,`f`).call(this,e),this._emit(`connect`))}get ended(){return w(this,Ks,`f`)}get errored(){return w(this,qs,`f`)}get aborted(){return w(this,Js,`f`)}abort(){this.controller.abort()}on(e,t){return(w(this,Gs,`f`)[e]||(w(this,Gs,`f`)[e]=[])).push({listener:t}),this}off(e,t){let n=w(this,Gs,`f`)[e];if(!n)return this;let r=n.findIndex(e=>e.listener===t);return r>=0&&n.splice(r,1),this}once(e,t){return(w(this,Gs,`f`)[e]||(w(this,Gs,`f`)[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{C(this,Ys,!0,`f`),e!==`error`&&this.once(`error`,n),this.once(e,t)})}async done(){C(this,Ys,!0,`f`),await w(this,Hs,`f`)}get currentMessage(){return w(this,Ls,`f`)}async finalMessage(){return await this.done(),w(this,$,`m`,ec).call(this)}async finalText(){return await this.done(),w(this,$,`m`,tc).call(this)}_emit(e,...t){if(w(this,Ks,`f`))return;e===`end`&&(C(this,Ks,!0,`f`),w(this,Us,`f`).call(this));let n=w(this,Gs,`f`)[e];if(n&&(w(this,Gs,`f`)[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),e===`abort`){let e=t[0];!w(this,Ys,`f`)&&!n?.length&&Promise.reject(e),w(this,Vs,`f`).call(this,e),w(this,Ws,`f`).call(this,e),this._emit(`end`);return}if(e===`error`){let e=t[0];!w(this,Ys,`f`)&&!n?.length&&Promise.reject(e),w(this,Vs,`f`).call(this,e),w(this,Ws,`f`).call(this,e),this._emit(`end`)}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit(`finalMessage`,w(this,$,`m`,ec).call(this))}async _fromReadableStream(e,t){let n=t?.signal,r;n&&(n.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),n.addEventListener(`abort`,r));try{w(this,$,`m`,rc).call(this),this._connected(null);let t=Sn.fromReadableStream(e,this.controller);for await(let e of t)w(this,$,`m`,ic).call(this,e);if(t.controller.signal?.aborted)throw new x;w(this,$,`m`,ac).call(this)}finally{n&&r&&n.removeEventListener(`abort`,r)}}[(Ls=new WeakMap,Rs=new WeakMap,zs=new WeakMap,Bs=new WeakMap,Vs=new WeakMap,Hs=new WeakMap,Us=new WeakMap,Ws=new WeakMap,Gs=new WeakMap,Ks=new WeakMap,qs=new WeakMap,Js=new WeakMap,Ys=new WeakMap,Xs=new WeakMap,Zs=new WeakMap,Qs=new WeakMap,$s=new WeakMap,nc=new WeakMap,$=new WeakSet,ec=function(){if(this.receivedMessages.length===0)throw new y(`stream ended without producing a Message with role=assistant`);return this.receivedMessages.at(-1)},tc=function(){if(this.receivedMessages.length===0)throw new y(`stream ended without producing a Message with role=assistant`);let e=this.receivedMessages.at(-1).content.filter(e=>e.type===`text`).map(e=>e.text);if(e.length===0)throw new y(`stream ended without producing a content block with type=text`);return e.join(` `)},rc=function(){this.ended||C(this,Ls,void 0,`f`)},ic=function(e){if(this.ended)return;let t=w(this,$,`m`,oc).call(this,e);switch(this._emit(`streamEvent`,e,t),e.type){case`content_block_delta`:{let n=t.content.at(-1);switch(e.delta.type){case`text_delta`:n.type===`text`&&this._emit(`text`,e.delta.text,n.text||``);break;case`citations_delta`:n.type===`text`&&this._emit(`citation`,e.delta.citation,n.citations??[]);break;case`input_json_delta`:sc(n)&&w(this,Gs,`f`).inputJson?.length&&this._emit(`inputJson`,e.delta.partial_json,n.input);break;case`thinking_delta`:n.type===`thinking`&&this._emit(`thinking`,e.delta.thinking,n.thinking);break;case`signature_delta`:n.type===`thinking`&&this._emit(`signature`,n.signature);break;default:e.delta}break}case`message_stop`:this._addMessageParam(t),this._addMessage(Ps(t,w(this,Rs,`f`),{logger:w(this,$s,`f`)}),!0);break;case`content_block_stop`:this._emit(`contentBlock`,t.content.at(-1));break;case`message_start`:C(this,Ls,t,`f`)}},ac=function(){if(this.ended)throw new y(`stream has ended, this shouldn't happen`);let e=w(this,Ls,`f`);if(!e)throw new y(`request ended without sending any chunks`);return C(this,Ls,void 0,`f`),Ps(e,w(this,Rs,`f`),{logger:w(this,$s,`f`)})},oc=function(e){let t=w(this,Ls,`f`);if(e.type===`message_start`){if(t)throw new y(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(!t)throw new y(`Unexpected event order, got ${e.type} before "message_start"`);switch(e.type){case`message_stop`:return t;case`message_delta`:return t.stop_reason=e.delta.stop_reason,t.stop_sequence=e.delta.stop_sequence,t.stop_details=e.delta.stop_details,t.usage.output_tokens=e.usage.output_tokens,e.delta.container!=null&&(t.container=e.delta.container),e.usage.input_tokens!=null&&(t.usage.input_tokens=e.usage.input_tokens),e.usage.cache_creation_input_tokens!=null&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),e.usage.cache_read_input_tokens!=null&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),e.usage.server_tool_use!=null&&(t.usage.server_tool_use=e.usage.server_tool_use),e.usage.output_tokens_details!=null&&(t.usage.output_tokens_details=e.usage.output_tokens_details),t;case`content_block_start`:return t.content.push({...e.content_block}),t;case`content_block_delta`:{let n=t.content.at(e.index);switch(e.delta.type){case`text_delta`:n?.type===`text`&&(t.content[e.index]={...n,text:(n.text||``)+e.delta.text});break;case`citations_delta`:n?.type===`text`&&(t.content[e.index]={...n,citations:[...n.citations??[],e.delta.citation]});break;case`input_json_delta`:if(n&&sc(n)){let r=(n.__json_buf||``)+e.delta.partial_json;t.content[e.index]=ja(n,r)}break;case`thinking_delta`:n?.type===`thinking`&&(t.content[e.index]={...n,thinking:n.thinking+e.delta.thinking});break;case`signature_delta`:n?.type===`thinking`&&(t.content[e.index]={...n,signature:e.delta.signature});break;default:e.delta}return t}case`content_block_stop`:{let n=t.content.at(e.index);return n&&sc(n)&&`__json_buf`in n&&Object.defineProperty(n,"input",{value:n.input,enumerable:!0,configurable:!0,writable:!0}),t}}},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`streamEvent`,n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on(`end`,()=>{n=!0;for(let e of t)e.resolve(void 0);t.length=0}),this.on(`abort`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),this.on(`error`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Sn(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}return e})(),lc=class extends F{create(e,t){let{user_profile_id:n,workspace_id:r,...i}=e;return this._client.post(`/v1/messages/batches`,{body:i,...t,headers:I([{...n==null?void 0:{"anthropic-user-profile-id":n},...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{workspace_id:r}=t??{};return this._client.get(L`/v1/messages/batches/${e}`,{...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])})}list(e={},t){let{workspace_id:n,...r}=e??{};return this._client.getAPIList(`/v1/messages/batches`,Bn,{query:r,...t,headers:I([{...n==null?void 0:{"anthropic-workspace-id":n}},t?.headers])})}delete(e,t={},n){let{workspace_id:r}=t??{};return this._client.delete(L`/v1/messages/batches/${e}`,{...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])})}cancel(e,t={},n){let{workspace_id:r}=t??{};return this._client.post(L`/v1/messages/batches/${e}/cancel`,{...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])})}async results(e,t={},n){let r=await this.retrieve(e,t,n);if(!r.results_url)throw new y(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`);let{workspace_id:i}=t??{};return this._client.get(r.results_url,{...n,headers:I([{Accept:`application/binary`,...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>va.fromResponse(t.response,t.controller))}},uc=(()=>{class e extends F{constructor(){super(...arguments),this.batches=new lc(this._client)}create(e,t){let{user_profile_id:n,workspace_id:r,...i}=e;i.model in dc&&console.warn(`The model '${i.model}' is deprecated and will reach end-of-life on ${dc[i.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),fc.includes(i.model)&&i.thinking&&i.thinking.type===`enabled`&&console.warn(`Using Claude with ${i.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let a=t?.timeout??this._client._options.timeout;if(!i.stream&&a==null){let e=ba[i.model]??void 0;a=this._client.calculateNonstreamingTimeout(i.max_tokens,e)}let o=yr(i.tools,i.messages);return this._client.post(`/v1/messages`,{body:i,timeout:a??6e5,...t,headers:I([{...n==null?void 0:{"anthropic-user-profile-id":n},...r==null?void 0:{"anthropic-workspace-id":r}},o,t?.headers]),stream:e.stream??!1})}parse(e,t){return this.create(e,t).then(t=>Fs(t,e,{logger:this._client.logger??console}))}stream(e,t){return cc.createMessage(this,e,t,{logger:this._client.logger??console})}countTokens(e,t){let{user_profile_id:n,workspace_id:r,...i}=e;return this._client.post(`/v1/messages/count_tokens`,{body:i,...t,headers:I([{...n==null?void 0:{"anthropic-user-profile-id":n},...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}}return e.Batches=lc,e})(),dc={},fc=[`claude-mythos-preview`,`claude-opus-4-6`],pc=class extends F{retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/models/${e}`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/models`,Bn,{query:i,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()},...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}},mc=class extends F{create(e,t,n){let{workspace_id:r,...i}=t;return this._client.post(L`/v1/skills/${e}/versions`,Kn({body:i,...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])},this._client,!1))}retrieve(e,t,n){let{skill_id:r,workspace_id:i}=t;return this._client.get(L`/v1/skills/${r}/versions/${e}`,{...n,headers:I([{...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e,t={},n){let{workspace_id:r,...i}=t??{};return this._client.getAPIList(L`/v1/skills/${e}/versions`,P,{query:i,...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])})}delete(e,t,n){let{skill_id:r,workspace_id:i}=t;return this._client.delete(L`/v1/skills/${r}/versions/${e}`,{...n,headers:I([{...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}},hc=(()=>{class e extends F{constructor(){super(...arguments),this.versions=new mc(this._client)}create(e,t){let{workspace_id:n,...r}=e;return this._client.post(`/v1/skills`,Kn({body:r,...t,headers:I([{...n==null?void 0:{"anthropic-workspace-id":n}},t?.headers])},this._client,!1))}retrieve(e,t={},n){let{workspace_id:r}=t??{};return this._client.get(L`/v1/skills/${e}`,{...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])})}list(e={},t){let{workspace_id:n,...r}=e??{};return this._client.getAPIList(`/v1/skills`,P,{query:r,...t,headers:I([{...n==null?void 0:{"anthropic-workspace-id":n}},t?.headers])})}delete(e,t={},n){let{workspace_id:r}=t??{};return this._client.delete(L`/v1/skills/${e}`,{...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])})}}return e.Versions=mc,e})(),gc,_c,vc,yc,bc=`\\n\\nHuman:`,xc=`\\n\\nAssistant:`,Sc=(()=>{class e{get credentials(){return this._authState.provider}constructor({baseURL:e=A(`ANTHROPIC_BASE_URL`),apiKey:t,authToken:n,webhookKey:r=A(`ANTHROPIC_WEBHOOK_SIGNING_KEY`)??null,...i}={}){if(gc.add(this),this._requestAuthFlags=new WeakMap,vc.set(this,void 0),t===void 0&&(t=i.profile==null?A(`ANTHROPIC_API_KEY`)??null:null),n===void 0&&(n=i.profile==null?A(`ANTHROPIC_AUTH_TOKEN`)??null:null),i.profile!=null&&(i.credentials!=null||i.config!=null))throw TypeError("Pass at most one of `profile`, `credentials`, or `config`.");let a={apiKey:t,authToken:n,webhookKey:r,...i,baseURL:e||`https://api.anthropic.com`};if(!a.dangerouslyAllowBrowser&&Re())throw new y(`It looks like you're running in a browser-like environment.
7
+ `)}\n${a}\n${t}`)}return a})(cr),ur=class extends F{retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/deployment_runs/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/deployment_runs?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}},dr=class extends F{create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/deployments?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/deployments/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}update(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/deployments/${e}?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/deployments?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}archive(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/deployments/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}pause(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/deployments/${e}/pause?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}run(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/deployments/${e}/run?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}unpause(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/deployments/${e}/unpause?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}},fr=class extends F{create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/dreams?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`dreaming-2026-04-21`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/dreams/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`dreaming-2026-04-21`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/dreams?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`dreaming-2026-04-21`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}archive(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/dreams/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`dreaming-2026-04-21`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}cancel(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/dreams/${e}/cancel?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`dreaming-2026-04-21`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}},pr=`x-stainless-helper`,mr=`x-stainless-helper-method`;function hr(e){return{[pr]:e}}var gr=Symbol(`anthropic.sdk.stainlessHelper`);function _r(e){return typeof e==`object`&&!!e&&gr in e}function vr(e,t){let n=new Set;if(e)for(let t of e)_r(t)&&n.add(t[gr]);if(t)for(let e of t){_r(e)&&n.add(e[gr]);let t=e.content;if(Array.isArray(t))for(let e of t){_r(e)&&n.add(e[gr]);let t=e?.tool?.definition;_r(t)&&n.add(t[gr])}}return Array.from(n)}function yr(e,t){let n=vr(e,t);return n.length===0?{}:{[pr]:n.join(`, `)}}function br(e){return _r(e)?{[pr]:e[gr]}:{}}var xr=class extends F{list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/files?beta=true`,P,{query:i,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()},...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}delete(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.delete(L`/v1/files/${e}?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}download(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/files/${e}/content?beta=true`,{...n,headers:I([{Accept:`application/binary`,...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers]),__binaryResponse:!0})}retrieveMetadata(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/files/${e}?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}upload(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/files?beta=true`,Kn({body:i,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()},...r==null?void 0:{"anthropic-workspace-id":r}},br(i.file),t?.headers])},this._client))}},Sr=class extends F{retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/models/${e}?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/models?beta=true`,Bn,{query:i,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()},...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}},Cr=class extends F{create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/user_profiles?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`user-profiles-2026-08-18`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/user_profiles/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`user-profiles-2026-08-18`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}update(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/user_profiles/${e}?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`user-profiles-2026-08-18`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/user_profiles?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`user-profiles-2026-08-18`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}createEnrollmentURL(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/user_profiles/${e}/enrollment_url?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`user-profiles-2026-08-18`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}},wr=t((e=>{var t=e&&e.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();Object.defineProperty(e,"__esModule",{value:!0});var n=256,r=function(){function e(e){e===void 0&&(e=`=`),this._paddingCharacter=e}return e.prototype.encodedLength=function(e){return this._paddingCharacter?(e+2)/3*4|0:(e*8+5)/6|0},e.prototype.encode=function(e){for(var t=``,n=0;n<e.length-2;n+=3){var r=e[n]<<16|e[n+1]<<8|e[n+2];t+=this._encodeByte(r>>>18&63),t+=this._encodeByte(r>>>12&63),t+=this._encodeByte(r>>>6&63),t+=this._encodeByte(r>>>0&63)}var i=e.length-n;if(i>0){var r=e[n]<<16|(i===2?e[n+1]<<8:0);t+=this._encodeByte(r>>>18&63),t+=this._encodeByte(r>>>12&63),t+=i===2?this._encodeByte(r>>>6&63):this._paddingCharacter||``,t+=this._paddingCharacter||``}return t},e.prototype.maxDecodedLength=function(e){return this._paddingCharacter?e/4*3|0:(e*6+7)/8|0},e.prototype.decodedLength=function(e){return this.maxDecodedLength(e.length-this._getPaddingLength(e))},e.prototype.decode=function(e){if(e.length===0)return new Uint8Array;for(var t=this._getPaddingLength(e),r=e.length-t,i=new Uint8Array(this.maxDecodedLength(r)),a=0,o=0,s=0,c=0,l=0,u=0,d=0;o<r-4;o+=4)c=this._decodeChar(e.charCodeAt(o+0)),l=this._decodeChar(e.charCodeAt(o+1)),u=this._decodeChar(e.charCodeAt(o+2)),d=this._decodeChar(e.charCodeAt(o+3)),i[a++]=c<<2|l>>>4,i[a++]=l<<4|u>>>2,i[a++]=u<<6|d,s|=c&n,s|=l&n,s|=u&n,s|=d&n;if(o<r-1&&(c=this._decodeChar(e.charCodeAt(o)),l=this._decodeChar(e.charCodeAt(o+1)),i[a++]=c<<2|l>>>4,s|=c&n,s|=l&n),o<r-2&&(u=this._decodeChar(e.charCodeAt(o+2)),i[a++]=l<<4|u>>>2,s|=u&n),o<r-3&&(d=this._decodeChar(e.charCodeAt(o+3)),i[a++]=u<<6|d,s|=d&n),s!==0)throw Error(`Base64Coder: incorrect characters for decoding`);return i},e.prototype._encodeByte=function(e){var t=e;return t+=65,t+=25-e>>>8&6,t+=51-e>>>8&-75,t+=61-e>>>8&-15,t+=62-e>>>8&3,String.fromCharCode(t)},e.prototype._decodeChar=function(e){var t=n;return t+=(42-e&e-44)>>>8&-n+e-43+62,t+=(46-e&e-48)>>>8&-n+e-47+63,t+=(47-e&e-58)>>>8&-n+e-48+52,t+=(64-e&e-91)>>>8&-n+e-65+0,t+=(96-e&e-123)>>>8&-n+e-97+26,t},e.prototype._getPaddingLength=function(e){var t=0;if(this._paddingCharacter){for(var n=e.length-1;n>=0&&e[n]===this._paddingCharacter;n--)t++;if(e.length<4||t>2)throw Error(`Base64Coder: incorrect padding`)}return t},e}();e.Coder=r;var i=new r;function a(e){return i.encode(e)}e.encode=a;function o(e){return i.decode(e)}e.decode=o;var s=function(e){t(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return r.prototype._encodeByte=function(e){var t=e;return t+=65,t+=25-e>>>8&6,t+=51-e>>>8&-75,t+=61-e>>>8&-13,t+=62-e>>>8&49,String.fromCharCode(t)},r.prototype._decodeChar=function(e){var t=n;return t+=(44-e&e-46)>>>8&-n+e-45+62,t+=(94-e&e-96)>>>8&-n+e-95+63,t+=(47-e&e-58)>>>8&-n+e-48+52,t+=(64-e&e-91)>>>8&-n+e-65+0,t+=(96-e&e-123)>>>8&-n+e-97+26,t},r}(r);e.URLSafeCoder=s;var c=new s;function l(e){return c.encode(e)}e.encodeURLSafe=l;function u(e){return c.decode(e)}e.decodeURLSafe=u,e.encodedLength=function(e){return i.encodedLength(e)},e.maxDecodedLength=function(e){return i.maxDecodedLength(e)},e.decodedLength=function(e){return i.decodedLength(e)}})),Tr=t(((e,t)=>{(function(e,n){var r={};n(r);var i=r.default;for(var a in r)i[a]=r[a];typeof t==`object`&&typeof t.exports==`object`?t.exports=i:typeof define==`function`&&define.amd?define(function(){return i}):e.sha256=i})(e,function(e){e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(e,n,r,i,a){for(var o,s,c,l,u,d,f,p,m,h,g,_,v;a>=64;){for(o=n[0],s=n[1],c=n[2],l=n[3],u=n[4],d=n[5],f=n[6],p=n[7],h=0;h<16;h++)g=i+h*4,e[h]=(r[g]&255)<<24|(r[g+1]&255)<<16|(r[g+2]&255)<<8|r[g+3]&255;for(h=16;h<64;h++)m=e[h-2],_=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,m=e[h-15],v=(m>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,e[h]=(_+e[h-7]|0)+(v+e[h-16]|0);for(h=0;h<64;h++)_=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&d^~u&f)|0)+(p+(t[h]+e[h]|0)|0)|0,v=((o>>>2|o<<30)^(o>>>13|o<<19)^(o>>>22|o<<10))+(o&s^o&c^s&c)|0,p=f,f=d,d=u,u=l+_|0,l=c,c=s,s=o,o=_+v|0;n[0]+=o,n[1]+=s,n[2]+=c,n[3]+=l,n[4]+=u,n[5]+=d,n[6]+=f,n[7]+=p,i+=64,a-=64}return i}var r=function(){function t(){this.digestLength=e.digestLength,this.blockSize=e.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return t.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},t.prototype.clean=function(){for(var e=0;e<this.buffer.length;e++)this.buffer[e]=0;for(var e=0;e<this.temp.length;e++)this.temp[e]=0;this.reset()},t.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this.finished)throw Error(`SHA256: can't update because hash was finished.`);var r=0;if(this.bytesHashed+=t,this.bufferLength>0){for(;this.bufferLength<64&&t>0;)this.buffer[this.bufferLength++]=e[r++],t--;this.bufferLength===64&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(t>=64&&(r=n(this.temp,this.state,e,r,t),t%=64);t>0;)this.buffer[this.bufferLength++]=e[r++],t--;return this},t.prototype.finish=function(e){if(!this.finished){var t=this.bytesHashed,r=this.bufferLength,i=t/536870912|0,a=t<<3,o=t%64<56?64:128;this.buffer[r]=128;for(var s=r+1;s<o-8;s++)this.buffer[s]=0;this.buffer[o-8]=i>>>24&255,this.buffer[o-7]=i>>>16&255,this.buffer[o-6]=i>>>8&255,this.buffer[o-5]=i>>>0&255,this.buffer[o-4]=a>>>24&255,this.buffer[o-3]=a>>>16&255,this.buffer[o-2]=a>>>8&255,this.buffer[o-1]=a>>>0&255,n(this.temp,this.state,this.buffer,0,o),this.finished=!0}for(var s=0;s<8;s++)e[s*4+0]=this.state[s]>>>24&255,e[s*4+1]=this.state[s]>>>16&255,e[s*4+2]=this.state[s]>>>8&255,e[s*4+3]=this.state[s]>>>0&255;return this},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype._saveState=function(e){for(var t=0;t<this.state.length;t++)e[t]=this.state[t]},t.prototype._restoreState=function(e,t){for(var n=0;n<this.state.length;n++)this.state[n]=e[n];this.bytesHashed=t,this.finished=!1,this.bufferLength=0},t}();e.Hash=r;var i=function(){function e(e){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var t=new Uint8Array(this.blockSize);if(e.length>this.blockSize)new r().update(e).finish(t).clean();else for(var n=0;n<e.length;n++)t[n]=e[n];for(var n=0;n<t.length;n++)t[n]^=54;this.inner.update(t);for(var n=0;n<t.length;n++)t[n]^=106;this.outer.update(t),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var n=0;n<t.length;n++)t[n]=0}return e.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},e.prototype.clean=function(){for(var e=0;e<this.istate.length;e++)this.ostate[e]=this.istate[e]=0;this.inner.clean(),this.outer.clean()},e.prototype.update=function(e){return this.inner.update(e),this},e.prototype.finish=function(e){return this.outer.finished?this.outer.finish(e):(this.inner.finish(e),this.outer.update(e,this.digestLength).finish(e)),this},e.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},e}();e.HMAC=i;function a(e){var t=new r().update(e),n=t.digest();return t.clean(),n}e.hash=a,e.default=a;function o(e,t){var n=new i(e).update(t),r=n.digest();return n.clean(),r}e.hmac=o;function s(e,t,n,r){var i=r[0];if(i===0)throw Error(`hkdf: cannot expand more`);t.reset(),i>1&&t.update(e),n&&t.update(n),t.update(r),t.finish(e),r[0]++}var c=new Uint8Array(e.digestLength);function l(e,t,n,r){t===void 0&&(t=c),r===void 0&&(r=32);for(var a=new Uint8Array([1]),l=new i(o(t,e)),u=new Uint8Array(l.digestLength),d=u.length,f=new Uint8Array(r),p=0;p<r;p++)d===u.length&&(s(u,l,n,a),d=0),f[p]=u[d++];return l.clean(),u.fill(0),a.fill(0),f}e.hkdf=l;function u(e,t,n,r){for(var a=new i(e),o=a.digestLength,s=new Uint8Array(4),c=new Uint8Array(o),l=new Uint8Array(o),u=new Uint8Array(r),d=0;d*o<r;d++){var f=d+1;s[0]=f>>>24&255,s[1]=f>>>16&255,s[2]=f>>>8&255,s[3]=f>>>0&255,a.reset(),a.update(t),a.update(s),a.finish(l);for(var p=0;p<o;p++)c[p]=l[p];for(var p=2;p<=n;p++){a.reset(),a.update(l).finish(l);for(var m=0;m<o;m++)c[m]^=l[m]}for(var p=0;p<o&&d*o+p<r;p++)u[d*o+p]=c[p]}for(var d=0;d<o;d++)c[d]=l[d]=0;for(var d=0;d<4;d++)s[d]=0;return a.clean(),u}e.pbkdf2=u})})),Er=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.timingSafeEqual=n;function t(e,t=``){if(!e)throw Error(t)}function n(e,n){if(e.byteLength!==n.byteLength)return!1;e instanceof DataView||(e=new DataView(ArrayBuffer.isView(e)?e.buffer:e)),n instanceof DataView||(n=new DataView(ArrayBuffer.isView(n)?n.buffer:n)),t(e instanceof DataView),t(n instanceof DataView);let r=e.byteLength,i=0,a=-1;for(;++a<r;)i|=e.getUint8(a)^n.getUint8(a);return i===0}})),Dr=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Webhook=e.WebhookVerificationError=void 0;var t=wr(),n=Tr(),r=Er(),i=300,a=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name=`ExtendableError`,this.stack=Error(t).stack}},o=class e extends a{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name=`WebhookVerificationError`}};e.WebhookVerificationError=o;var s=class e{constructor(n,r){if(r?.format===`raw`)this.key=n instanceof Uint8Array?n:Uint8Array.from(n,e=>e.charCodeAt(0));else{if(typeof n!=`string`)throw Error(`Expected secret to be of type string`);n.startsWith(e.prefix)&&(n=n.substring(e.prefix.length)),this.key=t.decode(n)}if(this.key.length===0)throw Error(`Secret can't be empty.`)}verify(e,t,n){let i=n?.jsonParse??!0,a={};for(let e of Object.keys(t))a[e.toLowerCase()]=t[e];let s=a[`webhook-id`],c=a[`webhook-signature`],l=a[`webhook-timestamp`];if(!c||!s||!l)throw new o(`Missing required headers`);let u=this.verifyTimestamp(l),d=this.sign(s,u,e).split(`,`)[1],f=c.split(` `),p=new globalThis.TextEncoder;for(let t of f){let[n,a]=t.split(`,`);if(n===`v1`&&(0,r.timingSafeEqual)(p.encode(a),p.encode(d))){let t=e.toString();return t===``?void 0:i?JSON.parse(t):void 0}}throw new o(`No matching signature found`)}sign(e,r,i){if(typeof i!=`string`){if(i.constructor.name===`Buffer`)i=i.toString();else throw Error(`Expected payload to be of type string or Buffer.`)}let a=new TextEncoder,o=Math.floor(r.getTime()/1e3),s=a.encode(`${e}.${o}.${i}`);return`v1,${t.encode(n.hmac(this.key,s))}`}verifyTimestamp(e){let t=Math.floor(Date.now()/1e3),n=parseInt(e,10);if(Number.isNaN(n))throw new o(`Invalid Signature Headers`);if(t-n>i)throw new o(`Message timestamp too old`);if(n>t+i)throw new o(`Message timestamp too new`);return new Date(n*1e3)}};e.Webhook=s,s.prefix=`whsec_`}))(),Or=class extends F{parseUnverified(e){return JSON.parse(e)}unwrap(e,t){let n=t?.headers;if(n==null)throw Error(`Webhook headers are required in order to verify the signature`);let r=t.key===void 0?this._client.webhookKey:t.key;if(!r)throw Error(`Webhook key must not be null or empty in order to unwrap`);return new Dr.Webhook(r).verify(e,n),JSON.parse(e)}},kr=class extends F{list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/agents/${e}/versions?beta=true`,P,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}},Ar=(()=>{class e extends F{constructor(){super(...arguments),this.versions=new kr(this._client)}create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/agents?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.get(L`/v1/agents/${e}?beta=true`,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}update(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/agents/${e}?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/agents?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}archive(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/agents/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}}return e.Versions=kr,e})();function jr(e,t){if(!e)return()=>{};if(e.aborted)return t.abort(),()=>{};let n=()=>t.abort();return e.addEventListener(`abort`,n),()=>e.removeEventListener(`abort`,n)}function Mr(e,t){return e instanceof le&&e.status===t}function Nr(e){return e instanceof le&&typeof e.status==`number`&&e.status>=400&&e.status<500}function Pr(e){return Nr(e)&&!Mr(e,408)&&!Mr(e,409)&&!Mr(e,429)}function Fr(e,t,n){return Math.min(t*2**e,n)}function Ir(e,t){return e+Math.random()*(t-e)}function Lr(e){return e*(1-Math.random()*.25)}function Rr(e,{authToken:t,helper:n}){if(!t)throw new y(`copyClientForHelper: expected a non-empty authToken but received ${JSON.stringify(t)}`);let r=e,i=r._options.defaultHeaders,a=r._authState?.extraHeaders,o=I([a?Object.fromEntries(Object.entries(a).filter(([e])=>{let t=e.toLowerCase();return t!==`authorization`&&t!==`x-api-key`})):void 0,i,{[pr]:n}]);return e.withOptions({apiKey:null,authToken:t,baseURL:e.baseURL,credentials:void 0,defaultHeaders:o})}var zr,Br,R,Vr,Hr,Ur,Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr=1e3,Qr=6e4,$r=3e5,ei=(()=>{class e{constructor(e){zr.set(this,void 0),Br.set(this,!1),R.set(this,void 0),Vr.set(this,void 0),Hr.set(this,void 0),Ur.set(this,void 0),Wr.set(this,void 0),Gr.set(this,void 0),Kr.set(this,void 0),this.client=e.client,this.environmentId=e.environmentId,this.environmentKey=e.environmentKey,this.workerId=e.workerId??ri(),C(this,zr,Rr(e.client,{authToken:e.environmentKey,helper:`environments-work-poller`}),`f`),C(this,Hr,e.autoStop??!0,`f`),C(this,Ur,e.drain??!1,`f`),C(this,Wr,e.blockMs===void 0?999:e.blockMs,`f`),C(this,Gr,e.reclaimOlderThanMs??null,`f`),C(this,Kr,e.requestOptions,`f`),C(this,R,new AbortController,`f`),C(this,Vr,jr(e.signal,w(this,R,`f`)),`f`)}get signal(){return w(this,R,`f`).signal}abort(){w(this,R,`f`).abort()}async*[(zr=new WeakMap,Br=new WeakMap,R=new WeakMap,Vr=new WeakMap,Hr=new WeakMap,Ur=new WeakMap,Wr=new WeakMap,Gr=new WeakMap,Kr=new WeakMap,Symbol.asyncIterator)](){if(w(this,Br,`f`))throw new y(`Cannot iterate over a consumed WorkPoller`);C(this,Br,!0,`f`);let e=j(this.client);e.info(`poller starting`,{component:`work-poller`,environment_id:this.environmentId});let t=new ni(e,this.environmentId);try{let n=0;for(;!w(this,R,`f`).signal.aborted;){let r;try{r=await w(this,zr,`f`).beta.environments.work.poll(this.environmentId,{"Anthropic-Worker-ID":this.workerId,...w(this,Wr,`f`)===null?{}:{block_ms:w(this,Wr,`f`)},...w(this,Gr,`f`)===null?{}:{reclaim_older_than_ms:w(this,Gr,`f`)}},{headers:I([w(this,Kr,`f`)?.headers]),signal:w(this,R,`f`).signal})}catch(t){if(w(this,R,`f`).signal.aborted)return;if(Pr(t))throw e.error(`poll failed permanently, stopping poller`,{error:String(t)}),t;let r=Lr(ti(n));e.warn(`poll failed, backing off`,{error:String(t),backoff_ms:r}),n++,await Ie(r,w(this,R,`f`).signal);continue}if(n=0,r==null){if(w(this,Ur,`f`))return;t.onEmptyPoll(),await Ie(Ir(1e3,3e3),w(this,R,`f`).signal);continue}t.onClaim(),e.info(`claimed work`,{component:`work-poller`,environment_id:this.environmentId,work_id:r.id,work_type:r.data.type});try{await w(this,zr,`f`).beta.environments.work.ack(r.id,{environment_id:r.environment_id},{headers:I([w(this,Kr,`f`)?.headers]),signal:w(this,R,`f`).signal})}catch(t){e.error(`ack failed`,{work_id:r.id,error:String(t)});continue}try{yield r}finally{if(w(this,Hr,`f`))try{await w(this,zr,`f`).beta.environments.work.stop(r.id,{environment_id:r.environment_id},{headers:I([w(this,Kr,`f`)?.headers])})}catch(t){Mr(t,409)||e.warn(`stop failed`,{work_id:r.id,error:String(t)})}}}}finally{w(this,Vr,`f`).call(this)}}}return e})();function ti(e){return Fr(e,Zr,Qr)}var ni=(()=>{class e{constructor(e,t){qr.set(this,void 0),Jr.set(this,void 0),Yr.set(this,void 0),Xr.set(this,0),C(this,qr,e,`f`),C(this,Jr,t,`f`)}onEmptyPoll(){let e=Date.now(),t={component:`work-poller`,environment_id:w(this,Jr,`f`)};w(this,Yr,`f`)===void 0?(C(this,Yr,C(this,Xr,e,`f`),`f`),w(this,qr,`f`).info(`idle; polling for work`,t)):e-w(this,Xr,`f`)>=$r?(C(this,Xr,e,`f`),w(this,qr,`f`).info(`still polling; idle for ${Math.round((e-w(this,Yr,`f`))/1e3)}s`,t)):w(this,qr,`f`).debug(`poll returned no work`,t)}onClaim(){C(this,Yr,void 0,`f`)}}return qr=new WeakMap,Jr=new WeakMap,Yr=new WeakMap,Xr=new WeakMap,e})();function ri(){let e={}.HOSTNAME;return e?`${e}-${tn()}`:tn()}var ii,ai,oi,si=(()=>{class e{constructor(){ii.set(this,[]),ai.set(this,[]),oi.set(this,!1)}push(e){if(w(this,oi,`f`))return!1;let t=w(this,ai,`f`).shift();return t?t({done:!1,value:e}):w(this,ii,`f`).push(e),!0}close(){if(!w(this,oi,`f`))for(C(this,oi,!0,`f`);w(this,ai,`f`).length>0;)w(this,ai,`f`).shift()({done:!0,value:void 0})}next(e){return w(this,ii,`f`).length>0?Promise.resolve({done:!1,value:w(this,ii,`f`).shift()}):w(this,oi,`f`)||e?.aborted?Promise.resolve({done:!0,value:void 0}):new Promise(t=>{let n=n=>{e?.removeEventListener(`abort`,r),t(n)},r=()=>{let e=w(this,ai,`f`).indexOf(n);e>=0&&w(this,ai,`f`).splice(e,1),t({done:!0,value:void 0})};w(this,ai,`f`).push(n),e?.addEventListener(`abort`,r,{once:!0})})}tryShift(){return w(this,ii,`f`).shift()}}return ii=new WeakMap,ai=new WeakMap,oi=new WeakMap,e})(),ci=(()=>{class e extends Error{constructor(e){let t=typeof e==`string`?e:e.map(e=>e.type===`text`?e.text:`[${e.type}]`).join(` `);super(t),this.name=`ToolError`,this.content=e}}return e})();function li(e){return`name`in e?e.name:`mcp_server_name`in e?e.mcp_server_name:e.type}function ui(e){return e instanceof ci?e.content:`Error: ${e instanceof Error?e.message:String(e)}`}async function di(e,t,n){try{let r=e.parse?e.parse(t):t;return{content:await e.run(r,n),isError:!1}}catch(e){return{content:ui(e),isError:!0}}}var fi,pi,mi,hi,z,B,gi,V,_i,vi,yi,H,bi,U,xi,Si,Ci,wi,Ti,Ei,W,Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii,Li,Ri,zi=500,Bi=1e4,Vi=12e4,Hi=3e4,Ui=1e3,Wi=3e4,Gi=3e5;function Ki(e){return e.type===`session.status_idle`&&e.stop_reason?.type===`end_turn`}var qi=(()=>{class e{constructor(e,t){fi.set(this,void 0),pi.set(this,void 0),mi.set(this,new Set),hi.set(this,!1),z.set(this,void 0),C(this,fi,e,`f`),C(this,pi,t,`f`)}noteEvent(e){e.type!==`user.tool_confirmation`&&(Ki(e)?this.arm():this.disarm())}block(e){w(this,mi,`f`).add(e),w(this,z,`f`)!==void 0&&(C(this,hi,!0,`f`),clearTimeout(w(this,z,`f`)),C(this,z,void 0,`f`))}unblock(e){w(this,mi,`f`).delete(e),w(this,mi,`f`).size===0&&w(this,hi,`f`)&&this.arm()}arm(){if(!(w(this,fi,`f`)<=0)){if(w(this,mi,`f`).size>0){C(this,hi,!0,`f`);return}C(this,hi,!1,`f`),w(this,z,`f`)!==void 0&&clearTimeout(w(this,z,`f`)),C(this,z,setTimeout(w(this,pi,`f`),w(this,fi,`f`)),`f`)}}disarm(){C(this,hi,!1,`f`),w(this,z,`f`)!==void 0&&(clearTimeout(w(this,z,`f`)),C(this,z,void 0,`f`))}}return fi=new WeakMap,pi=new WeakMap,mi=new WeakMap,hi=new WeakMap,z=new WeakMap,e})(),Ji=(()=>{class e{constructor(e,t){B.add(this),gi.set(this,!1),V.set(this,void 0),_i.set(this,void 0),vi.set(this,void 0),yi.set(this,void 0),H.set(this,void 0),bi.set(this,new Set),U.set(this,new Set),xi.set(this,new Map),Si.set(this,new Map),Ci.set(this,new si),wi.set(this,0),Ti.set(this,Gi),Ei.set(this,null),W.set(this,void 0),this.client=t.client,this.sessionId=e,this.tools=t.tools,this.maxIdleMs=t.maxIdleMs??6e4,C(this,H,j(t.client),`f`),C(this,yi,new Map(t.tools.map(e=>[li(e),e])),`f`),C(this,V,new AbortController,`f`),C(this,_i,jr(t.signal,w(this,V,`f`)),`f`),C(this,vi,t.requestOptions,`f`),C(this,W,new qi(this.maxIdleMs,()=>{w(this,H,`f`).info(`session idle after end_turn; stopping`,{component:`session-tool-runner`,session_id:this.sessionId,max_idle_ms:this.maxIdleMs}),w(this,V,`f`).abort()}),`f`)}get signal(){return w(this,V,`f`).signal}abort(){w(this,V,`f`).abort()}_setSendRetryWindow(e){C(this,Ti,e,`f`)}async*[(gi=new WeakMap,V=new WeakMap,_i=new WeakMap,vi=new WeakMap,yi=new WeakMap,H=new WeakMap,bi=new WeakMap,U=new WeakMap,xi=new WeakMap,Si=new WeakMap,Ci=new WeakMap,wi=new WeakMap,Ti=new WeakMap,Ei=new WeakMap,W=new WeakMap,B=new WeakSet,Symbol.asyncIterator)](){if(w(this,gi,`f`))throw new y(`Cannot iterate over a consumed SessionToolRunner`);C(this,gi,!0,`f`),w(this,H,`f`).info(`session tool runner starting`,{component:`session-tool-runner`,session_id:this.sessionId});let e=w(this,B,`m`,Oi).call(this).catch(e=>{w(this,V,`f`).signal.aborted||w(this,H,`f`).error(`stream loop failed`,{error:String(e)}),w(this,V,`f`).abort()});try{for(;;){let e=await w(this,Ci,`f`).next(w(this,V,`f`).signal);if(e.done)break;yield e.value}await e;let t;for(;(t=w(this,Ci,`f`).tryShift())!==void 0;)yield t}finally{w(this,V,`f`).abort(),w(this,W,`f`).disarm(),await e;try{await w(this,B,`m`,Ri).call(this)}catch(e){w(this,H,`f`).warn(`drain failed`,{error:String(e)})}w(this,Ci,`f`).close();for(let e of this.tools)try{await e.close?.()}catch(t){w(this,H,`f`).warn(`tool.close failed`,{tool:li(e),error:String(t)})}w(this,_i,`f`).call(this)}}}return Di=function(){return{...w(this,vi,`f`),headers:I([hr(`session-tool-runner`),w(this,vi,`f`)?.headers]),signal:w(this,V,`f`).signal}},Oi=async function(){let e=w(this,V,`f`),t=zi;for(;!e.signal.aborted;){try{let e=await this.client.beta.sessions.events.stream(this.sessionId,{},w(this,B,`m`,Di).call(this));await w(this,B,`m`,ki).call(this);for await(let n of e)if(t=zi,await w(this,B,`m`,ji).call(this,n))return}catch(n){if(e.signal.throwIfAborted(),Pr(n))throw w(this,H,`f`).error(`permanent stream failure, shutting down`,{error:String(n)}),e.abort(),n;w(this,H,`f`).warn(`stream disconnected, reconnecting`,{error:String(n),backoff_ms:t})}e.signal.throwIfAborted(),await Ie(t,e.signal),t=Math.min(t*2,Bi)}},ki=async function(){let e=w(this,V,`f`),t=[],n=!1;try{for await(let e of this.client.beta.sessions.events.list(this.sessionId,{limit:1e3},w(this,B,`m`,Di).call(this)))w(this,B,`m`,Ai).call(this,e,t),n=Ki(e)}catch(n){e.signal.throwIfAborted(),w(this,H,`f`).warn(`reconcile list failed`,{error:String(n)});for(let e of t)w(this,bi,`f`).delete(e.id);return}let r=t.filter(e=>!w(this,U,`f`).has(e.id));w(this,W,`f`).disarm();for(let e of r)await w(this,B,`m`,Mi).call(this,e);for(let e of[...w(this,Si,`f`).values()]){let t=w(this,xi,`f`).get(e.id);t!==void 0&&await w(this,B,`m`,Pi).call(this,e,t)}let i=r.filter(e=>!w(this,U,`f`).has(e.id)&&!w(this,Si,`f`).has(e.id));n&&i.length===0?w(this,W,`f`).arm():w(this,W,`f`).disarm()},Ai=function(e,t){e.type===`agent.tool_use`||e.type===`agent.custom_tool_use`?(w(this,bi,`f`).add(e.id),w(this,U,`f`).has(e.id)||t.push(e)):e.type===`user.tool_result`?w(this,U,`f`).add(e.tool_use_id):e.type===`user.custom_tool_result`?w(this,U,`f`).add(e.custom_tool_use_id):e.type===`user.tool_confirmation`&&(w(this,U,`f`).has(e.tool_use_id)||w(this,xi,`f`).set(e.tool_use_id,e.result))},ji=async function(e){switch(w(this,W,`f`).noteEvent(e),e.type){case`agent.tool_use`:case`agent.custom_tool_use`:return w(this,bi,`f`).has(e.id)||(w(this,bi,`f`).add(e.id),await w(this,B,`m`,Mi).call(this,e)),!1;case`user.tool_confirmation`:return await w(this,B,`m`,Ni).call(this,e),!1;case`user.tool_result`:return w(this,U,`f`).add(e.tool_use_id),!1;case`user.custom_tool_result`:return w(this,U,`f`).add(e.custom_tool_use_id),!1;case`session.status_terminated`:case`session.deleted`:return w(this,H,`f`).info(`session terminated`,{component:`session-tool-runner`,session_id:this.sessionId}),w(this,V,`f`).abort(),!0;default:return!1}},Mi=async function(e){let t=e.evaluated_permission,n=t===`deny`?`deny`:w(this,xi,`f`).get(e.id);if(n===void 0){t===void 0||t===`allow`?await w(this,B,`m`,Ii).call(this,e,void 0):w(this,Si,`f`).has(e.id)||(w(this,H,`f`).info(`tool call awaiting confirmation; holding`,{component:`session-tool-runner`,session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),w(this,Si,`f`).set(e.id,e),w(this,W,`f`).block(e.id));return}await w(this,B,`m`,Pi).call(this,e,n)},Ni=async function(e){w(this,xi,`f`).set(e.tool_use_id,e.result);let t=w(this,Si,`f`).get(e.tool_use_id);t!==void 0&&await w(this,B,`m`,Pi).call(this,t,e.result)},Pi=async function(e,t){let n=w(this,Si,`f`).delete(e.id);if(t===`allow`){w(this,H,`f`).info(`tool call confirmed`,{component:`session-tool-runner`,session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),n||w(this,W,`f`).block(e.id);try{await w(this,B,`m`,Ii).call(this,e,`allow`)}finally{w(this,W,`f`).unblock(e.id)}return}n&&w(this,W,`f`).unblock(e.id),w(this,U,`f`).add(e.id),w(this,H,`f`).info(`tool call denied; not executing`,{component:`session-tool-runner`,session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),w(this,B,`m`,Fi).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:`deny`})},Fi=function(e){w(this,Ci,`f`).push(e)},Ii=async function(e,t){var n,r;if(!w(this,U,`f`).has(e.id)){w(this,H,`f`).info(`executing tool`,{component:`session-tool-runner`,session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),C(this,wi,(n=w(this,wi,`f`),n++,n),`f`);try{let n=w(this,yi,`f`).get(e.name);if(!n){w(this,H,`f`).info(`tool not owned by this runner; leaving the tool_use_id pending for its owner`,{component:`session-tool-runner`,session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),w(this,B,`m`,Fi).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:t});return}let r,i,a=new AbortController,o=jr(w(this,V,`f`).signal,a),s=setTimeout(()=>a.abort(),Vi);try{let t=await di(n,e.input,{toolUse:e,toolUseBlock:e,signal:a.signal});r=t.content,i=t.isError}finally{clearTimeout(s),o()}let c=Yi(e,i,Xi(r)),l=await w(this,B,`m`,Li).call(this,c,e.id);w(this,B,`m`,Fi).call(this,{event:e,result:c,toolUseId:e.id,name:e.name,isError:i,posted:l,confirmation:t})}finally{C(this,wi,(r=w(this,wi,`f`),r--,r),`f`),w(this,wi,`f`)===0&&w(this,Ei,`f`)?.call(this)}}},Li=async function(e,t){let n=w(this,V,`f`),r=Date.now(),i,a=0;for(;;){a++,n.signal.throwIfAborted();try{return await this.client.beta.sessions.events.send(this.sessionId,{events:[e]},w(this,B,`m`,Di).call(this)),w(this,U,`f`).add(t),!0}catch(e){if(i=e,Pr(e))break;let o=w(this,Ti,`f`)-(Date.now()-r);if(o<=0)break;let s=Math.min(Lr(Fr(a-1,Ui,Wi)),o);w(this,H,`f`).warn(`tool result send failed; retrying`,{tool_use_id:t,attempt:a,backoff_ms:s,error:String(e)}),await Ie(s,n.signal)}}return w(this,H,`f`).error(`failed to send tool result`,{tool_use_id:t,attempts:a,error:String(i)}),!1},Ri=async function(){w(this,wi,`f`)!==0&&(await Promise.race([new Promise(e=>C(this,Ei,e,`f`)),Ie(Hi)]),C(this,Ei,null,`f`),w(this,wi,`f`)>0&&w(this,H,`f`).warn(`drain timeout exceeded`))},e})();function Yi(e,t,n){return e.type===`agent.custom_tool_use`?{type:`user.custom_tool_result`,custom_tool_use_id:e.id,is_error:t,content:n}:{type:`user.tool_result`,tool_use_id:e.id,is_error:t,content:n}}function Xi(e){if(typeof e==`string`)return[{type:`text`,text:e||`(no output)`}];let t=e.map(e=>e.type===`text`?{type:`text`,text:e.text||`(no output)`}:e.type===`image`||e.type===`document`?e:e.type===`search_result`?{type:`search_result`,source:e.source,title:e.title,content:e.content.map(e=>({type:`text`,text:e.text})),citations:{enabled:e.citations?.enabled??!1}}:{type:`text`,text:JSON.stringify(e)});return t.length>0?t:[{type:`text`,text:`(no output)`}]}var Zi,Qi,$i,ea,ta,na=3e4,ra=9e4,ia=`NO_HEARTBEAT`;function aa(e){return e.resources.some(e=>e.type===`memory_store`)}function oa(e){if(!e)return null;let t;try{let n=e.replace(/-/g,`+`).replace(/_/g,`/`),r=n.padEnd(Math.ceil(n.length/4)*4,`=`);t=JSON.parse(Bt(Vt(r)))}catch{return null}if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=t.sessions_token;return typeof n==`string`&&n!==``?n:null}var sa=(()=>{class e{constructor(e){if(Zi.add(this),Qi.set(this,void 0),e.unrestrictedPaths!==void 0)throw new y("The `unrestrictedPaths` option you passed to EnvironmentWorker (or client.beta.environments.work.worker()) is no longer supported. The worker's file tools (read, write, edit, glob, grep) are now always confined to `workdir` plus the session's memory folders. Remove `unrestrictedPaths` from your options; to let the file tools reach any other directory, add it to `AgentToolContext.allowedRoots` from a `tools` factory.");this.client=e.client,this.environmentId=e.environmentId,this.environmentKey=e.environmentKey,this.tools=e.tools,this.workdir=e.workdir??process.cwd(),this.maxFileBytes=e.maxFileBytes,this.maxIdleMs=e.maxIdleMs,e.memorySyncIntervalMs!=null&&Ee(e.memorySyncIntervalMs,`memorySyncIntervalMs`),this.memorySyncIntervalMs=e.memorySyncIntervalMs,this.memorySyncDeletions=e.memorySyncDeletions??`enabled`,this.workerId=e.workerId,this.requestOptions=e.requestOptions,C(this,Qi,e.signal,`f`)}async run(e){let{environmentId:t,environmentKey:n}=this;if(t===void 0||n===void 0)throw new y(`EnvironmentWorker.run: environmentId and environmentKey are required to poll for work`);let r=e??w(this,Qi,`f`),i=new ei({client:this.client,environmentId:t,environmentKey:n,...this.workerId===void 0?{}:{workerId:this.workerId},...r?{signal:r}:{},...this.requestOptions===void 0?{}:{requestOptions:this.requestOptions},autoStop:!1});for await(let e of i)try{await w(this,Zi,`m`,$i).call(this,e,n,i.signal)}catch(t){if(i.signal?.aborted)throw t;j(this.client).error(`work item failed`,{work_id:e.id,error:String(t)})}}async handleItem(e){let t=e?.workId??A(`ANTHROPIC_WORK_ID`),n=e?.environmentId??A(`ANTHROPIC_ENVIRONMENT_ID`),r=e?.sessionId??A(`ANTHROPIC_SESSION_ID`),i=(e?.environmentKey??this.environmentKey??A(`ANTHROPIC_ENVIRONMENT_KEY`))||void 0,a=e?.workSecret||A(`ANTHROPIC_WORK_SECRET`)||null;if(!t)throw new y(`handleItem: workId is required — pass it or set ANTHROPIC_WORK_ID`);if(!n)throw new y(`handleItem: environmentId is required — pass it or set ANTHROPIC_ENVIRONMENT_ID`);if(!r)throw new y(`handleItem: sessionId is required — pass it or set ANTHROPIC_SESSION_ID`);if(!i&&!a)throw new y(`handleItem: environmentKey is required when there is no work secret — pass it, construct the worker with it, or set ANTHROPIC_ENVIRONMENT_KEY`);let o={id:t,environment_id:n,secret:a,data:{type:`session`,id:r}};await w(this,Zi,`m`,$i).call(this,o,i,e?.signal??w(this,Qi,`f`))}}return Qi=new WeakMap,Zi=new WeakSet,$i=async function(e,t,n){let r=j(this.client),i=oa(e.secret),a=i??t;if(a===void 0)throw new y("handleItem: the work item carried a secret payload but no sessions token could be extracted, and there is no environment key to fall back to; the poller must issue a secret whose payload carries `sessions_token`, or provide the environment key (pass it, construct the worker with it, or set ANTHROPIC_ENVIRONMENT_KEY)");e.secret&&i===null&&r.warn(`work item carried a secret payload but no sessions token could be extracted; falling back to the environment key`,{work_id:e.id});let o=Rr(this.client,{authToken:a,helper:`environments-worker`}),s=e.data.id,c=new AbortController,l=jr(n,c),d=new ua(c),f=await u(()=>import(`./node.browser-POTNsJTJ.js`),__vite__mapDeps([2,1])),p,m,h=fa(o,e,d,r,this.requestOptions,e=>{p=e,m?._setSendRetryWindow(e)}).catch(t=>{c.signal.aborted||r.error(`heartbeat loop failed`,{work_id:e.id,error:String(t)}),c.abort()}),g=async()=>{},_,v=!1;try{if(e.data.type!==`session`){r.debug(`skipping non-session work item`,{work_id:e.id,type:e.data.type});return}let t=await o.beta.sessions.retrieve(s);if(i===null&&this.memorySyncIntervalMs!==null&&aa(t))throw new f.SessionMemoryError(`cannot mount the session's memories: the work item carried no sessions token (work_id=${e.id}, session_id=${s}); the memory endpoints reject the environment key, so the poller must issue a per-item \`secret\` carrying \`sessions_token\`, or set \`memorySyncIntervalMs: null\` to run without memory`);let n={workdir:this.workdir,client:o,session:t,...this.maxFileBytes===void 0?{}:{maxFileBytes:this.maxFileBytes}};try{g=await f.setupSkills(n)}catch(t){r.warn(`skill setup failed`,{session_id:s,work_id:e.id,error:String(t)})}i!==null&&this.memorySyncIntervalMs!==null?(_=new f.SessionMemoryStores(o,{workdir:this.workdir,...this.memorySyncIntervalMs===void 0?{}:{syncIntervalMs:this.memorySyncIntervalMs},syncDeletions:this.memorySyncDeletions}),await _.download(t),n.allowedRoots=_.roots,n.readOnlyRoots=_.readOnlyRoots):r.debug(`memory stores disabled for this item`,{work_id:e.id}),m=new Ji(s,{client:o,tools:typeof this.tools==`function`?this.tools(n):this.tools??f.betaAgentToolset20260401(n),...this.maxIdleMs===void 0?{}:{maxIdleMs:this.maxIdleMs},...this.requestOptions===void 0?{}:{requestOptions:this.requestOptions},signal:c.signal}),p!==void 0&&m._setSendRetryWindow(p);for await(let e of m)_&&await _.syncIfDue();v=!c.signal.aborted}finally{try{await g().catch(t=>{r.warn(`skill cleanup failed`,{session_id:s,work_id:e.id,error:String(t)})})}finally{if(_){let t=f.MEMORY_FLUSH_TIMEOUT_MS;v&&await ca(_.finish(),t)&&r.warn(`final memory sync cut off after ${t}ms; the flush that follows still uploads changed files`,{session_id:s,work_id:e.id});let n=new AbortController;await ca(_.flushWrites(n.signal),t)&&(n.abort(),r.warn(`memory flush cut off after ${t}ms; changed files it had not uploaded yet are not saved`,{session_id:s,work_id:e.id})),await _.dispose().catch(t=>{r.warn(`memory store cleanup failed`,{session_id:s,work_id:e.id,error:String(t)})})}}d.finish(`runner_done`),l(),await h,d.lost?r.info(`lease lost; released without stopping it`,{session_id:s,work_id:e.id}):await la(o,e,r,this.requestOptions)}},e})();async function ca(e,t){let n;try{return await Promise.race([e.then(()=>!1,()=>!1),new Promise(e=>{n=setTimeout(()=>e(!0),t)})])}finally{n!==void 0&&clearTimeout(n)}}async function la(e,t,n,r){try{await e.beta.environments.work.stop(t.id,{environment_id:t.environment_id,force:!0},{...r,headers:I([r?.headers])})}catch(e){Mr(e,409)||n.error(`force-stop on exit failed`,{work_id:t.id,error:String(e)})}}var ua=(()=>{class e{constructor(e){ea.set(this,void 0),ta.set(this,void 0),C(this,ea,e,`f`)}get signal(){return w(this,ea,`f`).signal}finish(e){C(this,ta,w(this,ta,`f`)??e,`f`),w(this,ea,`f`).abort()}get lost(){return w(this,ta,`f`)===`lease_lost`||w(this,ta,`f`)===`assumed_lost`}}return ea=new WeakMap,ta=new WeakMap,e})();function da(e){let t=e instanceof le?e.error:void 0;for(let e of[`error`,`details`,`current_state`]){if(!Ne(t))return{};t=t[e]}return Ne(t)?t:{}}async function fa(e,t,n,r,i,a){let o=na,s=ra,c=Date.now(),l=ia,u=async()=>{let u=new AbortController,d=jr(n.signal,u),f=setTimeout(()=>u.abort(),o);try{let d=await e.beta.environments.work.heartbeat(t.id,{environment_id:t.environment_id,expected_last_heartbeat:l},{...i,headers:I([i?.headers]),signal:u.signal});c=Date.now(),l=d.last_heartbeat,d.ttl_seconds>0&&(s=d.ttl_seconds*1e3,o=Math.max(1e3,Math.min(s/2,na)),a?.(s)),(d.state===`stopping`||d.state===`stopped`)&&(r.info(`heartbeat signals shutdown`,{work_id:t.id,state:d.state}),n.finish(`control_plane_stop`)),d.lease_extended||(r.warn(`lease not extended, shutting down`,{work_id:t.id}),n.finish(`control_plane_stop`))}catch(e){if(n.signal.throwIfAborted(),Mr(e,412)){let i=da(e);r.error(`lease lost: heartbeat precondition failed`,{work_id:t.id,server_state:i.state,server_ttl_seconds:i.ttl_seconds,server_last_heartbeat:i.last_heartbeat}),n.finish(`lease_lost`);return}if(Pr(e))throw r.error(`permanent heartbeat failure`,{work_id:t.id,error:String(e)}),n.finish(`heartbeat_rejected`),e;if(Date.now()-c>s){r.error(`lease assumed lost: no successful heartbeat in ttl`,{work_id:t.id,ttl_ms:s,error:String(e)}),n.finish(`assumed_lost`);return}r.warn(`transient heartbeat failure`,{work_id:t.id,error:String(e)})}finally{clearTimeout(f),d()}};for(await u();!n.signal.aborted;)await Ie(o,n.signal),n.signal.throwIfAborted(),await u()}var pa=(()=>{class e extends F{retrieve(e,t,n){let{environment_id:r,betas:i,workspace_id:a}=t;return this._client.get(L`/v1/environments/${r}/work/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}update(e,t,n){let{environment_id:r,betas:i,workspace_id:a,...o}=t;return this._client.post(L`/v1/environments/${r}/work/${e}?beta=true`,{body:o,...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}list(e,t={},n){let{betas:r,...i}=t??{};return this._client.getAPIList(L`/v1/environments/${e}/work?beta=true`,P,{query:i,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString()},n?.headers])})}ack(e,t,n){let{environment_id:r,betas:i}=t;return this._client.post(L`/v1/environments/${r}/work/${e}/ack?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString()},n?.headers])})}heartbeat(e,t,n){let{environment_id:r,desired_ttl_seconds:i,expected_last_heartbeat:a,betas:o}=t;return this._client.post(L`/v1/environments/${r}/work/${e}/heartbeat?beta=true`,{query:{desired_ttl_seconds:i,expected_last_heartbeat:a},...n,headers:I([{"anthropic-beta":[...o??[],`managed-agents-2026-04-01`].toString()},n?.headers])})}poll(e,t={},n){let{betas:r,"Anthropic-Worker-ID":i,...a}=t??{};return this._client.get(L`/v1/environments/${e}/work/poll?beta=true`,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"Anthropic-Worker-ID":i}},n?.headers])})}stats(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/environments/${e}/work/stats?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}stop(e,t,n){let{environment_id:r,betas:i,workspace_id:a,...o}=t;return this._client.post(L`/v1/environments/${r}/work/${e}/stop?beta=true`,{body:o,...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}poller(e){return new ei({...e,client:this._client})}worker(e){return new sa({...e,client:this._client})}}return e.WorkPoller=ei,e.EnvironmentWorker=sa,e})(),ma=(()=>{class e extends F{constructor(){super(...arguments),this.work=new pa(this._client)}create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/environments?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/environments/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}update(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/environments/${e}?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/environments?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}delete(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.delete(L`/v1/environments/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}archive(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/environments/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}}return e.Work=pa,e})(),ha=class extends F{create(e,t,n){let{view:r,betas:i,workspace_id:a,...o}=t;return this._client.post(L`/v1/memory_stores/${e}/memories?beta=true`,{query:{view:r},body:o,...n,headers:I([{"anthropic-beta":[...i??[],`agent-memory-2026-07-22`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}retrieve(e,t,n){let{memory_store_id:r,betas:i,workspace_id:a,...o}=t;return this._client.get(L`/v1/memory_stores/${r}/memories/${e}?beta=true`,{query:o,...n,headers:I([{"anthropic-beta":[...i??[],`agent-memory-2026-07-22`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}update(e,t,n){let{memory_store_id:r,view:i,betas:a,workspace_id:o,...s}=t;return this._client.post(L`/v1/memory_stores/${r}/memories/${e}?beta=true`,{query:{view:i},body:s,...n,headers:I([{"anthropic-beta":[...a??[],`agent-memory-2026-07-22`].toString(),...o==null?void 0:{"anthropic-workspace-id":o}},n?.headers])})}list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/memory_stores/${e}/memories?beta=true`,P,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`agent-memory-2026-07-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}delete(e,t,n){let{memory_store_id:r,expected_content_sha256:i,betas:a,workspace_id:o}=t;return this._client.delete(L`/v1/memory_stores/${r}/memories/${e}?beta=true`,{query:{expected_content_sha256:i},...n,headers:I([{"anthropic-beta":[...a??[],`agent-memory-2026-07-22`].toString(),...o==null?void 0:{"anthropic-workspace-id":o}},n?.headers])})}},ga=class extends F{retrieve(e,t,n){let{memory_store_id:r,betas:i,workspace_id:a,...o}=t;return this._client.get(L`/v1/memory_stores/${r}/memory_versions/${e}?beta=true`,{query:o,...n,headers:I([{"anthropic-beta":[...i??[],`agent-memory-2026-07-22`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/memory_stores/${e}/memory_versions?beta=true`,P,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`agent-memory-2026-07-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}redact(e,t,n){let{memory_store_id:r,betas:i,workspace_id:a}=t;return this._client.post(L`/v1/memory_stores/${r}/memory_versions/${e}/redact?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`agent-memory-2026-07-22`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}},_a=(()=>{class e extends F{constructor(){super(...arguments),this.memories=new ha(this._client),this.memoryVersions=new ga(this._client)}create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/memory_stores?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`agent-memory-2026-07-22`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/memory_stores/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`agent-memory-2026-07-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}update(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/memory_stores/${e}?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`agent-memory-2026-07-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/memory_stores?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`agent-memory-2026-07-22`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}delete(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.delete(L`/v1/memory_stores/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`agent-memory-2026-07-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}archive(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/memory_stores/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`agent-memory-2026-07-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}}return e.Memories=ha,e.MemoryVersions=ga,e})(),va=(()=>{class e{constructor(e,t){this.iterator=e,this.controller=t}async*decoder(){let e=new yn;for await(let t of this.iterator)for(let n of e.decode(t))yield JSON.parse(n);for(let t of e.flush())yield JSON.parse(t)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(t,n){if(!t.body)throw n.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new y(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new y(`Attempted to iterate over a response with no body`);return new e(tt(t.body),n)}}return e})(),ya=class extends F{create(e,t){let{betas:n,user_profile_id:r,workspace_id:i,...a}=e;return this._client.post(`/v1/messages/batches?beta=true`,{body:a,...t,headers:I([{"anthropic-beta":[...n??[],`message-batches-2024-09-24`].toString(),...r==null?void 0:{"anthropic-user-profile-id":r},...i==null?void 0:{"anthropic-workspace-id":i}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/messages/batches/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`message-batches-2024-09-24`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/messages/batches?beta=true`,Bn,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`message-batches-2024-09-24`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}delete(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.delete(L`/v1/messages/batches/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`message-batches-2024-09-24`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}cancel(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/messages/batches/${e}/cancel?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`message-batches-2024-09-24`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}async results(e,t={},n){let r=await this.retrieve(e,t,n);if(!r.results_url)throw new y(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`);let{betas:i,workspace_id:a}=t??{};return this._client.get(r.results_url,{...n,headers:I([{"anthropic-beta":[...i??[],`message-batches-2024-09-24`].toString(),Accept:`application/binary`,...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>va.fromResponse(t.response,t.controller))}},ba={"claude-opus-4@20250514":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192};function xa(e){return e?.output_format??e?.output_config?.format}function Sa(e,t,n){let r=xa(t);return!t||!(`parse`in(r??{}))?{...e,content:e.content.map(e=>{if(e.type===`text`){let t=Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(t,"parsed",{get(){return n.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null},enumerable:!1})}return e}),parsed_output:null}:Ca(e,t,n)}function Ca(e,t,n){let r=null,i=e.content.map(e=>{if(e.type===`text`){let i=wa(t,e.text);r===null&&(r=i);let a=Object.defineProperty({...e},"parsed_output",{value:i,enumerable:!1});return Object.defineProperty(a,"parsed",{get(){return n.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),i},enumerable:!1})}return e});return{...e,content:i,parsed_output:r}}function wa(e,t){let n=xa(e);if(n?.type!==`json_schema`)return null;try{return`parse`in n?n.parse(t):JSON.parse(t)}catch(e){throw new y(`Failed to parse structured output: ${e}`)}}var Ta=e=>{let t=0,n=[];for(;t<e.length;){let r=e[t];if(r===`\\`){t++;continue}if(r===`{`){n.push({type:`brace`,value:`{`}),t++;continue}if(r===`}`){n.push({type:`brace`,value:`}`}),t++;continue}if(r===`[`){n.push({type:`paren`,value:`[`}),t++;continue}if(r===`]`){n.push({type:`paren`,value:`]`}),t++;continue}if(r===`:`){n.push({type:`separator`,value:`:`}),t++;continue}if(r===`,`){n.push({type:`delimiter`,value:`,`}),t++;continue}if(r===`"`){let r=t+1,i=r,a=!1;for(;;){if(i=e.indexOf(`"`,i),i===-1){a=!0;break}let t=0,n=i-1;for(;n>=r&&e[n]===`\\`;)t++,n--;if(t%2==0)break;i++}a?t=e.length:(n.push({type:`string`,value:e.slice(r,i)}),t=i+1);continue}if(r&&/\s/.test(r)){t++;continue}let i=/[0-9]/;if(r&&i.test(r)||r===`-`||r===`.`){let a=``;for(r===`-`&&(a+=r,r=e[++t]);r&&(i.test(r)||r===`.`||r===`e`||r===`E`||(r===`-`||r===`+`)&&(a[a.length-1]===`e`||a[a.length-1]===`E`));)a+=r,r=e[++t];n.push({type:`number`,value:a,unterminated:t===e.length});continue}let a=/[a-z]/i;if(r&&a.test(r)){let i=``;for(;r&&a.test(r)&&t!==e.length;)i+=r,r=e[++t];if(i==`true`||i==`false`||i===`null`)n.push({type:`name`,value:i});else{t++;continue}continue}t++}return n},Ea=e=>{let t=[];for(let n of e)(n.type===`brace`||n.type===`paren`)&&(n.value===`{`||n.value===`[`?t.push(n.value):t.pop());let n=t[t.length-1],r=e.length,i=/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][-+]?[0-9]+)?$/;for(;r>0;){let t=e[r-1];switch(t.type){case`separator`:r--;continue;case`number`:if(t.unterminated||!i.test(t.value)){r--;continue}break;case`string`:let a=e[r-2];if(n===`{`&&(a?.type===`delimiter`||a?.type===`brace`&&a.value===`{`)){r--;continue}break;case`delimiter`:r--}break}return e.slice(0,r)},Da=e=>{let t=[];return e.map(e=>{e.type===`brace`&&(e.value===`{`?t.push(`}`):t.splice(t.lastIndexOf(`}`),1)),e.type===`paren`&&(e.value===`[`?t.push(`]`):t.splice(t.lastIndexOf(`]`),1))}),t.length>0&&t.reverse().map(t=>{t===`}`?e.push({type:`brace`,value:`}`}):t===`]`&&e.push({type:`paren`,value:`]`})}),e},Oa=e=>{let t=``;return e.map(e=>{switch(e.type){case`string`:t+=`"`+e.value+`"`;break;default:t+=e.value}}),t},ka=e=>JSON.parse(Oa(Da(Ea(Ta(e))))),Aa=`__json_buf`;function ja(e,t){let n={};for(let t of Object.keys(e))t!==`input`&&(n[t]=e[t]);Object.defineProperty(n,Aa,{value:t,enumerable:!1,writable:!0});let r,i=!1;return Object.defineProperty(n,"input",{enumerable:!0,configurable:!0,get(){return i||=(r=t?ka(t):{},!0),r}}),n}var G,Ma,Na,Pa,Fa,Ia,La,Ra,za,K,Ba,Va,Ha,Ua,Wa,Ga,Ka,qa,Ja,Ya,Xa,Za,Qa,$a,eo,to;function no(e){return e.type===`tool_use`||e.type===`server_tool_use`||e.type===`mcp_tool_use`}var ro=(()=>{class e{constructor(e,t){G.add(this),this.messages=[],this.receivedMessages=[],Ma.set(this,void 0),Na.set(this,null),this.controller=new AbortController,Pa.set(this,void 0),Fa.set(this,()=>{}),Ia.set(this,()=>{}),La.set(this,void 0),Ra.set(this,()=>{}),za.set(this,()=>{}),K.set(this,{}),Ba.set(this,!1),Va.set(this,!1),Ha.set(this,!1),Ua.set(this,!1),Wa.set(this,void 0),Ga.set(this,void 0),Ka.set(this,void 0),qa.set(this,void 0),Xa.set(this,e=>{if(C(this,Va,!0,`f`),b(e)&&(e=new x),e instanceof x)return C(this,Ha,!0,`f`),this._emit(`abort`,e);if(e instanceof y)return this._emit(`error`,e);if(e instanceof Error){let t=new y(e.message);return t.cause=e,this._emit(`error`,t)}return this._emit(`error`,new y(String(e)))}),C(this,Pa,new Promise((e,t)=>{C(this,Fa,e,`f`),C(this,Ia,t,`f`)}),`f`),C(this,La,new Promise((e,t)=>{C(this,Ra,e,`f`),C(this,za,t,`f`)}),`f`),w(this,Pa,`f`).catch(()=>{}),w(this,La,`f`).catch(()=>{}),C(this,Na,e,`f`),C(this,qa,t?.logger??console,`f`)}get response(){return w(this,Wa,`f`)}get request_id(){return w(this,Ga,`f`)}get workspace_id(){return w(this,Ka,`f`)}async withResponse(){C(this,Ua,!0,`f`);let e=await w(this,Pa,`f`);if(!e)throw Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get(`request-id`),workspace_id:e.headers.get(`anthropic-workspace-id`)}}static fromReadableStream(t){let n=new e(null);return n._run(()=>n._fromReadableStream(t)),n}static createMessage(t,n,r,{logger:i}={}){let a=new e(n,{logger:i});for(let e of n.messages)a._addMessageParam(e);return C(a,Na,{...n,stream:!0},`f`),a._run(()=>a._createMessage(t,{...n,stream:!0},{...r,headers:{...r?.headers,[mr]:`stream`}})),a}_run(e){e().then(()=>{this._emitFinal(),this._emit(`end`)},w(this,Xa,`f`))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit(`message`,e)}async _createMessage(e,t,n){let r=n?.signal,i;r&&(r.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),r.addEventListener(`abort`,i));try{w(this,G,`m`,Za).call(this);let{response:r,data:i}=await e.create({...t,stream:!0},{...n,signal:this.controller.signal}).withResponse();this._connected(r);for await(let e of i)w(this,G,`m`,Qa).call(this,e);if(i.controller.signal?.aborted)throw new x;w(this,G,`m`,$a).call(this)}finally{r&&i&&r.removeEventListener(`abort`,i)}}_connected(e){this.ended||(C(this,Wa,e,`f`),C(this,Ga,e?.headers.get(`request-id`),`f`),C(this,Ka,e?.headers.get(`anthropic-workspace-id`),`f`),w(this,Fa,`f`).call(this,e),this._emit(`connect`))}get ended(){return w(this,Ba,`f`)}get errored(){return w(this,Va,`f`)}get aborted(){return w(this,Ha,`f`)}abort(){this.controller.abort()}on(e,t){return(w(this,K,`f`)[e]||(w(this,K,`f`)[e]=[])).push({listener:t}),this}off(e,t){let n=w(this,K,`f`)[e];if(!n)return this;let r=n.findIndex(e=>e.listener===t);return r>=0&&n.splice(r,1),this}once(e,t){return(w(this,K,`f`)[e]||(w(this,K,`f`)[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{C(this,Ua,!0,`f`),e!==`error`&&this.once(`error`,n),this.once(e,t)})}async done(){C(this,Ua,!0,`f`),await w(this,La,`f`)}get currentMessage(){return w(this,Ma,`f`)}async finalMessage(){return await this.done(),w(this,G,`m`,Ja).call(this)}async finalText(){return await this.done(),w(this,G,`m`,Ya).call(this)}_emit(e,...t){if(w(this,Ba,`f`))return;e===`end`&&(C(this,Ba,!0,`f`),w(this,Ra,`f`).call(this));let n=w(this,K,`f`)[e];if(n&&(w(this,K,`f`)[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),e===`abort`){let e=t[0];!w(this,Ua,`f`)&&!n?.length&&Promise.reject(e),w(this,Ia,`f`).call(this,e),w(this,za,`f`).call(this,e),this._emit(`end`);return}if(e===`error`){let e=t[0];!w(this,Ua,`f`)&&!n?.length&&Promise.reject(e),w(this,Ia,`f`).call(this,e),w(this,za,`f`).call(this,e),this._emit(`end`)}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit(`finalMessage`,w(this,G,`m`,Ja).call(this))}async _fromReadableStream(e,t){let n=t?.signal,r;n&&(n.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),n.addEventListener(`abort`,r));try{w(this,G,`m`,Za).call(this),this._connected(null);let t=Sn.fromReadableStream(e,this.controller);for await(let e of t)w(this,G,`m`,Qa).call(this,e);if(t.controller.signal?.aborted)throw new x;w(this,G,`m`,$a).call(this)}finally{n&&r&&n.removeEventListener(`abort`,r)}}[(Ma=new WeakMap,Na=new WeakMap,Pa=new WeakMap,Fa=new WeakMap,Ia=new WeakMap,La=new WeakMap,Ra=new WeakMap,za=new WeakMap,K=new WeakMap,Ba=new WeakMap,Va=new WeakMap,Ha=new WeakMap,Ua=new WeakMap,Wa=new WeakMap,Ga=new WeakMap,Ka=new WeakMap,qa=new WeakMap,Xa=new WeakMap,G=new WeakSet,Ja=function(){if(this.receivedMessages.length===0)throw new y(`stream ended without producing a Message with role=assistant`);return this.receivedMessages.at(-1)},Ya=function(){if(this.receivedMessages.length===0)throw new y(`stream ended without producing a Message with role=assistant`);let e=this.receivedMessages.at(-1).content.filter(e=>e.type===`text`).map(e=>e.text);if(e.length===0)throw new y(`stream ended without producing a content block with type=text`);return e.join(` `)},Za=function(){this.ended||C(this,Ma,void 0,`f`)},Qa=function(e){if(this.ended)return;let t=w(this,G,`m`,eo).call(this,e);switch(this._emit(`streamEvent`,e,t),e.type){case`content_block_delta`:{let n=t.content.at(-1);switch(e.delta.type){case`text_delta`:n.type===`text`&&this._emit(`text`,e.delta.text,n.text||``);break;case`citations_delta`:n.type===`text`&&this._emit(`citation`,e.delta.citation,n.citations??[]);break;case`input_json_delta`:if(no(n)&&w(this,K,`f`).inputJson?.length){let t;try{t=n.input}catch(e){w(this,Xa,`f`).call(this,w(this,G,`m`,to).call(this,n,e));break}this._emit(`inputJson`,e.delta.partial_json,t)}break;case`thinking_delta`:n.type===`thinking`&&this._emit(`thinking`,e.delta.thinking,n.thinking);break;case`signature_delta`:n.type===`thinking`&&this._emit(`signature`,n.signature);break;case`compaction_delta`:n.type===`compaction`&&n.content&&this._emit(`compaction`,n.content);break;default:e.delta}break}case`message_stop`:this._addMessageParam(t),this._addMessage(Sa(t,w(this,Na,`f`),{logger:w(this,qa,`f`)}),!0);break;case`content_block_stop`:this._emit(`contentBlock`,t.content.at(-1));break;case`message_start`:C(this,Ma,t,`f`)}},$a=function(){if(this.ended)throw new y(`stream has ended, this shouldn't happen`);let e=w(this,Ma,`f`);if(!e)throw new y(`request ended without sending any chunks`);return C(this,Ma,void 0,`f`),Sa(e,w(this,Na,`f`),{logger:w(this,qa,`f`)})},eo=function(e){let t=w(this,Ma,`f`);if(e.type===`message_start`){if(t)throw new y(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(!t)throw new y(`Unexpected event order, got ${e.type} before "message_start"`);switch(e.type){case`message_stop`:return t;case`message_delta`:return t.stop_reason=e.delta.stop_reason,t.stop_sequence=e.delta.stop_sequence,t.stop_details=e.delta.stop_details,t.usage.output_tokens=e.usage.output_tokens,e.delta.container!=null&&(t.container=e.delta.container),e.context_management!=null&&(t.context_management=e.context_management),e.input_transformations!=null&&(t.input_transformations=e.input_transformations),e.usage.input_tokens!=null&&(t.usage.input_tokens=e.usage.input_tokens),e.usage.cache_creation_input_tokens!=null&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),e.usage.cache_read_input_tokens!=null&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),e.usage.server_tool_use!=null&&(t.usage.server_tool_use=e.usage.server_tool_use),e.usage.iterations!=null&&(t.usage.iterations=e.usage.iterations),e.usage.fallback_credit!=null&&(t.usage.fallback_credit=e.usage.fallback_credit),e.usage.output_tokens_details!=null&&(t.usage.output_tokens_details=e.usage.output_tokens_details),t;case`content_block_start`:return t.content.push(e.content_block),e.content_block.type===`fallback`&&(t.model=e.content_block.to.model),t;case`content_block_delta`:{let n=t.content.at(e.index);switch(e.delta.type){case`text_delta`:n?.type===`text`&&(t.content[e.index]={...n,text:(n.text||``)+e.delta.text});break;case`citations_delta`:n?.type===`text`&&(t.content[e.index]={...n,citations:[...n.citations??[],e.delta.citation]});break;case`input_json_delta`:if(n&&no(n)){let r=(n.__json_buf||``)+e.delta.partial_json;t.content[e.index]=ja(n,r)}break;case`thinking_delta`:n?.type===`thinking`&&(t.content[e.index]={...n,thinking:n.thinking+e.delta.thinking});break;case`signature_delta`:n?.type===`thinking`&&(t.content[e.index]={...n,signature:e.delta.signature});break;case`compaction_delta`:if(n?.type===`compaction`){let r={...n,content:e.delta.content};`encrypted_content`in e.delta&&(r.encrypted_content=e.delta.encrypted_content),t.content[e.index]=r}break;default:e.delta}return t}case`content_block_stop`:{let n=t.content.at(e.index);if(n&&no(n)&&`__json_buf`in n){let e;try{e=n.input}catch(t){e={},w(this,Xa,`f`).call(this,w(this,G,`m`,to).call(this,n,t))}Object.defineProperty(n,"input",{value:e,enumerable:!0,configurable:!0,writable:!0})}return t}}},to=function(e,t){let n=e[Aa];return new y(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${t}. JSON: ${n}`)},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`streamEvent`,n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on(`end`,()=>{n=!0;for(let e of t)e.resolve(void 0);t.length=0}),this.on(`abort`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),this.on(`error`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Sn(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}return e})(),io,ao,oo,so,co,lo,uo,fo,po,mo,ho,go=(()=>{class e extends ro{constructor(e,t){super(e),io.add(this),ao.set(this,void 0),oo.set(this,0),so.set(this,[]),co.set(this,[]),lo.set(this,void 0),uo.set(this,[]),fo.set(this,!1),C(this,ao,t,`f`)}get toolCalls(){return w(this,co,`f`)}static start(t,n,r,i){let a=new e({...n,stream:!0},i);for(let e of n.messages)a._addMessageParam(e);return a._run(()=>a._createMessage(t,{...n,stream:!0},{...r,headers:{...r?.headers,[mr]:`stream`}})),a}_emit(e,...t){var n;if(e!==`streamEvent`||this.ended){super._emit(e,...t);return}C(this,oo,(n=w(this,oo,`f`),n++,n),`f`);let[r,i]=t,a=r.type===`content_block_stop`?i.content[r.index]:void 0,o=a?.type===`tool_use`?a:void 0;o&&w(this,co,`f`).push(o),super._emit(e,...t),w(this,io,`m`,po).call(this,r,o),w(this,io,`m`,mo).call(this)}[(ao=new WeakMap,oo=new WeakMap,so=new WeakMap,co=new WeakMap,lo=new WeakMap,uo=new WeakMap,fo=new WeakMap,io=new WeakSet,Symbol.asyncIterator)](){let e=super[Symbol.asyncIterator](),t={handled:w(this,oo,`f`)};w(this,so,`f`).push(t);let n=!1;return{next:async()=>{n&&(n=!1,t.handled++,w(this,io,`m`,mo).call(this));try{let r=await e.next();return n=!r.done,r.done&&w(this,io,`m`,ho).call(this,t),r}catch(e){throw w(this,io,`m`,ho).call(this,t),e}},return:async()=>{let n=e.return?.();return w(this,io,`m`,ho).call(this,t),await n??{value:void 0,done:!0}}}}}return po=function(e,t){if(w(this,fo,`f`))return;if(e.type===`content_block_start`&&e.content_block.type===`fallback`){C(this,fo,!0,`f`),C(this,lo,void 0,`f`);return}let n=e.type===`content_block_start`||e.type===`message_delta`&&e.delta.stop_reason===`tool_use`;w(this,lo,`f`)&&n&&(w(this,uo,`f`).push({toolUse:w(this,lo,`f`),event:w(this,oo,`f`)}),C(this,lo,void 0,`f`)),t&&C(this,lo,t,`f`)},mo=function(){if(this.errored||this.controller.signal.aborted)return;let e=Math.min(w(this,oo,`f`),...w(this,so,`f`).map(e=>e.handled));for(;w(this,uo,`f`)[0]&&w(this,uo,`f`)[0].event<=e;)w(this,ao,`f`).call(this,w(this,uo,`f`).shift().toolUse)},ho=function(e){let t=w(this,so,`f`).indexOf(e);t>=0&&(w(this,so,`f`).splice(t,1),w(this,io,`m`,mo).call(this))},e})();function _o(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}var q,vo,yo,J,Y,X,bo,xo,So,Co,Z,Q,wo,To,Eo,Do,Oo,ko,Ao,jo,Mo,No,Po,Fo,Io,Lo,Ro=(()=>{class e{constructor(e,t,n){q.add(this),this.client=e,vo.set(this,!1),yo.set(this,!1),J.set(this,void 0),Y.set(this,void 0),X.set(this,void 0),bo.set(this,void 0),xo.set(this,void 0),So.set(this,void 0),Co.set(this,0),Z.set(this,{status:`idle`}),Q.set(this,void 0),wo.set(this,null),To.set(this,new Map),Eo.set(this,[]),zo(t),Bo(t),Vo(t),C(this,J,{params:{...t,messages:JSON.parse(JSON.stringify(t.messages))}},`f`);let r=vr(t.tools,t.messages);C(this,Y,{...n,headers:I([hr(`BetaToolRunner`),r.length?{[pr]:r.join(`, `)}:void 0,n?.headers])},`f`),C(this,So,_o(),`f`)}async*[(vo=new WeakMap,yo=new WeakMap,J=new WeakMap,Y=new WeakMap,X=new WeakMap,bo=new WeakMap,xo=new WeakMap,So=new WeakMap,Co=new WeakMap,Z=new WeakMap,Q=new WeakMap,wo=new WeakMap,To=new WeakMap,Eo=new WeakMap,q=new WeakSet,Symbol.asyncIterator)](){var e;if(w(this,vo,`f`))throw new y(`Cannot iterate over a consumed stream`);C(this,vo,!0,`f`),C(this,yo,!0,`f`),C(this,xo,void 0,`f`);try{for(;;)try{if(w(this,J,`f`).params.max_iterations&&w(this,Co,`f`)>=w(this,J,`f`).params.max_iterations)break;if(w(this,q,`m`,Io).call(this),w(this,Z,`f`).status===`scheduled`&&Zo(w(this,wo,`f`))!==`resume`){yield*w(this,q,`m`,Ao).call(this,w(this,Z,`f`).config);continue}C(this,yo,!1,`f`),C(this,xo,void 0,`f`),C(this,Co,(e=w(this,Co,`f`),e++,e),`f`),C(this,X,void 0,`f`);let{max_iterations:t,runToolsEagerly:n,...r}=w(this,J,`f`).params;if(yield*w(this,q,`m`,Do).call(this,r),w(this,yo,`f`))C(this,wo,null,`f`);else{let e=await w(this,X,`f`),t=Zo(e.stop_reason);C(this,wo,e.stop_reason,`f`),w(this,J,`f`).params.messages.push({role:e.role,content:Ko(e.content)});let{container:n}=w(this,J,`f`).params;if(e.container&&(n==null?w(this,J,`f`).params.container=e.container.id:typeof n==`object`&&n.id==null&&(w(this,J,`f`).params.container={...n,id:e.container.id})),t===`stop`){yield*w(this,q,`m`,Po).call(this);break}if(t===`resume`)continue}let i=await w(this,q,`m`,Fo).call(this,w(this,J,`f`).params.messages.at(-1));if(i)w(this,J,`f`).params.messages.push(i);else if(!w(this,yo,`f`)){yield*w(this,q,`m`,Po).call(this);break}}finally{w(this,bo,`f`)?.abort(),C(this,bo,void 0,`f`)}if(await w(this,q,`m`,ko).call(this),!w(this,X,`f`))throw new y(`ToolRunner concluded without a message from the server`);w(this,So,`f`).resolve(await w(this,X,`f`))}catch(e){throw C(this,vo,!1,`f`),w(this,So,`f`).promise.catch(()=>{}),w(this,So,`f`).reject(e),C(this,So,_o(),`f`),e}}setMessagesParams(e){let t=typeof e==`function`?e(w(this,J,`f`).params):e;if(zo(t),Vo(t),w(this,Z,`f`).status!==`idle`&&Ho(t),w(this,Z,`f`).status===`in_flight`&&t.messages!==w(this,J,`f`).params.messages)throw new y(`Message params can't be changed while the conversation is being compacted, because the compaction response is about to replace them. Change them after this iteration instead.`);w(this,J,`f`).params=t,C(this,yo,!0,`f`),C(this,xo,void 0,`f`)}setRequestOptions(e){typeof e==`function`?C(this,Y,e(w(this,Y,`f`)),`f`):C(this,Y,{...w(this,Y,`f`),...e},`f`)}async generateToolResponse(e=w(this,Y,`f`).signal){let t=await w(this,X,`f`)??this.params.messages.at(-1);return t?w(this,q,`m`,Fo).call(this,t,e):null}deferToolCall(e){let t=typeof e==`string`?e:e.id;w(this,Q,`f`)&&!w(this,Q,`f`).has(t)&&w(this,Q,`f`).set(t,{status:`held`})}get deferredToolCalls(){let e=w(this,bo,`f`),t=w(this,Q,`f`);return!(e instanceof go)||!t?[]:e.toolCalls.filter(e=>t.get(e.id)?.status===`held`)}done(){return w(this,So,`f`).promise}async runUntilDone(){if(!w(this,vo,`f`))for await(let e of this);return this.done()}get params(){return w(this,J,`f`).params}pushMessages(...e){this.setMessagesParams(t=>({...t,messages:[...t.messages,...e]}))}compactBeforeNextTurn(e){w(this,Z,`f`).status!==`in_flight`&&(Ho(w(this,J,`f`).params),C(this,Z,{status:`scheduled`,config:e??{type:`summarize`}},`f`))}addTools(...e){for(let t of e)`name`in t&&w(this,To,`f`).set(t.name,`run`in t?t:null),w(this,Eo,`f`).push({type:`addition`,tool:t})}removeTools(...e){for(let t of e){let e=typeof t==`string`?t:t.name;w(this,To,`f`).set(e,null),w(this,Eo,`f`).push({type:`removal`,name:e})}}then(e,t){return this.runUntilDone().then(e,t)}}return Do=async function*(e){await w(this,q,`m`,ko).call(this),C(this,Q,void 0,`f`),e.stream?(C(this,bo,w(this,J,`f`).params.runToolsEagerly?w(this,q,`m`,Oo).call(this,e):this.client.beta.messages.stream({...e},w(this,Y,`f`)),`f`),C(this,X,w(this,bo,`f`).finalMessage(),`f`),w(this,X,`f`).catch(()=>{}),yield w(this,bo,`f`)):(C(this,X,this.client.beta.messages.create({...e,stream:!1},w(this,Y,`f`)),`f`),yield w(this,X,`f`))},Oo=function(e){let t=new Map;return C(this,Q,t,`f`),go.start(this.client.beta.messages,e,w(this,Y,`f`),e=>{if(t.has(e.id))return;let n=Go(w(this,q,`m`,jo).call(this),w(this,q,`m`,Mo).call(this),e,w(this,Y,`f`));n.catch(()=>{}),t.set(e.id,{status:`started`,result:n})})},ko=async function(){let e=[...w(this,Q,`f`)?.values()??[]].filter(e=>e.status===`started`);await Promise.allSettled(e.map(e=>e.result))},Ao=async function*(e){Ho(w(this,J,`f`).params);let{max_iterations:t,runToolsEagerly:n,...r}=w(this,J,`f`).params,i=Uo(r);C(this,Z,{status:`in_flight`},`f`),C(this,xo,void 0,`f`);let a=w(this,X,`f`);try{yield*w(this,q,`m`,Do).call(this,{...i,compaction:e});let t=await w(this,X,`f`);t.content.some(e=>e.type===`compaction`&&e.content)?(w(this,q,`m`,No).call(this),w(this,J,`f`).params.messages=[{role:t.role,content:t.content}]):(j(this.client).warn(`Compaction produced no summary; keeping the conversation as it is.`),C(this,X,a,`f`))}finally{C(this,Z,{status:`idle`},`f`)}},jo=function(){let e=new Map;for(let t of w(this,J,`f`).params.tools)`run`in t&&e.set(t.name,t);for(let[t,n]of w(this,To,`f`))n?e.set(t,n):e.delete(t);return e},Mo=function(){let e=new Set(w(this,q,`m`,jo).call(this).keys());for(let t of[...w(this,J,`f`).params.messages,w(this,q,`m`,Lo).call(this)])if(typeof t.content!=`string`){for(let n of t.content)if(t.role===`system`)Jo(n,e);else if(t.role===`assistant`&&n.type===`compaction`)for(let t of n.tool_changes??[])Jo(t,e)}return e},No=function(){let e=w(this,q,`m`,Mo).call(this);for(let t of w(this,q,`m`,jo).call(this).keys())e.has(t)||w(this,To,`f`).set(t,null)},Po=async function*(){if(w(this,Z,`f`).status!==`scheduled`)return;let e=w(this,J,`f`).params.messages.at(-1)?.content;if(Array.isArray(e)&&e.some(e=>e.type===`tool_use`)){j(this.client).warn("The pending compaction was skipped because the last turn ended with tool calls that were not run. Call `compactBeforeNextTurn()` again if you continue the conversation."),C(this,Z,{status:`idle`},`f`);return}yield*w(this,q,`m`,Ao).call(this,w(this,Z,`f`).config)},Fo=async function(e,t=w(this,Y,`f`).signal){return w(this,xo,`f`)===void 0&&C(this,xo,Wo(w(this,q,`m`,jo).call(this),w(this,q,`m`,Mo).call(this),e,{...w(this,Y,`f`),signal:t},w(this,Q,`f`)),`f`),w(this,xo,`f`)},Io=function(){w(this,wo,`f`)!==`pause_turn`&&w(this,Eo,`f`).length!==0&&(w(this,J,`f`).params.messages.push(w(this,q,`m`,Lo).call(this)),C(this,Eo,[],`f`))},Lo=function(){let e=[];for(let t of w(this,Eo,`f`)){if(t.type===`removal`){e.push({type:`tool_removal`,tool:{type:`tool_reference`,name:t.name}});continue}let n=t.tool;if(`run`in t.tool){let{run:e,parse:r,close:i,...a}=t.tool;n=a}e.push({type:`tool_addition`,tool:{type:`tool_definition`,definition:n}})}return{role:`system`,content:e}},e})();function zo(e){if(`compaction`in e&&e.compaction!=null)throw new y("`compaction` cannot be set on a tool runner: every request in the loop would compact again. Call `runner.compactBeforeNextTurn()` when the conversation should be compacted instead.")}function Bo(e){if(`compactionControl`in e&&e.compactionControl!=null)throw new y("`compactionControl` has been removed from the tool runner. Use server-side compaction instead: call `runner.compactBeforeNextTurn()` when the conversation should be compacted.")}function Vo(e){if(e.runToolsEagerly&&!e.stream)throw TypeError("`runToolsEagerly: true` needs `stream: true` in the tool runner's params, because a reply that isn't streamed arrives whole.")}function Ho(e){if(e.context_management?.edits?.some(e=>e.type.startsWith(`compact_`)))throw new y("`compactBeforeNextTurn()` can't be used while `context_management` has a compaction edit, because the API doesn't accept a compaction block together with one. Remove the edit first.")}function Uo(e){let{context_management:t,stop_sequences:n,output_format:r,...i}=e,a=({format:e,...t})=>t;return(i.tool_choice?.type===`any`||i.tool_choice?.type===`tool`)&&delete i.tool_choice,i.output_config&&=a(i.output_config),Array.isArray(i.fallbacks)&&(i.fallbacks=i.fallbacks.map(e=>e.output_config?{...e,output_config:a(e.output_config)}:e)),i}async function Wo(e,t,n,r,i){if(!n||n.role!==`assistant`||!n.content||typeof n.content==`string`)return null;let a=n.content.filter(e=>e.type===`tool_use`);return a.length===0?null:{role:`user`,content:await Promise.all(a.map(n=>{let a=i?.get(n.id);if(a?.status===`started`)return a.result;let o=Go(e,t,n,r);return i?.set(n.id,{status:`started`,result:o}),o}))}}async function Go(e,t,n,r){let i=t.has(n.name)?e.get(n.name):void 0;if(!i)return qo(n);try{let e=n.input;`parse`in i&&i.parse&&(e=i.parse(e));let t=await i.run(e,{toolUse:n,toolUseBlock:n,signal:r?.signal});return{type:`tool_result`,tool_use_id:n.id,content:t}}catch(e){return{type:`tool_result`,tool_use_id:n.id,content:e instanceof ci?e.content:`Error: ${e instanceof Error?e.message:String(e)}`,is_error:!0}}}function Ko(e){return e}function qo(e){return{type:`tool_result`,tool_use_id:e.id,content:`Error: Tool '${e.name}' not found`,is_error:!0}}function Jo(e,t){switch(e.type){case`tool_removal`:case`tool_addition`:Yo(e,t)}}function Yo(e,t){let n=Xo(e.tool);n!==void 0&&(e.type===`tool_removal`?t.delete(n):t.add(n))}function Xo(e){switch(e.type){case`tool_reference`:return e.name;case`tool_definition`:return`name`in e.definition?e.definition.name:void 0;default:return}}function Zo(e){if(e===null)return`stop`;switch(e){case`tool_use`:return`run_tools`;case`pause_turn`:case`compaction`:return`resume`;case`end_turn`:case`stop_sequence`:case`max_tokens`:case`model_context_window_exceeded`:case`refusal`:return`stop`;default:return`stop`}}var Qo={},$o=[`claude-mythos-preview`,`claude-opus-4-6`],es=(()=>{class e extends F{constructor(){super(...arguments),this.batches=new ya(this._client)}create(e,t){let n=ts(e),{betas:r,user_profile_id:i,workspace_id:a,...o}=n;o.model in Qo&&console.warn(`The model '${o.model}' is deprecated and will reach end-of-life on ${Qo[o.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),$o.includes(o.model)&&o.thinking&&o.thinking.type===`enabled`&&console.warn(`Using Claude with ${o.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let s=t?.timeout??this._client._options.timeout;if(!o.stream&&s==null){let e=ba[o.model]??void 0;s=this._client.calculateNonstreamingTimeout(o.max_tokens,e)}let c=yr(o.tools,o.messages);return this._client.post(`/v1/messages?beta=true`,{body:o,timeout:s??6e5,...t,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-user-profile-id":i},...a==null?void 0:{"anthropic-workspace-id":a}},c,t?.headers]),stream:n.stream??!1})}parse(e,t){return t={...t,headers:I([{"anthropic-beta":[...e.betas??[],`structured-outputs-2025-12-15`].toString()},t?.headers])},this.create(e,t).then(t=>Ca(t,e,{logger:this._client.logger??console}))}stream(e,t){return ro.createMessage(this,e,t)}countTokens(e,t){let{betas:n,user_profile_id:r,workspace_id:i,...a}=ts(e);return this._client.post(`/v1/messages/count_tokens?beta=true`,{body:a,...t,headers:I([{"anthropic-beta":[...n??[],`token-counting-2024-11-01`].toString(),...r==null?void 0:{"anthropic-user-profile-id":r},...i==null?void 0:{"anthropic-workspace-id":i}},t?.headers])})}toolRunner(e,t){return new Ro(this._client,e,t)}}return e.Batches=ya,e.BetaToolRunner=Ro,e.ToolError=ci,e})();function ts(e){if(!e.output_format)return e;if(e.output_config?.format)throw new y(`Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).`);let{output_format:t,...n}=e;return{...n,output_config:{...e.output_config,format:t}}}var ns=class extends F{retrieve(e,t){return this._client.get(L`/v1/organizations/api_keys/${e}?beta=true`,t)}update(e,t,n){return this._client.post(L`/v1/organizations/api_keys/${e}?beta=true`,{body:t,...n})}list(e={},t){return this._client.getAPIList(`/v1/organizations/api_keys?beta=true`,Bn,{query:e,...t})}},rs=class extends F{retrieve(e){return this._client.get(`/v1/organizations/compliance_settings?beta=true`,e)}update(e,t){return this._client.post(`/v1/organizations/compliance_settings?beta=true`,{body:e,...t})}},is=class extends F{create(e,t){return this._client.post(`/v1/organizations/external_keys?beta=true`,{body:e,...t})}retrieve(e,t){return this._client.get(L`/v1/organizations/external_keys/${e}?beta=true`,t)}update(e,t,n){return this._client.post(L`/v1/organizations/external_keys/${e}?beta=true`,{body:t,...n})}list(e={},t){return this._client.getAPIList(`/v1/organizations/external_keys?beta=true`,P,{query:e,...t})}delete(e,t){return this._client.delete(L`/v1/organizations/external_keys/${e}?beta=true`,t)}validate(e,t){return this._client.post(L`/v1/organizations/external_keys/${e}/validate?beta=true`,t)}},as=class extends F{create(e,t){return this._client.post(`/v1/organizations/invites?beta=true`,{body:e,...t})}retrieve(e,t){return this._client.get(L`/v1/organizations/invites/${e}?beta=true`,t)}list(e={},t){return this._client.getAPIList(`/v1/organizations/invites?beta=true`,Bn,{query:e,...t})}delete(e,t){return this._client.delete(L`/v1/organizations/invites/${e}?beta=true`,t)}},os=class extends F{list(e={},t){return this._client.getAPIList(`/v1/organizations/rate_limits?beta=true`,P,{query:e,...t})}},ss=class extends F{retrieve(e,t){return this._client.get(L`/v1/organizations/users/${e}?beta=true`,t)}update(e,t,n){return this._client.post(L`/v1/organizations/users/${e}?beta=true`,{body:t,...n})}list(e={},t){return this._client.getAPIList(`/v1/organizations/users?beta=true`,Bn,{query:e,...t})}remove(e,t){return this._client.delete(L`/v1/organizations/users/${e}?beta=true`,t)}},cs=class extends F{create(e,t){let{betas:n,...r}=e;return this._client.post(`/v1/organizations/federation_issuers?beta=true`,{body:r,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(L`/v1/organizations/federation_issuers/${e}?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}update(e,t,n){let{betas:r,...i}=t;return this._client.post(L`/v1/organizations/federation_issuers/${e}?beta=true`,{body:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/organizations/federation_issuers?beta=true`,P,{query:r,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}archive(e,t={},n){let{betas:r}=t??{};return this._client.post(L`/v1/organizations/federation_issuers/${e}/archive?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}},ls=class extends F{list(e,t={},n){let{betas:r,...i}=t??{};return this._client.getAPIList(L`/v1/organizations/federation_rules/${e}/workspaces?beta=true`,P,{query:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}add(e,t,n){let{betas:r,...i}=t;return this._client.post(L`/v1/organizations/federation_rules/${e}/workspaces?beta=true`,{body:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}remove(e,t,n){let{federation_rule_id:r,betas:i}=t;return this._client.delete(L`/v1/organizations/federation_rules/${r}/workspaces/${e}?beta=true`,{...n,headers:I([{...i?.toString()==null?void 0:{"anthropic-beta":i?.toString()}},n?.headers])})}},us=(()=>{class e extends F{constructor(){super(...arguments),this.workspaces=new ls(this._client)}create(e,t){let{betas:n,...r}=e;return this._client.post(`/v1/organizations/federation_rules?beta=true`,{body:r,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(L`/v1/organizations/federation_rules/${e}?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}update(e,t,n){let{betas:r,...i}=t;return this._client.post(L`/v1/organizations/federation_rules/${e}?beta=true`,{body:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/organizations/federation_rules?beta=true`,P,{query:r,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}archive(e,t={},n){let{betas:r}=t??{};return this._client.post(L`/v1/organizations/federation_rules/${e}/archive?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}}return e.Workspaces=ls,e})(),ds=(()=>{class e extends F{constructor(){super(...arguments),this.issuers=new cs(this._client),this.rules=new us(this._client)}}return e.Issuers=cs,e.Rules=us,e})(),fs=class extends F{list(e,t={},n){let{betas:r,...i}=t??{};return this._client.getAPIList(L`/v1/organizations/service_accounts/${e}/workspaces?beta=true`,P,{query:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}add(e,t,n){let{betas:r,...i}=t;return this._client.post(L`/v1/organizations/service_accounts/${e}/workspaces?beta=true`,{body:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}remove(e,t,n){let{service_account_id:r,betas:i}=t;return this._client.delete(L`/v1/organizations/service_accounts/${r}/workspaces/${e}?beta=true`,{...n,headers:I([{...i?.toString()==null?void 0:{"anthropic-beta":i?.toString()}},n?.headers])})}},ps=(()=>{class e extends F{constructor(){super(...arguments),this.workspaces=new fs(this._client)}create(e,t){let{betas:n,...r}=e;return this._client.post(`/v1/organizations/service_accounts?beta=true`,{body:r,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(L`/v1/organizations/service_accounts/${e}?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}update(e,t,n){let{betas:r,...i}=t;return this._client.post(L`/v1/organizations/service_accounts/${e}?beta=true`,{body:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/organizations/service_accounts?beta=true`,P,{query:r,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}archive(e,t={},n){let{betas:r}=t??{};return this._client.post(L`/v1/organizations/service_accounts/${e}/archive?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}}return e.Workspaces=fs,e})(),ms=class extends F{retrieve(e,t,n){let{workspace_id:r}=t;return this._client.get(L`/v1/organizations/workspaces/${r}/members/${e}?beta=true`,n)}update(e,t,n){let{workspace_id:r,...i}=t;return this._client.post(L`/v1/organizations/workspaces/${r}/members/${e}?beta=true`,{body:i,...n})}list(e,t={},n){return this._client.getAPIList(L`/v1/organizations/workspaces/${e}/members?beta=true`,Bn,{query:t,...n})}add(e,t,n){return this._client.post(L`/v1/organizations/workspaces/${e}/members?beta=true`,{body:t,...n})}remove(e,t,n){let{workspace_id:r}=t;return this._client.delete(L`/v1/organizations/workspaces/${r}/members/${e}?beta=true`,n)}},hs=class extends F{list(e,t={},n){return this._client.getAPIList(L`/v1/organizations/workspaces/${e}/rate_limits?beta=true`,P,{query:t,...n})}},gs=class extends F{retrieve(e,t,n){let{workspace_id:r,betas:i}=t;return this._client.get(L`/v1/organizations/workspaces/${r}/service_accounts/${e}?beta=true`,{...n,headers:I([{...i?.toString()==null?void 0:{"anthropic-beta":i?.toString()}},n?.headers])})}update(e,t,n){let{workspace_id:r,betas:i,...a}=t;return this._client.post(L`/v1/organizations/workspaces/${r}/service_accounts/${e}?beta=true`,{body:a,...n,headers:I([{...i?.toString()==null?void 0:{"anthropic-beta":i?.toString()}},n?.headers])})}list(e,t={},n){let{betas:r,...i}=t??{};return this._client.getAPIList(L`/v1/organizations/workspaces/${e}/service_accounts?beta=true`,P,{query:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}add(e,t,n){let{betas:r,...i}=t;return this._client.post(L`/v1/organizations/workspaces/${e}/service_accounts?beta=true`,{body:i,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}remove(e,t,n){let{workspace_id:r,betas:i}=t;return this._client.delete(L`/v1/organizations/workspaces/${r}/service_accounts/${e}?beta=true`,{...n,headers:I([{...i?.toString()==null?void 0:{"anthropic-beta":i?.toString()}},n?.headers])})}},_s=(()=>{class e extends F{constructor(){super(...arguments),this.rateLimits=new hs(this._client),this.members=new ms(this._client),this.serviceAccounts=new gs(this._client)}create(e,t){let{betas:n,...r}=e;return this._client.post(`/v1/organizations/workspaces?beta=true`,{body:r,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}retrieve(e,t){return this._client.get(L`/v1/organizations/workspaces/${e}?beta=true`,t)}update(e,t,n){return this._client.post(L`/v1/organizations/workspaces/${e}?beta=true`,{body:t,...n})}list(e={},t){return this._client.getAPIList(`/v1/organizations/workspaces?beta=true`,Bn,{query:e,...t})}archive(e,t){return this._client.post(L`/v1/organizations/workspaces/${e}/archive?beta=true`,t)}}return e.RateLimits=hs,e.Members=ms,e.ServiceAccounts=gs,e})(),vs=(()=>{class e extends F{constructor(){super(...arguments),this.apiKeys=new ns(this._client),this.externalKeys=new is(this._client),this.federation=new ds(this._client),this.invites=new as(this._client),this.serviceAccounts=new ps(this._client),this.users=new ss(this._client),this.workspaces=new _s(this._client),this.rateLimits=new os(this._client),this.complianceSettings=new rs(this._client)}retrieve(e){return this._client.get(`/v1/organizations/me?beta=true`,e)}}return e.APIKeys=ns,e.ExternalKeys=is,e.Federation=ds,e.Invites=as,e.ServiceAccounts=ps,e.Users=ss,e.Workspaces=_s,e.RateLimits=os,e.ComplianceSettings=rs,e})(),ys=(()=>{class e extends F{list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/sessions/${e}/events?beta=true`,P,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}send(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/sessions/${e}/events?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}stream(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.get(L`/v1/sessions/${e}/events/stream?beta=true`,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers]),stream:!0})}toolRunner(e,t){return new Ji(e,{...t,client:this._client})}}return e.SessionToolRunner=Ji,e})(),bs=class extends F{retrieve(e,t,n){let{session_id:r,betas:i,workspace_id:a}=t;return this._client.get(L`/v1/sessions/${r}/resources/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}update(e,t,n){let{session_id:r,betas:i,workspace_id:a,...o}=t;return this._client.post(L`/v1/sessions/${r}/resources/${e}?beta=true`,{body:o,...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/sessions/${e}/resources?beta=true`,P,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}delete(e,t,n){let{session_id:r,betas:i,workspace_id:a}=t;return this._client.delete(L`/v1/sessions/${r}/resources/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}add(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/sessions/${e}/resources?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}},xs=class extends F{list(e,t,n){let{session_id:r,betas:i,workspace_id:a,...o}=t;return this._client.getAPIList(L`/v1/sessions/${r}/threads/${e}/events?beta=true`,P,{query:o,...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}stream(e,t,n){let{session_id:r,betas:i,workspace_id:a,...o}=t;return this._client.get(L`/v1/sessions/${r}/threads/${e}/stream?beta=true`,{query:o,...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers]),stream:!0})}},Ss=(()=>{class e extends F{constructor(){super(...arguments),this.events=new xs(this._client)}retrieve(e,t,n){let{session_id:r,betas:i,workspace_id:a}=t;return this._client.get(L`/v1/sessions/${r}/threads/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/sessions/${e}/threads?beta=true`,P,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}archive(e,t,n){let{session_id:r,betas:i,workspace_id:a}=t;return this._client.post(L`/v1/sessions/${r}/threads/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}}return e.Events=xs,e})(),Cs=(()=>{class e extends F{constructor(){super(...arguments),this.events=new ys(this._client),this.resources=new bs(this._client),this.threads=new Ss(this._client)}create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/sessions?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/sessions/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}update(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/sessions/${e}?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/sessions?beta=true`,Vn,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}delete(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.delete(L`/v1/sessions/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}archive(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/sessions/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}}return e.Events=ys,e.Resources=bs,e.Threads=Ss,e})(),ws=class extends F{create(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/skills/${e}/versions?beta=true`,Kn({body:a,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])},this._client,!1))}retrieve(e,t,n){let{skill_id:r,betas:i,workspace_id:a}=t;return this._client.get(L`/v1/skills/${r}/versions/${e}?beta=true`,{...n,headers:I([{...i?.toString()==null?void 0:{"anthropic-beta":i?.toString()},...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/skills/${e}/versions?beta=true`,P,{query:a,...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}delete(e,t,n){let{skill_id:r,betas:i,workspace_id:a}=t;return this._client.delete(L`/v1/skills/${r}/versions/${e}?beta=true`,{...n,headers:I([{...i?.toString()==null?void 0:{"anthropic-beta":i?.toString()},...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}download(e,t,n){let{skill_id:r,betas:i,workspace_id:a}=t;return this._client.get(L`/v1/skills/${r}/versions/${e}/content?beta=true`,{...n,headers:I([{Accept:`application/binary`,...i?.toString()==null?void 0:{"anthropic-beta":i?.toString()},...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers]),__binaryResponse:!0})}},Ts=(()=>{class e extends F{constructor(){super(...arguments),this.versions=new ws(this._client)}create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/skills?beta=true`,Kn({body:i,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()},...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])},this._client,!1))}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/skills/${e}?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/skills?beta=true`,P,{query:i,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()},...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}delete(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.delete(L`/v1/skills/${e}?beta=true`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}}return e.Versions=ws,e})(),Es=class extends F{create(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/tunnels/${e}/certificates?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`mcp-tunnels-2026-06-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}retrieve(e,t,n){let{tunnel_id:r,betas:i,workspace_id:a}=t;return this._client.get(L`/v1/tunnels/${r}/certificates/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`mcp-tunnels-2026-06-22`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/tunnels/${e}/certificates?beta=true`,P,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`mcp-tunnels-2026-06-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}archive(e,t,n){let{tunnel_id:r,betas:i,workspace_id:a}=t;return this._client.post(L`/v1/tunnels/${r}/certificates/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`mcp-tunnels-2026-06-22`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}},Ds=(()=>{class e extends F{constructor(){super(...arguments),this.certificates=new Es(this._client)}create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/tunnels?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`mcp-tunnels-2026-06-22`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/tunnels/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`mcp-tunnels-2026-06-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/tunnels?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`mcp-tunnels-2026-06-22`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}archive(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/tunnels/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`mcp-tunnels-2026-06-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}revealToken(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/tunnels/${e}/reveal_token?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`mcp-tunnels-2026-06-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}rotateToken(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/tunnels/${e}/rotate_token?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`mcp-tunnels-2026-06-22`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}}return e.Certificates=Es,e})(),Os=class extends F{create(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/vaults/${e}/credentials?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}retrieve(e,t,n){let{vault_id:r,betas:i,workspace_id:a}=t;return this._client.get(L`/v1/vaults/${r}/credentials/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}update(e,t,n){let{vault_id:r,betas:i,workspace_id:a,...o}=t;return this._client.post(L`/v1/vaults/${r}/credentials/${e}?beta=true`,{body:o,...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}list(e,t={},n){let{betas:r,workspace_id:i,...a}=t??{};return this._client.getAPIList(L`/v1/vaults/${e}/credentials?beta=true`,P,{query:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}delete(e,t,n){let{vault_id:r,betas:i,workspace_id:a}=t;return this._client.delete(L`/v1/vaults/${r}/credentials/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}archive(e,t,n){let{vault_id:r,betas:i,workspace_id:a}=t;return this._client.post(L`/v1/vaults/${r}/credentials/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}mcpOAuthValidate(e,t,n){let{vault_id:r,betas:i,workspace_id:a}=t;return this._client.post(L`/v1/vaults/${r}/credentials/${e}/mcp_oauth_validate?beta=true`,{...n,headers:I([{"anthropic-beta":[...i??[],`managed-agents-2026-04-01`].toString(),...a==null?void 0:{"anthropic-workspace-id":a}},n?.headers])})}},ks=(()=>{class e extends F{constructor(){super(...arguments),this.credentials=new Os(this._client)}create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/vaults?beta=true`,{body:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/vaults/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}update(e,t,n){let{betas:r,workspace_id:i,...a}=t;return this._client.post(L`/v1/vaults/${e}?beta=true`,{body:a,...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/vaults?beta=true`,P,{query:i,...t,headers:I([{"anthropic-beta":[...n??[],`managed-agents-2026-04-01`].toString(),...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}delete(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.delete(L`/v1/vaults/${e}?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}archive(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.post(L`/v1/vaults/${e}/archive?beta=true`,{...n,headers:I([{"anthropic-beta":[...r??[],`managed-agents-2026-04-01`].toString(),...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}}return e.Credentials=Os,e})(),As=(()=>{class e extends F{constructor(){super(...arguments),this.models=new Sr(this._client),this.messages=new es(this._client),this.agents=new Ar(this._client),this.environments=new ma(this._client),this.sessions=new Cs(this._client),this.deployments=new dr(this._client),this.deploymentRuns=new ur(this._client),this.vaults=new ks(this._client),this.memoryStores=new _a(this._client),this.files=new xr(this._client),this.skills=new Ts(this._client),this.webhooks=new Or(this._client),this.userProfiles=new Cr(this._client),this.dreams=new fr(this._client),this.tunnels=new Ds(this._client),this.organization=new vs(this._client)}}return e.Models=Sr,e.Messages=es,e.Agents=Ar,e.Environments=ma,e.Sessions=Cs,e.Deployments=dr,e.DeploymentRuns=ur,e.Vaults=ks,e.MemoryStores=_a,e.Files=xr,e.Skills=Ts,e.Webhooks=Or,e.UserProfiles=Cr,e.Dreams=fr,e.Tunnels=Ds,e.Organization=vs,e})(),js=class extends F{create(e,t){let{betas:n,workspace_id:r,...i}=e;return this._client.post(`/v1/complete`,{body:i,timeout:this._client._options.timeout??6e5,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()},...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers]),stream:e.stream??!1})}},Ms=class extends F{list(e={},t){let{workspace_id:n,...r}=e??{};return this._client.getAPIList(`/v1/files`,P,{query:r,...t,headers:I([{...n==null?void 0:{"anthropic-workspace-id":n}},t?.headers])})}delete(e,t={},n){let{workspace_id:r}=t??{};return this._client.delete(L`/v1/files/${e}`,{...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])})}download(e,t={},n){let{workspace_id:r}=t??{};return this._client.get(L`/v1/files/${e}/content`,{...n,headers:I([{Accept:`application/binary`,...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers]),__binaryResponse:!0})}retrieveMetadata(e,t={},n){let{workspace_id:r}=t??{};return this._client.get(L`/v1/files/${e}`,{...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])})}upload(e,t){let{workspace_id:n,...r}=e;return this._client.post(`/v1/files`,Kn({body:r,...t,headers:I([{...n==null?void 0:{"anthropic-workspace-id":n}},br(r.file),t?.headers])},this._client))}};function Ns(e){return e?.output_config?.format}function Ps(e,t,n){let r=Ns(t);return!t||!(`parse`in(r??{}))?{...e,content:e.content.map(e=>e.type===`text`?Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1}):e),parsed_output:null}:Fs(e,t,n)}function Fs(e,t,n){let r=null,i=e.content.map(e=>{if(e.type===`text`){let n=Is(t,e.text);return r===null&&(r=n),Object.defineProperty({...e},"parsed_output",{value:n,enumerable:!1})}return e});return{...e,content:i,parsed_output:r}}function Is(e,t){let n=Ns(e);if(n?.type!==`json_schema`)return null;try{return`parse`in n?n.parse(t):JSON.parse(t)}catch(e){throw new y(`Failed to parse structured output: ${e}`)}}var $,Ls,Rs,zs,Bs,Vs,Hs,Us,Ws,Gs,Ks,qs,Js,Ys,Xs,Zs,Qs,$s,ec,tc,nc,rc,ic,ac,oc;function sc(e){return e.type===`tool_use`||e.type===`server_tool_use`}var cc=(()=>{class e{constructor(e,t){$.add(this),this.messages=[],this.receivedMessages=[],Ls.set(this,void 0),Rs.set(this,null),this.controller=new AbortController,zs.set(this,void 0),Bs.set(this,()=>{}),Vs.set(this,()=>{}),Hs.set(this,void 0),Us.set(this,()=>{}),Ws.set(this,()=>{}),Gs.set(this,{}),Ks.set(this,!1),qs.set(this,!1),Js.set(this,!1),Ys.set(this,!1),Xs.set(this,void 0),Zs.set(this,void 0),Qs.set(this,void 0),$s.set(this,void 0),nc.set(this,e=>{if(C(this,qs,!0,`f`),b(e)&&(e=new x),e instanceof x)return C(this,Js,!0,`f`),this._emit(`abort`,e);if(e instanceof y)return this._emit(`error`,e);if(e instanceof Error){let t=new y(e.message);return t.cause=e,this._emit(`error`,t)}return this._emit(`error`,new y(String(e)))}),C(this,zs,new Promise((e,t)=>{C(this,Bs,e,`f`),C(this,Vs,t,`f`)}),`f`),C(this,Hs,new Promise((e,t)=>{C(this,Us,e,`f`),C(this,Ws,t,`f`)}),`f`),w(this,zs,`f`).catch(()=>{}),w(this,Hs,`f`).catch(()=>{}),C(this,Rs,e,`f`),C(this,$s,t?.logger??console,`f`)}get response(){return w(this,Xs,`f`)}get request_id(){return w(this,Zs,`f`)}get workspace_id(){return w(this,Qs,`f`)}async withResponse(){C(this,Ys,!0,`f`);let e=await w(this,zs,`f`);if(!e)throw Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get(`request-id`),workspace_id:e.headers.get(`anthropic-workspace-id`)}}static fromReadableStream(t){let n=new e(null);return n._run(()=>n._fromReadableStream(t)),n}static createMessage(t,n,r,{logger:i}={}){let a=new e(n,{logger:i});for(let e of n.messages)a._addMessageParam(e);return C(a,Rs,{...n,stream:!0},`f`),a._run(()=>a._createMessage(t,{...n,stream:!0},{...r,headers:{...r?.headers,[mr]:`stream`}})),a}_run(e){e().then(()=>{this._emitFinal(),this._emit(`end`)},w(this,nc,`f`))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit(`message`,e)}async _createMessage(e,t,n){let r=n?.signal,i;r&&(r.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),r.addEventListener(`abort`,i));try{w(this,$,`m`,rc).call(this);let{response:r,data:i}=await e.create({...t,stream:!0},{...n,signal:this.controller.signal}).withResponse();this._connected(r);for await(let e of i)w(this,$,`m`,ic).call(this,e);if(i.controller.signal?.aborted)throw new x;w(this,$,`m`,ac).call(this)}finally{r&&i&&r.removeEventListener(`abort`,i)}}_connected(e){this.ended||(C(this,Xs,e,`f`),C(this,Zs,e?.headers.get(`request-id`),`f`),C(this,Qs,e?.headers.get(`anthropic-workspace-id`),`f`),w(this,Bs,`f`).call(this,e),this._emit(`connect`))}get ended(){return w(this,Ks,`f`)}get errored(){return w(this,qs,`f`)}get aborted(){return w(this,Js,`f`)}abort(){this.controller.abort()}on(e,t){return(w(this,Gs,`f`)[e]||(w(this,Gs,`f`)[e]=[])).push({listener:t}),this}off(e,t){let n=w(this,Gs,`f`)[e];if(!n)return this;let r=n.findIndex(e=>e.listener===t);return r>=0&&n.splice(r,1),this}once(e,t){return(w(this,Gs,`f`)[e]||(w(this,Gs,`f`)[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{C(this,Ys,!0,`f`),e!==`error`&&this.once(`error`,n),this.once(e,t)})}async done(){C(this,Ys,!0,`f`),await w(this,Hs,`f`)}get currentMessage(){return w(this,Ls,`f`)}async finalMessage(){return await this.done(),w(this,$,`m`,ec).call(this)}async finalText(){return await this.done(),w(this,$,`m`,tc).call(this)}_emit(e,...t){if(w(this,Ks,`f`))return;e===`end`&&(C(this,Ks,!0,`f`),w(this,Us,`f`).call(this));let n=w(this,Gs,`f`)[e];if(n&&(w(this,Gs,`f`)[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),e===`abort`){let e=t[0];!w(this,Ys,`f`)&&!n?.length&&Promise.reject(e),w(this,Vs,`f`).call(this,e),w(this,Ws,`f`).call(this,e),this._emit(`end`);return}if(e===`error`){let e=t[0];!w(this,Ys,`f`)&&!n?.length&&Promise.reject(e),w(this,Vs,`f`).call(this,e),w(this,Ws,`f`).call(this,e),this._emit(`end`)}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit(`finalMessage`,w(this,$,`m`,ec).call(this))}async _fromReadableStream(e,t){let n=t?.signal,r;n&&(n.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),n.addEventListener(`abort`,r));try{w(this,$,`m`,rc).call(this),this._connected(null);let t=Sn.fromReadableStream(e,this.controller);for await(let e of t)w(this,$,`m`,ic).call(this,e);if(t.controller.signal?.aborted)throw new x;w(this,$,`m`,ac).call(this)}finally{n&&r&&n.removeEventListener(`abort`,r)}}[(Ls=new WeakMap,Rs=new WeakMap,zs=new WeakMap,Bs=new WeakMap,Vs=new WeakMap,Hs=new WeakMap,Us=new WeakMap,Ws=new WeakMap,Gs=new WeakMap,Ks=new WeakMap,qs=new WeakMap,Js=new WeakMap,Ys=new WeakMap,Xs=new WeakMap,Zs=new WeakMap,Qs=new WeakMap,$s=new WeakMap,nc=new WeakMap,$=new WeakSet,ec=function(){if(this.receivedMessages.length===0)throw new y(`stream ended without producing a Message with role=assistant`);return this.receivedMessages.at(-1)},tc=function(){if(this.receivedMessages.length===0)throw new y(`stream ended without producing a Message with role=assistant`);let e=this.receivedMessages.at(-1).content.filter(e=>e.type===`text`).map(e=>e.text);if(e.length===0)throw new y(`stream ended without producing a content block with type=text`);return e.join(` `)},rc=function(){this.ended||C(this,Ls,void 0,`f`)},ic=function(e){if(this.ended)return;let t=w(this,$,`m`,oc).call(this,e);switch(this._emit(`streamEvent`,e,t),e.type){case`content_block_delta`:{let n=t.content.at(-1);switch(e.delta.type){case`text_delta`:n.type===`text`&&this._emit(`text`,e.delta.text,n.text||``);break;case`citations_delta`:n.type===`text`&&this._emit(`citation`,e.delta.citation,n.citations??[]);break;case`input_json_delta`:sc(n)&&w(this,Gs,`f`).inputJson?.length&&this._emit(`inputJson`,e.delta.partial_json,n.input);break;case`thinking_delta`:n.type===`thinking`&&this._emit(`thinking`,e.delta.thinking,n.thinking);break;case`signature_delta`:n.type===`thinking`&&this._emit(`signature`,n.signature);break;default:e.delta}break}case`message_stop`:this._addMessageParam(t),this._addMessage(Ps(t,w(this,Rs,`f`),{logger:w(this,$s,`f`)}),!0);break;case`content_block_stop`:this._emit(`contentBlock`,t.content.at(-1));break;case`message_start`:C(this,Ls,t,`f`)}},ac=function(){if(this.ended)throw new y(`stream has ended, this shouldn't happen`);let e=w(this,Ls,`f`);if(!e)throw new y(`request ended without sending any chunks`);return C(this,Ls,void 0,`f`),Ps(e,w(this,Rs,`f`),{logger:w(this,$s,`f`)})},oc=function(e){let t=w(this,Ls,`f`);if(e.type===`message_start`){if(t)throw new y(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(!t)throw new y(`Unexpected event order, got ${e.type} before "message_start"`);switch(e.type){case`message_stop`:return t;case`message_delta`:return t.stop_reason=e.delta.stop_reason,t.stop_sequence=e.delta.stop_sequence,t.stop_details=e.delta.stop_details,t.usage.output_tokens=e.usage.output_tokens,e.delta.container!=null&&(t.container=e.delta.container),e.usage.input_tokens!=null&&(t.usage.input_tokens=e.usage.input_tokens),e.usage.cache_creation_input_tokens!=null&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),e.usage.cache_read_input_tokens!=null&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),e.usage.server_tool_use!=null&&(t.usage.server_tool_use=e.usage.server_tool_use),e.usage.output_tokens_details!=null&&(t.usage.output_tokens_details=e.usage.output_tokens_details),t;case`content_block_start`:return t.content.push({...e.content_block}),t;case`content_block_delta`:{let n=t.content.at(e.index);switch(e.delta.type){case`text_delta`:n?.type===`text`&&(t.content[e.index]={...n,text:(n.text||``)+e.delta.text});break;case`citations_delta`:n?.type===`text`&&(t.content[e.index]={...n,citations:[...n.citations??[],e.delta.citation]});break;case`input_json_delta`:if(n&&sc(n)){let r=(n.__json_buf||``)+e.delta.partial_json;t.content[e.index]=ja(n,r)}break;case`thinking_delta`:n?.type===`thinking`&&(t.content[e.index]={...n,thinking:n.thinking+e.delta.thinking});break;case`signature_delta`:n?.type===`thinking`&&(t.content[e.index]={...n,signature:e.delta.signature});break;default:e.delta}return t}case`content_block_stop`:{let n=t.content.at(e.index);return n&&sc(n)&&`__json_buf`in n&&Object.defineProperty(n,"input",{value:n.input,enumerable:!0,configurable:!0,writable:!0}),t}}},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`streamEvent`,n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on(`end`,()=>{n=!0;for(let e of t)e.resolve(void 0);t.length=0}),this.on(`abort`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),this.on(`error`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Sn(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}return e})(),lc=class extends F{create(e,t){let{user_profile_id:n,workspace_id:r,...i}=e;return this._client.post(`/v1/messages/batches`,{body:i,...t,headers:I([{...n==null?void 0:{"anthropic-user-profile-id":n},...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}retrieve(e,t={},n){let{workspace_id:r}=t??{};return this._client.get(L`/v1/messages/batches/${e}`,{...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])})}list(e={},t){let{workspace_id:n,...r}=e??{};return this._client.getAPIList(`/v1/messages/batches`,Bn,{query:r,...t,headers:I([{...n==null?void 0:{"anthropic-workspace-id":n}},t?.headers])})}delete(e,t={},n){let{workspace_id:r}=t??{};return this._client.delete(L`/v1/messages/batches/${e}`,{...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])})}cancel(e,t={},n){let{workspace_id:r}=t??{};return this._client.post(L`/v1/messages/batches/${e}/cancel`,{...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])})}async results(e,t={},n){let r=await this.retrieve(e,t,n);if(!r.results_url)throw new y(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`);let{workspace_id:i}=t??{};return this._client.get(r.results_url,{...n,headers:I([{Accept:`application/binary`,...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>va.fromResponse(t.response,t.controller))}},uc=(()=>{class e extends F{constructor(){super(...arguments),this.batches=new lc(this._client)}create(e,t){let{user_profile_id:n,workspace_id:r,...i}=e;i.model in dc&&console.warn(`The model '${i.model}' is deprecated and will reach end-of-life on ${dc[i.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),fc.includes(i.model)&&i.thinking&&i.thinking.type===`enabled`&&console.warn(`Using Claude with ${i.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let a=t?.timeout??this._client._options.timeout;if(!i.stream&&a==null){let e=ba[i.model]??void 0;a=this._client.calculateNonstreamingTimeout(i.max_tokens,e)}let o=yr(i.tools,i.messages);return this._client.post(`/v1/messages`,{body:i,timeout:a??6e5,...t,headers:I([{...n==null?void 0:{"anthropic-user-profile-id":n},...r==null?void 0:{"anthropic-workspace-id":r}},o,t?.headers]),stream:e.stream??!1})}parse(e,t){return this.create(e,t).then(t=>Fs(t,e,{logger:this._client.logger??console}))}stream(e,t){return cc.createMessage(this,e,t,{logger:this._client.logger??console})}countTokens(e,t){let{user_profile_id:n,workspace_id:r,...i}=e;return this._client.post(`/v1/messages/count_tokens`,{body:i,...t,headers:I([{...n==null?void 0:{"anthropic-user-profile-id":n},...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}}return e.Batches=lc,e})(),dc={},fc=[`claude-mythos-preview`,`claude-opus-4-6`],pc=class extends F{retrieve(e,t={},n){let{betas:r,workspace_id:i}=t??{};return this._client.get(L`/v1/models/${e}`,{...n,headers:I([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()},...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e={},t){let{betas:n,workspace_id:r,...i}=e??{};return this._client.getAPIList(`/v1/models`,Bn,{query:i,...t,headers:I([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()},...r==null?void 0:{"anthropic-workspace-id":r}},t?.headers])})}},mc=class extends F{create(e,t,n){let{workspace_id:r,...i}=t;return this._client.post(L`/v1/skills/${e}/versions`,Kn({body:i,...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])},this._client,!1))}retrieve(e,t,n){let{skill_id:r,workspace_id:i}=t;return this._client.get(L`/v1/skills/${r}/versions/${e}`,{...n,headers:I([{...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}list(e,t={},n){let{workspace_id:r,...i}=t??{};return this._client.getAPIList(L`/v1/skills/${e}/versions`,P,{query:i,...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])})}delete(e,t,n){let{skill_id:r,workspace_id:i}=t;return this._client.delete(L`/v1/skills/${r}/versions/${e}`,{...n,headers:I([{...i==null?void 0:{"anthropic-workspace-id":i}},n?.headers])})}},hc=(()=>{class e extends F{constructor(){super(...arguments),this.versions=new mc(this._client)}create(e,t){let{workspace_id:n,...r}=e;return this._client.post(`/v1/skills`,Kn({body:r,...t,headers:I([{...n==null?void 0:{"anthropic-workspace-id":n}},t?.headers])},this._client,!1))}retrieve(e,t={},n){let{workspace_id:r}=t??{};return this._client.get(L`/v1/skills/${e}`,{...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])})}list(e={},t){let{workspace_id:n,...r}=e??{};return this._client.getAPIList(`/v1/skills`,P,{query:r,...t,headers:I([{...n==null?void 0:{"anthropic-workspace-id":n}},t?.headers])})}delete(e,t={},n){let{workspace_id:r}=t??{};return this._client.delete(L`/v1/skills/${e}`,{...n,headers:I([{...r==null?void 0:{"anthropic-workspace-id":r}},n?.headers])})}}return e.Versions=mc,e})(),gc,_c,vc,yc,bc=`\\n\\nHuman:`,xc=`\\n\\nAssistant:`,Sc=(()=>{class e{get credentials(){return this._authState.provider}constructor({baseURL:e=A(`ANTHROPIC_BASE_URL`),apiKey:t,authToken:n,webhookKey:r=A(`ANTHROPIC_WEBHOOK_SIGNING_KEY`)??null,...i}={}){if(gc.add(this),this._requestAuthFlags=new WeakMap,vc.set(this,void 0),t===void 0&&(t=i.profile==null?A(`ANTHROPIC_API_KEY`)??null:null),n===void 0&&(n=i.profile==null?A(`ANTHROPIC_AUTH_TOKEN`)??null:null),i.profile!=null&&(i.credentials!=null||i.config!=null))throw TypeError("Pass at most one of `profile`, `credentials`, or `config`.");let a={apiKey:t,authToken:n,webhookKey:r,...i,baseURL:e||`https://api.anthropic.com`};if(!a.dangerouslyAllowBrowser&&Re())throw new y(`It looks like you're running in a browser-like environment.
8
8
 
9
9
  This is disabled by default, as it risks exposing your secret API credentials to attackers.
10
10
  If you understand the risks and have appropriate mitigations in place,