@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
@@ -11,12 +11,31 @@ var json = (ctx, status, payload) => {
11
11
  var previewStage = async (ctx) => {
12
12
  const preview = ctx.config.preview;
13
13
  const path = preview?.path ?? PREVIEW_PATH_DEFAULT;
14
- if (!preview?.enabled || ctx.req.method !== "POST" || ctx.req.path !== path) return false;
14
+ const ending = ctx.req.path === `${path}/end`;
15
+ if (!preview?.enabled || ctx.req.method !== "POST" || ctx.req.path !== path && !ending) return false;
15
16
  if (preview.secret && ctx.req.headers["x-preview-secret"] !== preview.secret) return json(ctx, 403, {
16
17
  error: "FORBIDDEN",
17
18
  message: "Invalid or missing preview secret."
18
19
  });
19
20
  ctx.req.body = await readRawBody(ctx.raw);
21
+ /**
22
+ * Ending a draft session, which is the half that makes one safe to offer.
23
+ *
24
+ * Without it a session is only ever ended by its own expiry, so "stop previewing" would leave a working URL behind
25
+ * for as long as the TTL says — and the person who asked to stop is precisely the one who has reason to think it
26
+ * no longer resolves.
27
+ *
28
+ * A token the store does not have answers 200 all the same: the caller asked for it to be gone, and it is.
29
+ */
30
+ if (ending) {
31
+ const { token } = JSON.parse(ctx.req.body || "{}");
32
+ if (typeof token !== "string" || !token) return json(ctx, 400, {
33
+ error: "BAD_REQUEST",
34
+ message: "token (string) is required."
35
+ });
36
+ await ctx.config.draftStore?.drop(token);
37
+ return json(ctx, 200, { ok: true });
38
+ }
20
39
  let body;
21
40
  try {
22
41
  body = JSON.parse(ctx.req.body || "{}");
@@ -1,6 +1,8 @@
1
+ import { default as http } from 'node:http';
1
2
  export type HttpProbeResult = {
2
3
  status: number;
3
4
  body: string;
5
+ headers: http.IncomingHttpHeaders;
4
6
  };
5
7
  /** Minimal HTTP client for the server-level tests. They drive a real listening server rather than calling a
6
8
  * handler, because what is under test is the pipeline — which stage answers, and in what order. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-mcp",
3
- "version": "0.33.2",
3
+ "version": "0.34.1",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist",
@@ -30,13 +30,16 @@
30
30
  "dependencies": {
31
31
  "@modelcontextprotocol/ext-apps": "^1.7.5",
32
32
  "@modelcontextprotocol/sdk": "^1.30.0",
33
- "@plitzi/plitzi-sdk": "0.33.2",
34
- "@plitzi/sdk-schema": "0.33.2",
35
- "@plitzi/sdk-server": "0.33.2",
36
- "@plitzi/sdk-shared": "0.33.2",
33
+ "@plitzi/plitzi-sdk": "0.34.1",
34
+ "@plitzi/sdk-elements": "0.34.1",
35
+ "@plitzi/sdk-interactions": "0.34.1",
36
+ "@plitzi/sdk-schema": "0.34.1",
37
+ "@plitzi/sdk-server": "0.34.1",
38
+ "@plitzi/sdk-shared": "0.34.1",
39
+ "@plitzi/sdk-style": "0.34.1",
37
40
  "ejs": "^6.0.1",
38
41
  "esbuild": "^0.28.2",
39
- "zod": "^4.4.3"
42
+ "zod": "^4.6.4"
40
43
  },
41
44
  "peerDependencies": {
42
45
  "react": "^19",
@@ -45,26 +48,27 @@
45
48
  "devDependencies": {
46
49
  "@types/ejs": "^3.1.5",
47
50
  "@types/jsdom": "^30.0.0",
48
- "@types/node": "^26.2.0",
49
- "@types/react": "^19.2.18",
50
- "@vitejs/plugin-react": "^6.0.5",
51
- "@vitest/coverage-v8": "^4.1.10",
51
+ "@types/node": "^26.5.1",
52
+ "@types/react": "^19.3.0",
53
+ "@vitejs/plugin-react": "^6.1.1",
54
+ "@vitest/coverage-v8": "^5.0.0",
52
55
  "eslint": "^9.39.5",
53
56
  "eslint-plugin-import": "^2.32.0",
54
57
  "jsdom": "^30.0.1",
55
- "react": "^19.2.8",
56
- "react-dom": "^19.2.8",
57
- "tsx": "^4.23.12",
58
+ "react": "^19.3.0",
59
+ "react-dom": "^19.3.0",
60
+ "tsx": "^4.23.13",
58
61
  "typescript": "^6.0.3",
59
- "vite": "^8.2.1",
60
- "vite-plugin-dts": "^5.0.3",
61
- "vitest": "^4.1.10"
62
+ "vite": "^8.3.0",
63
+ "vite-plugin-dts": "^5.1.0",
64
+ "vitest": "^5.0.0"
62
65
  },
63
66
  "scripts": {
64
67
  "start": "TSX_TSCONFIG_PATH=tsconfig.app.json node --import tsx dev/main.ts",
65
68
  "start:dev": "TSX_TSCONFIG_PATH=tsconfig.app.json node --import tsx --watch dev/main.ts",
66
69
  "start:inspect": "TSX_TSCONFIG_PATH=tsconfig.app.json node --import tsx --inspect dev/main.ts",
67
70
  "inspector": "yarn dlx @modelcontextprotocol/inspector@latest",
71
+ "inspector:legacy": "yarn dlx @modelcontextprotocol/inspector@1.0.1",
68
72
  "build:dev": "vite build --mode development",
69
73
  "build:prod": "vite build",
70
74
  "lint": "TIMING=1 eslint ./src ./dev",
@@ -4,7 +4,8 @@ description: >-
4
4
  Show answers as a rendered visual widget instead of plain text, using the Plitzi MCP's plitzi_render tool.
5
5
  Use whenever the reply is naturally visual or structured — a recipe, a comparison, pricing tiers, a profile,
6
6
  a menu, steps/checklist, a product card, a dashboard-like summary — or whenever the user asks to design,
7
- build, show, or "make it look nice". Requires the Plitzi MCP server (the plitzi_render tool) to be connected.
7
+ build, show, or "make it look nice", including widgets that react to clicks (toggles, expanders, tabs).
8
+ Requires the Plitzi MCP server (the plitzi_render tool) to be connected.
8
9
  ---
9
10
 
10
11
  # Rendering answers as Plitzi widgets
@@ -119,7 +120,7 @@ Everything the widget needs travels in ONE call, as `operations`. Three ops carr
119
120
  }
120
121
  ```
121
122
 
122
- ## The five things that decide whether it looks good
123
+ ## The six things that decide whether it looks good
123
124
 
124
125
  1. **Width is free, height is scarce.** The widget renders in a side panel. A plain container stacks its children
125
126
  vertically — that is the tall, half-empty default to avoid. Put peers (metrics, plans, options, image + text) in
@@ -128,16 +129,24 @@ Everything the widget needs travels in ONE call, as `operations`. Three ops carr
128
129
  order: heading over paragraph, forms, steps, prose.
129
130
  2. **The host may be in dark mode.** Never hardcode a light palette. Take colours from the host variables with a
130
131
  `light-dark()` fallback, and always set `color` wherever you set `background-color`.
131
- 3. **Watch the SDK defaults.** Every container has `min-width`/`min-height: 50px` — set them to `0` for rails,
132
- dividers, dots and any flex child that must shrink. Headings and paragraphs keep the browser's margins; zero
133
- them and space with the parent's `gap`.
132
+ 3. **You are not styling from zero.** The SDK's per-type CSS imposes **no minimum size**: a rail, a divider, a dot
133
+ or a narrow cell is exactly as small as you make it, and no `"min-width": "0"` escape hatch is needed. The flip
134
+ side is that an element with no content and no size takes no space at all — give a spacer its own `height`.
135
+ What does land on your elements is the BROWSER's own defaults: `heading` and `paragraph` keep their UA margins
136
+ (zero them, space with the parent's `gap`), `list` a 40px `padding-left`, `button` its native chrome. Borders
137
+ start at `0 solid`, so `border-color` alone paints nothing — give `border-width` too.
134
138
  4. **Draw with inline SVG, on a budget.** A logo, a sparkline, a badge or a decorative shape goes in a `blockHtml`
135
139
  element whose `props.content` is an `<svg>` — keep a `viewBox` with `width`/`height` `100%` so the element's
136
140
  class sizes it, and `fill`/`stroke` `currentColor` so it follows the theme. A handful of paths, drawn once and
137
141
  reused. Never a `data:` URI, and never a full illustration or a photo-real scene: that costs more than the rest
138
142
  of the widget, so use an `https` image, a flat colour or a CSS gradient instead. Markup only — `<script>` and
139
143
  inline `on*` handlers are rejected.
140
- 5. **Write CSS plainly.** Kebab-case properties, shorthands welcome (`padding: 8px 16px`, `border: 1px solid red`,
144
+ 5. **Only use image URLs you have seen work.** Everything the widget loads from outside is fetched for it by the
145
+ render server, so redirects, hotlink rules and missing CORS headers are already handled and there is nothing to
146
+ configure — but nothing can guess a URL. Write a direct file URL, never a page about the picture, a search
147
+ result, or a pattern assembled from memory: one that 404s leaves a grey box in the middle of a finished layout.
148
+ With no URL you trust, draw that block instead (a gradient, a flat colour, an inline `<svg>`).
149
+ 6. **Write CSS plainly.** Kebab-case properties, shorthands welcome (`padding: 8px 16px`, `border: 1px solid red`,
141
150
  `font: bold 16px/1.5 Arial`) — they are expanded and stored as longhands, so a breakpoint or state can override
142
151
  one property on its own.
143
152
 
@@ -162,13 +171,77 @@ storage, a conversation resumed elsewhere), send the whole batch again without `
162
171
  issues. The `path` names the operation, so fix that one and call again — you never lose the rest of the batch. An
163
172
  unknown prop comes back as a warning naming the right one, so probing is safe.
164
173
 
174
+ ## Making it interactive
175
+
176
+ Widgets are not only static: `upsertInteractionFlow` attaches a flow to an element — a `trigger` node first
177
+ (`onClick`), then the steps that run after it, in order.
178
+
179
+ **To show and hide, use `toggleState`.** Every element registers `setState` and `toggleState` as `callback`
180
+ actions, and `elementId` names the element they act on — the flow's own element by default, or another element's
181
+ ref to act on that one. `toggleState` with `category: "state"` and `key: "visibility"` is the show/hide toggle;
182
+ there is no separate `toggleVisibility` action. The element starts hidden with `initialState: { "visibility":
183
+ false }` on the element itself.
184
+
185
+ ```json
186
+ {
187
+ "operations": [
188
+ {
189
+ "type": "upsertElement",
190
+ "pageRef": "render",
191
+ "element": {
192
+ "ref": "card",
193
+ "type": "container",
194
+ "children": [
195
+ { "ref": "card-head", "type": "button", "props": { "content": "Details" } },
196
+ {
197
+ "ref": "card-body",
198
+ "type": "container",
199
+ "initialState": { "visibility": false },
200
+ "children": [
201
+ { "ref": "card-text", "type": "paragraph", "props": { "content": "The hidden detail." } }
202
+ ]
203
+ }
204
+ ]
205
+ }
206
+ },
207
+ {
208
+ "type": "upsertInteractionFlow",
209
+ "pageRef": "render",
210
+ "ref": "card-head",
211
+ "nodes": [
212
+ { "title": "On click", "nodeType": "trigger", "action": "onClick" },
213
+ {
214
+ "title": "Toggle body",
215
+ "nodeType": "callback",
216
+ "action": "toggleState",
217
+ "elementId": "card-body",
218
+ "params": { "category": "state", "key": "visibility" }
219
+ }
220
+ ]
221
+ }
222
+ ]
223
+ }
224
+ ```
225
+
226
+ Expand/collapse is **one step on one trigger** — never two `setState` branches under opposite `when` conditions,
227
+ which read the state as it was when the flow started and so are always one click behind. For several flows on one
228
+ element (an `onClick` and an `onMouseEnter`, or two independent clicks), call `upsertInteractionFlow` again with
229
+ the same `ref` and **omit `flowId`**; passing an existing `flowId` replaces that flow instead.
230
+
231
+ Two things routinely go wrong. Events **bubble**, so a clickable element inside another clickable element runs
232
+ BOTH flows — put the trigger on one of them (the render warns you and names the pair). And a `globalCallback`
233
+ (`addNotification`, `navigate`, app-level `setState`) is provided by a module, not by an element, so **omit
234
+ `elementId`** on those; a step with the wrong node type resolves against nothing and silently does nothing.
235
+
236
+ For data-driven widgets, an `apiContainer` fetches at runtime and `upsertBinding` wires the result into elements —
237
+ see "Data & interactivity" in `plitzi://render/guide`, which is also the full reference for everything above.
238
+
165
239
  ## After it renders
166
240
 
167
241
  The widget is shown to the user; you get a compact summary. Don't re-describe what they can already see — a short
168
242
  caption or a follow-up question is enough.
169
243
 
170
- ## Going further
171
-
172
- Widgets can be data-driven and interactive, not only static: an `apiContainer` fetches at runtime, `upsertBinding`
173
- wires that data into elements, and `upsertInteractionFlow` makes them react to clicks. See the "Data &
174
- interactivity" section of `plitzi://render/guide`.
244
+ When the widget has flows, the summary includes an `interactions` line per flow naming what got wired to what
245
+ (`"card-head onClick → toggleState card-body[visibility]"`). Read it: it is what confirms the flow landed on the
246
+ element you meant. But it reports the **wiring**, not a click that was performed — this tool authors the widget,
247
+ it does not drive it. So tell the user what you connected; never claim you verified the behaviour at runtime.
@@ -1,19 +0,0 @@
1
- import { ParamSpec } from './paramSpec';
2
- export interface BuiltinGlobalCallback {
3
- source: string;
4
- title: string;
5
- strictParams: boolean;
6
- params: ParamSpec;
7
- }
8
- export declare const BUILTIN_GLOBAL_CALLBACKS: Record<string, BuiltinGlobalCallback>;
9
- /** The built-in globalCallback for an action, or undefined when the action is not a known built-in (a plugin
10
- * callback whose source/schema is not knowable here). */
11
- export declare const getGlobalCallback: (action: string) => BuiltinGlobalCallback | undefined;
12
- /** Resolve a `globalCallback` action against the built-in catalog: returns the module id it is registered under
13
- * (`source`) and the params reconciled to the callback's schema — unknown keys dropped for a closed callback, then
14
- * missing defaults filled. An action the catalog does not know (e.g. a plugin callback) yields no source and
15
- * unchanged params, so the caller keeps its own behavior for it. */
16
- export declare const applyBuiltinCallback: (action: string, params: Record<string, unknown>) => {
17
- source?: string;
18
- params: Record<string, unknown>;
19
- };
@@ -1,139 +0,0 @@
1
- import { reconcileParams } from "./paramSpec.js";
2
- //#region src/modules/mcp/catalogs/builtinCallbacks.ts
3
- var BUILTIN_GLOBAL_CALLBACKS = {
4
- addNotification: {
5
- source: "space",
6
- title: "Add Notification",
7
- strictParams: true,
8
- params: {
9
- content: {
10
- type: "textarea",
11
- description: "The notification text shown to the user — this is the message body. There is no separate title/message/type param.",
12
- default: "Content"
13
- },
14
- placement: {
15
- type: "select",
16
- description: "Where the toast appears on screen.",
17
- default: "top-right",
18
- options: [
19
- "top-right",
20
- "top-center",
21
- "top-left",
22
- "bottom-right",
23
- "bottom-center",
24
- "bottom-left"
25
- ]
26
- },
27
- appeareance: {
28
- type: "select",
29
- description: "Visual style of the notification. NOTE: the key is spelled \"appeareance\".",
30
- default: "success",
31
- options: [
32
- "success",
33
- "danger",
34
- "warning",
35
- "info"
36
- ]
37
- },
38
- autoDismiss: {
39
- type: "boolean",
40
- description: "Whether the notification dismisses itself after a timeout.",
41
- default: true
42
- },
43
- autoDismissTimeout: {
44
- type: "number",
45
- description: "Milliseconds before auto-dismiss. Only applies when autoDismiss is true.",
46
- default: 5e3,
47
- when: (params) => params.autoDismiss === true
48
- }
49
- }
50
- },
51
- setState: {
52
- source: "state",
53
- title: "Set State",
54
- strictParams: true,
55
- params: {
56
- key: {
57
- type: "text",
58
- description: "The state key/path to set.",
59
- default: ""
60
- },
61
- type: {
62
- type: "select",
63
- description: "The value type.",
64
- options: [
65
- "boolean",
66
- "number",
67
- "text"
68
- ]
69
- },
70
- value: {
71
- type: "scalar",
72
- description: "The value to store — its type follows the `type` param (a real boolean/number, or text).",
73
- when: (params) => Boolean(params.type)
74
- }
75
- }
76
- },
77
- clearState: {
78
- source: "state",
79
- title: "Clear State",
80
- strictParams: true,
81
- params: {}
82
- },
83
- navigate: {
84
- source: "navigation",
85
- title: "Navigate",
86
- strictParams: true,
87
- params: {
88
- urlType: {
89
- type: "select",
90
- description: "Target kind: a space page, an internal space path, or an external URL.",
91
- options: [
92
- "page",
93
- "internal",
94
- "external"
95
- ]
96
- },
97
- url: {
98
- type: "text",
99
- description: "Destination — a page id when urlType is \"page\", otherwise a URL/path.",
100
- when: (params) => Boolean(params.urlType)
101
- }
102
- }
103
- },
104
- authLogin: {
105
- source: "auth",
106
- title: "Auth Login",
107
- strictParams: true,
108
- params: {}
109
- },
110
- authLogout: {
111
- source: "auth",
112
- title: "Auth Logout",
113
- strictParams: true,
114
- params: {}
115
- },
116
- authRefreshDetails: {
117
- source: "auth",
118
- title: "Auth Refresh Details",
119
- strictParams: true,
120
- params: {}
121
- }
122
- };
123
- /** The built-in globalCallback for an action, or undefined when the action is not a known built-in (a plugin
124
- * callback whose source/schema is not knowable here). */
125
- var getGlobalCallback = (action) => Object.hasOwn(BUILTIN_GLOBAL_CALLBACKS, action) ? BUILTIN_GLOBAL_CALLBACKS[action] : void 0;
126
- /** Resolve a `globalCallback` action against the built-in catalog: returns the module id it is registered under
127
- * (`source`) and the params reconciled to the callback's schema — unknown keys dropped for a closed callback, then
128
- * missing defaults filled. An action the catalog does not know (e.g. a plugin callback) yields no source and
129
- * unchanged params, so the caller keeps its own behavior for it. */
130
- var applyBuiltinCallback = (action, params) => {
131
- if (!(action in BUILTIN_GLOBAL_CALLBACKS)) return { params };
132
- const builtin = BUILTIN_GLOBAL_CALLBACKS[action];
133
- return {
134
- source: builtin.source,
135
- params: reconcileParams(params, builtin.params, builtin.strictParams)
136
- };
137
- };
138
- //#endregion
139
- export { BUILTIN_GLOBAL_CALLBACKS, applyBuiltinCallback, getGlobalCallback };
@@ -1,4 +0,0 @@
1
- import { ComponentCatalogEntry } from '@plitzi/sdk-shared';
2
- type BuiltinComponent = Required<Pick<ComponentCatalogEntry, 'label' | 'description' | 'category'>>;
3
- export declare const BUILTIN_COMPONENTS: Partial<Record<string, BuiltinComponent>>;
4
- export {};
@@ -1,165 +0,0 @@
1
- //#region src/modules/mcp/catalogs/builtinComponents.ts
2
- var BUILTIN_COMPONENTS = {
3
- container: {
4
- label: "Container",
5
- category: "structure",
6
- description: "Generic layout box (a div). The primary building block for structure: groups and positions child elements with flex/grid. Reach for it whenever you need to wrap or arrange other elements."
7
- },
8
- list: {
9
- label: "List",
10
- category: "structure",
11
- description: "Repeats a template (its listItem/link child) once per entry of a data array — the way to render a dynamic collection. Bind its items to a data source (e.g. an apiContainer response)."
12
- },
13
- listItem: {
14
- label: "List Item",
15
- category: "structure",
16
- description: "The repeated template rendered once per row inside a list; its fields bind to each array entry."
17
- },
18
- dialogContainer: {
19
- label: "Dialog Container",
20
- category: "structure",
21
- description: "A native <dialog> container shown or hidden through interactions (e.g. an onClick open/close)."
22
- },
23
- modalContainer: {
24
- label: "Modal Container",
25
- category: "structure",
26
- description: "A modal overlay container opened and closed through interactions; use for dialogs over the page."
27
- },
28
- tabContainer: {
29
- label: "Tab Container",
30
- category: "structure",
31
- description: "A tabbed container that switches between panels; composed of header/body/item parts."
32
- },
33
- tabContainerHeader: {
34
- label: "Tab Container Header",
35
- category: "structure",
36
- description: "The row of tab triggers inside a tabContainer."
37
- },
38
- tabContainerBody: {
39
- label: "Tab Container Body",
40
- category: "structure",
41
- description: "The panel area inside a tabContainer that shows the active tab item."
42
- },
43
- tabContainerItem: {
44
- label: "Tab Container Item",
45
- category: "structure",
46
- description: "One selectable tab (trigger + panel) inside a tabContainer."
47
- },
48
- apiContainer: {
49
- label: "Api Container",
50
- category: "provider",
51
- description: "Fetches data from a backend HTTP API (its `query`/`method`/`credentials`) and exposes the response as a data source ITS DESCENDANTS bind to (source `apiContainer_<idRef>.data`; only elements inside it can consume it). This is how you get backend data into the frontend. Its `mockData` prop is builder-only sample data — the published runtime fetches the real `query`, so always set a real query for production."
52
- },
53
- text: {
54
- label: "Text",
55
- category: "basic",
56
- description: "Inline plain-text content. Use for short runs of copy; bind its content to data for dynamic text."
57
- },
58
- paragraph: {
59
- label: "Paragraph",
60
- category: "basic",
61
- description: "A block of body text (a <p>). Use for longer prose passages."
62
- },
63
- heading: {
64
- label: "Heading",
65
- category: "basic",
66
- description: "A section heading (<h1>–<h6>) for titles and document hierarchy."
67
- },
68
- button: {
69
- label: "Button",
70
- category: "basic",
71
- description: "A clickable button. On its own it only renders; wire an interaction flow (trigger onClick → callbacks) to make it DO something."
72
- },
73
- link: {
74
- label: "Link",
75
- category: "basic",
76
- description: "Navigation. Moves the user between pages of the site or to an external URL (its `mode`/`href` decide which). Use this to go page-to-page rather than a button + interaction."
77
- },
78
- markdown: {
79
- label: "Markdown",
80
- category: "basic",
81
- description: "Renders a Markdown source string as formatted HTML."
82
- },
83
- dropdown: {
84
- label: "Dropdown",
85
- category: "basic",
86
- description: "A trigger that toggles an attached popup panel (dropdownPopup) — menus, selects, flyouts."
87
- },
88
- dropdownPopup: {
89
- label: "Dropdown Popup",
90
- category: "basic",
91
- description: "The floating panel revealed by a dropdown."
92
- },
93
- form: {
94
- label: "Form",
95
- category: "form",
96
- description: "A <form> that groups form controls and handles submission; wire its submit through an interaction flow."
97
- },
98
- formControl: {
99
- label: "Form Control",
100
- category: "form",
101
- description: "A single labelled input (text/select/checkbox/… per its subType) inside a form; captures one field of user input."
102
- },
103
- image: {
104
- label: "Image",
105
- category: "media",
106
- description: "Displays an image from a URL."
107
- },
108
- video: {
109
- label: "Video",
110
- category: "media",
111
- description: "Embeds a video from a URL."
112
- },
113
- fontAwesome: {
114
- label: "Font Awesome",
115
- category: "media",
116
- description: "Renders a Font Awesome icon by its icon name."
117
- },
118
- page: {
119
- label: "Page",
120
- category: "internal",
121
- description: "The root of a routable screen. Managed through the page ops (upsertPage/deletePage), not added as a child element."
122
- },
123
- layoutContainer: {
124
- label: "Layout Container",
125
- category: "internal",
126
- description: "A reusable layout shell (header/footer chrome) shared across pages."
127
- },
128
- notFound: {
129
- label: "Not Found",
130
- category: "internal",
131
- description: "The 404 screen shown when no route matches."
132
- },
133
- loading: {
134
- label: "Loading",
135
- category: "internal",
136
- description: "A loading placeholder shown while data or a suspense boundary resolves."
137
- },
138
- reference: {
139
- label: "Reference",
140
- category: "advanced",
141
- description: "Reuses another element or template by id, rendering it in place."
142
- },
143
- custom: {
144
- label: "Custom",
145
- category: "advanced",
146
- description: "A custom element slot whose behaviour is supplied by a host/plugin component."
147
- },
148
- blockHtml: {
149
- label: "HTML Block",
150
- category: "advanced",
151
- description: "Renders an arbitrary raw HTML string as a block. Escape hatch when no structured element fits."
152
- },
153
- nodeHtml: {
154
- label: "Html Node",
155
- category: "advanced",
156
- description: "A single raw HTML tag with custom attributes."
157
- },
158
- blockJsx: {
159
- label: "Block JSX",
160
- category: "advanced",
161
- description: "A compiled JSX block for advanced authoring."
162
- }
163
- };
164
- //#endregion
165
- export { BUILTIN_COMPONENTS };
@@ -1,17 +0,0 @@
1
- import { ParamSpec } from './paramSpec';
2
- export interface BuiltinElementCallback {
3
- title: string;
4
- strictParams: boolean;
5
- params: ParamSpec;
6
- }
7
- export declare const BUILTIN_ELEMENT_CALLBACKS: Record<string, BuiltinElementCallback>;
8
- /** The built-in element callback for an action, or undefined when the action is not a known built-in (an
9
- * element-type-specific/plugin callback whose schema is not knowable here). */
10
- export declare const getElementCallback: (action: string) => BuiltinElementCallback | undefined;
11
- /** Reconcile a `callback` action against the element-callback catalog: unknown keys dropped for a closed callback,
12
- * then missing defaults filled (category:"attribute", revertOnFinish:false). An unknown action yields unchanged
13
- * params, so a plugin/element-specific callback keeps whatever the agent passed. */
14
- export declare const applyElementCallback: (action: string, params: Record<string, unknown>) => {
15
- known: boolean;
16
- params: Record<string, unknown>;
17
- };
@@ -1,50 +0,0 @@
1
- import { reconcileParams } from "./paramSpec.js";
2
- //#region src/modules/mcp/catalogs/builtinElementCallbacks.ts
3
- var BUILTIN_ELEMENT_CALLBACKS = { setState: {
4
- title: "Update Element (set attribute / state)",
5
- strictParams: true,
6
- params: {
7
- category: {
8
- type: "select",
9
- description: "What to change on the element: \"attribute\" sets one of its props (the common case — e.g. content, disabled); \"state\" sets element state (visibility or a style selector). REQUIRED — always set it.",
10
- default: "attribute",
11
- options: ["attribute", "state"],
12
- required: true
13
- },
14
- key: {
15
- type: "text",
16
- description: "The field to set. When category=\"attribute\", an attribute/prop key of THIS element (e.g. \"content\", \"disabled\"). When category=\"state\", \"visibility\" or \"styleSelectors.<selector>\". REQUIRED.",
17
- required: true
18
- },
19
- value: {
20
- type: "scalar",
21
- description: "The value to set — its type follows the target attribute: a real boolean (true/false) for a boolean attribute, a number for a numeric one, otherwise a string (the strings \"true\"/\"false\" also coerce). There is NO separate `type` param (that belongs to the global state setState, not this one). REQUIRED.",
22
- when: (params) => Boolean(params.category),
23
- required: true
24
- },
25
- revertOnFinish: {
26
- type: "boolean",
27
- description: "When true, this change is UNDONE automatically when the whole flow finishes. Use it for a TEMPORARY change (a \"loading…\" label, disabling a button while it works) instead of adding manual restore steps at the end of the flow.",
28
- default: false
29
- }
30
- }
31
- } };
32
- /** The built-in element callback for an action, or undefined when the action is not a known built-in (an
33
- * element-type-specific/plugin callback whose schema is not knowable here). */
34
- var getElementCallback = (action) => Object.hasOwn(BUILTIN_ELEMENT_CALLBACKS, action) ? BUILTIN_ELEMENT_CALLBACKS[action] : void 0;
35
- /** Reconcile a `callback` action against the element-callback catalog: unknown keys dropped for a closed callback,
36
- * then missing defaults filled (category:"attribute", revertOnFinish:false). An unknown action yields unchanged
37
- * params, so a plugin/element-specific callback keeps whatever the agent passed. */
38
- var applyElementCallback = (action, params) => {
39
- const builtin = getElementCallback(action);
40
- if (!builtin) return {
41
- known: false,
42
- params
43
- };
44
- return {
45
- known: true,
46
- params: reconcileParams(params, builtin.params, builtin.strictParams)
47
- };
48
- };
49
- //#endregion
50
- export { BUILTIN_ELEMENT_CALLBACKS, applyElementCallback, getElementCallback };