thursday-agent 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +3 -3
- package/.next/prerender-manifest.json +4 -4
- package/.next/server/app/_global-error/page.js.nft.json +1 -1
- 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/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +12 -12
- package/.next/server/app/_not-found.segments/_full.segment.rsc +12 -12
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +11 -11
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/api/artifact/route.js +6 -6
- package/.next/server/app/api/artifact/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/memory/files/route.js +5 -4
- package/.next/server/app/api/bot/memory/files/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/memory/route.js +9 -9
- package/.next/server/app/api/bot/memory/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/route.js +9 -9
- package/.next/server/app/api/bot/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/thread/[id]/route.js +2 -2
- package/.next/server/app/api/bot/thread/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/thread/file/route.js +12 -12
- package/.next/server/app/api/bot/thread/file/route.js.nft.json +1 -1
- package/.next/server/app/api/bot/thread/route.js +2 -2
- package/.next/server/app/api/bot/thread/route.js.nft.json +1 -1
- package/.next/server/app/api/config/route.js +2 -2
- package/.next/server/app/api/config/route.js.nft.json +1 -1
- package/.next/server/app/api/events/route.js.nft.json +1 -1
- package/.next/server/app/api/favicon/[host]/route.js.nft.json +1 -1
- package/.next/server/app/api/file/[...path]/route.js +3 -3
- package/.next/server/app/api/file/[...path]/route.js.nft.json +1 -1
- package/.next/server/app/api/llm-model/automatic/route.js.nft.json +1 -1
- package/.next/server/app/api/llm-model/catalog/[provider]/route.js.nft.json +1 -1
- package/.next/server/app/api/llm-model/credits/[provider]/route.js.nft.json +1 -1
- package/.next/server/app/api/llm-model/route.js.nft.json +1 -1
- package/.next/server/app/api/llm-model/subscription/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/[name]/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/oauth/callback/route.js +2 -2
- package/.next/server/app/api/mcp/oauth/callback/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/route.js.nft.json +1 -1
- package/.next/server/app/api/mcp/tools/route.js.nft.json +1 -1
- package/.next/server/app/api/memory/edit/route.js +13 -13
- package/.next/server/app/api/memory/edit/route.js.nft.json +1 -1
- package/.next/server/app/api/memory/route.js +1 -1
- package/.next/server/app/api/memory/route.js.nft.json +1 -1
- package/.next/server/app/api/reach/route.js +11 -11
- package/.next/server/app/api/reach/route.js.nft.json +1 -1
- package/.next/server/app/api/routine/route.js +9 -9
- package/.next/server/app/api/routine/route.js.nft.json +1 -1
- package/.next/server/app/api/running/route.js.nft.json +1 -1
- package/.next/server/app/api/signins/route.js +7 -6
- package/.next/server/app/api/signins/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/[source]/[name]/route.js +8 -8
- package/.next/server/app/api/skills/[source]/[name]/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/route.js +8 -8
- package/.next/server/app/api/skills/route.js.nft.json +1 -1
- package/.next/server/app/api/thursday/call/end/route.js +6 -6
- package/.next/server/app/api/thursday/call/end/route.js.nft.json +1 -1
- package/.next/server/app/api/thursday/call/plan/route.js +16 -16
- package/.next/server/app/api/thursday/call/plan/route.js.nft.json +1 -1
- package/.next/server/app/api/thursday/call/route.js +6 -6
- package/.next/server/app/api/thursday/call/route.js.nft.json +1 -1
- package/.next/server/app/api/thursday/settings/route.js +6 -6
- package/.next/server/app/api/thursday/settings/route.js.nft.json +1 -1
- package/.next/server/app/api/thursday/text/route.js +16 -16
- package/.next/server/app/api/thursday/text/route.js.nft.json +1 -1
- package/.next/server/app/api/thursday/tool-call/route.js +10 -10
- package/.next/server/app/api/thursday/tool-call/route.js.nft.json +1 -1
- package/.next/server/app/api/workspace/files/route.js +1 -1
- package/.next/server/app/api/workspace/files/route.js.nft.json +1 -1
- package/.next/server/app/api/workspace/route.js +1 -1
- package/.next/server/app/api/workspace/route.js.nft.json +1 -1
- package/.next/server/app/artifact/[...path]/page/server-reference-manifest.json +11 -11
- package/.next/server/app/artifact/[...path]/page.js +5 -5
- package/.next/server/app/artifact/[...path]/page.js.nft.json +1 -1
- package/.next/server/app/artifact/[...path]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/favicon.ico/route.js.nft.json +1 -1
- package/.next/server/app/manifest.webmanifest/route.js.nft.json +1 -1
- package/.next/server/app/page/react-loadable-manifest.json +2 -2
- package/.next/server/app/page/server-reference-manifest.json +162 -162
- package/.next/server/app/page.js +7 -7
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__019e1fy._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__01jpmcj._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__03bjojd._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__03vunn6._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__06kxzw-._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__0atwstu._.js +1 -1
- package/.next/server/chunks/{[root-of-the-server]__005onk_._.js → [root-of-the-server]__0cfv4rq._.js} +1 -1
- package/.next/server/chunks/[root-of-the-server]__0d-dfqm._.js +1 -1
- package/.next/server/chunks/{[root-of-the-server]__1-i6lgn._.js → [root-of-the-server]__0d00o4_._.js} +1 -1
- package/.next/server/chunks/{[root-of-the-server]__0itmdqy._.js → [root-of-the-server]__0e8y4ok._.js} +1 -1
- package/.next/server/chunks/{[root-of-the-server]__1tyftcr._.js → [root-of-the-server]__0eem_66._.js} +1 -1
- package/.next/server/chunks/{[root-of-the-server]__0xn7a8p._.js → [root-of-the-server]__0jn2qbf._.js} +1 -1
- package/.next/server/chunks/{[root-of-the-server]__08922kg._.js → [root-of-the-server]__0l563r8._.js} +1 -1
- package/.next/server/chunks/[root-of-the-server]__0mh1tgg._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0mq0qmk._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0ncs9uu._.js +1 -1
- package/.next/server/chunks/{[root-of-the-server]__1a7rgvy._.js → [root-of-the-server]__0pp2355._.js} +1 -1
- package/.next/server/chunks/{[root-of-the-server]__1g08s7l._.js → [root-of-the-server]__0r77huw._.js} +2 -2
- package/.next/server/chunks/[root-of-the-server]__10_v9ml._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__13hng6h._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__1478lu3._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__16xao_p._.js +5 -0
- package/.next/server/chunks/[root-of-the-server]__17kdjf6._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__17m7ag9._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__17yv6lg._.js +5 -0
- package/.next/server/chunks/[root-of-the-server]__19aqyg-._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__19imprr._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__1_04mcf._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__1ceammd._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__1fhule0._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__1hing45._.js +3 -0
- package/.next/server/chunks/{[root-of-the-server]__0mttntm._.js → [root-of-the-server]__1ivfglf._.js} +1 -1
- package/.next/server/chunks/[root-of-the-server]__1jcu_e9._.js +5 -0
- package/.next/server/chunks/{[root-of-the-server]__0m0qglo._.js → [root-of-the-server]__1kb-dkn._.js} +2 -2
- package/.next/server/chunks/{[root-of-the-server]__0eluax8._.js → [root-of-the-server]__1mowvzz._.js} +1 -1
- package/.next/server/chunks/[root-of-the-server]__1ndi14y._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__1o7z93z._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__1onvx8x._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__1q_d6dj._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__1u_6dhy._.js +1 -1
- package/.next/server/chunks/{[root-of-the-server]__1_wtn0q._.js → [root-of-the-server]__1yiqjfx._.js} +1 -1
- package/.next/server/chunks/[root-of-the-server]__1yr_vvq._.js +3 -0
- package/.next/server/chunks/_0-mqt2w._.js +3 -0
- package/.next/server/chunks/_0-qt5if._.js +1 -1
- package/.next/server/chunks/{_0fau3ya._.js → _00aztuo._.js} +2 -2
- package/.next/server/chunks/_021kabv._.js +53 -0
- package/.next/server/chunks/_032k4m6._.js +3 -0
- package/.next/server/chunks/_03p6r2-._.js +1 -1
- package/.next/server/chunks/_06b5b4-._.js +2 -2
- package/.next/server/chunks/_06u9yo-._.js +1 -1
- package/.next/server/chunks/_07mczew._.js +3 -0
- package/.next/server/chunks/_07pkeds._.js +1 -1
- package/.next/server/chunks/_08354bn._.js +22 -22
- package/.next/server/chunks/_083t_nr._.js +5 -0
- package/.next/server/chunks/_0c-s0ei._.js +3 -0
- package/.next/server/chunks/_0cq69mm._.js +1 -1
- package/.next/server/chunks/_0gifi_2._.js +7 -0
- package/.next/server/chunks/_0gxz_1b._.js +1 -1
- package/.next/server/chunks/{_1tjwvoz._.js → _0la8s6t._.js} +2 -2
- package/.next/server/chunks/_0p27in2._.js +1 -1
- package/.next/server/chunks/{_09rtyfn._.js → _0rn3c_0._.js} +24 -26
- package/.next/server/chunks/_0ue8nq-._.js +5 -1
- package/.next/server/chunks/{_1uu4wjr._.js → _0wkhub3._.js} +2 -2
- package/.next/server/chunks/_0wyh244._.js +22 -22
- package/.next/server/chunks/_0ynjnhl._.js +5 -0
- package/.next/server/chunks/_1-wp0r0._.js +1 -1
- package/.next/server/chunks/{_201k0ah._.js → _12-7atf._.js} +2 -2
- package/.next/server/chunks/{_02mn8d7._.js → _124q1p2._.js} +2 -2
- package/.next/server/chunks/{_14xuq46._.js → _13qoxq9._.js} +24 -26
- package/.next/server/chunks/{_11y8h29._.js → _15-_mie._.js} +2 -2
- package/.next/server/chunks/_1823_7a._.js +1 -1
- package/.next/server/chunks/{_0uir6hb._.js → _186uku9._.js} +2 -2
- package/.next/server/chunks/{_0ggqpiz._.js → _18sj4xf._.js} +2 -2
- package/.next/server/chunks/_19kea1l._.js +12 -12
- package/.next/server/chunks/_1ac33qw._.js +2 -2
- package/.next/server/chunks/{_18z965x._.js → _1chy-lk._.js} +2 -2
- package/.next/server/chunks/_1cw6-rv._.js +1 -1
- package/.next/server/chunks/_1evvnbp._.js +1 -1
- package/.next/server/chunks/_1f_x75d._.js +3 -0
- package/.next/server/chunks/_1gn2r2q._.js +7 -9
- package/.next/server/chunks/_1icgbi8._.js +1 -1
- package/.next/server/chunks/{_1ozcb6o._.js → _1k6bmez._.js} +2 -2
- package/.next/server/chunks/_1ko5shz._.js +1 -1
- package/.next/server/chunks/_1ksyu6r._.js +1 -1
- package/.next/server/chunks/_1kwmzab._.js +3 -0
- package/.next/server/chunks/_1lg0lsu._.js +1 -1
- package/.next/server/chunks/_1pv6xbq._.js +5 -0
- package/.next/server/chunks/_1q42187._.js +2 -2
- package/.next/server/chunks/_1q6e56i._.js +7 -9
- package/.next/server/chunks/_1t43w6q._.js +1 -1
- package/.next/server/chunks/_1t8fv7b._.js +1 -1
- package/.next/server/chunks/_1ufbxe1._.js +1 -1
- package/.next/server/chunks/_1wgae1c._.js +1 -1
- package/.next/server/chunks/_1xps4ob._.js +1 -1
- package/.next/server/chunks/_1znrlca._.js +3 -0
- package/.next/server/chunks/config_ts_1g4sz5o._.js +1 -1
- package/.next/server/chunks/features_14kex_m._.js +11 -11
- package/.next/server/chunks/features_bot_08z387_._.js +2 -2
- package/.next/server/chunks/features_bot_1d6ghh5._.js +41 -0
- package/.next/server/chunks/features_bot_1dfrdsb._.js +10 -6
- package/.next/server/chunks/{node_modules_consola_dist_chunks_prompt_mjs_0yd5xa0._.js → node_modules_consola_dist_chunks_prompt_mjs_0k--vqs._.js} +1 -1
- package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_0ufuc3s._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__05qiosr._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__0y03pu0._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__0zt_au4._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__0eloa6y._.js → [root-of-the-server]__17yeveo._.js} +5 -5
- package/.next/server/chunks/ssr/[root-of-the-server]__1867koj._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__1t38-p_._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__1u42eh0._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__203utm3._.js +1 -1
- package/.next/server/chunks/ssr/{_0xurp8n._.js → _0-s7ria._.js} +2 -2
- package/.next/server/chunks/ssr/_03vw3u5._.js +3 -0
- package/.next/server/chunks/ssr/_088qe9a._.js +162 -0
- package/.next/server/chunks/ssr/_09a6bpd._.js +1 -1
- package/.next/server/chunks/ssr/{_0u43zjx._.js → _0a_pedm._.js} +2 -2
- package/.next/server/chunks/ssr/_0ali_i8._.js +3 -0
- package/.next/server/chunks/ssr/_0cd6g3l._.js +3 -3
- package/.next/server/chunks/ssr/{_1nwey7a._.js → _0eprrig._.js} +2 -2
- package/.next/server/chunks/ssr/_0flnog5._.js +3 -0
- package/.next/server/chunks/ssr/_0iuvjnw._.js +1 -1
- package/.next/server/chunks/ssr/{_0t_e9rd._.js → _0k-gl8l._.js} +2 -2
- package/.next/server/chunks/ssr/_0kmldic._.js +41 -0
- package/.next/server/chunks/ssr/_0ks03l-._.js +3 -0
- package/.next/server/chunks/ssr/_0mng-y8._.js +6 -0
- package/.next/server/chunks/ssr/_0tg3o37._.js +1 -1
- package/.next/server/chunks/ssr/_0ugzm_0._.js +3 -0
- package/.next/server/chunks/ssr/{_0ntol64._.js → _0wnv6c0._.js} +2 -2
- package/.next/server/chunks/ssr/{_0-y08rv._.js → _0z9zkd-._.js} +2 -2
- package/.next/server/chunks/ssr/_11l9kc0._.js +1 -1
- package/.next/server/chunks/ssr/_12_ail7._.js +3 -0
- package/.next/server/chunks/ssr/_16_7zeo._.js +1 -1
- package/.next/server/chunks/ssr/_16wjbs2._.js +3 -0
- package/.next/server/chunks/ssr/{_16o81mn._.js → _18rmqqu._.js} +2 -2
- package/.next/server/chunks/ssr/_1bfrntd._.js +2 -2
- package/.next/server/chunks/ssr/{_0gn_i4s._.js → _1ckje8g._.js} +2 -2
- package/.next/server/chunks/ssr/_1crszf7._.js +1 -1
- package/.next/server/chunks/ssr/_1h3qetc._.js +3 -0
- package/.next/server/chunks/ssr/{_1gz4ov7._.js → _1kpvfmn._.js} +3 -3
- package/.next/server/chunks/ssr/{_12hdw8x._.js → _1l-3enz._.js} +26 -28
- package/.next/server/chunks/ssr/_1neoj22._.js +1 -1
- package/.next/server/chunks/ssr/_1soynbw._.js +2 -2
- package/.next/server/chunks/ssr/{_0ux4i2m._.js → _1v1pcoh._.js} +2 -2
- package/.next/server/chunks/ssr/features_ai_components_model-picker_tsx_0ucb1y9._.js +1 -1
- package/.next/server/chunks/ssr/{features_bot_06n7hmd._.js → features_bot_0-7flc-._.js} +2 -2
- package/.next/server/chunks/ssr/features_bot_0tb4ui-._.js +1 -1
- package/.next/server/chunks/ssr/features_bot_1stfytf._.js +41 -0
- package/.next/server/chunks/ssr/features_config_10xs4l1._.js +20 -0
- package/.next/server/chunks/ssr/features_connectors_components_mcp-setting_tsx_0jmbgvp._.js +1 -1
- package/.next/server/chunks/ssr/features_memory_components_memory-setting_tsx_0oa43sw._.js +1 -1
- package/.next/server/chunks/ssr/features_routine_components_routine-setting_tsx_055fknz._.js +1 -1
- package/.next/server/chunks/ssr/features_thursday_0cf9y0b._.js +1 -1
- package/.next/server/chunks/ssr/features_thursday_components_here-globe_tsx_055duhw._.js +1 -1
- package/.next/server/chunks/ssr/lib_utils_ts_0_f1xvm._.js +1 -1
- package/.next/server/chunks/ssr/{node_modules_1i-g3bz._.js → node_modules_00mh9o-._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1bvw77g._.js → node_modules_04f_uw2._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_16tn8xu._.js → node_modules_07udd3z._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0ksqeyy._.js → node_modules_08-pj-2._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0e398ts._.js → node_modules_098h6h5._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_19r9vjv._.js → node_modules_0_7yfem._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_01v7ybp._.js → node_modules_0ayoorn._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0_zk6yd._.js → node_modules_0bp3vfu._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0m-dnm-._.js → node_modules_0ch5hqr._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0536cp2._.js → node_modules_0e-hyim._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0yn2z6s._.js → node_modules_0ffm9w3._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1jf8aik._.js → node_modules_0jzyuwk._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0m2oth3._.js → node_modules_0ln4iwf._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1dlue-g._.js → node_modules_0my2hph._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0cpegwf._.js → node_modules_0y_k4h5._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_13dwal5._.js → node_modules_10bzndo._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1ctm_ju._.js → node_modules_1b5rxw5._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_01fukqn._.js → node_modules_1b_h09q._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_12hh0bx._.js → node_modules_1e83j9e._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_08m1gvh._.js → node_modules_1e9ugfy._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_06n6ruk._.js → node_modules_1hd66k0._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1zdz2zf._.js → node_modules_1inwr2m._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1zalmtr._.js → node_modules_1j9xx1k._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_1kfbdfo._.js → node_modules_1k8kypa._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_056xgci._.js → node_modules_1oeu85h._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_0ie8g6a._.js → node_modules_1r2ghv5._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_1fqgrh0._.js → node_modules_1ttpnib._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0nj1l8f._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0ir6p7s._.js} +1 -1
- package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_17ok98u._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_1ejf5ye._.js} +1 -1
- package/.next/server/middleware-build-manifest.js +3 -3
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +163 -163
- package/.next/static/chunks/02lze_e5sagjn.js +1 -0
- package/.next/static/chunks/{3866u-edsoyj3.js → 081kl7k8r6f8z.js} +1 -1
- package/.next/static/chunks/0_s4z70lx1tgs.js +1 -0
- package/.next/static/chunks/0fklfoj8o_msg.js +18 -0
- package/.next/static/chunks/0ve2gb0hw3wkq.js +1 -0
- package/.next/static/chunks/11c3uijgqik4m.js +39 -0
- package/.next/static/chunks/{0go5_9zqag7l0.js → 125lh2zzxk3r2.js} +1 -1
- package/.next/static/chunks/{3zv4wiqjl5kex.js → 166v36614ycsf.js} +1 -1
- package/.next/static/chunks/16np6727e61io.js +1 -0
- package/.next/static/chunks/18amidjlaqexf.js +1 -0
- package/.next/static/chunks/{35ehi-okrfot5.js → 1ettmta9iet7b.js} +1 -1
- package/.next/static/chunks/{1dy5xaxjdsy11.js → 1j4rndg17wgfk.js} +1 -1
- package/.next/static/chunks/{01r1uco3ikisc.js → 1mpz4epyg-7pz.js} +1 -1
- package/.next/static/chunks/{05blzta_1i7c2.js → 1oh4hbusfz97l.js} +1 -1
- package/.next/static/chunks/{3qfhjwd9yuijo.js → 1x1-44qmhu437.js} +1 -1
- package/.next/static/chunks/{0hpx0--bh7vld.js → 22jb4s3-8ckup.js} +1 -1
- package/.next/static/chunks/236le5kv_yj6a.css +1 -0
- package/.next/static/chunks/24op50z6sqi_5.js +1 -0
- package/.next/static/chunks/2eczs-lporqt6.js +1 -0
- package/.next/static/chunks/{2nbj2t9yp8ke9.js → 2sxclirl-c-um.js} +1 -1
- package/.next/static/chunks/2yfmmo4qr_f-m.js +1 -0
- package/.next/static/chunks/2z4sodeldj_86.js +1 -0
- package/.next/static/chunks/{3tyacy8fh5_18.js → 2zhiqxw61qowv.js} +2 -2
- package/.next/static/chunks/338dt83llhu5m.js +1 -0
- package/.next/static/chunks/3ezjz93yvzmop.js +4 -0
- package/.next/static/chunks/3h6rqjx92wva9.js +1 -0
- package/.next/static/chunks/3ph9u-51x6jhe.js +15 -0
- package/.next/static/chunks/{052u13mcoxt87.js → 3uf32hp_g9stz.js} +1 -1
- package/.next/static/chunks/3w7zt3xzyjn86.js +3 -0
- package/.next/static/chunks/3xkx7vqefm7on.js +2 -0
- package/.next/static/chunks/3ygk41pgsw7nv.js +1 -0
- package/.next/static/chunks/{3146sccz1j76i.js → 411uyd0is9u5s.js} +1 -1
- package/.next/static/chunks/4384atd5zerir.js +1 -0
- package/README.md +1 -1
- package/database/migrations/20260929121448_thread_started_by/migration.sql +1 -0
- package/database/migrations/20260929121448_thread_started_by/snapshot.json +1969 -0
- package/guide/bots.md +89 -44
- package/guide/calls.md +41 -25
- package/guide/index.md +5 -2
- package/guide/phone.md +7 -4
- package/guide/setup.md +12 -6
- package/guide/trouble.md +3 -2
- package/package.json +1 -1
- package/public/voices/intro/mic-b17ca82d.ogg +0 -0
- package/seed-skills/concierge/travel/SKILL.md +2 -1
- package/seed-skills/concierge/travel/page/itinerary.css +1009 -257
- package/seed-skills/concierge/travel/references/itinerary.md +95 -35
- package/seed-skills/concierge/travel/references/plan.md +11 -4
- package/seed-skills/concierge/travel/scripts/itinerary.mjs +754 -138
- package/skills/README.md +7 -4
- package/skills/artifact/SKILL.md +17 -13
- package/skills/artifact/references/canvas.md +4 -5
- package/skills/artifact/references/deck.md +93 -2
- package/skills/artifact/runtime/app/kit/src/index.css +35 -0
- package/skills/artifact/runtime/app/kit/tailwind.config.js +6 -0
- package/skills/artifact/runtime/deck/data.mjs +21 -0
- package/skills/artifact/runtime/deck/deck.css +254 -4
- package/skills/artifact/runtime/deck/deck.html +3 -0
- package/skills/artifact/runtime/deck/deck.js +88 -5
- package/skills/artifact/runtime/deck/deck.mjs +1 -17
- package/skills/artifact/runtime/document/quick.css +264 -89
- package/skills/artifact/runtime/document/quick.html +16 -7
- package/skills/artifact/runtime/document/quick.js +377 -98
- package/skills/artifact/runtime/render.mjs +52 -6
- package/skills/artifact/runtime/sheet/sheet.css +29 -21
- package/skills/artifact/runtime/shell/drafts.js +25 -0
- package/skills/artifact/runtime/shell/fonts/Geist-latin-ext.woff2 +0 -0
- package/skills/artifact/runtime/shell/fonts/Geist-latin.woff2 +0 -0
- package/skills/artifact/runtime/shell/fonts/GeistMono-latin-ext.woff2 +0 -0
- package/skills/artifact/runtime/shell/fonts/GeistMono-latin.woff2 +0 -0
- package/skills/artifact/runtime/shell/fonts/OFL.txt +93 -0
- package/skills/artifact/runtime/shell/head.html +27 -2
- package/skills/artifact/runtime/shell/shell.css +88 -8
- package/skills/artifact/runtime/shell/shell.js +318 -22
- package/skills/artifact/runtime/shell/wear.mjs +114 -12
- package/skills/artifact/scripts/app.mjs +5 -0
- package/skills/artifact/scripts/chart.mjs +20 -19
- package/skills/artifact/scripts/deck.mjs +276 -0
- package/skills/artifact/scripts/document.mjs +55 -2
- package/skills/artifact/scripts/media.mjs +1 -1
- package/skills/artifact/templates/boards/direction.html +55 -2
- package/skills/browser/SKILL.md +1 -1
- package/skills/browser/references/scripts.md +1 -1
- package/skills/daily-brief/SKILL.md +2 -0
- package/skills/daily-brief/page/brief.css +460 -302
- package/skills/daily-brief/references/brief.md +33 -7
- package/skills/daily-brief/scripts/page.mjs +241 -48
- package/skills/media-digest/SKILL.md +1 -0
- package/skills/media-digest/scripts/digest.mjs +57 -43
- package/.next/server/chunks/[root-of-the-server]__00f051a._.js +0 -7
- package/.next/server/chunks/[root-of-the-server]__0340k46._.js +0 -7
- package/.next/server/chunks/[root-of-the-server]__0ndw2yj._.js +0 -5
- package/.next/server/chunks/[root-of-the-server]__16y0k92._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__18e65_-._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__1a0xgyh._.js +0 -5
- package/.next/server/chunks/[root-of-the-server]__1dth047._.js +0 -5
- package/.next/server/chunks/[root-of-the-server]__1huywqp._.js +0 -5
- package/.next/server/chunks/[root-of-the-server]__1ij4h2a._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__1q1s4ls._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__1qa67zs._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__1t-mfa4._.js +0 -5
- package/.next/server/chunks/[root-of-the-server]__20ofm9t._.js +0 -3
- package/.next/server/chunks/_0483t_f._.js +0 -5
- package/.next/server/chunks/_0lcthk8._.js +0 -3
- package/.next/server/chunks/_0uv1gs1._.js +0 -3
- package/.next/server/chunks/_17fjc-7._.js +0 -5
- package/.next/server/chunks/_1dcbwn-._.js +0 -3
- package/.next/server/chunks/_1mgzs18._.js +0 -3
- package/.next/server/chunks/_20qn224._.js +0 -3
- package/.next/server/chunks/features_bot_0zy_q8y._.js +0 -37
- package/.next/server/chunks/ssr/[root-of-the-server]__04upd5v._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__0dy20eb._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__0yyxgt2._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__14j8gxy._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__20t_4l2._.js +0 -3
- package/.next/server/chunks/ssr/_00buy3i._.js +0 -162
- package/.next/server/chunks/ssr/_014_wjp._.js +0 -3
- package/.next/server/chunks/ssr/_07m4ii5._.js +0 -3
- package/.next/server/chunks/ssr/_0cv9tmv._.js +0 -3
- package/.next/server/chunks/ssr/_0j6rtjm._.js +0 -6
- package/.next/server/chunks/ssr/_0ogkeu-._.js +0 -3
- package/.next/server/chunks/ssr/_10sc7ab._.js +0 -3
- package/.next/server/chunks/ssr/_14nwim3._.js +0 -37
- package/.next/server/chunks/ssr/_1e01b-_._.js +0 -3
- package/.next/server/chunks/ssr/_1nfv27b._.js +0 -3
- package/.next/server/chunks/ssr/features_bot_1c56lew._.js +0 -37
- package/.next/server/chunks/ssr/features_bot_1knyan7._.js +0 -3
- package/.next/server/chunks/ssr/features_config_09wq1s9._.js +0 -20
- package/.next/static/chunks/01gkq9y6_xk4a.js +0 -1
- package/.next/static/chunks/09kwsjbmr_z1w.js +0 -1
- package/.next/static/chunks/0ynv7zu_bguve.js +0 -1
- package/.next/static/chunks/0zi59tghmg1lu.js +0 -18
- package/.next/static/chunks/1_ftsgxa-sia_.js +0 -1
- package/.next/static/chunks/1cg3torc90q5t.js +0 -1
- package/.next/static/chunks/1qnx1h5c8f93b.js +0 -1
- package/.next/static/chunks/1rwn3d9ji5w35.js +0 -1
- package/.next/static/chunks/1so3f5fi7e5g9.js +0 -35
- package/.next/static/chunks/1ya41wxfmp4s8.js +0 -1
- package/.next/static/chunks/27rwkfu7_xvs1.js +0 -4
- package/.next/static/chunks/2hueh8masqd91.js +0 -15
- package/.next/static/chunks/2jrt_752fqz2f.js +0 -1
- package/.next/static/chunks/2ogme4qydxnaq.js +0 -3
- package/.next/static/chunks/2r2tocw2rpvm2.js +0 -1
- package/.next/static/chunks/2t4kimg1lt-p7.js +0 -2
- package/.next/static/chunks/2w6y71o27my_z.js +0 -1
- package/.next/static/chunks/31_am8rtmk_tv.css +0 -1
- package/.next/static/chunks/337g9g_ux2gj-.js +0 -1
- package/public/voices/intro/heard-1f12cd45.ogg +0 -0
- package/public/voices/intro/mic-e561372a.ogg +0 -0
- package/skills/artifact/references/book.md +0 -163
- package/skills/artifact/runtime/book/book.css +0 -256
- package/skills/artifact/runtime/book/book.html +0 -38
- package/skills/artifact/runtime/book/book.js +0 -81
- package/skills/artifact/scripts/book-pdf.mjs +0 -73
- package/skills/artifact/scripts/book-video.mjs +0 -168
- package/skills/artifact/scripts/book.mjs +0 -291
- /package/.next/static/{8exfHAtcoebYtxjUC4ugl → 6tIYlzfG_5P4sIxxgmucO}/_buildManifest.js +0 -0
- /package/.next/static/{8exfHAtcoebYtxjUC4ugl → 6tIYlzfG_5P4sIxxgmucO}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{8exfHAtcoebYtxjUC4ugl → 6tIYlzfG_5P4sIxxgmucO}/_ssgManifest.js +0 -0
- /package/seed-skills/{marketer → writer}/marketing/LICENSE +0 -0
- /package/seed-skills/{marketer → writer}/marketing/SKILL.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/copywriting-copy-frameworks.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/copywriting-natural-transitions.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/copywriting.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/emails-copy-guidelines.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/emails-email-types.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/emails-sequence-templates.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/emails.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/launch.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/product-marketing.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/seo-audit-ai-writing-detection.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/seo-audit-international-seo.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/seo-audit.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/social-carousel-frameworks.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/social-platform-limits.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/social-platforms.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/social-post-templates.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/social-reverse-engineering.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/social-short-form-video.md +0 -0
- /package/seed-skills/{marketer → writer}/marketing/references/social.md +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module.exports=[150171,e=>e.a(async(t,o)=>{try{var n=e.i(687388),r=e.i(340698),a=e.i(640911),i=e.i(53748),s=e.i(41444),l=e.i(264079),u=t([r]);[r]=u.then?(await u)():u;let m={"x-ai":"spacexai","z-ai":"zai",mistralai:"mistral","meta-llama":"meta",qwen:"alibaba","bytedance-seed":"bytedance"},h=e=>{let t=e.slice(0,e.indexOf("/")).replace(/^~/,"");return m[t]??t};function c(e){if(null==e||""===e)return null;let t=Number(e);return!Number.isFinite(t)||t<0?null:Math.round(1e6*t*1e4)/1e4}async function d(){let e=await fetch("https://openrouter.ai/api/v1/models",{headers:{accept:"application/json"}}).catch(e=>{a.logger.warn({cause:e},"openrouter catalog unreachable"),(0,i.publicError)("Could not reach OpenRouter")});return e.ok||(0,i.publicError)(`OpenRouter answered ${e.status}`),((await e.json()).data??[]).filter(e=>!!e.id).map(e=>{let t,o,n,r;return{id:e.id,label:e.name||e.id,owner:h(e.id),type:(e.architecture?.output_modalities??[]).includes("text")?l.CATALOG_TEXT:null,tags:(e.supported_parameters??[]).includes("tools")?[l.CATALOG_TOOL_USE]:[],price:(t=c(e.pricing?.prompt),o=c(e.pricing?.completion),0===t&&0===o?{in:0,out:0,note:null,free:!0}:{in:t,out:o,note:null===t&&null===o?"per model it picks":null,free:!1}),retiring:!!e.expiration_date,contextWindow:"number"==typeof e.context_length&&e.context_length>0?e.context_length:null,efforts:(n=e.reasoning?.supported_efforts??[],(r=l.EFFORTS.filter(e=>n.includes(e))).length?r:null)}})}async function p(){let e=await (0,r.readConfig)(l.TEXT_MODEL_PROVIDERS.openrouter.apiKeyName);if(!e)return null;let t=await fetch("https://openrouter.ai/api/v1/credits",{headers:{accept:"application/json",authorization:`Bearer ${e}`}}).catch(e=>{a.logger.warn({cause:e},"openrouter credits unreachable"),(0,i.publicError)("Could not reach OpenRouter")}),o=await t.json().catch(()=>null),u=(0,s.clip)(o?.error?.message??"",300);if(401===t.status||403===t.status)return{refused:u||`OpenRouter answered ${t.status}`};t.ok||(0,i.publicError)(`OpenRouter answered ${t.status}${u?`: ${u}`:""}`);let c=o?.data?.total_credits,d=o?.data?.total_usage;("number"!=typeof c||"number"!=typeof d)&&(0,i.publicError)("OpenRouter did not say what is left");let p=c-d;return{balance:p,low:p<=n.KEY_LOW_CREDIT}}e.s(["fetchOpenRouterCatalog",0,d,"readOpenRouterCredits",0,p,"vendorOf",0,h]),o()}catch(e){o(e)}},!1),386075,e=>e.a(async(t,o)=>{try{var n=e.i(631493),r=e.i(8421),a=e.i(759587),i=e.i(50503),s=e.i(666367),l=e.i(392086),u=e.i(312069),c=e.i(499349),d=e.i(3068),p=e.i(115737),m=e.i(860774),h=e.i(117578),g=e.i(724362),f=e.i(376261),y=e.i(375015),_=e.i(68356),b=e.i(687388),z=e.i(279041),v=e.i(340698),w=e.i(640911),x=e.i(53748),k=e.i(41444),I=e.i(656446),T=e.i(264079),S=e.i(150171),j=t([v,I,S]);[v,I,S]=j.then?(await j)():j;let B=/context[ _-]?(length|window)|maximum context|prompt is too long|too many (input )?tokens|input token count|exceeds? the (maximum|model'?s?) (context|input|prompt|number of tokens)|maximum prompt length|request (entity )?too large/i;function R(e){return C(e).some(e=>{let{statusCode:t,message:o,error:n}=e;if(void 0!==t&&400!==t&&413!==t)return!1;let r=f.APICallError.isInstance(e)?e.responseBody:null;return[o,n,r].some(e=>"string"==typeof e&&B.test(e))})}let V=new Set([408,409,429]);function C(e){let t=[],o=[e];for(;o.length&&t.length<12;){let e=o.shift();!("object"!=typeof e||null===e||t.includes(e))&&(t.push(e),_.RetryError.isInstance(e)&&o.push(...e.errors),"cause"in e&&o.push(e.cause))}return t}let J=(e,t)=>({ref:e,model:t,searchTools:null}),G={};function O(e){if(null==e||""===e)return null;let t=Number(e);return Number.isFinite(t)?Math.round(1e6*t*1e4)/1e4:null}async function E(e){let t=G[e];if(t&&Date.now()-t.at<b.CATALOG_MS)return t.models;let o=("openrouter"===e?await (0,S.fetchOpenRouterCatalog)():await A()).sort((e,t)=>e.id.localeCompare(t.id));return G[e]={at:Date.now(),models:o},o}async function A(){let e=await fetch("https://ai-gateway.vercel.sh/v1/models",{headers:{accept:"application/json"}}).catch(e=>{w.logger.warn({cause:e},"gateway catalog unreachable"),(0,x.publicError)("Could not reach the gateway")});return e.ok||(0,x.publicError)(`The gateway answered ${e.status}`),((await e.json()).data??[]).filter(e=>!!e.id).map(e=>{let t,o;return{id:e.id,label:e.name||e.id,owner:e.owned_by||e.id.slice(0,e.id.indexOf("/")),type:e.type??null,tags:e.tags??[],price:function(e){let t=e.pricing??{},o=O(t.input),n=O(t.output);if((e.tags??[]).includes("free")||0===o)return{in:0,out:0,note:null,free:!0};let r=t.transcription_duration_cost_per_second??t.realtime_session_duration_cost_per_second;if(r)return{in:null,out:null,note:`$${r}/s`,free:!1};if(t.speech_input_character_cost)return{in:null,out:null,note:"per character",free:!1};let a=Array.isArray(t.video_duration_pricing)?t.video_duration_pricing[0]:null;if(a?.cost_per_second)return{in:null,out:null,note:`$${a.cost_per_second}/s ${a.resolution??""}`.trimEnd(),free:!1};let i=t.image?`$${t.image}/image`:t.image_dimension_quality_pricing?"per image, by size":null;return null===o&&null===n?{in:null,out:null,note:i,free:!1}:{in:o,out:n,note:t.input_tiers?"tiered":t.varies_by_provider?"varies":i&&"+ per image",free:!1}}(e),retiring:!!e.deprecated_at,contextWindow:"number"==typeof e.context_window&&e.context_window>0?e.context_window:null,efforts:(t=(e.reasoning_options??[]).find(e=>e?.type==="effort"),(o=T.EFFORTS.filter(e=>t?.values?.includes(e))).length?o:null)}})}async function M(e){return"openrouter"===e?(0,S.readOpenRouterCredits)():$()}async function $(){let e=await (0,v.readConfig)(T.TEXT_MODEL_PROVIDERS["vercel-ai-gateway"].apiKeyName);if(!e)return null;let t=await fetch("https://ai-gateway.vercel.sh/v1/credits",{headers:{accept:"application/json",authorization:`Bearer ${e}`}}).catch(e=>{w.logger.warn({cause:e},"gateway credits unreachable"),(0,x.publicError)("Could not reach the gateway")}),o=await t.json().catch(()=>null),n=(0,k.clip)(o?.error?.message??"",300);if(401===t.status||403===t.status)return{refused:n||`The gateway answered ${t.status}`};t.ok||(0,x.publicError)(`The gateway answered ${t.status}${n?`: ${n}`:""}`);let r=Number(o?.balance);return o?.balance&&Number.isFinite(r)||(0,x.publicError)("The gateway did not say what is left"),{balance:r,low:r<=b.KEY_LOW_CREDIT}}async function q(e,t){if(t&&t>0)return t;let o=await U(e);return(0,T.compactAtFor)((0,T.contextWindowOf)(e.provider,e.model,o))}async function U(e){return(0,T.isCatalogProvider)(e.provider)?await E(e.provider).catch(()=>[]):[]}async function N(e,t){let o=t??T.effortSchema.safeParse(await (0,v.readConfig)(z.DEFAULT_EFFORT_KEY)).data;if(!o)return;let n=await U(e);return(0,T.effortsOf)(e.provider,e.model,n)?.includes(o)?o:void 0}async function P(e){return await E(e).then(e=>new Set(e.map(e=>e.id))).catch(()=>null)}async function L(e,t){if(!(0,T.isCatalogProvider)(e))return t;let o=await P(e);if(!o)return t;let n=t.filter(e=>o.has(e.id));return n.length>0?n:t}async function D(e){let{label:t,apiKeyName:o,signIn:f}=T.TEXT_MODEL_PROVIDERS[e.provider],b=await (0,v.readConfig)(o);return b||(0,x.publicError)(await (0,v.missingKeyWords)(o,f?`${t} is not signed in — sign in from Settings › API keys.`:`No ${t} key — add one in Settings › API keys.`)),function(e,t){switch(e.provider){case"openai":{let o=(0,p.createOpenAI)({apiKey:t});return{ref:e,model:o(e.model),searchTools:{search:o.tools.webSearch()}}}case"chatgpt":return{ref:e,model:(0,I.chatGptModel)(e.model),searchTools:{search:(0,I.chatGptSearch)()}};case"anthropic":{let o=(0,n.createAnthropic)({apiKey:t});return{ref:e,model:o(e.model),searchTools:{search:o.tools.webSearch_20260209()}}}case"google":{let o=(0,u.createGoogleGenerativeAI)({apiKey:t});return{ref:e,model:o(e.model),searchTools:{search:o.tools.googleSearch({})}}}case"xai":{let o=(0,h.createXai)({apiKey:t});return{ref:e,model:o(e.model),searchTools:{search:o.tools.webSearch()}}}case"mistral":return J(e,(0,d.createMistral)({apiKey:t})(e.model));case"deepseek":return J(e,(0,s.createDeepSeek)({apiKey:t})(e.model));case"groq":return J(e,(0,c.createGroq)({apiKey:t})(e.model));case"cerebras":return J(e,(0,r.createCerebras)({apiKey:t})(e.model));case"togetherai":return J(e,(0,m.createTogetherAI)({apiKey:t})(e.model));case"fireworks":return J(e,(0,l.createFireworks)({apiKey:t})(e.model));case"deepinfra":return J(e,(0,i.createDeepInfra)({apiKey:t})(e.model));case"cohere":return J(e,(0,a.createCohere)({apiKey:t})(e.model));case"vercel-ai-gateway":{let o=(0,y.createGateway)({apiKey:t});return{ref:e,model:o(e.model),searchTools:null}}case"openrouter":{var o;let n=(0,g.createOpenRouter)({apiKey:t});return{ref:e,model:(o=n(e.model),(0,_.wrapLanguageModel)({model:o,middleware:{specificationVersion:"v4",transformParams:async({params:e})=>e.reasoning&&"provider-default"!==e.reasoning?{...e,providerOptions:{...e.providerOptions,openrouter:{...e.providerOptions?.openrouter,reasoning:{effort:e.reasoning}}}}:e}})),searchTools:{search:n.tools.webSearch({})}}}default:(0,x.publicError)(`Not supported provider: ${String(e.provider)}`)}}(e,b)}async function F(e,{quiet:t=!1}={}){let o=async e=>(0,T.defaultModelOf)({defaultTier:"chatgpt"===e.id&&await (0,I.readChatGptPlan)()==="free"?"small":e.defaultTier,suggestModels:await L(e.id,e.suggestModels)}),n=e?T.TEXT_MODEL_PROVIDER_LIST.find(t=>t.id===e):void 0,r=["chatgpt","openai","xai"].map(e=>({...T.TEXT_MODEL_PROVIDERS[e],id:e}));if(n){let e=await o(n);if(e)return{provider:n.id,model:e}}let a=(0,T.parseTextModel)(await (0,v.readConfig)(z.DEFAULT_MODEL_KEY)??void 0);if(a){let{label:e,apiKeyName:t,signIn:o}=T.TEXT_MODEL_PROVIDERS[a.provider];if(await (0,v.readConfig)(t))return a;(0,x.publicError)(await (0,v.missingKeyWords)(t,o?`The default model is ${a.model} on ${e}, which is signed out — sign in again, or pick another in Settings › Models.`:`The default model is ${a.model}, and there is no ${e} key any more — add it in Settings › API keys, or pick another in Settings › Models.`))}for(let e of[...r,...T.TEXT_MODEL_PROVIDER_LIST]){if(!await (0,v.readConfig)(e.apiKeyName))continue;let n=await o(e);if(n)return t||w.logger.info(`no model set, falling back to ${e.id}/${n}`),{provider:e.id,model:n}}(0,x.publicError)("No model key is set — add one in Settings › API keys.")}async function H(e){let t=(0,T.parseMediaModel)(await (0,v.readConfig)(z.MEDIA_MODEL_KEYS[e]));if(!t){let t=await (0,v.readConfig)(T.MEDIA_MODEL_PROVIDERS.chatgpt.apiKeyName),o=t?(0,T.planMediaOf)(e,{plan:await (0,I.readChatGptPlan)()}):null;return o&&t?{ref:o,apiKey:t}:null}if(!(0,T.canMakeKind)(t.provider,e))return null;let o=await (0,v.readConfig)(T.MEDIA_MODEL_PROVIDERS[t.provider].apiKeyName);return o?{ref:t,apiKey:o}:null}e.s(["buildImageModel",0,function(e,t){switch(e.provider){case"openai":return(0,p.createOpenAI)({apiKey:t}).image(e.model);case"chatgpt":return(0,I.chatGptImageModel)(e.model);case"google":return(0,u.createGoogleGenerativeAI)({apiKey:t}).image(e.model);case"xai":return(0,h.createXai)({apiKey:t}).image(e.model);case"vercel-ai-gateway":return(0,y.createGateway)({apiKey:t}).image(e.model);default:(0,x.publicError)(`Not supported image provider: ${String(e.provider)}`)}},"buildSpeechModel",0,function(e,t){switch(e.provider){case"openai":return(0,p.createOpenAI)({apiKey:t}).speech(e.model);case"google":return(0,u.createGoogleGenerativeAI)({apiKey:t}).speech(e.model);case"xai":return(0,h.createXai)({apiKey:t}).speech();case"vercel-ai-gateway":return(0,y.createGateway)({apiKey:t}).speech(e.model);default:(0,x.publicError)(`Not supported speech provider: ${String(e.provider)}`)}},"buildTranscriptionModel",0,function(e,t){switch(e.provider){case"openai":return(0,p.createOpenAI)({apiKey:t}).transcription(e.model);case"google":return(0,u.createGoogleGenerativeAI)({apiKey:t}).transcription(e.model);case"xai":return(0,h.createXai)({apiKey:t}).transcription();case"vercel-ai-gateway":return(0,y.createGateway)({apiKey:t}).transcription(e.model);default:(0,x.publicError)(`Not supported transcription provider: ${String(e.provider)}`)}},"buildVideoModel",0,function(e,t){switch(e.provider){case"google":return(0,u.createGoogleGenerativeAI)({apiKey:t}).video(e.model);case"xai":return(0,h.createXai)({apiKey:t}).video(e.model);case"vercel-ai-gateway":return(0,y.createGateway)({apiKey:t}).video(e.model);default:(0,x.publicError)(`${e.provider} has no video model`)}},"compactBudget",0,q,"getTextModel",0,D,"isContextOverflow",0,R,"isPlanSpent",0,function(e){return C(e).some(e=>{if(!f.APICallError.isInstance(e)||402!==e.statusCode)return!1;try{let{code:t}=JSON.parse(e.responseBody??"").error??{};return"string"==typeof t&&I.PLAN_SPENT_CODE.test(t)}catch{return!1}})},"isProviderRefusal",0,function(e){return!R(e)&&C(e).some(e=>{let{statusCode:t}=e;return"number"==typeof t&&t>=400&&t<500&&!V.has(t)})},"modelErrorToString",0,function(e){if(!f.APICallError.isInstance(e))return(0,k.errorToString)(e);let t=e.statusCode?`(${e.statusCode})`:"",o=e.responseBody?.trim(),n=o&&!(e.message&&o.includes(e.message))?(0,k.clip)(o,300):"";return[e.message,t,n].filter(Boolean).join(" ")},"promptCacheOptions",0,function(e,t){switch(e.provider){case"openai":case"chatgpt":return t?{openai:{promptCacheKey:t}}:{};case"anthropic":return{anthropic:{cacheControl:{type:"ephemeral"}}};case"vercel-ai-gateway":return{gateway:{caching:"auto"}};case"openrouter":return"anthropic"===(0,S.vendorOf)(e.model)?{openrouter:{cacheControl:{type:"ephemeral"}}}:{};default:return{}}},"readCatalog",0,E,"readKeyCredits",0,M,"resolveDefaultModel",0,F,"resolveMediaRef",0,H,"runEffort",0,N,"seesToolImages",0,function(e){let t="vercel-ai-gateway"===e.provider?T.VENDOR_PROVIDERS[e.model.split("/")[0]]:"openrouter"===e.provider?T.VENDOR_PROVIDERS[(0,S.vendorOf)(e.model)]:e.provider;return void 0!==t&&["openai","chatgpt","anthropic","google","xai"].includes(t)}]),o()}catch(e){o(e)}},!1),631493,e=>{"use strict";var t=e.i(376261),o=e.i(847841),n=e.i(546888),r=e.i(469719),a=e.i(110567),i=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({type:r.z.literal("error"),error:r.z.object({type:r.z.string(),message:r.z.string()})}))),s=(0,o.createJsonErrorResponseHandler)({errorSchema:i,errorToMessage:e=>e.error.message}),l=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({id:r.z.string(),type:r.z.literal("file"),filename:r.z.string(),mime_type:r.z.string(),size_bytes:r.z.number(),created_at:r.z.string(),downloadable:r.z.boolean().nullish()}))),u=class{constructor(e){this.config=e,this.specificationVersion="v4"}get provider(){return this.config.provider}async uploadFile({data:e,mediaType:t,filename:n,abortSignal:r,headers:a}){let i=new Blob([(0,o.convertInlineFileDataToUint8Array)(e)],{type:t}),u=new FormData;null!=n?u.append("file",i,n):u.append("file",i);let{value:c}=await (0,o.postFormDataToApi)({url:`${this.config.baseURL}/files`,headers:(0,o.combineHeaders)(this.config.headers(),{"anthropic-beta":"files-api-2025-04-14"},a),formData:u,failedResponseHandler:s,successfulResponseHandler:(0,o.createJsonResponseHandler)(l),abortSignal:r,fetch:this.config.fetch});return{warnings:[],providerReference:{anthropic:c.id},mediaType:c.mime_type??t,filename:c.filename??n,providerMetadata:{anthropic:{filename:c.filename,mimeType:c.mime_type,sizeBytes:c.size_bytes,createdAt:c.created_at,...null!=c.downloadable?{downloadable:c.downloadable}:{}}}}}},c=r.z.object({type:r.z.string(),category:r.z.string().nullish(),explanation:r.z.string().nullish(),recommended_model:r.z.string().nullish()}),d=r.z.object({type:r.z.string(),status:r.z.object({type:r.z.string(),tool_uses:r.z.record(r.z.string(),r.z.object({type:r.z.string(),outcome:r.z.string().nullish(),explanation:r.z.string().nullish()})).nullish()})}),p=r.z.union([r.z.object({type:r.z.literal("code_execution_20250825"),tool_id:r.z.string()}),r.z.object({type:r.z.literal("code_execution_20260120"),tool_id:r.z.string()}),r.z.object({type:r.z.literal("direct")})]),m=r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("web_search_result_location"),cited_text:r.z.string(),url:r.z.string(),title:r.z.string().nullable(),encrypted_index:r.z.string()}),r.z.object({type:r.z.literal("page_location"),cited_text:r.z.string(),document_index:r.z.number(),document_title:r.z.string().nullable(),start_page_number:r.z.number(),end_page_number:r.z.number(),file_id:r.z.string().nullish()}),r.z.object({type:r.z.literal("char_location"),cited_text:r.z.string(),document_index:r.z.number(),document_title:r.z.string().nullable(),start_char_index:r.z.number(),end_char_index:r.z.number(),file_id:r.z.string().nullish()}),r.z.object({type:r.z.literal("content_block_location"),cited_text:r.z.string(),document_index:r.z.number(),document_title:r.z.string().nullable(),start_block_index:r.z.number(),end_block_index:r.z.number(),file_id:r.z.string().nullable()}),r.z.object({type:r.z.literal("search_result_location"),cited_text:r.z.string(),search_result_index:r.z.number(),source:r.z.string(),title:r.z.string().nullable(),start_block_index:r.z.number(),end_block_index:r.z.number()})]),h=r.z.union([r.z.string(),r.z.array(r.z.union([r.z.string(),r.z.object({type:r.z.literal("text"),text:r.z.string(),citations:r.z.array(r.z.json()).nullable().optional()})]))]),g=r.z.object({type:r.z.string(),path:r.z.string(),reason:r.z.string()}),f=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({type:r.z.literal("message"),id:r.z.string().nullish(),model:r.z.string().nullish(),content:r.z.array(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("text"),text:r.z.string(),citations:r.z.array(m).nullable().optional()}),r.z.object({type:r.z.literal("thinking"),thinking:r.z.string(),signature:r.z.string()}),r.z.object({type:r.z.literal("redacted_thinking"),data:r.z.string()}),r.z.object({type:r.z.literal("compaction"),content:r.z.string().nullish(),signature:r.z.string().nullish()}),r.z.object({type:r.z.literal("tool_use"),id:r.z.string(),name:r.z.string(),input:r.z.unknown(),caller:p.optional(),toolset_name:r.z.string().nullish()}),r.z.object({type:r.z.literal("server_tool_use"),id:r.z.string(),name:r.z.string(),input:r.z.record(r.z.string(),r.z.unknown()).nullish(),caller:p.optional()}),r.z.object({type:r.z.literal("mcp_tool_use"),id:r.z.string(),name:r.z.string(),input:r.z.unknown(),server_name:r.z.string()}),r.z.object({type:r.z.literal("mcp_tool_result"),tool_use_id:r.z.string(),is_error:r.z.boolean(),content:h}),r.z.object({type:r.z.literal("web_fetch_tool_result"),tool_use_id:r.z.string(),caller:p.optional(),content:r.z.union([r.z.object({type:r.z.literal("web_fetch_result"),url:r.z.string(),retrieved_at:r.z.string().nullable(),content:r.z.object({type:r.z.literal("document"),title:r.z.string().nullable(),citations:r.z.object({enabled:r.z.boolean()}).optional(),source:r.z.union([r.z.object({type:r.z.literal("base64"),media_type:r.z.literal("application/pdf"),data:r.z.string()}),r.z.object({type:r.z.literal("text"),media_type:r.z.literal("text/plain"),data:r.z.string()})])})}),r.z.object({type:r.z.literal("web_fetch_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("web_search_tool_result"),tool_use_id:r.z.string(),caller:p.optional(),content:r.z.union([r.z.array(r.z.object({type:r.z.literal("web_search_result"),url:r.z.string(),title:r.z.string().nullable(),encrypted_content:r.z.string(),page_age:r.z.string().nullish()})),r.z.object({type:r.z.literal("web_search_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("code_execution_tool_result"),tool_use_id:r.z.string(),content:r.z.union([r.z.object({type:r.z.literal("code_execution_result"),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number(),content:r.z.array(r.z.object({type:r.z.literal("code_execution_output"),file_id:r.z.string()})).optional().default([])}),r.z.object({type:r.z.literal("encrypted_code_execution_result"),encrypted_stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number(),content:r.z.array(r.z.object({type:r.z.literal("code_execution_output"),file_id:r.z.string()})).optional().default([])}),r.z.object({type:r.z.literal("code_execution_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("bash_code_execution_tool_result"),tool_use_id:r.z.string(),content:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("bash_code_execution_result"),content:r.z.array(r.z.object({type:r.z.literal("bash_code_execution_output"),file_id:r.z.string()})),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number()}),r.z.object({type:r.z.literal("bash_code_execution_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("text_editor_code_execution_tool_result"),tool_use_id:r.z.string(),content:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("text_editor_code_execution_tool_result_error"),error_code:r.z.string()}),r.z.object({type:r.z.literal("text_editor_code_execution_view_result"),content:r.z.string(),file_type:r.z.string(),num_lines:r.z.number().nullable(),start_line:r.z.number().nullable(),total_lines:r.z.number().nullable()}),r.z.object({type:r.z.literal("text_editor_code_execution_create_result"),is_file_update:r.z.boolean()}),r.z.object({type:r.z.literal("text_editor_code_execution_str_replace_result"),lines:r.z.array(r.z.string()).nullable(),new_lines:r.z.number().nullable(),new_start:r.z.number().nullable(),old_lines:r.z.number().nullable(),old_start:r.z.number().nullable()})])}),r.z.object({type:r.z.literal("tool_search_tool_result"),tool_use_id:r.z.string(),content:r.z.union([r.z.object({type:r.z.literal("tool_search_tool_search_result"),tool_references:r.z.array(r.z.object({type:r.z.literal("tool_reference"),tool_name:r.z.string()}))}),r.z.object({type:r.z.literal("tool_search_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("container_upload"),file_id:r.z.string()}),r.z.object({type:r.z.literal("advisor_tool_result"),tool_use_id:r.z.string(),content:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("advisor_result"),text:r.z.string(),stop_reason:r.z.string().nullish()}),r.z.object({type:r.z.literal("advisor_redacted_result"),encrypted_content:r.z.string(),stop_reason:r.z.string().nullish()}),r.z.object({type:r.z.literal("advisor_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("fallback")})])),stop_reason:r.z.string().nullish(),stop_sequence:r.z.string().nullish(),stop_details:c.nullish(),input_transformations:r.z.array(g).nullish(),safeguard_results:r.z.array(d).nullish(),usage:r.z.looseObject({input_tokens:r.z.number(),output_tokens:r.z.number(),output_tokens_details:r.z.object({thinking_tokens:r.z.number().nullish()}).nullish(),cache_creation_input_tokens:r.z.number().nullish(),cache_read_input_tokens:r.z.number().nullish(),iterations:r.z.array(r.z.object({type:r.z.union([r.z.literal("compaction"),r.z.literal("message"),r.z.literal("advisor_message"),r.z.literal("fallback_message")]),model:r.z.string().nullish(),input_tokens:r.z.number(),output_tokens:r.z.number(),cache_creation_input_tokens:r.z.number().nullish(),cache_read_input_tokens:r.z.number().nullish()})).nullish()}),container:r.z.object({expires_at:r.z.string(),id:r.z.string(),skills:r.z.array(r.z.object({type:r.z.union([r.z.literal("anthropic"),r.z.literal("custom")]),skill_id:r.z.string(),version:r.z.string()})).nullish()}).nullish(),context_management:r.z.object({applied_edits:r.z.array(r.z.union([r.z.object({type:r.z.literal("clear_tool_uses_20250919"),cleared_tool_uses:r.z.number(),cleared_input_tokens:r.z.number()}),r.z.object({type:r.z.literal("clear_thinking_20251015"),cleared_thinking_turns:r.z.number(),cleared_input_tokens:r.z.number()}),r.z.object({type:r.z.literal("compact_20260112")})]))}).nullish()}))),y=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("message_start"),message:r.z.object({id:r.z.string().nullish(),model:r.z.string().nullish(),role:r.z.string().nullish(),usage:r.z.looseObject({input_tokens:r.z.number(),cache_creation_input_tokens:r.z.number().nullish(),cache_read_input_tokens:r.z.number().nullish()}),content:r.z.array(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("tool_use"),id:r.z.string(),name:r.z.string(),input:r.z.unknown(),caller:p.optional(),toolset_name:r.z.string().nullish()})])).nullish(),stop_reason:r.z.string().nullish(),input_transformations:r.z.array(g).nullish(),container:r.z.object({expires_at:r.z.string(),id:r.z.string()}).nullish()})}),r.z.object({type:r.z.literal("content_block_start"),index:r.z.number(),content_block:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("text"),text:r.z.string()}),r.z.object({type:r.z.literal("thinking"),thinking:r.z.string()}),r.z.object({type:r.z.literal("tool_use"),id:r.z.string(),name:r.z.string(),input:r.z.record(r.z.string(),r.z.unknown()).optional(),caller:p.optional(),toolset_name:r.z.string().nullish()}),r.z.object({type:r.z.literal("redacted_thinking"),data:r.z.string()}),r.z.object({type:r.z.literal("compaction"),content:r.z.string().nullish(),signature:r.z.string().nullish()}),r.z.object({type:r.z.literal("server_tool_use"),id:r.z.string(),name:r.z.string(),input:r.z.record(r.z.string(),r.z.unknown()).nullish(),caller:p.optional()}),r.z.object({type:r.z.literal("mcp_tool_use"),id:r.z.string(),name:r.z.string(),input:r.z.unknown(),server_name:r.z.string()}),r.z.object({type:r.z.literal("mcp_tool_result"),tool_use_id:r.z.string(),is_error:r.z.boolean(),content:h}),r.z.object({type:r.z.literal("web_fetch_tool_result"),tool_use_id:r.z.string(),caller:p.optional(),content:r.z.union([r.z.object({type:r.z.literal("web_fetch_result"),url:r.z.string(),retrieved_at:r.z.string().nullable(),content:r.z.object({type:r.z.literal("document"),title:r.z.string().nullable(),citations:r.z.object({enabled:r.z.boolean()}).optional(),source:r.z.union([r.z.object({type:r.z.literal("base64"),media_type:r.z.literal("application/pdf"),data:r.z.string()}),r.z.object({type:r.z.literal("text"),media_type:r.z.literal("text/plain"),data:r.z.string()})])})}),r.z.object({type:r.z.literal("web_fetch_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("web_search_tool_result"),tool_use_id:r.z.string(),caller:p.optional(),content:r.z.union([r.z.array(r.z.object({type:r.z.literal("web_search_result"),url:r.z.string(),title:r.z.string().nullable(),encrypted_content:r.z.string(),page_age:r.z.string().nullish()})),r.z.object({type:r.z.literal("web_search_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("code_execution_tool_result"),tool_use_id:r.z.string(),content:r.z.union([r.z.object({type:r.z.literal("code_execution_result"),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number(),content:r.z.array(r.z.object({type:r.z.literal("code_execution_output"),file_id:r.z.string()})).optional().default([])}),r.z.object({type:r.z.literal("encrypted_code_execution_result"),encrypted_stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number(),content:r.z.array(r.z.object({type:r.z.literal("code_execution_output"),file_id:r.z.string()})).optional().default([])}),r.z.object({type:r.z.literal("code_execution_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("bash_code_execution_tool_result"),tool_use_id:r.z.string(),content:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("bash_code_execution_result"),content:r.z.array(r.z.object({type:r.z.literal("bash_code_execution_output"),file_id:r.z.string()})),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number()}),r.z.object({type:r.z.literal("bash_code_execution_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("text_editor_code_execution_tool_result"),tool_use_id:r.z.string(),content:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("text_editor_code_execution_tool_result_error"),error_code:r.z.string()}),r.z.object({type:r.z.literal("text_editor_code_execution_view_result"),content:r.z.string(),file_type:r.z.string(),num_lines:r.z.number().nullable(),start_line:r.z.number().nullable(),total_lines:r.z.number().nullable()}),r.z.object({type:r.z.literal("text_editor_code_execution_create_result"),is_file_update:r.z.boolean()}),r.z.object({type:r.z.literal("text_editor_code_execution_str_replace_result"),lines:r.z.array(r.z.string()).nullable(),new_lines:r.z.number().nullable(),new_start:r.z.number().nullable(),old_lines:r.z.number().nullable(),old_start:r.z.number().nullable()})])}),r.z.object({type:r.z.literal("tool_search_tool_result"),tool_use_id:r.z.string(),content:r.z.union([r.z.object({type:r.z.literal("tool_search_tool_search_result"),tool_references:r.z.array(r.z.object({type:r.z.literal("tool_reference"),tool_name:r.z.string()}))}),r.z.object({type:r.z.literal("tool_search_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("advisor_tool_result"),tool_use_id:r.z.string(),content:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("advisor_result"),text:r.z.string(),stop_reason:r.z.string().nullish()}),r.z.object({type:r.z.literal("advisor_redacted_result"),encrypted_content:r.z.string(),stop_reason:r.z.string().nullish()}),r.z.object({type:r.z.literal("advisor_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("fallback")})])}),r.z.object({type:r.z.literal("content_block_delta"),index:r.z.number(),delta:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("input_json_delta"),partial_json:r.z.string()}),r.z.object({type:r.z.literal("text_delta"),text:r.z.string()}),r.z.object({type:r.z.literal("thinking_delta"),thinking:r.z.string()}),r.z.object({type:r.z.literal("signature_delta"),signature:r.z.string()}),r.z.object({type:r.z.literal("compaction_delta"),content:r.z.string().nullish()}),r.z.object({type:r.z.literal("citations_delta"),citation:m})])}),r.z.object({type:r.z.literal("content_block_stop"),index:r.z.number()}),r.z.object({type:r.z.literal("error"),error:r.z.object({type:r.z.string(),message:r.z.string(),code:r.z.union([r.z.string(),r.z.number()]).nullish(),statusCode:r.z.number().nullish(),isRetryable:r.z.boolean().nullish(),data:r.z.unknown().nullish()})}),r.z.object({type:r.z.literal("message_delta"),delta:r.z.object({stop_reason:r.z.string().nullish(),stop_sequence:r.z.string().nullish(),stop_details:c.nullish(),safeguard_results:r.z.array(d).nullish(),container:r.z.object({expires_at:r.z.string(),id:r.z.string(),skills:r.z.array(r.z.object({type:r.z.union([r.z.literal("anthropic"),r.z.literal("custom")]),skill_id:r.z.string(),version:r.z.string()})).nullish()}).nullish()}),usage:r.z.looseObject({input_tokens:r.z.number().nullish(),output_tokens:r.z.number(),output_tokens_details:r.z.object({thinking_tokens:r.z.number().nullish()}).nullish(),cache_creation_input_tokens:r.z.number().nullish(),cache_read_input_tokens:r.z.number().nullish(),iterations:r.z.array(r.z.object({type:r.z.union([r.z.literal("compaction"),r.z.literal("message"),r.z.literal("advisor_message"),r.z.literal("fallback_message")]),model:r.z.string().nullish(),input_tokens:r.z.number(),output_tokens:r.z.number(),cache_creation_input_tokens:r.z.number().nullish(),cache_read_input_tokens:r.z.number().nullish()})).nullish()}),input_transformations:r.z.array(g).nullish(),context_management:r.z.object({applied_edits:r.z.array(r.z.union([r.z.object({type:r.z.literal("clear_tool_uses_20250919"),cleared_tool_uses:r.z.number(),cleared_input_tokens:r.z.number()}),r.z.object({type:r.z.literal("clear_thinking_20251015"),cleared_thinking_turns:r.z.number(),cleared_input_tokens:r.z.number()}),r.z.object({type:r.z.literal("compact_20260112")})]))}).nullish()}),r.z.object({type:r.z.literal("message_stop")}),r.z.object({type:r.z.literal("ping")})]))),_=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({signature:r.z.string().optional(),redactedData:r.z.string().optional()}))),b=r.z.object({containerUpload:r.z.boolean().optional(),citations:r.z.object({enabled:r.z.boolean()}).optional(),title:r.z.string().optional(),context:r.z.string().optional()}),z=r.z.object({clearAt:r.z.literal("next_user_message").optional(),effort:r.z.enum(["low","medium","high","xhigh","max"]).optional(),toolChanges:r.z.array(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("tool_addition"),toolName:r.z.string()}),r.z.object({type:r.z.literal("tool_removal"),toolName:r.z.string()})])).optional()}),v=r.z.object({sendReasoning:r.z.boolean().optional(),structuredOutputMode:r.z.enum(["outputFormat","jsonTool","auto"]).optional(),thinking:r.z.union([r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("adaptive"),display:r.z.enum(["omitted","summarized","updates"]).optional(),blockBinding:r.z.object({prefixMismatchBehavior:r.z.enum(["error","drop_block"])}).optional()}),r.z.object({type:r.z.literal("enabled"),budgetTokens:r.z.number().optional()}),r.z.object({type:r.z.literal("disabled")})]),r.z.object({type:r.z.never().optional(),blockBinding:r.z.object({prefixMismatchBehavior:r.z.enum(["error","drop_block"])})})]).optional(),disableParallelToolUse:r.z.boolean().optional(),cacheControl:r.z.object({type:r.z.literal("ephemeral"),ttl:r.z.union([r.z.literal("5m"),r.z.literal("1h")]).optional()}).optional(),metadata:r.z.object({userId:r.z.string().optional()}).optional(),mcpServers:r.z.array(r.z.object({type:r.z.literal("url"),name:r.z.string(),url:r.z.string(),authorizationToken:r.z.string().nullish(),toolConfiguration:r.z.object({enabled:r.z.boolean().nullish(),allowedTools:r.z.array(r.z.string()).nullish()}).nullish()})).optional(),container:r.z.object({id:r.z.string().optional(),skills:r.z.array(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("anthropic"),skillId:r.z.string(),version:r.z.string().optional()}),r.z.object({type:r.z.literal("custom"),providerReference:r.z.record(r.z.string(),r.z.string()),version:r.z.string().optional()})])).optional()}).optional(),toolStreaming:r.z.boolean().optional(),effort:r.z.enum(["low","medium","high","xhigh","max"]).optional(),taskBudget:r.z.object({type:r.z.literal("tokens"),total:r.z.number().int().min(2e4),remaining:r.z.number().int().min(0).optional()}).optional(),speed:r.z.enum(["fast","standard"]).optional(),serviceTier:r.z.enum(["auto","standard_only"]).optional(),inferenceGeo:r.z.enum(["us","global"]).optional(),fallbacks:r.z.union([r.z.literal("default"),r.z.array(r.z.object({model:r.z.string(),max_tokens:r.z.number().int().optional(),thinking:r.z.record(r.z.string(),r.z.unknown()).optional(),output_config:r.z.record(r.z.string(),r.z.unknown()).optional(),speed:r.z.enum(["fast","standard"]).optional()}))]).optional(),anthropicBeta:r.z.array(r.z.string()).optional(),safeguards:r.z.array(r.z.object({type:r.z.literal("dangerous_tool_use"),classifierContext:r.z.record(r.z.string(),r.z.unknown()).optional()})).optional(),compaction:r.z.object({type:r.z.literal("summarize"),instructions:r.z.string().optional()}).optional(),contextManagement:r.z.object({edits:r.z.array(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("clear_tool_uses_20250919"),trigger:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("input_tokens"),value:r.z.number()}),r.z.object({type:r.z.literal("tool_uses"),value:r.z.number()})]).optional(),keep:r.z.object({type:r.z.literal("tool_uses"),value:r.z.number()}).optional(),clearAtLeast:r.z.object({type:r.z.literal("input_tokens"),value:r.z.number()}).optional(),clearToolInputs:r.z.boolean().optional(),excludeTools:r.z.array(r.z.string()).optional()}),r.z.object({type:r.z.literal("clear_thinking_20251015"),keep:r.z.union([r.z.literal("all"),r.z.object({type:r.z.literal("thinking_turns"),value:r.z.number()})]).optional()}),r.z.object({type:r.z.literal("compact_20260112"),trigger:r.z.object({type:r.z.literal("input_tokens"),value:r.z.number()}).optional(),pauseAfterCompaction:r.z.boolean().optional(),instructions:r.z.string().optional()})]))}).optional()}),w=class{constructor(){this.breakpointCount=0,this.warnings=[]}getCacheControl(e,t){let o,n=(o=e?.anthropic,o?.cacheControl??o?.cache_control);if(n)return t.canCache?(this.breakpointCount++,this.breakpointCount>4)?void this.warnings.push({type:"unsupported",feature:"cacheControl breakpoint limit",details:`Maximum 4 cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`}):n:void this.warnings.push({type:"unsupported",feature:"cache_control on non-cacheable context",details:`cache_control cannot be set on ${t.type}. It will be ignored.`})}getWarnings(){return this.warnings}},x=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({model:r.z.string(),maxUses:r.z.number().optional(),maxTokens:r.z.number().int().min(1024).optional(),caching:r.z.object({type:r.z.literal("ephemeral"),ttl:r.z.union([r.z.literal("5m"),r.z.literal("1h")])}).optional()}))),k=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("advisor_result"),text:r.z.string(),stopReason:r.z.string().optional()}),r.z.object({type:r.z.literal("advisor_redacted_result"),encryptedContent:r.z.string(),stopReason:r.z.string().optional()}),r.z.object({type:r.z.literal("advisor_tool_result_error"),errorCode:r.z.string()})]))),I=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({}).strict())),T=(0,o.createProviderExecutedToolFactory)({id:"anthropic.advisor_20260301",inputSchema:I,outputSchema:k,supportsDeferredResults:!0}),S=["screenshot","zoom","left_click","right_click","middle_click","double_click","triple_click","left_click_drag","mouse_move","left_mouse_down","left_mouse_up","cursor_position","scroll","type","key","hold_key","wait"],j=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({action:r.z.enum(S),coordinate:r.z.tuple([r.z.number().int(),r.z.number().int()]).optional(),duration:r.z.number().optional(),region:r.z.tuple([r.z.number().int(),r.z.number().int(),r.z.number().int(),r.z.number().int()]).optional(),repeat:r.z.number().int().optional(),scroll_amount:r.z.number().optional(),scroll_direction:r.z.enum(["up","down","left","right"]).optional(),start_coordinate:r.z.tuple([r.z.number().int(),r.z.number().int()]).optional(),text:r.z.string().optional()}))),R=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({configs:r.z.partialRecord(r.z.enum(S),r.z.object({enabled:r.z.boolean().optional(),deferLoading:r.z.boolean().optional()})).optional()}))),C=(0,o.createProviderDefinedToolFactory)({id:"anthropic.computer_toolset_20260801",inputSchema:j}),O=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({maxCharacters:r.z.number().optional()}))),E=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({command:r.z.enum(["view","create","str_replace","insert"]),path:r.z.string(),file_text:r.z.string().optional(),insert_line:r.z.number().int().optional(),new_str:r.z.string().optional(),insert_text:r.z.string().optional(),old_str:r.z.string().optional(),view_range:r.z.array(r.z.number().int()).optional()}))),A=(0,o.createProviderDefinedToolFactory)({id:"anthropic.text_editor_20250728",inputSchema:E}),M=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({maxUses:r.z.number().optional(),allowedDomains:r.z.array(r.z.string()).optional(),blockedDomains:r.z.array(r.z.string()).optional(),userLocation:r.z.object({type:r.z.literal("approximate"),city:r.z.string().optional(),region:r.z.string().optional(),country:r.z.string().optional(),timezone:r.z.string().optional()}).optional(),responseInclusion:r.z.enum(["full","excluded"]).optional()}))),$=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.array(r.z.object({url:r.z.string(),title:r.z.string().nullable(),pageAge:r.z.string().nullable(),encryptedContent:r.z.string(),type:r.z.literal("web_search_result")})))),q=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({query:r.z.string()}))),U=(0,o.createProviderExecutedToolFactory)({id:"anthropic.web_search_20260318",inputSchema:q,outputSchema:$,supportsDeferredResults:!0}),N=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({maxUses:r.z.number().optional(),allowedDomains:r.z.array(r.z.string()).optional(),blockedDomains:r.z.array(r.z.string()).optional(),userLocation:r.z.object({type:r.z.literal("approximate"),city:r.z.string().optional(),region:r.z.string().optional(),country:r.z.string().optional(),timezone:r.z.string().optional()}).optional()}))),P=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.array(r.z.object({url:r.z.string(),title:r.z.string().nullable(),pageAge:r.z.string().nullable(),encryptedContent:r.z.string(),type:r.z.literal("web_search_result")})))),L=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({query:r.z.string()}))),D=(0,o.createProviderExecutedToolFactory)({id:"anthropic.web_search_20260209",inputSchema:L,outputSchema:P,supportsDeferredResults:!0}),F=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({maxUses:r.z.number().optional(),allowedDomains:r.z.array(r.z.string()).optional(),blockedDomains:r.z.array(r.z.string()).optional(),userLocation:r.z.object({type:r.z.literal("approximate"),city:r.z.string().optional(),region:r.z.string().optional(),country:r.z.string().optional(),timezone:r.z.string().optional()}).optional()}))),H=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.array(r.z.object({url:r.z.string(),title:r.z.string().nullable(),pageAge:r.z.string().nullable(),encryptedContent:r.z.string(),type:r.z.literal("web_search_result")})))),B=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({query:r.z.string()}))),V=(0,o.createProviderExecutedToolFactory)({id:"anthropic.web_search_20250305",inputSchema:B,outputSchema:H,supportsDeferredResults:!0}),J=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({maxUses:r.z.number().optional(),allowedDomains:r.z.array(r.z.string()).optional(),blockedDomains:r.z.array(r.z.string()).optional(),citations:r.z.object({enabled:r.z.boolean()}).optional(),maxContentTokens:r.z.number().optional(),useCache:r.z.boolean().optional(),responseInclusion:r.z.enum(["full","excluded"]).optional()}))),G=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({type:r.z.literal("web_fetch_result"),url:r.z.string(),content:r.z.object({type:r.z.literal("document"),title:r.z.string().nullable(),citations:r.z.object({enabled:r.z.boolean()}).optional(),source:r.z.union([r.z.object({type:r.z.literal("base64"),mediaType:r.z.literal("application/pdf"),data:r.z.string()}),r.z.object({type:r.z.literal("text"),mediaType:r.z.literal("text/plain"),data:r.z.string()})])}),retrievedAt:r.z.string().nullable()}))),W=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({url:r.z.string()}))),K=(0,o.createProviderExecutedToolFactory)({id:"anthropic.web_fetch_20260318",inputSchema:W,outputSchema:G,supportsDeferredResults:!0}),Z=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({maxUses:r.z.number().optional(),allowedDomains:r.z.array(r.z.string()).optional(),blockedDomains:r.z.array(r.z.string()).optional(),citations:r.z.object({enabled:r.z.boolean()}).optional(),maxContentTokens:r.z.number().optional()}))),X=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({type:r.z.literal("web_fetch_result"),url:r.z.string(),content:r.z.object({type:r.z.literal("document"),title:r.z.string().nullable(),citations:r.z.object({enabled:r.z.boolean()}).optional(),source:r.z.union([r.z.object({type:r.z.literal("base64"),mediaType:r.z.literal("application/pdf"),data:r.z.string()}),r.z.object({type:r.z.literal("text"),mediaType:r.z.literal("text/plain"),data:r.z.string()})])}),retrievedAt:r.z.string().nullable()}))),Y=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({url:r.z.string()}))),Q=(0,o.createProviderExecutedToolFactory)({id:"anthropic.web_fetch_20260209",inputSchema:Y,outputSchema:X,supportsDeferredResults:!0}),ee=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({maxUses:r.z.number().optional(),allowedDomains:r.z.array(r.z.string()).optional(),blockedDomains:r.z.array(r.z.string()).optional(),citations:r.z.object({enabled:r.z.boolean()}).optional(),maxContentTokens:r.z.number().optional()}))),et=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({type:r.z.literal("web_fetch_result"),url:r.z.string(),content:r.z.object({type:r.z.literal("document"),title:r.z.string().nullable(),citations:r.z.object({enabled:r.z.boolean()}).optional(),source:r.z.union([r.z.object({type:r.z.literal("base64"),mediaType:r.z.literal("application/pdf"),data:r.z.string()}),r.z.object({type:r.z.literal("text"),mediaType:r.z.literal("text/plain"),data:r.z.string()})])}),retrievedAt:r.z.string().nullable()}))),eo=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({url:r.z.string()}))),en=(0,o.createProviderExecutedToolFactory)({id:"anthropic.web_fetch_20250910",inputSchema:eo,outputSchema:et,supportsDeferredResults:!0});async function er({tools:e,toolChoice:n,disableParallelToolUse:r,cacheControlValidator:a,supportsStructuredOutput:i,supportsStrictTools:s,defaultEagerInputStreaming:l=!1,rejectsForcedToolUse:u=!1}){e=e?.length?e:void 0;let c=[],d=new Set,p=a||new w;if(null==e)return{tools:void 0,toolChoice:void 0,toolWarnings:c,betas:d};let m=[];for(let t of e)switch(t.type){case"function":{let e=p.getCacheControl(t.providerOptions,{type:"tool definition",canCache:!0}),o=t.providerOptions?.anthropic,n=o?.eagerInputStreaming??l,r=o?.deferLoading,a=o?.allowedCallers;s||null==t.strict||c.push({type:"unsupported",feature:"strict",details:`Tool '${t.name}' has strict: ${t.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`}),m.push({name:t.name,description:t.description,input_schema:t.inputSchema,cache_control:e,...n?{eager_input_streaming:!0}:{},...!0===s&&null!=t.strict?{strict:t.strict}:{},...null!=r?{defer_loading:r}:{},...null!=a?{allowed_callers:a}:{},...null!=t.inputExamples?{input_examples:t.inputExamples.map(e=>e.input)}:{}}),!0===i&&d.add("structured-outputs-2025-11-13"),(null!=t.inputExamples||null!=a)&&d.add("advanced-tool-use-2025-11-20");break}case"provider":switch(t.id){case"anthropic.code_execution_20250522":d.add("code-execution-2025-05-22"),m.push({type:"code_execution_20250522",name:"code_execution",cache_control:void 0});break;case"anthropic.code_execution_20250825":d.add("code-execution-2025-08-25"),m.push({type:"code_execution_20250825",name:"code_execution"});break;case"anthropic.code_execution_20260120":m.push({type:"code_execution_20260120",name:"code_execution"});break;case"anthropic.computer_20250124":d.add("computer-use-2025-01-24"),m.push({name:"computer",type:"computer_20250124",display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,cache_control:void 0});break;case"anthropic.computer_20251124":d.add("computer-use-2025-11-24"),m.push({name:"computer",type:"computer_20251124",display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,enable_zoom:t.args.enableZoom,cache_control:void 0});break;case"anthropic.computer_toolset_20260801":{let e=await (0,o.validateTypes)({value:t.args,schema:R}),n=null!=e.configs?Object.fromEntries(Object.entries(e.configs).map(([e,t])=>[e,{...t?.enabled!=null&&{enabled:t.enabled},...t?.deferLoading!=null&&{defer_loading:t.deferLoading}}])):void 0;m.push({type:"computer_toolset_20260801",...null!=n&&{configs:n},cache_control:void 0});break}case"anthropic.computer_20241022":d.add("computer-use-2024-10-22"),m.push({name:"computer",type:"computer_20241022",display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,cache_control:void 0});break;case"anthropic.text_editor_20250124":d.add("computer-use-2025-01-24"),m.push({name:"str_replace_editor",type:"text_editor_20250124",cache_control:void 0});break;case"anthropic.text_editor_20241022":d.add("computer-use-2024-10-22"),m.push({name:"str_replace_editor",type:"text_editor_20241022",cache_control:void 0});break;case"anthropic.text_editor_20250429":d.add("computer-use-2025-01-24"),m.push({name:"str_replace_based_edit_tool",type:"text_editor_20250429",cache_control:void 0});break;case"anthropic.text_editor_20250728":{let e=await (0,o.validateTypes)({value:t.args,schema:O});m.push({name:"str_replace_based_edit_tool",type:"text_editor_20250728",max_characters:e.maxCharacters,cache_control:void 0});break}case"anthropic.bash_20250124":d.add("computer-use-2025-01-24"),m.push({name:"bash",type:"bash_20250124",cache_control:void 0});break;case"anthropic.bash_20241022":d.add("computer-use-2024-10-22"),m.push({name:"bash",type:"bash_20241022",cache_control:void 0});break;case"anthropic.memory_20250818":d.add("context-management-2025-06-27"),m.push({name:"memory",type:"memory_20250818"});break;case"anthropic.web_fetch_20250910":{d.add("web-fetch-2025-09-10");let e=await (0,o.validateTypes)({value:t.args,schema:ee});m.push({type:"web_fetch_20250910",name:"web_fetch",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,cache_control:void 0});break}case"anthropic.web_fetch_20260209":{d.add("code-execution-web-tools-2026-02-09");let e=await (0,o.validateTypes)({value:t.args,schema:Z});m.push({type:"web_fetch_20260209",name:"web_fetch",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,cache_control:void 0});break}case"anthropic.web_fetch_20260318":{let e=await (0,o.validateTypes)({value:t.args,schema:J});m.push({type:"web_fetch_20260318",name:"web_fetch",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,use_cache:e.useCache,response_inclusion:e.responseInclusion,cache_control:void 0});break}case"anthropic.web_search_20250305":{let e=await (0,o.validateTypes)({value:t.args,schema:F});m.push({type:"web_search_20250305",name:"web_search",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,cache_control:void 0});break}case"anthropic.web_search_20260209":{d.add("code-execution-web-tools-2026-02-09");let e=await (0,o.validateTypes)({value:t.args,schema:N});m.push({type:"web_search_20260209",name:"web_search",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,cache_control:void 0});break}case"anthropic.web_search_20260318":{let e=await (0,o.validateTypes)({value:t.args,schema:M});m.push({type:"web_search_20260318",name:"web_search",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,response_inclusion:e.responseInclusion,cache_control:void 0});break}case"anthropic.tool_search_regex_20251119":m.push({type:"tool_search_tool_regex_20251119",name:"tool_search_tool_regex"});break;case"anthropic.tool_search_bm25_20251119":m.push({type:"tool_search_tool_bm25_20251119",name:"tool_search_tool_bm25"});break;case"anthropic.advisor_20260301":{d.add("advisor-tool-2026-03-01");let e=await (0,o.validateTypes)({value:t.args,schema:x});m.push({type:"advisor_20260301",name:"advisor",model:e.model,...void 0!==e.maxUses&&{max_uses:e.maxUses},...void 0!==e.maxTokens&&{max_tokens:e.maxTokens},...void 0!==e.caching&&{caching:e.caching}});break}default:c.push({type:"unsupported",feature:`provider-defined tool ${t.id}`})}break;default:c.push({type:"unsupported",feature:`tool ${t}`})}if(null==n)return{tools:m,toolChoice:r?{type:"auto",disable_parallel_tool_use:r}:void 0,toolWarnings:c,betas:d};let h=n.type;switch(h){case"auto":return{tools:m,toolChoice:{type:"auto",disable_parallel_tool_use:r},toolWarnings:c,betas:d};case"required":if(u)return c.push({type:"unsupported",feature:"toolChoice",details:"toolChoice 'required' is not supported by this model because it rejects forced tool use. Using 'auto' instead. Instruct the model to use a tool in the prompt and verify that a tool call was made."}),{tools:m,toolChoice:{type:"auto",disable_parallel_tool_use:r},toolWarnings:c,betas:d};return{tools:m,toolChoice:{type:"any",disable_parallel_tool_use:r},toolWarnings:c,betas:d};case"none":return{tools:void 0,toolChoice:void 0,toolWarnings:c,betas:d};case"tool":if(u)return c.push({type:"unsupported",feature:"toolChoice",details:`toolChoice 'tool' is not supported by this model because it rejects forced tool use. Only the '${n.toolName}' tool is sent with 'auto' tool choice. Instruct the model to use the tool in the prompt and verify that a tool call was made.`}),{tools:m.filter(e=>"name"in e&&e.name===n.toolName),toolChoice:{type:"auto",disable_parallel_tool_use:r},toolWarnings:c,betas:d};return{tools:m,toolChoice:{type:"tool",name:n.toolName,disable_parallel_tool_use:r},toolWarnings:c,betas:d};default:throw new t.UnsupportedFunctionalityError({functionality:`tool choice type: ${h}`})}}function ea({usage:e,rawUsage:t}){let o,n,r=e.cache_creation_input_tokens??0,a=e.cache_read_input_tokens??0,i=e.output_tokens_details?.thinking_tokens??void 0,s=e.iterations?.some(e=>"fallback_message"===e.type);if(e.iterations&&e.iterations.length>0&&!s){let t=e.iterations.filter(e=>"compaction"===e.type||"message"===e.type);if(t.length>0){let e=t.reduce((e,t)=>({input:e.input+t.input_tokens,output:e.output+t.output_tokens}),{input:0,output:0});o=e.input,n=e.output}else o=e.input_tokens,n=e.output_tokens}else o=e.input_tokens,n=e.output_tokens;return{inputTokens:{total:o+r+a,noCache:o,cacheRead:a,cacheWrite:r},outputTokens:{total:n,text:null==i?void 0:n-i,reasoning:i},raw:t??e}}var ei=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({type:r.z.literal("code_execution_result"),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number(),content:r.z.array(r.z.object({type:r.z.literal("code_execution_output"),file_id:r.z.string()})).optional().default([])}))),es=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({code:r.z.string()}))),el=(0,o.createProviderExecutedToolFactory)({id:"anthropic.code_execution_20250522",inputSchema:es,outputSchema:ei}),eu=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("code_execution_result"),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number(),content:r.z.array(r.z.object({type:r.z.literal("code_execution_output"),file_id:r.z.string()})).optional().default([])}),r.z.object({type:r.z.literal("bash_code_execution_result"),content:r.z.array(r.z.object({type:r.z.literal("bash_code_execution_output"),file_id:r.z.string()})),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number()}),r.z.object({type:r.z.literal("bash_code_execution_tool_result_error"),error_code:r.z.string()}),r.z.object({type:r.z.literal("text_editor_code_execution_tool_result_error"),error_code:r.z.string()}),r.z.object({type:r.z.literal("text_editor_code_execution_view_result"),content:r.z.string(),file_type:r.z.string(),num_lines:r.z.number().nullable(),start_line:r.z.number().nullable(),total_lines:r.z.number().nullable()}),r.z.object({type:r.z.literal("text_editor_code_execution_create_result"),is_file_update:r.z.boolean()}),r.z.object({type:r.z.literal("text_editor_code_execution_str_replace_result"),lines:r.z.array(r.z.string()).nullable(),new_lines:r.z.number().nullable(),new_start:r.z.number().nullable(),old_lines:r.z.number().nullable(),old_start:r.z.number().nullable()})]))),ec=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("programmatic-tool-call"),code:r.z.string()}),r.z.object({type:r.z.literal("bash_code_execution"),command:r.z.string()}),r.z.discriminatedUnion("command",[r.z.object({type:r.z.literal("text_editor_code_execution"),command:r.z.literal("view"),path:r.z.string()}),r.z.object({type:r.z.literal("text_editor_code_execution"),command:r.z.literal("create"),path:r.z.string(),file_text:r.z.string().nullish()}),r.z.object({type:r.z.literal("text_editor_code_execution"),command:r.z.literal("str_replace"),path:r.z.string(),old_str:r.z.string(),new_str:r.z.string()})])]))),ed=(0,o.createProviderExecutedToolFactory)({id:"anthropic.code_execution_20250825",inputSchema:ec,outputSchema:eu,supportsDeferredResults:!0}),ep=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("code_execution_result"),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number(),content:r.z.array(r.z.object({type:r.z.literal("code_execution_output"),file_id:r.z.string()})).optional().default([])}),r.z.object({type:r.z.literal("encrypted_code_execution_result"),encrypted_stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number(),content:r.z.array(r.z.object({type:r.z.literal("code_execution_output"),file_id:r.z.string()})).optional().default([])}),r.z.object({type:r.z.literal("bash_code_execution_result"),content:r.z.array(r.z.object({type:r.z.literal("bash_code_execution_output"),file_id:r.z.string()})),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number()}),r.z.object({type:r.z.literal("bash_code_execution_tool_result_error"),error_code:r.z.string()}),r.z.object({type:r.z.literal("text_editor_code_execution_tool_result_error"),error_code:r.z.string()}),r.z.object({type:r.z.literal("text_editor_code_execution_view_result"),content:r.z.string(),file_type:r.z.string(),num_lines:r.z.number().nullable(),start_line:r.z.number().nullable(),total_lines:r.z.number().nullable()}),r.z.object({type:r.z.literal("text_editor_code_execution_create_result"),is_file_update:r.z.boolean()}),r.z.object({type:r.z.literal("text_editor_code_execution_str_replace_result"),lines:r.z.array(r.z.string()).nullable(),new_lines:r.z.number().nullable(),new_start:r.z.number().nullable(),old_lines:r.z.number().nullable(),old_start:r.z.number().nullable()})]))),em=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("programmatic-tool-call"),code:r.z.string()}),r.z.object({type:r.z.literal("bash_code_execution"),command:r.z.string()}),r.z.discriminatedUnion("command",[r.z.object({type:r.z.literal("text_editor_code_execution"),command:r.z.literal("view"),path:r.z.string()}),r.z.object({type:r.z.literal("text_editor_code_execution"),command:r.z.literal("create"),path:r.z.string(),file_text:r.z.string().nullish()}),r.z.object({type:r.z.literal("text_editor_code_execution"),command:r.z.literal("str_replace"),path:r.z.string(),old_str:r.z.string(),new_str:r.z.string()})])]))),eh=(0,o.createProviderExecutedToolFactory)({id:"anthropic.code_execution_20260120",inputSchema:em,outputSchema:ep,supportsDeferredResults:!0}),eg=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.array(r.z.object({type:r.z.literal("tool_reference"),toolName:r.z.string()})))),ef=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({pattern:r.z.string(),limit:r.z.number().optional()}))),ey=(0,o.createProviderExecutedToolFactory)({id:"anthropic.tool_search_regex_20251119",inputSchema:ef,outputSchema:eg,supportsDeferredResults:!0});function e_(e){try{if("string"==typeof e)return(0,o.secureJsonParse)(e);if("object"==typeof e&&null!==e)return e}catch{let t=e?.errorCode;return{errorCode:"string"==typeof t?t:"unavailable"}}return{}}async function eb({prompt:e,sendReasoning:n,warnings:r,cacheControlValidator:a,toolNameMapping:i,toolsetNames:s={}}){let l,u=new Set,c=function(e){let t,o=[];for(let n of e){let{role:e}=n;switch(e){case"system":t?.type!=="system"&&(t={type:"system",messages:[]},o.push(t)),t.messages.push(n);break;case"assistant":t?.type!=="assistant"&&(t={type:"assistant",messages:[]},o.push(t)),t.messages.push(n);break;case"user":case"tool":t?.type!=="user"&&(t={type:"user",messages:[]},o.push(t)),t.messages.push(n);break;default:throw Error(`Unsupported role: ${e}`)}}return o}(e),d=a||new w,p=[];async function m(e){let t=await (0,o.parseProviderOptions)({provider:"anthropic",providerOptions:e,schema:b});return t?.citations?.enabled??!1}async function h(e){let t=await (0,o.parseProviderOptions)({provider:"anthropic",providerOptions:e,schema:b});return t?.containerUpload??!1}async function g(e){let t=await (0,o.parseProviderOptions)({provider:"anthropic",providerOptions:e,schema:b});return{title:t?.title,context:t?.context}}for(let e=0;e<c.length;e++){let a=c[e],y=e===c.length-1,b=a.type;switch(b){case"system":{let t=[];for(let{content:e,providerOptions:n}of a.messages){let r=await (0,o.parseProviderOptions)({provider:"anthropic",providerOptions:n,schema:z}),a=r?.toolChanges??[],s=[];for(let t of((""!==e||0===a.length&&r?.clearAt==null&&r?.effort==null)&&s.push({type:"text",text:e,cache_control:d.getCacheControl(n,{type:"system message",canCache:!0})}),a))s.push({type:t.type,tool:{type:"tool_reference",name:i.toProviderToolName(t.toolName)}});t.push({content:s,clearAt:r?.clearAt,effort:r?.effort,toolChangeCount:a.length})}let n=t.reduce((e,t)=>e+t.toolChangeCount,0),s=t.some(e=>null!=e.clearAt||null!=e.effort);if(0!==e&&(null!=l||0!==n||s))for(let e of(u.add("mid-conversation-system-2026-04-07"),t))p.push({role:"system",content:e.content,...null!=e.clearAt&&{clear_at:e.clearAt},...null!=e.effort&&{output_config:{effort:e.effort}}}),e.toolChangeCount>0&&u.add("mid-conversation-tool-changes-2026-07-01"),null!=e.clearAt&&u.add("mid-conversation-system-clear-at-2026-08-21"),null!=e.effort&&u.add("mid-conversation-output-config-2026-07-01");else{for(let e of(n>0&&r.push({type:"other",message:"tool changes on the initial system message are not supported by Anthropic. Configure the initial tool set via the tools option instead. The tool changes have been ignored."}),t))0===e.content.length&&null==e.clearAt&&null!=e.effort?(p.push({role:"system",content:[],output_config:{effort:e.effort}}),u.add("mid-conversation-output-config-2026-07-01")):(null!=e.clearAt||null!=e.effort)&&r.push({type:"other",message:"clearAt and effort on this initial system message are not supported by Anthropic. Use a separate effort-only system message with empty content to set effort. These options have been ignored."});l=t.flatMap(e=>e.content.filter(e=>"text"===e.type))}break}case"user":{let e=[];for(let n of a.messages){let{role:a,content:i}=n;switch(a){case"user":for(let r=0;r<i.length;r++){let a=i[r],s=r===i.length-1,l=d.getCacheControl(a.providerOptions,{type:"user message part",canCache:!0})??(s?d.getCacheControl(n.providerOptions,{type:"user message",canCache:!0}):void 0);switch(a.type){case"text":e.push({type:"text",text:a.text,cache_control:l});break;case"file":switch(a.data.type){case"reference":{let t=(0,o.resolveProviderReference)({reference:a.data.reference,provider:"anthropic"});u.add("files-api-2025-04-14"),await h(a.providerOptions)?e.push({type:"container_upload",file_id:t}):"image"===(0,o.getTopLevelMediaType)(a.mediaType)?e.push({type:"image",source:{type:"file",file_id:t},cache_control:l}):e.push({type:"document",source:{type:"file",file_id:t},cache_control:l});break}case"text":{let t=await m(a.providerOptions),o=await g(a.providerOptions);e.push({type:"document",source:{type:"text",media_type:"text/plain",data:a.data.text},title:o.title??a.filename,...o.context&&{context:o.context},...t&&{citations:{enabled:!0}},cache_control:l});break}case"url":case"data":{let n=(0,o.getTopLevelMediaType)(a.mediaType);if("image"===n)e.push({type:"image",source:"url"===a.data.type?{type:"url",url:a.data.url.toString()}:{type:"base64",media_type:(0,o.resolveFullMediaType)({part:a}),data:(0,o.convertToBase64)(a.data.data)},cache_control:l});else if("application"===n&&("url"===a.data.type?"application/pdf"===a.mediaType:"application/pdf"===(0,o.resolveFullMediaType)({part:a}))){u.add("pdfs-2024-09-25");let t=await m(a.providerOptions),n=await g(a.providerOptions);e.push({type:"document",source:"url"===a.data.type?{type:"url",url:a.data.url.toString()}:{type:"base64",media_type:"application/pdf",data:(0,o.convertToBase64)(a.data.data)},title:n.title??a.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:l})}else if("text/plain"===a.mediaType){var f;let t=await m(a.providerOptions),n=await g(a.providerOptions);e.push({type:"document",source:"url"===a.data.type?{type:"url",url:a.data.url.toString()}:{type:"text",media_type:"text/plain",data:"string"==typeof(f=a.data.data)?new TextDecoder().decode((0,o.convertBase64ToUint8Array)(f)):new TextDecoder().decode(f)},title:n.title??a.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:l})}else throw new t.UnsupportedFunctionalityError({functionality:`media type: ${a.mediaType}`})}}}}break;case"tool":for(let t=0;t<i.length;t++){let a,l=i[t];if("tool-approval-response"===l.type)continue;let c=l.output,p="providerOptions"in c?c.providerOptions:"content"===c.type?c.value.find(e=>null!=e.providerOptions)?.providerOptions:void 0,m=t===i.length-1,h=d.getCacheControl(l.providerOptions,{type:"tool result part",canCache:!0})??d.getCacheControl(p,{type:"tool result output",canCache:!0})??(m?d.getCacheControl(n.providerOptions,{type:"tool result message",canCache:!0}):void 0);switch(c.type){case"content":a=c.value.map(e=>{switch(e.type){case"text":return{type:"text",text:e.text};case"file":{let t=(0,o.getTopLevelMediaType)(e.mediaType);if("url"===e.data.type){if("image"===t)return{type:"image",source:{type:"url",url:e.data.url.toString()}};return{type:"document",source:{type:"url",url:e.data.url.toString()}}}if("data"===e.data.type){if("image"===t)return{type:"image",source:{type:"base64",media_type:(0,o.resolveFullMediaType)({part:e}),data:(0,o.convertToBase64)(e.data.data)}};if("application/pdf"===(0,o.resolveFullMediaType)({part:e}))return u.add("pdfs-2024-09-25"),{type:"document",source:{type:"base64",media_type:"application/pdf",data:(0,o.convertToBase64)(e.data.data)}};r.push({type:"other",message:`unsupported tool content part type: ${e.type} with media type: ${e.mediaType}`});return}r.push({type:"other",message:`unsupported tool content part type: ${e.type} with data type: ${e.data.type}`});return}case"custom":{let t=e.providerOptions?.anthropic;if(t?.type==="tool-reference")return{type:"tool_reference",tool_name:t.toolName};r.push({type:"other",message:"unsupported custom tool content part"});return}default:return void r.push({type:"other",message:`unsupported tool content part type: ${e.type}`})}}).filter(o.isNonNullable);break;case"text":case"error-text":a=c.value;break;case"execution-denied":a=c.reason??"Tool call execution denied.";break;default:a=JSON.stringify(c.value)}let g=ez({toolName:l.toolName,providerOptions:l.providerOptions,toolsetNames:s});e.push({type:"tool_result",tool_use_id:l.toolCallId,...null!=g&&{toolset_name:g},content:a,is_error:"error-text"===c.type||"error-json"===c.type||void 0,cache_control:h})}break;default:throw Error(`Unsupported role: ${a}`)}}p.push({role:"user",content:e});break}case"assistant":{let e=[],t=new Set;for(let l=0;l<a.messages.length;l++){let c=a.messages[l],p=l===a.messages.length-1,{content:m}=c;for(let a=0;a<m.length;a++){let l=m[a],h=a===m.length-1,g=d.getCacheControl(l.providerOptions,{type:"assistant message part",canCache:!0})??(h?d.getCacheControl(c.providerOptions,{type:"assistant message",canCache:!0}):void 0);switch(l.type){case"text":{let t=l.providerOptions?.anthropic;if(t?.type==="compaction"){if(""===l.text)break;"string"==typeof t.signature&&u.add("compact-2026-09-04"),e.push({type:"compaction",content:l.text,..."string"==typeof t.signature&&{signature:t.signature},cache_control:g})}else e.push({type:"text",text:y&&p&&h?l.text.trim():l.text,...t?.citations!=null&&{citations:t.citations},cache_control:g});break}case"reasoning":if(n){let t=await (0,o.parseProviderOptions)({provider:"anthropic",providerOptions:l.providerOptions,schema:_});null!=t?null!=t.signature?(d.getCacheControl(l.providerOptions,{type:"thinking block",canCache:!1}),e.push({type:"thinking",thinking:l.text,signature:t.signature})):null!=t.redactedData?(d.getCacheControl(l.providerOptions,{type:"redacted thinking block",canCache:!1}),e.push({type:"redacted_thinking",data:t.redactedData})):r.push({type:"other",message:"unsupported reasoning metadata"}):r.push({type:"other",message:"unsupported reasoning metadata"})}else r.push({type:"other",message:"sending reasoning content is disabled for this model"});break;case"tool-call":{let o=ev(l.providerOptions);if(l.providerExecuted){let n=i.toProviderToolName(l.toolName);if(l.providerOptions?.anthropic?.type==="mcp-tool-use"){t.add(l.toolCallId);let o=l.providerOptions?.anthropic?.serverName;if(null==o||"string"!=typeof o){r.push({type:"other",message:"mcp tool use server name is required and must be a string"});break}e.push({type:"mcp_tool_use",id:l.toolCallId,name:l.toolName,input:l.input,server_name:o,cache_control:g})}else if("code_execution"===n&&null!=l.input&&"object"==typeof l.input&&"type"in l.input&&"string"==typeof l.input.type&&("bash_code_execution"===l.input.type||"text_editor_code_execution"===l.input.type)){let{type:t,...n}=l.input;e.push({type:"server_tool_use",id:l.toolCallId,name:t,input:n,...o&&{caller:o},cache_control:g})}else if("code_execution"===n&&null!=l.input&&"object"==typeof l.input&&"type"in l.input&&"programmatic-tool-call"===l.input.type){let{type:t,...n}=l.input;e.push({type:"server_tool_use",id:l.toolCallId,name:"code_execution",input:n,...o&&{caller:o},cache_control:g})}else"code_execution"===n||"web_fetch"===n||"web_search"===n||"tool_search_tool_regex"===n||"tool_search_tool_bm25"===n?e.push({type:"server_tool_use",id:l.toolCallId,name:n,input:l.input,...o&&{caller:o},cache_control:g}):"advisor"===n?e.push({type:"server_tool_use",id:l.toolCallId,name:"advisor",input:{},...o&&{caller:o},cache_control:g}):r.push({type:"other",message:`provider executed tool call for tool ${l.toolName} is not supported`});break}let n=ez({toolName:l.toolName,providerOptions:l.providerOptions,toolsetNames:s});if(null!=n){let{action:t,...a}=ew(l.input);if("string"!=typeof t){r.push({type:"other",message:`toolset tool call for tool ${l.toolName} is missing the action`});break}e.push({type:"tool_use",id:l.toolCallId,name:t,toolset_name:n,input:a,...o&&{caller:o},cache_control:g});break}e.push({type:"tool_use",id:l.toolCallId,name:l.toolName,input:ew(l.input),...o&&{caller:o},cache_control:g});break}case"tool-result":{let n=i.toProviderToolName(l.toolName),a=ev(l.providerOptions);if(t.has(l.toolCallId)){let t=l.output;if("json"!==t.type&&"error-json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${l.toolName} is not supported`});break}e.push({type:"mcp_tool_result",tool_use_id:l.toolCallId,is_error:"error-json"===t.type,content:t.value,cache_control:g})}else if("code_execution"===n){let t=l.output;if("error-text"===t.type||"error-json"===t.type){let n={};try{"string"==typeof t.value?n=(0,o.secureJsonParse)(t.value):"object"==typeof t.value&&null!==t.value&&(n=t.value)}catch{}"code_execution_tool_result_error"===n.type?e.push({type:"code_execution_tool_result",tool_use_id:l.toolCallId,content:{type:"code_execution_tool_result_error",error_code:n.errorCode??"unknown"},cache_control:g}):e.push({type:"bash_code_execution_tool_result",tool_use_id:l.toolCallId,cache_control:g,content:{type:"bash_code_execution_tool_result_error",error_code:n.errorCode??"unknown"}});break}if("json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${l.toolName} is not supported`});break}if(null==t.value||"object"!=typeof t.value||!("type"in t.value)||"string"!=typeof t.value.type){r.push({type:"other",message:`provider executed tool result output value is not a valid code execution result for tool ${l.toolName}`});break}if("code_execution_result"===t.value.type){let n=await (0,o.validateTypes)({value:t.value,schema:ei});e.push({type:"code_execution_tool_result",tool_use_id:l.toolCallId,content:{type:n.type,stdout:n.stdout,stderr:n.stderr,return_code:n.return_code,content:n.content??[]},cache_control:g})}else if("encrypted_code_execution_result"===t.value.type){let n=await (0,o.validateTypes)({value:t.value,schema:ep});"encrypted_code_execution_result"===n.type&&e.push({type:"code_execution_tool_result",tool_use_id:l.toolCallId,content:{type:n.type,encrypted_stdout:n.encrypted_stdout,stderr:n.stderr,return_code:n.return_code,content:n.content??[]},cache_control:g})}else{let n=await (0,o.validateTypes)({value:t.value,schema:eu});"code_execution_result"===n.type?e.push({type:"code_execution_tool_result",tool_use_id:l.toolCallId,content:{type:n.type,stdout:n.stdout,stderr:n.stderr,return_code:n.return_code,content:n.content??[]},cache_control:g}):"bash_code_execution_result"===n.type||"bash_code_execution_tool_result_error"===n.type?e.push({type:"bash_code_execution_tool_result",tool_use_id:l.toolCallId,cache_control:g,content:"bash_code_execution_result"===n.type?{type:n.type,stdout:n.stdout,stderr:n.stderr,return_code:n.return_code,content:n.content}:n}):e.push({type:"text_editor_code_execution_tool_result",tool_use_id:l.toolCallId,cache_control:g,content:n})}break}if("web_fetch"===n){let t=l.output;if("error-json"===t.type){e.push({type:"web_fetch_tool_result",tool_use_id:l.toolCallId,content:{type:"web_fetch_tool_result_error",error_code:e_(t.value).errorCode??"unavailable"},...a&&{caller:a},cache_control:g});break}if("json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${l.toolName} is not supported`});break}let n=await (0,o.validateTypes)({value:t.value,schema:et});e.push({type:"web_fetch_tool_result",tool_use_id:l.toolCallId,content:{type:"web_fetch_result",url:n.url,retrieved_at:n.retrievedAt,content:{type:"document",title:n.content.title,citations:n.content.citations,source:{type:n.content.source.type,media_type:n.content.source.mediaType,data:n.content.source.data}}},...a&&{caller:a},cache_control:g});break}if("web_search"===n){let t=l.output;if("error-json"===t.type){e.push({type:"web_search_tool_result",tool_use_id:l.toolCallId,content:{type:"web_search_tool_result_error",error_code:e_(t.value).errorCode??"unavailable"},...a&&{caller:a},cache_control:g});break}if("json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${l.toolName} is not supported`});break}let n=await (0,o.validateTypes)({value:t.value,schema:H});e.push({type:"web_search_tool_result",tool_use_id:l.toolCallId,content:n.map(e=>({url:e.url,title:e.title,page_age:e.pageAge,encrypted_content:e.encryptedContent,type:e.type})),...a&&{caller:a},cache_control:g});break}if("tool_search_tool_regex"===n||"tool_search_tool_bm25"===n){let t=l.output;if("json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${l.toolName} is not supported`});break}let n=(await (0,o.validateTypes)({value:t.value,schema:eg})).map(e=>({type:"tool_reference",tool_name:e.toolName}));e.push({type:"tool_search_tool_result",tool_use_id:l.toolCallId,content:{type:"tool_search_tool_search_result",tool_references:n},cache_control:g});break}if("advisor"===n){let t=l.output;if("json"!==t.type&&"error-json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${l.toolName} is not supported`});break}let n=await (0,o.validateTypes)({value:t.value,schema:k});"advisor_result"===n.type?e.push({type:"advisor_tool_result",tool_use_id:l.toolCallId,content:{type:"advisor_result",text:n.text,...void 0!==n.stopReason&&{stop_reason:n.stopReason}},cache_control:g}):"advisor_redacted_result"===n.type?e.push({type:"advisor_tool_result",tool_use_id:l.toolCallId,content:{type:"advisor_redacted_result",encrypted_content:n.encryptedContent,...void 0!==n.stopReason&&{stop_reason:n.stopReason}},cache_control:g}):e.push({type:"advisor_tool_result",tool_use_id:l.toolCallId,content:{type:"advisor_tool_result_error",error_code:n.errorCode},cache_control:g});break}r.push({type:"other",message:`provider executed tool result for tool ${l.toolName} is not supported`})}}}}e.length>0&&p.push({role:"assistant",content:function(e){let t=[],o=[];function n(){t.push(...o.filter(e=>"tool_use"!==e.type),...o.filter(e=>"tool_use"===e.type)),o=[]}for(let r of e)"thinking"===r.type||"redacted_thinking"===r.type?(n(),t.push(r)):o.push(r);return n(),t}(e)});break}default:throw Error(`content type: ${b}`)}}return{prompt:{system:l,messages:p},betas:u}}function ez({toolName:e,providerOptions:t,toolsetNames:o}){let n=o[e];if(null!=n)return n;let r=t?.anthropic?.toolsetName;return"string"==typeof r?r:void 0}function ev(e){let t=e?.anthropic?.caller;return(t?.type==="code_execution_20250825"||t?.type==="code_execution_20260120")&&t.toolId?{type:t.type,tool_id:t.toolId}:t?.type==="direct"?{type:"direct"}:void 0}function ew(e){return"object"!=typeof e||null===e||Array.isArray(e)?{rawInvalidInput:e}:e}function ex({finishReason:e,isJsonResponseFromTool:t}){switch(e){case"pause_turn":case"end_turn":case"stop_sequence":return"stop";case"refusal":return"content-filter";case"tool_use":return t?"stop":"tool-calls";case"max_tokens":case"model_context_window_exceeded":return"length";default:return"other"}}var ek=new Set(["date-time","time","date","duration","email","hostname","uri","ipv4","ipv6","uuid"]),eI=["minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","minLength","maxLength","pattern","minItems","maxItems","uniqueItems","minProperties","maxProperties","not"];function eT(e){return"boolean"!=typeof e&&(0,o.isRecord)(e)?eS(e):e}function eS(e){var t;let o,n={};if(null!=e.$ref)return{$ref:e.$ref};null!=e.$schema&&(n.$schema=e.$schema),null!=e.$id&&(n.$id=e.$id),null!=e.title&&(n.title=e.title),null!=e.description&&(n.description=e.description),void 0!==e.default&&(n.default=e.default),void 0!==e.const&&(n.const=e.const),null!=e.enum&&(n.enum=e.enum),null!=e.type&&(n.type=e.type),null!=e.anyOf?n.anyOf=e.anyOf.map(eT):null!=e.oneOf&&(n.anyOf=e.oneOf.map(eT)),null!=e.allOf&&(n.allOf=e.allOf.map(eT)),null!=e.definitions&&(n.definitions=Object.fromEntries(Object.entries(e.definitions).map(([e,t])=>[e,eT(t)]))),null!=e.$defs&&(n.$defs=Object.fromEntries(Object.entries(e.$defs).map(([e,t])=>[e,eT(t)]))),("object"===e.type||null!=e.properties)&&(null!=e.properties&&(n.properties=Object.fromEntries(Object.entries(e.properties).map(([e,t])=>[e,eT(t)]))),n.additionalProperties=!1,null!=e.required&&(n.required=e.required)),null!=e.items&&(n.items=Array.isArray(e.items)?e.items.map(eT):eT(e.items)),"string"==typeof e.format&&ek.has(e.format)&&(n.format=e.format);let r=(t=e,o=eI.flatMap(e=>{var o;let n=t[e];return null==n||!1===n?[]:`${e.replace(/[A-Z]/g,e=>` ${e.toLowerCase()}`)}: ${"string"==typeof(o=n)?o:JSON.stringify(o)}`}),"string"!=typeof t.format||ek.has(t.format)||o.push(`format: ${t.format}`),0===o.length?void 0:`${o.join("; ")}.`);return null!=r&&(n.description=null==n.description?r:`${n.description}
|
|
1
|
+
module.exports=[150171,e=>e.a(async(t,o)=>{try{var n=e.i(687388),r=e.i(340698),a=e.i(640911),i=e.i(53748),s=e.i(41444),l=e.i(264079),u=t([r]);[r]=u.then?(await u)():u;let m={"x-ai":"spacexai","z-ai":"zai",mistralai:"mistral","meta-llama":"meta",qwen:"alibaba","bytedance-seed":"bytedance"},h=e=>{let t=e.slice(0,e.indexOf("/")).replace(/^~/,"");return m[t]??t};function c(e){if(null==e||""===e)return null;let t=Number(e);return!Number.isFinite(t)||t<0?null:Math.round(1e6*t*1e4)/1e4}async function d(){let e=await fetch("https://openrouter.ai/api/v1/models",{headers:{accept:"application/json"}}).catch(e=>{a.logger.warn({cause:e},"openrouter catalog unreachable"),(0,i.publicError)("Could not reach OpenRouter")});return e.ok||(0,i.publicError)(`OpenRouter answered ${e.status}`),((await e.json()).data??[]).filter(e=>!!e.id).map(e=>{let t,o,n,r;return{id:e.id,label:e.name||e.id,owner:h(e.id),type:(e.architecture?.output_modalities??[]).includes("text")?l.CATALOG_TEXT:null,tags:(e.supported_parameters??[]).includes("tools")?[l.CATALOG_TOOL_USE]:[],price:(t=c(e.pricing?.prompt),o=c(e.pricing?.completion),0===t&&0===o?{in:0,out:0,note:null,free:!0}:{in:t,out:o,note:null===t&&null===o?"per model it picks":null,free:!1}),retiring:!!e.expiration_date,contextWindow:"number"==typeof e.context_length&&e.context_length>0?e.context_length:null,efforts:(n=e.reasoning?.supported_efforts??[],(r=l.EFFORTS.filter(e=>n.includes(e))).length?r:null)}})}async function p(){let e=await (0,r.readConfig)(l.TEXT_MODEL_PROVIDERS.openrouter.apiKeyName);if(!e)return null;let t=await fetch("https://openrouter.ai/api/v1/credits",{headers:{accept:"application/json",authorization:`Bearer ${e}`}}).catch(e=>{a.logger.warn({cause:e},"openrouter credits unreachable"),(0,i.publicError)("Could not reach OpenRouter")}),o=await t.json().catch(()=>null),u=(0,s.clip)(o?.error?.message??"",300);if(401===t.status||403===t.status)return{refused:u||`OpenRouter answered ${t.status}`};t.ok||(0,i.publicError)(`OpenRouter answered ${t.status}${u?`: ${u}`:""}`);let c=o?.data?.total_credits,d=o?.data?.total_usage;("number"!=typeof c||"number"!=typeof d)&&(0,i.publicError)("OpenRouter did not say what is left");let p=c-d;return{balance:p,low:p<=n.KEY_LOW_CREDIT}}e.s(["fetchOpenRouterCatalog",0,d,"readOpenRouterCredits",0,p,"vendorOf",0,h]),o()}catch(e){o(e)}},!1),386075,e=>e.a(async(t,o)=>{try{var n=e.i(631493),r=e.i(8421),a=e.i(759587),i=e.i(50503),s=e.i(666367),l=e.i(392086),u=e.i(312069),c=e.i(499349),d=e.i(3068),p=e.i(115737),m=e.i(860774),h=e.i(117578),g=e.i(724362),f=e.i(376261),y=e.i(375015),_=e.i(68356),b=e.i(687388),z=e.i(279041),v=e.i(340698),w=e.i(640911),x=e.i(53748),k=e.i(41444),I=e.i(656446),T=e.i(264079),S=e.i(150171),j=t([v,I,S]);[v,I,S]=j.then?(await j)():j;let B=/context[ _-]?(length|window)|maximum context|prompt is too long|too many (input )?tokens|input token count|exceeds? the (maximum|model'?s?) (context|input|prompt|number of tokens)|maximum prompt length|request (entity )?too large/i;function R(e){return C(e).some(e=>{let{statusCode:t,message:o,error:n}=e;if(void 0!==t&&400!==t&&413!==t)return!1;let r=f.APICallError.isInstance(e)?e.responseBody:null;return[o,n,r].some(e=>"string"==typeof e&&B.test(e))})}let V=new Set([408,409,429]);function C(e){let t=[],o=[e];for(;o.length&&t.length<12;){let e=o.shift();!("object"!=typeof e||null===e||t.includes(e))&&(t.push(e),_.RetryError.isInstance(e)&&o.push(...e.errors),"cause"in e&&o.push(e.cause))}return t}let J=(e,t)=>({ref:e,model:t,searchTools:null}),G={};function O(e){if(null==e||""===e)return null;let t=Number(e);return Number.isFinite(t)?Math.round(1e6*t*1e4)/1e4:null}async function E(e){let t=G[e];if(t&&Date.now()-t.at<b.CATALOG_MS)return t.models;let o=("openrouter"===e?await (0,S.fetchOpenRouterCatalog)():await A()).sort((e,t)=>e.id.localeCompare(t.id));return G[e]={at:Date.now(),models:o},o}async function A(){let e=await fetch("https://ai-gateway.vercel.sh/v1/models",{headers:{accept:"application/json"}}).catch(e=>{w.logger.warn({cause:e},"gateway catalog unreachable"),(0,x.publicError)("Could not reach the gateway")});return e.ok||(0,x.publicError)(`The gateway answered ${e.status}`),((await e.json()).data??[]).filter(e=>!!e.id).map(e=>{let t,o;return{id:e.id,label:e.name||e.id,owner:e.owned_by||e.id.slice(0,e.id.indexOf("/")),type:e.type??null,tags:e.tags??[],price:function(e){let t=e.pricing??{},o=O(t.input),n=O(t.output);if((e.tags??[]).includes("free")||0===o)return{in:0,out:0,note:null,free:!0};let r=t.transcription_duration_cost_per_second??t.realtime_session_duration_cost_per_second;if(r)return{in:null,out:null,note:`$${r}/s`,free:!1};if(t.speech_input_character_cost)return{in:null,out:null,note:"per character",free:!1};let a=Array.isArray(t.video_duration_pricing)?t.video_duration_pricing[0]:null;if(a?.cost_per_second)return{in:null,out:null,note:`$${a.cost_per_second}/s ${a.resolution??""}`.trimEnd(),free:!1};let i=t.image?`$${t.image}/image`:t.image_dimension_quality_pricing?"per image, by size":null;return null===o&&null===n?{in:null,out:null,note:i,free:!1}:{in:o,out:n,note:t.input_tiers?"tiered":t.varies_by_provider?"varies":i&&"+ per image",free:!1}}(e),retiring:!!e.deprecated_at,contextWindow:"number"==typeof e.context_window&&e.context_window>0?e.context_window:null,efforts:(t=(e.reasoning_options??[]).find(e=>e?.type==="effort"),(o=T.EFFORTS.filter(e=>t?.values?.includes(e))).length?o:null)}})}async function M(e){return"openrouter"===e?(0,S.readOpenRouterCredits)():$()}async function $(){let e=await (0,v.readConfig)(T.TEXT_MODEL_PROVIDERS["vercel-ai-gateway"].apiKeyName);if(!e)return null;let t=await fetch("https://ai-gateway.vercel.sh/v1/credits",{headers:{accept:"application/json",authorization:`Bearer ${e}`}}).catch(e=>{w.logger.warn({cause:e},"gateway credits unreachable"),(0,x.publicError)("Could not reach the gateway")}),o=await t.json().catch(()=>null),n=(0,k.clip)(o?.error?.message??"",300);if(401===t.status||403===t.status)return{refused:n||`The gateway answered ${t.status}`};t.ok||(0,x.publicError)(`The gateway answered ${t.status}${n?`: ${n}`:""}`);let r=Number(o?.balance);return o?.balance&&Number.isFinite(r)||(0,x.publicError)("The gateway did not say what is left"),{balance:r,low:r<=b.KEY_LOW_CREDIT}}async function q(e,t){if(t&&t>0)return t;let o=await U(e);return(0,T.compactAtFor)((0,T.contextWindowOf)(e.provider,e.model,o))}async function U(e){return(0,T.isCatalogProvider)(e.provider)?await E(e.provider).catch(()=>[]):[]}async function N(e,t){let o=t??T.effortSchema.safeParse(await (0,v.readConfig)(z.DEFAULT_EFFORT_KEY)).data;if(!o)return;let n=await U(e);return(0,T.effortsOf)(e.provider,e.model,n)?.includes(o)?o:void 0}async function P(e){return await E(e).then(e=>new Set(e.map(e=>e.id))).catch(()=>null)}async function L(e,t){if(!(0,T.isCatalogProvider)(e))return t;let o=await P(e);if(!o)return t;let n=t.filter(e=>o.has(e.id));return n.length>0?n:t}async function D(e){let{label:t,apiKeyName:o,signIn:f}=T.TEXT_MODEL_PROVIDERS[e.provider],b=await (0,v.readConfig)(o);return b||(0,x.publicError)(await (0,v.missingKeyWords)(o,f?`${t} is not signed in — sign in from Settings › API keys.`:`No ${t} key — add one in Settings › API keys.`)),function(e,t){switch(e.provider){case"openai":{let o=(0,p.createOpenAI)({apiKey:t});return{ref:e,model:o(e.model),searchTools:{search:o.tools.webSearch()}}}case"chatgpt":return{ref:e,model:(0,I.chatGptModel)(e.model),searchTools:{search:(0,I.chatGptSearch)()}};case"anthropic":{let o=(0,n.createAnthropic)({apiKey:t});return{ref:e,model:o(e.model),searchTools:{search:o.tools.webSearch_20260209()}}}case"google":{let o=(0,u.createGoogleGenerativeAI)({apiKey:t});return{ref:e,model:o(e.model),searchTools:{search:o.tools.googleSearch({})}}}case"xai":{let o=(0,h.createXai)({apiKey:t});return{ref:e,model:o(e.model),searchTools:{search:o.tools.webSearch()}}}case"mistral":return J(e,(0,d.createMistral)({apiKey:t})(e.model));case"deepseek":return J(e,(0,s.createDeepSeek)({apiKey:t})(e.model));case"groq":return J(e,(0,c.createGroq)({apiKey:t})(e.model));case"cerebras":return J(e,(0,r.createCerebras)({apiKey:t})(e.model));case"togetherai":return J(e,(0,m.createTogetherAI)({apiKey:t})(e.model));case"fireworks":return J(e,(0,l.createFireworks)({apiKey:t})(e.model));case"deepinfra":return J(e,(0,i.createDeepInfra)({apiKey:t})(e.model));case"cohere":return J(e,(0,a.createCohere)({apiKey:t})(e.model));case"vercel-ai-gateway":{let o=(0,y.createGateway)({apiKey:t});return{ref:e,model:o(e.model),searchTools:null}}case"openrouter":{var o;let n=(0,g.createOpenRouter)({apiKey:t});return{ref:e,model:(o=n(e.model),(0,_.wrapLanguageModel)({model:o,middleware:{specificationVersion:"v4",transformParams:async({params:e})=>e.reasoning&&"provider-default"!==e.reasoning?{...e,providerOptions:{...e.providerOptions,openrouter:{...e.providerOptions?.openrouter,reasoning:{effort:e.reasoning}}}}:e}})),searchTools:{search:n.tools.webSearch({})}}}default:(0,x.publicError)(`Not supported provider: ${String(e.provider)}`)}}(e,b)}async function F(e,{quiet:t=!1}={}){let o=async e=>(0,T.defaultModelOf)({defaultTier:"chatgpt"===e.id&&await (0,I.readChatGptPlan)()==="free"?"small":e.defaultTier,suggestModels:await L(e.id,e.suggestModels)}),n=e?T.TEXT_MODEL_PROVIDER_LIST.find(t=>t.id===e):void 0,r=["chatgpt","openai","xai"].map(e=>({...T.TEXT_MODEL_PROVIDERS[e],id:e}));if(n){let e=await o(n);if(e)return{provider:n.id,model:e}}let a=(0,T.parseTextModel)(await (0,v.readConfig)(z.DEFAULT_MODEL_KEY)??void 0);if(a){let{label:e,apiKeyName:t,signIn:o}=T.TEXT_MODEL_PROVIDERS[a.provider];if(await (0,v.readConfig)(t))return a;(0,x.publicError)(await (0,v.missingKeyWords)(t,o?`The default model is ${a.model} on ${e}, which is signed out — sign in again, or pick another in Settings › Models.`:`The default model is ${a.model}, and there is no ${e} key any more — add it in Settings › API keys, or pick another in Settings › Models.`))}for(let e of[...r,...T.TEXT_MODEL_PROVIDER_LIST]){if(!await (0,v.readConfig)(e.apiKeyName))continue;let n=await o(e);if(n)return t||w.logger.info(`no model set, falling back to ${e.id}/${n}`),{provider:e.id,model:n}}(0,x.publicError)("No model key is set — add one in Settings › API keys.")}async function H(e){let t=(0,T.parseMediaModel)(await (0,v.readConfig)(z.MEDIA_MODEL_KEYS[e]));if(!t){let t=await (0,v.readConfig)(T.MEDIA_MODEL_PROVIDERS.chatgpt.apiKeyName),o=t?(0,T.planMediaOf)(e,{plan:await (0,I.readChatGptPlan)()}):null;return o&&t?{ref:o,apiKey:t}:null}if(!(0,T.canMakeKind)(t.provider,e))return null;let o=await (0,v.readConfig)(T.MEDIA_MODEL_PROVIDERS[t.provider].apiKeyName);return o?{ref:t,apiKey:o}:null}e.s(["buildImageModel",0,function(e,t){switch(e.provider){case"openai":return(0,p.createOpenAI)({apiKey:t}).image(e.model);case"chatgpt":return(0,I.chatGptImageModel)(e.model);case"google":return(0,u.createGoogleGenerativeAI)({apiKey:t}).image(e.model);case"xai":return(0,h.createXai)({apiKey:t}).image(e.model);case"vercel-ai-gateway":return(0,y.createGateway)({apiKey:t}).image(e.model);default:(0,x.publicError)(`Not supported image provider: ${String(e.provider)}`)}},"buildSpeechModel",0,function(e,t){switch(e.provider){case"openai":return(0,p.createOpenAI)({apiKey:t}).speech(e.model);case"google":return(0,u.createGoogleGenerativeAI)({apiKey:t}).speech(e.model);case"xai":return(0,h.createXai)({apiKey:t}).speech();case"vercel-ai-gateway":return(0,y.createGateway)({apiKey:t}).speech(e.model);default:(0,x.publicError)(`Not supported speech provider: ${String(e.provider)}`)}},"buildTranscriptionModel",0,function(e,t){switch(e.provider){case"openai":return(0,p.createOpenAI)({apiKey:t}).transcription(e.model);case"google":return(0,u.createGoogleGenerativeAI)({apiKey:t}).transcription(e.model);case"xai":return(0,h.createXai)({apiKey:t}).transcription();case"vercel-ai-gateway":return(0,y.createGateway)({apiKey:t}).transcription(e.model);default:(0,x.publicError)(`Not supported transcription provider: ${String(e.provider)}`)}},"buildVideoModel",0,function(e,t){switch(e.provider){case"google":return(0,u.createGoogleGenerativeAI)({apiKey:t}).video(e.model);case"xai":return(0,h.createXai)({apiKey:t}).video(e.model);case"vercel-ai-gateway":return(0,y.createGateway)({apiKey:t}).video(e.model);default:(0,x.publicError)(`${e.provider} has no video model`)}},"compactBudget",0,q,"getTextModel",0,D,"isContextOverflow",0,R,"isKeyRefused",0,function(e){return C(e).some(e=>401===e.statusCode)},"isPlanSpent",0,function(e){return C(e).some(e=>{if(!f.APICallError.isInstance(e)||402!==e.statusCode)return!1;try{let{code:t}=JSON.parse(e.responseBody??"").error??{};return"string"==typeof t&&I.PLAN_SPENT_CODE.test(t)}catch{return!1}})},"isProviderRefusal",0,function(e){return!R(e)&&C(e).some(e=>{let{statusCode:t}=e;return"number"==typeof t&&t>=400&&t<500&&!V.has(t)})},"modelErrorToString",0,function(e){if(!f.APICallError.isInstance(e))return(0,k.errorToString)(e);let t=e.statusCode?`(${e.statusCode})`:"",o=e.responseBody?.trim(),n=o&&!(e.message&&o.includes(e.message))?(0,k.clip)(o,300):"";return[e.message,t,n].filter(Boolean).join(" ")},"promptCacheOptions",0,function(e,t){switch(e.provider){case"openai":case"chatgpt":return t?{openai:{promptCacheKey:t}}:{};case"anthropic":return{anthropic:{cacheControl:{type:"ephemeral"}}};case"vercel-ai-gateway":return{gateway:{caching:"auto"}};case"openrouter":return"anthropic"===(0,S.vendorOf)(e.model)?{openrouter:{cacheControl:{type:"ephemeral"}}}:{};default:return{}}},"readCatalog",0,E,"readKeyCredits",0,M,"resolveDefaultModel",0,F,"resolveMediaRef",0,H,"runEffort",0,N,"seesToolImages",0,function(e){let t="vercel-ai-gateway"===e.provider?T.VENDOR_PROVIDERS[e.model.split("/")[0]]:"openrouter"===e.provider?T.VENDOR_PROVIDERS[(0,S.vendorOf)(e.model)]:e.provider;return void 0!==t&&["openai","chatgpt","anthropic","google","xai"].includes(t)}]),o()}catch(e){o(e)}},!1),631493,e=>{"use strict";var t=e.i(376261),o=e.i(847841),n=e.i(546888),r=e.i(469719),a=e.i(110567),i=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({type:r.z.literal("error"),error:r.z.object({type:r.z.string(),message:r.z.string()})}))),s=(0,o.createJsonErrorResponseHandler)({errorSchema:i,errorToMessage:e=>e.error.message}),l=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({id:r.z.string(),type:r.z.literal("file"),filename:r.z.string(),mime_type:r.z.string(),size_bytes:r.z.number(),created_at:r.z.string(),downloadable:r.z.boolean().nullish()}))),u=class{constructor(e){this.config=e,this.specificationVersion="v4"}get provider(){return this.config.provider}async uploadFile({data:e,mediaType:t,filename:n,abortSignal:r,headers:a}){let i=new Blob([(0,o.convertInlineFileDataToUint8Array)(e)],{type:t}),u=new FormData;null!=n?u.append("file",i,n):u.append("file",i);let{value:c}=await (0,o.postFormDataToApi)({url:`${this.config.baseURL}/files`,headers:(0,o.combineHeaders)(this.config.headers(),{"anthropic-beta":"files-api-2025-04-14"},a),formData:u,failedResponseHandler:s,successfulResponseHandler:(0,o.createJsonResponseHandler)(l),abortSignal:r,fetch:this.config.fetch});return{warnings:[],providerReference:{anthropic:c.id},mediaType:c.mime_type??t,filename:c.filename??n,providerMetadata:{anthropic:{filename:c.filename,mimeType:c.mime_type,sizeBytes:c.size_bytes,createdAt:c.created_at,...null!=c.downloadable?{downloadable:c.downloadable}:{}}}}}},c=r.z.object({type:r.z.string(),category:r.z.string().nullish(),explanation:r.z.string().nullish(),recommended_model:r.z.string().nullish()}),d=r.z.object({type:r.z.string(),status:r.z.object({type:r.z.string(),tool_uses:r.z.record(r.z.string(),r.z.object({type:r.z.string(),outcome:r.z.string().nullish(),explanation:r.z.string().nullish()})).nullish()})}),p=r.z.union([r.z.object({type:r.z.literal("code_execution_20250825"),tool_id:r.z.string()}),r.z.object({type:r.z.literal("code_execution_20260120"),tool_id:r.z.string()}),r.z.object({type:r.z.literal("direct")})]),m=r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("web_search_result_location"),cited_text:r.z.string(),url:r.z.string(),title:r.z.string().nullable(),encrypted_index:r.z.string()}),r.z.object({type:r.z.literal("page_location"),cited_text:r.z.string(),document_index:r.z.number(),document_title:r.z.string().nullable(),start_page_number:r.z.number(),end_page_number:r.z.number(),file_id:r.z.string().nullish()}),r.z.object({type:r.z.literal("char_location"),cited_text:r.z.string(),document_index:r.z.number(),document_title:r.z.string().nullable(),start_char_index:r.z.number(),end_char_index:r.z.number(),file_id:r.z.string().nullish()}),r.z.object({type:r.z.literal("content_block_location"),cited_text:r.z.string(),document_index:r.z.number(),document_title:r.z.string().nullable(),start_block_index:r.z.number(),end_block_index:r.z.number(),file_id:r.z.string().nullable()}),r.z.object({type:r.z.literal("search_result_location"),cited_text:r.z.string(),search_result_index:r.z.number(),source:r.z.string(),title:r.z.string().nullable(),start_block_index:r.z.number(),end_block_index:r.z.number()})]),h=r.z.union([r.z.string(),r.z.array(r.z.union([r.z.string(),r.z.object({type:r.z.literal("text"),text:r.z.string(),citations:r.z.array(r.z.json()).nullable().optional()})]))]),g=r.z.object({type:r.z.string(),path:r.z.string(),reason:r.z.string()}),f=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({type:r.z.literal("message"),id:r.z.string().nullish(),model:r.z.string().nullish(),content:r.z.array(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("text"),text:r.z.string(),citations:r.z.array(m).nullable().optional()}),r.z.object({type:r.z.literal("thinking"),thinking:r.z.string(),signature:r.z.string()}),r.z.object({type:r.z.literal("redacted_thinking"),data:r.z.string()}),r.z.object({type:r.z.literal("compaction"),content:r.z.string().nullish(),signature:r.z.string().nullish()}),r.z.object({type:r.z.literal("tool_use"),id:r.z.string(),name:r.z.string(),input:r.z.unknown(),caller:p.optional(),toolset_name:r.z.string().nullish()}),r.z.object({type:r.z.literal("server_tool_use"),id:r.z.string(),name:r.z.string(),input:r.z.record(r.z.string(),r.z.unknown()).nullish(),caller:p.optional()}),r.z.object({type:r.z.literal("mcp_tool_use"),id:r.z.string(),name:r.z.string(),input:r.z.unknown(),server_name:r.z.string()}),r.z.object({type:r.z.literal("mcp_tool_result"),tool_use_id:r.z.string(),is_error:r.z.boolean(),content:h}),r.z.object({type:r.z.literal("web_fetch_tool_result"),tool_use_id:r.z.string(),caller:p.optional(),content:r.z.union([r.z.object({type:r.z.literal("web_fetch_result"),url:r.z.string(),retrieved_at:r.z.string().nullable(),content:r.z.object({type:r.z.literal("document"),title:r.z.string().nullable(),citations:r.z.object({enabled:r.z.boolean()}).optional(),source:r.z.union([r.z.object({type:r.z.literal("base64"),media_type:r.z.literal("application/pdf"),data:r.z.string()}),r.z.object({type:r.z.literal("text"),media_type:r.z.literal("text/plain"),data:r.z.string()})])})}),r.z.object({type:r.z.literal("web_fetch_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("web_search_tool_result"),tool_use_id:r.z.string(),caller:p.optional(),content:r.z.union([r.z.array(r.z.object({type:r.z.literal("web_search_result"),url:r.z.string(),title:r.z.string().nullable(),encrypted_content:r.z.string(),page_age:r.z.string().nullish()})),r.z.object({type:r.z.literal("web_search_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("code_execution_tool_result"),tool_use_id:r.z.string(),content:r.z.union([r.z.object({type:r.z.literal("code_execution_result"),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number(),content:r.z.array(r.z.object({type:r.z.literal("code_execution_output"),file_id:r.z.string()})).optional().default([])}),r.z.object({type:r.z.literal("encrypted_code_execution_result"),encrypted_stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number(),content:r.z.array(r.z.object({type:r.z.literal("code_execution_output"),file_id:r.z.string()})).optional().default([])}),r.z.object({type:r.z.literal("code_execution_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("bash_code_execution_tool_result"),tool_use_id:r.z.string(),content:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("bash_code_execution_result"),content:r.z.array(r.z.object({type:r.z.literal("bash_code_execution_output"),file_id:r.z.string()})),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number()}),r.z.object({type:r.z.literal("bash_code_execution_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("text_editor_code_execution_tool_result"),tool_use_id:r.z.string(),content:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("text_editor_code_execution_tool_result_error"),error_code:r.z.string()}),r.z.object({type:r.z.literal("text_editor_code_execution_view_result"),content:r.z.string(),file_type:r.z.string(),num_lines:r.z.number().nullable(),start_line:r.z.number().nullable(),total_lines:r.z.number().nullable()}),r.z.object({type:r.z.literal("text_editor_code_execution_create_result"),is_file_update:r.z.boolean()}),r.z.object({type:r.z.literal("text_editor_code_execution_str_replace_result"),lines:r.z.array(r.z.string()).nullable(),new_lines:r.z.number().nullable(),new_start:r.z.number().nullable(),old_lines:r.z.number().nullable(),old_start:r.z.number().nullable()})])}),r.z.object({type:r.z.literal("tool_search_tool_result"),tool_use_id:r.z.string(),content:r.z.union([r.z.object({type:r.z.literal("tool_search_tool_search_result"),tool_references:r.z.array(r.z.object({type:r.z.literal("tool_reference"),tool_name:r.z.string()}))}),r.z.object({type:r.z.literal("tool_search_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("container_upload"),file_id:r.z.string()}),r.z.object({type:r.z.literal("advisor_tool_result"),tool_use_id:r.z.string(),content:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("advisor_result"),text:r.z.string(),stop_reason:r.z.string().nullish()}),r.z.object({type:r.z.literal("advisor_redacted_result"),encrypted_content:r.z.string(),stop_reason:r.z.string().nullish()}),r.z.object({type:r.z.literal("advisor_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("fallback")})])),stop_reason:r.z.string().nullish(),stop_sequence:r.z.string().nullish(),stop_details:c.nullish(),input_transformations:r.z.array(g).nullish(),safeguard_results:r.z.array(d).nullish(),usage:r.z.looseObject({input_tokens:r.z.number(),output_tokens:r.z.number(),output_tokens_details:r.z.object({thinking_tokens:r.z.number().nullish()}).nullish(),cache_creation_input_tokens:r.z.number().nullish(),cache_read_input_tokens:r.z.number().nullish(),iterations:r.z.array(r.z.object({type:r.z.union([r.z.literal("compaction"),r.z.literal("message"),r.z.literal("advisor_message"),r.z.literal("fallback_message")]),model:r.z.string().nullish(),input_tokens:r.z.number(),output_tokens:r.z.number(),cache_creation_input_tokens:r.z.number().nullish(),cache_read_input_tokens:r.z.number().nullish()})).nullish()}),container:r.z.object({expires_at:r.z.string(),id:r.z.string(),skills:r.z.array(r.z.object({type:r.z.union([r.z.literal("anthropic"),r.z.literal("custom")]),skill_id:r.z.string(),version:r.z.string()})).nullish()}).nullish(),context_management:r.z.object({applied_edits:r.z.array(r.z.union([r.z.object({type:r.z.literal("clear_tool_uses_20250919"),cleared_tool_uses:r.z.number(),cleared_input_tokens:r.z.number()}),r.z.object({type:r.z.literal("clear_thinking_20251015"),cleared_thinking_turns:r.z.number(),cleared_input_tokens:r.z.number()}),r.z.object({type:r.z.literal("compact_20260112")})]))}).nullish()}))),y=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("message_start"),message:r.z.object({id:r.z.string().nullish(),model:r.z.string().nullish(),role:r.z.string().nullish(),usage:r.z.looseObject({input_tokens:r.z.number(),cache_creation_input_tokens:r.z.number().nullish(),cache_read_input_tokens:r.z.number().nullish()}),content:r.z.array(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("tool_use"),id:r.z.string(),name:r.z.string(),input:r.z.unknown(),caller:p.optional(),toolset_name:r.z.string().nullish()})])).nullish(),stop_reason:r.z.string().nullish(),input_transformations:r.z.array(g).nullish(),container:r.z.object({expires_at:r.z.string(),id:r.z.string()}).nullish()})}),r.z.object({type:r.z.literal("content_block_start"),index:r.z.number(),content_block:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("text"),text:r.z.string()}),r.z.object({type:r.z.literal("thinking"),thinking:r.z.string()}),r.z.object({type:r.z.literal("tool_use"),id:r.z.string(),name:r.z.string(),input:r.z.record(r.z.string(),r.z.unknown()).optional(),caller:p.optional(),toolset_name:r.z.string().nullish()}),r.z.object({type:r.z.literal("redacted_thinking"),data:r.z.string()}),r.z.object({type:r.z.literal("compaction"),content:r.z.string().nullish(),signature:r.z.string().nullish()}),r.z.object({type:r.z.literal("server_tool_use"),id:r.z.string(),name:r.z.string(),input:r.z.record(r.z.string(),r.z.unknown()).nullish(),caller:p.optional()}),r.z.object({type:r.z.literal("mcp_tool_use"),id:r.z.string(),name:r.z.string(),input:r.z.unknown(),server_name:r.z.string()}),r.z.object({type:r.z.literal("mcp_tool_result"),tool_use_id:r.z.string(),is_error:r.z.boolean(),content:h}),r.z.object({type:r.z.literal("web_fetch_tool_result"),tool_use_id:r.z.string(),caller:p.optional(),content:r.z.union([r.z.object({type:r.z.literal("web_fetch_result"),url:r.z.string(),retrieved_at:r.z.string().nullable(),content:r.z.object({type:r.z.literal("document"),title:r.z.string().nullable(),citations:r.z.object({enabled:r.z.boolean()}).optional(),source:r.z.union([r.z.object({type:r.z.literal("base64"),media_type:r.z.literal("application/pdf"),data:r.z.string()}),r.z.object({type:r.z.literal("text"),media_type:r.z.literal("text/plain"),data:r.z.string()})])})}),r.z.object({type:r.z.literal("web_fetch_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("web_search_tool_result"),tool_use_id:r.z.string(),caller:p.optional(),content:r.z.union([r.z.array(r.z.object({type:r.z.literal("web_search_result"),url:r.z.string(),title:r.z.string().nullable(),encrypted_content:r.z.string(),page_age:r.z.string().nullish()})),r.z.object({type:r.z.literal("web_search_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("code_execution_tool_result"),tool_use_id:r.z.string(),content:r.z.union([r.z.object({type:r.z.literal("code_execution_result"),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number(),content:r.z.array(r.z.object({type:r.z.literal("code_execution_output"),file_id:r.z.string()})).optional().default([])}),r.z.object({type:r.z.literal("encrypted_code_execution_result"),encrypted_stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number(),content:r.z.array(r.z.object({type:r.z.literal("code_execution_output"),file_id:r.z.string()})).optional().default([])}),r.z.object({type:r.z.literal("code_execution_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("bash_code_execution_tool_result"),tool_use_id:r.z.string(),content:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("bash_code_execution_result"),content:r.z.array(r.z.object({type:r.z.literal("bash_code_execution_output"),file_id:r.z.string()})),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number()}),r.z.object({type:r.z.literal("bash_code_execution_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("text_editor_code_execution_tool_result"),tool_use_id:r.z.string(),content:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("text_editor_code_execution_tool_result_error"),error_code:r.z.string()}),r.z.object({type:r.z.literal("text_editor_code_execution_view_result"),content:r.z.string(),file_type:r.z.string(),num_lines:r.z.number().nullable(),start_line:r.z.number().nullable(),total_lines:r.z.number().nullable()}),r.z.object({type:r.z.literal("text_editor_code_execution_create_result"),is_file_update:r.z.boolean()}),r.z.object({type:r.z.literal("text_editor_code_execution_str_replace_result"),lines:r.z.array(r.z.string()).nullable(),new_lines:r.z.number().nullable(),new_start:r.z.number().nullable(),old_lines:r.z.number().nullable(),old_start:r.z.number().nullable()})])}),r.z.object({type:r.z.literal("tool_search_tool_result"),tool_use_id:r.z.string(),content:r.z.union([r.z.object({type:r.z.literal("tool_search_tool_search_result"),tool_references:r.z.array(r.z.object({type:r.z.literal("tool_reference"),tool_name:r.z.string()}))}),r.z.object({type:r.z.literal("tool_search_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("advisor_tool_result"),tool_use_id:r.z.string(),content:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("advisor_result"),text:r.z.string(),stop_reason:r.z.string().nullish()}),r.z.object({type:r.z.literal("advisor_redacted_result"),encrypted_content:r.z.string(),stop_reason:r.z.string().nullish()}),r.z.object({type:r.z.literal("advisor_tool_result_error"),error_code:r.z.string()})])}),r.z.object({type:r.z.literal("fallback")})])}),r.z.object({type:r.z.literal("content_block_delta"),index:r.z.number(),delta:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("input_json_delta"),partial_json:r.z.string()}),r.z.object({type:r.z.literal("text_delta"),text:r.z.string()}),r.z.object({type:r.z.literal("thinking_delta"),thinking:r.z.string()}),r.z.object({type:r.z.literal("signature_delta"),signature:r.z.string()}),r.z.object({type:r.z.literal("compaction_delta"),content:r.z.string().nullish()}),r.z.object({type:r.z.literal("citations_delta"),citation:m})])}),r.z.object({type:r.z.literal("content_block_stop"),index:r.z.number()}),r.z.object({type:r.z.literal("error"),error:r.z.object({type:r.z.string(),message:r.z.string(),code:r.z.union([r.z.string(),r.z.number()]).nullish(),statusCode:r.z.number().nullish(),isRetryable:r.z.boolean().nullish(),data:r.z.unknown().nullish()})}),r.z.object({type:r.z.literal("message_delta"),delta:r.z.object({stop_reason:r.z.string().nullish(),stop_sequence:r.z.string().nullish(),stop_details:c.nullish(),safeguard_results:r.z.array(d).nullish(),container:r.z.object({expires_at:r.z.string(),id:r.z.string(),skills:r.z.array(r.z.object({type:r.z.union([r.z.literal("anthropic"),r.z.literal("custom")]),skill_id:r.z.string(),version:r.z.string()})).nullish()}).nullish()}),usage:r.z.looseObject({input_tokens:r.z.number().nullish(),output_tokens:r.z.number(),output_tokens_details:r.z.object({thinking_tokens:r.z.number().nullish()}).nullish(),cache_creation_input_tokens:r.z.number().nullish(),cache_read_input_tokens:r.z.number().nullish(),iterations:r.z.array(r.z.object({type:r.z.union([r.z.literal("compaction"),r.z.literal("message"),r.z.literal("advisor_message"),r.z.literal("fallback_message")]),model:r.z.string().nullish(),input_tokens:r.z.number(),output_tokens:r.z.number(),cache_creation_input_tokens:r.z.number().nullish(),cache_read_input_tokens:r.z.number().nullish()})).nullish()}),input_transformations:r.z.array(g).nullish(),context_management:r.z.object({applied_edits:r.z.array(r.z.union([r.z.object({type:r.z.literal("clear_tool_uses_20250919"),cleared_tool_uses:r.z.number(),cleared_input_tokens:r.z.number()}),r.z.object({type:r.z.literal("clear_thinking_20251015"),cleared_thinking_turns:r.z.number(),cleared_input_tokens:r.z.number()}),r.z.object({type:r.z.literal("compact_20260112")})]))}).nullish()}),r.z.object({type:r.z.literal("message_stop")}),r.z.object({type:r.z.literal("ping")})]))),_=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({signature:r.z.string().optional(),redactedData:r.z.string().optional()}))),b=r.z.object({containerUpload:r.z.boolean().optional(),citations:r.z.object({enabled:r.z.boolean()}).optional(),title:r.z.string().optional(),context:r.z.string().optional()}),z=r.z.object({clearAt:r.z.literal("next_user_message").optional(),effort:r.z.enum(["low","medium","high","xhigh","max"]).optional(),toolChanges:r.z.array(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("tool_addition"),toolName:r.z.string()}),r.z.object({type:r.z.literal("tool_removal"),toolName:r.z.string()})])).optional()}),v=r.z.object({sendReasoning:r.z.boolean().optional(),structuredOutputMode:r.z.enum(["outputFormat","jsonTool","auto"]).optional(),thinking:r.z.union([r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("adaptive"),display:r.z.enum(["omitted","summarized","updates"]).optional(),blockBinding:r.z.object({prefixMismatchBehavior:r.z.enum(["error","drop_block"])}).optional()}),r.z.object({type:r.z.literal("enabled"),budgetTokens:r.z.number().optional()}),r.z.object({type:r.z.literal("disabled")})]),r.z.object({type:r.z.never().optional(),blockBinding:r.z.object({prefixMismatchBehavior:r.z.enum(["error","drop_block"])})})]).optional(),disableParallelToolUse:r.z.boolean().optional(),cacheControl:r.z.object({type:r.z.literal("ephemeral"),ttl:r.z.union([r.z.literal("5m"),r.z.literal("1h")]).optional()}).optional(),metadata:r.z.object({userId:r.z.string().optional()}).optional(),mcpServers:r.z.array(r.z.object({type:r.z.literal("url"),name:r.z.string(),url:r.z.string(),authorizationToken:r.z.string().nullish(),toolConfiguration:r.z.object({enabled:r.z.boolean().nullish(),allowedTools:r.z.array(r.z.string()).nullish()}).nullish()})).optional(),container:r.z.object({id:r.z.string().optional(),skills:r.z.array(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("anthropic"),skillId:r.z.string(),version:r.z.string().optional()}),r.z.object({type:r.z.literal("custom"),providerReference:r.z.record(r.z.string(),r.z.string()),version:r.z.string().optional()})])).optional()}).optional(),toolStreaming:r.z.boolean().optional(),effort:r.z.enum(["low","medium","high","xhigh","max"]).optional(),taskBudget:r.z.object({type:r.z.literal("tokens"),total:r.z.number().int().min(2e4),remaining:r.z.number().int().min(0).optional()}).optional(),speed:r.z.enum(["fast","standard"]).optional(),serviceTier:r.z.enum(["auto","standard_only"]).optional(),inferenceGeo:r.z.enum(["us","global"]).optional(),fallbacks:r.z.union([r.z.literal("default"),r.z.array(r.z.object({model:r.z.string(),max_tokens:r.z.number().int().optional(),thinking:r.z.record(r.z.string(),r.z.unknown()).optional(),output_config:r.z.record(r.z.string(),r.z.unknown()).optional(),speed:r.z.enum(["fast","standard"]).optional()}))]).optional(),anthropicBeta:r.z.array(r.z.string()).optional(),safeguards:r.z.array(r.z.object({type:r.z.literal("dangerous_tool_use"),classifierContext:r.z.record(r.z.string(),r.z.unknown()).optional()})).optional(),compaction:r.z.object({type:r.z.literal("summarize"),instructions:r.z.string().optional()}).optional(),contextManagement:r.z.object({edits:r.z.array(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("clear_tool_uses_20250919"),trigger:r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("input_tokens"),value:r.z.number()}),r.z.object({type:r.z.literal("tool_uses"),value:r.z.number()})]).optional(),keep:r.z.object({type:r.z.literal("tool_uses"),value:r.z.number()}).optional(),clearAtLeast:r.z.object({type:r.z.literal("input_tokens"),value:r.z.number()}).optional(),clearToolInputs:r.z.boolean().optional(),excludeTools:r.z.array(r.z.string()).optional()}),r.z.object({type:r.z.literal("clear_thinking_20251015"),keep:r.z.union([r.z.literal("all"),r.z.object({type:r.z.literal("thinking_turns"),value:r.z.number()})]).optional()}),r.z.object({type:r.z.literal("compact_20260112"),trigger:r.z.object({type:r.z.literal("input_tokens"),value:r.z.number()}).optional(),pauseAfterCompaction:r.z.boolean().optional(),instructions:r.z.string().optional()})]))}).optional()}),w=class{constructor(){this.breakpointCount=0,this.warnings=[]}getCacheControl(e,t){let o,n=(o=e?.anthropic,o?.cacheControl??o?.cache_control);if(n)return t.canCache?(this.breakpointCount++,this.breakpointCount>4)?void this.warnings.push({type:"unsupported",feature:"cacheControl breakpoint limit",details:`Maximum 4 cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`}):n:void this.warnings.push({type:"unsupported",feature:"cache_control on non-cacheable context",details:`cache_control cannot be set on ${t.type}. It will be ignored.`})}getWarnings(){return this.warnings}},x=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({model:r.z.string(),maxUses:r.z.number().optional(),maxTokens:r.z.number().int().min(1024).optional(),caching:r.z.object({type:r.z.literal("ephemeral"),ttl:r.z.union([r.z.literal("5m"),r.z.literal("1h")])}).optional()}))),k=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("advisor_result"),text:r.z.string(),stopReason:r.z.string().optional()}),r.z.object({type:r.z.literal("advisor_redacted_result"),encryptedContent:r.z.string(),stopReason:r.z.string().optional()}),r.z.object({type:r.z.literal("advisor_tool_result_error"),errorCode:r.z.string()})]))),I=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({}).strict())),T=(0,o.createProviderExecutedToolFactory)({id:"anthropic.advisor_20260301",inputSchema:I,outputSchema:k,supportsDeferredResults:!0}),S=["screenshot","zoom","left_click","right_click","middle_click","double_click","triple_click","left_click_drag","mouse_move","left_mouse_down","left_mouse_up","cursor_position","scroll","type","key","hold_key","wait"],j=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({action:r.z.enum(S),coordinate:r.z.tuple([r.z.number().int(),r.z.number().int()]).optional(),duration:r.z.number().optional(),region:r.z.tuple([r.z.number().int(),r.z.number().int(),r.z.number().int(),r.z.number().int()]).optional(),repeat:r.z.number().int().optional(),scroll_amount:r.z.number().optional(),scroll_direction:r.z.enum(["up","down","left","right"]).optional(),start_coordinate:r.z.tuple([r.z.number().int(),r.z.number().int()]).optional(),text:r.z.string().optional()}))),R=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({configs:r.z.partialRecord(r.z.enum(S),r.z.object({enabled:r.z.boolean().optional(),deferLoading:r.z.boolean().optional()})).optional()}))),C=(0,o.createProviderDefinedToolFactory)({id:"anthropic.computer_toolset_20260801",inputSchema:j}),O=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({maxCharacters:r.z.number().optional()}))),E=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({command:r.z.enum(["view","create","str_replace","insert"]),path:r.z.string(),file_text:r.z.string().optional(),insert_line:r.z.number().int().optional(),new_str:r.z.string().optional(),insert_text:r.z.string().optional(),old_str:r.z.string().optional(),view_range:r.z.array(r.z.number().int()).optional()}))),A=(0,o.createProviderDefinedToolFactory)({id:"anthropic.text_editor_20250728",inputSchema:E}),M=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({maxUses:r.z.number().optional(),allowedDomains:r.z.array(r.z.string()).optional(),blockedDomains:r.z.array(r.z.string()).optional(),userLocation:r.z.object({type:r.z.literal("approximate"),city:r.z.string().optional(),region:r.z.string().optional(),country:r.z.string().optional(),timezone:r.z.string().optional()}).optional(),responseInclusion:r.z.enum(["full","excluded"]).optional()}))),$=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.array(r.z.object({url:r.z.string(),title:r.z.string().nullable(),pageAge:r.z.string().nullable(),encryptedContent:r.z.string(),type:r.z.literal("web_search_result")})))),q=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({query:r.z.string()}))),U=(0,o.createProviderExecutedToolFactory)({id:"anthropic.web_search_20260318",inputSchema:q,outputSchema:$,supportsDeferredResults:!0}),N=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({maxUses:r.z.number().optional(),allowedDomains:r.z.array(r.z.string()).optional(),blockedDomains:r.z.array(r.z.string()).optional(),userLocation:r.z.object({type:r.z.literal("approximate"),city:r.z.string().optional(),region:r.z.string().optional(),country:r.z.string().optional(),timezone:r.z.string().optional()}).optional()}))),P=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.array(r.z.object({url:r.z.string(),title:r.z.string().nullable(),pageAge:r.z.string().nullable(),encryptedContent:r.z.string(),type:r.z.literal("web_search_result")})))),L=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({query:r.z.string()}))),D=(0,o.createProviderExecutedToolFactory)({id:"anthropic.web_search_20260209",inputSchema:L,outputSchema:P,supportsDeferredResults:!0}),F=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({maxUses:r.z.number().optional(),allowedDomains:r.z.array(r.z.string()).optional(),blockedDomains:r.z.array(r.z.string()).optional(),userLocation:r.z.object({type:r.z.literal("approximate"),city:r.z.string().optional(),region:r.z.string().optional(),country:r.z.string().optional(),timezone:r.z.string().optional()}).optional()}))),H=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.array(r.z.object({url:r.z.string(),title:r.z.string().nullable(),pageAge:r.z.string().nullable(),encryptedContent:r.z.string(),type:r.z.literal("web_search_result")})))),B=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({query:r.z.string()}))),V=(0,o.createProviderExecutedToolFactory)({id:"anthropic.web_search_20250305",inputSchema:B,outputSchema:H,supportsDeferredResults:!0}),J=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({maxUses:r.z.number().optional(),allowedDomains:r.z.array(r.z.string()).optional(),blockedDomains:r.z.array(r.z.string()).optional(),citations:r.z.object({enabled:r.z.boolean()}).optional(),maxContentTokens:r.z.number().optional(),useCache:r.z.boolean().optional(),responseInclusion:r.z.enum(["full","excluded"]).optional()}))),G=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({type:r.z.literal("web_fetch_result"),url:r.z.string(),content:r.z.object({type:r.z.literal("document"),title:r.z.string().nullable(),citations:r.z.object({enabled:r.z.boolean()}).optional(),source:r.z.union([r.z.object({type:r.z.literal("base64"),mediaType:r.z.literal("application/pdf"),data:r.z.string()}),r.z.object({type:r.z.literal("text"),mediaType:r.z.literal("text/plain"),data:r.z.string()})])}),retrievedAt:r.z.string().nullable()}))),W=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({url:r.z.string()}))),K=(0,o.createProviderExecutedToolFactory)({id:"anthropic.web_fetch_20260318",inputSchema:W,outputSchema:G,supportsDeferredResults:!0}),Z=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({maxUses:r.z.number().optional(),allowedDomains:r.z.array(r.z.string()).optional(),blockedDomains:r.z.array(r.z.string()).optional(),citations:r.z.object({enabled:r.z.boolean()}).optional(),maxContentTokens:r.z.number().optional()}))),X=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({type:r.z.literal("web_fetch_result"),url:r.z.string(),content:r.z.object({type:r.z.literal("document"),title:r.z.string().nullable(),citations:r.z.object({enabled:r.z.boolean()}).optional(),source:r.z.union([r.z.object({type:r.z.literal("base64"),mediaType:r.z.literal("application/pdf"),data:r.z.string()}),r.z.object({type:r.z.literal("text"),mediaType:r.z.literal("text/plain"),data:r.z.string()})])}),retrievedAt:r.z.string().nullable()}))),Y=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({url:r.z.string()}))),Q=(0,o.createProviderExecutedToolFactory)({id:"anthropic.web_fetch_20260209",inputSchema:Y,outputSchema:X,supportsDeferredResults:!0}),ee=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({maxUses:r.z.number().optional(),allowedDomains:r.z.array(r.z.string()).optional(),blockedDomains:r.z.array(r.z.string()).optional(),citations:r.z.object({enabled:r.z.boolean()}).optional(),maxContentTokens:r.z.number().optional()}))),et=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({type:r.z.literal("web_fetch_result"),url:r.z.string(),content:r.z.object({type:r.z.literal("document"),title:r.z.string().nullable(),citations:r.z.object({enabled:r.z.boolean()}).optional(),source:r.z.union([r.z.object({type:r.z.literal("base64"),mediaType:r.z.literal("application/pdf"),data:r.z.string()}),r.z.object({type:r.z.literal("text"),mediaType:r.z.literal("text/plain"),data:r.z.string()})])}),retrievedAt:r.z.string().nullable()}))),eo=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({url:r.z.string()}))),en=(0,o.createProviderExecutedToolFactory)({id:"anthropic.web_fetch_20250910",inputSchema:eo,outputSchema:et,supportsDeferredResults:!0});async function er({tools:e,toolChoice:n,disableParallelToolUse:r,cacheControlValidator:a,supportsStructuredOutput:i,supportsStrictTools:s,defaultEagerInputStreaming:l=!1,rejectsForcedToolUse:u=!1}){e=e?.length?e:void 0;let c=[],d=new Set,p=a||new w;if(null==e)return{tools:void 0,toolChoice:void 0,toolWarnings:c,betas:d};let m=[];for(let t of e)switch(t.type){case"function":{let e=p.getCacheControl(t.providerOptions,{type:"tool definition",canCache:!0}),o=t.providerOptions?.anthropic,n=o?.eagerInputStreaming??l,r=o?.deferLoading,a=o?.allowedCallers;s||null==t.strict||c.push({type:"unsupported",feature:"strict",details:`Tool '${t.name}' has strict: ${t.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`}),m.push({name:t.name,description:t.description,input_schema:t.inputSchema,cache_control:e,...n?{eager_input_streaming:!0}:{},...!0===s&&null!=t.strict?{strict:t.strict}:{},...null!=r?{defer_loading:r}:{},...null!=a?{allowed_callers:a}:{},...null!=t.inputExamples?{input_examples:t.inputExamples.map(e=>e.input)}:{}}),!0===i&&d.add("structured-outputs-2025-11-13"),(null!=t.inputExamples||null!=a)&&d.add("advanced-tool-use-2025-11-20");break}case"provider":switch(t.id){case"anthropic.code_execution_20250522":d.add("code-execution-2025-05-22"),m.push({type:"code_execution_20250522",name:"code_execution",cache_control:void 0});break;case"anthropic.code_execution_20250825":d.add("code-execution-2025-08-25"),m.push({type:"code_execution_20250825",name:"code_execution"});break;case"anthropic.code_execution_20260120":m.push({type:"code_execution_20260120",name:"code_execution"});break;case"anthropic.computer_20250124":d.add("computer-use-2025-01-24"),m.push({name:"computer",type:"computer_20250124",display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,cache_control:void 0});break;case"anthropic.computer_20251124":d.add("computer-use-2025-11-24"),m.push({name:"computer",type:"computer_20251124",display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,enable_zoom:t.args.enableZoom,cache_control:void 0});break;case"anthropic.computer_toolset_20260801":{let e=await (0,o.validateTypes)({value:t.args,schema:R}),n=null!=e.configs?Object.fromEntries(Object.entries(e.configs).map(([e,t])=>[e,{...t?.enabled!=null&&{enabled:t.enabled},...t?.deferLoading!=null&&{defer_loading:t.deferLoading}}])):void 0;m.push({type:"computer_toolset_20260801",...null!=n&&{configs:n},cache_control:void 0});break}case"anthropic.computer_20241022":d.add("computer-use-2024-10-22"),m.push({name:"computer",type:"computer_20241022",display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,cache_control:void 0});break;case"anthropic.text_editor_20250124":d.add("computer-use-2025-01-24"),m.push({name:"str_replace_editor",type:"text_editor_20250124",cache_control:void 0});break;case"anthropic.text_editor_20241022":d.add("computer-use-2024-10-22"),m.push({name:"str_replace_editor",type:"text_editor_20241022",cache_control:void 0});break;case"anthropic.text_editor_20250429":d.add("computer-use-2025-01-24"),m.push({name:"str_replace_based_edit_tool",type:"text_editor_20250429",cache_control:void 0});break;case"anthropic.text_editor_20250728":{let e=await (0,o.validateTypes)({value:t.args,schema:O});m.push({name:"str_replace_based_edit_tool",type:"text_editor_20250728",max_characters:e.maxCharacters,cache_control:void 0});break}case"anthropic.bash_20250124":d.add("computer-use-2025-01-24"),m.push({name:"bash",type:"bash_20250124",cache_control:void 0});break;case"anthropic.bash_20241022":d.add("computer-use-2024-10-22"),m.push({name:"bash",type:"bash_20241022",cache_control:void 0});break;case"anthropic.memory_20250818":d.add("context-management-2025-06-27"),m.push({name:"memory",type:"memory_20250818"});break;case"anthropic.web_fetch_20250910":{d.add("web-fetch-2025-09-10");let e=await (0,o.validateTypes)({value:t.args,schema:ee});m.push({type:"web_fetch_20250910",name:"web_fetch",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,cache_control:void 0});break}case"anthropic.web_fetch_20260209":{d.add("code-execution-web-tools-2026-02-09");let e=await (0,o.validateTypes)({value:t.args,schema:Z});m.push({type:"web_fetch_20260209",name:"web_fetch",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,cache_control:void 0});break}case"anthropic.web_fetch_20260318":{let e=await (0,o.validateTypes)({value:t.args,schema:J});m.push({type:"web_fetch_20260318",name:"web_fetch",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,use_cache:e.useCache,response_inclusion:e.responseInclusion,cache_control:void 0});break}case"anthropic.web_search_20250305":{let e=await (0,o.validateTypes)({value:t.args,schema:F});m.push({type:"web_search_20250305",name:"web_search",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,cache_control:void 0});break}case"anthropic.web_search_20260209":{d.add("code-execution-web-tools-2026-02-09");let e=await (0,o.validateTypes)({value:t.args,schema:N});m.push({type:"web_search_20260209",name:"web_search",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,cache_control:void 0});break}case"anthropic.web_search_20260318":{let e=await (0,o.validateTypes)({value:t.args,schema:M});m.push({type:"web_search_20260318",name:"web_search",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,response_inclusion:e.responseInclusion,cache_control:void 0});break}case"anthropic.tool_search_regex_20251119":m.push({type:"tool_search_tool_regex_20251119",name:"tool_search_tool_regex"});break;case"anthropic.tool_search_bm25_20251119":m.push({type:"tool_search_tool_bm25_20251119",name:"tool_search_tool_bm25"});break;case"anthropic.advisor_20260301":{d.add("advisor-tool-2026-03-01");let e=await (0,o.validateTypes)({value:t.args,schema:x});m.push({type:"advisor_20260301",name:"advisor",model:e.model,...void 0!==e.maxUses&&{max_uses:e.maxUses},...void 0!==e.maxTokens&&{max_tokens:e.maxTokens},...void 0!==e.caching&&{caching:e.caching}});break}default:c.push({type:"unsupported",feature:`provider-defined tool ${t.id}`})}break;default:c.push({type:"unsupported",feature:`tool ${t}`})}if(null==n)return{tools:m,toolChoice:r?{type:"auto",disable_parallel_tool_use:r}:void 0,toolWarnings:c,betas:d};let h=n.type;switch(h){case"auto":return{tools:m,toolChoice:{type:"auto",disable_parallel_tool_use:r},toolWarnings:c,betas:d};case"required":if(u)return c.push({type:"unsupported",feature:"toolChoice",details:"toolChoice 'required' is not supported by this model because it rejects forced tool use. Using 'auto' instead. Instruct the model to use a tool in the prompt and verify that a tool call was made."}),{tools:m,toolChoice:{type:"auto",disable_parallel_tool_use:r},toolWarnings:c,betas:d};return{tools:m,toolChoice:{type:"any",disable_parallel_tool_use:r},toolWarnings:c,betas:d};case"none":return{tools:void 0,toolChoice:void 0,toolWarnings:c,betas:d};case"tool":if(u)return c.push({type:"unsupported",feature:"toolChoice",details:`toolChoice 'tool' is not supported by this model because it rejects forced tool use. Only the '${n.toolName}' tool is sent with 'auto' tool choice. Instruct the model to use the tool in the prompt and verify that a tool call was made.`}),{tools:m.filter(e=>"name"in e&&e.name===n.toolName),toolChoice:{type:"auto",disable_parallel_tool_use:r},toolWarnings:c,betas:d};return{tools:m,toolChoice:{type:"tool",name:n.toolName,disable_parallel_tool_use:r},toolWarnings:c,betas:d};default:throw new t.UnsupportedFunctionalityError({functionality:`tool choice type: ${h}`})}}function ea({usage:e,rawUsage:t}){let o,n,r=e.cache_creation_input_tokens??0,a=e.cache_read_input_tokens??0,i=e.output_tokens_details?.thinking_tokens??void 0,s=e.iterations?.some(e=>"fallback_message"===e.type);if(e.iterations&&e.iterations.length>0&&!s){let t=e.iterations.filter(e=>"compaction"===e.type||"message"===e.type);if(t.length>0){let e=t.reduce((e,t)=>({input:e.input+t.input_tokens,output:e.output+t.output_tokens}),{input:0,output:0});o=e.input,n=e.output}else o=e.input_tokens,n=e.output_tokens}else o=e.input_tokens,n=e.output_tokens;return{inputTokens:{total:o+r+a,noCache:o,cacheRead:a,cacheWrite:r},outputTokens:{total:n,text:null==i?void 0:n-i,reasoning:i},raw:t??e}}var ei=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({type:r.z.literal("code_execution_result"),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number(),content:r.z.array(r.z.object({type:r.z.literal("code_execution_output"),file_id:r.z.string()})).optional().default([])}))),es=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({code:r.z.string()}))),el=(0,o.createProviderExecutedToolFactory)({id:"anthropic.code_execution_20250522",inputSchema:es,outputSchema:ei}),eu=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("code_execution_result"),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number(),content:r.z.array(r.z.object({type:r.z.literal("code_execution_output"),file_id:r.z.string()})).optional().default([])}),r.z.object({type:r.z.literal("bash_code_execution_result"),content:r.z.array(r.z.object({type:r.z.literal("bash_code_execution_output"),file_id:r.z.string()})),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number()}),r.z.object({type:r.z.literal("bash_code_execution_tool_result_error"),error_code:r.z.string()}),r.z.object({type:r.z.literal("text_editor_code_execution_tool_result_error"),error_code:r.z.string()}),r.z.object({type:r.z.literal("text_editor_code_execution_view_result"),content:r.z.string(),file_type:r.z.string(),num_lines:r.z.number().nullable(),start_line:r.z.number().nullable(),total_lines:r.z.number().nullable()}),r.z.object({type:r.z.literal("text_editor_code_execution_create_result"),is_file_update:r.z.boolean()}),r.z.object({type:r.z.literal("text_editor_code_execution_str_replace_result"),lines:r.z.array(r.z.string()).nullable(),new_lines:r.z.number().nullable(),new_start:r.z.number().nullable(),old_lines:r.z.number().nullable(),old_start:r.z.number().nullable()})]))),ec=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("programmatic-tool-call"),code:r.z.string()}),r.z.object({type:r.z.literal("bash_code_execution"),command:r.z.string()}),r.z.discriminatedUnion("command",[r.z.object({type:r.z.literal("text_editor_code_execution"),command:r.z.literal("view"),path:r.z.string()}),r.z.object({type:r.z.literal("text_editor_code_execution"),command:r.z.literal("create"),path:r.z.string(),file_text:r.z.string().nullish()}),r.z.object({type:r.z.literal("text_editor_code_execution"),command:r.z.literal("str_replace"),path:r.z.string(),old_str:r.z.string(),new_str:r.z.string()})])]))),ed=(0,o.createProviderExecutedToolFactory)({id:"anthropic.code_execution_20250825",inputSchema:ec,outputSchema:eu,supportsDeferredResults:!0}),ep=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("code_execution_result"),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number(),content:r.z.array(r.z.object({type:r.z.literal("code_execution_output"),file_id:r.z.string()})).optional().default([])}),r.z.object({type:r.z.literal("encrypted_code_execution_result"),encrypted_stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number(),content:r.z.array(r.z.object({type:r.z.literal("code_execution_output"),file_id:r.z.string()})).optional().default([])}),r.z.object({type:r.z.literal("bash_code_execution_result"),content:r.z.array(r.z.object({type:r.z.literal("bash_code_execution_output"),file_id:r.z.string()})),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number()}),r.z.object({type:r.z.literal("bash_code_execution_tool_result_error"),error_code:r.z.string()}),r.z.object({type:r.z.literal("text_editor_code_execution_tool_result_error"),error_code:r.z.string()}),r.z.object({type:r.z.literal("text_editor_code_execution_view_result"),content:r.z.string(),file_type:r.z.string(),num_lines:r.z.number().nullable(),start_line:r.z.number().nullable(),total_lines:r.z.number().nullable()}),r.z.object({type:r.z.literal("text_editor_code_execution_create_result"),is_file_update:r.z.boolean()}),r.z.object({type:r.z.literal("text_editor_code_execution_str_replace_result"),lines:r.z.array(r.z.string()).nullable(),new_lines:r.z.number().nullable(),new_start:r.z.number().nullable(),old_lines:r.z.number().nullable(),old_start:r.z.number().nullable()})]))),em=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("programmatic-tool-call"),code:r.z.string()}),r.z.object({type:r.z.literal("bash_code_execution"),command:r.z.string()}),r.z.discriminatedUnion("command",[r.z.object({type:r.z.literal("text_editor_code_execution"),command:r.z.literal("view"),path:r.z.string()}),r.z.object({type:r.z.literal("text_editor_code_execution"),command:r.z.literal("create"),path:r.z.string(),file_text:r.z.string().nullish()}),r.z.object({type:r.z.literal("text_editor_code_execution"),command:r.z.literal("str_replace"),path:r.z.string(),old_str:r.z.string(),new_str:r.z.string()})])]))),eh=(0,o.createProviderExecutedToolFactory)({id:"anthropic.code_execution_20260120",inputSchema:em,outputSchema:ep,supportsDeferredResults:!0}),eg=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.array(r.z.object({type:r.z.literal("tool_reference"),toolName:r.z.string()})))),ef=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({pattern:r.z.string(),limit:r.z.number().optional()}))),ey=(0,o.createProviderExecutedToolFactory)({id:"anthropic.tool_search_regex_20251119",inputSchema:ef,outputSchema:eg,supportsDeferredResults:!0});function e_(e){try{if("string"==typeof e)return(0,o.secureJsonParse)(e);if("object"==typeof e&&null!==e)return e}catch{let t=e?.errorCode;return{errorCode:"string"==typeof t?t:"unavailable"}}return{}}async function eb({prompt:e,sendReasoning:n,warnings:r,cacheControlValidator:a,toolNameMapping:i,toolsetNames:s={}}){let l,u=new Set,c=function(e){let t,o=[];for(let n of e){let{role:e}=n;switch(e){case"system":t?.type!=="system"&&(t={type:"system",messages:[]},o.push(t)),t.messages.push(n);break;case"assistant":t?.type!=="assistant"&&(t={type:"assistant",messages:[]},o.push(t)),t.messages.push(n);break;case"user":case"tool":t?.type!=="user"&&(t={type:"user",messages:[]},o.push(t)),t.messages.push(n);break;default:throw Error(`Unsupported role: ${e}`)}}return o}(e),d=a||new w,p=[];async function m(e){let t=await (0,o.parseProviderOptions)({provider:"anthropic",providerOptions:e,schema:b});return t?.citations?.enabled??!1}async function h(e){let t=await (0,o.parseProviderOptions)({provider:"anthropic",providerOptions:e,schema:b});return t?.containerUpload??!1}async function g(e){let t=await (0,o.parseProviderOptions)({provider:"anthropic",providerOptions:e,schema:b});return{title:t?.title,context:t?.context}}for(let e=0;e<c.length;e++){let a=c[e],y=e===c.length-1,b=a.type;switch(b){case"system":{let t=[];for(let{content:e,providerOptions:n}of a.messages){let r=await (0,o.parseProviderOptions)({provider:"anthropic",providerOptions:n,schema:z}),a=r?.toolChanges??[],s=[];for(let t of((""!==e||0===a.length&&r?.clearAt==null&&r?.effort==null)&&s.push({type:"text",text:e,cache_control:d.getCacheControl(n,{type:"system message",canCache:!0})}),a))s.push({type:t.type,tool:{type:"tool_reference",name:i.toProviderToolName(t.toolName)}});t.push({content:s,clearAt:r?.clearAt,effort:r?.effort,toolChangeCount:a.length})}let n=t.reduce((e,t)=>e+t.toolChangeCount,0),s=t.some(e=>null!=e.clearAt||null!=e.effort);if(0!==e&&(null!=l||0!==n||s))for(let e of(u.add("mid-conversation-system-2026-04-07"),t))p.push({role:"system",content:e.content,...null!=e.clearAt&&{clear_at:e.clearAt},...null!=e.effort&&{output_config:{effort:e.effort}}}),e.toolChangeCount>0&&u.add("mid-conversation-tool-changes-2026-07-01"),null!=e.clearAt&&u.add("mid-conversation-system-clear-at-2026-08-21"),null!=e.effort&&u.add("mid-conversation-output-config-2026-07-01");else{for(let e of(n>0&&r.push({type:"other",message:"tool changes on the initial system message are not supported by Anthropic. Configure the initial tool set via the tools option instead. The tool changes have been ignored."}),t))0===e.content.length&&null==e.clearAt&&null!=e.effort?(p.push({role:"system",content:[],output_config:{effort:e.effort}}),u.add("mid-conversation-output-config-2026-07-01")):(null!=e.clearAt||null!=e.effort)&&r.push({type:"other",message:"clearAt and effort on this initial system message are not supported by Anthropic. Use a separate effort-only system message with empty content to set effort. These options have been ignored."});l=t.flatMap(e=>e.content.filter(e=>"text"===e.type))}break}case"user":{let e=[];for(let n of a.messages){let{role:a,content:i}=n;switch(a){case"user":for(let r=0;r<i.length;r++){let a=i[r],s=r===i.length-1,l=d.getCacheControl(a.providerOptions,{type:"user message part",canCache:!0})??(s?d.getCacheControl(n.providerOptions,{type:"user message",canCache:!0}):void 0);switch(a.type){case"text":e.push({type:"text",text:a.text,cache_control:l});break;case"file":switch(a.data.type){case"reference":{let t=(0,o.resolveProviderReference)({reference:a.data.reference,provider:"anthropic"});u.add("files-api-2025-04-14"),await h(a.providerOptions)?e.push({type:"container_upload",file_id:t}):"image"===(0,o.getTopLevelMediaType)(a.mediaType)?e.push({type:"image",source:{type:"file",file_id:t},cache_control:l}):e.push({type:"document",source:{type:"file",file_id:t},cache_control:l});break}case"text":{let t=await m(a.providerOptions),o=await g(a.providerOptions);e.push({type:"document",source:{type:"text",media_type:"text/plain",data:a.data.text},title:o.title??a.filename,...o.context&&{context:o.context},...t&&{citations:{enabled:!0}},cache_control:l});break}case"url":case"data":{let n=(0,o.getTopLevelMediaType)(a.mediaType);if("image"===n)e.push({type:"image",source:"url"===a.data.type?{type:"url",url:a.data.url.toString()}:{type:"base64",media_type:(0,o.resolveFullMediaType)({part:a}),data:(0,o.convertToBase64)(a.data.data)},cache_control:l});else if("application"===n&&("url"===a.data.type?"application/pdf"===a.mediaType:"application/pdf"===(0,o.resolveFullMediaType)({part:a}))){u.add("pdfs-2024-09-25");let t=await m(a.providerOptions),n=await g(a.providerOptions);e.push({type:"document",source:"url"===a.data.type?{type:"url",url:a.data.url.toString()}:{type:"base64",media_type:"application/pdf",data:(0,o.convertToBase64)(a.data.data)},title:n.title??a.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:l})}else if("text/plain"===a.mediaType){var f;let t=await m(a.providerOptions),n=await g(a.providerOptions);e.push({type:"document",source:"url"===a.data.type?{type:"url",url:a.data.url.toString()}:{type:"text",media_type:"text/plain",data:"string"==typeof(f=a.data.data)?new TextDecoder().decode((0,o.convertBase64ToUint8Array)(f)):new TextDecoder().decode(f)},title:n.title??a.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:l})}else throw new t.UnsupportedFunctionalityError({functionality:`media type: ${a.mediaType}`})}}}}break;case"tool":for(let t=0;t<i.length;t++){let a,l=i[t];if("tool-approval-response"===l.type)continue;let c=l.output,p="providerOptions"in c?c.providerOptions:"content"===c.type?c.value.find(e=>null!=e.providerOptions)?.providerOptions:void 0,m=t===i.length-1,h=d.getCacheControl(l.providerOptions,{type:"tool result part",canCache:!0})??d.getCacheControl(p,{type:"tool result output",canCache:!0})??(m?d.getCacheControl(n.providerOptions,{type:"tool result message",canCache:!0}):void 0);switch(c.type){case"content":a=c.value.map(e=>{switch(e.type){case"text":return{type:"text",text:e.text};case"file":{let t=(0,o.getTopLevelMediaType)(e.mediaType);if("url"===e.data.type){if("image"===t)return{type:"image",source:{type:"url",url:e.data.url.toString()}};return{type:"document",source:{type:"url",url:e.data.url.toString()}}}if("data"===e.data.type){if("image"===t)return{type:"image",source:{type:"base64",media_type:(0,o.resolveFullMediaType)({part:e}),data:(0,o.convertToBase64)(e.data.data)}};if("application/pdf"===(0,o.resolveFullMediaType)({part:e}))return u.add("pdfs-2024-09-25"),{type:"document",source:{type:"base64",media_type:"application/pdf",data:(0,o.convertToBase64)(e.data.data)}};r.push({type:"other",message:`unsupported tool content part type: ${e.type} with media type: ${e.mediaType}`});return}r.push({type:"other",message:`unsupported tool content part type: ${e.type} with data type: ${e.data.type}`});return}case"custom":{let t=e.providerOptions?.anthropic;if(t?.type==="tool-reference")return{type:"tool_reference",tool_name:t.toolName};r.push({type:"other",message:"unsupported custom tool content part"});return}default:return void r.push({type:"other",message:`unsupported tool content part type: ${e.type}`})}}).filter(o.isNonNullable);break;case"text":case"error-text":a=c.value;break;case"execution-denied":a=c.reason??"Tool call execution denied.";break;default:a=JSON.stringify(c.value)}let g=ez({toolName:l.toolName,providerOptions:l.providerOptions,toolsetNames:s});e.push({type:"tool_result",tool_use_id:l.toolCallId,...null!=g&&{toolset_name:g},content:a,is_error:"error-text"===c.type||"error-json"===c.type||void 0,cache_control:h})}break;default:throw Error(`Unsupported role: ${a}`)}}p.push({role:"user",content:e});break}case"assistant":{let e=[],t=new Set;for(let l=0;l<a.messages.length;l++){let c=a.messages[l],p=l===a.messages.length-1,{content:m}=c;for(let a=0;a<m.length;a++){let l=m[a],h=a===m.length-1,g=d.getCacheControl(l.providerOptions,{type:"assistant message part",canCache:!0})??(h?d.getCacheControl(c.providerOptions,{type:"assistant message",canCache:!0}):void 0);switch(l.type){case"text":{let t=l.providerOptions?.anthropic;if(t?.type==="compaction"){if(""===l.text)break;"string"==typeof t.signature&&u.add("compact-2026-09-04"),e.push({type:"compaction",content:l.text,..."string"==typeof t.signature&&{signature:t.signature},cache_control:g})}else e.push({type:"text",text:y&&p&&h?l.text.trim():l.text,...t?.citations!=null&&{citations:t.citations},cache_control:g});break}case"reasoning":if(n){let t=await (0,o.parseProviderOptions)({provider:"anthropic",providerOptions:l.providerOptions,schema:_});null!=t?null!=t.signature?(d.getCacheControl(l.providerOptions,{type:"thinking block",canCache:!1}),e.push({type:"thinking",thinking:l.text,signature:t.signature})):null!=t.redactedData?(d.getCacheControl(l.providerOptions,{type:"redacted thinking block",canCache:!1}),e.push({type:"redacted_thinking",data:t.redactedData})):r.push({type:"other",message:"unsupported reasoning metadata"}):r.push({type:"other",message:"unsupported reasoning metadata"})}else r.push({type:"other",message:"sending reasoning content is disabled for this model"});break;case"tool-call":{let o=ev(l.providerOptions);if(l.providerExecuted){let n=i.toProviderToolName(l.toolName);if(l.providerOptions?.anthropic?.type==="mcp-tool-use"){t.add(l.toolCallId);let o=l.providerOptions?.anthropic?.serverName;if(null==o||"string"!=typeof o){r.push({type:"other",message:"mcp tool use server name is required and must be a string"});break}e.push({type:"mcp_tool_use",id:l.toolCallId,name:l.toolName,input:l.input,server_name:o,cache_control:g})}else if("code_execution"===n&&null!=l.input&&"object"==typeof l.input&&"type"in l.input&&"string"==typeof l.input.type&&("bash_code_execution"===l.input.type||"text_editor_code_execution"===l.input.type)){let{type:t,...n}=l.input;e.push({type:"server_tool_use",id:l.toolCallId,name:t,input:n,...o&&{caller:o},cache_control:g})}else if("code_execution"===n&&null!=l.input&&"object"==typeof l.input&&"type"in l.input&&"programmatic-tool-call"===l.input.type){let{type:t,...n}=l.input;e.push({type:"server_tool_use",id:l.toolCallId,name:"code_execution",input:n,...o&&{caller:o},cache_control:g})}else"code_execution"===n||"web_fetch"===n||"web_search"===n||"tool_search_tool_regex"===n||"tool_search_tool_bm25"===n?e.push({type:"server_tool_use",id:l.toolCallId,name:n,input:l.input,...o&&{caller:o},cache_control:g}):"advisor"===n?e.push({type:"server_tool_use",id:l.toolCallId,name:"advisor",input:{},...o&&{caller:o},cache_control:g}):r.push({type:"other",message:`provider executed tool call for tool ${l.toolName} is not supported`});break}let n=ez({toolName:l.toolName,providerOptions:l.providerOptions,toolsetNames:s});if(null!=n){let{action:t,...a}=ew(l.input);if("string"!=typeof t){r.push({type:"other",message:`toolset tool call for tool ${l.toolName} is missing the action`});break}e.push({type:"tool_use",id:l.toolCallId,name:t,toolset_name:n,input:a,...o&&{caller:o},cache_control:g});break}e.push({type:"tool_use",id:l.toolCallId,name:l.toolName,input:ew(l.input),...o&&{caller:o},cache_control:g});break}case"tool-result":{let n=i.toProviderToolName(l.toolName),a=ev(l.providerOptions);if(t.has(l.toolCallId)){let t=l.output;if("json"!==t.type&&"error-json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${l.toolName} is not supported`});break}e.push({type:"mcp_tool_result",tool_use_id:l.toolCallId,is_error:"error-json"===t.type,content:t.value,cache_control:g})}else if("code_execution"===n){let t=l.output;if("error-text"===t.type||"error-json"===t.type){let n={};try{"string"==typeof t.value?n=(0,o.secureJsonParse)(t.value):"object"==typeof t.value&&null!==t.value&&(n=t.value)}catch{}"code_execution_tool_result_error"===n.type?e.push({type:"code_execution_tool_result",tool_use_id:l.toolCallId,content:{type:"code_execution_tool_result_error",error_code:n.errorCode??"unknown"},cache_control:g}):e.push({type:"bash_code_execution_tool_result",tool_use_id:l.toolCallId,cache_control:g,content:{type:"bash_code_execution_tool_result_error",error_code:n.errorCode??"unknown"}});break}if("json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${l.toolName} is not supported`});break}if(null==t.value||"object"!=typeof t.value||!("type"in t.value)||"string"!=typeof t.value.type){r.push({type:"other",message:`provider executed tool result output value is not a valid code execution result for tool ${l.toolName}`});break}if("code_execution_result"===t.value.type){let n=await (0,o.validateTypes)({value:t.value,schema:ei});e.push({type:"code_execution_tool_result",tool_use_id:l.toolCallId,content:{type:n.type,stdout:n.stdout,stderr:n.stderr,return_code:n.return_code,content:n.content??[]},cache_control:g})}else if("encrypted_code_execution_result"===t.value.type){let n=await (0,o.validateTypes)({value:t.value,schema:ep});"encrypted_code_execution_result"===n.type&&e.push({type:"code_execution_tool_result",tool_use_id:l.toolCallId,content:{type:n.type,encrypted_stdout:n.encrypted_stdout,stderr:n.stderr,return_code:n.return_code,content:n.content??[]},cache_control:g})}else{let n=await (0,o.validateTypes)({value:t.value,schema:eu});"code_execution_result"===n.type?e.push({type:"code_execution_tool_result",tool_use_id:l.toolCallId,content:{type:n.type,stdout:n.stdout,stderr:n.stderr,return_code:n.return_code,content:n.content??[]},cache_control:g}):"bash_code_execution_result"===n.type||"bash_code_execution_tool_result_error"===n.type?e.push({type:"bash_code_execution_tool_result",tool_use_id:l.toolCallId,cache_control:g,content:"bash_code_execution_result"===n.type?{type:n.type,stdout:n.stdout,stderr:n.stderr,return_code:n.return_code,content:n.content}:n}):e.push({type:"text_editor_code_execution_tool_result",tool_use_id:l.toolCallId,cache_control:g,content:n})}break}if("web_fetch"===n){let t=l.output;if("error-json"===t.type){e.push({type:"web_fetch_tool_result",tool_use_id:l.toolCallId,content:{type:"web_fetch_tool_result_error",error_code:e_(t.value).errorCode??"unavailable"},...a&&{caller:a},cache_control:g});break}if("json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${l.toolName} is not supported`});break}let n=await (0,o.validateTypes)({value:t.value,schema:et});e.push({type:"web_fetch_tool_result",tool_use_id:l.toolCallId,content:{type:"web_fetch_result",url:n.url,retrieved_at:n.retrievedAt,content:{type:"document",title:n.content.title,citations:n.content.citations,source:{type:n.content.source.type,media_type:n.content.source.mediaType,data:n.content.source.data}}},...a&&{caller:a},cache_control:g});break}if("web_search"===n){let t=l.output;if("error-json"===t.type){e.push({type:"web_search_tool_result",tool_use_id:l.toolCallId,content:{type:"web_search_tool_result_error",error_code:e_(t.value).errorCode??"unavailable"},...a&&{caller:a},cache_control:g});break}if("json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${l.toolName} is not supported`});break}let n=await (0,o.validateTypes)({value:t.value,schema:H});e.push({type:"web_search_tool_result",tool_use_id:l.toolCallId,content:n.map(e=>({url:e.url,title:e.title,page_age:e.pageAge,encrypted_content:e.encryptedContent,type:e.type})),...a&&{caller:a},cache_control:g});break}if("tool_search_tool_regex"===n||"tool_search_tool_bm25"===n){let t=l.output;if("json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${l.toolName} is not supported`});break}let n=(await (0,o.validateTypes)({value:t.value,schema:eg})).map(e=>({type:"tool_reference",tool_name:e.toolName}));e.push({type:"tool_search_tool_result",tool_use_id:l.toolCallId,content:{type:"tool_search_tool_search_result",tool_references:n},cache_control:g});break}if("advisor"===n){let t=l.output;if("json"!==t.type&&"error-json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${l.toolName} is not supported`});break}let n=await (0,o.validateTypes)({value:t.value,schema:k});"advisor_result"===n.type?e.push({type:"advisor_tool_result",tool_use_id:l.toolCallId,content:{type:"advisor_result",text:n.text,...void 0!==n.stopReason&&{stop_reason:n.stopReason}},cache_control:g}):"advisor_redacted_result"===n.type?e.push({type:"advisor_tool_result",tool_use_id:l.toolCallId,content:{type:"advisor_redacted_result",encrypted_content:n.encryptedContent,...void 0!==n.stopReason&&{stop_reason:n.stopReason}},cache_control:g}):e.push({type:"advisor_tool_result",tool_use_id:l.toolCallId,content:{type:"advisor_tool_result_error",error_code:n.errorCode},cache_control:g});break}r.push({type:"other",message:`provider executed tool result for tool ${l.toolName} is not supported`})}}}}e.length>0&&p.push({role:"assistant",content:function(e){let t=[],o=[];function n(){t.push(...o.filter(e=>"tool_use"!==e.type),...o.filter(e=>"tool_use"===e.type)),o=[]}for(let r of e)"thinking"===r.type||"redacted_thinking"===r.type?(n(),t.push(r)):o.push(r);return n(),t}(e)});break}default:throw Error(`content type: ${b}`)}}return{prompt:{system:l,messages:p},betas:u}}function ez({toolName:e,providerOptions:t,toolsetNames:o}){let n=o[e];if(null!=n)return n;let r=t?.anthropic?.toolsetName;return"string"==typeof r?r:void 0}function ev(e){let t=e?.anthropic?.caller;return(t?.type==="code_execution_20250825"||t?.type==="code_execution_20260120")&&t.toolId?{type:t.type,tool_id:t.toolId}:t?.type==="direct"?{type:"direct"}:void 0}function ew(e){return"object"!=typeof e||null===e||Array.isArray(e)?{rawInvalidInput:e}:e}function ex({finishReason:e,isJsonResponseFromTool:t}){switch(e){case"pause_turn":case"end_turn":case"stop_sequence":return"stop";case"refusal":return"content-filter";case"tool_use":return t?"stop":"tool-calls";case"max_tokens":case"model_context_window_exceeded":return"length";default:return"other"}}var ek=new Set(["date-time","time","date","duration","email","hostname","uri","ipv4","ipv6","uuid"]),eI=["minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","minLength","maxLength","pattern","minItems","maxItems","uniqueItems","minProperties","maxProperties","not"];function eT(e){return"boolean"!=typeof e&&(0,o.isRecord)(e)?eS(e):e}function eS(e){var t;let o,n={};if(null!=e.$ref)return{$ref:e.$ref};null!=e.$schema&&(n.$schema=e.$schema),null!=e.$id&&(n.$id=e.$id),null!=e.title&&(n.title=e.title),null!=e.description&&(n.description=e.description),void 0!==e.default&&(n.default=e.default),void 0!==e.const&&(n.const=e.const),null!=e.enum&&(n.enum=e.enum),null!=e.type&&(n.type=e.type),null!=e.anyOf?n.anyOf=e.anyOf.map(eT):null!=e.oneOf&&(n.anyOf=e.oneOf.map(eT)),null!=e.allOf&&(n.allOf=e.allOf.map(eT)),null!=e.definitions&&(n.definitions=Object.fromEntries(Object.entries(e.definitions).map(([e,t])=>[e,eT(t)]))),null!=e.$defs&&(n.$defs=Object.fromEntries(Object.entries(e.$defs).map(([e,t])=>[e,eT(t)]))),("object"===e.type||null!=e.properties)&&(null!=e.properties&&(n.properties=Object.fromEntries(Object.entries(e.properties).map(([e,t])=>[e,eT(t)]))),n.additionalProperties=!1,null!=e.required&&(n.required=e.required)),null!=e.items&&(n.items=Array.isArray(e.items)?e.items.map(eT):eT(e.items)),"string"==typeof e.format&&ek.has(e.format)&&(n.format=e.format);let r=(t=e,o=eI.flatMap(e=>{var o;let n=t[e];return null==n||!1===n?[]:`${e.replace(/[A-Z]/g,e=>` ${e.toLowerCase()}`)}: ${"string"==typeof(o=n)?o:JSON.stringify(o)}`}),"string"!=typeof t.format||ek.has(t.format)||o.push(`format: ${t.format}`),0===o.length?void 0:`${o.join("; ")}.`);return null!=r&&(n.description=null==n.description?r:`${n.description}
|
|
2
2
|
${r}`),n}function ej(e,t,o){if("web_search_result_location"===e.type)return{type:"source",sourceType:"url",id:o(),url:e.url,title:e.title??void 0,providerMetadata:{anthropic:{citedText:e.cited_text,encryptedIndex:e.encrypted_index}}};if("page_location"!==e.type&&"char_location"!==e.type)return;let n=t[e.document_index];if(n)return{type:"source",sourceType:"document",id:o(),mediaType:n.mediaType,title:e.document_title??n.title,filename:n.filename,providerMetadata:{anthropic:"page_location"===e.type?{citedText:e.cited_text,startPageNumber:e.start_page_number,endPageNumber:e.end_page_number}:{citedText:e.cited_text,startCharIndex:e.start_char_index,endCharIndex:e.end_char_index}}}}function eR(e){return null==e?void 0:{type:e.type,toolId:"tool_id"in e?e.tool_id:void 0}}function eC(e){let t=eR(e);return null==t?{}:{providerMetadata:{anthropic:{caller:t}}}}function eO({memberName:e,input:t}){return{action:e,..."object"==typeof t&&null!==t&&!Array.isArray(t)?t:{}}}var eE=class e{constructor(e,t){this.specificationVersion="v4",this.modelId=e,this.config=t,this.generateId=t.generateId??o.generateId}static[a.WORKFLOW_SERIALIZE](e){return(0,o.serializeModelOptions)({modelId:e.modelId,config:e.config})}static[a.WORKFLOW_DESERIALIZE](t){return new e(t.modelId,t.config)}supportsUrl(e){return"https:"===e.protocol}get provider(){return this.config.provider}get supportedUrls(){return this.config.supportedUrls?.()??{}}static async prepareRequest({modelId:e,config:n,options:{userSuppliedBetas:r,prompt:a,maxOutputTokens:i,temperature:s,topP:l,topK:u,frequencyPenalty:c,presencePenalty:d,stopSequences:p,responseFormat:m,seed:h,tools:g,toolChoice:f,reasoning:y,providerOptions:_,stream:b}}){var z;let x,k=[];null!=c&&k.push({type:"unsupported",feature:"frequencyPenalty"}),null!=d&&k.push({type:"unsupported",feature:"presencePenalty"}),null!=h&&k.push({type:"unsupported",feature:"seed"}),null!=s&&s>1?(k.push({type:"unsupported",feature:"temperature",details:`${s} exceeds anthropic maximum of 1.0. clamped to 1.0`}),s=1):null!=s&&s<0&&(k.push({type:"unsupported",feature:"temperature",details:`${s} is below anthropic minimum of 0. clamped to 0`}),s=0),m?.type==="json"&&null==m.schema&&k.push({type:"unsupported",feature:"responseFormat",details:"JSON response format requires a schema. The response format is ignored."});let I=-1===(x=(z=n.provider).indexOf("."))?z:z.substring(0,x),T=await (0,o.parseProviderOptions)({provider:"anthropic",providerOptions:_,schema:v}),S="anthropic"!==I?await (0,o.parseProviderOptions)({provider:I,providerOptions:_,schema:v}):null,j=null!=S,R=Object.assign({},T??{},S??{}),{maxOutputTokens:C,supportsStructuredOutput:O,supportsAdaptiveThinking:E,rejectsSamplingParameters:A,supportsXhighEffort:M,rejectsThinkingDisabledAboveHighEffort:$,rejectsThinkingDisabled:q,rejectsForcedToolUse:U,isKnownModel:N}=function(e){if(e.includes("claude-opus-5-5"))return{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!0,rejectsThinkingDisabled:!0,rejectsForcedToolUse:!0,isKnownModel:!0};if(e.includes("claude-opus-5"))return{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!0,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,isKnownModel:!0};if(e.includes("claude-fable-5-1"))return{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!0,rejectsForcedToolUse:!0,isKnownModel:!0};if(e.includes("claude-fable-5"))return{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!0,rejectsForcedToolUse:!1,isKnownModel:!0};if(e.includes("claude-opus-4-8")||e.includes("claude-opus-4-7")||e.includes("claude-sonnet-5"))return{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,isKnownModel:!0};else if(e.includes("claude-sonnet-4-6")||e.includes("claude-opus-4-6"))return{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,isKnownModel:!0};else if(e.includes("claude-sonnet-4-5")||e.includes("claude-opus-4-5")||e.includes("claude-haiku-4-5"))return{maxOutputTokens:64e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,isKnownModel:!0};else if(e.includes("claude-opus-4-1"))return{maxOutputTokens:32e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,isKnownModel:!0};else if(/claude-sonnet-4(?:-|@)/.test(e))return{maxOutputTokens:64e3,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,isKnownModel:!0};else if(/claude-opus-4(?:-|@)/.test(e))return{maxOutputTokens:32e3,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,isKnownModel:!0};else if(e.includes("claude-3-haiku"))return{maxOutputTokens:4096,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,isKnownModel:!0};else if(/claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(e))return{maxOutputTokens:4096,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,isKnownModel:!1};else if(e.includes("claude-"))return{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!0,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,isKnownModel:!1};else return{maxOutputTokens:4096,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,isKnownModel:!1}}(e);N||null!=i||k.push({type:"compatibility",feature:"maxOutputTokens",details:`The model "${e}" is unknown. The max output tokens have been limited to ${C}. Set maxOutputTokens explicitly to override this limit.`}),A&&(null!=s&&(k.push({type:"unsupported",feature:"temperature",details:`temperature is not supported by ${e} and will be ignored`}),s=void 0),null!=u&&(k.push({type:"unsupported",feature:"topK",details:`topK is not supported by ${e} and will be ignored`}),u=void 0),null!=l&&(k.push({type:"unsupported",feature:"topP",details:`topP is not supported by ${e} and will be ignored`}),l=void 0));let P=N||e.includes("claude-"),L=(n.supportsNativeStructuredOutput??!0)&&O,D=(n.supportsStrictTools??!0)&&O,F=R?.structuredOutputMode??"auto",H="outputFormat"===F||"auto"===F&&L;!H&&U&&L&&m?.type==="json"&&null!=m.schema&&(k.push({type:"unsupported",feature:"providerOptions.anthropic.structuredOutputMode",details:`structuredOutputMode 'jsonTool' is not supported by ${e} because it rejects forced tool use. Using 'outputFormat' instead.`}),H=!0);let B=m?.type!=="json"||null==m.schema||H?void 0:{type:"function",name:"json",description:"Respond with a JSON object.",inputSchema:m.schema};null!=B&&R?.disableParallelToolUse===!1&&k.push({type:"unsupported",feature:"providerOptions.anthropic.disableParallelToolUse",details:"`disableParallelToolUse: false` is ignored when using the JSON response tool. Parallel tool use is disabled to ensure a single coherent JSON tool call."});let V=R?.contextManagement,J=R?.compaction;if(null!=V&&null!=J)throw new t.InvalidArgumentError({argument:"providerOptions",message:"Anthropic provider options `compaction` and `contextManagement` cannot be used together."});let G=new w,W=(0,o.createToolNameMapping)({tools:g,providerToolNames:{"anthropic.code_execution_20250522":"code_execution","anthropic.code_execution_20250825":"code_execution","anthropic.code_execution_20260120":"code_execution","anthropic.computer_20241022":"computer","anthropic.computer_20250124":"computer","anthropic.computer_20251124":"computer","anthropic.computer_toolset_20260801":"computer","anthropic.text_editor_20241022":"str_replace_editor","anthropic.text_editor_20250124":"str_replace_editor","anthropic.text_editor_20250429":"str_replace_based_edit_tool","anthropic.text_editor_20250728":"str_replace_based_edit_tool","anthropic.bash_20241022":"bash","anthropic.bash_20250124":"bash","anthropic.memory_20250818":"memory","anthropic.web_search_20250305":"web_search","anthropic.web_search_20260209":"web_search","anthropic.web_search_20260318":"web_search","anthropic.web_fetch_20250910":"web_fetch","anthropic.web_fetch_20260209":"web_fetch","anthropic.web_fetch_20260318":"web_fetch","anthropic.tool_search_regex_20251119":"tool_search_tool_regex","anthropic.tool_search_bm25_20251119":"tool_search_tool_bm25","anthropic.advisor_20260301":"advisor"}}),K=function(e){let t={};for(let o of e??[])"provider"===o.type&&"anthropic.computer_toolset_20260801"===o.id&&(t[o.name]="computer");return t}(g),{prompt:Z,betas:X}=await eb({prompt:a,sendReasoning:R?.sendReasoning??!0,warnings:k,cacheControlValidator:G,toolNameMapping:W,toolsetNames:K});if((0,o.isCustomReasoning)(y)&&R?.effort==null){let t=function({reasoning:e,modelId:t,supportsAdaptiveThinking:n,supportsXhighEffort:r,rejectsThinkingDisabled:a,maxOutputTokensForModel:i,warnings:s}){if(!(0,o.isCustomReasoning)(e))return;if("none"===e)return a?(s.push({type:"compatibility",feature:"reasoning",details:`reasoning 'none' is not supported by ${t}; it always uses adaptive thinking. Using effort 'low' to minimize thinking instead.`}),{effort:"low"}):{thinking:{type:"disabled"}};if(n)return{thinking:{type:"adaptive",display:"summarized"},effort:(0,o.mapReasoningToProviderEffort)({reasoning:e,effortMap:{minimal:"low",low:"low",medium:"medium",high:"high",xhigh:r?"xhigh":"max"},warnings:s})};let l=(0,o.mapReasoningToProviderBudget)({reasoning:e,maxOutputTokens:i,maxReasoningBudget:i,warnings:s});if(null!=l)return{thinking:{type:"enabled",budgetTokens:l}}}({reasoning:y,modelId:e,supportsAdaptiveThinking:E,supportsXhighEffort:M,rejectsThinkingDisabled:q,maxOutputTokensForModel:C,warnings:k});null!=t&&(null==R.thinking&&(R.thinking=t.thinking),null!=t.effort&&R.thinking?.type!=="disabled"&&(R.effort=t.effort))}if(q&&R?.thinking!=null){let t=R.thinking;"disabled"===t.type?(k.push({type:"unsupported",feature:"providerOptions.anthropic.thinking",details:`thinking cannot be disabled for ${e}; it always uses adaptive thinking. The thinking setting has been removed. Lower 'effort' to reduce thinking.`}),R.thinking=void 0):"enabled"===t.type&&(k.push({type:"unsupported",feature:"providerOptions.anthropic.thinking",details:`budget-based thinking is not supported by ${e}; it always uses adaptive thinking. Using adaptive thinking instead. Use 'effort' to control how much the model thinks.`}),R.thinking={type:"adaptive"})}$&&R?.thinking?.type==="disabled"&&("xhigh"===R.effort||"max"===R.effort)&&(k.push({type:"unsupported",feature:"providerOptions.anthropic.effort",details:`effort '${R.effort}' is not supported by ${e} when thinking is disabled. The effort has been lowered to 'high'.`}),R.effort="high");let Y=R?.thinking?.type,Q="enabled"===Y||"adaptive"===Y,ee=R?.thinking!=null&&"blockBinding"in R.thinking?R.thinking.blockBinding:void 0,et=Q||"disabled"===Y||null!=ee,eo="enabled"===Y?R?.thinking?.budgetTokens:void 0,en="adaptive"===Y?R?.thinking?.display:void 0,ea=i??C,ei={model:e,max_tokens:ea,temperature:s,top_k:u,top_p:l,stop_sequences:p,...et&&{thinking:{...null!=Y&&{type:Y},...null!=eo&&{budget_tokens:eo},...null!=en&&{display:en},...null!=ee&&{block_binding:{prefix_mismatch_behavior:ee.prefixMismatchBehavior}}}},...(R?.effort||R?.taskBudget||H&&m?.type==="json"&&null!=m.schema)&&{output_config:{...R?.effort&&{effort:R.effort},...R?.taskBudget&&{task_budget:{type:R.taskBudget.type,total:R.taskBudget.total,...null!=R.taskBudget.remaining&&{remaining:R.taskBudget.remaining}}},...H&&m?.type==="json"&&null!=m.schema&&{format:{type:"json_schema",schema:eS(m.schema)}}}},...R?.speed&&{speed:R.speed},...R?.serviceTier&&{service_tier:R.serviceTier},...R?.inferenceGeo&&{inference_geo:R.inferenceGeo},...R?.fallbacks!=null&&("default"===R.fallbacks||R.fallbacks.length>0)&&{fallbacks:R.fallbacks},...R?.cacheControl&&{cache_control:R.cacheControl},...R?.metadata?.userId!=null&&{metadata:{user_id:R.metadata.userId}},...R?.mcpServers&&R.mcpServers.length>0&&{mcp_servers:R.mcpServers.map(e=>({type:e.type,name:e.name,url:e.url,authorization_token:e.authorizationToken,tool_configuration:e.toolConfiguration?{allowed_tools:e.toolConfiguration.allowedTools,enabled:e.toolConfiguration.enabled}:void 0}))},...R?.container&&{container:R.container.skills&&R.container.skills.length>0?{id:R.container.id,skills:R.container.skills.map(e=>({type:e.type,skill_id:"custom"===e.type?(0,o.resolveProviderReference)({reference:e.providerReference,provider:"anthropic"}):e.skillId,version:e.version}))}:R.container.id},system:Z.system,messages:Z.messages,...R?.safeguards&&R.safeguards.length>0&&{safeguards:R.safeguards.map(e=>({type:e.type,...void 0!==e.classifierContext&&{classifier_context:e.classifierContext}}))},...J&&{compaction:{type:J.type,...void 0!==J.instructions&&{instructions:J.instructions}}},...V&&{context_management:{edits:V.edits.map(e=>{let t=e.type;switch(t){case"clear_tool_uses_20250919":return{type:e.type,...void 0!==e.trigger&&{trigger:e.trigger},...void 0!==e.keep&&{keep:e.keep},...void 0!==e.clearAtLeast&&{clear_at_least:e.clearAtLeast},...void 0!==e.clearToolInputs&&{clear_tool_inputs:e.clearToolInputs},...void 0!==e.excludeTools&&{exclude_tools:e.excludeTools}};case"clear_thinking_20251015":return{type:e.type,...void 0!==e.keep&&{keep:e.keep}};case"compact_20260112":return{type:e.type,...void 0!==e.trigger&&{trigger:e.trigger},...void 0!==e.pauseAfterCompaction&&{pause_after_compaction:e.pauseAfterCompaction},...void 0!==e.instructions&&{instructions:e.instructions}};default:k.push({type:"other",message:`Unknown context management strategy: ${t}`});return}}).filter(e=>void 0!==e)}}};Q?("enabled"===Y&&null==eo&&(k.push({type:"compatibility",feature:"extended thinking",details:"thinking budget is required when thinking is enabled. using default budget of 1024 tokens."}),ei.thinking={type:"enabled",budget_tokens:1024},eo=1024),null!=ei.temperature&&(ei.temperature=void 0,k.push({type:"unsupported",feature:"temperature",details:"temperature is not supported when thinking is enabled"})),null!=u&&(ei.top_k=void 0,k.push({type:"unsupported",feature:"topK",details:"topK is not supported when thinking is enabled"})),null!=l&&(ei.top_p=void 0,k.push({type:"unsupported",feature:"topP",details:"topP is not supported when thinking is enabled"})),ei.max_tokens=ea+(eo??0)):P&&null!=l&&null!=s&&(k.push({type:"unsupported",feature:"topP",details:"topP is not supported when temperature is set. topP is ignored."}),ei.top_p=void 0),N&&ei.max_tokens>C&&(null!=i&&k.push({type:"unsupported",feature:"maxOutputTokens",details:`${ei.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${e} ${C} max output tokens. The max output tokens have been limited to ${C}.`}),ei.max_tokens=C),R?.mcpServers&&R.mcpServers.length>0&&X.add("mcp-client-2025-04-04"),R?.safeguards&&R.safeguards.length>0&&X.add("dangerous-tool-use-2026-09-03"),J&&X.add("compact-2026-09-04"),V&&(X.add("context-management-2025-06-27"),V.edits.some(e=>"compact_20260112"===e.type)&&X.add("compact-2026-01-12")),R?.container&&R.container.skills&&R.container.skills.length>0&&(X.add("code-execution-2025-08-25"),X.add("skills-2025-10-02"),X.add("files-api-2025-04-14"),g?.some(e=>"provider"===e.type&&("anthropic.code_execution_20250825"===e.id||"anthropic.code_execution_20260120"===e.id))||k.push({type:"other",message:"code execution tool is required when using skills"})),R?.taskBudget&&X.add("task-budgets-2026-03-13"),R?.speed==="fast"&&X.add("fast-mode-2026-02-01"),"updates"===en&&X.add("thinking-display-updates-2026-08-18"),null!=ee&&X.add("thinking-binding-controls-2026-08-01"),R?.fallbacks==="default"?X.add("server-side-fallback-2026-07-01"):R?.fallbacks&&R.fallbacks.length>0&&X.add("server-side-fallback-2026-06-01");let es=b&&(R?.toolStreaming??!0),{tools:el,toolChoice:eu,toolWarnings:ec,betas:ed}=await er(null!=B?{tools:[...g??[],B],toolChoice:{type:"required"},disableParallelToolUse:!0,cacheControlValidator:G,supportsStructuredOutput:!1,supportsStrictTools:D,defaultEagerInputStreaming:es,rejectsForcedToolUse:U}:{tools:g??[],toolChoice:f,disableParallelToolUse:R?.disableParallelToolUse,cacheControlValidator:G,supportsStructuredOutput:L,supportsStrictTools:D,defaultEagerInputStreaming:es,rejectsForcedToolUse:U}),ep=G.getWarnings();return{args:{...ei,tools:el,tool_choice:eu,stream:!0===b||void 0},warnings:[...k,...ec,...ep],betas:new Set([...X,...ed,...r,...R?.anthropicBeta??[]]),usesJsonResponseTool:null!=B,toolNameMapping:W,providerOptionsName:I,usedCustomProviderKey:j}}getArgs(t){return e.prepareRequest({modelId:this.modelId,config:this.config,options:t})}async getHeaders({betas:e,headers:t}){return(0,o.combineHeaders)(this.config.headers?await (0,o.resolve)(this.config.headers):void 0,t,e.size>0?{"anthropic-beta":Array.from(e).join(",")}:{})}async getBetasFromHeaders(e){let t=this.config.headers?await (0,o.resolve)(this.config.headers):void 0,n=t?.["anthropic-beta"]??"",r=e?.["anthropic-beta"]??"";return new Set([...n.toLowerCase().split(","),...r.toLowerCase().split(",")].map(e=>e.trim()).filter(e=>""!==e))}buildRequestUrl(e){return this.config.buildRequestUrl?.(this.config.baseURL,e)??`${this.config.baseURL}/messages`}transformRequestBody(e,t){return this.config.transformRequestBody?.(e,t)??e}extractCitationDocuments(e){return e.filter(e=>"user"===e.role).flatMap(e=>e.content).filter(e=>{if("file"!==e.type||"application/pdf"!==e.mediaType&&"text/plain"!==e.mediaType)return!1;let t=e.providerOptions?.anthropic,o=t?.citations;return o?.enabled??!1}).map(e=>({title:e.filename??"Untitled Document",filename:e.filename,mediaType:e.mediaType}))}async doGenerate(e){let t,n,r,{args:a,warnings:i,betas:l,usesJsonResponseTool:u,toolNameMapping:c,providerOptionsName:d,usedCustomProviderKey:p}=await this.getArgs({...e,stream:!1,userSuppliedBetas:await this.getBetasFromHeaders(e.headers)}),m=[...this.extractCitationDocuments(e.prompt)],h=eA(a.tools),{responseHeaders:g,value:y,rawValue:_}=await (0,o.postJsonToApi)({url:this.buildRequestUrl(!1),headers:await this.getHeaders({betas:l,headers:e.headers}),body:this.transformRequestBody(a,l),failedResponseHandler:s,successfulResponseHandler:(0,o.createJsonResponseHandler)(f),abortSignal:e.abortSignal,fetch:this.config.fetch}),b=[],z={},v={},w=!1;for(let e of y.content)switch(e.type){case"text":if(!u){let t=e.citations?.filter(e=>"web_search_result_location"===e.type);if(b.push({type:"text",text:e.text,...null!=t&&t.length>0&&{providerMetadata:{anthropic:{citations:t}}}}),e.citations)for(let t of e.citations){let e=ej(t,m,this.generateId);e&&b.push(e)}}break;case"thinking":b.push({type:"reasoning",text:e.thinking,providerMetadata:{anthropic:{signature:e.signature}}});break;case"redacted_thinking":b.push({type:"reasoning",text:"",providerMetadata:{anthropic:{redactedData:e.data}}});break;case"container_upload":b.push({type:"custom",kind:"anthropic.container_upload",providerMetadata:{anthropic:{fileId:e.file_id}}});break;case"compaction":if(!e.content)break;b.push({type:"text",text:e.content,providerMetadata:{anthropic:{type:"compaction",...null!=e.signature&&{signature:e.signature}}}});break;case"tool_use":u&&"json"===e.name?(w=!0,b.push({type:"text",text:JSON.stringify(e.input)})):null!=e.toolset_name?b.push({type:"tool-call",toolCallId:e.id,toolName:c.toCustomToolName(e.toolset_name),input:JSON.stringify(eO({memberName:e.name,input:e.input})),providerMetadata:{anthropic:{toolsetName:e.toolset_name,...eC(e.caller).providerMetadata?.anthropic}}}):b.push({type:"tool-call",toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),...eC(e.caller)});break;case"server_tool_use":if("text_editor_code_execution"===e.name||"bash_code_execution"===e.name)b.push({type:"tool-call",toolCallId:e.id,toolName:c.toCustomToolName("code_execution"),input:JSON.stringify({type:e.name,...e.input}),providerExecuted:!0,...h&&1?{dynamic:!0}:{},...eC(e.caller)});else if("web_search"===e.name||"code_execution"===e.name||"web_fetch"===e.name){let t="code_execution"===e.name&&null!=e.input&&"object"==typeof e.input&&"code"in e.input&&!("type"in e.input)?{type:"programmatic-tool-call",...e.input}:e.input;b.push({type:"tool-call",toolCallId:e.id,toolName:c.toCustomToolName(e.name),input:JSON.stringify(t),providerExecuted:!0,...h&&"code_execution"===e.name?{dynamic:!0}:{},...eC(e.caller)})}else"tool_search_tool_regex"===e.name||"tool_search_tool_bm25"===e.name?(v[e.id]=e.name,b.push({type:"tool-call",toolCallId:e.id,toolName:c.toCustomToolName(e.name),input:JSON.stringify(e.input),providerExecuted:!0,...eC(e.caller)})):"advisor"===e.name&&b.push({type:"tool-call",toolCallId:e.id,toolName:c.toCustomToolName("advisor"),input:JSON.stringify(e.input),providerExecuted:!0,...eC(e.caller)});break;case"mcp_tool_use":z[e.id]={type:"tool-call",toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:"mcp-tool-use",serverName:e.server_name}}},b.push(z[e.id]);break;case"mcp_tool_result":b.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:z[e.tool_use_id].toolName,isError:e.is_error,result:e.content,dynamic:!0,providerMetadata:z[e.tool_use_id].providerMetadata});break;case"web_fetch_tool_result":"web_fetch_result"===e.content.type?(m.push({title:e.content.content.title??e.content.url,mediaType:e.content.content.source.media_type}),b.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:c.toCustomToolName("web_fetch"),result:{type:"web_fetch_result",url:e.content.url,retrievedAt:e.content.retrieved_at,content:{type:e.content.content.type,title:e.content.content.title,citations:e.content.content.citations,source:{type:e.content.content.source.type,mediaType:e.content.content.source.media_type,data:e.content.content.source.data}}},...eC(e.caller)})):"web_fetch_tool_result_error"===e.content.type&&b.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:c.toCustomToolName("web_fetch"),isError:!0,result:{type:"web_fetch_tool_result_error",errorCode:e.content.error_code},...eC(e.caller)});break;case"web_search_tool_result":if(Array.isArray(e.content))for(let t of(b.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:c.toCustomToolName("web_search"),result:e.content.map(e=>({url:e.url,...null!=e.title?{title:e.title}:{},pageAge:e.page_age??null,encryptedContent:e.encrypted_content,type:e.type})),...eC(e.caller)}),e.content))b.push({type:"source",sourceType:"url",id:this.generateId(),url:t.url,...null!=t.title?{title:t.title}:{},providerMetadata:{anthropic:{pageAge:t.page_age??null}}});else b.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:c.toCustomToolName("web_search"),isError:!0,result:{type:"web_search_tool_result_error",errorCode:e.content.error_code},...eC(e.caller)});break;case"code_execution_tool_result":"code_execution_result"===e.content.type?b.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:c.toCustomToolName("code_execution"),result:{type:e.content.type,stdout:e.content.stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:e.content.content??[]}}):"encrypted_code_execution_result"===e.content.type?b.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:c.toCustomToolName("code_execution"),result:{type:e.content.type,encrypted_stdout:e.content.encrypted_stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:e.content.content??[]}}):"code_execution_tool_result_error"===e.content.type&&b.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:c.toCustomToolName("code_execution"),isError:!0,result:{type:"code_execution_tool_result_error",errorCode:e.content.error_code}});break;case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":b.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:c.toCustomToolName("code_execution"),result:e.content});break;case"tool_search_tool_result":{let t=v[e.tool_use_id];if(null==t){let e=c.toCustomToolName("tool_search_tool_bm25");c.toCustomToolName("tool_search_tool_regex"),t="tool_search_tool_bm25"!==e?"tool_search_tool_bm25":"tool_search_tool_regex"}"tool_search_tool_search_result"===e.content.type?b.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:c.toCustomToolName(t),result:e.content.tool_references.map(e=>({type:e.type,toolName:e.tool_name}))}):b.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:c.toCustomToolName(t),isError:!0,result:{type:"tool_search_tool_result_error",errorCode:e.content.error_code}});break}case"advisor_tool_result":{let t=c.toCustomToolName("advisor");"advisor_result"===e.content.type?b.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:t,result:{type:"advisor_result",text:e.content.text,...null!=e.content.stop_reason&&{stopReason:e.content.stop_reason}}}):"advisor_redacted_result"===e.content.type?b.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:t,result:{type:"advisor_redacted_result",encryptedContent:e.content.encrypted_content,...null!=e.content.stop_reason&&{stopReason:e.content.stop_reason}}}):b.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:t,isError:!0,result:{type:"advisor_tool_result_error",errorCode:e.content.error_code}})}}return{content:b,finishReason:{unified:ex({finishReason:y.stop_reason,isJsonResponseFromTool:w}),raw:y.stop_reason??void 0},usage:ea({usage:y.usage}),request:{body:a},response:{id:y.id??void 0,modelId:y.model??void 0,headers:g,body:_},warnings:i,providerMetadata:(t=e$(y.stop_details),r={anthropic:n={usage:y.usage,stopSequence:y.stop_sequence??null,...null!=t?{stopDetails:t}:{},...null!=y.input_transformations?{inputTransformations:y.input_transformations}:{},...null!=y.safeguard_results?{safeguardResults:y.safeguard_results}:{},iterations:y.usage.iterations?y.usage.iterations.map(e=>({type:e.type,...null!=e.model?{model:e.model}:{},inputTokens:e.input_tokens,outputTokens:e.output_tokens,...e.cache_creation_input_tokens?{cacheCreationInputTokens:e.cache_creation_input_tokens}:{},...e.cache_read_input_tokens?{cacheReadInputTokens:e.cache_read_input_tokens}:{}})):null,container:y.container?{expiresAt:y.container.expires_at,id:y.container.id,skills:y.container.skills?.map(e=>({type:e.type,skillId:e.skill_id,version:e.version}))??null}:null,contextManagement:eM(y.context_management)??null}},p&&"anthropic"!==d&&(r[d]=n),r)}}async doStream(e){let n,r,a,i,l,u,{args:c,warnings:d,betas:p,usesJsonResponseTool:m,toolNameMapping:h,providerOptionsName:g,usedCustomProviderKey:f}=await this.getArgs({...e,stream:!0,userSuppliedBetas:await this.getBetasFromHeaders(e.headers)}),_=[...this.extractCitationDocuments(e.prompt)],b=eA(c.tools),z=this.buildRequestUrl(!0),{responseHeaders:v,value:w}=await (0,o.postJsonToApi)({url:z,headers:await this.getHeaders({betas:p,headers:e.headers}),body:this.transformRequestBody(c,p),failedResponseHandler:s,successfulResponseHandler:(0,o.createEventSourceResponseHandler)(y),abortSignal:e.abortSignal,fetch:this.config.fetch}),x={unified:"other",raw:void 0},k={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,iterations:null},I={},T={},S={},j=null,R=null,C=null,O=!1,E=!1,A=!1,M=this.generateId,[$,q]=w.pipeThrough(new TransformStream({start(e){e.enqueue({type:"stream-start",warnings:d})},transform(s,c){if(A)return;if(e.includeRawChunks&&c.enqueue({type:"raw",rawValue:s.rawValue}),!s.success)return void c.enqueue({type:"error",error:s.error});let d=s.value;switch(d.type){case"ping":return;case"content_block_start":{let e=d.content_block,t=e.type;if("fallback"===t)return;switch(u=t,t){case"text":if(m)return;I[d.index]={type:"text",citations:[]},c.enqueue({type:"text-start",id:String(d.index)});return;case"thinking":I[d.index]={type:"reasoning"},c.enqueue({type:"reasoning-start",id:String(d.index)});return;case"redacted_thinking":I[d.index]={type:"reasoning"},c.enqueue({type:"reasoning-start",id:String(d.index),providerMetadata:{anthropic:{redactedData:e.data}}});return;case"compaction":I[d.index]={type:"text",citations:[]},c.enqueue({type:"text-start",id:String(d.index),providerMetadata:{anthropic:{type:"compaction",...null!=e.signature&&{signature:e.signature}}}}),null!=e.signature&&null!=e.content&&""!==e.content&&c.enqueue({type:"text-delta",id:String(d.index),delta:e.content});return;case"tool_use":if(m&&"json"===e.name)O=!0,I[d.index]={type:"text",citations:[]},c.enqueue({type:"text-start",id:String(d.index)});else if(null!=e.toolset_name){let t=eR(e.caller),o=h.toCustomToolName(e.toolset_name),n=e.input&&Object.keys(e.input).length>0;I[d.index]={type:"tool-call",toolCallId:e.id,toolName:o,input:n?JSON.stringify(e.input):"",firstDelta:!0,toolset:{name:e.toolset_name,memberName:e.name},...t&&{caller:t}},c.enqueue({type:"tool-input-start",id:e.id,toolName:o})}else{let t=eR(e.caller),o=e.input&&Object.keys(e.input).length>0?JSON.stringify(e.input):"";I[d.index]={type:"tool-call",toolCallId:e.id,toolName:e.name,input:o,firstDelta:0===o.length,...t&&{caller:t}},c.enqueue({type:"tool-input-start",id:e.id,toolName:e.name})}return;case"server_tool_use":{let t=eR(e.caller);if(["web_fetch","web_search","code_execution","text_editor_code_execution","bash_code_execution"].includes(e.name)){let o="text_editor_code_execution"===e.name||"bash_code_execution"===e.name?"code_execution":e.name,n="text_editor_code_execution"===e.name||"bash_code_execution"===e.name?e.name:"code_execution"===e.name?"programmatic-tool-call":void 0,r=h.toCustomToolName(o),a=null!=e.input&&"object"==typeof e.input&&Object.keys(e.input).length>0?JSON.stringify(e.input):"";I[d.index]={type:"tool-call",toolCallId:e.id,toolName:r,input:a,providerExecuted:!0,...b&&"code_execution"===o?{dynamic:!0}:{},firstDelta:0===a.length,providerToolName:o,providerToolInputType:n,...t&&{caller:t}},c.enqueue({type:"tool-input-start",id:e.id,toolName:r,providerExecuted:!0,...b&&"code_execution"===o?{dynamic:!0}:{}})}else if("tool_search_tool_regex"===e.name||"tool_search_tool_bm25"===e.name){S[e.id]=e.name;let o=h.toCustomToolName(e.name);I[d.index]={type:"tool-call",toolCallId:e.id,toolName:o,input:"",providerExecuted:!0,firstDelta:!0,providerToolName:e.name,...t&&{caller:t}},c.enqueue({type:"tool-input-start",id:e.id,toolName:o,providerExecuted:!0})}else if("advisor"===e.name){let o=h.toCustomToolName("advisor");I[d.index]={type:"tool-call",toolCallId:e.id,toolName:o,input:"{}",providerExecuted:!0,firstDelta:!0,providerToolName:e.name,...t&&{caller:t}},c.enqueue({type:"tool-input-start",id:e.id,toolName:o,providerExecuted:!0})}return}case"web_fetch_tool_result":"web_fetch_result"===e.content.type?(_.push({title:e.content.content.title??e.content.url,mediaType:e.content.content.source.media_type}),c.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("web_fetch"),result:{type:"web_fetch_result",url:e.content.url,retrievedAt:e.content.retrieved_at,content:{type:e.content.content.type,title:e.content.content.title,citations:e.content.content.citations,source:{type:e.content.content.source.type,mediaType:e.content.content.source.media_type,data:e.content.content.source.data}}},...eC(e.caller)})):"web_fetch_tool_result_error"===e.content.type&&c.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("web_fetch"),isError:!0,result:{type:"web_fetch_tool_result_error",errorCode:e.content.error_code},...eC(e.caller)});return;case"web_search_tool_result":if(Array.isArray(e.content))for(let t of(c.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("web_search"),result:e.content.map(e=>({url:e.url,...null!=e.title?{title:e.title}:{},pageAge:e.page_age??null,encryptedContent:e.encrypted_content,type:e.type})),...eC(e.caller)}),e.content))c.enqueue({type:"source",sourceType:"url",id:M(),url:t.url,...null!=t.title?{title:t.title}:{},providerMetadata:{anthropic:{pageAge:t.page_age??null}}});else c.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("web_search"),isError:!0,result:{type:"web_search_tool_result_error",errorCode:e.content.error_code},...eC(e.caller)});return;case"code_execution_tool_result":"code_execution_result"===e.content.type?c.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("code_execution"),result:{type:e.content.type,stdout:e.content.stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:e.content.content??[]}}):"encrypted_code_execution_result"===e.content.type?c.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("code_execution"),result:{type:e.content.type,encrypted_stdout:e.content.encrypted_stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:e.content.content??[]}}):"code_execution_tool_result_error"===e.content.type&&c.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("code_execution"),isError:!0,result:{type:"code_execution_tool_result_error",errorCode:e.content.error_code}});return;case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":return void c.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("code_execution"),result:e.content});case"tool_search_tool_result":{let t=S[e.tool_use_id];if(null==t){let e=h.toCustomToolName("tool_search_tool_bm25");h.toCustomToolName("tool_search_tool_regex"),t="tool_search_tool_bm25"!==e?"tool_search_tool_bm25":"tool_search_tool_regex"}"tool_search_tool_search_result"===e.content.type?c.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName(t),result:e.content.tool_references.map(e=>({type:e.type,toolName:e.tool_name}))}):c.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName(t),isError:!0,result:{type:"tool_search_tool_result_error",errorCode:e.content.error_code}});return}case"advisor_tool_result":{let t=h.toCustomToolName("advisor");"advisor_result"===e.content.type?c.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:t,result:{type:"advisor_result",text:e.content.text,...null!=e.content.stop_reason&&{stopReason:e.content.stop_reason}}}):"advisor_redacted_result"===e.content.type?c.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:t,result:{type:"advisor_redacted_result",encryptedContent:e.content.encrypted_content,...null!=e.content.stop_reason&&{stopReason:e.content.stop_reason}}}):c.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:t,isError:!0,result:{type:"advisor_tool_result_error",errorCode:e.content.error_code}});return}case"mcp_tool_use":T[e.id]={type:"tool-call",toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:"mcp-tool-use",serverName:e.server_name}}},c.enqueue(T[e.id]);return;case"mcp_tool_result":return void c.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:T[e.tool_use_id].toolName,isError:e.is_error,result:e.content,dynamic:!0,providerMetadata:T[e.tool_use_id].providerMetadata});default:throw Error(`Unsupported content block type: ${t}`)}}case"content_block_stop":if(null!=I[d.index]){let e=I[d.index];switch(e.type){case"text":c.enqueue({type:"text-end",id:String(d.index),...e.citations.length>0&&{providerMetadata:{anthropic:{citations:e.citations}}}});break;case"reasoning":c.enqueue({type:"reasoning-end",id:String(d.index)});break;case"tool-call":if(!(m&&"json"===e.toolName)){if(null!=e.toolset){let t={};try{t=""===e.input?{}:(0,o.secureJsonParse)(e.input)}catch{t=void 0}e.input=void 0===t?e.input:JSON.stringify(eO({memberName:e.toolset.memberName,input:t})),c.enqueue({type:"tool-input-delta",id:e.toolCallId,delta:e.input})}c.enqueue({type:"tool-input-end",id:e.toolCallId});let t=""===e.input?"{}":e.input;if("code_execution"===e.providerToolName)try{let e=(0,o.secureJsonParse)(t);null!=e&&"object"==typeof e&&"code"in e&&!("type"in e)&&(t=JSON.stringify({type:"programmatic-tool-call",...e}))}catch{}c.enqueue({type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:t,providerExecuted:e.providerExecuted,...b&&"code_execution"===e.providerToolName?{dynamic:!0}:{},...(e.caller||e.toolset)&&{providerMetadata:{anthropic:{...e.toolset&&{toolsetName:e.toolset.name},...e.caller&&{caller:e.caller}}}}})}}delete I[d.index]}u=void 0;return;case"content_block_delta":{let e=d.delta.type;switch(e){case"text_delta":if(m)return;c.enqueue({type:"text-delta",id:String(d.index),delta:d.delta.text});return;case"thinking_delta":return void c.enqueue({type:"reasoning-delta",id:String(d.index),delta:d.delta.thinking});case"signature_delta":"thinking"===u&&c.enqueue({type:"reasoning-delta",id:String(d.index),delta:"",providerMetadata:{anthropic:{signature:d.delta.signature}}});return;case"compaction_delta":null!=d.delta.content&&c.enqueue({type:"text-delta",id:String(d.index),delta:d.delta.content});return;case"input_json_delta":{let e=I[d.index],t=d.delta.partial_json;if(0===t.length)return;if(O){if(e?.type!=="text")return;c.enqueue({type:"text-delta",id:String(d.index),delta:t})}else{if(e?.type!=="tool-call")return;if(null!=e.toolset){e.input+=t;return}e.firstDelta&&null!=e.providerToolInputType&&(t=`{"type": "${e.providerToolInputType}",${t.substring(1)}`),c.enqueue({type:"tool-input-delta",id:e.toolCallId,delta:t}),e.input+=t,e.firstDelta=!1}return}case"citations_delta":{let e=d.delta.citation,t=I[d.index];t?.type==="text"&&"web_search_result_location"===e.type&&t.citations.push(e);let o=ej(e,_,M);o&&c.enqueue(o);return}default:throw Error(`Unsupported delta type: ${e}`)}}case"message_start":if(E){if(a===d.message.id)return;A=!0,c.enqueue({type:"error",error:new t.InvalidResponseDataError({data:d,message:`Received message_start for message ${JSON.stringify(d.message.id)} while message ${JSON.stringify(a)} is still open.`})});return}if(E=!0,a=d.message.id,k.input_tokens=d.message.usage.input_tokens,k.cache_read_input_tokens=d.message.usage.cache_read_input_tokens??0,k.cache_creation_input_tokens=d.message.usage.cache_creation_input_tokens??0,i={...d.message.usage},null!=d.message.input_transformations&&(n=d.message.input_transformations),null!=d.message.container&&(C={expiresAt:d.message.container.expires_at,id:d.message.container.id,skills:null}),null!=d.message.stop_reason&&(x={unified:ex({finishReason:d.message.stop_reason,isJsonResponseFromTool:O}),raw:d.message.stop_reason}),c.enqueue({type:"response-metadata",id:d.message.id??void 0,modelId:d.message.model??void 0}),null!=d.message.content)for(let e=0;e<d.message.content.length;e++){let t=d.message.content[e];if("tool_use"===t.type){let e=eR(t.caller);c.enqueue({type:"tool-input-start",id:t.id,toolName:t.name});let o=JSON.stringify(t.input??{});c.enqueue({type:"tool-input-delta",id:t.id,delta:o}),c.enqueue({type:"tool-input-end",id:t.id}),c.enqueue({type:"tool-call",toolCallId:t.id,toolName:t.name,input:o,...e&&{providerMetadata:{anthropic:{caller:e}}}})}}return;case"message_delta":null!=d.usage.input_tokens&&k.input_tokens!==d.usage.input_tokens&&(k.input_tokens=d.usage.input_tokens),k.output_tokens=d.usage.output_tokens,null!=d.usage.output_tokens_details&&(k.output_tokens_details=d.usage.output_tokens_details),null!=d.usage.cache_read_input_tokens&&(k.cache_read_input_tokens=d.usage.cache_read_input_tokens),null!=d.usage.cache_creation_input_tokens&&(k.cache_creation_input_tokens=d.usage.cache_creation_input_tokens),null!=d.usage.iterations&&(k.iterations=d.usage.iterations),x={unified:ex({finishReason:d.delta.stop_reason,isJsonResponseFromTool:O}),raw:d.delta.stop_reason??void 0},R=d.delta.stop_sequence??null,l=e$(d.delta.stop_details),C=null!=d.delta.container?{expiresAt:d.delta.container.expires_at,id:d.delta.container.id,skills:d.delta.container.skills?.map(e=>({type:e.type,skillId:e.skill_id,version:e.version}))??null}:null,d.context_management&&(j=eM(d.context_management)),null!=d.input_transformations&&(n=d.input_transformations),null!=d.delta.safeguard_results&&(r=d.delta.safeguard_results),i={...i,...d.usage};return;case"message_stop":{E=!1,a=void 0;let e={usage:i??null,stopSequence:R,...null!=l?{stopDetails:l}:{},...null!=n?{inputTransformations:n}:{},...null!=r?{safeguardResults:r}:{},iterations:k.iterations?k.iterations.map(e=>({type:e.type,...null!=e.model?{model:e.model}:{},inputTokens:e.input_tokens,outputTokens:e.output_tokens,...e.cache_creation_input_tokens?{cacheCreationInputTokens:e.cache_creation_input_tokens}:{},...e.cache_read_input_tokens?{cacheReadInputTokens:e.cache_read_input_tokens}:{}})):null,container:C,contextManagement:j},t={anthropic:e};f&&"anthropic"!==g&&(t[g]=e),c.enqueue({type:"finish",finishReason:x,usage:ea({usage:k,rawUsage:i}),providerMetadata:t});return}case"error":var p;let y;return void c.enqueue({type:"error",error:(y=function(e){switch(e){case"api_error":return{statusCode:500,isRetryable:!0};case"overloaded_error":return{statusCode:529,isRetryable:!0};case"rate_limit_error":return{statusCode:429,isRetryable:!0};case"request_too_large":return{statusCode:413,isRetryable:!1};case"authentication_error":return{statusCode:401,isRetryable:!1};case"permission_error":return{statusCode:403,isRetryable:!1};case"not_found_error":return{statusCode:404,isRetryable:!1};case"billing_error":case"invalid_request_error":return{statusCode:400,isRetryable:!1};default:return{}}}((p=d.error).type),(0,o.createProviderStreamError)({message:p.message,type:p.type,code:p.code??void 0,statusCode:p.statusCode??y.statusCode,isRetryable:p.isRetryable??y.isRetryable,data:"data"in p?p.data:p}))});default:throw Error(`Unsupported chunk type: ${d}`)}}})).tee(),U=$.getReader();try{await U.read();let e=await U.read();if(e.value?.type==="raw"&&(e=await U.read()),e.value?.type==="error"){let n=e.value.error;if(!(0,o.isProviderStreamError)(n))throw Error("Expected a normalized Anthropic stream error");throw new t.APICallError({message:n.message,url:z,requestBodyValues:c,statusCode:n.statusCode??500,responseHeaders:v,responseBody:JSON.stringify(n.data),isRetryable:n.isRetryable??!1})}}finally{U.cancel().catch(()=>{}),U.releaseLock()}return{stream:q,request:{body:c},response:{headers:v}}}};function eA(e){if(!e)return!1;let t=!1,o=!1;for(let n of e){if("type"in n&&("web_fetch_20260209"===n.type||"web_fetch_20260318"===n.type||"web_search_20260209"===n.type||"web_search_20260318"===n.type)){t=!0;continue}if("type"in n&&("code_execution_20250522"===n.type||"code_execution_20250825"===n.type||"code_execution_20260120"===n.type)){o=!0;break}}return t&&!o}function eM(e){return e?{appliedEdits:e.applied_edits.map(e=>{switch(e.type){case"clear_tool_uses_20250919":return{type:e.type,clearedToolUses:e.cleared_tool_uses,clearedInputTokens:e.cleared_input_tokens};case"clear_thinking_20251015":return{type:e.type,clearedThinkingTurns:e.cleared_thinking_turns,clearedInputTokens:e.cleared_input_tokens};case"compact_20260112":return{type:e.type}}}).filter(e=>void 0!==e)}:null}function e$(e){if(null!=e)return{type:e.type,...null!=e.category?{category:e.category}:{},...null!=e.explanation?{explanation:e.explanation}:{},...null!=e.recommended_model?{recommendedModel:e.recommended_model}:{}}}var eq=/^[A-Za-z0-9_-]{1,64}$/,eU=v.pick({anthropicBeta:!0}),eN=()=>r.z.object({id:r.z.string(),type:r.z.literal("message_batch"),processing_status:r.z.string(),request_counts:r.z.object({processing:r.z.number(),succeeded:r.z.number(),errored:r.z.number(),canceled:r.z.number(),expired:r.z.number()}),created_at:r.z.string(),expires_at:r.z.string(),archived_at:r.z.string().nullish(),cancel_initiated_at:r.z.string().nullish(),ended_at:r.z.string().nullish(),results_url:r.z.string().nullish()}),eP=(0,o.lazySchema)(()=>(0,o.zodSchema)(eN())),eL=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({data:r.z.array(eN()),has_more:r.z.boolean(),last_id:r.z.string().nullish()}))),eD=new Set(["advisor_tool_result","bash_code_execution_tool_result","code_execution_tool_result","compaction","container_upload","fallback","mcp_tool_result","mcp_tool_use","redacted_thinking","server_tool_use","text","text_editor_code_execution_tool_result","thinking","tool_search_tool_result","tool_use","web_fetch_tool_result","web_search_tool_result"]),eF=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.discriminatedUnion("type",[r.z.object({type:r.z.literal("succeeded"),message:r.z.unknown()}),r.z.object({type:r.z.literal("errored"),error:r.z.object({type:r.z.literal("error"),error:r.z.object({type:r.z.string(),message:r.z.string()}),request_id:r.z.string().nullish()})}),r.z.object({type:r.z.literal("canceled")}),r.z.object({type:r.z.literal("expired")})]))),eH=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({custom_id:r.z.string(),result:r.z.unknown()}))),eB=class{constructor(e){this.options=e,this.specificationVersion="v4",this.provider=e.provider,this.supportedUrls=e.supportedUrls,this.generateId=e.config.generateId??o.generateId}async doStartBatch({requests:e,providerOptions:n,headers:r,abortSignal:a,webhookUrl:i}){for(let o of e){let e=o.type;if("text"!==e)throw new t.UnsupportedFunctionalityError({functionality:`batch request type: ${e}`,message:`The Anthropic Message Batches API does not support batch requests with type "${e}".`})}var l=e;let u=new Set;for(let e of l){if(!eq.test(e.id))throw new t.InvalidArgumentError({argument:"requests",message:`Anthropic batch request ID "${e.id}" must match ^[A-Za-z0-9_-]{1,64}$.`});if(u.has(e.id))throw new t.InvalidArgumentError({argument:"requests",message:`Anthropic batch request IDs must be unique; duplicate ID "${e.id}".`});u.add(e.id)}let c=new Set(await eV({provider:this.options.config.provider,providerOptions:n})),d=new Set(c),p=[],m=null==i?[]:[{warning:{type:"unsupported",feature:"webhookUrl",details:"The Anthropic Message Batches API does not support completion webhooks."}}];for(let o of e){if((await eV({provider:this.options.config.provider,providerOptions:o.options.providerOptions})).length>0)throw new t.UnsupportedFunctionalityError({functionality:"per-request providerOptions.anthropic.anthropicBeta",message:`Anthropic Message Batches do not support per-request betas (request "${o.id}"). Set providerOptions.anthropic.anthropicBeta on startBatch instead.`});let e=await eE.prepareRequest({modelId:o.modelId,config:this.options.config,options:{...o.options,stream:!1,userSuppliedBetas:new Set(c)}});if(e.usesJsonResponseTool)throw new t.UnsupportedFunctionalityError({functionality:"batch responseFormat JSON-tool fallback",message:`Anthropic Message Batches cannot decode the JSON-tool structured-output fallback (request "${o.id}") because batch results are retrieved independently of the start call. Use a model that supports native output_format structured outputs.`});let n=o.options.tools?.find(t=>"provider"===t.type&&e.toolNameMapping.toProviderToolName(t.name)!==t.name);if(null!=n)throw new t.UnsupportedFunctionalityError({functionality:"aliased provider tool names in batches",message:`Anthropic Message Batches cannot restore the custom provider-tool name "${n.name}" when results are retrieved independently of the start call (request "${o.id}"). Use the provider's canonical tool name.`});let r=this.options.config.transformRequestBody?.(e.args,e.betas)??e.args;for(let n of(function({body:e,requestId:o}){if(null!=e.speed)throw new t.UnsupportedFunctionalityError({functionality:"providerOptions.anthropic.speed",message:`Anthropic Message Batches do not support speed (request "${o}").`});if(Array.isArray(e.fallbacks)&&e.fallbacks.some(e=>null!=e&&"object"==typeof e&&"speed"in e&&null!=e.speed))throw new t.UnsupportedFunctionalityError({functionality:"providerOptions.anthropic.fallbacks[].speed",message:`Anthropic Message Batches do not support fallback speed (request "${o}").`})}({body:r,requestId:o.id}),p.push({custom_id:o.id,params:r}),e.betas))d.add(n);for(let t of e.warnings)m.push({requestId:o.id,warning:t})}let{value:h}=await (0,o.postJsonToApi)({url:this.getBatchUrl(""),headers:await this.getStartBatchHeaders({betas:d,headers:r}),body:{requests:p},failedResponseHandler:s,successfulResponseHandler:(0,o.createJsonResponseHandler)(eP),abortSignal:a,fetch:this.options.config.fetch});return{batchId:h.id,...eJ(h),warnings:m}}async doGetBatchStatus(e){return eJ(await this.retrieveBatch(e))}async doCancelBatch(e){return await (0,o.postJsonToApi)({url:this.getBatchUrl(`/${encodeURIComponent(e.batchId)}/cancel`),headers:await this.getBatchHeaders(e.headers),body:{},failedResponseHandler:s,successfulResponseHandler:(0,o.createJsonResponseHandler)(eP),abortSignal:e.abortSignal,fetch:this.options.config.fetch}),{}}async doListBatches(e){let t=new URL(this.getBatchUrl(""));null!=e.limit&&t.searchParams.set("limit",String(e.limit)),null!=e.cursor&&t.searchParams.set("after_id",e.cursor);let{value:n}=await (0,o.getFromApi)({url:t.toString(),validateUrl:!1,headers:await this.getBatchHeaders(e.headers),failedResponseHandler:s,successfulResponseHandler:(0,o.createJsonResponseHandler)(eL),abortSignal:e.abortSignal,fetch:this.options.config.fetch});return{batches:n.data.map(e=>({batchId:e.id,...eJ(e)})),...n.has_more&&null!=n.last_id?{nextCursor:n.last_id}:{}}}async doGetBatchResults(e){let n=await this.retrieveBatch(e);if("pending"===eJ(n).status)throw new t.InvalidArgumentError({argument:"batchId",message:`Anthropic batch "${e.batchId}" is not complete.`});if(null!=n.archived_at)throw new t.InvalidArgumentError({argument:"batchId",message:`Anthropic batch "${e.batchId}" results are no longer available.`});if(null==n.results_url)throw new t.InvalidResponseDataError({data:n,message:`Anthropic batch "${e.batchId}" completed without batch output.`});let{value:r}=await (0,o.getFromApi)({url:n.results_url,validateUrl:!0,credentialedOrigin:this.options.config.baseURL,trustedOrigin:this.options.config.baseURL,headers:await this.getBatchHeaders(e.headers),failedResponseHandler:s,successfulResponseHandler:(0,o.createJsonLinesResponseHandler)(eH),abortSignal:e.abortSignal,fetch:this.options.config.fetch});return(0,o.convertAsyncIteratorToReadableStream)(this.iterateBatchResults(r))}async retrieveBatch(e){let{value:t}=await (0,o.getFromApi)({url:this.getBatchUrl(`/${encodeURIComponent(e.batchId)}`),validateUrl:!1,headers:await this.getBatchHeaders(e.headers),failedResponseHandler:s,successfulResponseHandler:(0,o.createJsonResponseHandler)(eP),abortSignal:e.abortSignal,fetch:this.options.config.fetch});return t}async *iterateBatchResults(e){for await(let t of e)yield await eG(t,this.generateId)}getBatchUrl(e){return`${this.options.config.baseURL}/messages/batches${e}`}async getStartBatchHeaders({betas:e,headers:t}){return(0,o.combineHeaders)((0,o.normalizeHeaders)(await this.getBatchHeaders(t)),{"anthropic-beta":e.size>0?Array.from(e).join(","):void 0})}async getBatchHeaders(e){return(0,o.combineHeaders)(this.options.config.headers?await (0,o.resolve)(this.options.config.headers):void 0,e)}};async function eV({provider:e,providerOptions:t}){let n=e.split(".")[0];return Object.assign({},await (0,o.parseProviderOptions)({provider:"anthropic",providerOptions:t,schema:eU})??{},("anthropic"!==n?await (0,o.parseProviderOptions)({provider:n,providerOptions:t,schema:eU}):void 0)??{}).anthropicBeta??[]}function eJ(e){var t;let n=(t=e.request_counts,(0,o.normalizeBatchRequestCounts)({total:t.processing+t.succeeded+t.errored+t.canceled+t.expired,pending:t.processing,completed:t.succeeded,failed:t.errored+t.canceled+t.expired}));return{status:"ended"===e.processing_status?"completed":"pending",rawStatus:e.processing_status,...null!=n?{requestCounts:n}:{},createdAt:e.created_at,expiresAt:e.expires_at,providerMetadata:{anthropic:{archivedAt:e.archived_at??null,cancelInitiatedAt:e.cancel_initiated_at??null,endedAt:e.ended_at??null,requestCounts:e.request_counts,resultsUrl:e.results_url??null}}}}async function eG(e,t){let n=await (0,o.safeValidateTypes)({value:e.result,schema:eF});if(!n.success)return eW(e.custom_id);let r=n.value;switch(r.type){case"canceled":return{type:"text",id:e.custom_id,status:"cancelled"};case"expired":return{type:"text",id:e.custom_id,status:"expired"};case"errored":{let t=r.error.request_id;return{type:"text",id:e.custom_id,status:"failed",error:{message:r.error.error.message,type:r.error.error.type},...null!=t?{providerMetadata:{anthropic:{requestId:t}}}:{}}}case"succeeded":{let o=await eK(r.message);if(null==o)return eW(e.custom_id);return{type:"text",id:e.custom_id,status:"succeeded",result:function(e,t){var o,n;let r,a=[],i={},s={};for(let o of e.content)switch(o.type){case"text":let e=o.citations;for(let n of(a.push({type:"text",text:o.text,...null!=e&&e.length>0&&{providerMetadata:{anthropic:{citations:e}}}}),o.citations??[])){let e=ej(n,[],t);null!=e&&a.push(e)}break;case"thinking":a.push({type:"reasoning",text:o.thinking,providerMetadata:{anthropic:{signature:o.signature}}});break;case"redacted_thinking":a.push({type:"reasoning",text:"",providerMetadata:{anthropic:{redactedData:o.data}}});break;case"container_upload":a.push({type:"custom",kind:"anthropic.container_upload",providerMetadata:{anthropic:{fileId:o.file_id}}});break;case"compaction":if(!o.content)break;a.push({type:"text",text:o.content,providerMetadata:{anthropic:{type:"compaction",...null!=o.signature&&{signature:o.signature}}}});break;case"tool_use":a.push({type:"tool-call",toolCallId:o.id,toolName:o.name,input:JSON.stringify(o.input),...eZ(o.caller)});break;case"server_tool_use":{let e="bash_code_execution"===o.name||"text_editor_code_execution"===o.name,t=e||"code_execution"===o.name,n=e?"code_execution":o.name;("tool_search_tool_bm25"===o.name||"tool_search_tool_regex"===o.name)&&(s[o.id]=o.name),a.push({type:"tool-call",toolCallId:o.id,toolName:n,input:JSON.stringify(e?{type:o.name,...o.input}:"code_execution"===o.name&&null!=o.input&&"code"in o.input&&!("type"in o.input)?{type:"programmatic-tool-call",...o.input}:o.input),providerExecuted:!0,...t?{dynamic:!0}:{},...eZ(o.caller)});break}case"mcp_tool_use":{let e={type:"tool-call",toolCallId:o.id,toolName:o.name,input:JSON.stringify(o.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{serverName:o.server_name,type:"mcp-tool-use"}}};i[o.id]=e,a.push(e);break}case"mcp_tool_result":{let e=i[o.tool_use_id];a.push({type:"tool-result",toolCallId:o.tool_use_id,toolName:e?.toolName??"mcp",isError:o.is_error,result:o.content,dynamic:!0,...e?.providerMetadata!=null&&{providerMetadata:e.providerMetadata}});break}case"web_fetch_tool_result":a.push({type:"tool-result",toolCallId:o.tool_use_id,toolName:"web_fetch",..."web_fetch_tool_result_error"===o.content.type?{isError:!0,result:{errorCode:o.content.error_code,type:o.content.type}}:{result:{content:{citations:o.content.content.citations,source:{data:o.content.content.source.data,mediaType:o.content.content.source.media_type,type:o.content.content.source.type},title:o.content.content.title,type:o.content.content.type},retrievedAt:o.content.retrieved_at,type:o.content.type,url:o.content.url}},...eZ(o.caller)});break;case"web_search_tool_result":if(a.push({type:"tool-result",toolCallId:o.tool_use_id,toolName:"web_search",...Array.isArray(o.content)?{result:o.content.map(e=>({encryptedContent:e.encrypted_content,pageAge:e.page_age??null,...null!=e.title?{title:e.title}:{},type:e.type,url:e.url}))}:{isError:!0,result:{errorCode:o.content.error_code,type:o.content.type}},...eZ(o.caller)}),Array.isArray(o.content))for(let e of o.content)a.push({type:"source",sourceType:"url",id:t(),url:e.url,...null!=e.title?{title:e.title}:{},providerMetadata:{anthropic:{pageAge:e.page_age??null}}});break;case"code_execution_tool_result":a.push({type:"tool-result",toolCallId:o.tool_use_id,toolName:"code_execution",..."code_execution_tool_result_error"===o.content.type?{isError:!0,result:{errorCode:o.content.error_code,type:o.content.type}}:{result:o.content}});break;case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":a.push({type:"tool-result",toolCallId:o.tool_use_id,toolName:"code_execution",result:o.content});break;case"tool_search_tool_result":{let e=s[o.tool_use_id]??"tool_search_tool_regex";a.push({type:"tool-result",toolCallId:o.tool_use_id,toolName:e,..."tool_search_tool_result_error"===o.content.type?{isError:!0,result:{errorCode:o.content.error_code,type:o.content.type}}:{result:o.content.tool_references.map(e=>({toolName:e.tool_name,type:e.type}))}});break}case"advisor_tool_result":"advisor_result"===o.content.type?a.push({type:"tool-result",toolCallId:o.tool_use_id,toolName:"advisor",result:{type:o.content.type,text:o.content.text,...null!=o.content.stop_reason?{stopReason:o.content.stop_reason}:{}}}):"advisor_redacted_result"===o.content.type?a.push({type:"tool-result",toolCallId:o.tool_use_id,toolName:"advisor",result:{type:o.content.type,encryptedContent:o.content.encrypted_content,...null!=o.content.stop_reason?{stopReason:o.content.stop_reason}:{}}}):a.push({type:"tool-result",toolCallId:o.tool_use_id,toolName:"advisor",isError:!0,result:{errorCode:o.content.error_code,type:o.content.type}})}return{content:a,finishReason:{unified:ex({finishReason:e.stop_reason}),raw:e.stop_reason??void 0},usage:ea({usage:e.usage}),response:{id:e.id??void 0,modelId:e.model??void 0},warnings:[],providerMetadata:{anthropic:(r=function(e){if(null!=e)return{type:e.type,...null!=e.category?{category:e.category}:{},...null!=e.explanation?{explanation:e.explanation}:{},...null!=e.recommended_model?{recommendedModel:e.recommended_model}:{}}}((o=e).stop_details),{usage:o.usage,stopSequence:o.stop_sequence??null,...null!=r?{stopDetails:r}:{},...null!=o.input_transformations?{inputTransformations:o.input_transformations}:{},...null!=o.safeguard_results?{safeguardResults:o.safeguard_results}:{},iterations:o.usage.iterations?o.usage.iterations.map(e=>({type:e.type,...null!=e.model?{model:e.model}:{},inputTokens:e.input_tokens,outputTokens:e.output_tokens,...e.cache_creation_input_tokens?{cacheCreationInputTokens:e.cache_creation_input_tokens}:{},...e.cache_read_input_tokens?{cacheReadInputTokens:e.cache_read_input_tokens}:{}})):null,container:o.container?{expiresAt:o.container.expires_at,id:o.container.id,skills:o.container.skills?.map(e=>({type:e.type,skillId:e.skill_id,version:e.version}))??null}:null,contextManagement:(n=o.context_management)?{appliedEdits:n.applied_edits.map(e=>{switch(e.type){case"clear_tool_uses_20250919":return{type:e.type,clearedToolUses:e.cleared_tool_uses,clearedInputTokens:e.cleared_input_tokens};case"clear_thinking_20251015":return{type:e.type,clearedThinkingTurns:e.cleared_thinking_turns,clearedInputTokens:e.cleared_input_tokens};case"compact_20260112":return{type:e.type}}})}:null})}}}(o,t)}}}}function eW(e){return{type:"text",id:e,status:"failed",error:{message:"Anthropic returned an invalid Message batch result.",code:"invalid_response"}}}async function eK(e){let t=await (0,o.safeValidateTypes)({value:e,schema:f});if(t.success)return t.value;if(!(0,o.isRecord)(e)||!Array.isArray(e.content))return;let n=[];for(let t of e.content){let r=await (0,o.safeValidateTypes)({value:{...e,content:[t]},schema:f});if(r.success){let[e]=r.value.content;null!=e&&n.push(e)}else if(!(0,o.isRecord)(t)||"string"!=typeof t.type||eD.has(t.type))return}let r=await (0,o.safeValidateTypes)({value:{...e,content:n},schema:f});return r.success?r.value:void 0}function eZ(e){return null==e?{}:{providerMetadata:{anthropic:{caller:{type:e.type,toolId:e.tool_id}}}}}var eX=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({command:r.z.string(),restart:r.z.boolean().optional()}))),eY=(0,o.createProviderDefinedToolFactory)({id:"anthropic.bash_20241022",inputSchema:eX}),eQ=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({command:r.z.string(),restart:r.z.boolean().optional()}))),e0=(0,o.createProviderDefinedToolFactory)({id:"anthropic.bash_20250124",inputSchema:eQ}),e1=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({action:r.z.enum(["key","type","mouse_move","left_click","left_click_drag","right_click","middle_click","double_click","screenshot","cursor_position"]),coordinate:r.z.array(r.z.number().int()).optional(),text:r.z.string().optional()}))),e2=(0,o.createProviderDefinedToolFactory)({id:"anthropic.computer_20241022",inputSchema:e1}),e4=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({action:r.z.enum(["key","hold_key","type","cursor_position","mouse_move","left_mouse_down","left_mouse_up","left_click","left_click_drag","right_click","middle_click","double_click","triple_click","scroll","wait","screenshot"]),coordinate:r.z.tuple([r.z.number().int(),r.z.number().int()]).optional(),duration:r.z.number().optional(),scroll_amount:r.z.number().optional(),scroll_direction:r.z.enum(["up","down","left","right"]).optional(),start_coordinate:r.z.tuple([r.z.number().int(),r.z.number().int()]).optional(),text:r.z.string().optional()}))),e6=(0,o.createProviderDefinedToolFactory)({id:"anthropic.computer_20250124",inputSchema:e4}),e5=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({action:r.z.enum(["key","hold_key","type","cursor_position","mouse_move","left_mouse_down","left_mouse_up","left_click","left_click_drag","right_click","middle_click","double_click","triple_click","scroll","wait","screenshot","zoom"]),coordinate:r.z.tuple([r.z.number().int(),r.z.number().int()]).optional(),duration:r.z.number().optional(),region:r.z.tuple([r.z.number().int(),r.z.number().int(),r.z.number().int(),r.z.number().int()]).optional(),scroll_amount:r.z.number().optional(),scroll_direction:r.z.enum(["up","down","left","right"]).optional(),start_coordinate:r.z.tuple([r.z.number().int(),r.z.number().int()]).optional(),text:r.z.string().optional()}))),e3=(0,o.createProviderDefinedToolFactory)({id:"anthropic.computer_20251124",inputSchema:e5}),e8=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.discriminatedUnion("command",[r.z.object({command:r.z.literal("view"),path:r.z.string(),view_range:r.z.tuple([r.z.number(),r.z.number()]).optional()}),r.z.object({command:r.z.literal("create"),path:r.z.string(),file_text:r.z.string()}),r.z.object({command:r.z.literal("str_replace"),path:r.z.string(),old_str:r.z.string(),new_str:r.z.string()}),r.z.object({command:r.z.literal("insert"),path:r.z.string(),insert_line:r.z.number(),insert_text:r.z.string()}),r.z.object({command:r.z.literal("delete"),path:r.z.string()}),r.z.object({command:r.z.literal("rename"),old_path:r.z.string(),new_path:r.z.string()})]))),e9=(0,o.createProviderDefinedToolFactory)({id:"anthropic.memory_20250818",inputSchema:e8}),e7=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({command:r.z.enum(["view","create","str_replace","insert","undo_edit"]),path:r.z.string(),file_text:r.z.string().optional(),insert_line:r.z.number().int().optional(),new_str:r.z.string().optional(),insert_text:r.z.string().optional(),old_str:r.z.string().optional(),view_range:r.z.array(r.z.number().int()).optional()}))),te=(0,o.createProviderDefinedToolFactory)({id:"anthropic.text_editor_20241022",inputSchema:e7}),tt=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({command:r.z.enum(["view","create","str_replace","insert","undo_edit"]),path:r.z.string(),file_text:r.z.string().optional(),insert_line:r.z.number().int().optional(),new_str:r.z.string().optional(),insert_text:r.z.string().optional(),old_str:r.z.string().optional(),view_range:r.z.array(r.z.number().int()).optional()}))),to=(0,o.createProviderDefinedToolFactory)({id:"anthropic.text_editor_20250124",inputSchema:tt}),tn=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({command:r.z.enum(["view","create","str_replace","insert"]),path:r.z.string(),file_text:r.z.string().optional(),insert_line:r.z.number().int().optional(),new_str:r.z.string().optional(),insert_text:r.z.string().optional(),old_str:r.z.string().optional(),view_range:r.z.array(r.z.number().int()).optional()}))),tr=(0,o.createProviderDefinedToolFactory)({id:"anthropic.text_editor_20250429",inputSchema:tn}),ta=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.array(r.z.object({type:r.z.literal("tool_reference"),toolName:r.z.string()})))),ti=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({query:r.z.string(),limit:r.z.number().optional()}))),ts=(0,o.createProviderExecutedToolFactory)({id:"anthropic.tool_search_bm25_20251119",inputSchema:ti,outputSchema:ta,supportsDeferredResults:!0}),tl={advisor_20260301:e=>T(e),bash_20241022:function(e={}){let{execute:t,...o}=e;return void 0===t?eY({...o,execute:async({command:e},{abortSignal:t,experimental_sandbox:o})=>{if(!o)throw Error("Sandbox session is not available");return await o.run({command:e,abortSignal:t})}}):eY({...o,...null===t?{}:{execute:t}})},bash_20250124:function(e={}){let{execute:t,...o}=e;return void 0===t?e0({...o,execute:async({command:e},{abortSignal:t,experimental_sandbox:o})=>{if(!o)throw Error("Sandbox session is not available");return await o.run({command:e,abortSignal:t})}}):e0({...o,...null===t?{}:{execute:t}})},codeExecution_20250522:(e={})=>el(e),codeExecution_20250825:(e={})=>(0,o.experimental_toolCaller)(ed(e),{type:"provider",prepareProviderOptions:e=>{let t=e?.anthropic;return{...e,anthropic:{...t,allowedCallers:[...new Set([...t?.allowedCallers??[],"code_execution_20250825"])]}}}}),codeExecution_20260120:(e={})=>(0,o.experimental_toolCaller)(eh(e),{type:"provider",prepareProviderOptions:e=>{let t=e?.anthropic;return{...e,anthropic:{...t,allowedCallers:[...new Set([...t?.allowedCallers??[],"code_execution_20260120"])]}}}}),computer_20241022:e2,computer_20250124:e6,computer_20251124:e3,computerToolset_20260801:C,memory_20250818:e9,textEditor_20241022:te,textEditor_20250124:to,textEditor_20250429:tr,textEditor_20250728:(e={})=>A(e),webFetch_20250910:(e={})=>en(e),webFetch_20260209:(e={})=>Q(e),webFetch_20260318:(e={})=>K(e),webSearch_20250305:(e={})=>V(e),webSearch_20260209:(e={})=>D(e),webSearch_20260318:(e={})=>U(e),toolSearchRegex_20251119:(e={})=>ey(e),toolSearchBm25_20251119:(e={})=>ts(e)},tu=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({id:r.z.string(),display_title:r.z.string().nullish(),name:r.z.string().nullish(),description:r.z.string().nullish(),latest_version:r.z.string().nullish(),source:r.z.string(),created_at:r.z.string(),updated_at:r.z.string()})));(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({data:r.z.array(r.z.object({version:r.z.string()}))})));var tc=(0,o.lazySchema)(()=>(0,o.zodSchema)(r.z.object({type:r.z.string(),skill_id:r.z.string(),name:r.z.string().nullish(),description:r.z.string().nullish()})));function td(e){let t=encodeURIComponent(e);return"."===t?"%252E":".."===t?"%252E%252E":t}var tp=class{constructor(e){this.config=e,this.specificationVersion="v4"}get provider(){return this.config.provider}async getHeaders(){return(0,o.combineHeaders)(await (0,o.resolve)(this.config.headers),{"anthropic-beta":"skills-2025-10-02"})}async fetchVersionMetadata({skillId:e,version:t,headers:n}){let{value:r}=await (0,o.getFromApi)({url:`${this.config.baseURL}/skills/${td(e)}/versions/${td(t)}`,validateUrl:!1,headers:n,failedResponseHandler:s,successfulResponseHandler:(0,o.createJsonResponseHandler)(tc),fetch:this.config.fetch});return{...null!=r.name?{name:r.name}:{},...null!=r.description?{description:r.description}:{}}}async uploadSkill(e){let t=new FormData;for(let n of(null!=e.displayTitle&&t.append("display_title",e.displayTitle),e.files)){let e=(0,o.convertInlineFileDataToUint8Array)(n.data);t.append("files[]",new Blob([e]),n.path)}let n=await this.getHeaders(),{value:r}=await (0,o.postFormDataToApi)({url:`${this.config.baseURL}/skills`,headers:n,formData:t,failedResponseHandler:s,successfulResponseHandler:(0,o.createJsonResponseHandler)(tu),fetch:this.config.fetch}),a=null!=r.latest_version?await this.fetchVersionMetadata({skillId:r.id,version:r.latest_version,headers:n}):{},i=a.name??r.name,l=a.description??r.description;return{providerReference:{anthropic:r.id},...null!=r.display_title?{displayTitle:r.display_title}:{},...null!=i?{name:i}:{},...null!=l?{description:l}:{},...null!=r.latest_version?{latestVersion:r.latest_version}:{},providerMetadata:{anthropic:{...null!=r.source?{source:r.source}:{},...null!=r.created_at?{createdAt:r.created_at}:{},...null!=r.updated_at?{updatedAt:r.updated_at}:{}}},warnings:[]}}},tm="https://api.anthropic.com",th=`${tm}/v1`;function tg(e={}){var r;let a,i=(r=(0,o.loadOptionalSetting)({settingValue:e.baseURL,environmentVariableName:"ANTHROPIC_BASE_URL"}),((a=(0,o.withoutTrailingSlash)((0,o.validateBaseURL)(r)))===tm?th:a)??th),s=e.name??"anthropic.messages",l={"image/*":[/^https?:\/\/.*$/],"application/pdf":[/^https?:\/\/.*$/]};if(e.apiKey&&e.authToken)throw new t.InvalidArgumentError({argument:"apiKey/authToken",message:"Both apiKey and authToken were provided. Please use only one authentication method."});let c=()=>{let t=e.authToken?{Authorization:`Bearer ${e.authToken}`}:{"x-api-key":(0,o.loadApiKey)({apiKey:e.apiKey,environmentVariableName:"ANTHROPIC_API_KEY",description:"Anthropic"})};return(0,o.withUserAgentSuffix)({"anthropic-version":"2023-06-01",...t,...e.headers},"ai-sdk/anthropic/4.0.65")},d={provider:s,baseURL:i,headers:c,fetch:e.fetch,generateId:e.generateId??o.generateId,supportedUrls:()=>l},p=e=>new eE(e,d),m=function(e){if(new.target)throw Error("The Anthropic model function cannot be called with the new keyword.");return p(e)};return m.specificationVersion="v4",m.languageModel=p,m.chat=p,m.messages=p,m.evaluationModel=e=>new n.Experimental_EvaluationLanguageModel({model:p(e),provider:`${s.replace(/\.messages$/,"")}.evaluation`}),m.experimental_batch=()=>new eB({provider:`${s.replace(/\.messages$/,"")}.batch`,config:d,supportedUrls:l}),m.embeddingModel=e=>{throw new t.NoSuchModelError({modelId:e,modelType:"embeddingModel"})},m.textEmbeddingModel=m.embeddingModel,m.imageModel=e=>{throw new t.NoSuchModelError({modelId:e,modelType:"imageModel"})},m.files=()=>new u({provider:s,baseURL:i,headers:c,fetch:e.fetch}),m.skills=()=>new tp({provider:`${s.replace(".messages","")}.skills`,baseURL:i,headers:c,fetch:e.fetch}),m.tools=tl,m}tg(),e.s(["createAnthropic",0,tg])},493880,e=>{"use strict";var t=e.i(376261),o=e.i(847841),n=e.i(110567),r=e.i(469719);function a(e){return e.replace(/[_-]([a-z])/g,e=>e[1].toUpperCase())}function i({rawName:e,providerOptions:t,warnings:o}){let n=a(e);n!==e&&t?.[e]!=null&&o.push({type:"deprecated",setting:`providerOptions key '${e}'`,message:`Use '${n}' instead.`})}var s={errorSchema:r.z.object({error:r.z.object({message:r.z.string(),type:r.z.string().nullish(),param:r.z.any().nullish(),code:r.z.union([r.z.string(),r.z.number()]).nullish()})}),errorToMessage:e=>e.error.message};function l(e){return e?.providerOptions?.openaiCompatible??{}}function u({id:e,model:t,created:n}){return(0,o.createLanguageModelResponseMetadata)({id:e,model:t,created:n||void 0})}function c(e){switch(e){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"other"}}var d=r.z.object({user:r.z.string().optional(),reasoningEffort:r.z.string().optional(),textVerbosity:r.z.string().optional(),strictJsonSchema:r.z.boolean().optional()}),p=class e{constructor(e,t){this.specificationVersion="v4",this.modelId=e,this.config=t;const n=t.errorStructure??s;this.chunkSchema=_(n.errorSchema),this.failedResponseHandler=(0,o.createJsonErrorResponseHandler)(n),this.supportsStructuredOutputs=t.supportsStructuredOutputs??!1}static[n.WORKFLOW_SERIALIZE](e){return(0,o.serializeModelOptions)({modelId:e.modelId,config:e.config})}static[n.WORKFLOW_DESERIALIZE](t){return new e(t.modelId,t.config)}get provider(){return this.config.provider}get providerOptionsName(){return this.config.provider.split(".")[0].trim()}get supportedUrls(){return this.config.supportedUrls?.()??{}}transformRequestBody(e){return this.config.transformRequestBody?.(e)??e}convertUsage(e){return this.config.convertUsage?.(e)??function(e){if(null==e)return(0,o.createNullLanguageModelUsage)();let t=e.prompt_tokens??0,n=e.completion_tokens??0,r=e.prompt_tokens_details?.cached_tokens??0,a=e.completion_tokens_details?.reasoning_tokens??0;return{inputTokens:{total:t,noCache:t-r,cacheRead:r,cacheWrite:void 0},outputTokens:{total:n,text:Math.max(0,n-a),reasoning:a},raw:e}}(e)}async getArgs({prompt:e,maxOutputTokens:n,temperature:r,topP:s,topK:u,frequencyPenalty:c,presencePenalty:p,reasoning:m,providerOptions:h,stopSequences:g,responseFormat:f,seed:y,toolChoice:_,tools:b}){var z;let v,w=[],x=await (0,o.parseProviderOptions)({provider:"openai-compatible",providerOptions:h,schema:d});null!=x&&w.push({type:"deprecated",setting:"providerOptions key 'openai-compatible'",message:"Use 'openaiCompatible' instead."}),i({rawName:this.providerOptionsName,providerOptions:h,warnings:w});let k=Object.assign(x??{},await (0,o.parseProviderOptions)({provider:"openaiCompatible",providerOptions:h,schema:d})??{},await (0,o.parseProviderOptions)({provider:this.providerOptionsName,providerOptions:h,schema:d})??{},await (0,o.parseProviderOptions)({provider:a(this.providerOptionsName),providerOptions:h,schema:d})??{}),I=k?.strictJsonSchema??!0;null!=u&&w.push({type:"unsupported",feature:"topK"}),f?.type!=="json"||null==f.schema||this.supportsStructuredOutputs||w.push({type:"unsupported",feature:"responseFormat",details:"JSON response format schema is only supported with structuredOutputs"});let{tools:T,toolChoice:S,toolWarnings:j}=function({tools:e,toolChoice:o}){e=e?.length?e:void 0;let n=[];if(null==e)return{tools:void 0,toolChoice:void 0,toolWarnings:n};let r=[];for(let t of e)"provider"===t.type?n.push({type:"unsupported",feature:`provider-defined tool ${t.id}`}):r.push({type:"function",function:{name:t.name,description:t.description,parameters:t.inputSchema,...null!=t.strict?{strict:t.strict}:{}}});if(null==o)return{tools:r,toolChoice:void 0,toolWarnings:n};let a=o.type;switch(a){case"auto":case"none":case"required":return{tools:r,toolChoice:a,toolWarnings:n};case"tool":return{tools:r,toolChoice:{type:"function",function:{name:o.toolName}},toolWarnings:n};default:throw new t.UnsupportedFunctionalityError({functionality:`tool choice type: ${a}`})}}({tools:b,toolChoice:_}),R=(z=this.providerOptionsName,(v=a(z))!==z&&h?.[v]!=null?v:z);return{metadataKey:R,args:{model:this.modelId,user:k.user,max_tokens:n,temperature:r,top_p:s,frequency_penalty:c,presence_penalty:p,response_format:f?.type==="json"?!0===this.supportsStructuredOutputs&&null!=f.schema?{type:"json_schema",json_schema:{schema:f.schema,strict:I,name:f.name??"response",description:f.description}}:{type:"json_object"}:void 0,stop:g,seed:y,...Object.fromEntries(Object.entries({...h?.[this.providerOptionsName],...h?.[a(this.providerOptionsName)]}).filter(([e])=>!Object.keys(d.shape).includes(e))),reasoning_effort:k.reasoningEffort??((0,o.isCustomReasoning)(m)?m:void 0),verbosity:k.textVerbosity,messages:function(e,{providerOptionsKey:n="google"}={}){let r=[];for(let{role:a,content:i,...s}of e){let e=l({...s});switch(a){case"system":r.push({role:"system",content:i,...e});break;case"user":if(1===i.length&&"text"===i[0].type){r.push({role:"user",content:i[0].text,...l(i[0])});break}r.push({role:"user",content:i.map(e=>{let n=l(e);switch(e.type){case"text":return{type:"text",text:e.text,...n};case"file":switch(e.data.type){case"reference":throw new t.UnsupportedFunctionalityError({functionality:"file parts with provider references"});case"text":throw new t.UnsupportedFunctionalityError({functionality:"text file parts"});case"url":case"data":{let r=(0,o.getTopLevelMediaType)(e.mediaType);if("image"===r)return{type:"image_url",image_url:{url:"url"===e.data.type?e.data.url.toString():`data:${(0,o.resolveFullMediaType)({part:e})};base64,${(0,o.convertToBase64)(e.data.data)}`},...n};if("video"===r)return{type:"video_url",video_url:{url:"url"===e.data.type?e.data.url.toString():`data:${(0,o.resolveFullMediaType)({part:e})};base64,${(0,o.convertToBase64)(e.data.data)}`},...n};if("audio"===r){if("url"===e.data.type)throw new t.UnsupportedFunctionalityError({functionality:"audio file parts with URLs"});let r=(0,o.resolveFullMediaType)({part:e}),a=function(e){switch(e){case"audio/wav":return"wav";case"audio/mp3":case"audio/mpeg":return"mp3";default:return null}}(r);if(null===a)throw new t.UnsupportedFunctionalityError({functionality:`audio media type ${r}`});return{type:"input_audio",input_audio:{data:(0,o.convertToBase64)(e.data.data),format:a},...n}}if("application"===r){if("url"===e.data.type)throw new t.UnsupportedFunctionalityError({functionality:"PDF file parts with URLs"});let r=(0,o.resolveFullMediaType)({part:e});if("application/pdf"!==r)throw new t.UnsupportedFunctionalityError({functionality:`file part media type ${r}`});return{type:"file",file:{filename:e.filename??"document.pdf",file_data:`data:application/pdf;base64,${(0,o.convertToBase64)(e.data.data)}`},...n}}if("text"===r)return{type:"text",text:"url"===e.data.type?e.data.url.toString():"string"==typeof e.data.data?new TextDecoder().decode((0,o.convertBase64ToUint8Array)(e.data.data)):new TextDecoder().decode(e.data.data),...n};throw new t.UnsupportedFunctionalityError({functionality:`file part media type ${e.mediaType}`})}}}}),...e});break;case"assistant":{let t="",o="",a=[];for(let e of i){let r=l(e);switch(e.type){case"text":t+=e.text;break;case"reasoning":o+=e.text;break;case"tool-call":{let t=e.providerOptions?.[n]?.thoughtSignature??e.providerOptions?.google?.thoughtSignature;a.push({id:e.toolCallId,type:"function",function:{name:e.toolName,arguments:JSON.stringify(e.input)},...r,...t?{extra_content:{google:{thought_signature:String(t)}}}:{}})}}}r.push({role:"assistant",content:a.length>0?t||null:t,...o.length>0?{reasoning_content:o}:{},tool_calls:a.length>0?a:void 0,...e});break}case"tool":for(let e of i){let t;if("tool-approval-response"===e.type)continue;let o=e.output;switch(o.type){case"text":case"error-text":t=o.value;break;case"execution-denied":t=o.reason??"Tool call execution denied.";break;case"content":case"json":case"error-json":t=JSON.stringify(o.value)}let n=l(e);r.push({role:"tool",tool_call_id:e.toolCallId,content:t,...n})}break;default:throw Error(`Unsupported role: ${a}`)}}return r}(e,{providerOptionsKey:R}),tools:T,tool_choice:S},warnings:[...w,...j]}}async doGenerate(e){let{args:n,warnings:r,metadataKey:a}=await this.getArgs({...e}),i=this.transformRequestBody(n),s=JSON.stringify(i),{responseHeaders:l,value:d,rawValue:p}=await (0,o.postJsonToApi)({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:(0,o.combineHeaders)(this.config.headers?.(),e.headers),body:i,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:(0,o.createJsonResponseHandler)(f),abortSignal:e.abortSignal,fetch:this.config.fetch}),m=d.choices[0];if(null==m)throw new t.InvalidResponseDataError({data:p,message:"Response did not contain any choices."});let h=[];h.push(...g(m.message.content));let y=m.message.reasoning_content??m.message.reasoning;if(null!=y&&y.length>0&&h.push({type:"reasoning",text:y}),null!=m.message.tool_calls)for(let e of m.message.tool_calls){let t=e.extra_content?.google?.thought_signature;h.push({type:"tool-call",toolCallId:e.id||(0,o.generateId)(),toolName:e.function.name,input:e.function.arguments,...t?{providerMetadata:{[a]:{thoughtSignature:t}}}:{}})}let _={[a]:{},...await this.config.metadataExtractor?.extractMetadata?.({parsedBody:p})},b=d.usage?.completion_tokens_details;return b?.accepted_prediction_tokens!=null&&(_[a].acceptedPredictionTokens=b?.accepted_prediction_tokens),b?.rejected_prediction_tokens!=null&&(_[a].rejectedPredictionTokens=b?.rejected_prediction_tokens),{content:h,finishReason:{unified:c(m.finish_reason),raw:m.finish_reason??void 0},usage:this.convertUsage(d.usage),providerMetadata:_,request:{body:s},response:{...u(d),headers:l,body:p},warnings:r}}async doStream(e){let n,r,a,{args:i,warnings:s,metadataKey:l}=await this.getArgs({...e}),d=this.transformRequestBody({...i,stream:!0,stream_options:this.config.includeUsage?{include_usage:!0}:void 0}),p=this.config.metadataExtractor?.createStreamExtractor(),{responseHeaders:m,value:h}=await (0,o.postJsonToApi)({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:(0,o.combineHeaders)(this.config.headers?.(),e.headers),body:d,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:(0,o.createEventSourceResponseHandler)(this.chunkSchema),abortSignal:e.abortSignal,fetch:this.config.fetch}),f=new Map,y=new Set,_=e=>{let t=e.index;if(null==t||y.has(t))return void n.processDelta(e);let o=f.get(t);null==o?(o={id:e.id??null,bufferedArguments:"",extraContent:e.extra_content??null},f.set(t,o)):(null==o.id&&null!=e.id&&(o.id=e.id),null==o.extraContent&&null!=e.extra_content&&(o.extraContent=e.extra_content));let r=e.function?.arguments;null!=r&&(o.bufferedArguments+=r);let a=e.function?.name;if(null!=a){let e={index:t,id:o.id,function:{name:a,arguments:o.bufferedArguments},extra_content:o.extraContent??void 0};n.processDelta(e),f.delete(t),y.add(t)}},b=!1,z=!1,v=!1,w=e=>this.convertUsage(e);return{stream:h.pipeThrough(new TransformStream({start(e){n=new o.StreamingToolCallTracker(e,{generateId:o.generateId,extractMetadata:e=>{let t=e.extra_content?.google?.thought_signature;return t?{[l]:{thoughtSignature:t}}:void 0},buildToolCallProviderMetadata:e=>e}),e.enqueue({type:"stream-start",warnings:s})},transform(t,o){if(e.includeRawChunks&&o.enqueue({type:"raw",rawValue:t.rawValue}),!t.success){r={unified:"error",raw:void 0},o.enqueue({type:"error",error:t.error});return}if(p?.processChunk(t.rawValue),"error"in t.value){r={unified:"error",raw:void 0},o.enqueue({type:"error",error:t.value.error});return}let n=t.value;if(!b){let e=u(n);Object.values(e).some(Boolean)&&(b=!0,o.enqueue({type:"response-metadata",...e}))}null!=n.usage&&(a=n.usage);let i=n.choices[0];if(i?.finish_reason!=null&&(r={unified:c(i.finish_reason),raw:i.finish_reason??void 0}),i?.delta==null)return;let s=i.delta,l=e=>{v&&(o.enqueue({type:"text-end",id:"txt-0"}),v=!1),z||(o.enqueue({type:"reasoning-start",id:"reasoning-0"}),z=!0),o.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:e})},d=e=>{z&&(o.enqueue({type:"reasoning-end",id:"reasoning-0"}),z=!1),v||(o.enqueue({type:"text-start",id:"txt-0"}),v=!0),o.enqueue({type:"text-delta",id:"txt-0",delta:e})},m=s.reasoning_content??s.reasoning;for(let e of(m&&l(m),g(s.content)))"reasoning"===e.type?l(e.text):d(e.text);if(null!=s.tool_calls&&s.tool_calls.length>0)for(let e of(z&&(o.enqueue({type:"reasoning-end",id:"reasoning-0"}),z=!1),s.tool_calls))_(e)},flush(e){for(let[t,o]of(z&&e.enqueue({type:"reasoning-end",id:"reasoning-0"}),v&&e.enqueue({type:"text-end",id:"txt-0"}),f))n.processDelta({index:t,id:o.id,function:{arguments:o.bufferedArguments}});f.clear(),n.flush(),null==r&&(r={unified:"error",raw:void 0},e.enqueue({type:"error",error:new t.InvalidResponseDataError({data:void 0,message:"Response stream ended without a finish reason."})}));let o={[l]:{},...p?.buildMetadata()};a?.completion_tokens_details?.accepted_prediction_tokens!=null&&(o[l].acceptedPredictionTokens=a?.completion_tokens_details?.accepted_prediction_tokens),a?.completion_tokens_details?.rejected_prediction_tokens!=null&&(o[l].rejectedPredictionTokens=a?.completion_tokens_details?.rejected_prediction_tokens),e.enqueue({type:"finish",finishReason:r,usage:w(a),providerMetadata:o})}})),request:{body:d},response:{headers:m}}}},m=r.z.looseObject({prompt_tokens:r.z.number().nullish(),completion_tokens:r.z.number().nullish(),total_tokens:r.z.number().nullish(),prompt_tokens_details:r.z.looseObject({cached_tokens:r.z.number().nullish()}).nullish(),completion_tokens_details:r.z.looseObject({reasoning_tokens:r.z.number().nullish(),accepted_prediction_tokens:r.z.number().nullish(),rejected_prediction_tokens:r.z.number().nullish()}).nullish()}).nullish(),h=r.z.union([r.z.string(),r.z.array(r.z.looseObject({type:r.z.string()}))]).nullish();function g(e){if(null==e)return[];if("string"==typeof e)return e.length>0?[{type:"text",text:e}]:[];let t=[];for(let o of e)if("text"===o.type&&"string"==typeof o.text)o.text.length>0&&t.push({type:"text",text:o.text});else if("thinking"===o.type&&Array.isArray(o.thinking)){let e=o.thinking.filter(e=>null!=e&&"object"==typeof e&&"type"in e&&"text"===e.type&&"text"in e&&"string"==typeof e.text).map(e=>e.text).join("");e.length>0&&t.push({type:"reasoning",text:e})}return t}var f=r.z.looseObject({id:r.z.string().nullish(),created:r.z.number().nullish(),model:r.z.string().nullish(),choices:r.z.array(r.z.object({message:r.z.object({role:r.z.literal("assistant").nullish(),content:h,reasoning_content:r.z.string().nullish(),reasoning:r.z.string().nullish(),tool_calls:r.z.array(r.z.object({id:r.z.string().nullish(),function:r.z.object({name:r.z.string(),arguments:r.z.string()}),extra_content:r.z.object({google:r.z.object({thought_signature:r.z.string().nullish()}).nullish()}).nullish()})).nullish()}),finish_reason:r.z.string().nullish()})),usage:m}),y=r.z.looseObject({id:r.z.string().nullish(),created:r.z.number().nullish(),model:r.z.string().nullish(),choices:r.z.array(r.z.object({delta:r.z.object({role:r.z.enum(["assistant",""]).nullish(),content:h,reasoning_content:r.z.string().nullish(),reasoning:r.z.string().nullish(),tool_calls:r.z.array(r.z.object({index:r.z.number().nullish(),id:r.z.string().nullish(),function:r.z.object({name:r.z.string().nullish(),arguments:r.z.string().nullish()}),extra_content:r.z.object({google:r.z.object({thought_signature:r.z.string().nullish()}).nullish()}).nullish()})).nullish()}).nullish(),finish_reason:r.z.string().nullish()})),usage:m}),_=e=>r.z.union([y,e]);function b(e){if(null==e)return(0,o.createNullLanguageModelUsage)();let t=e.prompt_tokens??0,n=e.completion_tokens??0;return{inputTokens:{total:t,noCache:t,cacheRead:void 0,cacheWrite:void 0},outputTokens:{total:n,text:n,reasoning:void 0},raw:e}}function z(e){switch(e){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"other"}}var v=r.z.object({echo:r.z.boolean().optional(),logitBias:r.z.record(r.z.string(),r.z.number()).optional(),suffix:r.z.string().optional(),user:r.z.string().optional()}),w=class e{constructor(e,t){this.specificationVersion="v4",this.modelId=e,this.config=t;const n=t.errorStructure??s;this.chunkSchema=I(n.errorSchema),this.failedResponseHandler=(0,o.createJsonErrorResponseHandler)(n)}static[n.WORKFLOW_SERIALIZE](e){return(0,o.serializeModelOptions)({modelId:e.modelId,config:e.config})}static[n.WORKFLOW_DESERIALIZE](t){return new e(t.modelId,t.config)}get provider(){return this.config.provider}get providerOptionsName(){return this.config.provider.split(".")[0].trim()}get supportedUrls(){return this.config.supportedUrls?.()??{}}async getArgs({prompt:e,maxOutputTokens:n,temperature:r,topP:s,topK:l,frequencyPenalty:u,presencePenalty:c,stopSequences:d,responseFormat:p,seed:m,providerOptions:h,tools:g,toolChoice:f}){let y=[];i({rawName:this.providerOptionsName,providerOptions:h,warnings:y});let _=Object.assign(await (0,o.parseProviderOptions)({provider:this.providerOptionsName,providerOptions:h,schema:v})??{},await (0,o.parseProviderOptions)({provider:a(this.providerOptionsName),providerOptions:h,schema:v})??{});null!=l&&y.push({type:"unsupported",feature:"topK"}),g?.length&&y.push({type:"unsupported",feature:"tools"}),null!=f&&y.push({type:"unsupported",feature:"toolChoice"}),null!=p&&"text"!==p.type&&y.push({type:"unsupported",feature:"responseFormat",details:"JSON response format is not supported."});let{prompt:b,stopSequences:z}=function({prompt:e,user:o="user",assistant:n="assistant"}){let r="";for(let{role:a,content:i}of("system"===e[0].role&&(r+=`${e[0].content}
|
|
3
3
|
|
|
4
4
|
`,e=e.slice(1)),e))switch(a){case"system":throw new t.InvalidPromptError({message:"Unexpected system message in prompt: ${content}",prompt:e});case"user":{let e=i.map(e=>{if("text"===e.type)return e.text}).filter(Boolean).join("");r+=`${o}:
|