gemi 0.160.2 → 0.162.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.
- package/dist/ai/index.js +2 -2
- package/dist/ai/index.js.map +1 -1
- package/dist/app/App.d.ts +5 -0
- package/dist/app/App.d.ts.map +1 -1
- package/dist/app/index.js +2 -2
- package/dist/app/index.js.map +1 -1
- package/dist/auth/config.d.ts +3 -2
- package/dist/auth/config.d.ts.map +1 -1
- package/dist/auth/routes.d.ts +20 -42
- package/dist/auth/routes.d.ts.map +1 -1
- package/dist/bin/gemi.js +8 -1
- package/dist/bin/gemi.js.map +3 -3
- package/dist/bun/plugin.js +2 -2
- package/dist/bun/plugin.js.map +1 -1
- package/dist/bun/preload.js +2 -2
- package/dist/bun/preload.js.map +1 -1
- package/dist/{chunk-4vqnv41y.js → chunk-04ffq2ge.js} +2 -2
- package/dist/{chunk-4vqnv41y.js.map → chunk-04ffq2ge.js.map} +1 -1
- package/dist/{chunk-27habdva.js → chunk-04h49y2f.js} +2 -2
- package/dist/{chunk-27habdva.js.map → chunk-04h49y2f.js.map} +1 -1
- package/dist/{chunk-fcjjd162.js → chunk-10zbxbwk.js} +2 -2
- package/dist/{chunk-fcjjd162.js.map → chunk-10zbxbwk.js.map} +1 -1
- package/dist/{chunk-cxz7wycm.js → chunk-17s187yp.js} +4 -4
- package/dist/{chunk-cxz7wycm.js.map → chunk-17s187yp.js.map} +3 -3
- package/dist/{chunk-8tyw6faf.js → chunk-1btx3kkv.js} +2 -2
- package/dist/{chunk-8tyw6faf.js.map → chunk-1btx3kkv.js.map} +1 -1
- package/dist/{chunk-bfj2jafb.js → chunk-1cjr8hvc.js} +3 -3
- package/dist/{chunk-bfj2jafb.js.map → chunk-1cjr8hvc.js.map} +2 -2
- package/dist/{chunk-9f2ps5v2.js → chunk-22jm6sn1.js} +2 -2
- package/dist/{chunk-9f2ps5v2.js.map → chunk-22jm6sn1.js.map} +1 -1
- package/dist/{chunk-4ye6p5yk.js → chunk-2hhwsm69.js} +2 -2
- package/dist/{chunk-4ye6p5yk.js.map → chunk-2hhwsm69.js.map} +1 -1
- package/dist/{chunk-wtddr3vs.js → chunk-3tyqnh59.js} +2 -2
- package/dist/{chunk-wtddr3vs.js.map → chunk-3tyqnh59.js.map} +1 -1
- package/dist/{chunk-m4pkbndk.js → chunk-51fvpq55.js} +2 -2
- package/dist/{chunk-m4pkbndk.js.map → chunk-51fvpq55.js.map} +1 -1
- package/dist/{chunk-k43m5dvs.js → chunk-576g6eyk.js} +2 -2
- package/dist/{chunk-k43m5dvs.js.map → chunk-576g6eyk.js.map} +1 -1
- package/dist/{chunk-cn6dteec.js → chunk-5sd49vwm.js} +4 -4
- package/dist/{chunk-cn6dteec.js.map → chunk-5sd49vwm.js.map} +4 -3
- package/dist/{chunk-3cvza61a.js → chunk-6w2v33bd.js} +2 -2
- package/dist/{chunk-3cvza61a.js.map → chunk-6w2v33bd.js.map} +1 -1
- package/dist/{chunk-p9syxzxh.js → chunk-70kpm72z.js} +3 -3
- package/dist/{chunk-p9syxzxh.js.map → chunk-70kpm72z.js.map} +1 -1
- package/dist/{chunk-qbsk0jr8.js → chunk-7effp39a.js} +2 -2
- package/dist/{chunk-qbsk0jr8.js.map → chunk-7effp39a.js.map} +1 -1
- package/dist/{chunk-57qnqcrp.js → chunk-7ex7aczc.js} +3 -3
- package/dist/{chunk-57qnqcrp.js.map → chunk-7ex7aczc.js.map} +1 -1
- package/dist/{chunk-r3v2cnrj.js → chunk-7txst143.js} +2 -2
- package/dist/{chunk-r3v2cnrj.js.map → chunk-7txst143.js.map} +1 -1
- package/dist/{chunk-v8fx4vgq.js → chunk-89168m0z.js} +2 -2
- package/dist/{chunk-v8fx4vgq.js.map → chunk-89168m0z.js.map} +1 -1
- package/dist/{chunk-fcqx2t0p.js → chunk-8m9kgynj.js} +2 -2
- package/dist/{chunk-fcqx2t0p.js.map → chunk-8m9kgynj.js.map} +1 -1
- package/dist/{chunk-m8a80sgn.js → chunk-8x0q9h0j.js} +3 -3
- package/dist/{chunk-m8a80sgn.js.map → chunk-8x0q9h0j.js.map} +1 -1
- package/dist/{chunk-7rfw4h2x.js → chunk-95gag2pg.js} +2 -2
- package/dist/{chunk-7rfw4h2x.js.map → chunk-95gag2pg.js.map} +1 -1
- package/dist/{chunk-7bc9ypbk.js → chunk-99be7vbh.js} +3 -3
- package/dist/{chunk-7bc9ypbk.js.map → chunk-99be7vbh.js.map} +1 -1
- package/dist/{chunk-kan3yz82.js → chunk-a5htej1f.js} +2 -2
- package/dist/{chunk-kan3yz82.js.map → chunk-a5htej1f.js.map} +1 -1
- package/dist/chunk-a5qn2sq8.js +4 -0
- package/dist/chunk-a5qn2sq8.js.map +10 -0
- package/dist/{chunk-ctrmztan.js → chunk-akgd3c0k.js} +2 -2
- package/dist/{chunk-ctrmztan.js.map → chunk-akgd3c0k.js.map} +1 -1
- package/dist/{chunk-vb73ddwz.js → chunk-asnk2jqn.js} +2 -2
- package/dist/{chunk-vb73ddwz.js.map → chunk-asnk2jqn.js.map} +1 -1
- package/dist/{chunk-a22h5cby.js → chunk-bwg7genv.js} +2 -2
- package/dist/{chunk-a22h5cby.js.map → chunk-bwg7genv.js.map} +1 -1
- package/dist/{chunk-j144nwvh.js → chunk-cd847h0t.js} +3 -3
- package/dist/{chunk-j144nwvh.js.map → chunk-cd847h0t.js.map} +1 -1
- package/dist/{chunk-664ewdjv.js → chunk-dj6bw2jm.js} +3 -3
- package/dist/{chunk-664ewdjv.js.map → chunk-dj6bw2jm.js.map} +2 -2
- package/dist/{chunk-s0xwqcrf.js → chunk-dkmf4eg1.js} +3 -3
- package/dist/{chunk-s0xwqcrf.js.map → chunk-dkmf4eg1.js.map} +1 -1
- package/dist/{chunk-5qzxyj68.js → chunk-dwxgr189.js} +1 -1
- package/dist/{chunk-79nypedr.js → chunk-e0w1mf72.js} +3 -3
- package/dist/{chunk-79nypedr.js.map → chunk-e0w1mf72.js.map} +1 -1
- package/dist/{chunk-csvffxjh.js → chunk-e9c02bq0.js} +3 -3
- package/dist/{chunk-csvffxjh.js.map → chunk-e9c02bq0.js.map} +1 -1
- package/dist/{chunk-szdbsmq7.js → chunk-egzfxdr1.js} +2 -2
- package/dist/{chunk-szdbsmq7.js.map → chunk-egzfxdr1.js.map} +1 -1
- package/dist/{chunk-yzw2tvqq.js → chunk-fv1r0w0r.js} +2 -2
- package/dist/{chunk-yzw2tvqq.js.map → chunk-fv1r0w0r.js.map} +1 -1
- package/dist/chunk-fy55jd2h.js +58 -0
- package/dist/{chunk-hxe06cgw.js.map → chunk-fy55jd2h.js.map} +3 -3
- package/dist/{chunk-d249m2ct.js → chunk-fyyf44aj.js} +2 -2
- package/dist/{chunk-d249m2ct.js.map → chunk-fyyf44aj.js.map} +1 -1
- package/dist/{chunk-gmeeyg19.js → chunk-g3sryyn4.js} +2 -2
- package/dist/{chunk-gmeeyg19.js.map → chunk-g3sryyn4.js.map} +1 -1
- package/dist/{chunk-rq3wrwfa.js → chunk-g3vasg0d.js} +1 -1
- package/dist/{chunk-qsbtqh47.js → chunk-gcxk8j84.js} +3 -3
- package/dist/{chunk-qsbtqh47.js.map → chunk-gcxk8j84.js.map} +1 -1
- package/dist/{chunk-1xxh48bd.js → chunk-gn8ee1dp.js} +2 -2
- package/dist/{chunk-1xxh48bd.js.map → chunk-gn8ee1dp.js.map} +1 -1
- package/dist/{chunk-0vb4j7cx.js → chunk-h4h8m3yr.js} +3 -3
- package/dist/{chunk-0vb4j7cx.js.map → chunk-h4h8m3yr.js.map} +1 -1
- package/dist/chunk-hdr0m0md.js +5 -0
- package/dist/{chunk-0qrbspbe.js.map → chunk-hdr0m0md.js.map} +1 -1
- package/dist/{chunk-ryq2ezgt.js → chunk-hkp00b9x.js} +3 -3
- package/dist/{chunk-ryq2ezgt.js.map → chunk-hkp00b9x.js.map} +1 -1
- package/dist/{chunk-5pc21syf.js → chunk-hx8vkwsb.js} +2 -2
- package/dist/{chunk-5pc21syf.js.map → chunk-hx8vkwsb.js.map} +1 -1
- package/dist/chunk-jqzymm6j.js +24 -0
- package/dist/{chunk-d3195ypx.js.map → chunk-jqzymm6j.js.map} +3 -3
- package/dist/{chunk-cq16azbw.js → chunk-jry03jqj.js} +4 -4
- package/dist/{chunk-cq16azbw.js.map → chunk-jry03jqj.js.map} +1 -1
- package/dist/{chunk-qz9n2e59.js → chunk-k5xxwr5h.js} +2 -2
- package/dist/{chunk-qz9n2e59.js.map → chunk-k5xxwr5h.js.map} +1 -1
- package/dist/{chunk-p6nkfcn1.js → chunk-kqbnsthz.js} +2 -2
- package/dist/{chunk-p6nkfcn1.js.map → chunk-kqbnsthz.js.map} +1 -1
- package/dist/{chunk-w0rfypzx.js → chunk-kscwjycy.js} +2 -2
- package/dist/{chunk-w0rfypzx.js.map → chunk-kscwjycy.js.map} +1 -1
- package/dist/{chunk-pyyhmeg1.js → chunk-kt83h150.js} +3 -3
- package/dist/{chunk-pyyhmeg1.js.map → chunk-kt83h150.js.map} +1 -1
- package/dist/{chunk-msxhf3m6.js → chunk-m683535s.js} +3 -3
- package/dist/{chunk-msxhf3m6.js.map → chunk-m683535s.js.map} +1 -1
- package/dist/{chunk-98byy5m4.js → chunk-mg5gq632.js} +1 -1
- package/dist/{chunk-2ednvght.js → chunk-mqbx7hc4.js} +2 -2
- package/dist/{chunk-2ednvght.js.map → chunk-mqbx7hc4.js.map} +1 -1
- package/dist/{chunk-epvpmakp.js → chunk-mvd4mc8p.js} +2 -2
- package/dist/{chunk-epvpmakp.js.map → chunk-mvd4mc8p.js.map} +1 -1
- package/dist/{chunk-g71ppv6x.js → chunk-mxhy19a9.js} +2 -2
- package/dist/{chunk-g71ppv6x.js.map → chunk-mxhy19a9.js.map} +1 -1
- package/dist/{chunk-3d8jxky6.js → chunk-n3pc62tc.js} +3 -3
- package/dist/{chunk-3d8jxky6.js.map → chunk-n3pc62tc.js.map} +1 -1
- package/dist/{chunk-8z29qvvm.js → chunk-n6ywagxv.js} +2 -2
- package/dist/{chunk-8z29qvvm.js.map → chunk-n6ywagxv.js.map} +1 -1
- package/dist/{chunk-191gkynh.js → chunk-nc1gstvq.js} +3 -3
- package/dist/{chunk-191gkynh.js.map → chunk-nc1gstvq.js.map} +1 -1
- package/dist/chunk-p4ka241x.js +5 -0
- package/dist/{chunk-bzcfw8qd.js.map → chunk-p4ka241x.js.map} +3 -3
- package/dist/{chunk-0qernzn1.js → chunk-pfjky33c.js} +2 -2
- package/dist/{chunk-0qernzn1.js.map → chunk-pfjky33c.js.map} +1 -1
- package/dist/{chunk-3vmc6adw.js → chunk-q4q5mxte.js} +2 -2
- package/dist/{chunk-3vmc6adw.js.map → chunk-q4q5mxte.js.map} +1 -1
- package/dist/{chunk-8m3m5hcf.js → chunk-qttv23e7.js} +3 -3
- package/dist/{chunk-8m3m5hcf.js.map → chunk-qttv23e7.js.map} +1 -1
- package/dist/chunk-qwmw2rrh.js +117 -0
- package/dist/{chunk-jx1crzgg.js.map → chunk-qwmw2rrh.js.map} +7 -7
- package/dist/{chunk-weyv3zrt.js → chunk-r94gpbjv.js} +4 -4
- package/dist/{chunk-weyv3zrt.js.map → chunk-r94gpbjv.js.map} +1 -1
- package/dist/{chunk-tsbxdz4h.js → chunk-rh811v1f.js} +2 -2
- package/dist/{chunk-tsbxdz4h.js.map → chunk-rh811v1f.js.map} +1 -1
- package/dist/{chunk-kk18xqgc.js → chunk-s0z61m9j.js} +2 -2
- package/dist/{chunk-kk18xqgc.js.map → chunk-s0z61m9j.js.map} +1 -1
- package/dist/{chunk-6d6p0q3p.js → chunk-s4nqy979.js} +2 -2
- package/dist/{chunk-6d6p0q3p.js.map → chunk-s4nqy979.js.map} +1 -1
- package/dist/{chunk-0b8m1f07.js → chunk-s7tn2t8x.js} +3 -3
- package/dist/{chunk-0b8m1f07.js.map → chunk-s7tn2t8x.js.map} +1 -1
- package/dist/{chunk-6ytezxzj.js → chunk-s7w7pn80.js} +2 -2
- package/dist/{chunk-6ytezxzj.js.map → chunk-s7w7pn80.js.map} +1 -1
- package/dist/{chunk-xp7x27n8.js → chunk-vqar6ysw.js} +3 -3
- package/dist/{chunk-xp7x27n8.js.map → chunk-vqar6ysw.js.map} +1 -1
- package/dist/{chunk-5c6dfy75.js → chunk-wamxfhh6.js} +2 -2
- package/dist/{chunk-5c6dfy75.js.map → chunk-wamxfhh6.js.map} +1 -1
- package/dist/{chunk-egwz89ze.js → chunk-wgre66wq.js} +2 -2
- package/dist/{chunk-egwz89ze.js.map → chunk-wgre66wq.js.map} +1 -1
- package/dist/{chunk-bqxt1she.js → chunk-xzbhy9n5.js} +1 -1
- package/dist/{chunk-jarsydtr.js → chunk-xzkr8yck.js} +3 -3
- package/dist/{chunk-jarsydtr.js.map → chunk-xzkr8yck.js.map} +1 -1
- package/dist/{chunk-htbvkr11.js → chunk-y4bjsyt4.js} +3 -3
- package/dist/{chunk-htbvkr11.js.map → chunk-y4bjsyt4.js.map} +1 -1
- package/dist/{chunk-4670xxae.js → chunk-yc2pnb1w.js} +2 -2
- package/dist/{chunk-4670xxae.js.map → chunk-yc2pnb1w.js.map} +1 -1
- package/dist/{chunk-v0gjdknx.js → chunk-yvpgy1p1.js} +2 -2
- package/dist/{chunk-v0gjdknx.js.map → chunk-yvpgy1p1.js.map} +1 -1
- package/dist/{chunk-zz2n9pa5.js → chunk-z2btwd27.js} +3 -3
- package/dist/{chunk-zz2n9pa5.js.map → chunk-z2btwd27.js.map} +1 -1
- package/dist/{chunk-day21sfa.js → chunk-z94ms1jv.js} +3 -3
- package/dist/{chunk-day21sfa.js.map → chunk-z94ms1jv.js.map} +1 -1
- package/dist/{chunk-m73mjzeh.js → chunk-zh0knwen.js} +2 -2
- package/dist/{chunk-m73mjzeh.js.map → chunk-zh0knwen.js.map} +1 -1
- package/dist/{chunk-9983zmhx.js → chunk-zzgzz4hb.js} +3 -3
- package/dist/{chunk-9983zmhx.js.map → chunk-zzgzz4hb.js.map} +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/console/run.js +2 -2
- package/dist/console/run.js.map +1 -1
- package/dist/container/index.js +2 -2
- package/dist/container/index.js.map +1 -1
- package/dist/database/index.js +2 -2
- package/dist/database/index.js.map +1 -1
- package/dist/email/index.js +2 -2
- package/dist/email/index.js.map +1 -1
- package/dist/facades/index.js +2 -2
- package/dist/facades/index.js.map +1 -1
- package/dist/foundation/index.js +2 -2
- package/dist/foundation/index.js.map +1 -1
- package/dist/http/Metadata.d.ts +29 -1
- package/dist/http/Metadata.d.ts.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +1 -1
- package/dist/i18n/dictionaryRuntime.js +2 -2
- package/dist/i18n/dictionaryRuntime.js.map +1 -1
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/index.js.map +1 -1
- package/dist/kernel/index.js +2 -2
- package/dist/kernel/index.js.map +1 -1
- package/dist/orm/index.js +2 -2
- package/dist/orm/index.js.map +1 -1
- package/dist/probe/index.js +2 -2
- package/dist/probe/index.js.map +1 -1
- package/dist/server/devFetch.d.ts.map +1 -1
- package/dist/server/httpProd.d.ts.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/server/requiredViews.d.ts +7 -0
- package/dist/server/requiredViews.d.ts.map +1 -0
- package/dist/services/index.js +2 -2
- package/dist/services/index.js.map +1 -1
- package/dist/services/queue/work.js +2 -2
- package/dist/services/queue/work.js.map +1 -1
- package/dist/services/router/DomainRouter.d.ts +3 -0
- package/dist/services/router/DomainRouter.d.ts.map +1 -1
- package/dist/services/router/RouteServiceProvider.d.ts.map +1 -1
- package/dist/services/router/ViewRouteDispatcher.d.ts +14 -1
- package/dist/services/router/ViewRouteDispatcher.d.ts.map +1 -1
- package/dist/services/router/config.d.ts +15 -1
- package/dist/services/router/config.d.ts.map +1 -1
- package/dist/stats/route-table.js +1 -1
- package/dist/support/index.js +2 -2
- package/dist/support/index.js.map +1 -1
- package/dist/vitest/index.js +2 -2
- package/dist/vitest/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-0qrbspbe.js +0 -5
- package/dist/chunk-982x8jps.js +0 -4
- package/dist/chunk-982x8jps.js.map +0 -10
- package/dist/chunk-bzcfw8qd.js +0 -5
- package/dist/chunk-d3195ypx.js +0 -24
- package/dist/chunk-hxe06cgw.js +0 -58
- package/dist/chunk-jx1crzgg.js +0 -117
- /package/dist/{chunk-5qzxyj68.js.map → chunk-dwxgr189.js.map} +0 -0
- /package/dist/{chunk-rq3wrwfa.js.map → chunk-g3vasg0d.js.map} +0 -0
- /package/dist/{chunk-98byy5m4.js.map → chunk-mg5gq632.js.map} +0 -0
- /package/dist/{chunk-bqxt1she.js.map → chunk-xzbhy9n5.js.map} +0 -0
package/dist/ai/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$c as
|
|
2
|
+
import{$b as rQ,$c as w0,Ac as g8,Bc as u8,Cc as N$,Ec as O$,Fc as S$,Gc as C$,Hc as _$,Ic as M$,Jc as A$,Kc as R$,Lc as T$,Mc as E$,Nc as j$,Oc as k$,Pc as q$,Rc as w,Sc as t$,Tc as n,Uc as E,Vc as J$,Wc as j0,Xc as k0,Yb as tQ,Yc as q0,Zb as W9,Zc as x0,_b as K9,_c as I0,ad as b0,bd as f0,cc as TJ,cd as v0,dc as S,dd as y0,ec as A,ed as h0,fd as mQ,gc as n$,gd as g0,hc as c$,hd as D9,ic as ZJ,id as u0,jc as E0,jd as c0,kc as g,kd as MJ,lc as eQ,ld as VQ,mc as X9,md as m0,nc as G9,nd as p0,oc as Y9,od as l0,pc as m,pd as d0,qc as V9,qd as i0,rc as lJ,rd as GQ,sc as H9,tc as z9,uc as dJ,vc as F$,wc as P$,yc as B$,zc as v}from"../chunk-y4bjsyt4.js";import{Jd as G$}from"../chunk-3tyqnh59.js";import"../chunk-nc1gstvq.js";import{$h as x,Eh as e8,Fi as $9,Hh as Q9,Ii as gQ,Mi as Z9,Xh as O8,Yh as A0,Zh as R0,_h as T0}from"../chunk-s7tn2t8x.js";import{Ni as J9,Pi as mJ,Qi as pJ}from"../chunk-kscwjycy.js";import{Zi as h}from"../chunk-p4ka241x.js";import"../chunk-1btx3kkv.js";import"../chunk-rh811v1f.js";import"../chunk-wamxfhh6.js";import{ak as LJ,bk as UJ,pk as D$}from"../chunk-cd847h0t.js";import"../chunk-zh0knwen.js";import{cl as k8}from"../chunk-vqar6ysw.js";import"../chunk-mxhy19a9.js";import"../chunk-yc2pnb1w.js";import"../chunk-7effp39a.js";import"../chunk-wgre66wq.js";import{readFileSync as U9}from"fs";import{isAbsolute as C9,join as nJ}from"path";var _9=/\{\{>\s*([\w./-]+)\s*\}\}/g,Z$=/\{\{(\w+)\}\}/g,M9=/^[\w-]+(\/[\w-]+)*$/,W$={dir:"app/agents",shared:"prompts"},PJ={},oJ=new Map;function K$(){return PJ.cache??Bun.env.NODE_ENV==="production"}function S9(J){if(!M9.test(J))throw Error(`"${J}" is not a prompt name. Use letters, digits, "-" and "_", with "/" between folders.`);let Q=PJ.dir??W$.dir,$=C9(Q)?Q:nJ(process.cwd(),Q),Z=J.includes("/")?`${J}.md`:nJ(PJ.shared??W$.shared,`${J}.md`);return nJ($,Z)}function A9(J){let Q=S9(J),$=K$()?oJ.get(Q):void 0;if($!==void 0)return $;let Z;try{Z=U9(Q,"utf8").replace(/\r?\n$/,"")}catch(W){if(W.code==="ENOENT")throw Error(`The prompt "${J}" does not exist (looked for ${Q}).`);throw W}if(K$())oJ.set(Q,Z);return Z}function sJ(J,Q){if(Q.includes(J))throw Error(`The prompt "${J}" includes itself: ${[...Q,J].join(" > ")}.`);return A9(J).replace(_9,($,Z)=>sJ(Z,[...Q,J]))}class X${static configure(J){PJ={...J},oJ.clear()}static render(J,Q={}){return sJ(J,[]).replace(Z$,($,Z)=>{if(!Object.hasOwn(Q,Z))throw Error(`The prompt "${J}" has no value for {{${Z}}}.`);return String(Q[Z])})}static placeholders(J){let Q=[...sJ(J,[]).matchAll(Z$)].map(($)=>$[1]);return[...new Set(Q)]}}class aJ extends G${name="AgentJobDeadlineSweep";cron="* * * * *";async callback(){while(await v.sweep({limit:100})===100);}}var BJ=20;function V$(J,Q){if(Q<=0||J.length===0)return null;let $=(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)=>K.state==="running").sort($),...J.filter((K)=>K.state!=="running").sort($)].slice(0,Q).map((K)=>{let X=[`- ${K.id} (${K.toolName})`];if(K.state==="running")X.push(`running since ${tJ(K.createdAt)}`);else if(K.state==="ok")X.push(`finished at ${tJ(K.settledAt??K.updatedAt)}`);else{let Y=K.error?`${K.error.code}: ${Y$(K.error.message,200)}`:"failed";X.push(`failed at ${tJ(K.settledAt??K.updatedAt)} (${Y})`)}if(K.summary!==void 0)X.push(`summary: ${Y$(JSON.stringify(K.summary),300)}`);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 tJ(J){return new Date(J).toISOString().replace(/\.\d{3}Z$/,"Z")}function Y$(J,Q){return J.length<=Q?J:`${J.slice(0,Q-1)}\u2026`}class eJ{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 R9(this.dialect,this.table))await this.sql.unsafe(J)}async transaction(J){if(this.connection===void 0||this.joinable())return J();return D$(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,
|
|
@@ -153,4 +153,4 @@ return 0`;class cQ{injectedClient;prefix;constructor(J={}){this.injectedClient=J
|
|
|
153
153
|
|
|
154
154
|
`)||void 0,L=await this.context(J,{body:V}),U=await this.reasoning(J,{body:V})||void 0,j=await this.skills(J,{body:V})||void 0,k=await this.attachmentsFor(J,Z,{body:V}),I=this.agent.memory?await this.memoryScopes(J,{body:V}):void 0;if(H?.cancelled)return a8();let q=Z?new dQ(this.store,Z,N,(T)=>this.reportHookFailure(T)):null,d=`run_${crypto.randomUUID()}`,_={req:J,runId:d,threadId:Z},R={id:null,notified:Promise.resolve()},C=this.agent.stream({runId:d,messages:N,turn:K,threadId:Z,...q?{onMessage:(T)=>q.finish(T)}:{},onTurn:(T)=>{if(R.id!==null)return;R.id=T.id;let i=q?q.settled():Promise.resolve();R.notified=i.then(()=>this.safely(()=>this.onMessage(T,_)))},instructions:B,...U?{reasoning:U}:{},...j&&j.length>0?{skills:j}:{},context:L,attachments:k,body:V,redactError:(T,i)=>this.redactError(T,i,_),nonces:this.nonces,receipts:this.receipts,subject:G,...I?{memory:{scopes:I,...this.memoryMaxTokens!==void 0?{maxTokens:this.memoryMaxTokens}:{}}}:{},...Z?{jobs:{owner:G}}:{},...this.contextWindow!==void 0?{contextWindow:this.contextWindow}:{},...Z&&D9(this.store)?{summaryStore:this.store}:{},...this.prepareStep!==Q$.prototype.prepareStep||this.hooks?.prepareStep?{prepareStep:(T)=>this.prepareStep(T,_)}:{}}),N9=this.liveRuns.register(C,{threadId:Z,owner:G,clientRunId:Y,onEvent:(T)=>this.dispatchEvent(T,_),onInternalError:(T)=>this.reportHookFailure(T),maxRunDurationMs:this.agent.maxRunDurationMs});if(D=C,q)this.follow(C,q);let{stored:O9,hooks:$$}=this.persistRun(C,_,N9,q,R);if(p8.set(C,O9),zJ.has(J))zJ.set(J,{run:C,hooks:$$});return J.ctx?.()?.waitUntil($$),C.toResponse()};try{await this.authorizeRequest(J,{route:"stream",threadId:Z,body:V});let N=await this.foreignFile([...K?.files??[],...Z?[]:N0($.messages)],G);if(N)return N;if(H?.cancelled)return a8();let P=await this.runLimitKey(J,{owner:G,threadId:Z}),B=P===null?uJ:Q0(this.liveRuns).take(P,Z?`thread:${Z}`:`run:${crypto.randomUUID()}`,this.maxConcurrentRuns);if(!B)return aQ(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,G,F):await F()}finally{let L=D;if(L)L.result().then(B,B);else B()}}finally{if(H&&hJ.get(Y)===H)hJ.delete(Y)}}async withThread(J,Q,$){let Z=yJ.get(J)??Promise.resolve(),W,K=new Promise((Y)=>{W=Y}),X=Z.then(()=>K);yJ.set(J,X),await Z;try{let Y=await this.liveRuns.find({threadId:J});if(Y&&this.liveRuns.isRunning(Y.runId)&&!this.liveRuns.mayAccess(Y.runId,Q))return FJ();let V=Y?this.liveRuns.get(Y.runId):null;if(V)V.stop({reason:"superseded by a later turn on this thread"}),await p8.get(V);return await $()}finally{if(W(),yJ.get(J)===X)yJ.delete(J)}}async attach(J=new x){let Q=await DJ(J,gJ);if(Q.error)return r(Q);let $=Q.body,Z=typeof $.threadId==="string"?$.threadId:F0(J,"threadId");if(!Z)return M(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 FJ();if(!W)return M(404,{code:"no_live_run",message:`No run in progress for thread ${Z} in this process.`});let K=typeof $.runId==="string"?$.runId:void 0,X=K&&K!==W.runId?void 0:D0(J,$);try{return Z9(this.liveRuns.replay(W.runId,X))}catch(Y){if(Y instanceof t)return M(410,{code:Y.code,message:Y.message,oldestSeq:Y.oldest});if(Y instanceof HJ)return M(404,{code:Y.code,message:Y.message});throw Y}}async stop(J=new x){let Q=await DJ(J,gJ);if(Q.error)return r(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 X=hJ.get($.clientRunId);if(X){if(X.owner!==null&&X.owner!==Z)return FJ();return X.cancelled=!0,{stopped:!0}}}}if(!W&&typeof $.threadId==="string")W=(await this.liveRuns.find({threadId:$.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 $.reason==="string"?$.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(Q)return{key:`thread:${Q}`};return null}attachmentLimits(J){let Q=this.hooks?.attachmentLimits;if(Q)return Q(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 lJ(this.attachments,this.attachmentStorage,Z)}async voiceStart(J=new x){let Q=this.voice;if(!Q)return iQ();let $=await DJ(J,gJ);if($.error)return r($);let{sdp:Z,threadId:W,pushToTalk:K}=$.body;if(typeof Z!=="string"||!Z.trimStart().startsWith("v="))return M(400,{code:"invalid_request",message:"`sdp` must be the browser's SDP offer."});let X=cJ($.body,O0),Y=typeof W==="string"&&W!==""?W:void 0;await this.authorizeRequest(J,{route:"stream",threadId:Y,body:X});let V=J.ctx?.()?.user??null,G=await Q.start({req:J,body:X,threadId:Y,user:V,pushToTalk:K===!0}),H=Date.now(),D,z=async(L)=>{if(L!==void 0)console.error("[gemi/ai] a voice session could not start.",L);if(D)await Q.realtime.hangup(D).catch((U)=>{console.error("[gemi/ai] a voice call that failed to start could not be hung up.",U)});try{await G.onEnd?.({sessionId:"",...D?{callId:D}:{},threadId:G.threadId??Y??"",reason:"start_failed",startedAt:H,endedAt:Date.now(),durationMs:0,seconds:0,usage:S(),transcription:{usage:S(),seconds:0},transcript:[],requests:[],toolCalls:[],errors:[]})}catch(U){console.error("[gemi/ai] a voice session's onEnd threw.",U)}},F=G.threadId??Y;if(!F)return await z(void 0),M(400,{code:"invalid_request",message:"A voice session needs a thread: send `threadId`, or answer one from `voice.start`."});try{if(F!==Y)await this.authorizeRequest(J,{route:"stream",threadId:F,body:X})}catch(L){throw await z(void 0),L}let O=crypto.randomUUID(),N=G.tools??[];try{if(G.mcp)N=[...N,...await IQ(G.mcp,{user:V,sessionId:O})]}catch(L){return await z(L),M(500,{code:"voice_unavailable",message:"Voice isn't available right now."})}let P={...G.session,tools:[...YJ(Q.delegate),...G.session?.tools??[],...N.map((L)=>L.tool)],...K===!0?{turnDetection:null}:{}},B;try{B=await Q.realtime.createCall({sdp:Z,session:P,safetyIdentifier:G.safetyIdentifier})}catch(L){await z(L);let U=L instanceof f&&L.code==="rate_limited";return M(U?429:502,{code:"voice_unavailable",message:"Voice isn't available right now."})}D=B.callId;try{await this.voiceStore.create({id:O,callId:B.callId,threadId:F,owner:await this.runOwner(J),body:X,startedAt:H});let{threadId:L,session:U,safetyIdentifier:j,mcp:k,tools:I,...q}=G;return{sessionId:p.start({...q,tools:N,controller:this.constructor,threadId:F,user:V,body:X,call:{realtime:Q.realtime,callId:B.callId},sessionId:O,store:this.voiceStore,liveRuns:this.liveRuns,delegate:Q.delegate,session:P}).sessionId,sdp:B.sdpAnswer,threadId:F,delegate:Q.delegate?.name??VJ,endsAt:H+(G.limits?.maxDurationMs??900000)}}catch(L){return await z(L),M(500,{code:"voice_unavailable",message:"Voice isn't available right now."})}}async voiceUpdate(J=new x){if(!this.voice)return iQ();let Q=await this.voiceSession(J);if(Q instanceof Response)return Q;let $=await DJ(J,gJ);if($.error)return r($);let Z=cJ($.body,[]);if(await this.authorizeRequest(J,{route:"stream",threadId:Q.threadId,body:Z}),Q.endedAt!==void 0)return M(409,{code:"voice_ended",message:"This voice session has ended."});return await this.voiceStore.update(Q.id,{body:Z}),p.get(Q.id)?.setBody(Z),{updated:!0}}async voiceEnd(J=new x){let Q=this.voice;if(!Q)return iQ();let $=await this.voiceSession(J);if($ instanceof Response)return $;if(await this.authorizeRequest(J,{route:"stream",threadId:$.threadId,body:$.body}),$.endedAt!==void 0)return{ended:!1};let Z=p.get($.id);if(Z)await Z.end("hangup");else await Q.realtime.hangup($.callId),await this.voiceStore.update($.id,{endedAt:Date.now(),endReason:"hangup"});return{ended:!0}}async voiceSession(J){let Q=J.params?.sessionId,$=typeof Q==="string"&&Q?await this.voiceStore.get(Q):null;if(!$)return M(404,{code:"voice_not_found",message:"No such voice session."});if($.owner!==null&&$.owner!==await this.runOwner(J))return FJ();return $}async upload(J=new x){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",K=W0(Q.get("body")),X=Q.get("threadId");await this.authorizeRequest(J,{route:"upload",threadId:typeof X==="string"&&X.length>0?X:void 0,body:K});let Y=X0(await this.attachmentLimits(J),$,Z,W);if(Y)throw new sQ(Y.code,Y.message);let V=typeof X==="string"&&X.length>0&&await this.store.loadThread(X)!==null?X:void 0,G=await this.runOwner(J),H=(k)=>this.fileOwners.record(k,{owner:G,name:Z,mimeType:W,size:$.size,createdAt:new Date().toISOString()}),D={body:K,threadId:V},z=await this.checkUpload({name:Z,size:$.size,mimeType:W},J,D);if(z)throw new sQ(z.code||"upload_refused",z.message);let F=await this.attachmentDestination($,J,D),O=L0(F,Q.get("destination")),N=await this.attachmentScope(J,V,{body:K}),P=O!=="provider"&&!N;if(P){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()`.');U0()}if(O==="provider"||!N){let k=await i8(this.agent.provider,$);await H(k);let I={fileId:k,name:Z,mimeType:W,size:$.size,destination:"provider"};if(P)I.downgraded="no_scope";return I}let B=V9(),L=await this.attachmentStorage.put({name:H9(B,Z),body:$,contentType:W}),U=O==="both"?await i8(this.agent.provider,$):void 0;if(U)await H(U);let j={id:B,scopeKey:N.key,fileId:U,objectName:L,name:Z,mimeType:W,size:$.size,createdAt:new Date().toISOString(),destination:O};return await this.attachments.put(N,j),{fileId:U,attachmentId:B,name:Z,mimeType:W,size:$.size,destination:O}}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 B0()}return null}onMessage(J,Q){return this.hooks?.onMessage?.(J,Q)}onToolCall(J,Q){return this.hooks?.onToolCall?.(J,Q)}onAwaitingInput(J,Q){return this.hooks?.onAwaitingInput?.(J,Q)}redactError(J,Q,$){let Z=this.hooks?.redactError;if(Z)return Z(J,Q,$);return eQ(J,Q)}onError(J,Q){return this.hooks?.onError?.(J,Q)}onStreamComplete(J,Q){return this.hooks?.onStreamComplete?.(J,Q)}reportHookFailure(J){let Q=this.hooks?.reportHookFailure;if(Q)try{return Q(J)}catch($){console.error("[gemi/ai] reportHookFailure hook failed",$)}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(X9(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=(V)=>this.isRunLive(V,J),W=await y8(Q,Z),K=W.messages,X=[],Y=new Map(W.settled.map((V)=>[V.id,V]));if(S0(K)||$)try{let V=await c8(K,{threadId:J,store:v.store,isRunLive:Z,outputSchemaFor:(G)=>this.toolOutputSchema(G),scan:this.jobsBlockMax()});K=V.messages,X=V.jobs;for(let G of V.settled)Y.set(G.id,G);if($&&V.orphans.length>0){await m8(v.store,V.orphans,(H)=>this.reportHookFailure(H));let G=new Set(V.orphans.map((H)=>H.id));X=X.map((H)=>G.has(H.id)?{...H,orphaned:!0}:H)}}catch(V){this.reportHookFailure(V)}if($&&Y.size>0)try{await this.store.appendMessages(J,[...Y.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 V$(J,this.jobsBlockMax())}toolOutputSchema(J){let Q=($)=>{for(let Z of $){let W=Z;if(Array.isArray(W.tools)){let K=Q(W.tools);if(K)return K}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 K=Promise.resolve(),X=(async()=>{let V;try{V=await J.result()}catch(H){Z?.close(),await Z?.settled(),K=W.notified.then(()=>this.safely(()=>this.onError({code:"unknown",message:H instanceof Error?H.message:String(H),retryable:!1},Q)));return}let G=V.messages;if(Z?.close(G),await Z?.settled(),Q.threadId&&G.length>0)try{await this.store.appendMessages(Q.threadId,G)}catch(H){this.reportHookFailure(H)}K=this.notifyRun(V,G,Q,W)})(),Y=X.then(()=>_0(Promise.all([K,$]).then(()=>{}),this.hookHoldMs));return{stored:X,hooks:Y}}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 nQ=["turn","clientRunId","threadId","messages","regenerate"],Z0=["text","files","toolResults"];function cJ(J,Q=B9(J)?nQ:[...nQ,...Z0]){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 W0(J){if(J===null)return{};let Q;if(typeof J==="string")try{Q=JSON.parse(J)}catch{throw new oQ("The upload's `body` field is not valid JSON.")}if(Q===null||typeof Q!=="object"||Array.isArray(Q))throw new oQ("The upload's `body` field must be a JSON object.");return cJ(Q,nQ)}class oQ extends mJ{constructor(J){super(J);this.name="InvalidUploadError",this.payload={api:{status:400,data:{error:{code:"invalid_request",message:J}}},view:{}}}}async function i8(J,Q){try{return await J.upload(Q)}catch($){if($ instanceof w&&K0.has($.status))throw new P9(E($).message);throw $}}var K0=new Set([400,413,415,422]);class sQ extends mJ{constructor(J,Q){super(Q);this.name="LimitedUploadError",this.payload={api:{status:422,data:{error:{code:J,message:Q}}},view:{}}}}function X0(J,Q,$,Z){if(!J)return null;let{maxBytes:W,accept:K}=J;if(typeof W==="number"&&Q.size>W)return{code:"file_too_large",message:`${JSON.stringify($)} is ${n8(Q.size)}; the limit is ${n8(W)}.`};if(K&&K.length>0&&!K.some((X)=>G0(X,$,Z)))return{code:"unsupported_file_type",message:`${JSON.stringify($)} is not a type this chat accepts. Accepted: ${K.join(", ")}.`};return null}function G0(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 n8(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 P9 extends mJ{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 DJ(J,Q){let $=J?.rawRequest;if(!$||$.method==="GET"||$.method==="HEAD"||!$.body)return{body:{}};if(!Y0($.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 o8(Q);let W;try{let X=await V0($,Q);if(X===null)return o8(Q);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 Y0(J){return Q9(J)==="application/json"}async function V0(J,Q){if(!Number.isFinite(Q)||!J.body)return await J.text();let $=J.body.getReader(),Z=[],W=0;for(;;){let{done:Y,value:V}=await $.read();if(Y)break;if(W+=V.byteLength,W>Q)return await $.cancel().catch(uJ),null;Z.push(V)}let K=new Uint8Array(W),X=0;for(let Y of Z)K.set(Y,X),X+=Y.byteLength;return new TextDecoder().decode(K)}function o8(J){return{body:{},status:413,code:"body_too_large",error:`The request body is larger than this agent accepts (${J} bytes).`}}function aQ(J,Q,$){return M(J,{...pJ(J9(J),$,J),code:Q})}function r(J){if(J.status===413)return aQ(413,J.code??"body_too_large",J.error??"");return M(J.status??400,{code:J.code??"invalid_request",message:J.error})}function B9(J){return Boolean(J.turn)&&typeof J.turn==="object"}function H0(J){let Q=B9(J)?J.turn:J,$={};if(typeof Q.text==="string")$.text=Q.text;if(Array.isArray(Q.files)){let Z=z0(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>s8)return{error:`turn.localId is longer than ${s8} characters.`};$.localId=Z}return{turn:$}}var s8=200;function z0(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 K={};for(let H of["fileId","attachmentId","name","mimeType"]){let D=Z[H];if(D===void 0||D===null||D==="")continue;if(typeof D!=="string")return`${W}.${H} must be a string.`;K[H]=D}let{fileId:X,attachmentId:Y,name:V,mimeType:G}=K;if(X?.startsWith(m))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(Y!==void 0&&!Y.startsWith(m))return`${W}.attachmentId is not a gemi attachment id: it must start with "${m}".`;if(!X&&!Y)return`${W} has neither a \`fileId\` nor an \`attachmentId\`. Send the ids the upload response answered.`;Q.push({...X?{fileId:X}:{},...Y?{attachmentId:Y}:{},...V!==void 0?{name:V}:{},...G!==void 0?{mimeType:G}:{}})}return Q}function D0(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 F0(J,Q){let $=J?.search?.get(Q);return typeof $==="string"?$:void 0}function P0(J){let Q=J$(J);for(let $=J.length-1;$>=0;$--){let Z=J[$];if(Z.role!=="user"||Q.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:$,turn:{...W?{text:W}:{},...K.length>0?{files:K}:{}}}}return null}function a8(){return M(409,{code:"stopped",message:"The turn was stopped before it started."})}function FJ(){return M(403,pJ("permission","This run belongs to someone else.",403))}function B0(){return M(403,pJ("permission","A file in this turn was uploaded by someone else.",403))}function N0(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}var O0=["sdp","threadId","pushToTalk"];function iQ(){return M(404,{code:"voice_not_enabled",message:"This agent has no voice: set `voice` on its controller."})}function M(J,Q){return new Response(JSON.stringify({error:Q}),{status:J,headers:{"Content-Type":"application/json"}})}function L0(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 t8=!1;function U0(){if(t8)return;t8=!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 C0=2147483647;function _0(J,Q){let $=J.then(()=>{},()=>{});if(!(Q<=C0))return $;let Z,W=new Promise((K)=>{Z=setTimeout(K,Q)});return Promise.race([$,W]).finally(()=>clearTimeout(Z))}var r8=!1;function M0(J){if(r8||Bun.env.NODE_ENV!=="production")return;if(!(J instanceof tQ))return;r8=!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 S0(J){return J.some((Q)=>Q.content.some(($)=>$.type==="tool-result"&&$.status==="running"))}export{w0 as windowMessages,YJ as voiceTools,j0 as turnStarts,EJ as toRealtimeUsage,f9 as toAgentTools,T0 as supportsStrict,k0 as splitTurns,u0 as settleSummaries,R0 as s,eQ as redactError,q0 as messageSize,ZJ as measureUsage,IQ as mcpVoiceTools,vQ as liveRuns,mQ as keepSummary,C8 as isCallNotFound,J$ as injectedMessageIds,GQ as generate,kZ as evalChain,$0 as defineAgentHooks,bQ as defaultVoiceStore,g0 as defaultSummaryStore,rQ as defaultNonceStore,yQ as defaultFileOwners,dJ as defaultAttachmentStore,pQ as defaultAgentStore,wJ as VoiceHangup,p as VoiceBridge,E0 as Usage,VQ as ToolNamespace,g as ToolError,m0 as Skill,lJ as ScopedAttachments,p0 as SKILLS_NAMESPACE,cQ as RedisReceiptStore,W9 as RedisNonceStore,jJ as RealtimeSideband,f as RealtimeRequestError,XJ as RealtimeClient,X$ as Prompt,K9 as PrismaNonceStore,c0 as PendingEscalation,jQ as OpenAIProvider,PQ as OpenAIImageProvider,wQ as MemoryVoiceSessionStore,h0 as MemorySummaryStore,uQ as MemoryReceiptStore,tQ as MemoryNonceStore,bJ as MemoryLiveRuns,fJ as MemoryFileOwners,xJ as MemoryCircuitStore,z9 as MemoryAttachmentStore,vJ as MemoryAgentStore,F$ as MemoryAgentJobStore,q$ as MEMORY_NAMESPACE,HJ as LiveRunNotFoundError,B$ as JobsRequireThreadError,P$ as JobHandle,A0 as JSONSchemaError,Y9 as InvalidAttachmentScopeError,A$ as InMemoryAgentMemoryStore,AJ as ImageRequestError,RJ as ImageProvider,HQ as ImageModel,t as FrameCursorEvictedError,GJ as FallbackProvider,j$ as FakeAgentMemoryStore,_J as Eval,QQ as DatabaseAgentMemoryStore,eJ as DatabaseAgentJobStore,L8 as DEFAULT_TRANSCRIPTION_MODEL,S$ as DEFAULT_MEMORY_MAX_TOKENS,k$ as DEFAULT_MEMORY_LIMITS,b0 as DEFAULT_MAX_SUMMARY_TOKENS,l0 as DEFAULT_MAX_RUN_DURATION_MS,N$ as DEFAULT_JOB_DEADLINE_MS,BJ as DEFAULT_JOBS_CONTEXT_MAX,VJ as DEFAULT_DELEGATE_NAME,x0 as DEFAULT_CONTEXT_WINDOW_STEP,I0 as DEFAULT_CONTEXT_WINDOW_NOTE,f0 as DEFAULT_COMPACT_TRIGGER_TOKENS,v0 as DEFAULT_COMPACT_INSTRUCTIONS,y0 as COMPACT_SUMMARY_HEADER,kQ as AzureOpenAIProvider,BQ as AzureOpenAIImageProvider,G9 as AttachmentNotFoundError,iJ as AgentTurnError,MJ as AgentTool,d0 as AgentRunError,a as AgentProvider,R$ as AgentMemoryRefusedError,T$ as AgentMemoryConflictError,E$ as AgentMemories,v as AgentJobs,aJ as AgentJobDeadlineSweep,O$ as AgentJob,Q$ as AgentController,i0 as Agent};
|
|
155
155
|
|
|
156
|
-
//# debugId=
|
|
156
|
+
//# debugId=F62FD905B0D273CB64756E2164756E21
|