@plitzi/sdk-mcp 0.33.2 → 0.34.1

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 (187) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/dist/index.d.ts +2 -2
  3. package/dist/index.js +3 -2
  4. package/dist/modules/mcp/catalogs/index.d.ts +2 -7
  5. package/dist/modules/mcp/catalogs/index.js +4 -0
  6. package/dist/modules/mcp/catalogs/observed.d.ts +1 -1
  7. package/dist/modules/mcp/catalogs/observed.js +2 -5
  8. package/dist/modules/mcp/catalogs/pluginCatalog.d.ts +17 -0
  9. package/dist/modules/mcp/catalogs/pluginCatalog.js +91 -0
  10. package/dist/modules/mcp/catalogs/registry.js +2 -3
  11. package/dist/modules/mcp/helpers/agentPrompt.js +9 -9
  12. package/dist/modules/mcp/helpers/guide.d.ts +2 -2
  13. package/dist/modules/mcp/helpers/guide.js +117 -50
  14. package/dist/modules/mcp/helpers/interactions.d.ts +5 -1
  15. package/dist/modules/mcp/helpers/interactions.js +15 -6
  16. package/dist/modules/mcp/helpers/space.d.ts +45 -28
  17. package/dist/modules/mcp/helpers/space.js +87 -87
  18. package/dist/modules/mcp/helpers/uris.d.ts +9 -0
  19. package/dist/modules/mcp/helpers/uris.js +10 -1
  20. package/dist/modules/mcp/index.d.ts +2 -0
  21. package/dist/modules/mcp/localScreenshotClient.d.ts +51 -0
  22. package/dist/modules/mcp/localScreenshotClient.js +106 -0
  23. package/dist/modules/mcp/proxy/rewrite.js +15 -1
  24. package/dist/modules/mcp/resources/actions.d.ts +25 -0
  25. package/dist/modules/mcp/resources/actions.js +54 -0
  26. package/dist/modules/mcp/resources/canonical.d.ts +1 -1
  27. package/dist/modules/mcp/resources/canonical.js +1 -1
  28. package/dist/modules/mcp/resources/connectors.d.ts +1 -1
  29. package/dist/modules/mcp/resources/core.js +1 -1
  30. package/dist/modules/mcp/resources/index.d.ts +1 -0
  31. package/dist/modules/mcp/resources/primer.d.ts +8 -1
  32. package/dist/modules/mcp/resources/primer.js +139 -15
  33. package/dist/modules/mcp/resources/register.js +24 -4
  34. package/dist/modules/mcp/resources/renderGuide.js +66 -14
  35. package/dist/modules/mcp/resources/router.js +3 -1
  36. package/dist/modules/mcp/resources/schema.js +6 -5
  37. package/dist/modules/mcp/resources/style.d.ts +2 -1
  38. package/dist/modules/mcp/resources/style.js +10 -3
  39. package/dist/modules/mcp/screenshotClient.js +3 -2
  40. package/dist/modules/mcp/server.js +12 -6
  41. package/dist/modules/mcp/tests/agentRoundtrip.test.d.ts +1 -0
  42. package/dist/modules/mcp/tests/layouts.test.d.ts +1 -0
  43. package/dist/modules/mcp/tools/apply/dispatch.js +30 -1
  44. package/dist/modules/mcp/tools/apply/index.d.ts +149 -15
  45. package/dist/modules/mcp/tools/apply/index.js +12 -2
  46. package/dist/modules/mcp/tools/operations/actions/actions.test.d.ts +1 -0
  47. package/dist/modules/mcp/tools/operations/actions/deleteAction.d.ts +9 -0
  48. package/dist/modules/mcp/tools/operations/actions/deleteAction.js +20 -0
  49. package/dist/modules/mcp/tools/operations/actions/document.d.ts +69 -0
  50. package/dist/modules/mcp/tools/operations/actions/document.js +73 -0
  51. package/dist/modules/mcp/tools/operations/actions/index.d.ts +90 -0
  52. package/dist/modules/mcp/tools/operations/actions/index.js +12 -0
  53. package/dist/modules/mcp/tools/operations/actions/patchAction.d.ts +45 -0
  54. package/dist/modules/mcp/tools/operations/actions/patchAction.js +71 -0
  55. package/dist/modules/mcp/tools/operations/actions/upsertAction.d.ts +47 -0
  56. package/dist/modules/mcp/tools/operations/actions/upsertAction.js +83 -0
  57. package/dist/modules/mcp/tools/operations/connectors/index.d.ts +10 -10
  58. package/dist/modules/mcp/tools/operations/connectors/manifest.d.ts +5 -5
  59. package/dist/modules/mcp/tools/operations/connectors/patchConnector.d.ts +5 -5
  60. package/dist/modules/mcp/tools/operations/connectors/upsertConnector.d.ts +5 -5
  61. package/dist/modules/mcp/tools/operations/index.d.ts +415 -40
  62. package/dist/modules/mcp/tools/operations/index.js +11 -2
  63. package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +2 -2
  64. package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +1 -1
  65. package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +2 -2
  66. package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +1 -1
  67. package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +4 -4
  68. package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +5 -5
  69. package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +6 -6
  70. package/dist/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +1 -1
  71. package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +11 -12
  72. package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +1 -1
  73. package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +4 -4
  74. package/dist/modules/mcp/tools/operations/schema/index.d.ts +2 -0
  75. package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +2 -2
  76. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +1 -1
  77. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +2 -2
  78. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +1 -1
  79. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +4 -4
  80. package/dist/modules/mcp/tools/operations/schema/operations.d.ts +28 -5
  81. package/dist/modules/mcp/tools/operations/schema/operations.js +4 -0
  82. package/dist/modules/mcp/tools/operations/schema/pages/deleteLayout.d.ts +9 -0
  83. package/dist/modules/mcp/tools/operations/schema/pages/deleteLayout.js +33 -0
  84. package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +1 -1
  85. package/dist/modules/mcp/tools/operations/schema/pages/upsertLayout.d.ts +22 -0
  86. package/dist/modules/mcp/tools/operations/schema/pages/upsertLayout.js +61 -0
  87. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +2 -0
  88. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +53 -18
  89. package/dist/modules/mcp/tools/operations/schema/shared.d.ts +5 -1
  90. package/dist/modules/mcp/tools/operations/schema/shared.js +2 -2
  91. package/dist/modules/mcp/tools/operations/schema/translator.d.ts +2 -1
  92. package/dist/modules/mcp/tools/operations/schema/translator.js +21 -9
  93. package/dist/modules/mcp/tools/operations/schema/write.d.ts +9 -22
  94. package/dist/modules/mcp/tools/operations/schema/write.js +23 -43
  95. package/dist/modules/mcp/tools/operations/schemaIds.js +7 -1
  96. package/dist/modules/mcp/tools/operations/style/fonts/deleteFont.d.ts +9 -0
  97. package/dist/modules/mcp/tools/operations/style/fonts/deleteFont.js +21 -0
  98. package/dist/modules/mcp/tools/operations/style/fonts/fonts.test.d.ts +1 -0
  99. package/dist/modules/mcp/tools/operations/style/fonts/upsertFont.d.ts +35 -0
  100. package/dist/modules/mcp/tools/operations/style/fonts/upsertFont.js +66 -0
  101. package/dist/modules/mcp/tools/operations/style/index.d.ts +2 -0
  102. package/dist/modules/mcp/tools/operations/style/operations.d.ts +34 -0
  103. package/dist/modules/mcp/tools/operations/style/operations.js +5 -1
  104. package/dist/modules/mcp/tools/operations/style/translator.d.ts +13 -1
  105. package/dist/modules/mcp/tools/operations/style/translator.js +18 -1
  106. package/dist/modules/mcp/tools/operations/style/write.js +1 -1
  107. package/dist/modules/mcp/tools/preview.d.ts +58 -5
  108. package/dist/modules/mcp/tools/preview.js +1 -1
  109. package/dist/modules/mcp/tools/render.d.ts +61 -5
  110. package/dist/modules/mcp/tools/render.js +10 -3
  111. package/dist/modules/mcp/tools/screenshot.d.ts +151 -16
  112. package/dist/modules/mcp/tools/screenshot.js +22 -13
  113. package/dist/modules/mcp/tools/search.js +3 -3
  114. package/dist/modules/mcp/tools/shared/interactionReport.d.ts +7 -0
  115. package/dist/modules/mcp/tools/shared/interactionReport.js +48 -0
  116. package/dist/modules/mcp/tools/shared/validator/audit.js +4 -4
  117. package/dist/modules/mcp/tools/shared/validator/batch.d.ts +1 -0
  118. package/dist/modules/mcp/tools/shared/validator/batch.js +11 -2
  119. package/dist/modules/mcp/tools/shared/validator/bindings.js +6 -6
  120. package/dist/modules/mcp/tools/shared/validator/connectors.js +1 -1
  121. package/dist/modules/mcp/tools/shared/validator/context.d.ts +3 -0
  122. package/dist/modules/mcp/tools/shared/validator/css.js +1 -1
  123. package/dist/modules/mcp/tools/shared/validator/index.js +29 -9
  124. package/dist/modules/mcp/tools/shared/validator/interactions.js +41 -7
  125. package/dist/modules/mcp/tools/shared/validator/refs.js +4 -4
  126. package/dist/modules/mcp/tools/validate.d.ts +149 -15
  127. package/dist/modules/mcp/types/aiSchema.d.ts +33 -4
  128. package/dist/modules/mcp/types/previewTypes.d.ts +19 -0
  129. package/dist/modules/mcp/types/screenshotTypes.d.ts +1 -0
  130. package/dist/modules/mcp/types/toolTypes.d.ts +6 -1
  131. package/dist/pipeline.js +1 -1
  132. package/dist/preview/createPreview.d.ts +4 -2
  133. package/dist/preview/createPreview.js +16 -6
  134. package/dist/server.d.ts +3 -0
  135. package/dist/server.js +3 -1
  136. package/dist/stages/preview.js +20 -1
  137. package/dist/tests/httpRequest.d.ts +2 -0
  138. package/package.json +20 -16
  139. package/skills/plitzi-render/SKILL.md +84 -11
  140. package/dist/modules/mcp/catalogs/builtinCallbacks.d.ts +0 -19
  141. package/dist/modules/mcp/catalogs/builtinCallbacks.js +0 -139
  142. package/dist/modules/mcp/catalogs/builtinComponents.d.ts +0 -4
  143. package/dist/modules/mcp/catalogs/builtinComponents.js +0 -165
  144. package/dist/modules/mcp/catalogs/builtinElementCallbacks.d.ts +0 -17
  145. package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +0 -50
  146. package/dist/modules/mcp/catalogs/builtinTransformers.d.ts +0 -28
  147. package/dist/modules/mcp/catalogs/builtinTransformers.js +0 -148
  148. package/dist/modules/mcp/catalogs/builtinUtilities.d.ts +0 -15
  149. package/dist/modules/mcp/catalogs/builtinUtilities.js +0 -90
  150. package/dist/modules/mcp/catalogs/cssCatalog/border.d.ts +0 -4
  151. package/dist/modules/mcp/catalogs/cssCatalog/border.js +0 -30
  152. package/dist/modules/mcp/catalogs/cssCatalog/box.d.ts +0 -4
  153. package/dist/modules/mcp/catalogs/cssCatalog/box.js +0 -31
  154. package/dist/modules/mcp/catalogs/cssCatalog/helpers.d.ts +0 -34
  155. package/dist/modules/mcp/catalogs/cssCatalog/helpers.js +0 -185
  156. package/dist/modules/mcp/catalogs/cssCatalog/index.d.ts +0 -18
  157. package/dist/modules/mcp/catalogs/cssCatalog/index.js +0 -131
  158. package/dist/modules/mcp/catalogs/cssCatalog/layout.d.ts +0 -9
  159. package/dist/modules/mcp/catalogs/cssCatalog/layout.js +0 -99
  160. package/dist/modules/mcp/catalogs/cssCatalog/visual.d.ts +0 -8
  161. package/dist/modules/mcp/catalogs/cssCatalog/visual.js +0 -147
  162. package/dist/modules/mcp/catalogs/paramSpec.d.ts +0 -39
  163. package/dist/modules/mcp/catalogs/paramSpec.js +0 -69
  164. package/dist/modules/oauth/authorize.d.ts +0 -7
  165. package/dist/modules/oauth/authorize.js +0 -177
  166. package/dist/modules/oauth/challenge.d.ts +0 -11
  167. package/dist/modules/oauth/challenge.js +0 -33
  168. package/dist/modules/oauth/consentPage.d.ts +0 -7
  169. package/dist/modules/oauth/consentPage.js +0 -118
  170. package/dist/modules/oauth/metadata.d.ts +0 -40
  171. package/dist/modules/oauth/metadata.js +0 -69
  172. package/dist/modules/oauth/params.d.ts +0 -5
  173. package/dist/modules/oauth/params.js +0 -5
  174. package/dist/modules/oauth/pkce.d.ts +0 -6
  175. package/dist/modules/oauth/pkce.js +0 -15
  176. package/dist/modules/oauth/records.d.ts +0 -71
  177. package/dist/modules/oauth/records.js +0 -46
  178. package/dist/modules/oauth/register.d.ts +0 -5
  179. package/dist/modules/oauth/register.js +0 -55
  180. package/dist/modules/oauth/respond.d.ts +0 -13
  181. package/dist/modules/oauth/respond.js +0 -44
  182. package/dist/modules/oauth/token.d.ts +0 -5
  183. package/dist/modules/oauth/token.js +0 -100
  184. package/dist/stages/oauth.d.ts +0 -19
  185. package/dist/stages/oauth.js +0 -114
  186. /package/dist/modules/mcp/catalogs/{builtinTransformers.test.d.ts → pluginCatalog.test.d.ts} +0 -0
  187. /package/dist/modules/mcp/{catalogs/cssCatalog/cssCatalog.test.d.ts → localScreenshotClient.test.d.ts} +0 -0
@@ -1,5 +1,5 @@
1
1
  //#region src/modules/mcp/helpers/guide.ts
2
- var serverInstructions = "Plitzi AI server: read-then-write editing of a Plitzi space. Reads follow a filesystem model — list cheap, read one item in detail on demand; never fetch a whole tree you do not need. Workflow: (1) read plitzi://primer/{env} once — it bundles the guide, types, css-properties and page/definition/variable summaries in a single call; (2) plitzi_search with include:\"detail\" to jump to elements — each hit then carries its uri, stateVersion AND full style/resolvedStyle, so an edit needs no per-element read; open a page skeleton or element only when you need its tree/detail (the skeleton already lists the style classes of each node, and plitzi_read fetches many uris at once); (3) plitzi_apply with dryRun to preview a batch; (4) plitzi_apply to persist, passing expectedResourceVersions to guard against concurrent edits — apply and search both hand back the versions you need for the next edit. Use patchElement / patchDefinition to change only some props / CSS (the upsert variants replace them all). An element read (and search include:\"detail\") inlines the CSS of the definitions it attaches under resolvedStyle, so you rarely need a separate definition read. Refs accept a semantic idRef ([A-Za-z0-9_-] starting with a letter, unique, chosen by you) or the raw id — the idRef is ALSO the runtime wiring key, so a provider source is `<type>_<idRef>.<field>`, visible to the provider’s DESCENDANTS only (bind inside its subtree). CSS is plain kebab-case — write shorthands freely (`border: 1px solid red`, `padding: 8px 16px`, `font: bold 16px/1.5 Arial`), they are expanded to longhands for you and STORED that way, so read-back shows the longhands; style vars are var(--name), schema vars are {{name}}. READERS — do not confuse them: MCP *resources* are the browsable catalog (list them, or open one by URI); plitzi_search FINDS refs by label/type/attribute; plitzi_read BATCH-fetches URIs you already hold. Reach for search/read to work; browse resources to discover. CMS / API integrations (Strapi, WordPress, Contentful, any REST service) go through a CONNECTOR: a manifest you author declaring the base URL, endpoints and auth template, which the SERVER executes — read plitzi://connector-presets for working ones and plitzi://connectors/{env} for this space’s. You never see or create the credential; the space owner attaches it, and the connector saves without one. An apiContainer reads through it only with runtime:\"server\". Elements also carry applied style variants + visibility (initialState), data bindings and interaction flows: edit them with patchElement (initialState), upsertBinding/patchBinding/deleteBinding, and upsertInteractionFlow/patchInteractionNode/deleteInteraction. An element read shows all three plus availableVariants (which variant each of its classes offers). Separately, to SHOW the user a small self-contained widget (offline, no space or backend) instead of editing the space — a card, hero, pricing table, a visual answer — use plitzi_render; read plitzi://render/guide for it.";
2
+ var serverInstructions = "Plitzi AI server: read-then-write editing of a Plitzi space. Reads follow a filesystem model — list cheap, read one item in detail on demand; never fetch a whole tree you do not need. Workflow: (1) read plitzi://primer/{env} once — it bundles the guide, types, css-properties and page/definition/variable summaries in a single call; (2) plitzi_search with include:\"detail\" to jump to elements — each hit then carries its uri, stateVersion AND full style/resolvedStyle, so an edit needs no per-element read; open a page skeleton or element only when you need its tree/detail (the skeleton already lists the style classes of each node, and plitzi_read fetches many uris at once); (3) plitzi_apply with dryRun to preview a batch; (4) plitzi_apply to persist, passing expectedResourceVersions to guard against concurrent edits — apply and search both hand back the versions you need for the next edit. Use patchElement / patchDefinition to change only some props / CSS (the upsert variants replace them all). An element read (and search include:\"detail\") inlines the CSS of the definitions it attaches under resolvedStyle, so you rarely need a separate definition read. Every element has ONE name and it IS its id ([A-Za-z0-9_-] starting with a letter, unique, chosen by you) — the same name is the runtime wiring key, so a provider source is `<type>_<name>.<field>`, visible to the provider’s DESCENDANTS only (bind inside its subtree). CSS is plain kebab-case — write shorthands freely (`border: 1px solid red`, `padding: 8px 16px`, `font: bold 16px/1.5 Arial`), they are expanded to longhands for you and STORED that way, so read-back shows the longhands; style vars are var(--name), schema vars are {{name}}. READERS — do not confuse them: MCP *resources* are the browsable catalog (list them, or open one by URI); plitzi_search FINDS elements by label/type/attribute and hands you the name to write ops against; plitzi_read BATCH-fetches URIs you already hold. Reach for search/read to work; browse resources to discover. CMS / API integrations (Strapi, WordPress, Contentful, any REST service) go through a CONNECTOR: a manifest you author declaring the base URL, endpoints and auth template, which the SERVER executes — read plitzi://connector-presets for working ones and plitzi://connectors/{env} for this space’s. You never see or create the credential; the space owner attaches it, and the connector saves without one. An apiContainer reads through it only with runtime:\"server\". Elements also carry applied style variants + visibility (initialState), data bindings and interaction flows: edit them with patchElement (initialState), upsertBinding/patchBinding/deleteBinding, and upsertInteractionFlow/patchInteractionNode/deleteInteraction. An element read shows all three plus availableVariants (which variant each of its classes offers). Separately, to SHOW the user a small self-contained widget (offline, no space or backend) instead of editing the space — a card, hero, pricing table, a visual answer — use plitzi_render; read plitzi://render/guide for it.";
3
3
  var widgetsOnlyInstructions = "Plitzi widget server (widgets-only connection). This connection carries NO Plitzi space: nothing can be read or edited in one, and the space tools are not offered here — do not look for them. What it does do is build self-contained UI widgets fully offline, with no backend, account or setup: call plitzi_render to SHOW the user a real rendered layout (card, hero, pricing table, checklist, form, gallery) instead of describing one. Read plitzi://render/guide first — the element/prop table, the style model and a worked example; plitzi://render/types lists every element type you can author (plitzi_read fetches both). To change a widget you already rendered, call plitzi_render again with patch:true and its renderId. If the user wants to edit their real Plitzi space from here, that is a reconnection they make: the integration must be re-authorized and granted a space (the consent screen lists theirs) — you cannot do it from this connection, and no retry will change it.";
4
4
  var guideQuickstart = `# Plitzi AI MCP — quickstart
5
5
  This is the condensed guide; read \`plitzi://guide\` for the full reference (every resource, op and example).
@@ -8,16 +8,22 @@ A space is **two schemas you edit together in one atomic \`plitzi_apply\` batch*
8
8
  pages/elements) and the **style schema** (definitions = CSS classes, tokens, theme). To style an element: write a
9
9
  **definition** and attach it via the element's \`style.base\` in the same batch.
10
10
 
11
+ **Big spaces:** a primer section may arrive as \`{elided:true, bytes, entries, read}\` instead of its contents —
12
+ the space outgrew what one cold-start read can carry. \`read\` is the resource that serves that exact section whole
13
+ (\`plitzi://definitions/{env}\`, \`plitzi://interactions/{env}\`, …). Read the ones your task needs; nothing is
14
+ missing, it is one round-trip away.
15
+
11
16
  **Workflow:** (1) you already have this primer (guide + types + css + page/style summaries). (2) \`plitzi_search\`
12
17
  with \`include:"detail"\` to find elements — each hit carries its \`uri\`, \`stateVersion\` and full style, so no
13
18
  per-element read. (3) \`plitzi_apply\` with \`dryRun:true\` to preview. (4) \`plitzi_apply\` to persist, passing
14
19
  \`expectedResourceVersions\` (uri → the stateVersion you read) for every resource you change — omitting it lets a
15
20
  concurrent edit be lost. Use \`patchElement\`/\`patchDefinition\` to change only some props/CSS (upsert replaces all).
16
21
 
17
- **Refs & wiring:** a ref is the semantic \`idRef\` (letters, numbers, hyphens and underscores, **starting with a
18
- letter — no dots**) or the raw id. The idRef is the runtime wiring key: a provider's source is \`<type>_<idRef>\`, and
19
- interactions target by it. A dot would split that path; an **underscore is fine** — the first \`_\` separates the type
20
- from the idRef (element types have none), so \`list_food_item\` reads unambiguously as type \`list\`, idRef \`food_item\`.
22
+ **Names & wiring:** an element has ONE name and it is its id (letters, numbers, hyphens and underscores,
23
+ **starting with a letter — no dots**). It is also the runtime wiring key: a provider's source is
24
+ \`<type>_<name>\`, and interactions target by it. A dot would split that path; an **underscore is fine** — the first
25
+ \`_\` separates the type from the name (element types have none), so \`list_food_item\` reads unambiguously as type
26
+ \`list\`, name \`food_item\`.
21
27
 
22
28
  **Styling:** CSS keys are **kebab-case** (\`background-color\`); \`var(--token)\` for style vars, \`{{name}}\` for schema
23
29
  vars. **Write plain CSS** — shorthands (\`border\`, \`padding\`, \`margin\`, \`gap\`, \`overflow\`, \`flex\`, \`background\`,
@@ -28,7 +34,7 @@ still \`display: flex\` + \`flex-direction\`/\`align-items\`/…, not a \`flex\`
28
34
  (\`text\` is \`display: inline\`). Global styles (\`button {…}\`) and id styles (\`#id\`) have their own ops.
29
35
 
30
36
  **Data bindings** (\`upsertBinding\`, category attributes|style|initialState): connect a \`source\` to a \`to\` field.
31
- A source \`<type>_<idRef>\` is scoped to the provider's **DESCENDANTS only** — bind inside the provider's subtree
37
+ A source \`<type>_<name>\` is scoped to the provider's **DESCENDANTS only** — bind inside the provider's subtree
32
38
  (module sources state/space/navigation/auth/collection are global). \`apiContainer.mockData\` is builder-only; set a
33
39
  real \`query\` for production. \`transformers: [{action, params}]\` post-process the value — use exact action names
34
40
  from \`plitzi://data-sources\`; \`twigTemplate\` formats it (the value is \`{{source}}\`, not \`{{value}}\`). \`when\` is
@@ -39,7 +45,7 @@ computed for you). Node types: \`callback\` (an element's own callback — \`ele
39
45
  (a source module — omit \`elementId\`, the MCP sets it), \`utility\` (no element). Element \`setState\`
40
46
  (category/key/value/revertOnFinish) ≠ global \`setState\` (source \`state\`, key/type/value). To turn a step off use
41
47
  \`patchInteractionNode {enabled:false}\` — \`deleteInteraction\` removes it (destructive; confirm first). Any param
42
- **value** can be a binding token \`{{ source }}\` (e.g. notification \`content: "{{ list_<idRef>.item.name }}"\`).
48
+ **value** can be a binding token \`{{ source }}\` (e.g. notification \`content: "{{ list_<name>.item.name }}"\`).
43
49
 
44
50
  **CMS / API integrations** (\`upsertConnector\`): a **connector** is a manifest declaring a provider's base URL,
45
51
  endpoints, auth template and filter operators, executed by the **server** — so integrating Strapi, WordPress,
@@ -48,7 +54,7 @@ template token) and \`plitzi://connectors/{env}\` (this space's). **You never cr
48
54
  manifest with \`{{credential.token}}\` and no \`connection.credential\`; it saves, and the space owner attaches the
49
55
  secret in the builder. To consume one, an \`apiContainer\` needs **\`runtime: "server"\`** plus \`connector\`,
50
56
  \`resource\`, optional \`endpoint\`/\`filters\`/\`limit\`/\`singleRecord\`/\`pagination\`; it then publishes
51
- \`apiContainer_<idRef>.records\` (or \`.record\`) \`.pageInfo .isEmpty .hasError\` to its **descendants**. Full worked
57
+ \`apiContainer_<name>.records\` (or \`.record\`) \`.pageInfo .isEmpty .hasError\` to its **descendants**. Full worked
52
58
  flow — list page, detail page, paging, writes — in \`plitzi://guide\`.
53
59
 
54
60
  **Pages & navigation:** \`upsertPage\` — always set a **relative** \`slug\` (no leading \`/\`; the runtime and folder
@@ -124,6 +130,8 @@ Never download a whole tree you do not need.
124
130
  Space-independent. Read it before writing a connector by hand.
125
131
  - \`plitzi://connectors/{env}\` — the **connectors this space has**: for each, its read/write endpoint names, its
126
132
  filter operators and its published fields. \`/{ref}\` opens one manifest in full. See *Connectors* below.
133
+ - \`plitzi://actions/{env}\` — the **server actions this space has**: what starts each one, who may run it, and the
134
+ input/output contract a caller is held to. \`/{ref}\` opens one flow in full. See *Server actions* below.
127
135
 
128
136
  The style resources also answer under the \`plitzi://schema/{env}/…\` root as aliases — \`plitzi://schema/{env}/definitions/{ref}\`, \`plitzi://schema/{env}/style-variables/{category}\`, \`plitzi://schema/{env}/schema-variables\` — but prefer the ready-made \`uri\` from search / a write response over hand-building either form.
129
137
 
@@ -172,7 +180,7 @@ Three ways to read, each for a different moment — pick by what you have in han
172
180
  label/type/attribute and hands back the uri + stateVersion (and, with \`include:"detail"\`, the full element).
173
181
  - **\`plitzi_read\`** — you **already hold one or more uris** (from search or a write response) and want their
174
182
  content in one batch. It is the tool form of opening resources, for when you have the addresses.
175
- Rule of thumb: **discover → resources**, **find a ref → plitzi_search**, **fetch known uris → plitzi_read**. Never
183
+ Rule of thumb: **discover → resources**, **find a name → plitzi_search**, **fetch known uris → plitzi_read**. Never
176
184
  hand-build a URI to guess your way to an element — search for it instead.
177
185
 
178
186
  Write tools return what **changed** (\`{ uri, stateVersion }\`) plus counts, and the **full detail of every element
@@ -182,34 +190,30 @@ uri+stateVersion — re-read them if you need their new content. The operation s
182
190
  schema (discriminated by \`type\`).
183
191
 
184
192
  ## Addressing
185
- Refs are the semantic \`idRef\` (e.g. \`"hero-cta"\`) or the element's **raw id** — both resolve. Creating an element
186
- stores the \`ref\` you chose as its **idRef**.
187
-
188
- The idRef is not just an alias — it is the **wiring key the runtime uses**. A provider registers its data source as
189
- \`<type>_<idRef>\`, so a \`source\` you write against a ref resolves to that element at runtime with no id translation.
190
- Rules for a **new** ref (both are enforced; a violation fails the batch):
191
- - Charset \`[A-Za-z0-9_-]\`, **starting with a letter** (e.g. \`"products-api"\`, \`"food_item"\`). A \`.\` would split the
192
- \`<type>_<idRef>.<field>\` source path and the interaction target lookup, so **no dots**. An **underscore is
193
- allowed**: the FIRST \`_\` separates \`<type>\` from \`<idRef>\` and element types are camelCase with none, so
194
- underscores inside the idRef are unambiguous (\`list_food_item\` → type \`list\`, idRef \`food_item\`).
195
- - **Unique across the space**; creating a ref that is taken is rejected (address the existing element instead).
193
+ Every element and page has **one name, and that name is its id**. You choose it, you address it by it, and the
194
+ runtime wires by it — there is no second key and nothing to translate. Creating an element with
195
+ \`"ref": "products-api"\` stores it under exactly that.
196
+
197
+ That name is the **wiring key**: a provider registers its data source as \`<type>_<name>\`, so a \`source\` you write
198
+ against a name resolves to that element at runtime. Rules for a **new** name (both enforced; a violation fails the
199
+ batch):
200
+ - Charset \`[A-Za-z0-9_-]\`, **starting with a letter** (e.g. \`"products-api"\`, \`"food_item"\`). A \`.\` would split
201
+ the \`<type>_<name>.<field>\` source path and the interaction target lookup, so **no dots**. An **underscore is
202
+ allowed**: the FIRST \`_\` separates \`<type>\` from the name and element types are camelCase with none, so
203
+ underscores inside a name are unambiguous (\`list_food_item\` → type \`list\`, name \`food_item\`).
204
+ - **Unique across the space**; a name that is taken is rejected (address the existing element instead).
205
+
206
+ **Never invent a name for something that already exists** — read it. Every read hands you the name back
207
+ (\`plitzi_search\`, a page skeleton, a write response), and that is the string every op takes.
196
208
 
197
209
  **Where an element renders** is its \`runtime\`, settable on \`upsertElement\`/\`patchElement\`: \`"shared"\` (the
198
210
  default, both sides), \`"client"\` (browser only) or \`"server"\` (SSR only). It matters for one thing above all — an
199
211
  \`apiContainer\` reads through a **connector** only when it is \`"server"\` (see *Connectors*). An element read
200
212
  reports it only when it is set.
201
213
 
202
- An idRef is **optional** on an element — one built in the builder may not have it. The consequence is specific: an
203
- element without an idRef **publishes no data source** and **holds no interactions**, because the runtime keys
204
- everything by idRef and the raw id is never a fallback. You do not have to fix this by hand: writing an
205
- interaction **mints an idRef for you** — the element that hosts the flow, and any element a node targets, is given
206
- a free \`<type>-<n>\` ref if it lacks one, and the flow is wired to it. A node target you write may be a raw id; it
207
- is normalised to that element's idRef. (To make an element a data-source **provider** to bind against, give it an
208
- idRef explicitly with \`patchElement\`, or create it with the \`ref\` you want — a created element stores its ref as
209
- its idRef.)
210
-
211
- **Renaming** an idRef moves the wiring key: every binding source and interaction target across the space that
212
- pointed at the old name is repointed with it, so the element stays wired. You do not have to rewrite them.
214
+ **Renaming** (\`patchElement\` with \`rename\`) moves the one key: the parent's child list, every binding source and
215
+ every interaction target across the space that named the old one is repointed with it, so nothing comes unwired.
216
+ You do not have to rewrite them.
213
217
 
214
218
  ## Styling (crosses both schemas)
215
219
  - **Mind the type's intrinsic default style.** A type renders with a base CSS *before* any class is attached — read
@@ -298,11 +302,11 @@ list into a list element:
298
302
  "binding": { "to": "items", "source": "apiContainer_x.data" } }\`.
299
303
 
300
304
  **Source scope — a source is visible to the provider's DESCENDANTS only.** An element source named
301
- \`<type>_<idRef>\` (e.g. \`apiContainer_products\`, \`list_food-list\`) is published by that element into the scope of
305
+ \`<type>_<name>\` (e.g. \`apiContainer_products\`, \`list_food-list\`) is published by that element into the scope of
302
306
  its **subtree**, so **only elements INSIDE the provider can bind to it**. Binding a sibling or an unrelated element
303
307
  to it resolves to nothing at runtime. So to consume \`apiContainer_products.data\`, the bound element must live under
304
308
  that apiContainer; inside a \`list\`, the repeated \`listItem\` and its children read the per-row source
305
- (\`list_<idRef>.item.<field>\`). Module sources (no \`<type>_<idRef>\` head — \`state\`, \`space\`, \`navigation\`,
309
+ (\`list_<name>.item.<field>\`). Module sources (no \`<type>_<name>\` head — \`state\`, \`space\`, \`navigation\`,
306
310
  \`auth\`, \`collection\`) are global and bindable anywhere. Binding an element to an element source outside its
307
311
  provider's subtree is schema-valid but **broken at runtime** (the source is not in scope), so
308
312
  \`plitzi_validate\`/\`plitzi_apply\` treat it as an **error and reject the batch** — move the element under the
@@ -342,40 +346,46 @@ you — never wire them by hand. Each step also has an \`enabled\` flag (see dis
342
346
  **Node types & \`elementId\`** — a step names which element (or module) provides the callback it runs. Picking the
343
347
  **wrong node type for an action** makes the runtime resolve it against nothing, so the step **silently does nothing**:
344
348
  - \`trigger\` — the event; belongs to the host element. \`elementId\` defaults to the host.
345
- - \`callback\` — a callback provided by a **specific element**. \`elementId\` is that element's ref (the flow host by
346
- default, or another element to act on); give its ref or raw id and it is normalised to the idRef. Every element
349
+ - \`callback\` — a callback provided by a **specific element**. \`elementId\` is that element's name (the flow host by
350
+ default, or another element to act on). Every element
347
351
  registers a built-in **\`setState\`** callback that changes **its own attribute or state**: params
348
352
  \`category\` (\`"attribute"\` — set a prop like \`content\`/\`disabled\` — or \`"state"\` — \`visibility\` or a style
349
353
  selector), \`key\`, \`value\` (a **scalar** whose type follows the target attribute — a real boolean \`true\`/\`false\`
350
354
  for a boolean attribute, a number for a numeric one, otherwise a string), and **\`revertOnFinish\`**. Set
351
355
  \`revertOnFinish: true\` for a **temporary** change (a "loading…" label, disabling a button while it works): it is
352
356
  **undone automatically when the flow finishes**, so you do **NOT** add manual restore steps at the end. This element
353
- \`setState\` has **no** \`type\` param (that belongs to the global one below). An element type may also register its
354
- own extra callbacks.
357
+ \`setState\` has **no** \`type\` param (that belongs to the global one below). Beside it every element registers
358
+ **\`toggleState\`** — the same write with **no \`value\`**: it stores the OPPOSITE of what is there
359
+ (\`category\`, \`key\`, \`revertOnFinish\`). That is how expand/collapse is authored — **one step on one trigger**,
360
+ never two \`setState\` branches under complementary \`when\` conditions, which read the state as it was when the
361
+ flow STARTED and so are always one step behind. An element type may also register its own extra callbacks.
355
362
  - \`globalCallback\` — a callback provided by a **source module**, NOT by any element: \`addNotification\` (source
356
- \`space\`), \`setState\`/\`clearState\` (\`state\`), \`navigate\` (\`navigation\`), \`authLogin\`/\`authLogout\`/
357
- \`authRefreshDetails\` (\`auth\`), \`addCollectionRecord\`/\`updateCollectionRecord\`/\`removeCollectionRecord\`
358
- (\`collection\`). Its \`elementId\` is the **source module id**, never the host element — a node that stored the host
359
- idRef here would resolve to nothing at runtime. **Omit \`elementId\`**: the MCP sets the correct source and fills the
363
+ \`space\`), \`setState\`/\`toggleState\`/\`clearState\` (\`state\`), \`navigate\` (\`navigation\`), \`login\`/\`logout\`/
364
+ \`refreshDetails\` (\`auth\`), \`runServerAction\`/\`cancelServerAction\` (\`actions\`). Its \`elementId\` is the
365
+ **source module id**, never the host element — a node that stored the host element's name here would resolve to
366
+ nothing at runtime. **Omit \`elementId\`**: the MCP sets the correct source and fills the
360
367
  builder's **param defaults** (e.g. \`addNotification\` gets \`autoDismiss:true\`, \`autoDismissTimeout:5000\`,
361
368
  \`placement:"top-right"\`, \`appeareance:"success"\`) for any params you leave out. Use **only** the params each
362
369
  callback declares (exact spelling) — for \`addNotification\` the visible text goes in \`content\`; there is **no**
363
370
  \`title\`/\`message\`/\`type\` param, and any unknown key is dropped. See the full param schema for each callback under
364
371
  \`globalCallbacks\` in \`plitzi://interactions/{env}\`.
365
- - **Two \`setState\`s — do not mix them:** the **element** \`setState\` (nodeType \`callback\`, on an element,
366
- category/key/value/revertOnFinish) changes THAT element's attribute/state and is what you want to change a button's
367
- label or disabled flag. The **global** \`setState\` (nodeType \`globalCallback\`, source \`state\`, key/type/value)
368
- writes \`runtime.state.<key>\`. They share a name but have different node types AND different params.
372
+ - **Two \`setState\`s (and two \`toggleState\`s) — do not mix them:** the **element** \`setState\` (nodeType
373
+ \`callback\`, on an element, category/key/value/revertOnFinish) changes THAT element's attribute/state and is what
374
+ you want to change a button's label or disabled flag. The **global** \`setState\` (nodeType \`globalCallback\`,
375
+ source \`state\`, key/type/value) writes \`runtime.state.<key>\`. They share a name but have different node types
376
+ AND different params, and \`toggleState\` splits the same way: on an element (category/key/revertOnFinish) it flips
377
+ that element's own field; on source \`state\` (key) it flips \`runtime.state.<key>\`. Pick the element one when
378
+ nothing outside the element needs to know it is open; pick the state one when something else binds to it.
369
379
  - \`utility\` — a built-in utility action (no element/source module); nodeType \`utility\`. Use the **exact** param
370
380
  names: \`delayTime\` waits \`time\` milliseconds (**not** \`delay\`), \`twigTemplate\` (\`returnMode\`, \`template\`),
371
381
  \`webHook\` (\`url\`, \`method\`, …). See \`utilities\` in \`plitzi://interactions/{env}\`.
372
382
 
373
383
  **A param value can be a data binding.** Any interaction param may hold a \`{{ source }}\` token instead of a literal —
374
- it resolves at runtime exactly like a prop binding, using the same source grammar (\`<type>_<idRef>.<path>\`, or a
384
+ it resolves at runtime exactly like a prop binding, using the same source grammar (\`<type>_<name>.<path>\`, or a
375
385
  module source like \`navigation\`/\`state\`). This is how a step reacts to *the data in context*: inside a \`listItem\`,
376
- a click on a row can show \`addNotification\` with \`content: "{{ list_<idRef>.item.name }}"\` — the clicked row's field.
386
+ a click on a row can show \`addNotification\` with \`content: "{{ list_<name>.item.name }}"\` — the clicked row's field.
377
387
  The value follows the source's type, so a token is valid even where a param expects a boolean/number. Copy/paste of an
378
- element repoints these tokens to the new idRefs automatically, along with the element's bindings.
388
+ element repoints these tokens to the copies' names automatically, along with the element's bindings.
379
389
 
380
390
  **Navigating between pages — prefer the \`Link\` element over an interaction.** For a plain "go to page X" the right
381
391
  tool is a \`link\` element (a container, see *Pages & folders*), not a \`navigate\` interaction step. Use the
@@ -423,6 +433,26 @@ server-rendered ignores its connector entirely.
423
433
  - \`plitzi://connectors/{env}\` — the connectors **this space already has**, each with its read/write endpoint names,
424
434
  its filter operators and its published fields. \`plitzi://connectors/{env}/{ref}\` opens one manifest in full.
425
435
 
436
+ ### Server actions
437
+ Work a page cannot do in the browser — charge a card, send mail, read a system only the server reaches. An action
438
+ is a stored flow the SERVER runs; a page names it and never learns what it does. Write one with
439
+ \`upsertAction\` / \`patchAction\`, then call it from a page flow with the \`runServerAction\` step (mode
440
+ \`await\` to use the result, \`detached\` to fire and carry on).
441
+
442
+ Four rules worth knowing before you write:
443
+
444
+ - **Steps are server tasks.** \`plitzi://actions/{env}/tasks\` lists what this deployment can run — a browser step
445
+ (\`setState\`, \`navigate\`) has nothing to act on here, and the reverse is true too: a task cannot run in a page
446
+ flow.
447
+ - **The contracts.** \`input\` is coerced and anything undeclared is DROPPED. The OUTPUT is whatever the final
448
+ \`flow.output\` step names — there is no separate list to keep in step with it — and that step must be LAST,
449
+ since only the last one that runs is answered. Everything else a step produced stays on the server.
450
+ - **Whether it runs lives on its TRIGGERS.** Each trigger step carries \`enabled\`, and the action is on when any
451
+ way into it is — there is no switch beside the flow. So "pause this action" means disabling its trigger step(s),
452
+ never deleting them.
453
+ - **A step names the credential it uses**, and sees no other. \`credentials\` on the document says which ones the
454
+ action may ask for at all; the secret itself is never yours to see, exactly as with a connector.
455
+
426
456
  ### Credentials are NOT yours to write
427
457
  You never create, see or transmit a secret. Author the manifest with the token in place
428
458
  (\`"value": "Bearer {{credential.token}}"\`) and **leave \`connection.credential\` unset** unless the user hands you an
@@ -478,7 +508,7 @@ The provider element is \`apiContainer\`, and it needs **both halves**:
478
508
  other than \`list\`), \`filters\`, \`limit\`, \`singleRecord\`, \`pagination\`, \`pageParam\`.
479
509
 
480
510
  It then publishes one source **to its descendants only** (like any provider — bind *inside* its subtree):
481
- \`apiContainer_<idRef>.records\` (an array), \`.pageInfo\` (\`page\`, \`pageCount\`, \`total\`, \`hasNextPage\`…),
511
+ \`apiContainer_<name>.records\` (an array), \`.pageInfo\` (\`page\`, \`pageCount\`, \`total\`, \`hasNextPage\`…),
482
512
  \`.isEmpty\`, \`.hasError\`, \`.errorMessage\`, \`.isLoading\`. With \`singleRecord: true\` it publishes \`.record\`
483
513
  instead of \`.records\` — that is what a **detail page** uses. Bind an empty-state block's visibility to \`.isEmpty\`
484
514
  and an error block's to \`.hasError\`; they are ordinary bindings, no special mechanism.
@@ -523,6 +553,43 @@ credential and refuses any action the manifest does not declare. Writes exist **
523
553
  builder and renders empty when published. If the user has no SSR deployment, say so rather than leaving them to
524
554
  discover it — the alternative is a browser-side \`query\`, which cannot keep a secret.
525
555
 
556
+ ## Shared layouts — the chrome a page does NOT contain
557
+ A page's tree is usually **not the whole page**. The header, the sidebar and the footer normally live in a **layout
558
+ container**: a shell several pages are rendered inside, so the navigation is authored once instead of once per page.
559
+
560
+ It is a **root of its own** — a \`layoutContainer\` element that no page owns and that is not in the page list — and
561
+ a page points at it with two attributes:
562
+ - \`layout\` — the shell's ref. This is the whole of "which chrome do I render inside".
563
+ - \`layoutContainer\` — the **slot**: the ref of a container INSIDE that shell where this page's own body is placed.
564
+
565
+ So a page with \`layout: "main-layout"\` renders \`main-layout\`'s whole tree, with its own elements dropped into the
566
+ one container it named. Two pages naming the same shell share every element of it — **editing the shell changes
567
+ every page that uses it**, which is the point and also the thing to say out loud before you touch one.
568
+
569
+ **Reading them.**
570
+ - \`plitzi://schema/{env}/layouts\` lists the shells: \`ref\`, \`label\`, \`usedBy\` (the pages), \`slots\`, \`elementCount\`.
571
+ - Every page in \`plitzi://schema/{env}/pages\` carries \`layout\` and \`layoutSlot\` when it has them.
572
+ - Read a shell exactly like a page: \`plitzi://schema/{env}/pages/{layoutRef}\` for its skeleton,
573
+ \`.../pages/{layoutRef}/styles\` for its classes. \`plitzi_search\` reports a layout's elements with the layout as
574
+ their \`pageRef\`.
575
+
576
+ **Writing them.** Every element/binding/interaction op takes the shell's ref as its \`pageRef\` — there is no separate
577
+ vocabulary:
578
+ \`\`\`json
579
+ { "type": "upsertElement", "pageRef": "main-layout", "parentRef": "sidebar",
580
+ "element": { "ref": "upgrade-card", "type": "container", "children": [ … ] } }
581
+ \`\`\`
582
+ - \`upsertLayout\` creates a shell (\`ref\`, \`label\`, \`subType\`). Put the chrome in it with \`upsertElement\`, including
583
+ an empty container to serve as the slot.
584
+ - \`upsertPage { layout, layoutContainer }\` attaches a page to it; \`layout: null\` detaches. A \`layoutContainer\` that
585
+ is not an element of that shell is refused — stored, it would render the page's body where nobody sees it.
586
+ - \`deleteLayout\` removes a shell and everything in it, and is **refused while any page still renders inside it**
587
+ (the refusal names them). Destructive: what it deletes is on every page that uses it, so confirm first.
588
+
589
+ **Where does this element belong?** If the user asks for something "on every page" — a nav item, a banner, a footer
590
+ link, an upgrade prompt in the sidebar — it belongs in the LAYOUT, not in the page you happen to have open. Check
591
+ the page's \`layout\` first; if the element you are looking for is not in the page's own tree, it is in the shell.
592
+
526
593
  ## Pages & folders
527
594
  - **Always set a \`slug\` when creating a page** (\`upsertPage\`) — it is the page's URL path and good practice for a
528
595
  clean, stable route (e.g. \`"pricing"\` or \`"posts/:postId"\`). Omit it and the page ref is used as the slug,
@@ -545,7 +612,7 @@ discover it — the alternative is a browser-side \`query\`, which cannot keep a
545
612
  use \`link\`.
546
613
 
547
614
  Pages can be grouped into **folders** (the sidebar tree). A folder is \`{ ref, name, slug, parentId? }\`; its \`ref\`
548
- **is its id** (there is no separate idRef), and that id is what a page and a nested folder reference.
615
+ **is its id**, and that id is what a page and a nested folder reference.
549
616
  - **Folder slugs PREPEND to the page URL — this is how nested URLs are built.** The full path is each ancestor
550
617
  folder's slug plus the page slug, joined by \`/\`: a page at slug \`"1-1-1"\` inside \`folder-1\` > \`folder-1-1\`
551
618
  resolves to \`/folder-1/folder-1-1/1-1-1\`. So a folder slug is part of the route; keep folder slugs relative too.
@@ -17,7 +17,11 @@ export interface FlowNodeInput {
17
17
  declare const BINDING_CATEGORIES: Array<keyof AIBindings>;
18
18
  export declare const NULLISH_ELEMENT_IDS: Set<string>;
19
19
  export declare const flowsFromInteractions: (interactions: Record<string, ElementInteraction> | undefined) => AIInteractionFlow[];
20
- export declare const newNodeId: () => string;
20
+ /** A readable id for an unnamed step: `<action>-<n>`, counted per action within the flow being written — which is
21
+ * the scope that resolves `{{<id>.output}}` from a later step. `isTaken` covers the ids the agent named in the
22
+ * same flow: a minted `navigate-1` landing on a step the caller already called `navigate-1` would not be a
23
+ * duplicate, it would be the two steps collapsing into one entry of the record. */
24
+ export declare const newNodeId: (action: string, counters: Map<string, number>, isTaken: (id: string) => boolean) => string;
21
25
  /** Materialize an ordered list of nodes into the stored linked-node map for ONE flow: assign ids where missing,
22
26
  * set flowId to the trigger id, and recompute beforeNode/afterNode from the order. `ownerId` is the default
23
27
  * source element for callbacks that name none. */
@@ -1,7 +1,4 @@
1
- import { applyBuiltinCallback } from "../catalogs/builtinCallbacks.js";
2
- import { applyElementCallback } from "../catalogs/builtinElementCallbacks.js";
3
- import { applyUtility } from "../catalogs/builtinUtilities.js";
4
- import { generateObjectId } from "./space.js";
1
+ import { applyBuiltinCallback, applyElementCallback, applyUtility } from "../catalogs/index.js";
5
2
  //#region src/modules/mcp/helpers/interactions.ts
6
3
  var BINDING_CATEGORIES = [
7
4
  "attributes",
@@ -58,12 +55,24 @@ var flowsFromInteractions = (interactions) => {
58
55
  });
59
56
  return flows;
60
57
  };
61
- var newNodeId = () => `node_${generateObjectId()}`;
58
+ /** A readable id for an unnamed step: `<action>-<n>`, counted per action within the flow being written — which is
59
+ * the scope that resolves `{{<id>.output}}` from a later step. `isTaken` covers the ids the agent named in the
60
+ * same flow: a minted `navigate-1` landing on a step the caller already called `navigate-1` would not be a
61
+ * duplicate, it would be the two steps collapsing into one entry of the record. */
62
+ var newNodeId = (action, counters, isTaken) => {
63
+ const base = action.replace(/[^A-Za-z0-9]/g, "") || "step";
64
+ let next = (counters.get(base) ?? 0) + 1;
65
+ while (isTaken(`${base}-${next}`)) next += 1;
66
+ counters.set(base, next);
67
+ return `${base}-${next}`;
68
+ };
62
69
  /** Materialize an ordered list of nodes into the stored linked-node map for ONE flow: assign ids where missing,
63
70
  * set flowId to the trigger id, and recompute beforeNode/afterNode from the order. `ownerId` is the default
64
71
  * source element for callbacks that name none. */
65
72
  var materializeFlow = (nodes, ownerId) => {
66
- const ids = nodes.map((node) => node.id || newNodeId());
73
+ const counters = /* @__PURE__ */ new Map();
74
+ const named = new Set(nodes.map((node) => node.id).filter(Boolean));
75
+ const ids = nodes.map((node) => node.id || newNodeId(node.action, counters, (id) => named.has(id)));
67
76
  const flowId = ids[0];
68
77
  const record = {};
69
78
  nodes.forEach((node, i) => {
@@ -1,5 +1,5 @@
1
1
  import { AIElementDetail } from '../types';
2
- import { ComponentCatalog, ConnectorEntry, Element, PageFolder, Schema, Style } from '@plitzi/sdk-shared';
2
+ import { ActionEntry, ActionTaskDescriptor, ComponentCatalog, ConnectorEntry, Element, PageFolder, Schema, Style } from '@plitzi/sdk-shared';
3
3
  /** The working view the tools read and mutate: the two Plitzi schemas (elements + style), which the platform
4
4
  * stores and persists as separate documents (Space model / Style model), plus the space's `connectors` — a third
5
5
  * store (one row per connector) that a provider element points into by identifier. `catalog` is read-only
@@ -8,26 +8,25 @@ export interface Space {
8
8
  schema: Schema;
9
9
  style: Style;
10
10
  connectors: ConnectorEntry[];
11
+ /** The space's server actions — a fourth store, one row each, addressed by the identifier a step names. */
12
+ actions: ActionEntry[];
13
+ /** The server tasks this deployment can run. Read-only reference data like `catalog`, not persisted: it is what
14
+ * the server has, not what the space owns, and an action authored against a task it lacks cannot run. */
15
+ actionTasks?: ActionTaskDescriptor[];
11
16
  catalog?: ComponentCatalog;
12
17
  }
13
18
  export declare const cloneSpace: (space: Space) => Space;
14
19
  export declare const emptySpace: () => Space;
15
20
  /** A connector by the identifier a provider element stores in its `connector` attribute. */
16
21
  export declare const findConnectorEntry: (space: Space, ref: string) => ConnectorEntry | undefined;
22
+ /** An action by the identifier a `runServerAction` step stores. */
23
+ export declare const findActionEntry: (space: Space, ref: string) => ActionEntry | undefined;
17
24
  export declare const slugify: (value: string) => string;
18
25
  /** A value when it is a string, otherwise undefined — for the many attributes typed as `unknown` that are strings
19
26
  * in practice (name, slug, subType, dom id…). */
20
27
  export declare const strOr: (value: unknown) => string | undefined;
21
28
  /** Display name of a page or element: its `name` attribute when set, otherwise its definition label. */
22
29
  export declare const nameOf: (el: Element) => string;
23
- /** Stable, human-readable ref for a page: its idRef, then slug, then a slugified label. A page without an idRef is
24
- * still addressable — unlike a data source, a page ref has meaningful fallbacks the agent can read off the tree. */
25
- export declare const pageRefOf: (el: Element) => string;
26
- /** Stable ref for ADDRESSING a non-page element in the tree: its idRef when present, otherwise the opaque id so an
27
- * element without one is still reachable — the agent needs to name it to give it an idRef in the first place.
28
- * This is not the wiring key: the runtime wires interactions and data sources by idRef only, so an element
29
- * addressed here by its id alone publishes no source and takes no interactions (see `getSourceName`). */
30
- export declare const elementRefOf: (el: Element) => string;
31
30
  /** A memoized element projection: its full detail and the stateVersion (content hash) derived from it, plus the
32
31
  * style object they were computed against (a different style ref forces a recompute). */
33
32
  export interface ElementVersion {
@@ -40,11 +39,17 @@ export interface SpaceIndex {
40
39
  pageIds: Set<string>;
41
40
  /** The page elements, in schema.flat insertion order (what getPageElements returns). */
42
41
  pageElements: Element[];
43
- /** page ref (idRef/slug/label) AND raw page id → the page element. First writer wins on a ref collision. */
44
- pageByRef: Map<string, Element>;
45
- /** non-page idRef AND raw id → the element. First writer wins on a ref collision. */
46
- elementByRef: Map<string, Element>;
47
- /** Any element id (page root or nested descendant) → the id of the page it belongs to. */
42
+ /**
43
+ * Ids of the LAYOUT roots — a `layoutContainer` nobody owns.
44
+ *
45
+ * A layout is the shell several pages are rendered inside (the header, the sidebar, the footer) and it is a root
46
+ * of its own: it is not in `schema.pages` and it hangs off no page, so every walk that started from the pages
47
+ * missed it and everything in it read as belonging to nothing.
48
+ */
49
+ layoutIds: Set<string>;
50
+ /** The layout root elements, in schema.flat insertion order. */
51
+ layoutElements: Element[];
52
+ /** Any element id → the id of the ROOT it belongs to: its page, or the layout shell it is part of. */
48
53
  pageOf: Map<string, string>;
49
54
  /** element id → its memoized detail/version, so a page-skeleton hash, a search hit and a follow-up element read
50
55
  * all resolve the same element once. Populated lazily by `elementView`; dropped whole on `invalidateIndex`. */
@@ -60,24 +65,37 @@ export declare const invalidateIndex: (schema: Schema) => void;
60
65
  export declare const indexAddElement: (schema: Schema, el: Element, pageId: string) => void;
61
66
  /** These non-page elements were deleted (an element and its descendants). */
62
67
  export declare const indexRemoveElements: (schema: Schema, els: Element[]) => void;
63
- /** An existing element was just given an idRef (it had none), so it becomes addressable by that ref. */
64
- export declare const indexReRefElement: (schema: Schema, el: Element) => void;
65
68
  /** A new page element was created. */
66
69
  export declare const indexAddPage: (schema: Schema, page: Element) => void;
70
+ /** A new layout shell was created. */
71
+ export declare const indexAddLayout: (schema: Schema, layout: Element) => void;
72
+ /** A layout shell and its `descendants` were deleted. */
73
+ export declare const indexRemoveLayout: (schema: Schema, layout: Element, descendants: Element[]) => void;
67
74
  /** A page and its `descendants` (its non-page elements) were deleted. */
68
75
  export declare const indexRemovePage: (schema: Schema, page: Element, descendants: Element[]) => void;
69
- /** A page's slug/name/default changed; re-key its pageByRef entry if that changed its ref. `oldRef` is the ref
70
- * computed BEFORE the attribute change. */
71
- export declare const indexReRefPage: (schema: Schema, page: Element, oldRef: string) => void;
72
- /** A move reparented an element within its page: the ref/page maps are unchanged, but the moved element's
73
- * parentRef and both parents' childRefs did change, so their memoized detail must be dropped. */
76
+ /** A move reparented an element within its page: the page map is unchanged, but the moved element's parent and
77
+ * both parents' children did change, so their memoized detail must be dropped. */
74
78
  export declare const indexInvalidateDetails: (schema: Schema) => void;
75
79
  export declare const isPageElement: (schema: Schema, el: Element) => boolean;
76
80
  export declare const getPageElements: (schema: Schema) => Element[];
77
- /** Finds a page by its semantic ref (idRef/slug/…) or its raw id, so legacy schemas without an idRef still resolve. */
78
- export declare const findPageByRef: (schema: Schema, pageRef: string) => Element | undefined;
79
- /** Find any non-page element by its semantic ref (idRef) or raw id, across the whole space. */
80
- export declare const findElementByRef: (schema: Schema, ref: string) => Element | undefined;
81
+ /** A page by the one name it answers to, which is also its key in `flat`. */
82
+ export declare const findPageByRef: (schema: Schema, pageId: string) => Element | undefined;
83
+ /** A non-page element by the one name it answers to, anywhere in the space. */
84
+ export declare const findElementByRef: (schema: Schema, id: string) => Element | undefined;
85
+ /** A layout SHELL by name — the root a page names in its `layout` attribute. */
86
+ export declare const findLayoutByRef: (schema: Schema, id: string) => Element | undefined;
87
+ /**
88
+ * The root an element operation addresses — a page, or a layout shell.
89
+ *
90
+ * `pageRef` names either: the header of a space lives in a layout and is edited exactly like anything on a page, so
91
+ * every op that resolves an element resolves it from here. Reading them apart is only for the operations that are
92
+ * about pages as pages (routes, folders, the default page).
93
+ */
94
+ export declare const findRootByRef: (schema: Schema, id: string) => Element | undefined;
95
+ /** The layout shells of a space, in schema.flat insertion order. */
96
+ export declare const getLayoutElements: (schema: Schema) => Element[];
97
+ /** The pages rendered inside a given layout shell, by the `layout` attribute that names it. */
98
+ export declare const pagesUsingLayout: (schema: Schema, layoutId: string) => Element[];
81
99
  export declare const pageFoldersOf: (schema: Schema) => PageFolder[];
82
100
  /** Resolve a folder by its id, or (for agent convenience) by an exact name or slug when that is unambiguous. */
83
101
  export declare const findFolderByRef: (schema: Schema, ref: string) => PageFolder | undefined;
@@ -96,8 +114,8 @@ export declare const routeParamNames: (schema: Schema) => string[];
96
114
  /** Indexed lookup that reflects the runtime reality: a flat id may be dangling (rsc placeholders, stale items). */
97
115
  export declare const elementById: (schema: Schema, id: string) => Element | undefined;
98
116
  export declare const descendantIds: (schema: Schema, pageRootId: string) => string[];
99
- /** Resolve a ref to a concrete element within a page subtree (or the page root itself). Accepts either the
100
- * semantic ref (idRef) or the raw element id, so schemas predating idRef keep working through their ids. */
117
+ /** Resolve a name to a concrete element within a page subtree (or the page root itself). The name is the element's
118
+ * key in `flat`; what this adds is the check that it really belongs to this page. */
101
119
  export declare const resolveRef: (schema: Schema, page: Element, ref: string) => Element | undefined;
102
120
  /** Ordered children of an element, honoring definition.items and skipping dangling ids. */
103
121
  export declare const orderedChildren: (schema: Schema, el: Element) => Element[];
@@ -123,4 +141,3 @@ export declare const readOnlyGrantMessage: string;
123
141
  export declare class ReadOnlyGrantError extends Error {
124
142
  constructor();
125
143
  }
126
- export declare const generateObjectId: () => string;