@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,314 @@
1
+ //#region src/modules/mcp/helpers/space.ts
2
+ var cloneSpace = (space) => ({
3
+ schema: structuredClone(space.schema),
4
+ style: structuredClone(space.style),
5
+ connectors: structuredClone(space.connectors),
6
+ ...space.catalog ? { catalog: space.catalog } : {}
7
+ });
8
+ var emptySpace = () => ({
9
+ schema: {
10
+ flat: {},
11
+ definition: {
12
+ name: "",
13
+ permanentUrl: ""
14
+ },
15
+ variables: [],
16
+ settings: { customCss: "" },
17
+ pages: [],
18
+ pageFolders: []
19
+ },
20
+ style: {
21
+ platform: {
22
+ desktop: {},
23
+ tablet: {},
24
+ mobile: {}
25
+ },
26
+ theme: {
27
+ default: "system",
28
+ schemes: ["light", "dark"]
29
+ },
30
+ variables: {},
31
+ cache: ""
32
+ },
33
+ connectors: []
34
+ });
35
+ /** A connector by the identifier a provider element stores in its `connector` attribute. */
36
+ var findConnectorEntry = (space, ref) => space.connectors.find((entry) => entry.id === ref);
37
+ var slugify = (value) => value.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "";
38
+ /** A value when it is a string, otherwise undefined — for the many attributes typed as `unknown` that are strings
39
+ * in practice (name, slug, subType, dom id…). */
40
+ var strOr = (value) => typeof value === "string" ? value : void 0;
41
+ /** Display name of a page or element: its `name` attribute when set, otherwise its definition label. */
42
+ var nameOf = (el) => strOr(el.attributes.name) ?? el.definition.label;
43
+ /** Stable, human-readable ref for a page: its idRef, then slug, then a slugified label. A page without an idRef is
44
+ * still addressable — unlike a data source, a page ref has meaningful fallbacks the agent can read off the tree. */
45
+ var pageRefOf = (el) => {
46
+ if (el.idRef) return el.idRef;
47
+ const slug = strOr(el.attributes.slug)?.trim();
48
+ if (slug) return slugify(slug);
49
+ if (el.attributes.default === true) return "home";
50
+ return slugify(nameOf(el)) || el.id;
51
+ };
52
+ /** Stable ref for ADDRESSING a non-page element in the tree: its idRef when present, otherwise the opaque id so an
53
+ * element without one is still reachable — the agent needs to name it to give it an idRef in the first place.
54
+ * This is not the wiring key: the runtime wires interactions and data sources by idRef only, so an element
55
+ * addressed here by its id alone publishes no source and takes no interactions (see `getSourceName`). */
56
+ var elementRefOf = (el) => el.idRef ?? el.id;
57
+ var buildIndex = (schema) => {
58
+ const flat = schema.flat;
59
+ const lookup = (id) => flat[id];
60
+ const pageIds = new Set(schema.pages);
61
+ for (const el of Object.values(flat)) if (el.definition.type === "page") pageIds.add(el.id);
62
+ const pageElements = [];
63
+ const pageByRef = /* @__PURE__ */ new Map();
64
+ const elementByRef = /* @__PURE__ */ new Map();
65
+ for (const el of Object.values(flat)) if (pageIds.has(el.id)) {
66
+ pageElements.push(el);
67
+ const ref = pageRefOf(el);
68
+ if (!pageByRef.has(ref)) pageByRef.set(ref, el);
69
+ if (!pageByRef.has(el.id)) pageByRef.set(el.id, el);
70
+ } else {
71
+ const ref = elementRefOf(el);
72
+ if (!elementByRef.has(ref)) elementByRef.set(ref, el);
73
+ if (!elementByRef.has(el.id)) elementByRef.set(el.id, el);
74
+ }
75
+ const pageOf = /* @__PURE__ */ new Map();
76
+ for (const page of pageElements) {
77
+ pageOf.set(page.id, page.id);
78
+ const stack = [...page.definition.items ?? []];
79
+ while (stack.length > 0) {
80
+ const id = stack.pop();
81
+ if (id === void 0 || pageOf.has(id)) continue;
82
+ const el = lookup(id);
83
+ if (!el) continue;
84
+ pageOf.set(id, page.id);
85
+ for (const childId of el.definition.items ?? []) stack.push(childId);
86
+ }
87
+ }
88
+ return {
89
+ pageIds,
90
+ pageElements,
91
+ pageByRef,
92
+ elementByRef,
93
+ pageOf,
94
+ detailCache: /* @__PURE__ */ new Map()
95
+ };
96
+ };
97
+ var indexCache = /* @__PURE__ */ new WeakMap();
98
+ /** The index for a schema, built once and memoized on the schema object. */
99
+ var spaceIndex = (schema) => {
100
+ let index = indexCache.get(schema);
101
+ if (!index) {
102
+ index = buildIndex(schema);
103
+ indexCache.set(schema, index);
104
+ }
105
+ return index;
106
+ };
107
+ var cachedIndex = (schema) => indexCache.get(schema);
108
+ /** A new non-page element was created under `pageId`. */
109
+ var indexAddElement = (schema, el, pageId) => {
110
+ const index = cachedIndex(schema);
111
+ if (!index) return;
112
+ index.elementByRef.set(el.id, el);
113
+ if (el.idRef) index.elementByRef.set(el.idRef, el);
114
+ index.pageOf.set(el.id, pageId);
115
+ index.detailCache.clear();
116
+ };
117
+ /** These non-page elements were deleted (an element and its descendants). */
118
+ var indexRemoveElements = (schema, els) => {
119
+ const index = cachedIndex(schema);
120
+ if (!index) return;
121
+ for (const el of els) {
122
+ index.elementByRef.delete(el.id);
123
+ if (el.idRef) index.elementByRef.delete(el.idRef);
124
+ index.pageOf.delete(el.id);
125
+ }
126
+ index.detailCache.clear();
127
+ };
128
+ /** An existing element was just given an idRef (it had none), so it becomes addressable by that ref. */
129
+ var indexReRefElement = (schema, el) => {
130
+ const index = cachedIndex(schema);
131
+ if (!index) return;
132
+ if (el.idRef) index.elementByRef.set(el.idRef, el);
133
+ index.detailCache.clear();
134
+ };
135
+ /** A new page element was created. */
136
+ var indexAddPage = (schema, page) => {
137
+ const index = cachedIndex(schema);
138
+ if (!index) return;
139
+ index.pageIds.add(page.id);
140
+ index.pageElements.push(page);
141
+ index.pageByRef.set(page.id, page);
142
+ index.pageByRef.set(pageRefOf(page), page);
143
+ index.pageOf.set(page.id, page.id);
144
+ index.detailCache.clear();
145
+ };
146
+ /** A page and its `descendants` (its non-page elements) were deleted. */
147
+ var indexRemovePage = (schema, page, descendants) => {
148
+ const index = cachedIndex(schema);
149
+ if (!index) return;
150
+ index.pageIds.delete(page.id);
151
+ const at = index.pageElements.findIndex((p) => p.id === page.id);
152
+ if (at >= 0) index.pageElements.splice(at, 1);
153
+ index.pageByRef.delete(page.id);
154
+ index.pageByRef.delete(pageRefOf(page));
155
+ index.pageOf.delete(page.id);
156
+ for (const el of descendants) {
157
+ index.elementByRef.delete(el.id);
158
+ if (el.idRef) index.elementByRef.delete(el.idRef);
159
+ index.pageOf.delete(el.id);
160
+ }
161
+ index.detailCache.clear();
162
+ };
163
+ /** A page's slug/name/default changed; re-key its pageByRef entry if that changed its ref. `oldRef` is the ref
164
+ * computed BEFORE the attribute change. */
165
+ var indexReRefPage = (schema, page, oldRef) => {
166
+ const index = cachedIndex(schema);
167
+ if (!index) return;
168
+ const newRef = pageRefOf(page);
169
+ if (newRef !== oldRef) {
170
+ index.pageByRef.delete(oldRef);
171
+ index.pageByRef.set(newRef, page);
172
+ index.detailCache.clear();
173
+ }
174
+ };
175
+ /** A move reparented an element within its page: the ref/page maps are unchanged, but the moved element's
176
+ * parentRef and both parents' childRefs did change, so their memoized detail must be dropped. */
177
+ var indexInvalidateDetails = (schema) => {
178
+ cachedIndex(schema)?.detailCache.clear();
179
+ };
180
+ var isPageElement = (schema, el) => spaceIndex(schema).pageIds.has(el.id) || el.definition.type === "page";
181
+ var getPageElements = (schema) => spaceIndex(schema).pageElements;
182
+ /** Finds a page by its semantic ref (idRef/slug/…) or its raw id, so legacy schemas without an idRef still resolve. */
183
+ var findPageByRef = (schema, pageRef) => spaceIndex(schema).pageByRef.get(pageRef);
184
+ /** Find any non-page element by its semantic ref (idRef) or raw id, across the whole space. */
185
+ var findElementByRef = (schema, ref) => spaceIndex(schema).elementByRef.get(ref);
186
+ var pageFoldersOf = (schema) => {
187
+ schema.pageFolders ??= [];
188
+ return schema.pageFolders;
189
+ };
190
+ /** Resolve a folder by its id, or (for agent convenience) by an exact name or slug when that is unambiguous. */
191
+ var findFolderByRef = (schema, ref) => {
192
+ const folders = pageFoldersOf(schema);
193
+ const byId = folders.find((f) => f.id === ref);
194
+ if (byId) return byId;
195
+ const byName = folders.filter((f) => f.name === ref);
196
+ if (byName.length === 1) return byName[0];
197
+ const bySlug = folders.filter((f) => f.slug === ref);
198
+ return bySlug.length === 1 ? bySlug[0] : void 0;
199
+ };
200
+ /** Order folders so every parent precedes its children — the invariant the schema validator enforces on
201
+ * pageFolders (a parentId must appear earlier in the array). Cycles (rejected upstream) are left in place. */
202
+ var sortFolders = (folders) => {
203
+ const byId = new Map(folders.map((f) => [f.id, f]));
204
+ const placed = /* @__PURE__ */ new Set();
205
+ const result = [];
206
+ const visit = (folder, ancestry) => {
207
+ if (placed.has(folder.id)) return;
208
+ const parent = folder.parentId ? byId.get(folder.parentId) : void 0;
209
+ if (parent && !ancestry.has(parent.id)) visit(parent, new Set(ancestry).add(folder.id));
210
+ if (!placed.has(folder.id)) {
211
+ placed.add(folder.id);
212
+ result.push(folder);
213
+ }
214
+ };
215
+ for (const folder of folders) visit(folder, /* @__PURE__ */ new Set([folder.id]));
216
+ return result;
217
+ };
218
+ /** Ancestor ids of a folder (following parentId), stopping on a cycle. Used to reject a parent change that would
219
+ * make a folder its own ancestor. */
220
+ var folderAncestorIds = (folders, startParentId) => {
221
+ const byId = new Map(folders.map((f) => [f.id, f]));
222
+ const chain = [];
223
+ const seen = /* @__PURE__ */ new Set();
224
+ let current = startParentId ? byId.get(startParentId) : void 0;
225
+ while (current && !seen.has(current.id)) {
226
+ seen.add(current.id);
227
+ chain.push(current.id);
228
+ current = current.parentId ? byId.get(current.parentId) : void 0;
229
+ }
230
+ return chain;
231
+ };
232
+ /** Route params a page's slug binds (e.g. ":spaceId/update/*" → ["spaceId"]). These are valid {{name}}
233
+ * references on that page even though they are not space-level schema variables. */
234
+ var slugRouteParams = (slug) => {
235
+ const params = [];
236
+ for (const segment of slug.split("/")) if (segment.startsWith(":")) params.push(segment.slice(1).replace(/[*+?]+$/, ""));
237
+ return params;
238
+ };
239
+ /** Every route param bound by any page slug in the space (union), so {{name}} validation does not false-flag a
240
+ * page-scoped dynamic binding. */
241
+ var routeParamNames = (schema) => {
242
+ const params = /* @__PURE__ */ new Set();
243
+ for (const page of getPageElements(schema)) {
244
+ const slug = typeof page.attributes.slug === "string" ? page.attributes.slug : "";
245
+ for (const param of slugRouteParams(slug)) params.add(param);
246
+ }
247
+ return [...params];
248
+ };
249
+ /** Indexed lookup that reflects the runtime reality: a flat id may be dangling (rsc placeholders, stale items). */
250
+ var elementById = (schema, id) => schema.flat[id];
251
+ /** All element ids belonging to a page subtree (excluding the page root). */
252
+ var collectDescendants = (schema, rootId, acc) => {
253
+ const el = elementById(schema, rootId);
254
+ if (!el) return;
255
+ const childIds = el.definition.items ?? [];
256
+ for (const childId of childIds) if (elementById(schema, childId)) {
257
+ acc.push(childId);
258
+ collectDescendants(schema, childId, acc);
259
+ }
260
+ };
261
+ var descendantIds = (schema, pageRootId) => {
262
+ const acc = [];
263
+ collectDescendants(schema, pageRootId, acc);
264
+ return acc;
265
+ };
266
+ /** Resolve a ref to a concrete element within a page subtree (or the page root itself). Accepts either the
267
+ * semantic ref (idRef) or the raw element id, so schemas predating idRef keep working through their ids. */
268
+ var resolveRef = (schema, page, ref) => {
269
+ if (elementRefOf(page) === ref || pageRefOf(page) === ref || page.id === ref) return page;
270
+ const index = spaceIndex(schema);
271
+ const el = index.elementByRef.get(ref);
272
+ return el && index.pageOf.get(el.id) === page.id ? el : void 0;
273
+ };
274
+ /** Ordered children of an element, honoring definition.items and skipping dangling ids. */
275
+ var orderedChildren = (schema, el) => {
276
+ return (el.definition.items ?? []).map((id) => schema.flat[id]).filter((child) => Boolean(child));
277
+ };
278
+ /** The page ref an element belongs to. 'unknown' when it has no page ancestor. */
279
+ var pageRefOfElement = (schema, el) => {
280
+ const pageId = spaceIndex(schema).pageOf.get(el.id);
281
+ const page = pageId ? schema.flat[pageId] : void 0;
282
+ return page ? pageRefOf(page) : "unknown";
283
+ };
284
+ /** Total number of descendant elements under a subtree (excluding the root). */
285
+ var descendantCount = (schema, rootId) => descendantIds(schema, rootId).length;
286
+ var emptySpaceMessage = "Space data not available";
287
+ /** The code a space-dependent answer carries when the connection reaches no space, so both the agent and a host UI
288
+ * can tell "this connection cannot do that" from "the call failed". */
289
+ var noSpaceErrorCode = "NO_SPACE_ATTACHED";
290
+ var readOnlyGrantErrorCode = "READ_ONLY_GRANT";
291
+ var unauthorizedSpaceMessage = "This connection has no space attached (a guest or widgets-only grant, or a token that carries no space), so NOTHING in a space can be read or edited — every other space tool will fail the same way, do not retry them. Use plitzi_render instead: it builds a self-contained widget offline, with no space, backend or account (read plitzi://render/guide). To edit a real space, the user must reconnect the integration and grant access to one.";
292
+ /** Raised when a space-dependent operation runs on a connection that resolves no spaceId. A type of its own so the
293
+ * host answers it as a STATE of the connection — a plain result the agent reads — instead of letting it surface as
294
+ * a failed call, which hosts render to the user as "cannot connect to this server". */
295
+ var NoSpaceError = class extends Error {
296
+ constructor() {
297
+ super(unauthorizedSpaceMessage);
298
+ this.name = "NoSpaceError";
299
+ }
300
+ };
301
+ var readOnlyGrantMessage = "This connection may READ this space but not change it: its token is a read-only (render) credential, or the member who authorized it no longer has permission to edit this space. Every write tool will fail the same way, do not retry them — reads still work. To edit, the user must reconnect the integration and grant edit access.";
302
+ /** Raised when a write runs under a grant that carries no write authority. Like NoSpaceError this is a STATE of
303
+ * the connection rather than a failed call, so the host renders it as a result the agent can act on. */
304
+ var ReadOnlyGrantError = class extends Error {
305
+ constructor() {
306
+ super(readOnlyGrantMessage);
307
+ this.name = "ReadOnlyGrantError";
308
+ }
309
+ };
310
+ var generateObjectId = () => {
311
+ return `${Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0")}${Array.from({ length: 16 }, () => Math.floor(Math.random() * 16).toString(16)).join("")}`;
312
+ };
313
+ //#endregion
314
+ export { NoSpaceError, ReadOnlyGrantError, cloneSpace, descendantCount, descendantIds, elementById, elementRefOf, emptySpace, emptySpaceMessage, findConnectorEntry, findElementByRef, findFolderByRef, findPageByRef, folderAncestorIds, generateObjectId, getPageElements, indexAddElement, indexAddPage, indexInvalidateDetails, indexReRefElement, indexReRefPage, indexRemoveElements, indexRemovePage, isPageElement, nameOf, noSpaceErrorCode, orderedChildren, pageFoldersOf, pageRefOf, pageRefOfElement, readOnlyGrantErrorCode, readOnlyGrantMessage, resolveRef, routeParamNames, slugRouteParams, slugify, sortFolders, spaceIndex, strOr, unauthorizedSpaceMessage };
@@ -0,0 +1,33 @@
1
+ import { Env } from '../types';
2
+ export declare const guideUri = "plitzi://guide";
3
+ export declare const typesUri = "plitzi://types";
4
+ export declare const cssPropertiesUri = "plitzi://css-properties";
5
+ export declare const primerUri: (env: Env) => string;
6
+ export declare const pagesUri: (env: Env) => string;
7
+ export declare const pageUri: (env: Env, ref: string) => string;
8
+ export declare const pageStylesUri: (env: Env, ref: string) => string;
9
+ export declare const elementUri: (env: Env, ref: string) => string;
10
+ export declare const schemaVarsUri: (env: Env) => string;
11
+ export declare const settingsUri: (env: Env) => string;
12
+ export declare const interactionsUri: (env: Env) => string;
13
+ export declare const dataSourcesUri: (env: Env) => string;
14
+ /** Worked manifests + the template vocabulary. Space-independent, hence no env — and a distinct root, so a
15
+ * connector that happened to be named "presets" could never shadow it. */
16
+ export declare const connectorPresetsUri = "plitzi://connector-presets";
17
+ export declare const connectorsUri: (env: Env) => string;
18
+ export declare const connectorUri: (env: Env, ref: string) => string;
19
+ export declare const foldersUri: (env: Env) => string;
20
+ export declare const folderUri: (env: Env, ref: string) => string;
21
+ export declare const defsUri: (env: Env) => string;
22
+ export declare const defUri: (env: Env, ref: string) => string;
23
+ export declare const globalsUri: (env: Env) => string;
24
+ export declare const globalUri: (env: Env, componentType: string) => string;
25
+ export declare const idsUri: (env: Env) => string;
26
+ export declare const idUri: (env: Env, targetId: string) => string;
27
+ export declare const styleVarsUri: (env: Env) => string;
28
+ export declare const styleVarUri: (env: Env, category: string) => string;
29
+ export declare const aliasedRoots: string[];
30
+ export declare const itemTemplates: (env: Env) => string[];
31
+ /** The remainder of `uri` after `prefix`, or undefined when it does not start with it — so a resolver matches a
32
+ * family and extracts its ref in one step, without repeating the prefix string for both the startsWith and slice. */
33
+ export declare const afterPrefix: (uri: string, prefix: string) => string | undefined;
@@ -0,0 +1,50 @@
1
+ //#region src/modules/mcp/helpers/uris.ts
2
+ var guideUri = "plitzi://guide";
3
+ var typesUri = "plitzi://types";
4
+ var cssPropertiesUri = "plitzi://css-properties";
5
+ var primerUri = (env) => `plitzi://primer/${env}`;
6
+ var pagesUri = (env) => `plitzi://schema/${env}/pages`;
7
+ var pageUri = (env, ref) => `plitzi://schema/${env}/pages/${ref}`;
8
+ var elementUri = (env, ref) => `plitzi://schema/${env}/elements/${ref}`;
9
+ var schemaVarsUri = (env) => `plitzi://schema-variables/${env}`;
10
+ var settingsUri = (env) => `plitzi://settings/${env}`;
11
+ var interactionsUri = (env) => `plitzi://interactions/${env}`;
12
+ var dataSourcesUri = (env) => `plitzi://data-sources/${env}`;
13
+ /** Worked manifests + the template vocabulary. Space-independent, hence no env — and a distinct root, so a
14
+ * connector that happened to be named "presets" could never shadow it. */
15
+ var connectorPresetsUri = "plitzi://connector-presets";
16
+ var connectorsUri = (env) => `plitzi://connectors/${env}`;
17
+ var connectorUri = (env, ref) => `plitzi://connectors/${env}/${ref}`;
18
+ var foldersUri = (env) => `plitzi://folders/${env}`;
19
+ var folderUri = (env, ref) => `plitzi://folders/${env}/${ref}`;
20
+ var defsUri = (env) => `plitzi://definitions/${env}`;
21
+ var defUri = (env, ref) => `plitzi://definitions/${env}/${ref}`;
22
+ var globalsUri = (env) => `plitzi://global-styles/${env}`;
23
+ var globalUri = (env, componentType) => `plitzi://global-styles/${env}/${componentType}`;
24
+ var idsUri = (env) => `plitzi://id-styles/${env}`;
25
+ var idUri = (env, targetId) => `plitzi://id-styles/${env}/${targetId}`;
26
+ var styleVarsUri = (env) => `plitzi://style-variables/${env}`;
27
+ var styleVarUri = (env, category) => `plitzi://style-variables/${env}/${category}`;
28
+ var aliasedRoots = [
29
+ "definitions",
30
+ "global-styles",
31
+ "id-styles",
32
+ "style-variables",
33
+ "schema-variables",
34
+ "folders"
35
+ ];
36
+ var itemTemplates = (env) => [
37
+ pageUri(env, "{ref}"),
38
+ elementUri(env, "{ref}"),
39
+ defUri(env, "{ref}"),
40
+ globalUri(env, "{componentType}"),
41
+ idUri(env, "{targetId}"),
42
+ styleVarUri(env, "{category}"),
43
+ folderUri(env, "{ref}"),
44
+ connectorUri(env, "{ref}")
45
+ ];
46
+ /** The remainder of `uri` after `prefix`, or undefined when it does not start with it — so a resolver matches a
47
+ * family and extracts its ref in one step, without repeating the prefix string for both the startsWith and slice. */
48
+ var afterPrefix = (uri, prefix) => uri.startsWith(prefix) ? uri.slice(prefix.length) : void 0;
49
+ //#endregion
50
+ export { afterPrefix, aliasedRoots, connectorPresetsUri, connectorUri, connectorsUri, cssPropertiesUri, dataSourcesUri, defUri, defsUri, elementUri, folderUri, foldersUri, globalUri, globalsUri, guideUri, idUri, idsUri, interactionsUri, itemTemplates, pageUri, pagesUri, primerUri, schemaVarsUri, settingsUri, styleVarUri, styleVarsUri, typesUri };
@@ -0,0 +1,13 @@
1
+ export { createMcpServer, handleMcp, serveMcp, readMcpBody } from './handler';
2
+ export { readResource, resourceVersion, registerResources, buildTypeRegistry, cssProperties } from './resources';
3
+ export { apply, validate, search, read, validateOperations, operation, tools } from './tools';
4
+ export { computeVersion, buildAgentGuide } from './helpers';
5
+ export { createHttpPreviewClient } from './previewClient';
6
+ export { createHttpScreenshotClient } from './screenshotClient';
7
+ export type { McpRequestOptions } from './handler';
8
+ export type { HttpPreviewClientConfig } from './previewClient';
9
+ export type { HttpScreenshotClientConfig } from './screenshotClient';
10
+ export type { McpServerContext } from './server';
11
+ export type { ApplyInput, WriteResponse, Persisters, SearchInput, ReadInput, ReadResponse, ValidateInput, Operation, ToolDef, ToolContext } from './tools';
12
+ export type { Space } from './helpers';
13
+ export type * from './types';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { PreviewClient } from './types';
2
+ export type HttpPreviewClientConfig = {
3
+ /** Absolute URL of the SSR `/preview` endpoint. */
4
+ url: string;
5
+ /** Shared secret sent as `x-preview-secret`; must match the SSR server's `preview.secret`. */
6
+ secret?: string;
7
+ /** Injectable fetch (tests / non-global runtimes). Defaults to the global fetch. */
8
+ fetchImpl?: typeof fetch;
9
+ };
10
+ /** Default `PreviewClient`: POSTs the preview request to the SSR `/preview` endpoint over HTTP. Used when the
11
+ * MCP server is a separate process from the SSR renderer (the common case). A network/HTTP failure surfaces as
12
+ * an `ok:false` result rather than throwing, so the calling tool can degrade gracefully. */
13
+ export declare const createHttpPreviewClient: ({ url, secret, fetchImpl }: HttpPreviewClientConfig) => PreviewClient;
@@ -0,0 +1,31 @@
1
+ //#region src/modules/mcp/previewClient.ts
2
+ /** Default `PreviewClient`: POSTs the preview request to the SSR `/preview` endpoint over HTTP. Used when the
3
+ * MCP server is a separate process from the SSR renderer (the common case). A network/HTTP failure surfaces as
4
+ * an `ok:false` result rather than throwing, so the calling tool can degrade gracefully. */
5
+ var createHttpPreviewClient = ({ url, secret, fetchImpl = fetch }) => ({ async render(body) {
6
+ let res;
7
+ try {
8
+ res = await fetchImpl(url, {
9
+ method: "POST",
10
+ headers: {
11
+ "content-type": "application/json",
12
+ ...secret ? { "x-preview-secret": secret } : {}
13
+ },
14
+ body: JSON.stringify(body)
15
+ });
16
+ } catch (err) {
17
+ return {
18
+ ok: false,
19
+ error: "PREVIEW_UNREACHABLE",
20
+ message: `Preview endpoint unreachable: ${String(err)}`
21
+ };
22
+ }
23
+ if (!res.ok && res.status !== 422) return {
24
+ ok: false,
25
+ error: "PREVIEW_REQUEST_FAILED",
26
+ message: `Preview endpoint returned ${res.status}.`
27
+ };
28
+ return await res.json();
29
+ } });
30
+ //#endregion
31
+ export { createHttpPreviewClient };
@@ -0,0 +1,20 @@
1
+ import { ResourceProxy, ResourceProxySettings } from './types';
2
+ import { McpProxyOptions } from '../../../options';
3
+ import { SSRRequest } from '@plitzi/sdk-shared';
4
+ export declare const PROXY_PATH = "/__proxy";
5
+ /** What this deployment serves at its widget endpoint, or undefined when it serves none. A secret is what turns it
6
+ * on: without one the endpoint could not tell its own widgets' URLs from anyone else's, and an unsigned fetcher
7
+ * on a public origin is an open proxy. */
8
+ export declare const proxySettings: (proxy: McpProxyOptions | undefined) => ResourceProxySettings | undefined;
9
+ /** The proxy a tool rewrites through. The grants it mints carry the fingerprint of THIS request's credential, so
10
+ * they belong to this connection. */
11
+ export declare const requestProxy: (proxy: McpProxyOptions | undefined, req: SSRRequest) => ResourceProxy | undefined;
12
+ /** The proxy the ENDPOINT itself mints with, while serving an API answer that carries URLs of its own. The request
13
+ * it is serving comes from a sandboxed iframe and presents no credential, so the connection is the one signed into
14
+ * the grant being served — the widget's own — rather than one read off a header. */
15
+ export declare const grantingProxy: (settings: ResourceProxySettings, req: SSRRequest, identity: string) => ResourceProxy | undefined;
16
+ /** The proxy THIS tool may use, or undefined — the single place that decides it, so a tool cannot reach the
17
+ * endpoint by being wired to it later. A render authors a throwaway widget, so rewriting its URLs is invisible
18
+ * and lasts as long as the widget does; a tool that WRITES a space (plitzi_apply) would persist those URLs into
19
+ * content the user owns, which is why it is not on the list unless a deployment puts it there deliberately. */
20
+ export declare const proxyForTool: (proxy: ResourceProxy | undefined, tool: string) => ResourceProxy | undefined;
@@ -0,0 +1,62 @@
1
+ import { connectionId } from "./sign.js";
2
+ import { DEFAULT_PROXY_TOOLS } from "./types.js";
3
+ import { requestOrigin } from "@plitzi/sdk-server/kernel";
4
+ //#region src/modules/mcp/proxy/config.ts
5
+ var PROXY_PATH = "/__proxy";
6
+ var MAX_BYTES = 8388608;
7
+ var TTL_SECONDS = 604800;
8
+ /** What this deployment serves at its widget endpoint, or undefined when it serves none. A secret is what turns it
9
+ * on: without one the endpoint could not tell its own widgets' URLs from anyone else's, and an unsigned fetcher
10
+ * on a public origin is an open proxy. */
11
+ var proxySettings = (proxy) => {
12
+ if (!proxy?.secret || proxy.enabled === false) return;
13
+ return {
14
+ path: proxy.path ?? "/__proxy",
15
+ secret: proxy.secret,
16
+ maxBytes: proxy.maxBytes ?? MAX_BYTES,
17
+ ttl: proxy.ttl ?? TTL_SECONDS,
18
+ tools: proxy.tools ?? DEFAULT_PROXY_TOOLS,
19
+ baseUrl: proxy.baseUrl
20
+ };
21
+ };
22
+ /** The endpoint as a widget must address it: absolute, because the page runs on the host's origin and a relative
23
+ * URL there points at the host. Falls back to the origin this request came in on, which is the right one whenever
24
+ * the MCP server owns its sub-domain; a deployment reached under a different public name sets `proxy.baseUrl`. */
25
+ var endpointOf = (settings, req) => {
26
+ const base = (settings.baseUrl ?? requestOrigin(req)).replace(/\/$/, "");
27
+ return base ? `${base}${settings.path}` : void 0;
28
+ };
29
+ /** The proxy a tool rewrites through. The grants it mints carry the fingerprint of THIS request's credential, so
30
+ * they belong to this connection. */
31
+ var requestProxy = (proxy, req) => {
32
+ const settings = proxySettings(proxy);
33
+ const endpoint = settings && endpointOf(settings, req);
34
+ if (!settings || !endpoint) return;
35
+ return {
36
+ endpoint,
37
+ secret: settings.secret,
38
+ identity: connectionId(req.headers.authorization, settings.secret),
39
+ ttl: settings.ttl,
40
+ tools: settings.tools
41
+ };
42
+ };
43
+ /** The proxy the ENDPOINT itself mints with, while serving an API answer that carries URLs of its own. The request
44
+ * it is serving comes from a sandboxed iframe and presents no credential, so the connection is the one signed into
45
+ * the grant being served — the widget's own — rather than one read off a header. */
46
+ var grantingProxy = (settings, req, identity) => {
47
+ const endpoint = endpointOf(settings, req);
48
+ return endpoint ? {
49
+ endpoint,
50
+ secret: settings.secret,
51
+ identity,
52
+ ttl: settings.ttl,
53
+ tools: settings.tools
54
+ } : void 0;
55
+ };
56
+ /** The proxy THIS tool may use, or undefined — the single place that decides it, so a tool cannot reach the
57
+ * endpoint by being wired to it later. A render authors a throwaway widget, so rewriting its URLs is invisible
58
+ * and lasts as long as the widget does; a tool that WRITES a space (plitzi_apply) would persist those URLs into
59
+ * content the user owns, which is why it is not on the list unless a deployment puts it there deliberately. */
60
+ var proxyForTool = (proxy, tool) => proxy?.tools.includes(tool) ? proxy : void 0;
61
+ //#endregion
62
+ export { PROXY_PATH, grantingProxy, proxyForTool, proxySettings, requestProxy };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import { ProxyKind } from './types';
2
+ export type FetchFailure = {
3
+ ok: false;
4
+ status: number;
5
+ reason: string;
6
+ };
7
+ export type FetchSuccess = {
8
+ ok: true;
9
+ contentType: string;
10
+ contentLength?: number;
11
+ body: Response['body'];
12
+ };
13
+ export type FetchResult = FetchFailure | FetchSuccess;
14
+ /** Fetch a remote resource on the widget's behalf. Redirects are followed by hand rather than by fetch, because
15
+ * each hop is a new host that has to pass the same guard — an allowed URL that redirects into the private network
16
+ * would otherwise walk straight through it. (It is also what makes the redirect-based image services work at
17
+ * all: the sandbox loses the redirect, this does not.) */
18
+ export declare const fetchResource: (target: string, kind: ProxyKind, maxBytes: number) => Promise<FetchResult>;
@@ -0,0 +1,91 @@
1
+ import { isPublicHost } from "./guard.js";
2
+ //#region src/modules/mcp/proxy/fetch.ts
3
+ var TIMEOUT_MS = 1e4;
4
+ var MAX_REDIRECTS = 4;
5
+ var ALLOWED_TYPES = {
6
+ asset: [
7
+ "image/",
8
+ "video/",
9
+ "audio/",
10
+ "font/",
11
+ "application/font",
12
+ "application/octet-stream"
13
+ ],
14
+ data: [
15
+ "application/json",
16
+ "application/ld+json",
17
+ "application/xml",
18
+ "text/plain",
19
+ "text/csv",
20
+ "text/xml"
21
+ ]
22
+ };
23
+ var REQUEST_HEADERS = {
24
+ asset: {
25
+ "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0 Safari/537.36",
26
+ Accept: "image/avif,image/webp,image/apng,image/*,*/*;q=0.8",
27
+ "Accept-Language": "en-US,en;q=0.9"
28
+ },
29
+ data: {
30
+ "User-Agent": "PlitziWidget/1.0 (+https://plitzi.com)",
31
+ Accept: "application/json,text/plain;q=0.9,*/*;q=0.8"
32
+ }
33
+ };
34
+ var failure = (status, reason) => ({
35
+ ok: false,
36
+ status,
37
+ reason
38
+ });
39
+ var parseTarget = (target) => {
40
+ try {
41
+ const url = new URL(target);
42
+ return url.protocol === "http:" || url.protocol === "https:" ? url : void 0;
43
+ } catch {
44
+ return;
45
+ }
46
+ };
47
+ /** Fetch a remote resource on the widget's behalf. Redirects are followed by hand rather than by fetch, because
48
+ * each hop is a new host that has to pass the same guard — an allowed URL that redirects into the private network
49
+ * would otherwise walk straight through it. (It is also what makes the redirect-based image services work at
50
+ * all: the sandbox loses the redirect, this does not.) */
51
+ var fetchResource = async (target, kind, maxBytes) => {
52
+ let url = parseTarget(target);
53
+ if (!url) return failure(400, "Only http(s) URLs can be fetched.");
54
+ const controller = new AbortController();
55
+ const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
56
+ try {
57
+ for (let redirects = 0; redirects <= MAX_REDIRECTS; redirects += 1) {
58
+ if (!await isPublicHost(url.hostname)) return failure(403, "That host is not reachable from here.");
59
+ const response = await fetch(url, {
60
+ headers: REQUEST_HEADERS[kind],
61
+ redirect: "manual",
62
+ signal: controller.signal
63
+ });
64
+ const location = response.headers.get("location");
65
+ if (response.status >= 300 && response.status < 400 && location) {
66
+ const next = parseTarget(new URL(location, url).toString());
67
+ if (!next) return failure(502, "It redirected somewhere that is not an http(s) URL.");
68
+ url = next;
69
+ continue;
70
+ }
71
+ if (!response.ok) return failure(502, `It could not be fetched (upstream ${response.status}).`);
72
+ const contentType = response.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase() ?? "";
73
+ if (!ALLOWED_TYPES[kind].some((allowed) => contentType.startsWith(allowed))) return failure(415, `That URL answered with ${contentType || "no content type"}, which is not ${kind === "asset" ? "an image or media file" : "data"}.`);
74
+ const declared = Number(response.headers.get("content-length"));
75
+ if (Number.isFinite(declared) && declared > maxBytes) return failure(413, "That response is too large to load in a widget.");
76
+ return {
77
+ ok: true,
78
+ contentType,
79
+ contentLength: Number.isFinite(declared) && declared > 0 ? declared : void 0,
80
+ body: response.body
81
+ };
82
+ }
83
+ return failure(502, "It redirected too many times.");
84
+ } catch (error) {
85
+ return failure(504, error instanceof Error && error.name === "AbortError" ? "It timed out." : "unreachable");
86
+ } finally {
87
+ clearTimeout(timer);
88
+ }
89
+ };
90
+ //#endregion
91
+ export { fetchResource };