@mostra/protocol 0.0.0-placeholder → 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 +37 -1
  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 -4
  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
@@ -0,0 +1,156 @@
1
+ import { wireRegistry } from "./wire-registry.js";
2
+ import { ArtifactId, Cursor, MutationId, ViewId } from "./ids.js";
3
+ import { SubmissionPolicy } from "./manifest.js";
4
+ import { REVIEW_SET_ID_PATTERN, SubmitChannel, TrustedControl, VersionRef, ViewContext, ViewContextWire, readViewContext } from "./view.js";
5
+ import { DocumentRevision, EventRecord, FieldOp, FieldState, SubmissionSummary, Viewer } from "./interaction.js";
6
+ import * as z from "zod";
7
+ //#region src/browser.ts
8
+ /**
9
+ * The browser protocol (INTERFACES §4, D106): what the client runtime in an artifact's frame sends
10
+ * to the gateway and receives from it. Published versions embed the client runtime, so a gateway
11
+ * serves every revision it ever shipped (FAILURE_MODEL §7); within a revision payloads only grow.
12
+ * Paths are `/_mostra/v/{revision}/…` on the artifact's origin.
13
+ *
14
+ * ```ts
15
+ * const body: FieldsRequest = { mutationId, scope: "viewer", baseRevision: "3", viewId, ops };
16
+ * await fetch(`/_mostra/v/${BROWSER_PROTOCOL_REVISION}/fields`, { method: "POST", body: … });
17
+ * ```
18
+ */
19
+ /** Every browser-protocol revision this release serves, oldest first. */
20
+ const BROWSER_PROTOCOL_REVISIONS = ["2026-10-15"];
21
+ /** The newest browser-protocol revision: what a client runtime built now speaks. */
22
+ const BROWSER_PROTOCOL_REVISION = "2026-10-15";
23
+ /** The longest JSON a signal's payload may be, in UTF-8 bytes (D106). */
24
+ const SIGNAL_PAYLOAD_MAX_BYTES = 65536;
25
+ /** The Zod schema of the `FieldsRequest` type. */
26
+ const FieldsRequest = z.object({
27
+ mutationId: MutationId.schema,
28
+ scope: z.enum(["viewer", "artifact"]),
29
+ baseRevision: DocumentRevision,
30
+ viewId: ViewId.schema,
31
+ ops: z.array(FieldOp).min(1).max(1e3).readonly()
32
+ }).register(wireRegistry, {
33
+ id: "FieldsRequest",
34
+ description: "A browser mutation: its ID, scope, base revision, view and field ops."
35
+ });
36
+ /** The Zod schema of the `SubmitRequest` type. */
37
+ const SubmitRequest = z.object({
38
+ viewId: ViewId.schema,
39
+ expectedRevision: DocumentRevision,
40
+ channel: z.literal("artifact")
41
+ }).register(wireRegistry, {
42
+ id: "SubmitRequest",
43
+ description: "A browser submit: the view and the draft revision the viewer saw."
44
+ });
45
+ /** The Zod schema of the `SignalRequest` type. */
46
+ const SignalRequest = z.object({
47
+ viewId: ViewId.schema,
48
+ name: z.string().min(1).max(64),
49
+ payload: z.unknown().exactOptional()
50
+ }).register(wireRegistry, {
51
+ id: "SignalRequest",
52
+ description: "A browser signal: the view, the signal's name and an optional JSON payload."
53
+ });
54
+ /** The Zod schema of the `DocumentSnapshot` type. */
55
+ const DocumentSnapshot = z.object({
56
+ revision: DocumentRevision,
57
+ epoch: z.int().min(1),
58
+ fields: z.record(z.string(), FieldState)
59
+ }).register(wireRegistry, {
60
+ id: "DocumentSnapshot",
61
+ description: "A document's revision, epoch and fields, as a page loads it."
62
+ });
63
+ /** The Zod schema of the `StreamSnapshot` type. */
64
+ const StreamSnapshot = z.object({
65
+ cursor: Cursor.schema,
66
+ viewer: Viewer,
67
+ draft: DocumentSnapshot,
68
+ state: DocumentSnapshot,
69
+ submission: SubmissionSummary.exactOptional(),
70
+ latest: VersionRef.exactOptional()
71
+ }).register(wireRegistry, {
72
+ id: "StreamSnapshot",
73
+ description: "Where a page stands: cursor, viewer, draft, artifact state and its submission."
74
+ });
75
+ /** The Zod schema of the `PollResult` type. */
76
+ const PollResult = z.object({
77
+ cursor: Cursor.schema,
78
+ events: z.array(EventRecord).readonly(),
79
+ snapshot: StreamSnapshot.exactOptional(),
80
+ ephemeral: z.array(z.record(z.string(), z.unknown())).readonly().exactOptional()
81
+ }).register(wireRegistry, {
82
+ id: "PollResult",
83
+ description: "A long-poll answer: the cursor, the events after the asked one, and a snapshot."
84
+ });
85
+ /** The Zod schema of the `FrameTicket` type. */
86
+ const FrameTicket = z.object({
87
+ artifactId: ArtifactId.schema,
88
+ viewId: ViewId.schema,
89
+ version: VersionRef,
90
+ latest: VersionRef,
91
+ policy: SubmissionPolicy,
92
+ submitChannels: z.array(SubmitChannel).min(1).max(2).readonly(),
93
+ controls: z.array(TrustedControl).max(32).readonly(),
94
+ target: z.enum([
95
+ "live",
96
+ "static",
97
+ "mcp-app",
98
+ "verify"
99
+ ]),
100
+ src: z.string().min(1),
101
+ artifactOrigin: z.string().min(1),
102
+ follow: z.boolean(),
103
+ pinned: z.boolean(),
104
+ serverParked: z.literal(true).exactOptional(),
105
+ devPreview: z.literal(true).exactOptional()
106
+ }).register(wireRegistry, {
107
+ id: "FrameTicket",
108
+ description: "A frame ticket: the view it opens, where to load it, and the view's controls."
109
+ });
110
+ /** The Zod schema of the `ShellSubmitRequest` type. */
111
+ const ShellSubmitRequest = z.object({
112
+ viewId: ViewId.schema,
113
+ expectedRevision: DocumentRevision
114
+ }).register(wireRegistry, {
115
+ id: "ShellSubmitRequest",
116
+ description: "The shell's trusted Submit: the view and the draft revision the viewer saw."
117
+ });
118
+ /** The Zod schema of the `ChooseRequest` type. */
119
+ const ChooseRequest = z.object({
120
+ viewId: ViewId.schema,
121
+ mutationId: MutationId.schema,
122
+ baseRevision: DocumentRevision,
123
+ reviewSetId: z.string().regex(REVIEW_SET_ID_PATTERN),
124
+ candidateId: z.string().min(1).max(256),
125
+ label: z.string().max(256).exactOptional()
126
+ }).register(wireRegistry, {
127
+ id: "ChooseRequest",
128
+ description: "The shell's trusted Choose: the view, mutation, base revision, set and candidate."
129
+ });
130
+ /** The Zod schema of the `FollowRequest` type. */
131
+ const FollowRequest = z.object({ follow: z.boolean() }).register(wireRegistry, {
132
+ id: "FollowRequest",
133
+ description: "Whether the viewer follows the artifact's new versions."
134
+ });
135
+ /** The Zod schema of the `OrphanedField` type. */
136
+ const OrphanedField = z.object({
137
+ id: z.string(),
138
+ label: z.string().exactOptional(),
139
+ value: z.unknown(),
140
+ fromVersion: z.int().min(1)
141
+ }).register(wireRegistry, {
142
+ id: "OrphanedField",
143
+ description: "A draft field a version doesn't cover: its ID, label, value and source version."
144
+ });
145
+ /** The Zod schema of the `CarryOver` type. */
146
+ const CarryOver = z.object({
147
+ version: VersionRef,
148
+ orphans: z.array(OrphanedField).readonly()
149
+ }).register(wireRegistry, {
150
+ id: "CarryOver",
151
+ description: "The viewer's answers a version doesn't carry over."
152
+ });
153
+ //#endregion
154
+ export { BROWSER_PROTOCOL_REVISION, BROWSER_PROTOCOL_REVISIONS, CarryOver, ChooseRequest, DocumentSnapshot, FieldsRequest, FollowRequest, FrameTicket, OrphanedField, PollResult, REVIEW_SET_ID_PATTERN, SIGNAL_PAYLOAD_MAX_BYTES, ShellSubmitRequest, SignalRequest, StreamSnapshot, SubmitRequest, VersionRef, ViewContext, ViewContextWire, readViewContext };
155
+
156
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","names":[],"sources":["../src/browser.ts"],"sourcesContent":["/**\n * The browser protocol (INTERFACES §4, D106): what the client runtime in an artifact's frame sends\n * to the gateway and receives from it. Published versions embed the client runtime, so a gateway\n * serves every revision it ever shipped (FAILURE_MODEL §7); within a revision payloads only grow.\n * Paths are `/_mostra/v/{revision}/…` on the artifact's origin.\n *\n * ```ts\n * const body: FieldsRequest = { mutationId, scope: \"viewer\", baseRevision: \"3\", viewId, ops };\n * await fetch(`/_mostra/v/${BROWSER_PROTOCOL_REVISION}/fields`, { method: \"POST\", body: … });\n * ```\n */\nimport * as z from \"zod\";\nimport type { EphemeralMessage } from \"./actions.ts\";\nimport { ArtifactId, Cursor, MutationId, ViewId } from \"./ids.ts\";\nimport {\n DocumentRevision,\n EventRecord,\n FieldOp,\n FieldState,\n SubmissionSummary,\n Viewer,\n} from \"./interaction.ts\";\nimport { SubmissionPolicy } from \"./manifest.ts\";\nimport {\n REVIEW_SET_ID_PATTERN,\n SubmitChannel,\n TrustedControl,\n VersionRef,\n type ViewContext,\n} from \"./view.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\nexport {\n type DeliveryTarget,\n REVIEW_SET_ID_PATTERN,\n readViewContext,\n VersionRef,\n ViewContext,\n ViewContextWire,\n} from \"./view.ts\";\n\n/** Every browser-protocol revision this release serves, oldest first. */\nexport const BROWSER_PROTOCOL_REVISIONS: readonly [\"2026-10-15\"] = [\"2026-10-15\"];\n\n/** The newest browser-protocol revision: what a client runtime built now speaks. */\nexport const BROWSER_PROTOCOL_REVISION = \"2026-10-15\";\n\n/** The longest JSON a signal's payload may be, in UTF-8 bytes (D106). */\nexport const SIGNAL_PAYLOAD_MAX_BYTES: number = 64 * 1024;\n\n/** `POST …/fields`: one mutation of the viewer's draft or the artifact's state. */\nexport interface FieldsRequest {\n /** A fresh `mut_` ID per change; a retry repeats it and gets the recorded result. */\n readonly mutationId: string;\n /** Which document: the viewer's draft or the artifact's shared state. */\n readonly scope: \"viewer\" | \"artifact\";\n /** The document revision the page last saw; fields changed after it come back as conflicts. */\n readonly baseRevision: DocumentRevision;\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** The field changes, applied together under one revision. */\n readonly ops: readonly FieldOp[];\n}\n\n/** The Zod schema of the `FieldsRequest` type. */\nexport const FieldsRequest: z.ZodType<FieldsRequest> = z\n .object({\n mutationId: MutationId.schema,\n scope: z.enum([\"viewer\", \"artifact\"]),\n baseRevision: DocumentRevision,\n viewId: ViewId.schema,\n ops: z.array(FieldOp).min(1).max(1000).readonly(),\n })\n .register(wireRegistry, {\n id: \"FieldsRequest\",\n description: \"A browser mutation: its ID, scope, base revision, view and field ops.\",\n });\n\n/** `POST …/submit`: submit the viewer's draft from the artifact's own code (D40). */\nexport interface SubmitRequest {\n /** The view the page was opened as (D104); its version is what the submission names. */\n readonly viewId: string;\n /** The draft revision the viewer saw; another one is `MOSTRA_SUBMIT_REVISION_MOVED`. */\n readonly expectedRevision: DocumentRevision;\n /** Always `artifact` on this route; the shell's trusted Submit is the `shell` channel (D40). */\n readonly channel: \"artifact\";\n}\n\n/** The Zod schema of the `SubmitRequest` type. */\nexport const SubmitRequest: z.ZodType<SubmitRequest> = z\n .object({\n viewId: ViewId.schema,\n expectedRevision: DocumentRevision,\n channel: z.literal(\"artifact\"),\n })\n .register(wireRegistry, {\n id: \"SubmitRequest\",\n description: \"A browser submit: the view and the draft revision the viewer saw.\",\n });\n\n/** `POST …/signal`: raise a named signal for the host's attention (IN-09). */\nexport interface SignalRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** Letters, digits, `.`, `_` and `-`; `submit` is reserved. */\n readonly name: string;\n /** Any JSON, at most 64 KiB. */\n readonly payload?: unknown;\n}\n\n/** The Zod schema of the `SignalRequest` type. */\nexport const SignalRequest: z.ZodType<SignalRequest> = z\n .object({\n viewId: ViewId.schema,\n name: z.string().min(1).max(64),\n payload: z.unknown().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"SignalRequest\",\n description: \"A browser signal: the view, the signal's name and an optional JSON payload.\",\n }) as z.ZodType<SignalRequest>;\n\n/** A document as the page loads it: its revision and fields. */\nexport interface DocumentSnapshot {\n /** The document's revision. */\n readonly revision: DocumentRevision;\n /** The draft's epoch (D103); 1 for artifact state. */\n readonly epoch: number;\n /** Every field by ID. */\n readonly fields: Readonly<Record<string, FieldState>>;\n}\n\n/** The Zod schema of the `DocumentSnapshot` type. */\nexport const DocumentSnapshot: z.ZodType<DocumentSnapshot> = z\n .object({\n revision: DocumentRevision,\n epoch: z.int().min(1),\n fields: z.record(z.string(), FieldState),\n })\n .register(wireRegistry, {\n id: \"DocumentSnapshot\",\n description: \"A document's revision, epoch and fields, as a page loads it.\",\n });\n\n/**\n * The first message of a browser event stream, and a poll's `snapshot`: where the page stands,\n * so it renders the canonical draft and state before applying events after `cursor`.\n */\nexport interface StreamSnapshot {\n /** Events after this cursor follow. */\n readonly cursor: string;\n /** Who the page acts as. */\n readonly viewer: Viewer;\n /** The viewer's draft. */\n readonly draft: DocumentSnapshot;\n /** The artifact's shared state. */\n readonly state: DocumentSnapshot;\n /** The submission that closed this draft, or this viewer's latest under `epochs`. */\n readonly submission?: SubmissionSummary;\n /**\n * The artifact's latest version when the snapshot was read (WP-07): a reader that missed its\n * `version.published` event (published between a frame ticket and the stream, or compacted)\n * still learns of it.\n */\n readonly latest?: VersionRef;\n}\n\n/** The Zod schema of the `StreamSnapshot` type. */\nexport const StreamSnapshot: z.ZodType<StreamSnapshot> = z\n .object({\n cursor: Cursor.schema,\n viewer: Viewer,\n draft: DocumentSnapshot,\n state: DocumentSnapshot,\n submission: SubmissionSummary.exactOptional(),\n latest: VersionRef.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"StreamSnapshot\",\n description: \"Where a page stands: cursor, viewer, draft, artifact state and its submission.\",\n });\n\n/** `GET …/events/poll`: the long-poll answer on the same cursor as the stream (D47). */\nexport interface PollResult {\n /** Where the next poll continues. */\n readonly cursor: string;\n /** The events for this page after the cursor asked for, in order. */\n readonly events: readonly EventRecord[];\n /** Present when the poll asked for none or its cursor was compacted away. */\n readonly snapshot?: StreamSnapshot;\n /**\n * Run and live updates for this view since its last poll (WP-08): lossy and never stored as\n * events, the long-poll's counterpart of the stream's `run` and `live` messages.\n */\n readonly ephemeral?: readonly EphemeralMessage[];\n}\n\n/** The Zod schema of the `PollResult` type. */\nexport const PollResult: z.ZodType<PollResult> = z\n .object({\n cursor: Cursor.schema,\n events: z.array(EventRecord).readonly(),\n snapshot: StreamSnapshot.exactOptional(),\n ephemeral: z.array(z.record(z.string(), z.unknown())).readonly().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"PollResult\",\n description: \"A long-poll answer: the cursor, the events after the asked one, and a snapshot.\",\n }) as unknown as z.ZodType<PollResult>;\n\n/**\n * `POST /a/{artifactId}/_mostra/ticket`'s answer on the shell origin: a single-use frame ticket,\n * the view it opens and what the shell needs to render the view's trusted controls (D104, D108).\n */\nexport interface FrameTicket extends ViewContext {\n /** The frame's entry URL, carrying the single-use ticket. */\n readonly src: string;\n /** The artifact's origin: the only origin the bridge accepts messages from. */\n readonly artifactOrigin: string;\n /** Whether this viewer follows the artifact's new versions (D63). */\n readonly follow: boolean;\n /** Whether the link opens this version only (D97 item 9): then the shell offers no newer one. */\n readonly pinned: boolean;\n /**\n * The version's server code keeps crashing and is parked (WP-08, FAILURE_MODEL §2): the shell\n * says so, since the page's actions and live data won't work until a new publish.\n */\n readonly serverParked?: true;\n /**\n * The frame shows `mostra dev`'s development preview of unpublished source (D140 item 12): the\n * shell says so, and it is never a published version.\n */\n readonly devPreview?: true;\n}\n\n/** The Zod schema of the `FrameTicket` type. */\nexport const FrameTicket: z.ZodType<FrameTicket> = z\n .object({\n artifactId: ArtifactId.schema,\n viewId: ViewId.schema,\n version: VersionRef,\n latest: VersionRef,\n policy: SubmissionPolicy,\n submitChannels: z.array(SubmitChannel).min(1).max(2).readonly(),\n controls: z.array(TrustedControl).max(32).readonly(),\n target: z.enum([\"live\", \"static\", \"mcp-app\", \"verify\"]),\n src: z.string().min(1),\n artifactOrigin: z.string().min(1),\n follow: z.boolean(),\n pinned: z.boolean(),\n serverParked: z.literal(true).exactOptional(),\n devPreview: z.literal(true).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"FrameTicket\",\n description: \"A frame ticket: the view it opens, where to load it, and the view's controls.\",\n });\n\n// ── The shell's own routes (WP-07, on the shell origin) ──────────────────────────────────\n\n/**\n * `POST /a/{artifactId}/_mostra/v/{rev}/submit`: the shell's trusted Submit (the `shell` channel,\n * D40). Only the shell's page can send it: the route takes the shell's session, its exact origin\n * and its CSRF token, none of which an artifact's page has.\n */\nexport interface ShellSubmitRequest {\n /** The view the shell's frame shows (D104); its version is what the submission names. */\n readonly viewId: string;\n /** The draft revision the viewer saw, after the frame flushed its saves. */\n readonly expectedRevision: DocumentRevision;\n}\n\n/** The Zod schema of the `ShellSubmitRequest` type. */\nexport const ShellSubmitRequest: z.ZodType<ShellSubmitRequest> = z\n .object({ viewId: ViewId.schema, expectedRevision: DocumentRevision })\n .register(wireRegistry, {\n id: \"ShellSubmitRequest\",\n description: \"The shell's trusted Submit: the view and the draft revision the viewer saw.\",\n });\n\n/**\n * `POST /a/{artifactId}/_mostra/v/{rev}/review/choose`: the shell's trusted Choose (D65, D113).\n * It writes the viewer's draft field `review.<reviewSetId>.choice` like any mutation, so a stale\n * base revision comes back as a conflict.\n */\nexport interface ChooseRequest {\n /** The view the shell's frame shows. */\n readonly viewId: string;\n /** A fresh `mut_` ID; a retry repeats it. */\n readonly mutationId: string;\n /** The draft revision the shell last saw. */\n readonly baseRevision: DocumentRevision;\n /** The review set. */\n readonly reviewSetId: string;\n /** The chosen candidate's ID. */\n readonly candidateId: string;\n /** The candidate's label, kept with the choice for results. */\n readonly label?: string;\n}\n\n/** The Zod schema of the `ChooseRequest` type. */\nexport const ChooseRequest: z.ZodType<ChooseRequest> = z\n .object({\n viewId: ViewId.schema,\n mutationId: MutationId.schema,\n baseRevision: DocumentRevision,\n reviewSetId: z.string().regex(REVIEW_SET_ID_PATTERN),\n candidateId: z.string().min(1).max(256),\n label: z.string().max(256).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ChooseRequest\",\n description:\n \"The shell's trusted Choose: the view, mutation, base revision, set and candidate.\",\n });\n\n/** `POST /a/{artifactId}/_mostra/v/{rev}/follow`: the viewer's \"Always follow this artifact\" (D63). */\nexport interface FollowRequest {\n /** `true` to load new versions automatically, `false` to stop. */\n readonly follow: boolean;\n}\n\n/** The Zod schema of the `FollowRequest` type. */\nexport const FollowRequest: z.ZodType<FollowRequest> = z\n .object({ follow: z.boolean() })\n .register(wireRegistry, {\n id: \"FollowRequest\",\n description: \"Whether the viewer follows the artifact's new versions.\",\n });\n\n/** A draft field a version doesn't cover (D42, D109): kept, shown read-only and delivered. */\nexport interface OrphanedField {\n /** The field's ID. */\n readonly id: string;\n /** Its label, when it has one. */\n readonly label?: string;\n /** Its value. */\n readonly value: unknown;\n /** The version whose view last wrote it. */\n readonly fromVersion: number;\n}\n\n/** The Zod schema of the `OrphanedField` type. */\nexport const OrphanedField: z.ZodType<OrphanedField> = z\n .object({\n id: z.string(),\n label: z.string().exactOptional(),\n value: z.unknown(),\n fromVersion: z.int().min(1),\n })\n .register(wireRegistry, {\n id: \"OrphanedField\",\n description: \"A draft field a version doesn't cover: its ID, label, value and source version.\",\n }) as z.ZodType<OrphanedField>;\n\n/**\n * `GET /a/{artifactId}/_mostra/v/{rev}/carry?version=<number>`: which of the viewer's answers a\n * version doesn't carry over (D42, D109). The banner counts them before a switch; the \"Not\n * carried over\" panel lists them for the version shown.\n */\nexport interface CarryOver {\n /** The version asked about. */\n readonly version: VersionRef;\n /** The viewer's draft fields the version doesn't cover. */\n readonly orphans: readonly OrphanedField[];\n}\n\n/** The Zod schema of the `CarryOver` type. */\nexport const CarryOver: z.ZodType<CarryOver> = z\n .object({ version: VersionRef, orphans: z.array(OrphanedField).readonly() })\n .register(wireRegistry, {\n id: \"CarryOver\",\n description: \"The viewer's answers a version doesn't carry over.\",\n });\n"],"mappings":"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"}
@@ -0,0 +1,155 @@
1
+ import * as z from "zod";
2
+ //#region src/bundle.d.ts
3
+ /** The platforms v1 ships a bundle for (D35; Windows follows in v1.1, D120). */
4
+ export declare const BUNDLE_PLATFORMS: readonly ["darwin-arm64", "darwin-x64", "linux-x64", "linux-arm64"];
5
+ /** One platform a bundle is built for: `<os>-<arch>` as Node names them. */
6
+ export type BundlePlatform = (typeof BUNDLE_PLATFORMS)[number];
7
+ /** The `name` every `bundle.json` carries, so a stray JSON file is never taken for one. */
8
+ export declare const BUNDLE_NAME = "mostra-runtime-bundle";
9
+ /** The marker setup writes at a bundle's root once its files and its browser are verified. */
10
+ export declare const BUNDLE_SETUP_MARKER = ".mostra-setup.json";
11
+ /** The archive a release attaches for a version and platform. */
12
+ export declare function bundleAssetName(version: string, platform: BundlePlatform): string;
13
+ /** The platform schema. */
14
+ export declare const BundlePlatformSchema: z.ZodType<BundlePlatform>;
15
+ /** One regular file of a bundle or of its browser. */
16
+ export interface BundleFileEntry {
17
+ /** Relative to the bundle's root (or to `browsers/` for the browser), `/`-separated. */
18
+ readonly path: string;
19
+ /** Its length in bytes. */
20
+ readonly size: number;
21
+ /** The SHA-256 of its bytes, lowercase hex. */
22
+ readonly sha256: string;
23
+ /** Whether its owner may execute it (mode 0755 rather than 0644 once extracted). */
24
+ readonly executable: boolean;
25
+ }
26
+ /** The file entry schema. */
27
+ export declare const BundleFileEntry: z.ZodType<BundleFileEntry>;
28
+ /** One symbolic link of a bundle. Its target is relative and resolves inside the bundle. */
29
+ export interface BundleLinkEntry {
30
+ /** The link itself, relative to the bundle's root. */
31
+ readonly path: string;
32
+ /** What the link holds, exactly as written (relative). */
33
+ readonly target: string;
34
+ }
35
+ /** The link entry schema. */
36
+ export declare const BundleLinkEntry: z.ZodType<BundleLinkEntry>;
37
+ /** `files.json`: everything in the archive besides `bundle.json`, each list sorted by path. */
38
+ export interface BundleFiles {
39
+ /** The format's version; 1 today. */
40
+ readonly schemaVersion: 1;
41
+ /** Every regular file, sorted by path. */
42
+ readonly files: readonly BundleFileEntry[];
43
+ /** Every symbolic link, sorted by path. */
44
+ readonly links: readonly BundleLinkEntry[];
45
+ }
46
+ /** The `files.json` schema. */
47
+ export declare const BundleFiles: z.ZodType<BundleFiles>;
48
+ /** The verify browser a bundle pins: fetched at setup, checked file by file (D142). */
49
+ export interface BundleBrowser {
50
+ /** Playwright's name for the browser. */
51
+ readonly name: "chromium-headless-shell";
52
+ /** Playwright's revision, the directory `browsers/chromium_headless_shell-<revision>`. */
53
+ readonly revision: string;
54
+ /** The browser's own version, for people and diagnostics. */
55
+ readonly browserVersion: string;
56
+ /** The bundle's Playwright CLI, run with the bundle's Node: `install chromium-headless-shell`. */
57
+ readonly installer: string;
58
+ /** Every file the install leaves under `browsers/`, besides Playwright's own markers. */
59
+ readonly files: readonly BundleFileEntry[];
60
+ }
61
+ /** The browser pin schema. */
62
+ export declare const BundleBrowser: z.ZodType<BundleBrowser>;
63
+ /** `bundle.json`: a bundle's identity and entry points. */
64
+ export interface BundleInfo {
65
+ /** The format's version; 1 today. */
66
+ readonly schemaVersion: 1;
67
+ /** Always {@link BUNDLE_NAME}, so a stray `bundle.json` isn't taken for one. */
68
+ readonly name: typeof BUNDLE_NAME;
69
+ /** The Mostra release: every Mostra package in the bundle has this version. */
70
+ readonly version: string;
71
+ /** The platform it was built on and for. */
72
+ readonly platform: BundlePlatform;
73
+ /** The private Node.js the bundle runs on (RT-01), and its executable. */
74
+ readonly node: {
75
+ readonly version: string;
76
+ readonly path: string;
77
+ };
78
+ /** Scripts each run as `<node.path> <entry> …`, paths relative to the bundle's root. */
79
+ readonly entries: {
80
+ /** `mostra-runtime host|daemon|service`: what a host spawns (D85). */
81
+ readonly runtime: string;
82
+ /** `mostra`, the CLI. */
83
+ readonly cli: string;
84
+ /** Verifies the bundle, fetches its browser and writes `.mostra-setup.json`. */
85
+ readonly setup: string;
86
+ };
87
+ /** `files.json` and its SHA-256, which ties every other file to this one. */
88
+ readonly files: {
89
+ readonly path: string;
90
+ readonly sha256: string;
91
+ };
92
+ /** The verify browser setup fetches and checks (D142 item 2). */
93
+ readonly browser: BundleBrowser;
94
+ /** Where it was built from. */
95
+ readonly source?: {
96
+ readonly repository: string;
97
+ readonly commit: string;
98
+ };
99
+ }
100
+ /** The `bundle.json` schema. */
101
+ export declare const BundleInfo: z.ZodType<BundleInfo>;
102
+ /** One platform's archive in a release. */
103
+ export interface BundleAsset {
104
+ /** The file name, {@link bundleAssetName}. */
105
+ readonly file: string;
106
+ /** The SHA-256 of the archive's bytes, lowercase hex. */
107
+ readonly sha256: string;
108
+ /** Bytes of the archive. */
109
+ readonly size: number;
110
+ /** Bytes once extracted, before the browser: what an installer checks free space against. */
111
+ readonly unpackedSize: number;
112
+ }
113
+ /** The asset schema. */
114
+ export declare const BundleAsset: z.ZodType<BundleAsset>;
115
+ /**
116
+ * `bundles.json`: one release's archives, pinned by SHA-256. The release workflow writes it into
117
+ * `@mostra/sdk` before the package is published, so an npm install pins exactly what it fetches.
118
+ */
119
+ export interface BundlePins {
120
+ /** The format's version; 1 today. */
121
+ readonly schemaVersion: 1;
122
+ /** The release these archives belong to: the SDK's own version. */
123
+ readonly version: string;
124
+ /** The base URL the archives are under: the GitHub release's download path. */
125
+ readonly release: string;
126
+ /** Each platform's archive. */
127
+ readonly assets: Partial<Record<BundlePlatform, BundleAsset>>;
128
+ }
129
+ /**
130
+ * The `bundles.json` schema. Each asset's `file` has an archive's shape (no directory); that it is
131
+ * exactly {@link bundleAssetName} of the pins' version and its platform is checked by the
132
+ * installer before any I/O, since JSON Schema can't express the comparison.
133
+ */
134
+ export declare const BundlePins: z.ZodType<BundlePins>;
135
+ /** `.mostra-setup.json`: written by setup once the files and the browser are verified. */
136
+ export interface BundleSetup {
137
+ /** The format's version; 1 today. */
138
+ readonly schemaVersion: 1;
139
+ /** The bundle's release. */
140
+ readonly version: string;
141
+ /** The bundle's platform. */
142
+ readonly platform: BundlePlatform;
143
+ /** `BundleInfo.files.sha256` of the bundle it describes. */
144
+ readonly files: string;
145
+ /** The browser revision setup fetched and checked. */
146
+ readonly browser: {
147
+ readonly revision: string;
148
+ };
149
+ /** When setup finished (RFC 3339). */
150
+ readonly at: string;
151
+ }
152
+ /** The setup marker's schema. */
153
+ export declare const BundleSetup: z.ZodType<BundleSetup>;
154
+ //#endregion
155
+ //# sourceMappingURL=bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.d.ts","names":[],"sources":["../src/bundle.ts"],"mappings":";;;qBAuBa;;YAID,yBAAyB;;qBAGxB;;qBAGA;;wBAGG,gBAAgB,iBAAiB,UAAU;;qBAmB9C,sBAAsB,EAAE,QAAQ;;iBAK5B;;WAEN;;WAEA;;WAEA;;WAEA;;;qBAIE,iBAAiB,EAAE,QAAQ;;iBAUvB;;WAEN;;WAEA;;;qBAIE,iBAAiB,EAAE,QAAQ;;iBAKvB;;WAEN;;WAEA,gBAAgB;;WAEhB,gBAAgB;;;qBAId,aAAa,EAAE,QAAQ;;iBASnB;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA,gBAAgB;;;qBAId,eAAe,EAAE,QAAQ;;iBAWrB;;WAEN;;WAEA,aAAa;;WAEb;;WAEA,UAAU;;WAEV;aAAiB;aAA0B;;;WAE3C;;aAEE;;aAEA;;aAEA;;;WAGF;aAAkB;aAAuB;;;WAEzC,SAAS;;WAET;aAAoB;aAA6B;;;;qBAI/C,YAAY,EAAE,QAAQ;;iBAelB;;WAEN;;WAEA;;WAEA;;WAEA;;;qBAIE,aAAa,EAAE,QAAQ;;;;;iBAiBnB;;WAEN;;WAEA;;WAEA;;WAEA,QAAQ,QAAQ,OAAO,gBAAgB;;;;;;;qBAQrC,YAAY,EAAE,QAAQ;;iBAUlB;;WAEN;;WAEA;;WAEA,UAAU;;WAEV;;WAEA;aAAoB;;;WAEpB;;;qBAIE,aAAa,EAAE,QAAQ"}
package/dist/bundle.js ADDED
@@ -0,0 +1,130 @@
1
+ import { wireRegistry } from "./wire-registry.js";
2
+ import * as z from "zod";
3
+ //#region src/bundle.ts
4
+ /**
5
+ * The runtime bundle's contract (RT-01, INTERFACES §16): what a host downloads, how it checks it
6
+ * and where its entry points are. The SDK, the CLI's bootstrap and the Rust crate (WP-12) all read
7
+ * these files, so they are wire schemas: published as JSON Schema and changed only additively.
8
+ *
9
+ * A release attaches one archive per platform, `mostra-<version>-<platform>.tar.gz`, whose single
10
+ * top directory holds:
11
+ *
12
+ * ```text
13
+ * bundle.json BundleInfo: identity, entry points, the digest of files.json, the browser pin
14
+ * files.json BundleFiles: every other file and link of the archive with its SHA-256
15
+ * node/ the official Node.js distribution for the platform
16
+ * lib/node_modules/ Mostra's packages (cli, runtime, worker, verify, shell, sdk, warm) and theirs
17
+ * bin/ the mostra, mostra-runtime and mostra-setup launchers
18
+ * ```
19
+ *
20
+ * The verify browser isn't in the archive: setup downloads the pinned revision through the
21
+ * bundle's own Playwright and checks every file against `BundleInfo.browser.files` (D142).
22
+ */
23
+ /** The platforms v1 ships a bundle for (D35; Windows follows in v1.1, D120). */
24
+ const BUNDLE_PLATFORMS = [
25
+ "darwin-arm64",
26
+ "darwin-x64",
27
+ "linux-x64",
28
+ "linux-arm64"
29
+ ];
30
+ /** The `name` every `bundle.json` carries, so a stray JSON file is never taken for one. */
31
+ const BUNDLE_NAME = "mostra-runtime-bundle";
32
+ /** The marker setup writes at a bundle's root once its files and its browser are verified. */
33
+ const BUNDLE_SETUP_MARKER = ".mostra-setup.json";
34
+ /** The archive a release attaches for a version and platform. */
35
+ function bundleAssetName(version, platform) {
36
+ return `mostra-${version}-${platform}.tar.gz`;
37
+ }
38
+ const sha256 = z.string().regex(/^[0-9a-f]{64}$/).register(wireRegistry, {
39
+ id: "Sha256",
40
+ description: "A SHA-256 digest in lowercase hex."
41
+ });
42
+ /**
43
+ * A path inside a bundle, `/`-separated and relative. Readers refuse absolute paths and `.` or
44
+ * `..` segments themselves; the pattern only keeps the obvious out.
45
+ */
46
+ const bundlePath = z.string().min(1).regex(/^[^/\0]/);
47
+ /** The platform schema. */
48
+ const BundlePlatformSchema = z.enum(BUNDLE_PLATFORMS).register(wireRegistry, { id: "BundlePlatform" });
49
+ /** The file entry schema. */
50
+ const BundleFileEntry = z.object({
51
+ path: bundlePath,
52
+ size: z.int().min(0),
53
+ sha256,
54
+ executable: z.boolean()
55
+ }).register(wireRegistry, { id: "BundleFileEntry" });
56
+ /** The link entry schema. */
57
+ const BundleLinkEntry = z.object({
58
+ path: bundlePath,
59
+ target: z.string().min(1)
60
+ }).register(wireRegistry, { id: "BundleLinkEntry" });
61
+ /** The `files.json` schema. */
62
+ const BundleFiles = z.object({
63
+ schemaVersion: z.literal(1),
64
+ files: z.array(BundleFileEntry),
65
+ links: z.array(BundleLinkEntry)
66
+ }).register(wireRegistry, { id: "BundleFiles" });
67
+ /** The browser pin schema. */
68
+ const BundleBrowser = z.object({
69
+ name: z.literal("chromium-headless-shell"),
70
+ revision: z.string().min(1),
71
+ browserVersion: z.string().min(1),
72
+ installer: bundlePath,
73
+ files: z.array(BundleFileEntry)
74
+ }).register(wireRegistry, { id: "BundleBrowser" });
75
+ /** The `bundle.json` schema. */
76
+ const BundleInfo = z.object({
77
+ schemaVersion: z.literal(1),
78
+ name: z.literal(BUNDLE_NAME),
79
+ version: z.string().min(1),
80
+ platform: BundlePlatformSchema,
81
+ node: z.object({
82
+ version: z.string().min(1),
83
+ path: bundlePath
84
+ }),
85
+ entries: z.object({
86
+ runtime: bundlePath,
87
+ cli: bundlePath,
88
+ setup: bundlePath
89
+ }),
90
+ files: z.object({
91
+ path: bundlePath,
92
+ sha256
93
+ }),
94
+ browser: BundleBrowser,
95
+ source: z.object({
96
+ repository: z.string(),
97
+ commit: z.string()
98
+ }).exactOptional()
99
+ }).register(wireRegistry, { id: "BundleInfo" });
100
+ /** The asset schema. */
101
+ const BundleAsset = z.object({
102
+ file: z.string().regex(/^mostra-[0-9A-Za-z][0-9A-Za-z.+-]*-(darwin|linux)-(arm64|x64)\.tar\.gz$/),
103
+ sha256,
104
+ size: z.int().positive(),
105
+ unpackedSize: z.int().positive()
106
+ }).register(wireRegistry, { id: "BundleAsset" });
107
+ /**
108
+ * The `bundles.json` schema. Each asset's `file` has an archive's shape (no directory); that it is
109
+ * exactly {@link bundleAssetName} of the pins' version and its platform is checked by the
110
+ * installer before any I/O, since JSON Schema can't express the comparison.
111
+ */
112
+ const BundlePins = z.object({
113
+ schemaVersion: z.literal(1),
114
+ version: z.string().regex(/^[0-9A-Za-z][0-9A-Za-z.+-]*$/),
115
+ release: z.url({ protocol: /^https?$/ }),
116
+ assets: z.partialRecord(BundlePlatformSchema, BundleAsset)
117
+ }).register(wireRegistry, { id: "BundlePins" });
118
+ /** The setup marker's schema. */
119
+ const BundleSetup = z.object({
120
+ schemaVersion: z.literal(1),
121
+ version: z.string().min(1),
122
+ platform: BundlePlatformSchema,
123
+ files: sha256,
124
+ browser: z.object({ revision: z.string().min(1) }),
125
+ at: z.string()
126
+ }).register(wireRegistry, { id: "BundleSetup" });
127
+ //#endregion
128
+ export { BUNDLE_NAME, BUNDLE_PLATFORMS, BUNDLE_SETUP_MARKER, BundleAsset, BundleBrowser, BundleFileEntry, BundleFiles, BundleInfo, BundleLinkEntry, BundlePins, BundlePlatformSchema, BundleSetup, bundleAssetName };
129
+
130
+ //# sourceMappingURL=bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.js","names":[],"sources":["../src/bundle.ts"],"sourcesContent":["/**\n * The runtime bundle's contract (RT-01, INTERFACES §16): what a host downloads, how it checks it\n * and where its entry points are. The SDK, the CLI's bootstrap and the Rust crate (WP-12) all read\n * these files, so they are wire schemas: published as JSON Schema and changed only additively.\n *\n * A release attaches one archive per platform, `mostra-<version>-<platform>.tar.gz`, whose single\n * top directory holds:\n *\n * ```text\n * bundle.json BundleInfo: identity, entry points, the digest of files.json, the browser pin\n * files.json BundleFiles: every other file and link of the archive with its SHA-256\n * node/ the official Node.js distribution for the platform\n * lib/node_modules/ Mostra's packages (cli, runtime, worker, verify, shell, sdk, warm) and theirs\n * bin/ the mostra, mostra-runtime and mostra-setup launchers\n * ```\n *\n * The verify browser isn't in the archive: setup downloads the pinned revision through the\n * bundle's own Playwright and checks every file against `BundleInfo.browser.files` (D142).\n */\nimport * as z from \"zod\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** The platforms v1 ships a bundle for (D35; Windows follows in v1.1, D120). */\nexport const BUNDLE_PLATFORMS: readonly [\"darwin-arm64\", \"darwin-x64\", \"linux-x64\", \"linux-arm64\"] =\n [\"darwin-arm64\", \"darwin-x64\", \"linux-x64\", \"linux-arm64\"];\n\n/** One platform a bundle is built for: `<os>-<arch>` as Node names them. */\nexport type BundlePlatform = (typeof BUNDLE_PLATFORMS)[number];\n\n/** The `name` every `bundle.json` carries, so a stray JSON file is never taken for one. */\nexport const BUNDLE_NAME = \"mostra-runtime-bundle\";\n\n/** The marker setup writes at a bundle's root once its files and its browser are verified. */\nexport const BUNDLE_SETUP_MARKER = \".mostra-setup.json\";\n\n/** The archive a release attaches for a version and platform. */\nexport function bundleAssetName(version: string, platform: BundlePlatform): string {\n return `mostra-${version}-${platform}.tar.gz`;\n}\n\nconst sha256: z.ZodType<string> = z\n .string()\n .regex(/^[0-9a-f]{64}$/)\n .register(wireRegistry, { id: \"Sha256\", description: \"A SHA-256 digest in lowercase hex.\" });\n\n/**\n * A path inside a bundle, `/`-separated and relative. Readers refuse absolute paths and `.` or\n * `..` segments themselves; the pattern only keeps the obvious out.\n */\nconst bundlePath: z.ZodType<string> = z\n .string()\n .min(1)\n .regex(/^[^/\\0]/);\n\n/** The platform schema. */\nexport const BundlePlatformSchema: z.ZodType<BundlePlatform> = z\n .enum(BUNDLE_PLATFORMS)\n .register(wireRegistry, { id: \"BundlePlatform\" });\n\n/** One regular file of a bundle or of its browser. */\nexport interface BundleFileEntry {\n /** Relative to the bundle's root (or to `browsers/` for the browser), `/`-separated. */\n readonly path: string;\n /** Its length in bytes. */\n readonly size: number;\n /** The SHA-256 of its bytes, lowercase hex. */\n readonly sha256: string;\n /** Whether its owner may execute it (mode 0755 rather than 0644 once extracted). */\n readonly executable: boolean;\n}\n\n/** The file entry schema. */\nexport const BundleFileEntry: z.ZodType<BundleFileEntry> = z\n .object({\n path: bundlePath,\n size: z.int().min(0),\n sha256,\n executable: z.boolean(),\n })\n .register(wireRegistry, { id: \"BundleFileEntry\" });\n\n/** One symbolic link of a bundle. Its target is relative and resolves inside the bundle. */\nexport interface BundleLinkEntry {\n /** The link itself, relative to the bundle's root. */\n readonly path: string;\n /** What the link holds, exactly as written (relative). */\n readonly target: string;\n}\n\n/** The link entry schema. */\nexport const BundleLinkEntry: z.ZodType<BundleLinkEntry> = z\n .object({ path: bundlePath, target: z.string().min(1) })\n .register(wireRegistry, { id: \"BundleLinkEntry\" });\n\n/** `files.json`: everything in the archive besides `bundle.json`, each list sorted by path. */\nexport interface BundleFiles {\n /** The format's version; 1 today. */\n readonly schemaVersion: 1;\n /** Every regular file, sorted by path. */\n readonly files: readonly BundleFileEntry[];\n /** Every symbolic link, sorted by path. */\n readonly links: readonly BundleLinkEntry[];\n}\n\n/** The `files.json` schema. */\nexport const BundleFiles: z.ZodType<BundleFiles> = z\n .object({\n schemaVersion: z.literal(1),\n files: z.array(BundleFileEntry),\n links: z.array(BundleLinkEntry),\n })\n .register(wireRegistry, { id: \"BundleFiles\" });\n\n/** The verify browser a bundle pins: fetched at setup, checked file by file (D142). */\nexport interface BundleBrowser {\n /** Playwright's name for the browser. */\n readonly name: \"chromium-headless-shell\";\n /** Playwright's revision, the directory `browsers/chromium_headless_shell-<revision>`. */\n readonly revision: string;\n /** The browser's own version, for people and diagnostics. */\n readonly browserVersion: string;\n /** The bundle's Playwright CLI, run with the bundle's Node: `install chromium-headless-shell`. */\n readonly installer: string;\n /** Every file the install leaves under `browsers/`, besides Playwright's own markers. */\n readonly files: readonly BundleFileEntry[];\n}\n\n/** The browser pin schema. */\nexport const BundleBrowser: z.ZodType<BundleBrowser> = z\n .object({\n name: z.literal(\"chromium-headless-shell\"),\n revision: z.string().min(1),\n browserVersion: z.string().min(1),\n installer: bundlePath,\n files: z.array(BundleFileEntry),\n })\n .register(wireRegistry, { id: \"BundleBrowser\" });\n\n/** `bundle.json`: a bundle's identity and entry points. */\nexport interface BundleInfo {\n /** The format's version; 1 today. */\n readonly schemaVersion: 1;\n /** Always {@link BUNDLE_NAME}, so a stray `bundle.json` isn't taken for one. */\n readonly name: typeof BUNDLE_NAME;\n /** The Mostra release: every Mostra package in the bundle has this version. */\n readonly version: string;\n /** The platform it was built on and for. */\n readonly platform: BundlePlatform;\n /** The private Node.js the bundle runs on (RT-01), and its executable. */\n readonly node: { readonly version: string; readonly path: string };\n /** Scripts each run as `<node.path> <entry> …`, paths relative to the bundle's root. */\n readonly entries: {\n /** `mostra-runtime host|daemon|service`: what a host spawns (D85). */\n readonly runtime: string;\n /** `mostra`, the CLI. */\n readonly cli: string;\n /** Verifies the bundle, fetches its browser and writes `.mostra-setup.json`. */\n readonly setup: string;\n };\n /** `files.json` and its SHA-256, which ties every other file to this one. */\n readonly files: { readonly path: string; readonly sha256: string };\n /** The verify browser setup fetches and checks (D142 item 2). */\n readonly browser: BundleBrowser;\n /** Where it was built from. */\n readonly source?: { readonly repository: string; readonly commit: string };\n}\n\n/** The `bundle.json` schema. */\nexport const BundleInfo: z.ZodType<BundleInfo> = z\n .object({\n schemaVersion: z.literal(1),\n name: z.literal(BUNDLE_NAME),\n version: z.string().min(1),\n platform: BundlePlatformSchema,\n node: z.object({ version: z.string().min(1), path: bundlePath }),\n entries: z.object({ runtime: bundlePath, cli: bundlePath, setup: bundlePath }),\n files: z.object({ path: bundlePath, sha256 }),\n browser: BundleBrowser,\n source: z.object({ repository: z.string(), commit: z.string() }).exactOptional(),\n })\n .register(wireRegistry, { id: \"BundleInfo\" });\n\n/** One platform's archive in a release. */\nexport interface BundleAsset {\n /** The file name, {@link bundleAssetName}. */\n readonly file: string;\n /** The SHA-256 of the archive's bytes, lowercase hex. */\n readonly sha256: string;\n /** Bytes of the archive. */\n readonly size: number;\n /** Bytes once extracted, before the browser: what an installer checks free space against. */\n readonly unpackedSize: number;\n}\n\n/** The asset schema. */\nexport const BundleAsset: z.ZodType<BundleAsset> = z\n .object({\n // Exactly an archive's own name, no directory: an installer joins it to its scratch directory\n // (Opus review finding 8), and `BundlePins` checks it names its release and platform.\n file: z\n .string()\n .regex(/^mostra-[0-9A-Za-z][0-9A-Za-z.+-]*-(darwin|linux)-(arm64|x64)\\.tar\\.gz$/),\n sha256,\n size: z.int().positive(),\n unpackedSize: z.int().positive(),\n })\n .register(wireRegistry, { id: \"BundleAsset\" });\n\n/**\n * `bundles.json`: one release's archives, pinned by SHA-256. The release workflow writes it into\n * `@mostra/sdk` before the package is published, so an npm install pins exactly what it fetches.\n */\nexport interface BundlePins {\n /** The format's version; 1 today. */\n readonly schemaVersion: 1;\n /** The release these archives belong to: the SDK's own version. */\n readonly version: string;\n /** The base URL the archives are under: the GitHub release's download path. */\n readonly release: string;\n /** Each platform's archive. */\n readonly assets: Partial<Record<BundlePlatform, BundleAsset>>;\n}\n\n/**\n * The `bundles.json` schema. Each asset's `file` has an archive's shape (no directory); that it is\n * exactly {@link bundleAssetName} of the pins' version and its platform is checked by the\n * installer before any I/O, since JSON Schema can't express the comparison.\n */\nexport const BundlePins: z.ZodType<BundlePins> = z\n .object({\n schemaVersion: z.literal(1),\n version: z.string().regex(/^[0-9A-Za-z][0-9A-Za-z.+-]*$/),\n release: z.url({ protocol: /^https?$/ }),\n assets: z.partialRecord(BundlePlatformSchema, BundleAsset),\n })\n .register(wireRegistry, { id: \"BundlePins\" });\n\n/** `.mostra-setup.json`: written by setup once the files and the browser are verified. */\nexport interface BundleSetup {\n /** The format's version; 1 today. */\n readonly schemaVersion: 1;\n /** The bundle's release. */\n readonly version: string;\n /** The bundle's platform. */\n readonly platform: BundlePlatform;\n /** `BundleInfo.files.sha256` of the bundle it describes. */\n readonly files: string;\n /** The browser revision setup fetched and checked. */\n readonly browser: { readonly revision: string };\n /** When setup finished (RFC 3339). */\n readonly at: string;\n}\n\n/** The setup marker's schema. */\nexport const BundleSetup: z.ZodType<BundleSetup> = z\n .object({\n schemaVersion: z.literal(1),\n version: z.string().min(1),\n platform: BundlePlatformSchema,\n files: sha256,\n browser: z.object({ revision: z.string().min(1) }),\n at: z.string(),\n })\n .register(wireRegistry, { id: \"BundleSetup\" });\n"],"mappings":"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"}
@@ -0,0 +1,23 @@
1
+ //#region src/canonical.d.ts
2
+ /**
3
+ * Canonical JSON (RFC 8785, the JSON Canonicalization Scheme): one exact text for a JSON value,
4
+ * so equal values hash equally wherever they are hashed. A submission's digest is the SHA-256 of
5
+ * its stored snapshot in this form (DATA_MODEL §3). The snapshot stays in the ledger; results carry
6
+ * the digest as the snapshot's identity, so two results with the same digest hold the same answers.
7
+ *
8
+ * ```ts
9
+ * canonicalJson({ b: [1, "x"], a: null }); // '{"a":null,"b":[1,"x"]}'
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 declare function canonicalJson(value: unknown): string;
22
+ //#endregion
23
+ //# sourceMappingURL=canonical.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.d.ts","names":[],"sources":["../src/canonical.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;wBAoBgB,cAAc"}
@@ -0,0 +1,45 @@
1
+ //#region src/canonical.ts
2
+ /**
3
+ * Canonical JSON (RFC 8785, the JSON Canonicalization Scheme): one exact text for a JSON value,
4
+ * so equal values hash equally wherever they are hashed. A submission's digest is the SHA-256 of
5
+ * its stored snapshot in this form (DATA_MODEL §3). The snapshot stays in the ledger; results carry
6
+ * the digest as the snapshot's identity, so two results with the same digest hold the same answers.
7
+ *
8
+ * ```ts
9
+ * canonicalJson({ b: [1, "x"], a: null }); // '{"a":null,"b":[1,"x"]}'
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
+ function canonicalJson(value) {
22
+ switch (typeof value) {
23
+ case "string": return canonicalString(value);
24
+ case "number":
25
+ if (!Number.isFinite(value)) throw new TypeError("JSON numbers must be finite.");
26
+ return JSON.stringify(value);
27
+ case "boolean": return value ? "true" : "false";
28
+ case "object": {
29
+ if (value === null) return "null";
30
+ if (Array.isArray(value)) return `[${value.map((item) => canonicalJson(item)).join(",")}]`;
31
+ const entries = Object.entries(value).filter(([, item]) => item !== void 0);
32
+ entries.sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
33
+ return `{${entries.map(([key, item]) => `${canonicalString(key)}:${canonicalJson(item)}`).join(",")}}`;
34
+ }
35
+ default: throw new TypeError(`A ${typeof value} has no JSON form.`);
36
+ }
37
+ }
38
+ function canonicalString(text) {
39
+ if (!text.isWellFormed()) throw new TypeError("JSON strings must be well-formed Unicode.");
40
+ return JSON.stringify(text);
41
+ }
42
+ //#endregion
43
+ export { canonicalJson };
44
+
45
+ //# sourceMappingURL=canonical.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.js","names":[],"sources":["../src/canonical.ts"],"sourcesContent":["/**\n * Canonical JSON (RFC 8785, the JSON Canonicalization Scheme): one exact text for a JSON value,\n * so equal values hash equally wherever they are hashed. A submission's digest is the SHA-256 of\n * its stored snapshot in this form (DATA_MODEL §3). The snapshot stays in the ledger; results carry\n * the digest as the snapshot's identity, so two results with the same digest hold the same answers.\n *\n * ```ts\n * canonicalJson({ b: [1, \"x\"], a: null }); // '{\"a\":null,\"b\":[1,\"x\"]}'\n * ```\n */\n\n/**\n * The canonical JSON text of `value` (RFC 8785 §3.2): no whitespace; strings, numbers and\n * literals as ECMAScript's `JSON.stringify` writes them; object properties sorted by their UTF-16\n * code units at every depth; array order kept. Properties whose value is `undefined` are left out,\n * as `JSON.stringify` does.\n *\n * @throws TypeError for anything I-JSON can't hold: a non-finite number, a lone surrogate, a\n * bigint, a function or symbol, or an `undefined` outside an object.\n */\nexport function canonicalJson(value: unknown): string {\n switch (typeof value) {\n case \"string\":\n return canonicalString(value);\n case \"number\":\n if (!Number.isFinite(value)) throw new TypeError(\"JSON numbers must be finite.\");\n return JSON.stringify(value);\n case \"boolean\":\n return value ? \"true\" : \"false\";\n case \"object\": {\n if (value === null) return \"null\";\n if (Array.isArray(value)) return `[${value.map((item) => canonicalJson(item)).join(\",\")}]`;\n const entries = Object.entries(value as Record<string, unknown>).filter(\n ([, item]) => item !== undefined,\n );\n // The default sort compares UTF-16 code units, which is RFC 8785's order.\n entries.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));\n return `{${entries.map(([key, item]) => `${canonicalString(key)}:${canonicalJson(item)}`).join(\",\")}}`;\n }\n default:\n throw new TypeError(`A ${typeof value} has no JSON form.`);\n }\n}\n\nfunction canonicalString(text: string): string {\n // RFC 8785 §3.2.2.2: invalid Unicode (a lone surrogate) must fail rather than be escaped.\n if (!text.isWellFormed()) throw new TypeError(\"JSON strings must be well-formed Unicode.\");\n return JSON.stringify(text);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,cAAc,OAAwB;CACpD,QAAQ,OAAO,OAAf;EACE,KAAK,UACH,OAAO,gBAAgB,KAAK;EAC9B,KAAK;GACH,IAAI,CAAC,OAAO,SAAS,KAAK,GAAG,MAAM,IAAI,UAAU,8BAA8B;GAC/E,OAAO,KAAK,UAAU,KAAK;EAC7B,KAAK,WACH,OAAO,QAAQ,SAAS;EAC1B,KAAK,UAAU;GACb,IAAI,UAAU,MAAM,OAAO;GAC3B,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,IAAI,MAAM,KAAK,SAAS,cAAc,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;GACxF,MAAM,UAAU,OAAO,QAAQ,KAAgC,CAAC,CAAC,QAC9D,GAAG,UAAU,SAAS,KAAA,CACzB;GAEA,QAAQ,MAAM,CAAC,IAAI,CAAC,OAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAE;GACvD,OAAO,IAAI,QAAQ,KAAK,CAAC,KAAK,UAAU,GAAG,gBAAgB,GAAG,EAAE,GAAG,cAAc,IAAI,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;EACtG;EACA,SACE,MAAM,IAAI,UAAU,KAAK,OAAO,MAAM,mBAAmB;CAC7D;AACF;AAEA,SAAS,gBAAgB,MAAsB;CAE7C,IAAI,CAAC,KAAK,aAAa,GAAG,MAAM,IAAI,UAAU,2CAA2C;CACzF,OAAO,KAAK,UAAU,IAAI;AAC5B"}
@@ -0,0 +1,38 @@
1
+ import * as z from "zod";
2
+ //#region src/capability.d.ts
3
+ /**
4
+ * What a capability token allows (HY-03, D97):
5
+ * - `view`: open the artifact; every token has it.
6
+ * - `draft`: save answers and other field values.
7
+ * - `submit`: submit.
8
+ * - `review`: comment and choose.
9
+ * - `signal`: raise a signal for the host's attention (D10), which a waiting agent may act on.
10
+ * - `action:*`: run every server function; `action:<export>` runs that export of any
11
+ * `"use server"` module; `action:<module path>#<export>` runs one function ID.
12
+ */
13
+ export type CapabilityScope = "view" | "draft" | "submit" | "review" | "signal" | `action:${string}`;
14
+ /** The Zod schema of the `CapabilityScope` type. */
15
+ export declare const CapabilityScope: z.ZodType<CapabilityScope>;
16
+ /** Every scope at once: what a link minted without `scopes`, and every default link, carries. */
17
+ export declare const ALL_SCOPES: readonly CapabilityScope[];
18
+ /**
19
+ * A duration: a positive whole number and a unit, `s`, `m`, `h` or `d` (`30m`, `24h`, `7d`), as
20
+ * INTERFACES §1 writes durations in flags and manifests.
21
+ */
22
+ export type Duration = `${number}${"s" | "m" | "h" | "d"}`;
23
+ /** The Zod schema of the `Duration` type. */
24
+ export declare const Duration: z.ZodType<Duration>;
25
+ /** The length of a `Duration` in milliseconds. */
26
+ export declare function durationMs(duration: Duration): number;
27
+ /**
28
+ * The scopes a token holds after normalization: `view` added, duplicates removed, sorted, so equal
29
+ * grants compare equal.
30
+ */
31
+ export declare function normalizeScopes(scopes: readonly CapabilityScope[]): CapabilityScope[];
32
+ /**
33
+ * Whether `scopes` grant `required`. A plain scope must be held as written. An action scope
34
+ * `action:<module path>#<export>` is granted by `action:*`, by `action:<export>` and by itself.
35
+ */
36
+ export declare function scopeAllows(scopes: readonly CapabilityScope[], required: CapabilityScope): boolean;
37
+ //#endregion
38
+ //# sourceMappingURL=capability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability.d.ts","names":[],"sources":["../src/capability.ts"],"mappings":";;;;;;;;;;;;YAkBY;;qBASC,iBAAiB,EAAE,QAAQ;;qBAU3B,qBAAqB;;;;;YAatB;;qBAGC,UAAU,EAAE,QAAQ;;wBAWjB,WAAW,UAAU;;;;;wBASrB,gBAAgB,iBAAiB,oBAAoB;;;;;wBAQrD,YACd,iBAAiB,mBACjB,UAAU"}