@mostra/protocol 0.8.0 → 0.10.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 (224) hide show
  1. package/dist/actions.d.ts +30 -4
  2. package/dist/actions.d.ts.map +1 -1
  3. package/dist/actions.js +14 -4
  4. package/dist/actions.js.map +1 -1
  5. package/dist/artifact.d.ts +2 -1
  6. package/dist/artifact.d.ts.map +1 -1
  7. package/dist/artifact.js +2 -1
  8. package/dist/artifact.js.map +1 -1
  9. package/dist/browser.d.ts +5 -0
  10. package/dist/browser.d.ts.map +1 -1
  11. package/dist/browser.js +7 -2
  12. package/dist/browser.js.map +1 -1
  13. package/dist/capability.d.ts +0 -9
  14. package/dist/capability.d.ts.map +1 -1
  15. package/dist/capability.js +1 -17
  16. package/dist/capability.js.map +1 -1
  17. package/dist/diagnostics/codes/artifact.d.ts +1 -1
  18. package/dist/diagnostics/codes/artifact.d.ts.map +1 -1
  19. package/dist/diagnostics/codes/artifact.js +45 -1
  20. package/dist/diagnostics/codes/artifact.js.map +1 -1
  21. package/dist/diagnostics/codes/env.d.ts +1 -1
  22. package/dist/diagnostics/codes/env.d.ts.map +1 -1
  23. package/dist/diagnostics/codes/env.js +12 -1
  24. package/dist/diagnostics/codes/env.js.map +1 -1
  25. package/dist/diagnostics/codes/home.d.ts +1 -1
  26. package/dist/diagnostics/codes/home.d.ts.map +1 -1
  27. package/dist/diagnostics/codes/home.js +12 -1
  28. package/dist/diagnostics/codes/home.js.map +1 -1
  29. package/dist/diagnostics/codes/index.d.ts +3 -2
  30. package/dist/diagnostics/codes/index.d.ts.map +1 -1
  31. package/dist/diagnostics/codes/index.js +3 -1
  32. package/dist/diagnostics/codes/index.js.map +1 -1
  33. package/dist/diagnostics/codes/remote.d.ts +8 -0
  34. package/dist/diagnostics/codes/remote.d.ts.map +1 -0
  35. package/dist/diagnostics/codes/remote.js +99 -0
  36. package/dist/diagnostics/codes/remote.js.map +1 -0
  37. package/dist/diagnostics/codes/submit.js +3 -3
  38. package/dist/diagnostics/codes/submit.js.map +1 -1
  39. package/dist/diagnostics/diagnostic.d.ts +1 -1
  40. package/dist/diagnostics/diagnostic.d.ts.map +1 -1
  41. package/dist/diagnostics/diagnostic.js +2 -1
  42. package/dist/diagnostics/diagnostic.js.map +1 -1
  43. package/dist/duration.d.ts +13 -0
  44. package/dist/duration.d.ts.map +1 -0
  45. package/dist/duration.js +27 -0
  46. package/dist/duration.js.map +1 -0
  47. package/dist/hygiene.d.ts +4 -1
  48. package/dist/hygiene.d.ts.map +1 -1
  49. package/dist/hygiene.js +4 -0
  50. package/dist/hygiene.js.map +1 -1
  51. package/dist/ids.d.ts +17 -1
  52. package/dist/ids.d.ts.map +1 -1
  53. package/dist/ids.js +9 -1
  54. package/dist/ids.js.map +1 -1
  55. package/dist/index.d.ts +30 -8
  56. package/dist/index.js +30 -8
  57. package/dist/interaction.d.ts +28 -2
  58. package/dist/interaction.d.ts.map +1 -1
  59. package/dist/interaction.js +20 -5
  60. package/dist/interaction.js.map +1 -1
  61. package/dist/manifest.d.ts +59 -14
  62. package/dist/manifest.d.ts.map +1 -1
  63. package/dist/manifest.js +63 -15
  64. package/dist/manifest.js.map +1 -1
  65. package/dist/methods/artifact/export.d.ts +40 -0
  66. package/dist/methods/artifact/export.d.ts.map +1 -0
  67. package/dist/methods/artifact/export.js +36 -0
  68. package/dist/methods/artifact/export.js.map +1 -0
  69. package/dist/methods/artifact/import.d.ts +23 -0
  70. package/dist/methods/artifact/import.d.ts.map +1 -0
  71. package/dist/methods/artifact/import.js +25 -0
  72. package/dist/methods/artifact/import.js.map +1 -0
  73. package/dist/methods/artifact/publish.d.ts +2 -1
  74. package/dist/methods/artifact/publish.d.ts.map +1 -1
  75. package/dist/methods/artifact/publish.js +1 -1
  76. package/dist/methods/hosted/push.d.ts +76 -0
  77. package/dist/methods/hosted/push.d.ts.map +1 -0
  78. package/dist/methods/hosted/push.js +71 -0
  79. package/dist/methods/hosted/push.js.map +1 -0
  80. package/dist/methods/hosted/submission.d.ts +18 -0
  81. package/dist/methods/hosted/submission.d.ts.map +1 -0
  82. package/dist/methods/hosted/submission.js +23 -0
  83. package/dist/methods/hosted/submission.js.map +1 -0
  84. package/dist/methods/index.d.ts.map +1 -1
  85. package/dist/methods/index.js +38 -2
  86. package/dist/methods/index.js.map +1 -1
  87. package/dist/methods/instance/status.d.ts +3 -0
  88. package/dist/methods/instance/status.d.ts.map +1 -1
  89. package/dist/methods/instance/status.js +3 -1
  90. package/dist/methods/instance/status.js.map +1 -1
  91. package/dist/methods/mostra/initialize.d.ts +17 -3
  92. package/dist/methods/mostra/initialize.d.ts.map +1 -1
  93. package/dist/methods/mostra/initialize.js +11 -3
  94. package/dist/methods/mostra/initialize.js.map +1 -1
  95. package/dist/methods/port/relay-call.d.ts +33 -0
  96. package/dist/methods/port/relay-call.d.ts.map +1 -0
  97. package/dist/methods/port/relay-call.js +31 -0
  98. package/dist/methods/port/relay-call.js.map +1 -0
  99. package/dist/methods/port/relay-cancel.d.ts +16 -0
  100. package/dist/methods/port/relay-cancel.d.ts.map +1 -0
  101. package/dist/methods/port/relay-cancel.js +21 -0
  102. package/dist/methods/port/relay-cancel.js.map +1 -0
  103. package/dist/methods/port/relay-live.d.ts +25 -0
  104. package/dist/methods/port/relay-live.d.ts.map +1 -0
  105. package/dist/methods/port/relay-live.js +32 -0
  106. package/dist/methods/port/relay-live.js.map +1 -0
  107. package/dist/methods/port/relay-reconcile.d.ts +39 -0
  108. package/dist/methods/port/relay-reconcile.d.ts.map +1 -0
  109. package/dist/methods/port/relay-reconcile.js +35 -0
  110. package/dist/methods/port/relay-reconcile.js.map +1 -0
  111. package/dist/methods/port/relay-run.d.ts +47 -0
  112. package/dist/methods/port/relay-run.d.ts.map +1 -0
  113. package/dist/methods/port/relay-run.js +41 -0
  114. package/dist/methods/port/relay-run.js.map +1 -0
  115. package/dist/methods/port/submissions-deliver.d.ts +8 -0
  116. package/dist/methods/port/submissions-deliver.d.ts.map +1 -1
  117. package/dist/methods/port/submissions-deliver.js +4 -2
  118. package/dist/methods/port/submissions-deliver.js.map +1 -1
  119. package/dist/methods/relay/call-batch.d.ts +26 -0
  120. package/dist/methods/relay/call-batch.d.ts.map +1 -0
  121. package/dist/methods/relay/call-batch.js +30 -0
  122. package/dist/methods/relay/call-batch.js.map +1 -0
  123. package/dist/methods/relay/effect.d.ts +31 -0
  124. package/dist/methods/relay/effect.d.ts.map +1 -0
  125. package/dist/methods/relay/effect.js +30 -0
  126. package/dist/methods/relay/effect.js.map +1 -0
  127. package/dist/methods/relay/live-value.d.ts +33 -0
  128. package/dist/methods/relay/live-value.d.ts.map +1 -0
  129. package/dist/methods/relay/live-value.js +32 -0
  130. package/dist/methods/relay/live-value.js.map +1 -0
  131. package/dist/methods/relay/run-update.d.ts +46 -0
  132. package/dist/methods/relay/run-update.d.ts.map +1 -0
  133. package/dist/methods/relay/run-update.js +45 -0
  134. package/dist/methods/relay/run-update.js.map +1 -0
  135. package/dist/methods/remote/login-wait.d.ts +30 -0
  136. package/dist/methods/remote/login-wait.d.ts.map +1 -0
  137. package/dist/methods/remote/login-wait.js +36 -0
  138. package/dist/methods/remote/login-wait.js.map +1 -0
  139. package/dist/methods/remote/login.d.ts +41 -0
  140. package/dist/methods/remote/login.d.ts.map +1 -0
  141. package/dist/methods/remote/login.js +37 -0
  142. package/dist/methods/remote/login.js.map +1 -0
  143. package/dist/methods/remote/logout.d.ts +25 -0
  144. package/dist/methods/remote/logout.d.ts.map +1 -0
  145. package/dist/methods/remote/logout.js +28 -0
  146. package/dist/methods/remote/logout.js.map +1 -0
  147. package/dist/methods/remote/status.d.ts +14 -0
  148. package/dist/methods/remote/status.d.ts.map +1 -0
  149. package/dist/methods/remote/status.js +22 -0
  150. package/dist/methods/remote/status.js.map +1 -0
  151. package/dist/methods/remote/token.d.ts +19 -0
  152. package/dist/methods/remote/token.d.ts.map +1 -0
  153. package/dist/methods/remote/token.js +24 -0
  154. package/dist/methods/remote/token.js.map +1 -0
  155. package/dist/methods/share/start.d.ts +5 -2
  156. package/dist/methods/share/start.d.ts.map +1 -1
  157. package/dist/methods/share/start.js +6 -3
  158. package/dist/methods/share/start.js.map +1 -1
  159. package/dist/methods/state/patch.d.ts +7 -0
  160. package/dist/methods/state/patch.d.ts.map +1 -1
  161. package/dist/methods/state/patch.js +2 -1
  162. package/dist/methods/state/patch.js.map +1 -1
  163. package/dist/methods/view/url.d.ts +2 -1
  164. package/dist/methods/view/url.d.ts.map +1 -1
  165. package/dist/methods/view/url.js +2 -1
  166. package/dist/methods/view/url.js.map +1 -1
  167. package/dist/policy.d.ts +18 -0
  168. package/dist/policy.d.ts.map +1 -0
  169. package/dist/policy.js +23 -0
  170. package/dist/policy.js.map +1 -0
  171. package/dist/remote.d.ts +55 -0
  172. package/dist/remote.d.ts.map +1 -0
  173. package/dist/remote.js +52 -0
  174. package/dist/remote.js.map +1 -0
  175. package/dist/view.d.ts +1 -1
  176. package/dist/view.js +1 -1
  177. package/dist/view.js.map +1 -1
  178. package/package.json +2 -2
  179. package/schemas/protocol.draft-07.json +1607 -126
  180. package/schemas/protocol.schema.json +1543 -126
  181. package/src/actions.ts +45 -5
  182. package/src/browser.ts +6 -0
  183. package/src/capability.ts +0 -23
  184. package/src/diagnostics/codes/artifact.ts +48 -0
  185. package/src/diagnostics/codes/env.ts +12 -0
  186. package/src/diagnostics/codes/home.ts +12 -0
  187. package/src/diagnostics/codes/index.ts +6 -2
  188. package/src/diagnostics/codes/remote.ts +113 -0
  189. package/src/diagnostics/codes/submit.ts +3 -3
  190. package/src/diagnostics/diagnostic.ts +3 -1
  191. package/src/duration.ts +29 -0
  192. package/src/hygiene.ts +12 -1
  193. package/src/ids.ts +33 -1
  194. package/src/index.ts +124 -8
  195. package/src/interaction.ts +42 -2
  196. package/src/manifest.ts +115 -24
  197. package/src/methods/artifact/export.ts +68 -0
  198. package/src/methods/artifact/import.ts +39 -0
  199. package/src/methods/hosted/push.ts +146 -0
  200. package/src/methods/hosted/submission.ts +34 -0
  201. package/src/methods/index.ts +36 -0
  202. package/src/methods/instance/status.ts +4 -0
  203. package/src/methods/mostra/initialize.ts +19 -3
  204. package/src/methods/port/relay-call.ts +58 -0
  205. package/src/methods/port/relay-cancel.ts +33 -0
  206. package/src/methods/port/relay-live.ts +48 -0
  207. package/src/methods/port/relay-reconcile.ts +71 -0
  208. package/src/methods/port/relay-run.ts +80 -0
  209. package/src/methods/port/submissions-deliver.ts +13 -1
  210. package/src/methods/relay/call-batch.ts +52 -0
  211. package/src/methods/relay/effect.ts +55 -0
  212. package/src/methods/relay/live-value.ts +54 -0
  213. package/src/methods/relay/run-update.ts +81 -0
  214. package/src/methods/remote/login-wait.ts +55 -0
  215. package/src/methods/remote/login.ts +72 -0
  216. package/src/methods/remote/logout.ts +42 -0
  217. package/src/methods/remote/status.ts +34 -0
  218. package/src/methods/remote/token.ts +39 -0
  219. package/src/methods/share/start.ts +12 -4
  220. package/src/methods/state/patch.ts +6 -0
  221. package/src/methods/view/url.ts +2 -1
  222. package/src/policy.ts +30 -0
  223. package/src/remote.ts +89 -0
  224. package/src/view.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"submit.js","names":[],"sources":["../../../src/diagnostics/codes/submit.ts"],"sourcesContent":["/**\n * Diagnostic codes of the SUBMIT area.\n */\nimport type { AreaCatalog } from \"../spec.ts\";\n\n/** The codes of the SUBMIT area, in the order they were added. */\nexport const submitDiagnosticCodes = [\n \"MOSTRA_SUBMIT_ALREADY\",\n \"MOSTRA_SUBMIT_REVISION_MOVED\",\n \"MOSTRA_SUBMIT_POLICY_NONE\",\n \"MOSTRA_SUBMIT_NOT_FOUND\",\n \"MOSTRA_SUBMIT_VIEW_INVALID\",\n \"MOSTRA_SUBMIT_SIGNAL_INVALID\",\n \"MOSTRA_SUBMIT_CHANNEL_DENIED\",\n \"MOSTRA_SUBMIT_BLOCKED\",\n // gen:codes\n] as const;\n\n/** The codes of the SUBMIT area. */\nexport type SubmitDiagnosticCode = (typeof submitDiagnosticCodes)[number];\n\n/** The SUBMIT area's catalog entries. */\nexport const submitDiagnostics: AreaCatalog<SubmitDiagnosticCode> = {\n MOSTRA_SUBMIT_ALREADY: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Already submitted\",\n hint: \"This artifact takes one submission, and it was made; read it with `mostra results`.\",\n docs: {\n explanation:\n \"The artifact's submission policy is `once`, and a submission already closed this draft: for scope `per-artifact` any viewer's submission closes every draft, for `per-viewer` the viewer's own. A submission is immutable and final, so Mostra refuses a second one and further edits to the closed draft. The refusal carries the existing submission. A repeated submit of the same view at the same draft revision is not refused: it returns the original submission.\",\n fix: 'Read the existing submission with `mostra results <artifact>`. When another round of answers is wanted, publish a new artifact linked to this one (`links: [{ rel: \"round-of\", artifact }]`), or have the host publish with the `epochs` policy.',\n },\n },\n MOSTRA_SUBMIT_REVISION_MOVED: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Draft changed before submit\",\n hint: \"Reload the draft, check what changed, and submit again with its current revision.\",\n docs: {\n explanation:\n \"A submit names the draft revision the viewer saw (`expectedRevision`), and the draft has changed since: another tab, device or writer saved an edit. Mostra never makes a submission from content the viewer didn't see (FAILURE_MODEL §4), so it refuses. The message names the draft's current revision.\",\n fix: \"Let the page reload the draft so the viewer sees exactly what will be sent, then submit with the new revision. The shell and the client runtime flush pending saves before they submit, which makes this rare.\",\n },\n },\n MOSTRA_SUBMIT_POLICY_NONE: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Artifact takes no submissions\",\n hint: \"Exchange data through artifact state, actions and signals; this artifact has no submissions.\",\n docs: {\n explanation:\n \"The artifact's submission policy is `none` (D63): long-lived artifacts such as dashboards and task managers talk to agents through artifact state, actions, signals and events, and the shell shows no Submit control. Mostra refuses a submit, and a `wait --until submitted`, on such an artifact.\",\n fix: \"Wait for a signal (`--until signal:<name>`), a state change (`--until state:<field>`) or an event instead, and read state with `mostra state get`. To collect submissions, publish with policy `once` or `epochs`.\",\n },\n },\n MOSTRA_SUBMIT_NOT_FOUND: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"No such submission\",\n hint: \"Wait for a submission with `mostra wait <artifact> --until submitted`, or name one that exists.\",\n docs: {\n explanation:\n \"The artifact has no submission yet, or none with the ID asked for. Submissions are durable once made, so this means none was made (or the ID belongs to another artifact or home).\",\n fix: \"Run `mostra wait <artifact> --until submitted` to block until the viewer submits, then read the results. List the artifact's submissions through `submission.created` events.\",\n },\n },\n MOSTRA_SUBMIT_VIEW_INVALID: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Unknown view\",\n hint: \"Send the view ID this page was opened with.\",\n docs: {\n explanation:\n \"Mutations and submits name the view they come from, the one the shell created when it opened this frame. The view named doesn't exist, belongs to another artifact, or belongs to another viewer. Mostra binds every submission to the exact version its view showed, so it refuses a view it can't place.\",\n fix: \"Use the `viewId` the shell handed this frame. A page opened outside Mostra's shell has no view and can't submit.\",\n },\n },\n MOSTRA_SUBMIT_SIGNAL_INVALID: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Invalid signal\",\n hint: \"Name signals with letters, digits, `.`, `_` and `-`, and keep their payload under 64 KiB of JSON.\",\n docs: {\n explanation:\n \"A signal names something the artifact wants a host's attention for, such as `ping-agent`. Its name is 1 to 64 characters of letters, digits, `.`, `_` and `-`, starting with a letter or digit, and its payload is JSON of at most 64 KiB. This one broke one of those rules. The name `submit` is reserved for submissions.\",\n fix: \"Rename the signal or shrink its payload; put large data into a field or artifact state and send its ID in the payload.\",\n },\n },\n MOSTRA_SUBMIT_CHANNEL_DENIED: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Submit channel not allowed\",\n hint: \"Let the viewer submit with the shell's trusted Submit; this host doesn't take submissions from artifact code.\",\n docs: {\n explanation:\n \"A submission comes through one of two channels (D40): the shell's trusted Submit (`shell`), which only a person can press, or the artifact's own code (`artifact`, `useSubmit().submit()` and `useChoice().choose()`). The host decides which it accepts (D108): through `HomeConfig.submitChannels` for the home, or its `trustedControls` port for each artifact. This view allows only the other channel, so Mostra refused the submit or the choice. `useSubmit().allowed` is `false` in such a view.\",\n fix: \"Ask the viewer to press the shell's Submit (relabel it with `useSubmitControl`), and use `useChoice(id, { candidates })` to have the shell render a trusted Choose. Check `allowed` before showing an in-page submit button.\",\n },\n },\n MOSTRA_SUBMIT_BLOCKED: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Answers missing before submit\",\n hint: \"Fill in the fields this diagnostic lists, fix their errors or resolve their conflicts, then submit again.\",\n docs: {\n explanation:\n \"Before a submit, the shell and the client runtime check every mounted field (D106): a `required` field without a value, a value its `validate` rejects, or a conflict the viewer hasn't resolved blocks the submit. The diagnostic lists the blockers with their field IDs and labels; `useSubmit().blockers` lists them before anyone submits. Nothing was submitted.\",\n fix: \"Show `useSubmit().blockers` next to your submit button, or let the shell list them by label. Answer the required fields, fix the invalid values, and keep or take the conflicting values, then submit again.\",\n },\n },\n // gen:entries\n};\n"],"mappings":";;AAMA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAEF;;AAMA,MAAa,oBAAuD;CAClE,uBAAuB;EACrB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,2BAA2B;EACzB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,yBAAyB;EACvB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,4BAA4B;EAC1B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,uBAAuB;EACrB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;AAEF"}
1
+ {"version":3,"file":"submit.js","names":[],"sources":["../../../src/diagnostics/codes/submit.ts"],"sourcesContent":["/**\n * Diagnostic codes of the SUBMIT area.\n */\nimport type { AreaCatalog } from \"../spec.ts\";\n\n/** The codes of the SUBMIT area, in the order they were added. */\nexport const submitDiagnosticCodes = [\n \"MOSTRA_SUBMIT_ALREADY\",\n \"MOSTRA_SUBMIT_REVISION_MOVED\",\n \"MOSTRA_SUBMIT_POLICY_NONE\",\n \"MOSTRA_SUBMIT_NOT_FOUND\",\n \"MOSTRA_SUBMIT_VIEW_INVALID\",\n \"MOSTRA_SUBMIT_SIGNAL_INVALID\",\n \"MOSTRA_SUBMIT_CHANNEL_DENIED\",\n \"MOSTRA_SUBMIT_BLOCKED\",\n // gen:codes\n] as const;\n\n/** The codes of the SUBMIT area. */\nexport type SubmitDiagnosticCode = (typeof submitDiagnosticCodes)[number];\n\n/** The SUBMIT area's catalog entries. */\nexport const submitDiagnostics: AreaCatalog<SubmitDiagnosticCode> = {\n MOSTRA_SUBMIT_ALREADY: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Already submitted\",\n hint: \"This artifact takes one submission, and it was made; read it with `mostra results`.\",\n docs: {\n explanation:\n \"The artifact's submission policy is `once`, and a submission already closed this draft: for scope `per-artifact` any viewer's submission closes every draft, for `per-viewer` the viewer's own. A submission is immutable and final, so Mostra refuses a second one and further edits to the closed draft. The refusal carries the existing submission. A repeated submit of the same view at the same draft revision is not refused: it returns the original submission.\",\n fix: 'Read the existing submission with `mostra results <artifact>`. When another round of answers is wanted, publish a new artifact linked to this one (`links: [{ rel: \"round-of\", artifact }]`), or have the host publish with the `epochs` policy.',\n },\n },\n MOSTRA_SUBMIT_REVISION_MOVED: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Draft changed before submit\",\n hint: \"Reload the draft, check what changed, and submit again with its current revision.\",\n docs: {\n explanation:\n \"A submit names the draft revision the viewer saw (`expectedRevision`), and the draft has changed since: another tab, device or writer saved an edit. Mostra never makes a submission from content the viewer didn't see (FAILURE_MODEL §4), so it refuses. The message names the draft's current revision.\",\n fix: \"Let the page reload the draft so the viewer sees exactly what will be sent, then submit with the new revision. The shell and the client runtime flush pending saves before they submit, which makes this rare.\",\n },\n },\n MOSTRA_SUBMIT_POLICY_NONE: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Artifact takes no submissions\",\n hint: \"Exchange data through artifact state, actions and signals; this artifact has no submissions.\",\n docs: {\n explanation:\n \"The artifact's submission policy is `none` (D63): long-lived artifacts such as dashboards and task managers talk to agents through artifact state, actions, signals and events, and the shell shows no Submit control. Mostra refuses a submit, and a `wait --until submitted`, on such an artifact.\",\n fix: \"Wait for a signal (`--until signal:<name>`), a state change (`--until state:<field>`) or an event instead, and read state with `mostra state get`. To collect submissions, publish with policy `once` or `epochs`.\",\n },\n },\n MOSTRA_SUBMIT_NOT_FOUND: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"No such submission\",\n hint: \"Wait for a submission with `mostra wait <artifact> --until submitted`, or, when the message says the policy is none, read `mostra state get <artifact>` or wait for a signal with `--until signal:<name>`.\",\n docs: {\n explanation:\n \"The artifact has no submission yet, or none with the ID asked for. Submissions are durable once made, so this means none was made (or the ID belongs to another artifact or home). An artifact whose submission policy is `none` never has one, and the message says so: its viewers' work is in its shared state, its signals and its action runs.\",\n fix: \"Run `mostra wait <artifact> --until submitted` to block until the viewer submits, then read the results. List the artifact's submissions through `submission.created` events. Under policy `none`, read the shared state with `mostra state get <artifact>`, or wait for a signal the page raises with `mostra wait <artifact> --until signal:<name>`: its event carries the signal's payload.\",\n },\n },\n MOSTRA_SUBMIT_VIEW_INVALID: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Unknown view\",\n hint: \"Send the view ID this page was opened with.\",\n docs: {\n explanation:\n \"Mutations and submits name the view they come from, the one the shell created when it opened this frame. The view named doesn't exist, belongs to another artifact, or belongs to another viewer. Mostra binds every submission to the exact version its view showed, so it refuses a view it can't place.\",\n fix: \"Use the `viewId` the shell handed this frame. A page opened outside Mostra's shell has no view and can't submit.\",\n },\n },\n MOSTRA_SUBMIT_SIGNAL_INVALID: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Invalid signal\",\n hint: \"Name signals with letters, digits, `.`, `_` and `-`, and keep their payload under 64 KiB of JSON.\",\n docs: {\n explanation:\n \"A signal names something the artifact wants a host's attention for, such as `ping-agent`. Its name is 1 to 64 characters of letters, digits, `.`, `_` and `-`, starting with a letter or digit, and its payload is JSON of at most 64 KiB. This one broke one of those rules. The name `submit` is reserved for submissions.\",\n fix: \"Rename the signal or shrink its payload; put large data into a field or artifact state and send its ID in the payload.\",\n },\n },\n MOSTRA_SUBMIT_CHANNEL_DENIED: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Submit channel not allowed\",\n hint: \"Let the viewer submit with the shell's trusted Submit; this host doesn't take submissions from artifact code.\",\n docs: {\n explanation:\n \"A submission comes through one of two channels (D40): the shell's trusted Submit (`shell`), which only a person can press, or the artifact's own code (`artifact`, `useSubmit().submit()` and `useChoice().choose()`). The host decides which it accepts (D108): through `HomeConfig.submitChannels` for the home, or its `trustedControls` port for each artifact. This view allows only the other channel, so Mostra refused the submit or the choice. `useSubmit().allowed` is `false` in such a view.\",\n fix: \"Ask the viewer to press the shell's Submit (relabel it with `useSubmitControl`), and use `useChoice(id, { candidates })` to have the shell render a trusted Choose. Check `allowed` before showing an in-page submit button.\",\n },\n },\n MOSTRA_SUBMIT_BLOCKED: {\n severity: \"error\",\n phase: \"runtime\",\n title: \"Answers missing before submit\",\n hint: \"Fill in the fields this diagnostic lists, fix their errors or resolve their conflicts, then submit again.\",\n docs: {\n explanation:\n \"Before a submit, the shell and the client runtime check every mounted field (D106): a `required` field without a value, a value its `validate` rejects, or a conflict the viewer hasn't resolved blocks the submit. The diagnostic lists the blockers with their field IDs and labels; `useSubmit().blockers` lists them before anyone submits. Nothing was submitted.\",\n fix: \"Show `useSubmit().blockers` next to your submit button, or let the shell list them by label. Answer the required fields, fix the invalid values, and keep or take the conflicting values, then submit again.\",\n },\n },\n // gen:entries\n};\n"],"mappings":";;AAMA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAEF;;AAMA,MAAa,oBAAuD;CAClE,uBAAuB;EACrB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,2BAA2B;EACzB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,yBAAyB;EACvB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,4BAA4B;EAC1B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,8BAA8B;EAC5B,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;CACA,uBAAuB;EACrB,UAAU;EACV,OAAO;EACP,OAAO;EACP,MAAM;EACN,MAAM;GACJ,aACE;GACF,KAAK;EACP;CACF;AAEF"}
@@ -4,7 +4,7 @@ import * as z from "zod";
4
4
  * Diagnostic areas. A code is `MOSTRA_<AREA>_<NAME>`. INTERFACES §13 holds the authoritative list,
5
5
  * which only grows.
6
6
  */
7
- export type DiagnosticArea = "MANIFEST" | "BUILD" | "TYPE" | "LINT" | "DEP" | "KIT" | "FIELD" | "ACTION" | "LIVE" | "RUNTIME" | "CONSOLE" | "NETWORK" | "A11Y" | "VISUAL" | "SMOKE" | "REGRESSION" | "TERM" | "PUBLISH" | "SUBMIT" | "HOST" | "HOME" | "HYGIENE" | "SECRET" | "SHARE" | "VERIFY" | "TARGET" | "ENV" | "PLATFORM" | "ARTIFACT" | "CLI";
7
+ export type DiagnosticArea = "MANIFEST" | "BUILD" | "TYPE" | "LINT" | "DEP" | "KIT" | "FIELD" | "ACTION" | "LIVE" | "RUNTIME" | "CONSOLE" | "NETWORK" | "A11Y" | "VISUAL" | "SMOKE" | "REGRESSION" | "TERM" | "PUBLISH" | "SUBMIT" | "HOST" | "HOME" | "HYGIENE" | "SECRET" | "SHARE" | "VERIFY" | "TARGET" | "ENV" | "PLATFORM" | "ARTIFACT" | "CLI" | "REMOTE";
8
8
  /** Every diagnostic area, in INTERFACES §13 order. */
9
9
  export declare const DIAGNOSTIC_AREAS: readonly DiagnosticArea[];
10
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostic.d.ts","names":[],"sources":["../../src/diagnostics/diagnostic.ts"],"mappings":";;;;;;YAWY;;qBAiCC,2BAA2B;;;;;YAqC5B,2BAA2B;;;;;YAM3B;;YAGA;;;;;iBAqBK;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;YAIC;WACG;WAAuB;WAAuB;;WAC9C;WAA2B;;;iBAGzB;;WAEN,MAAM;;WAEN,UAAU;;WAEV;;WAEA;;WAEA,MAAM;;WAEN,WAAW;;WAEX,OAAO;;WAEP;;WAEA;;;qBAkBE,oBAAoB,EAAE,QAAQ;;qBAQ9B,iBAAiB,EAAE,QAAQ;;qBAwB3B,eAAe,EAAE,QAAQ;;qBAezB,oBAAoB,EAAE,QAAQ;;qBAW9B,YAAY,EAAE,QAAQ"}
1
+ {"version":3,"file":"diagnostic.d.ts","names":[],"sources":["../../src/diagnostics/diagnostic.ts"],"mappings":";;;;;;YAWY;;qBAkCC,2BAA2B;;;;;YAsC5B,2BAA2B;;;;;YAM3B;;YAGA;;;;;iBAqBK;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;YAIC;WACG;WAAuB;WAAuB;;WAC9C;WAA2B;;;iBAGzB;;WAEN,MAAM;;WAEN,UAAU;;WAEV;;WAEA;;WAEA,MAAM;;WAEN,WAAW;;WAEX,OAAO;;WAEP;;WAEA;;;qBAkBE,oBAAoB,EAAE,QAAQ;;qBAQ9B,iBAAiB,EAAE,QAAQ;;qBAwB3B,eAAe,EAAE,QAAQ;;qBAezB,oBAAoB,EAAE,QAAQ;;qBAW9B,YAAY,EAAE,QAAQ"}
@@ -36,7 +36,8 @@ const DIAGNOSTIC_AREAS = [
36
36
  "ENV",
37
37
  "PLATFORM",
38
38
  "ARTIFACT",
39
- "CLI"
39
+ "CLI",
40
+ "REMOTE"
40
41
  ];
41
42
  const positiveInt = z.int().min(1);
42
43
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostic.js","names":[],"sources":["../../src/diagnostics/diagnostic.ts"],"sourcesContent":["/**\n * The one diagnostic object every Mostra interface uses for errors, warnings and hints\n * (INTERFACES §1 and §13, AX-03).\n */\nimport * as z from \"zod\";\nimport { wireRegistry } from \"../wire-registry.ts\";\n\n/**\n * Diagnostic areas. A code is `MOSTRA_<AREA>_<NAME>`. INTERFACES §13 holds the authoritative list,\n * which only grows.\n */\nexport type DiagnosticArea =\n | \"MANIFEST\"\n | \"BUILD\"\n | \"TYPE\"\n | \"LINT\"\n | \"DEP\"\n | \"KIT\"\n | \"FIELD\"\n | \"ACTION\"\n | \"LIVE\"\n | \"RUNTIME\"\n | \"CONSOLE\"\n | \"NETWORK\"\n | \"A11Y\"\n | \"VISUAL\"\n | \"SMOKE\"\n | \"REGRESSION\"\n | \"TERM\"\n | \"PUBLISH\"\n | \"SUBMIT\"\n | \"HOST\"\n | \"HOME\"\n | \"HYGIENE\"\n | \"SECRET\"\n | \"SHARE\"\n | \"VERIFY\"\n | \"TARGET\"\n | \"ENV\"\n | \"PLATFORM\"\n | \"ARTIFACT\"\n | \"CLI\";\n\n/** Every diagnostic area, in INTERFACES §13 order. */\nexport const DIAGNOSTIC_AREAS: readonly DiagnosticArea[] = [\n \"MANIFEST\",\n \"BUILD\",\n \"TYPE\",\n \"LINT\",\n \"DEP\",\n \"KIT\",\n \"FIELD\",\n \"ACTION\",\n \"LIVE\",\n \"RUNTIME\",\n \"CONSOLE\",\n \"NETWORK\",\n \"A11Y\",\n \"VISUAL\",\n \"SMOKE\",\n \"REGRESSION\",\n \"TERM\",\n \"PUBLISH\",\n \"SUBMIT\",\n \"HOST\",\n \"HOME\",\n \"HYGIENE\",\n \"SECRET\",\n \"SHARE\",\n \"VERIFY\",\n \"TARGET\",\n \"ENV\",\n \"PLATFORM\",\n \"ARTIFACT\",\n \"CLI\",\n];\n\n/**\n * A diagnostic code. Codes are semver surface: once released, a code keeps its meaning and is\n * never removed (AX-03).\n */\nexport type DiagnosticCode = `MOSTRA_${DiagnosticArea}_${string}`;\n\n/**\n * How bad it is. `error` is only for definite failures; observations that might be fine are\n * warnings (D72).\n */\nexport type DiagnosticSeverity = \"error\" | \"warning\" | \"hint\";\n\n/** The stage of work that produced the diagnostic. */\nexport type DiagnosticPhase =\n | \"manifest\"\n | \"compile\"\n | \"lint\"\n | \"runtime\"\n | \"console\"\n | \"network\"\n | \"a11y\"\n | \"visual\"\n | \"smoke\"\n | \"regression\"\n | \"contract\"\n | \"publish\"\n | \"host\"\n | \"hygiene\"\n | \"platform\";\n\n/**\n * A machine-applicable fix. `range` is `[startLine, startColumn, endLine, endColumn]`, 1-based,\n * with the end exclusive.\n */\nexport interface DiagnosticFix {\n /** Replace, insert or delete text in `file`, or run `command`. */\n readonly kind: \"replace\" | \"insert\" | \"delete\" | \"command\";\n /** The file to edit, relative to the artifact or project root. */\n readonly file?: string;\n /** The span to edit. */\n readonly range?: readonly [number, number, number, number];\n /** The replacement or inserted text. */\n readonly text?: string;\n /** The command to run, for `kind: \"command\"`. */\n readonly command?: string;\n}\n\n/** Where the problem is: a source position (1-based) or a place in a rendered viewport. */\nexport type DiagnosticLocation =\n | { readonly file: string; readonly line: number; readonly column: number }\n | { readonly viewport: string; readonly selector?: string };\n\n/** One diagnostic (INTERFACES §13). */\nexport interface Diagnostic {\n /** The stable code, `MOSTRA_<AREA>_<NAME>`. */\n readonly code: DiagnosticCode;\n /** How bad it is. */\n readonly severity: DiagnosticSeverity;\n /** What is wrong, for this occurrence. */\n readonly message: string;\n /** What to do: one imperative sentence. */\n readonly hint?: string;\n /** A machine-applicable fix, when one exists. */\n readonly fix?: DiagnosticFix;\n /** Where the problem is, when it has a place. */\n readonly location?: DiagnosticLocation;\n /** The stage of work that produced it. */\n readonly phase: DiagnosticPhase;\n /** The code's documentation page: `${docsBase}/errors/${code}` (D37). */\n readonly docs: string;\n /** How many identical occurrences this one stands for, when deduplicated. */\n readonly count?: number;\n}\n\nconst positiveInt = z.int().min(1);\n\n/**\n * Codes on the wire accept any area, so a client keeps working when a newer Mostra reports a code\n * from an area it doesn't know yet. Producers are typed against {@link DiagnosticArea}.\n */\nconst codeSchema = z\n .string()\n .regex(/^MOSTRA_[A-Z0-9]+_[A-Z0-9_]+$/)\n .register(wireRegistry, {\n id: \"DiagnosticCode\",\n description: \"Stable diagnostic code: MOSTRA_<AREA>_<NAME>.\",\n }) as unknown as z.ZodType<DiagnosticCode, string>;\n\n/** The Zod schema of the `DiagnosticSeverity` type. */\nexport const DiagnosticSeverity: z.ZodType<DiagnosticSeverity, string> = z\n .enum([\"error\", \"warning\", \"hint\"])\n .register(wireRegistry, {\n id: \"DiagnosticSeverity\",\n description: \"How bad it is: error only for definite failures.\",\n });\n\n/** The Zod schema of the `DiagnosticPhase` type. */\nexport const DiagnosticPhase: z.ZodType<DiagnosticPhase, string> = z\n .enum([\n \"manifest\",\n \"compile\",\n \"lint\",\n \"runtime\",\n \"console\",\n \"network\",\n \"a11y\",\n \"visual\",\n \"smoke\",\n \"regression\",\n \"contract\",\n \"publish\",\n \"host\",\n \"hygiene\",\n \"platform\",\n ])\n .register(wireRegistry, {\n id: \"DiagnosticPhase\",\n description: \"The stage of work that produced the diagnostic.\",\n });\n\n/** The Zod schema of the `DiagnosticFix` type. */\nexport const DiagnosticFix: z.ZodType<DiagnosticFix> = z\n .object({\n kind: z.enum([\"replace\", \"insert\", \"delete\", \"command\"]),\n file: z.string().exactOptional(),\n range: z.tuple([positiveInt, positiveInt, positiveInt, positiveInt]).readonly().exactOptional(),\n text: z.string().exactOptional(),\n command: z.string().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"DiagnosticFix\",\n description:\n \"A machine-applicable fix; range is [startLine, startColumn, endLine, endColumn], 1-based, end exclusive.\",\n });\n\n/** The Zod schema of the `DiagnosticLocation` type. */\nexport const DiagnosticLocation: z.ZodType<DiagnosticLocation> = z\n .union([\n z.object({ file: z.string(), line: positiveInt, column: positiveInt }),\n z.object({ viewport: z.string(), selector: z.string().exactOptional() }),\n ])\n .register(wireRegistry, {\n id: \"DiagnosticLocation\",\n description: \"A 1-based source position, or a place in a rendered viewport.\",\n });\n\n/** The Zod schema of the `Diagnostic` type. */\nexport const Diagnostic: z.ZodType<Diagnostic> = z\n .object({\n code: codeSchema,\n severity: DiagnosticSeverity,\n message: z.string(),\n hint: z.string().exactOptional(),\n fix: DiagnosticFix.exactOptional(),\n location: DiagnosticLocation.exactOptional(),\n phase: DiagnosticPhase,\n docs: z.url(),\n count: positiveInt.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"Diagnostic\",\n description: \"One diagnostic: a stable code, severity, message, hint, fix and docs link.\",\n });\n"],"mappings":";;;;;;;;AA4CA,MAAa,mBAA8C;CACzD;CACA;CACA;CACA;CACA;C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ACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,aAAoC,EAC9C,OAAO;CACN,MAAM;CACN,UAAU;CACV,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO,CAAC,CAAC,cAAc;CAC/B,KAAK,cAAc,cAAc;CACjC,UAAU,mBAAmB,cAAc;CAC3C,OAAO;CACP,MAAM,EAAE,IAAI;CACZ,OAAO,YAAY,cAAc;AACnC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC"}
1
+ {"version":3,"file":"diagnostic.js","names":[],"sources":["../../src/diagnostics/diagnostic.ts"],"sourcesContent":["/**\n * The one diagnostic object every Mostra interface uses for errors, warnings and hints\n * (INTERFACES §1 and §13, AX-03).\n */\nimport * as z from \"zod\";\nimport { wireRegistry } from \"../wire-registry.ts\";\n\n/**\n * Diagnostic areas. A code is `MOSTRA_<AREA>_<NAME>`. INTERFACES §13 holds the authoritative list,\n * which only grows.\n */\nexport type DiagnosticArea =\n | \"MANIFEST\"\n | \"BUILD\"\n | \"TYPE\"\n | \"LINT\"\n | \"DEP\"\n | \"KIT\"\n | \"FIELD\"\n | \"ACTION\"\n | \"LIVE\"\n | \"RUNTIME\"\n | \"CONSOLE\"\n | \"NETWORK\"\n | \"A11Y\"\n | \"VISUAL\"\n | \"SMOKE\"\n | \"REGRESSION\"\n | \"TERM\"\n | \"PUBLISH\"\n | \"SUBMIT\"\n | \"HOST\"\n | \"HOME\"\n | \"HYGIENE\"\n | \"SECRET\"\n | \"SHARE\"\n | \"VERIFY\"\n | \"TARGET\"\n | \"ENV\"\n | \"PLATFORM\"\n | \"ARTIFACT\"\n | \"CLI\"\n | \"REMOTE\";\n\n/** Every diagnostic area, in INTERFACES §13 order. */\nexport const DIAGNOSTIC_AREAS: readonly DiagnosticArea[] = [\n \"MANIFEST\",\n \"BUILD\",\n \"TYPE\",\n \"LINT\",\n \"DEP\",\n \"KIT\",\n \"FIELD\",\n \"ACTION\",\n \"LIVE\",\n \"RUNTIME\",\n \"CONSOLE\",\n \"NETWORK\",\n \"A11Y\",\n \"VISUAL\",\n \"SMOKE\",\n \"REGRESSION\",\n \"TERM\",\n \"PUBLISH\",\n \"SUBMIT\",\n \"HOST\",\n \"HOME\",\n \"HYGIENE\",\n \"SECRET\",\n \"SHARE\",\n \"VERIFY\",\n \"TARGET\",\n \"ENV\",\n \"PLATFORM\",\n \"ARTIFACT\",\n \"CLI\",\n \"REMOTE\",\n];\n\n/**\n * A diagnostic code. Codes are semver surface: once released, a code keeps its meaning and is\n * never removed (AX-03).\n */\nexport type DiagnosticCode = `MOSTRA_${DiagnosticArea}_${string}`;\n\n/**\n * How bad it is. `error` is only for definite failures; observations that might be fine are\n * warnings (D72).\n */\nexport type DiagnosticSeverity = \"error\" | \"warning\" | \"hint\";\n\n/** The stage of work that produced the diagnostic. */\nexport type DiagnosticPhase =\n | \"manifest\"\n | \"compile\"\n | \"lint\"\n | \"runtime\"\n | \"console\"\n | \"network\"\n | \"a11y\"\n | \"visual\"\n | \"smoke\"\n | \"regression\"\n | \"contract\"\n | \"publish\"\n | \"host\"\n | \"hygiene\"\n | \"platform\";\n\n/**\n * A machine-applicable fix. `range` is `[startLine, startColumn, endLine, endColumn]`, 1-based,\n * with the end exclusive.\n */\nexport interface DiagnosticFix {\n /** Replace, insert or delete text in `file`, or run `command`. */\n readonly kind: \"replace\" | \"insert\" | \"delete\" | \"command\";\n /** The file to edit, relative to the artifact or project root. */\n readonly file?: string;\n /** The span to edit. */\n readonly range?: readonly [number, number, number, number];\n /** The replacement or inserted text. */\n readonly text?: string;\n /** The command to run, for `kind: \"command\"`. */\n readonly command?: string;\n}\n\n/** Where the problem is: a source position (1-based) or a place in a rendered viewport. */\nexport type DiagnosticLocation =\n | { readonly file: string; readonly line: number; readonly column: number }\n | { readonly viewport: string; readonly selector?: string };\n\n/** One diagnostic (INTERFACES §13). */\nexport interface Diagnostic {\n /** The stable code, `MOSTRA_<AREA>_<NAME>`. */\n readonly code: DiagnosticCode;\n /** How bad it is. */\n readonly severity: DiagnosticSeverity;\n /** What is wrong, for this occurrence. */\n readonly message: string;\n /** What to do: one imperative sentence. */\n readonly hint?: string;\n /** A machine-applicable fix, when one exists. */\n readonly fix?: DiagnosticFix;\n /** Where the problem is, when it has a place. */\n readonly location?: DiagnosticLocation;\n /** The stage of work that produced it. */\n readonly phase: DiagnosticPhase;\n /** The code's documentation page: `${docsBase}/errors/${code}` (D37). */\n readonly docs: string;\n /** How many identical occurrences this one stands for, when deduplicated. */\n readonly count?: number;\n}\n\nconst positiveInt = z.int().min(1);\n\n/**\n * Codes on the wire accept any area, so a client keeps working when a newer Mostra reports a code\n * from an area it doesn't know yet. Producers are typed against {@link DiagnosticArea}.\n */\nconst codeSchema = z\n .string()\n .regex(/^MOSTRA_[A-Z0-9]+_[A-Z0-9_]+$/)\n .register(wireRegistry, {\n id: \"DiagnosticCode\",\n description: \"Stable diagnostic code: MOSTRA_<AREA>_<NAME>.\",\n }) as unknown as z.ZodType<DiagnosticCode, string>;\n\n/** The Zod schema of the `DiagnosticSeverity` type. */\nexport const DiagnosticSeverity: z.ZodType<DiagnosticSeverity, string> = z\n .enum([\"error\", \"warning\", \"hint\"])\n .register(wireRegistry, {\n id: \"DiagnosticSeverity\",\n description: \"How bad it is: error only for definite failures.\",\n });\n\n/** The Zod schema of the `DiagnosticPhase` type. */\nexport const DiagnosticPhase: z.ZodType<DiagnosticPhase, string> = z\n .enum([\n \"manifest\",\n \"compile\",\n \"lint\",\n \"runtime\",\n \"console\",\n \"network\",\n \"a11y\",\n \"visual\",\n \"smoke\",\n \"regression\",\n \"contract\",\n \"publish\",\n \"host\",\n \"hygiene\",\n \"platform\",\n ])\n .register(wireRegistry, {\n id: \"DiagnosticPhase\",\n description: \"The stage of work that produced the diagnostic.\",\n });\n\n/** The Zod schema of the `DiagnosticFix` type. */\nexport const DiagnosticFix: z.ZodType<DiagnosticFix> = z\n .object({\n kind: z.enum([\"replace\", \"insert\", \"delete\", \"command\"]),\n file: z.string().exactOptional(),\n range: z.tuple([positiveInt, positiveInt, positiveInt, positiveInt]).readonly().exactOptional(),\n text: z.string().exactOptional(),\n command: z.string().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"DiagnosticFix\",\n description:\n \"A machine-applicable fix; range is [startLine, startColumn, endLine, endColumn], 1-based, end exclusive.\",\n });\n\n/** The Zod schema of the `DiagnosticLocation` type. */\nexport const DiagnosticLocation: z.ZodType<DiagnosticLocation> = z\n .union([\n z.object({ file: z.string(), line: positiveInt, column: positiveInt }),\n z.object({ viewport: z.string(), selector: z.string().exactOptional() }),\n ])\n .register(wireRegistry, {\n id: \"DiagnosticLocation\",\n description: \"A 1-based source position, or a place in a rendered viewport.\",\n });\n\n/** The Zod schema of the `Diagnostic` type. */\nexport const Diagnostic: z.ZodType<Diagnostic> = z\n .object({\n code: codeSchema,\n severity: DiagnosticSeverity,\n message: z.string(),\n hint: z.string().exactOptional(),\n fix: DiagnosticFix.exactOptional(),\n location: DiagnosticLocation.exactOptional(),\n phase: DiagnosticPhase,\n docs: z.url(),\n count: positiveInt.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"Diagnostic\",\n description: \"One diagnostic: a stable code, severity, message, hint, fix and docs link.\",\n });\n"],"mappings":";;;;;;;;AA6CA,MAAa,mBAA8C;CACzD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AA4EA,MAAM,cAAc,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;;;;;AAMjC,MAAM,aAAa,EAChB,OAAO,CAAC,CACR,MAAM,+BAA+B,CAAC,CACtC,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,qBAA4D,EACtE,KAAK;CAAC;CAAS;CAAW;AAAM,CAAC,CAAC,CAClC,SAAS,c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src/duration.d.ts
3
+ /**
4
+ * A duration: a positive whole number and a unit, `s`, `m`, `h` or `d` (`30m`, `24h`, `7d`), as
5
+ * INTERFACES §1 writes durations in flags and manifests.
6
+ */
7
+ export type Duration = `${number}${"s" | "m" | "h" | "d"}`;
8
+ /** The Zod schema of the `Duration` type. */
9
+ export declare const Duration: z.ZodType<Duration>;
10
+ /** The length of a `Duration` in milliseconds. */
11
+ export declare function durationMs(duration: Duration): number;
12
+ //#endregion
13
+ //# sourceMappingURL=duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.d.ts","names":[],"sources":["../src/duration.ts"],"mappings":";;;;;;YAWY;;qBAGC,UAAU,EAAE,QAAQ;;wBAWjB,WAAW,UAAU"}
@@ -0,0 +1,27 @@
1
+ import { wireRegistry } from "./wire-registry.js";
2
+ import * as z from "zod";
3
+ //#region src/duration.ts
4
+ /**
5
+ * Durations as INTERFACES §1 writes them in flags and manifests: a module of its own, so the
6
+ * manifest and capability links share it without either pulling the other into a browser bundle.
7
+ */
8
+ /** The Zod schema of the `Duration` type. */
9
+ const Duration = z.string().regex(/^[1-9][0-9]{0,8}[smhd]$/).register(wireRegistry, {
10
+ id: "Duration",
11
+ description: "A duration: a positive whole number and s, m, h or d, such as 30m, 24h or 7d."
12
+ });
13
+ const UNIT_MS = {
14
+ s: 1e3,
15
+ m: 6e4,
16
+ h: 36e5,
17
+ d: 864e5
18
+ };
19
+ /** The length of a `Duration` in milliseconds. */
20
+ function durationMs(duration) {
21
+ const unit = duration.slice(-1);
22
+ return Number(duration.slice(0, -1)) * UNIT_MS[unit];
23
+ }
24
+ //#endregion
25
+ export { Duration, durationMs };
26
+
27
+ //# sourceMappingURL=duration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.js","names":[],"sources":["../src/duration.ts"],"sourcesContent":["/**\n * Durations as INTERFACES §1 writes them in flags and manifests: a module of its own, so the\n * manifest and capability links share it without either pulling the other into a browser bundle.\n */\nimport * as z from \"zod\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/**\n * A duration: a positive whole number and a unit, `s`, `m`, `h` or `d` (`30m`, `24h`, `7d`), as\n * INTERFACES §1 writes durations in flags and manifests.\n */\nexport type Duration = `${number}${\"s\" | \"m\" | \"h\" | \"d\"}`;\n\n/** The Zod schema of the `Duration` type. */\nexport const Duration: z.ZodType<Duration> = z\n .string()\n .regex(/^[1-9][0-9]{0,8}[smhd]$/)\n .register(wireRegistry, {\n id: \"Duration\",\n description: \"A duration: a positive whole number and s, m, h or d, such as 30m, 24h or 7d.\",\n }) as z.ZodType<Duration>;\n\nconst UNIT_MS = { s: 1_000, m: 60_000, h: 3_600_000, d: 86_400_000 } as const;\n\n/** The length of a `Duration` in milliseconds. */\nexport function durationMs(duration: Duration): number {\n const unit = duration.slice(-1) as keyof typeof UNIT_MS;\n return Number(duration.slice(0, -1)) * UNIT_MS[unit];\n}\n"],"mappings":";;;;;;;;AAcA,MAAa,WAAgC,EAC1C,OAAO,CAAC,CACR,MAAM,yBAAyB,CAAC,CAChC,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;AAEH,MAAM,UAAU;CAAE,GAAG;CAAO,GAAG;CAAQ,GAAG;CAAW,GAAG;AAAW;;AAGnE,SAAgB,WAAW,UAA4B;CACrD,MAAM,OAAO,SAAS,MAAM,EAAE;CAC9B,OAAO,OAAO,SAAS,MAAM,GAAG,EAAE,CAAC,IAAI,QAAQ;AACjD"}
package/dist/hygiene.d.ts CHANGED
@@ -17,8 +17,11 @@ export interface RequestPolicy {
17
17
  * `Origin` and a JSON content type, but no CSRF token yet.
18
18
  * - `mutation`: any other state change: `Origin`, a JSON content type and the session's CSRF
19
19
  * token in `X-Mostra-CSRF`.
20
+ * - `rpc`: a JSON-RPC POST from a program that holds a bearer token (`mostra mcp --http`, D164): a
21
+ * foreign `Origin` is refused and none is fine, since browsers send one on every POST; a JSON
22
+ * content type. The endpoint checks the token itself, as it checks a session.
20
23
  */
21
- export type RequestIntent = "read" | "stream" | "upgrade" | "exchange" | "mutation";
24
+ export type RequestIntent = "read" | "stream" | "upgrade" | "exchange" | "mutation" | "rpc";
22
25
  /** One request as the transport received it. */
23
26
  export interface RequestFacts {
24
27
  /** The method, as sent. */
@@ -1 +1 @@
1
- {"version":3,"file":"hygiene.d.ts","names":[],"sources":["../src/hygiene.ts"],"mappings":";;;;iBAoBiB;;WAEN;;WAEA;;;;;;;;;;;;YAaC;;iBAGK;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;WAET;;;iBAIM;;WAEN;;WAEA,YAAY;;;qBAIV;;wBAoBG,QAAQ,MAAM,uBAAuB,iBAAiB,kBAAkB;;wBAexE,UAAU,WAAW;;;;;;wBAcrB,SAAS;;wBAiBT,YACd,iDACA;;wBAOc,kBAAkB;;;;;;;wBAWlB,aAAa,QAAQ,eAAe,SAAS,eAAe"}
1
+ {"version":3,"file":"hygiene.d.ts","names":[],"sources":["../src/hygiene.ts"],"mappings":";;;;iBAoBiB;;WAEN;;WAEA;;;;;;;;;;;;;;;YAgBC;;iBAGK;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;WAET;;;iBAIM;;WAEN;;WAEA,YAAY;;;qBAIV;;wBAoBG,QAAQ,MAAM,uBAAuB,iBAAiB,kBAAkB;;wBAexE,UAAU,WAAW;;;;;;wBAcrB,SAAS;;wBAiBT,YACd,iDACA;;wBAOc,kBAAkB;;;;;;;wBAWlB,aAAa,QAAQ,eAAe,SAAS,eAAe"}
package/dist/hygiene.js CHANGED
@@ -112,6 +112,10 @@ function checkRequest(policy, request) {
112
112
  case "read":
113
113
  if (origin !== void 0 && origin !== policy.origin) return refusal("MOSTRA_HYGIENE_ORIGIN_REFUSED", "The request came from another origin.");
114
114
  return;
115
+ case "rpc":
116
+ if (origin !== void 0 && origin !== policy.origin) return refusal("MOSTRA_HYGIENE_ORIGIN_REFUSED", "The request came from another origin.");
117
+ if (!isJsonContentType(headerValue(request.headers, "content-type"))) return refusal("MOSTRA_HYGIENE_CONTENT_TYPE", "The request's body isn't declared as JSON.");
118
+ return;
115
119
  case "stream": {
116
120
  const site = headerValue(request.headers, "sec-fetch-site");
117
121
  return (origin === void 0 ? site === "same-origin" : origin === policy.origin) ? void 0 : refusal("MOSTRA_HYGIENE_ORIGIN_REFUSED", "A stream must be opened by its own origin.");
@@ -1 +1 @@
1
- {"version":3,"file":"hygiene.js","names":[],"sources":["../src/hygiene.ts"],"sourcesContent":["/**\n * Request hygiene (D06, ARCHITECTURE §10, HY-01): the checks every Mostra HTTP endpoint applies\n * before it acts on a request, as pure functions with no I/O. The gateway runs them on every\n * request, and `mostra mcp --http` (WP-15) runs the same code (D96), so a request a stranger's\n * page could send is refused the same way everywhere. None of them limits what an artifact, an\n * agent or a viewer may do; they only make sure a request comes from the page it claims to.\n *\n * ```ts\n * const refusal = checkRequest(\n * { origin: \"http://127.0.0.1:23456\", hosts: [\"127.0.0.1:23456\"] },\n * { method: \"POST\", target: \"/a/art_…/_mostra/ticket\", headers, intent: \"mutation\", csrf },\n * );\n * if (refusal) return respond(refusal.status, refusal.diagnostic);\n * ```\n */\nimport { type HygieneDiagnosticCode, hygieneDiagnostics } from \"./diagnostics/codes/hygiene.ts\";\nimport type { Diagnostic } from \"./diagnostics/diagnostic.ts\";\nimport { buildDiagnostic } from \"./diagnostics/spec.ts\";\n\n/** What one listener serves: its own origin and the exact `Host` values it accepts. */\nexport interface RequestPolicy {\n /** The listener's origin, such as `http://127.0.0.1:23456`; `Origin` headers must equal it. */\n readonly origin: string;\n /** Every `host:port` this listener answers to (lowercase): its URL host, plus registered tunnels. */\n readonly hosts: readonly string[];\n}\n\n/**\n * What a request is for, which decides the checks beyond the envelope:\n * - `read`: a GET or HEAD of a page or file; a foreign `Origin` is refused, none is fine.\n * - `stream`: an event stream (GET); same-origin only, by `Origin` or `Sec-Fetch-Site`.\n * - `upgrade`: a WebSocket upgrade; `Origin` must be present and equal.\n * - `exchange`: a mutation that starts a session (a capability token or ticket in the body):\n * `Origin` and a JSON content type, but no CSRF token yet.\n * - `mutation`: any other state change: `Origin`, a JSON content type and the session's CSRF\n * token in `X-Mostra-CSRF`.\n */\nexport type RequestIntent = \"read\" | \"stream\" | \"upgrade\" | \"exchange\" | \"mutation\";\n\n/** One request as the transport received it. */\nexport interface RequestFacts {\n /** The method, as sent. */\n readonly method: string;\n /** The request target exactly as sent: an origin-form path with its query. */\n readonly target: string;\n /** Every header as `[name, value]` in arrival order, so repeated headers are visible. */\n readonly headers: readonly (readonly [string, string])[];\n /** The intent the matched route declared; omit to check only the envelope. */\n readonly intent?: RequestIntent;\n /** The session's CSRF token, for `mutation` requests. */\n readonly csrf?: string;\n}\n\n/** A refused request: the HTTP status to answer with and the diagnostic for its body. */\nexport interface Refusal {\n /** The HTTP status: 400, 401, 403, 404, 410, 415, 421 or 429. */\n readonly status: number;\n /** What was refused and why, for the response body and the log. */\n readonly diagnostic: Diagnostic;\n}\n\n/** The header that carries a session's CSRF token on every mutation (D98). */\nexport const CSRF_HEADER = \"x-mostra-csrf\";\n\nconst STATUS: Readonly<Record<HygieneDiagnosticCode, number>> = {\n MOSTRA_HYGIENE_HOST_REFUSED: 421,\n MOSTRA_HYGIENE_ORIGIN_REFUSED: 403,\n MOSTRA_HYGIENE_CSRF_MISSING: 403,\n MOSTRA_HYGIENE_CONTENT_TYPE: 415,\n MOSTRA_HYGIENE_REQUEST_MALFORMED: 400,\n MOSTRA_HYGIENE_SESSION_MISSING: 401,\n MOSTRA_HYGIENE_TOKEN_INVALID: 401,\n MOSTRA_HYGIENE_TOKEN_REVOKED: 410,\n MOSTRA_HYGIENE_SCOPE_DENIED: 403,\n MOSTRA_HYGIENE_RATE_LIMITED: 429,\n MOSTRA_HYGIENE_NOT_SERVED: 404,\n MOSTRA_HYGIENE_SESSION_CONFLICT: 409,\n MOSTRA_HYGIENE_HEADERS_TOO_LARGE: 431,\n MOSTRA_HYGIENE_FRAME_SESSION: 403,\n};\n\n/** Builds a refusal with the status the code's HTTP mapping gives (FAILURE_MODEL §8). */\nexport function refusal(code: HygieneDiagnosticCode, message: string, status?: number): Refusal {\n return {\n status: status ?? STATUS[code],\n diagnostic: buildDiagnostic(code, hygieneDiagnostics[code], { message }),\n };\n}\n\n/** Headers that must appear at most once: a second copy could mean two different things. */\nconst SINGLE = new Set([\"host\", \"origin\", \"content-type\", \"content-length\", CSRF_HEADER, \"cookie\"]);\n\n/** Characters no header value or path may carry: controls other than tab, and DEL. */\n// biome-ignore lint/suspicious/noControlCharactersInRegex: matching control characters is the point.\nconst CONTROL = /[\\u0000-\\u0008\\u000a-\\u001f\\u007f]/;\n\n/** Constant-time comparison of two strings, so timing reveals nothing about a secret. */\nexport function safeEqual(a: string, b: string): boolean {\n let difference = a.length ^ b.length;\n const length = Math.max(a.length, b.length);\n for (let index = 0; index < length; index++) {\n difference |= (a.charCodeAt(index) | 0) ^ (b.charCodeAt(index) | 0);\n }\n return difference === 0;\n}\n\n/**\n * The path a request target names, decoded, or `undefined` when it isn't a safe origin-form path:\n * absolute and authority forms, `*`, encoded `/` or `\\`, `.` or `..` segments (encoded or not),\n * NUL and other controls, and invalid percent-encoding are all refused.\n */\nexport function safePath(target: string): string | undefined {\n if (!target.startsWith(\"/\") || target.startsWith(\"//\")) return undefined;\n const end = target.search(/[?#]/);\n const raw = end < 0 ? target : target.slice(0, end);\n if (/%(2f|5c)/i.test(raw) || raw.includes(\"\\\\\")) return undefined;\n let path: string;\n try {\n path = decodeURIComponent(raw);\n } catch {\n return undefined;\n }\n if (CONTROL.test(path) || path.includes(\"\\u0000\")) return undefined;\n if (path.split(\"/\").some((segment) => segment === \".\" || segment === \"..\")) return undefined;\n return path;\n}\n\n/** The value of a header (case-insensitive name), or `undefined`. */\nexport function headerValue(\n headers: readonly (readonly [string, string])[],\n name: string,\n): string | undefined {\n const lower = name.toLowerCase();\n return headers.find(([key]) => key.toLowerCase() === lower)?.[1];\n}\n\n/** Whether a `Content-Type` value is JSON (`application/json`, any parameters). */\nexport function isJsonContentType(value: string | undefined): boolean {\n if (value === undefined) return false;\n return value.split(\";\")[0]?.trim().toLowerCase() === \"application/json\";\n}\n\n/**\n * Checks a request's envelope (the `Host` allowlist, the request target, repeated and malformed\n * headers) and, when `intent` is given, what that intent needs: `Origin`, the JSON content type\n * and the CSRF token. Returns the first refusal, or `undefined` when the request may proceed.\n * Session, token and scope checks follow in the endpoint, which knows its session.\n */\nexport function checkRequest(policy: RequestPolicy, request: RequestFacts): Refusal | undefined {\n const counts = new Map<string, number>();\n for (const [name, value] of request.headers) {\n const lower = name.toLowerCase();\n counts.set(lower, (counts.get(lower) ?? 0) + 1);\n if (CONTROL.test(value)) {\n return refusal(\n \"MOSTRA_HYGIENE_REQUEST_MALFORMED\",\n `The ${lower} header has control characters.`,\n );\n }\n }\n for (const name of SINGLE) {\n if ((counts.get(name) ?? 0) > 1) {\n return refusal(\"MOSTRA_HYGIENE_REQUEST_MALFORMED\", `The request repeats the ${name} header.`);\n }\n }\n const host = headerValue(request.headers, \"host\")?.toLowerCase();\n if (host === undefined || !policy.hosts.includes(host)) {\n return refusal(\n \"MOSTRA_HYGIENE_HOST_REFUSED\",\n host === undefined\n ? \"The request has no Host header.\"\n : \"The request's Host isn't one this listener serves.\",\n );\n }\n if (safePath(request.target) === undefined) {\n return refusal(\n \"MOSTRA_HYGIENE_REQUEST_MALFORMED\",\n \"The request target isn't a plain path inside the served tree.\",\n );\n }\n if (request.intent === undefined) return undefined;\n\n const origin = headerValue(request.headers, \"origin\");\n switch (request.intent) {\n case \"read\":\n if (origin !== undefined && origin !== policy.origin) {\n return refusal(\"MOSTRA_HYGIENE_ORIGIN_REFUSED\", \"The request came from another origin.\");\n }\n return undefined;\n case \"stream\": {\n const site = headerValue(request.headers, \"sec-fetch-site\");\n const sameOrigin = origin === undefined ? site === \"same-origin\" : origin === policy.origin;\n return sameOrigin\n ? undefined\n : refusal(\"MOSTRA_HYGIENE_ORIGIN_REFUSED\", \"A stream must be opened by its own origin.\");\n }\n case \"upgrade\":\n case \"exchange\":\n case \"mutation\": {\n if (origin !== policy.origin) {\n return refusal(\n \"MOSTRA_HYGIENE_ORIGIN_REFUSED\",\n origin === undefined\n ? \"The request has no Origin header.\"\n : \"The request came from another origin.\",\n );\n }\n if (request.intent === \"upgrade\") return undefined;\n if (!isJsonContentType(headerValue(request.headers, \"content-type\"))) {\n return refusal(\"MOSTRA_HYGIENE_CONTENT_TYPE\", \"The request's body isn't declared as JSON.\");\n }\n if (request.intent === \"exchange\") return undefined;\n const sent = headerValue(request.headers, CSRF_HEADER);\n if (request.csrf === undefined || sent === undefined || !safeEqual(sent, request.csrf)) {\n return refusal(\n \"MOSTRA_HYGIENE_CSRF_MISSING\",\n sent === undefined\n ? `The request has no ${CSRF_HEADER} header.`\n : `The request's ${CSRF_HEADER} header doesn't match its session.`,\n );\n }\n return undefined;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8DA,MAAa,cAAc;AAE3B,MAAM,SAA0D;CAC9D,6BAA6B;CAC7B,+BAA+B;CAC/B,6BAA6B;CAC7B,6BAA6B;CAC7B,kCAAkC;CAClC,gCAAgC;CAChC,8BAA8B;CAC9B,8BAA8B;CAC9B,6BAA6B;CAC7B,6BAA6B;CAC7B,2BAA2B;CAC3B,iCAAiC;CACjC,kCAAkC;CAClC,8BAA8B;AAChC;;AAGA,SAAgB,QAAQ,MAA6B,SAAiB,QAA0B;CAC9F,OAAO;EACL,QAAQ,UAAU,OAAO;EACzB,YAAY,gBAAgB,MAAM,mBAAmB,OAAO,EAAE,QAAQ,CAAC;CACzE;AACF;;AAGA,MAAM,yBAAS,IAAI,IAAI;CAAC;CAAQ;CAAU;CAAgB;CAAkB;CAAa;AAAQ,CAAC;;AAIlG,MAAM,UAAU;;AAGhB,SAAgB,UAAU,GAAW,GAAoB;CACvD,IAAI,aAAa,EAAE,SAAS,EAAE;CAC9B,MAAM,SAAS,KAAK,IAAI,EAAE,QAAQ,EAAE,MAAM;CAC1C,KAAK,IAAI,QAAQ,GAAG,QA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AAsB,YAAY,YAClC,iBAAiB,YAAY,mCACnC;GAEF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"hygiene.js","names":[],"sources":["../src/hygiene.ts"],"sourcesContent":["/**\n * Request hygiene (D06, ARCHITECTURE §10, HY-01): the checks every Mostra HTTP endpoint applies\n * before it acts on a request, as pure functions with no I/O. The gateway runs them on every\n * request, and `mostra mcp --http` (WP-15) runs the same code (D96), so a request a stranger's\n * page could send is refused the same way everywhere. None of them limits what an artifact, an\n * agent or a viewer may do; they only make sure a request comes from the page it claims to.\n *\n * ```ts\n * const refusal = checkRequest(\n * { origin: \"http://127.0.0.1:23456\", hosts: [\"127.0.0.1:23456\"] },\n * { method: \"POST\", target: \"/a/art_…/_mostra/ticket\", headers, intent: \"mutation\", csrf },\n * );\n * if (refusal) return respond(refusal.status, refusal.diagnostic);\n * ```\n */\nimport { type HygieneDiagnosticCode, hygieneDiagnostics } from \"./diagnostics/codes/hygiene.ts\";\nimport type { Diagnostic } from \"./diagnostics/diagnostic.ts\";\nimport { buildDiagnostic } from \"./diagnostics/spec.ts\";\n\n/** What one listener serves: its own origin and the exact `Host` values it accepts. */\nexport interface RequestPolicy {\n /** The listener's origin, such as `http://127.0.0.1:23456`; `Origin` headers must equal it. */\n readonly origin: string;\n /** Every `host:port` this listener answers to (lowercase): its URL host, plus registered tunnels. */\n readonly hosts: readonly string[];\n}\n\n/**\n * What a request is for, which decides the checks beyond the envelope:\n * - `read`: a GET or HEAD of a page or file; a foreign `Origin` is refused, none is fine.\n * - `stream`: an event stream (GET); same-origin only, by `Origin` or `Sec-Fetch-Site`.\n * - `upgrade`: a WebSocket upgrade; `Origin` must be present and equal.\n * - `exchange`: a mutation that starts a session (a capability token or ticket in the body):\n * `Origin` and a JSON content type, but no CSRF token yet.\n * - `mutation`: any other state change: `Origin`, a JSON content type and the session's CSRF\n * token in `X-Mostra-CSRF`.\n * - `rpc`: a JSON-RPC POST from a program that holds a bearer token (`mostra mcp --http`, D164): a\n * foreign `Origin` is refused and none is fine, since browsers send one on every POST; a JSON\n * content type. The endpoint checks the token itself, as it checks a session.\n */\nexport type RequestIntent = \"read\" | \"stream\" | \"upgrade\" | \"exchange\" | \"mutation\" | \"rpc\";\n\n/** One request as the transport received it. */\nexport interface RequestFacts {\n /** The method, as sent. */\n readonly method: string;\n /** The request target exactly as sent: an origin-form path with its query. */\n readonly target: string;\n /** Every header as `[name, value]` in arrival order, so repeated headers are visible. */\n readonly headers: readonly (readonly [string, string])[];\n /** The intent the matched route declared; omit to check only the envelope. */\n readonly intent?: RequestIntent;\n /** The session's CSRF token, for `mutation` requests. */\n readonly csrf?: string;\n}\n\n/** A refused request: the HTTP status to answer with and the diagnostic for its body. */\nexport interface Refusal {\n /** The HTTP status: 400, 401, 403, 404, 410, 415, 421 or 429. */\n readonly status: number;\n /** What was refused and why, for the response body and the log. */\n readonly diagnostic: Diagnostic;\n}\n\n/** The header that carries a session's CSRF token on every mutation (D98). */\nexport const CSRF_HEADER = \"x-mostra-csrf\";\n\nconst STATUS: Readonly<Record<HygieneDiagnosticCode, number>> = {\n MOSTRA_HYGIENE_HOST_REFUSED: 421,\n MOSTRA_HYGIENE_ORIGIN_REFUSED: 403,\n MOSTRA_HYGIENE_CSRF_MISSING: 403,\n MOSTRA_HYGIENE_CONTENT_TYPE: 415,\n MOSTRA_HYGIENE_REQUEST_MALFORMED: 400,\n MOSTRA_HYGIENE_SESSION_MISSING: 401,\n MOSTRA_HYGIENE_TOKEN_INVALID: 401,\n MOSTRA_HYGIENE_TOKEN_REVOKED: 410,\n MOSTRA_HYGIENE_SCOPE_DENIED: 403,\n MOSTRA_HYGIENE_RATE_LIMITED: 429,\n MOSTRA_HYGIENE_NOT_SERVED: 404,\n MOSTRA_HYGIENE_SESSION_CONFLICT: 409,\n MOSTRA_HYGIENE_HEADERS_TOO_LARGE: 431,\n MOSTRA_HYGIENE_FRAME_SESSION: 403,\n};\n\n/** Builds a refusal with the status the code's HTTP mapping gives (FAILURE_MODEL §8). */\nexport function refusal(code: HygieneDiagnosticCode, message: string, status?: number): Refusal {\n return {\n status: status ?? STATUS[code],\n diagnostic: buildDiagnostic(code, hygieneDiagnostics[code], { message }),\n };\n}\n\n/** Headers that must appear at most once: a second copy could mean two different things. */\nconst SINGLE = new Set([\"host\", \"origin\", \"content-type\", \"content-length\", CSRF_HEADER, \"cookie\"]);\n\n/** Characters no header value or path may carry: controls other than tab, and DEL. */\n// biome-ignore lint/suspicious/noControlCharactersInRegex: matching control characters is the point.\nconst CONTROL = /[\\u0000-\\u0008\\u000a-\\u001f\\u007f]/;\n\n/** Constant-time comparison of two strings, so timing reveals nothing about a secret. */\nexport function safeEqual(a: string, b: string): boolean {\n let difference = a.length ^ b.length;\n const length = Math.max(a.length, b.length);\n for (let index = 0; index < length; index++) {\n difference |= (a.charCodeAt(index) | 0) ^ (b.charCodeAt(index) | 0);\n }\n return difference === 0;\n}\n\n/**\n * The path a request target names, decoded, or `undefined` when it isn't a safe origin-form path:\n * absolute and authority forms, `*`, encoded `/` or `\\`, `.` or `..` segments (encoded or not),\n * NUL and other controls, and invalid percent-encoding are all refused.\n */\nexport function safePath(target: string): string | undefined {\n if (!target.startsWith(\"/\") || target.startsWith(\"//\")) return undefined;\n const end = target.search(/[?#]/);\n const raw = end < 0 ? target : target.slice(0, end);\n if (/%(2f|5c)/i.test(raw) || raw.includes(\"\\\\\")) return undefined;\n let path: string;\n try {\n path = decodeURIComponent(raw);\n } catch {\n return undefined;\n }\n if (CONTROL.test(path) || path.includes(\"\\u0000\")) return undefined;\n if (path.split(\"/\").some((segment) => segment === \".\" || segment === \"..\")) return undefined;\n return path;\n}\n\n/** The value of a header (case-insensitive name), or `undefined`. */\nexport function headerValue(\n headers: readonly (readonly [string, string])[],\n name: string,\n): string | undefined {\n const lower = name.toLowerCase();\n return headers.find(([key]) => key.toLowerCase() === lower)?.[1];\n}\n\n/** Whether a `Content-Type` value is JSON (`application/json`, any parameters). */\nexport function isJsonContentType(value: string | undefined): boolean {\n if (value === undefined) return false;\n return value.split(\";\")[0]?.trim().toLowerCase() === \"application/json\";\n}\n\n/**\n * Checks a request's envelope (the `Host` allowlist, the request target, repeated and malformed\n * headers) and, when `intent` is given, what that intent needs: `Origin`, the JSON content type\n * and the CSRF token. Returns the first refusal, or `undefined` when the request may proceed.\n * Session, token and scope checks follow in the endpoint, which knows its session.\n */\nexport function checkRequest(policy: RequestPolicy, request: RequestFacts): Refusal | undefined {\n const counts = new Map<string, number>();\n for (const [name, value] of request.headers) {\n const lower = name.toLowerCase();\n counts.set(lower, (counts.get(lower) ?? 0) + 1);\n if (CONTROL.test(value)) {\n return refusal(\n \"MOSTRA_HYGIENE_REQUEST_MALFORMED\",\n `The ${lower} header has control characters.`,\n );\n }\n }\n for (const name of SINGLE) {\n if ((counts.get(name) ?? 0) > 1) {\n return refusal(\"MOSTRA_HYGIENE_REQUEST_MALFORMED\", `The request repeats the ${name} header.`);\n }\n }\n const host = headerValue(request.headers, \"host\")?.toLowerCase();\n if (host === undefined || !policy.hosts.includes(host)) {\n return refusal(\n \"MOSTRA_HYGIENE_HOST_REFUSED\",\n host === undefined\n ? \"The request has no Host header.\"\n : \"The request's Host isn't one this listener serves.\",\n );\n }\n if (safePath(request.target) === undefined) {\n return refusal(\n \"MOSTRA_HYGIENE_REQUEST_MALFORMED\",\n \"The request target isn't a plain path inside the served tree.\",\n );\n }\n if (request.intent === undefined) return undefined;\n\n const origin = headerValue(request.headers, \"origin\");\n switch (request.intent) {\n case \"read\":\n if (origin !== undefined && origin !== policy.origin) {\n return refusal(\"MOSTRA_HYGIENE_ORIGIN_REFUSED\", \"The request came from another origin.\");\n }\n return undefined;\n case \"rpc\":\n if (origin !== undefined && origin !== policy.origin) {\n return refusal(\"MOSTRA_HYGIENE_ORIGIN_REFUSED\", \"The request came from another origin.\");\n }\n if (!isJsonContentType(headerValue(request.headers, \"content-type\"))) {\n return refusal(\"MOSTRA_HYGIENE_CONTENT_TYPE\", \"The request's body isn't declared as JSON.\");\n }\n return undefined;\n case \"stream\": {\n const site = headerValue(request.headers, \"sec-fetch-site\");\n const sameOrigin = origin === undefined ? site === \"same-origin\" : origin === policy.origin;\n return sameOrigin\n ? undefined\n : refusal(\"MOSTRA_HYGIENE_ORIGIN_REFUSED\", \"A stream must be opened by its own origin.\");\n }\n case \"upgrade\":\n case \"exchange\":\n case \"mutation\": {\n if (origin !== policy.origin) {\n return refusal(\n \"MOSTRA_HYGIENE_ORIGIN_REFUSED\",\n origin === undefined\n ? \"The request has no Origin header.\"\n : \"The request came from another origin.\",\n );\n }\n if (request.intent === \"upgrade\") return undefined;\n if (!isJsonContentType(headerValue(request.headers, \"content-type\"))) {\n return refusal(\"MOSTRA_HYGIENE_CONTENT_TYPE\", \"The request's body isn't declared as JSON.\");\n }\n if (request.intent === \"exchange\") return undefined;\n const sent = headerValue(request.headers, CSRF_HEADER);\n if (request.csrf === undefined || sent === undefined || !safeEqual(sent, request.csrf)) {\n return refusal(\n \"MOSTRA_HYGIENE_CSRF_MISSING\",\n sent === undefined\n ? `The request has no ${CSRF_HEADER} header.`\n : `The request's ${CSRF_HEADER} header doesn't match its session.`,\n );\n }\n return undefined;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiEA,MAAa,cAAc;AAE3B,MAAM,SAA0D;CAC9D,6BAA6B;CAC7B,+BAA+B;CAC/B,6BAA6B;CAC7B,6BAA6B;CAC7B,kCAAkC;CAClC,gCAAgC;CAChC,8BAA8B;CAC9B,8BAA8B;CAC9B,6BAA6B;CAC7B,6BAA6B;CAC7B,2BAA2B;CAC3B,iCAAiC;CACjC,kCAAkC;CAClC,8BAA8B;AAChC;;AAGA,SAAgB,QAAQ,MAA6B,SAAiB,QAA0B;CAC9F,OAAO;EACL,QAAQ,UAAU,OAAO;EACzB,YAAY,gBAAgB,MAAM,mBAAmB,OAAO,EAAE,QAAQ,CAAC;CACzE;AACF;;AAGA,MAAM,yBAAS,IAAI,IAAI;CAAC;CAAQ;CAAU;CAAgB;CAAkB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QACL,iCACA,WAAW,KAAA,IACP,sCACA,uCACN;GAEF,IAAI,QAAQ,WAAW,WAAW,OAAO,KAAA;GACzC,IAAI,CAAC,kBAAkB,YAAY,QAAQ,SAAS,cAAc,CAAC,GACjE,OAAO,QAAQ,+BAA+B,4CAA4C;GAE5F,IAAI,QAAQ,WAAW,YAAY,OAAO,KAAA;GAC1C,MAAM,OAAO,YAAY,QAAQ,SAAS,WAAW;GACrD,IAAI,QAAQ,SAAS,KAAA,KAAa,SAAS,KAAA,KAAa,CAAC,UAAU,MAAM,QAAQ,IAAI,GACnF,OAAO,QACL,+BACA,SAAS,KAAA,IACL,sBAAsB,YAAY,YAClC,iBAAiB,YAAY,mCACnC;GAEF;EACF;CACF;AACF"}
package/dist/ids.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as z from "zod";
2
2
  //#region src/ids.d.ts
3
3
  /** The prefixes INTERFACES §1 assigns, one per entity. */
4
- export type IdPrefix = "art" | "ver" | "vw" | "vwr" | "sub" | "dlv" | "run" | "thr" | "cmt" | "tok" | "mut" | "shr";
4
+ export type IdPrefix = "art" | "ver" | "vw" | "vwr" | "sub" | "dlv" | "run" | "thr" | "cmt" | "tok" | "mut" | "shr" | "acct" | "hom" | "lnk" | "rte";
5
5
  /**
6
6
  * A branded ID string. The brand exists only at the type level, so an `Id<"art">` is a plain
7
7
  * string at run time and on the wire.
@@ -101,6 +101,22 @@ export declare const MutationId: GeneratedIdKind<"mut">;
101
101
  export type ShareId = Id<"shr">;
102
102
  /** Share IDs. */
103
103
  export declare const ShareId: GeneratedIdKind<"shr">;
104
+ /** An account on a remote server (`acct_` + ULID, D165 item 8). */
105
+ export type AccountId = Id<"acct">;
106
+ /** Account IDs. */
107
+ export declare const AccountId: GeneratedIdKind<"acct">;
108
+ /** A hosted home on a remote server (`hom_` + ULID, D165 item 1). */
109
+ export type HomeId = Id<"hom">;
110
+ /** Hosted home IDs. */
111
+ export declare const HomeId: GeneratedIdKind<"hom">;
112
+ /** An instance linked to a remote server (`lnk_` + ULID, D165 item 2): its owner link. */
113
+ export type LinkId = Id<"lnk">;
114
+ /** Instance link IDs. */
115
+ export declare const LinkId: GeneratedIdKind<"lnk">;
116
+ /** A hosted route (`rte_` + ULID): one artifact on one hosted home (D165, after the Opus review). */
117
+ export type RouteId = Id<"rte">;
118
+ /** Hosted route IDs. */
119
+ export declare const RouteId: GeneratedIdKind<"rte">;
104
120
  /**
105
121
  * An event cursor: the decimal string of a home-wide event position (INTERFACES §1). Decimal
106
122
  * strings keep 64-bit positions exact in JavaScript.
package/dist/ids.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ids.d.ts","names":[],"sources":["../src/ids.ts"],"mappings":";;;YAmBY;;;;;YAkBA,GAAG,UAAU,eAAe;WAA2B,kBAAkB;;;YAGzE;;iBAGK,OAAO,UAAU;;WAEvB,QAAQ;;WAER;;WAEA,MAAM;;WAEN,SAAS;;WAET,QAAQ,EAAE,QAAQ,GAAG;;EAE9B,GAAG,iBAAiB,SAAS,GAAG;;;;;;;EAOhC,MAAM,gBAAgB,GAAG;;;iBAIV,gBAAgB,UAAU,kBAAkB,OAAO;;EAElE,UAAU,GAAG;;;YAkFH,aAAa;;qBAEZ,YAAY;;YAKb,YAAY;;iBAEP,sBAAsB;;;;;;;;;EASrC,WAAW,QAAQ,aAAa;;;qBAGrB,WAAW;;YAWZ,SAAS;;qBAER,QAAQ;;YAGT,WAAW;;qBAEV,UAAU;;YAKX,eAAe;;qBAEd,cAAc;;;;;YAQf,aAAa;;qBAEZ,YAAY;;YAKb,QAAQ;;qBAEP,OAAO;;YAKR,WAAW;;qBAEV,UAAU;;YAKX,YAAY;;qBAEX,WAAW;;YAKZ,UAAU;;qBAET,SAAS;;YAKV,aAAa;;qBAEZ,YAAY;;YAKb,UAAU;;qBAET,SAAS;;;;;YAQV;WAA6B;;;qBAG5B;;WAEF,SAAS;WACT,QAAQ,EAAE,QAAQ;EAC3B,GAAG,iBAAiB,SAAS;;EAE7B,MAAM,gBAAgB;;EAEtB,QAAQ,GAAG,QAAQ,GAAG"}
1
+ {"version":3,"file":"ids.d.ts","names":[],"sources":["../src/ids.ts"],"mappings":";;;YAmBY;;;;;YAsBA,GAAG,UAAU,eAAe;WAA2B,kBAAkB;;;YAGzE;;iBAGK,OAAO,UAAU;;WAEvB,QAAQ;;WAER;;WAEA,MAAM;;WAEN,SAAS;;WAET,QAAQ,EAAE,QAAQ,GAAG;;EAE9B,GAAG,iBAAiB,SAAS,GAAG;;;;;;;EAOhC,MAAM,gBAAgB,GAAG;;;iBAIV,gBAAgB,UAAU,kBAAkB,OAAO;;EAElE,UAAU,GAAG;;;YAkFH,aAAa;;qBAEZ,YAAY;;YAKb,YAAY;;iBAEP,sBAAsB;;;;;;;;;EASrC,WAAW,QAAQ,aAAa;;;qBAGrB,WAAW;;YAWZ,SAAS;;qBAER,QAAQ;;YAGT,WAAW;;qBAEV,UAAU;;YAKX,eAAe;;qBAEd,cAAc;;;;;YAQf,aAAa;;qBAEZ,YAAY;;YAKb,QAAQ;;qBAEP,OAAO;;YAKR,WAAW;;qBAEV,UAAU;;YAKX,YAAY;;qBAEX,WAAW;;YAKZ,UAAU;;qBAET,SAAS;;YAKV,aAAa;;qBAEZ,YAAY;;YAKb,UAAU;;qBAET,SAAS;;YAKV,YAAY;;qBAEX,WAAW;;YAKZ,SAAS;;qBAER,QAAQ;;YAKT,SAAS;;qBAER,QAAQ;;YAKT,UAAU;;qBAET,SAAS;;;;;YAQV;WAA6B;;;qBAG5B;;WAEF,SAAS;WACT,QAAQ,EAAE,QAAQ;EAC3B,GAAG,iBAAiB,SAAS;;EAE7B,MAAM,gBAAgB;;EAEtB,QAAQ,GAAG,QAAQ,GAAG"}
package/dist/ids.js CHANGED
@@ -111,6 +111,14 @@ const TokenId = generated(defineKind("tok", "capability token", "ulid", "TokenId
111
111
  const MutationId = generated(defineKind("mut", "mutation", "ulid", "MutationId"));
112
112
  /** Share IDs. */
113
113
  const ShareId = generated(defineKind("shr", "share", "ulid", "ShareId"));
114
+ /** Account IDs. */
115
+ const AccountId = generated(defineKind("acct", "account", "ulid", "AccountId"));
116
+ /** Hosted home IDs. */
117
+ const HomeId = generated(defineKind("hom", "hosted home", "ulid", "HomeId"));
118
+ /** Instance link IDs. */
119
+ const LinkId = generated(defineKind("lnk", "instance link", "ulid", "LinkId"));
120
+ /** Hosted route IDs. */
121
+ const RouteId = generated(defineKind("rte", "hosted route", "ulid", "RouteId"));
114
122
  /** Event cursors. */
115
123
  const Cursor = (() => {
116
124
  const pattern = /^(0|[1-9][0-9]{0,18})$/;
@@ -132,6 +140,6 @@ const Cursor = (() => {
132
140
  };
133
141
  })();
134
142
  //#endregion
135
- export { ArtifactId, CommentId, Cursor, DeliveryId, MutationId, RunId, ShareId, SubmissionId, ThreadId, TokenId, VersionId, ViewId, ViewerId };
143
+ export { AccountId, ArtifactId, CommentId, Cursor, DeliveryId, HomeId, LinkId, MutationId, RouteId, RunId, ShareId, SubmissionId, ThreadId, TokenId, VersionId, ViewId, ViewerId };
136
144
 
137
145
  //# sourceMappingURL=ids.js.map
package/dist/ids.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ids.js","names":[],"sources":["../src/ids.ts"],"sourcesContent":["/**\n * Prefixed, opaque identifiers (INTERFACES §1, DATA_MODEL §2).\n *\n * Every Mostra entity is named by a string of the form `<prefix>_<body>`. Callers treat IDs as\n * opaque: they validate the form at a boundary and never read meaning out of the body. Each ID\n * kind below is both a type and a value with the same name:\n *\n * ```ts\n * const artifact: ArtifactId = ArtifactId.parse(input);\n * const mutation: MutationId = MutationId.create();\n * const Params = z.object({ artifactId: ArtifactId.schema });\n * ```\n *\n * @packageDocumentation\n */\nimport * as z from \"zod\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** The prefixes INTERFACES §1 assigns, one per entity. */\nexport type IdPrefix =\n | \"art\"\n | \"ver\"\n | \"vw\"\n | \"vwr\"\n | \"sub\"\n | \"dlv\"\n | \"run\"\n | \"thr\"\n | \"cmt\"\n | \"tok\"\n | \"mut\"\n | \"shr\";\n\n/**\n * A branded ID string. The brand exists only at the type level, so an `Id<\"art\">` is a plain\n * string at run time and on the wire.\n */\nexport type Id<P extends IdPrefix> = `${P}_${string}` & { readonly __mostraIdPrefix: P };\n\n/** How an ID kind's body is formed. */\nexport type IdBody = \"ulid\" | \"sha256-base32\";\n\n/** One ID kind: its prefix, validation and schema. */\nexport interface IdKind<P extends IdPrefix> {\n /** The prefix, without the underscore. */\n readonly prefix: P;\n /** The entity the ID names, in the PRODUCT vocabulary. */\n readonly entity: string;\n /** How the body is formed. */\n readonly body: IdBody;\n /** The exact form, anchored at both ends. */\n readonly pattern: RegExp;\n /** The Zod schema for this ID, registered for JSON Schema output under the kind's type name. */\n readonly schema: z.ZodType<Id<P>, string>;\n /** Whether `value` is an ID of this kind. */\n is(value: unknown): value is Id<P>;\n /**\n * Returns `value` as an ID of this kind.\n *\n * @throws TypeError when `value` is not of this kind's form. The message names the expected\n * form and never echoes the input.\n */\n parse(value: string): Id<P>;\n}\n\n/** An ID kind whose body is a ULID that the creator generates. */\nexport interface GeneratedIdKind<P extends IdPrefix> extends IdKind<P> {\n /** Generates a new ID from the current time and 80 bits of Web Crypto randomness. */\n create(): Id<P>;\n}\n\n/** Crockford's base32 alphabet, used by ULIDs and by content-addressed version IDs. */\nconst CROCKFORD = \"0123456789ABCDEFGHJKMNPQRSTVWXYZ\";\nconst BODY_LENGTH = 26;\n/** A ULID's first character encodes at most 3 bits (48-bit time in 26 × 5 = 130 bits). */\nconst ULID_BODY = \"[0-7][0-9A-HJKMNP-TV-Z]{25}\";\nconst BASE32_BODY = \"[0-9A-HJKMNP-TV-Z]{26}\";\n\nfunction defineKind<P extends IdPrefix>(\n prefix: P,\n entity: string,\n body: IdBody,\n typeName: string,\n): IdKind<P> {\n const pattern = new RegExp(`^${prefix}_${body === \"ulid\" ? ULID_BODY : BASE32_BODY}$`);\n const form = body === \"ulid\" ? \"a 26-character ULID\" : \"26 characters of Crockford base32\";\n const is = (value: unknown): value is Id<P> => typeof value === \"string\" && pattern.test(value);\n const schema = z\n .string()\n .regex(pattern)\n .register(wireRegistry, {\n id: typeName,\n description: `${entity[0]?.toUpperCase()}${entity.slice(1)} ID: \"${prefix}_\" followed by ${form}.`,\n }) as unknown as z.ZodType<Id<P>, string>;\n return {\n prefix,\n entity,\n body,\n pattern,\n schema,\n is,\n parse(value: string): Id<P> {\n if (is(value)) return value;\n throw new TypeError(`Expected ${entity} ID \"${prefix}_\" followed by ${form}.`);\n },\n };\n}\n\nfunction generated<P extends IdPrefix>(kind: IdKind<P>): GeneratedIdKind<P> {\n return { ...kind, create: () => kind.parse(`${kind.prefix}_${ulidBody(Date.now())}`) };\n}\n\n/**\n * Encodes a ULID body: 48 bits of milliseconds since the Unix epoch, then 80 random bits, as 26\n * Crockford base32 characters.\n */\nfunction ulidBody(now: number): string {\n if (!Number.isSafeInteger(now) || now < 0 || now > 0xffff_ffff_ffff) {\n throw new RangeError(\"ULID time must be a millisecond timestamp between 0 and 2^48 - 1.\");\n }\n let time = \"\";\n let rest = now;\n for (let i = 0; i < 10; i++) {\n time = CROCKFORD.charAt(rest % 32) + time;\n rest = Math.floor(rest / 32);\n }\n const random = new Uint8Array(10);\n globalThis.crypto.getRandomValues(random);\n return time + base32(random).slice(0, 16);\n}\n\n/** Encodes bytes as Crockford base32, most significant bit first, padding the last group with 0. */\nfunction base32(bytes: Uint8Array): string {\n let out = \"\";\n let buffer = 0;\n let bits = 0;\n for (const byte of bytes) {\n buffer = (buffer << 8) | byte;\n bits += 8;\n while (bits >= 5) {\n out += CROCKFORD.charAt((buffer >>> (bits - 5)) & 31);\n bits -= 5;\n }\n buffer &= (1 << bits) - 1;\n }\n if (bits > 0) out += CROCKFORD.charAt((buffer << (5 - bits)) & 31);\n return out;\n}\n\n/** An artifact ID (`art_` + ULID). */\nexport type ArtifactId = Id<\"art\">;\n/** Artifact IDs. */\nexport const ArtifactId: GeneratedIdKind<\"art\"> = generated(\n defineKind(\"art\", \"artifact\", \"ulid\", \"ArtifactId\"),\n);\n\n/** A version ID (`ver_` + 26 characters of base32 SHA-256): content-addressed, never generated. */\nexport type VersionId = Id<\"ver\">;\n/** The version ID kind, with the content-addressed constructor DATA_MODEL §2 defines. */\nexport interface VersionIdKind extends IdKind<\"ver\"> {\n /**\n * Returns the version ID for a SHA-256 digest: `ver_` plus the first 26 characters of the\n * digest in Crockford base32 (130 bits). The caller computes the digest of the artifact ID's\n * UTF-8 bytes, a `0x00` byte, and the 32-byte `sourceDigest` and `envDigest` (DATA_MODEL §2,\n * D89).\n *\n * @throws RangeError when `digest` is not 32 bytes long.\n */\n fromSha256(digest: Uint8Array): VersionId;\n}\n/** Version IDs. */\nexport const VersionId: VersionIdKind = {\n ...defineKind(\"ver\", \"version\", \"sha256-base32\", \"VersionId\"),\n fromSha256(digest: Uint8Array): VersionId {\n if (digest.length !== 32) {\n throw new RangeError(`A SHA-256 digest is 32 bytes, got ${digest.length}.`);\n }\n return VersionId.parse(`ver_${base32(digest).slice(0, BODY_LENGTH)}`);\n },\n};\n\n/** A view ID (`vw_` + ULID). */\nexport type ViewId = Id<\"vw\">;\n/** View IDs. */\nexport const ViewId: GeneratedIdKind<\"vw\"> = generated(defineKind(\"vw\", \"view\", \"ulid\", \"ViewId\"));\n\n/** A viewer ID (`vwr_` + ULID). */\nexport type ViewerId = Id<\"vwr\">;\n/** Viewer IDs. */\nexport const ViewerId: GeneratedIdKind<\"vwr\"> = generated(\n defineKind(\"vwr\", \"viewer\", \"ulid\", \"ViewerId\"),\n);\n\n/** A submission ID (`sub_` + ULID). */\nexport type SubmissionId = Id<\"sub\">;\n/** Submission IDs. */\nexport const SubmissionId: GeneratedIdKind<\"sub\"> = generated(\n defineKind(\"sub\", \"submission\", \"ulid\", \"SubmissionId\"),\n);\n\n/**\n * A delivery ID (`dlv_` + ULID): one submission's delivery to one host (D105). A redelivery after a\n * crash repeats it, so a host can treat deliveries idempotently.\n */\nexport type DeliveryId = Id<\"dlv\">;\n/** Delivery IDs. */\nexport const DeliveryId: GeneratedIdKind<\"dlv\"> = generated(\n defineKind(\"dlv\", \"delivery\", \"ulid\", \"DeliveryId\"),\n);\n\n/** An action run ID (`run_` + ULID). */\nexport type RunId = Id<\"run\">;\n/** Action run IDs. */\nexport const RunId: GeneratedIdKind<\"run\"> = generated(\n defineKind(\"run\", \"action run\", \"ulid\", \"RunId\"),\n);\n\n/** A review thread ID (`thr_` + ULID). */\nexport type ThreadId = Id<\"thr\">;\n/** Review thread IDs. */\nexport const ThreadId: GeneratedIdKind<\"thr\"> = generated(\n defineKind(\"thr\", \"thread\", \"ulid\", \"ThreadId\"),\n);\n\n/** A comment ID (`cmt_` + ULID). */\nexport type CommentId = Id<\"cmt\">;\n/** Comment IDs. */\nexport const CommentId: GeneratedIdKind<\"cmt\"> = generated(\n defineKind(\"cmt\", \"comment\", \"ulid\", \"CommentId\"),\n);\n\n/** A capability token ID (`tok_` + ULID). The token's secret is separate and never an ID. */\nexport type TokenId = Id<\"tok\">;\n/** Capability token IDs. */\nexport const TokenId: GeneratedIdKind<\"tok\"> = generated(\n defineKind(\"tok\", \"capability token\", \"ulid\", \"TokenId\"),\n);\n\n/** A mutation ID (`mut_` + ULID), generated by the client that sends the mutation. */\nexport type MutationId = Id<\"mut\">;\n/** Mutation IDs. */\nexport const MutationId: GeneratedIdKind<\"mut\"> = generated(\n defineKind(\"mut\", \"mutation\", \"ulid\", \"MutationId\"),\n);\n\n/** A share ID (`shr_` + ULID): one share of an artifact through a tunnel (D158). */\nexport type ShareId = Id<\"shr\">;\n/** Share IDs. */\nexport const ShareId: GeneratedIdKind<\"shr\"> = generated(\n defineKind(\"shr\", \"share\", \"ulid\", \"ShareId\"),\n);\n\n/**\n * An event cursor: the decimal string of a home-wide event position (INTERFACES §1). Decimal\n * strings keep 64-bit positions exact in JavaScript.\n */\nexport type Cursor = string & { readonly __mostraCursor: true };\n\n/** Event cursors. */\nexport const Cursor: {\n /** The exact form: a non-negative decimal integer without leading zeros, at most 19 digits. */\n readonly pattern: RegExp;\n readonly schema: z.ZodType<Cursor, string>;\n is(value: unknown): value is Cursor;\n /** @throws TypeError when `value` is not a cursor. */\n parse(value: string): Cursor;\n /** Orders two cursors: negative when `a` comes first, zero when equal, positive otherwise. */\n compare(a: Cursor, b: Cursor): number;\n} = (() => {\n const pattern = /^(0|[1-9][0-9]{0,18})$/;\n const is = (value: unknown): value is Cursor => typeof value === \"string\" && pattern.test(value);\n return {\n pattern,\n schema: z.string().regex(pattern).register(wireRegistry, {\n id: \"Cursor\",\n description: \"Event cursor: the decimal string of a home-wide event position.\",\n }) as unknown as z.ZodType<Cursor, string>,\n is,\n parse(value: string): Cursor {\n if (is(value)) return value;\n throw new TypeError(\"Expected an event cursor: a non-negative decimal integer string.\");\n },\n compare(a: Cursor, b: Cursor): number {\n return a.length === b.length ? (a < b ? -1 : a > b ? 1 : 0) : a.length - b.length;\n },\n };\n})();\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwEA,MAAM,YAAY;AAClB,MAAM,cAAc;;AAEpB,MAAM,YAAY;AAClB,MAAM,cAAc;AAEpB,SAAS,WACP,QACA,QACA,MACA,UACW;CACX,MAAM,UAAU,IAAI,OAAO,IAAI,OAAO,GAAG,SAAS,SAAS,YAAY,YAAY,EAAE;CACrF,MAAM,OAAO,SAAS,SAAS,wBAAwB;CACvD,MAAM,MAAM,UAAmC,OAAO,UAAU,YAAY,QAAQ,KAAK,KAAK;CAQ9F,OAAO;EACL;EACA;EACA;EACA;EACA,QAZa,EACZ,OAAO,CAAC,CACR,MAAM,OAAO,CAAC,CACd,SAAS,cAAc;GACtB,IAAI;GACJ,aAAa,GAAG,OAAO,EAAE,EAAE,YAAY,IAAI,OAAO,MAAM,CAAC,EAAE,QAAQ,OAAO,iBAAiB,KAAK;EAClG,CAMK;EACL;EACA,MAAM,OAAsB;GAC1B,IAAI,GAAG,KAAK,GAAG,OAAO;GACtB,MAAM,IAAI,UAAU,YAA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ts"],"sourcesContent":["/**\n * Prefixed, opaque identifiers (INTERFACES §1, DATA_MODEL §2).\n *\n * Every Mostra entity is named by a string of the form `<prefix>_<body>`. Callers treat IDs as\n * opaque: they validate the form at a boundary and never read meaning out of the body. Each ID\n * kind below is both a type and a value with the same name:\n *\n * ```ts\n * const artifact: ArtifactId = ArtifactId.parse(input);\n * const mutation: MutationId = MutationId.create();\n * const Params = z.object({ artifactId: ArtifactId.schema });\n * ```\n *\n * @packageDocumentation\n */\nimport * as z from \"zod\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** The prefixes INTERFACES §1 assigns, one per entity. */\nexport type IdPrefix =\n | \"art\"\n | \"ver\"\n | \"vw\"\n | \"vwr\"\n | \"sub\"\n | \"dlv\"\n | \"run\"\n | \"thr\"\n | \"cmt\"\n | \"tok\"\n | \"mut\"\n | \"shr\"\n | \"acct\"\n | \"hom\"\n | \"lnk\"\n | \"rte\";\n\n/**\n * A branded ID string. The brand exists only at the type level, so an `Id<\"art\">` is a plain\n * string at run time and on the wire.\n */\nexport type Id<P extends IdPrefix> = `${P}_${string}` & { readonly __mostraIdPrefix: P };\n\n/** How an ID kind's body is formed. */\nexport type IdBody = \"ulid\" | \"sha256-base32\";\n\n/** One ID kind: its prefix, validation and schema. */\nexport interface IdKind<P extends IdPrefix> {\n /** The prefix, without the underscore. */\n readonly prefix: P;\n /** The entity the ID names, in the PRODUCT vocabulary. */\n readonly entity: string;\n /** How the body is formed. */\n readonly body: IdBody;\n /** The exact form, anchored at both ends. */\n readonly pattern: RegExp;\n /** The Zod schema for this ID, registered for JSON Schema output under the kind's type name. */\n readonly schema: z.ZodType<Id<P>, string>;\n /** Whether `value` is an ID of this kind. */\n is(value: unknown): value is Id<P>;\n /**\n * Returns `value` as an ID of this kind.\n *\n * @throws TypeError when `value` is not of this kind's form. The message names the expected\n * form and never echoes the input.\n */\n parse(value: string): Id<P>;\n}\n\n/** An ID kind whose body is a ULID that the creator generates. */\nexport interface GeneratedIdKind<P extends IdPrefix> extends IdKind<P> {\n /** Generates a new ID from the current time and 80 bits of Web Crypto randomness. */\n create(): Id<P>;\n}\n\n/** Crockford's base32 alphabet, used by ULIDs and by content-addressed version IDs. */\nconst CROCKFORD = \"0123456789ABCDEFGHJKMNPQRSTVWXYZ\";\nconst BODY_LENGTH = 26;\n/** A ULID's first character encodes at most 3 bits (48-bit time in 26 × 5 = 130 bits). */\nconst ULID_BODY = \"[0-7][0-9A-HJKMNP-TV-Z]{25}\";\nconst BASE32_BODY = \"[0-9A-HJKMNP-TV-Z]{26}\";\n\nfunction defineKind<P extends IdPrefix>(\n prefix: P,\n entity: string,\n body: IdBody,\n typeName: string,\n): IdKind<P> {\n const pattern = new RegExp(`^${prefix}_${body === \"ulid\" ? ULID_BODY : BASE32_BODY}$`);\n const form = body === \"ulid\" ? \"a 26-character ULID\" : \"26 characters of Crockford base32\";\n const is = (value: unknown): value is Id<P> => typeof value === \"string\" && pattern.test(value);\n const schema = z\n .string()\n .regex(pattern)\n .register(wireRegistry, {\n id: typeName,\n description: `${entity[0]?.toUpperCase()}${entity.slice(1)} ID: \"${prefix}_\" followed by ${form}.`,\n }) as unknown as z.ZodType<Id<P>, string>;\n return {\n prefix,\n entity,\n body,\n pattern,\n schema,\n is,\n parse(value: string): Id<P> {\n if (is(value)) return value;\n throw new TypeError(`Expected ${entity} ID \"${prefix}_\" followed by ${form}.`);\n },\n };\n}\n\nfunction generated<P extends IdPrefix>(kind: IdKind<P>): GeneratedIdKind<P> {\n return { ...kind, create: () => kind.parse(`${kind.prefix}_${ulidBody(Date.now())}`) };\n}\n\n/**\n * Encodes a ULID body: 48 bits of milliseconds since the Unix epoch, then 80 random bits, as 26\n * Crockford base32 characters.\n */\nfunction ulidBody(now: number): string {\n if (!Number.isSafeInteger(now) || now < 0 || now > 0xffff_ffff_ffff) {\n throw new RangeError(\"ULID time must be a millisecond timestamp between 0 and 2^48 - 1.\");\n }\n let time = \"\";\n let rest = now;\n for (let i = 0; i < 10; i++) {\n time = CROCKFORD.charAt(rest % 32) + time;\n rest = Math.floor(rest / 32);\n }\n const random = new Uint8Array(10);\n globalThis.crypto.getRandomValues(random);\n return time + base32(random).slice(0, 16);\n}\n\n/** Encodes bytes as Crockford base32, most significant bit first, padding the last group with 0. */\nfunction base32(bytes: Uint8Array): string {\n let out = \"\";\n let buffer = 0;\n let bits = 0;\n for (const byte of bytes) {\n buffer = (buffer << 8) | byte;\n bits += 8;\n while (bits >= 5) {\n out += CROCKFORD.charAt((buffer >>> (bits - 5)) & 31);\n bits -= 5;\n }\n buffer &= (1 << bits) - 1;\n }\n if (bits > 0) out += CROCKFORD.charAt((buffer << (5 - bits)) & 31);\n return out;\n}\n\n/** An artifact ID (`art_` + ULID). */\nexport type ArtifactId = Id<\"art\">;\n/** Artifact IDs. */\nexport const ArtifactId: GeneratedIdKind<\"art\"> = generated(\n defineKind(\"art\", \"artifact\", \"ulid\", \"ArtifactId\"),\n);\n\n/** A version ID (`ver_` + 26 characters of base32 SHA-256): content-addressed, never generated. */\nexport type VersionId = Id<\"ver\">;\n/** The version ID kind, with the content-addressed constructor DATA_MODEL §2 defines. */\nexport interface VersionIdKind extends IdKind<\"ver\"> {\n /**\n * Returns the version ID for a SHA-256 digest: `ver_` plus the first 26 characters of the\n * digest in Crockford base32 (130 bits). The caller computes the digest of the artifact ID's\n * UTF-8 bytes, a `0x00` byte, and the 32-byte `sourceDigest` and `envDigest` (DATA_MODEL §2,\n * D89).\n *\n * @throws RangeError when `digest` is not 32 bytes long.\n */\n fromSha256(digest: Uint8Array): VersionId;\n}\n/** Version IDs. */\nexport const VersionId: VersionIdKind = {\n ...defineKind(\"ver\", \"version\", \"sha256-base32\", \"VersionId\"),\n fromSha256(digest: Uint8Array): VersionId {\n if (digest.length !== 32) {\n throw new RangeError(`A SHA-256 digest is 32 bytes, got ${digest.length}.`);\n }\n return VersionId.parse(`ver_${base32(digest).slice(0, BODY_LENGTH)}`);\n },\n};\n\n/** A view ID (`vw_` + ULID). */\nexport type ViewId = Id<\"vw\">;\n/** View IDs. */\nexport const ViewId: GeneratedIdKind<\"vw\"> = generated(defineKind(\"vw\", \"view\", \"ulid\", \"ViewId\"));\n\n/** A viewer ID (`vwr_` + ULID). */\nexport type ViewerId = Id<\"vwr\">;\n/** Viewer IDs. */\nexport const ViewerId: GeneratedIdKind<\"vwr\"> = generated(\n defineKind(\"vwr\", \"viewer\", \"ulid\", \"ViewerId\"),\n);\n\n/** A submission ID (`sub_` + ULID). */\nexport type SubmissionId = Id<\"sub\">;\n/** Submission IDs. */\nexport const SubmissionId: GeneratedIdKind<\"sub\"> = generated(\n defineKind(\"sub\", \"submission\", \"ulid\", \"SubmissionId\"),\n);\n\n/**\n * A delivery ID (`dlv_` + ULID): one submission's delivery to one host (D105). A redelivery after a\n * crash repeats it, so a host can treat deliveries idempotently.\n */\nexport type DeliveryId = Id<\"dlv\">;\n/** Delivery IDs. */\nexport const DeliveryId: GeneratedIdKind<\"dlv\"> = generated(\n defineKind(\"dlv\", \"delivery\", \"ulid\", \"DeliveryId\"),\n);\n\n/** An action run ID (`run_` + ULID). */\nexport type RunId = Id<\"run\">;\n/** Action run IDs. */\nexport const RunId: GeneratedIdKind<\"run\"> = generated(\n defineKind(\"run\", \"action run\", \"ulid\", \"RunId\"),\n);\n\n/** A review thread ID (`thr_` + ULID). */\nexport type ThreadId = Id<\"thr\">;\n/** Review thread IDs. */\nexport const ThreadId: GeneratedIdKind<\"thr\"> = generated(\n defineKind(\"thr\", \"thread\", \"ulid\", \"ThreadId\"),\n);\n\n/** A comment ID (`cmt_` + ULID). */\nexport type CommentId = Id<\"cmt\">;\n/** Comment IDs. */\nexport const CommentId: GeneratedIdKind<\"cmt\"> = generated(\n defineKind(\"cmt\", \"comment\", \"ulid\", \"CommentId\"),\n);\n\n/** A capability token ID (`tok_` + ULID). The token's secret is separate and never an ID. */\nexport type TokenId = Id<\"tok\">;\n/** Capability token IDs. */\nexport const TokenId: GeneratedIdKind<\"tok\"> = generated(\n defineKind(\"tok\", \"capability token\", \"ulid\", \"TokenId\"),\n);\n\n/** A mutation ID (`mut_` + ULID), generated by the client that sends the mutation. */\nexport type MutationId = Id<\"mut\">;\n/** Mutation IDs. */\nexport const MutationId: GeneratedIdKind<\"mut\"> = generated(\n defineKind(\"mut\", \"mutation\", \"ulid\", \"MutationId\"),\n);\n\n/** A share ID (`shr_` + ULID): one share of an artifact through a tunnel (D158). */\nexport type ShareId = Id<\"shr\">;\n/** Share IDs. */\nexport const ShareId: GeneratedIdKind<\"shr\"> = generated(\n defineKind(\"shr\", \"share\", \"ulid\", \"ShareId\"),\n);\n\n/** An account on a remote server (`acct_` + ULID, D165 item 8). */\nexport type AccountId = Id<\"acct\">;\n/** Account IDs. */\nexport const AccountId: GeneratedIdKind<\"acct\"> = generated(\n defineKind(\"acct\", \"account\", \"ulid\", \"AccountId\"),\n);\n\n/** A hosted home on a remote server (`hom_` + ULID, D165 item 1). */\nexport type HomeId = Id<\"hom\">;\n/** Hosted home IDs. */\nexport const HomeId: GeneratedIdKind<\"hom\"> = generated(\n defineKind(\"hom\", \"hosted home\", \"ulid\", \"HomeId\"),\n);\n\n/** An instance linked to a remote server (`lnk_` + ULID, D165 item 2): its owner link. */\nexport type LinkId = Id<\"lnk\">;\n/** Instance link IDs. */\nexport const LinkId: GeneratedIdKind<\"lnk\"> = generated(\n defineKind(\"lnk\", \"instance link\", \"ulid\", \"LinkId\"),\n);\n\n/** A hosted route (`rte_` + ULID): one artifact on one hosted home (D165, after the Opus review). */\nexport type RouteId = Id<\"rte\">;\n/** Hosted route IDs. */\nexport const RouteId: GeneratedIdKind<\"rte\"> = generated(\n defineKind(\"rte\", \"hosted route\", \"ulid\", \"RouteId\"),\n);\n\n/**\n * An event cursor: the decimal string of a home-wide event position (INTERFACES §1). Decimal\n * strings keep 64-bit positions exact in JavaScript.\n */\nexport type Cursor = string & { readonly __mostraCursor: true };\n\n/** Event cursors. */\nexport const Cursor: {\n /** The exact form: a non-negative decimal integer without leading zeros, at most 19 digits. */\n readonly pattern: RegExp;\n readonly schema: z.ZodType<Cursor, string>;\n is(value: unknown): value is Cursor;\n /** @throws TypeError when `value` is not a cursor. */\n parse(value: string): Cursor;\n /** Orders two cursors: negative when `a` comes first, zero when equal, positive otherwise. */\n compare(a: Cursor, b: Cursor): number;\n} = (() => {\n const pattern = /^(0|[1-9][0-9]{0,18})$/;\n const is = (value: unknown): value is Cursor => typeof value === \"string\" && pattern.test(value);\n return {\n pattern,\n schema: z.string().regex(pattern).register(wireRegistry, {\n id: \"Cursor\",\n description: \"Event cursor: the decimal string of a home-wide event position.\",\n }) as unknown as z.ZodType<Cursor, string>,\n is,\n parse(value: string): Cursor {\n if (is(value)) return value;\n throw new TypeError(\"Expected an event cursor: a non-negative decimal integer string.\");\n },\n compare(a: Cursor, b: Cursor): number {\n return a.length === b.length ? (a < b ? -1 : a > b ? 1 : 0) : a.length - b.length;\n },\n };\n})();\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4EA,MAAM,YAAY;AAClB,MAAM,cAAc;;AAEpB,MAAM,YAAY;AAClB,MAAM,cAAc;AAEpB,SAAS,WACP,QACA,QACA,MACA,UACW;CACX,MAAM,UAAU,IAAI,OAAO,IAAI,OAAO,GAAG,SAAS,SAAS,YAAY,YAAY,EAAE;CACrF,MAAM,OAAO,SAAS,SAAS,wBAAwB;CACvD,MAAM,MAAM,UAAmC,OAAO,UAAU,YAAY,QAAQ,KAAK,KAAK;CAQ9F,OAAO;EACL;EACA;EACA;EACA;EACA,QAZa,EACZ,OAAO,CAAC,CACR,MAAM,OAAO,CAAC,CACd,SAAS,cAAc;GACtB,IAAI;GACJ,aAAa,GAAG,OAAO,EAAE,EAAE,YAAY,IAAI,OAAO,MAAM,CAAC,EAAE,QAAQ,OAAO,iBAAiB,KAAK;EAClG,CAMK;EACL;EACA,MAAM,OAAsB;GAC1B,IAAI,GAAG,KAAK,GAAG,OAAO;GACtB,MAAM,IAAI,UAAU,YAAY,OAAO,OAAO,OAAO,iBAAi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,OAAO;GACtB,MAAM,IAAI,UAAU,kEAAkE;EACxF;EACA,QAAQ,GAAW,GAAmB;GACpC,OAAO,EAAE,WAAW,EAAE,SAAU,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,IAAK,EAAE,SAAS,EAAE;EAC7E;CACF;AACF,EAAA,CAAG"}
package/dist/index.d.ts CHANGED
@@ -1,15 +1,17 @@
1
1
  import { ARGUMENT_BIGINT_DIGITS_MAX, AnyFunction, Frame, RemoteError, SerializationError, SerializeMode, UNSERIALIZABLE_CODE, ValueReader, ValueReaderOptions, ValueWriter, ValueWriterOptions, WireError, checkArgumentFrames, deserializeAll, fromBase64, serializeAll, toBase64, wireError } from "./serializer.js";
2
- import { ACTION_ARGS_MAX, ACTION_RESULT_MAX, ActionError, Batches, CallLine, CallRequest, EphemeralMessage, LIVE_KEY_PATTERN, LIVE_RING_DEFAULT, LIVE_RING_MAX, LIVE_VALUE_MAX, LiveRequest, LiveState, LiveUpdate, RUN_KEY_MAX, RUN_LOG_MAX, RUN_LOG_TRUNCATED, RUN_STATUSES, RunAttachRequest, RunCancelRequest, RunDelta, RunProgress, RunReason, RunRequest, RunState, RunStatus, SECRET_NAME_PATTERN, SECRET_VALUE_MAX, isFinalRunStatus } from "./actions.js";
3
- import { ARTIFACT_MANIFEST_KEYS, ArtifactFamily, ArtifactLink, ArtifactManifest, DemoSpec, SubmissionPolicy, TerminalSpec } from "./manifest.js";
2
+ import { ACTION_ARGS_MAX, ACTION_RESULT_MAX, ActionError, Batches, CallLine, CallRequest, EphemeralMessage, LIVE_KEY_PATTERN, LIVE_RING_DEFAULT, LIVE_RING_MAX, LIVE_VALUE_MAX, LiveRequest, LiveState, LiveUpdate, READABLE_LIVE_KEY_PATTERN, RUN_KEY_MAX, RUN_LOG_MAX, RUN_LOG_TRUNCATED, RUN_STATUSES, RunAttachRequest, RunCancelRequest, RunDelta, RunProgress, RunReason, RunRequest, RunState, RunStatus, SECRET_NAME_PATTERN, SECRET_VALUE_MAX, TALLY_LIVE_PREFIX, TallyValue, isFinalRunStatus } from "./actions.js";
3
+ import { Duration, durationMs } from "./duration.js";
4
+ import { SubmissionPolicy } from "./policy.js";
5
+ import { ARTIFACT_MANIFEST_KEYS, ArtifactFamily, ArtifactLink, ArtifactManifest, DemoSpec, HOSTED_OFFLINE_LIMIT_DEFAULT, HOSTED_OFFLINE_LIMIT_MAX_MS, HostedSettings, TALLY_CHOICES_MAX, TALLY_CHOICES_MIN, TallySpec, TerminalSpec, manifestProblem } from "./manifest.js";
4
6
  import { ArtifactDetail, ArtifactRef, ArtifactSummary, PublishReceipt, SourceRef, VersionSummary } from "./artifact.js";
5
7
  import { ControlsPolicy, DeliveryTarget, REVIEW_SET_ID_PATTERN, SubmitChannel, TrustedControl, VersionRef, ViewContext, ViewContextWire, readViewContext } from "./view.js";
6
8
  import { AnyBridgeMessage, BRIDGE_FIELDS_MAX, BRIDGE_MESSAGES, BRIDGE_TEXT_MAX, Bridge, BridgeEvent, BridgeHostContext, BridgeImplementation, BridgeMessage, BridgeOptions, BridgePeer, BridgeReceiver, BridgeRejection, BridgeSide, CONTROL_LABEL_MAX, ControlRequest, FieldRegistration, FieldsParams, FlushResult, FrameSessionFailedParams, MCP_APPS_PROTOCOL_VERSION, OPEN_LINK_SCHEMES, SaveState, SubmitBlocker, UiInitializeParams, UiInitializeResult, VersionAvailableParams, connectBridge, mostraControlsRequest, mostraFieldFocus, mostraFields, mostraFlush, mostraFrameSessionEntered, mostraFrameSessionFailed, mostraPage, mostraReady, mostraVersionAvailable, uiInitialize, uiInitialized, uiOpenLink, uiSizeChanged } from "./bridge.js";
7
- import { ArtifactId, CommentId, Cursor, DeliveryId, GeneratedIdKind, Id, IdBody, IdKind, IdPrefix, MutationId, RunId, ShareId, SubmissionId, ThreadId, TokenId, VersionId, VersionIdKind, ViewId, ViewerId } from "./ids.js";
8
- import { Actor, DeliveryState, DeliveryStatus, DocumentRevision, EventFilter, EventRecord, EventTypePattern, FIELD_ID_MAX_LENGTH, FieldConflict, FieldOp, FieldScope, FieldState, MutationResult, Rect, ResultComment, Results, SIGNAL_NAME_PATTERN, SubmissionSummary, Viewer, ViewerKind, ViewerSpec, Viewport, WaitCondition, isFieldId } from "./interaction.js";
9
- import { BROWSER_PROTOCOL_REVISION, BROWSER_PROTOCOL_REVISIONS, CarryOver, ChooseRequest, DocumentSnapshot, EnterRequest, EnterResult, FRAME_SESSION_HEADER, FieldsRequest, FollowRequest, FrameSessionFacts, FrameTicket, OrphanedField, PollResult, SIGNAL_PAYLOAD_MAX_BYTES, ShellSubmitRequest, SignalRequest, StreamSnapshot, StreamTicket, StreamTicketRequest, SubmitRequest } from "./browser.js";
9
+ import { AccountId, ArtifactId, CommentId, Cursor, DeliveryId, GeneratedIdKind, HomeId, Id, IdBody, IdKind, IdPrefix, LinkId, MutationId, RouteId, RunId, ShareId, SubmissionId, ThreadId, TokenId, VersionId, VersionIdKind, ViewId, ViewerId } from "./ids.js";
10
+ import { Actor, DeliveryState, DeliveryStatus, DocumentRevision, EventFilter, EventOrigin, EventRecord, EventTypePattern, FIELD_ID_MAX_LENGTH, FieldConflict, FieldOp, FieldScope, FieldState, MutationResult, Rect, ResultComment, Results, SIGNAL_NAME_PATTERN, SubmissionSummary, Viewer, ViewerKind, ViewerSpec, Viewport, WaitCondition, isFieldId } from "./interaction.js";
11
+ import { BROWSER_PROTOCOL_REVISION, BROWSER_PROTOCOL_REVISIONS, CarryOver, ChooseRequest, DocumentSnapshot, EnterRequest, EnterResult, FRAME_SESSION_HEADER, FieldsRequest, FollowRequest, FrameSessionFacts, FrameTicket, OrphanedField, PollResult, SHELL_SESSION_HEADER, SIGNAL_PAYLOAD_MAX_BYTES, ShellSubmitRequest, SignalRequest, StreamSnapshot, StreamTicket, StreamTicketRequest, SubmitRequest } from "./browser.js";
10
12
  import { BUNDLE_NAME, BUNDLE_PLATFORMS, BUNDLE_SETUP_MARKER, BundleAsset, BundleBrowser, BundleFileEntry, BundleFiles, BundleInfo, BundleLinkEntry, BundlePins, BundlePlatform, BundlePlatformSchema, BundleSetup, bundleAssetName, isWindowsBundle } from "./bundle.js";
11
13
  import { canonicalJson } from "./canonical.js";
12
- import { ALL_SCOPES, CapabilityScope, Duration, durationMs, normalizeScopes, scopeAllows } from "./capability.js";
14
+ import { ALL_SCOPES, CapabilityScope, normalizeScopes, scopeAllows } from "./capability.js";
13
15
  import { DIAGNOSTIC_AREAS, Diagnostic, DiagnosticArea, DiagnosticCode, DiagnosticFix, DiagnosticLocation, DiagnosticPhase, DiagnosticSeverity } from "./diagnostics/diagnostic.js";
14
16
  import { AreaCatalog, DEFAULT_DOCS_BASE, DiagnosticDetails, DiagnosticSpec, docsUrl } from "./diagnostics/spec.js";
15
17
  import { A11yDiagnosticCode, a11yDiagnosticCodes } from "./diagnostics/codes/a11y.js";
@@ -30,6 +32,7 @@ import { NetworkDiagnosticCode, networkDiagnosticCodes } from "./diagnostics/cod
30
32
  import { PlatformDiagnosticCode, platformDiagnosticCodes } from "./diagnostics/codes/platform.js";
31
33
  import { PublishDiagnosticCode, publishDiagnosticCodes } from "./diagnostics/codes/publish.js";
32
34
  import { RegressionDiagnosticCode, regressionDiagnosticCodes } from "./diagnostics/codes/regression.js";
35
+ import { RemoteDiagnosticCode, remoteDiagnosticCodes } from "./diagnostics/codes/remote.js";
33
36
  import { RuntimeDiagnosticCode, runtimeDiagnosticCodes } from "./diagnostics/codes/runtime.js";
34
37
  import { SecretDiagnosticCode, secretDiagnosticCodes } from "./diagnostics/codes/secret.js";
35
38
  import { ShareDiagnosticCode, shareDiagnosticCodes } from "./diagnostics/codes/share.js";
@@ -42,7 +45,9 @@ import { CreateDiagnosticOptions, KnownDiagnosticCode, createDiagnostic, diagnos
42
45
  import { CSRF_HEADER, Refusal, RequestFacts, RequestIntent, RequestPolicy, checkRequest, headerValue, isJsonContentType, refusal, safeEqual, safePath } from "./hygiene.js";
43
46
  import { AnyMethod, AnyNotification, MethodDefinition, MethodDirection, NotificationDefinition, defineMethod } from "./method.js";
44
47
  import { ArtifactCreateParams, ArtifactCreateResult, artifactCreateMethod } from "./methods/artifact/create.js";
48
+ import { ArtifactExportParams, ArtifactExportResult, ExportClass, artifactExportMethod } from "./methods/artifact/export.js";
45
49
  import { ArtifactGetParams, ArtifactGetResult, artifactGetMethod } from "./methods/artifact/get.js";
50
+ import { ArtifactImportParams, ArtifactImportResult, artifactImportMethod } from "./methods/artifact/import.js";
46
51
  import { ArtifactListFilter, ArtifactListParams, ArtifactListResult, artifactListMethod } from "./methods/artifact/list.js";
47
52
  import { ArtifactPublishParams, ArtifactPublishResult, artifactPublishMethod } from "./methods/artifact/publish.js";
48
53
  import { ARTIFACT_PROGRESS, ArtifactProgressParams, CompareRequest, CompareResult, DEFAULT_VIEWPORTS, ProbedField, RenderRequest, RenderResult, ScreenshotPolicy, TokenEstimate, VERIFY_PROBE, VERIFY_REPORT, VERIFY_RUNNER_METHODS, VerdictAria, VerdictScreenshot, VerifyVerdict, VerifyViewport, ariaSummary, estimateImageTokens, viewportsFor } from "./verify.js";
@@ -55,8 +60,12 @@ import { EVENTS_READ_MAX, EventsReadParams, EventsReadResult, eventsReadMethod }
55
60
  import { EVENTS_NOTIFY, EventsNotifyParams, EventsSubscribeParams, EventsSubscribeResult, eventsSubscribeMethod } from "./methods/events/subscribe.js";
56
61
  import { EventsUnsubscribeParams, EventsUnsubscribeResult, eventsUnsubscribeMethod } from "./methods/events/unsubscribe.js";
57
62
  import { GcCompactEvents, GcCompacted, GcCount, GcRunParams, GcRunResult, GcVersion, gcRunMethod } from "./methods/gc/run.js";
63
+ import { HostedPushParams, HostedPushResult, HostedRoute, ListingEntry, VersionPush, hostedPushMethod } from "./methods/hosted/push.js";
64
+ import { SubmissionEnvelope, SubmissionsDeliverResult, portSubmissionsDeliverMethod } from "./methods/port/submissions-deliver.js";
65
+ import { HostedSubmissionParams, HostedSubmissionResult, hostedSubmissionMethod } from "./methods/hosted/submission.js";
58
66
  import { hostMethods, hostNotifications } from "./methods/index.js";
59
67
  import { InstanceCheck, InstanceCheckParams, InstanceCheckResult, instanceCheckMethod } from "./methods/instance/check.js";
68
+ import { OwnerLinkInfo, RemoteLink, RemoteLinkState, ServerOrigin } from "./remote.js";
60
69
  import { HOST_PROTOCOL_REVISIONS, Revision, RevisionNegotiation, negotiateRevision } from "./revision.js";
61
70
  import { CLI_CLIENT_NAME, ClientCapabilities, ClientInfo, DependencyPolicy, HomeConfig, InstanceCapabilities, InstanceInfo, MostraInitializeParams, MostraInitializeResult, PortName, mostraInitializeMethod } from "./methods/mostra/initialize.js";
62
71
  import { PUBLIC_SHARE_DEFAULT_TTL, PUBLIC_SHARE_MAX_TTL_MS, Share, ShareStartParams, ShareStartResult, ShareVia, shareStartMethod } from "./methods/share/start.js";
@@ -66,10 +75,23 @@ import { MostraShutdownParams, MostraShutdownResult, mostraShutdownMethod } from
66
75
  import { ExternalBase, OriginString, PortAddressingExternalBaseParams, PortAddressingExternalBaseResult, portAddressingExternalBaseMethod } from "./methods/port/addressing-external-base.js";
67
76
  import { DraftMirror, DraftsMirrorResult, portDraftsMirrorMethod } from "./methods/port/drafts-mirror.js";
68
77
  import { IdentityVia, PortIdentityResolveParams, PortIdentityResolveResult, portIdentityResolveMethod } from "./methods/port/identity-resolve.js";
78
+ import { PortRelayRunParams, PortRelayRunResult, RelayViewer, portRelayRunMethod } from "./methods/port/relay-run.js";
79
+ import { PortRelayCallParams, PortRelayCallResult, portRelayCallMethod } from "./methods/port/relay-call.js";
80
+ import { PortRelayCancelParams, PortRelayCancelResult, portRelayCancelMethod } from "./methods/port/relay-cancel.js";
81
+ import { PortRelayLiveParams, PortRelayLiveResult, portRelayLiveMethod } from "./methods/port/relay-live.js";
82
+ import { PortRelayReconcileParams, PortRelayReconcileResult, RelayHeld, RelayReconciled, portRelayReconcileMethod } from "./methods/port/relay-reconcile.js";
69
83
  import { PortSecretsGetParams, PortSecretsGetResult, portSecretsGetMethod } from "./methods/port/secrets-get.js";
70
- import { SubmissionEnvelope, SubmissionsDeliverResult, portSubmissionsDeliverMethod } from "./methods/port/submissions-deliver.js";
71
84
  import { PortTrustedControlsActivatedParams, PortTrustedControlsActivatedResult, portTrustedControlsActivatedMethod } from "./methods/port/trusted-controls-activated.js";
72
85
  import { PortTrustedControlsPolicyParams, PortTrustedControlsPolicyResult, portTrustedControlsPolicyMethod } from "./methods/port/trusted-controls-policy.js";
86
+ import { RelayCallBatchParams, RelayCallBatchResult, relayCallBatchMethod } from "./methods/relay/call-batch.js";
87
+ import { RelayEffectParams, RelayEffectResult, relayEffectMethod } from "./methods/relay/effect.js";
88
+ import { RelayLiveValueParams, RelayLiveValueResult, relayLiveValueMethod } from "./methods/relay/live-value.js";
89
+ import { RelayRunEnd, RelayRunUpdateParams, RelayRunUpdateResult, relayRunUpdateMethod } from "./methods/relay/run-update.js";
90
+ import { RemoteLoginParams, RemoteLoginResult, remoteLoginMethod } from "./methods/remote/login.js";
91
+ import { RemoteLoginWaitParams, RemoteLoginWaitResult, remoteLoginWaitMethod } from "./methods/remote/login-wait.js";
92
+ import { RemoteLogoutParams, RemoteLogoutResult, remoteLogoutMethod } from "./methods/remote/logout.js";
93
+ import { RemoteStatusParams, RemoteStatusResult, remoteStatusMethod } from "./methods/remote/status.js";
94
+ import { RemoteTokenParams, RemoteTokenResult, remoteTokenMethod } from "./methods/remote/token.js";
73
95
  import { ResultsGetParams, ResultsGetResult, ResultsMarkdown, resultsGetMethod } from "./methods/results/get.js";
74
96
  import { SecretDeleteParams, SecretDeleteResult, secretDeleteMethod } from "./methods/secret/delete.js";
75
97
  import { SecretEntry, SecretSetParams, SecretSetResult, secretSetMethod } from "./methods/secret/set.js";
@@ -90,4 +112,4 @@ import { JSON_RPC_ERROR_CODES, RpcError } from "./rpc/error.js";
90
112
  import { LineSplitter, MAX_LINE_LENGTH, encodeLine } from "./rpc/lines.js";
91
113
  import { RpcPeer, RpcPeerOptions, RpcRequestContext, RpcRequestOptions, parseParams } from "./rpc/peer.js";
92
114
  import { CallContext, DEFAULT_WORKER_LIMITS, LiveSourceInfo, ServerEmitParams, ServerLiveValueParams, ServerLogParams, ServerProgressParams, ServerSecretParams, ServerSignalParams, ServerStateGetParams, ServerStatePatchParams, ServerStatePatchResult, WORKER_CHANNEL_REVISION, WORKER_METHODS, WorkerBatchParams, WorkerCallOutcome, WorkerCallParams, WorkerCancelParams, WorkerLimits, WorkerLiveParams, WorkerPingResult, WorkerStartParams, WorkerStartResult, WorkerVersionRef } from "./worker.js";
93
- export { type A11yDiagnosticCode, ACTION_ARGS_MAX, ACTION_RESULT_MAX, ALL_SCOPES, ARGUMENT_BIGINT_DIGITS_MAX, ARTIFACT_MANIFEST_KEYS, ARTIFACT_PROGRESS, type ActionDiagnosticCode, ActionError, Actor, AddedPackage, type AnyBridgeMessage, type AnyFunction, type AnyMethod, type AnyNotification, type AreaCatalog, type ArtifactCreateParams, type ArtifactCreateResult, ArtifactDetail, type ArtifactDiagnosticCode, type ArtifactFamily, type ArtifactGetParams, type ArtifactGetResult, ArtifactId, ArtifactLink, type ArtifactListFilter, type ArtifactListParams, type ArtifactListResult, ArtifactManifest, ArtifactProgressParams, type ArtifactPublishParams, type ArtifactPublishResult, ArtifactRef, ArtifactSummary, type ArtifactVerifyParams, type ArtifactVerifyResult, BRIDGE_FIELDS_MAX, BRIDGE_MESSAGES, BRIDGE_TEXT_MAX, BROWSER_PROTOCOL_REVISION, BROWSER_PROTOCOL_REVISIONS, BUNDLE_NAME, BUNDLE_PLATFORMS, BUNDLE_SETUP_MARKER, Batches, type Bridge, type BridgeEvent, type BridgeHostContext, type BridgeImplementation, type BridgeMessage, type BridgeOptions, type BridgePeer, type BridgeReceiver, type BridgeRejection, type BridgeSide, type BuildDiagnosticCode, BundleAsset, BundleBrowser, BundleFileEntry, BundleFiles, BundleInfo, BundleLinkEntry, BundlePins, type BundlePlatform, BundlePlatformSchema, BundleSetup, CLI_CLIENT_NAME, CONTROL_LABEL_MAX, CSRF_HEADER, type CallContext, type CallLine, CallRequest, CapabilityLink, CapabilityScope, CarryOver, ChildProcessStatus, ChooseRequest, type ClassifiedMessage, type CliDiagnosticCode, ClientCapabilities, ClientInfo, CommentId, type CompareRequest, type CompareResult, type ConsoleDiagnosticCode, type ControlRequest, ControlsPolicy, type CreateDiagnosticOptions, Cursor, DEFAULT_DOCS_BASE, DEFAULT_VIEWPORTS, DEFAULT_WORKER_LIMITS, DEV_NOTIFY, DIAGNOSTIC_AREAS, DeliveryCounts, DeliveryId, type DeliveryState, DeliveryStatus, type DeliveryTarget, type DemoSpec, type DepDiagnosticCode, DependencyPolicy, type DepsAddParams, type DepsAddResult, type DevEventKind, DevNotifyParams, type DevStartParams, type DevStartResult, type DevStopParams, type DevStopResult, Diagnostic, type DiagnosticArea, type DiagnosticCode, type DiagnosticDetails, DiagnosticFix, DiagnosticLocation, DiagnosticPhase, DiagnosticSeverity, type DiagnosticSpec, DocumentRevision, DocumentSnapshot, DraftMirror, type DraftsMirrorResult, Duration, EVENTS_NOTIFY, EVENTS_READ_MAX, EnterRequest, EnterResult, type EnvDiagnosticCode, type EphemeralMessage, EventFilter, EventRecord, EventTypePattern, type EventsAckParams, type EventsAckResult, EventsNotifyParams, type EventsReadParams, type EventsReadResult, type EventsSubscribeParams, type EventsSubscribeResult, type EventsUnsubscribeParams, type EventsUnsubscribeResult, ExternalBase, FIELD_ID_MAX_LENGTH, FRAME_SESSION_HEADER, type FaceStatus, FieldConflict, type FieldDiagnosticCode, FieldOp, type FieldRegistration, type FieldScope, FieldState, type FieldsParams, FieldsRequest, type FlushResult, FollowRequest, type Frame, FrameSessionFacts, type FrameSessionFailedParams, FrameTicket, GatewayStatus, type GcCompactEvents, type GcCompacted, type GcCount, type GcRunParams, type GcRunResult, type GcVersion, type GeneratedIdKind, HOST_PROTOCOL_REVISIONS, HomeConfig, type HomeDiagnosticCode, type HostDiagnosticCode, type HygieneDiagnosticCode, type Id, type IdBody, type IdKind, type IdPrefix, type IdentityVia, InstanceCapabilities, type InstanceCheck, type InstanceCheckParams, type InstanceCheckResult, InstanceInfo, type InstanceStatusParams, type InstanceStatusResult, JSON_RPC_ERROR_CODES, JsonRpcErrorObject, JsonRpcFailure, type JsonRpcId, type JsonRpcMessage, JsonRpcNotification, type JsonRpcParams, JsonRpcRequest, type JsonRpcResponse, JsonRpcSuccess, type KnownDiagnosticCode, LIVE_KEY_PATTERN, LIVE_RING_DEFAULT, LIVE_RING_MAX, LIVE_VALUE_MAX, LineSplitter, type LiveDiagnosticCode, type LivePushParams, type LivePushResult, LiveRequest, type LiveSourceInfo, type LiveState, type LiveUpdate, MAX_LINE_LENGTH, MCP_APPS_PROTOCOL_VERSION, type ManifestDiagnosticCode, type MethodDefinition, type MethodDirection, type MostraInitializeParams, type MostraInitializeResult, type MostraShutdownParams, type MostraShutdownResult, MutationId, MutationResult, type NetworkDiagnosticCode, type NotificationDefinition, OPEN_LINK_SCHEMES, OriginString, OrphanedField, PUBLIC_SHARE_DEFAULT_TTL, PUBLIC_SHARE_MAX_TTL_MS, type PlatformDiagnosticCode, PollResult, type PortAddressingExternalBaseParams, type PortAddressingExternalBaseResult, type PortIdentityResolveParams, type PortIdentityResolveResult, PortName, type PortSecretsGetParams, type PortSecretsGetResult, type PortTrustedControlsActivatedParams, type PortTrustedControlsActivatedResult, type PortTrustedControlsPolicyParams, type PortTrustedControlsPolicyResult, type ProbedField, type PublishDiagnosticCode, PublishReceipt, REVIEW_SET_ID_PATTERN, RUN_KEY_MAX, RUN_LOG_MAX, RUN_LOG_TRUNCATED, RUN_STATUSES, type Rect, type Refusal, type RegressionDiagnosticCode, RemoteError, type RenderRequest, type RenderResult, type RequestFacts, type RequestIntent, type RequestPolicy, ResultComment, Results, type ResultsGetParams, type ResultsGetResult, ResultsMarkdown, Revision, type RevisionNegotiation, RpcError, RpcPeer, type RpcPeerOptions, type RpcRequestContext, type RpcRequestOptions, RunAttachRequest, RunCancelRequest, type RunDelta, RunId, RunProgress, type RunReason, RunRequest, RunState, type RunStatus, type RuntimeDiagnosticCode, SECRET_NAME_PATTERN, SECRET_VALUE_MAX, SIGNAL_NAME_PATTERN, SIGNAL_PAYLOAD_MAX_BYTES, type SaveState, ScreenshotPolicy, type SecretDeleteParams, type SecretDeleteResult, type SecretDiagnosticCode, SecretEntry, type SecretListParams, type SecretListResult, type SecretSetParams, type SecretSetResult, SerializationError, type SerializeMode, ServerEmitParams, ServerLiveValueParams, ServerLogParams, ServerProgressParams, ServerSecretParams, ServerSignalParams, ServerStateGetParams, ServerStatePatchParams, type ServerStatePatchResult, Share, type ShareDiagnosticCode, ShareId, type ShareListParams, type ShareListResult, type ShareStartParams, type ShareStartResult, type ShareStopParams, type ShareStopResult, ShareVia, ShellSubmitRequest, SignalRequest, type SmokeDiagnosticCode, SourceRef, type StateGetParams, type StateGetResult, type StatePatchParams, type StatePatchResult, StreamSnapshot, StreamTicket, StreamTicketRequest, SubmissionEnvelope, SubmissionId, SubmissionPolicy, SubmissionSummary, type SubmissionsDeliverResult, type SubmitBlocker, SubmitChannel, type SubmitDiagnosticCode, SubmitRequest, type TargetDiagnosticCode, type TerminalSpec, ThreadId, type TokenEstimate, TokenId, TrustedControl, type TypeDiagnosticCode, UNSERIALIZABLE_CODE, type UiInitializeParams, type UiInitializeResult, VERIFY_PROBE, VERIFY_REPORT, VERIFY_RUNNER_METHODS, ValueReader, type ValueReaderOptions, ValueWriter, type ValueWriterOptions, type VerdictAria, type VerdictScreenshot, type VerifyDiagnosticCode, VerifyVerdict, type VerifyViewport, type VersionAvailableParams, VersionId, type VersionIdKind, VersionRef, VersionSummary, ViewContext, ViewContextWire, type ViewDefaultParams, type ViewDefaultResult, ViewId, type ViewLaunchParams, type ViewLaunchResult, type ViewRevokeParams, type ViewRevokeResult, type ViewRotateParams, type ViewRotateResult, type ViewUrlParams, type ViewUrlResult, Viewer, ViewerId, type ViewerKind, ViewerSpec, type Viewport, WAIT_MAX_MS, WORKER_CHANNEL_REVISION, WORKER_METHODS, WaitCondition, type WaitParams, type WaitResult, type WireError, WorkerBatchParams, WorkerCallOutcome, WorkerCallParams, type WorkerCancelParams, type WorkerLimits, type WorkerLiveParams, WorkerPingResult, WorkerStartParams, WorkerStartResult, WorkerStatus, WorkerVersionRef, a11yDiagnosticCodes, actionDiagnosticCodes, ariaSummary, artifactCreateMethod, artifactDiagnosticCodes, artifactGetMethod, artifactListMethod, artifactPublishMethod, artifactVerifyMethod, buildDiagnosticCodes, bundleAssetName, canonicalJson, checkArgumentFrames, checkRequest, classifyMessage, cliDiagnosticCodes, connectBridge, consoleDiagnosticCodes, createDiagnostic, defineMethod, depDiagnosticCodes, depsAddMethod, deserializeAll, devStartMethod, devStopMethod, diagnosticCatalog, docsUrl, durationMs, encodeLine, envDiagnosticCodes, estimateImageTokens, eventsAckMethod, eventsReadMethod, eventsSubscribeMethod, eventsUnsubscribeMethod, fieldDiagnosticCodes, fromBase64, gcRunMethod, headerValue, homeDiagnosticCodes, hostDiagnosticCodes, hostMethods, hostNotifications, hygieneDiagnosticCodes, instanceCheckMethod, instanceStatusMethod, isFieldId, isFinalRunStatus, isJsonContentType, isWindowsBundle, liveDiagnosticCodes, livePushMethod, manifestDiagnosticCodes, mostraControlsRequest, mostraFieldFocus, mostraFields, mostraFlush, mostraFrameSessionEntered, mostraFrameSessionFailed, mostraInitializeMethod, mostraPage, mostraReady, mostraShutdownMethod, mostraVersionAvailable, negotiateRevision, networkDiagnosticCodes, normalizeScopes, parseParams, platformDiagnosticCodes, portAddressingExternalBaseMethod, portDraftsMirrorMethod, portIdentityResolveMethod, portSecretsGetMethod, portSubmissionsDeliverMethod, portTrustedControlsActivatedMethod, portTrustedControlsPolicyMethod, publishDiagnosticCodes, readViewContext, receivable, refusal, regressionDiagnosticCodes, resultsGetMethod, runtimeDiagnosticCodes, safeEqual, safePath, scopeAllows, secretDeleteMethod, secretDiagnosticCodes, secretListMethod, secretSetMethod, serializeAll, shareDiagnosticCodes, shareListMethod, shareStartMethod, shareStopMethod, smokeDiagnosticCodes, stateGetMethod, statePatchMethod, submitDiagnosticCodes, targetDiagnosticCodes, toBase64, typeDiagnosticCodes, uiInitialize, uiInitialized, uiOpenLink, uiSizeChanged, verifyDiagnosticCodes, viewDefaultMethod, viewLaunchMethod, viewRevokeMethod, viewRotateMethod, viewUrlMethod, viewportsFor, waitMethod, wireError };
115
+ export { type A11yDiagnosticCode, ACTION_ARGS_MAX, ACTION_RESULT_MAX, ALL_SCOPES, ARGUMENT_BIGINT_DIGITS_MAX, ARTIFACT_MANIFEST_KEYS, ARTIFACT_PROGRESS, AccountId, type ActionDiagnosticCode, ActionError, Actor, AddedPackage, type AnyBridgeMessage, type AnyFunction, type AnyMethod, type AnyNotification, type AreaCatalog, type ArtifactCreateParams, type ArtifactCreateResult, ArtifactDetail, type ArtifactDiagnosticCode, type ArtifactExportParams, type ArtifactExportResult, type ArtifactFamily, type ArtifactGetParams, type ArtifactGetResult, ArtifactId, type ArtifactImportParams, type ArtifactImportResult, ArtifactLink, type ArtifactListFilter, type ArtifactListParams, type ArtifactListResult, ArtifactManifest, ArtifactProgressParams, type ArtifactPublishParams, type ArtifactPublishResult, ArtifactRef, ArtifactSummary, type ArtifactVerifyParams, type ArtifactVerifyResult, BRIDGE_FIELDS_MAX, BRIDGE_MESSAGES, BRIDGE_TEXT_MAX, BROWSER_PROTOCOL_REVISION, BROWSER_PROTOCOL_REVISIONS, BUNDLE_NAME, BUNDLE_PLATFORMS, BUNDLE_SETUP_MARKER, Batches, type Bridge, type BridgeEvent, type BridgeHostContext, type BridgeImplementation, type BridgeMessage, type BridgeOptions, type BridgePeer, type BridgeReceiver, type BridgeRejection, type BridgeSide, type BuildDiagnosticCode, BundleAsset, BundleBrowser, BundleFileEntry, BundleFiles, BundleInfo, BundleLinkEntry, BundlePins, type BundlePlatform, BundlePlatformSchema, BundleSetup, CLI_CLIENT_NAME, CONTROL_LABEL_MAX, CSRF_HEADER, type CallContext, type CallLine, CallRequest, CapabilityLink, CapabilityScope, CarryOver, ChildProcessStatus, ChooseRequest, type ClassifiedMessage, type CliDiagnosticCode, ClientCapabilities, ClientInfo, CommentId, type CompareRequest, type CompareResult, type ConsoleDiagnosticCode, type ControlRequest, ControlsPolicy, type CreateDiagnosticOptions, Cursor, DEFAULT_DOCS_BASE, DEFAULT_VIEWPORTS, DEFAULT_WORKER_LIMITS, DEV_NOTIFY, DIAGNOSTIC_AREAS, DeliveryCounts, DeliveryId, type DeliveryState, DeliveryStatus, type DeliveryTarget, type DemoSpec, type DepDiagnosticCode, DependencyPolicy, type DepsAddParams, type DepsAddResult, type DevEventKind, DevNotifyParams, type DevStartParams, type DevStartResult, type DevStopParams, type DevStopResult, Diagnostic, type DiagnosticArea, type DiagnosticCode, type DiagnosticDetails, DiagnosticFix, DiagnosticLocation, DiagnosticPhase, DiagnosticSeverity, type DiagnosticSpec, DocumentRevision, DocumentSnapshot, DraftMirror, type DraftsMirrorResult, Duration, EVENTS_NOTIFY, EVENTS_READ_MAX, EnterRequest, EnterResult, type EnvDiagnosticCode, type EphemeralMessage, EventFilter, EventOrigin, EventRecord, EventTypePattern, type EventsAckParams, type EventsAckResult, EventsNotifyParams, type EventsReadParams, type EventsReadResult, type EventsSubscribeParams, type EventsSubscribeResult, type EventsUnsubscribeParams, type EventsUnsubscribeResult, ExportClass, ExternalBase, FIELD_ID_MAX_LENGTH, FRAME_SESSION_HEADER, type FaceStatus, FieldConflict, type FieldDiagnosticCode, FieldOp, type FieldRegistration, type FieldScope, FieldState, type FieldsParams, FieldsRequest, type FlushResult, FollowRequest, type Frame, FrameSessionFacts, type FrameSessionFailedParams, FrameTicket, GatewayStatus, type GcCompactEvents, type GcCompacted, type GcCount, type GcRunParams, type GcRunResult, type GcVersion, type GeneratedIdKind, HOSTED_OFFLINE_LIMIT_DEFAULT, HOSTED_OFFLINE_LIMIT_MAX_MS, HOST_PROTOCOL_REVISIONS, HomeConfig, type HomeDiagnosticCode, HomeId, type HostDiagnosticCode, type HostedPushParams, type HostedPushResult, HostedRoute, HostedSettings, type HostedSubmissionParams, type HostedSubmissionResult, type HygieneDiagnosticCode, type Id, type IdBody, type IdKind, type IdPrefix, type IdentityVia, InstanceCapabilities, type InstanceCheck, type InstanceCheckParams, type InstanceCheckResult, InstanceInfo, type InstanceStatusParams, type InstanceStatusResult, JSON_RPC_ERROR_CODES, JsonRpcErrorObject, JsonRpcFailure, type JsonRpcId, type JsonRpcMessage, JsonRpcNotification, type JsonRpcParams, JsonRpcRequest, type JsonRpcResponse, JsonRpcSuccess, type KnownDiagnosticCode, LIVE_KEY_PATTERN, LIVE_RING_DEFAULT, LIVE_RING_MAX, LIVE_VALUE_MAX, LineSplitter, LinkId, type ListingEntry, type LiveDiagnosticCode, type LivePushParams, type LivePushResult, LiveRequest, type LiveSourceInfo, type LiveState, type LiveUpdate, MAX_LINE_LENGTH, MCP_APPS_PROTOCOL_VERSION, type ManifestDiagnosticCode, type MethodDefinition, type MethodDirection, type MostraInitializeParams, type MostraInitializeResult, type MostraShutdownParams, type MostraShutdownResult, MutationId, MutationResult, type NetworkDiagnosticCode, type NotificationDefinition, OPEN_LINK_SCHEMES, OriginString, OrphanedField, OwnerLinkInfo, PUBLIC_SHARE_DEFAULT_TTL, PUBLIC_SHARE_MAX_TTL_MS, type PlatformDiagnosticCode, PollResult, type PortAddressingExternalBaseParams, type PortAddressingExternalBaseResult, type PortIdentityResolveParams, type PortIdentityResolveResult, PortName, type PortRelayCallParams, type PortRelayCallResult, type PortRelayCancelParams, type PortRelayCancelResult, type PortRelayLiveParams, type PortRelayLiveResult, type PortRelayReconcileParams, type PortRelayReconcileResult, type PortRelayRunParams, type PortRelayRunResult, type PortSecretsGetParams, type PortSecretsGetResult, type PortTrustedControlsActivatedParams, type PortTrustedControlsActivatedResult, type PortTrustedControlsPolicyParams, type PortTrustedControlsPolicyResult, type ProbedField, type PublishDiagnosticCode, PublishReceipt, READABLE_LIVE_KEY_PATTERN, REVIEW_SET_ID_PATTERN, RUN_KEY_MAX, RUN_LOG_MAX, RUN_LOG_TRUNCATED, RUN_STATUSES, type Rect, type Refusal, type RegressionDiagnosticCode, type RelayCallBatchParams, type RelayCallBatchResult, type RelayEffectParams, type RelayEffectResult, type RelayHeld, type RelayLiveValueParams, type RelayLiveValueResult, type RelayReconciled, type RelayRunEnd, type RelayRunUpdateParams, type RelayRunUpdateResult, RelayViewer, type RemoteDiagnosticCode, RemoteError, RemoteLink, type RemoteLinkState, type RemoteLoginParams, type RemoteLoginResult, type RemoteLoginWaitParams, type RemoteLoginWaitResult, type RemoteLogoutParams, type RemoteLogoutResult, type RemoteStatusParams, type RemoteStatusResult, type RemoteTokenParams, type RemoteTokenResult, type RenderRequest, type RenderResult, type RequestFacts, type RequestIntent, type RequestPolicy, ResultComment, Results, type ResultsGetParams, type ResultsGetResult, ResultsMarkdown, Revision, type RevisionNegotiation, RouteId, RpcError, RpcPeer, type RpcPeerOptions, type RpcRequestContext, type RpcRequestOptions, RunAttachRequest, RunCancelRequest, type RunDelta, RunId, RunProgress, type RunReason, RunRequest, RunState, type RunStatus, type RuntimeDiagnosticCode, SECRET_NAME_PATTERN, SECRET_VALUE_MAX, SHELL_SESSION_HEADER, SIGNAL_NAME_PATTERN, SIGNAL_PAYLOAD_MAX_BYTES, type SaveState, ScreenshotPolicy, type SecretDeleteParams, type SecretDeleteResult, type SecretDiagnosticCode, SecretEntry, type SecretListParams, type SecretListResult, type SecretSetParams, type SecretSetResult, SerializationError, type SerializeMode, ServerEmitParams, ServerLiveValueParams, ServerLogParams, ServerOrigin, ServerProgressParams, ServerSecretParams, ServerSignalParams, ServerStateGetParams, ServerStatePatchParams, type ServerStatePatchResult, Share, type ShareDiagnosticCode, ShareId, type ShareListParams, type ShareListResult, type ShareStartParams, type ShareStartResult, type ShareStopParams, type ShareStopResult, ShareVia, ShellSubmitRequest, SignalRequest, type SmokeDiagnosticCode, SourceRef, type StateGetParams, type StateGetResult, type StatePatchParams, type StatePatchResult, StreamSnapshot, StreamTicket, StreamTicketRequest, SubmissionEnvelope, SubmissionId, SubmissionPolicy, SubmissionSummary, type SubmissionsDeliverResult, type SubmitBlocker, SubmitChannel, type SubmitDiagnosticCode, SubmitRequest, TALLY_CHOICES_MAX, TALLY_CHOICES_MIN, TALLY_LIVE_PREFIX, TallySpec, type TallyValue, type TargetDiagnosticCode, type TerminalSpec, ThreadId, type TokenEstimate, TokenId, TrustedControl, type TypeDiagnosticCode, UNSERIALIZABLE_CODE, type UiInitializeParams, type UiInitializeResult, VERIFY_PROBE, VERIFY_REPORT, VERIFY_RUNNER_METHODS, ValueReader, type ValueReaderOptions, ValueWriter, type ValueWriterOptions, type VerdictAria, type VerdictScreenshot, type VerifyDiagnosticCode, VerifyVerdict, type VerifyViewport, type VersionAvailableParams, VersionId, type VersionIdKind, VersionPush, VersionRef, VersionSummary, ViewContext, ViewContextWire, type ViewDefaultParams, type ViewDefaultResult, ViewId, type ViewLaunchParams, type ViewLaunchResult, type ViewRevokeParams, type ViewRevokeResult, type ViewRotateParams, type ViewRotateResult, type ViewUrlParams, type ViewUrlResult, Viewer, ViewerId, type ViewerKind, ViewerSpec, type Viewport, WAIT_MAX_MS, WORKER_CHANNEL_REVISION, WORKER_METHODS, WaitCondition, type WaitParams, type WaitResult, type WireError, WorkerBatchParams, WorkerCallOutcome, WorkerCallParams, type WorkerCancelParams, type WorkerLimits, type WorkerLiveParams, WorkerPingResult, WorkerStartParams, WorkerStartResult, WorkerStatus, WorkerVersionRef, a11yDiagnosticCodes, actionDiagnosticCodes, ariaSummary, artifactCreateMethod, artifactDiagnosticCodes, artifactExportMethod, artifactGetMethod, artifactImportMethod, artifactListMethod, artifactPublishMethod, artifactVerifyMethod, buildDiagnosticCodes, bundleAssetName, canonicalJson, checkArgumentFrames, checkRequest, classifyMessage, cliDiagnosticCodes, connectBridge, consoleDiagnosticCodes, createDiagnostic, defineMethod, depDiagnosticCodes, depsAddMethod, deserializeAll, devStartMethod, devStopMethod, diagnosticCatalog, docsUrl, durationMs, encodeLine, envDiagnosticCodes, estimateImageTokens, eventsAckMethod, eventsReadMethod, eventsSubscribeMethod, eventsUnsubscribeMethod, fieldDiagnosticCodes, fromBase64, gcRunMethod, headerValue, homeDiagnosticCodes, hostDiagnosticCodes, hostMethods, hostNotifications, hostedPushMethod, hostedSubmissionMethod, hygieneDiagnosticCodes, instanceCheckMethod, instanceStatusMethod, isFieldId, isFinalRunStatus, isJsonContentType, isWindowsBundle, liveDiagnosticCodes, livePushMethod, manifestDiagnosticCodes, manifestProblem, mostraControlsRequest, mostraFieldFocus, mostraFields, mostraFlush, mostraFrameSessionEntered, mostraFrameSessionFailed, mostraInitializeMethod, mostraPage, mostraReady, mostraShutdownMethod, mostraVersionAvailable, negotiateRevision, networkDiagnosticCodes, normalizeScopes, parseParams, platformDiagnosticCodes, portAddressingExternalBaseMethod, portDraftsMirrorMethod, portIdentityResolveMethod, portRelayCallMethod, portRelayCancelMethod, portRelayLiveMethod, portRelayReconcileMethod, portRelayRunMethod, portSecretsGetMethod, portSubmissionsDeliverMethod, portTrustedControlsActivatedMethod, portTrustedControlsPolicyMethod, publishDiagnosticCodes, readViewContext, receivable, refusal, regressionDiagnosticCodes, relayCallBatchMethod, relayEffectMethod, relayLiveValueMethod, relayRunUpdateMethod, remoteDiagnosticCodes, remoteLoginMethod, remoteLoginWaitMethod, remoteLogoutMethod, remoteStatusMethod, remoteTokenMethod, resultsGetMethod, runtimeDiagnosticCodes, safeEqual, safePath, scopeAllows, secretDeleteMethod, secretDiagnosticCodes, secretListMethod, secretSetMethod, serializeAll, shareDiagnosticCodes, shareListMethod, shareStartMethod, shareStopMethod, smokeDiagnosticCodes, stateGetMethod, statePatchMethod, submitDiagnosticCodes, targetDiagnosticCodes, toBase64, typeDiagnosticCodes, uiInitialize, uiInitialized, uiOpenLink, uiSizeChanged, verifyDiagnosticCodes, viewDefaultMethod, viewLaunchMethod, viewRevokeMethod, viewRotateMethod, viewUrlMethod, viewportsFor, waitMethod, wireError };