@plitzi/sdk-mcp 0.39.1 → 0.39.2

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 (193) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +5 -1
  3. package/dist/createServer.d.ts +3 -2
  4. package/dist/createServer.js +3 -13
  5. package/dist/index.js +8 -8
  6. package/dist/modules/mcp/accessibilityOutline.js +1 -2
  7. package/dist/modules/mcp/apps/index.js +3 -4
  8. package/dist/modules/mcp/apps/render/index.js +3 -7
  9. package/dist/modules/mcp/apps/render/styles.js +2 -3
  10. package/dist/modules/mcp/apps/shared/assets.d.ts +6 -0
  11. package/dist/modules/mcp/apps/shared/assets.js +15 -4
  12. package/dist/modules/mcp/apps/shared/bundle.js +3 -4
  13. package/dist/modules/mcp/apps/shared/index.d.ts +1 -1
  14. package/dist/modules/mcp/apps/shared/page.js +3 -5
  15. package/dist/modules/mcp/apps/shared/registerApp.js +1 -2
  16. package/dist/modules/mcp/apps/shared/resolve.js +1 -2
  17. package/dist/modules/mcp/apps/shared/zodEnglishOnly.js +1 -2
  18. package/dist/modules/mcp/catalogs/observed.js +1 -2
  19. package/dist/modules/mcp/catalogs/pluginCatalog.d.ts +1 -1
  20. package/dist/modules/mcp/catalogs/pluginCatalog.js +1 -2
  21. package/dist/modules/mcp/catalogs/registry.d.ts +2 -1
  22. package/dist/modules/mcp/catalogs/registry.js +1 -2
  23. package/dist/modules/mcp/handler.d.ts +1 -1
  24. package/dist/modules/mcp/handler.js +1 -2
  25. package/dist/modules/mcp/helpers/callToolResult.js +1 -2
  26. package/dist/modules/mcp/helpers/components.js +1 -2
  27. package/dist/modules/mcp/helpers/computeVersion.js +1 -2
  28. package/dist/modules/mcp/helpers/guide/index.js +1 -2
  29. package/dist/modules/mcp/helpers/guide/instructions.js +1 -2
  30. package/dist/modules/mcp/helpers/guide/logic.js +1 -2
  31. package/dist/modules/mcp/helpers/guide/practice.js +4 -4
  32. package/dist/modules/mcp/helpers/guide/reference.js +1 -2
  33. package/dist/modules/mcp/helpers/guide/server.d.ts +1 -1
  34. package/dist/modules/mcp/helpers/guide/server.js +3 -4
  35. package/dist/modules/mcp/helpers/guide/structure.js +1 -2
  36. package/dist/modules/mcp/helpers/guide/styling.js +1 -2
  37. package/dist/modules/mcp/helpers/guide/values.js +1 -2
  38. package/dist/modules/mcp/helpers/interactions.js +1 -2
  39. package/dist/modules/mcp/helpers/log.d.ts +1 -1
  40. package/dist/modules/mcp/helpers/log.js +2 -3
  41. package/dist/modules/mcp/helpers/opResult.js +1 -2
  42. package/dist/modules/mcp/helpers/space.d.ts +2 -1
  43. package/dist/modules/mcp/helpers/space.js +1 -2
  44. package/dist/modules/mcp/helpers/uris.js +1 -2
  45. package/dist/modules/mcp/localScreenshotClient.js +9 -6
  46. package/dist/modules/mcp/previewClient.js +1 -2
  47. package/dist/modules/mcp/proxy/config.d.ts +1 -1
  48. package/dist/modules/mcp/proxy/config.js +2 -3
  49. package/dist/modules/mcp/proxy/fetch.js +1 -2
  50. package/dist/modules/mcp/proxy/grant.js +1 -2
  51. package/dist/modules/mcp/proxy/guard.js +2 -3
  52. package/dist/modules/mcp/proxy/handler.d.ts +1 -1
  53. package/dist/modules/mcp/proxy/handler.js +2 -3
  54. package/dist/modules/mcp/proxy/payload.js +1 -2
  55. package/dist/modules/mcp/proxy/rewrite.js +1 -2
  56. package/dist/modules/mcp/proxy/sign.js +1 -2
  57. package/dist/modules/mcp/proxy/types.js +1 -2
  58. package/dist/modules/mcp/resources/actions.js +2 -3
  59. package/dist/modules/mcp/resources/canonical.js +1 -2
  60. package/dist/modules/mcp/resources/connectors.js +2 -3
  61. package/dist/modules/mcp/resources/core.js +4 -5
  62. package/dist/modules/mcp/resources/data.js +1 -2
  63. package/dist/modules/mcp/resources/envelope.js +1 -2
  64. package/dist/modules/mcp/resources/explain.js +1 -2
  65. package/dist/modules/mcp/resources/functions.js +1 -2
  66. package/dist/modules/mcp/resources/primer.js +7 -8
  67. package/dist/modules/mcp/resources/register.d.ts +1 -1
  68. package/dist/modules/mcp/resources/register.js +6 -7
  69. package/dist/modules/mcp/resources/renderGuide.js +2 -3
  70. package/dist/modules/mcp/resources/router.js +3 -4
  71. package/dist/modules/mcp/resources/schema.js +3 -4
  72. package/dist/modules/mcp/resources/style.js +2 -3
  73. package/dist/modules/mcp/screenshotClient.js +6 -5
  74. package/dist/modules/mcp/server.d.ts +1 -1
  75. package/dist/modules/mcp/server.js +4 -5
  76. package/dist/modules/mcp/tools/activity.js +1 -2
  77. package/dist/modules/mcp/tools/apply/dispatch.js +4 -5
  78. package/dist/modules/mcp/tools/apply/index.d.ts +4 -0
  79. package/dist/modules/mcp/tools/apply/index.js +3 -4
  80. package/dist/modules/mcp/tools/apply/writeResult.js +1 -2
  81. package/dist/modules/mcp/tools/describeOperation.js +2 -3
  82. package/dist/modules/mcp/tools/index.js +1 -2
  83. package/dist/modules/mcp/tools/intents.js +3 -4
  84. package/dist/modules/mcp/tools/look.js +2 -3
  85. package/dist/modules/mcp/tools/operations/actions/deleteAction.js +2 -3
  86. package/dist/modules/mcp/tools/operations/actions/document.d.ts +2 -0
  87. package/dist/modules/mcp/tools/operations/actions/document.js +4 -3
  88. package/dist/modules/mcp/tools/operations/actions/index.d.ts +4 -0
  89. package/dist/modules/mcp/tools/operations/actions/index.js +1 -2
  90. package/dist/modules/mcp/tools/operations/actions/patchAction.d.ts +2 -0
  91. package/dist/modules/mcp/tools/operations/actions/patchAction.js +3 -4
  92. package/dist/modules/mcp/tools/operations/actions/upsertAction.d.ts +2 -0
  93. package/dist/modules/mcp/tools/operations/actions/upsertAction.js +3 -4
  94. package/dist/modules/mcp/tools/operations/closed.js +1 -2
  95. package/dist/modules/mcp/tools/operations/connectors/deleteConnector.js +2 -3
  96. package/dist/modules/mcp/tools/operations/connectors/index.js +1 -2
  97. package/dist/modules/mcp/tools/operations/connectors/manifest.js +1 -2
  98. package/dist/modules/mcp/tools/operations/connectors/patchConnector.js +3 -4
  99. package/dist/modules/mcp/tools/operations/connectors/upsertConnector.js +3 -4
  100. package/dist/modules/mcp/tools/operations/data/index.js +1 -2
  101. package/dist/modules/mcp/tools/operations/functions/index.js +2 -3
  102. package/dist/modules/mcp/tools/operations/index.d.ts +8 -0
  103. package/dist/modules/mcp/tools/operations/index.js +1 -2
  104. package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +1 -2
  105. package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +1 -2
  106. package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +1 -2
  107. package/dist/modules/mcp/tools/operations/schema/components/deleteComponent.js +1 -2
  108. package/dist/modules/mcp/tools/operations/schema/components/upsertComponent.js +2 -3
  109. package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +2 -3
  110. package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +3 -4
  111. package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +3 -4
  112. package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +1 -2
  113. package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +3 -4
  114. package/dist/modules/mcp/tools/operations/schema/flags/deleteFlag.js +2 -3
  115. package/dist/modules/mcp/tools/operations/schema/flags/upsertFlag.js +2 -3
  116. package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +2 -3
  117. package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +2 -3
  118. package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +1 -2
  119. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +1 -2
  120. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +2 -3
  121. package/dist/modules/mcp/tools/operations/schema/operations.js +1 -2
  122. package/dist/modules/mcp/tools/operations/schema/pages/deleteLayout.js +2 -3
  123. package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +2 -3
  124. package/dist/modules/mcp/tools/operations/schema/pages/upsertLayout.js +3 -4
  125. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +3 -4
  126. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +2 -3
  127. package/dist/modules/mcp/tools/operations/schema/shared.js +1 -2
  128. package/dist/modules/mcp/tools/operations/schema/translator.js +2 -3
  129. package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +2 -3
  130. package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +2 -3
  131. package/dist/modules/mcp/tools/operations/schema/write.js +3 -4
  132. package/dist/modules/mcp/tools/operations/schemaIds.js +1 -2
  133. package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +1 -2
  134. package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +2 -3
  135. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +1 -2
  136. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +1 -2
  137. package/dist/modules/mcp/tools/operations/style/fonts/deleteFont.js +2 -3
  138. package/dist/modules/mcp/tools/operations/style/fonts/upsertFont.js +2 -3
  139. package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +1 -2
  140. package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +2 -3
  141. package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +1 -2
  142. package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +1 -2
  143. package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +2 -3
  144. package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +1 -2
  145. package/dist/modules/mcp/tools/operations/style/operations.js +1 -2
  146. package/dist/modules/mcp/tools/operations/style/shared.js +1 -2
  147. package/dist/modules/mcp/tools/operations/style/translator.js +1 -2
  148. package/dist/modules/mcp/tools/operations/style/validate.js +1 -2
  149. package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +2 -3
  150. package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +2 -3
  151. package/dist/modules/mcp/tools/operations/style/write.js +2 -3
  152. package/dist/modules/mcp/tools/read.js +2 -3
  153. package/dist/modules/mcp/tools/render.js +3 -4
  154. package/dist/modules/mcp/tools/renderWidget.js +2 -3
  155. package/dist/modules/mcp/tools/search.js +2 -3
  156. package/dist/modules/mcp/tools/shared/draftBatch.js +2 -3
  157. package/dist/modules/mcp/tools/shared/effects.js +1 -2
  158. package/dist/modules/mcp/tools/shared/expandOperations.js +1 -2
  159. package/dist/modules/mcp/tools/shared/interactionReport.js +1 -2
  160. package/dist/modules/mcp/tools/shared/lintDraft.js +1 -2
  161. package/dist/modules/mcp/tools/shared/look.js +1 -2
  162. package/dist/modules/mcp/tools/shared/newSuggestions.js +1 -2
  163. package/dist/modules/mcp/tools/shared/normalizeOperations.js +1 -2
  164. package/dist/modules/mcp/tools/shared/repeats.js +1 -2
  165. package/dist/modules/mcp/tools/shared/tool.js +1 -2
  166. package/dist/modules/mcp/tools/shared/validator/batch.js +1 -2
  167. package/dist/modules/mcp/tools/shared/validator/bindings.js +1 -2
  168. package/dist/modules/mcp/tools/shared/validator/connectors.js +2 -3
  169. package/dist/modules/mcp/tools/shared/validator/context.js +1 -2
  170. package/dist/modules/mcp/tools/shared/validator/css.js +2 -3
  171. package/dist/modules/mcp/tools/shared/validator/elements.js +2 -3
  172. package/dist/modules/mcp/tools/shared/validator/index.js +8 -9
  173. package/dist/modules/mcp/tools/shared/validator/interactions.js +2 -3
  174. package/dist/modules/mcp/tools/shared/validator/refs.js +1 -2
  175. package/dist/modules/mcp/tools/test.js +1 -2
  176. package/dist/modules/mcp/tools/tryFunction.js +1 -2
  177. package/dist/modules/mcp/types/screenshotTypes.d.ts +8 -0
  178. package/dist/options.d.ts +1 -1
  179. package/dist/pipeline.d.ts +2 -1
  180. package/dist/pipeline.js +4 -3
  181. package/dist/preview/createPreview.d.ts +1 -1
  182. package/dist/preview/createPreview.js +1 -2
  183. package/dist/preview.d.ts +7 -0
  184. package/dist/preview.js +1 -0
  185. package/dist/render.js +1 -1
  186. package/dist/server.js +3 -3
  187. package/dist/stages/mcp.d.ts +1 -1
  188. package/dist/stages/mcp.js +2 -3
  189. package/dist/stages/preview.d.ts +2 -1
  190. package/dist/stages/preview.js +3 -4
  191. package/dist/stages/proxy.d.ts +1 -1
  192. package/dist/stages/proxy.js +2 -3
  193. package/package.json +23 -16
@@ -1,2 +1,2 @@
1
1
  /** The space's server side: connectors, server actions, functions, data, realtime channels and feature flags. */
2
- export declare const serverGuide = "## Connectors \u2014 CMS and API integrations\nA **connector** is how a space reads real content from Strapi, WordPress, Contentful, Directus or any REST service.\nIt is **a manifest, not code**: you declare the base URL, the endpoints, the auth template and the filter operators,\nand the **server** executes it during the render. Integrating a new CMS never means shipping an adapter \u2014 it means\nwriting one document, which you can do here with `upsertConnector`.\n\nWhy the server and not the browser: the request (and the token behind it) never reaches the visitor, and the content\nis in the HTML search engines see. That is also the one hard rule below \u2014 a provider element that is not\nserver-rendered ignores its connector entirely.\n\n**Read these two first:**\n- `plitzi://connector-presets` \u2014 **working manifests** for Strapi v5, WordPress, Directus, Contentful and a plain\n REST API, each with the `credentialKeys` that provider needs, **plus every template token** the engine binds.\n Start from the preset for the user's provider and edit it; do not invent a shape from memory.\n- `plitzi://connectors/{env}` \u2014 the connectors **this space already has**, each with its read/write endpoint names,\n its filter operators and its published fields. `plitzi://connectors/{env}/{ref}` opens one manifest in full.\n\n### Credentials are NOT yours to write\nYou never create, see or transmit a secret. Author the manifest with the token in place\n(`\"value\": \"Bearer {{credential.token}}\"`) and **leave `connection.credential` unset** unless the user hands you an\nidentifier. The connector **saves fine that way** \u2014 validation reports it as a *warning*, not an error \u2014 and its\nrequests go unauthenticated until the space owner creates the credential in the builder and attaches it. Say that to\nthe user as the last step of any integration you build, naming the keys the preset lists (e.g. Strapi needs `token`).\n\n### The manifest\nEvery string is a template the server renders per request. `{{resource}}` is the collection the element asked for;\n`{{limit}}`/`{{offset}}`/`{{page}}`/`{{cursor}}` the window; `{{routeParams.x}}`/`{{queryParams.x}}` the\nvisitor's URL; `{{credential.x}}` the secret; `{{field}}`/`{{value}}` inside an operator; `{{id}}`/`{{values}}`\ninside a write. The op splits it in two, exactly as the engine does:\n- **`connection`** \u2014 what applies to every call: `credential`, `auth`, `headers`, `pagination`, `operators`,\n `mediaBaseUrl`, `fields`, `projection`.\n- **`endpoints`** \u2014 the individual calls: `read` (named; **`list` is the one an element addresses when it names\n none**) and `write` (named; **omit for read-only** \u2014 an undeclared write can never be executed).\n\nA read endpoint says where things live in *that* provider's response: `itemsPath` (the array), `totalPath` (the\ncount), `idPath` (the record's id), `valuesPath` (its fields). Strapi's `data` + `meta.pagination.total` and\nContentful's `items` + `fields` are the same manifest with different paths.\n\nTwo traps the validator will catch for you, both silent at runtime otherwise:\n- An **operator template must render a whole `key=value` entry** (`\"eq\": \"filters[{{field}}][$eq]={{value}}\"`). A\n filter naming an operator the manifest does not declare is **dropped** \u2014 the query then returns *unfiltered*\n records, not none.\n- **Paging must appear in the request.** Declaring `pagination: \"page\"` without `{{page}}` in the query makes every\n page resolve to the first one.\n\nExample \u2014 Strapi, from the preset:\n```json\n{ \"type\": \"upsertConnector\", \"ref\": \"strapi-blog\", \"name\": \"Blog CMS\",\n \"baseUrl\": \"https://cms.example.com\",\n \"connection\": {\n \"auth\": { \"in\": \"header\", \"name\": \"Authorization\", \"value\": \"Bearer {{credential.token}}\" },\n \"pagination\": \"offset\",\n \"operators\": { \"eq\": \"filters[{{field}}][$eq]={{value}}\", \"contains\": \"filters[{{field}}][$containsi]={{value}}\" },\n \"mediaBaseUrl\": \"https://cms.example.com\" },\n \"endpoints\": { \"read\": { \"list\": {\n \"path\": \"/api/{{resource}}\",\n \"query\": { \"pagination[start]\": \"{{offset}}\", \"pagination[limit]\": \"{{limit}}\", \"populate\": \"*\" },\n \"itemsPath\": \"data\", \"totalPath\": \"meta.pagination.total\", \"idPath\": \"documentId\" } } } }\n```\n`patchConnector` changes part of one (endpoints merge **by name**; `null` removes one) \u2014 that is how you add a\n`detail` read to a large manifest without resending it. `deleteConnector` is destructive: every element pointing\nat it stops resolving, so confirm first.\n\n### Using a connector on a page\nThe provider element is `apiContainer`, and it needs **both halves**:\n1. `runtime: \"server\"` \u2014 set it on `upsertElement`/`patchElement`. **Without it the connector is ignored** and the\n element falls back to fetching its own `query` URL from the browser. This is the single most common mistake; the\n validator warns when it sees one half without the other.\n2. props: `connector` (the ref), `resource` (the collection \u2192 `{{resource}}`), and optionally `endpoint` (a read\n other than `list`), `filters`, `limit`, `singleRecord`, `pagination`, `pageParam`.\n\nIt then publishes one source **to its descendants only** (like any provider \u2014 bind *inside* its subtree):\n`apiContainer_<name>.records` (an array of `{ id, values }` \u2014 a record's fields are under `values`, so a row\nreads `list_<name>.item.values.<field>`), `.pageInfo` (`page`, `pageCount`, `total`, `hasNextPage`\u2026),\n`.isEmpty`, `.hasError`, `.errorMessage`, `.isLoading`. With `singleRecord: true` it publishes `.record`\ninstead of `.records` \u2014 that is what a **detail page** uses. Bind an empty-state block's visibility to `.isEmpty`\nand an error block's to `.hasError`; they are ordinary bindings, no special mechanism.\n\n**A list page** \u2014 provider, then a `list` inside it bound to the records, then the row template reading the item\n(a `list` is a `<ul>`, or `<ol>` by `subType`; its row a `listItem`, an `<li>` \u2014 any other row is warned\n`list-row-not-li`):\n```json\n{ \"operations\": [\n { \"type\": \"upsertElement\", \"pageRef\": \"blog\", \"element\": {\n \"ref\": \"posts-api\", \"type\": \"apiContainer\", \"runtime\": \"server\",\n \"props\": { \"connector\": \"strapi-blog\", \"resource\": \"articles\", \"limit\": \"9\", \"pagination\": \"url\" },\n \"children\": [ { \"ref\": \"posts\", \"type\": \"list\", \"children\": [\n { \"ref\": \"post-row\", \"type\": \"listItem\", \"children\": [\n { \"ref\": \"post-title\", \"type\": \"text\" } ] } ] } ] } },\n { \"type\": \"upsertBinding\", \"pageRef\": \"blog\", \"ref\": \"posts\", \"category\": \"attributes\",\n \"binding\": { \"to\": \"items\", \"source\": \"apiContainer_posts-api.records\" } },\n { \"type\": \"upsertBinding\", \"pageRef\": \"blog\", \"ref\": \"post-title\", \"category\": \"attributes\",\n \"binding\": { \"to\": \"content\", \"source\": \"list_posts.item.values.title\" } } ] }\n```\n\n**A detail page** is the same provider with `singleRecord` and a filter resolved from the URL. Create the page with a\nroute param (`\"slug\": \"blog/:postSlug\"`), then filter on it \u2014 the filter `value` is a template the server resolves:\n```json\n{ \"type\": \"upsertElement\", \"pageRef\": \"post-detail\", \"element\": {\n \"ref\": \"post-api\", \"type\": \"apiContainer\", \"runtime\": \"server\",\n \"props\": { \"connector\": \"strapi-blog\", \"resource\": \"articles\", \"singleRecord\": true,\n \"filters\": [ { \"field\": \"slug\", \"operator\": \"eq\", \"value\": \"{{routeParams.postSlug}}\" } ] } } }\n```\nIts children then bind to `apiContainer_post-api.record.values.<field>`. A filter whose template resolves to nothing\nreturns **no records** rather than the whole collection \u2014 a URL that addressed one post never renders a different one.\n\n**Paging** is the `pagination` prop: `\"none\"`, `\"url\"` (the page number rides the query string, so pages are\nshareable and indexable \u2014 prefer it) or `\"append\"` (a \"load more\" list). Give each list on a page its own\n`pageParam` so two lists page independently. The provider also offers the `loadMore` and `goToPage` callbacks to\ninteraction flows, `performQuery` to refetch, and `cancelQuery` to drop a request in flight (a STOP).\n\n**Writing back** (a form, a \"delete\" button): declare the endpoint under `endpoints.write`, then call the provider's\n**`writeRecord`** callback from an interaction flow \u2014 nodeType `callback`, `elementId` the apiContainer's ref,\nparams `action` (the write endpoint's name) and `recordId`. The write goes through the server, which owns the\ncredential and refuses any action the manifest does not declare. Writes exist **only** on a server-rendered provider.\n\n**Connectors need a server.** A space published without server rendering has nowhere to resolve one: it works in the\nbuilder and renders empty when published. If the user has no SSR deployment, say so rather than leaving them to\ndiscover it \u2014 the alternative is a browser-side `query`, which cannot keep a secret.\n\n## Server actions\nWork a page cannot do in the browser \u2014 charge a card, send mail, read a system only the server reaches. An action\nis a stored flow the SERVER runs; a page names it and never learns what it does. Write one with\n`upsertAction` / `patchAction`, then call it from a page flow with the `runServerAction` step (mode\n`await` to use the result, `detached` to fire and carry on).\n\nFour rules worth knowing before you write:\n\n- **Steps are server tasks.** `plitzi://actions/{env}/tasks` lists what this deployment can run \u2014 a browser step\n (`setState`, `navigate`) has nothing to act on here, and the reverse is true too: a task cannot run in a page\n flow.\n- **The contracts.** `input` is coerced and anything undeclared is DROPPED. The OUTPUT is whatever the final\n `flow.output` step names \u2014 there is no separate list to keep in step with it \u2014 and that step must be LAST,\n since only the last one that runs is answered. Everything else a step produced stays on the server.\n- **Whether it runs lives on its TRIGGERS.** Each trigger step carries `enabled`, and the action is on when any\n way into it is \u2014 there is no switch beside the flow. So \"pause this action\" means disabling its trigger step(s),\n never deleting them.\n- **A step names the credential it uses**, and sees no other. `credentials` on the document says which ones the\n action may ask for at all; the secret itself is never yours to see, exactly as with a connector.\n\n`deleteAction { ref }` removes one; every `runServerAction` step that names it stops resolving, so confirm first.\n\n## Functions\nWhen no server task does what a flow needs \u2014 parse a feed, call an API with its own shape, compute something \u2014 the\nspace can have its own: **functions**, TypeScript the platform builds and runs in a sandbox. Their tasks are steps like\nany other (`<namespace>.<action>`), listed in `plitzi://actions/{env}/tasks` once saved.\n\n- **Write** files with `upsertFunctionFile { path, content }` (whole files; `deleteFunctionFile { path }` removes\n one). `index.ts` default-exports the definition:\n `export default defineFunctions({ allow: { hosts: [\"api.example.com\"] }, tasks: [{ namespace, action, title, params, run: async (params, ctx) => \u2026 }] })`,\n `defineFunctions` from `@plitzi/sdk-server/functions`. Files import each other by relative path \u2014 no package,\n no Node built-in.\n- **`ctx` is all a function reaches:** `ctx.kv` (the space's store), `ctx.fetch(url, init)` to the hosts\n `allow.hosts` names (`*.example.com` for subdomains), `ctx.publish/grant/revoke` (channels),\n `ctx.data(\"products.json\")` (one file of the space's data, parsed \u2014 never imported), `ctx.log`, `ctx.user` (who\n asked, never their session). A secret is NAMED, never read: `ctx.fetch(url, { credential: \"stripe\",\n headers: { authorization: \"Bearer {{ credential.apiKey }}\" } })`. `signal` in the init cuts a slow request short\n (`AbortSignal.timeout(12000)`).\n- **Refuse with `ActionRefusal`** (from `@plitzi/sdk-server/functions`): its message is written for whoever asked and\n reaches them (`{{ step.error }}`, a route's `400 { error }`); anything else thrown stays in the run's record.\n `new ActionRefusal(message, { code })` names it for code that catches it \u2014 compare `error.code`, never the message.\n- **An API on behalf of a visitor** (their calendar, their music) is an OAuth connection declared as data:\n `defineFunctions({ oauth: { calendar: { issuer, credential, scopes } } })` \u2014 `issuer` for OpenID, or\n `authorizeUrl`/`tokenUrl`; the credential holds the app's `clientId`/`clientSecret`. A route redirects to\n `(await ctx.oauth.connect(\"calendar\", { returnTo: \"/settings\" })).url` (`authorizeParams` adds to that one consent:\n `{ prompt: \"select_account\" }`), and `ctx.oauth.fetch(\"calendar\", url)` calls the API with the token written in;\n `status`, `disconnect` beside them. The platform keeps the token sealed and renews it \u2014 never put one in `kv`. The\n user registers `/fn/oauth/callback` on the space's host with the provider (`ctx.oauth.callbackUrl()` says the\n exact address, for a page that shows it). Not connected yet is a refusal with\n `code: \"oauth-not-connected\"`. `token` hands the access token only to a connection declaring `exposeToken: true`.\n- **Stateless:** nothing a function keeps in memory outlives the call \u2014 a module-level cache or counter starts empty\n every time, on whichever instance runs it. What must last goes in `ctx.kv`. A call gets 100 ms of CPU and 10 s;\n a task that needs more says so \u2014 `limits: { cpuMs: 1000, wallMs: 20000 }`, or `defineFunctions({ limits })` for\n all \u2014 up to the plan's ceiling. Asking above it is refused at save, never quietly cut.\n- **Routes** answer HTTP on the space's own host under `/fn/`: `routes: { \"GET /boards/:board\": (request, ctx) =>\n Response.json(\u2026) }` answers `/fn/boards/kanban` (`ctx.params.board`). No page may live under `/fn`.\n- **Saving builds and checks** the files: the batch is refused with each problem where it is (file and line). A\n namespace the platform uses (`kv`, `http`, `flow`\u2026) is refused.\n- **Try it** with `plitzi_try_function { task, params }` before a page relies on it: the value, the logs, the error.\n The live site runs what the space was last published with, never the draft. Running functions is part of the paid\n plans: on another plan they save, and a run answers why it did not start \u2014 tell the user rather than work around it.\n\n## Data\nJSON the space's pages read on the server and never serve \u2014 a catalog, prices, a menu: what a page needs whole and\nnobody edits element by element.\n\n- **Read** it as a provider does: `apiContainer` with `runtime: \"server\"` and `query: \"/data/products.json\"` reads\n `products.json` of `plitzi://data/{env}`, and the page arrives with it. A browser provider reading `/data/\u2026` is\n refused \u2014 the data is the server's.\n- **Write** it with `upsertDataFile { path, content }` (the whole file, as JSON text; `deleteDataFile { path }`\n removes one): a path of plain segments ending in `.json`. Saved whole, with the batch: a newer copy (somebody saved\n since you read it) refuses it \u2014 read it again.\n- **What a provider reads is in the page it renders**: data a page must not carry belongs in a server action, which\n answers only what is shown. The live site reads what the space was last published with, never the draft.\n\n## Realtime channels\nPages that see each other \u2014 cursors, presence, a shared board, a game. Three parts, all needed:\n\n1. **Declare** the topic pattern with `patchSettings { channels: { \"board:{id}\": { access: { mode: \"public\" }, publish: \"server\" } } }`.\n `publish: \"server\"` is for what must be validated and saved first; `\"clients\"` (the default) for what pages send\n directly \u2014 add `presence: true` for who-is-here.\n2. **Subscribe** with a `channel` element whose `topic` a pattern matches (`board:{{ id }}`, a route param).\n Its descendants bind `channel_<id>`: `connected`, `members`, `messages`, `last`, `retained`; flows use its `onMessage`,\n `onJoin`, `onLeave` triggers (`from`, `user` and the `state` the member announced \u2014 `onJoin` only for who\n came after this page) and its `publish` / `setPresence` callbacks.\n3. **Announce from the server**: an action whose last step is the `realtime.publish` task \u2014 validate, save, then say so.\n\nA topic no pattern matches is refused by the server and reported by the linter (`channel-topic`).\n\n**Private topics** (a room behind a password, a customer's order): declare the pattern `grant: true`. The action that\ndecides the visitor may be there ends with `realtime.grant { topic }` and answers its `grant`; the `channel`\nelement binds `grant` to it. Without one the topic is refused however well its name is known (`channel-grant`).\n`realtime.revoke { topic, grant }` takes one back \u2014 or all, naming none \u2014 and lets go whoever is on it with it.\n\n**State every screen shares** (a dashboard's lists, a board's settings): declare the pattern `retain: true` with\n`publish: \"server\"`. The server keeps the latest message of each type it says (`realtime.publish`) and hands them to\nevery page that joins \u2014 and to its `onMessage` flows, as if just said; the page binds `desk.retained.lists`, with no\nread of its own and no copy in `state`. `data: null` forgets a type; a topic keeps at most 64 types and 512 KB.\n\n**Two writers at once**: read-change-write with `kv.setIf` (written only if the value is still the one read \u2014 empty\n`expected` = only if nothing is there yet), ordered lists with `list.put` / `list.range`, and put\n`flow.rateLimit` first in any public action that writes.\n\n## Feature flags\nA flag turns a part of the space on or off without anyone editing it: a feature still being built, a version for\nbeta users, the old checkout kept until the new one ships. **Not a visibility** \u2014 visibility hides an element that is\nstill rendered; a flag decides whether it exists at all.\n\n- **Declare** with `upsertFlag { name, description?, value, rules? }`. `value` is its answer when no rule matches;\n `rules` are `[{ when, value }]` read top to bottom, the first match deciding. A rule's `when` is a rule group over\n `environment` (`main`, `development`, `staging`, `production`), `hostname`, `routeParams.<name>`,\n `queryParams.<name>` and the visitor: `user.authenticated`, `user.email`, `user.username`, `user.roles` (with\n `contains`). A group with no rules is skipped, never read as \"always\". `deleteFlag { name }` removes one.\n- **Gate** an element with `flag` on `upsertElement` / `patchElement`: `\"newCheckout\"` exists only while the flag is\n on, `\"!newCheckout\"` only while it is off \u2014 put both side by side for a rollout. On `upsertPage` a gated-off page\n answers 404. `null` on a patch removes the gate. Gated off, it is not rendered and its server data is not\n resolved \u2014 but the space's document, gated elements included, still reaches the browser: a flag is not a secret.\n- **Read** it anywhere a source is read: `{{ flags.newCheckout }}` in a binding, a `when` of a flow step, a computed\n value \u2014 and in a server action's steps, where it is resolved on the server.\n\nA gate or a read naming a flag the space does not declare is an error (`flag-undeclared`, `flag-unknown`): an\nundeclared flag is off. A declared flag nothing reads is a warning (`flag-unused`) \u2014 remove it once the feature\nships. The draft applies flags at once. Flags are not part of a snapshot: each environment has one set, shared by every\nsnapshot it serves \u2014 publishing a snapshot sends the draft's with it (and the snapshot keeps a copy, as a fallback), the\nbuilder's *Publish flags* sends only them, and a rollback keeps them. Above the space, the server rendering it, the SDK embedding it and a tester with the dev tools\nmay each override a flag; you only ever write the space's own.\n\n";
2
+ export declare const serverGuide = "## Connectors \u2014 CMS and API integrations\nA **connector** is how a space reads real content from Strapi, WordPress, Contentful, Directus or any REST service.\nIt is **a manifest, not code**: you declare the base URL, the endpoints, the auth template and the filter operators,\nand the **server** executes it during the render. Integrating a new CMS never means shipping an adapter \u2014 it means\nwriting one document, which you can do here with `upsertConnector`.\n\nWhy the server and not the browser: the request (and the token behind it) never reaches the visitor, and the content\nis in the HTML search engines see. That is also the one hard rule below \u2014 a provider element that is not\nserver-rendered ignores its connector entirely.\n\n**Read these two first:**\n- `plitzi://connector-presets` \u2014 **working manifests** for Strapi v5, WordPress, Directus, Contentful and a plain\n REST API, each with the `credentialKeys` that provider needs, **plus every template token** the engine binds.\n Start from the preset for the user's provider and edit it; do not invent a shape from memory.\n- `plitzi://connectors/{env}` \u2014 the connectors **this space already has**, each with its read/write endpoint names,\n its filter operators and its published fields. `plitzi://connectors/{env}/{ref}` opens one manifest in full.\n\n### Credentials are NOT yours to write\nYou never create, see or transmit a secret. Author the manifest with the token in place\n(`\"value\": \"Bearer {{credential.token}}\"`) and **leave `connection.credential` unset** unless the user hands you an\nidentifier. The connector **saves fine that way** \u2014 validation reports it as a *warning*, not an error \u2014 and its\nrequests go unauthenticated until the space owner creates the credential in the builder and attaches it. Say that to\nthe user as the last step of any integration you build, naming the keys the preset lists (e.g. Strapi needs `token`).\n\n### The manifest\nEvery string is a template the server renders per request. `{{resource}}` is the collection the element asked for;\n`{{limit}}`/`{{offset}}`/`{{page}}`/`{{cursor}}` the window; `{{routeParams.x}}`/`{{queryParams.x}}` the\nvisitor's URL; `{{credential.x}}` the secret; `{{field}}`/`{{value}}` inside an operator; `{{id}}`/`{{values}}`\ninside a write. The op splits it in two, exactly as the engine does:\n- **`connection`** \u2014 what applies to every call: `credential`, `auth`, `headers`, `pagination`, `operators`,\n `mediaBaseUrl`, `fields`, `projection`.\n- **`endpoints`** \u2014 the individual calls: `read` (named; **`list` is the one an element addresses when it names\n none**) and `write` (named; **omit for read-only** \u2014 an undeclared write can never be executed).\n\nA read endpoint says where things live in *that* provider's response: `itemsPath` (the array), `totalPath` (the\ncount), `idPath` (the record's id), `valuesPath` (its fields). Strapi's `data` + `meta.pagination.total` and\nContentful's `items` + `fields` are the same manifest with different paths.\n\nTwo traps the validator will catch for you, both silent at runtime otherwise:\n- An **operator template must render a whole `key=value` entry** (`\"eq\": \"filters[{{field}}][$eq]={{value}}\"`). A\n filter naming an operator the manifest does not declare is **dropped** \u2014 the query then returns *unfiltered*\n records, not none.\n- **Paging must appear in the request.** Declaring `pagination: \"page\"` without `{{page}}` in the query makes every\n page resolve to the first one.\n\nExample \u2014 Strapi, from the preset:\n```json\n{ \"type\": \"upsertConnector\", \"ref\": \"strapi-blog\", \"name\": \"Blog CMS\",\n \"baseUrl\": \"https://cms.example.com\",\n \"connection\": {\n \"auth\": { \"in\": \"header\", \"name\": \"Authorization\", \"value\": \"Bearer {{credential.token}}\" },\n \"pagination\": \"offset\",\n \"operators\": { \"eq\": \"filters[{{field}}][$eq]={{value}}\", \"contains\": \"filters[{{field}}][$containsi]={{value}}\" },\n \"mediaBaseUrl\": \"https://cms.example.com\" },\n \"endpoints\": { \"read\": { \"list\": {\n \"path\": \"/api/{{resource}}\",\n \"query\": { \"pagination[start]\": \"{{offset}}\", \"pagination[limit]\": \"{{limit}}\", \"populate\": \"*\" },\n \"itemsPath\": \"data\", \"totalPath\": \"meta.pagination.total\", \"idPath\": \"documentId\" } } } }\n```\n`patchConnector` changes part of one (endpoints merge **by name**; `null` removes one) \u2014 that is how you add a\n`detail` read to a large manifest without resending it. `deleteConnector` is destructive: every element pointing\nat it stops resolving, so confirm first.\n\n### Using a connector on a page\nThe provider element is `apiContainer`, and it needs **both halves**:\n1. `runtime: \"server\"` \u2014 set it on `upsertElement`/`patchElement`. **Without it the connector is ignored** and the\n element falls back to fetching its own `query` URL from the browser. This is the single most common mistake; the\n validator warns when it sees one half without the other.\n2. props: `connector` (the ref), `resource` (the collection \u2192 `{{resource}}`), and optionally `endpoint` (a read\n other than `list`), `filters`, `limit`, `singleRecord`, `pagination`, `pageParam`.\n\nIt then publishes one source **to its descendants only** (like any provider \u2014 bind *inside* its subtree):\n`apiContainer_<name>.records` (an array of `{ id, values }` \u2014 a record's fields are under `values`, so a row\nreads `list_<name>.item.values.<field>`), `.pageInfo` (`page`, `pageCount`, `total`, `hasNextPage`\u2026),\n`.isEmpty`, `.hasError`, `.errorMessage`, `.isLoading`. With `singleRecord: true` it publishes `.record`\ninstead of `.records` \u2014 that is what a **detail page** uses. Bind an empty-state block's visibility to `.isEmpty`\nand an error block's to `.hasError`; they are ordinary bindings, no special mechanism.\n\n**A list page** \u2014 provider, then a `list` inside it bound to the records, then the row template reading the item\n(a `list` is a `<ul>`, or `<ol>` by `subType`; its row a `listItem`, an `<li>` \u2014 any other row is warned\n`list-row-not-li`):\n```json\n{ \"operations\": [\n { \"type\": \"upsertElement\", \"pageRef\": \"blog\", \"element\": {\n \"ref\": \"posts-api\", \"type\": \"apiContainer\", \"runtime\": \"server\",\n \"props\": { \"connector\": \"strapi-blog\", \"resource\": \"articles\", \"limit\": \"9\", \"pagination\": \"url\" },\n \"children\": [ { \"ref\": \"posts\", \"type\": \"list\", \"children\": [\n { \"ref\": \"post-row\", \"type\": \"listItem\", \"children\": [\n { \"ref\": \"post-title\", \"type\": \"text\" } ] } ] } ] } },\n { \"type\": \"upsertBinding\", \"pageRef\": \"blog\", \"ref\": \"posts\", \"category\": \"attributes\",\n \"binding\": { \"to\": \"items\", \"source\": \"apiContainer_posts-api.records\" } },\n { \"type\": \"upsertBinding\", \"pageRef\": \"blog\", \"ref\": \"post-title\", \"category\": \"attributes\",\n \"binding\": { \"to\": \"content\", \"source\": \"list_posts.item.values.title\" } } ] }\n```\n\n**A detail page** is the same provider with `singleRecord` and a filter resolved from the URL. Create the page with a\nroute param (`\"slug\": \"blog/:postSlug\"`), then filter on it \u2014 the filter `value` is a template the server resolves:\n```json\n{ \"type\": \"upsertElement\", \"pageRef\": \"post-detail\", \"element\": {\n \"ref\": \"post-api\", \"type\": \"apiContainer\", \"runtime\": \"server\",\n \"props\": { \"connector\": \"strapi-blog\", \"resource\": \"articles\", \"singleRecord\": true,\n \"filters\": [ { \"field\": \"slug\", \"operator\": \"eq\", \"value\": \"{{routeParams.postSlug}}\" } ] } } }\n```\nIts children then bind to `apiContainer_post-api.record.values.<field>`. A filter whose template resolves to nothing\nreturns **no records** rather than the whole collection \u2014 a URL that addressed one post never renders a different one.\n\n**Paging** is the `pagination` prop: `\"none\"`, `\"url\"` (the page number rides the query string, so pages are\nshareable and indexable \u2014 prefer it) or `\"append\"` (a \"load more\" list). Give each list on a page its own\n`pageParam` so two lists page independently. The provider also offers the `loadMore` and `goToPage` callbacks to\ninteraction flows, `performQuery` to refetch, and `cancelQuery` to drop a request in flight (a STOP).\n\n**Writing back** (a form, a \"delete\" button): declare the endpoint under `endpoints.write`, then call the provider's\n**`writeRecord`** callback from an interaction flow \u2014 nodeType `callback`, `elementId` the apiContainer's ref,\nparams `action` (the write endpoint's name) and `recordId`. The write goes through the server, which owns the\ncredential and refuses any action the manifest does not declare. Writes exist **only** on a server-rendered provider.\n\n**Connectors need a server.** A space published without server rendering has nowhere to resolve one: it works in the\nbuilder and renders empty when published. If the user has no SSR deployment, say so rather than leaving them to\ndiscover it \u2014 the alternative is a browser-side `query`, which cannot keep a secret.\n\n## Server actions\nWork a page cannot do in the browser \u2014 charge a card, send mail, read a system only the server reaches. An action\nis a stored flow the SERVER runs; a page names it and never learns what it does. Write one with\n`upsertAction` / `patchAction`, then call it from a page flow with the `runServerAction` step (mode\n`await` to use the result, `detached` to fire and carry on).\n\nFour rules worth knowing before you write:\n\n- **Steps are server tasks.** `plitzi://actions/{env}/tasks` lists what this deployment can run \u2014 a browser step\n (`setState`, `navigate`) has nothing to act on here, and the reverse is true too: a task cannot run in a page\n flow.\n- **The contracts.** `input` is coerced and anything undeclared is DROPPED. The OUTPUT is whatever the final\n `flow.output` step names \u2014 there is no separate list to keep in step with it \u2014 and that step must be LAST,\n since only the last one that runs is answered. Everything else a step produced stays on the server.\n- **Whether it runs lives on its TRIGGERS.** Each trigger step carries `enabled`, and the action is on when any\n way into it is \u2014 there is no switch beside the flow. So \"pause this action\" means disabling its trigger step(s),\n never deleting them.\n- **A step names the credential it uses**, and sees no other. `credentials` on the document says which ones the\n action may ask for at all; the secret itself is never yours to see, exactly as with a connector.\n\n`deleteAction { ref }` removes one; every `runServerAction` step that names it stops resolving, so confirm first.\n\n## Functions\nWhen no server task does what a flow needs \u2014 parse a feed, call an API with its own shape, compute something \u2014 the\nspace can have its own: **functions**, TypeScript the platform builds and runs in a sandbox. Their tasks are steps like\nany other (`<namespace>.<action>`), listed in `plitzi://actions/{env}/tasks` once saved.\n\n- **Write** files with `upsertFunctionFile { path, content }` (whole files; `deleteFunctionFile { path }` removes\n one). `index.ts` default-exports the definition:\n `export default defineFunctions({ allow: { hosts: [\"api.example.com\"] }, tasks: [{ namespace, action, title, params, run: async (params, ctx) => \u2026 }] })`,\n `defineFunctions` from `@plitzi/sdk-runtime`. Files import each other by relative path \u2014 no package,\n no Node built-in.\n- **`ctx` is all a function reaches:** `ctx.kv` (the space's store), `ctx.fetch(url, init)` to the hosts\n `allow.hosts` names (`*.example.com` for subdomains), `ctx.publish/grant/revoke` (channels),\n `ctx.data(\"products.json\")` (one file of the space's data, parsed \u2014 never imported), `ctx.log`, `ctx.user` (who\n asked, never their session). A secret is NAMED, never read: `ctx.fetch(url, { credential: \"stripe\",\n headers: { authorization: \"Bearer {{ credential.apiKey }}\" } })`. `signal` in the init cuts a slow request short\n (`AbortSignal.timeout(12000)`).\n- **Refuse with `ActionRefusal`** (from `@plitzi/sdk-runtime`): its message is written for whoever asked and\n reaches them (`{{ step.error }}`, a route's `400 { error }`); anything else thrown stays in the run's record.\n `new ActionRefusal(message, { code })` names it for code that catches it \u2014 compare `error.code`, never the message.\n- **An API on behalf of a visitor** (their calendar, their music) is an OAuth connection declared as data:\n `defineFunctions({ oauth: { calendar: { issuer, credential, scopes } } })` \u2014 `issuer` for OpenID, or\n `authorizeUrl`/`tokenUrl`; the credential holds the app's `clientId`/`clientSecret`. A route redirects to\n `(await ctx.oauth.connect(\"calendar\", { returnTo: \"/settings\" })).url` (`authorizeParams` adds to that one consent:\n `{ prompt: \"select_account\" }`), and `ctx.oauth.fetch(\"calendar\", url)` calls the API with the token written in;\n `status`, `disconnect` beside them. The platform keeps the token sealed and renews it \u2014 never put one in `kv`. The\n user registers `/fn/oauth/callback` on the space's host with the provider (`ctx.oauth.callbackUrl()` says the\n exact address, for a page that shows it). Not connected yet is a refusal with\n `code: \"oauth-not-connected\"`. `token` hands the access token only to a connection declaring `exposeToken: true`.\n- **Stateless:** nothing a function keeps in memory outlives the call \u2014 a module-level cache or counter starts empty\n every time, on whichever instance runs it. What must last goes in `ctx.kv`. A call gets 100 ms of CPU and 10 s;\n a task that needs more says so \u2014 `limits: { cpuMs: 1000, wallMs: 20000 }`, or `defineFunctions({ limits })` for\n all \u2014 up to the plan's ceiling. Asking above it is refused at save, never quietly cut.\n- **Routes** answer HTTP on the space's own host under `/fn/`: `routes: { \"GET /boards/:board\": (request, ctx) =>\n Response.json(\u2026) }` answers `/fn/boards/kanban` (`ctx.params.board`). No page may live under `/fn`.\n- **Saving builds and checks** the files: the batch is refused with each problem where it is (file and line). A\n namespace the platform uses (`kv`, `http`, `flow`\u2026) is refused.\n- **Try it** with `plitzi_try_function { task, params }` before a page relies on it: the value, the logs, the error.\n The live site runs what the space was last published with, never the draft. Running functions is part of the paid\n plans: on another plan they save, and a run answers why it did not start \u2014 tell the user rather than work around it.\n\n## Data\nJSON the space's pages read on the server and never serve \u2014 a catalog, prices, a menu: what a page needs whole and\nnobody edits element by element.\n\n- **Read** it as a provider does: `apiContainer` with `runtime: \"server\"` and `query: \"/data/products.json\"` reads\n `products.json` of `plitzi://data/{env}`, and the page arrives with it. A browser provider reading `/data/\u2026` is\n refused \u2014 the data is the server's.\n- **Write** it with `upsertDataFile { path, content }` (the whole file, as JSON text; `deleteDataFile { path }`\n removes one): a path of plain segments ending in `.json`. Saved whole, with the batch: a newer copy (somebody saved\n since you read it) refuses it \u2014 read it again.\n- **What a provider reads is in the page it renders**: data a page must not carry belongs in a server action, which\n answers only what is shown. The live site reads what the space was last published with, never the draft.\n\n## Realtime channels\nPages that see each other \u2014 cursors, presence, a shared board, a game. Three parts, all needed:\n\n1. **Declare** the topic pattern with `patchSettings { channels: { \"board:{id}\": { access: { mode: \"public\" }, publish: \"server\" } } }`.\n `publish: \"server\"` is for what must be validated and saved first; `\"clients\"` (the default) for what pages send\n directly \u2014 add `presence: true` for who-is-here.\n2. **Subscribe** with a `channel` element whose `topic` a pattern matches (`board:{{ id }}`, a route param).\n Its descendants bind `channel_<id>`: `connected`, `members`, `messages`, `last`, `retained`; flows use its `onMessage`,\n `onJoin`, `onLeave` triggers (`from`, `user` and the `state` the member announced \u2014 `onJoin` only for who\n came after this page) and its `publish` / `setPresence` callbacks.\n3. **Announce from the server**: an action whose last step is the `realtime.publish` task \u2014 validate, save, then say so.\n\nA topic no pattern matches is refused by the server and reported by the linter (`channel-topic`).\n\n**Private topics** (a room behind a password, a customer's order): declare the pattern `grant: true`. The action that\ndecides the visitor may be there ends with `realtime.grant { topic }` and answers its `grant`; the `channel`\nelement binds `grant` to it. Without one the topic is refused however well its name is known (`channel-grant`).\n`realtime.revoke { topic, grant }` takes one back \u2014 or all, naming none \u2014 and lets go whoever is on it with it.\n\n**State every screen shares** (a dashboard's lists, a board's settings): declare the pattern `retain: true` with\n`publish: \"server\"`. The server keeps the latest message of each type it says (`realtime.publish`) and hands them to\nevery page that joins \u2014 and to its `onMessage` flows, as if just said; the page binds `desk.retained.lists`, with no\nread of its own and no copy in `state`. `data: null` forgets a type; a topic keeps at most 64 types and 512 KB.\n\n**Two writers at once**: read-change-write with `kv.setIf` (written only if the value is still the one read \u2014 empty\n`expected` = only if nothing is there yet), ordered lists with `list.put` / `list.range`, and put\n`flow.rateLimit` first in any public action that writes.\n\n## Feature flags\nA flag turns a part of the space on or off without anyone editing it: a feature still being built, a version for\nbeta users, the old checkout kept until the new one ships. **Not a visibility** \u2014 visibility hides an element that is\nstill rendered; a flag decides whether it exists at all.\n\n- **Declare** with `upsertFlag { name, description?, value, rules? }`. `value` is its answer when no rule matches;\n `rules` are `[{ when, value }]` read top to bottom, the first match deciding. A rule's `when` is a rule group over\n `environment` (`main`, `development`, `staging`, `production`), `hostname`, `routeParams.<name>`,\n `queryParams.<name>` and the visitor: `user.authenticated`, `user.email`, `user.username`, `user.roles` (with\n `contains`). A group with no rules is skipped, never read as \"always\". `deleteFlag { name }` removes one.\n- **Gate** an element with `flag` on `upsertElement` / `patchElement`: `\"newCheckout\"` exists only while the flag is\n on, `\"!newCheckout\"` only while it is off \u2014 put both side by side for a rollout. On `upsertPage` a gated-off page\n answers 404. `null` on a patch removes the gate. Gated off, it is not rendered and its server data is not\n resolved \u2014 but the space's document, gated elements included, still reaches the browser: a flag is not a secret.\n- **Read** it anywhere a source is read: `{{ flags.newCheckout }}` in a binding, a `when` of a flow step, a computed\n value \u2014 and in a server action's steps, where it is resolved on the server.\n\nA gate or a read naming a flag the space does not declare is an error (`flag-undeclared`, `flag-unknown`): an\nundeclared flag is off. A declared flag nothing reads is a warning (`flag-unused`) \u2014 remove it once the feature\nships. The draft applies flags at once. Flags are not part of a snapshot: each environment has one set, shared by every\nsnapshot it serves \u2014 publishing a snapshot sends the draft's with it (and the snapshot keeps a copy, as a fallback), the\nbuilder's *Publish flags* sends only them, and a rollback keeps them. Above the space, the server rendering it, the SDK embedding it and a tester with the dev tools\nmay each override a flag; you only ever write the space's own.\n\n";
@@ -1,4 +1,4 @@
1
- //#region src/modules/mcp/helpers/guide/server.ts
1
+ // src/modules/mcp/helpers/guide/server.ts
2
2
  /** The space's server side: connectors, server actions, functions, data, realtime channels and feature flags. */
3
3
  var serverGuide = `## Connectors — CMS and API integrations
4
4
  A **connector** is how a space reads real content from Strapi, WordPress, Contentful, Directus or any REST service.
@@ -150,7 +150,7 @@ any other (\`<namespace>.<action>\`), listed in \`plitzi://actions/{env}/tasks\`
150
150
  - **Write** files with \`upsertFunctionFile { path, content }\` (whole files; \`deleteFunctionFile { path }\` removes
151
151
  one). \`index.ts\` default-exports the definition:
152
152
  \`export default defineFunctions({ allow: { hosts: ["api.example.com"] }, tasks: [{ namespace, action, title, params, run: async (params, ctx) => … }] })\`,
153
- \`defineFunctions\` from \`@plitzi/sdk-server/functions\`. Files import each other by relative path — no package,
153
+ \`defineFunctions\` from \`@plitzi/sdk-runtime\`. Files import each other by relative path — no package,
154
154
  no Node built-in.
155
155
  - **\`ctx\` is all a function reaches:** \`ctx.kv\` (the space's store), \`ctx.fetch(url, init)\` to the hosts
156
156
  \`allow.hosts\` names (\`*.example.com\` for subdomains), \`ctx.publish/grant/revoke\` (channels),
@@ -158,7 +158,7 @@ any other (\`<namespace>.<action>\`), listed in \`plitzi://actions/{env}/tasks\`
158
158
  asked, never their session). A secret is NAMED, never read: \`ctx.fetch(url, { credential: "stripe",
159
159
  headers: { authorization: "Bearer {{ credential.apiKey }}" } })\`. \`signal\` in the init cuts a slow request short
160
160
  (\`AbortSignal.timeout(12000)\`).
161
- - **Refuse with \`ActionRefusal\`** (from \`@plitzi/sdk-server/functions\`): its message is written for whoever asked and
161
+ - **Refuse with \`ActionRefusal\`** (from \`@plitzi/sdk-runtime\`): its message is written for whoever asked and
162
162
  reaches them (\`{{ step.error }}\`, a route's \`400 { error }\`); anything else thrown stays in the run's record.
163
163
  \`new ActionRefusal(message, { code })\` names it for code that catches it — compare \`error.code\`, never the message.
164
164
  - **An API on behalf of a visitor** (their calendar, their music) is an OAuth connection declared as data:
@@ -248,5 +248,4 @@ builder's *Publish flags* sends only them, and a rollback keeps them. Above the
248
248
  may each override a flag; you only ever write the space's own.
249
249
 
250
250
  `;
251
- //#endregion
252
251
  export { serverGuide };
@@ -1,4 +1,4 @@
1
- //#region src/modules/mcp/helpers/guide/structure.ts
1
+ // src/modules/mcp/helpers/guide/structure.ts
2
2
  /** How a space is put together: shared layouts, components, pages and folders, and its settings. */
3
3
  var structureGuide = `## Shared layouts — the chrome a page does NOT contain
4
4
  A page's tree is usually **not the whole page**. The header, the sidebar and the footer normally live in a **layout
@@ -185,5 +185,4 @@ Space-level configuration lives in \`plitzi://settings/{env}\` and is edited wit
185
185
  \`{ "type": "patchSettings", "customCss": "@keyframes spin { to { transform: rotate(360deg); } }" }\`.
186
186
 
187
187
  `;
188
- //#endregion
189
188
  export { structureGuide };
@@ -1,4 +1,4 @@
1
- //#region src/modules/mcp/helpers/guide/styling.ts
1
+ // src/modules/mcp/helpers/guide/styling.ts
2
2
  /** Styling: classes and selectors, variants and state, variables, tokens and fonts. */
3
3
  var stylingGuide = `## Styling (crosses both schemas)
4
4
  - **Mind the type's intrinsic default style.** A type renders with a base CSS *before* any class is attached — read
@@ -114,5 +114,4 @@ Any ancestor counts, not only the parent; the class's own states and variants wi
114
114
  in their fallback.
115
115
 
116
116
  `;
117
- //#endregion
118
117
  export { stylingGuide };
@@ -1,6 +1,5 @@
1
1
  import { BUILTIN_TRANSFORMERS, GLOBAL_SOURCES } from "@plitzi/sdk-authoring";
2
- //#region src/modules/mcp/helpers/guide/values.ts
2
+ // src/modules/mcp/helpers/guide/values.ts
3
3
  var GLOBALS = GLOBAL_SOURCES.map((source) => `\`${source}\``).join(", ");
4
4
  var OTHER_TRANSFORMERS = Object.keys(BUILTIN_TRANSFORMERS).filter((action) => action !== "twigTemplate").map((action) => `\`${action}\``).join(", ");
5
- //#endregion
6
5
  export { GLOBALS, OTHER_TRANSFORMERS };
@@ -1,5 +1,5 @@
1
1
  import { applyBuiltinCallback, applyElementCallback, applyUtility } from "../catalogs/index.js";
2
- //#region src/modules/mcp/helpers/interactions.ts
2
+ // src/modules/mcp/helpers/interactions.ts
3
3
  var BINDING_CATEGORIES = [
4
4
  "attributes",
5
5
  "style",
@@ -130,5 +130,4 @@ var bindingsToAI = (bindings) => {
130
130
  }
131
131
  return Object.keys(result).length > 0 ? result : void 0;
132
132
  };
133
- //#endregion
134
133
  export { BINDING_CATEGORIES, NULLISH_ELEMENT_IDS, bindingToAI, bindingsToAI, flowsFromInteractions, materializeFlow, newNodeId };
@@ -1,4 +1,4 @@
1
- import { ServerLogger } from '@plitzi/sdk-shared';
1
+ import { ServerLogger } from '@plitzi/sdk-kernel/types';
2
2
  export interface McpLog {
3
3
  toolCall(name: string, args: unknown, ms: number, error?: unknown): void;
4
4
  resourceRead(uri: string, ms: number, error?: unknown): void;
@@ -1,5 +1,5 @@
1
- import { renderLogEvent } from "@plitzi/sdk-server/kernel";
2
- //#region src/modules/mcp/helpers/log.ts
1
+ import { renderLogEvent } from "@plitzi/sdk-kernel/log";
2
+ // src/modules/mcp/helpers/log.ts
3
3
  var MCP_DEBUG = process.env.MCP_DEBUG === "1";
4
4
  var MCP_LOG_ARGS = process.env.MCP_LOG_ARGS === "1";
5
5
  var shapeOf = (value, depth = 0) => {
@@ -60,5 +60,4 @@ var createMcpLog = (logger) => {
60
60
  })
61
61
  };
62
62
  };
63
- //#endregion
64
63
  export { createMcpLog };
@@ -1,4 +1,4 @@
1
- //#region src/modules/mcp/helpers/opResult.ts
1
+ // src/modules/mcp/helpers/opResult.ts
2
2
  var empty = () => ({
3
3
  created: 0,
4
4
  updated: 0,
@@ -14,5 +14,4 @@ var fail = (path, message, hint, validValues) => ({
14
14
  validValues
15
15
  }]
16
16
  });
17
- //#endregion
18
17
  export { empty, fail };
@@ -1,5 +1,6 @@
1
1
  import { AIElementDetail } from '../types';
2
- import { ActionEntry, ActionTaskDescriptor, ComponentCatalog, ConnectorEntry, DataDraft, Element, FunctionsDraft, PageFolder, Schema, Style } from '@plitzi/sdk-shared';
2
+ import { ComponentCatalog } from '@plitzi/sdk-kernel/types';
3
+ import { ActionEntry, ActionTaskDescriptor, ConnectorEntry, DataDraft, Element, FunctionsDraft, PageFolder, Schema, Style } from '@plitzi/sdk-shared';
3
4
  import { TSpaceEntitlements } from '@plitzi/sdk-shared/network';
4
5
  /** The working view the tools read and mutate: the two Plitzi schemas (elements + style), which the platform
5
6
  * stores and persists as separate documents (Space model / Style model), plus the space's `connectors` — a third
@@ -1,5 +1,5 @@
1
1
  import { descendants } from "@plitzi/sdk-schema";
2
- //#region src/modules/mcp/helpers/space.ts
2
+ // src/modules/mcp/helpers/space.ts
3
3
  var cloneSpace = (space) => ({
4
4
  schema: structuredClone(space.schema),
5
5
  style: structuredClone(space.style),
@@ -300,5 +300,4 @@ var ReadOnlyGrantError = class extends Error {
300
300
  this.name = "ReadOnlyGrantError";
301
301
  }
302
302
  };
303
- //#endregion
304
303
  export { NoSpaceError, ReadOnlyGrantError, cloneSpace, descendantCount, elementById, emptySpace, emptySpaceMessage, findActionEntry, findConnectorEntry, findElementByRef, findFolderByRef, findLayoutByRef, findPageByRef, findRootByRef, folderAncestorIds, getLayoutElements, getPageElements, indexAddElement, indexAddLayout, indexAddPage, indexInvalidateDetails, indexRemoveElements, indexRemoveLayout, indexRemovePage, invalidateIndex, isPageElement, nameOf, noSpaceErrorCode, orderedChildren, pageFoldersOf, pageRefOfElement, pagesUsingLayout, readOnlyGrantErrorCode, readOnlyGrantMessage, resolveRef, routeParamNames, slugRouteParams, slugify, sortFolders, spaceIndex, strOr, unauthorizedSpaceMessage };
@@ -1,4 +1,4 @@
1
- //#region src/modules/mcp/helpers/uris.ts
1
+ // src/modules/mcp/helpers/uris.ts
2
2
  var guideUri = "plitzi://guide";
3
3
  var typesUri = "plitzi://types";
4
4
  var cssPropertiesUri = "plitzi://css-properties";
@@ -63,5 +63,4 @@ var itemTemplates = (env) => [
63
63
  /** The remainder of `uri` after `prefix`, or undefined when it does not start with it — so a resolver matches a
64
64
  * family and extracts its ref in one step, without repeating the prefix string for both the startsWith and slice. */
65
65
  var afterPrefix = (uri, prefix) => uri.startsWith(prefix) ? uri.slice(prefix.length) : void 0;
66
- //#endregion
67
66
  export { actionTasksUri, actionUri, actionsUri, afterPrefix, aliasedRoots, changesUri, componentsUri, connectorPresetsUri, connectorUri, connectorsUri, cssPropertiesUri, dataFileUri, dataSourcesUri, dataUri, defUri, defsUri, elementUri, flagsUri, folderUri, foldersUri, fontUri, fontsUri, functionFileUri, functionsUri, globalUri, globalsUri, guideUri, idUri, idsUri, interactionsUri, itemTemplates, layoutsUri, pageUri, pagesUri, primerUri, schemaVarsUri, settingsUri, styleVarUri, styleVarsUri, typesUri };
@@ -1,6 +1,6 @@
1
1
  import { outlineOfSnapshot, outlineOfTree } from "./accessibilityOutline.js";
2
- import { PREVIEW_TOKEN_PARAM } from "@plitzi/sdk-server/kernel";
3
- //#region src/modules/mcp/localScreenshotClient.ts
2
+ import { PREVIEW_TOKEN_PARAM } from "@plitzi/sdk-kernel/identity";
3
+ // src/modules/mcp/localScreenshotClient.ts
4
4
  /**
5
5
  * Grow the window to whatever actually scrolls before shooting.
6
6
  *
@@ -72,7 +72,7 @@ var emulateCaptureMedia = async (page, colorScheme) => {
72
72
  var createLocalScreenshotClient = async ({ renderBaseUrl, ignoreHttpsErrors = true }) => {
73
73
  const driver = await resolveLocalBrowser();
74
74
  if (!driver) return;
75
- return { async capture({ pagePath, token, viewports, fullPage = true, colorScheme, views = ["image"] }) {
75
+ return { async capture({ pagePath, token, viewports, fullPage = true, colorScheme, views = ["image"], format = "png", quality = 80 }) {
76
76
  const url = new URL(pagePath, renderBaseUrl);
77
77
  if (token) url.searchParams.set(PREVIEW_TOKEN_PARAM, token);
78
78
  /**
@@ -109,13 +109,17 @@ var createLocalScreenshotClient = async ({ renderBaseUrl, ignoreHttpsErrors = tr
109
109
  });
110
110
  }
111
111
  if (views.includes("image")) {
112
- const shot = await page.screenshot({
112
+ const shot = await page.screenshot(format === "webp" ? {
113
+ type: "webp",
114
+ quality,
115
+ fullPage
116
+ } : {
113
117
  type: "png",
114
118
  fullPage
115
119
  });
116
120
  images.push({
117
121
  label: viewport.label,
118
- mimeType: "image/png",
122
+ mimeType: format === "webp" ? "image/webp" : "image/png",
119
123
  data: Buffer.from(shot).toString("base64")
120
124
  });
121
125
  }
@@ -141,5 +145,4 @@ var createLocalScreenshotClient = async ({ renderBaseUrl, ignoreHttpsErrors = tr
141
145
  }
142
146
  } };
143
147
  };
144
- //#endregion
145
148
  export { createLocalScreenshotClient, resolveLocalBrowser };
@@ -1,4 +1,4 @@
1
- //#region src/modules/mcp/previewClient.ts
1
+ // src/modules/mcp/previewClient.ts
2
2
  /** Default `PreviewClient`: POSTs the preview request to the SSR `/preview` endpoint over HTTP. Used when the
3
3
  * MCP server is a separate process from the SSR renderer (the common case). A network/HTTP failure surfaces as
4
4
  * an `ok:false` result rather than throwing, so the calling tool can degrade gracefully. */
@@ -27,5 +27,4 @@ var createHttpPreviewClient = ({ url, secret, fetchImpl = fetch }) => ({ async r
27
27
  };
28
28
  return await res.json();
29
29
  } });
30
- //#endregion
31
30
  export { createHttpPreviewClient };
@@ -1,6 +1,6 @@
1
1
  import { ResourceProxy, ResourceProxySettings } from './types';
2
2
  import { McpProxyOptions } from '../../../options';
3
- import { SSRRequest } from '@plitzi/sdk-shared';
3
+ import { SSRRequest } from '@plitzi/sdk-kernel/types';
4
4
  export declare const PROXY_PATH = "/__proxy";
5
5
  /** What this deployment serves at its widget endpoint, or undefined when it serves none. A secret is what turns it
6
6
  * on: without one the endpoint could not tell its own widgets' URLs from anyone else's, and an unsigned fetcher
@@ -1,7 +1,7 @@
1
1
  import { connectionId } from "./sign.js";
2
2
  import { DEFAULT_PROXY_TOOLS } from "./types.js";
3
- import { requestOrigin } from "@plitzi/sdk-server/kernel";
4
- //#region src/modules/mcp/proxy/config.ts
3
+ import { requestOrigin } from "@plitzi/sdk-kernel/http";
4
+ // src/modules/mcp/proxy/config.ts
5
5
  var PROXY_PATH = "/__proxy";
6
6
  var MAX_BYTES = 8388608;
7
7
  var TTL_SECONDS = 604800;
@@ -58,5 +58,4 @@ var grantingProxy = (settings, req, identity) => {
58
58
  * and lasts as long as the widget does; a tool that WRITES a space (plitzi_apply) would persist those URLs into
59
59
  * content the user owns, which is why it is not on the list unless a deployment puts it there deliberately. */
60
60
  var proxyForTool = (proxy, tool) => proxy?.tools.includes(tool) ? proxy : void 0;
61
- //#endregion
62
61
  export { PROXY_PATH, grantingProxy, proxyForTool, proxySettings, requestProxy };
@@ -1,5 +1,5 @@
1
1
  import { isPublicHost } from "./guard.js";
2
- //#region src/modules/mcp/proxy/fetch.ts
2
+ // src/modules/mcp/proxy/fetch.ts
3
3
  var TIMEOUT_MS = 1e4;
4
4
  var MAX_REDIRECTS = 4;
5
5
  var ALLOWED_TYPES = {
@@ -87,5 +87,4 @@ var fetchResource = async (target, kind, maxBytes) => {
87
87
  clearTimeout(timer);
88
88
  }
89
89
  };
90
- //#endregion
91
90
  export { fetchResource };
@@ -1,5 +1,5 @@
1
1
  import { sign, verify } from "./sign.js";
2
- //#region src/modules/mcp/proxy/grant.ts
2
+ // src/modules/mcp/proxy/grant.ts
3
3
  /** The single query parameter a proxied URL carries: `<signature>.<kind>.<expiry>.<connection>.<target>`. One
4
4
  * parameter rather than several so the URL holds no `&` — these end up inside HTML attributes and markdown
5
5
  * links, where an unescaped ampersand is the kind of detail that silently truncates a URL. */
@@ -63,5 +63,4 @@ var readGrant = (param, secret) => {
63
63
  * `data:`/`blob:` carry their own bytes, and a relative URL has no origin to reach in the first place. */
64
64
  var isRemote = (url) => /^https?:\/\//i.test(url);
65
65
  var isGranted = (url, proxy) => url.startsWith(`${proxy.endpoint}?`);
66
- //#endregion
67
66
  export { grantUrl, isGranted, isRemote, readGrant };
@@ -1,7 +1,7 @@
1
- import { isBlockedHost } from "@plitzi/sdk-server/kernel";
2
1
  import { lookup } from "node:dns/promises";
3
2
  import { isIP } from "node:net";
4
- //#region src/modules/mcp/proxy/guard.ts
3
+ import { isBlockedHost } from "@plitzi/sdk-kernel/outbound";
4
+ // src/modules/mcp/proxy/guard.ts
5
5
  /**
6
6
  * Whether an ADDRESS is never the public internet. The ranges are sdk-server's, the same rule its `http.request` task
7
7
  * and connector engine follow: this module used to keep its own copy, and the copy judged `::ffff:7f00:1` — the form a
@@ -30,5 +30,4 @@ var isPublicHost = async (hostname) => {
30
30
  return false;
31
31
  }
32
32
  };
33
- //#endregion
34
33
  export { isPrivateAddress, isPublicHost };
@@ -1,5 +1,5 @@
1
1
  import { ResourceProxySettings } from './types';
2
- import { SSRRequest, SSRResponseHelpers } from '@plitzi/sdk-shared';
2
+ import { SSRRequest, SSRResponseHelpers } from '@plitzi/sdk-kernel/types';
3
3
  /** Serve one external resource on behalf of a widget: check the grant this server signed, fetch the target, and
4
4
  * stream it back under this origin — the one the CSP declares. Read-only, credential-free and CORS-open, because
5
5
  * it answers the host's sandboxed iframe: a browser that has no origin of its own and can present nothing. The
@@ -1,8 +1,8 @@
1
1
  import { grantingProxy } from "./config.js";
2
- import { readGrant } from "./grant.js";
3
2
  import { fetchResource } from "./fetch.js";
3
+ import { readGrant } from "./grant.js";
4
4
  import { rewritablePayload, rewritePayload } from "./payload.js";
5
- //#region src/modules/mcp/proxy/handler.ts
5
+ // src/modules/mcp/proxy/handler.ts
6
6
  var CACHE_CONTROL = {
7
7
  asset: "public, max-age=86400, immutable",
8
8
  data: "no-store"
@@ -95,5 +95,4 @@ var handleProxyRequest = async (req, res, settings) => {
95
95
  res.end();
96
96
  }
97
97
  };
98
- //#endregion
99
98
  export { handleProxyRequest };
@@ -1,6 +1,6 @@
1
1
  import { grantUrl, isGranted, isRemote } from "./grant.js";
2
2
  import { looksLikeAsset } from "./rewrite.js";
3
- //#region src/modules/mcp/proxy/payload.ts
3
+ // src/modules/mcp/proxy/payload.ts
4
4
  var JSON_TYPES = ["application/json", "application/ld+json"];
5
5
  var ASSET_FIELD = /(image|img|thumb|photo|picture|avatar|icon|logo|cover|banner|poster|artwork|media|src)/i;
6
6
  /** Is this what the endpoint fetched a body it can rewrite? Only JSON: it is what an apiContainer binds against,
@@ -25,5 +25,4 @@ var rewritePayload = (body, proxy) => {
25
25
  return body;
26
26
  }
27
27
  };
28
- //#endregion
29
28
  export { rewritablePayload, rewritePayload };
@@ -1,5 +1,5 @@
1
1
  import { grantUrl, isGranted, isRemote } from "./grant.js";
2
- //#region src/modules/mcp/proxy/rewrite.ts
2
+ // src/modules/mcp/proxy/rewrite.ts
3
3
  var URL_ATTRIBUTES = ["src", "poster"];
4
4
  var MARKUP_ATTRIBUTES = ["content", "html"];
5
5
  var FETCHING_TYPE = "apiContainer";
@@ -148,5 +148,4 @@ var proxifyResources = (space, proxy) => {
148
148
  rewriteStyle(space.style, proxy);
149
149
  return warnings;
150
150
  };
151
- //#endregion
152
151
  export { looksLikeAsset, proxifyResources, rewriteText };
@@ -1,5 +1,5 @@
1
1
  import { createHmac, timingSafeEqual } from "node:crypto";
2
- //#region src/modules/mcp/proxy/sign.ts
2
+ // src/modules/mcp/proxy/sign.ts
3
3
  var SIGNATURE_LENGTH = 22;
4
4
  var sign = (payload, secret) => createHmac("sha256", secret).update(payload).digest("base64url").slice(0, SIGNATURE_LENGTH);
5
5
  var verify = (payload, signature, secret) => {
@@ -11,5 +11,4 @@ var verify = (payload, signature, secret) => {
11
11
  * Derived through the same secret, so it identifies without echoing any part of the token; a request with no
12
12
  * credential (the public widgets surface) gets the shared anonymous identity. */
13
13
  var connectionId = (authorization, secret) => authorization ? sign(`id:${authorization}`, secret).slice(0, 10) : "anon";
14
- //#endregion
15
14
  export { connectionId, sign, verify };
@@ -1,9 +1,8 @@
1
- //#region src/modules/mcp/proxy/types.ts
1
+ // src/modules/mcp/proxy/types.ts
2
2
  /** The tools a proxy may be handed to. `plitzi_render` alone by default, and that default is a guard, not a
3
3
  * convenience: a render is a THROWAWAY widget, so rewriting its URLs changes nothing that outlives the call —
4
4
  * while plitzi_apply writes to the user's real space, where a rewritten URL would be PERSISTED and the space
5
5
  * would come to depend on this server's endpoint for content it owns. Nothing else should be added here without
6
6
  * that being the intention. */
7
7
  var DEFAULT_PROXY_TOOLS = ["plitzi_render"];
8
- //#endregion
9
8
  export { DEFAULT_PROXY_TOOLS };
@@ -1,8 +1,8 @@
1
- import { findActionEntry } from "../helpers/space.js";
2
1
  import { actionTasksUri, actionUri, actionsUri, afterPrefix } from "../helpers/uris.js";
2
+ import { findActionEntry } from "../helpers/space.js";
3
3
  import { envelope } from "./envelope.js";
4
4
  import { actionTriggers, isActionEnabled, triggerAccess, triggerInput } from "@plitzi/sdk-shared/actions";
5
- //#region src/modules/mcp/resources/actions.ts
5
+ // src/modules/mcp/resources/actions.ts
6
6
  /**
7
7
  * What a `runServerAction` step needs to know without opening the flow: what the action is called, whether it can
8
8
  * run at all, and — per way in — who may use it and what it takes. The steps themselves are one read away: they
@@ -50,5 +50,4 @@ var readActionResource = (space, env, uri) => {
50
50
  document: entry.document
51
51
  }) : null;
52
52
  };
53
- //#endregion
54
53
  export { actionSummaries, readActionResource };
@@ -1,5 +1,5 @@
1
1
  import { afterPrefix, aliasedRoots, itemTemplates, primerUri } from "../helpers/uris.js";
2
- //#region src/modules/mcp/resources/canonical.ts
2
+ // src/modules/mcp/resources/canonical.ts
3
3
  var canonicalUri = (env, uri) => {
4
4
  const rest = afterPrefix(uri, `plitzi://schema/${env}/`);
5
5
  if (rest === void 0) return uri;
@@ -26,5 +26,4 @@ var resourceErrorMessage = (env, uri) => {
26
26
  validTemplates: [primerUri(env), ...itemTemplates(env)]
27
27
  });
28
28
  };
29
- //#endregion
30
29
  export { canonicalUri, resourceErrorMessage };
@@ -1,8 +1,8 @@
1
- import { findConnectorEntry } from "../helpers/space.js";
2
1
  import { afterPrefix, connectorUri, connectorsUri } from "../helpers/uris.js";
2
+ import { findConnectorEntry } from "../helpers/space.js";
3
3
  import { envelope } from "./envelope.js";
4
4
  import { connectorPresets, connectorTokens } from "@plitzi/sdk-shared/connectors";
5
- //#region src/modules/mcp/resources/connectors.ts
5
+ // src/modules/mcp/resources/connectors.ts
6
6
  /** What a provider element needs to know about a connector without opening it: which endpoints it can address,
7
7
  * which operators its filters may use, and which fields it publishes. The listing carries this for every
8
8
  * connector so choosing one — and wiring an apiContainer to it — takes a single read. */
@@ -42,5 +42,4 @@ var readConnectorResource = (space, env, uri) => {
42
42
  manifest: entry.manifest
43
43
  }) : null;
44
44
  };
45
- //#endregion
46
45
  export { connectorSummaries, readConnectorResource };
@@ -1,9 +1,9 @@
1
+ import { envelope } from "./envelope.js";
2
+ import { cssProperties, cssShorthands } from "../catalogs/index.js";
3
+ import { buildTypeRegistry } from "../catalogs/registry.js";
1
4
  import "../helpers/uris.js";
2
5
  import { guideText } from "../helpers/guide/index.js";
3
- import { buildTypeRegistry } from "../catalogs/registry.js";
4
- import { cssProperties, cssShorthands } from "../catalogs/index.js";
5
- import { envelope } from "./envelope.js";
6
- //#region src/modules/mcp/resources/core.ts
6
+ // src/modules/mcp/resources/core.ts
7
7
  /** Space-independent singletons: the usage guide, the observed type registry and the CSS property catalog.
8
8
  * Returns undefined when the URI is not one of these, so the router falls through to the next resolver. */
9
9
  var readCoreResource = (space, uri) => {
@@ -14,5 +14,4 @@ var readCoreResource = (space, uri) => {
14
14
  shorthands: cssShorthands
15
15
  });
16
16
  };
17
- //#endregion
18
17
  export { readCoreResource };
@@ -1,6 +1,6 @@
1
1
  import { afterPrefix, dataFileUri, dataUri } from "../helpers/uris.js";
2
2
  import { envelope } from "./envelope.js";
3
- //#region src/modules/mcp/resources/data.ts
3
+ // src/modules/mcp/resources/data.ts
4
4
  /**
5
5
  * The space's own data: JSON its server providers read (`query: '/data/<file>'`, `runtime: 'server'`), never served.
6
6
  * The listing says which files there are, so an agent reads the one it needs; a file reads whole — parsed, so its
@@ -42,5 +42,4 @@ var readDataResource = (space, env, uri) => {
42
42
  });
43
43
  }
44
44
  };
45
- //#endregion
46
45
  export { readDataResource };
@@ -1,5 +1,5 @@
1
1
  import { computeVersion } from "../helpers/computeVersion.js";
2
- //#region src/modules/mcp/resources/envelope.ts
2
+ // src/modules/mcp/resources/envelope.ts
3
3
  /** Wrap any read projection with the version its optimistic-concurrency checks key on. */
4
4
  var envelope = (data) => ({
5
5
  stateVersion: computeVersion(data),
@@ -10,5 +10,4 @@ var jsonContents = (uri, data) => ({ contents: [{
10
10
  mimeType: "application/json",
11
11
  text: JSON.stringify(data)
12
12
  }] });
13
- //#endregion
14
13
  export { envelope, jsonContents };
@@ -1,5 +1,5 @@
1
1
  import { EXPLAIN_KINDS, explain, explainKindOf, explainList, explanationText } from "@plitzi/sdk-authoring";
2
- //#region src/modules/mcp/resources/explain.ts
2
+ // src/modules/mcp/resources/explain.ts
3
3
  /** `plitzi://explain/{name}`: what a name means when authoring, or every name of a kind (`plitzi://explain/steps`). */
4
4
  var EXPLAIN_URI_TEMPLATE = "plitzi://explain/{name}";
5
5
  var PREFIX = "plitzi://explain/";
@@ -18,5 +18,4 @@ var explainResource = (uri) => {
18
18
  text: explanations.map(explanationText).join("\n\n")
19
19
  };
20
20
  };
21
- //#endregion
22
21
  export { EXPLAIN_URI_TEMPLATE, explainResource };
@@ -1,6 +1,6 @@
1
1
  import { afterPrefix, functionFileUri, functionsUri } from "../helpers/uris.js";
2
2
  import { envelope } from "./envelope.js";
3
- //#region src/modules/mcp/resources/functions.ts
3
+ // src/modules/mcp/resources/functions.ts
4
4
  /**
5
5
  * The space's own functions: the listing says what they declare and which files they are, so an agent knows where to
6
6
  * look before it reads one; a file reads whole. Server-side code — never a browser payload — and it holds no secret: a
@@ -31,5 +31,4 @@ var readFunctionsResource = (space, env, uri) => {
31
31
  content
32
32
  });
33
33
  };
34
- //#endregion
35
34
  export { readFunctionsResource };