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

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,41 @@
1
+ import { CapabilityError } from '@vibesdotdev/kernel';
2
+ import { BaseRuntimeClient } from '@vibesdotdev/kernel/client';
3
+ import { requireConsumerSessionUser } from '@vibesdotdev/auth/server/consumer-session-user';
4
+ import { createServedAppletRpc } from "../cli/commands/served-applet-rpc.js";
5
+ import { resolveAppletWorkspaceRoot } from "../cli/project-files.js";
6
+ import { appletProjectIdSchema } from "../local-project.js";
7
+ export default class RuntimeLocalAppletHost extends BaseRuntimeClient {
8
+ peers = new Map();
9
+ async handleRpc(projectId, request) {
10
+ await this.ensureLoaded();
11
+ const id = appletProjectIdSchema.parse(projectId);
12
+ const principal = this.runtime.requestPrincipal();
13
+ if (principal.kind !== 'user')
14
+ throw new CapabilityError('Sign in to use workspace applets.', 'AUTH_REQUIRED', {
15
+ reason: 'applet-host-sign-in-required', retryable: false
16
+ });
17
+ await requireConsumerSessionUser(this.runtime);
18
+ const workspaceRoot = await resolveAppletWorkspaceRoot(this.runtime);
19
+ let peer = this.peers.get(principal.userId);
20
+ if (!peer) {
21
+ peer = createServedAppletRpc({
22
+ runtime: this.runtime,
23
+ workspaceRoot,
24
+ routePrefix: project => `/${encodeURIComponent(project)}`,
25
+ runInvocation: (work, connection) => this.runtime.runInvocation(work, {
26
+ principal: this.runtime.requestPrincipal(), signal: connection.signal
27
+ })
28
+ });
29
+ this.peers.set(principal.userId, peer);
30
+ }
31
+ return peer.handle(id, request);
32
+ }
33
+ async onDispose() {
34
+ const outcomes = await Promise.allSettled([...this.peers.values()].map(peer => peer.close()));
35
+ this.peers.clear();
36
+ const failures = outcomes.flatMap(outcome => outcome.status === 'rejected' ? [outcome.reason] : []);
37
+ if (failures.length)
38
+ throw new AggregateError(failures, 'Local applet connections failed to close.');
39
+ }
40
+ }
41
+ //# sourceMappingURL=local-host.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-host.impl.js","sourceRoot":"","sources":["../../src/host/local-host.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAqB,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAG5D,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,iBAA+B;IACjE,KAAK,GAAG,IAAI,GAAG,EAAoD,CAAC;IAErF,KAAK,CAAC,SAAS,CAAC,SAAiB,EAAE,OAAgB;QAClD,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC1B,MAAM,EAAE,GAAG,qBAAqB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAClD,IAAI,SAAS,CAAC,IAAI,KAAK,MAAM;YAAE,MAAM,IAAI,eAAe,CAAC,mCAAmC,EAAE,eAAe,EAAE;gBAC9G,MAAM,EAAE,8BAA8B,EAAE,SAAS,EAAE,KAAK;aACxD,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AAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACpG,IAAI,QAAQ,CAAC,MAAM;YAAE,MAAM,IAAI,cAAc,CAAC,QAAQ,EAAE,2CAA2C,CAAC,CAAC;IACtG,CAAC;CACD"}
@@ -0,0 +1,3 @@
1
+ declare const localHostPlugin: import("@vibesdotdev/kernel").RuntimePlugin;
2
+ export default localHostPlugin;
3
+ //# sourceMappingURL=local-host.plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-host.plugin.d.ts","sourceRoot":"","sources":["../../src/host/local-host.plugin.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,eAAe,6CAUnB,CAAC;AAEH,eAAe,eAAe,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { createRuntimeAsset, createRuntimePlugin, loader } from '@vibesdotdev/kernel';
2
+ import localStore from "../cli/applet-local-store.storage.descriptor.js";
3
+ import localServeAuthzPolicy from "../cli/local-serve.authz-policy.descriptor.js";
4
+ import { LOCAL_APPLET_HOST_ID } from "./local-host.contract.js";
5
+ const localHostPlugin = createRuntimePlugin({
6
+ id: 'applets.local-host',
7
+ name: 'Local applet host',
8
+ dependencies: ['auth'],
9
+ descriptors: [localStore, localServeAuthzPolicy, createRuntimeAsset({
10
+ id: LOCAL_APPLET_HOST_ID, kind: 'runtime/client', name: 'Local applet host',
11
+ description: 'Authenticated local applet RPC, using the existing AppletRootSurface.'
12
+ })],
13
+ loaders: [loader(LOCAL_APPLET_HOST_ID, { kind: 'runtime/client', scope: 'consumer' }, () => import("./local-host.impl.js"))]
14
+ });
15
+ export default localHostPlugin;
16
+ //# sourceMappingURL=local-host.plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-host.plugin.js","sourceRoot":"","sources":["../../src/host/local-host.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,UAAU,MAAM,iDAAiD,CAAC;AACzE,OAAO,qBAAqB,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,MAAM,eAAe,GAAG,mBAAmB,CAAC;IAC3C,EAAE,EAAE,oBAAoB;IACxB,IAAI,EAAE,mBAAmB;IACzB,YAAY,EAAE,CAAC,MAAM,CAAC;IACtB,WAAW,EAAE,CAAC,UAAU,EAAE,qBAAqB,EAAE,kBAAkB,CAAC;YACnE,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,mBAAmB;YAC3E,WAAW,EAAE,uEAAuE;SACpF,CAAC,CAAC;IACH,OAAO,EAAE,CAAC,MAAM,CAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,EACnF,GAAG,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC;CACvC,CAAC,CAAC;AAEH,eAAe,eAAe,CAAC"}
@@ -0,0 +1,28 @@
1
+ export * from './schemas/index.ts';
2
+ export { appletsClientDescriptor, getVibesAppletsClient, APPLETS_REPOSITORY_CONTEXT_ID, appletsRepositoryContextDescriptor } from './client/contract.ts';
3
+ export type { AppletsClient, AppletsOwnerScope, AppletsRepositoryOwner, AppletsRepository } from './client/contract.ts';
4
+ export * from './storage/index.ts';
5
+ export * from './tools/index.ts';
6
+ export * from './authorization.ts';
7
+ export * from './build-definition.ts';
8
+ export * from './applet-gate.ts';
9
+ export * from './applet-root-surface.ts';
10
+ export * from './templates/index.ts';
11
+ export * from './composition-plan.ts';
12
+ export * from './local-project.ts';
13
+ export * from './companion-path.ts';
14
+ export * from './manifest-hash.ts';
15
+ export * from './composition.ts';
16
+ export * from './content-path.ts';
17
+ export * from './contribution-registry.ts';
18
+ export * from './upgrade.ts';
19
+ export * from './component-ref.ts';
20
+ export * from './selection.ts';
21
+ export * from './browser-runtime.ts';
22
+ export * from './presentation.ts';
23
+ export * from './host/local-host.contract.ts';
24
+ export { findReleaseReferences, isReleaseRetained, type ReleaseReference } from './retention.ts';
25
+ export { appletsPlugin } from './applets.plugin.ts';
26
+ export * from './capabilities/capability.kind.ts';
27
+ export * from './capabilities/runtime-dispatch.ts';
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,OAAO,EACN,uBAAuB,EACvB,qBAAqB,EACrB,6BAA6B,EAC7B,kCAAkC,EAClC,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACX,aAAa,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,iBAAiB,EAC3E,MAAM,sBAAsB,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ export * from "./schemas/index.js";
2
+ export { appletsClientDescriptor, getVibesAppletsClient, APPLETS_REPOSITORY_CONTEXT_ID, appletsRepositoryContextDescriptor } from "./client/contract.js";
3
+ export * from "./storage/index.js";
4
+ export * from "./tools/index.js";
5
+ export * from "./authorization.js";
6
+ export * from "./build-definition.js";
7
+ export * from "./applet-gate.js";
8
+ export * from "./applet-root-surface.js";
9
+ export * from "./templates/index.js";
10
+ export * from "./composition-plan.js";
11
+ export * from "./local-project.js";
12
+ export * from "./companion-path.js";
13
+ export * from "./manifest-hash.js";
14
+ export * from "./composition.js";
15
+ export * from "./content-path.js";
16
+ export * from "./contribution-registry.js";
17
+ export * from "./upgrade.js";
18
+ export * from "./component-ref.js";
19
+ export * from "./selection.js";
20
+ export * from "./browser-runtime.js";
21
+ export * from "./presentation.js";
22
+ export * from "./host/local-host.contract.js";
23
+ export { findReleaseReferences, isReleaseRetained } from "./retention.js";
24
+ export { appletsPlugin } from "./applets.plugin.js";
25
+ export * from "./capabilities/capability.kind.js";
26
+ export * from "./capabilities/runtime-dispatch.js";
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,OAAO,EACN,uBAAuB,EACvB,qBAAqB,EACrB,6BAA6B,EAC7B,kCAAkC,EAClC,MAAM,sBAAsB,CAAC;AAI9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAyB,MAAM,gBAAgB,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Local authoring: an applet on disk, in `.vibes/applets/{id}/`.
3
+ *
4
+ * Drew chose this shape — a descriptor plus a component that may import others —
5
+ * over a single-file format. The consequence for the compiler was that it had to
6
+ * accept a file SET; the consequence here is that the on-disk layout must produce
7
+ * exactly what `buildAppletDefinitionManifest` already consumes, rather than a
8
+ * second parallel notion of "what an applet is".
9
+ *
10
+ * FILESYSTEM ACCESS IS INJECTED. This module reads no files itself, which keeps
11
+ * it usable from a CLI, from a dev server, and from a test with no fixtures on
12
+ * disk. It also means the traversal rules below are testable as rules rather
13
+ * than as directory listings.
14
+ */
15
+ import * as z from 'zod/v4';
16
+ import type { AppletOwnStorageDescriptor, AppletPackageFile, AppletServerAction } from './schemas/definition.ts';
17
+ import { type AppletDefinitionBuildResult } from './build-definition.ts';
18
+ /**
19
+ * The directory an applet lives in, relative to the workspace root.
20
+ *
21
+ * Built from `PROJECT_STATE_DIRNAME` rather than spelling `.vibes` privately.
22
+ * `@vibesdotdev/paths` owns filesystem root policy and documents this exact case
23
+ * — "feature packages that need the bare dirname (to build a relative pattern
24
+ * rather than an absolute path) consume this instead" — and `check:path-roots`
25
+ * caught the private spelling within a minute of it being written.
26
+ */
27
+ export declare const APPLET_PROJECT_ROOT = ".vibes/applets";
28
+ /** The descriptor file every applet project must have. */
29
+ export declare const APPLET_DESCRIPTOR_FILENAME = "applet.descriptor.ts";
30
+ /**
31
+ * The stores a local project declares: the manifest's own `storage` field, as
32
+ * JSON.
33
+ *
34
+ * Data rather than a field on the TypeScript descriptor, because reading a
35
+ * descriptor means executing it, and nothing in this pipeline executes author
36
+ * code on the host. Parsed by the manifest's own schema, so a declaration that
37
+ * would not publish does not serve either. Like the descriptor it is authoring
38
+ * metadata, not a published file: what it says becomes `manifest.storage`.
39
+ */
40
+ export declare const APPLET_STORAGE_FILENAME = "applet.storage.json";
41
+ /**
42
+ * The A2b approved server actions a local project declares: the manifest's own
43
+ * `serverActions` field, as JSON. Authoring metadata like the storage file —
44
+ * read as data, never inventoried, never executed.
45
+ */
46
+ export declare const APPLET_ACTIONS_FILENAME = "applet.actions.json";
47
+ /**
48
+ * What one project's files look like once read.
49
+ *
50
+ * `sources` feeds the compiler; `files` feeds the manifest. They are produced
51
+ * together from one traversal so the two can never describe different sets —
52
+ * a manifest that inventories a file the bundle does not contain is exactly the
53
+ * digest-pinning failure this whole contract exists to prevent.
54
+ */
55
+ export interface AppletLocalProject {
56
+ readonly id: string;
57
+ readonly entry: string;
58
+ readonly sources: Record<string, string>;
59
+ readonly files: AppletPackageFile[];
60
+ /** The stores `applet.storage.json` declares; empty when the project has none. */
61
+ readonly storage: AppletOwnStorageDescriptor[];
62
+ /** The actions `applet.actions.json` declares; empty when the project has none. */
63
+ readonly actions: AppletServerAction[];
64
+ }
65
+ export interface AppletLocalProjectError {
66
+ readonly path: string;
67
+ readonly message: string;
68
+ /** The underlying failure, when one produced this error (malformed JSON, for one). */
69
+ readonly cause?: Error;
70
+ }
71
+ export declare function isBinaryMediaType(mediaType: string): boolean;
72
+ export declare function mediaTypeFor(path: string): string | undefined;
73
+ export declare const appletProjectIdSchema: z.ZodString;
74
+ /**
75
+ * Turn one project directory's contents into a compilable, inventoriable applet.
76
+ *
77
+ * `entries` is what the caller found on disk: path relative to the project root,
78
+ * and the bytes. Everything else is decided here so a CLI and a dev server cannot
79
+ * disagree about which files count.
80
+ */
81
+ export declare function readAppletLocalProject(input: {
82
+ id: string;
83
+ entry?: string;
84
+ entries: {
85
+ path: string;
86
+ contents: string;
87
+ encoding?: 'utf8' | 'base64';
88
+ }[];
89
+ digest: (bytes: Uint8Array) => Promise<string>;
90
+ }): Promise<{
91
+ ok: true;
92
+ project: AppletLocalProject;
93
+ } | {
94
+ ok: false;
95
+ errors: AppletLocalProjectError[];
96
+ }>;
97
+ /**
98
+ * The definition manifest a local project publishes as: its inventory and its
99
+ * declared stores, seeded the way `vibes applet build` always seeded it.
100
+ *
101
+ * One producer, so `build` (which prints the manifest hash an author pins) and
102
+ * `serve` (which binds the stores an applet may reach) cannot describe two
103
+ * different applets.
104
+ */
105
+ export declare function buildAppletLocalDefinitionManifest(project: AppletLocalProject): AppletDefinitionBuildResult;
106
+ //# sourceMappingURL=local-project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-project.d.ts","sourceRoot":"","sources":["../src/local-project.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAI5B,OAAO,KAAK,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACjH,OAAO,EAAiC,KAAK,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAExG;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,mBAAqC,CAAC;AAEtE,0DAA0D;AAC1D,eAAO,MAAM,0BAA0B,yBAAyB,CAAC;AAEjE;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AAO7D;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE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O,EAAE,kBAAkB,GAAG,2BAA2B,CAe3G"}
@@ -0,0 +1,277 @@
1
+ /**
2
+ * Local authoring: an applet on disk, in `.vibes/applets/{id}/`.
3
+ *
4
+ * Drew chose this shape — a descriptor plus a component that may import others —
5
+ * over a single-file format. The consequence for the compiler was that it had to
6
+ * accept a file SET; the consequence here is that the on-disk layout must produce
7
+ * exactly what `buildAppletDefinitionManifest` already consumes, rather than a
8
+ * second parallel notion of "what an applet is".
9
+ *
10
+ * FILESYSTEM ACCESS IS INJECTED. This module reads no files itself, which keeps
11
+ * it usable from a CLI, from a dev server, and from a test with no fixtures on
12
+ * disk. It also means the traversal rules below are testable as rules rather
13
+ * than as directory listings.
14
+ */
15
+ import * as z from 'zod/v4';
16
+ import { PROJECT_STATE_DIRNAME } from '@vibesdotdev/paths';
17
+ import { appletDefinitionManifestSchema, appletRelativePathSchema } from "./schemas/definition.js";
18
+ import { buildAppletDefinitionManifest } from "./build-definition.js";
19
+ /**
20
+ * The directory an applet lives in, relative to the workspace root.
21
+ *
22
+ * Built from `PROJECT_STATE_DIRNAME` rather than spelling `.vibes` privately.
23
+ * `@vibesdotdev/paths` owns filesystem root policy and documents this exact case
24
+ * — "feature packages that need the bare dirname (to build a relative pattern
25
+ * rather than an absolute path) consume this instead" — and `check:path-roots`
26
+ * caught the private spelling within a minute of it being written.
27
+ */
28
+ export const APPLET_PROJECT_ROOT = `${PROJECT_STATE_DIRNAME}/applets`;
29
+ /** The descriptor file every applet project must have. */
30
+ export const APPLET_DESCRIPTOR_FILENAME = 'applet.descriptor.ts';
31
+ /**
32
+ * The stores a local project declares: the manifest's own `storage` field, as
33
+ * JSON.
34
+ *
35
+ * Data rather than a field on the TypeScript descriptor, because reading a
36
+ * descriptor means executing it, and nothing in this pipeline executes author
37
+ * code on the host. Parsed by the manifest's own schema, so a declaration that
38
+ * would not publish does not serve either. Like the descriptor it is authoring
39
+ * metadata, not a published file: what it says becomes `manifest.storage`.
40
+ */
41
+ export const APPLET_STORAGE_FILENAME = 'applet.storage.json';
42
+ /**
43
+ * The A2b approved server actions a local project declares: the manifest's own
44
+ * `serverActions` field, as JSON. Authoring metadata like the storage file —
45
+ * read as data, never inventoried, never executed.
46
+ */
47
+ export const APPLET_ACTIONS_FILENAME = 'applet.actions.json';
48
+ /** The manifest's `storage` field, bounds included. One owner schema, not a copy. */
49
+ const appletStorageDeclarationSchema = appletDefinitionManifestSchema.shape.storage;
50
+ /** The manifest's `serverActions` field, bounds included. One owner schema, not a copy. */
51
+ const appletActionsDeclarationSchema = appletDefinitionManifestSchema.shape.serverActions;
52
+ /** Media types by extension. Deliberately small: an applet is source, not a CDN. */
53
+ const MEDIA_TYPES = {
54
+ '.svelte': 'text/x-svelte',
55
+ '.ts': 'text/typescript',
56
+ '.mjs': 'text/javascript',
57
+ '.js': 'text/javascript',
58
+ '.json': 'application/json',
59
+ '.css': 'text/css',
60
+ '.html': 'text/html',
61
+ '.md': 'text/markdown',
62
+ '.txt': 'text/plain',
63
+ '.svg': 'image/svg+xml',
64
+ '.png': 'image/png',
65
+ '.jpg': 'image/jpeg',
66
+ '.jpeg': 'image/jpeg',
67
+ '.gif': 'image/gif',
68
+ '.webp': 'image/webp',
69
+ '.ico': 'image/x-icon'
70
+ };
71
+ /**
72
+ * Media the bundle carries as BYTES: never a `source`, never compiled — served
73
+ * with its media type. The applet contract admits them as companions (A2b,
74
+ * Drew: "assets" alongside ts/css/js/md), so images travel digest-pinned like
75
+ * every other file.
76
+ */
77
+ const BINARY_MEDIA_TYPES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp', 'image/x-icon']);
78
+ export function isBinaryMediaType(mediaType) {
79
+ return BINARY_MEDIA_TYPES.has(mediaType);
80
+ }
81
+ /** Files that are never part of an applet, whatever an author leaves lying around. */
82
+ const IGNORED = new Set(['node_modules', '.git', 'dist', '.svelte-kit', '.DS_Store']);
83
+ export function mediaTypeFor(path) {
84
+ const dot = path.lastIndexOf('.');
85
+ if (dot === -1)
86
+ return undefined;
87
+ const ext = path.slice(dot).toLowerCase();
88
+ // SAFETY: ext is verified to be an owned property of MEDIA_TYPES before lookup
89
+ return Object.hasOwn(MEDIA_TYPES, ext) ? MEDIA_TYPES[ext] : undefined;
90
+ }
91
+ /** Base64 to bytes without Buffer: the reader hands binary companions back encoded. */
92
+ function base64ToBytes(text) {
93
+ const binary = atob(text);
94
+ const bytes = new Uint8Array(binary.length);
95
+ for (let index = 0; index < binary.length; index += 1)
96
+ bytes[index] = binary.charCodeAt(index);
97
+ return bytes;
98
+ }
99
+ export const appletProjectIdSchema = z
100
+ .string()
101
+ .min(1)
102
+ .max(64)
103
+ .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'Applet project ids must be kebab-case');
104
+ /**
105
+ * Turn one project directory's contents into a compilable, inventoriable applet.
106
+ *
107
+ * `entries` is what the caller found on disk: path relative to the project root,
108
+ * and the bytes. Everything else is decided here so a CLI and a dev server cannot
109
+ * disagree about which files count.
110
+ */
111
+ export async function readAppletLocalProject(input) {
112
+ const errors = [];
113
+ const id = appletProjectIdSchema.safeParse(input.id);
114
+ if (!id.success) {
115
+ errors.push({ path: input.id, message: id.error.issues[0]?.message ?? 'Invalid applet id' });
116
+ }
117
+ const sources = {};
118
+ const files = [];
119
+ let storage = [];
120
+ let actions = [];
121
+ for (const entry of input.entries) {
122
+ const segments = entry.path.split('/');
123
+ if (segments.some((segment) => IGNORED.has(segment)))
124
+ continue;
125
+ // The DESCRIPTOR is authoring metadata, not a published file. Inventorying
126
+ // it would publish the author's local configuration as part of the applet.
127
+ if (entry.path === APPLET_DESCRIPTOR_FILENAME)
128
+ continue;
129
+ // So is the storage declaration: it becomes `manifest.storage`, not a file.
130
+ if (entry.path === APPLET_STORAGE_FILENAME) {
131
+ const declared = readStorageDeclaration(entry.contents);
132
+ if (declared.ok)
133
+ storage = declared.storage;
134
+ else
135
+ errors.push(...declared.errors);
136
+ continue;
137
+ }
138
+ // The actions file is authoring metadata too: it becomes
139
+ // `manifest.serverActions`, not a published file.
140
+ if (entry.path === APPLET_ACTIONS_FILENAME) {
141
+ const declared = readActionsDeclaration(entry.contents);
142
+ if (declared.ok)
143
+ actions = declared.actions;
144
+ else
145
+ errors.push(...declared.errors);
146
+ continue;
147
+ }
148
+ const path = appletRelativePathSchema.safeParse(entry.path);
149
+ if (!path.success) {
150
+ // Refused rather than sanitised: a path that escapes the project is a
151
+ // question about intent, and guessing at it is how a build starts
152
+ // reading files nobody meant to publish.
153
+ errors.push({
154
+ path: entry.path,
155
+ message: path.error.issues[0]?.message ?? 'Invalid applet file path'
156
+ });
157
+ continue;
158
+ }
159
+ const mediaType = mediaTypeFor(entry.path);
160
+ if (!mediaType) {
161
+ errors.push({
162
+ path: entry.path,
163
+ message: `Unsupported file type. An applet may contain: ${Object.keys(MEDIA_TYPES).join(', ')}`
164
+ });
165
+ continue;
166
+ }
167
+ // BYTES, not characters. A file of emoji is longer than its length, and a
168
+ // PNG has no text length at all. Binary companions arrive base64 from the
169
+ // reader and stay out of `sources`: nothing compiles an image.
170
+ const bytes = entry.encoding === 'base64' ? base64ToBytes(entry.contents) : new TextEncoder().encode(entry.contents);
171
+ if (!isBinaryMediaType(mediaType))
172
+ sources[entry.path] = entry.contents;
173
+ files.push({
174
+ path: entry.path,
175
+ mediaType,
176
+ digest: await input.digest(bytes),
177
+ size: bytes.length
178
+ });
179
+ }
180
+ const entry = input.entry ?? 'Applet.svelte';
181
+ if (!(entry in sources)) {
182
+ errors.push({ path: entry, message: `Entry "${entry}" is not present in the project` });
183
+ }
184
+ if (errors.length > 0)
185
+ return { ok: false, errors };
186
+ return {
187
+ ok: true,
188
+ project: {
189
+ id: input.id,
190
+ entry,
191
+ sources,
192
+ // CODEPOINT order, not `localeCompare`. Locale ordering is by definition
193
+ // machine-dependent — it sorts `a.ts` before `Applet.svelte` under most
194
+ // locales and the other way under a byte comparison — so using it to
195
+ // make a manifest "stable across machines" achieves the opposite.
196
+ files: files.sort((left, right) => (left.path < right.path ? -1 : left.path > right.path ? 1 : 0)),
197
+ storage,
198
+ actions
199
+ }
200
+ };
201
+ }
202
+ /** Every problem with an actions declaration, in the shape every other project error has. */
203
+ function readActionsDeclaration(contents) {
204
+ let declared;
205
+ try {
206
+ declared = JSON.parse(contents);
207
+ }
208
+ catch (cause) {
209
+ if (!(cause instanceof SyntaxError))
210
+ throw cause;
211
+ return {
212
+ ok: false,
213
+ errors: [{ path: APPLET_ACTIONS_FILENAME, message: `Not valid JSON: ${cause.message}`, cause }]
214
+ };
215
+ }
216
+ const parsed = appletActionsDeclarationSchema.safeParse(declared);
217
+ if (parsed.success)
218
+ return { ok: true, actions: parsed.data ?? [] };
219
+ return {
220
+ ok: false,
221
+ errors: parsed.error.issues.map((issue) => ({
222
+ path: [APPLET_ACTIONS_FILENAME, ...issue.path].join('.'),
223
+ message: issue.message
224
+ }))
225
+ };
226
+ }
227
+ /** Every problem with a storage declaration, in the shape every other project error has. */
228
+ function readStorageDeclaration(contents) {
229
+ let declared;
230
+ try {
231
+ declared = JSON.parse(contents);
232
+ }
233
+ catch (cause) {
234
+ // Malformed JSON is an authoring error to report with the rest, like an
235
+ // unsupported file type. Anything else is not this file's problem.
236
+ if (!(cause instanceof SyntaxError))
237
+ throw cause;
238
+ return {
239
+ ok: false,
240
+ errors: [{ path: APPLET_STORAGE_FILENAME, message: `Not valid JSON: ${cause.message}`, cause }]
241
+ };
242
+ }
243
+ const parsed = appletStorageDeclarationSchema.safeParse(declared);
244
+ if (parsed.success)
245
+ return { ok: true, storage: parsed.data };
246
+ return {
247
+ ok: false,
248
+ errors: parsed.error.issues.map((issue) => ({
249
+ path: [APPLET_STORAGE_FILENAME, ...issue.path].join('.'),
250
+ message: issue.message
251
+ }))
252
+ };
253
+ }
254
+ /**
255
+ * The definition manifest a local project publishes as: its inventory and its
256
+ * declared stores, seeded the way `vibes applet build` always seeded it.
257
+ *
258
+ * One producer, so `build` (which prints the manifest hash an author pins) and
259
+ * `serve` (which binds the stores an applet may reach) cannot describe two
260
+ * different applets.
261
+ */
262
+ export function buildAppletLocalDefinitionManifest(project) {
263
+ // A local declaration a v2 host would publish but not enforce moves the
264
+ // project to v3: server actions and write conditions exist only there.
265
+ const schemaVersion = project.actions.length > 0 || project.storage.some((store) => store.writeConditions !== undefined) ? 3 : 2;
266
+ return buildAppletDefinitionManifest({
267
+ seed: {
268
+ schemaVersion,
269
+ entrypoint: { kind: 'svelte', path: project.entry },
270
+ storage: project.storage,
271
+ capabilities: [],
272
+ serverActions: project.actions
273
+ },
274
+ files: project.files
275
+ });
276
+ }
277
+ //# sourceMappingURL=local-project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-project.js","sourceRoot":"","sources":["../src/local-project.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,8BAA8B,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnG,OAAO,EAAE,6BAA6B,EAAoC,MAAM,uBAAuB,CAAC;AAExG;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,qBAAqB,UAAU,CAAC;AAEtE,0DAA0D;AAC1D,MAAM,CAAC,MAAM,0BAA0B,GAAG,sBAAsB,CAAC;AAEjE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAE7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAE7D,qFAAqF;AACrF,MAAM,8BAA8B,GAAG,8BAA8B,CAAC,KAAK,CAAC,OAAO,CAAC;AACpF,2FAA2F;AAC3F,MAAM,8BAA8B,GAAG,8BAA8B,CAAC,KAAK,CAAC,aAAa,CAAC;AA4B1F,oFAAoF;AACpF,MAAM,WAAW,GAAG;IACnB,SAAS,EAAE,eAAe;IAC1B,KAAK,EAAE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ACvE,MAAM,aAAa,GAClB,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5G,OAAO,6BAA6B,CAAC;QACpC,IAAI,EAAE;YACL,aAAa;YACb,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,EAAE;YACnD,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,YAAY,EAAE,EAAE;YAChB,aAAa,EAAE,OAAO,CAAC,OAAO;SAC9B;QACD,KAAK,EAAE,OAAO,CAAC,KAAK;KACpB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { AppletDefinitionManifest } from './schemas/definition.ts';
2
+ /** `sha256:<hex>` over the canonical form. */
3
+ export declare function computeAppletManifestHash(manifest: AppletDefinitionManifest): Promise<string>;
4
+ /**
5
+ * Does this manifest match what a release ref pinned?
6
+ *
7
+ * `false` when the ref pins nothing — deliberately. An unpinned manifest is
8
+ * unauthenticated, and treating "nothing to check" as "checks out" is how a
9
+ * commitment becomes decoration.
10
+ */
11
+ export declare function appletManifestMatchesPin(manifest: AppletDefinitionManifest, pinnedManifestHash: string | null | undefined): Promise<boolean>;
12
+ //# sourceMappingURL=manifest-hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-hash.d.ts","sourceRoot":"","sources":["../src/manifest-hash.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AA6DxE,8CAA8C;AAC9C,wBAAsB,yBAAyB,CAC9C,QAAQ,EAAE,wBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC7C,QAAQ,EAAE,wBAAwB,EAClC,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC3C,OAAO,CAAC,OAAO,CAAC,CAGlB"}
@@ -0,0 +1,76 @@
1
+ function isNumber(val) {
2
+ return typeof val === 'number';
3
+ }
4
+ function isObject(val) {
5
+ return typeof val === 'object' && val !== null;
6
+ }
7
+ function canonical(value) {
8
+ // `undefined` gets its own token rather than falling through to `null`.
9
+ //
10
+ // `JSON.stringify(undefined)` is `undefined`, and a `?? 'null'` fallback made
11
+ // `[undefined]` and `[null]` hash identically — two different documents with
12
+ // one commitment. Unreachable from a manifest read out of storage, because
13
+ // JSON has no `undefined`, and this function is exported and callable on
14
+ // in-memory manifests where it is very reachable.
15
+ //
16
+ // In OBJECTS undefined is filtered out below, because an absent key and a key
17
+ // set to undefined are the same document. In ARRAYS they are not: a hole is a
18
+ // position.
19
+ if (value === undefined)
20
+ return '\u0000undefined';
21
+ if (value === null)
22
+ return 'null';
23
+ // TOTAL over the primitives, not just the ones JSON survives.
24
+ //
25
+ // Fixing `undefined` alone patched an instance of the bug rather than the
26
+ // class: `JSON.stringify` returns the STRING "null" for NaN and both
27
+ // Infinities, and `undefined` for functions and symbols — so each of those
28
+ // collided with a real `null`. And a Date, Map, or Set is `typeof 'object'`
29
+ // with no own enumerable keys, so every one of them encoded as `{}`.
30
+ //
31
+ // None reach here from a manifest read out of storage, which is JSON. All of
32
+ // them reach here through the exported function, which is the same
33
+ // reachability argument that justified fixing `undefined`.
34
+ if (isNumber(value)) {
35
+ return Number.isFinite(value) ? JSON.stringify(Object.is(value, -0) ? '-0' : value) : `\u0000num:${String(value)}`;
36
+ }
37
+ if (!isObject(value)) {
38
+ const encoded = JSON.stringify(value);
39
+ return encoded ?? `\u0000${String(value)}`;
40
+ }
41
+ if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) {
42
+ // A Date/Map/Set is not a manifest node. Refusing to encode it beats
43
+ // encoding every one of them as the same empty object.
44
+ throw new TypeError(`Applet manifests contain only JSON values; received ${Object.prototype.toString.call(value)}`);
45
+ }
46
+ if (Array.isArray(value))
47
+ return `[${value.map(canonical).join(',')}]`;
48
+ const entries = Object.entries(value)
49
+ // `undefined` is absent, not a value: a manifest that omits `manifestHash`
50
+ // and one that sets it undefined are the same document.
51
+ .filter(([, item]) => item !== undefined)
52
+ .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0));
53
+ return `{${entries.map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`).join(',')}}`;
54
+ }
55
+ /** `sha256:<hex>` over the canonical form. */
56
+ export async function computeAppletManifestHash(manifest) {
57
+ const bytes = new TextEncoder().encode(canonical(manifest));
58
+ const digest = await crypto.subtle.digest('SHA-256', bytes);
59
+ const hex = Array.from(new Uint8Array(digest))
60
+ .map((byte) => byte.toString(16).padStart(2, '0'))
61
+ .join('');
62
+ return `sha256:${hex}`;
63
+ }
64
+ /**
65
+ * Does this manifest match what a release ref pinned?
66
+ *
67
+ * `false` when the ref pins nothing — deliberately. An unpinned manifest is
68
+ * unauthenticated, and treating "nothing to check" as "checks out" is how a
69
+ * commitment becomes decoration.
70
+ */
71
+ export async function appletManifestMatchesPin(manifest, pinnedManifestHash) {
72
+ if (!pinnedManifestHash)
73
+ return false;
74
+ return (await computeAppletManifestHash(manifest)) === pinnedManifestHash;
75
+ }
76
+ //# sourceMappingURL=manifest-hash.js.map