@plitzi/sdk-server 0.32.4 → 0.32.5

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 (415) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/adapters/jsonAdapters.js +6 -1
  3. package/dist/core/createServer.js +8 -44
  4. package/dist/core/health.js +15 -0
  5. package/dist/core/http/dispatcher.js +29 -0
  6. package/dist/core/http/securityHeaders.js +15 -0
  7. package/dist/core/http/stages/authRoutes.js +41 -0
  8. package/dist/core/http/stages/health.js +12 -0
  9. package/dist/core/http/stages/middlewares.js +16 -0
  10. package/dist/core/http/stages/pluginAssets.js +20 -0
  11. package/dist/core/http/stages/static.js +30 -0
  12. package/dist/core/server/baseServer.js +29 -0
  13. package/dist/core/server/mcpServer.js +29 -0
  14. package/dist/core/server/ssrServer.js +54 -0
  15. package/dist/core/services/mcp.js +22 -0
  16. package/dist/core/services/preview.js +37 -0
  17. package/dist/core/services/registry.js +30 -0
  18. package/dist/core/services/resolve.js +12 -0
  19. package/dist/core/services/rsc.js +11 -0
  20. package/dist/core/services/ssr.js +13 -0
  21. package/dist/core/transports.js +9 -9
  22. package/dist/index.js +19 -6
  23. package/dist/modules/ai/AIEngine.js +4 -4
  24. package/dist/modules/ai/toolkit.js +58 -0
  25. package/dist/modules/mcp/constants.js +4 -0
  26. package/dist/modules/mcp/handler.js +15 -21
  27. package/dist/modules/mcp/helpers/computeVersion.js +16 -0
  28. package/dist/modules/mcp/helpers/guide.js +130 -0
  29. package/dist/modules/mcp/helpers/opResult.js +18 -0
  30. package/dist/modules/mcp/helpers/space.js +137 -0
  31. package/dist/modules/mcp/previewClient.js +31 -0
  32. package/dist/modules/mcp/resources/canonical.js +45 -0
  33. package/dist/modules/mcp/resources/core.js +14 -0
  34. package/dist/modules/mcp/resources/envelope.js +14 -0
  35. package/dist/modules/mcp/resources/primer.js +25 -0
  36. package/dist/modules/mcp/resources/register.js +142 -0
  37. package/dist/modules/mcp/resources/router.js +25 -0
  38. package/dist/modules/mcp/resources/schema.js +33 -0
  39. package/dist/modules/mcp/resources/style.js +27 -0
  40. package/dist/modules/mcp/screenshotClient.js +47 -0
  41. package/dist/modules/mcp/server.js +52 -20
  42. package/dist/modules/mcp/tools/apply/dispatch.js +83 -0
  43. package/dist/modules/mcp/tools/apply/index.js +121 -0
  44. package/dist/modules/mcp/tools/apply/writeResult.js +36 -0
  45. package/dist/modules/mcp/tools/index.js +20 -148
  46. package/dist/modules/mcp/tools/operations/index.js +30 -0
  47. package/dist/modules/mcp/tools/operations/schema/deleteElement.js +25 -0
  48. package/dist/modules/mcp/tools/operations/schema/deleteFolder.js +30 -0
  49. package/dist/modules/mcp/tools/operations/schema/deletePage.js +22 -0
  50. package/dist/modules/mcp/tools/operations/schema/deleteVariable.js +18 -0
  51. package/dist/modules/mcp/tools/operations/schema/moveElement.js +39 -0
  52. package/dist/modules/mcp/tools/operations/schema/operations.js +25 -0
  53. package/dist/modules/mcp/tools/operations/schema/patchElement.js +46 -0
  54. package/dist/modules/mcp/tools/operations/schema/registry.js +55 -0
  55. package/dist/modules/mcp/tools/operations/schema/shared.js +27 -0
  56. package/dist/modules/mcp/tools/operations/schema/translator.js +148 -0
  57. package/dist/modules/mcp/tools/operations/schema/upsertElement.js +59 -0
  58. package/dist/modules/mcp/tools/operations/schema/upsertFolder.js +49 -0
  59. package/dist/modules/mcp/tools/operations/schema/upsertPage.js +64 -0
  60. package/dist/modules/mcp/tools/operations/schema/upsertVariable.js +42 -0
  61. package/dist/modules/mcp/tools/operations/schema/write.js +44 -0
  62. package/dist/modules/mcp/tools/operations/style/cssCatalog.js +132 -0
  63. package/dist/modules/mcp/tools/operations/style/deleteDefinition.js +20 -0
  64. package/dist/modules/mcp/tools/operations/style/deleteGlobalStyle.js +20 -0
  65. package/dist/modules/mcp/tools/operations/style/deleteStyleVariable.js +21 -0
  66. package/dist/modules/mcp/tools/operations/style/operations.js +21 -0
  67. package/dist/modules/mcp/tools/operations/style/patchDefinition.js +27 -0
  68. package/dist/modules/mcp/tools/operations/style/patchGlobalStyle.js +27 -0
  69. package/dist/modules/mcp/tools/operations/style/shared.js +59 -0
  70. package/dist/modules/mcp/tools/operations/style/translator.js +77 -0
  71. package/dist/modules/mcp/tools/operations/style/upsertDefinition.js +23 -0
  72. package/dist/modules/mcp/tools/operations/style/upsertGlobalStyle.js +23 -0
  73. package/dist/modules/mcp/tools/operations/style/upsertStyleVariable.js +22 -0
  74. package/dist/modules/mcp/tools/operations/style/write.js +100 -0
  75. package/dist/modules/mcp/tools/preview.js +37 -0
  76. package/dist/modules/mcp/tools/read.js +33 -0
  77. package/dist/modules/mcp/tools/screenshot.js +83 -0
  78. package/dist/modules/mcp/tools/search.js +108 -0
  79. package/dist/modules/mcp/tools/shared/tool.js +26 -0
  80. package/dist/modules/mcp/tools/shared/validator.js +262 -0
  81. package/dist/modules/mcp/tools/validate.js +19 -0
  82. package/dist/modules/ssr/buildBody.js +2 -2
  83. package/dist/modules/ssr/handler.js +6 -4
  84. package/dist/modules/ssr/prepareRender.js +5 -5
  85. package/dist/modules/ssr/preview.js +106 -0
  86. package/dist/modules/ssr/registerExternalPlugins.js +1 -1
  87. package/dist/modules/ssr/streamBody.js +3 -3
  88. package/dist/modules/ssr/template.js +1 -1
  89. package/dist/plugins/compile.js +1 -1
  90. package/dist/plugins/copy.js +1 -1
  91. package/dist/plugins/manager.js +1 -1
  92. package/dist/server.js +34 -9
  93. package/dist/src/core/createServer.d.ts +5 -1
  94. package/dist/src/core/health.d.ts +10 -0
  95. package/dist/src/core/http/dispatcher.d.ts +7 -0
  96. package/dist/src/core/http/securityHeaders.d.ts +2 -0
  97. package/dist/src/core/http/stages/authRoutes.d.ts +4 -0
  98. package/dist/src/core/http/stages/health.d.ts +2 -0
  99. package/dist/src/core/http/stages/middlewares.d.ts +2 -0
  100. package/dist/src/core/http/stages/pluginAssets.d.ts +2 -0
  101. package/dist/src/core/http/stages/static.d.ts +5 -0
  102. package/dist/src/core/http/types.d.ts +19 -0
  103. package/dist/src/core/server/baseServer.d.ts +9 -0
  104. package/dist/src/core/server/mcpServer.d.ts +2 -0
  105. package/dist/src/core/server/ssrServer.d.ts +2 -0
  106. package/dist/src/core/services/mcp.d.ts +3 -0
  107. package/dist/src/core/services/preview.d.ts +2 -0
  108. package/dist/src/core/services/registry.d.ts +4 -0
  109. package/dist/src/core/services/resolve.d.ts +3 -0
  110. package/dist/src/core/services/rsc.d.ts +2 -0
  111. package/dist/src/core/services/ssr.d.ts +3 -0
  112. package/dist/src/core/transports.d.ts +2 -2
  113. package/dist/src/index.d.ts +12 -3
  114. package/dist/src/modules/ai/index.d.ts +1 -0
  115. package/dist/src/modules/ai/toolkit.d.ts +17 -0
  116. package/dist/src/modules/mcp/constants.d.ts +1 -0
  117. package/dist/src/modules/mcp/handler.d.ts +6 -3
  118. package/dist/src/modules/mcp/helpers/computeVersion.d.ts +1 -0
  119. package/dist/src/modules/mcp/helpers/guide.d.ts +2 -0
  120. package/dist/src/modules/mcp/helpers/index.d.ts +4 -0
  121. package/dist/src/modules/mcp/helpers/opResult.d.ts +13 -0
  122. package/dist/src/modules/mcp/helpers/space.d.ts +49 -0
  123. package/dist/src/modules/mcp/index.d.ts +12 -5
  124. package/dist/src/modules/mcp/previewClient.d.ts +13 -0
  125. package/dist/src/modules/mcp/resources/canonical.d.ts +7 -0
  126. package/dist/src/modules/mcp/resources/core.d.ts +5 -0
  127. package/dist/src/modules/mcp/resources/envelope.d.ts +10 -0
  128. package/dist/src/modules/mcp/resources/index.d.ts +8 -10
  129. package/dist/src/modules/mcp/resources/primer.d.ts +6 -0
  130. package/dist/src/modules/mcp/resources/register.d.ts +6 -0
  131. package/dist/src/modules/mcp/resources/router.d.ts +6 -0
  132. package/dist/src/modules/mcp/resources/schema.d.ts +5 -0
  133. package/dist/src/modules/mcp/resources/style.d.ts +5 -0
  134. package/dist/src/modules/mcp/screenshotClient.d.ts +13 -0
  135. package/dist/src/modules/mcp/server.d.ts +18 -3
  136. package/dist/src/modules/mcp/tools/apply/dispatch.d.ts +6 -0
  137. package/dist/src/modules/mcp/tools/apply/index.d.ts +231 -0
  138. package/dist/src/modules/mcp/tools/apply/writeResult.d.ts +8 -0
  139. package/dist/src/modules/mcp/tools/index.d.ts +17 -6
  140. package/dist/src/modules/mcp/tools/operations/index.d.ts +449 -0
  141. package/dist/src/modules/mcp/tools/operations/schema/deleteElement.d.ts +10 -0
  142. package/dist/src/modules/mcp/tools/operations/schema/deleteFolder.d.ts +9 -0
  143. package/dist/src/modules/mcp/tools/operations/schema/deletePage.d.ts +9 -0
  144. package/dist/src/modules/mcp/tools/operations/schema/deleteVariable.d.ts +9 -0
  145. package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +14 -0
  146. package/dist/src/modules/mcp/tools/operations/schema/moveElement.d.ts +16 -0
  147. package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +79 -0
  148. package/dist/src/modules/mcp/tools/operations/schema/patchElement.d.ts +17 -0
  149. package/dist/src/modules/mcp/tools/operations/schema/registry.d.ts +22 -0
  150. package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +24 -0
  151. package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +9 -0
  152. package/dist/src/modules/mcp/tools/operations/schema/upsertElement.d.ts +16 -0
  153. package/dist/src/modules/mcp/tools/operations/schema/upsertFolder.d.ts +12 -0
  154. package/dist/src/modules/mcp/tools/operations/schema/upsertPage.d.ts +13 -0
  155. package/dist/src/modules/mcp/tools/operations/schema/upsertVariable.d.ts +16 -0
  156. package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +12 -0
  157. package/dist/src/modules/mcp/tools/operations/style/cssCatalog.d.ts +10 -0
  158. package/dist/src/modules/mcp/tools/operations/style/deleteDefinition.d.ts +9 -0
  159. package/dist/src/modules/mcp/tools/operations/style/deleteGlobalStyle.d.ts +9 -0
  160. package/dist/src/modules/mcp/tools/operations/style/deleteStyleVariable.d.ts +15 -0
  161. package/dist/src/modules/mcp/tools/operations/style/index.d.ts +12 -0
  162. package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +163 -0
  163. package/dist/src/modules/mcp/tools/operations/style/patchDefinition.d.ts +37 -0
  164. package/dist/src/modules/mcp/tools/operations/style/patchGlobalStyle.d.ts +37 -0
  165. package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +115 -0
  166. package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +9 -0
  167. package/dist/src/modules/mcp/tools/operations/style/upsertDefinition.d.ts +37 -0
  168. package/dist/src/modules/mcp/tools/operations/style/upsertGlobalStyle.d.ts +37 -0
  169. package/dist/src/modules/mcp/tools/operations/style/upsertStyleVariable.d.ts +20 -0
  170. package/dist/src/modules/mcp/tools/operations/style/write.d.ts +17 -0
  171. package/dist/src/modules/mcp/tools/preview.d.ts +226 -0
  172. package/dist/src/modules/mcp/tools/read.d.ts +8 -0
  173. package/dist/src/modules/mcp/tools/screenshot.d.ts +231 -0
  174. package/dist/src/modules/mcp/tools/search.d.ts +15 -0
  175. package/dist/src/modules/mcp/tools/shared/tool.d.ts +50 -0
  176. package/dist/src/modules/mcp/tools/shared/validator.d.ts +4 -0
  177. package/dist/src/modules/mcp/tools/validate.d.ts +228 -0
  178. package/dist/src/modules/mcp/types/aiSchema.d.ts +126 -0
  179. package/dist/src/modules/mcp/types/index.d.ts +4 -0
  180. package/dist/src/modules/mcp/types/previewTypes.d.ts +25 -0
  181. package/dist/src/modules/mcp/types/screenshotTypes.d.ts +29 -0
  182. package/dist/src/modules/mcp/types/toolTypes.d.ts +138 -0
  183. package/dist/src/modules/ssr/buildBody.d.ts +2 -2
  184. package/dist/src/modules/ssr/prepareRender.d.ts +2 -2
  185. package/dist/src/modules/ssr/preview.d.ts +16 -0
  186. package/dist/src/modules/ssr/streamBody.d.ts +2 -2
  187. package/package.json +10 -10
  188. package/dist/_virtual/_rolldown/runtime.js +0 -13
  189. package/dist/core/requestHandler.js +0 -126
  190. package/dist/modules/mcp/helpers.js +0 -75
  191. package/dist/modules/mcp/resources/glossary/binding.js +0 -73
  192. package/dist/modules/mcp/resources/glossary/collection.js +0 -76
  193. package/dist/modules/mcp/resources/glossary/displayMode.js +0 -50
  194. package/dist/modules/mcp/resources/glossary/element.js +0 -68
  195. package/dist/modules/mcp/resources/glossary/environment.js +0 -48
  196. package/dist/modules/mcp/resources/glossary/interaction.js +0 -62
  197. package/dist/modules/mcp/resources/glossary/page.js +0 -70
  198. package/dist/modules/mcp/resources/glossary/plugin.js +0 -96
  199. package/dist/modules/mcp/resources/glossary/resource.js +0 -75
  200. package/dist/modules/mcp/resources/glossary/schema.js +0 -69
  201. package/dist/modules/mcp/resources/glossary/schemaVariable.js +0 -60
  202. package/dist/modules/mcp/resources/glossary/segment.js +0 -59
  203. package/dist/modules/mcp/resources/glossary/space.js +0 -73
  204. package/dist/modules/mcp/resources/glossary/style.js +0 -81
  205. package/dist/modules/mcp/resources/glossary/styleSelector.js +0 -77
  206. package/dist/modules/mcp/resources/glossary/styleVariable.js +0 -72
  207. package/dist/modules/mcp/resources/index.js +0 -71
  208. package/dist/modules/mcp/resources/workflows/data.js +0 -49
  209. package/dist/modules/mcp/resources/workflows/elements.js +0 -53
  210. package/dist/modules/mcp/resources/workflows/segments.js +0 -55
  211. package/dist/modules/mcp/resources/workflows/styles.js +0 -91
  212. package/dist/modules/mcp/tools/collections/createCollection.js +0 -25
  213. package/dist/modules/mcp/tools/collections/createCollectionRecord.js +0 -27
  214. package/dist/modules/mcp/tools/collections/deleteCollection.js +0 -16
  215. package/dist/modules/mcp/tools/collections/deleteCollectionRecord.js +0 -16
  216. package/dist/modules/mcp/tools/collections/getCollection.js +0 -21
  217. package/dist/modules/mcp/tools/collections/getCollectionRecord.js +0 -25
  218. package/dist/modules/mcp/tools/collections/getCollectionRecords.js +0 -29
  219. package/dist/modules/mcp/tools/collections/getCollections.js +0 -19
  220. package/dist/modules/mcp/tools/collections/updateCollection.js +0 -28
  221. package/dist/modules/mcp/tools/collections/updateCollectionRecord.js +0 -31
  222. package/dist/modules/mcp/tools/docs/listResources.js +0 -16
  223. package/dist/modules/mcp/tools/docs/readResource.js +0 -23
  224. package/dist/modules/mcp/tools/plugins/addPlugin.js +0 -24
  225. package/dist/modules/mcp/tools/plugins/listPlugins.js +0 -20
  226. package/dist/modules/mcp/tools/plugins/removePlugin.js +0 -16
  227. package/dist/modules/mcp/tools/plugins/updatePlugin.js +0 -23
  228. package/dist/modules/mcp/tools/resources/addResource.js +0 -33
  229. package/dist/modules/mcp/tools/resources/getResource.js +0 -29
  230. package/dist/modules/mcp/tools/resources/getResources.js +0 -27
  231. package/dist/modules/mcp/tools/resources/moveResource.js +0 -30
  232. package/dist/modules/mcp/tools/resources/removeResource.js +0 -19
  233. package/dist/modules/mcp/tools/segment/createSegment.js +0 -27
  234. package/dist/modules/mcp/tools/segment/deleteSegment.js +0 -16
  235. package/dist/modules/mcp/tools/segment/getSegment.js +0 -19
  236. package/dist/modules/mcp/tools/segment/getSegments.js +0 -27
  237. package/dist/modules/mcp/tools/segment/schema/elements/createSegmentElement.js +0 -24
  238. package/dist/modules/mcp/tools/segment/schema/elements/deleteSegmentElement.js +0 -19
  239. package/dist/modules/mcp/tools/segment/schema/elements/moveSegmentElement.js +0 -28
  240. package/dist/modules/mcp/tools/segment/schema/elements/updateSegmentElement.js +0 -23
  241. package/dist/modules/mcp/tools/segment/schema/variables/createSegmentVariable.js +0 -41
  242. package/dist/modules/mcp/tools/segment/schema/variables/deleteSegmentVariable.js +0 -19
  243. package/dist/modules/mcp/tools/segment/schema/variables/updateSegmentVariable.js +0 -41
  244. package/dist/modules/mcp/tools/segment/style/variables/createSegmentStyleVariable.js +0 -34
  245. package/dist/modules/mcp/tools/segment/style/variables/deleteSegmentStyleVariable.js +0 -21
  246. package/dist/modules/mcp/tools/segment/style/variables/updateSegmentStyleVariable.js +0 -34
  247. package/dist/modules/mcp/tools/segment/updateSegment.js +0 -30
  248. package/dist/modules/mcp/tools/space/schema/applyPreview.js +0 -33
  249. package/dist/modules/mcp/tools/space/schema/elements/cloneElement.js +0 -34
  250. package/dist/modules/mcp/tools/space/schema/elements/createElement.js +0 -50
  251. package/dist/modules/mcp/tools/space/schema/elements/deleteElement.js +0 -16
  252. package/dist/modules/mcp/tools/space/schema/elements/getElement.js +0 -17
  253. package/dist/modules/mcp/tools/space/schema/elements/getElements.js +0 -21
  254. package/dist/modules/mcp/tools/space/schema/elements/listElements.js +0 -28
  255. package/dist/modules/mcp/tools/space/schema/elements/moveElement.js +0 -27
  256. package/dist/modules/mcp/tools/space/schema/elements/updateElement.js +0 -49
  257. package/dist/modules/mcp/tools/space/schema/getSpaceSettings.js +0 -46
  258. package/dist/modules/mcp/tools/space/schema/pageFolders/createPageFolder.js +0 -24
  259. package/dist/modules/mcp/tools/space/schema/pageFolders/deletePageFolder.js +0 -16
  260. package/dist/modules/mcp/tools/space/schema/pageFolders/getPageFolder.js +0 -17
  261. package/dist/modules/mcp/tools/space/schema/pageFolders/getPageFolders.js +0 -17
  262. package/dist/modules/mcp/tools/space/schema/pageFolders/updatePageFolder.js +0 -28
  263. package/dist/modules/mcp/tools/space/schema/pages/createPage.js +0 -37
  264. package/dist/modules/mcp/tools/space/schema/pages/deletePage.js +0 -16
  265. package/dist/modules/mcp/tools/space/schema/pages/getPage.js +0 -28
  266. package/dist/modules/mcp/tools/space/schema/pages/getPageBySlug.js +0 -17
  267. package/dist/modules/mcp/tools/space/schema/pages/getPages.js +0 -17
  268. package/dist/modules/mcp/tools/space/schema/pages/updatePage.js +0 -25
  269. package/dist/modules/mcp/tools/space/schema/schemas.js +0 -53
  270. package/dist/modules/mcp/tools/space/schema/updateSpaceSettings.js +0 -23
  271. package/dist/modules/mcp/tools/space/schema/variables/createVariable.js +0 -38
  272. package/dist/modules/mcp/tools/space/schema/variables/deleteVariable.js +0 -16
  273. package/dist/modules/mcp/tools/space/schema/variables/getVariable.js +0 -17
  274. package/dist/modules/mcp/tools/space/schema/variables/getVariables.js +0 -17
  275. package/dist/modules/mcp/tools/space/schema/variables/updateVariable.js +0 -38
  276. package/dist/modules/mcp/tools/space/style/selectors/createStyleSelector.js +0 -37
  277. package/dist/modules/mcp/tools/space/style/selectors/deleteStyleSelector.js +0 -24
  278. package/dist/modules/mcp/tools/space/style/selectors/getStyleSelectors.js +0 -20
  279. package/dist/modules/mcp/tools/space/style/selectors/updateStyleSelector.js +0 -37
  280. package/dist/modules/mcp/tools/space/style/variables/createStyleVariable.js +0 -33
  281. package/dist/modules/mcp/tools/space/style/variables/deleteStyleVariable.js +0 -20
  282. package/dist/modules/mcp/tools/space/style/variables/getStyleVariable.js +0 -19
  283. package/dist/modules/mcp/tools/space/style/variables/getStyleVariables.js +0 -16
  284. package/dist/modules/mcp/tools/space/style/variables/updateStyleVariable.js +0 -33
  285. package/dist/package.js +0 -77
  286. package/dist/package.json.d.ts +0 -67
  287. package/dist/src/core/requestHandler.d.ts +0 -5
  288. package/dist/src/modules/mcp/helpers.d.ts +0 -9
  289. package/dist/src/modules/mcp/resources/glossary/binding.d.ts +0 -7
  290. package/dist/src/modules/mcp/resources/glossary/collection.d.ts +0 -7
  291. package/dist/src/modules/mcp/resources/glossary/displayMode.d.ts +0 -7
  292. package/dist/src/modules/mcp/resources/glossary/element.d.ts +0 -7
  293. package/dist/src/modules/mcp/resources/glossary/environment.d.ts +0 -7
  294. package/dist/src/modules/mcp/resources/glossary/interaction.d.ts +0 -7
  295. package/dist/src/modules/mcp/resources/glossary/page.d.ts +0 -7
  296. package/dist/src/modules/mcp/resources/glossary/plugin.d.ts +0 -7
  297. package/dist/src/modules/mcp/resources/glossary/resource.d.ts +0 -7
  298. package/dist/src/modules/mcp/resources/glossary/schema.d.ts +0 -7
  299. package/dist/src/modules/mcp/resources/glossary/schemaVariable.d.ts +0 -7
  300. package/dist/src/modules/mcp/resources/glossary/segment.d.ts +0 -7
  301. package/dist/src/modules/mcp/resources/glossary/space.d.ts +0 -7
  302. package/dist/src/modules/mcp/resources/glossary/style.d.ts +0 -7
  303. package/dist/src/modules/mcp/resources/glossary/styleSelector.d.ts +0 -7
  304. package/dist/src/modules/mcp/resources/glossary/styleVariable.d.ts +0 -7
  305. package/dist/src/modules/mcp/resources/workflows/data.d.ts +0 -7
  306. package/dist/src/modules/mcp/resources/workflows/elements.d.ts +0 -7
  307. package/dist/src/modules/mcp/resources/workflows/segments.d.ts +0 -7
  308. package/dist/src/modules/mcp/resources/workflows/styles.d.ts +0 -7
  309. package/dist/src/modules/mcp/tools/collections/createCollection.d.ts +0 -3
  310. package/dist/src/modules/mcp/tools/collections/createCollectionRecord.d.ts +0 -3
  311. package/dist/src/modules/mcp/tools/collections/deleteCollection.d.ts +0 -3
  312. package/dist/src/modules/mcp/tools/collections/deleteCollectionRecord.d.ts +0 -3
  313. package/dist/src/modules/mcp/tools/collections/getCollection.d.ts +0 -3
  314. package/dist/src/modules/mcp/tools/collections/getCollectionRecord.d.ts +0 -3
  315. package/dist/src/modules/mcp/tools/collections/getCollectionRecords.d.ts +0 -3
  316. package/dist/src/modules/mcp/tools/collections/getCollections.d.ts +0 -3
  317. package/dist/src/modules/mcp/tools/collections/index.d.ts +0 -10
  318. package/dist/src/modules/mcp/tools/collections/updateCollection.d.ts +0 -3
  319. package/dist/src/modules/mcp/tools/collections/updateCollectionRecord.d.ts +0 -3
  320. package/dist/src/modules/mcp/tools/docs/index.d.ts +0 -2
  321. package/dist/src/modules/mcp/tools/docs/listResources.d.ts +0 -3
  322. package/dist/src/modules/mcp/tools/docs/readResource.d.ts +0 -3
  323. package/dist/src/modules/mcp/tools/plugins/addPlugin.d.ts +0 -3
  324. package/dist/src/modules/mcp/tools/plugins/index.d.ts +0 -5
  325. package/dist/src/modules/mcp/tools/plugins/listPlugins.d.ts +0 -3
  326. package/dist/src/modules/mcp/tools/plugins/removePlugin.d.ts +0 -3
  327. package/dist/src/modules/mcp/tools/plugins/updatePlugin.d.ts +0 -3
  328. package/dist/src/modules/mcp/tools/resources/addResource.d.ts +0 -3
  329. package/dist/src/modules/mcp/tools/resources/getResource.d.ts +0 -3
  330. package/dist/src/modules/mcp/tools/resources/getResources.d.ts +0 -3
  331. package/dist/src/modules/mcp/tools/resources/index.d.ts +0 -6
  332. package/dist/src/modules/mcp/tools/resources/moveResource.d.ts +0 -3
  333. package/dist/src/modules/mcp/tools/resources/removeResource.d.ts +0 -3
  334. package/dist/src/modules/mcp/tools/resources/resources.test.d.ts +0 -1
  335. package/dist/src/modules/mcp/tools/segment/createSegment.d.ts +0 -3
  336. package/dist/src/modules/mcp/tools/segment/deleteSegment.d.ts +0 -3
  337. package/dist/src/modules/mcp/tools/segment/getSegment.d.ts +0 -3
  338. package/dist/src/modules/mcp/tools/segment/getSegments.d.ts +0 -3
  339. package/dist/src/modules/mcp/tools/segment/index.d.ts +0 -8
  340. package/dist/src/modules/mcp/tools/segment/schema/elements/createSegmentElement.d.ts +0 -3
  341. package/dist/src/modules/mcp/tools/segment/schema/elements/deleteSegmentElement.d.ts +0 -3
  342. package/dist/src/modules/mcp/tools/segment/schema/elements/index.d.ts +0 -5
  343. package/dist/src/modules/mcp/tools/segment/schema/elements/moveSegmentElement.d.ts +0 -3
  344. package/dist/src/modules/mcp/tools/segment/schema/elements/segmentElements.test.d.ts +0 -1
  345. package/dist/src/modules/mcp/tools/segment/schema/elements/updateSegmentElement.d.ts +0 -3
  346. package/dist/src/modules/mcp/tools/segment/schema/index.d.ts +0 -2
  347. package/dist/src/modules/mcp/tools/segment/schema/variables/createSegmentVariable.d.ts +0 -3
  348. package/dist/src/modules/mcp/tools/segment/schema/variables/deleteSegmentVariable.d.ts +0 -3
  349. package/dist/src/modules/mcp/tools/segment/schema/variables/index.d.ts +0 -4
  350. package/dist/src/modules/mcp/tools/segment/schema/variables/segmentVariables.test.d.ts +0 -1
  351. package/dist/src/modules/mcp/tools/segment/schema/variables/updateSegmentVariable.d.ts +0 -3
  352. package/dist/src/modules/mcp/tools/segment/segment.test.d.ts +0 -1
  353. package/dist/src/modules/mcp/tools/segment/style/index.d.ts +0 -1
  354. package/dist/src/modules/mcp/tools/segment/style/variables/createSegmentStyleVariable.d.ts +0 -3
  355. package/dist/src/modules/mcp/tools/segment/style/variables/deleteSegmentStyleVariable.d.ts +0 -3
  356. package/dist/src/modules/mcp/tools/segment/style/variables/index.d.ts +0 -4
  357. package/dist/src/modules/mcp/tools/segment/style/variables/segmentStyleVariables.test.d.ts +0 -1
  358. package/dist/src/modules/mcp/tools/segment/style/variables/updateSegmentStyleVariable.d.ts +0 -3
  359. package/dist/src/modules/mcp/tools/segment/updateSegment.d.ts +0 -3
  360. package/dist/src/modules/mcp/tools/space/index.d.ts +0 -2
  361. package/dist/src/modules/mcp/tools/space/schema/applyPreview.d.ts +0 -3
  362. package/dist/src/modules/mcp/tools/space/schema/elements/cloneElement.d.ts +0 -3
  363. package/dist/src/modules/mcp/tools/space/schema/elements/createElement.d.ts +0 -3
  364. package/dist/src/modules/mcp/tools/space/schema/elements/deleteElement.d.ts +0 -3
  365. package/dist/src/modules/mcp/tools/space/schema/elements/elements.test.d.ts +0 -1
  366. package/dist/src/modules/mcp/tools/space/schema/elements/getElement.d.ts +0 -3
  367. package/dist/src/modules/mcp/tools/space/schema/elements/getElements.d.ts +0 -3
  368. package/dist/src/modules/mcp/tools/space/schema/elements/index.d.ts +0 -9
  369. package/dist/src/modules/mcp/tools/space/schema/elements/listElements.d.ts +0 -3
  370. package/dist/src/modules/mcp/tools/space/schema/elements/moveElement.d.ts +0 -3
  371. package/dist/src/modules/mcp/tools/space/schema/elements/updateElement.d.ts +0 -3
  372. package/dist/src/modules/mcp/tools/space/schema/getSpaceSettings.d.ts +0 -3
  373. package/dist/src/modules/mcp/tools/space/schema/index.d.ts +0 -8
  374. package/dist/src/modules/mcp/tools/space/schema/pageFolders/createPageFolder.d.ts +0 -3
  375. package/dist/src/modules/mcp/tools/space/schema/pageFolders/deletePageFolder.d.ts +0 -3
  376. package/dist/src/modules/mcp/tools/space/schema/pageFolders/getPageFolder.d.ts +0 -3
  377. package/dist/src/modules/mcp/tools/space/schema/pageFolders/getPageFolders.d.ts +0 -3
  378. package/dist/src/modules/mcp/tools/space/schema/pageFolders/index.d.ts +0 -6
  379. package/dist/src/modules/mcp/tools/space/schema/pageFolders/pageFolders.test.d.ts +0 -1
  380. package/dist/src/modules/mcp/tools/space/schema/pageFolders/updatePageFolder.d.ts +0 -3
  381. package/dist/src/modules/mcp/tools/space/schema/pages/createPage.d.ts +0 -3
  382. package/dist/src/modules/mcp/tools/space/schema/pages/deletePage.d.ts +0 -3
  383. package/dist/src/modules/mcp/tools/space/schema/pages/getPage.d.ts +0 -3
  384. package/dist/src/modules/mcp/tools/space/schema/pages/getPageBySlug.d.ts +0 -3
  385. package/dist/src/modules/mcp/tools/space/schema/pages/getPages.d.ts +0 -3
  386. package/dist/src/modules/mcp/tools/space/schema/pages/index.d.ts +0 -7
  387. package/dist/src/modules/mcp/tools/space/schema/pages/pages.test.d.ts +0 -1
  388. package/dist/src/modules/mcp/tools/space/schema/pages/updatePage.d.ts +0 -3
  389. package/dist/src/modules/mcp/tools/space/schema/schemas.d.ts +0 -66
  390. package/dist/src/modules/mcp/tools/space/schema/updateSpaceSettings.d.ts +0 -3
  391. package/dist/src/modules/mcp/tools/space/schema/variables/createVariable.d.ts +0 -3
  392. package/dist/src/modules/mcp/tools/space/schema/variables/deleteVariable.d.ts +0 -3
  393. package/dist/src/modules/mcp/tools/space/schema/variables/getVariable.d.ts +0 -3
  394. package/dist/src/modules/mcp/tools/space/schema/variables/getVariables.d.ts +0 -3
  395. package/dist/src/modules/mcp/tools/space/schema/variables/index.d.ts +0 -6
  396. package/dist/src/modules/mcp/tools/space/schema/variables/updateVariable.d.ts +0 -3
  397. package/dist/src/modules/mcp/tools/space/schema/variables/variables.test.d.ts +0 -1
  398. package/dist/src/modules/mcp/tools/space/space.test.d.ts +0 -1
  399. package/dist/src/modules/mcp/tools/space/style/index.d.ts +0 -2
  400. package/dist/src/modules/mcp/tools/space/style/selectors/createStyleSelector.d.ts +0 -3
  401. package/dist/src/modules/mcp/tools/space/style/selectors/deleteStyleSelector.d.ts +0 -3
  402. package/dist/src/modules/mcp/tools/space/style/selectors/getStyleSelectors.d.ts +0 -3
  403. package/dist/src/modules/mcp/tools/space/style/selectors/index.d.ts +0 -5
  404. package/dist/src/modules/mcp/tools/space/style/selectors/styleSelectors.test.d.ts +0 -1
  405. package/dist/src/modules/mcp/tools/space/style/selectors/updateStyleSelector.d.ts +0 -3
  406. package/dist/src/modules/mcp/tools/space/style/variables/createStyleVariable.d.ts +0 -3
  407. package/dist/src/modules/mcp/tools/space/style/variables/deleteStyleVariable.d.ts +0 -3
  408. package/dist/src/modules/mcp/tools/space/style/variables/getStyleVariable.d.ts +0 -3
  409. package/dist/src/modules/mcp/tools/space/style/variables/getStyleVariables.d.ts +0 -3
  410. package/dist/src/modules/mcp/tools/space/style/variables/index.d.ts +0 -6
  411. package/dist/src/modules/mcp/tools/space/style/variables/styleVariables.test.d.ts +0 -1
  412. package/dist/src/modules/mcp/tools/space/style/variables/updateStyleVariable.d.ts +0 -3
  413. /package/dist/src/{modules/mcp/helpers.test.d.ts → core/server/mcpServer.test.d.ts} +0 -0
  414. /package/dist/src/modules/{mcp/tools/collections/collections.test.d.ts → ai/toolkit.test.d.ts} +0 -0
  415. /package/dist/src/modules/mcp/{tools/plugins/plugins.test.d.ts → mcp.test.d.ts} +0 -0
@@ -0,0 +1,19 @@
1
+ import { RawResponse } from '../../helpers/buildResponseHelpers';
2
+ import { ServerCaches } from '../../helpers/cache';
3
+ import { PluginManager } from '../../plugins/manager';
4
+ import { SSRRequest, SSRResponseHelpers, SSRServerConfig, SSRTemplateFn } from '@plitzi/sdk-shared';
5
+ import { IncomingMessage } from 'node:http';
6
+ export interface BaseContext {
7
+ raw: IncomingMessage;
8
+ rawRes: RawResponse;
9
+ req: SSRRequest;
10
+ res: SSRResponseHelpers;
11
+ config: SSRServerConfig;
12
+ port: number;
13
+ }
14
+ export interface SSRContext extends BaseContext {
15
+ renderFn: SSRTemplateFn;
16
+ caches: ServerCaches;
17
+ pluginManager: PluginManager;
18
+ }
19
+ export type Stage<C extends BaseContext = BaseContext> = (ctx: C) => boolean | Promise<boolean>;
@@ -0,0 +1,9 @@
1
+ import { Handler } from '../transports';
2
+ import { CacheManager, PluginRegistry, SSRServer, SSRServerConfig } from '@plitzi/sdk-shared';
3
+ export interface HttpServerParts {
4
+ label: string;
5
+ cache: CacheManager | null;
6
+ plugins: PluginRegistry;
7
+ onDestroy?: () => void;
8
+ }
9
+ export declare const createHttpServer: (config: SSRServerConfig, makeHandlerForPort: (port: number) => Handler, parts: HttpServerParts) => SSRServer;
@@ -0,0 +1,2 @@
1
+ import { SSRServer, SSRServerConfig } from '@plitzi/sdk-shared';
2
+ export declare const createMCPServer: (config: SSRServerConfig) => SSRServer;
@@ -0,0 +1,2 @@
1
+ import { SSRServer, SSRServerConfig } from '@plitzi/sdk-shared';
2
+ export declare const createSSRServer: (config: SSRServerConfig) => SSRServer;
@@ -0,0 +1,3 @@
1
+ import { Stage } from '../http/types';
2
+ export declare const mcpStage: Stage;
3
+ export declare const mcpOnlyStage: Stage;
@@ -0,0 +1,2 @@
1
+ import { SSRContext, Stage } from '../http/types';
2
+ export declare const previewStage: Stage<SSRContext>;
@@ -0,0 +1,4 @@
1
+ import { ResolvedServices } from './resolve';
2
+ import { BaseContext, SSRContext, Stage } from '../http/types';
3
+ export declare const buildSSRPipeline: (services: ResolvedServices) => Stage<SSRContext>[];
4
+ export declare const buildMCPPipeline: () => Stage<BaseContext>[];
@@ -0,0 +1,3 @@
1
+ import { ServerServices, SSRServerConfig } from '@plitzi/sdk-shared';
2
+ export type ResolvedServices = Required<ServerServices>;
3
+ export declare const resolveServices: (config: SSRServerConfig) => ResolvedServices;
@@ -0,0 +1,2 @@
1
+ import { SSRContext, Stage } from '../http/types';
2
+ export declare const rscStage: Stage<SSRContext>;
@@ -0,0 +1,3 @@
1
+ import { SSRContext, Stage } from '../http/types';
2
+ export declare const ssrStage: Stage<SSRContext>;
3
+ export declare const notFoundStage: Stage;
@@ -6,13 +6,13 @@ export type CloseableServer = {
6
6
  listen: (port: number, host: string, cb: () => void) => unknown;
7
7
  };
8
8
  export type Handler = (req: IncomingMessage, res: RawResponse) => void;
9
- export declare const tlsOptions: (config: SSRServerConfig) => {
9
+ export declare const tlsOptions: (config: SSRServerConfig, label?: string) => {
10
10
  key: string | Buffer<ArrayBufferLike>;
11
11
  cert: string | Buffer<ArrayBufferLike>;
12
12
  minVersion: "TLSv1.3";
13
13
  };
14
14
  export declare const protoLabel: (version: number, hasTls: boolean) => string;
15
- export declare const buildTransport: (config: SSRServerConfig, handler: Handler, port: number) => {
15
+ export declare const buildTransport: (config: SSRServerConfig, handler: Handler, port: number, label?: string) => {
16
16
  primary: CloseableServer;
17
17
  h3?: CloseableServer;
18
18
  };
@@ -1,5 +1,14 @@
1
- export { createSSRServer } from './core/createServer';
1
+ export { createServer, createSSRServer, createMCPServer, resolveServices } from './core/createServer';
2
+ export { registerHealthCheck, buildHealthPayload } from './core/health';
3
+ export type { HealthCheckApp, HealthIdentity } from './core/health';
2
4
  export { createJsonAdapters } from './adapters/jsonAdapters';
3
- export { tools, toolResponseOk, toolResponseErr, readMcpBody, handleMcp, createMcpServer, zodToJsonSchema, getAllowedModes, bindTools, isToolActive, resolveToolHandler } from './modules/mcp';
4
- export { AIEngine } from './modules/ai';
5
+ export { AIEngine, toolResponseOk, toolResponseErr, zodToJsonSchema, getAllowedModes, bindTools, isToolActive, resolveToolHandler, isCallToolResult, toolResponseFromResult } from './modules/ai';
6
+ export { createMcpServer, handleMcp, serveMcp, readMcpBody, createHttpPreviewClient, createHttpScreenshotClient } from './modules/mcp';
7
+ export { createPreview, createMemoryDraftStore, PREVIEW_TOKEN_PARAM } from './modules/ssr/preview';
8
+ export { apply, search, read, validate, applyShape, searchShape, readShape, validateShape, operation, tools } from './modules/mcp/tools';
5
9
  export type { JsonAdaptersConfig } from './adapters/jsonAdapters';
10
+ export type { ResolvedServices } from './core/createServer';
11
+ export type { McpServerContext, PreviewClient, PreviewRequestBody, PreviewResult, HttpPreviewClientConfig, ScreenshotClient, ScreenshotImage, ScreenshotResult, Viewport, HttpScreenshotClientConfig } from './modules/mcp';
12
+ export type { ApplyInput, SearchInput, SearchResponse, SearchHit, ReadInput, ReadResponse, ReadHit, ValidateInput, WriteResponse, WriteElement, Persisters, Operation, ToolDef, ToolContext } from './modules/mcp/tools';
13
+ export type { Space } from './modules/mcp/helpers';
14
+ export type { Env } from './modules/mcp/types';
@@ -1,3 +1,4 @@
1
1
  import { default as AIEngine } from './AIEngine';
2
2
  export * from './AIEngine';
3
+ export { zodToJsonSchema, getAllowedModes, toolResponseOk, toolResponseErr, bindTools, isToolActive, resolveToolHandler, isCallToolResult, toolResponseFromResult } from './toolkit';
3
4
  export { AIEngine };
@@ -0,0 +1,17 @@
1
+ import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
+ import { AiMode, McpContent, McpTool, McpToolHandler, McpToolHandlerResult, ToolOperationType } from '@plitzi/sdk-shared';
3
+ /** Convert a Zod schema to the JSON Schema an AI provider (Anthropic / OpenAI) expects in a tool definition.
4
+ * Delegates to Zod v4's built-in converter — one implementation, so descriptions, literal discriminators,
5
+ * enums, nested objects and recursive (z.lazy) shapes all survive and the provider sees the same contract an
6
+ * MCP client does. `io: 'input'` describes what the agent must SEND; `unrepresentable: 'any'` degrades an
7
+ * exotic type to an empty schema instead of throwing, so one unusual tool never breaks the whole tool list. */
8
+ export declare const zodToJsonSchema: (schema: unknown) => Record<string, unknown>;
9
+ export declare const firstText: (content: McpContent[]) => string | undefined;
10
+ export declare const getAllowedModes: (operationType: ToolOperationType) => AiMode[];
11
+ export declare const toolResponseOk: (data: unknown, agentMessage?: string) => McpToolHandlerResult;
12
+ export declare const toolResponseErr: (error: Error | string) => McpToolHandlerResult;
13
+ export declare const isCallToolResult: (result: unknown) => result is CallToolResult;
14
+ export declare const toolResponseFromResult: (result: CallToolResult) => McpToolHandlerResult;
15
+ export declare const isToolActive: (tool: McpTool) => boolean;
16
+ export declare const resolveToolHandler: (tool: McpTool) => McpToolHandler | undefined;
17
+ export declare const bindTools: (tools: McpTool[]) => McpTool[];
@@ -0,0 +1 @@
1
+ export declare const PREVIEW_TOKEN_PARAM = "__pt";
@@ -1,6 +1,9 @@
1
- import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp';
1
+ import { createMcpServer } from './server';
2
+ import { PreviewClient, ScreenshotClient } from './types';
2
3
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
3
- import { McpServerConfig, AiContext } from '@plitzi/sdk-shared';
4
+ import { SSRAdapters, SSRRequest } from '@plitzi/sdk-shared';
4
5
  import { IncomingMessage, ServerResponse } from 'node:http';
5
6
  export declare const readMcpBody: (req: IncomingMessage) => Promise<unknown>;
6
- export declare const handleMcp: (req: IncomingMessage, res: ServerResponse, config: McpServerConfig, server?: McpServer, transport?: StreamableHTTPServerTransport, context?: AiContext) => Promise<void>;
7
+ export declare const serveMcp: (raw: IncomingMessage, res: ServerResponse, server: McpServer) => Promise<void>;
8
+ export declare const handleMcp: (raw: IncomingMessage, res: ServerResponse, req: SSRRequest, adapters: SSRAdapters, preview?: PreviewClient, screenshot?: ScreenshotClient) => Promise<void>;
9
+ export { createMcpServer };
@@ -0,0 +1 @@
1
+ export declare const computeVersion: (data: unknown) => string;
@@ -0,0 +1,2 @@
1
+ export declare const serverInstructions: string;
2
+ export declare const guideText = "# Plitzi AI MCP \u2014 usage guide\n\nA Plitzi space is **two separate schemas** you edit together:\n- **Element schema** \u2014 the tree of pages and elements (their type, label, props, and which style classes they use).\n- **Style schema** \u2014 reusable **definitions** (CSS classes), design tokens (variables), theme.\n\nThey are stored and persisted independently, but a single `plitzi_apply` batch may touch **both atomically**.\nTo style a specific element you do two things in one batch: write a **definition** (style schema) and **attach**\nit via the element's `style.base` (element schema). Example \u2014 \"rename button X to PEPE and make it red\":\n```json\n{ \"operations\": [\n { \"type\": \"upsertDefinition\", \"ref\": \"btn-x\", \"desktop\": { \"color\": \"red\" } },\n { \"type\": \"upsertElement\", \"pageRef\": \"home\",\n \"element\": { \"ref\": \"X\", \"type\": \"button\", \"label\": \"PEPE\", \"style\": { \"base\": [\"btn-x\"] } } }\n] }\n```\n\nReads are cheap by design \u2014 treat them like a filesystem: **list** to navigate, **read one item** for detail.\nNever download a whole tree you do not need.\n\n## Resources (read)\n- `plitzi://primer/{env}` \u2014 **cold-start bundle**: guide + types + css-properties + page/definition/variable\n **summaries** in one read. Fetch this first instead of the individual resources below. Summaries only \u2014 open a\n page skeleton or element for its tree/detail.\n- `plitzi://guide` \u2014 this guide.\n- `plitzi://types` \u2014 element types **observed in this space** (ground truth): props, slots, subTypes.\n- `plitzi://css-properties` \u2014 valid kebab-case CSS property keys.\n- `plitzi://schema/{env}/pages` \u2014 page **summaries** (ref, label, elementCount, folder). No element trees.\n- `plitzi://folders/{env}` \u2014 page **folders** (the sidebar tree): ref, name, slug, parentId. `/{ref}` for one.\n- `plitzi://schema/{env}/pages/{ref}` \u2014 one page as a **skeleton tree**: each node is `ref/type/label` **plus the\n style classes it attaches** (`base`, and `slots` for non-base slots) \u2014 names only, no CSS. So you can map every\n element to its class in a single page read, without opening each element just to learn which class it uses.\n- `plitzi://schema/{env}/pages/{ref}/styles` \u2014 **every style the page uses in one read**: the class definitions its\n elements attach (deduplicated, **with full CSS**) plus the global styles affecting any element type on the page.\n Reach for this to recolor/restyle a whole page \u2014 it needs no shared class-name prefix and no per-element reads.\n- `plitzi://schema/{env}/elements/{ref}` \u2014 one element in **full detail** (props, style, parentRef, childRefs).\n Its `resolvedStyle` inlines the **CSS of every definition** the element attaches (keyed by class ref), so you\n can see and edit its style without a separate definition read. Its `globalStyles` lists the **global element\n selectors** that also affect it (the CSS equivalent of `button { \u2026 }`, keyed by the type they target) \u2014 every\n element of that type inherits them. Edit a global only through the global-style tools (never per element).\n- `plitzi://definitions/{env}` \u2014 the **names** of every style definition.\n- `plitzi://definitions/{env}/{ref}` \u2014 one definition's CSS.\n- `plitzi://global-styles/{env}` \u2014 element **types** that have a site-wide global style. `/{componentType}` for one.\n- `plitzi://style-variables/{env}` \u2014 design tokens by category. `/{category}` for one.\n- `plitzi://schema-variables/{env}` \u2014 space-level values referenced in props as `{{name}}`.\n\nThe style resources also answer under the `plitzi://schema/{env}/\u2026` root as aliases \u2014 `plitzi://schema/{env}/definitions/{ref}`, `plitzi://schema/{env}/style-variables/{category}`, `plitzi://schema/{env}/schema-variables` \u2014 but prefer the ready-made `uri` from search / a write response over hand-building either form.\n\nData resources return `{ stateVersion, data }`. Keep `stateVersion` for optimistic concurrency.\n\n## Navigating (files analogy)\nPages and containers are folders; elements are files. **Prefer `plitzi_search` (especially with `include: \"detail\"`)\nover reading elements one by one** \u2014 it jumps straight to elements by label/type/attribute and each hit already\ncarries the element's `uri`, `stateVersion`, `pageUri`, `parentRef` and tree `path`, so you can edit it (with\noptimistic concurrency) **without a follow-up read**. `include: \"detail\"` additionally inlines each hit's props/style\n**and** its `resolvedStyle` (the CSS behind its classes) \u2014 so a search-then-edit is the efficient path and a manual\nelement read is the exception. Search also matches **pages** by name/slug (returned under `pages`, each with its uri +\nstateVersion) and returns any **style definitions** whose name matches the query, with full CSS, under `definitions`.\nWhen you do hold several refs to open (e.g. from a skeleton), read them together with `plitzi_read` rather than one at a time.\n\n## Tools (write)\n- `plitzi_validate` \u2014 check a batch, returns teachable errors/warnings. Writes nothing.\n- `plitzi_apply` \u2014 validate \u2192 apply \u2192 persist atomically. Rejects the whole batch on any error or conflict. Pass\n `dryRun: true` to apply in memory only and get the same result back (changed versions + full element detail)\n without persisting \u2014 inspect it, then re-run without `dryRun` to commit.\n- `plitzi_search` \u2014 find elements (and pages/definitions) across the space.\n- `plitzi_read` \u2014 read many resource **uris in one batch** (pages, elements, definitions, variables). Pass the\n ready-made uris from search / a write response; each result is `{ uri, stateVersion, data }` or a teachable error,\n so one bad uri never fails the batch. Use it instead of N single reads whenever you already hold several refs.\n\nWrite tools return what **changed** (`{ uri, stateVersion }`) plus counts, and the **full detail of every element\nthey created or updated** \u2014 each with its own `uri` and `stateVersion` (`elements: [...]`) so a follow-up edit of\nthe same element needs **no intermediate read**. Other resources (pages, definitions, variables) still report only\nuri+stateVersion \u2014 re-read them if you need their new content. The operation shapes are in each tool's input\nschema (discriminated by `type`).\n\n## Addressing\nRefs are a semantic `aiRef` you choose (e.g. `\"hero.cta\"`) or the element's **raw id**. Both always resolve, so\nschemas predating aiRef keep working through ids. Creating an element stores its `ref` as the aiRef.\n\n## Styling (crosses both schemas)\n- A definition lives in the **style schema**; an element's `style.base` (element schema) is the link that applies\n it. Styling an element = upsertDefinition + upsertElement with that ref in `style.base`, in one batch.\n- CSS keys are **kebab-case** (`background-color`). camelCase is rejected \u2014 read `plitzi://css-properties`.\n- Common **shorthands are accepted** and expanded for you: `border`, `border-{side}`, `border-radius`,\n `padding`, `margin`, `inset`, `gap` (they persist as their longhand keys).\n- CSS is grouped by breakpoint: `desktop`, `tablet`, `mobile`.\n- Reference a style variable in CSS as `var(--name)`; a schema variable in a prop as `{{name}}`.\n- `element.style.base` is a list of definition refs; other slots go under `element.style.slots`.\n- **Two kinds of style live in the style schema \u2014 do not confuse them:**\n - **Definitions** = reusable CSS **classes** (`upsertDefinition`/`patchDefinition`/`deleteDefinition`, keyed by a\n class `ref`). Attach one to an element via `style.base` to style **that** element (and anything else that opts in).\n - **Global styles** = the CSS equivalent of a bare element selector like `button { \u2026 }`\n (`upsertGlobalStyle`/`patchGlobalStyle`/`deleteGlobalStyle`, keyed by `componentType`). They style **every**\n element of that type at once. Use these for site-wide intent \u2014 e.g. \"all buttons rounded\":\n `{ \"type\": \"upsertGlobalStyle\", \"componentType\": \"button\", \"desktop\": { \"border-radius\": \"9999px\" } }`.\n - The two share one name space, so a class op refuses a name held by a global and vice-versa (guards against a\n typo silently rewriting every element of a type). If refused, you targeted the wrong kind \u2014 switch tools or\n rename. To style one element only, never reach for a global.\n\n## Pages & folders\nPages can be grouped into **folders** (the sidebar tree). A folder is `{ ref, name, slug, parentId? }`; its `ref`\n**is its id** (there is no separate aiRef), and that id is what a page and a nested folder reference.\n- Create/rename/move a folder with `upsertFolder` (the `ref` you pass on create becomes its id \u2014 pick a stable one\n like `\"blog\"`). Nest it under another with `parentId` (a folder ref); `parentId: null` moves it back to the root.\n- Put a page in a folder with `upsertPage`'s `folder` (a folder ref). A page's `folder` is always either **empty\n (root)** or an **existing folder id**: `folder: null` or `folder: \"\"` moves it to the root, and any other value\n must resolve to a folder that already exists or is created earlier in the same batch \u2014 an unknown folder is\n rejected, never stored.\n- `deleteFolder` removes a folder and **promotes its contents up one level** \u2014 its child folders and its pages move\n to its parent (or the root). A folder cannot be nested under itself or one of its descendants.\n\n## Semantics\n- **props are fully replaced** on `upsertElement`: send every prop you want to keep. To change only some props,\n use **`patchElement`** \u2014 it merges `props`/`style` onto the existing element (listed keys change, `null` unsets\n a key, everything else is preserved) and never creates. Combined with `plitzi_search` (which returns the ref +\n stateVersion), a targeted edit is two calls with no read.\n- **definition CSS is fully replaced** on `upsertDefinition`: send every property you want to keep. To change only\n some declarations, use **`patchDefinition`** \u2014 it merges CSS per breakpoint/state/variant/slot onto the existing\n definition (listed keys change, `null` removes a property, everything else is preserved) and never creates.\n Example \u2014 recolor one definition without resending it: `{ \"type\": \"patchDefinition\", \"ref\": \"btn-x\",\n \"desktop\": { \"background-color\": \"#111\" } }`.\n- **Atomic batches**: if any operation fails, `plitzi_apply` persists nothing.\n- **Optimistic concurrency**: pass `expectedResourceVersions` (URI \u2192 the stateVersion you read). If the live data\n drifted, apply is rejected with a conflict; re-read the reported resources and retry.\n";
@@ -0,0 +1,4 @@
1
+ export * from './computeVersion';
2
+ export * from './space';
3
+ export * from './guide';
4
+ export * from './opResult';
@@ -0,0 +1,13 @@
1
+ import { ValidationError } from '../types';
2
+ /** The result of one mutation handler: counts, the resource URIs it invalidated, any error, and the refs of
3
+ * elements it created/updated (so the caller can return their full detail as context — never for deletes). */
4
+ export interface OpResult {
5
+ errors?: ValidationError[];
6
+ created: number;
7
+ updated: number;
8
+ deleted: number;
9
+ staleResources: string[];
10
+ elementRefs?: string[];
11
+ }
12
+ export declare const empty: () => OpResult;
13
+ export declare const fail: (path: string, message: string, hint: string, validValues?: unknown[]) => OpResult;
@@ -0,0 +1,49 @@
1
+ import { Element, PageFolder, Schema, Style } from '@plitzi/sdk-shared';
2
+ /** The working view the tools read and mutate: the two Plitzi schemas (elements + style), which the platform
3
+ * stores and persists as separate documents (Space model / Style model). */
4
+ export interface Space {
5
+ schema: Schema;
6
+ style: Style;
7
+ }
8
+ export declare const cloneSpace: (space: Space) => Space;
9
+ export declare const slugify: (value: string) => string;
10
+ export declare const isPageElement: (schema: Schema, el: Element) => boolean;
11
+ export declare const getPageElements: (schema: Schema) => Element[];
12
+ /** Stable, human-readable ref for a page. Prefers an agent-chosen aiRef, then slug, then a slugified label. */
13
+ export declare const pageRefOf: (el: Element) => string;
14
+ /** Stable ref for a non-page element. An agent-chosen aiRef when present, otherwise the opaque id. */
15
+ export declare const elementRefOf: (el: Element) => string;
16
+ /** Finds a page by its semantic ref (aiRef/slug/…) or its raw id, so legacy schemas without an aiRef still resolve. */
17
+ export declare const findPageByRef: (schema: Schema, pageRef: string) => Element | undefined;
18
+ export declare const pageFoldersOf: (schema: Schema) => PageFolder[];
19
+ /** Resolve a folder by its id, or (for agent convenience) by an exact name or slug when that is unambiguous. */
20
+ export declare const findFolderByRef: (schema: Schema, ref: string) => PageFolder | undefined;
21
+ /** Order folders so every parent precedes its children — the invariant the schema validator enforces on
22
+ * pageFolders (a parentId must appear earlier in the array). Cycles (rejected upstream) are left in place. */
23
+ export declare const sortFolders: (folders: PageFolder[]) => PageFolder[];
24
+ /** Ancestor ids of a folder (following parentId), stopping on a cycle. Used to reject a parent change that would
25
+ * make a folder its own ancestor. */
26
+ export declare const folderAncestorIds: (folders: PageFolder[], startParentId: string | undefined) => string[];
27
+ /** Route params a page's slug binds (e.g. ":spaceId/update/*" → ["spaceId"]). These are valid {{name}}
28
+ * references on that page even though they are not space-level schema variables. */
29
+ export declare const slugRouteParams: (slug: string) => string[];
30
+ /** Every route param bound by any page slug in the space (union), so {{name}} validation does not false-flag a
31
+ * page-scoped dynamic binding. */
32
+ export declare const routeParamNames: (schema: Schema) => string[];
33
+ /** Indexed lookup that reflects the runtime reality: a flat id may be dangling (rsc placeholders, stale items). */
34
+ export declare const elementById: (schema: Schema, id: string) => Element | undefined;
35
+ export declare const descendantIds: (schema: Schema, pageRootId: string) => string[];
36
+ /** Resolve a ref to a concrete element within a page subtree (or the page root itself). Accepts either the
37
+ * semantic ref (aiRef) or the raw element id, so schemas predating aiRef keep working through their ids. */
38
+ export declare const resolveRef: (schema: Schema, page: Element, ref: string) => Element | undefined;
39
+ /** Ordered children of an element, honoring definition.items and skipping dangling ids. */
40
+ export declare const orderedChildren: (schema: Schema, el: Element) => Element[];
41
+ /** The page ref an element belongs to, walking up parents. 'unknown' when it has no page ancestor. */
42
+ export declare const pageRefOfElement: (schema: Schema, el: Element) => string;
43
+ /** Find any non-page element by its semantic ref (aiRef) or raw id, across the whole space. */
44
+ export declare const findElementByRef: (schema: Schema, ref: string) => Element | undefined;
45
+ /** Total number of descendant elements under a subtree (excluding the root). */
46
+ export declare const descendantCount: (schema: Schema, rootId: string) => number;
47
+ export declare const emptySpaceMessage = "Space data not available";
48
+ export declare const unauthorizedSpaceMessage = "This tool/resource needs a space, but no spaceId could be resolved from the Authorization token";
49
+ export declare const generateObjectId: () => string;
@@ -1,5 +1,12 @@
1
- import * as tools from './tools';
2
- export { readMcpBody, handleMcp } from './handler';
3
- export { createMcpServer } from './server';
4
- export { zodToJsonSchema, getAllowedModes, toolResponseOk, toolResponseErr, bindTools, isToolActive, resolveToolHandler } from './helpers';
5
- export { tools };
1
+ export { createMcpServer, handleMcp, serveMcp, readMcpBody } from './handler';
2
+ export { readResource, resourceVersion, registerResources, buildTypeRegistry, cssProperties } from './resources';
3
+ export { apply, validate, search, read, validateOperations, operation, tools } from './tools';
4
+ export { computeVersion } from './helpers';
5
+ export { createHttpPreviewClient } from './previewClient';
6
+ export { createHttpScreenshotClient } from './screenshotClient';
7
+ export type { HttpPreviewClientConfig } from './previewClient';
8
+ export type { HttpScreenshotClientConfig } from './screenshotClient';
9
+ export type { McpServerContext } from './server';
10
+ export type { ApplyInput, WriteResponse, Persisters, SearchInput, ReadInput, ReadResponse, ValidateInput, Operation, ToolDef, ToolContext } from './tools';
11
+ export type { Space } from './helpers';
12
+ export type * from './types';
@@ -0,0 +1,13 @@
1
+ import { PreviewClient } from './types';
2
+ export type HttpPreviewClientConfig = {
3
+ /** Absolute URL of the SSR `/preview` endpoint. */
4
+ url: string;
5
+ /** Shared secret sent as `x-preview-secret`; must match the SSR server's `preview.secret`. */
6
+ secret?: string;
7
+ /** Injectable fetch (tests / non-global runtimes). Defaults to the global fetch. */
8
+ fetchImpl?: typeof fetch;
9
+ };
10
+ /** Default `PreviewClient`: POSTs the preview request to the SSR `/preview` endpoint over HTTP. Used when the
11
+ * MCP server is a separate process from the SSR renderer (the common case). A network/HTTP failure surfaces as
12
+ * an `ok:false` result rather than throwing, so the calling tool can degrade gracefully. */
13
+ export declare const createHttpPreviewClient: ({ url, secret, fetchImpl }: HttpPreviewClientConfig) => PreviewClient;
@@ -0,0 +1,7 @@
1
+ import { Env } from '../types';
2
+ export declare const canonicalUri: (env: Env, uri: string) => string;
3
+ export declare const itemTemplates: (env: Env) => string[];
4
+ /** Teachable message for a URI that read as null. Distinguishes a well-formed URI whose ref does not resolve (the
5
+ * resource may be stale/deleted) from a URI whose shape matches no template at all (malformed — echo the valid
6
+ * templates so the agent stops hand-building URIs). See RFC 0004 I2. */
7
+ export declare const resourceErrorMessage: (env: Env, uri: string) => string;
@@ -0,0 +1,5 @@
1
+ import { Space } from '../helpers';
2
+ import { ResourceEnvelope } from '../types';
3
+ /** Space-independent singletons: the usage guide, the observed type registry and the CSS property catalog.
4
+ * Returns undefined when the URI is not one of these, so the router falls through to the next resolver. */
5
+ export declare const readCoreResource: (space: Space, uri: string) => ResourceEnvelope<unknown> | undefined;
@@ -0,0 +1,10 @@
1
+ import { ResourceEnvelope } from '../types';
2
+ /** Wrap any read projection with the version its optimistic-concurrency checks key on. */
3
+ export declare const envelope: <T>(data: T) => ResourceEnvelope<T>;
4
+ export declare const jsonContents: (uri: string, data: unknown) => {
5
+ contents: {
6
+ uri: string;
7
+ mimeType: string;
8
+ text: string;
9
+ }[];
10
+ };
@@ -1,10 +1,8 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
2
- import { McpResource } from '@plitzi/sdk-shared';
3
- export declare const registerResources: (server: McpServer, custom?: McpResource[], onRead?: (name: string, uri: string) => void) => void;
4
- export declare const allResources: McpResource[];
5
- export declare const getResourceList: () => {
6
- uri: string;
7
- name: string;
8
- description: string;
9
- }[];
10
- export declare const getResourceByUri: (uri: string) => McpResource | undefined;
1
+ export { readResource, resourceVersion } from './router';
2
+ export { registerResources } from './register';
3
+ export { resourceErrorMessage } from './canonical';
4
+ export { buildTypeRegistry } from '../tools/operations/schema/registry';
5
+ export type { TypeInfo, TypePropInfo, TypeRegistry } from '../tools/operations/schema/registry';
6
+ export * from '../tools/operations/schema/translator';
7
+ export { cssProperties, expandShorthand, isCssProperty, suggestCssProperty } from '../tools/operations/style/cssCatalog';
8
+ export * from '../tools/operations/style/translator';
@@ -0,0 +1,6 @@
1
+ import { Space } from '../helpers';
2
+ import { Env, ResourceEnvelope } from '../types';
3
+ /** The cold-start bundle: everything the guide says to read before the first write, in one round-trip.
4
+ * Summaries only — never full page/element trees (those are opened on demand), so it stays cheap even on a
5
+ * large space. Returns undefined when the URI is not the primer. */
6
+ export declare const readPrimerResource: (space: Space, env: Env, uri: string) => ResourceEnvelope<unknown> | undefined;
@@ -0,0 +1,6 @@
1
+ import { Space } from '../helpers';
2
+ import { Env } from '../types';
3
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
4
+ /** Register every resource on the MCP server: fixed listings plus templated per-item reads. The space is
5
+ * loaded lazily via getSpace, so listing resources never touches the store — only reading one does. */
6
+ export declare const registerResources: (server: McpServer, getSpace: () => Promise<Space>, env: Env) => void;
@@ -0,0 +1,6 @@
1
+ import { Space } from '../helpers';
2
+ import { Env, ResourceEnvelope } from '../types';
3
+ /** Resolve a resource URI to its versioned envelope, or null if unknown / not found. */
4
+ export declare const readResource: (space: Space, env: Env, rawUri: string) => ResourceEnvelope<unknown> | null;
5
+ /** Current version of a resource, for optimistic-concurrency checks. Null when the URI is unknown. */
6
+ export declare const resourceVersion: (space: Space, env: Env, uri: string) => string | null;
@@ -0,0 +1,5 @@
1
+ import { Space } from '../helpers';
2
+ import { Env, ResourceEnvelope } from '../types';
3
+ /** Element-schema reads: page listings/skeletons/styles, folders, single elements and schema variables. Returns
4
+ * undefined when the URI belongs to another domain, null when the shape is ours but the ref does not resolve. */
5
+ export declare const readSchemaResource: (space: Space, env: Env, uri: string) => ResourceEnvelope<unknown> | null | undefined;
@@ -0,0 +1,5 @@
1
+ import { Space } from '../helpers';
2
+ import { Env, ResourceEnvelope } from '../types';
3
+ /** Style-schema reads: definitions, global (per-type) styles and design-token variables by category. Returns
4
+ * undefined when the URI belongs to another domain, null when the shape is ours but the ref does not resolve. */
5
+ export declare const readStyleResource: (space: Space, env: Env, uri: string) => ResourceEnvelope<unknown> | null | undefined;
@@ -0,0 +1,13 @@
1
+ import { ScreenshotClient } from './types';
2
+ export type HttpScreenshotClientConfig = {
3
+ /** Browser service that turns a URL into PNG(s): POST { url, viewports } → { images }. */
4
+ serviceUrl: string;
5
+ /** SSR base the browser navigates to; the page path and the one-shot `__pt` token are appended. */
6
+ renderBaseUrl: string;
7
+ /** Injectable fetch (tests / non-global runtimes). Defaults to the global fetch. */
8
+ fetchImpl?: typeof fetch;
9
+ };
10
+ /** Default `ScreenshotClient`: composes the navigable preview URL (renderBaseUrl + pagePath + `?__pt=token`) and
11
+ * POSTs it to the browser service. Any network/HTTP failure surfaces as `ok:false` so the tool can fall back to
12
+ * the HTML preview instead of hard-failing. */
13
+ export declare const createHttpScreenshotClient: ({ serviceUrl, renderBaseUrl, fetchImpl }: HttpScreenshotClientConfig) => ScreenshotClient;
@@ -1,4 +1,19 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
2
- import { default as AIEngine } from '../ai/AIEngine';
3
- import { McpAdapters, McpTool, McpPrompt, McpResource } from '@plitzi/sdk-shared';
4
- export declare const createMcpServer: (adapters: Partial<McpAdapters> | undefined, engine: AIEngine, tools?: McpTool[], prompts?: McpPrompt[], resources?: McpResource[]) => McpServer;
2
+ import { PreviewClient, ScreenshotClient } from './types';
3
+ import { SSRAdapters } from '@plitzi/sdk-shared';
4
+ /** The MCP service is stateless: every request resolves its own `spaceId` (from the request JWT) and reads the
5
+ * space fresh through the adapters — schema and style are two documents, read/written independently. Both the
6
+ * spaceId and the space itself resolve lazily, so the public surface (handshake, tools-list, resources-list,
7
+ * and the space-independent guide / css-properties resources) works even when the request carries no auth —
8
+ * only a space-dependent tool/resource demands a spaceId, failing with `unauthorizedSpaceMessage` if none. */
9
+ export interface McpServerContext {
10
+ adapters: SSRAdapters;
11
+ getSpaceId: () => Promise<number | undefined>;
12
+ /** How the visual-preview tools (plitzi_preview / plitzi_screenshot) reach the renderer. Absent → those tools
13
+ * report PREVIEW_UNAVAILABLE, so an MCP-only deployment without a renderer still runs every other tool. */
14
+ preview?: PreviewClient;
15
+ /** The dedicated browser service for plitzi_screenshot. Absent → the tool is not registered (only the HTML
16
+ * plitzi_preview is offered). */
17
+ screenshot?: ScreenshotClient;
18
+ }
19
+ export declare const createMcpServer: ({ adapters, getSpaceId, preview, screenshot }: McpServerContext) => McpServer;
@@ -0,0 +1,6 @@
1
+ import { Space } from '../../helpers';
2
+ import { Env, MutationOutcome } from '../../types';
3
+ import { Operation } from '../operations';
4
+ /** Apply operations in order to the space (mutating it). Records which schema(s) changed so the caller can
5
+ * persist each independently. Stops collecting counts for a failed op but records its errors. */
6
+ export declare const applyOperations: (space: Space, env: Env, ops: Operation[]) => MutationOutcome;