wrong-notebook 2026.11.1 → 2026.11.2-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +1 -0
- package/.next/build-manifest.json +3 -3
- package/.next/prerender-manifest.json +3 -3
- package/.next/routes-manifest.json +6 -0
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/admin/page.js.nft.json +1 -1
- package/.next/server/app/admin/page_client-reference-manifest.js +1 -1
- package/.next/server/app/admin/user/[id]/page.js.nft.json +1 -1
- package/.next/server/app/admin/user/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/api/admin/cnm-tags/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/admin/cnm-tags/route/build-manifest.json +12 -0
- package/.next/server/app/api/admin/cnm-tags/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/admin/cnm-tags/route.js +12 -0
- package/.next/server/app/api/admin/cnm-tags/route.js.map +5 -0
- package/.next/server/app/api/admin/cnm-tags/route.js.nft.json +1 -0
- package/.next/server/app/api/admin/cnm-tags/route_client-reference-manifest.js +3 -0
- package/.next/server/app/api/admin/dashboard/route.js +10 -10
- package/.next/server/app/api/admin/dashboard/route.js.nft.json +1 -1
- package/.next/server/app/api/admin/debug-logs/export/route.js.nft.json +1 -1
- package/.next/server/app/api/admin/debug-logs/route.js.nft.json +1 -1
- package/.next/server/app/api/admin/migrate-tags/route.js.nft.json +1 -1
- package/.next/server/app/api/admin/system-reset/route.js.nft.json +1 -1
- package/.next/server/app/api/admin/users/[id]/detail/route.js +10 -10
- package/.next/server/app/api/admin/users/[id]/detail/route.js.nft.json +1 -1
- package/.next/server/app/api/admin/users/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/admin/users/route.js.nft.json +1 -1
- package/.next/server/app/api/ai/models/route.js +4 -4
- package/.next/server/app/api/ai/models/route.js.nft.json +1 -1
- package/.next/server/app/api/ai/test/route.js +8 -8
- package/.next/server/app/api/ai/test/route.js.nft.json +1 -1
- package/.next/server/app/api/analytics/route.js +8 -8
- package/.next/server/app/api/analytics/route.js.nft.json +1 -1
- package/.next/server/app/api/analyze/route.js +4 -4
- package/.next/server/app/api/analyze/route.js.nft.json +1 -1
- package/.next/server/app/api/auth/[...nextauth]/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/delete/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/figure/route.js +10 -10
- package/.next/server/app/api/error-items/[id]/figure/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/fix-latex/route.js +7 -7
- package/.next/server/app/api/error-items/[id]/fix-latex/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/geogebra/route.js +13 -13
- package/.next/server/app/api/error-items/[id]/geogebra/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/image/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/notes/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/practice-records/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/reanswer/route.js +10 -10
- package/.next/server/app/api/error-items/[id]/reanswer/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/retag/route.js +9 -9
- package/.next/server/app/api/error-items/[id]/retag/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/svg-animation/narration/route.js +10 -10
- package/.next/server/app/api/error-items/[id]/svg-animation/narration/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/svg-animation/route.js +10 -10
- package/.next/server/app/api/error-items/[id]/svg-animation/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/batch-delete/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/clear/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/list/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/route.js +11 -11
- package/.next/server/app/api/error-items/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/short/[shortId]/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/similarity/route.js.nft.json +1 -1
- package/.next/server/app/api/exams/[id]/questions/[questionId]/regenerate/route.js +13 -13
- package/.next/server/app/api/exams/[id]/questions/[questionId]/regenerate/route.js.nft.json +1 -1
- package/.next/server/app/api/exams/[id]/results/route.js +10 -10
- package/.next/server/app/api/exams/[id]/results/route.js.nft.json +1 -1
- package/.next/server/app/api/exams/[id]/retry/route.js +9 -9
- package/.next/server/app/api/exams/[id]/retry/route.js.nft.json +1 -1
- package/.next/server/app/api/exams/[id]/route.js +13 -13
- package/.next/server/app/api/exams/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/exams/route.js +12 -12
- package/.next/server/app/api/exams/route.js.nft.json +1 -1
- package/.next/server/app/api/export/route.js.nft.json +1 -1
- package/.next/server/app/api/geogebra-analyze/route.js +6 -6
- package/.next/server/app/api/geogebra-analyze/route.js.nft.json +1 -1
- package/.next/server/app/api/health/route.js.nft.json +1 -1
- package/.next/server/app/api/import/route.js +13 -13
- package/.next/server/app/api/import/route.js.nft.json +1 -1
- package/.next/server/app/api/initialize/route.js.nft.json +1 -1
- package/.next/server/app/api/logs/frontend/route.js.nft.json +1 -1
- package/.next/server/app/api/minimax-code/checkin/route.js.nft.json +1 -1
- package/.next/server/app/api/minimax-code/login/route.js.nft.json +1 -1
- package/.next/server/app/api/minimax-code/route.js.nft.json +1 -1
- package/.next/server/app/api/notebooks/[id]/retag/route.js +12 -12
- package/.next/server/app/api/notebooks/[id]/retag/route.js.nft.json +1 -1
- package/.next/server/app/api/notebooks/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/notebooks/route.js.nft.json +1 -1
- package/.next/server/app/api/openclaw/batch-upload/route.js +8 -8
- package/.next/server/app/api/openclaw/batch-upload/route.js.nft.json +1 -1
- package/.next/server/app/api/paper-groups/[id]/route.js +1 -1
- package/.next/server/app/api/paper-groups/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/paper-groups/route.js.nft.json +1 -1
- package/.next/server/app/api/practice/generate/route.js +9 -9
- package/.next/server/app/api/practice/generate/route.js.nft.json +1 -1
- package/.next/server/app/api/practice/grade/route.js +6 -6
- package/.next/server/app/api/practice/grade/route.js.nft.json +1 -1
- package/.next/server/app/api/practice/record/[id]/route.js +10 -10
- package/.next/server/app/api/practice/record/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/practice/record/route.js +10 -10
- package/.next/server/app/api/practice/record/route.js.nft.json +1 -1
- package/.next/server/app/api/reanswer/route.js +4 -4
- package/.next/server/app/api/reanswer/route.js.nft.json +1 -1
- package/.next/server/app/api/register/route.js.nft.json +1 -1
- package/.next/server/app/api/register/status/route.js.nft.json +1 -1
- package/.next/server/app/api/requests/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/review/due/route.js +8 -8
- package/.next/server/app/api/review/due/route.js.nft.json +1 -1
- package/.next/server/app/api/settings/route.js.nft.json +1 -1
- package/.next/server/app/api/setup/route.js.nft.json +1 -1
- package/.next/server/app/api/stats/practice/clear/route.js.nft.json +1 -1
- package/.next/server/app/api/stats/practice/route.js.nft.json +1 -1
- package/.next/server/app/api/tags/route.js.nft.json +1 -1
- package/.next/server/app/api/tags/stats/route.js.nft.json +1 -1
- package/.next/server/app/api/tags/suggestions/route.js.nft.json +1 -1
- package/.next/server/app/api/tasks/route.js.nft.json +1 -1
- package/.next/server/app/api/tts/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/tts/batch/route.js +6 -6
- package/.next/server/app/api/tts/batch/route.js.nft.json +1 -1
- package/.next/server/app/api/tts/route.js +5 -5
- package/.next/server/app/api/tts/route.js.nft.json +1 -1
- package/.next/server/app/api/tts/status/route.js +4 -4
- package/.next/server/app/api/tts/status/route.js.nft.json +1 -1
- package/.next/server/app/api/user/route.js +9 -9
- package/.next/server/app/api/user/route.js.nft.json +1 -1
- package/.next/server/app/api/version/route.js.nft.json +1 -1
- package/.next/server/app/error-items/[id]/page.js.nft.json +1 -1
- package/.next/server/app/error-items/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/exams/[id]/page.js.nft.json +1 -1
- package/.next/server/app/exams/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/exams/[id]/print/page.js.nft.json +1 -1
- package/.next/server/app/exams/[id]/print/page_client-reference-manifest.js +1 -1
- package/.next/server/app/exams/page.js.nft.json +1 -1
- package/.next/server/app/exams/page_client-reference-manifest.js +1 -1
- package/.next/server/app/initialize/page.js.nft.json +1 -1
- package/.next/server/app/initialize/page_client-reference-manifest.js +1 -1
- package/.next/server/app/login/page.js.nft.json +1 -1
- package/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/server/app/notebooks/[id]/add/page.js.nft.json +1 -1
- package/.next/server/app/notebooks/[id]/add/page_client-reference-manifest.js +1 -1
- package/.next/server/app/notebooks/[id]/page.js.nft.json +1 -1
- package/.next/server/app/notebooks/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/notebooks/page.js.nft.json +1 -1
- package/.next/server/app/notebooks/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/practice/page.js.nft.json +1 -1
- package/.next/server/app/practice/page_client-reference-manifest.js +1 -1
- package/.next/server/app/print-preview/page.js.nft.json +1 -1
- package/.next/server/app/print-preview/page_client-reference-manifest.js +1 -1
- package/.next/server/app/register/page.js.nft.json +1 -1
- package/.next/server/app/register/page_client-reference-manifest.js +1 -1
- package/.next/server/app/review/page.js.nft.json +1 -1
- package/.next/server/app/review/page_client-reference-manifest.js +1 -1
- package/.next/server/app/setup/page.js.nft.json +1 -1
- package/.next/server/app/setup/page_client-reference-manifest.js +1 -1
- package/.next/server/app/stats/page.js.nft.json +1 -1
- package/.next/server/app/stats/page_client-reference-manifest.js +1 -1
- package/.next/server/app/tags/page.js.nft.json +1 -1
- package/.next/server/app/tags/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +1 -0
- package/.next/server/chunks/[root-of-the-server]__02dkbynj2vxld._.js +1 -1
- package/.next/server/chunks/{[root-of-the-server]__0z24ffpp1rsf3._.js → [root-of-the-server]__08t21dbk1cidn._.js} +1 -1
- package/.next/server/chunks/[root-of-the-server]__09jqnx_673l93._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0_uvtfu0yr-na._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0nujsu6qbn-8o._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0tflqqgyujt1r._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__13_k7w8nrx7ie._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__18z_cczwqkonn._.js +1 -1
- package/.next/server/chunks/{[root-of-the-server]__0rpqerm37sl_v._.js → [root-of-the-server]__1f_lrxzw_n-6-._.js} +1 -1
- package/.next/server/chunks/[root-of-the-server]__1ptzu7aqoga2n._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__1r0s6pktkiqkf._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__1r_x7moz0opqt._.js +3 -0
- package/.next/server/chunks/{[root-of-the-server]__1mfrik5p09lu9._.js → [root-of-the-server]__1sggr1m3ukvts._.js} +1 -1
- package/.next/server/chunks/[root-of-the-server]__1v1p83o4ygnyt._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__1wh65tfd7apxx._.js +3 -0
- package/.next/server/chunks/_0dicq393_0h3i._.js +3 -0
- package/.next/server/chunks/{_0jgk7kwvf4_6i._.js → _0x3jdlmx-bey5._.js} +1 -1
- package/.next/server/chunks/_10tpt8iizl4v3._.js +3 -3
- package/.next/server/chunks/_1dvka-waihfum._.js +3 -3
- package/.next/server/chunks/_1yujnc0thk8ab._.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_admin_cnm-tags_route_actions_1en5m631bmjfo.js +3 -0
- package/.next/server/chunks/src_lib_0r67kyyoh6ky6._.js +1 -1
- package/.next/server/chunks/src_lib_1_m3-y2t3e4xi._.js +46 -42
- package/.next/server/chunks/src_lib_1geq39r7va9gy._.js +1 -1
- package/.next/server/chunks/src_lib_logger_ts_1a0ve505bb0y2._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__0fy6mc47ccfce._.js +1 -1
- package/.next/server/chunks/ssr/_02zfjls23g-o4._.js +1 -1
- package/.next/server/chunks/ssr/_09y2uhjubswp4._.js +1 -1
- package/.next/server/chunks/ssr/_0cmd1ubdlo_by._.js +1 -1
- package/.next/server/chunks/ssr/_0ltqx22v65imo._.js +1 -1
- package/.next/server/chunks/ssr/_0lzeodofsq9pe._.js +1 -1
- package/.next/server/chunks/ssr/_0ozptnii2nxuw._.js +1 -1
- package/.next/server/chunks/ssr/_0rd-teluypcd2._.js +1 -1
- package/.next/server/chunks/ssr/_0tr-7klbcz1r7._.js +3 -0
- package/.next/server/chunks/ssr/_0xsd7dy2sxg53._.js +3 -0
- package/.next/server/chunks/ssr/_1-i5cy964i_s9._.js +3 -0
- package/.next/server/chunks/ssr/_12toteu0ut39i._.js +3 -0
- package/.next/server/chunks/ssr/_1cc3psc9rvrwn._.js +1 -1
- package/.next/server/chunks/ssr/_1qgg_ll5hkjaf._.js +2 -2
- package/.next/server/chunks/ssr/_1ux6eqqkupo6v._.js +2 -2
- package/.next/server/chunks/ssr/node_modules_lucide-react_dist_esm_icons_play_mjs_1al5hft92dlrg._.js +1 -1
- package/.next/server/chunks/ssr/src_1gayunqs8u2e2._.js +1 -1
- package/.next/server/chunks/ssr/src_app_admin_page_tsx_0ublbd0w90cx_._.js +1 -1
- package/.next/server/chunks/ssr/src_app_admin_user_[id]_page_tsx_0zidp-8hr5upa._.js +1 -1
- package/.next/server/chunks/ssr/src_app_error-items_[id]_page_tsx_04xwwdmyh7_9q._.js +1 -1
- package/.next/server/chunks/ssr/src_app_exams_[id]_page_tsx_0xcjflkgkwzgd._.js +1 -1
- package/.next/server/chunks/ssr/src_app_exams_[id]_print_page_tsx_1i-xvhk8ul1l1._.js +9 -9
- package/.next/server/chunks/ssr/src_app_exams_page_tsx_17_d4_gy2i1ds._.js +1 -1
- package/.next/server/chunks/ssr/src_app_notebooks_[id]_add_page_tsx_179tow1ql6vc_._.js +1 -1
- package/.next/server/chunks/ssr/src_app_notebooks_[id]_page_tsx_08njm-5-txm8_._.js +1 -1
- package/.next/server/chunks/ssr/src_app_notebooks_page_tsx_1p9src5gnz_40._.js +1 -1
- package/.next/server/chunks/ssr/src_app_page_tsx_1chiuahujsxm1._.js +1 -1
- package/.next/server/chunks/ssr/src_app_practice_page_tsx_10gnx53v3kpzb._.js +1 -1
- package/.next/server/chunks/ssr/src_app_print-preview_page_tsx_001yt-fzrj7tf._.js +1 -1
- package/.next/server/chunks/ssr/src_app_register_page_tsx_0l87b3754fa2j._.js +1 -1
- package/.next/server/chunks/ssr/src_app_review_page_tsx_1rq4ygvo_szv0._.js +1 -1
- package/.next/server/chunks/ssr/src_app_setup_page_tsx_0szlnxow_9skp._.js +1 -1
- package/.next/server/chunks/ssr/src_components_1od0rowgu8w6v._.js +1 -1
- package/.next/server/chunks/ssr/src_components_create-notebook-dialog_tsx_0c5teagim70r7._.js +1 -1
- package/.next/server/chunks/ssr/src_components_mastery-panel_tsx_1--j5c7mhomdp._.js +1 -1
- package/.next/server/chunks/ssr/src_components_print-preview_answer-space-control_tsx_02kuswyxklzp_._.js +33 -0
- package/.next/server/chunks/ssr/src_components_providers_tsx_09kw-mv3nb6xs._.js +73 -17
- package/.next/server/chunks/ssr/src_components_tag-input_tsx_0b9sxffna5c9i._.js +1 -1
- package/.next/server/chunks/ssr/src_lib_api-client_ts_04r2_ex-gua5i._.js +1 -1
- package/.next/server/chunks/ssr/src_lib_short-id-client_ts_1v7n6pg50kguj._.js +1 -1
- package/.next/server/middleware-build-manifest.js +3 -3
- package/.next/server/pages/500.html +1 -1
- package/.next/server/preview-props.json +3 -3
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/{42p60iwe4ayfi.js → 06bfusm1eqhzt.js} +1 -1
- package/.next/static/chunks/{1oqx_8e83xfjr.js → 0fu1xttg42yzk.js} +1 -1
- package/.next/static/chunks/{1wq7na8axxyfd.js → 0nq5_ne_bugdp.js} +1 -1
- package/.next/static/chunks/0xuzdy0dn7jkp.js +63 -0
- package/.next/static/chunks/{1dyf1qqv2ckxs.js → 1-00icoq9w3_i.js} +1 -1
- package/.next/static/chunks/{2r4x8vhlmc092.js → 1b5jj8zk0mtzk.js} +1 -1
- package/.next/static/chunks/{3fohh6i-hrda9.js → 1d-3q230sjpsa.js} +1 -1
- package/.next/static/chunks/{1gvev34tv39bd.js → 1fa2xv93zl8oj.js} +1 -1
- package/.next/static/chunks/{370c45nip4mld.js → 1g13qcek7-0du.js} +1 -1
- package/.next/static/chunks/1iixgyplm7q17.js +247 -0
- package/.next/static/chunks/{10xs8eu3rd2lt.js → 1ou17klnb8gu_.js} +1 -1
- package/.next/static/chunks/{1sjf69friyuwh.js → 1pdlii0oox0-7.js} +1 -1
- package/.next/static/chunks/{26-0j9v7hswqr.js → 1rzk5q74nsv73.js} +1 -1
- package/.next/static/chunks/{25emavlvjqnb_.js → 1sisl9ld-ag-o.js} +2 -2
- package/.next/static/chunks/{2hihgd7vu8tw5.js → 1z_0hbg6kxv58.js} +1 -1
- package/.next/static/chunks/{41j6vve1unchm.js → 2cfz0fumc6ghe.js} +1 -1
- package/.next/static/chunks/2dml0yrklxocr.js +31 -0
- package/.next/static/chunks/{2p9s6dcxnj129.js → 2e0fqyqddz02g.js} +1 -1
- package/.next/static/chunks/{2qvnb2d_gv2o5.js → 2huy9i-dnxshq.js} +1 -1
- package/.next/static/chunks/{2h1-bjeib7r-u.js → 2mu8zu6zd59z2.js} +1 -1
- package/.next/static/chunks/{09z8ds-9g-ble.js → 2urhwgx3nt7lq.js} +1 -1
- package/.next/static/chunks/{1c36uw_9rc8oc.js → 2xibor-sxcc67.js} +1 -1
- package/.next/static/chunks/3-7dqhvzmyl4y.css +3 -0
- package/.next/static/chunks/{31pvc0nv10j93.js → 3-w46lg1a_qse.js} +1 -1
- package/.next/static/chunks/{0zj83pnid72u3.js → 34lp-hkkywd8r.js} +1 -1
- package/.next/static/chunks/37d6vrdascsro.js +1 -0
- package/.next/static/chunks/{0lwd5-772ng4i.js → 3difxy8vzqlxn.js} +1 -1
- package/.next/static/chunks/3zs0fu6zcu0lb.js +1 -0
- package/dist-scripts/src/lib/debug-log.js +6 -6
- package/package.json +1 -1
- package/prisma/seed.db +0 -0
- package/.next/server/chunks/ssr/_037_l3ca0s_0m._.js +0 -3
- package/.next/server/chunks/ssr/_0_snnfou-vj50._.js +0 -3
- package/.next/server/chunks/ssr/_19-9r85m2zwkm._.js +0 -3
- package/.next/server/chunks/ssr/_1b5bo2mgv9_4a._.js +0 -3
- package/.next/static/chunks/0i1q2hqzk7ojc.css +0 -3
- package/.next/static/chunks/24mest-vas-bu.js +0 -33
- package/.next/static/chunks/2ju2bi0z49pn1.js +0 -1
- package/.next/static/chunks/2rx6yjo9suvmj.js +0 -1
- package/.next/static/chunks/2zgqd5dt_6z_7.js +0 -1
- package/.next/static/chunks/3cyz6w014ooxj.js +0 -191
- /package/.next/static/{6sBeEDpD-TPpDMfiFpz9K → RjcLZuifR9iENqJ77CSYI}/_buildManifest.js +0 -0
- /package/.next/static/{6sBeEDpD-TPpDMfiFpz9K → RjcLZuifR9iENqJ77CSYI}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{6sBeEDpD-TPpDMfiFpz9K → RjcLZuifR9iENqJ77CSYI}/_ssgManifest.js +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
module.exports=[[72749,(e,t,i)=>{var r,s=e.e&&e.e.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)});Object.defineProperty(i,"__esModule",{value:!0});var n=function(){function e(e){void 0===e&&(e="="),this._paddingCharacter=e}return e.prototype.encodedLength=function(e){return this._paddingCharacter?(e+2)/3*4|0:(8*e+5)/6|0},e.prototype.encode=function(e){for(var t="",i=0;i<e.length-2;i+=3){var r=e[i]<<16|e[i+1]<<8|e[i+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 s=e.length-i;if(s>0){var r=e[i]<<16|(2===s?e[i+1]<<8:0);t+=this._encodeByte(r>>>18&63),t+=this._encodeByte(r>>>12&63),2===s?t+=this._encodeByte(r>>>6&63):t+=this._paddingCharacter||"",t+=this._paddingCharacter||""}return t},e.prototype.maxDecodedLength=function(e){return this._paddingCharacter?e/4*3|0:(6*e+7)/8|0},e.prototype.decodedLength=function(e){return this.maxDecodedLength(e.length-this._getPaddingLength(e))},e.prototype.decode=function(e){if(0===e.length)return new Uint8Array(0);for(var t=this._getPaddingLength(e),i=e.length-t,r=new Uint8Array(this.maxDecodedLength(i)),s=0,n=0,a=0,o=0,l=0,c=0,u=0;n<i-4;n+=4)o=this._decodeChar(e.charCodeAt(n+0)),l=this._decodeChar(e.charCodeAt(n+1)),c=this._decodeChar(e.charCodeAt(n+2)),u=this._decodeChar(e.charCodeAt(n+3)),r[s++]=o<<2|l>>>4,r[s++]=l<<4|c>>>2,r[s++]=c<<6|u,a|=256&o,a|=256&l,a|=256&c,a|=256&u;if(n<i-1&&(o=this._decodeChar(e.charCodeAt(n)),l=this._decodeChar(e.charCodeAt(n+1)),r[s++]=o<<2|l>>>4,a|=256&o,a|=256&l),n<i-2&&(c=this._decodeChar(e.charCodeAt(n+2)),r[s++]=l<<4|c>>>2,a|=256&c),n<i-3&&(u=this._decodeChar(e.charCodeAt(n+3)),r[s++]=c<<6|u,a|=256&u),0!==a)throw Error("Base64Coder: incorrect characters for decoding");return r},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,String.fromCharCode(t+=62-e>>>8&3)},e.prototype._decodeChar=function(e){return 256+((42-e&e-44)>>>8&-256+e-43+62)+((46-e&e-48)>>>8&-256+e-47+63)+((47-e&e-58)>>>8&-256+e-48+52)+((64-e&e-91)>>>8&-256+e-65+0)+((96-e&e-123)>>>8&-256+e-97+26)},e.prototype._getPaddingLength=function(e){var t=0;if(this._paddingCharacter){for(var i=e.length-1;i>=0&&e[i]===this._paddingCharacter;i--)t++;if(e.length<4||t>2)throw Error("Base64Coder: incorrect padding")}return t},e}();i.Coder=n;var a=new n;i.encode=function(e){return a.encode(e)},i.decode=function(e){return a.decode(e)};var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return s(t,e),t.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,String.fromCharCode(t+=62-e>>>8&49)},t.prototype._decodeChar=function(e){return 256+((44-e&e-46)>>>8&-256+e-45+62)+((94-e&e-96)>>>8&-256+e-95+63)+((47-e&e-58)>>>8&-256+e-48+52)+((64-e&e-91)>>>8&-256+e-65+0)+((96-e&e-123)>>>8&-256+e-97+26)},t}(n);i.URLSafeCoder=o;var l=new o;i.encodeURLSafe=function(e){return l.encode(e)},i.decodeURLSafe=function(e){return l.decode(e)},i.encodedLength=function(e){return a.encodedLength(e)},i.maxDecodedLength=function(e){return a.maxDecodedLength(e)},i.decodedLength=function(e){return a.decodedLength(e)}},305518,(e,t,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Webhook=i.WebhookVerificationError=void 0;let r=e.r(72749),s=e.r(426900),n=e.r(182864);class a extends Error{constructor(e){super(e),Object.setPrototypeOf(this,a.prototype),this.name="ExtendableError",this.stack=Error(e).stack}}class o extends a{constructor(e){super(e),Object.setPrototypeOf(this,o.prototype),this.name="WebhookVerificationError"}}i.WebhookVerificationError=o;class l{constructor(e,t){if((null==t?void 0:t.format)==="raw")e instanceof Uint8Array?this.key=e:this.key=Uint8Array.from(e,e=>e.charCodeAt(0));else{if("string"!=typeof e)throw Error("Expected secret to be of type string");e.startsWith(l.prefix)&&(e=e.substring(l.prefix.length)),this.key=r.decode(e)}if(0===this.key.length)throw Error("Secret can't be empty.")}verify(e,t,i){var r;let s=null==(r=null==i?void 0:i.jsonParse)||r,a={};for(let e of Object.keys(t))a[e.toLowerCase()]=t[e];let l=a["webhook-id"],c=a["webhook-signature"],u=a["webhook-timestamp"];if(!c||!l||!u)throw new o("Missing required headers");let h=this.verifyTimestamp(u),d=this.sign(l,h,e).split(",")[1],p=c.split(" "),_=new globalThis.TextEncoder;for(let t of p){let[i,r]=t.split(",");if("v1"===i&&(0,n.timingSafeEqual)(_.encode(r),_.encode(d))){let t=e.toString();if(""===t)return;if(s)return JSON.parse(t);return}}throw new o("No matching signature found")}sign(e,t,i){if("string"==typeof i);else if("Buffer"===i.constructor.name)i=i.toString();else throw Error("Expected payload to be of type string or Buffer.");let n=new TextEncoder,a=Math.floor(t.getTime()/1e3),o=n.encode(`${e}.${a}.${i}`),l=r.encode(s.hmac(this.key,o));return`v1,${l}`}verifyTimestamp(e){let t=Math.floor(Date.now()/1e3),i=parseInt(e,10);if(Number.isNaN(i))throw new o("Invalid Signature Headers");if(t-i>300)throw new o("Message timestamp too old");if(i>t+300)throw new o("Message timestamp too new");return new Date(1e3*i)}}i.Webhook=l,l.prefix="whsec_"},182864,(e,t,i)=>{function r(e,t=""){if(!e)throw Error(t)}Object.defineProperty(i,"__esModule",{value:!0}),i.timingSafeEqual=function(e,t){if(e.byteLength!==t.byteLength)return!1;e instanceof DataView||(e=new DataView(ArrayBuffer.isView(e)?e.buffer:e)),t instanceof DataView||(t=new DataView(ArrayBuffer.isView(t)?t.buffer:t)),r(e instanceof DataView),r(t instanceof DataView);let i=e.byteLength,s=0,n=-1;for(;++n<i;)s|=e.getUint8(n)^t.getUint8(n);return 0===s}},690604,e=>{let t,i,r;var s,n,a,o,l,c,u,h,d,p,_,f,g,m,v,b,y,w,k,z,S,x,V,A,I,q,$,R,P,T,E,O,M,L,C,N,j,D,W,U,F,H,B,K,J,G,X,Y,Q,Z,ee,et,ei,er,es,en,ea,eo,el,ec,eu,eh,ed,ep,e_,ef,eg,em,ev,eb,ey,ew,ek,ez,eS,ex,eV,eA,eI,eq,e$,eR,eP,eT,eE,eO,eM,eL,eC,eN,ej,eD,eW,eU,eF,eH,eB,eK,eJ,eG,eX,eY,eQ,eZ,e0,e1,e2,e6,e4,e5,e8,e3,e9,e7,te,tt,ti,tr,ts,tn,ta,to,tl,tc,tu,th,td,tp,t_,tf,tg,tm,tv,tb,ty,tw,tk,tz,tS,tx,tV,tA,tI,tq,t$,tR,tP,tT,tE,tO,tM,tL,tC,tN,tj,tD,tW,tU,tF,tH,tB,tK,tJ,tG,tX,tY,tQ,tZ,t0,t1,t2,t6,t4,t5,t8,t3,t9,t7,ie,it,ii,ir,is,ia,io,il,ic,iu,ih,id=e.i(996155),ip=e.i(664219);let i_=(e,t)=>new Promise(i=>{if(t?.aborted)return i();let r=()=>{clearTimeout(s),i()},s=setTimeout(()=>{t?.removeEventListener("abort",r),i()},e);t?.addEventListener("abort",r,{once:!0})});var ig=e.i(150580);let im="1.3.0",iv=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",ib=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown",iy=()=>t??(t=(()=>{let e="u">typeof Deno&&null!=Deno.build?"deno":"u">typeof EdgeRuntime?"edge":"[object process]"===Object.prototype.toString.call(void 0!==globalThis.process?globalThis.process:0)?"node":"unknown";if("deno"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":im,"X-Stainless-OS":ib(Deno.build.os),"X-Stainless-Arch":iv(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:Deno.version?.deno??"unknown"};if("u">typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":im,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process?.version??"unknown"};if("node"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":im,"X-Stainless-OS":ib(globalThis.process.platform??"unknown"),"X-Stainless-Arch":iv(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let t=function(){if("u"<typeof navigator||!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 i=t.exec(navigator.userAgent);if(i){let t=i[1]||0,r=i[2]||0,s=i[3]||0;return{browser:e,version:`${t}.${r}.${s}`}}}return null}();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":im,"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":im,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}})()),iw=new WeakMap,ik="function"==typeof globalThis.FinalizationRegistry?new globalThis.FinalizationRegistry(e=>iz(e)):null;function iz(e){let t=iw.get(e);t&&(iw.delete(e),ik?.unregister(e),t())}function iS(...e){let t=globalThis.ReadableStream;if(void 0===t)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ix(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return iS({start(){},async pull(e){let{done:i,value:r}=await t.next();i?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}let iV="u"<typeof FinalizationRegistry?void 0:new FinalizationRegistry(async e=>{try{await e.return?.()}catch{}});async function*iA(e){let t=function(e){if(e[Symbol.asyncIterator])return e[Symbol.asyncIterator]();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}}}}(e),i={};iV?.register(i,t,i);try{for await(let e of{[Symbol.asyncIterator]:()=>t})yield e}finally{iV?.unregister(i)}}async function iI(e){if(null===e||"object"!=typeof e)return;if(e[Symbol.asyncIterator])return void await e[Symbol.asyncIterator]().return?.();let t=e.getReader(),i=t.cancel();t.releaseLock(),await i}let iq=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)}),i$="1.10.0",iR=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/,iP=function(e){let t=new Set([e]),i=new Set,r=e.match(iR);if(!r)return()=>!1;let s={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(null!=s.prerelease)return function(t){return t===e};function n(e){return i.add(e),!1}return function(e){if(t.has(e))return!0;if(i.has(e))return!1;let r=e.match(iR);if(!r)return n(e);let a={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(null!=a.prerelease||s.major!==a.major)return n(e);if(0===s.major)return s.minor===a.minor&&s.patch<=a.patch?(t.add(e),!0):n(e);return s.minor<=a.minor?(t.add(e),!0):n(e)}}(i$),iT=i$.split(".")[0],iE=Symbol.for(`opentelemetry.js.api.${iT}`),iO="object"==typeof globalThis?globalThis:"object"==typeof self?self:e.g;function iM(e,t,i,r=!1){var s;let n=iO[iE]=null!=(s=iO[iE])?s:Object.defineProperty({},"version",{value:i$,enumerable:!0,writable:!1,configurable:!1});if(!r&&n[e]){let t=Error(`@opentelemetry/api: Attempted duplicate registration of API: ${e}`);return i.error(t.stack||t.message),!1}if("1.10.0"!==n.version){let t=Error(`@opentelemetry/api: Registration of version v${n.version} for ${e} does not match previously registered API v${i$}`);return i.error(t.stack||t.message),!1}return n[e]=t,i.debug(`@opentelemetry/api: Registered a global for ${e} v${i$}.`),!0}function iL(e){let t=iO[iE];if(null!=t){if(t!==i){if(!t.version||!iP(t.version))return;i=t}return t[e]}}function iC(e,t){t.debug(`@opentelemetry/api: Unregistering a global for ${e} v${i$}.`);let i=iO[iE];i&&delete i[e]}var iN=class{constructor(e){this._namespace=e.namespace||"DiagComponentLogger"}debug(...e){return ij("debug",this._namespace,e)}error(...e){return ij("error",this._namespace,e)}info(...e){return ij("info",this._namespace,e)}warn(...e){return ij("warn",this._namespace,e)}verbose(...e){return ij("verbose",this._namespace,e)}};function ij(e,t,i){let r=iL("diag");if(r)return r[e](t,...i)}var iD=class e{static instance(){return this._instance||(this._instance=new e),this._instance}constructor(){function e(e){return function(...t){let i=iL("diag");if(i)return i[e](...t)}}let t=this;t.setLogger=(e,i={logLevel:60})=>{var r,s,n;if(e===t){let e=Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return t.error(null!=(s=e.stack)?s:e.message),!1}"number"==typeof i&&(i={logLevel:i});let a=iL("diag"),o=function(e,t){function i(i,r){let s=t[i];return"function"==typeof s&&e>=r?s.bind(t):function(){}}return e<0?e=0:e>9999&&(e=9999),t=t||{},{error:i("error",30),warn:i("warn",50),info:i("info",60),debug:i("debug",70),verbose:i("verbose",80)}}(null!=(r=i.logLevel)?r:60,e);if(a&&!i.suppressOverrideMessage){let e=null!=(n=(Error()).stack)?n:"<failed to generate stacktrace>";a.warn(`Current logger will be overwritten from ${e}`),o.warn(`Current logger will overwrite one already registered from ${e}`)}return iM("diag",o,t,!0)},t.disable=()=>{iC("diag",t)},t.createComponentLogger=e=>new iN(e),t.verbose=e("verbose"),t.debug=e("debug"),t.info=e("info"),t.warn=e("warn"),t.error=e("error")}};function iW(e){return Symbol.for(e)}let iU=new class e{constructor(t){let i=this;i._currentContext=t?new Map(t):new Map,i.getValue=e=>i._currentContext.get(e),i.setValue=(t,r)=>{let s=new e(i._currentContext);return s._currentContext.set(t,r),s},i.deleteValue=t=>{let r=new e(i._currentContext);return r._currentContext.delete(t),r}}},iF="context",iH=new class{active(){return iU}with(e,t,i,...r){return t.call(i,...r)}bind(e,t){return t}enable(){return this}disable(){return this}attach(e){return{dispose(){}}}},iB=Object.freeze({dispose:()=>{}});var iK=class e{constructor(){this._attachUnsupportedWarned=!1}static getInstance(){return this._instance||(this._instance=new e),this._instance}setGlobalContextManager(e){return iM(iF,e,iD.instance())}active(){return this._getContextManager().active()}with(e,t,i,...r){return this._getContextManager().with(e,t,i,...r)}bind(e,t){return this._getContextManager().bind(e,t)}attach(e){let t=this._getContextManager();return t.attach?t.attach(e):(this._attachUnsupportedWarned||(this._attachUnsupportedWarned=!0,iD.instance().warn("The current ContextManager does not implement attach(). The context will not be attached. Use a ContextManager that supports attach() (e.g. AsyncLocalStorageContextManager) or use with()/bind() instead.")),iB)}_getContextManager(){return iL(iF)||iH}disable(){this._getContextManager().disable(),iC(iF,iD.instance())}};let iJ=iK.getInstance();var iG=class e{constructor(e){this._entries=e?new Map(e):new Map}getEntry(e){let t=this._entries.get(e);if(t)return Object.assign({},t)}getAllEntries(){return Array.from(this._entries.entries())}setEntry(t,i){let r=new e(this._entries);return r._entries.set(t,i),r}removeEntry(t){let i=new e(this._entries);return i._entries.delete(t),i}removeEntries(...t){let i=new e(this._entries);for(let e of t)i._entries.delete(e);return i}clear(){return new e}};function iX(e={}){return new iG(new Map(Object.entries(e)))}Symbol("BaggageEntryMetadata"),iD.instance();let iY={get(e,t){if(null!=e)return e[t]},keys:e=>null==e?[]:Object.keys(e)},iQ={set(e,t,i){null!=e&&(e[t]=i)}},iZ=iW("OpenTelemetry Baggage Key");function i0(e){return e.getValue(iZ)||void 0}function i1(){return i0(iK.getInstance().active())}function i2(e,t){return e.setValue(iZ,t)}function i6(e){return e.deleteValue(iZ)}let i4="propagation",i5=new class{inject(e,t){}extract(e,t){return e}fields(){return[]}},i8=(class e{constructor(){this.createBaggage=iX,this.getBaggage=i0,this.getActiveBaggage=i1,this.setBaggage=i2,this.deleteBaggage=i6}static getInstance(){return this._instance||(this._instance=new e),this._instance}setGlobalPropagator(e){return iM(i4,e,iD.instance())}inject(e,t,i=iQ){return this._getGlobalPropagator().inject(e,t,i)}extract(e,t,i=iY){return this._getGlobalPropagator().extract(e,t,i)}fields(){return this._getGlobalPropagator().fields()}disable(){iC(i4,iD.instance())}_getGlobalPropagator(){return iL(i4)||i5}}).getInstance(),i3={traceId:"00000000000000000000000000000000",spanId:"0000000000000000",traceFlags:0};var i9=class{constructor(e=i3){this._spanContext=e}spanContext(){return this._spanContext}setAttribute(e,t){return this}setAttributes(e){return this}addEvent(e,t){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,t){}};let i7=iW("OpenTelemetry Context Key SPAN");function re(e){return e.getValue(i7)||void 0}function rt(){return re(iK.getInstance().active())}function ri(e,t){return e.setValue(i7,t)}function rr(e){return e.deleteValue(i7)}function rs(e,t){return ri(e,new i9(t))}function rn(e){var t;return null==(t=re(e))?void 0:t.spanContext()}let ra=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function ro(e,t){if("string"!=typeof e||e.length!==t)return!1;let i=0;for(let t=0;t<e.length;t+=4)i+=(0|ra[e.charCodeAt(t)])+(0|ra[e.charCodeAt(t+1)])+(0|ra[e.charCodeAt(t+2)])+(0|ra[e.charCodeAt(t+3)]);return i===t}function rl(e){var t,i;return ro(t=e.traceId,32)&&"00000000000000000000000000000000"!==t&&ro(i=e.spanId,16)&&"0000000000000000"!==i}function rc(e){return new i9(e)}let ru=iK.getInstance();var rh=class{startSpan(e,t,i=ru.active()){var r;if(null==t?void 0:t.root)return new i9;let s=i&&rn(i);return null!==(r=s)&&"object"==typeof r&&"spanId"in r&&"string"==typeof r.spanId&&"traceId"in r&&"string"==typeof r.traceId&&"traceFlags"in r&&"number"==typeof r.traceFlags&&rl(s)?new i9(s):new i9}startActiveSpan(e,t,i,r){var s;let n,a,o;if(arguments.length<2)return;2==arguments.length?o=t:3==arguments.length?(n=t,o=i):(n=t,a=i,o=r);let l=null!=(s=a)?s:ru.active(),c=this.startSpan(e,n,l),u=ri(l,c);return ru.with(u,o,void 0,c)}};let rd=new rh;var rp=class{constructor(e,t,i,r){this._provider=e,this.name=t,this.version=i,this.options=r}startSpan(e,t,i){return this._getTracer().startSpan(e,t,i)}startActiveSpan(e,t,i,r){let s=this._getTracer();return Reflect.apply(s.startActiveSpan,s,arguments)}_getTracer(){if(this._delegate)return this._delegate;let e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):rd}};let r_=new class{getTracer(e,t,i){return new rh}};var rf=class{getTracer(e,t,i){var r;return null!=(r=this.getDelegateTracer(e,t,i))?r:new rp(this,e,t,i)}getDelegate(){var e;return null!=(e=this._delegate)?e:r_}setDelegate(e){this._delegate=e}getDelegateTracer(e,t,i){var r;return null==(r=this._delegate)?void 0:r.getTracer(e,t,i)}};let rg="trace",rm=(class e{constructor(){this._proxyTracerProvider=new rf,this.wrapSpanContext=rc,this.isSpanContextValid=rl,this.deleteSpan=rr,this.getSpan=re,this.getActiveSpan=rt,this.getSpanContext=rn,this.setSpan=ri,this.setSpanContext=rs}static getInstance(){return this._instance||(this._instance=new e),this._instance}setGlobalTracerProvider(e){let t=iM(rg,this._proxyTracerProvider,iD.instance());return t&&this._proxyTracerProvider.setDelegate(e),t}getTracerProvider(){return iL(rg)||this._proxyTracerProvider}getTracer(e,t){return this.getTracerProvider().getTracer(e,t)}disable(){iC(rg,iD.instance()),this._proxyTracerProvider=new rf}}).getInstance(),rv=((s={})[s.INTERNAL=0]="INTERNAL",s[s.SERVER=1]="SERVER",s[s.CLIENT=2]="CLIENT",s[s.PRODUCER=3]="PRODUCER",s[s.CONSUMER=4]="CONSUMER",s),rb=((n={})[n.UNSET=0]="UNSET",n[n.OK=1]="OK",n[n.ERROR=2]="ERROR",n);var ry=e.i(364351),rw=e.i(687160),rk=(()=>{class e{constructor(){a.set(this,void 0),o.set(this,void 0),(0,id.b)(this,a,new Uint8Array,"f"),(0,id.b)(this,o,null,"f")}decode(e){let t;if(null==e)return[];let i=e instanceof ArrayBuffer?new Uint8Array(e):"string"==typeof e?(0,rw.b)(e):e;(0,id.b)(this,a,(0,rw.t)([(0,id.V)(this,a,"f"),i]),"f");let r=[];for(;null!=(t=function(e,t){for(let i=t??0;i<e.length;i++){if(10===e[i])return{preceding:i,index:i+1,carriage:!1};if(13===e[i])return{preceding:i,index:i+1,carriage:!0}}return null}((0,id.V)(this,a,"f"),(0,id.V)(this,o,"f")));){if(t.carriage&&null==(0,id.V)(this,o,"f")){(0,id.b)(this,o,t.index,"f");continue}if(null!=(0,id.V)(this,o,"f")&&(t.index!==(0,id.V)(this,o,"f")+1||t.carriage)){r.push((0,rw.z)((0,id.V)(this,a,"f").subarray(0,(0,id.V)(this,o,"f")-1))),(0,id.b)(this,a,(0,id.V)(this,a,"f").subarray((0,id.V)(this,o,"f")),"f"),(0,id.b)(this,o,null,"f");continue}let e=null!==(0,id.V)(this,o,"f")?t.preceding-1:t.preceding,i=(0,rw.z)((0,id.V)(this,a,"f").subarray(0,e));r.push(i),(0,id.b)(this,a,(0,id.V)(this,a,"f").subarray(t.index),"f"),(0,id.b)(this,o,null,"f")}return r}flush(){return(0,id.V)(this,a,"f").length?this.decode("\n"):[]}}return a=new WeakMap,o=new WeakMap,e.NEWLINE_CHARS=new Set(["\n","\r"]),e.NEWLINE_REGEXP=/\r\n|[\n\r]/g,e})(),rz=e.i(511935),rS=(()=>{class e{constructor(e,t,i){this.iterator=e,l.set(this,void 0),this.controller=t,(0,id.b)(this,l,i,"f")}static rawEvents(e,t=new AbortController){return rx(e,t)}static fromSSEResponse(t,i,r){let s=!1,n=r?(0,rz.u)(r):console;return new e(async function*(){if(s)throw new ry.v("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let e=!1;try{for await(let e of rx(t,i))if("ping"!==e.event&&null!==e.event)if("error"===e.event){let i=(0,ip.k)(e.data)??e.data,r=i?.error?.type;throw new ry.E(void 0,i,void 0,t.headers,r)}else{if(!e.data)continue;try{yield JSON.parse(e.data)}catch(t){throw n.error("Could not parse message into JSON:",e.data),n.error("From chunk:",e.raw),t}}e=!0}catch(e){if((0,ig.c)(e))return;throw e}finally{e||i.abort(),iz(i)}},i,r)}static fromReadableStream(t,i,r){let s=!1;async function*n(){let e=new rk;for await(let i of iA(t))for(let t of e.decode(i))yield t;for(let t of e.flush())yield t}return new e(async function*(){if(s)throw new ry.v("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let e=!1;try{for await(let t of n())!e&&t&&(yield JSON.parse(t));e=!0}catch(e){if((0,ig.c)(e))return;throw e}finally{e||i.abort(),iz(i)}},i,r)}[(l=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],i=[],r=this[Symbol.asyncIterator](),s=e=>({next:()=>{if(0===e.length){let e=r.next();t.push(e),i.push(e)}return e.shift()}});return[new e(()=>s(t),this.controller,(0,id.V)(this,l,"f")),new e(()=>s(i),this.controller,(0,id.V)(this,l,"f"))]}toReadableStream(){let e,t=this;return iS({async start(){e=t[Symbol.asyncIterator]()},async pull(t){try{let{value:i,done:r}=await e.next();if(r)return t.close();let s=(0,rw.b)(JSON.stringify(i)+"\n");t.enqueue(s)}catch(e){t.error(e)}},async cancel(){await e.return?.()}})}}return e})();async function*rx(e,t){if(!e.body){if(t.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new ry.v("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new ry.v("Attempted to iterate over a response with no body")}let i=new rV,r=new rk;for await(let t of iA(e.body))for(let e of r.decode(t)){let t=i.decode(e);t&&(yield t)}for(let e of r.flush()){let t=i.decode(e);t&&(yield t)}}class rV{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){var t;let i;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("\n"),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(":"))return null;let[r,s,n]=-1!==(i=(t=e).indexOf(":"))?[t.substring(0,i),":",t.substring(i+1)]:[t,"",""];return n.startsWith(" ")&&(n=n.substring(1)),"event"===r?this.event=n:"data"===r&&this.data.push(n),null}}let rA=Symbol.for("brand.privateNullableHeaders"),rI=Symbol("clear"),rq=new Set(["x-stainless-helper"]),r$=(e,t)=>{let i=e?e.split(",").map(e=>e.trim()).filter(Boolean):[];for(let e of t.split(",").map(e=>e.trim()))e&&!i.includes(e)&&i.push(e);return i.join(", ")},rR=e=>{let t=new Headers,i=new Set;for(let r of e){let e=new Set;for(let[s,n]of function*(e){let t;if(!e)return;if(rA in e){let{values:t,nulls:i}=e;for(let e of(yield*t.entries(),i))yield[e,null];return}let i=!1;for(let r of(e instanceof Headers?t=e.entries():(0,ip.z)(e)?t=e:(i=!0,t=Object.entries(e??{})),t)){let e=r[0];if("string"!=typeof e)throw TypeError("expected header name to be a string");let t=(0,ip.z)(r[1])?r[1]:[r[1]],s=!1;for(let r of t)void 0!==r&&(i&&!s&&(s=!0,yield[e,rI]),yield[e,r])}}(r)){let r=s.toLowerCase();if(rq.has(r)){if(n===rI)continue;null===n?(t.delete(s),i.add(r)):(t.set(s,r$(t.get(s),n)),i.delete(r));continue}(n!==rI&&e.has(r)||(t.delete(s),e.add(r),n!==rI))&&(null===n?(t.delete(s),i.add(r)):(t.append(s,n),i.delete(r)))}}return{[rA]:!0,values:t,nulls:i}};var rP=e.i(931963);let rT="com.anthropic.sdk.typescript",rE="gen_ai.conversation.id",rO="gen_ai.provider.name",rM="http.response.status_code";function rL(e,t){try{return t()}catch(t){e&&(0,rz.u)(e).debug("could not record telemetry",t);return}}function rC(e,t,i,r){if(i?.__span)return i.__span;let s=e._tracer;if(s)return rL(e,()=>{let n=Date.now(),a=r?.attributes?.["anthropic.session.thread.id"],o=i?.openTelemetry?.conversationId??("string"==typeof a?a:void 0),l=s.startSpan(t,{kind:rv.CLIENT,attributes:{[rO]:e._genAIProviderName,...function(e){try{let{hostname:t,port:i,protocol:r}=new URL(e);return{"server.address":t.replace(/^\[(.*)\]$/,"$1"),"server.port":i?Number(i):"http:"===r?80:443}}catch{return{}}}(e.baseURL),...null!=o?{[rE]:o}:void 0,...r?.route!=null?{"http.route":r.route}:void 0,...r?.attributes}});if(l.isRecording()||(e.openTelemetry.propagation?Object.keys(rU(l)).length>0:rm.isSpanContextValid(l.spanContext())))return{...r,span:l,name:t,startTime:n}})}let rN=["email","path_prefix","expected_content_sha256"];function rj(e,t){if(e.isRecording()){var i,r;let s;switch(i=e,r=t,void 0!==(s=r.response?.status??("error"===r.status&&r.error instanceof ry.E?r.error.status:void 0))&&i.setAttribute(rM,s),t.status){case"success":e.setStatus({code:rb.OK});break;case"error":rW(e,t.error)}e.end()}}function rD(e,t,i){let r=e[Symbol.asyncIterator],s=!1,n=e=>{if(!s){s=!0,t.removeEventListener("abort",a);try{i.onEnd(e)}catch{}}},a=()=>n({reason:"canceled"});if(t.aborted)return a();t.addEventListener("abort",a,{once:!0});let o=!1;e[Symbol.asyncIterator]=function(){let e=r.call(this);if(o)return e;o=!0,t.removeEventListener("abort",a);let l={async next(){let r;try{r=await e.next()}catch(e){throw n({reason:"failed",error:e}),e}if(r.done)n({reason:t.aborted?"canceled":"completed"});else if(!s)try{i.onItem?.(r.value)}catch{}return r},return:async t=>(a(),await e.return?.(t)??{done:!0,value:t}),async throw(t){if(a(),e.throw)return e.throw(t);throw t},[Symbol.asyncIterator]:()=>l};return l}}function rW(e,t,i){t instanceof ry.F||(0,ig.c)(t)||(e.setStatus({code:rb.ERROR}),e.setAttribute("error.type",i??function(e){if(e instanceof ry.R)return"client_timeout_error";if(e instanceof ry.I)return"connection_error";if(e instanceof ry.E){if(e.type)return e.type;if(void 0!==e.status)return String(e.status)}return"client_error"}(t)))}function rU(e){let t={};return i8.inject(rm.setSpan(iJ.active(),e),t),t}let rF="RFC3986",rH=e=>String(e),rB={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:rH},rK=(e,t)=>(rK=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty))(e,t),rJ=(()=>{let e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})();function rG(e,t){if((0,ip.o)(e)){let i=[];for(let r=0;r<e.length;r+=1)i.push(t(e[r]));return i}return t(e)}let rX={brackets:e=>String(e)+"[]",comma:"comma",indices:(e,t)=>String(e)+"["+t+"]",repeat:e=>String(e)},rY=function(e,t){Array.prototype.push.apply(e,(0,ip.o)(t)?t:[t])},rQ={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:(e,t,i,r,s)=>{if(0===e.length)return e;let n=e;if("symbol"==typeof e?n=Symbol.prototype.toString.call(e):"string"!=typeof e&&(n=String(e)),"iso-8859-1"===i)return escape(n).replace(/%u[0-9a-f]{4}/gi,function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"});let a="";for(let e=0;e<n.length;e+=1024){let t=n.length>=1024?n.slice(e,e+1024):n,i=[];for(let e=0;e<t.length;++e){let r=t.charCodeAt(e);if(45===r||46===r||95===r||126===r||r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||"RFC1738"===s&&(40===r||41===r)){i[i.length]=t.charAt(e);continue}if(r<128){i[i.length]=rJ[r];continue}if(r<2048){i[i.length]=rJ[192|r>>6]+rJ[128|63&r];continue}if(r<55296||r>=57344){i[i.length]=rJ[224|r>>12]+rJ[128|r>>6&63]+rJ[128|63&r];continue}e+=1,r=65536+((1023&r)<<10|1023&t.charCodeAt(e)),i[i.length]=rJ[240|r>>18]+rJ[128|r>>12&63]+rJ[128|r>>6&63]+rJ[128|63&r]}a+=i.join("")}return a},encodeValuesOnly:!1,format:rF,formatter:rH,indices:!1,serializeDate:e=>(r??(r=Function.prototype.call.bind(Date.prototype.toISOString)))(e),skipNulls:!1,strictNullHandling:!1},rZ={};var r0=ry;let r1="/v1/oauth/token",r2="oauth-2025-04-20";function r6(e){let t;if(!e)return;try{t=new URL(e)}catch(t){throw new se(`Invalid token endpoint base URL "${e}": ${t}`)}if("https:"===t.protocol)return;let i=t.hostname.toLowerCase().replace(/^\[|\]$/g,"");if("http:"!==t.protocol||"localhost"!==i&&"127.0.0.1"!==i&&"::1"!==i)throw new se(`Refusing to send credential over non-https token endpoint "${e}"`)}async function r4(e,t){let i,r=await r7(e);try{i=JSON.parse(r)}catch{throw new se(`Token endpoint returned non-JSON response (status ${e.status})`,e.status,r8(r),t)}if(!i.access_token)throw new se(`Token endpoint response missing access_token: ${JSON.stringify(r8(i))}`,e.status,r8(i),t);if(i.token_type&&"bearer"!==i.token_type.toLowerCase())throw new se(`Token endpoint response: unsupported token_type "${i.token_type}" (want Bearer)`,e.status,r8(i),t);return i}let r5=new Set(["error","error_description","error_uri"]);function r8(e){if(null==e)return e;if("string"==typeof e){let t;try{t=JSON.parse(e)}catch{if(e.length<=2e3)return e;return e.slice(0,2e3)+`... <${e.length-2e3} more chars>`}return JSON.stringify(r8(t))}if("object"==typeof e&&!Array.isArray(e)){let t={};for(let[i,r]of Object.entries(e))r5.has(i)&&(t[i]=r);return t}return null}async function r3(t,i=e=>console.warn(`anthropic-sdk: ${e}`)){let r;if("u"<typeof process||"win32"===process.platform)return;let{fs:s}=await e.A(79955),n=t;try{n=await s.promises.realpath(t),r=await s.promises.stat(n)}catch{return}let a=511&r.mode;if(18&a)throw new se(`Credentials file at ${n} is group/world-writable (mode 0o${a.toString(8)}); this allows other local users to plant tokens. Run \`chmod 600 ${n}\`.`);if(36&a)throw new se(`Credentials file at ${n} is group/world-readable (mode 0o${a.toString(8)}); run \`chmod 600 ${n}\` before retrying.`);"function"==typeof process.getuid&&r.uid!==process.getuid()&&i(`credentials file at ${n} is owned by uid ${r.uid} (current process uid ${process.getuid()}); verify this is intentional.`)}async function r9(t,i){let{fs:r,path:s}=await e.A(79955),n=s.dirname(t);await r.promises.mkdir(n,{recursive:!0,mode:448});let a=`${t}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;try{let e=await r.promises.open(a,"w",384);try{await e.writeFile(JSON.stringify(i,null,2)),await e.sync()}finally{await e.close()}await r.promises.rename(a,t)}catch(e){throw await r.promises.unlink(a).catch(()=>{}),e}try{let e=await r.promises.open(n,"r");try{await e.sync()}finally{await e.close()}}catch{}}async function r7(e){let t;if(!e.body)return"";let i=e.body.getReader(),r=[],s=0;for(;;){let{done:e,value:t}=await i.read();if(e)break;if(s+t.length>1048576){let e=1048576-s;e>0&&r.push(t.subarray(0,e)),await i.cancel();break}r.push(t),s+=t.length}if(1===r.length)t=r[0];else{t=new Uint8Array(r.reduce((e,t)=>e+t.length,0));let e=0;for(let i of r)t.set(i,e),e+=i.length}return new TextDecoder("utf-8").decode(t)}class se extends r0.v{constructor(e,t=null,i=null,r=null){super(e),this.statusCode=t,this.body=i,this.requestId=r}}function st(){return Math.floor(Date.now()/1e3)}class si{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||null==t)return(await this.refresh(e)).token;if(null==t.expiresAt)return t.token;let i=t.expiresAt-st();return i>120?t.token:i>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||st()-this.lastAdvisoryError<5||this.doRefresh().catch(e=>{this.lastAdvisoryError=st(),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}}let sr="gen_ai.input.messages",ss="gen_ai.operation.name",sn="gen_ai.output.messages",sa="gen_ai.output.type",so="gen_ai.request.model",sl="gen_ai.request.stop_sequences",sc="gen_ai.system_instructions",su="json",sh="anthropic.tool_result.content",sd=[["anthropic.request.id","request-id"],["anthropic.organization.id","anthropic-organization-id"],["anthropic.workspace.id","anthropic-workspace-id"]];function sp(e,t,i,r){let s=e.span,n=e.requestContentSize;if(void 0!==i&&void 0!==n){let e=JSON.stringify([{role:"assistant",parts:s_(i)}]);if(n+3*e.length<=r||n+sy(e)<=r)return void s.setAttribute(sn,e)}let a=sv(s,{[sl]:t.stop_sequences?.length?[...t.stop_sequences]:void 0,[sc]:void 0===t.system?void 0:s_(t.system),[sr]:t.messages.map(e=>({role:e.role,parts:s_(e.content)})),[sn]:void 0===i?void 0:[{role:"assistant",parts:s_(i)}]},r);void 0===i&&(e.requestContentSize=a)}function s_(e){return"string"==typeof e?[{type:"text",content:e}]:e?.map(sf)??[]}function sf(e){switch(e.type){case"text":return{type:"text",content:e.text};case"thinking":return{type:"reasoning",content:e.thinking};case"tool_use":return{type:"tool_call",id:e.id,name:e.name,arguments:e.input,..."string"==typeof e.toolset_name?{anthropic_toolset_name:e.toolset_name}:void 0};case"server_tool_use":return{type:"tool_call",id:e.id,name:e.name,arguments:e.input};case"mcp_tool_use":return{type:"tool_call",id:e.id,name:e.name,arguments:e.input,anthropic_mcp_server_name:e.server_name};case"tool_result":return{type:"tool_call_response",id:e.tool_use_id,response:sg(e.content)};default:if("string"!=typeof e.type)return{type:"anthropic_unknown"};if(e.type.endsWith("_tool_result")&&"tool_use_id"in e){var t;return{type:"tool_call_response",id:e.tool_use_id,response:null==(t=e.content)?[]:"string"==typeof t?[{type:"text",text:t}]:Array.isArray(t)?t.map(e=>"text"===e.type||"search_result"===e.type||"web_search_result"===e.type?sm(e):"string"!=typeof e.type?{type:"unknown"}:{type:e.type}):[sm(t)]}}return{type:`anthropic_${e.type}`}}}function sg(e){return null==e?[]:"string"==typeof e?[{type:"text",text:e}]:e.map(e=>"text"===e.type||"search_result"===e.type?sm(e):"string"!=typeof e.type?{type:"unknown"}:{type:e.type})}function sm(e){if(Array.isArray(e))return e.map(sm);if("object"!=typeof e||null===e)return e;let{type:t,file_type:i}=e;if("image"===t||"document"===t)return{type:t};let r="text_editor_code_execution_view_result"===t&&("image"===i||"pdf"===i);return Object.fromEntries(Object.entries(e).filter(([e])=>!e.startsWith("encrypted_")&&!("content"===e&&r)).map(([e,t])=>[e,sm(t)]))}function sv(e,t,i){let{[sl]:r,[sc]:s,[sr]:n,[sn]:a,[sh]:o,...l}=t,c={[sc]:s,[sr]:n,[sn]:a},u={},h=o?.map(e=>JSON.stringify(e)),d=3*([...r??[],...h??[]].reduce((e,t)=>e+t.length+1,2)+sb(l,u)+sb(c,u))<=i?e=>3*e.length:sy,p=()=>Object.keys(c).reduce((e,t)=>e+d(u[t]??""),0),_=r?.reduce((e,t)=>e+d(t),0)??0,f=void 0!==r&&_<=i,g=f?_:0,m=void 0!==r&&!f;for(let e of Object.keys(l)){let t=d(u[e]??"");t>i?(delete u[e],m=!0):g+=t}let v=p();if(g+v>i){let{truncated:e,...t}=function(e,t){let i=e=>e?.map(e=>({...e,parts:[...e.parts]})),r=e[sc]?.slice(),s=i(e[sr]),n=i(e[sn]),a=[r??[],...[...s??[],...n??[]].map(({parts:e})=>e)],o=a.reduce((e,t)=>e+t.length,0),l=!1;for(let e of a){let i=0;for(;t>0&&i<e.length;){let r=e[i],s=sy(JSON.stringify(r)),n=r.content;if(1===o&&"text"===r.type&&"string"==typeof n){let a=function(e,t,i){let r=i-sy(JSON.stringify({...e,content:""})),s=t.slice(0,Math.max(r,0)),n=JSON.stringify(s),a=0,o=0,l=0;for(;a<s.length;){let e=n.codePointAt(1+o),t=e>65535?2:1,i=92!==e?t:"u"===n[2+o]?6:2;if((l+=e<128?i:e<2048?2:e<65536?3:4)>r)break;o+=i,a+=t}return t.slice(0,a)}(r,n,s-t);a!==n&&(e[i]={...r,content:a},l=!0);break}t-=s+ +(i+1<e.length),i++,o--,l=!0}e.splice(0,i)}return{[sc]:r,[sr]:s,[sn]:n,truncated:l}}(c,g+v-i);m||(m=e),sb(t,u),v=p()}if(g+=v,void 0!==h){let e=function(e,t,i){let r=[],s=2;for(let n of e){let e=s+ +(0!==r.length)+i(n);if(e>t)break;r.push(n),s=e}return{json:"["+r.join(",")+"]",size:s,truncated:r.length<e.length}}(h,i-g,d);u[sh]=e.json,g+=e.size,m||(m=e.truncated)}for(let[t,i]of(m&&e.setAttribute("anthropic.content.truncated",!0),f&&e.setAttribute(sl,r),Object.entries(u)))e.setAttribute(t,i);return g}function sb(e,t){let i=0;for(let[r,s]of Object.entries(e))void 0!==s&&(t[r]=JSON.stringify(s),i+=t[r].length);return i}function sy(e){let t=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);r<128?t+=1:r<2048?t+=2:r>=55296&&r<56320&&(64512&e.charCodeAt(i+1))==56320?(t+=4,i++):t+=3}return t}function sw(e,t,i,r){e.setAttribute("gen_ai.response.id",t.id),e.setAttribute("gen_ai.response.model",t.model),e.setAttribute("gen_ai.usage.input_tokens",i.input_tokens+(i.cache_read_input_tokens??0)+(i.cache_creation_input_tokens??0)),null!=i.cache_creation_input_tokens&&e.setAttribute("gen_ai.usage.cache_write.input_tokens",i.cache_creation_input_tokens),null!=i.cache_read_input_tokens&&e.setAttribute("gen_ai.usage.cache_read.input_tokens",i.cache_read_input_tokens);let s=i.cache_creation;if(null!=s&&(e.setAttribute("anthropic.usage.cache_creation.ephemeral_5m_input_tokens",s.ephemeral_5m_input_tokens),e.setAttribute("anthropic.usage.cache_creation.ephemeral_1h_input_tokens",s.ephemeral_1h_input_tokens)),null!=i.service_tier&&e.setAttribute("anthropic.response.service_tier",i.service_tier),!r)return;e.setAttribute("gen_ai.usage.output_tokens",i.output_tokens);let n=i.output_tokens_details;null!=n&&e.setAttribute("gen_ai.usage.reasoning.output_tokens",n.thinking_tokens);let a=i.iterations?.filter(e=>"compaction"===e.type)??[];a.length>0&&(e.setAttribute("anthropic.usage.compaction.input_tokens",a.reduce((e,t)=>e+t.input_tokens+t.cache_read_input_tokens+t.cache_creation_input_tokens,0)),e.setAttribute("anthropic.usage.compaction.output_tokens",a.reduce((e,t)=>e+t.output_tokens,0))),null!=t.stop_reason&&e.setAttribute("anthropic.message.stop_reason",t.stop_reason)}function sk(e,t,i){if(t.isRecording())try{let e="error"===i.status?i.error:void 0,r=i.response?.headers??(e instanceof ry.E?e.headers:void 0);for(let[e,i]of sd){let s=r?.get(i);s&&t.setAttribute(e,s)}}catch(t){(0,rz.u)(e).debug("could not record the API call on its span",t)}}function sz(e,t,i){let r={[ss]:"chat",[so]:t.model};try{let s=(rR([e._options.defaultHeaders,i]).values.get("anthropic-beta")??"").split(",").map(e=>e.trim()).filter(Boolean);s.length&&(r["anthropic.beta"]=s),r["gen_ai.request.max_tokens"]=t.max_tokens,!0===t.stream&&(r["gen_ai.request.stream"]=!0),t.output_config?.format?.type==="json_schema"&&(r[sa]=su);let n=t.output_config?.effort;null!=n&&(r["gen_ai.request.reasoning.level"]=n),null!=t.service_tier&&(r["anthropic.request.service_tier"]=t.service_tier);let a=t.thinking;null!=a&&(r["anthropic.thinking.type"]=a.type),a?.type==="enabled"&&(r["anthropic.thinking.budget_tokens"]=a.budget_tokens)}catch(t){(0,rz.u)(e).debug("could not record the request on its span",t)}return{route:"/v1/messages",attributes:r}}function sS(e,t,i){if(!t?.span.isRecording())return t;try{let{contentMode:r,maxContentBytes:s}=e.openTelemetry.traces;"content"===r&&sp(t,i,void 0,s)}catch(t){(0,rz.u)(e).debug("could not record the request on its span",t)}return t}function sx(e,t,i,r){if(!t?.span.isRecording()||r instanceof rS)return;let s=t.span;try{sw(s,r,r.usage,!0);let{contentMode:n,maxContentBytes:a}=e.openTelemetry.traces;"content"===n&&sp(t,i,r.content,a)}catch(t){(0,rz.u)(e).debug("could not record the response on its span",t)}}function sV(e,t,i){try{t?.span.setAttribute("anthropic.message.count_tokens.input_tokens",i.input_tokens)}catch(t){(0,rz.u)(e).debug("could not record the response on its span",t)}}function sA(e){let t=function(){let e=new Set(["traceparent","tracestate","baggage"]);try{for(let t of i8.fields())e.add(t.toLowerCase())}catch(e){(0,rz.i)().debug("could not record telemetry",e)}return e}(),i=Array.from(e.entries()).filter(([e])=>t.has(e));for(let[t]of i)e.delete(t);return i}function sI(e){return(t,i,r)=>{let s=new Headers(t.headers),n=sA(s);return e({...t,headers:s},e=>{let t=new Headers(e.headers);for(let[e,i]of n)t.set(e,i);return i({...e,headers:t})},r)}}let sq=/^[A-Za-z0-9_.-]+$/;function s$(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(!sq.test(e))throw Error(`profile name "${e}" contains disallowed characters (allowed: letters, digits, '_', '.', '-')`)}let sR=async t=>{var i,r;let s,n,a=await sT();if(null===a)return null;let o=null==t&&null!=(0,rP.f)("ANTHROPIC_PROFILE"),l=null;if(null==t&&!o){let e=(0,rP.f)("ANTHROPIC_ORGANIZATION_ID"),t=(0,rP.f)("ANTHROPIC_IDENTITY_TOKEN_FILE"),i=(0,rP.f)("ANTHROPIC_FEDERATION_RULE_ID");if(i&&e&&(l={fromFile:!1,config:{organization_id:e,workspace_id:(0,rP.f)("ANTHROPIC_WORKSPACE_ID"),base_url:(0,rP.f)("ANTHROPIC_BASE_URL"),authentication:{type:"oidc_federation",federation_rule_id:i,service_account_id:(0,rP.f)("ANTHROPIC_SERVICE_ACCOUNT_ID"),identity_token:t?{source:"file",path:t}:void 0,scope:(0,rP.f)("ANTHROPIC_SCOPE")}}},t||(0,rP.f)("ANTHROPIC_IDENTITY_TOKEN")))return l}let c=t??await sO();if(null===c)return null;s$(c);let{fs:u,path:h}=await e.A(79955),d=h.join(a,"configs",`${c}.json`);try{s=await u.promises.readFile(d,"utf-8")}catch(e){if(e?.code!=="ENOENT")throw Error(`failed to read config file ${d}: ${e}`);if(o)throw new ry.v(`ANTHROPIC_PROFILE names the profile "${c}", but ${d} does not exist. Set ANTHROPIC_PROFILE to a profile that exists, or unset it.`,{cause:e});return l}try{n=JSON.parse(s)}catch(e){throw Error(`failed to parse config file ${d}: ${e}`)}if(!n.authentication)throw Error(`config file ${d} is missing "authentication"`);let p=n.authentication.type;if("oidc_federation"!==p&&"user_oauth"!==p)throw Error(`authentication.type "${p}" is not a known authentication type`);if(n.organization_id??(n.organization_id=(0,rP.f)("ANTHROPIC_ORGANIZATION_ID")),n.workspace_id??(n.workspace_id=(0,rP.f)("ANTHROPIC_WORKSPACE_ID")),n.base_url??(n.base_url=(0,rP.f)("ANTHROPIC_BASE_URL")),(i=n.authentication).scope??(i.scope=(0,rP.f)("ANTHROPIC_SCOPE")),"oidc_federation"===n.authentication.type){if(!n.authentication.identity_token){let e=(0,rP.f)("ANTHROPIC_IDENTITY_TOKEN_FILE");e&&(n.authentication.identity_token={source:"file",path:e})}n.authentication.federation_rule_id||(n.authentication.federation_rule_id=(0,rP.f)("ANTHROPIC_FEDERATION_RULE_ID")??""),(r=n.authentication).service_account_id??(r.service_account_id=(0,rP.f)("ANTHROPIC_SERVICE_ACCOUNT_ID"))}return{config:n,fromFile:!0}},sP=async(t,i)=>{if(t?.authentication.credentials_path)return t.authentication.credentials_path;let r=await sT();if(!r)return null;let s=i??await sO();if(!s)return null;s$(s);let{path:n}=await e.A(79955);return n.join(r,"credentials",`${s}.json`)},sT=async()=>{if(!sE())return null;let{path:t}=await e.A(79955),i=(0,rP.f)("ANTHROPIC_CONFIG_DIR");if(i)return i;if("Windows"===iy()["X-Stainless-OS"]){let e=(0,rP.f)("APPDATA");if(e)return t.join(e,"Anthropic");let i=(0,rP.f)("USERPROFILE");return i?t.join(i,"AppData","Roaming","Anthropic"):null}let r=(0,rP.f)("XDG_CONFIG_HOME");if(r)return t.join(r,"anthropic");let s=(0,rP.f)("HOME");return s?t.join(s,".config","anthropic"):null},sE=()=>{let e=iy()["X-Stainless-Runtime"];return"node"===e||"deno"===e},sO=async()=>{let t=await sT();if(!t)return null;let i=(0,rP.f)("ANTHROPIC_PROFILE");if(i)return i;let{fs:r,path:s}=await e.A(79955),n=s.join(t,"active_config");try{return(await r.promises.readFile(n,"utf-8")).trim()||"default"}catch(e){if(e?.code!=="ENOENT")throw Error(`failed to read ${n}: ${e}`);return"default"}};function sM(t){if(!t)throw new ry.v("Identity token file path is empty");return async()=>{let i,{fs:r}=await e.A(79955);try{i=await r.promises.readFile(t,"utf-8")}catch(e){throw new ry.v(`Failed to read identity token file at ${t}: ${e}`)}let s=i.trim();if(!s)throw new ry.v(`Identity token file at ${t} is empty`);return s}}function sL(t,i){let r=t.authentication.credentials_path??null,s=(t.base_url||i.baseURL).replace(/\/+$/,""),n=function(t,i,r,s){var n,a,o,l,c,u;switch(t.authentication.type){case"oidc_federation":{let a=t.authentication,h=function(e){if(e.identity_token){let t=e.identity_token.source;if("file"!==t)throw new se(`identity_token.source "${t}" is not supported by this SDK version (only "file")`);if(!e.identity_token.path)throw new se('identity_token.source "file" requires a non-empty path');return sM(e.identity_token.path)}let t=(0,rP.f)("ANTHROPIC_IDENTITY_TOKEN_FILE");if(t)return sM(t);let i=(0,rP.f)("ANTHROPIC_IDENTITY_TOKEN");if(i){if(!i)throw new ry.v("Identity token value is empty");return()=>i}return null}(a);if(!h)throw new se("oidc_federation config requires an identity token (set authentication.identity_token, ANTHROPIC_IDENTITY_TOKEN_FILE, or ANTHROPIC_IDENTITY_TOKEN)");if(!a.federation_rule_id)throw new se("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(!t.organization_id)throw new se("oidc_federation config requires organization_id (set ANTHROPIC_ORGANIZATION_ID or config.organization_id)");let d=(n={identityTokenProvider:h,federationRuleId:a.federation_rule_id,organizationId:t.organization_id,serviceAccountId:a.service_account_id,workspaceId:t.workspace_id,baseURL:r,fetch:s.fetch,userAgent:s.userAgent},async()=>{let e;r6(n.baseURL);let t=await n.identityTokenProvider();if(t.length>16384)throw new se(`Identity token is ${Math.ceil(t.length/1024)} KiB, exceeds the 16 KiB assertion limit`);let i={grant_type:"urn:ietf:params:oauth:grant-type:jwt-bearer",assertion:t,federation_rule_id:n.federationRuleId,organization_id:n.organizationId};n.serviceAccountId&&(i.service_account_id=n.serviceAccountId),n.workspaceId&&(i.workspace_id=n.workspaceId);let r=`${n.baseURL}${r1}`;try{e=await n.fetch(r,{method:"POST",redirect:"manual",headers:{"Content-Type":"application/json","anthropic-beta":`${r2},oidc-federation-2026-04-01`,"User-Agent":n.userAgent||`anthropic-sdk-typescript/${im} oidcFederationProvider`},body:JSON.stringify(i)})}catch(e){throw new se(`Failed to reach token endpoint ${r}: ${e}`)}let s=e.headers.get("Request-Id");if(!e.ok){let t=r8(await e.text().catch(()=>"")),i="";if(401===e.status){let e=n.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. ";i=` Ensure your federation rule matches your identity token. ${e}View your authentication events in the Workload identity page of Claude Console for more details.`}throw new se(`Token exchange failed with status ${e.status}${s?` (request-id ${s})`:""}: ${t}${i}`,e.status,t,s)}let a=await r4(e,s),o=Number(a.expires_in);if(!Number.isFinite(o))throw new se(`Token endpoint response missing required fields: ${JSON.stringify(r8(a))}`,e.status,r8(a),s);return{token:a.access_token,expiresAt:st()+o}});if(i){return o=d,l=i,c=s.onCacheWriteError,u=s.onSafetyWarning,async t=>{let i,{fs:r}=await e.A(79955);await r3(l,u);try{let e=await r.promises.readFile(l,"utf-8");i=JSON.parse(e);let s=i?.access_token;if(s&&!t?.forceRefresh){let e=i?.expires_at;if(null==e||st()<e-30)return{token:s,expiresAt:e??null}}}catch(e){"ENOENT"===e?.code||e instanceof SyntaxError||c?.(e)}let s=await o(t);try{await r9(l,{...i??{},version:"1.0",type:"oauth_token",access_token:s.token,expires_at:s.expiresAt})}catch(e){c?.(e)}return s}}return d}case"user_oauth":if(!i)throw new se("user_oauth config requires authentication.credentials_path (or load via a profile so it defaults to <config_dir>/credentials/<profile>.json)");return a={credentialsPath:i,clientId:t.authentication.client_id,baseURL:r,fetch:s.fetch,userAgent:s.userAgent,onSafetyWarning:s.onSafetyWarning},async t=>{let i,r,s,{fs:n}=await e.A(79955);await r3(a.credentialsPath,a.onSafetyWarning);try{i=await n.promises.readFile(a.credentialsPath,"utf-8")}catch(e){throw new se(`Credentials file not found at ${a.credentialsPath}: ${e}`)}try{r=JSON.parse(i)}catch(e){throw new se(`Credentials file at ${a.credentialsPath} is not valid JSON: ${e}`)}let o=r.access_token;if(!o)throw new se(`Credentials file at ${a.credentialsPath} must include 'access_token'`);let l=r.expires_at;if(!t?.forceRefresh&&(null==l||st()<l-30))return{token:o,expiresAt:l??null};let c=r.refresh_token;if(!a.clientId||!c)throw new se(`Access token at ${a.credentialsPath} has expired and no refresh is available (client_id ${a.clientId?"set":"empty"}, refresh_token ${c?"set":"empty"})`);r6(a.baseURL);let u={grant_type:"refresh_token",refresh_token:c,client_id:a.clientId},h=`${a.baseURL}${r1}`;try{s=await a.fetch(h,{method:"POST",redirect:"manual",headers:{"Content-Type":"application/json","anthropic-beta":r2,"User-Agent":a.userAgent||`anthropic-sdk-typescript/${im} userOAuthProvider`},body:JSON.stringify(u)})}catch(e){throw new se(`User OAuth refresh failed to reach token endpoint: ${e}`)}let d=s.headers.get("Request-Id");if(!s.ok){let e=await s.text().catch(()=>"");throw new se(`User OAuth refresh failed (HTTP ${s.status}): ${r8(e)}`,s.status,r8(e),d)}let p=await r4(s,d),_=Number(p.expires_in);if(!Number.isFinite(_))throw new se(`User OAuth refresh response missing or invalid expires_in: ${JSON.stringify(r8(p))}`,s.status,r8(p),d);let f=st()+_,g=p.refresh_token||c;return await r9(a.credentialsPath,{...r,version:"1.0",type:"oauth_token",access_token:p.access_token,expires_at:f,refresh_token:g}),{token:p.access_token,expiresAt:f}};default:{let e=t.authentication.type;throw new se(`authentication.type "${e}" is not a known authentication type`)}}}(t,r,s,i),a={};return t.workspace_id&&"user_oauth"===t.authentication.type&&(a["anthropic-workspace-id"]=t.workspace_id),{provider:n,extraHeaders:a,baseURL:t.base_url||void 0}}async function sC(e,t){let i=await sR(t);if(!i)return null;let{config:r,fromFile:s}=i;return sL(r.authentication.credentials_path||!s?r:{...r,authentication:{...r.authentication,credentials_path:await sP(r,t)??void 0}},e)}async function sN(e,t){let{response:i,requestLogID:r,retryOfRequestLogID:s,startTime:n}=t,a=await (async()=>{if(t.options.stream)return(0,rz.u)(e).debug("response",i.status,i.url,i.headers,i.body),rS.fromSSEResponse(i,t.controller,e);if(204===i.status)return null;if(t.options.__binaryResponse)return i;let r=i.headers.get("content-type"),s=r?.split(";")[0]?.trim();if(s?.includes("application/json")||s?.endsWith("+json")){if("0"===i.headers.get("content-length"))return;return sj(await i.json(),i)}return await i.text()})().finally(()=>{t.options.stream||t.options.__binaryResponse||iz(t.controller)});return(0,rz.M)((0,rz.u)(e),`[${r}] response parsed`,{retryOfRequestLogID:s,url:i.url,status:i.status,body:a,durationMs:Date.now()-n}),a}function sj(e,t){return!e||"object"!=typeof e||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}})}let sD=new WeakSet;function sW(e){return"object"==typeof e&&null!==e&&sD.has(e)}function sU(e,t,i,r){return async(s,n={})=>{if(0===t.length)return e.call(void 0,s,n);let a=n.headers instanceof Headers?n.headers:new Headers(n.headers),o=await (function(e,t,i,r){let s,n=async({url:t,...i})=>{try{return await e.call(void 0,t,i)}catch(t){let e=(0,ig.Y)(t);throw sD.add(e),e}},a=(s=new WeakMap,{options:i,logger:r?(0,rz.u)(r):(0,rz.i)(),parse(e){if(i?.stream&&e.ok)return sF(e,i,r);let t=s.get(e);return t||(t=sF(e,i,r),s.set(e,t)),t}});for(let e=t.length-1;e>=0;e--){let i=t[e],r=n;n=async e=>i(e,r,a)}return n})(e,t,i,r)({...n,headers:a,url:"string"==typeof s?s:s instanceof URL?s.href:s.url});if(o.bodyUsed||o.body?.locked)throw new ry.v("middleware consumed the response body; use response.clone() to inspect it, or return new Response(body, response) to consume and replace it");return o}}async function sF(e,t,i){if(e.bodyUsed||e.body?.locked)throw new ry.v("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 rS.fromSSEResponse(e.clone(),new AbortController,i);if(204===e.status)return null;if(t?.__binaryResponse)return e;let r=e.headers.get("content-type"),s=r?.split(";")[0]?.trim();if(s?.includes("application/json")||s?.endsWith("+json")){if("0"===e.headers.get("content-length"))return;return sj(await e.clone().json(),e)}return await e.clone().text()}let sH=()=>{if("u"<typeof File){let{process:e}=globalThis;throw Error("`File` is not defined as a global, which is required for file uploads."+("string"==typeof e?.versions?.node&&20>parseInt(e.versions.node.split("."))?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function sB(e,t,i){return sH(),new File(e,t??"",i)}function sK(e,t){let i="object"==typeof e&&null!==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?i.split(/[\\/]/).pop()||void 0:i}let sJ=e=>null!=e&&"object"==typeof e&&"function"==typeof e[Symbol.asyncIterator],sG=async(e,t,i=!0)=>{try{return{...e,body:await sY(e.body,t,i)}}catch(r){let i=e.__span?.span;throw i&&rL("function"==typeof t?void 0:t,()=>rj(i,{status:"error",options:e,error:r})),r}},sX=new WeakMap,sY=async(e,t,i=!0)=>{if(!await function(e){let t="function"==typeof e?e:e.fetch,i=sX.get(t);if(i)return i;let r=(async()=>{try{let e="Response"in t?t.Response:(await t("data:,")).constructor,i=new FormData;if(i.toString()===await new e(i).text())return!1;return!0}catch{return!0}})();return sX.set(t,r),r}(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])=>sQ(r,e,t,i))),r},sQ=async(e,t,i,r)=>{if(void 0!==i){if(null==i)throw TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if("string"==typeof i||"number"==typeof i||"boolean"==typeof i)e.append(t,String(i));else if(i instanceof Response){let s={},n=i.headers.get("Content-Type");n&&(s={type:n}),e.append(t,sB([await i.blob()],sK(i,r),s))}else if(sJ(i))e.append(t,sB([await new Response(ix(i)).blob()],sK(i,r)));else if(i instanceof Blob){let s="u">typeof File&&i instanceof File?i.name:sK(i,r);e.append(t,sB([i],s,{type:i.type}))}else if(Array.isArray(i))await Promise.all(i.map(i=>sQ(e,t+"[]",i,r)));else if("function"==typeof i.then)throw TypeError(`Received a Promise for "${t}"; await it first, e.g. \`await toFile(...)\``);else if(i instanceof ArrayBuffer||ArrayBuffer.isView(i))throw TypeError(`Received ${i.constructor.name} for "${t}"; to upload raw bytes, wrap them with \`await toFile(bytes, 'filename')\``);else if("object"==typeof i)await Promise.all(Object.entries(i).map(([i,s])=>sQ(e,`${t}[${i}]`,s,r)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${i} instead`)}};function sZ(e,t,i,r){if(t.span.isRecording()&&"content"===e.openTelemetry.traces.contentMode)try{sp(t,i,r.content,e.openTelemetry.traces.maxContentBytes)}catch(t){(0,rz.u)(e).debug("could not record the streamed message on its span",t)}}var s0=(c=new WeakMap,class e extends Promise{constructor(e,t,i=sN){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=i,c.set(this,void 0),(0,id.b)(this,c,e,"f")}_responseProps(){return this.responsePromise}_thenUnwrap(t){return new e((0,id.V)(this,c,"f"),this.responsePromise,async(e,i)=>sj(t(await this.parseResponse(e,i),i),i.response))}asResponse(){return this.responsePromise.then(e=>{let t=e.options.__span?.span;if(t&&!this.parsedPromise){let i={status:"success",...e,data:void 0};sk((0,id.V)(this,c,"f"),t,i),rL((0,id.V)(this,c,"f"),()=>rj(t,i))}return 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.parsedPromise=this.responsePromise.then(e=>this.parseResponseTraced(e))),this.parsedPromise}async parseResponseTraced(e){let t,i=e.options.__span;if(!i)return this.parseResponse((0,id.V)(this,c,"f"),e);let{span:r}=i;try{t=await this.parseResponse((0,id.V)(this,c,"f"),e)}catch(i){let t={status:"error",...e,error:i};throw sk((0,id.V)(this,c,"f"),r,t),rL((0,id.V)(this,c,"f"),()=>rj(r,t)),i}let s={status:"success",...e,data:t};return rL((0,id.V)(this,c,"f"),()=>(function(e,t){if(void 0===e.createdIDAttribute||"object"!=typeof t||null===t)return;let i=t[e.createdIDField??"id"];"string"==typeof i&&e.span.setAttribute(e.createdIDAttribute,i)})(i,t)),sk((0,id.V)(this,c,"f"),r,s),e.options.stream&&sJ(t)?rL((0,id.V)(this,c,"f"),()=>{var i,s;return i=(0,id.V)(this,c,"f"),s=t,void(e.options.__span?.name==="anthropic.messages.create"&&s instanceof rS?function(e,t,i,r){let s,n;if(!t.isRecording())return;t.setAttribute(rM,r.response.status);let a=r.options.__span,o=a?.startTime,l=!1,c=!1,u=!1;rD(i,r.controller.signal,{onItem(i){try{switch(i.type){case"message_start":{let{id:e,model:t,stop_reason:r}=i.message;s={id:e,model:t,stop_reason:r},n={...i.message.usage};break}case"content_block_start":s&&"fallback"===i.content_block.type&&(s.model=i.content_block.to.model);break;case"message_delta":s&&n&&(n.output_tokens=i.usage.output_tokens,null!=i.usage.input_tokens&&(n.input_tokens=i.usage.input_tokens),null!=i.usage.cache_creation_input_tokens&&(n.cache_creation_input_tokens=i.usage.cache_creation_input_tokens),null!=i.usage.cache_read_input_tokens&&(n.cache_read_input_tokens=i.usage.cache_read_input_tokens),null!=i.usage.output_tokens_details&&(n.output_tokens_details=i.usage.output_tokens_details),"iterations"in i.usage&&null!=i.usage.iterations&&(n.iterations=i.usage.iterations),null!=i.delta.stop_reason&&(s.stop_reason=i.delta.stop_reason),c=!0);break;case"message_stop":u=!0;break;case"content_block_delta":l||void 0===o||t.setAttribute("gen_ai.response.time_to_first_chunk",(Date.now()-o)/1e3),l=!0;break;case"content_block_stop":break;default:(0,ip.f)(i)}}catch(t){(0,rz.u)(e).debug("could not record the stream on its span",t)}},onEnd(i){try{s&&n&&sw(t,s,n,c||u)}catch(t){(0,rz.u)(e).debug("could not record the stream on its span",t)}let r=a?.failure;!u&&a?.streamed&&void 0===r&&sZ(e,a,a.streamed.body,a.streamed.message),"failed"===i.reason?rW(t,i.error):void 0!==r?rW(t,r,"client_error"):"completed"===i.reason&&(u?t.setStatus({code:rb.OK}):rW(t,new ry.v("The stream ended before message_stop."),"api_error")),rL(e,()=>t.end())}})}(i,r,s,e):function(e,t,i){if(!e.isRecording())return;e.setAttribute(rM,i.response.status);let r=t instanceof rS;rD(t,i.controller.signal,{onEnd(t){"failed"===t.reason?rW(e,t.error):"completed"!==t.reason||r||e.setStatus({code:rb.OK}),e.end()}})}(r,s,e))}):rL((0,id.V)(this,c,"f"),()=>rj(r,s)),t}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}),s1=(()=>{class e{constructor(e,t,i,r){u.set(this,void 0),(0,id.b)(this,u,e,"f"),this.options=r,this.response=t,this.body=i}hasNextPage(){return!!this.getPaginatedItems().length&&null!=this.nextPageRequestOptions()}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new ry.v("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");let t=this.options.__span;return await (0,id.V)(this,u,"f").requestAPIList(this.constructor,{...e,__span:t&&rC((0,id.V)(this,u,"f"),t.name,{openTelemetry:this.options.openTelemetry},{route:t.route,queryParams:t.queryParams,contentQueryParams:t.contentQueryParams,attributes:t.attributes})})}async *iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async *[(u=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}}return e})(),s2=(()=>{class e extends s0{constructor(e,t,i){super(e,t,async(e,t)=>new i(e,t.response,await sN(e,t),t.options))}async *[Symbol.asyncIterator](){for await(let e of(await this))yield e}}return e})();class s6 extends s1{constructor(e,t,i,r){super(e,t,i,r),this.data=i.data||[],this.has_more=i.has_more||!1,this.first_id=i.first_id||null,this.last_id=i.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){let e=this.first_id;return e?{...this.options,query:{...(0,ip.V)(this.options.query),before_id:e}}:null}let e=this.last_id;return e?{...this.options,query:{...(0,ip.V)(this.options.query),after_id:e}}:null}}class s4 extends s1{constructor(e,t,i,r){super(e,t,i,r),this.data=i.data||[],this.next_page=i.next_page||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return null!=this.nextPageRequestOptions()}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{...(0,ip.V)(this.options.query),page:e}}:null}}class s5 extends s1{constructor(e,t,i,r){super(e,t,i,r),this.data=i.data||[],this.next_page=i.next_page||null,this.prev_page=i.prev_page||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return null!=this.nextPageRequestOptions()}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{...(0,ip.V)(this.options.query),page:e}}:null}}class s8 extends s1{constructor(e,t,i,r){super(e,t,i,r),this.data=i.data||[],this.next_page=i.next_page||null,this.has_more=i.has_more||!1,this.data_refreshed_at=i.data_refreshed_at||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&null!=this.nextPageRequestOptions()}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{...(0,ip.V)(this.options.query),page:e}}:null}}let s3=e=>null!=e&&"object"==typeof e&&"number"==typeof e.size&&"string"==typeof e.type&&"function"==typeof e.text&&"function"==typeof e.slice&&"function"==typeof e.arrayBuffer;async function s9(e,t,i){let r,s;if(sH(),e=await e,t||(t=e instanceof File?e.name:sK(e,!0)),null!=(r=e)&&"object"==typeof r&&"string"==typeof r.name&&"number"==typeof r.lastModified&&s3(r))return e instanceof File&&null==t&&null==i?e:sB([await e.arrayBuffer()],t??e.name,{type:e.type,lastModified:e.lastModified,...i});if(null!=(s=e)&&"object"==typeof s&&"string"==typeof s.url&&"function"==typeof s.blob){let r=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),sB(await s7(r),t,i)}let n=await s7(e);if(!i?.type){let e=n.find(e=>"object"==typeof e&&"type"in e&&e.type);"string"==typeof e&&(i={...i,type:e})}return sB(n,t,i)}async function s7(e){let t=[];if("string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(s3(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(sJ(e))for await(let i of e)t.push(...await s7(i));else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:""}${function(e){if("object"!=typeof e||null===e)return"";let t=Object.getOwnPropertyNames(e);return`; props: [${t.map(e=>`"${e}"`).join(", ")}]`}(e)}`)}return t}class ne{constructor(e){this._client=e}}let nt="x-stainless-helper",ni="x-stainless-helper-method",nr=Symbol("anthropic.sdk.stainlessHelper");function ns(e){return"object"==typeof e&&null!==e&&nr in e}function nn(e,t){let i=new Set;if(e)for(let t of e)ns(t)&&i.add(t[nr]);if(t)for(let e of t){ns(e)&&i.add(e[nr]);let t=e.content;if(Array.isArray(t))for(let e of t){ns(e)&&i.add(e[nr]);let t=e?.tool?.definition;ns(t)&&i.add(t[nr])}}return Array.from(i)}function na(e,t){let i=nn(e,t);return 0===i.length?{}:{[nt]:i.join(", ")}}function no(e){return ns(e)?{[nt]:e[nr]}:{}}function nl(e,t){let{user_profile_id:i,workspace_id:r,tools:s,messages:n}=e;return rR([{...null!=i?{"anthropic-user-profile-id":i}:void 0,...null!=r?{"anthropic-workspace-id":r}:void 0},na(s,n),t?.headers])}function nc(e){return e?.output_config?.format}function nu(e,t,i){let r=nc(t);return t&&"parse"in(r??{})?nh(e,t,i):{...e,content:e.content.map(e=>"text"===e.type?Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1}):e),parsed_output:null}}function nh(e,t,i){let r=null,s=e.content.map(e=>{if("text"===e.type){let i=function(e,t){let i=nc(e);if(i?.type!=="json_schema")return null;try{if("parse"in i)return i.parse(t);return JSON.parse(t)}catch(e){throw new ry.v(`Failed to parse structured output: ${e}`)}}(t,e.text);return null===r&&(r=i),Object.defineProperty({...e},"parsed_output",{value:i,enumerable:!1})}return e});return{...e,content:s,parsed_output:r}}let nd="__json_buf";function np(e,t){let i,r={};for(let t of Object.keys(e))"input"!==t&&(r[t]=e[t]);Object.defineProperty(r,nd,{value:t,enumerable:!1,writable:!0});let s=!1;return Object.defineProperty(r,"input",{enumerable:!0,configurable:!0,get(){if(!s){var e;let r,n;i=t?JSON.parse((e=(e=>{let t=[];for(let i of e)("brace"===i.type||"paren"===i.type)&&("{"===i.value||"["===i.value?t.push(i.value):t.pop());let i=t[t.length-1],r=e.length,s=/^-?(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||!s.test(t.value)){r--;continue}break;case"string":let n=e[r-2];if("{"===i&&(n?.type==="delimiter"||n?.type==="brace"&&"{"===n.value)){r--;continue}break;case"delimiter":r--}break}return e.slice(0,r)})((e=>{let t=0,i=[];for(;t<e.length;){let r=e[t];if("\\"===r){t++;continue}if("{"===r){i.push({type:"brace",value:"{"}),t++;continue}if("}"===r){i.push({type:"brace",value:"}"}),t++;continue}if("["===r){i.push({type:"paren",value:"["}),t++;continue}if("]"===r){i.push({type:"paren",value:"]"}),t++;continue}if(":"===r){i.push({type:"separator",value:":"}),t++;continue}if(","===r){i.push({type:"delimiter",value:","}),t++;continue}if('"'===r){let r=t+1,s=r,n=!1;for(;;){if(-1===(s=e.indexOf('"',s))){n=!0;break}let t=0,i=s-1;for(;i>=r&&"\\"===e[i];)t++,i--;if(t%2==0)break;s++}n?t=e.length:(i.push({type:"string",value:e.slice(r,s)}),t=s+1);continue}let s=/\s/;if(r&&s.test(r)){t++;continue}let n=/[0-9]/;if(r&&n.test(r)||"-"===r||"."===r){let s="";for("-"===r&&(s+=r,r=e[++t]);r&&(n.test(r)||"."===r||"e"===r||"E"===r||("-"===r||"+"===r)&&("e"===s[s.length-1]||"E"===s[s.length-1]));)s+=r,r=e[++t];i.push({type:"number",value:s,unterminated:t===e.length});continue}let a=/[a-z]/i;if(r&&a.test(r)){let s="";for(;r&&a.test(r)&&t!==e.length;)s+=r,r=e[++t];"true"==s||"false"==s||"null"===s?i.push({type:"name",value:s}):t++;continue}t++}return i})(t)),r=[],e.map(e=>{"brace"===e.type&&("{"===e.value?r.push("}"):r.splice(r.lastIndexOf("}"),1)),"paren"===e.type&&("["===e.value?r.push("]"):r.splice(r.lastIndexOf("]"),1))}),r.length>0&&r.reverse().map(t=>{"}"===t?e.push({type:"brace",value:"}"}):"]"===t&&e.push({type:"paren",value:"]"})}),n="",e.map(e=>{"string"===e.type?n+='"'+e.value+'"':n+=e.value}),n)):{},s=!0}return i}}),r}function n_(e){return"tool_use"===e.type||"server_tool_use"===e.type}var nf=(()=>{class e{constructor(e,t){h.add(this),this.messages=[],this.receivedMessages=[],d.set(this,void 0),p.set(this,null),this.controller=new AbortController,_.set(this,void 0),f.set(this,()=>{}),g.set(this,()=>{}),m.set(this,void 0),v.set(this,()=>{}),b.set(this,()=>{}),y.set(this,{}),w.set(this,!1),k.set(this,!1),z.set(this,!1),S.set(this,!1),x.set(this,void 0),V.set(this,void 0),A.set(this,void 0),I.set(this,void 0),q.set(this,void 0),$.set(this,void 0),T.set(this,e=>{if((0,id.b)(this,k,!0,"f"),(0,id.V)(this,$,"f")&&((0,id.V)(this,$,"f").streamed=void 0),(0,ig.c)(e)&&(e=new ry.F),e instanceof ry.F)return(0,id.b)(this,z,!0,"f"),this._emit("abort",e);if(e instanceof ry.v)return this._emit("error",e);if(e instanceof Error){let t=new ry.v(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new ry.v(String(e)))}),(0,id.b)(this,_,new Promise((e,t)=>{(0,id.b)(this,f,e,"f"),(0,id.b)(this,g,t,"f")}),"f"),(0,id.b)(this,m,new Promise((e,t)=>{(0,id.b)(this,v,e,"f"),(0,id.b)(this,b,t,"f")}),"f"),(0,id.V)(this,_,"f").catch(()=>{}),(0,id.V)(this,m,"f").catch(()=>{}),(0,id.b)(this,p,e,"f"),(0,id.b)(this,I,t?.logger??console,"f"),(0,id.b)(this,q,t?.client,"f")}get response(){return(0,id.V)(this,x,"f")}get request_id(){return(0,id.V)(this,V,"f")}get workspace_id(){return(0,id.V)(this,A,"f")}async withResponse(){(0,id.b)(this,S,!0,"f");let e=await (0,id.V)(this,_,"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 i=new e(null);return i._run(()=>i._fromReadableStream(t)),i}static createMessage(t,i,r,{logger:s,client:n}={}){let a=new e(i,{logger:s,client:n});for(let e of i.messages)a._addMessageParam(e);return(0,id.b)(a,p,{...i,stream:!0},"f"),a._run(()=>a._createMessage(t,{...i,stream:!0},{...r,headers:{...r?.headers,[ni]:"stream"}})),a}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},(0,id.V)(this,T,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,i){let r,s=i?.signal;s&&(s.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),s.addEventListener("abort",r));try{(0,id.V)(this,h,"m",E).call(this),(0,id.b)(this,$,i?.__span??((0,id.V)(this,q,"f")&&function(e,t,i){if(!e._tracer)return;let r=nl(t,i);return rC(e,"anthropic.messages.create",i,sz(e,{...t,stream:!0},r))}((0,id.V)(this,q,"f"),t,i)),"f");let{response:r,data:s}=await e.create({...t,stream:!0},{...i,__span:(0,id.V)(this,$,"f"),signal:this.controller.signal}).withResponse();try{this._connected(r)}catch(e){throw(0,id.V)(this,$,"f")&&((0,id.V)(this,$,"f").failure=e),s.controller.abort(),e}for await(let e of s)try{(0,id.V)(this,h,"m",O).call(this,e)}catch(e){throw(0,id.V)(this,$,"f")&&((0,id.V)(this,$,"f").failure=e),e}if(s.controller.signal?.aborted)throw new ry.F;(0,id.V)(this,h,"m",M).call(this)}finally{s&&r&&s.removeEventListener("abort",r)}}_connected(e){this.ended||((0,id.b)(this,x,e,"f"),(0,id.b)(this,V,e?.headers.get("request-id"),"f"),(0,id.b)(this,A,e?.headers.get("anthropic-workspace-id"),"f"),(0,id.V)(this,f,"f").call(this,e),this._emit("connect"))}get ended(){return(0,id.V)(this,w,"f")}get errored(){return(0,id.V)(this,k,"f")}get aborted(){return(0,id.V)(this,z,"f")}abort(){this.controller.abort()}on(e,t){return((0,id.V)(this,y,"f")[e]||((0,id.V)(this,y,"f")[e]=[])).push({listener:t}),this}off(e,t){let i=(0,id.V)(this,y,"f")[e];if(!i)return this;let r=i.findIndex(e=>e.listener===t);return r>=0&&i.splice(r,1),this}once(e,t){return((0,id.V)(this,y,"f")[e]||((0,id.V)(this,y,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,i)=>{(0,id.b)(this,S,!0,"f"),"error"!==e&&this.once("error",i),this.once(e,t)})}async done(){(0,id.b)(this,S,!0,"f"),await (0,id.V)(this,m,"f")}get currentMessage(){return(0,id.V)(this,d,"f")}async finalMessage(){return await this.done(),(0,id.V)(this,h,"m",R).call(this)}async finalText(){return await this.done(),(0,id.V)(this,h,"m",P).call(this)}_emit(e,...t){if((0,id.V)(this,w,"f"))return;"end"===e&&((0,id.b)(this,w,!0,"f"),(0,id.V)(this,v,"f").call(this));let i=(0,id.V)(this,y,"f")[e];if(i&&((0,id.V)(this,y,"f")[e]=i.filter(e=>!e.once),i.forEach(({listener:e})=>e(...t))),"abort"===e){let e=t[0];(0,id.V)(this,S,"f")||i?.length||Promise.reject(e),(0,id.V)(this,g,"f").call(this,e),(0,id.V)(this,b,"f").call(this,e),this._emit("end");return}if("error"===e){let e=t[0];(0,id.V)(this,S,"f")||i?.length||Promise.reject(e),(0,id.V)(this,g,"f").call(this,e),(0,id.V)(this,b,"f").call(this,e),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",(0,id.V)(this,h,"m",R).call(this))}async _fromReadableStream(e,t){let i,r=t?.signal;r&&(r.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),r.addEventListener("abort",i));try{(0,id.V)(this,h,"m",E).call(this),this._connected(null);let t=rS.fromReadableStream(e,this.controller);for await(let e of t)(0,id.V)(this,h,"m",O).call(this,e);if(t.controller.signal?.aborted)throw new ry.F;(0,id.V)(this,h,"m",M).call(this)}finally{r&&i&&r.removeEventListener("abort",i)}}[(d=new WeakMap,p=new WeakMap,_=new WeakMap,f=new WeakMap,g=new WeakMap,m=new WeakMap,v=new WeakMap,b=new WeakMap,y=new WeakMap,w=new WeakMap,k=new WeakMap,z=new WeakMap,S=new WeakMap,x=new WeakMap,V=new WeakMap,A=new WeakMap,I=new WeakMap,q=new WeakMap,$=new WeakMap,T=new WeakMap,h=new WeakSet,R=function(){if(0===this.receivedMessages.length)throw new ry.v("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},P=function(){if(0===this.receivedMessages.length)throw new ry.v("stream ended without producing a Message with role=assistant");let e=this.receivedMessages.at(-1).content.filter(e=>"text"===e.type).map(e=>e.text);if(0===e.length)throw new ry.v("stream ended without producing a content block with type=text");return e.join(" ")},E=function(){this.ended||(0,id.b)(this,d,void 0,"f")},O=function(e){if(this.ended)return;let t=(0,id.V)(this,h,"m",L).call(this,e);if(this._emit("_rawEvent",e),t)switch(this._emit("streamEvent",e,t),e.type){case"content_block_delta":{let i=t.content.at(-1);switch(e.delta.type){case"text_delta":"text"===i.type&&this._emit("text",e.delta.text,i.text||"");break;case"citations_delta":"text"===i.type&&this._emit("citation",e.delta.citation,i.citations??[]);break;case"input_json_delta":n_(i)&&(0,id.V)(this,y,"f").inputJson?.length&&this._emit("inputJson",e.delta.partial_json,i.input);break;case"thinking_delta":"thinking"===i.type&&this._emit("thinking",e.delta.thinking,i.thinking);break;case"signature_delta":"thinking"===i.type&&this._emit("signature",i.signature);break;default:(0,ip.f)(e.delta)}break}case"message_stop":(0,id.V)(this,q,"f")&&(0,id.V)(this,$,"f")&&(0,id.V)(this,p,"f")&&sZ((0,id.V)(this,q,"f"),(0,id.V)(this,$,"f"),(0,id.V)(this,p,"f"),t),this._addMessageParam(t),this._addMessage(nu(t,(0,id.V)(this,p,"f"),{logger:(0,id.V)(this,I,"f")}),!0);break;case"content_block_stop":this._emit("contentBlock",t.content.at(-1));break;case"message_start":(0,id.b)(this,d,t,"f"),(0,id.V)(this,$,"f")&&(0,id.V)(this,p,"f")&&((0,id.V)(this,$,"f").streamed={body:(0,id.V)(this,p,"f"),message:t})}},M=function(){if(this.ended)throw new ry.v("stream has ended, this shouldn't happen");let e=(0,id.V)(this,d,"f");if(!e)throw new ry.v("request ended without sending any chunks");return(0,id.b)(this,d,void 0,"f"),nu(e,(0,id.V)(this,p,"f"),{logger:(0,id.V)(this,I,"f")})},L=function(e){let t=(0,id.V)(this,d,"f");if("message_start"===e.type){if(t)throw new ry.v(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(t)switch(e.type){case"message_stop":default: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,null!=e.delta.container&&(t.container=e.delta.container),null!=e.usage.input_tokens&&(t.usage.input_tokens=e.usage.input_tokens),null!=e.usage.cache_creation_input_tokens&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),null!=e.usage.cache_read_input_tokens&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),null!=e.usage.server_tool_use&&(t.usage.server_tool_use=e.usage.server_tool_use),null!=e.usage.output_tokens_details&&(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 i=t.content.at(e.index);switch(e.delta.type){case"text_delta":i?.type==="text"&&(t.content[e.index]={...i,text:(i.text||"")+e.delta.text});break;case"citations_delta":i?.type==="text"&&(t.content[e.index]={...i,citations:[...i.citations??[],e.delta.citation]});break;case"input_json_delta":if(i&&n_(i)){let r=(i[nd]||"")+e.delta.partial_json;t.content[e.index]=np(i,r)}break;case"thinking_delta":i?.type==="thinking"&&(t.content[e.index]={...i,thinking:i.thinking+e.delta.thinking});break;case"signature_delta":i?.type==="thinking"&&(t.content[e.index]={...i,signature:e.delta.signature});break;default:(0,ip.f)(e.delta)}return t}case"content_block_stop":{let i=t.content.at(e.index);return i&&n_(i)&&nd in i&&Object.defineProperty(i,"input",{value:i.input,enumerable:!0,configurable:!0,writable:!0}),t}}},Symbol.asyncIterator)](){let e=[],t=[],i=!1;return this.on("_rawEvent",i=>{let r=t.shift();r?r.resolve(i):e.push(i)}),this.on("end",()=>{for(let e of(i=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let r of(i=!0,t))r.reject(e);t.length=0}),this.on("error",e=>{for(let r of(i=!0,t))r.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:i?{value:void 0,done:!0}:new Promise((e,i)=>t.push({resolve:e,reject:i})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new rS(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}return e})(),ng=(()=>{class e{constructor(e,t,i){this.iterator=e,this.response=i,this.controller=t}async *decoder(){let e=this.iterator;if(!e)throw new ry.v("Cannot iterate over a consumed stream.");this.iterator=void 0;let t=new rk;for await(let i of e)for(let e of t.decode(i))yield JSON.parse(e);for(let e of t.flush())yield JSON.parse(e)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(t,i){if(!t.body){if(i.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new ry.v("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new ry.v("Attempted to iterate over a response with no body")}return new e(iA(t.body),i,t)}}return e})();function nm(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}let nv=Object.freeze(Object.create(null)),nb=((e=nm)=>function(t,...i){let r;if(1===t.length)return t[0];let s=!1,n=[],a=t.reduce((t,r,a)=>{/[?#]/.test(r)&&(s=!0);let o=i[a],l=(s?encodeURIComponent:e)(""+o);return a!==i.length&&(null==o||"object"==typeof o&&o.toString===Object.getPrototypeOf(Object.getPrototypeOf(o.hasOwnProperty??nv)??nv)?.toString)&&(l=o+"",n.push({start:t.length+r.length,length:l.length,error:`Value of type ${Object.prototype.toString.call(o).slice(8,-1)} is not a valid path parameter`})),s||""!==l||n.push({start:t.length+r.length,length:0,error:'Value "" can\'t be safely passed as a path parameter'}),t+r+(a===i.length?"":l)},""),o=a.split(/[?#]/,1)[0],l=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;for(;null!==(r=l.exec(o));)n.push({start:r.index,length:r[0].length,error:`Value "${r[0]}" can't be safely passed as a path parameter`});if(n.sort((e,t)=>e.start-t.start),n.length>0){let e=[];for(let t of n)for(let i=t.start;i<t.start+Math.max(1,t.length);i++)e[i]="^";let t=Array.from(e,e=>e??" ").join("");throw new ry.v(`Path parameters result in path with invalid segments:
|
|
1
|
+
module.exports=[[72749,(e,t,i)=>{var r,s=e.e&&e.e.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)});Object.defineProperty(i,"__esModule",{value:!0});var n=function(){function e(e){void 0===e&&(e="="),this._paddingCharacter=e}return e.prototype.encodedLength=function(e){return this._paddingCharacter?(e+2)/3*4|0:(8*e+5)/6|0},e.prototype.encode=function(e){for(var t="",i=0;i<e.length-2;i+=3){var r=e[i]<<16|e[i+1]<<8|e[i+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 s=e.length-i;if(s>0){var r=e[i]<<16|(2===s?e[i+1]<<8:0);t+=this._encodeByte(r>>>18&63),t+=this._encodeByte(r>>>12&63),2===s?t+=this._encodeByte(r>>>6&63):t+=this._paddingCharacter||"",t+=this._paddingCharacter||""}return t},e.prototype.maxDecodedLength=function(e){return this._paddingCharacter?e/4*3|0:(6*e+7)/8|0},e.prototype.decodedLength=function(e){return this.maxDecodedLength(e.length-this._getPaddingLength(e))},e.prototype.decode=function(e){if(0===e.length)return new Uint8Array(0);for(var t=this._getPaddingLength(e),i=e.length-t,r=new Uint8Array(this.maxDecodedLength(i)),s=0,n=0,a=0,o=0,l=0,c=0,u=0;n<i-4;n+=4)o=this._decodeChar(e.charCodeAt(n+0)),l=this._decodeChar(e.charCodeAt(n+1)),c=this._decodeChar(e.charCodeAt(n+2)),u=this._decodeChar(e.charCodeAt(n+3)),r[s++]=o<<2|l>>>4,r[s++]=l<<4|c>>>2,r[s++]=c<<6|u,a|=256&o,a|=256&l,a|=256&c,a|=256&u;if(n<i-1&&(o=this._decodeChar(e.charCodeAt(n)),l=this._decodeChar(e.charCodeAt(n+1)),r[s++]=o<<2|l>>>4,a|=256&o,a|=256&l),n<i-2&&(c=this._decodeChar(e.charCodeAt(n+2)),r[s++]=l<<4|c>>>2,a|=256&c),n<i-3&&(u=this._decodeChar(e.charCodeAt(n+3)),r[s++]=c<<6|u,a|=256&u),0!==a)throw Error("Base64Coder: incorrect characters for decoding");return r},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,String.fromCharCode(t+=62-e>>>8&3)},e.prototype._decodeChar=function(e){return 256+((42-e&e-44)>>>8&-256+e-43+62)+((46-e&e-48)>>>8&-256+e-47+63)+((47-e&e-58)>>>8&-256+e-48+52)+((64-e&e-91)>>>8&-256+e-65+0)+((96-e&e-123)>>>8&-256+e-97+26)},e.prototype._getPaddingLength=function(e){var t=0;if(this._paddingCharacter){for(var i=e.length-1;i>=0&&e[i]===this._paddingCharacter;i--)t++;if(e.length<4||t>2)throw Error("Base64Coder: incorrect padding")}return t},e}();i.Coder=n;var a=new n;i.encode=function(e){return a.encode(e)},i.decode=function(e){return a.decode(e)};var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return s(t,e),t.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,String.fromCharCode(t+=62-e>>>8&49)},t.prototype._decodeChar=function(e){return 256+((44-e&e-46)>>>8&-256+e-45+62)+((94-e&e-96)>>>8&-256+e-95+63)+((47-e&e-58)>>>8&-256+e-48+52)+((64-e&e-91)>>>8&-256+e-65+0)+((96-e&e-123)>>>8&-256+e-97+26)},t}(n);i.URLSafeCoder=o;var l=new o;i.encodeURLSafe=function(e){return l.encode(e)},i.decodeURLSafe=function(e){return l.decode(e)},i.encodedLength=function(e){return a.encodedLength(e)},i.maxDecodedLength=function(e){return a.maxDecodedLength(e)},i.decodedLength=function(e){return a.decodedLength(e)}},305518,(e,t,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Webhook=i.WebhookVerificationError=void 0;let r=e.r(72749),s=e.r(426900),n=e.r(182864);class a extends Error{constructor(e){super(e),Object.setPrototypeOf(this,a.prototype),this.name="ExtendableError",this.stack=Error(e).stack}}class o extends a{constructor(e){super(e),Object.setPrototypeOf(this,o.prototype),this.name="WebhookVerificationError"}}i.WebhookVerificationError=o;class l{constructor(e,t){if((null==t?void 0:t.format)==="raw")e instanceof Uint8Array?this.key=e:this.key=Uint8Array.from(e,e=>e.charCodeAt(0));else{if("string"!=typeof e)throw Error("Expected secret to be of type string");e.startsWith(l.prefix)&&(e=e.substring(l.prefix.length)),this.key=r.decode(e)}if(0===this.key.length)throw Error("Secret can't be empty.")}verify(e,t,i){var r;let s=null==(r=null==i?void 0:i.jsonParse)||r,a={};for(let e of Object.keys(t))a[e.toLowerCase()]=t[e];let l=a["webhook-id"],c=a["webhook-signature"],u=a["webhook-timestamp"];if(!c||!l||!u)throw new o("Missing required headers");let h=this.verifyTimestamp(u),d=this.sign(l,h,e).split(",")[1],p=c.split(" "),_=new globalThis.TextEncoder;for(let t of p){let[i,r]=t.split(",");if("v1"===i&&(0,n.timingSafeEqual)(_.encode(r),_.encode(d))){let t=e.toString();if(""===t)return;if(s)return JSON.parse(t);return}}throw new o("No matching signature found")}sign(e,t,i){if("string"==typeof i);else if("Buffer"===i.constructor.name)i=i.toString();else throw Error("Expected payload to be of type string or Buffer.");let n=new TextEncoder,a=Math.floor(t.getTime()/1e3),o=n.encode(`${e}.${a}.${i}`),l=r.encode(s.hmac(this.key,o));return`v1,${l}`}verifyTimestamp(e){let t=Math.floor(Date.now()/1e3),i=parseInt(e,10);if(Number.isNaN(i))throw new o("Invalid Signature Headers");if(t-i>300)throw new o("Message timestamp too old");if(i>t+300)throw new o("Message timestamp too new");return new Date(1e3*i)}}i.Webhook=l,l.prefix="whsec_"},182864,(e,t,i)=>{function r(e,t=""){if(!e)throw Error(t)}Object.defineProperty(i,"__esModule",{value:!0}),i.timingSafeEqual=function(e,t){if(e.byteLength!==t.byteLength)return!1;e instanceof DataView||(e=new DataView(ArrayBuffer.isView(e)?e.buffer:e)),t instanceof DataView||(t=new DataView(ArrayBuffer.isView(t)?t.buffer:t)),r(e instanceof DataView),r(t instanceof DataView);let i=e.byteLength,s=0,n=-1;for(;++n<i;)s|=e.getUint8(n)^t.getUint8(n);return 0===s}},690604,e=>{let t,i,r;var s,n,a,o,l,c,u,h,d,p,_,f,g,m,v,b,y,w,k,z,S,x,V,A,I,q,$,R,P,T,E,O,M,L,C,N,j,D,W,U,F,H,B,K,J,G,X,Q,Y,Z,ee,et,ei,er,es,en,ea,eo,el,ec,eu,eh,ed,ep,e_,ef,eg,em,ev,eb,ey,ew,ek,ez,eS,ex,eV,eA,eI,eq,e$,eR,eP,eT,eE,eO,eM,eL,eC,eN,ej,eD,eW,eU,eF,eH,eB,eK,eJ,eG,eX,eQ,eY,eZ,e0,e1,e2,e6,e4,e5,e8,e3,e9,e7,te,tt,ti,tr,ts,tn,ta,to,tl,tc,tu,th,td,tp,t_,tf,tg,tm,tv,tb,ty,tw,tk,tz,tS,tx,tV,tA,tI,tq,t$,tR,tP,tT,tE,tO,tM,tL,tC,tN,tj,tD,tW,tU,tF,tH,tB,tK,tJ,tG,tX,tQ,tY,tZ,t0,t1,t2,t6,t4,t5,t8,t3,t9,t7,ie,it,ii,ir,is,ia,io,il,ic,iu,ih,id=e.i(996155),ip=e.i(664219);let i_=(e,t)=>new Promise(i=>{if(t?.aborted)return i();let r=()=>{clearTimeout(s),i()},s=setTimeout(()=>{t?.removeEventListener("abort",r),i()},e);t?.addEventListener("abort",r,{once:!0})});var ig=e.i(150580);let im="1.3.0",iv=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",ib=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown",iy=()=>t??(t=(()=>{let e="u">typeof Deno&&null!=Deno.build?"deno":"u">typeof EdgeRuntime?"edge":"[object process]"===Object.prototype.toString.call(void 0!==globalThis.process?globalThis.process:0)?"node":"unknown";if("deno"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":im,"X-Stainless-OS":ib(Deno.build.os),"X-Stainless-Arch":iv(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:Deno.version?.deno??"unknown"};if("u">typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":im,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process?.version??"unknown"};if("node"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":im,"X-Stainless-OS":ib(globalThis.process.platform??"unknown"),"X-Stainless-Arch":iv(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let t=function(){if("u"<typeof navigator||!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 i=t.exec(navigator.userAgent);if(i){let t=i[1]||0,r=i[2]||0,s=i[3]||0;return{browser:e,version:`${t}.${r}.${s}`}}}return null}();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":im,"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":im,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}})()),iw=new WeakMap,ik="function"==typeof globalThis.FinalizationRegistry?new globalThis.FinalizationRegistry(e=>iz(e)):null;function iz(e){let t=iw.get(e);t&&(iw.delete(e),ik?.unregister(e),t())}function iS(...e){let t=globalThis.ReadableStream;if(void 0===t)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ix(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return iS({start(){},async pull(e){let{done:i,value:r}=await t.next();i?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}let iV="u"<typeof FinalizationRegistry?void 0:new FinalizationRegistry(async e=>{try{await e.return?.()}catch{}});async function*iA(e){let t=function(e){if(e[Symbol.asyncIterator])return e[Symbol.asyncIterator]();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}}}}(e),i={};iV?.register(i,t,i);try{for await(let e of{[Symbol.asyncIterator]:()=>t})yield e}finally{iV?.unregister(i)}}async function iI(e){if(null===e||"object"!=typeof e)return;if(e[Symbol.asyncIterator])return void await e[Symbol.asyncIterator]().return?.();let t=e.getReader(),i=t.cancel();t.releaseLock(),await i}let iq=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)}),i$="1.10.0",iR=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/,iP=function(e){let t=new Set([e]),i=new Set,r=e.match(iR);if(!r)return()=>!1;let s={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(null!=s.prerelease)return function(t){return t===e};function n(e){return i.add(e),!1}return function(e){if(t.has(e))return!0;if(i.has(e))return!1;let r=e.match(iR);if(!r)return n(e);let a={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(null!=a.prerelease||s.major!==a.major)return n(e);if(0===s.major)return s.minor===a.minor&&s.patch<=a.patch?(t.add(e),!0):n(e);return s.minor<=a.minor?(t.add(e),!0):n(e)}}(i$),iT=i$.split(".")[0],iE=Symbol.for(`opentelemetry.js.api.${iT}`),iO="object"==typeof globalThis?globalThis:"object"==typeof self?self:e.g;function iM(e,t,i,r=!1){var s;let n=iO[iE]=null!=(s=iO[iE])?s:Object.defineProperty({},"version",{value:i$,enumerable:!0,writable:!1,configurable:!1});if(!r&&n[e]){let t=Error(`@opentelemetry/api: Attempted duplicate registration of API: ${e}`);return i.error(t.stack||t.message),!1}if("1.10.0"!==n.version){let t=Error(`@opentelemetry/api: Registration of version v${n.version} for ${e} does not match previously registered API v${i$}`);return i.error(t.stack||t.message),!1}return n[e]=t,i.debug(`@opentelemetry/api: Registered a global for ${e} v${i$}.`),!0}function iL(e){let t=iO[iE];if(null!=t){if(t!==i){if(!t.version||!iP(t.version))return;i=t}return t[e]}}function iC(e,t){t.debug(`@opentelemetry/api: Unregistering a global for ${e} v${i$}.`);let i=iO[iE];i&&delete i[e]}var iN=class{constructor(e){this._namespace=e.namespace||"DiagComponentLogger"}debug(...e){return ij("debug",this._namespace,e)}error(...e){return ij("error",this._namespace,e)}info(...e){return ij("info",this._namespace,e)}warn(...e){return ij("warn",this._namespace,e)}verbose(...e){return ij("verbose",this._namespace,e)}};function ij(e,t,i){let r=iL("diag");if(r)return r[e](t,...i)}var iD=class e{static instance(){return this._instance||(this._instance=new e),this._instance}constructor(){function e(e){return function(...t){let i=iL("diag");if(i)return i[e](...t)}}let t=this;t.setLogger=(e,i={logLevel:60})=>{var r,s,n;if(e===t){let e=Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return t.error(null!=(s=e.stack)?s:e.message),!1}"number"==typeof i&&(i={logLevel:i});let a=iL("diag"),o=function(e,t){function i(i,r){let s=t[i];return"function"==typeof s&&e>=r?s.bind(t):function(){}}return e<0?e=0:e>9999&&(e=9999),t=t||{},{error:i("error",30),warn:i("warn",50),info:i("info",60),debug:i("debug",70),verbose:i("verbose",80)}}(null!=(r=i.logLevel)?r:60,e);if(a&&!i.suppressOverrideMessage){let e=null!=(n=(Error()).stack)?n:"<failed to generate stacktrace>";a.warn(`Current logger will be overwritten from ${e}`),o.warn(`Current logger will overwrite one already registered from ${e}`)}return iM("diag",o,t,!0)},t.disable=()=>{iC("diag",t)},t.createComponentLogger=e=>new iN(e),t.verbose=e("verbose"),t.debug=e("debug"),t.info=e("info"),t.warn=e("warn"),t.error=e("error")}};function iW(e){return Symbol.for(e)}let iU=new class e{constructor(t){let i=this;i._currentContext=t?new Map(t):new Map,i.getValue=e=>i._currentContext.get(e),i.setValue=(t,r)=>{let s=new e(i._currentContext);return s._currentContext.set(t,r),s},i.deleteValue=t=>{let r=new e(i._currentContext);return r._currentContext.delete(t),r}}},iF="context",iH=new class{active(){return iU}with(e,t,i,...r){return t.call(i,...r)}bind(e,t){return t}enable(){return this}disable(){return this}attach(e){return{dispose(){}}}},iB=Object.freeze({dispose:()=>{}});var iK=class e{constructor(){this._attachUnsupportedWarned=!1}static getInstance(){return this._instance||(this._instance=new e),this._instance}setGlobalContextManager(e){return iM(iF,e,iD.instance())}active(){return this._getContextManager().active()}with(e,t,i,...r){return this._getContextManager().with(e,t,i,...r)}bind(e,t){return this._getContextManager().bind(e,t)}attach(e){let t=this._getContextManager();return t.attach?t.attach(e):(this._attachUnsupportedWarned||(this._attachUnsupportedWarned=!0,iD.instance().warn("The current ContextManager does not implement attach(). The context will not be attached. Use a ContextManager that supports attach() (e.g. AsyncLocalStorageContextManager) or use with()/bind() instead.")),iB)}_getContextManager(){return iL(iF)||iH}disable(){this._getContextManager().disable(),iC(iF,iD.instance())}};let iJ=iK.getInstance();var iG=class e{constructor(e){this._entries=e?new Map(e):new Map}getEntry(e){let t=this._entries.get(e);if(t)return Object.assign({},t)}getAllEntries(){return Array.from(this._entries.entries())}setEntry(t,i){let r=new e(this._entries);return r._entries.set(t,i),r}removeEntry(t){let i=new e(this._entries);return i._entries.delete(t),i}removeEntries(...t){let i=new e(this._entries);for(let e of t)i._entries.delete(e);return i}clear(){return new e}};function iX(e={}){return new iG(new Map(Object.entries(e)))}Symbol("BaggageEntryMetadata"),iD.instance();let iQ={get(e,t){if(null!=e)return e[t]},keys:e=>null==e?[]:Object.keys(e)},iY={set(e,t,i){null!=e&&(e[t]=i)}},iZ=iW("OpenTelemetry Baggage Key");function i0(e){return e.getValue(iZ)||void 0}function i1(){return i0(iK.getInstance().active())}function i2(e,t){return e.setValue(iZ,t)}function i6(e){return e.deleteValue(iZ)}let i4="propagation",i5=new class{inject(e,t){}extract(e,t){return e}fields(){return[]}},i8=(class e{constructor(){this.createBaggage=iX,this.getBaggage=i0,this.getActiveBaggage=i1,this.setBaggage=i2,this.deleteBaggage=i6}static getInstance(){return this._instance||(this._instance=new e),this._instance}setGlobalPropagator(e){return iM(i4,e,iD.instance())}inject(e,t,i=iY){return this._getGlobalPropagator().inject(e,t,i)}extract(e,t,i=iQ){return this._getGlobalPropagator().extract(e,t,i)}fields(){return this._getGlobalPropagator().fields()}disable(){iC(i4,iD.instance())}_getGlobalPropagator(){return iL(i4)||i5}}).getInstance(),i3={traceId:"00000000000000000000000000000000",spanId:"0000000000000000",traceFlags:0};var i9=class{constructor(e=i3){this._spanContext=e}spanContext(){return this._spanContext}setAttribute(e,t){return this}setAttributes(e){return this}addEvent(e,t){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,t){}};let i7=iW("OpenTelemetry Context Key SPAN");function re(e){return e.getValue(i7)||void 0}function rt(){return re(iK.getInstance().active())}function ri(e,t){return e.setValue(i7,t)}function rr(e){return e.deleteValue(i7)}function rs(e,t){return ri(e,new i9(t))}function rn(e){var t;return null==(t=re(e))?void 0:t.spanContext()}let ra=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function ro(e,t){if("string"!=typeof e||e.length!==t)return!1;let i=0;for(let t=0;t<e.length;t+=4)i+=(0|ra[e.charCodeAt(t)])+(0|ra[e.charCodeAt(t+1)])+(0|ra[e.charCodeAt(t+2)])+(0|ra[e.charCodeAt(t+3)]);return i===t}function rl(e){var t,i;return ro(t=e.traceId,32)&&"00000000000000000000000000000000"!==t&&ro(i=e.spanId,16)&&"0000000000000000"!==i}function rc(e){return new i9(e)}let ru=iK.getInstance();var rh=class{startSpan(e,t,i=ru.active()){var r;if(null==t?void 0:t.root)return new i9;let s=i&&rn(i);return null!==(r=s)&&"object"==typeof r&&"spanId"in r&&"string"==typeof r.spanId&&"traceId"in r&&"string"==typeof r.traceId&&"traceFlags"in r&&"number"==typeof r.traceFlags&&rl(s)?new i9(s):new i9}startActiveSpan(e,t,i,r){var s;let n,a,o;if(arguments.length<2)return;2==arguments.length?o=t:3==arguments.length?(n=t,o=i):(n=t,a=i,o=r);let l=null!=(s=a)?s:ru.active(),c=this.startSpan(e,n,l),u=ri(l,c);return ru.with(u,o,void 0,c)}};let rd=new rh;var rp=class{constructor(e,t,i,r){this._provider=e,this.name=t,this.version=i,this.options=r}startSpan(e,t,i){return this._getTracer().startSpan(e,t,i)}startActiveSpan(e,t,i,r){let s=this._getTracer();return Reflect.apply(s.startActiveSpan,s,arguments)}_getTracer(){if(this._delegate)return this._delegate;let e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):rd}};let r_=new class{getTracer(e,t,i){return new rh}};var rf=class{getTracer(e,t,i){var r;return null!=(r=this.getDelegateTracer(e,t,i))?r:new rp(this,e,t,i)}getDelegate(){var e;return null!=(e=this._delegate)?e:r_}setDelegate(e){this._delegate=e}getDelegateTracer(e,t,i){var r;return null==(r=this._delegate)?void 0:r.getTracer(e,t,i)}};let rg="trace",rm=(class e{constructor(){this._proxyTracerProvider=new rf,this.wrapSpanContext=rc,this.isSpanContextValid=rl,this.deleteSpan=rr,this.getSpan=re,this.getActiveSpan=rt,this.getSpanContext=rn,this.setSpan=ri,this.setSpanContext=rs}static getInstance(){return this._instance||(this._instance=new e),this._instance}setGlobalTracerProvider(e){let t=iM(rg,this._proxyTracerProvider,iD.instance());return t&&this._proxyTracerProvider.setDelegate(e),t}getTracerProvider(){return iL(rg)||this._proxyTracerProvider}getTracer(e,t){return this.getTracerProvider().getTracer(e,t)}disable(){iC(rg,iD.instance()),this._proxyTracerProvider=new rf}}).getInstance(),rv=((s={})[s.INTERNAL=0]="INTERNAL",s[s.SERVER=1]="SERVER",s[s.CLIENT=2]="CLIENT",s[s.PRODUCER=3]="PRODUCER",s[s.CONSUMER=4]="CONSUMER",s),rb=((n={})[n.UNSET=0]="UNSET",n[n.OK=1]="OK",n[n.ERROR=2]="ERROR",n);var ry=e.i(364351),rw=e.i(687160),rk=(()=>{class e{constructor(){a.set(this,void 0),o.set(this,void 0),(0,id.b)(this,a,new Uint8Array,"f"),(0,id.b)(this,o,null,"f")}decode(e){let t;if(null==e)return[];let i=e instanceof ArrayBuffer?new Uint8Array(e):"string"==typeof e?(0,rw.b)(e):e;(0,id.b)(this,a,(0,rw.t)([(0,id.V)(this,a,"f"),i]),"f");let r=[];for(;null!=(t=function(e,t){for(let i=t??0;i<e.length;i++){if(10===e[i])return{preceding:i,index:i+1,carriage:!1};if(13===e[i])return{preceding:i,index:i+1,carriage:!0}}return null}((0,id.V)(this,a,"f"),(0,id.V)(this,o,"f")));){if(t.carriage&&null==(0,id.V)(this,o,"f")){(0,id.b)(this,o,t.index,"f");continue}if(null!=(0,id.V)(this,o,"f")&&(t.index!==(0,id.V)(this,o,"f")+1||t.carriage)){r.push((0,rw.z)((0,id.V)(this,a,"f").subarray(0,(0,id.V)(this,o,"f")-1))),(0,id.b)(this,a,(0,id.V)(this,a,"f").subarray((0,id.V)(this,o,"f")),"f"),(0,id.b)(this,o,null,"f");continue}let e=null!==(0,id.V)(this,o,"f")?t.preceding-1:t.preceding,i=(0,rw.z)((0,id.V)(this,a,"f").subarray(0,e));r.push(i),(0,id.b)(this,a,(0,id.V)(this,a,"f").subarray(t.index),"f"),(0,id.b)(this,o,null,"f")}return r}flush(){return(0,id.V)(this,a,"f").length?this.decode("\n"):[]}}return a=new WeakMap,o=new WeakMap,e.NEWLINE_CHARS=new Set(["\n","\r"]),e.NEWLINE_REGEXP=/\r\n|[\n\r]/g,e})(),rz=e.i(511935),rS=(()=>{class e{constructor(e,t,i){this.iterator=e,l.set(this,void 0),this.controller=t,(0,id.b)(this,l,i,"f")}static rawEvents(e,t=new AbortController){return rx(e,t)}static fromSSEResponse(t,i,r){let s=!1,n=r?(0,rz.u)(r):console;return new e(async function*(){if(s)throw new ry.v("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let e=!1;try{for await(let e of rx(t,i))if("ping"!==e.event&&null!==e.event)if("error"===e.event){let i=(0,ip.k)(e.data)??e.data,r=i?.error?.type;throw new ry.E(void 0,i,void 0,t.headers,r)}else{if(!e.data)continue;try{yield JSON.parse(e.data)}catch(t){throw n.error("Could not parse message into JSON:",e.data),n.error("From chunk:",e.raw),t}}e=!0}catch(e){if((0,ig.c)(e))return;throw e}finally{e||i.abort(),iz(i)}},i,r)}static fromReadableStream(t,i,r){let s=!1;async function*n(){let e=new rk;for await(let i of iA(t))for(let t of e.decode(i))yield t;for(let t of e.flush())yield t}return new e(async function*(){if(s)throw new ry.v("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let e=!1;try{for await(let t of n())!e&&t&&(yield JSON.parse(t));e=!0}catch(e){if((0,ig.c)(e))return;throw e}finally{e||i.abort(),iz(i)}},i,r)}[(l=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],i=[],r=this[Symbol.asyncIterator](),s=e=>({next:()=>{if(0===e.length){let e=r.next();t.push(e),i.push(e)}return e.shift()}});return[new e(()=>s(t),this.controller,(0,id.V)(this,l,"f")),new e(()=>s(i),this.controller,(0,id.V)(this,l,"f"))]}toReadableStream(){let e,t=this;return iS({async start(){e=t[Symbol.asyncIterator]()},async pull(t){try{let{value:i,done:r}=await e.next();if(r)return t.close();let s=(0,rw.b)(JSON.stringify(i)+"\n");t.enqueue(s)}catch(e){t.error(e)}},async cancel(){await e.return?.()}})}}return e})();async function*rx(e,t){if(!e.body){if(t.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new ry.v("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new ry.v("Attempted to iterate over a response with no body")}let i=new rV,r=new rk;for await(let t of iA(e.body))for(let e of r.decode(t)){let t=i.decode(e);t&&(yield t)}for(let e of r.flush()){let t=i.decode(e);t&&(yield t)}}class rV{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){var t;let i;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("\n"),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(":"))return null;let[r,s,n]=-1!==(i=(t=e).indexOf(":"))?[t.substring(0,i),":",t.substring(i+1)]:[t,"",""];return n.startsWith(" ")&&(n=n.substring(1)),"event"===r?this.event=n:"data"===r&&this.data.push(n),null}}let rA=Symbol.for("brand.privateNullableHeaders"),rI=Symbol("clear"),rq=new Set(["x-stainless-helper"]),r$=(e,t)=>{let i=e?e.split(",").map(e=>e.trim()).filter(Boolean):[];for(let e of t.split(",").map(e=>e.trim()))e&&!i.includes(e)&&i.push(e);return i.join(", ")},rR=e=>{let t=new Headers,i=new Set;for(let r of e){let e=new Set;for(let[s,n]of function*(e){let t;if(!e)return;if(rA in e){let{values:t,nulls:i}=e;for(let e of(yield*t.entries(),i))yield[e,null];return}let i=!1;for(let r of(e instanceof Headers?t=e.entries():(0,ip.z)(e)?t=e:(i=!0,t=Object.entries(e??{})),t)){let e=r[0];if("string"!=typeof e)throw TypeError("expected header name to be a string");let t=(0,ip.z)(r[1])?r[1]:[r[1]],s=!1;for(let r of t)void 0!==r&&(i&&!s&&(s=!0,yield[e,rI]),yield[e,r])}}(r)){let r=s.toLowerCase();if(rq.has(r)){if(n===rI)continue;null===n?(t.delete(s),i.add(r)):(t.set(s,r$(t.get(s),n)),i.delete(r));continue}(n!==rI&&e.has(r)||(t.delete(s),e.add(r),n!==rI))&&(null===n?(t.delete(s),i.add(r)):(t.append(s,n),i.delete(r)))}}return{[rA]:!0,values:t,nulls:i}};var rP=e.i(931963);let rT="com.anthropic.sdk.typescript",rE="gen_ai.conversation.id",rO="gen_ai.provider.name",rM="http.response.status_code";function rL(e,t){try{return t()}catch(t){e&&(0,rz.u)(e).debug("could not record telemetry",t);return}}function rC(e,t,i,r){if(i?.__span)return i.__span;let s=e._tracer;if(s)return rL(e,()=>{let n=Date.now(),a=r?.attributes?.["anthropic.session.thread.id"],o=i?.openTelemetry?.conversationId??("string"==typeof a?a:void 0),l=s.startSpan(t,{kind:rv.CLIENT,attributes:{[rO]:e._genAIProviderName,...function(e){try{let{hostname:t,port:i,protocol:r}=new URL(e);return{"server.address":t.replace(/^\[(.*)\]$/,"$1"),"server.port":i?Number(i):"http:"===r?80:443}}catch{return{}}}(e.baseURL),...null!=o?{[rE]:o}:void 0,...r?.route!=null?{"http.route":r.route}:void 0,...r?.attributes}});if(l.isRecording()||(e.openTelemetry.propagation?Object.keys(rU(l)).length>0:rm.isSpanContextValid(l.spanContext())))return{...r,span:l,name:t,startTime:n}})}let rN=["email","path_prefix","expected_content_sha256"];function rj(e,t){if(e.isRecording()){var i,r;let s;switch(i=e,r=t,void 0!==(s=r.response?.status??("error"===r.status&&r.error instanceof ry.E?r.error.status:void 0))&&i.setAttribute(rM,s),t.status){case"success":e.setStatus({code:rb.OK});break;case"error":rW(e,t.error)}e.end()}}function rD(e,t,i){let r=e[Symbol.asyncIterator],s=!1,n=e=>{if(!s){s=!0,t.removeEventListener("abort",a);try{i.onEnd(e)}catch{}}},a=()=>n({reason:"canceled"});if(t.aborted)return a();t.addEventListener("abort",a,{once:!0});let o=!1;e[Symbol.asyncIterator]=function(){let e=r.call(this);if(o)return e;o=!0,t.removeEventListener("abort",a);let l={async next(){let r;try{r=await e.next()}catch(e){throw n({reason:"failed",error:e}),e}if(r.done)n({reason:t.aborted?"canceled":"completed"});else if(!s)try{i.onItem?.(r.value)}catch{}return r},return:async t=>(a(),await e.return?.(t)??{done:!0,value:t}),async throw(t){if(a(),e.throw)return e.throw(t);throw t},[Symbol.asyncIterator]:()=>l};return l}}function rW(e,t,i){t instanceof ry.F||(0,ig.c)(t)||(e.setStatus({code:rb.ERROR}),e.setAttribute("error.type",i??function(e){if(e instanceof ry.R)return"client_timeout_error";if(e instanceof ry.I)return"connection_error";if(e instanceof ry.E){if(e.type)return e.type;if(void 0!==e.status)return String(e.status)}return"client_error"}(t)))}function rU(e){let t={};return i8.inject(rm.setSpan(iJ.active(),e),t),t}let rF="RFC3986",rH=e=>String(e),rB={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:rH},rK=(e,t)=>(rK=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty))(e,t),rJ=(()=>{let e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})();function rG(e,t){if((0,ip.o)(e)){let i=[];for(let r=0;r<e.length;r+=1)i.push(t(e[r]));return i}return t(e)}let rX={brackets:e=>String(e)+"[]",comma:"comma",indices:(e,t)=>String(e)+"["+t+"]",repeat:e=>String(e)},rQ=function(e,t){Array.prototype.push.apply(e,(0,ip.o)(t)?t:[t])},rY={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:(e,t,i,r,s)=>{if(0===e.length)return e;let n=e;if("symbol"==typeof e?n=Symbol.prototype.toString.call(e):"string"!=typeof e&&(n=String(e)),"iso-8859-1"===i)return escape(n).replace(/%u[0-9a-f]{4}/gi,function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"});let a="";for(let e=0;e<n.length;e+=1024){let t=n.length>=1024?n.slice(e,e+1024):n,i=[];for(let e=0;e<t.length;++e){let r=t.charCodeAt(e);if(45===r||46===r||95===r||126===r||r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||"RFC1738"===s&&(40===r||41===r)){i[i.length]=t.charAt(e);continue}if(r<128){i[i.length]=rJ[r];continue}if(r<2048){i[i.length]=rJ[192|r>>6]+rJ[128|63&r];continue}if(r<55296||r>=57344){i[i.length]=rJ[224|r>>12]+rJ[128|r>>6&63]+rJ[128|63&r];continue}e+=1,r=65536+((1023&r)<<10|1023&t.charCodeAt(e)),i[i.length]=rJ[240|r>>18]+rJ[128|r>>12&63]+rJ[128|r>>6&63]+rJ[128|63&r]}a+=i.join("")}return a},encodeValuesOnly:!1,format:rF,formatter:rH,indices:!1,serializeDate:e=>(r??(r=Function.prototype.call.bind(Date.prototype.toISOString)))(e),skipNulls:!1,strictNullHandling:!1},rZ={};var r0=ry;let r1="/v1/oauth/token",r2="oauth-2025-04-20";function r6(e){let t;if(!e)return;try{t=new URL(e)}catch(t){throw new se(`Invalid token endpoint base URL "${e}": ${t}`)}if("https:"===t.protocol)return;let i=t.hostname.toLowerCase().replace(/^\[|\]$/g,"");if("http:"!==t.protocol||"localhost"!==i&&"127.0.0.1"!==i&&"::1"!==i)throw new se(`Refusing to send credential over non-https token endpoint "${e}"`)}async function r4(e,t){let i,r=await r7(e);try{i=JSON.parse(r)}catch{throw new se(`Token endpoint returned non-JSON response (status ${e.status})`,e.status,r8(r),t)}if(!i.access_token)throw new se(`Token endpoint response missing access_token: ${JSON.stringify(r8(i))}`,e.status,r8(i),t);if(i.token_type&&"bearer"!==i.token_type.toLowerCase())throw new se(`Token endpoint response: unsupported token_type "${i.token_type}" (want Bearer)`,e.status,r8(i),t);return i}let r5=new Set(["error","error_description","error_uri"]);function r8(e){if(null==e)return e;if("string"==typeof e){let t;try{t=JSON.parse(e)}catch{if(e.length<=2e3)return e;return e.slice(0,2e3)+`... <${e.length-2e3} more chars>`}return JSON.stringify(r8(t))}if("object"==typeof e&&!Array.isArray(e)){let t={};for(let[i,r]of Object.entries(e))r5.has(i)&&(t[i]=r);return t}return null}async function r3(t,i=e=>console.warn(`anthropic-sdk: ${e}`)){let r;if("u"<typeof process||"win32"===process.platform)return;let{fs:s}=await e.A(79955),n=t;try{n=await s.promises.realpath(t),r=await s.promises.stat(n)}catch{return}let a=511&r.mode;if(18&a)throw new se(`Credentials file at ${n} is group/world-writable (mode 0o${a.toString(8)}); this allows other local users to plant tokens. Run \`chmod 600 ${n}\`.`);if(36&a)throw new se(`Credentials file at ${n} is group/world-readable (mode 0o${a.toString(8)}); run \`chmod 600 ${n}\` before retrying.`);"function"==typeof process.getuid&&r.uid!==process.getuid()&&i(`credentials file at ${n} is owned by uid ${r.uid} (current process uid ${process.getuid()}); verify this is intentional.`)}async function r9(t,i){let{fs:r,path:s}=await e.A(79955),n=s.dirname(t);await r.promises.mkdir(n,{recursive:!0,mode:448});let a=`${t}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;try{let e=await r.promises.open(a,"w",384);try{await e.writeFile(JSON.stringify(i,null,2)),await e.sync()}finally{await e.close()}await r.promises.rename(a,t)}catch(e){throw await r.promises.unlink(a).catch(()=>{}),e}try{let e=await r.promises.open(n,"r");try{await e.sync()}finally{await e.close()}}catch{}}async function r7(e){let t;if(!e.body)return"";let i=e.body.getReader(),r=[],s=0;for(;;){let{done:e,value:t}=await i.read();if(e)break;if(s+t.length>1048576){let e=1048576-s;e>0&&r.push(t.subarray(0,e)),await i.cancel();break}r.push(t),s+=t.length}if(1===r.length)t=r[0];else{t=new Uint8Array(r.reduce((e,t)=>e+t.length,0));let e=0;for(let i of r)t.set(i,e),e+=i.length}return new TextDecoder("utf-8").decode(t)}class se extends r0.v{constructor(e,t=null,i=null,r=null){super(e),this.statusCode=t,this.body=i,this.requestId=r}}function st(){return Math.floor(Date.now()/1e3)}class si{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||null==t)return(await this.refresh(e)).token;if(null==t.expiresAt)return t.token;let i=t.expiresAt-st();return i>120?t.token:i>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||st()-this.lastAdvisoryError<5||this.doRefresh().catch(e=>{this.lastAdvisoryError=st(),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}}let sr="gen_ai.input.messages",ss="gen_ai.operation.name",sn="gen_ai.output.messages",sa="gen_ai.output.type",so="gen_ai.request.model",sl="gen_ai.request.stop_sequences",sc="gen_ai.system_instructions",su="json",sh="anthropic.tool_result.content",sd=[["anthropic.request.id","request-id"],["anthropic.organization.id","anthropic-organization-id"],["anthropic.workspace.id","anthropic-workspace-id"]];function sp(e,t,i,r){let s=e.span,n=e.requestContentSize;if(void 0!==i&&void 0!==n){let e=JSON.stringify([{role:"assistant",parts:s_(i)}]);if(n+3*e.length<=r||n+sy(e)<=r)return void s.setAttribute(sn,e)}let a=sv(s,{[sl]:t.stop_sequences?.length?[...t.stop_sequences]:void 0,[sc]:void 0===t.system?void 0:s_(t.system),[sr]:t.messages.map(e=>({role:e.role,parts:s_(e.content)})),[sn]:void 0===i?void 0:[{role:"assistant",parts:s_(i)}]},r);void 0===i&&(e.requestContentSize=a)}function s_(e){return"string"==typeof e?[{type:"text",content:e}]:e?.map(sf)??[]}function sf(e){switch(e.type){case"text":return{type:"text",content:e.text};case"thinking":return{type:"reasoning",content:e.thinking};case"tool_use":return{type:"tool_call",id:e.id,name:e.name,arguments:e.input,..."string"==typeof e.toolset_name?{anthropic_toolset_name:e.toolset_name}:void 0};case"server_tool_use":return{type:"tool_call",id:e.id,name:e.name,arguments:e.input};case"mcp_tool_use":return{type:"tool_call",id:e.id,name:e.name,arguments:e.input,anthropic_mcp_server_name:e.server_name};case"tool_result":return{type:"tool_call_response",id:e.tool_use_id,response:sg(e.content)};default:if("string"!=typeof e.type)return{type:"anthropic_unknown"};if(e.type.endsWith("_tool_result")&&"tool_use_id"in e){var t;return{type:"tool_call_response",id:e.tool_use_id,response:null==(t=e.content)?[]:"string"==typeof t?[{type:"text",text:t}]:Array.isArray(t)?t.map(e=>"text"===e.type||"search_result"===e.type||"web_search_result"===e.type?sm(e):"string"!=typeof e.type?{type:"unknown"}:{type:e.type}):[sm(t)]}}return{type:`anthropic_${e.type}`}}}function sg(e){return null==e?[]:"string"==typeof e?[{type:"text",text:e}]:e.map(e=>"text"===e.type||"search_result"===e.type?sm(e):"string"!=typeof e.type?{type:"unknown"}:{type:e.type})}function sm(e){if(Array.isArray(e))return e.map(sm);if("object"!=typeof e||null===e)return e;let{type:t,file_type:i}=e;if("image"===t||"document"===t)return{type:t};let r="text_editor_code_execution_view_result"===t&&("image"===i||"pdf"===i);return Object.fromEntries(Object.entries(e).filter(([e])=>!e.startsWith("encrypted_")&&!("content"===e&&r)).map(([e,t])=>[e,sm(t)]))}function sv(e,t,i){let{[sl]:r,[sc]:s,[sr]:n,[sn]:a,[sh]:o,...l}=t,c={[sc]:s,[sr]:n,[sn]:a},u={},h=o?.map(e=>JSON.stringify(e)),d=3*([...r??[],...h??[]].reduce((e,t)=>e+t.length+1,2)+sb(l,u)+sb(c,u))<=i?e=>3*e.length:sy,p=()=>Object.keys(c).reduce((e,t)=>e+d(u[t]??""),0),_=r?.reduce((e,t)=>e+d(t),0)??0,f=void 0!==r&&_<=i,g=f?_:0,m=void 0!==r&&!f;for(let e of Object.keys(l)){let t=d(u[e]??"");t>i?(delete u[e],m=!0):g+=t}let v=p();if(g+v>i){let{truncated:e,...t}=function(e,t){let i=e=>e?.map(e=>({...e,parts:[...e.parts]})),r=e[sc]?.slice(),s=i(e[sr]),n=i(e[sn]),a=[r??[],...[...s??[],...n??[]].map(({parts:e})=>e)],o=a.reduce((e,t)=>e+t.length,0),l=!1;for(let e of a){let i=0;for(;t>0&&i<e.length;){let r=e[i],s=sy(JSON.stringify(r)),n=r.content;if(1===o&&"text"===r.type&&"string"==typeof n){let a=function(e,t,i){let r=i-sy(JSON.stringify({...e,content:""})),s=t.slice(0,Math.max(r,0)),n=JSON.stringify(s),a=0,o=0,l=0;for(;a<s.length;){let e=n.codePointAt(1+o),t=e>65535?2:1,i=92!==e?t:"u"===n[2+o]?6:2;if((l+=e<128?i:e<2048?2:e<65536?3:4)>r)break;o+=i,a+=t}return t.slice(0,a)}(r,n,s-t);a!==n&&(e[i]={...r,content:a},l=!0);break}t-=s+ +(i+1<e.length),i++,o--,l=!0}e.splice(0,i)}return{[sc]:r,[sr]:s,[sn]:n,truncated:l}}(c,g+v-i);m||(m=e),sb(t,u),v=p()}if(g+=v,void 0!==h){let e=function(e,t,i){let r=[],s=2;for(let n of e){let e=s+ +(0!==r.length)+i(n);if(e>t)break;r.push(n),s=e}return{json:"["+r.join(",")+"]",size:s,truncated:r.length<e.length}}(h,i-g,d);u[sh]=e.json,g+=e.size,m||(m=e.truncated)}for(let[t,i]of(m&&e.setAttribute("anthropic.content.truncated",!0),f&&e.setAttribute(sl,r),Object.entries(u)))e.setAttribute(t,i);return g}function sb(e,t){let i=0;for(let[r,s]of Object.entries(e))void 0!==s&&(t[r]=JSON.stringify(s),i+=t[r].length);return i}function sy(e){let t=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);r<128?t+=1:r<2048?t+=2:r>=55296&&r<56320&&(64512&e.charCodeAt(i+1))==56320?(t+=4,i++):t+=3}return t}function sw(e,t,i,r){e.setAttribute("gen_ai.response.id",t.id),e.setAttribute("gen_ai.response.model",t.model),e.setAttribute("gen_ai.usage.input_tokens",i.input_tokens+(i.cache_read_input_tokens??0)+(i.cache_creation_input_tokens??0)),null!=i.cache_creation_input_tokens&&e.setAttribute("gen_ai.usage.cache_write.input_tokens",i.cache_creation_input_tokens),null!=i.cache_read_input_tokens&&e.setAttribute("gen_ai.usage.cache_read.input_tokens",i.cache_read_input_tokens);let s=i.cache_creation;if(null!=s&&(e.setAttribute("anthropic.usage.cache_creation.ephemeral_5m_input_tokens",s.ephemeral_5m_input_tokens),e.setAttribute("anthropic.usage.cache_creation.ephemeral_1h_input_tokens",s.ephemeral_1h_input_tokens)),null!=i.service_tier&&e.setAttribute("anthropic.response.service_tier",i.service_tier),!r)return;e.setAttribute("gen_ai.usage.output_tokens",i.output_tokens);let n=i.output_tokens_details;null!=n&&e.setAttribute("gen_ai.usage.reasoning.output_tokens",n.thinking_tokens);let a=i.iterations?.filter(e=>"compaction"===e.type)??[];a.length>0&&(e.setAttribute("anthropic.usage.compaction.input_tokens",a.reduce((e,t)=>e+t.input_tokens+t.cache_read_input_tokens+t.cache_creation_input_tokens,0)),e.setAttribute("anthropic.usage.compaction.output_tokens",a.reduce((e,t)=>e+t.output_tokens,0))),null!=t.stop_reason&&e.setAttribute("anthropic.message.stop_reason",t.stop_reason)}function sk(e,t,i){if(t.isRecording())try{let e="error"===i.status?i.error:void 0,r=i.response?.headers??(e instanceof ry.E?e.headers:void 0);for(let[e,i]of sd){let s=r?.get(i);s&&t.setAttribute(e,s)}}catch(t){(0,rz.u)(e).debug("could not record the API call on its span",t)}}function sz(e,t,i){let r={[ss]:"chat",[so]:t.model};try{let s=(rR([e._options.defaultHeaders,i]).values.get("anthropic-beta")??"").split(",").map(e=>e.trim()).filter(Boolean);s.length&&(r["anthropic.beta"]=s),r["gen_ai.request.max_tokens"]=t.max_tokens,!0===t.stream&&(r["gen_ai.request.stream"]=!0),t.output_config?.format?.type==="json_schema"&&(r[sa]=su);let n=t.output_config?.effort;null!=n&&(r["gen_ai.request.reasoning.level"]=n),null!=t.service_tier&&(r["anthropic.request.service_tier"]=t.service_tier);let a=t.thinking;null!=a&&(r["anthropic.thinking.type"]=a.type),a?.type==="enabled"&&(r["anthropic.thinking.budget_tokens"]=a.budget_tokens)}catch(t){(0,rz.u)(e).debug("could not record the request on its span",t)}return{route:"/v1/messages",attributes:r}}function sS(e,t,i){if(!t?.span.isRecording())return t;try{let{contentMode:r,maxContentBytes:s}=e.openTelemetry.traces;"content"===r&&sp(t,i,void 0,s)}catch(t){(0,rz.u)(e).debug("could not record the request on its span",t)}return t}function sx(e,t,i,r){if(!t?.span.isRecording()||r instanceof rS)return;let s=t.span;try{sw(s,r,r.usage,!0);let{contentMode:n,maxContentBytes:a}=e.openTelemetry.traces;"content"===n&&sp(t,i,r.content,a)}catch(t){(0,rz.u)(e).debug("could not record the response on its span",t)}}function sV(e,t,i){try{t?.span.setAttribute("anthropic.message.count_tokens.input_tokens",i.input_tokens)}catch(t){(0,rz.u)(e).debug("could not record the response on its span",t)}}function sA(e){let t=function(){let e=new Set(["traceparent","tracestate","baggage"]);try{for(let t of i8.fields())e.add(t.toLowerCase())}catch(e){(0,rz.i)().debug("could not record telemetry",e)}return e}(),i=Array.from(e.entries()).filter(([e])=>t.has(e));for(let[t]of i)e.delete(t);return i}function sI(e){return(t,i,r)=>{let s=new Headers(t.headers),n=sA(s);return e({...t,headers:s},e=>{let t=new Headers(e.headers);for(let[e,i]of n)t.set(e,i);return i({...e,headers:t})},r)}}let sq=/^[A-Za-z0-9_.-]+$/;function s$(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(!sq.test(e))throw Error(`profile name "${e}" contains disallowed characters (allowed: letters, digits, '_', '.', '-')`)}let sR=async t=>{var i,r;let s,n,a=await sT();if(null===a)return null;let o=null==t&&null!=(0,rP.f)("ANTHROPIC_PROFILE"),l=null;if(null==t&&!o){let e=(0,rP.f)("ANTHROPIC_ORGANIZATION_ID"),t=(0,rP.f)("ANTHROPIC_IDENTITY_TOKEN_FILE"),i=(0,rP.f)("ANTHROPIC_FEDERATION_RULE_ID");if(i&&e&&(l={fromFile:!1,config:{organization_id:e,workspace_id:(0,rP.f)("ANTHROPIC_WORKSPACE_ID"),base_url:(0,rP.f)("ANTHROPIC_BASE_URL"),authentication:{type:"oidc_federation",federation_rule_id:i,service_account_id:(0,rP.f)("ANTHROPIC_SERVICE_ACCOUNT_ID"),identity_token:t?{source:"file",path:t}:void 0,scope:(0,rP.f)("ANTHROPIC_SCOPE")}}},t||(0,rP.f)("ANTHROPIC_IDENTITY_TOKEN")))return l}let c=t??await sO();if(null===c)return null;s$(c);let{fs:u,path:h}=await e.A(79955),d=h.join(a,"configs",`${c}.json`);try{s=await u.promises.readFile(d,"utf-8")}catch(e){if(e?.code!=="ENOENT")throw Error(`failed to read config file ${d}: ${e}`);if(o)throw new ry.v(`ANTHROPIC_PROFILE names the profile "${c}", but ${d} does not exist. Set ANTHROPIC_PROFILE to a profile that exists, or unset it.`,{cause:e});return l}try{n=JSON.parse(s)}catch(e){throw Error(`failed to parse config file ${d}: ${e}`)}if(!n.authentication)throw Error(`config file ${d} is missing "authentication"`);let p=n.authentication.type;if("oidc_federation"!==p&&"user_oauth"!==p)throw Error(`authentication.type "${p}" is not a known authentication type`);if(n.organization_id??(n.organization_id=(0,rP.f)("ANTHROPIC_ORGANIZATION_ID")),n.workspace_id??(n.workspace_id=(0,rP.f)("ANTHROPIC_WORKSPACE_ID")),n.base_url??(n.base_url=(0,rP.f)("ANTHROPIC_BASE_URL")),(i=n.authentication).scope??(i.scope=(0,rP.f)("ANTHROPIC_SCOPE")),"oidc_federation"===n.authentication.type){if(!n.authentication.identity_token){let e=(0,rP.f)("ANTHROPIC_IDENTITY_TOKEN_FILE");e&&(n.authentication.identity_token={source:"file",path:e})}n.authentication.federation_rule_id||(n.authentication.federation_rule_id=(0,rP.f)("ANTHROPIC_FEDERATION_RULE_ID")??""),(r=n.authentication).service_account_id??(r.service_account_id=(0,rP.f)("ANTHROPIC_SERVICE_ACCOUNT_ID"))}return{config:n,fromFile:!0}},sP=async(t,i)=>{if(t?.authentication.credentials_path)return t.authentication.credentials_path;let r=await sT();if(!r)return null;let s=i??await sO();if(!s)return null;s$(s);let{path:n}=await e.A(79955);return n.join(r,"credentials",`${s}.json`)},sT=async()=>{if(!sE())return null;let{path:t}=await e.A(79955),i=(0,rP.f)("ANTHROPIC_CONFIG_DIR");if(i)return i;if("Windows"===iy()["X-Stainless-OS"]){let e=(0,rP.f)("APPDATA");if(e)return t.join(e,"Anthropic");let i=(0,rP.f)("USERPROFILE");return i?t.join(i,"AppData","Roaming","Anthropic"):null}let r=(0,rP.f)("XDG_CONFIG_HOME");if(r)return t.join(r,"anthropic");let s=(0,rP.f)("HOME");return s?t.join(s,".config","anthropic"):null},sE=()=>{let e=iy()["X-Stainless-Runtime"];return"node"===e||"deno"===e},sO=async()=>{let t=await sT();if(!t)return null;let i=(0,rP.f)("ANTHROPIC_PROFILE");if(i)return i;let{fs:r,path:s}=await e.A(79955),n=s.join(t,"active_config");try{return(await r.promises.readFile(n,"utf-8")).trim()||"default"}catch(e){if(e?.code!=="ENOENT")throw Error(`failed to read ${n}: ${e}`);return"default"}};function sM(t){if(!t)throw new ry.v("Identity token file path is empty");return async()=>{let i,{fs:r}=await e.A(79955);try{i=await r.promises.readFile(t,"utf-8")}catch(e){throw new ry.v(`Failed to read identity token file at ${t}: ${e}`)}let s=i.trim();if(!s)throw new ry.v(`Identity token file at ${t} is empty`);return s}}function sL(t,i){let r=t.authentication.credentials_path??null,s=(t.base_url||i.baseURL).replace(/\/+$/,""),n=function(t,i,r,s){var n,a,o,l,c,u;switch(t.authentication.type){case"oidc_federation":{let a=t.authentication,h=function(e){if(e.identity_token){let t=e.identity_token.source;if("file"!==t)throw new se(`identity_token.source "${t}" is not supported by this SDK version (only "file")`);if(!e.identity_token.path)throw new se('identity_token.source "file" requires a non-empty path');return sM(e.identity_token.path)}let t=(0,rP.f)("ANTHROPIC_IDENTITY_TOKEN_FILE");if(t)return sM(t);let i=(0,rP.f)("ANTHROPIC_IDENTITY_TOKEN");if(i){if(!i)throw new ry.v("Identity token value is empty");return()=>i}return null}(a);if(!h)throw new se("oidc_federation config requires an identity token (set authentication.identity_token, ANTHROPIC_IDENTITY_TOKEN_FILE, or ANTHROPIC_IDENTITY_TOKEN)");if(!a.federation_rule_id)throw new se("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(!t.organization_id)throw new se("oidc_federation config requires organization_id (set ANTHROPIC_ORGANIZATION_ID or config.organization_id)");let d=(n={identityTokenProvider:h,federationRuleId:a.federation_rule_id,organizationId:t.organization_id,serviceAccountId:a.service_account_id,workspaceId:t.workspace_id,baseURL:r,fetch:s.fetch,userAgent:s.userAgent},async()=>{let e;r6(n.baseURL);let t=await n.identityTokenProvider();if(t.length>16384)throw new se(`Identity token is ${Math.ceil(t.length/1024)} KiB, exceeds the 16 KiB assertion limit`);let i={grant_type:"urn:ietf:params:oauth:grant-type:jwt-bearer",assertion:t,federation_rule_id:n.federationRuleId,organization_id:n.organizationId};n.serviceAccountId&&(i.service_account_id=n.serviceAccountId),n.workspaceId&&(i.workspace_id=n.workspaceId);let r=`${n.baseURL}${r1}`;try{e=await n.fetch(r,{method:"POST",redirect:"manual",headers:{"Content-Type":"application/json","anthropic-beta":`${r2},oidc-federation-2026-04-01`,"User-Agent":n.userAgent||`anthropic-sdk-typescript/${im} oidcFederationProvider`},body:JSON.stringify(i)})}catch(e){throw new se(`Failed to reach token endpoint ${r}: ${e}`)}let s=e.headers.get("Request-Id");if(!e.ok){let t=r8(await e.text().catch(()=>"")),i="";if(401===e.status){let e=n.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. ";i=` Ensure your federation rule matches your identity token. ${e}View your authentication events in the Workload identity page of Claude Console for more details.`}throw new se(`Token exchange failed with status ${e.status}${s?` (request-id ${s})`:""}: ${t}${i}`,e.status,t,s)}let a=await r4(e,s),o=Number(a.expires_in);if(!Number.isFinite(o))throw new se(`Token endpoint response missing required fields: ${JSON.stringify(r8(a))}`,e.status,r8(a),s);return{token:a.access_token,expiresAt:st()+o}});if(i){return o=d,l=i,c=s.onCacheWriteError,u=s.onSafetyWarning,async t=>{let i,{fs:r}=await e.A(79955);await r3(l,u);try{let e=await r.promises.readFile(l,"utf-8");i=JSON.parse(e);let s=i?.access_token;if(s&&!t?.forceRefresh){let e=i?.expires_at;if(null==e||st()<e-30)return{token:s,expiresAt:e??null}}}catch(e){"ENOENT"===e?.code||e instanceof SyntaxError||c?.(e)}let s=await o(t);try{await r9(l,{...i??{},version:"1.0",type:"oauth_token",access_token:s.token,expires_at:s.expiresAt})}catch(e){c?.(e)}return s}}return d}case"user_oauth":if(!i)throw new se("user_oauth config requires authentication.credentials_path (or load via a profile so it defaults to <config_dir>/credentials/<profile>.json)");return a={credentialsPath:i,clientId:t.authentication.client_id,baseURL:r,fetch:s.fetch,userAgent:s.userAgent,onSafetyWarning:s.onSafetyWarning},async t=>{let i,r,s,{fs:n}=await e.A(79955);await r3(a.credentialsPath,a.onSafetyWarning);try{i=await n.promises.readFile(a.credentialsPath,"utf-8")}catch(e){throw new se(`Credentials file not found at ${a.credentialsPath}: ${e}`)}try{r=JSON.parse(i)}catch(e){throw new se(`Credentials file at ${a.credentialsPath} is not valid JSON: ${e}`)}let o=r.access_token;if(!o)throw new se(`Credentials file at ${a.credentialsPath} must include 'access_token'`);let l=r.expires_at;if(!t?.forceRefresh&&(null==l||st()<l-30))return{token:o,expiresAt:l??null};let c=r.refresh_token;if(!a.clientId||!c)throw new se(`Access token at ${a.credentialsPath} has expired and no refresh is available (client_id ${a.clientId?"set":"empty"}, refresh_token ${c?"set":"empty"})`);r6(a.baseURL);let u={grant_type:"refresh_token",refresh_token:c,client_id:a.clientId},h=`${a.baseURL}${r1}`;try{s=await a.fetch(h,{method:"POST",redirect:"manual",headers:{"Content-Type":"application/json","anthropic-beta":r2,"User-Agent":a.userAgent||`anthropic-sdk-typescript/${im} userOAuthProvider`},body:JSON.stringify(u)})}catch(e){throw new se(`User OAuth refresh failed to reach token endpoint: ${e}`)}let d=s.headers.get("Request-Id");if(!s.ok){let e=await s.text().catch(()=>"");throw new se(`User OAuth refresh failed (HTTP ${s.status}): ${r8(e)}`,s.status,r8(e),d)}let p=await r4(s,d),_=Number(p.expires_in);if(!Number.isFinite(_))throw new se(`User OAuth refresh response missing or invalid expires_in: ${JSON.stringify(r8(p))}`,s.status,r8(p),d);let f=st()+_,g=p.refresh_token||c;return await r9(a.credentialsPath,{...r,version:"1.0",type:"oauth_token",access_token:p.access_token,expires_at:f,refresh_token:g}),{token:p.access_token,expiresAt:f}};default:{let e=t.authentication.type;throw new se(`authentication.type "${e}" is not a known authentication type`)}}}(t,r,s,i),a={};return t.workspace_id&&"user_oauth"===t.authentication.type&&(a["anthropic-workspace-id"]=t.workspace_id),{provider:n,extraHeaders:a,baseURL:t.base_url||void 0}}async function sC(e,t){let i=await sR(t);if(!i)return null;let{config:r,fromFile:s}=i;return sL(r.authentication.credentials_path||!s?r:{...r,authentication:{...r.authentication,credentials_path:await sP(r,t)??void 0}},e)}async function sN(e,t){let{response:i,requestLogID:r,retryOfRequestLogID:s,startTime:n}=t,a=await (async()=>{if(t.options.stream)return(0,rz.u)(e).debug("response",i.status,i.url,i.headers,i.body),rS.fromSSEResponse(i,t.controller,e);if(204===i.status)return null;if(t.options.__binaryResponse)return i;let r=i.headers.get("content-type"),s=r?.split(";")[0]?.trim();if(s?.includes("application/json")||s?.endsWith("+json")){if("0"===i.headers.get("content-length"))return;return sj(await i.json(),i)}return await i.text()})().finally(()=>{t.options.stream||t.options.__binaryResponse||iz(t.controller)});return(0,rz.M)((0,rz.u)(e),`[${r}] response parsed`,{retryOfRequestLogID:s,url:i.url,status:i.status,body:a,durationMs:Date.now()-n}),a}function sj(e,t){return!e||"object"!=typeof e||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}})}let sD=new WeakSet;function sW(e){return"object"==typeof e&&null!==e&&sD.has(e)}function sU(e,t,i,r){return async(s,n={})=>{if(0===t.length)return e.call(void 0,s,n);let a=n.headers instanceof Headers?n.headers:new Headers(n.headers),o=await (function(e,t,i,r){let s,n=async({url:t,...i})=>{try{return await e.call(void 0,t,i)}catch(t){let e=(0,ig.Y)(t);throw sD.add(e),e}},a=(s=new WeakMap,{options:i,logger:r?(0,rz.u)(r):(0,rz.i)(),parse(e){if(i?.stream&&e.ok)return sF(e,i,r);let t=s.get(e);return t||(t=sF(e,i,r),s.set(e,t)),t}});for(let e=t.length-1;e>=0;e--){let i=t[e],r=n;n=async e=>i(e,r,a)}return n})(e,t,i,r)({...n,headers:a,url:"string"==typeof s?s:s instanceof URL?s.href:s.url});if(o.bodyUsed||o.body?.locked)throw new ry.v("middleware consumed the response body; use response.clone() to inspect it, or return new Response(body, response) to consume and replace it");return o}}async function sF(e,t,i){if(e.bodyUsed||e.body?.locked)throw new ry.v("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 rS.fromSSEResponse(e.clone(),new AbortController,i);if(204===e.status)return null;if(t?.__binaryResponse)return e;let r=e.headers.get("content-type"),s=r?.split(";")[0]?.trim();if(s?.includes("application/json")||s?.endsWith("+json")){if("0"===e.headers.get("content-length"))return;return sj(await e.clone().json(),e)}return await e.clone().text()}let sH=()=>{if("u"<typeof File){let{process:e}=globalThis;throw Error("`File` is not defined as a global, which is required for file uploads."+("string"==typeof e?.versions?.node&&20>parseInt(e.versions.node.split("."))?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function sB(e,t,i){return sH(),new File(e,t??"",i)}function sK(e,t){let i="object"==typeof e&&null!==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?i.split(/[\\/]/).pop()||void 0:i}let sJ=e=>null!=e&&"object"==typeof e&&"function"==typeof e[Symbol.asyncIterator],sG=async(e,t,i=!0)=>{try{return{...e,body:await sQ(e.body,t,i)}}catch(r){let i=e.__span?.span;throw i&&rL("function"==typeof t?void 0:t,()=>rj(i,{status:"error",options:e,error:r})),r}},sX=new WeakMap,sQ=async(e,t,i=!0)=>{if(!await function(e){let t="function"==typeof e?e:e.fetch,i=sX.get(t);if(i)return i;let r=(async()=>{try{let e="Response"in t?t.Response:(await t("data:,")).constructor,i=new FormData;if(i.toString()===await new e(i).text())return!1;return!0}catch{return!0}})();return sX.set(t,r),r}(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])=>sY(r,e,t,i))),r},sY=async(e,t,i,r)=>{if(void 0!==i){if(null==i)throw TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if("string"==typeof i||"number"==typeof i||"boolean"==typeof i)e.append(t,String(i));else if(i instanceof Response){let s={},n=i.headers.get("Content-Type");n&&(s={type:n}),e.append(t,sB([await i.blob()],sK(i,r),s))}else if(sJ(i))e.append(t,sB([await new Response(ix(i)).blob()],sK(i,r)));else if(i instanceof Blob){let s="u">typeof File&&i instanceof File?i.name:sK(i,r);e.append(t,sB([i],s,{type:i.type}))}else if(Array.isArray(i))await Promise.all(i.map(i=>sY(e,t+"[]",i,r)));else if("function"==typeof i.then)throw TypeError(`Received a Promise for "${t}"; await it first, e.g. \`await toFile(...)\``);else if(i instanceof ArrayBuffer||ArrayBuffer.isView(i))throw TypeError(`Received ${i.constructor.name} for "${t}"; to upload raw bytes, wrap them with \`await toFile(bytes, 'filename')\``);else if("object"==typeof i)await Promise.all(Object.entries(i).map(([i,s])=>sY(e,`${t}[${i}]`,s,r)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${i} instead`)}};function sZ(e,t,i,r){if(t.span.isRecording()&&"content"===e.openTelemetry.traces.contentMode)try{sp(t,i,r.content,e.openTelemetry.traces.maxContentBytes)}catch(t){(0,rz.u)(e).debug("could not record the streamed message on its span",t)}}var s0=(c=new WeakMap,class e extends Promise{constructor(e,t,i=sN){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=i,c.set(this,void 0),(0,id.b)(this,c,e,"f")}_responseProps(){return this.responsePromise}_thenUnwrap(t){return new e((0,id.V)(this,c,"f"),this.responsePromise,async(e,i)=>sj(t(await this.parseResponse(e,i),i),i.response))}asResponse(){return this.responsePromise.then(e=>{let t=e.options.__span?.span;if(t&&!this.parsedPromise){let i={status:"success",...e,data:void 0};sk((0,id.V)(this,c,"f"),t,i),rL((0,id.V)(this,c,"f"),()=>rj(t,i))}return 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.parsedPromise=this.responsePromise.then(e=>this.parseResponseTraced(e))),this.parsedPromise}async parseResponseTraced(e){let t,i=e.options.__span;if(!i)return this.parseResponse((0,id.V)(this,c,"f"),e);let{span:r}=i;try{t=await this.parseResponse((0,id.V)(this,c,"f"),e)}catch(i){let t={status:"error",...e,error:i};throw sk((0,id.V)(this,c,"f"),r,t),rL((0,id.V)(this,c,"f"),()=>rj(r,t)),i}let s={status:"success",...e,data:t};return rL((0,id.V)(this,c,"f"),()=>(function(e,t){if(void 0===e.createdIDAttribute||"object"!=typeof t||null===t)return;let i=t[e.createdIDField??"id"];"string"==typeof i&&e.span.setAttribute(e.createdIDAttribute,i)})(i,t)),sk((0,id.V)(this,c,"f"),r,s),e.options.stream&&sJ(t)?rL((0,id.V)(this,c,"f"),()=>{var i,s;return i=(0,id.V)(this,c,"f"),s=t,void(e.options.__span?.name==="anthropic.messages.create"&&s instanceof rS?function(e,t,i,r){let s,n;if(!t.isRecording())return;t.setAttribute(rM,r.response.status);let a=r.options.__span,o=a?.startTime,l=!1,c=!1,u=!1;rD(i,r.controller.signal,{onItem(i){try{switch(i.type){case"message_start":{let{id:e,model:t,stop_reason:r}=i.message;s={id:e,model:t,stop_reason:r},n={...i.message.usage};break}case"content_block_start":s&&"fallback"===i.content_block.type&&(s.model=i.content_block.to.model);break;case"message_delta":s&&n&&(n.output_tokens=i.usage.output_tokens,null!=i.usage.input_tokens&&(n.input_tokens=i.usage.input_tokens),null!=i.usage.cache_creation_input_tokens&&(n.cache_creation_input_tokens=i.usage.cache_creation_input_tokens),null!=i.usage.cache_read_input_tokens&&(n.cache_read_input_tokens=i.usage.cache_read_input_tokens),null!=i.usage.output_tokens_details&&(n.output_tokens_details=i.usage.output_tokens_details),"iterations"in i.usage&&null!=i.usage.iterations&&(n.iterations=i.usage.iterations),null!=i.delta.stop_reason&&(s.stop_reason=i.delta.stop_reason),c=!0);break;case"message_stop":u=!0;break;case"content_block_delta":l||void 0===o||t.setAttribute("gen_ai.response.time_to_first_chunk",(Date.now()-o)/1e3),l=!0;break;case"content_block_stop":break;default:(0,ip.f)(i)}}catch(t){(0,rz.u)(e).debug("could not record the stream on its span",t)}},onEnd(i){try{s&&n&&sw(t,s,n,c||u)}catch(t){(0,rz.u)(e).debug("could not record the stream on its span",t)}let r=a?.failure;!u&&a?.streamed&&void 0===r&&sZ(e,a,a.streamed.body,a.streamed.message),"failed"===i.reason?rW(t,i.error):void 0!==r?rW(t,r,"client_error"):"completed"===i.reason&&(u?t.setStatus({code:rb.OK}):rW(t,new ry.v("The stream ended before message_stop."),"api_error")),rL(e,()=>t.end())}})}(i,r,s,e):function(e,t,i){if(!e.isRecording())return;e.setAttribute(rM,i.response.status);let r=t instanceof rS;rD(t,i.controller.signal,{onEnd(t){"failed"===t.reason?rW(e,t.error):"completed"!==t.reason||r||e.setStatus({code:rb.OK}),e.end()}})}(r,s,e))}):rL((0,id.V)(this,c,"f"),()=>rj(r,s)),t}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}),s1=(()=>{class e{constructor(e,t,i,r){u.set(this,void 0),(0,id.b)(this,u,e,"f"),this.options=r,this.response=t,this.body=i}hasNextPage(){return!!this.getPaginatedItems().length&&null!=this.nextPageRequestOptions()}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new ry.v("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");let t=this.options.__span;return await (0,id.V)(this,u,"f").requestAPIList(this.constructor,{...e,__span:t&&rC((0,id.V)(this,u,"f"),t.name,{openTelemetry:this.options.openTelemetry},{route:t.route,queryParams:t.queryParams,contentQueryParams:t.contentQueryParams,attributes:t.attributes})})}async *iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async *[(u=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}}return e})(),s2=(()=>{class e extends s0{constructor(e,t,i){super(e,t,async(e,t)=>new i(e,t.response,await sN(e,t),t.options))}async *[Symbol.asyncIterator](){for await(let e of(await this))yield e}}return e})();class s6 extends s1{constructor(e,t,i,r){super(e,t,i,r),this.data=i.data||[],this.has_more=i.has_more||!1,this.first_id=i.first_id||null,this.last_id=i.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){let e=this.first_id;return e?{...this.options,query:{...(0,ip.V)(this.options.query),before_id:e}}:null}let e=this.last_id;return e?{...this.options,query:{...(0,ip.V)(this.options.query),after_id:e}}:null}}class s4 extends s1{constructor(e,t,i,r){super(e,t,i,r),this.data=i.data||[],this.next_page=i.next_page||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return null!=this.nextPageRequestOptions()}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{...(0,ip.V)(this.options.query),page:e}}:null}}class s5 extends s1{constructor(e,t,i,r){super(e,t,i,r),this.data=i.data||[],this.next_page=i.next_page||null,this.prev_page=i.prev_page||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return null!=this.nextPageRequestOptions()}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{...(0,ip.V)(this.options.query),page:e}}:null}}class s8 extends s1{constructor(e,t,i,r){super(e,t,i,r),this.data=i.data||[],this.next_page=i.next_page||null,this.has_more=i.has_more||!1,this.data_refreshed_at=i.data_refreshed_at||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&null!=this.nextPageRequestOptions()}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{...(0,ip.V)(this.options.query),page:e}}:null}}let s3=e=>null!=e&&"object"==typeof e&&"number"==typeof e.size&&"string"==typeof e.type&&"function"==typeof e.text&&"function"==typeof e.slice&&"function"==typeof e.arrayBuffer;async function s9(e,t,i){let r,s;if(sH(),e=await e,t||(t=e instanceof File?e.name:sK(e,!0)),null!=(r=e)&&"object"==typeof r&&"string"==typeof r.name&&"number"==typeof r.lastModified&&s3(r))return e instanceof File&&null==t&&null==i?e:sB([await e.arrayBuffer()],t??e.name,{type:e.type,lastModified:e.lastModified,...i});if(null!=(s=e)&&"object"==typeof s&&"string"==typeof s.url&&"function"==typeof s.blob){let r=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),sB(await s7(r),t,i)}let n=await s7(e);if(!i?.type){let e=n.find(e=>"object"==typeof e&&"type"in e&&e.type);"string"==typeof e&&(i={...i,type:e})}return sB(n,t,i)}async function s7(e){let t=[];if("string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(s3(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(sJ(e))for await(let i of e)t.push(...await s7(i));else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:""}${function(e){if("object"!=typeof e||null===e)return"";let t=Object.getOwnPropertyNames(e);return`; props: [${t.map(e=>`"${e}"`).join(", ")}]`}(e)}`)}return t}class ne{constructor(e){this._client=e}}let nt="x-stainless-helper",ni="x-stainless-helper-method",nr=Symbol("anthropic.sdk.stainlessHelper");function ns(e){return"object"==typeof e&&null!==e&&nr in e}function nn(e,t){let i=new Set;if(e)for(let t of e)ns(t)&&i.add(t[nr]);if(t)for(let e of t){ns(e)&&i.add(e[nr]);let t=e.content;if(Array.isArray(t))for(let e of t){ns(e)&&i.add(e[nr]);let t=e?.tool?.definition;ns(t)&&i.add(t[nr])}}return Array.from(i)}function na(e,t){let i=nn(e,t);return 0===i.length?{}:{[nt]:i.join(", ")}}function no(e){return ns(e)?{[nt]:e[nr]}:{}}function nl(e,t){let{user_profile_id:i,workspace_id:r,tools:s,messages:n}=e;return rR([{...null!=i?{"anthropic-user-profile-id":i}:void 0,...null!=r?{"anthropic-workspace-id":r}:void 0},na(s,n),t?.headers])}function nc(e){return e?.output_config?.format}function nu(e,t,i){let r=nc(t);return t&&"parse"in(r??{})?nh(e,t,i):{...e,content:e.content.map(e=>"text"===e.type?Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1}):e),parsed_output:null}}function nh(e,t,i){let r=null,s=e.content.map(e=>{if("text"===e.type){let i=function(e,t){let i=nc(e);if(i?.type!=="json_schema")return null;try{if("parse"in i)return i.parse(t);return JSON.parse(t)}catch(e){throw new ry.v(`Failed to parse structured output: ${e}`)}}(t,e.text);return null===r&&(r=i),Object.defineProperty({...e},"parsed_output",{value:i,enumerable:!1})}return e});return{...e,content:s,parsed_output:r}}let nd="__json_buf";function np(e,t){let i,r={};for(let t of Object.keys(e))"input"!==t&&(r[t]=e[t]);Object.defineProperty(r,nd,{value:t,enumerable:!1,writable:!0});let s=!1;return Object.defineProperty(r,"input",{enumerable:!0,configurable:!0,get(){if(!s){var e;let r,n;i=t?JSON.parse((e=(e=>{let t=[];for(let i of e)("brace"===i.type||"paren"===i.type)&&("{"===i.value||"["===i.value?t.push(i.value):t.pop());let i=t[t.length-1],r=e.length,s=/^-?(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||!s.test(t.value)){r--;continue}break;case"string":let n=e[r-2];if("{"===i&&(n?.type==="delimiter"||n?.type==="brace"&&"{"===n.value)){r--;continue}break;case"delimiter":r--}break}return e.slice(0,r)})((e=>{let t=0,i=[];for(;t<e.length;){let r=e[t];if("\\"===r){t++;continue}if("{"===r){i.push({type:"brace",value:"{"}),t++;continue}if("}"===r){i.push({type:"brace",value:"}"}),t++;continue}if("["===r){i.push({type:"paren",value:"["}),t++;continue}if("]"===r){i.push({type:"paren",value:"]"}),t++;continue}if(":"===r){i.push({type:"separator",value:":"}),t++;continue}if(","===r){i.push({type:"delimiter",value:","}),t++;continue}if('"'===r){let r=t+1,s=r,n=!1;for(;;){if(-1===(s=e.indexOf('"',s))){n=!0;break}let t=0,i=s-1;for(;i>=r&&"\\"===e[i];)t++,i--;if(t%2==0)break;s++}n?t=e.length:(i.push({type:"string",value:e.slice(r,s)}),t=s+1);continue}let s=/\s/;if(r&&s.test(r)){t++;continue}let n=/[0-9]/;if(r&&n.test(r)||"-"===r||"."===r){let s="";for("-"===r&&(s+=r,r=e[++t]);r&&(n.test(r)||"."===r||"e"===r||"E"===r||("-"===r||"+"===r)&&("e"===s[s.length-1]||"E"===s[s.length-1]));)s+=r,r=e[++t];i.push({type:"number",value:s,unterminated:t===e.length});continue}let a=/[a-z]/i;if(r&&a.test(r)){let s="";for(;r&&a.test(r)&&t!==e.length;)s+=r,r=e[++t];"true"==s||"false"==s||"null"===s?i.push({type:"name",value:s}):t++;continue}t++}return i})(t)),r=[],e.map(e=>{"brace"===e.type&&("{"===e.value?r.push("}"):r.splice(r.lastIndexOf("}"),1)),"paren"===e.type&&("["===e.value?r.push("]"):r.splice(r.lastIndexOf("]"),1))}),r.length>0&&r.reverse().map(t=>{"}"===t?e.push({type:"brace",value:"}"}):"]"===t&&e.push({type:"paren",value:"]"})}),n="",e.map(e=>{"string"===e.type?n+='"'+e.value+'"':n+=e.value}),n)):{},s=!0}return i}}),r}function n_(e){return"tool_use"===e.type||"server_tool_use"===e.type}var nf=(()=>{class e{constructor(e,t){h.add(this),this.messages=[],this.receivedMessages=[],d.set(this,void 0),p.set(this,null),this.controller=new AbortController,_.set(this,void 0),f.set(this,()=>{}),g.set(this,()=>{}),m.set(this,void 0),v.set(this,()=>{}),b.set(this,()=>{}),y.set(this,{}),w.set(this,!1),k.set(this,!1),z.set(this,!1),S.set(this,!1),x.set(this,void 0),V.set(this,void 0),A.set(this,void 0),I.set(this,void 0),q.set(this,void 0),$.set(this,void 0),T.set(this,e=>{if((0,id.b)(this,k,!0,"f"),(0,id.V)(this,$,"f")&&((0,id.V)(this,$,"f").streamed=void 0),(0,ig.c)(e)&&(e=new ry.F),e instanceof ry.F)return(0,id.b)(this,z,!0,"f"),this._emit("abort",e);if(e instanceof ry.v)return this._emit("error",e);if(e instanceof Error){let t=new ry.v(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new ry.v(String(e)))}),(0,id.b)(this,_,new Promise((e,t)=>{(0,id.b)(this,f,e,"f"),(0,id.b)(this,g,t,"f")}),"f"),(0,id.b)(this,m,new Promise((e,t)=>{(0,id.b)(this,v,e,"f"),(0,id.b)(this,b,t,"f")}),"f"),(0,id.V)(this,_,"f").catch(()=>{}),(0,id.V)(this,m,"f").catch(()=>{}),(0,id.b)(this,p,e,"f"),(0,id.b)(this,I,t?.logger??console,"f"),(0,id.b)(this,q,t?.client,"f")}get response(){return(0,id.V)(this,x,"f")}get request_id(){return(0,id.V)(this,V,"f")}get workspace_id(){return(0,id.V)(this,A,"f")}async withResponse(){(0,id.b)(this,S,!0,"f");let e=await (0,id.V)(this,_,"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 i=new e(null);return i._run(()=>i._fromReadableStream(t)),i}static createMessage(t,i,r,{logger:s,client:n}={}){let a=new e(i,{logger:s,client:n});for(let e of i.messages)a._addMessageParam(e);return(0,id.b)(a,p,{...i,stream:!0},"f"),a._run(()=>a._createMessage(t,{...i,stream:!0},{...r,headers:{...r?.headers,[ni]:"stream"}})),a}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},(0,id.V)(this,T,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,i){let r,s=i?.signal;s&&(s.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),s.addEventListener("abort",r));try{(0,id.V)(this,h,"m",E).call(this),(0,id.b)(this,$,i?.__span??((0,id.V)(this,q,"f")&&function(e,t,i){if(!e._tracer)return;let r=nl(t,i);return rC(e,"anthropic.messages.create",i,sz(e,{...t,stream:!0},r))}((0,id.V)(this,q,"f"),t,i)),"f");let{response:r,data:s}=await e.create({...t,stream:!0},{...i,__span:(0,id.V)(this,$,"f"),signal:this.controller.signal}).withResponse();try{this._connected(r)}catch(e){throw(0,id.V)(this,$,"f")&&((0,id.V)(this,$,"f").failure=e),s.controller.abort(),e}for await(let e of s)try{(0,id.V)(this,h,"m",O).call(this,e)}catch(e){throw(0,id.V)(this,$,"f")&&((0,id.V)(this,$,"f").failure=e),e}if(s.controller.signal?.aborted)throw new ry.F;(0,id.V)(this,h,"m",M).call(this)}finally{s&&r&&s.removeEventListener("abort",r)}}_connected(e){this.ended||((0,id.b)(this,x,e,"f"),(0,id.b)(this,V,e?.headers.get("request-id"),"f"),(0,id.b)(this,A,e?.headers.get("anthropic-workspace-id"),"f"),(0,id.V)(this,f,"f").call(this,e),this._emit("connect"))}get ended(){return(0,id.V)(this,w,"f")}get errored(){return(0,id.V)(this,k,"f")}get aborted(){return(0,id.V)(this,z,"f")}abort(){this.controller.abort()}on(e,t){return((0,id.V)(this,y,"f")[e]||((0,id.V)(this,y,"f")[e]=[])).push({listener:t}),this}off(e,t){let i=(0,id.V)(this,y,"f")[e];if(!i)return this;let r=i.findIndex(e=>e.listener===t);return r>=0&&i.splice(r,1),this}once(e,t){return((0,id.V)(this,y,"f")[e]||((0,id.V)(this,y,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,i)=>{(0,id.b)(this,S,!0,"f"),"error"!==e&&this.once("error",i),this.once(e,t)})}async done(){(0,id.b)(this,S,!0,"f"),await (0,id.V)(this,m,"f")}get currentMessage(){return(0,id.V)(this,d,"f")}async finalMessage(){return await this.done(),(0,id.V)(this,h,"m",R).call(this)}async finalText(){return await this.done(),(0,id.V)(this,h,"m",P).call(this)}_emit(e,...t){if((0,id.V)(this,w,"f"))return;"end"===e&&((0,id.b)(this,w,!0,"f"),(0,id.V)(this,v,"f").call(this));let i=(0,id.V)(this,y,"f")[e];if(i&&((0,id.V)(this,y,"f")[e]=i.filter(e=>!e.once),i.forEach(({listener:e})=>e(...t))),"abort"===e){let e=t[0];(0,id.V)(this,S,"f")||i?.length||Promise.reject(e),(0,id.V)(this,g,"f").call(this,e),(0,id.V)(this,b,"f").call(this,e),this._emit("end");return}if("error"===e){let e=t[0];(0,id.V)(this,S,"f")||i?.length||Promise.reject(e),(0,id.V)(this,g,"f").call(this,e),(0,id.V)(this,b,"f").call(this,e),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",(0,id.V)(this,h,"m",R).call(this))}async _fromReadableStream(e,t){let i,r=t?.signal;r&&(r.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),r.addEventListener("abort",i));try{(0,id.V)(this,h,"m",E).call(this),this._connected(null);let t=rS.fromReadableStream(e,this.controller);for await(let e of t)(0,id.V)(this,h,"m",O).call(this,e);if(t.controller.signal?.aborted)throw new ry.F;(0,id.V)(this,h,"m",M).call(this)}finally{r&&i&&r.removeEventListener("abort",i)}}[(d=new WeakMap,p=new WeakMap,_=new WeakMap,f=new WeakMap,g=new WeakMap,m=new WeakMap,v=new WeakMap,b=new WeakMap,y=new WeakMap,w=new WeakMap,k=new WeakMap,z=new WeakMap,S=new WeakMap,x=new WeakMap,V=new WeakMap,A=new WeakMap,I=new WeakMap,q=new WeakMap,$=new WeakMap,T=new WeakMap,h=new WeakSet,R=function(){if(0===this.receivedMessages.length)throw new ry.v("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},P=function(){if(0===this.receivedMessages.length)throw new ry.v("stream ended without producing a Message with role=assistant");let e=this.receivedMessages.at(-1).content.filter(e=>"text"===e.type).map(e=>e.text);if(0===e.length)throw new ry.v("stream ended without producing a content block with type=text");return e.join(" ")},E=function(){this.ended||(0,id.b)(this,d,void 0,"f")},O=function(e){if(this.ended)return;let t=(0,id.V)(this,h,"m",L).call(this,e);if(this._emit("_rawEvent",e),t)switch(this._emit("streamEvent",e,t),e.type){case"content_block_delta":{let i=t.content.at(-1);switch(e.delta.type){case"text_delta":"text"===i.type&&this._emit("text",e.delta.text,i.text||"");break;case"citations_delta":"text"===i.type&&this._emit("citation",e.delta.citation,i.citations??[]);break;case"input_json_delta":n_(i)&&(0,id.V)(this,y,"f").inputJson?.length&&this._emit("inputJson",e.delta.partial_json,i.input);break;case"thinking_delta":"thinking"===i.type&&this._emit("thinking",e.delta.thinking,i.thinking);break;case"signature_delta":"thinking"===i.type&&this._emit("signature",i.signature);break;default:(0,ip.f)(e.delta)}break}case"message_stop":(0,id.V)(this,q,"f")&&(0,id.V)(this,$,"f")&&(0,id.V)(this,p,"f")&&sZ((0,id.V)(this,q,"f"),(0,id.V)(this,$,"f"),(0,id.V)(this,p,"f"),t),this._addMessageParam(t),this._addMessage(nu(t,(0,id.V)(this,p,"f"),{logger:(0,id.V)(this,I,"f")}),!0);break;case"content_block_stop":this._emit("contentBlock",t.content.at(-1));break;case"message_start":(0,id.b)(this,d,t,"f"),(0,id.V)(this,$,"f")&&(0,id.V)(this,p,"f")&&((0,id.V)(this,$,"f").streamed={body:(0,id.V)(this,p,"f"),message:t})}},M=function(){if(this.ended)throw new ry.v("stream has ended, this shouldn't happen");let e=(0,id.V)(this,d,"f");if(!e)throw new ry.v("request ended without sending any chunks");return(0,id.b)(this,d,void 0,"f"),nu(e,(0,id.V)(this,p,"f"),{logger:(0,id.V)(this,I,"f")})},L=function(e){let t=(0,id.V)(this,d,"f");if("message_start"===e.type){if(t)throw new ry.v(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(t)switch(e.type){case"message_stop":default: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,null!=e.delta.container&&(t.container=e.delta.container),null!=e.usage.input_tokens&&(t.usage.input_tokens=e.usage.input_tokens),null!=e.usage.cache_creation_input_tokens&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),null!=e.usage.cache_read_input_tokens&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),null!=e.usage.server_tool_use&&(t.usage.server_tool_use=e.usage.server_tool_use),null!=e.usage.output_tokens_details&&(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 i=t.content.at(e.index);switch(e.delta.type){case"text_delta":i?.type==="text"&&(t.content[e.index]={...i,text:(i.text||"")+e.delta.text});break;case"citations_delta":i?.type==="text"&&(t.content[e.index]={...i,citations:[...i.citations??[],e.delta.citation]});break;case"input_json_delta":if(i&&n_(i)){let r=(i[nd]||"")+e.delta.partial_json;t.content[e.index]=np(i,r)}break;case"thinking_delta":i?.type==="thinking"&&(t.content[e.index]={...i,thinking:i.thinking+e.delta.thinking});break;case"signature_delta":i?.type==="thinking"&&(t.content[e.index]={...i,signature:e.delta.signature});break;default:(0,ip.f)(e.delta)}return t}case"content_block_stop":{let i=t.content.at(e.index);return i&&n_(i)&&nd in i&&Object.defineProperty(i,"input",{value:i.input,enumerable:!0,configurable:!0,writable:!0}),t}}},Symbol.asyncIterator)](){let e=[],t=[],i=!1;return this.on("_rawEvent",i=>{let r=t.shift();r?r.resolve(i):e.push(i)}),this.on("end",()=>{for(let e of(i=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let r of(i=!0,t))r.reject(e);t.length=0}),this.on("error",e=>{for(let r of(i=!0,t))r.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:i?{value:void 0,done:!0}:new Promise((e,i)=>t.push({resolve:e,reject:i})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new rS(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}return e})(),ng=(()=>{class e{constructor(e,t,i){this.iterator=e,this.response=i,this.controller=t}async *decoder(){let e=this.iterator;if(!e)throw new ry.v("Cannot iterate over a consumed stream.");this.iterator=void 0;let t=new rk;for await(let i of e)for(let e of t.decode(i))yield JSON.parse(e);for(let e of t.flush())yield JSON.parse(e)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(t,i){if(!t.body){if(i.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new ry.v("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new ry.v("Attempted to iterate over a response with no body")}return new e(iA(t.body),i,t)}}return e})();function nm(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}let nv=Object.freeze(Object.create(null)),nb=((e=nm)=>function(t,...i){let r;if(1===t.length)return t[0];let s=!1,n=[],a=t.reduce((t,r,a)=>{/[?#]/.test(r)&&(s=!0);let o=i[a],l=(s?encodeURIComponent:e)(""+o);return a!==i.length&&(null==o||"object"==typeof o&&o.toString===Object.getPrototypeOf(Object.getPrototypeOf(o.hasOwnProperty??nv)??nv)?.toString)&&(l=o+"",n.push({start:t.length+r.length,length:l.length,error:`Value of type ${Object.prototype.toString.call(o).slice(8,-1)} is not a valid path parameter`})),s||""!==l||n.push({start:t.length+r.length,length:0,error:'Value "" can\'t be safely passed as a path parameter'}),t+r+(a===i.length?"":l)},""),o=a.split(/[?#]/,1)[0],l=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;for(;null!==(r=l.exec(o));)n.push({start:r.index,length:r[0].length,error:`Value "${r[0]}" can't be safely passed as a path parameter`});if(n.sort((e,t)=>e.start-t.start),n.length>0){let e=[];for(let t of n)for(let i=t.start;i<t.start+Math.max(1,t.length);i++)e[i]="^";let t=Array.from(e,e=>e??" ").join("");throw new ry.v(`Path parameters result in path with invalid segments:
|
|
2
2
|
${n.map(e=>e.error).join("\n")}
|
|
3
3
|
${a}
|
|
4
4
|
${t}`)}return a})(nm);class ny extends ne{create(e,t){let{user_profile_id:i,workspace_id:r,...s}=e;return this._client.post("/v1/messages/batches",{body:s,...t,headers:rR([{...null!=i?{"anthropic-user-profile-id":i}:void 0,...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__span:rC(this._client,"anthropic.messages.batches.create",t,{route:"/v1/messages/batches",attributes:{"anthropic.message.batch.request_count":s.requests?.length},createdIDAttribute:"anthropic.message.batch.id"})})}retrieve(e,t={},i){let{workspace_id:r}=t??{};return this._client.get(nb`/v1/messages/batches/${e}`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.messages.batches.retrieve",i,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":e}})})}list(e={},t){let{workspace_id:i,...r}=e??{};return this._client.getAPIList("/v1/messages/batches",s6,{query:r,...t,headers:rR([{...null!=i?{"anthropic-workspace-id":i}:void 0},t?.headers]),__span:rC(this._client,"anthropic.messages.batches.list",t,{route:"/v1/messages/batches",queryParams:["after_id","before_id","limit"]})})}delete(e,t={},i){let{workspace_id:r}=t??{};return this._client.delete(nb`/v1/messages/batches/${e}`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.messages.batches.delete",i,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":e}})})}cancel(e,t={},i){let{workspace_id:r}=t??{};return this._client.post(nb`/v1/messages/batches/${e}/cancel`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.messages.batches.cancel",i,{route:"/v1/messages/batches/{message_batch_id}/cancel",attributes:{"anthropic.message.batch.id":e}})})}async results(e,t={},i){let r=await this.retrieve(e,t,i);if(!r.results_url)throw new ry.v(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`);let{workspace_id:s}=t??{};return this._client.get(r.results_url,{...i,headers:rR([{Accept:"application/binary",...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),stream:!0,__binaryResponse:!0,__span:rC(this._client,"anthropic.messages.batches.results",i,{route:"/v1/messages/batches/{message_batch_id}/results",attributes:{"anthropic.message.batch.id":e}})})._thenUnwrap((e,t)=>ng.fromResponse(t.response,t.controller))}}let nw={"claude-opus-4@20250514":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192};var nk=(()=>{class e extends ne{constructor(){super(...arguments),this.batches=new ny(this._client)}create(e,t){let{user_profile_id:i,workspace_id:r,...s}=e;s.model in nz&&console.warn(`The model '${s.model}' is deprecated and will reach end-of-life on ${nz[s.model]}
|
|
5
|
-
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),nS.includes(s.model)&&s.thinking&&"enabled"===s.thinking.type&&console.warn(`Using Claude with ${s.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 n=t?.timeout??this._client._options.timeout;if(!s.stream&&null==n){let e=nw[s.model]??void 0;n=this._client.calculateNonstreamingTimeout(s.max_tokens,e)}let a=nl(e,t),o=this._client._tracer&&rC(this._client,"anthropic.messages.create",t,sz(this._client,s,a));sS(this._client,o,s);let l=this._client.post("/v1/messages",{body:s,timeout:n??6e5,...t,__span:o,headers:a,stream:e.stream??!1});return o?l._thenUnwrap(e=>(sx(this._client,o,s,e),e)):l}parse(e,t){return this.create(e,t).then(t=>nh(t,e,{logger:this._client.logger??console}))}stream(e,t){return nf.createMessage(this,e,t,{logger:this._client.logger??console,client:this._client})}countTokens(e,t){let{user_profile_id:i,workspace_id:r,...s}=e,n=rR([{...null!=i?{"anthropic-user-profile-id":i}:void 0,...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),a=rC(this._client,"anthropic.messages.count_tokens",t,{route:"/v1/messages/count_tokens",attributes:{[so]:s.model}}),o=this._client.post("/v1/messages/count_tokens",{body:s,...t,__span:a,headers:n});return a?o._thenUnwrap(e=>(sV(this._client,a,e),e)):o}}return e.Batches=ny,e})();let nz={"claude-sonnet-4-5":"November 30th, 2026","claude-sonnet-4-5-20250929":"November 30th, 2026"},nS=["claude-mythos-preview","claude-opus-4-6"];class nx extends ne{retrieve(e,t={},i){let{workspace_id:r}=t??{};return this._client.get(nb`/v1/models/${e}`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.models.retrieve",i,{route:"/v1/models/{model_id}",attributes:{"anthropic.model.id":e}})})}list(e={},t){let{workspace_id:i,...r}=e??{};return this._client.getAPIList("/v1/models",s6,{query:r,...t,headers:rR([{...null!=i?{"anthropic-workspace-id":i}:void 0},t?.headers]),__span:rC(this._client,"anthropic.models.list",t,{route:"/v1/models",queryParams:["after_id","before_id","lifecycle","limit"]})})}}class nV extends ne{list(e={},t){let{workspace_id:i,...r}=e??{};return this._client.getAPIList("/v1/files",s4,{query:r,...t,headers:rR([{...null!=i?{"anthropic-workspace-id":i}:void 0},t?.headers]),__span:rC(this._client,"anthropic.files.list",t,{route:"/v1/files",queryParams:["ids","limit","page"]})})}delete(e,t={},i){let{workspace_id:r}=t??{};return this._client.delete(nb`/v1/files/${e}`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.files.delete",i,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":e}})})}download(e,t={},i){let{workspace_id:r}=t??{};return this._client.get(nb`/v1/files/${e}/content`,{...i,headers:rR([{Accept:"application/binary",...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__binaryResponse:!0,__span:rC(this._client,"anthropic.files.download",i,{route:"/v1/files/{file_id}/content",attributes:{"anthropic.file.id":e}})})}retrieveMetadata(e,t={},i){let{workspace_id:r}=t??{};return this._client.get(nb`/v1/files/${e}`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.files.retrieve_metadata",i,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":e}})})}upload(e,t){let{workspace_id:i,...r}=e;return this._client.post("/v1/files",sG({body:r,...t,headers:rR([{...null!=i?{"anthropic-workspace-id":i}:void 0},no(r.file),t?.headers]),__span:rC(this._client,"anthropic.files.upload",t,{route:"/v1/files",createdIDAttribute:"anthropic.file.id"})},this._client))}}class nA extends ne{create(e,t,i){let{workspace_id:r,...s}=t;return this._client.post(nb`/v1/skills/${e}/versions`,sG({body:s,...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.skills.versions.create",i,{route:"/v1/skills/{skill_id}/versions",attributes:{"anthropic.skill.id":e},createdIDAttribute:"anthropic.skill.version.id"})},this._client,!1))}retrieve(e,t,i){let{skill_id:r,workspace_id:s}=t;return this._client.get(nb`/v1/skills/${r}/versions/${e}`,{...i,headers:rR([{...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:rC(this._client,"anthropic.skills.versions.retrieve",i,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":r,"anthropic.skill.version.id":e}})})}list(e,t={},i){let{workspace_id:r,...s}=t??{};return this._client.getAPIList(nb`/v1/skills/${e}/versions`,s4,{query:s,...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.skills.versions.list",i,{route:"/v1/skills/{skill_id}/versions",queryParams:["limit","page"],attributes:{"anthropic.skill.id":e}})})}delete(e,t,i){let{skill_id:r,workspace_id:s}=t;return this._client.delete(nb`/v1/skills/${r}/versions/${e}`,{...i,headers:rR([{...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:rC(this._client,"anthropic.skills.versions.delete",i,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":r,"anthropic.skill.version.id":e}})})}}var nI=(()=>{class e extends ne{constructor(){super(...arguments),this.versions=new nA(this._client)}create(e,t){let{workspace_id:i,...r}=e;return this._client.post("/v1/skills",sG({body:r,...t,headers:rR([{...null!=i?{"anthropic-workspace-id":i}:void 0},t?.headers]),__span:rC(this._client,"anthropic.skills.create",t,{route:"/v1/skills",createdIDAttribute:"anthropic.skill.id"})},this._client,!1))}retrieve(e,t={},i){let{workspace_id:r}=t??{};return this._client.get(nb`/v1/skills/${e}`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.skills.retrieve",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}list(e={},t){let{workspace_id:i,...r}=e??{};return this._client.getAPIList("/v1/skills",s4,{query:r,...t,headers:rR([{...null!=i?{"anthropic-workspace-id":i}:void 0},t?.headers]),__span:rC(this._client,"anthropic.skills.list",t,{route:"/v1/skills",queryParams:["limit","page","source"]})})}delete(e,t={},i){let{workspace_id:r}=t??{};return this._client.delete(nb`/v1/skills/${e}`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.skills.delete",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}}return e.Versions=nA,e})();class nq extends ne{create(e,t,i){let{workspace_id:r,...s}=t;return this._client.post(nb`/v1/user_profiles/${e}/action_urls`,{body:s,...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.user_profiles.action_urls.create",i,{route:"/v1/user_profiles/{user_profile_id}/action_urls",attributes:{"anthropic.user_profile.id":e}})})}}var n$=(()=>{class e extends ne{constructor(){super(...arguments),this.actionURLs=new nq(this._client)}create(e,t){let{workspace_id:i,...r}=e;return this._client.post("/v1/user_profiles",{body:r,...t,headers:rR([{...null!=i?{"anthropic-workspace-id":i}:void 0},t?.headers]),__span:rC(this._client,"anthropic.user_profiles.create",t,{route:"/v1/user_profiles",createdIDAttribute:"anthropic.user_profile.id"})})}retrieve(e,t={},i){let{workspace_id:r}=t??{};return this._client.get(nb`/v1/user_profiles/${e}`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.user_profiles.retrieve",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}update(e,t,i){let{workspace_id:r,...s}=t;return this._client.post(nb`/v1/user_profiles/${e}`,{body:s,...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.user_profiles.update",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}list(e={},t){let{workspace_id:i,...r}=e??{};return this._client.getAPIList("/v1/user_profiles",s4,{query:r,...t,headers:rR([{...null!=i?{"anthropic-workspace-id":i}:void 0},t?.headers]),__span:rC(this._client,"anthropic.user_profiles.list",t,{route:"/v1/user_profiles",queryParams:["enforcement_status","limit","order","order_by","page"]})})}delete(e,t={},i){let{workspace_id:r}=t??{};return this._client.delete(nb`/v1/user_profiles/${e}`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.user_profiles.delete",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}}return e.ActionURLs=nq,e})();class nR extends ne{retrieve(e,t){return this._client.get(nb`/v1/organizations/api_keys/${e}`,{...t,__span:rC(this._client,"anthropic.organization.api_keys.retrieve",t,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/api_keys/${e}`,{body:t,...i,__span:rC(this._client,"anthropic.organization.api_keys.update",i,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/api_keys",s6,{query:e,...t,__span:rC(this._client,"anthropic.organization.api_keys.list",t,{route:"/v1/organizations/api_keys",queryParams:["after_id","before_id","created_by_user_id","limit","status","workspace_id"]})})}}class nP extends ne{retrieve(e){return this._client.get("/v1/organizations/compliance_settings",{...e,__span:rC(this._client,"anthropic.organization.compliance_settings.retrieve",e,{route:"/v1/organizations/compliance_settings"})})}update(e,t){return this._client.post("/v1/organizations/compliance_settings",{body:e,...t,__span:rC(this._client,"anthropic.organization.compliance_settings.update",t,{route:"/v1/organizations/compliance_settings"})})}}class nT extends ne{create(e,t){return this._client.post("/v1/organizations/external_keys",{body:e,...t,__span:rC(this._client,"anthropic.organization.external_keys.create",t,{route:"/v1/organizations/external_keys",createdIDAttribute:"anthropic.organization.external_key.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/external_keys/${e}`,{...t,__span:rC(this._client,"anthropic.organization.external_keys.retrieve",t,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/external_keys/${e}`,{body:t,...i,__span:rC(this._client,"anthropic.organization.external_keys.update",i,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/external_keys",s4,{query:e,...t,__span:rC(this._client,"anthropic.organization.external_keys.list",t,{route:"/v1/organizations/external_keys",queryParams:["limit","page"]})})}delete(e,t){return this._client.delete(nb`/v1/organizations/external_keys/${e}`,{...t,__span:rC(this._client,"anthropic.organization.external_keys.delete",t,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}validate(e,t){return this._client.post(nb`/v1/organizations/external_keys/${e}/validate`,{...t,__span:rC(this._client,"anthropic.organization.external_keys.validate",t,{route:"/v1/organizations/external_keys/{external_key_id}/validate",attributes:{"anthropic.organization.external_key.id":e}})})}}class nE extends ne{create(e,t){return this._client.post("/v1/organizations/invites",{body:e,...t,__span:rC(this._client,"anthropic.organization.invites.create",t,{route:"/v1/organizations/invites",createdIDAttribute:"anthropic.organization.invite.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/invites/${e}`,{...t,__span:rC(this._client,"anthropic.organization.invites.retrieve",t,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/invites",s6,{query:e,...t,__span:rC(this._client,"anthropic.organization.invites.list",t,{route:"/v1/organizations/invites",queryParams:["after_id","before_id","email","limit","roles","statuses"]})})}delete(e,t){return this._client.delete(nb`/v1/organizations/invites/${e}`,{...t,__span:rC(this._client,"anthropic.organization.invites.delete",t,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":e}})})}}class nO extends ne{list(e={},t){return this._client.getAPIList("/v1/organizations/rate_limits",s4,{query:e,...t,__span:rC(this._client,"anthropic.organization.rate_limits.list",t,{route:"/v1/organizations/rate_limits",queryParams:["group_type","limit","model","page"]})})}}class nM extends ne{retrieve(e,t){return this._client.get(nb`/v1/organizations/users/${e}`,{...t,__span:rC(this._client,"anthropic.organization.users.retrieve",t,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/users/${e}`,{body:t,...i,__span:rC(this._client,"anthropic.organization.users.update",i,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/users",s6,{query:e,...t,__span:rC(this._client,"anthropic.organization.users.list",t,{route:"/v1/organizations/users",queryParams:["after_id","before_id","email","limit","roles"]})})}remove(e,t){return this._client.delete(nb`/v1/organizations/users/${e}`,{...t,__span:rC(this._client,"anthropic.organization.users.remove",t,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}}class nL extends ne{create(e,t){return this._client.post("/v1/organizations/federation_issuers",{body:e,...t,__span:rC(this._client,"anthropic.organization.federation.issuers.create",t,{route:"/v1/organizations/federation_issuers",createdIDAttribute:"anthropic.organization.federation_issuer.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/federation_issuers/${e}`,{...t,__span:rC(this._client,"anthropic.organization.federation.issuers.retrieve",t,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/federation_issuers/${e}`,{body:t,...i,__span:rC(this._client,"anthropic.organization.federation.issuers.update",i,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/federation_issuers",s4,{query:e,...t,__span:rC(this._client,"anthropic.organization.federation.issuers.list",t,{route:"/v1/organizations/federation_issuers",queryParams:["include_archived","limit","page"]})})}archive(e,t){return this._client.post(nb`/v1/organizations/federation_issuers/${e}/archive`,{...t,__span:rC(this._client,"anthropic.organization.federation.issuers.archive",t,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}/archive",attributes:{"anthropic.organization.federation_issuer.id":e}})})}}class nC extends ne{list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/federation_rules/${e}/workspaces`,s4,{query:t,...i,__span:rC(this._client,"anthropic.organization.federation.rules.workspaces.list",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.federation_rule.id":e}})})}add(e,t,i){return this._client.post(nb`/v1/organizations/federation_rules/${e}/workspaces`,{body:t,...i,__span:rC(this._client,"anthropic.organization.federation.rules.workspaces.add",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",attributes:{"anthropic.organization.federation_rule.id":e},createdIDAttribute:"anthropic.organization.federation_rule.workspace.id",createdIDField:"workspace_id"})})}remove(e,t,i){let{federation_rule_id:r}=t;return this._client.delete(nb`/v1/organizations/federation_rules/${r}/workspaces/${e}`,{...i,__span:rC(this._client,"anthropic.organization.federation.rules.workspaces.remove",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.federation_rule.id":r,"anthropic.organization.federation_rule.workspace.id":e}})})}}var nN=(()=>{class e extends ne{constructor(){super(...arguments),this.workspaces=new nC(this._client)}create(e,t){return this._client.post("/v1/organizations/federation_rules",{body:e,...t,__span:rC(this._client,"anthropic.organization.federation.rules.create",t,{route:"/v1/organizations/federation_rules",createdIDAttribute:"anthropic.organization.federation_rule.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/federation_rules/${e}`,{...t,__span:rC(this._client,"anthropic.organization.federation.rules.retrieve",t,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/federation_rules/${e}`,{body:t,...i,__span:rC(this._client,"anthropic.organization.federation.rules.update",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/federation_rules",s4,{query:e,...t,__span:rC(this._client,"anthropic.organization.federation.rules.list",t,{route:"/v1/organizations/federation_rules",queryParams:["include_archived","issuer_id","limit","page"]})})}archive(e,t){return this._client.post(nb`/v1/organizations/federation_rules/${e}/archive`,{...t,__span:rC(this._client,"anthropic.organization.federation.rules.archive",t,{route:"/v1/organizations/federation_rules/{federation_rule_id}/archive",attributes:{"anthropic.organization.federation_rule.id":e}})})}}return e.Workspaces=nC,e})(),nj=(()=>{class e extends ne{constructor(){super(...arguments),this.issuers=new nL(this._client),this.rules=new nN(this._client)}}return e.Issuers=nL,e.Rules=nN,e})();class nD extends ne{list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/service_accounts/${e}/workspaces`,s4,{query:t,...i,__span:rC(this._client,"anthropic.organization.service_accounts.workspaces.list",i,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.service_account.id":e}})})}add(e,t,i){return this._client.post(nb`/v1/organizations/service_accounts/${e}/workspaces`,{body:t,...i,__span:rC(this._client,"anthropic.organization.service_accounts.workspaces.add",i,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",attributes:{"anthropic.organization.service_account.id":e},createdIDAttribute:"anthropic.organization.service_account.workspace.id",createdIDField:"workspace_id"})})}remove(e,t,i){let{service_account_id:r}=t;return this._client.delete(nb`/v1/organizations/service_accounts/${r}/workspaces/${e}`,{...i,__span:rC(this._client,"anthropic.organization.service_accounts.workspaces.remove",i,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.service_account.id":r,"anthropic.organization.service_account.workspace.id":e}})})}}var nW=(()=>{class e extends ne{constructor(){super(...arguments),this.workspaces=new nD(this._client)}create(e,t){return this._client.post("/v1/organizations/service_accounts",{body:e,...t,__span:rC(this._client,"anthropic.organization.service_accounts.create",t,{route:"/v1/organizations/service_accounts",createdIDAttribute:"anthropic.organization.service_account.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/service_accounts/${e}`,{...t,__span:rC(this._client,"anthropic.organization.service_accounts.retrieve",t,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/service_accounts/${e}`,{body:t,...i,__span:rC(this._client,"anthropic.organization.service_accounts.update",i,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/service_accounts",s4,{query:e,...t,__span:rC(this._client,"anthropic.organization.service_accounts.list",t,{route:"/v1/organizations/service_accounts",queryParams:["include_archived","limit","page"]})})}archive(e,t){return this._client.post(nb`/v1/organizations/service_accounts/${e}/archive`,{...t,__span:rC(this._client,"anthropic.organization.service_accounts.archive",t,{route:"/v1/organizations/service_accounts/{service_account_id}/archive",attributes:{"anthropic.organization.service_account.id":e}})})}}return e.Workspaces=nD,e})();class nU extends ne{retrieve(e,t,i){let{workspace_id:r}=t;return this._client.get(nb`/v1/organizations/workspaces/${r}/members/${e}`,{...i,__span:rC(this._client,"anthropic.organization.workspaces.members.retrieve",i,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.member.id":e}})})}update(e,t,i){let{workspace_id:r,...s}=t;return this._client.post(nb`/v1/organizations/workspaces/${r}/members/${e}`,{body:s,...i,__span:rC(this._client,"anthropic.organization.workspaces.members.update",i,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.member.id":e}})})}list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/workspaces/${e}/members`,s6,{query:t,...i,__span:rC(this._client,"anthropic.organization.workspaces.members.list",i,{route:"/v1/organizations/workspaces/{workspace_id}/members",queryParams:["after_id","before_id","limit"],attributes:{"anthropic.organization.workspace.id":e}})})}add(e,t,i){return this._client.post(nb`/v1/organizations/workspaces/${e}/members`,{body:t,...i,__span:rC(this._client,"anthropic.organization.workspaces.members.add",i,{route:"/v1/organizations/workspaces/{workspace_id}/members",attributes:{"anthropic.organization.workspace.id":e},createdIDAttribute:"anthropic.organization.workspace.member.id",createdIDField:"user_id"})})}remove(e,t,i){let{workspace_id:r}=t;return this._client.delete(nb`/v1/organizations/workspaces/${r}/members/${e}`,{...i,__span:rC(this._client,"anthropic.organization.workspaces.members.remove",i,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.member.id":e}})})}}class nF extends ne{update(e,t,i){let{workspace_id:r,...s}=t;return this._client.post(nb`/v1/organizations/workspaces/${r}/rate_limits/${e}`,{body:s,...i,__span:rC(this._client,"anthropic.organization.workspaces.rate_limits.update",i,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits/{rate_limit_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.rate_limit.id":e}})})}list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/workspaces/${e}/rate_limits`,s4,{query:t,...i,__span:rC(this._client,"anthropic.organization.workspaces.rate_limits.list",i,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits",queryParams:["group_type","include_inherited","limit","page"],attributes:{"anthropic.organization.workspace.id":e}})})}}class nH extends ne{retrieve(e,t,i){let{workspace_id:r}=t;return this._client.get(nb`/v1/organizations/workspaces/${r}/service_accounts/${e}`,{...i,__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.retrieve",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.service_account.id":e}})})}update(e,t,i){let{workspace_id:r,...s}=t;return this._client.post(nb`/v1/organizations/workspaces/${r}/service_accounts/${e}`,{body:s,...i,__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.update",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.service_account.id":e}})})}list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/workspaces/${e}/service_accounts`,s4,{query:t,...i,__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.list",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",queryParams:["limit","page"],attributes:{"anthropic.organization.workspace.id":e}})})}add(e,t,i){return this._client.post(nb`/v1/organizations/workspaces/${e}/service_accounts`,{body:t,...i,__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.add",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",attributes:{"anthropic.organization.workspace.id":e},createdIDAttribute:"anthropic.organization.workspace.service_account.id",createdIDField:"service_account_id"})})}remove(e,t,i){let{workspace_id:r}=t;return this._client.delete(nb`/v1/organizations/workspaces/${r}/service_accounts/${e}`,{...i,__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.remove",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.service_account.id":e}})})}}var nB=(()=>{class e extends ne{constructor(){super(...arguments),this.rateLimits=new nF(this._client),this.members=new nU(this._client),this.serviceAccounts=new nH(this._client)}create(e,t){return this._client.post("/v1/organizations/workspaces",{body:e,...t,__span:rC(this._client,"anthropic.organization.workspaces.create",t,{route:"/v1/organizations/workspaces",createdIDAttribute:"anthropic.organization.workspace.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/workspaces/${e}`,{...t,__span:rC(this._client,"anthropic.organization.workspaces.retrieve",t,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/workspaces/${e}`,{body:t,...i,__span:rC(this._client,"anthropic.organization.workspaces.update",i,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/workspaces",s6,{query:e,...t,__span:rC(this._client,"anthropic.organization.workspaces.list",t,{route:"/v1/organizations/workspaces",queryParams:["after_id","before_id","include_archived","include_default","limit"]})})}archive(e,t){return this._client.post(nb`/v1/organizations/workspaces/${e}/archive`,{...t,__span:rC(this._client,"anthropic.organization.workspaces.archive",t,{route:"/v1/organizations/workspaces/{workspace_id}/archive",attributes:{"anthropic.organization.workspace.id":e}})})}}return e.RateLimits=nF,e.Members=nU,e.ServiceAccounts=nH,e})(),nK=(()=>{class e extends ne{constructor(){super(...arguments),this.apiKeys=new nR(this._client),this.externalKeys=new nT(this._client),this.federation=new nj(this._client),this.invites=new nE(this._client),this.serviceAccounts=new nW(this._client),this.users=new nM(this._client),this.workspaces=new nB(this._client),this.rateLimits=new nO(this._client),this.complianceSettings=new nP(this._client)}retrieve(e){return this._client.get("/v1/organizations/me",{...e,__span:rC(this._client,"anthropic.organization.retrieve",e,{route:"/v1/organizations/me"})})}}return e.APIKeys=nR,e.ExternalKeys=nT,e.Federation=nj,e.Invites=nE,e.ServiceAccounts=nW,e.Users=nM,e.Workspaces=nB,e.RateLimits=nO,e.ComplianceSettings=nP,e})();class nJ extends ne{retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/deployment_runs/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployment_runs.retrieve",i,{route:"/v1/deployment_runs/{deployment_run_id}",attributes:{"anthropic.deployment_run.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/deployment_runs",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployment_runs.list",t,{route:"/v1/deployment_runs",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","deployment_id","has_error","limit","page","trigger_type"]})})}}class nG extends ne{create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/deployments",{body:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployments.create",t,{route:"/v1/deployments",createdIDAttribute:"anthropic.deployment.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/deployments/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployments.retrieve",i,{route:"/v1/deployments/{deployment_id}",attributes:{"anthropic.deployment.id":e}})})}update(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/deployments/${e}`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployments.update",i,{route:"/v1/deployments/{deployment_id}",attributes:{"anthropic.deployment.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/deployments",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployments.list",t,{route:"/v1/deployments",queryParams:["agent_id","created_at[gte]","created_at[lte]","include_archived","limit","page","status"]})})}archive(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/deployments/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployments.archive",i,{route:"/v1/deployments/{deployment_id}/archive",attributes:{"anthropic.deployment.id":e}})})}pause(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/deployments/${e}/pause`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployments.pause",i,{route:"/v1/deployments/{deployment_id}/pause",attributes:{"anthropic.deployment.id":e}})})}run(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/deployments/${e}/run`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployments.run",i,{route:"/v1/deployments/{deployment_id}/run",attributes:{"anthropic.deployment.id":e}})})}unpause(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/deployments/${e}/unpause`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployments.unpause",i,{route:"/v1/deployments/{deployment_id}/unpause",attributes:{"anthropic.deployment.id":e}})})}}class nX extends ne{create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/dreams",{body:s,...t,headers:rR([{"anthropic-beta":[...i??[],"dreaming-2026-04-21"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.dreams.create",t,{route:"/v1/dreams",createdIDAttribute:"anthropic.dream.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/dreams/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"dreaming-2026-04-21"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.dreams.retrieve",i,{route:"/v1/dreams/{dream_id}",attributes:{"anthropic.dream.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/dreams",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"dreaming-2026-04-21"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.dreams.list",t,{route:"/v1/dreams",queryParams:["created_at[gt]","created_at[lt]","include_archived","limit","page","statuses"]})})}archive(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/dreams/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...r??[],"dreaming-2026-04-21"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.dreams.archive",i,{route:"/v1/dreams/{dream_id}/archive",attributes:{"anthropic.dream.id":e}})})}cancel(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/dreams/${e}/cancel`,{...i,headers:rR([{"anthropic-beta":[...r??[],"dreaming-2026-04-21"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.dreams.cancel",i,{route:"/v1/dreams/{dream_id}/cancel",attributes:{"anthropic.dream.id":e}})})}}class nY extends ne{list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/files",s4,{query:s,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.files.list",t,{route:"/v1/files",queryParams:["ids","limit","page","scope_id"]})})}delete(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.delete(nb`/v1/files/${e}`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.files.delete",i,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":e}})})}download(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/files/${e}/content`,{...i,headers:rR([{Accept:"application/binary",...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__binaryResponse:!0,__span:rC(this._client,"anthropic.files.download",i,{route:"/v1/files/{file_id}/content",attributes:{"anthropic.file.id":e}})})}retrieveMetadata(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/files/${e}`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.files.retrieve_metadata",i,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":e}})})}upload(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/files",sG({body:s,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...null!=r?{"anthropic-workspace-id":r}:void 0},no(s.file),t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.files.upload",t,{route:"/v1/files",createdIDAttribute:"anthropic.file.id"})},this._client))}}class nQ extends ne{retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/models/${e}`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.models.retrieve",i,{route:"/v1/models/{model_id}",attributes:{"anthropic.model.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/models",s6,{query:s,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.models.list",t,{route:"/v1/models",queryParams:["after_id","before_id","lifecycle","limit"]})})}}var nZ=e.i(305518);class n0 extends ne{parseUnverified(e){return JSON.parse(e)}unwrap(e,t){let i=t?.headers;if(null==i)throw Error("Webhook headers are required in order to verify the signature");let r=void 0===t.key?this._client.webhookKey:t.key;if(!r)throw Error("Webhook key must not be null or empty in order to unwrap");return new nZ.Webhook(r).verify(e,i),JSON.parse(e)}}class n1 extends ne{list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/agents/${e}/versions`,s4,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.agents.versions.list",i,{route:"/v1/agents/{agent_id}/versions",queryParams:["limit","page"],attributes:{"gen_ai.agent.id":e}})})}}var n2=(()=>{class e extends ne{constructor(){super(...arguments),this.versions=new n1(this._client)}create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/agents",{body:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.agents.create",t,{route:"/v1/agents",createdIDAttribute:"gen_ai.agent.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.get(nb`/v1/agents/${e}`,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.agents.retrieve",i,{route:"/v1/agents/{agent_id}",queryParams:["version"],attributes:{"gen_ai.agent.id":e}})})}update(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/agents/${e}`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.agents.update",i,{route:"/v1/agents/{agent_id}",attributes:{"gen_ai.agent.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/agents",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.agents.list",t,{route:"/v1/agents",queryParams:["created_at[gte]","created_at[lte]","include_archived","limit","page"]})})}archive(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/agents/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.agents.archive",i,{route:"/v1/agents/{agent_id}/archive",attributes:{"gen_ai.agent.id":e}})})}}return e.Versions=n1,e})();let n6=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return n6=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),i=e?()=>e.getRandomValues(t)[0]:()=>255*Math.random()&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^i()&15>>e/4).toString(16))};function n4(e,t){if(!e)return()=>{};if(e.aborted)return t.abort(),()=>{};let i=()=>t.abort();return e.addEventListener("abort",i),()=>e.removeEventListener("abort",i)}var n5=e.i(198156);function n8(e,{authToken:t,helper:i}){if(!t)throw new ry.v(`copyClientForHelper: expected a non-empty authToken but received ${JSON.stringify(t)}`);let r=e._options.defaultHeaders,s=e._authState?.extraHeaders,n=rR([s?Object.fromEntries(Object.entries(s).filter(([e])=>{let t=e.toLowerCase();return"authorization"!==t&&"x-api-key"!==t})):void 0,r,{[nt]:i}]);return n.values.delete("x-api-key"),n.values.delete("authorization"),n.nulls.delete("authorization"),e.withOptions({authToken:t,baseURL:e.baseURL,defaultHeaders:n})}function n3(e,t){e?.isRecording()&&(t.aborted||e.setStatus({code:rb.OK}),e.end())}function n9(e,t,i){e?.isRecording()&&(t.aborted||rW(e,i),e.end())}async function n7(e,t,i,r){if(!t)return r();try{await iJ.with(rm.setSpan(iJ.active(),t),r)}catch(r){throw rL(e,()=>n9(t,i,r)),r}rL(e,()=>n3(t,i))}var ae=(()=>{class e{constructor(e){let t,i;C.set(this,void 0),N.set(this,!1),j.set(this,void 0),D.set(this,void 0),W.set(this,void 0),U.set(this,void 0),F.set(this,void 0),H.set(this,void 0),B.set(this,void 0),this.client=e.client,this.environmentId=e.environmentId,this.environmentKey=e.environmentKey,this.workerId=e.workerId??(t=globalThis.process?.env,(i=t?.HOSTNAME)?`${i}-${n6()}`:n6()),(0,id.b)(this,C,n8(e.client,{authToken:e.environmentKey,helper:"environments-work-poller"}),"f"),(0,id.b)(this,W,e.autoStop??!0,"f"),(0,id.b)(this,U,e.drain??!1,"f"),(0,id.b)(this,F,void 0===e.blockMs?999:e.blockMs,"f"),(0,id.b)(this,H,e.reclaimOlderThanMs??null,"f"),(0,id.b)(this,B,e.requestOptions,"f"),(0,id.b)(this,j,new AbortController,"f"),(0,id.b)(this,D,n4(e.signal,(0,id.V)(this,j,"f")),"f")}get signal(){return(0,id.V)(this,j,"f").signal}abort(){(0,id.V)(this,j,"f").abort()}async *[(C=new WeakMap,N=new WeakMap,j=new WeakMap,D=new WeakMap,W=new WeakMap,U=new WeakMap,F=new WeakMap,H=new WeakMap,B=new WeakMap,Symbol.asyncIterator)](){if((0,id.V)(this,N,"f"))throw new ry.v("Cannot iterate over a consumed WorkPoller");(0,id.b)(this,N,!0,"f");let e=iJ.active(),t=(0,rz.u)(this.client);t.info("poller starting",{component:"work-poller",environment_id:this.environmentId});let i=new at(t,this.environmentId);try{let s=0;for(;!(0,id.V)(this,j,"f").signal.aborted;){let n;try{n=await (0,id.V)(this,C,"f").beta.environments.work.poll(this.environmentId,{"Anthropic-Worker-ID":this.workerId,...null!==(0,id.V)(this,F,"f")?{block_ms:(0,id.V)(this,F,"f")}:{},...null!==(0,id.V)(this,H,"f")?{reclaim_older_than_ms:(0,id.V)(this,H,"f")}:{}},{headers:rR([(0,id.V)(this,B,"f")?.headers]),signal:(0,id.V)(this,j,"f").signal})}catch(i){var r;if((0,id.V)(this,j,"f").signal.aborted)return;if((0,n5.d)(i))throw t.error("poll failed permanently, stopping poller",{error:String(i)}),i;let e=(0,n5.o)((r=s,(0,n5.J)(r,1e3,6e4)));t.warn("poll failed, backing off",{error:String(i),backoff_ms:e}),s++,await i_(e,(0,id.V)(this,j,"f").signal);continue}if(s=0,null==n){if((0,id.V)(this,U,"f"))return;i.onEmptyPoll(),await i_((0,n5.e)(1e3,3e3),(0,id.V)(this,j,"f").signal);continue}i.onClaim(),this._workSpan=rL(this.client,()=>{var t,i,r;return t=this.client,i=n,r=e,t._tracer?.startSpan("anthropic.environment.work",{kind:rv.INTERNAL,attributes:{[rO]:t._genAIProviderName,"anthropic.environment.id":i.environment_id,"anthropic.environment.work.id":i.id,"anthropic.session.id":i.data.id}},r)}),t.info("claimed work",{component:"work-poller",environment_id:this.environmentId,work_id:n.id,work_type:n.data.type});try{await (0,id.V)(this,C,"f").beta.environments.work.ack(n.id,{environment_id:n.environment_id},{headers:rR([(0,id.V)(this,B,"f")?.headers]),signal:(0,id.V)(this,j,"f").signal})}catch(e){t.error("ack failed",{work_id:n.id,error:String(e)}),rL(this.client,()=>n9(this._workSpan,(0,id.V)(this,j,"f").signal,e));continue}try{yield n,e=iJ.active()}finally{if((0,id.V)(this,W,"f"))try{await (0,id.V)(this,C,"f").beta.environments.work.stop(n.id,{environment_id:n.environment_id},{headers:rR([(0,id.V)(this,B,"f")?.headers])})}catch(e){(0,n5.w)(e,409)||t.warn("stop failed",{work_id:n.id,error:String(e)})}rL(this.client,()=>n3(this._workSpan,(0,id.V)(this,j,"f").signal))}}}finally{(0,id.V)(this,D,"f").call(this)}}}return e})(),at=(K=new WeakMap,J=new WeakMap,G=new WeakMap,X=new WeakMap,class{constructor(e,t){K.set(this,void 0),J.set(this,void 0),G.set(this,void 0),X.set(this,0),(0,id.b)(this,K,e,"f"),(0,id.b)(this,J,t,"f")}onEmptyPoll(){let e=Date.now(),t={component:"work-poller",environment_id:(0,id.V)(this,J,"f")};void 0===(0,id.V)(this,G,"f")?((0,id.b)(this,G,(0,id.b)(this,X,e,"f"),"f"),(0,id.V)(this,K,"f").info("idle; polling for work",t)):e-(0,id.V)(this,X,"f")>=3e5?((0,id.b)(this,X,e,"f"),(0,id.V)(this,K,"f").info(`still polling; idle for ${Math.round((e-(0,id.V)(this,G,"f"))/1e3)}s`,t)):(0,id.V)(this,K,"f").debug("poll returned no work",t)}onClaim(){(0,id.b)(this,G,void 0,"f")}}),ai=(Y=new WeakMap,Q=new WeakMap,Z=new WeakMap,class{constructor(){Y.set(this,[]),Q.set(this,[]),Z.set(this,!1)}push(e){if((0,id.V)(this,Z,"f"))return!1;let t=(0,id.V)(this,Q,"f").shift();return t?t({done:!1,value:e}):(0,id.V)(this,Y,"f").push(e),!0}close(){if(!(0,id.V)(this,Z,"f"))for((0,id.b)(this,Z,!0,"f");(0,id.V)(this,Q,"f").length>0;)(0,id.V)(this,Q,"f").shift()({done:!0,value:void 0})}next(e){return(0,id.V)(this,Y,"f").length>0?Promise.resolve({done:!1,value:(0,id.V)(this,Y,"f").shift()}):(0,id.V)(this,Z,"f")||e?.aborted?Promise.resolve({done:!0,value:void 0}):new Promise(t=>{let i=i=>{e?.removeEventListener("abort",r),t(i)},r=()=>{let e=(0,id.V)(this,Q,"f").indexOf(i);e>=0&&(0,id.V)(this,Q,"f").splice(e,1),t({done:!0,value:void 0})};(0,id.V)(this,Q,"f").push(i),e?.addEventListener("abort",r,{once:!0})})}tryShift(){return(0,id.V)(this,Y,"f").shift()}}),ar=e.i(32014);let as=RegExp("[\\x00-\\x1f\\x7f-\\x9f\\u061c\\u200e\\u200f\\u2028\\u2029\\u202a-\\u202e\\u2066-\\u2069]+","g"),an=/[\uD800-\uDFFF]/gu;function aa(e){return e.replace(an,"�")}function ao(e){return(function(e,t=4096){return ac(aa(e).replace(as," ").trim(),t)})(e,200).replace(/[' ]+/g," ").trim()}function al(e){return`Error: ${e instanceof Error?e.message:String(e)}`}function ac(e,t){if(e.length<=t)return e;let i=0,r=0;for(let s of e){if(r===t)break;r+=1,i+=s.length}return e.slice(0,i)}function au(e){return"name"in e?e.name:"mcp_server_name"in e?e.mcp_server_name:e.type}async function ah(e,t,i){try{let r=e.parse?e.parse(t):t;return{content:await e.run(r,i),isError:!1}}catch(e){return{content:e instanceof ar.f?e.content:al(e),isError:!0}}}async function ad(e,t,i,r,s){let n,a=e._tracer;if(!a)return s();let{signal:o,conversationId:l,sessionID:c,parentContext:u=iJ.active()}=r,h="description"in t?t.description:void 0,d={[ss]:"execute_tool",[rO]:e._genAIProviderName,"gen_ai.tool.name":i.name,..."toolset_name"in i&&"string"==typeof i.toolset_name?{"anthropic.toolset.name":i.toolset_name}:void 0,...h?{"gen_ai.tool.description":h}:void 0,"gen_ai.tool.call.id":i.id,"gen_ai.tool.type":"function",...null!=l?{[rE]:l}:void 0,...null!=c?{"anthropic.session.id":c}:void 0,..."session_thread_id"in i&&null!=i.session_thread_id?{"anthropic.session.thread.id":i.session_thread_id}:void 0},p="agent.tool_use"===i.type?"anthropic.tool_use":ns(t)&&"mcpTool"===t[nr]?"anthropic.mcp_tool_use":"anthropic.custom_tool_use",_=rL(e,()=>a.startSpan(`${p} ${i.name}`,{kind:rv.INTERNAL,attributes:d},u));if(!_)return s();try{return n=await iJ.with(rm.setSpan(u,_),s)}finally{let t=void 0!==n&&!n.isError,r=!t&&o?.aborted===!0,{contentMode:s,maxContentBytes:a}=e.openTelemetry.traces;if("content"===s&&_.isRecording())try{sv(_,{"gen_ai.tool.call.arguments":i.input,[sh]:n&&!r?sg(n.content):void 0},a)}catch(t){(0,rz.u)(e).debug("could not record the tool run on its span",t)}rL(e,()=>{t?_.setStatus({code:rb.OK}):r||rW(_,n,"tool_error"),_.end()})}}function ap(e){return"session.status_idle"===e.type&&e.stop_reason?.type!=="requires_action"}var a_=(ee=new WeakMap,et=new WeakMap,ei=new WeakMap,er=new WeakMap,es=new WeakMap,class{constructor(e,t){ee.set(this,void 0),et.set(this,void 0),ei.set(this,new Set),er.set(this,!1),es.set(this,void 0),(0,id.b)(this,ee,e,"f"),(0,id.b)(this,et,t,"f")}noteEvent(e){"user.tool_confirmation"!==e.type&&(ap(e)?this.arm():this.disarm())}block(e){(0,id.V)(this,ei,"f").add(e),void 0!==(0,id.V)(this,es,"f")&&((0,id.b)(this,er,!0,"f"),clearTimeout((0,id.V)(this,es,"f")),(0,id.b)(this,es,void 0,"f"))}unblock(e){(0,id.V)(this,ei,"f").delete(e),0===(0,id.V)(this,ei,"f").size&&(0,id.V)(this,er,"f")&&this.arm()}arm(){if(!(0>=(0,id.V)(this,ee,"f"))){if((0,id.V)(this,ei,"f").size>0)return void(0,id.b)(this,er,!0,"f");(0,id.b)(this,er,!1,"f"),void 0!==(0,id.V)(this,es,"f")&&clearTimeout((0,id.V)(this,es,"f")),(0,id.b)(this,es,setTimeout((0,id.V)(this,et,"f"),(0,id.V)(this,ee,"f")),"f")}}disarm(){(0,id.b)(this,er,!1,"f"),void 0!==(0,id.V)(this,es,"f")&&(clearTimeout((0,id.V)(this,es,"f")),(0,id.b)(this,es,void 0,"f"))}}),af=(()=>{class e{constructor(e,t){en.add(this),ea.set(this,!1),eo.set(this,void 0),el.set(this,void 0),ec.set(this,void 0),eu.set(this,void 0),eh.set(this,void 0),ed.set(this,new Set),ep.set(this,new Set),e_.set(this,new Map),ef.set(this,new Map),eg.set(this,new ai),em.set(this,0),ev.set(this,3e5),eb.set(this,null),ey.set(this,void 0),ew.set(this,void 0),ek.set(this,void 0),ez.set(this,!1),this.client=t.client,this.sessionId=e,this.tools=t.tools,this.maxIdleMs=t.maxIdleMs??6e4,(0,id.b)(this,eh,(0,rz.u)(t.client),"f"),(0,id.b)(this,eu,new Map(t.tools.map(e=>[au(e),e])),"f"),(0,id.b)(this,eo,new AbortController,"f"),(0,id.b)(this,el,n4(t.signal,(0,id.V)(this,eo,"f")),"f"),(0,id.b)(this,ec,t.requestOptions,"f"),(0,id.b)(this,ey,new a_(this.maxIdleMs,()=>{(0,id.V)(this,eh,"f").info("session idle after its turn ended; stopping",{component:"session-tool-runner",session_id:this.sessionId,max_idle_ms:this.maxIdleMs}),(0,id.V)(this,eo,"f").abort()}),"f")}get signal(){return(0,id.V)(this,eo,"f").signal}abort(){(0,id.V)(this,eo,"f").abort()}_setSendRetryWindow(e){(0,id.b)(this,ev,e,"f")}async *[(ea=new WeakMap,eo=new WeakMap,el=new WeakMap,ec=new WeakMap,eu=new WeakMap,eh=new WeakMap,ed=new WeakMap,ep=new WeakMap,e_=new WeakMap,ef=new WeakMap,eg=new WeakMap,em=new WeakMap,ev=new WeakMap,eb=new WeakMap,ey=new WeakMap,ew=new WeakMap,ek=new WeakMap,ez=new WeakMap,en=new WeakSet,Symbol.asyncIterator)](){if((0,id.V)(this,ea,"f"))throw new ry.v("Cannot iterate over a consumed SessionToolRunner");(0,id.b)(this,ea,!0,"f"),(0,id.b)(this,ew,this.client._tracer?iJ.active():void 0,"f"),(0,id.V)(this,eh,"f").info("session tool runner starting",{component:"session-tool-runner",session_id:this.sessionId});let e=(0,id.V)(this,en,"m",ex).call(this).catch(e=>{(0,id.V)(this,eo,"f").signal.aborted||(0,id.V)(this,eh,"f").error("stream loop failed",{error:String(e)}),(0,id.V)(this,eo,"f").abort()});try{let t;for(;;){let e=await (0,id.V)(this,eg,"f").next((0,id.V)(this,eo,"f").signal);if(e.done)break;yield e.value}for(await e;void 0!==(t=(0,id.V)(this,eg,"f").tryShift());)yield t}finally{(0,id.V)(this,eo,"f").abort(),(0,id.V)(this,ey,"f").disarm(),await e;try{await (0,id.V)(this,en,"m",eM).call(this)}catch(e){(0,id.V)(this,eh,"f").warn("drain failed",{error:String(e)})}for(let e of((0,id.V)(this,eg,"f").close(),this.tools))try{await e.close?.()}catch(t){(0,id.V)(this,eh,"f").warn("tool.close failed",{tool:au(e),error:String(t)})}(0,id.V)(this,el,"f").call(this)}}}return eS=function(){return{...(0,id.V)(this,ec,"f"),headers:rR([{[nt]:"session-tool-runner"},(0,id.V)(this,ec,"f")?.headers]),signal:(0,id.V)(this,eo,"f").signal}},ex=async function(){let e=(0,id.V)(this,eo,"f"),t=500;for(;!e.signal.aborted;){try{let e=await this.client.beta.sessions.events.stream(this.sessionId,{},(0,id.V)(this,en,"m",eS).call(this));for await(let i of(await (0,id.V)(this,en,"m",eV).call(this),e))if(t=500,await (0,id.V)(this,en,"m",eq).call(this,i))return}catch(i){if(e.signal.throwIfAborted(),(0,n5.d)(i))throw(0,id.V)(this,eh,"f").error("permanent stream failure, shutting down",{error:String(i)}),e.abort(),i;(0,id.V)(this,eh,"f").warn("stream disconnected, reconnecting",{error:String(i),backoff_ms:t})}e.signal.throwIfAborted(),await i_(t,e.signal),t=Math.min(2*t,1e4)}},eV=async function(){let e=(0,id.V)(this,eo,"f"),t=[],i=!1;(0,id.b)(this,ez,!1,"f");try{for await(let e of this.client.beta.sessions.events.list(this.sessionId,{limit:1e3},(0,id.V)(this,en,"m",eS).call(this)))(0,id.V)(this,en,"m",eA).call(this,e,t),"user.tool_confirmation"!==e.type&&(i=ap(e))}catch(i){for(let r of(e.signal.throwIfAborted(),(0,id.V)(this,eh,"f").warn("reconcile list failed",{error:String(i)}),t))(0,id.V)(this,ed,"f").delete(r.id);return}(0,id.b)(this,ez,!0,"f");let r=t.filter(e=>!(0,id.V)(this,ep,"f").has(e.id));for(let e of((0,id.V)(this,ey,"f").disarm(),r))await (0,id.V)(this,en,"m",e$).call(this,e);for(let e of[...(0,id.V)(this,ef,"f").values()]){let t=(0,id.V)(this,e_,"f").get(e.id);void 0!==t&&await (0,id.V)(this,en,"m",eP).call(this,e,t)}let s=r.filter(e=>!(0,id.V)(this,ep,"f").has(e.id)&&!(0,id.V)(this,ef,"f").has(e.id));i&&0===s.length?(0,id.V)(this,ey,"f").arm():(0,id.V)(this,ey,"f").disarm()},eA=function(e,t){(0,id.V)(this,en,"m",eI).call(this,e),"agent.tool_use"===e.type||"agent.custom_tool_use"===e.type?((0,id.V)(this,ed,"f").add(e.id),(0,id.V)(this,ep,"f").has(e.id)||t.push(e)):"user.tool_result"===e.type?(0,id.V)(this,ep,"f").add(e.tool_use_id):"user.custom_tool_result"===e.type?(0,id.V)(this,ep,"f").add(e.custom_tool_use_id):"user.tool_confirmation"!==e.type||(0,id.V)(this,ep,"f").has(e.tool_use_id)||(0,id.V)(this,e_,"f").set(e.tool_use_id,e.result)},eI=function(e){if(this.client._tracer&&void 0===(0,id.V)(this,ek,"f"))switch(e.type){case"session.thread_status_running":case"session.thread_status_idle":case"session.thread_status_rescheduled":case"session.thread_status_terminated":(0,id.b)(this,ek,e.session_thread_id,"f")}},eq=async function(e){switch((0,id.V)(this,ey,"f").noteEvent(e),(0,id.V)(this,ez,"f")&&(0,id.V)(this,en,"m",eI).call(this,e),e.type){case"agent.tool_use":case"agent.custom_tool_use":return(0,id.V)(this,ed,"f").has(e.id)||((0,id.V)(this,ed,"f").add(e.id),await (0,id.V)(this,en,"m",e$).call(this,e)),!1;case"user.tool_confirmation":return await (0,id.V)(this,en,"m",eR).call(this,e),!1;case"user.tool_result":return(0,id.V)(this,ep,"f").add(e.tool_use_id),!1;case"user.custom_tool_result":return(0,id.V)(this,ep,"f").add(e.custom_tool_use_id),!1;case"session.status_terminated":case"session.deleted":return(0,id.V)(this,eh,"f").info("session terminated",{component:"session-tool-runner",session_id:this.sessionId}),(0,id.V)(this,eo,"f").abort(),!0;default:return!1}},e$=async function(e){let t=e.evaluated_permission,i="deny"===t?"deny":(0,id.V)(this,e_,"f").get(e.id);void 0===i?void 0===t||"allow"===t?await (0,id.V)(this,en,"m",eE).call(this,e,void 0):(0,id.V)(this,ef,"f").has(e.id)||((0,id.V)(this,eh,"f").info("tool call awaiting confirmation; holding",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),(0,id.V)(this,ef,"f").set(e.id,e),(0,id.V)(this,ey,"f").block(e.id)):await (0,id.V)(this,en,"m",eP).call(this,e,i)},eR=async function(e){(0,id.V)(this,e_,"f").set(e.tool_use_id,e.result);let t=(0,id.V)(this,ef,"f").get(e.tool_use_id);void 0!==t&&await (0,id.V)(this,en,"m",eP).call(this,t,e.result)},eP=async function(e,t){let i=(0,id.V)(this,ef,"f").delete(e.id);if("allow"===t){(0,id.V)(this,eh,"f").info("tool call confirmed",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),i||(0,id.V)(this,ey,"f").block(e.id);try{await (0,id.V)(this,en,"m",eE).call(this,e,"allow")}finally{(0,id.V)(this,ey,"f").unblock(e.id)}return}i&&(0,id.V)(this,ey,"f").unblock(e.id),(0,id.V)(this,ep,"f").add(e.id),(0,id.V)(this,eh,"f").info("tool call denied; not executing",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),(0,id.V)(this,en,"m",eT).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:"deny"})},eT=function(e){(0,id.V)(this,eg,"f").push(e)},eE=async function(e,t){var i,r,s,n,a;if(!(0,id.V)(this,ep,"f").has(e.id)){(0,id.V)(this,eh,"f").info("executing tool",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),(0,id.b)(this,em,(i=(0,id.V)(this,em,"f"),++i),"f");try{let i,r,o=(0,id.V)(this,eu,"f").get(e.name);if(!o){(0,id.V)(this,eh,"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}),"allow"===t&&(0,id.V)(this,ey,"f").disarm(),(0,id.V)(this,en,"m",eT).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:t});return}let l=(0,id.V)(this,ec,"f")?.openTelemetry?.conversationId??(e.session_thread_id||(0,id.V)(this,ek,"f")),c=new AbortController,u=n4((0,id.V)(this,eo,"f").signal,c),h=setTimeout(()=>c.abort(),12e4);try{let t={signal:(0,id.V)(this,eo,"f").signal,conversationId:l,sessionID:this.sessionId,parentContext:(0,id.V)(this,ew,"f")},s=await ad(this.client,o,e,t,async()=>{let t=await ah(o,e.input,{toolUse:e,toolUseBlock:e,signal:c.signal}),i=function(e){if("string"==typeof e)return[{type:"text",text:e||"(no output)"}];let t=e.map(e=>"text"===e.type?{type:"text",text:e.text||"(no output)"}:"image"===e.type||"document"===e.type?e:"search_result"===e.type?{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)"}]}(t.content),r=this.client._tracer?i.map((e,i)=>{let r="string"==typeof t.content?void 0:t.content[i];return r&&"text"!==r.type&&"text"===e.type?r:e}):i;return{sent:i,content:r,isError:t.isError}});i=s.sent,r=s.isError}finally{clearTimeout(h),u()}let d=(s=e,n=r,a=i,"agent.custom_tool_use"===s.type?{type:"user.custom_tool_result",custom_tool_use_id:s.id,is_error:n,content:a}:{type:"user.tool_result",tool_use_id:s.id,is_error:n,content:a}),p=await (0,id.V)(this,en,"m",eO).call(this,d,e.id,l);(0,id.V)(this,en,"m",eT).call(this,{event:e,result:d,toolUseId:e.id,name:e.name,isError:r,posted:p,confirmation:t})}finally{(0,id.b)(this,em,(r=(0,id.V)(this,em,"f"),--r),"f"),0===(0,id.V)(this,em,"f")&&(0,id.V)(this,eb,"f")?.call(this)}}},eO=async function(e,t,i){let r,s=(0,id.V)(this,eo,"f"),n=Date.now(),a=0;for(;;){a++,s.signal.throwIfAborted();try{return await this.client.beta.sessions.events.send(this.sessionId,{events:[e]},{...(0,id.V)(this,en,"m",eS).call(this),openTelemetry:{conversationId:i}}),(0,id.V)(this,ep,"f").add(t),!0}catch(o){if(r=o,(0,n5.d)(o))break;let e=(0,id.V)(this,ev,"f")-(Date.now()-n);if(e<=0)break;let i=Math.min((0,n5.o)((0,n5.J)(a-1,1e3,3e4)),e);(0,id.V)(this,eh,"f").warn("tool result send failed; retrying",{tool_use_id:t,attempt:a,backoff_ms:i,error:String(o)}),await i_(i,s.signal)}}return(0,id.V)(this,eh,"f").error("failed to send tool result",{tool_use_id:t,attempts:a,error:String(r)}),!1},eM=async function(){0!==(0,id.V)(this,em,"f")&&(await Promise.race([new Promise(e=>(0,id.b)(this,eb,e,"f")),i_(3e4)]),(0,id.b)(this,eb,null,"f"),(0,id.V)(this,em,"f")>0&&(0,id.V)(this,eh,"f").warn("drain timeout exceeded"))},e})(),ag=e.i(193668),am=(eC=new WeakMap,eL=new WeakSet,eN=async function(t,i,r,s){let n,a,o,l=(0,rz.u)(this.client),c=function(e){let t;if(!e)return null;try{let i=e.replace(/-/g,"+").replace(/_/g,"/"),r=i.padEnd(4*Math.ceil(i.length/4),"=");t=JSON.parse((0,rw.z)((e=>{if(void 0!==globalThis.Buffer){let t=globalThis.Buffer.from(e,"base64");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}if("u">typeof atob){let t=atob(e),i=new Uint8Array(t.length);for(let e=0;e<t.length;e++)i[e]=t.charCodeAt(e);return i}throw new ry.v("Cannot decode base64 string; Expected `Buffer` or `atob` to be defined")})(r)))}catch{return null}if(null===t||"object"!=typeof t||Array.isArray(t))return null;let i=t.sessions_token;return"string"==typeof i&&""!==i?i:null}(t.secret),u=c??i;if(void 0===u)throw new ry.v("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)");t.secret&&null===c&&l.warn("work item carried a secret payload but no sessions token could be extracted; falling back to the environment key",{work_id:t.id});let h=n8(this.client,{authToken:u,helper:"environments-worker"}),d=t.data.id,p=new AbortController,_=n4(r,p),f=new ay(p),g=await e.A(146735),m=aw(h,t,f,l,this.requestOptions,e=>{n=e,a?._setSendRetryWindow(e)}).catch(e=>{p.signal.aborted||l.error("heartbeat loop failed",{work_id:t.id,error:String(e)}),p.abort()}),v=async()=>{},b=!1;try{if("session"!==t.data.type)return void l.debug("skipping non-session work item",{work_id:t.id,type:t.data.type});let e=await h.beta.sessions.retrieve(d);if(null===c&&null!==this.memorySyncIntervalMs&&e.resources.some(e=>"memory_store"===e.type))throw new g.SessionMemoryError(`cannot mount the session's memories: the work item carried no sessions token (work_id=${t.id}, session_id=${d}); 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 i={workdir:this.workdir,client:h,session:e,...void 0!==this.maxFileBytes?{maxFileBytes:this.maxFileBytes}:{}};try{v=await g.setupSkills(i)}catch(e){l.warn("skill setup failed",{session_id:d,work_id:t.id,error:String(e)})}null!==c&&null!==this.memorySyncIntervalMs?(o=new g.SessionMemoryStores(h,{workdir:this.workdir,...void 0!==this.memorySyncIntervalMs?{syncIntervalMs:this.memorySyncIntervalMs}:{},syncDeletions:this.memorySyncDeletions}),await o.download(e),i.allowedRoots=o.roots,i.readOnlyRoots=o.readOnlyRoots):l.debug("memory stores disabled for this item",{work_id:t.id});let r="function"==typeof this.tools?this.tools(i):this.tools??g.betaAgentToolset20260401(i);for await(let e of(a=new af(d,{client:h,tools:r,...void 0!==this.maxIdleMs?{maxIdleMs:this.maxIdleMs}:{},...void 0!==this.requestOptions?{requestOptions:this.requestOptions}:{},signal:p.signal}),void 0!==n&&a._setSendRetryWindow(n),a))o&&await o.syncIfDue();b=!p.signal.aborted}finally{try{await v().catch(e=>{l.warn("skill cleanup failed",{session_id:d,work_id:t.id,error:String(e)})})}finally{if(o){let e=g.MEMORY_FLUSH_TIMEOUT_MS;b&&await av(o.finish(),e)&&l.warn(`final memory sync cut off after ${e}ms; the flush that follows still uploads changed files`,{session_id:d,work_id:t.id});let i=new AbortController;await av(o.flushWrites(i.signal),e)&&(i.abort(),l.warn(`memory flush cut off after ${e}ms; changed files it had not uploaded yet are not saved`,{session_id:d,work_id:t.id})),await o.dispose().catch(e=>{l.warn("memory store cleanup failed",{session_id:d,work_id:t.id,error:String(e)})})}}f.finish("runner_done"),_(),await m,f.lost?l.info("lease lost; released without stopping it",{session_id:d,work_id:t.id}):await ab(h,t,l,this.requestOptions),(f.lost||f.rejected)&&rL(this.client,()=>s?.end())}},class{constructor(e){if(eL.add(this),eC.set(this,void 0),void 0!==e.unrestrictedPaths)throw new ry.v("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,null!=e.memorySyncIntervalMs&&(0,ag.A)(e.memorySyncIntervalMs,"memorySyncIntervalMs"),this.memorySyncIntervalMs=e.memorySyncIntervalMs,this.memorySyncDeletions=e.memorySyncDeletions??"enabled",this.workerId=e.workerId,this.requestOptions=e.requestOptions,(0,id.b)(this,eC,e.signal,"f")}async run(e){let{environmentId:t,environmentKey:i}=this;if(void 0===t||void 0===i)throw new ry.v("EnvironmentWorker.run: environmentId and environmentKey are required to poll for work");let r=e??(0,id.V)(this,eC,"f"),s=new ae({client:this.client,environmentId:t,environmentKey:i,...void 0!==this.workerId?{workerId:this.workerId}:{},...r?{signal:r}:{},...void 0!==this.requestOptions?{requestOptions:this.requestOptions}:{},autoStop:!1});for await(let e of s){let t=s._workSpan;try{await n7(this.client,t,s.signal,()=>(0,id.V)(this,eL,"m",eN).call(this,e,i,s.signal,t))}catch(t){if(s.signal?.aborted)throw t;(0,rz.u)(this.client).error("work item failed",{work_id:e.id,error:String(t)})}}}async handleItem(e){let t=e?.workId??(0,rP.f)("ANTHROPIC_WORK_ID"),i=e?.environmentId??(0,rP.f)("ANTHROPIC_ENVIRONMENT_ID"),r=e?.sessionId??(0,rP.f)("ANTHROPIC_SESSION_ID"),s=(e?.environmentKey??this.environmentKey??(0,rP.f)("ANTHROPIC_ENVIRONMENT_KEY"))||void 0,n=e?.workSecret||(0,rP.f)("ANTHROPIC_WORK_SECRET")||null;if(!t)throw new ry.v("handleItem: workId is required — pass it or set ANTHROPIC_WORK_ID");if(!i)throw new ry.v("handleItem: environmentId is required — pass it or set ANTHROPIC_ENVIRONMENT_ID");if(!r)throw new ry.v("handleItem: sessionId is required — pass it or set ANTHROPIC_SESSION_ID");if(!s&&!n)throw new ry.v("handleItem: environmentKey is required when there is no work secret — pass it, construct the worker with it, or set ANTHROPIC_ENVIRONMENT_KEY");await (0,id.V)(this,eL,"m",eN).call(this,{id:t,environment_id:i,secret:n,data:{type:"session",id:r}},s,e?.signal??(0,id.V)(this,eC,"f"))}});async function av(e,t){let i;try{return await Promise.race([e.then(()=>!1,()=>!1),new Promise(e=>{i=setTimeout(()=>e(!0),t)})])}finally{void 0!==i&&clearTimeout(i)}}async function ab(e,t,i,r){try{await e.beta.environments.work.stop(t.id,{environment_id:t.environment_id,force:!0},{...r,headers:rR([r?.headers])})}catch(e){(0,n5.w)(e,409)||i.error("force-stop on exit failed",{work_id:t.id,error:String(e)})}}var ay=(ej=new WeakMap,eD=new WeakMap,class{constructor(e){ej.set(this,void 0),eD.set(this,void 0),(0,id.b)(this,ej,e,"f")}get signal(){return(0,id.V)(this,ej,"f").signal}finish(e){(0,id.b)(this,eD,(0,id.V)(this,eD,"f")??e,"f"),(0,id.V)(this,ej,"f").abort()}get lost(){return"lease_lost"===(0,id.V)(this,eD,"f")||"assumed_lost"===(0,id.V)(this,eD,"f")}get rejected(){return"heartbeat_rejected"===(0,id.V)(this,eD,"f")}});async function aw(e,t,i,r,s,n){let a=3e4,o=9e4,l=Date.now(),c="NO_HEARTBEAT",u=async()=>{let u=new AbortController,h=n4(i.signal,u),d=setTimeout(()=>u.abort(),a);try{let h=await e.beta.environments.work.heartbeat(t.id,{environment_id:t.environment_id,expected_last_heartbeat:c},{...s,headers:rR([s?.headers]),signal:u.signal});l=Date.now(),c=h.last_heartbeat,h.ttl_seconds>0&&(o=1e3*h.ttl_seconds,a=Math.max(1e3,Math.min(o/2,3e4)),n?.(o)),("stopping"===h.state||"stopped"===h.state)&&(r.info("heartbeat signals shutdown",{work_id:t.id,state:h.state}),i.finish("control_plane_stop")),h.lease_extended||(r.warn("lease not extended, shutting down",{work_id:t.id}),i.finish("control_plane_stop"))}catch(e){if(i.signal.throwIfAborted(),(0,n5.w)(e,412)){let s=function(e){let t=e instanceof ry.E?e.error:void 0;for(let e of["error","details","current_state"]){if(!(0,ip.u)(t))return{};t=t[e]}return(0,ip.u)(t)?t:{}}(e);r.error("lease lost: heartbeat precondition failed",{work_id:t.id,server_state:s.state,server_ttl_seconds:s.ttl_seconds,server_last_heartbeat:s.last_heartbeat}),i.finish("lease_lost");return}if((0,n5.d)(e))throw r.error("permanent heartbeat failure",{work_id:t.id,error:String(e)}),i.finish("heartbeat_rejected"),e;if(Date.now()-l>o){r.error("lease assumed lost: no successful heartbeat in ttl",{work_id:t.id,ttl_ms:o,error:String(e)}),i.finish("assumed_lost");return}r.warn("transient heartbeat failure",{work_id:t.id,error:String(e)})}finally{clearTimeout(d),h()}};for(await u();!i.signal.aborted;)await i_(a,i.signal),i.signal.throwIfAborted(),await u()}var ak=(()=>{class e extends ne{retrieve(e,t,i){let{environment_id:r,betas:s,workspace_id:n}=t;return this._client.get(nb`/v1/environments/${r}/work/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.work.retrieve",i,{route:"/v1/environments/{environment_id}/work/{work_id}",attributes:{"anthropic.environment.id":r,"anthropic.environment.work.id":e}})})}update(e,t,i){let{environment_id:r,betas:s,workspace_id:n,...a}=t;return this._client.post(nb`/v1/environments/${r}/work/${e}`,{body:a,...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.work.update",i,{route:"/v1/environments/{environment_id}/work/{work_id}",attributes:{"anthropic.environment.id":r,"anthropic.environment.work.id":e}})})}list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/environments/${e}/work`,s4,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.work.list",i,{route:"/v1/environments/{environment_id}/work",queryParams:["limit","page"],attributes:{"anthropic.environment.id":e}})})}ack(e,t,i){let{environment_id:r,betas:s}=t;return this._client.post(nb`/v1/environments/${r}/work/${e}/ack`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.work.ack",i,{route:"/v1/environments/{environment_id}/work/{work_id}/ack",attributes:{"anthropic.environment.id":r,"anthropic.environment.work.id":e}})})}heartbeat(e,t,i){let{environment_id:r,desired_ttl_seconds:s,expected_last_heartbeat:n,betas:a}=t;return this._client.post(nb`/v1/environments/${r}/work/${e}/heartbeat`,{query:{desired_ttl_seconds:s,expected_last_heartbeat:n},...i,headers:rR([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.work.heartbeat",i,{route:"/v1/environments/{environment_id}/work/{work_id}/heartbeat",queryParams:["desired_ttl_seconds","expected_last_heartbeat"],attributes:{"anthropic.environment.id":r,"anthropic.environment.work.id":e}})})}poll(e,t={},i){let{betas:r,"Anthropic-Worker-ID":s,...n}=t??{};return this._client.get(nb`/v1/environments/${e}/work/poll`,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"Anthropic-Worker-ID":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.work.poll",i,{route:"/v1/environments/{environment_id}/work/poll",queryParams:["block_ms","reclaim_older_than_ms"],attributes:{"anthropic.environment.id":e}})})}stats(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/environments/${e}/work/stats`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.work.stats",i,{route:"/v1/environments/{environment_id}/work/stats",attributes:{"anthropic.environment.id":e}})})}stop(e,t,i){let{environment_id:r,betas:s,workspace_id:n,...a}=t;return this._client.post(nb`/v1/environments/${r}/work/${e}/stop`,{body:a,...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.work.stop",i,{route:"/v1/environments/{environment_id}/work/{work_id}/stop",attributes:{"anthropic.environment.id":r,"anthropic.environment.work.id":e}})})}poller(e){return new ae({...e,client:this._client})}worker(e){return new am({...e,client:this._client})}}return e.WorkPoller=ae,e.EnvironmentWorker=am,e})(),az=(()=>{class e extends ne{constructor(){super(...arguments),this.work=new ak(this._client)}create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/environments",{body:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.create",t,{route:"/v1/environments",createdIDAttribute:"anthropic.environment.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/environments/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.retrieve",i,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":e}})})}update(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/environments/${e}`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.update",i,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/environments",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.list",t,{route:"/v1/environments",queryParams:["include_archived","limit","page"]})})}delete(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.delete(nb`/v1/environments/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.delete",i,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":e}})})}archive(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/environments/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.archive",i,{route:"/v1/environments/{environment_id}/archive",attributes:{"anthropic.environment.id":e}})})}}return e.Work=ak,e})();class aS extends ne{create(e,t,i){let{view:r,betas:s,workspace_id:n,...a}=t;return this._client.post(nb`/v1/memory_stores/${e}/memories`,{query:{view:r},body:a,...i,headers:rR([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.memories.create",i,{route:"/v1/memory_stores/{memory_store_id}/memories",queryParams:["view"],attributes:{"gen_ai.memory.store.id":e},createdIDAttribute:"gen_ai.memory.record.id"})})}retrieve(e,t,i){let{memory_store_id:r,betas:s,workspace_id:n,...a}=t;return this._client.get(nb`/v1/memory_stores/${r}/memories/${e}`,{query:a,...i,headers:rR([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.memories.retrieve",i,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":r,"gen_ai.memory.record.id":e}})})}update(e,t,i){let{memory_store_id:r,view:s,betas:n,workspace_id:a,...o}=t;return this._client.post(nb`/v1/memory_stores/${r}/memories/${e}`,{query:{view:s},body:o,...i,headers:rR([{"anthropic-beta":[...n??[],"agent-memory-2026-07-22"].toString(),...null!=a?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.memories.update",i,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":r,"gen_ai.memory.record.id":e}})})}list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/memory_stores/${e}/memories`,s4,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"agent-memory-2026-07-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.memories.list",i,{route:"/v1/memory_stores/{memory_store_id}/memories",queryParams:["depth","limit","page","path_prefix","view"],contentQueryParams:["page"],attributes:{"gen_ai.memory.store.id":e}})})}delete(e,t,i){let{memory_store_id:r,expected_content_sha256:s,betas:n,workspace_id:a}=t;return this._client.delete(nb`/v1/memory_stores/${r}/memories/${e}`,{query:{expected_content_sha256:s},...i,headers:rR([{"anthropic-beta":[...n??[],"agent-memory-2026-07-22"].toString(),...null!=a?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.memories.delete",i,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["expected_content_sha256"],attributes:{"gen_ai.memory.store.id":r,"gen_ai.memory.record.id":e}})})}}class ax extends ne{retrieve(e,t,i){let{memory_store_id:r,betas:s,workspace_id:n,...a}=t;return this._client.get(nb`/v1/memory_stores/${r}/memory_versions/${e}`,{query:a,...i,headers:rR([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.memory_versions.retrieve",i,{route:"/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":r,"anthropic.memory_store.memory_version.id":e}})})}list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/memory_stores/${e}/memory_versions`,s4,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"agent-memory-2026-07-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.memory_versions.list",i,{route:"/v1/memory_stores/{memory_store_id}/memory_versions",queryParams:["api_key_id","created_at[gte]","created_at[lte]","limit","memory_id","operation","page","service_account_id","session_id","view"],attributes:{"gen_ai.memory.store.id":e}})})}redact(e,t,i){let{memory_store_id:r,betas:s,workspace_id:n}=t;return this._client.post(nb`/v1/memory_stores/${r}/memory_versions/${e}/redact`,{...i,headers:rR([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.memory_versions.redact",i,{route:"/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}/redact",attributes:{"gen_ai.memory.store.id":r,"anthropic.memory_store.memory_version.id":e}})})}}var aV=(()=>{class e extends ne{constructor(){super(...arguments),this.memories=new aS(this._client),this.memoryVersions=new ax(this._client)}create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/memory_stores",{body:s,...t,headers:rR([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.create",t,{route:"/v1/memory_stores",createdIDAttribute:"gen_ai.memory.store.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/memory_stores/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"agent-memory-2026-07-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.retrieve",i,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":e}})})}update(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/memory_stores/${e}`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"agent-memory-2026-07-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.update",i,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/memory_stores",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.list",t,{route:"/v1/memory_stores",queryParams:["created_at[gte]","created_at[lte]","include_archived","limit","page"]})})}delete(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.delete(nb`/v1/memory_stores/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"agent-memory-2026-07-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.delete",i,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":e}})})}archive(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/memory_stores/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...r??[],"agent-memory-2026-07-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.archive",i,{route:"/v1/memory_stores/{memory_store_id}/archive",attributes:{"gen_ai.memory.store.id":e}})})}}return e.Memories=aS,e.MemoryVersions=ax,e})();class aA extends ne{create(e,t){let{betas:i,user_profile_id:r,workspace_id:s,...n}=e;return this._client.post("/v1/messages/batches",{body:n,...t,headers:rR([{"anthropic-beta":[...i??[],"message-batches-2024-09-24"].toString(),...null!=r?{"anthropic-user-profile-id":r}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.messages.batches.create",t,{route:"/v1/messages/batches",attributes:{"anthropic.message.batch.request_count":n.requests?.length},createdIDAttribute:"anthropic.message.batch.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/messages/batches/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.messages.batches.retrieve",i,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/messages/batches",s6,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"message-batches-2024-09-24"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.messages.batches.list",t,{route:"/v1/messages/batches",queryParams:["after_id","before_id","limit"]})})}delete(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.delete(nb`/v1/messages/batches/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.messages.batches.delete",i,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":e}})})}cancel(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/messages/batches/${e}/cancel`,{...i,headers:rR([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.messages.batches.cancel",i,{route:"/v1/messages/batches/{message_batch_id}/cancel",attributes:{"anthropic.message.batch.id":e}})})}async results(e,t={},i){let r=await this.retrieve(e,t,i);if(!r.results_url)throw new ry.v(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`);let{betas:s,workspace_id:n}=t??{};return this._client.get(r.results_url,{...i,headers:rR([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary",...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),stream:!0,__qualifiers:{beta:"true"},__binaryResponse:!0,__span:rC(this._client,"anthropic.messages.batches.results",i,{route:"/v1/messages/batches/{message_batch_id}/results",attributes:{"anthropic.message.batch.id":e}})})._thenUnwrap((e,t)=>ng.fromResponse(t.response,t.controller))}}function aI(e){return e?.output_format??e?.output_config?.format}function aq(e,t,i){let r=aI(t);return t&&"parse"in(r??{})?a$(e,t,i):{...e,content:e.content.map(e=>"text"===e.type?Object.defineProperty(Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1}),"parsed",{get:()=>(i.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null),enumerable:!1}):e),parsed_output:null}}function a$(e,t,i){let r=null,s=e.content.map(e=>{if("text"===e.type){let s=function(e,t){let i=aI(e);if(i?.type!=="json_schema")return null;try{if("parse"in i)return i.parse(t);return JSON.parse(t)}catch(e){throw new ry.v(`Failed to parse structured output: ${e}`)}}(t,e.text);return null===r&&(r=s),Object.defineProperty(Object.defineProperty({...e},"parsed_output",{value:s,enumerable:!1}),"parsed",{get:()=>(i.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),s),enumerable:!1})}return e});return{...e,content:s,parsed_output:r}}function aR(e,t){let{betas:i,user_profile_id:r,workspace_id:s,tools:n,messages:a}=e;return rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...null!=r?{"anthropic-user-profile-id":r}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},na(n,a),t?.headers])}function aP(e){if(!e.output_format)return e;aT(e);let{output_format:t,...i}=e;return{...i,output_config:{...e.output_config,format:t}}}function aT(e){if(e.output_format&&e.output_config?.format)throw new ry.v("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).")}function aE(e){return"tool_use"===e.type||"server_tool_use"===e.type||"mcp_tool_use"===e.type}var aO=(()=>{class e{constructor(e,t){eW.add(this),this.messages=[],this.receivedMessages=[],eU.set(this,void 0),eF.set(this,null),this.controller=new AbortController,eH.set(this,void 0),eB.set(this,()=>{}),eK.set(this,()=>{}),eJ.set(this,void 0),eG.set(this,()=>{}),eX.set(this,()=>{}),eY.set(this,{}),eQ.set(this,!1),eZ.set(this,!1),e0.set(this,!1),e1.set(this,!1),e2.set(this,void 0),e6.set(this,void 0),e4.set(this,void 0),e5.set(this,void 0),e8.set(this,void 0),e3.set(this,void 0),e9.set(this,void 0),tt.set(this,e=>{if((0,id.b)(this,eZ,!0,"f"),(0,id.V)(this,e3,"f")&&((0,id.V)(this,e3,"f").streamed=void 0),(0,ig.c)(e)&&(e=new ry.F),e instanceof ry.F)return(0,id.b)(this,e0,!0,"f"),this._emit("abort",e);if(e instanceof ry.v)return this._emit("error",e);if(e instanceof Error){let t=new ry.v(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new ry.v(String(e)))}),(0,id.b)(this,eH,new Promise((e,t)=>{(0,id.b)(this,eB,e,"f"),(0,id.b)(this,eK,t,"f")}),"f"),(0,id.b)(this,eJ,new Promise((e,t)=>{(0,id.b)(this,eG,e,"f"),(0,id.b)(this,eX,t,"f")}),"f"),(0,id.V)(this,eH,"f").catch(()=>{}),(0,id.V)(this,eJ,"f").catch(()=>{}),(0,id.b)(this,eF,e,"f"),(0,id.b)(this,e5,t?.logger??console,"f"),(0,id.b)(this,e8,t?.client,"f")}get response(){return(0,id.V)(this,e2,"f")}get request_id(){return(0,id.V)(this,e6,"f")}get workspace_id(){return(0,id.V)(this,e4,"f")}async withResponse(){(0,id.b)(this,e1,!0,"f");let e=await (0,id.V)(this,eH,"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 i=new e(null);return i._run(()=>i._fromReadableStream(t)),i}static createMessage(t,i,r,{logger:s,client:n}={}){let a=new e(i,{logger:s,client:n});for(let e of i.messages)a._addMessageParam(e);return(0,id.b)(a,eF,{...i,stream:!0},"f"),a._run(()=>a._createMessage((e,i)=>t.create(e,i),{...i,stream:!0},{...r,headers:{...r?.headers,[ni]:"stream"}})),a}_start(e,t,i,r){for(let e of t.messages)this._addMessageParam(e);let s=(0,id.V)(this,e8,"f");(0,id.b)(this,e8,void 0,"f");let n=(t,i)=>e(t,i)._thenUnwrap((e,{options:t})=>((0,id.b)(this,e8,s,"f"),(0,id.b)(this,e3,t.__span,"f"),(0,id.b)(this,e9,t.body,"f"),e));this._run(()=>this._createMessage(n,{...t,stream:!0},i).finally(r))}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},(0,id.V)(this,tt,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,i){let r,s=i?.signal;s&&(s.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),s.addEventListener("abort",r));try{(0,id.V)(this,eW,"m",ti).call(this),(0,id.b)(this,e3,i?.__span??((0,id.V)(this,e8,"f")&&function(e,t,i){if(!e._tracer)return;let r=aR(t,i);return rC(e,"anthropic.messages.create",i,sz(e,{...aP(t),stream:!0},r))}((0,id.V)(this,e8,"f"),t,i)),"f");let{response:r,data:s}=await e({...t,stream:!0},{...i,__span:(0,id.V)(this,e3,"f"),signal:this.controller.signal}).withResponse();try{this._connected(r)}catch(e){throw(0,id.V)(this,e3,"f")&&((0,id.V)(this,e3,"f").failure=e),s.controller.abort(),e}for await(let e of s)try{(0,id.V)(this,eW,"m",tr).call(this,e)}catch(e){throw(0,id.V)(this,e3,"f")&&((0,id.V)(this,e3,"f").failure=e),e}if(s.controller.signal?.aborted)throw new ry.F;(0,id.V)(this,eW,"m",ts).call(this)}finally{s&&r&&s.removeEventListener("abort",r)}}_connected(e){this.ended||((0,id.b)(this,e2,e,"f"),(0,id.b)(this,e6,e?.headers.get("request-id"),"f"),(0,id.b)(this,e4,e?.headers.get("anthropic-workspace-id"),"f"),(0,id.V)(this,eB,"f").call(this,e),this._emit("connect"))}get ended(){return(0,id.V)(this,eQ,"f")}get errored(){return(0,id.V)(this,eZ,"f")}get aborted(){return(0,id.V)(this,e0,"f")}abort(){this.controller.abort()}on(e,t){return((0,id.V)(this,eY,"f")[e]||((0,id.V)(this,eY,"f")[e]=[])).push({listener:t}),this}off(e,t){let i=(0,id.V)(this,eY,"f")[e];if(!i)return this;let r=i.findIndex(e=>e.listener===t);return r>=0&&i.splice(r,1),this}once(e,t){return((0,id.V)(this,eY,"f")[e]||((0,id.V)(this,eY,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,i)=>{(0,id.b)(this,e1,!0,"f"),"error"!==e&&this.once("error",i),this.once(e,t)})}async done(){(0,id.b)(this,e1,!0,"f"),await (0,id.V)(this,eJ,"f")}get currentMessage(){return(0,id.V)(this,eU,"f")}async finalMessage(){return await this.done(),(0,id.V)(this,eW,"m",e7).call(this)}async finalText(){return await this.done(),(0,id.V)(this,eW,"m",te).call(this)}_emit(e,...t){if((0,id.V)(this,eQ,"f"))return;"end"===e&&((0,id.b)(this,eQ,!0,"f"),(0,id.V)(this,eG,"f").call(this));let i=(0,id.V)(this,eY,"f")[e];if(i&&((0,id.V)(this,eY,"f")[e]=i.filter(e=>!e.once),i.forEach(({listener:e})=>e(...t))),"abort"===e){let e=t[0];(0,id.V)(this,e1,"f")||i?.length||Promise.reject(e),(0,id.V)(this,eK,"f").call(this,e),(0,id.V)(this,eX,"f").call(this,e),this._emit("end");return}if("error"===e){let e=t[0];(0,id.V)(this,e1,"f")||i?.length||Promise.reject(e),(0,id.V)(this,eK,"f").call(this,e),(0,id.V)(this,eX,"f").call(this,e),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",(0,id.V)(this,eW,"m",e7).call(this))}_deliverEvent(e,t){this._emit("_rawEvent",e),t&&this._emit("streamEvent",e,t)}async _fromReadableStream(e,t){let i,r=t?.signal;r&&(r.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),r.addEventListener("abort",i));try{(0,id.V)(this,eW,"m",ti).call(this),this._connected(null);let t=rS.fromReadableStream(e,this.controller);for await(let e of t)(0,id.V)(this,eW,"m",tr).call(this,e);if(t.controller.signal?.aborted)throw new ry.F;(0,id.V)(this,eW,"m",ts).call(this)}finally{r&&i&&r.removeEventListener("abort",i)}}[(eU=new WeakMap,eF=new WeakMap,eH=new WeakMap,eB=new WeakMap,eK=new WeakMap,eJ=new WeakMap,eG=new WeakMap,eX=new WeakMap,eY=new WeakMap,eQ=new WeakMap,eZ=new WeakMap,e0=new WeakMap,e1=new WeakMap,e2=new WeakMap,e6=new WeakMap,e4=new WeakMap,e5=new WeakMap,e8=new WeakMap,e3=new WeakMap,e9=new WeakMap,tt=new WeakMap,eW=new WeakSet,e7=function(){if(0===this.receivedMessages.length)throw new ry.v("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},te=function(){if(0===this.receivedMessages.length)throw new ry.v("stream ended without producing a Message with role=assistant");let e=this.receivedMessages.at(-1).content.filter(e=>"text"===e.type).map(e=>e.text);if(0===e.length)throw new ry.v("stream ended without producing a content block with type=text");return e.join(" ")},ti=function(){this.ended||(0,id.b)(this,eU,void 0,"f")},tr=function(e){if(this.ended)return;let t=(0,id.V)(this,eW,"m",tn).call(this,e);if(this._deliverEvent(e,t),t)switch(e.type){case"content_block_delta":{let i=t.content.at(-1);switch(e.delta.type){case"text_delta":"text"===i.type&&this._emit("text",e.delta.text,i.text||"");break;case"citations_delta":"text"===i.type&&this._emit("citation",e.delta.citation,i.citations??[]);break;case"input_json_delta":if(aE(i)&&(0,id.V)(this,eY,"f").inputJson?.length){let t;try{t=i.input}catch(e){(0,id.V)(this,tt,"f").call(this,(0,id.V)(this,eW,"m",ta).call(this,i,e));break}this._emit("inputJson",e.delta.partial_json,t)}break;case"thinking_delta":"thinking"===i.type&&this._emit("thinking",e.delta.thinking,i.thinking);break;case"signature_delta":"thinking"===i.type&&this._emit("signature",i.signature);break;case"compaction_delta":"compaction"===i.type&&i.content&&this._emit("compaction",i.content);break;default:(0,ip.f)(e.delta)}break}case"message_stop":(0,id.V)(this,e8,"f")&&(0,id.V)(this,e3,"f")&&(0,id.V)(this,eF,"f")&&sZ((0,id.V)(this,e8,"f"),(0,id.V)(this,e3,"f"),(0,id.V)(this,e9,"f")??(0,id.V)(this,eF,"f"),t),this._addMessageParam(t),this._addMessage(aq(t,(0,id.V)(this,eF,"f"),{logger:(0,id.V)(this,e5,"f")}),!0);break;case"content_block_stop":this._emit("contentBlock",t.content.at(-1));break;case"message_start":(0,id.b)(this,eU,t,"f"),(0,id.V)(this,e3,"f")&&(0,id.V)(this,eF,"f")&&((0,id.V)(this,e3,"f").streamed={body:(0,id.V)(this,e9,"f")??(0,id.V)(this,eF,"f"),message:t})}},ts=function(){if(this.ended)throw new ry.v("stream has ended, this shouldn't happen");let e=(0,id.V)(this,eU,"f");if(!e)throw new ry.v("request ended without sending any chunks");return(0,id.b)(this,eU,void 0,"f"),aq(e,(0,id.V)(this,eF,"f"),{logger:(0,id.V)(this,e5,"f")})},tn=function(e){let t=(0,id.V)(this,eU,"f");if("message_start"===e.type){if(t)throw new ry.v(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(t)switch(e.type){case"message_stop":default: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,null!=e.delta.container&&(t.container=e.delta.container),null!=e.context_management&&(t.context_management=e.context_management),null!=e.input_transformations&&(t.input_transformations=e.input_transformations),null!=e.usage.input_tokens&&(t.usage.input_tokens=e.usage.input_tokens),null!=e.usage.cache_creation_input_tokens&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),null!=e.usage.cache_read_input_tokens&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),null!=e.usage.server_tool_use&&(t.usage.server_tool_use=e.usage.server_tool_use),null!=e.usage.iterations&&(t.usage.iterations=e.usage.iterations),null!=e.usage.fallback_credit&&(t.usage.fallback_credit=e.usage.fallback_credit),null!=e.usage.output_tokens_details&&(t.usage.output_tokens_details=e.usage.output_tokens_details),t;case"content_block_start":return t.content.push(e.content_block),"fallback"===e.content_block.type&&(t.model=e.content_block.to.model),t;case"content_block_delta":{let i=t.content.at(e.index);switch(e.delta.type){case"text_delta":i?.type==="text"&&(t.content[e.index]={...i,text:(i.text||"")+e.delta.text});break;case"citations_delta":i?.type==="text"&&(t.content[e.index]={...i,citations:[...i.citations??[],e.delta.citation]});break;case"input_json_delta":if(i&&aE(i)){let r=(i[nd]||"")+e.delta.partial_json;t.content[e.index]=np(i,r)}break;case"thinking_delta":i?.type==="thinking"&&(t.content[e.index]={...i,thinking:i.thinking+e.delta.thinking});break;case"signature_delta":i?.type==="thinking"&&(t.content[e.index]={...i,signature:e.delta.signature});break;case"compaction_delta":if(i?.type==="compaction"){let r={...i,content:e.delta.content};"encrypted_content"in e.delta&&(r.encrypted_content=e.delta.encrypted_content),t.content[e.index]=r}break;default:(0,ip.f)(e.delta)}return t}case"content_block_stop":{let i=t.content.at(e.index);if(i&&aE(i)&&nd in i){let e;try{e=i.input}catch(t){e={},(0,id.V)(this,tt,"f").call(this,(0,id.V)(this,eW,"m",ta).call(this,i,t))}Object.defineProperty(i,"input",{value:e,enumerable:!0,configurable:!0,writable:!0})}return t}}},ta=function(e,t){let i=e[nd];return new ry.v(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${t}. JSON: ${i}`)},Symbol.asyncIterator)](){let e=[],t=[],i=!1;return this.on("_rawEvent",i=>{let r=t.shift();r?r.resolve(i):e.push(i)}),this.on("end",()=>{for(let e of(i=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let r of(i=!0,t))r.reject(e);t.length=0}),this.on("error",e=>{for(let r of(i=!0,t))r.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:i?{value:void 0,done:!0}:new Promise((e,i)=>t.push({resolve:e,reject:i})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new rS(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}return e})();let aM={browser_toolset_20260801:"browser",computer_toolset_20260801:"computer"};function aL(e){return aM[e.type]}function aC(e){return"run"in e&&null!=e.type&&Object.prototype.hasOwnProperty.call(aM,e.type)}var aN=ry;class aj extends aN.v{constructor(e,t){super(e),this.name="ToolsetUsageError",t&&"cause"in t&&(this.cause=t.cause)}}class aD extends aj{constructor(e,t){super(e,t),this.name="ToolsetContractError"}}ar.f,ar.f,ar.f,ar.f,ar.f,ar.f,ar.f,ar.f;let aW="Not executed: an earlier action in this turn failed.",aU={browser:aW,computer:"Not executed: an earlier computer action in this turn failed."};function aF(e,t,i=!1){return i&&(""===t||Array.isArray(t)&&0===t.length)&&(t="The tool call failed with an empty error message."),{type:"tool_result",tool_use_id:e.id,toolset_name:e.toolset_name??null,content:t,...i?{is_error:!0}:{}}}async function aH(e,t,i={}){let r=aL(e);if(t.toolset_name!==r)throw new aD(`tool_use ${JSON.stringify(t.id)} (toolset_name=${JSON.stringify(t.toolset_name??null)}, name=${JSON.stringify(t.name)}) is not a member call of the ${JSON.stringify(r)} toolset`);let s={...i,toolUse:t,toolUseBlock:t};try{return aF(t,await e.run(s,t))}catch(e){var n;if(e instanceof aj)throw e;return function(e){if(e?.aborted)throw new ry.F}(s.signal),aF(t,"string"==typeof(n=e instanceof ar.f?e.content:ac(aa(al(e)),4096))?aa(n):n.filter(e=>"text"===e.type&&""!==e.text).map(e=>({...e,text:aa(e.text)})),!0)}}var aB=(()=>{class e extends aO{constructor(e,t,i){super(e,{client:i}),to.add(this),tl.set(this,void 0),tc.set(this,0),tu.set(this,[]),th.set(this,[]),td.set(this,void 0),tp.set(this,[]),t_.set(this,!1),(0,id.b)(this,tl,t,"f")}get toolCalls(){return(0,id.V)(this,th,"f")}_deliverEvent(e,t){var i;(0,id.b)(this,tc,(i=(0,id.V)(this,tc,"f"),++i),"f");let r="content_block_stop"===e.type?t?.content[e.index]:void 0,s=r?.type==="tool_use"?r:void 0;s&&(0,id.V)(this,th,"f").push(s),super._deliverEvent(e,t),(0,id.V)(this,to,"m",tf).call(this,e,s),(0,id.V)(this,to,"m",tg).call(this)}[(tl=new WeakMap,tc=new WeakMap,tu=new WeakMap,th=new WeakMap,td=new WeakMap,tp=new WeakMap,t_=new WeakMap,to=new WeakSet,Symbol.asyncIterator)](){let e=super[Symbol.asyncIterator](),t={handled:(0,id.V)(this,tc,"f")};(0,id.V)(this,tu,"f").push(t);let i=!1;return{next:async()=>{i&&(i=!1,t.handled++,(0,id.V)(this,to,"m",tg).call(this));try{let r=await e.next();return i=!r.done,r.done&&(0,id.V)(this,to,"m",tm).call(this,t),r}catch(e){throw(0,id.V)(this,to,"m",tm).call(this,t),e}},return:async()=>{let i=e.return?.();return(0,id.V)(this,to,"m",tm).call(this,t),await i??{value:void 0,done:!0}}}}}return tf=function(e,t){if((0,id.V)(this,t_,"f"))return;if("content_block_start"===e.type&&"fallback"===e.content_block.type){(0,id.b)(this,t_,!0,"f"),(0,id.b)(this,td,void 0,"f");return}let i="content_block_start"===e.type||"message_delta"===e.type&&"tool_use"===e.delta.stop_reason;(0,id.V)(this,td,"f")&&i&&((0,id.V)(this,tp,"f").push({toolUse:(0,id.V)(this,td,"f"),event:(0,id.V)(this,tc,"f")}),(0,id.b)(this,td,void 0,"f")),t&&(0,id.b)(this,td,t,"f")},tg=function(){if(this.errored||this.controller.signal.aborted)return;let e=Math.min((0,id.V)(this,tc,"f"),...(0,id.V)(this,tu,"f").map(e=>e.handled));for(;(0,id.V)(this,tp,"f")[0]&&(0,id.V)(this,tp,"f")[0].event<=e;)(0,id.V)(this,tl,"f").call(this,(0,id.V)(this,tp,"f").shift().toolUse)},tm=function(e){let t=(0,id.V)(this,tu,"f").indexOf(e);t>=0&&((0,id.V)(this,tu,"f").splice(t,1),(0,id.V)(this,to,"m",tg).call(this))},e})(),aK=e.i(368120);class aJ{constructor(e,t,i){this.fields=e,this.ownMessages=t,this.ownCreateOnly=i,this.deferredMessages=[],this.replacementHistory=null,this.createOnly=a0(e)}}var aG=(tb=new WeakMap,ty=new WeakMap,tw=new WeakMap,tk=new WeakMap,tz=new WeakMap,tS=new WeakMap,tv=new WeakSet,tx=function(){for(let e of[(0,id.V)(this,tw,"f"),(0,id.V)(this,ty,"f")])for(let t=e.length-1;t>=0;t--)if(e[t].reply)return e[t].reply;return null},tV=function(e){if("id"in e)return e.id===(0,id.V)(this,tv,"a",tx)?.id;let t=(0,id.V)(this,tw,"f").at(-1)??(0,id.V)(this,ty,"f").at(-1);return t?.reply!=null&&a8(e,t.param)},tA=function(e){(0,id.V)(this,tS,"f").info(`Replaying the full message history under a new thread: reason=${e} previous_message_id=${this.previousMessageId}`),(0,id.b)(this,tk,{type:"create",replacesLostThread:"thread_not_found"===e},"f")},tI=function(){let e=(0,id.V)(this,ty,"f").at(-1);if((0,id.V)(this,tw,"f").length||!e||e.reply&&!e.partial)return;e.reply&&(0,id.V)(this,ty,"f").pop();let t=(0,id.V)(this,ty,"f").length;for(;t>0&&!(0,id.V)(this,ty,"f")[t-1].reply;)t-=1;(0,id.b)(this,tw,(0,id.V)(this,ty,"f").splice(t),"f"),(0,id.V)(this,tS,"f").info(`Re-sending the turn whose reply ended before \`message_stop\`: partial_reply_id=${e.reply?.id??null}`)},tq=function(e){return"refusal"===e.stop_reason&&"never_threaded"!==(0,id.V)(this,tk,"f").type&&(null!==this.previousMessageId&&(0,id.V)(this,tv,"m",tA).call(this,"refusal"),!0)},t$=function(e,{partial:t}){(0,id.V)(this,ty,"f").push(...(0,id.V)(this,tw,"f")),(0,id.b)(this,tw,[],"f"),e&&(0,id.V)(this,ty,"f").push({param:a3(e),reply:e,partial:t})},tR=function(e){let{container:t}=(0,id.V)(this,tb,"f");null==t?(0,id.b)(this,tb,{...(0,id.V)(this,tb,"f"),container:e},"f"):"object"==typeof t&&null==t.id&&(0,id.b)(this,tb,{...(0,id.V)(this,tb,"f"),container:{...t,id:e}},"f")},tP=function(e){if("continue"!==(0,id.V)(this,tk,"f").type)return;let{createdWith:t}=(0,id.V)(this,tk,"f"),i=aZ.filter(i=>e[i]!==t[i]);if(i.length){let e=i.map(e=>`\`${e}\``).join(" and ");throw new ry.v(`Cannot change ${e} on a thread: the server keeps the \`system\` and \`tools\` the thread was created with. To change them, start a new thread from \`thread.params\`.`+(i.includes("tools")?" To add or remove tools on this thread, send `tool_addition` or `tool_removal` blocks in a `system` message.":""))}},tT=function(e,{stream:t}){var i;let r,s={...this.options,...a4(e)};return t&&(s.headers=rR([{[ni]:"stream"},s.headers])),"never_threaded"!==(0,id.V)(this,tk,"f").type&&(s.headers=rR([s.headers,{[nt]:"message-thread"}])),this.threading&&(s.headers=null===(r=rR([i=s.headers]).values.get("anthropic-beta"))?i:rR([i,{"anthropic-beta":r$(r,aQ)}])),s},class e{constructor({params:e,options:t,threading:i,logger:r}){tv.add(this),tb.set(this,void 0),ty.set(this,[]),tw.set(this,[]),tk.set(this,void 0),tz.set(this,null),tS.set(this,void 0);let{messages:s,unsupportedRequestBehavior:n,...a}=e;a6(a),this.options=t,this.unsupportedRequestBehavior=n??"error",(0,id.b)(this,tb,a,"f"),(0,id.b)(this,tk,i?{type:"create",replacesLostThread:!1}:{type:"never_threaded"},"f"),(0,id.b)(this,tS,r,"f"),this.push(s??[])}get threading(){return"create"===(0,id.V)(this,tk,"f").type||"continue"===(0,id.V)(this,tk,"f").type}get previousMessageId(){return"continue"===(0,id.V)(this,tk,"f").type?(0,id.V)(this,tk,"f").previousMessageId:null}get messages(){let e=(0,id.V)(this,tz,"f")?.replacementHistory?.slice()??[...(0,id.V)(this,ty,"f"),...(0,id.V)(this,tw,"f")].map(e=>e.param);return(0,id.V)(this,tz,"f")&&e.push(...(0,id.V)(this,tz,"f").deferredMessages.map(a3)),e}get params(){let e="create"===(0,id.V)(this,tk,"f").type?(0,id.V)(this,tz,"f")?.ownCreateOnly:void 0;return{...(0,id.V)(this,tb,"f"),...e,messages:this.messages}}push(e){if((0,id.V)(this,tz,"f"))return void(0,id.V)(this,tz,"f").deferredMessages.push(...e);for(let t of e)(0,id.V)(this,tv,"m",tV).call(this,t)||(0,id.V)(this,tw,"f").push({param:a3(t),reply:null})}update(e={},t={}){for(let i of(a6(e),(0,id.b)(this,tb,{...(0,id.V)(this,tb,"f"),...a4(e)},"f"),this.options={...this.options,...a4(t)},aZ))void 0!==e[i]&&delete(0,id.V)(this,tz,"f")?.ownCreateOnly[i]}fork(t=(0,id.V)(this,tb,"f")){let i=new e({params:{...t,unsupportedRequestBehavior:this.unsupportedRequestBehavior},options:this.options,threading:"never_threaded"!==(0,id.V)(this,tk,"f").type,logger:(0,id.V)(this,tS,"f")});return this.threading||i.stopThreading(),(0,id.V)(this,tz,"f")?.replacementHistory?(0,id.b)(i,tw,(0,id.V)(this,tz,"f").replacementHistory.map(e=>({param:e,reply:null})),"f"):((0,id.b)(i,ty,[...(0,id.V)(this,ty,"f")],"f"),(0,id.b)(i,tw,[...(0,id.V)(this,tw,"f")],"f")),(0,id.V)(this,tz,"f")&&i.push((0,id.V)(this,tz,"f").deferredMessages),i}setParams({messages:e,...t}){(0,id.b)(this,tb,t,"f"),(0,id.V)(this,tz,"f")&&((0,id.V)(this,tz,"f").ownCreateOnly={}),this.setMessages(e)}setMessages(e){let t=[...(0,id.V)(this,ty,"f"),...(0,id.V)(this,tw,"f")];if((0,id.V)(this,tz,"f")){let i=t.map(e=>e.param);a5(e,i)?((0,id.V)(this,tz,"f").replacementHistory=null,(0,id.V)(this,tz,"f").deferredMessages=e.slice(i.length)):((0,id.V)(this,tz,"f").replacementHistory=e,(0,id.V)(this,tz,"f").deferredMessages=[]);return}!a5(e,(0,id.V)(this,ty,"f").map(e=>e.param))&&((0,id.b)(this,ty,[],"f"),this.threading&&(0,id.b)(this,tk,{type:"create",replacesLostThread:!1},"f")),(0,id.b)(this,tw,[],"f");let i=new Map(t.filter(e=>e.reply).map(e=>[e.param.content,e]));for(let t of e.slice((0,id.V)(this,ty,"f").length))(0,id.V)(this,tv,"m",tV).call(this,t)||(0,id.V)(this,tw,"f").push({...i.get(t.content)??{reply:null},param:a3(t)})}get hasTurnToSend(){return(0,id.V)(this,tw,"f").length>0||aY((0,id.V)(this,ty,"f").at(-1)?.reply?.stop_reason)}startTurn(e,t){if((0,id.V)(this,tz,"f"))throw new ry.v("Another `send()`, `parse()` or `stream()` is already in progress on this thread");a6(t);let i=(0,id.V)(this,tw,"f").length;this.push(e);let r=(0,id.V)(this,tw,"f").slice(i);(0,id.V)(this,tv,"m",tI).call(this);let s={};return void 0!==t.system&&(s.system=t.system),void 0!==t.tools&&(s.tools=t.tools),(0,id.b)(this,tz,new aJ({...(0,id.V)(this,tb,"f"),...a4(t)},r,s),"f")}endTurn(e){(0,id.b)(this,tz,null,"f"),(0,id.b)(this,tw,(0,id.V)(this,tw,"f").filter(t=>!e.ownMessages.includes(t)),"f"),e.replacementHistory&&this.setMessages(e.replacementHistory),this.push(e.deferredMessages)}recoversFrom(e){var t;let i;if(!(e instanceof ry.E))return!1;let r="continue_unthreaded"===this.unsupportedRequestBehavior,s=(t=e,i=a2(t)?.error_code,a1.find(e=>e===i)??null);if(null!==s&&"continue"===(0,id.V)(this,tk,"f").type)return"thread_not_found"===s&&(0,id.V)(this,tk,"f").replacesLostThread&&r?((0,id.V)(this,tS,"f").info(`The server lost the thread again right after a replay; continuing without a thread: previous_message_id=${(0,id.V)(this,tk,"f").previousMessageId}`),this.stopThreading()):(0,id.V)(this,tv,"m",tA).call(this,s),!0;let n=function(e){let t=a2(e);if(t?.error_code!=="thread_unsupported_request")return null;let i=t.unsupported;return Array.isArray(i)?i.map(String):[]}(e);return null!==n&&!!this.threading&&!!r&&((0,id.V)(this,tS,"f").info(`The server cannot thread this request; continuing without a thread: unsupported=${n.join(",")}`),this.stopThreading(),!0)}stopThreading(){this.threading&&(0,id.b)(this,tk,{type:"unthreaded"},"f")}recordPartialReply(e,t){var i,r;let s,n;(0,id.V)(this,tv,"m",tq).call(this,e)||((0,id.V)(this,tv,"m",t$).call(this,(i=e,r=t,s=i.content.slice(0,r),n=i.content[r],n?.type==="text"&&n.text&&s.push(n),s.length?{...i,content:s}:null),{partial:!0}),null!==this.previousMessageId&&(0,id.V)(this,tv,"m",tA).call(this,"stream_ended_before_message_stop"))}recordReply(e,t){!(0,id.V)(this,tv,"m",tq).call(this,t)&&((0,id.V)(this,tv,"m",t$).call(this,t,{partial:!1}),"create"===(0,id.V)(this,tk,"f").type&&(0,id.b)(this,tb,{...(0,id.V)(this,tb,"f"),...e.ownCreateOnly},"f"),this.threading&&((0,id.b)(this,tk,{type:"continue",previousMessageId:t.id,createdWith:e.createOnly,replacesLostThread:"create"===(0,id.V)(this,tk,"f").type&&(0,id.V)(this,tk,"f").replacesLostThread},"f"),t.usage.iterations?.some(e=>"fallback_message"===e.type)&&(0,id.V)(this,tv,"m",tA).call(this,"fallback_message")),t.container&&(0,id.V)(this,tv,"m",tR).call(this,t.container.id))}buildCreateArguments(e,t,{stream:i}){(0,id.V)(this,tv,"m",tP).call(this,e.createOnly);let r=(0,id.V)(this,tk,"f"),s="continue"===r.type?[]:(0,id.V)(this,ty,"f").map(e=>e.param);if("never_threaded"!==r.type){let e=(0,id.V)(this,ty,"f").map(e=>null!==e.reply).lastIndexOf(!0)+1;s=s.map((t,i)=>i<e?function e(t){if(!(0,ip.u)(t))return t;let{cache_control:i,...r}=t;for(let t of["content","source","tool","definition","tool_references"]){let i=r[t];Array.isArray(i)?r[t]=i.map(e):(0,ip.u)(i)&&(r[t]=e(i))}return r}(t):t)}let n={...e.fields,messages:[...s,...(0,id.V)(this,tw,"f").map(e=>e.param)]};if(this.threading&&!n.betas?.includes(aQ)&&(n.betas=[...n.betas??[],aQ]),"create"===r.type)n.thread={type:"create"};else if("continue"===r.type)for(let e of(n.thread={type:"continue",previous_message_id:r.previousMessageId},aZ))delete n[e];return{params:n,options:(0,id.V)(this,tv,"m",tT).call(this,t,{stream:i})}}checkNextTurn(e){(0,id.V)(this,tv,"m",tP).call(this,a0({...(0,id.V)(this,tb,"f"),...a4(e)}))}});let aX=["pause_turn","compaction"];function aY(e){return aX.some(t=>t===e)}let aQ="message-threads-2026-08-12",aZ=["system","tools"];function a0(e){return{system:JSON.stringify(e.system),tools:JSON.stringify(e.tools)}}let a1=["thread_not_found","thread_already_continued","thread_continue_in_flight"];function a2(e){let t=e.error,i=t?.error?.details;return(0,ip.u)(i)?i:null}function a6(e){if("thread"in e&&void 0!==e.thread)throw TypeError("`thread` cannot be set here. The message thread sets it for each request itself.")}function a4(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}function a5(e,t){return t.length<=e.length&&t.every((t,i)=>a8(t,e[i]))}function a8(e,t){let[i,r]=[a3(e),a3(t)];return Object.keys({...i,...r}).every(e=>i[e]===r[e]||JSON.stringify(i[e])===JSON.stringify(r[e]))}function a3(e){return"id"in e?{role:e.role,content:e.content}:e}function a9(e){return void 0===e?[]:(0,ip.z)(e)?e:[e]}function a7(e){let{stream:t,max_iterations:i,runToolsEagerly:r,thread:s,...n}=e;if(void 0!==s&&!1!==s)throw TypeError("`thread` cannot be set in the params of a tool runner. The runner sets it for each request itself. To run without a message thread, pass `thread: false`.");return{settings:{stream:t,max_iterations:i,runToolsEagerly:r},thread:s,threadParams:n}}let oe="a tool runner's toolsets come only from its tools param; change them with setMessagesParams(), or build a new runner";var ot=(()=>{class e{constructor(e,t,i){tE.add(this),tO.set(this,!1),tM.set(this,!1),tL.set(this,void 0),tC.set(this,void 0),tN.set(this,void 0),tj.set(this,void 0),tD.set(this,void 0),tW.set(this,void 0),tU.set(this,void 0),tF.set(this,void 0),tH.set(this,void 0),tB.set(this,0),tK.set(this,void 0),tJ.set(this,{status:"idle"}),tG.set(this,void 0),tX.set(this,null),tY.set(this,new Map),tQ.set(this,[]);let{thread:r,settings:s}="_state"in e?{thread:e,settings:t}:e.beta.messages._toolRunnerThread(t);or(r._state.params),os(s),(0,id.b)(this,tL,r,"f"),(0,id.b)(this,tC,a4(s),"f");let{tools:n,messages:a}=r._state.params,o=nn(n,a);"_state"in e||r._state.setMessages(JSON.parse(JSON.stringify(ol(a)))),(0,id.b)(this,tN,{...i},"f"),(0,id.b)(this,tj,rR([{[nt]:"BetaToolRunner"},o.length?{[nt]:o.join(", ")}:void 0]),"f"),(0,id.b)(this,tH,(0,aK.f)(),"f")}async *[(tO=new WeakMap,tM=new WeakMap,tL=new WeakMap,tC=new WeakMap,tN=new WeakMap,tj=new WeakMap,tD=new WeakMap,tW=new WeakMap,tU=new WeakMap,tF=new WeakMap,tH=new WeakMap,tB=new WeakMap,tK=new WeakMap,tJ=new WeakMap,tG=new WeakMap,tX=new WeakMap,tY=new WeakMap,tQ=new WeakMap,tE=new WeakSet,tZ=function(e){return(0,id.V)(this,tK,"f")?iJ.with((0,id.V)(this,tK,"f"),e):e()},Symbol.asyncIterator)](){var e;if((0,id.V)(this,tO,"f"))throw new ry.v("Cannot iterate over a consumed stream");(0,id.b)(this,tO,!0,"f"),(0,id.b)(this,tM,!0,"f"),(0,id.b)(this,tF,void 0,"f");let t=rL((0,id.V)(this,tL,"f")._client,()=>(function(e,t,i){if(!e._tracer)return;let r=t.output_config?.format?.type==="json_schema"||t.output_format?.type==="json_schema";return e._tracer.startSpan("anthropic.messages.tool_runner",{kind:rv.INTERNAL,attributes:{[ss]:"invoke_agent",[rO]:e._genAIProviderName,[so]:t.model,...r?{[sa]:su}:void 0,...null!=i?{[rE]:i}:void 0}})})((0,id.V)(this,tL,"f")._client,this.params,(0,id.V)(this,tN,"f").openTelemetry?.conversationId));(0,id.b)(this,tK,t&&rm.setSpan(iJ.active(),t),"f");try{for(;;)try{if((0,id.V)(this,tC,"f").max_iterations&&(0,id.V)(this,tB,"f")>=(0,id.V)(this,tC,"f").max_iterations)break;if((0,id.V)(this,tE,"m",ir).call(this),"scheduled"===(0,id.V)(this,tJ,"f").status&&"resume"!==of((0,id.V)(this,tX,"f"))){yield*(0,id.V)(this,tE,"m",t4).call(this,(0,id.V)(this,tJ,"f").config);continue}(0,id.b)(this,tM,!1,"f"),(0,id.b)(this,tF,void 0,"f"),(0,id.b)(this,tB,(e=(0,id.V)(this,tB,"f"),++e),"f"),(0,id.b)(this,tW,void 0,"f"),yield*(0,id.V)(this,tE,"m",t0).call(this,(0,id.V)(this,tL,"f"));let t=(0,id.V)(this,tD,"f");(0,id.b)(this,tD,void 0,"f");let i=await (0,id.V)(this,tE,"m",tZ).call(this,async()=>{let e;if((0,id.V)(this,tM,"f"))(0,id.b)(this,tX,null,"f"),(0,id.V)(this,tU,"f")?.abort(),(0,id.V)(this,tL,"f")._state.checkNextTurn(oo((0,id.V)(this,tL,"f"))),(0,id.V)(this,tL,"f")._state.setMessages(t),e=t.at(-1);else{let t=await (0,id.V)(this,tW,"f"),i=of(t.stop_reason);if((0,id.b)(this,tX,t.stop_reason,"f"),"stop"===i)return"stop";if("resume"===i)return"continue";e=function(e){for(let t=e.length-1;t>=0;t--){let i=e[t];if("assistant"===i.role)return i;if("user"===i.role&&Array.isArray(i.content)&&i.content.some(e=>"tool_result"===e.type))break}}((0,id.V)(this,tL,"f").messages)}op(e)&&(0,id.V)(this,tL,"f")._state.checkNextTurn(oo((0,id.V)(this,tL,"f")));let i=await (0,id.V)(this,tE,"m",ie).call(this,e,(0,id.V)(this,tN,"f").signal,(0,id.V)(this,tK,"f"));if(i){let e=(0,id.V)(this,tL,"f").messages,t=e.map(e=>e.role).lastIndexOf("assistant")+1;(0,id.V)(this,tL,"f")._state.setMessages([...e.slice(0,t),i,...e.slice(t)])}else if(!(0,id.V)(this,tM,"f")&&!(0,id.V)(this,tL,"f")._state.hasTurnToSend)return"stop";return"continue"});if("stop"===i){yield*(0,id.V)(this,tE,"m",t7).call(this);break}}finally{(0,id.V)(this,tU,"f")?.abort(),(0,id.b)(this,tU,void 0,"f")}if(await (0,id.V)(this,tE,"m",t6).call(this),!(0,id.V)(this,tW,"f"))throw new ry.v("ToolRunner concluded without a message from the server");(0,id.V)(this,tH,"f").resolve(await (0,id.V)(this,tW,"f")),rL((0,id.V)(this,tL,"f")._client,()=>t?.setStatus({code:rb.OK}))}catch(e){throw t&&rL((0,id.V)(this,tL,"f")._client,()=>rW(t,e)),(0,id.b)(this,tO,!1,"f"),(0,id.b)(this,tD,void 0,"f"),(0,id.V)(this,tH,"f").promise.catch(()=>{}),(0,id.V)(this,tH,"f").reject(e),(0,id.b)(this,tH,(0,aK.f)(),"f"),e}finally{rL((0,id.V)(this,tL,"f")._client,()=>t?.end()),(0,id.b)(this,tK,void 0,"f")}}setMessagesParams(e){var t,i;let r="function"==typeof e?e(this.params):e;if(or(r),"idle"!==(0,id.V)(this,tJ,"f").status&&on(r),"in_flight"===(0,id.V)(this,tJ,"f").status&&(t=r.messages,i=(0,id.V)(this,tL,"f").messages,!(t.length===i.length&&t.every((e,t)=>a8(e,i[t])))))throw new ry.v(oi);let{settings:s,threadParams:n}=a7(r);os(s),(0,id.b)(this,tC,a4(s),"f"),(0,id.V)(this,tD,"f")?((0,id.b)(this,tD,n.messages,"f"),(0,id.V)(this,tL,"f")._state.setParams({...n,messages:(0,id.V)(this,tL,"f").messages})):(0,id.V)(this,tL,"f")._state.setParams(n),(0,id.b)(this,tM,!0,"f"),(0,id.b)(this,tF,void 0,"f")}setRequestOptions(e){"function"==typeof e?(0,id.b)(this,tN,e((0,id.V)(this,tN,"f")),"f"):(0,id.b)(this,tN,{...(0,id.V)(this,tN,"f"),...e},"f")}async generateToolResponse(e=(0,id.V)(this,tN,"f").signal){let t=(0,id.V)(this,tL,"f")._client._tracer?iJ.active():void 0,i=await (0,id.V)(this,tW,"f")??(0,id.V)(this,tL,"f").messages.at(-1);return i?(0,id.V)(this,tE,"m",ie).call(this,i,e,t):null}deferToolCall(e){let t="string"==typeof e?e:e.id;(0,id.V)(this,tG,"f")&&!(0,id.V)(this,tG,"f").has(t)&&(0,id.V)(this,tG,"f").set(t,{status:"held"})}get deferredToolCalls(){let e=(0,id.V)(this,tU,"f"),t=(0,id.V)(this,tG,"f");return e instanceof aB&&t?e.toolCalls.filter(e=>t.get(e.id)?.status==="held"):[]}done(){return(0,id.V)(this,tH,"f").promise}async runUntilDone(){if(!(0,id.V)(this,tO,"f"))for await(let e of this);return this.done()}get params(){return{...(0,id.V)(this,tL,"f")._state.params,...(0,id.V)(this,tD,"f")&&{messages:[...(0,id.V)(this,tD,"f")]},...(0,id.V)(this,tC,"f")}}pushMessages(...e){this.setMessagesParams(t=>({...t,messages:[...t.messages,...e]}))}compactBeforeNextTurn(e){"in_flight"!==(0,id.V)(this,tJ,"f").status&&(on(this.params),(0,id.b)(this,tJ,{status:"scheduled",config:e??{type:"summarize"}},"f"))}addTools(...e){let t=(0,id.V)(this,tE,"m",it).call(this);for(let i of e){if(aC(i))throw new aD(`addTools() can't add the '${ao(aL(i))}' toolset: ${oe}`);let e=(i.type??"custom").replace(/_\d{8}$/,"").replace(/_toolset$/,"");if(t.has(e))throw new aD(`addTools() can't replace the '${ao(e)}' toolset: ${oe}`)}for(let t of e)"name"in t&&(0,id.V)(this,tY,"f").set(t.name,"run"in t?t:null),(0,id.V)(this,tQ,"f").push({type:"addition",tool:t})}removeTools(...e){let t=(0,id.V)(this,tE,"m",it).call(this);for(let i of e){let e="string"==typeof i?i:i.name;if(t.has(e))throw new aD(`removeTools() can't remove the '${ao(e)}' toolset: a tool runner's toolsets come only from its tools param; remove it there with setMessagesParams(), or build a new runner without it`)}for(let t of e){let e="string"==typeof t?t:t.name;(0,id.V)(this,tY,"f").set(e,null),(0,id.V)(this,tQ,"f").push({type:"removal",name:e})}}then(e,t){return this.runUntilDone().then(e,t)}}return t0=async function*(e){await (0,id.V)(this,tE,"m",t6).call(this),(0,id.b)(this,tG,void 0,"f");let t=e.messages;t.some(oc)&&(0,id.V)(this,tE,"m",tZ).call(this,()=>e._state.setMessages(ol(t)));let{tools:i}=e._state.params;(0,id.V)(this,tC,"f").stream?((0,id.b)(this,tU,(0,id.V)(this,tE,"m",tZ).call(this,()=>(0,id.V)(this,tC,"f").runToolsEagerly?(0,id.V)(this,tE,"m",t2).call(this,e):e.stream(void 0,oo(e),(0,id.V)(this,tE,"m",t1).call(this,e))),"f"),i&&e.update({tools:i}),e===(0,id.V)(this,tL,"f")&&(0,id.b)(this,tD,e.messages,"f"),(0,id.b)(this,tW,(0,id.V)(this,tU,"f").finalMessage(),"f"),(0,id.V)(this,tW,"f").catch(()=>{}),yield(0,id.V)(this,tU,"f")):((0,id.b)(this,tW,(0,id.V)(this,tE,"m",tZ).call(this,()=>e.send(void 0,oo(e),(0,id.V)(this,tE,"m",t1).call(this,e))),"f"),i&&e.update({tools:i}),e===(0,id.V)(this,tL,"f")&&(0,id.b)(this,tD,e.messages,"f"),yield(0,id.V)(this,tW,"f"))},t1=function(e){let{headers:t=e._state.options.headers}=(0,id.V)(this,tN,"f");return{...(0,id.V)(this,tN,"f"),headers:rR([(0,id.V)(this,tj,"f"),t])}},t2=function(e){let t=new Map;(0,id.b)(this,tG,t,"f");let i=new Map,r=e=>{let r=t.has(e.id),s=!e.toolset_name&&(0,id.V)(this,tE,"m",it).call(this).has(e.name),n=s?e.name:e.toolset_name;if(n){if(r||s||i.has(n))return void i.set(n,"waiting");i.set(n,"running");let a=oh((0,id.V)(this,tE,"m",ii).call(this),n,e,(0,id.V)(this,tN,"f"),(0,id.V)(this,tL,"f")._client,(0,id.V)(this,tK,"f"));return t.set(e.id,{status:"started",result:a}),void a.then(({is_error:e})=>{e||"waiting"===i.get(n)?i.set(n,"waiting"):i.delete(n)},()=>i.set(n,"waiting"))}if(r)return;let a=od((0,id.V)(this,tE,"m",t8).call(this),(0,id.V)(this,tE,"m",t3).call(this),e,(0,id.V)(this,tN,"f"),(0,id.V)(this,tL,"f")._client,(0,id.V)(this,tK,"f"));a.catch(()=>{}),t.set(e.id,{status:"started",result:a})},s=new aB(e._state.params,r,e._client);return e._stream(s,void 0,oo(e),(0,id.V)(this,tE,"m",t1).call(this,e)),s},t6=async function(){let e=[...(0,id.V)(this,tG,"f")?.values()??[]].filter(e=>"started"===e.status);await Promise.allSettled(e.map(e=>e.result))},t4=async function*(e){on(this.params),(0,id.b)(this,tJ,{status:"in_flight"},"f"),(0,id.b)(this,tF,void 0,"f");let t=(0,id.V)(this,tW,"f"),i=(0,id.V)(this,tE,"m",t5).call(this,e),r=(0,id.V)(this,tL,"f").messages.length;try{yield*(0,id.V)(this,tE,"m",t0).call(this,i);let e=await (0,id.V)(this,tW,"f");if(e.content.some(e=>"compaction"===e.type&&e.content)){(0,id.V)(this,tE,"m",t9).call(this);let t={role:e.role,content:e.content},i=(0,id.V)(this,tL,"f").messages.slice(r).filter(e=>!a8(e,t));(0,id.V)(this,tL,"f")._state.setMessages([t,...i])}else(0,rz.u)((0,id.V)(this,tL,"f")._client).warn("Compaction produced no summary; keeping the conversation as it is."),(0,id.b)(this,tW,t,"f")}finally{(0,id.b)(this,tJ,{status:"idle"},"f"),i._state.threading||(0,id.V)(this,tL,"f")._state.stopThreading()}},t5=function(e){let{messages:t,...i}=function(e){let{context_management:t,stop_sequences:i,output_format:r,...s}=e;return(s.tool_choice?.type==="any"||s.tool_choice?.type==="tool")&&delete s.tool_choice,s.output_config&&(s.output_config=(({format:e,...t})=>t)(s.output_config)),Array.isArray(s.fallbacks)&&(s.fallbacks=s.fallbacks.map(e=>e.output_config?{...e,output_config:(({format:e,...t})=>t)(e.output_config)}:e)),s}((0,id.V)(this,tL,"f")._state.params),r=(0,id.V)(this,tL,"f").fork();return r._state=(0,id.V)(this,tL,"f")._state.fork({...i,compaction:e}),r},t8=function(){let e=new Map;for(let t of(0,id.V)(this,tL,"f")._state.params.tools??[])"run"in t&&"name"in t&&e.set(t.name,t);for(let[t,i]of(0,id.V)(this,tY,"f"))i?e.set(t,i):e.delete(t);return e},t3=function(){let e=new Set((0,id.V)(this,tE,"m",t8).call(this).keys());for(let t of[...this.params.messages,(0,id.V)(this,tE,"m",is).call(this)])if(Array.isArray(t.content)){for(let i of t.content)if("system"===t.role)o_(i,e);else if("assistant"===t.role&&"compaction"===i.type)for(let t of i.tool_changes??[])o_(t,e)}return e},t9=function(){let e=(0,id.V)(this,tE,"m",t3).call(this);for(let t of(0,id.V)(this,tE,"m",t8).call(this).keys())e.has(t)||(0,id.V)(this,tY,"f").set(t,null)},t7=async function*(){if("scheduled"===(0,id.V)(this,tJ,"f").status){if(op((0,id.V)(this,tL,"f").messages.at(-1))){(0,rz.u)((0,id.V)(this,tL,"f")._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."),(0,id.b)(this,tJ,{status:"idle"},"f");return}yield*(0,id.V)(this,tE,"m",t4).call(this,(0,id.V)(this,tJ,"f").config)}},ie=async function(e,t,i){return void 0!==(0,id.V)(this,tF,"f")||(0,id.b)(this,tF,ou((0,id.V)(this,tE,"m",ii).call(this),(0,id.V)(this,tE,"m",t8).call(this),(0,id.V)(this,tE,"m",t3).call(this),e,{...(0,id.V)(this,tN,"f"),signal:t},(0,id.V)(this,tG,"f"),(0,id.V)(this,tL,"f")._client,i),"f"),(0,id.V)(this,tF,"f")},it=function(){return new Set((0,id.V)(this,tE,"m",ii).call(this).tools.filter(aC).map(aL))},ii=function(){return{...this.params,tools:(0,id.V)(this,tL,"f")._state.params.tools??[]}},ir=function(){"pause_turn"!==(0,id.V)(this,tX,"f")&&0!==(0,id.V)(this,tQ,"f").length&&((0,id.V)(this,tL,"f").append((0,id.V)(this,tE,"m",is).call(this)),(0,id.b)(this,tQ,[],"f"))},is=function(){let e=[];for(let t of(0,id.V)(this,tQ,"f")){if("removal"===t.type){e.push({type:"tool_removal",tool:{type:"tool_reference",name:t.name}});continue}let i=oa(t.tool);e.push({type:"tool_addition",tool:{type:"tool_definition",definition:i}})}return{role:"system",content:e}},e})();let oi="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.";function or(e){if("compaction"in e&&null!=e.compaction)throw new ry.v("`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 os(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 on(e){if(e.context_management?.edits?.some(e=>e.type.startsWith("compact_")))throw new ry.v("`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 oa(e){return"run"in e?{...Object.fromEntries(Object.entries("toJSON"in e&&"function"==typeof e.toJSON?e.toJSON():e).filter(([e])=>oy.includes(e))),...ns(e)&&{[nr]:e[nr]}}:e}function oo(e){let{tools:t}=e._state.params;return t?{tools:t.map(oa)}:{}}function ol(e){return e.map(e=>{if("system"!==e.role||!Array.isArray(e.content))return e;let t=e.content.map(e=>"tool_addition"===e.type&&"tool_definition"===e.tool.type?{...e,tool:{...e.tool,definition:oa(e.tool.definition)}}:e);return{...e,content:t}})}function oc(e){return"system"===e.role&&Array.isArray(e.content)&&e.content.some(e=>"tool_addition"===e.type&&"tool_definition"===e.tool.type&&"run"in e.tool.definition)}async function ou(e,t,i,r,s,n,a,o){if(!r||"assistant"!==r.role||!r.content||"string"==typeof r.content)return null;let l=r.content.filter(e=>"tool_use"===e.type);if(0===l.length)return null;let c=new Map;return{role:"user",content:await Promise.all(l.map(async r=>{let l=n?.get(r.id),u=l?.status==="started"?l.result:void 0;if(r.toolset_name){let t=r.toolset_name,i=c.get(t)??{tail:Promise.resolve(),failed:!1};c.set(t,i);let l=e.tools.some(e=>aC(e)&&aL(e)===t),h=u??i.tail.then(()=>i.failed?aF(r,Object.prototype.hasOwnProperty.call(aU,t)?aU[t]:aW,!0):oh(e,t,r,s,a,o));return i.tail=h.then(({is_error:e})=>{e&&l&&(i.failed=!0)},()=>{i.failed=!0}),n?.set(r.id,{status:"started",result:h}),h}if(u)return u;if(!(i.has(r.name)?t.get(r.name):void 0)&&e.tools.some(e=>aC(e)&&aL(e)===r.name)){var h;let e=c.get(r.name)??{tail:Promise.resolve(),failed:!1};return c.set(r.name,e),e.tail=e.tail.then(()=>{e.failed=!0}),{type:"tool_result",tool_use_id:(h=r).id,content:`Error: the '${ao(h.name)}' toolset could not run this call${function(e){let t="object"==typeof e&&null!==e?e:{};if(!("actions"in t)){let e="action"in t?t.action:void 0;return"string"==typeof e?`: the call has no 'actions' list (action: '${ao(e)}')`:": the call has no 'actions' list"}let{actions:i}=t;if("string"==typeof i)return": 'actions' is text, not a list of actions";if(!Array.isArray(i))return": 'actions' is not a list of actions";if(0===i.length)return": the 'actions' list is empty";let r=[];for(let[e,t]of i.entries()){let i="object"==typeof t&&null!==t&&"action"in t?t.action:void 0;if("string"!=typeof i)return`: action ${e} must be an object with a string 'action' field`;r.push(`'${ao(i)}'`)}let s=r.length>10?`, and ${r.length-10} more`:"";return`: its actions could not be run as sent (actions: ${r.slice(0,10).join(", ")}${s})`}(h.input)}; nothing in the batch was executed`,is_error:!0}}let d=od(t,i,r,s,a,o);return n?.set(r.id,{status:"started",result:d}),d}))}}async function oh(e,t,i,r,s,n){let a=e.tools.find(e=>aC(e)&&aL(e)===t);if(!a)return aF(i,`Error: Toolset '${ao(t)}' member '${ao(i.name)}' not found`,!0);let o={signal:r?.signal,conversationId:r?.openTelemetry?.conversationId,parentContext:n};return(await ad(s,a,i,o,async()=>{let e=await aH(a,i,{signal:r?.signal});return{block:e,content:e.content??[],isError:!0===e.is_error}})).block}async function od(e,t,i,r,s,n){let a=t.has(i.name)?e.get(i.name):void 0;if(!a){var o;return{type:"tool_result",tool_use_id:(o=i).id,content:`Error: Tool '${o.name}' not found`,is_error:!0}}let l={signal:r?.signal,conversationId:r?.openTelemetry?.conversationId,parentContext:n},c=await ad(s,a,i,l,()=>ah(a,i.input,{toolUse:i,toolUseBlock:i,signal:r?.signal}));return{type:"tool_result",tool_use_id:i.id,content:c.content,...c.isError?{is_error:!0}:void 0}}function op(e){return Array.isArray(e?.content)&&e.content.some(e=>"tool_use"===e.type)}function o_(e,t){switch(e.type){case"tool_removal":case"tool_addition":var i,r;let s;i=e,r=t,void 0!==(s=function(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}}(i.tool))&&("tool_removal"===i.type?r.delete(s):r.add(s))}}function of(e){if(null===e)return"stop";if(aY(e))return"resume";switch(e){case"tool_use":return"run_tools";case"end_turn":case"stop_sequence":case"max_tokens":case"model_context_window_exceeded":case"refusal":return"stop";default:return(0,ip.f)(e),"stop"}}class og{constructor(e,t,i){if(!e._supportsMessageThreads)throw new ry.v("Message threads are not available on this client; use `client.beta.messages.create()` with the full `messages` instead");aT(t),this._client=e,this._state=new aG({params:t,options:i??{},threading:!0,logger:(0,rz.u)(e)})}static _fromState(e,t){return Object.assign(Object.create(og.prototype),{_client:e,_state:t})}get messages(){return this._state.messages}get previousMessageId(){return this._state.previousMessageId}get params(){return{...this._state.params,unsupportedRequestBehavior:this._state.unsupportedRequestBehavior}}append(...e){this._state.push(e)}send(e,t={},i={}){return this._send(e,t,i,e=>e)}parse(e,t={},i={}){return this._send(e,t,i,e=>a$(e,this._state.params,{logger:(0,rz.u)(this._client)}))}_send(e,t,i,r){let s=this._state.startTurn(a9(e),t),n=(async()=>{try{let{request:e,props:t}=await this._createWithRecovery(s,i,{stream:!1}),r=await e;return this._state.recordReply(s,r),{props:t,reply:r}}finally{this._state.endTurn(s)}})();return new s0(this._client,n.then(({props:e})=>e),async()=>{let{props:e,reply:t}=await n;return sj(r(t),e.response)})}stream(e,t={},i={}){let r=new aO(this._state.params,{logger:(0,rz.u)(this._client),client:this._client});return this._stream(r,e,t,i),r}_stream(e,t,i,r){let s,n=this._state.startTurn(a9(t),i),a=0,o=!1;e.on("streamEvent",(e,t)=>{o||(s=t,"content_block_stop"===e.type&&(a+=1),"message_stop"===e.type&&(o=!0,this._state.recordReply(n,t),this._state.endTurn(n)))});let l=()=>{o||(o=!0,s&&this._state.recordPartialReply(s,a),this._state.endTurn(n))};e.controller.signal.addEventListener("abort",l,{once:!0});let c=(e,t)=>new s0(this._client,this._createWithRecovery(n,{...r,signal:t?.signal},{stream:!0}).then(({props:e})=>e));e._start(c,this._state.params,{signal:r.signal??this._state.options.signal},l)}update(e={},t={}){this._state.update(e,t)}toolRunner(e={},t={}){return a6(e),new ot(this,e,t)}fork(){return og._fromState(this._client,this._state.fork())}async _createWithRecovery(e,t,{stream:i}){for(;;){let{params:r,options:s}=this._state.buildCreateArguments(e,t,{stream:i}),n=this._client.beta.messages.create({...r,stream:i},s);try{return{request:n,props:await n._responseProps()}}catch(e){if(!this._state.recoversFrom(e))throw e}}}}let om={"claude-sonnet-4-5":"November 30th, 2026","claude-sonnet-4-5-20250929":"November 30th, 2026"},ov=["claude-mythos-preview","claude-opus-4-6"];var ob=(()=>{class e extends ne{constructor(){super(...arguments),this.batches=new aA(this._client)}create(e,t){let i=aP(e),{betas:r,user_profile_id:s,workspace_id:n,...a}=i;a.model in om&&console.warn(`The model '${a.model}' is deprecated and will reach end-of-life on ${om[a.model]}
|
|
6
|
-
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),ov.includes(a.model)&&a.thinking&&"enabled"===a.thinking.type&&console.warn(`Using Claude with ${a.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 o=t?.timeout??this._client._options.timeout;if(!a.stream&&null==o){let e=nw[a.model]??void 0;o=this._client.calculateNonstreamingTimeout(a.max_tokens,e)}let l=aR(i,t),c=this._client._tracer&&rC(this._client,"anthropic.messages.create",t,sz(this._client,a,l));sS(this._client,c,a);let u=this._client.post("/v1/messages",{body:a,timeout:o??6e5,...t,__qualifiers:{beta:"true"},__span:c,headers:l,stream:i.stream??!1});return c?u._thenUnwrap(e=>(sx(this._client,c,a,e),e)):u}parse(e,t){return t={...t,headers:rR([{"anthropic-beta":[...e.betas??[],"structured-outputs-2025-12-15"].toString()},t?.headers])},this.create(e,t).then(t=>a$(t,e,{logger:this._client.logger??console}))}stream(e,t){return aO.createMessage(this,e,t,{client:this._client})}countTokens(e,t){let{betas:i,user_profile_id:r,workspace_id:s,...n}=aP(e),a=rR([{"anthropic-beta":[...i??[],"token-counting-2024-11-01"].toString(),...null!=r?{"anthropic-user-profile-id":r}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},t?.headers]),o=rC(this._client,"anthropic.messages.count_tokens",t,{route:"/v1/messages/count_tokens",attributes:{[so]:n.model}}),l=this._client.post("/v1/messages/count_tokens",{body:n,...t,__qualifiers:{beta:"true"},__span:o,headers:a});return o?l._thenUnwrap(e=>(sV(this._client,o,e),e)):l}toolRunner(e,t){return new ot(this._client,e,t)}_toolRunnerThread(e){aT(e);let{settings:t,thread:i,threadParams:r}=a7(e),s=new aG({params:{...r,unsupportedRequestBehavior:"continue_unthreaded"},options:{},threading:!1!==i&&this._client._supportsMessageThreads,logger:(0,rz.u)(this._client)});return{thread:og._fromState(this._client,s),settings:t}}thread(e,t){return new og(this._client,e,t)}}return e.Batches=aA,e.BetaToolRunner=ot,e.ToolError=ar.f,e})();let oy=["input_schema","name","allowed_callers","cache_control","defer_loading","description","eager_input_streaming","input_examples","strict","type","configs","display_height_px","display_width_px","display_number","enable_zoom","max_characters"];class ow extends ne{retrieve(e,t){return this._client.get(nb`/v1/organizations/api_keys/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.api_keys.retrieve",t,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/api_keys/${e}`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.api_keys.update",i,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/api_keys",s6,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.api_keys.list",t,{route:"/v1/organizations/api_keys",queryParams:["after_id","before_id","created_by_user_id","limit","status","workspace_id"]})})}}class ok extends ne{retrieve(e){return this._client.get("/v1/organizations/compliance_settings",{...e,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.compliance_settings.retrieve",e,{route:"/v1/organizations/compliance_settings"})})}update(e,t){return this._client.post("/v1/organizations/compliance_settings",{body:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.compliance_settings.update",t,{route:"/v1/organizations/compliance_settings"})})}}class oz extends ne{create(e,t){return this._client.post("/v1/organizations/external_keys",{body:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.external_keys.create",t,{route:"/v1/organizations/external_keys",createdIDAttribute:"anthropic.organization.external_key.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/external_keys/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.external_keys.retrieve",t,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/external_keys/${e}`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.external_keys.update",i,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/external_keys",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.external_keys.list",t,{route:"/v1/organizations/external_keys",queryParams:["limit","page"]})})}delete(e,t){return this._client.delete(nb`/v1/organizations/external_keys/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.external_keys.delete",t,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}validate(e,t){return this._client.post(nb`/v1/organizations/external_keys/${e}/validate`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.external_keys.validate",t,{route:"/v1/organizations/external_keys/{external_key_id}/validate",attributes:{"anthropic.organization.external_key.id":e}})})}}class oS extends ne{create(e,t){return this._client.post("/v1/organizations/invites",{body:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.invites.create",t,{route:"/v1/organizations/invites",createdIDAttribute:"anthropic.organization.invite.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/invites/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.invites.retrieve",t,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/invites",s6,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.invites.list",t,{route:"/v1/organizations/invites",queryParams:["after_id","before_id","email","limit","roles","statuses"]})})}delete(e,t){return this._client.delete(nb`/v1/organizations/invites/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.invites.delete",t,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":e}})})}}class ox extends ne{retrieve(e,t={},i){let{betas:r,...s}=t??{};return this._client.get(nb`/v1/organizations/plugin_marketplaces/${e}`,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugin_marketplaces.retrieve",i,{route:"/v1/organizations/plugin_marketplaces/{marketplace_id}",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin_marketplace.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/plugin_marketplaces/${e}`,{body:s,...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugin_marketplaces.update",i,{route:"/v1/organizations/plugin_marketplaces/{marketplace_id}",attributes:{"anthropic.organization.plugin_marketplace.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/plugin_marketplaces",s4,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugin_marketplaces.list",t,{route:"/v1/organizations/plugin_marketplaces",queryParams:["limit","organization_id","owner_type","page","source"]})})}validateArchive(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/plugin_marketplaces/validate_archive",sG({body:r,...t,headers:rR([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugin_marketplaces.validate_archive",t,{route:"/v1/organizations/plugin_marketplaces/validate_archive"})},this._client))}validateRepository(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/plugin_marketplaces/validate_repository",{body:r,...t,headers:rR([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugin_marketplaces.validate_repository",t,{route:"/v1/organizations/plugin_marketplaces/validate_repository"})})}}class oV extends ne{list(e={},t){return this._client.getAPIList("/v1/organizations/rate_limits",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rate_limits.list",t,{route:"/v1/organizations/rate_limits",queryParams:["group_type","limit","model","page"]})})}}class oA extends ne{retrieve(e,t){return this._client.get(nb`/v1/organizations/users/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.users.retrieve",t,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/users/${e}`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.users.update",i,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/users",s6,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.users.list",t,{route:"/v1/organizations/users",queryParams:["after_id","before_id","email","limit","roles"]})})}remove(e,t){return this._client.delete(nb`/v1/organizations/users/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.users.remove",t,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}}class oI extends ne{create(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/webhooks",{body:r,...t,headers:rR([{"anthropic-beta":[...i??[],"webhooks-2026-10-07"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.webhooks.create",t,{route:"/v1/organizations/webhooks",createdIDAttribute:"anthropic.organization.webhook.id"})})}retrieve(e,t={},i){let{betas:r}=t??{};return this._client.get(nb`/v1/organizations/webhooks/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"webhooks-2026-10-07"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.webhooks.retrieve",i,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}",attributes:{"anthropic.organization.webhook.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/webhooks/${e}`,{body:s,...i,headers:rR([{"anthropic-beta":[...r??[],"webhooks-2026-10-07"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.webhooks.update",i,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}",attributes:{"anthropic.organization.webhook.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/webhooks",s6,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"webhooks-2026-10-07"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.webhooks.list",t,{route:"/v1/organizations/webhooks",queryParams:["after_id","before_id","limit","order"]})})}delete(e,t={},i){let{betas:r}=t??{};return this._client.delete(nb`/v1/organizations/webhooks/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"webhooks-2026-10-07"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.webhooks.delete",i,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}",attributes:{"anthropic.organization.webhook.id":e}})})}regenerateSigningSecret(e,t={},i){let{betas:r}=t??{};return this._client.post(nb`/v1/organizations/webhooks/${e}/regenerate_signing_secret`,{...i,headers:rR([{"anthropic-beta":[...r??[],"webhooks-2026-10-07"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.webhooks.regenerate_signing_secret",i,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}/regenerate_signing_secret",attributes:{"anthropic.organization.webhook.id":e}})})}}class oq extends ne{list(e,t){return this._client.getAPIList("/v1/organizations/analytics/artifacts",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.artifacts.list",t,{route:"/v1/organizations/analytics/artifacts",queryParams:["date","filter","group_by","limit","page"]})})}}class o$ extends ne{list(e={},t){return this._client.getAPIList("/v1/organizations/analytics/connectors",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.connectors.list",t,{route:"/v1/organizations/analytics/connectors",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}}class oR extends ne{list(e,t){let{betas:i,...r}=e;return this._client.getAPIList("/v1/organizations/analytics/cost",s8,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"analytics-usage-cost-2026-08-24"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.cost.list",t,{route:"/v1/organizations/analytics/cost",queryParams:["actor_ids","actor_types","agent_ids","api_key_ids","claude_tag_categories","claude_tag_user_ids","context_windows","deployment_ids","ending_at","environment_ids","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","page","products","rbac_group_ids","service_tiers","session_ids","slack_channel_ids","speeds","starting_at","time_bucket_width","user_profile_ids","workspace_ids"]})})}}class oP extends ne{list(e,t){return this._client.getAPIList("/v1/organizations/analytics/cost_report",s8,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.cost_report.list",t,{route:"/v1/organizations/analytics/cost_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","group_by","inference_geos","limit","models","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}}class oT extends ne{list(e={},t){return this._client.getAPIList("/v1/organizations/analytics/plugins",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.plugins.list",t,{route:"/v1/organizations/analytics/plugins",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}}class oE extends ne{list(e={},t){return this._client.getAPIList("/v1/organizations/analytics/skills",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.skills.list",t,{route:"/v1/organizations/analytics/skills",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}}class oO extends ne{list(e,t){return this._client.getAPIList("/v1/organizations/analytics/summaries",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.summaries.list",t,{route:"/v1/organizations/analytics/summaries",queryParams:["ending_date","filter","limit","page","starting_date"]})})}}class oM extends ne{list(e,t){let{betas:i,...r}=e;return this._client.getAPIList("/v1/organizations/analytics/usage",s8,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"analytics-usage-cost-2026-08-24"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.usage.list",t,{route:"/v1/organizations/analytics/usage",queryParams:["actor_ids","actor_types","agent_ids","api_key_ids","claude_tag_categories","claude_tag_user_ids","context_windows","deployment_ids","ending_at","environment_ids","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","page","products","rbac_group_ids","service_tiers","session_ids","slack_channel_ids","speeds","starting_at","time_bucket_width","user_profile_ids","workspace_ids"]})})}}class oL extends ne{list(e,t){return this._client.getAPIList("/v1/organizations/analytics/usage_report",s8,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.usage_report.list",t,{route:"/v1/organizations/analytics/usage_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","group_by","inference_geos","limit","models","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}}class oC extends ne{list(e,t){return this._client.getAPIList("/v1/organizations/analytics/user_cost_report",s8,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.user_cost_report.list",t,{route:"/v1/organizations/analytics/user_cost_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}}class oN extends ne{list(e,t){return this._client.getAPIList("/v1/organizations/analytics/user_usage_report",s8,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.user_usage_report.list",t,{route:"/v1/organizations/analytics/user_usage_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}}class oj extends ne{list(e={},t){return this._client.getAPIList("/v1/organizations/analytics/users",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.users.list",t,{route:"/v1/organizations/analytics/users",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["page"]})})}}class oD extends ne{list(e={},t){return this._client.getAPIList("/v1/organizations/analytics/apps/chat/projects",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.apps.chat.projects.list",t,{route:"/v1/organizations/analytics/apps/chat/projects",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"]})})}}var oW=(()=>{class e extends ne{constructor(){super(...arguments),this.projects=new oD(this._client)}}return e.Projects=oD,e})(),oU=(()=>{class e extends ne{constructor(){super(...arguments),this.chat=new oW(this._client)}}return e.Chat=oW,e})(),oF=(()=>{class e extends ne{constructor(){super(...arguments),this.summaries=new oO(this._client),this.users=new oj(this._client),this.apps=new oU(this._client),this.connectors=new o$(this._client),this.plugins=new oT(this._client),this.skills=new oE(this._client),this.artifacts=new oq(this._client),this.usage=new oM(this._client),this.cost=new oR(this._client),this.usageReport=new oL(this._client),this.userUsageReport=new oN(this._client),this.costReport=new oP(this._client),this.userCostReport=new oC(this._client)}}return e.Summaries=oO,e.Users=oj,e.Apps=oU,e.Connectors=o$,e.Plugins=oT,e.Skills=oE,e.Artifacts=oq,e.Usage=oM,e.Cost=oR,e.UsageReport=oL,e.UserUsageReport=oN,e.CostReport=oP,e.UserCostReport=oC,e})();class oH extends ne{create(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/claude_tag/slack_channels",{body:r,...t,headers:rR([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.slack_channels.create",t,{route:"/v1/organizations/claude_tag/slack_channels",createdIDAttribute:"anthropic.organization.claude_tag.slack_channel.id"})})}retrieve(e,t={},i){let{betas:r,...s}=t??{};return this._client.get(nb`/v1/organizations/claude_tag/slack_channels/${e}`,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.slack_channels.retrieve",i,{route:"/v1/organizations/claude_tag/slack_channels/{id}",queryParams:["include_inherited"],attributes:{"anthropic.organization.claude_tag.slack_channel.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/claude_tag/slack_channels/${e}`,{body:s,...i,headers:rR([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.slack_channels.update",i,{route:"/v1/organizations/claude_tag/slack_channels/{id}",attributes:{"anthropic.organization.claude_tag.slack_channel.id":e}})})}list(e,t){let{betas:i,...r}=e;return this._client.getAPIList("/v1/organizations/claude_tag/slack_channels",s4,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.slack_channels.list",t,{route:"/v1/organizations/claude_tag/slack_channels",queryParams:["include_inherited","limit","page","slack_channel_id","slack_workspace_id"]})})}delete(e,t={},i){let{betas:r}=t??{};return this._client.delete(nb`/v1/organizations/claude_tag/slack_channels/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.slack_channels.delete",i,{route:"/v1/organizations/claude_tag/slack_channels/{id}",attributes:{"anthropic.organization.claude_tag.slack_channel.id":e}})})}}class oB extends ne{retrieve(e,t={},i){let{betas:r,...s}=t??{};return this._client.get(nb`/v1/organizations/claude_tag/slack_workspaces/${e}`,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.slack_workspaces.retrieve",i,{route:"/v1/organizations/claude_tag/slack_workspaces/{id}",queryParams:["include_inherited"],attributes:{"anthropic.organization.claude_tag.slack_workspace.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/claude_tag/slack_workspaces/${e}`,{body:s,...i,headers:rR([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.slack_workspaces.update",i,{route:"/v1/organizations/claude_tag/slack_workspaces/{id}",attributes:{"anthropic.organization.claude_tag.slack_workspace.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/claude_tag/slack_workspaces",s4,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.slack_workspaces.list",t,{route:"/v1/organizations/claude_tag/slack_workspaces",queryParams:["include_inherited","limit","page","slack_workspace_id"]})})}}class oK extends ne{create(e,t,i){let{target:r,betas:s}=t;return this._client.post(nb`/v1/organizations/claude_tag/bundles/${e}/targets`,{body:r,...i,headers:rR([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.bundles.targets.create",i,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets",attributes:{"anthropic.organization.claude_tag.bundle.id":e}})})}retrieve(e,t,i){let{bundle_id:r,betas:s}=t;return this._client.get(nb`/v1/organizations/claude_tag/bundles/${r}/targets/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.bundles.targets.retrieve",i,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets/{target_id}",attributes:{"anthropic.organization.claude_tag.bundle.id":r,"anthropic.organization.claude_tag.bundle.target.id":e}})})}list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/organizations/claude_tag/bundles/${e}/targets`,s4,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.bundles.targets.list",i,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets",queryParams:["limit","page"],attributes:{"anthropic.organization.claude_tag.bundle.id":e}})})}delete(e,t,i){let{bundle_id:r,betas:s}=t;return this._client.delete(nb`/v1/organizations/claude_tag/bundles/${r}/targets/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.bundles.targets.delete",i,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets/{target_id}",attributes:{"anthropic.organization.claude_tag.bundle.id":r,"anthropic.organization.claude_tag.bundle.target.id":e}})})}}var oJ=(()=>{class e extends ne{constructor(){super(...arguments),this.targets=new oK(this._client)}retrieve(e,t={},i){let{betas:r}=t??{};return this._client.get(nb`/v1/organizations/claude_tag/bundles/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.bundles.retrieve",i,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}",attributes:{"anthropic.organization.claude_tag.bundle.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/claude_tag/bundles",s4,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.bundles.list",t,{route:"/v1/organizations/claude_tag/bundles",queryParams:["limit","page"]})})}}return e.Targets=oK,e})(),oG=(()=>{class e extends ne{constructor(){super(...arguments),this.slackChannels=new oH(this._client),this.slackWorkspaces=new oB(this._client),this.bundles=new oJ(this._client)}}return e.SlackChannels=oH,e.SlackWorkspaces=oB,e.Bundles=oJ,e})();class oX extends ne{create(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/federation_issuers",{body:r,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.issuers.create",t,{route:"/v1/organizations/federation_issuers",createdIDAttribute:"anthropic.organization.federation_issuer.id"})})}retrieve(e,t={},i){let{betas:r}=t??{};return this._client.get(nb`/v1/organizations/federation_issuers/${e}`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.issuers.retrieve",i,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/federation_issuers/${e}`,{body:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.issuers.update",i,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/federation_issuers",s4,{query:r,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.issuers.list",t,{route:"/v1/organizations/federation_issuers",queryParams:["include_archived","limit","page"]})})}archive(e,t={},i){let{betas:r}=t??{};return this._client.post(nb`/v1/organizations/federation_issuers/${e}/archive`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.issuers.archive",i,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}/archive",attributes:{"anthropic.organization.federation_issuer.id":e}})})}}class oY extends ne{list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/organizations/federation_rules/${e}/workspaces`,s4,{query:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.rules.workspaces.list",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.federation_rule.id":e}})})}add(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/federation_rules/${e}/workspaces`,{body:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.rules.workspaces.add",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",attributes:{"anthropic.organization.federation_rule.id":e},createdIDAttribute:"anthropic.organization.federation_rule.workspace.id",createdIDField:"workspace_id"})})}remove(e,t,i){let{federation_rule_id:r,betas:s}=t;return this._client.delete(nb`/v1/organizations/federation_rules/${r}/workspaces/${e}`,{...i,headers:rR([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.rules.workspaces.remove",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.federation_rule.id":r,"anthropic.organization.federation_rule.workspace.id":e}})})}}var oQ=(()=>{class e extends ne{constructor(){super(...arguments),this.workspaces=new oY(this._client)}create(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/federation_rules",{body:r,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.rules.create",t,{route:"/v1/organizations/federation_rules",createdIDAttribute:"anthropic.organization.federation_rule.id"})})}retrieve(e,t={},i){let{betas:r}=t??{};return this._client.get(nb`/v1/organizations/federation_rules/${e}`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.rules.retrieve",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/federation_rules/${e}`,{body:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.rules.update",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/federation_rules",s4,{query:r,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.rules.list",t,{route:"/v1/organizations/federation_rules",queryParams:["include_archived","issuer_id","limit","page"]})})}archive(e,t={},i){let{betas:r}=t??{};return this._client.post(nb`/v1/organizations/federation_rules/${e}/archive`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.rules.archive",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}/archive",attributes:{"anthropic.organization.federation_rule.id":e}})})}}return e.Workspaces=oY,e})(),oZ=(()=>{class e extends ne{constructor(){super(...arguments),this.issuers=new oX(this._client),this.rules=new oQ(this._client)}}return e.Issuers=oX,e.Rules=oQ,e})();class o0 extends ne{list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/organizations/plugins/${e}/installation_settings`,s4,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.installation_settings.list",i,{route:"/v1/organizations/plugins/{plugin_id}/installation_settings",queryParams:["limit","organization_id","page","target_type"],attributes:{"anthropic.organization.plugin.id":e}})})}remove(e,t,i){let{plugin_id:r,betas:s}=t;return this._client.delete(nb`/v1/organizations/plugins/${r}/installation_settings/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.installation_settings.remove",i,{route:"/v1/organizations/plugins/{plugin_id}/installation_settings/{target}",attributes:{"anthropic.organization.plugin.id":r,"anthropic.organization.plugin.installation_setting.id":e}})})}set(e,t,i){let{plugin_id:r,betas:s,...n}=t;return this._client.post(nb`/v1/organizations/plugins/${r}/installation_settings/${e}`,{body:n,...i,headers:rR([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.installation_settings.set",i,{route:"/v1/organizations/plugins/{plugin_id}/installation_settings/{target}",attributes:{"anthropic.organization.plugin.id":r,"anthropic.organization.plugin.installation_setting.id":e}})})}}class o1 extends ne{list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/organizations/plugins/${e}/shares`,s4,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.shares.list",i,{route:"/v1/organizations/plugins/{plugin_id}/shares",queryParams:["limit","organization_id","page","target_type"],attributes:{"anthropic.organization.plugin.id":e}})})}}class o2 extends ne{create(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/plugins/${e}/versions`,sG({body:s,...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.versions.create",i,{route:"/v1/organizations/plugins/{plugin_id}/versions",attributes:{"anthropic.organization.plugin.id":e},createdIDAttribute:"anthropic.organization.plugin.version.id"})},this._client))}retrieve(e,t,i){let{plugin_id:r,betas:s,...n}=t;return this._client.get(nb`/v1/organizations/plugins/${r}/versions/${e}`,{query:n,...i,headers:rR([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.versions.retrieve",i,{route:"/v1/organizations/plugins/{plugin_id}/versions/{version}",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin.id":r,"anthropic.organization.plugin.version.id":e}})})}list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/organizations/plugins/${e}/versions`,s4,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.versions.list",i,{route:"/v1/organizations/plugins/{plugin_id}/versions",queryParams:["limit","organization_id","page"],attributes:{"anthropic.organization.plugin.id":e}})})}download(e,t,i){let{plugin_id:r,betas:s,...n}=t;return this._client.get(nb`/v1/organizations/plugins/${r}/versions/${e}/content`,{query:n,...i,headers:rR([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString(),Accept:"application/binary"},i?.headers]),__qualifiers:{beta:"true"},__binaryResponse:!0,__span:rC(this._client,"anthropic.organization.plugins.versions.download",i,{route:"/v1/organizations/plugins/{plugin_id}/versions/{version}/content",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin.id":r,"anthropic.organization.plugin.version.id":e}})})}}var o6=(()=>{class e extends ne{constructor(){super(...arguments),this.versions=new o2(this._client),this.installationSettings=new o0(this._client),this.shares=new o1(this._client)}create(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/plugins",sG({body:r,...t,headers:rR([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.create",t,{route:"/v1/organizations/plugins",createdIDAttribute:"anthropic.organization.plugin.id"})},this._client))}retrieve(e,t={},i){let{betas:r,...s}=t??{};return this._client.get(nb`/v1/organizations/plugins/${e}`,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.retrieve",i,{route:"/v1/organizations/plugins/{plugin_id}",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/plugins/${e}`,{body:s,...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.update",i,{route:"/v1/organizations/plugins/{plugin_id}",attributes:{"anthropic.organization.plugin.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/plugins",s4,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.list",t,{route:"/v1/organizations/plugins",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","limit","marketplace_id","organization_id","owner_type","owner_user_id","page"]})})}delete(e,t={},i){let{betas:r}=t??{};return this._client.delete(nb`/v1/organizations/plugins/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.delete",i,{route:"/v1/organizations/plugins/{plugin_id}",attributes:{"anthropic.organization.plugin.id":e}})})}}return e.Versions=o2,e.InstallationSettings=o0,e.Shares=o1,e})();class o4 extends ne{list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/rbac_groups/${e}/members`,s4,{query:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_groups.members.list",i,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_group.id":e}})})}add(e,t,i){return this._client.post(nb`/v1/organizations/rbac_groups/${e}/members`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_groups.members.add",i,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",attributes:{"anthropic.organization.rbac_group.id":e},createdIDAttribute:"anthropic.organization.rbac_group.member.id",createdIDField:"user_id"})})}remove(e,t,i){let{rbac_group_id:r}=t;return this._client.delete(nb`/v1/organizations/rbac_groups/${r}/members/${e}`,{...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_groups.members.remove",i,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members/{user_id}",attributes:{"anthropic.organization.rbac_group.id":r,"anthropic.organization.rbac_group.member.id":e}})})}}var o5=(()=>{class e extends ne{constructor(){super(...arguments),this.members=new o4(this._client)}create(e,t){return this._client.post("/v1/organizations/rbac_groups",{body:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_groups.create",t,{route:"/v1/organizations/rbac_groups",createdIDAttribute:"anthropic.organization.rbac_group.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/rbac_groups/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_groups.retrieve",t,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/rbac_groups/${e}`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_groups.update",i,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/rbac_groups",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_groups.list",t,{route:"/v1/organizations/rbac_groups",queryParams:["limit","page"]})})}delete(e,t){return this._client.delete(nb`/v1/organizations/rbac_groups/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_groups.delete",t,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}}return e.Members=o4,e})();class o8 extends ne{list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/rbac_roles/${e}/permissions`,s4,{query:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_roles.permissions.list",i,{route:"/v1/organizations/rbac_roles/{rbac_role_id}/permissions",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_role.id":e}})})}}var o3=(()=>{class e extends ne{constructor(){super(...arguments),this.permissions=new o8(this._client)}retrieve(e,t){return this._client.get(nb`/v1/organizations/rbac_roles/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_roles.retrieve",t,{route:"/v1/organizations/rbac_roles/{rbac_role_id}",attributes:{"anthropic.organization.rbac_role.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/rbac_roles",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_roles.list",t,{route:"/v1/organizations/rbac_roles",queryParams:["limit","page"]})})}}return e.Permissions=o8,e})();class o9 extends ne{list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/organizations/service_accounts/${e}/workspaces`,s4,{query:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.service_accounts.workspaces.list",i,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.service_account.id":e}})})}add(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/service_accounts/${e}/workspaces`,{body:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.service_accounts.workspaces.add",i,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",attributes:{"anthropic.organization.service_account.id":e},createdIDAttribute:"anthropic.organization.service_account.workspace.id",createdIDField:"workspace_id"})})}remove(e,t,i){let{service_account_id:r,betas:s}=t;return this._client.delete(nb`/v1/organizations/service_accounts/${r}/workspaces/${e}`,{...i,headers:rR([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.service_accounts.workspaces.remove",i,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.service_account.id":r,"anthropic.organization.service_account.workspace.id":e}})})}}var o7=(()=>{class e extends ne{constructor(){super(...arguments),this.workspaces=new o9(this._client)}create(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/service_accounts",{body:r,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.service_accounts.create",t,{route:"/v1/organizations/service_accounts",createdIDAttribute:"anthropic.organization.service_account.id"})})}retrieve(e,t={},i){let{betas:r}=t??{};return this._client.get(nb`/v1/organizations/service_accounts/${e}`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.service_accounts.retrieve",i,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/service_accounts/${e}`,{body:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.service_accounts.update",i,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/service_accounts",s4,{query:r,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.service_accounts.list",t,{route:"/v1/organizations/service_accounts",queryParams:["include_archived","limit","page"]})})}archive(e,t={},i){let{betas:r}=t??{};return this._client.post(nb`/v1/organizations/service_accounts/${e}/archive`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.service_accounts.archive",i,{route:"/v1/organizations/service_accounts/{service_account_id}/archive",attributes:{"anthropic.organization.service_account.id":e}})})}}return e.Workspaces=o9,e})();class le extends ne{list(e={},t){return this._client.getAPIList("/v1/organizations/spend_limits/effective",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.effective.list",t,{route:"/v1/organizations/spend_limits/effective",queryParams:["limit","page","period","user_ids"]})})}}class lt extends ne{retrieve(e,t){return this._client.get(nb`/v1/organizations/spend_limit_increase_requests/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.increase_requests.retrieve",t,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}",attributes:{"anthropic.organization.spend_limit_increase_request.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/spend_limit_increase_requests",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.increase_requests.list",t,{route:"/v1/organizations/spend_limit_increase_requests",queryParams:["actor_ids","limit","page","status"]})})}approve(e,t,i){return this._client.post(nb`/v1/organizations/spend_limit_increase_requests/${e}/approve`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.increase_requests.approve",i,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/approve",attributes:{"anthropic.organization.spend_limit_increase_request.id":e}})})}deny(e,t,i){return this._client.post(nb`/v1/organizations/spend_limit_increase_requests/${e}/deny`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.increase_requests.deny",i,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/deny",attributes:{"anthropic.organization.spend_limit_increase_request.id":e}})})}}var li=(()=>{class e extends ne{constructor(){super(...arguments),this.effective=new le(this._client),this.increaseRequests=new lt(this._client)}retrieve(e,t){return this._client.get(nb`/v1/organizations/spend_limits/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.retrieve",t,{route:"/v1/organizations/spend_limits/{spend_limit_id}",attributes:{"anthropic.organization.spend_limit.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/spend_limits",s4,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"spend-limit-reads-2026-09-26"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.list",t,{route:"/v1/organizations/spend_limits",queryParams:["limit","page","scope_type","workspace_id"]})})}delete(e,t){return this._client.delete(nb`/v1/organizations/spend_limits/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.delete",t,{route:"/v1/organizations/spend_limits/{spend_limit_id}",attributes:{"anthropic.organization.spend_limit.id":e}})})}set(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/spend_limits",{body:r,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.set",t,{route:"/v1/organizations/spend_limits",createdIDAttribute:"anthropic.organization.spend_limit.id"})})}}return e.Effective=le,e.IncreaseRequests=lt,e})();class lr extends ne{list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/organizations/telemetry_destinations/${e}/workspaces`,s4,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.workspaces.list",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.telemetry_destination.id":e}})})}add(e,t,i){let{destination_id:r,betas:s}=t;return this._client.post(nb`/v1/organizations/telemetry_destinations/${r}/workspaces/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.workspaces.add",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.telemetry_destination.id":r,"anthropic.organization.telemetry_destination.workspace.id":e}})})}remove(e,t,i){let{destination_id:r,betas:s}=t;return this._client.delete(nb`/v1/organizations/telemetry_destinations/${r}/workspaces/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.workspaces.remove",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.telemetry_destination.id":r,"anthropic.organization.telemetry_destination.workspace.id":e}})})}}var ls=(()=>{class e extends ne{constructor(){super(...arguments),this.workspaces=new lr(this._client)}create(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/telemetry_destinations",{body:r,...t,headers:rR([{"anthropic-beta":[...i??[],"telemetry-destinations-2026-08-11"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.create",t,{route:"/v1/organizations/telemetry_destinations",createdIDAttribute:"anthropic.organization.telemetry_destination.id"})})}retrieve(e,t={},i){let{betas:r}=t??{};return this._client.get(nb`/v1/organizations/telemetry_destinations/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.retrieve",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}",attributes:{"anthropic.organization.telemetry_destination.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/telemetry_destinations/${e}`,{body:s,...i,headers:rR([{"anthropic-beta":[...r??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.update",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}",attributes:{"anthropic.organization.telemetry_destination.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/telemetry_destinations",s4,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"telemetry-destinations-2026-08-11"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.list",t,{route:"/v1/organizations/telemetry_destinations",queryParams:["limit","page","workspace_ids"]})})}delete(e,t={},i){let{betas:r}=t??{};return this._client.delete(nb`/v1/organizations/telemetry_destinations/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.delete",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}",attributes:{"anthropic.organization.telemetry_destination.id":e}})})}test(e,t={},i){let{betas:r}=t??{};return this._client.post(nb`/v1/organizations/telemetry_destinations/${e}/test`,{...i,headers:rR([{"anthropic-beta":[...r??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.test",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}/test",attributes:{"anthropic.organization.telemetry_destination.id":e}})})}}return e.Workspaces=lr,e})();class ln extends ne{retrieve(e,t,i){let{workspace_id:r}=t;return this._client.get(nb`/v1/organizations/workspaces/${r}/members/${e}`,{...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.members.retrieve",i,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.member.id":e}})})}update(e,t,i){let{workspace_id:r,...s}=t;return this._client.post(nb`/v1/organizations/workspaces/${r}/members/${e}`,{body:s,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.members.update",i,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.member.id":e}})})}list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/workspaces/${e}/members`,s6,{query:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.members.list",i,{route:"/v1/organizations/workspaces/{workspace_id}/members",queryParams:["after_id","before_id","limit"],attributes:{"anthropic.organization.workspace.id":e}})})}add(e,t,i){return this._client.post(nb`/v1/organizations/workspaces/${e}/members`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.members.add",i,{route:"/v1/organizations/workspaces/{workspace_id}/members",attributes:{"anthropic.organization.workspace.id":e},createdIDAttribute:"anthropic.organization.workspace.member.id",createdIDField:"user_id"})})}remove(e,t,i){let{workspace_id:r}=t;return this._client.delete(nb`/v1/organizations/workspaces/${r}/members/${e}`,{...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.members.remove",i,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.member.id":e}})})}}class la extends ne{update(e,t,i){let{workspace_id:r,...s}=t;return this._client.post(nb`/v1/organizations/workspaces/${r}/rate_limits/${e}`,{body:s,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.rate_limits.update",i,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits/{rate_limit_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.rate_limit.id":e}})})}list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/workspaces/${e}/rate_limits`,s4,{query:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.rate_limits.list",i,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits",queryParams:["group_type","include_inherited","limit","page"],attributes:{"anthropic.organization.workspace.id":e}})})}}class lo extends ne{retrieve(e,t,i){let{workspace_id:r,betas:s}=t;return this._client.get(nb`/v1/organizations/workspaces/${r}/service_accounts/${e}`,{...i,headers:rR([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.retrieve",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.service_account.id":e}})})}update(e,t,i){let{workspace_id:r,betas:s,...n}=t;return this._client.post(nb`/v1/organizations/workspaces/${r}/service_accounts/${e}`,{body:n,...i,headers:rR([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.update",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.service_account.id":e}})})}list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/organizations/workspaces/${e}/service_accounts`,s4,{query:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.list",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",queryParams:["limit","page"],attributes:{"anthropic.organization.workspace.id":e}})})}add(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/workspaces/${e}/service_accounts`,{body:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.add",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",attributes:{"anthropic.organization.workspace.id":e},createdIDAttribute:"anthropic.organization.workspace.service_account.id",createdIDField:"service_account_id"})})}remove(e,t,i){let{workspace_id:r,betas:s}=t;return this._client.delete(nb`/v1/organizations/workspaces/${r}/service_accounts/${e}`,{...i,headers:rR([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.remove",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.service_account.id":e}})})}}var ll=(()=>{class e extends ne{constructor(){super(...arguments),this.rateLimits=new la(this._client),this.members=new ln(this._client),this.serviceAccounts=new lo(this._client)}create(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/workspaces",{body:r,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.create",t,{route:"/v1/organizations/workspaces",createdIDAttribute:"anthropic.organization.workspace.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/workspaces/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.retrieve",t,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/workspaces/${e}`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.update",i,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/workspaces",s6,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.list",t,{route:"/v1/organizations/workspaces",queryParams:["after_id","before_id","include_archived","include_default","limit"]})})}archive(e,t){return this._client.post(nb`/v1/organizations/workspaces/${e}/archive`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.archive",t,{route:"/v1/organizations/workspaces/{workspace_id}/archive",attributes:{"anthropic.organization.workspace.id":e}})})}}return e.RateLimits=la,e.Members=ln,e.ServiceAccounts=lo,e})(),lc=(()=>{class e extends ne{constructor(){super(...arguments),this.apiKeys=new ow(this._client),this.externalKeys=new oz(this._client),this.federation=new oZ(this._client),this.invites=new oS(this._client),this.serviceAccounts=new o7(this._client),this.users=new oA(this._client),this.workspaces=new ll(this._client),this.rateLimits=new oV(this._client),this.complianceSettings=new ok(this._client),this.analytics=new oF(this._client),this.spendLimits=new li(this._client),this.rbacGroups=new o5(this._client),this.rbacRoles=new o3(this._client),this.plugins=new o6(this._client),this.pluginMarketplaces=new ox(this._client),this.telemetryDestinations=new ls(this._client),this.webhooks=new oI(this._client),this.claudeTag=new oG(this._client)}retrieve(e){return this._client.get("/v1/organizations/me",{...e,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.retrieve",e,{route:"/v1/organizations/me"})})}}return e.APIKeys=ow,e.ExternalKeys=oz,e.Federation=oZ,e.Invites=oS,e.ServiceAccounts=o7,e.Users=oA,e.Workspaces=ll,e.RateLimits=oV,e.ComplianceSettings=ok,e.Analytics=oF,e.SpendLimits=li,e.RBACGroups=o5,e.RBACRoles=o3,e.Plugins=o6,e.PluginMarketplaces=ox,e.TelemetryDestinations=ls,e.Webhooks=oI,e.ClaudeTag=oG,e})(),lu=(()=>{class e extends ne{list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/sessions/${e}/events`,s4,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.events.list",i,{route:"/v1/sessions/{session_id}/events",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","limit","order","page","types"],attributes:{"anthropic.session.id":e}})})}send(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/sessions/${e}/events`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.events.send",i,{route:"/v1/sessions/{session_id}/events",attributes:{"anthropic.session.id":e}})})}stream(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.get(nb`/v1/sessions/${e}/events/stream`,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),stream:!0,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.events.stream",i,{route:"/v1/sessions/{session_id}/events/stream",queryParams:["event_deltas"],attributes:{"anthropic.session.id":e}})})}toolRunner(e,t){return new af(e,{...t,client:this._client})}}return e.SessionToolRunner=af,e})();class lh extends ne{retrieve(e,t,i){let{session_id:r,betas:s,workspace_id:n}=t;return this._client.get(nb`/v1/sessions/${r}/resources/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.resources.retrieve",i,{route:"/v1/sessions/{session_id}/resources/{resource_id}",attributes:{"anthropic.session.id":r,"anthropic.session.resource.id":e}})})}update(e,t,i){let{session_id:r,betas:s,workspace_id:n,...a}=t;return this._client.post(nb`/v1/sessions/${r}/resources/${e}`,{body:a,...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.resources.update",i,{route:"/v1/sessions/{session_id}/resources/{resource_id}",attributes:{"anthropic.session.id":r,"anthropic.session.resource.id":e}})})}list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/sessions/${e}/resources`,s4,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.resources.list",i,{route:"/v1/sessions/{session_id}/resources",queryParams:["limit","page"],attributes:{"anthropic.session.id":e}})})}delete(e,t,i){let{session_id:r,betas:s,workspace_id:n}=t;return this._client.delete(nb`/v1/sessions/${r}/resources/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.resources.delete",i,{route:"/v1/sessions/{session_id}/resources/{resource_id}",attributes:{"anthropic.session.id":r,"anthropic.session.resource.id":e}})})}add(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/sessions/${e}/resources`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.resources.add",i,{route:"/v1/sessions/{session_id}/resources",attributes:{"anthropic.session.id":e},createdIDAttribute:"anthropic.session.resource.id"})})}}class ld extends ne{list(e,t,i){let{session_id:r,betas:s,workspace_id:n,...a}=t;return this._client.getAPIList(nb`/v1/sessions/${r}/threads/${e}/events`,s4,{query:a,...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.threads.events.list",i,{route:"/v1/sessions/{session_id}/threads/{thread_id}/events",queryParams:["limit","page"],attributes:{"anthropic.session.id":r,"anthropic.session.thread.id":e}})})}stream(e,t,i){let{session_id:r,betas:s,workspace_id:n,...a}=t;return this._client.get(nb`/v1/sessions/${r}/threads/${e}/stream`,{query:a,...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),stream:!0,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.threads.events.stream",i,{route:"/v1/sessions/{session_id}/threads/{thread_id}/stream",queryParams:["event_deltas"],attributes:{"anthropic.session.id":r,"anthropic.session.thread.id":e}})})}}var lp=(()=>{class e extends ne{constructor(){super(...arguments),this.events=new ld(this._client)}retrieve(e,t,i){let{session_id:r,betas:s,workspace_id:n}=t;return this._client.get(nb`/v1/sessions/${r}/threads/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.threads.retrieve",i,{route:"/v1/sessions/{session_id}/threads/{thread_id}",attributes:{"anthropic.session.id":r,"anthropic.session.thread.id":e}})})}list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/sessions/${e}/threads`,s4,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.threads.list",i,{route:"/v1/sessions/{session_id}/threads",queryParams:["limit","page","statuses"],attributes:{"anthropic.session.id":e}})})}archive(e,t,i){let{session_id:r,betas:s,workspace_id:n}=t;return this._client.post(nb`/v1/sessions/${r}/threads/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.threads.archive",i,{route:"/v1/sessions/{session_id}/threads/{thread_id}/archive",attributes:{"anthropic.session.id":r,"anthropic.session.thread.id":e}})})}}return e.Events=ld,e})(),l_=(()=>{class e extends ne{constructor(){super(...arguments),this.events=new lu(this._client),this.resources=new lh(this._client),this.threads=new lp(this._client)}create(e,t){let{betas:i,workspace_id:r,...s}=e,n=rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),a=rC(this._client,"anthropic.sessions.create",t,{route:"/v1/sessions",attributes:{"gen_ai.agent.id":"object"==typeof s.agent?s.agent?.id:s.agent,"anthropic.session.environment.id":s.environment_id},createdIDAttribute:"anthropic.session.id"}),o=this._client.post("/v1/sessions",{body:s,...t,headers:n,__qualifiers:{beta:"true"},__span:a});return a?o._thenUnwrap(e=>{var t=this._client;try{a?.span.setAttributes({"gen_ai.agent.name":e.agent.name,[so]:e.agent.model.id})}catch(e){(0,rz.u)(t).debug("could not record the response on its span",e)}return e}):o}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/sessions/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.retrieve",i,{route:"/v1/sessions/{session_id}",attributes:{"anthropic.session.id":e}})})}update(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/sessions/${e}`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.update",i,{route:"/v1/sessions/{session_id}",attributes:{"anthropic.session.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/sessions",s5,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.list",t,{route:"/v1/sessions",queryParams:["agent_id","agent_version","created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","deployment_id","include_archived","limit","memory_store_id","order","page","statuses"]})})}delete(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.delete(nb`/v1/sessions/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.delete",i,{route:"/v1/sessions/{session_id}",attributes:{"anthropic.session.id":e}})})}archive(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/sessions/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.archive",i,{route:"/v1/sessions/{session_id}/archive",attributes:{"anthropic.session.id":e}})})}}return e.Events=lu,e.Resources=lh,e.Threads=lp,e})();class lf extends ne{create(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/skills/${e}/versions`,sG({body:n,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.skills.versions.create",i,{route:"/v1/skills/{skill_id}/versions",attributes:{"anthropic.skill.id":e},createdIDAttribute:"anthropic.skill.version.id"})},this._client,!1))}retrieve(e,t,i){let{skill_id:r,betas:s,workspace_id:n}=t;return this._client.get(nb`/v1/skills/${r}/versions/${e}`,{...i,headers:rR([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.skills.versions.retrieve",i,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":r,"anthropic.skill.version.id":e}})})}list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/skills/${e}/versions`,s4,{query:n,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.skills.versions.list",i,{route:"/v1/skills/{skill_id}/versions",queryParams:["limit","page"],attributes:{"anthropic.skill.id":e}})})}delete(e,t,i){let{skill_id:r,betas:s,workspace_id:n}=t;return this._client.delete(nb`/v1/skills/${r}/versions/${e}`,{...i,headers:rR([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.skills.versions.delete",i,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":r,"anthropic.skill.version.id":e}})})}download(e,t,i){let{skill_id:r,betas:s,workspace_id:n}=t;return this._client.get(nb`/v1/skills/${r}/versions/${e}/content`,{...i,headers:rR([{Accept:"application/binary",...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__binaryResponse:!0,__span:rC(this._client,"anthropic.skills.versions.download",i,{route:"/v1/skills/{skill_id}/versions/{version}/content",attributes:{"anthropic.skill.id":r,"anthropic.skill.version.id":e}})})}}var lg=(()=>{class e extends ne{constructor(){super(...arguments),this.versions=new lf(this._client)}create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/skills",sG({body:s,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.skills.create",t,{route:"/v1/skills",createdIDAttribute:"anthropic.skill.id"})},this._client,!1))}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/skills/${e}`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.skills.retrieve",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/skills",s4,{query:s,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.skills.list",t,{route:"/v1/skills",queryParams:["limit","page","source"]})})}delete(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.delete(nb`/v1/skills/${e}`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.skills.delete",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}}return e.Versions=lf,e})();class lm extends ne{create(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/tunnels/${e}/certificates`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"mcp-tunnels-2026-06-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.certificates.create",i,{route:"/v1/tunnels/{tunnel_id}/certificates",attributes:{"anthropic.tunnel.id":e},createdIDAttribute:"anthropic.tunnel.certificate.id"})})}retrieve(e,t,i){let{tunnel_id:r,betas:s,workspace_id:n}=t;return this._client.get(nb`/v1/tunnels/${r}/certificates/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.certificates.retrieve",i,{route:"/v1/tunnels/{tunnel_id}/certificates/{certificate_id}",attributes:{"anthropic.tunnel.id":r,"anthropic.tunnel.certificate.id":e}})})}list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/tunnels/${e}/certificates`,s4,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"mcp-tunnels-2026-06-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.certificates.list",i,{route:"/v1/tunnels/{tunnel_id}/certificates",queryParams:["include_archived","limit","page"],attributes:{"anthropic.tunnel.id":e}})})}archive(e,t,i){let{tunnel_id:r,betas:s,workspace_id:n}=t;return this._client.post(nb`/v1/tunnels/${r}/certificates/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.certificates.archive",i,{route:"/v1/tunnels/{tunnel_id}/certificates/{certificate_id}/archive",attributes:{"anthropic.tunnel.id":r,"anthropic.tunnel.certificate.id":e}})})}}var lv=(()=>{class e extends ne{constructor(){super(...arguments),this.certificates=new lm(this._client)}create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/tunnels",{body:s,...t,headers:rR([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.create",t,{route:"/v1/tunnels",createdIDAttribute:"anthropic.tunnel.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/tunnels/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"mcp-tunnels-2026-06-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.retrieve",i,{route:"/v1/tunnels/{tunnel_id}",attributes:{"anthropic.tunnel.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/tunnels",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.list",t,{route:"/v1/tunnels",queryParams:["include_archived","limit","page"]})})}archive(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/tunnels/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...r??[],"mcp-tunnels-2026-06-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.archive",i,{route:"/v1/tunnels/{tunnel_id}/archive",attributes:{"anthropic.tunnel.id":e}})})}revealToken(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/tunnels/${e}/reveal_token`,{...i,headers:rR([{"anthropic-beta":[...r??[],"mcp-tunnels-2026-06-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.reveal_token",i,{route:"/v1/tunnels/{tunnel_id}/reveal_token",attributes:{"anthropic.tunnel.id":e}})})}rotateToken(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/tunnels/${e}/rotate_token`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"mcp-tunnels-2026-06-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.rotate_token",i,{route:"/v1/tunnels/{tunnel_id}/rotate_token",attributes:{"anthropic.tunnel.id":e}})})}}return e.Certificates=lm,e})();class lb extends ne{create(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/user_profiles/${e}/action_urls`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"user-profiles-2026-08-18"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.user_profiles.action_urls.create",i,{route:"/v1/user_profiles/{user_profile_id}/action_urls",attributes:{"anthropic.user_profile.id":e}})})}}var ly=(()=>{class e extends ne{constructor(){super(...arguments),this.actionURLs=new lb(this._client)}create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/user_profiles",{body:s,...t,headers:rR([{"anthropic-beta":[...i??[],"user-profiles-2026-08-18"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.user_profiles.create",t,{route:"/v1/user_profiles",createdIDAttribute:"anthropic.user_profile.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/user_profiles/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"user-profiles-2026-08-18"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.user_profiles.retrieve",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}update(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/user_profiles/${e}`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"user-profiles-2026-08-18"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.user_profiles.update",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/user_profiles",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"user-profiles-2026-08-18"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.user_profiles.list",t,{route:"/v1/user_profiles",queryParams:["limit","order","order_by","page"]})})}delete(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.delete(nb`/v1/user_profiles/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"user-profiles-2026-08-18"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.user_profiles.delete",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}createEnrollmentURL(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/user_profiles/${e}/enrollment_url`,{...i,headers:rR([{"anthropic-beta":[...r??[],"user-profiles-2026-08-18"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.user_profiles.create_enrollment_url",i,{route:"/v1/user_profiles/{user_profile_id}/enrollment_url",attributes:{"anthropic.user_profile.id":e}})})}}return e.ActionURLs=lb,e})();class lw extends ne{create(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/vaults/${e}/credentials`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.credentials.create",i,{route:"/v1/vaults/{vault_id}/credentials",attributes:{"anthropic.vault.id":e},createdIDAttribute:"anthropic.vault.credential.id"})})}retrieve(e,t,i){let{vault_id:r,betas:s,workspace_id:n}=t;return this._client.get(nb`/v1/vaults/${r}/credentials/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.credentials.retrieve",i,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}",attributes:{"anthropic.vault.id":r,"anthropic.vault.credential.id":e}})})}update(e,t,i){let{vault_id:r,betas:s,workspace_id:n,...a}=t;return this._client.post(nb`/v1/vaults/${r}/credentials/${e}`,{body:a,...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.credentials.update",i,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}",attributes:{"anthropic.vault.id":r,"anthropic.vault.credential.id":e}})})}list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/vaults/${e}/credentials`,s4,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.credentials.list",i,{route:"/v1/vaults/{vault_id}/credentials",queryParams:["include_archived","limit","page"],attributes:{"anthropic.vault.id":e}})})}delete(e,t,i){let{vault_id:r,betas:s,workspace_id:n}=t;return this._client.delete(nb`/v1/vaults/${r}/credentials/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.credentials.delete",i,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}",attributes:{"anthropic.vault.id":r,"anthropic.vault.credential.id":e}})})}archive(e,t,i){let{vault_id:r,betas:s,workspace_id:n}=t;return this._client.post(nb`/v1/vaults/${r}/credentials/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.credentials.archive",i,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}/archive",attributes:{"anthropic.vault.id":r,"anthropic.vault.credential.id":e}})})}mcpOAuthValidate(e,t,i){let{vault_id:r,betas:s,workspace_id:n}=t;return this._client.post(nb`/v1/vaults/${r}/credentials/${e}/mcp_oauth_validate`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.credentials.mcp_oauth_validate",i,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}/mcp_oauth_validate",attributes:{"anthropic.vault.id":r,"anthropic.vault.credential.id":e}})})}}var lk=(()=>{class e extends ne{constructor(){super(...arguments),this.credentials=new lw(this._client)}create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/vaults",{body:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.create",t,{route:"/v1/vaults",createdIDAttribute:"anthropic.vault.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/vaults/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.retrieve",i,{route:"/v1/vaults/{vault_id}",attributes:{"anthropic.vault.id":e}})})}update(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/vaults/${e}`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.update",i,{route:"/v1/vaults/{vault_id}",attributes:{"anthropic.vault.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/vaults",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.list",t,{route:"/v1/vaults",queryParams:["include_archived","limit","page"]})})}delete(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.delete(nb`/v1/vaults/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.delete",i,{route:"/v1/vaults/{vault_id}",attributes:{"anthropic.vault.id":e}})})}archive(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/vaults/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.archive",i,{route:"/v1/vaults/{vault_id}/archive",attributes:{"anthropic.vault.id":e}})})}}return e.Credentials=lw,e})(),lz=(()=>{class e extends ne{constructor(){super(...arguments),this.models=new nQ(this._client),this.messages=new ob(this._client),this.agents=new n2(this._client),this.environments=new az(this._client),this.sessions=new l_(this._client),this.deployments=new nG(this._client),this.deploymentRuns=new nJ(this._client),this.vaults=new lk(this._client),this.memoryStores=new aV(this._client),this.files=new nY(this._client),this.skills=new lg(this._client),this.webhooks=new n0(this._client),this.userProfiles=new ly(this._client),this.dreams=new nX(this._client),this.tunnels=new lv(this._client),this.organization=new lc(this._client)}}return e.Models=nQ,e.Messages=ob,e.Agents=n2,e.Environments=az,e.Sessions=l_,e.Deployments=nG,e.DeploymentRuns=nJ,e.Vaults=lk,e.MemoryStores=aV,e.Files=nY,e.Skills=lg,e.Webhooks=n0,e.UserProfiles=ly,e.Dreams=nX,e.Tunnels=lv,e.Organization=lc,e})();let lS=!1;var lx=(()=>{class e{get credentials(){return this._authState.provider}get openTelemetry(){return(0,id.V)(this,iu,"f")}_instrumentationScope(){return{version:im}}constructor({baseURL:e=(0,rP.f)("ANTHROPIC_BASE_URL"),apiKey:t,authToken:i,webhookKey:r=(0,rP.f)("ANTHROPIC_WEBHOOK_SIGNING_KEY")??null,...s}={}){ia.add(this),this._requestAuthFlags=new WeakMap,il.set(this,void 0),ic.set(this,void 0),iu.set(this,void 0),this._genAIProviderName="anthropic",this._supportsMessageThreads=!1;let n={apiKey:t,authToken:i,...s},a=ip.y.filter(e=>null!=n[e]);if(a.length>1){let e=e=>e.map(e=>`\`${e}\``).join(", ");throw TypeError(`Pass at most one of ${e(ip.y)}. Received ${e(a)}.`)}let[o]=a,l=null!=o?null:{apiKey:void 0===t?(0,rP.f)("ANTHROPIC_API_KEY"):void 0,authToken:void 0===i?(0,rP.f)("ANTHROPIC_AUTH_TOKEN"):void 0},c=null!=o?{type:o,value:n[o]}:l?.apiKey!=null?{type:"apiKey",value:l.apiKey}:l?.authToken!=null?{type:"authToken",value:l.authToken}:{type:"defaultChain"},u={apiKey:"apiKey"===c.type?c.value:null,authToken:"authToken"===c.type?c.value:null,webhookKey:r,...s,baseURL:e||"https://api.anthropic.com"};u.dangerouslyAllowBrowser,this.baseURL=u.baseURL,this._baseURLIsExplicit=s.__baseURLIsExplicit??!!e,this.timeout=u.timeout??io.DEFAULT_TIMEOUT,this.logger=u.logger??console,this.logLevel=rz.I,this.logLevel=(0,rz.J)(u.logLevel,"ClientOptions.logLevel",(0,rz.u)(this))??(0,rz.J)((0,rP.f)("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",(0,rz.u)(this))??rz.I,l?.apiKey==null||null==l.authToken||lS||(lS=!0,(0,rz.u)(this).warn("Anthropic: ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN are both set. Using ANTHROPIC_API_KEY.")),this.fetchOptions=u.fetchOptions,this.maxRetries=(0,ip.H)("maxRetries",u.maxRetries??2);let h=this._instrumentationScope();(0,id.b)(this,iu,function(e){let{tracerProvider:t,propagation:i,traces:r}=!1===e?{traces:!1}:e??{propagation:(0,rP.f)("ANTHROPIC_OPEN_TELEMETRY_PROPAGATION")?.toLowerCase()!=="false",traces:{enabled:(0,rP.f)("ANTHROPIC_OPEN_TELEMETRY")?.toLowerCase()!=="false",contentMode:(0,rP.f)("ANTHROPIC_OPEN_TELEMETRY_TRACES_CONTENT_MODE")?.toLowerCase()==="content"?"content":"metadata_only",maxContentBytes:Number(/^\d+$/.exec((0,rP.f)("ANTHROPIC_OPEN_TELEMETRY_TRACES_MAX_CONTENT_BYTES")??"")?.[0]??0/0)}},{enabled:s,contentMode:n,maxContentBytes:a}="boolean"==typeof r?{enabled:r}:r??{};return Object.freeze({tracerProvider:t,propagation:i??!0,traces:Object.freeze({enabled:s??!0,contentMode:"content"===n?"content":"metadata_only",maxContentBytes:void 0!==a&&Number.isInteger(a)&&a>=1?a:75e4})})}(u.openTelemetry),"f"),u.openTelemetry=(0,id.V)(this,iu,"f"),this._tracer=rL(this,()=>(function(e,t,i){if(!e.traces.enabled)return;let r=void 0!==i?`${rT}.${i}`:rT;return(e.tracerProvider??rm.getTracerProvider()).getTracer(r,t)})((0,id.V)(this,iu,"f"),h.version,h.platform)),this.fetch=u.fetch??function(){if("u">typeof fetch)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`")}(),(0,id.b)(this,il,iq,"f"),this.middleware=[...u.middleware??[]];let d=(0,rP.f)("ANTHROPIC_CUSTOM_HEADERS");if(d){let e={};for(let t of d.split("\n")){let i=t.indexOf(":");i>=0&&(e[t.substring(0,i).trim()]=t.substring(i+1).trim())}u.defaultHeaders={...e,...u.defaultHeaders}}let p=s.__auth;if(delete u.__auth,delete u.__baseURLIsExplicit,this._options=u,this.apiKey="string"==typeof u.apiKey?u.apiKey:null,(0,id.b)(this,ic,"function"==typeof u.apiKey?u.apiKey:null,"f"),this.authToken=u.authToken??null,this.webhookKey=r,p)this._authState=p,!this._baseURLIsExplicit&&p.baseURL&&(this.baseURL=p.baseURL);else switch(this._authState={provider:null,tokenCache:null,resolution:null,error:null,extraHeaders:{}},c.type){case"apiKey":case"authToken":break;case"credentials":this._authState.provider=c.value,this._authState.tokenCache=this._makeTokenCache(c.value);break;case"config":{let e=sL(c.value,this._credentialResolverOptions());this._authState.provider=e.provider,this._authState.tokenCache=this._makeTokenCache(e.provider),this._authState.extraHeaders=e.extraHeaders,this._applyCredentialBaseURL(e.baseURL);break}case"profile":this._authState.resolution=this._resolveDefaultCredentials(c.value);break;case"defaultChain":this._shouldResolveDefaultCredentials()&&(this._authState.resolution=this._resolveDefaultCredentials());break;default:(0,ip.f)(c)}}_shouldResolveDefaultCredentials(){return!0}_applyCredentialBaseURL(e){if(!e)return;let t=e.replace(/\/+$/,"");this._authState.baseURL=t,this._baseURLIsExplicit||(this.baseURL=t)}_credentialResolverOptions(){return{baseURL:this.baseURL,fetch:this._credentialsFetch(),userAgent:this.getUserAgent(),onCacheWriteError:e=>{(0,rz.u)(this).debug("credential cache write failed (best-effort)",e)},onSafetyWarning:e=>{(0,rz.u)(this).warn(e)}}}_credentialsFetch(){return sU(this.fetch,this.middleware,void 0,this)}_makeTokenCache(e){return new si(e,e=>{(0,rz.u)(this).debug("advisory token refresh failed; serving cached token",e)})}withOptions(e){for(let t of(e={...e},ip.y))void 0===e[t]&&delete e[t];let t=ip.y.some(t=>t in e),i=ip.y.some(t=>null!=e[t]),r={...this._options,...this._baseURLIsExplicit?{baseURL:this.baseURL}:{},maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,middleware:this.middleware,apiKey:this.apiKey??(0,id.V)(this,ic,"f"),authToken:this.authToken,webhookKey:this.webhookKey,...i?Object.fromEntries(ip.y.map(e=>[e,null])):{},...e,openTelemetry:e.openTelemetry??(0,id.V)(this,iu,"f"),__auth:t?void 0:this._authState,__baseURLIsExplicit:"baseURL"in e||this._baseURLIsExplicit};return new this.constructor(r)}async _resolveDefaultCredentials(e){try{let t=await sC(this._credentialResolverOptions(),e);if(t)this._authState.provider=t.provider,this._authState.tokenCache=this._makeTokenCache(t.provider),this._authState.extraHeaders=t.extraHeaders,this._applyCredentialBaseURL(t.baseURL);else if(null!=e)throw new ry.v(`Profile "${e}" could not be resolved (no <config_dir>/configs/${e}.json found).`)}catch(e){this._authState.error=e}finally{this._authState.resolution=null}}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(e.get("x-api-key")||e.get("authorization"))){if(this._authState.error)throw this._authState.error;if(!(this._authState.tokenCache||this._authState.resolution||this.apiKey&&e.get("authorization")||t.has("authorization")||this.authToken&&e.get("authorization"))&&!t.has("authorization"))throw Error('Could not resolve authentication method. Expected one of apiKey, authToken, credentials, config, or profile to be set. Or for the "Authorization" header to be explicitly omitted')}}_authFlags(e){let t=this._requestAuthFlags.get(e);return t||(t={usedTokenCache:!1,didRefreshFor401:!1},this._requestAuthFlags.set(e,t)),t}async authHeaders(e){if(this._authState.resolution&&await this._authState.resolution,!this._authState.error){if((0,id.V)(this,ic,"f")&&null==this.apiKey){let e;try{e=await (0,id.V)(this,ic,"f").call(this)}catch(e){throw new ry.v(`The \`apiKey\` function failed: ${(0,ig.Y)(e).message}`,{cause:e})}if(!e)throw new ry.v(`The \`apiKey\` function must return a non-empty string. It returned ${JSON.stringify(e)}.`);return rR([{Authorization:`Bearer ${e}`}])}if(this._authState.tokenCache&&null==this.apiKey){let t=await this._authState.tokenCache.getToken();return this._authFlags(e).usedTokenCache=!0,rR([{Authorization:`Bearer ${t}`}])}return rR([await this.bearerAuth(e),await this.apiKeyAuth(e)])}}async apiKeyAuth(e){if(null!=this.apiKey)return rR([{Authorization:`Bearer ${this.apiKey}`}])}async bearerAuth(e){if(null!=this.authToken)return rR([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return function(e,t={}){let i,r=e,s=function(e=rQ){let t;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw TypeError("Encoder has to be a function.");let i=e.charset||rQ.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let r=rF;if(void 0!==e.format){if(!rK(rB,e.format))throw TypeError("Unknown format option provided.");r=e.format}let s=rB[r],n=rQ.filter;if(("function"==typeof e.filter||(0,ip.o)(e.filter))&&(n=e.filter),t=e.arrayFormat&&e.arrayFormat in rX?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":rQ.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw TypeError("`commaRoundTrip` must be a boolean, or absent");let a=void 0===e.allowDots?!0==!!e.encodeDotInKeys||rQ.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:rQ.addQueryPrefix,allowDots:a,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:rQ.allowEmptyArrays,arrayFormat:t,charset:i,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:rQ.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?rQ.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:rQ.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:rQ.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:rQ.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:rQ.encodeValuesOnly,filter:n,format:r,formatter:s,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:rQ.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:rQ.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:rQ.strictNullHandling}}(t);"function"==typeof s.filter?r=(0,s.filter)("",r):(0,ip.o)(s.filter)&&(i=s.filter);let n=[];if("object"!=typeof r||null===r)return"";let a=rX[s.arrayFormat],o="comma"===a&&s.commaRoundTrip;i||(i=Object.keys(r)),s.sort&&i.sort(s.sort);let l=new WeakMap;for(let e=0;e<i.length;++e){let t=i[e];s.skipNulls&&null===r[t]||rY(n,function e(t,i,r,s,n,a,o,l,c,u,h,d,p,_,f,g,m,v){var b,y;let w,k=t,z=v,S=0,x=!1;for(;void 0!==(z=z.get(rZ))&&!x;){let e=z.get(t);if(S+=1,void 0!==e)if(e===S)throw RangeError("Cyclic object value");else x=!0;void 0===z.get(rZ)&&(S=0)}if("function"==typeof u?k=u(i,k):k instanceof Date?k=p?.(k):"comma"===r&&(0,ip.o)(k)&&(k=rG(k,function(e){return e instanceof Date?p?.(e):e})),null===k){if(a)return c&&!g?c(i,rQ.encoder,m,"key",_):i;k=""}if("string"==typeof(b=k)||"number"==typeof b||"boolean"==typeof b||"symbol"==typeof b||"bigint"==typeof b||(y=k)&&"object"==typeof y&&y.constructor&&y.constructor.isBuffer&&y.constructor.isBuffer(y)){if(c){let e=g?i:c(i,rQ.encoder,m,"key",_);return[f?.(e)+"="+f?.(c(k,rQ.encoder,m,"value",_))]}return[f?.(i)+"="+f?.(String(k))]}let V=[];if(void 0===k)return V;if("comma"===r&&(0,ip.o)(k))g&&c&&(k=rG(k,c)),w=[{value:k.length>0?k.join(",")||null:void 0}];else if((0,ip.o)(u))w=u;else{let e=Object.keys(k);w=h?e.sort(h):e}let A=l?String(i).replace(/\./g,"%2E"):String(i),I=s&&(0,ip.o)(k)&&1===k.length?A+"[]":A;if(n&&(0,ip.o)(k)&&0===k.length)return I+"[]";for(let i=0;i<w.length;++i){let b=w[i],y="object"==typeof b&&void 0!==b.value?b.value:k[b];if(o&&null===y)continue;let z=d&&l?b.replace(/\./g,"%2E"):b,x=(0,ip.o)(k)?"function"==typeof r?r(I,z):I:I+(d?"."+z:"["+z+"]");v.set(t,S);let A=new WeakMap;A.set(rZ,v),rY(V,e(y,x,r,s,n,a,o,l,"comma"===r&&g&&(0,ip.o)(k)?null:c,u,h,d,p,_,f,g,m,A))}return V}(r[t],t,a,o,s.allowEmptyArrays,s.strictNullHandling,s.skipNulls,s.encodeDotInKeys,s.encode?s.encoder:null,s.filter,s.sort,s.allowDots,s.serializeDate,s.format,s.formatter,s.encodeValuesOnly,s.charset,l))}let c=n.join(s.delimiter),u=!0===s.addQueryPrefix?"?":"";return s.charsetSentinel&&("iso-8859-1"===s.charset?u+="utf8=%26%2310003%3B&":u+="utf8=%E2%9C%93&"),c.length>0?u+c:""}(e,{arrayFormat:"brackets"})}getUserAgent(){return`Anthropic/JS ${im}`}makeStatusError(e,t,i,r){return ry.E.generate(e,t,i,r)}buildURL(e,t,i){let r=!(0,id.V)(this,ia,"m",ih).call(this)&&i||this.baseURL,s=new URL((0,ip.X)(e)?e:r+(r.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),n=this.defaultQuery(),a=Object.fromEntries(s.searchParams);return(0,ip.O)(n)&&(0,ip.O)(a)||(t={...a,...n,...t}),"object"==typeof t&&t&&!Array.isArray(t)&&(s.search=this.stringifyQuery(t)),s.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new ry.v("Streaming is required for operations that may take longer than 10 minutes. See https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/typescript#streaming-responses for more details");return 6e5}async prepareOptions(e){}async prepareRequest(e,{url:t,options:i}){if(this._authState.tokenCache&&null==this.apiKey){let t=e.headers instanceof Headers?e.headers:new Headers(e.headers);for(let[e,i]of Object.entries(this._authState.extraHeaders))t.has(e)||t.set(e,i);let i=t.get("anthropic-beta")?.split(",").map(e=>e.trim());i?.includes(r2)||t.set("anthropic-beta",[...i??[],r2].join(",")),e.headers=t}}backendMiddleware(){return[]}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,i){return this.request(Promise.resolve(i).then(i=>({method:e,path:t,...i})))}request(e,t=null){return this._tracer?new s0(this,this.makeTracedRequest(e,t)):new s0(this,this.makeRequest(e,t,void 0))}async makeTracedRequest(e,t){let i=await e,r=i.__span?.span;if(!r)return this.makeRequest(i,t,void 0);try{return await iJ.with(rm.setSpan(iJ.active(),r),()=>this.makeRequest(i,t,void 0,r))}catch(t){let e={status:"error",options:i,error:t};throw sk(this,r,e),rL(this,()=>rj(r,e)),t}}async makeRequest(e,t,i,r){var s;let n=await e,a=(0,ip.H)("maxRetries",n.maxRetries??this.maxRetries);this.isStreamBody(n.body)&&(a=0),null==t&&(t=a,this._requestAuthFlags.delete(n)),await this.prepareOptions(n);let{req:o,url:l,timeout:c}=await this.buildRequest(n,{retryCount:a-t}),u="log_"+(0x1000000*Math.random()|0).toString(16).padStart(6,"0"),h=void 0===i?"":`, retryOf: ${i}`;r&&this.openTelemetry.propagation&&(o.headers=rL(this,()=>(function(e,t){let i=rR([t]).values;for(let[t,r]of Object.entries(rU(e)))i.set(t,r);return i})(r,o.headers))??o.headers);let d=Date.now();if(n.signal?.aborted)throw new ry.F;let p=new AbortController,_=await this.fetchWithTimeout(l,o,c,p,n,{requestLogID:u,retryOfRequestLogID:i}).catch(ig.Y),f=Date.now();if(_ instanceof globalThis.Error){iz(p);let e=`retrying, ${t} attempts remaining`;if(n.signal?.aborted)throw new ry.F;let s=(0,ig.c)(_)||/timed? ?out/i.test(String(_)+("cause"in _?String(_.cause):"")),a=this.middleware.length>0||!!n.middleware?.length||this.backendMiddleware().length>0;if(a&&!s&&!function(e){let t=new Set;for(;"object"==typeof e&&null!==e&&!t.has(e);){if(t.add(e),sW(e)||(0,ig.c)(e)||e instanceof ry.I||e instanceof ry.O)return!0;e=e.cause}return!1}(_))throw(0,rz.u)(this).info(`[${u}] middleware error (not retryable)`),(0,rz.M)((0,rz.u)(this),`[${u}] middleware error (not retryable)`,{retryOfRequestLogID:i,url:l,durationMs:f-d,message:_.message}),_;if(t)return(0,rz.u)(this).info(`[${u}] connection ${s?"timed out":"failed"} - ${e}`),(0,rz.M)((0,rz.u)(this),`[${u}] connection ${s?"timed out":"failed"} (${e})`,{retryOfRequestLogID:i,url:l,durationMs:f-d,message:_.message}),this.retryRequest(n,t,i??u,r);if((0,rz.u)(this).info(`[${u}] connection ${s?"timed out":"failed"} - error; no more retries left`),(0,rz.M)((0,rz.u)(this),`[${u}] connection ${s?"timed out":"failed"} (error; no more retries left)`,{retryOfRequestLogID:i,url:l,durationMs:f-d,message:_.message}),s)throw new ry.R;if(a&&!sW(_))throw _;throw new ry.I({cause:_})}let g=[..._.headers.entries()].filter(([e])=>"request-id"===e||"anthropic-workspace-id"===e).map(([e,t])=>", "+e+": "+JSON.stringify(t)).join(""),m=`[${u}${h}${g}] ${o.method} ${l} ${_.ok?"succeeded":"failed"} with status ${_.status} in ${f-d}ms`;if(!_.ok){let e=await this.shouldRetry(_,n);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await iI(_.body),iz(p),(0,rz.u)(this).info(`${m} - ${e}`),(0,rz.M)((0,rz.u)(this),`[${u}] response error (${e})`,{retryOfRequestLogID:i,url:_.url,status:_.status,headers:_.headers,durationMs:f-d}),this.retryRequest(n,t,i??u,r,_.headers)}let s=e?"error; no more retries left":"error; not retryable";(0,rz.u)(this).info(`${m} - ${s}`);let a=await _.text().catch(e=>(0,ig.Y)(e).message),o=(0,ip.k)(a),l=o?void 0:a;throw(0,rz.M)((0,rz.u)(this),`[${u}] response error (${s})`,{retryOfRequestLogID:i,url:_.url,status:_.status,headers:_.headers,message:l,durationMs:Date.now()-d}),iz(p),this.makeStatusError(_.status,o,l,_.headers)}return(0,rz.u)(this).info(m),(0,rz.M)((0,rz.u)(this),`[${u}] response start`,{retryOfRequestLogID:i,url:_.url,status:_.status,headers:_.headers,durationMs:f-d}),s=_.body??_,iw.has(p)&&ik?.register(s,p,p),{response:_,options:n,controller:p,requestLogID:u,retryOfRequestLogID:i,startTime:d}}getAPIList(e,t,i){return this.requestAPIList(t,i&&"then"in i?i.then(t=>({method:"get",path:e,...t})):{method:"get",path:e,...i})}requestAPIList(e,t){return this._tracer?new s2(this,this.makeTracedRequest(t,null),e):new s2(this,this.makeRequest(t,null,void 0),e)}async fetchWithTimeout(e,t,i,r,s,n){let{signal:a,method:o,...l}=t||{},c=this._makeAbort(r);a&&(a.addEventListener("abort",c,{once:!0}),iw.set(r,()=>a.removeEventListener("abort",c)));let u=globalThis.ReadableStream&&l.body instanceof globalThis.ReadableStream||"object"==typeof l.body&&null!==l.body&&Symbol.asyncIterator in l.body,h={signal:r.signal,...u?{duplex:"half"}:{},method:"GET",...l};o&&(h.method=o.toUpperCase());let d=this.fetch,p=async(e,t)=>{let r=setTimeout(c,i);try{return await d.call(void 0,e,t)}finally{clearTimeout(r)}},_=void 0===s?p:async(e,t={})=>{let i="string"==typeof e?e:e instanceof URL?e.href:e.url;t.headers=t.headers instanceof Headers?t.headers:new Headers(t.headers);let r=[];s.__span&&(t.headers=new Headers(t.headers),r=sA(t.headers)),await this.prepareRequest(t,{url:i,options:s}),r.length&&(t.headers=rR([t.headers,r]).values);let a=s.__span;return a&&rL(this,()=>(function(e,t,i,r=!1){if(e.attempts=(e.attempts??0)+1,e.attempts>1)return void e.span.setAttribute("http.request.resend_count",e.attempts-1);e.span.setAttribute("http.request.method",t);try{let{protocol:t,host:s,pathname:n,search:a}=new URL(i),o=function(e,t,i){if(!e||!t?.length)return;let r=!1,s=e.split("&").filter(e=>{try{let s=decodeURIComponent(e.split("=",1)[0]),n=t.includes(s)||!s.endsWith("[]")?s:s.slice(0,-2);if(!t.includes(n))return!1;return r||(r=rN.includes(n)||!!i?.includes(n)),!0}catch{return!1}});return s.length?{value:s.join("&"),content:r}:void 0}(a.slice(1),e.queryParams,e.contentQueryParams);if(e.span.setAttributes({"url.scheme":t.slice(0,-1),"url.path":n}),o?.content&&!r)return;e.span.setAttributes({...void 0!==o?{"url.query":o.value}:void 0,"url.full":`${t}//${s}${n}${void 0!==o?`?${o.value}`:""}`})}catch{}})(a,t.method??"GET",i,"content"===this.openTelemetry.traces.contentMode)),n&&(0,rz.M)((0,rz.u)(this),`[${n.requestLogID}] sending request`,{retryOfRequestLogID:n.retryOfRequestLogID,method:t.method,url:i,options:s,headers:t.headers}),p(e,t)},f=s?.middleware,g=s?.__span?this.backendMiddleware().map(sI):this.backendMiddleware(),m=f?.length||g.length?[...this.middleware,...f??[],...g]:this.middleware;return await sU(_,m,s,this)(e,h)}async shouldRetry(e,t){let i=this._authFlags(t);if(401===e.status&&this._authState.tokenCache&&i.usedTokenCache&&!i.didRefreshFor401)return i.didRefreshFor401=!0,this._authState.tokenCache.invalidate(),!0;let r=e.headers.get("x-should-retry");return"true"===r||"false"!==r&&(408===e.status||409===e.status||429===e.status||!!(e.status>=500))}async retryRequest(e,t,i,r,s){let n,a=s?.get("retry-after-ms");if(a){let e=parseFloat(a);Number.isNaN(e)||(n=e)}let o=s?.get("retry-after");if(o&&!n){let e=parseFloat(o);n=Number.isNaN(e)?Date.parse(o)-Date.now():1e3*e}if(void 0===n||!(n>0&&n<=0x7fffffff)){let i=e.maxRetries??this.maxRetries;n=this.calculateDefaultRetryTimeoutMillis(t,i)}return await i_(n,e.signal??void 0),this.makeRequest(e,t-1,i,r)}calculateDefaultRetryTimeoutMillis(e,t){return Math.min(.5*Math.pow(2,t-e),8)*(1-.25*Math.random())*1e3}calculateNonstreamingTimeout(e,t){if(36e5*e/128e3>6e5||null!=t&&e>t)throw new ry.v("Streaming is required for operations that may take longer than 10 minutes. See https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/typescript#long-requests for more details");return 6e5}async buildRequest(e,{retryCount:t=0}={}){let i={...e},{method:r,path:s,query:n,defaultBaseURL:a}=i;this._authState.resolution&&await this._authState.resolution,!this._baseURLIsExplicit&&this._authState.baseURL&&this.baseURL!==this._authState.baseURL&&(this.baseURL=this._authState.baseURL);let o=this.buildURL(s,n,a);"timeout"in i&&(0,ip.H)("timeout",i.timeout),i.timeout=i.timeout??this.timeout;let{bodyHeaders:l,body:c}=this.buildBody({options:i}),u=await this.buildHeaders({options:e,method:r,bodyHeaders:l,retryCount:t,timeout:i.timeout});return{req:{method:r,headers:u,...i.signal&&{signal:i.signal},...globalThis.ReadableStream&&c instanceof globalThis.ReadableStream&&{duplex:"half"},...c&&{body:c},...this.fetchOptions??{},...i.fetchOptions??{}},url:o,timeout:i.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:i,retryCount:r,timeout:s}){let n=rR([{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r),"X-Stainless-Timeout":String(Math.trunc(s/1e3)),...iy(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2026-10-21"},await this.authHeaders(e),this._options.defaultHeaders,i,e.headers]);return this.validateHeaders(n),n.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let i=rR([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||"string"==typeof e&&i.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:this.isStreamBody(e)?{bodyHeaders:void 0,body:ix(e)}:"object"==typeof e&&"application/x-www-form-urlencoded"===i.values.get("content-type")?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:(0,id.V)(this,il,"f").call(this,{body:e,headers:i})}isStreamBody(e){return!!globalThis.ReadableStream&&e instanceof globalThis.ReadableStream||"object"==typeof e&&null!==e&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&"function"==typeof e.next)}}return io=e,il=new WeakMap,ic=new WeakMap,iu=new WeakMap,ia=new WeakSet,ih=function(){return"https://api.anthropic.com"!==this.baseURL},e.Anthropic=io,e.DEFAULT_TIMEOUT=6e5,e.AnthropicError=ry.v,e.APIError=ry.E,e.APIConnectionError=ry.I,e.APIConnectionTimeoutError=ry.R,e.APIUserAbortError=ry.F,e.NotFoundError=ry.i,e.ConflictError=ry.y,e.RateLimitError=ry.t,e.BadRequestError=ry.B,e.AuthenticationError=ry.P,e.InternalServerError=ry.j,e.PermissionDeniedError=ry.N,e.UnprocessableEntityError=ry.o,e.toFile=s9,e})(),lV=(()=>{class e extends lx{constructor(){super(...arguments),this._supportsMessageThreads=!0,this.messages=new nk(this),this.models=new nx(this),this.files=new nV(this),this.skills=new nI(this),this.userProfiles=new n$(this),this.organization=new nK(this),this.beta=new lz(this)}}return e.Messages=nk,e.Models=nx,e.Files=nV,e.Skills=nI,e.UserProfiles=n$,e.Organization=nK,e.Beta=lz,e})(),lA=e.i(687604),lI=e.i(261829),lq=e.i(983598),l$=e.i(798003),lR=e.i(999617),lP=e.i(459398),lT=e.i(50377),lE=e.i(481183),lO=e.i(93716),lM=e.i(630166),lL=e.i(215267),lC=e.i(115851),lN=e.i(907240);let lj=(0,lT.f)("ai:anthropic"),lD="https://api.anthropic.com",lW="claude-sonnet-5-5";function lU(e,t){let i,r=e.match(/^data:([^;]+);base64,([\s\S]*)$/);return{type:"image",source:{type:"base64",media_type:"image/png"===(i=((r?r[1]:t)||"").toLowerCase())||"image/gif"===i||"image/webp"===i?i:"image/jpeg",data:r?r[2]:e}}}function lF(e,t){let i=`<${t}>`,r=`</${t}>`,s=e.indexOf(i);if(-1===s)return null;let n=s+i.length,a=e.lastIndexOf(r);return -1===a&&"analysis"===t?(lj.warn({tagName:t},"Tag was verified unclosed, treating as truncated and reading to end"),e.substring(n).trim()):-1===a||n>=a?null:e.substring(n,a).trim()}function lH(e){return(e||"").split(/[,,\n]/).map(e=>e.trim()).filter(e=>e.length>0)}function lB(e){let t=lF(e,"question_text"),i=lF(e,"answer_text"),r=lF(e,"analysis");if(!t||!i||!r)throw lj.error({rawTextSample:e.substring(0,500)},"Missing critical XML tags"),Error("Invalid AI response: Missing critical XML tags (<question_text>, <answer_text>, or <analysis>)");let s=lF(e,"wrong_answer_text")||"",n={questionText:t,answerText:i,analysis:r,wrongAnswerText:s,mistakeAnalysis:lF(e,"mistake_analysis")||"",mistakeStatus:(0,lM.f)(lF(e,"mistake_status"),s),subject:(0,lR.G)(lF(e,"subject"))||"其他",knowledgePoints:lH(lF(e,"knowledge_points")),requiresImage:lF(e,"requires_image")?.toLowerCase().trim()==="true",gradeSemester:(0,lL.X)(lF(e,"grade_semester")),difficultyStars:(0,lR.B)(lF(e,"difficulty_stars")),...(0,lR.t)(lF(e,"has_figure"),lF(e,"figure_svg"))},a=(0,lR.u)(n);return a.success?a.data:(lj.warn({validationError:a.error.format()},"Schema validation warning"),n)}e.s(["R",0,class{client;model;baseURL;constructor(e){let t=e?.apiKey,i=e?.authToken;if(!t&&!i)throw Error("AI_AUTH_ERROR: ANTHROPIC_API_KEY is required for Anthropic provider");this.baseURL=(0,lE.z)(e?.baseUrl||lD).replace(/\/v1$/,""),this.model=e?.model||lW,this.client=function(e,t,i){let r={baseURL:e,timeout:6e5};if(function(e){try{return new URL(e).hostname===new URL(lD).hostname}catch{return!1}}(e))return new lV(t?{...r,apiKey:t,authToken:null}:{...r,apiKey:null,authToken:i});let s={"anthropic-version":"2023-06-01"};return t?(s["x-api-key"]=t,new lV({...r,apiKey:null,authToken:null,defaultHeaders:s})):new lV({...r,apiKey:null,authToken:i,defaultHeaders:s})}(this.baseURL,t,i),lj.info({provider:"Anthropic",model:this.model,baseURL:this.baseURL,apiKeyPrefix:t?t.substring(0,8)+"...":"bearer"},"AI Provider initialized")}async complete(e,t,i){let r=await (0,lO.V)(async i=>{let r=await this.client.messages.create({model:this.model,max_tokens:i,system:e,messages:[{role:"user",content:t}]}),s=r.content.filter(e=>"text"===e.type).map(e=>e.text).join("");return lj.debug({stopReason:r.stop_reason,usage:r.usage},"Anthropic response received"),{text:s,choices:[{finish_reason:"max_tokens"===r.stop_reason?"length":r.stop_reason,message:{content:s}}]}},i,()=>lj.warn("Output truncated by reasoning, retrying with larger max_tokens"),this.model);if(!r.text)throw Error("Empty response from AI");return r.text}async analyzeImage(e,t="image/jpeg",i="zh",r,s,n,a){let o=(0,l$.b)(),l=a?{candidateTags:a}:await (0,lP.i)(s,r),c=(0,lA.generateAnalyzeRequest)(i,r,s,{customTemplate:o.prompts?.analyze,...l},n);lj.box("🔍 AI Image Analysis Request",{provider:"Anthropic",endpoint:`${this.baseURL}/v1/messages`,imageSize:`${e.length} bytes`,mimeType:t,model:this.model,language:i,grade:r||"all"}),lj.box("📝 Full System Prompt",c.system);try{let i=await this.complete(c.system,[lU(e,t),{type:"text",text:c.user}],8192);lj.box("🤖 AI Raw Response",i);let r=(0,lN.f)(lB(i),l);return lj.box("✅ Parsed & Validated Result",JSON.stringify(r,null,2)),r}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during AI analysis"),this.handleError(e),e}}async generateSimilarQuestion(e,t,i="zh",r="medium",s,n){let a=(0,l$.b)(),o=(0,lA.generateSimilarQuestionRequest)(i,e,t,r,{customTemplate:a.prompts?.similar,originalFigureSvg:n},s),l=o.user;lj.info({provider:"Anthropic",model:this.model,difficulty:r,language:i},"Generate Similar Question Request");try{let e=await this.complete(o.system,l,8192);return lj.box("🤖 AI Raw Response",e),(0,lC.f)(lB(e))}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during question generation"),this.handleError(e),e}}async reanswerQuestion(e,t="zh",i,r,s,n){let a=(0,lA.generateReanswerRequest)(t,e,i,{candidateTags:n},s);lj.info({provider:"Anthropic",model:this.model,questionLength:e.length,subject:i||"auto",hasImage:!!r},"Reanswer Question Request");try{let e=r?[lU(r),{type:"text",text:a.user}]:a.user,t=await this.complete(a.system,e,8192);lj.debug({rawResponse:t},"AI raw response");let i=lF(t,"wrong_answer_text")||"";return(0,lN.f)({answerText:lF(t,"answer_text")||"",analysis:lF(t,"analysis")||"",knowledgePoints:lH(lF(t,"knowledge_points")),wrongAnswerText:i,mistakeAnalysis:lF(t,"mistake_analysis")||"",mistakeStatus:(0,lM.f)(lF(t,"mistake_status"),i),subject:(0,lR.G)(lF(t,"subject")),gradeSemester:(0,lL.X)(lF(t,"grade_semester")),difficultyStars:(0,lR.B)(lF(t,"difficulty_stars"))},{candidateTags:n})}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during reanswer"),this.handleError(e),e}}async analyzeForGeogebra(e,t,i,r){let s=(0,lA.generateGeogebraRequest)(e,t,i,r);lj.info({provider:"Anthropic",model:this.model,questionLength:e.length},"GeoGebra Analysis Request");try{let e=await this.complete(s.system,s.user,4096);lj.debug({rawResponse:e},"GeoGebra AI raw response");let t=(0,lR.F)(e);return{suitable:!!t.suitable,commands:Array.isArray(t.commands)?t.commands:[],description:"string"==typeof t.description?t.description:""}}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during GeoGebra analysis"),this.handleError(e),e}}async evaluateMastery(e){let t=(0,lA.generateMasteryRequest)(e);lj.info({provider:"Anthropic",historyCount:e.history.length},"Mastery Evaluation Request");try{let e=await this.complete(t.system,t.user,4096);return lj.debug({rawResponse:e},"Mastery AI raw response"),(0,lR.r)(e)}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during mastery evaluation"),this.handleError(e),e}}async recognizeGrade(e){let t=(0,lA.generateGradeRecognitionRequest)(e);try{return(0,lR.b)(await this.complete(t.system,t.user,1024))}catch(e){throw lj.error({error:e},"识别题目年级失败"),this.handleError(e),e}}async gradeAnswer(e){let t=(0,lA.generateGradingRequest)(e);lj.info({provider:"Anthropic"},"Answer Grading Request");try{let e=await this.complete(t.system,t.user,4096);return lj.debug({rawResponse:e},"Grading AI raw response"),(0,lR.o)(e)}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during answer grading"),this.handleError(e),e}}async suggestKnowledgeTags(e){let t=(0,lA.generateTagSuggestRequest)(e);lj.info({provider:"Anthropic",subject:e.subject,allowedTagCount:e.allowedTags.length},"Tag Suggestion Request");try{let i=await this.complete(t.system,t.user,4096);return lj.debug({rawResponse:i},"Tag suggestion AI raw response"),(0,lR.K)(i,e.allowedTags)}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during tag suggestion"),this.handleError(e),e}}async generateFigureSvg(e,t,i){let r=(0,lA.generateFigureRequest)(i);lj.info({provider:"Anthropic",model:this.model,imageSize:e.length},"Figure SVG Request");try{let i=await this.complete(r.system,[lU(e,t),{type:"text",text:r.user},{type:"text",text:"请重新绘制图中题目的配图。"}],8192);return lj.debug({rawResponse:i},"Figure SVG AI raw response"),(0,lR.t)(lF(i,"has_figure"),lF(i,"figure_svg"))}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during figure SVG generation"),this.handleError(e),e}}async fixLatex(e){let t=(0,lA.generateLatexFixRequest)(e);lj.info({provider:"Anthropic",model:this.model,fields:Object.keys(e)},"LaTeX Fix Request");try{let i=await this.complete(t.system,t.user,8192);return lj.debug({rawResponse:i},"LaTeX fix AI raw response"),(0,lq.f)(i,e)}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during LaTeX fix"),this.handleError(e),e}}async generateSvgAnimation(e,t,i,r,s="zh"){let n=(0,lA.generateSvgAnimationRequest)(e,t,i,r,s);lj.info({provider:"Anthropic",model:this.model,questionLength:e.length},"SVG Animation Request");try{let e=await this.complete(n.system,n.user,16384);return lj.debug({rawResponse:e},"SVG animation AI raw response"),(0,lI.J)(lF(e,"svg_animation")||e)}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during SVG animation generation"),this.handleError(e),e}}async generateSvgNarration(e,t,i,r,s="zh"){let n=(0,lA.generateSvgNarrationRequest)(e,t,i,r,s);lj.info({provider:"Anthropic",model:this.model,svgLength:r.length},"SVG Narration Request");try{let e=await this.complete(n.system,n.user,4096);return lj.debug({rawResponse:e},"SVG narration AI raw response"),(0,lI.a)(lF(e,"narration")||e)}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during SVG narration generation"),this.handleError(e),e}}handleError(e){if(lj.error({error:e},"Anthropic error"),e instanceof Error&&(e.message===lO.z||e.message.startsWith("AI_RESPONSE_ERROR:")))throw e;if(e instanceof lV.APIConnectionTimeoutError)throw Error("AI_TIMEOUT_ERROR",{cause:e});if(e instanceof lV.APIConnectionError)throw Error("AI_CONNECTION_FAILED",{cause:e});if(e instanceof lV.APIError&&e.status){let t=e.status;if(401===t)throw Error("AI_AUTH_ERROR",{cause:e});if(403===t)throw Error("AI_PERMISSION_DENIED",{cause:e});if(404===t)throw Error("AI_NOT_FOUND",{cause:e});if(408===t)throw Error("AI_TIMEOUT_ERROR",{cause:e});if(429===t)throw Error("AI_QUOTA_EXCEEDED",{cause:e});if(t>=500)throw Error("AI_SERVICE_UNAVAILABLE",{cause:e})}if(e instanceof Error){let t=e.message.toLowerCase();if(t.includes("fetch failed")||t.includes("network")||t.includes("connect"))throw Error("AI_CONNECTION_FAILED",{cause:e});if(t.includes("timeout")||t.includes("timed out")||t.includes("aborted"))throw Error("AI_TIMEOUT_ERROR",{cause:e});if(t.includes("invalid json")||t.includes("parse")||t.includes("json")||t.includes("missing critical xml"))throw Error("AI_RESPONSE_ERROR",{cause:e})}throw Error("AI_UNKNOWN_ERROR",{cause:e})}},"l",0,lD,"A",0,lW],690604)},983598,93716,115851,907240,e=>{var t=e.i(405898);e.s(["f",0,function(e,i){let r={};for(let s of Object.keys(i)){let i=t.t[s],n=e.indexOf(`<${i}>`);if(-1===n)continue;let a=n+i.length+2,o=e.indexOf(`</${i}>`,a);if(-1===o)continue;let l=e.slice(a,o).trim();l&&(r[s]=l)}return r}],983598);var i=e.i(629833),r=e.i(50377);let s=[{pattern:/claude-(opus|sonnet|haiku|fable|mythos)-([5-9]|4[-.][6-9])/,maxOutputTokens:128e3},{pattern:/claude-(opus|sonnet|haiku)-4[-.]5/,maxOutputTokens:64e3},{pattern:/claude-sonnet-4/,maxOutputTokens:64e3},{pattern:/claude-opus-4/,maxOutputTokens:32e3},{pattern:/claude-3[-.]7-sonnet/,maxOutputTokens:64e3},{pattern:/claude-3[-.]5-/,maxOutputTokens:8192},{pattern:/claude-3-/,maxOutputTokens:4096},{pattern:/(^|[/-])gpt-[5-9]/,maxOutputTokens:128e3},{pattern:/(^|[/-])o1-mini/,maxOutputTokens:65536},{pattern:/(^|[/-])o1-preview/,maxOutputTokens:32768},{pattern:/(^|[/-])o[134](-|$)/,maxOutputTokens:1e5},{pattern:/(^|[/-])gpt-4\.1/,maxOutputTokens:32768},{pattern:/(^|[/-])gpt-4o/,maxOutputTokens:16384},{pattern:/(^|[/-])gpt-4-(turbo|vision|1106|0125)/,maxOutputTokens:4096},{pattern:/(^|[/-])gpt-4(-|$)/,maxOutputTokens:8192},{pattern:/(^|[/-])gpt-3\.5/,maxOutputTokens:4096},{pattern:/gemini-(2\.5|[3-9])/,maxOutputTokens:65536},{pattern:/gemini-(1\.5|2\.0)/,maxOutputTokens:8192},{pattern:/^deepseek-(flash|v4)/,maxOutputTokens:384e3},{pattern:/^glm-4\.6v/,maxOutputTokens:32e3},{pattern:/^glm-(5|4\.7|4\.6)/,maxOutputTokens:128e3},{pattern:/^glm-4\.5/,maxOutputTokens:96e3},{pattern:/^glm-4\.1v/,maxOutputTokens:16e3},{pattern:/^glm-4-long/,maxOutputTokens:4e3},{pattern:/^glm-4v-flash/,maxOutputTokens:1e3},{pattern:/^glm-4-flash/,maxOutputTokens:16e3},{pattern:/^doubao-seed-character/,maxOutputTokens:32e3},{pattern:/^doubao-seed-(evolving|2-1)/,maxOutputTokens:256e3},{pattern:/^doubao-seed-2-0/,maxOutputTokens:128e3},{pattern:/^minimax-m3/,maxOutputTokens:128e3},{pattern:/^kimi-k3/,maxOutputTokens:131072},{pattern:/^qwen3\.8-max/,maxOutputTokens:128e3}],n=(0,r.f)("ai:truncation"),a="AI_OUTPUT_TRUNCATED",o=new Map;function l(e){let t=e?.trim().toLowerCase();return(t?o.get(t):void 0)??function(e){let t=(e||"").trim().toLowerCase();if(t)return s.find(e=>e.pattern.test(t))?.maxOutputTokens}(t)}function c(e){let t=e?.choices?.[0];return!!t&&"length"===t.finish_reason&&!(t.message?.content||"").trim()}async function u(e,t,r){try{return{response:await e(t),limit:t}}catch(u){let s=(0,i.Z)(u),a=function(e,t){if(!/max[_ ]?(completion[_ ]?|output[_ ]?)?tokens|output tokens|completion tokens/i.test(e))return;let i=(e.match(/\d+/g)||[]).map(Number).filter(e=>Number.isSafeInteger(e)&&e>=1024&&e<t);return i.length>0?Math.max(...i):void 0}(s,t),l=a??(/max[_ ]?(completion[_ ]?|output[_ ]?)?tokens/i.test(s)&&t>32768?32768:void 0);if(!l)throw u;let c=r?.trim().toLowerCase();return c&&a&&o.set(c,a),n.warn({model:r,requested:t,adjusted:l},"max_tokens exceeds model limit, retrying with model limit"),{response:await e(l),limit:l}}}async function h(e,t,i,r){var s;let n=l(r),o=await u(e,n?Math.min(t,n):t,r);if(s=o.response,s?.choices?.[0]?.finish_reason!=="length")return o.response;let h=l(r)??65536;if(o.limit>=h){if(c(o.response))throw Error(a);return o.response}i?.();let d=await u(e,h,r);if(c(d.response))throw Error(a);return d.response}e.s(["z",0,a,"V",0,h],93716),e.s(["f",0,function(e){let t=e.questionText.replace(/[((【\[]\s*(?:(?:本题|共|满分)\s*)?\d+(?:\.\d+)?\s*(?:分|points?|marks?|pts?\.?)\s*[))】\]]/giu,"").replace(/^\s*(?:#{1,6}\s*)?(?:第\s*\d+\s*题\s*[::.、]?|(?:Question|Problem)\s*\d+\s*[::.、]?|\d+\s*(?:[、.]|\.(?!\d)))\s*/iu,"").trim(),i=/^\s*(?:[-*]\s*)?(?:[A-DA-D][..、::))]|[((][A-DA-D][))])\s*\S/imu.test(t),r=t.match(/(?:^|\s)(?:[A-DA-D][..、::))]|[((][A-DA-D][))])/giu)||[],s=/(?:下列|以下|选择|答案|哪项|哪一|正确的是|正确的是)/u.test(t),n=t.match(/[①②③④⑤⑥⑦⑧⑨⑩][^①②③④⑤⑥⑦⑧⑨⑩]*/gu)||[],a=!(n.length<2)&&(!!s||!!(n.length>=4));if(!t||i||r.length>=2||a)throw Error("AI_RESPONSE_ERROR: 生成题目必须为不含选项的填空题或解答题");return{...e,questionText:t}}],115851);var d=e.i(999617);let p={数学:"prefetchedMathTags",物理:"prefetchedPhysicsTags",化学:"prefetchedChemistryTags",生物:"prefetchedBiologyTags",英语:"prefetchedEnglishTags"};e.s(["f",0,function(e,t){let i=t.candidateTags?.tags;if(!t.candidateTags){let r=p[e.subject];if(r)i=t[r];else{let e=Object.values(p).flatMap(e=>t[e]?[t[e]]:[]);i=e.length?e.flat():void 0}}let r=i?new Set(i):null,s=[...new Set(e.knowledgePoints.map(e=>e.trim()).filter(e=>e&&(!r||r.has(e))))].slice(0,d.e);return{...e,knowledgePoints:s}}],907240)},999617,e=>{var t=e.i(971724),i=e.i(105954),r=e.i(604147),s=e.i(455744),n=e.i(180473),a=e.i(206033),o=e.i(562810),o=o,l=e.i(140561),c=o,u=e.i(819428),h=e.i(215267);let d=t.z.object({questionText:i.z.string().min(1,"题目文本不能为空"),answerText:i.z.string().min(1,"答案不能为空"),analysis:i.z.string().min(1,"解析不能为空"),wrongAnswerText:i.z.string().optional().default(""),mistakeAnalysis:i.z.string().optional().default(""),mistakeStatus:r.z.enum(["not_attempted","wrong_attempt","unknown"]).optional().default("unknown"),subject:r.z.enum(["数学","物理","化学","生物","英语","语文","历史","地理","政治","其他"]),knowledgePoints:s.z.array(i.z.string()).max(5,"知识点最多 5 个"),requiresImage:n.z.boolean().optional().default(!1),difficultyStars:a.z.number().int().min(1).max(5).nullable().optional(),gradeSemester:i.z.string().max(100).nullable().optional(),hasFigure:n.z.boolean().optional(),figureSvg:i.z.string().nullable().optional()}),p=t.z.object({probability:o.coerce.number().min(0).max(100),reason:i.z.string().trim().min(1).max(500)});function _(e){let t=e.trim(),i=t.match(/```(?:json)?\s*([\s\S]*?)```/);i&&(t=i[1].trim());let r=t.indexOf("{"),s=t.lastIndexOf("}");return -1!==r&&s>r&&(t=t.substring(r,s+1)),JSON.parse(t)}let f=t.z.object({correct:l.z.union([n.z.boolean(),r.z.enum(["true","false"]).transform(e=>"true"===e)]),reason:i.z.string().trim().min(1).max(500)});function g(e){let t;if("number"==typeof e)t=e;else{if("string"!=typeof e)return null;let i=e.trim(),r=(i.match(/[★⭐]/gu)||[]).length,s=i.match(/\d+(\.\d+)?/);t=r>0&&!s?r:s?Number(s[0]):0/0}if(!Number.isFinite(t))return null;let i=Math.round(t);return i>=1&&i<=5?i:null}e.s(["e",0,5,"F",0,_,"G",0,function(e){let t=d.shape.subject.safeParse(e?.trim());return t.success?t.data:void 0},"o",0,function(e){return f.parse(_(e))},"B",0,g,"t",0,function(e,t){let i=(0,u.W)(t);return{hasFigure:e?.trim().toLowerCase()==="true"||null!==i,figureSvg:i}},"b",0,function(e){let r=t.z.object({gradeSemester:i.z.string().nullable()}).parse(_(e));return(0,h.X)(r.gradeSemester)},"r",0,function(e){let t=p.parse(_(e));return{probability:Math.round(t.probability)/100,reason:t.reason}},"K",0,function(e,r){let n=t.z.object({tags:s.z.array(i.z.string()),difficultyStars:c.unknown().optional()}).parse(_(e)),a=new Set(r),o=[];for(let e of n.tags.map(e=>e.trim()))a.has(e)&&!o.includes(e)&&o.push(e);return{tags:o.slice(0,5),difficultyStars:g(n.difficultyStars)}},"u",0,function(e){return d.safeParse(e)}],999617)},459398,e=>{var t=e.i(698043),i=e.i(50377),r=e.i(668426);let s=(0,i.f)("ai:tag-service");async function n(e,i="default"){let r={1:["一年级"],2:["二年级"],3:["三年级"],4:["四年级"],5:["五年级"],6:["六年级"],7:["七年级上","七年级下"],8:["八年级上","八年级下"],9:["九年级上","九年级下"],10:["高一上","高一下"],11:["高二上","高二下"],12:["高三上","高三下","高三"]},a=[];if(e)if(e<=6)for(let t=1;t<=e;t++)a.push(...r[t]);else if(e>=7&&e<=9)for(let t=7;t<=e;t++)a.push(...r[t]||[]);else for(let t=10;t<=e;t++)a.push(...r[t]||[]);else for(let e=7;e<=12;e++)a.push(...r[e]);try{let e=(await t.f.knowledgeTag.findMany({where:{subject:"math",parentId:null,tagSet:i,name:{in:a}},select:{id:!0}})).map(e=>e.id),r=await t.f.knowledgeTag.findMany({where:{subject:"math",isSystem:!0,tagSet:i},select:{id:!0,name:!0,parentId:!0}}),s=new Map;r.forEach(e=>{if(e.parentId){let t=s.get(e.parentId)||[];t.push(e.id),s.set(e.parentId,t)}});let n=e=>{let t=s.get(e)||[];return 0===t.length?[e]:t.flatMap(e=>n(e))},o=new Set;e.forEach(e=>{n(e).forEach(e=>o.add(e))});let l=new Map(r.map(e=>[e.id,e.name]));return Array.from(o).map(e=>l.get(e)).filter(e=>!!e)}catch(e){return s.error({error:e},"getMathTagsFromDB error"),[]}}async function a(e,i="default"){try{return(await t.f.knowledgeTag.findMany({where:{subject:e,isSystem:!0,tagSet:i,children:{none:{}}},select:{name:!0},orderBy:{order:"asc"}})).map(e=>e.name)}catch(e){return s.error({error:e},"getTagsFromDB error"),[]}}async function o(e,i,n="default"){try{let s=await t.f.knowledgeTag.findMany({where:{subject:e,isSystem:!0,tagSet:n},select:{id:!0,name:!0,parentId:!0},orderBy:[{order:"asc"},{createdAt:"asc"}]}),a=new Map;for(let e of s)if(e.parentId){let t=a.get(e.parentId)||[];t.push(e),a.set(e.parentId,t)}let o=new Set,l=e=>{let t=a.get(e.id);t?.length?t.forEach(l):o.add(e.name)};return s.filter(e=>!e.parentId&&(0,r.U)(e.name,i)).forEach(l),Array.from(o)}catch(t){return s.error({error:t,subject:e,stage:i,tagSet:n},"getScopeTagsFromDB error"),[]}}async function l(e,t="default"){if(e.subject)return{subjectName:r.L[e.subject],tags:await o(e.subject,e.stage,t)}}async function c(e,t,i="default"){return{prefetchedMathTags:"数学"!==e&&e?[]:await n(t||null,i),prefetchedPhysicsTags:"物理"!==e&&e?[]:await a("physics",i),prefetchedChemistryTags:"化学"!==e&&e?[]:await a("chemistry",i),prefetchedBiologyTags:"生物"!==e&&e?[]:await a("biology",i),prefetchedEnglishTags:"英语"!==e&&e?[]:await a("english",i)}}e.s(["v",0,n,"K",0,l,"e",0,o,"i",0,c])},215267,539811,e=>{var t=e.i(376025);function i(e,r,s=new Date,n="en",a=t.J){let o=(0,t.c)(s,a),l=o.getFullYear(),c=o.getMonth()+1,u=l-r,h="2nd";c>=9?(u+=1,h="1st"):h=c<2?"1st":"2nd";let d="zh"===n,p=d?"1st"===h?"上期":"下期":"1st"===h?"1st Semester":"2nd Semester",_=(d?{primary:["一年级","二年级","三年级","四年级","五年级","六年级"],junior_high:["初一","初二","初三"],senior_high:["高一","高二","高三"],university:["大一","大二","大三","大四"]}:{primary:["Grade 1","Grade 2","Grade 3","Grade 4","Grade 5","Grade 6"],junior_high:["Junior High Grade 1","Junior High Grade 2","Junior High Grade 3"],senior_high:["Senior High Grade 1","Senior High Grade 2","Senior High Grade 3"],university:["Freshman","Sophomore","Junior","Senior"]})[e]||[],f=`${u}`;if(f=u>0&&u<=_.length?_[u-1]:u>_.length?d?"已毕业":"Graduated":d?"学前":"Pre-school",!d)return`${f}, ${p}`;{let e="1st"===h?"上":"下";return`${f}${e}`}}e.s(["f",0,i],539811);var r=e.i(411706);function s(e){if("string"!=typeof e)return null;let t=e.trim();return r.H.includes(t)?t:null}function n(e,r=t.J){return"ai"===e.gradeRecognitionMode?null:e.fixedGradeSemester?e.fixedGradeSemester:e.educationStage&&e.enrollmentYear?i(e.educationStage,e.enrollmentYear,new Date,"zh",r):null}e.s(["K",0,["fixed","ai"],"L",0,n,"Z",0,function(e,i=t.J){let s=n(e,i),a=s?r.T.findIndex(e=>s.startsWith(e)):-1;return{grade:a>=0&&a<12?a+1:null,gradeSemester:s}},"P",0,function(e,t){return"ai"===e.gradeRecognitionMode&&void 0===t.gradeSemester&&void 0===t.recognizedGradeSemester&&!!t.questionText?.trim()},"X",0,s,"S",0,function(e,i,r=t.J){return void 0!==i.gradeSemester?i.gradeSemester?.trim()||null:"ai"===e.gradeRecognitionMode?s(i.recognizedGradeSemester):n(e,r)}],215267)},481183,e=>{function t(e){let t=e.length;for(;t>0&&"/"===e[t-1];)t--;return e.slice(0,t)}e.s(["$",0,function(e){let i;try{i=new URL(e)}catch{throw Error(`Invalid base URL: ${e}`)}if("http:"!==i.protocol&&"https:"!==i.protocol)throw Error(`Base URL must use http or https: ${e}`);return t(i.toString())},"z",0,t])}],426900,(e,t,i)=>{!function(i,r){var s={};r(s);var n=s.default;for(var a in s)n[a]=s[a];if("object"==typeof t.exports)t.exports=n;else if("function"==typeof define&&define.amd)e.r,void 0!==n&&e.v(n);else i.sha256=n}(e.e,function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2]);function i(e,i,r,s,n){for(var a,o,l,c,u,h,d,p,_,f,g,m,v;n>=64;){for(a=i[0],o=i[1],l=i[2],c=i[3],u=i[4],h=i[5],d=i[6],p=i[7],f=0;f<16;f++)g=s+4*f,e[f]=(255&r[g])<<24|(255&r[g+1])<<16|(255&r[g+2])<<8|255&r[g+3];for(f=16;f<64;f++)m=((_=e[f-2])>>>17|_<<15)^(_>>>19|_<<13)^_>>>10,v=((_=e[f-15])>>>7|_<<25)^(_>>>18|_<<14)^_>>>3,e[f]=(m+e[f-7]|0)+(v+e[f-16]|0);for(f=0;f<64;f++)m=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&h^~u&d)|0)+(p+(t[f]+e[f]|0)|0)|0,v=((a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10))+(a&o^a&l^o&l)|0,p=d,d=h,h=u,u=c+m|0,c=l,l=o,o=a,a=m+v|0;i[0]+=a,i[1]+=o,i[2]+=l,i[3]+=c,i[4]+=u,i[5]+=h,i[6]+=d,i[7]+=p,s+=64,n-=64}return s}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]=0x6a09e667,this.state[1]=0xbb67ae85,this.state[2]=0x3c6ef372,this.state[3]=0xa54ff53a,this.state[4]=0x510e527f,this.state[5]=0x9b05688c,this.state[6]=0x1f83d9ab,this.state[7]=0x5be0cd19,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(void 0===t&&(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--;64===this.bufferLength&&(i(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(t>=64&&(r=i(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,s=t/0x20000000|0,n=t<<3,a=t%64<56?64:128;this.buffer[r]=128;for(var o=r+1;o<a-8;o++)this.buffer[o]=0;this.buffer[a-8]=s>>>24&255,this.buffer[a-7]=s>>>16&255,this.buffer[a-6]=s>>>8&255,this.buffer[a-5]=s>>>0&255,this.buffer[a-4]=n>>>24&255,this.buffer[a-3]=n>>>16&255,this.buffer[a-2]=n>>>8&255,this.buffer[a-1]=n>>>0&255,i(this.temp,this.state,this.buffer,0,a),this.finished=!0}for(var o=0;o<8;o++)e[4*o+0]=this.state[o]>>>24&255,e[4*o+1]=this.state[o]>>>16&255,e[4*o+2]=this.state[o]>>>8&255,e[4*o+3]=this.state[o]>>>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 i=0;i<this.state.length;i++)this.state[i]=e[i];this.bytesHashed=t,this.finished=!1,this.bufferLength=0},t}();e.Hash=r;var s=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 i=0;i<e.length;i++)t[i]=e[i];for(var i=0;i<t.length;i++)t[i]^=54;this.inner.update(t);for(var i=0;i<t.length;i++)t[i]^=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 i=0;i<t.length;i++)t[i]=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}();function n(e){var t=new r().update(e),i=t.digest();return t.clean(),i}function a(e,t){var i=new s(e).update(t),r=i.digest();return i.clean(),r}e.HMAC=s,e.hash=n,e.default=n,e.hmac=a;var o=new Uint8Array(e.digestLength);e.hkdf=function(e,t,i,r){void 0===t&&(t=o),void 0===r&&(r=32);for(var n=new Uint8Array([1]),l=new s(a(t,e)),c=new Uint8Array(l.digestLength),u=c.length,h=new Uint8Array(r),d=0;d<r;d++)u===c.length&&(!function(e,t,i,r){var s=r[0];if(0===s)throw Error("hkdf: cannot expand more");t.reset(),s>1&&t.update(e),i&&t.update(i),t.update(r),t.finish(e),r[0]++}(c,l,i,n),u=0),h[d]=c[u++];return l.clean(),c.fill(0),n.fill(0),h},e.pbkdf2=function(e,t,i,r){for(var n=new s(e),a=n.digestLength,o=new Uint8Array(4),l=new Uint8Array(a),c=new Uint8Array(a),u=new Uint8Array(r),h=0;h*a<r;h++){var d=h+1;o[0]=d>>>24&255,o[1]=d>>>16&255,o[2]=d>>>8&255,o[3]=d>>>0&255,n.reset(),n.update(t),n.update(o),n.finish(c);for(var p=0;p<a;p++)l[p]=c[p];for(var p=2;p<=i;p++){n.reset(),n.update(c).finish(c);for(var _=0;_<a;_++)l[_]^=c[_]}for(var p=0;p<a&&h*a+p<r;p++)u[h*a+p]=l[p]}for(var h=0;h<a;h++)l[h]=c[h]=0;for(var h=0;h<4;h++)o[h]=0;return n.clean(),u}})}];
|
|
5
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),nS.includes(s.model)&&s.thinking&&"enabled"===s.thinking.type&&console.warn(`Using Claude with ${s.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 n=t?.timeout??this._client._options.timeout;if(!s.stream&&null==n){let e=nw[s.model]??void 0;n=this._client.calculateNonstreamingTimeout(s.max_tokens,e)}let a=nl(e,t),o=this._client._tracer&&rC(this._client,"anthropic.messages.create",t,sz(this._client,s,a));sS(this._client,o,s);let l=this._client.post("/v1/messages",{body:s,timeout:n??6e5,...t,__span:o,headers:a,stream:e.stream??!1});return o?l._thenUnwrap(e=>(sx(this._client,o,s,e),e)):l}parse(e,t){return this.create(e,t).then(t=>nh(t,e,{logger:this._client.logger??console}))}stream(e,t){return nf.createMessage(this,e,t,{logger:this._client.logger??console,client:this._client})}countTokens(e,t){let{user_profile_id:i,workspace_id:r,...s}=e,n=rR([{...null!=i?{"anthropic-user-profile-id":i}:void 0,...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),a=rC(this._client,"anthropic.messages.count_tokens",t,{route:"/v1/messages/count_tokens",attributes:{[so]:s.model}}),o=this._client.post("/v1/messages/count_tokens",{body:s,...t,__span:a,headers:n});return a?o._thenUnwrap(e=>(sV(this._client,a,e),e)):o}}return e.Batches=ny,e})();let nz={"claude-sonnet-4-5":"November 30th, 2026","claude-sonnet-4-5-20250929":"November 30th, 2026"},nS=["claude-mythos-preview","claude-opus-4-6"];class nx extends ne{retrieve(e,t={},i){let{workspace_id:r}=t??{};return this._client.get(nb`/v1/models/${e}`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.models.retrieve",i,{route:"/v1/models/{model_id}",attributes:{"anthropic.model.id":e}})})}list(e={},t){let{workspace_id:i,...r}=e??{};return this._client.getAPIList("/v1/models",s6,{query:r,...t,headers:rR([{...null!=i?{"anthropic-workspace-id":i}:void 0},t?.headers]),__span:rC(this._client,"anthropic.models.list",t,{route:"/v1/models",queryParams:["after_id","before_id","lifecycle","limit"]})})}}class nV extends ne{list(e={},t){let{workspace_id:i,...r}=e??{};return this._client.getAPIList("/v1/files",s4,{query:r,...t,headers:rR([{...null!=i?{"anthropic-workspace-id":i}:void 0},t?.headers]),__span:rC(this._client,"anthropic.files.list",t,{route:"/v1/files",queryParams:["ids","limit","page"]})})}delete(e,t={},i){let{workspace_id:r}=t??{};return this._client.delete(nb`/v1/files/${e}`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.files.delete",i,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":e}})})}download(e,t={},i){let{workspace_id:r}=t??{};return this._client.get(nb`/v1/files/${e}/content`,{...i,headers:rR([{Accept:"application/binary",...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__binaryResponse:!0,__span:rC(this._client,"anthropic.files.download",i,{route:"/v1/files/{file_id}/content",attributes:{"anthropic.file.id":e}})})}retrieveMetadata(e,t={},i){let{workspace_id:r}=t??{};return this._client.get(nb`/v1/files/${e}`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.files.retrieve_metadata",i,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":e}})})}upload(e,t){let{workspace_id:i,...r}=e;return this._client.post("/v1/files",sG({body:r,...t,headers:rR([{...null!=i?{"anthropic-workspace-id":i}:void 0},no(r.file),t?.headers]),__span:rC(this._client,"anthropic.files.upload",t,{route:"/v1/files",createdIDAttribute:"anthropic.file.id"})},this._client))}}class nA extends ne{create(e,t,i){let{workspace_id:r,...s}=t;return this._client.post(nb`/v1/skills/${e}/versions`,sG({body:s,...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.skills.versions.create",i,{route:"/v1/skills/{skill_id}/versions",attributes:{"anthropic.skill.id":e},createdIDAttribute:"anthropic.skill.version.id"})},this._client,!1))}retrieve(e,t,i){let{skill_id:r,workspace_id:s}=t;return this._client.get(nb`/v1/skills/${r}/versions/${e}`,{...i,headers:rR([{...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:rC(this._client,"anthropic.skills.versions.retrieve",i,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":r,"anthropic.skill.version.id":e}})})}list(e,t={},i){let{workspace_id:r,...s}=t??{};return this._client.getAPIList(nb`/v1/skills/${e}/versions`,s4,{query:s,...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.skills.versions.list",i,{route:"/v1/skills/{skill_id}/versions",queryParams:["limit","page"],attributes:{"anthropic.skill.id":e}})})}delete(e,t,i){let{skill_id:r,workspace_id:s}=t;return this._client.delete(nb`/v1/skills/${r}/versions/${e}`,{...i,headers:rR([{...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:rC(this._client,"anthropic.skills.versions.delete",i,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":r,"anthropic.skill.version.id":e}})})}}var nI=(()=>{class e extends ne{constructor(){super(...arguments),this.versions=new nA(this._client)}create(e,t){let{workspace_id:i,...r}=e;return this._client.post("/v1/skills",sG({body:r,...t,headers:rR([{...null!=i?{"anthropic-workspace-id":i}:void 0},t?.headers]),__span:rC(this._client,"anthropic.skills.create",t,{route:"/v1/skills",createdIDAttribute:"anthropic.skill.id"})},this._client,!1))}retrieve(e,t={},i){let{workspace_id:r}=t??{};return this._client.get(nb`/v1/skills/${e}`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.skills.retrieve",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}list(e={},t){let{workspace_id:i,...r}=e??{};return this._client.getAPIList("/v1/skills",s4,{query:r,...t,headers:rR([{...null!=i?{"anthropic-workspace-id":i}:void 0},t?.headers]),__span:rC(this._client,"anthropic.skills.list",t,{route:"/v1/skills",queryParams:["limit","page","source"]})})}delete(e,t={},i){let{workspace_id:r}=t??{};return this._client.delete(nb`/v1/skills/${e}`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.skills.delete",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}}return e.Versions=nA,e})();class nq extends ne{create(e,t,i){let{workspace_id:r,...s}=t;return this._client.post(nb`/v1/user_profiles/${e}/action_urls`,{body:s,...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.user_profiles.action_urls.create",i,{route:"/v1/user_profiles/{user_profile_id}/action_urls",attributes:{"anthropic.user_profile.id":e}})})}}var n$=(()=>{class e extends ne{constructor(){super(...arguments),this.actionURLs=new nq(this._client)}create(e,t){let{workspace_id:i,...r}=e;return this._client.post("/v1/user_profiles",{body:r,...t,headers:rR([{...null!=i?{"anthropic-workspace-id":i}:void 0},t?.headers]),__span:rC(this._client,"anthropic.user_profiles.create",t,{route:"/v1/user_profiles",createdIDAttribute:"anthropic.user_profile.id"})})}retrieve(e,t={},i){let{workspace_id:r}=t??{};return this._client.get(nb`/v1/user_profiles/${e}`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.user_profiles.retrieve",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}update(e,t,i){let{workspace_id:r,...s}=t;return this._client.post(nb`/v1/user_profiles/${e}`,{body:s,...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.user_profiles.update",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}list(e={},t){let{workspace_id:i,...r}=e??{};return this._client.getAPIList("/v1/user_profiles",s4,{query:r,...t,headers:rR([{...null!=i?{"anthropic-workspace-id":i}:void 0},t?.headers]),__span:rC(this._client,"anthropic.user_profiles.list",t,{route:"/v1/user_profiles",queryParams:["enforcement_status","limit","order","order_by","page"]})})}delete(e,t={},i){let{workspace_id:r}=t??{};return this._client.delete(nb`/v1/user_profiles/${e}`,{...i,headers:rR([{...null!=r?{"anthropic-workspace-id":r}:void 0},i?.headers]),__span:rC(this._client,"anthropic.user_profiles.delete",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}}return e.ActionURLs=nq,e})();class nR extends ne{retrieve(e,t){return this._client.get(nb`/v1/organizations/api_keys/${e}`,{...t,__span:rC(this._client,"anthropic.organization.api_keys.retrieve",t,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/api_keys/${e}`,{body:t,...i,__span:rC(this._client,"anthropic.organization.api_keys.update",i,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/api_keys",s6,{query:e,...t,__span:rC(this._client,"anthropic.organization.api_keys.list",t,{route:"/v1/organizations/api_keys",queryParams:["after_id","before_id","created_by_user_id","limit","status","workspace_id"]})})}}class nP extends ne{retrieve(e){return this._client.get("/v1/organizations/compliance_settings",{...e,__span:rC(this._client,"anthropic.organization.compliance_settings.retrieve",e,{route:"/v1/organizations/compliance_settings"})})}update(e,t){return this._client.post("/v1/organizations/compliance_settings",{body:e,...t,__span:rC(this._client,"anthropic.organization.compliance_settings.update",t,{route:"/v1/organizations/compliance_settings"})})}}class nT extends ne{create(e,t){return this._client.post("/v1/organizations/external_keys",{body:e,...t,__span:rC(this._client,"anthropic.organization.external_keys.create",t,{route:"/v1/organizations/external_keys",createdIDAttribute:"anthropic.organization.external_key.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/external_keys/${e}`,{...t,__span:rC(this._client,"anthropic.organization.external_keys.retrieve",t,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/external_keys/${e}`,{body:t,...i,__span:rC(this._client,"anthropic.organization.external_keys.update",i,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/external_keys",s4,{query:e,...t,__span:rC(this._client,"anthropic.organization.external_keys.list",t,{route:"/v1/organizations/external_keys",queryParams:["limit","page"]})})}delete(e,t){return this._client.delete(nb`/v1/organizations/external_keys/${e}`,{...t,__span:rC(this._client,"anthropic.organization.external_keys.delete",t,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}validate(e,t){return this._client.post(nb`/v1/organizations/external_keys/${e}/validate`,{...t,__span:rC(this._client,"anthropic.organization.external_keys.validate",t,{route:"/v1/organizations/external_keys/{external_key_id}/validate",attributes:{"anthropic.organization.external_key.id":e}})})}}class nE extends ne{create(e,t){return this._client.post("/v1/organizations/invites",{body:e,...t,__span:rC(this._client,"anthropic.organization.invites.create",t,{route:"/v1/organizations/invites",createdIDAttribute:"anthropic.organization.invite.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/invites/${e}`,{...t,__span:rC(this._client,"anthropic.organization.invites.retrieve",t,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/invites",s6,{query:e,...t,__span:rC(this._client,"anthropic.organization.invites.list",t,{route:"/v1/organizations/invites",queryParams:["after_id","before_id","email","limit","roles","statuses"]})})}delete(e,t){return this._client.delete(nb`/v1/organizations/invites/${e}`,{...t,__span:rC(this._client,"anthropic.organization.invites.delete",t,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":e}})})}}class nO extends ne{list(e={},t){return this._client.getAPIList("/v1/organizations/rate_limits",s4,{query:e,...t,__span:rC(this._client,"anthropic.organization.rate_limits.list",t,{route:"/v1/organizations/rate_limits",queryParams:["group_type","limit","model","page"]})})}}class nM extends ne{retrieve(e,t){return this._client.get(nb`/v1/organizations/users/${e}`,{...t,__span:rC(this._client,"anthropic.organization.users.retrieve",t,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/users/${e}`,{body:t,...i,__span:rC(this._client,"anthropic.organization.users.update",i,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/users",s6,{query:e,...t,__span:rC(this._client,"anthropic.organization.users.list",t,{route:"/v1/organizations/users",queryParams:["after_id","before_id","email","limit","roles"]})})}remove(e,t){return this._client.delete(nb`/v1/organizations/users/${e}`,{...t,__span:rC(this._client,"anthropic.organization.users.remove",t,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}}class nL extends ne{create(e,t){return this._client.post("/v1/organizations/federation_issuers",{body:e,...t,__span:rC(this._client,"anthropic.organization.federation.issuers.create",t,{route:"/v1/organizations/federation_issuers",createdIDAttribute:"anthropic.organization.federation_issuer.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/federation_issuers/${e}`,{...t,__span:rC(this._client,"anthropic.organization.federation.issuers.retrieve",t,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/federation_issuers/${e}`,{body:t,...i,__span:rC(this._client,"anthropic.organization.federation.issuers.update",i,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/federation_issuers",s4,{query:e,...t,__span:rC(this._client,"anthropic.organization.federation.issuers.list",t,{route:"/v1/organizations/federation_issuers",queryParams:["include_archived","limit","page"]})})}archive(e,t){return this._client.post(nb`/v1/organizations/federation_issuers/${e}/archive`,{...t,__span:rC(this._client,"anthropic.organization.federation.issuers.archive",t,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}/archive",attributes:{"anthropic.organization.federation_issuer.id":e}})})}}class nC extends ne{list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/federation_rules/${e}/workspaces`,s4,{query:t,...i,__span:rC(this._client,"anthropic.organization.federation.rules.workspaces.list",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.federation_rule.id":e}})})}add(e,t,i){return this._client.post(nb`/v1/organizations/federation_rules/${e}/workspaces`,{body:t,...i,__span:rC(this._client,"anthropic.organization.federation.rules.workspaces.add",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",attributes:{"anthropic.organization.federation_rule.id":e},createdIDAttribute:"anthropic.organization.federation_rule.workspace.id",createdIDField:"workspace_id"})})}remove(e,t,i){let{federation_rule_id:r}=t;return this._client.delete(nb`/v1/organizations/federation_rules/${r}/workspaces/${e}`,{...i,__span:rC(this._client,"anthropic.organization.federation.rules.workspaces.remove",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.federation_rule.id":r,"anthropic.organization.federation_rule.workspace.id":e}})})}}var nN=(()=>{class e extends ne{constructor(){super(...arguments),this.workspaces=new nC(this._client)}create(e,t){return this._client.post("/v1/organizations/federation_rules",{body:e,...t,__span:rC(this._client,"anthropic.organization.federation.rules.create",t,{route:"/v1/organizations/federation_rules",createdIDAttribute:"anthropic.organization.federation_rule.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/federation_rules/${e}`,{...t,__span:rC(this._client,"anthropic.organization.federation.rules.retrieve",t,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/federation_rules/${e}`,{body:t,...i,__span:rC(this._client,"anthropic.organization.federation.rules.update",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/federation_rules",s4,{query:e,...t,__span:rC(this._client,"anthropic.organization.federation.rules.list",t,{route:"/v1/organizations/federation_rules",queryParams:["include_archived","issuer_id","limit","page"]})})}archive(e,t){return this._client.post(nb`/v1/organizations/federation_rules/${e}/archive`,{...t,__span:rC(this._client,"anthropic.organization.federation.rules.archive",t,{route:"/v1/organizations/federation_rules/{federation_rule_id}/archive",attributes:{"anthropic.organization.federation_rule.id":e}})})}}return e.Workspaces=nC,e})(),nj=(()=>{class e extends ne{constructor(){super(...arguments),this.issuers=new nL(this._client),this.rules=new nN(this._client)}}return e.Issuers=nL,e.Rules=nN,e})();class nD extends ne{list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/service_accounts/${e}/workspaces`,s4,{query:t,...i,__span:rC(this._client,"anthropic.organization.service_accounts.workspaces.list",i,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.service_account.id":e}})})}add(e,t,i){return this._client.post(nb`/v1/organizations/service_accounts/${e}/workspaces`,{body:t,...i,__span:rC(this._client,"anthropic.organization.service_accounts.workspaces.add",i,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",attributes:{"anthropic.organization.service_account.id":e},createdIDAttribute:"anthropic.organization.service_account.workspace.id",createdIDField:"workspace_id"})})}remove(e,t,i){let{service_account_id:r}=t;return this._client.delete(nb`/v1/organizations/service_accounts/${r}/workspaces/${e}`,{...i,__span:rC(this._client,"anthropic.organization.service_accounts.workspaces.remove",i,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.service_account.id":r,"anthropic.organization.service_account.workspace.id":e}})})}}var nW=(()=>{class e extends ne{constructor(){super(...arguments),this.workspaces=new nD(this._client)}create(e,t){return this._client.post("/v1/organizations/service_accounts",{body:e,...t,__span:rC(this._client,"anthropic.organization.service_accounts.create",t,{route:"/v1/organizations/service_accounts",createdIDAttribute:"anthropic.organization.service_account.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/service_accounts/${e}`,{...t,__span:rC(this._client,"anthropic.organization.service_accounts.retrieve",t,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/service_accounts/${e}`,{body:t,...i,__span:rC(this._client,"anthropic.organization.service_accounts.update",i,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/service_accounts",s4,{query:e,...t,__span:rC(this._client,"anthropic.organization.service_accounts.list",t,{route:"/v1/organizations/service_accounts",queryParams:["include_archived","limit","page"]})})}archive(e,t){return this._client.post(nb`/v1/organizations/service_accounts/${e}/archive`,{...t,__span:rC(this._client,"anthropic.organization.service_accounts.archive",t,{route:"/v1/organizations/service_accounts/{service_account_id}/archive",attributes:{"anthropic.organization.service_account.id":e}})})}}return e.Workspaces=nD,e})();class nU extends ne{retrieve(e,t,i){let{workspace_id:r}=t;return this._client.get(nb`/v1/organizations/workspaces/${r}/members/${e}`,{...i,__span:rC(this._client,"anthropic.organization.workspaces.members.retrieve",i,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.member.id":e}})})}update(e,t,i){let{workspace_id:r,...s}=t;return this._client.post(nb`/v1/organizations/workspaces/${r}/members/${e}`,{body:s,...i,__span:rC(this._client,"anthropic.organization.workspaces.members.update",i,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.member.id":e}})})}list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/workspaces/${e}/members`,s6,{query:t,...i,__span:rC(this._client,"anthropic.organization.workspaces.members.list",i,{route:"/v1/organizations/workspaces/{workspace_id}/members",queryParams:["after_id","before_id","limit"],attributes:{"anthropic.organization.workspace.id":e}})})}add(e,t,i){return this._client.post(nb`/v1/organizations/workspaces/${e}/members`,{body:t,...i,__span:rC(this._client,"anthropic.organization.workspaces.members.add",i,{route:"/v1/organizations/workspaces/{workspace_id}/members",attributes:{"anthropic.organization.workspace.id":e},createdIDAttribute:"anthropic.organization.workspace.member.id",createdIDField:"user_id"})})}remove(e,t,i){let{workspace_id:r}=t;return this._client.delete(nb`/v1/organizations/workspaces/${r}/members/${e}`,{...i,__span:rC(this._client,"anthropic.organization.workspaces.members.remove",i,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.member.id":e}})})}}class nF extends ne{update(e,t,i){let{workspace_id:r,...s}=t;return this._client.post(nb`/v1/organizations/workspaces/${r}/rate_limits/${e}`,{body:s,...i,__span:rC(this._client,"anthropic.organization.workspaces.rate_limits.update",i,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits/{rate_limit_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.rate_limit.id":e}})})}list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/workspaces/${e}/rate_limits`,s4,{query:t,...i,__span:rC(this._client,"anthropic.organization.workspaces.rate_limits.list",i,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits",queryParams:["group_type","include_inherited","limit","page"],attributes:{"anthropic.organization.workspace.id":e}})})}}class nH extends ne{retrieve(e,t,i){let{workspace_id:r}=t;return this._client.get(nb`/v1/organizations/workspaces/${r}/service_accounts/${e}`,{...i,__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.retrieve",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.service_account.id":e}})})}update(e,t,i){let{workspace_id:r,...s}=t;return this._client.post(nb`/v1/organizations/workspaces/${r}/service_accounts/${e}`,{body:s,...i,__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.update",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.service_account.id":e}})})}list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/workspaces/${e}/service_accounts`,s4,{query:t,...i,__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.list",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",queryParams:["limit","page"],attributes:{"anthropic.organization.workspace.id":e}})})}add(e,t,i){return this._client.post(nb`/v1/organizations/workspaces/${e}/service_accounts`,{body:t,...i,__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.add",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",attributes:{"anthropic.organization.workspace.id":e},createdIDAttribute:"anthropic.organization.workspace.service_account.id",createdIDField:"service_account_id"})})}remove(e,t,i){let{workspace_id:r}=t;return this._client.delete(nb`/v1/organizations/workspaces/${r}/service_accounts/${e}`,{...i,__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.remove",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.service_account.id":e}})})}}var nB=(()=>{class e extends ne{constructor(){super(...arguments),this.rateLimits=new nF(this._client),this.members=new nU(this._client),this.serviceAccounts=new nH(this._client)}create(e,t){return this._client.post("/v1/organizations/workspaces",{body:e,...t,__span:rC(this._client,"anthropic.organization.workspaces.create",t,{route:"/v1/organizations/workspaces",createdIDAttribute:"anthropic.organization.workspace.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/workspaces/${e}`,{...t,__span:rC(this._client,"anthropic.organization.workspaces.retrieve",t,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/workspaces/${e}`,{body:t,...i,__span:rC(this._client,"anthropic.organization.workspaces.update",i,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/workspaces",s6,{query:e,...t,__span:rC(this._client,"anthropic.organization.workspaces.list",t,{route:"/v1/organizations/workspaces",queryParams:["after_id","before_id","include_archived","include_default","limit"]})})}archive(e,t){return this._client.post(nb`/v1/organizations/workspaces/${e}/archive`,{...t,__span:rC(this._client,"anthropic.organization.workspaces.archive",t,{route:"/v1/organizations/workspaces/{workspace_id}/archive",attributes:{"anthropic.organization.workspace.id":e}})})}}return e.RateLimits=nF,e.Members=nU,e.ServiceAccounts=nH,e})(),nK=(()=>{class e extends ne{constructor(){super(...arguments),this.apiKeys=new nR(this._client),this.externalKeys=new nT(this._client),this.federation=new nj(this._client),this.invites=new nE(this._client),this.serviceAccounts=new nW(this._client),this.users=new nM(this._client),this.workspaces=new nB(this._client),this.rateLimits=new nO(this._client),this.complianceSettings=new nP(this._client)}retrieve(e){return this._client.get("/v1/organizations/me",{...e,__span:rC(this._client,"anthropic.organization.retrieve",e,{route:"/v1/organizations/me"})})}}return e.APIKeys=nR,e.ExternalKeys=nT,e.Federation=nj,e.Invites=nE,e.ServiceAccounts=nW,e.Users=nM,e.Workspaces=nB,e.RateLimits=nO,e.ComplianceSettings=nP,e})();class nJ extends ne{retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/deployment_runs/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployment_runs.retrieve",i,{route:"/v1/deployment_runs/{deployment_run_id}",attributes:{"anthropic.deployment_run.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/deployment_runs",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployment_runs.list",t,{route:"/v1/deployment_runs",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","deployment_id","has_error","limit","page","trigger_type"]})})}}class nG extends ne{create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/deployments",{body:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployments.create",t,{route:"/v1/deployments",createdIDAttribute:"anthropic.deployment.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/deployments/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployments.retrieve",i,{route:"/v1/deployments/{deployment_id}",attributes:{"anthropic.deployment.id":e}})})}update(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/deployments/${e}`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployments.update",i,{route:"/v1/deployments/{deployment_id}",attributes:{"anthropic.deployment.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/deployments",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployments.list",t,{route:"/v1/deployments",queryParams:["agent_id","created_at[gte]","created_at[lte]","include_archived","limit","page","status"]})})}archive(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/deployments/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployments.archive",i,{route:"/v1/deployments/{deployment_id}/archive",attributes:{"anthropic.deployment.id":e}})})}pause(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/deployments/${e}/pause`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployments.pause",i,{route:"/v1/deployments/{deployment_id}/pause",attributes:{"anthropic.deployment.id":e}})})}run(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/deployments/${e}/run`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployments.run",i,{route:"/v1/deployments/{deployment_id}/run",attributes:{"anthropic.deployment.id":e}})})}unpause(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/deployments/${e}/unpause`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.deployments.unpause",i,{route:"/v1/deployments/{deployment_id}/unpause",attributes:{"anthropic.deployment.id":e}})})}}class nX extends ne{create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/dreams",{body:s,...t,headers:rR([{"anthropic-beta":[...i??[],"dreaming-2026-04-21"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.dreams.create",t,{route:"/v1/dreams",createdIDAttribute:"anthropic.dream.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/dreams/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"dreaming-2026-04-21"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.dreams.retrieve",i,{route:"/v1/dreams/{dream_id}",attributes:{"anthropic.dream.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/dreams",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"dreaming-2026-04-21"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.dreams.list",t,{route:"/v1/dreams",queryParams:["created_at[gt]","created_at[lt]","include_archived","limit","page","statuses"]})})}archive(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/dreams/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...r??[],"dreaming-2026-04-21"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.dreams.archive",i,{route:"/v1/dreams/{dream_id}/archive",attributes:{"anthropic.dream.id":e}})})}cancel(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/dreams/${e}/cancel`,{...i,headers:rR([{"anthropic-beta":[...r??[],"dreaming-2026-04-21"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.dreams.cancel",i,{route:"/v1/dreams/{dream_id}/cancel",attributes:{"anthropic.dream.id":e}})})}}class nQ extends ne{list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/files",s4,{query:s,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.files.list",t,{route:"/v1/files",queryParams:["ids","limit","page","scope_id"]})})}delete(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.delete(nb`/v1/files/${e}`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.files.delete",i,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":e}})})}download(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/files/${e}/content`,{...i,headers:rR([{Accept:"application/binary",...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__binaryResponse:!0,__span:rC(this._client,"anthropic.files.download",i,{route:"/v1/files/{file_id}/content",attributes:{"anthropic.file.id":e}})})}retrieveMetadata(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/files/${e}`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.files.retrieve_metadata",i,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":e}})})}upload(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/files",sG({body:s,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...null!=r?{"anthropic-workspace-id":r}:void 0},no(s.file),t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.files.upload",t,{route:"/v1/files",createdIDAttribute:"anthropic.file.id"})},this._client))}}class nY extends ne{retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/models/${e}`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.models.retrieve",i,{route:"/v1/models/{model_id}",attributes:{"anthropic.model.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/models",s6,{query:s,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.models.list",t,{route:"/v1/models",queryParams:["after_id","before_id","lifecycle","limit"]})})}}var nZ=e.i(305518);class n0 extends ne{parseUnverified(e){return JSON.parse(e)}unwrap(e,t){let i=t?.headers;if(null==i)throw Error("Webhook headers are required in order to verify the signature");let r=void 0===t.key?this._client.webhookKey:t.key;if(!r)throw Error("Webhook key must not be null or empty in order to unwrap");return new nZ.Webhook(r).verify(e,i),JSON.parse(e)}}class n1 extends ne{list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/agents/${e}/versions`,s4,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.agents.versions.list",i,{route:"/v1/agents/{agent_id}/versions",queryParams:["limit","page"],attributes:{"gen_ai.agent.id":e}})})}}var n2=(()=>{class e extends ne{constructor(){super(...arguments),this.versions=new n1(this._client)}create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/agents",{body:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.agents.create",t,{route:"/v1/agents",createdIDAttribute:"gen_ai.agent.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.get(nb`/v1/agents/${e}`,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.agents.retrieve",i,{route:"/v1/agents/{agent_id}",queryParams:["version"],attributes:{"gen_ai.agent.id":e}})})}update(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/agents/${e}`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.agents.update",i,{route:"/v1/agents/{agent_id}",attributes:{"gen_ai.agent.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/agents",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.agents.list",t,{route:"/v1/agents",queryParams:["created_at[gte]","created_at[lte]","include_archived","limit","page"]})})}archive(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/agents/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.agents.archive",i,{route:"/v1/agents/{agent_id}/archive",attributes:{"gen_ai.agent.id":e}})})}}return e.Versions=n1,e})();let n6=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return n6=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),i=e?()=>e.getRandomValues(t)[0]:()=>255*Math.random()&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^i()&15>>e/4).toString(16))};function n4(e,t){if(!e)return()=>{};if(e.aborted)return t.abort(),()=>{};let i=()=>t.abort();return e.addEventListener("abort",i),()=>e.removeEventListener("abort",i)}var n5=e.i(198156);function n8(e,{authToken:t,helper:i}){if(!t)throw new ry.v(`copyClientForHelper: expected a non-empty authToken but received ${JSON.stringify(t)}`);let r=e._options.defaultHeaders,s=e._authState?.extraHeaders,n=rR([s?Object.fromEntries(Object.entries(s).filter(([e])=>{let t=e.toLowerCase();return"authorization"!==t&&"x-api-key"!==t})):void 0,r,{[nt]:i}]);return n.values.delete("x-api-key"),n.values.delete("authorization"),n.nulls.delete("authorization"),e.withOptions({authToken:t,baseURL:e.baseURL,defaultHeaders:n})}function n3(e,t){e?.isRecording()&&(t.aborted||e.setStatus({code:rb.OK}),e.end())}function n9(e,t,i){e?.isRecording()&&(t.aborted||rW(e,i),e.end())}async function n7(e,t,i,r){if(!t)return r();try{await iJ.with(rm.setSpan(iJ.active(),t),r)}catch(r){throw rL(e,()=>n9(t,i,r)),r}rL(e,()=>n3(t,i))}var ae=(()=>{class e{constructor(e){let t,i;C.set(this,void 0),N.set(this,!1),j.set(this,void 0),D.set(this,void 0),W.set(this,void 0),U.set(this,void 0),F.set(this,void 0),H.set(this,void 0),B.set(this,void 0),this.client=e.client,this.environmentId=e.environmentId,this.environmentKey=e.environmentKey,this.workerId=e.workerId??(t=globalThis.process?.env,(i=t?.HOSTNAME)?`${i}-${n6()}`:n6()),(0,id.b)(this,C,n8(e.client,{authToken:e.environmentKey,helper:"environments-work-poller"}),"f"),(0,id.b)(this,W,e.autoStop??!0,"f"),(0,id.b)(this,U,e.drain??!1,"f"),(0,id.b)(this,F,void 0===e.blockMs?999:e.blockMs,"f"),(0,id.b)(this,H,e.reclaimOlderThanMs??null,"f"),(0,id.b)(this,B,e.requestOptions,"f"),(0,id.b)(this,j,new AbortController,"f"),(0,id.b)(this,D,n4(e.signal,(0,id.V)(this,j,"f")),"f")}get signal(){return(0,id.V)(this,j,"f").signal}abort(){(0,id.V)(this,j,"f").abort()}async *[(C=new WeakMap,N=new WeakMap,j=new WeakMap,D=new WeakMap,W=new WeakMap,U=new WeakMap,F=new WeakMap,H=new WeakMap,B=new WeakMap,Symbol.asyncIterator)](){if((0,id.V)(this,N,"f"))throw new ry.v("Cannot iterate over a consumed WorkPoller");(0,id.b)(this,N,!0,"f");let e=iJ.active(),t=(0,rz.u)(this.client);t.info("poller starting",{component:"work-poller",environment_id:this.environmentId});let i=new at(t,this.environmentId);try{let s=0;for(;!(0,id.V)(this,j,"f").signal.aborted;){let n;try{n=await (0,id.V)(this,C,"f").beta.environments.work.poll(this.environmentId,{"Anthropic-Worker-ID":this.workerId,...null!==(0,id.V)(this,F,"f")?{block_ms:(0,id.V)(this,F,"f")}:{},...null!==(0,id.V)(this,H,"f")?{reclaim_older_than_ms:(0,id.V)(this,H,"f")}:{}},{headers:rR([(0,id.V)(this,B,"f")?.headers]),signal:(0,id.V)(this,j,"f").signal})}catch(i){var r;if((0,id.V)(this,j,"f").signal.aborted)return;if((0,n5.d)(i))throw t.error("poll failed permanently, stopping poller",{error:String(i)}),i;let e=(0,n5.o)((r=s,(0,n5.J)(r,1e3,6e4)));t.warn("poll failed, backing off",{error:String(i),backoff_ms:e}),s++,await i_(e,(0,id.V)(this,j,"f").signal);continue}if(s=0,null==n){if((0,id.V)(this,U,"f"))return;i.onEmptyPoll(),await i_((0,n5.e)(1e3,3e3),(0,id.V)(this,j,"f").signal);continue}i.onClaim(),this._workSpan=rL(this.client,()=>{var t,i,r;return t=this.client,i=n,r=e,t._tracer?.startSpan("anthropic.environment.work",{kind:rv.INTERNAL,attributes:{[rO]:t._genAIProviderName,"anthropic.environment.id":i.environment_id,"anthropic.environment.work.id":i.id,"anthropic.session.id":i.data.id}},r)}),t.info("claimed work",{component:"work-poller",environment_id:this.environmentId,work_id:n.id,work_type:n.data.type});try{await (0,id.V)(this,C,"f").beta.environments.work.ack(n.id,{environment_id:n.environment_id},{headers:rR([(0,id.V)(this,B,"f")?.headers]),signal:(0,id.V)(this,j,"f").signal})}catch(e){t.error("ack failed",{work_id:n.id,error:String(e)}),rL(this.client,()=>n9(this._workSpan,(0,id.V)(this,j,"f").signal,e));continue}try{yield n,e=iJ.active()}finally{if((0,id.V)(this,W,"f"))try{await (0,id.V)(this,C,"f").beta.environments.work.stop(n.id,{environment_id:n.environment_id},{headers:rR([(0,id.V)(this,B,"f")?.headers])})}catch(e){(0,n5.w)(e,409)||t.warn("stop failed",{work_id:n.id,error:String(e)})}rL(this.client,()=>n3(this._workSpan,(0,id.V)(this,j,"f").signal))}}}finally{(0,id.V)(this,D,"f").call(this)}}}return e})(),at=(K=new WeakMap,J=new WeakMap,G=new WeakMap,X=new WeakMap,class{constructor(e,t){K.set(this,void 0),J.set(this,void 0),G.set(this,void 0),X.set(this,0),(0,id.b)(this,K,e,"f"),(0,id.b)(this,J,t,"f")}onEmptyPoll(){let e=Date.now(),t={component:"work-poller",environment_id:(0,id.V)(this,J,"f")};void 0===(0,id.V)(this,G,"f")?((0,id.b)(this,G,(0,id.b)(this,X,e,"f"),"f"),(0,id.V)(this,K,"f").info("idle; polling for work",t)):e-(0,id.V)(this,X,"f")>=3e5?((0,id.b)(this,X,e,"f"),(0,id.V)(this,K,"f").info(`still polling; idle for ${Math.round((e-(0,id.V)(this,G,"f"))/1e3)}s`,t)):(0,id.V)(this,K,"f").debug("poll returned no work",t)}onClaim(){(0,id.b)(this,G,void 0,"f")}}),ai=(Q=new WeakMap,Y=new WeakMap,Z=new WeakMap,class{constructor(){Q.set(this,[]),Y.set(this,[]),Z.set(this,!1)}push(e){if((0,id.V)(this,Z,"f"))return!1;let t=(0,id.V)(this,Y,"f").shift();return t?t({done:!1,value:e}):(0,id.V)(this,Q,"f").push(e),!0}close(){if(!(0,id.V)(this,Z,"f"))for((0,id.b)(this,Z,!0,"f");(0,id.V)(this,Y,"f").length>0;)(0,id.V)(this,Y,"f").shift()({done:!0,value:void 0})}next(e){return(0,id.V)(this,Q,"f").length>0?Promise.resolve({done:!1,value:(0,id.V)(this,Q,"f").shift()}):(0,id.V)(this,Z,"f")||e?.aborted?Promise.resolve({done:!0,value:void 0}):new Promise(t=>{let i=i=>{e?.removeEventListener("abort",r),t(i)},r=()=>{let e=(0,id.V)(this,Y,"f").indexOf(i);e>=0&&(0,id.V)(this,Y,"f").splice(e,1),t({done:!0,value:void 0})};(0,id.V)(this,Y,"f").push(i),e?.addEventListener("abort",r,{once:!0})})}tryShift(){return(0,id.V)(this,Q,"f").shift()}}),ar=e.i(32014);let as=RegExp("[\\x00-\\x1f\\x7f-\\x9f\\u061c\\u200e\\u200f\\u2028\\u2029\\u202a-\\u202e\\u2066-\\u2069]+","g"),an=/[\uD800-\uDFFF]/gu;function aa(e){return e.replace(an,"�")}function ao(e){return(function(e,t=4096){return ac(aa(e).replace(as," ").trim(),t)})(e,200).replace(/[' ]+/g," ").trim()}function al(e){return`Error: ${e instanceof Error?e.message:String(e)}`}function ac(e,t){if(e.length<=t)return e;let i=0,r=0;for(let s of e){if(r===t)break;r+=1,i+=s.length}return e.slice(0,i)}function au(e){return"name"in e?e.name:"mcp_server_name"in e?e.mcp_server_name:e.type}async function ah(e,t,i){try{let r=e.parse?e.parse(t):t;return{content:await e.run(r,i),isError:!1}}catch(e){return{content:e instanceof ar.f?e.content:al(e),isError:!0}}}async function ad(e,t,i,r,s){let n,a=e._tracer;if(!a)return s();let{signal:o,conversationId:l,sessionID:c,parentContext:u=iJ.active()}=r,h="description"in t?t.description:void 0,d={[ss]:"execute_tool",[rO]:e._genAIProviderName,"gen_ai.tool.name":i.name,..."toolset_name"in i&&"string"==typeof i.toolset_name?{"anthropic.toolset.name":i.toolset_name}:void 0,...h?{"gen_ai.tool.description":h}:void 0,"gen_ai.tool.call.id":i.id,"gen_ai.tool.type":"function",...null!=l?{[rE]:l}:void 0,...null!=c?{"anthropic.session.id":c}:void 0,..."session_thread_id"in i&&null!=i.session_thread_id?{"anthropic.session.thread.id":i.session_thread_id}:void 0},p="agent.tool_use"===i.type?"anthropic.tool_use":ns(t)&&"mcpTool"===t[nr]?"anthropic.mcp_tool_use":"anthropic.custom_tool_use",_=rL(e,()=>a.startSpan(`${p} ${i.name}`,{kind:rv.INTERNAL,attributes:d},u));if(!_)return s();try{return n=await iJ.with(rm.setSpan(u,_),s)}finally{let t=void 0!==n&&!n.isError,r=!t&&o?.aborted===!0,{contentMode:s,maxContentBytes:a}=e.openTelemetry.traces;if("content"===s&&_.isRecording())try{sv(_,{"gen_ai.tool.call.arguments":i.input,[sh]:n&&!r?sg(n.content):void 0},a)}catch(t){(0,rz.u)(e).debug("could not record the tool run on its span",t)}rL(e,()=>{t?_.setStatus({code:rb.OK}):r||rW(_,n,"tool_error"),_.end()})}}function ap(e){return"session.status_idle"===e.type&&e.stop_reason?.type!=="requires_action"}var a_=(ee=new WeakMap,et=new WeakMap,ei=new WeakMap,er=new WeakMap,es=new WeakMap,class{constructor(e,t){ee.set(this,void 0),et.set(this,void 0),ei.set(this,new Set),er.set(this,!1),es.set(this,void 0),(0,id.b)(this,ee,e,"f"),(0,id.b)(this,et,t,"f")}noteEvent(e){"user.tool_confirmation"!==e.type&&(ap(e)?this.arm():this.disarm())}block(e){(0,id.V)(this,ei,"f").add(e),void 0!==(0,id.V)(this,es,"f")&&((0,id.b)(this,er,!0,"f"),clearTimeout((0,id.V)(this,es,"f")),(0,id.b)(this,es,void 0,"f"))}unblock(e){(0,id.V)(this,ei,"f").delete(e),0===(0,id.V)(this,ei,"f").size&&(0,id.V)(this,er,"f")&&this.arm()}arm(){if(!(0>=(0,id.V)(this,ee,"f"))){if((0,id.V)(this,ei,"f").size>0)return void(0,id.b)(this,er,!0,"f");(0,id.b)(this,er,!1,"f"),void 0!==(0,id.V)(this,es,"f")&&clearTimeout((0,id.V)(this,es,"f")),(0,id.b)(this,es,setTimeout((0,id.V)(this,et,"f"),(0,id.V)(this,ee,"f")),"f")}}disarm(){(0,id.b)(this,er,!1,"f"),void 0!==(0,id.V)(this,es,"f")&&(clearTimeout((0,id.V)(this,es,"f")),(0,id.b)(this,es,void 0,"f"))}}),af=(()=>{class e{constructor(e,t){en.add(this),ea.set(this,!1),eo.set(this,void 0),el.set(this,void 0),ec.set(this,void 0),eu.set(this,void 0),eh.set(this,void 0),ed.set(this,new Set),ep.set(this,new Set),e_.set(this,new Map),ef.set(this,new Map),eg.set(this,new ai),em.set(this,0),ev.set(this,3e5),eb.set(this,null),ey.set(this,void 0),ew.set(this,void 0),ek.set(this,void 0),ez.set(this,!1),this.client=t.client,this.sessionId=e,this.tools=t.tools,this.maxIdleMs=t.maxIdleMs??6e4,(0,id.b)(this,eh,(0,rz.u)(t.client),"f"),(0,id.b)(this,eu,new Map(t.tools.map(e=>[au(e),e])),"f"),(0,id.b)(this,eo,new AbortController,"f"),(0,id.b)(this,el,n4(t.signal,(0,id.V)(this,eo,"f")),"f"),(0,id.b)(this,ec,t.requestOptions,"f"),(0,id.b)(this,ey,new a_(this.maxIdleMs,()=>{(0,id.V)(this,eh,"f").info("session idle after its turn ended; stopping",{component:"session-tool-runner",session_id:this.sessionId,max_idle_ms:this.maxIdleMs}),(0,id.V)(this,eo,"f").abort()}),"f")}get signal(){return(0,id.V)(this,eo,"f").signal}abort(){(0,id.V)(this,eo,"f").abort()}_setSendRetryWindow(e){(0,id.b)(this,ev,e,"f")}async *[(ea=new WeakMap,eo=new WeakMap,el=new WeakMap,ec=new WeakMap,eu=new WeakMap,eh=new WeakMap,ed=new WeakMap,ep=new WeakMap,e_=new WeakMap,ef=new WeakMap,eg=new WeakMap,em=new WeakMap,ev=new WeakMap,eb=new WeakMap,ey=new WeakMap,ew=new WeakMap,ek=new WeakMap,ez=new WeakMap,en=new WeakSet,Symbol.asyncIterator)](){if((0,id.V)(this,ea,"f"))throw new ry.v("Cannot iterate over a consumed SessionToolRunner");(0,id.b)(this,ea,!0,"f"),(0,id.b)(this,ew,this.client._tracer?iJ.active():void 0,"f"),(0,id.V)(this,eh,"f").info("session tool runner starting",{component:"session-tool-runner",session_id:this.sessionId});let e=(0,id.V)(this,en,"m",ex).call(this).catch(e=>{(0,id.V)(this,eo,"f").signal.aborted||(0,id.V)(this,eh,"f").error("stream loop failed",{error:String(e)}),(0,id.V)(this,eo,"f").abort()});try{let t;for(;;){let e=await (0,id.V)(this,eg,"f").next((0,id.V)(this,eo,"f").signal);if(e.done)break;yield e.value}for(await e;void 0!==(t=(0,id.V)(this,eg,"f").tryShift());)yield t}finally{(0,id.V)(this,eo,"f").abort(),(0,id.V)(this,ey,"f").disarm(),await e;try{await (0,id.V)(this,en,"m",eM).call(this)}catch(e){(0,id.V)(this,eh,"f").warn("drain failed",{error:String(e)})}for(let e of((0,id.V)(this,eg,"f").close(),this.tools))try{await e.close?.()}catch(t){(0,id.V)(this,eh,"f").warn("tool.close failed",{tool:au(e),error:String(t)})}(0,id.V)(this,el,"f").call(this)}}}return eS=function(){return{...(0,id.V)(this,ec,"f"),headers:rR([{[nt]:"session-tool-runner"},(0,id.V)(this,ec,"f")?.headers]),signal:(0,id.V)(this,eo,"f").signal}},ex=async function(){let e=(0,id.V)(this,eo,"f"),t=500;for(;!e.signal.aborted;){try{let e=await this.client.beta.sessions.events.stream(this.sessionId,{},(0,id.V)(this,en,"m",eS).call(this));for await(let i of(await (0,id.V)(this,en,"m",eV).call(this),e))if(t=500,await (0,id.V)(this,en,"m",eq).call(this,i))return}catch(i){if(e.signal.throwIfAborted(),(0,n5.d)(i))throw(0,id.V)(this,eh,"f").error("permanent stream failure, shutting down",{error:String(i)}),e.abort(),i;(0,id.V)(this,eh,"f").warn("stream disconnected, reconnecting",{error:String(i),backoff_ms:t})}e.signal.throwIfAborted(),await i_(t,e.signal),t=Math.min(2*t,1e4)}},eV=async function(){let e=(0,id.V)(this,eo,"f"),t=[],i=!1;(0,id.b)(this,ez,!1,"f");try{for await(let e of this.client.beta.sessions.events.list(this.sessionId,{limit:1e3},(0,id.V)(this,en,"m",eS).call(this)))(0,id.V)(this,en,"m",eA).call(this,e,t),"user.tool_confirmation"!==e.type&&(i=ap(e))}catch(i){for(let r of(e.signal.throwIfAborted(),(0,id.V)(this,eh,"f").warn("reconcile list failed",{error:String(i)}),t))(0,id.V)(this,ed,"f").delete(r.id);return}(0,id.b)(this,ez,!0,"f");let r=t.filter(e=>!(0,id.V)(this,ep,"f").has(e.id));for(let e of((0,id.V)(this,ey,"f").disarm(),r))await (0,id.V)(this,en,"m",e$).call(this,e);for(let e of[...(0,id.V)(this,ef,"f").values()]){let t=(0,id.V)(this,e_,"f").get(e.id);void 0!==t&&await (0,id.V)(this,en,"m",eP).call(this,e,t)}let s=r.filter(e=>!(0,id.V)(this,ep,"f").has(e.id)&&!(0,id.V)(this,ef,"f").has(e.id));i&&0===s.length?(0,id.V)(this,ey,"f").arm():(0,id.V)(this,ey,"f").disarm()},eA=function(e,t){(0,id.V)(this,en,"m",eI).call(this,e),"agent.tool_use"===e.type||"agent.custom_tool_use"===e.type?((0,id.V)(this,ed,"f").add(e.id),(0,id.V)(this,ep,"f").has(e.id)||t.push(e)):"user.tool_result"===e.type?(0,id.V)(this,ep,"f").add(e.tool_use_id):"user.custom_tool_result"===e.type?(0,id.V)(this,ep,"f").add(e.custom_tool_use_id):"user.tool_confirmation"!==e.type||(0,id.V)(this,ep,"f").has(e.tool_use_id)||(0,id.V)(this,e_,"f").set(e.tool_use_id,e.result)},eI=function(e){if(this.client._tracer&&void 0===(0,id.V)(this,ek,"f"))switch(e.type){case"session.thread_status_running":case"session.thread_status_idle":case"session.thread_status_rescheduled":case"session.thread_status_terminated":(0,id.b)(this,ek,e.session_thread_id,"f")}},eq=async function(e){switch((0,id.V)(this,ey,"f").noteEvent(e),(0,id.V)(this,ez,"f")&&(0,id.V)(this,en,"m",eI).call(this,e),e.type){case"agent.tool_use":case"agent.custom_tool_use":return(0,id.V)(this,ed,"f").has(e.id)||((0,id.V)(this,ed,"f").add(e.id),await (0,id.V)(this,en,"m",e$).call(this,e)),!1;case"user.tool_confirmation":return await (0,id.V)(this,en,"m",eR).call(this,e),!1;case"user.tool_result":return(0,id.V)(this,ep,"f").add(e.tool_use_id),!1;case"user.custom_tool_result":return(0,id.V)(this,ep,"f").add(e.custom_tool_use_id),!1;case"session.status_terminated":case"session.deleted":return(0,id.V)(this,eh,"f").info("session terminated",{component:"session-tool-runner",session_id:this.sessionId}),(0,id.V)(this,eo,"f").abort(),!0;default:return!1}},e$=async function(e){let t=e.evaluated_permission,i="deny"===t?"deny":(0,id.V)(this,e_,"f").get(e.id);void 0===i?void 0===t||"allow"===t?await (0,id.V)(this,en,"m",eE).call(this,e,void 0):(0,id.V)(this,ef,"f").has(e.id)||((0,id.V)(this,eh,"f").info("tool call awaiting confirmation; holding",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),(0,id.V)(this,ef,"f").set(e.id,e),(0,id.V)(this,ey,"f").block(e.id)):await (0,id.V)(this,en,"m",eP).call(this,e,i)},eR=async function(e){(0,id.V)(this,e_,"f").set(e.tool_use_id,e.result);let t=(0,id.V)(this,ef,"f").get(e.tool_use_id);void 0!==t&&await (0,id.V)(this,en,"m",eP).call(this,t,e.result)},eP=async function(e,t){let i=(0,id.V)(this,ef,"f").delete(e.id);if("allow"===t){(0,id.V)(this,eh,"f").info("tool call confirmed",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),i||(0,id.V)(this,ey,"f").block(e.id);try{await (0,id.V)(this,en,"m",eE).call(this,e,"allow")}finally{(0,id.V)(this,ey,"f").unblock(e.id)}return}i&&(0,id.V)(this,ey,"f").unblock(e.id),(0,id.V)(this,ep,"f").add(e.id),(0,id.V)(this,eh,"f").info("tool call denied; not executing",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),(0,id.V)(this,en,"m",eT).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:"deny"})},eT=function(e){(0,id.V)(this,eg,"f").push(e)},eE=async function(e,t){var i,r,s,n,a;if(!(0,id.V)(this,ep,"f").has(e.id)){(0,id.V)(this,eh,"f").info("executing tool",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),(0,id.b)(this,em,(i=(0,id.V)(this,em,"f"),++i),"f");try{let i,r,o=(0,id.V)(this,eu,"f").get(e.name);if(!o){(0,id.V)(this,eh,"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}),"allow"===t&&(0,id.V)(this,ey,"f").disarm(),(0,id.V)(this,en,"m",eT).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:t});return}let l=(0,id.V)(this,ec,"f")?.openTelemetry?.conversationId??(e.session_thread_id||(0,id.V)(this,ek,"f")),c=new AbortController,u=n4((0,id.V)(this,eo,"f").signal,c),h=setTimeout(()=>c.abort(),12e4);try{let t={signal:(0,id.V)(this,eo,"f").signal,conversationId:l,sessionID:this.sessionId,parentContext:(0,id.V)(this,ew,"f")},s=await ad(this.client,o,e,t,async()=>{let t=await ah(o,e.input,{toolUse:e,toolUseBlock:e,signal:c.signal}),i=function(e){if("string"==typeof e)return[{type:"text",text:e||"(no output)"}];let t=e.map(e=>"text"===e.type?{type:"text",text:e.text||"(no output)"}:"image"===e.type||"document"===e.type?e:"search_result"===e.type?{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)"}]}(t.content),r=this.client._tracer?i.map((e,i)=>{let r="string"==typeof t.content?void 0:t.content[i];return r&&"text"!==r.type&&"text"===e.type?r:e}):i;return{sent:i,content:r,isError:t.isError}});i=s.sent,r=s.isError}finally{clearTimeout(h),u()}let d=(s=e,n=r,a=i,"agent.custom_tool_use"===s.type?{type:"user.custom_tool_result",custom_tool_use_id:s.id,is_error:n,content:a}:{type:"user.tool_result",tool_use_id:s.id,is_error:n,content:a}),p=await (0,id.V)(this,en,"m",eO).call(this,d,e.id,l);(0,id.V)(this,en,"m",eT).call(this,{event:e,result:d,toolUseId:e.id,name:e.name,isError:r,posted:p,confirmation:t})}finally{(0,id.b)(this,em,(r=(0,id.V)(this,em,"f"),--r),"f"),0===(0,id.V)(this,em,"f")&&(0,id.V)(this,eb,"f")?.call(this)}}},eO=async function(e,t,i){let r,s=(0,id.V)(this,eo,"f"),n=Date.now(),a=0;for(;;){a++,s.signal.throwIfAborted();try{return await this.client.beta.sessions.events.send(this.sessionId,{events:[e]},{...(0,id.V)(this,en,"m",eS).call(this),openTelemetry:{conversationId:i}}),(0,id.V)(this,ep,"f").add(t),!0}catch(o){if(r=o,(0,n5.d)(o))break;let e=(0,id.V)(this,ev,"f")-(Date.now()-n);if(e<=0)break;let i=Math.min((0,n5.o)((0,n5.J)(a-1,1e3,3e4)),e);(0,id.V)(this,eh,"f").warn("tool result send failed; retrying",{tool_use_id:t,attempt:a,backoff_ms:i,error:String(o)}),await i_(i,s.signal)}}return(0,id.V)(this,eh,"f").error("failed to send tool result",{tool_use_id:t,attempts:a,error:String(r)}),!1},eM=async function(){0!==(0,id.V)(this,em,"f")&&(await Promise.race([new Promise(e=>(0,id.b)(this,eb,e,"f")),i_(3e4)]),(0,id.b)(this,eb,null,"f"),(0,id.V)(this,em,"f")>0&&(0,id.V)(this,eh,"f").warn("drain timeout exceeded"))},e})(),ag=e.i(193668),am=(eC=new WeakMap,eL=new WeakSet,eN=async function(t,i,r,s){let n,a,o,l=(0,rz.u)(this.client),c=function(e){let t;if(!e)return null;try{let i=e.replace(/-/g,"+").replace(/_/g,"/"),r=i.padEnd(4*Math.ceil(i.length/4),"=");t=JSON.parse((0,rw.z)((e=>{if(void 0!==globalThis.Buffer){let t=globalThis.Buffer.from(e,"base64");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}if("u">typeof atob){let t=atob(e),i=new Uint8Array(t.length);for(let e=0;e<t.length;e++)i[e]=t.charCodeAt(e);return i}throw new ry.v("Cannot decode base64 string; Expected `Buffer` or `atob` to be defined")})(r)))}catch{return null}if(null===t||"object"!=typeof t||Array.isArray(t))return null;let i=t.sessions_token;return"string"==typeof i&&""!==i?i:null}(t.secret),u=c??i;if(void 0===u)throw new ry.v("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)");t.secret&&null===c&&l.warn("work item carried a secret payload but no sessions token could be extracted; falling back to the environment key",{work_id:t.id});let h=n8(this.client,{authToken:u,helper:"environments-worker"}),d=t.data.id,p=new AbortController,_=n4(r,p),f=new ay(p),g=await e.A(146735),m=aw(h,t,f,l,this.requestOptions,e=>{n=e,a?._setSendRetryWindow(e)}).catch(e=>{p.signal.aborted||l.error("heartbeat loop failed",{work_id:t.id,error:String(e)}),p.abort()}),v=async()=>{},b=!1;try{if("session"!==t.data.type)return void l.debug("skipping non-session work item",{work_id:t.id,type:t.data.type});let e=await h.beta.sessions.retrieve(d);if(null===c&&null!==this.memorySyncIntervalMs&&e.resources.some(e=>"memory_store"===e.type))throw new g.SessionMemoryError(`cannot mount the session's memories: the work item carried no sessions token (work_id=${t.id}, session_id=${d}); 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 i={workdir:this.workdir,client:h,session:e,...void 0!==this.maxFileBytes?{maxFileBytes:this.maxFileBytes}:{}};try{v=await g.setupSkills(i)}catch(e){l.warn("skill setup failed",{session_id:d,work_id:t.id,error:String(e)})}null!==c&&null!==this.memorySyncIntervalMs?(o=new g.SessionMemoryStores(h,{workdir:this.workdir,...void 0!==this.memorySyncIntervalMs?{syncIntervalMs:this.memorySyncIntervalMs}:{},syncDeletions:this.memorySyncDeletions}),await o.download(e),i.allowedRoots=o.roots,i.readOnlyRoots=o.readOnlyRoots):l.debug("memory stores disabled for this item",{work_id:t.id});let r="function"==typeof this.tools?this.tools(i):this.tools??g.betaAgentToolset20260401(i);for await(let e of(a=new af(d,{client:h,tools:r,...void 0!==this.maxIdleMs?{maxIdleMs:this.maxIdleMs}:{},...void 0!==this.requestOptions?{requestOptions:this.requestOptions}:{},signal:p.signal}),void 0!==n&&a._setSendRetryWindow(n),a))o&&await o.syncIfDue();b=!p.signal.aborted}finally{try{await v().catch(e=>{l.warn("skill cleanup failed",{session_id:d,work_id:t.id,error:String(e)})})}finally{if(o){let e=g.MEMORY_FLUSH_TIMEOUT_MS;b&&await av(o.finish(),e)&&l.warn(`final memory sync cut off after ${e}ms; the flush that follows still uploads changed files`,{session_id:d,work_id:t.id});let i=new AbortController;await av(o.flushWrites(i.signal),e)&&(i.abort(),l.warn(`memory flush cut off after ${e}ms; changed files it had not uploaded yet are not saved`,{session_id:d,work_id:t.id})),await o.dispose().catch(e=>{l.warn("memory store cleanup failed",{session_id:d,work_id:t.id,error:String(e)})})}}f.finish("runner_done"),_(),await m,f.lost?l.info("lease lost; released without stopping it",{session_id:d,work_id:t.id}):await ab(h,t,l,this.requestOptions),(f.lost||f.rejected)&&rL(this.client,()=>s?.end())}},class{constructor(e){if(eL.add(this),eC.set(this,void 0),void 0!==e.unrestrictedPaths)throw new ry.v("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,null!=e.memorySyncIntervalMs&&(0,ag.A)(e.memorySyncIntervalMs,"memorySyncIntervalMs"),this.memorySyncIntervalMs=e.memorySyncIntervalMs,this.memorySyncDeletions=e.memorySyncDeletions??"enabled",this.workerId=e.workerId,this.requestOptions=e.requestOptions,(0,id.b)(this,eC,e.signal,"f")}async run(e){let{environmentId:t,environmentKey:i}=this;if(void 0===t||void 0===i)throw new ry.v("EnvironmentWorker.run: environmentId and environmentKey are required to poll for work");let r=e??(0,id.V)(this,eC,"f"),s=new ae({client:this.client,environmentId:t,environmentKey:i,...void 0!==this.workerId?{workerId:this.workerId}:{},...r?{signal:r}:{},...void 0!==this.requestOptions?{requestOptions:this.requestOptions}:{},autoStop:!1});for await(let e of s){let t=s._workSpan;try{await n7(this.client,t,s.signal,()=>(0,id.V)(this,eL,"m",eN).call(this,e,i,s.signal,t))}catch(t){if(s.signal?.aborted)throw t;(0,rz.u)(this.client).error("work item failed",{work_id:e.id,error:String(t)})}}}async handleItem(e){let t=e?.workId??(0,rP.f)("ANTHROPIC_WORK_ID"),i=e?.environmentId??(0,rP.f)("ANTHROPIC_ENVIRONMENT_ID"),r=e?.sessionId??(0,rP.f)("ANTHROPIC_SESSION_ID"),s=(e?.environmentKey??this.environmentKey??(0,rP.f)("ANTHROPIC_ENVIRONMENT_KEY"))||void 0,n=e?.workSecret||(0,rP.f)("ANTHROPIC_WORK_SECRET")||null;if(!t)throw new ry.v("handleItem: workId is required — pass it or set ANTHROPIC_WORK_ID");if(!i)throw new ry.v("handleItem: environmentId is required — pass it or set ANTHROPIC_ENVIRONMENT_ID");if(!r)throw new ry.v("handleItem: sessionId is required — pass it or set ANTHROPIC_SESSION_ID");if(!s&&!n)throw new ry.v("handleItem: environmentKey is required when there is no work secret — pass it, construct the worker with it, or set ANTHROPIC_ENVIRONMENT_KEY");await (0,id.V)(this,eL,"m",eN).call(this,{id:t,environment_id:i,secret:n,data:{type:"session",id:r}},s,e?.signal??(0,id.V)(this,eC,"f"))}});async function av(e,t){let i;try{return await Promise.race([e.then(()=>!1,()=>!1),new Promise(e=>{i=setTimeout(()=>e(!0),t)})])}finally{void 0!==i&&clearTimeout(i)}}async function ab(e,t,i,r){try{await e.beta.environments.work.stop(t.id,{environment_id:t.environment_id,force:!0},{...r,headers:rR([r?.headers])})}catch(e){(0,n5.w)(e,409)||i.error("force-stop on exit failed",{work_id:t.id,error:String(e)})}}var ay=(ej=new WeakMap,eD=new WeakMap,class{constructor(e){ej.set(this,void 0),eD.set(this,void 0),(0,id.b)(this,ej,e,"f")}get signal(){return(0,id.V)(this,ej,"f").signal}finish(e){(0,id.b)(this,eD,(0,id.V)(this,eD,"f")??e,"f"),(0,id.V)(this,ej,"f").abort()}get lost(){return"lease_lost"===(0,id.V)(this,eD,"f")||"assumed_lost"===(0,id.V)(this,eD,"f")}get rejected(){return"heartbeat_rejected"===(0,id.V)(this,eD,"f")}});async function aw(e,t,i,r,s,n){let a=3e4,o=9e4,l=Date.now(),c="NO_HEARTBEAT",u=async()=>{let u=new AbortController,h=n4(i.signal,u),d=setTimeout(()=>u.abort(),a);try{let h=await e.beta.environments.work.heartbeat(t.id,{environment_id:t.environment_id,expected_last_heartbeat:c},{...s,headers:rR([s?.headers]),signal:u.signal});l=Date.now(),c=h.last_heartbeat,h.ttl_seconds>0&&(o=1e3*h.ttl_seconds,a=Math.max(1e3,Math.min(o/2,3e4)),n?.(o)),("stopping"===h.state||"stopped"===h.state)&&(r.info("heartbeat signals shutdown",{work_id:t.id,state:h.state}),i.finish("control_plane_stop")),h.lease_extended||(r.warn("lease not extended, shutting down",{work_id:t.id}),i.finish("control_plane_stop"))}catch(e){if(i.signal.throwIfAborted(),(0,n5.w)(e,412)){let s=function(e){let t=e instanceof ry.E?e.error:void 0;for(let e of["error","details","current_state"]){if(!(0,ip.u)(t))return{};t=t[e]}return(0,ip.u)(t)?t:{}}(e);r.error("lease lost: heartbeat precondition failed",{work_id:t.id,server_state:s.state,server_ttl_seconds:s.ttl_seconds,server_last_heartbeat:s.last_heartbeat}),i.finish("lease_lost");return}if((0,n5.d)(e))throw r.error("permanent heartbeat failure",{work_id:t.id,error:String(e)}),i.finish("heartbeat_rejected"),e;if(Date.now()-l>o){r.error("lease assumed lost: no successful heartbeat in ttl",{work_id:t.id,ttl_ms:o,error:String(e)}),i.finish("assumed_lost");return}r.warn("transient heartbeat failure",{work_id:t.id,error:String(e)})}finally{clearTimeout(d),h()}};for(await u();!i.signal.aborted;)await i_(a,i.signal),i.signal.throwIfAborted(),await u()}var ak=(()=>{class e extends ne{retrieve(e,t,i){let{environment_id:r,betas:s,workspace_id:n}=t;return this._client.get(nb`/v1/environments/${r}/work/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.work.retrieve",i,{route:"/v1/environments/{environment_id}/work/{work_id}",attributes:{"anthropic.environment.id":r,"anthropic.environment.work.id":e}})})}update(e,t,i){let{environment_id:r,betas:s,workspace_id:n,...a}=t;return this._client.post(nb`/v1/environments/${r}/work/${e}`,{body:a,...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.work.update",i,{route:"/v1/environments/{environment_id}/work/{work_id}",attributes:{"anthropic.environment.id":r,"anthropic.environment.work.id":e}})})}list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/environments/${e}/work`,s4,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.work.list",i,{route:"/v1/environments/{environment_id}/work",queryParams:["limit","page"],attributes:{"anthropic.environment.id":e}})})}ack(e,t,i){let{environment_id:r,betas:s}=t;return this._client.post(nb`/v1/environments/${r}/work/${e}/ack`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.work.ack",i,{route:"/v1/environments/{environment_id}/work/{work_id}/ack",attributes:{"anthropic.environment.id":r,"anthropic.environment.work.id":e}})})}heartbeat(e,t,i){let{environment_id:r,desired_ttl_seconds:s,expected_last_heartbeat:n,betas:a}=t;return this._client.post(nb`/v1/environments/${r}/work/${e}/heartbeat`,{query:{desired_ttl_seconds:s,expected_last_heartbeat:n},...i,headers:rR([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.work.heartbeat",i,{route:"/v1/environments/{environment_id}/work/{work_id}/heartbeat",queryParams:["desired_ttl_seconds","expected_last_heartbeat"],attributes:{"anthropic.environment.id":r,"anthropic.environment.work.id":e}})})}poll(e,t={},i){let{betas:r,"Anthropic-Worker-ID":s,...n}=t??{};return this._client.get(nb`/v1/environments/${e}/work/poll`,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"Anthropic-Worker-ID":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.work.poll",i,{route:"/v1/environments/{environment_id}/work/poll",queryParams:["block_ms","reclaim_older_than_ms"],attributes:{"anthropic.environment.id":e}})})}stats(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/environments/${e}/work/stats`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.work.stats",i,{route:"/v1/environments/{environment_id}/work/stats",attributes:{"anthropic.environment.id":e}})})}stop(e,t,i){let{environment_id:r,betas:s,workspace_id:n,...a}=t;return this._client.post(nb`/v1/environments/${r}/work/${e}/stop`,{body:a,...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.work.stop",i,{route:"/v1/environments/{environment_id}/work/{work_id}/stop",attributes:{"anthropic.environment.id":r,"anthropic.environment.work.id":e}})})}poller(e){return new ae({...e,client:this._client})}worker(e){return new am({...e,client:this._client})}}return e.WorkPoller=ae,e.EnvironmentWorker=am,e})(),az=(()=>{class e extends ne{constructor(){super(...arguments),this.work=new ak(this._client)}create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/environments",{body:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.create",t,{route:"/v1/environments",createdIDAttribute:"anthropic.environment.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/environments/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.retrieve",i,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":e}})})}update(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/environments/${e}`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.update",i,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/environments",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.list",t,{route:"/v1/environments",queryParams:["include_archived","limit","page"]})})}delete(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.delete(nb`/v1/environments/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.delete",i,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":e}})})}archive(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/environments/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.environments.archive",i,{route:"/v1/environments/{environment_id}/archive",attributes:{"anthropic.environment.id":e}})})}}return e.Work=ak,e})();class aS extends ne{create(e,t,i){let{view:r,betas:s,workspace_id:n,...a}=t;return this._client.post(nb`/v1/memory_stores/${e}/memories`,{query:{view:r},body:a,...i,headers:rR([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.memories.create",i,{route:"/v1/memory_stores/{memory_store_id}/memories",queryParams:["view"],attributes:{"gen_ai.memory.store.id":e},createdIDAttribute:"gen_ai.memory.record.id"})})}retrieve(e,t,i){let{memory_store_id:r,betas:s,workspace_id:n,...a}=t;return this._client.get(nb`/v1/memory_stores/${r}/memories/${e}`,{query:a,...i,headers:rR([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.memories.retrieve",i,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":r,"gen_ai.memory.record.id":e}})})}update(e,t,i){let{memory_store_id:r,view:s,betas:n,workspace_id:a,...o}=t;return this._client.post(nb`/v1/memory_stores/${r}/memories/${e}`,{query:{view:s},body:o,...i,headers:rR([{"anthropic-beta":[...n??[],"agent-memory-2026-07-22"].toString(),...null!=a?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.memories.update",i,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":r,"gen_ai.memory.record.id":e}})})}list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/memory_stores/${e}/memories`,s4,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"agent-memory-2026-07-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.memories.list",i,{route:"/v1/memory_stores/{memory_store_id}/memories",queryParams:["depth","limit","page","path_prefix","view"],contentQueryParams:["page"],attributes:{"gen_ai.memory.store.id":e}})})}delete(e,t,i){let{memory_store_id:r,expected_content_sha256:s,betas:n,workspace_id:a}=t;return this._client.delete(nb`/v1/memory_stores/${r}/memories/${e}`,{query:{expected_content_sha256:s},...i,headers:rR([{"anthropic-beta":[...n??[],"agent-memory-2026-07-22"].toString(),...null!=a?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.memories.delete",i,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["expected_content_sha256"],attributes:{"gen_ai.memory.store.id":r,"gen_ai.memory.record.id":e}})})}}class ax extends ne{retrieve(e,t,i){let{memory_store_id:r,betas:s,workspace_id:n,...a}=t;return this._client.get(nb`/v1/memory_stores/${r}/memory_versions/${e}`,{query:a,...i,headers:rR([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.memory_versions.retrieve",i,{route:"/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":r,"anthropic.memory_store.memory_version.id":e}})})}list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/memory_stores/${e}/memory_versions`,s4,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"agent-memory-2026-07-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.memory_versions.list",i,{route:"/v1/memory_stores/{memory_store_id}/memory_versions",queryParams:["api_key_id","created_at[gte]","created_at[lte]","limit","memory_id","operation","page","service_account_id","session_id","view"],attributes:{"gen_ai.memory.store.id":e}})})}redact(e,t,i){let{memory_store_id:r,betas:s,workspace_id:n}=t;return this._client.post(nb`/v1/memory_stores/${r}/memory_versions/${e}/redact`,{...i,headers:rR([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.memory_versions.redact",i,{route:"/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}/redact",attributes:{"gen_ai.memory.store.id":r,"anthropic.memory_store.memory_version.id":e}})})}}var aV=(()=>{class e extends ne{constructor(){super(...arguments),this.memories=new aS(this._client),this.memoryVersions=new ax(this._client)}create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/memory_stores",{body:s,...t,headers:rR([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.create",t,{route:"/v1/memory_stores",createdIDAttribute:"gen_ai.memory.store.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/memory_stores/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"agent-memory-2026-07-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.retrieve",i,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":e}})})}update(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/memory_stores/${e}`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"agent-memory-2026-07-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.update",i,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/memory_stores",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.list",t,{route:"/v1/memory_stores",queryParams:["created_at[gte]","created_at[lte]","include_archived","limit","page"]})})}delete(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.delete(nb`/v1/memory_stores/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"agent-memory-2026-07-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.delete",i,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":e}})})}archive(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/memory_stores/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...r??[],"agent-memory-2026-07-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.memory_stores.archive",i,{route:"/v1/memory_stores/{memory_store_id}/archive",attributes:{"gen_ai.memory.store.id":e}})})}}return e.Memories=aS,e.MemoryVersions=ax,e})();class aA extends ne{create(e,t){let{betas:i,user_profile_id:r,workspace_id:s,...n}=e;return this._client.post("/v1/messages/batches",{body:n,...t,headers:rR([{"anthropic-beta":[...i??[],"message-batches-2024-09-24"].toString(),...null!=r?{"anthropic-user-profile-id":r}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.messages.batches.create",t,{route:"/v1/messages/batches",attributes:{"anthropic.message.batch.request_count":n.requests?.length},createdIDAttribute:"anthropic.message.batch.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/messages/batches/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.messages.batches.retrieve",i,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/messages/batches",s6,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"message-batches-2024-09-24"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.messages.batches.list",t,{route:"/v1/messages/batches",queryParams:["after_id","before_id","limit"]})})}delete(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.delete(nb`/v1/messages/batches/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.messages.batches.delete",i,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":e}})})}cancel(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/messages/batches/${e}/cancel`,{...i,headers:rR([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.messages.batches.cancel",i,{route:"/v1/messages/batches/{message_batch_id}/cancel",attributes:{"anthropic.message.batch.id":e}})})}async results(e,t={},i){let r=await this.retrieve(e,t,i);if(!r.results_url)throw new ry.v(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`);let{betas:s,workspace_id:n}=t??{};return this._client.get(r.results_url,{...i,headers:rR([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary",...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),stream:!0,__qualifiers:{beta:"true"},__binaryResponse:!0,__span:rC(this._client,"anthropic.messages.batches.results",i,{route:"/v1/messages/batches/{message_batch_id}/results",attributes:{"anthropic.message.batch.id":e}})})._thenUnwrap((e,t)=>ng.fromResponse(t.response,t.controller))}}function aI(e){return e?.output_format??e?.output_config?.format}function aq(e,t,i){let r=aI(t);return t&&"parse"in(r??{})?a$(e,t,i):{...e,content:e.content.map(e=>"text"===e.type?Object.defineProperty(Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1}),"parsed",{get:()=>(i.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null),enumerable:!1}):e),parsed_output:null}}function a$(e,t,i){let r=null,s=e.content.map(e=>{if("text"===e.type){let s=function(e,t){let i=aI(e);if(i?.type!=="json_schema")return null;try{if("parse"in i)return i.parse(t);return JSON.parse(t)}catch(e){throw new ry.v(`Failed to parse structured output: ${e}`)}}(t,e.text);return null===r&&(r=s),Object.defineProperty(Object.defineProperty({...e},"parsed_output",{value:s,enumerable:!1}),"parsed",{get:()=>(i.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),s),enumerable:!1})}return e});return{...e,content:s,parsed_output:r}}function aR(e,t){let{betas:i,user_profile_id:r,workspace_id:s,tools:n,messages:a}=e;return rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...null!=r?{"anthropic-user-profile-id":r}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},na(n,a),t?.headers])}function aP(e){if(!e.output_format)return e;aT(e);let{output_format:t,...i}=e;return{...i,output_config:{...e.output_config,format:t}}}function aT(e){if(e.output_format&&e.output_config?.format)throw new ry.v("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).")}function aE(e){return"tool_use"===e.type||"server_tool_use"===e.type||"mcp_tool_use"===e.type}var aO=(()=>{class e{constructor(e,t){eW.add(this),this.messages=[],this.receivedMessages=[],eU.set(this,void 0),eF.set(this,null),this.controller=new AbortController,eH.set(this,void 0),eB.set(this,()=>{}),eK.set(this,()=>{}),eJ.set(this,void 0),eG.set(this,()=>{}),eX.set(this,()=>{}),eQ.set(this,{}),eY.set(this,!1),eZ.set(this,!1),e0.set(this,!1),e1.set(this,!1),e2.set(this,void 0),e6.set(this,void 0),e4.set(this,void 0),e5.set(this,void 0),e8.set(this,void 0),e3.set(this,void 0),e9.set(this,void 0),tt.set(this,e=>{if((0,id.b)(this,eZ,!0,"f"),(0,id.V)(this,e3,"f")&&((0,id.V)(this,e3,"f").streamed=void 0),(0,ig.c)(e)&&(e=new ry.F),e instanceof ry.F)return(0,id.b)(this,e0,!0,"f"),this._emit("abort",e);if(e instanceof ry.v)return this._emit("error",e);if(e instanceof Error){let t=new ry.v(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new ry.v(String(e)))}),(0,id.b)(this,eH,new Promise((e,t)=>{(0,id.b)(this,eB,e,"f"),(0,id.b)(this,eK,t,"f")}),"f"),(0,id.b)(this,eJ,new Promise((e,t)=>{(0,id.b)(this,eG,e,"f"),(0,id.b)(this,eX,t,"f")}),"f"),(0,id.V)(this,eH,"f").catch(()=>{}),(0,id.V)(this,eJ,"f").catch(()=>{}),(0,id.b)(this,eF,e,"f"),(0,id.b)(this,e5,t?.logger??console,"f"),(0,id.b)(this,e8,t?.client,"f")}get response(){return(0,id.V)(this,e2,"f")}get request_id(){return(0,id.V)(this,e6,"f")}get workspace_id(){return(0,id.V)(this,e4,"f")}async withResponse(){(0,id.b)(this,e1,!0,"f");let e=await (0,id.V)(this,eH,"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 i=new e(null);return i._run(()=>i._fromReadableStream(t)),i}static createMessage(t,i,r,{logger:s,client:n}={}){let a=new e(i,{logger:s,client:n});for(let e of i.messages)a._addMessageParam(e);return(0,id.b)(a,eF,{...i,stream:!0},"f"),a._run(()=>a._createMessage((e,i)=>t.create(e,i),{...i,stream:!0},{...r,headers:{...r?.headers,[ni]:"stream"}})),a}_start(e,t,i,r){for(let e of t.messages)this._addMessageParam(e);let s=(0,id.V)(this,e8,"f");(0,id.b)(this,e8,void 0,"f");let n=(t,i)=>e(t,i)._thenUnwrap((e,{options:t})=>((0,id.b)(this,e8,s,"f"),(0,id.b)(this,e3,t.__span,"f"),(0,id.b)(this,e9,t.body,"f"),e));this._run(()=>this._createMessage(n,{...t,stream:!0},i).finally(r))}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},(0,id.V)(this,tt,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,i){let r,s=i?.signal;s&&(s.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),s.addEventListener("abort",r));try{(0,id.V)(this,eW,"m",ti).call(this),(0,id.b)(this,e3,i?.__span??((0,id.V)(this,e8,"f")&&function(e,t,i){if(!e._tracer)return;let r=aR(t,i);return rC(e,"anthropic.messages.create",i,sz(e,{...aP(t),stream:!0},r))}((0,id.V)(this,e8,"f"),t,i)),"f");let{response:r,data:s}=await e({...t,stream:!0},{...i,__span:(0,id.V)(this,e3,"f"),signal:this.controller.signal}).withResponse();try{this._connected(r)}catch(e){throw(0,id.V)(this,e3,"f")&&((0,id.V)(this,e3,"f").failure=e),s.controller.abort(),e}for await(let e of s)try{(0,id.V)(this,eW,"m",tr).call(this,e)}catch(e){throw(0,id.V)(this,e3,"f")&&((0,id.V)(this,e3,"f").failure=e),e}if(s.controller.signal?.aborted)throw new ry.F;(0,id.V)(this,eW,"m",ts).call(this)}finally{s&&r&&s.removeEventListener("abort",r)}}_connected(e){this.ended||((0,id.b)(this,e2,e,"f"),(0,id.b)(this,e6,e?.headers.get("request-id"),"f"),(0,id.b)(this,e4,e?.headers.get("anthropic-workspace-id"),"f"),(0,id.V)(this,eB,"f").call(this,e),this._emit("connect"))}get ended(){return(0,id.V)(this,eY,"f")}get errored(){return(0,id.V)(this,eZ,"f")}get aborted(){return(0,id.V)(this,e0,"f")}abort(){this.controller.abort()}on(e,t){return((0,id.V)(this,eQ,"f")[e]||((0,id.V)(this,eQ,"f")[e]=[])).push({listener:t}),this}off(e,t){let i=(0,id.V)(this,eQ,"f")[e];if(!i)return this;let r=i.findIndex(e=>e.listener===t);return r>=0&&i.splice(r,1),this}once(e,t){return((0,id.V)(this,eQ,"f")[e]||((0,id.V)(this,eQ,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,i)=>{(0,id.b)(this,e1,!0,"f"),"error"!==e&&this.once("error",i),this.once(e,t)})}async done(){(0,id.b)(this,e1,!0,"f"),await (0,id.V)(this,eJ,"f")}get currentMessage(){return(0,id.V)(this,eU,"f")}async finalMessage(){return await this.done(),(0,id.V)(this,eW,"m",e7).call(this)}async finalText(){return await this.done(),(0,id.V)(this,eW,"m",te).call(this)}_emit(e,...t){if((0,id.V)(this,eY,"f"))return;"end"===e&&((0,id.b)(this,eY,!0,"f"),(0,id.V)(this,eG,"f").call(this));let i=(0,id.V)(this,eQ,"f")[e];if(i&&((0,id.V)(this,eQ,"f")[e]=i.filter(e=>!e.once),i.forEach(({listener:e})=>e(...t))),"abort"===e){let e=t[0];(0,id.V)(this,e1,"f")||i?.length||Promise.reject(e),(0,id.V)(this,eK,"f").call(this,e),(0,id.V)(this,eX,"f").call(this,e),this._emit("end");return}if("error"===e){let e=t[0];(0,id.V)(this,e1,"f")||i?.length||Promise.reject(e),(0,id.V)(this,eK,"f").call(this,e),(0,id.V)(this,eX,"f").call(this,e),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",(0,id.V)(this,eW,"m",e7).call(this))}_deliverEvent(e,t){this._emit("_rawEvent",e),t&&this._emit("streamEvent",e,t)}async _fromReadableStream(e,t){let i,r=t?.signal;r&&(r.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),r.addEventListener("abort",i));try{(0,id.V)(this,eW,"m",ti).call(this),this._connected(null);let t=rS.fromReadableStream(e,this.controller);for await(let e of t)(0,id.V)(this,eW,"m",tr).call(this,e);if(t.controller.signal?.aborted)throw new ry.F;(0,id.V)(this,eW,"m",ts).call(this)}finally{r&&i&&r.removeEventListener("abort",i)}}[(eU=new WeakMap,eF=new WeakMap,eH=new WeakMap,eB=new WeakMap,eK=new WeakMap,eJ=new WeakMap,eG=new WeakMap,eX=new WeakMap,eQ=new WeakMap,eY=new WeakMap,eZ=new WeakMap,e0=new WeakMap,e1=new WeakMap,e2=new WeakMap,e6=new WeakMap,e4=new WeakMap,e5=new WeakMap,e8=new WeakMap,e3=new WeakMap,e9=new WeakMap,tt=new WeakMap,eW=new WeakSet,e7=function(){if(0===this.receivedMessages.length)throw new ry.v("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},te=function(){if(0===this.receivedMessages.length)throw new ry.v("stream ended without producing a Message with role=assistant");let e=this.receivedMessages.at(-1).content.filter(e=>"text"===e.type).map(e=>e.text);if(0===e.length)throw new ry.v("stream ended without producing a content block with type=text");return e.join(" ")},ti=function(){this.ended||(0,id.b)(this,eU,void 0,"f")},tr=function(e){if(this.ended)return;let t=(0,id.V)(this,eW,"m",tn).call(this,e);if(this._deliverEvent(e,t),t)switch(e.type){case"content_block_delta":{let i=t.content.at(-1);switch(e.delta.type){case"text_delta":"text"===i.type&&this._emit("text",e.delta.text,i.text||"");break;case"citations_delta":"text"===i.type&&this._emit("citation",e.delta.citation,i.citations??[]);break;case"input_json_delta":if(aE(i)&&(0,id.V)(this,eQ,"f").inputJson?.length){let t;try{t=i.input}catch(e){(0,id.V)(this,tt,"f").call(this,(0,id.V)(this,eW,"m",ta).call(this,i,e));break}this._emit("inputJson",e.delta.partial_json,t)}break;case"thinking_delta":"thinking"===i.type&&this._emit("thinking",e.delta.thinking,i.thinking);break;case"signature_delta":"thinking"===i.type&&this._emit("signature",i.signature);break;case"compaction_delta":"compaction"===i.type&&i.content&&this._emit("compaction",i.content);break;default:(0,ip.f)(e.delta)}break}case"message_stop":(0,id.V)(this,e8,"f")&&(0,id.V)(this,e3,"f")&&(0,id.V)(this,eF,"f")&&sZ((0,id.V)(this,e8,"f"),(0,id.V)(this,e3,"f"),(0,id.V)(this,e9,"f")??(0,id.V)(this,eF,"f"),t),this._addMessageParam(t),this._addMessage(aq(t,(0,id.V)(this,eF,"f"),{logger:(0,id.V)(this,e5,"f")}),!0);break;case"content_block_stop":this._emit("contentBlock",t.content.at(-1));break;case"message_start":(0,id.b)(this,eU,t,"f"),(0,id.V)(this,e3,"f")&&(0,id.V)(this,eF,"f")&&((0,id.V)(this,e3,"f").streamed={body:(0,id.V)(this,e9,"f")??(0,id.V)(this,eF,"f"),message:t})}},ts=function(){if(this.ended)throw new ry.v("stream has ended, this shouldn't happen");let e=(0,id.V)(this,eU,"f");if(!e)throw new ry.v("request ended without sending any chunks");return(0,id.b)(this,eU,void 0,"f"),aq(e,(0,id.V)(this,eF,"f"),{logger:(0,id.V)(this,e5,"f")})},tn=function(e){let t=(0,id.V)(this,eU,"f");if("message_start"===e.type){if(t)throw new ry.v(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(t)switch(e.type){case"message_stop":default: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,null!=e.delta.container&&(t.container=e.delta.container),null!=e.context_management&&(t.context_management=e.context_management),null!=e.input_transformations&&(t.input_transformations=e.input_transformations),null!=e.usage.input_tokens&&(t.usage.input_tokens=e.usage.input_tokens),null!=e.usage.cache_creation_input_tokens&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),null!=e.usage.cache_read_input_tokens&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),null!=e.usage.server_tool_use&&(t.usage.server_tool_use=e.usage.server_tool_use),null!=e.usage.iterations&&(t.usage.iterations=e.usage.iterations),null!=e.usage.fallback_credit&&(t.usage.fallback_credit=e.usage.fallback_credit),null!=e.usage.output_tokens_details&&(t.usage.output_tokens_details=e.usage.output_tokens_details),t;case"content_block_start":return t.content.push(e.content_block),"fallback"===e.content_block.type&&(t.model=e.content_block.to.model),t;case"content_block_delta":{let i=t.content.at(e.index);switch(e.delta.type){case"text_delta":i?.type==="text"&&(t.content[e.index]={...i,text:(i.text||"")+e.delta.text});break;case"citations_delta":i?.type==="text"&&(t.content[e.index]={...i,citations:[...i.citations??[],e.delta.citation]});break;case"input_json_delta":if(i&&aE(i)){let r=(i[nd]||"")+e.delta.partial_json;t.content[e.index]=np(i,r)}break;case"thinking_delta":i?.type==="thinking"&&(t.content[e.index]={...i,thinking:i.thinking+e.delta.thinking});break;case"signature_delta":i?.type==="thinking"&&(t.content[e.index]={...i,signature:e.delta.signature});break;case"compaction_delta":if(i?.type==="compaction"){let r={...i,content:e.delta.content};"encrypted_content"in e.delta&&(r.encrypted_content=e.delta.encrypted_content),t.content[e.index]=r}break;default:(0,ip.f)(e.delta)}return t}case"content_block_stop":{let i=t.content.at(e.index);if(i&&aE(i)&&nd in i){let e;try{e=i.input}catch(t){e={},(0,id.V)(this,tt,"f").call(this,(0,id.V)(this,eW,"m",ta).call(this,i,t))}Object.defineProperty(i,"input",{value:e,enumerable:!0,configurable:!0,writable:!0})}return t}}},ta=function(e,t){let i=e[nd];return new ry.v(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${t}. JSON: ${i}`)},Symbol.asyncIterator)](){let e=[],t=[],i=!1;return this.on("_rawEvent",i=>{let r=t.shift();r?r.resolve(i):e.push(i)}),this.on("end",()=>{for(let e of(i=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let r of(i=!0,t))r.reject(e);t.length=0}),this.on("error",e=>{for(let r of(i=!0,t))r.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:i?{value:void 0,done:!0}:new Promise((e,i)=>t.push({resolve:e,reject:i})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new rS(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}return e})();let aM={browser_toolset_20260801:"browser",computer_toolset_20260801:"computer"};function aL(e){return aM[e.type]}function aC(e){return"run"in e&&null!=e.type&&Object.prototype.hasOwnProperty.call(aM,e.type)}var aN=ry;class aj extends aN.v{constructor(e,t){super(e),this.name="ToolsetUsageError",t&&"cause"in t&&(this.cause=t.cause)}}class aD extends aj{constructor(e,t){super(e,t),this.name="ToolsetContractError"}}ar.f,ar.f,ar.f,ar.f,ar.f,ar.f,ar.f,ar.f;let aW="Not executed: an earlier action in this turn failed.",aU={browser:aW,computer:"Not executed: an earlier computer action in this turn failed."};function aF(e,t,i=!1){return i&&(""===t||Array.isArray(t)&&0===t.length)&&(t="The tool call failed with an empty error message."),{type:"tool_result",tool_use_id:e.id,toolset_name:e.toolset_name??null,content:t,...i?{is_error:!0}:{}}}async function aH(e,t,i={}){let r=aL(e);if(t.toolset_name!==r)throw new aD(`tool_use ${JSON.stringify(t.id)} (toolset_name=${JSON.stringify(t.toolset_name??null)}, name=${JSON.stringify(t.name)}) is not a member call of the ${JSON.stringify(r)} toolset`);let s={...i,toolUse:t,toolUseBlock:t};try{return aF(t,await e.run(s,t))}catch(e){var n;if(e instanceof aj)throw e;return function(e){if(e?.aborted)throw new ry.F}(s.signal),aF(t,"string"==typeof(n=e instanceof ar.f?e.content:ac(aa(al(e)),4096))?aa(n):n.filter(e=>"text"===e.type&&""!==e.text).map(e=>({...e,text:aa(e.text)})),!0)}}var aB=(()=>{class e extends aO{constructor(e,t,i){super(e,{client:i}),to.add(this),tl.set(this,void 0),tc.set(this,0),tu.set(this,[]),th.set(this,[]),td.set(this,void 0),tp.set(this,[]),t_.set(this,!1),(0,id.b)(this,tl,t,"f")}get toolCalls(){return(0,id.V)(this,th,"f")}_deliverEvent(e,t){var i;(0,id.b)(this,tc,(i=(0,id.V)(this,tc,"f"),++i),"f");let r="content_block_stop"===e.type?t?.content[e.index]:void 0,s=r?.type==="tool_use"?r:void 0;s&&(0,id.V)(this,th,"f").push(s),super._deliverEvent(e,t),(0,id.V)(this,to,"m",tf).call(this,e,s),(0,id.V)(this,to,"m",tg).call(this)}[(tl=new WeakMap,tc=new WeakMap,tu=new WeakMap,th=new WeakMap,td=new WeakMap,tp=new WeakMap,t_=new WeakMap,to=new WeakSet,Symbol.asyncIterator)](){let e=super[Symbol.asyncIterator](),t={handled:(0,id.V)(this,tc,"f")};(0,id.V)(this,tu,"f").push(t);let i=!1;return{next:async()=>{i&&(i=!1,t.handled++,(0,id.V)(this,to,"m",tg).call(this));try{let r=await e.next();return i=!r.done,r.done&&(0,id.V)(this,to,"m",tm).call(this,t),r}catch(e){throw(0,id.V)(this,to,"m",tm).call(this,t),e}},return:async()=>{let i=e.return?.();return(0,id.V)(this,to,"m",tm).call(this,t),await i??{value:void 0,done:!0}}}}}return tf=function(e,t){if((0,id.V)(this,t_,"f"))return;if("content_block_start"===e.type&&"fallback"===e.content_block.type){(0,id.b)(this,t_,!0,"f"),(0,id.b)(this,td,void 0,"f");return}let i="content_block_start"===e.type||"message_delta"===e.type&&"tool_use"===e.delta.stop_reason;(0,id.V)(this,td,"f")&&i&&((0,id.V)(this,tp,"f").push({toolUse:(0,id.V)(this,td,"f"),event:(0,id.V)(this,tc,"f")}),(0,id.b)(this,td,void 0,"f")),t&&(0,id.b)(this,td,t,"f")},tg=function(){if(this.errored||this.controller.signal.aborted)return;let e=Math.min((0,id.V)(this,tc,"f"),...(0,id.V)(this,tu,"f").map(e=>e.handled));for(;(0,id.V)(this,tp,"f")[0]&&(0,id.V)(this,tp,"f")[0].event<=e;)(0,id.V)(this,tl,"f").call(this,(0,id.V)(this,tp,"f").shift().toolUse)},tm=function(e){let t=(0,id.V)(this,tu,"f").indexOf(e);t>=0&&((0,id.V)(this,tu,"f").splice(t,1),(0,id.V)(this,to,"m",tg).call(this))},e})(),aK=e.i(368120);class aJ{constructor(e,t,i){this.fields=e,this.ownMessages=t,this.ownCreateOnly=i,this.deferredMessages=[],this.replacementHistory=null,this.createOnly=a0(e)}}var aG=(tb=new WeakMap,ty=new WeakMap,tw=new WeakMap,tk=new WeakMap,tz=new WeakMap,tS=new WeakMap,tv=new WeakSet,tx=function(){for(let e of[(0,id.V)(this,tw,"f"),(0,id.V)(this,ty,"f")])for(let t=e.length-1;t>=0;t--)if(e[t].reply)return e[t].reply;return null},tV=function(e){if("id"in e)return e.id===(0,id.V)(this,tv,"a",tx)?.id;let t=(0,id.V)(this,tw,"f").at(-1)??(0,id.V)(this,ty,"f").at(-1);return t?.reply!=null&&a8(e,t.param)},tA=function(e){(0,id.V)(this,tS,"f").info(`Replaying the full message history under a new thread: reason=${e} previous_message_id=${this.previousMessageId}`),(0,id.b)(this,tk,{type:"create",replacesLostThread:"thread_not_found"===e},"f")},tI=function(){let e=(0,id.V)(this,ty,"f").at(-1);if((0,id.V)(this,tw,"f").length||!e||e.reply&&!e.partial)return;e.reply&&(0,id.V)(this,ty,"f").pop();let t=(0,id.V)(this,ty,"f").length;for(;t>0&&!(0,id.V)(this,ty,"f")[t-1].reply;)t-=1;(0,id.b)(this,tw,(0,id.V)(this,ty,"f").splice(t),"f"),(0,id.V)(this,tS,"f").info(`Re-sending the turn whose reply ended before \`message_stop\`: partial_reply_id=${e.reply?.id??null}`)},tq=function(e){return"refusal"===e.stop_reason&&"never_threaded"!==(0,id.V)(this,tk,"f").type&&(null!==this.previousMessageId&&(0,id.V)(this,tv,"m",tA).call(this,"refusal"),!0)},t$=function(e,{partial:t}){(0,id.V)(this,ty,"f").push(...(0,id.V)(this,tw,"f")),(0,id.b)(this,tw,[],"f"),e&&(0,id.V)(this,ty,"f").push({param:a3(e),reply:e,partial:t})},tR=function(e){let{container:t}=(0,id.V)(this,tb,"f");null==t?(0,id.b)(this,tb,{...(0,id.V)(this,tb,"f"),container:e},"f"):"object"==typeof t&&null==t.id&&(0,id.b)(this,tb,{...(0,id.V)(this,tb,"f"),container:{...t,id:e}},"f")},tP=function(e){if("continue"!==(0,id.V)(this,tk,"f").type)return;let{createdWith:t}=(0,id.V)(this,tk,"f"),i=aZ.filter(i=>e[i]!==t[i]);if(i.length){let e=i.map(e=>`\`${e}\``).join(" and ");throw new ry.v(`Cannot change ${e} on a thread: the server keeps the \`system\` and \`tools\` the thread was created with. To change them, start a new thread from \`thread.params\`.`+(i.includes("tools")?" To add or remove tools on this thread, send `tool_addition` or `tool_removal` blocks in a `system` message.":""))}},tT=function(e,{stream:t}){var i;let r,s={...this.options,...a4(e)};return t&&(s.headers=rR([{[ni]:"stream"},s.headers])),"never_threaded"!==(0,id.V)(this,tk,"f").type&&(s.headers=rR([s.headers,{[nt]:"message-thread"}])),this.threading&&(s.headers=null===(r=rR([i=s.headers]).values.get("anthropic-beta"))?i:rR([i,{"anthropic-beta":r$(r,aY)}])),s},class e{constructor({params:e,options:t,threading:i,logger:r}){tv.add(this),tb.set(this,void 0),ty.set(this,[]),tw.set(this,[]),tk.set(this,void 0),tz.set(this,null),tS.set(this,void 0);let{messages:s,unsupportedRequestBehavior:n,...a}=e;a6(a),this.options=t,this.unsupportedRequestBehavior=n??"error",(0,id.b)(this,tb,a,"f"),(0,id.b)(this,tk,i?{type:"create",replacesLostThread:!1}:{type:"never_threaded"},"f"),(0,id.b)(this,tS,r,"f"),this.push(s??[])}get threading(){return"create"===(0,id.V)(this,tk,"f").type||"continue"===(0,id.V)(this,tk,"f").type}get previousMessageId(){return"continue"===(0,id.V)(this,tk,"f").type?(0,id.V)(this,tk,"f").previousMessageId:null}get messages(){let e=(0,id.V)(this,tz,"f")?.replacementHistory?.slice()??[...(0,id.V)(this,ty,"f"),...(0,id.V)(this,tw,"f")].map(e=>e.param);return(0,id.V)(this,tz,"f")&&e.push(...(0,id.V)(this,tz,"f").deferredMessages.map(a3)),e}get params(){let e="create"===(0,id.V)(this,tk,"f").type?(0,id.V)(this,tz,"f")?.ownCreateOnly:void 0;return{...(0,id.V)(this,tb,"f"),...e,messages:this.messages}}push(e){if((0,id.V)(this,tz,"f"))return void(0,id.V)(this,tz,"f").deferredMessages.push(...e);for(let t of e)(0,id.V)(this,tv,"m",tV).call(this,t)||(0,id.V)(this,tw,"f").push({param:a3(t),reply:null})}update(e={},t={}){for(let i of(a6(e),(0,id.b)(this,tb,{...(0,id.V)(this,tb,"f"),...a4(e)},"f"),this.options={...this.options,...a4(t)},aZ))void 0!==e[i]&&delete(0,id.V)(this,tz,"f")?.ownCreateOnly[i]}fork(t=(0,id.V)(this,tb,"f")){let i=new e({params:{...t,unsupportedRequestBehavior:this.unsupportedRequestBehavior},options:this.options,threading:"never_threaded"!==(0,id.V)(this,tk,"f").type,logger:(0,id.V)(this,tS,"f")});return this.threading||i.stopThreading(),(0,id.V)(this,tz,"f")?.replacementHistory?(0,id.b)(i,tw,(0,id.V)(this,tz,"f").replacementHistory.map(e=>({param:e,reply:null})),"f"):((0,id.b)(i,ty,[...(0,id.V)(this,ty,"f")],"f"),(0,id.b)(i,tw,[...(0,id.V)(this,tw,"f")],"f")),(0,id.V)(this,tz,"f")&&i.push((0,id.V)(this,tz,"f").deferredMessages),i}setParams({messages:e,...t}){(0,id.b)(this,tb,t,"f"),(0,id.V)(this,tz,"f")&&((0,id.V)(this,tz,"f").ownCreateOnly={}),this.setMessages(e)}setMessages(e){let t=[...(0,id.V)(this,ty,"f"),...(0,id.V)(this,tw,"f")];if((0,id.V)(this,tz,"f")){let i=t.map(e=>e.param);a5(e,i)?((0,id.V)(this,tz,"f").replacementHistory=null,(0,id.V)(this,tz,"f").deferredMessages=e.slice(i.length)):((0,id.V)(this,tz,"f").replacementHistory=e,(0,id.V)(this,tz,"f").deferredMessages=[]);return}!a5(e,(0,id.V)(this,ty,"f").map(e=>e.param))&&((0,id.b)(this,ty,[],"f"),this.threading&&(0,id.b)(this,tk,{type:"create",replacesLostThread:!1},"f")),(0,id.b)(this,tw,[],"f");let i=new Map(t.filter(e=>e.reply).map(e=>[e.param.content,e]));for(let t of e.slice((0,id.V)(this,ty,"f").length))(0,id.V)(this,tv,"m",tV).call(this,t)||(0,id.V)(this,tw,"f").push({...i.get(t.content)??{reply:null},param:a3(t)})}get hasTurnToSend(){return(0,id.V)(this,tw,"f").length>0||aQ((0,id.V)(this,ty,"f").at(-1)?.reply?.stop_reason)}startTurn(e,t){if((0,id.V)(this,tz,"f"))throw new ry.v("Another `send()`, `parse()` or `stream()` is already in progress on this thread");a6(t);let i=(0,id.V)(this,tw,"f").length;this.push(e);let r=(0,id.V)(this,tw,"f").slice(i);(0,id.V)(this,tv,"m",tI).call(this);let s={};return void 0!==t.system&&(s.system=t.system),void 0!==t.tools&&(s.tools=t.tools),(0,id.b)(this,tz,new aJ({...(0,id.V)(this,tb,"f"),...a4(t)},r,s),"f")}endTurn(e){(0,id.b)(this,tz,null,"f"),(0,id.b)(this,tw,(0,id.V)(this,tw,"f").filter(t=>!e.ownMessages.includes(t)),"f"),e.replacementHistory&&this.setMessages(e.replacementHistory),this.push(e.deferredMessages)}recoversFrom(e){var t;let i;if(!(e instanceof ry.E))return!1;let r="continue_unthreaded"===this.unsupportedRequestBehavior,s=(t=e,i=a2(t)?.error_code,a1.find(e=>e===i)??null);if(null!==s&&"continue"===(0,id.V)(this,tk,"f").type)return"thread_not_found"===s&&(0,id.V)(this,tk,"f").replacesLostThread&&r?((0,id.V)(this,tS,"f").info(`The server lost the thread again right after a replay; continuing without a thread: previous_message_id=${(0,id.V)(this,tk,"f").previousMessageId}`),this.stopThreading()):(0,id.V)(this,tv,"m",tA).call(this,s),!0;let n=function(e){let t=a2(e);if(t?.error_code!=="thread_unsupported_request")return null;let i=t.unsupported;return Array.isArray(i)?i.map(String):[]}(e);return null!==n&&!!this.threading&&!!r&&((0,id.V)(this,tS,"f").info(`The server cannot thread this request; continuing without a thread: unsupported=${n.join(",")}`),this.stopThreading(),!0)}stopThreading(){this.threading&&(0,id.b)(this,tk,{type:"unthreaded"},"f")}recordPartialReply(e,t){var i,r;let s,n;(0,id.V)(this,tv,"m",tq).call(this,e)||((0,id.V)(this,tv,"m",t$).call(this,(i=e,r=t,s=i.content.slice(0,r),n=i.content[r],n?.type==="text"&&n.text&&s.push(n),s.length?{...i,content:s}:null),{partial:!0}),null!==this.previousMessageId&&(0,id.V)(this,tv,"m",tA).call(this,"stream_ended_before_message_stop"))}recordReply(e,t){!(0,id.V)(this,tv,"m",tq).call(this,t)&&((0,id.V)(this,tv,"m",t$).call(this,t,{partial:!1}),"create"===(0,id.V)(this,tk,"f").type&&(0,id.b)(this,tb,{...(0,id.V)(this,tb,"f"),...e.ownCreateOnly},"f"),this.threading&&((0,id.b)(this,tk,{type:"continue",previousMessageId:t.id,createdWith:e.createOnly,replacesLostThread:"create"===(0,id.V)(this,tk,"f").type&&(0,id.V)(this,tk,"f").replacesLostThread},"f"),t.usage.iterations?.some(e=>"fallback_message"===e.type)&&(0,id.V)(this,tv,"m",tA).call(this,"fallback_message")),t.container&&(0,id.V)(this,tv,"m",tR).call(this,t.container.id))}buildCreateArguments(e,t,{stream:i}){(0,id.V)(this,tv,"m",tP).call(this,e.createOnly);let r=(0,id.V)(this,tk,"f"),s="continue"===r.type?[]:(0,id.V)(this,ty,"f").map(e=>e.param);if("never_threaded"!==r.type){let e=(0,id.V)(this,ty,"f").map(e=>null!==e.reply).lastIndexOf(!0)+1;s=s.map((t,i)=>i<e?function e(t){if(!(0,ip.u)(t))return t;let{cache_control:i,...r}=t;for(let t of["content","source","tool","definition","tool_references"]){let i=r[t];Array.isArray(i)?r[t]=i.map(e):(0,ip.u)(i)&&(r[t]=e(i))}return r}(t):t)}let n={...e.fields,messages:[...s,...(0,id.V)(this,tw,"f").map(e=>e.param)]};if(this.threading&&!n.betas?.includes(aY)&&(n.betas=[...n.betas??[],aY]),"create"===r.type)n.thread={type:"create"};else if("continue"===r.type)for(let e of(n.thread={type:"continue",previous_message_id:r.previousMessageId},aZ))delete n[e];return{params:n,options:(0,id.V)(this,tv,"m",tT).call(this,t,{stream:i})}}checkNextTurn(e){(0,id.V)(this,tv,"m",tP).call(this,a0({...(0,id.V)(this,tb,"f"),...a4(e)}))}});let aX=["pause_turn","compaction"];function aQ(e){return aX.some(t=>t===e)}let aY="message-threads-2026-08-12",aZ=["system","tools"];function a0(e){return{system:JSON.stringify(e.system),tools:JSON.stringify(e.tools)}}let a1=["thread_not_found","thread_already_continued","thread_continue_in_flight"];function a2(e){let t=e.error,i=t?.error?.details;return(0,ip.u)(i)?i:null}function a6(e){if("thread"in e&&void 0!==e.thread)throw TypeError("`thread` cannot be set here. The message thread sets it for each request itself.")}function a4(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}function a5(e,t){return t.length<=e.length&&t.every((t,i)=>a8(t,e[i]))}function a8(e,t){let[i,r]=[a3(e),a3(t)];return Object.keys({...i,...r}).every(e=>i[e]===r[e]||JSON.stringify(i[e])===JSON.stringify(r[e]))}function a3(e){return"id"in e?{role:e.role,content:e.content}:e}function a9(e){return void 0===e?[]:(0,ip.z)(e)?e:[e]}function a7(e){let{stream:t,max_iterations:i,runToolsEagerly:r,thread:s,...n}=e;if(void 0!==s&&!1!==s)throw TypeError("`thread` cannot be set in the params of a tool runner. The runner sets it for each request itself. To run without a message thread, pass `thread: false`.");return{settings:{stream:t,max_iterations:i,runToolsEagerly:r},thread:s,threadParams:n}}let oe="a tool runner's toolsets come only from its tools param; change them with setMessagesParams(), or build a new runner";var ot=(()=>{class e{constructor(e,t,i){tE.add(this),tO.set(this,!1),tM.set(this,!1),tL.set(this,void 0),tC.set(this,void 0),tN.set(this,void 0),tj.set(this,void 0),tD.set(this,void 0),tW.set(this,void 0),tU.set(this,void 0),tF.set(this,void 0),tH.set(this,void 0),tB.set(this,0),tK.set(this,void 0),tJ.set(this,{status:"idle"}),tG.set(this,void 0),tX.set(this,null),tQ.set(this,new Map),tY.set(this,[]);let{thread:r,settings:s}="_state"in e?{thread:e,settings:t}:e.beta.messages._toolRunnerThread(t);or(r._state.params),os(s),(0,id.b)(this,tL,r,"f"),(0,id.b)(this,tC,a4(s),"f");let{tools:n,messages:a}=r._state.params,o=nn(n,a);"_state"in e||r._state.setMessages(JSON.parse(JSON.stringify(ol(a)))),(0,id.b)(this,tN,{...i},"f"),(0,id.b)(this,tj,rR([{[nt]:"BetaToolRunner"},o.length?{[nt]:o.join(", ")}:void 0]),"f"),(0,id.b)(this,tH,(0,aK.f)(),"f")}async *[(tO=new WeakMap,tM=new WeakMap,tL=new WeakMap,tC=new WeakMap,tN=new WeakMap,tj=new WeakMap,tD=new WeakMap,tW=new WeakMap,tU=new WeakMap,tF=new WeakMap,tH=new WeakMap,tB=new WeakMap,tK=new WeakMap,tJ=new WeakMap,tG=new WeakMap,tX=new WeakMap,tQ=new WeakMap,tY=new WeakMap,tE=new WeakSet,tZ=function(e){return(0,id.V)(this,tK,"f")?iJ.with((0,id.V)(this,tK,"f"),e):e()},Symbol.asyncIterator)](){var e;if((0,id.V)(this,tO,"f"))throw new ry.v("Cannot iterate over a consumed stream");(0,id.b)(this,tO,!0,"f"),(0,id.b)(this,tM,!0,"f"),(0,id.b)(this,tF,void 0,"f");let t=rL((0,id.V)(this,tL,"f")._client,()=>(function(e,t,i){if(!e._tracer)return;let r=t.output_config?.format?.type==="json_schema"||t.output_format?.type==="json_schema";return e._tracer.startSpan("anthropic.messages.tool_runner",{kind:rv.INTERNAL,attributes:{[ss]:"invoke_agent",[rO]:e._genAIProviderName,[so]:t.model,...r?{[sa]:su}:void 0,...null!=i?{[rE]:i}:void 0}})})((0,id.V)(this,tL,"f")._client,this.params,(0,id.V)(this,tN,"f").openTelemetry?.conversationId));(0,id.b)(this,tK,t&&rm.setSpan(iJ.active(),t),"f");try{for(;;)try{if((0,id.V)(this,tC,"f").max_iterations&&(0,id.V)(this,tB,"f")>=(0,id.V)(this,tC,"f").max_iterations)break;if((0,id.V)(this,tE,"m",ir).call(this),"scheduled"===(0,id.V)(this,tJ,"f").status&&"resume"!==of((0,id.V)(this,tX,"f"))){yield*(0,id.V)(this,tE,"m",t4).call(this,(0,id.V)(this,tJ,"f").config);continue}(0,id.b)(this,tM,!1,"f"),(0,id.b)(this,tF,void 0,"f"),(0,id.b)(this,tB,(e=(0,id.V)(this,tB,"f"),++e),"f"),(0,id.b)(this,tW,void 0,"f"),yield*(0,id.V)(this,tE,"m",t0).call(this,(0,id.V)(this,tL,"f"));let t=(0,id.V)(this,tD,"f");(0,id.b)(this,tD,void 0,"f");let i=await (0,id.V)(this,tE,"m",tZ).call(this,async()=>{let e;if((0,id.V)(this,tM,"f"))(0,id.b)(this,tX,null,"f"),(0,id.V)(this,tU,"f")?.abort(),(0,id.V)(this,tL,"f")._state.checkNextTurn(oo((0,id.V)(this,tL,"f"))),(0,id.V)(this,tL,"f")._state.setMessages(t),e=t.at(-1);else{let t=await (0,id.V)(this,tW,"f"),i=of(t.stop_reason);if((0,id.b)(this,tX,t.stop_reason,"f"),"stop"===i)return"stop";if("resume"===i)return"continue";e=function(e){for(let t=e.length-1;t>=0;t--){let i=e[t];if("assistant"===i.role)return i;if("user"===i.role&&Array.isArray(i.content)&&i.content.some(e=>"tool_result"===e.type))break}}((0,id.V)(this,tL,"f").messages)}op(e)&&(0,id.V)(this,tL,"f")._state.checkNextTurn(oo((0,id.V)(this,tL,"f")));let i=await (0,id.V)(this,tE,"m",ie).call(this,e,(0,id.V)(this,tN,"f").signal,(0,id.V)(this,tK,"f"));if(i){let e=(0,id.V)(this,tL,"f").messages,t=e.map(e=>e.role).lastIndexOf("assistant")+1;(0,id.V)(this,tL,"f")._state.setMessages([...e.slice(0,t),i,...e.slice(t)])}else if(!(0,id.V)(this,tM,"f")&&!(0,id.V)(this,tL,"f")._state.hasTurnToSend)return"stop";return"continue"});if("stop"===i){yield*(0,id.V)(this,tE,"m",t7).call(this);break}}finally{(0,id.V)(this,tU,"f")?.abort(),(0,id.b)(this,tU,void 0,"f")}if(await (0,id.V)(this,tE,"m",t6).call(this),!(0,id.V)(this,tW,"f"))throw new ry.v("ToolRunner concluded without a message from the server");(0,id.V)(this,tH,"f").resolve(await (0,id.V)(this,tW,"f")),rL((0,id.V)(this,tL,"f")._client,()=>t?.setStatus({code:rb.OK}))}catch(e){throw t&&rL((0,id.V)(this,tL,"f")._client,()=>rW(t,e)),(0,id.b)(this,tO,!1,"f"),(0,id.b)(this,tD,void 0,"f"),(0,id.V)(this,tH,"f").promise.catch(()=>{}),(0,id.V)(this,tH,"f").reject(e),(0,id.b)(this,tH,(0,aK.f)(),"f"),e}finally{rL((0,id.V)(this,tL,"f")._client,()=>t?.end()),(0,id.b)(this,tK,void 0,"f")}}setMessagesParams(e){var t,i;let r="function"==typeof e?e(this.params):e;if(or(r),"idle"!==(0,id.V)(this,tJ,"f").status&&on(r),"in_flight"===(0,id.V)(this,tJ,"f").status&&(t=r.messages,i=(0,id.V)(this,tL,"f").messages,!(t.length===i.length&&t.every((e,t)=>a8(e,i[t])))))throw new ry.v(oi);let{settings:s,threadParams:n}=a7(r);os(s),(0,id.b)(this,tC,a4(s),"f"),(0,id.V)(this,tD,"f")?((0,id.b)(this,tD,n.messages,"f"),(0,id.V)(this,tL,"f")._state.setParams({...n,messages:(0,id.V)(this,tL,"f").messages})):(0,id.V)(this,tL,"f")._state.setParams(n),(0,id.b)(this,tM,!0,"f"),(0,id.b)(this,tF,void 0,"f")}setRequestOptions(e){"function"==typeof e?(0,id.b)(this,tN,e((0,id.V)(this,tN,"f")),"f"):(0,id.b)(this,tN,{...(0,id.V)(this,tN,"f"),...e},"f")}async generateToolResponse(e=(0,id.V)(this,tN,"f").signal){let t=(0,id.V)(this,tL,"f")._client._tracer?iJ.active():void 0,i=await (0,id.V)(this,tW,"f")??(0,id.V)(this,tL,"f").messages.at(-1);return i?(0,id.V)(this,tE,"m",ie).call(this,i,e,t):null}deferToolCall(e){let t="string"==typeof e?e:e.id;(0,id.V)(this,tG,"f")&&!(0,id.V)(this,tG,"f").has(t)&&(0,id.V)(this,tG,"f").set(t,{status:"held"})}get deferredToolCalls(){let e=(0,id.V)(this,tU,"f"),t=(0,id.V)(this,tG,"f");return e instanceof aB&&t?e.toolCalls.filter(e=>t.get(e.id)?.status==="held"):[]}done(){return(0,id.V)(this,tH,"f").promise}async runUntilDone(){if(!(0,id.V)(this,tO,"f"))for await(let e of this);return this.done()}get params(){return{...(0,id.V)(this,tL,"f")._state.params,...(0,id.V)(this,tD,"f")&&{messages:[...(0,id.V)(this,tD,"f")]},...(0,id.V)(this,tC,"f")}}pushMessages(...e){this.setMessagesParams(t=>({...t,messages:[...t.messages,...e]}))}compactBeforeNextTurn(e){"in_flight"!==(0,id.V)(this,tJ,"f").status&&(on(this.params),(0,id.b)(this,tJ,{status:"scheduled",config:e??{type:"summarize"}},"f"))}addTools(...e){let t=(0,id.V)(this,tE,"m",it).call(this);for(let i of e){if(aC(i))throw new aD(`addTools() can't add the '${ao(aL(i))}' toolset: ${oe}`);let e=(i.type??"custom").replace(/_\d{8}$/,"").replace(/_toolset$/,"");if(t.has(e))throw new aD(`addTools() can't replace the '${ao(e)}' toolset: ${oe}`)}for(let t of e)"name"in t&&(0,id.V)(this,tQ,"f").set(t.name,"run"in t?t:null),(0,id.V)(this,tY,"f").push({type:"addition",tool:t})}removeTools(...e){let t=(0,id.V)(this,tE,"m",it).call(this);for(let i of e){let e="string"==typeof i?i:i.name;if(t.has(e))throw new aD(`removeTools() can't remove the '${ao(e)}' toolset: a tool runner's toolsets come only from its tools param; remove it there with setMessagesParams(), or build a new runner without it`)}for(let t of e){let e="string"==typeof t?t:t.name;(0,id.V)(this,tQ,"f").set(e,null),(0,id.V)(this,tY,"f").push({type:"removal",name:e})}}then(e,t){return this.runUntilDone().then(e,t)}}return t0=async function*(e){await (0,id.V)(this,tE,"m",t6).call(this),(0,id.b)(this,tG,void 0,"f");let t=e.messages;t.some(oc)&&(0,id.V)(this,tE,"m",tZ).call(this,()=>e._state.setMessages(ol(t)));let{tools:i}=e._state.params;(0,id.V)(this,tC,"f").stream?((0,id.b)(this,tU,(0,id.V)(this,tE,"m",tZ).call(this,()=>(0,id.V)(this,tC,"f").runToolsEagerly?(0,id.V)(this,tE,"m",t2).call(this,e):e.stream(void 0,oo(e),(0,id.V)(this,tE,"m",t1).call(this,e))),"f"),i&&e.update({tools:i}),e===(0,id.V)(this,tL,"f")&&(0,id.b)(this,tD,e.messages,"f"),(0,id.b)(this,tW,(0,id.V)(this,tU,"f").finalMessage(),"f"),(0,id.V)(this,tW,"f").catch(()=>{}),yield(0,id.V)(this,tU,"f")):((0,id.b)(this,tW,(0,id.V)(this,tE,"m",tZ).call(this,()=>e.send(void 0,oo(e),(0,id.V)(this,tE,"m",t1).call(this,e))),"f"),i&&e.update({tools:i}),e===(0,id.V)(this,tL,"f")&&(0,id.b)(this,tD,e.messages,"f"),yield(0,id.V)(this,tW,"f"))},t1=function(e){let{headers:t=e._state.options.headers}=(0,id.V)(this,tN,"f");return{...(0,id.V)(this,tN,"f"),headers:rR([(0,id.V)(this,tj,"f"),t])}},t2=function(e){let t=new Map;(0,id.b)(this,tG,t,"f");let i=new Map,r=e=>{let r=t.has(e.id),s=!e.toolset_name&&(0,id.V)(this,tE,"m",it).call(this).has(e.name),n=s?e.name:e.toolset_name;if(n){if(r||s||i.has(n))return void i.set(n,"waiting");i.set(n,"running");let a=oh((0,id.V)(this,tE,"m",ii).call(this),n,e,(0,id.V)(this,tN,"f"),(0,id.V)(this,tL,"f")._client,(0,id.V)(this,tK,"f"));return t.set(e.id,{status:"started",result:a}),void a.then(({is_error:e})=>{e||"waiting"===i.get(n)?i.set(n,"waiting"):i.delete(n)},()=>i.set(n,"waiting"))}if(r)return;let a=od((0,id.V)(this,tE,"m",t8).call(this),(0,id.V)(this,tE,"m",t3).call(this),e,(0,id.V)(this,tN,"f"),(0,id.V)(this,tL,"f")._client,(0,id.V)(this,tK,"f"));a.catch(()=>{}),t.set(e.id,{status:"started",result:a})},s=new aB(e._state.params,r,e._client);return e._stream(s,void 0,oo(e),(0,id.V)(this,tE,"m",t1).call(this,e)),s},t6=async function(){let e=[...(0,id.V)(this,tG,"f")?.values()??[]].filter(e=>"started"===e.status);await Promise.allSettled(e.map(e=>e.result))},t4=async function*(e){on(this.params),(0,id.b)(this,tJ,{status:"in_flight"},"f"),(0,id.b)(this,tF,void 0,"f");let t=(0,id.V)(this,tW,"f"),i=(0,id.V)(this,tE,"m",t5).call(this,e),r=(0,id.V)(this,tL,"f").messages.length;try{yield*(0,id.V)(this,tE,"m",t0).call(this,i);let e=await (0,id.V)(this,tW,"f");if(e.content.some(e=>"compaction"===e.type&&e.content)){(0,id.V)(this,tE,"m",t9).call(this);let t={role:e.role,content:e.content},i=(0,id.V)(this,tL,"f").messages.slice(r).filter(e=>!a8(e,t));(0,id.V)(this,tL,"f")._state.setMessages([t,...i])}else(0,rz.u)((0,id.V)(this,tL,"f")._client).warn("Compaction produced no summary; keeping the conversation as it is."),(0,id.b)(this,tW,t,"f")}finally{(0,id.b)(this,tJ,{status:"idle"},"f"),i._state.threading||(0,id.V)(this,tL,"f")._state.stopThreading()}},t5=function(e){let{messages:t,...i}=function(e){let{context_management:t,stop_sequences:i,output_format:r,...s}=e;return(s.tool_choice?.type==="any"||s.tool_choice?.type==="tool")&&delete s.tool_choice,s.output_config&&(s.output_config=(({format:e,...t})=>t)(s.output_config)),Array.isArray(s.fallbacks)&&(s.fallbacks=s.fallbacks.map(e=>e.output_config?{...e,output_config:(({format:e,...t})=>t)(e.output_config)}:e)),s}((0,id.V)(this,tL,"f")._state.params),r=(0,id.V)(this,tL,"f").fork();return r._state=(0,id.V)(this,tL,"f")._state.fork({...i,compaction:e}),r},t8=function(){let e=new Map;for(let t of(0,id.V)(this,tL,"f")._state.params.tools??[])"run"in t&&"name"in t&&e.set(t.name,t);for(let[t,i]of(0,id.V)(this,tQ,"f"))i?e.set(t,i):e.delete(t);return e},t3=function(){let e=new Set((0,id.V)(this,tE,"m",t8).call(this).keys());for(let t of[...this.params.messages,(0,id.V)(this,tE,"m",is).call(this)])if(Array.isArray(t.content)){for(let i of t.content)if("system"===t.role)o_(i,e);else if("assistant"===t.role&&"compaction"===i.type)for(let t of i.tool_changes??[])o_(t,e)}return e},t9=function(){let e=(0,id.V)(this,tE,"m",t3).call(this);for(let t of(0,id.V)(this,tE,"m",t8).call(this).keys())e.has(t)||(0,id.V)(this,tQ,"f").set(t,null)},t7=async function*(){if("scheduled"===(0,id.V)(this,tJ,"f").status){if(op((0,id.V)(this,tL,"f").messages.at(-1))){(0,rz.u)((0,id.V)(this,tL,"f")._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."),(0,id.b)(this,tJ,{status:"idle"},"f");return}yield*(0,id.V)(this,tE,"m",t4).call(this,(0,id.V)(this,tJ,"f").config)}},ie=async function(e,t,i){return void 0!==(0,id.V)(this,tF,"f")||(0,id.b)(this,tF,ou((0,id.V)(this,tE,"m",ii).call(this),(0,id.V)(this,tE,"m",t8).call(this),(0,id.V)(this,tE,"m",t3).call(this),e,{...(0,id.V)(this,tN,"f"),signal:t},(0,id.V)(this,tG,"f"),(0,id.V)(this,tL,"f")._client,i),"f"),(0,id.V)(this,tF,"f")},it=function(){return new Set((0,id.V)(this,tE,"m",ii).call(this).tools.filter(aC).map(aL))},ii=function(){return{...this.params,tools:(0,id.V)(this,tL,"f")._state.params.tools??[]}},ir=function(){"pause_turn"!==(0,id.V)(this,tX,"f")&&0!==(0,id.V)(this,tY,"f").length&&((0,id.V)(this,tL,"f").append((0,id.V)(this,tE,"m",is).call(this)),(0,id.b)(this,tY,[],"f"))},is=function(){let e=[];for(let t of(0,id.V)(this,tY,"f")){if("removal"===t.type){e.push({type:"tool_removal",tool:{type:"tool_reference",name:t.name}});continue}let i=oa(t.tool);e.push({type:"tool_addition",tool:{type:"tool_definition",definition:i}})}return{role:"system",content:e}},e})();let oi="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.";function or(e){if("compaction"in e&&null!=e.compaction)throw new ry.v("`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 os(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 on(e){if(e.context_management?.edits?.some(e=>e.type.startsWith("compact_")))throw new ry.v("`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 oa(e){return"run"in e?{...Object.fromEntries(Object.entries("toJSON"in e&&"function"==typeof e.toJSON?e.toJSON():e).filter(([e])=>oy.includes(e))),...ns(e)&&{[nr]:e[nr]}}:e}function oo(e){let{tools:t}=e._state.params;return t?{tools:t.map(oa)}:{}}function ol(e){return e.map(e=>{if("system"!==e.role||!Array.isArray(e.content))return e;let t=e.content.map(e=>"tool_addition"===e.type&&"tool_definition"===e.tool.type?{...e,tool:{...e.tool,definition:oa(e.tool.definition)}}:e);return{...e,content:t}})}function oc(e){return"system"===e.role&&Array.isArray(e.content)&&e.content.some(e=>"tool_addition"===e.type&&"tool_definition"===e.tool.type&&"run"in e.tool.definition)}async function ou(e,t,i,r,s,n,a,o){if(!r||"assistant"!==r.role||!r.content||"string"==typeof r.content)return null;let l=r.content.filter(e=>"tool_use"===e.type);if(0===l.length)return null;let c=new Map;return{role:"user",content:await Promise.all(l.map(async r=>{let l=n?.get(r.id),u=l?.status==="started"?l.result:void 0;if(r.toolset_name){let t=r.toolset_name,i=c.get(t)??{tail:Promise.resolve(),failed:!1};c.set(t,i);let l=e.tools.some(e=>aC(e)&&aL(e)===t),h=u??i.tail.then(()=>i.failed?aF(r,Object.prototype.hasOwnProperty.call(aU,t)?aU[t]:aW,!0):oh(e,t,r,s,a,o));return i.tail=h.then(({is_error:e})=>{e&&l&&(i.failed=!0)},()=>{i.failed=!0}),n?.set(r.id,{status:"started",result:h}),h}if(u)return u;if(!(i.has(r.name)?t.get(r.name):void 0)&&e.tools.some(e=>aC(e)&&aL(e)===r.name)){var h;let e=c.get(r.name)??{tail:Promise.resolve(),failed:!1};return c.set(r.name,e),e.tail=e.tail.then(()=>{e.failed=!0}),{type:"tool_result",tool_use_id:(h=r).id,content:`Error: the '${ao(h.name)}' toolset could not run this call${function(e){let t="object"==typeof e&&null!==e?e:{};if(!("actions"in t)){let e="action"in t?t.action:void 0;return"string"==typeof e?`: the call has no 'actions' list (action: '${ao(e)}')`:": the call has no 'actions' list"}let{actions:i}=t;if("string"==typeof i)return": 'actions' is text, not a list of actions";if(!Array.isArray(i))return": 'actions' is not a list of actions";if(0===i.length)return": the 'actions' list is empty";let r=[];for(let[e,t]of i.entries()){let i="object"==typeof t&&null!==t&&"action"in t?t.action:void 0;if("string"!=typeof i)return`: action ${e} must be an object with a string 'action' field`;r.push(`'${ao(i)}'`)}let s=r.length>10?`, and ${r.length-10} more`:"";return`: its actions could not be run as sent (actions: ${r.slice(0,10).join(", ")}${s})`}(h.input)}; nothing in the batch was executed`,is_error:!0}}let d=od(t,i,r,s,a,o);return n?.set(r.id,{status:"started",result:d}),d}))}}async function oh(e,t,i,r,s,n){let a=e.tools.find(e=>aC(e)&&aL(e)===t);if(!a)return aF(i,`Error: Toolset '${ao(t)}' member '${ao(i.name)}' not found`,!0);let o={signal:r?.signal,conversationId:r?.openTelemetry?.conversationId,parentContext:n};return(await ad(s,a,i,o,async()=>{let e=await aH(a,i,{signal:r?.signal});return{block:e,content:e.content??[],isError:!0===e.is_error}})).block}async function od(e,t,i,r,s,n){let a=t.has(i.name)?e.get(i.name):void 0;if(!a){var o;return{type:"tool_result",tool_use_id:(o=i).id,content:`Error: Tool '${o.name}' not found`,is_error:!0}}let l={signal:r?.signal,conversationId:r?.openTelemetry?.conversationId,parentContext:n},c=await ad(s,a,i,l,()=>ah(a,i.input,{toolUse:i,toolUseBlock:i,signal:r?.signal}));return{type:"tool_result",tool_use_id:i.id,content:c.content,...c.isError?{is_error:!0}:void 0}}function op(e){return Array.isArray(e?.content)&&e.content.some(e=>"tool_use"===e.type)}function o_(e,t){switch(e.type){case"tool_removal":case"tool_addition":var i,r;let s;i=e,r=t,void 0!==(s=function(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}}(i.tool))&&("tool_removal"===i.type?r.delete(s):r.add(s))}}function of(e){if(null===e)return"stop";if(aQ(e))return"resume";switch(e){case"tool_use":return"run_tools";case"end_turn":case"stop_sequence":case"max_tokens":case"model_context_window_exceeded":case"refusal":return"stop";default:return(0,ip.f)(e),"stop"}}class og{constructor(e,t,i){if(!e._supportsMessageThreads)throw new ry.v("Message threads are not available on this client; use `client.beta.messages.create()` with the full `messages` instead");aT(t),this._client=e,this._state=new aG({params:t,options:i??{},threading:!0,logger:(0,rz.u)(e)})}static _fromState(e,t){return Object.assign(Object.create(og.prototype),{_client:e,_state:t})}get messages(){return this._state.messages}get previousMessageId(){return this._state.previousMessageId}get params(){return{...this._state.params,unsupportedRequestBehavior:this._state.unsupportedRequestBehavior}}append(...e){this._state.push(e)}send(e,t={},i={}){return this._send(e,t,i,e=>e)}parse(e,t={},i={}){return this._send(e,t,i,e=>a$(e,this._state.params,{logger:(0,rz.u)(this._client)}))}_send(e,t,i,r){let s=this._state.startTurn(a9(e),t),n=(async()=>{try{let{request:e,props:t}=await this._createWithRecovery(s,i,{stream:!1}),r=await e;return this._state.recordReply(s,r),{props:t,reply:r}}finally{this._state.endTurn(s)}})();return new s0(this._client,n.then(({props:e})=>e),async()=>{let{props:e,reply:t}=await n;return sj(r(t),e.response)})}stream(e,t={},i={}){let r=new aO(this._state.params,{logger:(0,rz.u)(this._client),client:this._client});return this._stream(r,e,t,i),r}_stream(e,t,i,r){let s,n=this._state.startTurn(a9(t),i),a=0,o=!1;e.on("streamEvent",(e,t)=>{o||(s=t,"content_block_stop"===e.type&&(a+=1),"message_stop"===e.type&&(o=!0,this._state.recordReply(n,t),this._state.endTurn(n)))});let l=()=>{o||(o=!0,s&&this._state.recordPartialReply(s,a),this._state.endTurn(n))};e.controller.signal.addEventListener("abort",l,{once:!0});let c=(e,t)=>new s0(this._client,this._createWithRecovery(n,{...r,signal:t?.signal},{stream:!0}).then(({props:e})=>e));e._start(c,this._state.params,{signal:r.signal??this._state.options.signal},l)}update(e={},t={}){this._state.update(e,t)}toolRunner(e={},t={}){return a6(e),new ot(this,e,t)}fork(){return og._fromState(this._client,this._state.fork())}async _createWithRecovery(e,t,{stream:i}){for(;;){let{params:r,options:s}=this._state.buildCreateArguments(e,t,{stream:i}),n=this._client.beta.messages.create({...r,stream:i},s);try{return{request:n,props:await n._responseProps()}}catch(e){if(!this._state.recoversFrom(e))throw e}}}}let om={"claude-sonnet-4-5":"November 30th, 2026","claude-sonnet-4-5-20250929":"November 30th, 2026"},ov=["claude-mythos-preview","claude-opus-4-6"];var ob=(()=>{class e extends ne{constructor(){super(...arguments),this.batches=new aA(this._client)}create(e,t){let i=aP(e),{betas:r,user_profile_id:s,workspace_id:n,...a}=i;a.model in om&&console.warn(`The model '${a.model}' is deprecated and will reach end-of-life on ${om[a.model]}
|
|
6
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),ov.includes(a.model)&&a.thinking&&"enabled"===a.thinking.type&&console.warn(`Using Claude with ${a.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 o=t?.timeout??this._client._options.timeout;if(!a.stream&&null==o){let e=nw[a.model]??void 0;o=this._client.calculateNonstreamingTimeout(a.max_tokens,e)}let l=aR(i,t),c=this._client._tracer&&rC(this._client,"anthropic.messages.create",t,sz(this._client,a,l));sS(this._client,c,a);let u=this._client.post("/v1/messages",{body:a,timeout:o??6e5,...t,__qualifiers:{beta:"true"},__span:c,headers:l,stream:i.stream??!1});return c?u._thenUnwrap(e=>(sx(this._client,c,a,e),e)):u}parse(e,t){return t={...t,headers:rR([{"anthropic-beta":[...e.betas??[],"structured-outputs-2025-12-15"].toString()},t?.headers])},this.create(e,t).then(t=>a$(t,e,{logger:this._client.logger??console}))}stream(e,t){return aO.createMessage(this,e,t,{client:this._client})}countTokens(e,t){let{betas:i,user_profile_id:r,workspace_id:s,...n}=aP(e),a=rR([{"anthropic-beta":[...i??[],"token-counting-2024-11-01"].toString(),...null!=r?{"anthropic-user-profile-id":r}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},t?.headers]),o=rC(this._client,"anthropic.messages.count_tokens",t,{route:"/v1/messages/count_tokens",attributes:{[so]:n.model}}),l=this._client.post("/v1/messages/count_tokens",{body:n,...t,__qualifiers:{beta:"true"},__span:o,headers:a});return o?l._thenUnwrap(e=>(sV(this._client,o,e),e)):l}toolRunner(e,t){return new ot(this._client,e,t)}_toolRunnerThread(e){aT(e);let{settings:t,thread:i,threadParams:r}=a7(e),s=new aG({params:{...r,unsupportedRequestBehavior:"continue_unthreaded"},options:{},threading:!1!==i&&this._client._supportsMessageThreads,logger:(0,rz.u)(this._client)});return{thread:og._fromState(this._client,s),settings:t}}thread(e,t){return new og(this._client,e,t)}}return e.Batches=aA,e.BetaToolRunner=ot,e.ToolError=ar.f,e})();let oy=["input_schema","name","allowed_callers","cache_control","defer_loading","description","eager_input_streaming","input_examples","strict","type","configs","display_height_px","display_width_px","display_number","enable_zoom","max_characters"];class ow extends ne{retrieve(e,t){return this._client.get(nb`/v1/organizations/api_keys/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.api_keys.retrieve",t,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/api_keys/${e}`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.api_keys.update",i,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/api_keys",s6,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.api_keys.list",t,{route:"/v1/organizations/api_keys",queryParams:["after_id","before_id","created_by_user_id","limit","status","workspace_id"]})})}}class ok extends ne{retrieve(e){return this._client.get("/v1/organizations/compliance_settings",{...e,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.compliance_settings.retrieve",e,{route:"/v1/organizations/compliance_settings"})})}update(e,t){return this._client.post("/v1/organizations/compliance_settings",{body:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.compliance_settings.update",t,{route:"/v1/organizations/compliance_settings"})})}}class oz extends ne{create(e,t){return this._client.post("/v1/organizations/external_keys",{body:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.external_keys.create",t,{route:"/v1/organizations/external_keys",createdIDAttribute:"anthropic.organization.external_key.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/external_keys/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.external_keys.retrieve",t,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/external_keys/${e}`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.external_keys.update",i,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/external_keys",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.external_keys.list",t,{route:"/v1/organizations/external_keys",queryParams:["limit","page"]})})}delete(e,t){return this._client.delete(nb`/v1/organizations/external_keys/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.external_keys.delete",t,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}validate(e,t){return this._client.post(nb`/v1/organizations/external_keys/${e}/validate`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.external_keys.validate",t,{route:"/v1/organizations/external_keys/{external_key_id}/validate",attributes:{"anthropic.organization.external_key.id":e}})})}}class oS extends ne{create(e,t){return this._client.post("/v1/organizations/invites",{body:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.invites.create",t,{route:"/v1/organizations/invites",createdIDAttribute:"anthropic.organization.invite.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/invites/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.invites.retrieve",t,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/invites",s6,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.invites.list",t,{route:"/v1/organizations/invites",queryParams:["after_id","before_id","email","limit","roles","statuses"]})})}delete(e,t){return this._client.delete(nb`/v1/organizations/invites/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.invites.delete",t,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":e}})})}}class ox extends ne{retrieve(e,t={},i){let{betas:r,...s}=t??{};return this._client.get(nb`/v1/organizations/plugin_marketplaces/${e}`,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugin_marketplaces.retrieve",i,{route:"/v1/organizations/plugin_marketplaces/{marketplace_id}",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin_marketplace.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/plugin_marketplaces/${e}`,{body:s,...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugin_marketplaces.update",i,{route:"/v1/organizations/plugin_marketplaces/{marketplace_id}",attributes:{"anthropic.organization.plugin_marketplace.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/plugin_marketplaces",s4,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugin_marketplaces.list",t,{route:"/v1/organizations/plugin_marketplaces",queryParams:["limit","organization_id","owner_type","page","source"]})})}validateArchive(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/plugin_marketplaces/validate_archive",sG({body:r,...t,headers:rR([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugin_marketplaces.validate_archive",t,{route:"/v1/organizations/plugin_marketplaces/validate_archive"})},this._client))}validateRepository(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/plugin_marketplaces/validate_repository",{body:r,...t,headers:rR([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugin_marketplaces.validate_repository",t,{route:"/v1/organizations/plugin_marketplaces/validate_repository"})})}}class oV extends ne{list(e={},t){return this._client.getAPIList("/v1/organizations/rate_limits",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rate_limits.list",t,{route:"/v1/organizations/rate_limits",queryParams:["group_type","limit","model","page"]})})}}class oA extends ne{retrieve(e,t){return this._client.get(nb`/v1/organizations/users/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.users.retrieve",t,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/users/${e}`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.users.update",i,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/users",s6,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.users.list",t,{route:"/v1/organizations/users",queryParams:["after_id","before_id","email","limit","roles"]})})}remove(e,t){return this._client.delete(nb`/v1/organizations/users/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.users.remove",t,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}}class oI extends ne{create(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/webhooks",{body:r,...t,headers:rR([{"anthropic-beta":[...i??[],"webhooks-2026-10-07"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.webhooks.create",t,{route:"/v1/organizations/webhooks",createdIDAttribute:"anthropic.organization.webhook.id"})})}retrieve(e,t={},i){let{betas:r}=t??{};return this._client.get(nb`/v1/organizations/webhooks/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"webhooks-2026-10-07"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.webhooks.retrieve",i,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}",attributes:{"anthropic.organization.webhook.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/webhooks/${e}`,{body:s,...i,headers:rR([{"anthropic-beta":[...r??[],"webhooks-2026-10-07"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.webhooks.update",i,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}",attributes:{"anthropic.organization.webhook.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/webhooks",s6,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"webhooks-2026-10-07"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.webhooks.list",t,{route:"/v1/organizations/webhooks",queryParams:["after_id","before_id","limit","order"]})})}delete(e,t={},i){let{betas:r}=t??{};return this._client.delete(nb`/v1/organizations/webhooks/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"webhooks-2026-10-07"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.webhooks.delete",i,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}",attributes:{"anthropic.organization.webhook.id":e}})})}regenerateSigningSecret(e,t={},i){let{betas:r}=t??{};return this._client.post(nb`/v1/organizations/webhooks/${e}/regenerate_signing_secret`,{...i,headers:rR([{"anthropic-beta":[...r??[],"webhooks-2026-10-07"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.webhooks.regenerate_signing_secret",i,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}/regenerate_signing_secret",attributes:{"anthropic.organization.webhook.id":e}})})}}class oq extends ne{list(e,t){return this._client.getAPIList("/v1/organizations/analytics/artifacts",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.artifacts.list",t,{route:"/v1/organizations/analytics/artifacts",queryParams:["date","filter","group_by","limit","page"]})})}}class o$ extends ne{list(e={},t){return this._client.getAPIList("/v1/organizations/analytics/connectors",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.connectors.list",t,{route:"/v1/organizations/analytics/connectors",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}}class oR extends ne{list(e,t){let{betas:i,...r}=e;return this._client.getAPIList("/v1/organizations/analytics/cost",s8,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"analytics-usage-cost-2026-08-24"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.cost.list",t,{route:"/v1/organizations/analytics/cost",queryParams:["actor_ids","actor_types","agent_ids","api_key_ids","claude_tag_categories","claude_tag_user_ids","context_windows","deployment_ids","ending_at","environment_ids","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","page","products","rbac_group_ids","service_tiers","session_ids","slack_channel_ids","speeds","starting_at","time_bucket_width","user_profile_ids","workspace_ids"]})})}}class oP extends ne{list(e,t){return this._client.getAPIList("/v1/organizations/analytics/cost_report",s8,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.cost_report.list",t,{route:"/v1/organizations/analytics/cost_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","group_by","inference_geos","limit","models","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}}class oT extends ne{list(e={},t){return this._client.getAPIList("/v1/organizations/analytics/plugins",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.plugins.list",t,{route:"/v1/organizations/analytics/plugins",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}}class oE extends ne{list(e={},t){return this._client.getAPIList("/v1/organizations/analytics/skills",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.skills.list",t,{route:"/v1/organizations/analytics/skills",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}}class oO extends ne{list(e,t){return this._client.getAPIList("/v1/organizations/analytics/summaries",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.summaries.list",t,{route:"/v1/organizations/analytics/summaries",queryParams:["ending_date","filter","limit","page","starting_date"]})})}}class oM extends ne{list(e,t){let{betas:i,...r}=e;return this._client.getAPIList("/v1/organizations/analytics/usage",s8,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"analytics-usage-cost-2026-08-24"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.usage.list",t,{route:"/v1/organizations/analytics/usage",queryParams:["actor_ids","actor_types","agent_ids","api_key_ids","claude_tag_categories","claude_tag_user_ids","context_windows","deployment_ids","ending_at","environment_ids","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","page","products","rbac_group_ids","service_tiers","session_ids","slack_channel_ids","speeds","starting_at","time_bucket_width","user_profile_ids","workspace_ids"]})})}}class oL extends ne{list(e,t){return this._client.getAPIList("/v1/organizations/analytics/usage_report",s8,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.usage_report.list",t,{route:"/v1/organizations/analytics/usage_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","group_by","inference_geos","limit","models","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}}class oC extends ne{list(e,t){return this._client.getAPIList("/v1/organizations/analytics/user_cost_report",s8,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.user_cost_report.list",t,{route:"/v1/organizations/analytics/user_cost_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}}class oN extends ne{list(e,t){return this._client.getAPIList("/v1/organizations/analytics/user_usage_report",s8,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.user_usage_report.list",t,{route:"/v1/organizations/analytics/user_usage_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}}class oj extends ne{list(e={},t){return this._client.getAPIList("/v1/organizations/analytics/users",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.users.list",t,{route:"/v1/organizations/analytics/users",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["page"]})})}}class oD extends ne{list(e={},t){return this._client.getAPIList("/v1/organizations/analytics/apps/chat/projects",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.analytics.apps.chat.projects.list",t,{route:"/v1/organizations/analytics/apps/chat/projects",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"]})})}}var oW=(()=>{class e extends ne{constructor(){super(...arguments),this.projects=new oD(this._client)}}return e.Projects=oD,e})(),oU=(()=>{class e extends ne{constructor(){super(...arguments),this.chat=new oW(this._client)}}return e.Chat=oW,e})(),oF=(()=>{class e extends ne{constructor(){super(...arguments),this.summaries=new oO(this._client),this.users=new oj(this._client),this.apps=new oU(this._client),this.connectors=new o$(this._client),this.plugins=new oT(this._client),this.skills=new oE(this._client),this.artifacts=new oq(this._client),this.usage=new oM(this._client),this.cost=new oR(this._client),this.usageReport=new oL(this._client),this.userUsageReport=new oN(this._client),this.costReport=new oP(this._client),this.userCostReport=new oC(this._client)}}return e.Summaries=oO,e.Users=oj,e.Apps=oU,e.Connectors=o$,e.Plugins=oT,e.Skills=oE,e.Artifacts=oq,e.Usage=oM,e.Cost=oR,e.UsageReport=oL,e.UserUsageReport=oN,e.CostReport=oP,e.UserCostReport=oC,e})();class oH extends ne{create(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/claude_tag/slack_channels",{body:r,...t,headers:rR([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.slack_channels.create",t,{route:"/v1/organizations/claude_tag/slack_channels",createdIDAttribute:"anthropic.organization.claude_tag.slack_channel.id"})})}retrieve(e,t={},i){let{betas:r,...s}=t??{};return this._client.get(nb`/v1/organizations/claude_tag/slack_channels/${e}`,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.slack_channels.retrieve",i,{route:"/v1/organizations/claude_tag/slack_channels/{id}",queryParams:["include_inherited"],attributes:{"anthropic.organization.claude_tag.slack_channel.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/claude_tag/slack_channels/${e}`,{body:s,...i,headers:rR([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.slack_channels.update",i,{route:"/v1/organizations/claude_tag/slack_channels/{id}",attributes:{"anthropic.organization.claude_tag.slack_channel.id":e}})})}list(e,t){let{betas:i,...r}=e;return this._client.getAPIList("/v1/organizations/claude_tag/slack_channels",s4,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.slack_channels.list",t,{route:"/v1/organizations/claude_tag/slack_channels",queryParams:["include_inherited","limit","page","slack_channel_id","slack_workspace_id"]})})}delete(e,t={},i){let{betas:r}=t??{};return this._client.delete(nb`/v1/organizations/claude_tag/slack_channels/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.slack_channels.delete",i,{route:"/v1/organizations/claude_tag/slack_channels/{id}",attributes:{"anthropic.organization.claude_tag.slack_channel.id":e}})})}}class oB extends ne{retrieve(e,t={},i){let{betas:r,...s}=t??{};return this._client.get(nb`/v1/organizations/claude_tag/slack_workspaces/${e}`,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.slack_workspaces.retrieve",i,{route:"/v1/organizations/claude_tag/slack_workspaces/{id}",queryParams:["include_inherited"],attributes:{"anthropic.organization.claude_tag.slack_workspace.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/claude_tag/slack_workspaces/${e}`,{body:s,...i,headers:rR([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.slack_workspaces.update",i,{route:"/v1/organizations/claude_tag/slack_workspaces/{id}",attributes:{"anthropic.organization.claude_tag.slack_workspace.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/claude_tag/slack_workspaces",s4,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.slack_workspaces.list",t,{route:"/v1/organizations/claude_tag/slack_workspaces",queryParams:["include_inherited","limit","page","slack_workspace_id"]})})}}class oK extends ne{create(e,t,i){let{target:r,betas:s}=t;return this._client.post(nb`/v1/organizations/claude_tag/bundles/${e}/targets`,{body:r,...i,headers:rR([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.bundles.targets.create",i,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets",attributes:{"anthropic.organization.claude_tag.bundle.id":e}})})}retrieve(e,t,i){let{bundle_id:r,betas:s}=t;return this._client.get(nb`/v1/organizations/claude_tag/bundles/${r}/targets/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.bundles.targets.retrieve",i,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets/{target_id}",attributes:{"anthropic.organization.claude_tag.bundle.id":r,"anthropic.organization.claude_tag.bundle.target.id":e}})})}list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/organizations/claude_tag/bundles/${e}/targets`,s4,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.bundles.targets.list",i,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets",queryParams:["limit","page"],attributes:{"anthropic.organization.claude_tag.bundle.id":e}})})}delete(e,t,i){let{bundle_id:r,betas:s}=t;return this._client.delete(nb`/v1/organizations/claude_tag/bundles/${r}/targets/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.bundles.targets.delete",i,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets/{target_id}",attributes:{"anthropic.organization.claude_tag.bundle.id":r,"anthropic.organization.claude_tag.bundle.target.id":e}})})}}var oJ=(()=>{class e extends ne{constructor(){super(...arguments),this.targets=new oK(this._client)}retrieve(e,t={},i){let{betas:r}=t??{};return this._client.get(nb`/v1/organizations/claude_tag/bundles/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.bundles.retrieve",i,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}",attributes:{"anthropic.organization.claude_tag.bundle.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/claude_tag/bundles",s4,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.claude_tag.bundles.list",t,{route:"/v1/organizations/claude_tag/bundles",queryParams:["limit","page"]})})}}return e.Targets=oK,e})(),oG=(()=>{class e extends ne{constructor(){super(...arguments),this.slackChannels=new oH(this._client),this.slackWorkspaces=new oB(this._client),this.bundles=new oJ(this._client)}}return e.SlackChannels=oH,e.SlackWorkspaces=oB,e.Bundles=oJ,e})();class oX extends ne{create(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/federation_issuers",{body:r,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.issuers.create",t,{route:"/v1/organizations/federation_issuers",createdIDAttribute:"anthropic.organization.federation_issuer.id"})})}retrieve(e,t={},i){let{betas:r}=t??{};return this._client.get(nb`/v1/organizations/federation_issuers/${e}`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.issuers.retrieve",i,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/federation_issuers/${e}`,{body:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.issuers.update",i,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/federation_issuers",s4,{query:r,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.issuers.list",t,{route:"/v1/organizations/federation_issuers",queryParams:["include_archived","limit","page"]})})}archive(e,t={},i){let{betas:r}=t??{};return this._client.post(nb`/v1/organizations/federation_issuers/${e}/archive`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.issuers.archive",i,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}/archive",attributes:{"anthropic.organization.federation_issuer.id":e}})})}}class oQ extends ne{list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/organizations/federation_rules/${e}/workspaces`,s4,{query:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.rules.workspaces.list",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.federation_rule.id":e}})})}add(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/federation_rules/${e}/workspaces`,{body:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.rules.workspaces.add",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",attributes:{"anthropic.organization.federation_rule.id":e},createdIDAttribute:"anthropic.organization.federation_rule.workspace.id",createdIDField:"workspace_id"})})}remove(e,t,i){let{federation_rule_id:r,betas:s}=t;return this._client.delete(nb`/v1/organizations/federation_rules/${r}/workspaces/${e}`,{...i,headers:rR([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.rules.workspaces.remove",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.federation_rule.id":r,"anthropic.organization.federation_rule.workspace.id":e}})})}}var oY=(()=>{class e extends ne{constructor(){super(...arguments),this.workspaces=new oQ(this._client)}create(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/federation_rules",{body:r,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.rules.create",t,{route:"/v1/organizations/federation_rules",createdIDAttribute:"anthropic.organization.federation_rule.id"})})}retrieve(e,t={},i){let{betas:r}=t??{};return this._client.get(nb`/v1/organizations/federation_rules/${e}`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.rules.retrieve",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/federation_rules/${e}`,{body:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.rules.update",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/federation_rules",s4,{query:r,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.rules.list",t,{route:"/v1/organizations/federation_rules",queryParams:["include_archived","issuer_id","limit","page"]})})}archive(e,t={},i){let{betas:r}=t??{};return this._client.post(nb`/v1/organizations/federation_rules/${e}/archive`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.federation.rules.archive",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}/archive",attributes:{"anthropic.organization.federation_rule.id":e}})})}}return e.Workspaces=oQ,e})(),oZ=(()=>{class e extends ne{constructor(){super(...arguments),this.issuers=new oX(this._client),this.rules=new oY(this._client)}}return e.Issuers=oX,e.Rules=oY,e})();class o0 extends ne{list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/organizations/plugins/${e}/installation_settings`,s4,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.installation_settings.list",i,{route:"/v1/organizations/plugins/{plugin_id}/installation_settings",queryParams:["limit","organization_id","page","target_type"],attributes:{"anthropic.organization.plugin.id":e}})})}remove(e,t,i){let{plugin_id:r,betas:s}=t;return this._client.delete(nb`/v1/organizations/plugins/${r}/installation_settings/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.installation_settings.remove",i,{route:"/v1/organizations/plugins/{plugin_id}/installation_settings/{target}",attributes:{"anthropic.organization.plugin.id":r,"anthropic.organization.plugin.installation_setting.id":e}})})}set(e,t,i){let{plugin_id:r,betas:s,...n}=t;return this._client.post(nb`/v1/organizations/plugins/${r}/installation_settings/${e}`,{body:n,...i,headers:rR([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.installation_settings.set",i,{route:"/v1/organizations/plugins/{plugin_id}/installation_settings/{target}",attributes:{"anthropic.organization.plugin.id":r,"anthropic.organization.plugin.installation_setting.id":e}})})}}class o1 extends ne{list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/organizations/plugins/${e}/shares`,s4,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.shares.list",i,{route:"/v1/organizations/plugins/{plugin_id}/shares",queryParams:["limit","organization_id","page","target_type"],attributes:{"anthropic.organization.plugin.id":e}})})}}class o2 extends ne{create(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/plugins/${e}/versions`,sG({body:s,...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.versions.create",i,{route:"/v1/organizations/plugins/{plugin_id}/versions",attributes:{"anthropic.organization.plugin.id":e},createdIDAttribute:"anthropic.organization.plugin.version.id"})},this._client))}retrieve(e,t,i){let{plugin_id:r,betas:s,...n}=t;return this._client.get(nb`/v1/organizations/plugins/${r}/versions/${e}`,{query:n,...i,headers:rR([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.versions.retrieve",i,{route:"/v1/organizations/plugins/{plugin_id}/versions/{version}",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin.id":r,"anthropic.organization.plugin.version.id":e}})})}list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/organizations/plugins/${e}/versions`,s4,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.versions.list",i,{route:"/v1/organizations/plugins/{plugin_id}/versions",queryParams:["limit","organization_id","page"],attributes:{"anthropic.organization.plugin.id":e}})})}download(e,t,i){let{plugin_id:r,betas:s,...n}=t;return this._client.get(nb`/v1/organizations/plugins/${r}/versions/${e}/content`,{query:n,...i,headers:rR([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString(),Accept:"application/binary"},i?.headers]),__qualifiers:{beta:"true"},__binaryResponse:!0,__span:rC(this._client,"anthropic.organization.plugins.versions.download",i,{route:"/v1/organizations/plugins/{plugin_id}/versions/{version}/content",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin.id":r,"anthropic.organization.plugin.version.id":e}})})}}var o6=(()=>{class e extends ne{constructor(){super(...arguments),this.versions=new o2(this._client),this.installationSettings=new o0(this._client),this.shares=new o1(this._client)}create(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/plugins",sG({body:r,...t,headers:rR([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.create",t,{route:"/v1/organizations/plugins",createdIDAttribute:"anthropic.organization.plugin.id"})},this._client))}retrieve(e,t={},i){let{betas:r,...s}=t??{};return this._client.get(nb`/v1/organizations/plugins/${e}`,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.retrieve",i,{route:"/v1/organizations/plugins/{plugin_id}",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/plugins/${e}`,{body:s,...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.update",i,{route:"/v1/organizations/plugins/{plugin_id}",attributes:{"anthropic.organization.plugin.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/plugins",s4,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.list",t,{route:"/v1/organizations/plugins",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","limit","marketplace_id","organization_id","owner_type","owner_user_id","page"]})})}delete(e,t={},i){let{betas:r}=t??{};return this._client.delete(nb`/v1/organizations/plugins/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.plugins.delete",i,{route:"/v1/organizations/plugins/{plugin_id}",attributes:{"anthropic.organization.plugin.id":e}})})}}return e.Versions=o2,e.InstallationSettings=o0,e.Shares=o1,e})();class o4 extends ne{list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/rbac_groups/${e}/members`,s4,{query:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_groups.members.list",i,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_group.id":e}})})}add(e,t,i){return this._client.post(nb`/v1/organizations/rbac_groups/${e}/members`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_groups.members.add",i,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",attributes:{"anthropic.organization.rbac_group.id":e},createdIDAttribute:"anthropic.organization.rbac_group.member.id",createdIDField:"user_id"})})}remove(e,t,i){let{rbac_group_id:r}=t;return this._client.delete(nb`/v1/organizations/rbac_groups/${r}/members/${e}`,{...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_groups.members.remove",i,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members/{user_id}",attributes:{"anthropic.organization.rbac_group.id":r,"anthropic.organization.rbac_group.member.id":e}})})}}var o5=(()=>{class e extends ne{constructor(){super(...arguments),this.members=new o4(this._client)}create(e,t){return this._client.post("/v1/organizations/rbac_groups",{body:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_groups.create",t,{route:"/v1/organizations/rbac_groups",createdIDAttribute:"anthropic.organization.rbac_group.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/rbac_groups/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_groups.retrieve",t,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/rbac_groups/${e}`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_groups.update",i,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/rbac_groups",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_groups.list",t,{route:"/v1/organizations/rbac_groups",queryParams:["limit","page"]})})}delete(e,t){return this._client.delete(nb`/v1/organizations/rbac_groups/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_groups.delete",t,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}}return e.Members=o4,e})();class o8 extends ne{list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/rbac_roles/${e}/permissions`,s4,{query:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_roles.permissions.list",i,{route:"/v1/organizations/rbac_roles/{rbac_role_id}/permissions",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_role.id":e}})})}}var o3=(()=>{class e extends ne{constructor(){super(...arguments),this.permissions=new o8(this._client)}retrieve(e,t){return this._client.get(nb`/v1/organizations/rbac_roles/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_roles.retrieve",t,{route:"/v1/organizations/rbac_roles/{rbac_role_id}",attributes:{"anthropic.organization.rbac_role.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/rbac_roles",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.rbac_roles.list",t,{route:"/v1/organizations/rbac_roles",queryParams:["limit","page"]})})}}return e.Permissions=o8,e})();class o9 extends ne{list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/organizations/service_accounts/${e}/workspaces`,s4,{query:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.service_accounts.workspaces.list",i,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.service_account.id":e}})})}add(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/service_accounts/${e}/workspaces`,{body:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.service_accounts.workspaces.add",i,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",attributes:{"anthropic.organization.service_account.id":e},createdIDAttribute:"anthropic.organization.service_account.workspace.id",createdIDField:"workspace_id"})})}remove(e,t,i){let{service_account_id:r,betas:s}=t;return this._client.delete(nb`/v1/organizations/service_accounts/${r}/workspaces/${e}`,{...i,headers:rR([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.service_accounts.workspaces.remove",i,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.service_account.id":r,"anthropic.organization.service_account.workspace.id":e}})})}}var o7=(()=>{class e extends ne{constructor(){super(...arguments),this.workspaces=new o9(this._client)}create(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/service_accounts",{body:r,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.service_accounts.create",t,{route:"/v1/organizations/service_accounts",createdIDAttribute:"anthropic.organization.service_account.id"})})}retrieve(e,t={},i){let{betas:r}=t??{};return this._client.get(nb`/v1/organizations/service_accounts/${e}`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.service_accounts.retrieve",i,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/service_accounts/${e}`,{body:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.service_accounts.update",i,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/service_accounts",s4,{query:r,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.service_accounts.list",t,{route:"/v1/organizations/service_accounts",queryParams:["include_archived","limit","page"]})})}archive(e,t={},i){let{betas:r}=t??{};return this._client.post(nb`/v1/organizations/service_accounts/${e}/archive`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.service_accounts.archive",i,{route:"/v1/organizations/service_accounts/{service_account_id}/archive",attributes:{"anthropic.organization.service_account.id":e}})})}}return e.Workspaces=o9,e})();class le extends ne{list(e={},t){return this._client.getAPIList("/v1/organizations/spend_limits/effective",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.effective.list",t,{route:"/v1/organizations/spend_limits/effective",queryParams:["limit","page","period","user_ids"]})})}}class lt extends ne{retrieve(e,t){return this._client.get(nb`/v1/organizations/spend_limit_increase_requests/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.increase_requests.retrieve",t,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}",attributes:{"anthropic.organization.spend_limit_increase_request.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/spend_limit_increase_requests",s4,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.increase_requests.list",t,{route:"/v1/organizations/spend_limit_increase_requests",queryParams:["actor_ids","limit","page","status"]})})}approve(e,t,i){return this._client.post(nb`/v1/organizations/spend_limit_increase_requests/${e}/approve`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.increase_requests.approve",i,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/approve",attributes:{"anthropic.organization.spend_limit_increase_request.id":e}})})}deny(e,t,i){return this._client.post(nb`/v1/organizations/spend_limit_increase_requests/${e}/deny`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.increase_requests.deny",i,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/deny",attributes:{"anthropic.organization.spend_limit_increase_request.id":e}})})}}var li=(()=>{class e extends ne{constructor(){super(...arguments),this.effective=new le(this._client),this.increaseRequests=new lt(this._client)}retrieve(e,t){return this._client.get(nb`/v1/organizations/spend_limits/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.retrieve",t,{route:"/v1/organizations/spend_limits/{spend_limit_id}",attributes:{"anthropic.organization.spend_limit.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/spend_limits",s4,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"spend-limit-reads-2026-09-26"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.list",t,{route:"/v1/organizations/spend_limits",queryParams:["limit","page","scope_type","workspace_id"]})})}delete(e,t){return this._client.delete(nb`/v1/organizations/spend_limits/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.delete",t,{route:"/v1/organizations/spend_limits/{spend_limit_id}",attributes:{"anthropic.organization.spend_limit.id":e}})})}set(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/spend_limits",{body:r,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.spend_limits.set",t,{route:"/v1/organizations/spend_limits",createdIDAttribute:"anthropic.organization.spend_limit.id"})})}}return e.Effective=le,e.IncreaseRequests=lt,e})();class lr extends ne{list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/organizations/telemetry_destinations/${e}/workspaces`,s4,{query:s,...i,headers:rR([{"anthropic-beta":[...r??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.workspaces.list",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.telemetry_destination.id":e}})})}add(e,t,i){let{destination_id:r,betas:s}=t;return this._client.post(nb`/v1/organizations/telemetry_destinations/${r}/workspaces/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.workspaces.add",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.telemetry_destination.id":r,"anthropic.organization.telemetry_destination.workspace.id":e}})})}remove(e,t,i){let{destination_id:r,betas:s}=t;return this._client.delete(nb`/v1/organizations/telemetry_destinations/${r}/workspaces/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.workspaces.remove",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.telemetry_destination.id":r,"anthropic.organization.telemetry_destination.workspace.id":e}})})}}var ls=(()=>{class e extends ne{constructor(){super(...arguments),this.workspaces=new lr(this._client)}create(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/telemetry_destinations",{body:r,...t,headers:rR([{"anthropic-beta":[...i??[],"telemetry-destinations-2026-08-11"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.create",t,{route:"/v1/organizations/telemetry_destinations",createdIDAttribute:"anthropic.organization.telemetry_destination.id"})})}retrieve(e,t={},i){let{betas:r}=t??{};return this._client.get(nb`/v1/organizations/telemetry_destinations/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.retrieve",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}",attributes:{"anthropic.organization.telemetry_destination.id":e}})})}update(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/telemetry_destinations/${e}`,{body:s,...i,headers:rR([{"anthropic-beta":[...r??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.update",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}",attributes:{"anthropic.organization.telemetry_destination.id":e}})})}list(e={},t){let{betas:i,...r}=e??{};return this._client.getAPIList("/v1/organizations/telemetry_destinations",s4,{query:r,...t,headers:rR([{"anthropic-beta":[...i??[],"telemetry-destinations-2026-08-11"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.list",t,{route:"/v1/organizations/telemetry_destinations",queryParams:["limit","page","workspace_ids"]})})}delete(e,t={},i){let{betas:r}=t??{};return this._client.delete(nb`/v1/organizations/telemetry_destinations/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.delete",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}",attributes:{"anthropic.organization.telemetry_destination.id":e}})})}test(e,t={},i){let{betas:r}=t??{};return this._client.post(nb`/v1/organizations/telemetry_destinations/${e}/test`,{...i,headers:rR([{"anthropic-beta":[...r??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.telemetry_destinations.test",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}/test",attributes:{"anthropic.organization.telemetry_destination.id":e}})})}}return e.Workspaces=lr,e})();class ln extends ne{retrieve(e,t,i){let{workspace_id:r}=t;return this._client.get(nb`/v1/organizations/workspaces/${r}/members/${e}`,{...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.members.retrieve",i,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.member.id":e}})})}update(e,t,i){let{workspace_id:r,...s}=t;return this._client.post(nb`/v1/organizations/workspaces/${r}/members/${e}`,{body:s,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.members.update",i,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.member.id":e}})})}list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/workspaces/${e}/members`,s6,{query:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.members.list",i,{route:"/v1/organizations/workspaces/{workspace_id}/members",queryParams:["after_id","before_id","limit"],attributes:{"anthropic.organization.workspace.id":e}})})}add(e,t,i){return this._client.post(nb`/v1/organizations/workspaces/${e}/members`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.members.add",i,{route:"/v1/organizations/workspaces/{workspace_id}/members",attributes:{"anthropic.organization.workspace.id":e},createdIDAttribute:"anthropic.organization.workspace.member.id",createdIDField:"user_id"})})}remove(e,t,i){let{workspace_id:r}=t;return this._client.delete(nb`/v1/organizations/workspaces/${r}/members/${e}`,{...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.members.remove",i,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.member.id":e}})})}}class la extends ne{update(e,t,i){let{workspace_id:r,...s}=t;return this._client.post(nb`/v1/organizations/workspaces/${r}/rate_limits/${e}`,{body:s,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.rate_limits.update",i,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits/{rate_limit_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.rate_limit.id":e}})})}list(e,t={},i){return this._client.getAPIList(nb`/v1/organizations/workspaces/${e}/rate_limits`,s4,{query:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.rate_limits.list",i,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits",queryParams:["group_type","include_inherited","limit","page"],attributes:{"anthropic.organization.workspace.id":e}})})}}class lo extends ne{retrieve(e,t,i){let{workspace_id:r,betas:s}=t;return this._client.get(nb`/v1/organizations/workspaces/${r}/service_accounts/${e}`,{...i,headers:rR([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.retrieve",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.service_account.id":e}})})}update(e,t,i){let{workspace_id:r,betas:s,...n}=t;return this._client.post(nb`/v1/organizations/workspaces/${r}/service_accounts/${e}`,{body:n,...i,headers:rR([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.update",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.service_account.id":e}})})}list(e,t={},i){let{betas:r,...s}=t??{};return this._client.getAPIList(nb`/v1/organizations/workspaces/${e}/service_accounts`,s4,{query:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.list",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",queryParams:["limit","page"],attributes:{"anthropic.organization.workspace.id":e}})})}add(e,t,i){let{betas:r,...s}=t;return this._client.post(nb`/v1/organizations/workspaces/${e}/service_accounts`,{body:s,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.add",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",attributes:{"anthropic.organization.workspace.id":e},createdIDAttribute:"anthropic.organization.workspace.service_account.id",createdIDField:"service_account_id"})})}remove(e,t,i){let{workspace_id:r,betas:s}=t;return this._client.delete(nb`/v1/organizations/workspaces/${r}/service_accounts/${e}`,{...i,headers:rR([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.service_accounts.remove",i,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":r,"anthropic.organization.workspace.service_account.id":e}})})}}var ll=(()=>{class e extends ne{constructor(){super(...arguments),this.rateLimits=new la(this._client),this.members=new ln(this._client),this.serviceAccounts=new lo(this._client)}create(e,t){let{betas:i,...r}=e;return this._client.post("/v1/organizations/workspaces",{body:r,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.create",t,{route:"/v1/organizations/workspaces",createdIDAttribute:"anthropic.organization.workspace.id"})})}retrieve(e,t){return this._client.get(nb`/v1/organizations/workspaces/${e}`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.retrieve",t,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}update(e,t,i){return this._client.post(nb`/v1/organizations/workspaces/${e}`,{body:t,...i,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.update",i,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/workspaces",s6,{query:e,...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.list",t,{route:"/v1/organizations/workspaces",queryParams:["after_id","before_id","include_archived","include_default","limit"]})})}archive(e,t){return this._client.post(nb`/v1/organizations/workspaces/${e}/archive`,{...t,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.workspaces.archive",t,{route:"/v1/organizations/workspaces/{workspace_id}/archive",attributes:{"anthropic.organization.workspace.id":e}})})}}return e.RateLimits=la,e.Members=ln,e.ServiceAccounts=lo,e})(),lc=(()=>{class e extends ne{constructor(){super(...arguments),this.apiKeys=new ow(this._client),this.externalKeys=new oz(this._client),this.federation=new oZ(this._client),this.invites=new oS(this._client),this.serviceAccounts=new o7(this._client),this.users=new oA(this._client),this.workspaces=new ll(this._client),this.rateLimits=new oV(this._client),this.complianceSettings=new ok(this._client),this.analytics=new oF(this._client),this.spendLimits=new li(this._client),this.rbacGroups=new o5(this._client),this.rbacRoles=new o3(this._client),this.plugins=new o6(this._client),this.pluginMarketplaces=new ox(this._client),this.telemetryDestinations=new ls(this._client),this.webhooks=new oI(this._client),this.claudeTag=new oG(this._client)}retrieve(e){return this._client.get("/v1/organizations/me",{...e,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.organization.retrieve",e,{route:"/v1/organizations/me"})})}}return e.APIKeys=ow,e.ExternalKeys=oz,e.Federation=oZ,e.Invites=oS,e.ServiceAccounts=o7,e.Users=oA,e.Workspaces=ll,e.RateLimits=oV,e.ComplianceSettings=ok,e.Analytics=oF,e.SpendLimits=li,e.RBACGroups=o5,e.RBACRoles=o3,e.Plugins=o6,e.PluginMarketplaces=ox,e.TelemetryDestinations=ls,e.Webhooks=oI,e.ClaudeTag=oG,e})(),lu=(()=>{class e extends ne{list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/sessions/${e}/events`,s4,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.events.list",i,{route:"/v1/sessions/{session_id}/events",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","limit","order","page","types"],attributes:{"anthropic.session.id":e}})})}send(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/sessions/${e}/events`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.events.send",i,{route:"/v1/sessions/{session_id}/events",attributes:{"anthropic.session.id":e}})})}stream(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.get(nb`/v1/sessions/${e}/events/stream`,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),stream:!0,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.events.stream",i,{route:"/v1/sessions/{session_id}/events/stream",queryParams:["event_deltas"],attributes:{"anthropic.session.id":e}})})}toolRunner(e,t){return new af(e,{...t,client:this._client})}}return e.SessionToolRunner=af,e})();class lh extends ne{retrieve(e,t,i){let{session_id:r,betas:s,workspace_id:n}=t;return this._client.get(nb`/v1/sessions/${r}/resources/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.resources.retrieve",i,{route:"/v1/sessions/{session_id}/resources/{resource_id}",attributes:{"anthropic.session.id":r,"anthropic.session.resource.id":e}})})}update(e,t,i){let{session_id:r,betas:s,workspace_id:n,...a}=t;return this._client.post(nb`/v1/sessions/${r}/resources/${e}`,{body:a,...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.resources.update",i,{route:"/v1/sessions/{session_id}/resources/{resource_id}",attributes:{"anthropic.session.id":r,"anthropic.session.resource.id":e}})})}list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/sessions/${e}/resources`,s4,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.resources.list",i,{route:"/v1/sessions/{session_id}/resources",queryParams:["limit","page"],attributes:{"anthropic.session.id":e}})})}delete(e,t,i){let{session_id:r,betas:s,workspace_id:n}=t;return this._client.delete(nb`/v1/sessions/${r}/resources/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.resources.delete",i,{route:"/v1/sessions/{session_id}/resources/{resource_id}",attributes:{"anthropic.session.id":r,"anthropic.session.resource.id":e}})})}add(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/sessions/${e}/resources`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.resources.add",i,{route:"/v1/sessions/{session_id}/resources",attributes:{"anthropic.session.id":e},createdIDAttribute:"anthropic.session.resource.id"})})}}class ld extends ne{list(e,t,i){let{session_id:r,betas:s,workspace_id:n,...a}=t;return this._client.getAPIList(nb`/v1/sessions/${r}/threads/${e}/events`,s4,{query:a,...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.threads.events.list",i,{route:"/v1/sessions/{session_id}/threads/{thread_id}/events",queryParams:["limit","page"],attributes:{"anthropic.session.id":r,"anthropic.session.thread.id":e}})})}stream(e,t,i){let{session_id:r,betas:s,workspace_id:n,...a}=t;return this._client.get(nb`/v1/sessions/${r}/threads/${e}/stream`,{query:a,...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),stream:!0,__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.threads.events.stream",i,{route:"/v1/sessions/{session_id}/threads/{thread_id}/stream",queryParams:["event_deltas"],attributes:{"anthropic.session.id":r,"anthropic.session.thread.id":e}})})}}var lp=(()=>{class e extends ne{constructor(){super(...arguments),this.events=new ld(this._client)}retrieve(e,t,i){let{session_id:r,betas:s,workspace_id:n}=t;return this._client.get(nb`/v1/sessions/${r}/threads/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.threads.retrieve",i,{route:"/v1/sessions/{session_id}/threads/{thread_id}",attributes:{"anthropic.session.id":r,"anthropic.session.thread.id":e}})})}list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/sessions/${e}/threads`,s4,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.threads.list",i,{route:"/v1/sessions/{session_id}/threads",queryParams:["limit","page","statuses"],attributes:{"anthropic.session.id":e}})})}archive(e,t,i){let{session_id:r,betas:s,workspace_id:n}=t;return this._client.post(nb`/v1/sessions/${r}/threads/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.threads.archive",i,{route:"/v1/sessions/{session_id}/threads/{thread_id}/archive",attributes:{"anthropic.session.id":r,"anthropic.session.thread.id":e}})})}}return e.Events=ld,e})(),l_=(()=>{class e extends ne{constructor(){super(...arguments),this.events=new lu(this._client),this.resources=new lh(this._client),this.threads=new lp(this._client)}create(e,t){let{betas:i,workspace_id:r,...s}=e,n=rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),a=rC(this._client,"anthropic.sessions.create",t,{route:"/v1/sessions",attributes:{"gen_ai.agent.id":"object"==typeof s.agent?s.agent?.id:s.agent,"anthropic.session.environment.id":s.environment_id},createdIDAttribute:"anthropic.session.id"}),o=this._client.post("/v1/sessions",{body:s,...t,headers:n,__qualifiers:{beta:"true"},__span:a});return a?o._thenUnwrap(e=>{var t=this._client;try{a?.span.setAttributes({"gen_ai.agent.name":e.agent.name,[so]:e.agent.model.id})}catch(e){(0,rz.u)(t).debug("could not record the response on its span",e)}return e}):o}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/sessions/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.retrieve",i,{route:"/v1/sessions/{session_id}",attributes:{"anthropic.session.id":e}})})}update(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/sessions/${e}`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.update",i,{route:"/v1/sessions/{session_id}",attributes:{"anthropic.session.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/sessions",s5,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.list",t,{route:"/v1/sessions",queryParams:["agent_id","agent_version","created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","deployment_id","include_archived","limit","memory_store_id","order","page","statuses"]})})}delete(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.delete(nb`/v1/sessions/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.delete",i,{route:"/v1/sessions/{session_id}",attributes:{"anthropic.session.id":e}})})}archive(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/sessions/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.sessions.archive",i,{route:"/v1/sessions/{session_id}/archive",attributes:{"anthropic.session.id":e}})})}}return e.Events=lu,e.Resources=lh,e.Threads=lp,e})();class lf extends ne{create(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/skills/${e}/versions`,sG({body:n,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.skills.versions.create",i,{route:"/v1/skills/{skill_id}/versions",attributes:{"anthropic.skill.id":e},createdIDAttribute:"anthropic.skill.version.id"})},this._client,!1))}retrieve(e,t,i){let{skill_id:r,betas:s,workspace_id:n}=t;return this._client.get(nb`/v1/skills/${r}/versions/${e}`,{...i,headers:rR([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.skills.versions.retrieve",i,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":r,"anthropic.skill.version.id":e}})})}list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/skills/${e}/versions`,s4,{query:n,...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.skills.versions.list",i,{route:"/v1/skills/{skill_id}/versions",queryParams:["limit","page"],attributes:{"anthropic.skill.id":e}})})}delete(e,t,i){let{skill_id:r,betas:s,workspace_id:n}=t;return this._client.delete(nb`/v1/skills/${r}/versions/${e}`,{...i,headers:rR([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.skills.versions.delete",i,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":r,"anthropic.skill.version.id":e}})})}download(e,t,i){let{skill_id:r,betas:s,workspace_id:n}=t;return this._client.get(nb`/v1/skills/${r}/versions/${e}/content`,{...i,headers:rR([{Accept:"application/binary",...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__binaryResponse:!0,__span:rC(this._client,"anthropic.skills.versions.download",i,{route:"/v1/skills/{skill_id}/versions/{version}/content",attributes:{"anthropic.skill.id":r,"anthropic.skill.version.id":e}})})}}var lg=(()=>{class e extends ne{constructor(){super(...arguments),this.versions=new lf(this._client)}create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/skills",sG({body:s,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.skills.create",t,{route:"/v1/skills",createdIDAttribute:"anthropic.skill.id"})},this._client,!1))}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/skills/${e}`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.skills.retrieve",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/skills",s4,{query:s,...t,headers:rR([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.skills.list",t,{route:"/v1/skills",queryParams:["limit","page","source"]})})}delete(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.delete(nb`/v1/skills/${e}`,{...i,headers:rR([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.skills.delete",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}}return e.Versions=lf,e})();class lm extends ne{create(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/tunnels/${e}/certificates`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"mcp-tunnels-2026-06-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.certificates.create",i,{route:"/v1/tunnels/{tunnel_id}/certificates",attributes:{"anthropic.tunnel.id":e},createdIDAttribute:"anthropic.tunnel.certificate.id"})})}retrieve(e,t,i){let{tunnel_id:r,betas:s,workspace_id:n}=t;return this._client.get(nb`/v1/tunnels/${r}/certificates/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.certificates.retrieve",i,{route:"/v1/tunnels/{tunnel_id}/certificates/{certificate_id}",attributes:{"anthropic.tunnel.id":r,"anthropic.tunnel.certificate.id":e}})})}list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/tunnels/${e}/certificates`,s4,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"mcp-tunnels-2026-06-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.certificates.list",i,{route:"/v1/tunnels/{tunnel_id}/certificates",queryParams:["include_archived","limit","page"],attributes:{"anthropic.tunnel.id":e}})})}archive(e,t,i){let{tunnel_id:r,betas:s,workspace_id:n}=t;return this._client.post(nb`/v1/tunnels/${r}/certificates/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.certificates.archive",i,{route:"/v1/tunnels/{tunnel_id}/certificates/{certificate_id}/archive",attributes:{"anthropic.tunnel.id":r,"anthropic.tunnel.certificate.id":e}})})}}var lv=(()=>{class e extends ne{constructor(){super(...arguments),this.certificates=new lm(this._client)}create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/tunnels",{body:s,...t,headers:rR([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.create",t,{route:"/v1/tunnels",createdIDAttribute:"anthropic.tunnel.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/tunnels/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"mcp-tunnels-2026-06-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.retrieve",i,{route:"/v1/tunnels/{tunnel_id}",attributes:{"anthropic.tunnel.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/tunnels",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.list",t,{route:"/v1/tunnels",queryParams:["include_archived","limit","page"]})})}archive(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/tunnels/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...r??[],"mcp-tunnels-2026-06-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.archive",i,{route:"/v1/tunnels/{tunnel_id}/archive",attributes:{"anthropic.tunnel.id":e}})})}revealToken(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/tunnels/${e}/reveal_token`,{...i,headers:rR([{"anthropic-beta":[...r??[],"mcp-tunnels-2026-06-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.reveal_token",i,{route:"/v1/tunnels/{tunnel_id}/reveal_token",attributes:{"anthropic.tunnel.id":e}})})}rotateToken(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/tunnels/${e}/rotate_token`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"mcp-tunnels-2026-06-22"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.tunnels.rotate_token",i,{route:"/v1/tunnels/{tunnel_id}/rotate_token",attributes:{"anthropic.tunnel.id":e}})})}}return e.Certificates=lm,e})();class lb extends ne{create(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/user_profiles/${e}/action_urls`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"user-profiles-2026-08-18"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.user_profiles.action_urls.create",i,{route:"/v1/user_profiles/{user_profile_id}/action_urls",attributes:{"anthropic.user_profile.id":e}})})}}var ly=(()=>{class e extends ne{constructor(){super(...arguments),this.actionURLs=new lb(this._client)}create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/user_profiles",{body:s,...t,headers:rR([{"anthropic-beta":[...i??[],"user-profiles-2026-08-18"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.user_profiles.create",t,{route:"/v1/user_profiles",createdIDAttribute:"anthropic.user_profile.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/user_profiles/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"user-profiles-2026-08-18"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.user_profiles.retrieve",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}update(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/user_profiles/${e}`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"user-profiles-2026-08-18"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.user_profiles.update",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/user_profiles",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"user-profiles-2026-08-18"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.user_profiles.list",t,{route:"/v1/user_profiles",queryParams:["limit","order","order_by","page"]})})}delete(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.delete(nb`/v1/user_profiles/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"user-profiles-2026-08-18"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.user_profiles.delete",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}createEnrollmentURL(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/user_profiles/${e}/enrollment_url`,{...i,headers:rR([{"anthropic-beta":[...r??[],"user-profiles-2026-08-18"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.user_profiles.create_enrollment_url",i,{route:"/v1/user_profiles/{user_profile_id}/enrollment_url",attributes:{"anthropic.user_profile.id":e}})})}}return e.ActionURLs=lb,e})();class lw extends ne{create(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/vaults/${e}/credentials`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.credentials.create",i,{route:"/v1/vaults/{vault_id}/credentials",attributes:{"anthropic.vault.id":e},createdIDAttribute:"anthropic.vault.credential.id"})})}retrieve(e,t,i){let{vault_id:r,betas:s,workspace_id:n}=t;return this._client.get(nb`/v1/vaults/${r}/credentials/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.credentials.retrieve",i,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}",attributes:{"anthropic.vault.id":r,"anthropic.vault.credential.id":e}})})}update(e,t,i){let{vault_id:r,betas:s,workspace_id:n,...a}=t;return this._client.post(nb`/v1/vaults/${r}/credentials/${e}`,{body:a,...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.credentials.update",i,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}",attributes:{"anthropic.vault.id":r,"anthropic.vault.credential.id":e}})})}list(e,t={},i){let{betas:r,workspace_id:s,...n}=t??{};return this._client.getAPIList(nb`/v1/vaults/${e}/credentials`,s4,{query:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.credentials.list",i,{route:"/v1/vaults/{vault_id}/credentials",queryParams:["include_archived","limit","page"],attributes:{"anthropic.vault.id":e}})})}delete(e,t,i){let{vault_id:r,betas:s,workspace_id:n}=t;return this._client.delete(nb`/v1/vaults/${r}/credentials/${e}`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.credentials.delete",i,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}",attributes:{"anthropic.vault.id":r,"anthropic.vault.credential.id":e}})})}archive(e,t,i){let{vault_id:r,betas:s,workspace_id:n}=t;return this._client.post(nb`/v1/vaults/${r}/credentials/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.credentials.archive",i,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}/archive",attributes:{"anthropic.vault.id":r,"anthropic.vault.credential.id":e}})})}mcpOAuthValidate(e,t,i){let{vault_id:r,betas:s,workspace_id:n}=t;return this._client.post(nb`/v1/vaults/${r}/credentials/${e}/mcp_oauth_validate`,{...i,headers:rR([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...null!=n?{"anthropic-workspace-id":n}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.credentials.mcp_oauth_validate",i,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}/mcp_oauth_validate",attributes:{"anthropic.vault.id":r,"anthropic.vault.credential.id":e}})})}}var lk=(()=>{class e extends ne{constructor(){super(...arguments),this.credentials=new lw(this._client)}create(e,t){let{betas:i,workspace_id:r,...s}=e;return this._client.post("/v1/vaults",{body:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.create",t,{route:"/v1/vaults",createdIDAttribute:"anthropic.vault.id"})})}retrieve(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.get(nb`/v1/vaults/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.retrieve",i,{route:"/v1/vaults/{vault_id}",attributes:{"anthropic.vault.id":e}})})}update(e,t,i){let{betas:r,workspace_id:s,...n}=t;return this._client.post(nb`/v1/vaults/${e}`,{body:n,...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.update",i,{route:"/v1/vaults/{vault_id}",attributes:{"anthropic.vault.id":e}})})}list(e={},t){let{betas:i,workspace_id:r,...s}=e??{};return this._client.getAPIList("/v1/vaults",s4,{query:s,...t,headers:rR([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...null!=r?{"anthropic-workspace-id":r}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.list",t,{route:"/v1/vaults",queryParams:["include_archived","limit","page"]})})}delete(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.delete(nb`/v1/vaults/${e}`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.delete",i,{route:"/v1/vaults/{vault_id}",attributes:{"anthropic.vault.id":e}})})}archive(e,t={},i){let{betas:r,workspace_id:s}=t??{};return this._client.post(nb`/v1/vaults/${e}/archive`,{...i,headers:rR([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...null!=s?{"anthropic-workspace-id":s}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:rC(this._client,"anthropic.vaults.archive",i,{route:"/v1/vaults/{vault_id}/archive",attributes:{"anthropic.vault.id":e}})})}}return e.Credentials=lw,e})(),lz=(()=>{class e extends ne{constructor(){super(...arguments),this.models=new nY(this._client),this.messages=new ob(this._client),this.agents=new n2(this._client),this.environments=new az(this._client),this.sessions=new l_(this._client),this.deployments=new nG(this._client),this.deploymentRuns=new nJ(this._client),this.vaults=new lk(this._client),this.memoryStores=new aV(this._client),this.files=new nQ(this._client),this.skills=new lg(this._client),this.webhooks=new n0(this._client),this.userProfiles=new ly(this._client),this.dreams=new nX(this._client),this.tunnels=new lv(this._client),this.organization=new lc(this._client)}}return e.Models=nY,e.Messages=ob,e.Agents=n2,e.Environments=az,e.Sessions=l_,e.Deployments=nG,e.DeploymentRuns=nJ,e.Vaults=lk,e.MemoryStores=aV,e.Files=nQ,e.Skills=lg,e.Webhooks=n0,e.UserProfiles=ly,e.Dreams=nX,e.Tunnels=lv,e.Organization=lc,e})();let lS=!1;var lx=(()=>{class e{get credentials(){return this._authState.provider}get openTelemetry(){return(0,id.V)(this,iu,"f")}_instrumentationScope(){return{version:im}}constructor({baseURL:e=(0,rP.f)("ANTHROPIC_BASE_URL"),apiKey:t,authToken:i,webhookKey:r=(0,rP.f)("ANTHROPIC_WEBHOOK_SIGNING_KEY")??null,...s}={}){ia.add(this),this._requestAuthFlags=new WeakMap,il.set(this,void 0),ic.set(this,void 0),iu.set(this,void 0),this._genAIProviderName="anthropic",this._supportsMessageThreads=!1;let n={apiKey:t,authToken:i,...s},a=ip.y.filter(e=>null!=n[e]);if(a.length>1){let e=e=>e.map(e=>`\`${e}\``).join(", ");throw TypeError(`Pass at most one of ${e(ip.y)}. Received ${e(a)}.`)}let[o]=a,l=null!=o?null:{apiKey:void 0===t?(0,rP.f)("ANTHROPIC_API_KEY"):void 0,authToken:void 0===i?(0,rP.f)("ANTHROPIC_AUTH_TOKEN"):void 0},c=null!=o?{type:o,value:n[o]}:l?.apiKey!=null?{type:"apiKey",value:l.apiKey}:l?.authToken!=null?{type:"authToken",value:l.authToken}:{type:"defaultChain"},u={apiKey:"apiKey"===c.type?c.value:null,authToken:"authToken"===c.type?c.value:null,webhookKey:r,...s,baseURL:e||"https://api.anthropic.com"};u.dangerouslyAllowBrowser,this.baseURL=u.baseURL,this._baseURLIsExplicit=s.__baseURLIsExplicit??!!e,this.timeout=u.timeout??io.DEFAULT_TIMEOUT,this.logger=u.logger??console,this.logLevel=rz.I,this.logLevel=(0,rz.J)(u.logLevel,"ClientOptions.logLevel",(0,rz.u)(this))??(0,rz.J)((0,rP.f)("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",(0,rz.u)(this))??rz.I,l?.apiKey==null||null==l.authToken||lS||(lS=!0,(0,rz.u)(this).warn("Anthropic: ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN are both set. Using ANTHROPIC_API_KEY.")),this.fetchOptions=u.fetchOptions,this.maxRetries=(0,ip.H)("maxRetries",u.maxRetries??2);let h=this._instrumentationScope();(0,id.b)(this,iu,function(e){let{tracerProvider:t,propagation:i,traces:r}=!1===e?{traces:!1}:e??{propagation:(0,rP.f)("ANTHROPIC_OPEN_TELEMETRY_PROPAGATION")?.toLowerCase()!=="false",traces:{enabled:(0,rP.f)("ANTHROPIC_OPEN_TELEMETRY")?.toLowerCase()!=="false",contentMode:(0,rP.f)("ANTHROPIC_OPEN_TELEMETRY_TRACES_CONTENT_MODE")?.toLowerCase()==="content"?"content":"metadata_only",maxContentBytes:Number(/^\d+$/.exec((0,rP.f)("ANTHROPIC_OPEN_TELEMETRY_TRACES_MAX_CONTENT_BYTES")??"")?.[0]??0/0)}},{enabled:s,contentMode:n,maxContentBytes:a}="boolean"==typeof r?{enabled:r}:r??{};return Object.freeze({tracerProvider:t,propagation:i??!0,traces:Object.freeze({enabled:s??!0,contentMode:"content"===n?"content":"metadata_only",maxContentBytes:void 0!==a&&Number.isInteger(a)&&a>=1?a:75e4})})}(u.openTelemetry),"f"),u.openTelemetry=(0,id.V)(this,iu,"f"),this._tracer=rL(this,()=>(function(e,t,i){if(!e.traces.enabled)return;let r=void 0!==i?`${rT}.${i}`:rT;return(e.tracerProvider??rm.getTracerProvider()).getTracer(r,t)})((0,id.V)(this,iu,"f"),h.version,h.platform)),this.fetch=u.fetch??function(){if("u">typeof fetch)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`")}(),(0,id.b)(this,il,iq,"f"),this.middleware=[...u.middleware??[]];let d=(0,rP.f)("ANTHROPIC_CUSTOM_HEADERS");if(d){let e={};for(let t of d.split("\n")){let i=t.indexOf(":");i>=0&&(e[t.substring(0,i).trim()]=t.substring(i+1).trim())}u.defaultHeaders={...e,...u.defaultHeaders}}let p=s.__auth;if(delete u.__auth,delete u.__baseURLIsExplicit,this._options=u,this.apiKey="string"==typeof u.apiKey?u.apiKey:null,(0,id.b)(this,ic,"function"==typeof u.apiKey?u.apiKey:null,"f"),this.authToken=u.authToken??null,this.webhookKey=r,p)this._authState=p,!this._baseURLIsExplicit&&p.baseURL&&(this.baseURL=p.baseURL);else switch(this._authState={provider:null,tokenCache:null,resolution:null,error:null,extraHeaders:{}},c.type){case"apiKey":case"authToken":break;case"credentials":this._authState.provider=c.value,this._authState.tokenCache=this._makeTokenCache(c.value);break;case"config":{let e=sL(c.value,this._credentialResolverOptions());this._authState.provider=e.provider,this._authState.tokenCache=this._makeTokenCache(e.provider),this._authState.extraHeaders=e.extraHeaders,this._applyCredentialBaseURL(e.baseURL);break}case"profile":this._authState.resolution=this._resolveDefaultCredentials(c.value);break;case"defaultChain":this._shouldResolveDefaultCredentials()&&(this._authState.resolution=this._resolveDefaultCredentials());break;default:(0,ip.f)(c)}}_shouldResolveDefaultCredentials(){return!0}_applyCredentialBaseURL(e){if(!e)return;let t=e.replace(/\/+$/,"");this._authState.baseURL=t,this._baseURLIsExplicit||(this.baseURL=t)}_credentialResolverOptions(){return{baseURL:this.baseURL,fetch:this._credentialsFetch(),userAgent:this.getUserAgent(),onCacheWriteError:e=>{(0,rz.u)(this).debug("credential cache write failed (best-effort)",e)},onSafetyWarning:e=>{(0,rz.u)(this).warn(e)}}}_credentialsFetch(){return sU(this.fetch,this.middleware,void 0,this)}_makeTokenCache(e){return new si(e,e=>{(0,rz.u)(this).debug("advisory token refresh failed; serving cached token",e)})}withOptions(e){for(let t of(e={...e},ip.y))void 0===e[t]&&delete e[t];let t=ip.y.some(t=>t in e),i=ip.y.some(t=>null!=e[t]),r={...this._options,...this._baseURLIsExplicit?{baseURL:this.baseURL}:{},maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,middleware:this.middleware,apiKey:this.apiKey??(0,id.V)(this,ic,"f"),authToken:this.authToken,webhookKey:this.webhookKey,...i?Object.fromEntries(ip.y.map(e=>[e,null])):{},...e,openTelemetry:e.openTelemetry??(0,id.V)(this,iu,"f"),__auth:t?void 0:this._authState,__baseURLIsExplicit:"baseURL"in e||this._baseURLIsExplicit};return new this.constructor(r)}async _resolveDefaultCredentials(e){try{let t=await sC(this._credentialResolverOptions(),e);if(t)this._authState.provider=t.provider,this._authState.tokenCache=this._makeTokenCache(t.provider),this._authState.extraHeaders=t.extraHeaders,this._applyCredentialBaseURL(t.baseURL);else if(null!=e)throw new ry.v(`Profile "${e}" could not be resolved (no <config_dir>/configs/${e}.json found).`)}catch(e){this._authState.error=e}finally{this._authState.resolution=null}}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(e.get("x-api-key")||e.get("authorization"))){if(this._authState.error)throw this._authState.error;if(!(this._authState.tokenCache||this._authState.resolution||this.apiKey&&e.get("authorization")||t.has("authorization")||this.authToken&&e.get("authorization"))&&!t.has("authorization"))throw Error('Could not resolve authentication method. Expected one of apiKey, authToken, credentials, config, or profile to be set. Or for the "Authorization" header to be explicitly omitted')}}_authFlags(e){let t=this._requestAuthFlags.get(e);return t||(t={usedTokenCache:!1,didRefreshFor401:!1},this._requestAuthFlags.set(e,t)),t}async authHeaders(e){if(this._authState.resolution&&await this._authState.resolution,!this._authState.error){if((0,id.V)(this,ic,"f")&&null==this.apiKey){let e;try{e=await (0,id.V)(this,ic,"f").call(this)}catch(e){throw new ry.v(`The \`apiKey\` function failed: ${(0,ig.Y)(e).message}`,{cause:e})}if(!e)throw new ry.v(`The \`apiKey\` function must return a non-empty string. It returned ${JSON.stringify(e)}.`);return rR([{Authorization:`Bearer ${e}`}])}if(this._authState.tokenCache&&null==this.apiKey){let t=await this._authState.tokenCache.getToken();return this._authFlags(e).usedTokenCache=!0,rR([{Authorization:`Bearer ${t}`}])}return rR([await this.bearerAuth(e),await this.apiKeyAuth(e)])}}async apiKeyAuth(e){if(null!=this.apiKey)return rR([{Authorization:`Bearer ${this.apiKey}`}])}async bearerAuth(e){if(null!=this.authToken)return rR([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return function(e,t={}){let i,r=e,s=function(e=rY){let t;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw TypeError("Encoder has to be a function.");let i=e.charset||rY.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let r=rF;if(void 0!==e.format){if(!rK(rB,e.format))throw TypeError("Unknown format option provided.");r=e.format}let s=rB[r],n=rY.filter;if(("function"==typeof e.filter||(0,ip.o)(e.filter))&&(n=e.filter),t=e.arrayFormat&&e.arrayFormat in rX?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":rY.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw TypeError("`commaRoundTrip` must be a boolean, or absent");let a=void 0===e.allowDots?!0==!!e.encodeDotInKeys||rY.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:rY.addQueryPrefix,allowDots:a,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:rY.allowEmptyArrays,arrayFormat:t,charset:i,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:rY.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?rY.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:rY.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:rY.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:rY.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:rY.encodeValuesOnly,filter:n,format:r,formatter:s,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:rY.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:rY.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:rY.strictNullHandling}}(t);"function"==typeof s.filter?r=(0,s.filter)("",r):(0,ip.o)(s.filter)&&(i=s.filter);let n=[];if("object"!=typeof r||null===r)return"";let a=rX[s.arrayFormat],o="comma"===a&&s.commaRoundTrip;i||(i=Object.keys(r)),s.sort&&i.sort(s.sort);let l=new WeakMap;for(let e=0;e<i.length;++e){let t=i[e];s.skipNulls&&null===r[t]||rQ(n,function e(t,i,r,s,n,a,o,l,c,u,h,d,p,_,f,g,m,v){var b,y;let w,k=t,z=v,S=0,x=!1;for(;void 0!==(z=z.get(rZ))&&!x;){let e=z.get(t);if(S+=1,void 0!==e)if(e===S)throw RangeError("Cyclic object value");else x=!0;void 0===z.get(rZ)&&(S=0)}if("function"==typeof u?k=u(i,k):k instanceof Date?k=p?.(k):"comma"===r&&(0,ip.o)(k)&&(k=rG(k,function(e){return e instanceof Date?p?.(e):e})),null===k){if(a)return c&&!g?c(i,rY.encoder,m,"key",_):i;k=""}if("string"==typeof(b=k)||"number"==typeof b||"boolean"==typeof b||"symbol"==typeof b||"bigint"==typeof b||(y=k)&&"object"==typeof y&&y.constructor&&y.constructor.isBuffer&&y.constructor.isBuffer(y)){if(c){let e=g?i:c(i,rY.encoder,m,"key",_);return[f?.(e)+"="+f?.(c(k,rY.encoder,m,"value",_))]}return[f?.(i)+"="+f?.(String(k))]}let V=[];if(void 0===k)return V;if("comma"===r&&(0,ip.o)(k))g&&c&&(k=rG(k,c)),w=[{value:k.length>0?k.join(",")||null:void 0}];else if((0,ip.o)(u))w=u;else{let e=Object.keys(k);w=h?e.sort(h):e}let A=l?String(i).replace(/\./g,"%2E"):String(i),I=s&&(0,ip.o)(k)&&1===k.length?A+"[]":A;if(n&&(0,ip.o)(k)&&0===k.length)return I+"[]";for(let i=0;i<w.length;++i){let b=w[i],y="object"==typeof b&&void 0!==b.value?b.value:k[b];if(o&&null===y)continue;let z=d&&l?b.replace(/\./g,"%2E"):b,x=(0,ip.o)(k)?"function"==typeof r?r(I,z):I:I+(d?"."+z:"["+z+"]");v.set(t,S);let A=new WeakMap;A.set(rZ,v),rQ(V,e(y,x,r,s,n,a,o,l,"comma"===r&&g&&(0,ip.o)(k)?null:c,u,h,d,p,_,f,g,m,A))}return V}(r[t],t,a,o,s.allowEmptyArrays,s.strictNullHandling,s.skipNulls,s.encodeDotInKeys,s.encode?s.encoder:null,s.filter,s.sort,s.allowDots,s.serializeDate,s.format,s.formatter,s.encodeValuesOnly,s.charset,l))}let c=n.join(s.delimiter),u=!0===s.addQueryPrefix?"?":"";return s.charsetSentinel&&("iso-8859-1"===s.charset?u+="utf8=%26%2310003%3B&":u+="utf8=%E2%9C%93&"),c.length>0?u+c:""}(e,{arrayFormat:"brackets"})}getUserAgent(){return`Anthropic/JS ${im}`}makeStatusError(e,t,i,r){return ry.E.generate(e,t,i,r)}buildURL(e,t,i){let r=!(0,id.V)(this,ia,"m",ih).call(this)&&i||this.baseURL,s=new URL((0,ip.X)(e)?e:r+(r.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),n=this.defaultQuery(),a=Object.fromEntries(s.searchParams);return(0,ip.O)(n)&&(0,ip.O)(a)||(t={...a,...n,...t}),"object"==typeof t&&t&&!Array.isArray(t)&&(s.search=this.stringifyQuery(t)),s.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new ry.v("Streaming is required for operations that may take longer than 10 minutes. See https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/typescript#streaming-responses for more details");return 6e5}async prepareOptions(e){}async prepareRequest(e,{url:t,options:i}){if(this._authState.tokenCache&&null==this.apiKey){let t=e.headers instanceof Headers?e.headers:new Headers(e.headers);for(let[e,i]of Object.entries(this._authState.extraHeaders))t.has(e)||t.set(e,i);let i=t.get("anthropic-beta")?.split(",").map(e=>e.trim());i?.includes(r2)||t.set("anthropic-beta",[...i??[],r2].join(",")),e.headers=t}}backendMiddleware(){return[]}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,i){return this.request(Promise.resolve(i).then(i=>({method:e,path:t,...i})))}request(e,t=null){return this._tracer?new s0(this,this.makeTracedRequest(e,t)):new s0(this,this.makeRequest(e,t,void 0))}async makeTracedRequest(e,t){let i=await e,r=i.__span?.span;if(!r)return this.makeRequest(i,t,void 0);try{return await iJ.with(rm.setSpan(iJ.active(),r),()=>this.makeRequest(i,t,void 0,r))}catch(t){let e={status:"error",options:i,error:t};throw sk(this,r,e),rL(this,()=>rj(r,e)),t}}async makeRequest(e,t,i,r){var s;let n=await e,a=(0,ip.H)("maxRetries",n.maxRetries??this.maxRetries);this.isStreamBody(n.body)&&(a=0),null==t&&(t=a,this._requestAuthFlags.delete(n)),await this.prepareOptions(n);let{req:o,url:l,timeout:c}=await this.buildRequest(n,{retryCount:a-t}),u="log_"+(0x1000000*Math.random()|0).toString(16).padStart(6,"0"),h=void 0===i?"":`, retryOf: ${i}`;r&&this.openTelemetry.propagation&&(o.headers=rL(this,()=>(function(e,t){let i=rR([t]).values;for(let[t,r]of Object.entries(rU(e)))i.set(t,r);return i})(r,o.headers))??o.headers);let d=Date.now();if(n.signal?.aborted)throw new ry.F;let p=new AbortController,_=await this.fetchWithTimeout(l,o,c,p,n,{requestLogID:u,retryOfRequestLogID:i}).catch(ig.Y),f=Date.now();if(_ instanceof globalThis.Error){iz(p);let e=`retrying, ${t} attempts remaining`;if(n.signal?.aborted)throw new ry.F;let s=(0,ig.c)(_)||/timed? ?out/i.test(String(_)+("cause"in _?String(_.cause):"")),a=this.middleware.length>0||!!n.middleware?.length||this.backendMiddleware().length>0;if(a&&!s&&!function(e){let t=new Set;for(;"object"==typeof e&&null!==e&&!t.has(e);){if(t.add(e),sW(e)||(0,ig.c)(e)||e instanceof ry.I||e instanceof ry.O)return!0;e=e.cause}return!1}(_))throw(0,rz.u)(this).info(`[${u}] middleware error (not retryable)`),(0,rz.M)((0,rz.u)(this),`[${u}] middleware error (not retryable)`,{retryOfRequestLogID:i,url:l,durationMs:f-d,message:_.message}),_;if(t)return(0,rz.u)(this).info(`[${u}] connection ${s?"timed out":"failed"} - ${e}`),(0,rz.M)((0,rz.u)(this),`[${u}] connection ${s?"timed out":"failed"} (${e})`,{retryOfRequestLogID:i,url:l,durationMs:f-d,message:_.message}),this.retryRequest(n,t,i??u,r);if((0,rz.u)(this).info(`[${u}] connection ${s?"timed out":"failed"} - error; no more retries left`),(0,rz.M)((0,rz.u)(this),`[${u}] connection ${s?"timed out":"failed"} (error; no more retries left)`,{retryOfRequestLogID:i,url:l,durationMs:f-d,message:_.message}),s)throw new ry.R;if(a&&!sW(_))throw _;throw new ry.I({cause:_})}let g=[..._.headers.entries()].filter(([e])=>"request-id"===e||"anthropic-workspace-id"===e).map(([e,t])=>", "+e+": "+JSON.stringify(t)).join(""),m=`[${u}${h}${g}] ${o.method} ${l} ${_.ok?"succeeded":"failed"} with status ${_.status} in ${f-d}ms`;if(!_.ok){let e=await this.shouldRetry(_,n);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await iI(_.body),iz(p),(0,rz.u)(this).info(`${m} - ${e}`),(0,rz.M)((0,rz.u)(this),`[${u}] response error (${e})`,{retryOfRequestLogID:i,url:_.url,status:_.status,headers:_.headers,durationMs:f-d}),this.retryRequest(n,t,i??u,r,_.headers)}let s=e?"error; no more retries left":"error; not retryable";(0,rz.u)(this).info(`${m} - ${s}`);let a=await _.text().catch(e=>(0,ig.Y)(e).message),o=(0,ip.k)(a),l=o?void 0:a;throw(0,rz.M)((0,rz.u)(this),`[${u}] response error (${s})`,{retryOfRequestLogID:i,url:_.url,status:_.status,headers:_.headers,message:l,durationMs:Date.now()-d}),iz(p),this.makeStatusError(_.status,o,l,_.headers)}return(0,rz.u)(this).info(m),(0,rz.M)((0,rz.u)(this),`[${u}] response start`,{retryOfRequestLogID:i,url:_.url,status:_.status,headers:_.headers,durationMs:f-d}),s=_.body??_,iw.has(p)&&ik?.register(s,p,p),{response:_,options:n,controller:p,requestLogID:u,retryOfRequestLogID:i,startTime:d}}getAPIList(e,t,i){return this.requestAPIList(t,i&&"then"in i?i.then(t=>({method:"get",path:e,...t})):{method:"get",path:e,...i})}requestAPIList(e,t){return this._tracer?new s2(this,this.makeTracedRequest(t,null),e):new s2(this,this.makeRequest(t,null,void 0),e)}async fetchWithTimeout(e,t,i,r,s,n){let{signal:a,method:o,...l}=t||{},c=this._makeAbort(r);a&&(a.addEventListener("abort",c,{once:!0}),iw.set(r,()=>a.removeEventListener("abort",c)));let u=globalThis.ReadableStream&&l.body instanceof globalThis.ReadableStream||"object"==typeof l.body&&null!==l.body&&Symbol.asyncIterator in l.body,h={signal:r.signal,...u?{duplex:"half"}:{},method:"GET",...l};o&&(h.method=o.toUpperCase());let d=this.fetch,p=async(e,t)=>{let r=setTimeout(c,i);try{return await d.call(void 0,e,t)}finally{clearTimeout(r)}},_=void 0===s?p:async(e,t={})=>{let i="string"==typeof e?e:e instanceof URL?e.href:e.url;t.headers=t.headers instanceof Headers?t.headers:new Headers(t.headers);let r=[];s.__span&&(t.headers=new Headers(t.headers),r=sA(t.headers)),await this.prepareRequest(t,{url:i,options:s}),r.length&&(t.headers=rR([t.headers,r]).values);let a=s.__span;return a&&rL(this,()=>(function(e,t,i,r=!1){if(e.attempts=(e.attempts??0)+1,e.attempts>1)return void e.span.setAttribute("http.request.resend_count",e.attempts-1);e.span.setAttribute("http.request.method",t);try{let{protocol:t,host:s,pathname:n,search:a}=new URL(i),o=function(e,t,i){if(!e||!t?.length)return;let r=!1,s=e.split("&").filter(e=>{try{let s=decodeURIComponent(e.split("=",1)[0]),n=t.includes(s)||!s.endsWith("[]")?s:s.slice(0,-2);if(!t.includes(n))return!1;return r||(r=rN.includes(n)||!!i?.includes(n)),!0}catch{return!1}});return s.length?{value:s.join("&"),content:r}:void 0}(a.slice(1),e.queryParams,e.contentQueryParams);if(e.span.setAttributes({"url.scheme":t.slice(0,-1),"url.path":n}),o?.content&&!r)return;e.span.setAttributes({...void 0!==o?{"url.query":o.value}:void 0,"url.full":`${t}//${s}${n}${void 0!==o?`?${o.value}`:""}`})}catch{}})(a,t.method??"GET",i,"content"===this.openTelemetry.traces.contentMode)),n&&(0,rz.M)((0,rz.u)(this),`[${n.requestLogID}] sending request`,{retryOfRequestLogID:n.retryOfRequestLogID,method:t.method,url:i,options:s,headers:t.headers}),p(e,t)},f=s?.middleware,g=s?.__span?this.backendMiddleware().map(sI):this.backendMiddleware(),m=f?.length||g.length?[...this.middleware,...f??[],...g]:this.middleware;return await sU(_,m,s,this)(e,h)}async shouldRetry(e,t){let i=this._authFlags(t);if(401===e.status&&this._authState.tokenCache&&i.usedTokenCache&&!i.didRefreshFor401)return i.didRefreshFor401=!0,this._authState.tokenCache.invalidate(),!0;let r=e.headers.get("x-should-retry");return"true"===r||"false"!==r&&(408===e.status||409===e.status||429===e.status||!!(e.status>=500))}async retryRequest(e,t,i,r,s){let n,a=s?.get("retry-after-ms");if(a){let e=parseFloat(a);Number.isNaN(e)||(n=e)}let o=s?.get("retry-after");if(o&&!n){let e=parseFloat(o);n=Number.isNaN(e)?Date.parse(o)-Date.now():1e3*e}if(void 0===n||!(n>0&&n<=0x7fffffff)){let i=e.maxRetries??this.maxRetries;n=this.calculateDefaultRetryTimeoutMillis(t,i)}return await i_(n,e.signal??void 0),this.makeRequest(e,t-1,i,r)}calculateDefaultRetryTimeoutMillis(e,t){return Math.min(.5*Math.pow(2,t-e),8)*(1-.25*Math.random())*1e3}calculateNonstreamingTimeout(e,t){if(36e5*e/128e3>6e5||null!=t&&e>t)throw new ry.v("Streaming is required for operations that may take longer than 10 minutes. See https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/typescript#long-requests for more details");return 6e5}async buildRequest(e,{retryCount:t=0}={}){let i={...e},{method:r,path:s,query:n,defaultBaseURL:a}=i;this._authState.resolution&&await this._authState.resolution,!this._baseURLIsExplicit&&this._authState.baseURL&&this.baseURL!==this._authState.baseURL&&(this.baseURL=this._authState.baseURL);let o=this.buildURL(s,n,a);"timeout"in i&&(0,ip.H)("timeout",i.timeout),i.timeout=i.timeout??this.timeout;let{bodyHeaders:l,body:c}=this.buildBody({options:i}),u=await this.buildHeaders({options:e,method:r,bodyHeaders:l,retryCount:t,timeout:i.timeout});return{req:{method:r,headers:u,...i.signal&&{signal:i.signal},...globalThis.ReadableStream&&c instanceof globalThis.ReadableStream&&{duplex:"half"},...c&&{body:c},...this.fetchOptions??{},...i.fetchOptions??{}},url:o,timeout:i.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:i,retryCount:r,timeout:s}){let n=rR([{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r),"X-Stainless-Timeout":String(Math.trunc(s/1e3)),...iy(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2026-10-21"},await this.authHeaders(e),this._options.defaultHeaders,i,e.headers]);return this.validateHeaders(n),n.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let i=rR([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||"string"==typeof e&&i.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:this.isStreamBody(e)?{bodyHeaders:void 0,body:ix(e)}:"object"==typeof e&&"application/x-www-form-urlencoded"===i.values.get("content-type")?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:(0,id.V)(this,il,"f").call(this,{body:e,headers:i})}isStreamBody(e){return!!globalThis.ReadableStream&&e instanceof globalThis.ReadableStream||"object"==typeof e&&null!==e&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&"function"==typeof e.next)}}return io=e,il=new WeakMap,ic=new WeakMap,iu=new WeakMap,ia=new WeakSet,ih=function(){return"https://api.anthropic.com"!==this.baseURL},e.Anthropic=io,e.DEFAULT_TIMEOUT=6e5,e.AnthropicError=ry.v,e.APIError=ry.E,e.APIConnectionError=ry.I,e.APIConnectionTimeoutError=ry.R,e.APIUserAbortError=ry.F,e.NotFoundError=ry.i,e.ConflictError=ry.y,e.RateLimitError=ry.t,e.BadRequestError=ry.B,e.AuthenticationError=ry.P,e.InternalServerError=ry.j,e.PermissionDeniedError=ry.N,e.UnprocessableEntityError=ry.o,e.toFile=s9,e})(),lV=(()=>{class e extends lx{constructor(){super(...arguments),this._supportsMessageThreads=!0,this.messages=new nk(this),this.models=new nx(this),this.files=new nV(this),this.skills=new nI(this),this.userProfiles=new n$(this),this.organization=new nK(this),this.beta=new lz(this)}}return e.Messages=nk,e.Models=nx,e.Files=nV,e.Skills=nI,e.UserProfiles=n$,e.Organization=nK,e.Beta=lz,e})(),lA=e.i(687604),lI=e.i(261829),lq=e.i(983598),l$=e.i(798003),lR=e.i(999617),lP=e.i(459398),lT=e.i(50377),lE=e.i(481183),lO=e.i(93716),lM=e.i(630166),lL=e.i(215267),lC=e.i(115851),lN=e.i(907240);let lj=(0,lT.f)("ai:anthropic"),lD="https://api.anthropic.com",lW="claude-sonnet-5-5";function lU(e,t){let i,r=e.match(/^data:([^;]+);base64,([\s\S]*)$/);return{type:"image",source:{type:"base64",media_type:"image/png"===(i=((r?r[1]:t)||"").toLowerCase())||"image/gif"===i||"image/webp"===i?i:"image/jpeg",data:r?r[2]:e}}}function lF(e,t){let i=(0,lR.Q)(e),r=`<${t}>`,s=`</${t}>`,n=i.indexOf(r);if(-1===n)return null;let a=n+r.length,o=i.lastIndexOf(s);return -1===o&&"analysis"===t?(lj.warn({tagName:t},"Tag was verified unclosed, treating as truncated and reading to end"),i.substring(a).trim()):-1===o||a>=o?null:i.substring(a,o).trim()}function lH(e){return(e||"").split(/[,,\n]/).map(e=>e.trim()).filter(e=>e.length>0)}function lB(e){let t=lF(e,"question_text"),i=lF(e,"answer_text"),r=lF(e,"analysis");if(!t||!i||!r)throw lj.error({rawTextSample:e.substring(0,500)},"Missing critical XML tags"),Error("Invalid AI response: Missing critical XML tags (<question_text>, <answer_text>, or <analysis>)");let s=lF(e,"wrong_answer_text")||"",n={questionText:t,answerText:i,analysis:r,wrongAnswerText:s,mistakeAnalysis:lF(e,"mistake_analysis")||"",mistakeStatus:(0,lM.f)(lF(e,"mistake_status"),s),subject:(0,lR.G)(lF(e,"subject"))||"其他",knowledgePoints:lH(lF(e,"knowledge_points")),requiresImage:lF(e,"requires_image")?.toLowerCase().trim()==="true",gradeSemester:(0,lL.X)(lF(e,"grade_semester")),difficultyStars:(0,lR.B)(lF(e,"difficulty_stars")),...(0,lR.t)(lF(e,"has_figure"),lF(e,"figure_svg"))},a=(0,lR.u)(n);return a.success?a.data:(lj.warn({validationError:a.error.format()},"Schema validation warning"),n)}e.s(["R",0,class{client;model;baseURL;constructor(e){let t=e?.apiKey,i=e?.authToken;if(!t&&!i)throw Error("AI_AUTH_ERROR: ANTHROPIC_API_KEY is required for Anthropic provider");this.baseURL=(0,lE.z)(e?.baseUrl||lD).replace(/\/v1$/,""),this.model=e?.model||lW,this.client=function(e,t,i){let r={baseURL:e,timeout:6e5};if(function(e){try{return new URL(e).hostname===new URL(lD).hostname}catch{return!1}}(e))return new lV(t?{...r,apiKey:t,authToken:null}:{...r,apiKey:null,authToken:i});let s={"anthropic-version":"2023-06-01"};return t?(s["x-api-key"]=t,new lV({...r,apiKey:null,authToken:null,defaultHeaders:s})):new lV({...r,apiKey:null,authToken:i,defaultHeaders:s})}(this.baseURL,t,i),lj.info({provider:"Anthropic",model:this.model,baseURL:this.baseURL,apiKeyPrefix:t?t.substring(0,8)+"...":"bearer"},"AI Provider initialized")}async complete(e,t,i){let r=await (0,lO.V)(async i=>{let r=await this.client.messages.create({model:this.model,max_tokens:i,system:e,messages:[{role:"user",content:t}]}),s=r.content.filter(e=>"text"===e.type).map(e=>e.text).join("");return lj.debug({stopReason:r.stop_reason,usage:r.usage},"Anthropic response received"),{text:s,choices:[{finish_reason:"max_tokens"===r.stop_reason?"length":r.stop_reason,message:{content:s}}]}},i,()=>lj.warn("Output truncated by reasoning, retrying with larger max_tokens"),this.model);if(!r.text)throw Error("Empty response from AI");return r.text}async analyzeImage(e,t="image/jpeg",i="zh",r,s,n,a){let o=(0,l$.b)(),l=a?{candidateTags:a}:await (0,lP.i)(s,r),c=(0,lA.generateAnalyzeRequest)(i,r,s,{customTemplate:o.prompts?.analyze,...l},n);lj.box("🔍 AI Image Analysis Request",{provider:"Anthropic",endpoint:`${this.baseURL}/v1/messages`,imageSize:`${e.length} bytes`,mimeType:t,model:this.model,language:i,grade:r||"all"}),lj.box("📝 Full System Prompt",c.system);try{let i=await this.complete(c.system,[lU(e,t),{type:"text",text:c.user}],8192);lj.box("🤖 AI Raw Response",i);let r=(0,lN.f)(lB(i),l);return lj.box("✅ Parsed & Validated Result",JSON.stringify(r,null,2)),r}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during AI analysis"),this.handleError(e),e}}async generateSimilarQuestion(e,t,i="zh",r="medium",s,n){let a=(0,l$.b)(),o=(0,lA.generateSimilarQuestionRequest)(i,e,t,r,{customTemplate:a.prompts?.similar,originalFigureSvg:n},s),l=o.user;lj.info({provider:"Anthropic",model:this.model,difficulty:r,language:i},"Generate Similar Question Request");try{let e=await this.complete(o.system,l,8192);return lj.box("🤖 AI Raw Response",e),(0,lC.f)(lB(e))}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during question generation"),this.handleError(e),e}}async reanswerQuestion(e,t="zh",i,r,s,n){let a=(0,lA.generateReanswerRequest)(t,e,i,{candidateTags:n},s);lj.info({provider:"Anthropic",model:this.model,questionLength:e.length,subject:i||"auto",hasImage:!!r},"Reanswer Question Request");try{let e=r?[lU(r),{type:"text",text:a.user}]:a.user,t=await this.complete(a.system,e,8192);lj.debug({rawResponse:t},"AI raw response");let i=lF(t,"wrong_answer_text")||"";return(0,lN.f)({answerText:lF(t,"answer_text")||"",analysis:lF(t,"analysis")||"",knowledgePoints:lH(lF(t,"knowledge_points")),wrongAnswerText:i,mistakeAnalysis:lF(t,"mistake_analysis")||"",mistakeStatus:(0,lM.f)(lF(t,"mistake_status"),i),subject:(0,lR.G)(lF(t,"subject")),gradeSemester:(0,lL.X)(lF(t,"grade_semester")),difficultyStars:(0,lR.B)(lF(t,"difficulty_stars"))},{candidateTags:n})}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during reanswer"),this.handleError(e),e}}async analyzeForGeogebra(e,t,i,r){let s=(0,lA.generateGeogebraRequest)(e,t,i,r);lj.info({provider:"Anthropic",model:this.model,questionLength:e.length},"GeoGebra Analysis Request");try{let e=await this.complete(s.system,s.user,4096);lj.debug({rawResponse:e},"GeoGebra AI raw response");let t=(0,lR.F)(e);return{suitable:!!t.suitable,commands:Array.isArray(t.commands)?t.commands:[],description:"string"==typeof t.description?t.description:""}}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during GeoGebra analysis"),this.handleError(e),e}}async evaluateMastery(e){let t=(0,lA.generateMasteryRequest)(e);lj.info({provider:"Anthropic",historyCount:e.history.length},"Mastery Evaluation Request");try{let e=await this.complete(t.system,t.user,4096);return lj.debug({rawResponse:e},"Mastery AI raw response"),(0,lR.r)(e)}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during mastery evaluation"),this.handleError(e),e}}async recognizeGrade(e){let t=(0,lA.generateGradeRecognitionRequest)(e);try{return(0,lR.b)(await this.complete(t.system,t.user,1024))}catch(e){throw lj.error({error:e},"识别题目年级失败"),this.handleError(e),e}}async gradeAnswer(e){let t=(0,lA.generateGradingRequest)(e);lj.info({provider:"Anthropic"},"Answer Grading Request");try{let e=await this.complete(t.system,t.user,4096);return lj.debug({rawResponse:e},"Grading AI raw response"),(0,lR.o)(e)}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during answer grading"),this.handleError(e),e}}async suggestKnowledgeTags(e){let t=(0,lA.generateTagSuggestRequest)(e);lj.info({provider:"Anthropic",subject:e.subject,allowedTagCount:e.allowedTags.length},"Tag Suggestion Request");try{let i=await this.complete(t.system,t.user,4096);return lj.debug({rawResponse:i},"Tag suggestion AI raw response"),(0,lR.K)(i,e.allowedTags)}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during tag suggestion"),this.handleError(e),e}}async generateFigureSvg(e,t,i){let r=(0,lA.generateFigureRequest)(i);lj.info({provider:"Anthropic",model:this.model,imageSize:e.length},"Figure SVG Request");try{let i=await this.complete(r.system,[lU(e,t),{type:"text",text:r.user},{type:"text",text:"请重新绘制图中题目的配图。"}],8192);return lj.debug({rawResponse:i},"Figure SVG AI raw response"),(0,lR.t)(lF(i,"has_figure"),lF(i,"figure_svg"))}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during figure SVG generation"),this.handleError(e),e}}async fixLatex(e){let t=(0,lA.generateLatexFixRequest)(e);lj.info({provider:"Anthropic",model:this.model,fields:Object.keys(e)},"LaTeX Fix Request");try{let i=await this.complete(t.system,t.user,8192);return lj.debug({rawResponse:i},"LaTeX fix AI raw response"),(0,lq.f)(i,e)}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during LaTeX fix"),this.handleError(e),e}}async generateSvgAnimation(e,t,i,r,s="zh"){let n=(0,lA.generateSvgAnimationRequest)(e,t,i,r,s);lj.info({provider:"Anthropic",model:this.model,questionLength:e.length},"SVG Animation Request");try{let e=await this.complete(n.system,n.user,16384);return lj.debug({rawResponse:e},"SVG animation AI raw response"),(0,lI.J)(lF(e,"svg_animation")||e)}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during SVG animation generation"),this.handleError(e),e}}async generateSvgNarration(e,t,i,r,s="zh"){let n=(0,lA.generateSvgNarrationRequest)(e,t,i,r,s);lj.info({provider:"Anthropic",model:this.model,svgLength:r.length},"SVG Narration Request");try{let e=await this.complete(n.system,n.user,4096);return lj.debug({rawResponse:e},"SVG narration AI raw response"),(0,lI.a)(lF(e,"narration")||e)}catch(e){throw lj.error({error:e,stack:e instanceof Error?e.stack:void 0},"Error during SVG narration generation"),this.handleError(e),e}}handleError(e){if(lj.error({error:e},"Anthropic error"),e instanceof Error&&(e.message===lO.z||e.message.startsWith("AI_RESPONSE_ERROR:")))throw e;if(e instanceof lV.APIConnectionTimeoutError)throw Error("AI_TIMEOUT_ERROR",{cause:e});if(e instanceof lV.APIConnectionError)throw Error("AI_CONNECTION_FAILED",{cause:e});if(e instanceof lV.APIError&&e.status){let t=e.status;if(401===t)throw Error("AI_AUTH_ERROR",{cause:e});if(403===t)throw Error("AI_PERMISSION_DENIED",{cause:e});if(404===t)throw Error("AI_NOT_FOUND",{cause:e});if(408===t)throw Error("AI_TIMEOUT_ERROR",{cause:e});if(429===t)throw Error("AI_QUOTA_EXCEEDED",{cause:e});if(t>=500)throw Error("AI_SERVICE_UNAVAILABLE",{cause:e})}if(e instanceof Error){let t=e.message.toLowerCase();if(t.includes("fetch failed")||t.includes("network")||t.includes("connect"))throw Error("AI_CONNECTION_FAILED",{cause:e});if(t.includes("timeout")||t.includes("timed out")||t.includes("aborted"))throw Error("AI_TIMEOUT_ERROR",{cause:e});if(t.includes("invalid json")||t.includes("parse")||t.includes("json")||t.includes("missing critical xml"))throw Error("AI_RESPONSE_ERROR",{cause:e})}throw Error("AI_UNKNOWN_ERROR",{cause:e})}},"l",0,lD,"A",0,lW],690604)},983598,93716,115851,907240,e=>{var t=e.i(405898);e.s(["f",0,function(e,i){let r={};for(let s of Object.keys(i)){let i=t.t[s],n=e.indexOf(`<${i}>`);if(-1===n)continue;let a=n+i.length+2,o=e.indexOf(`</${i}>`,a);if(-1===o)continue;let l=e.slice(a,o).trim();l&&(r[s]=l)}return r}],983598);var i=e.i(629833),r=e.i(50377);let s=[{pattern:/claude-(opus|sonnet|haiku|fable|mythos)-([5-9]|4[-.][6-9])/,maxOutputTokens:128e3},{pattern:/claude-(opus|sonnet|haiku)-4[-.]5/,maxOutputTokens:64e3},{pattern:/claude-sonnet-4/,maxOutputTokens:64e3},{pattern:/claude-opus-4/,maxOutputTokens:32e3},{pattern:/claude-3[-.]7-sonnet/,maxOutputTokens:64e3},{pattern:/claude-3[-.]5-/,maxOutputTokens:8192},{pattern:/claude-3-/,maxOutputTokens:4096},{pattern:/(^|[/-])gpt-[5-9]/,maxOutputTokens:128e3},{pattern:/(^|[/-])o1-mini/,maxOutputTokens:65536},{pattern:/(^|[/-])o1-preview/,maxOutputTokens:32768},{pattern:/(^|[/-])o[134](-|$)/,maxOutputTokens:1e5},{pattern:/(^|[/-])gpt-4\.1/,maxOutputTokens:32768},{pattern:/(^|[/-])gpt-4o/,maxOutputTokens:16384},{pattern:/(^|[/-])gpt-4-(turbo|vision|1106|0125)/,maxOutputTokens:4096},{pattern:/(^|[/-])gpt-4(-|$)/,maxOutputTokens:8192},{pattern:/(^|[/-])gpt-3\.5/,maxOutputTokens:4096},{pattern:/gemini-(2\.5|[3-9])/,maxOutputTokens:65536},{pattern:/gemini-(1\.5|2\.0)/,maxOutputTokens:8192},{pattern:/^deepseek-(flash|v4)/,maxOutputTokens:384e3},{pattern:/^glm-4\.6v/,maxOutputTokens:32e3},{pattern:/^glm-(5|4\.7|4\.6)/,maxOutputTokens:128e3},{pattern:/^glm-4\.5/,maxOutputTokens:96e3},{pattern:/^glm-4\.1v/,maxOutputTokens:16e3},{pattern:/^glm-4-long/,maxOutputTokens:4e3},{pattern:/^glm-4v-flash/,maxOutputTokens:1e3},{pattern:/^glm-4-flash/,maxOutputTokens:16e3},{pattern:/^doubao-seed-character/,maxOutputTokens:32e3},{pattern:/^doubao-seed-(evolving|2-1)/,maxOutputTokens:256e3},{pattern:/^doubao-seed-2-0/,maxOutputTokens:128e3},{pattern:/^minimax-m3/,maxOutputTokens:128e3},{pattern:/^kimi-k3/,maxOutputTokens:131072},{pattern:/^qwen3\.8-max/,maxOutputTokens:128e3}],n=(0,r.f)("ai:truncation"),a="AI_OUTPUT_TRUNCATED",o=new Map;function l(e){let t=e?.trim().toLowerCase();return(t?o.get(t):void 0)??function(e){let t=(e||"").trim().toLowerCase();if(t)return s.find(e=>e.pattern.test(t))?.maxOutputTokens}(t)}function c(e){let t=e?.choices?.[0];return!!t&&"length"===t.finish_reason&&!(t.message?.content||"").trim()}async function u(e,t,r){try{return{response:await e(t),limit:t}}catch(u){let s=(0,i.Z)(u),a=function(e,t){if(!/max[_ ]?(completion[_ ]?|output[_ ]?)?tokens|output tokens|completion tokens/i.test(e))return;let i=(e.match(/\d+/g)||[]).map(Number).filter(e=>Number.isSafeInteger(e)&&e>=1024&&e<t);return i.length>0?Math.max(...i):void 0}(s,t),l=a??(/max[_ ]?(completion[_ ]?|output[_ ]?)?tokens/i.test(s)&&t>32768?32768:void 0);if(!l)throw u;let c=r?.trim().toLowerCase();return c&&a&&o.set(c,a),n.warn({model:r,requested:t,adjusted:l},"max_tokens exceeds model limit, retrying with model limit"),{response:await e(l),limit:l}}}async function h(e,t,i,r){var s;let n=l(r),o=await u(e,n?Math.min(t,n):t,r);if(s=o.response,s?.choices?.[0]?.finish_reason!=="length")return o.response;let h=l(r)??65536;if(o.limit>=h){if(c(o.response))throw Error(a);return o.response}i?.();let d=await u(e,h,r);if(c(d.response))throw Error(a);return d.response}e.s(["z",0,a,"V",0,h],93716),e.s(["f",0,function(e){let t=e.questionText.replace(/[((【\[]\s*(?:(?:本题|共|满分)\s*)?\d+(?:\.\d+)?\s*(?:分|points?|marks?|pts?\.?)\s*[))】\]]/giu,"").replace(/^\s*(?:#{1,6}\s*)?(?:第\s*\d+\s*题\s*[::.、]?|(?:Question|Problem)\s*\d+\s*[::.、]?|\d+\s*(?:[、.]|\.(?!\d)))\s*/iu,"").trim(),i=/^\s*(?:[-*]\s*)?(?:[A-DA-D][..、::))]|[((][A-DA-D][))])\s*\S/imu.test(t),r=t.match(/(?:^|\s)(?:[A-DA-D][..、::))]|[((][A-DA-D][))])/giu)||[],s=/(?:下列|以下|选择|答案|哪项|哪一|正确的是|正确的是)/u.test(t),n=t.match(/[①②③④⑤⑥⑦⑧⑨⑩][^①②③④⑤⑥⑦⑧⑨⑩]*/gu)||[],a=!(n.length<2)&&(!!s||!!(n.length>=4));if(!t||i||r.length>=2||a)throw Error("AI_RESPONSE_ERROR: 生成题目必须为不含选项的填空题或解答题");return{...e,questionText:t}}],115851);var d=e.i(999617);let p={数学:"prefetchedMathTags",物理:"prefetchedPhysicsTags",化学:"prefetchedChemistryTags",生物:"prefetchedBiologyTags",英语:"prefetchedEnglishTags"};e.s(["f",0,function(e,t){let i=t.candidateTags?.tags;if(!t.candidateTags){let r=p[e.subject];if(r)i=t[r];else{let e=Object.values(p).flatMap(e=>t[e]?[t[e]]:[]);i=e.length?e.flat():void 0}}let r=i?new Set(i):null,s=[...new Set(e.knowledgePoints.map(e=>e.trim()).filter(e=>e&&(!r||r.has(e))))].slice(0,d.e);return{...e,knowledgePoints:s}}],907240)},999617,e=>{var t=e.i(971724),i=e.i(105954),r=e.i(604147),s=e.i(455744),n=e.i(180473),a=e.i(206033),o=e.i(562810),o=o,l=e.i(140561),c=o,u=e.i(819428),h=e.i(215267);let d=t.z.object({questionText:i.z.string().min(1,"题目文本不能为空"),answerText:i.z.string().min(1,"答案不能为空"),analysis:i.z.string().min(1,"解析不能为空"),wrongAnswerText:i.z.string().optional().default(""),mistakeAnalysis:i.z.string().optional().default(""),mistakeStatus:r.z.enum(["not_attempted","wrong_attempt","unknown"]).optional().default("unknown"),subject:r.z.enum(["数学","物理","化学","生物","英语","语文","历史","地理","政治","其他"]),knowledgePoints:s.z.array(i.z.string()).max(5,"知识点最多 5 个"),requiresImage:n.z.boolean().optional().default(!1),difficultyStars:a.z.number().int().min(1).max(5).nullable().optional(),gradeSemester:i.z.string().max(100).nullable().optional(),hasFigure:n.z.boolean().optional(),figureSvg:i.z.string().nullable().optional()}),p=t.z.object({probability:o.coerce.number().min(0).max(100),reason:i.z.string().trim().min(1).max(500)});function _(e){return e.replace(/<(think|thinking)\b[^>]*>[\s\S]*?<\/\1>/gi,"").trim()}function f(e){let t=_(e),i=t.match(/```(?:json)?\s*([\s\S]*?)```/);i&&(t=i[1].trim());let r=t.indexOf("{"),s=t.lastIndexOf("}");return -1!==r&&s>r&&(t=t.substring(r,s+1)),JSON.parse(t)}let g=t.z.object({correct:l.z.union([n.z.boolean(),r.z.enum(["true","false"]).transform(e=>"true"===e)]),reason:i.z.string().trim().min(1).max(500)});function m(e){let t;if("number"==typeof e)t=e;else{if("string"!=typeof e)return null;let i=e.trim(),r=(i.match(/[★⭐]/gu)||[]).length,s=i.match(/\d+(\.\d+)?/);t=r>0&&!s?r:s?Number(s[0]):0/0}if(!Number.isFinite(t))return null;let i=Math.round(t);return i>=1&&i<=5?i:null}e.s(["e",0,5,"F",0,f,"G",0,function(e){let t=d.shape.subject.safeParse(e?.trim());return t.success?t.data:void 0},"o",0,function(e){return g.parse(f(e))},"B",0,m,"t",0,function(e,t){let i=(0,u.W)(t);return{hasFigure:e?.trim().toLowerCase()==="true"||null!==i,figureSvg:i}},"b",0,function(e){let r=t.z.object({gradeSemester:i.z.string().nullable()}).parse(f(e));return(0,h.X)(r.gradeSemester)},"r",0,function(e){let t=p.parse(f(e));return{probability:Math.round(t.probability)/100,reason:t.reason}},"K",0,function(e,r){let n=t.z.object({tags:s.z.array(i.z.string()),difficultyStars:c.unknown().optional()}).parse(f(e)),a=new Set(r),o=[];for(let e of n.tags.map(e=>e.trim()))a.has(e)&&!o.includes(e)&&o.push(e);return{tags:o.slice(0,5),difficultyStars:m(n.difficultyStars)}},"u",0,function(e){return d.safeParse(e)},"Q",0,_],999617)},459398,e=>{var t=e.i(698043),i=e.i(50377),r=e.i(668426);let s=(0,i.f)("ai:tag-service");async function n(e,i="default"){let r={1:["一年级"],2:["二年级"],3:["三年级"],4:["四年级"],5:["五年级"],6:["六年级"],7:["七年级上","七年级下"],8:["八年级上","八年级下"],9:["九年级上","九年级下"],10:["高一上","高一下"],11:["高二上","高二下"],12:["高三上","高三下","高三"]},a=[];if(e)if(e<=6)for(let t=1;t<=e;t++)a.push(...r[t]);else if(e>=7&&e<=9)for(let t=7;t<=e;t++)a.push(...r[t]||[]);else for(let t=10;t<=e;t++)a.push(...r[t]||[]);else for(let e=7;e<=12;e++)a.push(...r[e]);try{let e=(await t.f.knowledgeTag.findMany({where:{subject:"math",parentId:null,tagSet:i,name:{in:a}},select:{id:!0}})).map(e=>e.id),r=await t.f.knowledgeTag.findMany({where:{subject:"math",isSystem:!0,tagSet:i},select:{id:!0,name:!0,parentId:!0}}),s=new Map;r.forEach(e=>{if(e.parentId){let t=s.get(e.parentId)||[];t.push(e.id),s.set(e.parentId,t)}});let n=e=>{let t=s.get(e)||[];return 0===t.length?[e]:t.flatMap(e=>n(e))},o=new Set;e.forEach(e=>{n(e).forEach(e=>o.add(e))});let l=new Map(r.map(e=>[e.id,e.name]));return Array.from(o).map(e=>l.get(e)).filter(e=>!!e)}catch(e){return s.error({error:e},"getMathTagsFromDB error"),[]}}async function a(e,i="default"){try{return(await t.f.knowledgeTag.findMany({where:{subject:e,isSystem:!0,tagSet:i,children:{none:{}}},select:{name:!0},orderBy:{order:"asc"}})).map(e=>e.name)}catch(e){return s.error({error:e},"getTagsFromDB error"),[]}}async function o(e,i,n="default"){try{let s=await t.f.knowledgeTag.findMany({where:{subject:e,isSystem:!0,tagSet:n},select:{id:!0,name:!0,parentId:!0},orderBy:[{order:"asc"},{createdAt:"asc"}]}),a=new Map;for(let e of s)if(e.parentId){let t=a.get(e.parentId)||[];t.push(e),a.set(e.parentId,t)}let o=new Set,l=e=>{let t=a.get(e.id);t?.length?t.forEach(l):o.add(e.name)};return s.filter(e=>!e.parentId&&(0,r.U)(e.name,i)).forEach(l),Array.from(o)}catch(t){return s.error({error:t,subject:e,stage:i,tagSet:n},"getScopeTagsFromDB error"),[]}}async function l(e,t="default"){if(e.subject)return{subjectName:r.L[e.subject],tags:await o(e.subject,e.stage,t)}}async function c(e,t,i="default"){return{prefetchedMathTags:"数学"!==e&&e?[]:await n(t||null,i),prefetchedPhysicsTags:"物理"!==e&&e?[]:await a("physics",i),prefetchedChemistryTags:"化学"!==e&&e?[]:await a("chemistry",i),prefetchedBiologyTags:"生物"!==e&&e?[]:await a("biology",i),prefetchedEnglishTags:"英语"!==e&&e?[]:await a("english",i)}}e.s(["v",0,n,"K",0,l,"e",0,o,"i",0,c])},215267,539811,e=>{var t=e.i(376025);function i(e,r,s=new Date,n="en",a=t.J){let o=(0,t.c)(s,a),l=o.getFullYear(),c=o.getMonth()+1,u=l-r,h="2nd";c>=9?(u+=1,h="1st"):h=c<2?"1st":"2nd";let d="zh"===n,p=d?"1st"===h?"上期":"下期":"1st"===h?"1st Semester":"2nd Semester",_=(d?{primary:["一年级","二年级","三年级","四年级","五年级","六年级"],junior_high:["初一","初二","初三"],senior_high:["高一","高二","高三"],university:["大一","大二","大三","大四"]}:{primary:["Grade 1","Grade 2","Grade 3","Grade 4","Grade 5","Grade 6"],junior_high:["Junior High Grade 1","Junior High Grade 2","Junior High Grade 3"],senior_high:["Senior High Grade 1","Senior High Grade 2","Senior High Grade 3"],university:["Freshman","Sophomore","Junior","Senior"]})[e]||[],f=`${u}`;if(f=u>0&&u<=_.length?_[u-1]:u>_.length?d?"已毕业":"Graduated":d?"学前":"Pre-school",!d)return`${f}, ${p}`;{let e="1st"===h?"上":"下";return`${f}${e}`}}e.s(["f",0,i],539811);var r=e.i(411706);function s(e){if("string"!=typeof e)return null;let t=e.trim();return r.H.includes(t)?t:null}function n(e,r=t.J){return"ai"===e.gradeRecognitionMode?null:e.fixedGradeSemester?e.fixedGradeSemester:e.educationStage&&e.enrollmentYear?i(e.educationStage,e.enrollmentYear,new Date,"zh",r):null}e.s(["K",0,["fixed","ai"],"L",0,n,"Z",0,function(e,i=t.J){let s=n(e,i),a=s?r.T.findIndex(e=>s.startsWith(e)):-1;return{grade:a>=0&&a<12?a+1:null,gradeSemester:s}},"P",0,function(e,t){return"ai"===e.gradeRecognitionMode&&void 0===t.gradeSemester&&void 0===t.recognizedGradeSemester&&!!t.questionText?.trim()},"X",0,s,"S",0,function(e,i,r=t.J){return void 0!==i.gradeSemester?i.gradeSemester?.trim()||null:"ai"===e.gradeRecognitionMode?s(i.recognizedGradeSemester):n(e,r)}],215267)},481183,e=>{function t(e){let t=e.length;for(;t>0&&"/"===e[t-1];)t--;return e.slice(0,t)}e.s(["$",0,function(e){let i;try{i=new URL(e)}catch{throw Error(`Invalid base URL: ${e}`)}if("http:"!==i.protocol&&"https:"!==i.protocol)throw Error(`Base URL must use http or https: ${e}`);return t(i.toString())},"z",0,t])}],426900,(e,t,i)=>{!function(i,r){var s={};r(s);var n=s.default;for(var a in s)n[a]=s[a];if("object"==typeof t.exports)t.exports=n;else if("function"==typeof define&&define.amd)e.r,void 0!==n&&e.v(n);else i.sha256=n}(e.e,function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2]);function i(e,i,r,s,n){for(var a,o,l,c,u,h,d,p,_,f,g,m,v;n>=64;){for(a=i[0],o=i[1],l=i[2],c=i[3],u=i[4],h=i[5],d=i[6],p=i[7],f=0;f<16;f++)g=s+4*f,e[f]=(255&r[g])<<24|(255&r[g+1])<<16|(255&r[g+2])<<8|255&r[g+3];for(f=16;f<64;f++)m=((_=e[f-2])>>>17|_<<15)^(_>>>19|_<<13)^_>>>10,v=((_=e[f-15])>>>7|_<<25)^(_>>>18|_<<14)^_>>>3,e[f]=(m+e[f-7]|0)+(v+e[f-16]|0);for(f=0;f<64;f++)m=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&h^~u&d)|0)+(p+(t[f]+e[f]|0)|0)|0,v=((a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10))+(a&o^a&l^o&l)|0,p=d,d=h,h=u,u=c+m|0,c=l,l=o,o=a,a=m+v|0;i[0]+=a,i[1]+=o,i[2]+=l,i[3]+=c,i[4]+=u,i[5]+=h,i[6]+=d,i[7]+=p,s+=64,n-=64}return s}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]=0x6a09e667,this.state[1]=0xbb67ae85,this.state[2]=0x3c6ef372,this.state[3]=0xa54ff53a,this.state[4]=0x510e527f,this.state[5]=0x9b05688c,this.state[6]=0x1f83d9ab,this.state[7]=0x5be0cd19,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(void 0===t&&(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--;64===this.bufferLength&&(i(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(t>=64&&(r=i(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,s=t/0x20000000|0,n=t<<3,a=t%64<56?64:128;this.buffer[r]=128;for(var o=r+1;o<a-8;o++)this.buffer[o]=0;this.buffer[a-8]=s>>>24&255,this.buffer[a-7]=s>>>16&255,this.buffer[a-6]=s>>>8&255,this.buffer[a-5]=s>>>0&255,this.buffer[a-4]=n>>>24&255,this.buffer[a-3]=n>>>16&255,this.buffer[a-2]=n>>>8&255,this.buffer[a-1]=n>>>0&255,i(this.temp,this.state,this.buffer,0,a),this.finished=!0}for(var o=0;o<8;o++)e[4*o+0]=this.state[o]>>>24&255,e[4*o+1]=this.state[o]>>>16&255,e[4*o+2]=this.state[o]>>>8&255,e[4*o+3]=this.state[o]>>>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 i=0;i<this.state.length;i++)this.state[i]=e[i];this.bytesHashed=t,this.finished=!1,this.bufferLength=0},t}();e.Hash=r;var s=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 i=0;i<e.length;i++)t[i]=e[i];for(var i=0;i<t.length;i++)t[i]^=54;this.inner.update(t);for(var i=0;i<t.length;i++)t[i]^=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 i=0;i<t.length;i++)t[i]=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}();function n(e){var t=new r().update(e),i=t.digest();return t.clean(),i}function a(e,t){var i=new s(e).update(t),r=i.digest();return i.clean(),r}e.HMAC=s,e.hash=n,e.default=n,e.hmac=a;var o=new Uint8Array(e.digestLength);e.hkdf=function(e,t,i,r){void 0===t&&(t=o),void 0===r&&(r=32);for(var n=new Uint8Array([1]),l=new s(a(t,e)),c=new Uint8Array(l.digestLength),u=c.length,h=new Uint8Array(r),d=0;d<r;d++)u===c.length&&(!function(e,t,i,r){var s=r[0];if(0===s)throw Error("hkdf: cannot expand more");t.reset(),s>1&&t.update(e),i&&t.update(i),t.update(r),t.finish(e),r[0]++}(c,l,i,n),u=0),h[d]=c[u++];return l.clean(),c.fill(0),n.fill(0),h},e.pbkdf2=function(e,t,i,r){for(var n=new s(e),a=n.digestLength,o=new Uint8Array(4),l=new Uint8Array(a),c=new Uint8Array(a),u=new Uint8Array(r),h=0;h*a<r;h++){var d=h+1;o[0]=d>>>24&255,o[1]=d>>>16&255,o[2]=d>>>8&255,o[3]=d>>>0&255,n.reset(),n.update(t),n.update(o),n.finish(c);for(var p=0;p<a;p++)l[p]=c[p];for(var p=2;p<=i;p++){n.reset(),n.update(c).finish(c);for(var _=0;_<a;_++)l[_]^=c[_]}for(var p=0;p<a&&h*a+p<r;p++)u[h*a+p]=l[p]}for(var h=0;h<a;h++)l[h]=c[h]=0;for(var h=0;h<4;h++)o[h]=0;return n.clean(),u}})}];
|
|
7
7
|
|
|
8
8
|
//# sourceMappingURL=_1dvka-waihfum._.js.map
|