gemi 0.141.0 → 0.143.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 +4 -3
- package/dist/app/App.d.ts.map +1 -1
- package/dist/app/index.js +1 -1
- package/dist/auth/AuthController.d.ts.map +1 -1
- package/dist/auth/config.d.ts +24 -5
- package/dist/auth/config.d.ts.map +1 -1
- package/dist/bin/gemi.js +2 -2
- package/dist/bin/gemi.js.map +3 -3
- package/dist/bun/plugin.js +1 -1
- package/dist/bun/preload.js +1 -1
- package/dist/{chunk-s58hbczk.js → chunk-0839f72f.js} +2 -2
- package/dist/{chunk-s58hbczk.js.map → chunk-0839f72f.js.map} +1 -1
- package/dist/{chunk-0c553zfq.js → chunk-0t2ym9ap.js} +3 -3
- package/dist/{chunk-0c553zfq.js.map → chunk-0t2ym9ap.js.map} +1 -1
- package/dist/{chunk-1axhttzr.js → chunk-159c392q.js} +2 -2
- package/dist/{chunk-1axhttzr.js.map → chunk-159c392q.js.map} +1 -1
- package/dist/{chunk-r6thf4ge.js → chunk-1cn7ets3.js} +3 -3
- package/dist/{chunk-r6thf4ge.js.map → chunk-1cn7ets3.js.map} +1 -1
- package/dist/{chunk-kddgfct7.js → chunk-1ed75a7b.js} +3 -3
- package/dist/{chunk-kddgfct7.js.map → chunk-1ed75a7b.js.map} +1 -1
- package/dist/chunk-1rvnk7g8.js +24 -0
- package/dist/{chunk-03qkwjvy.js.map → chunk-1rvnk7g8.js.map} +5 -6
- package/dist/{chunk-98dxtkbt.js → chunk-1skdsmjx.js} +2 -2
- package/dist/{chunk-98dxtkbt.js.map → chunk-1skdsmjx.js.map} +1 -1
- package/dist/{chunk-x4g0r9d3.js → chunk-1w5dnkd1.js} +2 -2
- package/dist/{chunk-x4g0r9d3.js.map → chunk-1w5dnkd1.js.map} +1 -1
- package/dist/{chunk-3wpxqcw7.js → chunk-1x9ghjpt.js} +1 -1
- package/dist/{chunk-vtqvq9ca.js → chunk-20d0n391.js} +2 -2
- package/dist/{chunk-tbhtx2t0.js.map → chunk-20d0n391.js.map} +1 -1
- package/dist/{chunk-y7v30zd8.js → chunk-236be97q.js} +1 -1
- package/dist/{chunk-tghh8r2q.js → chunk-2ra5skyk.js} +2 -2
- package/dist/{chunk-tghh8r2q.js.map → chunk-2ra5skyk.js.map} +1 -1
- package/dist/{chunk-kc2z9z3m.js → chunk-3q7sc68p.js} +2 -2
- package/dist/{chunk-kc2z9z3m.js.map → chunk-3q7sc68p.js.map} +1 -1
- package/dist/{chunk-t7qp951h.js → chunk-5g7m7g4a.js} +3 -3
- package/dist/{chunk-t7qp951h.js.map → chunk-5g7m7g4a.js.map} +1 -1
- package/dist/{chunk-5013raxj.js → chunk-5qfzvnyp.js} +3 -3
- package/dist/{chunk-5013raxj.js.map → chunk-5qfzvnyp.js.map} +1 -1
- package/dist/{chunk-eydahc2f.js → chunk-5xfpqda5.js} +1 -1
- package/dist/{chunk-p131vmpy.js → chunk-63q7ycwt.js} +2 -2
- package/dist/{chunk-p131vmpy.js.map → chunk-63q7ycwt.js.map} +1 -1
- package/dist/{chunk-gy307m19.js → chunk-68f0jpje.js} +2 -2
- package/dist/{chunk-gy307m19.js.map → chunk-68f0jpje.js.map} +1 -1
- package/dist/{chunk-b9d021hx.js → chunk-78bfmwp0.js} +2 -2
- package/dist/{chunk-b9d021hx.js.map → chunk-78bfmwp0.js.map} +1 -1
- package/dist/{chunk-j9hf1jyd.js → chunk-83cvkhzn.js} +2 -2
- package/dist/{chunk-j9hf1jyd.js.map → chunk-83cvkhzn.js.map} +1 -1
- package/dist/{chunk-9yfg4nqq.js → chunk-8ex0y47w.js} +2 -2
- package/dist/{chunk-9yfg4nqq.js.map → chunk-8ex0y47w.js.map} +1 -1
- package/dist/{chunk-me6mmvbq.js → chunk-8ky8cmde.js} +2 -2
- package/dist/{chunk-me6mmvbq.js.map → chunk-8ky8cmde.js.map} +1 -1
- package/dist/{chunk-gp4s95kn.js → chunk-9dkpv8ev.js} +2 -2
- package/dist/{chunk-gp4s95kn.js.map → chunk-9dkpv8ev.js.map} +1 -1
- package/dist/{chunk-v2cv3wcw.js → chunk-9k46m1vf.js} +2 -2
- package/dist/{chunk-v2cv3wcw.js.map → chunk-9k46m1vf.js.map} +1 -1
- package/dist/chunk-9qfd02h8.js +10 -0
- package/dist/{chunk-0540ptgm.js.map → chunk-9qfd02h8.js.map} +4 -4
- package/dist/{chunk-e9eh5k8a.js → chunk-9tgcmx4h.js} +2 -2
- package/dist/{chunk-e9eh5k8a.js.map → chunk-9tgcmx4h.js.map} +1 -1
- package/dist/{chunk-23mcs80p.js → chunk-9xzg05xg.js} +3 -3
- package/dist/{chunk-23mcs80p.js.map → chunk-9xzg05xg.js.map} +1 -1
- package/dist/{chunk-e9xbdgb2.js → chunk-a37shxb1.js} +2 -2
- package/dist/{chunk-e9xbdgb2.js.map → chunk-a37shxb1.js.map} +1 -1
- package/dist/chunk-aw8gj99f.js +4 -0
- package/dist/chunk-aw8gj99f.js.map +10 -0
- package/dist/{chunk-k732d7x5.js → chunk-azd6da5h.js} +2 -2
- package/dist/{chunk-k732d7x5.js.map → chunk-azd6da5h.js.map} +1 -1
- package/dist/{chunk-1fe07ge4.js → chunk-b4jx4fzq.js} +1 -1
- package/dist/chunk-b6mgrrk6.js +5 -0
- package/dist/{chunk-5gkzbhts.js.map → chunk-b6mgrrk6.js.map} +1 -1
- package/dist/{chunk-6zz3kez5.js → chunk-ce9wm3r9.js} +2 -2
- package/dist/{chunk-6zz3kez5.js.map → chunk-ce9wm3r9.js.map} +1 -1
- package/dist/{chunk-t6n490ha.js → chunk-ceb4jcrm.js} +2 -2
- package/dist/{chunk-t6n490ha.js.map → chunk-ceb4jcrm.js.map} +1 -1
- package/dist/{chunk-9b4ypfcw.js → chunk-ej4kf7m5.js} +3 -3
- package/dist/{chunk-9b4ypfcw.js.map → chunk-ej4kf7m5.js.map} +1 -1
- package/dist/{chunk-b3tmkge9.js → chunk-f2e7n064.js} +2 -2
- package/dist/{chunk-b3tmkge9.js.map → chunk-f2e7n064.js.map} +1 -1
- package/dist/{chunk-6qydm38w.js → chunk-f5qdyw45.js} +2 -2
- package/dist/{chunk-6qydm38w.js.map → chunk-f5qdyw45.js.map} +1 -1
- package/dist/{chunk-r1x5ms0y.js → chunk-fpz9e3xx.js} +2 -2
- package/dist/{chunk-r1x5ms0y.js.map → chunk-fpz9e3xx.js.map} +1 -1
- package/dist/{chunk-mj55jdwp.js → chunk-fsem81ec.js} +1 -1
- package/dist/{chunk-b97tpvet.js → chunk-hnsrwr0p.js} +2 -2
- package/dist/{chunk-b97tpvet.js.map → chunk-hnsrwr0p.js.map} +1 -1
- package/dist/{chunk-dptp6ceg.js → chunk-hyhbk12v.js} +2 -2
- package/dist/{chunk-dptp6ceg.js.map → chunk-hyhbk12v.js.map} +1 -1
- package/dist/{chunk-eve0hewa.js → chunk-j2k408xc.js} +3 -3
- package/dist/{chunk-eve0hewa.js.map → chunk-j2k408xc.js.map} +1 -1
- package/dist/{chunk-ct3sgfpj.js → chunk-jmhrpfqn.js} +2 -2
- package/dist/{chunk-ct3sgfpj.js.map → chunk-jmhrpfqn.js.map} +1 -1
- package/dist/{chunk-qdz4dqbf.js → chunk-kaphqnpp.js} +3 -3
- package/dist/{chunk-qdz4dqbf.js.map → chunk-kaphqnpp.js.map} +1 -1
- package/dist/chunk-kkqw8bqg.js +117 -0
- package/dist/{chunk-akahs8fn.js.map → chunk-kkqw8bqg.js.map} +10 -8
- package/dist/{chunk-dzvp8ynr.js → chunk-ktrm6y5j.js} +3 -3
- package/dist/{chunk-dzvp8ynr.js.map → chunk-ktrm6y5j.js.map} +1 -1
- package/dist/{chunk-vp4x2c0k.js → chunk-kzc6bn8n.js} +2 -2
- package/dist/{chunk-vp4x2c0k.js.map → chunk-kzc6bn8n.js.map} +1 -1
- package/dist/{chunk-5aj27bgc.js → chunk-m6t5a0me.js} +2 -2
- package/dist/{chunk-5aj27bgc.js.map → chunk-m6t5a0me.js.map} +1 -1
- package/dist/{chunk-yxhg3wjf.js → chunk-m70hn4eg.js} +2 -2
- package/dist/{chunk-yxhg3wjf.js.map → chunk-m70hn4eg.js.map} +1 -1
- package/dist/{chunk-rw4z3n9b.js → chunk-m8yd59gg.js} +2 -2
- package/dist/{chunk-rw4z3n9b.js.map → chunk-m8yd59gg.js.map} +1 -1
- package/dist/{chunk-b4qh3ywd.js → chunk-maqkrbsb.js} +2 -2
- package/dist/{chunk-b4qh3ywd.js.map → chunk-maqkrbsb.js.map} +1 -1
- package/dist/{chunk-7dwgex81.js → chunk-mfn94b95.js} +2 -2
- package/dist/{chunk-7dwgex81.js.map → chunk-mfn94b95.js.map} +1 -1
- package/dist/{chunk-jrvg80jw.js → chunk-mkw35cz7.js} +2 -2
- package/dist/{chunk-jrvg80jw.js.map → chunk-mkw35cz7.js.map} +1 -1
- package/dist/{chunk-7hdfbp2x.js → chunk-mnmr27wd.js} +2 -2
- package/dist/{chunk-7hdfbp2x.js.map → chunk-mnmr27wd.js.map} +1 -1
- package/dist/{chunk-1cdz01em.js → chunk-n9zycjm1.js} +3 -3
- package/dist/{chunk-1cdz01em.js.map → chunk-n9zycjm1.js.map} +1 -1
- package/dist/{chunk-d0kw04ym.js → chunk-ncb1qtae.js} +2 -2
- package/dist/{chunk-d0kw04ym.js.map → chunk-ncb1qtae.js.map} +1 -1
- package/dist/{chunk-c7ecv545.js → chunk-p57nt0pm.js} +2 -2
- package/dist/{chunk-c7ecv545.js.map → chunk-p57nt0pm.js.map} +1 -1
- package/dist/{chunk-yxjfghq3.js → chunk-p81qeav5.js} +3 -3
- package/dist/{chunk-yxjfghq3.js.map → chunk-p81qeav5.js.map} +1 -1
- package/dist/{chunk-rwrcsfzv.js → chunk-qt6x2r6a.js} +2 -2
- package/dist/{chunk-rwrcsfzv.js.map → chunk-qt6x2r6a.js.map} +1 -1
- package/dist/{chunk-qvtmn7mn.js → chunk-r0z27j6t.js} +2 -2
- package/dist/{chunk-qvtmn7mn.js.map → chunk-r0z27j6t.js.map} +1 -1
- package/dist/{chunk-6d9f4vw0.js → chunk-r567t83k.js} +4 -4
- package/dist/{chunk-6d9f4vw0.js.map → chunk-r567t83k.js.map} +1 -1
- package/dist/{chunk-pfgbkhmm.js → chunk-rezmtdyt.js} +2 -2
- package/dist/{chunk-pfgbkhmm.js.map → chunk-rezmtdyt.js.map} +1 -1
- package/dist/{chunk-apfk702c.js → chunk-rvm5mkwm.js} +2 -2
- package/dist/{chunk-apfk702c.js.map → chunk-rvm5mkwm.js.map} +1 -1
- package/dist/{chunk-eyqsvzej.js → chunk-s29tgy4y.js} +2 -2
- package/dist/{chunk-eyqsvzej.js.map → chunk-s29tgy4y.js.map} +1 -1
- package/dist/{chunk-dje31gme.js → chunk-sa6a0wy1.js} +2 -2
- package/dist/{chunk-dje31gme.js.map → chunk-sa6a0wy1.js.map} +1 -1
- package/dist/{chunk-d1whcvyn.js → chunk-sgwgj2q0.js} +1 -1
- package/dist/{chunk-8r9kna46.js → chunk-t03nda3s.js} +2 -2
- package/dist/{chunk-8r9kna46.js.map → chunk-t03nda3s.js.map} +1 -1
- package/dist/{chunk-tbhtx2t0.js → chunk-t2nsn0r2.js} +2 -2
- package/dist/{chunk-vtqvq9ca.js.map → chunk-t2nsn0r2.js.map} +1 -1
- package/dist/{chunk-7p64zc6a.js → chunk-tkvamktq.js} +2 -2
- package/dist/{chunk-7p64zc6a.js.map → chunk-tkvamktq.js.map} +1 -1
- package/dist/{chunk-8gfgsmxk.js → chunk-v57ndv0h.js} +2 -2
- package/dist/{chunk-8gfgsmxk.js.map → chunk-v57ndv0h.js.map} +1 -1
- package/dist/{chunk-e3y72vzw.js → chunk-wffc5k3m.js} +2 -2
- package/dist/{chunk-e3y72vzw.js.map → chunk-wffc5k3m.js.map} +1 -1
- package/dist/{chunk-pxavt1j3.js → chunk-x0t3t7g3.js} +2 -2
- package/dist/{chunk-pxavt1j3.js.map → chunk-x0t3t7g3.js.map} +1 -1
- package/dist/{chunk-dvwdehnp.js → chunk-y5yac6n1.js} +2 -2
- package/dist/{chunk-dvwdehnp.js.map → chunk-y5yac6n1.js.map} +1 -1
- package/dist/{chunk-ks7msv3e.js → chunk-yjszzjyj.js} +2 -2
- package/dist/{chunk-ks7msv3e.js.map → chunk-yjszzjyj.js.map} +1 -1
- package/dist/{chunk-18y8n1r3.js → chunk-z80v4z8y.js} +2 -2
- package/dist/{chunk-18y8n1r3.js.map → chunk-z80v4z8y.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/RateLimitMiddleware.d.ts.map +1 -1
- package/dist/http/clientAddress.d.ts +8 -0
- package/dist/http/clientAddress.d.ts.map +1 -0
- 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/server/forwardedFor.d.ts +28 -20
- package/dist/server/forwardedFor.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/services/broadcast/SocketHub.d.ts.map +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.d.ts.map +1 -1
- 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/DomainResolver.d.ts +2 -1
- package/dist/services/router/DomainResolver.d.ts.map +1 -1
- package/dist/services/router/DomainRouter.d.ts +17 -0
- package/dist/services/router/DomainRouter.d.ts.map +1 -1
- package/dist/services/router/RouteServiceProvider.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-03qkwjvy.js +0 -24
- package/dist/chunk-0540ptgm.js +0 -10
- package/dist/chunk-3v4esxbd.js +0 -4
- package/dist/chunk-3v4esxbd.js.map +0 -10
- package/dist/chunk-5gkzbhts.js +0 -5
- package/dist/chunk-akahs8fn.js +0 -117
- /package/dist/{chunk-3wpxqcw7.js.map → chunk-1x9ghjpt.js.map} +0 -0
- /package/dist/{chunk-y7v30zd8.js.map → chunk-236be97q.js.map} +0 -0
- /package/dist/{chunk-eydahc2f.js.map → chunk-5xfpqda5.js.map} +0 -0
- /package/dist/{chunk-1fe07ge4.js.map → chunk-b4jx4fzq.js.map} +0 -0
- /package/dist/{chunk-mj55jdwp.js.map → chunk-fsem81ec.js.map} +0 -0
- /package/dist/{chunk-d1whcvyn.js.map → chunk-sgwgj2q0.js.map} +0 -0
package/dist/ai/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$c as c9,Ac as $$,Bc as Z$,Cc as K$,Dc as G$,Ec as X$,Fc as Y$,Gc as V$,Hc as H$,Ic as z$,Kc as w,Lc as N$,Mc as i,Nc as k,Oc as gQ,Pc as x9,Qc as q9,Rc as I9,Sc as w9,Tc as b9,Uc as f9,Vc as v9,Wc as h9,Xb as vQ,Xc as y9,Yb as k6,Yc as g9,Zb as hQ,Zc as u9,_c as TQ,ac as MJ,ad as I6,bc as j,bd as m9,cc as E,cd as p9,dc as g,dd as OJ,ec as yQ,ed as oJ,fc as R6,fd as l9,gc as T6,gd as d9,hc as j6,hd as i9,ic as m,id as n9,jc as E6,jd as o9,kc as yJ,kd as a9,lc as x6,mc as q6,nc as gJ,oc as oQ,pc as aQ,rc as sQ,sc as h,tc as G6,uc as X6,vc as tQ,xc as rQ,yc as W$,zc as Q$}from"../chunk-
|
|
2
|
+
import{$c as c9,Ac as $$,Bc as Z$,Cc as K$,Dc as G$,Ec as X$,Fc as Y$,Gc as V$,Hc as H$,Ic as z$,Kc as w,Lc as N$,Mc as i,Nc as k,Oc as gQ,Pc as x9,Qc as q9,Rc as I9,Sc as w9,Tc as b9,Uc as f9,Vc as v9,Wc as h9,Xb as vQ,Xc as y9,Yb as k6,Yc as g9,Zb as hQ,Zc as u9,_c as TQ,ac as MJ,ad as I6,bc as j,bd as m9,cc as E,cd as p9,dc as g,dd as OJ,ec as yQ,ed as oJ,fc as R6,fd as l9,gc as T6,gd as d9,hc as j6,hd as i9,ic as m,id as n9,jc as E6,jd as o9,kc as yJ,kd as a9,lc as x6,mc as q6,nc as gJ,oc as oQ,pc as aQ,rc as sQ,sc as h,tc as G6,uc as X6,vc as tQ,xc as rQ,yc as W$,zc as Q$}from"../chunk-mfn94b95.js";import{Cd as mQ}from"../chunk-6jd0e1dz.js";import"../chunk-ce9wm3r9.js";import{Ah as _6,Bi as AQ,Fi as A6,Qh as y$,Rh as T9,Sh as j9,Th as E9,Uh as x,xh as M6,yi as S6}from"../chunk-j2k408xc.js";import{Gi as C6,Ii as vJ,Ji as hJ}from"../chunk-9k46m1vf.js";import{Si as y}from"../chunk-mnmr27wd.js";import"../chunk-1skdsmjx.js";import"../chunk-yjszzjyj.js";import{Vj as BJ,Wj as FJ,ik as nQ}from"../chunk-p81qeav5.js";import"../chunk-t03nda3s.js";import{Xk as s$}from"../chunk-1ed75a7b.js";import"../chunk-0839f72f.js";import"../chunk-s29tgy4y.js";import"../chunk-8ex0y47w.js";import"../chunk-t2nsn0r2.js";class cJ extends mQ{name="AgentJobDeadlineSweep";cron="* * * * *";async callback(){while(await h.sweep({limit:100})===100);}}var HJ=20;function lQ(J,Q){if(Q<=0||J.length===0)return null;let $=(K,G)=>G.createdAt-K.createdAt||(K.id<G.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 G=[`- ${K.id} (${K.toolName})`];if(K.state==="running")G.push(`running since ${mJ(K.createdAt)}`);else if(K.state==="ok")G.push(`finished at ${mJ(K.settledAt??K.updatedAt)}`);else{let Y=K.error?`${K.error.code}: ${pQ(K.error.message,200)}`:"failed";G.push(`failed at ${mJ(K.settledAt??K.updatedAt)} (${Y})`)}if(K.summary!==void 0)G.push(`summary: ${pQ(JSON.stringify(K.summary),300)}`);if(K.orphaned)G.push("its tool call was lost when the turn that started it was cut short");return G.join("; ")}),"</jobs>"].join(`
|
|
3
3
|
`)}function mJ(J){return new Date(J).toISOString().replace(/\.\d{3}Z$/,"Z")}function pQ(J,Q){return J.length<=Q?J:`${J.slice(0,Q-1)}\u2026`}class lJ{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 h6(this.dialect,this.table))await this.sql.unsafe(J)}async transaction(J){if(this.connection===void 0||this.joinable())return J();return nQ(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,
|
|
@@ -152,4 +152,4 @@ return 0`;class RQ{injectedClient;prefix;constructor(J={}){this.injectedClient=J
|
|
|
152
152
|
|
|
153
153
|
`)||void 0,N=await this.context(J,{body:V}),L=await this.attachmentsFor(J,Z,{body:V}),R=this.agent.memory?await this.memoryScopes(J,{body:V}):void 0;if(H?.cancelled)return U6();let S=Z?new xQ(this.store,Z,P,(A)=>this.reportHookFailure(A)):null,q=`run_${crypto.randomUUID()}`,I={req:J,runId:q,threadId:Z},f={id:null,notified:Promise.resolve()},M=this.agent.stream({runId:q,messages:P,turn:K,threadId:Z,...S?{onMessage:(A)=>S.finish(A)}:{},onTurn:(A)=>{if(f.id!==null)return;f.id=A.id;let d=S?S.settled():Promise.resolve();f.notified=d.then(()=>this.safely(()=>this.onMessage(A,I)))},instructions:F,context:N,attachments:L,body:V,redactError:(A,d)=>this.redactError(A,d,I),nonces:this.nonces,receipts:this.receipts,subject:X,...R?{memory:{scopes:R,...this.memoryMaxTokens!==void 0?{maxTokens:this.memoryMaxTokens}:{}}}:{},...Z?{jobs:{owner:X}}:{},...this.contextWindow!==void 0?{contextWindow:this.contextWindow}:{},...Z&&I6(this.store)?{summaryStore:this.store}:{},...this.prepareStep!==uQ.prototype.prepareStep?{prepareStep:(A)=>this.prepareStep(A,I)}:{}}),T=this.liveRuns.register(M,{threadId:Z,owner:X,clientRunId:Y,onEvent:(A)=>this.dispatchEvent(A,I),onInternalError:(A)=>this.reportHookFailure(A),maxRunDurationMs:this.agent.maxRunDurationMs});if(B=M,S)this.follow(M,S);let{stored:C,hooks:cQ}=this.persistRun(M,I,T,S,f);if(H6.set(M,C),XJ.has(J))XJ.set(J,{run:M,hooks:cQ});return J.ctx?.()?.waitUntil(cQ),M.toResponse()};try{await this.authorizeRequest(J,{route:"stream",threadId:Z,body:V});let P=await this.foreignFile([...K?.files??[],...Z?[]:L9($.messages)],X);if(P)return P;if(H?.cancelled)return U6();let O=await this.runLimitKey(J,{owner:X,threadId:Z}),F=O===null?bJ:K9(this.liveRuns).take(O,Z?`thread:${Z}`:`run:${crypto.randomUUID()}`,this.maxConcurrentRuns);if(!F)return fQ(429,"too_many_runs",`You already have ${this.maxConcurrentRuns} conversations answering. Wait for one to finish, or stop it, and send again.`);try{return Z?await this.withThread(Z,X,D):await D()}finally{let N=B;if(N)N.result().then(F,F);else F()}}finally{if(H&&IJ.get(Y)===H)IJ.delete(Y)}}async withThread(J,Q,$){let Z=qJ.get(J)??Promise.resolve(),W,K=new Promise((Y)=>{W=Y}),G=Z.then(()=>K);qJ.set(J,G),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 VJ();let V=Y?this.liveRuns.get(Y.runId):null;if(V)V.stop({reason:"superseded by a later turn on this thread"}),await H6.get(V);return await $()}finally{if(W(),qJ.get(J)===G)qJ.delete(J)}}async attach(J=new x){let Q=await YJ(J,wJ);if(Q.error)return t(Q);let $=Q.body,Z=typeof $.threadId==="string"?$.threadId:O9(J,"threadId");if(!Z)return _(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 VJ();if(!W)return _(404,{code:"no_live_run",message:`No run in progress for thread ${Z} in this process.`});let K=typeof $.runId==="string"?$.runId:void 0,G=K&&K!==W.runId?void 0:P9(J,$);try{return A6(this.liveRuns.replay(W.runId,G))}catch(Y){if(Y instanceof s)return _(410,{code:Y.code,message:Y.message,oldestSeq:Y.oldest});if(Y instanceof GJ)return _(404,{code:Y.code,message:Y.message});throw Y}}async stop(J=new x){let Q=await YJ(J,wJ);if(Q.error)return t(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 G=IJ.get($.clientRunId);if(G){if(G.owner!==null&&G.owner!==Z)return VJ();return G.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 VJ();return K.stop({reason:typeof $.reason==="string"?$.reason:void 0}),{stopped:!0}}attachmentScope(J,Q,$){let Z=J.ctx()?.user,W=Z?.id??Z?.publicId;if(W!==void 0&&W!==null&&String(W)!=="")return{key:`user:${String(W)}`};if(Q)return{key:`thread:${Q}`};return null}attachmentLimits(J){return null}checkUpload(J,Q,$){}attachmentDestination(J,Q,$){return"both"}async attachmentsFor(J,Q,$={body:{}}){let Z=await this.attachmentScope(J,Q,$);if(!Z)return null;return new yJ(this.attachments,this.attachmentStorage,Z)}async voiceStart(J=new x){let Q=this.voice;if(!Q)return qQ();let $=await YJ(J,wJ);if($.error)return t($);let{sdp:Z,threadId:W,pushToTalk:K}=$.body;if(typeof Z!=="string"||!Z.trimStart().startsWith("v="))return _(400,{code:"invalid_request",message:"`sdp` must be the browser's SDP offer."});let G=fJ($.body,M9),Y=typeof W==="string"&&W!==""?W:void 0;await this.authorizeRequest(J,{route:"stream",threadId:Y,body:G});let V=J.ctx?.()?.user??null,X=await Q.start({req:J,body:G,threadId:Y,user:V,pushToTalk:K===!0}),H=Date.now(),B,z=async(N)=>{if(N!==void 0)console.error("[gemi/ai] a voice session could not start.",N);if(B)await Q.realtime.hangup(B).catch((L)=>{console.error("[gemi/ai] a voice call that failed to start could not be hung up.",L)});try{await X.onEnd?.({sessionId:"",...B?{callId:B}:{},threadId:X.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(L){console.error("[gemi/ai] a voice session's onEnd threw.",L)}},D=X.threadId??Y;if(!D)return await z(void 0),_(400,{code:"invalid_request",message:"A voice session needs a thread: send `threadId`, or answer one from `voice.start`."});try{if(D!==Y)await this.authorizeRequest(J,{route:"stream",threadId:D,body:G})}catch(N){throw await z(void 0),N}let U=crypto.randomUUID(),P=X.tools??[];try{if(X.mcp)P=[...P,...await UQ(X.mcp,{user:V,sessionId:U})]}catch(N){return await z(N),_(500,{code:"voice_unavailable",message:"Voice isn't available right now."})}let O={...X.session,tools:[...WJ(Q.delegate),...X.session?.tools??[],...P.map((N)=>N.tool)],...K===!0?{turnDetection:null}:{}},F;try{F=await Q.realtime.createCall({sdp:Z,session:O,safetyIdentifier:X.safetyIdentifier})}catch(N){await z(N);let L=N instanceof v&&N.code==="rate_limited";return _(L?429:502,{code:"voice_unavailable",message:"Voice isn't available right now."})}B=F.callId;try{await this.voiceStore.create({id:U,callId:F.callId,threadId:D,owner:await this.runOwner(J),body:G,startedAt:H});let{threadId:N,session:L,safetyIdentifier:R,mcp:S,tools:q,...I}=X;return{sessionId:p.start({...I,tools:P,controller:this.constructor,threadId:D,user:V,body:G,call:{realtime:Q.realtime,callId:F.callId},sessionId:U,store:this.voiceStore,liveRuns:this.liveRuns,delegate:Q.delegate,session:O}).sessionId,sdp:F.sdpAnswer,threadId:D,delegate:Q.delegate?.name??KJ,endsAt:H+(X.limits?.maxDurationMs??900000)}}catch(N){return await z(N),_(500,{code:"voice_unavailable",message:"Voice isn't available right now."})}}async voiceUpdate(J=new x){if(!this.voice)return qQ();let Q=await this.voiceSession(J);if(Q instanceof Response)return Q;let $=await YJ(J,wJ);if($.error)return t($);let Z=fJ($.body,[]);if(await this.authorizeRequest(J,{route:"stream",threadId:Q.threadId,body:Z}),Q.endedAt!==void 0)return _(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 qQ();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 _(404,{code:"voice_not_found",message:"No such voice session."});if($.owner!==null&&$.owner!==await this.runOwner(J))return VJ();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=X9(Q.get("body")),G=Q.get("threadId");await this.authorizeRequest(J,{route:"upload",threadId:typeof G==="string"&&G.length>0?G:void 0,body:K});let Y=V9(await this.attachmentLimits(J),$,Z,W);if(Y)throw new bQ(Y.code,Y.message);let V=typeof G==="string"&&G.length>0&&await this.store.loadThread(G)!==null?G:void 0,X=await this.runOwner(J),H=(S)=>this.fileOwners.record(S,{owner:X,name:Z,mimeType:W,size:$.size,createdAt:new Date().toISOString()}),B={body:K,threadId:V},z=await this.checkUpload({name:Z,size:$.size,mimeType:W},J,B);if(z)throw new bQ(z.code||"upload_refused",z.message);let D=await this.attachmentDestination($,J,B),U=C9(D,Q.get("destination")),P=await this.attachmentScope(J,V,{body:K}),O=U!=="provider"&&!P;if(O){if(U==="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()`.');_9()}if(U==="provider"||!P){let S=await B6(this.agent.provider,$);await H(S);let q={fileId:S,name:Z,mimeType:W,size:$.size,destination:"provider"};if(O)q.downgraded="no_scope";return q}let F=E6(),N=await this.attachmentStorage.put({name:x6(F,Z),body:$,contentType:W}),L=U==="both"?await B6(this.agent.provider,$):void 0;if(L)await H(L);let R={id:F,scopeKey:P.key,fileId:L,objectName:N,name:Z,mimeType:W,size:$.size,createdAt:new Date().toISOString(),destination:U};return await this.attachments.put(P,R),{fileId:L,attachmentId:F,name:Z,mimeType:W,size:$.size,destination:U}}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 N9()}return null}onMessage(J,Q){}onToolCall(J,Q){}onAwaitingInput(J,Q){}redactError(J,Q,$){return yQ(J,Q)}onError(J,Q){}onStreamComplete(J,Q){}reportHookFailure(J){console.error("[gemi/ai] agent controller hook failed",J)}async dispatchEvent(J,Q){switch(J.type){case"tool-call":if(!J.part.partial&&!J.resent)await this.onToolCall({toolCallId:J.part.toolCallId,name:String(J.part.name),input:J.part.input},Q);return;case"awaiting-input":await this.onAwaitingInput(J.pending,Q);return;case"error":await this.onError(R6(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 W6(Q,Z),K=W.messages,G=[],Y=new Map(W.settled.map((V)=>[V.id,V]));if(R9(K)||$)try{let V=await Y6(K,{threadId:J,store:h.store,isRunLive:Z,outputSchemaFor:(X)=>this.toolOutputSchema(X),scan:this.jobsBlockMax()});K=V.messages,G=V.jobs;for(let X of V.settled)Y.set(X.id,X);if($&&V.orphans.length>0){await V6(h.store,V.orphans,(H)=>this.reportHookFailure(H));let X=new Set(V.orphans.map((H)=>H.id));G=G.map((H)=>X.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:G}}jobsBlockMax(){let J=this.agent.jobs?.contextBlock;if(J===!1)return 0;return J?.max??HJ}jobsBlock(J){return lQ(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(),G=(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 X=V.messages;if(Z?.close(X),await Z?.settled(),Q.threadId&&X.length>0)try{await this.store.appendMessages(Q.threadId,X)}catch(H){this.reportHookFailure(H)}K=this.notifyRun(V,X,Q,W)})(),Y=G.then(()=>A9(Promise.all([K,$]).then(()=>{}),this.hookHoldMs));return{stored:G,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 IQ=["turn","clientRunId","threadId","messages","regenerate"],G9=["text","files","toolResults"];function fJ(J,Q=f6(J)?IQ:[...IQ,...G9]){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 X9(J){if(J===null)return{};let Q;if(typeof J==="string")try{Q=JSON.parse(J)}catch{throw new wQ("The upload's `body` field is not valid JSON.")}if(Q===null||typeof Q!=="object"||Array.isArray(Q))throw new wQ("The upload's `body` field must be a JSON object.");return fJ(Q,IQ)}class wQ extends vJ{constructor(J){super(J);this.name="InvalidUploadError",this.payload={api:{status:400,data:{error:{code:"invalid_request",message:J}}},view:{}}}}async function B6(J,Q){try{return await J.upload(Q)}catch($){if($ instanceof w&&Y9.has($.status))throw new b6(k($).message);throw $}}var Y9=new Set([400,413,415,422]);class bQ extends vJ{constructor(J,Q){super(Q);this.name="LimitedUploadError",this.payload={api:{status:422,data:{error:{code:J,message:Q}}},view:{}}}}function V9(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 ${F6(Q.size)}; the limit is ${F6(W)}.`};if(K&&K.length>0&&!K.some((G)=>H9(G,$,Z)))return{code:"unsupported_file_type",message:`${JSON.stringify($)} is not a type this chat accepts. Accepted: ${K.join(", ")}.`};return null}function H9(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 F6(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 b6 extends vJ{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 YJ(J,Q){let $=J?.rawRequest;if(!$||$.method==="GET"||$.method==="HEAD"||!$.body)return{body:{}};if(!z9($.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 P6(Q);let W;try{let G=await D9($,Q);if(G===null)return P6(Q);W=G}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 z9(J){return _6(J)==="application/json"}async function D9(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(bJ),null;Z.push(V)}let K=new Uint8Array(W),G=0;for(let Y of Z)K.set(Y,G),G+=Y.byteLength;return new TextDecoder().decode(K)}function P6(J){return{body:{},status:413,code:"body_too_large",error:`The request body is larger than this agent accepts (${J} bytes).`}}function fQ(J,Q,$){return _(J,{...hJ(C6(J),$,J),code:Q})}function t(J){if(J.status===413)return fQ(413,J.code??"body_too_large",J.error??"");return _(J.status??400,{code:J.code??"invalid_request",message:J.error})}function f6(J){return Boolean(J.turn)&&typeof J.turn==="object"}function B9(J){let Q=f6(J)?J.turn:J,$={};if(typeof Q.text==="string")$.text=Q.text;if(Array.isArray(Q.files)){let Z=F9(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>O6)return{error:`turn.localId is longer than ${O6} characters.`};$.localId=Z}return{turn:$}}var O6=200;function F9(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 B=Z[H];if(B===void 0||B===null||B==="")continue;if(typeof B!=="string")return`${W}.${H} must be a string.`;K[H]=B}let{fileId:G,attachmentId:Y,name:V,mimeType:X}=K;if(G?.startsWith(m))return`${W}.fileId holds a gemi attachment id (${G}). \`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(!G&&!Y)return`${W} has neither a \`fileId\` nor an \`attachmentId\`. Send the ids the upload response answered.`;Q.push({...G?{fileId:G}:{},...Y?{attachmentId:Y}:{},...V!==void 0?{name:V}:{},...X!==void 0?{mimeType:X}:{}})}return Q}function P9(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 O9(J,Q){let $=J?.search?.get(Q);return typeof $==="string"?$:void 0}function U9(J){let Q=gQ(J);for(let $=J.length-1;$>=0;$--){let Z=J[$];if(Z.role!=="user"||Q.has(Z.id))continue;let W="",K=[];for(let G of Z.content){if(G.type==="text")W+=G.text;if(G.type==="file")K.push({...G.fileId?{fileId:G.fileId}:{},...G.attachmentId?{attachmentId:G.attachmentId}:{},...G.name?{name:G.name}:{},...G.mimeType?{mimeType:G.mimeType}:{}})}if(!W&&K.length===0)continue;return{index:$,turn:{...W?{text:W}:{},...K.length>0?{files:K}:{}}}}return null}function U6(){return _(409,{code:"stopped",message:"The turn was stopped before it started."})}function VJ(){return _(403,hJ("permission","This run belongs to someone else.",403))}function N9(){return _(403,hJ("permission","A file in this turn was uploaded by someone else.",403))}function L9(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 M9=["sdp","threadId","pushToTalk"];function qQ(){return _(404,{code:"voice_not_enabled",message:"This agent has no voice: set `voice` on its controller."})}function _(J,Q){return new Response(JSON.stringify({error:Q}),{status:J,headers:{"Content-Type":"application/json"}})}function C9(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 N6=!1;function _9(){if(N6)return;N6=!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 S9=2147483647;function A9(J,Q){let $=J.then(()=>{},()=>{});if(!(Q<=S9))return $;let Z,W=new Promise((K)=>{Z=setTimeout(K,Q)});return Promise.race([$,W]).finally(()=>clearTimeout(Z))}var L6=!1;function k9(J){if(L6||Bun.env.NODE_ENV!=="production")return;if(!(J instanceof vQ))return;L6=!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 R9(J){return J.some((Q)=>Q.content.some(($)=>$.type==="tool-result"&&$.status==="running"))}export{f9 as windowMessages,WJ as voiceTools,x9 as turnStarts,CJ as toRealtimeUsage,u6 as toAgentTools,E9 as supportsStrict,q9 as splitTurns,m9 as settleSummaries,j9 as s,yQ as redactError,I9 as messageSize,UQ as mcpVoiceTools,CQ as liveRuns,TQ as keepSummary,c$ as isCallNotFound,gQ as injectedMessageIds,a9 as generate,w8 as evalChain,LQ as defaultVoiceStore,c9 as defaultSummaryStore,hQ as defaultNonceStore,_Q as defaultFileOwners,gJ as defaultAttachmentStore,jQ as defaultAgentStore,TJ as VoiceHangup,p as VoiceBridge,oJ as ToolNamespace,g as ToolError,l9 as Skill,yJ as ScopedAttachments,d9 as SKILLS_NAMESPACE,RQ as RedisReceiptStore,k6 as RedisNonceStore,_J as RealtimeSideband,v as RealtimeRequestError,$J as RealtimeClient,p9 as PendingEscalation,BQ as OpenAIProvider,eJ as OpenAIImageProvider,NQ as MemoryVoiceSessionStore,u9 as MemorySummaryStore,kQ as MemoryReceiptStore,vQ as MemoryNonceStore,jJ as MemoryLiveRuns,EJ as MemoryFileOwners,kJ as MemoryCircuitStore,q6 as MemoryAttachmentStore,xJ as MemoryAgentStore,oQ as MemoryAgentJobStore,z$ as MEMORY_NAMESPACE,GJ as LiveRunNotFoundError,sQ as JobsRequireThreadError,aQ as JobHandle,T9 as JSONSchemaError,j6 as InvalidAttachmentScopeError,K$ as InMemoryAgentMemoryStore,NJ as ImageRequestError,LJ as ImageProvider,aJ as ImageModel,s as FrameCursorEvictedError,ZJ as FallbackProvider,V$ as FakeAgentMemoryStore,iJ as DatabaseAgentMemoryStore,lJ as DatabaseAgentJobStore,g$ as DEFAULT_TRANSCRIPTION_MODEL,W$ as DEFAULT_MEMORY_MAX_TOKENS,H$ as DEFAULT_MEMORY_LIMITS,v9 as DEFAULT_MAX_SUMMARY_TOKENS,i9 as DEFAULT_MAX_RUN_DURATION_MS,tQ as DEFAULT_JOB_DEADLINE_MS,HJ as DEFAULT_JOBS_CONTEXT_MAX,KJ as DEFAULT_DELEGATE_NAME,w9 as DEFAULT_CONTEXT_WINDOW_STEP,b9 as DEFAULT_CONTEXT_WINDOW_NOTE,h9 as DEFAULT_COMPACT_TRIGGER_TOKENS,y9 as DEFAULT_COMPACT_INSTRUCTIONS,g9 as COMPACT_SUMMARY_HEADER,FQ as AzureOpenAIProvider,JQ as AzureOpenAIImageProvider,T6 as AttachmentNotFoundError,uJ as AgentTurnError,OJ as AgentTool,n9 as AgentRunError,a as AgentProvider,G$ as AgentMemoryRefusedError,X$ as AgentMemoryConflictError,Y$ as AgentMemories,h as AgentJobs,cJ as AgentJobDeadlineSweep,rQ as AgentJob,uQ as AgentController,o9 as Agent};
|
|
154
154
|
|
|
155
|
-
//# debugId=
|
|
155
|
+
//# debugId=641717D0E566822464756E2164756E21
|