gemi 0.196.2 → 0.197.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/index.js +1 -1
- package/dist/bun/plugin.js +1 -1
- package/dist/bun/preload.js +1 -1
- package/dist/{chunk-mgdrf89p.js → chunk-02jze3te.js} +2 -2
- package/dist/{chunk-mgdrf89p.js.map → chunk-02jze3te.js.map} +1 -1
- package/dist/{chunk-nk7nmtng.js → chunk-20y02g4n.js} +2 -2
- package/dist/{chunk-nk7nmtng.js.map → chunk-20y02g4n.js.map} +1 -1
- package/dist/{chunk-9dxp7t3n.js → chunk-2g2cntdm.js} +2 -2
- package/dist/{chunk-9dxp7t3n.js.map → chunk-2g2cntdm.js.map} +1 -1
- package/dist/{chunk-228w21t6.js → chunk-2qbfvb6m.js} +2 -2
- package/dist/{chunk-228w21t6.js.map → chunk-2qbfvb6m.js.map} +1 -1
- package/dist/{chunk-m0dfgmbj.js → chunk-2v83pskm.js} +1 -1
- package/dist/{chunk-652a9mr0.js → chunk-2z160r1b.js} +2 -2
- package/dist/{chunk-652a9mr0.js.map → chunk-2z160r1b.js.map} +1 -1
- package/dist/{chunk-28macaes.js → chunk-3am1e8ya.js} +2 -2
- package/dist/{chunk-28macaes.js.map → chunk-3am1e8ya.js.map} +1 -1
- package/dist/{chunk-rp6ss7v3.js → chunk-3bsw9sra.js} +2 -2
- package/dist/{chunk-rp6ss7v3.js.map → chunk-3bsw9sra.js.map} +1 -1
- package/dist/{chunk-j56zk5a0.js → chunk-4f2xy9ws.js} +3 -3
- package/dist/{chunk-j56zk5a0.js.map → chunk-4f2xy9ws.js.map} +1 -1
- package/dist/{chunk-08m9egzx.js → chunk-4ftk3z34.js} +2 -2
- package/dist/{chunk-08m9egzx.js.map → chunk-4ftk3z34.js.map} +1 -1
- package/dist/{chunk-7t60d5qy.js → chunk-4k62r4hv.js} +1 -1
- package/dist/{chunk-9hjxpdjt.js → chunk-51n7yky9.js} +1 -1
- package/dist/{chunk-wvq3c25z.js → chunk-5qaxde5h.js} +3 -3
- package/dist/{chunk-wvq3c25z.js.map → chunk-5qaxde5h.js.map} +1 -1
- package/dist/{chunk-pmt2jt9b.js → chunk-6nj9xjsm.js} +2 -2
- package/dist/{chunk-pmt2jt9b.js.map → chunk-6nj9xjsm.js.map} +1 -1
- package/dist/{chunk-g7h28xcr.js → chunk-7q42fej6.js} +2 -2
- package/dist/{chunk-g7h28xcr.js.map → chunk-7q42fej6.js.map} +1 -1
- package/dist/{chunk-p4eger3g.js → chunk-7sadg8d7.js} +3 -3
- package/dist/{chunk-p4eger3g.js.map → chunk-7sadg8d7.js.map} +1 -1
- package/dist/chunk-7xy7ebkx.js +117 -0
- package/dist/{chunk-5w3kcn4a.js.map → chunk-7xy7ebkx.js.map} +9 -10
- package/dist/{chunk-2485bwzs.js → chunk-8mmskn4g.js} +3 -3
- package/dist/{chunk-2485bwzs.js.map → chunk-8mmskn4g.js.map} +1 -1
- package/dist/{chunk-hswnqn33.js → chunk-8xckmvea.js} +2 -2
- package/dist/{chunk-hswnqn33.js.map → chunk-8xckmvea.js.map} +1 -1
- package/dist/{chunk-pqr01waj.js → chunk-9dnbf9q8.js} +2 -2
- package/dist/{chunk-pqr01waj.js.map → chunk-9dnbf9q8.js.map} +1 -1
- package/dist/{chunk-ermvtpy9.js → chunk-9ky5d5js.js} +3 -3
- package/dist/{chunk-ermvtpy9.js.map → chunk-9ky5d5js.js.map} +1 -1
- package/dist/{chunk-3fcd8a47.js → chunk-a4kk68xy.js} +2 -2
- package/dist/{chunk-3fcd8a47.js.map → chunk-a4kk68xy.js.map} +1 -1
- package/dist/{chunk-1x23scpn.js → chunk-a77w04sw.js} +2 -2
- package/dist/{chunk-1x23scpn.js.map → chunk-a77w04sw.js.map} +1 -1
- package/dist/{chunk-43599z6g.js → chunk-arb0qkrm.js} +2 -2
- package/dist/{chunk-43599z6g.js.map → chunk-arb0qkrm.js.map} +1 -1
- package/dist/{chunk-paawtkza.js → chunk-bcydd231.js} +2 -2
- package/dist/{chunk-paawtkza.js.map → chunk-bcydd231.js.map} +1 -1
- package/dist/{chunk-hmn6pa78.js → chunk-c601phyd.js} +2 -2
- package/dist/{chunk-hmn6pa78.js.map → chunk-c601phyd.js.map} +1 -1
- package/dist/{chunk-zcqz5xn9.js → chunk-cpgc5q74.js} +2 -2
- package/dist/{chunk-zcqz5xn9.js.map → chunk-cpgc5q74.js.map} +1 -1
- package/dist/{chunk-39w89wss.js → chunk-dbe8zgyb.js} +2 -2
- package/dist/{chunk-39w89wss.js.map → chunk-dbe8zgyb.js.map} +1 -1
- package/dist/{chunk-qrn6ch3t.js → chunk-degz94dk.js} +2 -2
- package/dist/{chunk-qrn6ch3t.js.map → chunk-degz94dk.js.map} +1 -1
- package/dist/{chunk-qg9pyxg7.js → chunk-e0d6az7p.js} +2 -2
- package/dist/{chunk-qg9pyxg7.js.map → chunk-e0d6az7p.js.map} +1 -1
- package/dist/{chunk-g02gqhq0.js → chunk-ecyq52t3.js} +3 -3
- package/dist/{chunk-g02gqhq0.js.map → chunk-ecyq52t3.js.map} +1 -1
- package/dist/chunk-es05kqtp.js +15 -0
- package/dist/{chunk-nphb176s.js.map → chunk-es05kqtp.js.map} +6 -5
- package/dist/{chunk-qjwv9xfq.js → chunk-evdca0b9.js} +2 -2
- package/dist/{chunk-qjwv9xfq.js.map → chunk-evdca0b9.js.map} +1 -1
- package/dist/{chunk-0xssrbar.js → chunk-ff16m7gm.js} +2 -2
- package/dist/{chunk-0xssrbar.js.map → chunk-ff16m7gm.js.map} +1 -1
- package/dist/{chunk-dn20caf2.js → chunk-fyk66c5e.js} +2 -2
- package/dist/{chunk-dn20caf2.js.map → chunk-fyk66c5e.js.map} +1 -1
- package/dist/{chunk-vgxkt9vd.js → chunk-fzy1z97a.js} +2 -2
- package/dist/{chunk-q1aaqhnw.js.map → chunk-fzy1z97a.js.map} +1 -1
- package/dist/{chunk-1ghbn9jg.js → chunk-g1th116z.js} +2 -2
- package/dist/{chunk-1ghbn9jg.js.map → chunk-g1th116z.js.map} +1 -1
- package/dist/{chunk-2yzv5v3m.js → chunk-gk0d26zw.js} +2 -2
- package/dist/{chunk-2yzv5v3m.js.map → chunk-gk0d26zw.js.map} +1 -1
- package/dist/{chunk-sqqby94y.js → chunk-gk12v51y.js} +1 -1
- package/dist/{chunk-ftvc1a0k.js → chunk-htnbmbx1.js} +2 -2
- package/dist/{chunk-ftvc1a0k.js.map → chunk-htnbmbx1.js.map} +1 -1
- package/dist/{chunk-pg5hm00s.js → chunk-j84r2j7a.js} +2 -2
- package/dist/{chunk-pg5hm00s.js.map → chunk-j84r2j7a.js.map} +1 -1
- package/dist/{chunk-1705yamg.js → chunk-kjgy7sk0.js} +2 -2
- package/dist/{chunk-1705yamg.js.map → chunk-kjgy7sk0.js.map} +1 -1
- package/dist/{chunk-6m9qrs6d.js → chunk-kjygnj7y.js} +2 -2
- package/dist/{chunk-6m9qrs6d.js.map → chunk-kjygnj7y.js.map} +1 -1
- package/dist/{chunk-n914rs58.js → chunk-kzy4pyqb.js} +3 -3
- package/dist/{chunk-n914rs58.js.map → chunk-kzy4pyqb.js.map} +1 -1
- package/dist/{chunk-07zfrfbg.js → chunk-mk4x0vtp.js} +2 -2
- package/dist/{chunk-07zfrfbg.js.map → chunk-mk4x0vtp.js.map} +1 -1
- package/dist/{chunk-gmcttf0f.js → chunk-mnmz8n5k.js} +2 -2
- package/dist/{chunk-gmcttf0f.js.map → chunk-mnmz8n5k.js.map} +1 -1
- package/dist/{chunk-wgqppqcn.js → chunk-n01mhwkj.js} +3 -3
- package/dist/{chunk-wgqppqcn.js.map → chunk-n01mhwkj.js.map} +1 -1
- package/dist/{chunk-xhkga697.js → chunk-nbry43s8.js} +2 -2
- package/dist/{chunk-xhkga697.js.map → chunk-nbry43s8.js.map} +1 -1
- package/dist/{chunk-beckfwe9.js → chunk-ng5qfkgp.js} +2 -2
- package/dist/{chunk-beckfwe9.js.map → chunk-ng5qfkgp.js.map} +1 -1
- package/dist/{chunk-aycfrzh1.js → chunk-nnn2f1ew.js} +2 -2
- package/dist/{chunk-aycfrzh1.js.map → chunk-nnn2f1ew.js.map} +1 -1
- package/dist/{chunk-reaty2mv.js → chunk-pvx66dq2.js} +3 -3
- package/dist/{chunk-reaty2mv.js.map → chunk-pvx66dq2.js.map} +1 -1
- package/dist/{chunk-j49vh5bs.js → chunk-qw6aa9fy.js} +2 -2
- package/dist/{chunk-j49vh5bs.js.map → chunk-qw6aa9fy.js.map} +1 -1
- package/dist/{chunk-28fz99pn.js → chunk-qx1vc11v.js} +2 -2
- package/dist/{chunk-28fz99pn.js.map → chunk-qx1vc11v.js.map} +1 -1
- package/dist/{chunk-9gpjn44n.js → chunk-rk34z2wa.js} +2 -2
- package/dist/{chunk-9gpjn44n.js.map → chunk-rk34z2wa.js.map} +1 -1
- package/dist/{chunk-m08p5mre.js → chunk-rnjjn09d.js} +2 -2
- package/dist/{chunk-m08p5mre.js.map → chunk-rnjjn09d.js.map} +1 -1
- package/dist/{chunk-q1aaqhnw.js → chunk-rqs2s5nh.js} +2 -2
- package/dist/{chunk-vgxkt9vd.js.map → chunk-rqs2s5nh.js.map} +1 -1
- package/dist/{chunk-zzdvdr5a.js → chunk-s57n552b.js} +4 -4
- package/dist/{chunk-zzdvdr5a.js.map → chunk-s57n552b.js.map} +1 -1
- package/dist/{chunk-ejktrxp2.js → chunk-spsheyx9.js} +1 -1
- package/dist/{chunk-7zf8rnsb.js → chunk-sxww1ka5.js} +2 -2
- package/dist/{chunk-7zf8rnsb.js.map → chunk-sxww1ka5.js.map} +1 -1
- package/dist/chunk-tgbky7fc.js +5 -0
- package/dist/{chunk-ggbf1web.js.map → chunk-tgbky7fc.js.map} +1 -1
- package/dist/{chunk-03q4j7wa.js → chunk-tv33103m.js} +1 -1
- package/dist/{chunk-p2vasd1z.js → chunk-tvdmx66x.js} +2 -2
- package/dist/{chunk-p2vasd1z.js.map → chunk-tvdmx66x.js.map} +1 -1
- package/dist/{chunk-f6css3z6.js → chunk-v4ka65g8.js} +2 -2
- package/dist/{chunk-f6css3z6.js.map → chunk-v4ka65g8.js.map} +1 -1
- package/dist/{chunk-a02bmp0q.js → chunk-wprzrnqh.js} +2 -2
- package/dist/{chunk-a02bmp0q.js.map → chunk-wprzrnqh.js.map} +1 -1
- package/dist/{chunk-tj7z65ba.js → chunk-x05mj7ye.js} +2 -2
- package/dist/{chunk-tj7z65ba.js.map → chunk-x05mj7ye.js.map} +1 -1
- package/dist/{chunk-2g2fsr71.js → chunk-xb9zjaes.js} +2 -2
- package/dist/{chunk-2g2fsr71.js.map → chunk-xb9zjaes.js.map} +1 -1
- package/dist/{chunk-b6zqjyn1.js → chunk-y50h3cd6.js} +2 -2
- package/dist/{chunk-b6zqjyn1.js.map → chunk-y50h3cd6.js.map} +1 -1
- package/dist/{chunk-5bfrr8x5.js → chunk-y9pzr1wc.js} +2 -2
- package/dist/{chunk-5bfrr8x5.js.map → chunk-y9pzr1wc.js.map} +1 -1
- package/dist/{chunk-8e17k7ht.js → chunk-yzazktke.js} +3 -3
- package/dist/{chunk-8e17k7ht.js.map → chunk-yzazktke.js.map} +3 -3
- package/dist/{chunk-6efjnt6r.js → chunk-zcmfkb9f.js} +2 -2
- package/dist/{chunk-6efjnt6r.js.map → chunk-zcmfkb9f.js.map} +1 -1
- package/dist/{chunk-trqt1kkd.js → chunk-zehvtpgm.js} +2 -2
- package/dist/{chunk-trqt1kkd.js.map → chunk-zehvtpgm.js.map} +1 -1
- package/dist/{chunk-bc7hr358.js → chunk-zrykhpn9.js} +3 -3
- package/dist/{chunk-bc7hr358.js.map → chunk-zrykhpn9.js.map} +1 -1
- package/dist/{chunk-8fdk8bfd.js → chunk-zryrem89.js} +3 -3
- package/dist/{chunk-8fdk8bfd.js.map → chunk-zryrem89.js.map} +1 -1
- package/dist/{chunk-fhfkcmkc.js → chunk-zv55h4x9.js} +2 -2
- package/dist/{chunk-fhfkcmkc.js.map → chunk-zv55h4x9.js.map} +1 -1
- package/dist/{chunk-dfmxvp8p.js → chunk-zzmgz14a.js} +2 -2
- package/dist/{chunk-dfmxvp8p.js.map → chunk-zzmgz14a.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/ApiRouter.d.ts +7 -0
- package/dist/http/ApiRouter.d.ts.map +1 -1
- package/dist/http/BodyLimitMiddleware.d.ts +3 -0
- package/dist/http/BodyLimitMiddleware.d.ts.map +1 -1
- package/dist/http/HttpRequest.d.ts.map +1 -1
- package/dist/http/bodyLimit.d.ts +21 -1
- package/dist/http/bodyLimit.d.ts.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +1 -1
- package/dist/http/middleware-config.d.ts +12 -3
- package/dist/http/middleware-config.d.ts.map +1 -1
- package/dist/http/validate.d.ts +8 -0
- package/dist/http/validate.d.ts.map +1 -1
- package/dist/i18n/Translator.d.ts +5 -0
- package/dist/i18n/Translator.d.ts.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/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/services/index.js +2 -2
- package/dist/services/index.js.map +1 -1
- package/dist/services/middleware/MiddlewareRegistry.d.ts +16 -5
- package/dist/services/middleware/MiddlewareRegistry.d.ts.map +1 -1
- package/dist/services/queue/work.js +2 -2
- package/dist/services/queue/work.js.map +1 -1
- package/dist/services/router/ApiRouteDispatcher.d.ts.map +1 -1
- package/dist/services/router/createFlatApiRoutes.d.ts +3 -0
- package/dist/services/router/createFlatApiRoutes.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 +1 -1
- package/package.json +1 -1
- package/dist/chunk-5w3kcn4a.js +0 -117
- package/dist/chunk-ggbf1web.js +0 -5
- package/dist/chunk-nphb176s.js +0 -15
- /package/dist/{chunk-m0dfgmbj.js.map → chunk-2v83pskm.js.map} +0 -0
- /package/dist/{chunk-7t60d5qy.js.map → chunk-4k62r4hv.js.map} +0 -0
- /package/dist/{chunk-9hjxpdjt.js.map → chunk-51n7yky9.js.map} +0 -0
- /package/dist/{chunk-sqqby94y.js.map → chunk-gk12v51y.js.map} +0 -0
- /package/dist/{chunk-ejktrxp2.js.map → chunk-spsheyx9.js.map} +0 -0
- /package/dist/{chunk-03q4j7wa.js.map → chunk-tv33103m.js.map} +0 -0
package/dist/ai/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$c as _6,Ac as T8,Cc as x8,Dc as y8,Ec as q8,Fc as b8,Gc as f8,Hc as v8,Ic as h8,Jc as g8,Kc as u8,Lc as c8,Mc as m8,Nc as p8,Pc as y,Qc as bJ,Rc as E9,Sc as j9,Tc as k9,Uc as v,Vc as T,Wb as V8,Wc as D8,Xb as fQ,Xc as B6,Yb as yQ,Yc as L6,Zb as H8,Zc as C6,_c as O6,ac as vJ,ad as M6,bc as j,bd as S6,cc as k,cd as A6,dd as R6,ec as X9,ed as E6,fc as J9,fd as j6,gc as HJ,gd as BJ,hc as N6,hd as k6,ic as l,id as pQ,jc as z8,jd as T6,kc as vQ,kd as lQ,lc as hQ,ld as x6,mc as gQ,md as I6,nc as n,nd as w6,oc as uQ,od as wJ,pc as tJ,pd as L$,qc as cQ,qd as q6,rc as mQ,rd as b6,sc as rJ,sd as dQ,tc as E8,td as f6,uc as j8,ud as y6,vd as v6,wc as k8,wd as h6,xc as c,xd as N$,yc as YQ,zc as VQ}from"../chunk-
|
|
2
|
+
import{$c as _6,Ac as T8,Cc as x8,Dc as y8,Ec as q8,Fc as b8,Gc as f8,Hc as v8,Ic as h8,Jc as g8,Kc as u8,Lc as c8,Mc as m8,Nc as p8,Pc as y,Qc as bJ,Rc as E9,Sc as j9,Tc as k9,Uc as v,Vc as T,Wb as V8,Wc as D8,Xb as fQ,Xc as B6,Yb as yQ,Yc as L6,Zb as H8,Zc as C6,_c as O6,ac as vJ,ad as M6,bc as j,bd as S6,cc as k,cd as A6,dd as R6,ec as X9,ed as E6,fc as J9,fd as j6,gc as HJ,gd as BJ,hc as N6,hd as k6,ic as l,id as pQ,jc as z8,jd as T6,kc as vQ,kd as lQ,lc as hQ,ld as x6,mc as gQ,md as I6,nc as n,nd as w6,oc as uQ,od as wJ,pc as tJ,pd as L$,qc as cQ,qd as q6,rc as mQ,rd as b6,sc as rJ,sd as dQ,tc as E8,td as f6,uc as j8,ud as y6,vd as v6,wc as k8,wd as h6,xc as c,xd as N$,yc as YQ,zc as VQ}from"../chunk-2g2cntdm.js";import{Pd as _8}from"../chunk-mndcq5z1.js";import"../chunk-dbe8zgyb.js";import{Nh as jQ,Qh as TQ,Xi as xQ,aj as s$,bj as IQ,dj as wQ,ej as qQ,fj as bQ,ki as q9,li as F6,mi as P6,ni as U6,oi as b}from"../chunk-es05kqtp.js";import{gj as kQ,ij as sJ,jj as aJ}from"../chunk-2qbfvb6m.js";import{sj as p}from"../chunk-zzmgz14a.js";import"../chunk-kjgy7sk0.js";import"../chunk-mnmz8n5k.js";import"../chunk-ng5qfkgp.js";import{Kk as TJ,vk as t,wk as r}from"../chunk-5qaxde5h.js";import"../chunk-htnbmbx1.js";import"../chunk-yzazktke.js";import{xl as r9}from"../chunk-9ky5d5js.js";import"../chunk-a77w04sw.js";import"../chunk-y9pzr1wc.js";import{Ql as W$}from"../chunk-nnn2f1ew.js";import"../chunk-fzy1z97a.js";import{existsSync as tQ,readdirSync as u6,readFileSync as L8}from"fs";import{isAbsolute as rQ,join as SJ,relative as eQ,sep as JZ}from"path";var C8="prompts.json",$Z=/\{\{>\s*([\w./-]+)\s*\}\}/g,U8=/\{\{(\w+)\}\}/g,QZ=/^[\w-]+(\/[\w-]+)*$/,N8={dir:"app/agents",shared:"prompts"},RJ={},Q$=new Map,AJ;function ZZ(){if(AJ===void 0){let J=SJ(W$(),"dist","server",C8);AJ=tQ(J)?JSON.parse(L8(J,"utf8")):null}return AJ??null}function WZ(J){return J.replace(/\r?\n$/,"")}function B8(){return RJ.cache??Bun.env.NODE_ENV==="production"}function KZ(J){if(!QZ.test(J))throw Error(`"${J}" is not a prompt name. Use letters, digits, "-" and "_", with "/" between folders.`);let $=RJ.dir??N8.dir,Q=rQ($)?$:SJ(process.cwd(),$),Z=J.includes("/")?`${J}.md`:SJ(RJ.shared??N8.shared,`${J}.md`);return SJ(Q,Z)}function XZ(J){let $=KZ(J),Q=B8()?Q$.get($):void 0;if(Q!==void 0)return Q;let Z=Bun.env.NODE_ENV==="production";if(Z){let K=ZZ()?.[eQ(W$(),$).split(JZ).join("/")];if(K!==void 0)return K}let W;try{W=WZ(L8($,"utf8"))}catch(K){if(K.code==="ENOENT"){let X=Z?` or in dist/server/${C8}`:"";throw Error(`The prompt "${J}" does not exist (looked for ${$}${X}).`)}throw K}if(B8())Q$.set($,W);return W}function Z$(J,$){if($.includes(J))throw Error(`The prompt "${J}" includes itself: ${[...$,J].join(" > ")}.`);return XZ(J).replace($Z,(Q,Z)=>Z$(Z,[...$,J]))}class O8{static configure(J){RJ={...J},Q$.clear(),AJ=void 0}static render(J,$={}){return Z$(J,[]).replace(U8,(Q,Z)=>{if(!Object.hasOwn($,Z))throw Error(`The prompt "${J}" has no value for {{${Z}}}.`);return String($[Z])})}static placeholders(J){let $=[...Z$(J,[]).matchAll(U8)].map((Q)=>Q[1]);return[...new Set($)]}}class K$ extends _8{name="AgentJobDeadlineSweep";cron="* * * * *";async callback(){while(await c.sweep({limit:100})===100);}}var EJ=20;function S8(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)=>K.state==="running").sort(Q),...J.filter((K)=>K.state!=="running").sort(Q)].slice(0,$).map((K)=>{let X=[`- ${K.id} (${K.toolName})`];if(K.state==="running")X.push(`running since ${X$(K.createdAt)}`);else if(K.state==="ok")X.push(`finished at ${X$(K.settledAt??K.updatedAt)}`);else{let Y=K.error?`${K.error.code}: ${M8(K.error.message,200)}`:"failed";X.push(`failed at ${X$(K.settledAt??K.updatedAt)} (${Y})`)}if(K.summary!==void 0)X.push(`summary: ${M8(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 X$(J){return new Date(J).toISOString().replace(/\.\d{3}Z$/,"Z")}function M8(J,$){return J.length<=$?J:`${J.slice(0,$-1)}\u2026`}class Y${table;sql;dialect;connection;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 GZ(this.dialect,this.table))await this.sql.unsafe(J)}async transaction(J){if(this.connection===void 0||this.joinable())return J();return TJ(this.sql,()=>J(),{connection:this.connection})}async create(J){let $=this.q(),Q=this.clock($);await $`
|
|
4
4
|
INSERT INTO ${this.name($)}
|
|
5
5
|
(id, thread_id, run_id, tool_call_id, tool_name, owner, job, summary, state,
|
|
@@ -264,4 +264,4 @@ return 0`;class t${injectedClient;prefix;constructor(J={}){this.injectedClient=J
|
|
|
264
264
|
|
|
265
265
|
`)||void 0,L=await this.context(J,{body:V}),_=await this.reasoning(J,{body:V})||void 0,R=await this.skills(J,{body:V})||void 0,A=await this.runTools(J,{body:V,context:L})||void 0,x=await this.usageLimits(J,{body:V,context:L})||void 0,f=await this.attachmentsFor(J,Z,{body:V}),q=this.agent.memory?await this.memoryScopes(J,{body:V}):void 0;if(H?.cancelled)return _Q();let O=Z?new J8(this.store,Z,N,(E)=>this.reportHookFailure(E)):null,C=`run_${crypto.randomUUID()}`,M={req:J,runId:C,threadId:Z},w={id:null,notified:Promise.resolve()},I=this.agent.stream({runId:C,messages:N,turn:K,threadId:Z,...O?{onMessage:(E)=>O.finish(E)}:{},onTurn:(E)=>{if(w.id!==null)return;w.id=E.id;let a=O?O.settled():Promise.resolve();w.notified=a.then(()=>this.safely(()=>this.onMessage(E,M)))},instructions:U,...Q8.has(J)?{event:Q8.get(J)}:{},...ZJ.has(J)?{echoTurn:!0}:{},..._?{reasoning:_}:{},...R&&R.length>0?{skills:R}:{},...A?.tools&&A.tools.length>0?{tools:A.tools}:{},...A?.activeTools?{activeTools:A.activeTools}:{},...x?{usageLimits:x}:{},context:L,attachments:f,body:V,redactError:(E,a)=>this.redactError(E,a,M),onProviderRetry:(E)=>this.onProviderRetry(E,M),nonces:this.nonces,receipts:this.receipts,subject:G,...q?{memory:{scopes:q,...this.memoryMaxTokens!==void 0?{maxTokens:this.memoryMaxTokens}:{}}}:{},...Z?{jobs:{owner:G}}:{},...this.contextWindow!==void 0?{contextWindow:this.contextWindow}:{},...Z&&pQ(this.store)?{summaryStore:this.store}:{},...this.prepareStep!==F8.prototype.prepareStep||this.hooks?.prepareStep?{prepareStep:(E)=>this.prepareStep(E,M)}:{}}),J$=this.liveRuns.register(I,{threadId:Z,owner:G,clientRunId:Y,onEvent:(E)=>this.dispatchEvent(E,M),onInternalError:(E)=>this.reportHookFailure(E),maxRunDurationMs:this.agent.maxRunDurationMs});if(D=I,O)this.follow(I,O);if(Z)p0(this.liveRuns,Z,I.runId);let{stored:$$,hooks:P8}=this.persistRun(I,M,J$,O,w);if($8.set(I,$$),ZJ.has(J))ZJ.set(J,{run:I,hooks:P8});return J.ctx?.()?.waitUntil(P8),I.toResponse()};try{await this.authorizeRequest(J,{route:"stream",threadId:Z,body:V});let N=await this.foreignFile([...K?.files??[],...Z?[]:K6(Q.messages)],G);if(N)return N;if(H?.cancelled)return _Q();let P=await this.runLimitKey(J,{owner:G,threadId:Z}),U=P===null?KJ:l0(this.liveRuns).take(P,Z?`thread:${Z}`:`run:${crypto.randomUUID()}`,this.maxConcurrentRuns);if(!U)return Y8(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,FQ.get(J)??"supersede"):await F()}finally{let L=D;if(L)L.result().then(U,U);else U()}}finally{if(H&&nJ.get(Y)===H)nJ.delete(Y)}}async withThread(J,$,Q,Z="supersede"){if(Z==="skip"&&OJ.has(J))return MQ(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=OJ.get(J)??Promise.resolve(),K,X=new Promise((V)=>{K=V}),Y=W.then(()=>X);OJ.set(J,Y),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:MQ(J)};let H=this.liveRuns.get(V.runId),D=H?$8.get(H)??H.result():null;if(D)return{waitFor:D.then(KJ,KJ)}}if(V&&this.liveRuns.isRunning(V.runId)&&!this.liveRuns.mayAccess(V.runId,$))return{response:MJ()};let G=V?this.liveRuns.get(V.runId):null;if(G)G.stop({reason:"superseded by a later turn on this thread"}),await $8.get(G);return{response:await Q()}}finally{if(K(),OJ.get(J)===Y)OJ.delete(J)}}async attach(J=new b){let $=await WJ(J,_J);if($.error)return s($);let Q=$.body,Z=typeof Q.threadId==="string"?Q.threadId:OQ(J,"threadId");if(!Z)return S(400,{code:"invalid_request",message:"attach needs a threadId: it is the handle that survives a refresh."});if(await this.authorizeRequest(J,{route:"attach",threadId:Z}),!await this.threadInScope(J,Z))return EQ(Z);let W=await this.liveRuns.find({threadId:Z});if(W&&!this.liveRuns.mayAccess(W.runId,await this.runOwner(J)))return MJ();if(!W)return EQ(Z);let K=typeof Q.runId==="string"?Q.runId:void 0,X=K&&K!==W.runId?void 0:$6(J,Q);try{return bQ(this.liveRuns.replay(W.runId,X))}catch(Y){if(Y instanceof QJ)return S(410,{code:Y.code,message:Y.message,oldestSeq:Y.oldest});if(Y instanceof LJ)return S(404,{code:Y.code,message:Y.message});throw Y}}async watch(J=new b){let $=await WJ(J,_J);if($.error)return s($);let Q=$.body,Z=typeof Q.threadId==="string"?Q.threadId:OQ(J,"threadId");if(!Z)return S(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 S(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=m0(K),Y=await K.find({threadId:Z}),V=null,G=null,H=0,D=()=>{if(G?.stop(),!V)return;let F=X.get(Z);if(F?.delete(V),F&&F.size===0)X.delete(Z);V=null},z=new ReadableStream({start(F){G=wQ(F);let B=(P)=>{if(!K.mayAccess(P,W))return;try{F.enqueue(new TextEncoder().encode(IQ({seq:++H,event:{type:"run-start",runId:P,threadId:Z}}))),G?.touch()}catch{D()}};V=B;let N=X.get(Z);if(!N)N=new Set,X.set(Z,N);if(N.add(B),Y&&K.isRunning(Y.runId))B(Y.runId)},cancel(){D()}});return J.rawRequest?.signal?.addEventListener("abort",D,{once:!0}),new Response(z,{status:200,headers:qQ()})}async stop(J=new b){let $=await WJ(J,_J);if($.error)return s($);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=nJ.get(Q.clientRunId);if(X){if(X.owner!==null&&X.owner!==Z)return MJ();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 MJ();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}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 tJ(this.attachments,this.attachmentStorage,Z)}async voiceStart(J=new b){let $=this.voice;if(!$)return Z8();let Q=await WJ(J,_J);if(Q.error)return s(Q);let{sdp:Z,threadId:W,pushToTalk:K}=Q.body;if(typeof Z!=="string"||!Z.trimStart().startsWith("v="))return S(400,{code:"invalid_request",message:"`sdp` must be the browser's SDP offer."});let X=oJ(Q.body,X6),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 $.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 $.realtime.hangup(D).catch((_)=>{console.error("[gemi/ai] a voice call that failed to start could not be hung up.",_)});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:j(),transcription:{usage:j(),seconds:0},transcript:[],requests:[],toolCalls:[],errors:[]})}catch(_){console.error("[gemi/ai] a voice session's onEnd threw.",_)}},F=G.threadId??Y;if(!F)return await z(void 0),S(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 B=crypto.randomUUID(),N=G.tools??[];try{if(G.mcp)N=[...N,...await c$(G.mcp,{user:V,sessionId:B})]}catch(L){return await z(L),S(500,{code:"voice_unavailable",message:"Voice isn't available right now."})}let P={...G.session,tools:[...UJ($.delegate),...G.session?.tools??[],...N.map((L)=>L.tool)],...K===!0?{turnDetection:null}:{}},U;try{U=await $.realtime.createCall({sdp:Z,session:P,safetyIdentifier:G.safetyIdentifier})}catch(L){await z(L);let _=L instanceof g&&L.code==="rate_limited";return S(_?429:502,{code:"voice_unavailable",message:"Voice isn't available right now."})}D=U.callId;try{await this.voiceStore.create({id:B,callId:U.callId,threadId:F,owner:await this.runOwner(J),body:X,startedAt:H});let{threadId:L,session:_,safetyIdentifier:R,mcp:A,tools:x,...f}=G;return{sessionId:o.start({...f,tools:N,controller:this.constructor,threadId:F,user:V,body:X,call:{realtime:$.realtime,callId:U.callId},sessionId:B,store:this.voiceStore,liveRuns:this.liveRuns,delegate:$.delegate,session:P}).sessionId,sdp:U.sdpAnswer,threadId:F,delegate:$.delegate?.name??NJ,endsAt:H+(G.limits?.maxDurationMs??900000)}}catch(L){return await z(L),S(500,{code:"voice_unavailable",message:"Voice isn't available right now."})}}async voiceUpdate(J=new b){if(!this.voice)return Z8();let $=await this.voiceSession(J);if($ instanceof Response)return $;let Q=await WJ(J,_J);if(Q.error)return s(Q);let Z=oJ(Q.body,[]);if(await this.authorizeRequest(J,{route:"stream",threadId:$.threadId,body:Z}),$.endedAt!==void 0)return S(409,{code:"voice_ended",message:"This voice session has ended."});return await this.voiceStore.update($.id,{body:Z}),o.get($.id)?.setBody(Z),{updated:!0}}async voiceEnd(J=new b){let $=this.voice;if(!$)return Z8();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=o.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 S(404,{code:"voice_not_found",message:"No such voice session."});if(Q.owner!==null&&Q.owner!==await this.runOwner(J))return MJ();return Q}async upload(J=new b){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=n0($.get("body")),X=$.get("threadId");await this.authorizeRequest(J,{route:"upload",threadId:typeof X==="string"&&X.length>0?X:void 0,body:K});let Y=s0(await this.attachmentLimits(J),Q,Z,W);if(Y)throw new G8(Y.code,Y.message);await this.scopeStore(J,K);let V=typeof X==="string"&&X.length>0&&await this.store.loadThread(X)!==null?X:void 0,G=await this.runOwner(J),H=(A)=>this.fileOwners.record(A,{owner:G,name:Z,mimeType:W,size:Q.size,createdAt:new Date().toISOString()}),D={body:K,threadId:V},z=await this.checkUpload({name:Z,size:Q.size,mimeType:W},J,D);if(z)throw new G8(z.code||"upload_refused",z.message);let F=await this.attachmentDestination(Q,J,D),B=G6(F,$.get("destination")),N=await this.attachmentScope(J,V,{body:K}),P=B!=="provider"&&!N;if(P){if(B==="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()`.');Y6()}if(B==="provider"||!N){let A=await NQ(this.agent.provider,Q);await H(A);let x={fileId:A,name:Z,mimeType:W,size:Q.size,destination:"provider"};if(P)x.downgraded="no_scope";return x}let U=uQ(),L=await this.attachmentStorage.put({name:cQ(U,Z),body:Q,contentType:W}),_=B==="both"?await NQ(this.agent.provider,Q):void 0;if(_)await H(_);let R={id:U,scopeKey:N.key,fileId:_,objectName:L,name:Z,mimeType:W,size:Q.size,createdAt:new Date().toISOString(),destination:B};return await this.attachments.put(N,R),{fileId:_,attachmentId:U,name:Z,mimeType:W,size:Q.size,destination:B}}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 W6()}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 z8(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:dQ(Q)});return}case"awaiting-input":await this.onAwaitingInput(J.pending,$);return;case"error":await this.onError(vQ(J.error),$);return;default:return}}async readThread(J,$={}){let Z=await($.scope===null||$.scope===void 0?this.store:RQ(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 XQ($,Z),K=W.messages,X=[],Y=new Map(W.settled.map((V)=>[V.id,V]));if(D6(K)||Q)try{let V=await HQ(K,{threadId:J,store:c.store,isRunLive:Z,outputSchemaFor:(G)=>this.toolNamed(G)?.outputSchema,modelOutputFor:(G,H)=>lQ(this.toolNamed(G),H,(D)=>this.reportHookFailure(D)),scan:this.jobsBlockMax()});K=V.messages,X=V.jobs;for(let G of V.settled)Y.set(G.id,G);if(Q&&V.orphans.length>0){await zQ(c.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(Q&&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??EJ}jobsBlock(J){return S8(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()}){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},$)));return}let G=V.messages;if(Z?.close(G),await Z?.settled(),$.threadId&&G.length>0)try{await this.store.appendMessages($.threadId,G)}catch(H){this.reportHookFailure(H)}K=this.notifyRun(V,G,$,W)})(),Y=X.then(()=>H6(Promise.all([K,Q]).then(()=>{}),this.hookHoldMs));return{stored:X,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 K8=["turn","clientRunId","threadId","messages","regenerate"],i0=["text","files","toolResults"];function oJ(J,$=sQ(J)?K8:[...K8,...i0]){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 n0(J){if(J===null)return{};let $;if(typeof J==="string")try{$=JSON.parse(J)}catch{throw new X8("The upload's `body` field is not valid JSON.")}if($===null||typeof $!=="object"||Array.isArray($))throw new X8("The upload's `body` field must be a JSON object.");return oJ($,K8)}class X8 extends sJ{constructor(J){super(J);this.name="InvalidUploadError",this.payload={api:{status:400,data:{error:{code:"invalid_request",message:J}}},view:{}}}}async function NQ(J,$){try{return await J.upload($)}catch(Q){if(Q instanceof y&&o0.has(Q.status))throw new oQ(T(Q).message);throw Q}}var o0=new Set([400,413,415,422]);class G8 extends sJ{constructor(J,$){super($);this.name="LimitedUploadError",this.payload={api:{status:422,data:{error:{code:J,message:$}}},view:{}}}}function s0(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 ${BQ($.size)}; the limit is ${BQ(W)}.`};if(K&&K.length>0&&!K.some((X)=>a0(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 a0(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 BQ(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 oQ extends sJ{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 WJ(J,$){let Q=J?.rawRequest;if(!Q||Q.method==="GET"||Q.method==="HEAD"||!Q.body)return{body:{}};if(!t0(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 LQ($);let W;try{let X=await r0(Q,$);if(X===null)return LQ($);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 t0(J){return TQ(J)==="application/json"}async function r0(J,$){if(!Number.isFinite($)||!J.body)return await J.text();let Q=J.body.getReader(),Z=[],W=0;for(;;){let{done:Y,value:V}=await Q.read();if(Y)break;if(W+=V.byteLength,W>$)return await Q.cancel().catch(KJ),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 LQ(J){return{body:{},status:413,code:"body_too_large",error:`The request body is larger than this agent accepts (${J} bytes).`}}function Y8(J,$,Q){return S(J,{...aJ(kQ(J),Q,J),code:$})}function s(J){if(J.status===413)return Y8(413,J.code??"body_too_large",J.error??"");return S(J.status??400,{code:J.code??"invalid_request",message:J.error})}function sQ(J){return Boolean(J.turn)&&typeof J.turn==="object"}function e0(J){let $=sQ(J)?J.turn:J,Q={};if(typeof $.text==="string")Q.text=$.text;if(Array.isArray($.files)){let Z=J6($.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>CQ)return{error:`turn.localId is longer than ${CQ} characters.`};Q.localId=Z}return{turn:Q}}var CQ=200;function J6(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 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(n))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(n))return`${W}.attachmentId is not a gemi attachment id: it must start with "${n}".`;if(!X&&!Y)return`${W} has neither a \`fileId\` nor an \`attachmentId\`. Send the ids the upload response answered.`;$.push({...X?{fileId:X}:{},...Y?{attachmentId:Y}:{},...V!==void 0?{name:V}:{},...G!==void 0?{mimeType:G}:{}})}return $}function $6(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 OQ(J,$){let Q=J?.search?.get($);return typeof Q==="string"?Q:void 0}function Q6(J){let $=D8(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 _Q(){return S(409,{code:"stopped",message:"The turn was stopped before it started."})}function Z6(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"||!y0.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 MQ(J){return S(409,{code:iQ,message:`Thread ${J} has a run going, and this turn was not to interrupt it.`})}function MJ(){return S(403,aJ("permission","This run belongs to someone else.",403))}function W6(){return S(403,aJ("permission","A file in this turn was uploaded by someone else.",403))}function K6(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 X6=["sdp","threadId","pushToTalk"];function Z8(){return S(404,{code:"voice_not_enabled",message:"This agent has no voice: set `voice` on its controller."})}function S(J,$){return new Response(JSON.stringify({error:$}),{status:J,headers:{"Content-Type":"application/json"}})}function G6(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 SQ=!1;function Y6(){if(SQ)return;SQ=!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 V6=2147483647;function H6(J,$){let Q=J.then(()=>{},()=>{});if(!($<=V6))return Q;let Z,W=new Promise((K)=>{Z=setTimeout(K,$)});return Promise.race([Q,W]).finally(()=>clearTimeout(Z))}var AQ=!1;function z6(J){if(AQ||Bun.env.NODE_ENV!=="production")return;if(!(J instanceof V8))return;AQ=!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 D6(J){return J.some(($)=>$.content.some((Q)=>Q.type==="tool-result"&&Q.status==="running"))}function RQ(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 EQ(J){return S(404,{code:"no_live_run",message:`No run in progress for thread ${J} in this process.`})}export{M6 as windowMessages,UJ as voiceTools,B6 as turnStarts,hJ as toRealtimeUsage,BZ as toAgentTools,U6 as supportsStrict,L6 as splitTurns,T6 as settleSummaries,P6 as s,z8 as redactError,h6 as parsePartialJson,C6 as messageSize,HJ as measureUsage,c$ as mcpVoiceTools,i$ as liveRuns,BJ as keepSummary,y9 as isCallNotFound,D8 as injectedMessageIds,N$ as generate,z0 as evalChain,d0 as defineAgentHooks,p$ as defaultVoiceStore,I6 as defaultUsageLimitStore,k6 as defaultSummaryStore,H8 as defaultNonceStore,n$ as defaultFileOwners,rJ as defaultAttachmentStore,r$ as defaultAgentStore,lJ as VoiceHangup,o as VoiceBridge,N6 as Usage,L$ as ToolNamespace,l as ToolError,q6 as Skill,tJ as ScopedAttachments,b6 as SKILLS_NAMESPACE,t$ as RedisReceiptStore,fQ as RedisNonceStore,gJ as RealtimeSideband,g as RealtimeRequestError,FJ as RealtimeClient,O8 as Prompt,yQ as PrismaNonceStore,w6 as PendingEscalation,v$ as OpenAIProvider,S$ as OpenAIImageProvider,m$ as MemoryVoiceSessionStore,x6 as MemoryUsageLimitStore,j6 as MemorySummaryStore,a$ as MemoryReceiptStore,V8 as MemoryNonceStore,dJ as MemoryLiveRuns,iJ as MemoryFileOwners,mJ as MemoryCircuitStore,mQ as MemoryAttachmentStore,CJ as MemoryAgentStore,E8 as MemoryAgentJobStore,p8 as MEMORY_NAMESPACE,LJ as LiveRunNotFoundError,k8 as JobsRequireThreadError,j8 as JobHandle,F6 as JSONSchemaError,gQ as InvalidAttachmentScopeError,v8 as InMemoryAgentMemoryStore,fJ as ImageRequestError,yJ as ImageProvider,C$ as ImageModel,QJ as FrameCursorEvictedError,PJ as FallbackProvider,c8 as FakeAgentMemoryStore,IJ as Eval,l$ as DatabaseAgentStore,H$ as DatabaseAgentMemoryStore,Y$ as DatabaseAgentJobStore,b9 as DEFAULT_TRANSCRIPTION_MODEL,y8 as DEFAULT_MEMORY_MAX_TOKENS,m8 as DEFAULT_MEMORY_LIMITS,S6 as DEFAULT_MAX_SUMMARY_TOKENS,f6 as DEFAULT_MAX_RUN_DURATION_MS,T8 as DEFAULT_JOB_DEADLINE_MS,EJ as DEFAULT_JOBS_CONTEXT_MAX,NJ as DEFAULT_DELEGATE_NAME,O6 as DEFAULT_CONTEXT_WINDOW_STEP,_6 as DEFAULT_CONTEXT_WINDOW_NOTE,A6 as DEFAULT_COMPACT_TRIGGER_TOKENS,R6 as DEFAULT_COMPACT_INSTRUCTIONS,E6 as COMPACT_SUMMARY_HEADER,h$ as AzureOpenAIProvider,A$ as AzureOpenAIImageProvider,hQ as AttachmentNotFoundError,eJ as AgentTurnError,wJ as AgentTool,y6 as AgentRunError,$J as AgentProvider,h8 as AgentMemoryRefusedError,g8 as AgentMemoryConflictError,u8 as AgentMemories,c as AgentJobs,K$ as AgentJobDeadlineSweep,x8 as AgentJob,F8 as AgentController,v6 as Agent};
|
|
266
266
|
|
|
267
|
-
//# debugId=
|
|
267
|
+
//# debugId=CFAD37CD0E42010664756E2164756E21
|