@aotter/mantle 0.2.0-alpha.1 → 0.2.0-alpha.11
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/README.md +180 -45
- package/dist/auth/adapter.d.ts +32 -0
- package/dist/auth/adapter.js +261 -0
- package/dist/auth/admin.d.ts +3 -0
- package/dist/auth/admin.js +18 -0
- package/dist/auth/caller.d.ts +86 -0
- package/dist/auth/caller.js +128 -0
- package/dist/auth/{createAuthRoutes.js → consent.js} +26 -54
- package/dist/auth/hardening.d.ts +24 -0
- package/dist/auth/hardening.js +33 -0
- package/dist/auth/identity.d.ts +121 -0
- package/dist/auth/identity.js +192 -0
- package/dist/auth/oauth.d.ts +63 -0
- package/dist/auth/oauth.js +185 -0
- package/dist/auth/resource-seeds.js +8 -0
- package/dist/auth/route-http.js +33 -0
- package/dist/auth/routes.d.ts +32 -0
- package/dist/auth/routes.js +80 -0
- package/dist/build/compiler.d.ts +122 -0
- package/dist/build/compiler.js +3 -0
- package/dist/{spec → build/spec}/domain/model/ManifestGrammar.d.ts +30 -43
- package/dist/{spec → build/spec}/domain/model/RuntimePlan.d.ts +77 -3
- package/dist/{spec → build/spec}/domain/model/SqlIr.d.ts +39 -6
- package/dist/build/spec/domain/model/UserFields.d.ts +21 -0
- package/dist/{spec → build/spec}/domain/service/PlanFingerprint.d.ts +4 -1
- package/dist/{spec → build/spec}/kernel/diagnostic.d.ts +1 -30
- package/dist/bun/assets.d.ts +2 -0
- package/dist/bun/assets.js +22 -0
- package/dist/domain/adminOrder.js +22 -0
- package/dist/domain/columns.js +42 -0
- package/dist/domain/describe/chunk-SGMRVDGE.js +1 -0
- package/dist/domain/describe/index.d.ts +58 -0
- package/dist/domain/describe/index.js +1 -0
- package/dist/domain/describe/target-hash.d.ts +8 -0
- package/dist/domain/describe/target-hash.js +1 -0
- package/dist/domain/describe/targets.d.ts +40 -0
- package/dist/domain/entry.js +19 -0
- package/dist/domain/generated-tools.js +18 -0
- package/dist/domain/generation.d.ts +16 -0
- package/dist/domain/generation.js +1 -0
- package/dist/domain/input.js +15 -0
- package/dist/domain/model.js +1 -0
- package/dist/domain/paging.js +213 -0
- package/dist/domain/recipes.js +22 -0
- package/dist/domain/userReferences.js +4 -0
- package/dist/domain/wireScalars.js +41 -0
- package/dist/infrastructure/adminEntries.js +156 -0
- package/dist/infrastructure/adminPaging.js +70 -0
- package/dist/infrastructure/artifacts.js +67 -0
- package/dist/infrastructure/authSchema.js +74 -0
- package/dist/infrastructure/bundle.js +159 -0
- package/dist/infrastructure/cli.js +111 -0
- package/dist/infrastructure/generate.d.ts +12 -0
- package/dist/infrastructure/generate.js +175 -0
- package/dist/infrastructure/generateAuth.d.ts +8 -0
- package/dist/infrastructure/generateAuth.js +66 -0
- package/dist/infrastructure/help.js +55 -0
- package/dist/infrastructure/init.js +50 -0
- package/dist/infrastructure/inputs.js +32 -0
- package/dist/infrastructure/mounts.js +22 -0
- package/dist/infrastructure/wrangler.js +103 -0
- package/dist/kernel/authorization.d.ts +4 -0
- package/dist/kernel/authorization.js +15 -0
- package/dist/kernel/binds.d.ts +60 -0
- package/dist/kernel/binds.js +39 -0
- package/dist/kernel/caller-identity.d.ts +21 -0
- package/dist/kernel/caller-identity.js +7 -0
- package/dist/kernel/caller-mode.d.ts +4 -0
- package/dist/kernel/caller-mode.js +14 -0
- package/dist/kernel/contract-error.d.ts +12 -0
- package/dist/kernel/contract-error.js +14 -0
- package/dist/kernel/contracts.d.ts +135 -0
- package/dist/kernel/contracts.js +56 -0
- package/dist/{spec/domain/service/CloudflareCron.d.ts → kernel/cron.d.ts} +0 -1
- package/dist/{spec/domain/service/CloudflareCron.js → kernel/cron.js} +0 -9
- package/dist/kernel/dialect/common.d.ts +38 -0
- package/dist/kernel/dialect/common.js +3 -0
- package/dist/kernel/dialect/postgres.d.ts +16 -0
- package/dist/kernel/dialect/postgres.js +16 -0
- package/dist/kernel/dialect/sqlite.d.ts +20 -0
- package/dist/kernel/dialect/sqlite.js +29 -0
- package/dist/kernel/drain.d.ts +5 -0
- package/dist/kernel/drain.js +29 -0
- package/dist/kernel/driver/bun-sqlite.d.ts +19 -0
- package/dist/kernel/driver/bun-sqlite.js +73 -0
- package/dist/kernel/driver/d1.d.ts +24 -0
- package/dist/kernel/driver/d1.js +21 -0
- package/dist/kernel/driver/postgres.d.ts +25 -0
- package/dist/kernel/driver/postgres.js +84 -0
- package/dist/kernel/driver/transaction-context.d.ts +10 -0
- package/dist/kernel/driver/transaction-context.js +28 -0
- package/dist/kernel/email.d.ts +28 -0
- package/dist/{auth/emailTemplates.js → kernel/email.js} +9 -2
- package/dist/kernel/host-access.d.ts +10 -0
- package/dist/kernel/host-access.js +64 -0
- package/dist/kernel/host-caller.d.ts +39 -0
- package/dist/kernel/host-caller.js +53 -0
- package/dist/kernel/json-body.d.ts +4 -0
- package/dist/kernel/json-body.js +42 -0
- package/dist/kernel/mcp-apps.d.ts +69 -0
- package/dist/kernel/mcp-apps.js +35 -0
- package/dist/kernel/mcp-call.d.ts +5 -0
- package/dist/kernel/mcp-call.js +24 -0
- package/dist/kernel/mcp-handler.js +347 -0
- package/dist/kernel/mcp.d.ts +110 -0
- package/dist/kernel/mcp.js +45 -0
- package/dist/kernel/media.d.ts +27 -0
- package/dist/kernel/media.js +198 -0
- package/dist/kernel/paging.d.ts +55 -0
- package/dist/kernel/paging.js +87 -0
- package/dist/kernel/publishing.d.ts +4 -0
- package/dist/kernel/publishing.js +15 -0
- package/dist/{cloudflare/r2Media.d.ts → kernel/r2-media.d.ts} +4 -5
- package/dist/kernel/r2-media.js +71 -0
- package/dist/kernel/rest-dispatch.js +37 -0
- package/dist/kernel/rest-router.js +63 -0
- package/dist/kernel/rest.d.ts +58 -0
- package/dist/kernel/rest.js +38 -0
- package/dist/kernel/scalars.d.ts +6 -0
- package/dist/kernel/scalars.js +36 -0
- package/dist/kernel/search.js +4 -0
- package/dist/{core/site.d.ts → kernel/site-types.d.ts} +38 -9
- package/dist/kernel/site-types.js +1 -0
- package/dist/kernel/site.d.ts +39 -0
- package/dist/kernel/site.js +30 -0
- package/dist/kernel/store.d.ts +175 -0
- package/dist/kernel/store.js +244 -0
- package/dist/kernel/surface-failure.d.ts +10 -0
- package/dist/kernel/surface-failure.js +29 -0
- package/dist/kernel/surface.d.ts +10 -0
- package/dist/kernel/surface.js +16 -0
- package/dist/kernel/sweep.d.ts +17 -0
- package/dist/kernel/sweep.js +26 -0
- package/dist/kernel/translations.d.ts +1 -0
- package/dist/kernel/translations.js +12 -0
- package/dist/kernel/user-caller.d.ts +31 -0
- package/dist/kernel/user-caller.js +61 -0
- package/dist/kernel/user-field-name.js +3 -0
- package/dist/kernel/user-fields.d.ts +35 -0
- package/dist/kernel/user-fields.js +71 -0
- package/dist/kernel/validation.d.ts +15 -0
- package/dist/kernel/validation.js +46 -0
- package/dist/kernel/web-gateway.js +66 -0
- package/dist/kernel/web-head.js +14 -0
- package/dist/kernel/web-index.js +39 -0
- package/dist/kernel/web-response.js +7 -0
- package/dist/kernel/web-serve.js +97 -0
- package/dist/kernel/web.d.ts +77 -0
- package/dist/kernel/web.js +43 -0
- package/dist/kernel/where.js +21 -0
- package/dist/testing/index.d.ts +1 -37
- package/dist/testing/index.js +1 -43
- package/dist/usecase/adminBindings.js +150 -0
- package/dist/usecase/adminClient.js +66 -0
- package/dist/usecase/adminDescriptors.js +100 -0
- package/dist/usecase/generate.js +160 -0
- package/dist/usecase/handlers.js +18 -0
- package/dist/usecase/mcp-media.js +16 -0
- package/dist/usecase/mcp.js +96 -0
- package/dist/usecase/paging.js +69 -0
- package/dist/usecase/publishing.js +59 -0
- package/dist/usecase/refusals.js +27 -0
- package/dist/usecase/rest.js +53 -0
- package/dist/usecase/search.js +7 -0
- package/dist/usecase/site.js +38 -0
- package/dist/usecase/stores.js +52 -0
- package/dist/usecase/tool-version.js +6 -0
- package/dist/usecase/translations.js +76 -0
- package/dist/usecase/ttl.js +20 -0
- package/dist/usecase/validation.js +221 -0
- package/dist/usecase/web.js +23 -0
- package/docs/examples/README.md +39 -16
- package/docs/examples/app-shell/README.md +121 -0
- package/docs/examples/app-shell/accept.mjs +91 -0
- package/docs/examples/app-shell/gitignore +7 -0
- package/docs/examples/app-shell/package.json +43 -0
- package/docs/examples/app-shell/pnpm-workspace.yaml +8 -0
- package/docs/examples/app-shell/smoke-kit.mjs +168 -0
- package/docs/examples/app-shell/src/auth.ts +58 -0
- package/docs/examples/app-shell/src/handlers.ts +5 -0
- package/docs/examples/app-shell/src/index.ts +4 -0
- package/docs/examples/app-shell/src/routes.ts +16 -0
- package/docs/examples/app-shell/src/schedule.ts +8 -0
- package/docs/examples/app-shell/src/service.ts +71 -0
- package/docs/examples/app-shell/src/sign-in.ts +41 -0
- package/docs/examples/app-shell/src/signup.ts +8 -0
- package/docs/examples/{reference-service → app-shell}/tsconfig.json +6 -2
- package/docs/examples/app-shell/worker-configuration.d.ts +22 -0
- package/docs/examples/app-shell/wrangler.jsonc +62 -0
- package/docs/examples/club-events/README.md +65 -0
- package/docs/examples/club-events/manifests/club-events.yaml +247 -0
- package/docs/examples/club-events/smoke.mjs +127 -0
- package/docs/examples/club-events/src/handlers.ts +25 -0
- package/docs/examples/club-events/src/signup.ts +9 -0
- package/docs/examples/generated-web/README.md +78 -0
- package/docs/examples/generated-web/posts.yaml +38 -0
- package/docs/examples/generated-web/seed.sql +6 -0
- package/docs/examples/generated-web/src/worker.ts +43 -0
- package/docs/examples/generated-web/tsconfig.json +8 -0
- package/docs/examples/generated-web/wrangler.jsonc +8 -0
- package/docs/examples/purchasing/.dev.vars.example +6 -0
- package/docs/examples/purchasing/README.md +99 -0
- package/docs/examples/purchasing/manifests/purchasing.yaml +374 -0
- package/docs/examples/purchasing/seed.sql +4 -0
- package/docs/examples/purchasing/smoke.mjs +191 -0
- package/docs/examples/purchasing/src/admin.tsx +13 -0
- package/docs/examples/purchasing/src/handlers.ts +33 -0
- package/docs/examples/purchasing/src/notify.ts +29 -0
- package/docs/examples/purchasing/src/requests-page.ts +57 -0
- package/docs/examples/purchasing/src/routes.ts +53 -0
- package/docs/examples/purchasing/src/schedule.ts +31 -0
- package/docs/examples/purchasing/src/signup.ts +5 -0
- package/docs/examples/purchasing/src/supplier.ts +32 -0
- package/docs/examples/purchasing/wrangler.jsonc +69 -0
- package/docs/examples/recipes/README.md +60 -0
- package/docs/examples/recipes/manifests/recipes.yaml +75 -0
- package/docs/examples/recipes/smoke.mjs +102 -0
- package/docs/examples/recipes/src/media.ts +13 -0
- package/docs/examples/recipes/src/pages.ts +99 -0
- package/docs/examples/recipes/src/routes.ts +71 -0
- package/docs/examples/recipes/src/site-config.ts +12 -0
- package/docs/examples/recipes/wrangler.jsonc +74 -0
- package/docs/handbook/cloudflare/authentication.md +186 -108
- package/docs/handbook/cloudflare/chatgpt-sites.md +5 -112
- package/docs/handbook/cloudflare/deploy-and-operate.md +59 -87
- package/docs/handbook/cloudflare/media-r2.md +61 -82
- package/docs/handbook/cloudflare/service-entry.md +223 -119
- package/docs/handbook/concepts/authorization.md +10 -117
- package/docs/handbook/concepts/four-atoms.md +9 -92
- package/docs/handbook/concepts/lifecycle-and-locales.md +9 -80
- package/docs/handbook/concepts/mcp-and-agents.md +24 -116
- package/docs/handbook/concepts/procedures-and-triggers.md +5 -162
- package/docs/handbook/concepts/runtime-and-adapters.md +15 -183
- package/docs/handbook/concepts/views.md +10 -109
- package/docs/handbook/examples/hub.md +2 -18
- package/docs/handbook/guides/adapter-guide.md +11 -0
- package/docs/handbook/guides/admin-ui.md +113 -136
- package/docs/handbook/guides/agent-setup.md +32 -27
- package/docs/handbook/guides/agent-workflow-acceptance.md +232 -0
- package/docs/handbook/guides/email.md +86 -0
- package/docs/handbook/guides/local-testing.md +40 -0
- package/docs/handbook/guides/mcp-apps.md +560 -0
- package/docs/handbook/guides/native-admin.md +566 -0
- package/docs/handbook/guides/native-execution.md +133 -0
- package/docs/handbook/guides/oauth.md +219 -0
- package/docs/handbook/guides/postgres-adapters.md +56 -0
- package/docs/handbook/guides/public-pages.md +93 -0
- package/docs/handbook/guides/size-and-startup.md +9 -0
- package/docs/handbook/guides/sql-patterns.md +266 -0
- package/docs/handbook/guides/typed-queries.md +210 -100
- package/docs/handbook/navigation.json +176 -30
- package/docs/handbook/reference/admin-descriptors.md +56 -0
- package/docs/handbook/reference/authorization.md +44 -52
- package/docs/handbook/reference/describe.md +56 -0
- package/docs/handbook/reference/diagnostics.md +19 -77
- package/docs/handbook/reference/features.md +45 -53
- package/docs/handbook/reference/manifest.md +6 -69
- package/docs/handbook/reference/procedure.md +11 -115
- package/docs/handbook/reference/schema.md +81 -172
- package/docs/handbook/reference/site-config.md +5 -65
- package/docs/handbook/reference/sql.md +64 -0
- package/docs/handbook/reference/surface.md +396 -93
- package/docs/handbook/reference/trigger.md +62 -89
- package/docs/handbook/reference/view.md +40 -158
- package/docs/handbook/releases/index.md +198 -12
- package/docs/handbook/start/agents.md +45 -0
- package/docs/handbook/start/overview.md +9 -56
- package/docs/handbook/start/project-and-cli.md +51 -131
- package/docs/handbook/start/quickstart-worker.md +38 -115
- package/docs/skills/develop/SKILL.md +77 -121
- package/docs/skills/integrate/SKILL.md +37 -84
- package/docs/skills/media-gc/SKILL.md +21 -8
- package/docs/skills/provision/SKILL.md +31 -87
- package/docs/skills/update/SKILL.md +20 -34
- package/docs/source/scripts/postgres-adapter.ts +101 -0
- package/docs/upgrade-0.1-to-0.2.md +26 -10
- package/package.json +120 -112
- package/skills/README.md +67 -0
- package/skills/mantle/SKILL.md +76 -0
- package/dist/admin/consent.d.ts +0 -17
- package/dist/admin/consent.d.ts.map +0 -1
- package/dist/admin/consent.js +0 -17
- package/dist/admin/consent.js.map +0 -1
- package/dist/admin/createAdminSurface.d.ts +0 -22
- package/dist/admin/createAdminSurface.d.ts.map +0 -1
- package/dist/admin/createAdminSurface.js +0 -589
- package/dist/admin/createAdminSurface.js.map +0 -1
- package/dist/admin/developerConsole.d.ts +0 -264
- package/dist/admin/developerConsole.d.ts.map +0 -1
- package/dist/admin/developerConsole.js +0 -136
- package/dist/admin/developerConsole.js.map +0 -1
- package/dist/admin/identity.d.ts +0 -62
- package/dist/admin/identity.d.ts.map +0 -1
- package/dist/admin/identity.js +0 -7
- package/dist/admin/identity.js.map +0 -1
- package/dist/admin/index.d.ts +0 -4
- package/dist/admin/index.d.ts.map +0 -1
- package/dist/admin/index.js +0 -4
- package/dist/admin/index.js.map +0 -1
- package/dist/admin/procedureFlow.d.ts +0 -25
- package/dist/admin/procedureFlow.d.ts.map +0 -1
- package/dist/admin/procedureFlow.js +0 -154
- package/dist/admin/procedureFlow.js.map +0 -1
- package/dist/auth/ConsoleEmailSender.d.ts +0 -15
- package/dist/auth/ConsoleEmailSender.d.ts.map +0 -1
- package/dist/auth/ConsoleEmailSender.js +0 -19
- package/dist/auth/ConsoleEmailSender.js.map +0 -1
- package/dist/auth/appleClientSecret.d.ts +0 -75
- package/dist/auth/appleClientSecret.d.ts.map +0 -1
- package/dist/auth/appleClientSecret.js +0 -116
- package/dist/auth/appleClientSecret.js.map +0 -1
- package/dist/auth/buildAuth.d.ts +0 -4565
- package/dist/auth/buildAuth.d.ts.map +0 -1
- package/dist/auth/buildAuth.js +0 -307
- package/dist/auth/buildAuth.js.map +0 -1
- package/dist/auth/callerResolver.d.ts +0 -48
- package/dist/auth/callerResolver.d.ts.map +0 -1
- package/dist/auth/callerResolver.js +0 -49
- package/dist/auth/callerResolver.js.map +0 -1
- package/dist/auth/createAuthRoutes.d.ts +0 -22
- package/dist/auth/createAuthRoutes.d.ts.map +0 -1
- package/dist/auth/createAuthRoutes.js.map +0 -1
- package/dist/auth/createMantleAuth.d.ts +0 -3
- package/dist/auth/createMantleAuth.d.ts.map +0 -1
- package/dist/auth/createMantleAuth.js +0 -483
- package/dist/auth/createMantleAuth.js.map +0 -1
- package/dist/auth/db.d.ts +0 -17
- package/dist/auth/db.d.ts.map +0 -1
- package/dist/auth/db.js +0 -24
- package/dist/auth/db.js.map +0 -1
- package/dist/auth/emailTemplates.d.ts +0 -7
- package/dist/auth/emailTemplates.d.ts.map +0 -1
- package/dist/auth/emailTemplates.js.map +0 -1
- package/dist/auth/index.d.ts +0 -9
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js +0 -7
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/methods.d.ts +0 -717
- package/dist/auth/methods.d.ts.map +0 -1
- package/dist/auth/methods.js +0 -321
- package/dist/auth/methods.js.map +0 -1
- package/dist/auth/oauthTokens.d.ts +0 -24
- package/dist/auth/oauthTokens.d.ts.map +0 -1
- package/dist/auth/oauthTokens.js +0 -146
- package/dist/auth/oauthTokens.js.map +0 -1
- package/dist/auth/setupIncomplete.d.ts +0 -16
- package/dist/auth/setupIncomplete.d.ts.map +0 -1
- package/dist/auth/setupIncomplete.js +0 -50
- package/dist/auth/setupIncomplete.js.map +0 -1
- package/dist/auth/types.d.ts +0 -440
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js +0 -10
- package/dist/auth/types.js.map +0 -1
- package/dist/bun/index.d.ts +0 -65
- package/dist/bun/index.d.ts.map +0 -1
- package/dist/bun/index.js +0 -130
- package/dist/bun/index.js.map +0 -1
- package/dist/cli/emitModule.d.ts +0 -7
- package/dist/cli/emitModule.d.ts.map +0 -1
- package/dist/cli/emitModule.js +0 -127
- package/dist/cli/emitModule.js.map +0 -1
- package/dist/cli/generate.d.ts +0 -8
- package/dist/cli/generate.d.ts.map +0 -1
- package/dist/cli/generate.js +0 -355
- package/dist/cli/generate.js.map +0 -1
- package/dist/cli/main.d.ts +0 -3
- package/dist/cli/main.d.ts.map +0 -1
- package/dist/cli/main.js +0 -21
- package/dist/cli/main.js.map +0 -1
- package/dist/cli/preset.d.ts +0 -18
- package/dist/cli/preset.d.ts.map +0 -1
- package/dist/cli/preset.js +0 -352
- package/dist/cli/preset.js.map +0 -1
- package/dist/cloudflare/index.d.ts +0 -21
- package/dist/cloudflare/index.d.ts.map +0 -1
- package/dist/cloudflare/index.js +0 -14
- package/dist/cloudflare/index.js.map +0 -1
- package/dist/cloudflare/r2Media.d.ts.map +0 -1
- package/dist/cloudflare/r2Media.js +0 -69
- package/dist/cloudflare/r2Media.js.map +0 -1
- package/dist/core/caller.d.ts +0 -35
- package/dist/core/caller.d.ts.map +0 -1
- package/dist/core/caller.js +0 -3
- package/dist/core/caller.js.map +0 -1
- package/dist/core/createMantle.d.ts +0 -22
- package/dist/core/createMantle.d.ts.map +0 -1
- package/dist/core/createMantle.js +0 -117
- package/dist/core/createMantle.js.map +0 -1
- package/dist/core/dialect.d.ts +0 -41
- package/dist/core/dialect.d.ts.map +0 -1
- package/dist/core/dialect.js +0 -7
- package/dist/core/dialect.js.map +0 -1
- package/dist/core/driver.d.ts +0 -17
- package/dist/core/driver.d.ts.map +0 -1
- package/dist/core/driver.js +0 -2
- package/dist/core/driver.js.map +0 -1
- package/dist/core/email.d.ts +0 -17
- package/dist/core/email.d.ts.map +0 -1
- package/dist/core/email.js +0 -2
- package/dist/core/email.js.map +0 -1
- package/dist/core/index.d.ts +0 -16
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -16
- package/dist/core/index.js.map +0 -1
- package/dist/core/invocation.d.ts +0 -66
- package/dist/core/invocation.d.ts.map +0 -1
- package/dist/core/invocation.js +0 -3
- package/dist/core/invocation.js.map +0 -1
- package/dist/core/runtime/auth.d.ts +0 -9
- package/dist/core/runtime/auth.d.ts.map +0 -1
- package/dist/core/runtime/auth.js +0 -39
- package/dist/core/runtime/auth.js.map +0 -1
- package/dist/core/runtime/createRuntime.d.ts +0 -23
- package/dist/core/runtime/createRuntime.d.ts.map +0 -1
- package/dist/core/runtime/createRuntime.js +0 -214
- package/dist/core/runtime/createRuntime.js.map +0 -1
- package/dist/core/runtime/verifyPlan.d.ts +0 -34
- package/dist/core/runtime/verifyPlan.d.ts.map +0 -1
- package/dist/core/runtime/verifyPlan.js +0 -301
- package/dist/core/runtime/verifyPlan.js.map +0 -1
- package/dist/core/service.d.ts +0 -45
- package/dist/core/service.d.ts.map +0 -1
- package/dist/core/service.js +0 -2
- package/dist/core/service.js.map +0 -1
- package/dist/core/site.d.ts.map +0 -1
- package/dist/core/site.js +0 -2
- package/dist/core/site.js.map +0 -1
- package/dist/core/siteConfig.d.ts +0 -5
- package/dist/core/siteConfig.d.ts.map +0 -1
- package/dist/core/siteConfig.js +0 -24
- package/dist/core/siteConfig.js.map +0 -1
- package/dist/core/sql/allowlist.d.ts +0 -65
- package/dist/core/sql/allowlist.d.ts.map +0 -1
- package/dist/core/sql/allowlist.js +0 -705
- package/dist/core/sql/allowlist.js.map +0 -1
- package/dist/core/sql/ast.d.ts +0 -24
- package/dist/core/sql/ast.d.ts.map +0 -1
- package/dist/core/sql/ast.js +0 -32
- package/dist/core/sql/ast.js.map +0 -1
- package/dist/core/sql/compile.d.ts +0 -50
- package/dist/core/sql/compile.d.ts.map +0 -1
- package/dist/core/sql/compile.js +0 -48
- package/dist/core/sql/compile.js.map +0 -1
- package/dist/core/sql/policy.d.ts +0 -121
- package/dist/core/sql/policy.d.ts.map +0 -1
- package/dist/core/sql/policy.js +0 -379
- package/dist/core/sql/policy.js.map +0 -1
- package/dist/core/sql/positions.d.ts +0 -30
- package/dist/core/sql/positions.d.ts.map +0 -1
- package/dist/core/sql/positions.js +0 -22
- package/dist/core/sql/positions.js.map +0 -1
- package/dist/core/sql/run.d.ts +0 -76
- package/dist/core/sql/run.d.ts.map +0 -1
- package/dist/core/sql/run.js +0 -267
- package/dist/core/sql/run.js.map +0 -1
- package/dist/core/store/createStore.d.ts +0 -49
- package/dist/core/store/createStore.d.ts.map +0 -1
- package/dist/core/store/createStore.js +0 -227
- package/dist/core/store/createStore.js.map +0 -1
- package/dist/core/store/cursor.d.ts +0 -4
- package/dist/core/store/cursor.d.ts.map +0 -1
- package/dist/core/store/cursor.js +0 -22
- package/dist/core/store/cursor.js.map +0 -1
- package/dist/core/store/json.d.ts +0 -80
- package/dist/core/store/json.d.ts.map +0 -1
- package/dist/core/store/json.js +0 -342
- package/dist/core/store/json.js.map +0 -1
- package/dist/core/store.d.ts +0 -160
- package/dist/core/store.d.ts.map +0 -1
- package/dist/core/store.js +0 -2
- package/dist/core/store.js.map +0 -1
- package/dist/core/wire.d.ts +0 -20
- package/dist/core/wire.d.ts.map +0 -1
- package/dist/core/wire.js +0 -84
- package/dist/core/wire.js.map +0 -1
- package/dist/core/withCaller.d.ts +0 -16
- package/dist/core/withCaller.d.ts.map +0 -1
- package/dist/core/withCaller.js +0 -29
- package/dist/core/withCaller.js.map +0 -1
- package/dist/d1/adapter.d.ts +0 -12
- package/dist/d1/adapter.d.ts.map +0 -1
- package/dist/d1/adapter.js +0 -23
- package/dist/d1/adapter.js.map +0 -1
- package/dist/d1/codec.d.ts +0 -14
- package/dist/d1/codec.d.ts.map +0 -1
- package/dist/d1/codec.js +0 -136
- package/dist/d1/codec.js.map +0 -1
- package/dist/d1/compile/index.d.ts +0 -9
- package/dist/d1/compile/index.d.ts.map +0 -1
- package/dist/d1/compile/index.js +0 -9
- package/dist/d1/compile/index.js.map +0 -1
- package/dist/d1/dialect.d.ts +0 -4
- package/dist/d1/dialect.d.ts.map +0 -1
- package/dist/d1/dialect.js +0 -13
- package/dist/d1/dialect.js.map +0 -1
- package/dist/d1/executor.d.ts +0 -13
- package/dist/d1/executor.d.ts.map +0 -1
- package/dist/d1/executor.js +0 -91
- package/dist/d1/executor.js.map +0 -1
- package/dist/d1/index.d.ts +0 -6
- package/dist/d1/index.d.ts.map +0 -1
- package/dist/d1/index.js +0 -6
- package/dist/d1/index.js.map +0 -1
- package/dist/d1/lower.d.ts +0 -8
- package/dist/d1/lower.d.ts.map +0 -1
- package/dist/d1/lower.js +0 -167
- package/dist/d1/lower.js.map +0 -1
- package/dist/d1/media.d.ts +0 -5
- package/dist/d1/media.d.ts.map +0 -1
- package/dist/d1/media.js +0 -157
- package/dist/d1/media.js.map +0 -1
- package/dist/d1/migrations.d.ts +0 -12
- package/dist/d1/migrations.d.ts.map +0 -1
- package/dist/d1/migrations.js +0 -111
- package/dist/d1/migrations.js.map +0 -1
- package/dist/d1/print.d.ts +0 -28
- package/dist/d1/print.d.ts.map +0 -1
- package/dist/d1/print.js +0 -54
- package/dist/d1/print.js.map +0 -1
- package/dist/d1/site.d.ts +0 -17
- package/dist/d1/site.d.ts.map +0 -1
- package/dist/d1/site.js +0 -63
- package/dist/d1/site.js.map +0 -1
- package/dist/d1/storage.d.ts +0 -34
- package/dist/d1/storage.d.ts.map +0 -1
- package/dist/d1/storage.js +0 -288
- package/dist/d1/storage.js.map +0 -1
- package/dist/d1/tz.d.ts +0 -21
- package/dist/d1/tz.d.ts.map +0 -1
- package/dist/d1/tz.js +0 -54
- package/dist/d1/tz.js.map +0 -1
- package/dist/d1/validator.d.ts +0 -10
- package/dist/d1/validator.d.ts.map +0 -1
- package/dist/d1/validator.js +0 -33
- package/dist/d1/validator.js.map +0 -1
- package/dist/mcp/apps.d.ts +0 -43
- package/dist/mcp/apps.d.ts.map +0 -1
- package/dist/mcp/apps.js +0 -57
- package/dist/mcp/apps.js.map +0 -1
- package/dist/mcp/catalog.d.ts +0 -55
- package/dist/mcp/catalog.d.ts.map +0 -1
- package/dist/mcp/catalog.js +0 -81
- package/dist/mcp/catalog.js.map +0 -1
- package/dist/mcp/createMcpSurface.d.ts +0 -34
- package/dist/mcp/createMcpSurface.d.ts.map +0 -1
- package/dist/mcp/createMcpSurface.js +0 -150
- package/dist/mcp/createMcpSurface.js.map +0 -1
- package/dist/mcp/index.d.ts +0 -4
- package/dist/mcp/index.d.ts.map +0 -1
- package/dist/mcp/index.js +0 -4
- package/dist/mcp/index.js.map +0 -1
- package/dist/postgres/adapter.d.ts +0 -20
- package/dist/postgres/adapter.d.ts.map +0 -1
- package/dist/postgres/adapter.js +0 -44
- package/dist/postgres/adapter.js.map +0 -1
- package/dist/postgres/codec.d.ts +0 -13
- package/dist/postgres/codec.d.ts.map +0 -1
- package/dist/postgres/codec.js +0 -110
- package/dist/postgres/codec.js.map +0 -1
- package/dist/postgres/compile/index.d.ts +0 -9
- package/dist/postgres/compile/index.d.ts.map +0 -1
- package/dist/postgres/compile/index.js +0 -9
- package/dist/postgres/compile/index.js.map +0 -1
- package/dist/postgres/driver.d.ts +0 -92
- package/dist/postgres/driver.d.ts.map +0 -1
- package/dist/postgres/driver.js +0 -110
- package/dist/postgres/driver.js.map +0 -1
- package/dist/postgres/executor.d.ts +0 -20
- package/dist/postgres/executor.d.ts.map +0 -1
- package/dist/postgres/executor.js +0 -69
- package/dist/postgres/executor.js.map +0 -1
- package/dist/postgres/index.d.ts +0 -7
- package/dist/postgres/index.d.ts.map +0 -1
- package/dist/postgres/index.js +0 -7
- package/dist/postgres/index.js.map +0 -1
- package/dist/postgres/lower.d.ts +0 -6
- package/dist/postgres/lower.d.ts.map +0 -1
- package/dist/postgres/lower.js +0 -157
- package/dist/postgres/lower.js.map +0 -1
- package/dist/postgres/print.d.ts +0 -11
- package/dist/postgres/print.d.ts.map +0 -1
- package/dist/postgres/print.js +0 -121
- package/dist/postgres/print.js.map +0 -1
- package/dist/postgres/storage.d.ts +0 -19
- package/dist/postgres/storage.d.ts.map +0 -1
- package/dist/postgres/storage.js +0 -201
- package/dist/postgres/storage.js.map +0 -1
- package/dist/postgres/textRows.d.ts +0 -10
- package/dist/postgres/textRows.d.ts.map +0 -1
- package/dist/postgres/textRows.js +0 -44
- package/dist/postgres/textRows.js.map +0 -1
- package/dist/postgres/validator.d.ts +0 -12
- package/dist/postgres/validator.d.ts.map +0 -1
- package/dist/postgres/validator.js +0 -46
- package/dist/postgres/validator.js.map +0 -1
- package/dist/spec/domain/index.d.ts +0 -3
- package/dist/spec/domain/index.d.ts.map +0 -1
- package/dist/spec/domain/index.js +0 -3
- package/dist/spec/domain/index.js.map +0 -1
- package/dist/spec/domain/model/ContentState.d.ts +0 -8
- package/dist/spec/domain/model/ContentState.d.ts.map +0 -1
- package/dist/spec/domain/model/ContentState.js +0 -7
- package/dist/spec/domain/model/ContentState.js.map +0 -1
- package/dist/spec/domain/model/Entry.d.ts +0 -29
- package/dist/spec/domain/model/Entry.d.ts.map +0 -1
- package/dist/spec/domain/model/Entry.js +0 -16
- package/dist/spec/domain/model/Entry.js.map +0 -1
- package/dist/spec/domain/model/Locale.d.ts +0 -30
- package/dist/spec/domain/model/Locale.d.ts.map +0 -1
- package/dist/spec/domain/model/Locale.js +0 -33
- package/dist/spec/domain/model/Locale.js.map +0 -1
- package/dist/spec/domain/model/ManifestGrammar.d.ts.map +0 -1
- package/dist/spec/domain/model/ManifestGrammar.js +0 -149
- package/dist/spec/domain/model/ManifestGrammar.js.map +0 -1
- package/dist/spec/domain/model/MediaMimeAccept.d.ts +0 -55
- package/dist/spec/domain/model/MediaMimeAccept.d.ts.map +0 -1
- package/dist/spec/domain/model/MediaMimeAccept.js +0 -90
- package/dist/spec/domain/model/MediaMimeAccept.js.map +0 -1
- package/dist/spec/domain/model/RuntimePlan.d.ts.map +0 -1
- package/dist/spec/domain/model/RuntimePlan.js +0 -4
- package/dist/spec/domain/model/RuntimePlan.js.map +0 -1
- package/dist/spec/domain/model/SiteConfig.d.ts +0 -173
- package/dist/spec/domain/model/SiteConfig.d.ts.map +0 -1
- package/dist/spec/domain/model/SiteConfig.js +0 -13
- package/dist/spec/domain/model/SiteConfig.js.map +0 -1
- package/dist/spec/domain/model/SqlIr.d.ts.map +0 -1
- package/dist/spec/domain/model/SqlIr.js +0 -95
- package/dist/spec/domain/model/SqlIr.js.map +0 -1
- package/dist/spec/domain/model/index.d.ts +0 -14
- package/dist/spec/domain/model/index.d.ts.map +0 -1
- package/dist/spec/domain/model/index.js +0 -14
- package/dist/spec/domain/model/index.js.map +0 -1
- package/dist/spec/domain/service/CloudflareCron.d.ts.map +0 -1
- package/dist/spec/domain/service/CloudflareCron.js.map +0 -1
- package/dist/spec/domain/service/CrossSchemaChecker.d.ts +0 -34
- package/dist/spec/domain/service/CrossSchemaChecker.d.ts.map +0 -1
- package/dist/spec/domain/service/CrossSchemaChecker.js +0 -114
- package/dist/spec/domain/service/CrossSchemaChecker.js.map +0 -1
- package/dist/spec/domain/service/EntryDataValidator.d.ts +0 -56
- package/dist/spec/domain/service/EntryDataValidator.d.ts.map +0 -1
- package/dist/spec/domain/service/EntryDataValidator.js +0 -88
- package/dist/spec/domain/service/EntryDataValidator.js.map +0 -1
- package/dist/spec/domain/service/JsonSchemaToZod.d.ts +0 -29
- package/dist/spec/domain/service/JsonSchemaToZod.d.ts.map +0 -1
- package/dist/spec/domain/service/JsonSchemaToZod.js +0 -156
- package/dist/spec/domain/service/JsonSchemaToZod.js.map +0 -1
- package/dist/spec/domain/service/LifecycleStateMachine.d.ts +0 -75
- package/dist/spec/domain/service/LifecycleStateMachine.d.ts.map +0 -1
- package/dist/spec/domain/service/LifecycleStateMachine.js +0 -76
- package/dist/spec/domain/service/LifecycleStateMachine.js.map +0 -1
- package/dist/spec/domain/service/LocaleCanonicalizer.d.ts +0 -29
- package/dist/spec/domain/service/LocaleCanonicalizer.d.ts.map +0 -1
- package/dist/spec/domain/service/LocaleCanonicalizer.js +0 -96
- package/dist/spec/domain/service/LocaleCanonicalizer.js.map +0 -1
- package/dist/spec/domain/service/ManifestFieldChecks.d.ts +0 -60
- package/dist/spec/domain/service/ManifestFieldChecks.d.ts.map +0 -1
- package/dist/spec/domain/service/ManifestFieldChecks.js +0 -116
- package/dist/spec/domain/service/ManifestFieldChecks.js.map +0 -1
- package/dist/spec/domain/service/ManifestGraphValidator.d.ts +0 -15
- package/dist/spec/domain/service/ManifestGraphValidator.d.ts.map +0 -1
- package/dist/spec/domain/service/ManifestGraphValidator.js +0 -225
- package/dist/spec/domain/service/ManifestGraphValidator.js.map +0 -1
- package/dist/spec/domain/service/ManifestLinker.d.ts +0 -45
- package/dist/spec/domain/service/ManifestLinker.d.ts.map +0 -1
- package/dist/spec/domain/service/ManifestLinker.js +0 -92
- package/dist/spec/domain/service/ManifestLinker.js.map +0 -1
- package/dist/spec/domain/service/ManifestLocaleTrimmer.d.ts +0 -16
- package/dist/spec/domain/service/ManifestLocaleTrimmer.d.ts.map +0 -1
- package/dist/spec/domain/service/ManifestLocaleTrimmer.js +0 -76
- package/dist/spec/domain/service/ManifestLocaleTrimmer.js.map +0 -1
- package/dist/spec/domain/service/ManifestParser.d.ts +0 -49
- package/dist/spec/domain/service/ManifestParser.d.ts.map +0 -1
- package/dist/spec/domain/service/ManifestParser.js +0 -203
- package/dist/spec/domain/service/ManifestParser.js.map +0 -1
- package/dist/spec/domain/service/ManifestPartition.d.ts +0 -9
- package/dist/spec/domain/service/ManifestPartition.d.ts.map +0 -1
- package/dist/spec/domain/service/ManifestPartition.js +0 -19
- package/dist/spec/domain/service/ManifestPartition.js.map +0 -1
- package/dist/spec/domain/service/ManifestPathDiagnoser.d.ts +0 -33
- package/dist/spec/domain/service/ManifestPathDiagnoser.d.ts.map +0 -1
- package/dist/spec/domain/service/ManifestPathDiagnoser.js +0 -43
- package/dist/spec/domain/service/ManifestPathDiagnoser.js.map +0 -1
- package/dist/spec/domain/service/ManifestSourceSpans.d.ts +0 -10
- package/dist/spec/domain/service/ManifestSourceSpans.d.ts.map +0 -1
- package/dist/spec/domain/service/ManifestSourceSpans.js +0 -76
- package/dist/spec/domain/service/ManifestSourceSpans.js.map +0 -1
- package/dist/spec/domain/service/McpToolNaming.d.ts +0 -25
- package/dist/spec/domain/service/McpToolNaming.d.ts.map +0 -1
- package/dist/spec/domain/service/McpToolNaming.js +0 -50
- package/dist/spec/domain/service/McpToolNaming.js.map +0 -1
- package/dist/spec/domain/service/PlanFingerprint.d.ts.map +0 -1
- package/dist/spec/domain/service/PlanFingerprint.js +0 -14
- package/dist/spec/domain/service/PlanFingerprint.js.map +0 -1
- package/dist/spec/domain/service/ProcedureViewSpecChecks.d.ts +0 -4
- package/dist/spec/domain/service/ProcedureViewSpecChecks.d.ts.map +0 -1
- package/dist/spec/domain/service/ProcedureViewSpecChecks.js +0 -211
- package/dist/spec/domain/service/ProcedureViewSpecChecks.js.map +0 -1
- package/dist/spec/domain/service/SchemaAdminUiChecker.d.ts +0 -42
- package/dist/spec/domain/service/SchemaAdminUiChecker.d.ts.map +0 -1
- package/dist/spec/domain/service/SchemaAdminUiChecker.js +0 -289
- package/dist/spec/domain/service/SchemaAdminUiChecker.js.map +0 -1
- package/dist/spec/domain/service/SchemaIndexChecker.d.ts +0 -33
- package/dist/spec/domain/service/SchemaIndexChecker.d.ts.map +0 -1
- package/dist/spec/domain/service/SchemaIndexChecker.js +0 -256
- package/dist/spec/domain/service/SchemaIndexChecker.js.map +0 -1
- package/dist/spec/domain/service/SchemaSearchChecker.d.ts +0 -11
- package/dist/spec/domain/service/SchemaSearchChecker.d.ts.map +0 -1
- package/dist/spec/domain/service/SchemaSearchChecker.js +0 -78
- package/dist/spec/domain/service/SchemaSearchChecker.js.map +0 -1
- package/dist/spec/domain/service/SchemaSpecChecks.d.ts +0 -31
- package/dist/spec/domain/service/SchemaSpecChecks.d.ts.map +0 -1
- package/dist/spec/domain/service/SchemaSpecChecks.js +0 -445
- package/dist/spec/domain/service/SchemaSpecChecks.js.map +0 -1
- package/dist/spec/domain/service/SiteDefaultsValidator.d.ts +0 -39
- package/dist/spec/domain/service/SiteDefaultsValidator.d.ts.map +0 -1
- package/dist/spec/domain/service/SiteDefaultsValidator.js +0 -194
- package/dist/spec/domain/service/SiteDefaultsValidator.js.map +0 -1
- package/dist/spec/domain/service/SqlClassify.d.ts +0 -19
- package/dist/spec/domain/service/SqlClassify.d.ts.map +0 -1
- package/dist/spec/domain/service/SqlClassify.js +0 -42
- package/dist/spec/domain/service/SqlClassify.js.map +0 -1
- package/dist/spec/domain/service/SqlRefusal.d.ts +0 -16
- package/dist/spec/domain/service/SqlRefusal.d.ts.map +0 -1
- package/dist/spec/domain/service/SqlRefusal.js +0 -20
- package/dist/spec/domain/service/SqlRefusal.js.map +0 -1
- package/dist/spec/domain/service/SqlTypes.d.ts +0 -40
- package/dist/spec/domain/service/SqlTypes.d.ts.map +0 -1
- package/dist/spec/domain/service/SqlTypes.js +0 -110
- package/dist/spec/domain/service/SqlTypes.js.map +0 -1
- package/dist/spec/domain/service/StaffRoleHierarchy.d.ts +0 -3
- package/dist/spec/domain/service/StaffRoleHierarchy.d.ts.map +0 -1
- package/dist/spec/domain/service/StaffRoleHierarchy.js +0 -19
- package/dist/spec/domain/service/StaffRoleHierarchy.js.map +0 -1
- package/dist/spec/domain/service/TriggerGraphChecks.d.ts +0 -16
- package/dist/spec/domain/service/TriggerGraphChecks.d.ts.map +0 -1
- package/dist/spec/domain/service/TriggerGraphChecks.js +0 -337
- package/dist/spec/domain/service/TriggerGraphChecks.js.map +0 -1
- package/dist/spec/domain/service/TriggerSpecChecks.d.ts +0 -4
- package/dist/spec/domain/service/TriggerSpecChecks.d.ts.map +0 -1
- package/dist/spec/domain/service/TriggerSpecChecks.js +0 -89
- package/dist/spec/domain/service/TriggerSpecChecks.js.map +0 -1
- package/dist/spec/domain/service/ValidatedAdminUiProjection.d.ts +0 -11
- package/dist/spec/domain/service/ValidatedAdminUiProjection.d.ts.map +0 -1
- package/dist/spec/domain/service/ValidatedAdminUiProjection.js +0 -26
- package/dist/spec/domain/service/ValidatedAdminUiProjection.js.map +0 -1
- package/dist/spec/domain/service/ViewAdminUiChecker.d.ts +0 -14
- package/dist/spec/domain/service/ViewAdminUiChecker.d.ts.map +0 -1
- package/dist/spec/domain/service/ViewAdminUiChecker.js +0 -53
- package/dist/spec/domain/service/ViewAdminUiChecker.js.map +0 -1
- package/dist/spec/domain/service/index.d.ts +0 -24
- package/dist/spec/domain/service/index.d.ts.map +0 -1
- package/dist/spec/domain/service/index.js +0 -24
- package/dist/spec/domain/service/index.js.map +0 -1
- package/dist/spec/index.d.ts +0 -10
- package/dist/spec/index.d.ts.map +0 -1
- package/dist/spec/index.js +0 -12
- package/dist/spec/index.js.map +0 -1
- package/dist/spec/infrastructure/cli/parseArgsError.d.ts +0 -16
- package/dist/spec/infrastructure/cli/parseArgsError.d.ts.map +0 -1
- package/dist/spec/infrastructure/cli/parseArgsError.js +0 -34
- package/dist/spec/infrastructure/cli/parseArgsError.js.map +0 -1
- package/dist/spec/infrastructure/index.d.ts +0 -2
- package/dist/spec/infrastructure/index.d.ts.map +0 -1
- package/dist/spec/infrastructure/index.js +0 -2
- package/dist/spec/infrastructure/index.js.map +0 -1
- package/dist/spec/infrastructure/sql/PgQueryParser.d.ts +0 -18
- package/dist/spec/infrastructure/sql/PgQueryParser.d.ts.map +0 -1
- package/dist/spec/infrastructure/sql/PgQueryParser.js +0 -17
- package/dist/spec/infrastructure/sql/PgQueryParser.js.map +0 -1
- package/dist/spec/infrastructure/sql/compilePlan.d.ts +0 -37
- package/dist/spec/infrastructure/sql/compilePlan.d.ts.map +0 -1
- package/dist/spec/infrastructure/sql/compilePlan.js +0 -282
- package/dist/spec/infrastructure/sql/compilePlan.js.map +0 -1
- package/dist/spec/infrastructure/sql/compileSql.d.ts +0 -35
- package/dist/spec/infrastructure/sql/compileSql.d.ts.map +0 -1
- package/dist/spec/infrastructure/sql/compileSql.js +0 -92
- package/dist/spec/infrastructure/sql/compileSql.js.map +0 -1
- package/dist/spec/infrastructure/sql/frontEnd.d.ts +0 -8
- package/dist/spec/infrastructure/sql/frontEnd.d.ts.map +0 -1
- package/dist/spec/infrastructure/sql/frontEnd.js +0 -100
- package/dist/spec/infrastructure/sql/frontEnd.js.map +0 -1
- package/dist/spec/infrastructure/sql/index.d.ts +0 -4
- package/dist/spec/infrastructure/sql/index.d.ts.map +0 -1
- package/dist/spec/infrastructure/sql/index.js +0 -4
- package/dist/spec/infrastructure/sql/index.js.map +0 -1
- package/dist/spec/kernel/diagnostic.d.ts.map +0 -1
- package/dist/spec/kernel/diagnostic.js +0 -296
- package/dist/spec/kernel/diagnostic.js.map +0 -1
- package/dist/spec/kernel/index.d.ts +0 -8
- package/dist/spec/kernel/index.d.ts.map +0 -1
- package/dist/spec/kernel/index.js +0 -8
- package/dist/spec/kernel/index.js.map +0 -1
- package/dist/spec/usecase/EmitTypes.d.ts +0 -22
- package/dist/spec/usecase/EmitTypes.d.ts.map +0 -1
- package/dist/spec/usecase/EmitTypes.js +0 -182
- package/dist/spec/usecase/EmitTypes.js.map +0 -1
- package/dist/spec/usecase/ValidateManifestsUseCase.d.ts +0 -8
- package/dist/spec/usecase/ValidateManifestsUseCase.d.ts.map +0 -1
- package/dist/spec/usecase/ValidateManifestsUseCase.js +0 -101
- package/dist/spec/usecase/ValidateManifestsUseCase.js.map +0 -1
- package/dist/spec/usecase/dto/ValidateManifestsRequest.d.ts +0 -27
- package/dist/spec/usecase/dto/ValidateManifestsRequest.d.ts.map +0 -1
- package/dist/spec/usecase/dto/ValidateManifestsRequest.js +0 -2
- package/dist/spec/usecase/dto/ValidateManifestsRequest.js.map +0 -1
- package/dist/spec/usecase/dto/ValidateManifestsResponse.d.ts +0 -14
- package/dist/spec/usecase/dto/ValidateManifestsResponse.d.ts.map +0 -1
- package/dist/spec/usecase/dto/ValidateManifestsResponse.js +0 -2
- package/dist/spec/usecase/dto/ValidateManifestsResponse.js.map +0 -1
- package/dist/spec/usecase/dto/index.d.ts +0 -3
- package/dist/spec/usecase/dto/index.d.ts.map +0 -1
- package/dist/spec/usecase/dto/index.js +0 -3
- package/dist/spec/usecase/dto/index.js.map +0 -1
- package/dist/spec/usecase/index.d.ts +0 -10
- package/dist/spec/usecase/index.d.ts.map +0 -1
- package/dist/spec/usecase/index.js +0 -10
- package/dist/spec/usecase/index.js.map +0 -1
- package/dist/testing/cases/before-hook.d.ts +0 -4
- package/dist/testing/cases/before-hook.d.ts.map +0 -1
- package/dist/testing/cases/before-hook.js +0 -71
- package/dist/testing/cases/before-hook.js.map +0 -1
- package/dist/testing/cases/corpus.d.ts +0 -12
- package/dist/testing/cases/corpus.d.ts.map +0 -1
- package/dist/testing/cases/corpus.js +0 -91
- package/dist/testing/cases/corpus.js.map +0 -1
- package/dist/testing/cases/policy.d.ts +0 -74
- package/dist/testing/cases/policy.d.ts.map +0 -1
- package/dist/testing/cases/policy.js +0 -142
- package/dist/testing/cases/policy.js.map +0 -1
- package/dist/testing/cases/printer.d.ts +0 -4
- package/dist/testing/cases/printer.d.ts.map +0 -1
- package/dist/testing/cases/printer.js +0 -32
- package/dist/testing/cases/printer.js.map +0 -1
- package/dist/testing/cases/report-view.d.ts +0 -5
- package/dist/testing/cases/report-view.d.ts.map +0 -1
- package/dist/testing/cases/report-view.js +0 -33
- package/dist/testing/cases/report-view.js.map +0 -1
- package/dist/testing/cases/requisition.d.ts +0 -4
- package/dist/testing/cases/requisition.d.ts.map +0 -1
- package/dist/testing/cases/requisition.js +0 -38
- package/dist/testing/cases/requisition.js.map +0 -1
- package/dist/testing/cases/search-places.d.ts +0 -4
- package/dist/testing/cases/search-places.d.ts.map +0 -1
- package/dist/testing/cases/search-places.js +0 -60
- package/dist/testing/cases/search-places.js.map +0 -1
- package/dist/testing/cases/stock.d.ts +0 -4
- package/dist/testing/cases/stock.d.ts.map +0 -1
- package/dist/testing/cases/stock.js +0 -35
- package/dist/testing/cases/stock.js.map +0 -1
- package/dist/testing/cases/store.d.ts +0 -4
- package/dist/testing/cases/store.d.ts.map +0 -1
- package/dist/testing/cases/store.js +0 -100
- package/dist/testing/cases/store.js.map +0 -1
- package/dist/testing/harness.d.ts +0 -94
- package/dist/testing/harness.d.ts.map +0 -1
- package/dist/testing/harness.js +0 -168
- package/dist/testing/harness.js.map +0 -1
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js.map +0 -1
- package/dist/testing/report.d.ts +0 -15
- package/dist/testing/report.d.ts.map +0 -1
- package/dist/testing/report.js +0 -22
- package/dist/testing/report.js.map +0 -1
- package/dist/web/createRestSurface.d.ts +0 -7
- package/dist/web/createRestSurface.d.ts.map +0 -1
- package/dist/web/createRestSurface.js +0 -39
- package/dist/web/createRestSurface.js.map +0 -1
- package/dist/web/index.d.ts +0 -2
- package/dist/web/index.d.ts.map +0 -1
- package/dist/web/index.js +0 -2
- package/dist/web/index.js.map +0 -1
- package/docs/adr/0001-four-atom-manifest-model.md +0 -440
- package/docs/adr/0002-closed-enums-for-bindings.md +0 -253
- package/docs/adr/0007-ai-as-primary-author.md +0 -473
- package/docs/adr/0008-structured-diagnostic-shape.md +0 -338
- package/docs/adr/0009-consumer-supplied-manifests.md +0 -149
- package/docs/adr/0010-locale-and-translates.md +0 -453
- package/docs/adr/0011-adapter-port-spec.md +0 -281
- package/docs/adr/0012-views-as-public-rest.md +0 -161
- package/docs/adr/0013-agent-provisioned-consumer-projects.md +0 -154
- package/docs/adr/0014-auth-better-auth-and-multi-tenant-mcp.md +0 -919
- package/docs/adr/0016-site-semantic-layer.md +0 -70
- package/docs/adr/0017-media-multi-variant-agent-side-optimization.md +0 -181
- package/docs/adr/0018-core-starters-repository-boundary.md +0 -179
- package/docs/adr/0019-sealed-manifest-runtime-pipeline.md +0 -244
- package/docs/adr/0020-builtin-handler-contracts-and-matched-upsert.md +0 -199
- package/docs/adr/0021-retire-starter-scaffolding.md +0 -30
- package/docs/adr/0022-caller-observed-version-occ.md +0 -212
- package/docs/adr/0023-port-failure-contract.md +0 -69
- package/docs/adr/0024-manifest-native-schema-tables.md +0 -264
- package/docs/adr/0025-reserved-native-columns-and-published-only-public-views.md +0 -105
- package/docs/adr/0026-progressive-generate.md +0 -36
- package/docs/adr/0027-scheduled-procedure-triggers.md +0 -31
- package/docs/adr/0028-schema-ttl-expiry.md +0 -33
- package/docs/adr/0029-mcp-apps-interaction-contracts.md +0 -324
- package/docs/adr/0030-store.md +0 -40
- package/docs/adr/0031-host-cloud-core-contract.md +0 -25
- package/docs/adr/0032-store-centric-core-and-service-contract.md +0 -361
- package/docs/adr/0033-storage-converges-to-the-plan.md +0 -92
- package/docs/adr/0034-store-is-authored-as-sql.md +0 -192
- package/docs/adr/0035-sql-dialects.md +0 -154
- package/docs/adr/0036-host-and-dialect.md +0 -65
- package/docs/adr/0037-postgresql-is-the-reference-dialect.md +0 -124
- package/docs/adr/0038-bun-native-host.md +0 -63
- package/docs/adr/README.md +0 -96
- package/docs/adr/adr-lite-803-request-diagnostics.md +0 -38
- package/docs/adr/adr-lite-808-route-readiness.md +0 -47
- package/docs/adr/adr-lite-809-bounded-public-content.md +0 -71
- package/docs/adr/adr-lite-812-native-parity.md +0 -150
- package/docs/adr/adr-lite-823-home-statistics.md +0 -64
- package/docs/adr/adr-lite-842-mcp-authoring.md +0 -30
- package/docs/adr/adr-lite-845-frontend-client.md +0 -38
- package/docs/adr/adr-lite-861-admin-webmcp.md +0 -48
- package/docs/adr/adr-lite-909-admin-ui-kit.md +0 -37
- package/docs/examples/commerce-inventory.md +0 -481
- package/docs/examples/commerce.md +0 -254
- package/docs/examples/guarded-api.md +0 -238
- package/docs/examples/intake-hooks.md +0 -237
- package/docs/examples/intake.md +0 -127
- package/docs/examples/legal-documents.md +0 -218
- package/docs/examples/procurement.md +0 -215
- package/docs/examples/publication.md +0 -211
- package/docs/examples/reference-service/.mantle/generated/mantle.ts +0 -174
- package/docs/examples/reference-service/.mantle/generated/plan.json +0 -1936
- package/docs/examples/reference-service/README.md +0 -33
- package/docs/examples/reference-service/manifests/catalog.yaml +0 -103
- package/docs/examples/reference-service/manifests/orders.yaml +0 -120
- package/docs/examples/reference-service/mantle.config.json +0 -1
- package/docs/examples/reference-service/package.json +0 -27
- package/docs/examples/reference-service/smoke.mjs +0 -156
- package/docs/examples/reference-service/src/handlers.ts +0 -36
- package/docs/examples/reference-service/src/index.ts +0 -33
- package/docs/examples/reference-service/src/service.ts +0 -78
- package/docs/examples/reference-service/wrangler.jsonc +0 -26
- package/docs/examples/reservation.md +0 -142
- package/docs/skills/develop/mcp-app.md +0 -79
- /package/docs/examples/{reference-service → app-shell}/.dev.vars.example +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** MCP Apps (ADR-0029 D7): UI resources served beside the tools that render in them. */
|
|
2
|
+
export declare const RESOURCE_MIME_TYPE = "text/html;profile=mcp-app";
|
|
3
|
+
/** What `resources/read` passes an HTML loader. */
|
|
4
|
+
export interface McpAppRender {
|
|
5
|
+
/** The tools this caller's `tools/list` shows on the endpoint, so the HTML names none it cannot see. */
|
|
6
|
+
readonly tools: ReadonlySet<string>;
|
|
7
|
+
/** The request's environment as the handler received it: Worker bindings such as `ASSETS`, or whatever a Bun host passes. */
|
|
8
|
+
readonly env: unknown;
|
|
9
|
+
/** The `resources/read` request, for its origin. */
|
|
10
|
+
readonly request: Request;
|
|
11
|
+
}
|
|
12
|
+
/** The CSP a resource asks its host for, as `_meta.ui.csp`. */
|
|
13
|
+
export type McpAppCsp = {
|
|
14
|
+
readonly connectDomains?: readonly string[];
|
|
15
|
+
readonly resourceDomains?: readonly string[];
|
|
16
|
+
readonly frameDomains?: readonly string[];
|
|
17
|
+
readonly baseUriDomains?: readonly string[];
|
|
18
|
+
};
|
|
19
|
+
/** What a loader may return beside a plain string: the HTML and a CSP known only when it is read. It is sent on `resources/read` and replaces the resource's static `csp` (lists are not merged). */
|
|
20
|
+
export interface McpAppPage {
|
|
21
|
+
readonly html: string;
|
|
22
|
+
readonly csp?: McpAppCsp;
|
|
23
|
+
}
|
|
24
|
+
/** One `ui://` resource. The HTML is a reusable asset and never carries caller data: that travels in tool results. */
|
|
25
|
+
export interface McpAppResource {
|
|
26
|
+
readonly uri: string;
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly title?: string;
|
|
29
|
+
readonly description?: string;
|
|
30
|
+
readonly html: string | ((render: McpAppRender) => string | McpAppPage | Promise<string | McpAppPage>);
|
|
31
|
+
readonly csp?: McpAppCsp;
|
|
32
|
+
readonly permissions?: {
|
|
33
|
+
readonly camera?: Record<string, never>;
|
|
34
|
+
readonly microphone?: Record<string, never>;
|
|
35
|
+
readonly geolocation?: Record<string, never>;
|
|
36
|
+
readonly clipboardWrite?: Record<string, never>;
|
|
37
|
+
};
|
|
38
|
+
readonly prefersBorder?: boolean;
|
|
39
|
+
/** `_meta.ui.domain`: the dedicated sandbox origin a host should serve this App from, in the form that host documents. */
|
|
40
|
+
readonly domain?: string;
|
|
41
|
+
/** Tool names whose results this resource renders. */
|
|
42
|
+
readonly renders?: readonly string[];
|
|
43
|
+
/** Views only this App may call (`visibility: ["app"]`); a client without MCP Apps does not see them. A Procedure cannot be hidden from the model. */
|
|
44
|
+
readonly appOnly?: readonly string[];
|
|
45
|
+
}
|
|
46
|
+
export interface McpApps {
|
|
47
|
+
readonly resources: readonly McpAppResource[];
|
|
48
|
+
}
|
|
49
|
+
/** An application-owned contributor resolved after the endpoint's caller gate. */
|
|
50
|
+
export type McpAppsSource = McpApps | ((context: Pick<McpAppRender, "env" | "request">) => McpApps | Promise<McpApps>);
|
|
51
|
+
/** Flatten contributors; `mcp(...)` reads static resources getters once at construction. */
|
|
52
|
+
export declare const resourcesOf: (apps: McpApps | readonly McpApps[]) => McpApps;
|
|
53
|
+
/** Static contributors are checked at construction; resolved factories are checked per request. A request-bound tool table defers tool-link checks until its first request. */
|
|
54
|
+
export declare function linkApps(apps: McpApps | readonly McpApps[], tools?: ReadonlySet<string>, views?: ReadonlySet<string>): {
|
|
55
|
+
resources: McpAppResource[];
|
|
56
|
+
renders: Map<string, string>;
|
|
57
|
+
appOnly: Set<string>;
|
|
58
|
+
};
|
|
59
|
+
/** One endpoint's Apps bound to its tool table; `previous` is reused while the table's names are unchanged. */
|
|
60
|
+
export declare function linkSurface(apps: McpApps | readonly McpApps[], selected: readonly {
|
|
61
|
+
name: string;
|
|
62
|
+
page?: unknown;
|
|
63
|
+
}[], previous?: {
|
|
64
|
+
key: string;
|
|
65
|
+
links: ReturnType<typeof linkApps>;
|
|
66
|
+
}): {
|
|
67
|
+
key: string;
|
|
68
|
+
links: ReturnType<typeof linkApps>;
|
|
69
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ContractError } from "./contracts.js";
|
|
2
|
+
export const RESOURCE_MIME_TYPE = "text/html;profile=mcp-app";
|
|
3
|
+
export const resourcesOf = (apps) => ({ resources: (Array.isArray(apps) ? apps : [apps]).flatMap(app => app.resources) });
|
|
4
|
+
export function linkApps(apps, tools, views) {
|
|
5
|
+
const resources = resourcesOf(apps).resources;
|
|
6
|
+
const uris = new Set(), names = new Set(), renders = new Map(), appOnly = new Set();
|
|
7
|
+
const refuse = (message) => { throw new ContractError("MCP_APP_CONFLICT", message, "mcp:apps", { status: 500 }); };
|
|
8
|
+
for (const resource of resources) {
|
|
9
|
+
if (!resource.uri.startsWith("ui://"))
|
|
10
|
+
refuse(`MCP App resource '${resource.name}' must use a ui:// URI.`);
|
|
11
|
+
if (uris.has(resource.uri))
|
|
12
|
+
refuse(`MCP App resource URI '${resource.uri}' is registered twice.`);
|
|
13
|
+
if (names.has(resource.name))
|
|
14
|
+
refuse(`MCP App resource name '${resource.name}' is registered twice.`);
|
|
15
|
+
uris.add(resource.uri);
|
|
16
|
+
names.add(resource.name);
|
|
17
|
+
for (const tool of [...resource.renders ?? [], ...resource.appOnly ?? []]) {
|
|
18
|
+
if (tools && !tools.has(tool))
|
|
19
|
+
refuse(`MCP App resource '${resource.name}' names tool '${tool}', which this endpoint does not serve.`);
|
|
20
|
+
if (renders.has(tool) && renders.get(tool) !== resource.uri)
|
|
21
|
+
refuse(`Tool '${tool}' is claimed by two MCP App resources.`);
|
|
22
|
+
renders.set(tool, resource.uri);
|
|
23
|
+
}
|
|
24
|
+
for (const tool of resource.appOnly ?? []) {
|
|
25
|
+
if (views && !views.has(tool))
|
|
26
|
+
refuse(`App-only tool '${tool}' must be a View this endpoint serves.`);
|
|
27
|
+
appOnly.add(tool);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return { resources, renders, appOnly };
|
|
31
|
+
}
|
|
32
|
+
export function linkSurface(apps, selected, previous) {
|
|
33
|
+
const key = JSON.stringify(selected.map(tool => [tool.name, !!tool.page]).sort(([a], [b]) => a.localeCompare(b)));
|
|
34
|
+
return previous?.key === key ? previous : { key, links: linkApps(apps, new Set(selected.map(tool => tool.name)), new Set(selected.filter(tool => tool.page).map(tool => tool.name))) };
|
|
35
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Caller } from "./contracts.js";
|
|
2
|
+
import type { Tool } from "./mcp.js";
|
|
3
|
+
export declare function callTool<Database, Handlers>(tool: Tool<Database, Handlers>, raw: Record<string, unknown>, db: Database, caller: Caller, handlers: Handlers): Promise<unknown>;
|
|
4
|
+
/** Transport input is checked before acquiring an application-owned native handle. */
|
|
5
|
+
export declare function callToolLazy<Database, Handlers>(tool: Tool<Database, Handlers>, raw: Record<string, unknown>, getDb: () => Database, caller: Caller, handlers: Handlers, dryRun?: () => unknown): Promise<unknown>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { convert, invalid } from "./surface.js";
|
|
2
|
+
import { checkPageLimit } from "./paging.js";
|
|
3
|
+
export async function callTool(tool, raw, db, caller, handlers) {
|
|
4
|
+
return callToolLazy(tool, raw, () => db, caller, handlers);
|
|
5
|
+
}
|
|
6
|
+
export async function callToolLazy(tool, raw, getDb, caller, handlers, dryRun) {
|
|
7
|
+
if (tool.page) {
|
|
8
|
+
const { limit, cursor, ...input } = raw;
|
|
9
|
+
if (limit !== undefined)
|
|
10
|
+
checkPageLimit(limit, tool.path);
|
|
11
|
+
if (cursor !== undefined && typeof cursor !== "string")
|
|
12
|
+
invalid("Invalid paging options.", tool.path);
|
|
13
|
+
await tool.validate(input);
|
|
14
|
+
convert(input, tool.convert);
|
|
15
|
+
if (dryRun)
|
|
16
|
+
return dryRun();
|
|
17
|
+
return tool.page(getDb(), caller, input, { limit: limit, cursor: cursor });
|
|
18
|
+
}
|
|
19
|
+
const input = await tool.validate(raw);
|
|
20
|
+
convert(input, tool.convert);
|
|
21
|
+
if (dryRun)
|
|
22
|
+
return dryRun();
|
|
23
|
+
return tool.run(getDb(), caller, input, handlers);
|
|
24
|
+
}
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { authorized, authorizeTarget } from "./authorization.js";
|
|
2
|
+
import { forwarded, isAdmin, ContractError, wire } from "./contracts.js";
|
|
3
|
+
import { checkOrigin, surfaceCaller, surfaceError } from "./surface-failure.js";
|
|
4
|
+
import { draining } from "./drain.js";
|
|
5
|
+
import { callToolLazy as callTool } from "./mcp-call.js";
|
|
6
|
+
import { RESOURCE_MIME_TYPE, linkSurface, resourcesOf } from "./mcp-apps.js";
|
|
7
|
+
const text = (value, locale) => {
|
|
8
|
+
if (typeof value === "string")
|
|
9
|
+
return value;
|
|
10
|
+
if (!value)
|
|
11
|
+
return;
|
|
12
|
+
return Object.hasOwn(value, locale) ? value[locale] : Object.hasOwn(value, "en") ? value.en : Object.values(value)[0];
|
|
13
|
+
};
|
|
14
|
+
function observe(listener, event) {
|
|
15
|
+
if (listener)
|
|
16
|
+
try {
|
|
17
|
+
void Promise.resolve(listener(event)).catch(() => { });
|
|
18
|
+
}
|
|
19
|
+
catch { }
|
|
20
|
+
}
|
|
21
|
+
const paging = (schema) => ({ ...schema, properties: { ...schema.properties, limit: { type: "integer", minimum: 1, maximum: 500 }, cursor: { type: "string" } } });
|
|
22
|
+
const MCP_PAGE_BUDGET = 60_000;
|
|
23
|
+
const union = (scopes, extra) => [...new Set([...scopes, ...extra])].join(" ");
|
|
24
|
+
export function handler(tools, options, apps = {}, reads = []) {
|
|
25
|
+
const allowed = options.allowedOrigins ?? [];
|
|
26
|
+
return draining(async (request, env, ctx) => {
|
|
27
|
+
const access = options.gateway ? (await import("./host-access.js")).accessRequest(ctx, options) : undefined;
|
|
28
|
+
let resolved;
|
|
29
|
+
try {
|
|
30
|
+
const requiredScopes = options.requiredScopes ?? ["mcp"], locale = options.locale ?? "en";
|
|
31
|
+
const url = new URL(request.url), path = url.pathname.replace(/\/+$/, ""), surface = path === "/mcp" ? "public" : path === "/mcp/admin" ? "admin" : undefined;
|
|
32
|
+
if (!surface)
|
|
33
|
+
return;
|
|
34
|
+
if (request.headers.has("origin")) {
|
|
35
|
+
const sdk = await import("@modelcontextprotocol/server");
|
|
36
|
+
const foreign = sdk.originValidationResponse(request, [...sdk.localhostAllowedOrigins(), ...allowed]);
|
|
37
|
+
if (foreign) {
|
|
38
|
+
access?.finish(new ContractError("AUTH_DENIED", "Origin is not allowed.", "request:origin"));
|
|
39
|
+
observe(options.onObservation, { kind: "request-refused", at: Date.now(), surface, status: 403 });
|
|
40
|
+
observe(options.onRefusal, { at: Date.now(), status: 403, reason: "origin" });
|
|
41
|
+
return foreign;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const select = async () => (typeof tools === "function" ? await tools(request, env) : tools).filter(tool => tool.surface === surface);
|
|
45
|
+
let selected = surface === "public" ? await select() : [];
|
|
46
|
+
let parsedBody, tooLarge = false;
|
|
47
|
+
const cookieOnly = request.headers.has("cookie") && !request.headers.has("authorization");
|
|
48
|
+
const parse = async () => {
|
|
49
|
+
if (options.gateway) {
|
|
50
|
+
try {
|
|
51
|
+
const raw = await (await import("./json-body.js")).bytes(request, 1024 * 1024, () => { tooLarge = true; throw new Error("Body limit"); });
|
|
52
|
+
parsedBody = JSON.parse(new TextDecoder().decode(raw));
|
|
53
|
+
}
|
|
54
|
+
catch { }
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const { readRequestBody } = await import("@modelcontextprotocol/server");
|
|
58
|
+
try {
|
|
59
|
+
const body = await readRequestBody(request.clone(), 1024 * 1024);
|
|
60
|
+
tooLarge = body.tooLarge;
|
|
61
|
+
if (!body.tooLarge)
|
|
62
|
+
parsedBody = JSON.parse(body.text);
|
|
63
|
+
}
|
|
64
|
+
catch { }
|
|
65
|
+
};
|
|
66
|
+
if (request.method === "POST" && (cookieOnly || options.gateway))
|
|
67
|
+
await parse();
|
|
68
|
+
const messages = Array.isArray(parsedBody) ? parsedBody : [parsedBody];
|
|
69
|
+
const readOnly = request.method === "POST" && messages.length > 0 && messages.every(message => {
|
|
70
|
+
if (!isRecord(message) || message.jsonrpc !== "2.0" || typeof message.method !== "string")
|
|
71
|
+
return false;
|
|
72
|
+
if (["initialize", "tools/list", "resources/list", "resources/read"].includes(message.method))
|
|
73
|
+
return true;
|
|
74
|
+
if (message.method !== "tools/call")
|
|
75
|
+
return false;
|
|
76
|
+
const name = isRecord(message.params) ? message.params.name : undefined;
|
|
77
|
+
return reads.some(tool => tool.surface === surface && tool.name === name);
|
|
78
|
+
});
|
|
79
|
+
const challenge = async (error, scope, bare = false) => {
|
|
80
|
+
access?.finish(error);
|
|
81
|
+
const result = wire(error);
|
|
82
|
+
if (result.status === 401 || result.status === 403) {
|
|
83
|
+
observe(options.onObservation, { kind: "request-refused", at: Date.now(), surface, status: result.status });
|
|
84
|
+
observe(options.onRefusal, { at: Date.now(), status: result.status, reason: "credential" });
|
|
85
|
+
}
|
|
86
|
+
if (result.status === 401)
|
|
87
|
+
scope = union(scope === undefined ? requiredScopes : scope.split(" "), options.authorizationScopes ?? []);
|
|
88
|
+
return (await import("./host-caller.js")).hostFailure(error, resolved, `mcp ${path}`, bare ? undefined : 'Bearer ' + (scope ? (result.status === 403 ? 'error="insufficient_scope", ' : '') + 'scope="' + scope + '", ' : '') + 'resource_metadata="' + (options.resourceMetadata ?? url.origin + '/.well-known/oauth-protected-resource/mcp') + '"');
|
|
89
|
+
};
|
|
90
|
+
let caller;
|
|
91
|
+
try {
|
|
92
|
+
const requested = isRecord(parsedBody) && isRecord(parsedBody.params) ? parsedBody.params.name : undefined;
|
|
93
|
+
const requestedTool = selected.find(t => t.name === requested) ?? (typeof tools === "function" ? undefined : tools.find(t => t.surface === surface && t.name === requested));
|
|
94
|
+
await access?.select(requestedTool?.target ? `${requestedTool.target.kind}:${requestedTool.target.name}` : typeof requested === "string" ? `mcp:${requested}` : "mcp");
|
|
95
|
+
caller = resolved = forwarded(ctx, options.gateway)
|
|
96
|
+
? (await import("./host-caller.js")).gatewayCaller(ctx, options.gateway, options.fields)
|
|
97
|
+
: await surfaceCaller(request, env, options.caller ?? (() => ({ kind: "anonymous" })), readOnly);
|
|
98
|
+
await access?.select(requestedTool?.target ? `${requestedTool.target.kind}:${requestedTool.target.name}` : "target" in caller && caller.target ? caller.target : "mcp", caller);
|
|
99
|
+
if (caller.kind === "anonymous" && (surface === "admin" || selected.length > 0 && selected.every(tool => tool.closed)))
|
|
100
|
+
throw new ContractError("UNAUTHENTICATED", "Authentication is required.", "mcp");
|
|
101
|
+
if (caller.kind === "system")
|
|
102
|
+
return challenge(new ContractError("AUTH_DENIED", "System callers cannot use MCP.", "mcp"), undefined, true);
|
|
103
|
+
if (surface === "admin" && !isAdmin(caller))
|
|
104
|
+
return challenge(new ContractError("AUTH_DENIED", "Admin role is required.", "mcp/admin"), undefined, true);
|
|
105
|
+
if (!options.gateway && caller.kind === "user" && caller.credential !== "session" && requiredScopes.some(scope => !caller.scopes.includes(scope)))
|
|
106
|
+
return challenge(new ContractError("AUTH_DENIED", "The credential needs the required MCP scopes.", "mcp"), union(caller.scopes, requiredScopes));
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
return challenge(error);
|
|
110
|
+
}
|
|
111
|
+
if (surface === "admin")
|
|
112
|
+
selected = await select();
|
|
113
|
+
const version = catalogueVersion(selected);
|
|
114
|
+
const { McpServer, ProtocolError, ProtocolErrorCode, createMcpHandler, fromJsonSchema } = await import("@modelcontextprotocol/server");
|
|
115
|
+
if (request.method === "POST" && !cookieOnly && !options.gateway)
|
|
116
|
+
await parse();
|
|
117
|
+
if (tooLarge && access)
|
|
118
|
+
return challenge(new ContractError("INPUT_VALIDATION_FAILED", "MCP body exceeds its limit.", "mcp"), undefined, true);
|
|
119
|
+
if (tooLarge)
|
|
120
|
+
return Response.json({ jsonrpc: "2.0", id: null, error: { code: -32000, message: "Request body exceeds 1048576 bytes." } }, { status: 413 });
|
|
121
|
+
const host = options.gateway && (await import("./host-caller.js")).isHostCaller(caller);
|
|
122
|
+
if (host) {
|
|
123
|
+
try {
|
|
124
|
+
if (Array.isArray(parsedBody))
|
|
125
|
+
throw new ContractError("INPUT_VALIDATION_FAILED", "Host calls cannot batch MCP messages.", "mcp");
|
|
126
|
+
if (isRecord(parsedBody) && typeof parsedBody.method === "string" && !["initialize", "tools/call"].includes(parsedBody.method))
|
|
127
|
+
throw new ContractError("AUTH_DENIED", "Host callers may only initialize or call a tool.", "mcp", { status: 403 });
|
|
128
|
+
if (isRecord(parsedBody) && parsedBody.method === "initialize") {
|
|
129
|
+
const pinned = "target" in caller ? caller.target : undefined;
|
|
130
|
+
if (pinned && !selected.some(tool => (tool.target ? `${tool.target.kind}:${tool.target.name}` : `admin:tool:${tool.name}`) === pinned))
|
|
131
|
+
throw new ContractError("TARGET_MISMATCH", "Initialize must pin a mounted tool.", pinned, { status: 412 });
|
|
132
|
+
await access?.select(pinned ?? "mcp", caller);
|
|
133
|
+
await access?.check(true);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
const params = isRecord(parsedBody) && isRecord(parsedBody.params) ? parsedBody.params : undefined;
|
|
137
|
+
const tool = selected.find(t => t.name === params?.name);
|
|
138
|
+
if (tool) {
|
|
139
|
+
await access?.select(tool.target ? `${tool.target.kind}:${tool.target.name}` : `admin:tool:${tool.name}`, caller);
|
|
140
|
+
await access?.check(!!tool.page || tool.readOnly === true);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
return challenge(error, undefined, true);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (request.method === "POST") {
|
|
149
|
+
for (const message of Array.isArray(parsedBody) ? parsedBody : [parsedBody]) {
|
|
150
|
+
if (!message || message.method !== "tools/call")
|
|
151
|
+
continue;
|
|
152
|
+
const tool = selected.find(tool => tool.name === message.params?.name);
|
|
153
|
+
if (!tool)
|
|
154
|
+
continue;
|
|
155
|
+
const scopes = tool.scopes ?? [];
|
|
156
|
+
if (caller.kind === "anonymous" && tool.closed)
|
|
157
|
+
return challenge(new ContractError("UNAUTHENTICATED", "Authentication is required.", "mcp"), union(requiredScopes, scopes));
|
|
158
|
+
if (!options.gateway && caller.kind === "user" && caller.credential === "oauth" && scopes.some(scope => !caller.scopes.includes(scope)))
|
|
159
|
+
return challenge(new ContractError("AUTH_DENIED", "The credential needs additional scopes.", "mcp"), union(caller.scopes, scopes));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const app = options.apps?.[surface];
|
|
163
|
+
let links;
|
|
164
|
+
if (app) {
|
|
165
|
+
const sources = (Array.isArray(app) ? app : [app]);
|
|
166
|
+
const dynamic = sources.some(source => typeof source === "function");
|
|
167
|
+
const resolved = resourcesOf(await Promise.all(sources.map(source => typeof source === "function" ? source({ env, request }) : source)));
|
|
168
|
+
const current = linkSurface(resolved, selected, dynamic ? undefined : apps[surface]);
|
|
169
|
+
if (!dynamic)
|
|
170
|
+
apps[surface] = current;
|
|
171
|
+
links = current.links;
|
|
172
|
+
}
|
|
173
|
+
if (options.authorize) {
|
|
174
|
+
try {
|
|
175
|
+
for (const message of Array.isArray(parsedBody) ? parsedBody : [parsedBody]) {
|
|
176
|
+
if (message?.method !== "tools/call")
|
|
177
|
+
continue;
|
|
178
|
+
const tool = selected.find(tool => tool.name === message.params?.name);
|
|
179
|
+
if (!tool)
|
|
180
|
+
continue;
|
|
181
|
+
tool.check?.(caller);
|
|
182
|
+
await authorizeTarget(options.authorize, tool.target ?? { kind: tool.page ? "view" : "procedure", name: tool.name }, caller);
|
|
183
|
+
}
|
|
184
|
+
if ((Array.isArray(parsedBody) ? parsedBody : [parsedBody]).some(message => message?.method === "tools/list" || message?.method === "resources/read")) {
|
|
185
|
+
const visible = [];
|
|
186
|
+
for (const tool of selected) {
|
|
187
|
+
if (caller.kind === "anonymous" && tool.closed || !options.gateway && caller.kind === "user" && caller.credential === "oauth" && tool.scopes?.some(scope => !caller.scopes.includes(scope)))
|
|
188
|
+
continue;
|
|
189
|
+
try {
|
|
190
|
+
tool.check?.(caller);
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
if (error instanceof ContractError && ["AUTH_DENIED", "UNAUTHENTICATED"].includes(error.code))
|
|
194
|
+
continue;
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
if (await authorized(options.authorize, tool.target ?? { kind: tool.page ? "view" : "procedure", name: tool.name }, caller))
|
|
198
|
+
visible.push(tool);
|
|
199
|
+
}
|
|
200
|
+
selected = visible;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
return challenge(error);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const serverInfo = { name: "aotter.mantle", ...options.serverInfo, version: options.serverInfo?.version ?? version };
|
|
208
|
+
const handler = createMcpHandler(() => {
|
|
209
|
+
const schema = (value) => fromJsonSchema(value, { getValidator() { return (input) => ({ valid: true, data: input, errorMessage: undefined }); } });
|
|
210
|
+
const server = new McpServer(serverInfo, options.instructions ? { instructions: options.instructions } : {});
|
|
211
|
+
server.server.registerCapabilities({ tools: { listChanged: false } });
|
|
212
|
+
if (host)
|
|
213
|
+
server.server.onclose = () => access?.finish(isRecord(parsedBody) && parsedBody.method === "initialize" ? undefined : new ContractError("INPUT_VALIDATION_FAILED", "MCP request refused.", "mcp", { status: 400 }));
|
|
214
|
+
const appMeta = links ? registerApps(server, links, parsedBody, new Set(selected.map(tool => tool.name)), { env, request }) : undefined;
|
|
215
|
+
const registered = new Set(), set = server.server.setRequestHandler.bind(server.server);
|
|
216
|
+
server.server.setRequestHandler = ((method, handler) => set(method, method === "tools/call" && typeof handler === "function" ? (request, context) => {
|
|
217
|
+
if (!registered.has(request.params.name))
|
|
218
|
+
throw new ProtocolError(ProtocolErrorCode.InvalidParams, `No tool named ${JSON.stringify(request.params.name)} exists in the current catalogue (catalogue version ${serverInfo.version}).`);
|
|
219
|
+
return handler(request, context);
|
|
220
|
+
} : handler));
|
|
221
|
+
for (const tool of selected) {
|
|
222
|
+
const meta = appMeta?.(tool.name);
|
|
223
|
+
if (meta === false)
|
|
224
|
+
continue;
|
|
225
|
+
registered.add(tool.name);
|
|
226
|
+
const about = (contract) => { const text = [tool.version && `tool version ${tool.version}`, contract && `input schema ${JSON.stringify(tool.page ? paging(tool.inputSchema) : tool.inputSchema)}`].filter(Boolean).join("; "); return text ? [{ type: "text", text }] : []; };
|
|
227
|
+
server.registerTool(tool.name, { ...(meta ? { _meta: meta } : {}), ...(tool.title ? { title: text(tool.title, locale) } : {}), description: text(tool.description, locale) ?? text(tool.title, locale) ?? tool.name, inputSchema: schema(tool.page ? paging(tool.inputSchema) : tool.inputSchema), ...(tool.outputSchema ? { outputSchema: schema(tool.outputSchema) } : {}), ...(tool.annotations ? { annotations: tool.annotations } : {}) }, async (raw) => {
|
|
228
|
+
const metadata = options.onObservation ? { kind: "invocation", surface, invocationId: crypto.randomUUID(), tool: tool.name, caller: Object.freeze(caller.kind === "user" ? { ...caller, scopes: Object.freeze([...caller.scopes]) } : { ...caller }) } : undefined;
|
|
229
|
+
const started = metadata ? performance.now() : 0;
|
|
230
|
+
if (metadata)
|
|
231
|
+
observe(options.onObservation, { ...metadata, phase: "attempt", at: Date.now() });
|
|
232
|
+
let outcome = "succeeded", code;
|
|
233
|
+
try {
|
|
234
|
+
if (host)
|
|
235
|
+
tool.check?.(caller);
|
|
236
|
+
if (tool.run && (!host || !tool.readOnly))
|
|
237
|
+
checkOrigin(request, caller);
|
|
238
|
+
let db;
|
|
239
|
+
const run = (input) => callTool(tool, input, () => db ??= options.db(env), caller, options.handlers, access?.dryRun ? () => ({ dryRun: true, event: access.finish() }) : undefined);
|
|
240
|
+
let data = await run(raw);
|
|
241
|
+
for (let tries = 0; tool.page && isRecord(data) && Array.isArray(data.rows); tries++) {
|
|
242
|
+
const rows = data.rows, total = JSON.stringify(data).length;
|
|
243
|
+
if (total <= MCP_PAGE_BUDGET)
|
|
244
|
+
break;
|
|
245
|
+
if (rows.length === 1 || tries === 4)
|
|
246
|
+
break;
|
|
247
|
+
const sizes = rows.map(row => JSON.stringify(row).length);
|
|
248
|
+
let size = total - sizes.reduce((sum, n) => sum + n, 0) - (rows.length - 1), fit = 0;
|
|
249
|
+
for (const n of sizes) {
|
|
250
|
+
size += n + (fit ? 1 : 0);
|
|
251
|
+
if (size > MCP_PAGE_BUDGET)
|
|
252
|
+
break;
|
|
253
|
+
fit++;
|
|
254
|
+
}
|
|
255
|
+
const cut = await run({ ...raw, limit: Math.max(1, fit) }).catch(() => undefined);
|
|
256
|
+
if (cut === undefined)
|
|
257
|
+
break;
|
|
258
|
+
data = cut;
|
|
259
|
+
}
|
|
260
|
+
if (host)
|
|
261
|
+
access?.finish();
|
|
262
|
+
const text = JSON.stringify(data), notice = tool.page && text.length > MCP_PAGE_BUDGET;
|
|
263
|
+
return { ...(meta ? { _meta: { "net.aotter.mantle/tool": tool.name } } : {}), content: [{ type: "text", text }, ...about(false), ...(notice ? [{ type: "text", text: `This page is larger than the ${MCP_PAGE_BUDGET}-character page size budget (a single row over it, or a View without an order, is returned whole), so a host may truncate it. Continue with nextCursor, if any.` }] : [])], ...(data && typeof data === "object" && !Array.isArray(data) ? { structuredContent: data } : {}) };
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
if (host)
|
|
267
|
+
access?.finish(error);
|
|
268
|
+
const diagnostic = host ? (await (await import("./host-caller.js")).hostFailure(error, caller, `mcp ${tool.name}`).json()).error : surfaceError(error, `mcp ${tool.name}`).error;
|
|
269
|
+
code = diagnostic.code;
|
|
270
|
+
outcome = code === "AUTH_DENIED" || code === "UNAUTHENTICATED" ? "denied" : "failed";
|
|
271
|
+
if (diagnostic.path === "request:origin")
|
|
272
|
+
observe(options.onRefusal, { at: Date.now(), status: 403, reason: "origin" });
|
|
273
|
+
const payload = { diagnostics: [diagnostic] };
|
|
274
|
+
return { ...(meta ? { _meta: { "net.aotter.mantle/tool": tool.name } } : {}), isError: true, content: [{ type: "text", text: JSON.stringify(payload) }, ...about(outcome === "failed")], ...(tool.outputSchema ? {} : { structuredContent: payload }) };
|
|
275
|
+
}
|
|
276
|
+
finally {
|
|
277
|
+
if (metadata)
|
|
278
|
+
observe(options.onObservation, { ...metadata, phase: "completion", at: Date.now(), outcome, durationMs: Math.max(0, performance.now() - started), ...(code ? { code } : {}) });
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
if (registered.size === 0) {
|
|
283
|
+
server.server.setRequestHandler("tools/list", () => ({ tools: [] }));
|
|
284
|
+
server.server.setRequestHandler("tools/call", () => ({ content: [] }));
|
|
285
|
+
}
|
|
286
|
+
return server;
|
|
287
|
+
}, { legacy: "stateless", maxRequestBodySize: 1024 * 1024, onerror: error => console.error("[mantle mcp] request failed", error) });
|
|
288
|
+
const response = await handler.fetch(request, { parsedBody });
|
|
289
|
+
if (host) {
|
|
290
|
+
if (response.status >= 400)
|
|
291
|
+
access?.finish(new ContractError("INPUT_VALIDATION_FAILED", "MCP request refused.", "mcp", { status: response.status }));
|
|
292
|
+
}
|
|
293
|
+
return response;
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
access?.finish(error);
|
|
297
|
+
return (await import("./host-caller.js")).hostFailure(error, resolved, "mcp");
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function catalogueVersion(tools) {
|
|
302
|
+
const text = JSON.stringify(tools.map(tool => `${tool.surface}:${tool.name}:${tool.version ?? ""}`).sort());
|
|
303
|
+
return [...text].reduce((h, c) => Math.imul(h ^ c.codePointAt(0), 16777619) >>> 0, 2166136261).toString(16).padStart(8, "0");
|
|
304
|
+
}
|
|
305
|
+
const CLIENT_CAPABILITIES_META_KEY = "io.modelcontextprotocol/clientCapabilities";
|
|
306
|
+
const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
307
|
+
function clientUiSupport(message) {
|
|
308
|
+
for (const m of Array.isArray(message) ? message : [message]) {
|
|
309
|
+
if (!isRecord(m) || !isRecord(m.params))
|
|
310
|
+
continue;
|
|
311
|
+
const meta = m.params._meta;
|
|
312
|
+
const declared = isRecord(meta) && isRecord(meta[CLIENT_CAPABILITIES_META_KEY]) ? meta[CLIENT_CAPABILITIES_META_KEY] : m.method === "initialize" && isRecord(m.params.capabilities) ? m.params.capabilities : undefined;
|
|
313
|
+
if (!declared)
|
|
314
|
+
continue;
|
|
315
|
+
const extensions = declared.extensions, ui = isRecord(extensions) ? extensions["io.modelcontextprotocol/ui"] : undefined;
|
|
316
|
+
return isRecord(ui) && Array.isArray(ui.mimeTypes) && ui.mimeTypes.includes(RESOURCE_MIME_TYPE) ? "supported" : "unsupported";
|
|
317
|
+
}
|
|
318
|
+
return "unknown";
|
|
319
|
+
}
|
|
320
|
+
function appMeta(r, csp = r.csp) {
|
|
321
|
+
const ui = { ...(csp ? { csp } : {}), ...(r.permissions ? { permissions: r.permissions } : {}), ...(r.domain !== undefined ? { domain: r.domain } : {}), ...(r.prefersBorder !== undefined ? { prefersBorder: r.prefersBorder } : {}) };
|
|
322
|
+
return Object.keys(ui).length > 0 ? { ui } : undefined;
|
|
323
|
+
}
|
|
324
|
+
function registerApps(server, links, message, tools, request) {
|
|
325
|
+
const enabled = clientUiSupport(message) !== "unsupported";
|
|
326
|
+
if (enabled)
|
|
327
|
+
for (const resource of links.resources) {
|
|
328
|
+
const meta = appMeta(resource);
|
|
329
|
+
server.registerResource(resource.name, resource.uri, { mimeType: RESOURCE_MIME_TYPE, title: resource.title, description: resource.description, ...(meta ? { _meta: meta } : {}) }, async () => {
|
|
330
|
+
try {
|
|
331
|
+
const loaded = typeof resource.html === "string" ? resource.html : await resource.html({ tools, ...request });
|
|
332
|
+
const page = typeof loaded === "string" ? { html: loaded } : loaded, read = page.csp ? appMeta(resource, page.csp) : meta;
|
|
333
|
+
return { contents: [{ uri: resource.uri, mimeType: RESOURCE_MIME_TYPE, text: page.html, ...(read ? { _meta: read } : {}) }] };
|
|
334
|
+
}
|
|
335
|
+
catch (error) {
|
|
336
|
+
console.error("[mantle mcp] resource rendering failed:", error instanceof Error ? error.message : String(error));
|
|
337
|
+
throw new Error("Internal error.");
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
return (tool) => {
|
|
342
|
+
if (!enabled)
|
|
343
|
+
return links.appOnly.has(tool) ? false : undefined;
|
|
344
|
+
const uri = links.renders.get(tool);
|
|
345
|
+
return uri ? { ui: { resourceUri: uri, ...(links.appOnly.has(tool) ? { visibility: ["app"] } : {}) }, "ui/resourceUri": uri, ...(links.appOnly.has(tool) ? {} : { "openai/outputTemplate": uri }) } : undefined;
|
|
346
|
+
};
|
|
347
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/** MCP request handling for a generated tool table; the official SDK loads on the first MCP request. */
|
|
2
|
+
import type { Caller, Target, Authorize, Gateway, RequestContext, GatewayOptions } from "./contracts.js";
|
|
3
|
+
import type { Conversions } from "./surface.js";
|
|
4
|
+
import { type McpAppsSource } from "./mcp-apps.js";
|
|
5
|
+
type Call = typeof import("./mcp-call.js");
|
|
6
|
+
export declare const callTool: Call["callTool"];
|
|
7
|
+
export declare const callToolLazy: Call["callToolLazy"];
|
|
8
|
+
export type { McpApps, McpAppsSource, McpAppResource, McpAppRender, McpAppPage, McpAppCsp } from "./mcp-apps.js";
|
|
9
|
+
/** Options of a generated `mcp(...)`; it adds required `handlers` when the app declares ref Procedures. */
|
|
10
|
+
export interface Options<Env, Database> extends GatewayOptions {
|
|
11
|
+
apps?: Readonly<Partial<Record<"public" | "admin", McpAppsSource | readonly McpAppsSource[]>>>;
|
|
12
|
+
authorize?: Authorize;
|
|
13
|
+
gateway?: Gateway;
|
|
14
|
+
fields?: import("./user-fields.js").UserFields;
|
|
15
|
+
db: (env: Env) => Database;
|
|
16
|
+
caller?: (request: Request, env: Env, authority: {
|
|
17
|
+
readonly readOnly: boolean;
|
|
18
|
+
}) => Caller | Promise<Caller>;
|
|
19
|
+
locale?: string;
|
|
20
|
+
instructions?: string;
|
|
21
|
+
serverInfo?: {
|
|
22
|
+
name?: string;
|
|
23
|
+
title?: string;
|
|
24
|
+
version?: string;
|
|
25
|
+
icons?: {
|
|
26
|
+
src: string;
|
|
27
|
+
mimeType?: string;
|
|
28
|
+
sizes?: string[];
|
|
29
|
+
theme?: "light" | "dark";
|
|
30
|
+
}[];
|
|
31
|
+
};
|
|
32
|
+
requiredScopes?: readonly string[];
|
|
33
|
+
/** Additional scopes requested by an unauthenticated OAuth challenge (for example offline_access), not an API scope floor. */
|
|
34
|
+
authorizationScopes?: readonly string[];
|
|
35
|
+
resourceMetadata?: string;
|
|
36
|
+
/** Browser origins MCP answers besides loopback, compared by hostname: `https://console.example` or the official SDK's bare `console.example`. The site's own origin is not implied. */
|
|
37
|
+
allowedOrigins?: readonly string[];
|
|
38
|
+
onObservation?: (event: McpObservation) => void | Promise<void>;
|
|
39
|
+
onRefusal?: (event: CallerRefusal) => void | Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export interface CallerRefusal {
|
|
42
|
+
readonly at: number;
|
|
43
|
+
readonly status: 401 | 403;
|
|
44
|
+
readonly reason: "origin" | "credential";
|
|
45
|
+
}
|
|
46
|
+
export type McpObservation = {
|
|
47
|
+
readonly kind: "request-refused";
|
|
48
|
+
readonly at: number;
|
|
49
|
+
readonly surface: "public" | "admin";
|
|
50
|
+
readonly status: 401 | 403;
|
|
51
|
+
} | {
|
|
52
|
+
readonly kind: "invocation";
|
|
53
|
+
readonly at: number;
|
|
54
|
+
readonly surface: "public" | "admin";
|
|
55
|
+
readonly invocationId: string;
|
|
56
|
+
readonly tool: string;
|
|
57
|
+
readonly caller: Caller;
|
|
58
|
+
} & ({
|
|
59
|
+
readonly phase: "attempt";
|
|
60
|
+
} | {
|
|
61
|
+
readonly phase: "completion";
|
|
62
|
+
readonly outcome: "succeeded" | "failed" | "denied";
|
|
63
|
+
readonly durationMs: number;
|
|
64
|
+
readonly code?: string;
|
|
65
|
+
});
|
|
66
|
+
type LocalizedText = string | Readonly<Record<string, string>>;
|
|
67
|
+
type Paging = {
|
|
68
|
+
limit?: number;
|
|
69
|
+
cursor?: string;
|
|
70
|
+
};
|
|
71
|
+
/** One tool: a paged View (`page`) or a Procedure (`run`, a write), on the public or admin surface. */
|
|
72
|
+
export interface Tool<Database, Handlers = never> {
|
|
73
|
+
readonly readOnly?: boolean;
|
|
74
|
+
readonly name: string;
|
|
75
|
+
readonly target?: Target;
|
|
76
|
+
/** Generated requires guard, used before application authorization. */
|
|
77
|
+
readonly check?: (caller: Caller) => void;
|
|
78
|
+
readonly surface: string;
|
|
79
|
+
readonly title?: LocalizedText;
|
|
80
|
+
readonly description: LocalizedText;
|
|
81
|
+
readonly outputSchema?: unknown;
|
|
82
|
+
readonly annotations?: {
|
|
83
|
+
readonly readOnlyHint?: boolean;
|
|
84
|
+
readonly destructiveHint?: boolean;
|
|
85
|
+
readonly openWorldHint?: boolean;
|
|
86
|
+
readonly idempotentHint?: boolean;
|
|
87
|
+
};
|
|
88
|
+
readonly inputSchema: unknown;
|
|
89
|
+
/** The listed definition's version; results carry it so a model holding an older definition can tell. */
|
|
90
|
+
readonly version?: string;
|
|
91
|
+
/** Declares an auth requirement: anonymous callers are challenged. */
|
|
92
|
+
readonly closed?: boolean;
|
|
93
|
+
/** OAuth scopes the requirement names. */
|
|
94
|
+
readonly scopes?: readonly string[];
|
|
95
|
+
readonly validate: (raw: unknown) => Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
96
|
+
readonly convert?: Conversions;
|
|
97
|
+
/** A View tool: its operation path and paged boundary. */
|
|
98
|
+
readonly path?: string;
|
|
99
|
+
readonly page?: (db: Database, caller: Caller, input: never, paging: Paging) => Promise<unknown>;
|
|
100
|
+
readonly run?: (db: Database, caller: Caller, input: never, handlers: Handlers) => Promise<unknown>;
|
|
101
|
+
}
|
|
102
|
+
/** Request-bound tool tables keep native environment bindings outside the cached App catalogue. */
|
|
103
|
+
export type Tools<Env, Database, Handlers = never> = readonly Tool<Database, Handlers>[] | ((request: Request, env: Env) => readonly Tool<Database, Handlers>[] | Promise<readonly Tool<Database, Handlers>[]>);
|
|
104
|
+
/** The selected MCP routes; all request work loads only when an MCP request arrives. */
|
|
105
|
+
export declare function mcp<Env, Database, Handlers = never>(tools: Tools<Env, Database, Handlers>, options: Options<Env, Database> & {
|
|
106
|
+
handlers?: Handlers;
|
|
107
|
+
}, reads?: readonly {
|
|
108
|
+
readonly name: string;
|
|
109
|
+
readonly surface: string;
|
|
110
|
+
}[]): (request: Request, env: Env, ctx?: RequestContext) => Promise<Response | undefined>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { linkApps, linkSurface, resourcesOf } from "./mcp-apps.js";
|
|
2
|
+
export const callTool = async (...args) => (await import("./mcp-call.js")).callTool(...args);
|
|
3
|
+
export const callToolLazy = async (...args) => (await import("./mcp-call.js")).callToolLazy(...args);
|
|
4
|
+
export function mcp(tools, options, reads = []) {
|
|
5
|
+
let serve;
|
|
6
|
+
const linked = {};
|
|
7
|
+
const apps = {};
|
|
8
|
+
for (const surface of ["public", "admin"]) {
|
|
9
|
+
const declared = options.apps?.[surface];
|
|
10
|
+
if (declared) {
|
|
11
|
+
const sources = (Array.isArray(declared) ? declared : [declared])
|
|
12
|
+
.map(source => typeof source === "function" ? source : resourcesOf(source));
|
|
13
|
+
const fixed = resourcesOf(sources.filter(source => typeof source !== "function"));
|
|
14
|
+
const dynamic = sources.some(source => typeof source === "function");
|
|
15
|
+
apps[surface] = dynamic ? sources : fixed;
|
|
16
|
+
if (typeof tools === "function")
|
|
17
|
+
linkApps(fixed);
|
|
18
|
+
else {
|
|
19
|
+
const current = linkSurface(fixed, tools.filter(tool => tool.surface === surface));
|
|
20
|
+
if (!dynamic)
|
|
21
|
+
linked[surface] = current;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
options = { ...options, apps, allowedOrigins: originHostnames(options.allowedOrigins) };
|
|
26
|
+
return async (request, env, ctx) => {
|
|
27
|
+
if (!/^\/mcp(?:\/admin)?\/*$/.test(new URL(request.url).pathname))
|
|
28
|
+
return;
|
|
29
|
+
const { handler } = await import("./mcp-handler.js");
|
|
30
|
+
serve ??= handler(tools, options, linked, reads);
|
|
31
|
+
return serve(request, env, ctx);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function originHostnames(origins = []) {
|
|
35
|
+
return Object.freeze(origins.map(origin => {
|
|
36
|
+
let url;
|
|
37
|
+
try {
|
|
38
|
+
url = new URL(/^[a-z][a-z\d+.-]*:\/\//i.test(origin) ? origin : `http://${origin}`);
|
|
39
|
+
}
|
|
40
|
+
catch { }
|
|
41
|
+
if (origin.includes("*") || !url?.hostname || url.username || url.password || url.pathname !== "/" || url.search || url.hash)
|
|
42
|
+
throw new TypeError(`mcp allowedOrigins: "${origin}" is not an origin (https://host[:port]) or a host[:port]; wildcards never match.`);
|
|
43
|
+
return url.hostname;
|
|
44
|
+
}));
|
|
45
|
+
}
|