gemi 0.219.0 → 0.220.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 (220) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/ai/index.js.map +1 -1
  3. package/dist/ai/testing/index.js +2 -2
  4. package/dist/ai/testing/index.js.map +1 -1
  5. package/dist/app/index.js +1 -1
  6. package/dist/bun/plugin.js +1 -1
  7. package/dist/bun/preload.js +1 -1
  8. package/dist/{chunk-xyv3y476.js → chunk-0av1gyns.js} +3 -3
  9. package/dist/{chunk-xyv3y476.js.map → chunk-0av1gyns.js.map} +1 -1
  10. package/dist/{chunk-yxtfg4wy.js → chunk-0k2r6bep.js} +2 -2
  11. package/dist/{chunk-yxtfg4wy.js.map → chunk-0k2r6bep.js.map} +1 -1
  12. package/dist/chunk-169e9dg7.js +517 -0
  13. package/dist/chunk-169e9dg7.js.map +25 -0
  14. package/dist/{chunk-xp5mmgfp.js → chunk-2vv04thj.js} +2 -2
  15. package/dist/{chunk-xp5mmgfp.js.map → chunk-2vv04thj.js.map} +1 -1
  16. package/dist/{chunk-kt174y9e.js → chunk-2y0nr525.js} +3 -3
  17. package/dist/{chunk-kt174y9e.js.map → chunk-2y0nr525.js.map} +1 -1
  18. package/dist/{chunk-aes0ecnp.js → chunk-37209psn.js} +3 -3
  19. package/dist/{chunk-aes0ecnp.js.map → chunk-37209psn.js.map} +1 -1
  20. package/dist/{chunk-yedb5vvg.js → chunk-3dkv4989.js} +2 -2
  21. package/dist/{chunk-5gp49wph.js.map → chunk-3dkv4989.js.map} +1 -1
  22. package/dist/{chunk-5wh3cw2x.js → chunk-3y91vexx.js} +3 -3
  23. package/dist/{chunk-5wh3cw2x.js.map → chunk-3y91vexx.js.map} +1 -1
  24. package/dist/{chunk-cmyt2txd.js → chunk-4v5nwqw6.js} +3 -3
  25. package/dist/{chunk-cmyt2txd.js.map → chunk-4v5nwqw6.js.map} +1 -1
  26. package/dist/{chunk-v0sgcy87.js → chunk-4wh4dfgf.js} +1 -1
  27. package/dist/{chunk-1nw9jhpt.js → chunk-50791bmz.js} +2 -2
  28. package/dist/{chunk-1nw9jhpt.js.map → chunk-50791bmz.js.map} +1 -1
  29. package/dist/{chunk-rp2f9mq1.js → chunk-55btq9c7.js} +2 -2
  30. package/dist/{chunk-rp2f9mq1.js.map → chunk-55btq9c7.js.map} +1 -1
  31. package/dist/{chunk-w3ks9nz7.js → chunk-5h2xj3cx.js} +2 -2
  32. package/dist/{chunk-w3ks9nz7.js.map → chunk-5h2xj3cx.js.map} +1 -1
  33. package/dist/{chunk-at6zjajz.js → chunk-5jvbr0e5.js} +2 -2
  34. package/dist/{chunk-at6zjajz.js.map → chunk-5jvbr0e5.js.map} +1 -1
  35. package/dist/{chunk-hmtn7996.js → chunk-5mrtgr7q.js} +2 -2
  36. package/dist/{chunk-hmtn7996.js.map → chunk-5mrtgr7q.js.map} +1 -1
  37. package/dist/{chunk-2vktfp1f.js → chunk-6d67a1d4.js} +2 -2
  38. package/dist/{chunk-2vktfp1f.js.map → chunk-6d67a1d4.js.map} +1 -1
  39. package/dist/{chunk-q0d45r2j.js → chunk-6r7956dh.js} +2 -2
  40. package/dist/{chunk-q0d45r2j.js.map → chunk-6r7956dh.js.map} +1 -1
  41. package/dist/{chunk-ee7xb9qr.js → chunk-6ttbhhnn.js} +1 -1
  42. package/dist/{chunk-w85wrer7.js → chunk-726gd69z.js} +2 -2
  43. package/dist/{chunk-w85wrer7.js.map → chunk-726gd69z.js.map} +1 -1
  44. package/dist/{chunk-dgna0e7g.js → chunk-79wjkaa4.js} +2 -2
  45. package/dist/{chunk-dgna0e7g.js.map → chunk-79wjkaa4.js.map} +1 -1
  46. package/dist/{chunk-c250kpcm.js → chunk-7etvj6w2.js} +2 -2
  47. package/dist/{chunk-c250kpcm.js.map → chunk-7etvj6w2.js.map} +1 -1
  48. package/dist/{chunk-yv3y3r9q.js → chunk-7sjzgme6.js} +4 -4
  49. package/dist/{chunk-yv3y3r9q.js.map → chunk-7sjzgme6.js.map} +1 -1
  50. package/dist/chunk-89egc0h3.js +5 -0
  51. package/dist/{chunk-4g24ffv8.js.map → chunk-89egc0h3.js.map} +1 -1
  52. package/dist/{chunk-4k3r37be.js → chunk-8a3fqcf0.js} +2 -2
  53. package/dist/{chunk-4k3r37be.js.map → chunk-8a3fqcf0.js.map} +1 -1
  54. package/dist/{chunk-3r7z4kc0.js → chunk-8ddt5fa2.js} +2 -2
  55. package/dist/{chunk-3r7z4kc0.js.map → chunk-8ddt5fa2.js.map} +1 -1
  56. package/dist/{chunk-4kkb85z8.js → chunk-8gnbc9dg.js} +3 -3
  57. package/dist/{chunk-4kkb85z8.js.map → chunk-8gnbc9dg.js.map} +1 -1
  58. package/dist/{chunk-66re5qsr.js → chunk-8nctfg18.js} +2 -2
  59. package/dist/{chunk-66re5qsr.js.map → chunk-8nctfg18.js.map} +1 -1
  60. package/dist/{chunk-17agj0r3.js → chunk-8vpe54ek.js} +2 -2
  61. package/dist/{chunk-17agj0r3.js.map → chunk-8vpe54ek.js.map} +1 -1
  62. package/dist/{chunk-9c8e4nkz.js → chunk-97tj0d7v.js} +2 -2
  63. package/dist/{chunk-9c8e4nkz.js.map → chunk-97tj0d7v.js.map} +1 -1
  64. package/dist/{chunk-w9a3b4vs.js → chunk-9yascc81.js} +2 -2
  65. package/dist/{chunk-w9a3b4vs.js.map → chunk-9yascc81.js.map} +1 -1
  66. package/dist/{chunk-9pvxexh1.js → chunk-adw279ge.js} +2 -2
  67. package/dist/{chunk-9pvxexh1.js.map → chunk-adw279ge.js.map} +1 -1
  68. package/dist/{chunk-w4aw44zg.js → chunk-anc5v266.js} +2 -2
  69. package/dist/{chunk-w4aw44zg.js.map → chunk-anc5v266.js.map} +1 -1
  70. package/dist/{chunk-6b7z5h54.js → chunk-ax042w6k.js} +2 -2
  71. package/dist/{chunk-6b7z5h54.js.map → chunk-ax042w6k.js.map} +1 -1
  72. package/dist/{chunk-59p034g3.js → chunk-b87wvmsz.js} +2 -2
  73. package/dist/{chunk-59p034g3.js.map → chunk-b87wvmsz.js.map} +1 -1
  74. package/dist/{chunk-xn7azkgd.js → chunk-bqm79ar0.js} +3 -3
  75. package/dist/{chunk-xn7azkgd.js.map → chunk-bqm79ar0.js.map} +1 -1
  76. package/dist/{chunk-5gp49wph.js → chunk-cf8bztwq.js} +2 -2
  77. package/dist/{chunk-yedb5vvg.js.map → chunk-cf8bztwq.js.map} +1 -1
  78. package/dist/{chunk-kggwk7hz.js → chunk-dj0nvj66.js} +1 -1
  79. package/dist/{chunk-xf3wke41.js → chunk-e4zxacxd.js} +2 -2
  80. package/dist/{chunk-xf3wke41.js.map → chunk-e4zxacxd.js.map} +1 -1
  81. package/dist/{chunk-b8tmmpcf.js → chunk-fp9yn4k8.js} +2 -2
  82. package/dist/{chunk-b8tmmpcf.js.map → chunk-fp9yn4k8.js.map} +1 -1
  83. package/dist/{chunk-sba3s380.js → chunk-fqhkkpq3.js} +2 -2
  84. package/dist/{chunk-sba3s380.js.map → chunk-fqhkkpq3.js.map} +1 -1
  85. package/dist/{chunk-nhebjh6n.js → chunk-fxa72ppw.js} +1 -1
  86. package/dist/{chunk-w9sw2kn7.js → chunk-gyszenps.js} +3 -3
  87. package/dist/{chunk-w9sw2kn7.js.map → chunk-gyszenps.js.map} +1 -1
  88. package/dist/{chunk-y12m6w7b.js → chunk-h1wmpa03.js} +2 -2
  89. package/dist/{chunk-y12m6w7b.js.map → chunk-h1wmpa03.js.map} +1 -1
  90. package/dist/{chunk-5vdkqv17.js → chunk-h9nt7hm6.js} +2 -2
  91. package/dist/{chunk-5vdkqv17.js.map → chunk-h9nt7hm6.js.map} +1 -1
  92. package/dist/{chunk-nrv7hdeh.js → chunk-j9abwrkv.js} +3 -3
  93. package/dist/{chunk-nrv7hdeh.js.map → chunk-j9abwrkv.js.map} +1 -1
  94. package/dist/{chunk-m68cxnbv.js → chunk-jf2dr481.js} +2 -2
  95. package/dist/{chunk-m68cxnbv.js.map → chunk-jf2dr481.js.map} +1 -1
  96. package/dist/{chunk-h6knw9f0.js → chunk-k16phdjv.js} +1 -1
  97. package/dist/{chunk-vewxnk3g.js → chunk-k6af7qek.js} +2 -2
  98. package/dist/{chunk-vewxnk3g.js.map → chunk-k6af7qek.js.map} +1 -1
  99. package/dist/{chunk-xm6hfksv.js → chunk-kp7wcpx7.js} +2 -2
  100. package/dist/{chunk-xm6hfksv.js.map → chunk-kp7wcpx7.js.map} +1 -1
  101. package/dist/{chunk-d6056zme.js → chunk-mt82209n.js} +2 -2
  102. package/dist/{chunk-d6056zme.js.map → chunk-mt82209n.js.map} +1 -1
  103. package/dist/{chunk-vawqmdh4.js → chunk-ncnygh0s.js} +2 -2
  104. package/dist/{chunk-vawqmdh4.js.map → chunk-ncnygh0s.js.map} +1 -1
  105. package/dist/{chunk-g178aect.js → chunk-nqgeny8m.js} +4 -4
  106. package/dist/{chunk-g178aect.js.map → chunk-nqgeny8m.js.map} +1 -1
  107. package/dist/{chunk-zy6hj5cc.js → chunk-nqqyn3cx.js} +2 -2
  108. package/dist/{chunk-zy6hj5cc.js.map → chunk-nqqyn3cx.js.map} +1 -1
  109. package/dist/{chunk-ppdfwnqw.js → chunk-nzd7z4s6.js} +1 -1
  110. package/dist/{chunk-s4sx97fn.js → chunk-p4v71qfx.js} +3 -3
  111. package/dist/{chunk-s4sx97fn.js.map → chunk-p4v71qfx.js.map} +1 -1
  112. package/dist/{chunk-vck02shp.js → chunk-ps5rpy9n.js} +2 -2
  113. package/dist/{chunk-vck02shp.js.map → chunk-ps5rpy9n.js.map} +1 -1
  114. package/dist/{chunk-gt6eq1p2.js → chunk-pxjkxhf9.js} +3 -3
  115. package/dist/{chunk-gt6eq1p2.js.map → chunk-pxjkxhf9.js.map} +1 -1
  116. package/dist/{chunk-r90djdx6.js → chunk-pxjptskr.js} +2 -2
  117. package/dist/{chunk-r90djdx6.js.map → chunk-pxjptskr.js.map} +1 -1
  118. package/dist/{chunk-6ncn8rdn.js → chunk-q5xcjm5z.js} +2 -2
  119. package/dist/{chunk-6ncn8rdn.js.map → chunk-q5xcjm5z.js.map} +1 -1
  120. package/dist/{chunk-0egjv6cj.js → chunk-qs2xvc8g.js} +2 -2
  121. package/dist/{chunk-0egjv6cj.js.map → chunk-qs2xvc8g.js.map} +1 -1
  122. package/dist/{chunk-6my6c6b1.js → chunk-qy0k2s5f.js} +2 -2
  123. package/dist/{chunk-6my6c6b1.js.map → chunk-qy0k2s5f.js.map} +1 -1
  124. package/dist/{chunk-jzqywxpj.js → chunk-rat2827k.js} +2 -2
  125. package/dist/{chunk-jzqywxpj.js.map → chunk-rat2827k.js.map} +1 -1
  126. package/dist/{chunk-ykshxc5k.js → chunk-s3gn68dy.js} +2 -2
  127. package/dist/{chunk-ykshxc5k.js.map → chunk-s3gn68dy.js.map} +1 -1
  128. package/dist/{chunk-8524ejgk.js → chunk-sfrjkysf.js} +2 -2
  129. package/dist/{chunk-8524ejgk.js.map → chunk-sfrjkysf.js.map} +1 -1
  130. package/dist/{chunk-cw50n89n.js → chunk-snmyjq03.js} +2 -2
  131. package/dist/{chunk-cw50n89n.js.map → chunk-snmyjq03.js.map} +1 -1
  132. package/dist/{chunk-cwm5x7rf.js → chunk-swmf6w3z.js} +2 -2
  133. package/dist/{chunk-cwm5x7rf.js.map → chunk-swmf6w3z.js.map} +1 -1
  134. package/dist/{chunk-xvf1hcxg.js → chunk-t0ke72e9.js} +2 -2
  135. package/dist/{chunk-xvf1hcxg.js.map → chunk-t0ke72e9.js.map} +1 -1
  136. package/dist/{chunk-gf3m0866.js → chunk-t586p2g2.js} +2 -2
  137. package/dist/{chunk-gf3m0866.js.map → chunk-t586p2g2.js.map} +1 -1
  138. package/dist/{chunk-zyvmbqcx.js → chunk-t8ygf6zj.js} +3 -3
  139. package/dist/{chunk-zyvmbqcx.js.map → chunk-t8ygf6zj.js.map} +1 -1
  140. package/dist/{chunk-ak85ee4e.js → chunk-tac25cnj.js} +3 -3
  141. package/dist/{chunk-ak85ee4e.js.map → chunk-tac25cnj.js.map} +1 -1
  142. package/dist/{chunk-p4b5hmr8.js → chunk-vcw98sp6.js} +3 -3
  143. package/dist/{chunk-p4b5hmr8.js.map → chunk-vcw98sp6.js.map} +1 -1
  144. package/dist/{chunk-jfpwjqvq.js → chunk-vcy1y0ta.js} +2 -2
  145. package/dist/{chunk-jfpwjqvq.js.map → chunk-vcy1y0ta.js.map} +1 -1
  146. package/dist/{chunk-fhb00fjx.js → chunk-vmmjq9fn.js} +2 -2
  147. package/dist/{chunk-fhb00fjx.js.map → chunk-vmmjq9fn.js.map} +1 -1
  148. package/dist/{chunk-prc4bcgp.js → chunk-wt4ekzp9.js} +2 -2
  149. package/dist/{chunk-prc4bcgp.js.map → chunk-wt4ekzp9.js.map} +1 -1
  150. package/dist/{chunk-xrkr2yzz.js → chunk-wy82t7mz.js} +2 -2
  151. package/dist/{chunk-xrkr2yzz.js.map → chunk-wy82t7mz.js.map} +1 -1
  152. package/dist/{chunk-g5drp5xx.js → chunk-x3pbssy4.js} +2 -2
  153. package/dist/{chunk-g5drp5xx.js.map → chunk-x3pbssy4.js.map} +1 -1
  154. package/dist/{chunk-71r1x773.js → chunk-xjgfmefy.js} +2 -2
  155. package/dist/{chunk-71r1x773.js.map → chunk-xjgfmefy.js.map} +1 -1
  156. package/dist/{chunk-qstjm3cb.js → chunk-yj7pbbnm.js} +2 -2
  157. package/dist/{chunk-qstjm3cb.js.map → chunk-yj7pbbnm.js.map} +1 -1
  158. package/dist/{chunk-qa528feb.js → chunk-zmt5kdpb.js} +2 -2
  159. package/dist/{chunk-qa528feb.js.map → chunk-zmt5kdpb.js.map} +1 -1
  160. package/dist/config/index.js +1 -1
  161. package/dist/console/run.js +2 -2
  162. package/dist/console/run.js.map +1 -1
  163. package/dist/container/index.js +2 -2
  164. package/dist/container/index.js.map +1 -1
  165. package/dist/database/index.js +2 -2
  166. package/dist/database/index.js.map +1 -1
  167. package/dist/email/index.js +2 -2
  168. package/dist/email/index.js.map +1 -1
  169. package/dist/facades/index.js +2 -2
  170. package/dist/facades/index.js.map +1 -1
  171. package/dist/foundation/index.js +2 -2
  172. package/dist/foundation/index.js.map +1 -1
  173. package/dist/http/index.js +2 -2
  174. package/dist/http/index.js.map +1 -1
  175. package/dist/i18n/dictionaryRuntime.js +2 -2
  176. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  177. package/dist/i18n/index.js +2 -2
  178. package/dist/i18n/index.js.map +1 -1
  179. package/dist/kernel/index.js +2 -2
  180. package/dist/kernel/index.js.map +1 -1
  181. package/dist/orm/index.js +2 -2
  182. package/dist/orm/index.js.map +1 -1
  183. package/dist/probe/index.js +2 -2
  184. package/dist/probe/index.js.map +1 -1
  185. package/dist/server/index.js +2 -2
  186. package/dist/server/index.js.map +1 -1
  187. package/dist/services/index.d.ts +2 -1
  188. package/dist/services/index.d.ts.map +1 -1
  189. package/dist/services/index.js +3 -3
  190. package/dist/services/index.js.map +2 -2
  191. package/dist/services/queue/DatabaseQueueDriver.d.ts +8 -1
  192. package/dist/services/queue/DatabaseQueueDriver.d.ts.map +1 -1
  193. package/dist/services/queue/work.js +2 -2
  194. package/dist/services/queue/work.js.map +1 -1
  195. package/dist/services/queue/workflow/DatabaseWorkflowStore.d.ts +21 -0
  196. package/dist/services/queue/workflow/DatabaseWorkflowStore.d.ts.map +1 -1
  197. package/dist/services/queue/workflow/ItemSource.d.ts +68 -0
  198. package/dist/services/queue/workflow/ItemSource.d.ts.map +1 -0
  199. package/dist/services/queue/workflow/MemoryWorkflowStore.d.ts +12 -0
  200. package/dist/services/queue/workflow/MemoryWorkflowStore.d.ts.map +1 -1
  201. package/dist/services/queue/workflow/Step.d.ts +28 -1
  202. package/dist/services/queue/workflow/Step.d.ts.map +1 -1
  203. package/dist/services/queue/workflow/WorkflowRuntime.d.ts.map +1 -1
  204. package/dist/services/queue/workflow/WorkflowStore.d.ts +23 -1
  205. package/dist/services/queue/workflow/WorkflowStore.d.ts.map +1 -1
  206. package/dist/services/queue/workflow/workflowContract.d.ts.map +1 -1
  207. package/dist/stats/route-table.js +1 -1
  208. package/dist/support/index.js +2 -2
  209. package/dist/support/index.js.map +1 -1
  210. package/dist/vitest/index.js +1 -1
  211. package/package.json +1 -1
  212. package/dist/chunk-4g24ffv8.js +0 -5
  213. package/dist/chunk-pnt0c59g.js +0 -484
  214. package/dist/chunk-pnt0c59g.js.map +0 -24
  215. /package/dist/{chunk-v0sgcy87.js.map → chunk-4wh4dfgf.js.map} +0 -0
  216. /package/dist/{chunk-ee7xb9qr.js.map → chunk-6ttbhhnn.js.map} +0 -0
  217. /package/dist/{chunk-kggwk7hz.js.map → chunk-dj0nvj66.js.map} +0 -0
  218. /package/dist/{chunk-nhebjh6n.js.map → chunk-fxa72ppw.js.map} +0 -0
  219. /package/dist/{chunk-h6knw9f0.js.map → chunk-k16phdjv.js.map} +0 -0
  220. /package/dist/{chunk-ppdfwnqw.js.map → chunk-nzd7z4s6.js.map} +0 -0
package/dist/ai/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{ca as hQ,da as pQ,ea as mQ,fa as U6,ga as C6,ha as _6,ia as u$,ja as L6,ka as B6,la as H$,ma as M6,na as S6,oa as A6,pa as R6}from"../chunk-w9a3b4vs.js";import{$c as Z6,Ac as OZ,Bc as XQ,Dc as GQ,Ec as PQ,Fc as zQ,Gc as DQ,Hc as HQ,Ic as NQ,Jc as FQ,Kc as OQ,Lc as UQ,Mc as CQ,Nc as _Q,Oc as LQ,Qc as g$,Rc as n9,Sc as o9,Tc as s9,Uc as a9,Vc as t9,Wc as r9,Xc as e9,Yc as J6,Zc as $6,_c as Q6,ad as zJ,bd as W6,cd as tZ,dd as K6,ed as rZ,fd as X6,gd as G6,hd as Y6,ic as y$,id as EJ,jc as pZ,jd as W$,kc as mZ,kd as V6,lc as v$,ld as z6,md as eZ,nd as D6,od as H6,pc as vQ,pd as P6,qc as IQ,qd as N6,rc as XJ,rd as F6,sc as d9,sd as O6,tc as b,td as Q$,uc as ZQ,vc as WQ,xc as KQ,yc as g,zc as FZ}from"../chunk-xvf1hcxg.js";import{Gd as p,Hd as h$,Kd as lZ,Ld as iZ,Md as dZ,Nd as bJ,Od as nZ,Pd as cJ,Qd as yJ,Rd as x$,Sd as oZ,Td as sZ,Ud as pJ,Vd as aZ,_d as t,ae as a,xd as iQ,yd as A,zd as T}from"../chunk-xm6hfksv.js";import{re as t$}from"../chunk-7xe5vd4w.js";import"../chunk-pnt0c59g.js";import{Li as I,ji as fZ,mi as yZ,sj as vZ,xj as B$}from"../chunk-4kkb85z8.js";import{Aj as gJ,Bj as uJ,yj as bZ}from"../chunk-y12m6w7b.js";import{Kj as c}from"../chunk-gf3m0866.js";import{Mj as m9,Nj as l9,Oj as i9}from"../chunk-0egjv6cj.js";import"../chunk-w4aw44zg.js";import{Vk as hZ,Wk as gZ,Xk as uZ,Yk as cZ}from"../chunk-ak85ee4e.js";import"../chunk-yxtfg4wy.js";import{cl as o,dl as s,sl as SJ}from"../chunk-xyv3y476.js";import"../chunk-qa528feb.js";import"../chunk-qstjm3cb.js";import{jm as KZ}from"../chunk-aes0ecnp.js";import"../chunk-sba3s380.js";import"../chunk-q0d45r2j.js";import{Gm as dJ}from"../chunk-hmtn7996.js";import"../chunk-yedb5vvg.js";import{existsSync as Y8,readdirSync as k6,readFileSync as o$}from"fs";import{isAbsolute as V8,join as UJ,relative as z8,sep as D8}from"path";var s$="prompts.json",H8=/\{\{>\s*([\w./-]+)\s*\}\}/g,i$=/\{\{(\w+)\}\}/g,P8=/^[\w-]+(\/[\w-]+)*$/,d$={dir:"app/agents",shared:"prompts"},_J={},lJ=new Map,CJ;function N8(){if(CJ===void 0){let J=UJ(dJ(),"dist","server",s$);CJ=Y8(J)?JSON.parse(o$(J,"utf8")):null}return CJ??null}function F8(J){return J.replace(/\r?\n$/,"")}function n$(){return _J.cache??Bun.env.NODE_ENV==="production"}function O8(J,$){if(!P8.test(J))throw Error(`"${J}" is not a prompt name. Use letters, digits, "-" and "_", with "/" between folders.`);let Q=$.dir??_J.dir??d$.dir,Z=V8(Q)?Q:UJ(process.cwd(),Q),W=J.includes("/")?`${J}.md`:UJ($.shared??_J.shared??d$.shared,`${J}.md`);return UJ(Z,W)}function U8(J,$){let Q=O8(J,$),Z=n$()?lJ.get(Q):void 0;if(Z!==void 0)return Z;let W=Bun.env.NODE_ENV==="production";if(W){let X=N8()?.[z8(dJ(),Q).split(D8).join("/")];if(X!==void 0)return X}let K;try{K=F8(o$(Q,"utf8"))}catch(X){if(X.code==="ENOENT"){let G=W?` or in dist/server/${s$}`:"";throw Error(`The prompt "${J}" does not exist (looked for ${Q}${G}).`)}throw X}if(n$())lJ.set(Q,K);return K}function iJ(J,$,Q){if($.includes(J))throw Error(`The prompt "${J}" includes itself: ${[...$,J].join(" > ")}.`);return U8(J,Q).replace(H8,(Z,W)=>iJ(W,[...$,J],Q))}class a${static configure(J){_J={...J},lJ.clear(),CJ=void 0}static render(J,$={},Q={}){return iJ(J,[],Q).replace(i$,(Z,W)=>{if(!Object.hasOwn($,W))throw Error(`The prompt "${J}" has no value for {{${W}}}.`);return String($[W])})}static placeholders(J,$={}){let Q=[...iJ(J,[],$).matchAll(i$)].map((Z)=>Z[1]);return[...new Set(Q)]}}class nJ extends t${name="AgentJobDeadlineSweep";cron="* * * * *";async callback(){while(await g.sweep({limit:100})===100);}}var BJ=20,C8=300,_8=200;function e$(J,$){if($<=0||J.length===0)return null;let Q=(K,X)=>X.createdAt-K.createdAt||(K.id<X.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((K)=>!b(K.state)).sort(Q),...J.filter((K)=>b(K.state)).sort(Q)].slice(0,$).map((K)=>{let X=[`- ${K.id} (${K.toolName})`];if(K.state==="waiting")X.push(`waiting for ${(K.after??[]).join(", ")} since ${LJ(K.createdAt)}`);else if(K.state==="running")X.push(`running since ${LJ(K.createdAt)}`);else if(K.state==="ok")X.push(`finished at ${LJ(K.settledAt??K.updatedAt)}`);else{let G=K.error?`${K.error.code}: ${r$(K.error.message,_8)}`:"failed";X.push(`failed at ${LJ(K.settledAt??K.updatedAt)} (${G})`)}if(K.summary!==void 0)X.push(`summary: ${r$(JSON.stringify(K.summary),C8)}`);if(K.orphaned)X.push("its tool call was lost when the turn that started it was cut short");return X.join("; ")}),"</jobs>"].join(`
2
+ import{ca as hQ,da as pQ,ea as mQ,fa as U6,ga as C6,ha as _6,ia as u$,ja as L6,ka as B6,la as H$,ma as M6,na as S6,oa as A6,pa as R6}from"../chunk-9yascc81.js";import{$c as Z6,Ac as OZ,Bc as XQ,Dc as GQ,Ec as PQ,Fc as zQ,Gc as DQ,Hc as HQ,Ic as NQ,Jc as FQ,Kc as OQ,Lc as UQ,Mc as CQ,Nc as _Q,Oc as LQ,Qc as g$,Rc as n9,Sc as o9,Tc as s9,Uc as a9,Vc as t9,Wc as r9,Xc as e9,Yc as J6,Zc as $6,_c as Q6,ad as zJ,bd as W6,cd as tZ,dd as K6,ed as rZ,fd as X6,gd as G6,hd as Y6,ic as y$,id as EJ,jc as pZ,jd as W$,kc as mZ,kd as V6,lc as v$,ld as z6,md as eZ,nd as D6,od as H6,pc as vQ,pd as P6,qc as IQ,qd as N6,rc as XJ,rd as F6,sc as d9,sd as O6,tc as b,td as Q$,uc as ZQ,vc as WQ,xc as KQ,yc as g,zc as FZ}from"../chunk-t0ke72e9.js";import{Gd as p,Hd as h$,Kd as lZ,Ld as iZ,Md as dZ,Nd as bJ,Od as nZ,Pd as cJ,Qd as yJ,Rd as x$,Sd as oZ,Td as sZ,Ud as pJ,Vd as aZ,_d as t,ae as a,xd as iQ,yd as A,zd as T}from"../chunk-kp7wcpx7.js";import{re as t$}from"../chunk-7xe5vd4w.js";import"../chunk-169e9dg7.js";import{Ni as I,li as fZ,oi as yZ,uj as vZ,zj as B$}from"../chunk-8gnbc9dg.js";import{Aj as bZ,Cj as gJ,Dj as uJ}from"../chunk-h1wmpa03.js";import{Mj as c}from"../chunk-t586p2g2.js";import{Oj as m9,Pj as l9,Qj as i9}from"../chunk-qs2xvc8g.js";import"../chunk-anc5v266.js";import{Xk as hZ,Yk as gZ,Zk as uZ,_k as cZ}from"../chunk-tac25cnj.js";import"../chunk-0k2r6bep.js";import{el as o,fl as s,ul as SJ}from"../chunk-0av1gyns.js";import"../chunk-zmt5kdpb.js";import"../chunk-yj7pbbnm.js";import{lm as KZ}from"../chunk-37209psn.js";import"../chunk-fqhkkpq3.js";import"../chunk-6r7956dh.js";import{Im as dJ}from"../chunk-5mrtgr7q.js";import"../chunk-3dkv4989.js";import{existsSync as Y8,readdirSync as k6,readFileSync as o$}from"fs";import{isAbsolute as V8,join as UJ,relative as z8,sep as D8}from"path";var s$="prompts.json",H8=/\{\{>\s*([\w./-]+)\s*\}\}/g,i$=/\{\{(\w+)\}\}/g,P8=/^[\w-]+(\/[\w-]+)*$/,d$={dir:"app/agents",shared:"prompts"},_J={},lJ=new Map,CJ;function N8(){if(CJ===void 0){let J=UJ(dJ(),"dist","server",s$);CJ=Y8(J)?JSON.parse(o$(J,"utf8")):null}return CJ??null}function F8(J){return J.replace(/\r?\n$/,"")}function n$(){return _J.cache??Bun.env.NODE_ENV==="production"}function O8(J,$){if(!P8.test(J))throw Error(`"${J}" is not a prompt name. Use letters, digits, "-" and "_", with "/" between folders.`);let Q=$.dir??_J.dir??d$.dir,Z=V8(Q)?Q:UJ(process.cwd(),Q),W=J.includes("/")?`${J}.md`:UJ($.shared??_J.shared??d$.shared,`${J}.md`);return UJ(Z,W)}function U8(J,$){let Q=O8(J,$),Z=n$()?lJ.get(Q):void 0;if(Z!==void 0)return Z;let W=Bun.env.NODE_ENV==="production";if(W){let X=N8()?.[z8(dJ(),Q).split(D8).join("/")];if(X!==void 0)return X}let K;try{K=F8(o$(Q,"utf8"))}catch(X){if(X.code==="ENOENT"){let G=W?` or in dist/server/${s$}`:"";throw Error(`The prompt "${J}" does not exist (looked for ${Q}${G}).`)}throw X}if(n$())lJ.set(Q,K);return K}function iJ(J,$,Q){if($.includes(J))throw Error(`The prompt "${J}" includes itself: ${[...$,J].join(" > ")}.`);return U8(J,Q).replace(H8,(Z,W)=>iJ(W,[...$,J],Q))}class a${static configure(J){_J={...J},lJ.clear(),CJ=void 0}static render(J,$={},Q={}){return iJ(J,[],Q).replace(i$,(Z,W)=>{if(!Object.hasOwn($,W))throw Error(`The prompt "${J}" has no value for {{${W}}}.`);return String($[W])})}static placeholders(J,$={}){let Q=[...iJ(J,[],$).matchAll(i$)].map((Z)=>Z[1]);return[...new Set(Q)]}}class nJ extends t${name="AgentJobDeadlineSweep";cron="* * * * *";async callback(){while(await g.sweep({limit:100})===100);}}var BJ=20,C8=300,_8=200;function e$(J,$){if($<=0||J.length===0)return null;let Q=(K,X)=>X.createdAt-K.createdAt||(K.id<X.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((K)=>!b(K.state)).sort(Q),...J.filter((K)=>b(K.state)).sort(Q)].slice(0,$).map((K)=>{let X=[`- ${K.id} (${K.toolName})`];if(K.state==="waiting")X.push(`waiting for ${(K.after??[]).join(", ")} since ${LJ(K.createdAt)}`);else if(K.state==="running")X.push(`running since ${LJ(K.createdAt)}`);else if(K.state==="ok")X.push(`finished at ${LJ(K.settledAt??K.updatedAt)}`);else{let G=K.error?`${K.error.code}: ${r$(K.error.message,_8)}`:"failed";X.push(`failed at ${LJ(K.settledAt??K.updatedAt)} (${G})`)}if(K.summary!==void 0)X.push(`summary: ${r$(JSON.stringify(K.summary),C8)}`);if(K.orphaned)X.push("its tool call was lost when the turn that started it was cut short");return X.join("; ")}),"</jobs>"].join(`
3
3
  `)}function LJ(J){return new Date(J).toISOString().replace(/\.\d{3}Z$/,"Z")}function r$(J,$){return J.length<=$?J:`${J.slice(0,$-1)}\u2026`}var JQ=["after_jobs","batch_key","queued","inbox","job_checkpoint"],$Q=20;class oJ{table;sql;dialect;connection;later;constructor(J,$={}){let Q=$.table??"gemi_agent_jobs";if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(Q))throw Error(`The agent jobs table name "${Q}" is not a plain identifier. Use letters, digits and underscores.`);this.table=Q,this.sql=J.sql,this.dialect=J.dialect,this.connection=J.name}async createTable(){for(let J of L8(this.dialect,this.table))await this.sql.unsafe(J)}async transaction(J){if(this.connection===void 0||this.joinable())return J();return SJ(this.sql,()=>J(),{connection:this.connection})}async create(J){let $=J.after!==void 0||J.batch!==void 0||J.queued!==void 0;if($)await this.requireLaterColumns("A job with `after` or `batch`");let Q=this.q(),Z=this.clock(Q),W=J.state??"running";if($)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,
@@ -299,4 +299,4 @@ return 0`;class S${injectedClient;prefix;constructor(J={}){this.injectedClient=J
299
299
 
300
300
  `)||void 0,U=await this.context(J,{body:V}),_=await this.reasoning(J,{body:V})||void 0,R=await this.skills(J,{body:V})||void 0,E=await this.runTools(J,{body:V,context:U})||void 0,j=await this.usageLimits(J,{body:V,context:U})||void 0,x=await this.attachmentsFor(J,Z,{body:V}),f=await this.attachmentRetention(J,{route:"stream",threadId:Z,body:V});yJ(f,this.turnAttachmentMaxAgeMs);let L=[],k=x&&f?x.withLifetime({next:()=>yJ(f,this.turnAttachmentMaxAgeMs),onPut:(S)=>L.push(S)}):x,M=this.agent.memory?await this.memoryScopes(J,{body:V}):void 0;if(z?.cancelled)return TZ();let h=Z?new E$(this.store,Z,O,(S)=>this.reportHookFailure(S)):null,c$=`run_${crypto.randomUUID()}`,p$=[],i={req:J,runId:c$,threadId:Z,get denials(){return p$}},OJ={id:null,notified:Promise.resolve()},q=this.agent.stream({runId:c$,messages:O,turn:K,threadId:Z,...h?{onMessage:(S)=>h.finish(S)}:{},onTurn:(S)=>{if(OJ.id!==null)return;OJ.id=S.id;let d=h?h.settled():Promise.resolve();OJ.notified=d.then(()=>this.safely(()=>this.onMessage(S,i)))},instructions:F,...T$.has(J)?{event:T$.get(J)}:{},...e.has(J)?{echoTurn:!0}:{},..._?{reasoning:_}:{},...R&&R.length>0?{skills:R}:{},...E?.tools&&E.tools.length>0?{tools:E.tools}:{},...E?.activeTools?{activeTools:E.activeTools}:{},...j?{usageLimits:j}:{},context:U,attachments:k,body:V,redactError:(S,d)=>this.redactError(S,d,i),onProviderRetry:(S)=>this.onProviderRetry(S,i),nonces:this.nonces,receipts:this.receipts,subject:Y,...M?{memory:{scopes:M,...this.memoryMaxTokens!==void 0?{maxTokens:this.memoryMaxTokens}:{}}}:{},...Z?{jobs:{owner:Y}}:{},...this.contextWindow!==void 0?{contextWindow:this.contextWindow}:{},...Z&&tZ(this.store)?{summaryStore:this.store}:{},...this.prepareStep!==hJ.prototype.prepareStep||this.hooks?.prepareStep?{prepareStep:(S)=>this.prepareStep(S,i)}:{}});p$=q.denials;let W8=this.liveRuns.register(q,{threadId:Z,owner:Y,clientRunId:G,onEvent:(S)=>this.dispatchEvent(S,i),onInternalError:(S)=>this.reportHookFailure(S),maxRunDurationMs:this.agent.maxRunDurationMs});if(D=q,h)this.follow(q,h);if(Z)_9(this.liveRuns,Z,q.runId);let m$=K?.files??[],K8=this.definesRetention()&&(m$.length>0||f==="turn")?()=>this.expireTurn({scoped:x,files:m$,made:L,owner:Y}):null,{stored:X8,hooks:l$}=this.persistRun(q,i,W8,h,OJ,K8);if(k$.set(q,X8),e.has(J))e.set(J,{run:q,hooks:l$});return J.ctx?.()?.waitUntil(l$),q.toResponse()};try{await this.authorizeRequest(J,{route:"stream",threadId:Z,body:V});let O=await this.foreignFile([...K?.files??[],...Z?[]:b9(Q.messages)],Y);if(O)return O;if(z?.cancelled)return TZ();let P=await this.runLimitKey(J,{owner:Y,threadId:Z}),F=P===null?$J:L9(this.liveRuns).take(P,Z?`thread:${Z}`:`run:${crypto.randomUUID()}`,this.maxConcurrentRuns);if(!F)return b$(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,Y,H,LZ.get(J)??"supersede"):await H()}finally{let U=D;if(U)U.result().then(F,F);else F()}}finally{if(z&&fJ.get(G)===z)fJ.delete(G)}}async withThread(J,$,Q,Z="supersede"){if(Z==="skip"&&PJ.has(J))return jZ(J);for(;;){let W=await this.underThreadLock(J,$,Q,Z);if(!("waitFor"in W))return W.response;await W.waitFor}}async underThreadLock(J,$,Q,Z){let W=PJ.get(J)??Promise.resolve(),K,X=new Promise((V)=>{K=V}),G=W.then(()=>X);PJ.set(J,G),await W;try{let V=await this.liveRuns.find({threadId:J});if(V&&Z!=="supersede"&&this.liveRuns.isRunning(V.runId)){if(Z==="skip")return{response:jZ(J)};let z=this.liveRuns.get(V.runId),D=z?k$.get(z)??z.result():null;if(D)return{waitFor:D.then($J,$J)}}if(V&&this.liveRuns.isRunning(V.runId)&&!this.liveRuns.mayAccess(V.runId,$))return{response:FJ()};let Y=V?this.liveRuns.get(V.runId):null;if(Y)Y.stop({reason:"superseded by a later turn on this thread"}),await k$.get(Y);return{response:await Q()}}finally{if(K(),PJ.get(J)===G)PJ.delete(J)}}async attach(J=new I){let $=await JJ(J,NJ);if($.error)return l($);let Q=$.body,Z=typeof Q.threadId==="string"?Q.threadId:kZ(J,"threadId");if(!Z)return B(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=Q.emptyMiss===!0;if(!await this.threadInScope(J,Z))return qZ(Z,W);let K=await this.liveRuns.find({threadId:Z});if(K&&!this.liveRuns.mayAccess(K.runId,await this.runOwner(J)))return FJ();if(!K)return qZ(Z,W);let X=typeof Q.runId==="string"?Q.runId:void 0,G=X&&X!==K.runId?void 0:I9(J,Q);try{return cZ(this.liveRuns.replay(K.runId,G))}catch(V){if(V instanceof r)return B(410,{code:V.code,message:V.message,oldestSeq:V.oldest});if(V instanceof DJ)return B(404,{code:V.code,message:V.message});throw V}}async watch(J=new I){let $=await JJ(J,NJ);if($.error)return l($);let Q=$.body,Z=typeof Q.threadId==="string"?Q.threadId:kZ(J,"threadId");if(!Z)return B(400,{code:"invalid_request",message:"watch needs a threadId: it is the thread whose runs are announced."});if(await this.authorizeRequest(J,{route:"attach",threadId:Z}),!await this.threadInScope(J,Z))return B(404,{code:"thread_not_found",message:`Thread ${Z} does not exist here, or has expired.`});let W=await this.runOwner(J),K=this.liveRuns,X=C9(K),G=await K.find({threadId:Z}),V=null,Y=null,z=0,D=()=>{if(Y?.stop(),!V)return;let H=X.get(Z);if(H?.delete(V),H&&H.size===0)X.delete(Z);V=null},N=new ReadableStream({start(H){Y=gZ(H);let C=(P)=>{if(!K.mayAccess(P,W))return;try{H.enqueue(new TextEncoder().encode(hZ({seq:++z,event:{type:"run-start",runId:P,threadId:Z}}))),Y?.touch()}catch{D()}};V=C;let O=X.get(Z);if(!O)O=new Set,X.set(Z,O);if(O.add(C),G&&K.isRunning(G.runId))C(G.runId)},cancel(){D()}});return J.rawRequest?.signal?.addEventListener("abort",D,{once:!0}),new Response(N,{status:200,headers:uZ()})}async stop(J=new I){let $=await JJ(J,NJ);if($.error)return l($);let Q=$.body;await this.authorizeRequest(J,{route:"stop",threadId:typeof Q.threadId==="string"?Q.threadId:void 0});let Z=await this.runOwner(J),W=typeof Q.runId==="string"?Q.runId:void 0;if(!W&&typeof Q.clientRunId==="string"){if(W=this.liveRuns.findByClientRunId(Q.clientRunId)??void 0,!W){let X=fJ.get(Q.clientRunId);if(X){if(X.owner!==null&&X.owner!==Z)return FJ();return X.cancelled=!0,{stopped:!0}}}}if(!W&&typeof Q.threadId==="string")W=(await this.liveRuns.find({threadId:Q.threadId}))?.runId;let K=W?this.liveRuns.get(W):null;if(!K)return{stopped:!1};if(!this.liveRuns.mayAccess(K.runId,Z))return FJ();return K.stop({reason:typeof Q.reason==="string"?Q.reason:void 0}),{stopped:!0}}attachmentScope(J,$,Q){let Z=this.hooks?.attachmentScope;if(Z)return Z(J,$,Q);let W=J.ctx()?.user,K=W?.id??W?.publicId;if(K!==void 0&&K!==null&&String(K)!=="")return{key:`user:${String(K)}`};if($)return{key:`thread:${$}`};return null}attachmentRetention(J,$){return this.hooks?.attachmentRetention?.(J,$)??null}definesRetention(){return this.attachmentRetention!==hJ.prototype.attachmentRetention||Boolean(this.hooks?.attachmentRetention)}async sweepAttachments(J={}){let $=J.now??new Date,Q=J.limit??500;if(!this.attachments.expired||!this.attachments.delete)throw Error("sweepAttachments() needs an attachment store with expired() and delete(). Implement both on the controller's `attachments` store.");let Z={deleted:0,failed:0},W=this.deletionTargets();for(let K of await this.attachments.expired($,Q))try{await x$(K,W),Z.deleted++}catch(X){Z.failed++,this.reportHookFailure(X)}for(let K of await this.fileOwners.expired?.($,Q)??[])try{await this.deleteProviderFile(K),Z.deleted++}catch(X){Z.failed++,this.reportHookFailure(X)}return Z}deletionTargets(){return{store:this.attachments,storage:this.attachmentStorage,provider:this.agent.provider,fileOwners:this.fileOwners}}async deleteProviderFile(J){let $=this.agent.provider;if(!$.deleteFile)throw Error(`Cannot delete provider file ${J}: the agent's provider has no deleteFile().`);await $.deleteFile(J),await this.fileOwners.delete?.(J)}async expireTurn(J){let $=this.deletionTargets(),Q=new Set,Z=new Set,W=async(K)=>{if(Q.has(K.id))return;if(Q.add(K.id),K.fileId)Z.add(K.fileId);try{await x$(K,$)}catch(X){this.reportHookFailure(X)}};for(let K of J.made)if(K.deleteAfterTurn)await W(K);for(let K of J.files){if(K.attachmentId&&J.scoped){let X=await J.scoped.get(K.attachmentId).catch(()=>null);if(X?.deleteAfterTurn)await W(X)}if(K.fileId&&!Z.has(K.fileId)){Z.add(K.fileId);let X=await this.fileOwners.get(K.fileId);if(X?.deleteAfterTurn&&X.owner===J.owner)try{await this.deleteProviderFile(K.fileId)}catch(G){this.reportHookFailure(G)}}}}attachmentLimits(J){let $=this.hooks?.attachmentLimits;if($)return $(J);return null}checkUpload(J,$,Q){return this.hooks?.checkUpload?.(J,$,Q)}attachmentDestination(J,$,Q){let Z=this.hooks?.attachmentDestination;if(Z)return Z(J,$,Q);return"both"}async attachmentsFor(J,$,Q={body:{}}){let Z=await this.attachmentScope(J,$,Q);if(!Z)return null;return new cJ(this.attachments,this.attachmentStorage,Z)}async voiceStart(J=new I){let $=this.voice;if(!$)return j$();let Q=await JJ(J,NJ);if(Q.error)return l(Q);let{sdp:Z,threadId:W,pushToTalk:K}=Q.body;if(typeof Z!=="string"||!Z.trimStart().startsWith("v="))return B(400,{code:"invalid_request",message:"`sdp` must be the browser's SDP offer."});let X=vJ(Q.body,y9),G=typeof W==="string"&&W!==""?W:void 0;await this.authorizeRequest(J,{route:"stream",threadId:G,body:X});let V=J.ctx?.()?.user??null,Y=await $.start({req:J,body:X,threadId:G,user:V,pushToTalk:K===!0}),z=Date.now(),D,N=async(U)=>{if(U!==void 0)console.error("[gemi/ai] a voice session could not start.",U);if(D)await $.realtime.hangup(D).catch((_)=>{console.error("[gemi/ai] a voice call that failed to start could not be hung up.",_)});try{await Y.onEnd?.({sessionId:"",...D?{callId:D}:{},threadId:Y.threadId??G??"",reason:"start_failed",startedAt:z,endedAt:Date.now(),durationMs:0,seconds:0,usage:A(),transcription:{usage:A(),seconds:0},transcript:[],requests:[],toolCalls:[],errors:[]})}catch(_){console.error("[gemi/ai] a voice session's onEnd threw.",_)}},H=Y.threadId??G;if(!H)return await N(void 0),B(400,{code:"invalid_request",message:"A voice session needs a thread: send `threadId`, or answer one from `voice.start`."});try{if(H!==G)await this.authorizeRequest(J,{route:"stream",threadId:H,body:X})}catch(U){throw await N(void 0),U}let C=crypto.randomUUID(),O=Y.tools??[];try{if(Y.mcp)O=[...O,...await P$(Y.mcp,{user:V,sessionId:C})]}catch(U){return await N(U),B(500,{code:"voice_unavailable",message:"Voice isn't available right now."})}let P={...Y.session,tools:[...YJ($.delegate),...Y.session?.tools??[],...O.map((U)=>U.tool)],...K===!0?{turnDetection:null}:{}},F;try{F=await $.realtime.createCall({sdp:Z,session:P,safetyIdentifier:Y.safetyIdentifier})}catch(U){await N(U);let _=U instanceof u$&&U.code==="rate_limited";return B(_?429:502,{code:"voice_unavailable",message:"Voice isn't available right now."})}D=F.callId;try{await this.voiceStore.create({id:C,callId:F.callId,threadId:H,owner:await this.runOwner(J),body:X,startedAt:z});let{threadId:U,session:_,safetyIdentifier:R,mcp:E,tools:j,...x}=Y;return{sessionId:m.start({...x,tools:O,controller:this.constructor,threadId:H,user:V,body:X,call:{realtime:$.realtime,callId:F.callId},sessionId:C,store:this.voiceStore,liveRuns:this.liveRuns,delegate:$.delegate,session:P}).sessionId,sdp:F.sdpAnswer,threadId:H,delegate:$.delegate?.name??VJ,endsAt:z+(Y.limits?.maxDurationMs??900000)}}catch(U){return await N(U),B(500,{code:"voice_unavailable",message:"Voice isn't available right now."})}}async voiceUpdate(J=new I){if(!this.voice)return j$();let $=await this.voiceSession(J);if($ instanceof Response)return $;let Q=await JJ(J,NJ);if(Q.error)return l(Q);let Z=vJ(Q.body,[]);if(await this.authorizeRequest(J,{route:"stream",threadId:$.threadId,body:Z}),$.endedAt!==void 0)return B(409,{code:"voice_ended",message:"This voice session has ended."});return await this.voiceStore.update($.id,{body:Z}),m.get($.id)?.setBody(Z),{updated:!0}}async voiceEnd(J=new I){let $=this.voice;if(!$)return j$();let Q=await this.voiceSession(J);if(Q instanceof Response)return Q;if(await this.authorizeRequest(J,{route:"stream",threadId:Q.threadId,body:Q.body}),Q.endedAt!==void 0)return{ended:!1};let Z=m.get(Q.id);if(Z)await Z.end("hangup");else await $.realtime.hangup(Q.callId),await this.voiceStore.update(Q.id,{endedAt:Date.now(),endReason:"hangup"});return{ended:!0}}async voiceSession(J){let $=J.params?.sessionId,Q=typeof $==="string"&&$?await this.voiceStore.get($):null;if(!Q)return B(404,{code:"voice_not_found",message:"No such voice session."});if(Q.owner!==null&&Q.owner!==await this.runOwner(J))return FJ();return Q}async upload(J=new I){let $=await J.rawRequest.formData(),Q=$.get("file");if(!(Q instanceof Blob))throw Error("upload expects a multipart body with a `file` field.");let Z=Q instanceof File&&Q.name?Q.name:"upload",W=Q.type||"application/octet-stream",K=S9($.get("body")),X=$.get("threadId");await this.authorizeRequest(J,{route:"upload",threadId:typeof X==="string"&&X.length>0?X:void 0,body:K});let G=R9(await this.attachmentLimits(J),Q,Z,W);if(G)throw new f$(G.code,G.message);await this.scopeStore(J,K);let V=typeof X==="string"&&X.length>0&&await this.store.loadThread(X)!==null?X:void 0,Y=await this.runOwner(J),z=null,D=(j)=>this.fileOwners.record(j,{owner:Y,name:Z,mimeType:W,size:Q.size,createdAt:new Date().toISOString(),...z}),N={body:K,threadId:V},H=await this.checkUpload({name:Z,size:Q.size,mimeType:W},J,N);if(H)throw new f$(H.code||"upload_refused",H.message);let C=await this.attachmentDestination(Q,J,N),O=v9(C,$.get("destination")),P=await this.attachmentScope(J,V,{body:K});z=yJ(await this.attachmentRetention(J,{route:"upload",threadId:V,body:K}),this.turnAttachmentMaxAgeMs);let F=O!=="provider"&&!P;if(F){if(O==="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()`.');h9()}if(O==="provider"||!P){let j=await SZ(this.agent.provider,Q);await D(j);let x={fileId:j,name:Z,mimeType:W,size:Q.size,destination:"provider"};if(F)x.downgraded="no_scope";return x}let U=nZ(),_=await this.attachmentStorage.put({name:oZ(U,Z),body:Q,contentType:W}),R=O==="both"?await SZ(this.agent.provider,Q):void 0;if(R)await D(R);let E={id:U,scopeKey:P.key,fileId:R,objectName:_,name:Z,mimeType:W,size:Q.size,createdAt:new Date().toISOString(),destination:O,...z};return await this.attachments.put(P,E),{fileId:R,attachmentId:U,name:Z,mimeType:W,size:Q.size,destination:O}}async foreignFile(J,$){let Q=new Set(J.map((Z)=>Z.fileId).filter((Z)=>typeof Z==="string"));for(let Z of Q){let W=await this.fileOwners.get(Z);if(W?W.owner!==null&&W.owner!==$:this.requireKnownFiles)return f9()}return null}onMessage(J,$){return this.hooks?.onMessage?.(J,$)}onToolCall(J,$){return this.hooks?.onToolCall?.(J,$)}onToolResult(J,$,Q){return this.hooks?.onToolResult?.(J,$,Q)}onAwaitingInput(J,$){return this.hooks?.onAwaitingInput?.(J,$)}redactError(J,$,Q){let Z=this.hooks?.redactError;if(Z)return Z(J,$,Q);return h$(J,$)}onError(J,$){return this.hooks?.onError?.(J,$)}onProviderRetry(J,$){return this.hooks?.onProviderRetry?.(J,$)}onStreamComplete(J,$){return this.hooks?.onStreamComplete?.(J,$)}reportHookFailure(J){let $=this.hooks?.reportHookFailure;if($)try{return $(J)}catch(Q){console.error("[gemi/ai] reportHookFailure hook failed",Q)}console.error("[gemi/ai] agent controller hook failed",J)}async dispatchEvent(J,$){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},$);return;case"tool-result":{let Q=J.part;await this.onToolResult(Q,$,{toolCallId:Q.toolCallId,name:String(Q.name),input:eZ(Q)});return}case"awaiting-input":await this.onAwaitingInput(J.pending,$);return;case"error":await this.onError(lZ(J.error),$);return;default:return}}async readThread(J,$={}){let Z=await($.scope===null||$.scope===void 0?this.store:wZ(this.store,$.scope)).loadThread(J);if(!Z)return null;let{messages:W}=await this.settleThread(J,Z,{write:!1});return W}isRunLive(J,$){return this.liveRuns.get(J)!==null}async settleThread(J,$,{write:Q}){let Z=(V)=>this.isRunLive(V,J),W=await PZ($,Z),K=W.messages,X=[],G=new Map(W.settled.map((V)=>[V.id,V]));if(p9(K)||Q)try{let V=await UZ(K,{threadId:J,store:g.store,isRunLive:Z,outputSchemaFor:(Y)=>this.toolNamed(Y)?.outputSchema,modelOutputFor:(Y,z)=>rZ(this.toolNamed(Y),z,(D)=>this.reportHookFailure(D)),scan:this.jobsBlockMax()});K=V.messages,X=V.jobs;for(let Y of V.settled)G.set(Y.id,Y);if(Q&&V.orphans.length>0){await CZ(g.store,V.orphans,(z)=>this.reportHookFailure(z));let Y=new Set(V.orphans.map((z)=>z.id));X=X.map((z)=>Y.has(z.id)?{...z,orphaned:!0}:z)}}catch(V){this.reportHookFailure(V)}if(Q&&G.size>0)try{await this.store.appendMessages(J,[...G.values()])}catch(V){this.reportHookFailure(V)}return{messages:K,jobs:X}}jobsBlockMax(){let J=this.agent.jobs?.contextBlock;if(J===!1)return 0;return J?.max??BJ}jobsBlock(J){return e$(J,this.jobsBlockMax())}toolNamed(J){let $=(Q)=>{for(let Z of Q){let W=Z;if(Array.isArray(W.tools)){let K=$(W.tools);if(K)return K}else if(W.name===J)return W}return};return $(this.agent.tools??[])}follow(J,$){(async()=>{try{for await(let Q of J.frames())$.frame(Q)}catch(Q){this.reportHookFailure(Q)}})()}persistRun(J,$,Q,Z=null,W={id:null,notified:Promise.resolve()},K=null){let X=(z)=>K?z.then(()=>this.safely(K)):z,G=Promise.resolve(),V=(async()=>{let z;try{z=await J.result()}catch(N){Z?.close(),await Z?.settled(),G=X(W.notified.then(()=>this.safely(()=>this.onError({code:"unknown",message:N instanceof Error?N.message:String(N),retryable:!1},$))));return}let D=z.messages;if(Z?.close(D),await Z?.settled(),$.threadId&&D.length>0)try{await this.store.appendMessages($.threadId,D)}catch(N){this.reportHookFailure(N)}G=X(this.notifyRun(z,D,$,W))})(),Y=V.then(()=>u9(Promise.all([G,Q]).then(()=>{}),this.hookHoldMs));return{stored:V,hooks:Y}}async notifyRun(J,$,Q,Z){await Z.notified;for(let W of $){if(W.id===Z.id)continue;await this.safely(()=>this.onMessage(W,Q))}await this.safely(()=>this.onStreamComplete(J,Q))}async safely(J){try{await J()}catch($){this.reportHookFailure($)}}}var w$=["turn","clientRunId","threadId","messages","regenerate"],M9=["text","files","toolResults"];function vJ(J,$=Z8(J)?w$:[...w$,...M9]){let Q={};for(let[Z,W]of Object.entries(J)){if($.includes(Z))continue;Object.defineProperty(Q,Z,{value:W,writable:!0,enumerable:!0,configurable:!0})}return Q}function S9(J){if(J===null)return{};let $;if(typeof J==="string")try{$=JSON.parse(J)}catch{throw new q$("The upload's `body` field is not valid JSON.")}if($===null||typeof $!=="object"||Array.isArray($))throw new q$("The upload's `body` field must be a JSON object.");return vJ($,w$)}class q$ extends gJ{constructor(J){super(J);this.name="InvalidUploadError",this.payload={api:{status:400,data:{error:{code:"invalid_request",message:J}}},view:{}}}}async function SZ(J,$){try{return await J.upload($)}catch(Q){if(Q instanceof aZ&&A9.has(Q.status))throw new Q8(a(Q).message);throw Q}}var A9=new Set([400,413,415,422]);class f$ extends gJ{constructor(J,$){super($);this.name="LimitedUploadError",this.payload={api:{status:422,data:{error:{code:J,message:$}}},view:{}}}}function R9(J,$,Q,Z){if(!J)return null;let{maxBytes:W,accept:K}=J;if(typeof W==="number"&&$.size>W)return{code:"file_too_large",message:`${JSON.stringify(Q)} is ${AZ($.size)}; the limit is ${AZ(W)}.`};if(K&&K.length>0&&!K.some((X)=>E9(X,Q,Z)))return{code:"unsupported_file_type",message:`${JSON.stringify(Q)} is not a type this chat accepts. Accepted: ${K.join(", ")}.`};return null}function E9(J,$,Q){let Z=J.trim().toLowerCase();if(!Z)return!1;if(Z.startsWith("."))return $.toLowerCase().endsWith(Z);let W=Q.toLowerCase().split(";")[0].trim();if(Z.endsWith("/*"))return W.startsWith(Z.slice(0,-1));return W===Z}function AZ(J){if(J<1024)return`${J} B`;let $=["KB","MB","GB"],Q=J/1024,Z=0;while(Q>=1024&&Z<$.length-1)Q/=1024,Z++;return`${Math.round(Q*10)/10} ${$[Z]}`}class Q8 extends gJ{constructor(J){super(J);this.name="RejectedUploadError";let $=/(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:$,message:J}}},view:{}}}}async function JJ(J,$){let Q=J?.rawRequest;if(!Q||Q.method==="GET"||Q.method==="HEAD"||!Q.body)return{body:{}};if(!k9(Q.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(Q.headers.get("Content-Length"));if(Number.isFinite(Z)&&Z>$)return RZ($);let W;try{let X=await T9(Q,$);if(X===null)return RZ($);W=X}catch{return{body:{},error:"The request body could not be read."}}if(!W.trim())return{body:{}};let K;try{K=JSON.parse(W)}catch{return{body:{},error:"The request body is not valid JSON."}}if(K===null||typeof K!=="object"||Array.isArray(K))return{body:{},error:"The request body must be a JSON object."};return{body:K}}function k9(J){return yZ(J)==="application/json"}async function T9(J,$){if(!Number.isFinite($)||!J.body)return await J.text();let Q=J.body.getReader(),Z=[],W=0;for(;;){let{done:G,value:V}=await Q.read();if(G)break;if(W+=V.byteLength,W>$)return await Q.cancel().catch($J),null;Z.push(V)}let K=new Uint8Array(W),X=0;for(let G of Z)K.set(G,X),X+=G.byteLength;return new TextDecoder().decode(K)}function RZ(J){return{body:{},status:413,code:"body_too_large",error:`The request body is larger than this agent accepts (${J} bytes).`}}function b$(J,$,Q){return B(J,{...uJ(bZ(J),Q,J),code:$})}function l(J){if(J.status===413)return b$(413,J.code??"body_too_large",J.error??"");return B(J.status??400,{code:J.code??"invalid_request",message:J.error})}function Z8(J){return Boolean(J.turn)&&typeof J.turn==="object"}function j9(J){let $=Z8(J)?J.turn:J,Q={};if(typeof $.text==="string")Q.text=$.text;if(Array.isArray($.files)){let Z=x9($.files);if(typeof Z==="string")return{error:Z};Q.files=Z}if(Array.isArray($.toolResults))Q.toolResults=$.toolResults;if(Object.keys(Q).length===0)return{};if($===J.turn&&$.localId!==void 0&&$.localId!==null&&$.localId!==""){let{localId:Z}=$;if(typeof Z!=="string")return{error:"turn.localId must be a string."};if(Z.length>EZ)return{error:`turn.localId is longer than ${EZ} characters.`};Q.localId=Z}return{turn:Q}}var EZ=200;function x9(J){let $=[];for(let[Q,Z]of J.entries()){let W=`turn.files[${Q}]`;if(!Z||typeof Z!=="object"||Array.isArray(Z))return`${W} must be an object.`;let K={};for(let z of["fileId","attachmentId","name","mimeType"]){let D=Z[z];if(D===void 0||D===null||D==="")continue;if(typeof D!=="string")return`${W}.${z} must be a string.`;K[z]=D}let{fileId:X,attachmentId:G,name:V,mimeType:Y}=K;if(X?.startsWith(bJ))return`${W}.fileId holds a gemi attachment id (${X}). \`fileId\` is the provider's id from the upload response; put this one in \`attachmentId\`.`;if(G!==void 0&&!G.startsWith(bJ))return`${W}.attachmentId is not a gemi attachment id: it must start with "${bJ}".`;if(!X&&!G)return`${W} has neither a \`fileId\` nor an \`attachmentId\`. Send the ids the upload response answered.`;$.push({...X?{fileId:X}:{},...G?{attachmentId:G}:{},...V!==void 0?{name:V}:{},...Y!==void 0?{mimeType:Y}:{}})}return $}function I9(J,$){if(typeof $.from==="number"&&Number.isFinite($.from))return Math.max(0,Math.floor($.from));if(typeof $.cursor==="number"&&Number.isFinite($.cursor)){let Z=Math.floor($.cursor);if(Z>=0)return Z+1;return}let Q=J?.rawRequest?.headers?.get("Last-Event-ID");if(Q){let Z=Number.parseInt(Q,10);if(Number.isFinite(Z))return Math.max(0,Z+1)}return}function kZ(J,$){let Q=J?.search?.get($);return typeof Q==="string"?Q:void 0}function w9(J){let $=g$(J);for(let Q=J.length-1;Q>=0;Q--){let Z=J[Q];if(Z.role!=="user"||$.has(Z.id))continue;let W="",K=[];for(let X of Z.content){if(X.type==="text")W+=X.text;if(X.type==="file")K.push({...X.fileId?{fileId:X.fileId}:{},...X.attachmentId?{attachmentId:X.attachmentId}:{},...X.name?{name:X.name}:{},...X.mimeType?{mimeType:X.mimeType}:{}})}if(!W&&K.length===0)continue;return{index:Q,turn:{...W?{text:W}:{},...K.length>0?{files:K}:{}}}}return null}function TZ(){return B(409,{code:"stopped",message:"The turn was stopped before it started."})}function q9(J){let $=J.event;if(J.text!==void 0||J.turn!==void 0)throw TypeError("AgentController.startTurn takes an `event` or a `text`/`turn`, not both: an event is not a person's message.");if(typeof $!=="object"||$===null||typeof $.name!=="string"||!H9.test($.name))throw TypeError('AgentController.startTurn\'s `event.name` must be letters, digits and `.`, `_`, `:`, `-` (at most 64), like "job-settled".');if($.text!==void 0&&typeof $.text!=="string")throw TypeError("AgentController.startTurn's `event.text` must be a string.");let Q;if($.data!==void 0)try{Q=JSON.parse(JSON.stringify($.data))}catch(Z){throw TypeError(`AgentController.startTurn's \`event.data\` is not JSON: ${String(Z)}`)}return{name:$.name,...$.text?{text:$.text}:{},...Q!==void 0?{data:Q}:{}}}function jZ(J){return B(409,{code:J8,message:`Thread ${J} has a run going, and this turn was not to interrupt it.`})}function FJ(){return B(403,uJ("permission","This run belongs to someone else.",403))}function f9(){return B(403,uJ("permission","A file in this turn was uploaded by someone else.",403))}function b9(J){if(!Array.isArray(J))return[];let $=[];for(let Q of J){let Z=Q?.content;if(!Array.isArray(Z))continue;for(let W of Z)if(W&&typeof W==="object"&&typeof W.fileId==="string")$.push({fileId:W.fileId})}return $}var y9=["sdp","threadId","pushToTalk"];function j$(){return B(404,{code:"voice_not_enabled",message:"This agent has no voice: set `voice` on its controller."})}function B(J,$){return new Response(JSON.stringify({error:$}),{status:J,headers:{"Content-Type":"application/json"}})}function v9(J,$){if(typeof $!=="string"||$.length===0)return J;if($!=="both"&&$!=="provider"&&$!=="storage")throw Error(`Unknown attachment destination "${$}". Expected "both", "provider" or "storage".`);if($===J||J==="both"&&$==="storage")return $;if(J==="both"&&$==="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 "${$}" 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 xZ=!1;function h9(){if(xZ)return;xZ=!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 g9=2147483647;function u9(J,$){let Q=J.then(()=>{},()=>{});if(!($<=g9))return Q;let Z,W=new Promise((K)=>{Z=setTimeout(K,$)});return Promise.race([Q,W]).finally(()=>clearTimeout(Z))}var IZ=!1;function c9(J){if(IZ||Bun.env.NODE_ENV!=="production")return;if(!(J instanceof y$))return;IZ=!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 p9(J){return J.some(($)=>$.content.some((Q)=>Q.type==="tool-result"&&Q.status==="running"))}function wZ(J,$){if(typeof $!=="string"||$==="")throw TypeError("A store scope is a non-empty string.");if(!J.forScope)throw Error("This controller's store cannot be scoped: storeScope() or a turn's `scope` needs a store that implements `forScope` (DatabaseAgentStore or MemoryAgentStore).");return J.forScope($)}function qZ(J,$=!1){if($)return new Response(null,{status:204});return B(404,{code:"no_live_run",message:`No run in progress for thread ${J} in this process.`})}export{r9 as windowMessages,YJ as voiceTools,n9 as turnStarts,_6 as toRealtimeUsage,x8 as toAgentTools,i9 as supportsStrict,o9 as splitTurns,K6 as settleSummaries,l9 as s,h$ as redactError,O6 as parsePartialJson,s9 as messageSize,XJ as measureUsage,P$ as mcpVoiceTools,C$ as liveRuns,zJ as keepSummary,B6 as isCallNotFound,g$ as injectedMessageIds,Q$ as generate,c8 as evalChain,B9 as defineAgentHooks,F$ as defaultVoiceStore,G6 as defaultUsageLimitStore,W6 as defaultSummaryStore,F6 as defaultPromptCacheKey,v$ as defaultNonceStore,_$ as defaultFileOwners,pJ as defaultAttachmentStore,A$ as defaultAgentStore,IJ as VoiceHangup,m as VoiceBridge,d9 as Usage,W$ as ToolNamespace,p as ToolError,P6 as ToolArgumentsTooLongError,V6 as Skill,cJ as ScopedAttachments,z6 as SKILLS_NAMESPACE,S$ as RedisReceiptStore,pZ as RedisNonceStore,U6 as RealtimeSideband,u$ as RealtimeRequestError,L6 as RealtimeClient,a$ as Prompt,mZ as PrismaNonceStore,Y6 as PendingEscalation,M6 as OpenAIProvider,Y$ as OpenAIImageProvider,N$ as MemoryVoiceSessionStore,X6 as MemoryUsageLimitStore,Z6 as MemorySummaryStore,M$ as MemoryReceiptStore,y$ as MemoryNonceStore,wJ as MemoryLiveRuns,qJ as MemoryFileOwners,jJ as MemoryCircuitStore,sZ as MemoryAttachmentStore,HJ as MemoryAgentStore,ZQ as MemoryAgentJobStore,LQ as MEMORY_NAMESPACE,DJ as LiveRunNotFoundError,KQ as JobsRequireThreadError,WQ as JobHandle,m9 as JSONSchemaError,dZ as InvalidAttachmentScopeError,NQ as InMemoryAgentMemoryStore,kJ as ImageRequestError,TJ as ImageProvider,K$ as ImageModel,r as FrameCursorEvictedError,GJ as FallbackProvider,CQ as FakeAgentMemoryStore,RJ as Eval,O$ as DatabaseAgentStore,aJ as DatabaseAgentMemoryStore,oJ as DatabaseAgentJobStore,C6 as DEFAULT_TRANSCRIPTION_MODEL,PQ as DEFAULT_MEMORY_MAX_TOKENS,_Q as DEFAULT_MEMORY_LIMITS,e9 as DEFAULT_MAX_SUMMARY_TOKENS,D6 as DEFAULT_MAX_RUN_DURATION_MS,XQ as DEFAULT_JOB_DEADLINE_MS,BJ as DEFAULT_JOBS_CONTEXT_MAX,VJ as DEFAULT_DELEGATE_NAME,a9 as DEFAULT_CONTEXT_WINDOW_STEP,t9 as DEFAULT_CONTEXT_WINDOW_NOTE,J6 as DEFAULT_COMPACT_TRIGGER_TOKENS,$6 as DEFAULT_COMPACT_INSTRUCTIONS,Q6 as COMPACT_SUMMARY_HEADER,R6 as AzureOpenAIProvider,V$ as AzureOpenAIImageProvider,A6 as AzureAnthropicProvider,iZ as AttachmentNotFoundError,S6 as AnthropicProvider,mJ as AgentTurnError,EJ as AgentTool,H6 as AgentRunError,H$ as AgentProvider,FQ as AgentMemoryRefusedError,OQ as AgentMemoryConflictError,UQ as AgentMemories,g as AgentJobs,nJ as AgentJobDeadlineSweep,GQ as AgentJob,hJ as AgentController,N6 as Agent};
301
301
 
302
- //# debugId=FEB40C65B13A821B64756E2164756E21
302
+ //# debugId=2BB92C633058E7BC64756E2164756E21