gemi 0.82.0 → 0.84.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/Agent.d.ts +64 -1
- package/dist/ai/Agent.d.ts.map +1 -1
- package/dist/ai/generate.d.ts +177 -0
- package/dist/ai/generate.d.ts.map +1 -0
- package/dist/ai/index.d.ts +2 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +11 -11
- package/dist/ai/index.js.map +8 -6
- package/dist/ai/providers/request.d.ts +1 -1
- package/dist/ai/providers/request.d.ts.map +1 -1
- package/dist/ai/runtime.d.ts +115 -0
- package/dist/ai/runtime.d.ts.map +1 -0
- package/dist/ai/types.d.ts +4 -0
- package/dist/ai/types.d.ts.map +1 -1
- package/dist/app/App.d.ts +0 -5
- package/dist/app/App.d.ts.map +1 -1
- package/dist/app/index.js +1 -1
- package/dist/auth/AuthController.d.ts.map +1 -1
- package/dist/auth/accessToken.d.ts +45 -0
- package/dist/auth/accessToken.d.ts.map +1 -0
- package/dist/auth/config.d.ts +3 -3
- package/dist/auth/signInRedirect.d.ts +1 -1
- package/dist/bin/gemi.js +2 -33
- package/dist/bin/gemi.js.map +6 -6
- package/dist/bin/migrate/index.d.ts.map +1 -1
- package/dist/bin/migrate/tables.d.ts.map +1 -1
- package/dist/bun/plugin.js +1 -1
- package/dist/bun/preload.js +1 -1
- package/dist/{chunk-7dk4b1fn.js → chunk-159hyeng.js} +2 -2
- package/dist/{chunk-7dk4b1fn.js.map → chunk-159hyeng.js.map} +1 -1
- package/dist/{chunk-fya5147b.js → chunk-1cebv3h8.js} +2 -2
- package/dist/{chunk-fya5147b.js.map → chunk-1cebv3h8.js.map} +1 -1
- package/dist/{chunk-gzx3rskd.js → chunk-1evk2pma.js} +4 -4
- package/dist/{chunk-gzx3rskd.js.map → chunk-1evk2pma.js.map} +1 -1
- package/dist/{chunk-hfxx52vr.js → chunk-1s914cdj.js} +3 -3
- package/dist/{chunk-hfxx52vr.js.map → chunk-1s914cdj.js.map} +1 -1
- package/dist/chunk-302mkqeq.js +7 -0
- package/dist/{chunk-817dxq6w.js.map → chunk-302mkqeq.js.map} +4 -4
- package/dist/{chunk-03xrgp1m.js → chunk-3z6wkvwj.js} +2 -2
- package/dist/{chunk-03xrgp1m.js.map → chunk-3z6wkvwj.js.map} +1 -1
- package/dist/{chunk-2gprnzc3.js → chunk-3zb2ycxj.js} +2 -2
- package/dist/{chunk-2gprnzc3.js.map → chunk-3zb2ycxj.js.map} +1 -1
- package/dist/{chunk-9146818v.js → chunk-495qwteq.js} +3 -3
- package/dist/{chunk-9146818v.js.map → chunk-495qwteq.js.map} +1 -1
- package/dist/chunk-49akdtfe.js +17 -0
- package/dist/{chunk-rs0xmd64.js.map → chunk-49akdtfe.js.map} +11 -12
- package/dist/{chunk-0e5z1x9w.js → chunk-53we503k.js} +2 -2
- package/dist/{chunk-0e5z1x9w.js.map → chunk-53we503k.js.map} +3 -3
- package/dist/{chunk-q7ngq6c5.js → chunk-57ryyhh3.js} +2 -2
- package/dist/{chunk-q7ngq6c5.js.map → chunk-57ryyhh3.js.map} +1 -1
- package/dist/{chunk-mc1xsz8j.js → chunk-73dk6k4p.js} +3 -3
- package/dist/{chunk-mc1xsz8j.js.map → chunk-73dk6k4p.js.map} +1 -1
- package/dist/{chunk-t2htq1v0.js → chunk-82nn71zs.js} +2 -2
- package/dist/{chunk-t2htq1v0.js.map → chunk-82nn71zs.js.map} +1 -1
- package/dist/{chunk-bwwjkdts.js → chunk-87x692j7.js} +2 -2
- package/dist/{chunk-bwwjkdts.js.map → chunk-87x692j7.js.map} +1 -1
- package/dist/{chunk-zv7417j0.js → chunk-8mmfpqgs.js} +2 -2
- package/dist/{chunk-v0j7spj5.js.map → chunk-8mmfpqgs.js.map} +1 -1
- package/dist/{chunk-d2tpgkg2.js → chunk-ah9ajys0.js} +1 -1
- package/dist/{chunk-zbhqa2z7.js → chunk-ash9e6fn.js} +2 -2
- package/dist/{chunk-zbhqa2z7.js.map → chunk-ash9e6fn.js.map} +1 -1
- package/dist/{chunk-mmq47yh3.js → chunk-aztkrzvf.js} +2 -2
- package/dist/{chunk-mmq47yh3.js.map → chunk-aztkrzvf.js.map} +1 -1
- package/dist/chunk-b9dejyaq.js +6 -0
- package/dist/{chunk-kghwayjv.js.map → chunk-b9dejyaq.js.map} +2 -2
- package/dist/{chunk-actjm3wr.js → chunk-bn9pzgww.js} +2 -2
- package/dist/{chunk-actjm3wr.js.map → chunk-bn9pzgww.js.map} +1 -1
- package/dist/{chunk-2frgq249.js → chunk-cfvq30n4.js} +2 -2
- package/dist/{chunk-2frgq249.js.map → chunk-cfvq30n4.js.map} +1 -1
- package/dist/{chunk-egw90hq5.js → chunk-cg4k40zy.js} +2 -2
- package/dist/{chunk-egw90hq5.js.map → chunk-cg4k40zy.js.map} +1 -1
- package/dist/{chunk-1dgab0qn.js → chunk-d0qwdeza.js} +2 -2
- package/dist/{chunk-1dgab0qn.js.map → chunk-d0qwdeza.js.map} +1 -1
- package/dist/{chunk-1k783c44.js → chunk-dvpxkzms.js} +2 -2
- package/dist/{chunk-1k783c44.js.map → chunk-dvpxkzms.js.map} +1 -1
- package/dist/chunk-e43drft2.js +5 -0
- package/dist/{chunk-z9x8fx21.js.map → chunk-e43drft2.js.map} +5 -7
- package/dist/{chunk-3k2asp5z.js → chunk-ekppwzyg.js} +2 -2
- package/dist/{chunk-3k2asp5z.js.map → chunk-ekppwzyg.js.map} +1 -1
- package/dist/{chunk-3h1pd6ec.js → chunk-en3mtnsg.js} +2 -2
- package/dist/{chunk-3h1pd6ec.js.map → chunk-en3mtnsg.js.map} +1 -1
- package/dist/{chunk-v8s1dmc2.js → chunk-enf9mdac.js} +2 -2
- package/dist/{chunk-v8s1dmc2.js.map → chunk-enf9mdac.js.map} +1 -1
- package/dist/{chunk-gppm9gkg.js → chunk-eysexnqb.js} +2 -2
- package/dist/{chunk-gppm9gkg.js.map → chunk-eysexnqb.js.map} +1 -1
- package/dist/{chunk-06p4zq4m.js → chunk-g6qe6wyb.js} +2 -2
- package/dist/{chunk-06p4zq4m.js.map → chunk-g6qe6wyb.js.map} +1 -1
- package/dist/{chunk-fpy7m803.js → chunk-gr61ymse.js} +2 -2
- package/dist/{chunk-fpy7m803.js.map → chunk-gr61ymse.js.map} +1 -1
- package/dist/{chunk-0kpvbnz0.js → chunk-j9wqzemf.js} +2 -2
- package/dist/{chunk-0kpvbnz0.js.map → chunk-j9wqzemf.js.map} +1 -1
- package/dist/{chunk-9z5g1rf6.js → chunk-jg9eqd3r.js} +1 -1
- package/dist/{chunk-6sd7an1r.js → chunk-k2qh3hvd.js} +2 -2
- package/dist/{chunk-6sd7an1r.js.map → chunk-k2qh3hvd.js.map} +1 -1
- package/dist/{chunk-d2esms7y.js → chunk-kb3xk9r8.js} +2 -2
- package/dist/{chunk-d2esms7y.js.map → chunk-kb3xk9r8.js.map} +1 -1
- package/dist/{chunk-2c89p8pf.js → chunk-kfavcgv2.js} +2 -2
- package/dist/{chunk-2c89p8pf.js.map → chunk-kfavcgv2.js.map} +1 -1
- package/dist/{chunk-5krm6p9w.js → chunk-m0zba09s.js} +3 -3
- package/dist/{chunk-5krm6p9w.js.map → chunk-m0zba09s.js.map} +1 -1
- package/dist/{chunk-wmbpdjvs.js → chunk-m4xw99vm.js} +2 -2
- package/dist/{chunk-wmbpdjvs.js.map → chunk-m4xw99vm.js.map} +1 -1
- package/dist/{chunk-6c0s1mb7.js → chunk-ng8pp9k2.js} +2 -2
- package/dist/{chunk-6c0s1mb7.js.map → chunk-ng8pp9k2.js.map} +1 -1
- package/dist/{chunk-zbpgt20r.js → chunk-nvj1z2rs.js} +2 -2
- package/dist/{chunk-zbpgt20r.js.map → chunk-nvj1z2rs.js.map} +1 -1
- package/dist/{chunk-qff26x59.js → chunk-pa0ya991.js} +2 -2
- package/dist/{chunk-qff26x59.js.map → chunk-pa0ya991.js.map} +1 -1
- package/dist/{chunk-a3mgkrb2.js → chunk-pgpqsgzx.js} +1 -1
- package/dist/{chunk-sexaj89x.js → chunk-pt59xjfc.js} +2 -2
- package/dist/{chunk-sexaj89x.js.map → chunk-pt59xjfc.js.map} +1 -1
- package/dist/{chunk-8vnb3hfz.js → chunk-r5e4vpa1.js} +2 -2
- package/dist/{chunk-8vnb3hfz.js.map → chunk-r5e4vpa1.js.map} +1 -1
- package/dist/{chunk-vxxk4syx.js → chunk-r8nhndzb.js} +2 -2
- package/dist/{chunk-vxxk4syx.js.map → chunk-r8nhndzb.js.map} +1 -1
- package/dist/{chunk-vax2fp2k.js → chunk-rmv1jp9p.js} +2 -2
- package/dist/{chunk-vax2fp2k.js.map → chunk-rmv1jp9p.js.map} +1 -1
- package/dist/{chunk-d07y2ddw.js → chunk-rqh2wdhb.js} +2 -2
- package/dist/{chunk-d07y2ddw.js.map → chunk-rqh2wdhb.js.map} +1 -1
- package/dist/{chunk-9hbwvcxn.js → chunk-rv7da58g.js} +2 -2
- package/dist/chunk-rv7da58g.js.map +10 -0
- package/dist/{chunk-2y9haf48.js → chunk-tdnfhe7x.js} +3 -3
- package/dist/{chunk-2y9haf48.js.map → chunk-tdnfhe7x.js.map} +1 -1
- package/dist/chunk-tmwsvf02.js +5 -0
- package/dist/{chunk-nc82trtm.js.map → chunk-tmwsvf02.js.map} +1 -1
- package/dist/{chunk-0zr926cf.js → chunk-v1nm4tcq.js} +2 -2
- package/dist/{chunk-0zr926cf.js.map → chunk-v1nm4tcq.js.map} +1 -1
- package/dist/{chunk-mwrh96hx.js → chunk-v27a4se1.js} +3 -3
- package/dist/chunk-v27a4se1.js.map +12 -0
- package/dist/chunk-vfrrzr10.js +4 -0
- package/dist/chunk-vfrrzr10.js.map +10 -0
- package/dist/{chunk-s7rhttvd.js → chunk-vmpzg4z5.js} +3 -3
- package/dist/{chunk-s7rhttvd.js.map → chunk-vmpzg4z5.js.map} +1 -1
- package/dist/{chunk-aecx542w.js → chunk-w099t7zj.js} +2 -2
- package/dist/{chunk-aecx542w.js.map → chunk-w099t7zj.js.map} +1 -1
- package/dist/chunk-wh728wd6.js +5 -0
- package/dist/chunk-wh728wd6.js.map +10 -0
- package/dist/{chunk-vqexqkfk.js → chunk-wkdzz0rx.js} +3 -3
- package/dist/chunk-wkdzz0rx.js.map +10 -0
- package/dist/{chunk-vngyybzh.js → chunk-wsx3j5ws.js} +2 -2
- package/dist/{chunk-vngyybzh.js.map → chunk-wsx3j5ws.js.map} +1 -1
- package/dist/{chunk-7y6gpg08.js → chunk-wwdaswxh.js} +3 -3
- package/dist/{chunk-7y6gpg08.js.map → chunk-wwdaswxh.js.map} +1 -1
- package/dist/{chunk-nq2hm5xm.js → chunk-xhha1gb3.js} +2 -2
- package/dist/{chunk-nq2hm5xm.js.map → chunk-xhha1gb3.js.map} +1 -1
- package/dist/{chunk-dk0kdrkm.js → chunk-yk8s5egf.js} +2 -2
- package/dist/{chunk-dk0kdrkm.js.map → chunk-yk8s5egf.js.map} +1 -1
- package/dist/{chunk-y7gfg6tj.js → chunk-ys4fejmx.js} +2 -2
- package/dist/{chunk-y7gfg6tj.js.map → chunk-ys4fejmx.js.map} +1 -1
- package/dist/{chunk-6eprvf4s.js → chunk-z409rk5j.js} +2 -2
- package/dist/{chunk-6eprvf4s.js.map → chunk-z409rk5j.js.map} +1 -1
- package/dist/{chunk-t6yzarvt.js → chunk-z7442w3q.js} +2 -2
- package/dist/{chunk-t6yzarvt.js.map → chunk-z7442w3q.js.map} +1 -1
- package/dist/{chunk-v0j7spj5.js → chunk-zfch4da5.js} +2 -2
- package/dist/{chunk-zv7417j0.js.map → chunk-zfch4da5.js.map} +1 -1
- package/dist/{chunk-f46ntdj3.js → chunk-zp971jp2.js} +3 -3
- package/dist/{chunk-f46ntdj3.js.map → chunk-zp971jp2.js.map} +1 -1
- package/dist/chunks/{ThemeProvider-BiNFL6l7.js → ThemeProvider-Dn3UREDn.js} +64 -90
- package/dist/chunks/ThemeProvider-Dn3UREDn.js.map +1 -0
- package/dist/client/ClientRouter.d.ts.map +1 -1
- package/dist/client/QueryResource.d.ts +14 -0
- package/dist/client/QueryResource.d.ts.map +1 -1
- package/dist/client/index.d.ts +0 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +4 -29
- package/dist/client/index.js.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/console/run.js +2 -2
- package/dist/console/run.js.map +1 -1
- package/dist/container/index.js +2 -2
- package/dist/container/index.js.map +1 -1
- package/dist/database/index.js +2 -2
- package/dist/database/index.js.map +1 -1
- package/dist/email/index.js +2 -2
- package/dist/email/index.js.map +1 -1
- package/dist/facades/Auth.d.ts +14 -0
- package/dist/facades/Auth.d.ts.map +1 -1
- package/dist/facades/index.d.ts +0 -1
- package/dist/facades/index.d.ts.map +1 -1
- package/dist/facades/index.js +2 -2
- package/dist/facades/index.js.map +1 -1
- package/dist/foundation/Application.d.ts +7 -3
- package/dist/foundation/Application.d.ts.map +1 -1
- package/dist/foundation/app.d.ts +1 -1
- package/dist/foundation/index.js +2 -2
- package/dist/foundation/index.js.map +1 -1
- package/dist/http/AuthenticationMiddlware.d.ts +4 -3
- package/dist/http/AuthenticationMiddlware.d.ts.map +1 -1
- package/dist/http/HttpRequest.d.ts.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +1 -1
- package/dist/i18n/dictionaryRuntime.js +2 -2
- package/dist/i18n/dictionaryRuntime.js.map +1 -1
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/index.js.map +1 -1
- package/dist/internal/gemiExternals.d.ts +1 -1
- package/dist/internal/gemiExternals.d.ts.map +1 -1
- package/dist/kernel/Kernel.d.ts +0 -2
- package/dist/kernel/Kernel.d.ts.map +1 -1
- package/dist/kernel/context.d.ts +3 -4
- package/dist/kernel/context.d.ts.map +1 -1
- package/dist/kernel/index.js +3 -3
- package/dist/kernel/index.js.map +5 -5
- package/dist/kernel/providers.d.ts.map +1 -1
- package/dist/orm/context.d.ts +1 -2
- package/dist/orm/context.d.ts.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/cron/ScheduleServiceProvider.d.ts +7 -2
- package/dist/services/cron/ScheduleServiceProvider.d.ts.map +1 -1
- package/dist/services/index.d.ts +0 -3
- 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/logging/LogManager.d.ts.map +1 -1
- package/dist/services/queue/QueueServiceProvider.d.ts +8 -2
- package/dist/services/queue/QueueServiceProvider.d.ts.map +1 -1
- package/dist/services/queue/work.js +2 -2
- package/dist/services/queue/work.js.map +1 -1
- package/dist/services/router/ApiRouteDispatcher.d.ts.map +1 -1
- package/dist/services/router/globalMiddleware.d.ts +5 -3
- package/dist/services/router/globalMiddleware.d.ts.map +1 -1
- package/dist/support/ServiceProvider.d.ts +14 -1
- package/dist/support/ServiceProvider.d.ts.map +1 -1
- package/dist/support/index.d.ts +1 -1
- package/dist/support/index.d.ts.map +1 -1
- package/dist/support/index.js +2 -2
- package/dist/support/index.js.map +1 -1
- package/dist/testing/Page.d.ts.map +1 -1
- package/dist/testing/index.js +16 -24
- package/dist/testing/index.js.map +1 -1
- package/package.json +1 -2
- package/dist/broadcasting/BroadcastingChannel.d.ts +0 -5
- package/dist/broadcasting/BroadcastingChannel.d.ts.map +0 -1
- package/dist/broadcasting/index.d.ts +0 -2
- package/dist/broadcasting/index.d.ts.map +0 -1
- package/dist/broadcasting/index.js +0 -4
- package/dist/broadcasting/index.js.map +0 -10
- package/dist/chunk-817dxq6w.js +0 -7
- package/dist/chunk-9hbwvcxn.js.map +0 -10
- package/dist/chunk-f9mwxne0.js +0 -4
- package/dist/chunk-f9mwxne0.js.map +0 -10
- package/dist/chunk-fffph77x.js +0 -5
- package/dist/chunk-fffph77x.js.map +0 -10
- package/dist/chunk-kghwayjv.js +0 -6
- package/dist/chunk-mwrh96hx.js.map +0 -12
- package/dist/chunk-nc82trtm.js +0 -5
- package/dist/chunk-rs0xmd64.js +0 -17
- package/dist/chunk-vqexqkfk.js.map +0 -10
- package/dist/chunk-z9x8fx21.js +0 -5
- package/dist/chunks/ThemeProvider-BiNFL6l7.js.map +0 -1
- package/dist/client/WebsocketContext.d.ts +0 -10
- package/dist/client/WebsocketContext.d.ts.map +0 -1
- package/dist/client/useBroadcast.d.ts +0 -4
- package/dist/client/useBroadcast.d.ts.map +0 -1
- package/dist/client/useSubscription.d.ts +0 -5
- package/dist/client/useSubscription.d.ts.map +0 -1
- package/dist/facades/Broadcast.d.ts +0 -9
- package/dist/facades/Broadcast.d.ts.map +0 -1
- package/dist/http/BroadcastingRouter.d.ts +0 -8
- package/dist/http/BroadcastingRouter.d.ts.map +0 -1
- package/dist/services/pubsub/BroadcastManager.d.ts +0 -24
- package/dist/services/pubsub/BroadcastManager.d.ts.map +0 -1
- package/dist/services/pubsub/BroadcastServiceProvider.d.ts +0 -5
- package/dist/services/pubsub/BroadcastServiceProvider.d.ts.map +0 -1
- package/dist/services/pubsub/config.d.ts +0 -7
- package/dist/services/pubsub/config.d.ts.map +0 -1
- package/dist/services/pubsub/types.d.ts +0 -6
- package/dist/services/pubsub/types.d.ts.map +0 -1
- /package/dist/{chunk-d2tpgkg2.js.map → chunk-ah9ajys0.js.map} +0 -0
- /package/dist/{chunk-9z5g1rf6.js.map → chunk-jg9eqd3r.js.map} +0 -0
- /package/dist/{chunk-a3mgkrb2.js.map → chunk-pgpqsgzx.js.map} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../services/cron/Scheduler.ts", "../services/queue/QueueServiceProvider.ts", "../auth/AuthServiceProvider.ts", "../services/cron/ScheduleServiceProvider.ts", "../services/features/sources/DatabaseFeatureFlagSource.ts", "../services/features/config.ts", "../services/features/FeaturesServiceProvider.ts", "../services/email/MailServiceProvider.ts", "../services/events/listenerJob.ts", "../services/events/EventManager.ts", "../services/events/EventServiceProvider.ts", "../services/file-storage/FilesystemServiceProvider.ts", "../services/image-optimization/ImageServiceProvider.ts", "../services/kernel-id/KernelIdServiceProvider.ts", "../services/logging/config.ts", "../services/logging/LogServiceProvider.ts", "../services/middleware/MiddlewareServiceProvider.ts", "../services/
|
|
3
|
+
"sources": ["../services/cron/Scheduler.ts", "../services/queue/QueueServiceProvider.ts", "../auth/AuthServiceProvider.ts", "../services/cron/ScheduleServiceProvider.ts", "../services/features/sources/DatabaseFeatureFlagSource.ts", "../services/features/config.ts", "../services/features/FeaturesServiceProvider.ts", "../services/email/MailServiceProvider.ts", "../services/events/listenerJob.ts", "../services/events/EventManager.ts", "../services/events/EventServiceProvider.ts", "../services/file-storage/FilesystemServiceProvider.ts", "../services/image-optimization/ImageServiceProvider.ts", "../services/kernel-id/KernelIdServiceProvider.ts", "../services/logging/config.ts", "../services/logging/LogServiceProvider.ts", "../services/middleware/MiddlewareServiceProvider.ts", "../services/rate-limiter/drivers/RateLimiterDriver.ts", "../services/rate-limiter/slidingWindow.ts", "../services/rate-limiter/drivers/InMemoryRateLimiterDriver.ts", "../services/rate-limiter/config.ts", "../services/rate-limiter/RateLimiterServiceProvider.ts", "../services/redis/config.ts", "../services/redis/RedisServiceProvider.ts", "../services/mcp/McpRegistry.ts", "../services/router/RouteServiceProvider.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { CronJob } from \"./CronJob\";\nimport type { ScheduleConfig } from \"./config\";\n\n// The handle the in-process `Bun.cron(schedule, callback)` overload returns\n// (has `.stop()`). `ReturnType<typeof Bun.cron>` can't be used — it resolves to\n// the module-path overload's `Promise<void>` instead.\ntype BunCronHandle = Bun.CronJob;\n\n// Runs a tick inside whatever async context the framework needs, so a job body\n// can resolve services exactly like a request handler can.\nexport type ScheduleRunner = <T>(cb: () => T | Promise<T>) => Promise<T> | T;\n\ndeclare global {\n // Registered cron jobs keyed by name, kept on `globalThis` so it survives\n // `bun --hot` reloads. Re-registering a name stops the previous schedule\n // first, so a reload *updates* the job in place instead of stacking a\n // duplicate. (Bun also stops all in-process cron jobs before re-evaluating on\n // hot reload; this makes the intent explicit and covers any re-construction.)\n var __gemiCronJobs: Map<string, BunCronHandle> | undefined;\n}\n\n/**\n * One tick of one job: the gate, then the three hooks in order.\n *\n * Named and exported rather than left inline in `start()` because otherwise the\n * only way to reach it is to wait — the tightest schedule `Bun.cron` accepts is\n * once a minute, which is not a thing a test can honestly sit through. What a\n * caller gives up by calling this directly is Bun's clock; what it keeps is\n * everything the scheduler puts between the clock and the job, which is the\n * part that has behaviour.\n *\n * The three hooks each catch and log, so one throwing does not stop the next —\n * `onComplete` in particular runs whether `callback` returned or threw, closer\n * to a `finally` than to a success handler.\n */\nexport async function runTick(job: CronJob): Promise<void> {\n try {\n // Plain truthiness, not `!== false`. The sloppy gate an app writes is\n // `if (!isProduction) return false;`, which returns `undefined` on the path\n // that was meant to run — and between the two readings of that, the one\n // that skips a recurring tick is recoverable and the one that mails a\n // customer from a developer's laptop is not. The declared return type makes\n // that method a compile error anyway, so the type system catches it while\n // it is still being written and the runtime stays on the safe side.\n if (!(await job.shouldRun.call(job))) {\n return;\n }\n } catch (error) {\n // Fail closed, for the same reason. A gate that throws has told us nothing\n // about whether the job may run, and the framework already refuses to\n // schedule a job whose name or expression it cannot read rather than run\n // something half-declared. The throw is logged, so this is loud; the missed\n // tick comes back on the next one.\n console.error(\n `Error evaluating shouldRun for cron job ${job.name}:`,\n error,\n );\n return;\n }\n\n try {\n await job.onTick.call(job);\n } catch (error) {\n console.error(`Error executing cron job ${job.name}:`, error);\n }\n try {\n await job.callback.call(job);\n } catch (error) {\n console.error(`Error in cron job ${job.name}:`, error);\n }\n try {\n await job.onComplete.call(job);\n } catch (error) {\n console.error(`Error completing cron job ${job.name}:`, error);\n }\n}\n\n/** A tick `drain` could not wait out. */\nexport interface UnfinishedTick {\n /** The job's `name`. */\n name: string;\n /**\n * When this tick started. A job whose tick outlasts its own interval has\n * two ticks running at once, and the name alone would list it twice with\n * nothing to tell the two apart.\n */\n startedAt: Date;\n}\n\n/** What `drain` could not wait out. */\nexport interface ScheduleDrainResult {\n /**\n * Ticks still running when the timeout elapsed. They keep running — a tick\n * has no way to be told to stop — until they finish or the process exits.\n */\n unfinished: UnfinishedTick[];\n}\n\nexport class Scheduler {\n static token = \"scheduler\";\n\n private handles: BunCronHandle[] = [];\n private resolved: Array<new () => CronJob>;\n\n /**\n * Every tick this scheduler has started and not seen settle, keyed by an\n * object of its own so two overlapping ticks of one job are two entries.\n * Without this there is nothing for a shutdown to wait on, and a tick the\n * process exits under is cut off halfway through its `callback`.\n */\n private readonly inFlight = new Map<object, { tick: UnfinishedTick; done: Promise<unknown> }>();\n\n /**\n * Set by `stop()`, cleared by `start()`. `handle.stop()` is what keeps Bun\n * from firing again, and this is the second lock on the same door: a\n * callback Bun had already dispatched when `stop()` ran, or a handle some\n * other scheduler left in the hot-reload registry, still finds nothing to\n * start once the drain has begun.\n */\n private stopped = false;\n\n constructor(config: Required<ScheduleConfig>) {\n this.resolved = config.jobs;\n }\n\n /**\n * The jobs this scheduler will run, or ran — declared in the config slice or\n * discovered under `app/cron`, whichever the slice asked for.\n *\n * #323 turned an application's schedule from an array it could import into a\n * directory it cannot, and an app that had a test walking that array —\n * asserting every report has an owner, that no two share an expression — was\n * about to lose it. This is where that test goes instead, and it is the\n * better question anyway: the config slice says what was asked for, this says\n * what the scheduler took.\n *\n * It lists what `start()` iterates, not what `Bun.cron` accepted. A job with\n * no name, no expression, or a name another job already claimed is logged and\n * skipped, and still appears here — a test walking this should see the\n * problem rather than have it tidied away.\n *\n * A copy, so that walk cannot edit the set the scheduler is running from.\n */\n get jobs(): ReadonlyArray<new () => CronJob> {\n return [...this.resolved];\n }\n\n /**\n * Replaces the job set, for the provider to hand over what it found under\n * `app/cron` before it calls `start()`.\n *\n * The scheduler is constructed in `register()`, where reading a directory and\n * importing what is in it is not allowed to happen — that phase is\n * synchronous and resolves nothing. So it is built from whatever the slice\n * declared and corrected in `boot()`, one line before it starts. Calling this\n * after `start()` changes what `jobs` reports and nothing else; the schedules\n * are already registered.\n */\n useJobs(jobs: Array<new () => CronJob>) {\n this.resolved = jobs;\n }\n\n /**\n * Schedules every configured job. Called from `ScheduleServiceProvider.boot()`\n * — never from the constructor — so a job body may resolve any service the\n * container holds by the time it first ticks. That ordering is what replaced\n * the old `kernel.waitForBoot()` handshake.\n */\n start(run: ScheduleRunner = (cb) => cb()) {\n this.stopped = false;\n if (this.resolved.length === 0) {\n return;\n }\n\n const registry = (globalThis.__gemiCronJobs ??= new Map());\n\n // Names claimed during *this* pass, which is a different question from what\n // `registry` holds. `registry` spans hot reloads and is supposed to already\n // contain the previous reload's handle under the same name; this starts\n // empty every time and is how a name claimed twice in one schedule is told\n // apart from the same job coming back after an edit.\n const claimed = new Map<string, string>();\n\n for (const Job of this.resolved) {\n const job = new Job();\n if (!job.name) {\n // Named by its class, because under discovery nobody wrote this job\n // down anywhere and `JSON.stringify(job)` on a nameless one prints\n // `{}`. The overwhelmingly common cause is the second sentence: a\n // shared base class sitting in the walked directory. `abstract` is\n // erased before this code runs, so there is nothing here that could\n // tell a base class from a job — only the message can.\n console.error(\n `Cron job must have a name — ${Job.name || \"an anonymous class\"} ` +\n `has none, so it is not scheduled. If this is a base class that ` +\n `other jobs extend, move it out of the discovered directory: ` +\n `\\`abstract\\` does not survive to runtime, so a class under ` +\n `app/cron is indistinguishable from a job.`,\n );\n continue;\n }\n if (!job.cron) {\n console.error(`Cron job must have an expression. Job: ${job.name}`);\n continue;\n }\n const taken = claimed.get(job.name);\n if (taken !== undefined) {\n // Refusing the second one, rather than letting it through to the\n // `registry.get(...).stop()` below — which is what used to happen, and\n // it stopped the *first* job's schedule while leaving both classes in\n // `jobs`. That is the failure #323 exists to remove wearing a disguise:\n // a report that silently stops arriving, and a test walking `jobs` that\n // sees two healthy entries and passes.\n console.error(\n `Two cron jobs claim the name \"${job.name}\" — ${taken} is ` +\n `scheduled and ${Job.name || \"an anonymous class\"} is not. A name ` +\n `is the scheduler's key, so only one job can hold it. Rename one.`,\n );\n continue;\n }\n claimed.set(job.name, Job.name || \"an anonymous class\");\n\n // Update in place: stop any schedule previously registered under this name\n // before re-registering, so a hot reload replaces rather than duplicates.\n registry.get(job.name)?.stop();\n\n // Inside `run`, gate included: a `shouldRun` that resolves a service to\n // decide is the ordinary case, and evaluating it out here would leave it\n // without the application context every other line of the tick has.\n const handle = Bun.cron(job.cron, () => {\n if (this.stopped) return;\n return this.track(job.name, () => run(() => runTick(job)));\n });\n\n registry.set(job.name, handle);\n this.handles.push(handle);\n }\n }\n\n /**\n * Stops every schedule, so no new tick starts. A tick already running is\n * left alone — `drain` is how to wait for it.\n */\n stop() {\n this.stopped = true;\n for (const handle of this.handles) {\n handle.stop();\n }\n this.handles = [];\n }\n\n /**\n * Stops every schedule, waits up to `timeoutMs` for the ticks already\n * running, and reports the ones that did not finish.\n *\n * Stopping comes first, so a tick that falls due while this waits does not\n * start: a drain that kept the clock running would never be sure it had\n * waited for everything. Nothing is cancelled — a job has no way to be told\n * — so an unfinished tick keeps running after this resolves, until it ends\n * or the process does.\n *\n * A later `start()` schedules again.\n */\n async drain(timeoutMs = Infinity): Promise<ScheduleDrainResult> {\n this.stop();\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<void>((resolve) => {\n if (timeoutMs !== Infinity) timer = setTimeout(resolve, timeoutMs);\n });\n await Promise.race([\n Promise.allSettled([...this.inFlight.values()].map((e) => e.done)),\n deadline,\n ]);\n clearTimeout(timer);\n\n return {\n unfinished: [...this.inFlight.values()].map((e) => ({ ...e.tick })),\n };\n }\n\n /** How many ticks this scheduler is running right now. */\n get running(): number {\n return this.inFlight.size;\n }\n\n private track(name: string, tick: () => unknown): Promise<unknown> {\n const key = {};\n // `Promise.resolve().then(...)` rather than calling `tick` directly, so a\n // runner that throws synchronously lands in the same promise as one that\n // rejects, and the entry below is removed either way.\n const done = Promise.resolve()\n .then(tick)\n .finally(() => this.inFlight.delete(key));\n this.inFlight.set(key, { tick: { name, startedAt: new Date() }, done });\n return done;\n }\n}\n",
|
|
6
|
-
"import { isMainThread } from \"node:worker_threads\";\n\nimport type { Application } from \"../../foundation/Application\";\nimport { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { discoverJobs } from \"../discovery\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { queueConfigDefaults, type QueueConfig } from \"./config\";\nimport { MemoryQueueDriver } from \"./MemoryQueueDriver\";\nimport {\n claimingTurnedOff,\n claimsInThisProcess,\n isQueueWorker,\n QueueManager,\n} from \"./QueueManager\";\n\n/**\n * How far inside the provider deadline the drain stops, so there is time left\n * to write the list of jobs it abandoned before `Application` stops waiting\n * for this provider and the process exits. A tenth of the budget, capped, so\n * that a deadline of a few milliseconds still spends most of itself waiting\n * rather than handing the whole of it to the margin.\n */\nconst REPORT_MARGIN_MS = 100;\n\nconst reportMargin = (timeoutMs: number) =>\n Math.min(REPORT_MARGIN_MS, Math.floor(timeoutMs / 10));\n\nexport class QueueServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n QueueManager,\n () =>\n new QueueManager(this.app.config.get<QueueConfig>(\"queue\", {}), {\n application: this.app,\n }),\n );\n }\n\n /**\n * Fills in the job registry when the app did not declare one.\n *\n * ### Why the raw slice and not the manager's config\n *\n * The decision here is whether the app said anything, and by the time the\n * manager holds a config it can no longer tell: `withDefaults` treats an\n * absent key and an `undefined` one alike and substitutes the default `[]`,\n * which is the same value an app writes when it means \"no jobs, and I mean\n * it\". Reading the slice before defaults are applied is the only place the\n * difference still exists.\n *\n * So: `jobs` present, including `jobs: []`, is used verbatim and no directory\n * is read. Absent or `undefined`, the classes under `jobsDir` are.\n *\n * ### Why phase two\n *\n * Discovery imports every file it walks, which is asynchronous, and\n * `register()` is not. It also has to happen before the first dispatch rather\n * than before the first tick — there is no equivalent of the scheduler's\n * `start()` to hang it off, so the registry has to be complete by the end of\n * boot.\n */\n async boot() {\n const slice = this.app.config.get<QueueConfig>(\"queue\", {});\n if (slice.jobs !== undefined) return;\n\n const { jobsDir } = withDefaults(queueConfigDefaults(), slice);\n this.app.make(QueueManager).useJobs(await discoverJobs(jobsDir));\n }\n\n /**\n * Stops claiming and waits for the jobs this process is running, on the way\n * out of a server told to stop. Runs after the request drain, and before the\n * database provider's, so the jobs still have their connection.\n *\n * A job still running at the deadline is abandoned with the process. With\n * the memory driver that job is lost; with one that outlives the process it\n * is claimed again elsewhere once its lease runs out. With such a driver\n * claiming already stopped when the signal arrived, so the jobs here are\n * only the ones that were running then; the memory driver kept claiming\n * until now, so a job dispatched by a request still draining ran here too.\n *\n * The drain is bounded by a little less than what is left of the shared\n * provider deadline, so that this is the thing that names the jobs it gave\n * up on. Draining without a timeout of its own read better but could not\n * work: `drain()` then resolves only once every job has finished, by which\n * point nothing is unfinished and the list below is always empty — and the\n * operator who needed it got `Application`'s generic \"did not finish within\n * the provider shutdown deadline\" instead, which names no job at all.\n */\n async shutdown(options?: { timeoutMs: number }) {\n // Resolving the manager now would build a driver only to stop it.\n if (!this.app.resolved(QueueManager)) return;\n const queue = this.app.make(QueueManager);\n if (queue.running > 0) {\n console.log(\n `[gemi] Shutting down: waiting for ${queue.running} running queued job(s).`,\n );\n }\n const budget = options?.timeoutMs;\n const { unfinished } = await queue.drain(\n budget === undefined ? Infinity : Math.max(0, budget - reportMargin(budget)),\n );\n if (unfinished.length > 0) {\n console.error(\n `[gemi] Queued jobs still running at shutdown: ` +\n unfinished.map((job) => `${job.name} (${job.id})`).join(\", \"),\n );\n }\n }\n}\n\n/**\n * Starts claiming once the application has booted, in a production server\n * whose driver keeps jobs outside the process, rather than at its first\n * dispatch. That is the recovery half of a durable driver: the jobs a previous\n * process left behind are claimed by whichever one is up, and a replica that\n * serves no dispatch of its own would otherwise never look.\n *\n * Called by the kernel after every provider has booted, not from `boot()`\n * above: queued listeners are registered as jobs by the event provider, which\n * boots after this one, and a job claimed before its name is registered is\n * dead-lettered for it.\n *\n * Not the memory driver, which never has anything left behind. Not a console\n * command or a migration, which boot the same providers and would claim jobs\n * only to exit under them — `ROOT_DIR` is set by `Server.start()` and the\n * `gemi queue:work` worker alone. Not a server started with\n * `GEMI_QUEUE_CLAIM=off`, which leaves its jobs to workers. Not\n * a `worker` job's thread, which clones the application. And not development,\n * where `bun --hot` boots a fresh application on every save: there the queue\n * starts at the first dispatch, and a reload hands a running loop over — see\n * `takeOverDevQueue`.\n */\nexport function startClaimingIfServing(application: Application) {\n warnAboutClaimSwitch(application);\n if (process.env.NODE_ENV !== \"production\") return takeOverDevQueue(application);\n if (configuresMemory(application)) return;\n if (!claimsInThisProcess()) return;\n if (!application.bound(QueueManager)) return;\n application.make(QueueManager).start();\n}\n\nfunction configuresMemory(application: Application) {\n const driver = application.config.get<QueueConfig>(\"queue\", {}).driver ?? \"memory\";\n return driver === \"memory\" || driver instanceof MemoryQueueDriver;\n}\n\n/**\n * Whether the queue's jobs live only in this process, for the warning below.\n * The config says so for `\"memory\"` or a `MemoryQueueDriver`, but a factory\n * only says once it has run, so for one the manager is built — which is the\n * same driver `durable` and `push()` go by. A factory that throws here is\n * left to throw at the first dispatch, as it would have without the switch,\n * rather than failing the boot over a warning.\n */\nfunction keepsJobsInProcess(application: Application) {\n if (configuresMemory(application)) return true;\n const driver = application.config.get<QueueConfig>(\"queue\", {}).driver;\n if (typeof driver !== \"function\" || !application.bound(QueueManager)) return false;\n try {\n return !application.make(QueueManager).durable;\n } catch {\n return false;\n }\n}\n\n/**\n * Says so at boot when a server's `GEMI_QUEUE_CLAIM` will not do what it\n * reads as. Only in a server's main thread: a console command or a `worker`\n * job's thread shares the server's environment and claims nothing anyway.\n *\n * - `off` with the memory driver is ignored, because a memory queue's jobs\n * exist only in the process that dispatched them. Honoured, it would leave\n * every dispatch waiting in a `Map` that no worker can see, for good.\n * - Any value but `off` or `on` claims. `false` or `0` read as \"off\" and are\n * not it, and a web process that quietly keeps claiming is the failure a\n * deploy that set one would never notice.\n */\nfunction warnAboutClaimSwitch(application: Application) {\n const value = process.env.GEMI_QUEUE_CLAIM;\n if (value === undefined || isQueueWorker()) return;\n if (process.env.ROOT_DIR === undefined || !isMainThread) return;\n if (claimingTurnedOff()) {\n if (!keepsJobsInProcess(application)) return;\n console.warn(\n `[gemi] GEMI_QUEUE_CLAIM=off is ignored: the memory queue driver keeps ` +\n `jobs in the process that dispatched them, so no worker could run ` +\n `them. This server runs its own jobs. Use a driver other processes ` +\n `can read, such as \"database\", to hand jobs to \\`gemi queue:work\\`.`,\n );\n } else if (value.trim().toLowerCase() !== \"on\") {\n console.warn(\n `[gemi] GEMI_QUEUE_CLAIM=\"${value}\" is not \"off\" or \"on\", so this ` +\n `server claims jobs. Set it to \"off\" to leave them to \\`gemi queue:work\\`.`,\n );\n }\n}\n\n/**\n * Under `gemi dev`, stops the loop the previous application started over a\n * shared driver, and starts this application's in its place.\n *\n * A `bun --hot` reload boots a new application in the same process, and the\n * old application's loop — started lazily by a dispatch — is a live closure\n * that nothing stopped. Over the database driver it went on claiming rows\n * from the table and running them with the code from before the save, and\n * after a few saves several generations of it were doing so side by side.\n *\n * Stopped rather than drained: `stop()` claims nothing more and returns, and\n * a job the old loop is running finishes on its old code and reports as\n * usual, where waiting for it would hold up the reload behind a job. Its row\n * stays claimed until then, so the new loop cannot take it twice.\n *\n * The new loop is started only when an old one was running, which keeps the\n * rule that development claims nothing until something is dispatched, while\n * a job waiting out a retry when the file was saved still gets its retry —\n * on the new code, which is the point of the reload. A memory queue is never\n * recorded, so it is never handed over: only its own application feeds it,\n * and stopping it would drop whatever was still waiting there.\n *\n * Runs from every boot. `waitForBoot` twice on one application stops its own\n * loop and starts it again at once, which changes nothing. The `bound` guard\n * is for an application built without the queue provider, which still stops\n * the stale loop.\n */\nfunction takeOverDevQueue(application: Application) {\n const previous = globalThis.__gemiDevQueue;\n if (!previous) return;\n globalThis.__gemiDevQueue = undefined;\n void previous.stop();\n if (application.bound(QueueManager)) application.make(QueueManager).start();\n}\n",
|
|
6
|
+
"import { isMainThread } from \"node:worker_threads\";\n\nimport type { Application } from \"../../foundation/Application\";\nimport { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { discoverJobs } from \"../discovery\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { queueConfigDefaults, type QueueConfig } from \"./config\";\nimport { MemoryQueueDriver } from \"./MemoryQueueDriver\";\nimport {\n claimingTurnedOff,\n claimsInThisProcess,\n isQueueWorker,\n QueueManager,\n} from \"./QueueManager\";\n\n/**\n * How far inside the provider deadline the drain stops, so there is time left\n * to write the list of jobs it abandoned before `Application` stops waiting\n * for this provider and the process exits. A tenth of the budget, capped, so\n * that a deadline of a few milliseconds still spends most of itself waiting\n * rather than handing the whole of it to the margin.\n */\nconst REPORT_MARGIN_MS = 100;\n\nconst reportMargin = (timeoutMs: number) =>\n Math.min(REPORT_MARGIN_MS, Math.floor(timeoutMs / 10));\n\nexport class QueueServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n QueueManager,\n () =>\n new QueueManager(this.app.config.get<QueueConfig>(\"queue\", {}), {\n application: this.app,\n }),\n );\n }\n\n /**\n * Fills in the job registry when the app did not declare one.\n *\n * ### Why the raw slice and not the manager's config\n *\n * The decision here is whether the app said anything, and by the time the\n * manager holds a config it can no longer tell: `withDefaults` treats an\n * absent key and an `undefined` one alike and substitutes the default `[]`,\n * which is the same value an app writes when it means \"no jobs, and I mean\n * it\". Reading the slice before defaults are applied is the only place the\n * difference still exists.\n *\n * So: `jobs` present, including `jobs: []`, is used verbatim and no directory\n * is read. Absent or `undefined`, the classes under `jobsDir` are.\n *\n * ### Why phase two\n *\n * Discovery imports every file it walks, which is asynchronous, and\n * `register()` is not. It also has to happen before the first dispatch rather\n * than before the first tick — there is no equivalent of the scheduler's\n * `start()` to hang it off, so the registry has to be complete by the end of\n * boot.\n */\n async boot() {\n const slice = this.app.config.get<QueueConfig>(\"queue\", {});\n if (slice.jobs !== undefined) return;\n\n const { jobsDir } = withDefaults(queueConfigDefaults(), slice);\n this.app.make(QueueManager).useJobs(await discoverJobs(jobsDir));\n }\n\n /**\n * Stops claiming and waits for the jobs this process is running, on the way\n * out of a server told to stop. Runs after the request drain, and before the\n * database provider's, so the jobs still have their connection.\n *\n * A job still running at the deadline is abandoned with the process. With\n * the memory driver that job is lost; with one that outlives the process it\n * is claimed again elsewhere once its lease runs out. With such a driver\n * claiming already stopped when the signal arrived, so the jobs here are\n * only the ones that were running then; the memory driver kept claiming\n * until now, so a job dispatched by a request still draining ran here too.\n *\n * The drain is bounded by a little less than what is left of the shared\n * provider deadline, so that this is the thing that names the jobs it gave\n * up on. Draining without a timeout of its own read better but could not\n * work: `drain()` then resolves only once every job has finished, by which\n * point nothing is unfinished and the list below is always empty — and the\n * operator who needed it got `Application`'s generic \"did not finish within\n * the provider shutdown deadline\" instead, which names no job at all. *\n * A drain that left jobs running resolves `{ abandoned: true }`, so\n * `Application` reports this provider in `timedOut` and the process exits 1:\n * the jobs are named in the log, and the exit code shows the stop was not\n * clean (#580).\n */\n async shutdown(options?: { timeoutMs: number }) {\n // Resolving the manager now would build a driver only to stop it.\n if (!this.app.resolved(QueueManager)) return;\n const queue = this.app.make(QueueManager);\n if (queue.running > 0) {\n console.log(\n `[gemi] Shutting down: waiting for ${queue.running} running queued job(s).`,\n );\n }\n const budget = options?.timeoutMs;\n const { unfinished } = await queue.drain(\n budget === undefined ? Infinity : Math.max(0, budget - reportMargin(budget)),\n );\n if (unfinished.length > 0) {\n console.error(\n `[gemi] Queued jobs still running at shutdown: ` +\n unfinished.map((job) => `${job.name} (${job.id})`).join(\", \"),\n );\n return { abandoned: true };\n }\n }\n}\n\n/**\n * Starts claiming once the application has booted, in a production server\n * whose driver keeps jobs outside the process, rather than at its first\n * dispatch. That is the recovery half of a durable driver: the jobs a previous\n * process left behind are claimed by whichever one is up, and a replica that\n * serves no dispatch of its own would otherwise never look.\n *\n * Called by the kernel after every provider has booted, not from `boot()`\n * above: queued listeners are registered as jobs by the event provider, which\n * boots after this one, and a job claimed before its name is registered is\n * dead-lettered for it.\n *\n * Not the memory driver, which never has anything left behind. Not a console\n * command or a migration, which boot the same providers and would claim jobs\n * only to exit under them — `ROOT_DIR` is set by `Server.start()` and the\n * `gemi queue:work` worker alone. Not a server started with\n * `GEMI_QUEUE_CLAIM=off`, which leaves its jobs to workers. Not\n * a `worker` job's thread, which clones the application. And not development,\n * where `bun --hot` boots a fresh application on every save: there the queue\n * starts at the first dispatch, and a reload hands a running loop over — see\n * `takeOverDevQueue`.\n */\nexport function startClaimingIfServing(application: Application) {\n warnAboutClaimSwitch(application);\n if (process.env.NODE_ENV !== \"production\") return takeOverDevQueue(application);\n if (configuresMemory(application)) return;\n if (!claimsInThisProcess()) return;\n if (!application.bound(QueueManager)) return;\n application.make(QueueManager).start();\n}\n\nfunction configuresMemory(application: Application) {\n const driver = application.config.get<QueueConfig>(\"queue\", {}).driver ?? \"memory\";\n return driver === \"memory\" || driver instanceof MemoryQueueDriver;\n}\n\n/**\n * Whether the queue's jobs live only in this process, for the warning below.\n * The config says so for `\"memory\"` or a `MemoryQueueDriver`, but a factory\n * only says once it has run, so for one the manager is built — which is the\n * same driver `durable` and `push()` go by. A factory that throws here is\n * left to throw at the first dispatch, as it would have without the switch,\n * rather than failing the boot over a warning.\n */\nfunction keepsJobsInProcess(application: Application) {\n if (configuresMemory(application)) return true;\n const driver = application.config.get<QueueConfig>(\"queue\", {}).driver;\n if (typeof driver !== \"function\" || !application.bound(QueueManager)) return false;\n try {\n return !application.make(QueueManager).durable;\n } catch {\n return false;\n }\n}\n\n/**\n * Says so at boot when a server's `GEMI_QUEUE_CLAIM` will not do what it\n * reads as. Only in a server's main thread: a console command or a `worker`\n * job's thread shares the server's environment and claims nothing anyway.\n *\n * - `off` with the memory driver is ignored, because a memory queue's jobs\n * exist only in the process that dispatched them. Honoured, it would leave\n * every dispatch waiting in a `Map` that no worker can see, for good.\n * - Any value but `off` or `on` claims. `false` or `0` read as \"off\" and are\n * not it, and a web process that quietly keeps claiming is the failure a\n * deploy that set one would never notice.\n */\nfunction warnAboutClaimSwitch(application: Application) {\n const value = process.env.GEMI_QUEUE_CLAIM;\n if (value === undefined || isQueueWorker()) return;\n if (process.env.ROOT_DIR === undefined || !isMainThread) return;\n if (claimingTurnedOff()) {\n if (!keepsJobsInProcess(application)) return;\n console.warn(\n `[gemi] GEMI_QUEUE_CLAIM=off is ignored: the memory queue driver keeps ` +\n `jobs in the process that dispatched them, so no worker could run ` +\n `them. This server runs its own jobs. Use a driver other processes ` +\n `can read, such as \"database\", to hand jobs to \\`gemi queue:work\\`.`,\n );\n } else if (value.trim().toLowerCase() !== \"on\") {\n console.warn(\n `[gemi] GEMI_QUEUE_CLAIM=\"${value}\" is not \"off\" or \"on\", so this ` +\n `server claims jobs. Set it to \"off\" to leave them to \\`gemi queue:work\\`.`,\n );\n }\n}\n\n/**\n * Under `gemi dev`, stops the loop the previous application started over a\n * shared driver, and starts this application's in its place.\n *\n * A `bun --hot` reload boots a new application in the same process, and the\n * old application's loop — started lazily by a dispatch — is a live closure\n * that nothing stopped. Over the database driver it went on claiming rows\n * from the table and running them with the code from before the save, and\n * after a few saves several generations of it were doing so side by side.\n *\n * Stopped rather than drained: `stop()` claims nothing more and returns, and\n * a job the old loop is running finishes on its old code and reports as\n * usual, where waiting for it would hold up the reload behind a job. Its row\n * stays claimed until then, so the new loop cannot take it twice.\n *\n * The new loop is started only when an old one was running, which keeps the\n * rule that development claims nothing until something is dispatched, while\n * a job waiting out a retry when the file was saved still gets its retry —\n * on the new code, which is the point of the reload. A memory queue is never\n * recorded, so it is never handed over: only its own application feeds it,\n * and stopping it would drop whatever was still waiting there.\n *\n * Runs from every boot. `waitForBoot` twice on one application stops its own\n * loop and starts it again at once, which changes nothing. The `bound` guard\n * is for an application built without the queue provider, which still stops\n * the stale loop.\n */\nfunction takeOverDevQueue(application: Application) {\n const previous = globalThis.__gemiDevQueue;\n if (!previous) return;\n globalThis.__gemiDevQueue = undefined;\n void previous.stop();\n if (application.bound(QueueManager)) application.make(QueueManager).start();\n}\n",
|
|
7
7
|
"import { ServiceProvider } from \"../support/ServiceProvider\";\nimport type { AuthConfig } from \"./config\";\nimport { AuthManager } from \"./AuthManager\";\n\nexport class AuthServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n AuthManager,\n () => new AuthManager(this.app.config.get<AuthConfig>(\"auth\", {})),\n );\n }\n}\n",
|
|
8
|
-
"import { kernelContext } from \"../../kernel/context\";\nimport { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { discoverCronJobs } from \"../discovery\";\nimport { scheduleConfigDefaults, type ScheduleConfig } from \"./config\";\nimport { Scheduler } from \"./Scheduler\";\n\n/**\n * How far inside the provider deadline the drain stops, so there is time left\n * to name the ticks it abandoned before `Application` stops waiting for this\n * provider. The same margin as the queue's drain, for the same reason: a\n * tenth of the budget, capped, so a deadline of a few milliseconds still\n * spends most of itself waiting.\n */\nconst REPORT_MARGIN_MS = 100;\n\nconst reportMargin = (timeoutMs: number) => Math.min(REPORT_MARGIN_MS, Math.floor(timeoutMs / 10));\n\nexport class ScheduleServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n Scheduler,\n () =>\n new Scheduler(\n withDefaults(\n scheduleConfigDefaults(),\n this.app.config.get<ScheduleConfig>(\"schedule\", {}),\n ),\n ),\n );\n }\n\n /**\n * Resolves the schedule, then starts it.\n *\n * Cron jobs are scheduled in phase two, not in `register()`: a job body is\n * free to resolve any service, and by the time `boot()` runs every provider\n * has registered. Each tick re-enters the application context so the job sees\n * the same container a request handler would.\n *\n * ### Why the raw slice and not the scheduler's config\n *\n * The decision here is whether the app said anything, and by the time the\n * scheduler holds a config it can no longer tell: `withDefaults` treats an\n * absent key and an `undefined` one alike and substitutes the default `[]`,\n * which is the same value an app writes when it means \"nothing scheduled, and\n * I mean it\". Reading the slice before defaults are applied is the only place\n * that difference still exists.\n *\n * So: `jobs` present, including `jobs: []`, is used verbatim and no directory\n * is read. Absent or `undefined` — which includes an app with no `schedule`\n * slice at all — the classes under `jobsDir` are, which is the case #323 is\n * about: a cron job that is written and never listed fires never, and nothing\n * downstream is waiting to notice.\n */\n async boot() {\n const scheduler = this.app.make(Scheduler);\n const slice = this.app.config.get<ScheduleConfig>(\"schedule\", {});\n\n if (slice.jobs === undefined) {\n const { jobsDir } = withDefaults(scheduleConfigDefaults(), slice);\n scheduler.useJobs(await discoverCronJobs(jobsDir));\n }\n\n // Resolved, listed, and not started.\n //\n // `gemi run` sets this on the process it spawns. Booting the application is\n // how a console command reaches the container, and starting the schedule is\n // a side effect of that which nobody asked for: a `gemi run backfill` that\n // takes four minutes would otherwise fire the application's whole cron\n // schedule in a process no operator is watching, and `Bun.cron` handles hold\n // the loop open besides.\n //\n // Deliberately above `start` and below `useJobs`, so `app(Scheduler).jobs`\n // still answers honestly — a command that wants to fire a tick by hand can,\n // and a test asking what this application schedules gets the same answer\n // either way.\n //\n // An environment variable rather than a config field, because this is a\n // property of *this process* and not of the application: the same variable\n // is how a deploy runs one cron dyno beside several web ones, and a config\n // slice would have to know which command started it.\n if (process.env.GEMI_NO_SCHEDULE === \"1\") return;\n\n const app = this.app;\n scheduler.start((cb) => kernelContext.run(app, cb));\n }\n\n /**\n * Stops the schedule and waits for the ticks already running, on the way out\n * of a server told to stop.\n *\n * Stopping first is the point. Without it `Bun.cron` kept firing for the\n * whole drain window, starting ticks the process was about to exit under,\n * and a tick already running when the process exited was cut off halfway\n * through its `callback` — on a platform that recycles replicas on every\n * release, that is every release.\n *\n * The wait is bounded a little inside what is left of the shared provider\n * deadline, like the queue's, so that this is what names the ticks it gave\n * up on rather than `Application`'s generic \"did not finish within the\n * provider shutdown deadline\", which names no job at all.\n */\n async shutdown(options?: { timeoutMs: number }) {\n // `boot()` always resolves it; this is for an application that shuts down\n // without having booted, where building a scheduler would be pointless.\n if (!this.app.resolved(Scheduler)) return;\n const scheduler = this.app.make(Scheduler);\n if (scheduler.running > 0) {\n console.log(`[gemi] Shutting down: waiting for ${scheduler.running} running cron tick(s).`);\n }\n const budget = options?.timeoutMs;\n const { unfinished } = await scheduler.drain(\n budget === undefined ? Infinity : Math.max(0, budget - reportMargin(budget)),\n );\n if (unfinished.length > 0) {\n console.error(\n `[gemi] Cron jobs still running at shutdown: ` +\n unfinished\n .map((tick) => `${tick.name} (started ${tick.startedAt.toISOString()})`)\n .join(\", \"),\n );\n }\n }\n}\n",
|
|
8
|
+
"import { kernelContext } from \"../../kernel/context\";\nimport { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { discoverCronJobs } from \"../discovery\";\nimport { scheduleConfigDefaults, type ScheduleConfig } from \"./config\";\nimport { Scheduler } from \"./Scheduler\";\n\n/**\n * How far inside the provider deadline the drain stops, so there is time left\n * to name the ticks it abandoned before `Application` stops waiting for this\n * provider. The same margin as the queue's drain, for the same reason: a\n * tenth of the budget, capped, so a deadline of a few milliseconds still\n * spends most of itself waiting.\n */\nconst REPORT_MARGIN_MS = 100;\n\nconst reportMargin = (timeoutMs: number) => Math.min(REPORT_MARGIN_MS, Math.floor(timeoutMs / 10));\n\nexport class ScheduleServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n Scheduler,\n () =>\n new Scheduler(\n withDefaults(\n scheduleConfigDefaults(),\n this.app.config.get<ScheduleConfig>(\"schedule\", {}),\n ),\n ),\n );\n }\n\n /**\n * Resolves the schedule, then starts it.\n *\n * Cron jobs are scheduled in phase two, not in `register()`: a job body is\n * free to resolve any service, and by the time `boot()` runs every provider\n * has registered. Each tick re-enters the application context so the job sees\n * the same container a request handler would.\n *\n * ### Why the raw slice and not the scheduler's config\n *\n * The decision here is whether the app said anything, and by the time the\n * scheduler holds a config it can no longer tell: `withDefaults` treats an\n * absent key and an `undefined` one alike and substitutes the default `[]`,\n * which is the same value an app writes when it means \"nothing scheduled, and\n * I mean it\". Reading the slice before defaults are applied is the only place\n * that difference still exists.\n *\n * So: `jobs` present, including `jobs: []`, is used verbatim and no directory\n * is read. Absent or `undefined` — which includes an app with no `schedule`\n * slice at all — the classes under `jobsDir` are, which is the case #323 is\n * about: a cron job that is written and never listed fires never, and nothing\n * downstream is waiting to notice.\n */\n async boot() {\n const scheduler = this.app.make(Scheduler);\n const slice = this.app.config.get<ScheduleConfig>(\"schedule\", {});\n\n if (slice.jobs === undefined) {\n const { jobsDir } = withDefaults(scheduleConfigDefaults(), slice);\n scheduler.useJobs(await discoverCronJobs(jobsDir));\n }\n\n // Resolved, listed, and not started.\n //\n // `gemi run` sets this on the process it spawns. Booting the application is\n // how a console command reaches the container, and starting the schedule is\n // a side effect of that which nobody asked for: a `gemi run backfill` that\n // takes four minutes would otherwise fire the application's whole cron\n // schedule in a process no operator is watching, and `Bun.cron` handles hold\n // the loop open besides.\n //\n // Deliberately above `start` and below `useJobs`, so `app(Scheduler).jobs`\n // still answers honestly — a command that wants to fire a tick by hand can,\n // and a test asking what this application schedules gets the same answer\n // either way.\n //\n // An environment variable rather than a config field, because this is a\n // property of *this process* and not of the application: the same variable\n // is how a deploy runs one cron dyno beside several web ones, and a config\n // slice would have to know which command started it.\n if (process.env.GEMI_NO_SCHEDULE === \"1\") return;\n\n const app = this.app;\n scheduler.start((cb) => kernelContext.run(app, cb));\n }\n\n /**\n * Stops the schedule and waits for the ticks already running, on the way out\n * of a server told to stop.\n *\n * Stopping first is the point. Without it `Bun.cron` kept firing for the\n * whole drain window, starting ticks the process was about to exit under,\n * and a tick already running when the process exited was cut off halfway\n * through its `callback` — on a platform that recycles replicas on every\n * release, that is every release.\n *\n * The wait is bounded a little inside what is left of the shared provider\n * deadline, like the queue's, so that this is what names the ticks it gave\n * up on rather than `Application`'s generic \"did not finish within the\n * provider shutdown deadline\", which names no job at all. *\n * Ticks left running resolve `{ abandoned: true }`, so `Application`\n * reports this provider in `timedOut` and the process exits 1, as it does\n * for a queued job cut off at the deadline (#580).\n */\n async shutdown(options?: { timeoutMs: number }) {\n // `boot()` always resolves it; this is for an application that shuts down\n // without having booted, where building a scheduler would be pointless.\n if (!this.app.resolved(Scheduler)) return;\n const scheduler = this.app.make(Scheduler);\n if (scheduler.running > 0) {\n console.log(`[gemi] Shutting down: waiting for ${scheduler.running} running cron tick(s).`);\n }\n const budget = options?.timeoutMs;\n const { unfinished } = await scheduler.drain(\n budget === undefined ? Infinity : Math.max(0, budget - reportMargin(budget)),\n );\n if (unfinished.length > 0) {\n console.error(\n `[gemi] Cron jobs still running at shutdown: ` +\n unfinished\n .map((tick) => `${tick.name} (started ${tick.startedAt.toISOString()})`)\n .join(\", \"),\n );\n return { abandoned: true };\n }\n }\n}\n",
|
|
9
9
|
"import * as registry from \"../../../orm/registry\";\nimport {\n FeatureFlagSource,\n FeatureModelMissingError,\n type FeatureWriteMeta,\n type FeatureWriteResult,\n} from \"./FeatureFlagSource\";\n\n/**\n * Reads the application's `FeatureFlag` table — one row per feature, carrying\n * one meaningful column.\n *\n * The model is resolved from the ORM registry **by name, at call time**, the way\n * `auth/UserProvider` resolves `User`. The framework cannot import a class the\n * application generates, and resolving lazily also means constructing this\n * source does not require the app's models to have been imported yet — only\n * loading does.\n */\nexport class DatabaseFeatureFlagSource extends FeatureFlagSource {\n constructor(readonly modelName: string = \"FeatureFlag\") {\n super();\n }\n\n /** Whether the application has registered the model at all. */\n get available(): boolean {\n return registry.has(this.modelName);\n }\n\n async load(): Promise<Record<string, unknown>[]> {\n if (!this.available) {\n throw new FeatureModelMissingError(this.modelName);\n }\n\n const model = registry.get<any>(this.modelName);\n\n // `asSystem` for the same reason auth uses it: features are read before\n // there is a user — on an anonymous page load, in a cron tick — and a policy\n // that denies by default would turn \"nobody is signed in\" into \"no rows\",\n // which silently switches every feature off for logged-out traffic.\n return await model.asSystem(() => model.findMany());\n }\n\n /**\n * Upserts the row for `key`.\n *\n * `upsert`, not `update`: a feature that has been deployed but never switched\n * on has no row at all, and that is exactly the state an admin screen exists\n * to change.\n *\n * The actor goes into an `updatedBy` column **when the model has one**, and is\n * otherwise not recorded. The column is optional so that adding `Features.set`\n * did not become a migration every app owes. When it exists it is always\n * written — `null` for a write with no actor — because leaving the previous\n * value in place would credit the last named person with a change they did\n * not make.\n */\n async write(key: string, active: boolean, meta: FeatureWriteMeta): Promise<FeatureWriteResult> {\n if (!this.available) {\n throw new FeatureModelMissingError(this.modelName);\n }\n\n const model = registry.get<any>(this.modelName);\n const actorRecorded = this.hasActorColumn(model);\n const data: Record<string, unknown> = { active };\n if (actorRecorded) data.updatedBy = meta.actor;\n\n // `asSystem` for the same reason `load()` uses it: the table is global\n // configuration, and a policy that denied the write would leave the admin\n // with an error about tenancy on a row that has none.\n await model.asSystem(() =>\n model.upsert({\n where: { key },\n create: { key, ...data },\n update: data,\n }),\n );\n\n return { actorRecorded };\n }\n\n private hasActorColumn(model: any): boolean {\n const field = model?.$schema?.fields?.updatedBy;\n return field !== undefined && field.type === \"String\";\n }\n}\n",
|
|
10
10
|
"import type { HttpRequest } from \"../../http/HttpRequest\";\nimport type { FeatureRegistry } from \"./defineFeature\";\nimport { DatabaseFeatureFlagSource } from \"./sources/DatabaseFeatureFlagSource\";\nimport type { FeatureFlagSource } from \"./sources/FeatureFlagSource\";\nimport type { FeatureContext, FeatureEvaluation } from \"./types\";\n\n// Config key: `features`. Derived from `FeaturesServiceProvider`.\nexport interface FeaturesConfig {\n /**\n * The application's declarations — the default export of\n * `app/features/index.ts`.\n *\n * Named here as well as in the framework's `gemi.d.ts` because the two layers\n * cannot share one reference: the type augmentation resolves `@/app/features`\n * through the app's tsconfig paths, which exists only at compile time. This is\n * the runtime half. They should point at the same object.\n */\n features?: FeatureRegistry;\n\n /**\n * Master switch. `false` skips loading and evaluation entirely: every feature\n * reads off and the SSR payload carries `{}`.\n */\n enabled?: boolean;\n\n /** Where the on/off switches come from. The database by default. */\n source?: FeatureFlagSource;\n\n /** ORM registry name of the model, when using the database source. */\n model?: string;\n\n /**\n * Snapshot lifetime in **seconds**.\n *\n * This is the propagation delay: switching a feature on or off is live on\n * every instance within this window. Lower it if that matters more than the\n * query volume — there is no cross-instance invalidation.\n */\n ttl?: number;\n\n /**\n * Extra attributes for every evaluation — country, cohort, build, plan.\n * Reachable in a `when` as `ctx.attributes`.\n *\n * Runs on every request inside the render path, so keep it cheap and free of\n * I/O. If it throws, evaluation degrades to no attributes rather than failing\n * the page.\n */\n context?: (req: HttpRequest | null) => Record<string, unknown> | Promise<Record<string, unknown>>;\n\n /**\n * Called once per key per request after evaluation — the hook an analytics or\n * experiment pipeline reads exposures from. Errors are caught and logged.\n */\n onEvaluate?: (key: string, evaluation: FeatureEvaluation, ctx: FeatureContext) => void;\n\n /** Warn once per boot above this many client-visible features. */\n maxClientFlags?: number;\n}\n\nexport function defineFeaturesConfig(config: FeaturesConfig): FeaturesConfig {\n return config;\n}\n\nexport function featuresConfigDefaults(): Required<\n Omit<FeaturesConfig, \"features\" | \"context\" | \"onEvaluate\">\n> & {\n features: FeaturesConfig[\"features\"];\n context: FeaturesConfig[\"context\"];\n onEvaluate: FeaturesConfig[\"onEvaluate\"];\n} {\n return {\n features: undefined,\n enabled: true,\n source: new DatabaseFeatureFlagSource(),\n model: \"FeatureFlag\",\n ttl: 30,\n context: undefined,\n onEvaluate: undefined,\n maxClientFlags: 200,\n };\n}\n\nexport type ResolvedFeaturesConfig = ReturnType<typeof featuresConfigDefaults>;\n",
|
|
11
11
|
"import { Log } from \"../../facades/Log\";\nimport { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { featuresConfigDefaults, type FeaturesConfig } from \"./config\";\nimport { FeatureManager } from \"./FeatureManager\";\nimport { DatabaseFeatureFlagSource } from \"./sources/DatabaseFeatureFlagSource\";\n\nexport class FeaturesServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(FeatureManager, () => {\n const declared = this.app.config.get<FeaturesConfig>(\"features\", {});\n const config = withDefaults(featuresConfigDefaults(), declared);\n\n // The default source is constructed by `featuresConfigDefaults()` with the\n // default model name, so a `model` override would otherwise be ignored\n // unless the app also replaced the source. Rebuild it here instead of\n // making every app that renames the table also know about the source.\n //\n // Keyed on what the *application* wrote, not on the merged values. The\n // merged `model` is always set — it defaults to `\"FeatureFlag\"` — so\n // comparing it against the source's name would fire for an app that\n // configured only `source: new DatabaseFeatureFlagSource(\"Flags\")`,\n // throwing that source away and pointing the replacement at a table the\n // app never mentioned. Every feature would then read off with nothing to\n // explain why.\n //\n // An explicit `source` always wins: it is the more specific statement, and\n // it is the only one of the two that can name something other than the\n // local table.\n if (declared?.model !== undefined && declared?.source === undefined) {\n config.source = new DatabaseFeatureFlagSource(declared.model);\n } else if (\n declared?.model !== undefined &&\n declared.source instanceof DatabaseFeatureFlagSource &&\n declared.source.modelName !== declared.model\n ) {\n Log.warning(\n `app/config/features.ts sets \\`model: \"${declared.model}\"\\` and a source reading \"${declared.source.modelName}\". The source wins; drop \\`model\\` to silence this.`,\n );\n }\n\n return new FeatureManager(config, (message) => Log.warning(message));\n });\n }\n\n async boot() {\n const features = this.app.make(FeatureManager);\n if (!features.config.enabled) return;\n\n // Warmed at boot so the first request is served from memory rather than\n // paying for the cold load. Wrapped because a database that is not up yet\n // must not fail the boot — the store fails closed, every feature reads off,\n // and it recovers on its own once the next TTL elapses.\n try {\n await features.refresh();\n } catch (error) {\n Log.error(\n `Could not warm the feature flag cache at boot. ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n }\n}\n",
|
|
@@ -19,8 +19,6 @@
|
|
|
19
19
|
"import type { LogEntry } from \"./types\";\n\n// Config key: `log`. Derived from `LoggingServiceProvider`.\nexport interface LogConfig {\n maxFileSize?: number;\n\n onLogFileClosed?: (file: File) => void | Promise<void>;\n onLogCreated?: (logEntry: LogEntry) => void | Promise<void>;\n}\n\nexport function defineLogConfig(config: LogConfig): LogConfig {\n return config;\n}\n\nexport function logConfigDefaults(): Required<LogConfig> {\n return {\n maxFileSize: 1024 * 1024 * 10, // 10MB\n onLogFileClosed: () => {},\n onLogCreated: () => {},\n };\n}\n",
|
|
20
20
|
"import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { LogManager } from \"./LogManager\";\nimport { logConfigDefaults, type LogConfig } from \"./config\";\n\nexport class LogServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n LogManager,\n () =>\n new LogManager(\n withDefaults(\n logConfigDefaults(),\n this.app.config.get<LogConfig>(\"log\", {}),\n ),\n ),\n );\n }\n\n /**\n * The log directory is created once at kernel boot rather than on the first\n * `Log.info()`, which is what the old eagerly-constructed container did.\n * Resolving here is deliberate: it is the one service whose readiness is a\n * boot-time side effect, and paying for it lazily mid-request would add file\n * IO to whichever handler happened to log first.\n *\n * Only for a process that is serving, though. `runConsole` boots these same\n * providers for every command, as does a migration or a test with a Kernel,\n * and preparing a log file is not free: a `mkdir`, a `readdir`, and — when\n * the newest file still has room — reading its whole text back into a fresh\n * writer, up to `maxFileSize` (10MB by default), in whatever directory the\n * process was started from. `ROOT_DIR` is what `Server.start` sets and\n * nothing else does. Those contexts stay lazy rather than silent: a command\n * that actually logs still gets its file, because `LogManager.log()` boots\n * the manager on first use.\n */\n async boot() {\n if (!process.env.ROOT_DIR) {\n return;\n }\n await this.app.make(LogManager).boot();\n }\n}\n",
|
|
21
21
|
"import {\n middlewareConfigDefaults,\n type MiddlewareConfig,\n} from \"../../http/middleware-config\";\nimport { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { MiddlewareRegistry } from \"./MiddlewareRegistry\";\n\nexport class MiddlewareServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n MiddlewareRegistry,\n () =>\n new MiddlewareRegistry(\n withDefaults(\n middlewareConfigDefaults(),\n this.app.config.get<MiddlewareConfig>(\"middleware\", {}),\n ),\n ),\n );\n }\n\n boot() {\n // At boot rather than on the first request, so a bad `global` entry stops\n // `gemi start` instead of surfacing as a 500 on every request.\n this.app.make(MiddlewareRegistry).assertGlobalMiddleware();\n }\n}\n",
|
|
22
|
-
"import type { BroadcastingChannel } from \"../../broadcasting/BroadcastingChannel\";\n\n// Config key: `broadcast`. Derived from `BroadcastingServiceProvider`.\nexport interface BroadcastConfig {\n channels?: Record<string, new () => BroadcastingChannel>;\n}\n\nexport function defineBroadcastConfig(\n config: BroadcastConfig,\n): BroadcastConfig {\n return config;\n}\n\nexport function broadcastConfigDefaults(): Required<BroadcastConfig> {\n return {\n channels: {},\n };\n}\n",
|
|
23
|
-
"import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { BroadcastManager } from \"./BroadcastManager\";\nimport { broadcastConfigDefaults, type BroadcastConfig } from \"./config\";\n\nexport class BroadcastServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n BroadcastManager,\n () =>\n new BroadcastManager(\n withDefaults(\n broadcastConfigDefaults(),\n this.app.config.get<BroadcastConfig>(\"broadcast\", {}),\n ),\n ),\n );\n }\n}\n",
|
|
24
22
|
"import type { ConsumeParams, RateLimitResult } from \"../types\";\n\nexport abstract class RateLimiterDriver {\n /**\n * Records one request against `params.key` and reports whether it fits.\n *\n * Implementations must decide *and* record atomically — two concurrent calls\n * for the same key may never both be told they were the last one that fit.\n *\n * May be sync or async: the in-memory driver answers immediately, a network\n * backed driver returns a promise. Callers always `await` the result.\n */\n abstract consume(\n params: ConsumeParams,\n ): Promise<RateLimitResult> | RateLimitResult;\n}\n",
|
|
25
23
|
"import type { RateLimitResult } from \"./types\";\n\n/**\n * The sliding-window-counter algorithm, shared by every driver.\n *\n * A fixed window is cheap but lets a client spend its whole budget at the end\n * of one window and again at the start of the next — twice the limit across a\n * window's worth of time. A true sliding log fixes that but has to keep a\n * timestamp per request.\n *\n * The counter variant keeps two integers per key (this window and the one\n * before it) and estimates usage by weighting the previous window by how much\n * of it still overlaps the trailing window:\n *\n * usage = previous * (window - elapsed) / window + current\n *\n * That is a ~0.003% error on real traffic and costs two integers per key, so\n * it is what the in-memory and Redis drivers both implement.\n */\n\n/** Epoch ms of the start of the window `now` falls into. */\nexport function windowStartFor(now: number, window: number) {\n return Math.floor(now / window) * window;\n}\n\n/** Weight of the previous window's count, from `1` down to `0`. */\nexport function previousWeight(elapsed: number, window: number) {\n if (window <= 0) return 0;\n return Math.min(1, Math.max(0, (window - elapsed) / window));\n}\n\n/** Estimated usage of the trailing `window` ending at `now`. */\nexport function estimateUsage(\n current: number,\n previous: number,\n elapsed: number,\n window: number,\n) {\n return previous * previousWeight(elapsed, window) + current;\n}\n\n/**\n * How long until a request costing `cost` would be admitted, in milliseconds.\n *\n * Solves the usage equation for `elapsed` instead of guessing: the caller gets\n * a `Retry-After` that lands the moment capacity actually frees up rather than\n * at the end of the window, which for a sliding window is usually far too late.\n */\nexport function timeUntilAllowed(params: {\n current: number;\n previous: number;\n elapsed: number;\n window: number;\n limit: number;\n cost: number;\n}) {\n const { current, previous, elapsed, window, limit, cost } = params;\n // Usage the bucket may sit at for this request to still fit.\n const budget = limit - cost;\n\n // The request can never fit, no matter how long the caller waits. Report a\n // full window rather than `Infinity` so a `Retry-After` header stays usable.\n if (budget < 0) return window;\n\n const remainingWindow = Math.max(0, window - elapsed);\n\n // Phase 1 — capacity frees up inside the current window as `previous` decays.\n if (previous > 0) {\n // previous * (window - e) / window + current = budget => solve for e\n const target = window * (1 - (budget - current) / previous);\n if (target <= window) {\n return Math.max(0, Math.ceil(target - elapsed));\n }\n }\n\n // Phase 2 — `current` alone is already over budget, so nothing frees up until\n // the window rolls and `current` becomes the decaying `previous`.\n if (current <= budget) return remainingWindow;\n if (current <= 0) return remainingWindow;\n\n const target = window * (1 - budget / current);\n return remainingWindow + Math.max(0, Math.ceil(target));\n}\n\n/**\n * Turns a driver's post-operation counters into the result the caller sees.\n * `current` and `previous` are the counts *after* an allowed request has been\n * recorded, so every driver reports the same numbers for the same state.\n */\nexport function buildResult(params: {\n allowed: boolean;\n current: number;\n previous: number;\n now: number;\n elapsed: number;\n window: number;\n limit: number;\n cost: number;\n}): RateLimitResult {\n const { allowed, current, previous, now, elapsed, window, limit, cost } =\n params;\n\n if (allowed) {\n const usage = estimateUsage(current, previous, elapsed, window);\n return {\n allowed: true,\n limit,\n remaining: Math.max(0, Math.floor(limit - usage)),\n resetAt: now - elapsed + window,\n retryAfter: 0,\n };\n }\n\n const retryAfter = timeUntilAllowed({\n current,\n previous,\n elapsed,\n window,\n limit,\n cost,\n });\n\n return {\n allowed: false,\n limit,\n remaining: 0,\n resetAt: now + retryAfter,\n retryAfter,\n };\n}\n",
|
|
26
24
|
"import { buildResult, estimateUsage, windowStartFor } from \"../slidingWindow\";\nimport type { ConsumeParams, RateLimitResult } from \"../types\";\nimport { RateLimiterDriver } from \"./RateLimiterDriver\";\n\ninterface Bucket {\n /** Window length this bucket was counted with, so config changes reset it. */\n window: number;\n windowStart: number;\n current: number;\n previous: number;\n}\n\nexport interface InMemoryRateLimiterOptions {\n /**\n * Hard cap on tracked keys. Reached only by traffic that never repeats a key\n * (spoofed `x-forwarded-for`, for instance); the map is swept of dead buckets\n * first and only then evicts live ones, oldest touched first.\n *\n * Defaults to 100k keys — a few MB, and far more than a single instance\n * legitimately sees inside one window.\n */\n maxKeys?: number;\n}\n\n/**\n * Per-process rate limiter. The default driver, and the right one for a single\n * instance or for development.\n *\n * State lives in this process only: with N instances behind a load balancer the\n * effective limit is N × the configured limit, and it resets on deploy. Point\n * the service provider at `RedisRateLimiter` once you run more than one.\n */\nexport class InMemoryRateLimiter extends RateLimiterDriver {\n private buckets = new Map<string, Bucket>();\n private maxKeys: number;\n\n constructor(options: InMemoryRateLimiterOptions = {}) {\n super();\n this.maxKeys = Math.max(1, options.maxKeys ?? 100_000);\n }\n\n consume(params: ConsumeParams): RateLimitResult {\n const { key, limit, window } = params;\n const cost = params.cost ?? 1;\n const now = Date.now();\n const windowStart = windowStartFor(now, window);\n const elapsed = now - windowStart;\n\n const bucket = this.roll(key, window, windowStart);\n const usage = estimateUsage(\n bucket.current,\n bucket.previous,\n elapsed,\n window,\n );\n const allowed = usage + cost <= limit;\n\n if (allowed) {\n bucket.current += cost;\n }\n\n // Re-inserting moves the key to the end of the iteration order, which is\n // what makes eviction least-recently-used rather than arbitrary.\n this.buckets.delete(key);\n this.buckets.set(key, bucket);\n if (this.buckets.size > this.maxKeys) {\n this.evict(now);\n }\n\n return buildResult({\n allowed,\n current: bucket.current,\n previous: bucket.previous,\n now,\n elapsed,\n window,\n limit,\n cost,\n });\n }\n\n /** Drops all counters. Mainly useful in tests. */\n clear() {\n this.buckets.clear();\n }\n\n /** Number of tracked keys. Exposed for tests and diagnostics. */\n get size() {\n return this.buckets.size;\n }\n\n /** Advances a bucket to `windowStart`, creating it when absent or stale. */\n private roll(key: string, window: number, windowStart: number): Bucket {\n const bucket = this.buckets.get(key);\n\n if (!bucket || bucket.window !== window) {\n return { window, windowStart, current: 0, previous: 0 };\n }\n\n if (bucket.windowStart === windowStart) {\n return bucket;\n }\n\n if (bucket.windowStart + window === windowStart) {\n bucket.previous = bucket.current;\n bucket.current = 0;\n bucket.windowStart = windowStart;\n return bucket;\n }\n\n // Idle for more than a full window: everything it held has decayed away.\n bucket.previous = 0;\n bucket.current = 0;\n bucket.windowStart = windowStart;\n return bucket;\n }\n\n private evict(now: number) {\n for (const [key, bucket] of this.buckets) {\n // Fully decayed — it would be reset on the next read anyway.\n if (now - bucket.windowStart >= bucket.window * 2) {\n this.buckets.delete(key);\n }\n }\n\n // Still over the cap, so the traffic is live rather than stale. Drop the\n // least recently touched keys; the worst case is that a client whose bucket\n // was dropped gets a fresh budget, which beats growing without bound.\n for (const key of this.buckets.keys()) {\n if (this.buckets.size <= this.maxKeys) break;\n this.buckets.delete(key);\n }\n }\n}\n",
|
|
@@ -31,7 +29,7 @@
|
|
|
31
29
|
"import type { ToolContext } from \"../../ai/Agent\";\nimport { s, type AnySchema, type JSONSchema, type Schema } from \"../../ai/Schema\";\nimport type { RouteSource } from \"../../http/ApiRouter\";\nimport type { HttpRequest } from \"../../http/HttpRequest\";\nimport type {\n McpFileBinder,\n McpMethod,\n McpParamBinder,\n McpRouteDeclaration,\n McpRouter,\n} from \"../../http/McpRouter\";\nimport type { ApiRouteDispatcher } from \"../router/ApiRouteDispatcher\";\n\n/**\n * Who a tool call runs as. Always an argument to the registry, never read from\n * ambient state by it.\n *\n * `local` is an agent running in this server, and `req` is the request that\n * started its run — read by `toAgentTools` at the moment the tool executes,\n * not when the tool was built, which is what lets one set of tools serve every\n * user's run.\n *\n * That producer *does* read ambient state, since a run no longer carries a\n * request (see `AgentContext`), and the boundary is what keeps that from\n * mattering here: the registry is handed a caller and dispatches as that\n * caller, so a second producer — a job, a test, v2's remote client — supplies\n * one however it likes, and a run with no ambient request is refused by\n * `toAgentTools` before the registry is reached rather than dispatching as\n * nobody.\n * The call is dispatched with that request's credentials, so it runs as that\n * user, through that route's middleware.\n *\n * `remote` is v2's MCP client with a bearer token. It is typed so the seam\n * exists and every entry point already takes it; each of them refuses it,\n * because a token resolver is what makes it safe and there is none yet.\n * Reading the caller from `RequestContext` instead would have been shorter,\n * and would have left v2 a registry that only works inside a gemi request.\n */\nexport type McpCaller =\n | { kind: \"local\"; req: HttpRequest<any, any> }\n | { kind: \"remote\"; token: string };\n\n/**\n * MCP's tool annotations, from the verb. They drive confirmation prompts in\n * remote clients, which is why they are set now rather than when v2 lands:\n * every app would otherwise have to revisit its MCP file to get them.\n *\n * Only what the verb says is set. POST and PATCH carry nothing, and MCP's\n * defaults for an unannotated tool — not read-only, possibly destructive — are\n * the honest answer for them.\n */\nexport type McpToolAnnotations = {\n readOnlyHint?: true;\n destructiveHint?: true;\n idempotentHint?: true;\n};\n\n/**\n * One tool, described without committing to who consumes it.\n *\n * The registry's native output. An in-process agent projects it to an\n * `AgentTool` (`toAgentTools`); v2's `tools/list` will project it to JSON.\n * Emitting `AgentTool`s here instead would leave v2 reversing JSON Schema back\n * out of them.\n */\nexport interface McpToolDescriptor {\n /** The `routes` key, verbatim. See `McpRouter`. */\n readonly name: string;\n readonly description: string;\n readonly method: McpMethod;\n /** The route's path as declared, params unfilled. */\n readonly url: string;\n /**\n * What the model fills in: the declared `input`, plus a string for every\n * `\"input\"` path param and every `\"input\"` file field. Bound params and\n * bound files are not in it at all.\n */\n readonly inputSchema: Schema<Record<string, unknown>>;\n readonly annotations: McpToolAnnotations;\n readonly tags: readonly string[];\n readonly requiresApproval: boolean;\n /** The controller method mounted at the route, when there is one (#502). */\n readonly source?: RouteSource;\n}\n\n/**\n * Narrows `list`. Data rather than a predicate, because v2's per-token\n * visibility will come from a token's grants, which are data. Both fields\n * narrow: `names` keeps only those tools, `tags` keeps tools carrying at least\n * one of them.\n */\nexport type McpToolFilter = {\n names?: readonly string[];\n tags?: readonly string[];\n};\n\n/**\n * A failure the model is meant to read: a 4xx from the route, a missing file,\n * a bad argument. v2 turns it into `isError: true` rather than a protocol\n * error. Anything else thrown from `execute` is the caller's mistake or the\n * server's, not the model's.\n */\nexport class McpToolError extends Error {\n constructor(\n message: string,\n readonly status?: number,\n ) {\n super(message);\n this.name = \"McpToolError\";\n }\n}\n\n/** Tool names as OpenAI's function tools and MCP clients both accept them. */\nconst TOOL_NAME = /^[A-Za-z0-9_-]{1,64}$/;\n\n/** `:name`, with URLPattern's modifiers. */\nconst PATH_PARAM = /:([A-Za-z_][A-Za-z0-9_]*)([?*+]?)/g;\n\n/**\n * A 4xx body goes to the model verbatim, so a validation error can be fixed on\n * the next step — but a route that answers a 4xx with a page of HTML should not\n * be able to fill the context window with it.\n */\nconst MAX_ERROR_BODY = 4000;\n\n/**\n * The same limit for a success, set higher: a list route answering every row,\n * or a route serving a large text file, would otherwise land in the context\n * window whole. Past it the model gets the text cut short and told so, rather\n * than an error — the route has already done what it does, and a model told it\n * failed would do it again.\n */\nconst MAX_RESULT_BODY = 100_000;\n\n/** A body a model can read. A missing content-type is read as text. */\nconst READABLE = /^(text\\/|application\\/([\\w.+-]*\\+)?(json|xml))/i;\n\ntype PathParam = { name: string; modifier: string };\n\ntype Plan = {\n descriptor: McpToolDescriptor;\n params: PathParam[];\n paramBinders: Map<string, McpParamBinder>;\n fileFields: { name: string; binder: McpFileBinder | \"input\" }[];\n jsonKeys: string[];\n};\n\n/**\n * The tools an app's `McpRouter` declares, resolved against the api route\n * table, and the one place a call to them is dispatched.\n *\n * Built once, at boot, from the dispatcher's flat route table — so a route\n * that was renamed or unmounted fails the boot here, and at compile time\n * before that, rather than the first model that calls it.\n *\n * THE INVARIANT: a tool call can do nothing its caller could not do with a\n * direct HTTP request. `execute` builds a request and hands it to\n * `ApiRouteDispatcher.dispatchAs`, which runs the route's middleware, auth and\n * policies exactly as for a client. It never reaches for a flat entry's\n * `exec`, which is the handler alone — no auth, no policies, no rate limit —\n * and is the shorter path for exactly that reason.\n */\nexport class McpRegistry {\n static token = \"router.mcp\";\n\n private readonly plans = new Map<string, Plan>();\n\n constructor(\n router: McpRouter<any>,\n private readonly dispatcher: Pick<\n ApiRouteDispatcher,\n \"flatRoutes\" | \"dispatchAs\" | \"getRouteHandlerAndParams\"\n >,\n ) {\n for (const [name, declaration] of Object.entries(router.routes ?? {})) {\n this.plans.set(name, this.plan(name, declaration));\n }\n }\n\n /**\n * The tools `caller` may see. v1 has only local callers, and every declared\n * tool is visible to every one of them; `filter` is taken now so the shape\n * v2's per-token visibility needs is the shape callers already use.\n */\n list(caller: McpCaller, filter?: McpToolFilter): McpToolDescriptor[] {\n assertLocal(caller);\n return this.descriptors(filter);\n }\n\n /**\n * The same listing without a caller, for a projection built once before any\n * caller exists — `toAgentTools`. It is not per-caller visibility, and a v2\n * remote listing must go through `list`.\n */\n descriptors(filter?: McpToolFilter): McpToolDescriptor[] {\n const out: McpToolDescriptor[] = [];\n for (const { descriptor } of this.plans.values()) {\n if (filter?.names && !filter.names.includes(descriptor.name)) continue;\n if (filter?.tags && !descriptor.tags.some((tag) => filter.tags.includes(tag))) continue;\n out.push(descriptor);\n }\n return out;\n }\n\n /**\n * Calls the tool `name` as `caller`, and answers the route's JSON.\n *\n * `ctx` is the tool context of the agent call, and only files need it:\n * `\"input\"` files resolve through `ctx.attachments`, the handle already\n * scoped to the caller, and bound files are chosen by a binder given `ctx`.\n * Nothing here reads an attachment any other way — the store has no\n * unscoped lookup, and this must not become one.\n *\n * A 2xx answers its JSON, or its text, cut at `MAX_RESULT_BODY`; a body\n * that is neither — a file a route serves — is described, not shown.\n * A 4xx throws an `McpToolError` carrying the route's body, so a validation\n * error reaches the model word for word. Anything else, or a route that\n * throws, throws an `McpToolError` that says only that the server failed.\n * The app gets the reason in its log, and a stack trace or a database\n * message is not something to hand a model that may be steered by whoever\n * wrote the document it is reading.\n */\n async execute(\n caller: McpCaller,\n name: string,\n args: unknown,\n ctx?: ToolContext,\n ): Promise<unknown> {\n assertLocal(caller);\n const plan = this.plans.get(name);\n if (!plan) {\n throw new Error(`McpRegistry: there is no tool named \"${name}\".`);\n }\n const { descriptor } = plan;\n\n const parsed = descriptor.inputSchema.safeParse(args);\n if (parsed.ok === false) {\n throw new McpToolError(`Invalid arguments for \"${name}\": ${parsed.errors.join(\", \")}`);\n }\n const input = parsed.value;\n\n const path = await this.fillPath(plan, input, caller.req);\n\n // The dispatcher routes `path` afresh and takes the first route that\n // matches it, so a model's \"archive-all\" for `/products/:id` would reach a\n // `/products/archive-all` declared above it — a route the app never\n // exposed, behind none of this tool's approval or annotations.\n const { path: matched } = this.dispatcher.getRouteHandlerAndParams(\n new Request(`http://gemi.internal/api${path}`),\n );\n if (matched !== descriptor.url) {\n throw new McpToolError(`\"${name}\" has nothing at ${path}.`, 404);\n }\n\n const json: Record<string, unknown> = {};\n for (const key of plan.jsonKeys) {\n if (input[key] !== undefined) json[key] = input[key];\n }\n\n let body: FormData | Record<string, unknown> | undefined;\n let query = \"\";\n if (plan.fileFields.length > 0) {\n body = await this.formData(plan, input, json, ctx);\n } else if (descriptor.method === \"GET\") {\n query = toQuery(json);\n } else if (plan.jsonKeys.length > 0) {\n body = json;\n }\n\n let response: Response;\n try {\n response = await this.dispatcher.dispatchAs(\n caller.req,\n descriptor.method,\n query ? `${path}?${query}` : path,\n body,\n );\n } catch (error) {\n // What a client would get as a 500. A handler's throw is logged by the\n // dispatcher too, but dispatchAs's own refusal of the path is not.\n console.error(`[gemi/mcp] Dispatching \"${name}\" failed:`, error);\n throw new McpToolError(`\"${name}\" failed on the server.`, 500);\n }\n return await readResponse(name, response);\n }\n\n // --- building ------------------------------------------------------------\n\n private plan(name: string, declaration: McpRouteDeclaration): Plan {\n if (!TOOL_NAME.test(name)) {\n throw new Error(\n `McpRouter: \"${name}\" is not a valid tool name. A routes key is the tool's name as a model and an MCP client see it, used verbatim — letters, digits, \"_\" and \"-\", at most 64.`,\n );\n }\n const where = `McpRouter: \"${name}\" (${declaration?.method} ${declaration?.url})`;\n if (!(declaration instanceof Object) || declaration.__internal_brand !== \"McpRoute\") {\n throw new Error(\n `McpRouter: \"${name}\" is not a route. Declare it with this.fromApiRoute(...).`,\n );\n }\n const { method, url, meta } = declaration;\n if (url.startsWith(\"/__gemi__\")) {\n throw new Error(`${where} is a framework route, not an app route.`);\n }\n\n const entry = this.dispatcher.flatRoutes[url]?.[method];\n if (!entry) {\n throw new Error(\n `${where} names no route of this app. Expose a route by the path and verb it is mounted at.`,\n );\n }\n\n // Mirrors the compile-time check, for a router written in JavaScript or\n // behind a cast: a param left undeclared would otherwise be the model's.\n const params: PathParam[] = [...url.matchAll(PATH_PARAM)].map(([, param, modifier]) => ({\n name: param,\n modifier,\n }));\n const declared = meta.params ?? {};\n for (const param of params) {\n if (!(param.name in declared)) {\n throw new Error(\n `${where}: the path param \"${param.name}\" must be bound or declared \"input\".`,\n );\n }\n }\n for (const [key, binder] of Object.entries(declared)) {\n if (!params.some((param) => param.name === key)) {\n throw new Error(`${where}: \"${key}\" in params is not a param of the url.`);\n }\n assertBinder(where, `params.${key}`, binder);\n }\n\n let jsonKeys: string[] = [];\n let base: JSONSchema | undefined;\n if (meta.input) {\n base = meta.input.toJSONSchema();\n if (base.type !== \"object\" || !base.properties) {\n throw new Error(\n `${where}: input must be an s.object(...), the fields of the request body.`,\n );\n }\n jsonKeys = Object.keys(base.properties);\n }\n\n const fileFields = Object.entries(meta.files ?? {}).map(([field, binder]) => ({\n name: field,\n binder,\n }));\n for (const file of fileFields) {\n assertBinder(where, `files.${file.name}`, file.binder);\n }\n if (fileFields.length > 0 && method === \"GET\") {\n throw new Error(`${where}: a GET has no body to carry a file.`);\n }\n\n const extras: Record<string, AnySchema> = {};\n const paramBinders = new Map<string, McpParamBinder>();\n for (const param of params) {\n const binder = declared[param.name];\n if (binder === \"input\") {\n const field = s.string().describe(`The \":${param.name}\" segment of the url.`);\n extras[param.name] =\n param.modifier === \"?\" || param.modifier === \"*\" ? field.optional() : field;\n } else {\n paramBinders.set(param.name, binder);\n }\n }\n for (const file of fileFields) {\n if (file.binder === \"input\") {\n extras[file.name] = s\n .string()\n .describe(\n \"The id of an attachment the user uploaded or a tool produced (gemi_att_…), whose file is sent as this field.\",\n );\n }\n }\n // A bound file is not the model's, but it shares the form with the input,\n // so it collides all the same.\n const bodyKeys = [...Object.keys(extras), ...fileFields.map((file) => file.name)];\n for (const key of new Set(bodyKeys)) {\n if (jsonKeys.includes(key)) {\n throw new Error(\n `${where}: \"${key}\" is both an input field and a param or file, and the model can only send one.`,\n );\n }\n }\n\n return {\n descriptor: Object.freeze({\n name,\n description: meta.description,\n method,\n url,\n inputSchema: combineSchemas(meta.input, base, s.object(extras)),\n annotations: annotationsFor(method),\n tags: Object.freeze([...(meta.tags ?? [])]),\n requiresApproval: meta.requiresApproval === true,\n ...(entry.source ? { source: entry.source } : {}),\n }),\n params,\n paramBinders,\n fileFields,\n jsonKeys,\n };\n }\n\n // --- calling -------------------------------------------------------------\n\n private async fillPath(\n plan: Plan,\n input: Record<string, unknown>,\n req: HttpRequest<any, any>,\n ): Promise<string> {\n let path = plan.descriptor.url;\n for (const param of plan.params) {\n const binder = plan.paramBinders.get(param.name);\n let value: unknown;\n if (binder) {\n value = await this.bind(plan, `the param \"${param.name}\"`, () => binder(req));\n if (value === undefined || value === null || value === \"\") {\n console.error(\n `[gemi/mcp] The binder for \"${param.name}\" of \"${plan.descriptor.name}\" returned ${JSON.stringify(value)}.`,\n );\n throw new McpToolError(`\"${plan.descriptor.name}\" failed on the server.`, 500);\n }\n } else {\n value = input[param.name];\n }\n\n const token = `:${param.name}${param.modifier}`;\n if (value === undefined || value === null || value === \"\") {\n if (param.modifier !== \"?\" && param.modifier !== \"*\") {\n throw new McpToolError(`\"${param.name}\" of \"${plan.descriptor.name}\" must not be empty.`);\n }\n path = path.replace(`/${token}`, \"\");\n continue;\n }\n path = path.replace(token, encodeSegment(plan.descriptor.name, param, String(value)));\n }\n return path;\n }\n\n private async formData(\n plan: Plan,\n input: Record<string, unknown>,\n json: Record<string, unknown>,\n ctx: ToolContext | undefined,\n ): Promise<FormData> {\n const name = plan.descriptor.name;\n if (!ctx) {\n throw new Error(\n `McpRegistry: \"${name}\" sends a file, which is resolved through the tool context's attachments, and none was passed to execute().`,\n );\n }\n const form = new FormData();\n for (const [key, value] of Object.entries(json)) {\n appendField(form, key, value);\n }\n for (const field of plan.fileFields) {\n const id =\n field.binder === \"input\"\n ? (input[field.name] as string)\n : await this.bind(plan, `the file \"${field.name}\"`, () =>\n (field.binder as McpFileBinder)(ctx),\n );\n if (typeof id !== \"string\" || id === \"\") {\n throw new McpToolError(\n `\"${name}\" needs a file for \"${field.name}\", and this turn has none. Ask the user to attach one.`,\n );\n }\n // Scoped to the caller: someone else's id is a not-found, worded like an\n // invented one, and that error is what the model reads.\n form.append(field.name, await ctx.attachments.file(id));\n }\n return form;\n }\n\n /**\n * Runs an app's binder. Its failure is the server's, not the model's, so the\n * model is told only that; the app gets the error in its log.\n */\n private async bind<T>(plan: Plan, what: string, fn: () => T | Promise<T>): Promise<T> {\n try {\n return await fn();\n } catch (error) {\n console.error(`[gemi/mcp] Binding ${what} of \"${plan.descriptor.name}\" failed:`, error);\n throw new McpToolError(`\"${plan.descriptor.name}\" failed on the server.`, 500);\n }\n }\n}\n\nfunction assertLocal(caller: McpCaller): asserts caller is Extract<McpCaller, { kind: \"local\" }> {\n if (caller?.kind !== \"local\") {\n throw new Error(\n \"McpRegistry: only local callers are implemented. A remote caller needs a bearer-token resolver, which v1 does not have — and until it does there is no remote surface to call from.\",\n );\n }\n}\n\n/** A binder is a function or `\"input\"`; anything else would leave the value to nobody. */\nfunction assertBinder(where: string, at: string, binder: unknown) {\n if (binder !== \"input\" && typeof binder !== \"function\") {\n throw new Error(`${where}: ${at} must be a function or \"input\".`);\n }\n}\n\nfunction annotationsFor(method: McpMethod): McpToolAnnotations {\n switch (method) {\n case \"GET\":\n return Object.freeze({ readOnlyHint: true as const });\n case \"DELETE\":\n return Object.freeze({ destructiveHint: true as const });\n case \"PUT\":\n return Object.freeze({ idempotentHint: true as const });\n default:\n return Object.freeze({});\n }\n}\n\n/**\n * One schema out of two: the app's `input`, and the strings for `\"input\"`\n * params and files.\n *\n * Built by hand, like `questionSchema` in `ai/Agent.ts`, rather than by\n * widening `s` with a merge: `Schema.ts` is deliberately the strict\n * structured-output subset and owns no operation on a finished schema. Both\n * halves are real `s` schemas, each parses the whole value and drops the keys\n * that are not its own — which is also where a bound param the model sent\n * anyway disappears, since neither half declares it.\n */\nfunction combineSchemas(\n input: AnySchema | undefined,\n base: JSONSchema | undefined,\n extras: AnySchema,\n): Schema<Record<string, unknown>> {\n const extra = extras.toJSONSchema();\n const json: JSONSchema = {\n ...(base ?? {}),\n type: \"object\",\n properties: { ...(base?.properties ?? {}), ...extra.properties },\n required: [...(base?.required ?? []), ...(extra.required ?? [])],\n additionalProperties: false,\n };\n\n const safeParse = (value: unknown) => {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return { ok: false as const, errors: [\"expected an object\"] };\n }\n const errors: string[] = [];\n let out: Record<string, unknown> = {};\n if (input) {\n const own = input.safeParse(value);\n if (own.ok === false) errors.push(...own.errors);\n else out = { ...own.value };\n }\n const more = extras.safeParse(value);\n if (more.ok === false) errors.push(...more.errors);\n else out = { ...out, ...more.value };\n return errors.length > 0 ? { ok: false as const, errors } : { ok: true as const, value: out };\n };\n\n return {\n toJSONSchema: () => json,\n safeParse,\n parse(value: unknown) {\n const result = safeParse(value);\n if (result.ok === false) throw new Error(result.errors.join(\", \"));\n return result.value;\n },\n } as unknown as Schema<Record<string, unknown>>;\n}\n\n/**\n * A model-supplied param, as one encoded path segment. `.` and `..` are\n * refused rather than encoded: they encode to themselves, and URL parsing\n * would walk them out of the route.\n */\nfunction encodeSegment(tool: string, param: PathParam, value: string): string {\n const parts = param.modifier === \"*\" || param.modifier === \"+\" ? value.split(\"/\") : [value];\n if (parts.some((part) => part === \".\" || part === \"..\")) {\n throw new McpToolError(`\"${value}\" is not a valid value for \"${param.name}\" of \"${tool}\".`);\n }\n return parts.map(encodeURIComponent).join(\"/\");\n}\n\n/**\n * A JSON field as a multipart form field. A form has only strings, so the\n * route reads `\"12\"` where a JSON body would have carried `12` — what a\n * browser form sends the same route. An array becomes the key repeated, which\n * `HttpRequest` reads back as an array.\n */\nfunction appendField(form: FormData, key: string, value: unknown) {\n if (value === undefined || value === null) return;\n if (Array.isArray(value)) {\n for (const item of value) appendField(form, key, item);\n return;\n }\n form.append(key, typeof value === \"object\" ? JSON.stringify(value) : String(value));\n}\n\n/** A GET's input, as the query string `HttpRequest.search` reads. */\nfunction toQuery(json: Record<string, unknown>): string {\n const search = new URLSearchParams();\n const add = (key: string, value: unknown) => {\n if (value === undefined || value === null) return;\n if (Array.isArray(value)) {\n for (const item of value) add(key, item);\n return;\n }\n search.append(key, typeof value === \"object\" ? JSON.stringify(value) : String(value));\n };\n for (const [key, value] of Object.entries(json)) add(key, value);\n return search.toString();\n}\n\nasync function readResponse(name: string, response: Response): Promise<unknown> {\n if (response.status >= 200 && response.status < 300) {\n const type = response.headers.get(\"Content-Type\");\n if (type && !READABLE.test(type)) {\n const size = (await response.arrayBuffer()).byteLength;\n return `\"${name}\" answered with ${size} bytes of ${type}, which is not shown.`;\n }\n const text = await response.text();\n if (text === \"\") return null;\n if (text.length > MAX_RESULT_BODY) {\n return `${text.slice(0, MAX_RESULT_BODY)}… [cut at ${MAX_RESULT_BODY} of ${text.length} characters]`;\n }\n try {\n return JSON.parse(text);\n } catch {\n return text;\n }\n }\n const text = await response.text();\n if (response.status >= 400 && response.status < 500) {\n const shown = text.length > MAX_ERROR_BODY ? `${text.slice(0, MAX_ERROR_BODY)}…` : text;\n throw new McpToolError(\n `\"${name}\" was refused with ${response.status}${shown ? `: ${shown}` : \".\"}`,\n response.status,\n );\n }\n if (response.status < 500) {\n // A redirect, or a 1xx: nothing the model can follow, and nothing the\n // dispatcher logged.\n console.error(\n `[gemi/mcp] \"${name}\" answered ${response.status}${response.headers.get(\"Location\") ? ` to ${response.headers.get(\"Location\")}` : \"\"}, which a tool call cannot follow.`,\n );\n }\n throw new McpToolError(`\"${name}\" failed on the server.`, response.status);\n}\n",
|
|
32
30
|
"import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { McpRegistry } from \"../mcp/McpRegistry\";\nimport { ApiRouteDispatcher } from \"./ApiRouteDispatcher\";\nimport { DomainRouter } from \"./DomainRouter\";\nimport { ViewRouteDispatcher } from \"./ViewRouteDispatcher\";\nimport type { ApiRouteConfig, DomainsConfig, McpRouteConfig, ViewRouteConfig } from \"./config\";\nimport type { Repository } from \"../../support/Repository\";\n\nfunction readConfig<T>(config: Repository, key: string): T {\n const slice = config.get<T>(key);\n if (!slice) {\n throw new Error(\n `Missing \"${key}\" configuration. Route dispatching needs a root router — declare it in \"app/config/route.ts\".`,\n );\n }\n return slice;\n}\n\n/**\n * Owns both route dispatchers. Laravel ships a single RouteServiceProvider for\n * every route file it loads; the api/view split is a config slice, not a\n * separate provider.\n */\nexport class RouteServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n ApiRouteDispatcher,\n () =>\n new ApiRouteDispatcher(\n readConfig<ApiRouteConfig>(this.app.config, \"route.api\"),\n ),\n );\n\n this.app.singleton(\n ViewRouteDispatcher,\n () =>\n new ViewRouteDispatcher(\n readConfig<ViewRouteConfig>(this.app.config, \"route.view\"),\n ),\n );\n\n // The root pair above is the root group's; the other `route.domains`\n // groups get their own only when they bring their own routers.\n this.app.singleton(\n DomainRouter,\n () =>\n new DomainRouter(\n { api: this.app.make(ApiRouteDispatcher), view: this.app.make(ViewRouteDispatcher) },\n {\n api: readConfig<ApiRouteConfig>(this.app.config, \"route.api\"),\n view: readConfig<ViewRouteConfig>(this.app.config, \"route.view\"),\n domains: this.app.config.get<DomainsConfig | undefined>(\"route.domains\"),\n },\n ),\n );\n\n // Bound whether or not the app declares one, so asking for it without\n // `route.mcp` fails with a sentence rather than an unbound token.\n this.app.singleton(McpRegistry, () => {\n const config = this.app.config.get<McpRouteConfig | undefined>(\"route.mcp\");\n if (!config?.router) {\n throw new Error(\n 'No MCP router is configured. Declare one as `mcp: { router }` in \"app/config/route.ts\".',\n );\n }\n return new McpRegistry(new config.router(), this.app.make(ApiRouteDispatcher));\n });\n }\n\n /**\n * The dispatchers of every host group, and the MCP registry when an app declares one, must\n * not be built lazily: constructing the dispatchers flattens the route\n * tables and runs `assertNoReservedRoutePaths`, and constructing the registry\n * resolves every tool against those tables. A missing `route` config, a\n * route under a reserved prefix or a tool naming a route that is gone has to\n * fail the boot rather than the first request, or the first tool call, that\n * happens to hit it.\n */\n boot() {\n this.app.make(ApiRouteDispatcher);\n this.app.make(ViewRouteDispatcher);\n // Builds every host group's dispatchers and validates `route.domains`.\n this.app.make(DomainRouter);\n if (this.app.config.get(\"route.mcp\")) {\n this.app.make(McpRegistry);\n }\n }\n}\n"
|
|
33
31
|
],
|
|
34
|
-
"mappings": ";0wBAmCA,SAAsB,JAAO,LAAC,JAA6B,LACzD,HAAI,LAQF,HAAI,LAAE,AAAM,JAAI,UAAU,KAAK,CAAG,EAChC,OAEF,MAAO,EAAO,CAMd,QAAQ,MACN,2CAA2C,EAAI,QAC/C,CACF,EACA,OAGF,GAAI,CACF,MAAM,EAAI,OAAO,KAAK,CAAG,EACzB,MAAO,EAAO,CACd,QAAQ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WAA6B,CAAgB,CACxD,QAAQ,EAAG,CACT,KAAK,IAAI,UACP,EACA,IACE,IAAI,EACF,EAA2B,KAAK,IAAI,OAAQ,WAAW,CACzD,CACJ,EAEA,KAAK,IAAI,UACP,EACA,IACE,IAAI,EACF,EAA4B,KAAK,IAAI,OAAQ,YAAY,CAC3D,CACJ,EAIA,KAAK,IAAI,UACP,EACA,IACE,IAAI,EACF,CAAE,IAAK,KAAK,IAAI,KAAK,CAAkB,EAAG,KAAM,KAAK,IAAI,KAAK,CAAmB,CAAE,EACnF,CACE,IAAK,EAA2B,KAAK,IAAI,OAAQ,WAAW,EAC5D,KAAM,EAA4B,KAAK,IAAI,OAAQ,YAAY,EAC/D,QAAS,KAAK,IAAI,OAAO,IAA+B,eAAe,CACzE,CACF,CACJ,EAIA,KAAK,IAAI,UAAU,EAAa,IAAM,CACpC,IAAM,EAAS,KAAK,IAAI,OAAO,IAAgC,WAAW,EAC1E,GAAI,CAAC,GAAQ,OACX,MAAU,MACR,yFACF,EAEF,OAAO,IAAI,EAAY,IAAI,EAAO,OAAU,KAAK,IAAI,KAAK,CAAkB,CAAC,EAC9E,EAYH,IAAI,EAAG,CAKL,GAJA,KAAK,IAAI,KAAK,CAAkB,EAChC,KAAK,IAAI,KAAK,CAAmB,EAEjC,KAAK,IAAI,KAAK,CAAY,EACtB,KAAK,IAAI,OAAO,IAAI,WAAW,EACjC,KAAK,IAAI,KAAK,CAAW,EAG/B",
|
|
33
|
+
"debugId": "3E596CFE4FBC3FEB64756E2164756E21",
|
|
36
34
|
"names": []
|
|
37
35
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{h as b,j as T}from"./chunk-
|
|
2
|
+
import{h as b,j as T}from"./chunk-b9dejyaq.js";import{ia as M,ja as N}from"./chunk-53we503k.js";import"./chunk-zq5m4scz.js";import"./chunk-9a8qz3s7.js";import"./chunk-gvkydx8r.js";import"./chunk-8z37k28d.js";import"./chunk-vfrrzr10.js";import{zg as S}from"./chunk-kb3xk9r8.js";import"./chunk-zfch4da5.js";import{join as u}from"path";import{createServer as v}from"vite";import{join as E}from"path";import{IncomingMessage as P,ServerResponse as k}from"http";import{Socket as q}from"net";function w(J){return J.replace(/\x1b\[[0-9;]*m/g,"").replace(/\[[0-9;]*m/g,"").replace(/\n\s*\n/g,`
|
|
3
3
|
`).split(`
|
|
4
4
|
`).map((K)=>K.trim()).filter((K)=>K.length>0).join(`
|
|
5
5
|
`).trim()}function D(J){return`
|
|
@@ -52,4 +52,4 @@ ${U} | ${Y}
|
|
|
52
52
|
window.__vite_plugin_react_preamble_installed__ = true;
|
|
53
53
|
`,{headers:{"Content-Type":"application/javascript"}});return null}function f(J,K,O){let Q=E(process.cwd(),"app");return async(U)=>{let{pathname:Y}=new URL(U.url),B=(W)=>{if(console.error(W),O.ssrFixStacktrace?.(W),X(W),S(Y))return new Response(JSON.stringify({error:W?.message??String(W)}),{status:500,headers:{"Content-Type":"application/json"}});return globalThis.__gemiErrorPageServed=!0,new Response(D(H(W)),{status:500,headers:{"Content-Type":"text/html"}})},Z=async(W)=>{let L=c(W);if(L)return L;try{let z=J.fetch.bind(J),G=await d(O,W)??await z(W);if(G instanceof Response)return G;let C={},y={},I={},R=($,j)=>`"${$}": () => import("${j}")`,x=[];for(let $ of["404",...J.getFlatComponentTree.call(J)]){if(Bun.env.NODE_ENV==="test")break;let j=`${process.env.APP_DIR}`,A=await _(O).import(`${j}/views/${$}.tsx`);C[$]=A.default,y[$]=A?.OpenGraph,I[$]=A,x.push(R($,`/app/views/${$}.tsx`))}let g=`{${x.join(",")}}`;return await G({getStyles:async($)=>await b(Q,O,$),bootstrapModules:["/refresh.js","/app/client.tsx","/@vite/client"],viewImportMap:C,viewModules:I,ogMap:y,loaders:g,cssManifest:{}})}catch(z){return B(z)}};return await K(U,(W)=>J.withGlobalMiddleware(W,Z,B))}}function h(J){try{return Bun.listen({hostname:"0.0.0.0",port:J,socket:{data(){}}}).stop(!0),!0}catch(K){return K?.code!=="EADDRINUSE"}}function F(J,K=h){let O=24678+(J-5173);if(O>65471)O=24678;for(let Q=O;Q<O+64;Q++)if(K(Q))return Q;throw Error(`Could not find a free port for Vite's HMR websocket: tried ${O}-${O+64-1}. Set one explicitly in gemi.config.ts as \`vite: { server: { ws: { port } } }\`.`)}var V=process.cwd(),l=u(V,"app");if(!globalThis.__gemiErrorHooked)globalThis.__gemiErrorHooked=!0,process.on("unhandledRejection",(J)=>{console.error(J),X(J)}),process.on("uncaughtException",(J)=>{console.error(J),X(J)});async function ZJ(J,K){let O=Number(process.env.PORT)||5173,Q=Boolean(globalThis.__gemiVite),U=globalThis.__gemiVite??=await v({configFile:!1,plugins:[N()],server:{middlewareMode:!0,ws:{port:F(O)},allowedHosts:J.devAllowedHosts.call(J),watch:{ignored:(B)=>{let Z=B.split(/[/\\]/).pop()??"";return Z===".env"||Z.startsWith(".env.")}}},appType:"custom",resolve:{dedupe:["react","react-dom"]},optimizeDeps:{include:["react","react-dom","react-dom/client"]},ssr:{external:[...M]}});process.env.ROOT_DIR=V,process.env.APP_DIR=l;let Y=Bun.serve({port:O,fetch:f(J,K,U)});if(Q)_(U).clearCache();if(Q)if(globalThis.__gemiErrorActive&&globalThis.__gemiErrorPageServed)globalThis.__gemiErrorActive=!1,globalThis.__gemiErrorPageServed=!1,U.ws.send({type:"full-reload"});else globalThis.__gemiErrorActive=!1,U.ws.send({type:"custom",event:"http-reload"});else T({port:Y.port,rootDir:V});return Y}export{H as viteErrorPayload,ZJ as httpDev};
|
|
54
54
|
|
|
55
|
-
//# debugId=
|
|
55
|
+
//# debugId=8B888930C6E6E5E564756E2164756E21
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
"// Vite's HMR websocket needs a port of its own, and in middleware mode Vite\n// always picks the same one.\n//\n// `httpDev` runs Vite with `middlewareMode: true`, so Vite has no HTTP server of\n// its own to hang the websocket off — it stands up a second HTTP server just for\n// the upgrade. When nothing names a port, that server binds Vite's default 24678\n// in *every* `gemi dev` process. `PORT` moves the Bun server and nothing else, so\n// a second dev server logs\n//\n// WebSocket server error: Port undefined is already in use\n//\n// and carries on with a dead socket. (Vite logs that failure rather than throwing\n// — which is why the symptom is not a crash but pages that hot-reload on the\n// *other* checkout's edits: their `/@vite/client` was told 24678, and 24678 is\n// the first server's.) So gemi names the port instead of letting Vite default it.\n//\n// Why derive from the HTTP port rather than just scan for a free one: two dev\n// servers must already differ in `PORT` to run at all, so deriving makes their\n// HMR ports differ *before* either one binds anything. A scan alone would hand\n// both the same port when they start at the same moment, each having probed\n// before the other bound. The scan is still here, for the port being taken by\n// something that is not a gemi dev server.\n\nconst VITE_DEFAULT_HTTP_PORT = 5173;\nconst VITE_DEFAULT_HMR_PORT = 24678;\n\n// A port is 16 bits.\nconst MAX_PORT = 65535;\n\n// How far to walk up from the derived port before giving up. Large enough that\n// only a pathological machine exhausts it, small enough to fail in well under a\n// second rather than appearing to hang.\nconst SEARCH_WINDOW = 64;\n\n/**\n * Bind-test a port the same way Vite will.\n *\n * Vite calls `wsHttpServer.listen(port, host)` with no host unless one is\n * configured, so its websocket server takes the wildcard address — which is what\n * this binds too. The match matters: a wildcard bind collides with a wildcard\n * *or* a loopback holder, while a loopback bind only collides with loopback. A\n * process holding `127.0.0.1:P` alone therefore reads as free here, correctly —\n * Vite would fail to bind `*:P` against it, but nothing in gemi makes Vite bind\n * loopback-only, so that case cannot arise from a second `gemi dev`.\n *\n * Only `EADDRINUSE` counts as taken. Any other failure — a permission error, an\n * unroutable address — is not something a different port would fix, so it is\n * reported free and left for Vite to surface.\n */\nfunction isPortFree(port: number): boolean {\n try {\n const listener = Bun.listen({\n hostname: \"0.0.0.0\",\n port,\n socket: { data() {} },\n });\n // `true` closes active connections too. There are none — nothing has been\n // told this port exists yet — but it also makes the close synchronous, so\n // the port is released before the next probe or before Vite binds it.\n listener.stop(true);\n return true;\n } catch (error) {\n return (error as { code?: string })?.code !== \"EADDRINUSE\";\n }\n}\n\n/**\n * Pick the port for Vite's HMR websocket, given the port the dev server's HTTP\n * side is on.\n *\n * `5173` returns `24678` — Vite's two defaults stay paired, so a single dev\n * server behaves exactly as it did before, and anything pointed at 24678 (a\n * firewall rule, a container port mapping, a note in a README) keeps working.\n * Every other HTTP port is offset by the same distance, so distinct `PORT`s\n * always yield distinct HMR ports.\n *\n * @param isFree Injected for tests. Production callers use the bind test above.\n */\nexport function resolveHmrPort(\n httpPort: number,\n isFree: (port: number) => boolean = isPortFree,\n): number {\n let start = VITE_DEFAULT_HMR_PORT + (httpPort - VITE_DEFAULT_HTTP_PORT);\n\n // A high `PORT` can push the derived port past the top of the range — or so\n // close to it that the walk would run off the end. Fall back to the default\n // and let the scan sort it out; being *adjacent* to another server's port is\n // fine, landing *on* it is what has to be avoided, and the scan does that.\n //\n // There is deliberately no matching floor. The offset is only -5173, so the\n // lowest a real HTTP port can derive is 19505 (from `PORT=0`) — a guard for\n // the bottom of the range would be a branch no input can take.\n if (start > MAX_PORT - SEARCH_WINDOW) {\n start = VITE_DEFAULT_HMR_PORT;\n }\n\n for (let port = start; port < start + SEARCH_WINDOW; port++) {\n if (isFree(port)) return port;\n }\n\n throw new Error(\n `Could not find a free port for Vite's HMR websocket: tried ${start}-${\n start + SEARCH_WINDOW - 1\n }. Set one explicitly in gemi.config.ts as \\`vite: { server: { ws: { port } } }\\`.`,\n );\n}\n"
|
|
9
9
|
],
|
|
10
10
|
"mappings": ";iWAAA,SAAS,OAET,iBAAS,OCFT,SAAS,OACT,oBAAS,cAAiB,aAC1B,iBAAS,YCFT,SAAS,CAAmB,CAAC,EAAM,CACjC,OACE,EAEG,QAAQ,kBAAmB,EAAE,EAE7B,QAAQ,cAAe,EAAE,EAEzB,QAAQ,WAAY;AAAA,CAAI,EAExB,MAAM;AAAA,CAAI,EACV,IAAI,CAAC,IAAS,EAAK,KAAK,CAAC,EACzB,OAAO,CAAC,IAAS,EAAK,OAAS,CAAC,EAChC,KAAK;AAAA,CAAI,EACT,KAAK,EAIL,SAAS,CAAe,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,SAAQ,CAAC,EAGnD,OAAO",
|
|
11
|
-
"debugId": "
|
|
11
|
+
"debugId": "8B888930C6E6E5E564756E2164756E21",
|
|
12
12
|
"names": []
|
|
13
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var R=/^[a-z]{2,3}(?:[-_][a-z0-9]{2,8})*$/i;function S(j){return R.test(j)}function P(j){return j.split(/[-_]/)[0].toLowerCase()}function Q(j,B,F){let I=j?.split(";")[0].trim();if(!I||!S(I))return null;let H=I.replaceAll("_","-").toLowerCase(),J=B.find((N)=>N.toLowerCase()===H);if(J)return J;let M=P(I),K=B.filter((N)=>P(N)===M);if(K.length===0)return null;if(F&&K.includes(F))return F;return K[0]}class U{config;static token="translator";translations={};isEnabled=!1;constructor(j){this.config=j;let B={};for(let[F,I]of Object.entries(this.config.prefetch))for(let H of this.config.supportedLocales){if(!B[H])B[H]={};B[H][F]={};for(let J of I){B[H][F][J.name]={};for(let[M,K]of Object.entries(J.dictionary))this.isEnabled=!0,B[H][F][J.name][M]=K[H]}}this.translations=B}get isLocaleAware(){return this.isEnabled||this.config.supportedLocales.length>0}get supportedLocales(){return this.config.supportedLocales}get defaultLocale(){return this.config.defaultLocale}get components(){return this.config.components}onLocaleChange(j){return this.config.onLocaleChange(j)}detectLocale(j){let B=this.config.defaultLocale??this.config.supportedLocales[0]??"en-US",F=(M)=>Q(M,this.config.supportedLocales,this.config.defaultLocale),I=F(this.config.detectLocale(j));if(I)return I;let H=F(j.cookies.get("i18n-locale"));if(H)return H;let J=j.headers.get("accept-language")??"";for(let M of J.split(",")){let K=F(M);if(K)return K}return B}getPageTranslations(j,B){if(this.translations[j][B])return this.translations[j][B];return{}}}
|
|
3
|
-
export{Q as
|
|
3
|
+
export{Q as hg,U as ig};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=313EB849025F2CD064756E2164756E21
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
"import type { HttpRequest } from \"../http/HttpRequest\";\nimport type { Dictionary } from \"./Dictionary\";\nimport type { TranslationConfig } from \"./config\";\nimport { resolveLocale } from \"./resolveLocale\";\n\nexport class Translator {\n static token = \"translator\";\n\n translations = {};\n isEnabled = false;\n\n constructor(public config: Required<TranslationConfig>) {\n const translations = {};\n\n for (const [route, dicArray] of Object.entries(this.config.prefetch)) {\n for (const locale of this.config.supportedLocales) {\n if (!translations[locale]) {\n translations[locale] = {};\n }\n translations[locale][route] = {};\n for (const dic of dicArray) {\n translations[locale][route][dic.name] = {};\n for (const [key, value] of Object.entries(dic.dictionary)) {\n this.isEnabled = true;\n translations[locale][route][dic.name][key] = value[locale];\n }\n }\n }\n }\n this.translations = translations;\n }\n\n /**\n * Whether the app does locale-aware routing and rendering at all.\n *\n * `isEnabled` only means the legacy `prefetch` config has dictionaries to\n * serve. An app on `defineDictionary` has an empty `prefetch` and declares\n * its locales through `supportedLocales` alone, so gating on `isEnabled`\n * leaves it without locale detection or a locale URL prefix. Both the render\n * path and the redirect read this, because when they disagreed a migrated app\n * rendered a non-default locale at `/` with no redirect and no `Vary` — one\n * cache fill away from serving that document to everyone.\n */\n get isLocaleAware(): boolean {\n return this.isEnabled || this.config.supportedLocales.length > 0;\n }\n\n get supportedLocales(): string[] {\n return this.config.supportedLocales;\n }\n\n get defaultLocale(): string {\n return this.config.defaultLocale;\n }\n\n get components(): Record<string, Dictionary<any>> {\n return this.config.components;\n }\n\n onLocaleChange(locale: string): Promise<void> | void {\n return this.config.onLocaleChange(locale);\n }\n\n detectLocale(req: HttpRequest<any, any>) {\n const fallbackLocale =\n this.config.defaultLocale ?? this.config.supportedLocales[0] ?? \"en-US\";\n const resolve = (tag: string | null | undefined) =>\n resolveLocale(tag, this.config.supportedLocales, this.config.defaultLocale);\n\n const detectedLocale = resolve(this.config.detectLocale(req));\n if (detectedLocale) {\n return detectedLocale;\n }\n\n const previousLocale = resolve(req.cookies.get(\"i18n-locale\"));\n if (previousLocale) {\n return previousLocale;\n }\n\n // Entries are in the browser's preference order; the first one the app can\n // serve, even by language alone (`de-AT` → `de-DE`), wins.\n const acceptLanguage = req.headers.get(\"accept-language\") ?? \"\";\n for (const entry of acceptLanguage.split(\",\")) {\n const locale = resolve(entry);\n if (locale) {\n return locale;\n }\n }\n\n return fallbackLocale;\n }\n\n getPageTranslations(locale: string, scope: string) {\n if (this.translations[locale][scope]) {\n return this.translations[locale][scope];\n }\n return {};\n }\n}\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": ";AAGA,IAAM,EAAa,sCAEZ,SAAS,CAAe,CAAC,EAA0B,CACxD,OAAO,EAAW,KAAK,CAAO,EAGhC,SAAS,CAAU,CAAC,EAAqB,CACvC,OAAO,EAAI,MAAM,MAAM,EAAE,GAAG,YAAY,EAYnC,SAAS,CAAa,CAC3B,EACA,EACA,EACe,CAEf,IAAM,EAAM,GAAW,MAAM,GAAG,EAAE,GAAG,KAAK,EAC1C,GAAI,CAAC,GAAO,CAAC,EAAgB,CAAG,EAC9B,OAAO,KAGT,IAAM,EAAa,EAAI,WAAW,IAAK,GAAG,EAAE,YAAY,EAClD,EAAQ,EAAiB,KAAK,CAAC,IAAM,EAAE,YAAY,IAAM,CAAU,EACzE,GAAI,EACF,OAAO,EAGT,IAAM,EAAW,EAAW,CAAG,EACzB,EAAe,EAAiB,OAAO,CAAC,IAAM,EAAW,CAAC,IAAM,CAAQ,EAC9E,GAAI,EAAa,SAAW,EAC1B,OAAO,KAET,GAAI,GAAiB,EAAa,SAAS,CAAa,EACtD,OAAO,EAET,OAAO,EAAa,GC1Cf,MAAM,CAAW,CAMH,aALZ,OAAQ,aAEf,aAAe,CAAC,EAChB,UAAY,GAEZ,WAAW,CAAQ,EAAqC,CAArC,cACjB,IAAM,EAAe,CAAC,EAEtB,QAAY,EAAO,KAAa,OAAO,QAAQ,KAAK,OAAO,QAAQ,EACjE,QAAW,KAAU,KAAK,OAAO,iBAAkB,CACjD,GAAI,CAAC,EAAa,GAChB,EAAa,GAAU,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-1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{_ as J}from"./chunk-
|
|
2
|
+
import{_ as J}from"./chunk-rqh2wdhb.js";import{Cg as I}from"./chunk-zfch4da5.js";var Z=I((Q)=>{var K=J(),L=(b)=>{return{setHttpHandler(j){b.httpHandler=j},httpHandler(){return b.httpHandler},updateHttpClientConfig(j,w){b.httpHandler?.updateHttpClientConfig(j,w)},httpHandlerConfigs(){return b.httpHandler.httpHandlerConfigs()}}},M=(b)=>{return{httpHandler:b.httpHandler()}};class B{name;kind;values;constructor({name:b,kind:j=K.FieldPosition.HEADER,values:w=[]}){this.name=b,this.kind=j,this.values=w}add(b){this.values.push(b)}set(b){this.values=b}remove(b){this.values=this.values.filter((j)=>j!==b)}toString(){return this.values.map((b)=>b.includes(",")||b.includes(" ")?`"${b}"`:b).join(", ")}get(){return this.values}}class D{entries={};encoding;constructor({fields:b=[],encoding:j="utf-8"}){b.forEach(this.setField.bind(this)),this.encoding=j}setField(b){this.entries[b.name.toLowerCase()]=b}getField(b){return this.entries[b.toLowerCase()]}removeField(b){delete this.entries[b.toLowerCase()]}getByType(b){return Object.values(this.entries).filter((j)=>j.kind===b)}}class z{method;protocol;hostname;port;path;query;headers;username;password;fragment;body;constructor(b){this.method=b.method||"GET",this.hostname=b.hostname||"localhost",this.port=b.port,this.query=b.query||{},this.headers=b.headers||{},this.body=b.body,this.protocol=b.protocol?b.protocol.slice(-1)!==":"?`${b.protocol}:`:b.protocol:"https:",this.path=b.path?b.path.charAt(0)!=="/"?`/${b.path}`:b.path:"/",this.username=b.username,this.password=b.password,this.fragment=b.fragment}static clone(b){let j=new z({...b,headers:{...b.headers}});if(j.query)j.query=O(j.query);return j}static isInstance(b){if(!b)return!1;let j=b;return"method"in j&&"protocol"in j&&"hostname"in j&&"path"in j&&typeof j.query==="object"&&typeof j.headers==="object"}clone(){return z.clone(this)}}function O(b){return Object.keys(b).reduce((j,w)=>{let A=b[w];return{...j,[w]:Array.isArray(A)?[...A]:A}},{})}class G{statusCode;reason;headers;body;constructor(b){this.statusCode=b.statusCode,this.reason=b.reason,this.headers=b.headers||{},this.body=b.body}static isInstance(b){if(!b)return!1;let j=b;return typeof j.statusCode==="number"&&typeof j.headers==="object"}}function P(b){return/^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/.test(b)}Q.Field=B;Q.Fields=D;Q.HttpRequest=z;Q.HttpResponse=G;Q.getHttpHandlerExtensionConfiguration=L;Q.isValidHostname=P;Q.resolveHttpHandlerRuntimeConfig=M});
|
|
3
3
|
export{Z as U};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=CF85C5BB208F60A364756E2164756E21
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"'use strict';\n\nvar types = require('@smithy/types');\n\nconst getHttpHandlerExtensionConfiguration = (runtimeConfig) => {\n return {\n setHttpHandler(handler) {\n runtimeConfig.httpHandler = handler;\n },\n httpHandler() {\n return runtimeConfig.httpHandler;\n },\n updateHttpClientConfig(key, value) {\n runtimeConfig.httpHandler?.updateHttpClientConfig(key, value);\n },\n httpHandlerConfigs() {\n return runtimeConfig.httpHandler.httpHandlerConfigs();\n },\n };\n};\nconst resolveHttpHandlerRuntimeConfig = (httpHandlerExtensionConfiguration) => {\n return {\n httpHandler: httpHandlerExtensionConfiguration.httpHandler(),\n };\n};\n\nclass Field {\n name;\n kind;\n values;\n constructor({ name, kind = types.FieldPosition.HEADER, values = [] }) {\n this.name = name;\n this.kind = kind;\n this.values = values;\n }\n add(value) {\n this.values.push(value);\n }\n set(values) {\n this.values = values;\n }\n remove(value) {\n this.values = this.values.filter((v) => v !== value);\n }\n toString() {\n return this.values.map((v) => (v.includes(\",\") || v.includes(\" \") ? `\"${v}\"` : v)).join(\", \");\n }\n get() {\n return this.values;\n }\n}\n\nclass Fields {\n entries = {};\n encoding;\n constructor({ fields = [], encoding = \"utf-8\" }) {\n fields.forEach(this.setField.bind(this));\n this.encoding = encoding;\n }\n setField(field) {\n this.entries[field.name.toLowerCase()] = field;\n }\n getField(name) {\n return this.entries[name.toLowerCase()];\n }\n removeField(name) {\n delete this.entries[name.toLowerCase()];\n }\n getByType(kind) {\n return Object.values(this.entries).filter((field) => field.kind === kind);\n }\n}\n\nclass HttpRequest {\n method;\n protocol;\n hostname;\n port;\n path;\n query;\n headers;\n username;\n password;\n fragment;\n body;\n constructor(options) {\n this.method = options.method || \"GET\";\n this.hostname = options.hostname || \"localhost\";\n this.port = options.port;\n this.query = options.query || {};\n this.headers = options.headers || {};\n this.body = options.body;\n this.protocol = options.protocol\n ? options.protocol.slice(-1) !== \":\"\n ? `${options.protocol}:`\n : options.protocol\n : \"https:\";\n this.path = options.path ? (options.path.charAt(0) !== \"/\" ? `/${options.path}` : options.path) : \"/\";\n this.username = options.username;\n this.password = options.password;\n this.fragment = options.fragment;\n }\n static clone(request) {\n const cloned = new HttpRequest({\n ...request,\n headers: { ...request.headers },\n });\n if (cloned.query) {\n cloned.query = cloneQuery(cloned.query);\n }\n return cloned;\n }\n static isInstance(request) {\n if (!request) {\n return false;\n }\n const req = request;\n return (\"method\" in req &&\n \"protocol\" in req &&\n \"hostname\" in req &&\n \"path\" in req &&\n typeof req[\"query\"] === \"object\" &&\n typeof req[\"headers\"] === \"object\");\n }\n clone() {\n return HttpRequest.clone(this);\n }\n}\nfunction cloneQuery(query) {\n return Object.keys(query).reduce((carry, paramName) => {\n const param = query[paramName];\n return {\n ...carry,\n [paramName]: Array.isArray(param) ? [...param] : param,\n };\n }, {});\n}\n\nclass HttpResponse {\n statusCode;\n reason;\n headers;\n body;\n constructor(options) {\n this.statusCode = options.statusCode;\n this.reason = options.reason;\n this.headers = options.headers || {};\n this.body = options.body;\n }\n static isInstance(response) {\n if (!response)\n return false;\n const resp = response;\n return typeof resp.statusCode === \"number\" && typeof resp.headers === \"object\";\n }\n}\n\nfunction isValidHostname(hostname) {\n const hostPattern = /^[a-z0-9][a-z0-9\\.\\-]*[a-z0-9]$/;\n return hostPattern.test(hostname);\n}\n\nexports.Field = Field;\nexports.Fields = Fields;\nexports.HttpRequest = HttpRequest;\nexports.HttpResponse = HttpResponse;\nexports.getHttpHandlerExtensionConfiguration = getHttpHandlerExtensionConfiguration;\nexports.isValidHostname = isValidHostname;\nexports.resolveHttpHandlerRuntimeConfig = resolveHttpHandlerRuntimeConfig;\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";qGAEA,FAAI,MAEE,EAAuC,CAAC,IAAkB,CAC5D,MAAO,CACH,cAAc,CAAC,EAAS,CACpB,EAAc,YAAc,GAEhC,WAAW,EAAG,CACV,OAAO,EAAc,aAEzB,sBAAsB,CAAC,EAAK,EAAO,CAC/B,EAAc,aAAa,uBAAuB,EAAK,CAAK,GAEhE,kBAAkB,EAAG,CACjB,OAAO,EAAc,YAAY,mBAAmB,EAE5D,GAEE,EAAkC,CAAC,IAAsC,CAC3E,MAAO,CACH,YAAa,EAAkC,YAAY,CAC/D,GAGJ,MAAM,CAAM,CACR,KACA,KACA,OACA,WAAW,EAAG,OAAM,OAAO,EAAM,cAAc,OAAQ,SAAS,CAAC,GAAK,CAClE,KAAK,KAAO,EACZ,KAAK,KAAO,EACZ,KAAK,OAAS,EAElB,GAAG,CAAC,EAAO,CACP,KAAK,OAAO,KAAK,CAAK,EAE1B,GAAG,CAAC,EAAQ,CACR,KAAK,OAAS,EAElB,MAAM,CAAC,EAAO,CACV,KAAK,OAAS,KAAK,OAAO,OAAO,CAAC,IAAM,IAAM,CAAK,EAEvD,QAAQ,EAAG,CACP,OAAO,KAAK,OAAO,IAAI,CAAC,IAAO,EAAE,SAAS,GAAG,GAAK,EAAE,SAAS,GAAG,EAAI,IAAI,KAAO,CAAE,EAAE,KAAK,IAAI,EAEhG,GAAG,EAAG,CACF,OAAO,KAAK,OAEpB,CAEA,MAAM,CAAO,CACT,QAAU,CAAC,EACX,SACA,WAAW,EAAG,SAAS,CAAC,EAAG,WAAW,SAAW,CAC7C,EAAO,QAAQ,KAAK,SAAS,K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