thursday-agent 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +1 -0
  3. package/.next/build-manifest.json +3 -3
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/routes-manifest.json +6 -0
  6. package/.next/server/app/_global-error/page.js.nft.json +1 -1
  7. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/.next/server/app/_global-error.html +1 -1
  9. package/.next/server/app/_global-error.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  14. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/.next/server/app/_not-found.html +1 -1
  16. package/.next/server/app/_not-found.rsc +13 -13
  17. package/.next/server/app/_not-found.segments/_full.segment.rsc +13 -13
  18. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +12 -12
  19. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  20. package/.next/server/app/api/artifact/route.js +1 -1
  21. package/.next/server/app/api/artifact/route.js.nft.json +1 -1
  22. package/.next/server/app/api/bot/notes/route/app-paths-manifest.json +3 -0
  23. package/.next/server/app/api/bot/notes/route/build-manifest.json +12 -0
  24. package/.next/server/app/api/bot/notes/route/server-reference-manifest.json +4 -0
  25. package/.next/server/app/api/bot/notes/route.js +14 -0
  26. package/.next/server/app/api/bot/notes/route.js.map +5 -0
  27. package/.next/server/app/api/bot/notes/route.js.nft.json +1 -0
  28. package/.next/server/app/api/bot/notes/route_client-reference-manifest.js +3 -0
  29. package/.next/server/app/api/bot/route.js +4 -4
  30. package/.next/server/app/api/bot/route.js.nft.json +1 -1
  31. package/.next/server/app/api/bot/task/[id]/route.js +6 -6
  32. package/.next/server/app/api/bot/task/[id]/route.js.nft.json +1 -1
  33. package/.next/server/app/api/bot/task/route.js +6 -6
  34. package/.next/server/app/api/bot/task/route.js.nft.json +1 -1
  35. package/.next/server/app/api/config/route.js +3 -3
  36. package/.next/server/app/api/config/route.js.nft.json +1 -1
  37. package/.next/server/app/api/events/route.js +1 -1
  38. package/.next/server/app/api/events/route.js.nft.json +1 -1
  39. package/.next/server/app/api/file/[...path]/route.js +1 -1
  40. package/.next/server/app/api/file/[...path]/route.js.nft.json +1 -1
  41. package/.next/server/app/api/llm-model/catalog/route.js +6 -6
  42. package/.next/server/app/api/llm-model/catalog/route.js.nft.json +1 -1
  43. package/.next/server/app/api/llm-model/route.js +3 -3
  44. package/.next/server/app/api/llm-model/route.js.nft.json +1 -1
  45. package/.next/server/app/api/mcp/[name]/route.js +3 -3
  46. package/.next/server/app/api/mcp/[name]/route.js.nft.json +1 -1
  47. package/.next/server/app/api/mcp/oauth/callback/route.js +5 -5
  48. package/.next/server/app/api/mcp/oauth/callback/route.js.nft.json +1 -1
  49. package/.next/server/app/api/mcp/route.js +3 -3
  50. package/.next/server/app/api/mcp/route.js.nft.json +1 -1
  51. package/.next/server/app/api/mcp/tools/route.js +3 -3
  52. package/.next/server/app/api/mcp/tools/route.js.nft.json +1 -1
  53. package/.next/server/app/api/memory/route.js +7 -7
  54. package/.next/server/app/api/memory/route.js.nft.json +1 -1
  55. package/.next/server/app/api/memory/tidy/route.js +10 -11
  56. package/.next/server/app/api/memory/tidy/route.js.nft.json +1 -1
  57. package/.next/server/app/api/skills/[source]/[name]/route.js +1 -1
  58. package/.next/server/app/api/skills/[source]/[name]/route.js.nft.json +1 -1
  59. package/.next/server/app/api/skills/route.js +1 -1
  60. package/.next/server/app/api/skills/route.js.nft.json +1 -1
  61. package/.next/server/app/api/thursday/call/route.js +8 -8
  62. package/.next/server/app/api/thursday/call/route.js.nft.json +1 -1
  63. package/.next/server/app/api/thursday/skills/route.js +8 -8
  64. package/.next/server/app/api/thursday/skills/route.js.nft.json +1 -1
  65. package/.next/server/app/api/thursday/tool-call/route.js +11 -12
  66. package/.next/server/app/api/thursday/tool-call/route.js.nft.json +1 -1
  67. package/.next/server/app/api/workspace/route.js +1 -1
  68. package/.next/server/app/api/workspace/route.js.nft.json +1 -1
  69. package/.next/server/app/artifact/[...path]/page/server-reference-manifest.json +1 -1
  70. package/.next/server/app/artifact/[...path]/page.js +3 -3
  71. package/.next/server/app/artifact/[...path]/page.js.nft.json +1 -1
  72. package/.next/server/app/artifact/[...path]/page_client-reference-manifest.js +1 -1
  73. package/.next/server/app/favicon.ico/route.js.nft.json +1 -1
  74. package/.next/server/app/page/server-reference-manifest.json +63 -41
  75. package/.next/server/app/page.js +7 -7
  76. package/.next/server/app/page.js.nft.json +1 -1
  77. package/.next/server/app/page_client-reference-manifest.js +1 -1
  78. package/.next/server/app-paths-manifest.json +1 -0
  79. package/.next/server/chunks/0d-b_next_dist_server_app-render_after-task-async-storage_external_0-exn7p.js +3 -0
  80. package/.next/server/chunks/{[root-of-the-server]__0t_dqaj._.js → [root-of-the-server]__0-npkh_._.js} +1 -1
  81. package/.next/server/chunks/[root-of-the-server]__005var5._.js +3 -0
  82. package/.next/server/chunks/[root-of-the-server]__019dx9f._.js +2 -2
  83. package/.next/server/chunks/[root-of-the-server]__02va5wz._.js +3 -0
  84. package/.next/server/chunks/{[root-of-the-server]__1mzp_el._.js → [root-of-the-server]__04_8spk._.js} +2 -2
  85. package/.next/server/chunks/[root-of-the-server]__06t77t4._.js +1 -1
  86. package/.next/server/chunks/[root-of-the-server]__0bed6hu._.js +4 -4
  87. package/.next/server/chunks/[root-of-the-server]__0cro2dz._.js +5 -0
  88. package/.next/server/chunks/[root-of-the-server]__0emr6go._.js +3 -0
  89. package/.next/server/chunks/[root-of-the-server]__0le4d-p._.js +1 -1
  90. package/.next/server/chunks/[root-of-the-server]__0m8ywyo._.js +5 -5
  91. package/.next/server/chunks/{[root-of-the-server]__113fqg5._.js → [root-of-the-server]__0p32jfz._.js} +3 -3
  92. package/.next/server/chunks/[root-of-the-server]__0phdgco._.js +4 -4
  93. package/.next/server/chunks/[root-of-the-server]__0wvgrsl._.js +1 -1
  94. package/.next/server/chunks/[root-of-the-server]__11j52t0._.js +5 -0
  95. package/.next/server/chunks/{[root-of-the-server]__0j_n5l3._.js → [root-of-the-server]__1692zrv._.js} +2 -2
  96. package/.next/server/chunks/[root-of-the-server]__16thabu._.js +1 -1
  97. package/.next/server/chunks/[root-of-the-server]__173nhwf._.js +3 -3
  98. package/.next/server/chunks/[root-of-the-server]__1bn73ih._.js +10 -0
  99. package/.next/server/chunks/[root-of-the-server]__1bqhuh9._.js +4 -4
  100. package/.next/server/chunks/[root-of-the-server]__1ccon1w._.js +10 -0
  101. package/.next/server/chunks/[root-of-the-server]__1cqizfq._.js +1 -1
  102. package/.next/server/chunks/{[root-of-the-server]__1u_qvc7._.js → [root-of-the-server]__1fboj2j._.js} +2 -2
  103. package/.next/server/chunks/{[root-of-the-server]__1dow0bz._.js → [root-of-the-server]__1oli73c._.js} +2 -2
  104. package/.next/server/chunks/[root-of-the-server]__1txedx6._.js +4 -4
  105. package/.next/server/chunks/[root-of-the-server]__1untqv8._.js +5 -0
  106. package/.next/server/chunks/_0-73of8._.js +55 -0
  107. package/.next/server/chunks/{_2050gwn._.js → _00_584r._.js} +66 -28
  108. package/.next/server/chunks/{_0y8is-s._.js → _03a0897._.js} +1 -1
  109. package/.next/server/chunks/_05h2cii._.js +1 -1
  110. package/.next/server/chunks/_06mxlgn._.js +1 -1
  111. package/.next/server/chunks/_0a351g7._.js +1 -1
  112. package/.next/server/chunks/{_0hin38_._.js → _0khihjk._.js} +5 -5
  113. package/.next/server/chunks/_0kjjmag._.js +1 -1
  114. package/.next/server/chunks/{_1t8fv7b._.js → _0n74zsf._.js} +5 -5
  115. package/.next/server/chunks/_0nn99o2._.js +3 -0
  116. package/.next/server/chunks/_0pppbb5._.js +10 -6
  117. package/.next/server/chunks/{_1icgbi8._.js → _0rnf-6n._.js} +5 -5
  118. package/.next/server/chunks/_0u10wmw._.js +55 -0
  119. package/.next/server/chunks/{_0kl37zl._.js → _0vnutv9._.js} +1 -1
  120. package/.next/server/chunks/_0wp4le3._.js +1 -1
  121. package/.next/server/chunks/_0y5fg-x._.js +1 -1
  122. package/.next/server/chunks/_106co2o._.js +3 -0
  123. package/.next/server/chunks/_12bbv5i._.js +10 -6
  124. package/.next/server/chunks/_15hq89o._.js +1 -1
  125. package/.next/server/chunks/_15q1pig._.js +1 -1
  126. package/.next/server/chunks/_18-1wcc._.js +55 -0
  127. package/.next/server/chunks/_19wg5yn._.js +138 -0
  128. package/.next/server/chunks/_1_5mnq4._.js +18 -0
  129. package/.next/server/chunks/_1bt95p9._.js +55 -0
  130. package/.next/server/chunks/_1cbk7ms._.js +9 -9
  131. package/.next/server/chunks/_1drgfx4._.js +18 -0
  132. package/.next/server/chunks/_1drv2et._.js +10 -6
  133. package/.next/server/chunks/{_10qam6o._.js → _1e48czp._.js} +5 -5
  134. package/.next/server/chunks/{_1skgy7b._.js → _1kg70wc._.js} +5 -5
  135. package/.next/server/chunks/_1php4eq._.js +1 -1
  136. package/.next/server/chunks/_1rysr-r._.js +10 -0
  137. package/.next/server/chunks/_1u3rwbr._.js +3 -0
  138. package/.next/server/chunks/_1x7p319._.js +1 -1
  139. package/.next/server/chunks/_1yuv4vp._.js +1 -1
  140. package/.next/server/chunks/_next-internal_server_app_api_bot_notes_route_actions_0qcsyu7.js +3 -0
  141. package/.next/server/chunks/config_ts_1g4sz5o._.js +1 -1
  142. package/.next/server/chunks/features_bot_task_query_ts_11xuzl3._.js +1 -1
  143. package/.next/server/chunks/{node_modules_consola_dist_chunks_prompt_mjs_0228f43._.js → node_modules_consola_dist_chunks_prompt_mjs_02s3hjt._.js} +1 -1
  144. package/.next/server/chunks/{node_modules_consola_dist_chunks_prompt_mjs_0ir-vo2._.js → node_modules_consola_dist_chunks_prompt_mjs_06067w6._.js} +1 -1
  145. package/.next/server/chunks/{node_modules_consola_dist_chunks_prompt_mjs_0otw8ef._.js → node_modules_consola_dist_chunks_prompt_mjs_096ais_._.js} +1 -1
  146. package/.next/server/chunks/{node_modules_consola_dist_chunks_prompt_mjs_0tf290y._.js → node_modules_consola_dist_chunks_prompt_mjs_0a1rd09._.js} +1 -1
  147. package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_0gzvgfv._.js +3 -0
  148. package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_0j61-ma._.js +3 -0
  149. package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_0tvkfgh._.js +3 -0
  150. package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_11zjo-1._.js +3 -0
  151. package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_1pycqsq._.js +3 -0
  152. package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_1tpvamf._.js +3 -0
  153. package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_1y9-wcr._.js +3 -0
  154. package/.next/server/chunks/ssr/[externals]__0dizgek._.js +3 -0
  155. package/.next/server/chunks/ssr/[root-of-the-server]__0f6s48x._.js +1 -1
  156. package/.next/server/chunks/ssr/[root-of-the-server]__0m1b5ky._.js +3 -0
  157. package/.next/server/chunks/ssr/{[root-of-the-server]__0dfwvr4._.js → [root-of-the-server]__0un-erv._.js} +2 -2
  158. package/.next/server/chunks/ssr/[root-of-the-server]__1-mnhyd._.js +5 -3
  159. package/.next/server/chunks/ssr/[root-of-the-server]__1bww500._.js +3 -0
  160. package/.next/server/chunks/ssr/[root-of-the-server]__1mzi-ju._.js +1 -1
  161. package/.next/server/chunks/ssr/[root-of-the-server]__1qfqvmg._.js +3 -0
  162. package/.next/server/chunks/ssr/[root-of-the-server]__1vcdast._.js +3 -0
  163. package/.next/server/chunks/ssr/[root-of-the-server]__1xwnu-h._.js +3 -0
  164. package/.next/server/chunks/ssr/_03webdr._.js +3 -0
  165. package/.next/server/chunks/ssr/{_0gd4vaa._.js → _040sk32._.js} +71 -29
  166. package/.next/server/chunks/ssr/_077-g6s._.js +1 -1
  167. package/.next/server/chunks/ssr/{_0lc_7c8._.js → _09ja_w1._.js} +2 -2
  168. package/.next/server/chunks/ssr/{_1dcxzqe._.js → _0f_b_9s._.js} +2 -2
  169. package/.next/server/chunks/ssr/_0h7zdni._.js +1 -1
  170. package/.next/server/chunks/ssr/_0lu1n_x._.js +3 -0
  171. package/.next/server/chunks/ssr/_0sf1isi._.js +1 -1
  172. package/.next/server/chunks/ssr/_0su6_08._.js +3 -0
  173. package/.next/server/chunks/ssr/{_0nso8tp._.js → _0w5bgak._.js} +2 -2
  174. package/.next/server/chunks/ssr/{_19_o9d-._.js → _0x_nu5e._.js} +2 -2
  175. package/.next/server/chunks/ssr/_1-teee5._.js +3 -3
  176. package/.next/server/chunks/ssr/_13punpm._.js +1 -1
  177. package/.next/server/chunks/ssr/{_0ay6b01._.js → _1ciyoo3._.js} +2 -2
  178. package/.next/server/chunks/ssr/_1e-dgz0._.js +1 -1
  179. package/.next/server/chunks/ssr/_1fq7zgb._.js +1 -1
  180. package/.next/server/chunks/ssr/{_0cvjbuz._.js → _1g6l4uj._.js} +2 -2
  181. package/.next/server/chunks/ssr/{_0q_2f2x._.js → _1lip4th._.js} +2 -2
  182. package/.next/server/chunks/ssr/_1m3bsfr._.js +3 -0
  183. package/.next/server/chunks/ssr/_1mznrxk._.js +1 -1
  184. package/.next/server/chunks/ssr/_1ruzehw._.js +3 -0
  185. package/.next/server/chunks/ssr/_1vyd1ji._.js +3 -0
  186. package/.next/server/chunks/ssr/features_bot_components_bot-setting_tsx_01ajft6._.js +2 -2
  187. package/.next/server/chunks/ssr/features_config_components_14jqgy4._.js +1 -1
  188. package/.next/server/chunks/ssr/features_config_components_config-setting_tsx_0xfwqdg._.js +1 -1
  189. package/.next/server/chunks/ssr/features_connectors_components_mcp-setting_tsx_0jmbgvp._.js +1 -1
  190. package/.next/server/chunks/ssr/features_memory_components_memory-setting_tsx_0oa43sw._.js +1 -1
  191. package/.next/server/chunks/ssr/lib_realtime_12wg_dd._.js +27 -0
  192. package/.next/server/chunks/ssr/lib_realtime_15h_v1v._.js +27 -0
  193. package/.next/server/chunks/ssr/{node_modules_108wd2o._.js → node_modules_004qlr4._.js} +1 -1
  194. package/.next/server/chunks/ssr/{node_modules_1ub40gk._.js → node_modules_01qnv-a._.js} +1 -1
  195. package/.next/server/chunks/ssr/{node_modules_1y8_3vg._.js → node_modules_04n7mjs._.js} +1 -1
  196. package/.next/server/chunks/ssr/{node_modules_0_j7-g4._.js → node_modules_08d8bke._.js} +1 -1
  197. package/.next/server/chunks/ssr/{node_modules_0y2-av4._.js → node_modules_09xhur7._.js} +1 -1
  198. package/.next/server/chunks/ssr/{node_modules_043-236._.js → node_modules_0_n241r._.js} +1 -1
  199. package/.next/server/chunks/ssr/{node_modules_0ls96je._.js → node_modules_0iz1rzd._.js} +1 -1
  200. package/.next/server/chunks/ssr/{node_modules_0xwx4u-._.js → node_modules_0kl7-tn._.js} +1 -1
  201. package/.next/server/chunks/ssr/{node_modules_1jatz7w._.js → node_modules_0kxz4gt._.js} +1 -1
  202. package/.next/server/chunks/ssr/{node_modules_1t0y5jt._.js → node_modules_0lrjk5t._.js} +1 -1
  203. package/.next/server/chunks/ssr/{node_modules_13f2md6._.js → node_modules_0m93zeg._.js} +1 -1
  204. package/.next/server/chunks/ssr/{node_modules_1nhw9qg._.js → node_modules_0n1kj4p._.js} +1 -1
  205. package/.next/server/chunks/ssr/{node_modules_1k29j1j._.js → node_modules_0ndvxub._.js} +1 -1
  206. package/.next/server/chunks/ssr/{node_modules_16i4o_3._.js → node_modules_13r44jq._.js} +1 -1
  207. package/.next/server/chunks/ssr/{node_modules_0fbw5-u._.js → node_modules_17lrt3y._.js} +1 -1
  208. package/.next/server/chunks/ssr/{node_modules_1d-is1o._.js → node_modules_18_dk7_._.js} +1 -1
  209. package/.next/server/chunks/ssr/{node_modules_1hn_sd5._.js → node_modules_19dp7ko._.js} +1 -1
  210. package/.next/server/chunks/ssr/{node_modules_20ynonm._.js → node_modules_1dwguw_._.js} +1 -1
  211. package/.next/server/chunks/ssr/{node_modules_00d6675._.js → node_modules_1hd-5tv._.js} +1 -1
  212. package/.next/server/chunks/ssr/{node_modules_1ee8gav._.js → node_modules_1hn8z1f._.js} +1 -1
  213. package/.next/server/chunks/ssr/{node_modules_0bue6gy._.js → node_modules_1n5ygqe._.js} +1 -1
  214. package/.next/server/chunks/ssr/{node_modules_1_588_4._.js → node_modules_1q0p85z._.js} +1 -1
  215. package/.next/server/chunks/ssr/{node_modules_0ipn1ho._.js → node_modules_1toafc-._.js} +1 -1
  216. package/.next/server/chunks/ssr/{node_modules_0_fvxnt._.js → node_modules_1xyd7ov._.js} +1 -1
  217. package/.next/server/chunks/ssr/{node_modules_1v0077l._.js → node_modules_1zu988w._.js} +1 -1
  218. package/.next/server/chunks/ssr/{node_modules_06kvvuo._.js → node_modules_20yebtj._.js} +1 -1
  219. package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_092s8nx._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_0m9a4y0._.js} +1 -1
  220. package/.next/server/chunks/ssr/{node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_1nvexgu._.js → node_modules_@mermaid-js_parser_dist_chunks_mermaid-parser_core_13w_wy9._.js} +1 -1
  221. package/.next/server/chunks/ssr/node_modules_consola_dist_chunks_prompt_mjs_05cwqv2._.js +47 -0
  222. package/.next/server/middleware-build-manifest.js +3 -3
  223. package/.next/server/pages/404.html +1 -1
  224. package/.next/server/pages/500.html +1 -1
  225. package/.next/server/server-reference-manifest.js +1 -1
  226. package/.next/server/server-reference-manifest.json +64 -42
  227. package/.next/static/chunks/05b6nx_o3_f_n.js +1 -0
  228. package/.next/static/chunks/{3aquirz5h71da.js → 07kl352c-lvcz.js} +1 -1
  229. package/.next/static/chunks/0dmns-gi0raa4.js +1 -0
  230. package/.next/static/chunks/0oc4_xoia77dg.css +1 -0
  231. package/.next/static/chunks/0pheo8m3a-rzi.js +1 -0
  232. package/.next/static/chunks/{2ihkf6l2jowo9.js → 18vhba44l1fc9.js} +3 -3
  233. package/.next/static/chunks/19i8h2t-5evjx.js +1 -0
  234. package/.next/static/chunks/{1gy3bbv7usnjo.js → 1c5fcj473025q.js} +1 -1
  235. package/.next/static/chunks/1pi_hbmjw-f-z.js +1 -0
  236. package/.next/static/chunks/{0tydnn2kybibk.js → 1twt6k09vg4np.js} +1 -1
  237. package/.next/static/chunks/{21rk8w7bda-su.js → 28gotuisldmom.js} +1 -1
  238. package/.next/static/chunks/{3xxa2j56-f3nm.js → 2998p0y7k1c8z.js} +1 -1
  239. package/.next/static/chunks/2l233xfycjpd8.js +1 -0
  240. package/.next/static/chunks/2p5n7pa3c40t-.js +2 -0
  241. package/.next/static/chunks/2ru1q132af7h7.js +1 -0
  242. package/.next/static/chunks/{2fq_86jvq9ymq.js → 2t8wqycwg3y04.js} +2 -2
  243. package/.next/static/chunks/32z_ypgtchw48.js +1 -0
  244. package/.next/static/chunks/{247d-r95j8xs0.js → 33pyjb3xd1iez.js} +1 -1
  245. package/.next/static/chunks/3786h5vayt80-.js +28 -0
  246. package/.next/static/chunks/3_h9txt3tq8t8.js +28 -0
  247. package/.next/static/chunks/{1khakdu_iuedc.js → 3ard_noqapnw1.js} +1 -1
  248. package/.next/static/chunks/{1fr5m75pwtyic.js → 3omud5xunrk1f.js} +1 -1
  249. package/.next/static/chunks/42dnrkbph9e-1.js +1 -0
  250. package/app/api/events/app-event.client.ts +24 -0
  251. package/app/api/events/app-event.server.ts +45 -0
  252. package/app/api/events/app-event.ts +44 -0
  253. package/app/api/llm-model/catalog/route.ts +12 -0
  254. package/app/api/llm-model/route.ts +21 -0
  255. package/app/api/query-key.ts +144 -0
  256. package/app/api/thursday/tool-call/route.ts +67 -0
  257. package/components/ui/button-group.tsx +45 -0
  258. package/components/ui/custom-icon.tsx +259 -0
  259. package/components/ui/dropdown-menu.tsx +271 -0
  260. package/components/ui/folded-text.tsx +68 -0
  261. package/components/ui/input-group.tsx +157 -0
  262. package/components/ui/json-view.tsx +240 -0
  263. package/components/ui/shiny-text.tsx +141 -0
  264. package/components/ui/text-type.tsx +213 -0
  265. package/components/ui/theme-sync.tsx +9 -0
  266. package/database/migrations/{20260908030742_rainy_marvel_zombies → 20260909060813_optimal_sabretooth}/migration.sql +7 -0
  267. package/database/migrations/{20260908030742_rainy_marvel_zombies → 20260909060813_optimal_sabretooth}/snapshot.json +54 -1
  268. package/database/migrations/20260909063821_bitter_tenebrous/migration.sql +1 -0
  269. package/database/migrations/20260909063821_bitter_tenebrous/snapshot.json +1285 -0
  270. package/docs/how-it-works.md +59 -0
  271. package/docs/images/keeps-going.png +0 -0
  272. package/docs/images/task-thread.png +0 -0
  273. package/docs/images/two-minds.png +0 -0
  274. package/features/ai/load-tools.ts +55 -5
  275. package/features/ai/prompts/bot.prompt.ts +121 -26
  276. package/features/ai/prompts/memory-tidy.prompt.ts +7 -1
  277. package/features/ai/prompts/prompt-helper.ts +31 -5
  278. package/features/ai/prompts/thursday.prompt.ts +2 -0
  279. package/features/ai/tools/bot.tool.ts +37 -18
  280. package/features/ai/tools/mcp.tool.ts +5 -5
  281. package/features/ai/tools/memory.tool.ts +17 -10
  282. package/features/ai/tools/studio.tool.ts +5 -5
  283. package/features/ai/tools/tool-name.ts +2 -0
  284. package/features/ai/tools/workspace.tool.ts +33 -5
  285. package/features/bot/bot.action.ts +31 -4
  286. package/features/bot/bot.notes.ts +120 -0
  287. package/features/bot/bot.query.ts +56 -1
  288. package/features/bot/bot.run.ts +43 -3
  289. package/features/bot/bot.runner.ts +94 -20
  290. package/features/bot/bot.schema.ts +17 -0
  291. package/features/bot/components/bot-room.tsx +405 -306
  292. package/features/bot/components/bot-setting.tsx +123 -20
  293. package/features/bot/task.query.ts +18 -5
  294. package/features/memory/components/memory-setting.tsx +11 -2
  295. package/features/memory/memory.query.ts +9 -2
  296. package/features/memory/memory.schema.ts +30 -0
  297. package/features/skills/components/skills-setting.tsx +9 -1
  298. package/features/workspace/workspace.ts +136 -3
  299. package/hooks/use-draft.ts +37 -0
  300. package/hooks/use-hotkey.ts +105 -0
  301. package/hooks/use-object-state.ts +51 -0
  302. package/hooks/use-on-visible.ts +72 -0
  303. package/hooks/use-theme.ts +106 -0
  304. package/hooks/use-wake-word.ts +262 -0
  305. package/lib/realtime/realtime.driver.ts +34 -1
  306. package/lib/realtime/realtime.protocol.ts +6 -0
  307. package/lib/sandbox.ts +9 -1
  308. package/lib/tokens.ts +19 -0
  309. package/package.json +1 -1
  310. package/.next/server/chunks/[root-of-the-server]__02kt8yn._.js +0 -10
  311. package/.next/server/chunks/[root-of-the-server]__0h59di-._.js +0 -5
  312. package/.next/server/chunks/[root-of-the-server]__0qjqtwo._.js +0 -5
  313. package/.next/server/chunks/[root-of-the-server]__0yk6s3w._.js +0 -5
  314. package/.next/server/chunks/[root-of-the-server]__0z3gelv._.js +0 -3
  315. package/.next/server/chunks/[root-of-the-server]__11w_7_3._.js +0 -3
  316. package/.next/server/chunks/[root-of-the-server]__1_0q_9w._.js +0 -3
  317. package/.next/server/chunks/[root-of-the-server]__1gmn1cs._.js +0 -10
  318. package/.next/server/chunks/_0fzqt2y._.js +0 -100
  319. package/.next/server/chunks/_0jgm3b8._.js +0 -55
  320. package/.next/server/chunks/_0ks6_sg._.js +0 -55
  321. package/.next/server/chunks/_0tzfesa._.js +0 -3
  322. package/.next/server/chunks/_0zmestz._.js +0 -55
  323. package/.next/server/chunks/_12nr4xc._.js +0 -3
  324. package/.next/server/chunks/_1hzrsvg._.js +0 -55
  325. package/.next/server/chunks/_1uj4_io._.js +0 -10
  326. package/.next/server/chunks/_1yldgo4._.js +0 -55
  327. package/.next/server/chunks/features_0scmr4i._.js +0 -3
  328. package/.next/server/chunks/features_bot_bot_query_ts_12mgkl2._.js +0 -3
  329. package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_0ykklj0._.js +0 -3
  330. package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_1ryg3wh._.js +0 -3
  331. package/.next/server/chunks/node_modules_consola_dist_chunks_prompt_mjs_1vwbnq_._.js +0 -3
  332. package/.next/server/chunks/ssr/[root-of-the-server]__01id-v3._.js +0 -3
  333. package/.next/server/chunks/ssr/[root-of-the-server]__0b-0i32._.js +0 -3
  334. package/.next/server/chunks/ssr/[root-of-the-server]__185grso._.js +0 -3
  335. package/.next/server/chunks/ssr/[root-of-the-server]__1minz8_._.js +0 -3
  336. package/.next/server/chunks/ssr/_0j4v8of._.js +0 -3
  337. package/.next/server/chunks/ssr/_0l81bzy._.js +0 -3
  338. package/.next/server/chunks/ssr/_10uvw3l._.js +0 -3
  339. package/.next/server/chunks/ssr/_1jbv7m1._.js +0 -3
  340. package/.next/server/chunks/ssr/lib_realtime_0aetuyp._.js +0 -24
  341. package/.next/server/chunks/ssr/lib_realtime_18k_aj-._.js +0 -24
  342. package/.next/server/chunks/ssr/node_modules_zod_v4_classic_errors_05xv7vp.js +0 -3
  343. package/.next/static/chunks/0yysv1gzin17t.js +0 -1
  344. package/.next/static/chunks/1keib_gt066gc.js +0 -1
  345. package/.next/static/chunks/28g42tw8tsvhd.js +0 -1
  346. package/.next/static/chunks/2cwjgkt_hoyhj.js +0 -22
  347. package/.next/static/chunks/2rbf1fpd8n80-.js +0 -22
  348. package/.next/static/chunks/2ukj8k69y89um.js +0 -1
  349. package/.next/static/chunks/2wngeetfnzxkp.js +0 -2
  350. package/.next/static/chunks/388-t2v72jh39.css +0 -1
  351. package/.next/static/chunks/3fqvc0cg-atq_.js +0 -1
  352. package/.next/static/chunks/3p4egvfjxpatb.js +0 -1
  353. package/.next/static/chunks/3qe1w1ei-huhl.js +0 -1
  354. package/.next/static/chunks/3y40riycdip-i.js +0 -1
  355. package/.next/static/chunks/45a6zbtkelph9.js +0 -1
  356. /package/.next/static/{X34BUd9bfdH27ripuwwBm → YR4NWcDDuzwLbTTU7U7Vr}/_buildManifest.js +0 -0
  357. /package/.next/static/{X34BUd9bfdH27ripuwwBm → YR4NWcDDuzwLbTTU7U7Vr}/_clientMiddlewareManifest.js +0 -0
  358. /package/.next/static/{X34BUd9bfdH27ripuwwBm → YR4NWcDDuzwLbTTU7U7Vr}/_ssgManifest.js +0 -0
@@ -1,15 +1,13 @@
1
- module.exports=[159479,e=>e.a(async(t,a)=>{try{var o=e.i(847841),r=e.i(983477),n=e.i(54282),i=e.i(316172),l=e.i(349047),s=e.i(926435),u=e.i(770639),d=e.i(489956),p=e.i(41181),c=e.i(752774),m=e.i(353885),f=e.i(123203),h=e.i(944971),v=e.i(619898),g=e.i(636882),y=e.i(22676),w=e.i(786025),b=e.i(704161),x=e.i(41444),T=e.i(386075),M=t([s,u,v,y,T]);async function I(t){let{listTaskHistory:a}=await e.A(353587),o=await a({limit:5});if(!o.length)return"No jobs have been handed over yet.";let r=o.map(e=>`"${e.label}" (${e.bot}, ${e.status})`).join(", ");return`There is no job called "${t}". The latest are: ${r}. Call again with one of those names.`}async function S(t){let a=(0,u.createMemoryTools)();if("tidy"===t.target){let{[m.TOOL_NAMES.memory_show]:e,...t}=a;return{...t,[m.TOOL_NAMES.tidy_done]:c.tidyDoneTool}}let M=await (0,w.openWorkspace)();if("thursday"===t.target){var S;let{[m.TOOL_NAMES.memory_show]:s,...u}=a,{crowded:d,heavy:c}=(0,n.tidying)(await (0,v.listNoteIndex)()),w=await (0,y.readCallSkillsOn)()?(0,p.createSkillTools)({sandbox:M,skills:await (0,g.loadSkills)(M)}):{};return{...u,...d||c.length?{[m.TOOL_NAMES.memory_show]:s}:{},...w,...(0,f.createWorkspaceTools)(M,{write:!1}),...(S=t.callId,{[m.TOOL_NAMES.delegate]:(0,o.tool)({description:i.delegateSpec.description,inputSchema:i.delegateSpec.parameters,execute:async({bot:t,request:a,label:o})=>{let{findJobBot:r,listJobBots:n}=await e.A(814317),i=await r(t);if(!i){let e=(await n()).map(e=>e.name);return`There is no bot called "${t}". The bots are: ${e.join(", ")}. Nothing was handed over — call again with one of those.`}let{startTask:l}=await e.A(994193);return{taskId:await l({bot:i.name,request:a,label:o,callId:S}),note:`${i.name} has "${o}". Say so and keep talking — the result is put in front of you later. Everything further about it — an answer, a correction, carrying it on after it reports — is \`${m.TOOL_NAMES.task}\` with "${o}".`}}}),[m.TOOL_NAMES.task]:(0,o.tool)({description:i.taskSpec.description,inputSchema:i.taskSpec.parameters,execute:async({action:t,task:a,answer:o})=>{let{listTaskHistory:n,resolveTask:i}=await e.A(353587);if("status"===t){let e=o?.trim()?{note:"The text in `answer` was not passed on — `status` only reads. Send it again as `answer` if the bot is meant to hear it."}:{};if(a){let t=await i(a);return t?{...e,label:t.label,bot:t.bot,status:t.status,since:(0,r.formatDistanceToNowStrict)((0,b.toDate)(t.updatedAt),{addSuffix:!0}),outcome:t.outcome,..."waiting"===t.status&&t.pending?.options.length?{options:t.pending.options}:{}}:await I(a)}let t=await n({limit:8});return{...e,tasks:t.map(e=>({label:e.label,bot:e.bot,status:e.status,since:(0,r.formatDistanceToNowStrict)((0,b.toDate)(e.updatedAt),{addSuffix:!0}),...e.ask?{asking:e.ask.question,options:e.ask.options}:{},..."running"===e.status?{now:(0,h.taskActivity)(e.lines)}:{},...e.outcome&&"waiting"!==e.status?{outcome:(0,x.clip)(e.outcome,200)}:{}}))}}if(!a)return"Say which job — by its label. Call `status` with no job named to see them.";let l=await i(a);if(!l)return await I(a);let{answerTask:s,cancelTask:u}=await e.A(994193);return"cancel"===t?(await u(l.id),{label:l.label,status:"cancelled"}):o?.trim()?(await s(l.id,o.trim()),{label:l.label,status:"running",note:"running"===l.status?"The bot reads it before its next step.":"The bot picks the job back up from there."}):"Say what to pass on."}})}),...l.CALL_TOOLS}}let E=await (0,g.loadSkills)(M);return{[m.TOOL_NAMES.memory_recall]:a[m.TOOL_NAMES.memory_recall],[m.TOOL_NAMES.memory_remember]:u.botRememberTool,...(0,d.createSearchTool)(await (0,T.resolveSearchModel)(t.model),M),...(0,f.createWorkspaceTools)(M,{write:!0,env:(0,w.jobShellEnv)(t.taskId)}),...await (0,s.createMcpTools)(t.bot,M),...(0,p.createSkillTools)({sandbox:M,skills:E}),[m.TOOL_NAMES.ask_thursday]:i.askThursdayTool,[m.TOOL_NAMES.report]:i.reportTool}}[s,u,v,y,T]=M.then?(await M)():M,e.s(["loadTools",0,S]),a()}catch(e){a(e)}},!1),54282,e=>{"use strict";var t=e.i(343747),a=e.i(687388),o=e.i(453569),r=e.i(704161),n=e.i(388439);function i(e,t=!1){return e.length?e.map(e=>{var a;let o,n=e.aliases?.length?` ${e.aliases.map(e=>`"${e}"`).join(" ")}`:"",i=t?` \xb7 ${a=e.lastSeenAt,(o=Math.floor((Date.now()-(0,r.toDate)(a).getTime())/864e5))>=365?`${Math.floor(o/365)}y`:o>=30?`${Math.floor(o/30)}mo`:`${Math.max(o,0)}d`}`:"";return`- ${e.path} — ${e.description?.trim()} (${e.factCount})${n}${i}`}).join("\n"):"(nothing saved yet)"}e.s(["carriedLines",0,e=>e.map(e=>`- ${e.text} \xb7 ${e.path} #${e.id}`).join("\n"),"mcpToolLines",0,function(e){let t=new Map;for(let a of e){let e=t.get(a.server);e?e.push(a.name):t.set(a.server,[a.name])}return[...t].map(([e,t])=>`- **${e}**: ${t.join(", ")}`).join("\n")},"noteLines",0,i,"nowLine",0,(e=new Date)=>`**Now**: ${(0,t.format)(e,"yyyy-MM-dd (EEE) HH:mm")} ${Intl.DateTimeFormat().resolvedOptions().timeZone}`,"skillLines",0,(e,t={})=>e.map(e=>{var o;let r,n;return`- **${e.name}**: ${t.short?(o=e.description,r=a.PROMPT_LINE.skill,(n=o.trim().split(/(?<=[.。])\s|\n/)[0].trim()).length>r?`${n.slice(0,r).trim()}…`:n):e.description}`}).join("\n"),"tidying",0,e=>({crowded:(0,n.estimateTokens)(i(e))>a.MEMORY_LISTING_TOKENS,heavy:e.filter(e=>e.factCount>o.MANY_FACTS)})])},349047,e=>{"use strict";var t=e.i(847841),a=e.i(907855),o=e.i(353885);let r={name:o.TOOL_NAMES.end_call,description:`End the call.
1
+ module.exports=[159479,e=>e.a(async(t,a)=>{try{var o=e.i(847841),r=e.i(983477),n=e.i(687388),i=e.i(54282),l=e.i(316172),s=e.i(349047),u=e.i(926435),d=e.i(770639),p=e.i(489956),c=e.i(41181),m=e.i(752774),f=e.i(353885),h=e.i(123203),v=e.i(265143),g=e.i(944971),y=e.i(619898),w=e.i(636882),b=e.i(22676),x=e.i(786025),T=e.i(704161),M=e.i(640911),I=e.i(388439),S=e.i(41444),E=e.i(386075),k=t([u,d,v,y,b,E]);async function C(t){let{listTaskHistory:a}=await e.A(353587),o=await a({limit:5});if(!o.length)return"No jobs have been handed over yet.";let r=o.map(e=>`"${e.label}" (${e.bot}, ${e.status})`).join(", ");return`There is no job called "${t}". The latest are: ${r}. Call again with one of those names.`}async function O(e,t){let a=[];for(let[e,r]of Object.entries(t)){let t=await (0,o.asSchema)(r.inputSchema).jsonSchema,n="string"==typeof r.description?r.description:"";a.push({name:e,tokens:(0,I.estimateTokens)(n)+(0,I.estimateTokens)(JSON.stringify(t))})}a.sort((e,t)=>t.tokens-e.tokens);let r=a.reduce((e,t)=>e+t.tokens,0);M.logger.debug(`${e} tools ${r} tokens over ${a.length} — ${a.map(e=>`${e.name} ${e.tokens}`).join(", ")}`)}async function A(e){let t=await N(e);return n.IS_DEV&&await O(e.target,t),t}async function N(t){let a=(0,d.createMemoryTools)("tidy"===t.target?"tidy":"call");if("tidy"===t.target){let{[f.TOOL_NAMES.memory_show]:e,...t}=a;return{...t,[f.TOOL_NAMES.tidy_done]:m.tidyDoneTool}}let n=await (0,x.openWorkspace)();if("thursday"===t.target){var M;let{[f.TOOL_NAMES.memory_show]:u,...d}=a,{crowded:p,heavy:m}=(0,i.tidying)(await (0,y.listNoteIndex)()),v=await (0,b.readCallSkillsOn)()?(0,c.createSkillTools)({sandbox:n,skills:await (0,w.loadSkills)(n)}):{};return{...d,...p||m.length?{[f.TOOL_NAMES.memory_show]:u}:{},...v,...(0,h.createWorkspaceTools)(n,{write:!1}),...(M=t.callId,{[f.TOOL_NAMES.delegate]:(0,o.tool)({description:l.delegateSpec.description,inputSchema:l.delegateSpec.parameters,execute:async({bot:t,request:a,label:o})=>{let{findJobBot:r,listJobBots:n}=await e.A(814317),i=await r(t);if(!i){let e=(await n()).map(e=>e.name);return`There is no bot called "${t}". The bots are: ${e.join(", ")}. Nothing was handed over — call again with one of those.`}let{startTask:l}=await e.A(994193);return{taskId:await l({bot:i.name,request:a,label:o,callId:M}),note:`${i.name} has "${o}". Say so and keep talking — the result is put in front of you later. Everything further about it — an answer, a correction, carrying it on after it reports — is \`${f.TOOL_NAMES.task}\` with "${o}".`}}}),[f.TOOL_NAMES.task]:(0,o.tool)({description:l.taskSpec.description,inputSchema:l.taskSpec.parameters,execute:async({action:t,task:a,answer:o})=>{let{listTaskHistory:n,resolveTask:l}=await e.A(353587);if("status"===t){let e=o?.trim()?{note:"The text in `answer` was not passed on — `status` only reads. Send it again as `answer` if the bot is meant to hear it."}:{},t={now:(0,i.clockNow)()};if(a){let o=await l(a);return o?{...t,...e,label:o.label,bot:o.bot,status:o.status,since:(0,r.formatDistanceToNowStrict)((0,T.toDate)(o.updatedAt),{addSuffix:!0}),outcome:o.outcome,..."waiting"===o.status&&o.pending?.options.length?{options:o.pending.options}:{}}:await C(a)}let s=await n({limit:8});return{...t,...e,tasks:s.map(e=>({label:e.label,bot:e.bot,status:e.status,since:(0,r.formatDistanceToNowStrict)((0,T.toDate)(e.updatedAt),{addSuffix:!0}),...e.ask?{asking:e.ask.question,options:e.ask.options}:{},..."running"===e.status?{now:(0,g.taskActivity)(e.lines)}:{},...e.outcome&&"waiting"!==e.status?{outcome:(0,S.clip)(e.outcome,200)}:{}}))}}if(!a)return"Say which job — by its label. Call `status` with no job named to see them.";let s=await l(a);if(!s)return await C(a);let{answerTask:u,cancelTask:d}=await e.A(994193);return"cancel"===t?(await d(s.id),{label:s.label,status:"cancelled"}):o?.trim()?(await u(s.id,o.trim()),{label:s.label,status:"running",note:"running"===s.status?"The bot reads it before its next step.":"The bot picks the job back up from there."}):"Say what to pass on."}})}),...s.CALL_TOOLS}}let I=await (0,w.loadSkills)(n);return{[f.TOOL_NAMES.memory_recall]:a[f.TOOL_NAMES.memory_recall],[f.TOOL_NAMES.memory_remember]:d.botRememberTool,...(0,p.createSearchTool)(await (0,E.resolveSearchModel)(t.model),n),...(0,h.createWorkspaceTools)(n,{write:!0,env:(0,x.jobShellEnv)(t.taskId),guide:!0}),...await (0,u.createMcpTools)(t.bot,n),...(0,c.createSkillTools)({sandbox:n,skills:I}),[f.TOOL_NAMES.ask_thursday]:l.askThursdayTool,[f.TOOL_NAMES.report]:(0,l.createReportTool)(await (0,v.readBotNotesOn)())}}[u,d,v,y,b,E]=k.then?(await k)():k,e.s(["loadTools",0,A]),a()}catch(e){a(e)}},!1),54282,e=>{"use strict";var t=e.i(343747),a=e.i(687388),o=e.i(453569),r=e.i(704161),n=e.i(640911),i=e.i(388439);let l=(e=new Date)=>`${(0,t.format)(e,"yyyy-MM-dd (EEE) HH:mm")} ${Intl.DateTimeFormat().resolvedOptions().timeZone}`;function s(e,t=!1){return e.length?e.map(e=>{var a;let o,n=e.aliases?.length?` ${e.aliases.map(e=>`"${e}"`).join(" ")}`:"",i=t?` \xb7 ${a=e.lastSeenAt,(o=Math.floor((Date.now()-(0,r.toDate)(a).getTime())/864e5))>=365?`${Math.floor(o/365)}y`:o>=30?`${Math.floor(o/30)}mo`:`${Math.max(o,0)}d`}`:"";return`- ${e.path} — ${e.description?.trim()} (${e.factCount})${n}${i}`}).join("\n"):"(nothing saved yet)"}e.s(["carriedLines",0,e=>e.map(e=>`- ${e.text} \xb7 ${e.path} #${e.id}`).join("\n"),"clockNow",0,l,"logPromptSize",0,function(e,t){let o=(0,i.sectionTokens)(t),r=o.reduce((e,t)=>e+t.tokens,0);n.logger.debug(`${e} prompt ${r} tokens — ${o.map(e=>`${e.name} ${e.tokens}`).join(", ")}`);let l=o[0];r>a.PROMPT_BUDGET&&l&&n.logger.warn(`${e} prompt is ${r} tokens, over ${a.PROMPT_BUDGET}: ${l.name} carries ${l.tokens} of it. Every call and every job pays this.`)},"mcpToolLines",0,function(e){let t=new Map;for(let a of e){let e=t.get(a.server);e?e.push(a.name):t.set(a.server,[a.name])}return[...t].map(([e,t])=>`- **${e}**: ${t.join(", ")}`).join("\n")},"noteLines",0,s,"nowLine",0,(e=new Date)=>`**Now**: ${l(e)}`,"skillLines",0,(e,t={})=>e.map(e=>{var o;let r,n;return`- **${e.name}**: ${t.short?(o=e.description,r=a.PROMPT_LINE.skill,(n=o.trim().split(/(?<=[.。])\s|\n/)[0].trim()).length>r?`${n.slice(0,r).trim()}…`:n):e.description}`}).join("\n"),"tidying",0,e=>({crowded:(0,i.estimateTokens)(s(e))>a.MEMORY_LISTING_TOKENS,heavy:e.filter(e=>e.factCount>o.MANY_FACTS)})])},349047,e=>{"use strict";var t=e.i(847841),a=e.i(907855),o=e.i(353885);let r={name:o.TOOL_NAMES.end_call,description:`End the call.
2
2
 
3
- Say goodbye first — nothing said after this reaches the user.`,parameters:a.object({})},n=(0,t.tool)({description:r.description,inputSchema:r.parameters}),i={[o.TOOL_NAMES.end_call]:n};e.s(["CALL_TOOLS",0,i])},926435,e=>e.a(async(t,a)=>{try{var o=e.i(847841),r=e.i(907855),n=e.i(353885),i=e.i(148831),l=e.i(660948),s=t([i,l]);[i,l]=s.then?(await s)():s;let p={[n.TOOL_NAMES.tool_search]:{name:n.TOOL_NAMES.tool_search,description:`Fetch what a connected server's tools take, so they can be called.
4
-
5
- The Connected tools section names every server and every tool on it, and that is all it names: there is no description and no parameter schema, so a tool cannot be invoked from that list alone. Name a server and the tools on it, and this returns each one's description and its exact inputSchema. Then run one with \`${n.TOOL_NAMES.tool_call}\`.`,parameters:r.object({server:r.string().describe("A server name, exactly as the Connected tools section writes it."),tools:r.string().array().describe("Tool names listed under that server. Only the ones you may actually call — schemas are large, and at most 8 come back.")})},[n.TOOL_NAMES.tool_call]:{name:n.TOOL_NAMES.tool_call,description:`Run one tool whose definition came back from \`${n.TOOL_NAMES.tool_search}\`.`,parameters:r.object({server:r.string().describe("The server the tool lives on."),tool:r.string().describe("Its name, as search returned it."),args:r.record(r.string(),r.unknown()).nullable().describe("Arguments matching the inputSchema search returned — do not guess. Null when it takes none."),description:r.string().nullable().describe("One short line for the user: what this call is for. Shown on their screen while it runs.")})}},c=(e,t)=>`${e.replace(/[^a-zA-Z0-9]+/g,"_")}__${t.replace(/[^a-zA-Z0-9_-]+/g,"_")}`.slice(0,64);async function u(e,t){let[a,r]=await Promise.all([(0,l.listConnectedToolNames)(),(0,i.findPinnedTools)(e)]),n={};for(let e of r){let a=c(e.server,e.name);n[a]||(n[a]=(0,o.tool)({description:e.description??`${e.name} on the ${e.server} server.`,inputSchema:(0,o.jsonSchema)(e.inputSchema??{type:"object",properties:{}}),execute:(a,{abortSignal:o})=>(0,l.callConnectedTool)(t,e.server,e.name,a??void 0,o)}))}return a.length>r.length&&Object.assign(n,m(t)),n}async function d(e){let t=(await (0,l.listConnectedToolNames)(e)).map(e=>e.name);if(t.length)return`Tools on "${e}": ${t.join(", ")}.`;let a=await (0,l.listConnectedServerNames)();return a.length?`There is no server called "${e}". Connected: ${a.join(", ")}.`:"Nothing is connected."}let m=e=>({[n.TOOL_NAMES.tool_search]:(0,o.tool)({description:p[n.TOOL_NAMES.tool_search].description,inputSchema:p[n.TOOL_NAMES.tool_search].parameters,execute:async({server:e,tools:t})=>{let a=[...new Set(t.map(e=>e.trim()).filter(Boolean))],o=a.slice(0,8),r=await (0,l.findConnectedSchemas)(e.trim(),o);if(!r.length)return{tools:[],note:await d(e)};let n=o.filter(e=>!r.some(t=>t.name===e)),i=a.slice(8),s=[n.length?`Not on "${e}": ${n.join(", ")}.`:"",i.length?`Only 8 at a time — ask again for: ${i.join(", ")}.`:""].filter(Boolean);return{tools:r,...s.length?{note:s.join(" ")}:{}}}}),[n.TOOL_NAMES.tool_call]:(0,o.tool)({description:p[n.TOOL_NAMES.tool_call].description,inputSchema:p[n.TOOL_NAMES.tool_call].parameters,execute:async({server:t,tool:a,args:o},{abortSignal:r})=>(await (0,l.listConnectedToolNames)(t.trim())).some(e=>e.name===a.trim())?(0,l.callConnectedTool)(e,t.trim(),a.trim(),o??void 0,r):{status:"error",text:await d(t)}})});e.s(["createMcpTools",0,u]),a()}catch(e){a(e)}},!1),770639,e=>e.a(async(t,a)=>{try{var o=e.i(847841),r=e.i(907855),n=e.i(380690),i=e.i(353885),l=e.i(619898),s=e.i(453569),u=t([l]);[l]=u.then?(await u)():u;let d="Deleted for good. The listing in your instructions is from when this session opened and still shows it that way until the next one.",p=(0,o.tool)({description:"Save a lasting fact about the user. Only for what outlives this job; what the job itself turned up goes in the report.",inputSchema:r.object({path:r.string().describe("Exactly as the listing writes it, or a new path following the same convention."),facts:r.string().array().describe("One statement each, standing on its own later.")}),execute:async({path:e,facts:t})=>{let a=e.trim(),o=t.map(e=>e.trim()).filter(Boolean);if(!o.length)return{note:"Nothing to write: send a fact."};let r=await (0,l.resolveNotePath)(a),n=r||(0,s.isMemoryPath)(a)?r??a:s.MEMORY_INBOX;return await (0,l.writeNotes)([{path:n,facts:o.map(e=>({text:e}))}]),{note:n===a?`Saved to ${n}.`:`Saved to ${n}: "${a}" is not a path this listing can carry.`}}});e.s(["botRememberTool",0,p,"createMemoryTools",0,()=>({[i.TOOL_NAMES.memory_recall]:(0,o.tool)({description:"Open one note from the listing, whole.",inputSchema:r.object({path:r.string().describe("Exactly as the listing writes it — the path, or one of the names in quotes after it.")}),execute:async({path:e})=>{let t,a,{notes:o}=await (0,l.readNotes)([e]),r=o[0];return r?r.facts.length>s.MANY_FACTS?{...r,note:(t=r.path,a=r.facts.length,` ${t} carries ${a} facts — enough that it is worth tidying. Put it on screen with \`${i.TOOL_NAMES.memory_show}\` and ask which of it they no longer need.`).trim()}:r:{note:`Nothing on the listing called ${e.trim()}.`}}}),[i.TOOL_NAMES.memory_remember]:(0,o.tool)({description:"Write to one note: facts, and the line the listing shows for it. The path is the key — a path not on the listing is created (with at least one fact), one that is gets amended.",inputSchema:r.object({path:r.string().describe("Exactly as the listing writes it, or a new path following the same convention."),facts:r.object({text:r.string().describe("One statement that stands on its own later."),replaces:r.number().int().nullable().describe("The id of the fact this replaces — from this note as handed back here or by `memory_recall`. Null if this is new. A fact that stopped being true is replaced rather than deleted, and so is a note saying the same thing twice: replacing keeps what changed on the record, deleting does not."),alwaysLoad:r.boolean().nullable().describe(`True carries this line into every call's instructions without opening its note — for what to call them, their language and register, a standing rule. At most ${s.ALWAYS_LOADED_MAX}. Null leaves it; false makes a carried line an ordinary fact.`)}).array().nullable().describe("What to write under this note. Send everything that came up at once: one call is one pause in the conversation, three calls are three. Null when only naming it."),description:r.string().nullable().describe(`One line saying what this note is about, not what it currently says. Give it for a new note, or when the line no longer fits. Null leaves it; ${s.MEMORY_ALWAYS_LISTED.join(" and ")} keep their own line.`),aliases:r.string().array().nullable().describe('What the user calls this note out loud, in the language they say it — the words they would use to ask for it, not the facts inside. A note at people/yuri might be "Yuri" and "my wife". Replaces the set it has, so send the whole set. Null leaves it.')}),execute:async e=>{let t=e.path.trim(),a=await (0,l.resolveNotePath)(t),o=e.aliases??null,r=(0,s.isAlwaysListed)(a??t)?null:e.description?.trim()||null,n=e.facts??[];if(!n.length&&!r&&!o)return{note:"Nothing to write: send facts, a line, names, or any of them."};if(!a&&!n.length)return{note:`Nothing on the listing called ${t}. A note comes into being with a fact — send at least one.`};let i=a||(0,s.isMemoryPath)(t)?{path:a??t,description:r,aliases:o,facts:n}:{path:s.MEMORY_INBOX,description:"Facts with nowhere obvious to go",facts:n},u=await (0,l.writeNotes)([i]),d=i.path!==t?` Filed under ${i.path}: "${t}" is not a path this listing can carry. If that is not where it belongs, write it again under one that is.`:"",p=u.unnamed.length?` ${u.unnamed[0]} is new and has no line yet — the listing shows its first fact instead. Call again with \`description\` (one line about what it is) and \`aliases\` (the names they say for it).`:"",c=u.notLoaded.length?` All ${s.ALWAYS_LOADED_MAX} carried lines are taken, so ${u.notLoaded.map(e=>`"${e}"`).join(", ")} saved as an ordinary fact. Say which carried line you would drop for it and let them choose.`:"";return{...u.notes[0],note:`Saved. The listing in your instructions is from when this session opened and will not show this until the next one — the note below is current.${d}${p}${c}`}}}),[i.TOOL_NAMES.memory_show]:(0,o.tool)({description:`Put a note on the user's screen so they can see it while you
3
+ Say goodbye first — nothing said after this reaches the user.`,parameters:a.object({})},n=(0,t.tool)({description:r.description,inputSchema:r.parameters}),i={[o.TOOL_NAMES.end_call]:n};e.s(["CALL_TOOLS",0,i])},926435,e=>e.a(async(t,a)=>{try{var o=e.i(847841),r=e.i(907855),n=e.i(353885),i=e.i(148831),l=e.i(660948),s=t([i,l]);[i,l]=s.then?(await s)():s;let p={[n.TOOL_NAMES.tool_search]:{name:n.TOOL_NAMES.tool_search,description:`Return the description and exact inputSchema of tools on a connected server, so they can be called with \`${n.TOOL_NAMES.tool_call}\`.`,parameters:r.object({server:r.string().describe("A server name, exactly as the Connected tools section writes it."),tools:r.string().array().describe("Tool names listed under that server. Only the ones you may actually call — schemas are large, and at most 8 come back.")})},[n.TOOL_NAMES.tool_call]:{name:n.TOOL_NAMES.tool_call,description:`Run one tool whose definition came back from \`${n.TOOL_NAMES.tool_search}\`.`,parameters:r.object({server:r.string().describe("The server the tool lives on."),tool:r.string().describe("Its name, as search returned it."),args:r.record(r.string(),r.unknown()).nullish().describe("Arguments matching the inputSchema search returned — do not guess. Null when it takes none."),description:r.string().nullish().describe("One short line for the user: what this call is for. Shown on their screen while it runs.")})}},c=(e,t)=>`${e.replace(/[^a-zA-Z0-9]+/g,"_")}__${t.replace(/[^a-zA-Z0-9_-]+/g,"_")}`.slice(0,64);async function u(e,t){let[a,r]=await Promise.all([(0,l.listConnectedToolNames)(),(0,i.findPinnedTools)(e)]),n={};for(let e of r){let a=c(e.server,e.name);n[a]||(n[a]=(0,o.tool)({description:e.description??`${e.name} on the ${e.server} server.`,inputSchema:(0,o.jsonSchema)(e.inputSchema??{type:"object",properties:{}}),execute:(a,{abortSignal:o})=>(0,l.callConnectedTool)(t,e.server,e.name,a??void 0,o)}))}return a.length>r.length&&Object.assign(n,m(t)),n}async function d(e){let t=(await (0,l.listConnectedToolNames)(e)).map(e=>e.name);if(t.length)return`Tools on "${e}": ${t.join(", ")}.`;let a=await (0,l.listConnectedServerNames)();return a.length?`There is no server called "${e}". Connected: ${a.join(", ")}.`:"Nothing is connected."}let m=e=>({[n.TOOL_NAMES.tool_search]:(0,o.tool)({description:p[n.TOOL_NAMES.tool_search].description,inputSchema:p[n.TOOL_NAMES.tool_search].parameters,execute:async({server:e,tools:t})=>{let a=[...new Set(t.map(e=>e.trim()).filter(Boolean))],o=a.slice(0,8),r=await (0,l.findConnectedSchemas)(e.trim(),o);if(!r.length)return{tools:[],note:await d(e)};let n=o.filter(e=>!r.some(t=>t.name===e)),i=a.slice(8),s=[n.length?`Not on "${e}": ${n.join(", ")}.`:"",i.length?`Only 8 at a time — ask again for: ${i.join(", ")}.`:""].filter(Boolean);return{tools:r,...s.length?{note:s.join(" ")}:{}}}}),[n.TOOL_NAMES.tool_call]:(0,o.tool)({description:p[n.TOOL_NAMES.tool_call].description,inputSchema:p[n.TOOL_NAMES.tool_call].parameters,execute:async({server:t,tool:a,args:o},{abortSignal:r})=>(await (0,l.listConnectedToolNames)(t.trim())).some(e=>e.name===a.trim())?(0,l.callConnectedTool)(e,t.trim(),a.trim(),o??void 0,r):{status:"error",text:await d(t)}})});e.s(["createMcpTools",0,u]),a()}catch(e){a(e)}},!1),770639,e=>e.a(async(t,a)=>{try{var o=e.i(847841),r=e.i(907855),n=e.i(380690),i=e.i(353885),l=e.i(619898),s=e.i(453569),u=t([l]);[l]=u.then?(await u)():u;let d="Deleted for good. The listing in your instructions is from when this session opened and still shows it that way until the next one.",p=(0,o.tool)({description:"Save a lasting fact about the user. Only for what outlives this job; what the job itself turned up goes in the report.",inputSchema:r.object({path:r.string().describe("Exactly as the listing writes it, or a new path following the same convention."),facts:r.string().array().describe("One statement each, standing on its own later.")}),execute:async({path:e,facts:t})=>{let a=e.trim(),o=t.map(e=>e.trim()).filter(Boolean);if(!o.length)return{note:"Nothing to write: send a fact."};let r=await (0,l.resolveNotePath)(a),n=r||(0,s.isMemoryPath)(a)?r??a:s.MEMORY_INBOX;return await (0,l.writeNotes)([{path:n,facts:o.map(e=>({text:e}))}],"bot"),{note:n===a?`Saved to ${n}.`:`Saved to ${n}: "${a}" is not a path this listing can carry.`}}});e.s(["botRememberTool",0,p,"createMemoryTools",0,e=>({[i.TOOL_NAMES.memory_recall]:(0,o.tool)({description:"Open one note from the listing, whole.",inputSchema:r.object({path:r.string().describe("Exactly as the listing writes it — the path, or one of the names in quotes after it.")}),execute:async({path:e})=>{let t,a,{notes:o}=await (0,l.readNotes)([e]),r=o[0];return r?r.facts.length>s.MANY_FACTS?{...r,note:(t=r.path,a=r.facts.length,` ${t} carries ${a} facts — enough that it is worth tidying. Put it on screen with \`${i.TOOL_NAMES.memory_show}\` and ask which of it they no longer need.`).trim()}:r:{note:`Nothing on the listing called ${e.trim()}.`}}}),[i.TOOL_NAMES.memory_remember]:(0,o.tool)({description:"Write to one note: facts, and the line the listing shows for it. The path is the key — a path not on the listing is created (with at least one fact), one that is gets amended.",inputSchema:r.object({path:r.string().describe("Exactly as the listing writes it, or a new path following the same convention."),facts:r.object({text:r.string().describe("One statement that stands on its own later."),replaces:r.number().int().nullish().describe("The id of the fact this replaces — from this note as handed back here or by `memory_recall`. Null if this is new. A fact that stopped being true is replaced rather than deleted, and so is a note saying the same thing twice: replacing keeps what changed on the record, deleting does not."),alwaysLoad:r.boolean().nullish().describe(`True carries this line into every call's instructions without opening its note — for what to call them, their language and register, a standing rule. At most ${s.ALWAYS_LOADED_MAX}. Null leaves it; false makes a carried line an ordinary fact.`)}).array().nullish().describe("What to write under this note. Send everything that came up at once: one call is one pause in the conversation, three calls are three. Null when only naming it."),description:r.string().nullish().describe(`One line saying what this note is about, not what it currently says. Give it for a new note, or when the line no longer fits. Null leaves it; ${s.MEMORY_ALWAYS_LISTED.join(" and ")} keep their own line.`),aliases:r.string().array().nullish().describe('What the user calls this note out loud, in the language they say it — the words they would use to ask for it, not the facts inside. A note at people/yuri might be "Yuri" and "my wife". Replaces the set it has, so send the whole set. Null leaves it.')}),execute:async t=>{let a=t.path.trim(),o=await (0,l.resolveNotePath)(a),r=t.aliases??null,n=(0,s.isAlwaysListed)(o??a)?null:t.description?.trim()||null,i=t.facts??[];if(!i.length&&!n&&!r)return{note:"Nothing to write: send facts, a line, names, or any of them."};if(!o&&!i.length)return{note:`Nothing on the listing called ${a}. A note comes into being with a fact — send at least one.`};let u=o||(0,s.isMemoryPath)(a)?{path:o??a,description:n,aliases:r,facts:i}:{path:s.MEMORY_INBOX,description:"Facts with nowhere obvious to go",facts:i},d=await (0,l.writeNotes)([u],e),p=u.path!==a?` Filed under ${u.path}: "${a}" is not a path this listing can carry. If that is not where it belongs, write it again under one that is.`:"",c=d.unnamed.length?` ${d.unnamed[0]} is new and has no line yet — the listing shows its first fact instead. Call again with \`description\` (one line about what it is) and \`aliases\` (the names they say for it).`:"",m=d.notLoaded.length?` All ${s.ALWAYS_LOADED_MAX} carried lines are taken, so ${d.notLoaded.map(e=>`"${e}"`).join(", ")} saved as an ordinary fact. Say which carried line you would drop for it and let them choose.`:"";return{...d.notes[0],note:`Saved. The listing in your instructions is from when this session opened and will not show this until the next one — the note below is current.${p}${c}${m}`}}}),[i.TOOL_NAMES.memory_show]:(0,o.tool)({description:`Put a note on the user's screen so they can see it while you
6
4
  talk about it, and take it away again. They cannot edit it there — they say
7
5
  what to drop and you drop it.`,inputSchema:r.object({path:r.string().nullable().describe("The note to put on screen, exactly as the listing writes it. Null takes it away.")}),execute:async({path:e})=>{if(!e?.trim())return n.appEvents.emit({type:"memory-view",path:null}),{note:"Taken off the screen."};let{notes:t}=await (0,l.readNotes)([e],{touch:!1}),a=t[0];return a?(n.appEvents.emit({type:"memory-view",path:a.path}),{...a,note:"It is on their screen now, in this order. Ask what they no longer need, and forget only what they name."}):{note:`Nothing on the listing called ${e.trim()}.`}}}),[i.TOOL_NAMES.memory_forget]:(0,o.tool)({description:"Delete one fact for good.",inputSchema:r.object({factId:r.number().int().describe("The id that came with the fact when the note was opened.")}),execute:async({factId:e})=>{let t=await (0,l.forgetFactById)(e);if(!t)return{note:`No fact with id ${e}. Nothing was deleted.`};if(t.noteGone)return{note:`${d} That was the last fact under ${t.path}, so the note went with it.`};let{notes:a}=await (0,l.readNotes)([t.path],{touch:!1});return{...a[0],note:d}}})})]),a()}catch(e){a(e)}},!1),489956,e=>{"use strict";var t=e.i(68356),a=e.i(847841),o=e.i(105249),r=e.i(353885);let n=`Answer the question from the web. Lead with the answer, then
8
6
  what supports it. Say plainly what you could not find or confirm — do not fill
9
7
  the gap with a guess. Every number carries the date you saw it. Be brief: this
10
8
  is read by another model, not by a person.`;e.s(["createSearchTool",0,(e,i)=>{if(!e?.searchTools)return{};let{model:l,searchTools:s}=e;return{[r.TOOL_NAMES.web_search]:(0,a.tool)({description:"Search the web and get back an answer with its sources. For a fact, a price, a date, what a page says. Not for a page that has to be clicked, filled, or signed into — that is the browser.",inputSchema:o.default.object({query:o.default.string().describe("What you want to know, as one full question. Put the place and the time in when they matter — the searcher sees nothing but this line.")}),execute:async({query:e},{abortSignal:a})=>{let{text:o,sources:r}=await (0,t.generateText)({model:l,tools:s,system:n,prompt:e,abortSignal:a}),u=[...new Set(r.flatMap(e=>"url"===e.sourceType?[e.title?`${e.title} — ${e.url}`:e.url]:[]))].slice(0,8);return i.fold([o.trim(),u.length?`Sources:
11
9
  ${u.join("\n")}`:""].filter(Boolean).join("\n\n"),"web-search")}})}}])},41181,e=>{"use strict";var t=e.i(847841),a=e.i(105249),o=e.i(353885),r=e.i(696968);e.s(["createSkillTools",0,({skills:e,sandbox:n})=>{let i=new Set;return{[o.TOOL_NAMES.load_skill]:(0,t.tool)({description:"Load one skill: its instructions, and the files that ship with it.",inputSchema:a.default.object({name:a.default.string().describe("Exact name from the Skills list. Do not guess names that are not on it.")}),execute:async({name:t})=>{let a=e.find(e=>e.name.toLowerCase()===t.toLowerCase());if(!a)return{error:`No skill named '${t}'.`,available:e.map(e=>e.name)};let o=`${a.path}/SKILL.md`;if(i.has(a.path))return{skillDirectory:a.path,note:`You already loaded '${a.name}' in this run — its instructions are above, unchanged. Scroll back to that result rather than reading it again; if you need the file itself, read ${o} with the shell.`};let l=await n.readFile(o,"utf-8"),{body:s}=(0,r.splitFrontmatter)(l),u=await n.glob("**/*",{path:a.path,limit:50});return i.add(a.path),{skillDirectory:a.path,files:u,content:s}}})}}])},752774,e=>{"use strict";var t=e.i(847841),a=e.i(907855);let o={name:e.i(353885).TOOL_NAMES.tidy_done,description:"Finish. Calling this ends the read — nothing after it runs.",parameters:a.object({summary:a.string().describe("One or two lines on what changed and why, or that nothing needed to.")})},r=(0,t.tool)({description:o.description,inputSchema:o.parameters,execute:async({summary:e})=>({ok:!0,summary:e})});e.s(["tidyDoneTool",0,r])},741376,e=>e.a(async(t,a)=>{try{var o=e.i(912714),r=e.i(750227),n=e.i(68356),i=e.i(343747),l=e.i(105249),s=e.i(687388),u=e.i(386075),d=e.i(353885),p=e.i(640911),c=e.i(41444),m=t([u]);function f(e){return{...e,execute:(t,a)=>{let o=e.inputSchema.safeParse(t);if(!o.success)throw Error(l.default.prettifyError(o.error));return e.execute(o.data,a)}}}[u]=m.then?(await m)():m;let w={images:`${s.PATHS.artifacts}/images`,audio:`${s.PATHS.artifacts}/audio`,transcripts:`${s.PATHS.artifacts}/transcripts`,videos:`${s.PATHS.artifacts}/videos`};function h(e,t){let a=e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,40),o=(0,i.format)(new Date,"yyyyMMdd-HHmmss");return`${o}${a?`-${a}`:""}.${t}`}async function v(e,t,a,o){let r=`${t}/${a}`;return await e.exec(`mkdir -p ${t}`),await e.writeFile(r,Buffer.from(o)),r}let b=e=>`${e}
12
- Saved. Give the user this path — the file opens from the task row. Do not describe it back to them; they can open it.`,x=(e,t)=>e?.split("/")[1]?.split(";")[0]||t,T=["1:1","16:9","9:16","4:3","3:4"],M=async()=>{let e=await (0,u.resolveMediaRef)("image");if(!e)return null;let t=(0,u.buildImageModel)(e.ref,e.apiKey);return f({name:d.STUDIO_TOOLS.generate_image,description:"Draw an image and save it as a file in the workspace. What comes back is its path.",inputSchema:l.default.object({prompt:l.default.string().describe("What to draw, described: subject, style, mood, what is in frame. The image model does not see the job or the conversation, so nothing can be left implied."),aspectRatio:l.default.enum(T).nullable().describe("Aspect ratio. Null for square.")}),execute:async({prompt:e,aspectRatio:a},{sandbox:o,abortSignal:r})=>{let{image:i}=await (0,n.generateImage)({model:t,prompt:e,aspectRatio:a??"1:1",abortSignal:r}),l=await v(o,w.images,h(e,x(i.mediaType,"png")),i.uint8Array);return b(l)}})},I=async()=>{let e=await (0,u.resolveMediaRef)("speech");if(!e)return null;let t=(0,u.buildSpeechModel)(e.ref,e.apiKey);return f({name:d.STUDIO_TOOLS.generate_speech,description:"Read text aloud into an audio file in the workspace — something the user listens to or sends, not Thursday's voice. What comes back is its path.",inputSchema:l.default.object({text:l.default.string().min(1).max(4e3).describe("The words to read, up to 4000 characters. Longer pieces are read in parts, one call each."),voice:l.default.string().nullable().describe("A voice name the provider knows. Null for its default."),instructions:l.default.string().nullable().describe('How to read it — "slowly", "warm", "like a news anchor". Null for plain.')}),execute:async({text:e,voice:a,instructions:o},{sandbox:r,abortSignal:i})=>{let{audio:l}=await (0,n.generateSpeech)({model:t,text:e,voice:a??void 0,instructions:o??void 0,outputFormat:"mp3",abortSignal:i}),s=await v(r,w.audio,h(e.slice(0,60),l.format||"mp3"),l.uint8Array);return b(s)}})},S=async()=>{let e=await (0,u.resolveMediaRef)("transcription");if(!e)return null;let t=(0,u.buildTranscriptionModel)(e.ref,e.apiKey);return f({name:d.STUDIO_TOOLS.transcribe,description:"Turn an audio file — a recording, a voice memo, a meeting — into text. The transcript is saved as a file in the workspace; what comes back is its path and the text.",inputSchema:l.default.object({path:l.default.string().min(1).describe("The audio file: a path relative to the workspace, or an absolute one anywhere on this machine.")}),execute:async({path:e},{sandbox:a,abortSignal:i})=>{let l=await (0,o.readFile)(a.resolve(e)),s=await (0,n.transcribe)({model:t,audio:l,abortSignal:i}),u=s.segments.length?`
10
+ Saved. Give the user this path — the file opens from the task row. Do not describe it back to them; they can open it.`,x=(e,t)=>e?.split("/")[1]?.split(";")[0]||t,T=["1:1","16:9","9:16","4:3","3:4"],M=async()=>{let e=await (0,u.resolveMediaRef)("image");if(!e)return null;let t=(0,u.buildImageModel)(e.ref,e.apiKey);return f({name:d.STUDIO_TOOLS.generate_image,description:"Draw an image and save it as a file in the workspace. What comes back is its path.",inputSchema:l.default.object({prompt:l.default.string().describe("What to draw, described: subject, style, mood, what is in frame. The image model does not see the job or the conversation, so nothing can be left implied."),aspectRatio:l.default.enum(T).nullish().describe("Aspect ratio. Null for square.")}),execute:async({prompt:e,aspectRatio:a},{sandbox:o,abortSignal:r})=>{let{image:i}=await (0,n.generateImage)({model:t,prompt:e,aspectRatio:a??"1:1",abortSignal:r}),l=await v(o,w.images,h(e,x(i.mediaType,"png")),i.uint8Array);return b(l)}})},I=async()=>{let e=await (0,u.resolveMediaRef)("speech");if(!e)return null;let t=(0,u.buildSpeechModel)(e.ref,e.apiKey);return f({name:d.STUDIO_TOOLS.generate_speech,description:"Read text aloud into an audio file in the workspace — something the user listens to or sends, not Thursday's voice. What comes back is its path.",inputSchema:l.default.object({text:l.default.string().min(1).max(4e3).describe("The words to read, up to 4000 characters. Longer pieces are read in parts, one call each."),voice:l.default.string().nullish().describe("A voice name the provider knows. Null for its default."),instructions:l.default.string().nullish().describe('How to read it — "slowly", "warm", "like a news anchor". Null for plain.')}),execute:async({text:e,voice:a,instructions:o},{sandbox:r,abortSignal:i})=>{let{audio:l}=await (0,n.generateSpeech)({model:t,text:e,voice:a??void 0,instructions:o??void 0,outputFormat:"mp3",abortSignal:i}),s=await v(r,w.audio,h(e.slice(0,60),l.format||"mp3"),l.uint8Array);return b(s)}})},S=async()=>{let e=await (0,u.resolveMediaRef)("transcription");if(!e)return null;let t=(0,u.buildTranscriptionModel)(e.ref,e.apiKey);return f({name:d.STUDIO_TOOLS.transcribe,description:"Turn an audio file — a recording, a voice memo, a meeting — into text. The transcript is saved as a file in the workspace; what comes back is its path and the text.",inputSchema:l.default.object({path:l.default.string().min(1).describe("The audio file: a path relative to the workspace, or an absolute one anywhere on this machine.")}),execute:async({path:e},{sandbox:a,abortSignal:i})=>{let l=await (0,o.readFile)(a.resolve(e)),s=await (0,n.transcribe)({model:t,audio:l,abortSignal:i}),u=s.segments.length?`
13
11
 
14
12
  ## Timeline
15
13
 
@@ -18,7 +16,13 @@ ${s.segments.map(e=>{var t;let a,o;return`- ${t=e.startSecond,a=Math.floor(t/60)
18
16
  ${s.text.trim()}${u}
19
17
  `));return`${p}
20
18
 
21
- ${await a.fold(s.text,"transcript")}`}})},E=async()=>{let e=await (0,u.resolveMediaRef)("video");if(!e)return null;let t=(0,u.buildVideoModel)(e.ref,e.apiKey);return f({name:d.STUDIO_TOOLS.generate_video,description:"Make a short video and save it as a file in the workspace. Takes minutes. What comes back is its path.",inputSchema:l.default.object({prompt:l.default.string().describe("What happens: the scene, the motion, the camera, the mood. The video model does not see the job or the conversation, so nothing can be left implied."),aspectRatio:l.default.enum(["16:9","9:16"]).nullable().describe("Aspect ratio. Null for 16:9."),seconds:l.default.number().int().min(2).max(10).nullable().describe("Length in seconds, 2 to 10. Null for the provider's default.")}),execute:async({prompt:e,aspectRatio:a,seconds:o},{sandbox:r,abortSignal:i})=>{let{video:l}=await (0,n.experimental_generateVideo)({model:t,prompt:e,aspectRatio:a??"16:9",duration:o??void 0,abortSignal:i}),s=await v(r,w.videos,h(e,x(l.mediaType,"mp4")),l.uint8Array);return b(s)}})};async function g(){return(await Promise.all([y(M),y(I),y(S),y(E)])).filter(e=>null!==e)}async function y(e){try{return await e()}catch(e){return p.logger.warn(`studio: a tool could not be built — ${(0,c.errorToString)(e)}`),null}}e.s(["loadStudio",0,g]),a()}catch(e){a(e)}},!1),660948,e=>e.a(async(t,a)=>{try{var o=e.i(105249),r=e.i(687388),n=e.i(105303),i=e.i(148831),l=e.i(41444),s=e.i(741376),u=t([n,i,s]);async function d(e){let[t,a]=await Promise.all([!e||e===r.STUDIO_SERVER?(0,s.loadStudio)():[],e===r.STUDIO_SERVER?[]:(0,i.listToolNames)(e)]);return[...t.map(e=>({server:r.STUDIO_SERVER,name:e.name})),...a]}[n,i,s]=u.then?(await u)():u;let h=async()=>{let[e,t]=await Promise.all([(0,s.loadStudio)(),(0,i.listServerNames)()]);return[...e.length?[r.STUDIO_SERVER]:[],...t.map(e=>e.name)]};async function p(e,t){if(e===r.STUDIO_SERVER){let e=new Set(t);return(await (0,s.loadStudio)()).filter(t=>e.has(t.name)).map(e=>({name:e.name,description:e.description,inputSchema:o.default.toJSONSchema(e.inputSchema)}))}return(await (0,i.findToolSchemas)(e,t)).map(e=>({name:e.name,description:e.description??null,inputSchema:e.inputSchema??null}))}async function c(e,t,a,o,i){try{let n=t===r.STUDIO_SERVER?await m(e,a,o,i):await f(t,a,o);if("string"!=typeof n)return n;return{status:"ok",text:await e.fold(n,`${t}-${a}`)}}catch(e){if(e instanceof n.McpAuthRequiredError)return{status:"auth_required",server:t,authorizationUrl:e.authorizationUrl};return{status:"error",text:(0,l.errorToString)(e)}}}async function m(e,t,a,o){let n=(await (0,s.loadStudio)()).find(e=>e.name===t);if(!n)throw Error(`"${t}" is not in the ${r.STUDIO_SERVER} right now — the key that runs it is gone.`);return n.execute(a??{},{sandbox:e,abortSignal:o})}async function f(e,t,a){let o=function(e){let t=e??{},a=!0===t.isError;if(!Array.isArray(t.content)){let e=void 0===t.toolResult?"":"string"==typeof t.toolResult?t.toolResult:JSON.stringify(t.toolResult);return{status:a?"error":"ok",text:e||v(a)}}let o=t.content.map(e=>"text"===e.type&&"string"==typeof e.text?e.text:`[${e.type}${e.mimeType?` ${e.mimeType}`:""} — not shown]`).join("\n").trim();return{status:a?"error":"ok",text:o||v(a)}}(await n.mcpManager.callTool(e,t,a));return"ok"===o.status?o.text:o}let v=e=>e?"The tool failed without a message.":"Done.";e.s(["callConnectedTool",0,c,"findConnectedSchemas",0,p,"listConnectedServerNames",0,h,"listConnectedToolNames",0,d]),a()}catch(e){a(e)}},!1),123203,e=>{"use strict";var t=e.i(750227),a=e.i(847841),o=e.i(105249),r=e.i(353885),n=e.i(786025);e.s(["createWorkspaceTools",0,(e,i)=>{let l=(0,a.tool)({description:"Run a bash command.",inputSchema:o.default.object({command:o.default.string(),description:o.default.string().nullable().describe("One short line for the user: what this command does and why. Shown on their screen while it runs — not a restatement of the command.")}),execute:({command:t},{abortSignal:a})=>e.exec(t,{signal:a,env:i.env})});if(!i.write)return{[r.TOOL_NAMES.bash]:l};let s=(0,a.tool)({description:"Write a whole file — what was there is gone. Parent directories are created.",inputSchema:o.default.object({path:o.default.string().describe("Relative to the working directory — under one of its folders — or absolute"),content:o.default.string(),description:o.default.string().nullable().describe("One short line for the user: what this file is. Shown on their screen next to the path.")}),execute:async({path:a,content:o})=>{let r,i=e.resolve(a),l=(0,n.writeRefusal)(i);return l?l:(await e.writeFile(a,o),`Wrote ${(r=(0,t.relative)(e.cwd,i))&&!r.startsWith("..")?r:i} (${o.split("\n").length} lines)`)}});return{[r.TOOL_NAMES.bash]:l,[r.TOOL_NAMES.write_file]:s}}])},636882,e=>{"use strict";var t=e.i(750227),a=e.i(687388),o=e.i(640911),r=e.i(41444),n=e.i(696968);let i=[(0,t.join)(a.APP_DIR,a.PATHS.skills.default),(0,t.join)(a.DATA_DIR,a.PATHS.skills.custom)];async function l(e,t){let a=[],i=new Set;for(let l of t){let t;try{t=await e.readdir(l,{withFileTypes:!0})}catch{continue}for(let s of t){let t,u;if(!s.isDirectory())continue;let d=`${l}/${s.name}`,p=`${d}/SKILL.md`;try{t=await e.readFile(p,"utf-8")}catch{continue}try{u=(0,n.parseFrontmatter)(t)}catch(e){o.logger.warn(`skill ${d}: SKILL.md front matter did not load — ${(0,r.errorToString)(e)}`);continue}!i.has(u.name)&&(i.add(u.name),u.disabled||a.push({name:u.name,description:u.description,path:d}))}}return a}e.s(["loadSkills",0,e=>l(e,i)])},388439,e=>{"use strict";let t=/[\u1100-\u11ff\u3040-\u30ff\u3130-\u318f\u4e00-\u9fff\uac00-\ud7af]/;e.s(["estimateTokens",0,function(e){let a=0,o=0;for(let r of e)t.test(r)?a+=1:o+=1;return Math.ceil(a/1.3+o/4)}])},68356,e=>{"use strict";var t,a,o,r,n,i,l,s,u,d,p,c,m,f,h,v,g,y,w,b,x,T,M,I,S,E,k,C,O,A,N,R,_,D,j,P,$,q,L,U,F,W=e.i(669022),V=e.i(847841),B=e.i(376261),K=e.i(907855),Y=Object.defineProperty,G="AI_InvalidArgumentError",z=`vercel.ai.error.${G}`,H=Symbol.for(z),J=class extends(a=B.AISDKError,t=H,a){constructor({parameter:e,value:a,message:o}){super({name:G,message:`Invalid argument for parameter ${e}: ${o}`}),this[t]=!0,this.parameter=e,this.value=a}static isInstance(e){return B.AISDKError.hasMarker(e,z)}},X=Symbol.for("vercel.ai.error.AI_InvalidStreamPartError");B.AISDKError;var Q="AI_InvalidToolApprovalError",Z=`vercel.ai.error.${Q}`,ee=Symbol.for(Z),et=class extends(r=B.AISDKError,o=ee,r){constructor({approvalId:e}){super({name:Q,message:`Tool approval response references unknown approvalId: "${e}". No matching tool-approval-request found in message history.`}),this[o]=!0,this.approvalId=e}static isInstance(e){return B.AISDKError.hasMarker(e,Z)}},ea="AI_InvalidToolApprovalSignatureError",eo=`vercel.ai.error.${ea}`,er=Symbol.for(eo),en=class extends(i=B.AISDKError,n=er,i){constructor({approvalId:e,toolCallId:t,reason:a}){super({name:ea,message:`Tool approval signature verification failed for approval "${e}" (tool call "${t}"): ${a}`}),this[n]=!0,this.approvalId=e,this.toolCallId=t}static isInstance(e){return B.AISDKError.hasMarker(e,eo)}},ei="AI_InvalidToolInputError",el=`vercel.ai.error.${ei}`,es=Symbol.for(el),eu=class extends(s=B.AISDKError,l=es,s){constructor({toolInput:e,toolName:t,cause:a,message:o=`Invalid input for tool ${t}: ${(0,B.getErrorMessage)(a)}`}){super({name:ei,message:o,cause:a}),this[l]=!0,this.toolInput=e,this.toolName=t}static isInstance(e){return B.AISDKError.hasMarker(e,el)}},ed="AI_ToolCallNotFoundForApprovalError",ep=`vercel.ai.error.${ed}`,ec=Symbol.for(ep),em=class extends(d=B.AISDKError,u=ec,d){constructor({toolCallId:e,approvalId:t}){super({name:ed,message:`Tool call "${e}" not found for approval request "${t}".`}),this[u]=!0,this.toolCallId=e,this.approvalId=t}static isInstance(e){return B.AISDKError.hasMarker(e,ep)}},ef="AI_MissingToolResultsError",eh=`vercel.ai.error.${ef}`,ev=Symbol.for(eh),eg=class extends(c=B.AISDKError,p=ev,c){constructor({toolCallIds:e}){super({name:ef,message:`Tool result${e.length>1?"s are":" is"} missing for tool call${e.length>1?"s":""} ${e.join(", ")}.`}),this[p]=!0,this.toolCallIds=e}static isInstance(e){return B.AISDKError.hasMarker(e,eh)}},ey="AI_NoImageGeneratedError",ew=`vercel.ai.error.${ey}`,eb=Symbol.for(ew),ex=class extends(f=B.AISDKError,m=eb,f){constructor({message:e="No image generated.",cause:t,calls:a,responses:o}){super({name:ey,message:e,cause:t}),this[m]=!0,this.calls=a,this.responses=o}static isInstance(e){return B.AISDKError.hasMarker(e,ew)}},eT="AI_NoObjectGeneratedError",eM=`vercel.ai.error.${eT}`,eI=Symbol.for(eM),eS=class extends(v=B.AISDKError,h=eI,v){constructor({message:e="No object generated.",cause:t,text:a,response:o,usage:r,finishReason:n}){super({name:eT,message:e,cause:t}),this[h]=!0,this.text=a,this.response=o,this.usage=r,this.finishReason=n}static isInstance(e){return B.AISDKError.hasMarker(e,eM)}},eE="AI_NoOutputGeneratedError",ek=`vercel.ai.error.${eE}`,eC=Symbol.for(ek),eO=class extends(y=B.AISDKError,g=eC,y){constructor({message:e="No output generated.",cause:t}={}){super({name:eE,message:e,cause:t}),this[g]=!0}static isInstance(e){return B.AISDKError.hasMarker(e,ek)}},eA="AI_NoSpeechGeneratedError",eN=`vercel.ai.error.${eA}`,eR=Symbol.for(eN),e_=class extends(b=B.AISDKError,w=eR,b){constructor(e){super({name:eA,message:"No speech audio generated."}),this[w]=!0,this.responses=e.responses}static isInstance(e){return B.AISDKError.hasMarker(e,eN)}},eD="AI_NoTranscriptGeneratedError",ej=`vercel.ai.error.${eD}`,eP=Symbol.for(ej),e$=class extends(T=B.AISDKError,x=eP,T){constructor(e){super({name:eD,message:"No transcript generated."}),this[x]=!0,this.responses=e.responses}static isInstance(e){return B.AISDKError.hasMarker(e,ej)}},eq=Symbol.for("vercel.ai.error.AI_NoTranslationGeneratedError");B.AISDKError;var eL="AI_NoVideoGeneratedError",eU=`vercel.ai.error.${eL}`,eF=Symbol.for(eU),eW=class extends(I=B.AISDKError,M=eF,I){constructor({message:e="No video generated.",cause:t,responses:a}){super({name:eL,message:e,cause:t}),this[M]=!0,this.responses=a}static isInstance(e){return B.AISDKError.hasMarker(e,eU)}static isNoVideoGeneratedError(e){return e instanceof Error&&e.name===eL&&void 0!==e.responses}toJSON(){return{name:this.name,message:this.message,stack:this.stack,cause:this.cause,responses:this.responses}}},eV="AI_NoSuchToolError",eB=`vercel.ai.error.${eV}`,eK=Symbol.for(eB),eY=class extends(E=B.AISDKError,S=eK,E){constructor({toolName:e,availableTools:t,message:a=`Model tried to call unavailable tool '${e}'. ${void 0===t?"No tools are available.":`Available tools: ${t.join(", ")}.`}`}){super({name:eV,message:a}),this[S]=!0,this.toolName=e,this.availableTools=t}static isInstance(e){return B.AISDKError.hasMarker(e,eB)}},eG="AI_StreamProviderError",ez=`vercel.ai.error.${eG}`,eH=Symbol.for(ez),eJ=class extends(C=B.AISDKError,k=eH,C){constructor({message:e,type:t,code:a,statusCode:o,isRetryable:r=function(e){return null!=e&&(408===e||409===e||429===e||e>=500)}(o),data:n,cause:i}){super({name:eG,message:e,cause:i}),this[k]=!0,this.type=t,this.code=a,this.statusCode=o,this.isRetryable=r,this.data=n}static isInstance(e){return B.AISDKError.hasMarker(e,ez)}},eX="AI_ToolCallRepairError",eQ=`vercel.ai.error.${eX}`,eZ=Symbol.for(eQ),e0=class extends(A=B.AISDKError,O=eZ,A){constructor({cause:e,originalError:t,message:a=`Error repairing tool call: ${(0,B.getErrorMessage)(e)}`}){super({name:eX,message:a,cause:e}),this[O]=!0,this.originalError=t}static isInstance(e){return B.AISDKError.hasMarker(e,eQ)}},e1="AI_ToolChoiceViolationError",e4=`vercel.ai.error.${e1}`,e8=Symbol.for(e4),e3=class extends(R=B.AISDKError,N=e8,R){constructor({toolChoice:e,finishReason:t,provider:a,modelId:o,content:r,message:n="required"===e.type?"Model response did not contain a tool call even though tool choice was required.":`Model response did not contain a call to the required tool '${e.toolName}'.`}){super({name:e1,message:n}),this[N]=!0,this.toolChoice=e,this.finishReason=t,this.provider=a,this.modelId=o,this.content=r}static isInstance(e){return B.AISDKError.hasMarker(e,e4)}},e2=class extends B.AISDKError{constructor(e){super({name:"AI_UnsupportedModelVersionError",message:`Unsupported model version ${e.version} for provider "${e.provider}" and model "${e.modelId}". AI SDK 5 only supports models that implement specification version "v2".`}),this.version=e.version,this.provider=e.provider,this.modelId=e.modelId}},e6="AI_UIMessageStreamError",e7=`vercel.ai.error.${e6}`,e9=Symbol.for(e7),e5=class extends(D=B.AISDKError,_=e9,D){constructor({chunkType:e,chunkId:t,message:a}){super({name:e6,message:a}),this[_]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return B.AISDKError.hasMarker(e,e7)}},te="AI_InvalidDataContentError",tt=`vercel.ai.error.${te}`,ta=Symbol.for(tt),to=class extends(P=B.AISDKError,j=ta,P){constructor({content:e,cause:t,message:a=`Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof e}.`}){super({name:te,message:a,cause:t}),this[j]=!0,this.content=e}static isInstance(e){return B.AISDKError.hasMarker(e,tt)}},tr="AI_InvalidMessageRoleError",tn=`vercel.ai.error.${tr}`,ti=Symbol.for(tn),tl=class extends(q=B.AISDKError,$=ti,q){constructor({role:e,message:t=`Invalid message role: '${e}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:tr,message:t}),this[$]=!0,this.role=e}static isInstance(e){return B.AISDKError.hasMarker(e,tn)}},ts=Symbol.for("vercel.ai.error.AI_MessageConversionError");B.AISDKError;var tu="AI_RetryError",td=`vercel.ai.error.${tu}`,tp=Symbol.for(td),tc=class extends(U=B.AISDKError,L=tp,U){constructor({message:e,reason:t,errors:a}){super({name:tu,message:e}),this[L]=!0,this.reason=t,this.errors=a,this.lastError=a[a.length-1]}static isInstance(e){return B.AISDKError.hasMarker(e,td)}},tm=!1;function tf({message:e,type:t}){"u">typeof process&&"function"==typeof process.emitWarning?process.emitWarning(e,{type:t}):console.warn(e)}var th=e=>{if(0===e.warnings.length)return;let t=globalThis.AI_SDK_LOG_WARNINGS;if(!1!==t){if("function"==typeof t)return void t(e);for(let t of(tm||(tm=!0,tf({message:"AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.",type:"Warning"})),e.warnings))tf({message:function({warning:e,provider:t,model:a}){let o=null!=t&&null!=a?` (${t} / ${a})`:"",r=`AI SDK Warning${o}:`;switch(e.type){case"unsupported":{let t=`${r} The feature "${e.feature}" is not supported.`;return e.details&&(t+=` ${e.details}`),t}case"compatibility":{let t=`${r} The feature "${e.feature}" is used in a compatibility mode.`;return e.details&&(t+=` ${e.details}`),t}case"deprecated":return`${r} Deprecated: "${e.setting}". ${e.message}`;case"other":return`${r} ${e.message}`;default:return`${r} ${JSON.stringify(e,null,2)}`}}({warning:t,provider:e.provider,model:e.model}),type:"deprecated"===t.type?"DeprecationWarning":"Warning"})}};function tv({provider:e,modelId:t}){th({warnings:[{type:"compatibility",feature:"specificationVersion",details:"Using v2 specification compatibility mode. Some features may not be available."}],provider:e,model:t})}function tg(e){return"v3"===e.specificationVersion?e:(tv({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get:(e,t)=>"specificationVersion"===t?"v3":e[t]}))}function ty(e){return"v3"===e.specificationVersion?e:(tv({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get:(e,t)=>"specificationVersion"===t?"v3":e[t]}))}function tw(e){return"v4"===e.specificationVersion?e:new Proxy("v2"===e.specificationVersion?ty(e):e,{get:(e,t)=>"specificationVersion"===t?"v4":e[t]})}function tb(e){return"v3"===e.specificationVersion?e:(tv({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get(e,t){switch(t){case"specificationVersion":return"v3";case"doGenerate":return async(...t)=>{let a=await e.doGenerate(...t);return{...a,finishReason:tx(a.finishReason),usage:tT(a.usage)}};case"doStream":return async(...t)=>{let a=await e.doStream(...t);return{...a,stream:a.stream.pipeThrough(new TransformStream({transform(e,t){"finish"===e.type?t.enqueue({...e,finishReason:tx(e.finishReason),usage:tT(e.usage)}):t.enqueue(e)}}))}};default:return e[t]}}}))}function tx(e){return{unified:"unknown"===e?"other":e,raw:void 0}}function tT(e){return{inputTokens:{total:e.inputTokens,noCache:void 0,cacheRead:e.cachedInputTokens,cacheWrite:void 0},outputTokens:{total:e.outputTokens,text:void 0,reasoning:e.reasoningTokens}}}function tM(e){return"v4"===e.specificationVersion?e:new Proxy("v2"===e.specificationVersion?tb(e):e,{get:(e,t)=>"specificationVersion"===t?"v4":e[t]})}function tI(e){return"v3"===e.specificationVersion?e:(tv({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get:(e,t)=>"specificationVersion"===t?"v3":e[t]}))}function tS(e){return"v4"===e.specificationVersion?e:new Proxy("v2"===e.specificationVersion?tI(e):e,{get:(e,t)=>"specificationVersion"===t?"v4":e[t]})}function tE(e){return"v3"===e.specificationVersion?e:(tv({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get:(e,t)=>"specificationVersion"===t?"v3":e[t]}))}function tk(e){return"v4"===e.specificationVersion?e:new Proxy("v2"===e.specificationVersion?tE(e):e,{get:(e,t)=>"specificationVersion"===t?"v4":e[t]})}function tC(e){if("string"==typeof e)return tO().languageModel(e);if(!["v4","v3","v2"].includes(e.specificationVersion))throw new e2({version:e.specificationVersion,provider:e.provider,modelId:e.modelId});return tM(e)}function tO(){var e,t=null!=(e=globalThis.AI_SDK_DEFAULT_PROVIDER)?e:W.gateway;if("specificationVersion"in t&&"v4"===t.specificationVersion)return t;let a="specificationVersion"in t&&"v3"===t.specificationVersion||"specificationVersion"in t&&"v3"===t.specificationVersion?t:{specificationVersion:"v3",languageModel:e=>tb(t.languageModel(e)),embeddingModel:e=>tg(t.textEmbeddingModel(e)),imageModel:e=>ty(t.imageModel(e)),transcriptionModel:t.transcriptionModel?e=>tE(t.transcriptionModel(e)):void 0,speechModel:t.speechModel?e=>tI(t.speechModel(e)):void 0,rerankingModel:void 0};return{specificationVersion:"v4",languageModel:e=>tM(a.languageModel(e)),embeddingModel:e=>{var t;return"v4"===(t=a.embeddingModel(e)).specificationVersion?t:new Proxy("v2"===t.specificationVersion?tg(t):t,{get:(e,t)=>"specificationVersion"===t?"v4":e[t]})},imageModel:e=>tw(a.imageModel(e)),transcriptionModel:a.transcriptionModel?e=>tk(a.transcriptionModel(e)):void 0,speechModel:a.speechModel?e=>tS(a.speechModel(e)):void 0,rerankingModel:a.rerankingModel?e=>{var t;return"v4"===(t=a.rerankingModel(e)).specificationVersion?t:new Proxy(t,{get:(e,t)=>"specificationVersion"===t?"v4":e[t]})}:void 0}}function tA(e){return e.map(e=>(function e(t){return t instanceof URL?new URL(t.href):Array.isArray(t)?t.map(t=>e(t)):t instanceof Uint8Array?new Uint8Array(t):t instanceof ArrayBuffer?t.slice(0):t instanceof Date?new Date(t):null!=t&&"object"==typeof t?Object.fromEntries(Object.entries(t).map(([t,a])=>[t,e(a)])):t})(e))}var tN="7.0.93",tR=async({url:e,maxBytes:t,abortSignal:a})=>{var o;let r=e.toString();try{let e=(0,V.withUserAgentSuffix)({},`ai-sdk/${tN}`,(0,V.getRuntimeEnvironmentUserAgent)()),n=await (0,V.fetchWithValidatedRedirects)({url:r,headers:e,abortSignal:a});if(!n.ok)throw await (0,V.cancelResponseBody)(n),new V.DownloadError({url:r,statusCode:n.status,statusText:n.statusText});return{data:await (0,V.readResponseWithSizeLimit)({response:n,url:r,maxBytes:null!=t?t:V.DEFAULT_MAX_DOWNLOAD_SIZE}),mediaType:null!=(o=n.headers.get("content-type"))?o:void 0}}catch(e){if(V.DownloadError.isInstance(e))throw e;throw new V.DownloadError({url:r,cause:e})}};function t_(e,t){if(void 0===e&&void 0===t)return;if(void 0===e)return t;if(void 0===t)return e;let a={...e};for(let o in t)if("__proto__"!==o&&"constructor"!==o&&"prototype"!==o&&Object.prototype.hasOwnProperty.call(t,o)){let r=t[o];if(void 0===r)continue;let n=o in e?e[o]:void 0,i=null!==r&&"object"==typeof r&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp),l=null!=n&&"object"==typeof n&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof RegExp);i&&l?a[o]=t_(n,r):a[o]=r}return a}function tD(e){try{let[t,a]=e.split(",");return{mediaType:t.split(";")[0].split(":")[1],base64Content:a}}catch(e){return{mediaType:void 0,base64Content:void 0}}}function tj(e){if("data:"===e.protocol){let{mediaType:t,base64Content:a}=tD(e.toString());if(null==t||null==a)throw new to({content:e,message:`Invalid data URL format in content ${e.toString()}`});return{data:{type:"data",data:a},mediaType:t}}return{data:{type:"url",url:e},mediaType:void 0}}function tP(e){return e instanceof Uint8Array?{data:{type:"data",data:e},mediaType:void 0}:e instanceof ArrayBuffer||(0,V.isBuffer)(e)?{data:{type:"data",data:new Uint8Array(e)},mediaType:void 0}:{data:{type:"data",data:e},mediaType:void 0}}function t$(e){if(function(e){if("object"!=typeof e||null===e)return!1;let t=e.type;return"data"===t||"url"===t||"reference"===t||"text"===t}(e))switch(e.type){case"data":if("string"==typeof e.data&&e.data.startsWith("data:"))throw new to({content:e.data,message:'Data URLs are not valid inline data. Pass them as { type: "url", url } instead.'});return tP(e.data);case"url":return tj(e.url);case"reference":return{data:{type:"reference",reference:e.reference},mediaType:void 0};case"text":return{data:{type:"text",text:e.text},mediaType:void 0}}if(e instanceof URL)return tj(e);if("string"==typeof e)try{return tj(new URL(e))}catch(t){return tP(e)}return(0,V.isProviderReference)(e)?{data:{type:"reference",reference:e},mediaType:void 0}:tP(e)}async function tq({prompt:e,supportedUrls:t,download:a=((e=tR)=>t=>Promise.all(t.map(async t=>t.isUrlSupportedByModel?null:await e(t))))(),provider:o}){let r=await tU(e.messages,a,t),n=new Map;for(let t of e.messages)if("assistant"===t.role&&Array.isArray(t.content))for(let e of t.content)"tool-approval-request"===e.type&&"approvalId"in e&&"toolCallId"in e&&n.set(e.approvalId,e.toolCallId);let i=new Set;for(let t of e.messages)if("tool"===t.role){for(let e of t.content)if("tool-approval-response"===e.type){let t=n.get(e.approvalId);t&&i.add(t)}}let l=[...null!=e.instructions?"string"==typeof e.instructions?[{role:"system",content:e.instructions}]:(0,V.asArray)(e.instructions).map(e=>({role:"system",content:e.content,providerOptions:e.providerOptions})):[],...e.messages.map(e=>(function({message:e,downloadedAssets:t,provider:a}){let o=[],r=e.role;switch(r){case"system":return{role:"system",content:e.content,providerOptions:e.providerOptions};case"user":{if("string"==typeof e.content)return{role:"user",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions};let a={role:"user",content:e.content.map(e=>("image"===e.type&&o.push({type:"deprecated",setting:'"image" content part',message:'The "image" content part type is deprecated. Use a "file" part with mediaType: \'image\' (or a more specific image/* subtype) instead.'}),tL(e))).map(e=>tF(e,t)).filter(e=>"text"!==e.type||""!==e.text),providerOptions:e.providerOptions};return o.length>0&&th({warnings:o}),a}case"assistant":{if("string"==typeof e.content)return{role:"assistant",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions};let r={role:"assistant",content:e.content.filter(e=>"text"!==e.type||""!==e.text||null!=e.providerOptions).filter(e=>"tool-approval-request"!==e.type).map(e=>{let r=e.providerOptions;switch(e.type){case"custom":return{type:"custom",kind:e.kind,providerOptions:r};case"file":{let{data:t,mediaType:a}=t$(e.data);return{type:"file",data:t,filename:e.filename,mediaType:null!=a?a:e.mediaType,providerOptions:r}}case"reasoning":return{type:"reasoning",text:e.text,providerOptions:r};case"reasoning-file":{let{data:t,mediaType:a}=t$(e.data);if("data"!==t.type&&"url"!==t.type)throw Error(`Unsupported reasoning-file data type: ${t.type}`);return{type:"reasoning-file",data:t,mediaType:null!=a?a:e.mediaType,providerOptions:r}}case"text":return{type:"text",text:e.text,providerOptions:r};case"tool-call":return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,providerExecuted:e.providerExecuted,providerOptions:r};case"tool-result":return{type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,output:tW({output:e.output,provider:a,warnings:o,downloadedAssets:t}),providerOptions:r}}}),providerOptions:e.providerOptions};return o.length>0&&th({warnings:o}),r}case"tool":{let r={role:"tool",content:e.content.filter(e=>"tool-approval-response"!==e.type||e.providerExecuted).map(e=>{switch(e.type){case"tool-result":return{type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,output:tW({output:e.output,provider:a,warnings:o,downloadedAssets:t}),providerOptions:e.providerOptions};case"tool-approval-response":return{type:"tool-approval-response",approvalId:e.approvalId,approved:e.approved,reason:e.reason}}}),providerOptions:e.providerOptions};return o.length>0&&th({warnings:o}),r}default:throw new tl({role:r})}})({message:e,downloadedAssets:r,provider:o}))],s=[];for(let e of l){if("tool"!==e.role){s.push(e);continue}let t=s.at(-1);if((null==t?void 0:t.role)==="tool"){let a=t.content.at(-1);null!=a&&null!=t.providerOptions&&(a.providerOptions=t_(t.providerOptions,a.providerOptions)),t.content.push(...e.content),t.providerOptions=e.providerOptions}else s.push(e)}let u=new Set;for(let e of s)switch(e.role){case"assistant":for(let t of e.content)"tool-call"!==t.type||t.providerExecuted||u.add(t.toolCallId);break;case"tool":for(let t of e.content)"tool-result"===t.type&&u.delete(t.toolCallId);break;case"user":case"system":for(let e of i)u.delete(e);if(u.size>0)throw new eg({toolCallIds:Array.from(u)})}for(let e of i)u.delete(e);if(u.size>0)throw new eg({toolCallIds:Array.from(u)});return s.filter(e=>"tool"!==e.role||e.content.length>0)}function tL(e){var t;return"image"!==e.type?e:{type:"file",data:e.image,mediaType:null!=(t=e.mediaType)?t:"image",providerOptions:e.providerOptions}}async function tU(e,t,a){let o=[];for(let t of e){if("user"===t.role&&Array.isArray(t.content))for(let e of t.content){let t=tL(e);"file"===t.type&&o.push(t)}if("tool"===t.role){for(let e of t.content)if("tool-result"===e.type&&"content"===e.output.type)for(let t of e.output.value)"file"===t.type&&o.push(t)}if("assistant"===t.role&&Array.isArray(t.content)){for(let e of t.content)if("tool-result"===e.type&&"content"===e.output.type)for(let t of e.output.value)"file"===t.type&&o.push(t)}}let r=o.map(e=>{let t=e.mediaType,{data:a}=t$(e.data);return{mediaType:t,data:a}}).filter(e=>"url"===e.data.type).map(e=>({url:e.data.url,isUrlSupportedByModel:null!=e.mediaType&&(0,V.isUrlSupported)({url:e.data.url.toString(),mediaType:e.mediaType,supportedUrls:a})}));return Object.fromEntries((await t(r)).map((e,t)=>null==e?null:[r[t].url.toString(),{data:e.data,mediaType:e.mediaType}]).filter(e=>null!=e))}function tF(e,t){if("text"===e.type)return{type:"text",text:e.text,providerOptions:e.providerOptions};let{data:a,mediaType:o}=t$(e.data),r=null!=o?o:e.mediaType,n=a;if("url"===n.type){let e=t[n.url.toString()];e&&(n={type:"data",data:e.data},null==e.mediaType||null!=r&&(0,V.isFullMediaType)(r)||(r=e.mediaType))}if("data"===n.type&&(n.data instanceof Uint8Array||"string"==typeof n.data)){let e=(0,V.detectMediaType)({data:n.data,topLevelType:"image"});null!=e&&(r=e)}if(null==r)throw Error("Media type is missing for file part");return{type:"file",mediaType:r,filename:e.filename,data:n,providerOptions:e.providerOptions}}function tW({output:e,provider:t,warnings:a=[],downloadedAssets:o}){return"content"!==e.type?e:{type:"content",value:e.value.map(e=>{var r;switch(e.type){case"file":{let t=tF(e,o);if("file"!==t.type)throw Error("Expected tool result file content to convert to file.");return t}case"file-data":return a.push({type:"deprecated",setting:'"tool-result" content of type "file-data"',message:'The "file-data" type for tool result content is deprecated. Use the "file" type with mediaType and { type: \'data\', data } instead.'}),{type:"file",data:{type:"data",data:e.data},filename:e.filename,mediaType:e.mediaType,providerOptions:e.providerOptions};case"file-url":{let t=null!=(r=e.mediaType)?r:function(e,t="application/octet-stream"){var a;try{let t=new URL(e).pathname,o=null==(a=t.split(".").pop())?void 0:a.toLowerCase();if(o&&Object.hasOwn(tB,o))return tB[o]}catch(e){}return t}(e.url),o='The "file-url" type for tool result content is deprecated. Use the "file" type with mediaType and { type: \'url\', url } instead.';if(!e.mediaType){let a="application/octet-stream"===t?"Unable to infer media type from URL. Defaulting to 'application/octet-stream'.":`Inferred media type '${t}' from URL.`;o=`The "file-url" tool result content part with URL "${e.url}" is missing a "mediaType". ${a} ${o}`}return a.push({type:"deprecated",setting:'"tool-result" content of type "file-url"',message:o}),{type:"file",data:{type:"url",url:new URL(e.url)},mediaType:t,providerOptions:e.providerOptions}}case"file-id":return a.push({type:"deprecated",setting:'"tool-result" content of type "file-id"',message:'The "file-id" type for tool result content is deprecated. Use the "file" type with mediaType and { type: \'reference\', reference } instead.'}),{type:"file",data:{type:"reference",reference:tV({fileId:e.fileId,provider:t})},mediaType:"application",providerOptions:e.providerOptions};case"file-reference":return a.push({type:"deprecated",setting:'"tool-result" content of type "file-reference"',message:'The "file-reference" type for tool result content is deprecated. Use the "file" type with mediaType and { type: \'reference\', reference } instead.'}),{type:"file",data:{type:"reference",reference:e.providerReference},mediaType:"application",providerOptions:e.providerOptions};case"image-data":return a.push({type:"deprecated",setting:'"tool-result" content of type "image-data"',message:'The "image-data" type for tool result content is deprecated. Use the "file" type with mediaType and { type: \'data\', data } instead.'}),{type:"file",data:{type:"data",data:e.data},mediaType:e.mediaType,providerOptions:e.providerOptions};case"image-url":return a.push({type:"deprecated",setting:'"tool-result" content of type "image-url"',message:"The \"image-url\" type for tool result content is deprecated. Use the \"file\" type with mediaType 'image' (or a specific image/* subtype) and { type: 'url', url } instead."}),{type:"file",data:{type:"url",url:new URL(e.url)},mediaType:"image",providerOptions:e.providerOptions};case"image-file-id":return a.push({type:"deprecated",setting:'"tool-result" content of type "image-file-id"',message:'The "image-file-id" type for tool result content is deprecated. Use the "file" type with mediaType and { type: \'reference\', reference } instead.'}),{type:"file",data:{type:"reference",reference:tV({fileId:e.fileId,provider:t})},mediaType:"image",providerOptions:e.providerOptions};case"image-file-reference":return a.push({type:"deprecated",setting:'"tool-result" content of type "image-file-reference"',message:'The "image-file-reference" type for tool result content is deprecated. Use the "file" type with mediaType and { type: \'reference\', reference } instead.'}),{type:"file",data:{type:"reference",reference:e.providerReference},mediaType:"image",providerOptions:e.providerOptions};default:return e}})}}function tV({fileId:e,provider:t}){if("object"==typeof e)return e;if(null==t)throw Error("Cannot convert string fileId to provider reference without a provider ID. Use a Record<string, string> fileId or switch to the file-reference type.");return{[t]:e}}var tB={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",avif:"image/avif",heic:"image/heic",bmp:"image/bmp",tiff:"image/tiff",tif:"image/tiff",pdf:"application/pdf",mp4:"video/mp4",webm:"video/webm",mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg"};async function tK({toolCallId:e,input:t,output:a,tool:o,errorMode:r}){return"text"===r?{type:"error-text",value:(0,B.getErrorMessage)(a)}:"json"===r?{type:"error-json",value:tY(a)}:(null==o?void 0:o.toModelOutput)?await o.toModelOutput({toolCallId:e,input:t,output:a}):"string"==typeof a?{type:"text",value:a}:{type:"json",value:tY(a)}}function tY(e){return void 0===e?null:e}function tG({maxOutputTokens:e,temperature:t,topP:a,topK:o,presencePenalty:r,frequencyPenalty:n,seed:i,stopSequences:l,reasoning:s}){if(null!=e){if(!Number.isInteger(e))throw new J({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be an integer"});if(e<1)throw new J({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be >= 1"})}if(null!=t&&"number"!=typeof t)throw new J({parameter:"temperature",value:t,message:"temperature must be a number"});if(null!=a&&"number"!=typeof a)throw new J({parameter:"topP",value:a,message:"topP must be a number"});if(null!=o&&"number"!=typeof o)throw new J({parameter:"topK",value:o,message:"topK must be a number"});if(null!=r&&"number"!=typeof r)throw new J({parameter:"presencePenalty",value:r,message:"presencePenalty must be a number"});if(null!=n&&"number"!=typeof n)throw new J({parameter:"frequencyPenalty",value:n,message:"frequencyPenalty must be a number"});if(null!=i&&!Number.isInteger(i))throw new J({parameter:"seed",value:i,message:"seed must be an integer"});return{maxOutputTokens:e,temperature:t,topP:a,topK:o,presencePenalty:r,frequencyPenalty:n,stopSequences:l,seed:i,reasoning:s}}function tz({toolChoice:e}){return null==e?{type:"auto"}:"string"==typeof e?{type:e}:{type:"tool",toolName:e.toolName}}async function tH({tools:e,toolOrder:t,toolsContext:a={},experimental_sandbox:o}){if(!(null!=e&&Object.keys(e).length>0))return;let r=[];for(let[n,i]of function({tools:e,toolOrder:t}){if(null==t)return Object.entries(e);let a=Object.entries(e);return[...a.filter(([e])=>t.includes(e)).sort(([e],[a])=>t.indexOf(e)-t.indexOf(a)),...a.filter(([e])=>!t.includes(e)).sort(([e],[t])=>e<t?-1:+(e>t))]}({tools:e,toolOrder:t})){let e=i.type;switch(e){case void 0:case"dynamic":case"function":{let e=function({tool:e,toolName:t,toolsContext:a,experimental_sandbox:o}){return void 0===e.description?void 0:"string"==typeof e.description?e.description:e.description({context:a[t],experimental_sandbox:o})}({tool:i,toolName:n,toolsContext:a,experimental_sandbox:o}),t=i.providerOptions,l=i.inputExamples,s=i.strict;r.push({type:"function",name:n,inputSchema:await (0,V.asSchema)(i.inputSchema).jsonSchema,...null!=e?{description:e}:{},...null!=l?{inputExamples:l}:{},...null!=t?{providerOptions:t}:{},...null!=s?{strict:s}:{}});break}case"provider":r.push({type:"provider",name:n,id:i.id,args:i.args});break;default:throw Error(`Unsupported tool type: ${e}`)}}return r}function tJ(e){if(null!=e)return"number"==typeof e?e:e.totalMs}function tX(e){if(null!=e&&"number"!=typeof e)return e.stepMs}function tQ(e){if(null!=e&&"number"!=typeof e)return e.firstChunkMs}function tZ(e){if(null!=e&&"number"!=typeof e)return e.chunkMs}var t0={array:K.array,boolean:K.boolean,custom:K.custom,discriminatedUnion:K.discriminatedUnion,enum:K.enum,instanceof:K.instanceof,lazy:K.lazy,literal:K.literal,looseObject:K.looseObject,never:K.never,null:K.null,number:K.number,object:K.object,record:K.record,string:K.string,union:K.union,unknown:K.unknown},t1=t0.lazy(()=>t0.union([t0.null(),t0.string(),t0.number(),t0.boolean(),t0.record(t0.string(),t1.optional()),t0.array(t1)])),t4=t0.record(t0.string(),t0.record(t0.string(),t1.optional())),t8=t0.union([t0.string(),t0.instanceof(Uint8Array),t0.instanceof(ArrayBuffer),t0.custom(V.isBuffer,{message:"Must be a Buffer"})]),t3=t0.record(t0.string(),t0.string()),t2=t0.object({type:t0.literal("text"),text:t0.string(),providerOptions:t4.optional()}),t6=t0.object({type:t0.literal("image"),image:t0.union([t8,t0.instanceof(URL),t3]),mediaType:t0.string().optional(),providerOptions:t4.optional()}),t7=t0.discriminatedUnion("type",[t0.object({type:t0.literal("data"),data:t8}),t0.object({type:t0.literal("url"),url:t0.instanceof(URL)}),t0.object({type:t0.literal("reference"),reference:t3}),t0.object({type:t0.literal("text"),text:t0.string()})]),t9=t0.discriminatedUnion("type",[t0.object({type:t0.literal("data"),data:t8}),t0.object({type:t0.literal("url"),url:t0.instanceof(URL)})]),t5=t0.object({type:t0.literal("file"),data:t0.union([t7,t8,t0.instanceof(URL),t3]),filename:t0.string().optional(),mediaType:t0.string(),providerOptions:t4.optional()}),ae=t0.object({type:t0.literal("reasoning"),text:t0.string(),providerOptions:t4.optional()}),at=t0.object({type:t0.literal("custom"),kind:t0.string().transform(e=>e),providerOptions:t4.optional()}),aa=t0.object({type:t0.literal("reasoning-file"),data:t0.union([t9,t8,t0.instanceof(URL)]),mediaType:t0.string(),providerOptions:t4.optional()}),ao=t0.object({type:t0.literal("tool-call"),toolCallId:t0.string(),toolName:t0.string(),input:t0.unknown(),providerOptions:t4.optional(),providerExecuted:t0.boolean().optional()}),ar=t0.discriminatedUnion("type",[t0.object({type:t0.literal("text"),value:t0.string(),providerOptions:t4.optional()}),t0.object({type:t0.literal("json"),value:t1,providerOptions:t4.optional()}),t0.object({type:t0.literal("execution-denied"),reason:t0.string().optional(),providerOptions:t4.optional()}),t0.object({type:t0.literal("error-text"),value:t0.string(),providerOptions:t4.optional()}),t0.object({type:t0.literal("error-json"),value:t1,providerOptions:t4.optional()}),t0.object({type:t0.literal("content"),value:t0.array(t0.union([t0.object({type:t0.literal("text"),text:t0.string(),providerOptions:t4.optional()}),t0.object({type:t0.literal("file"),data:t7,mediaType:t0.string(),filename:t0.string().optional(),providerOptions:t4.optional()}),t0.object({type:t0.literal("file-data"),data:t0.string(),mediaType:t0.string(),filename:t0.string().optional(),providerOptions:t4.optional()}),t0.object({type:t0.literal("file-url"),url:t0.string(),mediaType:t0.string().optional(),providerOptions:t4.optional()}),t0.object({type:t0.literal("file-id"),fileId:t0.union([t0.string(),t0.record(t0.string(),t0.string())]),providerOptions:t4.optional()}),t0.object({type:t0.literal("file-reference"),providerReference:t0.record(t0.string(),t0.string()),providerOptions:t4.optional()}),t0.object({type:t0.literal("image-data"),data:t0.string(),mediaType:t0.string(),providerOptions:t4.optional()}),t0.object({type:t0.literal("image-url"),url:t0.string(),providerOptions:t4.optional()}),t0.object({type:t0.literal("image-file-id"),fileId:t0.union([t0.string(),t0.record(t0.string(),t0.string())]),providerOptions:t4.optional()}),t0.object({type:t0.literal("image-file-reference"),providerReference:t0.record(t0.string(),t0.string()),providerOptions:t4.optional()}),t0.object({type:t0.literal("custom"),providerOptions:t4.optional()})]))})]),an=t0.object({type:t0.literal("tool-result"),toolCallId:t0.string(),toolName:t0.string(),output:ar,providerOptions:t4.optional()}),ai=t0.object({type:t0.literal("tool-approval-request"),approvalId:t0.string(),toolCallId:t0.string(),reason:t0.string().optional()}),al=t0.object({type:t0.literal("tool-approval-response"),approvalId:t0.string(),approved:t0.boolean(),reason:t0.string().optional()}),as=t0.object({role:t0.literal("system"),content:t0.string(),providerOptions:t4.optional()}),au=t0.object({role:t0.literal("user"),content:t0.union([t0.string(),t0.array(t0.union([t2,t6,t5]))]),providerOptions:t4.optional()}),ad=t0.object({role:t0.literal("assistant"),content:t0.union([t0.string(),t0.array(t0.union([t2,at,t5,ae,aa,ao,an,ai]))]),providerOptions:t4.optional()}),ap=t0.object({role:t0.literal("tool"),content:t0.array(t0.union([an,al])),providerOptions:t4.optional()}),ac=t0.union([as,au,ad,ap]);async function am({allowSystemInMessages:e=!1,system:t,instructions:a=t,prompt:o,messages:r}){if(null==o&&null==r)throw new B.InvalidPromptError({prompt:o,message:"prompt or messages must be defined"});if(null!=o&&null!=r)throw new B.InvalidPromptError({prompt:o,message:"prompt and messages cannot be defined at the same time"});if("string"!=typeof a&&!(0,V.asArray)(a).every(e=>"system"===e.role))throw new B.InvalidPromptError({prompt:o,message:"instructions must be a string, SystemModelMessage, or array of SystemModelMessage"});if(null!=o&&"string"==typeof o)r=[{role:"user",content:o}];else if(null!=o&&Array.isArray(o))r=o;else if(null==r)throw new B.InvalidPromptError({prompt:o,message:"prompt or messages must be defined"});if(0===r.length)throw new B.InvalidPromptError({prompt:o,message:"messages must not be empty"});if(!e&&r.some(e=>"system"===e.role))throw new B.InvalidPromptError({prompt:o,message:"System messages are not allowed in the prompt or messages fields. Use the instructions option instead."});let n=await (0,V.safeValidateTypes)({value:r,schema:t0.array(ac)});if(!n.success)throw new B.InvalidPromptError({prompt:o,message:"The messages do not match the ModelMessage[] schema.",cause:n.error});return{messages:r,instructions:a}}function af(e){if(!W.GatewayAuthenticationError.isInstance(e))return e;let t="https://ai-sdk.dev/unauthenticated-ai-gateway";return(null==process?void 0:"production")==="production"?new B.AISDKError({name:"GatewayError",message:`Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${t}`}):Object.assign(Error(`\x1b[1m\x1b[31mUnauthenticated request to AI Gateway.\x1b[0m
19
+ ${await a.fold(s.text,"transcript")}`}})},E=async()=>{let e=await (0,u.resolveMediaRef)("video");if(!e)return null;let t=(0,u.buildVideoModel)(e.ref,e.apiKey);return f({name:d.STUDIO_TOOLS.generate_video,description:"Make a short video and save it as a file in the workspace. Takes minutes. What comes back is its path.",inputSchema:l.default.object({prompt:l.default.string().describe("What happens: the scene, the motion, the camera, the mood. The video model does not see the job or the conversation, so nothing can be left implied."),aspectRatio:l.default.enum(["16:9","9:16"]).nullish().describe("Aspect ratio. Null for 16:9."),seconds:l.default.number().int().min(2).max(10).nullish().describe("Length in seconds, 2 to 10. Null for the provider's default.")}),execute:async({prompt:e,aspectRatio:a,seconds:o},{sandbox:r,abortSignal:i})=>{let{video:l}=await (0,n.experimental_generateVideo)({model:t,prompt:e,aspectRatio:a??"16:9",duration:o??void 0,abortSignal:i}),s=await v(r,w.videos,h(e,x(l.mediaType,"mp4")),l.uint8Array);return b(s)}})};async function g(){return(await Promise.all([y(M),y(I),y(S),y(E)])).filter(e=>null!==e)}async function y(e){try{return await e()}catch(e){return p.logger.warn(`studio: a tool could not be built — ${(0,c.errorToString)(e)}`),null}}e.s(["loadStudio",0,g]),a()}catch(e){a(e)}},!1),660948,e=>e.a(async(t,a)=>{try{var o=e.i(105249),r=e.i(687388),n=e.i(105303),i=e.i(148831),l=e.i(41444),s=e.i(741376),u=t([n,i,s]);async function d(e){let[t,a]=await Promise.all([!e||e===r.STUDIO_SERVER?(0,s.loadStudio)():[],e===r.STUDIO_SERVER?[]:(0,i.listToolNames)(e)]);return[...t.map(e=>({server:r.STUDIO_SERVER,name:e.name})),...a]}[n,i,s]=u.then?(await u)():u;let h=async()=>{let[e,t]=await Promise.all([(0,s.loadStudio)(),(0,i.listServerNames)()]);return[...e.length?[r.STUDIO_SERVER]:[],...t.map(e=>e.name)]};async function p(e,t){if(e===r.STUDIO_SERVER){let e=new Set(t);return(await (0,s.loadStudio)()).filter(t=>e.has(t.name)).map(e=>({name:e.name,description:e.description,inputSchema:o.default.toJSONSchema(e.inputSchema)}))}return(await (0,i.findToolSchemas)(e,t)).map(e=>({name:e.name,description:e.description??null,inputSchema:e.inputSchema??null}))}async function c(e,t,a,o,i){try{let n=t===r.STUDIO_SERVER?await m(e,a,o,i):await f(t,a,o);if("string"!=typeof n)return n;return{status:"ok",text:await e.fold(n,`${t}-${a}`)}}catch(e){if(e instanceof n.McpAuthRequiredError)return{status:"auth_required",server:t,authorizationUrl:e.authorizationUrl};return{status:"error",text:(0,l.errorToString)(e)}}}async function m(e,t,a,o){let n=(await (0,s.loadStudio)()).find(e=>e.name===t);if(!n)throw Error(`"${t}" is not in the ${r.STUDIO_SERVER} right now — the key that runs it is gone.`);return n.execute(a??{},{sandbox:e,abortSignal:o})}async function f(e,t,a){let o=function(e){let t=e??{},a=!0===t.isError;if(!Array.isArray(t.content)){let e=void 0===t.toolResult?"":"string"==typeof t.toolResult?t.toolResult:JSON.stringify(t.toolResult);return{status:a?"error":"ok",text:e||v(a)}}let o=t.content.map(e=>"text"===e.type&&"string"==typeof e.text?e.text:`[${e.type}${e.mimeType?` ${e.mimeType}`:""} — not shown]`).join("\n").trim();return{status:a?"error":"ok",text:o||v(a)}}(await n.mcpManager.callTool(e,t,a));return"ok"===o.status?o.text:o}let v=e=>e?"The tool failed without a message.":"Done.";e.s(["callConnectedTool",0,c,"findConnectedSchemas",0,p,"listConnectedServerNames",0,h,"listConnectedToolNames",0,d]),a()}catch(e){a(e)}},!1),123203,e=>{"use strict";var t=e.i(750227),a=e.i(847841),o=e.i(105249),r=e.i(353885),n=e.i(786025),i=e.i(211644);let l=`## The shell here
20
+
21
+ Every command is a new shell: \`cd\`, exported variables and an activated venv are gone by the next one — chain what depends on the last step into a single command.
22
+
23
+ Nothing is watching it. A command that stops to ask never gets an answer and is killed after ${i.EXEC_TIMEOUT_MS/1e3}s, so pass the flag that skips the question (\`-y\`, \`--yes\`, \`--no-input\`), and send anything genuinely long to the background with its output redirected to a file.
24
+
25
+ Keys are not in the environment: every variable named like a key, a token or a secret is removed before the shell starts. An empty one is not an unset one — say which it was, and ask for what a command needs.`;e.s(["createWorkspaceTools",0,(e,i)=>{let s=!0===i.guide,u=(0,a.tool)({description:"Run a bash command.",inputSchema:o.default.object({command:o.default.string(),description:o.default.string().nullish().describe("One short line for the user: what this command does and why. Shown on their screen while it runs — not a restatement of the command.")}),execute:async({command:t},{abortSignal:a})=>{let o=await e.exec(t,{signal:a,env:i.env});return s?(s=!1,{...o,guide:l}):o}});if(!i.write)return{[r.TOOL_NAMES.bash]:u};let d=(0,a.tool)({description:"Write a whole file — what was there is gone. Parent directories are created.",inputSchema:o.default.object({path:o.default.string().describe("Relative to the working directory — under one of its folders — or absolute"),content:o.default.string(),description:o.default.string().nullish().describe("One short line for the user: what this file is. Shown on their screen next to the path.")}),execute:async({path:a,content:o})=>{let r,i=e.resolve(a),l=(0,n.writeRefusal)(i);return l?l:(await e.writeFile(a,o),`Wrote ${(r=(0,t.relative)(e.cwd,i))&&!r.startsWith("..")?r:i} (${o.split("\n").length} lines)`)}});return{[r.TOOL_NAMES.bash]:u,[r.TOOL_NAMES.write_file]:d}}])},636882,e=>{"use strict";var t=e.i(750227),a=e.i(687388),o=e.i(640911),r=e.i(41444),n=e.i(696968);let i=[(0,t.join)(a.APP_DIR,a.PATHS.skills.default),(0,t.join)(a.DATA_DIR,a.PATHS.skills.custom)];async function l(e,t){let a=[],i=new Set;for(let l of t){let t;try{t=await e.readdir(l,{withFileTypes:!0})}catch{continue}for(let s of t){let t,u;if(!s.isDirectory())continue;let d=`${l}/${s.name}`,p=`${d}/SKILL.md`;try{t=await e.readFile(p,"utf-8")}catch{continue}try{u=(0,n.parseFrontmatter)(t)}catch(e){o.logger.warn(`skill ${d}: SKILL.md front matter did not load — ${(0,r.errorToString)(e)}`);continue}!i.has(u.name)&&(i.add(u.name),u.disabled||a.push({name:u.name,description:u.description,path:d}))}}return a}e.s(["loadSkills",0,e=>l(e,i)])},388439,e=>{"use strict";let t=/[\u1100-\u11ff\u3040-\u30ff\u3130-\u318f\u4e00-\u9fff\uac00-\ud7af]/;function a(e){let a=0,o=0;for(let r of e)t.test(r)?a+=1:o+=1;return Math.ceil(a/1.3+o/4)}e.s(["estimateTokens",0,a,"sectionTokens",0,function(e){return e.split(/\n(?=## )/).map(e=>({name:e.startsWith("## ")?e.slice(3,e.indexOf("\n")):"identity",tokens:a(e)})).sort((e,t)=>t.tokens-e.tokens)}])},68356,e=>{"use strict";var t,a,o,r,n,i,l,s,u,d,p,c,m,f,h,v,g,y,w,b,x,T,M,I,S,E,k,C,O,A,N,R,_,D,j,P,$,q,L,U,F,W=e.i(669022),V=e.i(847841),B=e.i(376261),K=e.i(907855),Y=Object.defineProperty,G="AI_InvalidArgumentError",z=`vercel.ai.error.${G}`,H=Symbol.for(z),J=class extends(a=B.AISDKError,t=H,a){constructor({parameter:e,value:a,message:o}){super({name:G,message:`Invalid argument for parameter ${e}: ${o}`}),this[t]=!0,this.parameter=e,this.value=a}static isInstance(e){return B.AISDKError.hasMarker(e,z)}},X=Symbol.for("vercel.ai.error.AI_InvalidStreamPartError");B.AISDKError;var Q="AI_InvalidToolApprovalError",Z=`vercel.ai.error.${Q}`,ee=Symbol.for(Z),et=class extends(r=B.AISDKError,o=ee,r){constructor({approvalId:e}){super({name:Q,message:`Tool approval response references unknown approvalId: "${e}". No matching tool-approval-request found in message history.`}),this[o]=!0,this.approvalId=e}static isInstance(e){return B.AISDKError.hasMarker(e,Z)}},ea="AI_InvalidToolApprovalSignatureError",eo=`vercel.ai.error.${ea}`,er=Symbol.for(eo),en=class extends(i=B.AISDKError,n=er,i){constructor({approvalId:e,toolCallId:t,reason:a}){super({name:ea,message:`Tool approval signature verification failed for approval "${e}" (tool call "${t}"): ${a}`}),this[n]=!0,this.approvalId=e,this.toolCallId=t}static isInstance(e){return B.AISDKError.hasMarker(e,eo)}},ei="AI_InvalidToolInputError",el=`vercel.ai.error.${ei}`,es=Symbol.for(el),eu=class extends(s=B.AISDKError,l=es,s){constructor({toolInput:e,toolName:t,cause:a,message:o=`Invalid input for tool ${t}: ${(0,B.getErrorMessage)(a)}`}){super({name:ei,message:o,cause:a}),this[l]=!0,this.toolInput=e,this.toolName=t}static isInstance(e){return B.AISDKError.hasMarker(e,el)}},ed="AI_ToolCallNotFoundForApprovalError",ep=`vercel.ai.error.${ed}`,ec=Symbol.for(ep),em=class extends(d=B.AISDKError,u=ec,d){constructor({toolCallId:e,approvalId:t}){super({name:ed,message:`Tool call "${e}" not found for approval request "${t}".`}),this[u]=!0,this.toolCallId=e,this.approvalId=t}static isInstance(e){return B.AISDKError.hasMarker(e,ep)}},ef="AI_MissingToolResultsError",eh=`vercel.ai.error.${ef}`,ev=Symbol.for(eh),eg=class extends(c=B.AISDKError,p=ev,c){constructor({toolCallIds:e}){super({name:ef,message:`Tool result${e.length>1?"s are":" is"} missing for tool call${e.length>1?"s":""} ${e.join(", ")}.`}),this[p]=!0,this.toolCallIds=e}static isInstance(e){return B.AISDKError.hasMarker(e,eh)}},ey="AI_NoImageGeneratedError",ew=`vercel.ai.error.${ey}`,eb=Symbol.for(ew),ex=class extends(f=B.AISDKError,m=eb,f){constructor({message:e="No image generated.",cause:t,calls:a,responses:o}){super({name:ey,message:e,cause:t}),this[m]=!0,this.calls=a,this.responses=o}static isInstance(e){return B.AISDKError.hasMarker(e,ew)}},eT="AI_NoObjectGeneratedError",eM=`vercel.ai.error.${eT}`,eI=Symbol.for(eM),eS=class extends(v=B.AISDKError,h=eI,v){constructor({message:e="No object generated.",cause:t,text:a,response:o,usage:r,finishReason:n}){super({name:eT,message:e,cause:t}),this[h]=!0,this.text=a,this.response=o,this.usage=r,this.finishReason=n}static isInstance(e){return B.AISDKError.hasMarker(e,eM)}},eE="AI_NoOutputGeneratedError",ek=`vercel.ai.error.${eE}`,eC=Symbol.for(ek),eO=class extends(y=B.AISDKError,g=eC,y){constructor({message:e="No output generated.",cause:t}={}){super({name:eE,message:e,cause:t}),this[g]=!0}static isInstance(e){return B.AISDKError.hasMarker(e,ek)}},eA="AI_NoSpeechGeneratedError",eN=`vercel.ai.error.${eA}`,eR=Symbol.for(eN),e_=class extends(b=B.AISDKError,w=eR,b){constructor(e){super({name:eA,message:"No speech audio generated."}),this[w]=!0,this.responses=e.responses}static isInstance(e){return B.AISDKError.hasMarker(e,eN)}},eD="AI_NoTranscriptGeneratedError",ej=`vercel.ai.error.${eD}`,eP=Symbol.for(ej),e$=class extends(T=B.AISDKError,x=eP,T){constructor(e){super({name:eD,message:"No transcript generated."}),this[x]=!0,this.responses=e.responses}static isInstance(e){return B.AISDKError.hasMarker(e,ej)}},eq=Symbol.for("vercel.ai.error.AI_NoTranslationGeneratedError");B.AISDKError;var eL="AI_NoVideoGeneratedError",eU=`vercel.ai.error.${eL}`,eF=Symbol.for(eU),eW=class extends(I=B.AISDKError,M=eF,I){constructor({message:e="No video generated.",cause:t,responses:a}){super({name:eL,message:e,cause:t}),this[M]=!0,this.responses=a}static isInstance(e){return B.AISDKError.hasMarker(e,eU)}static isNoVideoGeneratedError(e){return e instanceof Error&&e.name===eL&&void 0!==e.responses}toJSON(){return{name:this.name,message:this.message,stack:this.stack,cause:this.cause,responses:this.responses}}},eV="AI_NoSuchToolError",eB=`vercel.ai.error.${eV}`,eK=Symbol.for(eB),eY=class extends(E=B.AISDKError,S=eK,E){constructor({toolName:e,availableTools:t,message:a=`Model tried to call unavailable tool '${e}'. ${void 0===t?"No tools are available.":`Available tools: ${t.join(", ")}.`}`}){super({name:eV,message:a}),this[S]=!0,this.toolName=e,this.availableTools=t}static isInstance(e){return B.AISDKError.hasMarker(e,eB)}},eG="AI_StreamProviderError",ez=`vercel.ai.error.${eG}`,eH=Symbol.for(ez),eJ=class extends(C=B.AISDKError,k=eH,C){constructor({message:e,type:t,code:a,statusCode:o,isRetryable:r=function(e){return null!=e&&(408===e||409===e||429===e||e>=500)}(o),data:n,cause:i}){super({name:eG,message:e,cause:i}),this[k]=!0,this.type=t,this.code=a,this.statusCode=o,this.isRetryable=r,this.data=n}static isInstance(e){return B.AISDKError.hasMarker(e,ez)}},eX="AI_ToolCallRepairError",eQ=`vercel.ai.error.${eX}`,eZ=Symbol.for(eQ),e0=class extends(A=B.AISDKError,O=eZ,A){constructor({cause:e,originalError:t,message:a=`Error repairing tool call: ${(0,B.getErrorMessage)(e)}`}){super({name:eX,message:a,cause:e}),this[O]=!0,this.originalError=t}static isInstance(e){return B.AISDKError.hasMarker(e,eQ)}},e1="AI_ToolChoiceViolationError",e4=`vercel.ai.error.${e1}`,e8=Symbol.for(e4),e3=class extends(R=B.AISDKError,N=e8,R){constructor({toolChoice:e,finishReason:t,provider:a,modelId:o,content:r,message:n="required"===e.type?"Model response did not contain a tool call even though tool choice was required.":`Model response did not contain a call to the required tool '${e.toolName}'.`}){super({name:e1,message:n}),this[N]=!0,this.toolChoice=e,this.finishReason=t,this.provider=a,this.modelId=o,this.content=r}static isInstance(e){return B.AISDKError.hasMarker(e,e4)}},e2=class extends B.AISDKError{constructor(e){super({name:"AI_UnsupportedModelVersionError",message:`Unsupported model version ${e.version} for provider "${e.provider}" and model "${e.modelId}". AI SDK 5 only supports models that implement specification version "v2".`}),this.version=e.version,this.provider=e.provider,this.modelId=e.modelId}},e6="AI_UIMessageStreamError",e7=`vercel.ai.error.${e6}`,e9=Symbol.for(e7),e5=class extends(D=B.AISDKError,_=e9,D){constructor({chunkType:e,chunkId:t,message:a}){super({name:e6,message:a}),this[_]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return B.AISDKError.hasMarker(e,e7)}},te="AI_InvalidDataContentError",tt=`vercel.ai.error.${te}`,ta=Symbol.for(tt),to=class extends(P=B.AISDKError,j=ta,P){constructor({content:e,cause:t,message:a=`Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof e}.`}){super({name:te,message:a,cause:t}),this[j]=!0,this.content=e}static isInstance(e){return B.AISDKError.hasMarker(e,tt)}},tr="AI_InvalidMessageRoleError",tn=`vercel.ai.error.${tr}`,ti=Symbol.for(tn),tl=class extends(q=B.AISDKError,$=ti,q){constructor({role:e,message:t=`Invalid message role: '${e}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:tr,message:t}),this[$]=!0,this.role=e}static isInstance(e){return B.AISDKError.hasMarker(e,tn)}},ts=Symbol.for("vercel.ai.error.AI_MessageConversionError");B.AISDKError;var tu="AI_RetryError",td=`vercel.ai.error.${tu}`,tp=Symbol.for(td),tc=class extends(U=B.AISDKError,L=tp,U){constructor({message:e,reason:t,errors:a}){super({name:tu,message:e}),this[L]=!0,this.reason=t,this.errors=a,this.lastError=a[a.length-1]}static isInstance(e){return B.AISDKError.hasMarker(e,td)}},tm=!1;function tf({message:e,type:t}){"u">typeof process&&"function"==typeof process.emitWarning?process.emitWarning(e,{type:t}):console.warn(e)}var th=e=>{if(0===e.warnings.length)return;let t=globalThis.AI_SDK_LOG_WARNINGS;if(!1!==t){if("function"==typeof t)return void t(e);for(let t of(tm||(tm=!0,tf({message:"AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.",type:"Warning"})),e.warnings))tf({message:function({warning:e,provider:t,model:a}){let o=null!=t&&null!=a?` (${t} / ${a})`:"",r=`AI SDK Warning${o}:`;switch(e.type){case"unsupported":{let t=`${r} The feature "${e.feature}" is not supported.`;return e.details&&(t+=` ${e.details}`),t}case"compatibility":{let t=`${r} The feature "${e.feature}" is used in a compatibility mode.`;return e.details&&(t+=` ${e.details}`),t}case"deprecated":return`${r} Deprecated: "${e.setting}". ${e.message}`;case"other":return`${r} ${e.message}`;default:return`${r} ${JSON.stringify(e,null,2)}`}}({warning:t,provider:e.provider,model:e.model}),type:"deprecated"===t.type?"DeprecationWarning":"Warning"})}};function tv({provider:e,modelId:t}){th({warnings:[{type:"compatibility",feature:"specificationVersion",details:"Using v2 specification compatibility mode. Some features may not be available."}],provider:e,model:t})}function tg(e){return"v3"===e.specificationVersion?e:(tv({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get:(e,t)=>"specificationVersion"===t?"v3":e[t]}))}function ty(e){return"v3"===e.specificationVersion?e:(tv({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get:(e,t)=>"specificationVersion"===t?"v3":e[t]}))}function tw(e){return"v4"===e.specificationVersion?e:new Proxy("v2"===e.specificationVersion?ty(e):e,{get:(e,t)=>"specificationVersion"===t?"v4":e[t]})}function tb(e){return"v3"===e.specificationVersion?e:(tv({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get(e,t){switch(t){case"specificationVersion":return"v3";case"doGenerate":return async(...t)=>{let a=await e.doGenerate(...t);return{...a,finishReason:tx(a.finishReason),usage:tT(a.usage)}};case"doStream":return async(...t)=>{let a=await e.doStream(...t);return{...a,stream:a.stream.pipeThrough(new TransformStream({transform(e,t){"finish"===e.type?t.enqueue({...e,finishReason:tx(e.finishReason),usage:tT(e.usage)}):t.enqueue(e)}}))}};default:return e[t]}}}))}function tx(e){return{unified:"unknown"===e?"other":e,raw:void 0}}function tT(e){return{inputTokens:{total:e.inputTokens,noCache:void 0,cacheRead:e.cachedInputTokens,cacheWrite:void 0},outputTokens:{total:e.outputTokens,text:void 0,reasoning:e.reasoningTokens}}}function tM(e){return"v4"===e.specificationVersion?e:new Proxy("v2"===e.specificationVersion?tb(e):e,{get:(e,t)=>"specificationVersion"===t?"v4":e[t]})}function tI(e){return"v3"===e.specificationVersion?e:(tv({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get:(e,t)=>"specificationVersion"===t?"v3":e[t]}))}function tS(e){return"v4"===e.specificationVersion?e:new Proxy("v2"===e.specificationVersion?tI(e):e,{get:(e,t)=>"specificationVersion"===t?"v4":e[t]})}function tE(e){return"v3"===e.specificationVersion?e:(tv({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get:(e,t)=>"specificationVersion"===t?"v3":e[t]}))}function tk(e){return"v4"===e.specificationVersion?e:new Proxy("v2"===e.specificationVersion?tE(e):e,{get:(e,t)=>"specificationVersion"===t?"v4":e[t]})}function tC(e){if("string"==typeof e)return tO().languageModel(e);if(!["v4","v3","v2"].includes(e.specificationVersion))throw new e2({version:e.specificationVersion,provider:e.provider,modelId:e.modelId});return tM(e)}function tO(){var e,t=null!=(e=globalThis.AI_SDK_DEFAULT_PROVIDER)?e:W.gateway;if("specificationVersion"in t&&"v4"===t.specificationVersion)return t;let a="specificationVersion"in t&&"v3"===t.specificationVersion||"specificationVersion"in t&&"v3"===t.specificationVersion?t:{specificationVersion:"v3",languageModel:e=>tb(t.languageModel(e)),embeddingModel:e=>tg(t.textEmbeddingModel(e)),imageModel:e=>ty(t.imageModel(e)),transcriptionModel:t.transcriptionModel?e=>tE(t.transcriptionModel(e)):void 0,speechModel:t.speechModel?e=>tI(t.speechModel(e)):void 0,rerankingModel:void 0};return{specificationVersion:"v4",languageModel:e=>tM(a.languageModel(e)),embeddingModel:e=>{var t;return"v4"===(t=a.embeddingModel(e)).specificationVersion?t:new Proxy("v2"===t.specificationVersion?tg(t):t,{get:(e,t)=>"specificationVersion"===t?"v4":e[t]})},imageModel:e=>tw(a.imageModel(e)),transcriptionModel:a.transcriptionModel?e=>tk(a.transcriptionModel(e)):void 0,speechModel:a.speechModel?e=>tS(a.speechModel(e)):void 0,rerankingModel:a.rerankingModel?e=>{var t;return"v4"===(t=a.rerankingModel(e)).specificationVersion?t:new Proxy(t,{get:(e,t)=>"specificationVersion"===t?"v4":e[t]})}:void 0}}function tA(e){return e.map(e=>(function e(t){return t instanceof URL?new URL(t.href):Array.isArray(t)?t.map(t=>e(t)):t instanceof Uint8Array?new Uint8Array(t):t instanceof ArrayBuffer?t.slice(0):t instanceof Date?new Date(t):null!=t&&"object"==typeof t?Object.fromEntries(Object.entries(t).map(([t,a])=>[t,e(a)])):t})(e))}var tN="7.0.93",tR=async({url:e,maxBytes:t,abortSignal:a})=>{var o;let r=e.toString();try{let e=(0,V.withUserAgentSuffix)({},`ai-sdk/${tN}`,(0,V.getRuntimeEnvironmentUserAgent)()),n=await (0,V.fetchWithValidatedRedirects)({url:r,headers:e,abortSignal:a});if(!n.ok)throw await (0,V.cancelResponseBody)(n),new V.DownloadError({url:r,statusCode:n.status,statusText:n.statusText});return{data:await (0,V.readResponseWithSizeLimit)({response:n,url:r,maxBytes:null!=t?t:V.DEFAULT_MAX_DOWNLOAD_SIZE}),mediaType:null!=(o=n.headers.get("content-type"))?o:void 0}}catch(e){if(V.DownloadError.isInstance(e))throw e;throw new V.DownloadError({url:r,cause:e})}};function t_(e,t){if(void 0===e&&void 0===t)return;if(void 0===e)return t;if(void 0===t)return e;let a={...e};for(let o in t)if("__proto__"!==o&&"constructor"!==o&&"prototype"!==o&&Object.prototype.hasOwnProperty.call(t,o)){let r=t[o];if(void 0===r)continue;let n=o in e?e[o]:void 0,i=null!==r&&"object"==typeof r&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp),l=null!=n&&"object"==typeof n&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof RegExp);i&&l?a[o]=t_(n,r):a[o]=r}return a}function tD(e){try{let[t,a]=e.split(",");return{mediaType:t.split(";")[0].split(":")[1],base64Content:a}}catch(e){return{mediaType:void 0,base64Content:void 0}}}function tj(e){if("data:"===e.protocol){let{mediaType:t,base64Content:a}=tD(e.toString());if(null==t||null==a)throw new to({content:e,message:`Invalid data URL format in content ${e.toString()}`});return{data:{type:"data",data:a},mediaType:t}}return{data:{type:"url",url:e},mediaType:void 0}}function tP(e){return e instanceof Uint8Array?{data:{type:"data",data:e},mediaType:void 0}:e instanceof ArrayBuffer||(0,V.isBuffer)(e)?{data:{type:"data",data:new Uint8Array(e)},mediaType:void 0}:{data:{type:"data",data:e},mediaType:void 0}}function t$(e){if(function(e){if("object"!=typeof e||null===e)return!1;let t=e.type;return"data"===t||"url"===t||"reference"===t||"text"===t}(e))switch(e.type){case"data":if("string"==typeof e.data&&e.data.startsWith("data:"))throw new to({content:e.data,message:'Data URLs are not valid inline data. Pass them as { type: "url", url } instead.'});return tP(e.data);case"url":return tj(e.url);case"reference":return{data:{type:"reference",reference:e.reference},mediaType:void 0};case"text":return{data:{type:"text",text:e.text},mediaType:void 0}}if(e instanceof URL)return tj(e);if("string"==typeof e)try{return tj(new URL(e))}catch(t){return tP(e)}return(0,V.isProviderReference)(e)?{data:{type:"reference",reference:e},mediaType:void 0}:tP(e)}async function tq({prompt:e,supportedUrls:t,download:a=((e=tR)=>t=>Promise.all(t.map(async t=>t.isUrlSupportedByModel?null:await e(t))))(),provider:o}){let r=await tU(e.messages,a,t),n=new Map;for(let t of e.messages)if("assistant"===t.role&&Array.isArray(t.content))for(let e of t.content)"tool-approval-request"===e.type&&"approvalId"in e&&"toolCallId"in e&&n.set(e.approvalId,e.toolCallId);let i=new Set;for(let t of e.messages)if("tool"===t.role){for(let e of t.content)if("tool-approval-response"===e.type){let t=n.get(e.approvalId);t&&i.add(t)}}let l=[...null!=e.instructions?"string"==typeof e.instructions?[{role:"system",content:e.instructions}]:(0,V.asArray)(e.instructions).map(e=>({role:"system",content:e.content,providerOptions:e.providerOptions})):[],...e.messages.map(e=>(function({message:e,downloadedAssets:t,provider:a}){let o=[],r=e.role;switch(r){case"system":return{role:"system",content:e.content,providerOptions:e.providerOptions};case"user":{if("string"==typeof e.content)return{role:"user",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions};let a={role:"user",content:e.content.map(e=>("image"===e.type&&o.push({type:"deprecated",setting:'"image" content part',message:'The "image" content part type is deprecated. Use a "file" part with mediaType: \'image\' (or a more specific image/* subtype) instead.'}),tL(e))).map(e=>tF(e,t)).filter(e=>"text"!==e.type||""!==e.text),providerOptions:e.providerOptions};return o.length>0&&th({warnings:o}),a}case"assistant":{if("string"==typeof e.content)return{role:"assistant",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions};let r={role:"assistant",content:e.content.filter(e=>"text"!==e.type||""!==e.text||null!=e.providerOptions).filter(e=>"tool-approval-request"!==e.type).map(e=>{let r=e.providerOptions;switch(e.type){case"custom":return{type:"custom",kind:e.kind,providerOptions:r};case"file":{let{data:t,mediaType:a}=t$(e.data);return{type:"file",data:t,filename:e.filename,mediaType:null!=a?a:e.mediaType,providerOptions:r}}case"reasoning":return{type:"reasoning",text:e.text,providerOptions:r};case"reasoning-file":{let{data:t,mediaType:a}=t$(e.data);if("data"!==t.type&&"url"!==t.type)throw Error(`Unsupported reasoning-file data type: ${t.type}`);return{type:"reasoning-file",data:t,mediaType:null!=a?a:e.mediaType,providerOptions:r}}case"text":return{type:"text",text:e.text,providerOptions:r};case"tool-call":return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,providerExecuted:e.providerExecuted,providerOptions:r};case"tool-result":return{type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,output:tW({output:e.output,provider:a,warnings:o,downloadedAssets:t}),providerOptions:r}}}),providerOptions:e.providerOptions};return o.length>0&&th({warnings:o}),r}case"tool":{let r={role:"tool",content:e.content.filter(e=>"tool-approval-response"!==e.type||e.providerExecuted).map(e=>{switch(e.type){case"tool-result":return{type:"tool-result",toolCallId:e.toolCallId,toolName:e.toolName,output:tW({output:e.output,provider:a,warnings:o,downloadedAssets:t}),providerOptions:e.providerOptions};case"tool-approval-response":return{type:"tool-approval-response",approvalId:e.approvalId,approved:e.approved,reason:e.reason}}}),providerOptions:e.providerOptions};return o.length>0&&th({warnings:o}),r}default:throw new tl({role:r})}})({message:e,downloadedAssets:r,provider:o}))],s=[];for(let e of l){if("tool"!==e.role){s.push(e);continue}let t=s.at(-1);if((null==t?void 0:t.role)==="tool"){let a=t.content.at(-1);null!=a&&null!=t.providerOptions&&(a.providerOptions=t_(t.providerOptions,a.providerOptions)),t.content.push(...e.content),t.providerOptions=e.providerOptions}else s.push(e)}let u=new Set;for(let e of s)switch(e.role){case"assistant":for(let t of e.content)"tool-call"!==t.type||t.providerExecuted||u.add(t.toolCallId);break;case"tool":for(let t of e.content)"tool-result"===t.type&&u.delete(t.toolCallId);break;case"user":case"system":for(let e of i)u.delete(e);if(u.size>0)throw new eg({toolCallIds:Array.from(u)})}for(let e of i)u.delete(e);if(u.size>0)throw new eg({toolCallIds:Array.from(u)});return s.filter(e=>"tool"!==e.role||e.content.length>0)}function tL(e){var t;return"image"!==e.type?e:{type:"file",data:e.image,mediaType:null!=(t=e.mediaType)?t:"image",providerOptions:e.providerOptions}}async function tU(e,t,a){let o=[];for(let t of e){if("user"===t.role&&Array.isArray(t.content))for(let e of t.content){let t=tL(e);"file"===t.type&&o.push(t)}if("tool"===t.role){for(let e of t.content)if("tool-result"===e.type&&"content"===e.output.type)for(let t of e.output.value)"file"===t.type&&o.push(t)}if("assistant"===t.role&&Array.isArray(t.content)){for(let e of t.content)if("tool-result"===e.type&&"content"===e.output.type)for(let t of e.output.value)"file"===t.type&&o.push(t)}}let r=o.map(e=>{let t=e.mediaType,{data:a}=t$(e.data);return{mediaType:t,data:a}}).filter(e=>"url"===e.data.type).map(e=>({url:e.data.url,isUrlSupportedByModel:null!=e.mediaType&&(0,V.isUrlSupported)({url:e.data.url.toString(),mediaType:e.mediaType,supportedUrls:a})}));return Object.fromEntries((await t(r)).map((e,t)=>null==e?null:[r[t].url.toString(),{data:e.data,mediaType:e.mediaType}]).filter(e=>null!=e))}function tF(e,t){if("text"===e.type)return{type:"text",text:e.text,providerOptions:e.providerOptions};let{data:a,mediaType:o}=t$(e.data),r=null!=o?o:e.mediaType,n=a;if("url"===n.type){let e=t[n.url.toString()];e&&(n={type:"data",data:e.data},null==e.mediaType||null!=r&&(0,V.isFullMediaType)(r)||(r=e.mediaType))}if("data"===n.type&&(n.data instanceof Uint8Array||"string"==typeof n.data)){let e=(0,V.detectMediaType)({data:n.data,topLevelType:"image"});null!=e&&(r=e)}if(null==r)throw Error("Media type is missing for file part");return{type:"file",mediaType:r,filename:e.filename,data:n,providerOptions:e.providerOptions}}function tW({output:e,provider:t,warnings:a=[],downloadedAssets:o}){return"content"!==e.type?e:{type:"content",value:e.value.map(e=>{var r;switch(e.type){case"file":{let t=tF(e,o);if("file"!==t.type)throw Error("Expected tool result file content to convert to file.");return t}case"file-data":return a.push({type:"deprecated",setting:'"tool-result" content of type "file-data"',message:'The "file-data" type for tool result content is deprecated. Use the "file" type with mediaType and { type: \'data\', data } instead.'}),{type:"file",data:{type:"data",data:e.data},filename:e.filename,mediaType:e.mediaType,providerOptions:e.providerOptions};case"file-url":{let t=null!=(r=e.mediaType)?r:function(e,t="application/octet-stream"){var a;try{let t=new URL(e).pathname,o=null==(a=t.split(".").pop())?void 0:a.toLowerCase();if(o&&Object.hasOwn(tB,o))return tB[o]}catch(e){}return t}(e.url),o='The "file-url" type for tool result content is deprecated. Use the "file" type with mediaType and { type: \'url\', url } instead.';if(!e.mediaType){let a="application/octet-stream"===t?"Unable to infer media type from URL. Defaulting to 'application/octet-stream'.":`Inferred media type '${t}' from URL.`;o=`The "file-url" tool result content part with URL "${e.url}" is missing a "mediaType". ${a} ${o}`}return a.push({type:"deprecated",setting:'"tool-result" content of type "file-url"',message:o}),{type:"file",data:{type:"url",url:new URL(e.url)},mediaType:t,providerOptions:e.providerOptions}}case"file-id":return a.push({type:"deprecated",setting:'"tool-result" content of type "file-id"',message:'The "file-id" type for tool result content is deprecated. Use the "file" type with mediaType and { type: \'reference\', reference } instead.'}),{type:"file",data:{type:"reference",reference:tV({fileId:e.fileId,provider:t})},mediaType:"application",providerOptions:e.providerOptions};case"file-reference":return a.push({type:"deprecated",setting:'"tool-result" content of type "file-reference"',message:'The "file-reference" type for tool result content is deprecated. Use the "file" type with mediaType and { type: \'reference\', reference } instead.'}),{type:"file",data:{type:"reference",reference:e.providerReference},mediaType:"application",providerOptions:e.providerOptions};case"image-data":return a.push({type:"deprecated",setting:'"tool-result" content of type "image-data"',message:'The "image-data" type for tool result content is deprecated. Use the "file" type with mediaType and { type: \'data\', data } instead.'}),{type:"file",data:{type:"data",data:e.data},mediaType:e.mediaType,providerOptions:e.providerOptions};case"image-url":return a.push({type:"deprecated",setting:'"tool-result" content of type "image-url"',message:"The \"image-url\" type for tool result content is deprecated. Use the \"file\" type with mediaType 'image' (or a specific image/* subtype) and { type: 'url', url } instead."}),{type:"file",data:{type:"url",url:new URL(e.url)},mediaType:"image",providerOptions:e.providerOptions};case"image-file-id":return a.push({type:"deprecated",setting:'"tool-result" content of type "image-file-id"',message:'The "image-file-id" type for tool result content is deprecated. Use the "file" type with mediaType and { type: \'reference\', reference } instead.'}),{type:"file",data:{type:"reference",reference:tV({fileId:e.fileId,provider:t})},mediaType:"image",providerOptions:e.providerOptions};case"image-file-reference":return a.push({type:"deprecated",setting:'"tool-result" content of type "image-file-reference"',message:'The "image-file-reference" type for tool result content is deprecated. Use the "file" type with mediaType and { type: \'reference\', reference } instead.'}),{type:"file",data:{type:"reference",reference:e.providerReference},mediaType:"image",providerOptions:e.providerOptions};default:return e}})}}function tV({fileId:e,provider:t}){if("object"==typeof e)return e;if(null==t)throw Error("Cannot convert string fileId to provider reference without a provider ID. Use a Record<string, string> fileId or switch to the file-reference type.");return{[t]:e}}var tB={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",avif:"image/avif",heic:"image/heic",bmp:"image/bmp",tiff:"image/tiff",tif:"image/tiff",pdf:"application/pdf",mp4:"video/mp4",webm:"video/webm",mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg"};async function tK({toolCallId:e,input:t,output:a,tool:o,errorMode:r}){return"text"===r?{type:"error-text",value:(0,B.getErrorMessage)(a)}:"json"===r?{type:"error-json",value:tY(a)}:(null==o?void 0:o.toModelOutput)?await o.toModelOutput({toolCallId:e,input:t,output:a}):"string"==typeof a?{type:"text",value:a}:{type:"json",value:tY(a)}}function tY(e){return void 0===e?null:e}function tG({maxOutputTokens:e,temperature:t,topP:a,topK:o,presencePenalty:r,frequencyPenalty:n,seed:i,stopSequences:l,reasoning:s}){if(null!=e){if(!Number.isInteger(e))throw new J({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be an integer"});if(e<1)throw new J({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be >= 1"})}if(null!=t&&"number"!=typeof t)throw new J({parameter:"temperature",value:t,message:"temperature must be a number"});if(null!=a&&"number"!=typeof a)throw new J({parameter:"topP",value:a,message:"topP must be a number"});if(null!=o&&"number"!=typeof o)throw new J({parameter:"topK",value:o,message:"topK must be a number"});if(null!=r&&"number"!=typeof r)throw new J({parameter:"presencePenalty",value:r,message:"presencePenalty must be a number"});if(null!=n&&"number"!=typeof n)throw new J({parameter:"frequencyPenalty",value:n,message:"frequencyPenalty must be a number"});if(null!=i&&!Number.isInteger(i))throw new J({parameter:"seed",value:i,message:"seed must be an integer"});return{maxOutputTokens:e,temperature:t,topP:a,topK:o,presencePenalty:r,frequencyPenalty:n,stopSequences:l,seed:i,reasoning:s}}function tz({toolChoice:e}){return null==e?{type:"auto"}:"string"==typeof e?{type:e}:{type:"tool",toolName:e.toolName}}async function tH({tools:e,toolOrder:t,toolsContext:a={},experimental_sandbox:o}){if(!(null!=e&&Object.keys(e).length>0))return;let r=[];for(let[n,i]of function({tools:e,toolOrder:t}){if(null==t)return Object.entries(e);let a=Object.entries(e);return[...a.filter(([e])=>t.includes(e)).sort(([e],[a])=>t.indexOf(e)-t.indexOf(a)),...a.filter(([e])=>!t.includes(e)).sort(([e],[t])=>e<t?-1:+(e>t))]}({tools:e,toolOrder:t})){let e=i.type;switch(e){case void 0:case"dynamic":case"function":{let e=function({tool:e,toolName:t,toolsContext:a,experimental_sandbox:o}){return void 0===e.description?void 0:"string"==typeof e.description?e.description:e.description({context:a[t],experimental_sandbox:o})}({tool:i,toolName:n,toolsContext:a,experimental_sandbox:o}),t=i.providerOptions,l=i.inputExamples,s=i.strict;r.push({type:"function",name:n,inputSchema:await (0,V.asSchema)(i.inputSchema).jsonSchema,...null!=e?{description:e}:{},...null!=l?{inputExamples:l}:{},...null!=t?{providerOptions:t}:{},...null!=s?{strict:s}:{}});break}case"provider":r.push({type:"provider",name:n,id:i.id,args:i.args});break;default:throw Error(`Unsupported tool type: ${e}`)}}return r}function tJ(e){if(null!=e)return"number"==typeof e?e:e.totalMs}function tX(e){if(null!=e&&"number"!=typeof e)return e.stepMs}function tQ(e){if(null!=e&&"number"!=typeof e)return e.firstChunkMs}function tZ(e){if(null!=e&&"number"!=typeof e)return e.chunkMs}var t0={array:K.array,boolean:K.boolean,custom:K.custom,discriminatedUnion:K.discriminatedUnion,enum:K.enum,instanceof:K.instanceof,lazy:K.lazy,literal:K.literal,looseObject:K.looseObject,never:K.never,null:K.null,number:K.number,object:K.object,record:K.record,string:K.string,union:K.union,unknown:K.unknown},t1=t0.lazy(()=>t0.union([t0.null(),t0.string(),t0.number(),t0.boolean(),t0.record(t0.string(),t1.optional()),t0.array(t1)])),t4=t0.record(t0.string(),t0.record(t0.string(),t1.optional())),t8=t0.union([t0.string(),t0.instanceof(Uint8Array),t0.instanceof(ArrayBuffer),t0.custom(V.isBuffer,{message:"Must be a Buffer"})]),t3=t0.record(t0.string(),t0.string()),t2=t0.object({type:t0.literal("text"),text:t0.string(),providerOptions:t4.optional()}),t6=t0.object({type:t0.literal("image"),image:t0.union([t8,t0.instanceof(URL),t3]),mediaType:t0.string().optional(),providerOptions:t4.optional()}),t7=t0.discriminatedUnion("type",[t0.object({type:t0.literal("data"),data:t8}),t0.object({type:t0.literal("url"),url:t0.instanceof(URL)}),t0.object({type:t0.literal("reference"),reference:t3}),t0.object({type:t0.literal("text"),text:t0.string()})]),t9=t0.discriminatedUnion("type",[t0.object({type:t0.literal("data"),data:t8}),t0.object({type:t0.literal("url"),url:t0.instanceof(URL)})]),t5=t0.object({type:t0.literal("file"),data:t0.union([t7,t8,t0.instanceof(URL),t3]),filename:t0.string().optional(),mediaType:t0.string(),providerOptions:t4.optional()}),ae=t0.object({type:t0.literal("reasoning"),text:t0.string(),providerOptions:t4.optional()}),at=t0.object({type:t0.literal("custom"),kind:t0.string().transform(e=>e),providerOptions:t4.optional()}),aa=t0.object({type:t0.literal("reasoning-file"),data:t0.union([t9,t8,t0.instanceof(URL)]),mediaType:t0.string(),providerOptions:t4.optional()}),ao=t0.object({type:t0.literal("tool-call"),toolCallId:t0.string(),toolName:t0.string(),input:t0.unknown(),providerOptions:t4.optional(),providerExecuted:t0.boolean().optional()}),ar=t0.discriminatedUnion("type",[t0.object({type:t0.literal("text"),value:t0.string(),providerOptions:t4.optional()}),t0.object({type:t0.literal("json"),value:t1,providerOptions:t4.optional()}),t0.object({type:t0.literal("execution-denied"),reason:t0.string().optional(),providerOptions:t4.optional()}),t0.object({type:t0.literal("error-text"),value:t0.string(),providerOptions:t4.optional()}),t0.object({type:t0.literal("error-json"),value:t1,providerOptions:t4.optional()}),t0.object({type:t0.literal("content"),value:t0.array(t0.union([t0.object({type:t0.literal("text"),text:t0.string(),providerOptions:t4.optional()}),t0.object({type:t0.literal("file"),data:t7,mediaType:t0.string(),filename:t0.string().optional(),providerOptions:t4.optional()}),t0.object({type:t0.literal("file-data"),data:t0.string(),mediaType:t0.string(),filename:t0.string().optional(),providerOptions:t4.optional()}),t0.object({type:t0.literal("file-url"),url:t0.string(),mediaType:t0.string().optional(),providerOptions:t4.optional()}),t0.object({type:t0.literal("file-id"),fileId:t0.union([t0.string(),t0.record(t0.string(),t0.string())]),providerOptions:t4.optional()}),t0.object({type:t0.literal("file-reference"),providerReference:t0.record(t0.string(),t0.string()),providerOptions:t4.optional()}),t0.object({type:t0.literal("image-data"),data:t0.string(),mediaType:t0.string(),providerOptions:t4.optional()}),t0.object({type:t0.literal("image-url"),url:t0.string(),providerOptions:t4.optional()}),t0.object({type:t0.literal("image-file-id"),fileId:t0.union([t0.string(),t0.record(t0.string(),t0.string())]),providerOptions:t4.optional()}),t0.object({type:t0.literal("image-file-reference"),providerReference:t0.record(t0.string(),t0.string()),providerOptions:t4.optional()}),t0.object({type:t0.literal("custom"),providerOptions:t4.optional()})]))})]),an=t0.object({type:t0.literal("tool-result"),toolCallId:t0.string(),toolName:t0.string(),output:ar,providerOptions:t4.optional()}),ai=t0.object({type:t0.literal("tool-approval-request"),approvalId:t0.string(),toolCallId:t0.string(),reason:t0.string().optional()}),al=t0.object({type:t0.literal("tool-approval-response"),approvalId:t0.string(),approved:t0.boolean(),reason:t0.string().optional()}),as=t0.object({role:t0.literal("system"),content:t0.string(),providerOptions:t4.optional()}),au=t0.object({role:t0.literal("user"),content:t0.union([t0.string(),t0.array(t0.union([t2,t6,t5]))]),providerOptions:t4.optional()}),ad=t0.object({role:t0.literal("assistant"),content:t0.union([t0.string(),t0.array(t0.union([t2,at,t5,ae,aa,ao,an,ai]))]),providerOptions:t4.optional()}),ap=t0.object({role:t0.literal("tool"),content:t0.array(t0.union([an,al])),providerOptions:t4.optional()}),ac=t0.union([as,au,ad,ap]);async function am({allowSystemInMessages:e=!1,system:t,instructions:a=t,prompt:o,messages:r}){if(null==o&&null==r)throw new B.InvalidPromptError({prompt:o,message:"prompt or messages must be defined"});if(null!=o&&null!=r)throw new B.InvalidPromptError({prompt:o,message:"prompt and messages cannot be defined at the same time"});if("string"!=typeof a&&!(0,V.asArray)(a).every(e=>"system"===e.role))throw new B.InvalidPromptError({prompt:o,message:"instructions must be a string, SystemModelMessage, or array of SystemModelMessage"});if(null!=o&&"string"==typeof o)r=[{role:"user",content:o}];else if(null!=o&&Array.isArray(o))r=o;else if(null==r)throw new B.InvalidPromptError({prompt:o,message:"prompt or messages must be defined"});if(0===r.length)throw new B.InvalidPromptError({prompt:o,message:"messages must not be empty"});if(!e&&r.some(e=>"system"===e.role))throw new B.InvalidPromptError({prompt:o,message:"System messages are not allowed in the prompt or messages fields. Use the instructions option instead."});let n=await (0,V.safeValidateTypes)({value:r,schema:t0.array(ac)});if(!n.success)throw new B.InvalidPromptError({prompt:o,message:"The messages do not match the ModelMessage[] schema.",cause:n.error});return{messages:r,instructions:a}}function af(e){if(!W.GatewayAuthenticationError.isInstance(e))return e;let t="https://ai-sdk.dev/unauthenticated-ai-gateway";return(null==process?void 0:"production")==="production"?new B.AISDKError({name:"GatewayError",message:`Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${t}`}):Object.assign(Error(`\x1b[1m\x1b[31mUnauthenticated request to AI Gateway.\x1b[0m
22
26
 
23
27
  To authenticate, set the \x1b[33mAI_GATEWAY_API_KEY\x1b[0m environment variable with your API key.
24
28