@plitzi/sdk-server 0.32.24 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (512) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +326 -162
  3. package/dist/adapters/authAdapters.d.ts +21 -0
  4. package/dist/adapters/authAdapters.js +12 -0
  5. package/dist/adapters/jsonAdapters.d.ts +15 -0
  6. package/dist/adapters/jsonAdapters.js +9 -4
  7. package/dist/core/auth/api.d.ts +148 -0
  8. package/dist/core/auth/api.js +286 -0
  9. package/dist/core/auth/authorize.d.ts +96 -0
  10. package/dist/core/auth/authorize.js +92 -0
  11. package/dist/core/auth/createAuth.d.ts +165 -0
  12. package/dist/core/auth/createAuth.js +105 -0
  13. package/dist/core/auth/credentials.d.ts +29 -0
  14. package/dist/core/auth/credentials.js +48 -0
  15. package/dist/core/auth/domains.d.ts +41 -0
  16. package/dist/core/auth/domains.js +78 -0
  17. package/dist/core/auth/identity.d.ts +108 -0
  18. package/dist/core/auth/identity.js +164 -0
  19. package/dist/core/auth/oauth/client.d.ts +5 -0
  20. package/dist/core/auth/oauth/client.js +47 -0
  21. package/dist/core/auth/oauth/index.d.ts +78 -0
  22. package/dist/core/auth/oauth/index.js +113 -0
  23. package/dist/core/auth/oauth/providers/github.d.ts +2 -0
  24. package/dist/core/auth/oauth/providers/github.js +48 -0
  25. package/dist/core/auth/oauth/providers/google.d.ts +2 -0
  26. package/dist/core/auth/oauth/providers/google.js +30 -0
  27. package/dist/core/auth/oauth/state.d.ts +23 -0
  28. package/dist/core/auth/oauth/state.js +55 -0
  29. package/dist/core/auth/oauth/types.d.ts +51 -0
  30. package/dist/core/auth/oauth/types.js +13 -0
  31. package/dist/core/auth/routes.d.ts +50 -0
  32. package/dist/core/auth/routes.js +129 -0
  33. package/dist/core/auth/session.d.ts +128 -0
  34. package/dist/core/auth/session.js +165 -0
  35. package/dist/core/auth/spaceTokens.d.ts +137 -0
  36. package/dist/core/auth/spaceTokens.js +212 -0
  37. package/dist/core/auth/tokens.d.ts +151 -0
  38. package/dist/core/auth/tokens.js +221 -0
  39. package/dist/core/createServer.d.ts +29 -0
  40. package/dist/core/createServer.js +28 -14
  41. package/dist/core/handlers/authMiddleware.d.ts +27 -0
  42. package/dist/core/handlers/authMiddleware.js +38 -0
  43. package/dist/core/handlers/authRouteHandlers.d.ts +46 -0
  44. package/dist/core/handlers/authRouteHandlers.js +75 -0
  45. package/dist/core/handlers/types.d.ts +37 -0
  46. package/dist/{src/core → core}/http/dispatcher.d.ts +2 -2
  47. package/dist/core/http/dispatcher.js +8 -6
  48. package/dist/core/http/navigation.d.ts +11 -0
  49. package/dist/core/http/navigation.js +16 -0
  50. package/dist/core/http/securityHeaders.js +6 -4
  51. package/dist/core/http/stages/authApi.d.ts +17 -0
  52. package/dist/core/http/stages/authApi.js +66 -0
  53. package/dist/core/http/stages/authRoutes.js +40 -11
  54. package/dist/core/http/stages/exchangeRoute.d.ts +15 -0
  55. package/dist/core/http/stages/exchangeRoute.js +67 -0
  56. package/dist/core/http/stages/health.d.ts +11 -0
  57. package/dist/core/http/stages/health.js +25 -3
  58. package/dist/core/http/stages/middlewares.d.ts +2 -0
  59. package/dist/core/http/stages/static.d.ts +13 -0
  60. package/dist/core/http/stages/static.js +21 -6
  61. package/dist/core/http/types.d.ts +35 -0
  62. package/dist/{modules/mcp/constants.js → core/previewToken.js} +1 -1
  63. package/dist/core/sdkAssets.d.ts +16 -0
  64. package/dist/core/sdkAssets.js +46 -0
  65. package/dist/core/server/baseServer.js +40 -5
  66. package/dist/core/server/pageServer.d.ts +7 -0
  67. package/dist/core/server/pageServer.js +13 -17
  68. package/dist/core/services/action.d.ts +9 -0
  69. package/dist/core/services/action.js +21 -0
  70. package/dist/core/services/registry.d.ts +3 -0
  71. package/dist/core/services/registry.js +9 -19
  72. package/dist/{src/core → core}/services/resolve.d.ts +1 -0
  73. package/dist/core/services/resolve.js +6 -4
  74. package/dist/core/services/rsc.js +3 -2
  75. package/dist/core/staticFiles.js +1 -1
  76. package/dist/{src/core → core}/transports.d.ts +3 -0
  77. package/dist/core/transports.js +7 -6
  78. package/dist/handlers.d.ts +58 -0
  79. package/dist/handlers.js +3 -0
  80. package/dist/{src/helpers → helpers}/buildResponseHelpers.d.ts +2 -1
  81. package/dist/helpers/buildResponseHelpers.js +13 -4
  82. package/dist/helpers/buildServerInfo.d.ts +3 -0
  83. package/dist/helpers/buildServerInfo.js +25 -3
  84. package/dist/{src/helpers → helpers}/cache/keys.d.ts +5 -1
  85. package/dist/helpers/cache/keys.js +1 -1
  86. package/dist/helpers/compress.d.ts +18 -0
  87. package/dist/helpers/compress.js +47 -11
  88. package/dist/helpers/offlineDataLoader.d.ts +11 -0
  89. package/dist/helpers/offlineDataLoader.js +15 -0
  90. package/dist/helpers/resolveDebugMode.d.ts +10 -0
  91. package/dist/helpers/resolveDebugMode.js +13 -0
  92. package/dist/index.d.ts +16 -2
  93. package/dist/index.js +9 -20
  94. package/dist/kernel.d.ts +41 -0
  95. package/dist/kernel.js +22 -0
  96. package/dist/middlewares/spaceDeployment.d.ts +2 -0
  97. package/dist/middlewares/spaceDeployment.js +2 -1
  98. package/dist/modules/actions/handler.d.ts +11 -0
  99. package/dist/modules/actions/handler.js +77 -0
  100. package/dist/modules/connectors/engine.d.ts +42 -0
  101. package/dist/modules/connectors/engine.js +221 -0
  102. package/dist/modules/connectors/getByPath.d.ts +8 -0
  103. package/dist/modules/connectors/getByPath.js +21 -0
  104. package/dist/modules/connectors/index.d.ts +7 -0
  105. package/dist/modules/connectors/projection.d.ts +18 -0
  106. package/dist/modules/connectors/projection.js +108 -0
  107. package/dist/modules/connectors/resolver.d.ts +18 -0
  108. package/dist/modules/connectors/resolver.js +68 -0
  109. package/dist/modules/connectors/types.d.ts +19 -0
  110. package/dist/{src/modules → modules}/rsc/handler.d.ts +2 -2
  111. package/dist/modules/rsc/handler.js +54 -2
  112. package/dist/modules/rsc/resolveRscData.d.ts +35 -0
  113. package/dist/modules/rsc/resolveRscData.js +74 -0
  114. package/dist/{src/modules → modules}/ssr/Component.d.ts +4 -1
  115. package/dist/modules/ssr/Component.js +10 -3
  116. package/dist/modules/ssr/buildBody.d.ts +9 -0
  117. package/dist/modules/ssr/handler.d.ts +4 -0
  118. package/dist/modules/ssr/handler.js +18 -1
  119. package/dist/{src/modules → modules}/ssr/loadPluginComponents.d.ts +5 -2
  120. package/dist/modules/ssr/loadPluginComponents.js +20 -2
  121. package/dist/{src/modules → modules}/ssr/prepareRender.d.ts +2 -2
  122. package/dist/modules/ssr/prepareRender.js +24 -7
  123. package/dist/modules/ssr/preview.d.ts +10 -0
  124. package/dist/modules/ssr/preview.js +5 -78
  125. package/dist/modules/ssr/registerExternalPlugins.js +1 -1
  126. package/dist/modules/ssr/streamBody.d.ts +5 -0
  127. package/dist/modules/ssr/streamBody.js +1 -1
  128. package/dist/modules/ssr/template.d.ts +2 -0
  129. package/dist/modules/ssr/template.js +1 -1
  130. package/dist/plugins/compile.js +1 -1
  131. package/dist/plugins/manager.js +12 -8
  132. package/dist/ssr.d.ts +15 -0
  133. package/dist/ssr.js +4 -0
  134. package/package.json +29 -25
  135. package/dist/.gitkeep +0 -0
  136. package/dist/core/server/mcpServer.js +0 -29
  137. package/dist/core/services/mcp.js +0 -27
  138. package/dist/core/services/oauth.js +0 -116
  139. package/dist/core/services/preview.js +0 -37
  140. package/dist/core/services/proxy.js +0 -12
  141. package/dist/mcp.d.ts +0 -2
  142. package/dist/mcp.js +0 -7
  143. package/dist/modules/ai/AIEngine.js +0 -120
  144. package/dist/modules/ai/toolkit.js +0 -59
  145. package/dist/modules/mcp/apps/example/view/index.tsx +0 -70
  146. package/dist/modules/mcp/apps/index.js +0 -16
  147. package/dist/modules/mcp/apps/render/index.js +0 -17
  148. package/dist/modules/mcp/apps/render/styles.js +0 -54
  149. package/dist/modules/mcp/apps/render/view/heldBatch.ts +0 -107
  150. package/dist/modules/mcp/apps/render/view/index.tsx +0 -314
  151. package/dist/modules/mcp/apps/render/view/streamProgress.ts +0 -137
  152. package/dist/modules/mcp/apps/shared/assets.js +0 -10
  153. package/dist/modules/mcp/apps/shared/bundle.js +0 -23
  154. package/dist/modules/mcp/apps/shared/page.js +0 -34
  155. package/dist/modules/mcp/apps/shared/registerApp.js +0 -43
  156. package/dist/modules/mcp/apps/shared/resolve.js +0 -5
  157. package/dist/modules/mcp/apps/shared/shell.ejs +0 -59
  158. package/dist/modules/mcp/apps/shared/zodEnglishOnly.js +0 -23
  159. package/dist/modules/mcp/catalogs/builtinCallbacks.js +0 -204
  160. package/dist/modules/mcp/catalogs/builtinComponents.js +0 -170
  161. package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +0 -50
  162. package/dist/modules/mcp/catalogs/builtinTransformers.js +0 -148
  163. package/dist/modules/mcp/catalogs/builtinUtilities.js +0 -90
  164. package/dist/modules/mcp/catalogs/cssCatalog/border.js +0 -30
  165. package/dist/modules/mcp/catalogs/cssCatalog/box.js +0 -31
  166. package/dist/modules/mcp/catalogs/cssCatalog/helpers.js +0 -185
  167. package/dist/modules/mcp/catalogs/cssCatalog/index.js +0 -131
  168. package/dist/modules/mcp/catalogs/cssCatalog/layout.js +0 -98
  169. package/dist/modules/mcp/catalogs/cssCatalog/visual.js +0 -144
  170. package/dist/modules/mcp/catalogs/observed.js +0 -90
  171. package/dist/modules/mcp/catalogs/paramSpec.js +0 -69
  172. package/dist/modules/mcp/catalogs/registry.js +0 -89
  173. package/dist/modules/mcp/handler.js +0 -83
  174. package/dist/modules/mcp/helpers/agentPrompt.js +0 -104
  175. package/dist/modules/mcp/helpers/computeVersion.js +0 -16
  176. package/dist/modules/mcp/helpers/guide.js +0 -467
  177. package/dist/modules/mcp/helpers/interactions.js +0 -123
  178. package/dist/modules/mcp/helpers/log.js +0 -64
  179. package/dist/modules/mcp/helpers/opResult.js +0 -18
  180. package/dist/modules/mcp/helpers/space.js +0 -300
  181. package/dist/modules/mcp/helpers/uris.js +0 -44
  182. package/dist/modules/mcp/previewClient.js +0 -31
  183. package/dist/modules/mcp/proxy/config.js +0 -46
  184. package/dist/modules/mcp/proxy/fetch.js +0 -91
  185. package/dist/modules/mcp/proxy/grant.js +0 -65
  186. package/dist/modules/mcp/proxy/guard.js +0 -38
  187. package/dist/modules/mcp/proxy/handler.js +0 -68
  188. package/dist/modules/mcp/proxy/rewrite.js +0 -72
  189. package/dist/modules/mcp/proxy/sign.js +0 -15
  190. package/dist/modules/mcp/proxy/types.js +0 -9
  191. package/dist/modules/mcp/resources/canonical.js +0 -30
  192. package/dist/modules/mcp/resources/core.js +0 -18
  193. package/dist/modules/mcp/resources/envelope.js +0 -14
  194. package/dist/modules/mcp/resources/primer.js +0 -31
  195. package/dist/modules/mcp/resources/register.js +0 -190
  196. package/dist/modules/mcp/resources/renderGuide.js +0 -451
  197. package/dist/modules/mcp/resources/router.js +0 -37
  198. package/dist/modules/mcp/resources/schema.js +0 -43
  199. package/dist/modules/mcp/resources/style.js +0 -34
  200. package/dist/modules/mcp/screenshotClient.js +0 -47
  201. package/dist/modules/mcp/server.js +0 -113
  202. package/dist/modules/mcp/tools/apply/dispatch.js +0 -105
  203. package/dist/modules/mcp/tools/apply/index.js +0 -150
  204. package/dist/modules/mcp/tools/apply/writeResult.js +0 -37
  205. package/dist/modules/mcp/tools/index.js +0 -24
  206. package/dist/modules/mcp/tools/operations/index.js +0 -45
  207. package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +0 -32
  208. package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +0 -36
  209. package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +0 -47
  210. package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +0 -29
  211. package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +0 -41
  212. package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +0 -58
  213. package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +0 -148
  214. package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +0 -65
  215. package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +0 -30
  216. package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +0 -49
  217. package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +0 -52
  218. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +0 -47
  219. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +0 -44
  220. package/dist/modules/mcp/tools/operations/schema/operations.js +0 -41
  221. package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +0 -25
  222. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +0 -75
  223. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +0 -45
  224. package/dist/modules/mcp/tools/operations/schema/shared.js +0 -122
  225. package/dist/modules/mcp/tools/operations/schema/translator.js +0 -215
  226. package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +0 -18
  227. package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +0 -42
  228. package/dist/modules/mcp/tools/operations/schema/write.js +0 -109
  229. package/dist/modules/mcp/tools/operations/schemaIds.js +0 -54
  230. package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +0 -21
  231. package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +0 -28
  232. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +0 -24
  233. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +0 -40
  234. package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +0 -21
  235. package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +0 -28
  236. package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +0 -24
  237. package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +0 -21
  238. package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +0 -28
  239. package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +0 -24
  240. package/dist/modules/mcp/tools/operations/style/operations.js +0 -29
  241. package/dist/modules/mcp/tools/operations/style/shared.js +0 -59
  242. package/dist/modules/mcp/tools/operations/style/translator.js +0 -101
  243. package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +0 -21
  244. package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +0 -22
  245. package/dist/modules/mcp/tools/operations/style/write.js +0 -108
  246. package/dist/modules/mcp/tools/preview.js +0 -37
  247. package/dist/modules/mcp/tools/read.js +0 -51
  248. package/dist/modules/mcp/tools/render.js +0 -184
  249. package/dist/modules/mcp/tools/screenshot.js +0 -83
  250. package/dist/modules/mcp/tools/search.js +0 -115
  251. package/dist/modules/mcp/tools/shared/expandOperations.js +0 -44
  252. package/dist/modules/mcp/tools/shared/tool.js +0 -33
  253. package/dist/modules/mcp/tools/shared/validator/audit.js +0 -124
  254. package/dist/modules/mcp/tools/shared/validator/batch.js +0 -39
  255. package/dist/modules/mcp/tools/shared/validator/bindings.js +0 -70
  256. package/dist/modules/mcp/tools/shared/validator/context.js +0 -35
  257. package/dist/modules/mcp/tools/shared/validator/css.js +0 -39
  258. package/dist/modules/mcp/tools/shared/validator/elements.js +0 -68
  259. package/dist/modules/mcp/tools/shared/validator/index.js +0 -246
  260. package/dist/modules/mcp/tools/shared/validator/interactions.js +0 -103
  261. package/dist/modules/mcp/tools/shared/validator/refs.js +0 -28
  262. package/dist/modules/mcp/tools/validate.js +0 -47
  263. package/dist/modules/oauth/authorize.js +0 -177
  264. package/dist/modules/oauth/challenge.js +0 -33
  265. package/dist/modules/oauth/consentPage.js +0 -118
  266. package/dist/modules/oauth/metadata.js +0 -69
  267. package/dist/modules/oauth/params.js +0 -5
  268. package/dist/modules/oauth/pkce.js +0 -15
  269. package/dist/modules/oauth/records.js +0 -46
  270. package/dist/modules/oauth/register.js +0 -55
  271. package/dist/modules/oauth/respond.js +0 -44
  272. package/dist/modules/oauth/token.js +0 -100
  273. package/dist/public/.gitkeep +0 -0
  274. package/dist/src/adapters/jsonAdapters.d.ts +0 -7
  275. package/dist/src/core/createServer.d.ts +0 -14
  276. package/dist/src/core/http/stages/health.d.ts +0 -2
  277. package/dist/src/core/http/stages/middlewares.d.ts +0 -2
  278. package/dist/src/core/http/stages/static.d.ts +0 -5
  279. package/dist/src/core/http/types.d.ts +0 -22
  280. package/dist/src/core/server/mcpServer.d.ts +0 -2
  281. package/dist/src/core/server/pageServer.d.ts +0 -10
  282. package/dist/src/core/services/mcp.d.ts +0 -3
  283. package/dist/src/core/services/oauth.d.ts +0 -18
  284. package/dist/src/core/services/preview.d.ts +0 -2
  285. package/dist/src/core/services/proxy.d.ts +0 -2
  286. package/dist/src/core/services/registry.d.ts +0 -4
  287. package/dist/src/helpers/buildServerInfo.d.ts +0 -2
  288. package/dist/src/helpers/compress.d.ts +0 -3
  289. package/dist/src/index.d.ts +0 -15
  290. package/dist/src/mcp.d.ts +0 -14
  291. package/dist/src/middlewares/spaceDeployment.d.ts +0 -2
  292. package/dist/src/modules/ai/AIEngine.d.ts +0 -20
  293. package/dist/src/modules/ai/index.d.ts +0 -4
  294. package/dist/src/modules/ai/toolkit.d.ts +0 -17
  295. package/dist/src/modules/mcp/apps/example/index.d.ts +0 -8
  296. package/dist/src/modules/mcp/apps/index.d.ts +0 -11
  297. package/dist/src/modules/mcp/apps/render/index.d.ts +0 -4
  298. package/dist/src/modules/mcp/apps/render/styles.d.ts +0 -10
  299. package/dist/src/modules/mcp/apps/shared/assets.d.ts +0 -10
  300. package/dist/src/modules/mcp/apps/shared/bundle.d.ts +0 -4
  301. package/dist/src/modules/mcp/apps/shared/index.d.ts +0 -3
  302. package/dist/src/modules/mcp/apps/shared/page.d.ts +0 -2
  303. package/dist/src/modules/mcp/apps/shared/registerApp.d.ts +0 -5
  304. package/dist/src/modules/mcp/apps/shared/resolve.d.ts +0 -1
  305. package/dist/src/modules/mcp/apps/shared/zodEnglishOnly.d.ts +0 -4
  306. package/dist/src/modules/mcp/catalogs/builtinCallbacks.d.ts +0 -23
  307. package/dist/src/modules/mcp/catalogs/builtinComponents.d.ts +0 -4
  308. package/dist/src/modules/mcp/catalogs/builtinElementCallbacks.d.ts +0 -20
  309. package/dist/src/modules/mcp/catalogs/builtinTransformers.d.ts +0 -28
  310. package/dist/src/modules/mcp/catalogs/builtinUtilities.d.ts +0 -18
  311. package/dist/src/modules/mcp/catalogs/cssCatalog/border.d.ts +0 -4
  312. package/dist/src/modules/mcp/catalogs/cssCatalog/box.d.ts +0 -4
  313. package/dist/src/modules/mcp/catalogs/cssCatalog/helpers.d.ts +0 -34
  314. package/dist/src/modules/mcp/catalogs/cssCatalog/index.d.ts +0 -19
  315. package/dist/src/modules/mcp/catalogs/cssCatalog/layout.d.ts +0 -9
  316. package/dist/src/modules/mcp/catalogs/cssCatalog/visual.d.ts +0 -8
  317. package/dist/src/modules/mcp/catalogs/index.d.ts +0 -9
  318. package/dist/src/modules/mcp/catalogs/observed.d.ts +0 -48
  319. package/dist/src/modules/mcp/catalogs/paramSpec.d.ts +0 -42
  320. package/dist/src/modules/mcp/catalogs/registry.d.ts +0 -35
  321. package/dist/src/modules/mcp/e2e/index.d.ts +0 -6
  322. package/dist/src/modules/mcp/e2e/mcpEndpoint.d.ts +0 -27
  323. package/dist/src/modules/mcp/e2e/postMessageChannel.d.ts +0 -22
  324. package/dist/src/modules/mcp/e2e/renderingHost.d.ts +0 -34
  325. package/dist/src/modules/mcp/handler.d.ts +0 -22
  326. package/dist/src/modules/mcp/helpers/agentPrompt.d.ts +0 -4
  327. package/dist/src/modules/mcp/helpers/computeVersion.d.ts +0 -1
  328. package/dist/src/modules/mcp/helpers/guide.d.ts +0 -4
  329. package/dist/src/modules/mcp/helpers/index.d.ts +0 -8
  330. package/dist/src/modules/mcp/helpers/interactions.d.ts +0 -30
  331. package/dist/src/modules/mcp/helpers/log.d.ts +0 -8
  332. package/dist/src/modules/mcp/helpers/opResult.d.ts +0 -13
  333. package/dist/src/modules/mcp/helpers/space.d.ts +0 -115
  334. package/dist/src/modules/mcp/helpers/uris.d.ts +0 -28
  335. package/dist/src/modules/mcp/index.d.ts +0 -13
  336. package/dist/src/modules/mcp/previewClient.d.ts +0 -13
  337. package/dist/src/modules/mcp/proxy/config.d.ts +0 -17
  338. package/dist/src/modules/mcp/proxy/fetch.d.ts +0 -18
  339. package/dist/src/modules/mcp/proxy/grant.d.ts +0 -23
  340. package/dist/src/modules/mcp/proxy/guard.d.ts +0 -6
  341. package/dist/src/modules/mcp/proxy/handler.d.ts +0 -8
  342. package/dist/src/modules/mcp/proxy/index.d.ts +0 -7
  343. package/dist/src/modules/mcp/proxy/rewrite.d.ts +0 -13
  344. package/dist/src/modules/mcp/proxy/sign.d.ts +0 -6
  345. package/dist/src/modules/mcp/proxy/types.d.ts +0 -45
  346. package/dist/src/modules/mcp/resources/canonical.d.ts +0 -6
  347. package/dist/src/modules/mcp/resources/core.d.ts +0 -5
  348. package/dist/src/modules/mcp/resources/envelope.d.ts +0 -10
  349. package/dist/src/modules/mcp/resources/index.d.ts +0 -8
  350. package/dist/src/modules/mcp/resources/primer.d.ts +0 -7
  351. package/dist/src/modules/mcp/resources/register.d.ts +0 -10
  352. package/dist/src/modules/mcp/resources/renderGuide.d.ts +0 -10
  353. package/dist/src/modules/mcp/resources/router.d.ts +0 -10
  354. package/dist/src/modules/mcp/resources/schema.d.ts +0 -5
  355. package/dist/src/modules/mcp/resources/style.d.ts +0 -5
  356. package/dist/src/modules/mcp/screenshotClient.d.ts +0 -13
  357. package/dist/src/modules/mcp/server.d.ts +0 -31
  358. package/dist/src/modules/mcp/tests/helpers.d.ts +0 -13
  359. package/dist/src/modules/mcp/tools/apply/dispatch.d.ts +0 -6
  360. package/dist/src/modules/mcp/tools/apply/index.d.ts +0 -470
  361. package/dist/src/modules/mcp/tools/apply/writeResult.d.ts +0 -8
  362. package/dist/src/modules/mcp/tools/index.d.ts +0 -18
  363. package/dist/src/modules/mcp/tools/operations/index.d.ts +0 -928
  364. package/dist/src/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +0 -17
  365. package/dist/src/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +0 -25
  366. package/dist/src/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +0 -27
  367. package/dist/src/modules/mcp/tools/operations/schema/elements/deleteElement.d.ts +0 -10
  368. package/dist/src/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +0 -16
  369. package/dist/src/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +0 -22
  370. package/dist/src/modules/mcp/tools/operations/schema/elements/repeatElement.d.ts +0 -55
  371. package/dist/src/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +0 -16
  372. package/dist/src/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +0 -9
  373. package/dist/src/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +0 -12
  374. package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +0 -21
  375. package/dist/src/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +0 -12
  376. package/dist/src/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +0 -18
  377. package/dist/src/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +0 -27
  378. package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +0 -229
  379. package/dist/src/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +0 -9
  380. package/dist/src/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +0 -14
  381. package/dist/src/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +0 -34
  382. package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +0 -92
  383. package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +0 -12
  384. package/dist/src/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +0 -9
  385. package/dist/src/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +0 -16
  386. package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +0 -42
  387. package/dist/src/modules/mcp/tools/operations/schemaIds.d.ts +0 -6
  388. package/dist/src/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +0 -9
  389. package/dist/src/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +0 -37
  390. package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +0 -37
  391. package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinitions.d.ts +0 -41
  392. package/dist/src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +0 -9
  393. package/dist/src/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +0 -37
  394. package/dist/src/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +0 -37
  395. package/dist/src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +0 -9
  396. package/dist/src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +0 -37
  397. package/dist/src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +0 -37
  398. package/dist/src/modules/mcp/tools/operations/style/index.d.ts +0 -15
  399. package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +0 -264
  400. package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +0 -116
  401. package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +0 -12
  402. package/dist/src/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +0 -15
  403. package/dist/src/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +0 -20
  404. package/dist/src/modules/mcp/tools/operations/style/write.d.ts +0 -12
  405. package/dist/src/modules/mcp/tools/preview.d.ts +0 -465
  406. package/dist/src/modules/mcp/tools/read.d.ts +0 -9
  407. package/dist/src/modules/mcp/tools/render.d.ts +0 -499
  408. package/dist/src/modules/mcp/tools/render.test.d.ts +0 -1
  409. package/dist/src/modules/mcp/tools/screenshot.d.ts +0 -470
  410. package/dist/src/modules/mcp/tools/search.d.ts +0 -15
  411. package/dist/src/modules/mcp/tools/shared/expandOperations.d.ts +0 -13
  412. package/dist/src/modules/mcp/tools/shared/tool.d.ts +0 -72
  413. package/dist/src/modules/mcp/tools/shared/validator/audit.d.ts +0 -4
  414. package/dist/src/modules/mcp/tools/shared/validator/batch.d.ts +0 -5
  415. package/dist/src/modules/mcp/tools/shared/validator/bindings.d.ts +0 -6
  416. package/dist/src/modules/mcp/tools/shared/validator/context.d.ts +0 -38
  417. package/dist/src/modules/mcp/tools/shared/validator/css.d.ts +0 -4
  418. package/dist/src/modules/mcp/tools/shared/validator/elements.d.ts +0 -7
  419. package/dist/src/modules/mcp/tools/shared/validator/index.d.ts +0 -8
  420. package/dist/src/modules/mcp/tools/shared/validator/interactions.d.ts +0 -3
  421. package/dist/src/modules/mcp/tools/shared/validator/refs.d.ts +0 -4
  422. package/dist/src/modules/mcp/tools/validate.d.ts +0 -467
  423. package/dist/src/modules/mcp/types/aiSchema.d.ts +0 -218
  424. package/dist/src/modules/mcp/types/appTypes.d.ts +0 -26
  425. package/dist/src/modules/mcp/types/index.d.ts +0 -5
  426. package/dist/src/modules/mcp/types/previewTypes.d.ts +0 -25
  427. package/dist/src/modules/mcp/types/screenshotTypes.d.ts +0 -29
  428. package/dist/src/modules/mcp/types/toolTypes.d.ts +0 -138
  429. package/dist/src/modules/oauth/authorize.d.ts +0 -7
  430. package/dist/src/modules/oauth/challenge.d.ts +0 -11
  431. package/dist/src/modules/oauth/consentPage.d.ts +0 -7
  432. package/dist/src/modules/oauth/metadata.d.ts +0 -40
  433. package/dist/src/modules/oauth/params.d.ts +0 -5
  434. package/dist/src/modules/oauth/pkce.d.ts +0 -6
  435. package/dist/src/modules/oauth/records.d.ts +0 -71
  436. package/dist/src/modules/oauth/register.d.ts +0 -5
  437. package/dist/src/modules/oauth/respond.d.ts +0 -13
  438. package/dist/src/modules/oauth/token.d.ts +0 -5
  439. package/dist/src/modules/ssr/buildBody.d.ts +0 -9
  440. package/dist/src/modules/ssr/handler.d.ts +0 -4
  441. package/dist/src/modules/ssr/preview.d.ts +0 -16
  442. package/dist/src/modules/ssr/streamBody.d.ts +0 -5
  443. package/dist/src/modules/ssr/template.d.ts +0 -6
  444. package/dist/src/standalone/alias-loader.d.mts +0 -2
  445. package/dist/src/standalone/plugins/ClientInfo.d.ts +0 -2
  446. package/dist/src/standalone/plugins/ServerInfo.d.ts +0 -2
  447. package/dist/src/standalone/plugins/SharedInfo.d.ts +0 -2
  448. package/dist/src/standalone/plugins/styles.d.ts +0 -5
  449. package/dist/src/standalone/register-alias.d.mts +0 -1
  450. package/dist/src/standalone/server.d.ts +0 -1
  451. package/dist/src/standalone/stubs/react-syntax-highlighter.d.mts +0 -31
  452. package/skills/plitzi-render/SKILL.md +0 -174
  453. /package/dist/{src/core/http/dispatcher.test.d.ts → core/auth/api.test.d.ts} +0 -0
  454. /package/dist/{src/core/server/mcpServer.test.d.ts → core/auth/authorize.test.d.ts} +0 -0
  455. /package/dist/{src/modules/ai/toolkit.test.d.ts → core/auth/createAuth.test.d.ts} +0 -0
  456. /package/dist/{src/modules/mcp/apps/apps.test.d.ts → core/auth/domains.test.d.ts} +0 -0
  457. /package/dist/{src/modules/mcp/apps/render/styles.test.d.ts → core/auth/identity.test.d.ts} +0 -0
  458. /package/dist/{src/modules → core/auth}/oauth/oauth.test.d.ts +0 -0
  459. /package/dist/{src/modules/mcp/catalogs/builtinTransformers.test.d.ts → core/auth/routes.test.d.ts} +0 -0
  460. /package/dist/{src/modules/mcp/catalogs/cssCatalog/cssCatalog.test.d.ts → core/auth/session.test.d.ts} +0 -0
  461. /package/dist/{src/modules/mcp/e2e/connector.test.d.ts → core/auth/spaceTokens.test.d.ts} +0 -0
  462. /package/dist/{src/modules/mcp/e2e/host.test.d.ts → core/auth/tokens.test.d.ts} +0 -0
  463. /package/dist/{src/modules/mcp/e2e/oauthConnector.test.d.ts → core/createServer.test.d.ts} +0 -0
  464. /package/dist/{src/modules/mcp/helpers/log.test.d.ts → core/handlers/handlers.test.d.ts} +0 -0
  465. /package/dist/{src/core → core}/health.d.ts +0 -0
  466. /package/dist/{src/modules/mcp/mcp.bench.d.ts → core/http/dispatcher.test.d.ts} +0 -0
  467. /package/dist/{src/core → core}/http/securityHeaders.d.ts +0 -0
  468. /package/dist/{src/core → core}/http/stages/authRoutes.d.ts +0 -0
  469. /package/dist/{src/core → core}/http/stages/pluginAssets.d.ts +0 -0
  470. /package/dist/{src/core → core}/mimeTypes.d.ts +0 -0
  471. /package/dist/{src/modules/mcp/constants.d.ts → core/previewToken.d.ts} +0 -0
  472. /package/dist/{src/core → core}/requestParser.d.ts +0 -0
  473. /package/dist/{src/core → core}/server/baseServer.d.ts +0 -0
  474. /package/dist/{src/modules/mcp/proxy/endpoint.test.d.ts → core/server/baseServer.test.d.ts} +0 -0
  475. /package/dist/{src/modules/mcp/proxy/proxy.test.d.ts → core/services/resolve.test.d.ts} +0 -0
  476. /package/dist/{src/core → core}/services/rsc.d.ts +0 -0
  477. /package/dist/{src/core → core}/services/ssr.d.ts +0 -0
  478. /package/dist/{src/core → core}/staticFiles.d.ts +0 -0
  479. /package/dist/{src/modules/mcp/proxy/wiring.test.d.ts → helpers/buildResponseHelpers.test.d.ts} +0 -0
  480. /package/dist/{src/helpers → helpers}/cache/TtlCache.d.ts +0 -0
  481. /package/dist/{src/helpers → helpers}/cache/cacheManager.d.ts +0 -0
  482. /package/dist/{src/helpers → helpers}/cache/defaults.d.ts +0 -0
  483. /package/dist/{src/helpers → helpers}/cache/index.d.ts +0 -0
  484. /package/dist/{src/modules/mcp/tests/apply.test.d.ts → helpers/cache/keys.test.d.ts} +0 -0
  485. /package/dist/{src/helpers → helpers}/cache/serverCaches.d.ts +0 -0
  486. /package/dist/{src/modules/mcp/tests/bindings.test.d.ts → helpers/compress.test.d.ts} +0 -0
  487. /package/dist/{src/helpers → helpers}/escapeJson.d.ts +0 -0
  488. /package/dist/{src/helpers → helpers}/metrics.d.ts +0 -0
  489. /package/dist/{src/helpers → helpers}/normalizePlugins.d.ts +0 -0
  490. /package/dist/{src/modules/mcp/tests/css.test.d.ts → helpers/offlineDataLoader.test.d.ts} +0 -0
  491. /package/dist/{src/helpers → helpers}/readCookie.d.ts +0 -0
  492. /package/dist/{src/modules/mcp/tests/interactions.test.d.ts → helpers/resolveDebugMode.test.d.ts} +0 -0
  493. /package/dist/{src/helpers → helpers}/runMiddlewares.d.ts +0 -0
  494. /package/dist/{src/helpers → helpers}/serverLog.d.ts +0 -0
  495. /package/dist/{src/middlewares → middlewares}/auth.d.ts +0 -0
  496. /package/dist/{src/middlewares → middlewares}/basicAuth.d.ts +0 -0
  497. /package/dist/{src/modules/mcp/tests/pages.test.d.ts → middlewares/spaceDeployment.test.d.ts} +0 -0
  498. /package/dist/{src/modules/mcp/tests/reads.test.d.ts → modules/actions/handler.test.d.ts} +0 -0
  499. /package/dist/{src/modules/mcp/tests/schemaIds.test.d.ts → modules/connectors/engine.test.d.ts} +0 -0
  500. /package/dist/{src/modules/mcp/tests/search.test.d.ts → modules/connectors/projection.test.d.ts} +0 -0
  501. /package/dist/{src/modules/mcp/tests/skill.test.d.ts → modules/connectors/resolver.test.d.ts} +0 -0
  502. /package/dist/{src/modules/mcp/tests/styles.test.d.ts → modules/rsc/resolveRscData.test.d.ts} +0 -0
  503. /package/dist/{src/modules → modules}/ssr/applySSRResult.d.ts +0 -0
  504. /package/dist/{src/modules/mcp/tests/tools.test.d.ts → modules/ssr/loadPluginComponents.test.d.ts} +0 -0
  505. /package/dist/{src/modules/mcp/tests/validation.test.d.ts → modules/ssr/metering.test.d.ts} +0 -0
  506. /package/dist/{src/modules → modules}/ssr/registerExternalPlugins.d.ts +0 -0
  507. /package/dist/{src/plugins → plugins}/compile.d.ts +0 -0
  508. /package/dist/{src/plugins → plugins}/copy.d.ts +0 -0
  509. /package/dist/{src/plugins → plugins}/detect.d.ts +0 -0
  510. /package/dist/{src/plugins → plugins}/manager.d.ts +0 -0
  511. /package/dist/{src/plugins → plugins}/validate.d.ts +0 -0
  512. /package/dist/{src/plugins → plugins}/validate.test.d.ts +0 -0
@@ -1,38 +0,0 @@
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 };
@@ -1,68 +0,0 @@
1
- import { readGrant } from "./grant.js";
2
- import { fetchResource } from "./fetch.js";
3
- //#region src/modules/mcp/proxy/handler.ts
4
- var CACHE_CONTROL = {
5
- asset: "public, max-age=86400, immutable",
6
- data: "no-store"
7
- };
8
- var fail = (res, status, reason) => {
9
- res.setStatus(status);
10
- res.setHeader("Content-Type", "text/plain; charset=utf-8");
11
- res.setHeader("Cache-Control", "no-store");
12
- res.send(reason);
13
- };
14
- /** Serve one external resource on behalf of a widget: check the grant this server signed, fetch the target, and
15
- * stream it back under this origin — the one the CSP declares. Read-only, credential-free and CORS-open, because
16
- * it answers the host's sandboxed iframe: a browser that has no origin of its own and can present nothing. The
17
- * grant is what stands in for a caller identity — it is unforgeable, it names one target (or one host, for a
18
- * templated API URL), it names the kind, it expires, and it carries the connection that minted it. */
19
- var handleProxyRequest = async (req, res, settings) => {
20
- res.setHeader("Access-Control-Allow-Origin", "*");
21
- res.setHeader("Cross-Origin-Resource-Policy", "cross-origin");
22
- if (req.method === "OPTIONS") {
23
- res.setHeader("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS");
24
- res.setHeader("Access-Control-Allow-Headers", "*");
25
- res.setStatus(204);
26
- res.end();
27
- return;
28
- }
29
- if (req.method !== "GET" && req.method !== "HEAD") {
30
- fail(res, 405, "Only GET is served here.");
31
- return;
32
- }
33
- const grant = readGrant(req.query["i"], settings.secret);
34
- if (!grant) {
35
- fail(res, 403, "This URL is missing a grant, or the one it carries was not issued here or has expired.");
36
- return;
37
- }
38
- const result = await fetchResource(grant.target, grant.kind, settings.maxBytes);
39
- if (!result.ok) {
40
- fail(res, result.status, result.reason);
41
- return;
42
- }
43
- res.setStatus(200);
44
- res.setHeader("Content-Type", result.contentType);
45
- res.setHeader("Cache-Control", CACHE_CONTROL[grant.kind]);
46
- if (req.method === "HEAD" || !result.body) {
47
- res.end();
48
- return;
49
- }
50
- const reader = result.body.getReader();
51
- let written = 0;
52
- try {
53
- for (;;) {
54
- const { done, value } = await reader.read();
55
- if (done) break;
56
- written += value.byteLength;
57
- if (written > settings.maxBytes) {
58
- await reader.cancel();
59
- break;
60
- }
61
- res.write(Buffer.from(value));
62
- }
63
- } finally {
64
- res.end();
65
- }
66
- };
67
- //#endregion
68
- export { handleProxyRequest };
@@ -1,72 +0,0 @@
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 CSS_URL = /url\(\s*(["']?)(https?:\/\/[^"')\s]+)\1\s*\)/gi;
7
- var HTML_SRC = /(<[^>]+?\ssrc\s*=\s*)(["'])(https?:\/\/[^"']+)\2/gi;
8
- var MARKDOWN_IMAGE = /(!\[[^\]]*\]\(\s*)(https?:\/\/[^\s)]+)/gi;
9
- var unescapeHtml = (url) => url.replace(/&amp;/g, "&");
10
- var toProxy = (url, proxy) => isGranted(url, proxy) ? url : grantUrl(unescapeHtml(url), proxy);
11
- /** Rewrite every remote URL embedded in a string: `url(…)` in CSS, `src="…"` in markup, `![](…)` in markdown. */
12
- 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)}`);
13
- var rewriteStyleObject = (styleObject, proxy) => {
14
- for (const [property, value] of Object.entries(styleObject)) if (typeof value === "string" && value.includes("url(")) styleObject[property] = rewriteText(value, proxy);
15
- };
16
- var rewriteStyleBlock = (block, proxy) => {
17
- if (block.default) rewriteStyleObject(block.default, proxy);
18
- for (const state of Object.values(block.states ?? {})) rewriteStyleObject(state, proxy);
19
- };
20
- /** Why a fetching element's URL was left as authored, or undefined when it can be granted. Each case is one this
21
- * hop cannot reproduce faithfully, and getting it wrong silently would be worse than the request being blocked:
22
- * a write sent through a GET, or an API answering 401 because its credential was dropped on the way. */
23
- var unproxyableFetch = (element) => {
24
- const { method, headers, accessToken } = element.attributes;
25
- if (typeof method === "string" && method.toLowerCase() !== "get") return `it is a ${method.toUpperCase()} request`;
26
- if (typeof accessToken === "string" && accessToken !== "") return "it sends its own credentials";
27
- return headers && Object.keys(headers).length > 0 ? "it sends its own headers" : void 0;
28
- };
29
- var rewriteSchema = (schema, proxy, warnings) => {
30
- for (const element of Object.values(schema.flat)) {
31
- const attributes = element.attributes;
32
- for (const name of URL_ATTRIBUTES) {
33
- const value = attributes[name];
34
- if (typeof value === "string" && isRemote(value) && !isGranted(value, proxy)) attributes[name] = grantUrl(value, proxy);
35
- }
36
- for (const name of MARKUP_ATTRIBUTES) {
37
- const value = attributes[name];
38
- if (typeof value === "string" && value.includes("http")) attributes[name] = rewriteText(value, proxy);
39
- }
40
- const query = attributes.query;
41
- if (element.definition.type !== FETCHING_TYPE || typeof query !== "string" || !isRemote(query)) continue;
42
- const blocked = unproxyableFetch(element);
43
- if (blocked) {
44
- 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.`);
45
- continue;
46
- }
47
- if (!isGranted(query, proxy)) attributes.query = grantUrl(query, proxy, "data");
48
- }
49
- };
50
- var rewriteStyle = (style, proxy) => {
51
- for (const items of Object.values(style.platform)) for (const item of Object.values(items)) {
52
- for (const selector of Object.values(item.attributes)) {
53
- rewriteStyleBlock(selector, proxy);
54
- for (const variant of Object.values(selector.variants ?? {})) rewriteStyleBlock(variant, proxy);
55
- }
56
- if (item.cache.includes("url(")) item.cache = rewriteText(item.cache, proxy);
57
- }
58
- if (style.cache.includes("url(")) style.cache = rewriteText(style.cache, proxy);
59
- };
60
- /** Point everything an authored widget loads from outside — images, media, fonts, and the data an apiContainer
61
- * fetches — at this server's endpoint, in place. The AGENT never sees this: it authors the real URL and this runs
62
- * afterwards, on the throwaway space a render builds (so nothing shared is mutated) and before the global style
63
- * cache is compiled (so the concatenated CSS comes out already rewritten). Returns what could not be rewritten,
64
- * which is the only part the model hears about. */
65
- var proxifyResources = (space, proxy) => {
66
- const warnings = [];
67
- rewriteSchema(space.schema, proxy, warnings);
68
- rewriteStyle(space.style, proxy);
69
- return warnings;
70
- };
71
- //#endregion
72
- export { proxifyResources, rewriteText };
@@ -1,15 +0,0 @@
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 };
@@ -1,9 +0,0 @@
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 };
@@ -1,30 +0,0 @@
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 };
@@ -1,18 +0,0 @@
1
- import { cssProperties, cssShorthands } from "../catalogs/cssCatalog/index.js";
2
- import { buildTypeRegistry } from "../catalogs/registry.js";
3
- import "../helpers/uris.js";
4
- import { guideText } from "../helpers/guide.js";
5
- import { envelope } from "./envelope.js";
6
- //#region src/modules/mcp/resources/core.ts
7
- /** Space-independent singletons: the usage guide, the observed type registry and the CSS property catalog.
8
- * Returns undefined when the URI is not one of these, so the router falls through to the next resolver. */
9
- var readCoreResource = (space, uri) => {
10
- if (uri === "plitzi://guide") return envelope(guideText);
11
- if (uri === "plitzi://types") return envelope(buildTypeRegistry(space.schema, space.catalog));
12
- if (uri === "plitzi://css-properties") return envelope({
13
- properties: cssProperties,
14
- shorthands: cssShorthands
15
- });
16
- };
17
- //#endregion
18
- export { readCoreResource };
@@ -1,14 +0,0 @@
1
- import { computeVersion } from "../helpers/computeVersion.js";
2
- //#region src/modules/mcp/resources/envelope.ts
3
- /** Wrap any read projection with the version its optimistic-concurrency checks key on. */
4
- var envelope = (data) => ({
5
- stateVersion: computeVersion(data),
6
- data
7
- });
8
- var jsonContents = (uri, data) => ({ contents: [{
9
- uri,
10
- mimeType: "application/json",
11
- text: JSON.stringify(data)
12
- }] });
13
- //#endregion
14
- export { envelope, jsonContents };
@@ -1,31 +0,0 @@
1
- import { cssProperties, cssShorthands } from "../catalogs/cssCatalog/index.js";
2
- import { buildDataSourceCatalog, buildInteractionCatalog } from "../catalogs/observed.js";
3
- import { buildTypeRegistry } from "../catalogs/registry.js";
4
- import { guideQuickstart } from "../helpers/guide.js";
5
- import { envelope } from "./envelope.js";
6
- import { definitionRefs, styleVariablesToAI } from "../tools/operations/style/translator.js";
7
- import { foldersToAI, pageSummariesToAI, schemaVariablesToAI, settingsToAI } from "../tools/operations/schema/translator.js";
8
- //#region src/modules/mcp/resources/primer.ts
9
- /** The cold-start bundle: everything the guide says to read before the first write, in one round-trip.
10
- * Summaries only — never full page/element trees (those are opened on demand), so it stays cheap even on a
11
- * large space. Carries the condensed `guideQuickstart` (not the full guideText, which the agent reads on demand at
12
- * plitzi://guide) to keep the bundle small. Returns undefined when the URI is not the primer. */
13
- var readPrimerResource = (space, env, uri) => {
14
- if (uri !== `plitzi://primer/${env}`) return;
15
- return envelope({
16
- guide: guideQuickstart,
17
- types: buildTypeRegistry(space.schema, space.catalog),
18
- cssProperties,
19
- cssShorthands,
20
- pages: pageSummariesToAI(space.schema),
21
- folders: foldersToAI(space.schema),
22
- definitions: definitionRefs(space.style),
23
- styleVariables: styleVariablesToAI(space.style),
24
- schemaVariables: schemaVariablesToAI(space.schema, false),
25
- settings: settingsToAI(space.schema),
26
- interactions: buildInteractionCatalog(space.schema),
27
- dataSources: buildDataSourceCatalog(space.schema)
28
- });
29
- };
30
- //#endregion
31
- export { readPrimerResource };
@@ -1,190 +0,0 @@
1
- import { cssProperties, cssShorthands } from "../catalogs/cssCatalog/index.js";
2
- import { guideText } from "../helpers/guide.js";
3
- import { resourceErrorMessage } from "./canonical.js";
4
- import { envelope, jsonContents } from "./envelope.js";
5
- import { registerRenderResources } from "./renderGuide.js";
6
- import { readResource } from "./router.js";
7
- import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
8
- //#region src/modules/mcp/resources/register.ts
9
- /** Register every resource on the MCP server: fixed listings plus templated per-item reads. The space is
10
- * loaded lazily via getSpace, so listing resources never touches the store — only reading one does.
11
- *
12
- * `hasSpace` is false when the connection reaches no space (a guest / widgets-only grant): the space-dependent
13
- * families are then not registered at all, so the catalog the agent browses holds only what it can actually
14
- * open — no listing that answers every read with the same refusal. */
15
- var registerResources = (server, getSpace, env, log, hasSpace) => {
16
- const emit = async (uri) => {
17
- const start = performance.now();
18
- try {
19
- const result = readResource(await getSpace(), env, uri);
20
- if (!result) throw new Error(resourceErrorMessage(env, uri));
21
- log.resourceRead(uri, performance.now() - start);
22
- return jsonContents(uri, result);
23
- } catch (error) {
24
- log.resourceRead(uri, performance.now() - start, error);
25
- throw error;
26
- }
27
- };
28
- const emitStatic = (uri, read) => {
29
- const start = performance.now();
30
- const result = read();
31
- log.resourceRead(uri, performance.now() - start);
32
- return result;
33
- };
34
- server.registerResource("Guide", "plitzi://guide", {
35
- description: "How to read and write this space with mcp-ai",
36
- mimeType: "text/markdown"
37
- }, () => emitStatic("plitzi://guide", () => ({ contents: [{
38
- uri: "plitzi://guide",
39
- mimeType: "text/markdown",
40
- text: guideText
41
- }] })));
42
- server.registerResource("CSS properties", "plitzi://css-properties", {
43
- description: "Valid kebab-case CSS property keys, plus the shorthands that are accepted and auto-expanded",
44
- mimeType: "application/json"
45
- }, () => emitStatic("plitzi://css-properties", () => jsonContents("plitzi://css-properties", envelope({
46
- properties: cssProperties,
47
- shorthands: cssShorthands
48
- }))));
49
- registerRenderResources(server, log);
50
- if (!hasSpace) return;
51
- const fixed = [
52
- [
53
- "Primer",
54
- `plitzi://primer/${env}`,
55
- "Read this FIRST. Cold-start bundle in one call: guide, types, css-properties and SUMMARIES of pages, definitions and variables — summaries only, never full page/element trees, so it stays small even on a large space. Open a page or element on demand afterwards."
56
- ],
57
- [
58
- "Element types",
59
- "plitzi://types",
60
- "Observed element types with props, slots and subTypes"
61
- ],
62
- [
63
- "Pages",
64
- `plitzi://schema/${env}/pages`,
65
- "Page summaries (ref, label, elementCount) — no element trees"
66
- ],
67
- [
68
- "Folders",
69
- `plitzi://folders/${env}`,
70
- "Page folders (the sidebar tree): ref, name, slug, parentId"
71
- ],
72
- [
73
- "Style definitions",
74
- `plitzi://definitions/${env}`,
75
- "Style definition refs (names)"
76
- ],
77
- [
78
- "Global styles",
79
- `plitzi://global-styles/${env}`,
80
- "Element types that have a site-wide global style"
81
- ],
82
- [
83
- "Id styles",
84
- `plitzi://id-styles/${env}`,
85
- "DOM ids that have an id rule (#id) targeting a single element"
86
- ],
87
- [
88
- "Style variables",
89
- `plitzi://style-variables/${env}`,
90
- "Design tokens by category"
91
- ],
92
- [
93
- "Schema variables",
94
- `plitzi://schema-variables/${env}`,
95
- "Space-level values referenced via {{name}}"
96
- ],
97
- [
98
- "Settings",
99
- `plitzi://settings/${env}`,
100
- "Space-level settings: global customCss and state/auth configuration"
101
- ],
102
- [
103
- "Interactions catalog",
104
- `plitzi://interactions/${env}`,
105
- "Interaction actions (observed, grouped by node type) plus the built-in vocabularies — globalCallbacks (with their source module), element callbacks and utilities — each with its full param schema, the vocabulary for upsertInteractionFlow"
106
- ],
107
- [
108
- "Data sources catalog",
109
- `plitzi://data-sources/${env}`,
110
- "Data-source paths and binding targets observed in this space — the vocabulary for upsertBinding"
111
- ],
112
- [
113
- "Style definitions (schema alias)",
114
- `plitzi://schema/${env}/definitions`,
115
- "Alias of plitzi://definitions/{env}"
116
- ],
117
- [
118
- "Style variables (schema alias)",
119
- `plitzi://schema/${env}/style-variables`,
120
- "Alias of plitzi://style-variables/{env}"
121
- ],
122
- [
123
- "Schema variables (schema alias)",
124
- `plitzi://schema/${env}/schema-variables`,
125
- "Alias of plitzi://schema-variables/{env}"
126
- ]
127
- ];
128
- for (const [name, uri, description] of fixed) server.registerResource(name, uri, {
129
- description,
130
- mimeType: "application/json"
131
- }, () => emit(uri));
132
- const templates = [
133
- [
134
- "Page",
135
- `plitzi://schema/${env}/pages/{ref}`,
136
- "One page as a skeleton tree (ref/type/label/children), no props"
137
- ],
138
- [
139
- "Page styles",
140
- `plitzi://schema/${env}/pages/{ref}/styles`,
141
- "Every style a page uses in one read: class definitions its elements attach (with CSS) + global styles"
142
- ],
143
- [
144
- "Element",
145
- `plitzi://schema/${env}/elements/{ref}`,
146
- "One element in full detail (props, style) by ref or id"
147
- ],
148
- [
149
- "Folder",
150
- `plitzi://folders/${env}/{ref}`,
151
- "One page folder (name, slug, parentId) by folder id"
152
- ],
153
- [
154
- "Style definition",
155
- `plitzi://definitions/${env}/{ref}`,
156
- "One style definition (CSS) by class ref"
157
- ],
158
- [
159
- "Global style",
160
- `plitzi://global-styles/${env}/{componentType}`,
161
- "The site-wide CSS applied to every element of one type"
162
- ],
163
- [
164
- "Id style",
165
- `plitzi://id-styles/${env}/{targetId}`,
166
- "The CSS of an id rule (#id) targeting a single element"
167
- ],
168
- [
169
- "Style variables by category",
170
- `plitzi://style-variables/${env}/{category}`,
171
- "Design tokens for one category"
172
- ],
173
- [
174
- "Style definition (schema alias)",
175
- `plitzi://schema/${env}/definitions/{ref}`,
176
- "Alias of plitzi://definitions/{env}/{ref}"
177
- ],
178
- [
179
- "Style variables by category (schema alias)",
180
- `plitzi://schema/${env}/style-variables/{category}`,
181
- "Alias of plitzi://style-variables/{env}/{category}"
182
- ]
183
- ];
184
- for (const [name, tpl, description] of templates) server.registerResource(name, new ResourceTemplate(tpl, { list: void 0 }), {
185
- description,
186
- mimeType: "application/json"
187
- }, (uri) => emit(uri.href));
188
- };
189
- //#endregion
190
- export { registerResources };