@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
package/dist/remote.js ADDED
@@ -0,0 +1,52 @@
1
+ import { wireRegistry } from "./wire-registry.js";
2
+ import { Cursor } from "./ids.js";
3
+ import * as z from "zod";
4
+ //#region src/remote.ts
5
+ /**
6
+ * The owner instance's links to remote servers (INTERFACES §18.2, D165 items 1, 2): what
7
+ * `remote/status` reports and `mostra/initialize` carries on a binding.
8
+ */
9
+ /** The Zod schema of the `ServerOrigin` type: an origin with no path. */
10
+ const ServerOrigin = z.string().regex(/^https?:\/\/[^/?#\s]+$/).register(wireRegistry, {
11
+ id: "ServerOrigin",
12
+ description: "A remote server, by its API origin, such as https://api.example."
13
+ });
14
+ /** The Zod schema of the `RemoteLink` type. */
15
+ const RemoteLink = z.object({
16
+ server: ServerOrigin,
17
+ account: z.object({
18
+ id: z.string(),
19
+ name: z.string().exactOptional()
20
+ }),
21
+ instanceId: z.string(),
22
+ name: z.string(),
23
+ default: z.boolean(),
24
+ state: z.enum([
25
+ "connected",
26
+ "connecting",
27
+ "offline",
28
+ "signed-out"
29
+ ]),
30
+ since: z.string(),
31
+ pendingPushes: z.int().min(0),
32
+ lastError: z.string().exactOptional()
33
+ }).register(wireRegistry, {
34
+ id: "RemoteLink",
35
+ description: "One remote server this home is linked to, and the state of the link."
36
+ });
37
+ /** The Zod schema of the `OwnerLinkInfo` type. */
38
+ const OwnerLinkInfo = z.object({
39
+ instanceId: z.string().min(1),
40
+ relayMark: z.int().min(0),
41
+ followed: z.object({
42
+ incarnation: z.string().min(1),
43
+ cursor: Cursor.schema
44
+ }).exactOptional()
45
+ }).register(wireRegistry, {
46
+ id: "OwnerLinkInfo",
47
+ description: "An owner instance's link on its binding session: its link ID, its relay mark and the hosted home's position it committed."
48
+ });
49
+ //#endregion
50
+ export { OwnerLinkInfo, RemoteLink, ServerOrigin };
51
+
52
+ //# sourceMappingURL=remote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.js","names":[],"sources":["../src/remote.ts"],"sourcesContent":["/**\n * The owner instance's links to remote servers (INTERFACES §18.2, D165 items 1, 2): what\n * `remote/status` reports and `mostra/initialize` carries on a binding.\n */\nimport * as z from \"zod\";\nimport { Cursor } from \"./ids.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** A server, by its API origin (`https://api.example`). */\nexport type ServerOrigin = string;\n\n/** The Zod schema of the `ServerOrigin` type: an origin with no path. */\nexport const ServerOrigin: z.ZodType<ServerOrigin> = z\n .string()\n .regex(/^https?:\\/\\/[^/?#\\s]+$/)\n .register(wireRegistry, {\n id: \"ServerOrigin\",\n description: \"A remote server, by its API origin, such as https://api.example.\",\n });\n\n/** The state of an instance's link to one server (INTERFACES §18.2). */\nexport type RemoteLinkState = \"connected\" | \"connecting\" | \"offline\" | \"signed-out\";\n\n/** One server this home is linked to (`remote/status`). */\nexport interface RemoteLink {\n /** The server's API origin. */\n readonly server: ServerOrigin;\n /** The account signed in there. */\n readonly account: { readonly id: string; readonly name?: string };\n /** This home's instance link on that server (`lnk_…`), kept across sign-outs. */\n readonly instanceId: string;\n /** The link's name, as the account's other instances see it. */\n readonly name: string;\n /** Whether this instance is the account's default instance (D165 item 1b). */\n readonly default: boolean;\n /** Whether the binding is open, being dialled, offline, or signed out. */\n readonly state: RemoteLinkState;\n /** When the link reached its state. */\n readonly since: string;\n /** Publishes of shared artifacts waiting to reach the server. */\n readonly pendingPushes: number;\n /** Why the link isn't connected, when it failed. */\n readonly lastError?: string;\n}\n\n/** The Zod schema of the `RemoteLink` type. */\nexport const RemoteLink: z.ZodType<RemoteLink> = z\n .object({\n server: ServerOrigin,\n account: z.object({ id: z.string(), name: z.string().exactOptional() }),\n instanceId: z.string(),\n name: z.string(),\n default: z.boolean(),\n state: z.enum([\"connected\", \"connecting\", \"offline\", \"signed-out\"]),\n since: z.string(),\n pendingPushes: z.int().min(0),\n lastError: z.string().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"RemoteLink\",\n description: \"One remote server this home is linked to, and the state of the link.\",\n });\n\n/**\n * What an owner instance tells its hosted home as it opens a binding session (INTERFACES §18.2):\n * its link, the highest relay sequence it accepted, and the hosted home's position it committed,\n * so a home restored to an earlier copy is found before it answers (D165, FAILURE_MODEL §11.2).\n */\nexport interface OwnerLinkInfo {\n /** The instance's `lnk_` ID on this server. */\n readonly instanceId: string;\n /** The highest relay sequence the owner's ledger accepted. */\n readonly relayMark: number;\n /** The hosted home's position the owner committed: its incarnation and cursor. */\n readonly followed?: { readonly incarnation: string; readonly cursor: Cursor };\n}\n\n/** The Zod schema of the `OwnerLinkInfo` type. */\nexport const OwnerLinkInfo: z.ZodType<OwnerLinkInfo> = z\n .object({\n instanceId: z.string().min(1),\n relayMark: z.int().min(0),\n followed: z.object({ incarnation: z.string().min(1), cursor: Cursor.schema }).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"OwnerLinkInfo\",\n description:\n \"An owner instance's link on its binding session: its link ID, its relay mark and the hosted home's position it committed.\",\n });\n"],"mappings":";;;;;;;;;AAYA,MAAa,eAAwC,EAClD,OAAO,CAAC,CACR,MAAM,wBAAwB,CAAC,CAC/B,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AA4BH,MAAa,aAAoC,EAC9C,OAAO;CACN,QAAQ;CACR,SAAS,EAAE,OAAO;EAAE,IAAI,EAAE,OAAO;EAAG,MAAM,EAAE,OAAO,CAAC,CAAC,cAAc;CAAE,CAAC;CACtE,YAAY,EAAE,OAAO;CACrB,MAAM,EAAE,OAAO;CACf,SAAS,EAAE,QAAQ;CACnB,OAAO,EAAE,KAAK;EAAC;EAAa;EAAc;EAAW;CAAY,CAAC;CAClE,OAAO,EAAE,OAAO;CAChB,eAAe,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;CAC5B,WAAW,EAAE,OAAO,CAAC,CAAC,cAAc;AACtC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAiBH,MAAa,gBAA0C,EACpD,OAAO;CACN,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAC5B,WAAW,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;CACxB,UAAU,EAAE,OAAO;EAAE,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;EAAG,QAAQ,OAAO;CAAO,CAAC,CAAC,CAAC,cAAc;AAC9F,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC"}
package/dist/view.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SubmissionPolicy } from "./manifest.js";
1
+ import { SubmissionPolicy } from "./policy.js";
2
2
  import * as z from "zod";
3
3
  //#region src/view.d.ts
4
4
  /** Where a submit came from (D40). */
package/dist/view.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { wireRegistry } from "./wire-registry.js";
2
2
  import { ArtifactId, VersionId, ViewId } from "./ids.js";
3
- import { SubmissionPolicy } from "./manifest.js";
3
+ import { SubmissionPolicy } from "./policy.js";
4
4
  import * as z from "zod";
5
5
  //#region src/view.ts
6
6
  /**
package/dist/view.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"view.js","names":[],"sources":["../src/view.ts"],"sourcesContent":["/**\n * What one view is (D104, D108): its artifact, version, policy, submit channels and trusted\n * controls. The browser protocol's frame ticket, the bridge's `ui/initialize` result and the\n * interaction core's channel policy share these shapes, so they live in a module of their own:\n * the bridge, which every version embeds, imports them without the interaction schemas.\n */\nimport * as z from \"zod\";\nimport { ArtifactId, VersionId, ViewId } from \"./ids.ts\";\nimport { SubmissionPolicy } from \"./manifest.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** Where a submit came from (D40). */\nexport type SubmitChannel = \"shell\" | \"artifact\";\n\n/** The Zod schema of the `SubmitChannel` type. */\nexport const SubmitChannel: z.ZodType<SubmitChannel> = z\n .enum([\"shell\", \"artifact\"])\n .register(wireRegistry, {\n id: \"SubmitChannel\",\n description: \"Where a submit comes from: the shell's trusted Submit, or the artifact's code.\",\n });\n\n/**\n * A trusted control the shell renders outside the artifact's frame (D06, PRODUCT vocabulary):\n * Submit, Choose (review sets) and Approve. Open for later controls on the wire.\n */\nexport type TrustedControl = \"submit\" | \"choose\" | \"approve\" | (string & {});\n\n/** The Zod schema of the `TrustedControl` type. */\nexport const TrustedControl: z.ZodType<TrustedControl> = z\n .string()\n .regex(/^[a-z][a-z0-9-]{0,31}$/)\n .register(wireRegistry, {\n id: \"TrustedControl\",\n description: \"A trusted control the shell renders: submit, choose, approve; open for more.\",\n });\n\n/**\n * Which submit channels a view accepts and which trusted controls its shell renders (D40, D108):\n * the `trustedControls` port's answer, or the home's `HomeConfig.submitChannels`.\n */\nexport interface ControlsPolicy {\n /** The channels submissions may come through; at least one. */\n readonly submitChannels: readonly SubmitChannel[];\n /** The trusted controls the shell may render; absent: every control the artifact asks for. */\n readonly controls?: readonly TrustedControl[];\n}\n\n/** The Zod schema of the `ControlsPolicy` type. */\nexport const ControlsPolicy: z.ZodType<ControlsPolicy> = z\n .object({\n submitChannels: z.array(SubmitChannel).min(1).max(2).readonly(),\n controls: z.array(TrustedControl).max(32).readonly().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ControlsPolicy\",\n description:\n \"Which submit channels a view accepts and which trusted controls its shell renders (D108).\",\n });\n\n/** A review set's ID: letters, digits, `_` and `-` (its choice is the field `review.<id>.choice`). */\nexport const REVIEW_SET_ID_PATTERN: RegExp = /^[A-Za-z0-9_-]{1,64}$/;\n\n/** Where a client runtime runs (D111): Mostra's gateway, a static export, an MCP App, or `verify`. */\nexport type DeliveryTarget = \"live\" | \"static\" | \"mcp-app\" | \"verify\";\n\n/** A version by ID and number. */\nexport interface VersionRef {\n /** The version's ID. */\n readonly id: string;\n /** Its number, for people. */\n readonly number: number;\n}\n\n/** The Zod schema of the `VersionRef` type. */\nexport const VersionRef: z.ZodType<VersionRef> = z\n .object({ id: VersionId.schema, number: z.int().min(1) })\n .register(wireRegistry, {\n id: \"VersionRef\",\n description: \"A version by ID and number.\",\n });\n\n/**\n * What one view is (D104, D108): the shell learns it from its frame ticket and hands it to the\n * frame in `ui/initialize`'s result, so the client runtime names the view in every request and\n * knows what the host allows.\n */\nexport interface ViewContext {\n /** The artifact. */\n readonly artifactId: string;\n /** The view this frame load is; every mutation and submit names it (D104). */\n readonly viewId: string;\n /** The version the view shows. */\n readonly version: VersionRef;\n /** The artifact's latest version when the view opened. */\n readonly latest: VersionRef;\n /** The submission policy in force (D102). */\n readonly policy: SubmissionPolicy;\n /** The submit channels this view accepts (D108). */\n readonly submitChannels: readonly SubmitChannel[];\n /** The trusted controls the shell renders for this view (D108). */\n readonly controls: readonly TrustedControl[];\n /** Always `live` in a frame Mostra's shell hosts. */\n readonly target: DeliveryTarget;\n}\n\n/** The Zod schema of the `ViewContext` type. */\nexport const ViewContext: z.ZodType<ViewContext> = z\n .object({\n artifactId: ArtifactId.schema,\n viewId: ViewId.schema,\n version: VersionRef,\n latest: VersionRef,\n policy: SubmissionPolicy,\n submitChannels: z.array(SubmitChannel).min(1).max(2).readonly(),\n controls: z.array(TrustedControl).max(32).readonly(),\n target: z.enum([\"live\", \"static\", \"mcp-app\", \"verify\"]),\n })\n .register(wireRegistry, {\n id: \"ViewContext\",\n description:\n \"What one view is: its artifact, view ID, version, latest version, policy, channels and controls.\",\n });\n\n/**\n * A view as a page reads it from `ui/initialize` (Claude review finding 5): every published\n * version embeds the page's reader, so it takes values a later Mostra may add (a channel, a\n * policy, a target) without refusing the whole view; {@link readViewContext} reads them safely.\n */\nexport interface ViewContextWire {\n /** The artifact. */\n readonly artifactId: string;\n /** The view this frame load is (D104). */\n readonly viewId: string;\n /** The version the view shows. */\n readonly version: VersionRef;\n /** The artifact's latest version when the view opened. */\n readonly latest: VersionRef;\n /** The submission policy in force (D102); a later policy or scope is read as `once` per viewer. */\n readonly policy: {\n /** `once`, `epochs`, `none`, or one a later release adds. */\n readonly policy: string;\n /** `per-artifact` or `per-viewer` under `once`, or one a later release adds. */\n readonly scope?: string;\n };\n /** The submit channels the view accepts (D108); channels this release doesn't know are not allowed. */\n readonly submitChannels: readonly string[];\n /** The trusted controls the shell renders for the view (D108). */\n readonly controls: readonly string[];\n /** Where the page runs (D111); a target this release doesn't know is read as `live`. */\n readonly target: string;\n}\n\n/** The Zod schema of the `ViewContextWire` type: open where later revisions may add values. */\nexport const ViewContextWire: z.ZodType<ViewContextWire> = z.looseObject({\n artifactId: ArtifactId.schema,\n viewId: ViewId.schema,\n version: VersionRef,\n latest: VersionRef,\n policy: z.looseObject({ policy: z.string(), scope: z.string().exactOptional() }),\n submitChannels: z.array(z.string()).max(16).readonly(),\n controls: z.array(z.string()).max(32).readonly(),\n target: z.string(),\n}) as z.ZodType<ViewContextWire>;\n\nconst CONTROL_NAME = /^[a-z][a-z0-9-]{0,31}$/;\n\n/**\n * The view a page acts on, with every value this release doesn't know read the safe way: an\n * unknown channel isn't allowed (the shell's stays), an unknown policy or `once` scope is read as\n * `once` per viewer (the page may submit and the server decides; it closes on its own submission\n * only), and an unknown target as `live`.\n */\nexport function readViewContext(wire: ViewContextWire): ViewContext {\n const channels = ([\"shell\", \"artifact\"] as const).filter((channel) =>\n wire.submitChannels.includes(channel),\n );\n const { policy: name, scope } = wire.policy;\n const policy: SubmissionPolicy =\n name === \"none\"\n ? { policy: \"none\" }\n : name === \"epochs\"\n ? { policy: \"epochs\" }\n : name === \"once\" && (scope === undefined || scope === \"per-artifact\")\n ? { policy: \"once\", scope: \"per-artifact\" }\n : { policy: \"once\", scope: \"per-viewer\" };\n const target = ([\"live\", \"static\", \"mcp-app\", \"verify\"] as const).find(\n (known) => known === wire.target,\n );\n return {\n artifactId: wire.artifactId,\n viewId: wire.viewId,\n version: wire.version,\n latest: wire.latest,\n policy,\n submitChannels: channels.length > 0 ? channels : [\"shell\"],\n controls: wire.controls.filter((control) => CONTROL_NAME.test(control)),\n target: target ?? \"live\",\n };\n}\n"],"mappings":";;;;;;;;;;;;AAeA,MAAa,gBAA0C,EACpD,KAAK,CAAC,SAAS,UAAU,CAAC,CAAC,CAC3B,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AASH,MAAa,iBAA4C,EACtD,OAAO,CAAC,CACR,MAAM,wBAAwB,CAAC,CAC/B,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAcH,MAAa,iBAA4C,EACtD,OAAO;CACN,gBAAgB,EAAE,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;CAC9D,UAAU,EAAE,MAAM,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;AACrE,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC;;AAGH,MAAa,wBAAgC;;AAc7C,MAAa,aAAoC,EAC9C,OAAO;CA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,SAAS,WAAW,UAAU,KAAA,KAAa,UAAU,kBACnD;EAAE,QAAQ;EAAQ,OAAO;CAAe,IACxC;EAAE,QAAQ;EAAQ,OAAO;CAAa;CAChD,MAAM,SAAU;EAAC;EAAQ;EAAU;EAAW;CAAQ,CAAC,CAAW,MAC/D,UAAU,UAAU,KAAK,MAC5B;CACA,OAAO;EACL,YAAY,KAAK;EACjB,QAAQ,KAAK;EACb,SAAS,KAAK;EACd,QAAQ,KAAK;EACb;EACA,gBAAgB,SAAS,SAAS,IAAI,WAAW,CAAC,OAAO;EACzD,UAAU,KAAK,SAAS,QAAQ,YAAY,aAAa,KAAK,OAAO,CAAC;EACtE,QAAQ,UAAU;CACpB;AACF"}
1
+ {"version":3,"file":"view.js","names":[],"sources":["../src/view.ts"],"sourcesContent":["/**\n * What one view is (D104, D108): its artifact, version, policy, submit channels and trusted\n * controls. The browser protocol's frame ticket, the bridge's `ui/initialize` result and the\n * interaction core's channel policy share these shapes, so they live in a module of their own:\n * the bridge, which every version embeds, imports them without the interaction schemas.\n */\nimport * as z from \"zod\";\nimport { ArtifactId, VersionId, ViewId } from \"./ids.ts\";\nimport { SubmissionPolicy } from \"./policy.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** Where a submit came from (D40). */\nexport type SubmitChannel = \"shell\" | \"artifact\";\n\n/** The Zod schema of the `SubmitChannel` type. */\nexport const SubmitChannel: z.ZodType<SubmitChannel> = z\n .enum([\"shell\", \"artifact\"])\n .register(wireRegistry, {\n id: \"SubmitChannel\",\n description: \"Where a submit comes from: the shell's trusted Submit, or the artifact's code.\",\n });\n\n/**\n * A trusted control the shell renders outside the artifact's frame (D06, PRODUCT vocabulary):\n * Submit, Choose (review sets) and Approve. Open for later controls on the wire.\n */\nexport type TrustedControl = \"submit\" | \"choose\" | \"approve\" | (string & {});\n\n/** The Zod schema of the `TrustedControl` type. */\nexport const TrustedControl: z.ZodType<TrustedControl> = z\n .string()\n .regex(/^[a-z][a-z0-9-]{0,31}$/)\n .register(wireRegistry, {\n id: \"TrustedControl\",\n description: \"A trusted control the shell renders: submit, choose, approve; open for more.\",\n });\n\n/**\n * Which submit channels a view accepts and which trusted controls its shell renders (D40, D108):\n * the `trustedControls` port's answer, or the home's `HomeConfig.submitChannels`.\n */\nexport interface ControlsPolicy {\n /** The channels submissions may come through; at least one. */\n readonly submitChannels: readonly SubmitChannel[];\n /** The trusted controls the shell may render; absent: every control the artifact asks for. */\n readonly controls?: readonly TrustedControl[];\n}\n\n/** The Zod schema of the `ControlsPolicy` type. */\nexport const ControlsPolicy: z.ZodType<ControlsPolicy> = z\n .object({\n submitChannels: z.array(SubmitChannel).min(1).max(2).readonly(),\n controls: z.array(TrustedControl).max(32).readonly().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ControlsPolicy\",\n description:\n \"Which submit channels a view accepts and which trusted controls its shell renders (D108).\",\n });\n\n/** A review set's ID: letters, digits, `_` and `-` (its choice is the field `review.<id>.choice`). */\nexport const REVIEW_SET_ID_PATTERN: RegExp = /^[A-Za-z0-9_-]{1,64}$/;\n\n/** Where a client runtime runs (D111): Mostra's gateway, a static export, an MCP App, or `verify`. */\nexport type DeliveryTarget = \"live\" | \"static\" | \"mcp-app\" | \"verify\";\n\n/** A version by ID and number. */\nexport interface VersionRef {\n /** The version's ID. */\n readonly id: string;\n /** Its number, for people. */\n readonly number: number;\n}\n\n/** The Zod schema of the `VersionRef` type. */\nexport const VersionRef: z.ZodType<VersionRef> = z\n .object({ id: VersionId.schema, number: z.int().min(1) })\n .register(wireRegistry, {\n id: \"VersionRef\",\n description: \"A version by ID and number.\",\n });\n\n/**\n * What one view is (D104, D108): the shell learns it from its frame ticket and hands it to the\n * frame in `ui/initialize`'s result, so the client runtime names the view in every request and\n * knows what the host allows.\n */\nexport interface ViewContext {\n /** The artifact. */\n readonly artifactId: string;\n /** The view this frame load is; every mutation and submit names it (D104). */\n readonly viewId: string;\n /** The version the view shows. */\n readonly version: VersionRef;\n /** The artifact's latest version when the view opened. */\n readonly latest: VersionRef;\n /** The submission policy in force (D102). */\n readonly policy: SubmissionPolicy;\n /** The submit channels this view accepts (D108). */\n readonly submitChannels: readonly SubmitChannel[];\n /** The trusted controls the shell renders for this view (D108). */\n readonly controls: readonly TrustedControl[];\n /** Always `live` in a frame Mostra's shell hosts. */\n readonly target: DeliveryTarget;\n}\n\n/** The Zod schema of the `ViewContext` type. */\nexport const ViewContext: z.ZodType<ViewContext> = z\n .object({\n artifactId: ArtifactId.schema,\n viewId: ViewId.schema,\n version: VersionRef,\n latest: VersionRef,\n policy: SubmissionPolicy,\n submitChannels: z.array(SubmitChannel).min(1).max(2).readonly(),\n controls: z.array(TrustedControl).max(32).readonly(),\n target: z.enum([\"live\", \"static\", \"mcp-app\", \"verify\"]),\n })\n .register(wireRegistry, {\n id: \"ViewContext\",\n description:\n \"What one view is: its artifact, view ID, version, latest version, policy, channels and controls.\",\n });\n\n/**\n * A view as a page reads it from `ui/initialize` (Claude review finding 5): every published\n * version embeds the page's reader, so it takes values a later Mostra may add (a channel, a\n * policy, a target) without refusing the whole view; {@link readViewContext} reads them safely.\n */\nexport interface ViewContextWire {\n /** The artifact. */\n readonly artifactId: string;\n /** The view this frame load is (D104). */\n readonly viewId: string;\n /** The version the view shows. */\n readonly version: VersionRef;\n /** The artifact's latest version when the view opened. */\n readonly latest: VersionRef;\n /** The submission policy in force (D102); a later policy or scope is read as `once` per viewer. */\n readonly policy: {\n /** `once`, `epochs`, `none`, or one a later release adds. */\n readonly policy: string;\n /** `per-artifact` or `per-viewer` under `once`, or one a later release adds. */\n readonly scope?: string;\n };\n /** The submit channels the view accepts (D108); channels this release doesn't know are not allowed. */\n readonly submitChannels: readonly string[];\n /** The trusted controls the shell renders for the view (D108). */\n readonly controls: readonly string[];\n /** Where the page runs (D111); a target this release doesn't know is read as `live`. */\n readonly target: string;\n}\n\n/** The Zod schema of the `ViewContextWire` type: open where later revisions may add values. */\nexport const ViewContextWire: z.ZodType<ViewContextWire> = z.looseObject({\n artifactId: ArtifactId.schema,\n viewId: ViewId.schema,\n version: VersionRef,\n latest: VersionRef,\n policy: z.looseObject({ policy: z.string(), scope: z.string().exactOptional() }),\n submitChannels: z.array(z.string()).max(16).readonly(),\n controls: z.array(z.string()).max(32).readonly(),\n target: z.string(),\n}) as z.ZodType<ViewContextWire>;\n\nconst CONTROL_NAME = /^[a-z][a-z0-9-]{0,31}$/;\n\n/**\n * The view a page acts on, with every value this release doesn't know read the safe way: an\n * unknown channel isn't allowed (the shell's stays), an unknown policy or `once` scope is read as\n * `once` per viewer (the page may submit and the server decides; it closes on its own submission\n * only), and an unknown target as `live`.\n */\nexport function readViewContext(wire: ViewContextWire): ViewContext {\n const channels = ([\"shell\", \"artifact\"] as const).filter((channel) =>\n wire.submitChannels.includes(channel),\n );\n const { policy: name, scope } = wire.policy;\n const policy: SubmissionPolicy =\n name === \"none\"\n ? { policy: \"none\" }\n : name === \"epochs\"\n ? { policy: \"epochs\" }\n : name === \"once\" && (scope === undefined || scope === \"per-artifact\")\n ? { policy: \"once\", scope: \"per-artifact\" }\n : { policy: \"once\", scope: \"per-viewer\" };\n const target = ([\"live\", \"static\", \"mcp-app\", \"verify\"] as const).find(\n (known) => known === wire.target,\n );\n return {\n artifactId: wire.artifactId,\n viewId: wire.viewId,\n version: wire.version,\n latest: wire.latest,\n policy,\n submitChannels: channels.length > 0 ? channels : [\"shell\"],\n controls: wire.controls.filter((control) => CONTROL_NAME.test(control)),\n target: target ?? \"live\",\n };\n}\n"],"mappings":";;;;;;;;;;;;AAeA,MAAa,gBAA0C,EACpD,KAAK,CAAC,SAAS,UAAU,CAAC,CAAC,CAC3B,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AASH,MAAa,iBAA4C,EACtD,OAAO,CAAC,CACR,MAAM,wBAAwB,CAAC,CAC/B,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAcH,MAAa,iBAA4C,EACtD,OAAO;CACN,gBAAgB,EAA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EAAE,OAAO;AACnB,CAAC;AAED,MAAM,eAAe;;;;;;;AAQrB,SAAgB,gBAAgB,MAAoC;CAClE,MAAM,WAAY,CAAC,SAAS,UAAU,CAAC,CAAW,QAAQ,YACxD,KAAK,eAAe,SAAS,OAAO,CACtC;CACA,MAAM,EAAE,QAAQ,MAAM,UAAU,KAAK;CACrC,MAAM,SACJ,SAAS,SACL,EAAE,QAAQ,OAAO,IACjB,SAAS,WACP,EAAE,QAAQ,SAAS,IACnB,SAAS,WAAW,UAAU,KAAA,KAAa,UAAU,kBACnD;EAAE,QAAQ;EAAQ,OAAO;CAAe,IACxC;EAAE,QAAQ;EAAQ,OAAO;CAAa;CAChD,MAAM,SAAU;EAAC;EAAQ;EAAU;EAAW;CAAQ,CAAC,CAAW,MAC/D,UAAU,UAAU,KAAK,MAC5B;CACA,OAAO;EACL,YAAY,KAAK;EACjB,QAAQ,KAAK;EACb,SAAS,KAAK;EACd,QAAQ,KAAK;EACb;EACA,gBAAgB,SAAS,SAAS,IAAI,WAAW,CAAC,OAAO;EACzD,UAAU,KAAK,SAAS,QAAQ,YAAY,aAAa,KAAK,OAAO,CAAC;EACtE,QAAQ,UAAU;CACpB;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mostra/protocol",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "Mostra's shared protocol vocabulary: IDs, dated revisions and diagnostics, with Zod schemas and generated JSON Schema.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "The Mostra Authors",
@@ -66,7 +66,7 @@
66
66
  "ignore": [
67
67
  "zod"
68
68
  ],
69
- "limit": "52 kB"
69
+ "limit": "60 kB"
70
70
  },
71
71
  {
72
72
  "name": "@mostra/protocol JSON-RPC core (D83, zod excluded)",