@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
package/dist/bridge.js ADDED
@@ -0,0 +1,343 @@
1
+ import { JSON_RPC_ERROR_CODES, RpcError, hostDiagnostic } from "./rpc/error.js";
2
+ import { classifyMessage } from "./rpc/messages.js";
3
+ import { RpcPeer } from "./rpc/peer.js";
4
+ import { REVIEW_SET_ID_PATTERN, ViewContextWire } from "./view.js";
5
+ import * as z from "zod";
6
+ //#region src/bridge.ts
7
+ /**
8
+ * The shell ↔ artifact bridge (INTERFACES §5, ROUND-3 §8, SH-04): JSON-RPC 2.0 over
9
+ * `postMessage`, shaped like MCP Apps so exporting an artifact as an MCP App only swaps the
10
+ * transport. Both ends accept a message only when it comes from the one window they talk to, at
11
+ * its exact origin, and only when it is a message of the bridge's set with valid params; anything
12
+ * else is dropped (or, for a request from the right window, answered with an error). It has no
13
+ * I/O of its own: the caller hands it the window objects.
14
+ *
15
+ * ```ts
16
+ * // In the shell:
17
+ * const bridge = connectBridge({
18
+ * side: "shell",
19
+ * receiver: window,
20
+ * peer: () => frame.contentWindow,
21
+ * peerOrigin: "http://127.0.0.1:23457",
22
+ * onRequest: (message, params) => (message === uiInitialize ? initializeResult : undefined),
23
+ * });
24
+ * ```
25
+ */
26
+ /** The version of MCP Apps whose message shapes the bridge follows (VERIFIED_FACTS, MCP). */
27
+ const MCP_APPS_PROTOCOL_VERSION = "2026-01-26";
28
+ const Implementation = z.looseObject({
29
+ name: z.string(),
30
+ version: z.string(),
31
+ title: z.string().exactOptional()
32
+ });
33
+ /** `ui/initialize`: the artifact's first request, answered with the shell's context. */
34
+ const uiInitialize = {
35
+ method: "ui/initialize",
36
+ from: "artifact",
37
+ kind: "request",
38
+ params: z.looseObject({
39
+ appInfo: Implementation,
40
+ appCapabilities: z.record(z.string(), z.unknown()),
41
+ protocolVersion: z.string().min(1),
42
+ mostra: z.looseObject({ versionId: z.string().min(1).max(64) }).exactOptional()
43
+ }),
44
+ result: z.looseObject({
45
+ protocolVersion: z.string().min(1),
46
+ hostInfo: Implementation,
47
+ hostCapabilities: z.record(z.string(), z.unknown()),
48
+ hostContext: z.looseObject({
49
+ theme: z.enum(["light", "dark"]).exactOptional(),
50
+ displayMode: z.enum([
51
+ "inline",
52
+ "fullscreen",
53
+ "pip"
54
+ ]).exactOptional(),
55
+ availableDisplayModes: z.array(z.string()).readonly().exactOptional(),
56
+ locale: z.string().exactOptional(),
57
+ timeZone: z.string().exactOptional(),
58
+ platform: z.enum([
59
+ "web",
60
+ "desktop",
61
+ "mobile"
62
+ ]).exactOptional()
63
+ }),
64
+ mostra: ViewContextWire.exactOptional()
65
+ })
66
+ };
67
+ /** `ui/notifications/initialized`: the artifact finished initializing; the shell may now send. */
68
+ const uiInitialized = {
69
+ method: "ui/notifications/initialized",
70
+ from: "artifact",
71
+ kind: "notification",
72
+ params: z.record(z.string(), z.unknown()),
73
+ result: z.undefined()
74
+ };
75
+ /** `ui/notifications/size-changed`: the artifact's rendered size (MCP Apps). */
76
+ const uiSizeChanged = {
77
+ method: "ui/notifications/size-changed",
78
+ from: "artifact",
79
+ kind: "notification",
80
+ params: z.looseObject({
81
+ width: z.number().min(0).exactOptional(),
82
+ height: z.number().min(0).exactOptional()
83
+ }),
84
+ result: z.undefined()
85
+ };
86
+ /**
87
+ * The URL schemes `ui/open-link` opens: the web, mail and phone numbers. Anything else, such as
88
+ * `javascript:` or `data:`, would run or show content in the shell's own context.
89
+ */
90
+ const OPEN_LINK_SCHEMES = [
91
+ "http:",
92
+ "https:",
93
+ "mailto:",
94
+ "tel:"
95
+ ];
96
+ /**
97
+ * `ui/open-link`: the artifact asks the shell to open a URL in a new tab (MCP Apps). The frame
98
+ * can't navigate the viewer's tab itself (D98 item 7), so this is how an artifact sends the
99
+ * viewer anywhere. `isError` is `true` when the shell couldn't open it.
100
+ */
101
+ const uiOpenLink = {
102
+ method: "ui/open-link",
103
+ from: "artifact",
104
+ kind: "request",
105
+ params: z.looseObject({ url: z.string().min(1).max(8192) }),
106
+ result: z.looseObject({ isError: z.boolean().exactOptional() })
107
+ };
108
+ /** `mostra/ready`: the artifact's page has rendered; `verify` waits for it (ROUND-3 §8). */
109
+ const mostraReady = {
110
+ method: "mostra/ready",
111
+ from: "artifact",
112
+ kind: "notification",
113
+ params: z.record(z.string(), z.unknown()),
114
+ result: z.undefined()
115
+ };
116
+ /**
117
+ * The longest label, validation message or other text a field carries over the bridge; a page
118
+ * shortens longer ones before it sends them (Claude review finding 11).
119
+ */
120
+ const BRIDGE_TEXT_MAX = 1024;
121
+ /** The most fields or blockers one bridge message lists; a page sends those that matter first. */
122
+ const BRIDGE_FIELDS_MAX = 1e4;
123
+ const SubmitBlockerSchema = z.looseObject({
124
+ fieldId: z.string().min(1).max(256),
125
+ label: z.string().max(BRIDGE_TEXT_MAX).exactOptional(),
126
+ reason: z.enum([
127
+ "required",
128
+ "invalid",
129
+ "conflict"
130
+ ])
131
+ });
132
+ /**
133
+ * `mostra/fields`: the page's mounted fields and save state, sent whenever they change, so the
134
+ * shell lists blockers by label and its rail shows "Saving" and "Saved" (INTERFACES §5).
135
+ */
136
+ const mostraFields = {
137
+ method: "mostra/fields",
138
+ from: "artifact",
139
+ kind: "notification",
140
+ params: z.looseObject({
141
+ fields: z.array(z.looseObject({
142
+ id: z.string().min(1).max(256),
143
+ label: z.string().max(BRIDGE_TEXT_MAX).exactOptional(),
144
+ required: z.boolean().exactOptional(),
145
+ scope: z.enum(["viewer", "artifact"]),
146
+ sensitive: z.boolean().exactOptional(),
147
+ error: z.string().max(BRIDGE_TEXT_MAX).exactOptional(),
148
+ conflict: z.boolean().exactOptional()
149
+ })).max(BRIDGE_FIELDS_MAX).readonly(),
150
+ save: z.enum([
151
+ "saved",
152
+ "saving",
153
+ "offline",
154
+ "conflict"
155
+ ]),
156
+ unsaved: z.boolean()
157
+ }),
158
+ result: z.undefined()
159
+ };
160
+ /**
161
+ * `mostra/page`: the page the viewer is on, inside a `pages/` artifact (D57), so comments record
162
+ * it (WP-20). `path` is the route's path with its search and hash, whatever the history mode.
163
+ */
164
+ const mostraPage = {
165
+ method: "mostra/page",
166
+ from: "artifact",
167
+ kind: "notification",
168
+ params: z.looseObject({
169
+ path: z.string().min(1).max(2048),
170
+ title: z.string().max(1024).exactOptional()
171
+ }),
172
+ result: z.undefined()
173
+ };
174
+ /** The longest Submit label the shell renders: one short line. */
175
+ const CONTROL_LABEL_MAX = 48;
176
+ /**
177
+ * `mostra/controls.request`: the artifact asks the shell for a trusted control (D06, SH-02). The
178
+ * shell renders it in its own origin, where the artifact can neither click nor reach it, and
179
+ * answers whether it is shown: a control the host's policy leaves out is not (D108).
180
+ */
181
+ const mostraControlsRequest = {
182
+ method: "mostra/controls.request",
183
+ from: "artifact",
184
+ kind: "request",
185
+ params: z.discriminatedUnion("control", [
186
+ z.looseObject({
187
+ control: z.literal("submit"),
188
+ label: z.string().min(1).max(48).exactOptional(),
189
+ confirm: z.string().min(1).max(500).exactOptional()
190
+ }),
191
+ z.looseObject({
192
+ control: z.literal("choose"),
193
+ reviewSetId: z.string().regex(REVIEW_SET_ID_PATTERN),
194
+ candidates: z.array(z.looseObject({
195
+ id: z.string().min(1).max(256),
196
+ label: z.string().max(48).exactOptional()
197
+ })).min(1).max(64).readonly(),
198
+ current: z.string().min(1).max(256).exactOptional()
199
+ }),
200
+ z.looseObject({
201
+ control: z.literal("release"),
202
+ submit: z.literal(true).exactOptional(),
203
+ reviewSetId: z.string().regex(REVIEW_SET_ID_PATTERN).exactOptional()
204
+ })
205
+ ]),
206
+ result: z.looseObject({ shown: z.boolean() })
207
+ };
208
+ /**
209
+ * `mostra/flush`: the shell asks the page to save everything now, before its trusted Submit or a
210
+ * switch to a newer version (IN-02, D110). For a submit, the page first writes the defaults the
211
+ * viewer saw. The shell checks the answer against the draft it reads itself.
212
+ */
213
+ const mostraFlush = {
214
+ method: "mostra/flush",
215
+ from: "shell",
216
+ kind: "request",
217
+ params: z.looseObject({ reason: z.enum(["submit", "switch"]) }),
218
+ result: z.looseObject({
219
+ revision: z.string().regex(/^(0|[1-9][0-9]{0,15})$/),
220
+ unsaved: z.boolean(),
221
+ blockers: z.array(SubmitBlockerSchema).max(BRIDGE_FIELDS_MAX).readonly()
222
+ })
223
+ };
224
+ /**
225
+ * `mostra/version.available`: a newer version was published while the page is open (VR-04). The
226
+ * shell always shows its own trusted banner; the page may show a notice too.
227
+ */
228
+ const mostraVersionAvailable = {
229
+ method: "mostra/version.available",
230
+ from: "shell",
231
+ kind: "notification",
232
+ params: z.looseObject({
233
+ versionId: z.string().min(1),
234
+ version: z.int().min(1),
235
+ orphans: z.int().min(0)
236
+ }),
237
+ result: z.undefined()
238
+ };
239
+ /** `mostra/field.focus`: the viewer picked a blocker in the shell; the page focuses that field. */
240
+ const mostraFieldFocus = {
241
+ method: "mostra/field.focus",
242
+ from: "shell",
243
+ kind: "notification",
244
+ params: z.looseObject({ id: z.string().min(1).max(256) }),
245
+ result: z.undefined()
246
+ };
247
+ /**
248
+ * Every message of the bridge in this release. WP-20 adds review messages; a message never
249
+ * changes meaning once released (D32).
250
+ */
251
+ const BRIDGE_MESSAGES = [
252
+ uiInitialize,
253
+ uiInitialized,
254
+ uiSizeChanged,
255
+ uiOpenLink,
256
+ mostraReady,
257
+ mostraFields,
258
+ mostraPage,
259
+ mostraControlsRequest,
260
+ mostraFlush,
261
+ mostraVersionAvailable,
262
+ mostraFieldFocus
263
+ ];
264
+ const asMethod = (message) => ({
265
+ method: message.method,
266
+ direction: "client-to-instance",
267
+ mutating: false,
268
+ params: message.params,
269
+ result: message.result
270
+ });
271
+ /**
272
+ * Connects one end of the bridge. Every incoming message must come from `peer()` at exactly
273
+ * `peerOrigin`, be a JSON-RPC message, name a message the other side sends, and carry valid params.
274
+ */
275
+ function connectBridge(options) {
276
+ const known = new Map(BRIDGE_MESSAGES.map((message) => [message.method, message]));
277
+ const send = (message) => {
278
+ const peer = options.peer();
279
+ if (!peer) throw new Error("The bridge's peer window is gone.");
280
+ peer.postMessage(message, options.peerOrigin);
281
+ };
282
+ const rpc = new RpcPeer({
283
+ send,
284
+ onRequest: (method, params) => {
285
+ const message = known.get(method);
286
+ if (!message || message.from === options.side || message.kind !== "request") throw new RpcError(hostDiagnostic("MOSTRA_HOST_METHOD_UNKNOWN", { message: `The bridge has no request ${method} for this side.` }), JSON_RPC_ERROR_CODES.methodNotFound);
287
+ if (!options.onRequest) throw new RpcError(hostDiagnostic("MOSTRA_HOST_METHOD_UNKNOWN", { message: `This side doesn't answer ${method}.` }), JSON_RPC_ERROR_CODES.methodNotFound);
288
+ const parsed = message.params.safeParse(params ?? {});
289
+ if (!parsed.success) throw new RpcError(hostDiagnostic("MOSTRA_HOST_INVALID_PARAMS", { message: `Invalid params for ${method}.` }), JSON_RPC_ERROR_CODES.invalidParams);
290
+ return options.onRequest(message, parsed.data);
291
+ },
292
+ onNotification: (method, params) => {
293
+ const message = known.get(method);
294
+ if (message?.kind !== "notification" || message.from === options.side) return;
295
+ const parsed = message.params.safeParse(params ?? {});
296
+ if (parsed.success) options.onNotification?.(message, parsed.data);
297
+ }
298
+ });
299
+ /** Why an incoming message must be dropped, or `undefined` when the RPC peer may take it. */
300
+ const screen = (event) => {
301
+ const peer = options.peer();
302
+ if (!peer || event.source !== peer) return "wrong-source";
303
+ if (event.origin !== options.peerOrigin) return "wrong-origin";
304
+ const classified = classifyMessage(event.data);
305
+ if (classified.kind === "invalid") return "not-json-rpc";
306
+ if (classified.kind !== "request" && classified.kind !== "notification") return void 0;
307
+ const message = known.get(classified.message.method);
308
+ if (!message) return "unknown-method";
309
+ if (message.from === options.side) return "wrong-direction";
310
+ if (!message.params.safeParse(classified.message.params ?? {}).success) return "invalid-params";
311
+ };
312
+ const listener = (event) => {
313
+ const rejection = screen(event);
314
+ if (rejection !== void 0) {
315
+ options.onRejected?.(rejection, event);
316
+ if (!(rejection !== "wrong-source" && rejection !== "wrong-origin" && rejection !== "not-json-rpc" && classifyMessage(event.data).kind === "request")) return;
317
+ }
318
+ rpc.receive(event.data);
319
+ };
320
+ options.receiver.addEventListener("message", listener);
321
+ const sendable = (message) => {
322
+ if (message.from !== options.side) throw new Error(`The ${options.side} doesn't send ${message.method}.`);
323
+ };
324
+ return {
325
+ call(message, params, callOptions) {
326
+ sendable(message);
327
+ return rpc.call(asMethod(message), params, callOptions ?? {});
328
+ },
329
+ notify(message, params) {
330
+ sendable(message);
331
+ const parsed = message.params.parse(params);
332
+ rpc.notify(message.method, parsed);
333
+ },
334
+ close() {
335
+ options.receiver.removeEventListener("message", listener);
336
+ rpc.close();
337
+ }
338
+ };
339
+ }
340
+ //#endregion
341
+ export { BRIDGE_FIELDS_MAX, BRIDGE_MESSAGES, BRIDGE_TEXT_MAX, CONTROL_LABEL_MAX, MCP_APPS_PROTOCOL_VERSION, OPEN_LINK_SCHEMES, connectBridge, mostraControlsRequest, mostraFieldFocus, mostraFields, mostraFlush, mostraPage, mostraReady, mostraVersionAvailable, uiInitialize, uiInitialized, uiOpenLink, uiSizeChanged };
342
+
343
+ //# sourceMappingURL=bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.js","names":[],"sources":["../src/bridge.ts"],"sourcesContent":["/**\n * The shell ↔ artifact bridge (INTERFACES §5, ROUND-3 §8, SH-04): JSON-RPC 2.0 over\n * `postMessage`, shaped like MCP Apps so exporting an artifact as an MCP App only swaps the\n * transport. Both ends accept a message only when it comes from the one window they talk to, at\n * its exact origin, and only when it is a message of the bridge's set with valid params; anything\n * else is dropped (or, for a request from the right window, answered with an error). It has no\n * I/O of its own: the caller hands it the window objects.\n *\n * ```ts\n * // In the shell:\n * const bridge = connectBridge({\n * side: \"shell\",\n * receiver: window,\n * peer: () => frame.contentWindow,\n * peerOrigin: \"http://127.0.0.1:23457\",\n * onRequest: (message, params) => (message === uiInitialize ? initializeResult : undefined),\n * });\n * ```\n */\nimport * as z from \"zod\";\nimport type { MethodDefinition } from \"./method.ts\";\nimport { hostDiagnostic, JSON_RPC_ERROR_CODES, RpcError } from \"./rpc/error.ts\";\nimport { classifyMessage } from \"./rpc/messages.ts\";\nimport { RpcPeer } from \"./rpc/peer.ts\";\nimport { REVIEW_SET_ID_PATTERN, ViewContextWire } from \"./view.ts\";\n\n/** Which end of the bridge: the trusted shell, or the artifact's frame. */\nexport type BridgeSide = \"shell\" | \"artifact\";\n\n/** One message of the bridge's set. */\nexport interface BridgeMessage<P, R> {\n /** The JSON-RPC method name; MCP Apps' name where the concept exists. */\n readonly method: string;\n /** The side that sends it. */\n readonly from: BridgeSide;\n /** A request is answered; a notification isn't. */\n readonly kind: \"request\" | \"notification\";\n /** The schema of its params. */\n readonly params: z.ZodType<P>;\n /** The schema of a request's result (`z.undefined()` for notifications). */\n readonly result: z.ZodType<R>;\n}\n\n/** A bridge message of any params and result type. */\nexport type AnyBridgeMessage = BridgeMessage<unknown, unknown>;\n\n/** The version of MCP Apps whose message shapes the bridge follows (VERIFIED_FACTS, MCP). */\nexport const MCP_APPS_PROTOCOL_VERSION = \"2026-01-26\";\n\n/** An application's name and version (MCP's `Implementation`). */\nexport interface BridgeImplementation {\n /** A stable machine name, such as `mostra-shell`. */\n readonly name: string;\n /** Its release. */\n readonly version: string;\n /** A name for people. */\n readonly title?: string;\n}\n\nconst Implementation: z.ZodType<BridgeImplementation> = z.looseObject({\n name: z.string(),\n version: z.string(),\n title: z.string().exactOptional(),\n});\n\n/** The params of `ui/initialize`: the artifact introduces itself (MCP Apps). */\nexport interface UiInitializeParams {\n /** The artifact's client runtime. */\n readonly appInfo: BridgeImplementation;\n /** What the artifact offers (MCP Apps' `McpUiAppCapabilities`). */\n readonly appCapabilities: Readonly<Record<string, unknown>>;\n /** The MCP Apps revision the artifact speaks, {@link MCP_APPS_PROTOCOL_VERSION}. */\n readonly protocolVersion: string;\n /**\n * What the page is (WP-07): the version whose build the frame loaded. An artifact origin serves\n * the version its frame session last entered (D98 item 5), so a frame reloaded after another\n * tab switched versions may hold another version than its view; the shell re-enters its own.\n */\n readonly mostra?: { readonly versionId: string };\n}\n\n/** What the shell tells the artifact about where it is shown (MCP Apps' `HostContext`). */\nexport interface BridgeHostContext {\n /** The viewer's color scheme. */\n readonly theme?: \"light\" | \"dark\";\n /** How the artifact is shown: the shell shows it `fullscreen`. */\n readonly displayMode?: \"inline\" | \"fullscreen\" | \"pip\";\n /** The display modes the shell offers. */\n readonly availableDisplayModes?: readonly string[];\n /** The viewer's language (BCP 47). */\n readonly locale?: string;\n /** The viewer's time zone (IANA). */\n readonly timeZone?: string;\n /** The kind of device. */\n readonly platform?: \"web\" | \"desktop\" | \"mobile\";\n /** Further MCP Apps context, passed through. */\n readonly [key: string]: unknown;\n}\n\n/** The result of `ui/initialize`: the shell introduces itself (MCP Apps). */\nexport interface UiInitializeResult {\n /** The MCP Apps revision both ends speak. */\n readonly protocolVersion: string;\n /** The shell. */\n readonly hostInfo: BridgeImplementation;\n /** What the shell offers (MCP Apps' `McpUiHostCapabilities`). */\n readonly hostCapabilities: Readonly<Record<string, unknown>>;\n /** Where and how the artifact is shown. */\n readonly hostContext: BridgeHostContext;\n /** Mostra's shell: the view this frame load is, and what the host allows in it (WP-07). */\n readonly mostra?: ViewContextWire;\n}\n\n/** `ui/initialize`: the artifact's first request, answered with the shell's context. */\nexport const uiInitialize: BridgeMessage<UiInitializeParams, UiInitializeResult> = {\n method: \"ui/initialize\",\n from: \"artifact\",\n kind: \"request\",\n params: z.looseObject({\n appInfo: Implementation,\n appCapabilities: z.record(z.string(), z.unknown()),\n protocolVersion: z.string().min(1),\n mostra: z.looseObject({ versionId: z.string().min(1).max(64) }).exactOptional(),\n }),\n result: z.looseObject({\n protocolVersion: z.string().min(1),\n hostInfo: Implementation,\n hostCapabilities: z.record(z.string(), z.unknown()),\n hostContext: z.looseObject({\n theme: z.enum([\"light\", \"dark\"]).exactOptional(),\n displayMode: z.enum([\"inline\", \"fullscreen\", \"pip\"]).exactOptional(),\n availableDisplayModes: z.array(z.string()).readonly().exactOptional(),\n locale: z.string().exactOptional(),\n timeZone: z.string().exactOptional(),\n platform: z.enum([\"web\", \"desktop\", \"mobile\"]).exactOptional(),\n }),\n mostra: ViewContextWire.exactOptional(),\n }),\n};\n\n/** `ui/notifications/initialized`: the artifact finished initializing; the shell may now send. */\nexport const uiInitialized: BridgeMessage<Readonly<Record<string, unknown>>, undefined> = {\n method: \"ui/notifications/initialized\",\n from: \"artifact\",\n kind: \"notification\",\n params: z.record(z.string(), z.unknown()),\n result: z.undefined(),\n};\n\n/** `ui/notifications/size-changed`: the artifact's rendered size (MCP Apps). */\nexport const uiSizeChanged: BridgeMessage<\n { readonly width?: number; readonly height?: number },\n undefined\n> = {\n method: \"ui/notifications/size-changed\",\n from: \"artifact\",\n kind: \"notification\",\n params: z.looseObject({\n width: z.number().min(0).exactOptional(),\n height: z.number().min(0).exactOptional(),\n }),\n result: z.undefined(),\n};\n\n/**\n * The URL schemes `ui/open-link` opens: the web, mail and phone numbers. Anything else, such as\n * `javascript:` or `data:`, would run or show content in the shell's own context.\n */\nexport const OPEN_LINK_SCHEMES: readonly string[] = [\"http:\", \"https:\", \"mailto:\", \"tel:\"];\n\n/**\n * `ui/open-link`: the artifact asks the shell to open a URL in a new tab (MCP Apps). The frame\n * can't navigate the viewer's tab itself (D98 item 7), so this is how an artifact sends the\n * viewer anywhere. `isError` is `true` when the shell couldn't open it.\n */\nexport const uiOpenLink: BridgeMessage<\n { readonly url: string },\n { readonly isError?: boolean; readonly [key: string]: unknown }\n> = {\n method: \"ui/open-link\",\n from: \"artifact\",\n kind: \"request\",\n params: z.looseObject({ url: z.string().min(1).max(8192) }),\n result: z.looseObject({ isError: z.boolean().exactOptional() }),\n};\n\n/** `mostra/ready`: the artifact's page has rendered; `verify` waits for it (ROUND-3 §8). */\nexport const mostraReady: BridgeMessage<Readonly<Record<string, unknown>>, undefined> = {\n method: \"mostra/ready\",\n from: \"artifact\",\n kind: \"notification\",\n params: z.record(z.string(), z.unknown()),\n result: z.undefined(),\n};\n\n// ── Fields, pages, controls and versions (WP-07, INTERFACES §5, ROUND-3 §8) ──────────────\n\n/** The page's save state, as the shell's rail shows it (D47). */\nexport type SaveState = \"saved\" | \"saving\" | \"offline\" | \"conflict\";\n\n/** Why a field blocks a submit (INTERFACES §2.3). */\nexport interface SubmitBlocker {\n /** The field's ID. */\n readonly fieldId: string;\n /** Its label, when it has one. */\n readonly label?: string;\n /** `required` without a value, `invalid` by its `validate`, or a `conflict` not yet resolved. */\n readonly reason: \"required\" | \"invalid\" | \"conflict\";\n}\n\n/**\n * The longest label, validation message or other text a field carries over the bridge; a page\n * shortens longer ones before it sends them (Claude review finding 11).\n */\nexport const BRIDGE_TEXT_MAX = 1024;\n\n/** The most fields or blockers one bridge message lists; a page sends those that matter first. */\nexport const BRIDGE_FIELDS_MAX = 10_000;\n\nconst SubmitBlockerSchema: z.ZodType<SubmitBlocker> = z.looseObject({\n fieldId: z.string().min(1).max(256),\n label: z.string().max(BRIDGE_TEXT_MAX).exactOptional(),\n reason: z.enum([\"required\", \"invalid\", \"conflict\"]),\n});\n\n/**\n * A field the page has mounted, with what the shell needs to list blockers by label (D52, D106).\n * The page reports it; the shell checks `required` against the draft it reads itself.\n */\nexport interface FieldRegistration {\n /** The field's ID. */\n readonly id: string;\n /** The label people see. */\n readonly label?: string;\n /** Whether a submit needs a value. */\n readonly required?: boolean;\n /** The viewer's draft or the artifact's shared state. */\n readonly scope: \"viewer\" | \"artifact\";\n /** Whether its value is kept out of events and logs. */\n readonly sensitive?: boolean;\n /** Its `validate` message for the current value, if any. */\n readonly error?: string;\n /** Whether it has a conflict the viewer hasn't resolved. */\n readonly conflict?: boolean;\n}\n\n/** The params of `mostra/fields`. */\nexport interface FieldsParams {\n /** Every mounted field, once per ID. */\n readonly fields: readonly FieldRegistration[];\n /** The page's save state. */\n readonly save: SaveState;\n /** Whether edits are waiting to be saved (typed, offline, or in the journal). */\n readonly unsaved: boolean;\n}\n\n/**\n * `mostra/fields`: the page's mounted fields and save state, sent whenever they change, so the\n * shell lists blockers by label and its rail shows \"Saving\" and \"Saved\" (INTERFACES §5).\n */\nexport const mostraFields: BridgeMessage<FieldsParams, undefined> = {\n method: \"mostra/fields\",\n from: \"artifact\",\n kind: \"notification\",\n params: z.looseObject({\n fields: z\n .array(\n z.looseObject({\n id: z.string().min(1).max(256),\n label: z.string().max(BRIDGE_TEXT_MAX).exactOptional(),\n required: z.boolean().exactOptional(),\n scope: z.enum([\"viewer\", \"artifact\"]),\n sensitive: z.boolean().exactOptional(),\n error: z.string().max(BRIDGE_TEXT_MAX).exactOptional(),\n conflict: z.boolean().exactOptional(),\n }),\n )\n .max(BRIDGE_FIELDS_MAX)\n .readonly(),\n save: z.enum([\"saved\", \"saving\", \"offline\", \"conflict\"]),\n unsaved: z.boolean(),\n }),\n result: z.undefined(),\n};\n\n/**\n * `mostra/page`: the page the viewer is on, inside a `pages/` artifact (D57), so comments record\n * it (WP-20). `path` is the route's path with its search and hash, whatever the history mode.\n */\nexport const mostraPage: BridgeMessage<\n { readonly path: string; readonly title?: string },\n undefined\n> = {\n method: \"mostra/page\",\n from: \"artifact\",\n kind: \"notification\",\n params: z.looseObject({\n path: z.string().min(1).max(2048),\n title: z.string().max(1024).exactOptional(),\n }),\n result: z.undefined(),\n};\n\n/** A trusted control the artifact asks the shell for (INTERFACES §5): the artifact asks, the shell decides. */\nexport type ControlRequest =\n | {\n /** Relabel the shell's trusted Submit, with an optional confirmation text. */\n readonly control: \"submit\";\n readonly label?: string;\n readonly confirm?: string;\n }\n | {\n /** Render a trusted Choose for a review set's candidates (D113). */\n readonly control: \"choose\";\n readonly reviewSetId: string;\n readonly candidates: readonly { readonly id: string; readonly label?: string }[];\n /** The candidate the page shows now, which Choose names. */\n readonly current?: string;\n }\n | {\n /** Withdraw an earlier request: the Submit label, or a review set's Choose. */\n readonly control: \"release\";\n readonly submit?: true;\n readonly reviewSetId?: string;\n };\n\n/** The longest Submit label the shell renders: one short line. */\nexport const CONTROL_LABEL_MAX = 48;\n\n/**\n * `mostra/controls.request`: the artifact asks the shell for a trusted control (D06, SH-02). The\n * shell renders it in its own origin, where the artifact can neither click nor reach it, and\n * answers whether it is shown: a control the host's policy leaves out is not (D108).\n */\nexport const mostraControlsRequest: BridgeMessage<ControlRequest, { readonly shown: boolean }> = {\n method: \"mostra/controls.request\",\n from: \"artifact\",\n kind: \"request\",\n params: z.discriminatedUnion(\"control\", [\n z.looseObject({\n control: z.literal(\"submit\"),\n label: z.string().min(1).max(CONTROL_LABEL_MAX).exactOptional(),\n confirm: z.string().min(1).max(500).exactOptional(),\n }),\n z.looseObject({\n control: z.literal(\"choose\"),\n reviewSetId: z.string().regex(REVIEW_SET_ID_PATTERN),\n candidates: z\n .array(\n z.looseObject({\n id: z.string().min(1).max(256),\n label: z.string().max(CONTROL_LABEL_MAX).exactOptional(),\n }),\n )\n .min(1)\n .max(64)\n .readonly(),\n current: z.string().min(1).max(256).exactOptional(),\n }),\n z.looseObject({\n control: z.literal(\"release\"),\n submit: z.literal(true).exactOptional(),\n reviewSetId: z.string().regex(REVIEW_SET_ID_PATTERN).exactOptional(),\n }),\n ]) as unknown as z.ZodType<ControlRequest>,\n result: z.looseObject({ shown: z.boolean() }),\n};\n\n/** What the page answers `mostra/flush`. */\nexport interface FlushResult {\n /** The viewer's draft revision once every save landed. */\n readonly revision: string;\n /** Whether edits still wait (offline, or a save failed). */\n readonly unsaved: boolean;\n /** What blocks a submit now: invalid values and open conflicts, and required fields the page sees empty. */\n readonly blockers: readonly SubmitBlocker[];\n}\n\n/**\n * `mostra/flush`: the shell asks the page to save everything now, before its trusted Submit or a\n * switch to a newer version (IN-02, D110). For a submit, the page first writes the defaults the\n * viewer saw. The shell checks the answer against the draft it reads itself.\n */\nexport const mostraFlush: BridgeMessage<{ readonly reason: \"submit\" | \"switch\" }, FlushResult> = {\n method: \"mostra/flush\",\n from: \"shell\",\n kind: \"request\",\n params: z.looseObject({ reason: z.enum([\"submit\", \"switch\"]) }),\n result: z.looseObject({\n revision: z.string().regex(/^(0|[1-9][0-9]{0,15})$/),\n unsaved: z.boolean(),\n blockers: z.array(SubmitBlockerSchema).max(BRIDGE_FIELDS_MAX).readonly(),\n }),\n};\n\n/** The params of `mostra/version.available`. */\nexport interface VersionAvailableParams {\n /** The newer version's ID. */\n readonly versionId: string;\n /** Its number. */\n readonly version: number;\n /** How many of the viewer's answers it doesn't carry over (D42). */\n readonly orphans: number;\n}\n\n/**\n * `mostra/version.available`: a newer version was published while the page is open (VR-04). The\n * shell always shows its own trusted banner; the page may show a notice too.\n */\nexport const mostraVersionAvailable: BridgeMessage<VersionAvailableParams, undefined> = {\n method: \"mostra/version.available\",\n from: \"shell\",\n kind: \"notification\",\n params: z.looseObject({\n versionId: z.string().min(1),\n version: z.int().min(1),\n orphans: z.int().min(0),\n }),\n result: z.undefined(),\n};\n\n/** `mostra/field.focus`: the viewer picked a blocker in the shell; the page focuses that field. */\nexport const mostraFieldFocus: BridgeMessage<{ readonly id: string }, undefined> = {\n method: \"mostra/field.focus\",\n from: \"shell\",\n kind: \"notification\",\n params: z.looseObject({ id: z.string().min(1).max(256) }),\n result: z.undefined(),\n};\n\n/**\n * Every message of the bridge in this release. WP-20 adds review messages; a message never\n * changes meaning once released (D32).\n */\nexport const BRIDGE_MESSAGES: readonly AnyBridgeMessage[] = [\n uiInitialize,\n uiInitialized,\n uiSizeChanged,\n uiOpenLink,\n mostraReady,\n mostraFields,\n mostraPage,\n mostraControlsRequest,\n mostraFlush,\n mostraVersionAvailable,\n mostraFieldFocus,\n] as readonly AnyBridgeMessage[];\n\n/** The window events arrive on (`window` itself). */\nexport interface BridgeReceiver {\n /** Starts delivering `message` events to `listener`. */\n addEventListener(type: \"message\", listener: (event: BridgeEvent) => void): void;\n /** Stops delivering them. */\n removeEventListener(type: \"message\", listener: (event: BridgeEvent) => void): void;\n}\n\n/** The parts of a `MessageEvent` the bridge reads. */\nexport interface BridgeEvent {\n /** The message. */\n readonly data: unknown;\n /** The sender's origin, as the browser reports it. */\n readonly origin: string;\n /** The sending window. */\n readonly source: unknown;\n}\n\n/** The window messages go to: the frame's `contentWindow`, or the shell (`window.parent`). */\nexport interface BridgePeer {\n /** Posts `message` to the window, delivered only if its origin is `targetOrigin`. */\n postMessage(message: unknown, targetOrigin: string): void;\n}\n\n/** Why the bridge dropped a message, for logs and tests. */\nexport type BridgeRejection =\n | \"wrong-source\"\n | \"wrong-origin\"\n | \"not-json-rpc\"\n | \"unknown-method\"\n | \"wrong-direction\"\n | \"invalid-params\";\n\n/** Options for {@link connectBridge}. */\nexport interface BridgeOptions {\n /** This end. It accepts only messages the other side sends. */\n readonly side: BridgeSide;\n /** Where messages arrive. */\n readonly receiver: BridgeReceiver;\n /** The window this end talks to, looked up on every message (a frame's window changes on reload). */\n readonly peer: () => BridgePeer | null | undefined;\n /** The peer's exact origin. Messages from any other origin are dropped. */\n readonly peerOrigin: string;\n /** Answers a request from the peer; throw an {@link RpcError} to answer with an error. */\n readonly onRequest?: (message: AnyBridgeMessage, params: unknown) => unknown;\n /** Receives a notification from the peer. */\n readonly onNotification?: (message: AnyBridgeMessage, params: unknown) => void;\n /** Hears about every dropped message. */\n readonly onRejected?: (reason: BridgeRejection, event: BridgeEvent) => void;\n}\n\n/** One end of a connected bridge. */\nexport interface Bridge {\n /** Sends a request this side may send and resolves with its validated result. */\n call<P, R>(message: BridgeMessage<P, R>, params: P, options?: { timeoutMs?: number }): Promise<R>;\n /** Sends a notification this side may send. */\n notify<P>(message: BridgeMessage<P, undefined>, params: P): void;\n /** Stops listening; waiting calls reject. */\n close(): void;\n}\n\nconst asMethod = <P, R>(message: BridgeMessage<P, R>): MethodDefinition<P, R> => ({\n method: message.method,\n direction: \"client-to-instance\",\n mutating: false,\n params: message.params,\n result: message.result,\n});\n\n/**\n * Connects one end of the bridge. Every incoming message must come from `peer()` at exactly\n * `peerOrigin`, be a JSON-RPC message, name a message the other side sends, and carry valid params.\n */\nexport function connectBridge(options: BridgeOptions): Bridge {\n const known = new Map(BRIDGE_MESSAGES.map((message) => [message.method, message]));\n const send = (message: unknown): void => {\n const peer = options.peer();\n if (!peer) throw new Error(\"The bridge's peer window is gone.\");\n peer.postMessage(message, options.peerOrigin);\n };\n const rpc = new RpcPeer({\n send,\n onRequest: (method, params) => {\n const message = known.get(method);\n if (!message || message.from === options.side || message.kind !== \"request\") {\n throw new RpcError(\n hostDiagnostic(\"MOSTRA_HOST_METHOD_UNKNOWN\", {\n message: `The bridge has no request ${method} for this side.`,\n }),\n JSON_RPC_ERROR_CODES.methodNotFound,\n );\n }\n if (!options.onRequest) {\n throw new RpcError(\n hostDiagnostic(\"MOSTRA_HOST_METHOD_UNKNOWN\", {\n message: `This side doesn't answer ${method}.`,\n }),\n JSON_RPC_ERROR_CODES.methodNotFound,\n );\n }\n const parsed = message.params.safeParse(params ?? {});\n if (!parsed.success) {\n throw new RpcError(\n hostDiagnostic(\"MOSTRA_HOST_INVALID_PARAMS\", {\n message: `Invalid params for ${method}.`,\n }),\n JSON_RPC_ERROR_CODES.invalidParams,\n );\n }\n return options.onRequest(message, parsed.data);\n },\n onNotification: (method, params) => {\n const message = known.get(method);\n if (message?.kind !== \"notification\" || message.from === options.side) return;\n const parsed = message.params.safeParse(params ?? {});\n if (parsed.success) options.onNotification?.(message, parsed.data);\n },\n });\n\n /** Why an incoming message must be dropped, or `undefined` when the RPC peer may take it. */\n const screen = (event: BridgeEvent): BridgeRejection | undefined => {\n const peer = options.peer();\n if (!peer || event.source !== peer) return \"wrong-source\";\n if (event.origin !== options.peerOrigin) return \"wrong-origin\";\n const classified = classifyMessage(event.data);\n if (classified.kind === \"invalid\") return \"not-json-rpc\";\n if (classified.kind !== \"request\" && classified.kind !== \"notification\") return undefined;\n const message = known.get(classified.message.method);\n if (!message) return \"unknown-method\";\n if (message.from === options.side) return \"wrong-direction\";\n if (!message.params.safeParse(classified.message.params ?? {}).success) return \"invalid-params\";\n return undefined;\n };\n const listener = (event: BridgeEvent): void => {\n const rejection = screen(event);\n if (rejection !== undefined) {\n options.onRejected?.(rejection, event);\n // A request from the right window still gets its error answer from the RPC peer.\n const answerable =\n rejection !== \"wrong-source\" &&\n rejection !== \"wrong-origin\" &&\n rejection !== \"not-json-rpc\" &&\n classifyMessage(event.data).kind === \"request\";\n if (!answerable) return;\n }\n rpc.receive(event.data);\n };\n options.receiver.addEventListener(\"message\", listener);\n\n const sendable = (message: AnyBridgeMessage): void => {\n if (message.from !== options.side) {\n throw new Error(`The ${options.side} doesn't send ${message.method}.`);\n }\n };\n return {\n call(message, params, callOptions) {\n sendable(message as AnyBridgeMessage);\n return rpc.call(asMethod(message), params, callOptions ?? {});\n },\n notify(message, params) {\n sendable(message as AnyBridgeMessage);\n const parsed = message.params.parse(params);\n rpc.notify(message.method, parsed as Readonly<Record<string, unknown>>);\n },\n close() {\n options.receiver.removeEventListener(\"message\", listener);\n rpc.close();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAa,4BAA4B;AAYzC,MAAM,iBAAkD,EAAE,YAAY;CACpE,MAAM,EAAE,OAAO;CACf,SAAS,EAAE,OAAO;CAClB,OAAO,EAAE,OAAO,CAAC,CAAC,cAAc;AAClC,CAAC;;AAmDD,MAAa,eAAsE;CACjF,QAAQ;CACR,MAAM;CACN,MAAM;CACN,QAAQ,EAAE,YAAY;EACpB,SAAS;EACT,iBAAiB,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC;EACjD,iBAAiB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;EACjC,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc;CAChF,CAAC;CACD,QAAQ,EAAE,YAAY;EACpB,iBAAiB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;EACjC,UAAU;EACV,kBAAkB,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC;EAClD,aAAa,EAAE,YAAY;GACz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Q,SAAS,QAAQ,MAAM,OAAO;EAC1C,IAAI,CAAC,QAAQ,OAAO,UAAU,WAAW,QAAQ,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO;CAEjF;CACA,MAAM,YAAY,UAA6B;EAC7C,MAAM,YAAY,OAAO,KAAK;EAC9B,IAAI,cAAc,KAAA,GAAW;GAC3B,QAAQ,aAAa,WAAW,KAAK;GAOrC,IAAI,EAJF,cAAc,kBACd,cAAc,kBACd,cAAc,kBACd,gBAAgB,MAAM,IAAI,CAAC,CAAC,SAAS,YACtB;EACnB;EACA,IAAI,QAAQ,MAAM,IAAI;CACxB;CACA,QAAQ,SAAS,iBAAiB,WAAW,QAAQ;CAErD,MAAM,YAAY,YAAoC;EACpD,IAAI,QAAQ,SAAS,QAAQ,MAC3B,MAAM,IAAI,MAAM,OAAO,QAAQ,KAAK,gBAAgB,QAAQ,OAAO,EAAE;CAEzE;CACA,OAAO;EACL,KAAK,SAAS,QAAQ,aAAa;GACjC,SAAS,OAA2B;GACpC,OAAO,IAAI,KAAK,SAAS,OAAO,GAAG,QAAQ,eAAe,CAAC,CAAC;EAC9D;EACA,OAAO,SAAS,QAAQ;GACtB,SAAS,OAA2B;GACpC,MAAM,SAAS,QAAQ,OAAO,MAAM,MAAM;GAC1C,IAAI,OAAO,QAAQ,QAAQ,MAA2C;EACxE;EACA,QAAQ;GACN,QAAQ,SAAS,oBAAoB,WAAW,QAAQ;GACxD,IAAI,MAAM;EACZ;CACF;AACF"}
@@ -0,0 +1,195 @@
1
+ import { EphemeralMessage } from "./actions.js";
2
+ import { DeliveryTarget, REVIEW_SET_ID_PATTERN, VersionRef, ViewContext, ViewContextWire, readViewContext } from "./view.js";
3
+ import { DocumentRevision, EventRecord, FieldOp, FieldState, SubmissionSummary, Viewer } from "./interaction.js";
4
+ import * as z from "zod";
5
+ //#region src/browser.d.ts
6
+ /** Every browser-protocol revision this release serves, oldest first. */
7
+ export declare const BROWSER_PROTOCOL_REVISIONS: readonly ["2026-10-15"];
8
+ /** The newest browser-protocol revision: what a client runtime built now speaks. */
9
+ export declare const BROWSER_PROTOCOL_REVISION = "2026-10-15";
10
+ /** The longest JSON a signal's payload may be, in UTF-8 bytes (D106). */
11
+ export declare const SIGNAL_PAYLOAD_MAX_BYTES: number;
12
+ /** `POST …/fields`: one mutation of the viewer's draft or the artifact's state. */
13
+ export interface FieldsRequest {
14
+ /** A fresh `mut_` ID per change; a retry repeats it and gets the recorded result. */
15
+ readonly mutationId: string;
16
+ /** Which document: the viewer's draft or the artifact's shared state. */
17
+ readonly scope: "viewer" | "artifact";
18
+ /** The document revision the page last saw; fields changed after it come back as conflicts. */
19
+ readonly baseRevision: DocumentRevision;
20
+ /** The view the page was opened as (D104). */
21
+ readonly viewId: string;
22
+ /** The field changes, applied together under one revision. */
23
+ readonly ops: readonly FieldOp[];
24
+ }
25
+ /** The Zod schema of the `FieldsRequest` type. */
26
+ export declare const FieldsRequest: z.ZodType<FieldsRequest>;
27
+ /** `POST …/submit`: submit the viewer's draft from the artifact's own code (D40). */
28
+ export interface SubmitRequest {
29
+ /** The view the page was opened as (D104); its version is what the submission names. */
30
+ readonly viewId: string;
31
+ /** The draft revision the viewer saw; another one is `MOSTRA_SUBMIT_REVISION_MOVED`. */
32
+ readonly expectedRevision: DocumentRevision;
33
+ /** Always `artifact` on this route; the shell's trusted Submit is the `shell` channel (D40). */
34
+ readonly channel: "artifact";
35
+ }
36
+ /** The Zod schema of the `SubmitRequest` type. */
37
+ export declare const SubmitRequest: z.ZodType<SubmitRequest>;
38
+ /** `POST …/signal`: raise a named signal for the host's attention (IN-09). */
39
+ export interface SignalRequest {
40
+ /** The view the page was opened as (D104). */
41
+ readonly viewId: string;
42
+ /** Letters, digits, `.`, `_` and `-`; `submit` is reserved. */
43
+ readonly name: string;
44
+ /** Any JSON, at most 64 KiB. */
45
+ readonly payload?: unknown;
46
+ }
47
+ /** The Zod schema of the `SignalRequest` type. */
48
+ export declare const SignalRequest: z.ZodType<SignalRequest>;
49
+ /** A document as the page loads it: its revision and fields. */
50
+ export interface DocumentSnapshot {
51
+ /** The document's revision. */
52
+ readonly revision: DocumentRevision;
53
+ /** The draft's epoch (D103); 1 for artifact state. */
54
+ readonly epoch: number;
55
+ /** Every field by ID. */
56
+ readonly fields: Readonly<Record<string, FieldState>>;
57
+ }
58
+ /** The Zod schema of the `DocumentSnapshot` type. */
59
+ export declare const DocumentSnapshot: z.ZodType<DocumentSnapshot>;
60
+ /**
61
+ * The first message of a browser event stream, and a poll's `snapshot`: where the page stands,
62
+ * so it renders the canonical draft and state before applying events after `cursor`.
63
+ */
64
+ export interface StreamSnapshot {
65
+ /** Events after this cursor follow. */
66
+ readonly cursor: string;
67
+ /** Who the page acts as. */
68
+ readonly viewer: Viewer;
69
+ /** The viewer's draft. */
70
+ readonly draft: DocumentSnapshot;
71
+ /** The artifact's shared state. */
72
+ readonly state: DocumentSnapshot;
73
+ /** The submission that closed this draft, or this viewer's latest under `epochs`. */
74
+ readonly submission?: SubmissionSummary;
75
+ /**
76
+ * The artifact's latest version when the snapshot was read (WP-07): a reader that missed its
77
+ * `version.published` event (published between a frame ticket and the stream, or compacted)
78
+ * still learns of it.
79
+ */
80
+ readonly latest?: VersionRef;
81
+ }
82
+ /** The Zod schema of the `StreamSnapshot` type. */
83
+ export declare const StreamSnapshot: z.ZodType<StreamSnapshot>;
84
+ /** `GET …/events/poll`: the long-poll answer on the same cursor as the stream (D47). */
85
+ export interface PollResult {
86
+ /** Where the next poll continues. */
87
+ readonly cursor: string;
88
+ /** The events for this page after the cursor asked for, in order. */
89
+ readonly events: readonly EventRecord[];
90
+ /** Present when the poll asked for none or its cursor was compacted away. */
91
+ readonly snapshot?: StreamSnapshot;
92
+ /**
93
+ * Run and live updates for this view since its last poll (WP-08): lossy and never stored as
94
+ * events, the long-poll's counterpart of the stream's `run` and `live` messages.
95
+ */
96
+ readonly ephemeral?: readonly EphemeralMessage[];
97
+ }
98
+ /** The Zod schema of the `PollResult` type. */
99
+ export declare const PollResult: z.ZodType<PollResult>;
100
+ /**
101
+ * `POST /a/{artifactId}/_mostra/ticket`'s answer on the shell origin: a single-use frame ticket,
102
+ * the view it opens and what the shell needs to render the view's trusted controls (D104, D108).
103
+ */
104
+ export interface FrameTicket extends ViewContext {
105
+ /** The frame's entry URL, carrying the single-use ticket. */
106
+ readonly src: string;
107
+ /** The artifact's origin: the only origin the bridge accepts messages from. */
108
+ readonly artifactOrigin: string;
109
+ /** Whether this viewer follows the artifact's new versions (D63). */
110
+ readonly follow: boolean;
111
+ /** Whether the link opens this version only (D97 item 9): then the shell offers no newer one. */
112
+ readonly pinned: boolean;
113
+ /**
114
+ * The version's server code keeps crashing and is parked (WP-08, FAILURE_MODEL §2): the shell
115
+ * says so, since the page's actions and live data won't work until a new publish.
116
+ */
117
+ readonly serverParked?: true;
118
+ /**
119
+ * The frame shows `mostra dev`'s development preview of unpublished source (D140 item 12): the
120
+ * shell says so, and it is never a published version.
121
+ */
122
+ readonly devPreview?: true;
123
+ }
124
+ /** The Zod schema of the `FrameTicket` type. */
125
+ export declare const FrameTicket: z.ZodType<FrameTicket>;
126
+ /**
127
+ * `POST /a/{artifactId}/_mostra/v/{rev}/submit`: the shell's trusted Submit (the `shell` channel,
128
+ * D40). Only the shell's page can send it: the route takes the shell's session, its exact origin
129
+ * and its CSRF token, none of which an artifact's page has.
130
+ */
131
+ export interface ShellSubmitRequest {
132
+ /** The view the shell's frame shows (D104); its version is what the submission names. */
133
+ readonly viewId: string;
134
+ /** The draft revision the viewer saw, after the frame flushed its saves. */
135
+ readonly expectedRevision: DocumentRevision;
136
+ }
137
+ /** The Zod schema of the `ShellSubmitRequest` type. */
138
+ export declare const ShellSubmitRequest: z.ZodType<ShellSubmitRequest>;
139
+ /**
140
+ * `POST /a/{artifactId}/_mostra/v/{rev}/review/choose`: the shell's trusted Choose (D65, D113).
141
+ * It writes the viewer's draft field `review.<reviewSetId>.choice` like any mutation, so a stale
142
+ * base revision comes back as a conflict.
143
+ */
144
+ export interface ChooseRequest {
145
+ /** The view the shell's frame shows. */
146
+ readonly viewId: string;
147
+ /** A fresh `mut_` ID; a retry repeats it. */
148
+ readonly mutationId: string;
149
+ /** The draft revision the shell last saw. */
150
+ readonly baseRevision: DocumentRevision;
151
+ /** The review set. */
152
+ readonly reviewSetId: string;
153
+ /** The chosen candidate's ID. */
154
+ readonly candidateId: string;
155
+ /** The candidate's label, kept with the choice for results. */
156
+ readonly label?: string;
157
+ }
158
+ /** The Zod schema of the `ChooseRequest` type. */
159
+ export declare const ChooseRequest: z.ZodType<ChooseRequest>;
160
+ /** `POST /a/{artifactId}/_mostra/v/{rev}/follow`: the viewer's "Always follow this artifact" (D63). */
161
+ export interface FollowRequest {
162
+ /** `true` to load new versions automatically, `false` to stop. */
163
+ readonly follow: boolean;
164
+ }
165
+ /** The Zod schema of the `FollowRequest` type. */
166
+ export declare const FollowRequest: z.ZodType<FollowRequest>;
167
+ /** A draft field a version doesn't cover (D42, D109): kept, shown read-only and delivered. */
168
+ export interface OrphanedField {
169
+ /** The field's ID. */
170
+ readonly id: string;
171
+ /** Its label, when it has one. */
172
+ readonly label?: string;
173
+ /** Its value. */
174
+ readonly value: unknown;
175
+ /** The version whose view last wrote it. */
176
+ readonly fromVersion: number;
177
+ }
178
+ /** The Zod schema of the `OrphanedField` type. */
179
+ export declare const OrphanedField: z.ZodType<OrphanedField>;
180
+ /**
181
+ * `GET /a/{artifactId}/_mostra/v/{rev}/carry?version=<number>`: which of the viewer's answers a
182
+ * version doesn't carry over (D42, D109). The banner counts them before a switch; the "Not
183
+ * carried over" panel lists them for the version shown.
184
+ */
185
+ export interface CarryOver {
186
+ /** The version asked about. */
187
+ readonly version: VersionRef;
188
+ /** The viewer's draft fields the version doesn't cover. */
189
+ readonly orphans: readonly OrphanedField[];
190
+ }
191
+ /** The Zod schema of the `CarryOver` type. */
192
+ export declare const CarryOver: z.ZodType<CarryOver>;
193
+ //#endregion
194
+ export { type DeliveryTarget, REVIEW_SET_ID_PATTERN, VersionRef, ViewContext, ViewContextWire, readViewContext };
195
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","names":[],"sources":["../src/browser.ts"],"mappings":";;;;;;qBA0Ca;;qBAGA;;qBAGA;;iBAGI;;WAEN;;WAEA;;WAEA,cAAc;;WAEd;;WAEA,cAAc;;;qBAIZ,eAAe,EAAE,QAAQ;;iBAcrB;;WAEN;;WAEA,kBAAkB;;WAElB;;;qBAIE,eAAe,EAAE,QAAQ;;iBAYrB;;WAEN;;WAEA;;WAEA;;;qBAIE,eAAe,EAAE,QAAQ;;iBAYrB;;WAEN,UAAU;;WAEV;;WAEA,QAAQ,SAAS,eAAe;;;qBAI9B,kBAAkB,EAAE,QAAQ;;;;;iBAexB;;WAEN;;WAEA,QAAQ;;WAER,OAAO;;WAEP,OAAO;;WAEP,aAAa;;;;;;WAMb,SAAS;;;qBAIP,gBAAgB,EAAE,QAAQ;;iBAetB;;WAEN;;WAEA,iBAAiB;;WAEjB,WAAW;;;;;WAKX,qBAAqB;;;qBAInB,YAAY,EAAE,QAAQ;;;;;iBAgBlB,oBAAoB;;WAE1B;;WAEA;;WAEA;;WAEA;;;;;WAKA;;;;;WAKA;;;qBAIE,aAAa,EAAE,QAAQ;;;;;;iBA6BnB;;WAEN;;WAEA,kBAAkB;;;qBAIhB,oBAAoB,EAAE,QAAQ;;;;;;iBAY1B;;WAEN;;WAEA;;WAEA,cAAc;;WAEd;;WAEA;;WAEA;;;qBAIE,eAAe,EAAE,QAAQ;;iBAgBrB;;WAEN;;;qBAIE,eAAe,EAAE,QAAQ;;iBAQrB;;WAEN;;WAEA;;WAEA;;WAEA;;;qBAIE,eAAe,EAAE,QAAQ;;;;;;iBAiBrB;;WAEN,SAAS;;WAET,kBAAkB;;;qBAIhB,WAAW,EAAE,QAAQ"}