@aotter/mantle 0.1.5-alpha.1 → 0.2.0-alpha.10

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.
Files changed (495) hide show
  1. package/README.md +166 -298
  2. package/dist/auth/adapter.d.ts +32 -0
  3. package/dist/auth/adapter.js +288 -0
  4. package/dist/auth/admin.d.ts +3 -0
  5. package/dist/auth/admin.js +21 -0
  6. package/dist/auth/caller.d.ts +86 -0
  7. package/dist/auth/caller.js +155 -0
  8. package/dist/auth/hardening.d.ts +24 -0
  9. package/dist/auth/hardening.js +40 -0
  10. package/dist/auth/identity.d.ts +121 -0
  11. package/dist/auth/identity.js +203 -0
  12. package/dist/auth/oauth.d.ts +63 -0
  13. package/dist/auth/oauth.js +217 -0
  14. package/dist/auth/resource-seeds.js +10 -0
  15. package/dist/auth/routes.d.ts +32 -0
  16. package/dist/auth/routes.js +226 -0
  17. package/dist/build/compiler.d.ts +721 -0
  18. package/dist/build/compiler.js +7029 -0
  19. package/dist/build/spec/domain/model/ManifestGrammar.d.ts +439 -0
  20. package/dist/build/spec/domain/model/RuntimePlan.d.ts +168 -0
  21. package/dist/build/spec/domain/model/SqlIr.d.ts +129 -0
  22. package/dist/build/spec/domain/model/UserFields.d.ts +21 -0
  23. package/dist/build/spec/domain/service/PlanFingerprint.d.ts +7 -0
  24. package/dist/build/spec/kernel/diagnostic.d.ts +108 -0
  25. package/dist/bun/assets.d.ts +2 -0
  26. package/dist/bun/assets.js +24 -0
  27. package/dist/domain/adminOrder.js +24 -0
  28. package/dist/domain/columns.js +57 -0
  29. package/dist/domain/describe/chunk-ZVXBGP7Y.js +424 -0
  30. package/dist/domain/describe/index.d.ts +58 -0
  31. package/dist/domain/describe/index.js +115 -0
  32. package/dist/domain/describe/target-hash.d.ts +8 -0
  33. package/dist/domain/describe/target-hash.js +12 -0
  34. package/dist/domain/describe/targets.d.ts +40 -0
  35. package/dist/domain/entry.js +33 -0
  36. package/dist/domain/generated-tools.js +19 -0
  37. package/dist/domain/generation.d.ts +16 -0
  38. package/dist/domain/generation.js +1 -0
  39. package/dist/domain/input.js +17 -0
  40. package/dist/domain/model.js +1 -0
  41. package/dist/domain/paging.js +230 -0
  42. package/dist/domain/recipes.js +24 -0
  43. package/dist/domain/userReferences.js +5 -0
  44. package/dist/domain/wireScalars.js +47 -0
  45. package/dist/infrastructure/adminEntries.js +153 -0
  46. package/dist/infrastructure/adminPaging.js +72 -0
  47. package/dist/infrastructure/artifacts.js +71 -0
  48. package/dist/infrastructure/authSchema.js +83 -0
  49. package/dist/infrastructure/bundle.js +188 -0
  50. package/dist/infrastructure/cli.js +118 -0
  51. package/dist/infrastructure/generate.d.ts +12 -0
  52. package/dist/infrastructure/generate.js +189 -0
  53. package/dist/infrastructure/generateAuth.d.ts +8 -0
  54. package/dist/infrastructure/generateAuth.js +74 -0
  55. package/dist/infrastructure/help.js +60 -0
  56. package/dist/infrastructure/init.js +54 -0
  57. package/dist/infrastructure/inputs.js +41 -0
  58. package/dist/infrastructure/mounts.js +25 -0
  59. package/dist/infrastructure/wrangler.js +109 -0
  60. package/dist/kernel/authorization.d.ts +4 -0
  61. package/dist/kernel/authorization.js +16 -0
  62. package/dist/kernel/binds.d.ts +60 -0
  63. package/dist/kernel/binds.js +49 -0
  64. package/dist/kernel/caller-identity.d.ts +24 -0
  65. package/dist/kernel/caller-identity.js +22 -0
  66. package/dist/kernel/contract-error.d.ts +12 -0
  67. package/dist/kernel/contract-error.js +14 -0
  68. package/dist/kernel/contracts.d.ts +143 -0
  69. package/dist/kernel/contracts.js +97 -0
  70. package/dist/kernel/cron.d.ts +1 -0
  71. package/dist/kernel/cron.js +58 -0
  72. package/dist/kernel/dialect/common.d.ts +38 -0
  73. package/dist/kernel/dialect/common.js +6 -0
  74. package/dist/kernel/dialect/postgres.d.ts +16 -0
  75. package/dist/kernel/dialect/postgres.js +18 -0
  76. package/dist/kernel/dialect/sqlite.d.ts +20 -0
  77. package/dist/kernel/dialect/sqlite.js +34 -0
  78. package/dist/kernel/drain.d.ts +5 -0
  79. package/dist/kernel/drain.js +35 -0
  80. package/dist/kernel/driver/bun-sqlite.d.ts +19 -0
  81. package/dist/kernel/driver/bun-sqlite.js +77 -0
  82. package/dist/kernel/driver/d1.d.ts +24 -0
  83. package/dist/kernel/driver/d1.js +22 -0
  84. package/dist/kernel/driver/postgres.d.ts +25 -0
  85. package/dist/kernel/driver/postgres.js +99 -0
  86. package/dist/kernel/driver/transaction-context.d.ts +10 -0
  87. package/dist/kernel/driver/transaction-context.js +29 -0
  88. package/dist/kernel/email.d.ts +28 -0
  89. package/dist/kernel/email.js +38 -0
  90. package/dist/kernel/host-access.d.ts +10 -0
  91. package/dist/kernel/host-access.js +65 -0
  92. package/dist/kernel/host-caller.d.ts +39 -0
  93. package/dist/kernel/host-caller.js +56 -0
  94. package/dist/kernel/json-body.d.ts +4 -0
  95. package/dist/kernel/json-body.js +44 -0
  96. package/dist/kernel/mcp-apps.d.ts +69 -0
  97. package/dist/kernel/mcp-apps.js +40 -0
  98. package/dist/kernel/mcp-call.d.ts +5 -0
  99. package/dist/kernel/mcp-call.js +25 -0
  100. package/dist/kernel/mcp-handler.js +371 -0
  101. package/dist/kernel/mcp.d.ts +110 -0
  102. package/dist/kernel/mcp.js +50 -0
  103. package/dist/kernel/media.d.ts +27 -0
  104. package/dist/kernel/media.js +216 -0
  105. package/dist/kernel/paging.d.ts +55 -0
  106. package/dist/kernel/paging.js +95 -0
  107. package/dist/kernel/publishing.d.ts +4 -0
  108. package/dist/kernel/publishing.js +16 -0
  109. package/dist/kernel/r2-media.d.ts +42 -0
  110. package/dist/kernel/r2-media.js +78 -0
  111. package/dist/kernel/rest-dispatch.js +38 -0
  112. package/dist/kernel/rest-router.js +64 -0
  113. package/dist/kernel/rest.d.ts +58 -0
  114. package/dist/kernel/rest.js +41 -0
  115. package/dist/kernel/scalars.d.ts +6 -0
  116. package/dist/kernel/scalars.js +44 -0
  117. package/dist/kernel/search.js +5 -0
  118. package/dist/kernel/site-types.d.ts +146 -0
  119. package/dist/kernel/site-types.js +1 -0
  120. package/dist/kernel/site.d.ts +39 -0
  121. package/dist/kernel/site.js +32 -0
  122. package/dist/kernel/store.d.ts +175 -0
  123. package/dist/kernel/store.js +269 -0
  124. package/dist/kernel/surface.d.ts +10 -0
  125. package/dist/kernel/surface.js +19 -0
  126. package/dist/kernel/sweep.d.ts +17 -0
  127. package/dist/kernel/sweep.js +27 -0
  128. package/dist/kernel/translations.d.ts +1 -0
  129. package/dist/kernel/translations.js +13 -0
  130. package/dist/kernel/user-caller.d.ts +31 -0
  131. package/dist/kernel/user-caller.js +67 -0
  132. package/dist/kernel/user-field-name.js +3 -0
  133. package/dist/kernel/user-fields.d.ts +35 -0
  134. package/dist/kernel/user-fields.js +81 -0
  135. package/dist/kernel/validation.d.ts +15 -0
  136. package/dist/kernel/validation.js +54 -0
  137. package/dist/kernel/web-gateway.js +68 -0
  138. package/dist/kernel/web-head.js +15 -0
  139. package/dist/kernel/web-index.js +40 -0
  140. package/dist/kernel/web-response.js +8 -0
  141. package/dist/kernel/web.d.ts +77 -0
  142. package/dist/kernel/web.js +124 -0
  143. package/dist/kernel/where.js +27 -0
  144. package/dist/testing/index.d.ts +1 -0
  145. package/dist/testing/index.js +1 -0
  146. package/dist/usecase/adminBindings.js +143 -0
  147. package/dist/usecase/adminClient.js +87 -0
  148. package/dist/usecase/adminDescriptors.js +107 -0
  149. package/dist/usecase/generate.js +166 -0
  150. package/dist/usecase/handlers.js +21 -0
  151. package/dist/usecase/mcp-media.js +17 -0
  152. package/dist/usecase/mcp.js +100 -0
  153. package/dist/usecase/paging.js +71 -0
  154. package/dist/usecase/publishing.js +63 -0
  155. package/dist/usecase/refusals.js +27 -0
  156. package/dist/usecase/rest.js +54 -0
  157. package/dist/usecase/search.js +7 -0
  158. package/dist/usecase/site.js +39 -0
  159. package/dist/usecase/stores.js +64 -0
  160. package/dist/usecase/tool-version.js +9 -0
  161. package/dist/usecase/translations.js +78 -0
  162. package/dist/usecase/ttl.js +20 -0
  163. package/dist/usecase/validation.js +241 -0
  164. package/dist/usecase/web.js +23 -0
  165. package/docs/examples/README.md +39 -18
  166. package/docs/examples/app-shell/.dev.vars.example +4 -0
  167. package/docs/examples/app-shell/README.md +121 -0
  168. package/docs/examples/app-shell/accept.mjs +91 -0
  169. package/docs/examples/app-shell/gitignore +7 -0
  170. package/docs/examples/app-shell/package.json +43 -0
  171. package/docs/examples/app-shell/pnpm-workspace.yaml +8 -0
  172. package/docs/examples/app-shell/smoke-kit.mjs +168 -0
  173. package/docs/examples/app-shell/src/auth.ts +58 -0
  174. package/docs/examples/app-shell/src/handlers.ts +5 -0
  175. package/docs/examples/app-shell/src/index.ts +4 -0
  176. package/docs/examples/app-shell/src/routes.ts +14 -0
  177. package/docs/examples/app-shell/src/schedule.ts +8 -0
  178. package/docs/examples/app-shell/src/service.ts +70 -0
  179. package/docs/examples/app-shell/src/sign-in.ts +41 -0
  180. package/docs/examples/app-shell/src/signup.ts +8 -0
  181. package/docs/examples/app-shell/tsconfig.json +26 -0
  182. package/docs/examples/app-shell/worker-configuration.d.ts +22 -0
  183. package/docs/examples/app-shell/wrangler.jsonc +62 -0
  184. package/docs/examples/club-events/README.md +65 -0
  185. package/docs/examples/club-events/manifests/club-events.yaml +247 -0
  186. package/docs/examples/club-events/smoke.mjs +127 -0
  187. package/docs/examples/club-events/src/handlers.ts +25 -0
  188. package/docs/examples/club-events/src/signup.ts +9 -0
  189. package/docs/examples/generated-web/README.md +78 -0
  190. package/docs/examples/generated-web/posts.yaml +38 -0
  191. package/docs/examples/generated-web/seed.sql +6 -0
  192. package/docs/examples/generated-web/src/worker.ts +43 -0
  193. package/docs/examples/generated-web/tsconfig.json +8 -0
  194. package/docs/examples/generated-web/wrangler.jsonc +8 -0
  195. package/docs/examples/purchasing/.dev.vars.example +6 -0
  196. package/docs/examples/purchasing/README.md +99 -0
  197. package/docs/examples/purchasing/manifests/purchasing.yaml +374 -0
  198. package/docs/examples/purchasing/seed.sql +4 -0
  199. package/docs/examples/purchasing/smoke.mjs +191 -0
  200. package/docs/examples/purchasing/src/admin.tsx +13 -0
  201. package/docs/examples/purchasing/src/handlers.ts +33 -0
  202. package/docs/examples/purchasing/src/notify.ts +29 -0
  203. package/docs/examples/purchasing/src/requests-page.ts +57 -0
  204. package/docs/examples/purchasing/src/routes.ts +53 -0
  205. package/docs/examples/purchasing/src/schedule.ts +31 -0
  206. package/docs/examples/purchasing/src/signup.ts +5 -0
  207. package/docs/examples/purchasing/src/supplier.ts +32 -0
  208. package/docs/examples/purchasing/wrangler.jsonc +69 -0
  209. package/docs/examples/recipes/README.md +60 -0
  210. package/docs/examples/recipes/manifests/recipes.yaml +75 -0
  211. package/docs/examples/recipes/smoke.mjs +102 -0
  212. package/docs/examples/recipes/src/media.ts +13 -0
  213. package/docs/examples/recipes/src/pages.ts +99 -0
  214. package/docs/examples/recipes/src/routes.ts +71 -0
  215. package/docs/examples/recipes/src/site-config.ts +12 -0
  216. package/docs/examples/recipes/wrangler.jsonc +74 -0
  217. package/docs/handbook/cloudflare/authentication.md +180 -322
  218. package/docs/handbook/cloudflare/chatgpt-sites.md +5 -23
  219. package/docs/handbook/cloudflare/deploy-and-operate.md +55 -77
  220. package/docs/handbook/cloudflare/media-r2.md +61 -205
  221. package/docs/handbook/cloudflare/service-entry.md +239 -0
  222. package/docs/handbook/concepts/authorization.md +10 -107
  223. package/docs/handbook/concepts/four-atoms.md +9 -168
  224. package/docs/handbook/concepts/lifecycle-and-locales.md +9 -132
  225. package/docs/handbook/concepts/mcp-and-agents.md +24 -121
  226. package/docs/handbook/concepts/procedures-and-triggers.md +5 -217
  227. package/docs/handbook/concepts/runtime-and-adapters.md +15 -169
  228. package/docs/handbook/concepts/views.md +10 -185
  229. package/docs/handbook/examples/hub.md +3 -8
  230. package/docs/handbook/guides/adapter-guide.md +11 -0
  231. package/docs/handbook/guides/admin-ui.md +115 -133
  232. package/docs/handbook/guides/agent-setup.md +64 -74
  233. package/docs/handbook/guides/agent-workflow-acceptance.md +232 -0
  234. package/docs/handbook/guides/email.md +86 -0
  235. package/docs/handbook/guides/local-testing.md +40 -0
  236. package/docs/handbook/guides/mcp-apps.md +560 -0
  237. package/docs/handbook/guides/native-admin.md +566 -0
  238. package/docs/handbook/guides/native-execution.md +133 -0
  239. package/docs/handbook/guides/oauth.md +219 -0
  240. package/docs/handbook/guides/postgres-adapters.md +56 -0
  241. package/docs/handbook/guides/public-pages.md +87 -0
  242. package/docs/handbook/guides/size-and-startup.md +9 -0
  243. package/docs/handbook/guides/sql-patterns.md +266 -0
  244. package/docs/handbook/guides/typed-queries.md +211 -107
  245. package/docs/handbook/navigation.json +176 -55
  246. package/docs/handbook/reference/admin-descriptors.md +53 -0
  247. package/docs/handbook/reference/authorization.md +39 -266
  248. package/docs/handbook/reference/describe.md +56 -0
  249. package/docs/handbook/reference/diagnostics.md +19 -186
  250. package/docs/handbook/reference/features.md +45 -55
  251. package/docs/handbook/reference/manifest.md +6 -129
  252. package/docs/handbook/reference/procedure.md +11 -303
  253. package/docs/handbook/reference/schema.md +64 -240
  254. package/docs/handbook/reference/site-config.md +5 -218
  255. package/docs/handbook/reference/sql.md +64 -0
  256. package/docs/handbook/reference/surface.md +392 -201
  257. package/docs/handbook/reference/trigger.md +56 -192
  258. package/docs/handbook/reference/view.md +24 -243
  259. package/docs/handbook/releases/index.md +244 -77
  260. package/docs/handbook/start/agents.md +45 -0
  261. package/docs/handbook/start/overview.md +9 -48
  262. package/docs/handbook/start/project-and-cli.md +51 -104
  263. package/docs/handbook/start/quickstart-worker.md +43 -178
  264. package/docs/skills/develop/SKILL.md +79 -249
  265. package/docs/skills/integrate/SKILL.md +39 -50
  266. package/docs/skills/media-gc/SKILL.md +34 -10
  267. package/docs/skills/provision/SKILL.md +36 -186
  268. package/docs/skills/update/SKILL.md +23 -38
  269. package/docs/source/scripts/postgres-adapter.ts +101 -0
  270. package/docs/upgrade-0.1-to-0.2.md +227 -0
  271. package/package.json +120 -131
  272. package/skills/README.md +48 -108
  273. package/skills/mantle/SKILL.md +76 -0
  274. package/dist/admin-ui.d.ts +0 -2
  275. package/dist/admin-ui.d.ts.map +0 -1
  276. package/dist/admin-ui.js +0 -2
  277. package/dist/admin-ui.js.map +0 -1
  278. package/dist/admin.d.ts +0 -2
  279. package/dist/admin.d.ts.map +0 -1
  280. package/dist/admin.js +0 -2
  281. package/dist/admin.js.map +0 -1
  282. package/dist/auth.d.ts +0 -2
  283. package/dist/auth.d.ts.map +0 -1
  284. package/dist/auth.js +0 -2
  285. package/dist/auth.js.map +0 -1
  286. package/dist/bun.d.ts +0 -2
  287. package/dist/bun.d.ts.map +0 -1
  288. package/dist/bun.js +0 -2
  289. package/dist/bun.js.map +0 -1
  290. package/dist/cli/generate-cloudflare.d.ts +0 -7
  291. package/dist/cli/generate-cloudflare.d.ts.map +0 -1
  292. package/dist/cli/generate-cloudflare.js +0 -123
  293. package/dist/cli/generate-cloudflare.js.map +0 -1
  294. package/dist/cli/generate-project.d.ts +0 -25
  295. package/dist/cli/generate-project.d.ts.map +0 -1
  296. package/dist/cli/generate-project.js +0 -282
  297. package/dist/cli/generate-project.js.map +0 -1
  298. package/dist/cli/generate-sites.d.ts +0 -8
  299. package/dist/cli/generate-sites.d.ts.map +0 -1
  300. package/dist/cli/generate-sites.js +0 -273
  301. package/dist/cli/generate-sites.js.map +0 -1
  302. package/dist/cli/generate.d.ts +0 -20
  303. package/dist/cli/generate.d.ts.map +0 -1
  304. package/dist/cli/generate.js +0 -299
  305. package/dist/cli/generate.js.map +0 -1
  306. package/dist/cli/harness.d.ts +0 -3
  307. package/dist/cli/harness.d.ts.map +0 -1
  308. package/dist/cli/harness.js +0 -214
  309. package/dist/cli/harness.js.map +0 -1
  310. package/dist/cli/main.d.ts +0 -3
  311. package/dist/cli/main.d.ts.map +0 -1
  312. package/dist/cli/main.js +0 -77
  313. package/dist/cli/main.js.map +0 -1
  314. package/dist/cli/skills.d.ts +0 -3
  315. package/dist/cli/skills.d.ts.map +0 -1
  316. package/dist/cli/skills.js +0 -128
  317. package/dist/cli/skills.js.map +0 -1
  318. package/dist/cloudflare.d.ts +0 -2
  319. package/dist/cloudflare.d.ts.map +0 -1
  320. package/dist/cloudflare.js +0 -2
  321. package/dist/cloudflare.js.map +0 -1
  322. package/dist/codegen/emitMantleModule.d.ts +0 -22
  323. package/dist/codegen/emitMantleModule.d.ts.map +0 -1
  324. package/dist/codegen/emitMantleModule.js +0 -291
  325. package/dist/codegen/emitMantleModule.js.map +0 -1
  326. package/dist/codegen.d.ts +0 -2
  327. package/dist/codegen.d.ts.map +0 -1
  328. package/dist/codegen.js +0 -2
  329. package/dist/codegen.js.map +0 -1
  330. package/dist/runtime-testing.d.ts +0 -2
  331. package/dist/runtime-testing.d.ts.map +0 -1
  332. package/dist/runtime-testing.js +0 -2
  333. package/dist/runtime-testing.js.map +0 -1
  334. package/dist/runtime.d.ts +0 -2
  335. package/dist/runtime.d.ts.map +0 -1
  336. package/dist/runtime.js +0 -2
  337. package/dist/runtime.js.map +0 -1
  338. package/dist/spec.d.ts +0 -2
  339. package/dist/spec.d.ts.map +0 -1
  340. package/dist/spec.js +0 -2
  341. package/dist/spec.js.map +0 -1
  342. package/dist/vercel-libsql.d.ts +0 -2
  343. package/dist/vercel-libsql.d.ts.map +0 -1
  344. package/dist/vercel-libsql.js +0 -2
  345. package/dist/vercel-libsql.js.map +0 -1
  346. package/dist/vercel.d.ts +0 -2
  347. package/dist/vercel.d.ts.map +0 -1
  348. package/dist/vercel.js +0 -2
  349. package/dist/vercel.js.map +0 -1
  350. package/dist/web.d.ts +0 -2
  351. package/dist/web.d.ts.map +0 -1
  352. package/dist/web.js +0 -2
  353. package/dist/web.js.map +0 -1
  354. package/docs/adapter-guide.md +0 -222
  355. package/docs/adr/0001-four-atom-manifest-model.md +0 -440
  356. package/docs/adr/0002-closed-enums-for-bindings.md +0 -253
  357. package/docs/adr/0007-ai-as-primary-author.md +0 -473
  358. package/docs/adr/0008-structured-diagnostic-shape.md +0 -338
  359. package/docs/adr/0009-consumer-supplied-manifests.md +0 -149
  360. package/docs/adr/0010-locale-and-translates.md +0 -453
  361. package/docs/adr/0011-adapter-port-spec.md +0 -281
  362. package/docs/adr/0012-views-as-public-rest.md +0 -161
  363. package/docs/adr/0013-agent-provisioned-consumer-projects.md +0 -154
  364. package/docs/adr/0014-auth-better-auth-and-multi-tenant-mcp.md +0 -900
  365. package/docs/adr/0016-site-semantic-layer.md +0 -70
  366. package/docs/adr/0017-media-multi-variant-agent-side-optimization.md +0 -181
  367. package/docs/adr/0018-core-starters-repository-boundary.md +0 -179
  368. package/docs/adr/0019-sealed-manifest-runtime-pipeline.md +0 -240
  369. package/docs/adr/0020-builtin-handler-contracts-and-matched-upsert.md +0 -199
  370. package/docs/adr/0021-retire-starter-scaffolding.md +0 -30
  371. package/docs/adr/0022-caller-observed-version-occ.md +0 -212
  372. package/docs/adr/0023-port-failure-contract.md +0 -69
  373. package/docs/adr/0024-manifest-native-schema-tables.md +0 -264
  374. package/docs/adr/0025-reserved-native-columns-and-published-only-public-views.md +0 -105
  375. package/docs/adr/0026-progressive-generate.md +0 -36
  376. package/docs/adr/0027-scheduled-procedure-triggers.md +0 -31
  377. package/docs/adr/0028-schema-ttl-expiry.md +0 -33
  378. package/docs/adr/README.md +0 -81
  379. package/docs/adr/adr-lite-803-request-diagnostics.md +0 -38
  380. package/docs/adr/adr-lite-808-route-readiness.md +0 -47
  381. package/docs/adr/adr-lite-809-bounded-public-content.md +0 -71
  382. package/docs/adr/adr-lite-812-native-parity.md +0 -150
  383. package/docs/adr/adr-lite-823-home-statistics.md +0 -64
  384. package/docs/adr/adr-lite-842-mcp-authoring.md +0 -30
  385. package/docs/adr/adr-lite-845-frontend-client.md +0 -38
  386. package/docs/adr/adr-lite-861-admin-webmcp.md +0 -42
  387. package/docs/adr/adr-lite-909-admin-ui-kit.md +0 -37
  388. package/docs/agent-prompts.md +0 -64
  389. package/docs/api-mcp-authorization.md +0 -5
  390. package/docs/assets/mantle-admin-developer.png +0 -0
  391. package/docs/assets/mantle-admin-operations.png +0 -0
  392. package/docs/assets/mantle-hero.jpg +0 -0
  393. package/docs/auth-hosting-model.md +0 -166
  394. package/docs/cloudflare-low-level-composition.md +0 -5
  395. package/docs/consumer-onboarding-audit.md +0 -65
  396. package/docs/deferred-lifecycle-queues.md +0 -5
  397. package/docs/design-atoms.md +0 -16
  398. package/docs/design-references/editorial-blog-2026-05-05.md +0 -218
  399. package/docs/direct-authoring.md +0 -5
  400. package/docs/examples/builtin-commerce.md +0 -269
  401. package/docs/examples/builtin-intake.md +0 -143
  402. package/docs/examples/builtin-legal-documents.md +0 -189
  403. package/docs/examples/builtin-procurement.md +0 -241
  404. package/docs/examples/builtin-publication.md +0 -241
  405. package/docs/examples/builtin-reservation.md +0 -149
  406. package/docs/examples/cf-primitives-commerce-inventory.md +0 -809
  407. package/docs/examples/cf-primitives-guarded-api.md +0 -429
  408. package/docs/examples/cf-primitives-intake-hooks.md +0 -319
  409. package/docs/examples/host-chatgpt-sites/.openai/hosting.json +0 -1
  410. package/docs/examples/host-chatgpt-sites/README.md +0 -70
  411. package/docs/examples/host-chatgpt-sites/drizzle/0000_sites_users.sql +0 -8
  412. package/docs/examples/host-chatgpt-sites/drizzle/0001_mantle.sql +0 -294
  413. package/docs/examples/host-chatgpt-sites/drizzle/0002_article_cover.sql +0 -5
  414. package/docs/examples/host-chatgpt-sites/drizzle/0003_store_instance_id.sql +0 -1
  415. package/docs/examples/host-chatgpt-sites/drizzle/0004_mantle.sql +0 -10
  416. package/docs/examples/host-chatgpt-sites/drizzle/0005_mantle.sql +0 -24
  417. package/docs/examples/host-chatgpt-sites/drizzle/meta/_journal.json +0 -1
  418. package/docs/examples/host-chatgpt-sites/drizzle/meta/mantle-state.json +0 -60
  419. package/docs/examples/host-chatgpt-sites/manifests/site.yaml +0 -27
  420. package/docs/examples/host-chatgpt-sites/package.json +0 -1
  421. package/docs/examples/host-chatgpt-sites/public/site.css +0 -1
  422. package/docs/examples/host-chatgpt-sites/scripts/build.mjs +0 -13
  423. package/docs/examples/host-chatgpt-sites/scripts/check.mjs +0 -101
  424. package/docs/examples/host-chatgpt-sites/scripts/migration.mjs +0 -43
  425. package/docs/examples/host-chatgpt-sites/src/chatgpt-auth.ts +0 -66
  426. package/docs/examples/host-chatgpt-sites/src/index.ts +0 -46
  427. package/docs/examples/host-chatgpt-sites/src/mcp.ts +0 -49
  428. package/docs/examples/host-chatgpt-sites/src/media.ts +0 -109
  429. package/docs/examples/host-chatgpt-sites/src/r2-lab.ts +0 -38
  430. package/docs/examples/host-chatgpt-sites/src/storage-fingerprint.json +0 -1
  431. package/docs/examples/host-chatgpt-sites/src/web.ts +0 -35
  432. package/docs/examples/host-chatgpt-sites/tsconfig.json +0 -1
  433. package/docs/examples/host-chatgpt-sites/wrangler.jsonc +0 -10
  434. package/docs/examples/host-local-admin-otp/.dev.vars.example +0 -3
  435. package/docs/examples/host-local-admin-otp/README.md +0 -80
  436. package/docs/examples/host-local-admin-otp/ensure-dev-vars.mjs +0 -5
  437. package/docs/examples/host-local-admin-otp/manifests/site.yaml +0 -25
  438. package/docs/examples/host-local-admin-otp/package.json +0 -29
  439. package/docs/examples/host-local-admin-otp/public/.gitkeep +0 -1
  440. package/docs/examples/host-local-admin-otp/smoke.mjs +0 -141
  441. package/docs/examples/host-local-admin-otp/src/index.ts +0 -54
  442. package/docs/examples/host-local-admin-otp/tsconfig.json +0 -17
  443. package/docs/examples/host-local-admin-otp/wrangler.jsonc +0 -23
  444. package/docs/examples/host-minimal-worker/README.md +0 -41
  445. package/docs/examples/host-minimal-worker/manifests/site.yaml +0 -25
  446. package/docs/examples/host-minimal-worker/package.json +0 -26
  447. package/docs/examples/host-minimal-worker/smoke.mjs +0 -23
  448. package/docs/examples/host-minimal-worker/src/index.ts +0 -4
  449. package/docs/examples/host-minimal-worker/tsconfig.json +0 -17
  450. package/docs/examples/host-minimal-worker/wrangler.jsonc +0 -22
  451. package/docs/handbook/chatgpt-sites/equipment-checkout.md +0 -231
  452. package/docs/handbook/chatgpt-sites/generated-app.md +0 -84
  453. package/docs/handbook/chatgpt-sites/host-reference.md +0 -113
  454. package/docs/handbook/chatgpt-sites/index.md +0 -133
  455. package/docs/handbook/cloudflare/bindings.md +0 -291
  456. package/docs/handbook/cloudflare/conventional-worker.md +0 -166
  457. package/docs/handbook/cloudflare/deferred-hooks-queues.md +0 -170
  458. package/docs/handbook/cloudflare/low-level-composition.md +0 -169
  459. package/docs/handbook/cloudflare/public-web.md +0 -144
  460. package/docs/handbook/cloudflare/site-chrome.md +0 -75
  461. package/docs/handbook/examples/commerce-transaction.md +0 -11
  462. package/docs/handbook/examples/commerce.md +0 -11
  463. package/docs/handbook/examples/guarded-api.md +0 -10
  464. package/docs/handbook/examples/intake-form.md +0 -12
  465. package/docs/handbook/examples/intake-hooks.md +0 -11
  466. package/docs/handbook/examples/legal-documents.md +0 -10
  467. package/docs/handbook/examples/procurement-approvals.md +0 -10
  468. package/docs/handbook/examples/publication.md +0 -10
  469. package/docs/handbook/examples/reservation.md +0 -10
  470. package/docs/handbook/start/quickstart-admin.md +0 -52
  471. package/docs/labels.md +0 -71
  472. package/docs/media-uploads.md +0 -5
  473. package/docs/migration-0.1.2.md +0 -13
  474. package/docs/performance-harness.md +0 -228
  475. package/docs/release-process.md +0 -244
  476. package/docs/schema-indexes.md +0 -5
  477. package/docs/sealed-pipeline-ownership.md +0 -101
  478. package/docs/skills/plugin/SKILL.md +0 -132
  479. package/docs/skills/theme/SKILL.md +0 -77
  480. package/docs/spec-only-host-adoption.md +0 -157
  481. package/docs/transaction-patterns.md +0 -5
  482. package/skills/develop/SKILL.md +0 -258
  483. package/skills/install/SKILL.md +0 -112
  484. package/skills/integrate/SKILL.md +0 -60
  485. package/skills/media-gc/SKILL.md +0 -85
  486. package/skills/plugin/SKILL.md +0 -132
  487. package/skills/provision/SKILL.md +0 -194
  488. package/skills/theme/SKILL.md +0 -77
  489. package/skills/update/SKILL.md +0 -51
  490. package/templates/chatgpt-sites/auth.ts +0 -66
  491. package/templates/chatgpt-sites/build.mjs +0 -14
  492. package/templates/chatgpt-sites/env.ts +0 -1
  493. package/templates/chatgpt-sites/mcp.ts +0 -48
  494. package/templates/chatgpt-sites/public-mcp.ts +0 -29
  495. package/templates/chatgpt-sites/smoke-local.mjs +0 -20
@@ -0,0 +1,424 @@
1
+ // src/build/spec/domain/model/ManifestGrammar.ts
2
+ function resolveLocalizedText(value, preferred, canonical2) {
3
+ if (value == null) return null;
4
+ if (typeof value === "string") return value;
5
+ if (Object.prototype.hasOwnProperty.call(value, preferred)) {
6
+ return value[preferred];
7
+ }
8
+ if (canonical2 && Object.prototype.hasOwnProperty.call(value, canonical2)) {
9
+ return value[canonical2];
10
+ }
11
+ const firstKey = Object.keys(value)[0];
12
+ return firstKey !== void 0 ? value[firstKey] : null;
13
+ }
14
+ var INPUT_RULE_KEYWORDS = ["dependentRequired", "anyOf", "if", "then", "else"];
15
+
16
+ // src/build/spec/domain/service/RootRefChain.ts
17
+ function lookupLocalRef(root, ref) {
18
+ if (typeof ref !== "string" || !ref.startsWith("#/")) return void 0;
19
+ let value = root;
20
+ try {
21
+ for (const key of decodeURIComponent(ref.slice(2)).split("/").map((key2) => key2.replace(/~1/g, "/").replace(/~0/g, "~"))) value = value && typeof value === "object" && Object.hasOwn(value, key) ? value[key] : void 0;
22
+ } catch {
23
+ return void 0;
24
+ }
25
+ return value && typeof value === "object" ? value : void 0;
26
+ }
27
+ function rootRefChain(input) {
28
+ const chain = [];
29
+ for (let schema = input; schema !== void 0; schema = lookupLocalRef(input, schema.$ref)) {
30
+ if (chain.includes(schema)) return void 0;
31
+ chain.push(schema);
32
+ if (schema.$ref === void 0) return chain;
33
+ }
34
+ return void 0;
35
+ }
36
+
37
+ // src/build/spec/domain/service/McpToolNaming.ts
38
+ function mcpToolNameSegment(name) {
39
+ return name.toLowerCase().replace(/-/g, "_");
40
+ }
41
+ function toolTitle(name) {
42
+ const words = name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[-_.\s]+/g, " ").trim().toLowerCase();
43
+ return words.charAt(0).toUpperCase() + words.slice(1);
44
+ }
45
+ var viewAnnotations = { readOnlyHint: true, destructiveHint: false };
46
+ function procedureAnnotations(p) {
47
+ const readOnlyHint = p.mcp?.readOnlyHint ?? false;
48
+ return { readOnlyHint, destructiveHint: !readOnlyHint && ("ref" in p.handler || overwrites(p.handler.sql.stmts)), ...p.mcp };
49
+ }
50
+ var overwrites = (node) => !!node && typeof node === "object" && ("DeleteStmt" in node || "UpdateStmt" in node || node.onConflictClause?.action === "ONCONFLICT_UPDATE" || Object.values(node).some(overwrites));
51
+ function mcpTools(plan, surface, locale = "en") {
52
+ const text = (t) => resolveLocalizedText(t, locale, "en") ?? void 0;
53
+ const tools = /* @__PURE__ */ new Map();
54
+ const add = (tool) => {
55
+ const prior = tools.get(tool.name);
56
+ if (prior && (prior.kind !== tool.kind || prior.source !== tool.source)) throw new TypeError(`MCP tool '${tool.name}' comes from both '${prior.source}' and '${tool.source}'.`);
57
+ tools.set(tool.name, tool);
58
+ };
59
+ for (const t of Object.values(plan.triggers)) {
60
+ if (t.source.kind !== "mcp" || t.source.surface !== surface) continue;
61
+ const p = plan.procedures[t.procedure];
62
+ const title = text(p.title);
63
+ add({
64
+ name: mcpToolNameSegment(t.procedure),
65
+ kind: "procedure",
66
+ source: t.procedure,
67
+ title: title ?? toolTitle(t.procedure),
68
+ description: text(p.description) ?? title ?? t.procedure,
69
+ inputSchema: p.input,
70
+ // structuredContent must be an object
71
+ ...p.output.type === "object" ? { outputSchema: p.output } : {},
72
+ annotations: procedureAnnotations(p),
73
+ requires: p.requires
74
+ });
75
+ }
76
+ for (const [name, v] of Object.entries(plan.views)) {
77
+ if (v.surface !== surface) continue;
78
+ const chain = (v.input ? rootRefChain(v.input) ?? [v.input] : []).reverse();
79
+ const props = Object.assign({}, ...chain.map((s) => s.properties ?? {}));
80
+ const required = [...new Set(chain.flatMap((s) => s.required ?? []))];
81
+ if ("limit" in props || "cursor" in props) throw new TypeError(`View '${name}' declares an input named limit or cursor; the MCP tool reserves both for paging.`);
82
+ const rules = chain.map((s) => Object.fromEntries(INPUT_RULE_KEYWORDS.flatMap((k) => s[k] === void 0 ? [] : [[k, s[k]]]))).filter((r) => Object.keys(r).length);
83
+ const defs = v.input ? referencedDefs(v.input, props) : {};
84
+ const title = text(v.title);
85
+ add({
86
+ name: mcpToolNameSegment(name),
87
+ kind: "view",
88
+ source: name,
89
+ title: title ?? toolTitle(name),
90
+ description: text(v.description) ?? title ?? name,
91
+ inputSchema: {
92
+ type: "object",
93
+ properties: { ...props, limit: { type: "integer", minimum: 1, maximum: 500 }, cursor: { type: "string" } },
94
+ ...required.length ? { required } : {},
95
+ ...rules.length > 1 ? { allOf: rules } : rules[0],
96
+ ...Object.keys(defs).length ? { $defs: defs } : {}
97
+ },
98
+ annotations: viewAnnotations,
99
+ requires: v.requires
100
+ });
101
+ }
102
+ return [...tools.values()];
103
+ }
104
+ function referencedDefs(root, node, found = {}) {
105
+ if (!node || typeof node !== "object") return found;
106
+ const ref = node.$ref, [head, segment] = typeof ref === "string" && ref.startsWith("#/") ? decoded(ref.slice(2)).split("/") : [];
107
+ const key = head === "$defs" ? segment?.replace(/~1/g, "/").replace(/~0/g, "~") : void 0;
108
+ if (key !== void 0 && !Object.hasOwn(found, key) && root.$defs && Object.hasOwn(root.$defs, key)) {
109
+ found[key] = root.$defs[key];
110
+ referencedDefs(root, found[key], found);
111
+ }
112
+ for (const child of Object.values(node)) referencedDefs(root, child, found);
113
+ return found;
114
+ }
115
+ var decoded = (pointer) => {
116
+ try {
117
+ return decodeURIComponent(pointer);
118
+ } catch {
119
+ return "";
120
+ }
121
+ };
122
+
123
+ // src/build/spec/domain/service/PlanFingerprint.ts
124
+ function canonical(v) {
125
+ if (Array.isArray(v)) return `[${v.map(canonical).join(",")}]`;
126
+ if (v && typeof v === "object")
127
+ return `{${Object.keys(v).sort().filter((k) => v[k] !== void 0).map((k) => `${JSON.stringify(k)}:${canonical(v[k])}`).join(",")}}`;
128
+ return JSON.stringify(v) ?? "null";
129
+ }
130
+
131
+ // src/domain/generated-tools.ts
132
+ var publishingTransitions = [["publish", ["draft"], "published"], ["unpublish", ["published", "archived"], "draft"], ["archive", ["draft", "published"], "archived"]];
133
+ var publishingInput = { type: "object", properties: { id: { type: "string", minLength: 1 }, expectedVersion: { type: "integer", minimum: 1 } }, required: ["id", "expectedVersion"], additionalProperties: false };
134
+ function mediaDefinitions() {
135
+ const define = (name, description, inputSchema, action, readOnlyHint = false) => ({ name, description, inputSchema, action, annotations: { readOnlyHint, destructiveHint: action === "delete", openWorldHint: true } });
136
+ const string = { type: "string" };
137
+ const texts = { alt: { type: "string", maxLength: 1e3 }, caption: { type: "string", maxLength: 1e3 } };
138
+ const input = (properties, required = []) => ({ type: "object", properties, required, additionalProperties: false });
139
+ return [
140
+ define("get_media_upload_policy", "Read declared image purpose MIME slots and byte caps before preparing variants or requesting an upload. Optimization runs locally, never in the host.", input({}), "policy", true),
141
+ define("create_media_upload", "Create short-lived PUT capabilities for image variants. Read site media purpose policy first; optimize images locally. Obtain attachment bytes yourself, then PUT each variant with its requiredHeaders and call commit_media_upload. Never store upload URLs as published images or ask the user to run terminal commands.", input({ filename: { type: "string", maxLength: 255 }, purpose: string, variants: { type: "array", minItems: 1, items: input({ mimeType: string, byteSize: { type: "integer", minimum: 1 }, role: { type: "string", enum: ["primary", "alternate", "fallback"] } }, ["mimeType", "byteSize", "role"]) }, ...texts }, ["filename", "purpose", "variants"]), "create"),
142
+ define("commit_media_upload", "Verify all uploaded variants and commit one permanent media asset. Store the returned asset id in fields referencing media_assets.id, never a temporary upload URL. Unknown or expired upload groups require a new create_media_upload.", input({ uploadGroupId: string, ...texts }, ["uploadGroupId"]), "commit"),
143
+ define("list_media_assets", "List committed image assets, newest first, with their permanent variants and alt/caption. Search matches id, alt or caption; reuse only a returned cursor.", input({ limit: { type: "integer", minimum: 1, maximum: 500 }, cursor: string, search: string }), "list", true),
144
+ define("get_media_asset", "Read one committed media asset and its permanent variant URLs.", input({ id: string }, ["id"]), "get", true),
145
+ define("update_media_asset", "Update committed asset alt or caption; omitted fields remain unchanged and empty strings clear text.", input({ id: string, ...texts }, ["id"]), "update"),
146
+ define("delete_media_asset", "Delete an asset's objects and library record. Check application references first. A partial failure can be retried using the same id.", input({ id: string }, ["id"]), "delete")
147
+ ];
148
+ }
149
+
150
+ // src/domain/describe/targets.ts
151
+ function inspectSql(value) {
152
+ const schemas = /* @__PURE__ */ new Set(), readSchemas = /* @__PURE__ */ new Set();
153
+ const writes = [];
154
+ let readOnly = true;
155
+ const walk = (v) => {
156
+ if (!v || typeof v !== "object") return;
157
+ const n = v;
158
+ if (n.RangeVar?.mantle === "table") {
159
+ schemas.add(n.RangeVar.relname.toLowerCase());
160
+ readSchemas.add(n.RangeVar.relname.toLowerCase());
161
+ }
162
+ for (const kind of ["InsertStmt", "UpdateStmt", "DeleteStmt"]) if (n[kind]) {
163
+ readOnly = false;
164
+ if (n[kind].relation?.relname) writes.push({ schema: n[kind].relation.relname.toLowerCase(), operation: kind === "InsertStmt" ? "create" : kind === "UpdateStmt" ? "update" : "delete" });
165
+ if (n[kind].relation?.relname) {
166
+ schemas.add(n[kind].relation.relname.toLowerCase());
167
+ if (kind !== "InsertStmt") readSchemas.add(n[kind].relation.relname.toLowerCase());
168
+ }
169
+ }
170
+ Object.values(n).forEach(walk);
171
+ };
172
+ walk(value);
173
+ return { schemas: [...schemas].sort(), readSchemas: [...readSchemas].sort(), readOnly, writes };
174
+ }
175
+ function mergeRestrict(policies, conjunctive) {
176
+ return Object.fromEntries([...new Set(policies.flatMap((p) => Object.keys(p)))].sort().map((schema) => {
177
+ const rows = policies.map((p) => p[schema] ?? { terms: [] });
178
+ const terms = [...new Map(rows.flatMap((p) => p.terms).map((t) => [canonical(t), t])).values()].filter((t) => conjunctive || rows.every((p) => p.terms.some((v) => canonical(v) === canonical(t))));
179
+ const owner = rows.find((p) => p.owner)?.owner;
180
+ return [schema, { ...owner && (conjunctive || rows.every((p) => p.owner === owner)) ? { owner } : {}, terms }];
181
+ }));
182
+ }
183
+ function inspectBehavior(plan, ir, opaque, requires, restrict, writes) {
184
+ const inspected = inspectSql(ir);
185
+ if (writes) {
186
+ inspected.writes = [...writes];
187
+ inspected.schemas.push(...writes.map((w) => w.schema));
188
+ inspected.readSchemas.push(...writes.filter((w) => w.operation !== "create").map((w) => w.schema));
189
+ }
190
+ const dependencies = [], policies = [restrict ?? {}];
191
+ const procedures = /* @__PURE__ */ new Set(), hooks = /* @__PURE__ */ new Set();
192
+ const visit = (name) => {
193
+ if (procedures.has(name)) return;
194
+ procedures.add(name);
195
+ const p = plan.procedures[name];
196
+ if (!p) throw new TypeError(`Unknown dependency '${name}'.`);
197
+ dependencies.push({ procedure: name, declaration: p });
198
+ policies.push(p.restrict ?? {});
199
+ opaque ||= "ref" in p.handler;
200
+ const g = inspectSql("sql" in p.handler ? p.handler.sql.stmts : void 0);
201
+ inspected.schemas.push(...g.schemas);
202
+ inspected.readSchemas.push(...g.readSchemas);
203
+ inspected.writes.push(...g.writes);
204
+ inspected.readOnly &&= g.readOnly;
205
+ if (p.requires?.guard) visit(p.requires.guard.procedure);
206
+ };
207
+ if (requires?.guard) visit(requires.guard.procedure);
208
+ for (; ; ) {
209
+ const before = hooks.size;
210
+ for (const [id, t] of Object.entries(plan.triggers).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) {
211
+ if (t.source.kind !== "lifecycle" || hooks.has(id)) continue;
212
+ const source = t.source;
213
+ if (!opaque && !inspected.writes.some((w) => w.schema === source.schema.toLowerCase() && source.on.some((on) => on.endsWith(`_${w.operation}`)))) continue;
214
+ hooks.add(id);
215
+ dependencies.push({ trigger: id, source });
216
+ visit(t.procedure);
217
+ }
218
+ if (hooks.size === before) break;
219
+ }
220
+ const related = (names) => {
221
+ const all = new Set(opaque ? Object.keys(plan.schemas) : names);
222
+ for (const name of all) {
223
+ const parent = plan.schemas[name]?.translates?.parent.toLowerCase();
224
+ if (parent) all.add(parent);
225
+ }
226
+ return [...all].sort();
227
+ };
228
+ return {
229
+ ...inspected,
230
+ schemas: related(inspected.schemas),
231
+ readSchemas: related(inspected.readSchemas),
232
+ opaque,
233
+ restrict: mergeRestrict(policies, true),
234
+ dependencies
235
+ };
236
+ }
237
+ var objectInput = { type: "object", properties: {} };
238
+ var pathTemplate = (path) => path.replace(/\{([^}]+)\}/g, ":$1");
239
+ var adminRoutes = [
240
+ "GET /me",
241
+ "GET /site",
242
+ "GET /collections",
243
+ "GET /views-manifest",
244
+ "GET /operations",
245
+ "GET /webmcp",
246
+ "POST /webmcp/:tool",
247
+ "GET /bootstrap",
248
+ "GET /views/:name/export",
249
+ "GET /views/:name",
250
+ "GET /view-batch",
251
+ "GET /developer/views/:name",
252
+ "POST /operations/:name",
253
+ "GET /developer-console",
254
+ "GET /collections/:name/statistics",
255
+ "GET /entries",
256
+ "GET /entries/export",
257
+ "GET /entries/:id",
258
+ "POST /entries",
259
+ "PATCH /entries/:id",
260
+ "POST /entries/:id/publish",
261
+ "POST /entries/:id/unpublish",
262
+ "POST /entries/:id/archive",
263
+ "DELETE /entries/:id",
264
+ "GET /site-settings",
265
+ "PATCH /site-settings",
266
+ "POST /media/uploads",
267
+ "POST /media/uploads/:groupId/commit",
268
+ "GET /media",
269
+ "GET /media/:id",
270
+ "PATCH /media/:id",
271
+ "DELETE /media/:id",
272
+ "GET /admin",
273
+ "GET /members",
274
+ "PATCH /admin/:id/role",
275
+ "POST /admin/invitations",
276
+ "DELETE /admin/invitations/:id"
277
+ ];
278
+ function targetDefinitions(plan) {
279
+ const out = [];
280
+ const tools = [...mcpTools(plan, "public"), ...mcpTools(plan, "admin")];
281
+ for (const [kind, entries] of [["view", plan.views], ["procedure", plan.procedures]]) {
282
+ for (const [name, p] of Object.entries(entries).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) {
283
+ const view = kind === "view" ? plan.views[name] : void 0;
284
+ const proc = kind === "procedure" ? plan.procedures[name] : void 0;
285
+ const ir = view?.stmts ?? (proc && "sql" in proc.handler ? proc.handler.sql.stmts : void 0);
286
+ const inspected = inspectBehavior(plan, ir, !!proc && "ref" in proc.handler, p.requires, p.restrict);
287
+ const tool = tools.find((t) => t.kind === kind && t.source === name);
288
+ const title = resolveLocalizedText(p.title, "en", "en") ?? name;
289
+ const triggers = Object.entries(plan.triggers).filter(([, t]) => kind === "procedure" && t.procedure === name).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([id, t]) => ({ id, source: t.source }));
290
+ const surfaces = [.../* @__PURE__ */ new Set([
291
+ ...view ? [view.surface, "admin", ...view.surface === "public" ? ["rest"] : []] : [],
292
+ ...triggers.map((t) => t.source.kind === "mcp" ? t.source.surface : t.source.kind === "http" ? "rest" : t.source.kind)
293
+ ])].sort();
294
+ if (!surfaces.length) surfaces.push("internal");
295
+ out.push({
296
+ id: `${kind}:${name}`,
297
+ name: tool?.name ?? mcpToolNameSegment(name),
298
+ kind,
299
+ surface: view?.surface ?? (surfaces.includes("public") || surfaces.includes("rest") ? "public" : surfaces.includes("admin") ? "admin" : "internal"),
300
+ surfaces,
301
+ triggers,
302
+ title,
303
+ description: resolveLocalizedText(p.description, "en", "en") ?? title,
304
+ inputSchema: tool?.inputSchema ?? view?.input ?? proc?.input ?? objectInput,
305
+ annotations: tool?.annotations ?? {},
306
+ requires: p.requires,
307
+ restrict: inspected.restrict,
308
+ schemas: inspected.schemas,
309
+ readSchemas: inspected.readSchemas,
310
+ readOnly: !inspected.opaque && inspected.readOnly,
311
+ opaque: inspected.opaque,
312
+ trustedOnly: !!proc?.trustedOnly,
313
+ variants: [],
314
+ behavior: { declaration: p, dependencies: inspected.dependencies }
315
+ });
316
+ }
317
+ }
318
+ const addRoute = (id, dependencies, inputSchema = objectInput) => {
319
+ const admin = id.startsWith("admin:");
320
+ out.push({
321
+ id,
322
+ name: id.replace(/[^a-zA-Z0-9_-]/g, "_"),
323
+ title: id,
324
+ description: id,
325
+ kind: admin ? "admin" : "rest",
326
+ surface: admin ? "admin" : "public",
327
+ surfaces: [admin ? "admin" : "rest"],
328
+ triggers: dependencies.flatMap((d) => d.triggers),
329
+ inputSchema,
330
+ annotations: {},
331
+ requires: admin ? { auth: { all: ["ctx.admin"] } } : dependencies[0]?.requires,
332
+ restrict: mergeRestrict(dependencies.map((d) => d.restrict), false),
333
+ schemas: [...new Set(dependencies.flatMap((d) => d.schemas))].sort(),
334
+ readSchemas: [...new Set(dependencies.flatMap((d) => d.readSchemas))].sort(),
335
+ readOnly: dependencies.length > 0 && dependencies.every((d) => d.readOnly) && (!admin || id.startsWith("admin:GET ") || id === "admin:POST /operations/:name" || id === "admin:POST /webmcp/:tool"),
336
+ opaque: dependencies.some((d) => d.opaque),
337
+ trustedOnly: dependencies.some((d) => d.trustedOnly),
338
+ variants: dependencies,
339
+ behavior: dependencies.map((d) => ({ id: d.id, behavior: d.behavior, surfaces: d.surfaces, triggers: d.triggers, input: d.inputSchema, requires: d.requires, restrict: d.restrict, trustedOnly: d.trustedOnly }))
340
+ });
341
+ };
342
+ const declarations = [...out];
343
+ const adminOperations = new Set(mcpTools(plan, "admin").filter((t) => t.kind === "procedure").map((t) => `procedure:${t.source}`));
344
+ for (const d of declarations) if (d.kind === "view" && d.surfaces.includes("public")) addRoute(`rest:GET /api/views/${d.id.slice(5)}`, [d], d.inputSchema);
345
+ for (const [, t] of Object.entries(plan.triggers).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) if (t.source.kind === "http") {
346
+ const d = declarations.find((d2) => d2.id === `procedure:${t.procedure}`);
347
+ addRoute(`rest:${t.source.method} ${pathTemplate(t.source.path)}`, [d], d.inputSchema);
348
+ }
349
+ const generated = [];
350
+ for (const [schema, s] of Object.entries(plan.schemas).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) if (s.publishing) for (const [verb, from, to] of publishingTransitions) {
351
+ addRoute(`procedure:${s.name}.${verb}`, [], publishingInput);
352
+ const d = out.at(-1);
353
+ const inspected = inspectBehavior(plan, void 0, false, void 0, void 0, [{ schema, operation: verb === "publish" ? "publish" : "update" }]);
354
+ Object.assign(d, {
355
+ kind: "procedure",
356
+ name: mcpToolNameSegment(`${verb}_${s.name}`),
357
+ surface: "admin",
358
+ surfaces: ["admin"],
359
+ requires: { auth: { all: ["ctx.admin"] } },
360
+ schemas: [.../* @__PURE__ */ new Set([schema, ...inspected.schemas])].sort(),
361
+ readSchemas: [.../* @__PURE__ */ new Set([schema, ...inspected.readSchemas])].sort(),
362
+ opaque: inspected.opaque,
363
+ behavior: { schema, verb, from, to, dependencies: inspected.dependencies }
364
+ });
365
+ generated.push(d);
366
+ }
367
+ for (const tool of mediaDefinitions()) {
368
+ addRoute(`admin:tool:${tool.name}`, [], tool.inputSchema);
369
+ const d = out.at(-1);
370
+ Object.assign(d, { name: tool.name, readOnly: tool.annotations.readOnlyHint, opaque: !tool.annotations.readOnlyHint, annotations: tool.annotations, behavior: { tool, schemas: plan.schemas } });
371
+ generated.push(d);
372
+ }
373
+ for (const route of adminRoutes) {
374
+ const deps = route.includes("/views/:") || route === "GET /view-batch" ? declarations.filter((d2) => d2.kind === "view" && (route.includes("/developer/") || plan.views[d2.id.slice(5)]?.surface === "admin")) : route.includes("/operations/:") ? declarations.filter((d2) => adminOperations.has(d2.id)) : route === "POST /webmcp/:tool" ? declarations.filter((d2) => mcpTools(plan, "admin").some((t) => `${t.kind}:${t.source}` === d2.id)).concat(generated) : [];
375
+ const generic = route.includes("/entries") || route.includes("/statistics") || route === "GET /bootstrap";
376
+ addRoute(`admin:${route}`, deps, deps.length && route !== "GET /view-batch" ? { ...objectInput, anyOf: deps.map((d2) => ({ type: "object", properties: { [route.includes("/webmcp/") ? "tool" : "name"]: { type: "string", const: route.includes("/webmcp/") ? d2.name : d2.id.slice(d2.kind === "view" ? 5 : 10) } } })) } : objectInput);
377
+ const d = out.at(-1);
378
+ if (generic) {
379
+ const operation = route === "POST /entries" ? "create" : route === "DELETE /entries/:id" ? "delete" : route.startsWith("GET ") ? void 0 : route.endsWith("/publish") ? "publish" : "update";
380
+ const inspected = inspectBehavior(plan, void 0, false, void 0, void 0, operation ? Object.keys(plan.schemas).map((schema) => ({ schema, operation })) : []);
381
+ d.schemas = Object.keys(plan.schemas).sort();
382
+ d.readSchemas = d.schemas;
383
+ d.opaque = inspected.opaque;
384
+ d.behavior = { schemas: plan.schemas, dependencies: inspected.dependencies };
385
+ }
386
+ }
387
+ return [...new Map(out.map((d) => [d.id, d])).values()].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
388
+ }
389
+
390
+ // src/domain/describe/target-hash.ts
391
+ async function hash(value) {
392
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(canonical(value)));
393
+ return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
394
+ }
395
+ function hashDefinition(plan, d) {
396
+ return hash({
397
+ id: d.id,
398
+ surfaces: d.surfaces,
399
+ triggers: d.triggers,
400
+ behavior: d.behavior,
401
+ input: d.inputSchema,
402
+ requires: d.requires,
403
+ restrict: d.restrict,
404
+ dialect: plan.dialect,
405
+ schemas: Object.fromEntries(d.schemas.map((name) => [name, plan.schemas[name]])),
406
+ userFields: plan.access?.userFields,
407
+ readOnly: d.readOnly,
408
+ opaque: d.opaque,
409
+ trustedOnly: d.trustedOnly
410
+ });
411
+ }
412
+ async function targetHash(plan, targetId) {
413
+ const target = targetDefinitions(plan).find((d) => d.id === targetId);
414
+ if (!target) throw new TypeError(`Unknown target '${targetId}'.`);
415
+ return hashDefinition(plan, target);
416
+ }
417
+
418
+ export {
419
+ canonical,
420
+ targetDefinitions,
421
+ hash,
422
+ hashDefinition,
423
+ targetHash
424
+ };
@@ -0,0 +1,58 @@
1
+ import type { RuntimePlan } from "../../build/compiler.js";
2
+ import type { PlanRestrict } from "../../build/spec/domain/model/RuntimePlan.js";
3
+ import type { UserFieldSpec } from "../../build/spec/domain/model/UserFields.js";
4
+ import { type TargetDefinition } from "./targets.js";
5
+ export { targetHash } from "./target-hash.js";
6
+ export interface DescribeTarget {
7
+ name: string;
8
+ title: string;
9
+ description: string;
10
+ inputSchema: import("../../build/compiler.js").JsonSchema;
11
+ annotations: import("../../build/spec/domain/model/ManifestGrammar.js").ProcedureMcpAnnotations;
12
+ _meta: {
13
+ surfaces: string[];
14
+ triggers: TargetDefinition["triggers"];
15
+ id: string;
16
+ targetHash: string;
17
+ readOnly: boolean;
18
+ scope: PlanRestrict;
19
+ restrict: PlanRestrict;
20
+ opaque: boolean;
21
+ unscopedReads: boolean;
22
+ trustedOnly: boolean;
23
+ variants: {
24
+ id: string;
25
+ scope: PlanRestrict;
26
+ restrict: PlanRestrict;
27
+ requires: Requirements;
28
+ inputSchema: DescribeTarget["inputSchema"];
29
+ readOnly: boolean;
30
+ trustedOnly: boolean;
31
+ opaque: boolean;
32
+ unscopedReads: boolean;
33
+ }[];
34
+ requires: Requirements;
35
+ };
36
+ }
37
+ interface Requirements {
38
+ all: readonly (string | {
39
+ readonly "ctx.auth.scope": string;
40
+ })[];
41
+ guard?: string;
42
+ }
43
+ export interface AppDescription {
44
+ schemaVersion: 1;
45
+ access: Readonly<Record<string, UserFieldSpec>>;
46
+ targets: DescribeTarget[];
47
+ }
48
+ /** A report of sealed declarations; no SQL or row values leave this function. */
49
+ export declare function describeApp(plan: RuntimePlan): Promise<AppDescription>;
50
+ export interface AppChange {
51
+ id: string;
52
+ field: string;
53
+ direction: "widened" | "narrowed" | "changed";
54
+ before?: unknown;
55
+ after?: unknown;
56
+ }
57
+ /** Report widening on any reachable surface or dispatcher variant. */
58
+ export declare function diffApp(a: AppDescription, b: AppDescription): AppChange[];
@@ -0,0 +1,115 @@
1
+ import {
2
+ canonical,
3
+ hashDefinition,
4
+ targetDefinitions,
5
+ targetHash
6
+ } from "./chunk-ZVXBGP7Y.js";
7
+
8
+ // src/domain/describe/index.ts
9
+ function requirements(d, surface) {
10
+ const all = d.requires?.auth?.all ?? [];
11
+ return {
12
+ all: surface === "admin" && !all.includes("ctx.admin") ? ["ctx.admin", ...all] : all,
13
+ ...d.requires?.guard ? { guard: d.requires.guard.procedure } : {}
14
+ };
15
+ }
16
+ async function describeApp(plan) {
17
+ const targets = await Promise.all(targetDefinitions(plan).map(async (d) => {
18
+ const scope = Object.fromEntries(d.schemas.map((name) => {
19
+ const s = plan.schemas[name];
20
+ return [name, { ...s.scope ? { owner: s.scope } : {}, terms: s.userScopes ?? [] }];
21
+ }));
22
+ return { name: d.name, title: d.title, description: d.description, inputSchema: d.inputSchema, annotations: { ...d.annotations, readOnlyHint: d.readOnly }, _meta: {
23
+ surfaces: d.surfaces,
24
+ triggers: d.triggers,
25
+ id: d.id,
26
+ targetHash: await hashDefinition(plan, d),
27
+ readOnly: d.readOnly,
28
+ scope,
29
+ restrict: d.restrict,
30
+ opaque: d.opaque,
31
+ unscopedReads: d.readSchemas.some((name) => !plan.schemas[name]?.scope && !plan.schemas[name]?.userScopes?.length),
32
+ trustedOnly: d.trustedOnly,
33
+ variants: d.variants.map((v) => ({
34
+ id: v.id,
35
+ restrict: v.restrict,
36
+ requires: requirements(v, d.surface),
37
+ inputSchema: v.inputSchema,
38
+ readOnly: v.readOnly,
39
+ trustedOnly: v.trustedOnly,
40
+ opaque: v.opaque,
41
+ unscopedReads: v.readSchemas.some((name) => !plan.schemas[name]?.scope && !plan.schemas[name]?.userScopes?.length),
42
+ scope: Object.fromEntries(v.schemas.map((name) => {
43
+ const s = plan.schemas[name];
44
+ return [name, { ...s.scope ? { owner: s.scope } : {}, terms: s.userScopes ?? [] }];
45
+ }))
46
+ })),
47
+ requires: requirements(d, d.surface)
48
+ } };
49
+ }));
50
+ return JSON.parse(canonical({ schemaVersion: 1, access: plan.access?.userFields ?? {}, targets }));
51
+ }
52
+ var securityFlags = ["readOnly", "trustedOnly", "opaque", "unscopedReads"];
53
+ var flagDirection = (field, value) => (field === "readOnly" || field === "trustedOnly" ? !value : value) ? "widened" : "narrowed";
54
+ var inclusion = (before, after) => before.some((t) => !after.includes(t)) ? "widened" : after.some((t) => !before.includes(t)) ? "narrowed" : "changed";
55
+ var exposureDirection = (before, after) => after.some((t) => !before.includes(t) && t !== canonical("internal")) ? "widened" : before.some((t) => !after.includes(t) && t !== canonical("internal")) ? "narrowed" : "changed";
56
+ var combine = (directions) => directions.includes("widened") ? "widened" : directions.length && directions.every((d) => d === "narrowed") ? "narrowed" : "changed";
57
+ var terms = (p) => [...p.owner ? [canonical({ owner: p.owner })] : [], ...p.terms.map(canonical)];
58
+ function policyDirection(before, after, scope) {
59
+ const directions = [];
60
+ for (const schema of /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])) {
61
+ const x = before[schema], y = after[schema];
62
+ if (canonical(x) === canonical(y)) continue;
63
+ directions.push(scope && (!x || !y) ? x ? "narrowed" : "widened" : inclusion(x ? terms(x) : [], y ? terms(y) : []));
64
+ }
65
+ return combine(directions);
66
+ }
67
+ function requiresDirection(x, y) {
68
+ const directions = [];
69
+ if (canonical(x.all) !== canonical(y.all)) directions.push(inclusion(x.all.map(canonical), y.all.map(canonical)));
70
+ if (x.guard !== y.guard) directions.push(!y.guard ? "widened" : !x.guard ? "narrowed" : "changed");
71
+ return combine(directions);
72
+ }
73
+ function diffApp(a, b) {
74
+ if (a.schemaVersion !== 1 || b.schemaVersion !== 1) throw new TypeError("Unsupported describe schemaVersion.");
75
+ const changes = [], old = new Map(a.targets.map((t) => [t._meta.id, t])), next = new Map(b.targets.map((t) => [t._meta.id, t]));
76
+ for (const id of [.../* @__PURE__ */ new Set([...old.keys(), ...next.keys()])].sort()) {
77
+ const before = old.get(id), after = next.get(id);
78
+ if (!before || !after) {
79
+ changes.push({ id, field: "target", direction: before ? "narrowed" : "widened" });
80
+ continue;
81
+ }
82
+ const x = before._meta, y = after._meta, start = changes.length;
83
+ const record = (field, left, right, direction) => {
84
+ if (canonical(left) !== canonical(right)) changes.push({ id, field, direction, before: left, after: right });
85
+ };
86
+ record("scope", x.scope, y.scope, policyDirection(x.scope, y.scope, true));
87
+ record("restrict", x.restrict, y.restrict, policyDirection(x.restrict, y.restrict, false));
88
+ record("requires", x.requires, y.requires, requiresDirection(x.requires, y.requires));
89
+ for (const field of ["surfaces", "triggers"]) record(field, x[field], y[field], exposureDirection(x[field].map(canonical), y[field].map(canonical)));
90
+ for (const field of securityFlags) record(field, x[field], y[field], flagDirection(field, y[field]));
91
+ record("inputSchema", before.inputSchema, after.inputSchema, "changed");
92
+ const directions = [];
93
+ const variants = new Map(x.variants.map((v) => [v.id, v])), added = new Map(y.variants.map((v) => [v.id, v]));
94
+ for (const name of /* @__PURE__ */ new Set([...variants.keys(), ...added.keys()])) {
95
+ const left = variants.get(name), right = added.get(name);
96
+ if (canonical(left) === canonical(right)) continue;
97
+ if (!left || !right) directions.push(left ? "narrowed" : "widened");
98
+ else {
99
+ if (canonical(left.scope) !== canonical(right.scope)) directions.push(policyDirection(left.scope, right.scope, true));
100
+ if (canonical(left.restrict) !== canonical(right.restrict)) directions.push(policyDirection(left.restrict, right.restrict, false));
101
+ if (canonical(left.requires) !== canonical(right.requires)) directions.push(requiresDirection(left.requires, right.requires));
102
+ if (canonical(left.inputSchema) !== canonical(right.inputSchema)) directions.push("changed");
103
+ for (const field of securityFlags) if (left[field] !== right[field]) directions.push(flagDirection(field, right[field]));
104
+ }
105
+ }
106
+ record("variants", x.variants, y.variants, combine(directions));
107
+ if (changes.length === start && x.targetHash !== y.targetHash) changes.push({ id, field: "behavior", direction: "changed" });
108
+ }
109
+ return changes;
110
+ }
111
+ export {
112
+ describeApp,
113
+ diffApp,
114
+ targetHash
115
+ };
@@ -0,0 +1,8 @@
1
+ import type { RuntimePlan } from "../../build/compiler.js";
2
+ import { type TargetDefinition } from "./targets.js";
3
+ import { canonical } from "../../build/spec/domain/service/PlanFingerprint.js";
4
+ export { canonical };
5
+ export declare function hash(value: unknown): Promise<string>;
6
+ export declare function hashDefinition(plan: RuntimePlan, d: TargetDefinition): Promise<string>;
7
+ /** Opt-in runtime export. No compiler, parser, database or Node API is loaded. */
8
+ export declare function targetHash(plan: RuntimePlan, targetId: string): Promise<string>;
@@ -0,0 +1,12 @@
1
+ import {
2
+ canonical,
3
+ hash,
4
+ hashDefinition,
5
+ targetHash
6
+ } from "./chunk-ZVXBGP7Y.js";
7
+ export {
8
+ canonical,
9
+ hash,
10
+ hashDefinition,
11
+ targetHash
12
+ };
@@ -0,0 +1,40 @@
1
+ import type { RuntimePlan } from "../../build/compiler.js";
2
+ import type { PlanRestrict } from "../../build/spec/domain/model/RuntimePlan.js";
3
+ import { type JsonSchema, type AuthorizationRequirements, type ProcedureMcpAnnotations } from "../../build/spec/domain/model/ManifestGrammar.js";
4
+ export interface TargetDefinition {
5
+ id: string;
6
+ name: string;
7
+ surface: string;
8
+ surfaces: string[];
9
+ triggers: {
10
+ id: string;
11
+ source: RuntimePlan["triggers"][string]["source"];
12
+ }[];
13
+ kind: "view" | "procedure" | "rest" | "admin";
14
+ title: string;
15
+ description: string;
16
+ inputSchema: JsonSchema;
17
+ annotations: ProcedureMcpAnnotations;
18
+ requires?: AuthorizationRequirements;
19
+ restrict: PlanRestrict;
20
+ schemas: string[];
21
+ readSchemas: string[];
22
+ readOnly: boolean;
23
+ opaque: boolean;
24
+ trustedOnly: boolean;
25
+ behavior: unknown;
26
+ variants: TargetDefinition[];
27
+ }
28
+ /** Walk sealed IR, including nested statements and expanded View dependencies. */
29
+ export declare function inspectSql(value: unknown): {
30
+ schemas: string[];
31
+ readSchemas: string[];
32
+ readOnly: boolean;
33
+ writes: {
34
+ schema: string;
35
+ operation: string;
36
+ }[];
37
+ };
38
+ /** Built-in Admin API templates, relative to the configured Admin API base. */
39
+ export declare const adminRoutes: readonly ["GET /me", "GET /site", "GET /collections", "GET /views-manifest", "GET /operations", "GET /webmcp", "POST /webmcp/:tool", "GET /bootstrap", "GET /views/:name/export", "GET /views/:name", "GET /view-batch", "GET /developer/views/:name", "POST /operations/:name", "GET /developer-console", "GET /collections/:name/statistics", "GET /entries", "GET /entries/export", "GET /entries/:id", "POST /entries", "PATCH /entries/:id", "POST /entries/:id/publish", "POST /entries/:id/unpublish", "POST /entries/:id/archive", "DELETE /entries/:id", "GET /site-settings", "PATCH /site-settings", "POST /media/uploads", "POST /media/uploads/:groupId/commit", "GET /media", "GET /media/:id", "PATCH /media/:id", "DELETE /media/:id", "GET /admin", "GET /members", "PATCH /admin/:id/role", "POST /admin/invitations", "DELETE /admin/invitations/:id"];
40
+ export declare function targetDefinitions(plan: RuntimePlan): TargetDefinition[];