@mostra/protocol 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (439) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +38 -2
  3. package/dist/actions.d.ts +273 -0
  4. package/dist/actions.d.ts.map +1 -0
  5. package/dist/actions.js +154 -0
  6. package/dist/actions.js.map +1 -0
  7. package/dist/artifact.d.ts +113 -0
  8. package/dist/artifact.d.ts.map +1 -0
  9. package/dist/artifact.js +79 -0
  10. package/dist/artifact.js.map +1 -0
  11. package/dist/bridge.d.ts +295 -0
  12. package/dist/bridge.d.ts.map +1 -0
  13. package/dist/bridge.js +343 -0
  14. package/dist/bridge.js.map +1 -0
  15. package/dist/browser.d.ts +195 -0
  16. package/dist/browser.d.ts.map +1 -0
  17. package/dist/browser.js +156 -0
  18. package/dist/browser.js.map +1 -0
  19. package/dist/bundle.d.ts +155 -0
  20. package/dist/bundle.d.ts.map +1 -0
  21. package/dist/bundle.js +130 -0
  22. package/dist/bundle.js.map +1 -0
  23. package/dist/canonical.d.ts +23 -0
  24. package/dist/canonical.d.ts.map +1 -0
  25. package/dist/canonical.js +45 -0
  26. package/dist/canonical.js.map +1 -0
  27. package/dist/capability.d.ts +38 -0
  28. package/dist/capability.d.ts.map +1 -0
  29. package/dist/capability.js +61 -0
  30. package/dist/capability.js.map +1 -0
  31. package/dist/diagnostics/codes/a11y.d.ts +8 -0
  32. package/dist/diagnostics/codes/a11y.d.ts.map +1 -0
  33. package/dist/diagnostics/codes/a11y.js +30 -0
  34. package/dist/diagnostics/codes/a11y.js.map +1 -0
  35. package/dist/diagnostics/codes/action.d.ts +8 -0
  36. package/dist/diagnostics/codes/action.d.ts.map +1 -0
  37. package/dist/diagnostics/codes/action.js +110 -0
  38. package/dist/diagnostics/codes/action.js.map +1 -0
  39. package/dist/diagnostics/codes/artifact.d.ts +8 -0
  40. package/dist/diagnostics/codes/artifact.d.ts.map +1 -0
  41. package/dist/diagnostics/codes/artifact.js +121 -0
  42. package/dist/diagnostics/codes/artifact.js.map +1 -0
  43. package/dist/diagnostics/codes/build.d.ts +8 -0
  44. package/dist/diagnostics/codes/build.d.ts.map +1 -0
  45. package/dist/diagnostics/codes/build.js +55 -0
  46. package/dist/diagnostics/codes/build.js.map +1 -0
  47. package/dist/diagnostics/codes/cli.d.ts +8 -0
  48. package/dist/diagnostics/codes/cli.d.ts.map +1 -0
  49. package/dist/diagnostics/codes/cli.js +44 -0
  50. package/dist/diagnostics/codes/cli.js.map +1 -0
  51. package/dist/diagnostics/codes/console.d.ts +8 -0
  52. package/dist/diagnostics/codes/console.d.ts.map +1 -0
  53. package/dist/diagnostics/codes/console.js +30 -0
  54. package/dist/diagnostics/codes/console.js.map +1 -0
  55. package/dist/diagnostics/codes/dep.d.ts +8 -0
  56. package/dist/diagnostics/codes/dep.d.ts.map +1 -0
  57. package/dist/diagnostics/codes/dep.js +88 -0
  58. package/dist/diagnostics/codes/dep.js.map +1 -0
  59. package/dist/diagnostics/codes/env.d.ts +8 -0
  60. package/dist/diagnostics/codes/env.d.ts.map +1 -0
  61. package/dist/diagnostics/codes/env.js +132 -0
  62. package/dist/diagnostics/codes/env.js.map +1 -0
  63. package/dist/diagnostics/codes/field.d.ts +8 -0
  64. package/dist/diagnostics/codes/field.d.ts.map +1 -0
  65. package/dist/diagnostics/codes/field.js +99 -0
  66. package/dist/diagnostics/codes/field.js.map +1 -0
  67. package/dist/diagnostics/codes/home.d.ts +8 -0
  68. package/dist/diagnostics/codes/home.d.ts.map +1 -0
  69. package/dist/diagnostics/codes/home.js +132 -0
  70. package/dist/diagnostics/codes/home.js.map +1 -0
  71. package/dist/diagnostics/codes/host.d.ts +8 -0
  72. package/dist/diagnostics/codes/host.d.ts.map +1 -0
  73. package/dist/diagnostics/codes/host.js +176 -0
  74. package/dist/diagnostics/codes/host.js.map +1 -0
  75. package/dist/diagnostics/codes/hygiene.d.ts +8 -0
  76. package/dist/diagnostics/codes/hygiene.d.ts.map +1 -0
  77. package/dist/diagnostics/codes/hygiene.js +154 -0
  78. package/dist/diagnostics/codes/hygiene.js.map +1 -0
  79. package/dist/diagnostics/codes/index.d.ts +51 -0
  80. package/dist/diagnostics/codes/index.d.ts.map +1 -0
  81. package/dist/diagnostics/codes/index.js +72 -0
  82. package/dist/diagnostics/codes/index.js.map +1 -0
  83. package/dist/diagnostics/codes/live.d.ts +8 -0
  84. package/dist/diagnostics/codes/live.d.ts.map +1 -0
  85. package/dist/diagnostics/codes/live.js +30 -0
  86. package/dist/diagnostics/codes/live.js.map +1 -0
  87. package/dist/diagnostics/codes/manifest.d.ts +8 -0
  88. package/dist/diagnostics/codes/manifest.d.ts.map +1 -0
  89. package/dist/diagnostics/codes/manifest.js +44 -0
  90. package/dist/diagnostics/codes/manifest.js.map +1 -0
  91. package/dist/diagnostics/codes/network.d.ts +8 -0
  92. package/dist/diagnostics/codes/network.d.ts.map +1 -0
  93. package/dist/diagnostics/codes/network.js +30 -0
  94. package/dist/diagnostics/codes/network.js.map +1 -0
  95. package/dist/diagnostics/codes/platform.d.ts +8 -0
  96. package/dist/diagnostics/codes/platform.d.ts.map +1 -0
  97. package/dist/diagnostics/codes/platform.js +18 -0
  98. package/dist/diagnostics/codes/platform.js.map +1 -0
  99. package/dist/diagnostics/codes/publish.d.ts +8 -0
  100. package/dist/diagnostics/codes/publish.d.ts.map +1 -0
  101. package/dist/diagnostics/codes/publish.js +44 -0
  102. package/dist/diagnostics/codes/publish.js.map +1 -0
  103. package/dist/diagnostics/codes/regression.d.ts +8 -0
  104. package/dist/diagnostics/codes/regression.d.ts.map +1 -0
  105. package/dist/diagnostics/codes/regression.js +77 -0
  106. package/dist/diagnostics/codes/regression.js.map +1 -0
  107. package/dist/diagnostics/codes/runtime.d.ts +8 -0
  108. package/dist/diagnostics/codes/runtime.d.ts.map +1 -0
  109. package/dist/diagnostics/codes/runtime.js +66 -0
  110. package/dist/diagnostics/codes/runtime.js.map +1 -0
  111. package/dist/diagnostics/codes/secret.d.ts +8 -0
  112. package/dist/diagnostics/codes/secret.d.ts.map +1 -0
  113. package/dist/diagnostics/codes/secret.js +18 -0
  114. package/dist/diagnostics/codes/secret.js.map +1 -0
  115. package/dist/diagnostics/codes/smoke.d.ts +8 -0
  116. package/dist/diagnostics/codes/smoke.d.ts.map +1 -0
  117. package/dist/diagnostics/codes/smoke.js +30 -0
  118. package/dist/diagnostics/codes/smoke.js.map +1 -0
  119. package/dist/diagnostics/codes/submit.d.ts +8 -0
  120. package/dist/diagnostics/codes/submit.d.ts.map +1 -0
  121. package/dist/diagnostics/codes/submit.js +99 -0
  122. package/dist/diagnostics/codes/submit.js.map +1 -0
  123. package/dist/diagnostics/codes/target.d.ts +8 -0
  124. package/dist/diagnostics/codes/target.d.ts.map +1 -0
  125. package/dist/diagnostics/codes/target.js +18 -0
  126. package/dist/diagnostics/codes/target.js.map +1 -0
  127. package/dist/diagnostics/codes/type.d.ts +8 -0
  128. package/dist/diagnostics/codes/type.d.ts.map +1 -0
  129. package/dist/diagnostics/codes/type.js +30 -0
  130. package/dist/diagnostics/codes/type.js.map +1 -0
  131. package/dist/diagnostics/codes/verify.d.ts +8 -0
  132. package/dist/diagnostics/codes/verify.d.ts.map +1 -0
  133. package/dist/diagnostics/codes/verify.js +99 -0
  134. package/dist/diagnostics/codes/verify.js.map +1 -0
  135. package/dist/diagnostics/diagnostic.d.ts +79 -0
  136. package/dist/diagnostics/diagnostic.d.ts.map +1 -0
  137. package/dist/diagnostics/diagnostic.js +131 -0
  138. package/dist/diagnostics/diagnostic.js.map +1 -0
  139. package/dist/diagnostics/spec.d.ts +49 -0
  140. package/dist/diagnostics/spec.d.ts.map +1 -0
  141. package/dist/diagnostics/spec.js +31 -0
  142. package/dist/diagnostics/spec.js.map +1 -0
  143. package/dist/hygiene.d.ts +66 -0
  144. package/dist/hygiene.d.ts.map +1 -0
  145. package/dist/hygiene.js +134 -0
  146. package/dist/hygiene.js.map +1 -0
  147. package/dist/ids.d.ts +119 -0
  148. package/dist/ids.d.ts.map +1 -0
  149. package/dist/ids.js +135 -0
  150. package/dist/ids.js.map +1 -0
  151. package/dist/index.d.ts +86 -0
  152. package/dist/index.js +86 -0
  153. package/dist/interaction.d.ts +391 -0
  154. package/dist/interaction.d.ts.map +1 -0
  155. package/dist/interaction.js +306 -0
  156. package/dist/interaction.js.map +1 -0
  157. package/dist/manifest.d.ts +97 -0
  158. package/dist/manifest.d.ts.map +1 -0
  159. package/dist/manifest.js +101 -0
  160. package/dist/manifest.js.map +1 -0
  161. package/dist/method.d.ts +26 -0
  162. package/dist/method.d.ts.map +1 -0
  163. package/dist/method.js +10 -0
  164. package/dist/method.js.map +1 -0
  165. package/dist/methods/artifact/create.d.ts +29 -0
  166. package/dist/methods/artifact/create.d.ts.map +1 -0
  167. package/dist/methods/artifact/create.js +31 -0
  168. package/dist/methods/artifact/create.js.map +1 -0
  169. package/dist/methods/artifact/get.d.ts +17 -0
  170. package/dist/methods/artifact/get.d.ts.map +1 -0
  171. package/dist/methods/artifact/get.js +21 -0
  172. package/dist/methods/artifact/get.js.map +1 -0
  173. package/dist/methods/artifact/list.d.ts +22 -0
  174. package/dist/methods/artifact/list.d.ts.map +1 -0
  175. package/dist/methods/artifact/list.js +19 -0
  176. package/dist/methods/artifact/list.js.map +1 -0
  177. package/dist/methods/artifact/publish.d.ts +28 -0
  178. package/dist/methods/artifact/publish.d.ts.map +1 -0
  179. package/dist/methods/artifact/publish.js +28 -0
  180. package/dist/methods/artifact/publish.js.map +1 -0
  181. package/dist/methods/artifact/verify.d.ts +29 -0
  182. package/dist/methods/artifact/verify.d.ts.map +1 -0
  183. package/dist/methods/artifact/verify.js +27 -0
  184. package/dist/methods/artifact/verify.js.map +1 -0
  185. package/dist/methods/deps/add.d.ts +43 -0
  186. package/dist/methods/deps/add.d.ts.map +1 -0
  187. package/dist/methods/deps/add.js +40 -0
  188. package/dist/methods/deps/add.js.map +1 -0
  189. package/dist/methods/dev/start.d.ts +52 -0
  190. package/dist/methods/dev/start.d.ts.map +1 -0
  191. package/dist/methods/dev/start.js +56 -0
  192. package/dist/methods/dev/start.js.map +1 -0
  193. package/dist/methods/dev/stop.d.ts +16 -0
  194. package/dist/methods/dev/stop.d.ts.map +1 -0
  195. package/dist/methods/dev/stop.js +21 -0
  196. package/dist/methods/dev/stop.js.map +1 -0
  197. package/dist/methods/events/ack.d.ts +20 -0
  198. package/dist/methods/events/ack.d.ts.map +1 -0
  199. package/dist/methods/events/ack.js +26 -0
  200. package/dist/methods/events/ack.js.map +1 -0
  201. package/dist/methods/events/read.d.ts +40 -0
  202. package/dist/methods/events/read.d.ts.map +1 -0
  203. package/dist/methods/events/read.js +35 -0
  204. package/dist/methods/events/read.js.map +1 -0
  205. package/dist/methods/events/subscribe.d.ts +54 -0
  206. package/dist/methods/events/subscribe.d.ts.map +1 -0
  207. package/dist/methods/events/subscribe.js +44 -0
  208. package/dist/methods/events/subscribe.js.map +1 -0
  209. package/dist/methods/events/unsubscribe.d.ts +16 -0
  210. package/dist/methods/events/unsubscribe.d.ts.map +1 -0
  211. package/dist/methods/events/unsubscribe.js +21 -0
  212. package/dist/methods/events/unsubscribe.js.map +1 -0
  213. package/dist/methods/gc/run.d.ts +76 -0
  214. package/dist/methods/gc/run.d.ts.map +1 -0
  215. package/dist/methods/gc/run.js +56 -0
  216. package/dist/methods/gc/run.js.map +1 -0
  217. package/dist/methods/index.d.ts +6 -0
  218. package/dist/methods/index.d.ts.map +1 -0
  219. package/dist/methods/index.js +78 -0
  220. package/dist/methods/index.js.map +1 -0
  221. package/dist/methods/instance/check.d.ts +30 -0
  222. package/dist/methods/instance/check.d.ts.map +1 -0
  223. package/dist/methods/instance/check.js +34 -0
  224. package/dist/methods/instance/check.js.map +1 -0
  225. package/dist/methods/instance/status.d.ts +102 -0
  226. package/dist/methods/instance/status.d.ts.map +1 -0
  227. package/dist/methods/instance/status.js +83 -0
  228. package/dist/methods/instance/status.js.map +1 -0
  229. package/dist/methods/live/push.d.ts +28 -0
  230. package/dist/methods/live/push.d.ts.map +1 -0
  231. package/dist/methods/live/push.js +35 -0
  232. package/dist/methods/live/push.js.map +1 -0
  233. package/dist/methods/mostra/initialize.d.ts +143 -0
  234. package/dist/methods/mostra/initialize.d.ts.map +1 -0
  235. package/dist/methods/mostra/initialize.js +97 -0
  236. package/dist/methods/mostra/initialize.js.map +1 -0
  237. package/dist/methods/mostra/shutdown.d.ts +14 -0
  238. package/dist/methods/mostra/shutdown.d.ts.map +1 -0
  239. package/dist/methods/mostra/shutdown.js +22 -0
  240. package/dist/methods/mostra/shutdown.js.map +1 -0
  241. package/dist/methods/port/drafts-mirror.d.ts +30 -0
  242. package/dist/methods/port/drafts-mirror.d.ts.map +1 -0
  243. package/dist/methods/port/drafts-mirror.js +33 -0
  244. package/dist/methods/port/drafts-mirror.js.map +1 -0
  245. package/dist/methods/port/secrets-get.d.ts +19 -0
  246. package/dist/methods/port/secrets-get.d.ts.map +1 -0
  247. package/dist/methods/port/secrets-get.js +31 -0
  248. package/dist/methods/port/secrets-get.js.map +1 -0
  249. package/dist/methods/port/submissions-deliver.d.ts +38 -0
  250. package/dist/methods/port/submissions-deliver.d.ts.map +1 -0
  251. package/dist/methods/port/submissions-deliver.js +38 -0
  252. package/dist/methods/port/submissions-deliver.js.map +1 -0
  253. package/dist/methods/port/trusted-controls-activated.d.ts +27 -0
  254. package/dist/methods/port/trusted-controls-activated.d.ts.map +1 -0
  255. package/dist/methods/port/trusted-controls-activated.js +33 -0
  256. package/dist/methods/port/trusted-controls-activated.js.map +1 -0
  257. package/dist/methods/port/trusted-controls-policy.d.ts +21 -0
  258. package/dist/methods/port/trusted-controls-policy.d.ts.map +1 -0
  259. package/dist/methods/port/trusted-controls-policy.js +27 -0
  260. package/dist/methods/port/trusted-controls-policy.js.map +1 -0
  261. package/dist/methods/results/get.d.ts +32 -0
  262. package/dist/methods/results/get.d.ts.map +1 -0
  263. package/dist/methods/results/get.js +36 -0
  264. package/dist/methods/results/get.js.map +1 -0
  265. package/dist/methods/secret/delete.d.ts +22 -0
  266. package/dist/methods/secret/delete.d.ts.map +1 -0
  267. package/dist/methods/secret/delete.js +32 -0
  268. package/dist/methods/secret/delete.js.map +1 -0
  269. package/dist/methods/secret/list.d.ts +21 -0
  270. package/dist/methods/secret/list.d.ts.map +1 -0
  271. package/dist/methods/secret/list.js +29 -0
  272. package/dist/methods/secret/list.js.map +1 -0
  273. package/dist/methods/secret/set.d.ts +37 -0
  274. package/dist/methods/secret/set.d.ts.map +1 -0
  275. package/dist/methods/secret/set.js +41 -0
  276. package/dist/methods/secret/set.js.map +1 -0
  277. package/dist/methods/state/get.d.ts +25 -0
  278. package/dist/methods/state/get.d.ts.map +1 -0
  279. package/dist/methods/state/get.js +29 -0
  280. package/dist/methods/state/get.js.map +1 -0
  281. package/dist/methods/state/patch.d.ts +32 -0
  282. package/dist/methods/state/patch.d.ts.map +1 -0
  283. package/dist/methods/state/patch.js +29 -0
  284. package/dist/methods/state/patch.js.map +1 -0
  285. package/dist/methods/view/default.d.ts +19 -0
  286. package/dist/methods/view/default.d.ts.map +1 -0
  287. package/dist/methods/view/default.js +23 -0
  288. package/dist/methods/view/default.js.map +1 -0
  289. package/dist/methods/view/launch.d.ts +27 -0
  290. package/dist/methods/view/launch.d.ts.map +1 -0
  291. package/dist/methods/view/launch.js +30 -0
  292. package/dist/methods/view/launch.js.map +1 -0
  293. package/dist/methods/view/revoke.d.ts +19 -0
  294. package/dist/methods/view/revoke.d.ts.map +1 -0
  295. package/dist/methods/view/revoke.js +26 -0
  296. package/dist/methods/view/revoke.js.map +1 -0
  297. package/dist/methods/view/rotate.d.ts +21 -0
  298. package/dist/methods/view/rotate.d.ts.map +1 -0
  299. package/dist/methods/view/rotate.js +27 -0
  300. package/dist/methods/view/rotate.js.map +1 -0
  301. package/dist/methods/view/url.d.ts +52 -0
  302. package/dist/methods/view/url.d.ts.map +1 -0
  303. package/dist/methods/view/url.js +43 -0
  304. package/dist/methods/view/url.js.map +1 -0
  305. package/dist/methods/wait/wait.d.ts +37 -0
  306. package/dist/methods/wait/wait.d.ts.map +1 -0
  307. package/dist/methods/wait/wait.js +39 -0
  308. package/dist/methods/wait/wait.js.map +1 -0
  309. package/dist/revision.d.ts +43 -0
  310. package/dist/revision.d.ts.map +1 -0
  311. package/dist/revision.js +69 -0
  312. package/dist/revision.js.map +1 -0
  313. package/dist/rpc/error.d.ts +47 -0
  314. package/dist/rpc/error.d.ts.map +1 -0
  315. package/dist/rpc/error.js +77 -0
  316. package/dist/rpc/error.js.map +1 -0
  317. package/dist/rpc/lines.d.ts +30 -0
  318. package/dist/rpc/lines.d.ts.map +1 -0
  319. package/dist/rpc/lines.js +63 -0
  320. package/dist/rpc/lines.js.map +1 -0
  321. package/dist/rpc/messages.d.ts +92 -0
  322. package/dist/rpc/messages.d.ts.map +1 -0
  323. package/dist/rpc/messages.js +133 -0
  324. package/dist/rpc/messages.js.map +1 -0
  325. package/dist/rpc/peer.d.ts +81 -0
  326. package/dist/rpc/peer.d.ts.map +1 -0
  327. package/dist/rpc/peer.js +208 -0
  328. package/dist/rpc/peer.js.map +1 -0
  329. package/dist/serializer.d.ts +178 -0
  330. package/dist/serializer.d.ts.map +1 -0
  331. package/dist/serializer.js +929 -0
  332. package/dist/serializer.js.map +1 -0
  333. package/dist/verify.d.ts +254 -0
  334. package/dist/verify.d.ts.map +1 -0
  335. package/dist/verify.js +243 -0
  336. package/dist/verify.js.map +1 -0
  337. package/dist/view.d.ts +103 -0
  338. package/dist/view.d.ts.map +1 -0
  339. package/dist/view.js +110 -0
  340. package/dist/view.js.map +1 -0
  341. package/dist/wire-registry.js +11 -0
  342. package/dist/wire-registry.js.map +1 -0
  343. package/dist/worker.d.ts +249 -0
  344. package/dist/worker.d.ts.map +1 -0
  345. package/dist/worker.js +158 -0
  346. package/dist/worker.js.map +1 -0
  347. package/package.json +114 -3
  348. package/schemas/protocol.draft-07.json +5120 -0
  349. package/schemas/protocol.schema.json +4964 -0
  350. package/src/actions.ts +418 -0
  351. package/src/artifact.ts +187 -0
  352. package/src/bridge.ts +618 -0
  353. package/src/browser.ts +374 -0
  354. package/src/bundle.ts +264 -0
  355. package/src/canonical.ts +49 -0
  356. package/src/capability.ts +92 -0
  357. package/src/diagnostics/codes/a11y.ts +41 -0
  358. package/src/diagnostics/codes/action.ts +125 -0
  359. package/src/diagnostics/codes/artifact.ts +137 -0
  360. package/src/diagnostics/codes/build.ts +65 -0
  361. package/src/diagnostics/codes/cli.ts +53 -0
  362. package/src/diagnostics/codes/console.ts +41 -0
  363. package/src/diagnostics/codes/dep.ts +101 -0
  364. package/src/diagnostics/codes/env.ts +149 -0
  365. package/src/diagnostics/codes/field.ts +113 -0
  366. package/src/diagnostics/codes/home.ts +150 -0
  367. package/src/diagnostics/codes/host.ts +197 -0
  368. package/src/diagnostics/codes/hygiene.ts +175 -0
  369. package/src/diagnostics/codes/index.ts +142 -0
  370. package/src/diagnostics/codes/live.ts +41 -0
  371. package/src/diagnostics/codes/manifest.ts +53 -0
  372. package/src/diagnostics/codes/network.ts +41 -0
  373. package/src/diagnostics/codes/platform.ts +30 -0
  374. package/src/diagnostics/codes/publish.ts +53 -0
  375. package/src/diagnostics/codes/regression.ts +89 -0
  376. package/src/diagnostics/codes/runtime.ts +77 -0
  377. package/src/diagnostics/codes/secret.ts +29 -0
  378. package/src/diagnostics/codes/smoke.ts +41 -0
  379. package/src/diagnostics/codes/submit.ts +113 -0
  380. package/src/diagnostics/codes/target.ts +29 -0
  381. package/src/diagnostics/codes/type.ts +41 -0
  382. package/src/diagnostics/codes/verify.ts +113 -0
  383. package/src/diagnostics/diagnostic.ts +240 -0
  384. package/src/diagnostics/spec.ts +90 -0
  385. package/src/hygiene.ts +224 -0
  386. package/src/ids.ts +279 -0
  387. package/src/index.ts +576 -0
  388. package/src/interaction.ts +728 -0
  389. package/src/manifest.ts +206 -0
  390. package/src/method.ts +42 -0
  391. package/src/methods/artifact/create.ts +56 -0
  392. package/src/methods/artifact/get.ts +30 -0
  393. package/src/methods/artifact/list.ts +42 -0
  394. package/src/methods/artifact/publish.ts +46 -0
  395. package/src/methods/artifact/verify.ts +46 -0
  396. package/src/methods/deps/add.ts +72 -0
  397. package/src/methods/dev/start.ts +84 -0
  398. package/src/methods/dev/stop.ts +32 -0
  399. package/src/methods/events/ack.ts +41 -0
  400. package/src/methods/events/read.ts +67 -0
  401. package/src/methods/events/subscribe.ts +91 -0
  402. package/src/methods/events/unsubscribe.ts +35 -0
  403. package/src/methods/gc/run.ts +125 -0
  404. package/src/methods/index.ts +81 -0
  405. package/src/methods/instance/check.ts +61 -0
  406. package/src/methods/instance/status.ts +172 -0
  407. package/src/methods/live/push.ts +54 -0
  408. package/src/methods/mostra/initialize.ts +249 -0
  409. package/src/methods/mostra/shutdown.ts +31 -0
  410. package/src/methods/port/drafts-mirror.ts +52 -0
  411. package/src/methods/port/secrets-get.ts +40 -0
  412. package/src/methods/port/submissions-deliver.ts +70 -0
  413. package/src/methods/port/trusted-controls-activated.ts +51 -0
  414. package/src/methods/port/trusted-controls-policy.ts +38 -0
  415. package/src/methods/results/get.ts +59 -0
  416. package/src/methods/secret/delete.ts +43 -0
  417. package/src/methods/secret/list.ts +40 -0
  418. package/src/methods/secret/set.ts +69 -0
  419. package/src/methods/state/get.ts +44 -0
  420. package/src/methods/state/patch.ts +51 -0
  421. package/src/methods/view/default.ts +32 -0
  422. package/src/methods/view/launch.ts +47 -0
  423. package/src/methods/view/revoke.ts +39 -0
  424. package/src/methods/view/rotate.ts +37 -0
  425. package/src/methods/view/url.ts +84 -0
  426. package/src/methods/wait/wait.ts +58 -0
  427. package/src/revision.ts +101 -0
  428. package/src/rpc/error.ts +107 -0
  429. package/src/rpc/lines.ts +70 -0
  430. package/src/rpc/messages.ts +188 -0
  431. package/src/rpc/peer.ts +341 -0
  432. package/src/serializer.ts +1217 -0
  433. package/src/timers.d.ts +8 -0
  434. package/src/verify.ts +458 -0
  435. package/src/view.ts +200 -0
  436. package/src/web-crypto.d.ts +9 -0
  437. package/src/web-platform.d.ts +35 -0
  438. package/src/wire-registry.ts +14 -0
  439. package/src/worker.ts +374 -0
package/src/browser.ts ADDED
@@ -0,0 +1,374 @@
1
+ /**
2
+ * The browser protocol (INTERFACES §4, D106): what the client runtime in an artifact's frame sends
3
+ * to the gateway and receives from it. Published versions embed the client runtime, so a gateway
4
+ * serves every revision it ever shipped (FAILURE_MODEL §7); within a revision payloads only grow.
5
+ * Paths are `/_mostra/v/{revision}/…` on the artifact's origin.
6
+ *
7
+ * ```ts
8
+ * const body: FieldsRequest = { mutationId, scope: "viewer", baseRevision: "3", viewId, ops };
9
+ * await fetch(`/_mostra/v/${BROWSER_PROTOCOL_REVISION}/fields`, { method: "POST", body: … });
10
+ * ```
11
+ */
12
+ import * as z from "zod";
13
+ import type { EphemeralMessage } from "./actions.ts";
14
+ import { ArtifactId, Cursor, MutationId, ViewId } from "./ids.ts";
15
+ import {
16
+ DocumentRevision,
17
+ EventRecord,
18
+ FieldOp,
19
+ FieldState,
20
+ SubmissionSummary,
21
+ Viewer,
22
+ } from "./interaction.ts";
23
+ import { SubmissionPolicy } from "./manifest.ts";
24
+ import {
25
+ REVIEW_SET_ID_PATTERN,
26
+ SubmitChannel,
27
+ TrustedControl,
28
+ VersionRef,
29
+ type ViewContext,
30
+ } from "./view.ts";
31
+ import { wireRegistry } from "./wire-registry.ts";
32
+
33
+ export {
34
+ type DeliveryTarget,
35
+ REVIEW_SET_ID_PATTERN,
36
+ readViewContext,
37
+ VersionRef,
38
+ ViewContext,
39
+ ViewContextWire,
40
+ } from "./view.ts";
41
+
42
+ /** Every browser-protocol revision this release serves, oldest first. */
43
+ export const BROWSER_PROTOCOL_REVISIONS: readonly ["2026-10-15"] = ["2026-10-15"];
44
+
45
+ /** The newest browser-protocol revision: what a client runtime built now speaks. */
46
+ export const BROWSER_PROTOCOL_REVISION = "2026-10-15";
47
+
48
+ /** The longest JSON a signal's payload may be, in UTF-8 bytes (D106). */
49
+ export const SIGNAL_PAYLOAD_MAX_BYTES: number = 64 * 1024;
50
+
51
+ /** `POST …/fields`: one mutation of the viewer's draft or the artifact's state. */
52
+ export interface FieldsRequest {
53
+ /** A fresh `mut_` ID per change; a retry repeats it and gets the recorded result. */
54
+ readonly mutationId: string;
55
+ /** Which document: the viewer's draft or the artifact's shared state. */
56
+ readonly scope: "viewer" | "artifact";
57
+ /** The document revision the page last saw; fields changed after it come back as conflicts. */
58
+ readonly baseRevision: DocumentRevision;
59
+ /** The view the page was opened as (D104). */
60
+ readonly viewId: string;
61
+ /** The field changes, applied together under one revision. */
62
+ readonly ops: readonly FieldOp[];
63
+ }
64
+
65
+ /** The Zod schema of the `FieldsRequest` type. */
66
+ export const FieldsRequest: z.ZodType<FieldsRequest> = z
67
+ .object({
68
+ mutationId: MutationId.schema,
69
+ scope: z.enum(["viewer", "artifact"]),
70
+ baseRevision: DocumentRevision,
71
+ viewId: ViewId.schema,
72
+ ops: z.array(FieldOp).min(1).max(1000).readonly(),
73
+ })
74
+ .register(wireRegistry, {
75
+ id: "FieldsRequest",
76
+ description: "A browser mutation: its ID, scope, base revision, view and field ops.",
77
+ });
78
+
79
+ /** `POST …/submit`: submit the viewer's draft from the artifact's own code (D40). */
80
+ export interface SubmitRequest {
81
+ /** The view the page was opened as (D104); its version is what the submission names. */
82
+ readonly viewId: string;
83
+ /** The draft revision the viewer saw; another one is `MOSTRA_SUBMIT_REVISION_MOVED`. */
84
+ readonly expectedRevision: DocumentRevision;
85
+ /** Always `artifact` on this route; the shell's trusted Submit is the `shell` channel (D40). */
86
+ readonly channel: "artifact";
87
+ }
88
+
89
+ /** The Zod schema of the `SubmitRequest` type. */
90
+ export const SubmitRequest: z.ZodType<SubmitRequest> = z
91
+ .object({
92
+ viewId: ViewId.schema,
93
+ expectedRevision: DocumentRevision,
94
+ channel: z.literal("artifact"),
95
+ })
96
+ .register(wireRegistry, {
97
+ id: "SubmitRequest",
98
+ description: "A browser submit: the view and the draft revision the viewer saw.",
99
+ });
100
+
101
+ /** `POST …/signal`: raise a named signal for the host's attention (IN-09). */
102
+ export interface SignalRequest {
103
+ /** The view the page was opened as (D104). */
104
+ readonly viewId: string;
105
+ /** Letters, digits, `.`, `_` and `-`; `submit` is reserved. */
106
+ readonly name: string;
107
+ /** Any JSON, at most 64 KiB. */
108
+ readonly payload?: unknown;
109
+ }
110
+
111
+ /** The Zod schema of the `SignalRequest` type. */
112
+ export const SignalRequest: z.ZodType<SignalRequest> = z
113
+ .object({
114
+ viewId: ViewId.schema,
115
+ name: z.string().min(1).max(64),
116
+ payload: z.unknown().exactOptional(),
117
+ })
118
+ .register(wireRegistry, {
119
+ id: "SignalRequest",
120
+ description: "A browser signal: the view, the signal's name and an optional JSON payload.",
121
+ }) as z.ZodType<SignalRequest>;
122
+
123
+ /** A document as the page loads it: its revision and fields. */
124
+ export interface DocumentSnapshot {
125
+ /** The document's revision. */
126
+ readonly revision: DocumentRevision;
127
+ /** The draft's epoch (D103); 1 for artifact state. */
128
+ readonly epoch: number;
129
+ /** Every field by ID. */
130
+ readonly fields: Readonly<Record<string, FieldState>>;
131
+ }
132
+
133
+ /** The Zod schema of the `DocumentSnapshot` type. */
134
+ export const DocumentSnapshot: z.ZodType<DocumentSnapshot> = z
135
+ .object({
136
+ revision: DocumentRevision,
137
+ epoch: z.int().min(1),
138
+ fields: z.record(z.string(), FieldState),
139
+ })
140
+ .register(wireRegistry, {
141
+ id: "DocumentSnapshot",
142
+ description: "A document's revision, epoch and fields, as a page loads it.",
143
+ });
144
+
145
+ /**
146
+ * The first message of a browser event stream, and a poll's `snapshot`: where the page stands,
147
+ * so it renders the canonical draft and state before applying events after `cursor`.
148
+ */
149
+ export interface StreamSnapshot {
150
+ /** Events after this cursor follow. */
151
+ readonly cursor: string;
152
+ /** Who the page acts as. */
153
+ readonly viewer: Viewer;
154
+ /** The viewer's draft. */
155
+ readonly draft: DocumentSnapshot;
156
+ /** The artifact's shared state. */
157
+ readonly state: DocumentSnapshot;
158
+ /** The submission that closed this draft, or this viewer's latest under `epochs`. */
159
+ readonly submission?: SubmissionSummary;
160
+ /**
161
+ * The artifact's latest version when the snapshot was read (WP-07): a reader that missed its
162
+ * `version.published` event (published between a frame ticket and the stream, or compacted)
163
+ * still learns of it.
164
+ */
165
+ readonly latest?: VersionRef;
166
+ }
167
+
168
+ /** The Zod schema of the `StreamSnapshot` type. */
169
+ export const StreamSnapshot: z.ZodType<StreamSnapshot> = z
170
+ .object({
171
+ cursor: Cursor.schema,
172
+ viewer: Viewer,
173
+ draft: DocumentSnapshot,
174
+ state: DocumentSnapshot,
175
+ submission: SubmissionSummary.exactOptional(),
176
+ latest: VersionRef.exactOptional(),
177
+ })
178
+ .register(wireRegistry, {
179
+ id: "StreamSnapshot",
180
+ description: "Where a page stands: cursor, viewer, draft, artifact state and its submission.",
181
+ });
182
+
183
+ /** `GET …/events/poll`: the long-poll answer on the same cursor as the stream (D47). */
184
+ export interface PollResult {
185
+ /** Where the next poll continues. */
186
+ readonly cursor: string;
187
+ /** The events for this page after the cursor asked for, in order. */
188
+ readonly events: readonly EventRecord[];
189
+ /** Present when the poll asked for none or its cursor was compacted away. */
190
+ readonly snapshot?: StreamSnapshot;
191
+ /**
192
+ * Run and live updates for this view since its last poll (WP-08): lossy and never stored as
193
+ * events, the long-poll's counterpart of the stream's `run` and `live` messages.
194
+ */
195
+ readonly ephemeral?: readonly EphemeralMessage[];
196
+ }
197
+
198
+ /** The Zod schema of the `PollResult` type. */
199
+ export const PollResult: z.ZodType<PollResult> = z
200
+ .object({
201
+ cursor: Cursor.schema,
202
+ events: z.array(EventRecord).readonly(),
203
+ snapshot: StreamSnapshot.exactOptional(),
204
+ ephemeral: z.array(z.record(z.string(), z.unknown())).readonly().exactOptional(),
205
+ })
206
+ .register(wireRegistry, {
207
+ id: "PollResult",
208
+ description: "A long-poll answer: the cursor, the events after the asked one, and a snapshot.",
209
+ }) as unknown as z.ZodType<PollResult>;
210
+
211
+ /**
212
+ * `POST /a/{artifactId}/_mostra/ticket`'s answer on the shell origin: a single-use frame ticket,
213
+ * the view it opens and what the shell needs to render the view's trusted controls (D104, D108).
214
+ */
215
+ export interface FrameTicket extends ViewContext {
216
+ /** The frame's entry URL, carrying the single-use ticket. */
217
+ readonly src: string;
218
+ /** The artifact's origin: the only origin the bridge accepts messages from. */
219
+ readonly artifactOrigin: string;
220
+ /** Whether this viewer follows the artifact's new versions (D63). */
221
+ readonly follow: boolean;
222
+ /** Whether the link opens this version only (D97 item 9): then the shell offers no newer one. */
223
+ readonly pinned: boolean;
224
+ /**
225
+ * The version's server code keeps crashing and is parked (WP-08, FAILURE_MODEL §2): the shell
226
+ * says so, since the page's actions and live data won't work until a new publish.
227
+ */
228
+ readonly serverParked?: true;
229
+ /**
230
+ * The frame shows `mostra dev`'s development preview of unpublished source (D140 item 12): the
231
+ * shell says so, and it is never a published version.
232
+ */
233
+ readonly devPreview?: true;
234
+ }
235
+
236
+ /** The Zod schema of the `FrameTicket` type. */
237
+ export const FrameTicket: z.ZodType<FrameTicket> = z
238
+ .object({
239
+ artifactId: ArtifactId.schema,
240
+ viewId: ViewId.schema,
241
+ version: VersionRef,
242
+ latest: VersionRef,
243
+ policy: SubmissionPolicy,
244
+ submitChannels: z.array(SubmitChannel).min(1).max(2).readonly(),
245
+ controls: z.array(TrustedControl).max(32).readonly(),
246
+ target: z.enum(["live", "static", "mcp-app", "verify"]),
247
+ src: z.string().min(1),
248
+ artifactOrigin: z.string().min(1),
249
+ follow: z.boolean(),
250
+ pinned: z.boolean(),
251
+ serverParked: z.literal(true).exactOptional(),
252
+ devPreview: z.literal(true).exactOptional(),
253
+ })
254
+ .register(wireRegistry, {
255
+ id: "FrameTicket",
256
+ description: "A frame ticket: the view it opens, where to load it, and the view's controls.",
257
+ });
258
+
259
+ // ── The shell's own routes (WP-07, on the shell origin) ──────────────────────────────────
260
+
261
+ /**
262
+ * `POST /a/{artifactId}/_mostra/v/{rev}/submit`: the shell's trusted Submit (the `shell` channel,
263
+ * D40). Only the shell's page can send it: the route takes the shell's session, its exact origin
264
+ * and its CSRF token, none of which an artifact's page has.
265
+ */
266
+ export interface ShellSubmitRequest {
267
+ /** The view the shell's frame shows (D104); its version is what the submission names. */
268
+ readonly viewId: string;
269
+ /** The draft revision the viewer saw, after the frame flushed its saves. */
270
+ readonly expectedRevision: DocumentRevision;
271
+ }
272
+
273
+ /** The Zod schema of the `ShellSubmitRequest` type. */
274
+ export const ShellSubmitRequest: z.ZodType<ShellSubmitRequest> = z
275
+ .object({ viewId: ViewId.schema, expectedRevision: DocumentRevision })
276
+ .register(wireRegistry, {
277
+ id: "ShellSubmitRequest",
278
+ description: "The shell's trusted Submit: the view and the draft revision the viewer saw.",
279
+ });
280
+
281
+ /**
282
+ * `POST /a/{artifactId}/_mostra/v/{rev}/review/choose`: the shell's trusted Choose (D65, D113).
283
+ * It writes the viewer's draft field `review.<reviewSetId>.choice` like any mutation, so a stale
284
+ * base revision comes back as a conflict.
285
+ */
286
+ export interface ChooseRequest {
287
+ /** The view the shell's frame shows. */
288
+ readonly viewId: string;
289
+ /** A fresh `mut_` ID; a retry repeats it. */
290
+ readonly mutationId: string;
291
+ /** The draft revision the shell last saw. */
292
+ readonly baseRevision: DocumentRevision;
293
+ /** The review set. */
294
+ readonly reviewSetId: string;
295
+ /** The chosen candidate's ID. */
296
+ readonly candidateId: string;
297
+ /** The candidate's label, kept with the choice for results. */
298
+ readonly label?: string;
299
+ }
300
+
301
+ /** The Zod schema of the `ChooseRequest` type. */
302
+ export const ChooseRequest: z.ZodType<ChooseRequest> = z
303
+ .object({
304
+ viewId: ViewId.schema,
305
+ mutationId: MutationId.schema,
306
+ baseRevision: DocumentRevision,
307
+ reviewSetId: z.string().regex(REVIEW_SET_ID_PATTERN),
308
+ candidateId: z.string().min(1).max(256),
309
+ label: z.string().max(256).exactOptional(),
310
+ })
311
+ .register(wireRegistry, {
312
+ id: "ChooseRequest",
313
+ description:
314
+ "The shell's trusted Choose: the view, mutation, base revision, set and candidate.",
315
+ });
316
+
317
+ /** `POST /a/{artifactId}/_mostra/v/{rev}/follow`: the viewer's "Always follow this artifact" (D63). */
318
+ export interface FollowRequest {
319
+ /** `true` to load new versions automatically, `false` to stop. */
320
+ readonly follow: boolean;
321
+ }
322
+
323
+ /** The Zod schema of the `FollowRequest` type. */
324
+ export const FollowRequest: z.ZodType<FollowRequest> = z
325
+ .object({ follow: z.boolean() })
326
+ .register(wireRegistry, {
327
+ id: "FollowRequest",
328
+ description: "Whether the viewer follows the artifact's new versions.",
329
+ });
330
+
331
+ /** A draft field a version doesn't cover (D42, D109): kept, shown read-only and delivered. */
332
+ export interface OrphanedField {
333
+ /** The field's ID. */
334
+ readonly id: string;
335
+ /** Its label, when it has one. */
336
+ readonly label?: string;
337
+ /** Its value. */
338
+ readonly value: unknown;
339
+ /** The version whose view last wrote it. */
340
+ readonly fromVersion: number;
341
+ }
342
+
343
+ /** The Zod schema of the `OrphanedField` type. */
344
+ export const OrphanedField: z.ZodType<OrphanedField> = z
345
+ .object({
346
+ id: z.string(),
347
+ label: z.string().exactOptional(),
348
+ value: z.unknown(),
349
+ fromVersion: z.int().min(1),
350
+ })
351
+ .register(wireRegistry, {
352
+ id: "OrphanedField",
353
+ description: "A draft field a version doesn't cover: its ID, label, value and source version.",
354
+ }) as z.ZodType<OrphanedField>;
355
+
356
+ /**
357
+ * `GET /a/{artifactId}/_mostra/v/{rev}/carry?version=<number>`: which of the viewer's answers a
358
+ * version doesn't carry over (D42, D109). The banner counts them before a switch; the "Not
359
+ * carried over" panel lists them for the version shown.
360
+ */
361
+ export interface CarryOver {
362
+ /** The version asked about. */
363
+ readonly version: VersionRef;
364
+ /** The viewer's draft fields the version doesn't cover. */
365
+ readonly orphans: readonly OrphanedField[];
366
+ }
367
+
368
+ /** The Zod schema of the `CarryOver` type. */
369
+ export const CarryOver: z.ZodType<CarryOver> = z
370
+ .object({ version: VersionRef, orphans: z.array(OrphanedField).readonly() })
371
+ .register(wireRegistry, {
372
+ id: "CarryOver",
373
+ description: "The viewer's answers a version doesn't carry over.",
374
+ });
package/src/bundle.ts ADDED
@@ -0,0 +1,264 @@
1
+ /**
2
+ * The runtime bundle's contract (RT-01, INTERFACES §16): what a host downloads, how it checks it
3
+ * and where its entry points are. The SDK, the CLI's bootstrap and the Rust crate (WP-12) all read
4
+ * these files, so they are wire schemas: published as JSON Schema and changed only additively.
5
+ *
6
+ * A release attaches one archive per platform, `mostra-<version>-<platform>.tar.gz`, whose single
7
+ * top directory holds:
8
+ *
9
+ * ```text
10
+ * bundle.json BundleInfo: identity, entry points, the digest of files.json, the browser pin
11
+ * files.json BundleFiles: every other file and link of the archive with its SHA-256
12
+ * node/ the official Node.js distribution for the platform
13
+ * lib/node_modules/ Mostra's packages (cli, runtime, worker, verify, shell, sdk, warm) and theirs
14
+ * bin/ the mostra, mostra-runtime and mostra-setup launchers
15
+ * ```
16
+ *
17
+ * The verify browser isn't in the archive: setup downloads the pinned revision through the
18
+ * bundle's own Playwright and checks every file against `BundleInfo.browser.files` (D142).
19
+ */
20
+ import * as z from "zod";
21
+ import { wireRegistry } from "./wire-registry.ts";
22
+
23
+ /** The platforms v1 ships a bundle for (D35; Windows follows in v1.1, D120). */
24
+ export const BUNDLE_PLATFORMS: readonly ["darwin-arm64", "darwin-x64", "linux-x64", "linux-arm64"] =
25
+ ["darwin-arm64", "darwin-x64", "linux-x64", "linux-arm64"];
26
+
27
+ /** One platform a bundle is built for: `<os>-<arch>` as Node names them. */
28
+ export type BundlePlatform = (typeof BUNDLE_PLATFORMS)[number];
29
+
30
+ /** The `name` every `bundle.json` carries, so a stray JSON file is never taken for one. */
31
+ export const BUNDLE_NAME = "mostra-runtime-bundle";
32
+
33
+ /** The marker setup writes at a bundle's root once its files and its browser are verified. */
34
+ export const BUNDLE_SETUP_MARKER = ".mostra-setup.json";
35
+
36
+ /** The archive a release attaches for a version and platform. */
37
+ export function bundleAssetName(version: string, platform: BundlePlatform): string {
38
+ return `mostra-${version}-${platform}.tar.gz`;
39
+ }
40
+
41
+ const sha256: z.ZodType<string> = z
42
+ .string()
43
+ .regex(/^[0-9a-f]{64}$/)
44
+ .register(wireRegistry, { id: "Sha256", description: "A SHA-256 digest in lowercase hex." });
45
+
46
+ /**
47
+ * A path inside a bundle, `/`-separated and relative. Readers refuse absolute paths and `.` or
48
+ * `..` segments themselves; the pattern only keeps the obvious out.
49
+ */
50
+ const bundlePath: z.ZodType<string> = z
51
+ .string()
52
+ .min(1)
53
+ .regex(/^[^/\0]/);
54
+
55
+ /** The platform schema. */
56
+ export const BundlePlatformSchema: z.ZodType<BundlePlatform> = z
57
+ .enum(BUNDLE_PLATFORMS)
58
+ .register(wireRegistry, { id: "BundlePlatform" });
59
+
60
+ /** One regular file of a bundle or of its browser. */
61
+ export interface BundleFileEntry {
62
+ /** Relative to the bundle's root (or to `browsers/` for the browser), `/`-separated. */
63
+ readonly path: string;
64
+ /** Its length in bytes. */
65
+ readonly size: number;
66
+ /** The SHA-256 of its bytes, lowercase hex. */
67
+ readonly sha256: string;
68
+ /** Whether its owner may execute it (mode 0755 rather than 0644 once extracted). */
69
+ readonly executable: boolean;
70
+ }
71
+
72
+ /** The file entry schema. */
73
+ export const BundleFileEntry: z.ZodType<BundleFileEntry> = z
74
+ .object({
75
+ path: bundlePath,
76
+ size: z.int().min(0),
77
+ sha256,
78
+ executable: z.boolean(),
79
+ })
80
+ .register(wireRegistry, { id: "BundleFileEntry" });
81
+
82
+ /** One symbolic link of a bundle. Its target is relative and resolves inside the bundle. */
83
+ export interface BundleLinkEntry {
84
+ /** The link itself, relative to the bundle's root. */
85
+ readonly path: string;
86
+ /** What the link holds, exactly as written (relative). */
87
+ readonly target: string;
88
+ }
89
+
90
+ /** The link entry schema. */
91
+ export const BundleLinkEntry: z.ZodType<BundleLinkEntry> = z
92
+ .object({ path: bundlePath, target: z.string().min(1) })
93
+ .register(wireRegistry, { id: "BundleLinkEntry" });
94
+
95
+ /** `files.json`: everything in the archive besides `bundle.json`, each list sorted by path. */
96
+ export interface BundleFiles {
97
+ /** The format's version; 1 today. */
98
+ readonly schemaVersion: 1;
99
+ /** Every regular file, sorted by path. */
100
+ readonly files: readonly BundleFileEntry[];
101
+ /** Every symbolic link, sorted by path. */
102
+ readonly links: readonly BundleLinkEntry[];
103
+ }
104
+
105
+ /** The `files.json` schema. */
106
+ export const BundleFiles: z.ZodType<BundleFiles> = z
107
+ .object({
108
+ schemaVersion: z.literal(1),
109
+ files: z.array(BundleFileEntry),
110
+ links: z.array(BundleLinkEntry),
111
+ })
112
+ .register(wireRegistry, { id: "BundleFiles" });
113
+
114
+ /** The verify browser a bundle pins: fetched at setup, checked file by file (D142). */
115
+ export interface BundleBrowser {
116
+ /** Playwright's name for the browser. */
117
+ readonly name: "chromium-headless-shell";
118
+ /** Playwright's revision, the directory `browsers/chromium_headless_shell-<revision>`. */
119
+ readonly revision: string;
120
+ /** The browser's own version, for people and diagnostics. */
121
+ readonly browserVersion: string;
122
+ /** The bundle's Playwright CLI, run with the bundle's Node: `install chromium-headless-shell`. */
123
+ readonly installer: string;
124
+ /** Every file the install leaves under `browsers/`, besides Playwright's own markers. */
125
+ readonly files: readonly BundleFileEntry[];
126
+ }
127
+
128
+ /** The browser pin schema. */
129
+ export const BundleBrowser: z.ZodType<BundleBrowser> = z
130
+ .object({
131
+ name: z.literal("chromium-headless-shell"),
132
+ revision: z.string().min(1),
133
+ browserVersion: z.string().min(1),
134
+ installer: bundlePath,
135
+ files: z.array(BundleFileEntry),
136
+ })
137
+ .register(wireRegistry, { id: "BundleBrowser" });
138
+
139
+ /** `bundle.json`: a bundle's identity and entry points. */
140
+ export interface BundleInfo {
141
+ /** The format's version; 1 today. */
142
+ readonly schemaVersion: 1;
143
+ /** Always {@link BUNDLE_NAME}, so a stray `bundle.json` isn't taken for one. */
144
+ readonly name: typeof BUNDLE_NAME;
145
+ /** The Mostra release: every Mostra package in the bundle has this version. */
146
+ readonly version: string;
147
+ /** The platform it was built on and for. */
148
+ readonly platform: BundlePlatform;
149
+ /** The private Node.js the bundle runs on (RT-01), and its executable. */
150
+ readonly node: { readonly version: string; readonly path: string };
151
+ /** Scripts each run as `<node.path> <entry> …`, paths relative to the bundle's root. */
152
+ readonly entries: {
153
+ /** `mostra-runtime host|daemon|service`: what a host spawns (D85). */
154
+ readonly runtime: string;
155
+ /** `mostra`, the CLI. */
156
+ readonly cli: string;
157
+ /** Verifies the bundle, fetches its browser and writes `.mostra-setup.json`. */
158
+ readonly setup: string;
159
+ };
160
+ /** `files.json` and its SHA-256, which ties every other file to this one. */
161
+ readonly files: { readonly path: string; readonly sha256: string };
162
+ /** The verify browser setup fetches and checks (D142 item 2). */
163
+ readonly browser: BundleBrowser;
164
+ /** Where it was built from. */
165
+ readonly source?: { readonly repository: string; readonly commit: string };
166
+ }
167
+
168
+ /** The `bundle.json` schema. */
169
+ export const BundleInfo: z.ZodType<BundleInfo> = z
170
+ .object({
171
+ schemaVersion: z.literal(1),
172
+ name: z.literal(BUNDLE_NAME),
173
+ version: z.string().min(1),
174
+ platform: BundlePlatformSchema,
175
+ node: z.object({ version: z.string().min(1), path: bundlePath }),
176
+ entries: z.object({ runtime: bundlePath, cli: bundlePath, setup: bundlePath }),
177
+ files: z.object({ path: bundlePath, sha256 }),
178
+ browser: BundleBrowser,
179
+ source: z.object({ repository: z.string(), commit: z.string() }).exactOptional(),
180
+ })
181
+ .register(wireRegistry, { id: "BundleInfo" });
182
+
183
+ /** One platform's archive in a release. */
184
+ export interface BundleAsset {
185
+ /** The file name, {@link bundleAssetName}. */
186
+ readonly file: string;
187
+ /** The SHA-256 of the archive's bytes, lowercase hex. */
188
+ readonly sha256: string;
189
+ /** Bytes of the archive. */
190
+ readonly size: number;
191
+ /** Bytes once extracted, before the browser: what an installer checks free space against. */
192
+ readonly unpackedSize: number;
193
+ }
194
+
195
+ /** The asset schema. */
196
+ export const BundleAsset: z.ZodType<BundleAsset> = z
197
+ .object({
198
+ // Exactly an archive's own name, no directory: an installer joins it to its scratch directory
199
+ // (Opus review finding 8), and `BundlePins` checks it names its release and platform.
200
+ file: z
201
+ .string()
202
+ .regex(/^mostra-[0-9A-Za-z][0-9A-Za-z.+-]*-(darwin|linux)-(arm64|x64)\.tar\.gz$/),
203
+ sha256,
204
+ size: z.int().positive(),
205
+ unpackedSize: z.int().positive(),
206
+ })
207
+ .register(wireRegistry, { id: "BundleAsset" });
208
+
209
+ /**
210
+ * `bundles.json`: one release's archives, pinned by SHA-256. The release workflow writes it into
211
+ * `@mostra/sdk` before the package is published, so an npm install pins exactly what it fetches.
212
+ */
213
+ export interface BundlePins {
214
+ /** The format's version; 1 today. */
215
+ readonly schemaVersion: 1;
216
+ /** The release these archives belong to: the SDK's own version. */
217
+ readonly version: string;
218
+ /** The base URL the archives are under: the GitHub release's download path. */
219
+ readonly release: string;
220
+ /** Each platform's archive. */
221
+ readonly assets: Partial<Record<BundlePlatform, BundleAsset>>;
222
+ }
223
+
224
+ /**
225
+ * The `bundles.json` schema. Each asset's `file` has an archive's shape (no directory); that it is
226
+ * exactly {@link bundleAssetName} of the pins' version and its platform is checked by the
227
+ * installer before any I/O, since JSON Schema can't express the comparison.
228
+ */
229
+ export const BundlePins: z.ZodType<BundlePins> = z
230
+ .object({
231
+ schemaVersion: z.literal(1),
232
+ version: z.string().regex(/^[0-9A-Za-z][0-9A-Za-z.+-]*$/),
233
+ release: z.url({ protocol: /^https?$/ }),
234
+ assets: z.partialRecord(BundlePlatformSchema, BundleAsset),
235
+ })
236
+ .register(wireRegistry, { id: "BundlePins" });
237
+
238
+ /** `.mostra-setup.json`: written by setup once the files and the browser are verified. */
239
+ export interface BundleSetup {
240
+ /** The format's version; 1 today. */
241
+ readonly schemaVersion: 1;
242
+ /** The bundle's release. */
243
+ readonly version: string;
244
+ /** The bundle's platform. */
245
+ readonly platform: BundlePlatform;
246
+ /** `BundleInfo.files.sha256` of the bundle it describes. */
247
+ readonly files: string;
248
+ /** The browser revision setup fetched and checked. */
249
+ readonly browser: { readonly revision: string };
250
+ /** When setup finished (RFC 3339). */
251
+ readonly at: string;
252
+ }
253
+
254
+ /** The setup marker's schema. */
255
+ export const BundleSetup: z.ZodType<BundleSetup> = z
256
+ .object({
257
+ schemaVersion: z.literal(1),
258
+ version: z.string().min(1),
259
+ platform: BundlePlatformSchema,
260
+ files: sha256,
261
+ browser: z.object({ revision: z.string().min(1) }),
262
+ at: z.string(),
263
+ })
264
+ .register(wireRegistry, { id: "BundleSetup" });
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Canonical JSON (RFC 8785, the JSON Canonicalization Scheme): one exact text for a JSON value,
3
+ * so equal values hash equally wherever they are hashed. A submission's digest is the SHA-256 of
4
+ * its stored snapshot in this form (DATA_MODEL §3). The snapshot stays in the ledger; results carry
5
+ * the digest as the snapshot's identity, so two results with the same digest hold the same answers.
6
+ *
7
+ * ```ts
8
+ * canonicalJson({ b: [1, "x"], a: null }); // '{"a":null,"b":[1,"x"]}'
9
+ * ```
10
+ */
11
+
12
+ /**
13
+ * The canonical JSON text of `value` (RFC 8785 §3.2): no whitespace; strings, numbers and
14
+ * literals as ECMAScript's `JSON.stringify` writes them; object properties sorted by their UTF-16
15
+ * code units at every depth; array order kept. Properties whose value is `undefined` are left out,
16
+ * as `JSON.stringify` does.
17
+ *
18
+ * @throws TypeError for anything I-JSON can't hold: a non-finite number, a lone surrogate, a
19
+ * bigint, a function or symbol, or an `undefined` outside an object.
20
+ */
21
+ export function canonicalJson(value: unknown): string {
22
+ switch (typeof value) {
23
+ case "string":
24
+ return canonicalString(value);
25
+ case "number":
26
+ if (!Number.isFinite(value)) throw new TypeError("JSON numbers must be finite.");
27
+ return JSON.stringify(value);
28
+ case "boolean":
29
+ return value ? "true" : "false";
30
+ case "object": {
31
+ if (value === null) return "null";
32
+ if (Array.isArray(value)) return `[${value.map((item) => canonicalJson(item)).join(",")}]`;
33
+ const entries = Object.entries(value as Record<string, unknown>).filter(
34
+ ([, item]) => item !== undefined,
35
+ );
36
+ // The default sort compares UTF-16 code units, which is RFC 8785's order.
37
+ entries.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
38
+ return `{${entries.map(([key, item]) => `${canonicalString(key)}:${canonicalJson(item)}`).join(",")}}`;
39
+ }
40
+ default:
41
+ throw new TypeError(`A ${typeof value} has no JSON form.`);
42
+ }
43
+ }
44
+
45
+ function canonicalString(text: string): string {
46
+ // RFC 8785 §3.2.2.2: invalid Unicode (a lone surrogate) must fail rather than be escaped.
47
+ if (!text.isWellFormed()) throw new TypeError("JSON strings must be well-formed Unicode.");
48
+ return JSON.stringify(text);
49
+ }