@aotter/mantle 0.2.0-alpha.7 → 0.2.0-alpha.9

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 (126) hide show
  1. package/README.md +27 -5
  2. package/dist/auth/adapter.js +9 -6
  3. package/dist/auth/caller.js +2 -1
  4. package/dist/auth/identity.d.ts +2 -2
  5. package/dist/auth/oauth.d.ts +33 -1
  6. package/dist/auth/oauth.js +121 -28
  7. package/dist/auth/routes.js +6 -4
  8. package/dist/build/compiler.d.ts +44 -122
  9. package/dist/build/compiler.js +202 -277
  10. package/dist/build/spec/domain/model/ManifestGrammar.d.ts +6 -5
  11. package/dist/build/spec/domain/model/SqlIr.d.ts +2 -0
  12. package/dist/build/spec/domain/service/PlanFingerprint.d.ts +2 -0
  13. package/dist/build/spec/kernel/diagnostic.d.ts +1 -1
  14. package/dist/domain/describe/{chunk-ZIQVLA7X.js → chunk-ZVXBGP7Y.js} +69 -8
  15. package/dist/domain/describe/index.js +1 -1
  16. package/dist/domain/describe/target-hash.js +1 -1
  17. package/dist/domain/describe/targets.d.ts +1 -1
  18. package/dist/domain/generated-tools.js +2 -0
  19. package/dist/domain/paging.js +41 -15
  20. package/dist/infrastructure/bundle.js +118 -15
  21. package/dist/infrastructure/cli.js +11 -15
  22. package/dist/infrastructure/generate.d.ts +1 -3
  23. package/dist/infrastructure/generate.js +11 -3
  24. package/dist/infrastructure/generateAuth.js +57 -0
  25. package/dist/infrastructure/inputs.js +8 -3
  26. package/dist/infrastructure/wrangler.js +50 -12
  27. package/dist/kernel/binds.d.ts +0 -3
  28. package/dist/kernel/contracts.d.ts +1 -1
  29. package/dist/kernel/contracts.js +4 -4
  30. package/dist/kernel/dialect/common.d.ts +0 -1
  31. package/dist/kernel/drain.d.ts +5 -0
  32. package/dist/kernel/drain.js +35 -0
  33. package/dist/kernel/driver/postgres.js +6 -2
  34. package/dist/kernel/host-caller.d.ts +1 -0
  35. package/dist/kernel/host-caller.js +1 -0
  36. package/dist/kernel/mcp-apps.d.ts +29 -9
  37. package/dist/kernel/mcp-apps.js +3 -3
  38. package/dist/kernel/mcp-handler.js +101 -18
  39. package/dist/kernel/mcp.d.ts +12 -3
  40. package/dist/kernel/mcp.js +31 -6
  41. package/dist/kernel/rest-router.js +3 -2
  42. package/dist/kernel/scalars.js +3 -2
  43. package/dist/kernel/site.d.ts +1 -3
  44. package/dist/kernel/site.js +2 -2
  45. package/dist/kernel/web-index.js +40 -0
  46. package/dist/kernel/web.d.ts +3 -1
  47. package/dist/kernel/web.js +6 -37
  48. package/dist/usecase/adminBindings.js +2 -3
  49. package/dist/usecase/adminClient.js +87 -0
  50. package/dist/usecase/adminDescriptors.js +19 -65
  51. package/dist/usecase/generate.js +5 -4
  52. package/dist/usecase/mcp-media.js +2 -2
  53. package/dist/usecase/mcp.js +16 -12
  54. package/dist/usecase/paging.js +2 -3
  55. package/dist/usecase/publishing.js +3 -3
  56. package/dist/usecase/site.js +0 -1
  57. package/dist/usecase/tool-version.js +9 -0
  58. package/dist/usecase/translations.js +1 -1
  59. package/dist/usecase/validation.js +128 -19
  60. package/dist/usecase/web.js +3 -2
  61. package/docs/examples/README.md +1 -1
  62. package/docs/examples/app-shell/README.md +45 -3
  63. package/docs/examples/app-shell/package.json +14 -6
  64. package/docs/examples/app-shell/smoke-kit.mjs +54 -0
  65. package/docs/examples/app-shell/src/auth.ts +6 -3
  66. package/docs/examples/app-shell/src/service.ts +3 -3
  67. package/docs/examples/app-shell/tsconfig.json +4 -1
  68. package/docs/examples/app-shell/worker-configuration.d.ts +2 -2
  69. package/docs/examples/app-shell/wrangler.jsonc +5 -4
  70. package/docs/examples/club-events/manifests/club-events.yaml +7 -0
  71. package/docs/examples/club-events/src/handlers.ts +1 -1
  72. package/docs/examples/generated-web/README.md +6 -2
  73. package/docs/examples/generated-web/wrangler.jsonc +1 -0
  74. package/docs/examples/purchasing/README.md +1 -1
  75. package/docs/examples/purchasing/manifests/purchasing.yaml +17 -1
  76. package/docs/examples/purchasing/smoke.mjs +10 -4
  77. package/docs/examples/purchasing/src/admin.tsx +13 -0
  78. package/docs/examples/purchasing/src/handlers.ts +1 -1
  79. package/docs/examples/purchasing/wrangler.jsonc +5 -4
  80. package/docs/examples/recipes/wrangler.jsonc +5 -4
  81. package/docs/handbook/cloudflare/authentication.md +43 -6
  82. package/docs/handbook/cloudflare/chatgpt-sites.md +4 -2
  83. package/docs/handbook/cloudflare/deploy-and-operate.md +45 -1
  84. package/docs/handbook/cloudflare/media-r2.md +2 -3
  85. package/docs/handbook/cloudflare/service-entry.md +68 -31
  86. package/docs/handbook/concepts/authorization.md +1 -1
  87. package/docs/handbook/concepts/mcp-and-agents.md +19 -0
  88. package/docs/handbook/concepts/runtime-and-adapters.md +1 -1
  89. package/docs/handbook/examples/hub.md +1 -1
  90. package/docs/handbook/guides/admin-ui.md +107 -1
  91. package/docs/handbook/guides/agent-setup.md +27 -9
  92. package/docs/handbook/guides/agent-workflow-acceptance.md +222 -0
  93. package/docs/handbook/guides/mcp-apps.md +522 -6
  94. package/docs/handbook/guides/native-admin.md +300 -51
  95. package/docs/handbook/guides/oauth.md +119 -5
  96. package/docs/handbook/guides/public-pages.md +2 -2
  97. package/docs/handbook/guides/size-and-startup.md +1 -1
  98. package/docs/handbook/guides/typed-queries.md +35 -0
  99. package/docs/handbook/navigation.json +0 -4
  100. package/docs/handbook/reference/admin-descriptors.md +0 -35
  101. package/docs/handbook/reference/procedure.md +6 -2
  102. package/docs/handbook/reference/schema.md +13 -3
  103. package/docs/handbook/reference/surface.md +129 -15
  104. package/docs/handbook/reference/trigger.md +43 -1
  105. package/docs/handbook/reference/view.md +1 -1
  106. package/docs/handbook/releases/index.md +74 -2
  107. package/docs/handbook/start/overview.md +1 -1
  108. package/docs/handbook/start/project-and-cli.md +16 -8
  109. package/docs/handbook/start/quickstart-worker.md +1 -1
  110. package/docs/skills/develop/SKILL.md +46 -18
  111. package/docs/skills/integrate/SKILL.md +4 -9
  112. package/docs/skills/media-gc/SKILL.md +7 -5
  113. package/docs/skills/provision/SKILL.md +18 -12
  114. package/docs/skills/update/SKILL.md +19 -18
  115. package/docs/upgrade-0.1-to-0.2.md +6 -6
  116. package/package.json +2 -1
  117. package/skills/README.md +11 -16
  118. package/skills/mantle/SKILL.md +39 -17
  119. package/skills/mantle/references/local-testing.md +9 -0
  120. package/skills/mantle/references/web.md +1 -1
  121. package/skills/mantle/references/website.md +26 -22
  122. package/docs/examples/app-shell/src/admin.ts +0 -10
  123. package/docs/examples/purchasing/src/admin.ts +0 -12
  124. package/docs/handbook/guides/admin-extensions.md +0 -20
  125. package/docs/skills/develop/mcp-app.md +0 -39
  126. package/skills/.keep +0 -0
@@ -7,19 +7,21 @@ selected host's frontend kit before choosing APIs. Native applications use
7
7
  their installed `docs/handbook/guides/native-admin.md` and the
8
8
  [web contract](web.md).
9
9
 
10
- - Link to host-provided Mantle Admin UI and configured tenant OTP; do not emit frontend assets under host-owned /admin routes. Add visitor sign-in only where
11
- needed. Do not build a second identity store or configure another mail provider
12
- when the host already supplies one. Backend permissions enforce roles and data
13
- access; Host membership is not application admin access.
10
+ - For self-hosted applications, build Admin with `mantle bundle` and serve it as
11
+ the installed `docs/handbook/guides/native-admin.md` describes. The application
12
+ owns auth, OTP delivery and verified Caller wiring; use a console/test sender
13
+ locally and configure production email for deployment. If a host already
14
+ supplies identity/Admin, reuse its explicit contract and reserved routes.
15
+ Add visitor sign-in where needed. Backend permissions enforce roles and data
16
+ access; host membership alone is not application admin authority.
14
17
  - Integrate image selection/upload into content editing through the existing
15
- Admin media library and host storage. Follow the pinned Core upload/PUT/commit
16
- contract and `x-mantle-ref: media_assets` plus `x-mcp-hint: media-image`; store committed asset IDs, resolve permanent variants in the frontend, never use an ID as an image URL. Tenant `/mcp/admin` supplies `get_media_upload_policy` → `create_media_upload` → direct HTTP PUT → `commit_media_upload` when its shared media adapter is wired. Follow the pinned media docs for tenant admin authentication (historical Core
17
- uses admin); host project credentials are not application credentials. Upload capability URLs are temporary,
18
+ Admin media library and the application's selected storage. Follow the pinned Core upload/PUT/commit
19
+ contract and `x-mantle-ref: media_assets` plus `x-mcp-hint: media-image`; store committed asset IDs, resolve permanent variants in the frontend, never use an ID as an image URL. The application's `/mcp/admin` supplies `get_media_upload_policy` → `create_media_upload` → direct HTTP PUT → `commit_media_upload` when its shared media adapter is wired. Follow the installed media authentication contract; host project credentials are not application credentials. Upload capability URLs are temporary,
18
20
  not committed public images; anonymous visitors must not gain admin media access.
19
21
  - Generate an accessible, responsive public frontend by reading the installed
20
- `@aotter/mantle/web` REST contract; browser code on static hosts uses
22
+ generated `web.ts` and REST contracts; browser code on static hosts uses
21
23
  same-origin fetch, not a server surface imported into the browser. Do not install the historical standalone
22
- `@aotter/mantle-web` or claim Core supplies an HTML renderer. Application-owned `service.fetch` may render HTML; follow the selected host's static/template and pairing restrictions.
24
+ `@aotter/mantle-web` or claim Core supplies an HTML renderer. The application-owned Fetch entry renders HTML; follow the selected host's static/template restrictions.
23
25
  - Public content follows the installed `docs/handbook/guides/public-pages.md`
24
26
  (the one list of head tags, JSON-LD, languages, Markdown, sitemap, robots and
25
27
  `llms.txt`). For public content on static hosts disable SPA fallback and check unknown URLs
@@ -32,16 +34,18 @@ uses admin); host project credentials are not application credentials. Upload ca
32
34
  dependency; a dynamic blog is blocked until that path exists. Do not silently
33
35
  substitute build-time sample content for live tenant content.
34
36
 
35
- Before upload, follow the [local HTTP acceptance](local-testing.md): native HTTP HTML responses need no browser or deployment. Before reporting completion, inspect HTML without executing JavaScript, check
36
- metadata/sitemap and anonymous draft/permission refusal, and exercise OTP,
37
- content editing and media upload/commit with authorized synthetic accounts.
38
- Read the host's preview capability limits: disabled mail/media checks stay
39
- pending, not passed. Use candidate preview first, then an existing explicitly authorized live test
40
- tenant with authorized admin accounts for disabled services. Do not create or
41
- publish a test tenant without authorization. Live tests require
42
- explicit authorization for synthetic writes and cleanup. Without a published
43
- test tenant or that authorization, report them pending.
44
- Do not weaken preview isolation, fake success or grant admin privileges outside the authorized test scope to make
45
- checks pass. Provenance/pairing review does not certify website quality; report
46
- passed, failed and blocked checks separately. Pending required checks also
47
- block completion.
37
+ Follow the [local HTTP acceptance](local-testing.md) before reporting local
38
+ readiness: inspect HTML without JavaScript, check metadata/sitemap and anonymous
39
+ draft/permission refusal, and exercise OTP and editing with isolated synthetic
40
+ accounts. Local readiness does not require publication, a hosted tenant or a
41
+ candidate preview. Scripted local acceptance does not replace the installed
42
+ independent acceptance guide, which is required before reporting the pages done.
43
+ Report production email, public origin and real object-store upload/commit checks
44
+ separately when local capabilities cannot exercise them.
45
+
46
+ For an explicitly requested deployment, use the selected host's native workflow
47
+ and any preview it provides. Verify disabled preview capabilities on an already
48
+ authorized live target; synthetic writes and cleanup stay within that scope.
49
+ Pending production checks block a production-readiness claim, not an otherwise
50
+ passing local-development handoff. Preserve preview isolation and permissions;
51
+ report passed, failed and blocked checks for each environment separately.
@@ -1,10 +0,0 @@
1
- import type { AdminExtension, AdminNavGroup } from "@aotter/mantle-admin/server/extensions";
2
-
3
- /**
4
- * Admin presentation, read by `mantle generate --admin-extensions src/admin.ts` (no runtime code).
5
- * AGENT: to group the sidebar for how staff work, declare groups here and place Schemas and admin Views in them with
6
- * `uiSchema.nav: { group, order, hidden }` (docs/handbook/guides/native-admin.md, "Sidebar"). Built-in groups need no
7
- * declaration: content, operations, reports, more. Admin extensions also go here.
8
- */
9
- export const navGroups: AdminNavGroup[] = [];
10
- export const adminExtensions: AdminExtension[] = [];
@@ -1,12 +0,0 @@
1
- import type { AdminExtension, AdminNavGroup } from "@aotter/mantle-admin/server/extensions";
2
-
3
- /**
4
- * Admin presentation, read by `mantle generate --admin-extensions src/admin.ts` (no runtime code).
5
- * The approver's daily work gets its own sidebar group above Admin's built-in ones (content 10, operations 20,
6
- * reports 30; More stays last); manifests place `pending-requests` and `requests` in it with `uiSchema.nav`.
7
- * AGENT: add groups for how the staff work; titles take one string or a { locale: text } map.
8
- */
9
- export const navGroups: AdminNavGroup[] = [
10
- { id: "approvals", title: { en: "Approvals", "zh-TW": "簽核" }, order: 5 },
11
- ];
12
- export const adminExtensions: AdminExtension[] = [];
@@ -1,20 +0,0 @@
1
- # Extend Admin
2
-
3
- Native Admin accepts app-owned extension declarations, executable server handlers and optional same-origin client modules. Import client `defineAdminExtension` from `@aotter/mantle-admin/extension` and UI primitives from `@aotter/mantle-ui/kit`. Server types live in `@aotter/mantle-admin/server`.
4
-
5
- | Contribution | Placement |
6
- | --- | --- |
7
- | pages/settings | Extension page; settings forms are generated from the supported form subset |
8
- | actions | record, list selection or list toolbar |
9
- | panels | record sidebar or home |
10
- | fields | field input or cell |
11
-
12
- Admin contributions sit behind the admin-layer gate; optional field roles default to `admin`. Server authorization is checked on every route. Handlers own finer business permissions.
13
-
14
- Pass full declarations to `mantle generate … --admin --admin-extensions <module>` (named/default `adminExtensions` array). Generation checks contributions, manifest uiSchema references and settings schemas, then emits `extensionMetadata` and compiled `extensionBindings` in `admin-extensions.ts`. Bind the same runtime definitions with `extensionBindings(adminExtensions)` and merge its extensions/routes into `admin()` options. Drift is refused before execution.
15
-
16
- Serve each `module` at a same-origin absolute path and install its integrity in the host shell's import map. Native Admin does not serve `source` modules or inject integrity; generation rejects source. Share React and the UI kit via the built import map, rather than bundling a second React. Canonical Admin refuses framing; use its separate same-origin preview contract.
17
-
18
- Raw API handlers receive the original Request. Declared `bodyLimit` checks Content-Length before DB access, but the app must bound unknown-length streams. Built-in JSON routes use the shared bounded reader after caller/origin checks. Do not lose exact OCC or uncertain-outcome handling in custom actions.
19
-
20
- See [native Admin](native-admin.md) for mounting and acceptance and [generated descriptors](../reference/admin-descriptors.md) for build-time metadata.
@@ -1,39 +0,0 @@
1
- # Recipe: an MCP App for members
2
-
3
- ## Native applications
4
-
5
- Read the installed MCP App contract. The SDK's generic hook attaches only the resources the app selects;
6
- only selected modules enter the service.
7
-
8
- ```ts
9
- import type { McpApps } from '@aotter/mantle/mcp';
10
- import { mcp } from '../generated/mcp.js';
11
- const memberApp: McpApps = { resources: [{
12
- uri: 'ui://shop/my-orders',
13
- name: 'my-orders-app',
14
- renders: ['my_orders'], // the tool for the declared public View my-orders
15
- html: async () => (await import('./member-app.js')).memberHtml,
16
- }] };
17
- const tools = mcp({ db, caller, handlers, apps: { public: memberApp } });
18
- ```
19
-
20
- Each endpoint accepts one contributor or an array. The separate
21
- `@aotter/mantle-admin` package contributes its admin App through this same
22
- `apps.admin` hook; it owns `ui://mantle-admin/…`. App resources use their own
23
- `ui://<app>/…` namespace. Duplicate resource URI/name, conflicting `renders`,
24
- or `renders`/`appOnly` naming an unavailable endpoint tool (or a Procedure for
25
- `appOnly`) fail when `mcp(...)` is built; with a request-bound tool table, the
26
- tool names are checked on the first matching request. Only clients that
27
- declare no MCP Apps support see no UI resources; a request that advertises no
28
- capabilities at all is treated as supported.
29
-
30
- Use `renders` for a declared tool; `appOnly` optionally hides it from non-UI
31
- clients. Import HTML lazily; it carries no secrets or caller data. Tool results
32
- use the caller's SQL policy, and an App cannot authorize a hidden admin tool.
33
- Generic interaction components and controllers remain in `@aotter/mantle-ui`;
34
- Admin-specific controllers/catalogues belong to `@aotter/mantle-admin`.
35
-
36
- Verify tools/list metadata, resources/read, actual tool calls and a host-rendered
37
- member App. Test anonymous/member isolation and resource conflicts. Never retry
38
- unknown writes blindly; retain OCC and re-read state after an uncertain outcome.
39
- Commit generated output and run generation with `--check` before deployment.
package/skills/.keep DELETED
File without changes