@vibesdotdev/applets 0.0.0-stage → 1.0.0-rc.3

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 (421) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +43 -2
  3. package/dist/applet-gate.d.ts +47 -0
  4. package/dist/applet-gate.d.ts.map +1 -0
  5. package/dist/applet-gate.js +167 -0
  6. package/dist/applet-gate.js.map +1 -0
  7. package/dist/applet-root-surface.d.ts +135 -0
  8. package/dist/applet-root-surface.d.ts.map +1 -0
  9. package/dist/applet-root-surface.js +222 -0
  10. package/dist/applet-root-surface.js.map +1 -0
  11. package/dist/applet-value-bound.d.ts +24 -0
  12. package/dist/applet-value-bound.d.ts.map +1 -0
  13. package/dist/applet-value-bound.js +46 -0
  14. package/dist/applet-value-bound.js.map +1 -0
  15. package/dist/applets.cloud.plugin.d.ts +4 -0
  16. package/dist/applets.cloud.plugin.d.ts.map +1 -0
  17. package/dist/applets.cloud.plugin.js +11 -0
  18. package/dist/applets.cloud.plugin.js.map +1 -0
  19. package/dist/applets.consumer.plugin.d.ts +4 -0
  20. package/dist/applets.consumer.plugin.d.ts.map +1 -0
  21. package/dist/applets.consumer.plugin.js +11 -0
  22. package/dist/applets.consumer.plugin.js.map +1 -0
  23. package/dist/applets.plugin.d.ts +3 -0
  24. package/dist/applets.plugin.d.ts.map +1 -0
  25. package/dist/applets.plugin.js +30 -0
  26. package/dist/applets.plugin.js.map +1 -0
  27. package/dist/authorization.d.ts +87 -0
  28. package/dist/authorization.d.ts.map +1 -0
  29. package/dist/authorization.js +189 -0
  30. package/dist/authorization.js.map +1 -0
  31. package/dist/browser-runtime.d.ts +34 -0
  32. package/dist/browser-runtime.d.ts.map +1 -0
  33. package/dist/browser-runtime.js +5 -0
  34. package/dist/browser-runtime.js.map +1 -0
  35. package/dist/build-definition.d.ts +34 -0
  36. package/dist/build-definition.d.ts.map +1 -0
  37. package/dist/build-definition.js +44 -0
  38. package/dist/build-definition.js.map +1 -0
  39. package/dist/capabilities/capability.kind.d.ts +44 -0
  40. package/dist/capabilities/capability.kind.d.ts.map +1 -0
  41. package/dist/capabilities/capability.kind.js +17 -0
  42. package/dist/capabilities/capability.kind.js.map +1 -0
  43. package/dist/capabilities/runtime-dispatch.d.ts +9 -0
  44. package/dist/capabilities/runtime-dispatch.d.ts.map +1 -0
  45. package/dist/capabilities/runtime-dispatch.js +62 -0
  46. package/dist/capabilities/runtime-dispatch.js.map +1 -0
  47. package/dist/cli/applet-group.descriptor.d.ts +11 -0
  48. package/dist/cli/applet-group.descriptor.d.ts.map +1 -0
  49. package/dist/cli/applet-group.descriptor.js +19 -0
  50. package/dist/cli/applet-group.descriptor.js.map +1 -0
  51. package/dist/cli/applet-local-store.storage.descriptor.d.ts +66 -0
  52. package/dist/cli/applet-local-store.storage.descriptor.d.ts.map +1 -0
  53. package/dist/cli/applet-local-store.storage.descriptor.js +39 -0
  54. package/dist/cli/applet-local-store.storage.descriptor.js.map +1 -0
  55. package/dist/cli/applet-serve.process.descriptor.d.ts +37 -0
  56. package/dist/cli/applet-serve.process.descriptor.d.ts.map +1 -0
  57. package/dist/cli/applet-serve.process.descriptor.js +41 -0
  58. package/dist/cli/applet-serve.process.descriptor.js.map +1 -0
  59. package/dist/cli/commands/build.command.descriptor.d.ts +40 -0
  60. package/dist/cli/commands/build.command.descriptor.d.ts.map +1 -0
  61. package/dist/cli/commands/build.command.descriptor.js +52 -0
  62. package/dist/cli/commands/build.command.descriptor.js.map +1 -0
  63. package/dist/cli/commands/build.command.impl.d.ts +8 -0
  64. package/dist/cli/commands/build.command.impl.d.ts.map +1 -0
  65. package/dist/cli/commands/build.command.impl.js +116 -0
  66. package/dist/cli/commands/build.command.impl.js.map +1 -0
  67. package/dist/cli/commands/init.command.descriptor.d.ts +29 -0
  68. package/dist/cli/commands/init.command.descriptor.d.ts.map +1 -0
  69. package/dist/cli/commands/init.command.descriptor.js +23 -0
  70. package/dist/cli/commands/init.command.descriptor.js.map +1 -0
  71. package/dist/cli/commands/init.command.impl.d.ts +7 -0
  72. package/dist/cli/commands/init.command.impl.d.ts.map +1 -0
  73. package/dist/cli/commands/init.command.impl.js +64 -0
  74. package/dist/cli/commands/init.command.impl.js.map +1 -0
  75. package/dist/cli/commands/list.command.descriptor.d.ts +26 -0
  76. package/dist/cli/commands/list.command.descriptor.d.ts.map +1 -0
  77. package/dist/cli/commands/list.command.descriptor.js +22 -0
  78. package/dist/cli/commands/list.command.descriptor.js.map +1 -0
  79. package/dist/cli/commands/list.command.impl.d.ts +13 -0
  80. package/dist/cli/commands/list.command.impl.d.ts.map +1 -0
  81. package/dist/cli/commands/list.command.impl.js +47 -0
  82. package/dist/cli/commands/list.command.impl.js.map +1 -0
  83. package/dist/cli/commands/serve-stylesheet.d.ts +11 -0
  84. package/dist/cli/commands/serve-stylesheet.d.ts.map +1 -0
  85. package/dist/cli/commands/serve-stylesheet.js +50 -0
  86. package/dist/cli/commands/serve-stylesheet.js.map +1 -0
  87. package/dist/cli/commands/serve-surface.d.ts +36 -0
  88. package/dist/cli/commands/serve-surface.d.ts.map +1 -0
  89. package/dist/cli/commands/serve-surface.js +410 -0
  90. package/dist/cli/commands/serve-surface.js.map +1 -0
  91. package/dist/cli/commands/serve.command.descriptor.d.ts +42 -0
  92. package/dist/cli/commands/serve.command.descriptor.d.ts.map +1 -0
  93. package/dist/cli/commands/serve.command.descriptor.js +46 -0
  94. package/dist/cli/commands/serve.command.descriptor.js.map +1 -0
  95. package/dist/cli/commands/serve.command.impl.d.ts +110 -0
  96. package/dist/cli/commands/serve.command.impl.d.ts.map +1 -0
  97. package/dist/cli/commands/serve.command.impl.js +1105 -0
  98. package/dist/cli/commands/serve.command.impl.js.map +1 -0
  99. package/dist/cli/commands/serve.schemas.d.ts +127 -0
  100. package/dist/cli/commands/serve.schemas.d.ts.map +1 -0
  101. package/dist/cli/commands/serve.schemas.js +85 -0
  102. package/dist/cli/commands/serve.schemas.js.map +1 -0
  103. package/dist/cli/commands/served-applet-browser.d.ts +12 -0
  104. package/dist/cli/commands/served-applet-browser.d.ts.map +1 -0
  105. package/dist/cli/commands/served-applet-browser.js +48 -0
  106. package/dist/cli/commands/served-applet-browser.js.map +1 -0
  107. package/dist/cli/commands/served-applet-connection.d.ts +15 -0
  108. package/dist/cli/commands/served-applet-connection.d.ts.map +1 -0
  109. package/dist/cli/commands/served-applet-connection.js +25 -0
  110. package/dist/cli/commands/served-applet-connection.js.map +1 -0
  111. package/dist/cli/commands/served-applet-rpc.d.ts +16 -0
  112. package/dist/cli/commands/served-applet-rpc.d.ts.map +1 -0
  113. package/dist/cli/commands/served-applet-rpc.js +108 -0
  114. package/dist/cli/commands/served-applet-rpc.js.map +1 -0
  115. package/dist/cli/commands/served-applet-surface.d.ts +14 -0
  116. package/dist/cli/commands/served-applet-surface.d.ts.map +1 -0
  117. package/dist/cli/commands/served-applet-surface.js +99 -0
  118. package/dist/cli/commands/served-applet-surface.js.map +1 -0
  119. package/dist/cli/commands/templates.command.descriptor.d.ts +22 -0
  120. package/dist/cli/commands/templates.command.descriptor.d.ts.map +1 -0
  121. package/dist/cli/commands/templates.command.descriptor.js +21 -0
  122. package/dist/cli/commands/templates.command.descriptor.js.map +1 -0
  123. package/dist/cli/commands/templates.command.impl.d.ts +35 -0
  124. package/dist/cli/commands/templates.command.impl.d.ts.map +1 -0
  125. package/dist/cli/commands/templates.command.impl.js +59 -0
  126. package/dist/cli/commands/templates.command.impl.js.map +1 -0
  127. package/dist/cli/index.d.ts +7 -0
  128. package/dist/cli/index.d.ts.map +1 -0
  129. package/dist/cli/index.js +7 -0
  130. package/dist/cli/index.js.map +1 -0
  131. package/dist/cli/local-serve.authz-policy.descriptor.d.ts +22 -0
  132. package/dist/cli/local-serve.authz-policy.descriptor.d.ts.map +1 -0
  133. package/dist/cli/local-serve.authz-policy.descriptor.js +13 -0
  134. package/dist/cli/local-serve.authz-policy.descriptor.js.map +1 -0
  135. package/dist/cli/plugin.d.ts +19 -0
  136. package/dist/cli/plugin.d.ts.map +1 -0
  137. package/dist/cli/plugin.js +57 -0
  138. package/dist/cli/plugin.js.map +1 -0
  139. package/dist/cli/project-files.d.ts +48 -0
  140. package/dist/cli/project-files.d.ts.map +1 -0
  141. package/dist/cli/project-files.js +130 -0
  142. package/dist/cli/project-files.js.map +1 -0
  143. package/dist/client/contract.d.ts +113 -0
  144. package/dist/client/contract.d.ts.map +1 -0
  145. package/dist/client/contract.js +17 -0
  146. package/dist/client/contract.js.map +1 -0
  147. package/dist/client/index.d.ts +3 -0
  148. package/dist/client/index.d.ts.map +1 -0
  149. package/dist/client/index.js +3 -0
  150. package/dist/client/index.js.map +1 -0
  151. package/dist/client/repository.context.d.ts +113 -0
  152. package/dist/client/repository.context.d.ts.map +1 -0
  153. package/dist/client/repository.context.js +8 -0
  154. package/dist/client/repository.context.js.map +1 -0
  155. package/dist/client/runtime-client.d.ts +22 -0
  156. package/dist/client/runtime-client.d.ts.map +1 -0
  157. package/dist/client/runtime-client.js +200 -0
  158. package/dist/client/runtime-client.js.map +1 -0
  159. package/dist/companion-path.d.ts +25 -0
  160. package/dist/companion-path.d.ts.map +1 -0
  161. package/dist/companion-path.js +90 -0
  162. package/dist/companion-path.js.map +1 -0
  163. package/dist/component-ref.d.ts +12 -0
  164. package/dist/component-ref.d.ts.map +1 -0
  165. package/dist/component-ref.js +45 -0
  166. package/dist/component-ref.js.map +1 -0
  167. package/dist/composition-plan.d.ts +92 -0
  168. package/dist/composition-plan.d.ts.map +1 -0
  169. package/dist/composition-plan.js +44 -0
  170. package/dist/composition-plan.js.map +1 -0
  171. package/dist/composition.d.ts +97 -0
  172. package/dist/composition.d.ts.map +1 -0
  173. package/dist/composition.js +99 -0
  174. package/dist/composition.js.map +1 -0
  175. package/dist/config/applets.config.descriptor.d.ts +55 -0
  176. package/dist/config/applets.config.descriptor.d.ts.map +1 -0
  177. package/dist/config/applets.config.descriptor.js +37 -0
  178. package/dist/config/applets.config.descriptor.js.map +1 -0
  179. package/dist/config/load.d.ts +4 -0
  180. package/dist/config/load.d.ts.map +1 -0
  181. package/dist/config/load.js +12 -0
  182. package/dist/config/load.js.map +1 -0
  183. package/dist/content-path.d.ts +62 -0
  184. package/dist/content-path.d.ts.map +1 -0
  185. package/dist/content-path.js +121 -0
  186. package/dist/content-path.js.map +1 -0
  187. package/dist/contribution-registry.d.ts +270 -0
  188. package/dist/contribution-registry.d.ts.map +1 -0
  189. package/dist/contribution-registry.js +488 -0
  190. package/dist/contribution-registry.js.map +1 -0
  191. package/dist/docs/applets.docs.descriptor.d.ts +4 -0
  192. package/dist/docs/applets.docs.descriptor.d.ts.map +1 -0
  193. package/dist/docs/applets.docs.descriptor.js +74 -0
  194. package/dist/docs/applets.docs.descriptor.js.map +1 -0
  195. package/dist/host/local-host.contract.d.ts +7 -0
  196. package/dist/host/local-host.contract.d.ts.map +1 -0
  197. package/dist/host/local-host.contract.js +2 -0
  198. package/dist/host/local-host.contract.js.map +1 -0
  199. package/dist/host/local-host.impl.d.ts +9 -0
  200. package/dist/host/local-host.impl.d.ts.map +1 -0
  201. package/dist/host/local-host.impl.js +41 -0
  202. package/dist/host/local-host.impl.js.map +1 -0
  203. package/dist/host/local-host.plugin.d.ts +3 -0
  204. package/dist/host/local-host.plugin.d.ts.map +1 -0
  205. package/dist/host/local-host.plugin.js +16 -0
  206. package/dist/host/local-host.plugin.js.map +1 -0
  207. package/dist/index.d.ts +28 -0
  208. package/dist/index.d.ts.map +1 -0
  209. package/dist/index.js +27 -0
  210. package/dist/index.js.map +1 -0
  211. package/dist/local-project.d.ts +106 -0
  212. package/dist/local-project.d.ts.map +1 -0
  213. package/dist/local-project.js +277 -0
  214. package/dist/local-project.js.map +1 -0
  215. package/dist/manifest-hash.d.ts +12 -0
  216. package/dist/manifest-hash.d.ts.map +1 -0
  217. package/dist/manifest-hash.js +76 -0
  218. package/dist/manifest-hash.js.map +1 -0
  219. package/dist/presentation.d.ts +43 -0
  220. package/dist/presentation.d.ts.map +1 -0
  221. package/dist/presentation.js +36 -0
  222. package/dist/presentation.js.map +1 -0
  223. package/dist/retention.d.ts +34 -0
  224. package/dist/retention.d.ts.map +1 -0
  225. package/dist/retention.js +51 -0
  226. package/dist/retention.js.map +1 -0
  227. package/dist/schemas/applet-messages.d.ts +97 -0
  228. package/dist/schemas/applet-messages.d.ts.map +1 -0
  229. package/dist/schemas/applet-messages.js +51 -0
  230. package/dist/schemas/applet-messages.js.map +1 -0
  231. package/dist/schemas/capabilities.d.ts +37 -0
  232. package/dist/schemas/capabilities.d.ts.map +1 -0
  233. package/dist/schemas/capabilities.js +28 -0
  234. package/dist/schemas/capabilities.js.map +1 -0
  235. package/dist/schemas/component-release-ref.d.ts +13 -0
  236. package/dist/schemas/component-release-ref.d.ts.map +1 -0
  237. package/dist/schemas/component-release-ref.js +21 -0
  238. package/dist/schemas/component-release-ref.js.map +1 -0
  239. package/dist/schemas/contributes.d.ts +306 -0
  240. package/dist/schemas/contributes.d.ts.map +1 -0
  241. package/dist/schemas/contributes.js +184 -0
  242. package/dist/schemas/contributes.js.map +1 -0
  243. package/dist/schemas/definition.d.ts +301 -0
  244. package/dist/schemas/definition.d.ts.map +1 -0
  245. package/dist/schemas/definition.js +457 -0
  246. package/dist/schemas/definition.js.map +1 -0
  247. package/dist/schemas/dispatch.d.ts +52 -0
  248. package/dist/schemas/dispatch.d.ts.map +1 -0
  249. package/dist/schemas/dispatch.js +32 -0
  250. package/dist/schemas/dispatch.js.map +1 -0
  251. package/dist/schemas/grants.d.ts +56 -0
  252. package/dist/schemas/grants.d.ts.map +1 -0
  253. package/dist/schemas/grants.js +64 -0
  254. package/dist/schemas/grants.js.map +1 -0
  255. package/dist/schemas/index.d.ts +16 -0
  256. package/dist/schemas/index.d.ts.map +1 -0
  257. package/dist/schemas/index.js +16 -0
  258. package/dist/schemas/index.js.map +1 -0
  259. package/dist/schemas/instance.d.ts +230 -0
  260. package/dist/schemas/instance.d.ts.map +1 -0
  261. package/dist/schemas/instance.js +44 -0
  262. package/dist/schemas/instance.js.map +1 -0
  263. package/dist/schemas/lineage.d.ts +60 -0
  264. package/dist/schemas/lineage.d.ts.map +1 -0
  265. package/dist/schemas/lineage.js +52 -0
  266. package/dist/schemas/lineage.js.map +1 -0
  267. package/dist/schemas/observation.d.ts +70 -0
  268. package/dist/schemas/observation.d.ts.map +1 -0
  269. package/dist/schemas/observation.js +49 -0
  270. package/dist/schemas/observation.js.map +1 -0
  271. package/dist/schemas/patterns.d.ts +24 -0
  272. package/dist/schemas/patterns.d.ts.map +1 -0
  273. package/dist/schemas/patterns.js +24 -0
  274. package/dist/schemas/patterns.js.map +1 -0
  275. package/dist/schemas/publishing.d.ts +27 -0
  276. package/dist/schemas/publishing.d.ts.map +1 -0
  277. package/dist/schemas/publishing.js +20 -0
  278. package/dist/schemas/publishing.js.map +1 -0
  279. package/dist/schemas/run.d.ts +35 -0
  280. package/dist/schemas/run.d.ts.map +1 -0
  281. package/dist/schemas/run.js +26 -0
  282. package/dist/schemas/run.js.map +1 -0
  283. package/dist/schemas/share-link.d.ts +61 -0
  284. package/dist/schemas/share-link.d.ts.map +1 -0
  285. package/dist/schemas/share-link.js +68 -0
  286. package/dist/schemas/share-link.js.map +1 -0
  287. package/dist/schemas/state-events.d.ts +66 -0
  288. package/dist/schemas/state-events.d.ts.map +1 -0
  289. package/dist/schemas/state-events.js +66 -0
  290. package/dist/schemas/state-events.js.map +1 -0
  291. package/dist/schemas/subscription.d.ts +47 -0
  292. package/dist/schemas/subscription.d.ts.map +1 -0
  293. package/dist/schemas/subscription.js +46 -0
  294. package/dist/schemas/subscription.js.map +1 -0
  295. package/dist/schemas/template-revision.d.ts +53 -0
  296. package/dist/schemas/template-revision.d.ts.map +1 -0
  297. package/dist/schemas/template-revision.js +30 -0
  298. package/dist/schemas/template-revision.js.map +1 -0
  299. package/dist/selection.d.ts +22 -0
  300. package/dist/selection.d.ts.map +1 -0
  301. package/dist/selection.js +21 -0
  302. package/dist/selection.js.map +1 -0
  303. package/dist/storage/index.d.ts +27 -0
  304. package/dist/storage/index.d.ts.map +1 -0
  305. package/dist/storage/index.js +27 -0
  306. package/dist/storage/index.js.map +1 -0
  307. package/dist/storage/records.d.ts +28 -0
  308. package/dist/storage/records.d.ts.map +1 -0
  309. package/dist/storage/records.js +272 -0
  310. package/dist/storage/records.js.map +1 -0
  311. package/dist/svelte/applets-svelte.plugin.d.ts +38 -0
  312. package/dist/svelte/applets-svelte.plugin.d.ts.map +1 -0
  313. package/dist/svelte/applets-svelte.plugin.js +25 -0
  314. package/dist/svelte/components/AppletCanvas.svelte +488 -0
  315. package/dist/svelte/components/AppletCanvas.svelte.d.ts +53 -0
  316. package/dist/svelte/components/AppletCanvas.svelte.d.ts.map +1 -0
  317. package/dist/svelte/components/AppletCatalog.svelte +42 -0
  318. package/dist/svelte/components/AppletCatalog.svelte.d.ts +8 -0
  319. package/dist/svelte/components/AppletCatalog.svelte.d.ts.map +1 -0
  320. package/dist/svelte/components/AppletComposition.svelte +128 -0
  321. package/dist/svelte/components/AppletComposition.svelte.d.ts +30 -0
  322. package/dist/svelte/components/AppletComposition.svelte.d.ts.map +1 -0
  323. package/dist/svelte/components/AppletConsent.svelte +143 -0
  324. package/dist/svelte/components/AppletConsent.svelte.d.ts +12 -0
  325. package/dist/svelte/components/AppletConsent.svelte.d.ts.map +1 -0
  326. package/dist/svelte/components/LocalAppletView.svelte +102 -0
  327. package/dist/svelte/components/LocalAppletView.svelte.d.ts +13 -0
  328. package/dist/svelte/components/LocalAppletView.svelte.d.ts.map +1 -0
  329. package/dist/svelte/components/RunnableTracker.svelte +51 -0
  330. package/dist/svelte/components/RunnableTracker.svelte.d.ts +18 -0
  331. package/dist/svelte/components/RunnableTracker.svelte.d.ts.map +1 -0
  332. package/dist/svelte/index.d.ts +11 -0
  333. package/dist/svelte/index.d.ts.map +1 -0
  334. package/dist/svelte/index.js +10 -0
  335. package/dist/svelte/lib/canvas-lifecycle.d.ts +68 -0
  336. package/dist/svelte/lib/canvas-lifecycle.d.ts.map +1 -0
  337. package/dist/svelte/lib/canvas-lifecycle.js +99 -0
  338. package/dist/svelte/lib/capability-review.d.ts +64 -0
  339. package/dist/svelte/lib/capability-review.d.ts.map +1 -0
  340. package/dist/svelte/lib/capability-review.js +77 -0
  341. package/dist/svelte/lib/message-protocol.d.ts +184 -0
  342. package/dist/svelte/lib/message-protocol.d.ts.map +1 -0
  343. package/dist/svelte/lib/message-protocol.js +251 -0
  344. package/dist/svelte/runnable-source.d.ts +5 -0
  345. package/dist/svelte/runnable-source.d.ts.map +1 -0
  346. package/dist/svelte/runnable-source.js +92 -0
  347. package/dist/svelte/serve-index.svelte +39 -0
  348. package/dist/svelte/serve-index.svelte.d.ts +10 -0
  349. package/dist/svelte/serve-index.svelte.d.ts.map +1 -0
  350. package/dist/svelte/state.svelte.d.ts +26 -0
  351. package/dist/svelte/state.svelte.d.ts.map +1 -0
  352. package/dist/svelte/state.svelte.js +74 -0
  353. package/dist/svelte/styles.css +4 -0
  354. package/dist/svelte/tool-widgets/AppletToolCard.svelte +148 -0
  355. package/dist/svelte/tool-widgets/AppletToolCard.svelte.d.ts +5 -0
  356. package/dist/svelte/tool-widgets/AppletToolCard.svelte.d.ts.map +1 -0
  357. package/dist/svelte/tool-widgets/applet-tool-card.d.ts +41 -0
  358. package/dist/svelte/tool-widgets/applet-tool-card.d.ts.map +1 -0
  359. package/dist/svelte/tool-widgets/applet-tool-card.js +167 -0
  360. package/dist/svelte/tool-widgets/index.d.ts +3 -0
  361. package/dist/svelte/tool-widgets/index.d.ts.map +1 -0
  362. package/dist/svelte/tool-widgets/index.js +2 -0
  363. package/dist/templates/index.d.ts +2 -0
  364. package/dist/templates/index.d.ts.map +1 -0
  365. package/dist/templates/index.js +2 -0
  366. package/dist/templates/index.js.map +1 -0
  367. package/dist/templates/template.kind.d.ts +39 -0
  368. package/dist/templates/template.kind.d.ts.map +1 -0
  369. package/dist/templates/template.kind.js +29 -0
  370. package/dist/templates/template.kind.js.map +1 -0
  371. package/dist/tools/applet.descriptor.d.ts +196 -0
  372. package/dist/tools/applet.descriptor.d.ts.map +1 -0
  373. package/dist/tools/applet.descriptor.js +81 -0
  374. package/dist/tools/applet.descriptor.js.map +1 -0
  375. package/dist/tools/applet.impl.d.ts +32 -0
  376. package/dist/tools/applet.impl.d.ts.map +1 -0
  377. package/dist/tools/applet.impl.js +485 -0
  378. package/dist/tools/applet.impl.js.map +1 -0
  379. package/dist/tools/applet.schemas.d.ts +198 -0
  380. package/dist/tools/applet.schemas.d.ts.map +1 -0
  381. package/dist/tools/applet.schemas.js +136 -0
  382. package/dist/tools/applet.schemas.js.map +1 -0
  383. package/dist/tools/index.d.ts +3 -0
  384. package/dist/tools/index.d.ts.map +1 -0
  385. package/dist/tools/index.js +3 -0
  386. package/dist/tools/index.js.map +1 -0
  387. package/dist/upgrade.d.ts +45 -0
  388. package/dist/upgrade.d.ts.map +1 -0
  389. package/dist/upgrade.js +179 -0
  390. package/dist/upgrade.js.map +1 -0
  391. package/dist/vite.d.ts +26 -0
  392. package/dist/vite.d.ts.map +1 -0
  393. package/dist/vite.js +28 -0
  394. package/dist/vite.js.map +1 -0
  395. package/package.json +264 -4
  396. package/templates/applet-tour/Applet.svelte +95 -0
  397. package/templates/applet-tour/applet.descriptor.ts +15 -0
  398. package/templates/assembly-field/Applet.svelte +242 -0
  399. package/templates/assembly-field/applet.descriptor.ts +7 -0
  400. package/templates/assembly-field/applet.storage.json +47 -0
  401. package/templates/assembly-field/schemas/settings.ts +14 -0
  402. package/templates/assembly-field/settings.ts +32 -0
  403. package/templates/benchmark-comparison/Applet.svelte +17 -0
  404. package/templates/benchmark-comparison/applet.descriptor.ts +7 -0
  405. package/templates/file-diff-viewer/Applet.svelte +91 -0
  406. package/templates/file-diff-viewer/applet.descriptor.ts +14 -0
  407. package/templates/file-diff-viewer/diff.ts +63 -0
  408. package/templates/file-viewer/Applet.svelte +80 -0
  409. package/templates/file-viewer/applet.descriptor.ts +14 -0
  410. package/templates/fleet-runs/Applet.svelte +14 -0
  411. package/templates/fleet-runs/applet.descriptor.ts +7 -0
  412. package/templates/graph-runbook-tracker/Applet.svelte +13 -0
  413. package/templates/graph-runbook-tracker/applet.descriptor.ts +7 -0
  414. package/templates/runbook-tracker/Applet.svelte +12 -0
  415. package/templates/runbook-tracker/applet.descriptor.ts +7 -0
  416. package/templates/runnable-tracker/Applet.svelte +16 -0
  417. package/templates/runnable-tracker/applet.descriptor.ts +10 -0
  418. package/templates/storage-viewer/Applet.svelte +90 -0
  419. package/templates/storage-viewer/applet.descriptor.ts +15 -0
  420. package/templates/workspace-graph-runbook-tracker/Applet.svelte +13 -0
  421. package/templates/workspace-graph-runbook-tracker/applet.descriptor.ts +7 -0
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Applet canvas lifecycle — pure state machine, no Svelte reactivity.
3
+ *
4
+ * The canvas transitions through these states:
5
+ *
6
+ * loading → ready → approved → mounted → (running | crashed | unresponsive)
7
+ * ↑ ↓
8
+ * ←←← revoked / expired / disposed ←←←
9
+ *
10
+ * CRITICAL INVARIANT: no bundle URL, modulepreload, or runner document
11
+ * may enter the DOM before the `approved` state. The `loading` and `ready`
12
+ * states carry ONLY inert release metadata (digest, version, capabilities).
13
+ */
14
+ export function createCanvasContext() {
15
+ return {
16
+ state: 'loading',
17
+ consented: false,
18
+ runnerMounted: false,
19
+ heartbeatCount: 0,
20
+ error: null
21
+ };
22
+ }
23
+ /** Transition to `ready` — metadata loaded, awaiting consent. */
24
+ export function transitionToReady(ctx) {
25
+ if (ctx.state !== 'loading')
26
+ return ctx;
27
+ return { ...ctx, state: 'ready' };
28
+ }
29
+ /** Transition to `approved` — consent granted, may now mount the runner. */
30
+ export function transitionToApproved(ctx) {
31
+ if (ctx.state !== 'ready')
32
+ return ctx;
33
+ return { ...ctx, state: 'approved', consented: true };
34
+ }
35
+ /** Transition to `mounted` — runner frame is in the DOM. */
36
+ export function transitionToMounted(ctx) {
37
+ if (ctx.state !== 'approved')
38
+ return ctx;
39
+ return { ...ctx, state: 'mounted', runnerMounted: true };
40
+ }
41
+ /** Transition to `running` — runner handshake completed. */
42
+ export function transitionToRunning(ctx) {
43
+ if (ctx.state !== 'mounted')
44
+ return ctx;
45
+ return { ...ctx, state: 'running' };
46
+ }
47
+ /** Record a heartbeat from the runner. */
48
+ export function recordHeartbeat(ctx) {
49
+ return { ...ctx, heartbeatCount: ctx.heartbeatCount + 1 };
50
+ }
51
+ /** Transition to `crashed` — runner reported an error. */
52
+ export function transitionToCrashed(ctx, error) {
53
+ return { ...ctx, state: 'crashed', error };
54
+ }
55
+ /** Transition to `unresponsive` — heartbeat timeout. */
56
+ export function transitionToUnresponsive(ctx) {
57
+ return { ...ctx, state: 'unresponsive' };
58
+ }
59
+ /** Transition to `revoked` — capabilities revoked by user. */
60
+ export function transitionToRevoked(ctx) {
61
+ return { ...ctx, state: 'revoked', consented: false };
62
+ }
63
+ /** Transition to `expired` — launch lease expired. */
64
+ export function transitionToExpired(ctx) {
65
+ return { ...ctx, state: 'expired' };
66
+ }
67
+ /** Transition to `disposed` — runner destroyed, ports closed. */
68
+ export function transitionToDisposed(ctx) {
69
+ return { ...ctx, state: 'disposed', runnerMounted: false };
70
+ }
71
+ /**
72
+ * Returns true if the current state permits mounting the runner.
73
+ * Only `approved` permits mounting — never `loading`, `ready`, `running`,
74
+ * `crashed`, etc.
75
+ */
76
+ export function canMountRunner(ctx) {
77
+ return ctx.state === 'approved' && ctx.consented;
78
+ }
79
+ /**
80
+ * Returns true if the current state permits fetching the bundle bytes.
81
+ * Only `approved` (after consent) permits fetching — never `loading` or
82
+ * `ready`. This is the network assertion: zero bundle requests before
83
+ * consent.
84
+ */
85
+ export function canFetchBundle(ctx) {
86
+ return ctx.state === 'approved' && ctx.consented;
87
+ }
88
+ /**
89
+ * Returns true if the current state is terminal (no further transitions).
90
+ */
91
+ export function isTerminal(ctx) {
92
+ return ctx.state === 'disposed';
93
+ }
94
+ /**
95
+ * Returns true if the current state is an error state.
96
+ */
97
+ export function isErrorState(ctx) {
98
+ return ctx.state === 'crashed' || ctx.state === 'unresponsive';
99
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Capability review — pure logic for validating requested capabilities
3
+ * against granted capabilities for one exact release.
4
+ *
5
+ * The user consents to a set of capability tags at the exact release
6
+ * (componentId + version + bundleHash). The canvas shell must reject any
7
+ * capability the runner requests that was not in the granted set.
8
+ */
9
+ export interface CapabilityRequest {
10
+ tag: string;
11
+ /** Optional reason text supplied by the runner. */
12
+ reason?: string;
13
+ }
14
+ export interface GrantedCapability {
15
+ tag: string;
16
+ /** Reason text the user saw at consent time. */
17
+ reason: string;
18
+ }
19
+ export interface CapabilityReviewResult {
20
+ approved: string[];
21
+ rejected: string[];
22
+ /** True if all requests were approved. */
23
+ allApproved: boolean;
24
+ }
25
+ /**
26
+ * Review runner-requested capabilities against the granted set.
27
+ * Returns approved (in the granted set) and rejected (not granted).
28
+ */
29
+ export declare function reviewCapabilities(requested: CapabilityRequest[], granted: GrantedCapability[]): CapabilityReviewResult;
30
+ /**
31
+ * Returns true if the granted capabilities match the exact release
32
+ * (componentId + version + bundleHash). A grant from a different
33
+ * release is not valid — re-consent is required.
34
+ */
35
+ export declare function isGrantValidForRelease(grant: {
36
+ componentId: string;
37
+ version: string;
38
+ bundleHash: string;
39
+ }, release: {
40
+ componentId: string;
41
+ version: string;
42
+ bundleHash: string;
43
+ }): boolean;
44
+ /**
45
+ * Returns true if the bundle hash matches the expected digest.
46
+ * The runner must verify the bytes it received match the hash consented to.
47
+ */
48
+ export declare function verifyBundleHash(actualHash: string, expectedHash: string): boolean;
49
+ /**
50
+ * Normalize the registry's SHA-256 spelling.
51
+ *
52
+ * Platform currently persists the bare lowercase hex digest. Accepting the
53
+ * explicit `sha256:<hex>` spelling keeps the wire self-describing without
54
+ * weakening verification to arbitrary labels such as `sha256-test`.
55
+ */
56
+ export declare function normalizeBundleSha256(value: string): string | null;
57
+ /** Compute the digest of the exact bytes that will cross into the runner. */
58
+ export declare function bundleSha256Hex(bytes: ArrayBuffer): Promise<string>;
59
+ /**
60
+ * Bind execution to registry truth. The fetcher's reported hash is metadata;
61
+ * only hashing the received bytes proves what will actually execute.
62
+ */
63
+ export declare function verifyBundleBytes(bytes: ArrayBuffer, expectedHash: string): Promise<boolean>;
64
+ //# sourceMappingURL=capability-review.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-review.d.ts","sourceRoot":"","sources":["../../../src/svelte/lib/capability-review.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,iBAAiB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACtC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,0CAA0C;IAC1C,WAAW,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CACjC,SAAS,EAAE,iBAAiB,EAAE,EAC9B,OAAO,EAAE,iBAAiB,EAAE,GAC1B,sBAAsB,CAkBxB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACrC,KAAK,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,EACnE,OAAO,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACnE,OAAO,CAMT;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAElF;AAID;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMlE;AAED,6EAA6E;AAC7E,wBAAsB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAGzE;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACtC,KAAK,EAAE,WAAW,EAClB,YAAY,EAAE,MAAM,GAClB,OAAO,CAAC,OAAO,CAAC,CAIlB"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Capability review — pure logic for validating requested capabilities
3
+ * against granted capabilities for one exact release.
4
+ *
5
+ * The user consents to a set of capability tags at the exact release
6
+ * (componentId + version + bundleHash). The canvas shell must reject any
7
+ * capability the runner requests that was not in the granted set.
8
+ */
9
+ /**
10
+ * Review runner-requested capabilities against the granted set.
11
+ * Returns approved (in the granted set) and rejected (not granted).
12
+ */
13
+ export function reviewCapabilities(requested, granted) {
14
+ const grantedTags = new Set(granted.map((g) => g.tag));
15
+ const approved = [];
16
+ const rejected = [];
17
+ for (const req of requested) {
18
+ if (grantedTags.has(req.tag)) {
19
+ approved.push(req.tag);
20
+ }
21
+ else {
22
+ rejected.push(req.tag);
23
+ }
24
+ }
25
+ return {
26
+ approved,
27
+ rejected,
28
+ allApproved: rejected.length === 0
29
+ };
30
+ }
31
+ /**
32
+ * Returns true if the granted capabilities match the exact release
33
+ * (componentId + version + bundleHash). A grant from a different
34
+ * release is not valid — re-consent is required.
35
+ */
36
+ export function isGrantValidForRelease(grant, release) {
37
+ return (grant.componentId === release.componentId &&
38
+ grant.version === release.version &&
39
+ grant.bundleHash === release.bundleHash);
40
+ }
41
+ /**
42
+ * Returns true if the bundle hash matches the expected digest.
43
+ * The runner must verify the bytes it received match the hash consented to.
44
+ */
45
+ export function verifyBundleHash(actualHash, expectedHash) {
46
+ return actualHash === expectedHash;
47
+ }
48
+ const SHA256_HEX_PATTERN = /^[a-f0-9]{64}$/i;
49
+ /**
50
+ * Normalize the registry's SHA-256 spelling.
51
+ *
52
+ * Platform currently persists the bare lowercase hex digest. Accepting the
53
+ * explicit `sha256:<hex>` spelling keeps the wire self-describing without
54
+ * weakening verification to arbitrary labels such as `sha256-test`.
55
+ */
56
+ export function normalizeBundleSha256(value) {
57
+ const trimmed = value.trim();
58
+ const digest = trimmed.toLowerCase().startsWith('sha256:')
59
+ ? trimmed.slice('sha256:'.length)
60
+ : trimmed;
61
+ return SHA256_HEX_PATTERN.test(digest) ? digest.toLowerCase() : null;
62
+ }
63
+ /** Compute the digest of the exact bytes that will cross into the runner. */
64
+ export async function bundleSha256Hex(bytes) {
65
+ const digest = await crypto.subtle.digest('SHA-256', bytes);
66
+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');
67
+ }
68
+ /**
69
+ * Bind execution to registry truth. The fetcher's reported hash is metadata;
70
+ * only hashing the received bytes proves what will actually execute.
71
+ */
72
+ export async function verifyBundleBytes(bytes, expectedHash) {
73
+ const expected = normalizeBundleSha256(expectedHash);
74
+ if (!expected)
75
+ return false;
76
+ return (await bundleSha256Hex(bytes)) === expected;
77
+ }
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Versioned MessagePort protocol — the wire format between the trusted
3
+ * wrapper (host) and the isolated runner (frame).
4
+ *
5
+ * Every message carries a protocol version. The host rejects any message
6
+ * with an unsupported version. The handshake establishes the version before
7
+ * any code execution or capability requests.
8
+ *
9
+ * Disposal: the host sends `dispose`, the frame acks, both sides close
10
+ * the port. The host must persist revocation BEFORE closing ports.
11
+ */
12
+ import { type JsonObject, type JsonValue } from '@vibesdotdev/kernel/schemas/json';
13
+ export declare const PROTOCOL_VERSION: 1;
14
+ export declare const MAX_BUNDLE_BYTES: number;
15
+ export interface RunnerConnectionMessage {
16
+ type: 'vibes.applet.connect';
17
+ version: number;
18
+ launchToken: string;
19
+ }
20
+ export interface RunnerBootMessage {
21
+ type: 'vibes.applet.booted';
22
+ version: number;
23
+ launchToken: string;
24
+ }
25
+ /**
26
+ * Dispatch travels to the frame as a PORT message. The envelope shape is owned
27
+ * by `@vibesdotdev/applets` — imported, not restated, because this package may
28
+ * depend on the base package. The runner mirrors it by value and
29
+ * `apps/applet-runner/test/protocol-parity.test.ts` locks the two together.
30
+ */
31
+ export type { AppletDispatchRequest, AppletDispatchResponse } from '@vibesdotdev/applets';
32
+ export type HostMessage = {
33
+ type: 'mount';
34
+ version: number;
35
+ nonce: string;
36
+ capabilities: string[];
37
+ bundleHash: string;
38
+ bundleBytes: ArrayBuffer;
39
+ /** Stamped by the host; the frame reports it back to applet code. */
40
+ instanceId: string;
41
+ release: {
42
+ componentId: string;
43
+ version: string;
44
+ bundleHash: string;
45
+ };
46
+ /** Store ids the release declared. The frame refuses handles for others. */
47
+ declaredStorageIds: string[];
48
+ } | {
49
+ type: 'state';
50
+ scope: 'shared' | 'viewer';
51
+ revision: number;
52
+ state: JsonObject;
53
+ } | {
54
+ type: 'dispose';
55
+ };
56
+ export type RunnerMessage = {
57
+ type: 'ready';
58
+ version: number;
59
+ launchToken: string;
60
+ } | {
61
+ type: 'mounted';
62
+ nonce: string;
63
+ } | {
64
+ type: 'heartbeat';
65
+ } | {
66
+ type: 'capability.request';
67
+ capabilities: {
68
+ tag: string;
69
+ reason?: string;
70
+ }[];
71
+ } | {
72
+ type: 'state.mutate';
73
+ scope: 'shared' | 'viewer';
74
+ operationId: string;
75
+ expectedRevision: number;
76
+ eventType: string;
77
+ payload: JsonObject;
78
+ } | {
79
+ type: 'event';
80
+ eventType: string;
81
+ payload: JsonObject;
82
+ } | {
83
+ type: 'error';
84
+ nonce?: string;
85
+ code: string;
86
+ message: string;
87
+ } | {
88
+ type: 'disposed';
89
+ };
90
+ export interface HandshakeResult {
91
+ success: boolean;
92
+ /** The version negotiated, or null on failure. */
93
+ version: number | null;
94
+ /** Error message on failure. */
95
+ error: string | null;
96
+ }
97
+ /**
98
+ * Validate a runner handshake message. The host rejects any version it
99
+ * does not support.
100
+ */
101
+ export declare function validateHandshake(msg: unknown, launchToken?: string): HandshakeResult;
102
+ export declare function createRunnerConnectionMessage(launchToken: string): RunnerConnectionMessage;
103
+ export declare function isRunnerBootMessage(event: Pick<MessageEvent, 'data' | 'origin' | 'source'>, expectedSource: MessageEventSource, launchToken: string): event is Pick<MessageEvent, 'data' | 'origin' | 'source'> & {
104
+ data: RunnerBootMessage;
105
+ };
106
+ export interface CorrelatedRunnerUrl {
107
+ href: string;
108
+ origin: string;
109
+ }
110
+ /**
111
+ * Add one ephemeral launch capability to the runner URL. The fragment never
112
+ * reaches the runner server and is paired with the exact parent origin.
113
+ */
114
+ export declare function createCorrelatedRunnerUrl(runnerUrl: string, launchToken: string, parentOrigin: string): CorrelatedRunnerUrl;
115
+ /**
116
+ * Create a mount message — sent after handshake success and consent.
117
+ */
118
+ export declare function createMountMessage(nonce: string, capabilities: string[], bundleHash: string, bundleBytes: ArrayBuffer,
119
+ /**
120
+ * Identity and declared stores, stamped by the HOST.
121
+ *
122
+ * The frame reports `applet.instanceId` back to applet code and refuses a
123
+ * storage handle for anything not in `declaredStorageIds`. Neither can be
124
+ * derived inside the frame, and an applet that names its own instance names
125
+ * someone else's — so they cross here, from the side that knows.
126
+ */
127
+ identity?: {
128
+ instanceId: string;
129
+ release: {
130
+ componentId: string;
131
+ version: string;
132
+ bundleHash: string;
133
+ };
134
+ declaredStorageIds: string[];
135
+ }): HostMessage;
136
+ /**
137
+ * Create a dispose message — sent when the host is tearing down the runner.
138
+ */
139
+ export declare function createDisposeMessage(): HostMessage;
140
+ /**
141
+ * Recognize a dispatch result coming back from the frame.
142
+ *
143
+ * Only the correlation and the envelope are checked here. The RESULT is
144
+ * third-party output and is parsed by `parseAppletDispatchResponse` in
145
+ * `@vibesdotdev/applets` before it reaches a caller — recognizing a message is
146
+ * not the same as trusting its contents.
147
+ */
148
+ export type RunnerMessageWire = JsonValue | undefined;
149
+ export declare function isDispatchResult(msg: RunnerMessageWire, correlationId: string): msg is {
150
+ type: 'dispatch.result';
151
+ correlationId: string;
152
+ response: JsonValue;
153
+ };
154
+ /**
155
+ * Returns true if a runner message is a heartbeat.
156
+ */
157
+ export declare function isHeartbeat(msg: RunnerMessageWire): msg is Extract<RunnerMessage, {
158
+ type: 'heartbeat';
159
+ }>;
160
+ /**
161
+ * Returns true if a runner message is a capability request.
162
+ */
163
+ export declare function isCapabilityRequest(msg: RunnerMessageWire): msg is Extract<RunnerMessage, {
164
+ type: 'capability.request';
165
+ }>;
166
+ /**
167
+ * Returns true if a runner message is a state mutation.
168
+ */
169
+ export declare function isStateMutation(msg: RunnerMessageWire): msg is Extract<RunnerMessage, {
170
+ type: 'state.mutate';
171
+ }>;
172
+ /**
173
+ * Returns true if a runner message is a disposed ack.
174
+ */
175
+ export declare function isDisposedAck(msg: RunnerMessageWire): msg is Extract<RunnerMessage, {
176
+ type: 'disposed';
177
+ }>;
178
+ export declare function isMountedAck(msg: RunnerMessageWire, nonce: string): msg is Extract<RunnerMessage, {
179
+ type: 'mounted';
180
+ }>;
181
+ export declare function isRunnerError(msg: RunnerMessageWire): msg is Extract<RunnerMessage, {
182
+ type: 'error';
183
+ }>;
184
+ //# sourceMappingURL=message-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-protocol.d.ts","sourceRoot":"","sources":["../../../src/svelte/lib/message-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAGN,KAAK,UAAU,EACf,KAAK,SAAS,EACd,MAAM,kCAAkC,CAAC;AAE1C,eAAO,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAC3C,eAAO,MAAM,gBAAgB,QAAmB,CAAC;AAEjD,MAAM,WAAW,uBAAuB;IACvC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CA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AAiB,GAAG,GAAG,IAAI,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAEzG;AAOD,wBAAgB,YAAY,CAC3B,GAAG,EAAE,iBAAiB,EACtB,KAAK,EAAE,MAAM,GACX,GAAG,IAAI,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,CAMpD;AASD,wBAAgB,aAAa,CAAC,GAAG,EAAE,iBAAiB,GAAG,GAAG,IAAI,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAEtG"}
@@ -0,0 +1,251 @@
1
+ /**
2
+ * Versioned MessagePort protocol — the wire format between the trusted
3
+ * wrapper (host) and the isolated runner (frame).
4
+ *
5
+ * Every message carries a protocol version. The host rejects any message
6
+ * with an unsupported version. The handshake establishes the version before
7
+ * any code execution or capability requests.
8
+ *
9
+ * Disposal: the host sends `dispose`, the frame acks, both sides close
10
+ * the port. The host must persist revocation BEFORE closing ports.
11
+ */
12
+ import * as z from 'zod/v4';
13
+ import { JsonObjectSchema, JsonValueSchema } from '@vibesdotdev/kernel/schemas/json';
14
+ export const PROTOCOL_VERSION = 1;
15
+ export const MAX_BUNDLE_BYTES = 16 * 1024 * 1024;
16
+ const correlationIdSchema = z.string().min(32).max(128).regex(/^[a-zA-Z0-9_-]+$/);
17
+ function isCorrelationId(value) {
18
+ return correlationIdSchema.safeParse(value).success;
19
+ }
20
+ const handshakeCandidateSchema = z.object({
21
+ type: z.string().optional(),
22
+ version: z.number().optional(),
23
+ launchToken: z.string().optional()
24
+ }).passthrough();
25
+ /**
26
+ * Validate a runner handshake message. The host rejects any version it
27
+ * does not support.
28
+ */
29
+ export function validateHandshake(msg, launchToken) {
30
+ const parsed = handshakeCandidateSchema.safeParse(msg);
31
+ if (!parsed.success || parsed.data.type !== 'ready') {
32
+ const type = parsed.success && parsed.data.type ? parsed.data.type : 'unknown';
33
+ return { success: false, version: null, error: `Expected 'ready', got '${type}'` };
34
+ }
35
+ if (parsed.data.version !== PROTOCOL_VERSION) {
36
+ return {
37
+ success: false,
38
+ version: null,
39
+ error: `Unsupported protocol version ${parsed.data.version}, expected ${PROTOCOL_VERSION}`
40
+ };
41
+ }
42
+ const token = parsed.data.launchToken;
43
+ if (!token || !isCorrelationId(token)) {
44
+ return {
45
+ success: false,
46
+ version: null,
47
+ error: 'Runner handshake omitted a valid launch correlation'
48
+ };
49
+ }
50
+ if (launchToken !== undefined && token !== launchToken) {
51
+ return {
52
+ success: false,
53
+ version: null,
54
+ error: 'Runner launch correlation did not match'
55
+ };
56
+ }
57
+ return { success: true, version: parsed.data.version, error: null };
58
+ }
59
+ export function createRunnerConnectionMessage(launchToken) {
60
+ if (!isCorrelationId(launchToken)) {
61
+ throw new Error('Applet launch correlation must be a strong opaque identifier.');
62
+ }
63
+ return { type: 'vibes.applet.connect', version: PROTOCOL_VERSION, launchToken };
64
+ }
65
+ /**
66
+ * Authenticate the runner's data-less boot signal before transferring the one
67
+ * control port. An allow-scripts-only sandbox always reports origin "null", so
68
+ * the exact WindowProxy and fragment correlation carry the identity here.
69
+ */
70
+ const runnerBootCandidateSchema = z.object({
71
+ type: z.literal('vibes.applet.booted'),
72
+ version: z.literal(PROTOCOL_VERSION),
73
+ launchToken: z.string().min(1)
74
+ });
75
+ export function isRunnerBootMessage(event, expectedSource, launchToken) {
76
+ const parsed = runnerBootCandidateSchema.safeParse(event.data);
77
+ return (event.source === expectedSource &&
78
+ event.origin === 'null' &&
79
+ parsed.success &&
80
+ parsed.data.launchToken === launchToken);
81
+ }
82
+ /**
83
+ * Add one ephemeral launch capability to the runner URL. The fragment never
84
+ * reaches the runner server and is paired with the exact parent origin.
85
+ */
86
+ export function createCorrelatedRunnerUrl(runnerUrl, launchToken, parentOrigin) {
87
+ const url = new URL(runnerUrl);
88
+ if (!['https:', 'http:'].includes(url.protocol) || url.origin === 'null') {
89
+ throw new Error('Applet runner URL must use an HTTP(S) origin.');
90
+ }
91
+ let parent;
92
+ try {
93
+ parent = new URL(parentOrigin);
94
+ }
95
+ catch (cause) {
96
+ throw new Error('Applet host must have an HTTP(S) origin.', { cause });
97
+ }
98
+ if (!['https:', 'http:'].includes(parent.protocol) || parent.origin !== parentOrigin) {
99
+ throw new Error('Applet host must have an HTTP(S) origin.');
100
+ }
101
+ if (!isCorrelationId(launchToken)) {
102
+ throw new Error('Applet launch correlation must be a strong opaque identifier.');
103
+ }
104
+ if (url.origin === parent.origin) {
105
+ throw new Error('Applet runner must use a separate origin from its host.');
106
+ }
107
+ const fragment = new URLSearchParams({
108
+ launch: launchToken,
109
+ parent: parentOrigin
110
+ });
111
+ url.hash = fragment.toString();
112
+ return { href: url.href, origin: url.origin };
113
+ }
114
+ /**
115
+ * Create a mount message — sent after handshake success and consent.
116
+ */
117
+ export function createMountMessage(nonce, capabilities, bundleHash, bundleBytes,
118
+ /**
119
+ * Identity and declared stores, stamped by the HOST.
120
+ *
121
+ * The frame reports `applet.instanceId` back to applet code and refuses a
122
+ * storage handle for anything not in `declaredStorageIds`. Neither can be
123
+ * derived inside the frame, and an applet that names its own instance names
124
+ * someone else's — so they cross here, from the side that knows.
125
+ */
126
+ identity) {
127
+ if (!isCorrelationId(nonce)) {
128
+ throw new Error('Applet mount correlation must be a strong opaque identifier.');
129
+ }
130
+ if (!z.array(z.string()).safeParse(capabilities).success) {
131
+ throw new Error('Applet capabilities must be strings.');
132
+ }
133
+ if (!normalizeBundleSha256(bundleHash)) {
134
+ throw new Error('Applet bundle hash must be a SHA-256 digest.');
135
+ }
136
+ if (bundleBytes.byteLength === 0 || bundleBytes.byteLength > MAX_BUNDLE_BYTES) {
137
+ throw new Error(`Applet bundle must be between 1 and ${MAX_BUNDLE_BYTES} bytes.`);
138
+ }
139
+ return {
140
+ type: 'mount',
141
+ version: PROTOCOL_VERSION,
142
+ nonce,
143
+ capabilities,
144
+ bundleHash,
145
+ bundleBytes,
146
+ instanceId: identity?.instanceId ?? '',
147
+ // Rebuilt as PLAIN fields, never passed through.
148
+ //
149
+ // `release` and `declaredStorageIds` arrive as component props, which in
150
+ // Svelte 5 are reactive proxies — and `postMessage` cannot structured-clone
151
+ // a proxy. The e2e caught it as "could not be cloned" after the frame had
152
+ // already mounted, which is the worst place to learn it.
153
+ release: {
154
+ componentId: identity?.release.componentId ?? '',
155
+ version: identity?.release.version ?? '',
156
+ bundleHash: identity?.release.bundleHash ?? bundleHash
157
+ },
158
+ declaredStorageIds: [...(identity?.declaredStorageIds ?? [])]
159
+ };
160
+ }
161
+ /**
162
+ * Create a dispose message — sent when the host is tearing down the runner.
163
+ */
164
+ export function createDisposeMessage() {
165
+ return { type: 'dispose' };
166
+ }
167
+ const dispatchResultCandidateSchema = z.object({
168
+ type: z.literal('dispatch.result'),
169
+ correlationId: z.string(),
170
+ response: JsonValueSchema
171
+ });
172
+ export function isDispatchResult(msg, correlationId) {
173
+ const parsed = dispatchResultCandidateSchema.safeParse(msg);
174
+ if (!parsed.success) {
175
+ return false;
176
+ }
177
+ return (parsed.data.correlationId === correlationId &&
178
+ isCorrelationId(parsed.data.correlationId));
179
+ }
180
+ const heartbeatSchema = z.object({
181
+ type: z.literal('heartbeat')
182
+ });
183
+ /**
184
+ * Returns true if a runner message is a heartbeat.
185
+ */
186
+ export function isHeartbeat(msg) {
187
+ return heartbeatSchema.safeParse(msg).success;
188
+ }
189
+ const capabilityRequestSchema = z.object({
190
+ type: z.literal('capability.request'),
191
+ capabilities: z.array(z.object({
192
+ tag: z.string(),
193
+ reason: z.string().optional()
194
+ }))
195
+ });
196
+ /**
197
+ * Returns true if a runner message is a capability request.
198
+ */
199
+ export function isCapabilityRequest(msg) {
200
+ return capabilityRequestSchema.safeParse(msg).success;
201
+ }
202
+ const stateMutationSchema = z.object({
203
+ type: z.literal('state.mutate'),
204
+ scope: z.enum(['shared', 'viewer']),
205
+ operationId: z.string(),
206
+ expectedRevision: z.number().int().nonnegative(),
207
+ eventType: z.string(),
208
+ payload: JsonObjectSchema
209
+ });
210
+ /**
211
+ * Returns true if a runner message is a state mutation.
212
+ */
213
+ export function isStateMutation(msg) {
214
+ return stateMutationSchema.safeParse(msg).success;
215
+ }
216
+ const disposedAckSchema = z.object({
217
+ type: z.literal('disposed')
218
+ });
219
+ /**
220
+ * Returns true if a runner message is a disposed ack.
221
+ */
222
+ export function isDisposedAck(msg) {
223
+ return disposedAckSchema.safeParse(msg).success;
224
+ }
225
+ const mountedAckSchema = z.object({
226
+ type: z.literal('mounted'),
227
+ nonce: z.string()
228
+ });
229
+ export function isMountedAck(msg, nonce) {
230
+ const parsed = mountedAckSchema.safeParse(msg);
231
+ if (!parsed.success) {
232
+ return false;
233
+ }
234
+ return parsed.data.nonce === nonce;
235
+ }
236
+ const runnerErrorSchema = z.object({
237
+ type: z.literal('error'),
238
+ code: z.string(),
239
+ message: z.string(),
240
+ nonce: z.string().optional()
241
+ });
242
+ export function isRunnerError(msg) {
243
+ return runnerErrorSchema.safeParse(msg).success;
244
+ }
245
+ function normalizeBundleSha256(value) {
246
+ const trimmed = value.trim();
247
+ const digest = trimmed.toLowerCase().startsWith('sha256:')
248
+ ? trimmed.slice('sha256:'.length)
249
+ : trimmed;
250
+ return /^[a-f0-9]{64}$/i.test(digest) ? digest.toLowerCase() : null;
251
+ }