@plitzi/sdk-server 0.32.24 → 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 (512) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +326 -162
  3. package/dist/adapters/authAdapters.d.ts +21 -0
  4. package/dist/adapters/authAdapters.js +12 -0
  5. package/dist/adapters/jsonAdapters.d.ts +15 -0
  6. package/dist/adapters/jsonAdapters.js +9 -4
  7. package/dist/core/auth/api.d.ts +148 -0
  8. package/dist/core/auth/api.js +286 -0
  9. package/dist/core/auth/authorize.d.ts +96 -0
  10. package/dist/core/auth/authorize.js +92 -0
  11. package/dist/core/auth/createAuth.d.ts +165 -0
  12. package/dist/core/auth/createAuth.js +105 -0
  13. package/dist/core/auth/credentials.d.ts +29 -0
  14. package/dist/core/auth/credentials.js +48 -0
  15. package/dist/core/auth/domains.d.ts +41 -0
  16. package/dist/core/auth/domains.js +78 -0
  17. package/dist/core/auth/identity.d.ts +108 -0
  18. package/dist/core/auth/identity.js +164 -0
  19. package/dist/core/auth/oauth/client.d.ts +5 -0
  20. package/dist/core/auth/oauth/client.js +47 -0
  21. package/dist/core/auth/oauth/index.d.ts +78 -0
  22. package/dist/core/auth/oauth/index.js +113 -0
  23. package/dist/core/auth/oauth/providers/github.d.ts +2 -0
  24. package/dist/core/auth/oauth/providers/github.js +48 -0
  25. package/dist/core/auth/oauth/providers/google.d.ts +2 -0
  26. package/dist/core/auth/oauth/providers/google.js +30 -0
  27. package/dist/core/auth/oauth/state.d.ts +23 -0
  28. package/dist/core/auth/oauth/state.js +55 -0
  29. package/dist/core/auth/oauth/types.d.ts +51 -0
  30. package/dist/core/auth/oauth/types.js +13 -0
  31. package/dist/core/auth/routes.d.ts +50 -0
  32. package/dist/core/auth/routes.js +129 -0
  33. package/dist/core/auth/session.d.ts +128 -0
  34. package/dist/core/auth/session.js +165 -0
  35. package/dist/core/auth/spaceTokens.d.ts +137 -0
  36. package/dist/core/auth/spaceTokens.js +212 -0
  37. package/dist/core/auth/tokens.d.ts +151 -0
  38. package/dist/core/auth/tokens.js +221 -0
  39. package/dist/core/createServer.d.ts +29 -0
  40. package/dist/core/createServer.js +28 -14
  41. package/dist/core/handlers/authMiddleware.d.ts +27 -0
  42. package/dist/core/handlers/authMiddleware.js +38 -0
  43. package/dist/core/handlers/authRouteHandlers.d.ts +46 -0
  44. package/dist/core/handlers/authRouteHandlers.js +75 -0
  45. package/dist/core/handlers/types.d.ts +37 -0
  46. package/dist/{src/core → core}/http/dispatcher.d.ts +2 -2
  47. package/dist/core/http/dispatcher.js +8 -6
  48. package/dist/core/http/navigation.d.ts +11 -0
  49. package/dist/core/http/navigation.js +16 -0
  50. package/dist/core/http/securityHeaders.js +6 -4
  51. package/dist/core/http/stages/authApi.d.ts +17 -0
  52. package/dist/core/http/stages/authApi.js +66 -0
  53. package/dist/core/http/stages/authRoutes.js +40 -11
  54. package/dist/core/http/stages/exchangeRoute.d.ts +15 -0
  55. package/dist/core/http/stages/exchangeRoute.js +67 -0
  56. package/dist/core/http/stages/health.d.ts +11 -0
  57. package/dist/core/http/stages/health.js +25 -3
  58. package/dist/core/http/stages/middlewares.d.ts +2 -0
  59. package/dist/core/http/stages/static.d.ts +13 -0
  60. package/dist/core/http/stages/static.js +21 -6
  61. package/dist/core/http/types.d.ts +35 -0
  62. package/dist/{modules/mcp/constants.js → core/previewToken.js} +1 -1
  63. package/dist/core/sdkAssets.d.ts +16 -0
  64. package/dist/core/sdkAssets.js +46 -0
  65. package/dist/core/server/baseServer.js +40 -5
  66. package/dist/core/server/pageServer.d.ts +7 -0
  67. package/dist/core/server/pageServer.js +13 -17
  68. package/dist/core/services/action.d.ts +9 -0
  69. package/dist/core/services/action.js +21 -0
  70. package/dist/core/services/registry.d.ts +3 -0
  71. package/dist/core/services/registry.js +9 -19
  72. package/dist/{src/core → core}/services/resolve.d.ts +1 -0
  73. package/dist/core/services/resolve.js +6 -4
  74. package/dist/core/services/rsc.js +3 -2
  75. package/dist/core/staticFiles.js +1 -1
  76. package/dist/{src/core → core}/transports.d.ts +3 -0
  77. package/dist/core/transports.js +7 -6
  78. package/dist/handlers.d.ts +58 -0
  79. package/dist/handlers.js +3 -0
  80. package/dist/{src/helpers → helpers}/buildResponseHelpers.d.ts +2 -1
  81. package/dist/helpers/buildResponseHelpers.js +13 -4
  82. package/dist/helpers/buildServerInfo.d.ts +3 -0
  83. package/dist/helpers/buildServerInfo.js +25 -3
  84. package/dist/{src/helpers → helpers}/cache/keys.d.ts +5 -1
  85. package/dist/helpers/cache/keys.js +1 -1
  86. package/dist/helpers/compress.d.ts +18 -0
  87. package/dist/helpers/compress.js +47 -11
  88. package/dist/helpers/offlineDataLoader.d.ts +11 -0
  89. package/dist/helpers/offlineDataLoader.js +15 -0
  90. package/dist/helpers/resolveDebugMode.d.ts +10 -0
  91. package/dist/helpers/resolveDebugMode.js +13 -0
  92. package/dist/index.d.ts +16 -2
  93. package/dist/index.js +9 -20
  94. package/dist/kernel.d.ts +41 -0
  95. package/dist/kernel.js +22 -0
  96. package/dist/middlewares/spaceDeployment.d.ts +2 -0
  97. package/dist/middlewares/spaceDeployment.js +2 -1
  98. package/dist/modules/actions/handler.d.ts +11 -0
  99. package/dist/modules/actions/handler.js +77 -0
  100. package/dist/modules/connectors/engine.d.ts +42 -0
  101. package/dist/modules/connectors/engine.js +221 -0
  102. package/dist/modules/connectors/getByPath.d.ts +8 -0
  103. package/dist/modules/connectors/getByPath.js +21 -0
  104. package/dist/modules/connectors/index.d.ts +7 -0
  105. package/dist/modules/connectors/projection.d.ts +18 -0
  106. package/dist/modules/connectors/projection.js +108 -0
  107. package/dist/modules/connectors/resolver.d.ts +18 -0
  108. package/dist/modules/connectors/resolver.js +68 -0
  109. package/dist/modules/connectors/types.d.ts +19 -0
  110. package/dist/{src/modules → modules}/rsc/handler.d.ts +2 -2
  111. package/dist/modules/rsc/handler.js +54 -2
  112. package/dist/modules/rsc/resolveRscData.d.ts +35 -0
  113. package/dist/modules/rsc/resolveRscData.js +74 -0
  114. package/dist/{src/modules → modules}/ssr/Component.d.ts +4 -1
  115. package/dist/modules/ssr/Component.js +10 -3
  116. package/dist/modules/ssr/buildBody.d.ts +9 -0
  117. package/dist/modules/ssr/handler.d.ts +4 -0
  118. package/dist/modules/ssr/handler.js +18 -1
  119. package/dist/{src/modules → modules}/ssr/loadPluginComponents.d.ts +5 -2
  120. package/dist/modules/ssr/loadPluginComponents.js +20 -2
  121. package/dist/{src/modules → modules}/ssr/prepareRender.d.ts +2 -2
  122. package/dist/modules/ssr/prepareRender.js +24 -7
  123. package/dist/modules/ssr/preview.d.ts +10 -0
  124. package/dist/modules/ssr/preview.js +5 -78
  125. package/dist/modules/ssr/registerExternalPlugins.js +1 -1
  126. package/dist/modules/ssr/streamBody.d.ts +5 -0
  127. package/dist/modules/ssr/streamBody.js +1 -1
  128. package/dist/modules/ssr/template.d.ts +2 -0
  129. package/dist/modules/ssr/template.js +1 -1
  130. package/dist/plugins/compile.js +1 -1
  131. package/dist/plugins/manager.js +12 -8
  132. package/dist/ssr.d.ts +15 -0
  133. package/dist/ssr.js +4 -0
  134. package/package.json +29 -25
  135. package/dist/.gitkeep +0 -0
  136. package/dist/core/server/mcpServer.js +0 -29
  137. package/dist/core/services/mcp.js +0 -27
  138. package/dist/core/services/oauth.js +0 -116
  139. package/dist/core/services/preview.js +0 -37
  140. package/dist/core/services/proxy.js +0 -12
  141. package/dist/mcp.d.ts +0 -2
  142. package/dist/mcp.js +0 -7
  143. package/dist/modules/ai/AIEngine.js +0 -120
  144. package/dist/modules/ai/toolkit.js +0 -59
  145. package/dist/modules/mcp/apps/example/view/index.tsx +0 -70
  146. package/dist/modules/mcp/apps/index.js +0 -16
  147. package/dist/modules/mcp/apps/render/index.js +0 -17
  148. package/dist/modules/mcp/apps/render/styles.js +0 -54
  149. package/dist/modules/mcp/apps/render/view/heldBatch.ts +0 -107
  150. package/dist/modules/mcp/apps/render/view/index.tsx +0 -314
  151. package/dist/modules/mcp/apps/render/view/streamProgress.ts +0 -137
  152. package/dist/modules/mcp/apps/shared/assets.js +0 -10
  153. package/dist/modules/mcp/apps/shared/bundle.js +0 -23
  154. package/dist/modules/mcp/apps/shared/page.js +0 -34
  155. package/dist/modules/mcp/apps/shared/registerApp.js +0 -43
  156. package/dist/modules/mcp/apps/shared/resolve.js +0 -5
  157. package/dist/modules/mcp/apps/shared/shell.ejs +0 -59
  158. package/dist/modules/mcp/apps/shared/zodEnglishOnly.js +0 -23
  159. package/dist/modules/mcp/catalogs/builtinCallbacks.js +0 -204
  160. package/dist/modules/mcp/catalogs/builtinComponents.js +0 -170
  161. package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +0 -50
  162. package/dist/modules/mcp/catalogs/builtinTransformers.js +0 -148
  163. package/dist/modules/mcp/catalogs/builtinUtilities.js +0 -90
  164. package/dist/modules/mcp/catalogs/cssCatalog/border.js +0 -30
  165. package/dist/modules/mcp/catalogs/cssCatalog/box.js +0 -31
  166. package/dist/modules/mcp/catalogs/cssCatalog/helpers.js +0 -185
  167. package/dist/modules/mcp/catalogs/cssCatalog/index.js +0 -131
  168. package/dist/modules/mcp/catalogs/cssCatalog/layout.js +0 -98
  169. package/dist/modules/mcp/catalogs/cssCatalog/visual.js +0 -144
  170. package/dist/modules/mcp/catalogs/observed.js +0 -90
  171. package/dist/modules/mcp/catalogs/paramSpec.js +0 -69
  172. package/dist/modules/mcp/catalogs/registry.js +0 -89
  173. package/dist/modules/mcp/handler.js +0 -83
  174. package/dist/modules/mcp/helpers/agentPrompt.js +0 -104
  175. package/dist/modules/mcp/helpers/computeVersion.js +0 -16
  176. package/dist/modules/mcp/helpers/guide.js +0 -467
  177. package/dist/modules/mcp/helpers/interactions.js +0 -123
  178. package/dist/modules/mcp/helpers/log.js +0 -64
  179. package/dist/modules/mcp/helpers/opResult.js +0 -18
  180. package/dist/modules/mcp/helpers/space.js +0 -300
  181. package/dist/modules/mcp/helpers/uris.js +0 -44
  182. package/dist/modules/mcp/previewClient.js +0 -31
  183. package/dist/modules/mcp/proxy/config.js +0 -46
  184. package/dist/modules/mcp/proxy/fetch.js +0 -91
  185. package/dist/modules/mcp/proxy/grant.js +0 -65
  186. package/dist/modules/mcp/proxy/guard.js +0 -38
  187. package/dist/modules/mcp/proxy/handler.js +0 -68
  188. package/dist/modules/mcp/proxy/rewrite.js +0 -72
  189. package/dist/modules/mcp/proxy/sign.js +0 -15
  190. package/dist/modules/mcp/proxy/types.js +0 -9
  191. package/dist/modules/mcp/resources/canonical.js +0 -30
  192. package/dist/modules/mcp/resources/core.js +0 -18
  193. package/dist/modules/mcp/resources/envelope.js +0 -14
  194. package/dist/modules/mcp/resources/primer.js +0 -31
  195. package/dist/modules/mcp/resources/register.js +0 -190
  196. package/dist/modules/mcp/resources/renderGuide.js +0 -451
  197. package/dist/modules/mcp/resources/router.js +0 -37
  198. package/dist/modules/mcp/resources/schema.js +0 -43
  199. package/dist/modules/mcp/resources/style.js +0 -34
  200. package/dist/modules/mcp/screenshotClient.js +0 -47
  201. package/dist/modules/mcp/server.js +0 -113
  202. package/dist/modules/mcp/tools/apply/dispatch.js +0 -105
  203. package/dist/modules/mcp/tools/apply/index.js +0 -150
  204. package/dist/modules/mcp/tools/apply/writeResult.js +0 -37
  205. package/dist/modules/mcp/tools/index.js +0 -24
  206. package/dist/modules/mcp/tools/operations/index.js +0 -45
  207. package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +0 -32
  208. package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +0 -36
  209. package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +0 -47
  210. package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +0 -29
  211. package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +0 -41
  212. package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +0 -58
  213. package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +0 -148
  214. package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +0 -65
  215. package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +0 -30
  216. package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +0 -49
  217. package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +0 -52
  218. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +0 -47
  219. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +0 -44
  220. package/dist/modules/mcp/tools/operations/schema/operations.js +0 -41
  221. package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +0 -25
  222. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +0 -75
  223. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +0 -45
  224. package/dist/modules/mcp/tools/operations/schema/shared.js +0 -122
  225. package/dist/modules/mcp/tools/operations/schema/translator.js +0 -215
  226. package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +0 -18
  227. package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +0 -42
  228. package/dist/modules/mcp/tools/operations/schema/write.js +0 -109
  229. package/dist/modules/mcp/tools/operations/schemaIds.js +0 -54
  230. package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +0 -21
  231. package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +0 -28
  232. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +0 -24
  233. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +0 -40
  234. package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +0 -21
  235. package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +0 -28
  236. package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +0 -24
  237. package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +0 -21
  238. package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +0 -28
  239. package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +0 -24
  240. package/dist/modules/mcp/tools/operations/style/operations.js +0 -29
  241. package/dist/modules/mcp/tools/operations/style/shared.js +0 -59
  242. package/dist/modules/mcp/tools/operations/style/translator.js +0 -101
  243. package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +0 -21
  244. package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +0 -22
  245. package/dist/modules/mcp/tools/operations/style/write.js +0 -108
  246. package/dist/modules/mcp/tools/preview.js +0 -37
  247. package/dist/modules/mcp/tools/read.js +0 -51
  248. package/dist/modules/mcp/tools/render.js +0 -184
  249. package/dist/modules/mcp/tools/screenshot.js +0 -83
  250. package/dist/modules/mcp/tools/search.js +0 -115
  251. package/dist/modules/mcp/tools/shared/expandOperations.js +0 -44
  252. package/dist/modules/mcp/tools/shared/tool.js +0 -33
  253. package/dist/modules/mcp/tools/shared/validator/audit.js +0 -124
  254. package/dist/modules/mcp/tools/shared/validator/batch.js +0 -39
  255. package/dist/modules/mcp/tools/shared/validator/bindings.js +0 -70
  256. package/dist/modules/mcp/tools/shared/validator/context.js +0 -35
  257. package/dist/modules/mcp/tools/shared/validator/css.js +0 -39
  258. package/dist/modules/mcp/tools/shared/validator/elements.js +0 -68
  259. package/dist/modules/mcp/tools/shared/validator/index.js +0 -246
  260. package/dist/modules/mcp/tools/shared/validator/interactions.js +0 -103
  261. package/dist/modules/mcp/tools/shared/validator/refs.js +0 -28
  262. package/dist/modules/mcp/tools/validate.js +0 -47
  263. package/dist/modules/oauth/authorize.js +0 -177
  264. package/dist/modules/oauth/challenge.js +0 -33
  265. package/dist/modules/oauth/consentPage.js +0 -118
  266. package/dist/modules/oauth/metadata.js +0 -69
  267. package/dist/modules/oauth/params.js +0 -5
  268. package/dist/modules/oauth/pkce.js +0 -15
  269. package/dist/modules/oauth/records.js +0 -46
  270. package/dist/modules/oauth/register.js +0 -55
  271. package/dist/modules/oauth/respond.js +0 -44
  272. package/dist/modules/oauth/token.js +0 -100
  273. package/dist/public/.gitkeep +0 -0
  274. package/dist/src/adapters/jsonAdapters.d.ts +0 -7
  275. package/dist/src/core/createServer.d.ts +0 -14
  276. package/dist/src/core/http/stages/health.d.ts +0 -2
  277. package/dist/src/core/http/stages/middlewares.d.ts +0 -2
  278. package/dist/src/core/http/stages/static.d.ts +0 -5
  279. package/dist/src/core/http/types.d.ts +0 -22
  280. package/dist/src/core/server/mcpServer.d.ts +0 -2
  281. package/dist/src/core/server/pageServer.d.ts +0 -10
  282. package/dist/src/core/services/mcp.d.ts +0 -3
  283. package/dist/src/core/services/oauth.d.ts +0 -18
  284. package/dist/src/core/services/preview.d.ts +0 -2
  285. package/dist/src/core/services/proxy.d.ts +0 -2
  286. package/dist/src/core/services/registry.d.ts +0 -4
  287. package/dist/src/helpers/buildServerInfo.d.ts +0 -2
  288. package/dist/src/helpers/compress.d.ts +0 -3
  289. package/dist/src/index.d.ts +0 -15
  290. package/dist/src/mcp.d.ts +0 -14
  291. package/dist/src/middlewares/spaceDeployment.d.ts +0 -2
  292. package/dist/src/modules/ai/AIEngine.d.ts +0 -20
  293. package/dist/src/modules/ai/index.d.ts +0 -4
  294. package/dist/src/modules/ai/toolkit.d.ts +0 -17
  295. package/dist/src/modules/mcp/apps/example/index.d.ts +0 -8
  296. package/dist/src/modules/mcp/apps/index.d.ts +0 -11
  297. package/dist/src/modules/mcp/apps/render/index.d.ts +0 -4
  298. package/dist/src/modules/mcp/apps/render/styles.d.ts +0 -10
  299. package/dist/src/modules/mcp/apps/shared/assets.d.ts +0 -10
  300. package/dist/src/modules/mcp/apps/shared/bundle.d.ts +0 -4
  301. package/dist/src/modules/mcp/apps/shared/index.d.ts +0 -3
  302. package/dist/src/modules/mcp/apps/shared/page.d.ts +0 -2
  303. package/dist/src/modules/mcp/apps/shared/registerApp.d.ts +0 -5
  304. package/dist/src/modules/mcp/apps/shared/resolve.d.ts +0 -1
  305. package/dist/src/modules/mcp/apps/shared/zodEnglishOnly.d.ts +0 -4
  306. package/dist/src/modules/mcp/catalogs/builtinCallbacks.d.ts +0 -23
  307. package/dist/src/modules/mcp/catalogs/builtinComponents.d.ts +0 -4
  308. package/dist/src/modules/mcp/catalogs/builtinElementCallbacks.d.ts +0 -20
  309. package/dist/src/modules/mcp/catalogs/builtinTransformers.d.ts +0 -28
  310. package/dist/src/modules/mcp/catalogs/builtinUtilities.d.ts +0 -18
  311. package/dist/src/modules/mcp/catalogs/cssCatalog/border.d.ts +0 -4
  312. package/dist/src/modules/mcp/catalogs/cssCatalog/box.d.ts +0 -4
  313. package/dist/src/modules/mcp/catalogs/cssCatalog/helpers.d.ts +0 -34
  314. package/dist/src/modules/mcp/catalogs/cssCatalog/index.d.ts +0 -19
  315. package/dist/src/modules/mcp/catalogs/cssCatalog/layout.d.ts +0 -9
  316. package/dist/src/modules/mcp/catalogs/cssCatalog/visual.d.ts +0 -8
  317. package/dist/src/modules/mcp/catalogs/index.d.ts +0 -9
  318. package/dist/src/modules/mcp/catalogs/observed.d.ts +0 -48
  319. package/dist/src/modules/mcp/catalogs/paramSpec.d.ts +0 -42
  320. package/dist/src/modules/mcp/catalogs/registry.d.ts +0 -35
  321. package/dist/src/modules/mcp/e2e/index.d.ts +0 -6
  322. package/dist/src/modules/mcp/e2e/mcpEndpoint.d.ts +0 -27
  323. package/dist/src/modules/mcp/e2e/postMessageChannel.d.ts +0 -22
  324. package/dist/src/modules/mcp/e2e/renderingHost.d.ts +0 -34
  325. package/dist/src/modules/mcp/handler.d.ts +0 -22
  326. package/dist/src/modules/mcp/helpers/agentPrompt.d.ts +0 -4
  327. package/dist/src/modules/mcp/helpers/computeVersion.d.ts +0 -1
  328. package/dist/src/modules/mcp/helpers/guide.d.ts +0 -4
  329. package/dist/src/modules/mcp/helpers/index.d.ts +0 -8
  330. package/dist/src/modules/mcp/helpers/interactions.d.ts +0 -30
  331. package/dist/src/modules/mcp/helpers/log.d.ts +0 -8
  332. package/dist/src/modules/mcp/helpers/opResult.d.ts +0 -13
  333. package/dist/src/modules/mcp/helpers/space.d.ts +0 -115
  334. package/dist/src/modules/mcp/helpers/uris.d.ts +0 -28
  335. package/dist/src/modules/mcp/index.d.ts +0 -13
  336. package/dist/src/modules/mcp/previewClient.d.ts +0 -13
  337. package/dist/src/modules/mcp/proxy/config.d.ts +0 -17
  338. package/dist/src/modules/mcp/proxy/fetch.d.ts +0 -18
  339. package/dist/src/modules/mcp/proxy/grant.d.ts +0 -23
  340. package/dist/src/modules/mcp/proxy/guard.d.ts +0 -6
  341. package/dist/src/modules/mcp/proxy/handler.d.ts +0 -8
  342. package/dist/src/modules/mcp/proxy/index.d.ts +0 -7
  343. package/dist/src/modules/mcp/proxy/rewrite.d.ts +0 -13
  344. package/dist/src/modules/mcp/proxy/sign.d.ts +0 -6
  345. package/dist/src/modules/mcp/proxy/types.d.ts +0 -45
  346. package/dist/src/modules/mcp/resources/canonical.d.ts +0 -6
  347. package/dist/src/modules/mcp/resources/core.d.ts +0 -5
  348. package/dist/src/modules/mcp/resources/envelope.d.ts +0 -10
  349. package/dist/src/modules/mcp/resources/index.d.ts +0 -8
  350. package/dist/src/modules/mcp/resources/primer.d.ts +0 -7
  351. package/dist/src/modules/mcp/resources/register.d.ts +0 -10
  352. package/dist/src/modules/mcp/resources/renderGuide.d.ts +0 -10
  353. package/dist/src/modules/mcp/resources/router.d.ts +0 -10
  354. package/dist/src/modules/mcp/resources/schema.d.ts +0 -5
  355. package/dist/src/modules/mcp/resources/style.d.ts +0 -5
  356. package/dist/src/modules/mcp/screenshotClient.d.ts +0 -13
  357. package/dist/src/modules/mcp/server.d.ts +0 -31
  358. package/dist/src/modules/mcp/tests/helpers.d.ts +0 -13
  359. package/dist/src/modules/mcp/tools/apply/dispatch.d.ts +0 -6
  360. package/dist/src/modules/mcp/tools/apply/index.d.ts +0 -470
  361. package/dist/src/modules/mcp/tools/apply/writeResult.d.ts +0 -8
  362. package/dist/src/modules/mcp/tools/index.d.ts +0 -18
  363. package/dist/src/modules/mcp/tools/operations/index.d.ts +0 -928
  364. package/dist/src/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +0 -17
  365. package/dist/src/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +0 -25
  366. package/dist/src/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +0 -27
  367. package/dist/src/modules/mcp/tools/operations/schema/elements/deleteElement.d.ts +0 -10
  368. package/dist/src/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +0 -16
  369. package/dist/src/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +0 -22
  370. package/dist/src/modules/mcp/tools/operations/schema/elements/repeatElement.d.ts +0 -55
  371. package/dist/src/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +0 -16
  372. package/dist/src/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +0 -9
  373. package/dist/src/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +0 -12
  374. package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +0 -21
  375. package/dist/src/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +0 -12
  376. package/dist/src/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +0 -18
  377. package/dist/src/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +0 -27
  378. package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +0 -229
  379. package/dist/src/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +0 -9
  380. package/dist/src/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +0 -14
  381. package/dist/src/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +0 -34
  382. package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +0 -92
  383. package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +0 -12
  384. package/dist/src/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +0 -9
  385. package/dist/src/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +0 -16
  386. package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +0 -42
  387. package/dist/src/modules/mcp/tools/operations/schemaIds.d.ts +0 -6
  388. package/dist/src/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +0 -9
  389. package/dist/src/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +0 -37
  390. package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +0 -37
  391. package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinitions.d.ts +0 -41
  392. package/dist/src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +0 -9
  393. package/dist/src/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +0 -37
  394. package/dist/src/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +0 -37
  395. package/dist/src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +0 -9
  396. package/dist/src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +0 -37
  397. package/dist/src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +0 -37
  398. package/dist/src/modules/mcp/tools/operations/style/index.d.ts +0 -15
  399. package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +0 -264
  400. package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +0 -116
  401. package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +0 -12
  402. package/dist/src/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +0 -15
  403. package/dist/src/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +0 -20
  404. package/dist/src/modules/mcp/tools/operations/style/write.d.ts +0 -12
  405. package/dist/src/modules/mcp/tools/preview.d.ts +0 -465
  406. package/dist/src/modules/mcp/tools/read.d.ts +0 -9
  407. package/dist/src/modules/mcp/tools/render.d.ts +0 -499
  408. package/dist/src/modules/mcp/tools/render.test.d.ts +0 -1
  409. package/dist/src/modules/mcp/tools/screenshot.d.ts +0 -470
  410. package/dist/src/modules/mcp/tools/search.d.ts +0 -15
  411. package/dist/src/modules/mcp/tools/shared/expandOperations.d.ts +0 -13
  412. package/dist/src/modules/mcp/tools/shared/tool.d.ts +0 -72
  413. package/dist/src/modules/mcp/tools/shared/validator/audit.d.ts +0 -4
  414. package/dist/src/modules/mcp/tools/shared/validator/batch.d.ts +0 -5
  415. package/dist/src/modules/mcp/tools/shared/validator/bindings.d.ts +0 -6
  416. package/dist/src/modules/mcp/tools/shared/validator/context.d.ts +0 -38
  417. package/dist/src/modules/mcp/tools/shared/validator/css.d.ts +0 -4
  418. package/dist/src/modules/mcp/tools/shared/validator/elements.d.ts +0 -7
  419. package/dist/src/modules/mcp/tools/shared/validator/index.d.ts +0 -8
  420. package/dist/src/modules/mcp/tools/shared/validator/interactions.d.ts +0 -3
  421. package/dist/src/modules/mcp/tools/shared/validator/refs.d.ts +0 -4
  422. package/dist/src/modules/mcp/tools/validate.d.ts +0 -467
  423. package/dist/src/modules/mcp/types/aiSchema.d.ts +0 -218
  424. package/dist/src/modules/mcp/types/appTypes.d.ts +0 -26
  425. package/dist/src/modules/mcp/types/index.d.ts +0 -5
  426. package/dist/src/modules/mcp/types/previewTypes.d.ts +0 -25
  427. package/dist/src/modules/mcp/types/screenshotTypes.d.ts +0 -29
  428. package/dist/src/modules/mcp/types/toolTypes.d.ts +0 -138
  429. package/dist/src/modules/oauth/authorize.d.ts +0 -7
  430. package/dist/src/modules/oauth/challenge.d.ts +0 -11
  431. package/dist/src/modules/oauth/consentPage.d.ts +0 -7
  432. package/dist/src/modules/oauth/metadata.d.ts +0 -40
  433. package/dist/src/modules/oauth/params.d.ts +0 -5
  434. package/dist/src/modules/oauth/pkce.d.ts +0 -6
  435. package/dist/src/modules/oauth/records.d.ts +0 -71
  436. package/dist/src/modules/oauth/register.d.ts +0 -5
  437. package/dist/src/modules/oauth/respond.d.ts +0 -13
  438. package/dist/src/modules/oauth/token.d.ts +0 -5
  439. package/dist/src/modules/ssr/buildBody.d.ts +0 -9
  440. package/dist/src/modules/ssr/handler.d.ts +0 -4
  441. package/dist/src/modules/ssr/preview.d.ts +0 -16
  442. package/dist/src/modules/ssr/streamBody.d.ts +0 -5
  443. package/dist/src/modules/ssr/template.d.ts +0 -6
  444. package/dist/src/standalone/alias-loader.d.mts +0 -2
  445. package/dist/src/standalone/plugins/ClientInfo.d.ts +0 -2
  446. package/dist/src/standalone/plugins/ServerInfo.d.ts +0 -2
  447. package/dist/src/standalone/plugins/SharedInfo.d.ts +0 -2
  448. package/dist/src/standalone/plugins/styles.d.ts +0 -5
  449. package/dist/src/standalone/register-alias.d.mts +0 -1
  450. package/dist/src/standalone/server.d.ts +0 -1
  451. package/dist/src/standalone/stubs/react-syntax-highlighter.d.mts +0 -31
  452. package/skills/plitzi-render/SKILL.md +0 -174
  453. /package/dist/{src/core/http/dispatcher.test.d.ts → core/auth/api.test.d.ts} +0 -0
  454. /package/dist/{src/core/server/mcpServer.test.d.ts → core/auth/authorize.test.d.ts} +0 -0
  455. /package/dist/{src/modules/ai/toolkit.test.d.ts → core/auth/createAuth.test.d.ts} +0 -0
  456. /package/dist/{src/modules/mcp/apps/apps.test.d.ts → core/auth/domains.test.d.ts} +0 -0
  457. /package/dist/{src/modules/mcp/apps/render/styles.test.d.ts → core/auth/identity.test.d.ts} +0 -0
  458. /package/dist/{src/modules → core/auth}/oauth/oauth.test.d.ts +0 -0
  459. /package/dist/{src/modules/mcp/catalogs/builtinTransformers.test.d.ts → core/auth/routes.test.d.ts} +0 -0
  460. /package/dist/{src/modules/mcp/catalogs/cssCatalog/cssCatalog.test.d.ts → core/auth/session.test.d.ts} +0 -0
  461. /package/dist/{src/modules/mcp/e2e/connector.test.d.ts → core/auth/spaceTokens.test.d.ts} +0 -0
  462. /package/dist/{src/modules/mcp/e2e/host.test.d.ts → core/auth/tokens.test.d.ts} +0 -0
  463. /package/dist/{src/modules/mcp/e2e/oauthConnector.test.d.ts → core/createServer.test.d.ts} +0 -0
  464. /package/dist/{src/modules/mcp/helpers/log.test.d.ts → core/handlers/handlers.test.d.ts} +0 -0
  465. /package/dist/{src/core → core}/health.d.ts +0 -0
  466. /package/dist/{src/modules/mcp/mcp.bench.d.ts → core/http/dispatcher.test.d.ts} +0 -0
  467. /package/dist/{src/core → core}/http/securityHeaders.d.ts +0 -0
  468. /package/dist/{src/core → core}/http/stages/authRoutes.d.ts +0 -0
  469. /package/dist/{src/core → core}/http/stages/pluginAssets.d.ts +0 -0
  470. /package/dist/{src/core → core}/mimeTypes.d.ts +0 -0
  471. /package/dist/{src/modules/mcp/constants.d.ts → core/previewToken.d.ts} +0 -0
  472. /package/dist/{src/core → core}/requestParser.d.ts +0 -0
  473. /package/dist/{src/core → core}/server/baseServer.d.ts +0 -0
  474. /package/dist/{src/modules/mcp/proxy/endpoint.test.d.ts → core/server/baseServer.test.d.ts} +0 -0
  475. /package/dist/{src/modules/mcp/proxy/proxy.test.d.ts → core/services/resolve.test.d.ts} +0 -0
  476. /package/dist/{src/core → core}/services/rsc.d.ts +0 -0
  477. /package/dist/{src/core → core}/services/ssr.d.ts +0 -0
  478. /package/dist/{src/core → core}/staticFiles.d.ts +0 -0
  479. /package/dist/{src/modules/mcp/proxy/wiring.test.d.ts → helpers/buildResponseHelpers.test.d.ts} +0 -0
  480. /package/dist/{src/helpers → helpers}/cache/TtlCache.d.ts +0 -0
  481. /package/dist/{src/helpers → helpers}/cache/cacheManager.d.ts +0 -0
  482. /package/dist/{src/helpers → helpers}/cache/defaults.d.ts +0 -0
  483. /package/dist/{src/helpers → helpers}/cache/index.d.ts +0 -0
  484. /package/dist/{src/modules/mcp/tests/apply.test.d.ts → helpers/cache/keys.test.d.ts} +0 -0
  485. /package/dist/{src/helpers → helpers}/cache/serverCaches.d.ts +0 -0
  486. /package/dist/{src/modules/mcp/tests/bindings.test.d.ts → helpers/compress.test.d.ts} +0 -0
  487. /package/dist/{src/helpers → helpers}/escapeJson.d.ts +0 -0
  488. /package/dist/{src/helpers → helpers}/metrics.d.ts +0 -0
  489. /package/dist/{src/helpers → helpers}/normalizePlugins.d.ts +0 -0
  490. /package/dist/{src/modules/mcp/tests/css.test.d.ts → helpers/offlineDataLoader.test.d.ts} +0 -0
  491. /package/dist/{src/helpers → helpers}/readCookie.d.ts +0 -0
  492. /package/dist/{src/modules/mcp/tests/interactions.test.d.ts → helpers/resolveDebugMode.test.d.ts} +0 -0
  493. /package/dist/{src/helpers → helpers}/runMiddlewares.d.ts +0 -0
  494. /package/dist/{src/helpers → helpers}/serverLog.d.ts +0 -0
  495. /package/dist/{src/middlewares → middlewares}/auth.d.ts +0 -0
  496. /package/dist/{src/middlewares → middlewares}/basicAuth.d.ts +0 -0
  497. /package/dist/{src/modules/mcp/tests/pages.test.d.ts → middlewares/spaceDeployment.test.d.ts} +0 -0
  498. /package/dist/{src/modules/mcp/tests/reads.test.d.ts → modules/actions/handler.test.d.ts} +0 -0
  499. /package/dist/{src/modules/mcp/tests/schemaIds.test.d.ts → modules/connectors/engine.test.d.ts} +0 -0
  500. /package/dist/{src/modules/mcp/tests/search.test.d.ts → modules/connectors/projection.test.d.ts} +0 -0
  501. /package/dist/{src/modules/mcp/tests/skill.test.d.ts → modules/connectors/resolver.test.d.ts} +0 -0
  502. /package/dist/{src/modules/mcp/tests/styles.test.d.ts → modules/rsc/resolveRscData.test.d.ts} +0 -0
  503. /package/dist/{src/modules → modules}/ssr/applySSRResult.d.ts +0 -0
  504. /package/dist/{src/modules/mcp/tests/tools.test.d.ts → modules/ssr/loadPluginComponents.test.d.ts} +0 -0
  505. /package/dist/{src/modules/mcp/tests/validation.test.d.ts → modules/ssr/metering.test.d.ts} +0 -0
  506. /package/dist/{src/modules → modules}/ssr/registerExternalPlugins.d.ts +0 -0
  507. /package/dist/{src/plugins → plugins}/compile.d.ts +0 -0
  508. /package/dist/{src/plugins → plugins}/copy.d.ts +0 -0
  509. /package/dist/{src/plugins → plugins}/detect.d.ts +0 -0
  510. /package/dist/{src/plugins → plugins}/manager.d.ts +0 -0
  511. /package/dist/{src/plugins → plugins}/validate.d.ts +0 -0
  512. /package/dist/{src/plugins → plugins}/validate.test.d.ts +0 -0
@@ -1,467 +0,0 @@
1
- //#region src/modules/mcp/helpers/guide.ts
2
- var serverInstructions = "Plitzi AI server: read-then-write editing of a Plitzi space. Reads follow a filesystem model — list cheap, read one item in detail on demand; never fetch a whole tree you do not need. Workflow: (1) read plitzi://primer/{env} once — it bundles the guide, types, css-properties and page/definition/variable summaries in a single call; (2) plitzi_search with include:\"detail\" to jump to elements — each hit then carries its uri, stateVersion AND full style/resolvedStyle, so an edit needs no per-element read; open a page skeleton or element only when you need its tree/detail (the skeleton already lists the style classes of each node, and plitzi_read fetches many uris at once); (3) plitzi_apply with dryRun to preview a batch; (4) plitzi_apply to persist, passing expectedResourceVersions to guard against concurrent edits — apply and search both hand back the versions you need for the next edit. Use patchElement / patchDefinition to change only some props / CSS (the upsert variants replace them all). An element read (and search include:\"detail\") inlines the CSS of the definitions it attaches under resolvedStyle, so you rarely need a separate definition read. Refs accept a semantic idRef ([A-Za-z0-9_-] starting with a letter, unique, chosen by you) or the raw id — the idRef is ALSO the runtime wiring key, so a provider source is `<type>_<idRef>.<field>`, visible to the provider’s DESCENDANTS only (bind inside its subtree). CSS is plain kebab-case — write shorthands freely (`border: 1px solid red`, `padding: 8px 16px`, `font: bold 16px/1.5 Arial`), they are expanded to longhands for you and STORED that way, so read-back shows the longhands; style vars are var(--name), schema vars are {{name}}. READERS — do not confuse them: MCP *resources* are the browsable catalog (list them, or open one by URI); plitzi_search FINDS refs by label/type/attribute; plitzi_read BATCH-fetches URIs you already hold. Reach for search/read to work; browse resources to discover. Elements also carry applied style variants + visibility (initialState), data bindings and interaction flows: edit them with patchElement (initialState), upsertBinding/patchBinding/deleteBinding, and upsertInteractionFlow/patchInteractionNode/deleteInteraction. An element read shows all three plus availableVariants (which variant each of its classes offers). Separately, to SHOW the user a small self-contained widget (offline, no space or backend) instead of editing the space — a card, hero, pricing table, a visual answer — use plitzi_render; read plitzi://render/guide for it.";
3
- var widgetsOnlyInstructions = "Plitzi widget server (widgets-only connection). This connection carries NO Plitzi space: nothing can be read or edited in one, and the space tools are not offered here — do not look for them. What it does do is build self-contained UI widgets fully offline, with no backend, account or setup: call plitzi_render to SHOW the user a real rendered layout (card, hero, pricing table, checklist, form, gallery) instead of describing one. Read plitzi://render/guide first — the element/prop table, the style model and a worked example; plitzi://render/types lists every element type you can author (plitzi_read fetches both). To change a widget you already rendered, call plitzi_render again with patch:true and its renderId. If the user wants to edit their real Plitzi space from here, that is a reconnection they make: the integration must be re-authorized and granted a space (the consent screen lists theirs) — you cannot do it from this connection, and no retry will change it.";
4
- var guideQuickstart = `# Plitzi AI MCP — quickstart
5
- This is the condensed guide; read \`plitzi://guide\` for the full reference (every resource, op and example).
6
-
7
- A space is **two schemas you edit together in one atomic \`plitzi_apply\` batch**: the **element schema** (tree of
8
- pages/elements) and the **style schema** (definitions = CSS classes, tokens, theme). To style an element: write a
9
- **definition** and attach it via the element's \`style.base\` in the same batch.
10
-
11
- **Workflow:** (1) you already have this primer (guide + types + css + page/style summaries). (2) \`plitzi_search\`
12
- with \`include:"detail"\` to find elements — each hit carries its \`uri\`, \`stateVersion\` and full style, so no
13
- per-element read. (3) \`plitzi_apply\` with \`dryRun:true\` to preview. (4) \`plitzi_apply\` to persist, passing
14
- \`expectedResourceVersions\` (uri → the stateVersion you read) for every resource you change — omitting it lets a
15
- concurrent edit be lost. Use \`patchElement\`/\`patchDefinition\` to change only some props/CSS (upsert replaces all).
16
-
17
- **Refs & wiring:** a ref is the semantic \`idRef\` (letters, numbers, hyphens and underscores, **starting with a
18
- letter — no dots**) or the raw id. The idRef is the runtime wiring key: a provider's source is \`<type>_<idRef>\`, and
19
- interactions target by it. A dot would split that path; an **underscore is fine** — the first \`_\` separates the type
20
- from the idRef (element types have none), so \`list_food_item\` reads unambiguously as type \`list\`, idRef \`food_item\`.
21
-
22
- **Styling:** CSS keys are **kebab-case** (\`background-color\`); \`var(--token)\` for style vars, \`{{name}}\` for schema
23
- vars. **Write plain CSS** — shorthands (\`border\`, \`padding\`, \`margin\`, \`gap\`, \`overflow\`, \`flex\`, \`background\`,
24
- \`font\`, \`transition\`, \`animation\`, \`grid\`, \`grid-row\`/\`grid-column\`, \`place-*\`, \`outline\`, \`columns\`,
25
- \`list-style\`, \`text-decoration\`) are expanded to their longhands for you, so \`border: 1px solid red\` is stored as
26
- \`border-top-color\`/\`border-top-width\`/\`border-top-style\`/… That is also how you read them back. Flex layout is
27
- still \`display: flex\` + \`flex-direction\`/\`align-items\`/…, not a \`flex\` value. Mind a type's \`defaultStyle\`
28
- (\`text\` is \`display: inline\`). Global styles (\`button {…}\`) and id styles (\`#id\`) have their own ops.
29
-
30
- **Data bindings** (\`upsertBinding\`, category attributes|style|initialState): connect a \`source\` to a \`to\` field.
31
- A source \`<type>_<idRef>\` is scoped to the provider's **DESCENDANTS only** — bind inside the provider's subtree
32
- (module sources state/space/navigation/auth/collection are global). \`apiContainer.mockData\` is builder-only; set a
33
- real \`query\` for production. \`transformers: [{action, params}]\` post-process the value — use exact action names
34
- from \`plitzi://data-sources\`; \`twigTemplate\` formats it (the value is \`{{source}}\`, not \`{{value}}\`). \`when\` is
35
- a QueryBuilder RuleGroup gating the binding.
36
-
37
- **Interactions** (\`upsertInteractionFlow\`): a \`trigger\` node first, then callbacks/utilities **in order** (links
38
- computed for you). Node types: \`callback\` (an element's own callback — \`elementId\` is that element), \`globalCallback\`
39
- (a source module — omit \`elementId\`, the MCP sets it), \`utility\` (no element). Element \`setState\`
40
- (category/key/value/revertOnFinish) ≠ global \`setState\` (source \`state\`, key/type/value). To turn a step off use
41
- \`patchInteractionNode {enabled:false}\` — \`deleteInteraction\` removes it (destructive; confirm first). Any param
42
- **value** can be a binding token \`{{ source }}\` (e.g. notification \`content: "{{ list_<idRef>.item.name }}"\`).
43
-
44
- **Pages & navigation:** \`upsertPage\` — always set a **relative** \`slug\` (no leading \`/\`; the runtime and folder
45
- slugs prepend the path). A \`:name\` segment (\`"posts/:postId"\`) is a route param, readable as \`{{name}}\` and as the
46
- source \`navigation.routeParams.name\` → build dynamic pages this way. To move between pages **prefer the \`Link\`
47
- element** (a container: \`mode\` "page"/"internal"/"external") over a \`navigate\` interaction.
48
-
49
- **Touched resources must be malformation-free.** Editing an element/definition also checks its CURRENT stored content
50
- and BLOCKS the save on any \`Pre-existing malformation in <resource>\` error (a broken transformer, malformed node,
51
- invalid CSS) — even parts you did not touch. These are NOT from your change (the message says so); fix them in the
52
- SAME batch and re-apply (the check runs on the result, so the fix unblocks it). \`Pre-existing issue\` warnings advise
53
- but do not block.
54
-
55
- Read \`plitzi://guide\` before anything above is unclear.
56
- `;
57
- var guideText = `# Plitzi AI MCP — usage guide
58
-
59
- A Plitzi space is **two separate schemas** you edit together:
60
- - **Element schema** — the tree of pages and elements (their type, label, props, and which style classes they use).
61
- - **Style schema** — reusable **definitions** (CSS classes), design tokens (variables), theme.
62
-
63
- They are stored and persisted independently, but a single \`plitzi_apply\` batch may touch **both atomically**.
64
- To style a specific element you do two things in one batch: write a **definition** (style schema) and **attach**
65
- it via the element's \`style.base\` (element schema). Example — "rename button X to PEPE and make it red":
66
- \`\`\`json
67
- { "operations": [
68
- { "type": "upsertDefinition", "ref": "btn-x", "desktop": { "color": "red" } },
69
- { "type": "upsertElement", "pageRef": "home",
70
- "element": { "ref": "X", "type": "button", "label": "PEPE", "style": { "base": ["btn-x"] } } }
71
- ] }
72
- \`\`\`
73
-
74
- Reads are cheap by design — treat them like a filesystem: **list** to navigate, **read one item** for detail.
75
- Never download a whole tree you do not need.
76
-
77
- ## Resources (read)
78
- - \`plitzi://primer/{env}\` — **cold-start bundle**: guide + types + css-properties + page/definition/variable
79
- **summaries** in one read. Fetch this first instead of the individual resources below. Summaries only — open a
80
- page skeleton or element for its tree/detail.
81
- - \`plitzi://guide\` — this guide.
82
- - \`plitzi://types\` — element types **observed in this space** (ground truth): props, slots, subTypes, plus each
83
- type's \`label\`, \`description\` (what it is FOR) and \`category\`, and a \`source\` (\`builtin\` | \`plugin\` | \`unknown\`).
84
- Read the descriptions to pick the right type — e.g. \`apiContainer\` fetches backend data into the frontend,
85
- \`link\` navigates between pages, \`list\` repeats a template over a data array. \`plugin\` types are custom elements.
86
- - \`plitzi://css-properties\` — valid kebab-case CSS property keys.
87
- - \`plitzi://schema/{env}/pages\` — page **summaries** (ref, label, elementCount, folder). No element trees.
88
- - \`plitzi://folders/{env}\` — page **folders** (the sidebar tree): ref, name, slug, parentId. \`/{ref}\` for one.
89
- - \`plitzi://schema/{env}/pages/{ref}\` — one page as a **skeleton tree**: each node is \`ref/type/label\` **plus the
90
- style classes it attaches** (\`base\`, and \`slots\` for non-base slots) — names only, no CSS. So you can map every
91
- element to its class in a single page read, without opening each element just to learn which class it uses.
92
- - \`plitzi://schema/{env}/pages/{ref}/styles\` — **every style the page uses in one read**: the class definitions its
93
- elements attach (deduplicated, **with full CSS**) plus the global styles affecting any element type on the page.
94
- Reach for this to recolor/restyle a whole page — it needs no shared class-name prefix and no per-element reads.
95
- - \`plitzi://schema/{env}/elements/{ref}\` — one element in **full detail** (props, style, parentRef, childRefs).
96
- Its \`resolvedStyle\` inlines the **CSS of every definition** the element attaches (keyed by class ref), so you
97
- can see and edit its style without a separate definition read. Its \`globalStyles\` lists the **global element
98
- selectors** that also affect it (the CSS equivalent of \`button { … }\`, keyed by the type they target) — every
99
- element of that type inherits them. Edit a global only through the global-style tools (never per element). If the
100
- element carries a DOM \`id\` that an id rule matches, its \`idStyle\` (\`#id\`) is inlined too.
101
- - \`plitzi://definitions/{env}\` — the **names** of every style definition.
102
- - \`plitzi://definitions/{env}/{ref}\` — one definition's CSS.
103
- - \`plitzi://global-styles/{env}\` — element **types** that have a site-wide global style. \`/{componentType}\` for one.
104
- - \`plitzi://id-styles/{env}\` — DOM **ids** that have an id rule (\`#id\`) targeting a single element. \`/{targetId}\` for one.
105
- - \`plitzi://style-variables/{env}\` — design tokens by category. \`/{category}\` for one.
106
- - \`plitzi://schema-variables/{env}\` — space-level values referenced in props as \`{{name}}\`.
107
- - \`plitzi://settings/{env}\` — space-level settings: the global \`customCss\` and the state/auth (user-provider) config.
108
- - \`plitzi://interactions/{env}\` — interaction **actions** observed in this space (grouped by node type): the
109
- vocabulary for interaction flows.
110
- - \`plitzi://data-sources/{env}\` — data-source **paths** and binding targets observed in this space: the
111
- vocabulary for data bindings.
112
-
113
- The style resources also answer under the \`plitzi://schema/{env}/…\` root as aliases — \`plitzi://schema/{env}/definitions/{ref}\`, \`plitzi://schema/{env}/style-variables/{category}\`, \`plitzi://schema/{env}/schema-variables\` — but prefer the ready-made \`uri\` from search / a write response over hand-building either form.
114
-
115
- Data resources return \`{ stateVersion, data }\`. Keep \`stateVersion\` for optimistic concurrency.
116
-
117
- **Reuse what you already know — don't re-scan an unchanged page.** A page read (\`plitzi://schema/{env}/pages/{ref}\`)
118
- returns a \`stateVersion\` that is an **aggregate of the whole page**: it changes if and only if some element on the
119
- page changed. Its skeleton \`tree\` also carries a \`stateVersion\` **per node**, identical to the one a direct element
120
- read or search hit returns for that element. So when you come back to a page you already inspected:
121
- 1. Re-read just the page skeleton and compare its top-level \`stateVersion\` to the one you held. **Same → nothing
122
- changed since your read; skip re-reading and re-searching the tree** and act on what you already know.
123
- 2. If it differs, diff the per-node \`stateVersion\`s against the ones you cached and \`plitzi_read\` **only the nodes
124
- that changed** — never re-search or re-read the whole tree.
125
-
126
- This is a **read-time** shortcut, not a safety guarantee. **Other agents/sub-agents may edit the same space
127
- concurrently**, so a version you cached can go stale between your read and your write. Never skip the write-time
128
- check below on the strength of a cached hash — the guarantee that no concurrent edit is lost comes only from
129
- \`expectedResourceVersions\` on \`plitzi_apply\`, which re-validates against the live data at write time.
130
-
131
- ## Navigating (files analogy)
132
- Pages and containers are folders; elements are files. **Prefer \`plitzi_search\` (especially with \`include: "detail"\`)
133
- over reading elements one by one** — it jumps straight to elements by label/type/attribute and each hit already
134
- carries the element's \`uri\`, \`stateVersion\`, \`pageUri\`, \`parentRef\` and tree \`path\`, so you can edit it (with
135
- optimistic concurrency) **without a follow-up read**. \`include: "detail"\` additionally inlines each hit's props/style
136
- **and** its \`resolvedStyle\` (the CSS behind its classes) — so a search-then-edit is the efficient path and a manual
137
- element read is the exception. Search also matches **pages** by name/slug (returned under \`pages\`, each with its uri +
138
- stateVersion) and returns any **style definitions** whose name matches the query, with full CSS, under \`definitions\`.
139
- When you do hold several refs to open (e.g. from a skeleton), read them together with \`plitzi_read\` rather than one at a time.
140
-
141
- ## Tools (write)
142
- - \`plitzi_validate\` — check a batch, returns teachable errors/warnings. Writes nothing. Also reports **pre-existing
143
- malformations** in any resource the batch touches (see below).
144
- - \`plitzi_apply\` — validate → apply → persist atomically. Rejects the whole batch on any error or conflict. Pass
145
- \`dryRun: true\` to apply in memory only and get the same result back (changed versions + full element detail)
146
- without persisting — inspect it, then re-run without \`dryRun\` to commit.
147
- - \`plitzi_search\` — find elements (and pages/definitions) across the space.
148
- - \`plitzi_read\` — read many resource **uris in one batch** (pages, elements, definitions, variables). Pass the
149
- ready-made uris from search / a write response; each result is \`{ uri, stateVersion, data }\` or a teachable error,
150
- so one bad uri never fails the batch. Use it instead of N single reads whenever you already hold several refs.
151
-
152
- ## Readers: resources vs plitzi_search vs plitzi_read (do not confuse them)
153
- Three ways to read, each for a different moment — pick by what you have in hand:
154
- - **MCP resources** (the \`plitzi://…\` catalog above) — the **browsable index**. List them to discover what exists, or
155
- open one by URI when you are exploring. This is the passive catalog, not a tool.
156
- - **\`plitzi_search\`** — you know *what* you want but not its **ref/uri** ("the hero button"). Search finds it by
157
- label/type/attribute and hands back the uri + stateVersion (and, with \`include:"detail"\`, the full element).
158
- - **\`plitzi_read\`** — you **already hold one or more uris** (from search or a write response) and want their
159
- content in one batch. It is the tool form of opening resources, for when you have the addresses.
160
- Rule of thumb: **discover → resources**, **find a ref → plitzi_search**, **fetch known uris → plitzi_read**. Never
161
- hand-build a URI to guess your way to an element — search for it instead.
162
-
163
- Write tools return what **changed** (\`{ uri, stateVersion }\`) plus counts, and the **full detail of every element
164
- they created or updated** — each with its own \`uri\` and \`stateVersion\` (\`elements: [...]\`) so a follow-up edit of
165
- the same element needs **no intermediate read**. Other resources (pages, definitions, variables) still report only
166
- uri+stateVersion — re-read them if you need their new content. The operation shapes are in each tool's input
167
- schema (discriminated by \`type\`).
168
-
169
- ## Addressing
170
- Refs are the semantic \`idRef\` (e.g. \`"hero-cta"\`) or the element's **raw id** — both resolve. Creating an element
171
- stores the \`ref\` you chose as its **idRef**.
172
-
173
- The idRef is not just an alias — it is the **wiring key the runtime uses**. A provider registers its data source as
174
- \`<type>_<idRef>\`, so a \`source\` you write against a ref resolves to that element at runtime with no id translation.
175
- Rules for a **new** ref (both are enforced; a violation fails the batch):
176
- - Charset \`[A-Za-z0-9_-]\`, **starting with a letter** (e.g. \`"products-api"\`, \`"food_item"\`). A \`.\` would split the
177
- \`<type>_<idRef>.<field>\` source path and the interaction target lookup, so **no dots**. An **underscore is
178
- allowed**: the FIRST \`_\` separates \`<type>\` from \`<idRef>\` and element types are camelCase with none, so
179
- underscores inside the idRef are unambiguous (\`list_food_item\` → type \`list\`, idRef \`food_item\`).
180
- - **Unique across the space**; creating a ref that is taken is rejected (address the existing element instead).
181
-
182
- An idRef is **optional** on an element — one built in the builder may not have it. The consequence is specific: an
183
- element without an idRef **publishes no data source** and **holds no interactions**, because the runtime keys
184
- everything by idRef and the raw id is never a fallback. You do not have to fix this by hand: writing an
185
- interaction **mints an idRef for you** — the element that hosts the flow, and any element a node targets, is given
186
- a free \`<type>-<n>\` ref if it lacks one, and the flow is wired to it. A node target you write may be a raw id; it
187
- is normalised to that element's idRef. (To make an element a data-source **provider** to bind against, give it an
188
- idRef explicitly with \`patchElement\`, or create it with the \`ref\` you want — a created element stores its ref as
189
- its idRef.)
190
-
191
- **Renaming** an idRef moves the wiring key: every binding source and interaction target across the space that
192
- pointed at the old name is repointed with it, so the element stays wired. You do not have to rewrite them.
193
-
194
- ## Styling (crosses both schemas)
195
- - **Mind the type's intrinsic default style.** A type renders with a base CSS *before* any class is attached — read
196
- it from \`defaultStyle\` on the type in \`plitzi://types\` (the primer includes it). Do not assume \`display: block\`:
197
- \`text\`, for one, defaults to \`display: inline\`, so margins/width/vertical padding behave differently. If you need
198
- block/flex layout on such an element, set \`display\` explicitly in your definition rather than relying on a default.
199
- - **Images: preserve aspect ratio.** Setting only \`width\` and \`height\` (or forcing both) distorts an image. Change
200
- one dimension and let the other be \`auto\`, or set \`aspect-ratio\` with \`object-fit: cover\`/\`contain\`, so the
201
- image scales without stretching.
202
- - **Font size and line height move together.** When you change \`font-size\`, set \`line-height\` in the same edit
203
- (prefer a unitless ratio like \`1.5\`, which tracks the font size). Changing one without the other leaves cramped or
204
- loosely-spaced text — they are a joint change, not two separate ones.
205
- - A definition lives in the **style schema**; an element's \`style.base\` (element schema) is the link that applies
206
- it. Styling an element = upsertDefinitions + upsertElement with that ref in \`style.base\`, in one batch.
207
- - **Repeating siblings**: when a set of siblings shares a shape and differs only in data (a list, cards, rows,
208
- steps), use \`repeatElement\` — the template once with \`{{item.field}}\` placeholders plus \`items\`, which
209
- creates the wrapper and numbers each row's refs (\`step-1\`, \`step-2\`…). A list inside each row is the same op:
210
- the wrapping node carries \`repeat: { items: "{{item.<list>}}", template: … }\` and its refs number both levels
211
- (\`blk-2-3\`). Copy-pasting the subtree N times costs N times the tokens and drifts.
212
- - CSS keys are **kebab-case** (\`background-color\`). camelCase is rejected — read \`plitzi://css-properties\`.
213
- - **Write normal CSS — shorthands are accepted and expanded for you.** \`border\`, \`border-{side}\`,
214
- \`border-width\`/\`-color\`/\`-style\`, \`border-radius\`, \`padding\`, \`margin\`, \`inset\`, \`gap\`, \`overflow\`,
215
- \`flex\`, \`flex-flow\`, \`background\`, \`font\`, \`transition\`, \`animation\`, \`grid\`, \`grid-template\`,
216
- \`grid-area\`, \`grid-row\`, \`grid-column\`, \`place-content\`, \`place-items\`, \`place-self\`, \`outline\`,
217
- \`columns\`, \`list-style\`, \`text-decoration\` — the full list is in \`plitzi://css-properties\` under
218
- \`shorthands\`. They **persist as longhand keys** (that is what a read gives back), so a breakpoint/state/variant
219
- can still override one property at a time.
220
- - \`border: 1px solid red\` → \`border-top-width: 1px\`, \`border-top-style: solid\`, \`border-top-color: red\`, …
221
- for all four sides. A shorthand also RESETS what it omits, so \`border: none\` clears a width a previous
222
- definition set.
223
- - Comma-separated layers are kept per longhand: \`transition: opacity 200ms, transform 300ms\` →
224
- \`transition-property: opacity, transform\` + \`transition-duration: 200ms, 300ms\`.
225
- - In a **patch**, a shorthand replaces the longhands it controls (\`padding: 8px\` overwrites a previous
226
- \`padding-left\`), and \`"border": null\` removes all twelve border longhands.
227
- - **Flex layout is not a \`flex\` value**: set \`display: flex\` **plus** \`flex-direction\`, \`align-items\`,
228
- \`justify-content\` as separate properties.
229
- - CSS is grouped by breakpoint: \`desktop\`, \`tablet\`, \`mobile\`.
230
- - Reference a style variable in CSS as \`var(--name)\`; a schema variable in a prop as \`{{name}}\`.
231
- - \`element.style.base\` is a **list** of definition refs; other slots go under \`element.style.slots\`.
232
- - **An element can attach SEVERAL classes at once, and they all apply.** \`style.base\` holds a list, and each
233
- non-base slot holds its own — every attached definition contributes CSS, and they **cascade** (a later class, then a
234
- global/id rule, overrides an earlier one on the same property). So when a style looks wrong, the culprit may be
235
- ANY attached class, not the one you just edited: read the element's \`resolvedStyle\` (it inlines the CSS of every
236
- class it attaches, keyed by ref) together with its \`globalStyles\`/\`idStyle\` and the type's \`defaultStyle\`, and
237
- fix the class that actually sets the property — do not just pile another class on top.
238
- - **Three kinds of style live in the style schema — do not confuse them:**
239
- - **Definitions** = reusable CSS **classes** (\`upsertDefinition\`/\`patchDefinition\`/\`deleteDefinition\`, keyed by a
240
- class \`ref\`). Attach one to an element via \`style.base\` to style **that** element (and anything else that opts in).
241
- This is the **default** way to style one element. Declaring MORE than one class in a batch? Use
242
- \`upsertDefinitions\` — one op carrying \`{ "<class>": { desktop: … }, … }\`, same result as the run of
243
- \`upsertDefinition\` it replaces, without repeating the envelope once per class.
244
- - **Global styles** = the CSS equivalent of a bare element selector like \`button { … }\`
245
- (\`upsertGlobalStyle\`/\`patchGlobalStyle\`/\`deleteGlobalStyle\`, keyed by \`componentType\`). They style **every**
246
- element of that type at once. Use these for site-wide intent — e.g. "all buttons rounded":
247
- \`{ "type": "upsertGlobalStyle", "componentType": "button", "desktop": { "border-radius": "9999px" } }\`.
248
- - **Id styles** = the CSS equivalent of an id selector like \`#hero { … }\`
249
- (\`upsertIdStyle\`/\`patchIdStyle\`/\`deleteIdStyle\`, keyed by \`targetId\`). They style the **single** element whose
250
- DOM \`id\` attribute equals \`targetId\` — so the element must carry that \`id\` (set it in its props). Prefer a
251
- **definition** for one element; reach for an id style only when a specific, uniquely-identified node must be
252
- targeted by id: \`{ "type": "upsertIdStyle", "targetId": "hero", "desktop": { "min-height": "100vh" } }\`.
253
- - The three share one name space, so an op refuses a name held by another kind (guards against a typo silently
254
- rewriting every element of a type, or converting a class into an id rule). If refused, you targeted the wrong
255
- kind — switch tools or rename.
256
-
257
- ## Style variants & element state
258
- A **variant** is a named CSS override on a definition (e.g. a button class with a \`primary\` variant). It takes two
259
- steps across the two schemas:
260
- - **Declare** the variant CSS on the class (style schema): \`upsertDefinition\`/\`patchDefinition\` with
261
- \`variants: { "primary": { "desktop": { "background-color": "#111" } } }\` (per slot under \`slots.<slot>.variants\`).
262
- - **Apply** it to an element (element schema): \`initialState.styleVariant\` =
263
- \`{ "<class-ref>": { "base": "primary" } }\` — a slot name instead of \`base\` targets that slot; an array applies
264
- several. Set it via \`upsertElement\`/\`patchElement\`.
265
- An element read reports \`availableVariants\` (which variant each attached class offers) and the element's current
266
- \`initialState\`, so you can see a button **has** a \`primary\` variant and whether it uses it. If the user asks for a
267
- variant that does not exist yet, **create it (upsertDefinition variants) and apply it in the same batch**.
268
- - \`initialState.visibility\` (boolean) sets whether the element starts shown or hidden.
269
-
270
- ## Data bindings
271
- Connect a data **source** to an element field. A binding is \`{ to, source, transformers?, when?, enabled? }\` grouped
272
- by **category**: \`attributes\` (a prop), \`style\` (a style value), \`initialState\` (an initial-state key).
273
- - \`upsertBinding\` adds one, or replaces the binding already feeding the same \`to\` (or \`id\`).
274
- - \`patchBinding\` edits an existing one (matched by \`to\`/\`id\`); \`deleteBinding\` removes it.
275
- Discover valid source paths **and the transformer catalog** in \`plitzi://data-sources/{env}\`. Example — feed an API
276
- list into a list element:
277
- \`{ "type": "upsertBinding", "pageRef": "home", "ref": "myList", "category": "attributes",
278
- "binding": { "to": "items", "source": "apiContainer_x.data" } }\`.
279
-
280
- **Source scope — a source is visible to the provider's DESCENDANTS only.** An element source named
281
- \`<type>_<idRef>\` (e.g. \`apiContainer_products\`, \`list_food-list\`) is published by that element into the scope of
282
- its **subtree**, so **only elements INSIDE the provider can bind to it**. Binding a sibling or an unrelated element
283
- to it resolves to nothing at runtime. So to consume \`apiContainer_products.data\`, the bound element must live under
284
- that apiContainer; inside a \`list\`, the repeated \`listItem\` and its children read the per-row source
285
- (\`list_<idRef>.item.<field>\`). Module sources (no \`<type>_<idRef>\` head — \`state\`, \`space\`, \`navigation\`,
286
- \`auth\`, \`collection\`) are global and bindable anywhere. Binding an element to an element source outside its
287
- provider's subtree is schema-valid but **broken at runtime** (the source is not in scope), so
288
- \`plitzi_validate\`/\`plitzi_apply\` treat it as an **error and reject the batch** — move the element under the
289
- provider, or bind a source that is in scope.
290
-
291
- **mockData is builder-only.** An \`apiContainer\`'s \`mockData\` prop feeds sample data **while editing in the
292
- builder**; the published runtime fetches the real \`query\` instead. Never rely on mockData as the production source —
293
- set a real \`query\`/\`method\` so the binding has data at runtime.
294
-
295
- **\`transformers\` — post-process the value before it reaches the field** (\`source → t₁ → t₂ → field\`). An array of
296
- \`{ action, params }\`; the runtime runs them in order and resolves each by its \`action\` alone, so an **unknown
297
- action is silently skipped** and the raw value passes through. Use the **exact** action names from
298
- \`plitzi://data-sources\` (\`transformers\`). The most common is **\`twigTemplate\`** to format a value — the incoming
299
- value is the **\`{{source}}\`** token (NOT \`{{value}}\`); \`{{sourceTo}}\` is the field's previous value. Example —
300
- show a number with units:
301
- \`{ "type": "upsertBinding", "pageRef": "home", "ref": "food-item-time", "category": "attributes",
302
- "binding": { "to": "content", "source": "list_food-list.item.cookTimeMinutes",
303
- "transformers": [ { "action": "twigTemplate", "params": { "template": "{{source}} min de cocción" } } ] } }\`.
304
- Other transformers: \`dateConverter\` (format a date/timestamp), \`capitalize\`, \`stringToArray\` (split on a
305
- separator), \`arrayMap\` (remap the keys of each object in an array), \`staticValue\`. Transformer \`params\` values are
306
- strings. Each transformer also takes an optional \`enabled\` flag: set \`"enabled": false\` to keep it in the chain but
307
- skip it at runtime (defaults to true) — the value passes through untouched, and a disabled transformer is not
308
- validated.
309
-
310
- **\`when\` — gate the binding** with a QueryBuilder RuleGroup: the binding only applies when the guard passes against
311
- the data source. Shape: \`{ "combinator": "and", "rules": [ { "field": "<path>", "operator": "=", "value": "x" } ] }\`
312
- (operators: \`=\`, \`!=\`, \`<\`, \`>\`, \`contains\`, \`beginsWith\`, \`empty\`, \`in\`, \`between\`, …; nest RuleGroups for
313
- and/or). The guard is validated structurally. Example — only bind when a flag is set:
314
- \`"when": { "combinator": "and", "rules": [ { "field": "status", "operator": "=", "value": "published" } ] }\`.
315
-
316
- ## Interactions
317
- An interaction **flow** is a **trigger** (an event like \`onClick\`, \`onPageLoad\`) followed by the callbacks/utilities
318
- it runs, in order. You pass the steps **in order** and the stored beforeNode/afterNode/flowId links are computed for
319
- you — never wire them by hand. Each step also has an \`enabled\` flag (see disable vs delete below).
320
-
321
- **Node types & \`elementId\`** — a step names which element (or module) provides the callback it runs. Picking the
322
- **wrong node type for an action** makes the runtime resolve it against nothing, so the step **silently does nothing**:
323
- - \`trigger\` — the event; belongs to the host element. \`elementId\` defaults to the host.
324
- - \`callback\` — a callback provided by a **specific element**. \`elementId\` is that element's ref (the flow host by
325
- default, or another element to act on); give its ref or raw id and it is normalised to the idRef. Every element
326
- registers a built-in **\`setState\`** callback that changes **its own attribute or state**: params
327
- \`category\` (\`"attribute"\` — set a prop like \`content\`/\`disabled\` — or \`"state"\` — \`visibility\` or a style
328
- selector), \`key\`, \`value\` (a **scalar** whose type follows the target attribute — a real boolean \`true\`/\`false\`
329
- for a boolean attribute, a number for a numeric one, otherwise a string), and **\`revertOnFinish\`**. Set
330
- \`revertOnFinish: true\` for a **temporary** change (a "loading…" label, disabling a button while it works): it is
331
- **undone automatically when the flow finishes**, so you do **NOT** add manual restore steps at the end. This element
332
- \`setState\` has **no** \`type\` param (that belongs to the global one below). An element type may also register its
333
- own extra callbacks.
334
- - \`globalCallback\` — a callback provided by a **source module**, NOT by any element: \`addNotification\` (source
335
- \`space\`), \`setState\`/\`clearState\` (\`state\`), \`navigate\` (\`navigation\`), \`authLogin\`/\`authLogout\`/
336
- \`authRefreshDetails\` (\`auth\`), \`addCollectionRecord\`/\`updateCollectionRecord\`/\`removeCollectionRecord\`
337
- (\`collection\`). Its \`elementId\` is the **source module id**, never the host element — a node that stored the host
338
- idRef here would resolve to nothing at runtime. **Omit \`elementId\`**: the MCP sets the correct source and fills the
339
- builder's **param defaults** (e.g. \`addNotification\` gets \`autoDismiss:true\`, \`autoDismissTimeout:5000\`,
340
- \`placement:"top-right"\`, \`appeareance:"success"\`) for any params you leave out. Use **only** the params each
341
- callback declares (exact spelling) — for \`addNotification\` the visible text goes in \`content\`; there is **no**
342
- \`title\`/\`message\`/\`type\` param, and any unknown key is dropped. See the full param schema for each callback under
343
- \`globalCallbacks\` in \`plitzi://interactions/{env}\`.
344
- - **Two \`setState\`s — do not mix them:** the **element** \`setState\` (nodeType \`callback\`, on an element,
345
- category/key/value/revertOnFinish) changes THAT element's attribute/state and is what you want to change a button's
346
- label or disabled flag. The **global** \`setState\` (nodeType \`globalCallback\`, source \`state\`, key/type/value)
347
- writes \`runtime.state.<key>\`. They share a name but have different node types AND different params.
348
- - \`utility\` — a built-in utility action (no element/source module); nodeType \`utility\`. Use the **exact** param
349
- names: \`delayTime\` waits \`time\` milliseconds (**not** \`delay\`), \`twigTemplate\` (\`returnMode\`, \`template\`),
350
- \`webHook\` (\`url\`, \`method\`, …). See \`utilities\` in \`plitzi://interactions/{env}\`.
351
-
352
- **A param value can be a data binding.** Any interaction param may hold a \`{{ source }}\` token instead of a literal —
353
- it resolves at runtime exactly like a prop binding, using the same source grammar (\`<type>_<idRef>.<path>\`, or a
354
- module source like \`navigation\`/\`state\`). This is how a step reacts to *the data in context*: inside a \`listItem\`,
355
- a click on a row can show \`addNotification\` with \`content: "{{ list_<idRef>.item.name }}"\` — the clicked row's field.
356
- The value follows the source's type, so a token is valid even where a param expects a boolean/number. Copy/paste of an
357
- element repoints these tokens to the new idRefs automatically, along with the element's bindings.
358
-
359
- **Navigating between pages — prefer the \`Link\` element over an interaction.** For a plain "go to page X" the right
360
- tool is a \`link\` element (a container, see *Pages & folders*), not a \`navigate\` interaction step. Use the
361
- \`navigate\` globalCallback only when the navigation is one step of a larger flow (e.g. submit a form, then go).
362
-
363
- Tools:
364
- - \`upsertInteractionFlow\` — create or replace one flow. The FIRST node must be a \`trigger\`. Pass \`flowId\` (the
365
- trigger's node id) to replace an existing flow. Example (elementId omitted — the MCP wires it to \`space\` and fills
366
- the notification defaults):
367
- \`{ "type": "upsertInteractionFlow", "pageRef": "home", "ref": "cta", "nodes": [
368
- { "nodeType": "trigger", "action": "onClick", "title": "Click" },
369
- { "nodeType": "globalCallback", "action": "addNotification", "title": "Notify",
370
- "params": { "content": "Saved!" } } ] }\`.
371
- - \`patchInteractionNode\` — change one step in place (by \`nodeId\`); \`params\` merge onto the node.
372
-
373
- **Disable vs delete a step — do not confuse them (three different intents):**
374
- - **Disable / deactivate / turn off a step** (keep it in the flow, just stop it running): \`patchInteractionNode\`
375
- with \`{ "enabled": false }\`. Re-enable with \`{ "enabled": true }\`. This is NOT a deletion — the step stays.
376
- - **Remove one step** from a flow: \`deleteInteraction\` with \`nodeId\` (its neighbors are re-linked).
377
- - **Remove the whole flow**: \`deleteInteraction\` with \`flowId\` (the trigger node id).
378
-
379
- So "deactivate the addNotification step" means \`patchInteractionNode { enabled: false }\` — never delete the step, and
380
- never delete the flow. \`deleteInteraction\` is **destructive and not undoable**: only use it when the user asked to
381
- *remove* something, and **confirm with the user before deleting** a step or a flow.
382
-
383
- Discover valid actions in \`plitzi://interactions/{env}\`: \`actions\` = observed, \`globalCallbacks\` /
384
- \`elementCallbacks\` / \`utilities\` = the built-in vocabularies with their full param schema, so you know the exact
385
- node type and valid params per action. An element read lists its flows as ordered nodes (each with its \`id\` and
386
- \`enabled\`), so a follow-up patch/delete needs no extra read.
387
-
388
- ## Pages & folders
389
- - **Always set a \`slug\` when creating a page** (\`upsertPage\`) — it is the page's URL path and good practice for a
390
- clean, stable route (e.g. \`"pricing"\` or \`"posts/:postId"\`). Omit it and the page ref is used as the slug,
391
- and \`plitzi_validate\`/\`plitzi_apply\` warn so you remember to set a meaningful one.
392
- - **A page slug is RELATIVE — do NOT start it with \`/\`.** The runtime prepends the leading slash (and any folder
393
- path) itself, so a leading slash doubles it. Write \`"pricing"\`, not \`"/pricing"\`. (upsertPage strips a leading
394
- slash for you, but write it relative.)
395
- - **Dynamic pages — route params.** A slug segment written \`:name\` (e.g. \`"posts/:postId"\`) is a **route param**,
396
- exactly like React Router. On that page it is readable **two ways**: as \`{{name}}\` inside a prop, and as the
397
- data-binding source **\`navigation.routeParams.name\`** (the \`navigation\` module source, global — bindable
398
- anywhere). So a blog is a \`"posts"\` list page plus a \`"posts/:postId"\` detail page whose \`apiContainer\` query
399
- binds \`navigation.routeParams.postId\` to fetch that one post. (\`navigation.queryParams.<name>\` exposes \`?query=\`
400
- string params the same way.)
401
- - **Navigate with the \`Link\` element, not an interaction.** \`link\` is a **container** — it wraps any children and
402
- navigates on click, so it is the default way to move between pages. Its \`mode\`: \`"page"\` links to another space
403
- page (set \`href\` to the target page, folder path resolved for you); \`"internal"\` takes a path inside the space and
404
- resolves \`{{token}}\` templates in it, so a row's "view" link is \`mode:"internal", href:"posts/{{postId}}"\`;
405
- \`"external"\` is a full URL. \`target\` is \`self\`/\`blank\`/\`parent\`/\`top\`. Reach for the \`navigate\` globalCallback
406
- only when navigation must be **one step inside a larger interaction flow** (e.g. save, then go) — for a plain link,
407
- use \`link\`.
408
-
409
- Pages can be grouped into **folders** (the sidebar tree). A folder is \`{ ref, name, slug, parentId? }\`; its \`ref\`
410
- **is its id** (there is no separate idRef), and that id is what a page and a nested folder reference.
411
- - **Folder slugs PREPEND to the page URL — this is how nested URLs are built.** The full path is each ancestor
412
- folder's slug plus the page slug, joined by \`/\`: a page at slug \`"1-1-1"\` inside \`folder-1\` > \`folder-1-1\`
413
- resolves to \`/folder-1/folder-1-1/1-1-1\`. So a folder slug is part of the route; keep folder slugs relative too.
414
- - Create/rename/move a folder with \`upsertFolder\` (the \`ref\` you pass on create becomes its id — pick a stable one
415
- like \`"blog"\`). Nest it under another with \`parentId\` (a folder ref); \`parentId: null\` moves it back to the root.
416
- - Put a page in a folder with \`upsertPage\`'s \`folder\` (a folder ref). A page's \`folder\` is always either **empty
417
- (root)** or an **existing folder id**: \`folder: null\` or \`folder: ""\` moves it to the root, and any other value
418
- must resolve to a folder that already exists or is created earlier in the same batch — an unknown folder is
419
- rejected, never stored.
420
- - \`deleteFolder\` removes a folder and **promotes its contents up one level** — its child folders and its pages move
421
- to its parent (or the root). A folder cannot be nested under itself or one of its descendants.
422
- - **Disable a page** with \`upsertPage\`'s \`enabled: false\`; \`enabled: true\` re-enables it (defaults to enabled, and
423
- a page read reports its current \`enabled\`). Disabling only affects the **published SDK runtime** — the page stops
424
- being routable/accessible to end users. It stays fully **editable here**: you can still read it and apply any op to
425
- a disabled page. This does not delete it — \`deletePage\` does.
426
-
427
- ## Settings
428
- Space-level configuration lives in \`plitzi://settings/{env}\` and is edited with a single **\`patchSettings\`** op
429
- (merge — only the fields you pass change):
430
- - \`customCss\` — **raw global CSS** injected for the whole space. Use it only for genuinely site-wide rules
431
- (\`@keyframes\`, \`@font-face\`, resets). To style an element, write a **definition** and attach it — never customCss.
432
- - \`keepState\` / \`stateStorage\` — persist element state across reloads (\`localStorage\`/\`sessionStorage\`).
433
- - **User provider / auth**: \`userProvider\` (\`auth0\`|\`basic\`|\`custom\`|\`""\` to disable), \`auth0Domain\`,
434
- \`auth0ClientId\`, \`tokenStorage\`, and the \`loginUrl\`/\`userUrl\`/\`refreshUrl\`/\`logoutUrl\` + \`detailsPath\`/
435
- \`tokenPath\`/\`expirationTimePath\` mapping. Example — inject a keyframe globally:
436
- \`{ "type": "patchSettings", "customCss": "@keyframes spin { to { transform: rotate(360deg); } }" }\`.
437
-
438
- ## Semantics
439
- - **props are fully replaced** on \`upsertElement\`: send every prop you want to keep. To change only some props,
440
- use **\`patchElement\`** — it merges \`props\`/\`style\` onto the existing element (listed keys change, \`null\` unsets
441
- a key, everything else is preserved) and never creates. Combined with \`plitzi_search\` (which returns the ref +
442
- stateVersion), a targeted edit is two calls with no read.
443
- - **definition CSS is fully replaced** on \`upsertDefinition\`: send every property you want to keep. To change only
444
- some declarations, use **\`patchDefinition\`** — it merges CSS per breakpoint/state/variant/slot onto the existing
445
- definition (listed keys change, \`null\` removes a property, everything else is preserved) and never creates.
446
- Example — recolor one definition without resending it: \`{ "type": "patchDefinition", "ref": "btn-x",
447
- "desktop": { "background-color": "#111" } }\`.
448
- - **Atomic batches**: if any operation fails, \`plitzi_apply\` persists nothing.
449
- - **Every resource you touch must be malformation-free — pre-existing errors block the save.** When your batch edits
450
- an element (or a definition/global/id style), the validator also checks the resource's **current stored content**
451
- for malformations — a broken transformer action, a malformed interaction node, invalid CSS — even in parts your
452
- edit does not touch. Such a finding is reported as a \`Pre-existing malformation in <resource>: …\` **error**, and
453
- \`plitzi_apply\` rejects the batch until it is fixed. These are **not caused by your change** (the message says so)
454
- — do not be confused; fix them **in the same batch** and re-apply. Because the check runs on the resulting state,
455
- including the fix in your batch is exactly what unblocks the save. (Advisory issues — an unobserved source/action
456
- name that may still be a valid plugin, a binding target a plugin manifest does not list — come back as
457
- \`Pre-existing issue …\` **warnings** and do not block.)
458
- - **Optimistic concurrency — read before you write, and prove your read is current.** Editing a resource means you
459
- read it first, so you hold its \`stateVersion\`. **Always pass \`expectedResourceVersions\`** (URI → the stateVersion
460
- you read) for every resource your batch changes. If another agent edited it in the meantime, the live version no
461
- longer matches and apply is **rejected with a conflict** — nothing persists. Then re-read the reported resources
462
- (their new content + version) and retry on top of the fresh state. This is exactly how a file editor forces a
463
- re-read after a stale write: it is what keeps concurrent agents from silently overwriting each other's changes, so
464
- never omit it "to save a call".
465
- `;
466
- //#endregion
467
- export { guideQuickstart, guideText, serverInstructions, widgetsOnlyInstructions };
@@ -1,123 +0,0 @@
1
- import { applyBuiltinCallback } from "../catalogs/builtinCallbacks.js";
2
- import { applyElementCallback } from "../catalogs/builtinElementCallbacks.js";
3
- import { applyUtility } from "../catalogs/builtinUtilities.js";
4
- import { generateObjectId } from "./space.js";
5
- //#region src/modules/mcp/helpers/interactions.ts
6
- var BINDING_CATEGORIES = [
7
- "attributes",
8
- "style",
9
- "initialState"
10
- ];
11
- var NULLISH_ELEMENT_IDS = /* @__PURE__ */ new Set([
12
- "undefined",
13
- "null",
14
- ""
15
- ]);
16
- var isNonEmptyObject = (value) => value !== void 0 && Object.keys(value).length > 0;
17
- var nodeToAI = (node) => {
18
- const ai = {
19
- id: node.id,
20
- title: node.title,
21
- nodeType: node.type,
22
- action: node.action
23
- };
24
- if (isNonEmptyObject(node.params)) ai.params = node.params;
25
- if (!node.enabled) ai.enabled = false;
26
- if (node.when !== void 0) ai.when = node.when;
27
- if (node.elementId && node.elementId !== node.id) ai.elementId = node.elementId;
28
- if (isNonEmptyObject(node.preview)) ai.preview = node.preview;
29
- return ai;
30
- };
31
- var orderFlow = (nodes) => {
32
- const byId = new Map(nodes.map((n) => [n.id, n]));
33
- const head = nodes.find((n) => !n.beforeNode || !byId.has(n.beforeNode)) ?? nodes[0];
34
- const ordered = [];
35
- const seen = /* @__PURE__ */ new Set();
36
- let current = head;
37
- while (current && !seen.has(current.id)) {
38
- seen.add(current.id);
39
- ordered.push(current);
40
- current = current.afterNode ? byId.get(current.afterNode) : void 0;
41
- }
42
- for (const node of nodes) if (!seen.has(node.id)) ordered.push(node);
43
- return ordered;
44
- };
45
- var flowsFromInteractions = (interactions) => {
46
- if (!interactions || Object.keys(interactions).length === 0) return [];
47
- const byFlow = /* @__PURE__ */ new Map();
48
- for (const node of Object.values(interactions)) {
49
- const key = node.flowId || node.id;
50
- const list = byFlow.get(key);
51
- if (list) list.push(node);
52
- else byFlow.set(key, [node]);
53
- }
54
- const flows = [];
55
- for (const [flowId, nodes] of byFlow) flows.push({
56
- flowId,
57
- nodes: orderFlow(nodes).map(nodeToAI)
58
- });
59
- return flows;
60
- };
61
- var newNodeId = () => `node_${generateObjectId()}`;
62
- /** Materialize an ordered list of nodes into the stored linked-node map for ONE flow: assign ids where missing,
63
- * set flowId to the trigger id, and recompute beforeNode/afterNode from the order. `ownerId` is the default
64
- * source element for callbacks that name none. */
65
- var materializeFlow = (nodes, ownerId) => {
66
- const ids = nodes.map((node) => node.id || newNodeId());
67
- const flowId = ids[0];
68
- const record = {};
69
- nodes.forEach((node, i) => {
70
- let params = node.params ?? {};
71
- const supplied = NULLISH_ELEMENT_IDS.has(node.elementId ?? "") ? void 0 : node.elementId;
72
- let elementId = node.nodeType === "utility" ? null : supplied ?? ownerId;
73
- if (node.nodeType === "globalCallback") {
74
- const builtin = applyBuiltinCallback(node.action, params);
75
- if (builtin.source) {
76
- elementId = builtin.source;
77
- params = builtin.params;
78
- }
79
- } else if (node.nodeType === "callback") params = applyElementCallback(node.action, params).params;
80
- else if (node.nodeType === "utility") params = applyUtility(node.action, params).params;
81
- const interaction = {
82
- id: ids[i],
83
- title: node.title,
84
- type: node.nodeType,
85
- action: node.action,
86
- params,
87
- preview: node.preview ?? {},
88
- elementId,
89
- beforeNode: i > 0 ? ids[i - 1] : "",
90
- afterNode: i < ids.length - 1 ? ids[i + 1] : "",
91
- flowId,
92
- enabled: node.enabled ?? true
93
- };
94
- if (node.when !== void 0) interaction.when = node.when;
95
- record[ids[i]] = interaction;
96
- });
97
- return {
98
- flowId,
99
- record
100
- };
101
- };
102
- var bindingToAI = (binding) => {
103
- const ai = {
104
- id: binding.id,
105
- to: binding.to,
106
- source: binding.source
107
- };
108
- if (binding.transformers && binding.transformers.length > 0) ai.transformers = binding.transformers;
109
- if (binding.when !== void 0) ai.when = binding.when;
110
- if (binding.enabled === false) ai.enabled = false;
111
- return ai;
112
- };
113
- var bindingsToAI = (bindings) => {
114
- if (!bindings) return;
115
- const result = {};
116
- for (const category of BINDING_CATEGORIES) {
117
- const list = bindings[category];
118
- if (list && list.length > 0) result[category] = list.map(bindingToAI);
119
- }
120
- return Object.keys(result).length > 0 ? result : void 0;
121
- };
122
- //#endregion
123
- export { BINDING_CATEGORIES, NULLISH_ELEMENT_IDS, bindingToAI, bindingsToAI, flowsFromInteractions, materializeFlow, newNodeId };