gemi 0.126.0 → 0.128.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/ai/index.js.map +1 -1
  3. package/dist/app/index.js +1 -1
  4. package/dist/bun/plugin.js +1 -1
  5. package/dist/bun/preload.js +1 -1
  6. package/dist/{chunk-bghxdjqv.js → chunk-03wc6em7.js} +1 -1
  7. package/dist/{chunk-56ryda9y.js → chunk-0m2fyw7g.js} +2 -2
  8. package/dist/{chunk-56ryda9y.js.map → chunk-0m2fyw7g.js.map} +1 -1
  9. package/dist/chunk-0mp9tck6.js +120 -0
  10. package/dist/{chunk-cwpezdpw.js.map → chunk-0mp9tck6.js.map} +9 -4
  11. package/dist/{chunk-ecb8qggy.js → chunk-0vxwrc4t.js} +2 -2
  12. package/dist/{chunk-ecb8qggy.js.map → chunk-0vxwrc4t.js.map} +1 -1
  13. package/dist/{chunk-1v368y9a.js → chunk-1gdzajwb.js} +2 -2
  14. package/dist/{chunk-1v368y9a.js.map → chunk-1gdzajwb.js.map} +1 -1
  15. package/dist/{chunk-h4755p9h.js → chunk-1rq53cb0.js} +2 -2
  16. package/dist/{chunk-h4755p9h.js.map → chunk-1rq53cb0.js.map} +1 -1
  17. package/dist/{chunk-v7nw1g2n.js → chunk-1yttk239.js} +2 -2
  18. package/dist/{chunk-v7nw1g2n.js.map → chunk-1yttk239.js.map} +1 -1
  19. package/dist/{chunk-28bby5pp.js → chunk-1z311hyj.js} +2 -2
  20. package/dist/{chunk-28bby5pp.js.map → chunk-1z311hyj.js.map} +1 -1
  21. package/dist/{chunk-n8mxsfc2.js → chunk-2869cbhd.js} +3 -3
  22. package/dist/{chunk-n8mxsfc2.js.map → chunk-2869cbhd.js.map} +1 -1
  23. package/dist/{chunk-dm7mada7.js → chunk-2bmk0fzm.js} +3 -3
  24. package/dist/{chunk-dm7mada7.js.map → chunk-2bmk0fzm.js.map} +1 -1
  25. package/dist/{chunk-ych1dv5q.js → chunk-2epj17ac.js} +3 -3
  26. package/dist/{chunk-ych1dv5q.js.map → chunk-2epj17ac.js.map} +1 -1
  27. package/dist/{chunk-0arss2xy.js → chunk-2z1gd231.js} +2 -2
  28. package/dist/{chunk-0arss2xy.js.map → chunk-2z1gd231.js.map} +1 -1
  29. package/dist/{chunk-xe2cfmyb.js → chunk-3dyd4z06.js} +2 -2
  30. package/dist/{chunk-xe2cfmyb.js.map → chunk-3dyd4z06.js.map} +1 -1
  31. package/dist/{chunk-p0ccxfkq.js → chunk-43vjbd6n.js} +1 -1
  32. package/dist/{chunk-nv2t87c3.js → chunk-4yp84g2y.js} +2 -2
  33. package/dist/{chunk-nv2t87c3.js.map → chunk-4yp84g2y.js.map} +1 -1
  34. package/dist/{chunk-bhbxhk9e.js → chunk-5bk7767a.js} +2 -2
  35. package/dist/{chunk-bhbxhk9e.js.map → chunk-5bk7767a.js.map} +1 -1
  36. package/dist/{chunk-k6gvbvyw.js → chunk-5nkvpc0a.js} +1 -1
  37. package/dist/{chunk-gxp48t81.js → chunk-5ym464xx.js} +4 -4
  38. package/dist/{chunk-gxp48t81.js.map → chunk-5ym464xx.js.map} +1 -1
  39. package/dist/{chunk-v80890xx.js → chunk-7321qjgb.js} +3 -3
  40. package/dist/{chunk-v80890xx.js.map → chunk-7321qjgb.js.map} +1 -1
  41. package/dist/{chunk-0f0xxqhy.js → chunk-87rtxv9n.js} +3 -3
  42. package/dist/{chunk-0f0xxqhy.js.map → chunk-87rtxv9n.js.map} +1 -1
  43. package/dist/{chunk-avfntxm1.js → chunk-8jqve5dr.js} +2 -2
  44. package/dist/{chunk-avfntxm1.js.map → chunk-8jqve5dr.js.map} +1 -1
  45. package/dist/{chunk-5vvfcdpk.js → chunk-9122838b.js} +2 -2
  46. package/dist/{chunk-5vvfcdpk.js.map → chunk-9122838b.js.map} +1 -1
  47. package/dist/{chunk-jg3kg55f.js → chunk-9701fx4z.js} +2 -2
  48. package/dist/{chunk-jg3kg55f.js.map → chunk-9701fx4z.js.map} +1 -1
  49. package/dist/{chunk-mj7h1dgh.js → chunk-b7wmssj5.js} +2 -2
  50. package/dist/{chunk-mj7h1dgh.js.map → chunk-b7wmssj5.js.map} +1 -1
  51. package/dist/{chunk-etf6h5m1.js → chunk-bg5qb9hm.js} +2 -2
  52. package/dist/{chunk-etf6h5m1.js.map → chunk-bg5qb9hm.js.map} +1 -1
  53. package/dist/{chunk-w4111j5d.js → chunk-bnp6wpzd.js} +2 -2
  54. package/dist/{chunk-w4111j5d.js.map → chunk-bnp6wpzd.js.map} +1 -1
  55. package/dist/{chunk-yg8se4vs.js → chunk-cp84b0ev.js} +3 -3
  56. package/dist/{chunk-yg8se4vs.js.map → chunk-cp84b0ev.js.map} +1 -1
  57. package/dist/{chunk-hye22tpt.js → chunk-dak8txaw.js} +2 -2
  58. package/dist/{chunk-hye22tpt.js.map → chunk-dak8txaw.js.map} +1 -1
  59. package/dist/{chunk-zy5gxk1g.js → chunk-df0mekds.js} +2 -2
  60. package/dist/{chunk-zy5gxk1g.js.map → chunk-df0mekds.js.map} +1 -1
  61. package/dist/{chunk-7x2n788t.js → chunk-er5ed5pg.js} +3 -3
  62. package/dist/{chunk-7x2n788t.js.map → chunk-er5ed5pg.js.map} +1 -1
  63. package/dist/{chunk-s2y2b8tz.js → chunk-f8ce6e9c.js} +2 -2
  64. package/dist/{chunk-s2y2b8tz.js.map → chunk-f8ce6e9c.js.map} +1 -1
  65. package/dist/{chunk-7eerqsg2.js → chunk-fezaxj28.js} +2 -2
  66. package/dist/{chunk-7eerqsg2.js.map → chunk-fezaxj28.js.map} +1 -1
  67. package/dist/{chunk-q9mxjh10.js → chunk-fv53h1q2.js} +2 -2
  68. package/dist/{chunk-q9mxjh10.js.map → chunk-fv53h1q2.js.map} +1 -1
  69. package/dist/{chunk-62zn06wb.js → chunk-gpdsxwkt.js} +2 -2
  70. package/dist/{chunk-62zn06wb.js.map → chunk-gpdsxwkt.js.map} +1 -1
  71. package/dist/{chunk-15bmfr7f.js → chunk-gzaaspe7.js} +2 -2
  72. package/dist/{chunk-15bmfr7f.js.map → chunk-gzaaspe7.js.map} +1 -1
  73. package/dist/{chunk-3fyhd641.js → chunk-h55c9bdf.js} +1 -1
  74. package/dist/{chunk-x5vpjzpp.js → chunk-ja41ts8v.js} +2 -2
  75. package/dist/{chunk-x5vpjzpp.js.map → chunk-ja41ts8v.js.map} +1 -1
  76. package/dist/{chunk-1dzs05dc.js → chunk-jcps2gpp.js} +2 -2
  77. package/dist/{chunk-1dzs05dc.js.map → chunk-jcps2gpp.js.map} +1 -1
  78. package/dist/{chunk-psdyfaf1.js → chunk-jm1f9cas.js} +2 -2
  79. package/dist/{chunk-psdyfaf1.js.map → chunk-jm1f9cas.js.map} +1 -1
  80. package/dist/{chunk-99z9d0sa.js → chunk-k107vw69.js} +2 -2
  81. package/dist/{chunk-99z9d0sa.js.map → chunk-k107vw69.js.map} +1 -1
  82. package/dist/{chunk-7dzprr9b.js → chunk-k10vbrjx.js} +3 -3
  83. package/dist/{chunk-7dzprr9b.js.map → chunk-k10vbrjx.js.map} +1 -1
  84. package/dist/{chunk-c48gag78.js → chunk-kmcnfk2s.js} +1 -1
  85. package/dist/{chunk-yffm8nxa.js → chunk-mc8mxx2a.js} +2 -2
  86. package/dist/{chunk-yffm8nxa.js.map → chunk-mc8mxx2a.js.map} +1 -1
  87. package/dist/{chunk-ewv1m1sv.js → chunk-n1t4ea9g.js} +3 -3
  88. package/dist/{chunk-ewv1m1sv.js.map → chunk-n1t4ea9g.js.map} +1 -1
  89. package/dist/{chunk-9hhxy88x.js → chunk-n4dk0dc9.js} +2 -2
  90. package/dist/{chunk-9hhxy88x.js.map → chunk-n4dk0dc9.js.map} +1 -1
  91. package/dist/{chunk-rvdsaqdv.js → chunk-nh9ewam0.js} +1 -1
  92. package/dist/{chunk-84rbdyhe.js → chunk-njaxnv6c.js} +2 -2
  93. package/dist/{chunk-84rbdyhe.js.map → chunk-njaxnv6c.js.map} +1 -1
  94. package/dist/{chunk-7nfprr9v.js → chunk-np73p641.js} +2 -2
  95. package/dist/{chunk-7nfprr9v.js.map → chunk-np73p641.js.map} +1 -1
  96. package/dist/{chunk-87jj7n9q.js → chunk-nvfhx9d1.js} +2 -2
  97. package/dist/{chunk-87jj7n9q.js.map → chunk-nvfhx9d1.js.map} +1 -1
  98. package/dist/{chunk-qmcjh6de.js → chunk-nwzsgzvy.js} +2 -2
  99. package/dist/{chunk-qmcjh6de.js.map → chunk-nwzsgzvy.js.map} +1 -1
  100. package/dist/{chunk-43faxwf5.js → chunk-p528pvmm.js} +2 -2
  101. package/dist/{chunk-43faxwf5.js.map → chunk-p528pvmm.js.map} +1 -1
  102. package/dist/{chunk-kzk5r6v4.js → chunk-peng31np.js} +3 -3
  103. package/dist/{chunk-kzk5r6v4.js.map → chunk-peng31np.js.map} +1 -1
  104. package/dist/{chunk-mj4n5mar.js → chunk-pgddb43b.js} +2 -2
  105. package/dist/{chunk-mj4n5mar.js.map → chunk-pgddb43b.js.map} +1 -1
  106. package/dist/{chunk-s2krqtwj.js → chunk-pgh7gsag.js} +2 -2
  107. package/dist/{chunk-s2krqtwj.js.map → chunk-pgh7gsag.js.map} +1 -1
  108. package/dist/chunk-pqn9j5s8.js +5 -0
  109. package/dist/{chunk-87bmhng2.js.map → chunk-pqn9j5s8.js.map} +1 -1
  110. package/dist/{chunk-m63v6aze.js → chunk-pxsq9841.js} +2 -2
  111. package/dist/{chunk-m63v6aze.js.map → chunk-pxsq9841.js.map} +1 -1
  112. package/dist/{chunk-1eb4p352.js → chunk-py1twqh8.js} +2 -2
  113. package/dist/{chunk-1eb4p352.js.map → chunk-py1twqh8.js.map} +1 -1
  114. package/dist/{chunk-nrf23yan.js → chunk-qjmcn5m5.js} +2 -2
  115. package/dist/{chunk-nrf23yan.js.map → chunk-qjmcn5m5.js.map} +1 -1
  116. package/dist/{chunk-t8kzaxaa.js → chunk-qpwb3gnh.js} +2 -2
  117. package/dist/{chunk-t8kzaxaa.js.map → chunk-qpwb3gnh.js.map} +1 -1
  118. package/dist/{chunk-c65rh4k8.js → chunk-qv8sj2z3.js} +2 -2
  119. package/dist/{chunk-c65rh4k8.js.map → chunk-qv8sj2z3.js.map} +1 -1
  120. package/dist/{chunk-mpt5jg4e.js → chunk-qz0da20r.js} +2 -2
  121. package/dist/{chunk-mpt5jg4e.js.map → chunk-qz0da20r.js.map} +1 -1
  122. package/dist/{chunk-v1eeh7a7.js → chunk-sh39q44t.js} +3 -3
  123. package/dist/{chunk-v1eeh7a7.js.map → chunk-sh39q44t.js.map} +1 -1
  124. package/dist/{chunk-b2pdqxj3.js → chunk-t7gvgz20.js} +3 -3
  125. package/dist/{chunk-b2pdqxj3.js.map → chunk-t7gvgz20.js.map} +1 -1
  126. package/dist/{chunk-ravssmdy.js → chunk-tchte4dv.js} +2 -2
  127. package/dist/{chunk-ravssmdy.js.map → chunk-tchte4dv.js.map} +1 -1
  128. package/dist/{chunk-gv59djt3.js → chunk-tn3y2qkj.js} +2 -2
  129. package/dist/{chunk-gv59djt3.js.map → chunk-tn3y2qkj.js.map} +1 -1
  130. package/dist/{chunk-9x0pgkns.js → chunk-ty5sp1ym.js} +2 -2
  131. package/dist/{chunk-9x0pgkns.js.map → chunk-ty5sp1ym.js.map} +1 -1
  132. package/dist/{chunk-8df7fn7f.js → chunk-v09w6pr2.js} +3 -3
  133. package/dist/{chunk-8df7fn7f.js.map → chunk-v09w6pr2.js.map} +1 -1
  134. package/dist/{chunk-s0kns9q1.js → chunk-vc5kpxdk.js} +3 -3
  135. package/dist/{chunk-s0kns9q1.js.map → chunk-vc5kpxdk.js.map} +1 -1
  136. package/dist/{chunk-1gd1ykgj.js → chunk-vjpby5sf.js} +3 -3
  137. package/dist/{chunk-1gd1ykgj.js.map → chunk-vjpby5sf.js.map} +1 -1
  138. package/dist/{chunk-p7abyc0b.js → chunk-wf3qe12c.js} +2 -2
  139. package/dist/{chunk-p7abyc0b.js.map → chunk-wf3qe12c.js.map} +1 -1
  140. package/dist/{chunk-094m8mj3.js → chunk-wn437678.js} +2 -2
  141. package/dist/{chunk-094m8mj3.js.map → chunk-wn437678.js.map} +1 -1
  142. package/dist/{chunk-rtb64x14.js → chunk-wv3nnq8c.js} +3 -3
  143. package/dist/{chunk-rtb64x14.js.map → chunk-wv3nnq8c.js.map} +1 -1
  144. package/dist/{chunk-wat33wxh.js → chunk-ww86zqbw.js} +2 -2
  145. package/dist/{chunk-wat33wxh.js.map → chunk-ww86zqbw.js.map} +1 -1
  146. package/dist/chunk-wzfvwvz0.js +10 -0
  147. package/dist/{chunk-zbvdkh6q.js.map → chunk-wzfvwvz0.js.map} +5 -4
  148. package/dist/{chunk-ebdkmzm9.js → chunk-x92g4x4w.js} +2 -2
  149. package/dist/{chunk-ebdkmzm9.js.map → chunk-x92g4x4w.js.map} +1 -1
  150. package/dist/{chunk-qy3s6pwz.js → chunk-xhm5wgfe.js} +2 -2
  151. package/dist/{chunk-qy3s6pwz.js.map → chunk-xhm5wgfe.js.map} +1 -1
  152. package/dist/{chunk-89swy5aq.js → chunk-xtnbcbkf.js} +2 -2
  153. package/dist/{chunk-89swy5aq.js.map → chunk-xtnbcbkf.js.map} +1 -1
  154. package/dist/chunks/{ThemeProvider-CS2a1snV.js → ThemeProvider-BIrCSrFY.js} +2 -2
  155. package/dist/chunks/{ThemeProvider-CS2a1snV.js.map → ThemeProvider-BIrCSrFY.js.map} +1 -1
  156. package/dist/client/fetchFile.d.ts +66 -0
  157. package/dist/client/fetchFile.d.ts.map +1 -0
  158. package/dist/client/index.d.ts +3 -1
  159. package/dist/client/index.d.ts.map +1 -1
  160. package/dist/client/index.js +75 -2
  161. package/dist/client/index.js.map +1 -1
  162. package/dist/client/rpc.d.ts +11 -0
  163. package/dist/client/rpc.d.ts.map +1 -1
  164. package/dist/config/index.js +1 -1
  165. package/dist/console/run.js +2 -2
  166. package/dist/console/run.js.map +1 -1
  167. package/dist/container/index.js +2 -2
  168. package/dist/container/index.js.map +1 -1
  169. package/dist/database/index.js +2 -2
  170. package/dist/database/index.js.map +1 -1
  171. package/dist/email/index.js +2 -2
  172. package/dist/email/index.js.map +1 -1
  173. package/dist/facades/Runs.d.ts +64 -0
  174. package/dist/facades/Runs.d.ts.map +1 -0
  175. package/dist/facades/index.d.ts +1 -0
  176. package/dist/facades/index.d.ts.map +1 -1
  177. package/dist/facades/index.js +2 -2
  178. package/dist/facades/index.js.map +1 -1
  179. package/dist/foundation/index.js +2 -2
  180. package/dist/foundation/index.js.map +1 -1
  181. package/dist/gemi.d.ts +4 -0
  182. package/dist/http/ApiRouter.d.ts +40 -3
  183. package/dist/http/ApiRouter.d.ts.map +1 -1
  184. package/dist/http/index.d.ts +1 -1
  185. package/dist/http/index.d.ts.map +1 -1
  186. package/dist/http/index.js +2 -2
  187. package/dist/http/index.js.map +1 -1
  188. package/dist/i18n/dictionaryRuntime.js +2 -2
  189. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  190. package/dist/i18n/index.js +2 -2
  191. package/dist/i18n/index.js.map +1 -1
  192. package/dist/kernel/index.js +3 -3
  193. package/dist/kernel/index.js.map +3 -3
  194. package/dist/kernel/providers.d.ts.map +1 -1
  195. package/dist/orm/index.js +2 -2
  196. package/dist/orm/index.js.map +1 -1
  197. package/dist/server/index.js +2 -2
  198. package/dist/server/index.js.map +1 -1
  199. package/dist/services/index.d.ts +5 -0
  200. package/dist/services/index.d.ts.map +1 -1
  201. package/dist/services/index.js +3 -3
  202. package/dist/services/index.js.map +2 -2
  203. package/dist/services/queue/work.js +2 -2
  204. package/dist/services/queue/work.js.map +1 -1
  205. package/dist/services/runs/DatabaseRunStore.d.ts +62 -0
  206. package/dist/services/runs/DatabaseRunStore.d.ts.map +1 -0
  207. package/dist/services/runs/RunManager.d.ts +200 -0
  208. package/dist/services/runs/RunManager.d.ts.map +1 -0
  209. package/dist/services/runs/RunStore.d.ts +163 -0
  210. package/dist/services/runs/RunStore.d.ts.map +1 -0
  211. package/dist/services/runs/RunsServiceProvider.d.ts +5 -0
  212. package/dist/services/runs/RunsServiceProvider.d.ts.map +1 -0
  213. package/dist/services/runs/config.d.ts +20 -0
  214. package/dist/services/runs/config.d.ts.map +1 -0
  215. package/dist/stats/route-table.js +1 -1
  216. package/dist/support/index.js +2 -2
  217. package/dist/support/index.js.map +1 -1
  218. package/dist/testing/index.js +1 -1
  219. package/dist/vitest/index.js +1 -1
  220. package/package.json +1 -1
  221. package/skills/gemi-react-best-practices/rules/query-no-hand-rolled-fetch.md +14 -0
  222. package/dist/chunk-87bmhng2.js +0 -5
  223. package/dist/chunk-cwpezdpw.js +0 -57
  224. package/dist/chunk-zbvdkh6q.js +0 -10
  225. /package/dist/{chunk-bghxdjqv.js.map → chunk-03wc6em7.js.map} +0 -0
  226. /package/dist/{chunk-p0ccxfkq.js.map → chunk-43vjbd6n.js.map} +0 -0
  227. /package/dist/{chunk-k6gvbvyw.js.map → chunk-5nkvpc0a.js.map} +0 -0
  228. /package/dist/{chunk-3fyhd641.js.map → chunk-h55c9bdf.js.map} +0 -0
  229. /package/dist/{chunk-c48gag78.js.map → chunk-kmcnfk2s.js.map} +0 -0
  230. /package/dist/{chunk-rvdsaqdv.js.map → chunk-nh9ewam0.js.map} +0 -0
package/dist/ai/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{$b as q,Ac as BQ,Bc as S9,Cc as M9,Dc as A9,Ec as R9,Fc as T9,Gc as j9,Hc as k9,Ic as E9,Jc as q9,Kc as x9,Lc as w9,Mc as QQ,Nc as I9,Oc as h$,Pc as b9,Qc as v9,Rc as QJ,Sc as jJ,Tc as f9,Uc as h9,Vc as y9,Wb as HQ,Wc as g9,Xb as q$,Xc as u9,Yb as DQ,Yc as c9,ac as p,bc as TJ,cc as zQ,dc as x$,ec as w$,fc as I$,gc as b,hc as b$,ic as LJ,jc as v$,kc as f$,lc as CJ,mc as MQ,nc as AQ,pc as RQ,qc as w,rc as H$,sc as D$,tc as TQ,vc as jQ,wc as h,xc as IQ,yc as g,zc as R}from"../chunk-s0kns9q1.js";import{od as PQ}from"../chunk-t8kzaxaa.js";import"../chunk-b2pdqxj3.js";import{Vg as R$,Vh as k$,Yg as j$,Yh as rJ,ai as E$,mh as C9,nh as O9,oh as _9,ph as d}from"../chunk-dm7mada7.js";import{bi as T$,di as FJ,ei as NJ}from"../chunk-7eerqsg2.js";import{ni as n}from"../chunk-15bmfr7f.js";import"../chunk-0arss2xy.js";import"../chunk-nv2t87c3.js";import{Fj as SQ,qj as OQ,rj as _Q}from"../chunk-kzk5r6v4.js";import"../chunk-v7nw1g2n.js";import{sk as J$}from"../chunk-yg8se4vs.js";import"../chunk-84rbdyhe.js";import"../chunk-7nfprr9v.js";import"../chunk-9x0pgkns.js";import"../chunk-89swy5aq.js";class _J extends PQ{name="AgentJobDeadlineSweep";cron="* * * * *";async callback(){while(await w.sweep({limit:100})===100);}}var r=20;function NQ(J,Q){if(Q<=0||J.length===0)return null;let $=(G,V)=>V.createdAt-G.createdAt||(G.id<V.id?1:-1);return["<jobs>","Background jobs that tools started in this conversation, running ones first. A running job's result replaces its tool result when it finishes. Do not start the same work again while a job for it is running.",...[...J.filter((G)=>G.state==="running").sort($),...J.filter((G)=>G.state!=="running").sort($)].slice(0,Q).map((G)=>{let V=[`- ${G.id} (${G.toolName})`];if(G.state==="running")V.push(`running since ${SJ(G.createdAt)}`);else if(G.state==="ok")V.push(`finished at ${SJ(G.settledAt??G.updatedAt)}`);else{let K=G.error?`${G.error.code}: ${FQ(G.error.message,200)}`:"failed";V.push(`failed at ${SJ(G.settledAt??G.updatedAt)} (${K})`)}if(G.summary!==void 0)V.push(`summary: ${FQ(JSON.stringify(G.summary),300)}`);if(G.orphaned)V.push("its tool call was lost when the turn that started it was cut short");return V.join("; ")}),"</jobs>"].join(`
2
+ import{Ac as R,Bc as BQ,Cc as S9,Dc as M9,Ec as A9,Fc as R9,Gc as T9,Hc as j9,Ic as k9,Jc as E9,Kc as q9,Lc as x9,Mc as w9,Nc as QQ,Oc as I9,Pc as h$,Qc as b9,Rc as v9,Sc as QJ,Tc as jJ,Uc as f9,Vc as h9,Wc as y9,Xb as HQ,Xc as g9,Yb as q$,Yc as u9,Zb as DQ,Zc as c9,ac as q,bc as p,cc as TJ,dc as zQ,ec as x$,fc as w$,gc as I$,hc as b,ic as b$,jc as LJ,kc as v$,lc as f$,mc as CJ,nc as MQ,oc as AQ,qc as RQ,rc as w,sc as H$,tc as D$,uc as TQ,wc as jQ,xc as h,yc as IQ,zc as g}from"../chunk-vc5kpxdk.js";import{pd as PQ}from"../chunk-qpwb3gnh.js";import"../chunk-t7gvgz20.js";import{Ah as _9,Bh as d,fh as R$,fi as k$,ih as j$,ii as rJ,mi as E$,yh as C9,zh as O9}from"../chunk-2bmk0fzm.js";import{ni as T$,pi as FJ,qi as NJ}from"../chunk-fezaxj28.js";import{zi as n}from"../chunk-gzaaspe7.js";import"../chunk-2z1gd231.js";import"../chunk-4yp84g2y.js";import{Cj as OQ,Dj as _Q,Rj as SQ}from"../chunk-peng31np.js";import"../chunk-1yttk239.js";import{Ek as J$}from"../chunk-cp84b0ev.js";import"../chunk-njaxnv6c.js";import"../chunk-np73p641.js";import"../chunk-ty5sp1ym.js";import"../chunk-xtnbcbkf.js";class _J extends PQ{name="AgentJobDeadlineSweep";cron="* * * * *";async callback(){while(await w.sweep({limit:100})===100);}}var r=20;function NQ(J,Q){if(Q<=0||J.length===0)return null;let $=(G,V)=>V.createdAt-G.createdAt||(G.id<V.id?1:-1);return["<jobs>","Background jobs that tools started in this conversation, running ones first. A running job's result replaces its tool result when it finishes. Do not start the same work again while a job for it is running.",...[...J.filter((G)=>G.state==="running").sort($),...J.filter((G)=>G.state!=="running").sort($)].slice(0,Q).map((G)=>{let V=[`- ${G.id} (${G.toolName})`];if(G.state==="running")V.push(`running since ${SJ(G.createdAt)}`);else if(G.state==="ok")V.push(`finished at ${SJ(G.settledAt??G.updatedAt)}`);else{let K=G.error?`${G.error.code}: ${FQ(G.error.message,200)}`:"failed";V.push(`failed at ${SJ(G.settledAt??G.updatedAt)} (${K})`)}if(G.summary!==void 0)V.push(`summary: ${FQ(JSON.stringify(G.summary),300)}`);if(G.orphaned)V.push("its tool call was lost when the turn that started it was cut short");return V.join("; ")}),"</jobs>"].join(`
3
3
  `)}function SJ(J){return new Date(J).toISOString().replace(/\.\d{3}Z$/,"Z")}function FQ(J,Q){return J.length<=Q?J:`${J.slice(0,Q-1)}\u2026`}class AJ{table;sql;dialect;connection;constructor(J,Q={}){let $=Q.table??"gemi_agent_jobs";if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test($))throw Error(`The agent jobs table name "${$}" is not a plain identifier. Use letters, digits and underscores.`);this.table=$,this.sql=J.sql,this.dialect=J.dialect,this.connection=J.name}async createTable(){for(let J of p$(this.dialect,this.table))await this.sql.unsafe(J)}async transaction(J){if(this.connection===void 0||this.joinable())return J();return SQ(this.sql,()=>J(),{connection:this.connection})}async create(J){let Q=this.q(),$=this.clock(Q);await Q`
4
4
  INSERT INTO ${this.name(Q)}
5
5
  (id, thread_id, run_id, tool_call_id, tool_name, owner, job, summary, state,
@@ -85,4 +85,4 @@ return 0`;class JQ{injectedClient;prefix;constructor(J={}){this.injectedClient=J
85
85
 
86
86
  `)||void 0,_=await this.context(J,{body:Y}),O=await this.attachmentsFor(J,Z,{body:Y});if(H?.cancelled)return S$();let M=Z?new WQ(this.store,Z,U,(S)=>this.reportHookFailure(S)):null,T=`run_${crypto.randomUUID()}`,k={req:J,runId:T,threadId:Z},x={id:null,notified:Promise.resolve()},E=this.agent.stream({runId:T,messages:U,turn:G,threadId:Z,...M?{onMessage:(S)=>M.finish(S)}:{},onTurn:(S)=>{if(x.id!==null)return;x.id=S.id;let f=M?M.settled():Promise.resolve();x.notified=f.then(()=>this.safely(()=>this.onMessage(S,k)))},instructions:P,context:_,attachments:O,body:Y,redactError:(S,f)=>this.redactError(S,f,k),nonces:this.nonces,receipts:this.receipts,subject:X,...Z?{jobs:{owner:X}}:{},...this.contextWindow!==void 0?{contextWindow:this.contextWindow}:{},...Z&&h$(this.store)?{summaryStore:this.store}:{},...this.prepareStep!==UQ.prototype.prepareStep?{prepareStep:(S)=>this.prepareStep(S,k)}:{}}),C=this.liveRuns.register(E,{threadId:Z,owner:X,clientRunId:K,onEvent:(S)=>this.dispatchEvent(S,k),onInternalError:(S)=>this.reportHookFailure(S),maxRunDurationMs:this.agent.maxRunDurationMs});if(B=E,M)this.follow(E,M);let{stored:A,hooks:L}=this.persistRun(E,k,C,M,x);if(U$.set(E,A),t.has(J))t.set(J,{run:E,hooks:L});return J.ctx?.()?.waitUntil(L),E.toResponse()};try{await this.authorizeRequest(J,{route:"stream",threadId:Z,body:Y});let U=await this.foreignFile([...G?.files??[],...Z?[]:z9($.messages)],X);if(U)return U;if(H?.cancelled)return S$();let N=await this.runLimitKey(J,{owner:X,threadId:Z}),P=N===null?PJ:r3(this.liveRuns).take(N,Z?`thread:${Z}`:`run:${crypto.randomUUID()}`,this.maxConcurrentRuns);if(!P)return YQ(429,"too_many_runs",`You already have ${this.maxConcurrentRuns} conversations answering. Wait for one to finish, or stop it, and send again.`);try{return Z?await this.withThread(Z,X,z):await z()}finally{let _=B;if(_)_.result().then(P,P);else P()}}finally{if(H&&zJ.get(K)===H)zJ.delete(K)}}async withThread(J,Q,$){let Z=DJ.get(J)??Promise.resolve(),W,G=new Promise((K)=>{W=K}),V=Z.then(()=>G);DJ.set(J,V),await Z;try{let K=await this.liveRuns.find({threadId:J});if(K&&this.liveRuns.isRunning(K.runId)&&!this.liveRuns.mayAccess(K.runId,Q))return UJ();let Y=K?this.liveRuns.get(K.runId):null;if(Y)Y.stop({reason:"superseded by a later turn on this thread"}),await U$.get(Y);return await $()}finally{if(W(),DJ.get(J)===V)DJ.delete(J)}}async attach(J=new d){let Q=await GQ(J,F$);if(Q.error)return BJ(Q);let $=Q.body,Z=typeof $.threadId==="string"?$.threadId:Y9(J,"threadId");if(!Z)return j(400,{code:"invalid_request",message:"attach needs a threadId: it is the handle that survives a refresh."});await this.authorizeRequest(J,{route:"attach",threadId:Z});let W=await this.liveRuns.find({threadId:Z});if(W&&!this.liveRuns.mayAccess(W.runId,await this.runOwner(J)))return UJ();if(!W)return j(404,{code:"no_live_run",message:`No run in progress for thread ${Z} in this process.`});let G=typeof $.runId==="string"?$.runId:void 0,V=G&&G!==W.runId?void 0:X9(J,$);try{return E$(this.liveRuns.replay(W.runId,V))}catch(K){if(K instanceof l)return j(410,{code:K.code,message:K.message,oldestSeq:K.oldest});if(K instanceof a)return j(404,{code:K.code,message:K.message});throw K}}async stop(J=new d){let Q=await GQ(J,F$);if(Q.error)return BJ(Q);let $=Q.body;await this.authorizeRequest(J,{route:"stop",threadId:typeof $.threadId==="string"?$.threadId:void 0});let Z=await this.runOwner(J),W=typeof $.runId==="string"?$.runId:void 0;if(!W&&typeof $.clientRunId==="string"){if(W=this.liveRuns.findByClientRunId($.clientRunId)??void 0,!W){let V=zJ.get($.clientRunId);if(V){if(V.owner!==null&&V.owner!==Z)return UJ();return V.cancelled=!0,{stopped:!0}}}}if(!W&&typeof $.threadId==="string")W=(await this.liveRuns.find({threadId:$.threadId}))?.runId;let G=W?this.liveRuns.get(W):null;if(!G)return{stopped:!1};if(!this.liveRuns.mayAccess(G.runId,Z))return UJ();return G.stop({reason:typeof $.reason==="string"?$.reason:void 0}),{stopped:!0}}attachmentScope(J,Q,$){let Z=J.ctx()?.user,W=Z?.id??Z?.publicId;if(W!==void 0&&W!==null&&String(W)!=="")return{key:`user:${String(W)}`};if(Q)return{key:`thread:${Q}`};return null}attachmentLimits(J){return null}checkUpload(J,Q,$){}attachmentDestination(J,Q,$){return"both"}async attachmentsFor(J,Q,$={body:{}}){let Z=await this.attachmentScope(J,Q,$);if(!Z)return null;return new LJ(this.attachments,this.attachmentStorage,Z)}async upload(J=new d){let Q=await J.rawRequest.formData(),$=Q.get("file");if(!($ instanceof Blob))throw Error("upload expects a multipart body with a `file` field.");let Z=$ instanceof File&&$.name?$.name:"upload",W=$.type||"application/octet-stream",G=J9(Q.get("body")),V=Q.get("threadId");await this.authorizeRequest(J,{route:"upload",threadId:typeof V==="string"&&V.length>0?V:void 0,body:G});let K=$9(await this.attachmentLimits(J),$,Z,W);if(K)throw new XQ(K.code,K.message);let Y=typeof V==="string"&&V.length>0&&await this.store.loadThread(V)!==null?V:void 0,X=await this.runOwner(J),H=(T)=>this.fileOwners.record(T,{owner:X,name:Z,mimeType:W,size:$.size,createdAt:new Date().toISOString()}),B={body:G,threadId:Y},D=await this.checkUpload({name:Z,size:$.size,mimeType:W},J,B);if(D)throw new XQ(D.code||"upload_refused",D.message);let z=await this.attachmentDestination($,J,B),F=B9(z,Q.get("destination")),U=await this.attachmentScope(J,Y,{body:G}),N=F!=="provider"&&!U;if(N){if(F==="storage")throw Error('This upload was routed to storage, but `attachmentScope()` returned null for the request, so there is no subject to file the attachment under. Guard the route (`this.agent(Chat).middleware({ upload: "auth" })`), send a `threadId` with the upload, or override `attachmentScope()`.');U9()}if(F==="provider"||!U){let T=await L$(this.agent.provider,$);await H(T);let k={fileId:T,name:Z,mimeType:W,size:$.size,destination:"provider"};if(N)k.downgraded="no_scope";return k}let P=b$(),_=await this.attachmentStorage.put({name:v$(P,Z),body:$,contentType:W}),O=F==="both"?await L$(this.agent.provider,$):void 0;if(O)await H(O);let M={id:P,scopeKey:U.key,fileId:O,objectName:_,name:Z,mimeType:W,size:$.size,createdAt:new Date().toISOString(),destination:F};return await this.attachments.put(U,M),{fileId:O,attachmentId:P,name:Z,mimeType:W,size:$.size,destination:F}}async foreignFile(J,Q){let $=new Set(J.map((Z)=>Z.fileId).filter((Z)=>typeof Z==="string"));for(let Z of $){let W=await this.fileOwners.get(Z);if(W?W.owner!==null&&W.owner!==Q:this.requireKnownFiles)return D9()}return null}onMessage(J,Q){}onToolCall(J,Q){}onAwaitingInput(J,Q){}redactError(J,Q,$){return zQ(J,Q)}onError(J,Q){}onStreamComplete(J,Q){}reportHookFailure(J){console.error("[gemi/ai] agent controller hook failed",J)}async dispatchEvent(J,Q){switch(J.type){case"tool-call":if(!J.part.partial&&!J.resent)await this.onToolCall({toolCallId:J.part.toolCallId,name:String(J.part.name),input:J.part.input},Q);return;case"awaiting-input":await this.onAwaitingInput(J.pending,Q);return;case"error":await this.onError(x$(J.error),Q);return;default:return}}async readThread(J){let Q=await this.store.loadThread(J);return Q?(await this.settleThread(J,Q,{write:!1})).messages:null}isRunLive(J,Q){return this.liveRuns.get(J)!==null}async settleThread(J,Q,{write:$}){let Z=(Y)=>this.isRunLive(Y,J),W=await X$(Q,Z),G=W.messages,V=[],K=new Map(W.settled.map((Y)=>[Y.id,Y]));if(L9(G)||$)try{let Y=await z$(G,{threadId:J,store:w.store,isRunLive:Z,outputSchemaFor:(X)=>this.toolOutputSchema(X),scan:this.jobsBlockMax()});G=Y.messages,V=Y.jobs;for(let X of Y.settled)K.set(X.id,X);if($&&Y.orphans.length>0){await B$(w.store,Y.orphans,(H)=>this.reportHookFailure(H));let X=new Set(Y.orphans.map((H)=>H.id));V=V.map((H)=>X.has(H.id)?{...H,orphaned:!0}:H)}}catch(Y){this.reportHookFailure(Y)}if($&&K.size>0)try{await this.store.appendMessages(J,[...K.values()])}catch(Y){this.reportHookFailure(Y)}return{messages:G,jobs:V}}jobsBlockMax(){let J=this.agent.jobs?.contextBlock;if(J===!1)return 0;return J?.max??r}jobsBlock(J){return NQ(J,this.jobsBlockMax())}toolOutputSchema(J){let Q=($)=>{for(let Z of $){let W=Z;if(Array.isArray(W.tools)){let G=Q(W.tools);if(G)return G}else if(W.name===J)return W.outputSchema}return};return Q(this.agent.tools??[])}follow(J,Q){(async()=>{try{for await(let $ of J.frames())Q.frame($)}catch($){this.reportHookFailure($)}})()}persistRun(J,Q,$,Z=null,W={id:null,notified:Promise.resolve()}){let G=Promise.resolve(),V=(async()=>{let Y;try{Y=await J.result()}catch(H){Z?.close(),await Z?.settled(),G=W.notified.then(()=>this.safely(()=>this.onError({code:"unknown",message:H instanceof Error?H.message:String(H),retryable:!1},Q)));return}let X=Y.messages;if(Z?.close(X),await Z?.settled(),Q.threadId&&X.length>0)try{await this.store.appendMessages(Q.threadId,X)}catch(H){this.reportHookFailure(H)}G=this.notifyRun(Y,X,Q,W)})(),K=V.then(()=>F9(Promise.all([G,$]).then(()=>{}),this.hookHoldMs));return{stored:V,hooks:K}}async notifyRun(J,Q,$,Z){await Z.notified;for(let W of Q){if(W.id===Z.id)continue;await this.safely(()=>this.onMessage(W,$))}await this.safely(()=>this.onStreamComplete(J,$))}async safely(J){try{await J()}catch(Q){this.reportHookFailure(Q)}}}var VQ=["turn","clientRunId","threadId","messages","regenerate"],e3=["text","files","toolResults"];function g$(J,Q=c$(J)?VQ:[...VQ,...e3]){let $={};for(let[Z,W]of Object.entries(J)){if(Q.includes(Z))continue;Object.defineProperty($,Z,{value:W,writable:!0,enumerable:!0,configurable:!0})}return $}function J9(J){if(J===null)return{};let Q;if(typeof J==="string")try{Q=JSON.parse(J)}catch{throw new KQ("The upload's `body` field is not valid JSON.")}if(Q===null||typeof Q!=="object"||Array.isArray(Q))throw new KQ("The upload's `body` field must be a JSON object.");return g$(Q,VQ)}class KQ extends FJ{constructor(J){super(J);this.name="InvalidUploadError",this.payload={api:{status:400,data:{error:{code:"invalid_request",message:J}}},view:{}}}}async function L$(J,Q){try{return await J.upload(Q)}catch($){if($ instanceof h&&Q9.has($.status))throw new u$(R($).message);throw $}}var Q9=new Set([400,413,415,422]);class XQ extends FJ{constructor(J,Q){super(Q);this.name="LimitedUploadError",this.payload={api:{status:422,data:{error:{code:J,message:Q}}},view:{}}}}function $9(J,Q,$,Z){if(!J)return null;let{maxBytes:W,accept:G}=J;if(typeof W==="number"&&Q.size>W)return{code:"file_too_large",message:`${JSON.stringify($)} is ${C$(Q.size)}; the limit is ${C$(W)}.`};if(G&&G.length>0&&!G.some((V)=>Z9(V,$,Z)))return{code:"unsupported_file_type",message:`${JSON.stringify($)} is not a type this chat accepts. Accepted: ${G.join(", ")}.`};return null}function Z9(J,Q,$){let Z=J.trim().toLowerCase();if(!Z)return!1;if(Z.startsWith("."))return Q.toLowerCase().endsWith(Z);let W=$.toLowerCase().split(";")[0].trim();if(Z.endsWith("/*"))return W.startsWith(Z.slice(0,-1));return W===Z}function C$(J){if(J<1024)return`${J} B`;let Q=["KB","MB","GB"],$=J/1024,Z=0;while($>=1024&&Z<Q.length-1)$/=1024,Z++;return`${Math.round($*10)/10} ${Q[Z]}`}class u$ extends FJ{constructor(J){super(J);this.name="RejectedUploadError";let Q=/(unsupported|invalid) (extension|file type|format|mime)|supported (extensions|formats?)/i.test(J)?"unsupported_file_type":"file_rejected";this.payload={api:{status:422,data:{error:{code:Q,message:J}}},view:{}}}}async function GQ(J,Q){let $=J?.rawRequest;if(!$||$.method==="GET"||$.method==="HEAD"||!$.body)return{body:{}};if(!W9($.headers.get("Content-Type")))return{body:{},status:415,code:"unsupported_media_type",error:"The request body must be sent as application/json."};let Z=Number($.headers.get("Content-Length"));if(Number.isFinite(Z)&&Z>Q)return O$(Q);let W;try{let V=await G9($,Q);if(V===null)return O$(Q);W=V}catch{return{body:{},error:"The request body could not be read."}}if(!W.trim())return{body:{}};let G;try{G=JSON.parse(W)}catch{return{body:{},error:"The request body is not valid JSON."}}if(G===null||typeof G!=="object"||Array.isArray(G))return{body:{},error:"The request body must be a JSON object."};return{body:G}}function W9(J){return j$(J)==="application/json"}async function G9(J,Q){if(!Number.isFinite(Q)||!J.body)return await J.text();let $=J.body.getReader(),Z=[],W=0;for(;;){let{done:K,value:Y}=await $.read();if(K)break;if(W+=Y.byteLength,W>Q)return await $.cancel().catch(PJ),null;Z.push(Y)}let G=new Uint8Array(W),V=0;for(let K of Z)G.set(K,V),V+=K.byteLength;return new TextDecoder().decode(G)}function O$(J){return{body:{},status:413,code:"body_too_large",error:`The request body is larger than this agent accepts (${J} bytes).`}}function YQ(J,Q,$){return j(J,{...NJ(T$(J),$,J),code:Q})}function BJ(J){if(J.status===413)return YQ(413,J.code??"body_too_large",J.error??"");return j(J.status??400,{code:J.code??"invalid_request",message:J.error})}function c$(J){return Boolean(J.turn)&&typeof J.turn==="object"}function V9(J){let Q=c$(J)?J.turn:J,$={};if(typeof Q.text==="string")$.text=Q.text;if(Array.isArray(Q.files)){let Z=K9(Q.files);if(typeof Z==="string")return{error:Z};$.files=Z}if(Array.isArray(Q.toolResults))$.toolResults=Q.toolResults;if(Object.keys($).length===0)return{};if(Q===J.turn&&Q.localId!==void 0&&Q.localId!==null&&Q.localId!==""){let{localId:Z}=Q;if(typeof Z!=="string")return{error:"turn.localId must be a string."};if(Z.length>_$)return{error:`turn.localId is longer than ${_$} characters.`};$.localId=Z}return{turn:$}}var _$=200;function K9(J){let Q=[];for(let[$,Z]of J.entries()){let W=`turn.files[${$}]`;if(!Z||typeof Z!=="object"||Array.isArray(Z))return`${W} must be an object.`;let G={};for(let H of["fileId","attachmentId","name","mimeType"]){let B=Z[H];if(B===void 0||B===null||B==="")continue;if(typeof B!=="string")return`${W}.${H} must be a string.`;G[H]=B}let{fileId:V,attachmentId:K,name:Y,mimeType:X}=G;if(V?.startsWith(b))return`${W}.fileId holds a gemi attachment id (${V}). \`fileId\` is the provider's id from the upload response; put this one in \`attachmentId\`.`;if(K!==void 0&&!K.startsWith(b))return`${W}.attachmentId is not a gemi attachment id: it must start with "${b}".`;if(!V&&!K)return`${W} has neither a \`fileId\` nor an \`attachmentId\`. Send the ids the upload response answered.`;Q.push({...V?{fileId:V}:{},...K?{attachmentId:K}:{},...Y!==void 0?{name:Y}:{},...X!==void 0?{mimeType:X}:{}})}return Q}function X9(J,Q){if(typeof Q.from==="number"&&Number.isFinite(Q.from))return Math.max(0,Math.floor(Q.from));if(typeof Q.cursor==="number"&&Number.isFinite(Q.cursor)){let Z=Math.floor(Q.cursor);if(Z>=0)return Z+1;return}let $=J?.rawRequest?.headers?.get("Last-Event-ID");if($){let Z=Number.parseInt($,10);if(Number.isFinite(Z))return Math.max(0,Z+1)}return}function Y9(J,Q){let $=J?.search?.get(Q);return typeof $==="string"?$:void 0}function H9(J){let Q=BQ(J);for(let $=J.length-1;$>=0;$--){let Z=J[$];if(Z.role!=="user"||Q.has(Z.id))continue;let W="",G=[];for(let V of Z.content){if(V.type==="text")W+=V.text;if(V.type==="file")G.push({...V.fileId?{fileId:V.fileId}:{},...V.attachmentId?{attachmentId:V.attachmentId}:{},...V.name?{name:V.name}:{},...V.mimeType?{mimeType:V.mimeType}:{}})}if(!W&&G.length===0)continue;return{index:$,turn:{...W?{text:W}:{},...G.length>0?{files:G}:{}}}}return null}function S$(){return j(409,{code:"stopped",message:"The turn was stopped before it started."})}function UJ(){return j(403,NJ("permission","This run belongs to someone else.",403))}function D9(){return j(403,NJ("permission","A file in this turn was uploaded by someone else.",403))}function z9(J){if(!Array.isArray(J))return[];let Q=[];for(let $ of J){let Z=$?.content;if(!Array.isArray(Z))continue;for(let W of Z)if(W&&typeof W==="object"&&typeof W.fileId==="string")Q.push({fileId:W.fileId})}return Q}function j(J,Q){return new Response(JSON.stringify({error:Q}),{status:J,headers:{"Content-Type":"application/json"}})}function B9(J,Q){if(typeof Q!=="string"||Q.length===0)return J;if(Q!=="both"&&Q!=="provider"&&Q!=="storage")throw Error(`Unknown attachment destination "${Q}". Expected "both", "provider" or "storage".`);if(Q===J||J==="both"&&Q==="storage")return Q;if(J==="both"&&Q==="provider")throw Error('This upload asked for the "provider" destination under a "both" policy. A client may ask for "storage", which keeps a file away from the model provider, but it may not ask the server to stop keeping its own copy while the vendor still gets the file \u2014 that is the app\'s retention decision. Change `attachmentDestination()` if this file should not be kept.');throw Error(`This upload asked for the "${Q}" destination, but the server's policy for it is "${J}", and a client hint may only ask for "storage" under a "both" policy. Change \`attachmentDestination()\` if the file really should go there.`)}var M$=!1;function U9(){if(M$)return;M$=!0,console.warn("[gemi/ai] An upload had no attachment scope, so its bytes were sent to the model provider only and no attachment id was minted \u2014 a tool cannot forward this file. Guard the route with auth, send a `threadId` with the upload, or override `attachmentScope()`.")}var P9=2147483647;function F9(J,Q){let $=J.then(()=>{},()=>{});if(!(Q<=P9))return $;let Z,W=new Promise((G)=>{Z=setTimeout(G,Q)});return Promise.race([$,W]).finally(()=>clearTimeout(Z))}var A$=!1;function N9(J){if(A$||Bun.env.NODE_ENV!=="production")return;if(!(J instanceof HQ))return;A$=!0,console.warn("[gemi/ai] A stateless agent chat is spending approval nonces in process memory. With more than one instance a replayed approval is accepted once per instance. Set `nonces = new RedisNonceStore()` (or your own NonceStore) on the AgentController.")}function L9(J){return J.some((Q)=>Q.content.some(($)=>$.type==="tool-result"&&$.status==="running"))}export{j9 as windowMessages,S9 as turnStarts,d$ as toAgentTools,_9 as supportsStrict,M9 as splitTurns,b9 as settleSummaries,O9 as s,zQ as redactError,A9 as messageSize,sJ as liveRuns,QQ as keepSummary,BQ as injectedMessageIds,c9 as generate,x3 as evalChain,I9 as defaultSummaryStore,DQ as defaultNonceStore,aJ as defaultFileOwners,CJ as defaultAttachmentStore,$Q as defaultAgentStore,jJ as ToolNamespace,TJ as ToolError,f9 as Skill,LJ as ScopedAttachments,h9 as SKILLS_NAMESPACE,JQ as RedisReceiptStore,q$ as RedisNonceStore,v9 as PendingEscalation,lJ as OpenAIProvider,xJ as OpenAIImageProvider,w9 as MemorySummaryStore,eJ as MemoryReceiptStore,HQ as MemoryNonceStore,XJ as MemoryLiveRuns,YJ as MemoryFileOwners,KJ as MemoryCircuitStore,f$ as MemoryAttachmentStore,HJ as MemoryAgentStore,MQ as MemoryAgentJobStore,a as LiveRunNotFoundError,RQ as JobsRequireThreadError,AQ as JobHandle,C9 as JSONSchemaError,I$ as InvalidAttachmentScopeError,WJ as ImageRequestError,GJ as ImageProvider,kJ as ImageModel,l as FrameCursorEvictedError,s as FallbackProvider,AJ as DatabaseAgentJobStore,k9 as DEFAULT_MAX_SUMMARY_TOKENS,y9 as DEFAULT_MAX_RUN_DURATION_MS,TQ as DEFAULT_JOB_DEADLINE_MS,r as DEFAULT_JOBS_CONTEXT_MAX,R9 as DEFAULT_CONTEXT_WINDOW_STEP,T9 as DEFAULT_CONTEXT_WINDOW_NOTE,E9 as DEFAULT_COMPACT_TRIGGER_TOKENS,q9 as DEFAULT_COMPACT_INSTRUCTIONS,x9 as COMPACT_SUMMARY_HEADER,dJ as AzureOpenAIProvider,wJ as AzureOpenAIImageProvider,w$ as AttachmentNotFoundError,OJ as AgentTurnError,QJ as AgentTool,g9 as AgentRunError,m as AgentProvider,w as AgentJobs,_J as AgentJobDeadlineSweep,jQ as AgentJob,UQ as AgentController,u9 as Agent};
87
87
 
88
- //# debugId=620D0615AF4EBD5664756E2164756E21
88
+ //# debugId=BCA1CA1EAA9866F864756E2164756E21