gemi 0.117.0 → 0.118.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-6y4nk9f1.js → chunk-01ehxca0.js} +2 -2
- package/dist/{chunk-6y4nk9f1.js.map → chunk-01ehxca0.js.map} +1 -1
- package/dist/chunk-0gtyects.js +10 -0
- package/dist/{chunk-2czfefn2.js.map → chunk-0gtyects.js.map} +3 -3
- package/dist/{chunk-gn7kne7r.js → chunk-1m3hvy3q.js} +2 -2
- package/dist/{chunk-gn7kne7r.js.map → chunk-1m3hvy3q.js.map} +1 -1
- package/dist/{chunk-1ckha5dt.js → chunk-1z1rj2zq.js} +2 -2
- package/dist/{chunk-1ckha5dt.js.map → chunk-1z1rj2zq.js.map} +1 -1
- package/dist/{chunk-n9jyjp4a.js → chunk-30xxc6r7.js} +2 -2
- package/dist/{chunk-n9jyjp4a.js.map → chunk-30xxc6r7.js.map} +1 -1
- package/dist/{chunk-077rea02.js → chunk-33s2xqv1.js} +1 -1
- package/dist/{chunk-5m8vvtvn.js → chunk-39kyz4k6.js} +2 -2
- package/dist/{chunk-5m8vvtvn.js.map → chunk-39kyz4k6.js.map} +1 -1
- package/dist/chunk-3nf95j9e.js +5 -0
- package/dist/{chunk-63ewmmhc.js.map → chunk-3nf95j9e.js.map} +1 -1
- package/dist/{chunk-kpn7f58a.js → chunk-3zxfd7pn.js} +3 -3
- package/dist/{chunk-kpn7f58a.js.map → chunk-3zxfd7pn.js.map} +1 -1
- package/dist/{chunk-62jw0vsf.js → chunk-453rmkpm.js} +2 -2
- package/dist/{chunk-62jw0vsf.js.map → chunk-453rmkpm.js.map} +1 -1
- package/dist/{chunk-mhteg4yz.js → chunk-47h12eme.js} +5 -5
- package/dist/{chunk-mhteg4yz.js.map → chunk-47h12eme.js.map} +1 -1
- package/dist/{chunk-x84as3vy.js → chunk-490sbcma.js} +2 -2
- package/dist/{chunk-x84as3vy.js.map → chunk-490sbcma.js.map} +1 -1
- package/dist/{chunk-stnd9qht.js → chunk-4c1kdd8p.js} +2 -2
- package/dist/{chunk-stnd9qht.js.map → chunk-4c1kdd8p.js.map} +1 -1
- package/dist/{chunk-j1453bn1.js → chunk-5cgq9c43.js} +2 -2
- package/dist/{chunk-j1453bn1.js.map → chunk-5cgq9c43.js.map} +1 -1
- package/dist/{chunk-hr61ekcr.js → chunk-5dbpgyrx.js} +2 -2
- package/dist/{chunk-hr61ekcr.js.map → chunk-5dbpgyrx.js.map} +1 -1
- package/dist/{chunk-wzzrz612.js → chunk-5ses4tcz.js} +2 -2
- package/dist/{chunk-wzzrz612.js.map → chunk-5ses4tcz.js.map} +1 -1
- package/dist/{chunk-pepzecrm.js → chunk-675kzd7z.js} +2 -2
- package/dist/{chunk-pepzecrm.js.map → chunk-675kzd7z.js.map} +1 -1
- package/dist/{chunk-yhp6bvhj.js → chunk-76p0rf4d.js} +3 -3
- package/dist/{chunk-yhp6bvhj.js.map → chunk-76p0rf4d.js.map} +1 -1
- package/dist/{chunk-bvqae0px.js → chunk-8t6dwwz6.js} +1 -1
- package/dist/{chunk-a32wfzdq.js → chunk-8wcpxm41.js} +2 -2
- package/dist/{chunk-a32wfzdq.js.map → chunk-8wcpxm41.js.map} +1 -1
- package/dist/{chunk-ntxsdchf.js → chunk-9pkj7sk6.js} +2 -2
- package/dist/{chunk-ntxsdchf.js.map → chunk-9pkj7sk6.js.map} +1 -1
- package/dist/{chunk-w4e480he.js → chunk-a1qt8aky.js} +2 -2
- package/dist/{chunk-w4e480he.js.map → chunk-a1qt8aky.js.map} +1 -1
- package/dist/{chunk-e7ezmag9.js → chunk-aedkrck1.js} +1 -1
- package/dist/{chunk-arwmvgrz.js → chunk-aqpaw4jq.js} +2 -2
- package/dist/{chunk-arwmvgrz.js.map → chunk-aqpaw4jq.js.map} +1 -1
- package/dist/{chunk-hvpn18bb.js → chunk-bgwtdbfw.js} +3 -3
- package/dist/{chunk-hvpn18bb.js.map → chunk-bgwtdbfw.js.map} +1 -1
- package/dist/{chunk-gjy2qjcr.js → chunk-bz8xssrc.js} +2 -2
- package/dist/{chunk-gjy2qjcr.js.map → chunk-bz8xssrc.js.map} +1 -1
- package/dist/{chunk-yvtmygrk.js → chunk-cte6ysqd.js} +4 -4
- package/dist/{chunk-yvtmygrk.js.map → chunk-cte6ysqd.js.map} +1 -1
- package/dist/{chunk-3w4hk6q2.js → chunk-cvfg88cx.js} +3 -3
- package/dist/{chunk-3w4hk6q2.js.map → chunk-cvfg88cx.js.map} +1 -1
- package/dist/{chunk-wk1tp1f1.js → chunk-d806cy7p.js} +2 -2
- package/dist/{chunk-wk1tp1f1.js.map → chunk-d806cy7p.js.map} +1 -1
- package/dist/{chunk-zkjs3m5m.js → chunk-dwpn6fze.js} +2 -2
- package/dist/{chunk-zkjs3m5m.js.map → chunk-dwpn6fze.js.map} +1 -1
- package/dist/{chunk-nb2gggba.js → chunk-ebret82e.js} +3 -3
- package/dist/{chunk-nb2gggba.js.map → chunk-ebret82e.js.map} +1 -1
- package/dist/{chunk-g2wncay4.js → chunk-eke2frrm.js} +3 -3
- package/dist/{chunk-g2wncay4.js.map → chunk-eke2frrm.js.map} +1 -1
- package/dist/{chunk-ffgmqwzy.js → chunk-fsj5k511.js} +2 -2
- package/dist/{chunk-ffgmqwzy.js.map → chunk-fsj5k511.js.map} +1 -1
- package/dist/{chunk-076jezzg.js → chunk-g5ppst76.js} +3 -3
- package/dist/{chunk-076jezzg.js.map → chunk-g5ppst76.js.map} +1 -1
- package/dist/{chunk-37pk2cjg.js → chunk-g9hhdcax.js} +2 -2
- package/dist/{chunk-37pk2cjg.js.map → chunk-g9hhdcax.js.map} +1 -1
- package/dist/{chunk-dz99g58c.js → chunk-gqfqnv3f.js} +2 -2
- package/dist/{chunk-dz99g58c.js.map → chunk-gqfqnv3f.js.map} +1 -1
- package/dist/{chunk-51w202vr.js → chunk-hkf2k2eq.js} +3 -3
- package/dist/{chunk-51w202vr.js.map → chunk-hkf2k2eq.js.map} +1 -1
- package/dist/{chunk-dcgvq79a.js → chunk-hm9cjxy2.js} +2 -2
- package/dist/{chunk-dcgvq79a.js.map → chunk-hm9cjxy2.js.map} +1 -1
- package/dist/{chunk-5w6kyxsj.js → chunk-hr1r3g0d.js} +2 -2
- package/dist/{chunk-5w6kyxsj.js.map → chunk-hr1r3g0d.js.map} +1 -1
- package/dist/{chunk-fnwbbmnk.js → chunk-hzepfrzy.js} +2 -2
- package/dist/{chunk-fnwbbmnk.js.map → chunk-hzepfrzy.js.map} +1 -1
- package/dist/{chunk-pgy3mfxw.js → chunk-j5858bz7.js} +2 -2
- package/dist/{chunk-pgy3mfxw.js.map → chunk-j5858bz7.js.map} +1 -1
- package/dist/{chunk-c2n6zdyd.js → chunk-jf6qqzat.js} +2 -2
- package/dist/{chunk-c2n6zdyd.js.map → chunk-jf6qqzat.js.map} +1 -1
- package/dist/{chunk-8gtc3s1y.js → chunk-jg79n382.js} +2 -2
- package/dist/{chunk-8gtc3s1y.js.map → chunk-jg79n382.js.map} +1 -1
- package/dist/{chunk-00n3gwr8.js → chunk-k31qfe7a.js} +3 -3
- package/dist/{chunk-00n3gwr8.js.map → chunk-k31qfe7a.js.map} +1 -1
- package/dist/{chunk-t65074mw.js → chunk-kkte8nze.js} +3 -3
- package/dist/{chunk-t65074mw.js.map → chunk-kkte8nze.js.map} +1 -1
- package/dist/{chunk-x7qwx07b.js → chunk-m4kmetpb.js} +2 -2
- package/dist/{chunk-x7qwx07b.js.map → chunk-m4kmetpb.js.map} +1 -1
- package/dist/{chunk-ge9xjwgq.js → chunk-n4sdm0jn.js} +3 -3
- package/dist/{chunk-ge9xjwgq.js.map → chunk-n4sdm0jn.js.map} +1 -1
- package/dist/chunk-nang3847.js +416 -0
- package/dist/chunk-nang3847.js.map +24 -0
- package/dist/{chunk-vj5necm0.js → chunk-nrezmscd.js} +1 -1
- package/dist/{chunk-v8vnxkvp.js → chunk-p83erprx.js} +2 -2
- package/dist/{chunk-v8vnxkvp.js.map → chunk-p83erprx.js.map} +1 -1
- package/dist/{chunk-sj4f7x4p.js → chunk-pkr5dsbk.js} +2 -2
- package/dist/{chunk-sj4f7x4p.js.map → chunk-pkr5dsbk.js.map} +1 -1
- package/dist/{chunk-f8vcwzgd.js → chunk-pqc16rrx.js} +2 -2
- package/dist/{chunk-f8vcwzgd.js.map → chunk-pqc16rrx.js.map} +1 -1
- package/dist/{chunk-hvgmqt6z.js → chunk-pvz90a49.js} +2 -2
- package/dist/{chunk-hvgmqt6z.js.map → chunk-pvz90a49.js.map} +1 -1
- package/dist/{chunk-s4f56035.js → chunk-q290tgza.js} +2 -2
- package/dist/{chunk-s4f56035.js.map → chunk-q290tgza.js.map} +1 -1
- package/dist/{chunk-wgb79ysr.js → chunk-qf4bmee9.js} +2 -2
- package/dist/{chunk-wgb79ysr.js.map → chunk-qf4bmee9.js.map} +1 -1
- package/dist/{chunk-a7r39713.js → chunk-qkxnvpaj.js} +2 -2
- package/dist/{chunk-a7r39713.js.map → chunk-qkxnvpaj.js.map} +1 -1
- package/dist/chunk-r1favzz4.js +19 -0
- package/dist/{chunk-rhmpphhc.js.map → chunk-r1favzz4.js.map} +5 -4
- package/dist/{chunk-veq07rp8.js → chunk-razjfecn.js} +1 -1
- package/dist/{chunk-a77586gv.js → chunk-scc0j5k9.js} +2 -2
- package/dist/{chunk-a77586gv.js.map → chunk-scc0j5k9.js.map} +1 -1
- package/dist/{chunk-cytss9mb.js → chunk-sce5jes2.js} +2 -2
- package/dist/{chunk-cytss9mb.js.map → chunk-sce5jes2.js.map} +1 -1
- package/dist/{chunk-t87w4h84.js → chunk-sd02ktf2.js} +2 -2
- package/dist/{chunk-t87w4h84.js.map → chunk-sd02ktf2.js.map} +1 -1
- package/dist/{chunk-1zzd39qg.js → chunk-sn04cyw0.js} +2 -2
- package/dist/{chunk-1zzd39qg.js.map → chunk-sn04cyw0.js.map} +1 -1
- package/dist/{chunk-wwdbgshx.js → chunk-tfdmvxza.js} +2 -2
- package/dist/{chunk-wwdbgshx.js.map → chunk-tfdmvxza.js.map} +1 -1
- package/dist/{chunk-jqrs16g2.js → chunk-tzdenj0n.js} +3 -3
- package/dist/{chunk-jqrs16g2.js.map → chunk-tzdenj0n.js.map} +1 -1
- package/dist/{chunk-qhw0hej0.js → chunk-x6v2zex2.js} +2 -2
- package/dist/{chunk-qhw0hej0.js.map → chunk-x6v2zex2.js.map} +1 -1
- package/dist/{chunk-yfwrbfnw.js → chunk-xfw8zyvn.js} +2 -2
- package/dist/{chunk-yfwrbfnw.js.map → chunk-xfw8zyvn.js.map} +1 -1
- package/dist/{chunk-sksmnjkn.js → chunk-xtzn0qfh.js} +2 -2
- package/dist/{chunk-sksmnjkn.js.map → chunk-xtzn0qfh.js.map} +1 -1
- package/dist/{chunk-jpetnpzn.js → chunk-xx3zvc3g.js} +2 -2
- package/dist/{chunk-jpetnpzn.js.map → chunk-xx3zvc3g.js.map} +1 -1
- package/dist/{chunk-fk6nxhxn.js → chunk-xzn2nmny.js} +2 -2
- package/dist/{chunk-fk6nxhxn.js.map → chunk-xzn2nmny.js.map} +1 -1
- package/dist/{chunk-vtc23xpk.js → chunk-xzyy896s.js} +2 -2
- package/dist/{chunk-vtc23xpk.js.map → chunk-xzyy896s.js.map} +1 -1
- package/dist/{chunk-fa37qzm3.js → chunk-y09r0wsw.js} +3 -3
- package/dist/{chunk-fa37qzm3.js.map → chunk-y09r0wsw.js.map} +1 -1
- package/dist/{chunk-5p4z1fgc.js → chunk-ygf0z7kk.js} +2 -2
- package/dist/{chunk-5p4z1fgc.js.map → chunk-ygf0z7kk.js.map} +1 -1
- package/dist/{chunk-zw6843j3.js → chunk-z759yah5.js} +2 -2
- package/dist/{chunk-zw6843j3.js.map → chunk-z759yah5.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/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/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/services/discovery.d.ts +8 -0
- package/dist/services/discovery.d.ts.map +1 -1
- package/dist/services/index.d.ts +8 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +3 -3
- package/dist/services/index.js.map +2 -2
- package/dist/services/queue/DatabaseQueueDriver.d.ts +23 -2
- package/dist/services/queue/DatabaseQueueDriver.d.ts.map +1 -1
- package/dist/services/queue/Job.d.ts +3 -0
- package/dist/services/queue/Job.d.ts.map +1 -1
- package/dist/services/queue/MemoryQueueDriver.d.ts +10 -0
- package/dist/services/queue/MemoryQueueDriver.d.ts.map +1 -1
- package/dist/services/queue/QueueDriver.d.ts +9 -0
- package/dist/services/queue/QueueDriver.d.ts.map +1 -1
- package/dist/services/queue/QueueManager.d.ts +33 -7
- package/dist/services/queue/QueueManager.d.ts.map +1 -1
- package/dist/services/queue/QueueServiceProvider.d.ts.map +1 -1
- package/dist/services/queue/backoff.d.ts +6 -0
- package/dist/services/queue/backoff.d.ts.map +1 -0
- package/dist/services/queue/config.d.ts +9 -0
- package/dist/services/queue/config.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/queue/workflow/DatabaseWorkflowStore.d.ts +89 -0
- package/dist/services/queue/workflow/DatabaseWorkflowStore.d.ts.map +1 -0
- package/dist/services/queue/workflow/MemoryWorkflowStore.d.ts +43 -0
- package/dist/services/queue/workflow/MemoryWorkflowStore.d.ts.map +1 -0
- package/dist/services/queue/workflow/Step.d.ts +202 -0
- package/dist/services/queue/workflow/Step.d.ts.map +1 -0
- package/dist/services/queue/workflow/Workflow.d.ts +124 -0
- package/dist/services/queue/workflow/Workflow.d.ts.map +1 -0
- package/dist/services/queue/workflow/WorkflowRuntime.d.ts +60 -0
- package/dist/services/queue/workflow/WorkflowRuntime.d.ts.map +1 -0
- package/dist/services/queue/workflow/WorkflowStore.d.ts +184 -0
- package/dist/services/queue/workflow/WorkflowStore.d.ts.map +1 -0
- package/dist/services/queue/workflow/duration.d.ts +8 -0
- package/dist/services/queue/workflow/duration.d.ts.map +1 -0
- package/dist/services/queue/workflow/workflowContract.d.ts +30 -0
- package/dist/services/queue/workflow/workflowContract.d.ts.map +1 -0
- 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-2czfefn2.js +0 -10
- package/dist/chunk-63ewmmhc.js +0 -5
- package/dist/chunk-rhmpphhc.js +0 -19
- package/dist/chunk-y0en07zh.js +0 -302
- package/dist/chunk-y0en07zh.js.map +0 -17
- /package/dist/{chunk-077rea02.js.map → chunk-33s2xqv1.js.map} +0 -0
- /package/dist/{chunk-bvqae0px.js.map → chunk-8t6dwwz6.js.map} +0 -0
- /package/dist/{chunk-e7ezmag9.js.map → chunk-aedkrck1.js.map} +0 -0
- /package/dist/{chunk-vj5necm0.js.map → chunk-nrezmscd.js.map} +0 -0
- /package/dist/{chunk-veq07rp8.js.map → chunk-razjfecn.js.map} +0 -0
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"import type { Application } from \"../foundation/Application\";\n\n/**\n * What a provider's `shutdown()` may resolve: nothing, or whether it\n * abandoned work at the deadline. See `ServiceProvider` below.\n */\nexport type ProviderShutdownResult = void | { abandoned: boolean };\n\n/**\n * Every hook defaults to a no-op. `register()` binds services into the\n * container and must not resolve any of them; `boot()` runs after every\n * provider has registered, so it may resolve freely.\n *\n * `shutdown()` runs once when a production server is told to stop (`SIGTERM`\n * or `SIGINT`), after it has stopped accepting requests and the in-flight ones\n * have finished or run out of grace — so nothing a request needs is torn down\n * under it. Providers shut down in reverse registration order, so one\n * registered after another may still use it. Each is awaited, but under a\n * shared deadline (`GEMI_SHUTDOWN_PROVIDER_TIMEOUT`): one that overruns is\n * abandoned and the next begins, and one that throws is logged and does not\n * stop the rest. See `Application.shutdown`.\n *\n * Under `gemi dev` it also runs on every `bun --hot` reload, for the\n * application the reload replaced, once the new one is serving and the old\n * one's requests have finished (see `server/devReload.ts`). A hook that closes\n * something kept on `globalThis` across reloads would close it for the new\n * application too.\n *\n * `timeoutMs` is what is left of that shared deadline when this provider is\n * reached. A provider that waits for something — jobs finishing, a queue\n * draining — should bound its own wait by a little less than this, so that it\n * is still the one to report what it gave up on. Ignoring it is fine; the\n * provider is then simply abandoned at the deadline, with only a generic line\n * from `Application` to say so.\n *\n * A provider that bounds its own wait and gives up on work it was waiting for\n * resolves `{ abandoned: true }`. `Application` then reports it in `timedOut`\n * as if it had overrun, and the process exits `1` — the work was cut off just\n * the same, and an orchestrator or a log alert has to be able to see that from\n * the exit code. The provider names what it abandoned in its own log line.\n */\nexport abstract class ServiceProvider {\n constructor(protected app: Application) {}\n\n register(): void {}\n\n boot(): void | Promise<void> {}\n\n shutdown(options?: {\n timeoutMs: number;\n }): ProviderShutdownResult | Promise<ProviderShutdownResult> {}\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";AAyCO,MAAe,CAAgB,CACd,IAAtB,WAAW,CAAW,EAAkB,CAAlB,WAEtB,QAAQ,EAAS,EAEjB,IAAI,EAAyB,EAE7B,QAAQ,CAAC,EAEoD,EAC/D",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "DBAD9399BC25435864756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-dcgvq79a.js";import Eu from"os";import Au from"fs";var Wl=new Map,hh=new Map,nh=Symbol("OriginError"),Dl={};class fl extends Promise{constructor(l,n,u,c,w={}){let E,t;super((_,B)=>{E=_,t=B});this.tagged=Array.isArray(l.raw),this.strings=l,this.args=n,this.handler=u,this.canceller=c,this.options=w,this.state=null,this.statement=null,this.resolve=(_)=>(this.active=!1,E(_)),this.reject=(_)=>(this.active=!1,t(_)),this.active=!1,this.cancelled=null,this.executed=!1,this.signature="",this[nh]=this.handler.debug?Error():this.tagged&&vn(this.strings)}get origin(){return(this.handler.debug?this[nh].stack:this.tagged&&hh.has(this.strings)?hh.get(this.strings):hh.set(this.strings,this[nh].stack).get(this.strings))||""}static get[Symbol.species](){return Promise}cancel(){return this.canceller&&(this.canceller(this),this.canceller=null)}simple(){return this.options.simple=!0,this.options.prepare=!1,this}async readable(){return this.simple(),this.streaming=!0,this}async writable(){return this.simple(),this.streaming=!0,this}cursor(l=1,n){if(this.options.simple=!1,typeof l==="function")n=l,l=1;if(this.cursorRows=l,typeof n==="function")return this.cursorFn=n,this;let u;return{[Symbol.asyncIterator]:()=>({next:()=>{if(this.executed&&!this.active)return{done:!0};u&&u();let c=new Promise((w,E)=>{this.cursorFn=(t)=>{return w({value:t,done:!1}),new Promise((_)=>u=_)},this.resolve=()=>(this.active=!1,w({done:!0})),this.reject=(t)=>(this.active=!1,E(t))});return this.execute(),c},return(){return u&&u(Dl),{done:!0}}})}}describe(){return this.options.simple=!1,this.onlyDescribe=this.options.prepare=!0,this}stream(){throw Error(".stream has been renamed to .forEach")}forEach(l){return this.forEachFn=l,this.handle(),this}raw(){return this.isRaw=!0,this}values(){return this.isRaw="values",this}async handle(){!this.executed&&(this.executed=!0)&&await 1&&this.handler(this)}execute(){return this.handle(),this}then(){return this.handle(),super.then.apply(this,arguments)}catch(){return this.handle(),super.catch.apply(this,arguments)}finally(){return this.handle(),super.finally.apply(this,arguments)}}function vn(l){if(Wl.has(l))return Wl.get(l);let n=Error.stackTraceLimit;return Error.stackTraceLimit=4,Wl.set(l,Error()),Error.stackTraceLimit=n,Wl.get(l)}class Yl extends Error{constructor(l){super(l.message);this.name=this.constructor.name,Object.assign(this,l)}}var K={connection:Th,postgres:Xh,generic:Ch,notSupported:Zh};function Th(l,n,u){let{host:c,port:w}=u||n,E=Object.assign(Error("write "+l+" "+(n.path||c+":"+w)),{code:l,errno:l,address:n.path||c},n.path?{}:{port:w});return Error.captureStackTrace(E,Th),E}function Xh(l){let n=new Yl(l);return Error.captureStackTrace(n,Xh),n}function Ch(l,n){let u=Object.assign(Error(l+": "+n),{code:l});return Error.captureStackTrace(u,Ch),u}function Zh(l){let n=Object.assign(Error(l+" (B) is not supported"),{code:"MESSAGE_NOT_SUPPORTED",name:l});return Error.captureStackTrace(n,Zh),n}var mn={string:{to:25,from:null,serialize:(l)=>""+l},number:{to:0,from:[21,23,26,700,701],serialize:(l)=>""+l,parse:(l)=>+l},json:{to:114,from:[114,3802],serialize:(l)=>JSON.stringify(l),parse:(l)=>JSON.parse(l)},boolean:{to:16,from:16,serialize:(l)=>l===!0?"t":"f",parse:(l)=>l==="t"},date:{to:1184,from:[1082,1114,1184],serialize:(l)=>(l instanceof Date?l:new Date(l)).toISOString(),parse:(l)=>new Date(l)},bytea:{to:17,from:17,serialize:(l)=>"\\x"+Buffer.from(l).toString("hex"),parse:(l)=>Buffer.from(l.slice(2),"hex")}};class ml{then(){uh()}catch(){uh()}finally(){uh()}}class il extends ml{constructor(l){super();this.value=el(l)}}class wl extends ml{constructor(l,n,u){super();this.value=l,this.type=n,this.array=u}}class bl extends ml{constructor(l,n){super();this.first=l,this.rest=n}build(l,n,u,c){let w=bn.map(([E,t])=>({fn:t,i:l.search(E)})).sort((E,t)=>E.i-t.i).pop();return w.i===-1?_h(this.first,c):w.fn(this.first,this.rest,n,u,c)}}function al(l,n,u,c){let w=l instanceof wl?l.value:l;if(w===void 0){if(l instanceof wl?l.value=c.transform.undefined:w=l=c.transform.undefined,w===void 0)throw K.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return"$"+u.push(l instanceof wl?(n.push(l.value),l.array?l.array[l.type||vl(l.value)]||l.type||ih(l.value):l.type):(n.push(l),vl(l)))}var Hh=Qh(mn);function th(l,n,u,c,w,E){for(let t=1;t<l.strings.length;t++)n+=wh(n,u,c,w,E)+l.strings[t],u=l.args[t];return n}function wh(l,n,u,c,w){return n instanceof bl?n.build(l,u,c,w):n instanceof fl?ch(n,u,c,w):n instanceof il?n.value:n&&n[0]instanceof fl?n.reduce((E,t)=>E+" "+ch(t,u,c,w),""):al(n,u,c,w)}function ch(l,n,u,c){return l.fragment=!0,th(l,l.strings[0],l.args[0],n,u,c)}function zh(l,n,u,c,w){return l.map((E)=>"("+c.map((t)=>wh("values",E[t],n,u,w)).join(",")+")").join(",")}function Fh(l,n,u,c,w){let E=Array.isArray(l[0]),t=n.length?n.flat():Object.keys(E?l[0]:l);return zh(E?l:[l],u,c,t,w)}function Kl(l,n,u,c,w){if(typeof l==="string"&&(l=[l].concat(n)),Array.isArray(l))return _h(l,w);let E;return(n.length?n.flat():Object.keys(l)).map((_)=>{return E=l[_],(E instanceof fl?ch(E,u,c,w):E instanceof il?E.value:al(E,u,c,w))+" as "+el(w.transform.column.to?w.transform.column.to(_):_)}).join(",")}var bn=Object.entries({values:Fh,in:(...l)=>{let n=Fh(...l);return n==="()"?"(null)":n},select:Kl,as:Kl,returning:Kl,"\\(":Kl,update(l,n,u,c,w){return(n.length?n.flat():Object.keys(l)).map((E)=>el(w.transform.column.to?w.transform.column.to(E):E)+"="+wh("values",l[E],u,c,w))},insert(l,n,u,c,w){let E=n.length?n.flat():Object.keys(Array.isArray(l)?l[0]:l);return"("+_h(E,w)+")values"+zh(Array.isArray(l)?l:[l],u,c,E,w)}}).map(([l,n])=>[new RegExp("((?:^|[\\s(])"+l+"(?:$|[\\s(]))(?![\\s\\S]*\\1)","i"),n]);function uh(){throw K.generic("NOT_TAGGED_CALL","Query not called as a tagged template literal")}var{serializers:an,parsers:en}=Hh;function ih(l){if(Array.isArray(l))return ih(l[0]);return typeof l==="string"?1009:0}var Jh=function(l){let n=Qh(l||{});return{serializers:Object.assign({},an,n.serializers),parsers:Object.assign({},en,n.parsers)}};function Qh(l){return Object.keys(l).reduce((n,u)=>{if(l[u].from&&[].concat(l[u].from).forEach((c)=>n.parsers[c]=l[u].parse),l[u].serialize)n.serializers[l[u].to]=l[u].serialize,l[u].from&&[].concat(l[u].from).forEach((c)=>n.serializers[c]=l[u].serialize);return n},{parsers:{},serializers:{}})}function _h(l,{transform:{column:n}}){return l.map((u)=>el(n.to?n.to(u):u)).join(",")}var el=function(n){return'"'+n.replace(/"/g,'""').replace(/\./g,'"."')+'"'},vl=function l(n){return n instanceof wl?n.type:n instanceof Date?1184:n instanceof Uint8Array?17:n===!0||n===!1?16:typeof n==="bigint"?20:Array.isArray(n)?l(n[0]):0},kn=/\\/g,on=/"/g;function pn(l){return l.replace(kn,"\\\\").replace(on,"\\\"")}var Vh=function l(n,u,c,w){if(Array.isArray(n)===!1)return n;if(!n.length)return"{}";let E=n[0],t=w===1020?";":",";if(Array.isArray(E)&&!E.type)return"{"+n.map((_)=>l(_,u,c,w)).join(t)+"}";return"{"+n.map((_)=>{if(_===void 0){if(_=c.transform.undefined,_===void 0)throw K.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return _===null?"null":'"'+pn(u?u(_.type?_.value:_):""+_)+'"'}).join(t)+"}"},fh={i:0,char:null,str:"",quoted:!1,last:0},Wh=function(n,u,c){return fh.i=fh.last=0,Kh(fh,n,u,c)};function Kh(l,n,u,c){let w=[],E=c===1020?";":",";for(;l.i<n.length;l.i++){if(l.char=n[l.i],l.quoted)if(l.char==="\\")l.str+=n[++l.i];else if(l.char==='"')w.push(u?u(l.str):l.str),l.str="",l.quoted=n[l.i+1]==='"',l.last=l.i+2;else l.str+=l.char;else if(l.char==='"')l.quoted=!0;else if(l.char==="{")l.last=++l.i,w.push(Kh(l,n,u,c));else if(l.char==="}"){l.quoted=!1,l.last<l.i&&w.push(u?u(n.slice(l.last,l.i)):n.slice(l.last,l.i)),l.last=l.i+1;break}else if(l.char===E&&l.p!=="}"&&l.p!=='"')w.push(u?u(n.slice(l.last,l.i)):n.slice(l.last,l.i)),l.last=l.i+1;l.p=l.char}return l.last<l.i&&w.push(u?u(n.slice(l.last,l.i+1)):n.slice(l.last,l.i+1)),w}var Sl=(l)=>{let n=l[0];for(let u=1;u<l.length;u++)n+=l[u]==="_"?l[++u].toUpperCase():l[u];return n},Gl=(l)=>{let n=l[0].toUpperCase();for(let u=1;u<l.length;u++)n+=l[u]==="_"?l[++u].toUpperCase():l[u];return n},jl=(l)=>l.replace(/_/g,"-"),Fl=(l)=>l.replace(/([A-Z])/g,"_$1").toLowerCase(),Hl=(l)=>(l.slice(0,1)+l.slice(1).replace(/([A-Z])/g,"_$1")).toLowerCase(),zl=(l)=>l.replace(/-/g,"_");function Oh(l){return function n(u,c){return typeof u==="object"&&u!==null&&(c.type===114||c.type===3802)?Array.isArray(u)?u.map((w)=>n(w,c)):Object.entries(u).reduce((w,[E,t])=>Object.assign(w,{[l(E)]:n(t,c)}),{}):u}}Sl.column={from:Sl};Sl.value={from:Oh(Sl)};Fl.column={to:Fl};var Eh={...Sl};Eh.column.to=Fl;Gl.column={from:Gl};Gl.value={from:Oh(Gl)};Hl.column={to:Hl};var Ah={...Gl};Ah.column.to=Hl;jl.column={from:jl};jl.value={from:Oh(jl)};zl.column={to:zl};var Uh={...jl};Uh.column.to=zl;import vh from"net";import qn from"tls";import Jl from"crypto";import $h from"stream";import{performance as mh}from"perf_hooks";class Ml extends Array{constructor(){super();Object.defineProperties(this,{count:{value:null,writable:!0},state:{value:null,writable:!0},command:{value:null,writable:!0},columns:{value:null,writable:!0},statement:{value:null,writable:!0}})}static get[Symbol.species](){return Array}}var hl=yn;function yn(l=[]){let n=l.slice(),u=0;return{get length(){return n.length-u},remove:(c)=>{let w=n.indexOf(c);return w===-1?null:(n.splice(w,1),c)},push:(c)=>(n.push(c),c),shift:()=>{let c=n[u++];if(u===n.length)u=0,n=[];else n[u-1]=void 0;return c}}}var p=Buffer.allocUnsafe(256),rn="BCcDdEFfHPpQSX".split("").reduce((l,n)=>{let u=n.charCodeAt(0);return l[n]=()=>{return p[0]=u,R.i=5,R},l},{}),R=Object.assign(sn,rn,{N:String.fromCharCode(0),i:0,inc(l){return R.i+=l,R},str(l){let n=Buffer.byteLength(l);return kl(n),R.i+=p.write(l,R.i,n,"utf8"),R},i16(l){return kl(2),p.writeUInt16BE(l,R.i),R.i+=2,R},i32(l,n){if(n||n===0)return p.writeUInt32BE(l,n),R;return kl(4),p.writeUInt32BE(l,R.i),R.i+=4,R},z(l){return kl(l),p.fill(0,R.i,R.i+l),R.i+=l,R},raw(l){return p=Buffer.concat([p.subarray(0,R.i),l]),R.i=p.length,R},end(l=1){p.writeUInt32BE(R.i-l,l);let n=p.subarray(0,R.i);return R.i=0,p=Buffer.allocUnsafe(256),n}}),$=R;function kl(l){if(p.length-R.i<l){let n=p,u=n.length;p=Buffer.allocUnsafe(u+(u>>1)+l),n.copy(p)}}function sn(){return R.i=0,R}var Bh=eh,xn=1,Bl=$().S().end(),bh=$().H().end(),lu=$().i32(8).i32(80877103).end(8),hu=Buffer.concat([$().E().str($.N).i32(0).end(),Bl]),nu=$().D().str("S").str($.N).end(),Rl=()=>{},uu=new Set(["FetchPreparedStatement","RevalidateCachedQuery","transformAssignedExpr"]),fu={83:"severity_local",86:"severity",67:"code",77:"message",68:"detail",72:"hint",80:"position",112:"internal_position",113:"internal_query",87:"where",115:"schema_name",116:"table_name",99:"column_name",100:"data type_name",110:"constraint_name",70:"file",76:"line",82:"routine"};function eh(l,n={},{onopen:u=Rl,onend:c=Rl,onclose:w=Rl}={}){let{sslnegotiation:E,ssl:t,max:_,user:B,host:Q,port:T,database:Y,parsers:j,transform:M,onnotice:H,onnotify:I,onparameter:b,max_pipeline:Z,keep_alive:cl,backoff:nl,target_session_attrs:x}=l,d=hl(),Ul=xn++,_l={pid:null,secret:null},Pl=gh(xl,l.idle_timeout),Il=gh(xl,l.max_lifetime),L=gh(xh,l.connect_timeout),U=null,Ol,q=null,N=new Ml,y=Buffer.alloc(0),dl=l.fetch_types,El={},O={},S=Math.random().toString(36).slice(2),F=1,v=0,V=0,G=0,D=0,i=0,J=0,m=0,r=null,X=null,Al=!1,tl=null,$l=null,e=null,z=null,C=null,ll=null,Ql=null,sl=null,A=null,Tl=null,k={queue:n.closed,idleTimer:Pl,connect(h){e=h,Lh()},terminate:Zl,execute:Xl,cancel:yh,end:xl,count:0,id:Ul};return n.closed&&n.closed.push(k),k;async function ph(){let h;try{h=l.socket?await Promise.resolve(l.socket(l)):new vh.Socket}catch(f){Nl(f);return}return h.on("error",Nl),h.on("close",Nh),h.on("drain",Ph),h}async function yh({pid:h,secret:f},g,P){try{Ol=$().i32(16).i32(80877102).i32(h).i32(f).end(16),await dh(),U.once("error",P),U.once("close",g)}catch(W){P(W)}}function Xl(h){if(Al)return Cl(h,K.connection("CONNECTION_DESTROYED",l));if(C)return Cl(h,K.generic("COPY_IN_PROGRESS","You cannot execute queries during copy"));if(h.cancelled)return;try{return h.state=_l,A?d.push(h):(A=h,A.active=!0),qh(h),a(rh(h))&&!h.describeFirst&&!h.cursorFn&&d.length<Z&&(!h.options.onexecute||h.options.onexecute(k))}catch(f){return d.length===0&&a(Bl),ul(f),!0}}function rh(h){if(h.parameters.length>=65534)throw K.generic("MAX_PARAMETERS_EXCEEDED","Max number of parameters (65534) exceeded");return h.options.simple?$().Q().str(h.statement.string+$.N).end():h.describeFirst?Buffer.concat([Gh(h),bh]):h.prepare?h.prepared?Vl(h):Buffer.concat([Gh(h),Vl(h)]):sh(h)}function Gh(h){return Buffer.concat([Yh(h.statement.string,h.parameters,h.statement.types,h.statement.name),Vn("S",h.statement.name)])}function Vl(h){return Buffer.concat([Qn(h.parameters,h.statement.types,h.statement.name,h.cursorName),h.cursorFn?Rh("",h.cursorRows):hu])}function sh(h){return Buffer.concat([Yh(h.statement.string,h.parameters,h.statement.types),nu,Vl(h)])}function qh(h){let f=[],g=[],P=th(h,h.strings[0],h.args[0],f,g,l);!h.tagged&&h.args.forEach((W)=>al(W,f,g,l)),h.prepare=l.prepare&&("prepare"in h.options?h.options.prepare:!0),h.string=P,h.signature=h.prepare&&g+P,h.onlyDescribe&&delete O[h.signature],h.parameters=h.parameters||f,h.prepared=h.prepare&&h.signature in O,h.describeFirst=h.onlyDescribe||f.length&&!h.prepared,h.statement=h.prepared?O[h.signature]:{string:P,types:g,name:h.prepare?S+F++:""},typeof l.debug==="function"&&l.debug(Ul,P,f,g)}function a(h,f){if(ll=ll?Buffer.concat([ll,h]):Buffer.from(h),f||ll.length>=1024)return jh(f);return X===null&&(X=setImmediate(jh)),!0}function jh(h){let f=U.write(ll,h);return X!==null&&clearImmediate(X),ll=X=null,f}function xh(){ul(K.connection("CONNECT_TIMEOUT",l,U)),U.destroy()}async function Mh(){if(E!=="direct"){if(a(lu),!await new Promise((g)=>U.once("data",(P)=>g(P[0]===83)))&&t==="prefer")return Ll()}let h={socket:U,servername:vh.isIP(U.host)?void 0:U.host};if(E==="direct")h.ALPNProtocols=["postgresql"];if(t==="require"||t==="allow"||t==="prefer")h.rejectUnauthorized=!1;else if(typeof t==="object")Object.assign(h,t);U.removeAllListeners(),U=qn.connect(h),U.on("secureConnect",Ll),U.on("error",Nl),U.on("close",Nh),U.on("drain",Ph)}function Ph(){!A&&u(k)}function ql(h){if(tl){if(tl.push(h),V-=h.length,V>0)return}y=tl?Buffer.concat(tl,i-V):y.length===0?h:Buffer.concat([y,h],y.length+h.length);while(y.length>4){if(i=y.readUInt32BE(1),i>=y.length){V=i-y.length,tl=[y];break}try{ln(y.subarray(0,i+1))}catch(f){A&&(A.cursorFn||A.describeFirst)&&a(Bl),ul(f)}y=y.subarray(i+1),V=0,tl=null}}async function dh(){if(Al=!1,El={},U||(U=await ph()),!U)return;if(L.start(),l.socket)return t?Mh():Ll();if(U.on("connect",t?Mh:Ll),l.path)return U.connect(l.path);U.ssl=t,U.connect(T[G],Q[G]),U.host=Q[G],U.port=T[G],G=(G+1)%T.length}function Lh(){setTimeout(dh,v?Math.max(0,v+J-mh.now()):0)}function Ll(){try{O={},dl=l.fetch_types,S=Math.random().toString(36).slice(2),F=1,Il.start(),U.on("data",ql),cl&&U.setKeepAlive&&U.setKeepAlive(!0,1000*cl);let h=Kn();a(h)}catch(h){Nl(h)}}function Nl(h){if(k.queue===n.connecting&&l.host[D+1])return;ul(h);while(d.length)Cl(d.shift(),h)}function ul(h){C&&(C.destroy(h),C=null),A&&Cl(A,h),e&&(Cl(e,h),e=null)}function Cl(h,f){if(h.reserve)return h.reject(f);if(!f||typeof f!=="object")f=Error(f);"query"in f||"parameters"in f||Object.defineProperties(f,{stack:{value:f.stack+h.origin.replace(/.*\n/,`
|
|
2
|
+
import"./chunk-hm9cjxy2.js";import Eu from"os";import Au from"fs";var Wl=new Map,hh=new Map,nh=Symbol("OriginError"),Dl={};class fl extends Promise{constructor(l,n,u,c,w={}){let E,t;super((_,B)=>{E=_,t=B});this.tagged=Array.isArray(l.raw),this.strings=l,this.args=n,this.handler=u,this.canceller=c,this.options=w,this.state=null,this.statement=null,this.resolve=(_)=>(this.active=!1,E(_)),this.reject=(_)=>(this.active=!1,t(_)),this.active=!1,this.cancelled=null,this.executed=!1,this.signature="",this[nh]=this.handler.debug?Error():this.tagged&&vn(this.strings)}get origin(){return(this.handler.debug?this[nh].stack:this.tagged&&hh.has(this.strings)?hh.get(this.strings):hh.set(this.strings,this[nh].stack).get(this.strings))||""}static get[Symbol.species](){return Promise}cancel(){return this.canceller&&(this.canceller(this),this.canceller=null)}simple(){return this.options.simple=!0,this.options.prepare=!1,this}async readable(){return this.simple(),this.streaming=!0,this}async writable(){return this.simple(),this.streaming=!0,this}cursor(l=1,n){if(this.options.simple=!1,typeof l==="function")n=l,l=1;if(this.cursorRows=l,typeof n==="function")return this.cursorFn=n,this;let u;return{[Symbol.asyncIterator]:()=>({next:()=>{if(this.executed&&!this.active)return{done:!0};u&&u();let c=new Promise((w,E)=>{this.cursorFn=(t)=>{return w({value:t,done:!1}),new Promise((_)=>u=_)},this.resolve=()=>(this.active=!1,w({done:!0})),this.reject=(t)=>(this.active=!1,E(t))});return this.execute(),c},return(){return u&&u(Dl),{done:!0}}})}}describe(){return this.options.simple=!1,this.onlyDescribe=this.options.prepare=!0,this}stream(){throw Error(".stream has been renamed to .forEach")}forEach(l){return this.forEachFn=l,this.handle(),this}raw(){return this.isRaw=!0,this}values(){return this.isRaw="values",this}async handle(){!this.executed&&(this.executed=!0)&&await 1&&this.handler(this)}execute(){return this.handle(),this}then(){return this.handle(),super.then.apply(this,arguments)}catch(){return this.handle(),super.catch.apply(this,arguments)}finally(){return this.handle(),super.finally.apply(this,arguments)}}function vn(l){if(Wl.has(l))return Wl.get(l);let n=Error.stackTraceLimit;return Error.stackTraceLimit=4,Wl.set(l,Error()),Error.stackTraceLimit=n,Wl.get(l)}class Yl extends Error{constructor(l){super(l.message);this.name=this.constructor.name,Object.assign(this,l)}}var K={connection:Th,postgres:Xh,generic:Ch,notSupported:Zh};function Th(l,n,u){let{host:c,port:w}=u||n,E=Object.assign(Error("write "+l+" "+(n.path||c+":"+w)),{code:l,errno:l,address:n.path||c},n.path?{}:{port:w});return Error.captureStackTrace(E,Th),E}function Xh(l){let n=new Yl(l);return Error.captureStackTrace(n,Xh),n}function Ch(l,n){let u=Object.assign(Error(l+": "+n),{code:l});return Error.captureStackTrace(u,Ch),u}function Zh(l){let n=Object.assign(Error(l+" (B) is not supported"),{code:"MESSAGE_NOT_SUPPORTED",name:l});return Error.captureStackTrace(n,Zh),n}var mn={string:{to:25,from:null,serialize:(l)=>""+l},number:{to:0,from:[21,23,26,700,701],serialize:(l)=>""+l,parse:(l)=>+l},json:{to:114,from:[114,3802],serialize:(l)=>JSON.stringify(l),parse:(l)=>JSON.parse(l)},boolean:{to:16,from:16,serialize:(l)=>l===!0?"t":"f",parse:(l)=>l==="t"},date:{to:1184,from:[1082,1114,1184],serialize:(l)=>(l instanceof Date?l:new Date(l)).toISOString(),parse:(l)=>new Date(l)},bytea:{to:17,from:17,serialize:(l)=>"\\x"+Buffer.from(l).toString("hex"),parse:(l)=>Buffer.from(l.slice(2),"hex")}};class ml{then(){uh()}catch(){uh()}finally(){uh()}}class il extends ml{constructor(l){super();this.value=el(l)}}class wl extends ml{constructor(l,n,u){super();this.value=l,this.type=n,this.array=u}}class bl extends ml{constructor(l,n){super();this.first=l,this.rest=n}build(l,n,u,c){let w=bn.map(([E,t])=>({fn:t,i:l.search(E)})).sort((E,t)=>E.i-t.i).pop();return w.i===-1?_h(this.first,c):w.fn(this.first,this.rest,n,u,c)}}function al(l,n,u,c){let w=l instanceof wl?l.value:l;if(w===void 0){if(l instanceof wl?l.value=c.transform.undefined:w=l=c.transform.undefined,w===void 0)throw K.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return"$"+u.push(l instanceof wl?(n.push(l.value),l.array?l.array[l.type||vl(l.value)]||l.type||ih(l.value):l.type):(n.push(l),vl(l)))}var Hh=Qh(mn);function th(l,n,u,c,w,E){for(let t=1;t<l.strings.length;t++)n+=wh(n,u,c,w,E)+l.strings[t],u=l.args[t];return n}function wh(l,n,u,c,w){return n instanceof bl?n.build(l,u,c,w):n instanceof fl?ch(n,u,c,w):n instanceof il?n.value:n&&n[0]instanceof fl?n.reduce((E,t)=>E+" "+ch(t,u,c,w),""):al(n,u,c,w)}function ch(l,n,u,c){return l.fragment=!0,th(l,l.strings[0],l.args[0],n,u,c)}function zh(l,n,u,c,w){return l.map((E)=>"("+c.map((t)=>wh("values",E[t],n,u,w)).join(",")+")").join(",")}function Fh(l,n,u,c,w){let E=Array.isArray(l[0]),t=n.length?n.flat():Object.keys(E?l[0]:l);return zh(E?l:[l],u,c,t,w)}function Kl(l,n,u,c,w){if(typeof l==="string"&&(l=[l].concat(n)),Array.isArray(l))return _h(l,w);let E;return(n.length?n.flat():Object.keys(l)).map((_)=>{return E=l[_],(E instanceof fl?ch(E,u,c,w):E instanceof il?E.value:al(E,u,c,w))+" as "+el(w.transform.column.to?w.transform.column.to(_):_)}).join(",")}var bn=Object.entries({values:Fh,in:(...l)=>{let n=Fh(...l);return n==="()"?"(null)":n},select:Kl,as:Kl,returning:Kl,"\\(":Kl,update(l,n,u,c,w){return(n.length?n.flat():Object.keys(l)).map((E)=>el(w.transform.column.to?w.transform.column.to(E):E)+"="+wh("values",l[E],u,c,w))},insert(l,n,u,c,w){let E=n.length?n.flat():Object.keys(Array.isArray(l)?l[0]:l);return"("+_h(E,w)+")values"+zh(Array.isArray(l)?l:[l],u,c,E,w)}}).map(([l,n])=>[new RegExp("((?:^|[\\s(])"+l+"(?:$|[\\s(]))(?![\\s\\S]*\\1)","i"),n]);function uh(){throw K.generic("NOT_TAGGED_CALL","Query not called as a tagged template literal")}var{serializers:an,parsers:en}=Hh;function ih(l){if(Array.isArray(l))return ih(l[0]);return typeof l==="string"?1009:0}var Jh=function(l){let n=Qh(l||{});return{serializers:Object.assign({},an,n.serializers),parsers:Object.assign({},en,n.parsers)}};function Qh(l){return Object.keys(l).reduce((n,u)=>{if(l[u].from&&[].concat(l[u].from).forEach((c)=>n.parsers[c]=l[u].parse),l[u].serialize)n.serializers[l[u].to]=l[u].serialize,l[u].from&&[].concat(l[u].from).forEach((c)=>n.serializers[c]=l[u].serialize);return n},{parsers:{},serializers:{}})}function _h(l,{transform:{column:n}}){return l.map((u)=>el(n.to?n.to(u):u)).join(",")}var el=function(n){return'"'+n.replace(/"/g,'""').replace(/\./g,'"."')+'"'},vl=function l(n){return n instanceof wl?n.type:n instanceof Date?1184:n instanceof Uint8Array?17:n===!0||n===!1?16:typeof n==="bigint"?20:Array.isArray(n)?l(n[0]):0},kn=/\\/g,on=/"/g;function pn(l){return l.replace(kn,"\\\\").replace(on,"\\\"")}var Vh=function l(n,u,c,w){if(Array.isArray(n)===!1)return n;if(!n.length)return"{}";let E=n[0],t=w===1020?";":",";if(Array.isArray(E)&&!E.type)return"{"+n.map((_)=>l(_,u,c,w)).join(t)+"}";return"{"+n.map((_)=>{if(_===void 0){if(_=c.transform.undefined,_===void 0)throw K.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return _===null?"null":'"'+pn(u?u(_.type?_.value:_):""+_)+'"'}).join(t)+"}"},fh={i:0,char:null,str:"",quoted:!1,last:0},Wh=function(n,u,c){return fh.i=fh.last=0,Kh(fh,n,u,c)};function Kh(l,n,u,c){let w=[],E=c===1020?";":",";for(;l.i<n.length;l.i++){if(l.char=n[l.i],l.quoted)if(l.char==="\\")l.str+=n[++l.i];else if(l.char==='"')w.push(u?u(l.str):l.str),l.str="",l.quoted=n[l.i+1]==='"',l.last=l.i+2;else l.str+=l.char;else if(l.char==='"')l.quoted=!0;else if(l.char==="{")l.last=++l.i,w.push(Kh(l,n,u,c));else if(l.char==="}"){l.quoted=!1,l.last<l.i&&w.push(u?u(n.slice(l.last,l.i)):n.slice(l.last,l.i)),l.last=l.i+1;break}else if(l.char===E&&l.p!=="}"&&l.p!=='"')w.push(u?u(n.slice(l.last,l.i)):n.slice(l.last,l.i)),l.last=l.i+1;l.p=l.char}return l.last<l.i&&w.push(u?u(n.slice(l.last,l.i+1)):n.slice(l.last,l.i+1)),w}var Sl=(l)=>{let n=l[0];for(let u=1;u<l.length;u++)n+=l[u]==="_"?l[++u].toUpperCase():l[u];return n},Gl=(l)=>{let n=l[0].toUpperCase();for(let u=1;u<l.length;u++)n+=l[u]==="_"?l[++u].toUpperCase():l[u];return n},jl=(l)=>l.replace(/_/g,"-"),Fl=(l)=>l.replace(/([A-Z])/g,"_$1").toLowerCase(),Hl=(l)=>(l.slice(0,1)+l.slice(1).replace(/([A-Z])/g,"_$1")).toLowerCase(),zl=(l)=>l.replace(/-/g,"_");function Oh(l){return function n(u,c){return typeof u==="object"&&u!==null&&(c.type===114||c.type===3802)?Array.isArray(u)?u.map((w)=>n(w,c)):Object.entries(u).reduce((w,[E,t])=>Object.assign(w,{[l(E)]:n(t,c)}),{}):u}}Sl.column={from:Sl};Sl.value={from:Oh(Sl)};Fl.column={to:Fl};var Eh={...Sl};Eh.column.to=Fl;Gl.column={from:Gl};Gl.value={from:Oh(Gl)};Hl.column={to:Hl};var Ah={...Gl};Ah.column.to=Hl;jl.column={from:jl};jl.value={from:Oh(jl)};zl.column={to:zl};var Uh={...jl};Uh.column.to=zl;import vh from"net";import qn from"tls";import Jl from"crypto";import $h from"stream";import{performance as mh}from"perf_hooks";class Ml extends Array{constructor(){super();Object.defineProperties(this,{count:{value:null,writable:!0},state:{value:null,writable:!0},command:{value:null,writable:!0},columns:{value:null,writable:!0},statement:{value:null,writable:!0}})}static get[Symbol.species](){return Array}}var hl=yn;function yn(l=[]){let n=l.slice(),u=0;return{get length(){return n.length-u},remove:(c)=>{let w=n.indexOf(c);return w===-1?null:(n.splice(w,1),c)},push:(c)=>(n.push(c),c),shift:()=>{let c=n[u++];if(u===n.length)u=0,n=[];else n[u-1]=void 0;return c}}}var p=Buffer.allocUnsafe(256),rn="BCcDdEFfHPpQSX".split("").reduce((l,n)=>{let u=n.charCodeAt(0);return l[n]=()=>{return p[0]=u,R.i=5,R},l},{}),R=Object.assign(sn,rn,{N:String.fromCharCode(0),i:0,inc(l){return R.i+=l,R},str(l){let n=Buffer.byteLength(l);return kl(n),R.i+=p.write(l,R.i,n,"utf8"),R},i16(l){return kl(2),p.writeUInt16BE(l,R.i),R.i+=2,R},i32(l,n){if(n||n===0)return p.writeUInt32BE(l,n),R;return kl(4),p.writeUInt32BE(l,R.i),R.i+=4,R},z(l){return kl(l),p.fill(0,R.i,R.i+l),R.i+=l,R},raw(l){return p=Buffer.concat([p.subarray(0,R.i),l]),R.i=p.length,R},end(l=1){p.writeUInt32BE(R.i-l,l);let n=p.subarray(0,R.i);return R.i=0,p=Buffer.allocUnsafe(256),n}}),$=R;function kl(l){if(p.length-R.i<l){let n=p,u=n.length;p=Buffer.allocUnsafe(u+(u>>1)+l),n.copy(p)}}function sn(){return R.i=0,R}var Bh=eh,xn=1,Bl=$().S().end(),bh=$().H().end(),lu=$().i32(8).i32(80877103).end(8),hu=Buffer.concat([$().E().str($.N).i32(0).end(),Bl]),nu=$().D().str("S").str($.N).end(),Rl=()=>{},uu=new Set(["FetchPreparedStatement","RevalidateCachedQuery","transformAssignedExpr"]),fu={83:"severity_local",86:"severity",67:"code",77:"message",68:"detail",72:"hint",80:"position",112:"internal_position",113:"internal_query",87:"where",115:"schema_name",116:"table_name",99:"column_name",100:"data type_name",110:"constraint_name",70:"file",76:"line",82:"routine"};function eh(l,n={},{onopen:u=Rl,onend:c=Rl,onclose:w=Rl}={}){let{sslnegotiation:E,ssl:t,max:_,user:B,host:Q,port:T,database:Y,parsers:j,transform:M,onnotice:H,onnotify:I,onparameter:b,max_pipeline:Z,keep_alive:cl,backoff:nl,target_session_attrs:x}=l,d=hl(),Ul=xn++,_l={pid:null,secret:null},Pl=gh(xl,l.idle_timeout),Il=gh(xl,l.max_lifetime),L=gh(xh,l.connect_timeout),U=null,Ol,q=null,N=new Ml,y=Buffer.alloc(0),dl=l.fetch_types,El={},O={},S=Math.random().toString(36).slice(2),F=1,v=0,V=0,G=0,D=0,i=0,J=0,m=0,r=null,X=null,Al=!1,tl=null,$l=null,e=null,z=null,C=null,ll=null,Ql=null,sl=null,A=null,Tl=null,k={queue:n.closed,idleTimer:Pl,connect(h){e=h,Lh()},terminate:Zl,execute:Xl,cancel:yh,end:xl,count:0,id:Ul};return n.closed&&n.closed.push(k),k;async function ph(){let h;try{h=l.socket?await Promise.resolve(l.socket(l)):new vh.Socket}catch(f){Nl(f);return}return h.on("error",Nl),h.on("close",Nh),h.on("drain",Ph),h}async function yh({pid:h,secret:f},g,P){try{Ol=$().i32(16).i32(80877102).i32(h).i32(f).end(16),await dh(),U.once("error",P),U.once("close",g)}catch(W){P(W)}}function Xl(h){if(Al)return Cl(h,K.connection("CONNECTION_DESTROYED",l));if(C)return Cl(h,K.generic("COPY_IN_PROGRESS","You cannot execute queries during copy"));if(h.cancelled)return;try{return h.state=_l,A?d.push(h):(A=h,A.active=!0),qh(h),a(rh(h))&&!h.describeFirst&&!h.cursorFn&&d.length<Z&&(!h.options.onexecute||h.options.onexecute(k))}catch(f){return d.length===0&&a(Bl),ul(f),!0}}function rh(h){if(h.parameters.length>=65534)throw K.generic("MAX_PARAMETERS_EXCEEDED","Max number of parameters (65534) exceeded");return h.options.simple?$().Q().str(h.statement.string+$.N).end():h.describeFirst?Buffer.concat([Gh(h),bh]):h.prepare?h.prepared?Vl(h):Buffer.concat([Gh(h),Vl(h)]):sh(h)}function Gh(h){return Buffer.concat([Yh(h.statement.string,h.parameters,h.statement.types,h.statement.name),Vn("S",h.statement.name)])}function Vl(h){return Buffer.concat([Qn(h.parameters,h.statement.types,h.statement.name,h.cursorName),h.cursorFn?Rh("",h.cursorRows):hu])}function sh(h){return Buffer.concat([Yh(h.statement.string,h.parameters,h.statement.types),nu,Vl(h)])}function qh(h){let f=[],g=[],P=th(h,h.strings[0],h.args[0],f,g,l);!h.tagged&&h.args.forEach((W)=>al(W,f,g,l)),h.prepare=l.prepare&&("prepare"in h.options?h.options.prepare:!0),h.string=P,h.signature=h.prepare&&g+P,h.onlyDescribe&&delete O[h.signature],h.parameters=h.parameters||f,h.prepared=h.prepare&&h.signature in O,h.describeFirst=h.onlyDescribe||f.length&&!h.prepared,h.statement=h.prepared?O[h.signature]:{string:P,types:g,name:h.prepare?S+F++:""},typeof l.debug==="function"&&l.debug(Ul,P,f,g)}function a(h,f){if(ll=ll?Buffer.concat([ll,h]):Buffer.from(h),f||ll.length>=1024)return jh(f);return X===null&&(X=setImmediate(jh)),!0}function jh(h){let f=U.write(ll,h);return X!==null&&clearImmediate(X),ll=X=null,f}function xh(){ul(K.connection("CONNECT_TIMEOUT",l,U)),U.destroy()}async function Mh(){if(E!=="direct"){if(a(lu),!await new Promise((g)=>U.once("data",(P)=>g(P[0]===83)))&&t==="prefer")return Ll()}let h={socket:U,servername:vh.isIP(U.host)?void 0:U.host};if(E==="direct")h.ALPNProtocols=["postgresql"];if(t==="require"||t==="allow"||t==="prefer")h.rejectUnauthorized=!1;else if(typeof t==="object")Object.assign(h,t);U.removeAllListeners(),U=qn.connect(h),U.on("secureConnect",Ll),U.on("error",Nl),U.on("close",Nh),U.on("drain",Ph)}function Ph(){!A&&u(k)}function ql(h){if(tl){if(tl.push(h),V-=h.length,V>0)return}y=tl?Buffer.concat(tl,i-V):y.length===0?h:Buffer.concat([y,h],y.length+h.length);while(y.length>4){if(i=y.readUInt32BE(1),i>=y.length){V=i-y.length,tl=[y];break}try{ln(y.subarray(0,i+1))}catch(f){A&&(A.cursorFn||A.describeFirst)&&a(Bl),ul(f)}y=y.subarray(i+1),V=0,tl=null}}async function dh(){if(Al=!1,El={},U||(U=await ph()),!U)return;if(L.start(),l.socket)return t?Mh():Ll();if(U.on("connect",t?Mh:Ll),l.path)return U.connect(l.path);U.ssl=t,U.connect(T[G],Q[G]),U.host=Q[G],U.port=T[G],G=(G+1)%T.length}function Lh(){setTimeout(dh,v?Math.max(0,v+J-mh.now()):0)}function Ll(){try{O={},dl=l.fetch_types,S=Math.random().toString(36).slice(2),F=1,Il.start(),U.on("data",ql),cl&&U.setKeepAlive&&U.setKeepAlive(!0,1000*cl);let h=Kn();a(h)}catch(h){Nl(h)}}function Nl(h){if(k.queue===n.connecting&&l.host[D+1])return;ul(h);while(d.length)Cl(d.shift(),h)}function ul(h){C&&(C.destroy(h),C=null),A&&Cl(A,h),e&&(Cl(e,h),e=null)}function Cl(h,f){if(h.reserve)return h.reject(f);if(!f||typeof f!=="object")f=Error(f);"query"in f||"parameters"in f||Object.defineProperties(f,{stack:{value:f.stack+h.origin.replace(/.*\n/,`
|
|
3
3
|
`),enumerable:l.debug},query:{value:h.string,enumerable:l.debug},parameters:{value:h.parameters,enumerable:l.debug},args:{value:h.args,enumerable:l.debug},types:{value:h.statement&&h.statement.types,enumerable:l.debug}}),h.reject(f)}function xl(){return z||(!k.reserved&&c(k),!k.reserved&&!e&&!A&&d.length===0?(Zl(),new Promise((h)=>U&&U.readyState!=="closed"?U.once("close",h):h())):z=new Promise((h)=>Ql=h))}function Zl(){if(Al=!0,C||A||e||d.length)Nl(K.connection("CONNECTION_DESTROYED",l));if(clearImmediate(X),U)U.removeListener("data",ql),U.removeListener("connect",Ll),U.readyState==="open"&&U.end($().X().end());Ql&&(Ql(),z=Ql=null)}async function Nh(h){if(y=Buffer.alloc(0),V=0,tl=null,clearImmediate(X),U.removeListener("data",ql),U.removeListener("connect",Ll),Pl.cancel(),Il.cancel(),L.cancel(),U.removeAllListeners(),U=null,e)return Lh();!h&&(A||d.length)&&Nl(K.connection("CONNECTION_CLOSED",l,U)),v=mh.now(),h&&l.shared.retries++,J=(typeof nl==="function"?nl(l.shared.retries):nl)*1000,w(k,K.connection("CONNECTION_CLOSED",l,U))}function ln(h,f=h[0]){(f===68?hn:f===100?Tn:f===65?dn:f===83?nn:f===90?un:f===67?fn:f===50?Dh:f===49?cn:f===116?tn:f===84?wn:f===82?_n:f===110?gn:f===75?Bn:f===69?Mn:f===115?Ln:f===51?Nn:f===71?Dn:f===78?Cn:f===72?Yn:f===99?Xn:f===73?Zn:f===86?Fn:f===118?Hn:f===87?Rn:zn)(h)}function hn(h){let f=7,g,P,W,o=A.isRaw?Array(A.statement.columns.length):{};for(let s=0;s<A.statement.columns.length;s++)P=A.statement.columns[s],g=h.readInt32BE(f),f+=4,W=g===-1?null:A.isRaw===!0?h.subarray(f,f+=g):P.parser===void 0?h.toString("utf8",f,f+=g):P.parser.array===!0?P.parser(h.toString("utf8",f+1,f+=g)):P.parser(h.toString("utf8",f,f+=g)),A.isRaw?o[s]=A.isRaw===!0?W:M.value.from?M.value.from(W,P):W:o[P.name]=M.value.from?M.value.from(W,P):W;A.forEachFn?A.forEachFn(M.row.from?M.row.from(o):o,N):N[m++]=M.row.from?M.row.from(o):o}function nn(h){let[f,g]=h.toString("utf8",5,h.length-1).split($.N);if(El[f]=g,l.parameters[f]!==g)l.parameters[f]=g,b&&b(f,g)}function un(h){if(A)if(q)A.retried?ul(A.retried):A.prepared&&uu.has(q.routine)?Pn(A,q):ul(q);else A.resolve($l||N);else if(q)ul(q);if(A=$l=q=null,N=new Ml,L.cancel(),e){if(x){if(!El.in_hot_standby||!El.default_transaction_read_only)return jn();else if(Gn(x,El))return Zl()}if(dl)return e.reserve&&(e=null),In();e&&!e.reserve&&Xl(e),l.shared.retries=D=0,e=null;return}while(d.length&&(A=d.shift())&&(A.active=!0,A.cancelled))eh(l).cancel(A.state,A.cancelled.resolve,A.cancelled.reject);if(A)return;k.reserved?!k.reserved.release&&h[5]===73?z?Zl():(k.reserved=null,u(k)):k.reserved():z?Zl():u(k)}function fn(h){m=0;for(let f=h.length-1;f>0;f--){if(h[f]===32&&h[f+1]<58&&N.count===null)N.count=+h.toString("utf8",f+1,h.length-1);if(h[f-1]>=65){N.command=h.toString("utf8",5,f),N.state=_l;break}}if(Tl&&(Tl(),Tl=null),N.command==="BEGIN"&&_!==1&&!k.reserved)return ul(K.generic("UNSAFE_TRANSACTION","Only use sql.begin, sql.reserved or max: 1"));if(A.options.simple)return Dh();if(A.cursorFn)N.count&&A.cursorFn(N),a(Bl)}function cn(){A.parsing=!1}function Dh(){!N.statement&&(N.statement=A.statement),N.columns=A.statement.columns}function tn(h){let f=h.readUInt16BE(5);for(let g=0;g<f;++g)!A.statement.types[g]&&(A.statement.types[g]=h.readUInt32BE(7+g*4));A.prepare&&(O[A.signature]=A.statement),A.describeFirst&&!A.onlyDescribe&&(a(Vl(A)),A.describeFirst=!1)}function wn(h){if(N.command)$l=$l||[N],$l.push(N=new Ml),N.count=null,A.statement.columns=null;let f=h.readUInt16BE(5),g=7,P;A.statement.columns=Array(f);for(let W=0;W<f;++W){P=g;while(h[g++]!==0);let o=h.readUInt32BE(g),s=h.readUInt16BE(g+4),gl=h.readUInt32BE(g+6);A.statement.columns[W]={name:M.column.from?M.column.from(h.toString("utf8",P,g-1)):h.toString("utf8",P,g-1),parser:j[gl],table:o,number:s,type:gl},g+=18}if(N.statement=A.statement,A.onlyDescribe)return A.resolve(A.statement),a(Bl)}async function _n(h,f=h.readUInt32BE(5)){(f===3?On:f===5?En:f===10?An:f===11?Un:f===12?$n:f!==0?Jn:Rl)(h,f)}async function On(){let h=await lh();a($().p().str(h).z(1).end())}async function En(h){let f="md5"+await ah(Buffer.concat([Buffer.from(await ah(await lh()+B)),h.subarray(9)]));a($().p().str(f).z(1).end())}async function An(){sl=(await Jl.randomBytes(18)).toString("base64"),$().p().str("SCRAM-SHA-256"+$.N);let h=$.i;a($.inc(4).str("n,,n=*,r="+sl).i32($.i-h-4,h).end())}async function Un(h){let f=h.toString("utf8",9).split(",").reduce((s,gl)=>(s[gl[0]]=gl.slice(2),s),{}),g=await Jl.pbkdf2Sync(await lh(),Buffer.from(f.s,"base64"),parseInt(f.i),32,"sha256"),P=await pl(g,"Client Key"),W="n=*,r="+sl+",r="+f.r+",s="+f.s+",i="+f.i+",c=biws,r="+f.r;r=(await pl(await pl(g,"Server Key"),W)).toString("base64");let o="c=biws,r="+f.r+",p="+tu(P,Buffer.from(await pl(await cu(P),W))).toString("base64");a($().p().str(o).end())}function $n(h){if(h.toString("utf8",9).split($.N,1)[0].slice(2)===r)return;ul(K.generic("SASL_SIGNATURE_MISMATCH","The server did not return the correct signature")),U.destroy()}function lh(){return Promise.resolve(typeof l.pass==="function"?l.pass():l.pass)}function gn(){if(N.statement=A.statement,N.statement.columns=[],A.onlyDescribe)return A.resolve(A.statement),a(Bl)}function Bn(h){_l.pid=h.readUInt32BE(5),_l.secret=h.readUInt32BE(9)}async function In(){dl=!1,(await new fl([`
|
|
4
4
|
select b.oid, b.typarray
|
|
5
5
|
from pg_catalog.pg_type a
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Cg as M}from"./chunk-3zxfd7pn.js";import{Ri as P}from"./chunk-g5ppst76.js";class C{spent=new Map;sweepAt=1024;async consume(J,Q){return this.consumeSync(J,Q)}consumeSync(J,Q,Z=Date.now()){if(this.spent.size>=this.sweepAt)this.sweep(Z);let W=this.spent.get(J);if(W!==void 0&&W>Z)return!1;return this.spent.set(J,Q),!0}get size(){return this.spent.size}sweep(J){for(let[Q,Z]of this.spent)if(Z<=J)this.spent.delete(Q);this.sweepAt=Math.max(1024,this.spent.size*2)}}class N{injectedClient;prefix;constructor(J={}){this.injectedClient=J.client,this.prefix=J.prefix??"gemi:ai:nonce"}async consume(J,Q){let Z=Math.max(1,Math.ceil(Q-Date.now()));return await this.client.send("SET",[`${this.prefix}:${J}`,"1","PX",String(Z),"NX"])==="OK"}get client(){if(this.injectedClient)return this.injectedClient;let J=P(),Q=J.bound(M)?J.make(M).client:void 0;if(!Q)throw Error("RedisNonceStore could not reach the Redis client. Register RedisServiceProvider on your application, or pass a client: new RedisNonceStore({ client }).");return Q}}var S=new C;class D extends Error{retryable;constructor(J,Q={}){super(J,Q.cause!==void 0?{cause:Q.cause}:void 0);this.name="ToolError",this.retryable=Q.retryable??!0}}var u={provider_error:"The model provider returned an error.",rate_limited:"The model provider is rate limiting requests. Try again shortly.",context_length_exceeded:"The conversation is too long for the model.",content_filtered:"The model provider's content filter blocked this request.",invalid_tool_input:"The model provider rejected the request.",tool_error:"A tool failed.",unknown:"The run failed unexpectedly."};function V(J,Q){if(Q.source==="tool"){if(Q.cause instanceof D)return J;return{...J,message:`The tool "${Q.toolName}" failed with an unexpected error.`}}let Z=u[J.code];return Z===void 0?J:{...J,message:Z}}function e(J,Q,Z,W){let $;try{$=(J??V)(Q,Z)}catch(X){W(X),$=V(Q,Z)}return{code:$.code,message:$.message,...$.toolCallId!==void 0?{toolCallId:$.toolCallId}:{},retryable:$.retryable}}var L=new WeakMap;function JJ(J,Q){if(J!==Q)L.set(J,Q)}function QJ(J){return L.get(J)??J}import{createHmac as E,hkdfSync as m,randomBytes as k,timingSafeEqual as d}from"crypto";var z="agt2",j="agt1",O=[z,j],G=86400000,p=Date.now()+G;function f(J){return J<=p}var v="gemi.ai.pending-call.v1",I="gemi.ai.nested-run.v1",l="gemi.ai.execution-receipt.v1",t="gemi.ai.signing",b=new Map;function H(J,Q){let Z=K(Q),W=`${J}\x00${Z}`,$=b.get(W);if(!$){if($=Buffer.from(m("sha256",Z,t,J,32)),b.size>64)b.clear();b.set(W,$)}return $}function K(J){let Q=J??process.env.SECRET;if(!Q)throw Error("Signing a pending tool call needs an app secret. Set SECRET in the environment.");return Q}function q(J){if(J===null||typeof J!=="object")return JSON.stringify(J)??"null";if(Array.isArray(J))return`[${J.map(q).join(",")}]`;let Q=J;return`{${Object.keys(Q).filter((W)=>Q[W]!==void 0).sort().map((W)=>`${JSON.stringify(W)}:${q(Q[W])}`).join(",")}}`}function c(J){return J.map((Q)=>`${Q.length}:${Q}`).join("")}function B(J,Q){return E("sha256",J).update(c(Q)).digest()}function x(J,Q){let Z=Buffer.from(J.split(".")[4],"base64url");return Z.length===Q.length&&d(Z,Q)}function U(J){return q(J??null)}function R(J,Q,Z){return[z,J.runId,J.toolCallId,J.name,J.kind,Q,String(Z),q(J.input),q(J.path??[]),U(J.subject)]}function n(J,Q,Z){let W=[j,J.runId,J.toolCallId,J.name,J.kind,Q,String(Z),q(J.input)];if(J.path&&J.path.length>0)W.push(q(J.path));return W}var T=(J)=>Buffer.from(J,"utf8").toString("base64url"),o=(J)=>Buffer.from(J,"base64url").toString("utf8");function qJ(J,Q={}){let Z=H(v,Q.secret),$=(Q.now??Date.now())+(Q.ttlMs??G),X=k(12).toString("base64url"),h=B(Z,R(J,X,$)).toString("base64url");return[z,T(J.runId),X,$.toString(36),h].join(".")}function a(J){return Y(J,O)}function Y(J,Q){let Z=J.split(".");if(Z.length!==5||!Q.includes(Z[0]))return null;let W=Number.parseInt(Z[3],36);if(!Number.isFinite(W))return null;try{return{runId:o(Z[1]),nonce:Z[2],expiresAt:W,version:Z[0]}}catch{return null}}function XJ(J,Q,Z={}){let W=Y(J,O);if(!W)return{ok:!1,reason:"malformed"};if(W.version===j&&!f(W.expiresAt))return{ok:!1,reason:"forged"};let $=W.version===j?B(K(Z.secret),n(Q,W.nonce,W.expiresAt)):B(H(v,Z.secret),R(Q,W.nonce,W.expiresAt));if(!x(J,$))return{ok:!1,reason:"forged"};if((Z.now??Date.now())>W.expiresAt)return{ok:!1,reason:"expired"};return{ok:!0,runId:W.runId,nonce:W.nonce,expiresAt:W.expiresAt}}var F="agn2",w="agn1",A=[F,w];function _(J,Q,Z){return[...y(J,Q,Z,F),U(J.subject)]}function y(J,Q,Z,W=w){return[W,J.runId,q(J.path),J.nestedRunId,Q,String(Z),q([...J.open].sort()),q(J.input)]}function BJ(J,Q={}){let Z=H(I,Q.secret),$=(Q.now??Date.now())+(Q.ttlMs??G),X=k(12).toString("base64url"),h=B(Z,_(J,X,$)).toString("base64url");return[F,T(J.runId),X,$.toString(36),h].join(".")}function HJ(J,Q,Z={}){let W=Y(J,A);if(!W)return{ok:!1,reason:"malformed"};if(W.version===w&&!f(W.expiresAt))return{ok:!1,reason:"forged"};let $={...Q,runId:W.runId},X=W.version===w?B(K(Z.secret),y($,W.nonce,W.expiresAt)):B(H(I,Z.secret),_($,W.nonce,W.expiresAt));if(!x(J,X))return{ok:!1,reason:"forged"};if((Z.now??Date.now())>W.expiresAt)return{ok:!1,reason:"expired"};return{ok:!0,runId:W.runId,nonce:W.nonce,expiresAt:W.expiresAt}}function bJ(J,Q,Z={}){let W=H(l,Z.secret);return B(W,[J,Q.runId,Q.toolCallId,Q.name,Q.kind,q(Q.input),q(Q.path??[]),U(Q.subject)]).toString("base64url")}function jJ(J,Q){return g(Q,a(J))}function wJ(J,Q){return g(Q,Y(J,A))}async function g(J,Q){if(!Q)return!1;return J.consume(Q.nonce,Q.expiresAt)}
|
|
3
3
|
export{C as Ub,N as Vb,S as Wb,H as Xb,q as Yb,qJ as Zb,a as _b,XJ as $b,BJ as ac,HJ as bc,bJ as cc,jJ as dc,wJ as ec,D as fc,V as gc,e as hc,JJ as ic,QJ as jc};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=50FECCE9F573BC6B64756E2164756E21
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
"import { createHmac, hkdfSync, randomBytes, timingSafeEqual } from \"crypto\";\nimport { defaultNonceStore, type NonceStore } from \"./store/Nonces\";\n\n/**\n * Signing for pending tool calls.\n *\n * A pending call travels through the browser and comes back — in stateless mode\n * the whole history does — so the server cannot trust that what it gets back is\n * what it sent. Without a signature the client asserts not just *that* a call\n * was approved but *what* was approved, and nothing would stop it from\n * returning `approve: true` against an input it rewrote on the way. Signing is\n * what makes the round trip safe, and it is why approvals need no server-side\n * storage at all.\n *\n * What is signed, and what deliberately is not:\n *\n * signed — `runId`, `toolCallId`, the tool `name`, the `kind` of pending call\n * and a canonical serialization of the input, plus a nonce, an\n * expiry, and — for a call a sub-agent asked — the `path` of\n * tool-call ids it is nested under.\n * not — the client's answer. `approve: true` / `approve: false` and a\n * question's output are the *point* of asking; a client that flips\n * its own answer has refused, not forged. What the signature buys is\n * that the answer is bound to the call the server actually made,\n * with the input the server actually saw.\n *\n * A verified token is not yet an answer the server may act on: it says the\n * question was asked, not that it is still open. `consumePendingCall` at the\n * bottom of this file spends the nonce, which is what makes an approval\n * single-use — see the note there for what that guarantee is worth.\n *\n * `kind` is in there for a specific attack: an `approval`-kind call is one the\n * *server* runs, so a client that reused its signature on the \"here is the\n * output\" arm of `ClientToolResult` would be fabricating a server tool's result\n * rather than approving it. Binding the kind makes that a forgery instead of a\n * shape the caller has to remember to check.\n *\n * Keys and principals (#447). Neither token kind is MACed with `SECRET`\n * itself: each is keyed with its own HKDF-derived key (`purposeKey` below), so\n * a MAC minted for one purpose — a pending call, a parked-run record, or\n * anything else in the app keyed off `SECRET` (CSRF, sessions) — is never a\n * MAC for another. And each binds the `subject`, the principal the run was\n * started for (`AgentController.runOwner`), so a token minted while user A was\n * asked cannot be answered by user B, even with A's history in hand.\n */\n\n/** Everything the signature commits to. */\nexport type PendingCallClaims = {\n runId: string;\n toolCallId: string;\n name: string;\n kind: \"approval\" | \"question\" | \"client\";\n input: unknown;\n /**\n * The chain of tool-call ids the call is nested under, outermost first.\n * Absent — or empty, which means the same thing — for a top-level call.\n *\n * A sub-agent's question reaches the user through its parent's pending list,\n * so `toolCallId` stops being an address on its own: two sub-runs under two\n * different tools can each hold a call the outer run never made. Binding the\n * path is what stops a token minted for a call nested under tool call X from\n * being replayed as a top-level call, or as one nested under Y.\n */\n path?: string[];\n /**\n * Who the question was asked of: the run's owner (`AgentController.runOwner`,\n * `user:<id>` by default). `null` or absent is nobody in particular — an\n * anonymous run — and the two are the same claim. A token minted for one\n * subject fails verification for any other, `null` included, so an approval\n * cannot be carried from one user's session to another's.\n */\n subject?: string | null;\n};\n\nexport type SignOptions = {\n /** Overrides `process.env.SECRET`. Exists for tests; apps use the app key. */\n secret?: string;\n /**\n * Default 24 hours. An approval waits on a human, and humans go to lunch —\n * a short expiry turns \"I approved it after standup\" into an unexplained\n * failure. Long enough to survive a working day, short enough that a token\n * lifted from a log is not useful next month.\n */\n ttlMs?: number;\n /** Injected clock, so the expiry path is testable without waiting. */\n now?: number;\n};\n\nexport type VerifyOptions = {\n secret?: string;\n now?: number;\n};\n\n/**\n * A discriminated result rather than a boolean, because the two failures are\n * different events: `expired` is a sentence to show the user, `forged` is worth\n * logging and possibly alerting on. Collapsing them loses the only signal that\n * says someone is probing.\n */\nexport type VerifyResult =\n | { ok: true; runId: string; nonce: string; expiresAt: number }\n | { ok: false; reason: \"malformed\" | \"expired\" | \"forged\" };\n\n/**\n * `agt2` is minted; `agt1` is still verified. A v1 token was MACed with the raw\n * `SECRET` and binds no subject — it is accepted so that a question asked\n * before the upgrade can still be answered after it, and it stops mattering on\n * its own when the last one expires (`DEFAULT_TTL_MS` after the deploy). Drop\n * `LEGACY_VERSION` from the accepted set once that window is long past.\n */\nconst VERSION = \"agt2\";\nconst LEGACY_VERSION = \"agt1\";\nconst PENDING_VERSIONS = [VERSION, LEGACY_VERSION];\nconst DEFAULT_TTL_MS = 24 * 60 * 60 * 1000;\n\n/**\n * The latest expiry a legacy token may claim. Every v1 token this process can\n * legitimately see was minted by an earlier deploy with the default TTL, so it\n * expires no later than one TTL after this module loaded. Bounding it here\n * means a v1 token — MACed with the raw `SECRET`, the key this change exists to\n * stop relying on — cannot be forged with a far-future expiry, and that after\n * one TTL of uptime no v1 token verifies at all.\n */\nconst LEGACY_ACCEPTED_UNTIL = Date.now() + DEFAULT_TTL_MS;\n\nfunction legacyExpiryOk(expiresAt: number): boolean {\n return expiresAt <= LEGACY_ACCEPTED_UNTIL;\n}\n\n/**\n * HKDF `info` labels, one per thing a key signs. Changing a label is a key\n * rotation for that purpose alone.\n */\nconst PENDING_CALL_PURPOSE = \"gemi.ai.pending-call.v1\";\nconst NESTED_RUN_PURPOSE = \"gemi.ai.nested-run.v1\";\nconst EXECUTION_RECEIPT_PURPOSE = \"gemi.ai.execution-receipt.v1\";\nconst HKDF_SALT = \"gemi.ai.signing\";\n\nconst derivedKeys = new Map<string, Buffer>();\n\n/**\n * A key for one purpose, derived from the app secret with HKDF-SHA256.\n *\n * `SECRET` is also what CSRF tokens and sessions are keyed with. Using it as\n * the HMAC key here would make every one of those a potential oracle for the\n * others; HKDF with a purpose label gives each its own independent key, so a\n * weakness or leak in one use cannot be turned against another — including\n * the two token kinds in this file against each other.\n *\n * Memoized per (purpose, secret): verification is on the request path and the\n * derivation is pure. The map is bounded by the number of purposes times the\n * secrets a process ever sees, which is one outside of tests.\n */\nexport function purposeKey(purpose: string, override?: string): Buffer {\n const secret = secretKey(override);\n const cacheKey = `${purpose}\\u0000${secret}`;\n let key = derivedKeys.get(cacheKey);\n if (!key) {\n key = Buffer.from(hkdfSync(\"sha256\", secret, HKDF_SALT, purpose, 32));\n if (derivedKeys.size > 64) derivedKeys.clear();\n derivedKeys.set(cacheKey, key);\n }\n return key;\n}\n\nfunction secretKey(override?: string): string {\n const secret = override ?? process.env.SECRET;\n if (!secret) {\n // Refusing is the only safe answer. A fallback constant would make every\n // approval in every deployment forgeable by anyone who read this file, and\n // it would do it silently — the feature would appear to work.\n throw new Error(\n \"Signing a pending tool call needs an app secret. Set SECRET in the environment.\",\n );\n }\n return secret;\n}\n\n/**\n * Serializes a value so that the same value always produces the same string.\n *\n * `JSON.stringify` is not enough: it preserves insertion order, so an input\n * that made a round trip through a client — parsed and re-serialized, with the\n * keys in whatever order the parser produced — would hash differently and a\n * legitimate approval would come back looking forged. Keys are sorted,\n * `undefined` members are dropped (they do not survive JSON anyway), and arrays\n * keep their order because in an array order *is* the value.\n */\nexport function canonicalize(value: unknown): string {\n if (value === null || typeof value !== \"object\") {\n return JSON.stringify(value) ?? \"null\";\n }\n if (Array.isArray(value)) {\n return `[${value.map(canonicalize).join(\",\")}]`;\n }\n const record = value as Record<string, unknown>;\n const keys = Object.keys(record)\n .filter((key) => record[key] !== undefined)\n .sort();\n return `{${keys.map((key) => `${JSON.stringify(key)}:${canonicalize(record[key])}`).join(\",\")}}`;\n}\n\n/**\n * Length-prefixed rather than delimiter-joined. A separator is a place for two\n * different claim sets to hash the same — `runId: \"a\", toolCallId: \"b|c\"` and\n * `runId: \"a|b\", toolCallId: \"c\"` — and while neither field contains the\n * separator today, that is a property of the id generator, not of this code.\n */\nfunction payload(fields: string[]): string {\n return fields.map((field) => `${field.length}:${field}`).join(\"\");\n}\n\nfunction mac(key: string | Buffer, fields: string[]): Buffer {\n return createHmac(\"sha256\", key).update(payload(fields)).digest();\n}\n\nfunction macMatches(signature: string, expected: Buffer): boolean {\n const presented = Buffer.from(signature.split(\".\")[4], \"base64url\");\n // `timingSafeEqual` throws on a length mismatch, and a wrong length is\n // already a public fact about the token — nothing is leaked by checking it\n // first, and everything is leaked by comparing the bytes with `===`.\n return presented.length === expected.length && timingSafeEqual(presented, expected);\n}\n\n/** The principal as a field: absent and `null` are the same claim. */\nfunction subjectField(subject: string | null | undefined): string {\n return canonicalize(subject ?? null);\n}\n\n/**\n * The v2 claim set. Fixed-length: the path is always present (`[]` at the top\n * level) and so is the subject, so there is no optional field to reason about.\n */\nfunction claimFields(claims: PendingCallClaims, nonce: string, expiresAt: number): string[] {\n return [\n VERSION,\n claims.runId,\n claims.toolCallId,\n claims.name,\n claims.kind,\n nonce,\n String(expiresAt),\n canonicalize(claims.input),\n canonicalize(claims.path ?? []),\n subjectField(claims.subject),\n ];\n}\n\n/**\n * The v1 claim set, kept only to verify tokens minted before #447.\n *\n * The path is appended, and only when there is one.\n *\n * Byte-identical output for a call with no path is the whole requirement here:\n * every approval already in flight was minted from the eight fields below, and\n * a ninth field carrying `\"[]\"` or `\"undefined\"` would invalidate all of them\n * on deploy — the user who clicked Approve before the release would be told\n * their answer was forged. So an absent path adds nothing at all, and an empty\n * array is treated as absent because it says the same thing.\n *\n * `payload` is length-prefixed, so appending a field cannot collide with a\n * longer value in the one before it; that is why this can be an append rather\n * than a new version tag.\n */\nfunction legacyClaimFields(claims: PendingCallClaims, nonce: string, expiresAt: number): string[] {\n const fields = [\n LEGACY_VERSION,\n claims.runId,\n claims.toolCallId,\n claims.name,\n claims.kind,\n nonce,\n String(expiresAt),\n canonicalize(claims.input),\n ];\n if (claims.path && claims.path.length > 0) {\n fields.push(canonicalize(claims.path));\n }\n return fields;\n}\n\nconst encode = (value: string) => Buffer.from(value, \"utf8\").toString(\"base64url\");\nconst decode = (value: string) => Buffer.from(value, \"base64url\").toString(\"utf8\");\n\n/** `agt2.<runId>.<nonce>.<expiry>.<mac>`, all base64url or base36. */\nexport function signPendingCall(claims: PendingCallClaims, options: SignOptions = {}): string {\n const key = purposeKey(PENDING_CALL_PURPOSE, options.secret);\n const now = options.now ?? Date.now();\n const expiresAt = now + (options.ttlMs ?? DEFAULT_TTL_MS);\n const nonce = randomBytes(12).toString(\"base64url\");\n const signature = mac(key, claimFields(claims, nonce, expiresAt)).toString(\"base64url\");\n return [VERSION, encode(claims.runId), nonce, expiresAt.toString(36), signature].join(\".\");\n}\n\n/**\n * The metadata a signature carries in the clear.\n *\n * `Agent` needs the issuing `runId` before it can verify anything: the call was\n * signed under the run that made it, and the turn answering it is a *new* run\n * with a new id. Reading it out of the token is safe because the token's own\n * MAC covers it — a client that edits the runId here fails verification, so\n * this is \"which run does this claim to belong to\", not \"which run does the\n * client say it belongs to\".\n */\nexport function readSignature(\n signature: string,\n): { runId: string; nonce: string; expiresAt: number } | null {\n return readToken(signature, PENDING_VERSIONS);\n}\n\n/**\n * The version tag is checked here and nowhere else, which is what keeps the\n * two token kinds apart: a parked-run record presented where a pending call's\n * signature is expected fails as malformed before its MAC is even looked at,\n * and the other way round. Their claim sets are different lengths and would\n * not collide anyway, but a tag makes that a rule rather than an accident of\n * the field count.\n */\nfunction readToken(\n signature: string,\n versions: readonly string[],\n): { runId: string; nonce: string; expiresAt: number; version: string } | null {\n const parts = signature.split(\".\");\n if (parts.length !== 5 || !versions.includes(parts[0])) {\n return null;\n }\n const expiresAt = Number.parseInt(parts[3], 36);\n if (!Number.isFinite(expiresAt)) {\n return null;\n }\n try {\n return { runId: decode(parts[1]), nonce: parts[2], expiresAt, version: parts[0] };\n } catch {\n return null;\n }\n}\n\nexport function verifyPendingCall(\n signature: string,\n claims: PendingCallClaims,\n options: VerifyOptions = {},\n): VerifyResult {\n const parsed = readToken(signature, PENDING_VERSIONS);\n if (!parsed) {\n return { ok: false, reason: \"malformed\" };\n }\n\n if (parsed.version === LEGACY_VERSION && !legacyExpiryOk(parsed.expiresAt)) {\n return { ok: false, reason: \"forged\" };\n }\n const expected =\n parsed.version === LEGACY_VERSION\n ? // Raw secret, no subject: see `LEGACY_VERSION`.\n mac(secretKey(options.secret), legacyClaimFields(claims, parsed.nonce, parsed.expiresAt))\n : mac(\n purposeKey(PENDING_CALL_PURPOSE, options.secret),\n claimFields(claims, parsed.nonce, parsed.expiresAt),\n );\n if (!macMatches(signature, expected)) {\n return { ok: false, reason: \"forged\" };\n }\n\n // Expiry is checked *after* the MAC on purpose: only a genuine token can be\n // \"expired\". Reporting a forgery as expired would tell the UI to say \"your\n // approval timed out\" to someone who was tampering.\n if ((options.now ?? Date.now()) > parsed.expiresAt) {\n return { ok: false, reason: \"expired\" };\n }\n\n return { ok: true, runId: parsed.runId, nonce: parsed.nonce, expiresAt: parsed.expiresAt };\n}\n\n// --- parked sub-runs -----------------------------------------------------\n\n/**\n * What a parked sub-run's record is signed over.\n *\n * `ToolCallPart.nested` is the parent's own record of where a sub-run stopped,\n * and in stateless mode it makes the same trip through the browser a pending\n * call does. The next turn *runs a tool* on the strength of that record — the\n * tool is re-entered because the record says a sub-run under it is waiting on\n * the question being answered — so an unsigned record lets the client choose\n * which tools run, with what input, before any answer is verified. A MAC over\n * what the server actually recorded is what makes the record safe to carry.\n *\n * Only a parked record is signed, because only a parked record executes\n * anything: a finished sub-run is replayed out of its transcript and spends\n * nothing, and a client that forges one has fed its own tool a made-up answer,\n * which a client-carried history already allows everywhere.\n *\n * Deliberately not signed: the transcript. The sub-run resumes from messages\n * the client carried, exactly as the parent does in stateless mode, and the\n * same argument applies — what the signature pins is that the server parked\n * *here*, on *these* calls, with *this* input, and not what was said on the\n * way.\n */\nexport type NestedRunClaims = {\n /** The root run's id, the one every pending call of the tree is minted under. */\n runId: string;\n /**\n * Tool-call ids from the root down to and including the call the record\n * hangs off. A sub-run's id is not an address on its own for the same reason\n * a nested call's is not: two sub-runs under two different tools can carry\n * the same one.\n */\n path: string[];\n /** The sub-run's own id, so a record cannot be moved between sub-runs. */\n nestedRunId: string;\n /** The tool calls the sub-run is waiting on: every call left open in its transcript. */\n open: string[];\n /**\n * The input the tool that parked was running on, as the transcript carries\n * it. Re-entry runs the tool body with the input the history holds, and the\n * history is the client's — so a record that pinned where the sub-run parked\n * but not what its tool was given would let the client keep the run and\n * rewrite the arguments to anything the schema accepts. The same bargain a\n * pending call makes: the input executed is the input signed.\n */\n input: unknown;\n /** The run's owner, as on `PendingCallClaims.subject`: a record parked for\n * one principal does not re-enter a tool for another. */\n subject?: string | null;\n};\n\n/** `agn2` is minted; `agn1` (raw secret, no subject) is still verified. See\n * `LEGACY_VERSION`. */\nconst NESTED_VERSION = \"agn2\";\nconst LEGACY_NESTED_VERSION = \"agn1\";\nconst NESTED_VERSIONS = [NESTED_VERSION, LEGACY_NESTED_VERSION];\n\nfunction nestedFields(claims: NestedRunClaims, nonce: string, expiresAt: number): string[] {\n return [\n ...legacyNestedFields(claims, nonce, expiresAt, NESTED_VERSION),\n subjectField(claims.subject),\n ];\n}\n\nfunction legacyNestedFields(\n claims: NestedRunClaims,\n nonce: string,\n expiresAt: number,\n version = LEGACY_NESTED_VERSION,\n): string[] {\n return [\n version,\n claims.runId,\n canonicalize(claims.path),\n claims.nestedRunId,\n nonce,\n String(expiresAt),\n // A set, so it is sorted: the ids are read back out of a transcript the\n // client re-serialized, and message order is not part of the claim.\n canonicalize([...claims.open].sort()),\n canonicalize(claims.input),\n ];\n}\n\n/**\n * Same shape as a pending call's token, so the same reader serves both — nonce\n * included, and the nonce is spent, by `consumeNestedRun` below. A verified\n * record is permission to run the tool it hangs off, and the tool body runs\n * before the sub-run gets to look at the answer's own nonce; a record that\n * could be presented twice would run the body twice before anything refused\n * the replay. Every park mints a fresh record, so spending one costs a\n * legitimate re-park nothing.\n */\nexport function signNestedRun(claims: NestedRunClaims, options: SignOptions = {}): string {\n const key = purposeKey(NESTED_RUN_PURPOSE, options.secret);\n const now = options.now ?? Date.now();\n const expiresAt = now + (options.ttlMs ?? DEFAULT_TTL_MS);\n const nonce = randomBytes(12).toString(\"base64url\");\n const signature = mac(key, nestedFields(claims, nonce, expiresAt)).toString(\"base64url\");\n return [NESTED_VERSION, encode(claims.runId), nonce, expiresAt.toString(36), signature].join(\".\");\n}\n\n/**\n * The run that verifies a record is never the run that minted it — the turn\n * answering a question is a new run with a new id — so the minting run's id is\n * read out of the token rather than asked of the caller, which has no other\n * source for it. The MAC covers it, so a client that edits the id in the clear\n * fails here rather than being believed.\n */\nexport function verifyNestedRun(\n signature: string,\n claims: Omit<NestedRunClaims, \"runId\">,\n options: VerifyOptions = {},\n): VerifyResult {\n const parsed = readToken(signature, NESTED_VERSIONS);\n if (!parsed) {\n return { ok: false, reason: \"malformed\" };\n }\n\n if (parsed.version === LEGACY_NESTED_VERSION && !legacyExpiryOk(parsed.expiresAt)) {\n return { ok: false, reason: \"forged\" };\n }\n const full = { ...claims, runId: parsed.runId };\n const expected =\n parsed.version === LEGACY_NESTED_VERSION\n ? mac(secretKey(options.secret), legacyNestedFields(full, parsed.nonce, parsed.expiresAt))\n : mac(\n purposeKey(NESTED_RUN_PURPOSE, options.secret),\n nestedFields(full, parsed.nonce, parsed.expiresAt),\n );\n if (!macMatches(signature, expected)) {\n return { ok: false, reason: \"forged\" };\n }\n\n // A parked record outlives its usefulness with the answers it exists to\n // deliver: those expire on the pending call's TTL, and a record older than\n // that can route nothing that would still verify.\n if ((options.now ?? Date.now()) > parsed.expiresAt) {\n return { ok: false, reason: \"expired\" };\n }\n\n return { ok: true, runId: parsed.runId, nonce: parsed.nonce, expiresAt: parsed.expiresAt };\n}\n\n// --- single use ----------------------------------------------------------\n\n/**\n * Spending a nonce.\n *\n * The MAC makes a token unforgeable; it does not make it single-use. Without\n * this a captured signature approves the same call again every time it is\n * presented, because a token that carries its own `runId` is a token that\n * asserts its own binding — which is no binding at all. Verifying tells you the\n * server once asked this exact question; spending the nonce is what says nobody\n * has answered it yet.\n *\n * Where spent nonces live is a `NonceStore` (`store/Nonces.ts`, #445). The\n * default is the process-wide `MemoryNonceStore`, which is exact for one\n * instance; an app with several instances gives the agent a shared store\n * (`RedisNonceStore`, or a table) so a rewound history cannot be replayed once\n * against each of them. The store's `consume` is insert-if-absent, so two\n * instances answering at once cannot both win.\n *\n * The other guard is the app's own message store: once a call has a result\n * next to it, the call is no longer open and the answer has nothing to attach\n * to. This is what stands in for that in stateless mode, where the history the\n * client returns can be rewound to before the result existed.\n */\n\n/**\n * The id an approved call's execution receipt is kept under (#458).\n *\n * Deterministic in the call the signature covers — the issuing run, the tool\n * call id, the tool, its canonical input, the nesting path and the subject —\n * and in nothing else, so every presentation of one approval, on any instance,\n * names the same receipt. Not in the nonce or expiry: those identify one\n * *token*, and a receipt identifies the *execution* it authorizes.\n *\n * An HMAC under its own HKDF-derived key rather than a plain hash, so an id in\n * a shared store is neither a MAC for anything else nor something a client can\n * compute to probe the store for another user's calls.\n */\nexport function executionReceiptId(\n agent: string,\n claims: PendingCallClaims,\n options: { secret?: string } = {},\n): string {\n const key = purposeKey(EXECUTION_RECEIPT_PURPOSE, options.secret);\n return mac(key, [\n agent,\n claims.runId,\n claims.toolCallId,\n claims.name,\n claims.kind,\n canonicalize(claims.input),\n canonicalize(claims.path ?? []),\n subjectField(claims.subject),\n ]).toString(\"base64url\");\n}\n\n/**\n * Spends a signature's nonce in `store`. `false` means it was already spent —\n * the answer is a replay and must not be acted on — or the token is malformed.\n * A store that throws rejects; the caller refuses the answer.\n *\n * Separate from `verifyPendingCall` rather than folded into it, because verify\n * is a pure question a caller may want to ask twice (logging a forgery, say)\n * and this one is a state change that must happen exactly once per answer.\n */\nexport function spendPendingCall(signature: string, store: NonceStore): Promise<boolean> {\n return spendIn(store, readSignature(signature));\n}\n\n/**\n * Spends a parked-run record's nonce, on the same store and the same terms.\n * `false` means the record has already re-entered its tool once — the turn is\n * a replay of a history from before the answer was delivered, and the body\n * must not run again on it.\n */\nexport function spendNestedRun(signature: string, store: NonceStore): Promise<boolean> {\n return spendIn(store, readToken(signature, NESTED_VERSIONS));\n}\n\nasync function spendIn(\n store: NonceStore,\n parsed: { nonce: string; expiresAt: number } | null,\n): Promise<boolean> {\n if (!parsed) return false;\n return store.consume(parsed.nonce, parsed.expiresAt);\n}\n\n/** `spendPendingCall` on the process-wide default store, synchronously.\n * `now` is injectable for tests. */\nexport function consumePendingCall(signature: string, options: VerifyOptions = {}): boolean {\n const parsed = readSignature(signature);\n return parsed\n ? defaultNonceStore.consumeSync(parsed.nonce, parsed.expiresAt, options.now)\n : false;\n}\n\n/** `spendNestedRun` on the process-wide default store, synchronously. */\nexport function consumeNestedRun(signature: string, options: VerifyOptions = {}): boolean {\n const parsed = readToken(signature, NESTED_VERSIONS);\n return parsed\n ? defaultNonceStore.consumeSync(parsed.nonce, parsed.expiresAt, options.now)\n : false;\n}\n"
|
|
8
8
|
],
|
|
9
9
|
"mappings": "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",
|
|
10
|
-
"debugId": "
|
|
10
|
+
"debugId": "50FECCE9F573BC6B64756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Xc as o}from"./chunk-tzdenj0n.js";import{Yc as i}from"./chunk-30xxc6r7.js";import{Nh as t}from"./chunk-gqfqnv3f.js";import{Ni as r}from"./chunk-z759yah5.js";class n extends i{register(){this.app.singleton(r,()=>new r(t(o(),this.app.config.get("translation",{}))))}}
|
|
3
|
+
export{n as fb};
|
|
4
|
+
|
|
5
|
+
//# debugId=87B0CFB72984AA3C64756E2164756E21
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"import { ServiceProvider } from \"../support/ServiceProvider\";\nimport { withDefaults } from \"../support/withDefaults\";\nimport { Translator } from \"./Translator\";\nimport { translationConfigDefaults, type TranslationConfig } from \"./config\";\n\nexport class TranslationServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n Translator,\n () =>\n new Translator(\n withDefaults(\n translationConfigDefaults(),\n this.app.config.get<TranslationConfig>(\"translation\", {}),\n ),\n ),\n );\n }\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";sLAKO,AAAM,IAAmC,LAAgB,CAC9D,QAAQ,EAAG,CACT,KAAK,IAAI,UACP,EACA,IACE,IAAI,EACF,EACE,EAA0B,EAC1B,KAAK,IAAI,OAAO,IAAuB,cAAe,CAAC,CAAC,CAC1D,CACF,CACJ,EAEJ",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "87B0CFB72984AA3C64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ag as _0,yg as q,zg as L0}from"./chunk-gn7kne7r.js";import{Dg as b}from"./chunk-x84as3vy.js";import{Gi as zQ}from"./chunk-076jezzg.js";import{Si as Y0}from"./chunk-8gtc3s1y.js";import{Zi as mZ}from"./chunk-dcgvq79a.js";class i0{static kind="controller";constructor(){}}class SQ extends i0{}function q0(Q){let Z=new Map;if(!Q)return Z;for(let $ of Q.split(";")){let X=$.indexOf("=");if(X===-1)continue;let G=$.slice(0,X).trim();if(!G)continue;Z.set(G,$.slice(X+1).trim())}return Z}function $1(Q){return q0(Q.headers.get("cookie"))}function p(Q){if(!/^\d+$/.test(Q))return null;let Z=Number(Q);return Number.isSafeInteger(Z)?Z:null}function n0(Q){if(!Q)return null;let Z=Q.trim();if(!/^bytes=/i.test(Z))return null;let X=Z.slice(6).split(",").map((D)=>D.trim()).filter((D)=>D!=="");if(X.length!==1)return null;let G=X[0],H=G.indexOf("-");if(H===-1)return null;let Y=G.slice(0,H),M=G.slice(H+1);if(Y===""){let D=p(M);if(D===null)return null;return{kind:"suffix",suffixLength:D}}let K=p(Y);if(K===null)return null;if(M==="")return{kind:"offset",start:K,end:null};let J=p(M);if(J===null||J<K)return null;return{kind:"offset",start:K,end:J}}function o0(Q,Z){if(!Number.isFinite(Z)||Z<=0)return null;let $,X;if(Q.kind==="suffix"){if(Q.suffixLength<=0)return null;$=Math.max(0,Z-Q.suffixLength),X=Z-1}else{if(Q.start>=Z)return null;if($=Q.start,X=Q.end===null?Z-1:Math.min(Q.end,Z-1),X<$)return null}return{start:$,end:X,length:X-$+1}}function G1(Q){if(Q.kind==="suffix")return`bytes=-${Q.suffixLength}`;return Q.end===null?`bytes=${Q.start}-`:`bytes=${Q.start}-${Q.end}`}function H1(Q){if(!Q)return null;let Z=/^bytes\s+(\d+)-(\d+)\/(\d+)$/i.exec(Q.trim());if(!Z)return null;let $=p(Z[1]),X=p(Z[2]),G=p(Z[3]);if($===null||X===null||G===null||X<$)return null;return{start:$,end:X,total:G}}function Y1(Q,Z,$){return`bytes ${Q}-${Z}/${$}`}function t0(Q){return`bytes */${Q}`}class s extends q{errors={};constructor(Q){super("Validation error");this.name="ValidationError",this.errors=Q,this.payload={api:{status:400,data:{error:{kind:"validation_error",messages:Q,status:400}},headers:{"Content-Type":"application/json"}},view:{status:400}}}}function xQ(Q){let[Z,$]=Q.match(/\d+|\D+/g)??[];if(!Z||!$)return 0;let X=Number.parseInt(Z);switch($){case"B":return X;case"KB":return X*1024;case"MB":return X*1024*1024;case"GB":return X*1024*1024*1024;case"TB":return X*1024*1024*1024*1024;default:return 0}}function kQ(Q){switch(Q){case"image":return"image";case"png":return"image/png";case"jpg":return"image/jpeg";case"jpeg":return"image/jpeg";case"ttf":return"font/ttf";case"excel":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case"csv":return"text/csv";case"word":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"pdf":return"application/pdf";case"json":return"application/json";default:return Q}}function s0(Q){if(typeof Q==="string"||Array.isArray(Q))return Q.length;return}function N0(Q){return typeof Q==="number"&&!Number.isNaN(Q)}var gQ=["required","string","boolean","number","email","password","min","max","gte","lte","file","fileType","fileSize","array","object","in"];class k extends Error{name="InvalidValidationRuleError"}function V0(Q,Z){let $=Z===void 0||Z.trim()===""?Number.NaN:Number(Z);if(Number.isNaN($))throw new k(`Validation rule "${Q}:${Z??""}" needs a number, e.g. "${Q}:3"`);return $}function a0(Q){let Z=Q.indexOf(":"),$=Z===-1?Q:Q.slice(0,Z),X=Z===-1?void 0:Q.slice(Z+1);switch($){case"required":return(G)=>{if(G instanceof Blob)return G.size>0;if(G===null||G===void 0)return!1;if(typeof G==="string"||Array.isArray(G))return G.length>0;return!0};case"string":return(G)=>typeof G==="string";case"boolean":return(G)=>typeof G==="boolean";case"number":return(G)=>N0(G);case"password":return(G)=>{return typeof G==="string"&&/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/.test(G)};case"min":{let G=V0($,X);return(H)=>{let Y=s0(H);return Y!==void 0&&Y>=G}}case"max":{let G=V0($,X);return(H)=>{let Y=s0(H);return Y!==void 0&&Y<=G}}case"gte":{let G=V0($,X);return(H)=>N0(H)&&H>=G}case"lte":{let G=V0($,X);return(H)=>N0(H)&&H<=G}case"email":return(G)=>{return typeof G==="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(G)};case"file":return(G)=>{return G instanceof Blob};case"fileType":{if(!X)throw new k('Validation rule "fileType" needs a type, e.g. "fileType:png" or "fileType:image"');let G=kQ(X);return(H)=>H instanceof Blob&&H.type.startsWith(G)}case"fileSize":{let G=xQ(X??"");if(G===0&&!/^0+(B|KB|MB|GB|TB)$/.test(X??""))throw new k(`Validation rule "fileSize:${X??""}" needs a whole size in B, KB, MB, GB or TB, e.g. "fileSize:5MB"`);return(H)=>H instanceof Blob&&H.size<=G}case"array":return(G)=>Array.isArray(G);case"object":return(G)=>typeof G==="object"&&G!==null&&!Array.isArray(G)&&!(G instanceof Blob);case"in":{let G=(X??"").split(",").filter((H)=>H!=="");if(G.length===0)throw new k('Validation rule "in" needs a comma-separated list, e.g. "in:draft,published"');return(H)=>typeof H==="string"&&G.includes(H)}default:throw new k(`Unknown validation rule "${Q}". Known rules: ${gQ.join(", ")}`)}}function u(Q){if(!Q.definition)throw Error(`gemi/ai: the recursive schema "${Q.name}" was used before its definition returned; \`self\` can be nested into the schema, but not parsed or emitted inside the callback`);return Q.definition}var j0=new WeakMap;function QQ(Q){return typeof Q==="object"&&Q!==null&&j0.has(Q)}function U0(Q){let Z=j0.get(Q);if(!Z)throw Error("gemi/ai: expected a schema built with `s`, got a foreign object");return Z}function yQ(Q){let Z={defs:{},cells:new Map},$=Q;if(Q.node.kind==="ref"){let G=u(Q.node.cell);$={...G,...Q.description?{description:Q.description}:{},optional:Q.optional,nullable:Q.nullable||G.nullable}}let X=r($,Z);return Object.keys(Z.defs).length>0?{...X,$defs:Z.defs}:X}function r(Q,Z){let $=(Q.optional||Q.nullable)&&Q.node.kind!=="json",X=vQ(fQ(Q.node,Z),$),G=[Q.description,bQ(Q.node)].filter(Boolean).join(" ");if(G&&X.$ref!==void 0)X={anyOf:[X]};return G?{description:G,...X}:X}function bQ(Q){let Z=[];if(Q.kind==="string"||Q.kind==="enum"){let $=Q.checks;if($?.format)Z.push(`Format: ${$.format.name}.`);if($?.minLength!==void 0)Z.push(`At least ${$.minLength} characters.`);if($?.maxLength!==void 0)Z.push(`At most ${$.maxLength} characters.`)}else if(Q.kind==="number"){let $=Q.checks;if($?.minimum!==void 0)Z.push(`Minimum ${$.minimum}.`);if($?.exclusiveMinimum!==void 0)Z.push(`Greater than ${$.exclusiveMinimum}.`);if($?.maximum!==void 0)Z.push(`Maximum ${$.maximum}.`);if($?.exclusiveMaximum!==void 0)Z.push(`Less than ${$.exclusiveMaximum}.`)}else if(Q.kind==="array"){let $=Q.checks;if($?.minItems!==void 0)Z.push(`At least ${$.minItems} items.`);if($?.maxItems!==void 0)Z.push(`At most ${$.maxItems} items.`)}return Z.join(" ")}function fQ(Q,Z){switch(Q.kind){case"string":return{type:"string"};case"number":return{type:Q.checks?.integer?"integer":"number"};case"boolean":return{type:"boolean"};case"literal":return{type:typeof Q.value,const:Q.value};case"enum":return{type:"string",enum:Q.values};case"array":return{type:"array",items:r(Q.item,Z)};case"object":return{type:"object",properties:Object.fromEntries(Object.entries(Q.shape).map(([$,X])=>[$,r(X,Z)])),required:Object.keys(Q.shape),additionalProperties:!1};case"union":return{anyOf:Q.members.map(($)=>r($,Z))};case"json":return{};case"ref":{let{cell:$}=Q,X=Z.cells.get($.name);if(X&&X!==$)throw Error(`gemi/ai: two different recursive schemas are named "${$.name}" in one schema; give each s.recursive(...) its own name`);if(!X)Z.cells.set($.name,$),Z.defs[$.name]={},Z.defs[$.name]=r(u($),Z);return{$ref:`#/$defs/${$.name}`}}}}function vQ(Q,Z){if(!Z)return Q;if(Q.anyOf)return{...Q,anyOf:[...Q.anyOf,{type:"null"}]};if(Q.enum||Q.const!==void 0)return{anyOf:[Q,{type:"null"}]};if(typeof Q.type==="string")return{...Q,type:[Q.type,"null"]};return{anyOf:[Q,{type:"null"}]}}function hQ(Q){if(Q===null)return"null";if(Array.isArray(Q))return"array";return typeof Q}function mQ(Q,Z){if(typeof Z==="number"&&!Number.isFinite(Z))return String(Z);if(Q.kind==="literal"||Q.kind==="enum"){if(typeof Z==="string"||typeof Z==="number"||typeof Z==="boolean")return JSON.stringify(Z)}return hQ(Z)}function ZQ(Q){let Z=Q.node,$=(()=>{switch(Z.kind){case"number":return Z.checks?.integer?"integer":"number";case"string":case"boolean":return Z.kind;case"literal":return JSON.stringify(Z.value);case"enum":return`one of ${Z.values.map((X)=>JSON.stringify(X)).join(" | ")}`;case"array":return"array";case"object":return"object";case"union":return"one of the variants";case"json":return"a JSON value";case"ref":return ZQ({...u(Z.cell),optional:!1,nullable:!1})}})();return Q.optional||Q.nullable?`${$} or null`:$}function cQ(Q){let Z="";for(let $ of Q)Z+=typeof $==="number"?`[${$}]`:Z?`.${$}`:$;return Z}function pQ(Q){let Z=cQ(Q);return Z?`${Z}: `:""}function w0(Q){return`${pQ(Q.path)}${Q.message}`}function B0(Q,Z){if(Z===null||Z===void 0)return Q.optional||Q.nullable?1:0;let $=Q.node;switch($.kind){case"string":return typeof Z==="string"?1:0;case"number":return typeof Z==="number"?1:0;case"boolean":return typeof Z==="boolean"?1:0;case"literal":return Z===$.value?10:0;case"enum":return typeof Z==="string"&&$.values.includes(Z)?10:0;case"array":return Array.isArray(Z)?1:0;case"object":{if(typeof Z!=="object"||Array.isArray(Z))return 0;let X=Z,G=1;for(let[H,Y]of Object.entries($.shape))G+=B0(Y,X[H]);return G}case"union":return $.members.reduce((X,G)=>Math.max(X,B0(G,Z)),0);case"json":return 1;case"ref":return $Q($.cell,Z,()=>1,()=>B0(u($.cell),Z))}}function $Q(Q,Z,$,X){if(typeof Z!=="object"||Z===null)return X();if(Q.active.has(Z))return $();Q.active.add(Z);try{return X()}finally{Q.active.delete(Z)}}function v(Q,Z,$,X){if(Q.optional&&(Z===null||Z===void 0))return{drop:!0,value:void 0};if(Q.nullable&&Z===null)return{drop:!1,value:null};return{drop:!1,value:uQ(Q,Z,$,X)}}function uQ(Q,Z,$,X){let G=Q.node,H=()=>{let Y=Z===void 0?"required":G.kind==="literal"?"const":G.kind==="enum"&&typeof Z==="string"?"enum":"type",M=Y==="const"?{allowedValue:G.value}:Y==="enum"?{allowedValues:G.values}:{};X.push({path:$,code:Y,message:`expected ${ZQ(Q)}, got ${mQ(G,Z)}`,params:M});return};switch(G.kind){case"string":if(typeof Z!=="string")return H();return r0(G.checks,Z,$,X),Z;case"number":if(typeof Z!=="number"||!Number.isFinite(Z))return H();if(G.checks?.integer&&!Number.isInteger(Z))return H();return lQ(G.checks,Z,$,X),Z;case"boolean":return typeof Z==="boolean"?Z:H();case"literal":return Z===G.value?Z:H();case"enum":if(typeof Z!=="string"||!G.values.includes(Z))return H();return r0(G.checks,Z,$,X),Z;case"array":{if(!Array.isArray(Z))return H();let Y=Z.map((J,D)=>{let V=v(G.item,J,[...$,D],X);return V.drop?void 0:V.value}),{minItems:M,maxItems:K}=G.checks??{};if(M!==void 0&&Z.length<M)X.push({path:$,code:"minItems",message:`expected at least ${M} items, got ${Z.length}`,params:{limit:M}});if(K!==void 0&&Z.length>K)X.push({path:$,code:"maxItems",message:`expected at most ${K} items, got ${Z.length}`,params:{limit:K}});return Y}case"object":{if(typeof Z!=="object"||Z===null||Array.isArray(Z))return H();let Y=Z,M={};for(let[K,J]of Object.entries(G.shape)){let D=v(J,Y[K],[...$,K],X);if(!D.drop)M[K]=D.value}if(G.unknownKeys)for(let K of Object.keys(Y)){if(Object.hasOwn(G.shape,K)||Y[K]===void 0)continue;if(G.unknownKeys==="error"){X.push({path:[...$,K],code:"additionalProperties",message:"unknown key",params:{additionalProperty:K}});continue}Z0(Y[K],[...$,K],X,new Set),Object.defineProperty(M,K,{value:Y[K],enumerable:!0,writable:!0,configurable:!0})}return M}case"union":{let Y;for(let M of G.members){let K=[],J=v(M,Z,$,K);if(K.length===0)return J.drop?void 0:J.value;let D=B0(M,Z);if(!Y||D>Y.score)Y={issues:K,score:D}}X.push({path:$,code:"anyOf",message:`no matching variant; closest: ${Y.issues.map(w0).join("; ")}`,params:{closest:Y.issues}});return}case"json":if(Z===void 0)return H();return Z0(Z,$,X,new Set),Z;case"ref":return $Q(G.cell,Z,()=>{X.push({path:$,code:"type",message:"expected a finite tree, got a circular reference",params:{}});return},()=>v(u(G.cell),Z,$,X).value)}}function dQ(Q){let Z=0;for(let $ of Q)Z++;return Z}function r0(Q,Z,$,X){if(!Q)return;let{minLength:G,maxLength:H,format:Y}=Q;if(G!==void 0||H!==void 0){let M=dQ(Z);if(G!==void 0&&M<G)X.push({path:$,code:"minLength",message:`expected at least ${G} characters, got ${M}`,params:{limit:G}});if(H!==void 0&&M>H)X.push({path:$,code:"maxLength",message:`expected at most ${H} characters, got ${M}`,params:{limit:H}})}if(Y){let M=!1;try{M=Y.test(Z)===!0}catch{}if(!M)X.push({path:$,code:"format",message:`expected a string in format "${Y.name}"`,params:{format:Y.name}})}}function lQ(Q,Z,$,X){if(!Q)return;let G=(H,Y,M,K)=>{if(Y===void 0||M(Y))return;X.push({path:$,code:H,message:`expected ${K} ${Y}, got ${Z}`,params:{limit:Y}})};G("minimum",Q.minimum,(H)=>Z>=H,"at least"),G("exclusiveMinimum",Q.exclusiveMinimum,(H)=>Z>H,"more than"),G("maximum",Q.maximum,(H)=>Z<=H,"at most"),G("exclusiveMaximum",Q.exclusiveMaximum,(H)=>Z<H,"less than")}function Z0(Q,Z,$,X,G=!0){let H=(M)=>{$.push({path:Z,code:"type",message:`expected a JSON value, got ${M}`,params:{}})};switch(typeof Q){case"undefined":case"string":case"boolean":return;case"number":if(!Number.isFinite(Q))H(String(Q));return;case"bigint":return H("a bigint");case"function":return H("a function");case"symbol":return H("a symbol")}if(Q===null)return;let Y=Q;if(X.has(Y))return H("a circular reference");X.add(Y);try{let M=G?Y.toJSON:void 0;if(typeof M==="function"){let K;try{K=M.call(Y)}catch{return H("a toJSON that threw")}if(K===void 0)return H("a toJSON that returns undefined");return Z0(K,Z,$,X,!1)}if(Array.isArray(Q))Q.forEach((K,J)=>Z0(K,[...Z,J],$,X));else for(let[K,J]of Object.entries(Y))Z0(J,[...Z,K],$,X)}finally{X.delete(Y)}}function E(Q){return R0(Q)}function R0(Q){let Z={toJSONSchema:()=>yQ(Q),parse($){let X=[],G=v(Q,$,[],X);if(X.length>0)throw Error(X.map(w0).join("; "));return G.drop?void 0:G.value},safeParse($){let X=[],G=v(Q,$,[],X);if(X.length>0)return{ok:!1,errors:X.map(w0)};return{ok:!0,value:G.drop?void 0:G.value}},validate($){let X=[],G=v(Q,$,[],X);if(X.length>0)return{ok:!1,issues:X};return{ok:!0,value:G.drop?void 0:G.value}},describe:($)=>R0({...Q,description:$}),optional:()=>R0({...Q,optional:!0}),nullable:()=>R0({...Q,nullable:!0,optional:!1})};return j0.set(Z,Q),Z}function x(Q){return{node:Q,optional:!1,nullable:!1}}var e0=["strip","error","passthrough"];class XQ extends Error{problems;constructor(Q){super(`gemi/ai: s.fromJSONSchema cannot model this schema:
|
|
2
|
+
import{Jg as q,Kg as L0,Lg as _0}from"./chunk-1m3hvy3q.js";import{Og as b}from"./chunk-490sbcma.js";import{Ri as zQ}from"./chunk-g5ppst76.js";import{bj as Y0}from"./chunk-jg79n382.js";import{ij as mZ}from"./chunk-hm9cjxy2.js";class i0{static kind="controller";constructor(){}}class SQ extends i0{}function q0(Q){let Z=new Map;if(!Q)return Z;for(let $ of Q.split(";")){let X=$.indexOf("=");if(X===-1)continue;let G=$.slice(0,X).trim();if(!G)continue;Z.set(G,$.slice(X+1).trim())}return Z}function $1(Q){return q0(Q.headers.get("cookie"))}function p(Q){if(!/^\d+$/.test(Q))return null;let Z=Number(Q);return Number.isSafeInteger(Z)?Z:null}function n0(Q){if(!Q)return null;let Z=Q.trim();if(!/^bytes=/i.test(Z))return null;let X=Z.slice(6).split(",").map((D)=>D.trim()).filter((D)=>D!=="");if(X.length!==1)return null;let G=X[0],H=G.indexOf("-");if(H===-1)return null;let Y=G.slice(0,H),M=G.slice(H+1);if(Y===""){let D=p(M);if(D===null)return null;return{kind:"suffix",suffixLength:D}}let K=p(Y);if(K===null)return null;if(M==="")return{kind:"offset",start:K,end:null};let J=p(M);if(J===null||J<K)return null;return{kind:"offset",start:K,end:J}}function o0(Q,Z){if(!Number.isFinite(Z)||Z<=0)return null;let $,X;if(Q.kind==="suffix"){if(Q.suffixLength<=0)return null;$=Math.max(0,Z-Q.suffixLength),X=Z-1}else{if(Q.start>=Z)return null;if($=Q.start,X=Q.end===null?Z-1:Math.min(Q.end,Z-1),X<$)return null}return{start:$,end:X,length:X-$+1}}function G1(Q){if(Q.kind==="suffix")return`bytes=-${Q.suffixLength}`;return Q.end===null?`bytes=${Q.start}-`:`bytes=${Q.start}-${Q.end}`}function H1(Q){if(!Q)return null;let Z=/^bytes\s+(\d+)-(\d+)\/(\d+)$/i.exec(Q.trim());if(!Z)return null;let $=p(Z[1]),X=p(Z[2]),G=p(Z[3]);if($===null||X===null||G===null||X<$)return null;return{start:$,end:X,total:G}}function Y1(Q,Z,$){return`bytes ${Q}-${Z}/${$}`}function t0(Q){return`bytes */${Q}`}class s extends q{errors={};constructor(Q){super("Validation error");this.name="ValidationError",this.errors=Q,this.payload={api:{status:400,data:{error:{kind:"validation_error",messages:Q,status:400}},headers:{"Content-Type":"application/json"}},view:{status:400}}}}function xQ(Q){let[Z,$]=Q.match(/\d+|\D+/g)??[];if(!Z||!$)return 0;let X=Number.parseInt(Z);switch($){case"B":return X;case"KB":return X*1024;case"MB":return X*1024*1024;case"GB":return X*1024*1024*1024;case"TB":return X*1024*1024*1024*1024;default:return 0}}function kQ(Q){switch(Q){case"image":return"image";case"png":return"image/png";case"jpg":return"image/jpeg";case"jpeg":return"image/jpeg";case"ttf":return"font/ttf";case"excel":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case"csv":return"text/csv";case"word":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"pdf":return"application/pdf";case"json":return"application/json";default:return Q}}function s0(Q){if(typeof Q==="string"||Array.isArray(Q))return Q.length;return}function N0(Q){return typeof Q==="number"&&!Number.isNaN(Q)}var gQ=["required","string","boolean","number","email","password","min","max","gte","lte","file","fileType","fileSize","array","object","in"];class k extends Error{name="InvalidValidationRuleError"}function V0(Q,Z){let $=Z===void 0||Z.trim()===""?Number.NaN:Number(Z);if(Number.isNaN($))throw new k(`Validation rule "${Q}:${Z??""}" needs a number, e.g. "${Q}:3"`);return $}function a0(Q){let Z=Q.indexOf(":"),$=Z===-1?Q:Q.slice(0,Z),X=Z===-1?void 0:Q.slice(Z+1);switch($){case"required":return(G)=>{if(G instanceof Blob)return G.size>0;if(G===null||G===void 0)return!1;if(typeof G==="string"||Array.isArray(G))return G.length>0;return!0};case"string":return(G)=>typeof G==="string";case"boolean":return(G)=>typeof G==="boolean";case"number":return(G)=>N0(G);case"password":return(G)=>{return typeof G==="string"&&/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/.test(G)};case"min":{let G=V0($,X);return(H)=>{let Y=s0(H);return Y!==void 0&&Y>=G}}case"max":{let G=V0($,X);return(H)=>{let Y=s0(H);return Y!==void 0&&Y<=G}}case"gte":{let G=V0($,X);return(H)=>N0(H)&&H>=G}case"lte":{let G=V0($,X);return(H)=>N0(H)&&H<=G}case"email":return(G)=>{return typeof G==="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(G)};case"file":return(G)=>{return G instanceof Blob};case"fileType":{if(!X)throw new k('Validation rule "fileType" needs a type, e.g. "fileType:png" or "fileType:image"');let G=kQ(X);return(H)=>H instanceof Blob&&H.type.startsWith(G)}case"fileSize":{let G=xQ(X??"");if(G===0&&!/^0+(B|KB|MB|GB|TB)$/.test(X??""))throw new k(`Validation rule "fileSize:${X??""}" needs a whole size in B, KB, MB, GB or TB, e.g. "fileSize:5MB"`);return(H)=>H instanceof Blob&&H.size<=G}case"array":return(G)=>Array.isArray(G);case"object":return(G)=>typeof G==="object"&&G!==null&&!Array.isArray(G)&&!(G instanceof Blob);case"in":{let G=(X??"").split(",").filter((H)=>H!=="");if(G.length===0)throw new k('Validation rule "in" needs a comma-separated list, e.g. "in:draft,published"');return(H)=>typeof H==="string"&&G.includes(H)}default:throw new k(`Unknown validation rule "${Q}". Known rules: ${gQ.join(", ")}`)}}function u(Q){if(!Q.definition)throw Error(`gemi/ai: the recursive schema "${Q.name}" was used before its definition returned; \`self\` can be nested into the schema, but not parsed or emitted inside the callback`);return Q.definition}var j0=new WeakMap;function QQ(Q){return typeof Q==="object"&&Q!==null&&j0.has(Q)}function U0(Q){let Z=j0.get(Q);if(!Z)throw Error("gemi/ai: expected a schema built with `s`, got a foreign object");return Z}function yQ(Q){let Z={defs:{},cells:new Map},$=Q;if(Q.node.kind==="ref"){let G=u(Q.node.cell);$={...G,...Q.description?{description:Q.description}:{},optional:Q.optional,nullable:Q.nullable||G.nullable}}let X=r($,Z);return Object.keys(Z.defs).length>0?{...X,$defs:Z.defs}:X}function r(Q,Z){let $=(Q.optional||Q.nullable)&&Q.node.kind!=="json",X=vQ(fQ(Q.node,Z),$),G=[Q.description,bQ(Q.node)].filter(Boolean).join(" ");if(G&&X.$ref!==void 0)X={anyOf:[X]};return G?{description:G,...X}:X}function bQ(Q){let Z=[];if(Q.kind==="string"||Q.kind==="enum"){let $=Q.checks;if($?.format)Z.push(`Format: ${$.format.name}.`);if($?.minLength!==void 0)Z.push(`At least ${$.minLength} characters.`);if($?.maxLength!==void 0)Z.push(`At most ${$.maxLength} characters.`)}else if(Q.kind==="number"){let $=Q.checks;if($?.minimum!==void 0)Z.push(`Minimum ${$.minimum}.`);if($?.exclusiveMinimum!==void 0)Z.push(`Greater than ${$.exclusiveMinimum}.`);if($?.maximum!==void 0)Z.push(`Maximum ${$.maximum}.`);if($?.exclusiveMaximum!==void 0)Z.push(`Less than ${$.exclusiveMaximum}.`)}else if(Q.kind==="array"){let $=Q.checks;if($?.minItems!==void 0)Z.push(`At least ${$.minItems} items.`);if($?.maxItems!==void 0)Z.push(`At most ${$.maxItems} items.`)}return Z.join(" ")}function fQ(Q,Z){switch(Q.kind){case"string":return{type:"string"};case"number":return{type:Q.checks?.integer?"integer":"number"};case"boolean":return{type:"boolean"};case"literal":return{type:typeof Q.value,const:Q.value};case"enum":return{type:"string",enum:Q.values};case"array":return{type:"array",items:r(Q.item,Z)};case"object":return{type:"object",properties:Object.fromEntries(Object.entries(Q.shape).map(([$,X])=>[$,r(X,Z)])),required:Object.keys(Q.shape),additionalProperties:!1};case"union":return{anyOf:Q.members.map(($)=>r($,Z))};case"json":return{};case"ref":{let{cell:$}=Q,X=Z.cells.get($.name);if(X&&X!==$)throw Error(`gemi/ai: two different recursive schemas are named "${$.name}" in one schema; give each s.recursive(...) its own name`);if(!X)Z.cells.set($.name,$),Z.defs[$.name]={},Z.defs[$.name]=r(u($),Z);return{$ref:`#/$defs/${$.name}`}}}}function vQ(Q,Z){if(!Z)return Q;if(Q.anyOf)return{...Q,anyOf:[...Q.anyOf,{type:"null"}]};if(Q.enum||Q.const!==void 0)return{anyOf:[Q,{type:"null"}]};if(typeof Q.type==="string")return{...Q,type:[Q.type,"null"]};return{anyOf:[Q,{type:"null"}]}}function hQ(Q){if(Q===null)return"null";if(Array.isArray(Q))return"array";return typeof Q}function mQ(Q,Z){if(typeof Z==="number"&&!Number.isFinite(Z))return String(Z);if(Q.kind==="literal"||Q.kind==="enum"){if(typeof Z==="string"||typeof Z==="number"||typeof Z==="boolean")return JSON.stringify(Z)}return hQ(Z)}function ZQ(Q){let Z=Q.node,$=(()=>{switch(Z.kind){case"number":return Z.checks?.integer?"integer":"number";case"string":case"boolean":return Z.kind;case"literal":return JSON.stringify(Z.value);case"enum":return`one of ${Z.values.map((X)=>JSON.stringify(X)).join(" | ")}`;case"array":return"array";case"object":return"object";case"union":return"one of the variants";case"json":return"a JSON value";case"ref":return ZQ({...u(Z.cell),optional:!1,nullable:!1})}})();return Q.optional||Q.nullable?`${$} or null`:$}function cQ(Q){let Z="";for(let $ of Q)Z+=typeof $==="number"?`[${$}]`:Z?`.${$}`:$;return Z}function pQ(Q){let Z=cQ(Q);return Z?`${Z}: `:""}function w0(Q){return`${pQ(Q.path)}${Q.message}`}function B0(Q,Z){if(Z===null||Z===void 0)return Q.optional||Q.nullable?1:0;let $=Q.node;switch($.kind){case"string":return typeof Z==="string"?1:0;case"number":return typeof Z==="number"?1:0;case"boolean":return typeof Z==="boolean"?1:0;case"literal":return Z===$.value?10:0;case"enum":return typeof Z==="string"&&$.values.includes(Z)?10:0;case"array":return Array.isArray(Z)?1:0;case"object":{if(typeof Z!=="object"||Array.isArray(Z))return 0;let X=Z,G=1;for(let[H,Y]of Object.entries($.shape))G+=B0(Y,X[H]);return G}case"union":return $.members.reduce((X,G)=>Math.max(X,B0(G,Z)),0);case"json":return 1;case"ref":return $Q($.cell,Z,()=>1,()=>B0(u($.cell),Z))}}function $Q(Q,Z,$,X){if(typeof Z!=="object"||Z===null)return X();if(Q.active.has(Z))return $();Q.active.add(Z);try{return X()}finally{Q.active.delete(Z)}}function v(Q,Z,$,X){if(Q.optional&&(Z===null||Z===void 0))return{drop:!0,value:void 0};if(Q.nullable&&Z===null)return{drop:!1,value:null};return{drop:!1,value:uQ(Q,Z,$,X)}}function uQ(Q,Z,$,X){let G=Q.node,H=()=>{let Y=Z===void 0?"required":G.kind==="literal"?"const":G.kind==="enum"&&typeof Z==="string"?"enum":"type",M=Y==="const"?{allowedValue:G.value}:Y==="enum"?{allowedValues:G.values}:{};X.push({path:$,code:Y,message:`expected ${ZQ(Q)}, got ${mQ(G,Z)}`,params:M});return};switch(G.kind){case"string":if(typeof Z!=="string")return H();return r0(G.checks,Z,$,X),Z;case"number":if(typeof Z!=="number"||!Number.isFinite(Z))return H();if(G.checks?.integer&&!Number.isInteger(Z))return H();return lQ(G.checks,Z,$,X),Z;case"boolean":return typeof Z==="boolean"?Z:H();case"literal":return Z===G.value?Z:H();case"enum":if(typeof Z!=="string"||!G.values.includes(Z))return H();return r0(G.checks,Z,$,X),Z;case"array":{if(!Array.isArray(Z))return H();let Y=Z.map((J,D)=>{let V=v(G.item,J,[...$,D],X);return V.drop?void 0:V.value}),{minItems:M,maxItems:K}=G.checks??{};if(M!==void 0&&Z.length<M)X.push({path:$,code:"minItems",message:`expected at least ${M} items, got ${Z.length}`,params:{limit:M}});if(K!==void 0&&Z.length>K)X.push({path:$,code:"maxItems",message:`expected at most ${K} items, got ${Z.length}`,params:{limit:K}});return Y}case"object":{if(typeof Z!=="object"||Z===null||Array.isArray(Z))return H();let Y=Z,M={};for(let[K,J]of Object.entries(G.shape)){let D=v(J,Y[K],[...$,K],X);if(!D.drop)M[K]=D.value}if(G.unknownKeys)for(let K of Object.keys(Y)){if(Object.hasOwn(G.shape,K)||Y[K]===void 0)continue;if(G.unknownKeys==="error"){X.push({path:[...$,K],code:"additionalProperties",message:"unknown key",params:{additionalProperty:K}});continue}Z0(Y[K],[...$,K],X,new Set),Object.defineProperty(M,K,{value:Y[K],enumerable:!0,writable:!0,configurable:!0})}return M}case"union":{let Y;for(let M of G.members){let K=[],J=v(M,Z,$,K);if(K.length===0)return J.drop?void 0:J.value;let D=B0(M,Z);if(!Y||D>Y.score)Y={issues:K,score:D}}X.push({path:$,code:"anyOf",message:`no matching variant; closest: ${Y.issues.map(w0).join("; ")}`,params:{closest:Y.issues}});return}case"json":if(Z===void 0)return H();return Z0(Z,$,X,new Set),Z;case"ref":return $Q(G.cell,Z,()=>{X.push({path:$,code:"type",message:"expected a finite tree, got a circular reference",params:{}});return},()=>v(u(G.cell),Z,$,X).value)}}function dQ(Q){let Z=0;for(let $ of Q)Z++;return Z}function r0(Q,Z,$,X){if(!Q)return;let{minLength:G,maxLength:H,format:Y}=Q;if(G!==void 0||H!==void 0){let M=dQ(Z);if(G!==void 0&&M<G)X.push({path:$,code:"minLength",message:`expected at least ${G} characters, got ${M}`,params:{limit:G}});if(H!==void 0&&M>H)X.push({path:$,code:"maxLength",message:`expected at most ${H} characters, got ${M}`,params:{limit:H}})}if(Y){let M=!1;try{M=Y.test(Z)===!0}catch{}if(!M)X.push({path:$,code:"format",message:`expected a string in format "${Y.name}"`,params:{format:Y.name}})}}function lQ(Q,Z,$,X){if(!Q)return;let G=(H,Y,M,K)=>{if(Y===void 0||M(Y))return;X.push({path:$,code:H,message:`expected ${K} ${Y}, got ${Z}`,params:{limit:Y}})};G("minimum",Q.minimum,(H)=>Z>=H,"at least"),G("exclusiveMinimum",Q.exclusiveMinimum,(H)=>Z>H,"more than"),G("maximum",Q.maximum,(H)=>Z<=H,"at most"),G("exclusiveMaximum",Q.exclusiveMaximum,(H)=>Z<H,"less than")}function Z0(Q,Z,$,X,G=!0){let H=(M)=>{$.push({path:Z,code:"type",message:`expected a JSON value, got ${M}`,params:{}})};switch(typeof Q){case"undefined":case"string":case"boolean":return;case"number":if(!Number.isFinite(Q))H(String(Q));return;case"bigint":return H("a bigint");case"function":return H("a function");case"symbol":return H("a symbol")}if(Q===null)return;let Y=Q;if(X.has(Y))return H("a circular reference");X.add(Y);try{let M=G?Y.toJSON:void 0;if(typeof M==="function"){let K;try{K=M.call(Y)}catch{return H("a toJSON that threw")}if(K===void 0)return H("a toJSON that returns undefined");return Z0(K,Z,$,X,!1)}if(Array.isArray(Q))Q.forEach((K,J)=>Z0(K,[...Z,J],$,X));else for(let[K,J]of Object.entries(Y))Z0(J,[...Z,K],$,X)}finally{X.delete(Y)}}function E(Q){return R0(Q)}function R0(Q){let Z={toJSONSchema:()=>yQ(Q),parse($){let X=[],G=v(Q,$,[],X);if(X.length>0)throw Error(X.map(w0).join("; "));return G.drop?void 0:G.value},safeParse($){let X=[],G=v(Q,$,[],X);if(X.length>0)return{ok:!1,errors:X.map(w0)};return{ok:!0,value:G.drop?void 0:G.value}},validate($){let X=[],G=v(Q,$,[],X);if(X.length>0)return{ok:!1,issues:X};return{ok:!0,value:G.drop?void 0:G.value}},describe:($)=>R0({...Q,description:$}),optional:()=>R0({...Q,optional:!0}),nullable:()=>R0({...Q,nullable:!0,optional:!1})};return j0.set(Z,Q),Z}function x(Q){return{node:Q,optional:!1,nullable:!1}}var e0=["strip","error","passthrough"];class XQ extends Error{problems;constructor(Q){super(`gemi/ai: s.fromJSONSchema cannot model this schema:
|
|
3
3
|
${Q.map((Z)=>`- ${Z}`).join(`
|
|
4
4
|
`)}`);this.name="JSONSchemaError",this.problems=Q}}var iQ=new Set(["title","$schema","$id","$comment","examples","default","deprecated","readOnly","writeOnly"]),a={string:["minLength","maxLength","format"],number:["minimum","maximum","exclusiveMinimum","exclusiveMaximum"],integer:["minimum","maximum","exclusiveMinimum","exclusiveMaximum"],boolean:[],object:["properties","required","additionalProperties"],array:["items","minItems","maxItems"]};function z0(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function P0(Q,Z,$,X){let G=(W,U=$)=>{X.push(U?`${U}: ${W}`:W);return},H=(W)=>$?`${$}.${W}`:W;if(!z0(Q))return G("expected a schema object");let Y=new Set(Z.ignoreKeywords??[]),M=(W)=>iQ.has(W)||W.startsWith("x-")||Y.has(W),K=!1,J=Q.type;if(Array.isArray(J)){let W=J.filter((U)=>U!=="null");if(W.length!==1)return G(`type ${JSON.stringify(J)} is not supported; only one type, optionally with "null". Use anyOf for alternatives`,H("type"));K=W.length<J.length,J=W[0]}if(J!==void 0&&(typeof J!=="string"||!(J in a)))return G(`type ${JSON.stringify(J)} is not supported; expected one of ${Object.keys(a).join(", ")}`,H("type"));let D=new Set(["type","description","enum","const","anyOf",...J?a[J]:[]]),V=!1;for(let W of Object.keys(Q)){if(D.has(W)||M(W))continue;V=!0;let U=Object.entries(a).find(([,z])=>z.includes(W));G(U&&U[0]!==J?`"${W}" applies to type ${U[0]}, and this schema is ${J?`type ${J}`:"untyped"}`:`"${W}" is not supported by s.fromJSONSchema`,H(W))}if(V)return;if(Q.description!==void 0&&typeof Q.description!=="string")return G("expected a string",H("description"));let O=Q.description,B=(W)=>({node:W,optional:!1,nullable:K,...O?{description:O}:{}});if(Q.anyOf!==void 0){if(J!==void 0||Q.enum!==void 0||Q.const!==void 0)return G("anyOf cannot be combined with type, enum or const here",H("anyOf"));if(!Array.isArray(Q.anyOf)||Q.anyOf.length===0)return G("expected a non-empty array",H("anyOf"));let W=[],U=!1;if(Q.anyOf.forEach((z,R)=>{if(z0(z)&&z.type==="null"&&Object.keys(z).length===1){K=!0;return}let F=P0(z,Z,H(`anyOf[${R}]`),X);if(F)W.push(F);else U=!0}),U)return;if(W.length===0)return G("anyOf has only null in it",H("anyOf"));if(W.length===1){let z=W[0];return{...z,nullable:z.nullable||K,...O?{description:O}:{}}}return B({kind:"union",members:W})}if(Q.const!==void 0){let W=Q.const;if(typeof W!=="string"&&typeof W!=="number"&&typeof W!=="boolean")return G("only a string, number or boolean const is supported",H("const"));if(J!==void 0&&typeof W!==(J==="integer"?"number":J))return G(`const ${JSON.stringify(W)} is not of type ${J}`,H("const"));return B({kind:"literal",value:W})}let L;if(J==="string"){if(L=nQ(Q,Z,H,X),L===null)return}if(Q.enum!==void 0){if(!Array.isArray(Q.enum)||Q.enum.length===0)return G("expected a non-empty array",H("enum"));let W=Q.enum.filter((R)=>R!==null);if(W.length<Q.enum.length)K=!0;let U=W.find((R)=>!(typeof R==="string"||typeof R==="number"||typeof R==="boolean")||J!==void 0&&typeof R!==(J==="integer"?"number":J));if(U!==void 0||W.length===0)return G(J?`every value must be of type ${J}${W.length===0?", and there must be one":`; ${JSON.stringify(U)} is not`}`:"only strings, numbers and booleans are supported",H("enum"));if(W.every((R)=>typeof R==="string"))return B({kind:"enum",values:[...new Set(W)],...L?{checks:L}:{}});let z=[...new Set(W)];if(z.length===1)return B({kind:"literal",value:z[0]});return B({kind:"union",members:z.map((R)=>x({kind:"literal",value:R}))})}switch(J){case void 0:return G("a schema needs a type, an enum, a const or an anyOf");case"string":return B({kind:"string",...L?{checks:L}:{}});case"number":case"integer":{let W=J==="integer"?{integer:!0}:{},U=!1;for(let z of a.number){let R=Q[z];if(R===void 0)continue;if(typeof R!=="number"||!Number.isFinite(R)){G("expected a number",H(z)),U=!0;continue}W[z]=R}if(U)return;return B({kind:"number",...Object.keys(W).length>0?{checks:W}:{}})}case"boolean":return B({kind:"boolean"});case"array":{if(!z0(Q.items))return G('an array needs "items" to be one schema (tuples are not supported)',H("items"));let W={},U=!1;for(let R of["minItems","maxItems"]){let F=Q[R];if(F===void 0)continue;if(typeof F!=="number"||!Number.isInteger(F)||F<0){G("expected a non-negative integer",H(R)),U=!0;continue}W[R]=F}let z=P0(Q.items,Z,H("items"),X);if(!z||U)return;return B({kind:"array",item:z,...Object.keys(W).length>0?{checks:W}:{}})}case"object":{let W=Q.properties??{};if(!z0(W))return G("expected an object",H("properties"));if(Q.additionalProperties!==void 0&&Q.additionalProperties!==!1)return G("only false is supported; a record with arbitrary keys has no strict-mode form (use s.json())",H("additionalProperties"));let U=Q.required??[];if(!Array.isArray(U)||!U.every((T)=>typeof T==="string"))return G("expected an array of property names",H("required"));let z=U.filter((T)=>!Object.hasOwn(W,T));if(z.length>0)return G(`lists properties the schema doesn't have: ${z.join(", ")}`,H("required"));let R={},F=!1;for(let[T,C]of Object.entries(W)){let j=P0(C,Z,H(`properties.${T}`),X);if(!j){F=!0;continue}R[T]=U.includes(T)?j:{...j,optional:!0}}if(F)return;let I=Z.unknownKeys;return B({kind:"object",shape:R,...I==="error"||I==="passthrough"?{unknownKeys:I}:{}})}}return}function nQ(Q,Z,$,X){let G={},H=!1;for(let Y of["minLength","maxLength"]){let M=Q[Y];if(M===void 0)continue;if(typeof M!=="number"||!Number.isInteger(M)||M<0){X.push(`${$(Y)}: expected a non-negative integer`),H=!0;continue}G[Y]=M}if(Q.format!==void 0){let Y=Q.format,M=typeof Y==="string"?Z.formats?.[Y]:void 0;if(typeof Y!=="string")X.push(`${$("format")}: expected a string`),H=!0;else if(!M||!Object.hasOwn(Z.formats,Y))X.push(`${$("format")}: unknown format ${JSON.stringify(Y)}; pass a check for it in the formats option`),H=!0;else G.format={name:Y,test:oQ(M)}}if(H)return null;return Object.keys(G).length>0?G:void 0}function oQ(Q){if(Q===!0)return()=>!0;if(Q instanceof RegExp)return(Z)=>{return Q.lastIndex=0,Q.test(Z)};return Q}var D1={string:()=>E(x({kind:"string"})),number:()=>E(x({kind:"number"})),boolean:()=>E(x({kind:"boolean"})),literal:(Q)=>E(x({kind:"literal",value:Q})),enum:(Q)=>E(x({kind:"enum",values:Q})),object:(Q)=>E(x({kind:"object",shape:Object.fromEntries(Object.entries(Q).map(([Z,$])=>[Z,U0($)]))})),array:(Q)=>E(x({kind:"array",item:U0(Q)})),union:(Q)=>E(x({kind:"union",members:Q.map(U0)})),json:()=>E(x({kind:"json"})),recursive:sQ,fromJSONSchema:(Q,Z={})=>{let $=[];if(Z.unknownKeys!==void 0&&!e0.includes(Z.unknownKeys))throw Error(`gemi/ai: s.fromJSONSchema's unknownKeys option must be one of ${e0.map((G)=>JSON.stringify(G)).join(", ")}, got ${JSON.stringify(Z.unknownKeys)}`);let X=P0(Q,Z,"",$);if(!X||$.length>0)throw new XQ($.length>0?$:["unreadable schema"]);return E(X)}};function V1(Q){let Z=j0.get(Q);if(Z)return Q0(Z.node);return e(Q.toJSONSchema())}function e(Q){if(!(Q.$ref!==void 0||Q.type!==void 0||Q.enum!==void 0||Q.const!==void 0||Q.anyOf!==void 0||Q.properties!==void 0||Q.items!==void 0))return!1;for(let $ of Object.values(Q.properties??{}))if(!e($))return!1;if(Q.items&&!e(Q.items))return!1;for(let $ of Q.anyOf??[])if(!e($))return!1;for(let $ of Object.values(Q.$defs??{}))if(!e($))return!1;return!0}function Q0(Q,Z=new Set){switch(Q.kind){case"string":case"number":case"boolean":case"literal":case"enum":return!0;case"object":return Object.values(Q.shape).every(($)=>Q0($.node,Z));case"array":return Q0(Q.item.node,Z);case"union":return Q.members.every(($)=>Q0($.node,Z));case"json":return!1;case"ref":if(Z.has(Q.cell))return!0;return Z.add(Q.cell),Q0(u(Q.cell).node,Z)}}function E0(Q,Z,$=new Set){let X=Q.node;if(X.kind==="union")return X.members.some((G)=>E0(G,Z,$));if(X.kind!=="ref")return!1;if(X.cell===Z)return!0;if($.has(X.cell)||!X.cell.definition)return!1;return $.add(X.cell),E0(X.cell.definition,Z,$)}var tQ=/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/;function sQ(Q,Z){if(typeof Q!=="string"||!tQ.test(Q))throw Error(`gemi/ai: s.recursive needs a name of letters, digits, "_" and "-" (starting with a letter or "_", at most 64), got ${JSON.stringify(Q)}`);let $={name:Q,active:new Set},X=()=>x({kind:"ref",cell:$}),G=U0(Z(E(X())));if(G.optional)throw Error(`gemi/ai: the recursive schema "${Q}" is optional() as a whole; mark the places that use it optional instead`);if(E0(G,$))throw Error(`gemi/ai: the recursive schema "${Q}" refers to itself outside any object or array, so it describes no finite value; nest \`self\` in an s.object(...) field or an s.array(...)`);return $.definition=G,E(X())}function GQ(Q){if(typeof Q!=="string")return null;let[Z]=Q.split(";",1),$=Z.trim().toLowerCase();return $===""?null:$}function HQ(Q){if(Q===null)return!1;if(Q==="application/json")return!0;let Z=Q.indexOf("/");return Z>0&&Q.endsWith("+json")&&Q.length>Z+1+5}var $0=new WeakMap;function B1(Q,Z,$,X){$0.set(Q,{clientAddress:Z,...$?{grant:Object.freeze({...$,scopes:Object.freeze([...$.scopes])})}:{},...X?{progress:X}:{}})}function YQ(Q){return $0.get(Q)?.progress}function MQ(Q){return $0.get(Q)?.grant}function KQ(Q){return $0.has(Q)}function R1(Q){return $0.get(Q)?.clientAddress}var JQ=new WeakMap;function j1(Q,Z){JQ.set(Q,Z)}function WQ(Q){return JQ.get(Q)??null}var S0=new WeakMap;function L1(Q,Z){let $=S0.get(Q)??[];if(!$.includes(Z))S0.set(Q,[...$,Z])}function _1(Q){return S0.get(Q)??[]}class d{data;constructor(Q){this.data=Q}get(Q){return this.data[Q]}has(Q){return this.data[Q]!==void 0}toJSON(){return this.data}}function DQ(Q){return typeof Q==="object"&&Q!==null&&!(Q instanceof Blob)}function aQ(Q,Z){if(!Z.includes(".")||Object.hasOwn(Q,Z))return[{path:[Z],value:Q[Z]}];let $=[{path:[],value:Q}];for(let X of Z.split(".")){let G=[];for(let{path:H,value:Y}of $){if(X==="*"){if(Array.isArray(Y))Y.forEach((M,K)=>G.push({path:[...H,K],value:M}));else if(DQ(Y))for(let[M,K]of Object.entries(Y))G.push({path:[...H,M],value:K});continue}if(Array.isArray(Y)&&/^\d+$/.test(X)){G.push({path:[...H,Number(X)],value:Y[Number(X)]});continue}G.push({path:[...H,X],value:DQ(Y)&&Object.hasOwn(Y,X)?Y[X]:void 0})}$=G}return $}function VQ(Q){return Q.join(".")}class rQ{kind;rawRequest;headers;cookies;search;schema={};routePath;params;domain;constructor(Q,Z,$,X){if(!Q){let K=b.getStore().req;this.params=K.params,this.rawRequest=K.rawRequest,this.kind=K.kind,this.routePath=K.routePath,this.domain=K.domain??null}else this.params=Z,this.rawRequest=Q,this.routePath=X,this.kind=$??"api",this.domain=WQ(Q);this.headers=this.rawRequest.headers;let G=q0(this.rawRequest.headers.get("Cookie")),H=new URL(this.rawRequest.url),Y=new Map;for(let[K,J]of H.searchParams)if(Y.has(K)){let D=Y.get(K);if(Array.isArray(D))D.push(J),Y.set(K,D);else Y.set(K,[D,J])}else Y.set(K,J);let M=Object.fromEntries(Y.entries());this.search=new d(M),this.cookies=G}locale(){return b.getStore().locale}ctx(){return b.getStore()}isModelOriginated(){return KQ(this.rawRequest)}mcpGrant(){return MQ(this.rawRequest)??null}reportProgress(Q){let Z=YQ(this.rawRequest);if(!Z)return!1;return Z(Q),!0}get signal(){return this.rawRequest.signal}range(){return n0(this.rawRequest.headers.get("Range"))}refine(Q){return{}}async parseBody(){let Q=GQ(this.rawRequest.headers.get("Content-Type"));if(HQ(Q))return new d(await this.parseJsonBody());if(Q==="application/x-www-form-urlencoded"||Q==="multipart/form-data"){let Z;try{Z=await this.rawRequest.formData()}catch(X){if(X instanceof q)throw X;throw new q("The request body could not be read as a form.")}let $=new Map;for(let[X,G]of Z.entries())if($.has(X)){let H=$.get(X);if(Array.isArray(H))H.push(G);else $.set(X,[H,G])}else $.set(X,G);return new d(Object.fromEntries($.entries()))}return new d({})}async parseJsonBody(){if(!this.rawRequest.body)return{};let Q;try{Q=await this.rawRequest.text()}catch($){if($ instanceof q)throw $;throw new q("The request body could not be read.")}if(Q.trim()==="")return{};let Z;try{Z=JSON.parse(Q)}catch{throw new q("The request body is not valid JSON.")}if(Z===null||typeof Z!=="object")throw new q("The request body must be a JSON object.");return Z}validateInput(Q){if(QQ(this.schema))return this.validateWithSchema(Q);let Z=Q.toJSON()??{},$={},X=Object.entries(this.schema).map(([G,H])=>({key:G,rules:Object.entries(H).map(([Y,M])=>({rule:Y,message:M,check:typeof M==="function"?null:this.ruleFor(G,Y)}))}));for(let{key:G,rules:H}of X)for(let{path:Y,value:M}of aQ(Z,G)){let K=this.checkField(M,H);if(K.length>0){let J=$[VQ(Y)]??=[];for(let D of K)if(!J.includes(D))J.push(D)}}if(this.addRefinements($,Z),Object.keys($).length>0)throw new s($);return Q}checkField(Q,Z){let $=Z.some(({rule:H})=>H==="required"),X=Q===void 0||Q===null||Q==="",G=[];for(let{rule:H,message:Y,check:M}of Z){let K=Y,J=!1;if(typeof Y==="function")K=Y(Q),J=typeof K>"u";else J=M(Q);if(J)continue;if(X&&!$)continue;if(H==="required")return[String(K)];if(!G.includes(String(K)))G.push(String(K))}return G}validateWithSchema(Q){let Z=this.schema.validate(Q.toJSON()),$={};if("issues"in Z)for(let G of Z.issues){let H=VQ(G.path),Y=$[H]??=[];if(!Y.includes(G.message))Y.push(G.message)}let X="value"in Z?new d(Z.value):Q;if(this.addRefinements($,X.toJSON()),Object.keys($).length>0)throw new s($);return X}addRefinements(Q,Z){for(let[$,X]of Object.entries(this.refine(Z)??{})){let G=Q[$]??[];Q[$]=G.includes(X)?G:[...G,X]}}ruleFor(Q,Z){try{return a0(Z)}catch($){if($ instanceof k)throw new k(`${this.constructor.name}.schema.${Q}: ${$.message}`);throw $}}async input(){return this.validateInput(await this.parseBody())}async safeInput(){let Q=await this.parseBody();try{return{isValid:!0,errors:{},input:this.validateInput(Q)}}catch(Z){if(!(Z instanceof s))throw Z;return{isValid:!1,errors:Z.errors,input:Q}}}}class eQ extends q{error;constructor(Q="Not authorized"){super(Q);this.name="AuthorizationError",this.error=Q,this.payload={api:{status:401,data:{error:_0("authorization",this.error,401)}},view:{}}}}class x0 extends q{static apiStatus=403;error;constructor(Q="Insufficient permissions"){super(Q);this.name="InsufficientPermissionsError",this.error=Q,this.payload={api:{status:x0.apiStatus,data:{error:_0("permission",this.error,x0.apiStatus)}},view:{status:403}}}}class k0 extends q{total;constructor(Q){super("Range not satisfiable");this.total=Q;this.name="RangeNotSatisfiableError",this.payload={api:{status:416,data:{error:L0("range_not_satisfiable","Range not satisfiable",416)},headers:{"Content-Range":t0(Q),"Accept-Ranges":"bytes","Cache-Control":"no-store"}},view:{}}}}class QZ extends q{constructor(Q="Not found"){super(Q);this.name="NotFoundError",this.payload={api:{status:404,data:{error:L0("not_found",Q,404)},headers:{"Cache-Control":"no-store"}},view:{status:404}}}}class h extends q{fileName;constructor(Q){super("File not found");this.fileName=Q;this.name="FileNotFoundError",this.payload={api:{status:404,data:{error:L0("not_found","Not found",404)},headers:{"Cache-Control":"no-store"}},view:{status:404}}}}class ZZ extends q{constructor(Q={}){super("Authentication error");this.name="AuthenticationError";let Z=Q.redirectTo??"/auth/sign-in";this.payload={api:{status:401,data:{error:_0("authentication","Authentication error",401)}},viewData:{status:200,data:{},headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate"},directive:{kind:"Redirect",path:Z}},view:{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:Z}}}}}class X0{static getFacadeAccessor(){throw Error(`Facade [${this.name}] does not implement getFacadeAccessor().`)}static getFacadeRoot(){return zQ(this.getFacadeAccessor())}}import{Buffer as $Z}from"buffer";function C0(Q){if(typeof Q!=="string"||/^[\s/.]*$/.test(Q))throw Error(`Refusing to delete by prefix ${JSON.stringify(Q)}: it would match the whole store`)}class G0{async putStream({body:Q,...Z},$={}){$.signal?.throwIfAborted();let X=[],G=Q.getReader();try{for(;;){$.signal?.throwIfAborted();let{done:H,value:Y}=await G.read();if(H)break;X.push(Y)}}catch(H){throw await G.cancel(H).catch(()=>{}),H}return this.put({...Z,body:$Z.concat(X)},$)}async*objects(Q,Z={}){throw Error(`${this.constructor.name} does not implement objects(). Override it to list objects in this backend.`)}async deletePrefix(Q,Z={}){C0(Q);let $=[];for await(let X of this.objects(Q,Z))$.push(X.name);for(let X of $)Z.signal?.throwIfAborted(),await this.delete({name:X,bucket:Z.bucket});return $.length}async delete(Q){throw Error(`${this.constructor.name} does not implement delete(). Override it to remove objects from this backend.`)}async read(Q){let Z=typeof Q==="string"?{name:Q}:Q,$=await this.fetch({name:Z.name,bucket:Z.bucket});if(!$.ok)throw new h(Z.name);let X=$.headers.get("Content-Type")??"application/octet-stream",G=$.headers.get("ETag")??void 0,H=$.headers.get("Last-Modified"),Y=H?new Date(H):void 0;if(Z.range){let J=await $.blob();return{body:J,start:0,end:J.size-1,total:J.size,partial:!1,type:X,etag:G,lastModified:Y,name:Z.name}}let M=Number($.headers.get("Content-Length")),K=Number.isFinite(M)?M:0;return{body:$.body,start:0,end:K-1,total:K,partial:!1,type:X,etag:G,lastModified:Y,name:Z.name}}async size(Q){let Z=typeof Q==="string"?Q:Q.name,$=typeof Q==="string"?void 0:Q.bucket,X=await this.fetch({name:Z,bucket:$});if(!X.ok)throw new h(Z);let G=Number(X.headers.get("Content-Length"));if(Number.isFinite(G))return await X.body?.cancel(),G;return(await X.blob()).size}}function UQ(Q,Z){if(!Z)return Q;let $=Q.getReader(),X=!1,G,H=()=>{if(X=!0,G)Z.removeEventListener("abort",G)};return new ReadableStream({start(Y){if(G=()=>{if(X)return;H(),Y.error(Z.reason),$.cancel(Z.reason).catch(()=>{})},Z.aborted)G();else Z.addEventListener("abort",G,{once:!0})},async pull(Y){let M;try{M=await $.read()}catch(K){if(X)return;H(),Y.error(K);return}if(X)return;if(M.done){H(),Y.close();return}Y.enqueue(M.value)},cancel(Y){return H(),$.cancel(Y)}},{highWaterMark:0})}import{mkdir as XZ,open as GZ,readdir as g0,rename as HZ,rmdir as YZ,stat as MZ,unlink as BQ}from"fs/promises";import{dirname as KZ,isAbsolute as y0,relative as H0,resolve as l,sep as f}from"path";class b0 extends G0{configured;constructor(Q){super();this.configured=Q}get folderPath(){return this.configured??`${Y0()}/storage`}async put(Q,{signal:Z}={}){Z?.throwIfAborted();let $,X;if(Q instanceof Blob)$=Q,X=`${Bun.randomUUIDv7()}.${Q.type.split("/")[1].split(";")[0]}`;else $=Q.body,X=Q.name;let G=$ instanceof Buffer?$:$ instanceof Blob||$ instanceof File?Buffer.from(await $.arrayBuffer()):"",H=`${this.folderPath}/${X}`;return Z?.throwIfAborted(),await Bun.write(H,G),X}async putStream({name:Q,body:Z},{signal:$}={}){let X=Z.getReader(),G=null;try{if($?.throwIfAborted(),!Q)throw Error("Object name has to be specified");let H=l(this.folderPath),Y=l(H,Q),M=H0(H,Y);if(!M||M===".."||M.startsWith(`..${f}`)||y0(M))throw Error(`Refusing to write "${Q}": it is outside the storage folder`);await XZ(KZ(Y),{recursive:!0}),G=`${Y}.${Bun.randomUUIDv7()}.partial`;let K=await GZ(G,"wx");try{for(;;){$?.throwIfAborted();let{done:J,value:D}=await X.read();if(J)break;for(let V=0;V<D.byteLength;){let{bytesWritten:O}=await K.write(D,V);V+=O}}}finally{await K.close()}return $?.throwIfAborted(),await HZ(G,Y),Q}catch(H){if(await X.cancel(H).catch(()=>{}),G)await BQ(G).catch(()=>{});throw H}}async fetch(Q,{signal:Z}={}){Z?.throwIfAborted();let $=process.env.BUCKET_NAME,X;if(typeof Q==="string")X=Q;else $=Q.bucket??$,X=Q.name;if(!X)throw Error("Object name has to be specified");let G=`${this.folderPath}/${X}`,H=Bun.file(G),Y=UQ(Bun.file(G).stream(),Z),M=new Date(H.lastModified).toUTCString();return new Response(Y,{headers:{"Content-Type":H.type,"Content-Length":String(H.size),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":M}})}async read(Q){let Z=typeof Q==="string"?{name:Q}:Q,{name:$,range:X=null}=Z;if(!$)throw Error("Object name has to be specified");let G=Bun.file(`${this.folderPath}/${$}`);if(!await G.exists())throw new h($);let H=G.size,Y=X?o0(X,H):null;if(X&&!Y)throw new k0(H);let M=Y?.start??0,K=Y?Y.end:H-1;return{body:Y?G.slice(M,K+1):G,start:M,end:K,total:H,partial:Boolean(Y),type:G.type||"application/octet-stream",lastModified:new Date(G.lastModified),name:$}}async size(Q){let Z=typeof Q==="string"?Q:Q.name,$=Bun.file(`${this.folderPath}/${Z}`);if(!await $.exists())throw new h(Z);return $.size}async delete(Q){let Z=typeof Q==="string"?Q:Q.name;if(!Z)throw Error("Object name has to be specified");let $=l(this.folderPath),X=l($,Z),G=H0($,X);if(!G||G===".."||G.startsWith(`..${f}`)||y0(G))throw Error(`Refusing to delete "${Z}": it is outside the storage folder`);try{await BQ(X)}catch(H){if(H?.code==="ENOENT")return;throw H}}resolvePrefix(Q){let Z=l(this.folderPath),$=Q.lastIndexOf("/"),X=$===-1?"":Q.slice(0,$),G=$===-1?Q:Q.slice($+1),H=l(Z,X),Y=H0(Z,H);if(Y===".."||Y.startsWith(`..${f}`)||y0(Y))throw Error(`Refusing to list "${Q}": it is outside the storage folder`);let M=Y.split(f).join("/");return{root:Z,dir:H,match:M?`${M}/${G}`:G}}async*objects(Q,{signal:Z}={}){Z?.throwIfAborted();let{root:$,dir:X,match:G}=this.resolvePrefix(Q),H=[],Y=async(M)=>{let K;try{K=await g0(M,{withFileTypes:!0})}catch(J){if(J?.code==="ENOENT"||J?.code==="ENOTDIR")return;throw J}for(let J of K){let D=`${M}${f}${J.name}`,V=H0($,D).split(f).join("/");if(J.isDirectory()){if(`${V}/`.startsWith(G)||G.startsWith(`${V}/`))await Y(D)}else if(J.isFile()&&V.startsWith(G))H.push(V)}};await Y(X),H.sort();for(let M of H){Z?.throwIfAborted();let K;try{K=await MZ(`${$}/${M}`)}catch(J){if(J?.code==="ENOENT")continue;throw J}yield{name:M,size:K.size,lastModified:K.mtime}}}async deletePrefix(Q,Z={}){C0(Q);let{root:$,match:X}=this.resolvePrefix(Q);C0(X);let G=await super.deletePrefix(Q,Z);if(G>0)await this.pruneEmptyDirs($,X);return G}async pruneEmptyDirs(Q,Z){let $=[],X=async(G)=>{let H;try{H=await g0(G,{withFileTypes:!0})}catch{return}for(let Y of H){if(!Y.isDirectory())continue;let M=`${G}${f}${Y.name}`,K=H0(Q,M).split(f).join("/");if(`${K}/`.startsWith(Z)||Z.startsWith(`${K}/`)){if(await X(M),`${K}/`.startsWith(Z))$.push(M)}}};await X(Q);for(let G of $)try{await YZ(G)}catch{}}async list(){return await g0(this.folderPath)}}function a1(Q){return Q}function RQ(){return{driver:new b0}}class f0{static token="filesystem";driver;constructor(Q={}){this.driver=Q.driver??RQ().driver}}class N extends Error{code="safe-fetch";url;constructor(Q,Z,$){super(Q,$);this.name=new.target.name,this.url=Z}}class m extends N{reason;code="invalid-url";constructor(Q,Z,$){super($,Q);this.reason=Z}}class O0 extends N{host;reason;code="blocked-host";constructor(Q,Z,$){super($==="denied"?`Requests to ${Z} are not allowed.`:`${Z} is not on the list of hosts this request may reach.`,Q);this.host=Z;this.reason=$}}class i extends N{host;address;range;code="blocked-address";constructor(Q,Z,$,X){super(Z===$?`${$} is not a public address (${X}).`:`${Z} resolves to ${$}, which is not a public address (${X}).`,Q);this.host=Z;this.address=$;this.range=X}}class F0 extends N{host;code="dns";constructor(Q,Z,$){super(`Couldn't resolve ${Z}.`,Q,{cause:$});this.host=Z}}class I0 extends N{phase;ms;code="timeout";constructor(Q,Z,$){super(Z==="connect"?`Couldn't connect within ${$} ms.`:`The request didn't finish within ${$} ms.`,Q);this.phase=Z;this.ms=$}}class T0 extends N{limit;code="too-large";constructor(Q,Z){super(`The response is larger than ${Z} bytes.`,Q);this.limit=Z}}class M0 extends N{contentType;allowed;code="content-type";constructor(Q,Z,$){super(`The response is ${Z??"of no content type"}, not ${$.join(" or ")}.`,Q);this.contentType=Z;this.allowed=$}}class v0 extends N{limit;code="too-many-redirects";constructor(Q,Z){super(`More than ${Z} redirects.`,Q);this.limit=Z}}class n extends N{code="network";constructor(Q,Z){super(`The request failed: ${Z instanceof Error?Z.message:String(Z)}`,Q,{cause:Z})}}class h0 extends N{status;code="http-status";constructor(Q,Z){super(`The server answered ${Z}.`,Q);this.status=Z}}function JZ(Q){if(Q==="")return null;let Z=Q.split(".");if(Z.length>1&&Z[Z.length-1]==="")Z.pop();if(Z.length===0||Z.length>4)return null;let $=[];for(let H of Z){let Y=WZ(H);if(Y===null)return null;$.push(Y)}let X=$.pop();for(let H of $)if(H>255)return null;if(X>=256**(4-$.length))return null;let G=X;return $.forEach((H,Y)=>{G+=H*256**(3-Y)}),new Uint8Array([Math.floor(G/16777216)&255,Math.floor(G/65536)&255,Math.floor(G/256)&255,G&255])}function WZ(Q){if(Q==="")return null;let Z=Q,$=10;if(/^0x/i.test(Z)){if(Z=Z.slice(2),$=16,Z==="")return 0}else if(Z.length>1&&Z.startsWith("0"))Z=Z.slice(1),$=8;if(!($===16?/^[0-9a-f]+$/i:$===8?/^[0-7]+$/:/^[0-9]+$/).test(Z))return null;let G=parseInt(Z,$);return Number.isSafeInteger(G)?G:null}function PQ(Q){let Z=Q;if(Z.startsWith("[")&&Z.endsWith("]"))Z=Z.slice(1,-1);let $=Z.indexOf("%");if($!==-1)Z=Z.slice(0,$);if(!Z.includes(":"))return null;let X=Z.split("::");if(X.length>2)return null;let G=(J,D)=>{if(J==="")return[];let V=[],O=J.split(":");for(let B=0;B<O.length;B++){let L=O[B];if(D&&B===O.length-1&&L.includes(".")){if(!/^\d{1,3}(\.\d{1,3}){3}$/.test(L))return null;let W=L.split(".").map(Number);if(W.some((U)=>U>255))return null;V.push(W[0]<<8|W[1],W[2]<<8|W[3]);continue}if(!/^[0-9a-f]{1,4}$/i.test(L))return null;V.push(parseInt(L,16))}return V},H=G(X[0],X.length===1),Y=X.length===2?G(X[1],!0):[];if(!H||!Y)return null;let M;if(X.length===2){let J=8-H.length-Y.length;if(J<1)return null;M=[...H,...Array.from({length:J},()=>0),...Y]}else M=H;if(M.length!==8)return null;let K=new Uint8Array(16);return M.forEach((J,D)=>{K[D*2]=J>>8,K[D*2+1]=J&255}),K}function K0(Q){let Z=PQ(Q);if(Z)return{family:6,bytes:Z};let $=JZ(Q);if($)return{family:4,bytes:$};return null}function c(Q){if(Q.family===6&&DZ(Q.bytes))return{family:4,bytes:Q.bytes.slice(12)};return Q}function DZ(Q){for(let Z=0;Z<10;Z++)if(Q[Z]!==0)return!1;return Q[10]===255&&Q[11]===255}function J0(Q){if(Q.family===4)return Array.from(Q.bytes).join(".");let Z=[];for(let $=0;$<16;$+=2)Z.push((Q.bytes[$]<<8|Q.bytes[$+1]).toString(16));return Z.join(":")}function o(Q){let Z=Q.lastIndexOf("/"),$=Z===-1?Q:Q.slice(0,Z),X=/^[0-9.]+$/.test($)?VZ($):PQ($);if(!X)return null;let G=c(X.length===4?{family:4,bytes:X}:{family:6,bytes:X}),H=G.family===4?32:128,Y=H;if(Z!==-1){let M=Q.slice(Z+1);if(!/^\d{1,3}$/.test(M))return null;if(Y=Number(M),X.length===16&&G.family===4)Y-=96;if(Y<0||Y>H)return null}return{family:G.family,bytes:G.bytes,prefix:Y}}function VZ(Q){return/^\d{1,3}(\.\d{1,3}){3}$/.test(Q)&&Q.split(".").every((Z)=>Number(Z)<=255)?new Uint8Array(Q.split(".").map(Number)):null}function g(Q,Z){let $=c(Q);if($.family!==Z.family)return!1;let X=Z.prefix;for(let G=0;X>0;G++){let H=Math.min(8,X),Y=255<<8-H&255;if(($.bytes[G]&Y)!==(Z.bytes[G]&Y))return!1;X-=H}return!0}var _=(Q,Z)=>({cidr:o(Q),kind:Z,text:Q}),zZ=[_("0.0.0.0/8","unspecified"),_("10.0.0.0/8","private"),_("100.64.0.0/10","shared"),_("127.0.0.0/8","loopback"),_("169.254.169.254/32","metadata"),_("169.254.0.0/16","link-local"),_("168.63.129.16/32","metadata"),_("172.16.0.0/12","private"),_("192.0.0.0/24","reserved"),_("192.0.2.0/24","documentation"),_("192.88.99.0/24","reserved"),_("192.168.0.0/16","private"),_("198.18.0.0/15","benchmarking"),_("198.51.100.0/24","documentation"),_("203.0.113.0/24","documentation"),_("224.0.0.0/4","multicast"),_("255.255.255.255/32","broadcast"),_("240.0.0.0/4","reserved")],UZ=[_("::/128","unspecified"),_("::1/128","loopback"),_("64:ff9b:1::/48","private"),_("::/8","reserved"),_("100::/64","reserved"),_("2001:db8::/32","documentation"),_("2001::/23","reserved"),_("3fff::/20","documentation"),_("fd00:ec2::254/128","metadata"),_("fc00::/7","unique-local"),_("fe80::/10","link-local"),_("fec0::/10","private"),_("ff00::/8","multicast")],BZ=o("64:ff9b::/96"),RZ=o("2002::/16"),PZ=o("2000::/3");function A0(Q){let Z=typeof Q==="string"?K0(Q):Q;if(!Z)return{kind:"reserved",range:"not an IP address"};let $=c(Z);if($.family===4){let G=zZ.find((H)=>g($,H.cidr));return G?{kind:G.kind,range:G.text}:null}if(g($,BZ))return A0({family:4,bytes:$.bytes.slice(12)});if(g($,RZ))return A0({family:4,bytes:$.bytes.slice(2,6)});let X=UZ.find((G)=>g($,G.cidr));if(X)return{kind:X.kind,range:X.text};return g($,PZ)?null:{kind:"reserved",range:"outside 2000::/3"}}function jQ(Q,Z){let $=c(Q),X=c(Z);return $.family===X.family&&$.bytes.every((G,H)=>G===X.bytes[H])}import{lookup as jZ}from"dns/promises";import*as LZ from"http";import*as _Z from"https";import*as t from"zlib";class m0 extends Response{#Q;#Z;address;constructor(Q,Z,$){super(Q,Z);this.#Q=$.url,this.#Z=$.redirected,this.address=$.address}get url(){return this.#Q}get redirected(){return this.#Z}}var W0={timeout:30000,connectTimeout:1e4,maxSize:10485760,maxRedirects:5,ports:[80,443]},CZ=new Set([301,302,303,307,308]),OZ=new Set([101,103,204,205,304]),FZ=["host","connection","content-length","transfer-encoding","keep-alive","upgrade"],IZ=["authorization","cookie","proxy-authorization"];async function CQ(Q,Z={}){let $=TZ(Z),X=Z.signal;X?.throwIfAborted();let G=new AbortController,H=G.signal,Y=String(Q),M=(V)=>{if(!H.aborted)G.abort(V)},K=setTimeout(()=>M(new I0(Y,"total",$.timeout)),$.timeout),J=()=>M(X.reason);X?.addEventListener("abort",J,{once:!0});let D=()=>{clearTimeout(K),X?.removeEventListener("abort",J)};try{let V=_Q(Y,$),O=(Z.method??"GET").toUpperCase(),B=new Headers(Z.headers);for(let W of FZ)B.delete(W);if(!B.has("accept"))B.set("accept","*/*");if(!B.has("user-agent"))B.set("user-agent","gemi");if(!B.has("accept-encoding"))B.set("accept-encoding","gzip, deflate, br");let L=await wZ(O,Z.body,B);for(let W=0;;W++){Y=V.href;let{request:U,response:z,address:R}=await EZ(V,O,B,L,$,H),F=z.statusCode??0,I=z.headers.location;if(CZ.has(F)&&I&&Z.redirect!=="manual"){if(U.destroy(),W>=$.maxRedirects)throw new v0(V.href,$.maxRedirects);let T;try{T=new URL(I,V)}catch{throw new m(I,"malformed",`The redirect to "${I}" is not a URL.`)}if(F===303?O!=="HEAD":(F===301||F===302)&&O==="POST"){O="GET",L=null;let C=[];B.forEach((j,P)=>{if(P.startsWith("content-"))C.push(P)});for(let j of C)B.delete(j)}if(T.origin!==V.origin)for(let C of IZ)B.delete(C);V=_Q(T.href,$);continue}return SZ({url:V,hop:W,method:O,request:U,response:z,address:R,policy:$,signal:H,release:D})}}catch(V){throw D(),H.aborted?H.reason:V}}function TZ(Q){let Z=(X,G)=>{let H={hosts:[],ranges:[]};for(let Y of X){let M=Y.includes("/")||Y.includes(":")||/^[\d.]+$/.test(Y),K=M?o(Y):null;if(K)H.ranges.push(K);else if(!M&&/^(\*\.)?[a-z0-9-]+(\.[a-z0-9-]+)*\.?$/i.test(Y))H.hosts.push(OQ(Y));else throw TypeError(`safeFetch: "${Y}" in ${G} is not a host name or an IP range.`)}return H},$=Q.allowPrivate;return{timeout:Q.timeout??W0.timeout,connectTimeout:Q.connectTimeout??W0.connectTimeout,maxSize:Q.maxSize??W0.maxSize,maxRedirects:Q.maxRedirects??W0.maxRedirects,ports:Q.ports??W0.ports,allow:Q.allow&&Q.allow.length>0?Z(Q.allow,"allow"):null,deny:Z(Q.deny??[],"deny"),allowPrivate:$===!0?!0:Z($||[],"allowPrivate").ranges,contentTypes:Q.contentTypes?.length?Q.contentTypes:null,resolve:Q.resolve??AZ}}async function AZ(Q){return(await jZ(Q,{all:!0,verbatim:!0})).map(($)=>$.address)}function OQ(Q){return Q.toLowerCase().replace(/\.$/,"")}function LQ(Q,Z){return Z.some(($)=>$.startsWith("*.")?Q.endsWith($.slice(1)):Q===$)}function _Q(Q,Z){let $;try{$=new URL(Q)}catch{throw new m(Q,"malformed",`"${Q}" is not a URL.`)}if($.protocol!=="http:"&&$.protocol!=="https:")throw new m($.href,"scheme",`Only http and https URLs can be fetched, not ${$.protocol.slice(0,-1)}.`);if($.username||$.password)throw new m($.href,"credentials","The URL has a username or password in it.");let X=FQ($);if(Z.ports!=="any"&&!Z.ports.includes(X))throw new m($.href,"port",`Port ${X} is not allowed.`);return $}function FQ(Q){return Q.port?Number(Q.port):Q.protocol==="https:"?443:80}async function qZ(Q,Z,$){let X=OQ(Q.hostname.replace(/^\[(.*)\]$/,"$1")),G=K0(X),H=G!==null&&(X.includes(":")||/^\d+\.\d+\.\d+\.\d+$/.test(X));if(!H&&LQ(X,Z.deny.hosts))throw new O0(Q.href,X,"denied");let Y=!H&&Z.allow!==null&&LQ(X,Z.allow.hosts);if(Z.allow&&!Y&&Z.allow.ranges.length===0)throw new O0(Q.href,X,"not-allowed");let M;if(H)M=[G];else{let K;try{K=await NZ(Z.resolve(X),$)}catch(J){if($.aborted)throw $.reason;throw new F0(Q.href,X,J)}if(M=K.map((J)=>K0(J)).filter((J)=>J!==null),M.length===0)throw new F0(Q.href,X)}for(let K of M){let J=J0(K);if(Z.deny.ranges.some((V)=>g(K,V)))throw new i(Q.href,X,J,"denied");if(Z.allow&&!Y&&!Z.allow.ranges.some((V)=>g(K,V)))throw new i(Q.href,X,J,"not-allowed");let D=A0(K);if(D&&Z.allowPrivate!==!0&&!Z.allowPrivate.some((V)=>g(K,V)))throw new i(Q.href,X,J,D.kind)}return{host:X,addresses:M,isLiteral:H}}function NZ(Q,Z){if(Z.aborted)return Promise.reject(Z.reason);return new Promise(($,X)=>{let G=()=>X(Z.reason);Z.addEventListener("abort",G,{once:!0}),Q.then((H)=>{Z.removeEventListener("abort",G),$(H)},(H)=>{Z.removeEventListener("abort",G),X(H)})})}async function wZ(Q,Z,$){if(Z===void 0||Z===null)return null;if(Q==="GET"||Q==="HEAD")throw TypeError(`safeFetch: a ${Q} request can't have a body.`);let X=new Request("http://body.invalid/",{method:"POST",body:Z}),G=X.headers.get("content-type");if(G&&!$.has("content-type"))$.set("content-type",G);return new Uint8Array(await X.arrayBuffer())}async function EZ(Q,Z,$,X,G,H){let Y=new AbortController,M=setTimeout(()=>Y.abort(new I0(Q.href,"connect",G.connectTimeout)),G.connectTimeout),K=AbortSignal.any([H,Y.signal]);try{let{host:J,addresses:D,isLiteral:V}=await qZ(Q,G,K),O=Q.protocol==="https:",B={};if($.forEach((L,W)=>{B[W]=L}),X)B["content-length"]=String(X.byteLength);return await new Promise((L,W)=>{let U={method:Z,host:J,port:FQ(Q),path:`${Q.pathname}${Q.search}`,headers:B,agent:!1,lookup:(C,j,P)=>{let w=j?.family,A=D.filter((D0)=>!w||D0.family===w);if(A.length===0)P(Object.assign(Error(`No IPv${w} address for ${J}`),{code:"ENOTFOUND"}));else if(j?.all)P(null,A.map((D0)=>({address:J0(D0),family:D0.family})));else P(null,J0(A[0]),A[0].family)}};if(O&&!V)U.servername=J;let z=(O?_Z:LZ).request(U),R=null,F=(C)=>{K.removeEventListener("abort",I),z.destroy(),W(C)},I=()=>F(K.aborted?K.reason:H.reason);K.addEventListener("abort",I,{once:!0});let T=(C)=>{let j=C?.remoteAddress;if(!j||R!==null)return!0;let P=K0(j);if(!P||!D.some((w)=>jQ(w,P)))return F(new i(Q.href,J,j,"not-allowed")),!1;return R=J0(c(P)),!0};z.once("socket",(C)=>{let j=()=>{if(T(C)&&!O)clearTimeout(M)};if(C.connecting)C.once("connect",j);else j();if(O)C.once("secureConnect",()=>clearTimeout(M))}),z.once("response",(C)=>{if(clearTimeout(M),C.on("error",()=>{}),!T(C.socket))return;K.removeEventListener("abort",I),L({request:z,response:C,address:R})}),z.on("error",(C)=>{if(K.aborted)return F(K.reason);F(C instanceof N?C:new n(Q.href,C))}),z.end(X??void 0)})}finally{clearTimeout(M)}}function SZ({url:Q,hop:Z,method:$,request:X,response:G,address:H,policy:Y,signal:M,release:K}){let J=G.statusCode??0;if(J<200||J>599)throw X.destroy(),new n(Q.href,Error(`Unexpected status ${J}`));let D=new Headers,V=G.rawHeaders;for(let j=0;j<V.length;j+=2)D.append(V[j],V[j+1]);if(Y.contentTypes){let j=D.get("content-type")?.split(";")[0].trim().toLowerCase()??null;if(!j||!Y.contentTypes.some((P)=>xZ(j,P)))throw X.destroy(),new M0(Q.href,j,Y.contentTypes)}let O={url:Q.href,redirected:Z>0,address:H},B={status:J,statusText:G.statusMessage??"",headers:D};if($==="HEAD"||OZ.has(J))return X.destroy(),K(),new m0(null,B,O);let L=D.get("content-encoding")?.trim().toLowerCase(),W=L==="gzip"||L==="x-gzip"?t.createGunzip():L==="deflate"?t.createInflate():L==="br"?t.createBrotliDecompress():null,U=Number(D.get("content-length"));if(!W&&Number.isFinite(U)&&U>Y.maxSize)throw X.destroy(),new T0(Q.href,Y.maxSize);if(W)D.delete("content-encoding"),D.delete("content-length");let z=W?G.pipe(W):G,R=0,F=!1,I=()=>{},T=()=>{F=!0,M.removeEventListener("abort",I),K()},C=new ReadableStream({start(j){let P=(A)=>{if(F)return;if(T(),A===void 0)j.close();else X.destroy(),W?.destroy(),j.error(A)};if(I=()=>P(M.reason),M.addEventListener("abort",I,{once:!0}),M.aborted)return I();z.on("data",(A)=>{if(F)return;if(R+=A.byteLength,R>Y.maxSize)return P(new T0(Q.href,Y.maxSize));if(j.enqueue(new Uint8Array(A)),(j.desiredSize??1)<=0)z.pause()}),z.once("end",()=>P());let w=(A)=>P(A instanceof N?A:new n(Q.href,A));if(z.on("error",w),W)G.on("error",w);G.once("aborted",()=>P(new n(Q.href,Error("The response was cut off."))))},pull(){z.resume()},cancel(){if(F)return;T(),X.destroy(),W?.destroy()}});return new m0(C,B,O)}function xZ(Q,Z){let $=Z.toLowerCase();return $.endsWith("/*")?Q.startsWith($.slice(0,-1)):Q===$}function TQ(Q){return yZ(Q)??fZ(Q)??vZ(Q)}var c0=4096,kZ={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/avif":"avif","image/heic":"heic","image/heif":"heif","image/bmp":"bmp","image/tiff":"tiff","image/x-icon":"ico","image/svg+xml":"svg","audio/mpeg":"mp3","audio/aac":"aac","audio/mp4":"m4a","audio/ogg":"ogg","audio/flac":"flac","audio/wav":"wav","video/mp4":"mp4","video/quicktime":"mov","video/webm":"webm","video/x-matroska":"mkv","video/x-msvideo":"avi","font/woff":"woff","font/woff2":"woff2","font/ttf":"ttf","font/otf":"otf","application/pdf":"pdf","application/zip":"zip","application/gzip":"gz","application/xml":"xml","text/html":"html","text/plain":"txt","application/octet-stream":"bin"};function AQ(Q){return kZ[Q]??"bin"}function S(Q,Z,$=0){if(Q.length<$+Z.length)return!1;return Z.every((X,G)=>Q[$+G]===X)}function y(Q,Z,$){return String.fromCharCode(...Q.subarray(Z,$))}var gZ={avif:"image/avif",avis:"image/avif",heic:"image/heic",heix:"image/heic",hevc:"image/heic",hevx:"image/heic",heim:"image/heic",heis:"image/heic",mif1:"image/heif",msf1:"image/heif","qt ":"video/quicktime","M4A ":"audio/mp4","M4B ":"audio/mp4"};function yZ(Q){if(S(Q,[137,80,78,71,13,10,26,10]))return"image/png";if(S(Q,[255,216,255]))return"image/jpeg";if(Q.length>=6&&(y(Q,0,6)==="GIF87a"||y(Q,0,6)==="GIF89a"))return"image/gif";if(Q.length>=12&&y(Q,0,4)==="RIFF"){let Z=y(Q,8,12);if(Z==="WEBP")return"image/webp";if(Z==="WAVE")return"audio/wav";if(Z==="AVI ")return"video/x-msvideo"}if(Q.length>=12&&y(Q,4,8)==="ftyp"){let Z=y(Q,8,12);return gZ[Z]??"video/mp4"}if(S(Q,[73,73,42,0])||S(Q,[77,77,0,42]))return"image/tiff";if(S(Q,[66,77])&&S(Q,[0,0,0,0],6))return"image/bmp";if(S(Q,[0,0,1,0])&&Q.length>=6&&Q[4]>0)return"image/x-icon";if(S(Q,[37,80,68,70,45]))return"application/pdf";if(S(Q,[80,75,3,4]))return"application/zip";if(S(Q,[31,139]))return"application/gzip";if(S(Q,[26,69,223,163]))return y(Q,0,Math.min(Q.length,64)).includes("webm")?"video/webm":"video/x-matroska";if(Q.length>=4){let Z=y(Q,0,4);if(Z==="OggS")return"audio/ogg";if(Z==="fLaC")return"audio/flac";if(Z==="wOFF")return"font/woff";if(Z==="wOF2")return"font/woff2";if(Z==="OTTO")return"font/otf"}if(S(Q,[0,1,0,0,0]))return"font/ttf";if(Q.length>=3&&y(Q,0,3)==="ID3")return"audio/mpeg";if(Q.length>=2&&Q[0]===255){if((Q[1]&246)===240)return"audio/aac";if((Q[1]&224)===224&&(Q[1]&6)!==0)return"audio/mpeg"}return null}var bZ=["!doctype html","html","head","script","iframe","h1","div","font","table","a","style","title","b","body","br","p","!--"];function fZ(Q){let Z=new TextDecoder("utf-8",{fatal:!1}).decode(Q);if(Z.charCodeAt(0)===65279)Z=Z.slice(1);if(Z=Z.trimStart(),!Z.startsWith("<"))return null;let $=Z.toLowerCase(),X=$;for(;;){X=X.trimStart();let G=/^(<\?[\s\S]*?\?>|<!--[\s\S]*?-->|<!doctype[^>]*>)/.exec(X);if(!G)break;X=X.slice(G[0].length)}if(/^<svg[\s>/]/.test(X))return"image/svg+xml";for(let G of bZ){if(!$.startsWith(`<${G}`))continue;if(/^[\s>]/.test($.charAt(G.length+1)))return"text/html"}if(/^<(html|head|body)[\s>]/.test(X))return"text/html";if($.startsWith("<?xml"))return"application/xml";return null}function vZ(Q){if(Q.length===0)return"application/octet-stream";for(let Z of Q)if(Z<32&&Z!==9&&Z!==10&&Z!==12&&Z!==13&&Z!==27)return"application/octet-stream";try{return new TextDecoder("utf-8",{fatal:!0}).decode(Q,{stream:!0}),"text/plain"}catch{return"application/octet-stream"}}var hZ=new Set(["text/html","application/xhtml+xml","image/svg+xml","text/xml","application/xml","text/xsl","application/xslt+xml"]);function IQ(Q){let Z=Q.split(";")[0].trim().toLowerCase();return hZ.has(Z)||Z.endsWith("+xml")}function qQ(Q,Z){let $=Q.split(";")[0].trim().toLowerCase();return Z.some((X)=>{let G=X.split(";")[0].trim().toLowerCase();if(G==="*/*"||G==="*")return!IQ($);if(G.endsWith("/*"))return $.startsWith(G.slice(0,-1))&&!IQ($);return $===G})}import{Buffer as pZ}from"buffer";async function NQ(Q){try{return(await import("sharp")).default}catch(Z){throw Error(`${Q} requires the 'sharp' package. Install it with \`bun add sharp\`.`,{cause:Z})}}async function wQ(Q,Z,$={}){let{name:X,directory:G,bucket:H,maxSize:Y,timeout:M,contentTypes:K,signal:J}=$;if(X!==void 0&&G!==void 0)throw TypeError("Storage.putFromUrl(): pass `name` or `directory`, not both.");if(X!==void 0&&!X)throw TypeError("Storage.putFromUrl(): `name` is empty.");let D=await CQ(Z,{...$.fetch,method:"GET",redirect:"follow",contentTypes:void 0,signal:J,timeout:M,maxSize:Y});if(!D.ok)throw await D.body?.cancel().catch(()=>{}),new h0(D.url,D.status);let V=(D.body??new Response(new Uint8Array).body).getReader(),O=async(P)=>{throw await V.cancel(P).catch(()=>{}),P},B=[],L=0,W=!1;while(L<c0){let{done:P,value:w}=await V.read();if(P){W=!0;break}B.push(w),L+=w.byteLength}let U=cZ(B,L),z=TQ(U.subarray(0,Math.min(L,c0))),R=K?.length?K:["*/*"];if(!qQ(z,R))await O(new M0(D.url,z,R));let F=X??[(G??"").replace(/\/+$/,""),`${Bun.randomUUIDv7()}.${AQ(z)}`].filter(Boolean).join("/"),I=L,T=new ReadableStream({start(P){if(L>0)P.enqueue(U);if(W)P.close()},async pull(P){let{done:w,value:A}=await V.read();if(w){P.close();return}I+=A.byteLength,P.enqueue(A)},cancel(P){return V.cancel(P)}}),C={name:F,bucket:H,body:T,contentType:z},j;try{j=Q.putStream?await Q.putStream(C,{signal:J}):await G0.prototype.putStream.call(Q,C,{signal:J})}catch(P){throw await O(P),P}return{name:j,contentType:z,size:I,url:D.url}}function cZ(Q,Z){if(Q.length===1)return Q[0];let $=new Uint8Array(Z),X=0;for(let G of Q)$.set(G,X),X+=G.byteLength;return $}class uZ extends X0{static getFacadeAccessor(){return f0}static async put(Q,Z={}){return this.getFacadeRoot().driver.put(Q,Z)}static async putFromUrl(Q,Z={}){return wQ(this.getFacadeRoot().driver,Q,Z)}static async metadata(Q){let Z=pZ.from(await Q.arrayBuffer()),$=await NQ("Storage.metadata()");try{return await $(Z).metadata()}catch{return{}}}static async fetch(Q,Z={}){return Z.signal?.throwIfAborted(),this.getFacadeRoot().driver.fetch(Q,Z)}static async read(Q,Z={}){let $=typeof Q==="string"?{name:Q}:{...Q},X="range"in Z?Z.range??null:$.range!==void 0?$.range:b.getStore()?.rangeRequest??null;return this.getFacadeRoot().driver.read({...$,range:X})}static list(Q){return this.getFacadeRoot().driver.list(Q)}static objects(Q,Z={}){return this.getFacadeRoot().driver.objects(Q,Z)}static async deletePrefix(Q,Z={}){return this.getFacadeRoot().driver.deletePrefix(Q,Z)}static async delete(Q){return this.getFacadeRoot().driver.delete(Q)}}import{mkdir as p0,readdir as dZ,access as lZ}from"fs/promises";async function u0(Q){try{return await lZ(Q),!0}catch{return!1}}class d0{config;static token="log";writer;isReady=!1;flushTimeout;fileSize=0;writerSize=0;isCreatingFile=!1;bootPromise=null;currentLogFilePath;get logsDirPath(){return`${Y0()}/storage/logs`}constructor(Q){this.config=Q}boot(){if(!this.bootPromise)this.bootPromise=this.createStorage().catch((Q)=>{console.error("Log storage unavailable, file logging disabled",Q)}).then(()=>{this.isReady=!0});return this.bootPromise}async createStorage(){let Q=`${Y0()}/storage`;if(!await u0(Q))await p0(Q);if(!await u0(this.logsDirPath))await p0(this.logsDirPath);await this.newLogFile()}async newLogFile(){if(!await u0(this.logsDirPath))await p0(this.logsDirPath);if(this.isCreatingFile=!0,this.currentLogFilePath){this.writer.flush(),this.writer.end(),this.writer=null;let $=new File([await Bun.file(this.currentLogFilePath).arrayBuffer()],this.currentLogFilePath.split("/").pop(),{type:"text/plain"});this.config.onLogFileClosed($),this.fileSize=0,this.writerSize=0}let Z=(await dZ(this.logsDirPath)).sort().reverse()[0];if(Z){let $=Bun.file(`${this.logsDirPath}/${Z}`);if($.size<this.config.maxFileSize)this.currentLogFilePath=`${this.logsDirPath}/${Z}`,this.writer=$.writer(),this.writer.write(await $.text()),this.writer.write(`
|
|
5
5
|
`),this.writer.flush(),this.fileSize=$.size}if(!this.writer){let $=`${new Date(Date.now()).toISOString()}.log`.replaceAll(":","-");this.currentLogFilePath=`${this.logsDirPath}/${$}`;let X=Bun.file(`${this.logsDirPath}/${$}`);this.writer=X.writer(),this.fileSize=0,this.writerSize=0}this.isCreatingFile=!1}async log(Q,Z,$={}){if(!this.isReady)await this.boot();let X=b.getStore(),G={};if(X)G={url:X.req.rawRequest.url,method:X.req.rawRequest.method,headers:X.req.rawRequest.headers,body:X.req.rawRequest.body};let H={timestamp:new Date(Date.now()).toISOString(),env:Bun.env.NODE_ENV,level:Q,message:Z,metadata:{...G,...$}},Y="";try{Y=JSON.stringify(H)}catch(M){console.log("Error parsing log object",M)}try{let M=this.config.onLogCreated(H);if(M instanceof Promise)M.catch((K)=>console.error("Error in onLogCreated",K))}catch(M){console.error("Error in onLogCreated",M)}if(!this.writer)return;this.writerSize+=Y.length,this.fileSize+=Y.length;try{this.writer.write(Y),this.writer.write(`
|
|
@@ -9,6 +9,6 @@ data: ${JSON.stringify(Q.event)}
|
|
|
9
9
|
`}var tZ=5000,sZ=`: keepalive
|
|
10
10
|
|
|
11
11
|
`;function aZ(Q,Z=tZ){let $=null,X=!1,G=()=>{if(X)return;if($!==null)clearTimeout($);$=setTimeout(()=>{if($=null,X)return;try{Q.enqueue(l0.encode(sZ))}catch{H();return}G()},Z)},H=()=>{if(X=!0,$!==null)clearTimeout($);$=null};return G(),{touch:G,stop:H}}function rZ(){return{"Content-Type":"text/event-stream","Cache-Control":"no-store, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}}function w8(Q,Z=200){let $=Q[Symbol.asyncIterator](),X=-1,G,H=new ReadableStream({start(Y){G=aZ(Y)},async pull(Y){try{let M=await $.next();if(M.done){G.stop(),Y.close();return}X=M.value.seq,Y.enqueue(l0.encode(EQ(M.value))),G.touch()}catch(M){let K={type:"error",error:Q1(M)};G.stop(),Y.enqueue(l0.encode(EQ({seq:X+1,event:K}))),Y.close()}},cancel(Y){G.stop(),$.return?.(Y)}});return new Response(H,{status:Z,headers:rZ()})}var eZ=new Set(["frame_cursor_evicted","live_run_not_found"]);function Q1(Q){let Z=Q&&typeof Q==="object"?Q.code:void 0;if(Q instanceof Error&&typeof Z==="string"&&eZ.has(Z))return{code:"unknown",message:Q.message,retryable:!1};return console.error("[gemi/ai] agent stream failed",Q),{code:"unknown",message:"The run's stream failed.",retryable:!1}}
|
|
12
|
-
export{i0 as
|
|
12
|
+
export{i0 as zf,SQ as Af,$1 as Bf,GQ as Cf,B1 as Df,MQ as Ef,R1 as Ff,n0 as Gf,o0 as Hf,G1 as If,H1 as Jf,Y1 as Kf,t0 as Lf,j1 as Mf,WQ as Nf,L1 as Of,_1 as Pf,s as Qf,k as Rf,XQ as Sf,D1 as Tf,V1 as Uf,rQ as Vf,eQ as Wf,x0 as Xf,k0 as Yf,QZ as Zf,h as _f,ZZ as $f,X0 as ag,NQ as bg,C0 as cg,G0 as dg,UQ as eg,b0 as fg,a1 as gg,RQ as hg,f0 as ig,N as jg,m as kg,O0 as lg,i as mg,F0 as ng,I0 as og,T0 as pg,M0 as qg,v0 as rg,n as sg,h0 as tg,A0 as ug,m0 as vg,CQ as wg,TQ as xg,IQ as yg,uZ as zg,d0 as Ag,iZ as Bg,nZ as Cg,sZ as Dg,aZ as Eg,rZ as Fg,w8 as Gg};
|
|
13
13
|
|
|
14
|
-
//# debugId=
|
|
14
|
+
//# debugId=57E870FCFDE975B864756E2164756E21
|