gemi 0.216.0 → 0.218.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/AgentController.d.ts +85 -2
- package/dist/ai/AgentController.d.ts.map +1 -1
- package/dist/ai/AgentProvider.d.ts +20 -0
- package/dist/ai/AgentProvider.d.ts.map +1 -1
- package/dist/ai/FallbackProvider.d.ts +2 -0
- package/dist/ai/FallbackProvider.d.ts.map +1 -1
- package/dist/ai/index.d.ts +2 -1
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +42 -42
- package/dist/ai/index.js.map +5 -5
- package/dist/ai/live/harness.d.ts +1 -0
- package/dist/ai/live/harness.d.ts.map +1 -1
- package/dist/ai/providers/call.d.ts +10 -0
- package/dist/ai/providers/call.d.ts.map +1 -1
- package/dist/ai/providers/fakeProvider.d.ts +3 -0
- package/dist/ai/providers/fakeProvider.d.ts.map +1 -1
- package/dist/ai/store/Attachments.d.ts +98 -2
- package/dist/ai/store/Attachments.d.ts.map +1 -1
- package/dist/ai/store/FileOwners.d.ts +18 -0
- package/dist/ai/store/FileOwners.d.ts.map +1 -1
- package/dist/ai/store/index.d.ts +1 -1
- package/dist/ai/store/index.d.ts.map +1 -1
- package/dist/ai/testing/RecordingProvider.d.ts +2 -0
- package/dist/ai/testing/RecordingProvider.d.ts.map +1 -1
- package/dist/ai/testing/index.js +3 -3
- package/dist/ai/testing/index.js.map +3 -3
- package/dist/app/index.js +1 -1
- package/dist/bin/ai-client/kotlin.d.ts +13 -1
- package/dist/bin/ai-client/kotlin.d.ts.map +1 -1
- package/dist/bin/ai-client/swift.d.ts +10 -1
- package/dist/bin/ai-client/swift.d.ts.map +1 -1
- package/dist/bin/gemi.js +40 -22
- package/dist/bin/gemi.js.map +4 -4
- package/dist/bin/http-client/render.d.ts +5 -0
- package/dist/bin/http-client/render.d.ts.map +1 -0
- package/dist/bun/plugin.js +1 -1
- package/dist/bun/preload.js +1 -1
- package/dist/{chunk-0ah98rf4.js → chunk-17agj0r3.js} +2 -2
- package/dist/{chunk-0ah98rf4.js.map → chunk-17agj0r3.js.map} +1 -1
- package/dist/{chunk-c2c21b6g.js → chunk-1nw9jhpt.js} +2 -2
- package/dist/{chunk-c2c21b6g.js.map → chunk-1nw9jhpt.js.map} +1 -1
- package/dist/{chunk-362a52jj.js → chunk-3r7z4kc0.js} +2 -2
- package/dist/{chunk-362a52jj.js.map → chunk-3r7z4kc0.js.map} +1 -1
- package/dist/{chunk-t0519abr.js → chunk-4k3r37be.js} +2 -2
- package/dist/{chunk-t0519abr.js.map → chunk-4k3r37be.js.map} +1 -1
- package/dist/{chunk-2crfg0m7.js → chunk-4s72m6zx.js} +3 -3
- package/dist/{chunk-2crfg0m7.js.map → chunk-4s72m6zx.js.map} +1 -1
- package/dist/{chunk-v7bbn1m0.js → chunk-4sbrvmz9.js} +5 -5
- package/dist/{chunk-v7bbn1m0.js.map → chunk-4sbrvmz9.js.map} +3 -3
- package/dist/{chunk-5294qsfq.js → chunk-5gp49wph.js} +2 -2
- package/dist/{chunk-0z8h6t7k.js.map → chunk-5gp49wph.js.map} +1 -1
- package/dist/{chunk-w1my1q4q.js → chunk-5vdkqv17.js} +2 -2
- package/dist/{chunk-w1my1q4q.js.map → chunk-5vdkqv17.js.map} +1 -1
- package/dist/{chunk-dqw432zh.js → chunk-5wh3cw2x.js} +3 -3
- package/dist/{chunk-dqw432zh.js.map → chunk-5wh3cw2x.js.map} +1 -1
- package/dist/{chunk-ttz05z12.js → chunk-6b7z5h54.js} +2 -2
- package/dist/{chunk-ttz05z12.js.map → chunk-6b7z5h54.js.map} +1 -1
- package/dist/{chunk-mw4c05vw.js → chunk-6ncn8rdn.js} +2 -2
- package/dist/{chunk-mw4c05vw.js.map → chunk-6ncn8rdn.js.map} +1 -1
- package/dist/chunk-7081awrd.js +11 -0
- package/dist/{chunk-rqa04dtq.js.map → chunk-7081awrd.js.map} +4 -4
- package/dist/{chunk-j6j0qxam.js → chunk-7rmb1v9c.js} +2 -2
- package/dist/{chunk-j6j0qxam.js.map → chunk-7rmb1v9c.js.map} +1 -1
- package/dist/{chunk-wcj083k2.js → chunk-7t13vyzg.js} +3 -3
- package/dist/{chunk-wcj083k2.js.map → chunk-7t13vyzg.js.map} +1 -1
- package/dist/{chunk-bk1e8sah.js → chunk-7xe5vd4w.js} +2 -2
- package/dist/{chunk-bk1e8sah.js.map → chunk-7xe5vd4w.js.map} +1 -1
- package/dist/{chunk-cws2tsxg.js → chunk-8524ejgk.js} +2 -2
- package/dist/{chunk-cws2tsxg.js.map → chunk-8524ejgk.js.map} +1 -1
- package/dist/{chunk-twb7x8j8.js → chunk-9c8e4nkz.js} +2 -2
- package/dist/{chunk-twb7x8j8.js.map → chunk-9c8e4nkz.js.map} +1 -1
- package/dist/{chunk-p5n1tqqg.js → chunk-9g5qh1ya.js} +2 -2
- package/dist/{chunk-p5n1tqqg.js.map → chunk-9g5qh1ya.js.map} +1 -1
- package/dist/{chunk-yjshg4e5.js → chunk-9pvxexh1.js} +2 -2
- package/dist/{chunk-yjshg4e5.js.map → chunk-9pvxexh1.js.map} +1 -1
- package/dist/{chunk-kd6z1t9z.js → chunk-aes0ecnp.js} +3 -3
- package/dist/{chunk-kd6z1t9z.js.map → chunk-aes0ecnp.js.map} +1 -1
- package/dist/{chunk-0a796avj.js → chunk-at6zjajz.js} +2 -2
- package/dist/{chunk-0a796avj.js.map → chunk-at6zjajz.js.map} +1 -1
- package/dist/{chunk-htkw9qbv.js → chunk-b1pps9bj.js} +2 -2
- package/dist/{chunk-htkw9qbv.js.map → chunk-b1pps9bj.js.map} +1 -1
- package/dist/{chunk-btf3t4qa.js → chunk-b8tmmpcf.js} +2 -2
- package/dist/{chunk-btf3t4qa.js.map → chunk-b8tmmpcf.js.map} +1 -1
- package/dist/chunk-bcfwa370.js +5 -0
- package/dist/chunk-bcfwa370.js.map +13 -0
- package/dist/{chunk-ybmy1rts.js → chunk-c95ds04p.js} +2 -2
- package/dist/{chunk-ybmy1rts.js.map → chunk-c95ds04p.js.map} +1 -1
- package/dist/{chunk-y9fye7az.js → chunk-cwm5x7rf.js} +2 -2
- package/dist/{chunk-y9fye7az.js.map → chunk-cwm5x7rf.js.map} +1 -1
- package/dist/{chunk-djwmrvsq.js → chunk-d6056zme.js} +2 -2
- package/dist/{chunk-djwmrvsq.js.map → chunk-d6056zme.js.map} +1 -1
- package/dist/chunk-d6bgh2nr.js +5 -0
- package/dist/{chunk-texzdarz.js.map → chunk-d6bgh2nr.js.map} +1 -1
- package/dist/{chunk-z03ds1qe.js → chunk-dgna0e7g.js} +2 -2
- package/dist/{chunk-z03ds1qe.js.map → chunk-dgna0e7g.js.map} +1 -1
- package/dist/{chunk-1k6dn4ba.js → chunk-ee7xb9qr.js} +1 -1
- package/dist/{chunk-5ya7fbfg.js → chunk-eh3ktv8k.js} +2 -2
- package/dist/{chunk-5ya7fbfg.js.map → chunk-eh3ktv8k.js.map} +1 -1
- package/dist/{chunk-aqjjknyk.js → chunk-evgs2tr8.js} +2 -2
- package/dist/{chunk-aqjjknyk.js.map → chunk-evgs2tr8.js.map} +1 -1
- package/dist/{chunk-mv2d2njy.js → chunk-fhb00fjx.js} +2 -2
- package/dist/{chunk-mv2d2njy.js.map → chunk-fhb00fjx.js.map} +1 -1
- package/dist/{chunk-py69zwwv.js → chunk-fq7wkefg.js} +2 -2
- package/dist/{chunk-py69zwwv.js.map → chunk-fq7wkefg.js.map} +1 -1
- package/dist/{chunk-01r2cx3k.js → chunk-g178aect.js} +4 -4
- package/dist/{chunk-01r2cx3k.js.map → chunk-g178aect.js.map} +1 -1
- package/dist/{chunk-jr9f5r65.js → chunk-gt6eq1p2.js} +3 -3
- package/dist/{chunk-jr9f5r65.js.map → chunk-gt6eq1p2.js.map} +1 -1
- package/dist/{chunk-z54zefss.js → chunk-gxd1388t.js} +2 -2
- package/dist/{chunk-z54zefss.js.map → chunk-gxd1388t.js.map} +1 -1
- package/dist/{chunk-dpm875be.js → chunk-gxfyd8wr.js} +3 -3
- package/dist/{chunk-dpm875be.js.map → chunk-gxfyd8wr.js.map} +1 -1
- package/dist/{chunk-gkjsanjh.js → chunk-h6knw9f0.js} +1 -1
- package/dist/{chunk-shn9t4vg.js → chunk-hmtn7996.js} +2 -2
- package/dist/{chunk-shn9t4vg.js.map → chunk-hmtn7996.js.map} +1 -1
- package/dist/{chunk-6s48nq83.js → chunk-jzqywxpj.js} +2 -2
- package/dist/{chunk-6s48nq83.js.map → chunk-jzqywxpj.js.map} +1 -1
- package/dist/{chunk-mnfk2r8z.js → chunk-k8nsefzb.js} +2 -2
- package/dist/{chunk-mnfk2r8z.js.map → chunk-k8nsefzb.js.map} +1 -1
- package/dist/{chunk-xw241q0q.js → chunk-kggwk7hz.js} +1 -1
- package/dist/chunk-ktee4gy4.js +484 -0
- package/dist/chunk-ktee4gy4.js.map +23 -0
- package/dist/{chunk-hknnxxg6.js → chunk-m0pfdc1n.js} +3 -3
- package/dist/{chunk-hknnxxg6.js.map → chunk-m0pfdc1n.js.map} +1 -1
- package/dist/{chunk-yak9kt1x.js → chunk-m68cxnbv.js} +2 -2
- package/dist/{chunk-yak9kt1x.js.map → chunk-m68cxnbv.js.map} +1 -1
- package/dist/{chunk-5m0vh0rg.js → chunk-ncw3zjxm.js} +2 -2
- package/dist/{chunk-5m0vh0rg.js.map → chunk-ncw3zjxm.js.map} +1 -1
- package/dist/{chunk-6cge785m.js → chunk-nhebjh6n.js} +1 -1
- package/dist/{chunk-djpqt7kh.js → chunk-ppdfwnqw.js} +1 -1
- package/dist/{chunk-62b7paq5.js → chunk-prc4bcgp.js} +2 -2
- package/dist/{chunk-62b7paq5.js.map → chunk-prc4bcgp.js.map} +1 -1
- package/dist/{chunk-hea3rwj3.js → chunk-q0d45r2j.js} +2 -2
- package/dist/{chunk-hea3rwj3.js.map → chunk-q0d45r2j.js.map} +1 -1
- package/dist/{chunk-6669vjve.js → chunk-qa528feb.js} +2 -2
- package/dist/{chunk-6669vjve.js.map → chunk-qa528feb.js.map} +1 -1
- package/dist/{chunk-4zw9gaey.js → chunk-qstjm3cb.js} +2 -2
- package/dist/{chunk-4zw9gaey.js.map → chunk-qstjm3cb.js.map} +1 -1
- package/dist/{chunk-t5af0fjq.js → chunk-r90djdx6.js} +2 -2
- package/dist/{chunk-t5af0fjq.js.map → chunk-r90djdx6.js.map} +1 -1
- package/dist/{chunk-bw1mvk6n.js → chunk-rp2f9mq1.js} +2 -2
- package/dist/{chunk-bw1mvk6n.js.map → chunk-rp2f9mq1.js.map} +1 -1
- package/dist/{chunk-9k6swvf1.js → chunk-s7jwsbfd.js} +3 -3
- package/dist/{chunk-9k6swvf1.js.map → chunk-s7jwsbfd.js.map} +1 -1
- package/dist/{chunk-3pfrqzw8.js → chunk-sba3s380.js} +2 -2
- package/dist/{chunk-3pfrqzw8.js.map → chunk-sba3s380.js.map} +1 -1
- package/dist/{chunk-naj8bmj5.js → chunk-snt0523y.js} +2 -2
- package/dist/{chunk-naj8bmj5.js.map → chunk-snt0523y.js.map} +1 -1
- package/dist/{chunk-5cf59esb.js → chunk-sqqh78tf.js} +2 -2
- package/dist/{chunk-5cf59esb.js.map → chunk-sqqh78tf.js.map} +1 -1
- package/dist/{chunk-9pjvetym.js → chunk-sxxkkx75.js} +4 -4
- package/dist/{chunk-9pjvetym.js.map → chunk-sxxkkx75.js.map} +1 -1
- package/dist/{chunk-1hs2fxxx.js → chunk-tw338bbv.js} +2 -2
- package/dist/{chunk-1hs2fxxx.js.map → chunk-tw338bbv.js.map} +1 -1
- package/dist/{chunk-rzhgcajs.js → chunk-v0sgcy87.js} +1 -1
- package/dist/{chunk-8q3pnwtj.js → chunk-vawqmdh4.js} +2 -2
- package/dist/{chunk-8q3pnwtj.js.map → chunk-vawqmdh4.js.map} +1 -1
- package/dist/{chunk-c231j2e7.js → chunk-vck02shp.js} +2 -2
- package/dist/{chunk-c231j2e7.js.map → chunk-vck02shp.js.map} +1 -1
- package/dist/{chunk-knmh8ynk.js → chunk-vewxnk3g.js} +2 -2
- package/dist/{chunk-knmh8ynk.js.map → chunk-vewxnk3g.js.map} +1 -1
- package/dist/{chunk-7bywa721.js → chunk-w3ks9nz7.js} +2 -2
- package/dist/{chunk-7bywa721.js.map → chunk-w3ks9nz7.js.map} +1 -1
- package/dist/{chunk-k9pch3e6.js → chunk-w85wrer7.js} +2 -2
- package/dist/{chunk-k9pch3e6.js.map → chunk-w85wrer7.js.map} +1 -1
- package/dist/{chunk-g7vyn179.js → chunk-w9sw2kn7.js} +3 -3
- package/dist/{chunk-g7vyn179.js.map → chunk-w9sw2kn7.js.map} +1 -1
- package/dist/{chunk-95yr9y9v.js → chunk-ww62b10k.js} +2 -2
- package/dist/{chunk-95yr9y9v.js.map → chunk-ww62b10k.js.map} +1 -1
- package/dist/{chunk-a6yge4kh.js → chunk-xb0evp2m.js} +2 -2
- package/dist/{chunk-a6yge4kh.js.map → chunk-xb0evp2m.js.map} +1 -1
- package/dist/{chunk-g1th1dfa.js → chunk-xese0rng.js} +3 -3
- package/dist/{chunk-g1th1dfa.js.map → chunk-xese0rng.js.map} +1 -1
- package/dist/{chunk-cgkp0ypn.js → chunk-xf3wke41.js} +2 -2
- package/dist/{chunk-cgkp0ypn.js.map → chunk-xf3wke41.js.map} +1 -1
- package/dist/{chunk-mjyr8at2.js → chunk-xn7azkgd.js} +3 -3
- package/dist/{chunk-mjyr8at2.js.map → chunk-xn7azkgd.js.map} +1 -1
- package/dist/{chunk-gwe9hbds.js → chunk-xp5mmgfp.js} +2 -2
- package/dist/{chunk-gwe9hbds.js.map → chunk-xp5mmgfp.js.map} +1 -1
- package/dist/{chunk-kc1y747c.js → chunk-xyv3y476.js} +3 -3
- package/dist/{chunk-kc1y747c.js.map → chunk-xyv3y476.js.map} +1 -1
- package/dist/{chunk-0z8h6t7k.js → chunk-yedb5vvg.js} +2 -2
- package/dist/{chunk-5294qsfq.js.map → chunk-yedb5vvg.js.map} +1 -1
- package/dist/{chunk-b02yzfpk.js → chunk-ykshxc5k.js} +2 -2
- package/dist/{chunk-b02yzfpk.js.map → chunk-ykshxc5k.js.map} +1 -1
- package/dist/{chunk-zbxvyanj.js → chunk-yxtfg4wy.js} +2 -2
- package/dist/{chunk-zbxvyanj.js.map → chunk-yxtfg4wy.js.map} +1 -1
- package/dist/{chunk-7mg2ash8.js → chunk-zy6hj5cc.js} +2 -2
- package/dist/{chunk-7mg2ash8.js.map → chunk-zy6hj5cc.js.map} +1 -1
- package/dist/{chunk-xg5r0383.js → chunk-zyvmbqcx.js} +3 -3
- package/dist/{chunk-xg5r0383.js.map → chunk-zyvmbqcx.js.map} +1 -1
- package/dist/config/index.js +1 -1
- package/dist/console/run.js +2 -2
- package/dist/console/run.js.map +1 -1
- package/dist/container/index.js +2 -2
- package/dist/container/index.js.map +1 -1
- package/dist/database/index.js +2 -2
- package/dist/database/index.js.map +1 -1
- package/dist/email/index.js +2 -2
- package/dist/email/index.js.map +1 -1
- package/dist/facades/index.js +2 -2
- package/dist/facades/index.js.map +1 -1
- package/dist/foundation/index.js +2 -2
- package/dist/foundation/index.js.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +1 -1
- package/dist/i18n/dictionaryRuntime.js +2 -2
- package/dist/i18n/dictionaryRuntime.js.map +1 -1
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/index.js.map +1 -1
- package/dist/kernel/index.js +2 -2
- package/dist/kernel/index.js.map +1 -1
- package/dist/orm/index.js +2 -2
- package/dist/orm/index.js.map +1 -1
- package/dist/probe/index.js +2 -2
- package/dist/probe/index.js.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/services/index.d.ts +2 -2
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +2 -2
- package/dist/services/index.js.map +1 -1
- package/dist/services/queue/DatabaseQueueDriver.d.ts +8 -1
- package/dist/services/queue/DatabaseQueueDriver.d.ts.map +1 -1
- package/dist/services/queue/work.js +2 -2
- package/dist/services/queue/work.js.map +1 -1
- package/dist/services/queue/workflow/DatabaseWorkflowStore.d.ts +20 -1
- package/dist/services/queue/workflow/DatabaseWorkflowStore.d.ts.map +1 -1
- package/dist/services/queue/workflow/MemoryWorkflowStore.d.ts +12 -1
- package/dist/services/queue/workflow/MemoryWorkflowStore.d.ts.map +1 -1
- package/dist/services/queue/workflow/Step.d.ts +131 -2
- package/dist/services/queue/workflow/Step.d.ts.map +1 -1
- package/dist/services/queue/workflow/Workflow.d.ts +18 -2
- package/dist/services/queue/workflow/Workflow.d.ts.map +1 -1
- package/dist/services/queue/workflow/WorkflowRuntime.d.ts +6 -0
- package/dist/services/queue/workflow/WorkflowRuntime.d.ts.map +1 -1
- package/dist/services/queue/workflow/WorkflowStore.d.ts +67 -3
- package/dist/services/queue/workflow/WorkflowStore.d.ts.map +1 -1
- package/dist/services/queue/workflow/workflowContract.d.ts +2 -0
- package/dist/services/queue/workflow/workflowContract.d.ts.map +1 -1
- package/dist/stats/route-table.js +1 -1
- package/dist/support/index.js +2 -2
- package/dist/support/index.js.map +1 -1
- package/dist/vitest/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-g1b6zetz.js +0 -5
- package/dist/chunk-g1b6zetz.js.map +0 -13
- package/dist/chunk-q677pnq5.js +0 -416
- package/dist/chunk-q677pnq5.js.map +0 -23
- package/dist/chunk-rqa04dtq.js +0 -11
- package/dist/chunk-texzdarz.js +0 -5
- /package/dist/{chunk-1k6dn4ba.js.map → chunk-ee7xb9qr.js.map} +0 -0
- /package/dist/{chunk-gkjsanjh.js.map → chunk-h6knw9f0.js.map} +0 -0
- /package/dist/{chunk-xw241q0q.js.map → chunk-kggwk7hz.js.map} +0 -0
- /package/dist/{chunk-6cge785m.js.map → chunk-nhebjh6n.js.map} +0 -0
- /package/dist/{chunk-djpqt7kh.js.map → chunk-ppdfwnqw.js.map} +0 -0
- /package/dist/{chunk-rzhgcajs.js.map → chunk-v0sgcy87.js.map} +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../ai/redact.ts", "../ai/store/Attachments.ts", "../ai/runtime.ts", "../ai/providers/errors.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { AgentError, AgentErrorCode, ProviderErrorDetail } from \"./types\";\n\n/**\n * A tool failure whose message is meant to be read: by the model, which can\n * act on it, and by the client, which shows it.\n *\n * Any other exception a tool throws reaches the model and the client as a\n * generic sentence (see `redactError`), because its message is whatever the\n * code underneath happened to say: a database driver's connection string, an\n * internal hostname, a third party's error body. The full error is logged.\n * Throw this instead when the message is written for the person:\n *\n * ```ts\n * if (!order) throw new ToolError(`There is no order ${input.orderId}.`);\n * ```\n */\nexport class ToolError extends Error {\n /** Whether the model may try the call again. Default `true`. */\n readonly retryable: boolean;\n\n constructor(message: string, options: { retryable?: boolean; cause?: unknown } = {}) {\n super(message, options.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = \"ToolError\";\n this.retryable = options.retryable ?? true;\n }\n}\n\n/**\n * Where an error being redacted came from, with the unredacted detail.\n *\n * - `run`: the run's own failure, on its `error` frame. `failure` is what\n * `result().error` returns: the provider's own message, its HTTP status and\n * request id, and its error `providerType` / `providerCode` /\n * `providerParam` (#1302).\n * - `tool`: a tool threw. `cause` is what it threw; the result the model and\n * the client read is the redacted one.\n */\nexport type ErrorRedactionInfo =\n | {\n source: \"run\";\n failure: AgentError & ProviderErrorDetail;\n }\n | {\n source: \"tool\";\n toolName: string;\n cause: unknown;\n };\n\n/**\n * Decides what a client (and, for a tool, the model) is told about a failure.\n * Return the error to send. Full detail is never lost: it stays on\n * `result().error`, in the log and in the controller's `onError`.\n */\nexport type ErrorRedactor = (error: AgentError, info: ErrorRedactionInfo) => AgentError;\n\n/**\n * The run failures whose message comes from outside gemi: a provider's error\n * body or an exception's text. Those can carry resource and deployment names,\n * internal URLs, request ids and, in a provider's validation message, pieces of\n * the request itself. The rest (`timeout`, `invalid_output`, `aborted`, ...)\n * are sentences gemi wrote and are kept.\n */\nconst GENERIC_RUN_MESSAGES: Partial<Record<AgentErrorCode, string>> = {\n provider_error: \"The model provider returned an error.\",\n rate_limited: \"The model provider is rate limiting requests. Try again shortly.\",\n context_length_exceeded: \"The conversation is too long for the model.\",\n content_filtered: \"The model provider's content filter blocked this request.\",\n invalid_tool_input: \"The model provider rejected the request.\",\n tool_error: \"A tool failed.\",\n unknown: \"The run failed unexpectedly.\",\n};\n\n/**\n * The default redaction, and what an override of `AgentController.redactError`\n * falls back to.\n *\n * Keeps `code`, `retryable` and `toolCallId`, which are what a client branches\n * on, and replaces a message that did not come from gemi with a fixed sentence\n * for its code. A tool's exception keeps its message only when it is a\n * `ToolError`.\n */\nexport function redactError(error: AgentError, info: ErrorRedactionInfo): AgentError {\n if (info.source === \"tool\") {\n if (info.cause instanceof ToolError) return error;\n return {\n ...error,\n message: `The tool \"${info.toolName}\" failed with an unexpected error.`,\n };\n }\n const generic = GENERIC_RUN_MESSAGES[error.code];\n return generic === undefined ? error : { ...error, message: generic };\n}\n\n/**\n * Runs an app's redactor and keeps only the `AgentError` fields of what it\n * returns, so a redactor that spreads the failure (`{ ...info.failure }`)\n * cannot put its status or request id on the wire by accident. A redactor\n * that throws falls back to the default rather than to the unredacted error.\n */\nexport function applyRedaction(\n redactor: ErrorRedactor | undefined,\n error: AgentError,\n info: ErrorRedactionInfo,\n onFailure: (err: unknown) => void,\n): AgentError {\n let out: AgentError;\n try {\n out = (redactor ?? redactError)(error, info);\n } catch (err) {\n onFailure(err);\n out = redactError(error, info);\n }\n return {\n code: out.code,\n message: out.message,\n ...(out.toolCallId !== undefined ? { toolCallId: out.toolCallId } : {}),\n retryable: out.retryable,\n };\n}\n\n/**\n * The unredacted error behind a redacted one, for the server-side hooks.\n *\n * Keyed by the object put on the frame, which is the object the controller's\n * event hooks are handed in the same process; it never crosses a wire.\n */\nconst unredacted = new WeakMap<AgentError, AgentError>();\n\nexport function rememberUnredacted(redacted: AgentError, original: AgentError): void {\n if (redacted !== original) unredacted.set(redacted, original);\n}\n\n/** The original of `error` when it was redacted in this process, else `error`. */\nexport function unredactedError(error: AgentError): AgentError {\n return unredacted.get(error) ?? error;\n}\n",
|
|
6
|
+
"import { ToolError } from \"../redact\";\nimport type {\n DeleteFileParams,\n PutFileParams,\n ReadFileParams,\n ReadResult,\n} from \"../../services/file-storage/drivers/types\";\nimport type { Usage } from \"../types\";\n\n/**\n * The bytes of an upload, kept by gemi, and the scope that says whose they are.\n *\n * WHY THIS EXISTS. `AgentController.upload` used to hand the file straight to\n * the model provider and keep nothing, which is the trade `AgentProvider.upload`\n * documents — provider file ids in the history, no storage story. That is a fine\n * trade for vision and it fails the moment a *tool* needs the file: the user\n * uploads an image and asks the agent to create a product, `POST /products`\n * wants multipart bytes, and the server is holding a provider file id and\n * nothing else. The model cannot make up the difference — it *saw* the image, it\n * cannot reproduce it — and the only recovery left is downloading from the\n * vendor, which is a round trip for bytes we held minutes ago, is not declared\n * anywhere (`AgentProvider` has `upload` and no counterpart), and is subject to\n * a retention policy that is not ours.\n *\n * WHY THE SCOPE IS NOT OPTIONAL. Once a tool takes an attachment id as an\n * argument, that id arrives *from the model*, and a model's arguments are as\n * untrusted as a request body: whatever the model wrote is a function of what it\n * read, and it reads the user's text, tool output, and any document it was\n * shown. A store that resolves ids globally therefore lets a prompt-injected\n * model name another tenant's upload and have the server fetch it — the model as\n * confused deputy, spending the server's own credentials.\n *\n * So there is no `find(id)` on this interface, only `find(scope, id)`, and the\n * thing a tool is handed is a `ScopedAttachments` whose methods take no scope at\n * all because it already closed over one. The unscoped read is not discouraged,\n * it is unspellable: the tool has no object to call it on. The scope itself is\n * derived from the server's own knowledge of the request — see\n * `AgentController.attachmentScope` — and never from anything the model can\n * write.\n */\n\n/**\n * The subject an attachment belongs to, as one opaque string.\n *\n * ONE STRING, COMPARED WITH `===`, RATHER THAN A STRUCTURE OF user/thread/org\n * fields. gemi does not have an opinion about tenancy — there is no `Org` in\n * this framework — so a structured scope would have had to be a bag of optional\n * fields, and a bag of optional fields has a worst member: `{}`, which under any\n * partial-match rule matches everything. Every such rule admits `{}` — or\n * `{ userId: undefined }`, which is the same thing arrived at by a typo — so one\n * forgetful line in an app turns the scope check into a no-op that still\n * typechecks. An opaque key has no such member: an app that wants org isolation\n * writes `org:${org.id}` and gets it, and an app that decides a request has no\n * subject returns `null` from `attachmentScope()` and gets no attachment ids at\n * all, rather than a bucket everyone shares.\n *\n * It is an object rather than a bare `string` for one reason, and it is a real\n * one: `find(scope, id)` taking two bare strings is a signature whose arguments\n * can be transposed, and the transposition typechecks, runs, and is a scope\n * check comparing an id against an id. The wrapper makes that a compile error.\n *\n * The key is never shown to the model and never sent to the client. It is a\n * server-side comparison value; it is not a path component and is not parsed.\n */\nexport type AttachmentScope = { readonly key: string };\n\n/**\n * Where an upload's bytes were sent. See `AgentController.attachmentDestination`.\n *\n * `\"provider\"` DESCRIBES A RECORD `upload` NEVER WRITES. A file that goes to the\n * provider alone leaves gemi holding nothing to resolve — `read` and `file`\n * would throw for it — so the route answers `fileId` and mints no attachment id\n * at all, and there is no id for anyone to look up its name with. The value is\n * on this type because a store *can* hold such a row (a custom `AttachmentStore`\n * filing provider uploads for its own bookkeeping is a reasonable thing to\n * write, and `ScopedAttachments` handles it correctly), not because the shipped\n * route produces one.\n */\nexport type AttachmentDestination = \"both\" | \"provider\" | \"storage\";\n\n/**\n * One recorded upload.\n *\n * `fileId` and `objectName` are both optional and at least one is always\n * present, because which of them exists is exactly the destination decision:\n * `provider` has a `fileId` and no bytes of ours, `storage` has bytes and no\n * `fileId`, `both` has both.\n */\nexport type Attachment = {\n /**\n * gemi's id for the upload — the one a tool takes as an argument, and the only\n * id in this module that may be shown to a model.\n *\n * Prefixed `gemi_att_` so that the mistake everyone makes once — a gemi\n * attachment id put into `FilePart.fileId`, which is a *provider* id — is\n * caught by a sentence to read rather than by whatever the vendor says about\n * a file it has never heard of, mid-conversation. `toResponsesInput` checks\n * for the prefix; the vendor's own answer to a bogus `file_id` has not been\n * measured, and the guard does not depend on it.\n */\n id: string;\n /**\n * The scope this was filed under, carried on the record so `ScopedAttachments`\n * can check it a second time. See `ScopedAttachments.get` for why the second\n * check is not redundant.\n */\n scopeKey: string;\n /** The provider file id, when the file was sent to the provider. */\n fileId?: string;\n /** The storage object name, when the bytes were kept. Feed it to `read`. */\n objectName?: string;\n /** The client's filename, kept so a tool can forward the file under it. */\n name: string;\n mimeType: string;\n size: number;\n createdAt: string;\n destination: AttachmentDestination;\n /**\n * When this attachment stops resolving and `AgentController.sweepAttachments`\n * may delete it (#1307). Absent for an attachment that is kept, which is\n * every attachment unless `attachmentRetention` answers otherwise.\n */\n expiresAt?: string;\n /**\n * Deleted, with its provider copy, once the turn that names it (or, for a\n * tool's output, the turn that made it) has completed. Set by\n * `attachmentRetention` answering `\"turn\"`; `expiresAt` is then the\n * fallback for a turn that never comes.\n */\n deleteAfterTurn?: boolean;\n};\n\n/**\n * How long a turn's uploads and tool-made attachments live (#1307). What\n * `AgentController.attachmentRetention` answers; `null` keeps them.\n *\n * - `\"turn\"`: deleted from storage and from the provider once the turn has\n * completed (after `onStreamComplete`). An upload no turn names is deleted by\n * the sweep after `AgentController.turnAttachmentMaxAgeMs`.\n * - `{ ttlMs }`: kept for that long, then no longer resolves and is deleted by\n * `AgentController.sweepAttachments()`.\n */\nexport type AttachmentRetention = \"turn\" | { ttlMs: number };\n\n/** The fields a short-lived attachment carries. See `Attachment.expiresAt`. */\nexport type AttachmentLifetime = { expiresAt: string; deleteAfterTurn?: boolean };\n\n/**\n * Where attachment *records* live. The bytes are in `AttachmentStorage`; this\n * holds the row that says which bytes, whose, and under what id.\n *\n * The default is `MemoryAttachmentStore`, which dies with the process, exactly\n * like `MemoryAgentStore`. An app that wants an attachment to outlive a deploy\n * implements this over a table — `id` primary key, `scope_key` column — and\n * assigns it to `AgentController.attachments`.\n *\n * IF YOU IMPLEMENT THIS, THE ONE THING YOU MUST NOT DO is answer `find` from the\n * id alone. `SELECT * FROM attachments WHERE id = ?` is the leak this module\n * exists to prevent, and it passes every test an app writes about its own\n * uploads, because those uploads are always in scope. It is wrong only for an id\n * that came from somewhere else, which is to say only when it matters. The\n * clause is `WHERE id = ? AND scope_key = ?`.\n */\nexport interface AttachmentStore {\n /** Records an attachment under `scope`. The caller has already minted the id. */\n put(scope: AttachmentScope, attachment: Attachment): Promise<void>;\n /**\n * The attachment with this id *within this scope*, or `null`.\n *\n * `null` for an id that does not exist and `null` for an id that exists under\n * another scope, and the caller cannot tell which — deliberately. See\n * `AttachmentNotFoundError`.\n */\n find(scope: AttachmentScope, id: string): Promise<Attachment | null>;\n /**\n * Removes the record (#1307). Optional, so a store written before this keeps\n * compiling; short-lived attachments (`attachmentRetention`) need it, and\n * without it their records outlive their bytes. Scoped like `find`: the\n * clause is `WHERE id = ? AND scope_key = ?`.\n */\n delete?(scope: AttachmentScope, id: string): Promise<void>;\n /**\n * Up to `limit` records whose `expiresAt` is at or before `now`, across every\n * scope (#1307). Only `AgentController.sweepAttachments` calls it, with no\n * model or request anywhere near it; it is the one unscoped read, and it\n * exists to delete. Index `expires_at`.\n */\n expired?(now: Date, limit: number): Promise<Attachment[]>;\n}\n\n/**\n * The bytes half: whatever the app's file storage is.\n *\n * Structurally satisfied by the `Storage` facade, which is what\n * `AgentController` defaults to. Declared as an interface of two methods rather\n * than as `typeof Storage` so a test — or an app with a second bucket for user\n * uploads — can pass something else without standing up a container.\n */\nexport interface AttachmentStorage {\n put(params: PutFileParams | Blob): Promise<string>;\n read(params: ReadFileParams | string): Promise<ReadResult>;\n /** Needed for short-lived attachments (#1307). The `Storage` facade has it. */\n delete?(params: DeleteFileParams | string): Promise<void>;\n}\n\n/**\n * What both a missing id and someone else's id answer.\n *\n * THE MESSAGE MUST NOT SAY WHICH. \"Exists but is not yours\" and \"does not exist\"\n * are two answers to a question the caller is not entitled to ask, and a store\n * that distinguishes them is an oracle: a prompt-injected model that can tell\n * the two apart can walk an id space and report back which ids are live, which\n * is a tenant census delivered through the very tool the injection was aimed at.\n * One error, one wording, one code, for both.\n *\n * A `ToolError` rather than a `RequestBreakerError`: this is thrown inside a\n * tool, where the agent loop turns a throw into a tool result the model reads\n * and can recover from, not inside a route where it would decide a status code.\n * A `ToolError` so the model and the client are shown its message (#446).\n */\nexport class AttachmentNotFoundError extends ToolError {\n readonly code = \"attachment_not_found\";\n constructor(public readonly id: string) {\n super(`No attachment ${id}.`);\n this.name = \"AttachmentNotFoundError\";\n }\n}\n\n/** Raised for a scope no caller could have meant. See `assertScope`. */\nexport class InvalidAttachmentScopeError extends ToolError {\n readonly code = \"invalid_attachment_scope\";\n constructor(message: string) {\n super(message);\n this.name = \"InvalidAttachmentScopeError\";\n }\n}\n\n/**\n * Rejects the empty scope.\n *\n * `{ key: \"\" }` is what an app produces by writing `` `org:${org?.id ?? \"\"}` ``\n * for a request that has no org, and it is the one value that must never reach a\n * store: it compares equal to itself, so every subject-less upload in the\n * process lands in one shared bucket that every subject-less caller can read out\n * of. That is the global store this module exists not to be, arrived at by a\n * template literal. Failing here is loud, happens on the first request, and\n * names the method to fix.\n */\nfunction assertScope(scope: AttachmentScope): AttachmentScope {\n if (!scope || typeof scope.key !== \"string\" || scope.key.length === 0) {\n throw new InvalidAttachmentScopeError(\n \"An attachment scope needs a non-empty key. Return `null` from `attachmentScope()` for a request that has no subject — an empty key is a bucket every caller shares.\",\n );\n }\n return scope;\n}\n\n/** The prefix on every gemi attachment id. See `Attachment.id`. */\nexport const ATTACHMENT_ID_PREFIX = \"gemi_att_\";\n\nexport function newAttachmentId(): string {\n return `${ATTACHMENT_ID_PREFIX}${crypto.randomUUID()}`;\n}\n\n/**\n * The handle a tool is given, and the only attachment API a tool should ever\n * see.\n *\n * IT TAKES NO SCOPE, ON ANY METHOD. That is the whole design, and it is not a\n * convenience: an API where the scope is a parameter is an API where the scope\n * is a parameter someone passes the wrong thing to — and the wrong thing here is\n * whatever the model wrote, because inside a tool body the model's arguments are\n * the variables closest to hand. Handing the tool an object that has already\n * closed over the server's answer leaves nothing to pass. `resolve(id, scope)`\n * was the rejected shape: it is the same code with the mistake still available.\n */\nexport class ScopedAttachments {\n constructor(\n private readonly store: AttachmentStore,\n private readonly storage: AttachmentStorage,\n private readonly scope: AttachmentScope,\n private readonly lifetime: ScopedLifetime | null = null,\n ) {\n assertScope(scope);\n }\n\n /**\n * The same scope, with every `put` made short-lived (#1307): each record\n * gets `lifetime.next()`'s fields and is handed to `lifetime.onPut`, which is\n * how a turn collects what its tools made so it can delete them. Reads are\n * unchanged.\n */\n withLifetime(lifetime: ScopedLifetime): ScopedAttachments {\n return new ScopedAttachments(this.store, this.storage, this.scope, lifetime);\n }\n\n /**\n * The scope's key. Read by `ctx.jobs.start` (#461), which records it on the\n * job so a background job gets the same attachments its tool had. Only the\n * key leaves: it is the server's answer, not something a tool can set.\n */\n get scopeKey(): string {\n return this.scope.key;\n }\n\n /**\n * The record for `id`, or `AttachmentNotFoundError`.\n *\n * THE SCOPE IS CHECKED TWICE HERE, and the second check is the one that\n * matters. `store.find` is an app's code — a table lookup somebody wrote, with\n * a `WHERE` clause somebody has to have remembered — and the failure mode of\n * forgetting the scope clause is a query that works perfectly for every upload\n * the app's own tests make. Comparing `record.scopeKey` again is three lines\n * that hold even when that clause is missing, so a careless store finds nothing\n * across scopes instead of leaking.\n *\n * It is not defence against a *malicious* store — an app's store is the app's\n * own code and could return anything. It is defence against the ordinary\n * version of this bug, which is the one that ships.\n */\n async get(id: string): Promise<Attachment> {\n const record = await this.store.find(this.scope, id);\n if (!record || record.scopeKey !== this.scope.key || isExpired(record, Date.now())) {\n throw new AttachmentNotFoundError(id);\n }\n return record;\n }\n\n /**\n * The bytes, streaming, with the metadata `createStreamResponse` wants.\n *\n * Throws `AttachmentNotFoundError` for an attachment that exists but whose\n * bytes were never kept — a `provider`-destination upload. The same error as\n * an unknown id, for the reason on that class: \"it is at the vendor and not\n * here\" is information about someone else's upload as readily as about your\n * own.\n */\n async read(id: string): Promise<ReadResult> {\n return await this.readRecord(id, await this.get(id));\n }\n\n /**\n * The bytes for a record already resolved, so `file()` does one lookup rather\n * than two. `store.find` is a `SELECT` in any real store, and the second one\n * was not a second check of anything — same scope, same id, same row.\n *\n * It still takes the id the *caller* asked for, rather than reading\n * `record.id`, so the error stays a function of the caller's own input: an app\n * store that answers with the wrong row must not get to choose which id\n * appears in a message the model may read.\n */\n private async readRecord(id: string, record: Attachment): Promise<ReadResult> {\n if (!record.objectName) {\n throw new AttachmentNotFoundError(id);\n }\n return await this.storage.read({ name: record.objectName });\n }\n\n /**\n * The bytes as a `File`, under the name and type they were uploaded with —\n * which is the shape the motivating case actually needs, because\n * `form.append(\"image\", file)` is what a tool forwarding an upload to a\n * multipart endpoint writes.\n *\n * Buffers, and says so. `read()` is there for anything large enough that\n * buffering it is the wrong call.\n *\n * THIS IS ALSO HOW AN ATTACHMENT OUTLIVES THE RUN, and it is `file()` rather\n * than `read()` that composes for it:\n *\n * const file = await ctx.attachments.file(id);\n * await Storage.put({ name: `pages/${pageId}/hero.png`, body: file });\n *\n * `read()` answers a `ReadResult` whose `body` is `ReadableStream | Blob |\n * null`, and `PutFileParams.body` is `Blob | File | Buffer` — a stream body\n * has nowhere to go without being drained first.\n *\n * Two things that bite on the way out, both silent:\n *\n * - **Do not keep a `gemi_att_` id as an app's durable handle to a file.**\n * The default record store is `MemoryAttachmentStore`, so the id→object\n * mapping dies with the process while the bytes stay in storage. Copy the\n * file under a key of the app's own and keep that.\n * - **Put an extension on that key.** `FileSystemDriver` — the default —\n * ignores `contentType` on write and re-derives the type from the stored\n * path on read, so an extensionless object serves as\n * `application/octet-stream` and an `<img>` pointed at it renders nothing,\n * with no error anywhere. `attachmentObjectName` carries one over for this\n * module's own writes; an app's key is the app's to name.\n */\n async file(id: string): Promise<File> {\n const record = await this.get(id);\n const result = await this.readRecord(id, record);\n const body = result.body;\n const blob =\n body instanceof Blob ? body : body ? await new Response(body).blob() : new Blob([]);\n return new File([blob], record.name, { type: record.mimeType });\n }\n\n /**\n * Stores bytes a tool produced, under this caller's scope, and answers the\n * record.\n *\n * Here rather than on the store because the id, the object name and the scope\n * all have to be decided together, and because an attachment a tool created\n * has to land in the scope the tool is reading from — otherwise a tool writes\n * a file the next tool of the same run cannot see.\n *\n * Nothing is sent to the provider: bytes a tool made are bytes for the app,\n * and a tool that wants the model to look at its output says so by returning\n * something the model can read. Issue #490 builds `ctx.attachments.put(blob)`\n * on exactly this.\n */\n async put(\n blob: Blob,\n params: { name?: string; mimeType?: string; fileId?: string } = {},\n ): Promise<Attachment> {\n const id = newAttachmentId();\n const mimeType = params.mimeType ?? blob.type ?? \"\";\n const name = params.name ?? (blob instanceof File ? blob.name : id);\n const objectName = await this.storage.put({\n name: attachmentObjectName(id, name),\n body: blob,\n contentType: mimeType || undefined,\n });\n const record: Attachment = {\n id,\n scopeKey: this.scope.key,\n objectName,\n name,\n mimeType: mimeType || \"application/octet-stream\",\n size: blob.size,\n createdAt: new Date().toISOString(),\n // `both` when the caller has already sent the same bytes to the provider,\n // which is what `ctx.attachments.put(blob, { showModel: true })` does\n // before it gets here.\n //\n // The parameter exists rather than a second `markShown` call because the\n // alternative is a row that is briefly, and then permanently if the second\n // write fails, a lie: `destination` is the field that says where the bytes\n // went, and a file sitting in the vendor's file list under a record that\n // says `storage` is exactly the discrepancy the field was added to close.\n // Nothing here uploads — the provider is the run's, not this module's —\n // so the id is passed in rather than produced.\n destination: params.fileId ? \"both\" : \"storage\",\n ...(params.fileId ? { fileId: params.fileId } : {}),\n ...(this.lifetime ? this.lifetime.next() : {}),\n };\n await this.store.put(this.scope, record);\n this.lifetime?.onPut?.(record);\n return record;\n }\n}\n\n/** What `ScopedAttachments.withLifetime` takes. */\nexport type ScopedLifetime = {\n /** The lifetime fields for a record stored now. */\n next(): AttachmentLifetime;\n /** Told about each record stored. */\n onPut?(attachment: Attachment): void;\n};\n\n/** Whether `attachment` has passed its `expiresAt`. */\nexport function isExpired(attachment: { expiresAt?: string }, now: number): boolean {\n if (!attachment.expiresAt) return false;\n const at = Date.parse(attachment.expiresAt);\n return Number.isFinite(at) && at <= now;\n}\n\n/**\n * The lifetime fields for something stored now under `retention`, or `null`\n * for one that is kept. `turnMaxAgeMs` is how long a `\"turn\"` attachment may\n * wait for a turn to delete it before the sweep does.\n */\nexport function attachmentLifetime(\n retention: AttachmentRetention | null | undefined,\n turnMaxAgeMs: number,\n now = Date.now(),\n): AttachmentLifetime | null {\n if (retention === null || retention === undefined) return null;\n if (retention === \"turn\") {\n return { expiresAt: new Date(now + turnMaxAgeMs).toISOString(), deleteAfterTurn: true };\n }\n const ttlMs = (retention as { ttlMs?: unknown })?.ttlMs;\n if (typeof ttlMs !== \"number\" || !Number.isFinite(ttlMs) || ttlMs <= 0) {\n throw new Error(\n `attachmentRetention() must answer \"turn\", { ttlMs } with a positive number of milliseconds, or null; it answered ${JSON.stringify(retention)}.`,\n );\n }\n return { expiresAt: new Date(now + ttlMs).toISOString() };\n}\n\n/** What `deleteAttachment` deletes from. */\nexport type AttachmentDeletionTargets = {\n store: AttachmentStore;\n storage: AttachmentStorage;\n /** The provider the file was uploaded to, for `fileId`. */\n provider?: { deleteFile?(fileId: string): Promise<void> };\n /** Forgets the provider file's owner record once it is deleted. */\n fileOwners?: { delete?(fileId: string): Promise<void> };\n};\n\n/**\n * Deletes every copy of one attachment (#1307): the stored bytes, then the\n * provider's file, then the record. In that order so a failure leaves the\n * record behind, and the sweep (or the next attempt) finds it and tries again.\n * Throws on the first copy it cannot delete, including when `storage` or the\n * provider has no way to delete at all: a privacy deletion that skips a copy\n * must not look like one that succeeded.\n */\nexport async function deleteAttachment(\n attachment: Attachment,\n targets: AttachmentDeletionTargets,\n): Promise<void> {\n if (attachment.objectName) {\n if (!targets.storage.delete) {\n throw new Error(\n `Cannot delete attachment ${attachment.id}: the controller's attachmentStorage has no delete().`,\n );\n }\n await targets.storage.delete({ name: attachment.objectName });\n }\n if (attachment.fileId) {\n if (!targets.provider?.deleteFile) {\n throw new Error(\n `Cannot delete the provider copy of attachment ${attachment.id}: the agent's provider has no deleteFile().`,\n );\n }\n await targets.provider.deleteFile(attachment.fileId);\n await targets.fileOwners?.delete?.(attachment.fileId);\n }\n if (!targets.store.delete) {\n throw new Error(\n `Cannot delete attachment ${attachment.id}: the controller's attachment store has no delete().`,\n );\n }\n await targets.store.delete({ key: attachment.scopeKey }, attachment.id);\n}\n\n/**\n * What a tool asks for when it parks bytes.\n *\n * `showModel` is the whole of issue #490 in one flag: without it a tool's\n * output is an id in a string, which the model can quote back and cannot look\n * at, so \"edit this image\" produces a file nobody but the app ever sees. With\n * it the same bytes also go to the provider and come back into the transcript\n * as an input-role message the next step is built on — generate, look, fix.\n *\n * It is a flag rather than the default because the default costs money on every\n * call. The reasoning is `capabilitiesForModel`'s, run the other way round: a\n * file the model did not need and was shown anyway is an upload plus a set of\n * image tokens on every subsequent request of the run, on an invoice, for a\n * tool whose author never asked to be looked at. A file the model needed and\n * was not shown is a tool that returned an id, which is what tools did before\n * this existed and is visible in the transcript the moment anyone reads it. The\n * expensive mistake is the silent one here, so the expensive thing is opt in.\n */\nexport type PutAttachmentParams = {\n /** The filename to keep, so a later `file()` hands the bytes back under it. */\n name?: string;\n /** Overrides `blob.type`, which a `Blob` built from raw bytes does not have. */\n mimeType?: string;\n /**\n * Also send these bytes to the model provider and put them in front of the\n * model as an input-role message, once this tool call settles.\n *\n * Refused, loudly, by a provider whose `capabilities.fileInput` is false: the\n * request builder drops a file part such a provider cannot read, and an\n * upload paid for, stored, and then dropped on the way to the wire is the\n * silent-forever failure — the tool reports success, the model answers about\n * an image it was never shown, and nothing anywhere says why.\n */\n showModel?: boolean;\n};\n\n/**\n * The attachment API a tool is given, as `ctx.attachments`.\n *\n * Everything a `ScopedAttachments` does, plus `showModel`, plus the memo that\n * makes a re-entered tool call idempotent. It is a separate interface from\n * `ScopedAttachments` because those two additions are not properties of the\n * scope, they are properties of *one tool call*: the run has to know which call\n * a `put` belongs to in order to replay it, and the object handed to a tool is\n * therefore built per call — the same shape `ctx.runAgent` has, for the same\n * reason.\n *\n * The read half (`get`, `read`, `file`) is delegated to the `ScopedAttachments`\n * unchanged, including its two scope checks. A tool reading a file it did not\n * create is reading an id the model wrote, and #489's whole argument applies to\n * it word for word.\n */\nexport interface ToolAttachments {\n /**\n * Parks bytes under this caller's scope and answers the record.\n *\n * ON A REPLAY THIS STORES NOTHING. An escalating tool is re-entered from the\n * top on the next turn, so the body that built this blob has run before and\n * built one already; the record from that first attempt is what comes back,\n * and the bytes handed in now are dropped. That is the same bargain\n * `ctx.runAgent` makes and it is not avoidable: the id from the first attempt\n * is already in the transcript the model read, so minting a second one would\n * leave the model holding an id for bytes nobody kept — and uploading the\n * second copy would pay the vendor twice and put the same image into the\n * context twice. Work *before* a `put` still runs again; if producing the\n * bytes is what costs, branch on `ctx.resumed`.\n */\n put(blob: Blob, params?: PutAttachmentParams): Promise<Attachment>;\n /** The record for `id`, or `AttachmentNotFoundError`. Scoped. */\n get(id: string): Promise<Attachment>;\n /** The bytes, streaming. Scoped. */\n read(id: string): Promise<ReadResult>;\n /** The bytes as a `File`, under their original name and type. Scoped. */\n file(id: string): Promise<File>;\n}\n\n/**\n * One successful `ctx.attachments.put` of one tool call, written down so the\n * next turn can replay it instead of doing it again.\n *\n * Lives on `ToolCallPart.attachments`, indexed by the order the puts happened\n * in — exactly where and how `ToolCallPart.nested` records sub-runs, and for\n * exactly the same reason: the message history is the only state that survives\n * a turn boundary, in a thread and in the browser both, so a memo that is not\n * on the message is a memo a stateless app does not have.\n *\n * `shown` is absent for a plain `put`. When present it carries the provider\n * file id AND the identity of the message injected for it, because both have to\n * come back byte for byte: a replay that minted a fresh message id would put a\n * second copy of the same image in the transcript, and a client that had\n * already applied the first would show it twice.\n */\nexport type ToolAttachmentPut = {\n /** What `put` answered, replayed verbatim. */\n attachment: Attachment;\n /**\n * Set when this slot was filled by `ctx.generateImage` / `ctx.editImage`\n * rather than a plain `put`, carrying what the render reported and the\n * attachment record cannot.\n *\n * WHY THE RENDER IS MEMOIZED AT ALL, and why it is memoized *here*. An\n * escalating tool is re-entered from the top on the next turn, so a render\n * that is not written down is paid for again — and unlike a `put`, the thing\n * being repeated costs money at the vendor and about two minutes of wall\n * clock. The memo cannot hold the image: this record lives in the message\n * history, which goes over the wire and into a store on every turn, and a\n * megabyte of base64 per generated image would go with it. So what is\n * recorded is the attachment id, and the bytes live in storage where they\n * were going anyway.\n *\n * That is the whole reason `ctx.generateImage` answers an `Attachment`\n * instead of a `Blob` while `ImageModel.generate` answers the bytes: outside\n * a run there is nothing to replay and nowhere to park, and inside one there\n * has to be both.\n *\n * `size` is the pixel dimensions the model actually produced — read off the\n * response, which does not always echo the request — and is not derivable\n * from `Attachment.size`, which is a byte count.\n */\n generated?: {\n size: string;\n usage: Usage;\n };\n /** Set when `showModel` was asked for. See above. */\n shown?: {\n /** The provider's file id — what the injected `FilePart` carries. */\n fileId: string;\n /** The injected message's id, so a replay reproduces it rather than a twin. */\n messageId: string;\n /** Its `createdAt`, for the same reason. */\n createdAt: string;\n };\n};\n\n/**\n * A slot in that list, which is one `put` — or one `put` that threw.\n *\n * The failure arm exists because the index is what identifies a `put`, and an\n * index is taken the moment the call is made rather than when it succeeds: a\n * body that runs its puts concurrently must number them by the order it *asked*\n * and not by the order the network answered, or the next turn will not\n * reproduce the numbering. So a `put` that throws and is caught — a provider\n * that cannot read files, a vendor that refuses the type, a storage write that\n * fails — leaves a slot behind, and a later successful `put` in the same call\n * would otherwise leave a hole in front of it. A hole is `null` once it has\n * been through JSON, which is what a consumer walking `part.attachments`\n * crashes on; `{ failed: true }` is the same fact said out loud.\n *\n * It is written lazily, only when a later `put` needs the index above it, so a\n * tool whose puts all threw still adds no `attachments` field at all. And it is\n * not a memo: a replayed slot marked `failed` is re-attempted from scratch,\n * because there is nothing recorded to hand back and the failure may have been\n * the network's rather than the tool's.\n */\nexport type ToolAttachmentRecord = ToolAttachmentPut | { failed: true };\n\n/**\n * The object name an attachment's bytes are stored under.\n *\n * The scope is deliberately NOT in the path. A scope key is app-authored text —\n * `org:${slug}`, with whatever a slug turns out to be — and putting arbitrary\n * app text into an object name is how a `..` or a `/` ends up somewhere nobody\n * meant on the one driver that resolves names literally (`FileSystemDriver`\n * concatenates them onto a folder path). The record is what carries the scope;\n * the object name only has to be unique, and a uuid already is.\n *\n * The extension is carried over from the client's filename when it looks like\n * one, because `FileSystemDriver` reads a stored object's content type back off\n * its path and would otherwise answer `application/octet-stream` for everything.\n * `Attachment.mimeType` is the authority either way — this is for anything that\n * reads the bucket without the record.\n */\nexport function attachmentObjectName(id: string, name: string): string {\n const match = /\\.([A-Za-z0-9]{1,8})$/.exec(name);\n return `attachments/${id}${match ? `.${match[1]!.toLowerCase()}` : \"\"}`;\n}\n\n/**\n * The default: attachment records last as long as the process.\n *\n * Modelled as one flat map keyed by id, holding the scope beside the record and\n * comparing it in `find` — rather than as a map of maps, which would make the\n * scoping structural and unforgettable. That looks like the safer shape and is\n * the wrong reference implementation: an app's store is a table with an `id`\n * primary key and a `scope_key` column, and its `find` is a `WHERE` clause that\n * can be written wrong. The store gemi ships should have the same failure\n * available to it as the store an app writes, so that a test written against\n * this one is a test of the check every real store also has to make.\n */\nexport class MemoryAttachmentStore implements AttachmentStore {\n private readonly rows = new Map<string, Attachment>();\n\n async put(scope: AttachmentScope, attachment: Attachment): Promise<void> {\n assertScope(scope);\n this.rows.set(attachment.id, { ...attachment, scopeKey: scope.key });\n }\n\n async find(scope: AttachmentScope, id: string): Promise<Attachment | null> {\n assertScope(scope);\n const row = this.rows.get(id);\n // The scope clause. An id belonging to another scope answers `null`, which\n // is the answer an id that does not exist gets — see\n // `AttachmentNotFoundError` for why the two must be indistinguishable.\n if (!row || row.scopeKey !== scope.key) {\n return null;\n }\n return row;\n }\n\n async delete(scope: AttachmentScope, id: string): Promise<void> {\n assertScope(scope);\n const row = this.rows.get(id);\n if (row && row.scopeKey === scope.key) {\n this.rows.delete(id);\n }\n }\n\n async expired(now: Date, limit: number): Promise<Attachment[]> {\n const found: Attachment[] = [];\n for (const row of this.rows.values()) {\n if (found.length >= limit) break;\n if (isExpired(row, now.getTime())) found.push(row);\n }\n return found;\n }\n\n /** Test and dev affordance: how many rows are held, across every scope. */\n get size(): number {\n return this.rows.size;\n }\n}\n\n/**\n * The process-wide default, so an app that configures nothing still gets\n * attachment ids that work for the length of a conversation.\n *\n * Module-level for the reason `defaultAgentStore` is: the controller is\n * constructed per request, so a store assigned as `new MemoryAttachmentStore()`\n * in a field initializer is an empty store on every request, and every\n * attachment id is a miss one turn after it was minted.\n */\nexport const defaultAttachmentStore = new MemoryAttachmentStore();\n",
|
|
7
|
+
"import type { ProviderEvent, ProviderStreamParams } from \"./AgentProvider\";\nimport { supportsStrict, type Schema } from \"./Schema\";\nimport type { AgentError, AgentMessage, Usage } from \"./types\";\n\n/**\n * What one model call needs, whether the agent loop makes it or `generate` does.\n *\n * Moved out of `Agent.ts` rather than copied when `generate` arrived (#594).\n * `generate` is the agent's step without the loop around it — assemble one\n * call, read the stream, parse the answer — so each of these would otherwise\n * exist twice, and the two copies of \"how is a structured answer parsed\" or\n * \"how is usage summed\" are exactly the kind that drift apart unnoticed.\n *\n * Internal. Nothing here is exported from `gemi/ai`.\n */\n\n// --- aborting --------------------------------------------------------------\n\nexport class RunAborted extends Error {\n constructor() {\n super(\"The run was stopped\");\n this.name = \"RunAborted\";\n }\n}\n\nexport function raceAbort<T>(promise: Promise<T>, signal: AbortSignal): Promise<T> {\n if (signal.aborted) {\n return Promise.reject(new RunAborted());\n }\n return new Promise<T>((resolve, reject) => {\n const onAbort = () => reject(new RunAborted());\n signal.addEventListener(\"abort\", onAbort, { once: true });\n promise.then(resolve, reject).finally(() => signal.removeEventListener(\"abort\", onAbort));\n });\n}\n\n/**\n * Every event that is content a consumer shows or stores.\n *\n * The first one is the point of no return for a call: before it, the call can\n * be asked again (the stream retry in `providers/call.ts`) or handed to another\n * model (`FallbackProvider`) without anyone seeing a seam; after it, the user\n * has read something, and asking again would show it twice.\n */\nexport function isContentEvent(event: ProviderEvent): boolean {\n switch (event.type) {\n case \"text-delta\":\n case \"reasoning-delta\":\n case \"tool-call-delta\":\n case \"tool-call\":\n case \"tool-search\":\n case \"output-delta\":\n return true;\n default:\n return false;\n }\n}\n\n// --- usage -----------------------------------------------------------------\n\nexport function emptyUsage(): Usage {\n return { inputTokens: 0, outputTokens: 0, totalTokens: 0 };\n}\n\nexport function addUsage(total: Usage, next: Usage | undefined): Usage {\n if (!next) return total;\n const merged: Usage = {\n inputTokens: total.inputTokens + (next.inputTokens ?? 0),\n outputTokens: total.outputTokens + (next.outputTokens ?? 0),\n totalTokens: total.totalTokens + (next.totalTokens ?? 0),\n };\n // A breakdown stays absent until either side reports it, so a text run's\n // usage does not grow fields it never measured.\n for (const key of USAGE_BREAKDOWNS) {\n if (next[key] !== undefined || total[key] !== undefined) {\n merged[key] = (total[key] ?? 0) + (next[key] ?? 0);\n }\n }\n return merged;\n}\n\nconst USAGE_BREAKDOWNS = [\n \"reasoningTokens\",\n \"cachedInputTokens\",\n \"cacheWriteInputTokens\",\n \"imageInputTokens\",\n \"imageOutputTokens\",\n \"audioInputTokens\",\n \"cachedAudioInputTokens\",\n \"audioOutputTokens\",\n] as const satisfies readonly (keyof Usage)[];\n\n// --- structured output -----------------------------------------------------\n\n/**\n * The best parse of a JSON document that is still arriving.\n *\n * Exists so a UI can bind fields before the object closes. It closes whatever\n * brackets are open and drops a trailing key with no value; when even that does\n * not parse it gives up and returns an empty object rather than throwing,\n * because a snapshot is a convenience and a run must not die for one.\n */\nexport function bestEffortParse(text: string): any {\n if (!text.trim()) return {};\n try {\n return JSON.parse(text);\n } catch {\n // fall through to repair\n }\n const closers: string[] = [];\n let inString = false;\n let escaped = false;\n for (const char of text) {\n if (inString) {\n if (escaped) escaped = false;\n else if (char === \"\\\\\") escaped = true;\n else if (char === '\"') inString = false;\n continue;\n }\n if (char === '\"') inString = true;\n else if (char === \"{\") closers.push(\"}\");\n else if (char === \"[\") closers.push(\"]\");\n else if (char === \"}\" || char === \"]\") closers.pop();\n }\n let repaired = text;\n if (inString) repaired += '\"';\n repaired = repaired.replace(/[,:]\\s*$/, \"\");\n const suffix = closers.reverse().join(\"\");\n try {\n return JSON.parse(repaired + suffix);\n } catch {\n // A trailing `\"key\":` leaves a property with no value; drop the key too.\n try {\n return JSON.parse(repaired.replace(/,?\\s*\"[^\"]*\"\\s*$/, \"\") + suffix);\n } catch {\n return {};\n }\n }\n}\n/**\n * The `output` parameter a provider is sent for a schema.\n *\n * `strict` is read off the schema, never chosen: an `s.json()` node anywhere in\n * it has no spelling in strict mode, so a schema containing one is sent\n * non-strict and the provider does not answer 400.\n */\nexport function outputFormat(schema: Schema<any>): NonNullable<ProviderStreamParams[\"output\"]> {\n return { name: \"output\", schema: schema.toJSONSchema(), strict: supportsStrict(schema) };\n}\n\n/**\n * A finished structured answer, checked against its schema.\n *\n * The failure is an `AgentError` with `code: \"invalid_output\"` rather than the\n * schema's own `errors: string[]`, so a caller branches on a code the way it\n * does for `invalid_tool_input`, and the list is joined into the message for a\n * person — or a retry prompt — to read.\n *\n * `bestEffortParse`, not `JSON.parse`, for the reason the agent loop has always\n * used it: the text is the whole answer by now, so the repair has nothing to\n * close, and a document that still does not parse comes back `{}` and fails the\n * schema with a message naming what is missing, instead of a `SyntaxError`\n * position nobody can act on. A cut-off answer never reaches here — see the\n * `length` checks in both callers — because a repaired prefix can pass a loose\n * schema and look finished.\n */\nexport function parseOutput<T>(\n schema: Schema<T>,\n text: string,\n): { ok: true; value: T } | { ok: false; error: AgentError } {\n const parsed = schema.safeParse(bestEffortParse(text));\n if (parsed.ok === true) return { ok: true, value: parsed.value };\n return {\n ok: false,\n error: {\n code: \"invalid_output\",\n message: `The model's structured answer did not match the output schema: ${parsed.errors.join(\", \")}`,\n retryable: true,\n },\n };\n}\n\n// --- building the assistant message ----------------------------------------\n\n/**\n * Resolves a string built by repeated concatenation, in place.\n *\n * `text = text + delta`, run once per streamed token, does not build a string —\n * it builds a rope: a tree of pointers to every fragment, which the engine\n * flattens only when something needs the characters contiguously. A message\n * that nothing reads before it is persisted therefore keeps all of its\n * fragments alive, and the tree costs several times the text.\n *\n * Measured on Bun 1.x, 600 deltas of six characters (a ~450-token answer, 3.5 KB\n * of ASCII): held as a rope, 18.7 KB. Resolved, 3.5 KB — half the UTF-16 size,\n * because a flat ASCII string is stored one byte per character and a rope\n * cannot be. That is 5.3x, and it is paid by every message a store keeps and\n * every run the live registry holds.\n *\n * Indexing is what forces the resolution: `text[0]` cannot be answered without\n * the characters, so the engine collapses the tree and drops the fragments.\n * Nothing is allocated and nothing is copied, which is why this is not\n * `split(\"\").join(\"\")` — that measures the same but allocates one string per\n * character to get there.\n *\n * DO NOT DELETE THIS AS A NO-OP. It reads like one and it is not; the value is\n * the side effect on the receiver. If a future engine does not resolve on\n * index, this silently becomes a real no-op and memory returns to what it is\n * today — a safe failure, which is why it is written as a hint rather than as a\n * round trip through an encoder that would also mangle a lone surrogate.\n */\nexport function resolveRope(text: string): string {\n if (text.length > 0) void text[0];\n return text;\n}\n\nexport function appendText(message: AgentMessage, type: \"text\" | \"reasoning\", delta: string) {\n const last = message.content[message.content.length - 1];\n if (last && last.type === type) {\n (last as { text?: string }).text = ((last as { text?: string }).text ?? \"\") + delta;\n return;\n }\n message.content.push(\n type === \"text\" ? { type: \"text\", text: delta } : { type: \"reasoning\", text: delta },\n );\n}\n\n/**\n * Reasoning is accumulated per ITEM, not per message, and the item's id is kept.\n *\n * This used to go through `appendText`, which merges on the part *type* alone\n * and has nowhere to put an id. Both halves of that were wrong and neither was\n * visible in the transcript:\n *\n * - `request.ts` drops a reasoning item with no id, deliberately — the id is\n * the API's handle on the stored reasoning and a fabricated one would look\n * like continuity that is not there. So an id dropped here meant reasoning\n * was never sent back at all: on a two-step run the model re-derived its\n * own argument from nothing, and the prompt cache (which keys on the\n * literal item) missed every time. Measured against the live Responses API\n * in `live/live.test.ts`: the second call's input carried zero reasoning\n * items.\n * - a step that produces two reasoning items was flattening them into one\n * part, so even with an id there would have been one id for two items'\n * text.\n *\n * A part with no id is still appended rather than dropped: the text is what a\n * UI renders, and a provider that reports no item id (Azure does not always)\n * should still show its thinking. It just cannot be echoed back, which is the\n * bargain `reasoningItem` already documents.\n *\n * `providerMetadata` (#477) arrives on a part's last delta and closes it: a\n * part that has it is not joined again, so two thinking blocks with no id\n * (Anthropic's have none) stay two parts, each with its own signature.\n */\nexport function appendReasoning(\n message: AgentMessage,\n id: string | undefined,\n delta: string,\n providerMetadata?: Record<string, unknown>,\n) {\n const last = message.content[message.content.length - 1];\n if (last && last.type === \"reasoning\" && last.id === id && !last.providerMetadata) {\n last.text = (last.text ?? \"\") + delta;\n if (providerMetadata) last.providerMetadata = providerMetadata;\n return;\n }\n message.content.push({\n type: \"reasoning\",\n ...(id ? { id } : {}),\n text: delta,\n ...(providerMetadata ? { providerMetadata } : {}),\n });\n}\n",
|
|
8
|
+
"import type { AgentError, ProviderErrorDetail, ToolArgumentsTooLong } from \"../types\";\n\n/**\n * A non-2xx response, carried as an exception so the retry loop and\n * `normalizeError` can both read it.\n *\n * The body is kept parsed-if-possible and raw-if-not: OpenAI and Azure both\n * answer `{ error: { message, type, code } }` on a good day, and an HTML error\n * page from a proxy on a bad one, and the bad day is exactly when the text\n * matters.\n */\nexport class ProviderHttpError extends Error {\n readonly status: number;\n readonly body: unknown;\n readonly requestId?: string;\n /** The response's `Retry-After`, in milliseconds, when it had one. */\n readonly retryAfter?: number;\n\n constructor(status: number, body: unknown, requestId?: string, retryAfter?: number) {\n super(`Provider request failed with status ${status}: ${describeBody(body)}`);\n this.name = \"ProviderHttpError\";\n this.status = status;\n this.body = body;\n this.requestId = requestId;\n if (retryAfter !== undefined) this.retryAfter = retryAfter;\n }\n}\n\n/**\n * The request ran out of time. Its own class because it must not read as a\n * user abort: `stop()` means the person is done, and a timeout means the\n * network was, and only one of those is worth trying again.\n */\nexport class ProviderTimeoutError extends Error {\n readonly timeoutMs: number;\n\n constructor(timeoutMs: number) {\n super(`Provider request timed out after ${timeoutMs}ms`);\n this.name = \"ProviderTimeoutError\";\n this.timeoutMs = timeoutMs;\n }\n}\n\n/**\n * A streamed answer that started and then sent nothing, not even a keepalive,\n * for `streamIdleTimeoutMs` (#1167). A `ProviderTimeoutError`, so it reads the\n * same everywhere: retryable `provider_error`, never an abort. The attempt was\n * aborted, so its connection is released.\n */\nexport class ProviderStreamIdleError extends ProviderTimeoutError {\n constructor(timeoutMs: number) {\n super(timeoutMs);\n this.name = \"ProviderStreamIdleError\";\n this.message = `Provider stream sent nothing for ${timeoutMs}ms (streamIdleTimeoutMs)`;\n }\n}\n\n/**\n * A streamed answer still going after `streamMaxDurationMs` (#1169): the one\n * bound a stream that keeps trickling cannot get around, because no chunk\n * resets it. A `ProviderTimeoutError`, so it is a retryable `provider_error`\n * and never an abort. The attempt was aborted, so its connection is released.\n */\nexport class ProviderStreamDurationError extends ProviderTimeoutError {\n constructor(timeoutMs: number) {\n super(timeoutMs);\n this.name = \"ProviderStreamDurationError\";\n this.message = `Provider stream was still going after ${timeoutMs}ms (streamMaxDurationMs)`;\n }\n}\n\n/**\n * One tool call streamed more argument text than `maxToolArgumentChars`\n * without finishing (#1169), which is what a degenerate generation inside the\n * arguments looks like. Retryable: the call never completed and never ran, so\n * asking again costs a request, and the next sample usually ends normally.\n */\nexport class ProviderToolArgumentsTooLongError extends Error {\n readonly limit: number;\n /** The cut call (#1259), carried onto the provider's `error` event. */\n readonly detail: ToolArgumentsTooLong;\n\n constructor(limit: number, toolName: string, toolCallId = \"\", chars = limit + 1) {\n super(\n `Provider streamed more than ${limit} characters of arguments for \"${toolName}\" without finishing the call (maxToolArgumentChars)`,\n );\n this.name = \"ProviderToolArgumentsTooLongError\";\n this.limit = limit;\n this.detail = { tool: toolName, toolCallId, limit, chars };\n }\n}\n\nfunction describeBody(body: unknown): string {\n const detail = errorBody(body);\n if (detail?.message) return detail.message;\n if (typeof body === \"string\") return body.slice(0, 500);\n return \"no error body\";\n}\n\ntype OpenAIErrorBody = { message?: string; type?: string; code?: string; param?: string };\n\nfunction errorBody(body: unknown): OpenAIErrorBody | null {\n if (!body || typeof body !== \"object\") return null;\n const wrapper = body as { error?: unknown };\n const inner = wrapper.error && typeof wrapper.error === \"object\" ? wrapper.error : body;\n const e = inner as OpenAIErrorBody & { innererror?: { code?: string } };\n if (typeof e.message !== \"string\" && typeof e.code !== \"string\" && typeof e.type !== \"string\") {\n return null;\n }\n // Azure hides the interesting code one level down when its content filter\n // fires, and the outer code is the useless `content_filter`.\n const code = e.innererror?.code ?? e.code;\n return { message: e.message, type: e.type, code, param: e.param };\n}\n\n/**\n * The HTTP status, request id and error body detail of a provider failure,\n * read off what was thrown or off an `error` event — server-side detail for\n * `AgentRunResult.error`, never for a frame.\n *\n * By shape rather than by `instanceof ProviderHttpError`, so a custom provider\n * whose SDK throws its own error class with a `status` gets the same detail.\n * A `status` outside 100–599 is not an HTTP status and is ignored.\n *\n * `providerType`, `providerCode` and `providerParam` (#1302) are taken as set\n * on the object (an `error` event carries them that way), and otherwise read\n * from a `body` in the provider's error shape, as `ProviderHttpError` has.\n */\nexport function httpErrorDetail(error: unknown): ProviderErrorDetail {\n if (!error || typeof error !== \"object\") return {};\n const e = error as {\n status?: unknown;\n requestId?: unknown;\n providerType?: unknown;\n providerCode?: unknown;\n providerParam?: unknown;\n body?: unknown;\n };\n const { status, requestId } = e;\n const body = streamErrorDetail(e.body);\n const providerType = nonEmpty(e.providerType) ?? body.providerType;\n const providerCode = nonEmpty(e.providerCode) ?? body.providerCode;\n const providerParam = nonEmpty(e.providerParam) ?? body.providerParam;\n return {\n ...(typeof status === \"number\" && status >= 100 && status <= 599 ? { status } : {}),\n ...(typeof requestId === \"string\" && requestId ? { requestId } : {}),\n ...(providerType ? { providerType } : {}),\n ...(providerCode ? { providerCode } : {}),\n ...(providerParam ? { providerParam } : {}),\n };\n}\n\n/**\n * The `type`, `code` and `param` of a provider's error object: a response\n * body, or one it streamed (Anthropic's `error` frame, the Responses API's\n * `response.failed`), for the `error` event that reports it.\n */\nexport function streamErrorDetail(raw: unknown): ProviderErrorDetail {\n const body = errorBody(raw);\n const providerType = nonEmpty(body?.type);\n const providerCode = nonEmpty(body?.code);\n const providerParam = nonEmpty(body?.param);\n return {\n ...(providerType ? { providerType } : {}),\n ...(providerCode ? { providerCode } : {}),\n ...(providerParam ? { providerParam } : {}),\n };\n}\n\nfunction nonEmpty(value: unknown): string | undefined {\n return typeof value === \"string\" && value ? value : undefined;\n}\n\n/**\n * Provider failures onto `AgentErrorCode`.\n *\n * The contract an app is buying here is that it can branch on `rate_limited`\n * without knowing whose rate limit it was, and on `retryable` without knowing\n * which of the two APIs answered. So `retryable` is set from what is actually\n * true of the failure — a 429 from a spent quota is not retryable no matter\n * what its status code says, and neither is a request that will be too long\n * again next time.\n */\nexport function normalizeProviderError(error: unknown): AgentError {\n if (error instanceof ProviderTimeoutError || error instanceof ProviderToolArgumentsTooLongError) {\n return { code: \"provider_error\", message: error.message, retryable: true };\n }\n\n if (isAbort(error)) {\n return { code: \"aborted\", message: \"The request was aborted.\", retryable: false };\n }\n\n if (error instanceof ProviderHttpError) {\n return fromStatus(error.status, errorBody(error.body), error.message, error.retryAfter);\n }\n\n // `fetch` rejects with a TypeError for DNS failures, refused connections and\n // dropped sockets. Every one of those is worth another attempt.\n if (error instanceof TypeError) {\n return {\n code: \"provider_error\",\n message: `Could not reach the provider: ${error.message}`,\n retryable: true,\n };\n }\n\n if (error instanceof Error) {\n return { code: \"provider_error\", message: error.message, retryable: false };\n }\n\n return { code: \"unknown\", message: String(error), retryable: false };\n}\n\nfunction fromStatus(\n status: number,\n body: OpenAIErrorBody | null,\n fallbackMessage: string,\n retryAfterHeader?: number,\n): AgentError {\n const message = body?.message ?? fallbackMessage;\n const code = (body?.code ?? \"\").toLowerCase();\n const type = (body?.type ?? \"\").toLowerCase();\n // URLs are dropped before matching: Azure's ordinary rate-limit 429 ends\n // with \"visit: https://aka.ms/oai/quotaincrease\", and a link in a message is\n // advice, not the diagnosis.\n const haystack = `${code} ${type} ${message}`.toLowerCase().replace(/https?:\\/\\/\\S+/g, \"\");\n\n if (status === 429) {\n // A spent quota answers 429 and will answer 429 for the rest of the month.\n // Retrying it is how a run turns one billing problem into `maxRetries`\n // billing problems and a much later error message. A code that names a\n // rate limit is believed over any wording, though: Azure's\n // `RateLimitReached` asks for a retry in so many seconds.\n const outOfCredit =\n !RATE_LIMIT_CODES.has(code) && (code === \"insufficient_quota\" || haystack.includes(\"quota\"));\n if (outOfCredit) return { code: \"rate_limited\", message, retryable: false };\n const retryAfter = retryAfterHeader ?? retryAfterFromMessage(message);\n return {\n code: \"rate_limited\",\n message,\n retryable: true,\n ...(retryAfter !== undefined ? { retryAfter } : {}),\n };\n }\n\n if (status >= 500 || status === 408 || status === 409) {\n return { code: \"provider_error\", message, retryable: true };\n }\n\n if (isContextLength(haystack)) {\n return { code: \"context_length_exceeded\", message, retryable: false };\n }\n\n if (isContentFilter(haystack)) {\n return { code: \"content_filtered\", message, retryable: false };\n }\n\n // A schema the API refused. It is our request that is wrong, so the run\n // should surface it as a tool problem rather than a generic outage.\n if (body?.param?.startsWith(\"tools\") || haystack.includes(\"invalid schema for function\")) {\n return { code: \"invalid_tool_input\", message, retryable: false };\n }\n\n return { code: \"provider_error\", message, retryable: false };\n}\n\n/** Body codes that say \"too many requests right now\", never \"out of credit\". */\nconst RATE_LIMIT_CODES = new Set([\"ratelimitreached\", \"rate_limit_exceeded\", \"too_many_requests\"]);\n\n/**\n * \"Please retry after 30 seconds\", as Azure words it in a 429 that may come\n * without a `Retry-After` header. Milliseconds, or undefined when the message\n * does not say.\n */\nexport function retryAfterFromMessage(message: string): number | undefined {\n const match = /retry after (\\d+(?:\\.\\d+)?)\\s*(milliseconds?|ms|seconds?|secs?|s)\\b/i.exec(message);\n if (!match) return undefined;\n const value = Number(match[1]);\n return /^m(s|illi)/i.test(match[2]!) ? value : value * 1000;\n}\n\nfunction isContextLength(haystack: string): boolean {\n return (\n haystack.includes(\"context_length_exceeded\") ||\n haystack.includes(\"maximum context length\") ||\n haystack.includes(\"context window\") ||\n haystack.includes(\"reduce the length\") ||\n // Anthropic: 400 \"prompt is too long: 1050000 tokens > 1000000 maximum\",\n // and 413 `request_too_large` for a body over the byte limit. Neither\n // works on a retry; both want a shorter history.\n haystack.includes(\"prompt is too long\") ||\n haystack.includes(\"request_too_large\")\n );\n}\n\nfunction isContentFilter(haystack: string): boolean {\n return (\n haystack.includes(\"content_filter\") ||\n haystack.includes(\"content_policy_violation\") ||\n haystack.includes(\"responsibleaipolicyviolation\") ||\n haystack.includes(\"content management policy\") ||\n // The image models' refusal: `code: \"moderation_blocked\"`, \"Your request\n // was rejected by the safety system ... safety_violations=[...]\".\n haystack.includes(\"moderation_blocked\") ||\n haystack.includes(\"rejected by the safety system\") ||\n haystack.includes(\"safety_violations\")\n );\n}\n\nfunction isAbort(error: unknown): boolean {\n if (!error || typeof error !== \"object\") return false;\n const e = error as { name?: string; code?: string };\n return e.name === \"AbortError\" || e.code === \"ABORT_ERR\";\n}\n"
|
|
9
|
+
],
|
|
10
|
+
"mappings": ";yCAgBO,MAAM,UAAkB,KAAM,CAE1B,UAET,WAAW,CAAC,EAAiB,EAAoD,CAAC,EAAG,CACnF,MAAM,EAAS,EAAQ,QAAU,OAAY,CAAE,MAAO,EAAQ,KAAM,EAAI,MAAS,EACjF,KAAK,KAAO,YACZ,KAAK,UAAY,EAAQ,WAAa,GAE1C,CAqCA,IAAM,EAAgE,CACpE,eAAgB,wCAChB,aAAc,mEACd,wBAAyB,8CACzB,iBAAkB,4DAClB,mBAAoB,2CACpB,WAAY,iBACZ,QAAS,8BACX,EAWO,SAAS,CAAW,CAAC,EAAmB,EAAsC,CACnF,GAAI,EAAK,SAAW,OAAQ,CAC1B,GAAI,EAAK,iBAAiB,EAAW,OAAO,EAC5C,MAAO,IACF,EACH,QAAS,aAAa,EAAK,4CAC7B,EAEF,IAAM,EAAU,EAAqB,EAAM,MAC3C,OAAO,IAAY,OAAY,EAAQ,IAAK,EAAO,Q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2
|
-
import{$ as RJ,_ as p,aa as TJ,ba as SJ}from"./chunk-j6j0qxam.js";import{Da as b,Ha as R,Ia as BJ}from"./chunk-v2fd69at.js";import"./chunk-ba1h9pm6.js";import{Re as YJ,gh as LJ,hh as k,ph as DJ,qh as PJ,rh as AJ}from"./chunk-9pjvetym.js";import"./chunk-9k6swvf1.js";import"./chunk-2crfg0m7.js";import{Ai as jJ,wi as XJ,xi as HJ}from"./chunk-g1th1dfa.js";import{Nj as NJ}from"./chunk-5ya7fbfg.js";import"./chunk-naj8bmj5.js";import"./chunk-95yr9y9v.js";import"./chunk-dpm875be.js";import"./chunk-hknnxxg6.js";import"./chunk-5m0vh0rg.js";import"./chunk-mnfk2r8z.js";import"./chunk-a6yge4kh.js";import"./chunk-zbxvyanj.js";import"./chunk-kc1y747c.js";import"./chunk-6669vjve.js";import"./chunk-6s48nq83.js";import"./chunk-4zw9gaey.js";import"./chunk-kd6z1t9z.js";import"./chunk-3pfrqzw8.js";import{mm as zJ}from"./chunk-y9fye7az.js";import"./chunk-hea3rwj3.js";import{Em as FJ}from"./chunk-shn9t4vg.js";import{Gm as y}from"./chunk-bw1mvk6n.js";import"./chunk-0z8h6t7k.js";import{createHash as L2}from"crypto";import{join as d,resolve as qJ,sep as bJ}from"path";import{Duplex as hJ}from"stream";import{constants as v,createBrotliCompress as cJ,createGzip as pJ}from"zlib";var dJ=["br","gzip"],lJ=1024,oJ=5,nJ=19,iJ=6;function rJ(J){if(J===void 0)return 1;if(!/^\d+(\.\d{0,3})?$/.test(J.trim()))return 1;let $=Number(J.trim());return Number.isFinite($)?Math.min($,1):1}function aJ(J){if(J===null||J===void 0)return null;let $=new Map;for(let Z of J.split(",")){let[Q,...H]=Z.split(";"),j=Q.trim().toLowerCase();if(j==="")continue;let Y=1;for(let W of H){let G=W.indexOf("=");if(G===-1)continue;if(W.slice(0,G).trim().toLowerCase()==="q"){Y=rJ(W.slice(G+1));break}}$.set(j,Y)}return $}function u(J,$=dJ){let Z=aJ(J);if(!Z)return null;let Q=Z.get("*"),H=null,j=0;for(let Y of $){let W=Z.get(Y)??Q??0;if(W>j)H=Y,j=W}return H}function sJ(J,$){if(!J)return!1;return J.split(",").some((Z)=>Z.trim().toLowerCase().split("=")[0].trim()===$)}function tJ(J,$){if(J==="HEAD")return!1;if($.status<200||$.status===204||$.status===206||$.status===304)return!1;if($.headers.has("Content-Range"))return!1;let Z=$.headers.get("Content-Type");if(!Z||!/^\s*text\/html\s*(;|$)/i.test(Z))return!1;if(!$.body)return!1;let Q=$.headers.get("Content-Encoding");if(Q&&Q.trim().toLowerCase()!=="identity")return!1;if(sJ($.headers.get("Cache-Control"),"no-transform"))return!1;let H=$.headers.get("Content-Length");if(H!==null&&Number(H)<lJ)return!1;return!0}function eJ(J){let $=J==="br"?cJ({params:{[v.BROTLI_PARAM_QUALITY]:oJ,[v.BROTLI_PARAM_LGWIN]:nJ},flush:v.BROTLI_OPERATION_FLUSH}):pJ({level:iJ,flush:v.Z_SYNC_FLUSH});return hJ.toWeb($)}function J2(J){let $=J.get("Vary");if(!$){J.set("Vary","Accept-Encoding");return}let Z=$.split(",").map((Q)=>Q.trim().toLowerCase());if(Z.includes("*")||Z.includes("accept-encoding"))return;J.append("Vary","Accept-Encoding")}function JJ(J,$){if(!tJ(J.method,$))return $;let Z=new Headers($.headers);J2(Z);let Q=u(J.headers.get("Accept-Encoding"));if(!Q)return new Response($.body,{status:$.status,statusText:$.statusText,headers:Z});let H;try{H=eJ(Q)}catch{return new Response($.body,{status:$.status,statusText:$.statusText,headers:Z})}return Z.set("Content-Encoding",Q),Z.delete("Content-Length"),new Response($.body.pipeThrough(H),{status:$.status,statusText:$.statusText,headers:Z})}import{readdir as Y2,stat as WJ}from"fs/promises";import{join as W2}from"path";import{mkdir as B2,readFile as $2,stat as R2,writeFile as T2}from"fs/promises";import{dirname as q2,join as Z2}from"path";import{promisify as $J}from"util";import{brotliCompress as Q2,constants as v2,gzip as X2}from"zlib";var H2=".vite/static-assets.json";var ZJ={br:".br",gzip:".gz"},j2=["br","gzip"],w2=$J(Q2),k2=$J(X2);async function QJ(J){let $;try{$=await $2(Z2(J,H2),"utf8")}catch{return null}let Z;try{Z=JSON.parse($)?.files}catch{return null}if(!Z||typeof Z!=="object")return null;let Q={files:{}};for(let[H,j]of Object.entries(Z)){if(!Array.isArray(j))continue;Q.files[H]=j2.filter((Y)=>j.includes(Y))}return Q}function m(J){let $=J.toString(),Z=new Bun.CryptoHasher("sha1");return Z.update($),Z.digest("hex")}async function GJ(J){let $=new Set;async function Z(Q,H){let j;try{j=await Y2(Q,{withFileTypes:!0})}catch{return}for(let Y of j){if(Y.name.startsWith("."))continue;if(H&&Y.name==="assets")continue;let W=W2(Q,Y.name),G=Y.isDirectory(),z=Y.isFile();if(Y.isSymbolicLink())try{let C=await WJ(W);G=C.isDirectory(),z=C.isFile()}catch{continue}if(z)$.add(W);else if(G&&!Y.isSymbolicLink())await Z(W,!1)}}return await Z(J,!0),$}var G2="public, max-age=31536000, must-revalidate",V2="public, max-age=31536000, immutable";async function z2(J,$,Z){if(Z.length===0||J.headers.has("Range"))return null;let Q=u(J.headers.get("Accept-Encoding"),Z);if(!Q)return null;let H=$+ZJ[Q];try{let j=await WJ(H);return j.isFile()?{encoding:Q,path:H,size:j.size}:null}catch{return null}}async function VJ(J,$,Z={}){let Q=Bun.file($),H=Z.encodings??[],j={"Content-Type":Q.type||"application/octet-stream","Cache-Control":Z.immutable?V2:G2,"Accept-Ranges":"bytes"};if(H.length>0)j.Vary="Accept-Encoding";let Y=await z2(J,$,H);if(Y){let z=Bun.file(Y.path);return new Response(z.stream(),{headers:{...j,"Content-Encoding":Y.encoding,"Content-Length":String(Y.size),ETag:`${m(z.lastModified)}-${Y.encoding}`}})}let W=Q.size;j.ETag=m(Q.lastModified);let G=XJ(J.headers.get("Range"));if(G){let z=HJ(G,W);if(!z)return YJ(W);return new Response(Q.slice(z.start,z.end+1).stream(),{status:206,headers:{...j,"Content-Range":jJ(z.start,z.end,W),"Content-Length":String(z.length)}})}return new Response(Q.stream(),{headers:{...j,"Content-Length":String(W)}})}import{stat as _2}from"fs/promises";var w="app/client.tsx";function UJ(J,$=b){let Z=J[w]?.file;if(!Z)return;return{module:R(Z,$),preload:B(J,w,$)}}function B(J,$,Z=b){let Q=[],H=new Set,j=(Y)=>{if(H.has(Y))return;H.add(Y);let W=J[Y];if(!W?.file)return;Q.push(R(W.file,Z));for(let G of W.imports??[])j(G)};return j($),Q}function U2(J,$,Z=b){let Q=new Set(B(J,$,Z)),H=[],j=new Set,Y=(G)=>{if(j.has(G))return;j.add(G);let z=J[G];if(!z)return;for(let C of z.dynamicImports??[])if(!/(^|\/)node_modules\//.test(C)&&!H.includes(C))H.push(C);for(let C of z.imports??[])Y(C)};Y($);let W=[];for(let G of H)for(let z of B(J,G,Z))if(!Q.has(z))Q.add(z),W.push(z);return W}function KJ(J,$){let Z=[],Q=new Set,H=new Set,j=(Y)=>{if(H.has(Y))return;H.add(Y);let W=J[Y];if(!W)return;for(let G of W.imports??[])j(G);for(let G of W.css??[])if(!Q.has(G))Q.add(G),Z.push(G)};return j($),Z}function OJ(J,$=b){let Z=new Map;return(Q)=>{if(!Z.has(Q)){let H=`${Q}${zJ}`,j=J[H]?.file;Z.set(Q,j?{src:R(j,$),preload:B(J,H,$),dynamicPreload:U2(J,H,$)}:void 0)}return Z.get(Q)}}var xJ="x-gemi-build";var K2="__gemiReload";function O2(J,$,Z,Q){let H=Date.now(),j=function(U){return typeof U==="number"&&H-U>=0&&H-U<Z},Y=function(U){try{let K=U?JSON.parse(U):null;return K&&typeof K==="object"&&!Array.isArray(K)?K:{}}catch{return{}}},W=function(U){let K={};for(let M in U)if(j(U[M]))K[M]=U[M];return K},G=function(U){let K=2166136261;for(let M=0;M<U.length;M++)K=Math.imul(K^U.charCodeAt(M),16777619);return(K>>>0).toString(36)},z=null,C={};try{z=window.sessionStorage,C=Y(z.getItem(J))}catch{z=null}let N=J+":",F="",I="";try{let U=new URL($,window.location.href);F=G(new URL(window.location.href).origin),I=G(U.origin+U.pathname)}catch{}let L=null;try{let U=window.name;if(!I)L=null;else if(U==="")L={};else if(U.indexOf(N)===0){let K=Y(U.slice(N.length)),M=K.m;L=K.o===F&&M&&typeof M==="object"&&!Array.isArray(M)?M:{}}}catch{L=null}if(Q==="tidy"){try{let U=window.name;if(L===null||U.indexOf(N)!==0)return"ok";for(let K in L)if(j(L[K]))return"cooldown";window.name=""}catch{}return"ok"}if(j(C[$])||L&&j(L[I]))return"cooldown";if(!z&&!L)return"storage";if(!Q)return"ok";if(z)try{let U=W(C);U[$]=H;let K=JSON.stringify(U);if(z.setItem(J,K),z.getItem(J)===K)return"ok"}catch{}if(L)try{let U=W(L);U[I]=H;let K=N+JSON.stringify({o:F,m:U});if(window.name=K,window.name===K)return"ok"}catch{}return"storage"}function CJ(J,$=30000){let Z=JSON.stringify("gemi:chunk-reload"),Q=JSON.stringify(`Failed to fetch dynamically imported module: ${J}`);return`var g=${O2.toString()};var r=!1;try{r=navigator.onLine!==!1&&g(${Z},window.location.href,${Number($)},!0)==="ok"}catch(e){}if(r)window.location.reload();else throw new Error(${Q});export {r as ${K2}}`}var x2=new RegExp(`^${LJ}/.+\\.m?js$`);function h(J){return x2.test(J)}function _J(J){if(h(J))return new Response(CJ(J),{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store"}});if(k(J))return new Response("Not found",{status:404});return}function IJ(J){let $=J?.trim();if(!$)return;try{let Z=new URL($);if(Z.protocol!=="https:"&&Z.protocol!=="http:")throw Error("not http(s)");return Z.search="",Z.hash="",Z.href.endsWith("/")?Z.href:`${Z.href}/`}catch{console.error(`GEMI_ASSET_FALLBACK_URL is not an absolute http(s) URL (${JSON.stringify($)}); missing assets are not looked up anywhere else.`);return}}function MJ({base:J,timeoutMs:$=3000,missTtlMs:Z=30000,fetch:Q=fetch,now:H=Date.now}){let j=new Map,Y=(W)=>{if(j.delete(W),j.set(W,H()+Z),j.size>1000)j.delete(j.keys().next().value)};return async(W,G)=>{if(W.method!=="GET"&&W.method!=="HEAD")return;let z=j.get(G);if(z!==void 0){if(z>H())return;j.delete(G)}let C;try{C=new URL(G.replace(/^\/+/,""),J)}catch{return}if(!C.href.startsWith(J))return;let N=new AbortController,F=setTimeout(()=>N.abort(),$),I;try{I=await Q(C.href,{method:W.method,signal:N.signal,redirect:"error"})}catch{Y(G);return}finally{clearTimeout(F)}if(I.status!==200){I.body?.cancel().catch(()=>{}),Y(G);return}let L=Bun.file(G).type,U=new Headers({"Content-Type":L!=="application/octet-stream"&&L||I.headers.get("content-type")||"application/octet-stream","Cache-Control":"public, max-age=31536000, immutable",["x-gemi-asset-fallback"]:"1"}),K=I.headers.get("content-length");if(K&&!I.headers.get("content-encoding"))U.set("Content-Length",K);return new Response(W.method==="HEAD"?null:I.body,{status:200,headers:U})}}var C2=`<!DOCTYPE html>
|
|
2
|
+
import{$ as RJ,_ as p,aa as TJ,ba as SJ}from"./chunk-7rmb1v9c.js";import{Da as b,Ha as R,Ia as BJ}from"./chunk-v2fd69at.js";import"./chunk-ba1h9pm6.js";import{Te as YJ,ih as LJ,jh as k,rh as DJ,sh as PJ,th as AJ}from"./chunk-sxxkkx75.js";import"./chunk-s7jwsbfd.js";import"./chunk-4s72m6zx.js";import{Ci as jJ,yi as XJ,zi as HJ}from"./chunk-xese0rng.js";import{Pj as NJ}from"./chunk-eh3ktv8k.js";import"./chunk-snt0523y.js";import"./chunk-ww62b10k.js";import"./chunk-gxfyd8wr.js";import"./chunk-m0pfdc1n.js";import"./chunk-ncw3zjxm.js";import"./chunk-k8nsefzb.js";import"./chunk-xb0evp2m.js";import"./chunk-yxtfg4wy.js";import"./chunk-xyv3y476.js";import"./chunk-qa528feb.js";import"./chunk-jzqywxpj.js";import"./chunk-qstjm3cb.js";import"./chunk-aes0ecnp.js";import"./chunk-sba3s380.js";import{om as zJ}from"./chunk-cwm5x7rf.js";import"./chunk-q0d45r2j.js";import{Gm as FJ}from"./chunk-hmtn7996.js";import{Im as y}from"./chunk-rp2f9mq1.js";import"./chunk-yedb5vvg.js";import{createHash as L2}from"crypto";import{join as d,resolve as qJ,sep as bJ}from"path";import{Duplex as hJ}from"stream";import{constants as v,createBrotliCompress as cJ,createGzip as pJ}from"zlib";var dJ=["br","gzip"],lJ=1024,oJ=5,nJ=19,iJ=6;function rJ(J){if(J===void 0)return 1;if(!/^\d+(\.\d{0,3})?$/.test(J.trim()))return 1;let $=Number(J.trim());return Number.isFinite($)?Math.min($,1):1}function aJ(J){if(J===null||J===void 0)return null;let $=new Map;for(let Z of J.split(",")){let[Q,...H]=Z.split(";"),j=Q.trim().toLowerCase();if(j==="")continue;let Y=1;for(let W of H){let G=W.indexOf("=");if(G===-1)continue;if(W.slice(0,G).trim().toLowerCase()==="q"){Y=rJ(W.slice(G+1));break}}$.set(j,Y)}return $}function u(J,$=dJ){let Z=aJ(J);if(!Z)return null;let Q=Z.get("*"),H=null,j=0;for(let Y of $){let W=Z.get(Y)??Q??0;if(W>j)H=Y,j=W}return H}function sJ(J,$){if(!J)return!1;return J.split(",").some((Z)=>Z.trim().toLowerCase().split("=")[0].trim()===$)}function tJ(J,$){if(J==="HEAD")return!1;if($.status<200||$.status===204||$.status===206||$.status===304)return!1;if($.headers.has("Content-Range"))return!1;let Z=$.headers.get("Content-Type");if(!Z||!/^\s*text\/html\s*(;|$)/i.test(Z))return!1;if(!$.body)return!1;let Q=$.headers.get("Content-Encoding");if(Q&&Q.trim().toLowerCase()!=="identity")return!1;if(sJ($.headers.get("Cache-Control"),"no-transform"))return!1;let H=$.headers.get("Content-Length");if(H!==null&&Number(H)<lJ)return!1;return!0}function eJ(J){let $=J==="br"?cJ({params:{[v.BROTLI_PARAM_QUALITY]:oJ,[v.BROTLI_PARAM_LGWIN]:nJ},flush:v.BROTLI_OPERATION_FLUSH}):pJ({level:iJ,flush:v.Z_SYNC_FLUSH});return hJ.toWeb($)}function J2(J){let $=J.get("Vary");if(!$){J.set("Vary","Accept-Encoding");return}let Z=$.split(",").map((Q)=>Q.trim().toLowerCase());if(Z.includes("*")||Z.includes("accept-encoding"))return;J.append("Vary","Accept-Encoding")}function JJ(J,$){if(!tJ(J.method,$))return $;let Z=new Headers($.headers);J2(Z);let Q=u(J.headers.get("Accept-Encoding"));if(!Q)return new Response($.body,{status:$.status,statusText:$.statusText,headers:Z});let H;try{H=eJ(Q)}catch{return new Response($.body,{status:$.status,statusText:$.statusText,headers:Z})}return Z.set("Content-Encoding",Q),Z.delete("Content-Length"),new Response($.body.pipeThrough(H),{status:$.status,statusText:$.statusText,headers:Z})}import{readdir as Y2,stat as WJ}from"fs/promises";import{join as W2}from"path";import{mkdir as B2,readFile as $2,stat as R2,writeFile as T2}from"fs/promises";import{dirname as q2,join as Z2}from"path";import{promisify as $J}from"util";import{brotliCompress as Q2,constants as v2,gzip as X2}from"zlib";var H2=".vite/static-assets.json";var ZJ={br:".br",gzip:".gz"},j2=["br","gzip"],w2=$J(Q2),k2=$J(X2);async function QJ(J){let $;try{$=await $2(Z2(J,H2),"utf8")}catch{return null}let Z;try{Z=JSON.parse($)?.files}catch{return null}if(!Z||typeof Z!=="object")return null;let Q={files:{}};for(let[H,j]of Object.entries(Z)){if(!Array.isArray(j))continue;Q.files[H]=j2.filter((Y)=>j.includes(Y))}return Q}function m(J){let $=J.toString(),Z=new Bun.CryptoHasher("sha1");return Z.update($),Z.digest("hex")}async function GJ(J){let $=new Set;async function Z(Q,H){let j;try{j=await Y2(Q,{withFileTypes:!0})}catch{return}for(let Y of j){if(Y.name.startsWith("."))continue;if(H&&Y.name==="assets")continue;let W=W2(Q,Y.name),G=Y.isDirectory(),z=Y.isFile();if(Y.isSymbolicLink())try{let C=await WJ(W);G=C.isDirectory(),z=C.isFile()}catch{continue}if(z)$.add(W);else if(G&&!Y.isSymbolicLink())await Z(W,!1)}}return await Z(J,!0),$}var G2="public, max-age=31536000, must-revalidate",V2="public, max-age=31536000, immutable";async function z2(J,$,Z){if(Z.length===0||J.headers.has("Range"))return null;let Q=u(J.headers.get("Accept-Encoding"),Z);if(!Q)return null;let H=$+ZJ[Q];try{let j=await WJ(H);return j.isFile()?{encoding:Q,path:H,size:j.size}:null}catch{return null}}async function VJ(J,$,Z={}){let Q=Bun.file($),H=Z.encodings??[],j={"Content-Type":Q.type||"application/octet-stream","Cache-Control":Z.immutable?V2:G2,"Accept-Ranges":"bytes"};if(H.length>0)j.Vary="Accept-Encoding";let Y=await z2(J,$,H);if(Y){let z=Bun.file(Y.path);return new Response(z.stream(),{headers:{...j,"Content-Encoding":Y.encoding,"Content-Length":String(Y.size),ETag:`${m(z.lastModified)}-${Y.encoding}`}})}let W=Q.size;j.ETag=m(Q.lastModified);let G=XJ(J.headers.get("Range"));if(G){let z=HJ(G,W);if(!z)return YJ(W);return new Response(Q.slice(z.start,z.end+1).stream(),{status:206,headers:{...j,"Content-Range":jJ(z.start,z.end,W),"Content-Length":String(z.length)}})}return new Response(Q.stream(),{headers:{...j,"Content-Length":String(W)}})}import{stat as _2}from"fs/promises";var w="app/client.tsx";function UJ(J,$=b){let Z=J[w]?.file;if(!Z)return;return{module:R(Z,$),preload:B(J,w,$)}}function B(J,$,Z=b){let Q=[],H=new Set,j=(Y)=>{if(H.has(Y))return;H.add(Y);let W=J[Y];if(!W?.file)return;Q.push(R(W.file,Z));for(let G of W.imports??[])j(G)};return j($),Q}function U2(J,$,Z=b){let Q=new Set(B(J,$,Z)),H=[],j=new Set,Y=(G)=>{if(j.has(G))return;j.add(G);let z=J[G];if(!z)return;for(let C of z.dynamicImports??[])if(!/(^|\/)node_modules\//.test(C)&&!H.includes(C))H.push(C);for(let C of z.imports??[])Y(C)};Y($);let W=[];for(let G of H)for(let z of B(J,G,Z))if(!Q.has(z))Q.add(z),W.push(z);return W}function KJ(J,$){let Z=[],Q=new Set,H=new Set,j=(Y)=>{if(H.has(Y))return;H.add(Y);let W=J[Y];if(!W)return;for(let G of W.imports??[])j(G);for(let G of W.css??[])if(!Q.has(G))Q.add(G),Z.push(G)};return j($),Z}function OJ(J,$=b){let Z=new Map;return(Q)=>{if(!Z.has(Q)){let H=`${Q}${zJ}`,j=J[H]?.file;Z.set(Q,j?{src:R(j,$),preload:B(J,H,$),dynamicPreload:U2(J,H,$)}:void 0)}return Z.get(Q)}}var xJ="x-gemi-build";var K2="__gemiReload";function O2(J,$,Z,Q){let H=Date.now(),j=function(U){return typeof U==="number"&&H-U>=0&&H-U<Z},Y=function(U){try{let K=U?JSON.parse(U):null;return K&&typeof K==="object"&&!Array.isArray(K)?K:{}}catch{return{}}},W=function(U){let K={};for(let M in U)if(j(U[M]))K[M]=U[M];return K},G=function(U){let K=2166136261;for(let M=0;M<U.length;M++)K=Math.imul(K^U.charCodeAt(M),16777619);return(K>>>0).toString(36)},z=null,C={};try{z=window.sessionStorage,C=Y(z.getItem(J))}catch{z=null}let N=J+":",F="",I="";try{let U=new URL($,window.location.href);F=G(new URL(window.location.href).origin),I=G(U.origin+U.pathname)}catch{}let L=null;try{let U=window.name;if(!I)L=null;else if(U==="")L={};else if(U.indexOf(N)===0){let K=Y(U.slice(N.length)),M=K.m;L=K.o===F&&M&&typeof M==="object"&&!Array.isArray(M)?M:{}}}catch{L=null}if(Q==="tidy"){try{let U=window.name;if(L===null||U.indexOf(N)!==0)return"ok";for(let K in L)if(j(L[K]))return"cooldown";window.name=""}catch{}return"ok"}if(j(C[$])||L&&j(L[I]))return"cooldown";if(!z&&!L)return"storage";if(!Q)return"ok";if(z)try{let U=W(C);U[$]=H;let K=JSON.stringify(U);if(z.setItem(J,K),z.getItem(J)===K)return"ok"}catch{}if(L)try{let U=W(L);U[I]=H;let K=N+JSON.stringify({o:F,m:U});if(window.name=K,window.name===K)return"ok"}catch{}return"storage"}function CJ(J,$=30000){let Z=JSON.stringify("gemi:chunk-reload"),Q=JSON.stringify(`Failed to fetch dynamically imported module: ${J}`);return`var g=${O2.toString()};var r=!1;try{r=navigator.onLine!==!1&&g(${Z},window.location.href,${Number($)},!0)==="ok"}catch(e){}if(r)window.location.reload();else throw new Error(${Q});export {r as ${K2}}`}var x2=new RegExp(`^${LJ}/.+\\.m?js$`);function h(J){return x2.test(J)}function _J(J){if(h(J))return new Response(CJ(J),{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store"}});if(k(J))return new Response("Not found",{status:404});return}function IJ(J){let $=J?.trim();if(!$)return;try{let Z=new URL($);if(Z.protocol!=="https:"&&Z.protocol!=="http:")throw Error("not http(s)");return Z.search="",Z.hash="",Z.href.endsWith("/")?Z.href:`${Z.href}/`}catch{console.error(`GEMI_ASSET_FALLBACK_URL is not an absolute http(s) URL (${JSON.stringify($)}); missing assets are not looked up anywhere else.`);return}}function MJ({base:J,timeoutMs:$=3000,missTtlMs:Z=30000,fetch:Q=fetch,now:H=Date.now}){let j=new Map,Y=(W)=>{if(j.delete(W),j.set(W,H()+Z),j.size>1000)j.delete(j.keys().next().value)};return async(W,G)=>{if(W.method!=="GET"&&W.method!=="HEAD")return;let z=j.get(G);if(z!==void 0){if(z>H())return;j.delete(G)}let C;try{C=new URL(G.replace(/^\/+/,""),J)}catch{return}if(!C.href.startsWith(J))return;let N=new AbortController,F=setTimeout(()=>N.abort(),$),I;try{I=await Q(C.href,{method:W.method,signal:N.signal,redirect:"error"})}catch{Y(G);return}finally{clearTimeout(F)}if(I.status!==200){I.body?.cancel().catch(()=>{}),Y(G);return}let L=Bun.file(G).type,U=new Headers({"Content-Type":L!=="application/octet-stream"&&L||I.headers.get("content-type")||"application/octet-stream","Cache-Control":"public, max-age=31536000, immutable",["x-gemi-asset-fallback"]:"1"}),K=I.headers.get("content-length");if(K&&!I.headers.get("content-encoding"))U.set("Content-Length",K);return new Response(W.method==="HEAD"?null:I.body,{status:200,headers:U})}}var C2=`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8" />
|
|
@@ -21,4 +21,4 @@ import{$ as RJ,_ as p,aa as TJ,ba as SJ}from"./chunk-j6j0qxam.js";import{Da as b
|
|
|
21
21
|
</html>`;function c(J,$,Z){if(!Z)console.error(J);else try{Z(J instanceof Error?J:Error(String(J),{cause:J}))}catch(Q){console.error(J),console.error(Q)}if(y($))return new Response(JSON.stringify({error:NJ("server_error","Internal Server Error",500)}),{status:500,headers:{"Content-Type":"application/json"}});return new Response(C2,{status:500,headers:{"Content-Type":"text/html; charset=utf-8"}})}var g=FJ(),I2=d(g,"app"),D=d(g,"dist"),T=d(D,"client");function M2(J){let $;try{$=decodeURIComponent(J)}catch{return null}let Z=qJ(T,"."+$.replace("/assets/assets","/assets"));return Z.startsWith(T+bJ)?Z:null}async function N2(J){try{return(await _2(J)).isFile()}catch{return!1}}async function F3(J,$){let Z=await import(`${D}/client/.vite/manifest.json`),Q=await import(`${D}/server/.vite/manifest.json`),H=await BJ(`${D}/client`);process.env.ROOT_DIR=g,process.env.APP_DIR=I2,process.env.DIST_DIR=D;let j={},Y={},W={},G={},z={},C=(X,V)=>`"${X}": () => import("${V}")`,N=[],F=J.getRequiredViews.call(J);for(let X of["404",...J.getFlatComponentTree.call(J)]){let V=Q[`app/views/${X}.tsx`];if(!V?.file&&F[X])throw TJ(X,F[X]);if(!V?.file){console.log(`Server file not found for ${X}`),console.log(V);let _=Object.keys(Q),A=`app/views/${X}.tsx`;console.log(`${A} not found in server manifest`),console.log(_)}let x=await import(`${process.env.DIST_DIR}/server/${V?.file}`);j[X]=x.default,Y[X]=x.OpenGraph,W[X]=x;let O=Z[`app/views/${X}.tsx`];if(O?.css&&O?.css.length>0)G[X]=O?.css;if(O)N.push(C(X,R(O?.file,H))),z[X]=B(Z,`app/views/${X}.tsx`,H)}let I=`{${N.join(",")}}`,L=UJ(Z,H);if(!L)console.error(`Client manifest has no "${w}" entry \u2014 dist/client is incomplete, so documents will render but never hydrate.`);let U=Z["app/client.tsx"]?.css??[],K=(await Promise.all(U.map((X)=>Bun.file(`${D}/client/${X}`).text()))).join(`
|
|
22
22
|
`),M=OJ(Z,H),l=L2("sha256").update(await Bun.file(`${D}/client/.vite/manifest.json`).text()).digest("base64url").slice(0,12),o=new Map,EJ=(X)=>{let V=o.get(X);if(!V)V=Bun.file(`${D}/client/${X}`).text(),o.set(X,V);return V},vJ=async(X,V)=>{let x=new Set;for(let _ of V?[V,...X]:X)for(let A of KJ(Z,`app/views/${_}.tsx`))x.add(A);let O=await Promise.all([...x].map(async(_)=>({id:_,content:await EJ(_)})));return p(V?O:[{content:K},...O])},wJ=await GJ(T),n=new Map;for(let[X,V]of Object.entries((await QJ(T))?.files??{})){let x=qJ(T,X);if(x.startsWith(T+bJ))n.set(x,{immutable:!0,encodings:V})}let i=IJ(process.env.GEMI_ASSET_FALLBACK_URL),r=i?MJ({base:i}):void 0;async function kJ(X){let{pathname:V}=new URL(X.url);if(y(V))return await S(X,V);let x=M2(V),O=k(V),_=!O&&x!==null&&wJ.has(x),A=O||V.startsWith("/.well-known")||_;if(_&&!(await a(X)).publicFiles)return await S(X,V);if(A){if(!x||!await N2(x)){if(O&&r){let P=await r(X,V);if(P)return P}if(O&&!h(V)&&(await a(X)).assetRoutes)return await S(X,V);return _J(V)??await S(X,V)}try{return await VJ(X,x,n.get(x))}catch(P){return J.onException?.(P),new Response("Not found",{status:404})}}let E=await S(X,V);if(V.endsWith(".json"))try{E.headers.set(xJ,l)}catch{}return E}async function a(X){try{return await J.staticFiles?.(X)??{publicFiles:!0,assetRoutes:!1}}catch{return{publicFiles:!1,assetRoutes:!0}}}async function S(X,V){let x=J.fetch.bind(J);try{let O=await x(X);if(O instanceof Response)return O;else{let _=[];return _.push({content:K}),await O({getStyles:async(E,P)=>{let t=E??["404"];if(P?.static)return vJ(t,P.layout);for(let fJ of t){let uJ=Z[`app/views/${fJ}.tsx`];for(let e of uJ?.css??[]){let mJ=Bun.file(`${process.env.DIST_DIR}/client/${e}`);_.push({id:e,content:await mJ.text()})}}return p(_)},clientEntry:L,modulePreloadManifest:z,loaders:I,viewImportMap:j,viewModules:W,ogMap:Y,cssManifest:G,assetBase:H,resolveIsland:M,buildId:l})}}catch(O){return c(O,V,J.onException)}}let yJ=(process.env.GEMI_COMPRESSION??"auto").toLowerCase()!=="off",s=DJ(process.env.GEMI_TRUST_PROXY),gJ=AJ(process.env),q=J.sockets();if(q&&s.kind==="none"&&!gJ)console.warn("[gemi] Broadcast sockets: GEMI_TRUST_PROXY is not set, so a socket's address is its TCP peer. Behind a proxy or load balancer every client shares the proxy's address, and broadcast.maxConnectionsPerIp caps the whole app per process. Set GEMI_TRUST_PROXY (see forwardedFor) or raise that limit.");let f=Bun.serve({maxRequestBodySize:10737418240,fetch:async(X,V)=>{if(PJ(X.headers,V.requestIP(X)?.address??null,s),J.applyTrustedClientIp(X),q?.matches(X))return q.upgrade(X,V);let x=await $(X,(O)=>J.withGlobalMiddleware(O,kJ,(_)=>c(_,new URL(O.url).pathname,J.onException)));return yJ?JJ(X,x):x},idleTimeout:SJ(),port:process.env.PORT||5173,websocket:q?.websocket});return await q?.start(f),RJ({port:f.port,rootDir:g}),f}export{F3 as httpProd};
|
|
23
23
|
|
|
24
|
-
//# debugId=
|
|
24
|
+
//# debugId=E90A7CC68CA086FB64756E2164756E21
|
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
"import { stringEraRefusal } from \"../http/Error\";\nimport { isApiPath } from \"../services/router/apiPath\";\n\n// The production server's last resort: an error nothing on the way here turned\n// into a response. Request breakers (auth, 404s, 416s) are answered by the\n// dispatchers before this, so what arrives is a genuine failure — and its\n// message and stack are for the developer, not for whoever triggered it. They\n// can carry absolute paths, dependency versions, SQL fragments and column\n// names. The dev server renders them on purpose (`httpDev.ts`); this does not.\n\nconst GENERIC_500_HTML = `<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Internal Server Error</title>\n <style>\n body { font-family: system-ui, sans-serif; margin: 0; min-height: 100vh; display: grid; place-items: center; }\n main { text-align: center; padding: 16px; }\n h1 { font-size: 1.5rem; margin: 0 0 0.5rem; }\n p { margin: 0; opacity: 0.7; }\n </style>\n </head>\n <body>\n <main>\n <h1>Something went wrong</h1>\n <p>Please try again later.</p>\n </main>\n </body>\n</html>`;\n\nexport function unhandledErrorResponse(\n err: unknown,\n pathname: string,\n onException?: (error: Error) => void,\n): Response {\n // `onException` is the report, and the default one `App` installs is a\n // `console.error`, so logging here as well printed every failure twice\n // (three times for `/api`, whose dispatcher logs before rethrowing). Only\n // without a reporter does this log itself.\n //\n // Reported for `/api` too: an app's error tracking should see an API failure\n // that got this far, not only a page one. `onRequestFail` is a different\n // hook (route config, called by the dispatchers), so this is not a second\n // report through the same channel.\n if (!onException) {\n console.error(err);\n } else {\n try {\n // The hook is typed to receive an `Error`; a thrown string or object is\n // wrapped so a reporter reading `.stack` or `.name` gets one.\n onException(err instanceof Error ? err : new Error(String(err), { cause: err }));\n } catch (reportError) {\n // A broken reporter must not turn a 500 into a leaked stack either.\n console.error(err);\n console.error(reportError);\n }\n }\n\n if (isApiPath(pathname)) {\n return new Response(\n JSON.stringify({ error: stringEraRefusal(\"server_error\", \"Internal Server Error\", 500) }),\n {\n status: 500,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n\n return new Response(GENERIC_500_HTML, {\n status: 500,\n headers: { \"Content-Type\": \"text/html; charset=utf-8\" },\n });\n}\n"
|
|
15
15
|
],
|
|
16
16
|
"mappings": ";qmCAAA,eAAS,UAET,SAAS,OAAM,IAAS,QCgBxB,WAAS,UACT,cAAS,oBAAW,WAAsB,QAW1C,FAAM,HAAuC,LAAC,DAAM,AAAM,JAQpD,HAAyB,DAYzB,HAAiB,JACjB,HAAqB,HAGrB,HAAa,JAEnB,SAAS,EAAW,CAAC,EAAiC,CACpD,GAAI,IAAQ,OACV,MAAO,GAKT,GAAI,CAAC,oBAAoB,KAAK,EAAI,KAAK,CAAC,EACtC,MAAO,GAET,IAAM,EAAQ,OAAO,EAAI,KAAK,CAAC,EAC/B,OAAO,OAAO,SAAS,CAAK,EAAI,KAAK,IAAI,EAAO,CAAC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IAAI,gBAAgB,EAI7D,GAAgB,GAAyB,QAAQ,GAAG,EAGpD,EAAU,EAAI,QAAQ,EAC5B,GAAI,GAAW,EAAe,OAAS,QAAU,CAAC,GAChD,QAAQ,KACN,uSACF,EAGF,IAAM,EAAS,IAAI,MAAW,CAC5B,mBAAoB,YACpB,MAAO,MAAO,EAAK,IAAW,CAU5B,GAPA,GAAoB,EAAI,QAAS,EAAO,UAAU,CAAG,GAAG,SAAW,KAAM,CAAc,EAIvF,EAAI,qBAAqB,CAAG,EAGxB,GAAS,QAAQ,CAAG,EACtB,OAAO,EAAQ,QAAQ,EAAK,CAAM,EAIpC,IAAM,EAAM,MAAM,EAAgB,EAAK,CAAC,IACtC,EAAI,qBAAqB,EAAK,GAAgB,CAAC,IAC7C,EAAuB,EAAK,IAAI,IAAI,EAAI,GAAG,EAAE,SAAU,EAAI,WAAW,CACxE,CACF,EAKA,OAAO,GAAqB,GAAiB,EAAK,CAAG,EAAI,GAE3D,YAAa,GAAkB,EAC/B,KAAM,QAAQ,IAAI,MAAQ,KAC1B,UAAW,GAAS,SACtB,CAAC,EAKD,OAJA,MAAM,GAAS,MAAM,CAAM,EAE3B,GAAmB,CAAE,KAAM,EAAO,KAAM,SAAQ,CAAC,EAE1C",
|
|
17
|
-
"debugId": "
|
|
17
|
+
"debugId": "E90A7CC68CA086FB64756E2164756E21",
|
|
18
18
|
"names": []
|
|
19
19
|
}
|
|
@@ -46,6 +46,6 @@ export { h } from ${JSON.stringify("virtual:gemi-island-runtime")};
|
|
|
46
46
|
import { hydrateRoot } from "react-dom/client";
|
|
47
47
|
export ${z}
|
|
48
48
|
`,Q='const d=document,c=JSON.parse(d.getElementById("gemi-islands").textContent),w=f=>(window.requestIdleCallback||setTimeout)(f),m=(e,o)=>{if(!e.g){e.g=1;import(o.s).then(x=>x.h(e,x.m[o.e])).catch(r=>console.error(r))}};for(const e of d.querySelectorAll("gemi-island")){const o=c.i[e.dataset.island];if(!o)continue;if(o.l=="eager")m(e,o);else if(o.l=="idle"||!window.IntersectionObserver||!e.children.length)w(()=>m(e,o));else{const v=new IntersectionObserver(n=>{if(n.some(x=>x.isIntersecting)){v.disconnect();m(e,o)}});for(const k of e.children)v.observe(k)}}';
|
|
49
|
-
export{B as
|
|
49
|
+
export{B as mm,F as nm,G as om,J as pm,M as qm,Q as rm};
|
|
50
50
|
|
|
51
|
-
//# debugId=
|
|
51
|
+
//# debugId=5CACF65CC6240C8A64756E2164756E21
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"/**\n * The browser side of islands, shared by the Vite plugin (which builds it), the\n * servers (which point the loader at it) and the tests.\n *\n * No imports: the Vite plugin is built on its own and the servers load it at\n * boot, so this file stays plain strings.\n */\n\n/**\n * The module that hydrates islands: React, `react-dom/client` and the small\n * `h(marker, Component)` below. A virtual module of gemi's Vite plugin that\n * every island entry imports, so the islands on a page share one copy of\n * React, in one chunk.\n */\nexport const ISLAND_RUNTIME_ID = \"virtual:gemi-island-runtime\";\n\n/** What `resolveId` turns `ISLAND_RUNTIME_ID` into (Vite's virtual-module convention). */\nexport const RESOLVED_ISLAND_RUNTIME_ID = `\\0${ISLAND_RUNTIME_ID}`;\n\n/**\n * The query that turns a module into its island entry: `Counter.tsx?gemi-island`\n * is a module of the plugin's that re-exports `Counter.tsx` as `m` next to the\n * runtime's `h`. It is what a static page imports for an island, and so it\n * is what the client manifest lists, keyed `app/…/Counter.tsx?gemi-island`,\n * with React and `react-dom/client` among its imports.\n */\nexport const ISLAND_ENTRY_QUERY = \"?gemi-island\";\n\n/** The island entry module for `file` (an absolute path or a root-relative URL). */\nexport function islandEntrySource(file: string) {\n return `import * as m from ${JSON.stringify(file)};\nexport { m };\nexport { h } from ${JSON.stringify(ISLAND_RUNTIME_ID)};\n`;\n}\n\n/**\n * `h(marker, Component)`: hydrates one `<gemi-island>` marker with the island's\n * component and the props the server serialised into `data-props`.\n *\n * The island's static children were rendered on the server into a\n * `<gemi-slot>` (the first one that belongs to this marker, not to an island\n * nested in it). They are handed back to the component as that same element\n * with the server's HTML, so hydration matches and React leaves them alone.\n *\n * `data-uid` is the `identifierPrefix` the server rendered the island with, so\n * `useId` agrees on both sides and two islands never share an id.\n *\n * When the page carries `#gemi-island-i18n` (its islands read the page's\n * locale or dictionaries, #1095), the dictionaries in it are seeded into the\n * dictionary registry through `__GEMI_DICT__` and the island's root gets the\n * locale and zone in `IslandI18nContext` (found on `globalThis`, where\n * `gemi/client` puts it), so `useDictionary` resolves synchronously, with the\n * strings the server rendered, and fetches nothing. An island that does not\n * import `gemi/client` has no such context to read, and is left as it was.\n *\n * The island's root reads queries through the cache the page's islands\n * share (found on `globalThis` under `gemi.islandQueries`, where `gemi/client`\n * puts it, #1155). When the page carries `#gemi-island-queries` (its islands\n * read queries the request prefetched), that `{ path: { variantKey: data } }`\n * payload seeds the cache first, so `useQuery` hydrates with the server's\n * data and does not refetch it.\n *\n * Written as a function body with `createElement` and `hydrateRoot` free, so a\n * test can run it against real React without a bundler.\n */\nexport const ISLAND_HYDRATE_SOURCE = `function h(marker, Component) {\n if (typeof Component !== \"function\" && (typeof Component !== \"object\" || Component === null)) {\n throw new Error(\"gemi: island module has no component export for \" + marker.outerHTML.slice(0, 80));\n }\n const json = marker.getAttribute(\"data-props\");\n const props = json ? JSON.parse(json) : {};\n let slot = null;\n for (const candidate of marker.querySelectorAll(\"gemi-slot\")) {\n if (candidate.closest(\"gemi-island\") === marker) {\n slot = candidate;\n break;\n }\n }\n const children = slot\n ? [createElement(\"gemi-slot\", {\n style: { display: \"contents\" },\n suppressHydrationWarning: true,\n dangerouslySetInnerHTML: { __html: slot.innerHTML },\n })]\n : [];\n let element = createElement(Component, props, ...children);\n const i18n = document.getElementById(\"gemi-island-i18n\");\n const context = globalThis[Symbol.for(\"gemi.islandI18n\")];\n if (i18n && context) {\n const payload = (i18n.p = i18n.p || JSON.parse(i18n.textContent));\n const dictionaries = (self.__GEMI_DICT__ = self.__GEMI_DICT__ || []);\n for (const entry of payload.dictionaries || []) dictionaries.push(entry);\n element = createElement(context.Provider, {\n value: { currentLocale: payload.currentLocale, defaultLocale: payload.defaultLocale, timeZone: payload.timeZone },\n }, element);\n }\n const cache = globalThis[Symbol.for(\"gemi.islandQueries\")];\n if (cache) {\n const queries = document.getElementById(\"gemi-island-queries\");\n if (queries) cache.seed((queries.p = queries.p || JSON.parse(queries.textContent)));\n element = createElement(cache.Provider, null, element);\n }\n return hydrateRoot(marker, element, {\n identifierPrefix: marker.getAttribute(\"data-uid\") || undefined,\n });\n}`;\n\n/** The runtime module's source, as the plugin serves and builds it. */\nexport const ISLAND_RUNTIME_SOURCE = `import { createElement } from \"react\";\nimport { hydrateRoot } from \"react-dom/client\";\nexport ${ISLAND_HYDRATE_SOURCE}\n`;\n\n/**\n * The island loader, inlined into a static document that uses islands.\n *\n * Kept byte-for-byte constant (the per-page island table travels in a\n * separate `<script type=\"application/json\">`, which a Content Security Policy\n * does not treat as script), so a strict policy can allow it by hash:\n * `script-src 'sha256-…'` with `ISLAND_LOADER_CSP_HASH`. Everything it loads\n * is a plain `import()` of a same-origin (or asset-base) file.\n *\n * The table is `{ i: [{ s: entry URL, e: export, l: load }] }` and each\n * marker's `data-island` indexes `i`. Per marker, on its schedule: import the\n * island's entry (the module as `m`, the runtime's `h`), then\n * `h(marker, m[export])`, which calls `hydrateRoot`. A failure is logged and\n * leaves the server-rendered markup in place.\n */\nexport const ISLAND_LOADER_SOURCE =\n 'const d=document,c=JSON.parse(d.getElementById(\"gemi-islands\").textContent),' +\n \"w=f=>(window.requestIdleCallback||setTimeout)(f),\" +\n \"m=(e,o)=>{if(!e.g){e.g=1;import(o.s).then(x=>x.h(e,x.m[o.e])).catch(r=>console.error(r))}};\" +\n 'for(const e of d.querySelectorAll(\"gemi-island\")){const o=c.i[e.dataset.island];if(!o)continue;' +\n 'if(o.l==\"eager\")m(e,o);else if(o.l==\"idle\"||!window.IntersectionObserver||!e.children.length)w(()=>m(e,o));' +\n \"else{const v=new IntersectionObserver(n=>{if(n.some(x=>x.isIntersecting)){v.disconnect();m(e,o)}});for(const k of e.children)v.observe(k)}}\";\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";AAcO,IAAM,EAAoB,8BAGpB,EAA6B,kCAS7B,EAAqB,eAG3B,SAAS,CAAiB,CAAC,EAAc,CAC9C,MAAO,sBAAsB,KAAK,UAAU,CAAI;AAAA;AAAA,oBAE9B,KAAK,UAlBQ,6BAkBmB;AAAA,EAkC7C,IAAM,EAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GA2CxB,EAAwB;AAAA;AAAA,SAE5B;AAAA,EAkBI,EACX",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "5CACF65CC6240C8A64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{X as C}from"./chunk-
|
|
2
|
+
import{X as C}from"./chunk-at6zjajz.js";import{Y as A}from"./chunk-vawqmdh4.js";import{Km as _}from"./chunk-yedb5vvg.js";var S=_(C(),1),p=_(A(),1),N="AWS_ACCESS_KEY_ID",a="AWS_SECRET_ACCESS_KEY",i="AWS_SESSION_TOKEN",I="AWS_CREDENTIAL_EXPIRATION",d="AWS_CREDENTIAL_SCOPE",v="AWS_ACCOUNT_ID",T=(e)=>async()=>{e?.logger?.debug("@aws-sdk/credential-provider-env - fromEnv");let o=process.env[N],r=process.env[a],n=process.env[i],s=process.env[I],t=process.env[d],E=process.env[v];if(o&&r){let c={accessKeyId:o,secretAccessKey:r,...n&&{sessionToken:n},...s&&{expiration:new Date(s)},...t&&{credentialScope:t},...E&&{accountId:E}};return S.setCredentialFeature(c,"CREDENTIALS_ENV_VARS","g"),c}throw new p.CredentialsProviderError("Unable to find environment variable credentials.",{logger:e?.logger})};export{N as a,a as b,i as c,I as d,d as e,v as f,T as g};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=643D136D0A44815064756E2164756E21
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"import { setCredentialFeature } from \"@aws-sdk/core/client\";\nimport { CredentialsProviderError } from \"@smithy/property-provider\";\nexport const ENV_KEY = \"AWS_ACCESS_KEY_ID\";\nexport const ENV_SECRET = \"AWS_SECRET_ACCESS_KEY\";\nexport const ENV_SESSION = \"AWS_SESSION_TOKEN\";\nexport const ENV_EXPIRATION = \"AWS_CREDENTIAL_EXPIRATION\";\nexport const ENV_CREDENTIAL_SCOPE = \"AWS_CREDENTIAL_SCOPE\";\nexport const ENV_ACCOUNT_ID = \"AWS_ACCOUNT_ID\";\nexport const fromEnv = (init) => async () => {\n init?.logger?.debug(\"@aws-sdk/credential-provider-env - fromEnv\");\n const accessKeyId = process.env[ENV_KEY];\n const secretAccessKey = process.env[ENV_SECRET];\n const sessionToken = process.env[ENV_SESSION];\n const expiry = process.env[ENV_EXPIRATION];\n const credentialScope = process.env[ENV_CREDENTIAL_SCOPE];\n const accountId = process.env[ENV_ACCOUNT_ID];\n if (accessKeyId && secretAccessKey) {\n const credentials = {\n accessKeyId,\n secretAccessKey,\n ...(sessionToken && { sessionToken }),\n ...(expiry && { expiration: new Date(expiry) }),\n ...(credentialScope && { credentialScope }),\n ...(accountId && { accountId }),\n };\n setCredentialFeature(credentials, \"CREDENTIALS_ENV_VARS\", \"g\");\n return credentials;\n }\n throw new CredentialsProviderError(\"Unable to find environment variable credentials.\", { logger: init?.logger });\n};\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";qIAAA,SACA,KACa,EAAU,oBACV,EAAa,wBACb,EAAc,oBACd,EAAiB,4BACjB,EAAuB,uBACvB,EAAiB,iBACjB,EAAU,CAAC,IAAS,SAAY,CACzC,GAAM,QAAQ,MAAM,4CAA4C,EAChE,IAAM,EAAc,QAAQ,IAAI,GAC1B,EAAkB,QAAQ,IAAI,GAC9B,EAAe,QAAQ,IAAI,GAC3B,EAAS,QAAQ,IAAI,GACrB,EAAkB,QAAQ,IAAI,GAC9B,EAAY,QAAQ,IAAI,GAC9B,GAAI,GAAe,EAAiB,CAChC,IAAM,EAAc,CAChB,cACA,qBACI,GAAgB,CAAE,cAAa,KAC/B,GAAU,CAAE,WAAY,IAAI,KAAK,CAAM,CAAE,KACzC,GAAmB,CAAE,iBAAgB,KACrC,GAAa,CAAE,WAAU,CACjC,EAEA,OADA,uBAAqB,EAAa,uBAAwB,GAAG,EACtD,EAEX,MAAM,IAAI,2BAAyB,mDAAoD,CAAE,OAAQ,GAAM,MAAO,CAAC",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "643D136D0A44815064756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Oe as o}from"./chunk-7t13vyzg.js";import{Pe as i}from"./chunk-sqqh78tf.js";import{al as t}from"./chunk-yxtfg4wy.js";import{fm as r}from"./chunk-qstjm3cb.js";class n extends i{register(){this.app.singleton(r,()=>new r(t(o(),this.app.config.get("translation",{}))))}}
|
|
3
|
+
export{n as pb};
|
|
4
|
+
|
|
5
|
+
//# debugId=1BE1A2F1C892D74064756E2164756E21
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"import { ServiceProvider } from \"../support/ServiceProvider\";\nimport { withDefaults } from \"../support/withDefaults\";\nimport { Translator } from \"./Translator\";\nimport { translationConfigDefaults, type TranslationConfig } from \"./config\";\n\nexport class TranslationServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n Translator,\n () =>\n new Translator(\n withDefaults(\n translationConfigDefaults(),\n this.app.config.get<TranslationConfig>(\"translation\", {}),\n ),\n ),\n );\n }\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";sLAKO,AAAM,IAAmC,LAAgB,CAC9D,QAAQ,EAAG,CACT,KAAK,IAAI,UACP,EACA,IACE,IAAI,EACF,EACE,EAA0B,EAC1B,KAAK,IAAI,OAAO,IAAuB,cAAe,CAAC,CAAC,CAC1D,CACF,CACJ,EAEJ",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "1BE1A2F1C892D74064756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Lm as t,Om as A}from"./chunk-yedb5vvg.js";var o=t((b)=>{var i=(r)=>typeof ArrayBuffer==="function"&&r instanceof ArrayBuffer||Object.prototype.toString.call(r)==="[object ArrayBuffer]";b.isArrayBuffer=i});var y=t((g)=>{var m=o(),f=A("buffer"),B=(r,e=0,u=r.byteLength-e)=>{if(!m.isArrayBuffer(r))throw TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof r} (${r})`);return f.Buffer.from(r,e,u)},a=(r,e)=>{if(typeof r!=="string")throw TypeError(`The "input" argument must be of type string. Received type ${typeof r} (${r})`);return e?f.Buffer.from(r,e):f.Buffer.from(r)};g.fromArrayBuffer=B;g.fromString=a});var x=t((w)=>{var n=y(),s=(r)=>{let e=n.fromString(r,"utf8");return new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT)},h=(r)=>{if(typeof r==="string")return s(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength/Uint8Array.BYTES_PER_ELEMENT);return new Uint8Array(r)},p=(r)=>{if(typeof r==="string")return r;if(typeof r!=="object"||typeof r.byteOffset!=="number"||typeof r.byteLength!=="number")throw Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");return n.fromArrayBuffer(r.buffer,r.byteOffset,r.byteLength).toString("utf8")};w.fromUtf8=s;w.toUint8Array=h;w.toUtf8=p});
|
|
3
3
|
export{o as R,y as S,x as T};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=05E8F250BDB59DE064756E2164756E21
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
"'use strict';\n\nvar utilBufferFrom = require('@smithy/util-buffer-from');\n\nconst fromUtf8 = (input) => {\n const buf = utilBufferFrom.fromString(input, \"utf8\");\n return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT);\n};\n\nconst toUint8Array = (data) => {\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);\n }\n return new Uint8Array(data);\n};\n\nconst toUtf8 = (input) => {\n if (typeof input === \"string\") {\n return input;\n }\n if (typeof input !== \"object\" || typeof input.byteOffset !== \"number\" || typeof input.byteLength !== \"number\") {\n throw new Error(\"@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.\");\n }\n return utilBufferFrom.fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString(\"utf8\");\n};\n\nexports.fromUtf8 = fromUtf8;\nexports.toUint8Array = toUint8Array;\nexports.toUtf8 = toUtf8;\n"
|
|
8
8
|
],
|
|
9
9
|
"mappings": ";+DAEA,IAAM,EAAgB,CAAC,IAAS,OAAO,cAAgB,YAAc,aAAe,aAChF,OAAO,UAAU,SAAS,KAAK,CAAG,IAAM,uBAEpC,gBAAgB,kBCHxB,IAAI,MACA,cAEE,EAAkB,CAAC,EAAO,EAAS,EAAG,EAAS,EAAM,WAAa,IAAW,CAC/E,GAAI,CAAC,EAAc,cAAc,CAAK,EAClC,MAAU,UAAU,2DAA2D,OAAO,MAAU,IAAQ,EAE5G,OAAO,EAAO,OAAO,KAAK,EAAO,EAAQ,CAAM,GAE7C,EAAa,CAAC,EAAO,IAAa,CACpC,GAAI,OAAO,IAAU,SACjB,MAAU,UAAU,8DAA8D,OAAO,MAAU,IAAQ,EAE/G,OAAO,EAAW,EAAO,OAAO,KAAK,EAAO,CAAQ,EAAI,EAAO,OAAO,KAAK,CAAK,GAG5E,kBAAkB,EAClB,aAAa,kBCjBrB,IAAI,MAEE,EAAW,CAAC,IAAU,CACxB,IAAM,EAAM,EAAe,WAAW,EAAO,MAAM,EACnD,OAAO,IAAI,WAAW,EAAI,OAAQ,EAAI,WAAY,EAAI,WAAa,WAAW,iBAAiB,GAG7F,EAAe,CAAC,IAAS,CAC3B,GAAI,OAAO,IAAS,SAChB,OAAO,EAAS,CAAI,EAExB,GAAI,YAAY,OAAO,CAAI,EACvB,OAAO,IAAI,WAAW,EAAK,OAAQ,EAAK,WAAY,EAAK,WAAa,WAAW,iBAAiB,EAEtG,OAAO,IAAI,WAAW,CAAI,GAGxB,EAAS,CAAC,IAAU,CACtB,GAAI,OAAO,IAAU,SACjB,OAAO,EAEX,GAAI,OAAO,IAAU,UAAY,OAAO,EAAM,aAAe,UAAY,OAAO,EAAM,aAAe,SACjG,MAAU,MAAM,8EAA8E,EAElG,OAAO,EAAe,gBAAgB,EAAM,OAAQ,EAAM,WAAY,EAAM,UAAU,EAAE,SAAS,MAAM,GAGnG,WAAW,EACX,eAAe,EACf,SAAS",
|
|
10
|
-
"debugId": "
|
|
10
|
+
"debugId": "05E8F250BDB59DE064756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-yedb5vvg.js";function R(f,D){let P=new Map;for(let p of[...D.tables].sort())P.set(p,{name:p,columns:[],primaryKey:[],relations:[]});for(let{table:p,...s}of D.columns)P.get(p)?.columns.push(s);for(let{table:p,column:s}of D.primaryKeys)P.get(p)?.primaryKey.push(s);let d=new Map;for(let p of D.foreignKeys){let s=P.get(p.table);if(!s)continue;let M=`${p.table}\x00${p.key}`,q=d.get(M);if(!q)q={name:p.name,columns:[],referencedTable:p.referencedTable,referencedColumns:[],onDelete:p.onDelete,onUpdate:p.onUpdate},d.set(M,q),s.relations.push(q);q.columns.push(p.column),q.referencedColumns.push(p.referencedColumn)}return{dialect:f,tables:[...P.values()]}}async function h(f,D){let P=await f.unsafe(`
|
|
3
3
|
select TABLE_NAME as name
|
|
4
4
|
from information_schema.TABLES
|
|
5
5
|
where TABLE_SCHEMA = database() and TABLE_TYPE = 'BASE TABLE'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
function H(z){if(z===401)return"authentication";if(z===403)return"permission";if(z===404)return"not_found";if(z===416)return"range_not_satisfiable";if(z===429)return"rate_limit";if(z>=500)return"server_error";return"form_error"}var N="GEMI_REQUEST_BREAKER_ERROR";class J extends Error{static legacyStringPayload=!1;kind=N;payload;constructor(z,C={}){super(z);let D=C.status??400;this.payload={api:{status:D,data:{error:L(C.kind??H(D),z??"",D)},...C.headers?{headers:C.headers}:{}},view:{status:D}}}}function L(z,C,D){return{kind:z,message:C,status:D}}function X(z,C,D){return J.legacyStringPayload?C:L(z,C,D)}
|
|
3
|
-
export{H as
|
|
3
|
+
export{H as Lj,N as Mj,J as Nj,L as Oj,X as Pj};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=E631F3D9E6906C3664756E2164756E21
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
"import { refusalKindForStatus, type Refusal, type RefusalKind } from \"./refusal\";\n\nexport const GEMI_REQUEST_BREAKER_ERROR = \"GEMI_REQUEST_BREAKER_ERROR\";\n\nexport type RequestBreakerOptions = {\n /** The answer's status. 400 when absent. */\n status?: number;\n /**\n * What the client's guards classify it as. Absent, it follows from\n * `status`: 401 `authentication`, 403 `permission`, 404 `not_found`, 429\n * `rate_limit`, 5xx `server_error`, any other status `form_error`.\n */\n kind?: Exclude<RefusalKind, \"validation_error\">;\n /** Extra headers for the API answer. */\n headers?: Record<string, string>;\n};\n\nexport class RequestBreakerError extends Error {\n /**\n * Answer the refusals that were bare strings before 0.88 — authentication,\n * authorization, permission, CSRF and a 500 — with that string again,\n * instead of `{ kind, message, status }`.\n *\n * For a shipped native client that reads `body.error` as a string and cannot\n * be rolled forward in the same deploy as the server. Set it once at boot,\n * and remove the line when the clients read `body.error.message`:\n *\n * ```ts\n * RequestBreakerError.legacyStringPayload = true;\n * ```\n *\n * gemi's own web client reads either shape. Refusals that were already\n * objects (404, 429, a policy 403) stay objects.\n */\n static legacyStringPayload = false;\n\n public kind = GEMI_REQUEST_BREAKER_ERROR;\n public payload: {\n api: Record<string, any>;\n view: Record<string, any>;\n /**\n * What a `.json` view navigation answers, when that differs from `api`.\n * Absent, it gets `api` — right for most breakers, but not for one that\n * must be a 401 to an API client and a redirect to the client router.\n */\n viewData?: Record<string, any>;\n };\n\n /**\n * A refusal that answers `{ error: { kind, message, status } }` with\n * `status`, so the client's guards classify it without a payload of your\n * own. A subclass that sets `payload` itself replaces this.\n *\n * ```ts\n * throw new RequestBreakerError(\"This slug is taken\", { status: 409 });\n * // → 409 { error: { kind: \"form_error\", message: \"This slug is taken\", status: 409 } }\n * ```\n */\n constructor(message?: string, options: RequestBreakerOptions = {}) {\n super(message);\n const status = options.status ?? 400;\n this.payload = {\n api: {\n status,\n data: {\n error: refusal(options.kind ?? refusalKindForStatus(status), message ?? \"\", status),\n },\n ...(options.headers ? { headers: options.headers } : {}),\n },\n view: { status },\n };\n }\n}\n\n/** A refusal's `error` field. */\nexport function refusal<K extends Exclude<RefusalKind, \"validation_error\">>(\n kind: K,\n message: string,\n status: number,\n): Refusal<K> {\n return { kind, message, status };\n}\n\n/**\n * A refusal that was a bare string before 0.88: the object, or the string\n * under `RequestBreakerError.legacyStringPayload`.\n *\n * @internal\n */\nexport function stringEraRefusal<K extends Exclude<RefusalKind, \"validation_error\">>(\n kind: K,\n message: string,\n status: number,\n): Refusal<K> | string {\n return RequestBreakerError.legacyStringPayload ? message : refusal(kind, message, status);\n}\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": ";AA0DO,SAAS,CAAoB,CAAC,EAA0D,CAC7F,GAAI,IAAW,IAAK,MAAO,iBAC3B,GAAI,IAAW,IAAK,MAAO,aAC3B,GAAI,IAAW,IAAK,MAAO,YAC3B,GAAI,IAAW,IAAK,MAAO,wBAC3B,GAAI,IAAW,IAAK,MAAO,aAC3B,GAAI,GAAU,IAAK,MAAO,eAC1B,MAAO,aC/DF,IAAM,EAA6B,6BAenC,MAAM,UAA4B,KAAM,OAiBtC,qBAAsB,GAEtB,KAAO,EACP,QAqBP,WAAW,CAAC,EAAkB,EAAiC,CAAC,EAAG,CACjE,MAAM,CAAO,EACb,IAAM,EAAS,EAAQ,QAAU,IACjC,KAAK,QAAU,CACb,IAAK,CACH,SACA,KAAM,CACJ,MAAO,EAAQ,EAAQ,MAAQ,EAAqB,CAAM,EAAG,GAAW,GAAI,CAAM,CACpF,KACI,EAAQ,QAAU,CAAE,QAAS,EAAQ,OAAQ,EAAI,CAAC,CACxD,EACA,KAAM,CAAE,QAAO,CACjB,EAEJ,CAGO,SAAS,CAA2D,CACzE,EACA,EACA,EACY,CACZ,MAAO,CAAE,OAAM,UAAS,QAAO,EAS1B,SAAS,CAAoE,CAClF,EACA,EACA,EACqB,CACrB,OAAO,EAAoB,oBAAsB,EAAU,EAAQ,EAAM,EAAS,CAAM",
|
|
9
|
-
"debugId": "
|
|
9
|
+
"debugId": "E631F3D9E6906C3664756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|