@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,25 @@
1
+ import { ProxyKind, ResourceProxy } from './types';
2
+ /** What a widget was granted. The kind is signed in too, so a URL minted for an image cannot be replayed as an
3
+ * API call (they answer with different content types, cache rules and request headers). The connection comes back
4
+ * out because a data answer may carry URLs of its own, and the grants minted for those belong to the same one. */
5
+ export type Grant = {
6
+ kind: ProxyKind;
7
+ target: string;
8
+ identity: string;
9
+ };
10
+ /** Mint the URL a widget will load this target from: this server's endpoint, carrying the target, the kind it was
11
+ * granted for, when the grant stops working and which connection minted it — all covered by one signature. */
12
+ export declare const grantUrl: (target: string, proxy: ResourceProxy, kind?: ProxyKind) => string;
13
+ /** What this endpoint was asked to fetch, or undefined when the parameter is missing, malformed, expired or not
14
+ * signed here — which is what keeps it from being an open proxy for anyone who finds it: it serves the URLs this
15
+ * server rewrote, for as long as it said, and nothing else.
16
+ *
17
+ * Takes the parameter as the query parser hands it over — decoded exactly once, which is the form that was
18
+ * signed. Decoding it again would corrupt every target that legitimately carries a percent-escape (an API URL
19
+ * with a nested URL in its query) and reject it as unsigned. */
20
+ export declare const readGrant: (param: string | undefined, secret: string) => Grant | undefined;
21
+ export declare const PROXY_PARAM = "i";
22
+ /** Is this URL one the widget can already reach? Absolute http(s) URLs are the ones a sandbox CSP blocks;
23
+ * `data:`/`blob:` carry their own bytes, and a relative URL has no origin to reach in the first place. */
24
+ export declare const isRemote: (url: string) => boolean;
25
+ export declare const isGranted: (url: string, proxy: ResourceProxy) => boolean;
@@ -0,0 +1,67 @@
1
+ import { sign, verify } from "./sign.js";
2
+ //#region src/modules/mcp/proxy/grant.ts
3
+ /** The single query parameter a proxied URL carries: `<signature>.<kind>.<expiry>.<connection>.<target>`. One
4
+ * parameter rather than several so the URL holds no `&` — these end up inside HTML attributes and markdown
5
+ * links, where an unescaped ampersand is the kind of detail that silently truncates a URL. */
6
+ var PARAM = "i";
7
+ var CODE = {
8
+ asset: "a",
9
+ data: "d"
10
+ };
11
+ var KIND = {
12
+ a: "asset",
13
+ d: "data"
14
+ };
15
+ var isTemplated = (target) => target.includes("{{");
16
+ var originOf = (target) => {
17
+ try {
18
+ return new URL(target).origin;
19
+ } catch {
20
+ return;
21
+ }
22
+ };
23
+ var encodeTarget = (target) => encodeURIComponent(target).replace(/%7B/g, "{").replace(/%7D/g, "}");
24
+ var payloadOf = (kind, expiry, identity, target) => `${CODE[kind]}.${expiry.toString(36)}.${identity}.${target}`;
25
+ /** Mint the URL a widget will load this target from: this server's endpoint, carrying the target, the kind it was
26
+ * granted for, when the grant stops working and which connection minted it — all covered by one signature. */
27
+ var grantUrl = (target, proxy, kind = "asset") => {
28
+ const expiry = Math.floor(Date.now() / 1e3) + proxy.ttl;
29
+ const scope = (isTemplated(target) ? originOf(target) : target) ?? target;
30
+ const signature = sign(payloadOf(kind, expiry, proxy.identity, scope), proxy.secret);
31
+ const payload = `${CODE[kind]}.${expiry.toString(36)}.${proxy.identity}.${encodeTarget(target)}`;
32
+ return `${proxy.endpoint}?${PARAM}=${signature}.${payload}`;
33
+ };
34
+ /** What this endpoint was asked to fetch, or undefined when the parameter is missing, malformed, expired or not
35
+ * signed here — which is what keeps it from being an open proxy for anyone who finds it: it serves the URLs this
36
+ * server rewrote, for as long as it said, and nothing else.
37
+ *
38
+ * Takes the parameter as the query parser hands it over — decoded exactly once, which is the form that was
39
+ * signed. Decoding it again would corrupt every target that legitimately carries a percent-escape (an API URL
40
+ * with a nested URL in its query) and reject it as unsigned. */
41
+ var readGrant = (param, secret) => {
42
+ const parts = param?.split(".") ?? [];
43
+ if (parts.length < 5) return;
44
+ const [signature = "", code = "", expiry = "", identity = ""] = parts;
45
+ const kind = KIND[code];
46
+ const target = parts.slice(4).join(".");
47
+ const expiresAt = parseInt(expiry, 36);
48
+ if (!kind || !Number.isFinite(expiresAt) || expiresAt * 1e3 < Date.now()) return;
49
+ const payload = payloadOf(kind, expiresAt, identity, target);
50
+ if (verify(payload, signature, secret)) return {
51
+ kind,
52
+ target,
53
+ identity
54
+ };
55
+ const origin = originOf(target);
56
+ return origin && verify(payloadOf(kind, expiresAt, identity, origin), signature, secret) ? {
57
+ kind,
58
+ target,
59
+ identity
60
+ } : void 0;
61
+ };
62
+ /** Is this URL one the widget can already reach? Absolute http(s) URLs are the ones a sandbox CSP blocks;
63
+ * `data:`/`blob:` carry their own bytes, and a relative URL has no origin to reach in the first place. */
64
+ var isRemote = (url) => /^https?:\/\//i.test(url);
65
+ var isGranted = (url, proxy) => url.startsWith(`${proxy.endpoint}?`);
66
+ //#endregion
67
+ export { grantUrl, isGranted, isRemote, readGrant };
@@ -0,0 +1,6 @@
1
+ export declare const isPrivateAddress: (address: string) => boolean;
2
+ /** Does this hostname resolve somewhere on the public internet? The endpoint fetches URLs an agent authored, so
3
+ * without this it would be a way to read whatever the pod itself can reach — the cluster's services, the cloud
4
+ * metadata endpoint, a database on the node. Both the literal address and every address the name resolves to are
5
+ * checked; a name that does not resolve is refused rather than handed to fetch. */
6
+ export declare const isPublicHost: (hostname: string) => Promise<boolean>;
@@ -0,0 +1,38 @@
1
+ import { lookup } from "node:dns/promises";
2
+ import { isIP } from "node:net";
3
+ //#region src/modules/mcp/proxy/guard.ts
4
+ var isPrivateIpv4 = (address) => {
5
+ const parts = address.split(".").map(Number);
6
+ if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) return true;
7
+ const [a = 0, b = 0] = parts;
8
+ return a === 0 || a === 10 || a === 127 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 0 || a === 192 && b === 168 || a === 198 && (b === 18 || b === 19) || a >= 224;
9
+ };
10
+ var isPrivateIpv6 = (address) => {
11
+ const normalized = address.toLowerCase().split("%")[0] ?? "";
12
+ if (normalized.startsWith("::ffff:") && normalized.includes(".")) return isPrivateIpv4(normalized.slice(7));
13
+ return normalized === "::" || normalized === "::1" || normalized.startsWith("fc") || normalized.startsWith("fd") || normalized.startsWith("fe8") || normalized.startsWith("fe9") || normalized.startsWith("fea") || normalized.startsWith("feb");
14
+ };
15
+ var isPrivateAddress = (address) => isIP(address) === 6 ? isPrivateIpv6(address) : isPrivateIpv4(address);
16
+ var PRIVATE_SUFFIXES = [
17
+ ".local",
18
+ ".internal",
19
+ ".localhost",
20
+ ".home.arpa"
21
+ ];
22
+ /** Does this hostname resolve somewhere on the public internet? The endpoint fetches URLs an agent authored, so
23
+ * without this it would be a way to read whatever the pod itself can reach — the cluster's services, the cloud
24
+ * metadata endpoint, a database on the node. Both the literal address and every address the name resolves to are
25
+ * checked; a name that does not resolve is refused rather than handed to fetch. */
26
+ var isPublicHost = async (hostname) => {
27
+ const host = hostname.toLowerCase().replace(/^\[|\]$/g, "");
28
+ if (!host || host === "localhost" || PRIVATE_SUFFIXES.some((suffix) => host.endsWith(suffix))) return false;
29
+ if (isIP(host)) return !isPrivateAddress(host);
30
+ try {
31
+ const addresses = await lookup(host, { all: true });
32
+ return addresses.length > 0 && addresses.every((entry) => !isPrivateAddress(entry.address));
33
+ } catch {
34
+ return false;
35
+ }
36
+ };
37
+ //#endregion
38
+ export { isPrivateAddress, isPublicHost };
@@ -0,0 +1,8 @@
1
+ import { ResourceProxySettings } from './types';
2
+ import { SSRRequest, SSRResponseHelpers } from '@plitzi/sdk-shared';
3
+ /** Serve one external resource on behalf of a widget: check the grant this server signed, fetch the target, and
4
+ * stream it back under this origin — the one the CSP declares. Read-only, credential-free and CORS-open, because
5
+ * it answers the host's sandboxed iframe: a browser that has no origin of its own and can present nothing. The
6
+ * grant is what stands in for a caller identity — it is unforgeable, it names one target (or one host, for a
7
+ * templated API URL), it names the kind, it expires, and it carries the connection that minted it. */
8
+ export declare const handleProxyRequest: (req: SSRRequest, res: SSRResponseHelpers, settings: ResourceProxySettings) => Promise<void>;
@@ -0,0 +1,99 @@
1
+ import { grantingProxy } from "./config.js";
2
+ import { readGrant } from "./grant.js";
3
+ import { fetchResource } from "./fetch.js";
4
+ import { rewritablePayload, rewritePayload } from "./payload.js";
5
+ //#region src/modules/mcp/proxy/handler.ts
6
+ var CACHE_CONTROL = {
7
+ asset: "public, max-age=86400, immutable",
8
+ data: "no-store"
9
+ };
10
+ /** Read a response whole, or undefined once it is past the limit. Only a rewritable answer is read this way: it has
11
+ * to be complete before a URL inside it can be swapped, and an API answer is small — which is exactly why the
12
+ * streaming path below stays the rule for everything else. */
13
+ var readAll = async (body, maxBytes) => {
14
+ const reader = body.getReader();
15
+ const chunks = [];
16
+ let written = 0;
17
+ for (;;) {
18
+ const { done, value } = await reader.read();
19
+ if (done) break;
20
+ written += value.byteLength;
21
+ if (written > maxBytes) {
22
+ await reader.cancel();
23
+ return;
24
+ }
25
+ chunks.push(Buffer.from(value));
26
+ }
27
+ return Buffer.concat(chunks);
28
+ };
29
+ var fail = (res, status, reason) => {
30
+ res.setStatus(status);
31
+ res.setHeader("Content-Type", "text/plain; charset=utf-8");
32
+ res.setHeader("Cache-Control", "no-store");
33
+ res.send(reason);
34
+ };
35
+ /** Serve one external resource on behalf of a widget: check the grant this server signed, fetch the target, and
36
+ * stream it back under this origin — the one the CSP declares. Read-only, credential-free and CORS-open, because
37
+ * it answers the host's sandboxed iframe: a browser that has no origin of its own and can present nothing. The
38
+ * grant is what stands in for a caller identity — it is unforgeable, it names one target (or one host, for a
39
+ * templated API URL), it names the kind, it expires, and it carries the connection that minted it. */
40
+ var handleProxyRequest = async (req, res, settings) => {
41
+ res.setHeader("Access-Control-Allow-Origin", "*");
42
+ res.setHeader("Cross-Origin-Resource-Policy", "cross-origin");
43
+ if (req.method === "OPTIONS") {
44
+ res.setHeader("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS");
45
+ res.setHeader("Access-Control-Allow-Headers", "*");
46
+ res.setStatus(204);
47
+ res.end();
48
+ return;
49
+ }
50
+ if (req.method !== "GET" && req.method !== "HEAD") {
51
+ fail(res, 405, "Only GET is served here.");
52
+ return;
53
+ }
54
+ const grant = readGrant(req.query["i"], settings.secret);
55
+ if (!grant) {
56
+ fail(res, 403, "This URL is missing a grant, or the one it carries was not issued here or has expired.");
57
+ return;
58
+ }
59
+ const result = await fetchResource(grant.target, grant.kind, settings.maxBytes);
60
+ if (!result.ok) {
61
+ fail(res, result.status, result.reason);
62
+ return;
63
+ }
64
+ res.setStatus(200);
65
+ res.setHeader("Content-Type", result.contentType);
66
+ res.setHeader("Cache-Control", CACHE_CONTROL[grant.kind]);
67
+ if (req.method === "HEAD" || !result.body) {
68
+ res.end();
69
+ return;
70
+ }
71
+ const payloadProxy = grant.kind === "data" && rewritablePayload(result.contentType) ? grantingProxy(settings, req, grant.identity) : void 0;
72
+ if (payloadProxy) {
73
+ const body = await readAll(result.body, settings.maxBytes);
74
+ if (!body) {
75
+ fail(res, 413, "That response is too large to load in a widget.");
76
+ return;
77
+ }
78
+ res.send(rewritePayload(body.toString("utf8"), payloadProxy));
79
+ return;
80
+ }
81
+ const reader = result.body.getReader();
82
+ let written = 0;
83
+ try {
84
+ for (;;) {
85
+ const { done, value } = await reader.read();
86
+ if (done) break;
87
+ written += value.byteLength;
88
+ if (written > settings.maxBytes) {
89
+ await reader.cancel();
90
+ break;
91
+ }
92
+ res.write(Buffer.from(value));
93
+ }
94
+ } finally {
95
+ res.end();
96
+ }
97
+ };
98
+ //#endregion
99
+ export { handleProxyRequest };
@@ -0,0 +1,8 @@
1
+ export { grantingProxy, PROXY_PATH, proxyForTool, proxySettings, requestProxy } from './config';
2
+ export { grantUrl, isGranted, isRemote, PROXY_PARAM, readGrant } from './grant';
3
+ export { handleProxyRequest } from './handler';
4
+ export { rewritablePayload, rewritePayload } from './payload';
5
+ export { looksLikeAsset, proxifyResources, rewriteText } from './rewrite';
6
+ export { connectionId, sign, verify } from './sign';
7
+ export { DEFAULT_PROXY_TOOLS } from './types';
8
+ export type { ProxyKind, ResourceProxy, ResourceProxySettings } from './types';
@@ -0,0 +1,8 @@
1
+ import { ResourceProxy } from './types';
2
+ /** Is this what the endpoint fetched a body it can rewrite? Only JSON: it is what an apiContainer binds against,
3
+ * and re-serializing anything else would risk changing a document to fix a URL that may not even be loaded. */
4
+ export declare const rewritablePayload: (contentType: string) => boolean;
5
+ /** Rewrite the asset URLs an API answer carries so the widget loads them through this endpoint too. Returns the
6
+ * body untouched when it is not the JSON it claimed to be — the widget asked for that response, and serving it
7
+ * as it came is better than failing the fetch over a rewrite. */
8
+ export declare const rewritePayload: (body: string, proxy: ResourceProxy) => string;
@@ -0,0 +1,29 @@
1
+ import { grantUrl, isGranted, isRemote } from "./grant.js";
2
+ import { looksLikeAsset } from "./rewrite.js";
3
+ //#region src/modules/mcp/proxy/payload.ts
4
+ var JSON_TYPES = ["application/json", "application/ld+json"];
5
+ var ASSET_FIELD = /(image|img|thumb|photo|picture|avatar|icon|logo|cover|banner|poster|artwork|media|src)/i;
6
+ /** Is this what the endpoint fetched a body it can rewrite? Only JSON: it is what an apiContainer binds against,
7
+ * and re-serializing anything else would risk changing a document to fix a URL that may not even be loaded. */
8
+ var rewritablePayload = (contentType) => JSON_TYPES.some((type) => contentType.startsWith(type));
9
+ var rewriteNode = (node, field, proxy) => {
10
+ if (typeof node === "string") return isRemote(node) && !isGranted(node, proxy) && (looksLikeAsset(node) || ASSET_FIELD.test(field)) ? grantUrl(node, proxy) : node;
11
+ if (Array.isArray(node)) return node.map((item) => rewriteNode(item, field, proxy));
12
+ if (node !== null && typeof node === "object") {
13
+ const entries = Object.entries(node);
14
+ return Object.fromEntries(entries.map(([key, value]) => [key, rewriteNode(value, key, proxy)]));
15
+ }
16
+ return node;
17
+ };
18
+ /** Rewrite the asset URLs an API answer carries so the widget loads them through this endpoint too. Returns the
19
+ * body untouched when it is not the JSON it claimed to be — the widget asked for that response, and serving it
20
+ * as it came is better than failing the fetch over a rewrite. */
21
+ var rewritePayload = (body, proxy) => {
22
+ try {
23
+ return JSON.stringify(rewriteNode(JSON.parse(body), "", proxy));
24
+ } catch {
25
+ return body;
26
+ }
27
+ };
28
+ //#endregion
29
+ export { rewritablePayload, rewritePayload };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import { ResourceProxy } from './types';
2
+ import { Schema, Style } from '@plitzi/sdk-shared';
3
+ /** Does this URL name a file the widget loads, judged by its path alone? Used where nothing else says what a URL is
4
+ * for — an interaction param, a field of an API answer — so the extension is the evidence and its absence is a
5
+ * reason to leave the URL alone. */
6
+ export declare const looksLikeAsset: (url: string) => boolean;
7
+ /** Rewrite every remote URL embedded in a string: `url(…)` in CSS, `src="…"` in markup, `![](…)` in markdown. */
8
+ export declare const rewriteText: (text: string, proxy: ResourceProxy) => string;
9
+ /** Point everything an authored widget loads from outside — images, media, fonts, the data an apiContainer fetches
10
+ * and the URLs its interactions swap in later — at this server's endpoint, in place. The AGENT never sees this: it
11
+ * authors the real URL and this runs
12
+ * afterwards, on the throwaway space a render builds (so nothing shared is mutated) and before the global style
13
+ * cache is compiled (so the concatenated CSS comes out already rewritten). Returns what could not be rewritten,
14
+ * which is the only part the model hears about. */
15
+ export declare const proxifyResources: (space: {
16
+ schema: Schema;
17
+ style: Style;
18
+ }, proxy: ResourceProxy) => string[];
@@ -0,0 +1,138 @@
1
+ import { grantUrl, isGranted, isRemote } from "./grant.js";
2
+ //#region src/modules/mcp/proxy/rewrite.ts
3
+ var URL_ATTRIBUTES = ["src", "poster"];
4
+ var MARKUP_ATTRIBUTES = ["content", "html"];
5
+ var FETCHING_TYPE = "apiContainer";
6
+ var SET_STATE_ACTION = "setState";
7
+ var NAVIGATION_ACTION = "navigate";
8
+ var FETCHING_UTILITY = "webHook";
9
+ var ASSET_EXTENSION = /\.(?:apng|avif|bmp|gif|ico|jpe?g|png|svg|webp|aac|flac|m4a|mp3|oga|ogg|opus|wav|mp4|m4v|mov|ogv|webm|otf|ttf|woff2?)$/i;
10
+ var CSS_URL = /url\(\s*(["']?)(https?:\/\/[^"')\s]+)\1\s*\)/gi;
11
+ var HTML_SRC = /(<[^>]+?\ssrc\s*=\s*)(["'])(https?:\/\/[^"']+)\2/gi;
12
+ var MARKDOWN_IMAGE = /(!\[[^\]]*\]\(\s*)(https?:\/\/[^\s)]+)/gi;
13
+ var unescapeHtml = (url) => url.replace(/&amp;/g, "&");
14
+ var toProxy = (url, proxy) => isGranted(url, proxy) ? url : grantUrl(unescapeHtml(url), proxy);
15
+ /** Does this URL name a file the widget loads, judged by its path alone? Used where nothing else says what a URL is
16
+ * for — an interaction param, a field of an API answer — so the extension is the evidence and its absence is a
17
+ * reason to leave the URL alone. */
18
+ var looksLikeAsset = (url) => {
19
+ try {
20
+ return ASSET_EXTENSION.test(new URL(url).pathname);
21
+ } catch {
22
+ return false;
23
+ }
24
+ };
25
+ /** Rewrite every remote URL embedded in a string: `url(…)` in CSS, `src="…"` in markup, `![](…)` in markdown. */
26
+ var rewriteText = (text, proxy) => text.replace(CSS_URL, (_match, quote, url) => `url(${quote}${toProxy(url, proxy)}${quote})`).replace(HTML_SRC, (_match, prefix, quote, url) => `${prefix}${quote}${toProxy(url, proxy)}${quote}`).replace(MARKDOWN_IMAGE, (_match, prefix, url) => `${prefix}${toProxy(url, proxy)}`);
27
+ var rewriteStyleObject = (styleObject, proxy) => {
28
+ for (const [property, value] of Object.entries(styleObject)) if (typeof value === "string" && value.includes("url(")) styleObject[property] = rewriteText(value, proxy);
29
+ };
30
+ var rewriteStyleBlock = (block, proxy) => {
31
+ if (block.default) rewriteStyleObject(block.default, proxy);
32
+ for (const state of Object.values(block.states ?? {})) rewriteStyleObject(state, proxy);
33
+ };
34
+ /** Why a request was left as authored, or undefined when it can be granted. Each case is one this hop cannot
35
+ * reproduce faithfully, and getting it wrong silently would be worse than the request being blocked: a write sent
36
+ * through a GET, or an API answering 401 because its credential was dropped on the way. Reads both vocabularies —
37
+ * an apiContainer's attributes and a webHook's params name the same things differently. */
38
+ var unproxyableFetch = (source) => {
39
+ const { method, headers, accessToken, authorizationToken } = source;
40
+ if (typeof method === "string" && method.toLowerCase() !== "get") return `it is a ${method.toUpperCase()} request`;
41
+ if (typeof accessToken === "string" && accessToken !== "") return "it sends its own credentials";
42
+ if (typeof authorizationToken === "string" && authorizationToken !== "") return "it sends its own credentials";
43
+ return headers && Object.keys(headers).length > 0 ? "it sends its own headers" : void 0;
44
+ };
45
+ var rewriteSetState = (params, proxy) => {
46
+ const { key, value } = params;
47
+ if (typeof key !== "string" || typeof value !== "string") return false;
48
+ if (URL_ATTRIBUTES.includes(key) && isRemote(value)) {
49
+ params.value = toProxy(value, proxy);
50
+ return true;
51
+ }
52
+ if (MARKUP_ATTRIBUTES.includes(key) && value.includes("http")) {
53
+ params.value = rewriteText(value, proxy);
54
+ return true;
55
+ }
56
+ return false;
57
+ };
58
+ var rewriteParams = (params, proxy) => {
59
+ for (const [name, value] of Object.entries(params)) {
60
+ if (typeof value !== "string") continue;
61
+ if (URL_ATTRIBUTES.includes(name) && isRemote(value)) params[name] = toProxy(value, proxy);
62
+ else if (MARKUP_ATTRIBUTES.includes(name) && value.includes("http")) params[name] = rewriteText(value, proxy);
63
+ else if (isRemote(value) && looksLikeAsset(value)) params[name] = toProxy(value, proxy);
64
+ }
65
+ };
66
+ var rewriteWebHook = (node, proxy, warnings) => {
67
+ const params = node.params;
68
+ const url = params.url;
69
+ if (typeof url !== "string" || !isRemote(url) || isGranted(url, proxy)) return;
70
+ const blocked = unproxyableFetch(params);
71
+ if (blocked) {
72
+ warnings.push(`The ${FETCHING_UTILITY} step "${node.title}" calls its endpoint directly because ${blocked}, so that request is subject to the network policy of the surface it renders in, and to the CORS headers of the API, and may not run. A plain GET with no credentials is fetched by the widget server instead, which always works.`);
73
+ return;
74
+ }
75
+ params.url = grantUrl(url, proxy, "data");
76
+ };
77
+ var rewriteInteractions = (interactions, proxy, warnings) => {
78
+ for (const node of Object.values(interactions ?? {})) {
79
+ if (node.type === "globalCallback" && node.action === NAVIGATION_ACTION) continue;
80
+ if (node.type === "utility" && node.action === FETCHING_UTILITY) {
81
+ rewriteWebHook(node, proxy, warnings);
82
+ continue;
83
+ }
84
+ const params = node.params;
85
+ if (node.action === SET_STATE_ACTION && rewriteSetState(params, proxy)) continue;
86
+ rewriteParams(params, proxy);
87
+ }
88
+ };
89
+ var rewriteBindings = (bindings, proxy) => {
90
+ for (const category of Object.values(bindings ?? {})) for (const binding of category) for (const transformer of binding.transformers ?? []) rewriteParams(transformer.params, proxy);
91
+ };
92
+ var rewriteSchema = (schema, proxy, warnings) => {
93
+ for (const element of Object.values(schema.flat)) {
94
+ rewriteInteractions(element.definition.interactions, proxy, warnings);
95
+ rewriteBindings(element.definition.bindings, proxy);
96
+ const attributes = element.attributes;
97
+ for (const name of URL_ATTRIBUTES) {
98
+ const value = attributes[name];
99
+ if (typeof value === "string" && isRemote(value) && !isGranted(value, proxy)) attributes[name] = grantUrl(value, proxy);
100
+ }
101
+ for (const name of MARKUP_ATTRIBUTES) {
102
+ const value = attributes[name];
103
+ if (typeof value === "string" && value.includes("http")) attributes[name] = rewriteText(value, proxy);
104
+ }
105
+ const query = attributes.query;
106
+ if (element.definition.type !== FETCHING_TYPE || typeof query !== "string" || !isRemote(query)) continue;
107
+ const blocked = unproxyableFetch(attributes);
108
+ if (blocked) {
109
+ warnings.push(`The ${FETCHING_TYPE} "${element.idRef ?? element.id}" calls its endpoint directly because ${blocked}, so that request is subject to the network policy of the surface it renders in, and to the CORS headers of the API, and may not run. A plain GET with no headers is fetched by the widget server instead, which always works.`);
110
+ continue;
111
+ }
112
+ if (!isGranted(query, proxy)) attributes.query = grantUrl(query, proxy, "data");
113
+ }
114
+ };
115
+ var rewriteStyle = (style, proxy) => {
116
+ for (const items of Object.values(style.platform)) for (const item of Object.values(items)) {
117
+ for (const selector of Object.values(item.attributes)) {
118
+ rewriteStyleBlock(selector, proxy);
119
+ for (const variant of Object.values(selector.variants ?? {})) rewriteStyleBlock(variant, proxy);
120
+ }
121
+ if (item.cache.includes("url(")) item.cache = rewriteText(item.cache, proxy);
122
+ }
123
+ if (style.cache.includes("url(")) style.cache = rewriteText(style.cache, proxy);
124
+ };
125
+ /** Point everything an authored widget loads from outside — images, media, fonts, the data an apiContainer fetches
126
+ * and the URLs its interactions swap in later — at this server's endpoint, in place. The AGENT never sees this: it
127
+ * authors the real URL and this runs
128
+ * afterwards, on the throwaway space a render builds (so nothing shared is mutated) and before the global style
129
+ * cache is compiled (so the concatenated CSS comes out already rewritten). Returns what could not be rewritten,
130
+ * which is the only part the model hears about. */
131
+ var proxifyResources = (space, proxy) => {
132
+ const warnings = [];
133
+ rewriteSchema(space.schema, proxy, warnings);
134
+ rewriteStyle(space.style, proxy);
135
+ return warnings;
136
+ };
137
+ //#endregion
138
+ export { looksLikeAsset, proxifyResources, rewriteText };
@@ -0,0 +1,6 @@
1
+ export declare const sign: (payload: string, secret: string) => string;
2
+ export declare const verify: (payload: string, signature: string, secret: string) => boolean;
3
+ /** A short, stable fingerprint of the MCP credential a request carried — the connection a grant belongs to.
4
+ * Derived through the same secret, so it identifies without echoing any part of the token; a request with no
5
+ * credential (the public widgets surface) gets the shared anonymous identity. */
6
+ export declare const connectionId: (authorization: string | undefined, secret: string) => string;
@@ -0,0 +1,15 @@
1
+ import { createHmac, timingSafeEqual } from "node:crypto";
2
+ //#region src/modules/mcp/proxy/sign.ts
3
+ var SIGNATURE_LENGTH = 22;
4
+ var sign = (payload, secret) => createHmac("sha256", secret).update(payload).digest("base64url").slice(0, SIGNATURE_LENGTH);
5
+ var verify = (payload, signature, secret) => {
6
+ const expected = Buffer.from(sign(payload, secret));
7
+ const given = Buffer.from(signature);
8
+ return expected.length === given.length && timingSafeEqual(expected, given);
9
+ };
10
+ /** A short, stable fingerprint of the MCP credential a request carried — the connection a grant belongs to.
11
+ * Derived through the same secret, so it identifies without echoing any part of the token; a request with no
12
+ * credential (the public widgets surface) gets the shared anonymous identity. */
13
+ var connectionId = (authorization, secret) => authorization ? sign(`id:${authorization}`, secret).slice(0, 10) : "anon";
14
+ //#endregion
15
+ export { connectionId, sign, verify };
@@ -0,0 +1,45 @@
1
+ /** What a widget is loading. Both ride the same endpoint but are not the same thing: an asset is immutable and
2
+ * cached hard, data is an API answer that must never be served stale, and each accepts its own content types. */
3
+ export type ProxyKind = 'asset' | 'data';
4
+ /** How a widget reaches ANYTHING outside its sandbox — an image, a font, a video, an API.
5
+ *
6
+ * An MCP App runs in an iframe on the HOST's origin under a CSP the host builds from the domains this server
7
+ * declares, and that declaration belongs to the `ui://` RESOURCE: it is read (and may be cached) before any
8
+ * widget exists, the spec types `csp` as `never` on the tool meta, and plitzi_render is stateless, so the origins
9
+ * an agent is about to author can never be listed there. The one origin that CAN be declared up front is this
10
+ * server's own, so every external URL a render authored is rewritten to point here and this server fetches the
11
+ * original — which also settles the redirects, hotlink rules and missing CORS headers a null-origin sandbox
12
+ * cannot. Nothing is stored: the URL carries its own signed grant, so any replica answers any request. */
13
+ export interface ResourceProxy {
14
+ /** Absolute endpoint the browser fetches from, e.g. `https://mcp.plitzi.app/__proxy`. */
15
+ endpoint: string;
16
+ /** Signs the grant, so the endpoint serves what this server rewrote and not whatever a caller asks for. */
17
+ secret: string;
18
+ /** Fingerprint of the MCP credential the render was called with (see `connectionId`). It is signed into every
19
+ * URL, so the grants one connection minted are distinct from another's and a widget's URLs cannot be pooled. */
20
+ identity: string;
21
+ /** How long a minted URL stays valid, in seconds. A widget outlives the call that made it (it sits in the
22
+ * conversation), so this is days rather than minutes — but not forever, so a leaked URL stops working. */
23
+ ttl: number;
24
+ /** The tools allowed to rewrite through this endpoint (see {@link DEFAULT_PROXY_TOOLS}). Carried here because
25
+ * the decision is made once, where each tool's context is built. */
26
+ tools: readonly string[];
27
+ }
28
+ /** The tools a proxy may be handed to. `plitzi_render` alone by default, and that default is a guard, not a
29
+ * convenience: a render is a THROWAWAY widget, so rewriting its URLs changes nothing that outlives the call —
30
+ * while plitzi_apply writes to the user's real space, where a rewritten URL would be PERSISTED and the space
31
+ * would come to depend on this server's endpoint for content it owns. Nothing else should be added here without
32
+ * that being the intention. */
33
+ export declare const DEFAULT_PROXY_TOOLS: string[];
34
+ /** The endpoint's own side of the same feature: where it answers and what it will carry. */
35
+ export interface ResourceProxySettings {
36
+ path: string;
37
+ secret: string;
38
+ maxBytes: number;
39
+ ttl: number;
40
+ /** Which tools rewrite their URLs through the endpoint (see {@link DEFAULT_PROXY_TOOLS}). */
41
+ tools: readonly string[];
42
+ /** Absolute base to build widget URLs from. Empty → the origin each request arrived on, which is right whenever
43
+ * the MCP server owns its sub-domain. */
44
+ baseUrl?: string;
45
+ }
@@ -0,0 +1,9 @@
1
+ //#region src/modules/mcp/proxy/types.ts
2
+ /** The tools a proxy may be handed to. `plitzi_render` alone by default, and that default is a guard, not a
3
+ * convenience: a render is a THROWAWAY widget, so rewriting its URLs changes nothing that outlives the call —
4
+ * while plitzi_apply writes to the user's real space, where a rewritten URL would be PERSISTED and the space
5
+ * would come to depend on this server's endpoint for content it owns. Nothing else should be added here without
6
+ * that being the intention. */
7
+ var DEFAULT_PROXY_TOOLS = ["plitzi_render"];
8
+ //#endregion
9
+ export { DEFAULT_PROXY_TOOLS };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { Env } from '../types';
2
+ export declare const canonicalUri: (env: Env, uri: string) => string;
3
+ /** Teachable message for a URI that read as null. Distinguishes a well-formed URI whose ref does not resolve (the
4
+ * resource may be stale/deleted) from a URI whose shape matches no template at all (malformed — echo the valid
5
+ * templates so the agent stops hand-building URIs). See RFC 0004 I2. */
6
+ export declare const resourceErrorMessage: (env: Env, uri: string) => string;
@@ -0,0 +1,30 @@
1
+ import { afterPrefix, aliasedRoots, itemTemplates, primerUri } from "../helpers/uris.js";
2
+ //#region src/modules/mcp/resources/canonical.ts
3
+ var canonicalUri = (env, uri) => {
4
+ const rest = afterPrefix(uri, `plitzi://schema/${env}/`);
5
+ if (rest === void 0) return uri;
6
+ for (const root of aliasedRoots) {
7
+ if (rest === root) return `plitzi://${root}/${env}`;
8
+ if (rest.startsWith(`${root}/`)) return `plitzi://${root}/${env}/${rest.slice(root.length + 1)}`;
9
+ }
10
+ return uri;
11
+ };
12
+ /** Teachable message for a URI that read as null. Distinguishes a well-formed URI whose ref does not resolve (the
13
+ * resource may be stale/deleted) from a URI whose shape matches no template at all (malformed — echo the valid
14
+ * templates so the agent stops hand-building URIs). See RFC 0004 I2. */
15
+ var resourceErrorMessage = (env, uri) => {
16
+ const canonical = canonicalUri(env, uri);
17
+ if (itemTemplates(env).some((tpl) => canonical.startsWith(tpl.slice(0, tpl.lastIndexOf("/") + 1)))) return JSON.stringify({
18
+ error: "NOT_FOUND",
19
+ message: `No resource at '${uri}'. Its shape is valid but the ref does not resolve.`,
20
+ hint: "It may have been deleted or your URI is stale. Re-list the parent resource (pages/definitions) to refresh."
21
+ });
22
+ return JSON.stringify({
23
+ error: "MALFORMED_URI",
24
+ message: `'${uri}' matches no resource template.`,
25
+ hint: "Do not hand-build element URIs — take the ready-made uri from plitzi_search or a write response.",
26
+ validTemplates: [primerUri(env), ...itemTemplates(env)]
27
+ });
28
+ };
29
+ //#endregion
30
+ export { canonicalUri, resourceErrorMessage };
@@ -0,0 +1,22 @@
1
+ import { Space } from '../helpers';
2
+ import { Env, ResourceEnvelope } from '../types';
3
+ export declare const connectorSummaries: (space: Space) => {
4
+ connectors: {
5
+ ref: string;
6
+ name: string;
7
+ baseUrl: string;
8
+ read: string[];
9
+ write: string[];
10
+ operators: string[];
11
+ pagination: import('@plitzi/sdk-shared').ConnectorPagination | undefined;
12
+ credential: string | undefined;
13
+ fields: Record<string, "number" | "file" | "text" | "color" | "link" | "image" | "video" | "switch" | "email" | "date" | "richText" | "multiImage" | "phone" | "option"> | undefined;
14
+ }[];
15
+ };
16
+ /** Connector reads: the space's connector listing and one full manifest. Undefined when the URI belongs to
17
+ * another family, null when the shape is ours but the ref does not resolve.
18
+ *
19
+ * The item read returns the manifest verbatim, endpoints and auth template included. That is server-side state
20
+ * the browser never sees, but an agent authoring one has to read back what it wrote — and the manifest holds no
21
+ * secret either way: `credential` names a secret, it does not carry it. */
22
+ export declare const readConnectorResource: (space: Space, env: Env, uri: string) => ResourceEnvelope<unknown> | null | undefined;