@mastra/server 1.80.0-alpha.3 → 1.80.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (475) hide show
  1. package/dist/_types/@internal_core/dist/storage/index.d.ts +0 -12
  2. package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/request-context/index.d.ts +0 -2
  3. package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/routes/index.d.ts +0 -2
  4. package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/types/index.d.ts +0 -2
  5. package/dist/_types/@mastra_schema-compat/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +65 -13
  6. package/dist/_types/@mastra_schema-compat/dist/_types/@internal_ai-v6/dist/index.d.ts +110 -35
  7. package/dist/{a2a-DKGBctKT.js → a2a-B2K45wEY.js} +13 -21
  8. package/dist/{a2a-DKGBctKT.js.map → a2a-B2K45wEY.js.map} +1 -1
  9. package/dist/{a2a-BKtK_s5o.cjs → a2a-BUOtgjP-.cjs} +14 -22
  10. package/dist/{a2a-BKtK_s5o.cjs.map → a2a-BUOtgjP-.cjs.map} +1 -1
  11. package/dist/{a2a-CBl-c-lm.cjs → a2a-BsBYrosr.cjs} +2 -3
  12. package/dist/{a2a-CBl-c-lm.cjs.map → a2a-BsBYrosr.cjs.map} +1 -1
  13. package/dist/{a2a-BS0gTQk3.js → a2a-C3ClP3C2.js} +2 -3
  14. package/dist/{a2a-BS0gTQk3.js.map → a2a-C3ClP3C2.js.map} +1 -1
  15. package/dist/{agent-builder-DDYdQvlQ.cjs → agent-builder-9-GSvpgR.cjs} +3 -4
  16. package/dist/{agent-builder-DDYdQvlQ.cjs.map → agent-builder-9-GSvpgR.cjs.map} +1 -1
  17. package/dist/{agent-builder-C-U5USc5.js → agent-builder-BEhoRLS_.js} +12 -13
  18. package/dist/{agent-builder-C-U5USc5.js.map → agent-builder-BEhoRLS_.js.map} +1 -1
  19. package/dist/{agent-builder-us2nwcWc.cjs → agent-builder-CTHPsm8d.cjs} +12 -13
  20. package/dist/{agent-builder-us2nwcWc.cjs.map → agent-builder-CTHPsm8d.cjs.map} +1 -1
  21. package/dist/{agent-builder-B8kc4OBs.js → agent-builder-Cr-52Ulb.js} +3 -4
  22. package/dist/{agent-builder-B8kc4OBs.js.map → agent-builder-Cr-52Ulb.js.map} +1 -1
  23. package/dist/{agent-versions-CzXJWn1T.cjs → agent-versions-De5bRBaa.cjs} +5 -6
  24. package/dist/{agent-versions-CzXJWn1T.cjs.map → agent-versions-De5bRBaa.cjs.map} +1 -1
  25. package/dist/{agent-versions-W600H1ME.js → agent-versions-Pa-ABszp.js} +5 -6
  26. package/dist/{agent-versions-W600H1ME.js.map → agent-versions-Pa-ABszp.js.map} +1 -1
  27. package/dist/{agents-D1-fgNeb.js → agents-A-ahR0eQ.js} +5 -6
  28. package/dist/{agents-D1-fgNeb.js.map → agents-A-ahR0eQ.js.map} +1 -1
  29. package/dist/{agents-BYE5Dmfk.js → agents-DSZgApzs.js} +12 -13
  30. package/dist/{agents-BYE5Dmfk.js.map → agents-DSZgApzs.js.map} +1 -1
  31. package/dist/{agents-AyHEkc2F.cjs → agents-I0TVb_TM.cjs} +13 -14
  32. package/dist/{agents-AyHEkc2F.cjs.map → agents-I0TVb_TM.cjs.map} +1 -1
  33. package/dist/{agents-B1EiIdRs.cjs → agents-vFpMvK3w.cjs} +5 -6
  34. package/dist/{agents-B1EiIdRs.cjs.map → agents-vFpMvK3w.cjs.map} +1 -1
  35. package/dist/{api-schema-manifest-BaF6TE9d.cjs → api-schema-manifest-DCuGBEO0.cjs} +5 -6
  36. package/dist/{api-schema-manifest-BaF6TE9d.cjs.map → api-schema-manifest-DCuGBEO0.cjs.map} +1 -1
  37. package/dist/{api-schema-manifest-A066IsPX.js → api-schema-manifest-j2xurBb0.js} +4 -5
  38. package/dist/{api-schema-manifest-A066IsPX.js.map → api-schema-manifest-j2xurBb0.js.map} +1 -1
  39. package/dist/{auth-B8fQdEg-.cjs → auth-CM5AgF9l.cjs} +2 -3
  40. package/dist/{auth-B8fQdEg-.cjs.map → auth-CM5AgF9l.cjs.map} +1 -1
  41. package/dist/{auth-CZFXpwba.js → auth-CjT_a76k.js} +2 -3
  42. package/dist/{auth-CZFXpwba.js.map → auth-CjT_a76k.js.map} +1 -1
  43. package/dist/{background-tasks-B3VAKTJh.cjs → background-tasks-BMVUFtVh.cjs} +7 -9
  44. package/dist/{background-tasks-B3VAKTJh.cjs.map → background-tasks-BMVUFtVh.cjs.map} +1 -1
  45. package/dist/{background-tasks-Du2zYOPl.js → background-tasks-CFkXHgyQ.js} +7 -9
  46. package/dist/{background-tasks-Du2zYOPl.js.map → background-tasks-CFkXHgyQ.js.map} +1 -1
  47. package/dist/{builder-registry-DLdu9bWH.js → builder-registry-CtGv0Gj6.js} +7 -9
  48. package/dist/{builder-registry-DLdu9bWH.js.map → builder-registry-CtGv0Gj6.js.map} +1 -1
  49. package/dist/{builder-registry-DaFAaMTf.cjs → builder-registry-DWusXgse.cjs} +7 -9
  50. package/dist/{builder-registry-DaFAaMTf.cjs.map → builder-registry-DWusXgse.cjs.map} +1 -1
  51. package/dist/{channels-BnVRmnzK.cjs → channels-EqvuQQbv.cjs} +6 -8
  52. package/dist/{channels-BnVRmnzK.cjs.map → channels-EqvuQQbv.cjs.map} +1 -1
  53. package/dist/{channels-Db-4pXVZ.js → channels-LNR2QIkc.js} +6 -8
  54. package/dist/{channels-Db-4pXVZ.js.map → channels-LNR2QIkc.js.map} +1 -1
  55. package/dist/{common-DhKNoXGp.cjs → common-DVZqSEhZ.cjs} +2 -3
  56. package/dist/{common-DhKNoXGp.cjs.map → common-DVZqSEhZ.cjs.map} +1 -1
  57. package/dist/{common-Y30XtCyr.js → common-xUmaFUop.js} +2 -3
  58. package/dist/{common-Y30XtCyr.js.map → common-xUmaFUop.js.map} +1 -1
  59. package/dist/{constants-e7aaPCLj.cjs → constants-Co1XjPjd.cjs} +2 -3
  60. package/dist/{constants-e7aaPCLj.cjs.map → constants-Co1XjPjd.cjs.map} +1 -1
  61. package/dist/{constants-DazK_RZj.js → constants-ohUUT3Vg.js} +2 -3
  62. package/dist/{constants-DazK_RZj.js.map → constants-ohUUT3Vg.js.map} +1 -1
  63. package/dist/{conversations-DasqEDCF.cjs → conversations-BPQNrv5g.cjs} +5 -6
  64. package/dist/{conversations-DasqEDCF.cjs.map → conversations-BPQNrv5g.cjs.map} +1 -1
  65. package/dist/{conversations-DzuWI3w-.cjs → conversations-BSYZlASE.cjs} +8 -9
  66. package/dist/{conversations-DzuWI3w-.cjs.map → conversations-BSYZlASE.cjs.map} +1 -1
  67. package/dist/{conversations-D-ew5IXn.js → conversations-BfBS1UwQ.js} +8 -9
  68. package/dist/{conversations-D-ew5IXn.js.map → conversations-BfBS1UwQ.js.map} +1 -1
  69. package/dist/{conversations-BzBHVFYe.js → conversations-nNko6-H4.js} +4 -5
  70. package/dist/{conversations-BzBHVFYe.js.map → conversations-nNko6-H4.js.map} +1 -1
  71. package/dist/{datasets-Cgtczd13.cjs → datasets-BP2O5CSR.cjs} +3 -4
  72. package/dist/{datasets-Cgtczd13.cjs.map → datasets-BP2O5CSR.cjs.map} +1 -1
  73. package/dist/{datasets-FRp69Mwv.js → datasets-hLmYapTk.js} +3 -4
  74. package/dist/{datasets-FRp69Mwv.js.map → datasets-hLmYapTk.js.map} +1 -1
  75. package/dist/{default-options-C7tykjLq.cjs → default-options-DRN81WEQ.cjs} +2 -3
  76. package/dist/{default-options-C7tykjLq.cjs.map → default-options-DRN81WEQ.cjs.map} +1 -1
  77. package/dist/{default-options-oSlrqpuP.js → default-options-Dir6CKnE.js} +2 -3
  78. package/dist/{default-options-oSlrqpuP.js.map → default-options-Dir6CKnE.js.map} +1 -1
  79. package/dist/{dist-lT2rqyY9.cjs → dist-36GZrEvk.cjs} +4 -5
  80. package/dist/{dist-lT2rqyY9.cjs.map → dist-36GZrEvk.cjs.map} +1 -1
  81. package/dist/{dist-CeTLA-e5.cjs → dist-BZGewCGq.cjs} +6 -10
  82. package/dist/{dist-CeTLA-e5.cjs.map → dist-BZGewCGq.cjs.map} +1 -1
  83. package/dist/{dist-Bo3GdQwf.cjs → dist-Bal15xNO.cjs} +5 -7
  84. package/dist/{dist-Bo3GdQwf.cjs.map → dist-Bal15xNO.cjs.map} +1 -1
  85. package/dist/{dist-DjkPkAzV.js → dist-CNjm6d2Q.js} +5 -8
  86. package/dist/{dist-DjkPkAzV.js.map → dist-CNjm6d2Q.js.map} +1 -1
  87. package/dist/{dist-DLld1qjf.js → dist-CVoi_Dov.js} +3 -4
  88. package/dist/{dist-DLld1qjf.js.map → dist-CVoi_Dov.js.map} +1 -1
  89. package/dist/{dist-CukR8zi9.cjs → dist-Cci9RRWj.cjs} +1518 -667
  90. package/dist/dist-Cci9RRWj.cjs.map +1 -0
  91. package/dist/{dist-DsrJXwic.cjs → dist-D02J6PZG.cjs} +4 -5
  92. package/dist/{dist-DsrJXwic.cjs.map → dist-D02J6PZG.cjs.map} +1 -1
  93. package/dist/{dist-CREG82cy.js → dist-DC9qnRcv.js} +3 -4
  94. package/dist/{dist-CREG82cy.js.map → dist-DC9qnRcv.js.map} +1 -1
  95. package/dist/dist-DJ3281Ve.cjs +3 -0
  96. package/dist/{dist-BIrQLUV9.js → dist-Dc0g0QSi.js} +4 -6
  97. package/dist/{dist-BIrQLUV9.js.map → dist-Dc0g0QSi.js.map} +1 -1
  98. package/dist/{dist-BBOnrL_A.js → dist-Dwfkbwzg.js} +3 -4
  99. package/dist/{dist-BBOnrL_A.js.map → dist-Dwfkbwzg.js.map} +1 -1
  100. package/dist/{dist-5TAg2f91.js → dist-bAoX6ick.js} +1512 -660
  101. package/dist/dist-bAoX6ick.js.map +1 -0
  102. package/dist/{dist-B9ery9Zw.cjs → dist-lG-fYW7-.cjs} +4 -5
  103. package/dist/{dist-B9ery9Zw.cjs.map → dist-lG-fYW7-.cjs.map} +1 -1
  104. package/dist/dist-t_05BTrR.js +1 -0
  105. package/dist/docs/SKILL.md +1 -1
  106. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  107. package/dist/docs/references/docs-server-custom-adapters.md +53 -1
  108. package/dist/docs/references/docs-server-custom-api-routes.md +2 -0
  109. package/dist/{dynamic-workflows-HwPX3mcf.cjs → dynamic-workflows-CpCkqM1g.cjs} +6 -8
  110. package/dist/{dynamic-workflows-HwPX3mcf.cjs.map → dynamic-workflows-CpCkqM1g.cjs.map} +1 -1
  111. package/dist/{dynamic-workflows-CTUO0SFu.js → dynamic-workflows-DDauBnDt.js} +6 -8
  112. package/dist/{dynamic-workflows-CTUO0SFu.js.map → dynamic-workflows-DDauBnDt.js.map} +1 -1
  113. package/dist/{editor-builder-BSBHrTzY.cjs → editor-builder-8li-nXor.cjs} +3 -4
  114. package/dist/{editor-builder-BSBHrTzY.cjs.map → editor-builder-8li-nXor.cjs.map} +1 -1
  115. package/dist/{editor-builder-DCrTMwA4.js → editor-builder-BCZy1ZH1.js} +3 -4
  116. package/dist/{editor-builder-DCrTMwA4.js.map → editor-builder-BCZy1ZH1.js.map} +1 -1
  117. package/dist/{editor-builder-Bibw1X4q.cjs → editor-builder-BXT6F3Hl.cjs} +7 -9
  118. package/dist/{editor-builder-Bibw1X4q.cjs.map → editor-builder-BXT6F3Hl.cjs.map} +1 -1
  119. package/dist/{editor-builder-Dq03QZzH.js → editor-builder-Bywazgj1.js} +7 -9
  120. package/dist/{editor-builder-Dq03QZzH.js.map → editor-builder-Bywazgj1.js.map} +1 -1
  121. package/dist/{favorites-DWDyKxts.js → favorites-8aieznq3.js} +2 -3
  122. package/dist/{favorites-DWDyKxts.js.map → favorites-8aieznq3.js.map} +1 -1
  123. package/dist/{favorites-D1-AzGsK.cjs → favorites-D0CoxxQn.cjs} +2 -3
  124. package/dist/{favorites-D1-AzGsK.cjs.map → favorites-D0CoxxQn.cjs.map} +1 -1
  125. package/dist/{helpers-CewFtCva.cjs → helpers-CE1fJdLM.cjs} +6 -9
  126. package/dist/{helpers-CewFtCva.cjs.map → helpers-CE1fJdLM.cjs.map} +1 -1
  127. package/dist/{helpers-CxSa9O3X.js → helpers-CMCXsowL.js} +6 -9
  128. package/dist/{helpers-CxSa9O3X.js.map → helpers-CMCXsowL.js.map} +1 -1
  129. package/dist/{http-exception-CKDHupKw.cjs → http-exception-Co3MbFUf.cjs} +2 -3
  130. package/dist/{http-exception-CKDHupKw.cjs.map → http-exception-Co3MbFUf.cjs.map} +1 -1
  131. package/dist/{http-exception-CyfxZB6W.js → http-exception-CzaWkxMl.js} +2 -3
  132. package/dist/{http-exception-CyfxZB6W.js.map → http-exception-CzaWkxMl.js.map} +1 -1
  133. package/dist/index.cjs +2 -3
  134. package/dist/index.js +1 -2
  135. package/dist/{logs-CiSw7r0s.cjs → logs-BqHVVZBm.cjs} +7 -8
  136. package/dist/{logs-CiSw7r0s.cjs.map → logs-BqHVVZBm.cjs.map} +1 -1
  137. package/dist/{logs-CY8AGOCO.cjs → logs-CC6IycDY.cjs} +3 -4
  138. package/dist/{logs-CY8AGOCO.cjs.map → logs-CC6IycDY.cjs.map} +1 -1
  139. package/dist/{logs-CxfPk-iL.js → logs-Cbq2PiQG.js} +7 -8
  140. package/dist/{logs-CxfPk-iL.js.map → logs-Cbq2PiQG.js.map} +1 -1
  141. package/dist/{logs-Bd_xpsYw.js → logs-DpyTCDyt.js} +3 -4
  142. package/dist/{logs-Bd_xpsYw.js.map → logs-DpyTCDyt.js.map} +1 -1
  143. package/dist/{mcp-ziWVk7Ol.cjs → mcp-4iUBgZ7s.cjs} +3 -4
  144. package/dist/{mcp-ziWVk7Ol.cjs.map → mcp-4iUBgZ7s.cjs.map} +1 -1
  145. package/dist/{mcp-CWDfSu7w.js → mcp-CnV25lv0.js} +6 -7
  146. package/dist/{mcp-CWDfSu7w.js.map → mcp-CnV25lv0.js.map} +1 -1
  147. package/dist/{mcp-CWGJRqkC.cjs → mcp-DegWUDeB.cjs} +6 -7
  148. package/dist/{mcp-CWGJRqkC.cjs.map → mcp-DegWUDeB.cjs.map} +1 -1
  149. package/dist/{mcp-Drqt0GqD.js → mcp-DgdKiptb.js} +3 -4
  150. package/dist/{mcp-Drqt0GqD.js.map → mcp-DgdKiptb.js.map} +1 -1
  151. package/dist/{mcp-client-versions-DxBkzcYH.js → mcp-client-versions-B471u-DI.js} +3 -4
  152. package/dist/{mcp-client-versions-DxBkzcYH.js.map → mcp-client-versions-B471u-DI.js.map} +1 -1
  153. package/dist/{mcp-client-versions-Cq97zXiK.cjs → mcp-client-versions-HRTe5cRT.cjs} +3 -4
  154. package/dist/{mcp-client-versions-Cq97zXiK.cjs.map → mcp-client-versions-HRTe5cRT.cjs.map} +1 -1
  155. package/dist/{memory-CizEIbl1.cjs → memory-BnPGDrdg.cjs} +4 -5
  156. package/dist/{memory-CizEIbl1.cjs.map → memory-BnPGDrdg.cjs.map} +1 -1
  157. package/dist/{memory-B58Q2LgU.js → memory-CZ2ELVP0.js} +4 -5
  158. package/dist/{memory-B58Q2LgU.js.map → memory-CZ2ELVP0.js.map} +1 -1
  159. package/dist/{memory-BHtTSzvJ.js → memory-CtSwODLV.js} +7 -8
  160. package/dist/{memory-BHtTSzvJ.js.map → memory-CtSwODLV.js.map} +1 -1
  161. package/dist/{memory-CwwkVDh1.cjs → memory-dujCippo.cjs} +7 -8
  162. package/dist/{memory-CwwkVDh1.cjs.map → memory-dujCippo.cjs.map} +1 -1
  163. package/dist/{message-history-_kbQlA4r.js → message-history-BBVH-ORZ.js} +2 -3
  164. package/dist/{message-history-_kbQlA4r.js.map → message-history-BBVH-ORZ.js.map} +1 -1
  165. package/dist/{message-history-CkUYxSaS.cjs → message-history-CtELj716.cjs} +2 -3
  166. package/dist/{message-history-CkUYxSaS.cjs.map → message-history-CtELj716.cjs.map} +1 -1
  167. package/dist/{observability-Dz9jvMJ3.js → observability-65rZOqJk.js} +6 -7
  168. package/dist/{observability-Dz9jvMJ3.js.map → observability-65rZOqJk.js.map} +1 -1
  169. package/dist/{observability-C2BZQ2jU.cjs → observability-CFKSxaff.cjs} +6 -7
  170. package/dist/{observability-C2BZQ2jU.cjs.map → observability-CFKSxaff.cjs.map} +1 -1
  171. package/dist/{observability-new-endpoints-3DlTYf34.js → observability-new-endpoints-B6MRJ5Rb.js} +8 -11
  172. package/dist/observability-new-endpoints-B6MRJ5Rb.js.map +1 -0
  173. package/dist/{observability-new-endpoints-Drr7q2Dj.cjs → observability-new-endpoints-CDeHfFNP.cjs} +9 -12
  174. package/dist/observability-new-endpoints-CDeHfFNP.cjs.map +1 -0
  175. package/dist/{plans-DZAJG1Et.cjs → plans-CSLB_JKn.cjs} +8 -9
  176. package/dist/{plans-DZAJG1Et.cjs.map → plans-CSLB_JKn.cjs.map} +1 -1
  177. package/dist/{plans-CKbStbWl.js → plans-DToC_H5z.js} +8 -9
  178. package/dist/{plans-CKbStbWl.js.map → plans-DToC_H5z.js.map} +1 -1
  179. package/dist/{probe-image-size-l1uuhbob.cjs → probe-image-size-CTKFNI9H.cjs} +69 -120
  180. package/dist/probe-image-size-CTKFNI9H.cjs.map +1 -0
  181. package/dist/{probe-image-size-DBmo2MAe.js → probe-image-size-DnRk0ecb.js} +69 -120
  182. package/dist/probe-image-size-DnRk0ecb.js.map +1 -0
  183. package/dist/{processor-providers-DHvTA9AL.cjs → processor-providers-CRrcV9ra.cjs} +2 -3
  184. package/dist/{processor-providers-DHvTA9AL.cjs.map → processor-providers-CRrcV9ra.cjs.map} +1 -1
  185. package/dist/{processor-providers-DBhZC6-4.js → processor-providers-WHdDe4aA.js} +2 -3
  186. package/dist/{processor-providers-DBhZC6-4.js.map → processor-providers-WHdDe4aA.js.map} +1 -1
  187. package/dist/{processors-80HWq8nr.cjs → processors-BEut-2a-.cjs} +2 -3
  188. package/dist/{processors-80HWq8nr.cjs.map → processors-BEut-2a-.cjs.map} +1 -1
  189. package/dist/{processors-33IULT8X.js → processors-IhyRC0xH.js} +2 -3
  190. package/dist/{processors-33IULT8X.js.map → processors-IhyRC0xH.js.map} +1 -1
  191. package/dist/{prompt-block-versions-Cl3Lh4H-.cjs → prompt-block-versions-BUPyaY8g.cjs} +4 -5
  192. package/dist/{prompt-block-versions-Cl3Lh4H-.cjs.map → prompt-block-versions-BUPyaY8g.cjs.map} +1 -1
  193. package/dist/{prompt-block-versions-cfq_e1Zi.js → prompt-block-versions-D1gjBkQx.js} +4 -5
  194. package/dist/{prompt-block-versions-cfq_e1Zi.js.map → prompt-block-versions-D1gjBkQx.js.map} +1 -1
  195. package/dist/{responses-CfcIc53b.cjs → responses-CTiwnWeF.cjs} +3 -4
  196. package/dist/{responses-CfcIc53b.cjs.map → responses-CTiwnWeF.cjs.map} +1 -1
  197. package/dist/{responses-DJNJgCTg.js → responses-D-fsDRLd.js} +2 -3
  198. package/dist/{responses-DJNJgCTg.js.map → responses-D-fsDRLd.js.map} +1 -1
  199. package/dist/{responses-BubMB79l.cjs → responses-OoIIZ1g6.cjs} +8 -9
  200. package/dist/{responses-BubMB79l.cjs.map → responses-OoIIZ1g6.cjs.map} +1 -1
  201. package/dist/{responses-jiVC-1lx.js → responses-w6B0iv_t.js} +8 -9
  202. package/dist/{responses-jiVC-1lx.js.map → responses-w6B0iv_t.js.map} +1 -1
  203. package/dist/{rolldown-runtime-BwC_XMyb.cjs → rolldown-runtime-10nMEhjP.cjs} +1 -2
  204. package/dist/{rolldown-runtime-D3Hj5m0v.js → rolldown-runtime-CQI-hT2b.js} +1 -2
  205. package/dist/{route-builder-CjkWxv4E.js → route-builder-BxPrwNog.js} +6 -10
  206. package/dist/route-builder-BxPrwNog.js.map +1 -0
  207. package/dist/{route-builder-B2Qhhd7C.cjs → route-builder-CvARmqnA.cjs} +8 -12
  208. package/dist/route-builder-CvARmqnA.cjs.map +1 -0
  209. package/dist/{routes-DKV9oxFW.js → routes-CIjXlRu7.js} +59 -92
  210. package/dist/{routes-DKV9oxFW.js.map → routes-CIjXlRu7.js.map} +1 -1
  211. package/dist/{routes-jXksmX9G.cjs → routes-CtGp_lBn.cjs} +4 -7
  212. package/dist/routes-CtGp_lBn.cjs.map +1 -0
  213. package/dist/{routes-D6bDACPd.cjs → routes-KTxoRutQ.cjs} +59 -92
  214. package/dist/{routes-D6bDACPd.cjs.map → routes-KTxoRutQ.cjs.map} +1 -1
  215. package/dist/{routes-CKfXiwRc.js → routes-MRZFTKei.js} +4 -7
  216. package/dist/routes-MRZFTKei.js.map +1 -0
  217. package/dist/{rule-group-C5eydl98.js → rule-group-4pWeG61q.js} +2 -3
  218. package/dist/{rule-group-C5eydl98.js.map → rule-group-4pWeG61q.js.map} +1 -1
  219. package/dist/{rule-group-Hyn4rN52.cjs → rule-group-CIacr-Zz.cjs} +2 -3
  220. package/dist/{rule-group-Hyn4rN52.cjs.map → rule-group-CIacr-Zz.cjs.map} +1 -1
  221. package/dist/{schedules-GokZKBYg.cjs → schedules-CSkQFQwy.cjs} +6 -8
  222. package/dist/{schedules-GokZKBYg.cjs.map → schedules-CSkQFQwy.cjs.map} +1 -1
  223. package/dist/{schedules-_3zPKyqm.js → schedules-DfelziYe.js} +6 -8
  224. package/dist/{schedules-_3zPKyqm.js.map → schedules-DfelziYe.js.map} +1 -1
  225. package/dist/{schema-CzbEIyhE-BsMcj9Ws.js → schema-Bf12g7KC-DBc4NSds.js} +104 -35
  226. package/dist/schema-Bf12g7KC-DBc4NSds.js.map +1 -0
  227. package/dist/{schema-CzbEIyhE-20gGIWkz.cjs → schema-Bf12g7KC-plP4Ir6h.cjs} +105 -36
  228. package/dist/schema-Bf12g7KC-plP4Ir6h.cjs.map +1 -0
  229. package/dist/{scorer-versions-CX8RM9a6.js → scorer-versions-DIqKt2kn.js} +4 -5
  230. package/dist/{scorer-versions-CX8RM9a6.js.map → scorer-versions-DIqKt2kn.js.map} +1 -1
  231. package/dist/{scorer-versions-DeCS12ym.cjs → scorer-versions-r7C61gWf.cjs} +4 -5
  232. package/dist/{scorer-versions-DeCS12ym.cjs.map → scorer-versions-r7C61gWf.cjs.map} +1 -1
  233. package/dist/{scores-CetVKM4g.cjs → scores-Bu70OP1U.cjs} +3 -4
  234. package/dist/{scores-CetVKM4g.cjs.map → scores-Bu70OP1U.cjs.map} +1 -1
  235. package/dist/{scores-BbqFfKcy.js → scores-DZ1hftoG.js} +3 -4
  236. package/dist/{scores-BbqFfKcy.js.map → scores-DZ1hftoG.js.map} +1 -1
  237. package/dist/{scores-C8XPZcwt.cjs → scores-FzL-bpCC.cjs} +8 -9
  238. package/dist/{scores-C8XPZcwt.cjs.map → scores-FzL-bpCC.cjs.map} +1 -1
  239. package/dist/{scores-BWTo-_L5.js → scores-PdRDQNaC.js} +8 -9
  240. package/dist/{scores-BWTo-_L5.js.map → scores-PdRDQNaC.js.map} +1 -1
  241. package/dist/server/a2a/store.cjs +2 -3
  242. package/dist/server/a2a/store.js +1 -2
  243. package/dist/server/auth/index.cjs +3 -3
  244. package/dist/server/auth/index.js +2 -2
  245. package/dist/server/browser-stream/index.cjs +3 -5
  246. package/dist/server/browser-stream/index.cjs.map +1 -1
  247. package/dist/server/browser-stream/index.js +2 -4
  248. package/dist/server/browser-stream/index.js.map +1 -1
  249. package/dist/server/handlers/a2a.cjs +2 -2
  250. package/dist/server/handlers/a2a.js +1 -1
  251. package/dist/server/handlers/agent-builder.cjs +2 -2
  252. package/dist/server/handlers/agent-builder.js +1 -1
  253. package/dist/server/handlers/agent-controller.cjs +7 -8
  254. package/dist/server/handlers/agent-controller.js +6 -7
  255. package/dist/server/handlers/agent-versions.cjs +7 -8
  256. package/dist/server/handlers/agent-versions.js +6 -7
  257. package/dist/server/handlers/agents.cjs +2 -2
  258. package/dist/server/handlers/agents.js +1 -1
  259. package/dist/server/handlers/auth.cjs +7 -8
  260. package/dist/server/handlers/auth.js +6 -7
  261. package/dist/server/handlers/author-enrichment.cjs +2 -3
  262. package/dist/server/handlers/author-enrichment.js +1 -2
  263. package/dist/server/handlers/authorship.cjs +4 -5
  264. package/dist/server/handlers/authorship.js +3 -4
  265. package/dist/server/handlers/background-tasks.cjs +2 -2
  266. package/dist/server/handlers/background-tasks.js +1 -1
  267. package/dist/server/handlers/builder-registry.cjs +2 -2
  268. package/dist/server/handlers/builder-registry.js +1 -1
  269. package/dist/server/handlers/channels.cjs +2 -2
  270. package/dist/server/handlers/channels.js +1 -1
  271. package/dist/server/handlers/conversations.cjs +2 -2
  272. package/dist/server/handlers/conversations.js +1 -1
  273. package/dist/server/handlers/datasets.cjs +7 -8
  274. package/dist/server/handlers/datasets.js +6 -7
  275. package/dist/server/handlers/dynamic-workflows.cjs +2 -2
  276. package/dist/server/handlers/dynamic-workflows.js +1 -1
  277. package/dist/server/handlers/editor-builder.cjs +2 -2
  278. package/dist/server/handlers/editor-builder.js +1 -1
  279. package/dist/server/handlers/error.cjs +3 -4
  280. package/dist/server/handlers/error.js +2 -3
  281. package/dist/server/handlers/favorites-enrichment.cjs +3 -4
  282. package/dist/server/handlers/favorites-enrichment.js +2 -3
  283. package/dist/server/handlers/gateway-memory-client.cjs +2 -3
  284. package/dist/server/handlers/gateway-memory-client.js +1 -2
  285. package/dist/server/handlers/logs.cjs +2 -2
  286. package/dist/server/handlers/logs.js +1 -1
  287. package/dist/server/handlers/mcp-client-versions.cjs +6 -7
  288. package/dist/server/handlers/mcp-client-versions.js +5 -6
  289. package/dist/server/handlers/mcp.cjs +2 -2
  290. package/dist/server/handlers/mcp.js +1 -1
  291. package/dist/server/handlers/memory.cjs +2 -2
  292. package/dist/server/handlers/memory.js +1 -1
  293. package/dist/server/handlers/observability-list-query-schemas.cjs +2 -3
  294. package/dist/server/handlers/observability-list-query-schemas.js +1 -2
  295. package/dist/server/handlers/observability-new-endpoints.cjs +2 -2
  296. package/dist/server/handlers/observability-new-endpoints.js +1 -1
  297. package/dist/server/handlers/observability-shared.cjs +4 -5
  298. package/dist/server/handlers/observability-shared.js +3 -4
  299. package/dist/server/handlers/observability-storage-schemas.cjs +2 -3
  300. package/dist/server/handlers/observability-storage-schemas.js +1 -2
  301. package/dist/server/handlers/observability.cjs +3 -3
  302. package/dist/server/handlers/observability.js +2 -2
  303. package/dist/server/handlers/plans.cjs +2 -2
  304. package/dist/server/handlers/plans.js +1 -1
  305. package/dist/server/handlers/processor-providers.cjs +5 -6
  306. package/dist/server/handlers/processor-providers.js +4 -5
  307. package/dist/server/handlers/processors.cjs +5 -6
  308. package/dist/server/handlers/processors.js +4 -5
  309. package/dist/server/handlers/prompt-block-versions.cjs +6 -7
  310. package/dist/server/handlers/prompt-block-versions.js +5 -6
  311. package/dist/server/handlers/responses.adapter.cjs +2 -3
  312. package/dist/server/handlers/responses.adapter.js +1 -2
  313. package/dist/server/handlers/responses.cjs +2 -2
  314. package/dist/server/handlers/responses.js +1 -1
  315. package/dist/server/handlers/responses.storage.cjs +4 -5
  316. package/dist/server/handlers/responses.storage.js +3 -4
  317. package/dist/server/handlers/schedules-workflows-shim.cjs +2 -3
  318. package/dist/server/handlers/schedules-workflows-shim.js +1 -2
  319. package/dist/server/handlers/schedules.cjs +2 -2
  320. package/dist/server/handlers/schedules.js +1 -1
  321. package/dist/server/handlers/scorer-versions.cjs +6 -7
  322. package/dist/server/handlers/scorer-versions.js +5 -6
  323. package/dist/server/handlers/scores.cjs +2 -2
  324. package/dist/server/handlers/scores.js +1 -1
  325. package/dist/server/handlers/skills-sh-shared.cjs +3 -4
  326. package/dist/server/handlers/skills-sh-shared.js +2 -3
  327. package/dist/server/handlers/stored-agent-favorites.cjs +8 -9
  328. package/dist/server/handlers/stored-agent-favorites.js +7 -8
  329. package/dist/server/handlers/stored-agents.cjs +8 -9
  330. package/dist/server/handlers/stored-agents.js +7 -8
  331. package/dist/server/handlers/stored-mcp-clients.cjs +7 -8
  332. package/dist/server/handlers/stored-mcp-clients.js +6 -7
  333. package/dist/server/handlers/stored-prompt-blocks.cjs +7 -8
  334. package/dist/server/handlers/stored-prompt-blocks.js +6 -7
  335. package/dist/server/handlers/stored-scorers.cjs +7 -8
  336. package/dist/server/handlers/stored-scorers.js +6 -7
  337. package/dist/server/handlers/stored-skill-favorites.cjs +8 -9
  338. package/dist/server/handlers/stored-skill-favorites.js +7 -8
  339. package/dist/server/handlers/stored-skills.cjs +7 -8
  340. package/dist/server/handlers/stored-skills.js +6 -7
  341. package/dist/server/handlers/stored-workspaces.cjs +6 -7
  342. package/dist/server/handlers/stored-workspaces.js +5 -6
  343. package/dist/server/handlers/system.cjs +5 -6
  344. package/dist/server/handlers/system.js +4 -5
  345. package/dist/server/handlers/test-utils.cjs +2 -3
  346. package/dist/server/handlers/test-utils.js +1 -2
  347. package/dist/server/handlers/tool-providers.cjs +6 -7
  348. package/dist/server/handlers/tool-providers.js +5 -6
  349. package/dist/server/handlers/tool-schema-overrides.cjs +2 -3
  350. package/dist/server/handlers/tool-schema-overrides.js +1 -2
  351. package/dist/server/handlers/tools.cjs +2 -2
  352. package/dist/server/handlers/tools.js +1 -1
  353. package/dist/server/handlers/utils.cjs +2 -2
  354. package/dist/server/handlers/utils.js +1 -1
  355. package/dist/server/handlers/validate-agent-instructions.cjs +4 -5
  356. package/dist/server/handlers/validate-agent-instructions.js +3 -4
  357. package/dist/server/handlers/validate-avatar.cjs +3 -4
  358. package/dist/server/handlers/validate-avatar.js +2 -3
  359. package/dist/server/handlers/vector.cjs +2 -2
  360. package/dist/server/handlers/vector.js +1 -1
  361. package/dist/server/handlers/version-helpers.cjs +2 -3
  362. package/dist/server/handlers/version-helpers.js +1 -2
  363. package/dist/server/handlers/voice.cjs +2 -2
  364. package/dist/server/handlers/voice.js +1 -1
  365. package/dist/server/handlers/workflow-builder.cjs +2 -2
  366. package/dist/server/handlers/workflow-builder.js +1 -1
  367. package/dist/server/handlers/workflows.cjs +2 -2
  368. package/dist/server/handlers/workflows.js +1 -1
  369. package/dist/server/handlers/workspace.cjs +2 -2
  370. package/dist/server/handlers/workspace.js +1 -1
  371. package/dist/server/handlers.cjs +18 -18
  372. package/dist/server/handlers.js +17 -17
  373. package/dist/server/schemas/index.cjs +35 -35
  374. package/dist/server/schemas/index.js +34 -34
  375. package/dist/server/server-adapter/index.cjs +14 -21
  376. package/dist/server/server-adapter/index.cjs.map +1 -1
  377. package/dist/server/server-adapter/index.js +13 -20
  378. package/dist/server/server-adapter/index.js.map +1 -1
  379. package/dist/{stored-agents-BtaEzKfr.js → stored-agents-BpxMmhtz.js} +9 -11
  380. package/dist/{stored-agents-BtaEzKfr.js.map → stored-agents-BpxMmhtz.js.map} +1 -1
  381. package/dist/{stored-agents-BTL-o6aM.cjs → stored-agents-CDlh3CQQ.cjs} +9 -11
  382. package/dist/{stored-agents-BTL-o6aM.cjs.map → stored-agents-CDlh3CQQ.cjs.map} +1 -1
  383. package/dist/{stored-mcp-clients-D7bNkmTM.cjs → stored-mcp-clients-BA7OSGZ_.cjs} +3 -4
  384. package/dist/{stored-mcp-clients-D7bNkmTM.cjs.map → stored-mcp-clients-BA7OSGZ_.cjs.map} +1 -1
  385. package/dist/{stored-mcp-clients-DMR6NvCp.js → stored-mcp-clients-DtLv0Tly.js} +3 -4
  386. package/dist/{stored-mcp-clients-DMR6NvCp.js.map → stored-mcp-clients-DtLv0Tly.js.map} +1 -1
  387. package/dist/{stored-prompt-blocks-BjHxMCuC.cjs → stored-prompt-blocks-Cqi0vnTE.cjs} +4 -5
  388. package/dist/{stored-prompt-blocks-BjHxMCuC.cjs.map → stored-prompt-blocks-Cqi0vnTE.cjs.map} +1 -1
  389. package/dist/{stored-prompt-blocks-C7qmiWSB.js → stored-prompt-blocks-Z_BuhsUq.js} +4 -5
  390. package/dist/{stored-prompt-blocks-C7qmiWSB.js.map → stored-prompt-blocks-Z_BuhsUq.js.map} +1 -1
  391. package/dist/{stored-scorers-BSxh7JZX.js → stored-scorers-BdJadnUS.js} +4 -5
  392. package/dist/{stored-scorers-BSxh7JZX.js.map → stored-scorers-BdJadnUS.js.map} +1 -1
  393. package/dist/{stored-scorers-I8L1-bAI.cjs → stored-scorers-D1zYUEXg.cjs} +4 -5
  394. package/dist/{stored-scorers-I8L1-bAI.cjs.map → stored-scorers-D1zYUEXg.cjs.map} +1 -1
  395. package/dist/{stored-skills-DzW8hLnI.js → stored-skills-D8Q1NmsH.js} +3 -4
  396. package/dist/{stored-skills-DzW8hLnI.js.map → stored-skills-D8Q1NmsH.js.map} +1 -1
  397. package/dist/{stored-skills-C1e8kf2k.cjs → stored-skills-DppdzQY0.cjs} +3 -4
  398. package/dist/{stored-skills-C1e8kf2k.cjs.map → stored-skills-DppdzQY0.cjs.map} +1 -1
  399. package/dist/{stored-workspaces-DSfChCJ0.cjs → stored-workspaces-BOwJwkec.cjs} +3 -4
  400. package/dist/{stored-workspaces-DSfChCJ0.cjs.map → stored-workspaces-BOwJwkec.cjs.map} +1 -1
  401. package/dist/{stored-workspaces-AkC68rSw.js → stored-workspaces-CYXLBJy5.js} +3 -4
  402. package/dist/{stored-workspaces-AkC68rSw.js.map → stored-workspaces-CYXLBJy5.js.map} +1 -1
  403. package/dist/{system-sSSmmt7I.js → system-B8L_G4oo.js} +2 -3
  404. package/dist/{system-sSSmmt7I.js.map → system-B8L_G4oo.js.map} +1 -1
  405. package/dist/{system-B_Sod-Le.cjs → system-DGfJlOxK.cjs} +2 -3
  406. package/dist/{system-B_Sod-Le.cjs.map → system-DGfJlOxK.cjs.map} +1 -1
  407. package/dist/{tool-providers-DFQkhO4R.cjs → tool-providers-BVwRJTtB.cjs} +2 -3
  408. package/dist/{tool-providers-DFQkhO4R.cjs.map → tool-providers-BVwRJTtB.cjs.map} +1 -1
  409. package/dist/{tool-providers-CIESXi7M.js → tool-providers-Cq3vFqgE.js} +2 -3
  410. package/dist/{tool-providers-CIESXi7M.js.map → tool-providers-Cq3vFqgE.js.map} +1 -1
  411. package/dist/{tools-Ci71xxGP.cjs → tools-CottqeCZ.cjs} +12 -13
  412. package/dist/{tools-Ci71xxGP.cjs.map → tools-CottqeCZ.cjs.map} +1 -1
  413. package/dist/{tools--oMljfqq.js → tools-tMPXGAUO.js} +11 -12
  414. package/dist/{tools--oMljfqq.js.map → tools-tMPXGAUO.js.map} +1 -1
  415. package/dist/{utils-dDLIDg8O.cjs → utils-1UlUJRyC.cjs} +6 -8
  416. package/dist/{utils-dDLIDg8O.cjs.map → utils-1UlUJRyC.cjs.map} +1 -1
  417. package/dist/{utils-CF76qzZR.cjs → utils-BnH77wPf.cjs} +107 -81
  418. package/dist/utils-BnH77wPf.cjs.map +1 -0
  419. package/dist/{utils-BBJlS81s.js → utils-DEwjGOpJ.js} +5 -7
  420. package/dist/{utils-BBJlS81s.js.map → utils-DEwjGOpJ.js.map} +1 -1
  421. package/dist/{utils-aoLN3Wfi.js → utils-YEuwVEc2.js} +104 -78
  422. package/dist/utils-YEuwVEc2.js.map +1 -0
  423. package/dist/{vector-TWv4t-4g.js → vector-Deod39jt.js} +6 -7
  424. package/dist/{vector-TWv4t-4g.js.map → vector-Deod39jt.js.map} +1 -1
  425. package/dist/{vector-BKDD1kwc.cjs → vector-IxK1t4Cb.cjs} +6 -7
  426. package/dist/{vector-BKDD1kwc.cjs.map → vector-IxK1t4Cb.cjs.map} +1 -1
  427. package/dist/{vectors-LFI1jch0.cjs → vectors-CqV387sY.cjs} +3 -4
  428. package/dist/{vectors-LFI1jch0.cjs.map → vectors-CqV387sY.cjs.map} +1 -1
  429. package/dist/{vectors-CJtupgIF.js → vectors-CvHLWqjC.js} +3 -4
  430. package/dist/{vectors-CJtupgIF.js.map → vectors-CvHLWqjC.js.map} +1 -1
  431. package/dist/{version-common-DrzXq7Ct.cjs → version-common-B2n_ML_w.cjs} +3 -4
  432. package/dist/{version-common-DrzXq7Ct.cjs.map → version-common-B2n_ML_w.cjs.map} +1 -1
  433. package/dist/{version-common-4xFzvCS5.js → version-common-Di2U8VWH.js} +3 -4
  434. package/dist/{version-common-4xFzvCS5.js.map → version-common-Di2U8VWH.js.map} +1 -1
  435. package/dist/{voice-BnGwlZ75.cjs → voice-CBbxcsCM.cjs} +4 -5
  436. package/dist/{voice-BnGwlZ75.cjs.map → voice-CBbxcsCM.cjs.map} +1 -1
  437. package/dist/{voice-DjG8tBAD.js → voice-CzFWhWPJ.js} +4 -5
  438. package/dist/{voice-DjG8tBAD.js.map → voice-CzFWhWPJ.js.map} +1 -1
  439. package/dist/{workflow-builder-BoI-XXsT.js → workflow-builder-BcVfkods.js} +8 -10
  440. package/dist/{workflow-builder-BoI-XXsT.js.map → workflow-builder-BcVfkods.js.map} +1 -1
  441. package/dist/{workflow-builder-Dguv4rc0.cjs → workflow-builder-CJEajbkw.cjs} +8 -10
  442. package/dist/{workflow-builder-Dguv4rc0.cjs.map → workflow-builder-CJEajbkw.cjs.map} +1 -1
  443. package/dist/{workflows-D7Oq5On9.js → workflows-BjLruwQB.js} +10 -11
  444. package/dist/{workflows-D7Oq5On9.js.map → workflows-BjLruwQB.js.map} +1 -1
  445. package/dist/{workflows-Dcx4Ib0t.js → workflows-C9BMJV_C.js} +3 -4
  446. package/dist/{workflows-Dcx4Ib0t.js.map → workflows-C9BMJV_C.js.map} +1 -1
  447. package/dist/{workflows-5AytZqK_.cjs → workflows-CxPsDCnW.cjs} +10 -11
  448. package/dist/{workflows-5AytZqK_.cjs.map → workflows-CxPsDCnW.cjs.map} +1 -1
  449. package/dist/{workflows-C8rDpHyY.cjs → workflows-SYBpQupF.cjs} +3 -4
  450. package/dist/{workflows-C8rDpHyY.cjs.map → workflows-SYBpQupF.cjs.map} +1 -1
  451. package/dist/{workspace-BVHXoKmP.js → workspace-C9dE6D1U.js} +6 -7
  452. package/dist/{workspace-BVHXoKmP.js.map → workspace-C9dE6D1U.js.map} +1 -1
  453. package/dist/{workspace-d25MZ9dj.cjs → workspace-CyH_iu8w.cjs} +6 -7
  454. package/dist/{workspace-d25MZ9dj.cjs.map → workspace-CyH_iu8w.cjs.map} +1 -1
  455. package/dist/{workspace-BJYV2lkt.cjs → workspace-KeHGZvNV.cjs} +2 -3
  456. package/dist/{workspace-BJYV2lkt.cjs.map → workspace-KeHGZvNV.cjs.map} +1 -1
  457. package/dist/{workspace-4dBGFdV2.js → workspace-muaSMxVS.js} +2 -3
  458. package/dist/{workspace-4dBGFdV2.js.map → workspace-muaSMxVS.js.map} +1 -1
  459. package/package.json +10 -10
  460. package/dist/dist-5TAg2f91.js.map +0 -1
  461. package/dist/dist-C9Jwt1f0.cjs +0 -3
  462. package/dist/dist-CukR8zi9.cjs.map +0 -1
  463. package/dist/dist-Dgae8Imb.js +0 -1
  464. package/dist/observability-new-endpoints-3DlTYf34.js.map +0 -1
  465. package/dist/observability-new-endpoints-Drr7q2Dj.cjs.map +0 -1
  466. package/dist/probe-image-size-DBmo2MAe.js.map +0 -1
  467. package/dist/probe-image-size-l1uuhbob.cjs.map +0 -1
  468. package/dist/route-builder-B2Qhhd7C.cjs.map +0 -1
  469. package/dist/route-builder-CjkWxv4E.js.map +0 -1
  470. package/dist/routes-CKfXiwRc.js.map +0 -1
  471. package/dist/routes-jXksmX9G.cjs.map +0 -1
  472. package/dist/schema-CzbEIyhE-20gGIWkz.cjs.map +0 -1
  473. package/dist/schema-CzbEIyhE-BsMcj9Ws.js.map +0 -1
  474. package/dist/utils-CF76qzZR.cjs.map +0 -1
  475. package/dist/utils-aoLN3Wfi.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { i as __require, o as __toESM$1, t as __commonJSMin$1 } from "./rolldown-runtime-D3Hj5m0v.js";
2
- import { n as standardSchemaToJSONSchema, r as toStandardSchema$5, t as isStandardSchemaWithJSON$1 } from "./schema-CzbEIyhE-BsMcj9Ws.js";
3
- import "./utils-aoLN3Wfi.js";
4
- import { _ as InvalidPromptError, a as createEventSourceResponseHandler$3, b as TooManyEmbeddingValuesForCallError, c as generateId, d as parseProviderOptions$1, f as postFormDataToApi, g as APICallError$4, h as withoutTrailingSlash$3, i as createBinaryResponseHandler, l as isParsableJson, n as convertBase64ToUint8Array$1, o as createJsonErrorResponseHandler$3, p as postJsonToApi$3, r as convertUint8ArrayToBase64$2, s as createJsonResponseHandler$3, t as combineHeaders$3, u as loadApiKey, v as InvalidResponseDataError$1, x as UnsupportedFunctionalityError$1 } from "./dist-DjkPkAzV.js";
1
+ import { i as __require, o as __toESM$1, t as __commonJSMin$1 } from "./rolldown-runtime-CQI-hT2b.js";
2
+ import { n as standardSchemaToJSONSchema, r as toStandardSchema$5, t as isStandardSchemaWithJSON$1 } from "./schema-Bf12g7KC-DBc4NSds.js";
3
+ import "./utils-YEuwVEc2.js";
4
+ import { _ as InvalidPromptError, a as createEventSourceResponseHandler$3, b as TooManyEmbeddingValuesForCallError, c as generateId, d as parseProviderOptions$1, f as postFormDataToApi, g as APICallError$4, h as withoutTrailingSlash$3, i as createBinaryResponseHandler, l as isParsableJson, n as convertBase64ToUint8Array$1, o as createJsonErrorResponseHandler$3, p as postJsonToApi$3, r as convertUint8ArrayToBase64$2, s as createJsonResponseHandler$3, t as combineHeaders$3, u as loadApiKey, v as InvalidResponseDataError$1, x as UnsupportedFunctionalityError$1 } from "./dist-CNjm6d2Q.js";
5
5
  import { createRequire } from "module";
6
6
  import * as z4 from "zod/v4";
7
7
  import { any, array, boolean, custom, discriminatedUnion, enum as enum$1, instanceof as instanceof$1, json, lazy, literal, looseObject, never, null as null$1, number, object, record, safeParseAsync, string, union, unknown, z } from "zod/v4";
@@ -30,7 +30,7 @@ import { channel, tracingChannel } from "diagnostics_channel";
30
30
  import { AsyncLocalStorage, AsyncResource } from "async_hooks";
31
31
  import { exec, execFile, spawn } from "child_process";
32
32
  import { copyFile, mkdir, mkdtemp, readFile, readdir, rm, stat, writeFile } from "fs/promises";
33
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/ms/2.0.0/a65cc302695e9dde36bdbab59e67a07f313b77a4e7b89957a7bf17f930a58070/node_modules/ms/index.js
33
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/ms/2.0.0/a65cc302695e9dde36bdbab59e67a07f313b77a4e7b89957a7bf17f930a58070/node_modules/ms/index.js
34
34
  var require_ms = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
35
35
  /**
36
36
  * Helpers.
@@ -138,8 +138,7 @@ var require_ms = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
138
138
  return Math.ceil(ms / n) + " " + name + "s";
139
139
  }
140
140
  }));
141
- //#endregion
142
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/debug/2.6.9/801652e4785c84886fe45a314148ed1497034cb567c175a44cafefed7bfe99be/node_modules/debug/src/debug.js
141
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/debug/2.6.9/801652e4785c84886fe45a314148ed1497034cb567c175a44cafefed7bfe99be/node_modules/debug/src/debug.js
143
142
  var require_debug = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
144
143
  /**
145
144
  * This is the common logic for both the Node.js and web browser
@@ -278,8 +277,7 @@ var require_debug = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
278
277
  return val;
279
278
  }
280
279
  }));
281
- //#endregion
282
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/debug/2.6.9/801652e4785c84886fe45a314148ed1497034cb567c175a44cafefed7bfe99be/node_modules/debug/src/browser.js
280
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/debug/2.6.9/801652e4785c84886fe45a314148ed1497034cb567c175a44cafefed7bfe99be/node_modules/debug/src/browser.js
283
281
  var require_browser = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
284
282
  /**
285
283
  * This is the web browser implementation of `debug()`.
@@ -400,8 +398,7 @@ var require_browser = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
400
398
  } catch (e) {}
401
399
  }
402
400
  }));
403
- //#endregion
404
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/debug/2.6.9/801652e4785c84886fe45a314148ed1497034cb567c175a44cafefed7bfe99be/node_modules/debug/src/node.js
401
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/debug/2.6.9/801652e4785c84886fe45a314148ed1497034cb567c175a44cafefed7bfe99be/node_modules/debug/src/node.js
405
402
  var require_node = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
406
403
  /**
407
404
  * Module dependencies.
@@ -572,8 +569,7 @@ var require_node = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
572
569
  */
573
570
  exports.enable(load());
574
571
  }));
575
- //#endregion
576
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/debug/2.6.9/801652e4785c84886fe45a314148ed1497034cb567c175a44cafefed7bfe99be/node_modules/debug/src/index.js
572
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/debug/2.6.9/801652e4785c84886fe45a314148ed1497034cb567c175a44cafefed7bfe99be/node_modules/debug/src/index.js
577
573
  var require_src = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
578
574
  /**
579
575
  * Detect Electron renderer process, which is node, but we should
@@ -582,8 +578,7 @@ var require_src = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
582
578
  if (typeof process !== "undefined" && process.type === "renderer") module.exports = require_browser();
583
579
  else module.exports = require_node();
584
580
  }));
585
- //#endregion
586
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/stream-parser/0.3.1/05001837beb9bed7e5025720d2f11fc3082c627fc85fbc1354f5c8b6191938d4/node_modules/stream-parser/index.js
581
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/stream-parser/0.3.1/05001837beb9bed7e5025720d2f11fc3082c627fc85fbc1354f5c8b6191938d4/node_modules/stream-parser/index.js
587
582
  var require_stream_parser = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
588
583
  /**
589
584
  * Module dependencies.
@@ -784,8 +779,7 @@ var require_stream_parser = /* @__PURE__ */ __commonJSMin$1(((exports, module) =
784
779
  };
785
780
  }
786
781
  }));
787
- //#endregion
788
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/lib/common/read_le_be.js
782
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/lib/common/read_le_be.js
789
783
  var require_read_le_be = /* @__PURE__ */ __commonJSMin$1(((exports) => {
790
784
  exports.readUInt16LE = function(data, offset) {
791
785
  return data[offset] | data[offset + 1] << 8;
@@ -812,8 +806,7 @@ var require_read_le_be = /* @__PURE__ */ __commonJSMin$1(((exports) => {
812
806
  return exports.readUInt32BE(data, offset) | 0;
813
807
  };
814
808
  }));
815
- //#endregion
816
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/lib/common/index.js
809
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/lib/common/index.js
817
810
  var require_common = /* @__PURE__ */ __commonJSMin$1(((exports) => {
818
811
  var Transform = __require("stream").Transform;
819
812
  var streamParser = require_stream_parser();
@@ -860,8 +853,7 @@ var require_common = /* @__PURE__ */ __commonJSMin$1(((exports) => {
860
853
  exports.readInt32LE = readLeBe.readInt32LE;
861
854
  exports.readInt32BE = readLeBe.readInt32BE;
862
855
  }));
863
- //#endregion
864
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/lib/miaf_utils.js
856
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/lib/miaf_utils.js
865
857
  var require_miaf_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
866
858
  var readUInt16BE = require_common().readUInt16BE;
867
859
  var readUInt32BE = require_common().readUInt32BE;
@@ -1070,8 +1062,7 @@ var require_miaf_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1070
1062
  };
1071
1063
  };
1072
1064
  }));
1073
- //#endregion
1074
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/lib/exif_utils.js
1065
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/lib/exif_utils.js
1075
1066
  var require_exif_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1076
1067
  function error(message, code) {
1077
1068
  var err = new Error(message);
@@ -1238,8 +1229,7 @@ var require_exif_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1238
1229
  }
1239
1230
  };
1240
1231
  }));
1241
- //#endregion
1242
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/lib/common/svg_header.js
1232
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/lib/common/svg_header.js
1243
1233
  var require_svg_header = /* @__PURE__ */ __commonJSMin$1(((exports) => {
1244
1234
  exports.MAX_DATA_LENGTH = 10240;
1245
1235
  var attr_name = "[a-zA-Z_:][a-zA-Z0-9:._-]*";
@@ -1323,8 +1313,7 @@ var require_svg_header = /* @__PURE__ */ __commonJSMin$1(((exports) => {
1323
1313
  };
1324
1314
  };
1325
1315
  }));
1326
- //#endregion
1327
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/lib/parse_sync/avif.js
1316
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/lib/parse_sync/avif.js
1328
1317
  var require_avif = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1329
1318
  var str2arr = require_common().str2arr;
1330
1319
  var sliceEq = require_common().sliceEq;
@@ -1372,8 +1361,7 @@ var require_avif = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1372
1361
  return result;
1373
1362
  };
1374
1363
  }));
1375
- //#endregion
1376
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/lib/parse_sync/bmp.js
1364
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/lib/parse_sync/bmp.js
1377
1365
  var require_bmp = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1378
1366
  var str2arr = require_common().str2arr;
1379
1367
  var sliceEq = require_common().sliceEq;
@@ -1404,8 +1392,7 @@ var require_bmp = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1404
1392
  };
1405
1393
  };
1406
1394
  }));
1407
- //#endregion
1408
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/lib/parse_sync/gif.js
1395
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/lib/parse_sync/gif.js
1409
1396
  var require_gif = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1410
1397
  var str2arr = require_common().str2arr;
1411
1398
  var sliceEq = require_common().sliceEq;
@@ -1425,8 +1412,7 @@ var require_gif = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1425
1412
  };
1426
1413
  };
1427
1414
  }));
1428
- //#endregion
1429
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/lib/parse_sync/ico.js
1415
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/lib/parse_sync/ico.js
1430
1416
  var require_ico = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1431
1417
  var readUInt16LE = require_common().readUInt16LE;
1432
1418
  var HEADER = 0;
@@ -1464,8 +1450,7 @@ var require_ico = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1464
1450
  };
1465
1451
  };
1466
1452
  }));
1467
- //#endregion
1468
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/lib/parse_sync/jpeg.js
1453
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/lib/parse_sync/jpeg.js
1469
1454
  var require_jpeg = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1470
1455
  var readUInt16BE = require_common().readUInt16BE;
1471
1456
  var str2arr = require_common().str2arr;
@@ -1510,8 +1495,7 @@ var require_jpeg = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1510
1495
  }
1511
1496
  };
1512
1497
  }));
1513
- //#endregion
1514
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/lib/parse_sync/png.js
1498
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/lib/parse_sync/png.js
1515
1499
  var require_png = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1516
1500
  var str2arr = require_common().str2arr;
1517
1501
  var sliceEq = require_common().sliceEq;
@@ -1532,8 +1516,7 @@ var require_png = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1532
1516
  };
1533
1517
  };
1534
1518
  }));
1535
- //#endregion
1536
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/lib/parse_sync/psd.js
1519
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/lib/parse_sync/psd.js
1537
1520
  var require_psd = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1538
1521
  var str2arr = require_common().str2arr;
1539
1522
  var sliceEq = require_common().sliceEq;
@@ -1552,8 +1535,7 @@ var require_psd = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1552
1535
  };
1553
1536
  };
1554
1537
  }));
1555
- //#endregion
1556
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/lib/parse_sync/svg.js
1538
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/lib/parse_sync/svg.js
1557
1539
  var require_svg = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1558
1540
  var parseSvgHeader = require_svg_header().parse;
1559
1541
  var MAX_DATA_LENGTH = require_svg_header().MAX_DATA_LENGTH;
@@ -1566,8 +1548,7 @@ var require_svg = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1566
1548
  return parseSvgHeader(str);
1567
1549
  };
1568
1550
  }));
1569
- //#endregion
1570
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/lib/parse_sync/tiff.js
1551
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/lib/parse_sync/tiff.js
1571
1552
  var require_tiff = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1572
1553
  var str2arr = require_common().str2arr;
1573
1554
  var sliceEq = require_common().sliceEq;
@@ -1617,8 +1598,7 @@ var require_tiff = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1617
1598
  };
1618
1599
  };
1619
1600
  }));
1620
- //#endregion
1621
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/lib/parse_sync/webp.js
1601
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/lib/parse_sync/webp.js
1622
1602
  var require_webp = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1623
1603
  var str2arr = require_common().str2arr;
1624
1604
  var sliceEq = require_common().sliceEq;
@@ -1689,8 +1669,7 @@ var require_webp = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1689
1669
  return result;
1690
1670
  };
1691
1671
  }));
1692
- //#endregion
1693
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/lib/parsers_sync.js
1672
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/lib/parsers_sync.js
1694
1673
  var require_parsers_sync = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1695
1674
  module.exports = {
1696
1675
  avif: require_avif(),
@@ -1705,8 +1684,7 @@ var require_parsers_sync = /* @__PURE__ */ __commonJSMin$1(((exports, module) =>
1705
1684
  webp: require_webp()
1706
1685
  };
1707
1686
  }));
1708
- //#endregion
1709
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/43b9b37f7c8cc84dfb4291a9197892579e4bb95490e2ba02998c927153256ea7/node_modules/probe-image-size/sync.js
1687
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/probe-image-size/7.4.0/f69b9b4fcba47e3caec204c2c2fb06128584c44c9c217acf2bb0f3ce5286d00b/node_modules/probe-image-size/sync.js
1710
1688
  var require_sync = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1711
1689
  var parsers = require_parsers_sync();
1712
1690
  function probeBuffer(buffer) {
@@ -1725,8 +1703,7 @@ var require_sync = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1725
1703
  };
1726
1704
  module.exports.parsers = parsers;
1727
1705
  }));
1728
- //#endregion
1729
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/openai/1.3.24/9ea9437756f1191484449f4e611ce2befb4ff9a7be92f5dfa8b1970d80a87966/node_modules/@ai-sdk/openai/dist/index.mjs
1706
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@ai-sdk/openai/1.3.24/9ea9437756f1191484449f4e611ce2befb4ff9a7be92f5dfa8b1970d80a87966/node_modules/@ai-sdk/openai/dist/index.mjs
1730
1707
  var import_sync = /* @__PURE__ */ __toESM$1(require_sync(), 1);
1731
1708
  function convertToOpenAIChatMessages({ prompt, useLegacyFunctionCalling = false, systemMessageMode = "system" }) {
1732
1709
  const messages = [];
@@ -4008,8 +3985,7 @@ function createOpenAI(options = {}) {
4008
3985
  return provider;
4009
3986
  }
4010
3987
  var openai = createOpenAI({ compatibility: "strict" });
4011
- //#endregion
4012
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/async-mutex/0.5.0/4b32f2ae13cd0d7acb694455f7c2810d59202098580506b1730c21c7ab02798f/node_modules/async-mutex/index.mjs
3988
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/async-mutex/0.5.0/4b32f2ae13cd0d7acb694455f7c2810d59202098580506b1730c21c7ab02798f/node_modules/async-mutex/index.mjs
4013
3989
  const E_CANCELED = /* @__PURE__ */ new Error("request for lock canceled");
4014
3990
  var __awaiter$2 = function(thisArg, _arguments, P, generator) {
4015
3991
  function adopt(value) {
@@ -4201,8 +4177,7 @@ var Mutex = class {
4201
4177
  return this._semaphore.cancel();
4202
4178
  }
4203
4179
  };
4204
- //#endregion
4205
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/lru-cache/11.5.3/5f933852b2037e33252208b4fa114552d3422c97eca48d9d18f9ecabf26b3c0c/node_modules/lru-cache/dist/esm/node/index.min.js
4180
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/lru-cache/11.5.3/5f933852b2037e33252208b4fa114552d3422c97eca48d9d18f9ecabf26b3c0c/node_modules/lru-cache/dist/esm/node/index.min.js
4206
4181
  var S = channel("lru-cache:metrics");
4207
4182
  var W = tracingChannel("lru-cache");
4208
4183
  var L = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
@@ -4850,8 +4825,7 @@ var I = class d {
4850
4825
  }
4851
4826
  }
4852
4827
  };
4853
- //#endregion
4854
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/xxhash-wasm/1.1.0/7a4d29379f632c8775c0f7a81c6f7be0607f720c94b35e32b01c8ed7b2685ac1/node_modules/xxhash-wasm/esm/xxhash-wasm.js
4828
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/xxhash-wasm/1.1.0/7a4d29379f632c8775c0f7a81c6f7be0607f720c94b35e32b01c8ed7b2685ac1/node_modules/xxhash-wasm/esm/xxhash-wasm.js
4855
4829
  const t = new Uint8Array([
4856
4830
  0,
4857
4831
  97,
@@ -8006,8 +7980,7 @@ async function e() {
8006
7980
  };
8007
7981
  }((await WebAssembly.instantiate(t)).instance);
8008
7982
  }
8009
- //#endregion
8010
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/diff/base.js
7983
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/diff/base.js
8011
7984
  var Diff = class {
8012
7985
  diff(oldStr, newStr, options = {}) {
8013
7986
  let callback;
@@ -8184,12 +8157,10 @@ var Diff = class {
8184
8157
  return components;
8185
8158
  }
8186
8159
  };
8187
- //#endregion
8188
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/diff/character.js
8160
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/diff/character.js
8189
8161
  var CharacterDiff = class extends Diff {};
8190
8162
  new CharacterDiff();
8191
- //#endregion
8192
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/util/string.js
8163
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/util/string.js
8193
8164
  function longestCommonPrefix(str1, str2) {
8194
8165
  let i = 0;
8195
8166
  for (; i < str1.length && i < str2.length; i++) if (str1[i] != str2[i]) return str1.slice(0, i);
@@ -8278,8 +8249,7 @@ function leadingAndTrailingWs(string, segmenter) {
8278
8249
  const lastSeg = segments[segments.length - 1];
8279
8250
  return [/\s/.test(firstSeg) ? firstSeg : "", /\s/.test(lastSeg) ? lastSeg : ""];
8280
8251
  }
8281
- //#endregion
8282
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/diff/word.js
8252
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/diff/word.js
8283
8253
  const extendedWordChars = "a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
8284
8254
  const tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\s+|[^${extendedWordChars}]`, "ug");
8285
8255
  var WordDiff = class extends Diff {
@@ -8386,8 +8356,7 @@ var WordsWithSpaceDiff = class extends Diff {
8386
8356
  }
8387
8357
  };
8388
8358
  new WordsWithSpaceDiff();
8389
- //#endregion
8390
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/diff/line.js
8359
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/diff/line.js
8391
8360
  var LineDiff = class extends Diff {
8392
8361
  constructor() {
8393
8362
  super(...arguments);
@@ -8419,8 +8388,7 @@ function tokenize(value, options) {
8419
8388
  }
8420
8389
  return retLines;
8421
8390
  }
8422
- //#endregion
8423
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/diff/sentence.js
8391
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/diff/sentence.js
8424
8392
  function isSentenceEndPunct(char) {
8425
8393
  return char == "." || char == "!" || char == "?";
8426
8394
  }
@@ -8446,16 +8414,14 @@ var SentenceDiff = class extends Diff {
8446
8414
  }
8447
8415
  };
8448
8416
  new SentenceDiff();
8449
- //#endregion
8450
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/diff/css.js
8417
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/diff/css.js
8451
8418
  var CssDiff = class extends Diff {
8452
8419
  tokenize(value) {
8453
8420
  return value.split(/([{}:;,]|\s+)/);
8454
8421
  }
8455
8422
  };
8456
8423
  new CssDiff();
8457
- //#endregion
8458
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/diff/json.js
8424
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/diff/json.js
8459
8425
  var JsonDiff = class extends Diff {
8460
8426
  constructor() {
8461
8427
  super(...arguments);
@@ -8509,8 +8475,7 @@ function canonicalize(obj, stack, replacementStack, replacer, key) {
8509
8475
  } else canonicalizedObj = obj;
8510
8476
  return canonicalizedObj;
8511
8477
  }
8512
- //#endregion
8513
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/diff/array.js
8478
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/diff/array.js
8514
8479
  var ArrayDiff = class extends Diff {
8515
8480
  tokenize(value) {
8516
8481
  return value.slice();
@@ -8523,8 +8488,7 @@ var ArrayDiff = class extends Diff {
8523
8488
  }
8524
8489
  };
8525
8490
  new ArrayDiff();
8526
- //#endregion
8527
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/patch/create.js
8491
+ // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/diff/8.0.4/6781cdda9837821c30a1f4c4db1d9286b838fe139b78d9658b2471e961b45953/node_modules/diff/libesm/patch/create.js
8528
8492
  function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
8529
8493
  let optionsObj;
8530
8494
  if (!options) optionsObj = {};
@@ -8618,8 +8582,7 @@ function splitLines(text) {
8618
8582
  else result.push(result.pop().slice(0, -1));
8619
8583
  return result;
8620
8584
  }
8621
- //#endregion
8622
- //#region ../memory/dist/src-BUWL69LT.js
8585
+ // ../memory/dist/src-stSVckwY.js
8623
8586
  var __defProp$3 = Object.defineProperty;
8624
8587
  var __exportAll = (all, no_symbols) => {
8625
8588
  let target = {};
@@ -12443,26 +12406,30 @@ const LF$2 = 10;
12443
12406
  const CR$2 = 13;
12444
12407
  const SPACE$2 = 32;
12445
12408
  function noop$2(_arg) {}
12446
- function createParser$2(callbacks) {
12447
- if (typeof callbacks == "function") throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");
12448
- const { onEvent = noop$2, onError = noop$2, onRetry = noop$2, onComment } = callbacks, pendingFragments = [];
12449
- let isFirstChunk = !0, id, data = "", dataLines = 0, eventType;
12409
+ function createParser$2(config) {
12410
+ if (typeof config == "function") throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");
12411
+ const { onEvent = noop$2, onError = noop$2, onRetry = noop$2, onComment, maxBufferSize } = config, pendingFragments = [];
12412
+ let pendingFragmentsLength = 0, isFirstChunk = !0, id, data = "", dataLines = 0, eventType, terminated = !1;
12450
12413
  function feed(chunk) {
12414
+ if (terminated) throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");
12451
12415
  if (isFirstChunk && (isFirstChunk = !1, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
12452
12416
  const trailing2 = processLines(chunk);
12453
- trailing2 !== "" && pendingFragments.push(trailing2);
12417
+ trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
12454
12418
  return;
12455
12419
  }
12456
12420
  if (chunk.indexOf(`
12457
12421
  `) === -1 && chunk.indexOf("\r") === -1) {
12458
- pendingFragments.push(chunk);
12422
+ pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
12459
12423
  return;
12460
12424
  }
12461
12425
  pendingFragments.push(chunk);
12462
12426
  const input = pendingFragments.join("");
12463
- pendingFragments.length = 0;
12427
+ pendingFragments.length = 0, pendingFragmentsLength = 0;
12464
12428
  const trailing = processLines(input);
12465
- trailing !== "" && pendingFragments.push(trailing);
12429
+ trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
12430
+ }
12431
+ function checkBufferSize() {
12432
+ maxBufferSize !== void 0 && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = !0, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data = "", dataLines = 0, eventType = void 0, onError(new ParseError$2(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, { type: "max-buffer-size-exceeded" }))));
12466
12433
  }
12467
12434
  function processLines(chunk) {
12468
12435
  let searchIndex = 0;
@@ -12526,7 +12493,7 @@ ${value2}`, dataLines++;
12526
12493
  }
12527
12494
  if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
12528
12495
  const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE$2 ? start + 4 : start + 3, end);
12529
- id = value2.includes("\0") ? void 0 : value2;
12496
+ value2.includes("\0") || (id = value2);
12530
12497
  return;
12531
12498
  }
12532
12499
  if (firstCharCode === 58) {
@@ -12554,7 +12521,7 @@ ${value2}`, dataLines++;
12554
12521
  ${value}`, dataLines++;
12555
12522
  break;
12556
12523
  case "id":
12557
- id = value.includes("\0") ? void 0 : value;
12524
+ value.includes("\0") || (id = value);
12558
12525
  break;
12559
12526
  case "retry":
12560
12527
  /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(new ParseError$2(`Invalid \`retry\` value: "${value}"`, {
@@ -12583,7 +12550,7 @@ ${value}`, dataLines++;
12583
12550
  const incompleteLine = pendingFragments.join("");
12584
12551
  parseLine(incompleteLine, 0, incompleteLine.length);
12585
12552
  }
12586
- isFirstChunk = !0, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0;
12553
+ isFirstChunk = !0, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = !1;
12587
12554
  }
12588
12555
  return {
12589
12556
  feed,
@@ -12597,7 +12564,7 @@ function isEventPrefix$2(chunk, i, firstCharCode) {
12597
12564
  return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
12598
12565
  }
12599
12566
  var EventSourceParserStream$2 = class extends TransformStream {
12600
- constructor({ onError, onRetry, onComment } = {}) {
12567
+ constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
12601
12568
  let parser;
12602
12569
  super({
12603
12570
  start(controller) {
@@ -12606,10 +12573,11 @@ var EventSourceParserStream$2 = class extends TransformStream {
12606
12573
  controller.enqueue(event);
12607
12574
  },
12608
12575
  onError(error) {
12609
- onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error);
12576
+ typeof onError == "function" && onError(error), (onError === "terminate" || error.type === "max-buffer-size-exceeded") && controller.error(error);
12610
12577
  },
12611
12578
  onRetry,
12612
- onComment
12579
+ onComment,
12580
+ maxBufferSize
12613
12581
  });
12614
12582
  },
12615
12583
  transform(chunk) {
@@ -12834,7 +12802,7 @@ function withUserAgentSuffix$2(headers, ...userAgentSuffixParts) {
12834
12802
  normalizedHeaders.set("user-agent", [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" "));
12835
12803
  return Object.fromEntries(normalizedHeaders.entries());
12836
12804
  }
12837
- var VERSION$8 = "3.0.41";
12805
+ var VERSION$8 = "3.0.42";
12838
12806
  var getOriginalFetch$3 = () => globalThis.fetch;
12839
12807
  var getFromApi$2 = async ({ url, headers = {}, successfulResponseHandler, failedResponseHandler, abortSignal, fetch = getOriginalFetch$3() }) => {
12840
12808
  try {
@@ -15088,58 +15056,84 @@ var GatewayImageModel$2 = class {
15088
15056
  };
15089
15057
  }
15090
15058
  };
15091
- var providerMetadataEntrySchema$5 = z.object({ images: z.array(z.unknown()).optional() }).catchall(z.unknown());
15092
- var gatewayImageUsageSchema$2 = z.object({
15059
+ var providerMetadataEntrySchema$5 = () => z.object({ images: z.array(z.unknown()).optional() }).catchall(z.unknown());
15060
+ var gatewayImageUsageSchema$2 = () => z.object({
15093
15061
  inputTokens: z.number().nullish(),
15094
15062
  outputTokens: z.number().nullish(),
15095
15063
  totalTokens: z.number().nullish()
15096
15064
  });
15097
- var gatewayImageResponseSchema$2 = z.object({
15065
+ var gatewayImageResponseSchema$2 = lazySchema$2(() => zodSchema$2(z.object({
15098
15066
  images: z.array(z.string()),
15099
15067
  isRetryable: z.boolean().optional(),
15100
15068
  warnings: z.array(z.object({
15101
15069
  type: z.literal("other"),
15102
15070
  message: z.string()
15103
15071
  })).optional(),
15104
- providerMetadata: z.record(z.string(), providerMetadataEntrySchema$5).optional(),
15105
- usage: gatewayImageUsageSchema$2.optional()
15106
- });
15072
+ providerMetadata: z.record(z.string(), providerMetadataEntrySchema$5()).optional(),
15073
+ usage: gatewayImageUsageSchema$2().optional()
15074
+ })));
15075
+ var parallelSearchModes$2 = [
15076
+ "turbo",
15077
+ "fast",
15078
+ "basic",
15079
+ "advanced",
15080
+ "one-shot",
15081
+ "agentic"
15082
+ ];
15107
15083
  var parallelSearchToolFactory$2 = createProviderDefinedToolFactoryWithOutputSchema({
15108
15084
  id: "gateway.parallel_search",
15109
15085
  name: "parallel_search",
15110
15086
  inputSchema: lazySchema$2(() => zodSchema$2(z$2.object({
15111
15087
  objective: z$2.string().describe("Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."),
15112
- search_queries: z$2.array(z$2.string()).optional().describe("Optional search queries to supplement the objective. Maximum 200 characters per query."),
15113
- mode: z$2.enum(["one-shot", "agentic"]).optional().describe("Mode preset: \"one-shot\" for comprehensive results with longer excerpts (default), \"agentic\" for concise, token-efficient results for multi-step workflows."),
15088
+ search_queries: z$2.array(z$2.string()).optional().describe("Provide 2-3 concise keyword queries, 3-6 words each (max 5, 200 chars each). Strongly recommended; the search runs on these queries."),
15089
+ mode: z$2.enum(parallelSearchModes$2).optional().describe("Search mode: \"turbo\" and \"fast\" return quickly with shorter excerpts, \"basic\" is balanced (default), \"advanced\" is the most thorough. \"turbo\" supports English and Japanese only. \"one-shot\" and \"agentic\" are deprecated aliases of \"basic\" and \"advanced\"."),
15114
15090
  max_results: z$2.number().optional().describe("Maximum number of results to return (1-20). Defaults to 10 if not specified."),
15115
15091
  source_policy: z$2.object({
15116
- include_domains: z$2.array(z$2.string()).optional().describe("List of domains to include in search results."),
15117
- exclude_domains: z$2.array(z$2.string()).optional().describe("List of domains to exclude from search results."),
15118
- after_date: z$2.string().optional().describe("Only include results published after this date (ISO 8601 format).")
15092
+ include_domains: z$2.array(z$2.string()).optional().describe("Domains or domain/path prefixes to restrict results to, without scheme or port. Example: ['wikipedia.org', 'docs.python.org/3']."),
15093
+ exclude_domains: z$2.array(z$2.string()).optional().describe("Domains or domain/path prefixes to exclude, without scheme or port. Example: ['reddit.com']."),
15094
+ after_date: z$2.string().optional().describe("Only include results published on or after this date. Use an ISO 8601 calendar date formatted YYYY-MM-DD (e.g. 2025-01-01); do not include a time.")
15119
15095
  }).optional().describe("Source policy for controlling which domains to include/exclude and freshness."),
15120
15096
  excerpts: z$2.object({
15121
15097
  max_chars_per_result: z$2.number().optional().describe("Maximum characters per result."),
15122
- max_chars_total: z$2.number().optional().describe("Maximum total characters across all results.")
15098
+ max_chars_total: z$2.number().optional().describe("Deprecated: use the top-level max_chars_total.")
15123
15099
  }).optional().describe("Excerpt configuration for controlling result length."),
15124
- fetch_policy: z$2.object({ max_age_seconds: z$2.number().optional().describe("Maximum age in seconds for cached content. Set to 0 to always fetch fresh content.") }).optional().describe("Fetch policy for controlling content freshness.")
15100
+ max_chars_total: z$2.number().optional().describe("Maximum total characters across all result excerpts."),
15101
+ fetch_policy: z$2.object({
15102
+ max_age_seconds: z$2.number().optional().describe("Maximum age of cached content in seconds before a live fetch, minimum 600."),
15103
+ timeout_seconds: z$2.number().optional().describe("Timeout in seconds for a live fetch when content is not cached. Capped by the gateway tool timeout."),
15104
+ disable_cache_fallback: z$2.boolean().optional().describe("Return an error instead of older cached content when a live fetch fails.")
15105
+ }).optional().describe("Fetch policy for controlling content freshness."),
15106
+ location: z$2.string().optional().describe("ISO 3166-1 alpha-2 country code to localize results, e.g. \"us\".")
15125
15107
  }))),
15126
15108
  outputSchema: lazySchema$2(() => zodSchema$2(z$2.union([z$2.object({
15127
- searchId: z$2.string(),
15109
+ search_id: z$2.string(),
15128
15110
  results: z$2.array(z$2.object({
15129
15111
  url: z$2.string(),
15130
- title: z$2.string(),
15131
- excerpt: z$2.string(),
15132
- publishDate: z$2.string().nullable().optional(),
15133
- relevanceScore: z$2.number().optional()
15134
- }))
15112
+ title: z$2.string().nullable().optional(),
15113
+ publish_date: z$2.string().nullable().optional(),
15114
+ excerpts: z$2.array(z$2.string())
15115
+ })),
15116
+ warnings: z$2.array(z$2.object({
15117
+ type: z$2.string(),
15118
+ message: z$2.string(),
15119
+ detail: z$2.record(z$2.string(), z$2.unknown()).nullable().optional()
15120
+ })).nullable().optional(),
15121
+ usage: z$2.array(z$2.object({
15122
+ name: z$2.string(),
15123
+ count: z$2.number().optional()
15124
+ })).nullable().optional(),
15125
+ session_id: z$2.string().optional()
15135
15126
  }), z$2.object({
15136
15127
  error: z$2.enum([
15137
15128
  "api_error",
15129
+ "configuration_error",
15130
+ "execution_error",
15131
+ "gateway_rate_limit",
15132
+ "invalid_input",
15138
15133
  "rate_limit",
15139
15134
  "timeout",
15140
- "invalid_input",
15141
- "configuration_error",
15142
- "unknown"
15135
+ "unknown",
15136
+ "unknown_tool"
15143
15137
  ]),
15144
15138
  statusCode: z$2.number().optional(),
15145
15139
  message: z$2.string()
@@ -15213,7 +15207,7 @@ async function getVercelRequestId$2() {
15213
15207
  var _a10;
15214
15208
  return (_a10 = getContext$2().headers) == null ? void 0 : _a10["x-vercel-id"];
15215
15209
  }
15216
- var VERSION$7 = "2.0.168";
15210
+ var VERSION$7 = "2.0.172";
15217
15211
  var AI_GATEWAY_PROTOCOL_VERSION$2 = "0.0.1";
15218
15212
  function createGatewayProvider$1(options = {}) {
15219
15213
  var _a10, _b10;
@@ -16155,52 +16149,52 @@ var trace$1 = function() {
16155
16149
  }().getInstance();
16156
16150
  var __defProp$1 = Object.defineProperty;
16157
16151
  var __export$1 = (target, all) => {
16158
- for (var name16 in all) __defProp$1(target, name16, {
16159
- get: all[name16],
16152
+ for (var name17 in all) __defProp$1(target, name17, {
16153
+ get: all[name17],
16160
16154
  enumerable: true
16161
16155
  });
16162
16156
  };
16163
- var name2$3 = "AI_InvalidArgumentError";
16164
- var marker2$3 = `vercel.ai.error.${name2$3}`;
16165
- var symbol2$3 = Symbol.for(marker2$3);
16166
- var _a2$3;
16157
+ var name3$3 = "AI_InvalidArgumentError";
16158
+ var marker3$3 = `vercel.ai.error.${name3$3}`;
16159
+ var symbol3$3 = Symbol.for(marker3$3);
16160
+ var _a3$3;
16167
16161
  var InvalidArgumentError$4 = class extends AISDKError$2 {
16168
16162
  constructor({ parameter, value, message }) {
16169
16163
  super({
16170
- name: name2$3,
16164
+ name: name3$3,
16171
16165
  message: `Invalid argument for parameter ${parameter}: ${message}`
16172
16166
  });
16173
- this[_a2$3] = true;
16167
+ this[_a3$3] = true;
16174
16168
  this.parameter = parameter;
16175
16169
  this.value = value;
16176
16170
  }
16177
16171
  static isInstance(error) {
16178
- return AISDKError$2.hasMarker(error, marker2$3);
16172
+ return AISDKError$2.hasMarker(error, marker3$3);
16179
16173
  }
16180
16174
  };
16181
- _a2$3 = symbol2$3;
16182
- var name6$3 = "AI_NoObjectGeneratedError";
16183
- var marker6$3 = `vercel.ai.error.${name6$3}`;
16184
- var symbol6$3 = Symbol.for(marker6$3);
16185
- var _a6$3;
16175
+ _a3$3 = symbol3$3;
16176
+ var name7$3 = "AI_NoObjectGeneratedError";
16177
+ var marker7$3 = `vercel.ai.error.${name7$3}`;
16178
+ var symbol7$3 = Symbol.for(marker7$3);
16179
+ var _a7$3;
16186
16180
  var NoObjectGeneratedError$1 = class extends AISDKError$2 {
16187
16181
  constructor({ message = "No object generated.", cause, text: text2, response, usage, finishReason }) {
16188
16182
  super({
16189
- name: name6$3,
16183
+ name: name7$3,
16190
16184
  message,
16191
16185
  cause
16192
16186
  });
16193
- this[_a6$3] = true;
16187
+ this[_a7$3] = true;
16194
16188
  this.text = text2;
16195
16189
  this.response = response;
16196
16190
  this.usage = usage;
16197
16191
  this.finishReason = finishReason;
16198
16192
  }
16199
16193
  static isInstance(error) {
16200
- return AISDKError$2.hasMarker(error, marker6$3);
16194
+ return AISDKError$2.hasMarker(error, marker7$3);
16201
16195
  }
16202
16196
  };
16203
- _a6$3 = symbol6$3;
16197
+ _a7$3 = symbol7$3;
16204
16198
  var UnsupportedModelVersionError$2 = class extends AISDKError$2 {
16205
16199
  constructor(options) {
16206
16200
  super({
@@ -16212,26 +16206,26 @@ var UnsupportedModelVersionError$2 = class extends AISDKError$2 {
16212
16206
  this.modelId = options.modelId;
16213
16207
  }
16214
16208
  };
16215
- var name14$1 = "AI_RetryError";
16216
- var marker14$2 = `vercel.ai.error.${name14$1}`;
16217
- var symbol14$2 = Symbol.for(marker14$2);
16218
- var _a14$2;
16209
+ var name15$1 = "AI_RetryError";
16210
+ var marker15$1 = `vercel.ai.error.${name15$1}`;
16211
+ var symbol15$1 = Symbol.for(marker15$1);
16212
+ var _a15$1;
16219
16213
  var RetryError$2 = class extends AISDKError$2 {
16220
16214
  constructor({ message, reason, errors }) {
16221
16215
  super({
16222
- name: name14$1,
16216
+ name: name15$1,
16223
16217
  message
16224
16218
  });
16225
- this[_a14$2] = true;
16219
+ this[_a15$1] = true;
16226
16220
  this.reason = reason;
16227
16221
  this.errors = errors;
16228
16222
  this.lastError = errors[errors.length - 1];
16229
16223
  }
16230
16224
  static isInstance(error) {
16231
- return AISDKError$2.hasMarker(error, marker14$2);
16225
+ return AISDKError$2.hasMarker(error, marker15$1);
16232
16226
  }
16233
16227
  };
16234
- _a14$2 = symbol14$2;
16228
+ _a15$1 = symbol15$1;
16235
16229
  function resolveEmbeddingModel$2(model) {
16236
16230
  if (typeof model !== "string") {
16237
16231
  if (model.specificationVersion !== "v2") throw new UnsupportedModelVersionError$2({
@@ -16244,17 +16238,17 @@ function resolveEmbeddingModel$2(model) {
16244
16238
  return getGlobalProvider$2().textEmbeddingModel(model);
16245
16239
  }
16246
16240
  function getGlobalProvider$2() {
16247
- var _a16;
16248
- return (_a16 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a16 : gateway$2;
16241
+ var _a17;
16242
+ return (_a17 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a17 : gateway$2;
16249
16243
  }
16250
- var VERSION$6 = "5.0.277";
16244
+ var VERSION$6 = "5.0.281";
16251
16245
  var dataContentSchema$1 = z.union([
16252
16246
  z.string(),
16253
16247
  z.instanceof(Uint8Array),
16254
16248
  z.instanceof(ArrayBuffer),
16255
16249
  z.custom((value) => {
16256
- var _a16, _b;
16257
- return (_b = (_a16 = globalThis.Buffer) == null ? void 0 : _a16.isBuffer(value)) != null ? _b : false;
16250
+ var _a17, _b;
16251
+ return (_b = (_a17 = globalThis.Buffer) == null ? void 0 : _a17.isBuffer(value)) != null ? _b : false;
16258
16252
  }, { message: "Must be a Buffer" })
16259
16253
  ]);
16260
16254
  var jsonValueSchema$2 = z.lazy(() => z.union([
@@ -16378,8 +16372,8 @@ function assembleOperationName$1({ operationId, telemetry }) {
16378
16372
  };
16379
16373
  }
16380
16374
  function getTelemetryMetadataAttributes(telemetry) {
16381
- var _a16;
16382
- return Object.entries((_a16 = telemetry == null ? void 0 : telemetry.metadata) != null ? _a16 : {}).reduce((attributes, [key, value]) => {
16375
+ var _a17;
16376
+ return Object.entries((_a17 = telemetry == null ? void 0 : telemetry.metadata) != null ? _a17 : {}).reduce((attributes, [key, value]) => {
16383
16377
  attributes[`ai.telemetry.metadata.${key}`] = value;
16384
16378
  return attributes;
16385
16379
  }, {});
@@ -16403,7 +16397,7 @@ var noopTracer$1 = {
16403
16397
  startSpan() {
16404
16398
  return noopSpan$1;
16405
16399
  },
16406
- startActiveSpan(name16, arg1, arg2, arg3) {
16400
+ startActiveSpan(name17, arg1, arg2, arg3) {
16407
16401
  if (typeof arg1 === "function") return arg1(noopSpan$1);
16408
16402
  if (typeof arg2 === "function") return arg2(noopSpan$1);
16409
16403
  if (typeof arg3 === "function") return arg3(noopSpan$1);
@@ -16454,8 +16448,8 @@ function getTracer$1({ isEnabled = false, tracer } = {}) {
16454
16448
  if (tracer) return tracer;
16455
16449
  return trace$1.getTracer("ai");
16456
16450
  }
16457
- function recordSpan$1({ name: name16, tracer, attributes, fn, endWhenDone = true, endOnError = endWhenDone }) {
16458
- return tracer.startActiveSpan(name16, { attributes }, async (span) => {
16451
+ function recordSpan$1({ name: name17, tracer, attributes, fn, endWhenDone = true, endOnError = endWhenDone }) {
16452
+ return tracer.startActiveSpan(name17, { attributes }, async (span) => {
16459
16453
  try {
16460
16454
  const result = await fn(span);
16461
16455
  if (endWhenDone) span.end();
@@ -16929,7 +16923,7 @@ async function embedMany$2({ model: modelArg, values, maxParallelCalls = Infinit
16929
16923
  }),
16930
16924
  tracer,
16931
16925
  fn: async (doEmbedSpan) => {
16932
- var _a16;
16926
+ var _a17;
16933
16927
  const modelResponse = await model.doEmbed({
16934
16928
  values,
16935
16929
  abortSignal,
@@ -16937,7 +16931,7 @@ async function embedMany$2({ model: modelArg, values, maxParallelCalls = Infinit
16937
16931
  providerOptions
16938
16932
  });
16939
16933
  const embeddings3 = modelResponse.embeddings;
16940
- const usage2 = (_a16 = modelResponse.usage) != null ? _a16 : { tokens: NaN };
16934
+ const usage2 = (_a17 = modelResponse.usage) != null ? _a17 : { tokens: NaN };
16941
16935
  doEmbedSpan.setAttributes(selectTelemetryAttributes$1({
16942
16936
  telemetry,
16943
16937
  attributes: {
@@ -16997,7 +16991,7 @@ async function embedMany$2({ model: modelArg, values, maxParallelCalls = Infinit
16997
16991
  }),
16998
16992
  tracer,
16999
16993
  fn: async (doEmbedSpan) => {
17000
- var _a16;
16994
+ var _a17;
17001
16995
  const modelResponse = await model.doEmbed({
17002
16996
  values: chunk,
17003
16997
  abortSignal,
@@ -17005,7 +16999,7 @@ async function embedMany$2({ model: modelArg, values, maxParallelCalls = Infinit
17005
16999
  providerOptions
17006
17000
  });
17007
17001
  const embeddings2 = modelResponse.embeddings;
17008
- const usage = (_a16 = modelResponse.usage) != null ? _a16 : { tokens: NaN };
17002
+ const usage = (_a17 = modelResponse.usage) != null ? _a17 : { tokens: NaN };
17009
17003
  doEmbedSpan.setAttributes(selectTelemetryAttributes$1({
17010
17004
  telemetry,
17011
17005
  attributes: {
@@ -17332,26 +17326,30 @@ const LF$1 = 10;
17332
17326
  const CR$1 = 13;
17333
17327
  const SPACE$1 = 32;
17334
17328
  function noop$1(_arg) {}
17335
- function createParser$1(callbacks) {
17336
- if (typeof callbacks == "function") throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");
17337
- const { onEvent = noop$1, onError = noop$1, onRetry = noop$1, onComment } = callbacks, pendingFragments = [];
17338
- let isFirstChunk = !0, id, data = "", dataLines = 0, eventType;
17329
+ function createParser$1(config) {
17330
+ if (typeof config == "function") throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");
17331
+ const { onEvent = noop$1, onError = noop$1, onRetry = noop$1, onComment, maxBufferSize } = config, pendingFragments = [];
17332
+ let pendingFragmentsLength = 0, isFirstChunk = !0, id, data = "", dataLines = 0, eventType, terminated = !1;
17339
17333
  function feed(chunk) {
17334
+ if (terminated) throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");
17340
17335
  if (isFirstChunk && (isFirstChunk = !1, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
17341
17336
  const trailing2 = processLines(chunk);
17342
- trailing2 !== "" && pendingFragments.push(trailing2);
17337
+ trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
17343
17338
  return;
17344
17339
  }
17345
17340
  if (chunk.indexOf(`
17346
17341
  `) === -1 && chunk.indexOf("\r") === -1) {
17347
- pendingFragments.push(chunk);
17342
+ pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
17348
17343
  return;
17349
17344
  }
17350
17345
  pendingFragments.push(chunk);
17351
17346
  const input = pendingFragments.join("");
17352
- pendingFragments.length = 0;
17347
+ pendingFragments.length = 0, pendingFragmentsLength = 0;
17353
17348
  const trailing = processLines(input);
17354
- trailing !== "" && pendingFragments.push(trailing);
17349
+ trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
17350
+ }
17351
+ function checkBufferSize() {
17352
+ maxBufferSize !== void 0 && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = !0, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data = "", dataLines = 0, eventType = void 0, onError(new ParseError$1(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, { type: "max-buffer-size-exceeded" }))));
17355
17353
  }
17356
17354
  function processLines(chunk) {
17357
17355
  let searchIndex = 0;
@@ -17415,7 +17413,7 @@ ${value2}`, dataLines++;
17415
17413
  }
17416
17414
  if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
17417
17415
  const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE$1 ? start + 4 : start + 3, end);
17418
- id = value2.includes("\0") ? void 0 : value2;
17416
+ value2.includes("\0") || (id = value2);
17419
17417
  return;
17420
17418
  }
17421
17419
  if (firstCharCode === 58) {
@@ -17443,7 +17441,7 @@ ${value2}`, dataLines++;
17443
17441
  ${value}`, dataLines++;
17444
17442
  break;
17445
17443
  case "id":
17446
- id = value.includes("\0") ? void 0 : value;
17444
+ value.includes("\0") || (id = value);
17447
17445
  break;
17448
17446
  case "retry":
17449
17447
  /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(new ParseError$1(`Invalid \`retry\` value: "${value}"`, {
@@ -17472,7 +17470,7 @@ ${value}`, dataLines++;
17472
17470
  const incompleteLine = pendingFragments.join("");
17473
17471
  parseLine(incompleteLine, 0, incompleteLine.length);
17474
17472
  }
17475
- isFirstChunk = !0, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0;
17473
+ isFirstChunk = !0, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = !1;
17476
17474
  }
17477
17475
  return {
17478
17476
  feed,
@@ -17486,7 +17484,7 @@ function isEventPrefix$1(chunk, i, firstCharCode) {
17486
17484
  return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
17487
17485
  }
17488
17486
  var EventSourceParserStream$1 = class extends TransformStream {
17489
- constructor({ onError, onRetry, onComment } = {}) {
17487
+ constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
17490
17488
  let parser;
17491
17489
  super({
17492
17490
  start(controller) {
@@ -17495,10 +17493,11 @@ var EventSourceParserStream$1 = class extends TransformStream {
17495
17493
  controller.enqueue(event);
17496
17494
  },
17497
17495
  onError(error) {
17498
- onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error);
17496
+ typeof onError == "function" && onError(error), (onError === "terminate" || error.type === "max-buffer-size-exceeded") && controller.error(error);
17499
17497
  },
17500
17498
  onRetry,
17501
- onComment
17499
+ onComment,
17500
+ maxBufferSize
17502
17501
  });
17503
17502
  },
17504
17503
  transform(chunk) {
@@ -17606,7 +17605,7 @@ function validateDownloadUrl$1(url) {
17606
17605
  url,
17607
17606
  message: `URL must have a hostname`
17608
17607
  });
17609
- if (hostname === "localhost" || hostname.endsWith(".local") || hostname.endsWith(".localhost")) throw new DownloadError$1({
17608
+ if (hostname === "localhost" || hostname.endsWith(".local") || hostname.endsWith(".localhost") || hostname.endsWith(".internal")) throw new DownloadError$1({
17610
17609
  url,
17611
17610
  message: `URL with hostname ${hostname} is not allowed`
17612
17611
  });
@@ -18003,7 +18002,7 @@ function withUserAgentSuffix$1(headers, ...userAgentSuffixParts) {
18003
18002
  normalizedHeaders.set("user-agent", [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" "));
18004
18003
  return Object.fromEntries(normalizedHeaders.entries());
18005
18004
  }
18006
- var VERSION$5 = "4.0.61";
18005
+ var VERSION$5 = "4.0.62";
18007
18006
  var getOriginalFetch$1 = () => globalThis.fetch;
18008
18007
  var getFromApi$1 = async ({ url, headers = {}, successfulResponseHandler, failedResponseHandler, abortSignal, fetch, validateUrl, credentialedOrigin, trustedOrigin }) => {
18009
18008
  try {
@@ -20294,7 +20293,7 @@ var GatewayEmbeddingModel$1 = class {
20294
20293
  };
20295
20294
  }
20296
20295
  };
20297
- var gatewayEmbeddingWarningSchema$1 = z.discriminatedUnion("type", [
20296
+ var gatewayEmbeddingWarningSchema$1 = () => z.discriminatedUnion("type", [
20298
20297
  z.object({
20299
20298
  type: z.literal("unsupported"),
20300
20299
  feature: z.string(),
@@ -20313,7 +20312,7 @@ var gatewayEmbeddingWarningSchema$1 = z.discriminatedUnion("type", [
20313
20312
  var gatewayEmbeddingResponseSchema$1 = lazySchema$1(() => zodSchema$1(z.object({
20314
20313
  embeddings: z.array(z.array(z.number())),
20315
20314
  usage: z.object({ tokens: z.number() }).nullish(),
20316
- warnings: z.array(gatewayEmbeddingWarningSchema$1).optional(),
20315
+ warnings: z.array(gatewayEmbeddingWarningSchema$1()).optional(),
20317
20316
  providerMetadata: z.record(z.string(), z.record(z.string(), z.unknown())).optional()
20318
20317
  })));
20319
20318
  function mapGatewayWarnings(warnings) {
@@ -20397,8 +20396,8 @@ function maybeEncodeImageFile$1(file) {
20397
20396
  };
20398
20397
  return file;
20399
20398
  }
20400
- var providerMetadataEntrySchema$4 = z.object({ images: z.array(z.unknown()).optional() }).catchall(z.unknown());
20401
- var gatewayImageWarningSchema$1 = z.discriminatedUnion("type", [
20399
+ var providerMetadataEntrySchema$4 = () => z.object({ images: z.array(z.unknown()).optional() }).catchall(z.unknown());
20400
+ var gatewayImageWarningSchema$1 = () => z.discriminatedUnion("type", [
20402
20401
  z.object({
20403
20402
  type: z.literal("unsupported"),
20404
20403
  feature: z.string(),
@@ -20419,18 +20418,18 @@ var gatewayImageWarningSchema$1 = z.discriminatedUnion("type", [
20419
20418
  message: z.string()
20420
20419
  })
20421
20420
  ]);
20422
- var gatewayImageUsageSchema$1 = z.object({
20421
+ var gatewayImageUsageSchema$1 = () => z.object({
20423
20422
  inputTokens: z.number().nullish(),
20424
20423
  outputTokens: z.number().nullish(),
20425
20424
  totalTokens: z.number().nullish()
20426
20425
  });
20427
- var gatewayImageResponseSchema$1 = z.object({
20426
+ var gatewayImageResponseSchema$1 = lazySchema$1(() => zodSchema$1(z.object({
20428
20427
  images: z.array(z.string()),
20429
20428
  isRetryable: z.boolean().optional(),
20430
- warnings: z.array(gatewayImageWarningSchema$1).optional(),
20431
- providerMetadata: z.record(z.string(), providerMetadataEntrySchema$4).optional(),
20432
- usage: gatewayImageUsageSchema$1.optional()
20433
- });
20429
+ warnings: z.array(gatewayImageWarningSchema$1()).optional(),
20430
+ providerMetadata: z.record(z.string(), providerMetadataEntrySchema$4()).optional(),
20431
+ usage: gatewayImageUsageSchema$1().optional()
20432
+ })));
20434
20433
  var GatewayVideoModel$1 = class {
20435
20434
  constructor(modelId, config) {
20436
20435
  this.modelId = modelId;
@@ -20554,8 +20553,8 @@ function maybeEncodeVideoFile$1(file) {
20554
20553
  };
20555
20554
  return file;
20556
20555
  }
20557
- var providerMetadataEntrySchema2 = z.object({ videos: z.array(z.unknown()).optional() }).catchall(z.unknown());
20558
- var gatewayVideoDataSchema$1 = z.union([z.object({
20556
+ var providerMetadataEntrySchema2 = () => z.object({ videos: z.array(z.unknown()).optional() }).catchall(z.unknown());
20557
+ var gatewayVideoDataSchema$1 = () => z.union([z.object({
20559
20558
  type: z.literal("url"),
20560
20559
  url: z.string(),
20561
20560
  mediaType: z.string()
@@ -20564,7 +20563,7 @@ var gatewayVideoDataSchema$1 = z.union([z.object({
20564
20563
  data: z.string(),
20565
20564
  mediaType: z.string()
20566
20565
  })]);
20567
- var gatewayVideoWarningSchema$1 = z.discriminatedUnion("type", [
20566
+ var gatewayVideoWarningSchema$1 = () => z.discriminatedUnion("type", [
20568
20567
  z.object({
20569
20568
  type: z.literal("unsupported"),
20570
20569
  feature: z.string(),
@@ -20585,18 +20584,18 @@ var gatewayVideoWarningSchema$1 = z.discriminatedUnion("type", [
20585
20584
  message: z.string()
20586
20585
  })
20587
20586
  ]);
20588
- var gatewayVideoEventSchema$1 = z.discriminatedUnion("type", [z.object({
20587
+ var gatewayVideoEventSchema$1 = lazySchema$1(() => zodSchema$1(z.discriminatedUnion("type", [z.object({
20589
20588
  type: z.literal("result"),
20590
- videos: z.array(gatewayVideoDataSchema$1),
20591
- warnings: z.array(gatewayVideoWarningSchema$1).optional(),
20592
- providerMetadata: z.record(z.string(), providerMetadataEntrySchema2).optional()
20589
+ videos: z.array(gatewayVideoDataSchema$1()),
20590
+ warnings: z.array(gatewayVideoWarningSchema$1()).optional(),
20591
+ providerMetadata: z.record(z.string(), providerMetadataEntrySchema2()).optional()
20593
20592
  }), z.object({
20594
20593
  type: z.literal("error"),
20595
20594
  message: z.string(),
20596
20595
  errorType: z.string(),
20597
20596
  statusCode: z.number(),
20598
20597
  param: z.unknown().nullable()
20599
- })]);
20598
+ })])));
20600
20599
  var GatewayRerankingModel$1 = class {
20601
20600
  constructor(modelId, config) {
20602
20601
  this.modelId = modelId;
@@ -20653,7 +20652,7 @@ var GatewayRerankingModel$1 = class {
20653
20652
  };
20654
20653
  }
20655
20654
  };
20656
- var gatewayRerankingWarningSchema$1 = z.discriminatedUnion("type", [
20655
+ var gatewayRerankingWarningSchema$1 = () => z.discriminatedUnion("type", [
20657
20656
  z.object({
20658
20657
  type: z.literal("unsupported"),
20659
20658
  feature: z.string(),
@@ -20674,7 +20673,7 @@ var gatewayRerankingResponseSchema$1 = lazySchema$1(() => zodSchema$1(z.object({
20674
20673
  index: z.number(),
20675
20674
  relevanceScore: z.number()
20676
20675
  })),
20677
- warnings: z.array(gatewayRerankingWarningSchema$1).optional(),
20676
+ warnings: z.array(gatewayRerankingWarningSchema$1()).optional(),
20678
20677
  providerMetadata: z.record(z.string(), z.record(z.string(), z.unknown())).optional()
20679
20678
  })));
20680
20679
  var GatewaySpeechModel$1 = class {
@@ -20737,8 +20736,8 @@ var GatewaySpeechModel$1 = class {
20737
20736
  };
20738
20737
  }
20739
20738
  };
20740
- var providerMetadataEntrySchema3 = z.object({}).catchall(z.unknown());
20741
- var gatewaySpeechWarningSchema$1 = z.discriminatedUnion("type", [
20739
+ var providerMetadataEntrySchema3 = () => z.object({}).catchall(z.unknown());
20740
+ var gatewaySpeechWarningSchema$1 = () => z.discriminatedUnion("type", [
20742
20741
  z.object({
20743
20742
  type: z.literal("unsupported"),
20744
20743
  feature: z.string(),
@@ -20759,11 +20758,11 @@ var gatewaySpeechWarningSchema$1 = z.discriminatedUnion("type", [
20759
20758
  message: z.string()
20760
20759
  })
20761
20760
  ]);
20762
- var gatewaySpeechResponseSchema$1 = z.object({
20761
+ var gatewaySpeechResponseSchema$1 = lazySchema$1(() => zodSchema$1(z.object({
20763
20762
  audio: z.string(),
20764
- warnings: z.array(gatewaySpeechWarningSchema$1).optional(),
20765
- providerMetadata: z.record(z.string(), providerMetadataEntrySchema3).optional()
20766
- });
20763
+ warnings: z.array(gatewaySpeechWarningSchema$1()).optional(),
20764
+ providerMetadata: z.record(z.string(), providerMetadataEntrySchema3()).optional()
20765
+ })));
20767
20766
  var GatewayTranscriptionModel$1 = class {
20768
20767
  constructor(modelId, config) {
20769
20768
  this.modelId = modelId;
@@ -20824,8 +20823,8 @@ var GatewayTranscriptionModel$1 = class {
20824
20823
  };
20825
20824
  }
20826
20825
  };
20827
- var providerMetadataEntrySchema4 = z.object({}).catchall(z.unknown());
20828
- var gatewayTranscriptionWarningSchema$1 = z.discriminatedUnion("type", [
20826
+ var providerMetadataEntrySchema4 = () => z.object({}).catchall(z.unknown());
20827
+ var gatewayTranscriptionWarningSchema$1 = () => z.discriminatedUnion("type", [
20829
20828
  z.object({
20830
20829
  type: z.literal("unsupported"),
20831
20830
  feature: z.string(),
@@ -20846,7 +20845,7 @@ var gatewayTranscriptionWarningSchema$1 = z.discriminatedUnion("type", [
20846
20845
  message: z.string()
20847
20846
  })
20848
20847
  ]);
20849
- var gatewayTranscriptionResponseSchema$1 = z.object({
20848
+ var gatewayTranscriptionResponseSchema$1 = lazySchema$1(() => zodSchema$1(z.object({
20850
20849
  text: z.string(),
20851
20850
  segments: z.array(z.object({
20852
20851
  text: z.string(),
@@ -20855,10 +20854,10 @@ var gatewayTranscriptionResponseSchema$1 = z.object({
20855
20854
  })).optional(),
20856
20855
  language: z.string().nullish(),
20857
20856
  durationInSeconds: z.number().nullish(),
20858
- warnings: z.array(gatewayTranscriptionWarningSchema$1).optional(),
20859
- providerMetadata: z.record(z.string(), providerMetadataEntrySchema4).optional()
20860
- });
20861
- var jsonObjectSchema$1 = z$2.record(z$2.string(), z$2.unknown());
20857
+ warnings: z.array(gatewayTranscriptionWarningSchema$1()).optional(),
20858
+ providerMetadata: z.record(z.string(), providerMetadataEntrySchema4()).optional()
20859
+ })));
20860
+ var jsonObjectSchema$1 = () => z$2.record(z$2.string(), z$2.unknown());
20862
20861
  var browserbaseFetchToolFactory$1 = createProviderToolFactoryWithOutputSchema({
20863
20862
  id: "gateway.browserbase_fetch",
20864
20863
  inputSchema: lazySchema$1(() => zodSchema$1(z$2.object({
@@ -20871,11 +20870,11 @@ var browserbaseFetchToolFactory$1 = createProviderToolFactoryWithOutputSchema({
20871
20870
  "json",
20872
20871
  "markdown"
20873
20872
  ]).optional().describe("Output format. raw returns the response body unchanged, markdown returns page content as Markdown, and json returns structured content using schema."),
20874
- schema: jsonObjectSchema$1.optional().describe("JSON Schema for structured extraction. Only use with format set to json.")
20873
+ schema: jsonObjectSchema$1().optional().describe("JSON Schema for structured extraction. Only use with format set to json.")
20875
20874
  }))),
20876
20875
  outputSchema: lazySchema$1(() => zodSchema$1(z$2.union([z$2.object({
20877
20876
  id: z$2.string(),
20878
- content: z$2.union([z$2.string(), jsonObjectSchema$1]),
20877
+ content: z$2.union([z$2.string(), jsonObjectSchema$1()]),
20879
20878
  contentType: z$2.string(),
20880
20879
  encoding: z$2.string(),
20881
20880
  headers: z$2.record(z$2.string(), z$2.string()),
@@ -21034,41 +21033,67 @@ var exaSearchToolFactory$1 = createProviderToolFactoryWithOutputSchema({
21034
21033
  })])))
21035
21034
  });
21036
21035
  var exaSearch$1 = (config = {}) => exaSearchToolFactory$1(config);
21036
+ var parallelSearchModes$1 = [
21037
+ "turbo",
21038
+ "fast",
21039
+ "basic",
21040
+ "advanced",
21041
+ "one-shot",
21042
+ "agentic"
21043
+ ];
21037
21044
  var parallelSearchToolFactory$1 = createProviderToolFactoryWithOutputSchema({
21038
21045
  id: "gateway.parallel_search",
21039
21046
  inputSchema: lazySchema$1(() => zodSchema$1(z$2.object({
21040
21047
  objective: z$2.string().describe("Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."),
21041
- search_queries: z$2.array(z$2.string()).optional().describe("Optional search queries to supplement the objective. Maximum 200 characters per query."),
21042
- mode: z$2.enum(["one-shot", "agentic"]).optional().describe("Mode preset: \"one-shot\" for comprehensive results with longer excerpts (default), \"agentic\" for concise, token-efficient results for multi-step workflows."),
21048
+ search_queries: z$2.array(z$2.string()).optional().describe("Provide 2-3 concise keyword queries, 3-6 words each (max 5, 200 chars each). Strongly recommended; the search runs on these queries."),
21049
+ mode: z$2.enum(parallelSearchModes$1).optional().describe("Search mode: \"turbo\" and \"fast\" return quickly with shorter excerpts, \"basic\" is balanced (default), \"advanced\" is the most thorough. \"turbo\" supports English and Japanese only. \"one-shot\" and \"agentic\" are deprecated aliases of \"basic\" and \"advanced\"."),
21043
21050
  max_results: z$2.number().optional().describe("Maximum number of results to return (1-20). Defaults to 10 if not specified."),
21044
21051
  source_policy: z$2.object({
21045
- include_domains: z$2.array(z$2.string()).optional().describe("Limit results to these domains. Use plain domain names only — e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page)."),
21046
- exclude_domains: z$2.array(z$2.string()).optional().describe("Exclude results from these domains. Use plain domain names only — e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page)."),
21047
- after_date: z$2.string().optional().describe("Only include results published after this date. Use an ISO 8601 calendar date formatted YYYY-MM-DD (e.g. 2025-01-01); do not include a time.")
21052
+ include_domains: z$2.array(z$2.string()).optional().describe("Domains or domain/path prefixes to restrict results to, without scheme or port. Example: ['wikipedia.org', 'docs.python.org/3']."),
21053
+ exclude_domains: z$2.array(z$2.string()).optional().describe("Domains or domain/path prefixes to exclude, without scheme or port. Example: ['reddit.com']."),
21054
+ after_date: z$2.string().optional().describe("Only include results published on or after this date. Use an ISO 8601 calendar date formatted YYYY-MM-DD (e.g. 2025-01-01); do not include a time.")
21048
21055
  }).optional().describe("Source policy for controlling which domains to include/exclude and freshness."),
21049
21056
  excerpts: z$2.object({
21050
21057
  max_chars_per_result: z$2.number().optional().describe("Maximum characters per result."),
21051
- max_chars_total: z$2.number().optional().describe("Maximum total characters across all results.")
21058
+ max_chars_total: z$2.number().optional().describe("Deprecated: use the top-level max_chars_total.")
21052
21059
  }).optional().describe("Excerpt configuration for controlling result length."),
21053
- fetch_policy: z$2.object({ max_age_seconds: z$2.number().optional().describe("Maximum age in seconds for cached content. Set to 0 to always fetch fresh content.") }).optional().describe("Fetch policy for controlling content freshness.")
21060
+ max_chars_total: z$2.number().optional().describe("Maximum total characters across all result excerpts."),
21061
+ fetch_policy: z$2.object({
21062
+ max_age_seconds: z$2.number().optional().describe("Maximum age of cached content in seconds before a live fetch, minimum 600."),
21063
+ timeout_seconds: z$2.number().optional().describe("Timeout in seconds for a live fetch when content is not cached. Capped by the gateway tool timeout."),
21064
+ disable_cache_fallback: z$2.boolean().optional().describe("Return an error instead of older cached content when a live fetch fails.")
21065
+ }).optional().describe("Fetch policy for controlling content freshness."),
21066
+ location: z$2.string().optional().describe("ISO 3166-1 alpha-2 country code to localize results, e.g. \"us\".")
21054
21067
  }))),
21055
21068
  outputSchema: lazySchema$1(() => zodSchema$1(z$2.union([z$2.object({
21056
- searchId: z$2.string(),
21069
+ search_id: z$2.string(),
21057
21070
  results: z$2.array(z$2.object({
21058
21071
  url: z$2.string(),
21059
- title: z$2.string(),
21060
- excerpt: z$2.string(),
21061
- publishDate: z$2.string().nullable().optional(),
21062
- relevanceScore: z$2.number().optional()
21063
- }))
21072
+ title: z$2.string().nullable().optional(),
21073
+ publish_date: z$2.string().nullable().optional(),
21074
+ excerpts: z$2.array(z$2.string())
21075
+ })),
21076
+ warnings: z$2.array(z$2.object({
21077
+ type: z$2.string(),
21078
+ message: z$2.string(),
21079
+ detail: z$2.record(z$2.string(), z$2.unknown()).nullable().optional()
21080
+ })).nullable().optional(),
21081
+ usage: z$2.array(z$2.object({
21082
+ name: z$2.string(),
21083
+ count: z$2.number().optional()
21084
+ })).nullable().optional(),
21085
+ session_id: z$2.string().optional()
21064
21086
  }), z$2.object({
21065
21087
  error: z$2.enum([
21066
21088
  "api_error",
21089
+ "configuration_error",
21090
+ "execution_error",
21091
+ "gateway_rate_limit",
21092
+ "invalid_input",
21067
21093
  "rate_limit",
21068
21094
  "timeout",
21069
- "invalid_input",
21070
- "configuration_error",
21071
- "unknown"
21095
+ "unknown",
21096
+ "unknown_tool"
21072
21097
  ]),
21073
21098
  statusCode: z$2.number().optional(),
21074
21099
  message: z$2.string()
@@ -21118,7 +21143,7 @@ var perplexitySearchToolFactory$1 = createProviderToolFactoryWithOutputSchema({
21118
21143
  })])))
21119
21144
  });
21120
21145
  var perplexitySearch$1 = (config = {}) => perplexitySearchToolFactory$1(config);
21121
- var takoDataSourceInputSchema$1 = z$2.object({
21146
+ var takoDataSourceInputSchema$1 = () => z$2.object({
21122
21147
  count: z$2.number().optional().describe("Maximum number of data results to return (1-20). When include_contents is true, each additional result adds its own data surcharge."),
21123
21148
  include_contents: z$2.boolean().optional().describe("Inline rows for each data result. This adds a data surcharge based on row count and dataset source. To estimate cost, search with include_contents disabled and inspect cards.content.export_pricing. This applies to every returned card; limit sources.data.count and sources.data.max_rows to control cost."),
21124
21149
  mode: z$2.enum(["inline", "url"]).optional().describe("Requested data delivery mode. Search card data is always inline."),
@@ -21132,7 +21157,7 @@ var takoDataSourceInputSchema$1 = z$2.object({
21132
21157
  node_ids: z$2.array(z$2.string()).optional().describe("Data Graph node IDs to prioritize. Maximum 20."),
21133
21158
  strict: z$2.boolean().optional().describe("Only return cards matching node_ids. Requires a non-empty node_ids.")
21134
21159
  });
21135
- var takoWebSourceInputSchema$1 = z$2.object({
21160
+ var takoWebSourceInputSchema$1 = () => z$2.object({
21136
21161
  count: z$2.number().optional().describe("Maximum number of web results to return (1-20)."),
21137
21162
  include_contents: z$2.boolean().optional().describe("Inline extracted web page text. This can add a data charge."),
21138
21163
  category: z$2.enum([
@@ -21156,8 +21181,8 @@ var takoSearchInputSchema$1 = lazySchema$1(() => zodSchema$1(z$2.object({
21156
21181
  "instant"
21157
21182
  ]).optional().describe("Search effort. fast is the balanced default, instant favors cached results and low latency, and deep broadens retrieval with reranking at higher cost and latency."),
21158
21183
  sources: z$2.object({
21159
- data: takoDataSourceInputSchema$1.optional(),
21160
- web: takoWebSourceInputSchema$1.optional()
21184
+ data: takoDataSourceInputSchema$1().optional(),
21185
+ web: takoWebSourceInputSchema$1().optional()
21161
21186
  }).optional().describe("Sources to search. Omit to search both curated data and the web. When provided, only keys present are searched."),
21162
21187
  location: z$2.object({
21163
21188
  latitude: z$2.number().describe("Latitude between -90 and 90."),
@@ -21172,12 +21197,12 @@ var takoSearchInputSchema$1 = lazySchema$1(() => zodSchema$1(z$2.object({
21172
21197
  }).optional().describe("Controls card rendering in the search response."),
21173
21198
  include_related: z$2.number().optional().describe("Maximum related search suggestions to include (1-20).")
21174
21199
  })));
21175
- var takoDatasetCellSchema$1 = z$2.union([
21200
+ var takoDatasetCellSchema$1 = () => z$2.union([
21176
21201
  z$2.boolean(),
21177
21202
  z$2.number(),
21178
21203
  z$2.string()
21179
21204
  ]).nullable();
21180
- var takoResultContentSchema$1 = z$2.object({
21205
+ var takoResultContentSchema$1 = () => z$2.object({
21181
21206
  content_format: z$2.enum([
21182
21207
  "card_json",
21183
21208
  "csv",
@@ -21186,7 +21211,7 @@ var takoResultContentSchema$1 = z$2.object({
21186
21211
  ]).nullish(),
21187
21212
  cost: z$2.number().optional(),
21188
21213
  data: z$2.string().nullish(),
21189
- records: z$2.array(z$2.record(z$2.string(), takoDatasetCellSchema$1)).nullish(),
21214
+ records: z$2.array(z$2.record(z$2.string(), takoDatasetCellSchema$1())).nullish(),
21190
21215
  dataset: z$2.object({
21191
21216
  columns: z$2.array(z$2.object({
21192
21217
  name: z$2.string(),
@@ -21199,7 +21224,7 @@ var takoResultContentSchema$1 = z$2.object({
21199
21224
  ]),
21200
21225
  unit: z$2.string().nullish()
21201
21226
  })),
21202
- rows: z$2.array(z$2.array(takoDatasetCellSchema$1)),
21227
+ rows: z$2.array(z$2.array(takoDatasetCellSchema$1())),
21203
21228
  total_rows: z$2.number(),
21204
21229
  truncated: z$2.boolean(),
21205
21230
  ref: z$2.string(),
@@ -21235,7 +21260,7 @@ var takoResultContentSchema$1 = z$2.object({
21235
21260
  unit: z$2.string().nullish()
21236
21261
  })).nullish()
21237
21262
  }).passthrough();
21238
- var takoCardSchema$1 = z$2.object({
21263
+ var takoCardSchema$1 = () => z$2.object({
21239
21264
  card_id: z$2.string().nullish(),
21240
21265
  title: z$2.string().nullish(),
21241
21266
  description: z$2.string().nullish(),
@@ -21261,7 +21286,7 @@ var takoCardSchema$1 = z$2.object({
21261
21286
  "Low",
21262
21287
  "Medium"
21263
21288
  ]).nullish(),
21264
- content: takoResultContentSchema$1.nullish(),
21289
+ content: takoResultContentSchema$1().nullish(),
21265
21290
  exportable: z$2.boolean().optional(),
21266
21291
  nodes: z$2.array(z$2.object({
21267
21292
  id: z$2.string(),
@@ -21279,21 +21304,21 @@ var takoCardSchema$1 = z$2.object({
21279
21304
  last_updated: z$2.string().nullish()
21280
21305
  }).nullish()
21281
21306
  }).passthrough();
21282
- var takoWebResultSchema$1 = z$2.object({
21307
+ var takoWebResultSchema$1 = () => z$2.object({
21283
21308
  title: z$2.string(),
21284
21309
  url: z$2.string(),
21285
21310
  snippet: z$2.string().nullish(),
21286
21311
  source_name: z$2.string().nullish(),
21287
21312
  publish_date: z$2.string().nullish(),
21288
- content: takoResultContentSchema$1.nullish()
21313
+ content: takoResultContentSchema$1().nullish()
21289
21314
  }).passthrough();
21290
21315
  var takoSearchToolFactory$1 = createProviderToolFactoryWithOutputSchema({
21291
21316
  id: "gateway.tako_search",
21292
21317
  inputSchema: takoSearchInputSchema$1,
21293
21318
  outputSchema: lazySchema$1(() => zodSchema$1(z$2.union([z$2.object({
21294
21319
  request_id: z$2.string(),
21295
- cards: z$2.array(takoCardSchema$1).optional(),
21296
- web_results: z$2.array(takoWebResultSchema$1).optional(),
21320
+ cards: z$2.array(takoCardSchema$1()).optional(),
21321
+ web_results: z$2.array(takoWebResultSchema$1()).optional(),
21297
21322
  usage: z$2.object({
21298
21323
  total_cost_usd: z$2.number(),
21299
21324
  compute: z$2.object({ cost_usd: z$2.number() }).nullish(),
@@ -21372,7 +21397,7 @@ async function getVercelRequestId$1() {
21372
21397
  var _a11;
21373
21398
  return (_a11 = getContext$1().headers) == null ? void 0 : _a11["x-vercel-id"];
21374
21399
  }
21375
- var VERSION$4 = "3.0.217";
21400
+ var VERSION$4 = "3.0.221";
21376
21401
  var AI_GATEWAY_PROTOCOL_VERSION$1 = "0.0.1";
21377
21402
  function createGatewayProvider(options = {}) {
21378
21403
  var _a11, _b11;
@@ -22529,7 +22554,7 @@ function getTotalTimeoutMs(timeout) {
22529
22554
  if (typeof timeout === "number") return timeout;
22530
22555
  return timeout.totalMs;
22531
22556
  }
22532
- var VERSION$3 = "6.0.309";
22557
+ var VERSION$3 = "6.0.315";
22533
22558
  var dataContentSchema$3 = z.union([
22534
22559
  z.string(),
22535
22560
  z.instanceof(Uint8Array),
@@ -23936,26 +23961,30 @@ const LF = 10;
23936
23961
  const CR = 13;
23937
23962
  const SPACE = 32;
23938
23963
  function noop(_arg) {}
23939
- function createParser(callbacks) {
23940
- if (typeof callbacks == "function") throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");
23941
- const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks, pendingFragments = [];
23942
- let isFirstChunk = !0, id, data = "", dataLines = 0, eventType;
23964
+ function createParser(config) {
23965
+ if (typeof config == "function") throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");
23966
+ const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config, pendingFragments = [];
23967
+ let pendingFragmentsLength = 0, isFirstChunk = !0, id, data = "", dataLines = 0, eventType, terminated = !1;
23943
23968
  function feed(chunk) {
23969
+ if (terminated) throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");
23944
23970
  if (isFirstChunk && (isFirstChunk = !1, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
23945
23971
  const trailing2 = processLines(chunk);
23946
- trailing2 !== "" && pendingFragments.push(trailing2);
23972
+ trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
23947
23973
  return;
23948
23974
  }
23949
23975
  if (chunk.indexOf(`
23950
23976
  `) === -1 && chunk.indexOf("\r") === -1) {
23951
- pendingFragments.push(chunk);
23977
+ pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
23952
23978
  return;
23953
23979
  }
23954
23980
  pendingFragments.push(chunk);
23955
23981
  const input = pendingFragments.join("");
23956
- pendingFragments.length = 0;
23982
+ pendingFragments.length = 0, pendingFragmentsLength = 0;
23957
23983
  const trailing = processLines(input);
23958
- trailing !== "" && pendingFragments.push(trailing);
23984
+ trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
23985
+ }
23986
+ function checkBufferSize() {
23987
+ maxBufferSize !== void 0 && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = !0, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data = "", dataLines = 0, eventType = void 0, onError(new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, { type: "max-buffer-size-exceeded" }))));
23959
23988
  }
23960
23989
  function processLines(chunk) {
23961
23990
  let searchIndex = 0;
@@ -24019,7 +24048,7 @@ ${value2}`, dataLines++;
24019
24048
  }
24020
24049
  if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
24021
24050
  const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
24022
- id = value2.includes("\0") ? void 0 : value2;
24051
+ value2.includes("\0") || (id = value2);
24023
24052
  return;
24024
24053
  }
24025
24054
  if (firstCharCode === 58) {
@@ -24047,7 +24076,7 @@ ${value2}`, dataLines++;
24047
24076
  ${value}`, dataLines++;
24048
24077
  break;
24049
24078
  case "id":
24050
- id = value.includes("\0") ? void 0 : value;
24079
+ value.includes("\0") || (id = value);
24051
24080
  break;
24052
24081
  case "retry":
24053
24082
  /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(new ParseError(`Invalid \`retry\` value: "${value}"`, {
@@ -24076,7 +24105,7 @@ ${value}`, dataLines++;
24076
24105
  const incompleteLine = pendingFragments.join("");
24077
24106
  parseLine(incompleteLine, 0, incompleteLine.length);
24078
24107
  }
24079
- isFirstChunk = !0, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0;
24108
+ isFirstChunk = !0, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = !1;
24080
24109
  }
24081
24110
  return {
24082
24111
  feed,
@@ -24090,7 +24119,7 @@ function isEventPrefix(chunk, i, firstCharCode) {
24090
24119
  return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
24091
24120
  }
24092
24121
  var EventSourceParserStream = class extends TransformStream {
24093
- constructor({ onError, onRetry, onComment } = {}) {
24122
+ constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
24094
24123
  let parser;
24095
24124
  super({
24096
24125
  start(controller) {
@@ -24099,10 +24128,11 @@ var EventSourceParserStream = class extends TransformStream {
24099
24128
  controller.enqueue(event);
24100
24129
  },
24101
24130
  onError(error) {
24102
- onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error);
24131
+ typeof onError == "function" && onError(error), (onError === "terminate" || error.type === "max-buffer-size-exceeded") && controller.error(error);
24103
24132
  },
24104
24133
  onRetry,
24105
- onComment
24134
+ onComment,
24135
+ maxBufferSize
24106
24136
  });
24107
24137
  },
24108
24138
  transform(chunk) {
@@ -24388,7 +24418,7 @@ function handleFetchError({ error, url, requestBodyValues }) {
24388
24418
  }
24389
24419
  return error;
24390
24420
  }
24391
- const VERSION$2 = "5.0.62";
24421
+ const VERSION$2 = "5.0.68";
24392
24422
  /**
24393
24423
  * Normalizes different header inputs into a plain record with lower-case keys.
24394
24424
  * Entries with `undefined` or `null` values are removed.
@@ -24520,7 +24550,7 @@ function validateDownloadUrl(url) {
24520
24550
  url,
24521
24551
  message: `URL must have a hostname`
24522
24552
  });
24523
- if (hostname === "localhost" || hostname.endsWith(".local") || hostname.endsWith(".localhost")) throw new DownloadError({
24553
+ if (hostname === "localhost" || hostname.endsWith(".local") || hostname.endsWith(".localhost") || hostname.endsWith(".internal")) throw new DownloadError({
24524
24554
  url,
24525
24555
  message: `URL with hostname ${hostname} is not allowed`
24526
24556
  });
@@ -24894,7 +24924,7 @@ async function readResponseWithSizeLimit({ response, url, maxBytes = DEFAULT_MAX
24894
24924
  url,
24895
24925
  message: `Download of ${url} exceeded maximum size of ${maxBytes} bytes.`
24896
24926
  });
24897
- chunks.push(value);
24927
+ chunks.push(value.byteLength < value.buffer.byteLength ? new Uint8Array(value) : value);
24898
24928
  }
24899
24929
  } finally {
24900
24930
  try {
@@ -26652,6 +26682,132 @@ function resolveSync(value) {
26652
26682
  return next;
26653
26683
  }
26654
26684
  /**
26685
+ * Experimental speech-stream WebSocket envelope (v1): the standard
26686
+ * serialization of `Experimental_StreamingSpeechModelV4.doStream` over a WebSocket. Clients (e.g.
26687
+ * the `@ai-sdk/gateway` provider) encode with this module and servers (e.g.
26688
+ * AI Gateway) decode with it, so the two sides cannot drift.
26689
+ *
26690
+ * Envelope rules:
26691
+ *
26692
+ * 1. The client sends exactly one `speech-stream.start` TEXT frame first.
26693
+ * 2. Input text rides `speech-stream.text-delta` TEXT frames, in order. A
26694
+ * frame may carry its text part's `voice` and `providerOptions`. A long
26695
+ * part may span several frames: `voice` is repeated on each, and
26696
+ * `providerOptions` appear on the first only, so they must describe an
26697
+ * event at the start of the part (e.g. a turn break), not a setting. An
26698
+ * empty `delta` is valid and carries only part metadata; it does not end
26699
+ * the input.
26700
+ * 3. The client signals the end of the input text with the
26701
+ * `speech-stream.text-done` TEXT frame; a plain close without it is an
26702
+ * abort.
26703
+ * 4. Every server→client TEXT frame is one JSON-serialized
26704
+ * `SpeechModelV4StreamPart` (flattened, no wrapper). `audio` payloads are
26705
+ * base64 strings. `Date` values (`response-metadata.timestamp`) serialize
26706
+ * to ISO 8601 strings and are revived by `parseSpeechStreamPart`. `Error`
26707
+ * payloads in `error` parts serialize as `{ name, message }`; servers may
26708
+ * instead send `{ type, message }`, where `type` names an error class the
26709
+ * client can map to a typed error (e.g. `invalid_request_error`).
26710
+ * 5. The server closes with code 1000 after the `finish` part. Over this
26711
+ * envelope an `error` part is terminal: the server sends it on failure and
26712
+ * then closes non-1000. A close without a prior `finish` is an error.
26713
+ * 6. Unknown frame/part types are ignored in both directions (forward
26714
+ * compatibility).
26715
+ * 7. Servers may enforce a maximum frame size (the AI Gateway rejects frames
26716
+ * over 256 KiB); clients should keep text-delta frames under 64 KiB.
26717
+ * 8. Connection establishment (URL, auth) is transport-specific and out of
26718
+ * scope.
26719
+ *
26720
+ * The envelope validates frame shape only; server policy layers on top. Both
26721
+ * parsers use `secureJsonParse`, so frames carrying `__proto__` /
26722
+ * `constructor.prototype` keys are rejected rather than parsed.
26723
+ */
26724
+ /** Type of the first client TEXT frame. */
26725
+ const SPEECH_STREAM_START_FRAME_TYPE = "speech-stream.start";
26726
+ /** Type of the client TEXT frame that carries one input text delta. */
26727
+ const SPEECH_STREAM_TEXT_DELTA_FRAME_TYPE = "speech-stream.text-delta";
26728
+ /** Type of the client TEXT frame that signals the end of the input text. */
26729
+ const SPEECH_STREAM_TEXT_DONE_FRAME_TYPE = "speech-stream.text-done";
26730
+ /**
26731
+ * Client-side: parse a server TEXT frame into a speech stream part. Returns
26732
+ * `undefined` for malformed or unsafe JSON, unknown part types, and known
26733
+ * part types whose fields are missing or mistyped. Revives
26734
+ * `response-metadata.timestamp` to a `Date`.
26735
+ */
26736
+ function parseSpeechStreamPart(text) {
26737
+ let value;
26738
+ try {
26739
+ value = secureJsonParse$3(text);
26740
+ } catch {
26741
+ return;
26742
+ }
26743
+ if (!isRecord$6(value)) return;
26744
+ const part = value;
26745
+ switch (part.type) {
26746
+ case "stream-start": {
26747
+ if (!Array.isArray(part.warnings)) return;
26748
+ const warnings = part.warnings.filter((warning) => !isUnknownWarningType(warning));
26749
+ return warnings.every(isWarning$1) ? {
26750
+ ...part,
26751
+ warnings
26752
+ } : void 0;
26753
+ }
26754
+ case "audio": return isString$1(part.audio) && isAudioFormat(part.audioFormat) && isOptional$1(part.id, isString$1) && isOptional$1(part.providerMetadata, isRecord$6) ? part : void 0;
26755
+ case "finish": return isOptional$1(part.usage, isUsage) && isOptional$1(part.providerMetadata, isRecord$6) ? part : void 0;
26756
+ case "response-metadata": {
26757
+ if (!(isOptional$1(part.modelId, isString$1) && isOptional$1(part.headers, isRecord$6))) return;
26758
+ const timestamp = part.timestamp;
26759
+ if (timestamp == null) return {
26760
+ ...part,
26761
+ timestamp: void 0
26762
+ };
26763
+ if (typeof timestamp !== "string") return;
26764
+ const revived = new Date(timestamp);
26765
+ return Number.isNaN(revived.getTime()) ? void 0 : {
26766
+ ...part,
26767
+ timestamp: revived
26768
+ };
26769
+ }
26770
+ case "raw": return "rawValue" in part ? part : void 0;
26771
+ case "error": return "error" in part ? part : void 0;
26772
+ default: return;
26773
+ }
26774
+ }
26775
+ function isString$1(value) {
26776
+ return typeof value === "string";
26777
+ }
26778
+ function isOptional$1(value, check) {
26779
+ return value === void 0 || check(value);
26780
+ }
26781
+ const knownWarningTypes = /* @__PURE__ */ new Set([
26782
+ "compatibility",
26783
+ "deprecated",
26784
+ "other",
26785
+ "unsupported"
26786
+ ]);
26787
+ function isUnknownWarningType(value) {
26788
+ return isRecord$6(value) && isString$1(value.type) && !knownWarningTypes.has(value.type);
26789
+ }
26790
+ function isWarning$1(value) {
26791
+ if (!isRecord$6(value)) return false;
26792
+ switch (value.type) {
26793
+ case "compatibility":
26794
+ case "unsupported": return isString$1(value.feature) && isOptional$1(value.details, isString$1);
26795
+ case "deprecated": return isString$1(value.setting) && isString$1(value.message);
26796
+ case "other": return isString$1(value.message);
26797
+ default: return false;
26798
+ }
26799
+ }
26800
+ function isAudioFormat(value) {
26801
+ return isRecord$6(value) && isString$1(value.type) && value.type.length > 0 && isOptional$1(value.rate, (rate) => typeof rate === "number" && Number.isFinite(rate) && rate > 0);
26802
+ }
26803
+ function isUsage(value) {
26804
+ return isRecord$6(value) && [
26805
+ "inputCharacters",
26806
+ "inputTokens",
26807
+ "outputTokens"
26808
+ ].every((key) => isOptional$1(value[key], (count) => typeof count === "number"));
26809
+ }
26810
+ /**
26655
26811
  * Experimental transcription-stream WebSocket envelope (v1): the standard
26656
26812
  * serialization of `TranscriptionModelV4.doStream` over a WebSocket. Clients
26657
26813
  * (e.g. the `@ai-sdk/gateway` provider) encode with this module and servers
@@ -26712,12 +26868,12 @@ function parseTranscriptionStreamPart(text) {
26712
26868
  const part = value;
26713
26869
  switch (part.type) {
26714
26870
  case "stream-start": return Array.isArray(part.warnings) && part.warnings.every(isWarning) ? part : void 0;
26715
- case "transcript-delta": return isString$1(part.delta) && isOptional(part.id, isString$1) && isOptional(part.providerMetadata, isRecord$6) ? part : void 0;
26716
- case "transcript-partial": return isString$1(part.text) && isOptional(part.id, isString$1) && isOptional(part.startSecond, isNumber) && isOptional(part.durationInSeconds, isNumber) && isOptional(part.channelIndex, isNumber) && isOptional(part.providerMetadata, isRecord$6) ? part : void 0;
26717
- case "transcript-final": return isString$1(part.text) && isOptional(part.id, isString$1) && isOptional(part.startSecond, isNumber) && isOptional(part.endSecond, isNumber) && isOptional(part.channelIndex, isNumber) && isOptional(part.providerMetadata, isRecord$6) ? part : void 0;
26718
- case "finish": return isString$1(part.text) && Array.isArray(part.segments) && part.segments.every(isSegment) && isOptional(part.language, isString$1) && isOptional(part.durationInSeconds, isNumber) && isOptional(part.usage, isRecord$6) && isOptional(part.providerMetadata, isRecord$6) ? part : void 0;
26871
+ case "transcript-delta": return isString$2(part.delta) && isOptional(part.id, isString$2) && isOptional(part.providerMetadata, isRecord$6) ? part : void 0;
26872
+ case "transcript-partial": return isString$2(part.text) && isOptional(part.id, isString$2) && isOptional(part.startSecond, isNumber) && isOptional(part.durationInSeconds, isNumber) && isOptional(part.channelIndex, isNumber) && isOptional(part.providerMetadata, isRecord$6) ? part : void 0;
26873
+ case "transcript-final": return isString$2(part.text) && isOptional(part.id, isString$2) && isOptional(part.startSecond, isNumber) && isOptional(part.endSecond, isNumber) && isOptional(part.channelIndex, isNumber) && isOptional(part.providerMetadata, isRecord$6) ? part : void 0;
26874
+ case "finish": return isString$2(part.text) && Array.isArray(part.segments) && part.segments.every(isSegment) && isOptional(part.language, isString$2) && isOptional(part.durationInSeconds, isNumber) && isOptional(part.usage, isRecord$6) && isOptional(part.providerMetadata, isRecord$6) ? part : void 0;
26719
26875
  case "response-metadata": {
26720
- if (!(isOptional(part.modelId, isString$1) && isOptional(part.headers, isRecord$6))) return;
26876
+ if (!(isOptional(part.modelId, isString$2) && isOptional(part.headers, isRecord$6))) return;
26721
26877
  const timestamp = part.timestamp;
26722
26878
  if (timestamp == null) return {
26723
26879
  ...part,
@@ -26735,7 +26891,7 @@ function parseTranscriptionStreamPart(text) {
26735
26891
  default: return;
26736
26892
  }
26737
26893
  }
26738
- function isString$1(value) {
26894
+ function isString$2(value) {
26739
26895
  return typeof value === "string";
26740
26896
  }
26741
26897
  function isNumber(value) {
@@ -26745,10 +26901,10 @@ function isOptional(value, check) {
26745
26901
  return value === void 0 || check(value);
26746
26902
  }
26747
26903
  function isWarning(value) {
26748
- return isRecord$6(value) && isString$1(value.type);
26904
+ return isRecord$6(value) && isString$2(value.type);
26749
26905
  }
26750
26906
  function isSegment(value) {
26751
- return isRecord$6(value) && isString$1(value.text) && isNumber(value.startSecond) && isNumber(value.endSecond);
26907
+ return isRecord$6(value) && isString$2(value.text) && isNumber(value.startSecond) && isNumber(value.endSecond);
26752
26908
  }
26753
26909
  function withoutTrailingSlash(url) {
26754
26910
  return url?.replace(/\/$/, "");
@@ -26790,8 +26946,8 @@ async function getVercelOidcToken() {
26790
26946
  throw new Error("@vercel/oidc is not available in the vendored @internal AI packages. Provide an API key instead.");
26791
26947
  }
26792
26948
  /**
26793
- * Shared WebSocket subprotocol contract for AI Gateway realtime and streaming
26794
- * transcription auth.
26949
+ * Shared WebSocket subprotocol contract for AI Gateway realtime, streaming
26950
+ * transcription, and streaming speech auth.
26795
26951
  *
26796
26952
  * The browser `WebSocket` API cannot set request headers, so the Gateway auth
26797
26953
  * (bearer) token is carried through the `Sec-WebSocket-Protocol` handshake
@@ -26800,7 +26956,8 @@ async function getVercelOidcToken() {
26800
26956
  *
26801
26957
  * This module is the single source of truth for that contract so the client and
26802
26958
  * the Gateway server can't drift: the client encodes values with
26803
- * `getGatewayRealtimeProtocols` / `getGatewayTranscriptionProtocols`, and the
26959
+ * `getGatewayRealtimeProtocols` / `getGatewayTranscriptionProtocols` /
26960
+ * `getGatewaySpeechProtocols`, and the
26804
26961
  * Gateway server decodes them with `getGatewayRealtimeAuthToken` /
26805
26962
  * `getGatewayRealtimeTeamIdOrSlug`.
26806
26963
  *
@@ -26821,6 +26978,11 @@ const GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realtime.v1";
26821
26978
  * purpose as `GATEWAY_REALTIME_SUBPROTOCOL`).
26822
26979
  */
26823
26980
  const GATEWAY_TRANSCRIPTION_SUBPROTOCOL = "ai-gateway-transcription.v1";
26981
+ /**
26982
+ * Marker subprotocol for streaming speech handshakes (same negotiation
26983
+ * purpose as `GATEWAY_REALTIME_SUBPROTOCOL`).
26984
+ */
26985
+ const GATEWAY_SPEECH_SUBPROTOCOL = "ai-gateway-speech.v1";
26824
26986
  /** Subprotocol prefix that carries the Gateway auth (bearer) token. */
26825
26987
  const GATEWAY_AUTH_SUBPROTOCOL_PREFIX = "ai-gateway-auth.";
26826
26988
  /** Subprotocol prefix that carries optional Vercel team scoping. */
@@ -26839,6 +27001,13 @@ function getGatewayRealtimeProtocols(token, options) {
26839
27001
  function getGatewayTranscriptionProtocols(token, options) {
26840
27002
  return buildGatewayProtocols(GATEWAY_TRANSCRIPTION_SUBPROTOCOL, token, options);
26841
27003
  }
27004
+ /**
27005
+ * Client-side: `getGatewayRealtimeProtocols`, but with the streaming speech
27006
+ * marker subprotocol.
27007
+ */
27008
+ function getGatewaySpeechProtocols(token, options) {
27009
+ return buildGatewayProtocols(GATEWAY_SPEECH_SUBPROTOCOL, token, options);
27010
+ }
26842
27011
  function buildGatewayProtocols(marker, token, options) {
26843
27012
  const protocols = [marker, `${GATEWAY_AUTH_SUBPROTOCOL_PREFIX}${token}`];
26844
27013
  if (options?.teamIdOrSlug) protocols.push(`${GATEWAY_TEAM_SUBPROTOCOL_PREFIX}${encodeSubprotocolValue(options.teamIdOrSlug)}`);
@@ -27792,7 +27961,7 @@ async function* convertGatewayBatchResultLines(lines) {
27792
27961
  yield item;
27793
27962
  }
27794
27963
  }
27795
- const gatewayBatchItemResultLineSchema = z$3.object({
27964
+ const gatewayBatchItemResultLineSchema = lazySchema(() => zodSchema$4(z$3.object({
27796
27965
  type: z$3.literal("text"),
27797
27966
  id: z$3.string(),
27798
27967
  status: z$3.enum([
@@ -27801,41 +27970,41 @@ const gatewayBatchItemResultLineSchema = z$3.object({
27801
27970
  "failed",
27802
27971
  "succeeded"
27803
27972
  ])
27804
- }).catchall(z$3.unknown());
27805
- const gatewayBatchErrorSchema = z$3.object({
27973
+ }).catchall(z$3.unknown())));
27974
+ const gatewayBatchErrorSchema = () => z$3.object({
27806
27975
  message: z$3.string(),
27807
27976
  type: z$3.string().nullish(),
27808
27977
  code: z$3.string().nullish(),
27809
27978
  statusCode: z$3.number().nullish()
27810
27979
  });
27811
- const gatewayBatchRequestCountsSchema = z$3.object({
27980
+ const gatewayBatchRequestCountsSchema = () => z$3.object({
27812
27981
  total: z$3.number().nullish(),
27813
27982
  pending: z$3.number().nullish(),
27814
27983
  completed: z$3.number().nullish(),
27815
27984
  failed: z$3.number().nullish()
27816
27985
  });
27817
- const gatewayBatchProviderMetadataSchema = z$3.record(z$3.string(), z$3.record(z$3.string(), z$3.unknown()));
27818
- const gatewayBatchStatusFieldsSchema = z$3.object({
27986
+ const gatewayBatchProviderMetadataSchema = () => z$3.record(z$3.string(), z$3.record(z$3.string(), z$3.unknown()));
27987
+ const gatewayBatchStatusFieldsSchema = () => z$3.object({
27819
27988
  status: z$3.enum([
27820
27989
  "completed",
27821
27990
  "failed",
27822
27991
  "pending"
27823
27992
  ]),
27824
27993
  rawStatus: z$3.string().nullish(),
27825
- requestCounts: gatewayBatchRequestCountsSchema.nullish(),
27826
- error: gatewayBatchErrorSchema.nullish(),
27994
+ requestCounts: gatewayBatchRequestCountsSchema().nullish(),
27995
+ error: gatewayBatchErrorSchema().nullish(),
27827
27996
  createdAt: z$3.string().nullish(),
27828
27997
  expiresAt: z$3.string().nullish(),
27829
- providerMetadata: gatewayBatchProviderMetadataSchema.nullish()
27998
+ providerMetadata: gatewayBatchProviderMetadataSchema().nullish()
27830
27999
  });
27831
- const gatewayBatchStartResponseSchema = gatewayBatchStatusFieldsSchema.extend({
28000
+ const gatewayBatchStartResponseSchema = lazySchema(() => zodSchema$4(gatewayBatchStatusFieldsSchema().extend({
27832
28001
  batchId: z$3.string(),
27833
28002
  warnings: z$3.array(z$3.object({
27834
28003
  requestId: z$3.string().nullish(),
27835
28004
  warning: z$3.unknown()
27836
28005
  }).catchall(z$3.unknown())).nullish()
27837
- });
27838
- const gatewayBatchStatusResponseSchema = gatewayBatchStatusFieldsSchema;
28006
+ })));
28007
+ const gatewayBatchStatusResponseSchema = lazySchema(() => zodSchema$4(gatewayBatchStatusFieldsSchema()));
27839
28008
  var GatewayLanguageModel = class GatewayLanguageModel {
27840
28009
  static [WORKFLOW_SERIALIZE](model) {
27841
28010
  return serializeModelOptions({
@@ -28032,7 +28201,7 @@ var GatewayEmbeddingModel = class GatewayEmbeddingModel {
28032
28201
  };
28033
28202
  }
28034
28203
  };
28035
- const gatewayEmbeddingWarningSchema = z$3.discriminatedUnion("type", [
28204
+ const gatewayEmbeddingWarningSchema = () => z$3.discriminatedUnion("type", [
28036
28205
  z$3.object({
28037
28206
  type: z$3.literal("unsupported"),
28038
28207
  feature: z$3.string(),
@@ -28056,7 +28225,7 @@ const gatewayEmbeddingWarningSchema = z$3.discriminatedUnion("type", [
28056
28225
  const gatewayEmbeddingResponseSchema = lazySchema(() => zodSchema$4(z$3.object({
28057
28226
  embeddings: z$3.array(z$3.array(z$3.number())),
28058
28227
  usage: z$3.object({ tokens: z$3.number() }).nullish(),
28059
- warnings: z$3.array(gatewayEmbeddingWarningSchema).optional(),
28228
+ warnings: z$3.array(gatewayEmbeddingWarningSchema()).optional(),
28060
28229
  providerMetadata: z$3.record(z$3.string(), z$3.record(z$3.string(), z$3.unknown())).optional()
28061
28230
  })));
28062
28231
  var GatewayImageModel = class GatewayImageModel {
@@ -28139,8 +28308,8 @@ function maybeEncodeImageFile(file) {
28139
28308
  };
28140
28309
  return file;
28141
28310
  }
28142
- const providerMetadataEntrySchema$3 = z$3.object({ images: z$3.array(z$3.unknown()).optional() }).catchall(z$3.unknown());
28143
- const gatewayImageWarningSchema = z$3.discriminatedUnion("type", [
28311
+ const providerMetadataEntrySchema$3 = () => z$3.object({ images: z$3.array(z$3.unknown()).optional() }).catchall(z$3.unknown());
28312
+ const gatewayImageWarningSchema = () => z$3.discriminatedUnion("type", [
28144
28313
  z$3.object({
28145
28314
  type: z$3.literal("unsupported"),
28146
28315
  feature: z$3.string(),
@@ -28161,18 +28330,18 @@ const gatewayImageWarningSchema = z$3.discriminatedUnion("type", [
28161
28330
  message: z$3.string()
28162
28331
  })
28163
28332
  ]);
28164
- const gatewayImageUsageSchema = z$3.object({
28333
+ const gatewayImageUsageSchema = () => z$3.object({
28165
28334
  inputTokens: z$3.number().nullish(),
28166
28335
  outputTokens: z$3.number().nullish(),
28167
28336
  totalTokens: z$3.number().nullish()
28168
28337
  });
28169
- const gatewayImageResponseSchema = z$3.object({
28338
+ const gatewayImageResponseSchema = lazySchema(() => zodSchema$4(z$3.object({
28170
28339
  images: z$3.array(z$3.string()),
28171
28340
  isRetryable: z$3.boolean().optional(),
28172
- warnings: z$3.array(gatewayImageWarningSchema).optional(),
28173
- providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema$3).optional(),
28174
- usage: gatewayImageUsageSchema.optional()
28175
- });
28341
+ warnings: z$3.array(gatewayImageWarningSchema()).optional(),
28342
+ providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema$3()).optional(),
28343
+ usage: gatewayImageUsageSchema().optional()
28344
+ })));
28176
28345
  var GatewayVideoModel = class {
28177
28346
  constructor(modelId, config) {
28178
28347
  this.modelId = modelId;
@@ -28392,8 +28561,8 @@ function maybeEncodeVideoFile(file) {
28392
28561
  };
28393
28562
  return file;
28394
28563
  }
28395
- const providerMetadataEntrySchema$2 = z$3.object({ videos: z$3.array(z$3.unknown()).optional() }).catchall(z$3.unknown());
28396
- const gatewayVideoDataSchema = z$3.union([z$3.object({
28564
+ const providerMetadataEntrySchema$2 = () => z$3.object({ videos: z$3.array(z$3.unknown()).optional() }).catchall(z$3.unknown());
28565
+ const gatewayVideoDataSchema = () => z$3.union([z$3.object({
28397
28566
  type: z$3.literal("url"),
28398
28567
  url: z$3.string(),
28399
28568
  mediaType: z$3.string()
@@ -28402,7 +28571,7 @@ const gatewayVideoDataSchema = z$3.union([z$3.object({
28402
28571
  data: z$3.string(),
28403
28572
  mediaType: z$3.string()
28404
28573
  })]);
28405
- const gatewayVideoWarningSchema = z$3.discriminatedUnion("type", [
28574
+ const gatewayVideoWarningSchema = () => z$3.discriminatedUnion("type", [
28406
28575
  z$3.object({
28407
28576
  type: z$3.literal("unsupported"),
28408
28577
  feature: z$3.string(),
@@ -28423,56 +28592,56 @@ const gatewayVideoWarningSchema = z$3.discriminatedUnion("type", [
28423
28592
  message: z$3.string()
28424
28593
  })
28425
28594
  ]);
28426
- const gatewayVideoEventSchema = z$3.discriminatedUnion("type", [z$3.object({
28595
+ const gatewayVideoEventSchema = lazySchema(() => zodSchema$4(z$3.discriminatedUnion("type", [z$3.object({
28427
28596
  type: z$3.literal("result"),
28428
- videos: z$3.array(gatewayVideoDataSchema),
28429
- warnings: z$3.array(gatewayVideoWarningSchema).optional(),
28430
- providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema$2).optional()
28597
+ videos: z$3.array(gatewayVideoDataSchema()),
28598
+ warnings: z$3.array(gatewayVideoWarningSchema()).optional(),
28599
+ providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema$2()).optional()
28431
28600
  }), z$3.object({
28432
28601
  type: z$3.literal("error"),
28433
28602
  message: z$3.string(),
28434
28603
  errorType: z$3.string(),
28435
28604
  statusCode: z$3.number(),
28436
28605
  param: z$3.unknown().nullable()
28437
- })]);
28438
- const gatewayVideoStartResponseSchema = z$3.object({
28606
+ })])));
28607
+ const gatewayVideoStartResponseSchema = lazySchema(() => zodSchema$4(z$3.object({
28439
28608
  operation: z$3.unknown(),
28440
- warnings: z$3.array(gatewayVideoWarningSchema).nullish(),
28441
- providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema$2).nullish()
28442
- });
28443
- const gatewayVideoStatusResponseSchema = z$3.discriminatedUnion("status", [
28609
+ warnings: z$3.array(gatewayVideoWarningSchema()).nullish(),
28610
+ providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema$2()).nullish()
28611
+ })));
28612
+ const gatewayVideoStatusResponseSchema = lazySchema(() => zodSchema$4(z$3.discriminatedUnion("status", [
28444
28613
  z$3.object({
28445
28614
  status: z$3.literal("pending"),
28446
- warnings: z$3.array(gatewayVideoWarningSchema).nullish(),
28447
- providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema$2).nullish()
28615
+ warnings: z$3.array(gatewayVideoWarningSchema()).nullish(),
28616
+ providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema$2()).nullish()
28448
28617
  }),
28449
28618
  z$3.object({
28450
28619
  status: z$3.literal("completed"),
28451
- videos: z$3.array(gatewayVideoDataSchema),
28452
- warnings: z$3.array(gatewayVideoWarningSchema).nullish(),
28453
- providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema$2).nullish()
28620
+ videos: z$3.array(gatewayVideoDataSchema()),
28621
+ warnings: z$3.array(gatewayVideoWarningSchema()).nullish(),
28622
+ providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema$2()).nullish()
28454
28623
  }),
28455
28624
  z$3.object({
28456
28625
  status: z$3.literal("error"),
28457
28626
  error: z$3.string(),
28458
- providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema$2).nullish()
28627
+ providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema$2()).nullish()
28459
28628
  }),
28460
28629
  z$3.object({
28461
28630
  status: z$3.literal("cancelled"),
28462
- providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema$2).nullish()
28631
+ providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema$2()).nullish()
28463
28632
  })
28464
- ]);
28465
- const gatewayDecisionProviderOptionsSchema = lazySchema(() => zodSchema$4(z$3.object({ models: gatewayModelFallbacksSchema.optional() }).catchall(z$3.unknown())));
28466
- const probabilitySchema = z$3.number().finite().min(0).max(1);
28467
- const questionSchema = z$3.string().min(1).max(256);
28468
- const directConditionSchema = z$3.union([z$3.object({
28469
- question: questionSchema.optional(),
28470
- confidenceBelow: probabilitySchema
28633
+ ])));
28634
+ const gatewayDecisionProviderOptionsSchema = lazySchema(() => zodSchema$4(z$3.object({ models: gatewayModelFallbacksSchema().optional() }).catchall(z$3.unknown())));
28635
+ const probabilitySchema = () => z$3.number().finite().min(0).max(1);
28636
+ const questionSchema = () => z$3.string().min(1).max(256);
28637
+ const directConditionSchema = () => z$3.union([z$3.object({
28638
+ question: questionSchema().optional(),
28639
+ confidenceBelow: probabilitySchema()
28471
28640
  }).strict(), z$3.object({
28472
- question: questionSchema.optional(),
28473
- probabilityBetween: z$3.array(probabilitySchema).length(2).refine(([minimum, maximum]) => minimum <= maximum, { message: "probabilityBetween minimum must be less than or equal to maximum" })
28641
+ question: questionSchema().optional(),
28642
+ probabilityBetween: z$3.array(probabilitySchema()).length(2).refine(([minimum, maximum]) => minimum <= maximum, { message: "probabilityBetween minimum must be less than or equal to maximum" })
28474
28643
  }).strict()]);
28475
- const groupBeyondMaxDepthSchema = z$3.union([
28644
+ const groupBeyondMaxDepthSchema = () => z$3.union([
28476
28645
  z$3.object({ any: z$3.unknown() }),
28477
28646
  z$3.object({ all: z$3.unknown() }),
28478
28647
  z$3.object({ atLeast: z$3.unknown() })
@@ -28482,11 +28651,11 @@ const groupBeyondMaxDepthSchema = z$3.union([
28482
28651
  message: `conditions can be nested at most 5 levels deep`
28483
28652
  });
28484
28653
  });
28485
- const conditionalModelFallbackSchema = z$3.object({
28654
+ const conditionalModelFallbackSchema = () => z$3.object({
28486
28655
  model: z$3.string().min(1),
28487
28656
  when: conditionSchema(1)
28488
28657
  }).strict();
28489
- const gatewayModelFallbacksSchema = z$3.array(z$3.union([z$3.string(), conditionalModelFallbackSchema])).superRefine((entries, context) => {
28658
+ const gatewayModelFallbacksSchema = () => z$3.array(z$3.union([z$3.string(), conditionalModelFallbackSchema()])).superRefine((entries, context) => {
28490
28659
  const conditionalIndexes = entries.flatMap((entry, index) => typeof entry === "string" ? [] : [index]);
28491
28660
  if (conditionalIndexes.length > 1) context.addIssue({
28492
28661
  code: "custom",
@@ -28499,11 +28668,11 @@ const gatewayModelFallbacksSchema = z$3.array(z$3.union([z$3.string(), condition
28499
28668
  });
28500
28669
  });
28501
28670
  function conditionSchema(depth) {
28502
- if (depth === 5) return z$3.union([directConditionSchema, groupBeyondMaxDepthSchema]);
28671
+ if (depth === 5) return z$3.union([directConditionSchema(), groupBeyondMaxDepthSchema()]);
28503
28672
  const childConditionSchema = conditionSchema(depth + 1);
28504
28673
  const conditionListSchema = z$3.array(childConditionSchema).min(1).max(20);
28505
28674
  return z$3.union([
28506
- directConditionSchema,
28675
+ directConditionSchema(),
28507
28676
  z$3.object({ any: conditionListSchema }).strict(),
28508
28677
  z$3.object({ all: conditionListSchema }).strict(),
28509
28678
  z$3.object({ atLeast: z$3.object({
@@ -28533,7 +28702,7 @@ var GatewayDecisionModel = class {
28533
28702
  doEvaluate(options) {
28534
28703
  return this.doDecide(options);
28535
28704
  }
28536
- async doDecide({ state, questions, headers, abortSignal, providerOptions }) {
28705
+ async doDecide({ state, questions, maxOutputTokens, reasoning, headers, abortSignal, providerOptions }) {
28537
28706
  const stateParts = toGatewayDecisionState(state);
28538
28707
  const gatewayOptions = await parseProviderOptions({
28539
28708
  provider: "gateway",
@@ -28552,6 +28721,8 @@ var GatewayDecisionModel = class {
28552
28721
  body: {
28553
28722
  stateParts,
28554
28723
  questions,
28724
+ maxOutputTokens,
28725
+ reasoning,
28555
28726
  ...validatedProviderOptions ? { providerOptions: validatedProviderOptions } : {}
28556
28727
  },
28557
28728
  successfulResponseHandler: createJsonResponseHandler(gatewayDecisionResponseSchema),
@@ -28588,7 +28759,7 @@ var GatewayDecisionModel = class {
28588
28759
  };
28589
28760
  }
28590
28761
  };
28591
- const gatewayDecisionAnswerSchema = z$3.discriminatedUnion("type", [
28762
+ const gatewayDecisionAnswerSchema = () => z$3.discriminatedUnion("type", [
28592
28763
  z$3.object({
28593
28764
  type: z$3.literal("choice"),
28594
28765
  choice: z$3.string(),
@@ -28605,7 +28776,7 @@ const gatewayDecisionAnswerSchema = z$3.discriminatedUnion("type", [
28605
28776
  }),
28606
28777
  z$3.object({ type: z$3.literal("refusal") })
28607
28778
  ]);
28608
- const gatewayDecisionWarningSchema = z$3.discriminatedUnion("type", [
28779
+ const gatewayDecisionWarningSchema = () => z$3.discriminatedUnion("type", [
28609
28780
  z$3.object({
28610
28781
  type: z$3.literal("unsupported"),
28611
28782
  feature: z$3.string(),
@@ -28627,7 +28798,7 @@ const gatewayDecisionWarningSchema = z$3.discriminatedUnion("type", [
28627
28798
  })
28628
28799
  ]);
28629
28800
  const gatewayDecisionResponseSchema = lazySchema(() => zodSchema$4(z$3.object({
28630
- answers: z$3.record(z$3.string(), gatewayDecisionAnswerSchema),
28801
+ answers: z$3.record(z$3.string(), gatewayDecisionAnswerSchema()),
28631
28802
  model: z$3.string().optional(),
28632
28803
  rounding: z$3.object({
28633
28804
  probabilityDecimals: z$3.number().optional(),
@@ -28637,7 +28808,7 @@ const gatewayDecisionResponseSchema = lazySchema(() => zodSchema$4(z$3.object({
28637
28808
  inputTokens: z$3.number().optional(),
28638
28809
  outputTokens: z$3.number().optional()
28639
28810
  }).optional(),
28640
- warnings: z$3.array(gatewayDecisionWarningSchema).optional(),
28811
+ warnings: z$3.array(gatewayDecisionWarningSchema()).optional(),
28641
28812
  providerMetadata: z$3.record(z$3.string(), z$3.record(z$3.string(), z$3.unknown())).optional()
28642
28813
  })));
28643
28814
  function toGatewayDecisionState(state) {
@@ -28706,7 +28877,7 @@ var GatewayRerankingModel = class {
28706
28877
  };
28707
28878
  }
28708
28879
  };
28709
- const gatewayRerankingWarningSchema = z$3.discriminatedUnion("type", [
28880
+ const gatewayRerankingWarningSchema = () => z$3.discriminatedUnion("type", [
28710
28881
  z$3.object({
28711
28882
  type: z$3.literal("unsupported"),
28712
28883
  feature: z$3.string(),
@@ -28732,95 +28903,49 @@ const gatewayRerankingResponseSchema = lazySchema(() => zodSchema$4(z$3.object({
28732
28903
  index: z$3.number(),
28733
28904
  relevanceScore: z$3.number()
28734
28905
  })),
28735
- warnings: z$3.array(gatewayRerankingWarningSchema).optional(),
28906
+ warnings: z$3.array(gatewayRerankingWarningSchema()).optional(),
28736
28907
  providerMetadata: z$3.record(z$3.string(), z$3.record(z$3.string(), z$3.unknown())).optional()
28737
28908
  })));
28738
- var GatewaySpeechModel = class {
28739
- constructor(modelId, config) {
28740
- this.modelId = modelId;
28741
- this.config = config;
28742
- this.specificationVersion = "v4";
28743
- }
28744
- get provider() {
28745
- return this.config.provider;
28746
- }
28747
- async doGenerate({ text, voice, outputFormat, instructions, speed, language, providerOptions, headers, abortSignal }) {
28748
- const resolvedHeaders = this.config.headers ? await resolve$3(this.config.headers) : void 0;
28749
- try {
28750
- const { responseHeaders, value: responseBody, rawValue } = await postJsonToApi({
28751
- url: this.getUrl(),
28752
- headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await resolve$3(this.config.o11yHeaders)),
28753
- body: {
28754
- text,
28755
- ...voice && { voice },
28756
- ...outputFormat && { outputFormat },
28757
- ...instructions && { instructions },
28758
- ...speed != null && { speed },
28759
- ...language && { language },
28760
- ...providerOptions && { providerOptions }
28761
- },
28762
- successfulResponseHandler: createJsonResponseHandler(gatewaySpeechResponseSchema),
28763
- failedResponseHandler: createJsonErrorResponseHandler({
28764
- errorSchema: z$3.any(),
28765
- errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
28766
- }),
28767
- ...abortSignal && { abortSignal },
28768
- fetch: this.config.fetch
28769
- });
28770
- return {
28771
- audio: responseBody.audio,
28772
- warnings: responseBody.warnings ?? [],
28773
- ...responseBody.usage != null && { usage: responseBody.usage },
28774
- providerMetadata: responseBody.providerMetadata,
28775
- response: {
28776
- timestamp: /* @__PURE__ */ new Date(),
28777
- modelId: this.modelId,
28778
- headers: responseHeaders,
28779
- body: rawValue
28780
- }
28781
- };
28782
- } catch (error) {
28783
- throw await asGatewayError(error, await parseAuthMethod(resolvedHeaders ?? {}));
28784
- }
28785
- }
28786
- getUrl() {
28787
- return `${this.config.baseURL}/speech-model`;
28788
- }
28789
- getModelConfigHeaders() {
28790
- return {
28791
- "ai-speech-model-specification-version": "4",
28792
- "ai-model-id": this.modelId
28793
- };
28794
- }
28909
+ /**
28910
+ * `asGatewayError` is async while the WebSocket event handlers are
28911
+ * synchronous, hence this helper.
28912
+ */
28913
+ async function errorControllerWithGatewayError(controller, error, authMethod) {
28914
+ controller.error(await asGatewayError(error, authMethod));
28915
+ }
28916
+ /**
28917
+ * Extract a human-readable message from an `error` stream part's payload for
28918
+ * the terminal close error.
28919
+ */
28920
+ function getServerErrorMessage(error) {
28921
+ if (error != null && typeof error === "object" && "message" in error && typeof error.message === "string") return error.message;
28922
+ return getErrorMessage(error);
28923
+ }
28924
+ /** Canonical status codes for server error-part types (no HTTP status exists on the WebSocket). */
28925
+ const SERVER_ERROR_STATUS_CODES = {
28926
+ authentication_error: 401,
28927
+ failed_dependency: 424,
28928
+ forbidden: 403,
28929
+ internal_server_error: 500,
28930
+ invalid_request_error: 400,
28931
+ model_not_found: 404,
28932
+ rate_limit_exceeded: 429
28795
28933
  };
28796
- const providerMetadataEntrySchema$1 = z$3.object({}).catchall(z$3.unknown());
28797
- const gatewaySpeechWarningSchema = z$3.discriminatedUnion("type", [
28798
- z$3.object({
28799
- type: z$3.literal("unsupported"),
28800
- feature: z$3.string(),
28801
- details: z$3.string().optional()
28802
- }),
28803
- z$3.object({
28804
- type: z$3.literal("compatibility"),
28805
- feature: z$3.string(),
28806
- details: z$3.string().optional()
28807
- }),
28808
- z$3.object({
28809
- type: z$3.literal("deprecated"),
28810
- setting: z$3.string(),
28811
- message: z$3.string()
28812
- }),
28813
- z$3.object({
28814
- type: z$3.literal("other"),
28815
- message: z$3.string()
28816
- })
28817
- ]);
28818
- const gatewaySpeechResponseSchema = z$3.object({
28819
- audio: z$3.string(),
28820
- warnings: z$3.array(gatewaySpeechWarningSchema).optional(),
28821
- usage: z$3.record(z$3.string(), z$3.json()).optional(),
28822
- providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema$1).optional()
28823
- });
28934
+ /**
28935
+ * Maps a server error-part payload (`{ message, type }`) to the public
28936
+ * Gateway error class for its type; unknown shapes keep the generic message.
28937
+ */
28938
+ async function createErrorFromServerErrorPart(error, authMethod, streamLabel = "transcription") {
28939
+ if (typeof error === "object" && error != null && "message" in error && typeof error.message === "string" && "type" in error && typeof error.type === "string" && error.type in SERVER_ERROR_STATUS_CODES) return createGatewayErrorFromResponse({
28940
+ response: { error: {
28941
+ message: error.message,
28942
+ type: error.type
28943
+ } },
28944
+ statusCode: SERVER_ERROR_STATUS_CODES[error.type],
28945
+ authMethod
28946
+ });
28947
+ return /* @__PURE__ */ new Error(`AI Gateway ${streamLabel} stream failed: ${getServerErrorMessage(error)}`);
28948
+ }
28824
28949
  var GatewayTranscriptionModel = class {
28825
28950
  constructor(modelId, config) {
28826
28951
  this.modelId = modelId;
@@ -28940,11 +29065,11 @@ function toGatewayTranscriptionUrl(baseURL, modelId) {
28940
29065
  * case-insensitive because `combineHeaders` does not normalize casing and
28941
29066
  * callers can pass arbitrary casing via the `headers` option.
28942
29067
  */
28943
- function getProtocolsFromHeaders(headers) {
29068
+ function getProtocolsFromHeaders(headers, { marker = GATEWAY_TRANSCRIPTION_SUBPROTOCOL, getProtocols = getGatewayTranscriptionProtocols } = {}) {
28944
29069
  const normalizedHeaders = normalizeHeaders(headers);
28945
29070
  const authorization = normalizedHeaders.authorization;
28946
29071
  const token = authorization?.startsWith("Bearer ") ? authorization.slice(7) : void 0;
28947
- return token == null ? [GATEWAY_TRANSCRIPTION_SUBPROTOCOL] : getGatewayTranscriptionProtocols(token, { teamIdOrSlug: normalizedHeaders[VERCEL_AI_GATEWAY_TEAM_HEADER] });
29072
+ return token == null ? [marker] : getProtocols(token, { teamIdOrSlug: normalizedHeaders[VERCEL_AI_GATEWAY_TEAM_HEADER] });
28948
29073
  }
28949
29074
  /** Audio frames stay under server frame-size limits (envelope rule 7). */
28950
29075
  const MAX_AUDIO_FRAME_BYTES = 65536;
@@ -29051,8 +29176,8 @@ function createGatewayTranscriptionStream({ webSocket, url, protocols, headers,
29051
29176
  }
29052
29177
  });
29053
29178
  }
29054
- const providerMetadataEntrySchema = z$3.object({}).catchall(z$3.unknown());
29055
- const gatewayTranscriptionWarningSchema = z$3.discriminatedUnion("type", [
29179
+ const providerMetadataEntrySchema$1 = () => z$3.object({}).catchall(z$3.unknown());
29180
+ const gatewayTranscriptionWarningSchema = () => z$3.discriminatedUnion("type", [
29056
29181
  z$3.object({
29057
29182
  type: z$3.literal("unsupported"),
29058
29183
  feature: z$3.string(),
@@ -29073,7 +29198,7 @@ const gatewayTranscriptionWarningSchema = z$3.discriminatedUnion("type", [
29073
29198
  message: z$3.string()
29074
29199
  })
29075
29200
  ]);
29076
- const gatewayTranscriptionResponseSchema = z$3.object({
29201
+ const gatewayTranscriptionResponseSchema = lazySchema(() => zodSchema$4(z$3.object({
29077
29202
  text: z$3.string(),
29078
29203
  segments: z$3.array(z$3.object({
29079
29204
  text: z$3.string(),
@@ -29082,50 +29207,274 @@ const gatewayTranscriptionResponseSchema = z$3.object({
29082
29207
  })).optional(),
29083
29208
  language: z$3.string().nullish(),
29084
29209
  durationInSeconds: z$3.number().nullish(),
29085
- warnings: z$3.array(gatewayTranscriptionWarningSchema).optional(),
29210
+ warnings: z$3.array(gatewayTranscriptionWarningSchema()).optional(),
29086
29211
  usage: z$3.record(z$3.string(), z$3.json()).optional(),
29087
- providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema).optional()
29088
- });
29212
+ providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema$1()).optional()
29213
+ })));
29214
+ var GatewaySpeechModel = class {
29215
+ constructor(modelId, config) {
29216
+ this.modelId = modelId;
29217
+ this.config = config;
29218
+ this.specificationVersion = "v4";
29219
+ }
29220
+ get provider() {
29221
+ return this.config.provider;
29222
+ }
29223
+ async doGenerate({ text, voice, outputFormat, instructions, speed, language, providerOptions, headers, abortSignal }) {
29224
+ const resolvedHeaders = this.config.headers ? await resolve$3(this.config.headers) : void 0;
29225
+ try {
29226
+ const { responseHeaders, value: responseBody, rawValue } = await postJsonToApi({
29227
+ url: this.getUrl(),
29228
+ headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await resolve$3(this.config.o11yHeaders)),
29229
+ body: {
29230
+ text,
29231
+ ...voice && { voice },
29232
+ ...outputFormat && { outputFormat },
29233
+ ...instructions && { instructions },
29234
+ ...speed != null && { speed },
29235
+ ...language && { language },
29236
+ ...providerOptions && { providerOptions }
29237
+ },
29238
+ successfulResponseHandler: createJsonResponseHandler(gatewaySpeechResponseSchema),
29239
+ failedResponseHandler: createJsonErrorResponseHandler({
29240
+ errorSchema: z$3.any(),
29241
+ errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
29242
+ }),
29243
+ ...abortSignal && { abortSignal },
29244
+ fetch: this.config.fetch
29245
+ });
29246
+ return {
29247
+ audio: responseBody.audio,
29248
+ warnings: responseBody.warnings ?? [],
29249
+ ...responseBody.usage != null && { usage: responseBody.usage },
29250
+ providerMetadata: responseBody.providerMetadata,
29251
+ response: {
29252
+ timestamp: /* @__PURE__ */ new Date(),
29253
+ modelId: this.modelId,
29254
+ headers: responseHeaders,
29255
+ body: rawValue
29256
+ }
29257
+ };
29258
+ } catch (error) {
29259
+ throw await asGatewayError(error, await parseAuthMethod(resolvedHeaders ?? {}));
29260
+ }
29261
+ }
29262
+ async doStream(options) {
29263
+ const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
29264
+ const headers = combineHeaders(await resolve$3(this.config.headers ?? {}), options.headers ?? {}, this.getModelConfigHeaders(), await resolve$3(this.config.o11yHeaders));
29265
+ const authMethod = await parseAuthMethod(headers);
29266
+ const startFrame = {
29267
+ type: SPEECH_STREAM_START_FRAME_TYPE,
29268
+ ...options.voice != null && { voice: options.voice },
29269
+ ...options.outputFormat != null && { outputFormat: options.outputFormat },
29270
+ ...options.instructions != null && { instructions: options.instructions },
29271
+ ...options.speed != null && { speed: options.speed },
29272
+ ...options.language != null && { language: options.language },
29273
+ ...options.providerOptions != null && { providerOptions: options.providerOptions },
29274
+ ...options.includeRawChunks != null && { includeRawChunks: options.includeRawChunks }
29275
+ };
29276
+ return {
29277
+ stream: createGatewaySpeechStream({
29278
+ webSocket: this.config.webSocket,
29279
+ url: toGatewaySpeechUrl(this.config.baseURL, this.modelId),
29280
+ protocols: getProtocolsFromHeaders(headers, {
29281
+ marker: GATEWAY_SPEECH_SUBPROTOCOL,
29282
+ getProtocols: getGatewaySpeechProtocols
29283
+ }),
29284
+ headers,
29285
+ startFrame,
29286
+ text: options.text,
29287
+ abortSignal: options.abortSignal,
29288
+ authMethod
29289
+ }),
29290
+ request: { body: startFrame },
29291
+ response: {
29292
+ timestamp: currentDate,
29293
+ modelId: this.modelId
29294
+ }
29295
+ };
29296
+ }
29297
+ getUrl() {
29298
+ return `${this.config.baseURL}/speech-model`;
29299
+ }
29300
+ getModelConfigHeaders() {
29301
+ return {
29302
+ "ai-speech-model-specification-version": "4",
29303
+ "ai-model-id": this.modelId
29304
+ };
29305
+ }
29306
+ };
29089
29307
  /**
29090
- * `asGatewayError` is async while the WebSocket event handlers are
29091
- * synchronous, hence this helper.
29308
+ * Gateway streaming speech WebSocket URL: HTTP(S) base upgraded to WS(S),
29309
+ * model id in `?ai-model-id=` (browser `WebSocket` cannot set headers).
29092
29310
  */
29093
- async function errorControllerWithGatewayError(controller, error, authMethod) {
29094
- controller.error(await asGatewayError(error, authMethod));
29311
+ function toGatewaySpeechUrl(baseURL, modelId) {
29312
+ const url = new URL(`${baseURL.replace(/^http/, "ws")}/speech-model`);
29313
+ url.searchParams.set("ai-model-id", modelId);
29314
+ return url.toString();
29095
29315
  }
29096
29316
  /**
29097
- * Extract a human-readable message from an `error` stream part's payload for
29098
- * the terminal close error.
29317
+ * Keeps text-delta frames under 64 KiB (envelope rule 7) even when JSON
29318
+ * escapes every code unit as `\uXXXX`.
29099
29319
  */
29100
- function getServerErrorMessage(error) {
29101
- if (error != null && typeof error === "object" && "message" in error && typeof error.message === "string") return error.message;
29102
- return getErrorMessage(error);
29103
- }
29104
- /** Canonical status codes for server error-part types (no HTTP status exists on the WebSocket). */
29105
- const SERVER_ERROR_STATUS_CODES = {
29106
- authentication_error: 401,
29107
- failed_dependency: 424,
29108
- forbidden: 403,
29109
- internal_server_error: 500,
29110
- invalid_request_error: 400,
29111
- model_not_found: 404,
29112
- rate_limit_exceeded: 429
29113
- };
29320
+ const MAX_TEXT_DELTA_CODE_UNITS = 8192;
29114
29321
  /**
29115
- * Maps a server error-part payload (`{ message, type }`) to the public
29116
- * Gateway error class for its type; unknown shapes keep the generic message.
29322
+ * Splits a long text delta into pieces of at most `MAX_TEXT_DELTA_CODE_UNITS`
29323
+ * UTF-16 code units without separating a surrogate pair.
29117
29324
  */
29118
- async function createErrorFromServerErrorPart(error, authMethod) {
29119
- if (typeof error === "object" && error != null && "message" in error && typeof error.message === "string" && "type" in error && typeof error.type === "string" && error.type in SERVER_ERROR_STATUS_CODES) return createGatewayErrorFromResponse({
29120
- response: { error: {
29121
- message: error.message,
29122
- type: error.type
29123
- } },
29124
- statusCode: SERVER_ERROR_STATUS_CODES[error.type],
29125
- authMethod
29325
+ function splitTextDelta(delta) {
29326
+ const pieces = [];
29327
+ let offset = 0;
29328
+ while (offset < delta.length) {
29329
+ let end = Math.min(offset + MAX_TEXT_DELTA_CODE_UNITS, delta.length);
29330
+ const lastCodeUnit = delta.charCodeAt(end - 1);
29331
+ if (end < delta.length && lastCodeUnit >= 55296 && lastCodeUnit <= 56319) end--;
29332
+ pieces.push(delta.slice(offset, end));
29333
+ offset = end;
29334
+ }
29335
+ return pieces;
29336
+ }
29337
+ function createGatewaySpeechStream({ webSocket, url, protocols, headers, startFrame, text, abortSignal, authMethod }) {
29338
+ let finished = false;
29339
+ let cleanup = () => {};
29340
+ return new ReadableStream({
29341
+ start: (controller) => {
29342
+ let textReader;
29343
+ let hasServerErrorPart = false;
29344
+ let lastServerError;
29345
+ let textStopped = false;
29346
+ let connection;
29347
+ const cancelText = () => {
29348
+ if (textReader != null) {
29349
+ textReader.cancel().catch(() => {});
29350
+ textReader = void 0;
29351
+ } else text.cancel().catch(() => {});
29352
+ };
29353
+ cleanup = (closeCode) => {
29354
+ cancelText();
29355
+ connection?.close(closeCode);
29356
+ };
29357
+ const finishWithError = (error) => {
29358
+ if (finished) return;
29359
+ finished = true;
29360
+ cleanup();
29361
+ errorControllerWithGatewayError(controller, error, authMethod);
29362
+ };
29363
+ const sendText = async (socket) => {
29364
+ const reader = text.getReader();
29365
+ textReader = reader;
29366
+ try {
29367
+ while (true) {
29368
+ const { done, value } = await reader.read();
29369
+ if (done || finished || textStopped) break;
29370
+ let first = true;
29371
+ const pieces = splitTextDelta(value.text);
29372
+ if (pieces.length === 0 && (value.voice != null || value.providerOptions != null)) pieces.push("");
29373
+ for (const delta of pieces) {
29374
+ if (finished || textStopped) break;
29375
+ const frame = {
29376
+ type: SPEECH_STREAM_TEXT_DELTA_FRAME_TYPE,
29377
+ delta,
29378
+ ...value.voice != null && { voice: value.voice },
29379
+ ...first && value.providerOptions != null && { providerOptions: value.providerOptions }
29380
+ };
29381
+ first = false;
29382
+ socket.send(JSON.stringify(frame));
29383
+ await waitForWebSocketBufferDrain(socket);
29384
+ }
29385
+ }
29386
+ } finally {
29387
+ reader.releaseLock();
29388
+ if (textReader === reader) textReader = void 0;
29389
+ }
29390
+ if (!finished && !textStopped) socket.send(JSON.stringify({ type: SPEECH_STREAM_TEXT_DONE_FRAME_TYPE }));
29391
+ };
29392
+ connection = connectToWebSocket({
29393
+ url,
29394
+ protocols,
29395
+ headers,
29396
+ webSocket,
29397
+ abortSignal,
29398
+ onAbort: (reason) => {
29399
+ if (finished) return;
29400
+ finished = true;
29401
+ cleanup();
29402
+ controller.error(reason);
29403
+ },
29404
+ onProcessingError: finishWithError,
29405
+ onOpen: (socket) => {
29406
+ socket.send(JSON.stringify(startFrame));
29407
+ sendText(socket).catch(finishWithError);
29408
+ },
29409
+ onMessageText: async (messageText) => {
29410
+ if (finished) return;
29411
+ const part = parseSpeechStreamPart(messageText);
29412
+ if (part == null) return;
29413
+ if (part.type === "finish") {
29414
+ finished = true;
29415
+ controller.enqueue(part);
29416
+ controller.close();
29417
+ cleanup(1e3);
29418
+ return;
29419
+ }
29420
+ if (part.type === "error") {
29421
+ hasServerErrorPart = true;
29422
+ lastServerError = part.error;
29423
+ textStopped = true;
29424
+ cancelText();
29425
+ part.error = await createErrorFromServerErrorPart(part.error, authMethod, "speech");
29426
+ if (finished) return;
29427
+ }
29428
+ controller.enqueue(part);
29429
+ },
29430
+ onSocketError: () => {
29431
+ finishWithError(/* @__PURE__ */ new Error("Connection error on AI Gateway speech stream"));
29432
+ },
29433
+ onClose: ({ code, reason }) => {
29434
+ if (hasServerErrorPart) {
29435
+ if (finished) return;
29436
+ createErrorFromServerErrorPart(lastServerError, authMethod, "speech").then(finishWithError);
29437
+ return;
29438
+ }
29439
+ finishWithError(/* @__PURE__ */ new Error("AI Gateway speech stream closed before a finish part was received" + (code != null ? ` (code ${code}${reason ? `: ${reason}` : ""})` : "") + "."));
29440
+ }
29441
+ });
29442
+ },
29443
+ cancel: () => {
29444
+ if (finished) return;
29445
+ finished = true;
29446
+ cleanup();
29447
+ }
29126
29448
  });
29127
- return /* @__PURE__ */ new Error(`AI Gateway transcription stream failed: ${getServerErrorMessage(error)}`);
29128
29449
  }
29450
+ const providerMetadataEntrySchema = () => z$3.object({}).catchall(z$3.unknown());
29451
+ const gatewaySpeechWarningSchema = () => z$3.discriminatedUnion("type", [
29452
+ z$3.object({
29453
+ type: z$3.literal("unsupported"),
29454
+ feature: z$3.string(),
29455
+ details: z$3.string().optional()
29456
+ }),
29457
+ z$3.object({
29458
+ type: z$3.literal("compatibility"),
29459
+ feature: z$3.string(),
29460
+ details: z$3.string().optional()
29461
+ }),
29462
+ z$3.object({
29463
+ type: z$3.literal("deprecated"),
29464
+ setting: z$3.string(),
29465
+ message: z$3.string()
29466
+ }),
29467
+ z$3.object({
29468
+ type: z$3.literal("other"),
29469
+ message: z$3.string()
29470
+ })
29471
+ ]);
29472
+ const gatewaySpeechResponseSchema = lazySchema(() => zodSchema$4(z$3.object({
29473
+ audio: z$3.string(),
29474
+ warnings: z$3.array(gatewaySpeechWarningSchema()).optional(),
29475
+ usage: z$3.record(z$3.string(), z$3.json()).optional(),
29476
+ providerMetadata: z$3.record(z$3.string(), providerMetadataEntrySchema()).optional()
29477
+ })));
29129
29478
  /**
29130
29479
  * Realtime model backed by the AI Gateway.
29131
29480
  *
@@ -29193,7 +29542,7 @@ function toGatewayRealtimeUrl(baseURL, modelId) {
29193
29542
  url.searchParams.set("ai-model-id", modelId);
29194
29543
  return url.toString();
29195
29544
  }
29196
- const jsonObjectSchema = z$3.record(z$3.string(), z$3.unknown());
29545
+ const jsonObjectSchema = () => z$3.record(z$3.string(), z$3.unknown());
29197
29546
  const browserbaseFetchToolFactory = createProviderExecutedToolFactory({
29198
29547
  id: "gateway.browserbase_fetch",
29199
29548
  inputSchema: lazySchema(() => zodSchema$4(z$3.object({
@@ -29206,11 +29555,11 @@ const browserbaseFetchToolFactory = createProviderExecutedToolFactory({
29206
29555
  "json",
29207
29556
  "markdown"
29208
29557
  ]).optional().describe("Output format. raw returns the response body unchanged, markdown returns page content as Markdown, and json returns structured content using schema."),
29209
- schema: jsonObjectSchema.optional().describe("JSON Schema for structured extraction. Only use with format set to json.")
29558
+ schema: jsonObjectSchema().optional().describe("JSON Schema for structured extraction. Only use with format set to json.")
29210
29559
  }))),
29211
29560
  outputSchema: lazySchema(() => zodSchema$4(z$3.union([z$3.object({
29212
29561
  id: z$3.string(),
29213
- content: z$3.union([z$3.string(), jsonObjectSchema]),
29562
+ content: z$3.union([z$3.string(), jsonObjectSchema()]),
29214
29563
  contentType: z$3.string(),
29215
29564
  encoding: z$3.string(),
29216
29565
  headers: z$3.record(z$3.string(), z$3.string()),
@@ -29369,41 +29718,67 @@ const exaSearchToolFactory = createProviderExecutedToolFactory({
29369
29718
  })])))
29370
29719
  });
29371
29720
  const exaSearch = (config = {}) => exaSearchToolFactory(config);
29721
+ const parallelSearchModes = [
29722
+ "turbo",
29723
+ "fast",
29724
+ "basic",
29725
+ "advanced",
29726
+ "one-shot",
29727
+ "agentic"
29728
+ ];
29372
29729
  const parallelSearchToolFactory = createProviderExecutedToolFactory({
29373
29730
  id: "gateway.parallel_search",
29374
29731
  inputSchema: lazySchema(() => zodSchema$4(z$3.object({
29375
29732
  objective: z$3.string().describe("Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."),
29376
- search_queries: z$3.array(z$3.string()).optional().describe("Optional search queries to supplement the objective. Maximum 200 characters per query."),
29377
- mode: z$3.enum(["one-shot", "agentic"]).optional().describe("Mode preset: \"one-shot\" for comprehensive results with longer excerpts (default), \"agentic\" for concise, token-efficient results for multi-step workflows."),
29733
+ search_queries: z$3.array(z$3.string()).optional().describe("Provide 2-3 concise keyword queries, 3-6 words each (max 5, 200 chars each). Strongly recommended; the search runs on these queries."),
29734
+ mode: z$3.enum(parallelSearchModes).optional().describe("Search mode: \"turbo\" and \"fast\" return quickly with shorter excerpts, \"basic\" is balanced (default), \"advanced\" is the most thorough. \"turbo\" supports English and Japanese only. \"one-shot\" and \"agentic\" are deprecated aliases of \"basic\" and \"advanced\"."),
29378
29735
  max_results: z$3.number().optional().describe("Maximum number of results to return (1-20). Defaults to 10 if not specified."),
29379
29736
  source_policy: z$3.object({
29380
- include_domains: z$3.array(z$3.string()).optional().describe("Limit results to these domains. Use plain domain names only — e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page)."),
29381
- exclude_domains: z$3.array(z$3.string()).optional().describe("Exclude results from these domains. Use plain domain names only — e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page)."),
29382
- after_date: z$3.string().optional().describe("Only include results published after this date. Use an ISO 8601 calendar date formatted YYYY-MM-DD (e.g. 2025-01-01); do not include a time.")
29737
+ include_domains: z$3.array(z$3.string()).optional().describe("Domains or domain/path prefixes to restrict results to, without scheme or port. Example: ['wikipedia.org', 'docs.python.org/3']."),
29738
+ exclude_domains: z$3.array(z$3.string()).optional().describe("Domains or domain/path prefixes to exclude, without scheme or port. Example: ['reddit.com']."),
29739
+ after_date: z$3.string().optional().describe("Only include results published on or after this date. Use an ISO 8601 calendar date formatted YYYY-MM-DD (e.g. 2025-01-01); do not include a time.")
29383
29740
  }).optional().describe("Source policy for controlling which domains to include/exclude and freshness."),
29384
29741
  excerpts: z$3.object({
29385
29742
  max_chars_per_result: z$3.number().optional().describe("Maximum characters per result."),
29386
- max_chars_total: z$3.number().optional().describe("Maximum total characters across all results.")
29743
+ max_chars_total: z$3.number().optional().describe("Deprecated: use the top-level max_chars_total.")
29387
29744
  }).optional().describe("Excerpt configuration for controlling result length."),
29388
- fetch_policy: z$3.object({ max_age_seconds: z$3.number().optional().describe("Maximum age in seconds for cached content. Set to 0 to always fetch fresh content.") }).optional().describe("Fetch policy for controlling content freshness.")
29745
+ max_chars_total: z$3.number().optional().describe("Maximum total characters across all result excerpts."),
29746
+ fetch_policy: z$3.object({
29747
+ max_age_seconds: z$3.number().optional().describe("Maximum age of cached content in seconds before a live fetch, minimum 600."),
29748
+ timeout_seconds: z$3.number().optional().describe("Timeout in seconds for a live fetch when content is not cached. Capped by the gateway tool timeout."),
29749
+ disable_cache_fallback: z$3.boolean().optional().describe("Return an error instead of older cached content when a live fetch fails.")
29750
+ }).optional().describe("Fetch policy for controlling content freshness."),
29751
+ location: z$3.string().optional().describe("ISO 3166-1 alpha-2 country code to localize results, e.g. \"us\".")
29389
29752
  }))),
29390
29753
  outputSchema: lazySchema(() => zodSchema$4(z$3.union([z$3.object({
29391
- searchId: z$3.string(),
29754
+ search_id: z$3.string(),
29392
29755
  results: z$3.array(z$3.object({
29393
29756
  url: z$3.string(),
29394
- title: z$3.string(),
29395
- excerpt: z$3.string(),
29396
- publishDate: z$3.string().nullable().optional(),
29397
- relevanceScore: z$3.number().optional()
29398
- }))
29757
+ title: z$3.string().nullable().optional(),
29758
+ publish_date: z$3.string().nullable().optional(),
29759
+ excerpts: z$3.array(z$3.string())
29760
+ })),
29761
+ warnings: z$3.array(z$3.object({
29762
+ type: z$3.string(),
29763
+ message: z$3.string(),
29764
+ detail: z$3.record(z$3.string(), z$3.unknown()).nullable().optional()
29765
+ })).nullable().optional(),
29766
+ usage: z$3.array(z$3.object({
29767
+ name: z$3.string(),
29768
+ count: z$3.number().optional()
29769
+ })).nullable().optional(),
29770
+ session_id: z$3.string().optional()
29399
29771
  }), z$3.object({
29400
29772
  error: z$3.enum([
29401
29773
  "api_error",
29774
+ "configuration_error",
29775
+ "execution_error",
29776
+ "gateway_rate_limit",
29777
+ "invalid_input",
29402
29778
  "rate_limit",
29403
29779
  "timeout",
29404
- "invalid_input",
29405
- "configuration_error",
29406
- "unknown"
29780
+ "unknown",
29781
+ "unknown_tool"
29407
29782
  ]),
29408
29783
  statusCode: z$3.number().optional(),
29409
29784
  message: z$3.string()
@@ -29453,7 +29828,7 @@ const perplexitySearchToolFactory = createProviderExecutedToolFactory({
29453
29828
  })])))
29454
29829
  });
29455
29830
  const perplexitySearch = (config = {}) => perplexitySearchToolFactory(config);
29456
- const takoDataSourceInputSchema = z$3.object({
29831
+ const takoDataSourceInputSchema = () => z$3.object({
29457
29832
  count: z$3.number().optional().describe("Maximum number of data results to return (1-20). When include_contents is true, each additional result adds its own data surcharge."),
29458
29833
  include_contents: z$3.boolean().optional().describe("Inline rows for each data result. This adds a data surcharge based on row count and dataset source. To estimate cost, search with include_contents disabled and inspect cards.content.export_pricing. This applies to every returned card; limit sources.data.count and sources.data.max_rows to control cost."),
29459
29834
  mode: z$3.enum(["inline", "url"]).optional().describe("Requested data delivery mode. Search card data is always inline."),
@@ -29467,7 +29842,7 @@ const takoDataSourceInputSchema = z$3.object({
29467
29842
  node_ids: z$3.array(z$3.string()).optional().describe("Data Graph node IDs to prioritize. Maximum 20."),
29468
29843
  strict: z$3.boolean().optional().describe("Only return cards matching node_ids. Requires a non-empty node_ids.")
29469
29844
  });
29470
- const takoWebSourceInputSchema = z$3.object({
29845
+ const takoWebSourceInputSchema = () => z$3.object({
29471
29846
  count: z$3.number().optional().describe("Maximum number of web results to return (1-20)."),
29472
29847
  include_contents: z$3.boolean().optional().describe("Inline extracted web page text. This can add a data charge."),
29473
29848
  category: z$3.enum([
@@ -29491,8 +29866,8 @@ const takoSearchInputSchema = lazySchema(() => zodSchema$4(z$3.object({
29491
29866
  "instant"
29492
29867
  ]).optional().describe("Search effort. fast is the balanced default, instant favors cached results and low latency, and deep broadens retrieval with reranking at higher cost and latency."),
29493
29868
  sources: z$3.object({
29494
- data: takoDataSourceInputSchema.optional(),
29495
- web: takoWebSourceInputSchema.optional()
29869
+ data: takoDataSourceInputSchema().optional(),
29870
+ web: takoWebSourceInputSchema().optional()
29496
29871
  }).optional().describe("Sources to search. Omit to search both curated data and the web. When provided, only keys present are searched."),
29497
29872
  location: z$3.object({
29498
29873
  latitude: z$3.number().describe("Latitude between -90 and 90."),
@@ -29507,12 +29882,12 @@ const takoSearchInputSchema = lazySchema(() => zodSchema$4(z$3.object({
29507
29882
  }).optional().describe("Controls card rendering in the search response."),
29508
29883
  include_related: z$3.number().optional().describe("Maximum related search suggestions to include (1-20).")
29509
29884
  })));
29510
- const takoDatasetCellSchema = z$3.union([
29885
+ const takoDatasetCellSchema = () => z$3.union([
29511
29886
  z$3.boolean(),
29512
29887
  z$3.number(),
29513
29888
  z$3.string()
29514
29889
  ]).nullable();
29515
- const takoResultContentSchema = z$3.object({
29890
+ const takoResultContentSchema = () => z$3.object({
29516
29891
  content_format: z$3.enum([
29517
29892
  "card_json",
29518
29893
  "csv",
@@ -29521,7 +29896,7 @@ const takoResultContentSchema = z$3.object({
29521
29896
  ]).nullish(),
29522
29897
  cost: z$3.number().optional(),
29523
29898
  data: z$3.string().nullish(),
29524
- records: z$3.array(z$3.record(z$3.string(), takoDatasetCellSchema)).nullish(),
29899
+ records: z$3.array(z$3.record(z$3.string(), takoDatasetCellSchema())).nullish(),
29525
29900
  dataset: z$3.object({
29526
29901
  columns: z$3.array(z$3.object({
29527
29902
  name: z$3.string(),
@@ -29534,7 +29909,7 @@ const takoResultContentSchema = z$3.object({
29534
29909
  ]),
29535
29910
  unit: z$3.string().nullish()
29536
29911
  })),
29537
- rows: z$3.array(z$3.array(takoDatasetCellSchema)),
29912
+ rows: z$3.array(z$3.array(takoDatasetCellSchema())),
29538
29913
  total_rows: z$3.number(),
29539
29914
  truncated: z$3.boolean(),
29540
29915
  ref: z$3.string(),
@@ -29570,7 +29945,7 @@ const takoResultContentSchema = z$3.object({
29570
29945
  unit: z$3.string().nullish()
29571
29946
  })).nullish()
29572
29947
  }).passthrough();
29573
- const takoCardSchema = z$3.object({
29948
+ const takoCardSchema = () => z$3.object({
29574
29949
  card_id: z$3.string().nullish(),
29575
29950
  title: z$3.string().nullish(),
29576
29951
  description: z$3.string().nullish(),
@@ -29596,7 +29971,7 @@ const takoCardSchema = z$3.object({
29596
29971
  "Low",
29597
29972
  "Medium"
29598
29973
  ]).nullish(),
29599
- content: takoResultContentSchema.nullish(),
29974
+ content: takoResultContentSchema().nullish(),
29600
29975
  exportable: z$3.boolean().optional(),
29601
29976
  nodes: z$3.array(z$3.object({
29602
29977
  id: z$3.string(),
@@ -29614,21 +29989,21 @@ const takoCardSchema = z$3.object({
29614
29989
  last_updated: z$3.string().nullish()
29615
29990
  }).nullish()
29616
29991
  }).passthrough();
29617
- const takoWebResultSchema = z$3.object({
29992
+ const takoWebResultSchema = () => z$3.object({
29618
29993
  title: z$3.string(),
29619
29994
  url: z$3.string(),
29620
29995
  snippet: z$3.string().nullish(),
29621
29996
  source_name: z$3.string().nullish(),
29622
29997
  publish_date: z$3.string().nullish(),
29623
- content: takoResultContentSchema.nullish()
29998
+ content: takoResultContentSchema().nullish()
29624
29999
  }).passthrough();
29625
30000
  const takoSearchToolFactory = createProviderExecutedToolFactory({
29626
30001
  id: "gateway.tako_search",
29627
30002
  inputSchema: takoSearchInputSchema,
29628
30003
  outputSchema: lazySchema(() => zodSchema$4(z$3.union([z$3.object({
29629
30004
  request_id: z$3.string(),
29630
- cards: z$3.array(takoCardSchema).optional(),
29631
- web_results: z$3.array(takoWebResultSchema).optional(),
30005
+ cards: z$3.array(takoCardSchema()).optional(),
30006
+ web_results: z$3.array(takoWebResultSchema()).optional(),
29632
30007
  usage: z$3.object({
29633
30008
  total_cost_usd: z$3.number(),
29634
30009
  compute: z$3.object({ cost_usd: z$3.number() }).nullish(),
@@ -29709,13 +30084,13 @@ const gatewayTools = {
29709
30084
  async function getVercelRequestId() {
29710
30085
  return getContext().headers?.["x-vercel-id"];
29711
30086
  }
29712
- const VERSION$1$3 = "4.0.116";
30087
+ const VERSION$1$3 = "4.0.126";
29713
30088
  const AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
29714
30089
  /** Response shape of `POST /v1/realtime/client-secrets`. `expiresAt` is epoch seconds. */
29715
- const gatewayClientSecretResponseSchema = z$3.object({
30090
+ const gatewayClientSecretResponseSchema = lazySchema(() => zodSchema$4(z$3.object({
29716
30091
  token: z$3.string(),
29717
30092
  expiresAt: z$3.number().nullish()
29718
- });
30093
+ })));
29719
30094
  /**
29720
30095
  * Create a remote provider instance.
29721
30096
  */
@@ -29944,11 +30319,24 @@ function createGateway(options = {}) {
29944
30319
  baseURL,
29945
30320
  headers: getHeaders,
29946
30321
  fetch: options.fetch,
29947
- o11yHeaders: createO11yHeaders()
30322
+ o11yHeaders: createO11yHeaders(),
30323
+ webSocket: options.webSocket
29948
30324
  });
29949
30325
  };
29950
30326
  provider.speechModel = createSpeechModel;
29951
30327
  provider.speech = createSpeechModel;
30328
+ provider.experimental_speech = Object.assign((modelId) => createSpeechModel(modelId), { getToken: async (tokenOptions) => {
30329
+ const secret = await mintClientSecret({
30330
+ modelId: tokenOptions.model,
30331
+ routeKind: "speech",
30332
+ ...tokenOptions.expiresAfterSeconds != null && { expiresAfterSeconds: tokenOptions.expiresAfterSeconds }
30333
+ });
30334
+ return {
30335
+ token: secret.token,
30336
+ url: toGatewaySpeechUrl(baseURL, tokenOptions.model),
30337
+ ...secret.expiresAt != null && { expiresAt: secret.expiresAt }
30338
+ };
30339
+ } });
29952
30340
  const createTranscriptionModel = (modelId) => {
29953
30341
  return new GatewayTranscriptionModel(modelId, {
29954
30342
  provider: "gateway",
@@ -30011,7 +30399,7 @@ async function getGatewayAuthToken(options) {
30011
30399
  };
30012
30400
  }
30013
30401
  function assertGatewayClientSecretServerEnvironment() {
30014
- if (typeof globalThis.window !== "undefined") throw new Error("AI Gateway client secrets must be minted server-side: minting needs your Gateway credential, which must never reach the browser. Call gateway.experimental_realtime.getToken() or gateway.experimental_transcription.getToken() from your server and pass the returned token to the client.");
30402
+ if (typeof globalThis.window !== "undefined") throw new Error("AI Gateway client secrets must be minted server-side: minting needs your Gateway credential, which must never reach the browser. Call gateway.experimental_realtime.getToken(), gateway.experimental_transcription.getToken(), or gateway.experimental_speech.getToken() from your server and pass the returned token to the client.");
30015
30403
  }
30016
30404
  const name$23 = "AI_InvalidArgumentError";
30017
30405
  const marker$23 = `vercel.ai.error.${name$23}`;
@@ -30487,7 +30875,7 @@ function resolveEmbeddingModel(model) {
30487
30875
  function getGlobalProvider() {
30488
30876
  return asProviderV4(globalThis.AI_SDK_DEFAULT_PROVIDER ?? gateway);
30489
30877
  }
30490
- const VERSION = "7.0.143";
30878
+ const VERSION = "7.0.153";
30491
30879
  const z$2$1 = {
30492
30880
  array,
30493
30881
  boolean,
@@ -35240,6 +35628,19 @@ var OmIncompleteResponseError = class extends Error {
35240
35628
  }
35241
35629
  };
35242
35630
  /**
35631
+ * A model reply that finished but contains no text, or only whitespace.
35632
+ * Retryable, so an empty reply is retried like a transport error.
35633
+ *
35634
+ * @internal
35635
+ */
35636
+ var OmEmptyResponseError = class extends Error {
35637
+ isRetryable = true;
35638
+ constructor(label) {
35639
+ super(`${label} returned empty output`);
35640
+ this.name = "OmEmptyResponseError";
35641
+ }
35642
+ };
35643
+ /**
35243
35644
  * OM calls are single-step (`maxSteps: 1`). A step that ends with `other` or
35244
35645
  * `unknown` means the stream closed before the model finished, so its text is
35245
35646
  * partial. Throw a retryable error so `withRetry` re-runs the whole call
@@ -36559,6 +36960,14 @@ function sanitizeToolResultValue(value, seen = /* @__PURE__ */ new WeakMap()) {
36559
36960
  function serializeToolResultForTokenCounting(value) {
36560
36961
  return stringifyToolResult(value);
36561
36962
  }
36963
+ /**
36964
+ * Returns a tool invocation's `errorText` as a string. The field is typed as a string, but
36965
+ * persisted or imported history can hold a structured error object, so anything that is not
36966
+ * a string is serialized. Nullish values become an empty string.
36967
+ */
36968
+ function toolErrorTextToString(errorText) {
36969
+ return errorText == null ? "" : stringifyToolResult(errorText);
36970
+ }
36562
36971
  function stringifyToolResult(value) {
36563
36972
  if (typeof value === "string") return value;
36564
36973
  const sanitized = sanitizeToolResultValue(value);
@@ -37415,15 +37824,18 @@ function formatObserverMessage(msg, counter, toolFormatting, options) {
37415
37824
  if (exchange?.terminal?.occurrence === occurrence && !toolFormatting.emittedOutcomes.has(inv.toolCallId)) {
37416
37825
  toolFormatting.emittedOutcomes.add(inv.toolCallId);
37417
37826
  const hasResult = resultWithoutAttachments !== void 0 && (typeof resultWithoutAttachments !== "string" || resultWithoutAttachments.trim().length > 0);
37418
- const body = inv.isError ? hasResult ? formatToolResultForObserver(resultWithoutAttachments, { maxTokens: maxToolResultTokens }) : inv.errorText?.trim() ? inv.errorText : "Tool execution failed" : hasResult ? formatToolResultForObserver(resultWithoutAttachments, { maxTokens: maxToolResultTokens }) : "[empty result]";
37827
+ const errorText = toolErrorTextToString(inv.errorText);
37828
+ const body = inv.isError ? hasResult ? formatToolResultForObserver(resultWithoutAttachments, { maxTokens: maxToolResultTokens }) : errorText.trim() ? errorText : "Tool execution failed" : hasResult ? formatToolResultForObserver(resultWithoutAttachments, { maxTokens: maxToolResultTokens }) : "[empty result]";
37419
37829
  pushLine(`${inv.isError ? "Tool Error" : "Tool Result"} ${inv.toolName}`, maybeTruncate(body, maxLen), partCreatedAt, { tool: true });
37420
37830
  }
37421
37831
  return;
37422
37832
  }
37423
37833
  if (exchange?.terminal?.occurrence === occurrence && !toolFormatting.emittedOutcomes.has(inv.toolCallId)) {
37424
37834
  toolFormatting.emittedOutcomes.add(inv.toolCallId);
37425
- if (inv.state === "output-error") pushLine(`Tool Error ${inv.toolName}`, maybeTruncate(inv.errorText?.trim() ? inv.errorText : "Tool execution failed", maxLen), partCreatedAt, { tool: true });
37426
- else if (inv.state === "output-denied") pushLine(`Tool Denied ${inv.toolName}`, maybeTruncate(inv.approval?.reason?.trim() ? inv.approval.reason : "Tool call was not approved by the user", maxLen), partCreatedAt, { tool: true });
37835
+ if (inv.state === "output-error") {
37836
+ const errorText = toolErrorTextToString(inv.errorText);
37837
+ pushLine(`Tool Error ${inv.toolName}`, maybeTruncate(errorText.trim() ? errorText : "Tool execution failed", maxLen), partCreatedAt, { tool: true });
37838
+ } else if (inv.state === "output-denied") pushLine(`Tool Denied ${inv.toolName}`, maybeTruncate(inv.approval?.reason?.trim() ? inv.approval.reason : "Tool call was not approved by the user", maxLen), partCreatedAt, { tool: true });
37427
37839
  return;
37428
37840
  }
37429
37841
  if (!exchange) pushLine(`Tool Call ${inv.toolName}`, formatObserverToolArguments(inv.args, maxLen), partCreatedAt, { tool: true });
@@ -38320,7 +38732,7 @@ var ObserverRunner = class {
38320
38732
  callback: (childObservabilityContext) => this.withAbortCheck(async () => {
38321
38733
  try {
38322
38734
  attemptMemory = temporaryMemory?.newThread();
38323
- return assertCompleteModelResponse(await (await agent.stream(observerMessages, {
38735
+ return assertNonEmptyObserverOutput(assertCompleteModelResponse(await (await agent.stream(observerMessages, {
38324
38736
  maxSteps: 1,
38325
38737
  modelSettings: { ...this.observationConfig.modelSettings },
38326
38738
  providerOptions: this.observationConfig.providerOptions,
@@ -38329,7 +38741,7 @@ var ObserverRunner = class {
38329
38741
  onChunk: onActivity,
38330
38742
  ...internalRequestContext ? { requestContext: internalRequestContext } : {},
38331
38743
  ...childObservabilityContext
38332
- })).getFullOutput(), "OM observer");
38744
+ })).getFullOutput(), "OM observer"), "OM observer");
38333
38745
  } catch (error) {
38334
38746
  this.mastra?.getLogger?.().error("OM observer provider call failed", {
38335
38747
  diagnostic: formatOmError(error),
@@ -38534,7 +38946,7 @@ var ObserverRunner = class {
38534
38946
  },
38535
38947
  callback: (childObservabilityContext) => this.withAbortCheck(async () => {
38536
38948
  try {
38537
- return assertCompleteModelResponse(await (await agent.stream(observerMessages, {
38949
+ return assertNonEmptyObserverOutput(assertCompleteModelResponse(await (await agent.stream(observerMessages, {
38538
38950
  maxSteps: 1,
38539
38951
  modelSettings: { ...this.observationConfig.modelSettings },
38540
38952
  providerOptions: this.observationConfig.providerOptions,
@@ -38542,7 +38954,7 @@ var ObserverRunner = class {
38542
38954
  onChunk: onActivity,
38543
38955
  ...internalRequestContext ? { requestContext: internalRequestContext } : {},
38544
38956
  ...childObservabilityContext
38545
- })).getFullOutput(), "OM multi-thread observer");
38957
+ })).getFullOutput(), "OM multi-thread observer"), "OM multi-thread observer");
38546
38958
  } catch (error) {
38547
38959
  this.mastra?.getLogger?.().error("OM multi-thread observer provider call failed", {
38548
38960
  diagnostic: formatOmError(error),
@@ -38634,6 +39046,16 @@ var ObserverRunner = class {
38634
39046
  }
38635
39047
  };
38636
39048
  /**
39049
+ * An empty Observer response must not be committed: that would advance
39050
+ * `lastObservedAt` past messages that were never observed. Throwing a retryable
39051
+ * error lets `withRetry` retry it like a transport error; once retries run out
39052
+ * it surfaces as `OmModelExecutionError`, so `failurePolicy` decides the turn.
39053
+ */
39054
+ function assertNonEmptyObserverOutput(output, label) {
39055
+ if (!output.text?.trim()) throw new OmEmptyResponseError(label);
39056
+ return output;
39057
+ }
39058
+ /**
38637
39059
  * Synchronous image dimension lookup for in-memory image buffers.
38638
39060
  *
38639
39061
  * Uses `probe-image-size`'s sync parsers rather than `image-size`, which has unfixed
@@ -38944,7 +39366,7 @@ async function resolveImageDimensionsAsync(part) {
38944
39366
  const url = resolveHttpAssetUrl(getObjectValue(part, "image") ?? getObjectValue(part, "data"));
38945
39367
  if (!url) return existing;
38946
39368
  try {
38947
- const probeImageSize = (await import("./probe-image-size-DBmo2MAe.js").then((m) => /* @__PURE__ */ __toESM$1(m.default, 1))).default;
39369
+ const probeImageSize = (await import("./probe-image-size-DnRk0ecb.js").then((m) => /* @__PURE__ */ __toESM$1(m.default, 1))).default;
38948
39370
  const probed = await probeImageSize(url, {
38949
39371
  open_timeout: REMOTE_IMAGE_PROBE_TIMEOUT_MS,
38950
39372
  response_timeout: REMOTE_IMAGE_PROBE_TIMEOUT_MS,
@@ -39935,7 +40357,8 @@ var TokenCounter = class TokenCounter {
39935
40357
  }
39936
40358
  if (typeof resultForCounting !== "string") overheadDelta -= 12;
39937
40359
  } else {
39938
- const fallback = invocation.isError ? invocation.errorText?.trim() ? invocation.errorText : "Tool execution failed" : "[empty result]";
40360
+ const errorText = toolErrorTextToString(invocation.errorText);
40361
+ const fallback = invocation.isError ? errorText.trim() ? errorText : "Tool execution failed" : "[empty result]";
39939
40362
  tokens += this.readOrPersistPartEstimate(part, invocation.isError ? "tool-result-error" : "tool-result-json", fallback);
39940
40363
  }
39941
40364
  return {
@@ -39962,7 +40385,8 @@ var TokenCounter = class TokenCounter {
39962
40385
  const signature = this.countToolCallSignature(part, invocation);
39963
40386
  tokens += signature.tokens;
39964
40387
  overheadDelta += signature.overheadDelta;
39965
- const errorMessage = invocation.errorText?.trim() ? invocation.errorText : "Tool execution failed";
40388
+ const errorText = toolErrorTextToString(invocation.errorText);
40389
+ const errorMessage = errorText.trim() ? errorText : "Tool execution failed";
39966
40390
  tokens += this.readOrPersistPartEstimate(part, "tool-result-error", errorMessage);
39967
40391
  return {
39968
40392
  tokens,
@@ -42808,12 +43232,17 @@ function runNext(key, queue) {
42808
43232
  * Runs `op` once every earlier op on `key` has settled (reflection-priority ops first among those
42809
43233
  * still waiting) and resolves or rejects with its result. A rejection reaches only this caller.
42810
43234
  *
43235
+ * Aborting `abortSignal` while the op is still queued rejects the caller and skips the op. Once the
43236
+ * op has started, the caller waits for its result, so work after a landed commit still runs.
43237
+ *
42811
43238
  * Enqueueing on a key from inside an op that holds the same key, directly or through nested ops
42812
43239
  * on other keys, would deadlock, so it rejects.
42813
43240
  */
42814
- function runOMCommit(key, op, { priority = "normal" } = {}) {
43241
+ function runOMCommit(key, op, { priority = "normal", abortSignal } = {}) {
42815
43242
  if (holdsKey(key)) return Promise.reject(/* @__PURE__ */ new Error(`Re-entrant observational memory commit on "${key}": an op cannot enqueue on the key it holds.`));
42816
- return new Promise((resolve, reject) => {
43243
+ if (abortSignal?.aborted) return Promise.reject(abortSignal.reason);
43244
+ let started = false;
43245
+ const work = new Promise((resolve, reject) => {
42817
43246
  let queue = queues.get(key);
42818
43247
  if (!queue) {
42819
43248
  queue = {
@@ -42841,7 +43270,11 @@ function runOMCommit(key, op, { priority = "normal" } = {}) {
42841
43270
  release();
42842
43271
  }, OM_COMMIT_STALL_MS);
42843
43272
  stallTimer.unref?.();
42844
- heldKeys.run(held, () => Promise.resolve().then(op)).then((value) => {
43273
+ heldKeys.run(held, () => Promise.resolve().then(() => {
43274
+ abortSignal?.throwIfAborted();
43275
+ started = true;
43276
+ return op();
43277
+ })).then((value) => {
42845
43278
  release();
42846
43279
  resolve(value);
42847
43280
  }, (error) => {
@@ -42852,6 +43285,14 @@ function runOMCommit(key, op, { priority = "normal" } = {}) {
42852
43285
  (priority === "reflection" ? owner.reflection : owner.normal).push(start);
42853
43286
  if (owner.running === null) runNext(key, owner);
42854
43287
  });
43288
+ if (!abortSignal) return work;
43289
+ return new Promise((resolve, reject) => {
43290
+ const onAbort = () => {
43291
+ if (!started) reject(abortSignal.reason);
43292
+ };
43293
+ abortSignal.addEventListener("abort", onAbort, { once: true });
43294
+ work.then(resolve, reject).finally(() => abortSignal.removeEventListener("abort", onAbort));
43295
+ });
42855
43296
  }
42856
43297
  const activeOps = /* @__PURE__ */ new Map();
42857
43298
  function opKey(recordId, op) {
@@ -42871,6 +43312,24 @@ function unregisterOp(recordId, op) {
42871
43312
  function isOpActiveInProcess(recordId, op) {
42872
43313
  return (activeOps.get(opKey(recordId, op)) ?? 0) > 0;
42873
43314
  }
43315
+ /** Stops waiting when `signal` aborts; the awaited work keeps running. */
43316
+ async function waitWithAbort(work, signal) {
43317
+ if (!signal) return work;
43318
+ if (signal.aborted) {
43319
+ work.catch(() => {});
43320
+ throw signal.reason;
43321
+ }
43322
+ let onAbort = () => {};
43323
+ const cancelled = new Promise((_, reject) => {
43324
+ onAbort = () => reject(signal.reason);
43325
+ signal.addEventListener("abort", onAbort, { once: true });
43326
+ });
43327
+ try {
43328
+ return await Promise.race([work, cancelled]);
43329
+ } finally {
43330
+ signal.removeEventListener("abort", onAbort);
43331
+ }
43332
+ }
42874
43333
  /**
42875
43334
  * Manages the static buffering state machine for async observation and reflection.
42876
43335
  *
@@ -43013,7 +43472,7 @@ var BufferingCoordinator = class BufferingCoordinator {
43013
43472
  /**
43014
43473
  * Await any in-flight async buffering operations for a given thread/resource.
43015
43474
  */
43016
- static async awaitBuffering(threadId, resourceId, scope, timeoutMs = 3e4) {
43475
+ static async awaitBuffering(threadId, resourceId, scope, timeoutMs = 3e4, abortSignal) {
43017
43476
  const lockKey = getOMLockKey(scope, threadId, resourceId);
43018
43477
  const obsKey = `obs:${lockKey}`;
43019
43478
  const reflKey = `refl:${lockKey}`;
@@ -43025,9 +43484,9 @@ var BufferingCoordinator = class BufferingCoordinator {
43025
43484
  if (promises.length === 0) return;
43026
43485
  let timeoutId;
43027
43486
  try {
43028
- await Promise.race([Promise.allSettled(promises).then(() => void 0), new Promise((resolve) => {
43487
+ await waitWithAbort(Promise.race([Promise.allSettled(promises).then(() => void 0), new Promise((resolve) => {
43029
43488
  timeoutId = setTimeout(resolve, timeoutMs);
43030
- })]);
43489
+ })]), abortSignal);
43031
43490
  } finally {
43032
43491
  if (timeoutId !== void 0) clearTimeout(timeoutId);
43033
43492
  }
@@ -43554,17 +44013,21 @@ var ObservationStrategy = class ObservationStrategy {
43554
44013
  const { record, threadId, abortSignal, writer, reflectionHooks, requestContext } = this.opts;
43555
44014
  const cycleId = this.generateCycleId();
43556
44015
  try {
44016
+ abortSignal?.throwIfAborted();
43557
44017
  if (this.needsLock) {
43558
44018
  const fresh = await this.storage.getObservationalMemory(record.threadId, record.resourceId);
43559
44019
  if (fresh?.lastObservedAt && record.lastObservedAt && fresh.lastObservedAt > record.lastObservedAt) return { observed: false };
43560
44020
  }
44021
+ abortSignal?.throwIfAborted();
43561
44022
  const { messages, existingObservations, contextRecord } = await this.prepare();
43562
44023
  if (messages.length === 0) return { observed: false };
43563
44024
  const observationMessages = stripSubconsciousSignals(messages);
43564
44025
  await this.emitStartMarkers(cycleId);
43565
44026
  const observerContext = this.deps.prepareObserverContext(existingObservations, contextRecord ?? record);
43566
44027
  const output = await this.observe(observerContext.context ?? "", observationMessages, observerContext.wasTruncated);
44028
+ abortSignal?.throwIfAborted();
43567
44029
  let processed = await this.process(output, existingObservations);
44030
+ abortSignal?.throwIfAborted();
43568
44031
  let committedRecord = record;
43569
44032
  const outcome = await this.persist(processed);
43570
44033
  this.settleObservationCommit(outcome?.status === "committed" && !outcome.alreadyCovered);
@@ -43581,6 +44044,7 @@ var ObservationStrategy = class ObservationStrategy {
43581
44044
  processed = outcome.processed;
43582
44045
  committedRecord = outcome.record;
43583
44046
  }
44047
+ abortSignal?.throwIfAborted();
43584
44048
  await this.emitEndMarkers(cycleId, processed);
43585
44049
  if (this.needsReflection) await this.deps.reflector.maybeReflect({
43586
44050
  record: {
@@ -43608,6 +44072,7 @@ var ObservationStrategy = class ObservationStrategy {
43608
44072
  providerMetadata: output.providerMetadata
43609
44073
  };
43610
44074
  } catch (error) {
44075
+ if (abortSignal?.aborted) throw error;
43611
44076
  await this.emitFailedMarkers(cycleId, error);
43612
44077
  if (!this.rethrowOnFailure) {
43613
44078
  const failedMarkerForStorage = {
@@ -43770,6 +44235,7 @@ var ObservationStrategy = class ObservationStrategy {
43770
44235
  composedFrom = head.activeObservations ?? "";
43771
44236
  processed = await opts.recompose(head);
43772
44237
  }
44238
+ this.opts.abortSignal?.throwIfAborted();
43773
44239
  const input = {
43774
44240
  id: target.id,
43775
44241
  observations: processed.observations,
@@ -43806,7 +44272,10 @@ var ObservationStrategy = class ObservationStrategy {
43806
44272
  /** Runs one storage commit in this thread's (or resource's) slot of the process-wide commit queue. */
43807
44273
  runCommit(op) {
43808
44274
  const { threadId, resourceId, record } = this.opts;
43809
- return runOMCommit(getOMLockKey(this.scope, record.threadId ?? threadId, record.resourceId ?? resourceId), op);
44275
+ return runOMCommit(getOMLockKey(this.scope, record.threadId ?? threadId, record.resourceId ?? resourceId), () => {
44276
+ this.opts.abortSignal?.throwIfAborted();
44277
+ return op();
44278
+ }, { abortSignal: this.opts.abortSignal });
43810
44279
  }
43811
44280
  async indexObservationGroups(observations, threadId, resourceId, observedAt, recordId) {
43812
44281
  if (!resourceId || !this.deps.onIndexObservations) return;
@@ -43910,6 +44379,7 @@ var ObservationStrategy = class ObservationStrategy {
43910
44379
  return index;
43911
44380
  }
43912
44381
  async attachMarker(marker, msg, index, threadId, resourceId) {
44382
+ if (this.opts.abortSignal?.aborted) return;
43913
44383
  const parts = msg.content?.parts;
43914
44384
  if (!parts || !Array.isArray(parts)) return;
43915
44385
  const markerData = marker.data;
@@ -43931,7 +44401,7 @@ var ObservationStrategy = class ObservationStrategy {
43931
44401
  */
43932
44402
  async persistMarkerToStorage(marker, threadId, resourceId, opts) {
43933
44403
  try {
43934
- const assistants = ((await this.storage.listMessages({
44404
+ const result = await this.storage.listMessages({
43935
44405
  threadId,
43936
44406
  perPage: 20,
43937
44407
  orderBy: {
@@ -43939,7 +44409,9 @@ var ObservationStrategy = class ObservationStrategy {
43939
44409
  direction: "DESC"
43940
44410
  },
43941
44411
  ...opts?.notAfter ? { filter: { dateRange: { end: opts.notAfter } } } : {}
43942
- }))?.messages ?? []).filter((msg) => msg?.role === "assistant" && Array.isArray(msg.content?.parts));
44412
+ });
44413
+ if (this.opts.abortSignal?.aborted) return;
44414
+ const assistants = (result?.messages ?? []).filter((msg) => msg?.role === "assistant" && Array.isArray(msg.content?.parts));
43943
44415
  const startMessage = opts?.onlyIfObserved || opts?.onCycleStartMessage ? assistants.find((m) => afterOwnStartMarker(m, marker) !== -1) : void 0;
43944
44416
  const msg = opts?.onCycleStartMessage ? startMessage : startMessage ?? assistants[0];
43945
44417
  if (!msg) return;
@@ -43966,7 +44438,7 @@ var ObservationStrategy = class ObservationStrategy {
43966
44438
  * should fall back to `persistMarkerToStorage`).
43967
44439
  */
43968
44440
  async persistMarkerToMessage(marker, messageList, threadId, resourceId) {
43969
- if (!messageList) return false;
44441
+ if (this.opts.abortSignal?.aborted || !messageList) return false;
43970
44442
  const allMsgs = getObservableMessages(messageList);
43971
44443
  for (let i = allMsgs.length - 1; i >= 0; i--) {
43972
44444
  const msg = allMsgs[i];
@@ -44207,6 +44679,7 @@ var SyncObservationStrategy = class extends ObservationStrategy {
44207
44679
  },
44208
44680
  lastObservedMessageCursor: getLastObservedMessageCursor(messages)
44209
44681
  });
44682
+ this.opts.abortSignal?.throwIfAborted();
44210
44683
  await this.storage.patchThread({
44211
44684
  id: threadId,
44212
44685
  ...shouldUpdateThreadTitle ? { title: newTitle } : {},
@@ -44880,6 +45353,7 @@ var ResourceScopedObservationStrategy = class extends ObservationStrategy {
44880
45353
  },
44881
45354
  lastObservedMessageCursor: update.lastObservedMessageCursor
44882
45355
  });
45356
+ this.opts.abortSignal?.throwIfAborted();
44883
45357
  await this.storage.patchThread({
44884
45358
  id: update.threadId,
44885
45359
  ...shouldUpdateThreadTitle ? { title: newTitle } : {},
@@ -45075,6 +45549,7 @@ var ObservationStep = class {
45075
45549
  * builds system message, filters observed.
45076
45550
  */
45077
45551
  async prepare() {
45552
+ this.turn.abortSignal?.throwIfAborted();
45078
45553
  if (this._prepared) throw new Error(`Step ${this.stepNumber} already prepared`);
45079
45554
  const { threadId, resourceId, messageList } = this.turn;
45080
45555
  const om = this.turn.om;
@@ -45087,6 +45562,7 @@ var ObservationStep = class {
45087
45562
  const step0Messages = this.stepNumber === 0 ? getObservableMessages(messageList) : [];
45088
45563
  if (this.stepNumber === 0) {
45089
45564
  const activation = await om.activate({
45565
+ abortSignal: this.turn.abortSignal,
45090
45566
  threadId,
45091
45567
  resourceId,
45092
45568
  checkThreshold: true,
@@ -45103,7 +45579,8 @@ var ObservationStep = class {
45103
45579
  await om.resetBufferingState({
45104
45580
  threadId,
45105
45581
  resourceId,
45106
- recordId: activation.record.id
45582
+ recordId: activation.record.id,
45583
+ abortSignal: this.turn.abortSignal
45107
45584
  });
45108
45585
  await this.turn.refreshRecord();
45109
45586
  }
@@ -45111,6 +45588,7 @@ var ObservationStep = class {
45111
45588
  const preReflectGeneration = record.generationCount;
45112
45589
  const obsTokens = record.observationTokenCount ?? 0;
45113
45590
  await om.reflector.maybeReflect({
45591
+ abortSignal: this.turn.abortSignal,
45114
45592
  record,
45115
45593
  observationTokens: obsTokens,
45116
45594
  threadId,
@@ -45159,12 +45637,14 @@ var ObservationStep = class {
45159
45637
  const safeCandidates = selectSafeBufferPrefix(candidates);
45160
45638
  const deferred = candidates.length > 0 && safeCandidates.length === 0;
45161
45639
  if (safeCandidates.length > 0) {
45640
+ this.turn.abortSignal?.throwIfAborted();
45162
45641
  om.sealMessagesForBuffering(safeCandidates);
45163
45642
  try {
45164
45643
  await this.turn.hooks?.onBufferChunkSealed?.();
45165
45644
  } catch (error) {
45166
45645
  omDebug(`[OM:buffer] onBufferChunkSealed hook failed: ${error instanceof Error ? error.message : String(error)}`);
45167
45646
  }
45647
+ this.turn.abortSignal?.throwIfAborted();
45168
45648
  if (this.turn.memory) await this.turn.memory.persistMessages(safeCandidates);
45169
45649
  const inputIds = new Set(messageList.get.input.db().map((msg) => msg.id));
45170
45650
  const sealedOutput = safeCandidates.filter((msg) => !inputIds.has(msg.id));
@@ -45271,7 +45751,8 @@ var ObservationStep = class {
45271
45751
  threadId,
45272
45752
  resourceId,
45273
45753
  recordId: obsResult.record.id,
45274
- activatedMessageIds: obsResult.activatedMessageIds
45754
+ activatedMessageIds: obsResult.activatedMessageIds,
45755
+ abortSignal: this.turn.abortSignal
45275
45756
  });
45276
45757
  await this.turn.refreshRecord();
45277
45758
  if (this.turn.record.generationCount > preObsGeneration) reflected = true;
@@ -45337,7 +45818,7 @@ var ObservationStep = class {
45337
45818
  async runThresholdObservation(inAsyncObservationBand) {
45338
45819
  const { threadId, resourceId, messageList } = this.turn;
45339
45820
  const om = this.turn.om;
45340
- if (!inAsyncObservationBand) await om.waitForBuffering(threadId, resourceId);
45821
+ if (!inAsyncObservationBand) await om.waitForBuffering(threadId, resourceId, void 0, this.turn.abortSignal);
45341
45822
  await this.turn.refreshRecord();
45342
45823
  const observableMessages = this.seededResponseMessage ? getObservableMessages(messageList).filter((msg) => msg.id !== this.turn.responseMessageId) : getObservableMessages(messageList);
45343
45824
  let status = await om.getStatus({
@@ -45356,6 +45837,7 @@ var ObservationStep = class {
45356
45837
  let activated = false;
45357
45838
  while (status.shouldObserve && status.canActivate) {
45358
45839
  const activation = await om.activate({
45840
+ abortSignal: this.turn.abortSignal,
45359
45841
  threadId,
45360
45842
  resourceId,
45361
45843
  record: this.turn.record,
@@ -45396,6 +45878,7 @@ var ObservationStep = class {
45396
45878
  if (activated) {
45397
45879
  const preReflectionRecord = this.turn.record;
45398
45880
  await om.reflector.maybeReflect({
45881
+ abortSignal: this.turn.abortSignal,
45399
45882
  record: preReflectionRecord,
45400
45883
  observationTokens: preReflectionRecord.observationTokenCount ?? 0,
45401
45884
  threadId,
@@ -45436,6 +45919,7 @@ var ObservationStep = class {
45436
45919
  let obsResult;
45437
45920
  try {
45438
45921
  obsResult = await om.observe({
45922
+ abortSignal: this.turn.abortSignal,
45439
45923
  threadId,
45440
45924
  resourceId,
45441
45925
  messages: pendingMessages,
@@ -45472,6 +45956,7 @@ var ObservationStep = class {
45472
45956
  let messageToSeal = latestObservedIndex >= 0 ? liveMessages[latestObservedIndex] : void 0;
45473
45957
  if (this.stepNumber === 0 && messageToSeal?.role !== "assistant") messageToSeal = void 0;
45474
45958
  const messagesToSeal = messageToSeal ? [messageToSeal] : [];
45959
+ this.turn.abortSignal?.throwIfAborted();
45475
45960
  om.sealMessagesForBuffering(messagesToSeal);
45476
45961
  if (this.seededResponseMessage) omDebug("[OM:observe] skipping response-id rotation — step-0 seeded response message holds the active id");
45477
45962
  else try {
@@ -45603,7 +46088,9 @@ var ObservationTurn = class {
45603
46088
  responseMessageId;
45604
46089
  /** Processor-provided hooks for turn/step lifecycle integration. */
45605
46090
  hooks;
46091
+ abortSignal;
45606
46092
  constructor(opts) {
46093
+ this.abortSignal = opts.abortSignal;
45607
46094
  this.om = opts.om;
45608
46095
  this.threadId = opts.threadId;
45609
46096
  this.resourceId = opts.resourceId;
@@ -45717,7 +46204,7 @@ var ObservationTurn = class {
45717
46204
  if (unsavedMessages.length > 0) await this.om.persistMessages(unsavedMessages, this.threadId, this.resourceId);
45718
46205
  const asyncObservationEnabled = this.om.buffering.isAsyncObservationEnabled();
45719
46206
  const bufferOnIdle = this.om.getObservationConfig().bufferOnIdle;
45720
- if (asyncObservationEnabled && bufferOnIdle) {
46207
+ if (!this.abortSignal?.aborted && asyncObservationEnabled && bufferOnIdle) {
45721
46208
  const allMessages = getObservableMessages(messageList);
45722
46209
  const record = this._record;
45723
46210
  const idleMessages = selectSafeBufferPrefix(this.om.getUnobservedMessages(allMessages, record));
@@ -46069,7 +46556,7 @@ async function getThreadExtractedValues(storage, extractors, threadId) {
46069
46556
  const thread = await storage.getThreadById({ threadId });
46070
46557
  return getPriorExtractedValues(getThreadOMMetadata(thread?.metadata), extractors);
46071
46558
  }
46072
- async function persistThreadExtractedValues(storage, extractors, threadId, values) {
46559
+ async function persistThreadExtractedValues(storage, extractors, threadId, values, abortSignal) {
46073
46560
  if (!threadId || !values) return;
46074
46561
  const metadataUpdate = buildThreadMetadataFromExtractedValues(extractors, values);
46075
46562
  const thread = await storage.getThreadById({ threadId });
@@ -46084,6 +46571,7 @@ async function persistThreadExtractedValues(storage, extractors, threadId, value
46084
46571
  ...metadataUpdate.extracted ?? {}
46085
46572
  }
46086
46573
  });
46574
+ abortSignal?.throwIfAborted();
46087
46575
  await storage.patchThread({
46088
46576
  id: threadId,
46089
46577
  metadata: newMetadata
@@ -46391,7 +46879,7 @@ var ReflectorRunner = class {
46391
46879
  ...failedMarker,
46392
46880
  transient: true
46393
46881
  }).catch(() => {});
46394
- await this.persistMarkerToStorage(failedMarker, streamContext.threadId, streamContext.resourceId);
46882
+ await this.persistMarkerToStorage(failedMarker, streamContext.threadId, streamContext.resourceId, abortSignal);
46395
46883
  const retryCycleId = crypto.randomUUID();
46396
46884
  streamContext.cycleId = retryCycleId;
46397
46885
  const startMarker = createObservationStartMarker({
@@ -46408,7 +46896,7 @@ var ReflectorRunner = class {
46408
46896
  ...startMarker,
46409
46897
  transient: true
46410
46898
  }).catch(() => {});
46411
- await this.persistMarkerToStorage(startMarker, streamContext.threadId, streamContext.resourceId);
46899
+ await this.persistMarkerToStorage(startMarker, streamContext.threadId, streamContext.resourceId, abortSignal);
46412
46900
  }
46413
46901
  currentLevel = Math.min(currentLevel + 1, maxLevel);
46414
46902
  }
@@ -46558,7 +47046,6 @@ var ReflectorRunner = class {
46558
47046
  const compressionStartLevel = await this.getCompressionStartLevel(requestContext);
46559
47047
  const reflectResult = await this.call(activeObservations, void 0, void 0, compressionTarget, void 0, true, compressionStartLevel, requestContext, priorExtractedValues, observabilityContext, void 0, mainAgent, sendSignal, currentModel);
46560
47048
  reflectResult.observations = await applyTextTransform(this.hooks, "afterReflection", reflectResult.observations, hookContext);
46561
- await persistThreadExtractedValues(this.storage, this.reflectionConfig.extractors, currentRecord.threadId ?? void 0, reflectResult.extractedValues);
46562
47049
  const reflectionTokenCount = this.tokenCounter.countObservations(reflectResult.observations);
46563
47050
  omDebug(`[OM:reflect] doAsyncBufferedReflection: reflector returned ${reflectionTokenCount} tokens (${reflectResult.observations?.length} chars), saving to recordId=${currentRecord.id}`);
46564
47051
  if (!await runOMCommit(this.buffering.getLockKey(currentRecord.threadId, currentRecord.resourceId), async () => {
@@ -46580,6 +47067,7 @@ var ReflectorRunner = class {
46580
47067
  };
46581
47068
  }
46582
47069
  omDebug(`[OM:reflect] doAsyncBufferedReflection: bufferedReflection saved with lineCount=${reflectedObservationLineCount}`);
47070
+ await persistThreadExtractedValues(this.storage, this.reflectionConfig.extractors, currentRecord.threadId ?? void 0, reflectResult.extractedValues);
46583
47071
  if (writer) {
46584
47072
  const endMarker = createBufferingEndMarker({
46585
47073
  cycleId,
@@ -46618,8 +47106,10 @@ var ReflectorRunner = class {
46618
47106
  else {
46619
47107
  omDebug(`[OM:reflect] tryActivateBufferedReflection: waiting for in-progress op...`);
46620
47108
  try {
46621
- await Promise.race([asyncOp, new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error("Timeout")), 5e3))]);
46622
- } catch {}
47109
+ await waitWithAbort(Promise.race([asyncOp, new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error("Timeout")), 5e3))]), committedContext?.abortSignal);
47110
+ } catch {
47111
+ committedContext?.abortSignal?.throwIfAborted();
47112
+ }
46623
47113
  }
46624
47114
  }
46625
47115
  const freshRecord = await this.storage.getObservationalMemory(record.threadId, record.resourceId);
@@ -46660,11 +47150,17 @@ var ReflectorRunner = class {
46660
47150
  }
46661
47151
  omDebug(`[OM:reflect] tryActivateBufferedReflection: activating, beforeTokens=${beforeTokens}, combinedTokenCount=${combinedTokenCount}, reflectedLineCount=${reflectedLineCount}, unreflectedLines=${unreflectedLines.length}`);
46662
47152
  const newRecordId = crypto.randomUUID();
46663
- const swapped = await runOMCommit(lockKey, () => this.storage.swapBufferedReflectionToActive({
46664
- currentRecord: freshRecord,
46665
- tokenCount: combinedTokenCount,
46666
- newRecordId
46667
- }), { priority: "reflection" });
47153
+ const swapped = await runOMCommit(lockKey, () => {
47154
+ committedContext?.abortSignal?.throwIfAborted();
47155
+ return this.storage.swapBufferedReflectionToActive({
47156
+ currentRecord: freshRecord,
47157
+ tokenCount: combinedTokenCount,
47158
+ newRecordId
47159
+ });
47160
+ }, {
47161
+ priority: "reflection",
47162
+ abortSignal: committedContext?.abortSignal
47163
+ });
46668
47164
  if (!isReflectionApplied(swapped, newRecordId, freshRecord.id)) {
46669
47165
  omDebug(`[OM:reflect] tryActivateBufferedReflection: buffered reflection on ${freshRecord.id} not applied (head is ${swapped.id})`);
46670
47166
  return { status: "not-applied" };
@@ -46704,7 +47200,7 @@ var ReflectorRunner = class {
46704
47200
  ...activationMarker,
46705
47201
  transient: true
46706
47202
  }).catch(() => {});
46707
- await this.persistMarkerToMessage(activationMarker, messageList, freshRecord.threadId ?? "", freshRecord.resourceId ?? void 0);
47203
+ await this.persistMarkerToMessage(activationMarker, messageList, freshRecord.threadId ?? "", freshRecord.resourceId ?? void 0, committedContext?.abortSignal);
46708
47204
  }
46709
47205
  BufferingCoordinator.reflectionBufferCycleIds.delete(bufferKey);
46710
47206
  return { status: "activated" };
@@ -46723,11 +47219,13 @@ var ReflectorRunner = class {
46723
47219
  * @internal Used by observation strategies. Do not call directly.
46724
47220
  */
46725
47221
  async maybeReflect(opts) {
47222
+ opts.abortSignal?.throwIfAborted();
46726
47223
  const { record: callerRecord, observationTokens, writer, abortSignal, mainAgent, sendSignal, sendStateSignal, messageList, currentModel, reflectionHooks, trigger, requestContext, observabilityContext, lastActivityAt, threadId: requestedThreadId } = opts;
46727
47224
  const record = { ...callerRecord };
46728
47225
  const lockKey = this.buffering.getLockKey(record.threadId, record.resourceId);
46729
47226
  const reflectThreshold = getMaxThreshold(this.getEffectiveReflectionTokens(record));
46730
47227
  const priorExtractedValues = await getThreadExtractedValues(this.storage, this.reflectionConfig.extractors, requestedThreadId ?? record.threadId);
47228
+ abortSignal?.throwIfAborted();
46731
47229
  if (this.buffering.isAsyncReflectionEnabled() && observationTokens < reflectThreshold) {
46732
47230
  if ((() => {
46733
47231
  if (!this.buffering.isAsyncReflectionEnabled()) return false;
@@ -46821,7 +47319,7 @@ var ReflectorRunner = class {
46821
47319
  ...startMarker,
46822
47320
  transient: true
46823
47321
  }).catch(() => {});
46824
- await this.persistMarkerToStorage(startMarker, threadId, record.resourceId ?? void 0);
47322
+ await this.persistMarkerToStorage(startMarker, threadId, record.resourceId ?? void 0, abortSignal);
46825
47323
  }
46826
47324
  this.emitDebugEvent({
46827
47325
  type: "reflection_triggered",
@@ -46859,21 +47357,29 @@ var ReflectorRunner = class {
46859
47357
  };
46860
47358
  const reflectResult = await this.call(await applyTextTransform(this.hooks, "beforeReflection", record.activeObservations, hookContext), void 0, streamContext, reflectThreshold, abortSignal, void 0, compressionStartLevel, requestContext, priorExtractedValues, observabilityContext, void 0, mainAgent, sendSignal, currentModel);
46861
47359
  reflectResult.observations = await applyTextTransform(this.hooks, "afterReflection", reflectResult.observations, hookContext);
47360
+ abortSignal?.throwIfAborted();
46862
47361
  reflectionUsage = reflectResult.usage;
46863
47362
  reflectionProviderMetadata = reflectResult.providerMetadata;
46864
47363
  const reflectionTokenCount = this.tokenCounter.countObservations(reflectResult.observations);
46865
47364
  const newRecordId = crypto.randomUUID();
46866
- const committedRecord = await runOMCommit(this.buffering.getLockKey(record.threadId, record.resourceId), () => this.storage.createReflectionGeneration({
46867
- currentRecord: record,
46868
- reflection: reflectResult.observations,
46869
- tokenCount: reflectionTokenCount,
46870
- newRecordId
46871
- }), { priority: "reflection" });
47365
+ const committedRecord = await runOMCommit(this.buffering.getLockKey(record.threadId, record.resourceId), () => {
47366
+ abortSignal?.throwIfAborted();
47367
+ return this.storage.createReflectionGeneration({
47368
+ currentRecord: record,
47369
+ reflection: reflectResult.observations,
47370
+ tokenCount: reflectionTokenCount,
47371
+ newRecordId
47372
+ });
47373
+ }, {
47374
+ priority: "reflection",
47375
+ abortSignal
47376
+ });
46872
47377
  if (!isReflectionApplied(committedRecord, newRecordId, record.id)) {
46873
47378
  omDebug(`[OM:reflect] reflection of ${record.id} not applied (head is ${committedRecord.id})`);
46874
47379
  throw new ReflectionNotAppliedError(record.id, committedRecord.id);
46875
47380
  }
46876
- await persistThreadExtractedValues(this.storage, this.reflectionConfig.extractors, record.threadId ?? void 0, reflectResult.extractedValues);
47381
+ abortSignal?.throwIfAborted();
47382
+ await persistThreadExtractedValues(this.storage, this.reflectionConfig.extractors, record.threadId ?? void 0, reflectResult.extractedValues, abortSignal);
46877
47383
  if (reflectionTokenCount >= reflectThreshold) this.syncReflectionSuppression.set(lockKey, reflectionTokenCount);
46878
47384
  else this.syncReflectionSuppression.delete(lockKey);
46879
47385
  await this.notifyReflectionCommitted({
@@ -46904,7 +47410,7 @@ var ReflectorRunner = class {
46904
47410
  ...endMarker,
46905
47411
  transient: true
46906
47412
  }).catch(() => {});
46907
- await this.persistMarkerToStorage(endMarker, threadId, record.resourceId ?? void 0);
47413
+ await this.persistMarkerToStorage(endMarker, threadId, record.resourceId ?? void 0, abortSignal);
46908
47414
  }
46909
47415
  this.emitDebugEvent({
46910
47416
  type: "reflection_complete",
@@ -46918,6 +47424,7 @@ var ReflectorRunner = class {
46918
47424
  });
46919
47425
  } catch (error) {
46920
47426
  reflectionError = error instanceof Error ? error : new Error(String(error));
47427
+ if (abortSignal?.aborted) throw error;
46921
47428
  const failedMarker = createObservationFailedMarker({
46922
47429
  cycleId: streamContext?.cycleId ?? cycleId,
46923
47430
  operationType: "reflection",
@@ -46934,12 +47441,12 @@ var ReflectorRunner = class {
46934
47441
  }).catch(() => {});
46935
47442
  let persistedToList = false;
46936
47443
  try {
46937
- persistedToList = await this.persistMarkerToMessage(failedMarker, messageList, threadId, record.resourceId ?? void 0);
47444
+ persistedToList = await this.persistMarkerToMessage(failedMarker, messageList, threadId, record.resourceId ?? void 0, abortSignal);
46938
47445
  } catch {
46939
47446
  persistedToList = false;
46940
47447
  }
46941
47448
  if (!persistedToList) try {
46942
- await this.persistMarkerToStorage(failedMarker, threadId, record.resourceId ?? void 0);
47449
+ await this.persistMarkerToStorage(failedMarker, threadId, record.resourceId ?? void 0, abortSignal);
46943
47450
  } catch (markerError) {
46944
47451
  omError("[OM] Failed to persist reflection-failed marker", markerError);
46945
47452
  }
@@ -47579,9 +48086,10 @@ var ObservationalMemory = class ObservationalMemory {
47579
48086
  * Acquire a lock for the given key, execute the callback, then release.
47580
48087
  * If a lock is already held, waits for it to be released before acquiring.
47581
48088
  */
47582
- async withLock(key, fn) {
48089
+ async withLock(key, fn, abortSignal) {
47583
48090
  const existingLock = this.locks.get(key);
47584
- if (existingLock) await existingLock;
48091
+ if (existingLock) await waitWithAbort(existingLock, abortSignal);
48092
+ abortSignal?.throwIfAborted();
47585
48093
  let releaseLock;
47586
48094
  const lockPromise = new Promise((resolve) => {
47587
48095
  releaseLock = resolve;
@@ -47723,8 +48231,8 @@ var ObservationalMemory = class ObservationalMemory {
47723
48231
  scope: this.scope,
47724
48232
  buffering: this.buffering,
47725
48233
  emitDebugEvent: (e) => this.emitDebugEvent(e),
47726
- persistMarkerToStorage: (m, t, r) => this.persistMarkerToStorage(m, t, r),
47727
- persistMarkerToMessage: (m, ml, t, r) => this.persistMarkerToMessage(m, ml, t, r),
48234
+ persistMarkerToStorage: (m, t, r, signal) => this.persistMarkerToStorage(m, t, r, { abortSignal: signal }),
48235
+ persistMarkerToMessage: (m, ml, t, r, signal) => this.persistMarkerToMessage(m, ml, t, r, signal),
47728
48236
  getCompressionStartLevel: (rc) => this.getCompressionStartLevel(rc),
47729
48237
  resolveModel: (inputTokens, options) => this.resolveReflectionModel(inputTokens, options),
47730
48238
  mastra: config.mastra,
@@ -47770,8 +48278,8 @@ var ObservationalMemory = class ObservationalMemory {
47770
48278
  * Wait for any in-flight async buffering operations for the given thread/resource.
47771
48279
  * Used by server endpoints to block until buffering completes so the UI can get final state.
47772
48280
  */
47773
- async waitForBuffering(threadId, resourceId, timeoutMs = 3e4) {
47774
- return BufferingCoordinator.awaitBuffering(threadId, resourceId, this.scope, timeoutMs);
48281
+ async waitForBuffering(threadId, resourceId, timeoutMs = 3e4, abortSignal) {
48282
+ return BufferingCoordinator.awaitBuffering(threadId, resourceId, this.scope, timeoutMs, abortSignal);
47775
48283
  }
47776
48284
  getConcreteModel(model, inputTokens) {
47777
48285
  if (model instanceof ModelByInputTokens) {
@@ -48074,7 +48582,8 @@ var ObservationalMemory = class ObservationalMemory {
48074
48582
  * assistant message; reflection markers belong to the current user input.
48075
48583
  * @internal Used by ReflectorRunner. Do not call directly.
48076
48584
  */
48077
- async persistMarkerToMessage(marker, messageList, threadId, resourceId) {
48585
+ async persistMarkerToMessage(marker, messageList, threadId, resourceId, abortSignal) {
48586
+ if (abortSignal?.aborted) return false;
48078
48587
  if (!messageList) return false;
48079
48588
  const allMsgs = messageList.get.all.db();
48080
48589
  const markerData = marker.data;
@@ -48111,7 +48620,7 @@ var ObservationalMemory = class ObservationalMemory {
48111
48620
  const targetRole = markerData?.operationType === "reflection" ? "user" : "assistant";
48112
48621
  const preferred = [...opts?.preferMessages ?? []].reverse().find((m) => m.role === targetRole && (!m.threadId || m.threadId === threadId));
48113
48622
  const preferredStored = preferred ? (await this.storage.listMessagesById({ messageIds: [preferred.id] })).messages : [];
48114
- const messages = (preferredStored.length ? { messages: preferredStored } : await this.storage.listMessages({
48623
+ const result = preferredStored.length ? { messages: preferredStored } : await this.storage.listMessages({
48115
48624
  threadId,
48116
48625
  perPage: 20,
48117
48626
  orderBy: {
@@ -48119,7 +48628,9 @@ var ObservationalMemory = class ObservationalMemory {
48119
48628
  direction: "DESC"
48120
48629
  },
48121
48630
  ...opts?.notAfter ? { filter: { dateRange: { end: opts.notAfter } } } : {}
48122
- }))?.messages ?? [];
48631
+ });
48632
+ if (opts?.abortSignal?.aborted) return;
48633
+ const messages = result?.messages ?? [];
48123
48634
  for (const msg of messages) if (msg?.role === targetRole && msg.content?.parts && Array.isArray(msg.content.parts)) {
48124
48635
  if (!(markerData?.cycleId && msg.content.parts.some((p) => p?.type === marker.type && p?.data?.cycleId === markerData.cycleId))) msg.content.parts.push(marker);
48125
48636
  await this.messageHistory.persistMessages({
@@ -48886,12 +49397,15 @@ ${formattedMessages}
48886
49397
  */
48887
49398
  /** @internal Used by ObservationStep. */
48888
49399
  async resetBufferingState(opts) {
48889
- const { threadId, resourceId, recordId, activatedMessageIds } = opts;
49400
+ const { threadId, resourceId, recordId, activatedMessageIds, abortSignal } = opts;
48890
49401
  const lockKey = this.buffering.getLockKey(threadId, resourceId);
48891
49402
  const bufKey = this.buffering.getObservationBufferKey(lockKey);
48892
49403
  BufferingCoordinator.setObservationBoundary(bufKey, 0);
48893
- await runOMCommit(lockKey, () => this.storage.setBufferingObservationFlag(recordId, false, 0)).catch(() => {});
48894
- if (activatedMessageIds && activatedMessageIds.length > 0) this.buffering.cleanupStaticMaps(threadId, resourceId, activatedMessageIds);
49404
+ try {
49405
+ await waitWithAbort(this.trackBackgroundWork(runOMCommit(lockKey, () => this.storage.setBufferingObservationFlag(recordId, false, 0)).catch(() => {}), lockKey), abortSignal);
49406
+ } finally {
49407
+ if (activatedMessageIds && activatedMessageIds.length > 0) this.buffering.cleanupStaticMaps(threadId, resourceId, activatedMessageIds);
49408
+ }
48895
49409
  }
48896
49410
  /**
48897
49411
  * Build the observation system message string for injection into an LLM prompt.
@@ -49419,6 +49933,7 @@ ${formattedMessages}
49419
49933
  */
49420
49934
  /** @internal Used by ObservationStep. */
49421
49935
  async activate(opts) {
49936
+ opts.abortSignal?.throwIfAborted();
49422
49937
  const { threadId, resourceId } = opts;
49423
49938
  const record = opts.record ?? await this.getOrCreateRecord(threadId, resourceId);
49424
49939
  if (this.buffering.isAsyncObservationEnabled()) {
@@ -49431,7 +49946,8 @@ ${formattedMessages}
49431
49946
  if (currentContextTokens < dbBoundary * .5) {
49432
49947
  omDebug(`[OM:activate] resetting stale lastBufferedBoundary: dbBoundary=${dbBoundary}, currentContextTokens=${currentContextTokens}`);
49433
49948
  BufferingCoordinator.setObservationBoundary(bufKey, 0);
49434
- await runOMCommit(lockKey, () => this.storage.setBufferingObservationFlag(record.id, false, 0)).catch(() => {});
49949
+ await runOMCommit(lockKey, () => this.storage.setBufferingObservationFlag(record.id, false, 0), { abortSignal: opts.abortSignal }).catch(() => {});
49950
+ opts.abortSignal?.throwIfAborted();
49435
49951
  }
49436
49952
  }
49437
49953
  }
@@ -49484,8 +50000,11 @@ ${formattedMessages}
49484
50000
  const threshold = calculateDynamicThreshold(this.getEffectiveMessageTokens(record), record.observationTokenCount ?? 0);
49485
50001
  if (activationTriggeredBy === "threshold" && !(livePendingTokens !== void 0 && blockAfter !== void 0 && livePendingTokens >= threshold && livePendingTokens < blockAfter)) {
49486
50002
  let timeoutId;
49487
- await Promise.race([pendingChunkWrite, new Promise((resolve) => timeoutId = setTimeout(resolve, 6e4))]);
49488
- clearTimeout(timeoutId);
50003
+ try {
50004
+ await waitWithAbort(Promise.race([pendingChunkWrite, new Promise((resolve) => timeoutId = setTimeout(resolve, 6e4))]), opts.abortSignal);
50005
+ } finally {
50006
+ clearTimeout(timeoutId);
50007
+ }
49489
50008
  }
49490
50009
  }
49491
50010
  const commitKey = this.buffering.getLockKey(threadId, resourceId);
@@ -49504,7 +50023,9 @@ ${formattedMessages}
49504
50023
  const currentPendingTokens = livePendingTokens ?? (head.pendingMessageTokens || totalChunkMessageTokens);
49505
50024
  const blockAfter = this.getEffectiveObservationBlockAfter(head);
49506
50025
  const forceMaxActivation = !!(blockAfter && currentPendingTokens >= blockAfter);
50026
+ opts.abortSignal?.throwIfAborted();
49507
50027
  if (head.pendingMessageTokens !== currentPendingTokens) await this.storage.setPendingMessageTokens(head.id, currentPendingTokens);
50028
+ opts.abortSignal?.throwIfAborted();
49508
50029
  return {
49509
50030
  head,
49510
50031
  chunks,
@@ -49517,7 +50038,7 @@ ${formattedMessages}
49517
50038
  bufferedChunks: chunks
49518
50039
  })
49519
50040
  };
49520
- });
50041
+ }, { abortSignal: opts.abortSignal });
49521
50042
  if (!swapped) return {
49522
50043
  activated: false,
49523
50044
  record
@@ -49533,9 +50054,10 @@ ${formattedMessages}
49533
50054
  record: await this.getRecord(threadId, resourceId) ?? record
49534
50055
  };
49535
50056
  const swappedRecordId = freshRecord.id;
49536
- await runOMCommit(commitKey, () => this.storage.setBufferingObservationFlag(swappedRecordId, false)).catch(() => {});
50057
+ await waitWithAbort(this.trackBackgroundWork(runOMCommit(commitKey, () => this.storage.setBufferingObservationFlag(swappedRecordId, false)).catch(() => {}), commitKey), opts.abortSignal).catch(() => {});
49537
50058
  unregisterOp(freshRecord.id, "bufferingObservation");
49538
50059
  const postSwapRecord = await this.storage.getObservationalMemory(record.threadId, record.resourceId);
50060
+ opts.abortSignal?.throwIfAborted();
49539
50061
  if (opts.writer && postSwapRecord && activationResult.activatedCycleIds.length > 0) {
49540
50062
  const perChunkMap = new Map(activationResult.perChunk?.map((c) => [c.cycleId, c]));
49541
50063
  for (const cycleId of activationResult.activatedCycleIds) {
@@ -49565,10 +50087,11 @@ ${formattedMessages}
49565
50087
  ...activationMarker,
49566
50088
  transient: true
49567
50089
  }).catch(() => {});
49568
- await this.persistMarkerToMessage(activationMarker, opts.messageList, record.threadId ?? "", record.resourceId ?? void 0);
50090
+ await this.persistMarkerToMessage(activationMarker, opts.messageList, record.threadId ?? "", record.resourceId ?? void 0, opts.abortSignal);
49569
50091
  }
49570
50092
  }
49571
50093
  const thread = await this.storage.getThreadById({ threadId });
50094
+ opts.abortSignal?.throwIfAborted();
49572
50095
  if (thread) {
49573
50096
  const activatedChunks = freshChunks.filter((c) => activationResult.activatedCycleIds.includes(c.cycleId));
49574
50097
  const lastActivated = activatedChunks[activatedChunks.length - 1];
@@ -49713,6 +50236,7 @@ ${formattedMessages}
49713
50236
  let recordInsideLock;
49714
50237
  try {
49715
50238
  await this.withLock(lockKey, async () => {
50239
+ opts.abortSignal?.throwIfAborted();
49716
50240
  const freshRecord = await this.getOrCreateRecord(threadId, resourceId);
49717
50241
  recordInsideLock = freshRecord;
49718
50242
  generationBefore = freshRecord.generationCount;
@@ -49731,6 +50255,7 @@ ${formattedMessages}
49731
50255
  resourceId,
49732
50256
  messages: unobservedMessages,
49733
50257
  messageList: opts.messageList,
50258
+ abortSignal: opts.abortSignal,
49734
50259
  reflectionHooks,
49735
50260
  trigger,
49736
50261
  agent: opts.agent,
@@ -49745,7 +50270,7 @@ ${formattedMessages}
49745
50270
  observationUsage = result.usage;
49746
50271
  observationProviderMetadata = result.providerMetadata;
49747
50272
  observationError = result.error;
49748
- });
50273
+ }, opts.abortSignal);
49749
50274
  } catch (error) {
49750
50275
  lifecycleError = error;
49751
50276
  observationError = error instanceof Error ? error : new Error(String(error));
@@ -50016,6 +50541,7 @@ ${formattedMessages}
50016
50541
  beginTurn(opts) {
50017
50542
  return new ObservationTurn({
50018
50543
  om: this,
50544
+ abortSignal: opts.abortSignal,
50019
50545
  threadId: opts.threadId,
50020
50546
  resourceId: opts.resourceId,
50021
50547
  messageList: opts.messageList,
@@ -50187,10 +50713,11 @@ const CONTEXT_OVERFLOW_STEP_KEY = "__omContextOverflowStep";
50187
50713
  function isMastraGatewayModel(model) {
50188
50714
  return typeof model === "object" && model !== null && "gatewayId" in model && model.gatewayId === "mastra";
50189
50715
  }
50190
- function injectObservationContextMessages({ messageList, systemMessages, continuationMessage, threadId, resourceId }) {
50716
+ function injectObservationContextMessages({ messageList, systemMessages, continuationMessage, hasObservations, threadId, resourceId }) {
50191
50717
  if (!systemMessages?.length) return;
50192
50718
  messageList.clearSystemMessages("observational-memory");
50193
50719
  for (const msg of systemMessages) messageList.addSystem(msg, "observational-memory");
50720
+ if (!continuationMessage && !hasObservations) return;
50194
50721
  const contMsg = continuationMessage ?? {
50195
50722
  id: "om-continuation",
50196
50723
  role: "user",
@@ -50297,6 +50824,7 @@ var ObservationalMemoryProcessor = class {
50297
50824
  messageList,
50298
50825
  systemMessages,
50299
50826
  continuationMessage: ctx.continuationMessage,
50827
+ hasObservations: Boolean(ctx.omRecord?.activeObservations),
50300
50828
  threadId,
50301
50829
  resourceId
50302
50830
  });
@@ -50316,6 +50844,7 @@ var ObservationalMemoryProcessor = class {
50316
50844
  if (!this.turn || !state.__omTurn) {
50317
50845
  if (this.turn && !state.__omTurn) await this.turn.end().catch(() => {});
50318
50846
  this.turn = this.engine.beginTurn({
50847
+ abortSignal,
50319
50848
  threadId,
50320
50849
  resourceId,
50321
50850
  messageList,
@@ -50400,6 +50929,7 @@ var ObservationalMemoryProcessor = class {
50400
50929
  messageList,
50401
50930
  systemMessages: ctx.systemMessage,
50402
50931
  continuationMessage: this.turn.context.continuation,
50932
+ hasObservations: Boolean(this.turn.record.activeObservations),
50403
50933
  threadId,
50404
50934
  resourceId
50405
50935
  });
@@ -50417,7 +50947,7 @@ var ObservationalMemoryProcessor = class {
50417
50947
  });
50418
50948
  const finalTotalPending = ctx.status.pendingTokens;
50419
50949
  try {
50420
- await runOMCommit(this.engine.buffering.getLockKey(threadId, resourceId), () => this.engine.getStorage().setPendingMessageTokens(turnRecord.id, finalTotalPending));
50950
+ await runOMCommit(this.engine.buffering.getLockKey(threadId, resourceId), () => this.engine.getStorage().setPendingMessageTokens(turnRecord.id, finalTotalPending), { abortSignal });
50421
50951
  this.turn.patchRecord({ pendingMessageTokens: finalTotalPending });
50422
50952
  } catch {}
50423
50953
  if (reproCaptureEnabled) writeProcessInputStepReproCapture({
@@ -50476,9 +51006,10 @@ var ObservationalMemoryProcessor = class {
50476
51006
  state[CONTEXT_OVERFLOW_STEP_KEY] = stepNumber;
50477
51007
  omDebug(`[OM:processAPIError] context overflow at step ${stepNumber} — observing pending messages`);
50478
51008
  const { threadId, resourceId } = context;
50479
- await this.engine.waitForBuffering(threadId, resourceId);
51009
+ await this.engine.waitForBuffering(threadId, resourceId, void 0, args.abortSignal);
50480
51010
  const messages = getObservableMessages(messageList);
50481
51011
  const { activated } = await this.engine.activate({
51012
+ abortSignal: args.abortSignal,
50482
51013
  threadId,
50483
51014
  resourceId,
50484
51015
  messages,
@@ -50486,6 +51017,7 @@ var ObservationalMemoryProcessor = class {
50486
51017
  writer: args.writer
50487
51018
  });
50488
51019
  const { observed } = await this.engine.getTokenCounter().runWithModelContext(state.__omActorModelContext, () => this.engine.observe({
51020
+ abortSignal: args.abortSignal,
50489
51021
  threadId,
50490
51022
  resourceId,
50491
51023
  messages: getObservableMessages(messageList),
@@ -51781,7 +52313,8 @@ ${workingMemory}`;
51781
52313
  const workingMemoryConfig = config.workingMemory;
51782
52314
  if (config?.readOnly || workingMemoryConfig.agentManaged === false) return this.getReadOnlyWorkingMemoryInstruction({
51783
52315
  template: workingMemoryTemplate,
51784
- data: workingMemoryData
52316
+ data: workingMemoryData,
52317
+ autoUpdated: !config?.readOnly
51785
52318
  });
51786
52319
  return this.isVNextWorkingMemoryConfig(memoryConfig) ? this.__experimental_getWorkingMemoryToolInstructionVNext({
51787
52320
  template: workingMemoryTemplate,
@@ -52118,10 +52651,10 @@ ${template.content !== this.defaultWorkingMemoryTemplate ? `- Only store informa
52118
52651
  /**
52119
52652
  * Generate read-only working memory instructions.
52120
52653
  * This provides the working memory context without any tool update instructions.
52121
- * Used when memory is in readOnly mode.
52654
+ * Used when memory is in readOnly mode, or with `autoUpdated` when the app updates it (agentManaged: false).
52122
52655
  */
52123
- getReadOnlyWorkingMemoryInstruction({ data }) {
52124
- return `WORKING_MEMORY_SYSTEM_INSTRUCTION (READ-ONLY):
52656
+ getReadOnlyWorkingMemoryInstruction({ data, autoUpdated = false }) {
52657
+ return `WORKING_MEMORY_SYSTEM_INSTRUCTION (${autoUpdated ? "AUTO-UPDATED" : "READ-ONLY"}):
52125
52658
  The following is your working memory - persistent information about the user and conversation collected over previous interactions. This data is provided for context to help you maintain continuity.
52126
52659
 
52127
52660
  <working_memory_data>
@@ -52131,7 +52664,7 @@ ${data || "No working memory data available."}
52131
52664
  Guidelines:
52132
52665
  1. Use this information to provide personalized and contextually relevant responses
52133
52666
  2. Act naturally - don't mention this system to users. This information should inform your responses without being explicitly referenced
52134
- 3. This memory is read-only in the current session - you cannot update it
52667
+ 3. ${autoUpdated ? "This memory is updated automatically after each response. When the user shares or corrects information, acknowledge it naturally. Never say you can't save or update it" : "This memory is read-only in the current session - you cannot update it"}
52135
52668
 
52136
52669
  Notes:
52137
52670
  - This system is here so that you can maintain the conversation when your context window is very short
@@ -53259,8 +53792,7 @@ Notes:
53259
53792
  return new PinnedStateProcessor({ getKnowledgeStore: () => this.getKnowledgeStore() });
53260
53793
  }
53261
53794
  };
53262
- //#endregion
53263
- //#region ../agent-builder/dist/index.js
53795
+ // ../agent-builder/dist/index.js
53264
53796
  var import_ignore = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJSMin$1(((exports, module) => {
53265
53797
  function makeArray(subject) {
53266
53798
  return Array.isArray(subject) ? subject : [subject];
@@ -53269,13 +53801,16 @@ var import_ignore = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJSMin$1((
53269
53801
  const EMPTY = "";
53270
53802
  const SPACE = " ";
53271
53803
  const ESCAPE = "\\";
53272
- const REGEX_TEST_BLANK_LINE = /^\s+$/;
53804
+ const REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/;
53805
+ const BOM = "";
53273
53806
  const REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
53807
+ const REGEX_ANCHORED_GLOBSTAR = /^\/\*{2,}$/;
53274
53808
  const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
53275
53809
  const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
53276
53810
  const REGEX_SPLITALL_CRLF = /\r?\n/g;
53277
- const REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
53278
- const REGEX_TEST_TRAILING_SLASH = /\/$/;
53811
+ const DOUBLE_SLASH = "//";
53812
+ const SLASH_CODE = 47;
53813
+ const DOT_CODE = 46;
53279
53814
  const SLASH = "/";
53280
53815
  let TMP_KEY_IGNORE = "node-ignore";
53281
53816
  /* istanbul ignore else */
@@ -53285,51 +53820,319 @@ var import_ignore = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJSMin$1((
53285
53820
  Object.defineProperty(object, key, { value });
53286
53821
  return value;
53287
53822
  };
53288
- const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
53289
53823
  const RETURN_FALSE = () => false;
53290
- const sanitizeRange = (range) => range.replace(REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY);
53291
- const cleanRangeBackSlash = (slashes) => {
53292
- const { length } = slashes;
53293
- return slashes.slice(0, length - length % 2);
53824
+ const POSIX_CLASSES = {
53825
+ alnum: "0-9A-Za-z",
53826
+ alpha: "A-Za-z",
53827
+ blank: " \\t",
53828
+ cntrl: "\\x00-\\x1f\\x7f",
53829
+ digit: "0-9",
53830
+ graph: "!-.0-~",
53831
+ lower: "a-z",
53832
+ print: " -.0-~",
53833
+ punct: "!-.:-@\\[-`{-~",
53834
+ space: " \\t\\n\\r",
53835
+ upper: "A-Z",
53836
+ xdigit: "0-9A-Fa-f"
53837
+ };
53838
+ const CLASS_MEMBERS_TO_ESCAPE = "\\]^-[";
53839
+ const escapeMember = (char) => CLASS_MEMBERS_TO_ESCAPE.indexOf(char) < 0 ? char : ESCAPE + char;
53840
+ const NON_SLASH = "(?!\\/)";
53841
+ const classSource = (negated, body) => {
53842
+ if (negated) return `[^\\/${body}]`;
53843
+ const source = `[${body}]`;
53844
+ return new RegExp(source).test("/") ? NON_SLASH + source : source;
53845
+ };
53846
+ const scanBracket = (pattern, start) => {
53847
+ const { length } = pattern;
53848
+ let index = start + 1;
53849
+ let negated = EMPTY;
53850
+ const lead = pattern[index];
53851
+ if (lead === "!" || lead === "^") {
53852
+ negated = "^";
53853
+ index++;
53854
+ }
53855
+ let body = EMPTY;
53856
+ let prev = EMPTY;
53857
+ for (;;) {
53858
+ const char = pattern[index];
53859
+ if (char === UNDEFINED) return null;
53860
+ if (char === ESCAPE) {
53861
+ const escaped = pattern[index + 1];
53862
+ if (escaped === UNDEFINED) return null;
53863
+ body += escapeMember(escaped);
53864
+ prev = escaped;
53865
+ index++;
53866
+ } else if (char === "-" && prev && index + 1 < length && pattern[index + 1] !== "]") {
53867
+ index++;
53868
+ let to = pattern[index];
53869
+ if (to === ESCAPE) to = pattern[index += 1];
53870
+ if (prev <= to) body += `-${escapeMember(to)}`;
53871
+ prev = EMPTY;
53872
+ } else if (char === "[" && pattern[index + 1] === ":") {
53873
+ const nameStart = index + 2;
53874
+ let end = nameStart;
53875
+ while (end < length && pattern[end] !== "]") end++;
53876
+ if (end === length) return null;
53877
+ if (end > nameStart && pattern[end - 1] === ":") {
53878
+ const name = pattern.slice(nameStart, end - 1);
53879
+ if (!Object.prototype.hasOwnProperty.call(POSIX_CLASSES, name)) return null;
53880
+ body += POSIX_CLASSES[name];
53881
+ prev = EMPTY;
53882
+ index = end;
53883
+ } else {
53884
+ body += escapeMember("[");
53885
+ prev = "[";
53886
+ index = nameStart - 2;
53887
+ }
53888
+ } else {
53889
+ body += escapeMember(char);
53890
+ prev = char;
53891
+ }
53892
+ index++;
53893
+ if (pattern[index] === "]") return {
53894
+ end: index,
53895
+ source: classSource(negated, body)
53896
+ };
53897
+ }
53294
53898
  };
53899
+ const NEVER_MATCH = "[]";
53900
+ const PLACEHOLDER = "\0";
53901
+ const REGEX_RESTORE_PLACEHOLDER = new RegExp(`${PLACEHOLDER}(\\d+)${PLACEHOLDER}`, "g");
53902
+ const TRAILING_WILDCARD = "";
53903
+ const TRAILING_DOUBLESTAR = "";
53904
+ const isReserved = (char) => char === PLACEHOLDER || char === TRAILING_WILDCARD || char === TRAILING_DOUBLESTAR;
53905
+ const extractBrackets = (pattern) => {
53906
+ const sources = [];
53907
+ const hold = (source) => `${PLACEHOLDER}${sources.push(source) - 1}${PLACEHOLDER}`;
53908
+ const { length } = pattern;
53909
+ let out = EMPTY;
53910
+ let index = 0;
53911
+ while (index < length) {
53912
+ const char = pattern[index];
53913
+ if (char === ESCAPE) {
53914
+ const escaped = pattern[index + 1];
53915
+ if (escaped === UNDEFINED || escaped === SLASH && index + 2 === length) out += hold(NEVER_MATCH);
53916
+ else if (escaped === "*" || escaped === "[" || escaped === SPACE) out += pattern.slice(index, index + 2);
53917
+ else out += hold(REGEX_LITERAL_SPECIAL.test(escaped) ? ESCAPE + escaped : isReserved(escaped) ? `[${escaped}]` : escaped);
53918
+ index += 2;
53919
+ } else if (isReserved(char)) {
53920
+ out += hold(`[${char}]`);
53921
+ index++;
53922
+ } else if (char === "[") {
53923
+ const scanned = scanBracket(pattern, index);
53924
+ if (scanned === null) {
53925
+ out += hold(NEVER_MATCH);
53926
+ index = length;
53927
+ } else {
53928
+ out += hold(scanned.source);
53929
+ index = scanned.end + 1;
53930
+ }
53931
+ } else {
53932
+ out += char;
53933
+ index++;
53934
+ }
53935
+ }
53936
+ return {
53937
+ source: out,
53938
+ sources
53939
+ };
53940
+ };
53941
+ const DIRECT = null;
53942
+ const REGEX_INNER_SLASH = /\/(?!$)/;
53295
53943
  const REPLACERS = [
53296
- [/^\uFEFF/, () => EMPTY],
53297
- [/((?:\\\\)*?)(\\?\s+)$/, (_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)],
53298
- [/(\\+?)\s/g, (_, m1) => {
53299
- const { length } = m1;
53300
- return m1.slice(0, length - length % 2) + SPACE;
53301
- }],
53944
+ [
53945
+ /(\\+)( ?)/g,
53946
+ (_, run, space) => space ? run.slice(0, run.length - run.length % 2) + SPACE : run,
53947
+ "\\ "
53948
+ ],
53949
+ [
53950
+ /(^|\/)\*{3,}(?=\/|$)/g,
53951
+ (_, start) => `${start}**`,
53952
+ "*"
53953
+ ],
53302
53954
  [/[\\$.|*+(){^]/g, (match) => `\\${match}`],
53303
- [/(?!\\)\?/g, () => "[^/]"],
53304
- [/^\//, () => "^"],
53305
- [/\//g, () => "\\/"],
53306
- [/^\^*\\\*\\\*\\\//, () => "^(?:.*\\/)?"],
53307
- [/^(?=[^^])/, function startingReplacer() {
53308
- return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
53309
- }],
53310
- [/\\\/\\\*\\\*(?=\\\/|$)/g, (_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"],
53311
- [/(^|[^\\]+)(\\\*)+(?=.+)/g, (_, p1, p2) => {
53312
- return p1 + p2.replace(/\\\*/g, "[^\\/]*");
53955
+ [
53956
+ /(?!\\)\?/g,
53957
+ () => "[^/]",
53958
+ "?"
53959
+ ],
53960
+ [
53961
+ /^\//,
53962
+ () => "^",
53963
+ SLASH
53964
+ ],
53965
+ [
53966
+ /\//g,
53967
+ () => "\\/",
53968
+ SLASH
53969
+ ],
53970
+ [
53971
+ /^\^*(?:\\\*\\\*\\\/)+/,
53972
+ () => "^(?:.*\\/)?",
53973
+ "*"
53974
+ ],
53975
+ [DIRECT, (source, pattern) => {
53976
+ if (!source || source[0] === "^") return source;
53977
+ return (!REGEX_INNER_SLASH.test(pattern) ? "(?:^|\\/)" : "^") + source;
53313
53978
  }],
53314
- [/\\\\\\(?=[$.|*+(){^])/g, () => ESCAPE],
53315
- [/\\\\/g, () => ESCAPE],
53316
- [/(\\)?\[([^\]/]*?)(\\*)($|\])/g, (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]"],
53317
- [/(?:[^*])$/, (match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`]
53979
+ [
53980
+ /\\\/\\\*\\\*(?=\\\/|$)/g,
53981
+ (_, index, str) => index + 6 < str.length ? str.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : `\\/${TRAILING_DOUBLESTAR}`,
53982
+ "*"
53983
+ ],
53984
+ [
53985
+ /(^|[^\\]+)(\\\*)+(?=.+)/g,
53986
+ (_, p1, p2) => {
53987
+ return p1 + p2.replace(/\\\*/g, "[^\\/]*");
53988
+ },
53989
+ "*"
53990
+ ],
53991
+ [
53992
+ /(^|[^\\])((?:\\\\)*)\\\*$/,
53993
+ (match, p1, p2) => p2 === EMPTY ? p1 + TRAILING_WILDCARD : match,
53994
+ "*"
53995
+ ],
53996
+ [
53997
+ /\\\\\\(?=[$.|*+(){^])/g,
53998
+ () => ESCAPE,
53999
+ "\\\\"
54000
+ ],
54001
+ [
54002
+ /\\\\/g,
54003
+ () => ESCAPE,
54004
+ "\\\\"
54005
+ ],
54006
+ [
54007
+ /\\\[([^\]/]*?)($|\])/g,
54008
+ (match, range, close) => `\\[${range}${close}`,
54009
+ "["
54010
+ ],
54011
+ [DIRECT, (source) => {
54012
+ const last = source[source.length - 1];
54013
+ if (!last || last === TRAILING_WILDCARD || last === TRAILING_DOUBLESTAR) return source;
54014
+ return last === SLASH ? `${source}$` : `${source}(?=$|\\/$)`;
54015
+ }]
53318
54016
  ];
53319
- const REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
54017
+ const REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\uE000$/;
53320
54018
  const MODE_IGNORE = "regex";
53321
54019
  const MODE_CHECK_IGNORE = "checkRegex";
53322
- const TRAILING_WILD_CARD_REPLACERS = {
53323
- [MODE_IGNORE](_, p1) {
53324
- return `${p1 ? `${p1}[^/]+` : "[^/]*"}(?=$|\\/$)`;
53325
- },
53326
- [MODE_CHECK_IGNORE](_, p1) {
53327
- return `${p1 ? `${p1}[^/]*` : "[^/]*"}(?=$|\\/$)`;
54020
+ const replaceTrailingWildcard = (_, p1) => {
54021
+ return `${p1 ? `${p1}[^/]+` : "[^/]*"}(?=$|\\/$)`;
54022
+ };
54023
+ const REGEX_REPLACE_TRAILING_DOUBLESTAR = /\uE001$/;
54024
+ const replaceTrailingDoublestar = () => ".+(?=$|\\/$)";
54025
+ const WILDCARD = "[^\\/]*";
54026
+ const separatorAfter = (run, at) => {
54027
+ let separator = EMPTY;
54028
+ for (let index = at + 1; index < run.length && !run[index].wildcard; index++) separator += run[index].single;
54029
+ return separator;
54030
+ };
54031
+ const pinWildcards = (source) => {
54032
+ if (source.indexOf(WILDCARD) < 0) return source;
54033
+ const tokens = [];
54034
+ const { length } = source;
54035
+ let index = 0;
54036
+ while (index < length) {
54037
+ const char = source[index];
54038
+ if (source.startsWith(WILDCARD, index)) {
54039
+ tokens.push({ wildcard: true });
54040
+ index += 6;
54041
+ } else if (char === "[") {
54042
+ let end = index + 1;
54043
+ if (source[end] === "^") end++;
54044
+ if (source[end] === "]") end++;
54045
+ while (end < length && source[end] !== "]") end += source[end] === ESCAPE ? 2 : 1;
54046
+ end++;
54047
+ tokens.push({ single: source.slice(index, end) });
54048
+ index = end;
54049
+ } else if (char === ESCAPE) {
54050
+ tokens.push({ single: source.slice(index, index + 2) });
54051
+ index += 2;
54052
+ } else if (char === "(") {
54053
+ let depth = 0;
54054
+ let end = index;
54055
+ do {
54056
+ if (source[end] === ESCAPE) end++;
54057
+ else if (source[end] === "(") depth++;
54058
+ else if (source[end] === ")") depth--;
54059
+ end++;
54060
+ } while (end < length && depth > 0);
54061
+ if ("*+?".indexOf(source[end]) >= 0) end++;
54062
+ tokens.push({ boundary: source.slice(index, end) });
54063
+ index = end;
54064
+ } else if (char === "^" || char === "$") {
54065
+ tokens.push({ boundary: char });
54066
+ index++;
54067
+ } else {
54068
+ tokens.push({ single: char });
54069
+ index++;
54070
+ }
53328
54071
  }
54072
+ let out = EMPTY;
54073
+ let run = [];
54074
+ const flush = () => {
54075
+ let lastWildcard;
54076
+ run.forEach((token, at) => {
54077
+ if (token.wildcard) lastWildcard = at;
54078
+ });
54079
+ run.forEach((token, at) => {
54080
+ if (!token.wildcard) {
54081
+ out += token.single;
54082
+ return;
54083
+ }
54084
+ out += at === lastWildcard ? WILDCARD : `(?:(?!${separatorAfter(run, at)})[^\\/])*`;
54085
+ });
54086
+ run = [];
54087
+ };
54088
+ tokens.forEach((token) => {
54089
+ if (token.boundary === void 0) {
54090
+ run.push(token);
54091
+ return;
54092
+ }
54093
+ flush();
54094
+ out += token.boundary;
54095
+ });
54096
+ flush();
54097
+ return out;
54098
+ };
54099
+ const makeRegexPrefix = (pattern) => {
54100
+ if (REGEX_ANCHORED_GLOBSTAR.test(pattern)) pattern = "**";
54101
+ const { source, sources } = extractBrackets(pattern);
54102
+ const replaced = REPLACERS.reduce((prev, [matcher, replacer, required]) => {
54103
+ if (matcher === DIRECT) return replacer(prev, pattern);
54104
+ if (required !== UNDEFINED && prev.indexOf(required) < 0) return prev;
54105
+ return matcher.test(prev) ? prev.replace(matcher, replacer.bind(pattern)) : prev;
54106
+ }, source);
54107
+ return sources.length ? replaced.replace(REGEX_RESTORE_PLACEHOLDER, (match, index) => sources[index]) : replaced;
54108
+ };
54109
+ const checkSourceOf = (body, prefix) => {
54110
+ if (body[body.length - 1] === SLASH) prefix = makeRegexPrefix(body.slice(0, -1));
54111
+ const head = prefix.slice(0, -1);
54112
+ const last = prefix[prefix.length - 1];
54113
+ return last === TRAILING_WILDCARD ? `${head}$` : last === TRAILING_DOUBLESTAR ? `${head}.*$` : NEVER_MATCH;
54114
+ };
54115
+ const matchesBasename = (body) => {
54116
+ const index = body.indexOf(SLASH);
54117
+ return index < 0 || index === body.length - 1;
54118
+ };
54119
+ const basenameOf = (path) => {
54120
+ const end = path.length - 1;
54121
+ const index = path.lastIndexOf(SLASH, path[end] === SLASH ? end - 1 : end);
54122
+ return index < 0 ? path : path.slice(index + 1);
54123
+ };
54124
+ const parentOf = (path) => {
54125
+ if (path.charCodeAt(0) === SLASH_CODE || path.indexOf(DOUBLE_SLASH) >= 0) {
54126
+ const slices = path.split(SLASH).filter(Boolean);
54127
+ slices.pop();
54128
+ return slices.length ? slices.join(SLASH) + SLASH : EMPTY;
54129
+ }
54130
+ const end = path.length - 1;
54131
+ const cut = path.lastIndexOf(SLASH, path.charCodeAt(end) === SLASH_CODE ? end - 1 : end);
54132
+ return cut < 0 ? EMPTY : path.slice(0, cut + 1);
53329
54133
  };
53330
- const makeRegexPrefix = (pattern) => REPLACERS.reduce((prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)), pattern);
53331
54134
  const isString = (subject) => typeof subject === "string";
53332
- const checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
54135
+ const checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern);
53333
54136
  const splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
53334
54137
  var IgnoreRule = class {
53335
54138
  constructor(pattern, mark, body, ignoreCase, negative, prefix) {
@@ -53340,6 +54143,9 @@ var import_ignore = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJSMin$1((
53340
54143
  define(this, "ignoreCase", ignoreCase);
53341
54144
  define(this, "regexPrefix", prefix);
53342
54145
  }
54146
+ get _basenameOnly() {
54147
+ return define(this, "_basenameOnly", matchesBasename(this.body));
54148
+ }
53343
54149
  get regex() {
53344
54150
  const key = "_regex";
53345
54151
  if (this[key]) return this[key];
@@ -53351,18 +54157,33 @@ var import_ignore = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJSMin$1((
53351
54157
  return this._make(MODE_CHECK_IGNORE, key);
53352
54158
  }
53353
54159
  _make(mode, key) {
53354
- const str = this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, TRAILING_WILD_CARD_REPLACERS[mode]);
54160
+ const str = pinWildcards(mode === MODE_IGNORE ? this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, replaceTrailingWildcard).replace(REGEX_REPLACE_TRAILING_DOUBLESTAR, replaceTrailingDoublestar) : checkSourceOf(this.body, this.regexPrefix));
53355
54161
  const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
53356
54162
  return define(this, key, regex);
53357
54163
  }
53358
54164
  };
54165
+ const isLineEnd = (char) => char === "\r" || char === "\n";
54166
+ const trimEnd = (body) => {
54167
+ let end = body.length;
54168
+ while (end && isLineEnd(body[end - 1])) end--;
54169
+ const lineEnd = end;
54170
+ while (end && body[end - 1] === SPACE) end--;
54171
+ if (end === lineEnd) return body.slice(0, end);
54172
+ let backslashes = 0;
54173
+ while (backslashes < end && body[end - backslashes - 1] === ESCAPE) backslashes++;
54174
+ return backslashes % 2 ? body.slice(0, end - 1) + SPACE : body.slice(0, end);
54175
+ };
53359
54176
  const createRule = ({ pattern, mark }, ignoreCase) => {
54177
+ let body = pattern[0] === BOM ? pattern.slice(1) : pattern;
54178
+ if (body[0] === "#") return;
53360
54179
  let negative = false;
53361
- let body = pattern;
53362
- if (body.indexOf("!") === 0) {
54180
+ if (body[0] === "!") {
53363
54181
  negative = true;
53364
- body = body.substr(1);
54182
+ body = body.slice(1);
53365
54183
  }
54184
+ const last = body[body.length - 1];
54185
+ if (last === SPACE || last === "\r" || last === "\n") body = trimEnd(body);
54186
+ if (!body) return;
53366
54187
  body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
53367
54188
  const regexPrefix = makeRegexPrefix(body);
53368
54189
  return new IgnoreRule(pattern, mark, body, ignoreCase, negative, regexPrefix);
@@ -53371,37 +54192,43 @@ var import_ignore = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJSMin$1((
53371
54192
  constructor(ignoreCase) {
53372
54193
  this._ignoreCase = ignoreCase;
53373
54194
  this._rules = [];
54195
+ this._basenameCount = 0;
53374
54196
  }
53375
54197
  _add(pattern) {
53376
54198
  if (pattern && pattern[KEY_IGNORE]) {
53377
54199
  this._rules = this._rules.concat(pattern._rules._rules);
54200
+ this._basenameCount += pattern._rules._basenameCount;
53378
54201
  this._added = true;
53379
54202
  return;
53380
54203
  }
53381
54204
  if (isString(pattern)) pattern = { pattern };
53382
- if (checkPattern(pattern.pattern)) {
53383
- const rule = createRule(pattern, this._ignoreCase);
54205
+ const rule = checkPattern(pattern.pattern) && createRule(pattern, this._ignoreCase);
54206
+ if (rule) {
53384
54207
  this._added = true;
53385
54208
  this._rules.push(rule);
54209
+ if (matchesBasename(rule.body)) this._basenameCount++;
53386
54210
  }
53387
54211
  }
53388
54212
  add(pattern) {
53389
54213
  this._added = false;
53390
54214
  makeArray(isString(pattern) ? splitPattern(pattern) : pattern).forEach(this._add, this);
54215
+ if (this._added) this._literalRules = UNDEFINED;
53391
54216
  return this._added;
53392
54217
  }
53393
- test(path, checkUnignored, mode) {
54218
+ testLiteral(path) {
54219
+ const rules = this._literalRules || (this._literalRules = this._rules.filter(({ body }) => body[body.length - (body[body.length - 1] === SLASH ? 2 : 1)] === "*"));
53394
54220
  let ignored = false;
53395
54221
  let unignored = false;
53396
54222
  let matchedRule;
53397
- this._rules.forEach((rule) => {
53398
- const { negative } = rule;
53399
- if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) return;
53400
- if (!rule[mode].test(path)) return;
53401
- ignored = !negative;
53402
- unignored = negative;
53403
- matchedRule = negative ? UNDEFINED : rule;
53404
- });
54223
+ for (let index = rules.length - 1; index >= 0; index--) {
54224
+ const rule = rules[index];
54225
+ if (rule.checkRegex.test(path)) {
54226
+ ignored = !rule.negative;
54227
+ unignored = rule.negative;
54228
+ matchedRule = rule.negative ? UNDEFINED : rule;
54229
+ break;
54230
+ }
54231
+ }
53405
54232
  const ret = {
53406
54233
  ignored,
53407
54234
  unignored
@@ -53409,6 +54236,28 @@ var import_ignore = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJSMin$1((
53409
54236
  if (matchedRule) ret.rule = matchedRule;
53410
54237
  return ret;
53411
54238
  }
54239
+ test(path, mode) {
54240
+ const rules = this._rules;
54241
+ const { length } = rules;
54242
+ const shortcut = this._basenameCount * 2 >= length;
54243
+ const basename = shortcut ? basenameOf(path) : path;
54244
+ for (let index = length - 1; index >= 0; index--) {
54245
+ const rule = rules[index];
54246
+ if (rule[mode].test(shortcut && rule._basenameOnly ? basename : path)) {
54247
+ const { negative } = rule;
54248
+ const ret = {
54249
+ ignored: !negative,
54250
+ unignored: negative
54251
+ };
54252
+ if (!negative) ret.rule = rule;
54253
+ return ret;
54254
+ }
54255
+ }
54256
+ return {
54257
+ ignored: false,
54258
+ unignored: false
54259
+ };
54260
+ }
53412
54261
  };
53413
54262
  const throwError = (message, Ctor) => {
53414
54263
  throw new Ctor(message);
@@ -53419,7 +54268,16 @@ var import_ignore = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJSMin$1((
53419
54268
  if (checkPath.isNotRelative(path)) return doThrow(`path should be a \`path.relative()\`d string, but got "${originalPath}"`, RangeError);
53420
54269
  return true;
53421
54270
  };
53422
- const isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
54271
+ const isNotRelative = (path) => {
54272
+ const first = path.charCodeAt(0);
54273
+ if (first === SLASH_CODE) return true;
54274
+ if (first !== DOT_CODE) return false;
54275
+ if (path.length === 1) return true;
54276
+ const second = path.charCodeAt(1);
54277
+ if (second === SLASH_CODE) return true;
54278
+ if (second !== DOT_CODE) return false;
54279
+ return path.length === 2 || path.charCodeAt(2) === SLASH_CODE;
54280
+ };
53423
54281
  checkPath.isNotRelative = isNotRelative;
53424
54282
  /* istanbul ignore next */
53425
54283
  checkPath.convert = (p) => p;
@@ -53441,31 +54299,26 @@ var import_ignore = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJSMin$1((
53441
54299
  addPattern(pattern) {
53442
54300
  return this.add(pattern);
53443
54301
  }
53444
- _test(originalPath, cache, checkUnignored, slices) {
54302
+ _test(originalPath, cache) {
53445
54303
  const path = originalPath && checkPath.convert(originalPath);
53446
54304
  checkPath(path, originalPath, this._strictPathCheck ? throwError : RETURN_FALSE);
53447
- return this._t(path, cache, checkUnignored, slices);
54305
+ return this._t(path, cache);
53448
54306
  }
53449
54307
  checkIgnore(path) {
53450
- if (!REGEX_TEST_TRAILING_SLASH.test(path)) return this.test(path);
53451
- const slices = path.split(SLASH).filter(Boolean);
53452
- slices.pop();
53453
- if (slices.length) {
53454
- const parent = this._t(slices.join(SLASH) + SLASH, this._testCache, true, slices);
53455
- if (parent.ignored) return parent;
53456
- }
53457
- return this._rules.test(path, false, MODE_CHECK_IGNORE);
54308
+ if (path.charCodeAt(path.length - 1) !== SLASH_CODE) return this.test(path);
54309
+ const dir = this._t(path, this._testCache);
54310
+ if (dir.ignored) return dir;
54311
+ const literal = this._rules.testLiteral(path);
54312
+ return literal.ignored || literal.unignored ? literal : dir;
53458
54313
  }
53459
- _t(path, cache, checkUnignored, slices) {
54314
+ _t(path, cache) {
53460
54315
  if (path in cache) return cache[path];
53461
- if (!slices) slices = path.split(SLASH).filter(Boolean);
53462
- slices.pop();
53463
- if (!slices.length) return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
53464
- const parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices);
53465
- return cache[path] = parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
54316
+ const parentPath = parentOf(path);
54317
+ const parent = parentPath ? this._t(parentPath, cache) : UNDEFINED;
54318
+ return cache[path] = parent && parent.ignored ? parent : this._rules.test(path, MODE_IGNORE);
53466
54319
  }
53467
54320
  ignores(path) {
53468
- return this._test(path, this._ignoreCache, false).ignored;
54321
+ return this._test(path, this._ignoreCache).ignored;
53469
54322
  }
53470
54323
  createFilter() {
53471
54324
  return (path) => !this.ignores(path);
@@ -53474,7 +54327,7 @@ var import_ignore = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJSMin$1((
53474
54327
  return makeArray(paths).filter(this.createFilter());
53475
54328
  }
53476
54329
  test(path) {
53477
- return this._test(path, this._testCache, true);
54330
+ return this._test(path, this._testCache);
53478
54331
  }
53479
54332
  };
53480
54333
  const factory = (options) => new Ignore(options);
@@ -54049,23 +54902,23 @@ const createModelInstance = async (provider, modelId, version = "v2") => {
54049
54902
  try {
54050
54903
  const providerFn = version === `v1` ? { v1: {
54051
54904
  openai: async () => {
54052
- const { openai } = await import("./dist-Dgae8Imb.js");
54905
+ const { openai } = await import("./dist-t_05BTrR.js");
54053
54906
  return openai(modelId);
54054
54907
  },
54055
54908
  anthropic: async () => {
54056
- const { anthropic } = await import("./dist-DLld1qjf.js");
54909
+ const { anthropic } = await import("./dist-CVoi_Dov.js");
54057
54910
  return anthropic(modelId);
54058
54911
  },
54059
54912
  groq: async () => {
54060
- const { groq } = await import("./dist-BBOnrL_A.js");
54913
+ const { groq } = await import("./dist-Dwfkbwzg.js");
54061
54914
  return groq(modelId);
54062
54915
  },
54063
54916
  xai: async () => {
54064
- const { xai } = await import("./dist-BIrQLUV9.js");
54917
+ const { xai } = await import("./dist-Dc0g0QSi.js");
54065
54918
  return xai(modelId);
54066
54919
  },
54067
54920
  google: async () => {
54068
- const { google } = await import("./dist-CREG82cy.js");
54921
+ const { google } = await import("./dist-DC9qnRcv.js");
54069
54922
  return google(modelId);
54070
54923
  }
54071
54924
  } }[version][provider] : () => new ModelRouterLanguageModel(`${provider}/${modelId}`);
@@ -59990,40 +60843,40 @@ var API_NAME = "trace";
59990
60843
  })().getInstance();
59991
60844
  var __defProp = Object.defineProperty;
59992
60845
  var __export = (target, all) => {
59993
- for (var name16 in all) __defProp(target, name16, {
59994
- get: all[name16],
60846
+ for (var name17 in all) __defProp(target, name17, {
60847
+ get: all[name17],
59995
60848
  enumerable: true
59996
60849
  });
59997
60850
  };
59998
- var name6 = "AI_NoObjectGeneratedError";
59999
- var marker6 = `vercel.ai.error.${name6}`;
60000
- var symbol6 = Symbol.for(marker6);
60001
- var _a6;
60851
+ var name7 = "AI_NoObjectGeneratedError";
60852
+ var marker7 = `vercel.ai.error.${name7}`;
60853
+ var symbol7 = Symbol.for(marker7);
60854
+ var _a7;
60002
60855
  var NoObjectGeneratedError = class extends AISDKError {
60003
60856
  constructor({ message = "No object generated.", cause, text: text2, response, usage, finishReason }) {
60004
60857
  super({
60005
- name: name6,
60858
+ name: name7,
60006
60859
  message,
60007
60860
  cause
60008
60861
  });
60009
- this[_a6] = true;
60862
+ this[_a7] = true;
60010
60863
  this.text = text2;
60011
60864
  this.response = response;
60012
60865
  this.usage = usage;
60013
60866
  this.finishReason = finishReason;
60014
60867
  }
60015
60868
  static isInstance(error) {
60016
- return AISDKError.hasMarker(error, marker6);
60869
+ return AISDKError.hasMarker(error, marker7);
60017
60870
  }
60018
60871
  };
60019
- _a6 = symbol6;
60872
+ _a7 = symbol7;
60020
60873
  var dataContentSchema = z.union([
60021
60874
  z.string(),
60022
60875
  z.instanceof(Uint8Array),
60023
60876
  z.instanceof(ArrayBuffer),
60024
60877
  z.custom((value) => {
60025
- var _a16, _b;
60026
- return (_b = (_a16 = globalThis.Buffer) == null ? void 0 : _a16.isBuffer(value)) != null ? _b : false;
60878
+ var _a17, _b;
60879
+ return (_b = (_a17 = globalThis.Buffer) == null ? void 0 : _a17.isBuffer(value)) != null ? _b : false;
60027
60880
  }, { message: "Must be a Buffer" })
60028
60881
  ]);
60029
60882
  var jsonValueSchema = z.lazy(() => z.union([
@@ -61751,7 +62604,6 @@ const agentBuilderWorkflows = {
61751
62604
  };
61752
62605
  }).then(taskExecutionStep).commit()
61753
62606
  };
61754
- //#endregion
61755
62607
  export { require_exif_utils as a, agentBuilderWorkflows, require_svg_header as i, openai as n, require_miaf_utils as o, require_sync as r, require_common as s, createOpenAI as t };
61756
62608
 
61757
- //# sourceMappingURL=dist-5TAg2f91.js.map
62609
+ //# sourceMappingURL=dist-bAoX6ick.js.map