alchemylab-opencode 2.0.1 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/NODE_COMPAT.md +8 -1
  2. package/dist/20260127222353_familiar_lady_ursula-YYOFSQD5.js +18 -0
  3. package/dist/20260211171708_add_project_commands-3GKQTPBZ.js +18 -0
  4. package/dist/20260213144116_wakeful_the_professor-ROO7OAVL.js +18 -0
  5. package/dist/20260225215848_workspace-V2OZTNFF.js +18 -0
  6. package/dist/20260227213759_add_session_workspace_id-GVDWAXKM.js +18 -0
  7. package/dist/20260228203230_blue_harpoon-Z5QP2II5.js +18 -0
  8. package/dist/20260303231226_add_workspace_fields-QOVAFN7W.js +18 -0
  9. package/dist/20260309230000_move_org_to_state-RQURSDZD.js +18 -0
  10. package/dist/20260312043431_session_message_cursor-VBISKDXL.js +18 -0
  11. package/dist/20260323234822_events-PILJHLNA.js +18 -0
  12. package/dist/20260410174513_workspace-name-63YCZ5NS.js +18 -0
  13. package/dist/20260413175956_chief_energizer-NMAZYGDO.js +18 -0
  14. package/dist/20260423070820_add_icon_url_override-RAJCVNEP.js +18 -0
  15. package/dist/20260427172553_slow_nightmare-ULYYZLR4.js +18 -0
  16. package/dist/20260428004200_add_session_path-U4WO2TGE.js +18 -0
  17. package/dist/20260501142318_next_venus-6BCYATSC.js +18 -0
  18. package/dist/20260504145000_add_sync_owner-RGVHV6LN.js +18 -0
  19. package/dist/20260507164347_add_workspace_time-GE6UHNPM.js +18 -0
  20. package/dist/{20260510033149_session_usage-UGBVOXZB.js → 20260510033149_session_usage-7XHCFVKY.js} +5 -1
  21. package/dist/20260511000411_data_migration_state-2EGZKFLB.js +18 -0
  22. package/dist/20260511173437_session-metadata-K322YY33.js +18 -0
  23. package/dist/20260601010001_normalize_storage_paths-VZDTY366.js +18 -0
  24. package/dist/{20260225215848_workspace-ZMSOZSPA.js → 20260601202201_amazing_prowler-YT6PLK3L.js} +5 -1
  25. package/dist/{20260228203230_blue_harpoon-IW3Z4TQZ.js → 20260602002951_lowly_union_jack-6VLQTBVB.js} +5 -1
  26. package/dist/20260602182828_add_project_directories-TVSRD25A.js +18 -0
  27. package/dist/20260603001617_session_message_projection_indexes-PHKTF6HK.js +18 -0
  28. package/dist/{20260622170816_reset_v2_session_state-5JPHJTZG.js → 20260603040000_session_message_projection_order-7RTV2POG.js} +5 -1
  29. package/dist/20260603141458_session_input_inbox-RSBWABG7.js +18 -0
  30. package/dist/20260603160727_jittery_ezekiel_stane-DXBLLRVV.js +18 -0
  31. package/dist/20260604172448_event_sourced_session_input-H6Z3JEBD.js +18 -0
  32. package/dist/20260605003541_add_session_context_snapshot-6FDPM2TK.js +18 -0
  33. package/dist/20260605042240_add_context_epoch_agent-C2OF2UKR.js +18 -0
  34. package/dist/20260611035744_credential-YNZ47FSH.js +18 -0
  35. package/dist/20260611192811_lush_chimera-E357VI6P.js +18 -0
  36. package/dist/20260612174303_project_dir_strategy-VUGGK42O.js +18 -0
  37. package/dist/20260622142730_simplify_session_context_epoch-UYGXZ5BX.js +18 -0
  38. package/dist/20260622170816_reset_v2_session_state-EILLPCJQ.js +18 -0
  39. package/dist/20260622202450_simplify_session_input-Y65GDGBO.js +18 -0
  40. package/dist/NodeSdk-AGMQWBHH.js +18 -0
  41. package/dist/anthropic-45OFTLAW.js +18 -0
  42. package/dist/anthropic-FVULF7C3.js +18 -0
  43. package/dist/app-runtime-LDQWNGWP.js +18 -0
  44. package/dist/chunk-2JE3QYG6.js +18 -0
  45. package/dist/chunk-2MRHL4B2.js +18 -0
  46. package/dist/chunk-4GJE6OMN.js +190 -0
  47. package/dist/chunk-4MBUHJHY.js +22 -0
  48. package/dist/chunk-5BLZCAU6.js +55 -0
  49. package/dist/chunk-7XX6TY62.js +259 -0
  50. package/dist/chunk-ANF3QA3Z.js +48 -0
  51. package/dist/chunk-AZUMH3TO.js +18 -0
  52. package/dist/chunk-B74WSFN4.js +878 -0
  53. package/dist/chunk-BQ4IEPN3.js +19 -0
  54. package/dist/chunk-CYRZU5QM.js +33 -0
  55. package/dist/chunk-DADVNQTM.js +1490 -0
  56. package/dist/chunk-DO2UZ6NY.js +18 -0
  57. package/dist/chunk-DWEYXIQI.js +780 -0
  58. package/dist/chunk-EK6FQQHY.js +20 -0
  59. package/dist/chunk-ELPXQ32J.js +90 -0
  60. package/dist/chunk-FGLPSSRK.js +19 -0
  61. package/dist/chunk-FOHYZ7MJ.js +55 -0
  62. package/dist/chunk-FV7U6PVP.js +18 -0
  63. package/dist/chunk-FYYAOZPU.js +18 -0
  64. package/dist/chunk-G7PFO5HG.js +920 -0
  65. package/dist/chunk-GDWO6EXN.js +22 -0
  66. package/dist/chunk-GW3ZRKAI.js +20 -0
  67. package/dist/chunk-IYUSBBGY.js +35 -0
  68. package/dist/chunk-JPOFLMNH.js +18 -0
  69. package/dist/{chunk-VURLSDCB.js → chunk-K5LKDIVU.js} +4 -0
  70. package/dist/chunk-KS4WLVK5.js +19 -0
  71. package/dist/chunk-LIXP4TPL.js +18 -0
  72. package/dist/chunk-LSC4RT5V.js +36 -0
  73. package/dist/chunk-M5A6NFHQ.js +28 -0
  74. package/dist/chunk-M6E6KNLV.js +30 -0
  75. package/dist/chunk-MLFZXUGQ.js +18 -0
  76. package/dist/chunk-NDI67DRG.js +31 -0
  77. package/dist/chunk-NGT6LCW6.js +18 -0
  78. package/dist/chunk-OCWGUTZJ.js +36 -0
  79. package/dist/chunk-OGDRUXMJ.js +18 -0
  80. package/dist/chunk-OGJKLJC7.js +29 -0
  81. package/dist/chunk-OT2YNR56.js +19 -0
  82. package/dist/chunk-OUVSKG2H.js +19 -0
  83. package/dist/chunk-P5RLCJUV.js +18 -0
  84. package/dist/chunk-Q3WIUQXB.js +18 -0
  85. package/dist/{20260227213759_add_session_workspace_id-ROENWPKA.js → chunk-QCRIXKIC.js} +5 -1
  86. package/dist/chunk-QD24DLUD.js +18 -0
  87. package/dist/chunk-R2GWBJEP.js +18 -0
  88. package/dist/chunk-RPAXSOGH.js +18 -0
  89. package/dist/chunk-TK5R7QUN.js +18 -0
  90. package/dist/chunk-TNQWZFIZ.js +28 -0
  91. package/dist/chunk-UCLPBO4I.js +18 -0
  92. package/dist/chunk-UPEPL4I2.js +18 -0
  93. package/dist/chunk-V6FDDNGV.js +117 -0
  94. package/dist/chunk-V6HERYFV.js +18 -0
  95. package/dist/chunk-V7XKKJ7X.js +24 -0
  96. package/dist/chunk-VHDYUBBS.js +23 -0
  97. package/dist/chunk-VWLJXTZ5.js +18 -0
  98. package/dist/chunk-VXAPFOIL.js +22 -0
  99. package/dist/chunk-WKZYINC7.js +29 -0
  100. package/dist/chunk-WPMP2ZFE.js +40 -0
  101. package/dist/chunk-WRTNIOI3.js +18 -0
  102. package/dist/chunk-X5F46HR5.js +18 -0
  103. package/dist/chunk-XPS7TQZG.js +22 -0
  104. package/dist/chunk-YJPP6IQ3.js +23 -0
  105. package/dist/chunk-ZYQWFC55.js +22 -0
  106. package/dist/code-mode-YYOGD36U.js +502 -0
  107. package/dist/copilot-provider-QVMLQZZC.js +18 -0
  108. package/dist/dist-5NQOHNPL.js +18 -0
  109. package/dist/dist-7CT3XCNN.js +32 -0
  110. package/dist/dist-CL46WFZG.js +18 -0
  111. package/dist/{20260605042240_add_context_epoch_agent-W6IQYZXE.js → dist-CYBRID2F.js} +5 -1
  112. package/dist/dist-HXJTF22W.js +32 -0
  113. package/dist/dist-JFXI53ZF.js +22 -0
  114. package/dist/dist-KBYKWVT5.js +22 -0
  115. package/dist/dist-KM5HCPZX.js +35 -0
  116. package/dist/dist-KTNLTEHB.js +18 -0
  117. package/dist/dist-KZ5R5QM5.js +24 -0
  118. package/dist/dist-NLXUYBW7.js +32 -0
  119. package/dist/dist-O4DF72J2.js +22 -0
  120. package/dist/dist-PH4MEGVR.js +22 -0
  121. package/dist/{20260511000411_data_migration_state-FB4LBFSE.js → dist-QJPOJCLB.js} +5 -1
  122. package/dist/dist-QYH62TCJ.js +22 -0
  123. package/dist/{20260303231226_add_workspace_fields-OUVZMNAG.js → dist-RIC4WKHC.js} +5 -1
  124. package/dist/dist-T776XKTM.js +22 -0
  125. package/dist/dist-TCE5MKZQ.js +23 -0
  126. package/dist/dist-TH2Q44RX.js +50 -0
  127. package/dist/dist-VV5FV5RT.js +101 -0
  128. package/dist/dist-XAFENVUS.js +22 -0
  129. package/dist/dist-XPFB35TX.js +32 -0
  130. package/dist/dist-YUH4RKR5.js +28 -0
  131. package/dist/dist-es-43ZM44MP.js +18 -0
  132. package/dist/dist-es-6PLFRCS4.js +18 -0
  133. package/dist/dist-es-G5UIJOU7.js +26 -0
  134. package/dist/{20260428004200_add_session_path-LGW75WYA.js → dist-es-HYIIGUNX.js} +5 -1
  135. package/dist/dist-es-L2GU465G.js +18 -0
  136. package/dist/dist-es-LSR2QCFZ.js +18 -0
  137. package/dist/dist-es-RGEIM2BP.js +18 -0
  138. package/dist/dist-es-SITTNOGV.js +18 -0
  139. package/dist/dist-es-W5GYOX6F.js +18 -0
  140. package/dist/esm-NN5W7YCL.js +18 -0
  141. package/dist/esm-XWJSHYHG.js +18 -0
  142. package/dist/getMachineId-bsd-L5I5TZ5I.js +18 -0
  143. package/dist/getMachineId-darwin-YB7KG37W.js +19 -0
  144. package/dist/getMachineId-linux-EL47KXX7.js +18 -0
  145. package/dist/getMachineId-unsupported-QOWPEBPN.js +18 -0
  146. package/dist/getMachineId-win-HCRYRDFJ.js +18 -0
  147. package/dist/lib-ZP7Q6A3E.js +199 -0
  148. package/dist/loadCognitoIdentity-EWT55EI7.js +18 -0
  149. package/dist/loadSso-AGOUE6RL.js +18 -0
  150. package/dist/{20260213144116_wakeful_the_professor-ZVDD54AK.js → loadSts-RH5L3PIX.js} +5 -1
  151. package/dist/mantle-IJXDXT4M.js +25 -0
  152. package/dist/mime-types-46EO4HOZ.js +18 -0
  153. package/dist/multipart-parser-KZWMKXA4.js +19 -0
  154. package/dist/{20260211171708_add_project_commands-GDOHPDPF.js → open-7KXTRM37.js} +5 -1
  155. package/dist/openai-ZOJI6I5R.js +18 -0
  156. package/dist/p-map-CYL6ILJW.js +18 -0
  157. package/dist/photon-W56QZY4L.js +18 -0
  158. package/dist/{20260423070820_add_icon_url_override-X5SHFGTI.js → pkce-VT4ITJTB.js} +5 -1
  159. package/dist/{pty.node-Y3N2XKYG.js → pty.node-IWULXXG6.js} +5 -1
  160. package/dist/run.js +5 -1
  161. package/dist/serve.js +143 -1
  162. package/dist/server-LVIHYOCY.js +21 -0
  163. package/dist/session-6OPJNJMK.js +18 -0
  164. package/dist/signin-OCIW23YM.js +18 -0
  165. package/dist/src-3NCXEROI.js +18 -0
  166. package/dist/src-LXWGIUZH.js +18 -0
  167. package/dist/src-WDYKISPD.js +20 -0
  168. package/dist/src-YAAFIGTW.js +18 -0
  169. package/dist/sso-oidc-OMMKINFE.js +18 -0
  170. package/dist/sts-MWK22JIX.js +18 -0
  171. package/dist/token-QPO3OAGS.js +18 -0
  172. package/dist/token-util-YGPCEEPO.js +18 -0
  173. package/dist/unified-W3ZKZ4HG.js +18 -0
  174. package/dist/worktree-32M5MTFE.js +18 -0
  175. package/package.json +40 -40
  176. package/postinstall.cjs +4 -2
  177. package/dist/20260127222353_familiar_lady_ursula-KV747FJX.js +0 -14
  178. package/dist/20260309230000_move_org_to_state-NOXAPU5V.js +0 -14
  179. package/dist/20260312043431_session_message_cursor-DJ4T3T4R.js +0 -14
  180. package/dist/20260323234822_events-72GIKJ2A.js +0 -14
  181. package/dist/20260410174513_workspace-name-JXSWFBJN.js +0 -14
  182. package/dist/20260413175956_chief_energizer-4HEWZ6U3.js +0 -14
  183. package/dist/20260427172553_slow_nightmare-PS5T2AH2.js +0 -14
  184. package/dist/20260501142318_next_venus-J3TLVXZ6.js +0 -14
  185. package/dist/20260504145000_add_sync_owner-3R52GB4C.js +0 -14
  186. package/dist/20260507164347_add_workspace_time-JHDRCZAR.js +0 -14
  187. package/dist/20260511173437_session-metadata-T2XHGWHS.js +0 -14
  188. package/dist/20260601010001_normalize_storage_paths-5MAY5GT3.js +0 -14
  189. package/dist/20260601202201_amazing_prowler-PET224YG.js +0 -14
  190. package/dist/20260602002951_lowly_union_jack-PG6XDMGL.js +0 -14
  191. package/dist/20260602182828_add_project_directories-ZCH2ACGG.js +0 -14
  192. package/dist/20260603001617_session_message_projection_indexes-XVLJTUF2.js +0 -14
  193. package/dist/20260603040000_session_message_projection_order-XG6RACZQ.js +0 -14
  194. package/dist/20260603141458_session_input_inbox-K2VQ7V6E.js +0 -14
  195. package/dist/20260603160727_jittery_ezekiel_stane-WKJLRDO7.js +0 -14
  196. package/dist/20260604172448_event_sourced_session_input-NTXOECR7.js +0 -14
  197. package/dist/20260605003541_add_session_context_snapshot-DXMQEXMT.js +0 -14
  198. package/dist/20260611035744_credential-XTMSYTJD.js +0 -14
  199. package/dist/20260611192811_lush_chimera-XPLIQMJD.js +0 -14
  200. package/dist/20260612174303_project_dir_strategy-FR2NGQKK.js +0 -14
  201. package/dist/20260622142730_simplify_session_context_epoch-NTQZR3RE.js +0 -14
  202. package/dist/20260622202450_simplify_session_input-2EXF2HMV.js +0 -14
  203. package/dist/app-runtime-HQBOCDV5.js +0 -14
  204. package/dist/chunk-4FEBIOI5.js +0 -865
  205. package/dist/chunk-4K2RXRZL.js +0 -14
  206. package/dist/chunk-4RFMKEKM.js +0 -1455
  207. package/dist/chunk-BM2C7NHL.js +0 -41
  208. package/dist/chunk-MKEMZFJI.js +0 -393
  209. package/dist/chunk-OMDJ6ZZ2.js +0 -684
  210. package/dist/chunk-OWMG4NNF.js +0 -186
  211. package/dist/chunk-QRABYJKL.js +0 -14
  212. package/dist/chunk-RHIWAYN5.js +0 -14
  213. package/dist/chunk-Z5TLIUAI.js +0 -28
  214. package/dist/code-mode-7BQJUARW.js +0 -40
  215. package/dist/copilot-provider-TX4YFKJZ.js +0 -14
  216. package/dist/photon-VQS5F5BI.js +0 -14
  217. package/dist/server-BFUQR7MX.js +0 -17
  218. package/dist/session-6RNXZNG6.js +0 -14
  219. package/dist/worktree-QHQHX3SG.js +0 -14
  220. package/patches/@ai-sdk%2Famazon-bedrock@4.0.166.patch +0 -164
  221. package/patches/@ai-sdk%2Fanthropic@3.0.111.patch +0 -528
  222. package/patches/@ai-sdk%2Fgoogle@3.0.73.patch +0 -69
  223. package/patches/@ai-sdk%2Fgroq@3.0.31.patch +0 -79
  224. package/patches/@ai-sdk%2Fmistral@3.0.51.patch +0 -714
  225. package/patches/@ai-sdk%2Fopenai-compatible@2.0.41.patch +0 -39
  226. package/patches/@ai-sdk%2Fopenai@3.0.88.patch +0 -280
  227. package/patches/@ai-sdk%2Fxai@3.0.139.patch +0 -296
  228. package/patches/@modelcontextprotocol%2Fsdk@1.29.0.patch +0 -647
  229. package/patches/@npmcli%2Fagent@4.0.2.patch +0 -13
  230. package/patches/effect@4.0.0-beta.83.patch +0 -57
  231. package/patches/gcp-metadata@8.1.2.patch +0 -14
  232. package/patches/pacote@21.5.0.patch +0 -18
@@ -0,0 +1,19 @@
1
+ // Built by esbuild from opencode-server source
2
+ if (typeof globalThis.Bun === 'undefined') {
3
+ globalThis.Bun = {
4
+ version: '0.0.0-node-compat',
5
+ stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
6
+ which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
7
+ };
8
+ }
9
+ if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
10
+ if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
11
+ import { createRequire as __alchemyCreateRequire } from 'node:module';
12
+ const require = __alchemyCreateRequire(import.meta.url);
13
+ import { fileURLToPath as __alchemyFileURLToPath } from 'node:url';
14
+ import { dirname as __alchemyDirname } from 'node:path';
15
+ const __alchemy_filename = __alchemyFileURLToPath(import.meta.url);
16
+ const __alchemy_dirname = __alchemyDirname(__alchemy_filename);
17
+
18
+ import{a as Ee,b as Pe,c as qe,d as ke,e as Me,g as Re,j as ve,k as _,l as m,m as re,n as $e,o as _e,p as je,q as K,r as V,s as Se,t as Ue,u as Ae,v as De}from"./chunk-VXAPFOIL.js";import{b as Ie,g as ze,n as be}from"./chunk-WKZYINC7.js";import{A as e}from"./chunk-WPMP2ZFE.js";import{a as S}from"./chunk-2MRHL4B2.js";var ct=_(()=>m(e.object({type:e.literal("error"),error:e.object({type:e.string(),message:e.string()})}))),Fe=Ue({errorSchema:ct,errorToMessage:S(t=>t.error.message,"errorToMessage")}),Ye=e.object({type:e.string(),category:e.string().nullish(),explanation:e.string().nullish(),recommended_model:e.string().nullish()}),pe=e.union([e.object({type:e.literal("code_execution_20250825"),tool_id:e.string()}),e.object({type:e.literal("code_execution_20260120"),tool_id:e.string()}),e.object({type:e.literal("direct")})]),ut=_(()=>m(e.object({type:e.literal("message"),id:e.string().nullish(),model:e.string().nullish(),input_transformations:e.array(e.looseObject({type:e.string(),path:e.string().nullish(),reason:e.string().nullish()})).nullish(),content:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("text"),text:e.string(),citations:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("web_search_result_location"),cited_text:e.string(),url:e.string(),title:e.string(),encrypted_index:e.string()}),e.object({type:e.literal("page_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_page_number:e.number(),end_page_number:e.number()}),e.object({type:e.literal("char_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_char_index:e.number(),end_char_index:e.number()})])).optional()}),e.object({type:e.literal("thinking"),thinking:e.string(),signature:e.string()}),e.object({type:e.literal("redacted_thinking"),data:e.string()}),e.object({type:e.literal("compaction"),content:e.string()}),e.object({type:e.literal("tool_use"),id:e.string(),name:e.string(),input:e.unknown(),caller:pe.optional()}),e.object({type:e.literal("server_tool_use"),id:e.string(),name:e.string(),input:e.record(e.string(),e.unknown()).nullish(),caller:pe.optional()}),e.object({type:e.literal("mcp_tool_use"),id:e.string(),name:e.string(),input:e.unknown(),server_name:e.string()}),e.object({type:e.literal("mcp_tool_result"),tool_use_id:e.string(),is_error:e.boolean(),content:e.array(e.union([e.string(),e.object({type:e.literal("text"),text:e.string()})]))}),e.object({type:e.literal("web_fetch_tool_result"),tool_use_id:e.string(),caller:pe.optional(),content:e.union([e.object({type:e.literal("web_fetch_result"),url:e.string(),retrieved_at:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),media_type:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),media_type:e.literal("text/plain"),data:e.string()})])})}),e.object({type:e.literal("web_fetch_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("web_search_tool_result"),tool_use_id:e.string(),caller:pe.optional(),content:e.union([e.array(e.object({type:e.literal("web_search_result"),url:e.string(),title:e.string(),encrypted_content:e.string(),page_age:e.string().nullish()})),e.object({type:e.literal("web_search_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("code_execution_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("encrypted_code_execution_result"),encrypted_stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("bash_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("text_editor_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})])}),e.object({type:e.literal("tool_search_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("tool_search_tool_search_result"),tool_references:e.array(e.object({type:e.literal("tool_reference"),tool_name:e.string()}))}),e.object({type:e.literal("tool_search_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("advisor_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("advisor_result"),text:e.string()}),e.object({type:e.literal("advisor_redacted_result"),encrypted_content:e.string()}),e.object({type:e.literal("advisor_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("fallback")})])),stop_reason:e.string().nullish(),stop_sequence:e.string().nullish(),stop_details:Ye.nullish(),usage:e.looseObject({input_tokens:e.number(),output_tokens:e.number(),output_tokens_details:e.object({thinking_tokens:e.number().nullish()}).nullish(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish(),iterations:e.array(e.object({type:e.union([e.literal("compaction"),e.literal("message"),e.literal("advisor_message"),e.literal("fallback_message")]),model:e.string().nullish(),input_tokens:e.number(),output_tokens:e.number(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish()})).nullish()}),container:e.object({expires_at:e.string(),id:e.string(),skills:e.array(e.object({type:e.union([e.literal("anthropic"),e.literal("custom")]),skill_id:e.string(),version:e.string()})).nullish()}).nullish(),context_management:e.object({applied_edits:e.array(e.union([e.object({type:e.literal("clear_tool_uses_20250919"),cleared_tool_uses:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("clear_thinking_20251015"),cleared_thinking_turns:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("compact_20260112")})]))}).nullish()}))),pt=_(()=>m(e.discriminatedUnion("type",[e.object({type:e.literal("message_start"),message:e.object({id:e.string().nullish(),model:e.string().nullish(),role:e.string().nullish(),input_transformations:e.array(e.looseObject({type:e.string(),path:e.string().nullish(),reason:e.string().nullish()})).nullish(),usage:e.looseObject({input_tokens:e.number(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish()}),content:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("tool_use"),id:e.string(),name:e.string(),input:e.unknown(),caller:pe.optional()})])).nullish(),stop_reason:e.string().nullish(),container:e.object({expires_at:e.string(),id:e.string()}).nullish()})}),e.object({type:e.literal("content_block_start"),index:e.number(),content_block:e.discriminatedUnion("type",[e.object({type:e.literal("text"),text:e.string()}),e.object({type:e.literal("thinking"),thinking:e.string()}),e.object({type:e.literal("tool_use"),id:e.string(),name:e.string(),input:e.record(e.string(),e.unknown()).optional(),caller:pe.optional()}),e.object({type:e.literal("redacted_thinking"),data:e.string()}),e.object({type:e.literal("compaction"),content:e.string().nullish()}),e.object({type:e.literal("server_tool_use"),id:e.string(),name:e.string(),input:e.record(e.string(),e.unknown()).nullish(),caller:pe.optional()}),e.object({type:e.literal("mcp_tool_use"),id:e.string(),name:e.string(),input:e.unknown(),server_name:e.string()}),e.object({type:e.literal("mcp_tool_result"),tool_use_id:e.string(),is_error:e.boolean(),content:e.array(e.union([e.string(),e.object({type:e.literal("text"),text:e.string()})]))}),e.object({type:e.literal("web_fetch_tool_result"),tool_use_id:e.string(),caller:pe.optional(),content:e.union([e.object({type:e.literal("web_fetch_result"),url:e.string(),retrieved_at:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),media_type:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),media_type:e.literal("text/plain"),data:e.string()})])})}),e.object({type:e.literal("web_fetch_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("web_search_tool_result"),tool_use_id:e.string(),caller:pe.optional(),content:e.union([e.array(e.object({type:e.literal("web_search_result"),url:e.string(),title:e.string(),encrypted_content:e.string(),page_age:e.string().nullish()})),e.object({type:e.literal("web_search_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("code_execution_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("encrypted_code_execution_result"),encrypted_stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("bash_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("text_editor_code_execution_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})])}),e.object({type:e.literal("tool_search_tool_result"),tool_use_id:e.string(),content:e.union([e.object({type:e.literal("tool_search_tool_search_result"),tool_references:e.array(e.object({type:e.literal("tool_reference"),tool_name:e.string()}))}),e.object({type:e.literal("tool_search_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("advisor_tool_result"),tool_use_id:e.string(),content:e.discriminatedUnion("type",[e.object({type:e.literal("advisor_result"),text:e.string()}),e.object({type:e.literal("advisor_redacted_result"),encrypted_content:e.string()}),e.object({type:e.literal("advisor_tool_result_error"),error_code:e.string()})])}),e.object({type:e.literal("fallback")})])}),e.object({type:e.literal("content_block_delta"),index:e.number(),delta:e.discriminatedUnion("type",[e.object({type:e.literal("input_json_delta"),partial_json:e.string()}),e.object({type:e.literal("text_delta"),text:e.string()}),e.object({type:e.literal("thinking_delta"),thinking:e.string()}),e.object({type:e.literal("signature_delta"),signature:e.string()}),e.object({type:e.literal("compaction_delta"),content:e.string().nullish()}),e.object({type:e.literal("citations_delta"),citation:e.discriminatedUnion("type",[e.object({type:e.literal("web_search_result_location"),cited_text:e.string(),url:e.string(),title:e.string(),encrypted_index:e.string()}),e.object({type:e.literal("page_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_page_number:e.number(),end_page_number:e.number()}),e.object({type:e.literal("char_location"),cited_text:e.string(),document_index:e.number(),document_title:e.string().nullable(),start_char_index:e.number(),end_char_index:e.number()})])})])}),e.object({type:e.literal("content_block_stop"),index:e.number()}),e.object({type:e.literal("error"),error:e.object({type:e.string(),message:e.string()})}),e.object({type:e.literal("message_delta"),delta:e.object({stop_reason:e.string().nullish(),stop_sequence:e.string().nullish(),stop_details:Ye.nullish(),container:e.object({expires_at:e.string(),id:e.string(),skills:e.array(e.object({type:e.union([e.literal("anthropic"),e.literal("custom")]),skill_id:e.string(),version:e.string()})).nullish()}).nullish()}),usage:e.looseObject({input_tokens:e.number().nullish(),output_tokens:e.number(),output_tokens_details:e.object({thinking_tokens:e.number().nullish()}).nullish(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish(),iterations:e.array(e.object({type:e.union([e.literal("compaction"),e.literal("message"),e.literal("advisor_message"),e.literal("fallback_message")]),model:e.string().nullish(),input_tokens:e.number(),output_tokens:e.number(),cache_creation_input_tokens:e.number().nullish(),cache_read_input_tokens:e.number().nullish()})).nullish()}),context_management:e.object({applied_edits:e.array(e.union([e.object({type:e.literal("clear_tool_uses_20250919"),cleared_tool_uses:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("clear_thinking_20251015"),cleared_thinking_turns:e.number(),cleared_input_tokens:e.number()}),e.object({type:e.literal("compact_20260112")})]))}).nullish()}),e.object({type:e.literal("message_stop")}),e.object({type:e.literal("ping")})]))),dt=_(()=>m(e.object({signature:e.string().optional(),redactedData:e.string().optional()}))),Be=e.object({citations:e.object({enabled:e.boolean()}).optional(),title:e.string().optional(),context:e.string().optional()}),_t=e.object({toolChanges:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("tool_addition"),toolName:e.string()}),e.object({type:e.literal("tool_removal"),toolName:e.string()})])).optional()}),Je=e.object({sendReasoning:e.boolean().optional(),structuredOutputMode:e.enum(["outputFormat","jsonTool","auto"]).optional(),thinking:e.discriminatedUnion("type",[e.object({type:e.literal("adaptive"),display:e.enum(["omitted","summarized"]).optional(),blockBinding:e.object({prefixMismatchBehavior:e.enum(["error","drop_block"])}).optional()}),e.object({type:e.literal("enabled"),budgetTokens:e.number().optional(),blockBinding:e.object({prefixMismatchBehavior:e.enum(["error","drop_block"])}).optional()}),e.object({type:e.literal("disabled")})]).optional(),disableParallelToolUse:e.boolean().optional(),cacheControl:e.object({type:e.literal("ephemeral"),ttl:e.union([e.literal("5m"),e.literal("1h")]).optional()}).optional(),metadata:e.object({userId:e.string().optional()}).optional(),mcpServers:e.array(e.object({type:e.literal("url"),name:e.string(),url:e.string(),authorizationToken:e.string().nullish(),toolConfiguration:e.object({enabled:e.boolean().nullish(),allowedTools:e.array(e.string()).nullish()}).nullish()})).optional(),container:e.object({id:e.string().optional(),skills:e.array(e.object({type:e.union([e.literal("anthropic"),e.literal("custom")]),skillId:e.string(),version:e.string().optional()})).optional()}).optional(),toolStreaming:e.boolean().optional(),effort:e.enum(["low","medium","high","xhigh","max"]).optional(),taskBudget:e.object({type:e.literal("tokens"),total:e.number().int().min(2e4),remaining:e.number().int().min(0).optional()}).optional(),speed:e.enum(["fast","standard"]).optional(),inferenceGeo:e.enum(["us","global"]).optional(),fallbacks:e.union([e.literal("default"),e.array(e.object({model:e.string(),max_tokens:e.number().int().optional(),thinking:e.record(e.string(),e.unknown()).optional(),output_config:e.record(e.string(),e.unknown()).optional(),speed:e.enum(["fast","standard"]).optional()}))]).optional(),anthropicBeta:e.array(e.string()).optional(),contextManagement:e.object({edits:e.array(e.discriminatedUnion("type",[e.object({type:e.literal("clear_tool_uses_20250919"),trigger:e.discriminatedUnion("type",[e.object({type:e.literal("input_tokens"),value:e.number()}),e.object({type:e.literal("tool_uses"),value:e.number()})]).optional(),keep:e.object({type:e.literal("tool_uses"),value:e.number()}).optional(),clearAtLeast:e.object({type:e.literal("input_tokens"),value:e.number()}).optional(),clearToolInputs:e.boolean().optional(),excludeTools:e.array(e.string()).optional()}),e.object({type:e.literal("clear_thinking_20251015"),keep:e.union([e.literal("all"),e.object({type:e.literal("thinking_turns"),value:e.number()})]).optional()}),e.object({type:e.literal("compact_20260112"),trigger:e.object({type:e.literal("input_tokens"),value:e.number()}).optional(),pauseAfterCompaction:e.boolean().optional(),instructions:e.string().optional()})]))}).optional()}),He=4;function mt(t){var a;let n=t?.anthropic;return(a=n?.cacheControl)!=null?a:n?.cache_control}S(mt,"getCacheControl");var Ne=class{static{S(this,"CacheControlValidator")}constructor(){this.breakpointCount=0,this.warnings=[]}getCacheControl(t,a){let n=mt(t);if(n){if(!a.canCache){this.warnings.push({type:"unsupported",feature:"cache_control on non-cacheable context",details:`cache_control cannot be set on ${a.type}. It will be ignored.`});return}if(this.breakpointCount++,this.breakpointCount>He){this.warnings.push({type:"unsupported",feature:"cacheControl breakpoint limit",details:`Maximum ${He} cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`});return}return n}}getWarnings(){return this.warnings}},ht=_(()=>m(e.object({model:e.string(),maxUses:e.number().optional(),caching:e.object({type:e.literal("ephemeral"),ttl:e.union([e.literal("5m"),e.literal("1h")])}).optional()}))),Qe=_(()=>m(e.discriminatedUnion("type",[e.object({type:e.literal("advisor_result"),text:e.string()}),e.object({type:e.literal("advisor_redacted_result"),encryptedContent:e.string()}),e.object({type:e.literal("advisor_tool_result_error"),errorCode:e.string()})]))),yt=_(()=>m(e.object({}).strict())),gt=V({id:"anthropic.advisor_20260301",inputSchema:yt,outputSchema:Qe,supportsDeferredResults:!0}),bt=S(t=>gt(t),"advisor_20260301"),ft=_(()=>m(e.object({maxCharacters:e.number().optional()}))),vt=_(()=>m(e.object({command:e.enum(["view","create","str_replace","insert"]),path:e.string(),file_text:e.string().optional(),insert_line:e.number().int().optional(),new_str:e.string().optional(),insert_text:e.string().optional(),old_str:e.string().optional(),view_range:e.array(e.number().int()).optional()}))),xt=K({id:"anthropic.text_editor_20250728",inputSchema:vt}),kt=S((t={})=>xt(t),"textEditor_20250728"),jt=_(()=>m(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),userLocation:e.object({type:e.literal("approximate"),city:e.string().optional(),region:e.string().optional(),country:e.string().optional(),timezone:e.string().optional()}).optional()}))),St=_(()=>m(e.array(e.object({url:e.string(),title:e.string().nullable(),pageAge:e.string().nullable(),encryptedContent:e.string(),type:e.literal("web_search_result")})))),wt=_(()=>m(e.object({query:e.string()}))),Ct=V({id:"anthropic.web_search_20260209",inputSchema:wt,outputSchema:St,supportsDeferredResults:!0}),Tt=S((t={})=>Ct(t),"webSearch_20260209"),Nt=_(()=>m(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),userLocation:e.object({type:e.literal("approximate"),city:e.string().optional(),region:e.string().optional(),country:e.string().optional(),timezone:e.string().optional()}).optional()}))),et=_(()=>m(e.array(e.object({url:e.string(),title:e.string().nullable(),pageAge:e.string().nullable(),encryptedContent:e.string(),type:e.literal("web_search_result")})))),Ot=_(()=>m(e.object({query:e.string()}))),It=V({id:"anthropic.web_search_20250305",inputSchema:Ot,outputSchema:et,supportsDeferredResults:!0}),zt=S((t={})=>It(t),"webSearch_20250305"),Et=_(()=>m(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),citations:e.object({enabled:e.boolean()}).optional(),maxContentTokens:e.number().optional()}))),Pt=_(()=>m(e.object({type:e.literal("web_fetch_result"),url:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),mediaType:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),mediaType:e.literal("text/plain"),data:e.string()})])}),retrievedAt:e.string().nullable()}))),qt=_(()=>m(e.object({url:e.string()}))),Mt=V({id:"anthropic.web_fetch_20260209",inputSchema:qt,outputSchema:Pt,supportsDeferredResults:!0}),Rt=S((t={})=>Mt(t),"webFetch_20260209"),$t=_(()=>m(e.object({maxUses:e.number().optional(),allowedDomains:e.array(e.string()).optional(),blockedDomains:e.array(e.string()).optional(),citations:e.object({enabled:e.boolean()}).optional(),maxContentTokens:e.number().optional()}))),tt=_(()=>m(e.object({type:e.literal("web_fetch_result"),url:e.string(),content:e.object({type:e.literal("document"),title:e.string().nullable(),citations:e.object({enabled:e.boolean()}).optional(),source:e.union([e.object({type:e.literal("base64"),mediaType:e.literal("application/pdf"),data:e.string()}),e.object({type:e.literal("text"),mediaType:e.literal("text/plain"),data:e.string()})])}),retrievedAt:e.string().nullable()}))),Ut=_(()=>m(e.object({url:e.string()}))),At=V({id:"anthropic.web_fetch_20250910",inputSchema:Ut,outputSchema:tt,supportsDeferredResults:!0}),Dt=S((t={})=>At(t),"webFetch_20250910");async function Ft({tools:t,toolChoice:a,disableParallelToolUse:n,cacheControlValidator:u,supportsStructuredOutput:b,supportsStrictTools:q,defaultEagerInputStreaming:F=!1}){var $,Y;t=t?.length?t:void 0;let z=[],O=new Set,B=u||new Ne;if(t==null)return{tools:void 0,toolChoice:void 0,toolWarnings:z,betas:O};let I=[];for(let v of t)switch(v.type){case"function":{let k=B.getCacheControl(v.providerOptions,{type:"tool definition",canCache:!0}),M=($=v.providerOptions)==null?void 0:$.anthropic,J=(Y=M?.eagerInputStreaming)!=null?Y:F,Q=M?.deferLoading,R=M?.allowedCallers;!q&&v.strict!=null&&z.push({type:"unsupported",feature:"strict",details:`Tool '${v.name}' has strict: ${v.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`}),I.push({name:v.name,description:v.description,input_schema:v.inputSchema,cache_control:k,...J?{eager_input_streaming:!0}:{},...q===!0&&v.strict!=null?{strict:v.strict}:{},...Q!=null?{defer_loading:Q}:{},...R!=null?{allowed_callers:R}:{},...v.inputExamples!=null?{input_examples:v.inputExamples.map(le=>le.input)}:{}}),b===!0&&O.add("structured-outputs-2025-11-13"),(v.inputExamples!=null||R!=null)&&O.add("advanced-tool-use-2025-11-20");break}case"provider":{switch(v.id){case"anthropic.code_execution_20250522":{O.add("code-execution-2025-05-22"),I.push({type:"code_execution_20250522",name:"code_execution",cache_control:void 0});break}case"anthropic.code_execution_20250825":{O.add("code-execution-2025-08-25"),I.push({type:"code_execution_20250825",name:"code_execution"});break}case"anthropic.code_execution_20260120":{I.push({type:"code_execution_20260120",name:"code_execution"});break}case"anthropic.computer_20250124":{O.add("computer-use-2025-01-24"),I.push({name:"computer",type:"computer_20250124",display_width_px:v.args.displayWidthPx,display_height_px:v.args.displayHeightPx,display_number:v.args.displayNumber,cache_control:void 0});break}case"anthropic.computer_20251124":{O.add("computer-use-2025-11-24"),I.push({name:"computer",type:"computer_20251124",display_width_px:v.args.displayWidthPx,display_height_px:v.args.displayHeightPx,display_number:v.args.displayNumber,enable_zoom:v.args.enableZoom,cache_control:void 0});break}case"anthropic.computer_20241022":{O.add("computer-use-2024-10-22"),I.push({name:"computer",type:"computer_20241022",display_width_px:v.args.displayWidthPx,display_height_px:v.args.displayHeightPx,display_number:v.args.displayNumber,cache_control:void 0});break}case"anthropic.text_editor_20250124":{O.add("computer-use-2025-01-24"),I.push({name:"str_replace_editor",type:"text_editor_20250124",cache_control:void 0});break}case"anthropic.text_editor_20241022":{O.add("computer-use-2024-10-22"),I.push({name:"str_replace_editor",type:"text_editor_20241022",cache_control:void 0});break}case"anthropic.text_editor_20250429":{O.add("computer-use-2025-01-24"),I.push({name:"str_replace_based_edit_tool",type:"text_editor_20250429",cache_control:void 0});break}case"anthropic.text_editor_20250728":{let k=await re({value:v.args,schema:ft});I.push({name:"str_replace_based_edit_tool",type:"text_editor_20250728",max_characters:k.maxCharacters,cache_control:void 0});break}case"anthropic.bash_20250124":{O.add("computer-use-2025-01-24"),I.push({name:"bash",type:"bash_20250124",cache_control:void 0});break}case"anthropic.bash_20241022":{O.add("computer-use-2024-10-22"),I.push({name:"bash",type:"bash_20241022",cache_control:void 0});break}case"anthropic.memory_20250818":{O.add("context-management-2025-06-27"),I.push({name:"memory",type:"memory_20250818"});break}case"anthropic.web_fetch_20250910":{O.add("web-fetch-2025-09-10");let k=await re({value:v.args,schema:$t});I.push({type:"web_fetch_20250910",name:"web_fetch",max_uses:k.maxUses,allowed_domains:k.allowedDomains,blocked_domains:k.blockedDomains,citations:k.citations,max_content_tokens:k.maxContentTokens,cache_control:void 0});break}case"anthropic.web_fetch_20260209":{O.add("code-execution-web-tools-2026-02-09");let k=await re({value:v.args,schema:Et});I.push({type:"web_fetch_20260209",name:"web_fetch",max_uses:k.maxUses,allowed_domains:k.allowedDomains,blocked_domains:k.blockedDomains,citations:k.citations,max_content_tokens:k.maxContentTokens,cache_control:void 0});break}case"anthropic.web_search_20250305":{let k=await re({value:v.args,schema:Nt});I.push({type:"web_search_20250305",name:"web_search",max_uses:k.maxUses,allowed_domains:k.allowedDomains,blocked_domains:k.blockedDomains,user_location:k.userLocation,cache_control:void 0});break}case"anthropic.web_search_20260209":{O.add("code-execution-web-tools-2026-02-09");let k=await re({value:v.args,schema:jt});I.push({type:"web_search_20260209",name:"web_search",max_uses:k.maxUses,allowed_domains:k.allowedDomains,blocked_domains:k.blockedDomains,user_location:k.userLocation,cache_control:void 0});break}case"anthropic.tool_search_regex_20251119":{I.push({type:"tool_search_tool_regex_20251119",name:"tool_search_tool_regex"});break}case"anthropic.tool_search_bm25_20251119":{I.push({type:"tool_search_tool_bm25_20251119",name:"tool_search_tool_bm25"});break}case"anthropic.advisor_20260301":{O.add("advisor-tool-2026-03-01");let k=await re({value:v.args,schema:ht});I.push({type:"advisor_20260301",name:"advisor",model:k.model,...k.maxUses!==void 0&&{max_uses:k.maxUses},...k.caching!==void 0&&{caching:k.caching}});break}default:{z.push({type:"unsupported",feature:`provider-defined tool ${v.id}`});break}}break}default:{z.push({type:"unsupported",feature:`tool ${v}`});break}}if(a==null)return{tools:I,toolChoice:n?{type:"auto",disable_parallel_tool_use:n}:void 0,toolWarnings:z,betas:O};let P=a.type;switch(P){case"auto":return{tools:I,toolChoice:{type:"auto",disable_parallel_tool_use:n},toolWarnings:z,betas:O};case"required":return{tools:I,toolChoice:{type:"any",disable_parallel_tool_use:n},toolWarnings:z,betas:O};case"none":return{tools:void 0,toolChoice:void 0,toolWarnings:z,betas:O};case"tool":return{tools:I,toolChoice:{type:"tool",name:a.toolName,disable_parallel_tool_use:n},toolWarnings:z,betas:O};default:{let v=P;throw new be({functionality:`tool choice type: ${v}`})}}}S(Ft,"prepareTools");function We({usage:t,rawUsage:a}){var n,u,b,q,F;let $=(n=t.cache_creation_input_tokens)!=null?n:0,Y=(u=t.cache_read_input_tokens)!=null?u:0,z=(q=(b=t.output_tokens_details)==null?void 0:b.thinking_tokens)!=null?q:void 0,O,B,I=(F=t.iterations)==null?void 0:F.some(P=>P.type==="fallback_message");if(t.iterations&&t.iterations.length>0&&!I){let P=t.iterations.filter(v=>v.type==="compaction"||v.type==="message");if(P.length>0){let v=P.reduce((k,M)=>({input:k.input+M.input_tokens,output:k.output+M.output_tokens}),{input:0,output:0});O=v.input,B=v.output}else O=t.input_tokens,B=t.output_tokens}else O=t.input_tokens,B=t.output_tokens;return{inputTokens:{total:O+$+Y,noCache:O,cacheRead:Y,cacheWrite:$},outputTokens:{total:B,text:z==null?void 0:B-z,reasoning:z},raw:a??t}}S(We,"convertAnthropicMessagesUsage");var ot=_(()=>m(e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}))),Bt=_(()=>m(e.object({code:e.string()}))),Jt=V({id:"anthropic.code_execution_20250522",inputSchema:Bt,outputSchema:ot}),Ht=S((t={})=>Jt(t),"codeExecution_20250522"),rt=_(()=>m(e.discriminatedUnion("type",[e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})]))),Wt=_(()=>m(e.discriminatedUnion("type",[e.object({type:e.literal("programmatic-tool-call"),code:e.string()}),e.object({type:e.literal("bash_code_execution"),command:e.string()}),e.discriminatedUnion("command",[e.object({type:e.literal("text_editor_code_execution"),command:e.literal("view"),path:e.string()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("create"),path:e.string(),file_text:e.string().nullish()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("str_replace"),path:e.string(),old_str:e.string(),new_str:e.string()})])]))),Lt=V({id:"anthropic.code_execution_20250825",inputSchema:Wt,outputSchema:rt,supportsDeferredResults:!0}),Kt=S((t={})=>Lt(t),"codeExecution_20250825"),nt=_(()=>m(e.discriminatedUnion("type",[e.object({type:e.literal("code_execution_result"),stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("encrypted_code_execution_result"),encrypted_stdout:e.string(),stderr:e.string(),return_code:e.number(),content:e.array(e.object({type:e.literal("code_execution_output"),file_id:e.string()})).optional().default([])}),e.object({type:e.literal("bash_code_execution_result"),content:e.array(e.object({type:e.literal("bash_code_execution_output"),file_id:e.string()})),stdout:e.string(),stderr:e.string(),return_code:e.number()}),e.object({type:e.literal("bash_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_tool_result_error"),error_code:e.string()}),e.object({type:e.literal("text_editor_code_execution_view_result"),content:e.string(),file_type:e.string(),num_lines:e.number().nullable(),start_line:e.number().nullable(),total_lines:e.number().nullable()}),e.object({type:e.literal("text_editor_code_execution_create_result"),is_file_update:e.boolean()}),e.object({type:e.literal("text_editor_code_execution_str_replace_result"),lines:e.array(e.string()).nullable(),new_lines:e.number().nullable(),new_start:e.number().nullable(),old_lines:e.number().nullable(),old_start:e.number().nullable()})]))),Vt=_(()=>m(e.discriminatedUnion("type",[e.object({type:e.literal("programmatic-tool-call"),code:e.string()}),e.object({type:e.literal("bash_code_execution"),command:e.string()}),e.discriminatedUnion("command",[e.object({type:e.literal("text_editor_code_execution"),command:e.literal("view"),path:e.string()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("create"),path:e.string(),file_text:e.string().nullish()}),e.object({type:e.literal("text_editor_code_execution"),command:e.literal("str_replace"),path:e.string(),old_str:e.string(),new_str:e.string()})])]))),Gt=V({id:"anthropic.code_execution_20260120",inputSchema:Vt,outputSchema:nt,supportsDeferredResults:!0}),Zt=S((t={})=>Gt(t),"codeExecution_20260120"),at=_(()=>m(e.array(e.object({type:e.literal("tool_reference"),toolName:e.string()})))),Xt=_(()=>m(e.object({pattern:e.string(),limit:e.number().optional()}))),Yt=V({id:"anthropic.tool_search_regex_20251119",inputSchema:Xt,outputSchema:at,supportsDeferredResults:!0}),Qt=S((t={})=>Yt(t),"toolSearchRegex_20251119");function eo(t){if(typeof t=="string")return new TextDecoder().decode(qe(t));if(t instanceof Uint8Array)return new TextDecoder().decode(t);throw t instanceof URL?new be({functionality:"URL-based text documents are not supported for citations"}):new be({functionality:`unsupported data type for text documents: ${typeof t}`})}S(eo,"convertToString");function we(t){return t instanceof URL||to(t)}S(we,"isUrlData");function to(t){return typeof t=="string"&&/^https?:\/\//i.test(t)}S(to,"isUrlString");function Ce(t){return t instanceof URL?t.toString():t}S(Ce,"getUrlString");async function Le(t){if(typeof t=="string"){let a=await $e({text:t});return a.success&&typeof a.value=="object"&&a.value!==null?a.value:{errorCode:"unavailable"}}return typeof t=="object"&&t!==null?t:{}}S(Le,"extractErrorValue");async function oo({prompt:t,sendReasoning:a,warnings:n,cacheControlValidator:u,toolNameMapping:b}){var q,F,$,Y,z,O,B,I,P,v,k,M,J,Q,R,le,T,ne,ue,se,r;let d=new Set,D=ro(t),H=u||new Ne,ee,ce=[];async function i(A){var G,de;let oe=await _e({provider:"anthropic",providerOptions:A,schema:Be});return(de=(G=oe?.citations)==null?void 0:G.enabled)!=null?de:!1}S(i,"shouldEnableCitations");async function te(A){let G=await _e({provider:"anthropic",providerOptions:A,schema:Be});return{title:G?.title,context:G?.context}}S(te,"getDocumentMetadata");for(let A=0;A<D.length;A++){let G=D[A],de=A===D.length-1,oe=G.type;switch(oe){case"system":{let y=[],p=0;for(let{content:Z,providerOptions:X}of G.messages){let W=await _e({provider:"anthropic",providerOptions:X,schema:_t}),w=(q=W?.toolChanges)!=null?q:[];(Z!==""||w.length===0)&&y.push({type:"text",text:Z,cache_control:H.getCacheControl(X,{type:"system message",canCache:!0})});for(let U of w)p++,y.push({type:U.type,tool:{type:"tool_reference",name:b.toProviderToolName(U.toolName)}})}A===0||ee==null&&p===0?(p>0&&n.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."}),ee=y.filter(Z=>Z.type==="text")):(ce.push({role:"system",content:y}),d.add("mid-conversation-system-2026-04-07"),p>0&&d.add("mid-conversation-tool-changes-2026-07-01"));break}case"user":{let y=[];for(let p of G.messages){let{role:Z,content:X}=p;switch(Z){case"user":{for(let W=0;W<X.length;W++){let w=X[W],U=W===X.length-1,l=(F=H.getCacheControl(w.providerOptions,{type:"user message part",canCache:!0}))!=null?F:U?H.getCacheControl(p.providerOptions,{type:"user message",canCache:!0}):void 0;switch(w.type){case"text":{y.push({type:"text",text:w.text,cache_control:l});break}case"file":{if(w.mediaType.startsWith("image/"))y.push({type:"image",source:we(w.data)?{type:"url",url:Ce(w.data)}:{type:"base64",media_type:w.mediaType==="image/*"?"image/jpeg":w.mediaType,data:ke(w.data)},cache_control:l});else if(w.mediaType==="application/pdf"){d.add("pdfs-2024-09-25");let ae=await i(w.providerOptions),N=await te(w.providerOptions);y.push({type:"document",source:we(w.data)?{type:"url",url:Ce(w.data)}:{type:"base64",media_type:"application/pdf",data:ke(w.data)},title:($=N.title)!=null?$:w.filename,...N.context&&{context:N.context},...ae&&{citations:{enabled:!0}},cache_control:l})}else if(w.mediaType==="text/plain"){let ae=await i(w.providerOptions),N=await te(w.providerOptions);y.push({type:"document",source:we(w.data)?{type:"url",url:Ce(w.data)}:{type:"text",media_type:"text/plain",data:eo(w.data)},title:(Y=N.title)!=null?Y:w.filename,...N.context&&{context:N.context},...ae&&{citations:{enabled:!0}},cache_control:l})}else throw new be({functionality:`media type: ${w.mediaType}`});break}}}break}case"tool":{for(let W=0;W<X.length;W++){let w=X[W];if(w.type==="tool-approval-response")continue;let U=w.output,l="providerOptions"in U?U.providerOptions:U.type==="content"?(z=U.value.find(j=>j.providerOptions!=null))==null?void 0:z.providerOptions:void 0,ae=W===X.length-1,N=(B=(O=H.getCacheControl(w.providerOptions,{type:"tool result part",canCache:!0}))!=null?O:H.getCacheControl(l,{type:"tool result output",canCache:!0}))!=null?B:ae?H.getCacheControl(p.providerOptions,{type:"tool result message",canCache:!0}):void 0,f;switch(U.type){case"content":f=U.value.map(j=>{var g;switch(j.type){case"text":return{type:"text",text:j.text};case"image-data":return{type:"image",source:{type:"base64",media_type:j.mediaType,data:j.data}};case"image-url":return{type:"image",source:{type:"url",url:j.url}};case"file-url":return{type:"document",source:{type:"url",url:j.url}};case"file-data":{if(j.mediaType==="application/pdf")return d.add("pdfs-2024-09-25"),{type:"document",source:{type:"base64",media_type:j.mediaType,data:j.data}};n.push({type:"other",message:`unsupported tool content part type: ${j.type} with media type: ${j.mediaType}`});return}case"custom":{let c=(g=j.providerOptions)==null?void 0:g.anthropic;if(c?.type==="tool-reference")return{type:"tool_reference",tool_name:c.toolName};n.push({type:"other",message:"unsupported custom tool content part"});return}default:{n.push({type:"other",message:`unsupported tool content part type: ${j.type}`});return}}}).filter(Re);break;case"text":case"error-text":f=U.value;break;case"execution-denied":f=(I=U.reason)!=null?I:"Tool call execution denied.";break;default:f=JSON.stringify(U.value);break}y.push({type:"tool_result",tool_use_id:w.toolCallId,content:f,is_error:U.type==="error-text"||U.type==="error-json"?!0:void 0,cache_control:N})}break}default:{let W=Z;throw new Error(`Unsupported role: ${W}`)}}}ce.push({role:"user",content:y});break}case"assistant":{let y=[],p=new Set;for(let Z=0;Z<G.messages.length;Z++){let X=G.messages[Z],W=Z===G.messages.length-1,{content:w}=X;for(let U=0;U<w.length;U++){let l=w[U],ae=U===w.length-1,N=(P=H.getCacheControl(l.providerOptions,{type:"assistant message part",canCache:!0}))!=null?P:ae?H.getCacheControl(X.providerOptions,{type:"assistant message",canCache:!0}):void 0;switch(l.type){case"text":{let f=(v=l.providerOptions)==null?void 0:v.anthropic;f?.type==="compaction"?y.push({type:"compaction",content:l.text,cache_control:N}):y.push({type:"text",text:de&&W&&ae?l.text.trim():l.text,...f?.citations!=null&&{citations:f.citations},cache_control:N});break}case"reasoning":{if(a){let f=await _e({provider:"anthropic",providerOptions:l.providerOptions,schema:dt});f!=null?f.signature!=null?(H.getCacheControl(l.providerOptions,{type:"thinking block",canCache:!1}),y.push({type:"thinking",thinking:l.text,signature:f.signature})):f.redactedData!=null?(H.getCacheControl(l.providerOptions,{type:"redacted thinking block",canCache:!1}),y.push({type:"redacted_thinking",data:f.redactedData})):n.push({type:"other",message:"unsupported reasoning metadata"}):n.push({type:"other",message:"unsupported reasoning metadata"})}else n.push({type:"other",message:"sending reasoning content is disabled for this model"});break}case"tool-call":{let f=Ke(l.providerOptions);if(l.providerExecuted){let j=b.toProviderToolName(l.toolName);if(((M=(k=l.providerOptions)==null?void 0:k.anthropic)==null?void 0:M.type)==="mcp-tool-use"){p.add(l.toolCallId);let c=(Q=(J=l.providerOptions)==null?void 0:J.anthropic)==null?void 0:Q.serverName;if(c==null||typeof c!="string"){n.push({type:"other",message:"mcp tool use server name is required and must be a string"});break}y.push({type:"mcp_tool_use",id:l.toolCallId,name:l.toolName,input:l.input,server_name:c,cache_control:N})}else if(j==="code_execution"&&l.input!=null&&typeof l.input=="object"&&"type"in l.input&&typeof l.input.type=="string"&&(l.input.type==="bash_code_execution"||l.input.type==="text_editor_code_execution")){let{type:c,...L}=l.input;y.push({type:"server_tool_use",id:l.toolCallId,name:c,input:L,...f&&{caller:f},cache_control:N})}else if(j==="code_execution"&&l.input!=null&&typeof l.input=="object"&&"type"in l.input&&l.input.type==="programmatic-tool-call"){let{type:c,...L}=l.input;y.push({type:"server_tool_use",id:l.toolCallId,name:"code_execution",input:L,...f&&{caller:f},cache_control:N})}else j==="code_execution"||j==="web_fetch"||j==="web_search"?y.push({type:"server_tool_use",id:l.toolCallId,name:j,input:l.input,...f&&{caller:f},cache_control:N}):j==="tool_search_tool_regex"||j==="tool_search_tool_bm25"?y.push({type:"server_tool_use",id:l.toolCallId,name:j,input:l.input,...f&&{caller:f},cache_control:N}):j==="advisor"?y.push({type:"server_tool_use",id:l.toolCallId,name:"advisor",input:{},...f&&{caller:f},cache_control:N}):n.push({type:"other",message:`provider executed tool call for tool ${l.toolName} is not supported`});break}y.push({type:"tool_use",id:l.toolCallId,name:l.toolName,input:l.input,...f&&{caller:f},cache_control:N});break}case"tool-result":{let f=b.toProviderToolName(l.toolName),j=Ke(l.providerOptions);if(p.has(l.toolCallId)){let g=l.output;if(g.type!=="json"&&g.type!=="error-json"){n.push({type:"other",message:`provider executed tool result output type ${g.type} for tool ${l.toolName} is not supported`});break}y.push({type:"mcp_tool_result",tool_use_id:l.toolCallId,is_error:g.type==="error-json",content:g.value,cache_control:N})}else if(f==="code_execution"){let g=l.output;if(g.type==="error-text"||g.type==="error-json"){let c={};try{typeof g.value=="string"?c=ve(g.value):typeof g.value=="object"&&g.value!==null&&(c=g.value)}catch{}c.type==="code_execution_tool_result_error"?y.push({type:"code_execution_tool_result",tool_use_id:l.toolCallId,content:{type:"code_execution_tool_result_error",error_code:(R=c.errorCode)!=null?R:"unknown"},cache_control:N}):y.push({type:"bash_code_execution_tool_result",tool_use_id:l.toolCallId,cache_control:N,content:{type:"bash_code_execution_tool_result_error",error_code:(le=c.errorCode)!=null?le:"unknown"}});break}if(g.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${g.type} for tool ${l.toolName} is not supported`});break}if(g.value==null||typeof g.value!="object"||!("type"in g.value)||typeof g.value.type!="string"){n.push({type:"other",message:`provider executed tool result output value is not a valid code execution result for tool ${l.toolName}`});break}if(g.value.type==="code_execution_result"){let c=await re({value:g.value,schema:ot});y.push({type:"code_execution_tool_result",tool_use_id:l.toolCallId,content:{type:c.type,stdout:c.stdout,stderr:c.stderr,return_code:c.return_code,content:(T=c.content)!=null?T:[]},cache_control:N})}else if(g.value.type==="encrypted_code_execution_result"){let c=await re({value:g.value,schema:nt});c.type==="encrypted_code_execution_result"&&y.push({type:"code_execution_tool_result",tool_use_id:l.toolCallId,content:{type:c.type,encrypted_stdout:c.encrypted_stdout,stderr:c.stderr,return_code:c.return_code,content:(ne=c.content)!=null?ne:[]},cache_control:N})}else{let c=await re({value:g.value,schema:rt});c.type==="code_execution_result"?y.push({type:"code_execution_tool_result",tool_use_id:l.toolCallId,content:{type:c.type,stdout:c.stdout,stderr:c.stderr,return_code:c.return_code,content:(ue=c.content)!=null?ue:[]},cache_control:N}):c.type==="bash_code_execution_result"||c.type==="bash_code_execution_tool_result_error"?y.push({type:"bash_code_execution_tool_result",tool_use_id:l.toolCallId,cache_control:N,content:c.type==="bash_code_execution_result"?{type:c.type,stdout:c.stdout,stderr:c.stderr,return_code:c.return_code,content:c.content}:c}):y.push({type:"text_editor_code_execution_tool_result",tool_use_id:l.toolCallId,cache_control:N,content:c})}break}if(f==="web_fetch"){let g=l.output;if(g.type==="error-json"){y.push({type:"web_fetch_tool_result",tool_use_id:l.toolCallId,content:{type:"web_fetch_tool_result_error",error_code:(se=(await Le(g.value)).errorCode)!=null?se:"unavailable"},...j&&{caller:j},cache_control:N});break}if(g.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${g.type} for tool ${l.toolName} is not supported`});break}let c=await re({value:g.value,schema:tt});y.push({type:"web_fetch_tool_result",tool_use_id:l.toolCallId,content:{type:"web_fetch_result",url:c.url,retrieved_at:c.retrievedAt,content:{type:"document",title:c.content.title,citations:c.content.citations,source:{type:c.content.source.type,media_type:c.content.source.mediaType,data:c.content.source.data}}},...j&&{caller:j},cache_control:N});break}if(f==="web_search"){let g=l.output;if(g.type==="error-json"){y.push({type:"web_search_tool_result",tool_use_id:l.toolCallId,content:{type:"web_search_tool_result_error",error_code:(r=(await Le(g.value)).errorCode)!=null?r:"unavailable"},...j&&{caller:j},cache_control:N});break}if(g.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${g.type} for tool ${l.toolName} is not supported`});break}let c=await re({value:g.value,schema:et});y.push({type:"web_search_tool_result",tool_use_id:l.toolCallId,content:c.map(L=>({url:L.url,title:L.title,page_age:L.pageAge,encrypted_content:L.encryptedContent,type:L.type})),...j&&{caller:j},cache_control:N});break}if(f==="tool_search_tool_regex"||f==="tool_search_tool_bm25"){let g=l.output;if(g.type!=="json"){n.push({type:"other",message:`provider executed tool result output type ${g.type} for tool ${l.toolName} is not supported`});break}let L=(await re({value:g.value,schema:at})).map(he=>({type:"tool_reference",tool_name:he.toolName}));y.push({type:"tool_search_tool_result",tool_use_id:l.toolCallId,content:{type:"tool_search_tool_search_result",tool_references:L},cache_control:N});break}if(f==="advisor"){let g=l.output;if(g.type!=="json"&&g.type!=="error-json"){n.push({type:"other",message:`provider executed tool result output type ${g.type} for tool ${l.toolName} is not supported`});break}let c=await re({value:g.value,schema:Qe});c.type==="advisor_result"?y.push({type:"advisor_tool_result",tool_use_id:l.toolCallId,content:{type:"advisor_result",text:c.text},cache_control:N}):c.type==="advisor_redacted_result"?y.push({type:"advisor_tool_result",tool_use_id:l.toolCallId,content:{type:"advisor_redacted_result",encrypted_content:c.encryptedContent},cache_control:N}):y.push({type:"advisor_tool_result",tool_use_id:l.toolCallId,content:{type:"advisor_tool_result_error",error_code:c.errorCode},cache_control:N});break}n.push({type:"other",message:`provider executed tool result for tool ${l.toolName} is not supported`});break}}}}ce.push({role:"assistant",content:no(y)});break}default:{let y=oe;throw new Error(`content type: ${y}`)}}}return{prompt:{system:ee,messages:ce},betas:d}}S(oo,"convertToAnthropicMessagesPrompt");function ro(t){let a=[],n;for(let u of t){let{role:b}=u;switch(b){case"system":{n?.type!=="system"&&(n={type:"system",messages:[]},a.push(n)),n.messages.push(u);break}case"assistant":{n?.type!=="assistant"&&(n={type:"assistant",messages:[]},a.push(n)),n.messages.push(u);break}case"user":{n?.type!=="user"&&(n={type:"user",messages:[]},a.push(n)),n.messages.push(u);break}case"tool":{n?.type!=="user"&&(n={type:"user",messages:[]},a.push(n)),n.messages.push(u);break}default:{let q=b;throw new Error(`Unsupported role: ${q}`)}}}return a}S(ro,"groupIntoBlocks");function no(t){let a=[],n=[];function u(){a.push(...n.filter(b=>b.type!=="tool_use"),...n.filter(b=>b.type==="tool_use")),n=[]}S(u,"flushSegment");for(let b of t)b.type==="thinking"||b.type==="redacted_thinking"?(u(),a.push(b)):n.push(b);return u(),a}S(no,"moveToolUseBlocksToEnd");function Ke(t){var a;let n=(a=t?.anthropic)==null?void 0:a.caller;return(n?.type==="code_execution_20250825"||n?.type==="code_execution_20260120")&&n.toolId?{type:n.type,tool_id:n.toolId}:n?.type==="direct"?{type:"direct"}:void 0}S(Ke,"getAnthropicCaller");function Te({finishReason:t,isJsonResponseFromTool:a}){switch(t){case"pause_turn":case"end_turn":case"stop_sequence":return"stop";case"refusal":return"content-filter";case"tool_use":return a?"stop":"tool-calls";case"max_tokens":case"model_context_window_exceeded":return"length";case"compaction":return"other";default:return"other"}}S(Te,"mapAnthropicStopReason");var it=new Set(["date-time","time","date","duration","email","hostname","uri","ipv4","ipv6","uuid"]),ao=["minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","minLength","maxLength","pattern","minItems","maxItems","uniqueItems","minProperties","maxProperties","not"];function io(t){return lt(t)}S(io,"sanitizeJsonSchema");function me(t){return typeof t=="boolean"||!uo(t)?t:lt(t)}S(me,"sanitizeDefinition");function lt(t){let a={},n=t;if(t.$ref!=null)return{$ref:t.$ref};if(t.$schema!=null&&(a.$schema=t.$schema),t.$id!=null&&(a.$id=t.$id),t.title!=null&&(a.title=t.title),t.description!=null&&(a.description=t.description),t.default!==void 0&&(a.default=t.default),t.const!==void 0&&(a.const=t.const),t.enum!=null&&(a.enum=t.enum),t.type!=null&&(a.type=t.type),t.anyOf!=null?a.anyOf=t.anyOf.map(me):t.oneOf!=null&&(a.anyOf=t.oneOf.map(me)),t.allOf!=null&&(a.allOf=t.allOf.map(me)),t.definitions!=null&&(a.definitions=Object.fromEntries(Object.entries(t.definitions).map(([b,q])=>[b,me(q)]))),n.$defs!=null){let b=a;b.$defs=Object.fromEntries(Object.entries(n.$defs).map(([q,F])=>[q,me(F)]))}(t.type==="object"||t.properties!=null)&&(t.properties!=null&&(a.properties=Object.fromEntries(Object.entries(t.properties).map(([b,q])=>[b,me(q)]))),a.additionalProperties=!1,t.required!=null&&(a.required=t.required)),t.items!=null&&(a.items=Array.isArray(t.items)?t.items.map(me):me(t.items)),typeof t.format=="string"&&it.has(t.format)&&(a.format=t.format);let u=lo(t);return u!=null&&(a.description=a.description==null?u:`${a.description}
19
+ ${u}`),a}S(lt,"sanitizeSchema");function lo(t){let a=ao.flatMap(n=>{let u=t[n];return u==null||u===!1?[]:`${so(n)}: ${co(u)}`});return typeof t.format=="string"&&!it.has(t.format)&&a.push(`format: ${t.format}`),a.length===0?void 0:`${a.join("; ")}.`}S(lo,"getConstraintDescription");function so(t){return t.replace(/[A-Z]/g,a=>` ${a.toLowerCase()}`)}S(so,"formatConstraintName");function co(t){return typeof t=="string"?t:JSON.stringify(t)}S(co,"formatConstraintValue");function uo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}S(uo,"isPlainObject");function Ve(t,a,n){var u;if(t.type==="web_search_result_location")return{type:"source",sourceType:"url",id:n(),url:t.url,title:t.title,providerMetadata:{anthropic:{citedText:t.cited_text,encryptedIndex:t.encrypted_index}}};if(t.type!=="page_location"&&t.type!=="char_location")return;let b=a[t.document_index];if(b)return{type:"source",sourceType:"document",id:n(),mediaType:b.mediaType,title:(u=t.document_title)!=null?u:b.title,filename:b.filename,providerMetadata:{anthropic:t.type==="page_location"?{citedText:t.cited_text,startPageNumber:t.start_page_number,endPageNumber:t.end_page_number}:{citedText:t.cited_text,startCharIndex:t.start_char_index,endCharIndex:t.end_char_index}}}}S(Ve,"createCitationSource");function xe(t){return t==null?void 0:{type:t.type,toolId:"tool_id"in t?t.tool_id:void 0}}S(xe,"getAnthropicCallerInfo");function ie(t){let a=xe(t);return a==null?{}:{providerMetadata:{anthropic:{caller:a}}}}S(ie,"getAnthropicCallerMetadata");var dr=class{static{S(this,"AnthropicMessagesLanguageModel")}constructor(t,a){this.specificationVersion="v3";var n;this.modelId=t,this.config=a,this.generateId=(n=a.generateId)!=null?n:Me}supportsUrl(t){return t.protocol==="https:"}get provider(){return this.config.provider}get providerOptionsName(){let t=this.config.provider,a=t.indexOf(".");return a===-1?t:t.substring(0,a)}get supportedUrls(){var t,a,n;return(n=(a=(t=this.config).supportedUrls)==null?void 0:a.call(t))!=null?n:{}}async getArgs({userSuppliedBetas:t,prompt:a,maxOutputTokens:n,temperature:u,topP:b,topK:q,frequencyPenalty:F,presencePenalty:$,stopSequences:Y,responseFormat:z,seed:O,tools:B,toolChoice:I,providerOptions:P,stream:v}){var k,M,J,Q,R,le,T,ne,ue,se,r;let d=[];F!=null&&d.push({type:"unsupported",feature:"frequencyPenalty"}),$!=null&&d.push({type:"unsupported",feature:"presencePenalty"}),O!=null&&d.push({type:"unsupported",feature:"seed"}),u!=null&&u>1?(d.push({type:"unsupported",feature:"temperature",details:`${u} exceeds anthropic maximum of 1.0. clamped to 1.0`}),u=1):u!=null&&u<0&&(d.push({type:"unsupported",feature:"temperature",details:`${u} is below anthropic minimum of 0. clamped to 0`}),u=0),z?.type==="json"&&z.schema==null&&d.push({type:"unsupported",feature:"responseFormat",details:"JSON response format requires a schema. The response format is ignored."});let D=this.providerOptionsName,H=await _e({provider:"anthropic",providerOptions:P,schema:Je}),ee=D!=="anthropic"?await _e({provider:D,providerOptions:P,schema:Je}):null,ce=ee!=null,i=Object.assign({},H??{},ee??{}),{maxOutputTokens:te,supportsStructuredOutput:A,rejectsSamplingParameters:G,rejectsThinkingDisabledAboveHighEffort:de,isKnownModel:oe}=po(this.modelId);!oe&&n==null&&d.push({type:"compatibility",feature:"maxOutputTokens",details:`The model "${this.modelId}" is unknown. The max output tokens have been limited to ${te}. Set maxOutputTokens explicitly to override this limit.`}),G&&(u!=null&&(d.push({type:"unsupported",feature:"temperature",details:`temperature is not supported by ${this.modelId} and will be ignored`}),u=void 0),q!=null&&(d.push({type:"unsupported",feature:"topK",details:`topK is not supported by ${this.modelId} and will be ignored`}),q=void 0),b!=null&&(d.push({type:"unsupported",feature:"topP",details:`topP is not supported by ${this.modelId} and will be ignored`}),b=void 0));let y=oe||this.modelId.includes("claude-"),p=((k=this.config.supportsNativeStructuredOutput)!=null?k:!0)&&A,Z=((M=this.config.supportsStrictTools)!=null?M:!0)&&A,X=(J=i?.structuredOutputMode)!=null?J:"auto",W=X==="outputFormat"||X==="auto"&&p,w=z?.type==="json"&&z.schema!=null&&!W?{type:"function",name:"json",description:"Respond with a JSON object.",inputSchema:z.schema}:void 0;w!=null&&i?.disableParallelToolUse===!1&&d.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 U=i?.contextManagement,l=new Ne,ae=Pe({tools:B,providerToolNames:{"anthropic.code_execution_20250522":"code_execution","anthropic.code_execution_20250825":"code_execution","anthropic.code_execution_20260120":"code_execution","anthropic.computer_20241022":"computer","anthropic.computer_20250124":"computer","anthropic.text_editor_20241022":"str_replace_editor","anthropic.text_editor_20250124":"str_replace_editor","anthropic.text_editor_20250429":"str_replace_based_edit_tool","anthropic.text_editor_20250728":"str_replace_based_edit_tool","anthropic.bash_20241022":"bash","anthropic.bash_20250124":"bash","anthropic.memory_20250818":"memory","anthropic.web_search_20250305":"web_search","anthropic.web_search_20260209":"web_search","anthropic.web_fetch_20250910":"web_fetch","anthropic.web_fetch_20260209":"web_fetch","anthropic.tool_search_regex_20251119":"tool_search_tool_regex","anthropic.tool_search_bm25_20251119":"tool_search_tool_bm25","anthropic.advisor_20260301":"advisor"}}),{prompt:N,betas:f}=await oo({prompt:a,sendReasoning:(Q=i?.sendReasoning)!=null?Q:!0,warnings:d,cacheControlValidator:l,toolNameMapping:ae});de&&((R=i?.thinking)==null?void 0:R.type)==="disabled"&&(i.effort==="xhigh"||i.effort==="max")&&(d.push({type:"unsupported",feature:"providerOptions.anthropic.effort",details:`effort '${i.effort}' is not supported by ${this.modelId} when thinking is disabled. The effort has been lowered to 'high'.`}),i.effort="high");let j=(le=i?.thinking)==null?void 0:le.type,g=j==="enabled"||j==="adaptive",c=g||j==="disabled",L=j==="enabled"?(T=i?.thinking)==null?void 0:T.budgetTokens:void 0,he=j==="adaptive"?(ne=i?.thinking)==null?void 0:ne.display:void 0,s=g?i?.thinking==null?void 0:i.thinking.blockBinding:void 0,o=n??te,x={model:this.modelId,max_tokens:o,temperature:u,top_k:q,top_p:b,stop_sequences:Y,...c&&{thinking:{type:j,...L!=null&&{budget_tokens:L},...he!=null&&{display:he},...s!=null&&{block_binding:{prefix_mismatch_behavior:s.prefixMismatchBehavior}}}},...(i?.effort||i?.taskBudget||W&&z?.type==="json"&&z.schema!=null)&&{output_config:{...i?.effort&&{effort:i.effort},...i?.taskBudget&&{task_budget:{type:i.taskBudget.type,total:i.taskBudget.total,...i.taskBudget.remaining!=null&&{remaining:i.taskBudget.remaining}}},...W&&z?.type==="json"&&z.schema!=null&&{format:{type:"json_schema",schema:io(z.schema)}}}},...i?.speed&&{speed:i.speed},...i?.inferenceGeo&&{inference_geo:i.inferenceGeo},...i?.fallbacks!=null&&(i.fallbacks==="default"||i.fallbacks.length>0)&&{fallbacks:i.fallbacks},...i?.cacheControl&&{cache_control:i.cacheControl},...((ue=i?.metadata)==null?void 0:ue.userId)!=null&&{metadata:{user_id:i.metadata.userId}},...i?.mcpServers&&i.mcpServers.length>0&&{mcp_servers:i.mcpServers.map(C=>({type:C.type,name:C.name,url:C.url,authorization_token:C.authorizationToken,tool_configuration:C.toolConfiguration?{allowed_tools:C.toolConfiguration.allowedTools,enabled:C.toolConfiguration.enabled}:void 0}))},...i?.container&&{container:i.container.skills&&i.container.skills.length>0?{id:i.container.id,skills:i.container.skills.map(C=>({type:C.type,skill_id:C.skillId,version:C.version}))}:i.container.id},system:N.system,messages:N.messages,...U&&{context_management:{edits:U.edits.map(C=>{let Oe=C.type;switch(Oe){case"clear_tool_uses_20250919":return{type:C.type,...C.trigger!==void 0&&{trigger:C.trigger},...C.keep!==void 0&&{keep:C.keep},...C.clearAtLeast!==void 0&&{clear_at_least:C.clearAtLeast},...C.clearToolInputs!==void 0&&{clear_tool_inputs:C.clearToolInputs},...C.excludeTools!==void 0&&{exclude_tools:C.excludeTools}};case"clear_thinking_20251015":return{type:C.type,...C.keep!==void 0&&{keep:C.keep}};case"compact_20260112":return{type:C.type,...C.trigger!==void 0&&{trigger:C.trigger},...C.pauseAfterCompaction!==void 0&&{pause_after_compaction:C.pauseAfterCompaction},...C.instructions!==void 0&&{instructions:C.instructions}};default:d.push({type:"other",message:`Unknown context management strategy: ${Oe}`});return}}).filter(C=>C!==void 0)}}};g?(j==="enabled"&&L==null&&(d.push({type:"compatibility",feature:"extended thinking",details:"thinking budget is required when thinking is enabled. using default budget of 1024 tokens."}),x.thinking={type:"enabled",budget_tokens:1024},L=1024),x.temperature!=null&&(x.temperature=void 0,d.push({type:"unsupported",feature:"temperature",details:"temperature is not supported when thinking is enabled"})),q!=null&&(x.top_k=void 0,d.push({type:"unsupported",feature:"topK",details:"topK is not supported when thinking is enabled"})),b!=null&&(x.top_p=void 0,d.push({type:"unsupported",feature:"topP",details:"topP is not supported when thinking is enabled"})),x.max_tokens=o+(L??0)):y&&b!=null&&u!=null&&(d.push({type:"unsupported",feature:"topP",details:"topP is not supported when temperature is set. topP is ignored."}),x.top_p=void 0),oe&&x.max_tokens>te&&(n!=null&&d.push({type:"unsupported",feature:"maxOutputTokens",details:`${x.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${this.modelId} ${te} max output tokens. The max output tokens have been limited to ${te}.`}),x.max_tokens=te),i?.mcpServers&&i.mcpServers.length>0&&f.add("mcp-client-2025-04-04"),U&&(f.add("context-management-2025-06-27"),U.edits.some(C=>C.type==="compact_20260112")&&f.add("compact-2026-01-12")),i?.container&&i.container.skills&&i.container.skills.length>0&&(f.add("code-execution-2025-08-25"),f.add("skills-2025-10-02"),f.add("files-api-2025-04-14"),B?.some(C=>C.type==="provider"&&(C.id==="anthropic.code_execution_20250825"||C.id==="anthropic.code_execution_20260120"))||d.push({type:"other",message:"code execution tool is required when using skills"})),i?.taskBudget&&f.add("task-budgets-2026-03-13"),i?.speed==="fast"&&f.add("fast-mode-2026-02-01"),i?.fallbacks==="default"?f.add("server-side-fallback-2026-07-01"):i?.fallbacks&&i.fallbacks.length>0&&f.add("server-side-fallback-2026-06-01"),s!=null&&f.add("thinking-binding-controls-2026-08-01");let h=v&&((se=i?.toolStreaming)!=null?se:!0),{tools:E,toolChoice:ge,toolWarnings:ye,betas:fe}=await Ft(w!=null?{tools:[...B??[],w],toolChoice:{type:"required"},disableParallelToolUse:!0,cacheControlValidator:l,supportsStructuredOutput:!1,supportsStrictTools:Z,defaultEagerInputStreaming:h}:{tools:B??[],toolChoice:I,disableParallelToolUse:i?.disableParallelToolUse,cacheControlValidator:l,supportsStructuredOutput:p,supportsStrictTools:Z,defaultEagerInputStreaming:h}),st=l.getWarnings();return{args:{...x,tools:E,tool_choice:ge,stream:v===!0?!0:void 0},warnings:[...d,...ye,...st],betas:new Set([...f,...fe,...t,...(r=i?.anthropicBeta)!=null?r:[]]),usesJsonResponseTool:w!=null,toolNameMapping:ae,providerOptionsName:D,usedCustomProviderKey:ce}}async getHeaders({betas:t,headers:a}){return Ee(await Se(this.config.headers),a,t.size>0?{"anthropic-beta":Array.from(t).join(",")}:{})}async getBetasFromHeaders(t){var a,n;let b=(a=(await Se(this.config.headers))["anthropic-beta"])!=null?a:"",q=(n=t?.["anthropic-beta"])!=null?n:"";return new Set([...b.toLowerCase().split(","),...q.toLowerCase().split(",")].map(F=>F.trim()).filter(F=>F!==""))}buildRequestUrl(t){var a,n,u;return(u=(n=(a=this.config).buildRequestUrl)==null?void 0:n.call(a,this.config.baseURL,t))!=null?u:`${this.config.baseURL}/messages`}transformRequestBody(t,a){var n,u,b;return(b=(u=(n=this.config).transformRequestBody)==null?void 0:u.call(n,t,a))!=null?b:t}extractCitationDocuments(t){let a=S(n=>{var u,b;if(n.type!=="file"||n.mediaType!=="application/pdf"&&n.mediaType!=="text/plain")return!1;let q=(u=n.providerOptions)==null?void 0:u.anthropic,F=q?.citations;return(b=F?.enabled)!=null?b:!1},"isCitationPart");return t.filter(n=>n.role==="user").flatMap(n=>n.content).filter(a).map(n=>{var u;let b=n;return{title:(u=b.filename)!=null?u:"Untitled Document",filename:b.filename,mediaType:b.mediaType}})}async doGenerate(t){var a,n,u,b,q,F,$,Y;let{args:z,warnings:O,betas:B,usesJsonResponseTool:I,toolNameMapping:P,providerOptionsName:v,usedCustomProviderKey:k}=await this.getArgs({...t,stream:!1,userSuppliedBetas:await this.getBetasFromHeaders(t.headers)}),M=[...this.extractCitationDocuments(t.prompt)],J=Ge(z.tools),{responseHeaders:Q,value:R,rawValue:le}=await je({url:this.buildRequestUrl(!1),headers:await this.getHeaders({betas:B,headers:t.headers}),body:this.transformRequestBody(z,B),failedResponseHandler:Fe,successfulResponseHandler:De(ut),abortSignal:t.abortSignal,fetch:this.config.fetch}),T=[],ne={},ue={},se=!1;for(let r of R.content)switch(r.type){case"text":{if(!I){let d=(a=r.citations)==null?void 0:a.filter(D=>D.type==="web_search_result_location");if(T.push({type:"text",text:r.text,...d!=null&&d.length>0&&{providerMetadata:{anthropic:{citations:d}}}}),r.citations)for(let D of r.citations){let H=Ve(D,M,this.generateId);H&&T.push(H)}}break}case"thinking":{T.push({type:"reasoning",text:r.thinking,providerMetadata:{anthropic:{signature:r.signature}}});break}case"redacted_thinking":{T.push({type:"reasoning",text:"",providerMetadata:{anthropic:{redactedData:r.data}}});break}case"compaction":{T.push({type:"text",text:r.content,providerMetadata:{anthropic:{type:"compaction"}}});break}case"tool_use":{I&&r.name==="json"?(se=!0,T.push({type:"text",text:JSON.stringify(r.input)})):T.push({type:"tool-call",toolCallId:r.id,toolName:r.name,input:JSON.stringify(r.input),...ie(r.caller)});break}case"server_tool_use":{if(r.name==="text_editor_code_execution"||r.name==="bash_code_execution")T.push({type:"tool-call",toolCallId:r.id,toolName:P.toCustomToolName("code_execution"),input:JSON.stringify({type:r.name,...r.input}),providerExecuted:!0,...J&&"code_execution"==="code_execution"?{dynamic:!0}:{},...ie(r.caller)});else if(r.name==="web_search"||r.name==="code_execution"||r.name==="web_fetch"){let d=r.name==="code_execution"&&r.input!=null&&typeof r.input=="object"&&"code"in r.input&&!("type"in r.input)?{type:"programmatic-tool-call",...r.input}:r.input;T.push({type:"tool-call",toolCallId:r.id,toolName:P.toCustomToolName(r.name),input:JSON.stringify(d),providerExecuted:!0,...J&&r.name==="code_execution"?{dynamic:!0}:{},...ie(r.caller)})}else r.name==="tool_search_tool_regex"||r.name==="tool_search_tool_bm25"?(ue[r.id]=r.name,T.push({type:"tool-call",toolCallId:r.id,toolName:P.toCustomToolName(r.name),input:JSON.stringify(r.input),providerExecuted:!0,...ie(r.caller)})):r.name==="advisor"&&T.push({type:"tool-call",toolCallId:r.id,toolName:P.toCustomToolName("advisor"),input:JSON.stringify(r.input),providerExecuted:!0,...ie(r.caller)});break}case"mcp_tool_use":{ne[r.id]={type:"tool-call",toolCallId:r.id,toolName:r.name,input:JSON.stringify(r.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:"mcp-tool-use",serverName:r.server_name}}},T.push(ne[r.id]);break}case"mcp_tool_result":{T.push({type:"tool-result",toolCallId:r.tool_use_id,toolName:ne[r.tool_use_id].toolName,isError:r.is_error,result:r.content,dynamic:!0,providerMetadata:ne[r.tool_use_id].providerMetadata});break}case"web_fetch_tool_result":{r.content.type==="web_fetch_result"?(M.push({title:(n=r.content.content.title)!=null?n:r.content.url,mediaType:r.content.content.source.media_type}),T.push({type:"tool-result",toolCallId:r.tool_use_id,toolName:P.toCustomToolName("web_fetch"),result:{type:"web_fetch_result",url:r.content.url,retrievedAt:r.content.retrieved_at,content:{type:r.content.content.type,title:r.content.content.title,citations:r.content.content.citations,source:{type:r.content.content.source.type,mediaType:r.content.content.source.media_type,data:r.content.content.source.data}}},...ie(r.caller)})):r.content.type==="web_fetch_tool_result_error"&&T.push({type:"tool-result",toolCallId:r.tool_use_id,toolName:P.toCustomToolName("web_fetch"),isError:!0,result:{type:"web_fetch_tool_result_error",errorCode:r.content.error_code},...ie(r.caller)});break}case"web_search_tool_result":{if(Array.isArray(r.content)){T.push({type:"tool-result",toolCallId:r.tool_use_id,toolName:P.toCustomToolName("web_search"),result:r.content.map(d=>{var D;return{url:d.url,title:d.title,pageAge:(D=d.page_age)!=null?D:null,encryptedContent:d.encrypted_content,type:d.type}}),...ie(r.caller)});for(let d of r.content)T.push({type:"source",sourceType:"url",id:this.generateId(),url:d.url,title:d.title,providerMetadata:{anthropic:{pageAge:(u=d.page_age)!=null?u:null}}})}else T.push({type:"tool-result",toolCallId:r.tool_use_id,toolName:P.toCustomToolName("web_search"),isError:!0,result:{type:"web_search_tool_result_error",errorCode:r.content.error_code},...ie(r.caller)});break}case"code_execution_tool_result":{r.content.type==="code_execution_result"?T.push({type:"tool-result",toolCallId:r.tool_use_id,toolName:P.toCustomToolName("code_execution"),result:{type:r.content.type,stdout:r.content.stdout,stderr:r.content.stderr,return_code:r.content.return_code,content:(b=r.content.content)!=null?b:[]}}):r.content.type==="encrypted_code_execution_result"?T.push({type:"tool-result",toolCallId:r.tool_use_id,toolName:P.toCustomToolName("code_execution"),result:{type:r.content.type,encrypted_stdout:r.content.encrypted_stdout,stderr:r.content.stderr,return_code:r.content.return_code,content:(q=r.content.content)!=null?q:[]}}):r.content.type==="code_execution_tool_result_error"&&T.push({type:"tool-result",toolCallId:r.tool_use_id,toolName:P.toCustomToolName("code_execution"),isError:!0,result:{type:"code_execution_tool_result_error",errorCode:r.content.error_code}});break}case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":{T.push({type:"tool-result",toolCallId:r.tool_use_id,toolName:P.toCustomToolName("code_execution"),result:r.content});break}case"tool_search_tool_result":{let d=ue[r.tool_use_id];if(d==null){let D=P.toCustomToolName("tool_search_tool_bm25"),H=P.toCustomToolName("tool_search_tool_regex");D!=="tool_search_tool_bm25"?d="tool_search_tool_bm25":d="tool_search_tool_regex"}r.content.type==="tool_search_tool_search_result"?T.push({type:"tool-result",toolCallId:r.tool_use_id,toolName:P.toCustomToolName(d),result:r.content.tool_references.map(D=>({type:D.type,toolName:D.tool_name}))}):T.push({type:"tool-result",toolCallId:r.tool_use_id,toolName:P.toCustomToolName(d),isError:!0,result:{type:"tool_search_tool_result_error",errorCode:r.content.error_code}});break}case"advisor_tool_result":{let d=P.toCustomToolName("advisor");r.content.type==="advisor_result"?T.push({type:"tool-result",toolCallId:r.tool_use_id,toolName:d,result:{type:"advisor_result",text:r.content.text}}):r.content.type==="advisor_redacted_result"?T.push({type:"tool-result",toolCallId:r.tool_use_id,toolName:d,result:{type:"advisor_redacted_result",encryptedContent:r.content.encrypted_content}}):T.push({type:"tool-result",toolCallId:r.tool_use_id,toolName:d,isError:!0,result:{type:"advisor_tool_result_error",errorCode:r.content.error_code}});break}case"fallback":break}return{content:T,finishReason:{unified:Te({finishReason:R.stop_reason,isJsonResponseFromTool:se}),raw:(F=R.stop_reason)!=null?F:void 0},usage:We({usage:R.usage}),request:{body:z},response:{id:($=R.id)!=null?$:void 0,modelId:(Y=R.model)!=null?Y:void 0,headers:Q,body:le},warnings:O,providerMetadata:(()=>{var r,d,D,H,ee;let ce=Xe(R.stop_details),i={usage:R.usage,cacheCreationInputTokens:(r=R.usage.cache_creation_input_tokens)!=null?r:null,stopSequence:(d=R.stop_sequence)!=null?d:null,...ce!=null?{stopDetails:ce}:{},...R.input_transformations!=null?{inputTransformations:R.input_transformations}:{},iterations:R.usage.iterations?R.usage.iterations.map(A=>({type:A.type,...A.model!=null?{model:A.model}:{},inputTokens:A.input_tokens,outputTokens:A.output_tokens,...A.cache_creation_input_tokens?{cacheCreationInputTokens:A.cache_creation_input_tokens}:{},...A.cache_read_input_tokens?{cacheReadInputTokens:A.cache_read_input_tokens}:{}})):null,container:R.container?{expiresAt:R.container.expires_at,id:R.container.id,skills:(H=(D=R.container.skills)==null?void 0:D.map(A=>({type:A.type,skillId:A.skill_id,version:A.version})))!=null?H:null}:null,contextManagement:(ee=Ze(R.context_management))!=null?ee:null},te={anthropic:i};return k&&v!=="anthropic"&&(te[v]=i),te})()}}async doStream(t){var a,n;let{args:u,warnings:b,betas:q,usesJsonResponseTool:F,toolNameMapping:$,providerOptionsName:Y,usedCustomProviderKey:z}=await this.getArgs({...t,stream:!0,userSuppliedBetas:await this.getBetasFromHeaders(t.headers)}),O=[...this.extractCitationDocuments(t.prompt)],B=Ge(u.tools),I=this.buildRequestUrl(!0),{responseHeaders:P,value:v}=await je({url:I,headers:await this.getHeaders({betas:q,headers:t.headers}),body:this.transformRequestBody(u,q),failedResponseHandler:Fe,successfulResponseHandler:Ae(pt),abortSignal:t.abortSignal,fetch:this.config.fetch}),k={unified:"other",raw:void 0},M={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,iterations:null},J={},Q={},R={},le=null,T,ne=null,ue=null,se,r,d=null,D=!1,H=!1,ee,ce=!1,i,te=this.generateId,A=v.pipeThrough(new TransformStream({start(y){y.enqueue({type:"stream-start",warnings:b})},transform(y,p){var Z,X,W,w,U,l,ae,N,f,j,g,c,L,he;if(ce)return;if(t.includeRawChunks&&p.enqueue({type:"raw",rawValue:y.rawValue}),!y.success){p.enqueue({type:"error",error:y.error});return}let s=y.value;switch(s.type){case"ping":return;case"content_block_start":{let o=s.content_block,x=o.type;if(x==="fallback")return;switch(i=x,x){case"text":{if(F)return;J[s.index]={type:"text",citations:[]},p.enqueue({type:"text-start",id:String(s.index)});return}case"thinking":{J[s.index]={type:"reasoning"},p.enqueue({type:"reasoning-start",id:String(s.index)});return}case"redacted_thinking":{J[s.index]={type:"reasoning"},p.enqueue({type:"reasoning-start",id:String(s.index),providerMetadata:{anthropic:{redactedData:o.data}}});return}case"compaction":{J[s.index]={type:"text",citations:[]},p.enqueue({type:"text-start",id:String(s.index),providerMetadata:{anthropic:{type:"compaction"}}});return}case"tool_use":{if(F&&o.name==="json")D=!0,J[s.index]={type:"text",citations:[]},p.enqueue({type:"text-start",id:String(s.index)});else{let E=xe(o.caller),ye=o.input&&Object.keys(o.input).length>0?JSON.stringify(o.input):"";J[s.index]={type:"tool-call",toolCallId:o.id,toolName:o.name,input:ye,firstDelta:ye.length===0,...E&&{caller:E}},p.enqueue({type:"tool-input-start",id:o.id,toolName:o.name})}return}case"server_tool_use":{let h=xe(o.caller);if(["web_fetch","web_search","code_execution","text_editor_code_execution","bash_code_execution"].includes(o.name)){let E=o.name==="text_editor_code_execution"||o.name==="bash_code_execution"?"code_execution":o.name,ge=o.name==="text_editor_code_execution"||o.name==="bash_code_execution"?o.name:o.name==="code_execution"?"programmatic-tool-call":void 0,ye=$.toCustomToolName(E),fe=o.input!=null&&typeof o.input=="object"&&Object.keys(o.input).length>0?JSON.stringify(o.input):"";J[s.index]={type:"tool-call",toolCallId:o.id,toolName:ye,input:fe,providerExecuted:!0,...B&&E==="code_execution"?{dynamic:!0}:{},firstDelta:fe.length===0,providerToolName:E,providerToolInputType:ge,...h&&{caller:h}},p.enqueue({type:"tool-input-start",id:o.id,toolName:ye,providerExecuted:!0,...B&&E==="code_execution"?{dynamic:!0}:{}})}else if(o.name==="tool_search_tool_regex"||o.name==="tool_search_tool_bm25"){R[o.id]=o.name;let E=$.toCustomToolName(o.name);J[s.index]={type:"tool-call",toolCallId:o.id,toolName:E,input:"",providerExecuted:!0,firstDelta:!0,providerToolName:o.name,...h&&{caller:h}},p.enqueue({type:"tool-input-start",id:o.id,toolName:E,providerExecuted:!0})}else if(o.name==="advisor"){let E=$.toCustomToolName("advisor");J[s.index]={type:"tool-call",toolCallId:o.id,toolName:E,input:"{}",providerExecuted:!0,firstDelta:!0,providerToolName:o.name,...h&&{caller:h}},p.enqueue({type:"tool-input-start",id:o.id,toolName:E,providerExecuted:!0})}return}case"web_fetch_tool_result":{o.content.type==="web_fetch_result"?(O.push({title:(Z=o.content.content.title)!=null?Z:o.content.url,mediaType:o.content.content.source.media_type}),p.enqueue({type:"tool-result",toolCallId:o.tool_use_id,toolName:$.toCustomToolName("web_fetch"),result:{type:"web_fetch_result",url:o.content.url,retrievedAt:o.content.retrieved_at,content:{type:o.content.content.type,title:o.content.content.title,citations:o.content.content.citations,source:{type:o.content.content.source.type,mediaType:o.content.content.source.media_type,data:o.content.content.source.data}}},...ie(o.caller)})):o.content.type==="web_fetch_tool_result_error"&&p.enqueue({type:"tool-result",toolCallId:o.tool_use_id,toolName:$.toCustomToolName("web_fetch"),isError:!0,result:{type:"web_fetch_tool_result_error",errorCode:o.content.error_code},...ie(o.caller)});return}case"web_search_tool_result":{if(Array.isArray(o.content)){p.enqueue({type:"tool-result",toolCallId:o.tool_use_id,toolName:$.toCustomToolName("web_search"),result:o.content.map(h=>{var E;return{url:h.url,title:h.title,pageAge:(E=h.page_age)!=null?E:null,encryptedContent:h.encrypted_content,type:h.type}}),...ie(o.caller)});for(let h of o.content)p.enqueue({type:"source",sourceType:"url",id:te(),url:h.url,title:h.title,providerMetadata:{anthropic:{pageAge:(X=h.page_age)!=null?X:null}}})}else p.enqueue({type:"tool-result",toolCallId:o.tool_use_id,toolName:$.toCustomToolName("web_search"),isError:!0,result:{type:"web_search_tool_result_error",errorCode:o.content.error_code},...ie(o.caller)});return}case"code_execution_tool_result":{o.content.type==="code_execution_result"?p.enqueue({type:"tool-result",toolCallId:o.tool_use_id,toolName:$.toCustomToolName("code_execution"),result:{type:o.content.type,stdout:o.content.stdout,stderr:o.content.stderr,return_code:o.content.return_code,content:(W=o.content.content)!=null?W:[]}}):o.content.type==="encrypted_code_execution_result"?p.enqueue({type:"tool-result",toolCallId:o.tool_use_id,toolName:$.toCustomToolName("code_execution"),result:{type:o.content.type,encrypted_stdout:o.content.encrypted_stdout,stderr:o.content.stderr,return_code:o.content.return_code,content:(w=o.content.content)!=null?w:[]}}):o.content.type==="code_execution_tool_result_error"&&p.enqueue({type:"tool-result",toolCallId:o.tool_use_id,toolName:$.toCustomToolName("code_execution"),isError:!0,result:{type:"code_execution_tool_result_error",errorCode:o.content.error_code}});return}case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":{p.enqueue({type:"tool-result",toolCallId:o.tool_use_id,toolName:$.toCustomToolName("code_execution"),result:o.content});return}case"tool_search_tool_result":{let h=R[o.tool_use_id];if(h==null){let E=$.toCustomToolName("tool_search_tool_bm25"),ge=$.toCustomToolName("tool_search_tool_regex");E!=="tool_search_tool_bm25"?h="tool_search_tool_bm25":h="tool_search_tool_regex"}o.content.type==="tool_search_tool_search_result"?p.enqueue({type:"tool-result",toolCallId:o.tool_use_id,toolName:$.toCustomToolName(h),result:o.content.tool_references.map(E=>({type:E.type,toolName:E.tool_name}))}):p.enqueue({type:"tool-result",toolCallId:o.tool_use_id,toolName:$.toCustomToolName(h),isError:!0,result:{type:"tool_search_tool_result_error",errorCode:o.content.error_code}});return}case"advisor_tool_result":{let h=$.toCustomToolName("advisor");o.content.type==="advisor_result"?p.enqueue({type:"tool-result",toolCallId:o.tool_use_id,toolName:h,result:{type:"advisor_result",text:o.content.text}}):o.content.type==="advisor_redacted_result"?p.enqueue({type:"tool-result",toolCallId:o.tool_use_id,toolName:h,result:{type:"advisor_redacted_result",encryptedContent:o.content.encrypted_content}}):p.enqueue({type:"tool-result",toolCallId:o.tool_use_id,toolName:h,isError:!0,result:{type:"advisor_tool_result_error",errorCode:o.content.error_code}});return}case"mcp_tool_use":{Q[o.id]={type:"tool-call",toolCallId:o.id,toolName:o.name,input:JSON.stringify(o.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:"mcp-tool-use",serverName:o.server_name}}},p.enqueue(Q[o.id]);return}case"mcp_tool_result":{p.enqueue({type:"tool-result",toolCallId:o.tool_use_id,toolName:Q[o.tool_use_id].toolName,isError:o.is_error,result:o.content,dynamic:!0,providerMetadata:Q[o.tool_use_id].providerMetadata});return}default:{let h=x;throw new Error(`Unsupported content block type: ${h}`)}}}case"content_block_stop":{if(J[s.index]!=null){let o=J[s.index];switch(o.type){case"text":{p.enqueue({type:"text-end",id:String(s.index),...o.citations.length>0&&{providerMetadata:{anthropic:{citations:o.citations}}}});break}case"reasoning":{p.enqueue({type:"reasoning-end",id:String(s.index)});break}case"tool-call":if(!(F&&o.toolName==="json")){p.enqueue({type:"tool-input-end",id:o.toolCallId});let h=o.input===""?"{}":o.input;if(o.providerToolName==="code_execution")try{let E=ve(h);E!=null&&typeof E=="object"&&"code"in E&&!("type"in E)&&(h=JSON.stringify({type:"programmatic-tool-call",...E}))}catch{}p.enqueue({type:"tool-call",toolCallId:o.toolCallId,toolName:o.toolName,input:h,providerExecuted:o.providerExecuted,...B&&o.providerToolName==="code_execution"?{dynamic:!0}:{},...o.caller&&{providerMetadata:{anthropic:{caller:o.caller}}}})}break}delete J[s.index]}i=void 0;return}case"content_block_delta":{let o=s.delta.type;switch(o){case"text_delta":{if(F)return;p.enqueue({type:"text-delta",id:String(s.index),delta:s.delta.text});return}case"thinking_delta":{p.enqueue({type:"reasoning-delta",id:String(s.index),delta:s.delta.thinking});return}case"signature_delta":{i==="thinking"&&p.enqueue({type:"reasoning-delta",id:String(s.index),delta:"",providerMetadata:{anthropic:{signature:s.delta.signature}}});return}case"compaction_delta":{s.delta.content!=null&&p.enqueue({type:"text-delta",id:String(s.index),delta:s.delta.content});return}case"input_json_delta":{let x=J[s.index],h=s.delta.partial_json;if(h.length===0)return;if(D){if(x?.type!=="text")return;p.enqueue({type:"text-delta",id:String(s.index),delta:h})}else{if(x?.type!=="tool-call")return;x.firstDelta&&x.providerToolInputType!=null&&(h=`{"type": "${x.providerToolInputType}",${h.substring(1)}`),p.enqueue({type:"tool-input-delta",id:x.toolCallId,delta:h}),x.input+=h,x.firstDelta=!1}return}case"citations_delta":{let x=s.delta.citation,h=J[s.index];h?.type==="text"&&x.type==="web_search_result_location"&&h.citations.push(x);let E=Ve(x,O,te);E&&p.enqueue(E);return}default:{let x=o;throw new Error(`Unsupported delta type: ${x}`)}}}case"message_start":{if(H){if(ee===s.message.id)return;ce=!0,p.enqueue({type:"error",error:new ze({data:s,message:`Received message_start for message ${JSON.stringify(s.message.id)} while message ${JSON.stringify(ee)} is still open.`})});return}if(H=!0,ee=s.message.id,M.input_tokens=s.message.usage.input_tokens,s.message.input_transformations!=null&&(r=s.message.input_transformations),M.cache_read_input_tokens=(U=s.message.usage.cache_read_input_tokens)!=null?U:0,M.cache_creation_input_tokens=(l=s.message.usage.cache_creation_input_tokens)!=null?l:0,T={...s.message.usage},ne=(ae=s.message.usage.cache_creation_input_tokens)!=null?ae:null,s.message.container!=null&&(d={expiresAt:s.message.container.expires_at,id:s.message.container.id,skills:null}),s.message.stop_reason!=null&&(k={unified:Te({finishReason:s.message.stop_reason,isJsonResponseFromTool:D}),raw:s.message.stop_reason}),p.enqueue({type:"response-metadata",id:(N=s.message.id)!=null?N:void 0,modelId:(f=s.message.model)!=null?f:void 0}),s.message.content!=null)for(let o=0;o<s.message.content.length;o++){let x=s.message.content[o];if(x.type==="tool_use"){let h=xe(x.caller);p.enqueue({type:"tool-input-start",id:x.id,toolName:x.name});let E=JSON.stringify((j=x.input)!=null?j:{});p.enqueue({type:"tool-input-delta",id:x.id,delta:E}),p.enqueue({type:"tool-input-end",id:x.id}),p.enqueue({type:"tool-call",toolCallId:x.id,toolName:x.name,input:E,...h&&{providerMetadata:{anthropic:{caller:h}}}})}}return}case"message_delta":{s.usage.input_tokens!=null&&M.input_tokens!==s.usage.input_tokens&&(M.input_tokens=s.usage.input_tokens),M.output_tokens=s.usage.output_tokens,s.usage.output_tokens_details!=null&&(M.output_tokens_details=s.usage.output_tokens_details),s.usage.cache_read_input_tokens!=null&&(M.cache_read_input_tokens=s.usage.cache_read_input_tokens),s.usage.cache_creation_input_tokens!=null&&(M.cache_creation_input_tokens=s.usage.cache_creation_input_tokens,ne=s.usage.cache_creation_input_tokens),s.usage.iterations!=null&&(M.iterations=s.usage.iterations),k={unified:Te({finishReason:s.delta.stop_reason,isJsonResponseFromTool:D}),raw:(g=s.delta.stop_reason)!=null?g:void 0},ue=(c=s.delta.stop_sequence)!=null?c:null,se=Xe(s.delta.stop_details),d=s.delta.container!=null?{expiresAt:s.delta.container.expires_at,id:s.delta.container.id,skills:(he=(L=s.delta.container.skills)==null?void 0:L.map(o=>({type:o.type,skillId:o.skill_id,version:o.version})))!=null?he:null}:null,s.context_management&&(le=Ze(s.context_management)),T={...T,...s.usage};return}case"message_stop":{H=!1,ee=void 0;let o={usage:T??null,cacheCreationInputTokens:ne,stopSequence:ue,...se!=null?{stopDetails:se}:{},...r!=null?{inputTransformations:r}:{},iterations:M.iterations?M.iterations.map(h=>({type:h.type,...h.model!=null?{model:h.model}:{},inputTokens:h.input_tokens,outputTokens:h.output_tokens,...h.cache_creation_input_tokens?{cacheCreationInputTokens:h.cache_creation_input_tokens}:{},...h.cache_read_input_tokens?{cacheReadInputTokens:h.cache_read_input_tokens}:{}})):null,container:d,contextManagement:le},x={anthropic:o};z&&Y!=="anthropic"&&(x[Y]=o),p.enqueue({type:"finish",finishReason:k,usage:We({usage:M,rawUsage:T}),providerMetadata:x});return}case"error":{p.enqueue({type:"error",error:s.error});return}default:{let o=s;throw new Error(`Unsupported chunk type: ${o}`)}}}})),[G,de]=A.tee(),oe=G.getReader();try{await oe.read();let y=await oe.read();if(((a=y.value)==null?void 0:a.type)==="raw"&&(y=await oe.read()),((n=y.value)==null?void 0:n.type)==="error"){let p=y.value.error;throw new Ie({message:p.message,url:I,requestBodyValues:u,statusCode:p.type==="overloaded_error"?529:500,responseHeaders:P,responseBody:JSON.stringify(p),isRetryable:p.type==="overloaded_error"})}}finally{oe.cancel().catch(()=>{}),oe.releaseLock()}return{stream:de,request:{body:u},response:{headers:P}}}};function po(t){return t.includes("claude-opus-5")?{maxOutputTokens:128e3,supportsStructuredOutput:!0,rejectsSamplingParameters:!0,rejectsThinkingDisabledAboveHighEffort:!0,isKnownModel:!0}:t.includes("claude-opus-4-8")||t.includes("claude-opus-4-7")||t.includes("claude-fable-5")||t.includes("claude-sonnet-5")?{maxOutputTokens:128e3,supportsStructuredOutput:!0,rejectsSamplingParameters:!0,rejectsThinkingDisabledAboveHighEffort:!1,isKnownModel:!0}:t.includes("claude-sonnet-4-6")||t.includes("claude-opus-4-6")?{maxOutputTokens:128e3,supportsStructuredOutput:!0,rejectsSamplingParameters:!1,rejectsThinkingDisabledAboveHighEffort:!1,isKnownModel:!0}:t.includes("claude-sonnet-4-5")||t.includes("claude-opus-4-5")||t.includes("claude-haiku-4-5")?{maxOutputTokens:64e3,supportsStructuredOutput:!0,rejectsSamplingParameters:!1,rejectsThinkingDisabledAboveHighEffort:!1,isKnownModel:!0}:t.includes("claude-opus-4-1")?{maxOutputTokens:32e3,supportsStructuredOutput:!0,rejectsSamplingParameters:!1,rejectsThinkingDisabledAboveHighEffort:!1,isKnownModel:!0}:t.includes("claude-sonnet-4-")?{maxOutputTokens:64e3,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,rejectsThinkingDisabledAboveHighEffort:!1,isKnownModel:!0}:t.includes("claude-opus-4-")?{maxOutputTokens:32e3,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,rejectsThinkingDisabledAboveHighEffort:!1,isKnownModel:!0}:t.includes("claude-3-haiku")?{maxOutputTokens:4096,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,rejectsThinkingDisabledAboveHighEffort:!1,isKnownModel:!0}:/claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(t)?{maxOutputTokens:4096,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,rejectsThinkingDisabledAboveHighEffort:!1,isKnownModel:!1}:t.includes("claude-")?{maxOutputTokens:128e3,supportsStructuredOutput:!0,rejectsSamplingParameters:!0,rejectsThinkingDisabledAboveHighEffort:!0,isKnownModel:!1}:{maxOutputTokens:4096,supportsStructuredOutput:!1,rejectsSamplingParameters:!1,rejectsThinkingDisabledAboveHighEffort:!1,isKnownModel:!1}}S(po,"getModelCapabilities");function Ge(t){if(!t)return!1;let a=!1,n=!1;for(let u of t){if("type"in u&&(u.type==="web_fetch_20260209"||u.type==="web_search_20260209")){a=!0;continue}if(u.name==="code_execution"){n=!0;break}}return a&&!n}S(Ge,"hasWebTool20260209WithoutCodeExecution");function Ze(t){return t?{appliedEdits:t.applied_edits.map(a=>{switch(a.type){case"clear_tool_uses_20250919":return{type:a.type,clearedToolUses:a.cleared_tool_uses,clearedInputTokens:a.cleared_input_tokens};case"clear_thinking_20251015":return{type:a.type,clearedThinkingTurns:a.cleared_thinking_turns,clearedInputTokens:a.cleared_input_tokens};case"compact_20260112":return{type:a.type}}}).filter(a=>a!==void 0)}:null}S(Ze,"mapAnthropicResponseContextManagement");function Xe(t){if(t!=null)return{type:t.type,...t.category!=null?{category:t.category}:{},...t.explanation!=null?{explanation:t.explanation}:{},...t.recommended_model!=null?{recommendedModel:t.recommended_model}:{}}}S(Xe,"mapAnthropicStopDetails");var _o=_(()=>m(e.object({command:e.string(),restart:e.boolean().optional()}))),mo=K({id:"anthropic.bash_20241022",inputSchema:_o}),ho=_(()=>m(e.object({command:e.string(),restart:e.boolean().optional()}))),yo=K({id:"anthropic.bash_20250124",inputSchema:ho}),go=_(()=>m(e.object({action:e.enum(["key","type","mouse_move","left_click","left_click_drag","right_click","middle_click","double_click","screenshot","cursor_position"]),coordinate:e.array(e.number().int()).optional(),text:e.string().optional()}))),bo=K({id:"anthropic.computer_20241022",inputSchema:go}),fo=_(()=>m(e.object({action:e.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:e.tuple([e.number().int(),e.number().int()]).optional(),duration:e.number().optional(),scroll_amount:e.number().optional(),scroll_direction:e.enum(["up","down","left","right"]).optional(),start_coordinate:e.tuple([e.number().int(),e.number().int()]).optional(),text:e.string().optional()}))),vo=K({id:"anthropic.computer_20250124",inputSchema:fo}),xo=_(()=>m(e.object({action:e.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:e.tuple([e.number().int(),e.number().int()]).optional(),duration:e.number().optional(),region:e.tuple([e.number().int(),e.number().int(),e.number().int(),e.number().int()]).optional(),scroll_amount:e.number().optional(),scroll_direction:e.enum(["up","down","left","right"]).optional(),start_coordinate:e.tuple([e.number().int(),e.number().int()]).optional(),text:e.string().optional()}))),ko=K({id:"anthropic.computer_20251124",inputSchema:xo}),jo=_(()=>m(e.discriminatedUnion("command",[e.object({command:e.literal("view"),path:e.string(),view_range:e.tuple([e.number(),e.number()]).optional()}),e.object({command:e.literal("create"),path:e.string(),file_text:e.string()}),e.object({command:e.literal("str_replace"),path:e.string(),old_str:e.string(),new_str:e.string()}),e.object({command:e.literal("insert"),path:e.string(),insert_line:e.number(),insert_text:e.string()}),e.object({command:e.literal("delete"),path:e.string()}),e.object({command:e.literal("rename"),old_path:e.string(),new_path:e.string()})]))),So=K({id:"anthropic.memory_20250818",inputSchema:jo}),wo=_(()=>m(e.object({command:e.enum(["view","create","str_replace","insert","undo_edit"]),path:e.string(),file_text:e.string().optional(),insert_line:e.number().int().optional(),new_str:e.string().optional(),insert_text:e.string().optional(),old_str:e.string().optional(),view_range:e.array(e.number().int()).optional()}))),Co=K({id:"anthropic.text_editor_20241022",inputSchema:wo}),To=_(()=>m(e.object({command:e.enum(["view","create","str_replace","insert","undo_edit"]),path:e.string(),file_text:e.string().optional(),insert_line:e.number().int().optional(),new_str:e.string().optional(),insert_text:e.string().optional(),old_str:e.string().optional(),view_range:e.array(e.number().int()).optional()}))),No=K({id:"anthropic.text_editor_20250124",inputSchema:To}),Oo=_(()=>m(e.object({command:e.enum(["view","create","str_replace","insert"]),path:e.string(),file_text:e.string().optional(),insert_line:e.number().int().optional(),new_str:e.string().optional(),insert_text:e.string().optional(),old_str:e.string().optional(),view_range:e.array(e.number().int()).optional()}))),Io=K({id:"anthropic.text_editor_20250429",inputSchema:Oo}),zo=_(()=>m(e.array(e.object({type:e.literal("tool_reference"),toolName:e.string()})))),Eo=_(()=>m(e.object({query:e.string(),limit:e.number().optional()}))),Po=V({id:"anthropic.tool_search_bm25_20251119",inputSchema:Eo,outputSchema:zo,supportsDeferredResults:!0}),qo=S((t={})=>Po(t),"toolSearchBm25_20251119"),Pr={advisor_20260301:bt,bash_20241022:mo,bash_20250124:yo,codeExecution_20250522:Ht,codeExecution_20250825:Kt,codeExecution_20260120:Zt,computer_20241022:bo,computer_20250124:vo,computer_20251124:ko,memory_20250818:So,textEditor_20241022:Co,textEditor_20250124:No,textEditor_20250429:Io,textEditor_20250728:kt,webFetch_20250910:Dt,webFetch_20260209:Rt,webSearch_20250305:zt,webSearch_20260209:Tt,toolSearchRegex_20251119:Qt,toolSearchBm25_20251119:qo};export{Ft as a,io as b,dr as c,po as d,Pr as e};
@@ -0,0 +1,18 @@
1
+ // Built by esbuild from opencode-server source
2
+ if (typeof globalThis.Bun === 'undefined') {
3
+ globalThis.Bun = {
4
+ version: '0.0.0-node-compat',
5
+ stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
6
+ which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
7
+ };
8
+ }
9
+ if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
10
+ if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
11
+ import { createRequire as __alchemyCreateRequire } from 'node:module';
12
+ const require = __alchemyCreateRequire(import.meta.url);
13
+ import { fileURLToPath as __alchemyFileURLToPath } from 'node:url';
14
+ import { dirname as __alchemyDirname } from 'node:path';
15
+ const __alchemy_filename = __alchemyFileURLToPath(import.meta.url);
16
+ const __alchemy_dirname = __alchemyDirname(__alchemy_filename);
17
+
18
+ import{a as s,d as Ie,g as Pe}from"./chunk-2MRHL4B2.js";var me=Ie((Qe,j)=>{var k,K,z,V,q,X,H,J,Q,W,Z,Y,ee,S,I,te,re,ne,F,oe,ae,se,ie,fe,ce,ue,le,ye,U,_e,xe,pe;(function(r){var a=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(u){r(c(a,c(u)))}):typeof j=="object"&&typeof j.exports=="object"?r(c(a,c(j.exports))):r(c(a));function c(u,_){return u!==a&&(typeof Object.create=="function"?Object.defineProperty(u,"__esModule",{value:!0}):u.__esModule=!0),function(e,t){return u[e]=_?_(e,t):t}}s(c,"createExporter")})(function(r){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])};k=s(function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");a(e,t);function n(){this.constructor=e}s(n,"__"),e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)},"__extends"),K=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},z=s(function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]]);return n},"__rest"),V=s(function(e,t,n,o){var i=arguments.length,f=i<3?t:o===null?o=Object.getOwnPropertyDescriptor(t,n):o,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(e,t,n,o);else for(var x=e.length-1;x>=0;x--)(l=e[x])&&(f=(i<3?l(f):i>3?l(t,n,f):l(t,n))||f);return i>3&&f&&Object.defineProperty(t,n,f),f},"__decorate"),q=s(function(e,t){return function(n,o){t(n,o,e)}},"__param"),X=s(function(e,t,n,o,i,f){function l(A){if(A!==void 0&&typeof A!="function")throw new TypeError("Function expected");return A}s(l,"accept");for(var x=o.kind,h=x==="getter"?"get":x==="setter"?"set":"value",y=!t&&e?o.static?e:e.prototype:null,m=t||(y?Object.getOwnPropertyDescriptor(y,o.name):{}),B,O=!1,p=n.length-1;p>=0;p--){var b={};for(var w in o)b[w]=w==="access"?{}:o[w];for(var w in o.access)b.access[w]=o.access[w];b.addInitializer=function(A){if(O)throw new TypeError("Cannot add initializers after decoration has completed");f.push(l(A||null))};var g=(0,n[p])(x==="accessor"?{get:m.get,set:m.set}:m[h],b);if(x==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(B=l(g.get))&&(m.get=B),(B=l(g.set))&&(m.set=B),(B=l(g.init))&&i.unshift(B)}else(B=l(g))&&(x==="field"?i.unshift(B):m[h]=B)}y&&Object.defineProperty(y,o.name,m),O=!0},"__esDecorate"),H=s(function(e,t,n){for(var o=arguments.length>2,i=0;i<t.length;i++)n=o?t[i].call(e,n):t[i].call(e);return o?n:void 0},"__runInitializers"),J=s(function(e){return typeof e=="symbol"?e:"".concat(e)},"__propKey"),Q=s(function(e,t,n){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:n?"".concat(n," ",t):t})},"__setFunctionName"),W=s(function(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)},"__metadata"),Z=s(function(e,t,n,o){function i(f){return f instanceof n?f:new n(function(l){l(f)})}return s(i,"adopt"),new(n||(n=Promise))(function(f,l){function x(m){try{y(o.next(m))}catch(B){l(B)}}s(x,"fulfilled");function h(m){try{y(o.throw(m))}catch(B){l(B)}}s(h,"rejected");function y(m){m.done?f(m.value):i(m.value).then(x,h)}s(y,"step"),y((o=o.apply(e,t||[])).next())})},"__awaiter"),Y=s(function(e,t){var n={label:0,sent:s(function(){if(f[0]&1)throw f[1];return f[1]},"sent"),trys:[],ops:[]},o,i,f,l=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return l.next=x(0),l.throw=x(1),l.return=x(2),typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function x(y){return function(m){return h([y,m])}}function h(y){if(o)throw new TypeError("Generator is already executing.");for(;l&&(l=0,y[0]&&(n=0)),n;)try{if(o=1,i&&(f=y[0]&2?i.return:y[0]?i.throw||((f=i.return)&&f.call(i),0):i.next)&&!(f=f.call(i,y[1])).done)return f;switch(i=0,f&&(y=[y[0]&2,f.value]),y[0]){case 0:case 1:f=y;break;case 4:return n.label++,{value:y[1],done:!1};case 5:n.label++,i=y[1],y=[0];continue;case 7:y=n.ops.pop(),n.trys.pop();continue;default:if(f=n.trys,!(f=f.length>0&&f[f.length-1])&&(y[0]===6||y[0]===2)){n=0;continue}if(y[0]===3&&(!f||y[1]>f[0]&&y[1]<f[3])){n.label=y[1];break}if(y[0]===6&&n.label<f[1]){n.label=f[1],f=y;break}if(f&&n.label<f[2]){n.label=f[2],n.ops.push(y);break}f[2]&&n.ops.pop(),n.trys.pop();continue}y=t.call(e,n)}catch(m){y=[6,m],i=0}finally{o=f=0}if(y[0]&5)throw y[1];return{value:y[0]?y[1]:void 0,done:!0}}},"__generator"),ee=s(function(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&U(t,e,n)},"__exportStar"),U=Object.create?(function(e,t,n,o){o===void 0&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:s(function(){return t[n]},"get")}),Object.defineProperty(e,o,i)}):(function(e,t,n,o){o===void 0&&(o=n),e[o]=t[n]}),S=s(function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],o=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:s(function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}},"next")};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},"__values"),I=s(function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var o=n.call(e),i,f=[],l;try{for(;(t===void 0||t-- >0)&&!(i=o.next()).done;)f.push(i.value)}catch(x){l={error:x}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(l)throw l.error}}return f},"__read"),te=s(function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(I(arguments[t]));return e},"__spread"),re=s(function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var o=Array(e),i=0,t=0;t<n;t++)for(var f=arguments[t],l=0,x=f.length;l<x;l++,i++)o[i]=f[l];return o},"__spreadArrays"),ne=s(function(e,t,n){if(n||arguments.length===2)for(var o=0,i=t.length,f;o<i;o++)(f||!(o in t))&&(f||(f=Array.prototype.slice.call(t,0,o)),f[o]=t[o]);return e.concat(f||Array.prototype.slice.call(t))},"__spreadArray"),F=s(function(e){return this instanceof F?(this.v=e,this):new F(e)},"__await"),oe=s(function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=n.apply(e,t||[]),i,f=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),x("next"),x("throw"),x("return",l),i[Symbol.asyncIterator]=function(){return this},i;function l(p){return function(b){return Promise.resolve(b).then(p,B)}}function x(p,b){o[p]&&(i[p]=function(w){return new Promise(function(g,A){f.push([p,w,g,A])>1||h(p,w)})},b&&(i[p]=b(i[p])))}function h(p,b){try{y(o[p](b))}catch(w){O(f[0][3],w)}}function y(p){p.value instanceof F?Promise.resolve(p.value.v).then(m,B):O(f[0][2],p)}function m(p){h("next",p)}function B(p){h("throw",p)}function O(p,b){p(b),f.shift(),f.length&&h(f[0][0],f[0][1])}},"__asyncGenerator"),ae=s(function(e){var t,n;return t={},o("next"),o("throw",function(i){throw i}),o("return"),t[Symbol.iterator]=function(){return this},t;function o(i,f){t[i]=e[i]?function(l){return(n=!n)?{value:F(e[i](l)),done:!1}:f?f(l):l}:f}},"__asyncDelegator"),se=s(function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof S=="function"?S(e):e[Symbol.iterator](),n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n);function o(f){n[f]=e[f]&&function(l){return new Promise(function(x,h){l=e[f](l),i(x,h,l.done,l.value)})}}function i(f,l,x,h){Promise.resolve(h).then(function(y){f({value:y,done:x})},l)}},"__asyncValues"),ie=s(function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e},"__makeTemplateObject");var c=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},u=s(function(e){return u=Object.getOwnPropertyNames||function(t){var n=[];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[n.length]=o);return n},u(e)},"ownKeys");fe=s(function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=u(e),o=0;o<n.length;o++)n[o]!=="default"&&U(t,e,n[o]);return c(t,e),t},"__importStar"),ce=s(function(e){return e&&e.__esModule?e:{default:e}},"__importDefault"),ue=s(function(e,t,n,o){if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?o:n==="a"?o.call(e):o?o.value:t.get(e)},"__classPrivateFieldGet"),le=s(function(e,t,n,o,i){if(o==="m")throw new TypeError("Private method is not writable");if(o==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return o==="a"?i.call(e,n):i?i.value=n:t.set(e,n),n},"__classPrivateFieldSet"),ye=s(function(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)},"__classPrivateFieldIn"),_e=s(function(e,t,n){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var o,i;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");o=t[Symbol.asyncDispose]}if(o===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");o=t[Symbol.dispose],n&&(i=o)}if(typeof o!="function")throw new TypeError("Object not disposable.");i&&(o=s(function(){try{i.call(this)}catch(f){return Promise.reject(f)}},"dispose")),e.stack.push({value:t,dispose:o,async:n})}else n&&e.stack.push({async:!0});return t},"__addDisposableResource");var _=typeof SuppressedError=="function"?SuppressedError:function(e,t,n){var o=new Error(n);return o.name="SuppressedError",o.error=e,o.suppressed=t,o};xe=s(function(e){function t(f){e.error=e.hasError?new _(f,e.error,"An error was suppressed during disposal."):f,e.hasError=!0}s(t,"fail");var n,o=0;function i(){for(;n=e.stack.pop();)try{if(!n.async&&o===1)return o=0,e.stack.push(n),Promise.resolve().then(i);if(n.dispose){var f=n.dispose.call(n.value);if(n.async)return o|=2,Promise.resolve(f).then(i,function(l){return t(l),i()})}else o|=1}catch(l){t(l)}if(o===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return s(i,"next"),i()},"__disposeResources"),pe=s(function(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(n,o,i,f,l){return o?t?".jsx":".js":i&&(!f||!l)?n:i+f+"."+l.toLowerCase()+"js"}):e},"__rewriteRelativeImportExtension"),r("__extends",k),r("__assign",K),r("__rest",z),r("__decorate",V),r("__param",q),r("__esDecorate",X),r("__runInitializers",H),r("__propKey",J),r("__setFunctionName",Q),r("__metadata",W),r("__awaiter",Z),r("__generator",Y),r("__exportStar",ee),r("__createBinding",U),r("__values",S),r("__read",I),r("__spread",te),r("__spreadArrays",re),r("__spreadArray",ne),r("__await",F),r("__asyncGenerator",oe),r("__asyncDelegator",ae),r("__asyncValues",se),r("__makeTemplateObject",ie),r("__importStar",fe),r("__importDefault",ce),r("__classPrivateFieldGet",ue),r("__classPrivateFieldSet",le),r("__classPrivateFieldIn",ye),r("__addDisposableResource",_e),r("__disposeResources",xe),r("__rewriteRelativeImportExtension",pe)})});var Be=Pe(me(),1),{__extends:Ze,__assign:Ye,__rest:et,__decorate:tt,__param:rt,__esDecorate:nt,__runInitializers:ot,__propKey:at,__setFunctionName:st,__metadata:it,__awaiter:he,__generator:be,__exportStar:ft,__createBinding:ct,__values:we,__read:ut,__spread:lt,__spreadArrays:yt,__spreadArray:_t,__await:xt,__asyncGenerator:pt,__asyncDelegator:mt,__asyncValues:Bt,__makeTemplateObject:ht,__importStar:bt,__importDefault:wt,__classPrivateFieldGet:gt,__classPrivateFieldSet:Dt,__classPrivateFieldIn:dt,__addDisposableResource:At,__disposeResources:vt,__rewriteRelativeImportExtension:Et}=Be.default;import{Buffer as ge}from"buffer";var De=s((r,a)=>{if(typeof r!="string")throw new TypeError(`The "input" argument must be of type string. Received type ${typeof r} (${r})`);return a?ge.from(r,a):ge.from(r)},"fromString");var P=s(r=>{let a=De(r,"utf8");return new Uint8Array(a.buffer,a.byteOffset,a.byteLength/Uint8Array.BYTES_PER_ELEMENT)},"fromUtf8");var Me=typeof Buffer<"u"&&Buffer.from?function(r){return Buffer.from(r,"utf8")}:P;function M(r){return r instanceof Uint8Array?r:typeof r=="string"?Me(r):ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(r)}s(M,"convertToBuffer");function G(r){return typeof r=="string"?r.length===0:r.byteLength===0}s(G,"isEmptyData");function L(r){return new Uint8Array([(r&4278190080)>>24,(r&16711680)>>16,(r&65280)>>8,r&255])}s(L,"numToUint8");function N(r){if(!Uint32Array.from){for(var a=new Uint32Array(r.length),c=0;c<r.length;)a[c]=r[c],c+=1;return a}return Uint32Array.from(r)}s(N,"uint32ArrayFrom");var Ge=(function(){function r(){this.crc32=new v}return s(r,"AwsCrc32"),r.prototype.update=function(a){G(a)||this.crc32.update(M(a))},r.prototype.digest=function(){return he(this,void 0,void 0,function(){return be(this,function(a){return[2,L(this.crc32.digest())]})})},r.prototype.reset=function(){this.crc32=new v},r})();var v=(function(){function r(){this.checksum=4294967295}return s(r,"Crc32"),r.prototype.update=function(a){var c,u;try{for(var _=we(a),e=_.next();!e.done;e=_.next()){var t=e.value;this.checksum=this.checksum>>>8^Ne[(this.checksum^t)&255]}}catch(n){c={error:n}}finally{try{e&&!e.done&&(u=_.return)&&u.call(_)}finally{if(c)throw c.error}}return this},r.prototype.digest=function(){return(this.checksum^4294967295)>>>0},r})();var Le=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],Ne=N(Le);var de={},$={};for(let r=0;r<256;r++){let a=r.toString(16).toLowerCase();a.length===1&&(a=`0${a}`),de[r]=a,$[a]=r}function Ae(r){if(r.length%2!==0)throw new Error("Hex encoded strings must have an even number length");let a=new Uint8Array(r.length/2);for(let c=0;c<r.length;c+=2){let u=r.slice(c,c+2).toLowerCase();if(u in $)a[c/2]=$[u];else throw new Error(`Cannot decode unrecognized sequence ${u} as hexadecimal`)}return a}s(Ae,"fromHex");function D(r){let a="";for(let c=0;c<r.byteLength;c++)a+=de[r[c]];return a}s(D,"toHex");var C=class r{static{s(this,"Int64")}bytes;constructor(a){if(this.bytes=a,a.byteLength!==8)throw new Error("Int64 buffers must be exactly 8 bytes")}static fromNumber(a){if(a>9223372036854776e3||a<-9223372036854776e3)throw new Error(`${a} is too large (or, if negative, too small) to represent as an Int64`);let c=new Uint8Array(8);for(let u=7,_=Math.abs(Math.round(a));u>-1&&_>0;u--,_/=256)c[u]=_;return a<0&&ve(c),new r(c)}valueOf(){let a=this.bytes.slice(0),c=a[0]&128;return c&&ve(a),parseInt(D(a),16)*(c?-1:1)}toString(){return String(this.valueOf())}};function ve(r){for(let a=0;a<8;a++)r[a]^=255;for(let a=7;a>-1&&(r[a]++,r[a]===0);a--);}s(ve,"negate");var T=class{static{s(this,"HeaderMarshaller")}toUtf8;fromUtf8;constructor(a,c){this.toUtf8=a,this.fromUtf8=c}format(a){let c=[];for(let e of Object.keys(a)){let t=this.fromUtf8(e);c.push(Uint8Array.from([t.byteLength]),t,this.formatHeaderValue(a[e]))}let u=new Uint8Array(c.reduce((e,t)=>e+t.byteLength,0)),_=0;for(let e of c)u.set(e,_),_+=e.byteLength;return u}formatHeaderValue(a){switch(a.type){case"boolean":return Uint8Array.from([a.value?0:1]);case"byte":return Uint8Array.from([2,a.value]);case"short":let c=new DataView(new ArrayBuffer(3));return c.setUint8(0,3),c.setInt16(1,a.value,!1),new Uint8Array(c.buffer);case"integer":let u=new DataView(new ArrayBuffer(5));return u.setUint8(0,4),u.setInt32(1,a.value,!1),new Uint8Array(u.buffer);case"long":let _=new Uint8Array(9);return _[0]=5,_.set(a.value.bytes,1),_;case"binary":let e=new DataView(new ArrayBuffer(3+a.value.byteLength));e.setUint8(0,6),e.setUint16(1,a.value.byteLength,!1);let t=new Uint8Array(e.buffer);return t.set(a.value,3),t;case"string":let n=this.fromUtf8(a.value),o=new DataView(new ArrayBuffer(3+n.byteLength));o.setUint8(0,7),o.setUint16(1,n.byteLength,!1);let i=new Uint8Array(o.buffer);return i.set(n,3),i;case"timestamp":let f=new Uint8Array(9);return f[0]=8,f.set(C.fromNumber(a.value.valueOf()).bytes,1),f;case"uuid":if(!He.test(a.value))throw new Error(`Invalid UUID received: ${a.value}`);let l=new Uint8Array(17);return l[0]=9,l.set(Ae(a.value.replace(/\-/g,"")),1),l}}parse(a){let c={},u=0;for(;u<a.byteLength;){let _=a.getUint8(u++),e=this.toUtf8(new Uint8Array(a.buffer,a.byteOffset+u,_));switch(u+=_,a.getUint8(u++)){case 0:c[e]={type:Fe,value:!0};break;case 1:c[e]={type:Fe,value:!1};break;case 2:c[e]={type:$e,value:a.getInt8(u++)};break;case 3:c[e]={type:Re,value:a.getInt16(u,!1)},u+=2;break;case 4:c[e]={type:ke,value:a.getInt32(u,!1)},u+=4;break;case 5:c[e]={type:Ke,value:new C(new Uint8Array(a.buffer,a.byteOffset+u,8))},u+=8;break;case 6:let t=a.getUint16(u,!1);u+=2,c[e]={type:ze,value:new Uint8Array(a.buffer,a.byteOffset+u,t)},u+=t;break;case 7:let n=a.getUint16(u,!1);u+=2,c[e]={type:Ve,value:this.toUtf8(new Uint8Array(a.buffer,a.byteOffset+u,n))},u+=n;break;case 8:c[e]={type:qe,value:new Date(new C(new Uint8Array(a.buffer,a.byteOffset+u,8)).valueOf())},u+=8;break;case 9:let o=new Uint8Array(a.buffer,a.byteOffset+u,16);u+=16,c[e]={type:Xe,value:`${D(o.subarray(0,4))}-${D(o.subarray(4,6))}-${D(o.subarray(6,8))}-${D(o.subarray(8,10))}-${D(o.subarray(10))}`};break;default:throw new Error("Unrecognized header type tag")}}return c}},Ee;(function(r){r[r.boolTrue=0]="boolTrue",r[r.boolFalse=1]="boolFalse",r[r.byte=2]="byte",r[r.short=3]="short",r[r.integer=4]="integer",r[r.long=5]="long",r[r.byteArray=6]="byteArray",r[r.string=7]="string",r[r.timestamp=8]="timestamp",r[r.uuid=9]="uuid"})(Ee||(Ee={}));var Fe="boolean",$e="byte",Re="short",ke="integer",Ke="long",ze="binary",Ve="string",qe="timestamp",Xe="uuid",He=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;var Ce=4,d=Ce*2,E=4,Je=d+E*2;function Oe({byteLength:r,byteOffset:a,buffer:c}){if(r<Je)throw new Error("Provided message too short to accommodate event stream message overhead");let u=new DataView(c,a,r),_=u.getUint32(0,!1);if(r!==_)throw new Error("Reported message length does not match received message length");let e=u.getUint32(Ce,!1),t=u.getUint32(d,!1),n=u.getUint32(r-E,!1),o=new v().update(new Uint8Array(c,a,d));if(t!==o.digest())throw new Error(`The prelude checksum specified in the message (${t}) does not match the calculated CRC32 checksum (${o.digest()})`);if(o.update(new Uint8Array(c,a+d,r-(d+E))),n!==o.digest())throw new Error(`The message checksum (${o.digest()}) did not match the expected value of ${n}`);return{headers:new DataView(c,a+d+E,e),body:new Uint8Array(c,a+d+E+e,_-e-(d+E+E))}}s(Oe,"splitMessage");var Se=class{static{s(this,"EventStreamCodec")}headerMarshaller;messageBuffer;isEndOfStream;constructor(a,c){this.headerMarshaller=new T(a,c),this.messageBuffer=[],this.isEndOfStream=!1}feed(a){this.messageBuffer.push(this.decode(a))}endOfStream(){this.isEndOfStream=!0}getMessage(){let a=this.messageBuffer.pop(),c=this.isEndOfStream;return{getMessage(){return a},isEndOfStream(){return c}}}getAvailableMessages(){let a=this.messageBuffer;this.messageBuffer=[];let c=this.isEndOfStream;return{getMessages(){return a},isEndOfStream(){return c}}}encode({headers:a,body:c}){let u=this.headerMarshaller.format(a),_=u.byteLength+c.byteLength+16,e=new Uint8Array(_),t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=new v;return t.setUint32(0,_,!1),t.setUint32(4,u.byteLength,!1),t.setUint32(8,n.update(e.subarray(0,8)).digest(),!1),e.set(u,12),e.set(c,u.byteLength+12),t.setUint32(_-4,n.update(e.subarray(8,_-4)).digest(),!1),e}decode(a){let{headers:c,body:u}=Oe(a);return{headers:this.headerMarshaller.parse(c),body:u}}formatHeaders(a){return this.headerMarshaller.format(a)}};var Ue=s(r=>typeof ArrayBuffer=="function"&&r instanceof ArrayBuffer||Object.prototype.toString.call(r)==="[object ArrayBuffer]","isArrayBuffer");import{Buffer as R}from"buffer";var je=s((r,a=0,c=r.byteLength-a)=>{if(!Ue(r))throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof r} (${r})`);return R.from(r,a,c)},"fromArrayBuffer"),Te=s((r,a)=>{if(typeof r!="string")throw new TypeError(`The "input" argument must be of type string. Received type ${typeof r} (${r})`);return a?R.from(r,a):R.from(r)},"fromString");var Kr=s(r=>{let a=Te(r,"utf8");return new Uint8Array(a.buffer,a.byteOffset,a.byteLength/Uint8Array.BYTES_PER_ELEMENT)},"fromUtf8");var Xr=s(r=>{if(typeof r=="string")return r;if(typeof r!="object"||typeof r.byteOffset!="number"||typeof r.byteLength!="number")throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");return je(r.buffer,r.byteOffset,r.byteLength).toString("utf8")},"toUtf8");export{Se as a,Kr as b,Xr as c};