@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
@@ -10,7 +10,7 @@ export declare const connectorSummaries: (space: Space) => {
10
10
  operators: string[];
11
11
  pagination: import('@plitzi/sdk-shared').ConnectorPagination | undefined;
12
12
  credential: string | undefined;
13
- fields: Record<string, "number" | "file" | "text" | "color" | "link" | "image" | "video" | "switch" | "email" | "date" | "richText" | "multiImage" | "phone" | "option"> | undefined;
13
+ fields: Record<string, "number" | "file" | "text" | "color" | "switch" | "email" | "date" | "richText" | "image" | "multiImage" | "video" | "link" | "phone" | "option"> | undefined;
14
14
  }[];
15
15
  };
16
16
  /** Connector reads: the space's connector listing and one full manifest. Undefined when the URI belongs to
@@ -1,5 +1,5 @@
1
- import { cssProperties, cssShorthands } from "../catalogs/cssCatalog/index.js";
2
1
  import { buildTypeRegistry } from "../catalogs/registry.js";
2
+ import { cssProperties, cssShorthands } from "../catalogs/index.js";
3
3
  import "../helpers/uris.js";
4
4
  import { guideText } from "../helpers/guide.js";
5
5
  import { envelope } from "./envelope.js";
@@ -1,4 +1,5 @@
1
1
  export { readPublicResource, readResource, resourceVersion } from './router';
2
+ export { actionSummaries } from './actions';
2
3
  export { connectorSummaries } from './connectors';
3
4
  export { registerResources } from './register';
4
5
  export { resourceErrorMessage } from './canonical';
@@ -1,7 +1,14 @@
1
1
  import { Space } from '../helpers';
2
2
  import { Env, ResourceEnvelope } from '../types';
3
3
  /** The cold-start bundle: everything the guide says to read before the first write, in one round-trip.
4
+ *
4
5
  * Summaries only — never full page/element trees (those are opened on demand), so it stays cheap even on a
5
6
  * large space. Carries the condensed `guideQuickstart` (not the full guideText, which the agent reads on demand at
6
- * plitzi://guide) to keep the bundle small. Returns undefined when the URI is not the primer. */
7
+ * plitzi://guide) to keep the bundle small.
8
+ *
9
+ * Past `SPACE_BUDGET` the summaries themselves stop being cheap, and the tail is replaced by pointers. Nothing is
10
+ * lost by that: the primer is an aggregate of reads an agent can make one at a time, and every section here names
11
+ * the resource that answers it in full — eliding one costs a round-trip, never information.
12
+ *
13
+ * Returns undefined when the URI is not the primer. */
7
14
  export declare const readPrimerResource: (space: Space, env: Env, uri: string) => ResourceEnvelope<unknown> | undefined;
@@ -1,32 +1,156 @@
1
- import { cssProperties, cssShorthands } from "../catalogs/cssCatalog/index.js";
2
1
  import { buildDataSourceCatalog, buildInteractionCatalog } from "../catalogs/observed.js";
3
2
  import { buildTypeRegistry } from "../catalogs/registry.js";
3
+ import { cssProperties, cssShorthands } from "../catalogs/index.js";
4
+ import { connectorsUri, dataSourcesUri, defsUri, foldersUri, fontsUri, interactionsUri, layoutsUri, pagesUri, primerUri, schemaVarsUri, settingsUri, styleVarsUri, typesUri } from "../helpers/uris.js";
4
5
  import { guideQuickstart } from "../helpers/guide.js";
5
6
  import { envelope } from "./envelope.js";
6
7
  import { connectorSummaries } from "./connectors.js";
7
- import { definitionRefs, styleVariablesToAI } from "../tools/operations/style/translator.js";
8
- import { foldersToAI, pageSummariesToAI, schemaVariablesToAI, settingsToAI } from "../tools/operations/schema/translator.js";
8
+ import { definitionRefs, fontsToAI, styleVariablesToAI } from "../tools/operations/style/translator.js";
9
+ import { foldersToAI, layoutSummariesToAI, pageSummariesToAI, schemaVariablesToAI, settingsToAI } from "../tools/operations/schema/translator.js";
9
10
  //#region src/modules/mcp/resources/primer.ts
11
+ /**
12
+ * How much of the cold-start bundle the SPACE may fill, in characters of JSON.
13
+ *
14
+ * Only the space-derived sections are measured against it: the guide and the CSS vocabulary are constants that no
15
+ * schema can grow, so budgeting them would only make a large space evict a fixed cost it did not cause.
16
+ *
17
+ * The number exists because every section here scales with something — pages with pages, definitions with style
18
+ * classes, interactions with flows — and their sum does not converge. A space big enough made the one read that is
19
+ * supposed to START the work the one an agent could not finish: too long to hold, and too long to grep out of the
20
+ * tool-output file it was spilled to.
21
+ */
22
+ var SPACE_BUDGET = 24e3;
23
+ var entryCount = (value) => {
24
+ if (Array.isArray(value)) return value.length;
25
+ if (value !== null && typeof value === "object") return Object.keys(value).length;
26
+ };
27
+ /**
28
+ * Keeps every section the budget can still afford and replaces the rest with a pointer to its own resource.
29
+ *
30
+ * Two properties worth being deliberate about. It SKIPS rather than stops: one oversized section costs the bundle
31
+ * that section, not everything declared after it, so a space with a thousand style classes still gets its handful of
32
+ * schema variables inline. And the order below is a priority, not an accident — what an agent cannot begin without
33
+ * comes first, so what a large space loses is always the tail.
34
+ */
35
+ var fit = (sections, budget) => {
36
+ const bundle = {};
37
+ const elided = [];
38
+ let spent = 0;
39
+ for (const { key, value, measured, read } of sections) {
40
+ const bytes = JSON.stringify(value).length;
41
+ const budgeted = measured === void 0 ? bytes : JSON.stringify(measured).length;
42
+ if (spent + budgeted <= budget) {
43
+ bundle[key] = value;
44
+ spent += budgeted;
45
+ continue;
46
+ }
47
+ bundle[key] = {
48
+ elided: true,
49
+ bytes,
50
+ entries: entryCount(value),
51
+ read
52
+ };
53
+ elided.push(key);
54
+ }
55
+ return {
56
+ bundle,
57
+ elided
58
+ };
59
+ };
10
60
  /** The cold-start bundle: everything the guide says to read before the first write, in one round-trip.
61
+ *
11
62
  * Summaries only — never full page/element trees (those are opened on demand), so it stays cheap even on a
12
63
  * large space. Carries the condensed `guideQuickstart` (not the full guideText, which the agent reads on demand at
13
- * plitzi://guide) to keep the bundle small. Returns undefined when the URI is not the primer. */
64
+ * plitzi://guide) to keep the bundle small.
65
+ *
66
+ * Past `SPACE_BUDGET` the summaries themselves stop being cheap, and the tail is replaced by pointers. Nothing is
67
+ * lost by that: the primer is an aggregate of reads an agent can make one at a time, and every section here names
68
+ * the resource that answers it in full — eliding one costs a round-trip, never information.
69
+ *
70
+ * Returns undefined when the URI is not the primer. */
14
71
  var readPrimerResource = (space, env, uri) => {
15
- if (uri !== `plitzi://primer/${env}`) return;
72
+ if (uri !== primerUri(env)) return;
73
+ const interactionCatalog = buildInteractionCatalog(space.schema);
74
+ const dataSourceCatalog = buildDataSourceCatalog(space.schema);
75
+ const { bundle, elided } = fit([
76
+ {
77
+ key: "pages",
78
+ value: pageSummariesToAI(space.schema),
79
+ read: pagesUri(env)
80
+ },
81
+ {
82
+ key: "layouts",
83
+ value: layoutSummariesToAI(space.schema),
84
+ read: layoutsUri(env)
85
+ },
86
+ {
87
+ key: "folders",
88
+ value: foldersToAI(space.schema),
89
+ read: foldersUri(env)
90
+ },
91
+ {
92
+ key: "types",
93
+ value: buildTypeRegistry(space.schema, space.catalog),
94
+ read: typesUri
95
+ },
96
+ {
97
+ key: "schemaVariables",
98
+ value: schemaVariablesToAI(space.schema, false),
99
+ read: schemaVarsUri(env)
100
+ },
101
+ {
102
+ key: "styleVariables",
103
+ value: styleVariablesToAI(space.style),
104
+ read: styleVarsUri(env)
105
+ },
106
+ {
107
+ key: "fonts",
108
+ value: fontsToAI(space.style),
109
+ read: fontsUri(env)
110
+ },
111
+ {
112
+ key: "settings",
113
+ value: settingsToAI(space.schema),
114
+ read: settingsUri(env)
115
+ },
116
+ {
117
+ key: "definitions",
118
+ value: definitionRefs(space.style),
119
+ read: defsUri(env)
120
+ },
121
+ {
122
+ key: "interactions",
123
+ value: interactionCatalog,
124
+ measured: {
125
+ actions: interactionCatalog.actions,
126
+ flowCount: interactionCatalog.flowCount
127
+ },
128
+ read: interactionsUri(env)
129
+ },
130
+ {
131
+ key: "dataSources",
132
+ value: dataSourceCatalog,
133
+ measured: {
134
+ sources: dataSourceCatalog.sources,
135
+ targets: dataSourceCatalog.targets
136
+ },
137
+ read: dataSourcesUri(env)
138
+ },
139
+ {
140
+ key: "connectors",
141
+ value: connectorSummaries(space).connectors,
142
+ read: connectorsUri(env)
143
+ }
144
+ ], SPACE_BUDGET);
16
145
  return envelope({
17
146
  guide: guideQuickstart,
18
- types: buildTypeRegistry(space.schema, space.catalog),
19
147
  cssProperties,
20
148
  cssShorthands,
21
- pages: pageSummariesToAI(space.schema),
22
- folders: foldersToAI(space.schema),
23
- definitions: definitionRefs(space.style),
24
- styleVariables: styleVariablesToAI(space.style),
25
- schemaVariables: schemaVariablesToAI(space.schema, false),
26
- settings: settingsToAI(space.schema),
27
- interactions: buildInteractionCatalog(space.schema),
28
- dataSources: buildDataSourceCatalog(space.schema),
29
- ...connectorSummaries(space)
149
+ ...bundle,
150
+ ...elided.length > 0 ? { elided: {
151
+ sections: elided,
152
+ note: "This space is too large to summarise in one read. Each section above carries the resource URI that serves it whole; read only the ones the task needs."
153
+ } } : {}
30
154
  });
31
155
  };
32
156
  //#endregion
@@ -1,7 +1,7 @@
1
- import { cssProperties, cssShorthands } from "../catalogs/cssCatalog/index.js";
1
+ import { cssProperties, cssShorthands } from "../catalogs/index.js";
2
2
  import { guideText } from "../helpers/guide.js";
3
- import { resourceErrorMessage } from "./canonical.js";
4
3
  import { envelope, jsonContents } from "./envelope.js";
4
+ import { resourceErrorMessage } from "./canonical.js";
5
5
  import { registerRenderResources } from "./renderGuide.js";
6
6
  import { readResource } from "./router.js";
7
7
  import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -64,6 +64,11 @@ var registerResources = (server, getSpace, env, log, hasSpace) => {
64
64
  `plitzi://schema/${env}/pages`,
65
65
  "Page summaries (ref, label, elementCount) — no element trees"
66
66
  ],
67
+ [
68
+ "Layouts",
69
+ `plitzi://schema/${env}/layouts`,
70
+ "Shared layout shells (header/sidebar/footer) and the pages rendered inside each — read one as a page"
71
+ ],
67
72
  [
68
73
  "Folders",
69
74
  `plitzi://folders/${env}`,
@@ -119,6 +124,16 @@ var registerResources = (server, getSpace, env, log, hasSpace) => {
119
124
  `plitzi://connectors/${env}`,
120
125
  "Server-side CMS/API connectors configured for this space: each with the read/write endpoints it can address, the filter operators it accepts and the fields it publishes — what a server-rendered apiContainer points at"
121
126
  ],
127
+ [
128
+ "Server tasks",
129
+ `plitzi://actions/${env}/tasks`,
130
+ "The steps a server action can be built from on THIS deployment: each with its parameters — read before authoring a flow, since a task this server does not have cannot run"
131
+ ],
132
+ [
133
+ "Server actions",
134
+ `plitzi://actions/${env}`,
135
+ "Server actions this space runs: what starts each one, who may run it, and the input/output contract a caller is held to — what a runServerAction step points at"
136
+ ],
122
137
  [
123
138
  "Style definitions (schema alias)",
124
139
  `plitzi://schema/${env}/definitions`,
@@ -143,7 +158,7 @@ var registerResources = (server, getSpace, env, log, hasSpace) => {
143
158
  [
144
159
  "Page",
145
160
  `plitzi://schema/${env}/pages/{ref}`,
146
- "One page as a skeleton tree (ref/type/label/children), no props"
161
+ "One page (or LAYOUT shell) as a skeleton tree (ref/type/label/children), no props"
147
162
  ],
148
163
  [
149
164
  "Page styles",
@@ -153,7 +168,7 @@ var registerResources = (server, getSpace, env, log, hasSpace) => {
153
168
  [
154
169
  "Element",
155
170
  `plitzi://schema/${env}/elements/{ref}`,
156
- "One element in full detail (props, style) by ref or id"
171
+ "One element in full detail (props, style), by name"
157
172
  ],
158
173
  [
159
174
  "Folder",
@@ -165,6 +180,11 @@ var registerResources = (server, getSpace, env, log, hasSpace) => {
165
180
  `plitzi://connectors/${env}/{ref}`,
166
181
  "One connector manifest in full: baseUrl, auth template, every read/write endpoint and its response mapping"
167
182
  ],
183
+ [
184
+ "Server action",
185
+ `plitzi://actions/${env}/{ref}`,
186
+ "One action document in full: its access rule, triggers, declared credentials and connectors, and every step"
187
+ ],
168
188
  [
169
189
  "Style definition",
170
190
  `plitzi://definitions/${env}/{ref}`,
@@ -1,4 +1,4 @@
1
- import { BUILTIN_COMPONENTS } from "../catalogs/builtinComponents.js";
1
+ import { elementCatalog } from "../catalogs/index.js";
2
2
  import { envelope, jsonContents } from "./envelope.js";
3
3
  //#region src/modules/mcp/resources/renderGuide.ts
4
4
  var RENDER_GUIDE_URI = "plitzi://render/guide";
@@ -15,17 +15,19 @@ var rawHtmlDescription = "Renders a raw HTML string (props.content) — in a wid
15
15
  var renderTypesNote = "The built-in element types you can put in a plitzi_render widget, grouped by category. Pick by `description`. For the props of each type and the full authoring model, read plitzi://render/guide. Types that need a backend (providers) or a plugin are omitted because the widget renders offline.";
16
16
  var renderTypes = () => {
17
17
  const types = {};
18
- for (const [name, info] of Object.entries(BUILTIN_COMPONENTS)) if (info && info.category && RENDER_TYPE_CATEGORIES.has(info.category)) types[name] = {
18
+ for (const [name, info] of Object.entries(elementCatalog)) if (RENDER_TYPE_CATEGORIES.has(info.category)) types[name] = {
19
19
  label: info.label,
20
20
  category: info.category,
21
21
  description: info.description
22
22
  };
23
- const rawHtml = BUILTIN_COMPONENTS[RENDER_RAW_HTML_TYPE];
24
- if (rawHtml) types[RENDER_RAW_HTML_TYPE] = {
25
- label: rawHtml.label,
26
- category: rawHtml.category,
27
- description: rawHtmlDescription
28
- };
23
+ if (Object.hasOwn(elementCatalog, RENDER_RAW_HTML_TYPE)) {
24
+ const rawHtml = elementCatalog[RENDER_RAW_HTML_TYPE];
25
+ types[RENDER_RAW_HTML_TYPE] = {
26
+ label: rawHtml.label,
27
+ category: rawHtml.category,
28
+ description: rawHtmlDescription
29
+ };
30
+ }
29
31
  return {
30
32
  note: renderTypesNote,
31
33
  types
@@ -378,7 +380,7 @@ The widget runs the live SDK, so beyond static layout it can fetch data and resp
378
380
  \`ref\`, just like styling. (Full reference: **plitzi://guide** — sections Data bindings and Interactions.)
379
381
 
380
382
  ### Fetch data — a provider + a binding
381
- An \`apiContainer\` fetches at runtime and exposes the result as the source **\`apiContainer_<idRef>.data\`**, visible
383
+ An \`apiContainer\` fetches at runtime and exposes the result as the source **\`apiContainer_<id>.data\`**, visible
382
384
  to its **DESCENDANTS only** — the bound element must live inside the container's subtree. \`upsertBinding\` then
383
385
  connects that source to a descendant's field.
384
386
 
@@ -394,16 +396,17 @@ connects that source to a descendant's field.
394
396
  }
395
397
  \`\`\`
396
398
  - \`category\`: \`"attributes"\` (a prop such as \`content\`/\`src\`), \`"style"\` (a CSS value) or \`"initialState"\`.
397
- - \`binding.to\` is the target field; \`binding.source\` is the \`<type>_<idRef>.path\` into the provider's data.
399
+ - \`binding.to\` is the target field; \`binding.source\` is the \`<type>_<id>.path\` into the provider's data.
398
400
  - \`mockData\` on the provider is builder-only — set a real \`query\` for the widget to actually fetch.
399
401
 
400
402
  ### React to events — an interaction flow
401
403
  \`upsertInteractionFlow\` attaches an ordered \`nodes\` list to an element; the FIRST node is a \`trigger\` (e.g.
402
404
  \`onClick\`), the rest run after it. Each following step is one of:
403
- - **\`globalCallback\`** (OMIT \`elementId\`) — a built-in app action: \`addNotification\` (\`params.content\`),
404
- \`navigate\`, \`setState\` (\`key\`/\`type\`/\`value\`), \`authLogin\`/\`authLogout\`…
405
- - **\`callback\`** (\`elementId\` = an element, defaults to the trigger's) — that ELEMENT's OWN callback: e.g. an
406
- \`apiContainer\` re-fetches, a \`form\` submits. Each type's own callback action names are in plitzi://guide.
405
+ - **\`callback\`** — a callback the ELEMENT provides. \`elementId\` is the element it acts on: **the flow's own
406
+ element by default, or another element's ref to act on that one**. Every element has \`setState\` and
407
+ \`toggleState\` (below); a type may add its own (an \`apiContainer\` re-fetches, a \`form\` submits).
408
+ - **\`globalCallback\`** (OMIT \`elementId\`) — an app-level action, provided by a module and not by any element:
409
+ \`addNotification\` (\`params.content\`), \`navigate\`, \`setState\` (\`key\`/\`type\`/\`value\`), \`login\`/\`logout\`.
407
410
 
408
411
  \`\`\`json
409
412
  { "type": "upsertInteractionFlow", "pageRef": "render", "ref": "buy", "nodes": [
@@ -412,6 +415,55 @@ connects that source to a descendant's field.
412
415
  ] }
413
416
  \`\`\`
414
417
 
418
+ ### Show, hide and toggle — \`setState\` / \`toggleState\`
419
+ Every element registers two \`callback\` actions that change **the element \`elementId\` names**:
420
+ - **\`setState\`** — \`category\` (\`"state"\` or \`"attribute"\`), \`key\`, \`value\`. With \`category:"state"\` the key
421
+ is **\`"visibility"\`** (a boolean: show/hide) or \`"styleSelectors.<selector>"\`. With \`category:"attribute"\` the
422
+ key is one of the element's own props (\`content\`, \`disabled\`, \`src\`…).
423
+ - **\`toggleState\`** — the same write with **no \`value\`**: it stores the OPPOSITE of what is there. This is how
424
+ you show/hide on click. There is no separate "toggleVisibility" action — it is
425
+ \`toggleState\` + \`category:"state"\` + \`key:"visibility"\`.
426
+
427
+ An element starts hidden with \`initialState: { "visibility": false }\` on the element itself. Anything not already
428
+ \`true\` counts as false, so a panel that has never been set flips **open** on the first click.
429
+
430
+ Expand/collapse is therefore **ONE step on ONE trigger** — never two \`setState\` branches under opposite \`when\`
431
+ conditions, which read the state as it was when the flow STARTED and so are always one click behind:
432
+
433
+ \`\`\`json
434
+ { "operations": [
435
+ { "type": "upsertElement", "pageRef": "render", "element": { "ref": "card", "type": "container", "children": [
436
+ { "ref": "card-head", "type": "button", "props": { "content": "Details" } },
437
+ { "ref": "card-body", "type": "container", "initialState": { "visibility": false }, "children": [
438
+ { "ref": "card-text", "type": "paragraph", "props": { "content": "The hidden detail." } } ] } ] } },
439
+ { "type": "upsertInteractionFlow", "pageRef": "render", "ref": "card-head", "nodes": [
440
+ { "title": "On click", "nodeType": "trigger", "action": "onClick" },
441
+ { "title": "Toggle body", "nodeType": "callback", "action": "toggleState", "elementId": "card-body",
442
+ "params": { "category": "state", "key": "visibility" } } ] }
443
+ ] }
444
+ \`\`\`
445
+
446
+ Two \`setState\`s share a name and are **not interchangeable**: the \`callback\` one (above) changes that element's
447
+ own state/attribute; the \`globalCallback\` one (source \`state\`, params \`key\`/\`type\`/\`value\`) writes app state a
448
+ binding can read. Use the element one unless something outside the element must react.
449
+
450
+ ### Several flows on one element
451
+ Call \`upsertInteractionFlow\` again with the same \`ref\` and **omit \`flowId\`** — each call with no \`flowId\`
452
+ creates a NEW flow, so one button can carry an \`onClick\` and an \`onMouseEnter\`, or two independent \`onClick\`
453
+ flows. Passing an existing \`flowId\` REPLACES that flow instead. To change one step, use \`patchInteractionNode\`.
454
+
455
+ ### What comes back, and what does not
456
+ A successful render lists the wiring it stored, one line per flow —
457
+ \`"card-head onClick → toggleState card-body[visibility]"\`. Read it: it is what confirms the flow landed on the
458
+ element you meant, with the step targeting the element you meant. A step naming an \`elementId\` that is not in the
459
+ widget is an **error**, not a silent no-op.
460
+
461
+ What it does NOT tell you is whether a click was later performed and the callback ran — that is runtime, and this
462
+ tool authors the widget rather than driving it. So report what you wired, not that it was exercised.
463
+
464
+ Events **bubble**: a clickable element inside another clickable element runs BOTH flows. Put the trigger on one of
465
+ them; if both are needed, the render warns you and names the pair.
466
+
415
467
  ## When it fails
416
468
  The tool returns \`rendered: false\` with \`errors: [{ path, message, hint }]\`. Read the hint, fix that one op, and
417
469
  retry — you never lose the rest of the batch.
@@ -1,5 +1,6 @@
1
1
  import { emptySpace } from "../helpers/space.js";
2
2
  import "../helpers/uris.js";
3
+ import { readActionResource } from "./actions.js";
3
4
  import { canonicalUri } from "./canonical.js";
4
5
  import { readConnectorResource } from "./connectors.js";
5
6
  import { readCoreResource } from "./core.js";
@@ -14,7 +15,8 @@ var resolvers = [
14
15
  readPrimerResource,
15
16
  readSchemaResource,
16
17
  readStyleResource,
17
- readConnectorResource
18
+ readConnectorResource,
19
+ readActionResource
18
20
  ];
19
21
  /** Resolve a resource URI to its versioned envelope, or null if unknown / not found. */
20
22
  var readResource = (space, env, rawUri) => {
@@ -1,13 +1,14 @@
1
1
  import { buildDataSourceCatalog, buildInteractionCatalog } from "../catalogs/observed.js";
2
- import { findElementByRef, findPageByRef } from "../helpers/space.js";
3
- import { afterPrefix, dataSourcesUri, elementUri, folderUri, foldersUri, interactionsUri, pageUri, pagesUri, schemaVarsUri, settingsUri } from "../helpers/uris.js";
2
+ import { findElementByRef, findRootByRef } from "../helpers/space.js";
3
+ import { afterPrefix, dataSourcesUri, elementUri, folderUri, foldersUri, interactionsUri, layoutsUri, pageUri, pagesUri, schemaVarsUri, settingsUri } from "../helpers/uris.js";
4
4
  import { envelope } from "./envelope.js";
5
- import { elementView, folderRefToAI, foldersToAI, pageSkeletonToAI, pageStylesToAI, pageSummariesToAI, schemaVariablesToAI, settingsToAI } from "../tools/operations/schema/translator.js";
5
+ import { elementView, folderRefToAI, foldersToAI, layoutSummariesToAI, pageSkeletonToAI, pageStylesToAI, pageSummariesToAI, schemaVariablesToAI, settingsToAI } from "../tools/operations/schema/translator.js";
6
6
  //#region src/modules/mcp/resources/schema.ts
7
7
  /** Element-schema reads: page listings/skeletons/styles, folders, single elements and schema variables. Returns
8
8
  * undefined when the URI belongs to another domain, null when the shape is ours but the ref does not resolve. */
9
9
  var readSchemaResource = (space, env, uri) => {
10
10
  if (uri === pagesUri(env)) return envelope(pageSummariesToAI(space.schema));
11
+ if (uri === layoutsUri(env)) return envelope(layoutSummariesToAI(space.schema));
11
12
  if (uri === foldersUri(env)) return envelope(foldersToAI(space.schema));
12
13
  const folderRef = afterPrefix(uri, folderUri(env, ""));
13
14
  if (folderRef !== void 0) {
@@ -18,10 +19,10 @@ var readSchemaResource = (space, env, uri) => {
18
19
  if (pageItem !== void 0) {
19
20
  if (pageItem.endsWith("/styles")) {
20
21
  const ref = pageItem.slice(0, -7);
21
- const page = findPageByRef(space.schema, ref);
22
+ const page = findRootByRef(space.schema, ref);
22
23
  return page ? envelope(pageStylesToAI(space.schema, space.style, page)) : null;
23
24
  }
24
- const page = findPageByRef(space.schema, pageItem);
25
+ const page = findRootByRef(space.schema, pageItem);
25
26
  return page ? envelope(pageSkeletonToAI(space.schema, page, space.style)) : null;
26
27
  }
27
28
  const elementRef = afterPrefix(uri, elementUri(env, ""));
@@ -1,5 +1,6 @@
1
1
  import { Space } from '../helpers';
2
2
  import { Env, ResourceEnvelope } from '../types';
3
- /** Style-schema reads: definitions, global (per-type) styles and design-token variables by category. Returns
3
+ /** Style-schema reads: definitions, global (per-type) styles, design-token variables by category, and the fonts
4
+ * the space declares. Returns
4
5
  * undefined when the URI belongs to another domain, null when the shape is ours but the ref does not resolve. */
5
6
  export declare const readStyleResource: (space: Space, env: Env, uri: string) => ResourceEnvelope<unknown> | null | undefined;
@@ -1,8 +1,9 @@
1
- import { afterPrefix, defUri, defsUri, globalUri, globalsUri, idUri, idsUri, styleVarUri, styleVarsUri } from "../helpers/uris.js";
1
+ import { afterPrefix, defUri, defsUri, fontUri, fontsUri, globalUri, globalsUri, idUri, idsUri, styleVarUri, styleVarsUri } from "../helpers/uris.js";
2
2
  import { envelope } from "./envelope.js";
3
- import { definitionRefs, definitionToAI, globalStyleToAI, globalStyleTypes, idStyleIds, idStyleToAI, styleVariablesToAI } from "../tools/operations/style/translator.js";
3
+ import { definitionRefs, definitionToAI, fontsToAI, globalStyleToAI, globalStyleTypes, idStyleIds, idStyleToAI, styleVariablesToAI } from "../tools/operations/style/translator.js";
4
4
  //#region src/modules/mcp/resources/style.ts
5
- /** Style-schema reads: definitions, global (per-type) styles and design-token variables by category. Returns
5
+ /** Style-schema reads: definitions, global (per-type) styles, design-token variables by category, and the fonts
6
+ * the space declares. Returns
6
7
  * undefined when the URI belongs to another domain, null when the shape is ours but the ref does not resolve. */
7
8
  var readStyleResource = (space, env, uri) => {
8
9
  if (uri === defsUri(env)) return envelope(definitionRefs(space.style));
@@ -23,6 +24,12 @@ var readStyleResource = (space, env, uri) => {
23
24
  const idStyle = idStyleToAI(space.style, targetId);
24
25
  return idStyle ? envelope(idStyle) : null;
25
26
  }
27
+ if (uri === fontsUri(env)) return envelope(fontsToAI(space.style));
28
+ const family = afterPrefix(uri, fontUri(env, ""));
29
+ if (family !== void 0) {
30
+ const font = (space.style.fonts ?? []).find((item) => item.family === decodeURIComponent(family));
31
+ return font ? envelope(font) : null;
32
+ }
26
33
  if (uri === styleVarsUri(env)) return envelope(styleVariablesToAI(space.style));
27
34
  const category = afterPrefix(uri, styleVarUri(env, ""));
28
35
  if (category !== void 0) {
@@ -8,7 +8,7 @@ var composeUrl = (base, pagePath, token) => {
8
8
  /** Default `ScreenshotClient`: composes the navigable preview URL (renderBaseUrl + pagePath + `?__pt=token`) and
9
9
  * POSTs it to the browser service. Any network/HTTP failure surfaces as `ok:false` so the tool can fall back to
10
10
  * the HTML preview instead of hard-failing. */
11
- var createHttpScreenshotClient = ({ serviceUrl, renderBaseUrl, fetchImpl = fetch }) => ({ async capture({ pagePath, token, viewports }) {
11
+ var createHttpScreenshotClient = ({ serviceUrl, renderBaseUrl, fetchImpl = fetch }) => ({ async capture({ pagePath, token, viewports, fullPage }) {
12
12
  const url = composeUrl(renderBaseUrl, pagePath, token);
13
13
  let res;
14
14
  try {
@@ -17,7 +17,8 @@ var createHttpScreenshotClient = ({ serviceUrl, renderBaseUrl, fetchImpl = fetch
17
17
  headers: { "content-type": "application/json" },
18
18
  body: JSON.stringify({
19
19
  url,
20
- viewports
20
+ viewports,
21
+ fullPage
21
22
  })
22
23
  });
23
24
  } catch (err) {
@@ -30,32 +30,38 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
30
30
  };
31
31
  const loadSpace = async () => {
32
32
  const id = requireSpaceId();
33
- const [schema, style, catalog, connectors] = await Promise.all([
33
+ const [schema, style, catalog, connectors, actions, actionTasks] = await Promise.all([
34
34
  adapters.getSchema?.(id, MCP_ENV),
35
35
  adapters.getStyle?.(id, MCP_ENV),
36
36
  adapters.getComponentCatalog?.(id, MCP_ENV).catch(() => void 0),
37
- adapters.getConnectors?.(id).catch(() => void 0)
37
+ adapters.getConnectors?.(id).catch(() => void 0),
38
+ adapters.getActions?.(id).catch(() => void 0),
39
+ adapters.getActionTasks?.(id).catch(() => void 0)
38
40
  ]);
39
41
  if (!schema || !style) throw new Error(emptySpaceMessage);
40
42
  return {
41
43
  schema,
42
44
  style,
43
45
  catalog,
44
- connectors: connectors ?? []
46
+ connectors: connectors ?? [],
47
+ actions: actions ?? [],
48
+ actionTasks
45
49
  };
46
50
  };
47
- const { saveSchema, saveStyle, saveConnector, deleteConnector } = adapters;
51
+ const { saveSchema, saveStyle, saveConnector, deleteConnector, saveAction, deleteAction } = adapters;
48
52
  const persisters = {
49
53
  schema: saveSchema ? (schema) => saveSchema(requireWritableSpaceId(), MCP_ENV, schema) : void 0,
50
54
  style: saveStyle ? (style) => saveStyle(requireWritableSpaceId(), MCP_ENV, style) : void 0,
51
55
  saveConnector: saveConnector ? (entry) => saveConnector(requireWritableSpaceId(), entry) : void 0,
52
- deleteConnector: deleteConnector ? (id) => deleteConnector(requireWritableSpaceId(), id) : void 0
56
+ deleteConnector: deleteConnector ? (id) => deleteConnector(requireWritableSpaceId(), id) : void 0,
57
+ saveAction: saveAction ? (entry) => saveAction(requireWritableSpaceId(), entry) : void 0,
58
+ deleteAction: deleteAction ? (id) => deleteAction(requireWritableSpaceId(), id) : void 0
53
59
  };
54
60
  let spacePromise;
55
61
  const getSpace = () => spacePromise ??= loadSpace();
56
62
  const server = new McpServer({
57
63
  name: "plitzi-mcp",
58
- version: "0.33.2"
64
+ version: "0.34.1"
59
65
  }, { instructions: hasSpace ? serverInstructions : widgetsOnlyInstructions });
60
66
  registerResources(server, getSpace, MCP_ENV, log, hasSpace);
61
67
  registerApps(server, {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};