@plitzi/sdk-mcp 0.33.0

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 (347) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +175 -0
  3. package/dist/createServer.d.ts +11 -0
  4. package/dist/createServer.js +36 -0
  5. package/dist/createServer.test.d.ts +1 -0
  6. package/dist/index.d.ts +20 -0
  7. package/dist/index.js +21 -0
  8. package/dist/modules/ai/AIEngine.d.ts +20 -0
  9. package/dist/modules/ai/AIEngine.js +120 -0
  10. package/dist/modules/ai/index.d.ts +4 -0
  11. package/dist/modules/ai/toolkit.d.ts +17 -0
  12. package/dist/modules/ai/toolkit.js +59 -0
  13. package/dist/modules/ai/toolkit.test.d.ts +1 -0
  14. package/dist/modules/mcp/apps/apps.test.d.ts +1 -0
  15. package/dist/modules/mcp/apps/example/index.d.ts +8 -0
  16. package/dist/modules/mcp/apps/example/view/index.tsx +70 -0
  17. package/dist/modules/mcp/apps/index.d.ts +11 -0
  18. package/dist/modules/mcp/apps/index.js +16 -0
  19. package/dist/modules/mcp/apps/render/index.d.ts +4 -0
  20. package/dist/modules/mcp/apps/render/index.js +17 -0
  21. package/dist/modules/mcp/apps/render/styles.d.ts +10 -0
  22. package/dist/modules/mcp/apps/render/styles.js +54 -0
  23. package/dist/modules/mcp/apps/render/styles.test.d.ts +1 -0
  24. package/dist/modules/mcp/apps/render/view/heldBatch.ts +107 -0
  25. package/dist/modules/mcp/apps/render/view/index.tsx +314 -0
  26. package/dist/modules/mcp/apps/render/view/streamProgress.ts +137 -0
  27. package/dist/modules/mcp/apps/shared/assets.d.ts +10 -0
  28. package/dist/modules/mcp/apps/shared/assets.js +10 -0
  29. package/dist/modules/mcp/apps/shared/bundle.d.ts +4 -0
  30. package/dist/modules/mcp/apps/shared/bundle.js +23 -0
  31. package/dist/modules/mcp/apps/shared/index.d.ts +3 -0
  32. package/dist/modules/mcp/apps/shared/page.d.ts +2 -0
  33. package/dist/modules/mcp/apps/shared/page.js +34 -0
  34. package/dist/modules/mcp/apps/shared/registerApp.d.ts +5 -0
  35. package/dist/modules/mcp/apps/shared/registerApp.js +43 -0
  36. package/dist/modules/mcp/apps/shared/resolve.d.ts +1 -0
  37. package/dist/modules/mcp/apps/shared/resolve.js +5 -0
  38. package/dist/modules/mcp/apps/shared/shell.ejs +59 -0
  39. package/dist/modules/mcp/apps/shared/zodEnglishOnly.d.ts +4 -0
  40. package/dist/modules/mcp/apps/shared/zodEnglishOnly.js +23 -0
  41. package/dist/modules/mcp/catalogs/builtinCallbacks.d.ts +19 -0
  42. package/dist/modules/mcp/catalogs/builtinCallbacks.js +139 -0
  43. package/dist/modules/mcp/catalogs/builtinComponents.d.ts +4 -0
  44. package/dist/modules/mcp/catalogs/builtinComponents.js +165 -0
  45. package/dist/modules/mcp/catalogs/builtinElementCallbacks.d.ts +17 -0
  46. package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +50 -0
  47. package/dist/modules/mcp/catalogs/builtinTransformers.d.ts +28 -0
  48. package/dist/modules/mcp/catalogs/builtinTransformers.js +148 -0
  49. package/dist/modules/mcp/catalogs/builtinTransformers.test.d.ts +1 -0
  50. package/dist/modules/mcp/catalogs/builtinUtilities.d.ts +15 -0
  51. package/dist/modules/mcp/catalogs/builtinUtilities.js +90 -0
  52. package/dist/modules/mcp/catalogs/cssCatalog/border.d.ts +4 -0
  53. package/dist/modules/mcp/catalogs/cssCatalog/border.js +30 -0
  54. package/dist/modules/mcp/catalogs/cssCatalog/box.d.ts +4 -0
  55. package/dist/modules/mcp/catalogs/cssCatalog/box.js +31 -0
  56. package/dist/modules/mcp/catalogs/cssCatalog/cssCatalog.test.d.ts +1 -0
  57. package/dist/modules/mcp/catalogs/cssCatalog/helpers.d.ts +34 -0
  58. package/dist/modules/mcp/catalogs/cssCatalog/helpers.js +185 -0
  59. package/dist/modules/mcp/catalogs/cssCatalog/index.d.ts +18 -0
  60. package/dist/modules/mcp/catalogs/cssCatalog/index.js +131 -0
  61. package/dist/modules/mcp/catalogs/cssCatalog/layout.d.ts +9 -0
  62. package/dist/modules/mcp/catalogs/cssCatalog/layout.js +99 -0
  63. package/dist/modules/mcp/catalogs/cssCatalog/visual.d.ts +8 -0
  64. package/dist/modules/mcp/catalogs/cssCatalog/visual.js +147 -0
  65. package/dist/modules/mcp/catalogs/index.d.ts +9 -0
  66. package/dist/modules/mcp/catalogs/observed.d.ts +46 -0
  67. package/dist/modules/mcp/catalogs/observed.js +90 -0
  68. package/dist/modules/mcp/catalogs/paramSpec.d.ts +39 -0
  69. package/dist/modules/mcp/catalogs/paramSpec.js +69 -0
  70. package/dist/modules/mcp/catalogs/registry.d.ts +35 -0
  71. package/dist/modules/mcp/catalogs/registry.js +89 -0
  72. package/dist/modules/mcp/e2e/connector.test.d.ts +1 -0
  73. package/dist/modules/mcp/e2e/host.test.d.ts +1 -0
  74. package/dist/modules/mcp/e2e/index.d.ts +6 -0
  75. package/dist/modules/mcp/e2e/mcpEndpoint.d.ts +27 -0
  76. package/dist/modules/mcp/e2e/oauthConnector.test.d.ts +1 -0
  77. package/dist/modules/mcp/e2e/postMessageChannel.d.ts +22 -0
  78. package/dist/modules/mcp/e2e/renderingHost.d.ts +39 -0
  79. package/dist/modules/mcp/handler.d.ts +22 -0
  80. package/dist/modules/mcp/handler.js +83 -0
  81. package/dist/modules/mcp/helpers/agentPrompt.d.ts +4 -0
  82. package/dist/modules/mcp/helpers/agentPrompt.js +104 -0
  83. package/dist/modules/mcp/helpers/computeVersion.d.ts +1 -0
  84. package/dist/modules/mcp/helpers/computeVersion.js +16 -0
  85. package/dist/modules/mcp/helpers/guide.d.ts +4 -0
  86. package/dist/modules/mcp/helpers/guide.js +608 -0
  87. package/dist/modules/mcp/helpers/index.d.ts +8 -0
  88. package/dist/modules/mcp/helpers/interactions.d.ts +30 -0
  89. package/dist/modules/mcp/helpers/interactions.js +123 -0
  90. package/dist/modules/mcp/helpers/log.d.ts +8 -0
  91. package/dist/modules/mcp/helpers/log.js +64 -0
  92. package/dist/modules/mcp/helpers/log.test.d.ts +1 -0
  93. package/dist/modules/mcp/helpers/opResult.d.ts +13 -0
  94. package/dist/modules/mcp/helpers/opResult.js +18 -0
  95. package/dist/modules/mcp/helpers/space.d.ts +126 -0
  96. package/dist/modules/mcp/helpers/space.js +314 -0
  97. package/dist/modules/mcp/helpers/uris.d.ts +33 -0
  98. package/dist/modules/mcp/helpers/uris.js +50 -0
  99. package/dist/modules/mcp/index.d.ts +13 -0
  100. package/dist/modules/mcp/mcp.bench.d.ts +1 -0
  101. package/dist/modules/mcp/previewClient.d.ts +13 -0
  102. package/dist/modules/mcp/previewClient.js +31 -0
  103. package/dist/modules/mcp/proxy/config.d.ts +20 -0
  104. package/dist/modules/mcp/proxy/config.js +62 -0
  105. package/dist/modules/mcp/proxy/endpoint.test.d.ts +1 -0
  106. package/dist/modules/mcp/proxy/fetch.d.ts +18 -0
  107. package/dist/modules/mcp/proxy/fetch.js +91 -0
  108. package/dist/modules/mcp/proxy/grant.d.ts +25 -0
  109. package/dist/modules/mcp/proxy/grant.js +67 -0
  110. package/dist/modules/mcp/proxy/guard.d.ts +6 -0
  111. package/dist/modules/mcp/proxy/guard.js +38 -0
  112. package/dist/modules/mcp/proxy/handler.d.ts +8 -0
  113. package/dist/modules/mcp/proxy/handler.js +99 -0
  114. package/dist/modules/mcp/proxy/index.d.ts +8 -0
  115. package/dist/modules/mcp/proxy/payload.d.ts +8 -0
  116. package/dist/modules/mcp/proxy/payload.js +29 -0
  117. package/dist/modules/mcp/proxy/proxy.test.d.ts +1 -0
  118. package/dist/modules/mcp/proxy/rewrite.d.ts +18 -0
  119. package/dist/modules/mcp/proxy/rewrite.js +138 -0
  120. package/dist/modules/mcp/proxy/sign.d.ts +6 -0
  121. package/dist/modules/mcp/proxy/sign.js +15 -0
  122. package/dist/modules/mcp/proxy/types.d.ts +45 -0
  123. package/dist/modules/mcp/proxy/types.js +9 -0
  124. package/dist/modules/mcp/proxy/wiring.test.d.ts +1 -0
  125. package/dist/modules/mcp/resources/canonical.d.ts +6 -0
  126. package/dist/modules/mcp/resources/canonical.js +30 -0
  127. package/dist/modules/mcp/resources/connectors.d.ts +22 -0
  128. package/dist/modules/mcp/resources/connectors.js +46 -0
  129. package/dist/modules/mcp/resources/core.d.ts +5 -0
  130. package/dist/modules/mcp/resources/core.js +18 -0
  131. package/dist/modules/mcp/resources/envelope.d.ts +10 -0
  132. package/dist/modules/mcp/resources/envelope.js +14 -0
  133. package/dist/modules/mcp/resources/index.d.ts +9 -0
  134. package/dist/modules/mcp/resources/primer.d.ts +7 -0
  135. package/dist/modules/mcp/resources/primer.js +33 -0
  136. package/dist/modules/mcp/resources/register.d.ts +10 -0
  137. package/dist/modules/mcp/resources/register.js +205 -0
  138. package/dist/modules/mcp/resources/renderGuide.d.ts +10 -0
  139. package/dist/modules/mcp/resources/renderGuide.js +451 -0
  140. package/dist/modules/mcp/resources/router.d.ts +10 -0
  141. package/dist/modules/mcp/resources/router.js +39 -0
  142. package/dist/modules/mcp/resources/schema.d.ts +5 -0
  143. package/dist/modules/mcp/resources/schema.js +43 -0
  144. package/dist/modules/mcp/resources/style.d.ts +5 -0
  145. package/dist/modules/mcp/resources/style.js +34 -0
  146. package/dist/modules/mcp/screenshotClient.d.ts +13 -0
  147. package/dist/modules/mcp/screenshotClient.js +47 -0
  148. package/dist/modules/mcp/server.d.ts +31 -0
  149. package/dist/modules/mcp/server.js +127 -0
  150. package/dist/modules/mcp/tests/apply.test.d.ts +1 -0
  151. package/dist/modules/mcp/tests/bindings.test.d.ts +1 -0
  152. package/dist/modules/mcp/tests/connectors.test.d.ts +1 -0
  153. package/dist/modules/mcp/tests/css.test.d.ts +1 -0
  154. package/dist/modules/mcp/tests/helpers.d.ts +13 -0
  155. package/dist/modules/mcp/tests/interactions.test.d.ts +1 -0
  156. package/dist/modules/mcp/tests/pages.test.d.ts +1 -0
  157. package/dist/modules/mcp/tests/reads.test.d.ts +1 -0
  158. package/dist/modules/mcp/tests/schemaIds.test.d.ts +1 -0
  159. package/dist/modules/mcp/tests/search.test.d.ts +1 -0
  160. package/dist/modules/mcp/tests/skill.test.d.ts +1 -0
  161. package/dist/modules/mcp/tests/styles.test.d.ts +1 -0
  162. package/dist/modules/mcp/tests/tools.test.d.ts +1 -0
  163. package/dist/modules/mcp/tests/validation.test.d.ts +1 -0
  164. package/dist/modules/mcp/tools/apply/dispatch.d.ts +6 -0
  165. package/dist/modules/mcp/tools/apply/dispatch.js +128 -0
  166. package/dist/modules/mcp/tools/apply/index.d.ts +656 -0
  167. package/dist/modules/mcp/tools/apply/index.js +161 -0
  168. package/dist/modules/mcp/tools/apply/writeResult.d.ts +8 -0
  169. package/dist/modules/mcp/tools/apply/writeResult.js +37 -0
  170. package/dist/modules/mcp/tools/index.d.ts +18 -0
  171. package/dist/modules/mcp/tools/index.js +24 -0
  172. package/dist/modules/mcp/tools/operations/connectors/deleteConnector.d.ts +9 -0
  173. package/dist/modules/mcp/tools/operations/connectors/deleteConnector.js +20 -0
  174. package/dist/modules/mcp/tools/operations/connectors/index.d.ts +188 -0
  175. package/dist/modules/mcp/tools/operations/connectors/index.js +12 -0
  176. package/dist/modules/mcp/tools/operations/connectors/manifest.d.ts +89 -0
  177. package/dist/modules/mcp/tools/operations/connectors/manifest.js +70 -0
  178. package/dist/modules/mcp/tools/operations/connectors/patchConnector.d.ts +94 -0
  179. package/dist/modules/mcp/tools/operations/connectors/patchConnector.js +58 -0
  180. package/dist/modules/mcp/tools/operations/connectors/upsertConnector.d.ts +98 -0
  181. package/dist/modules/mcp/tools/operations/connectors/upsertConnector.js +64 -0
  182. package/dist/modules/mcp/tools/operations/index.d.ts +2235 -0
  183. package/dist/modules/mcp/tools/operations/index.js +55 -0
  184. package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +17 -0
  185. package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +32 -0
  186. package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +25 -0
  187. package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +36 -0
  188. package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +27 -0
  189. package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +47 -0
  190. package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.d.ts +10 -0
  191. package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +29 -0
  192. package/dist/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +16 -0
  193. package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +41 -0
  194. package/dist/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +27 -0
  195. package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +60 -0
  196. package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.d.ts +55 -0
  197. package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +148 -0
  198. package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +16 -0
  199. package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +66 -0
  200. package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +9 -0
  201. package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +32 -0
  202. package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +12 -0
  203. package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +49 -0
  204. package/dist/modules/mcp/tools/operations/schema/index.d.ts +21 -0
  205. package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +12 -0
  206. package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +52 -0
  207. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +18 -0
  208. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +47 -0
  209. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +27 -0
  210. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +44 -0
  211. package/dist/modules/mcp/tools/operations/schema/operations.d.ts +236 -0
  212. package/dist/modules/mcp/tools/operations/schema/operations.js +41 -0
  213. package/dist/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +9 -0
  214. package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +25 -0
  215. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +14 -0
  216. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +77 -0
  217. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +36 -0
  218. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +44 -0
  219. package/dist/modules/mcp/tools/operations/schema/shared.d.ts +106 -0
  220. package/dist/modules/mcp/tools/operations/schema/shared.js +131 -0
  221. package/dist/modules/mcp/tools/operations/schema/translator.d.ts +12 -0
  222. package/dist/modules/mcp/tools/operations/schema/translator.js +216 -0
  223. package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +9 -0
  224. package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +18 -0
  225. package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +16 -0
  226. package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +42 -0
  227. package/dist/modules/mcp/tools/operations/schema/write.d.ts +42 -0
  228. package/dist/modules/mcp/tools/operations/schema/write.js +112 -0
  229. package/dist/modules/mcp/tools/operations/schemaIds.d.ts +6 -0
  230. package/dist/modules/mcp/tools/operations/schemaIds.js +58 -0
  231. package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +9 -0
  232. package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +21 -0
  233. package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +37 -0
  234. package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +28 -0
  235. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +37 -0
  236. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +24 -0
  237. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.d.ts +41 -0
  238. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +40 -0
  239. package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +9 -0
  240. package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +21 -0
  241. package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +37 -0
  242. package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +28 -0
  243. package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +37 -0
  244. package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +24 -0
  245. package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +9 -0
  246. package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +21 -0
  247. package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +37 -0
  248. package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +28 -0
  249. package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +37 -0
  250. package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +24 -0
  251. package/dist/modules/mcp/tools/operations/style/index.d.ts +15 -0
  252. package/dist/modules/mcp/tools/operations/style/operations.d.ts +264 -0
  253. package/dist/modules/mcp/tools/operations/style/operations.js +29 -0
  254. package/dist/modules/mcp/tools/operations/style/shared.d.ts +116 -0
  255. package/dist/modules/mcp/tools/operations/style/shared.js +59 -0
  256. package/dist/modules/mcp/tools/operations/style/translator.d.ts +12 -0
  257. package/dist/modules/mcp/tools/operations/style/translator.js +101 -0
  258. package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +15 -0
  259. package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +21 -0
  260. package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +20 -0
  261. package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +22 -0
  262. package/dist/modules/mcp/tools/operations/style/write.d.ts +12 -0
  263. package/dist/modules/mcp/tools/operations/style/write.js +108 -0
  264. package/dist/modules/mcp/tools/preview.d.ts +472 -0
  265. package/dist/modules/mcp/tools/preview.js +37 -0
  266. package/dist/modules/mcp/tools/read.d.ts +9 -0
  267. package/dist/modules/mcp/tools/read.js +51 -0
  268. package/dist/modules/mcp/tools/render.d.ts +506 -0
  269. package/dist/modules/mcp/tools/render.js +184 -0
  270. package/dist/modules/mcp/tools/render.test.d.ts +1 -0
  271. package/dist/modules/mcp/tools/screenshot.d.ts +656 -0
  272. package/dist/modules/mcp/tools/screenshot.js +83 -0
  273. package/dist/modules/mcp/tools/search.d.ts +15 -0
  274. package/dist/modules/mcp/tools/search.js +115 -0
  275. package/dist/modules/mcp/tools/shared/expandOperations.d.ts +13 -0
  276. package/dist/modules/mcp/tools/shared/expandOperations.js +44 -0
  277. package/dist/modules/mcp/tools/shared/tool.d.ts +72 -0
  278. package/dist/modules/mcp/tools/shared/tool.js +33 -0
  279. package/dist/modules/mcp/tools/shared/validator/audit.d.ts +4 -0
  280. package/dist/modules/mcp/tools/shared/validator/audit.js +124 -0
  281. package/dist/modules/mcp/tools/shared/validator/batch.d.ts +5 -0
  282. package/dist/modules/mcp/tools/shared/validator/batch.js +39 -0
  283. package/dist/modules/mcp/tools/shared/validator/bindings.d.ts +6 -0
  284. package/dist/modules/mcp/tools/shared/validator/bindings.js +70 -0
  285. package/dist/modules/mcp/tools/shared/validator/connectors.d.ts +19 -0
  286. package/dist/modules/mcp/tools/shared/validator/connectors.js +76 -0
  287. package/dist/modules/mcp/tools/shared/validator/context.d.ts +38 -0
  288. package/dist/modules/mcp/tools/shared/validator/context.js +35 -0
  289. package/dist/modules/mcp/tools/shared/validator/css.d.ts +4 -0
  290. package/dist/modules/mcp/tools/shared/validator/css.js +39 -0
  291. package/dist/modules/mcp/tools/shared/validator/elements.d.ts +7 -0
  292. package/dist/modules/mcp/tools/shared/validator/elements.js +68 -0
  293. package/dist/modules/mcp/tools/shared/validator/index.d.ts +8 -0
  294. package/dist/modules/mcp/tools/shared/validator/index.js +268 -0
  295. package/dist/modules/mcp/tools/shared/validator/interactions.d.ts +3 -0
  296. package/dist/modules/mcp/tools/shared/validator/interactions.js +103 -0
  297. package/dist/modules/mcp/tools/shared/validator/refs.d.ts +4 -0
  298. package/dist/modules/mcp/tools/shared/validator/refs.js +28 -0
  299. package/dist/modules/mcp/tools/validate.d.ts +653 -0
  300. package/dist/modules/mcp/tools/validate.js +47 -0
  301. package/dist/modules/mcp/types/aiSchema.d.ts +226 -0
  302. package/dist/modules/mcp/types/appTypes.d.ts +26 -0
  303. package/dist/modules/mcp/types/index.d.ts +5 -0
  304. package/dist/modules/mcp/types/previewTypes.d.ts +25 -0
  305. package/dist/modules/mcp/types/screenshotTypes.d.ts +29 -0
  306. package/dist/modules/mcp/types/toolTypes.d.ts +145 -0
  307. package/dist/modules/oauth/authorize.d.ts +7 -0
  308. package/dist/modules/oauth/authorize.js +177 -0
  309. package/dist/modules/oauth/challenge.d.ts +11 -0
  310. package/dist/modules/oauth/challenge.js +33 -0
  311. package/dist/modules/oauth/consentPage.d.ts +7 -0
  312. package/dist/modules/oauth/consentPage.js +118 -0
  313. package/dist/modules/oauth/metadata.d.ts +40 -0
  314. package/dist/modules/oauth/metadata.js +69 -0
  315. package/dist/modules/oauth/oauth.test.d.ts +1 -0
  316. package/dist/modules/oauth/params.d.ts +5 -0
  317. package/dist/modules/oauth/params.js +5 -0
  318. package/dist/modules/oauth/pkce.d.ts +6 -0
  319. package/dist/modules/oauth/pkce.js +15 -0
  320. package/dist/modules/oauth/records.d.ts +71 -0
  321. package/dist/modules/oauth/records.js +46 -0
  322. package/dist/modules/oauth/register.d.ts +5 -0
  323. package/dist/modules/oauth/register.js +55 -0
  324. package/dist/modules/oauth/respond.d.ts +13 -0
  325. package/dist/modules/oauth/respond.js +44 -0
  326. package/dist/modules/oauth/token.d.ts +5 -0
  327. package/dist/modules/oauth/token.js +100 -0
  328. package/dist/options.d.ts +73 -0
  329. package/dist/packageBoundary.test.d.ts +1 -0
  330. package/dist/pipeline.d.ts +12 -0
  331. package/dist/pipeline.js +29 -0
  332. package/dist/pipeline.test.d.ts +1 -0
  333. package/dist/preview/createPreview.d.ts +10 -0
  334. package/dist/preview/createPreview.js +83 -0
  335. package/dist/server.d.ts +15 -0
  336. package/dist/server.js +7 -0
  337. package/dist/stages/mcp.d.ts +4 -0
  338. package/dist/stages/mcp.js +30 -0
  339. package/dist/stages/oauth.d.ts +19 -0
  340. package/dist/stages/oauth.js +114 -0
  341. package/dist/stages/preview.d.ts +2 -0
  342. package/dist/stages/preview.js +37 -0
  343. package/dist/stages/proxy.d.ts +3 -0
  344. package/dist/stages/proxy.js +14 -0
  345. package/dist/tests/httpRequest.d.ts +14 -0
  346. package/package.json +77 -0
  347. package/skills/plitzi-render/SKILL.md +174 -0
@@ -0,0 +1,216 @@
1
+ import { computeVersion } from "../../../helpers/computeVersion.js";
2
+ import { descendantCount, descendantIds, elementById, elementRefOf, getPageElements, isPageElement, nameOf, orderedChildren, pageFoldersOf, pageRefOf, pageRefOfElement, slugRouteParams, spaceIndex, strOr } from "../../../helpers/space.js";
3
+ import { bindingsToAI, flowsFromInteractions } from "../../../helpers/interactions.js";
4
+ import { definitionToAI, globalStylesForType, idStyleToAI } from "../style/translator.js";
5
+ //#region src/modules/mcp/tools/operations/schema/translator.ts
6
+ var splitClasses = (value) => value ? value.split(/\s+/).filter(Boolean) : [];
7
+ var propsOf = (el) => {
8
+ const { subType, ...rest } = el.attributes;
9
+ return Object.keys(rest).length > 0 ? rest : void 0;
10
+ };
11
+ var slotClasses = (selectors) => {
12
+ const slots = {};
13
+ for (const [slot, classes] of Object.entries(selectors)) if (slot !== "base") slots[slot] = splitClasses(classes);
14
+ return slots;
15
+ };
16
+ var pageSummariesToAI = (schema) => getPageElements(schema).map((page) => ({
17
+ ref: pageRefOf(page),
18
+ label: nameOf(page),
19
+ slug: strOr(page.attributes.slug) ?? "",
20
+ default: page.attributes.default === true,
21
+ enabled: page.attributes.enabled !== false,
22
+ folder: strOr(page.attributes.folder) || void 0,
23
+ elementCount: descendantCount(schema, page.id)
24
+ }));
25
+ var folderToAI = (folder) => ({
26
+ ref: folder.id,
27
+ name: folder.name,
28
+ slug: folder.slug,
29
+ parentId: folder.parentId
30
+ });
31
+ var foldersToAI = (schema) => pageFoldersOf(schema).map(folderToAI);
32
+ var folderRefToAI = (schema, ref) => {
33
+ const folder = pageFoldersOf(schema).find((f) => f.id === ref);
34
+ return folder ? folderToAI(folder) : void 0;
35
+ };
36
+ var elementView = (schema, el, style) => {
37
+ const cache = spaceIndex(schema).detailCache;
38
+ const cached = cache.get(el.id);
39
+ if (cached && cached.style === style) return cached;
40
+ const detail = elementDetailToAI(schema, el, style);
41
+ const view = {
42
+ style,
43
+ detail,
44
+ version: computeVersion(detail)
45
+ };
46
+ cache.set(el.id, view);
47
+ return view;
48
+ };
49
+ var skeletonNode = (schema, el, style) => {
50
+ const children = orderedChildren(schema, el);
51
+ const base = splitClasses(el.definition.styleSelectors.base);
52
+ const slots = slotClasses(el.definition.styleSelectors);
53
+ return {
54
+ ref: elementRefOf(el),
55
+ type: el.definition.type,
56
+ label: el.definition.label,
57
+ subType: strOr(el.attributes.subType),
58
+ stateVersion: style ? elementView(schema, el, style).version : void 0,
59
+ base: base.length > 0 ? base : void 0,
60
+ slots: Object.keys(slots).length > 0 ? slots : void 0,
61
+ childCount: children.length,
62
+ children: children.length > 0 ? children.map((child) => skeletonNode(schema, child, style)) : void 0
63
+ };
64
+ };
65
+ var pageSkeletonToAI = (schema, pageEl, style) => {
66
+ const slug = strOr(pageEl.attributes.slug) ?? "";
67
+ return {
68
+ ref: pageRefOf(pageEl),
69
+ label: nameOf(pageEl),
70
+ slug,
71
+ default: pageEl.attributes.default === true,
72
+ enabled: pageEl.attributes.enabled !== false,
73
+ routeParams: slugRouteParams(slug),
74
+ tree: orderedChildren(schema, pageEl).map((child) => skeletonNode(schema, child, style))
75
+ };
76
+ };
77
+ var elementClassRefs = (el) => {
78
+ const refs = splitClasses(el.definition.styleSelectors.base);
79
+ for (const classes of Object.values(slotClasses(el.definition.styleSelectors))) refs.push(...classes);
80
+ return refs;
81
+ };
82
+ var pageStylesToAI = (schema, style, pageEl) => {
83
+ const classRefs = /* @__PURE__ */ new Set();
84
+ const types = /* @__PURE__ */ new Set();
85
+ const collect = (el) => {
86
+ for (const ref of elementClassRefs(el)) classRefs.add(ref);
87
+ types.add(el.definition.type);
88
+ };
89
+ collect(pageEl);
90
+ for (const id of descendantIds(schema, pageEl.id)) {
91
+ const el = elementById(schema, id);
92
+ if (el) collect(el);
93
+ }
94
+ const definitions = [];
95
+ for (const ref of Array.from(classRefs).sort()) {
96
+ const def = definitionToAI(style, ref);
97
+ if (def) definitions.push(def);
98
+ }
99
+ const globalStyles = [];
100
+ const seenGlobals = /* @__PURE__ */ new Set();
101
+ for (const type of Array.from(types).sort()) for (const global of globalStylesForType(style, type)) if (!seenGlobals.has(global.ref)) {
102
+ seenGlobals.add(global.ref);
103
+ globalStyles.push(global);
104
+ }
105
+ return {
106
+ ref: pageRefOf(pageEl),
107
+ definitions,
108
+ globalStyles
109
+ };
110
+ };
111
+ var resolveDefinitions = (style, base, slots) => {
112
+ const refs = new Set(base);
113
+ for (const classes of Object.values(slots)) for (const cls of classes) refs.add(cls);
114
+ const resolved = {};
115
+ for (const ref of refs) {
116
+ const def = definitionToAI(style, ref);
117
+ if (def) resolved[ref] = def;
118
+ }
119
+ return Object.keys(resolved).length > 0 ? resolved : void 0;
120
+ };
121
+ var variantNamesOf = (def) => {
122
+ const names = new Set(Object.keys(def.variants ?? {}));
123
+ for (const slot of Object.values(def.slots ?? {})) for (const name of Object.keys(slot.variants ?? {})) names.add(name);
124
+ return [...names].sort();
125
+ };
126
+ var availableVariantsFrom = (resolvedStyle) => {
127
+ if (!resolvedStyle) return;
128
+ const result = {};
129
+ for (const [ref, def] of Object.entries(resolvedStyle)) {
130
+ const names = variantNamesOf(def);
131
+ if (names.length > 0) result[ref] = names;
132
+ }
133
+ return Object.keys(result).length > 0 ? result : void 0;
134
+ };
135
+ var initialStateToAI = (el) => {
136
+ const initialState = el.definition.initialState;
137
+ if (!initialState) return;
138
+ const result = {};
139
+ if (initialState.styleVariant) {
140
+ const styleVariant = {};
141
+ for (const [cls, selectors] of Object.entries(initialState.styleVariant)) {
142
+ if (!selectors) continue;
143
+ const bySelector = {};
144
+ for (const [selector, variant] of Object.entries(selectors)) if (variant !== void 0) bySelector[selector] = variant;
145
+ if (Object.keys(bySelector).length > 0) styleVariant[cls] = bySelector;
146
+ }
147
+ if (Object.keys(styleVariant).length > 0) result.styleVariant = styleVariant;
148
+ }
149
+ if (typeof initialState.visibility === "boolean") result.visibility = initialState.visibility;
150
+ return Object.keys(result).length > 0 ? result : void 0;
151
+ };
152
+ var elementDetailToAI = (schema, el, style) => {
153
+ const children = orderedChildren(schema, el);
154
+ const parent = el.definition.parentId ? schema.flat[el.definition.parentId] : void 0;
155
+ const base = splitClasses(el.definition.styleSelectors.base);
156
+ const slots = slotClasses(el.definition.styleSelectors);
157
+ const detail = {
158
+ ref: elementRefOf(el),
159
+ type: el.definition.type,
160
+ subType: strOr(el.attributes.subType),
161
+ label: el.definition.label,
162
+ pageRef: pageRefOfElement(schema, el),
163
+ parentRef: parent ? isPageElement(schema, parent) ? pageRefOf(parent) : elementRefOf(parent) : void 0,
164
+ props: propsOf(el),
165
+ style: {
166
+ base,
167
+ slots
168
+ },
169
+ childRefs: children.length > 0 ? children.map(elementRefOf) : void 0
170
+ };
171
+ if (el.definition.runtime) detail.runtime = el.definition.runtime;
172
+ const initialState = initialStateToAI(el);
173
+ if (initialState) detail.initialState = initialState;
174
+ const bindings = bindingsToAI(el.definition.bindings);
175
+ if (bindings) detail.bindings = bindings;
176
+ const interactions = flowsFromInteractions(el.definition.interactions);
177
+ if (interactions.length > 0) detail.interactions = interactions;
178
+ if (style) {
179
+ const resolvedStyle = resolveDefinitions(style, base, slots);
180
+ if (resolvedStyle) {
181
+ detail.resolvedStyle = resolvedStyle;
182
+ const availableVariants = availableVariantsFrom(resolvedStyle);
183
+ if (availableVariants) detail.availableVariants = availableVariants;
184
+ }
185
+ const globalStyles = globalStylesForType(style, el.definition.type);
186
+ if (globalStyles.length > 0) detail.globalStyles = globalStyles;
187
+ const domId = strOr(el.attributes.id);
188
+ if (domId) {
189
+ const idStyle = idStyleToAI(style, domId);
190
+ if (idStyle) detail.idStyle = idStyle;
191
+ }
192
+ }
193
+ return detail;
194
+ };
195
+ var schemaVariablesToAI = (schema, includeSubValues = true) => {
196
+ const data = {};
197
+ for (const variable of schema.variables) data[variable.name] = {
198
+ name: variable.name,
199
+ reference: `{{${variable.name}}}`,
200
+ category: variable.category,
201
+ type: variable.type,
202
+ value: variable.value,
203
+ subValues: includeSubValues ? variable.subValues.map((sv) => ({
204
+ when: sv.when,
205
+ value: sv.value
206
+ })) : void 0
207
+ };
208
+ return data;
209
+ };
210
+ var settingsToAI = (schema) => {
211
+ const result = {};
212
+ for (const [key, value] of Object.entries(schema.settings)) result[key] = value;
213
+ return result;
214
+ };
215
+ //#endregion
216
+ export { elementDetailToAI, elementView, folderRefToAI, foldersToAI, pageSkeletonToAI, pageStylesToAI, pageSummariesToAI, schemaVariablesToAI, settingsToAI };
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ import { Space, OpResult } from '../../../../helpers';
3
+ import { Env } from '../../../../types';
4
+ export declare const deleteVariableOp: z.ZodObject<{
5
+ type: z.ZodLiteral<"deleteVariable">;
6
+ name: z.ZodString;
7
+ }, z.core.$strip>;
8
+ export type DeleteVariable = z.infer<typeof deleteVariableOp>;
9
+ export declare const deleteVariable: (space: Space, env: Env, op: DeleteVariable) => OpResult;
@@ -0,0 +1,18 @@
1
+ import { schemaVarsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { z } from "zod";
4
+ //#region src/modules/mcp/tools/operations/schema/variables/deleteVariable.ts
5
+ var deleteVariableOp = z.object({
6
+ type: z.literal("deleteVariable"),
7
+ name: z.string().describe("Name of the schema variable to delete")
8
+ }).describe("Delete a space-level schema variable by name.");
9
+ var deleteVariable = (space, env, op) => {
10
+ space.schema.variables = space.schema.variables.filter((v) => v.name !== op.name);
11
+ return {
12
+ ...empty(),
13
+ deleted: 1,
14
+ staleResources: [schemaVarsUri(env)]
15
+ };
16
+ };
17
+ //#endregion
18
+ export { deleteVariable, deleteVariableOp };
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ import { Space, OpResult } from '../../../../helpers';
3
+ import { Env } from '../../../../types';
4
+ export declare const upsertVariableOp: z.ZodObject<{
5
+ type: z.ZodLiteral<"upsertVariable">;
6
+ name: z.ZodString;
7
+ variableType: z.ZodString;
8
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
9
+ category: z.ZodOptional<z.ZodString>;
10
+ subValues: z.ZodOptional<z.ZodArray<z.ZodObject<{
11
+ when: z.ZodUnknown;
12
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
13
+ }, z.core.$strip>>>;
14
+ }, z.core.$strip>;
15
+ export type UpsertVariable = z.infer<typeof upsertVariableOp>;
16
+ export declare const upsertVariable: (space: Space, env: Env, op: UpsertVariable) => OpResult;
@@ -0,0 +1,42 @@
1
+ import { schemaVarsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { scalar } from "../shared.js";
4
+ import { z } from "zod";
5
+ //#region src/modules/mcp/tools/operations/schema/variables/upsertVariable.ts
6
+ var upsertVariableOp = z.object({
7
+ type: z.literal("upsertVariable"),
8
+ name: z.string().describe("Variable name; referenced in content as {{name}}"),
9
+ variableType: z.string().describe("Runtime type (text|number|...); NOT the `type` discriminator"),
10
+ value: scalar,
11
+ category: z.string().optional(),
12
+ subValues: z.array(z.object({
13
+ when: z.unknown(),
14
+ value: scalar
15
+ })).optional()
16
+ }).describe("Create or update a space-level schema variable (a {{name}} value shared across the space).");
17
+ var upsertVariable = (space, env, op) => {
18
+ const variable = {
19
+ name: op.name,
20
+ category: op.category ?? "general",
21
+ type: op.variableType,
22
+ value: op.value,
23
+ subValues: op.subValues ?? []
24
+ };
25
+ const idx = space.schema.variables.findIndex((v) => v.name === op.name);
26
+ if (idx >= 0) {
27
+ space.schema.variables[idx] = variable;
28
+ return {
29
+ ...empty(),
30
+ updated: 1,
31
+ staleResources: [schemaVarsUri(env)]
32
+ };
33
+ }
34
+ space.schema.variables.push(variable);
35
+ return {
36
+ ...empty(),
37
+ created: 1,
38
+ staleResources: [schemaVarsUri(env)]
39
+ };
40
+ };
41
+ //#endregion
42
+ export { upsertVariable, upsertVariableOp };
@@ -0,0 +1,42 @@
1
+ import { ElementInput, InitialStateInput } from './shared';
2
+ import { OpResult, Space } from '../../../helpers';
3
+ import { Env } from '../../../types';
4
+ import { Element } from '@plitzi/sdk-shared';
5
+ export declare const ID_REF_HINT: string;
6
+ /** Every ref in an element input tree (the element plus its nested children) — each becomes a new element's idRef. */
7
+ export declare const collectInputRefs: (input: ElementInput) => string[];
8
+ /** Validate a ref that is about to become an element's idRef: the charset, then whether anything already answers
9
+ * to it. The charset rule is sdk-schema's `isValidIdRef` — never a regex restated here, so the MCP cannot drift
10
+ * from what the builder and the schema validator enforce.
11
+ *
12
+ * Uniqueness is checked with the ref lookups rather than `FlatMap.idRefConflict`, and deliberately so: these are
13
+ * a superset of it. FlatMap asks whether another element holds this idRef; the MCP must also refuse a ref that
14
+ * shadows a raw id or a page slug, because its handlers resolve refs through those too — calling both would just
15
+ * run the same rule twice. Null when the ref is usable.
16
+ *
17
+ * Enforced here, at every point a ref BECOMES an idRef — addressing an existing element by its raw id is not
18
+ * charset-checked, which is why the validator cannot simply tighten its own REF_RE for every ref it sees. */
19
+ export declare const guardNewRef: (space: Space, ref: string, field: string) => OpResult | null;
20
+ export { folderUri, foldersUri, pageUri, pagesUri, schemaVarsUri, settingsUri } from '../../../helpers';
21
+ export declare const removeFromParent: (space: Space, child: Element) => void;
22
+ export declare const placeChild: (parent: Element, childId: string, index?: number) => void;
23
+ export declare const writeInitialState: (el: Element, input: InitialStateInput, merge: boolean) => void;
24
+ export declare const createElement: (space: Space, page: Element, input: ElementInput, parent: Element, index: number | undefined) => void;
25
+ /** The idRef an element is wired by, minting one when it has none. Interactions are keyed by idRef, so an element
26
+ * that is about to host or be targeted by a flow must have one — rather than make the agent assign it with a
27
+ * separate patchElement, the MCP gives it a free `<type>-<n>` ref (unique across the space) and proceeds. An
28
+ * element that already has an idRef keeps it. Mutates the element in place and returns the ref. */
29
+ export declare const ensureIdRef: (space: Space, el: Element) => string;
30
+ /** The key an interaction node must store to reach a target element. Every ref field also accepts a raw id, so a
31
+ * target given as an id is resolved to the element's idRef — the key the runtime registers callbacks under. A
32
+ * target that has no idRef is given one (see `ensureIdRef`), since it must be reachable to be wired to. A target
33
+ * that resolves to no element is left as written — it is already a ref, or a key only a plugin knows. */
34
+ export declare const resolveTargetRef: (space: Space, elementId: string) => string;
35
+ /** Resolve a non-page element within a page for the element-scoped ops (bindings, interactions). Returns the
36
+ * element, or a teachable OpResult when the page or element ref does not resolve — so each op reports the same
37
+ * errors as patchElement without repeating them. */
38
+ export declare const resolveElement: (space: Space, env: Env, pageRef: string, ref: string) => {
39
+ el: Element;
40
+ } | {
41
+ error: OpResult;
42
+ };
@@ -0,0 +1,112 @@
1
+ import { findElementByRef, findPageByRef, generateObjectId, indexAddElement, indexReRefElement, resolveRef, spaceIndex } from "../../../helpers/space.js";
2
+ import { folderUri, foldersUri, pageUri, pagesUri, schemaVarsUri, settingsUri } from "../../../helpers/uris.js";
3
+ import { fail } from "../../../helpers/opResult.js";
4
+ import { isValidIdRef, makeIdRef } from "@plitzi/sdk-schema/helpers/idRef";
5
+ //#region src/modules/mcp/tools/operations/schema/write.ts
6
+ var ID_REF_HINT = "Start with a letter, then letters, numbers, hyphens and underscores (e.g. \"hero-cta\" or \"food_item\"). The ref becomes the element idRef, which the runtime embeds in source names like `apiContainer_<idRef>.field` and in interaction targets — a dot would split those paths (an underscore is fine: the FIRST `_` separates the type from the idRef, and element types carry none, so extra underscores are unambiguous).";
7
+ var TAKEN_HINT = "An idRef must be unique across the space — pick a different ref, or address the existing element by this ref.";
8
+ /** Every ref in an element input tree (the element plus its nested children) — each becomes a new element's idRef. */
9
+ var collectInputRefs = (input) => [input.ref, ...(input.children ?? []).flatMap(collectInputRefs)];
10
+ /** Validate a ref that is about to become an element's idRef: the charset, then whether anything already answers
11
+ * to it. The charset rule is sdk-schema's `isValidIdRef` — never a regex restated here, so the MCP cannot drift
12
+ * from what the builder and the schema validator enforce.
13
+ *
14
+ * Uniqueness is checked with the ref lookups rather than `FlatMap.idRefConflict`, and deliberately so: these are
15
+ * a superset of it. FlatMap asks whether another element holds this idRef; the MCP must also refuse a ref that
16
+ * shadows a raw id or a page slug, because its handlers resolve refs through those too — calling both would just
17
+ * run the same rule twice. Null when the ref is usable.
18
+ *
19
+ * Enforced here, at every point a ref BECOMES an idRef — addressing an existing element by its raw id is not
20
+ * charset-checked, which is why the validator cannot simply tighten its own REF_RE for every ref it sees. */
21
+ var guardNewRef = (space, ref, field) => {
22
+ if (!isValidIdRef(ref)) return fail(field, `"${ref}" is not a valid idRef`, ID_REF_HINT);
23
+ if (findElementByRef(space.schema, ref) || findPageByRef(space.schema, ref)) return fail(field, `"${ref}" is already used by another element in this space`, TAKEN_HINT);
24
+ return null;
25
+ };
26
+ var removeFromParent = (space, child) => {
27
+ const parent = child.definition.parentId ? space.schema.flat[child.definition.parentId] : void 0;
28
+ if (parent?.definition.items) parent.definition.items = parent.definition.items.filter((id) => id !== child.id);
29
+ };
30
+ var placeChild = (parent, childId, index) => {
31
+ const items = parent.definition.items ?? (parent.definition.items = []);
32
+ if (index === void 0 || index < 0 || index >= items.length) items.push(childId);
33
+ else items.splice(index, 0, childId);
34
+ };
35
+ var writeInitialState = (el, input, merge) => {
36
+ const current = el.definition.initialState ?? {};
37
+ const next = { ...current };
38
+ if (input.styleVariant !== void 0) {
39
+ if (merge) {
40
+ const merged = { ...current.styleVariant };
41
+ for (const [cls, selectors] of Object.entries(input.styleVariant)) merged[cls] = {
42
+ ...merged[cls],
43
+ ...selectors
44
+ };
45
+ next.styleVariant = merged;
46
+ } else next.styleVariant = input.styleVariant;
47
+ }
48
+ if (input.visibility !== void 0) next.visibility = input.visibility;
49
+ el.definition.initialState = next;
50
+ };
51
+ var createElement = (space, page, input, parent, index) => {
52
+ const id = generateObjectId();
53
+ const { subType, ...props } = {
54
+ subType: input.subType,
55
+ ...input.props
56
+ };
57
+ const styleSelectors = { base: (input.style?.base ?? []).join(" ") };
58
+ for (const [slot, classes] of Object.entries(input.style?.slots ?? {})) styleSelectors[slot] = classes.join(" ");
59
+ const el = {
60
+ id,
61
+ idRef: input.ref,
62
+ attributes: subType === void 0 ? props : {
63
+ subType,
64
+ ...props
65
+ },
66
+ definition: {
67
+ rootId: page.id,
68
+ parentId: parent.id,
69
+ label: input.label ?? input.ref,
70
+ type: input.type,
71
+ items: [],
72
+ styleSelectors,
73
+ ...input.runtime === void 0 ? {} : { runtime: input.runtime }
74
+ }
75
+ };
76
+ space.schema.flat[id] = el;
77
+ placeChild(parent, id, index);
78
+ indexAddElement(space.schema, el, page.id);
79
+ if (input.initialState) writeInitialState(el, input.initialState, false);
80
+ for (const child of input.children ?? []) createElement(space, page, child, el, void 0);
81
+ };
82
+ /** The idRef an element is wired by, minting one when it has none. Interactions are keyed by idRef, so an element
83
+ * that is about to host or be targeted by a flow must have one — rather than make the agent assign it with a
84
+ * separate patchElement, the MCP gives it a free `<type>-<n>` ref (unique across the space) and proceeds. An
85
+ * element that already has an idRef keeps it. Mutates the element in place and returns the ref. */
86
+ var ensureIdRef = (space, el) => {
87
+ if (el.idRef) return el.idRef;
88
+ const index = spaceIndex(space.schema);
89
+ el.idRef = makeIdRef(el.definition.type, (candidate) => index.elementByRef.has(candidate) || index.pageByRef.has(candidate));
90
+ indexReRefElement(space.schema, el);
91
+ return el.idRef;
92
+ };
93
+ /** The key an interaction node must store to reach a target element. Every ref field also accepts a raw id, so a
94
+ * target given as an id is resolved to the element's idRef — the key the runtime registers callbacks under. A
95
+ * target that has no idRef is given one (see `ensureIdRef`), since it must be reachable to be wired to. A target
96
+ * that resolves to no element is left as written — it is already a ref, or a key only a plugin knows. */
97
+ var resolveTargetRef = (space, elementId) => {
98
+ const el = space.schema.flat[elementId] ?? findElementByRef(space.schema, elementId);
99
+ return el ? ensureIdRef(space, el) : elementId;
100
+ };
101
+ /** Resolve a non-page element within a page for the element-scoped ops (bindings, interactions). Returns the
102
+ * element, or a teachable OpResult when the page or element ref does not resolve — so each op reports the same
103
+ * errors as patchElement without repeating them. */
104
+ var resolveElement = (space, env, pageRef, ref) => {
105
+ const page = findPageByRef(space.schema, pageRef);
106
+ if (!page) return { error: fail("pageRef", `Page "${pageRef}" not found`, `Read plitzi://schema/${env}/pages for valid refs`) };
107
+ const el = resolveRef(space.schema, page, ref);
108
+ if (!el || el.id === page.id) return { error: fail("ref", `Element "${ref}" not found in page "${pageRef}"`, "Use an existing element ref or id") };
109
+ return { el };
110
+ };
111
+ //#endregion
112
+ export { ID_REF_HINT, collectInputRefs, createElement, ensureIdRef, folderUri, foldersUri, guardNewRef, pageUri, pagesUri, placeChild, removeFromParent, resolveElement, resolveTargetRef, schemaVarsUri, settingsUri, writeInitialState };
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+ export declare const claimSchemaId: (schema: z.ZodType, id: string) => void;
3
+ /** Idempotent: the module can be imported more than once in a test run, and a schema that already carries its id
4
+ * is left alone (re-adding the same one is harmless but pointless). Runs at module load, never per request — the
5
+ * MCP builds a server per request and this must not grow with them (pinned in the statelessness test). */
6
+ export declare const registerSharedSchemaIds: () => void;
@@ -0,0 +1,58 @@
1
+ import { connectorConnection, readEndpoint, writeEndpoint } from "./connectors/manifest.js";
2
+ import { bindingInput, elementInput, initialStateInput, interactionNode, position, ruleGroup, styleRefs, styleVariantInput } from "./schema/shared.js";
3
+ import { cssMap, cssPatchMap, definitionSlot, definitionSlotPatch, displayModeCss, displayModeCssPatch, themeValue } from "./style/shared.js";
4
+ import { z } from "zod";
5
+ //#region src/modules/mcp/tools/operations/schemaIds.ts
6
+ /** The op union is the tool input of plitzi_apply, plitzi_validate, plitzi_render AND plitzi_preview, and every
7
+ * host reads it as JSON Schema on tools/list — four copies of the same 30 operations in the model's context, on
8
+ * EVERY request of every conversation the server is connected to. It measured ~25k tokens PER TOOL (~100k in
9
+ * total), which dwarfs anything a widget payload ever costs.
10
+ *
11
+ * Most of that weight is one subschema pasted over and over: an element tree appears in upsertElement,
12
+ * patchElement and both repeat templates; a breakpoint CSS block in every style op; a rule group in every binding
13
+ * and interaction step. Zod emits a named `definitions` entry (and `$ref`s to it) for any schema carrying an `id`
14
+ * in the global registry, so registering the shared ones here collapses those copies — without touching the ops,
15
+ * the tools, or the MCP SDK, whose own converter honours the registry (it is given no options otherwise).
16
+ *
17
+ * An id only pays when the schema is REUSED: giving one to a subschema that appears once makes the listing bigger,
18
+ * because the `definitions` entry and the ref cost more than the single copy they replace (measured, and reverted).
19
+ *
20
+ * The ids are the names the MODEL reads in the refs, so they are written for it: `Element`, not `ElementInput`.
21
+ * This runs once, at module load of the op vocabulary, so every conversion path benefits — the MCP tools list and
22
+ * the co-worker's own tool-schema converter alike. */
23
+ var SHARED_SCHEMAS = [
24
+ [elementInput, "Element"],
25
+ [ruleGroup, "RuleGroup"],
26
+ [styleRefs, "StyleRefs"],
27
+ [initialStateInput, "InitialState"],
28
+ [styleVariantInput, "StyleVariant"],
29
+ [interactionNode, "InteractionNode"],
30
+ [bindingInput, "Binding"],
31
+ [position, "Position"],
32
+ [cssMap, "Css"],
33
+ [cssPatchMap, "CssPatch"],
34
+ [definitionSlot, "StyleSlot"],
35
+ [definitionSlotPatch, "StyleSlotPatch"],
36
+ [displayModeCss, "BreakpointCss"],
37
+ [displayModeCssPatch, "BreakpointCssPatch"],
38
+ [themeValue, "ThemeValue"],
39
+ [readEndpoint, "ConnectorRead"],
40
+ [writeEndpoint, "ConnectorWrite"],
41
+ [connectorConnection, "ConnectorConnection"]
42
+ ];
43
+ var claimSchemaId = (schema, id) => {
44
+ const taken = z.globalRegistry._idmap.get(id);
45
+ if (taken !== void 0 && taken !== schema) {
46
+ z.globalRegistry.add(schema, { id: `Plitzi${id}` });
47
+ return;
48
+ }
49
+ z.globalRegistry.add(schema, { id });
50
+ };
51
+ /** Idempotent: the module can be imported more than once in a test run, and a schema that already carries its id
52
+ * is left alone (re-adding the same one is harmless but pointless). Runs at module load, never per request — the
53
+ * MCP builds a server per request and this must not grow with them (pinned in the statelessness test). */
54
+ var registerSharedSchemaIds = () => {
55
+ for (const [schema, id] of SHARED_SCHEMAS) if (z.globalRegistry.get(schema)?.id === void 0) claimSchemaId(schema, id);
56
+ };
57
+ //#endregion
58
+ export { claimSchemaId, registerSharedSchemaIds };
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ import { Space, OpResult } from '../../../../helpers';
3
+ import { Env } from '../../../../types';
4
+ export declare const deleteDefinitionOp: z.ZodObject<{
5
+ type: z.ZodLiteral<"deleteDefinition">;
6
+ ref: z.ZodString;
7
+ }, z.core.$strip>;
8
+ export type DeleteDefinition = z.infer<typeof deleteDefinitionOp>;
9
+ export declare const deleteDefinition: (space: Space, env: Env, op: DeleteDefinition) => OpResult;
@@ -0,0 +1,21 @@
1
+ import { defUri, defsUri } from "../../../../helpers/uris.js";
2
+ import { empty } from "../../../../helpers/opResult.js";
3
+ import { MODES, guardKind } from "../write.js";
4
+ import { z } from "zod";
5
+ //#region src/modules/mcp/tools/operations/style/definitions/deleteDefinition.ts
6
+ var deleteDefinitionOp = z.object({
7
+ type: z.literal("deleteDefinition"),
8
+ ref: z.string().describe("Class ref of the definition to delete")
9
+ }).describe("Delete a style class definition by ref (does not detach it from elements that still list it).");
10
+ var deleteDefinition = (space, env, op) => {
11
+ const guard = guardKind(space.style, op.ref, "class");
12
+ if (guard) return guard;
13
+ for (const mode of MODES) Reflect.deleteProperty(space.style.platform[mode], op.ref);
14
+ return {
15
+ ...empty(),
16
+ deleted: 1,
17
+ staleResources: [defUri(env, op.ref), defsUri(env)]
18
+ };
19
+ };
20
+ //#endregion
21
+ export { deleteDefinition, deleteDefinitionOp };
@@ -0,0 +1,37 @@
1
+ import { z } from 'zod';
2
+ import { Space, OpResult } from '../../../../helpers';
3
+ import { Env } from '../../../../types';
4
+ export declare const patchDefinitionOp: z.ZodObject<{
5
+ desktop: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
6
+ tablet: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
7
+ mobile: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
8
+ states: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
9
+ desktop: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
10
+ tablet: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
11
+ mobile: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
12
+ }, z.core.$strip>>>;
13
+ variants: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
14
+ desktop: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
15
+ tablet: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
16
+ mobile: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
17
+ }, z.core.$strip>>>;
18
+ slots: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
19
+ desktop: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
20
+ tablet: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
21
+ mobile: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
22
+ states: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
23
+ desktop: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
24
+ tablet: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
25
+ mobile: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
26
+ }, z.core.$strip>>>;
27
+ variants: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
28
+ desktop: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
29
+ tablet: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
30
+ mobile: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>>;
31
+ }, z.core.$strip>>>;
32
+ }, z.core.$strip>>>;
33
+ type: z.ZodLiteral<"patchDefinition">;
34
+ ref: z.ZodString;
35
+ }, z.core.$strip>;
36
+ export type PatchDefinition = z.infer<typeof patchDefinitionOp>;
37
+ export declare const patchDefinition: (space: Space, env: Env, op: PatchDefinition) => OpResult;
@@ -0,0 +1,28 @@
1
+ import { defUri, defsUri } from "../../../../helpers/uris.js";
2
+ import { empty, fail } from "../../../../helpers/opResult.js";
3
+ import { definitionToAI } from "../translator.js";
4
+ import { patchCssShape } from "../shared.js";
5
+ import { guardKind, mergePatch, writeStyleItem } from "../write.js";
6
+ import { z } from "zod";
7
+ //#region src/modules/mcp/tools/operations/style/definitions/patchDefinition.ts
8
+ var patchDefinitionOp = z.object({
9
+ type: z.literal("patchDefinition"),
10
+ ref: z.string().describe("Existing class ref to patch"),
11
+ ...patchCssShape
12
+ }).describe("Partially update an existing style class: the CSS you pass is merged (a null value removes that property, others are kept). Never creates — use upsertDefinition for that.");
13
+ var patchDefinition = (space, env, op) => {
14
+ const guard = guardKind(space.style, op.ref, "class");
15
+ if (guard) return guard;
16
+ const existing = definitionToAI(space.style, op.ref);
17
+ if (!existing) return fail("ref", `Definition "${op.ref}" not found`, "patchDefinition only updates an existing definition; use upsertDefinition to create one");
18
+ const { type, ref, slots: slotsPatch, ...basePatch } = op;
19
+ const { base, slots } = mergePatch(existing, basePatch, slotsPatch);
20
+ writeStyleItem(space.style, ref, base, slots, "class", void 0);
21
+ return {
22
+ ...empty(),
23
+ updated: 1,
24
+ staleResources: [defUri(env, ref), defsUri(env)]
25
+ };
26
+ };
27
+ //#endregion
28
+ export { patchDefinition, patchDefinitionOp };