@mostra/protocol 0.9.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 (211) 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 +12 -1
  20. package/dist/diagnostics/codes/artifact.js.map +1 -1
  21. package/dist/diagnostics/codes/home.d.ts +1 -1
  22. package/dist/diagnostics/codes/home.d.ts.map +1 -1
  23. package/dist/diagnostics/codes/home.js +12 -1
  24. package/dist/diagnostics/codes/home.js.map +1 -1
  25. package/dist/diagnostics/codes/index.d.ts +3 -2
  26. package/dist/diagnostics/codes/index.d.ts.map +1 -1
  27. package/dist/diagnostics/codes/index.js +3 -1
  28. package/dist/diagnostics/codes/index.js.map +1 -1
  29. package/dist/diagnostics/codes/remote.d.ts +8 -0
  30. package/dist/diagnostics/codes/remote.d.ts.map +1 -0
  31. package/dist/diagnostics/codes/remote.js +99 -0
  32. package/dist/diagnostics/codes/remote.js.map +1 -0
  33. package/dist/diagnostics/diagnostic.d.ts +1 -1
  34. package/dist/diagnostics/diagnostic.d.ts.map +1 -1
  35. package/dist/diagnostics/diagnostic.js +2 -1
  36. package/dist/diagnostics/diagnostic.js.map +1 -1
  37. package/dist/duration.d.ts +13 -0
  38. package/dist/duration.d.ts.map +1 -0
  39. package/dist/duration.js +27 -0
  40. package/dist/duration.js.map +1 -0
  41. package/dist/ids.d.ts +17 -1
  42. package/dist/ids.d.ts.map +1 -1
  43. package/dist/ids.js +9 -1
  44. package/dist/ids.js.map +1 -1
  45. package/dist/index.d.ts +30 -8
  46. package/dist/index.js +30 -8
  47. package/dist/interaction.d.ts +28 -2
  48. package/dist/interaction.d.ts.map +1 -1
  49. package/dist/interaction.js +20 -5
  50. package/dist/interaction.js.map +1 -1
  51. package/dist/manifest.d.ts +59 -14
  52. package/dist/manifest.d.ts.map +1 -1
  53. package/dist/manifest.js +63 -15
  54. package/dist/manifest.js.map +1 -1
  55. package/dist/methods/artifact/export.d.ts +40 -0
  56. package/dist/methods/artifact/export.d.ts.map +1 -0
  57. package/dist/methods/artifact/export.js +36 -0
  58. package/dist/methods/artifact/export.js.map +1 -0
  59. package/dist/methods/artifact/import.d.ts +23 -0
  60. package/dist/methods/artifact/import.d.ts.map +1 -0
  61. package/dist/methods/artifact/import.js +25 -0
  62. package/dist/methods/artifact/import.js.map +1 -0
  63. package/dist/methods/artifact/publish.d.ts +2 -1
  64. package/dist/methods/artifact/publish.d.ts.map +1 -1
  65. package/dist/methods/artifact/publish.js +1 -1
  66. package/dist/methods/hosted/push.d.ts +76 -0
  67. package/dist/methods/hosted/push.d.ts.map +1 -0
  68. package/dist/methods/hosted/push.js +71 -0
  69. package/dist/methods/hosted/push.js.map +1 -0
  70. package/dist/methods/hosted/submission.d.ts +18 -0
  71. package/dist/methods/hosted/submission.d.ts.map +1 -0
  72. package/dist/methods/hosted/submission.js +23 -0
  73. package/dist/methods/hosted/submission.js.map +1 -0
  74. package/dist/methods/index.d.ts.map +1 -1
  75. package/dist/methods/index.js +38 -2
  76. package/dist/methods/index.js.map +1 -1
  77. package/dist/methods/instance/status.d.ts +3 -0
  78. package/dist/methods/instance/status.d.ts.map +1 -1
  79. package/dist/methods/instance/status.js +3 -1
  80. package/dist/methods/instance/status.js.map +1 -1
  81. package/dist/methods/mostra/initialize.d.ts +17 -3
  82. package/dist/methods/mostra/initialize.d.ts.map +1 -1
  83. package/dist/methods/mostra/initialize.js +11 -3
  84. package/dist/methods/mostra/initialize.js.map +1 -1
  85. package/dist/methods/port/relay-call.d.ts +33 -0
  86. package/dist/methods/port/relay-call.d.ts.map +1 -0
  87. package/dist/methods/port/relay-call.js +31 -0
  88. package/dist/methods/port/relay-call.js.map +1 -0
  89. package/dist/methods/port/relay-cancel.d.ts +16 -0
  90. package/dist/methods/port/relay-cancel.d.ts.map +1 -0
  91. package/dist/methods/port/relay-cancel.js +21 -0
  92. package/dist/methods/port/relay-cancel.js.map +1 -0
  93. package/dist/methods/port/relay-live.d.ts +25 -0
  94. package/dist/methods/port/relay-live.d.ts.map +1 -0
  95. package/dist/methods/port/relay-live.js +32 -0
  96. package/dist/methods/port/relay-live.js.map +1 -0
  97. package/dist/methods/port/relay-reconcile.d.ts +39 -0
  98. package/dist/methods/port/relay-reconcile.d.ts.map +1 -0
  99. package/dist/methods/port/relay-reconcile.js +35 -0
  100. package/dist/methods/port/relay-reconcile.js.map +1 -0
  101. package/dist/methods/port/relay-run.d.ts +47 -0
  102. package/dist/methods/port/relay-run.d.ts.map +1 -0
  103. package/dist/methods/port/relay-run.js +41 -0
  104. package/dist/methods/port/relay-run.js.map +1 -0
  105. package/dist/methods/port/submissions-deliver.d.ts +8 -0
  106. package/dist/methods/port/submissions-deliver.d.ts.map +1 -1
  107. package/dist/methods/port/submissions-deliver.js +4 -2
  108. package/dist/methods/port/submissions-deliver.js.map +1 -1
  109. package/dist/methods/relay/call-batch.d.ts +26 -0
  110. package/dist/methods/relay/call-batch.d.ts.map +1 -0
  111. package/dist/methods/relay/call-batch.js +30 -0
  112. package/dist/methods/relay/call-batch.js.map +1 -0
  113. package/dist/methods/relay/effect.d.ts +31 -0
  114. package/dist/methods/relay/effect.d.ts.map +1 -0
  115. package/dist/methods/relay/effect.js +30 -0
  116. package/dist/methods/relay/effect.js.map +1 -0
  117. package/dist/methods/relay/live-value.d.ts +33 -0
  118. package/dist/methods/relay/live-value.d.ts.map +1 -0
  119. package/dist/methods/relay/live-value.js +32 -0
  120. package/dist/methods/relay/live-value.js.map +1 -0
  121. package/dist/methods/relay/run-update.d.ts +46 -0
  122. package/dist/methods/relay/run-update.d.ts.map +1 -0
  123. package/dist/methods/relay/run-update.js +45 -0
  124. package/dist/methods/relay/run-update.js.map +1 -0
  125. package/dist/methods/remote/login-wait.d.ts +30 -0
  126. package/dist/methods/remote/login-wait.d.ts.map +1 -0
  127. package/dist/methods/remote/login-wait.js +36 -0
  128. package/dist/methods/remote/login-wait.js.map +1 -0
  129. package/dist/methods/remote/login.d.ts +41 -0
  130. package/dist/methods/remote/login.d.ts.map +1 -0
  131. package/dist/methods/remote/login.js +37 -0
  132. package/dist/methods/remote/login.js.map +1 -0
  133. package/dist/methods/remote/logout.d.ts +25 -0
  134. package/dist/methods/remote/logout.d.ts.map +1 -0
  135. package/dist/methods/remote/logout.js +28 -0
  136. package/dist/methods/remote/logout.js.map +1 -0
  137. package/dist/methods/remote/status.d.ts +14 -0
  138. package/dist/methods/remote/status.d.ts.map +1 -0
  139. package/dist/methods/remote/status.js +22 -0
  140. package/dist/methods/remote/status.js.map +1 -0
  141. package/dist/methods/remote/token.d.ts +19 -0
  142. package/dist/methods/remote/token.d.ts.map +1 -0
  143. package/dist/methods/remote/token.js +24 -0
  144. package/dist/methods/remote/token.js.map +1 -0
  145. package/dist/methods/share/start.d.ts +5 -2
  146. package/dist/methods/share/start.d.ts.map +1 -1
  147. package/dist/methods/share/start.js +6 -3
  148. package/dist/methods/share/start.js.map +1 -1
  149. package/dist/methods/state/patch.d.ts +7 -0
  150. package/dist/methods/state/patch.d.ts.map +1 -1
  151. package/dist/methods/state/patch.js +2 -1
  152. package/dist/methods/state/patch.js.map +1 -1
  153. package/dist/methods/view/url.d.ts +2 -1
  154. package/dist/methods/view/url.d.ts.map +1 -1
  155. package/dist/methods/view/url.js +2 -1
  156. package/dist/methods/view/url.js.map +1 -1
  157. package/dist/policy.d.ts +18 -0
  158. package/dist/policy.d.ts.map +1 -0
  159. package/dist/policy.js +23 -0
  160. package/dist/policy.js.map +1 -0
  161. package/dist/remote.d.ts +55 -0
  162. package/dist/remote.d.ts.map +1 -0
  163. package/dist/remote.js +52 -0
  164. package/dist/remote.js.map +1 -0
  165. package/dist/view.d.ts +1 -1
  166. package/dist/view.js +1 -1
  167. package/dist/view.js.map +1 -1
  168. package/package.json +2 -2
  169. package/schemas/protocol.draft-07.json +1607 -126
  170. package/schemas/protocol.schema.json +1543 -126
  171. package/src/actions.ts +45 -5
  172. package/src/browser.ts +6 -0
  173. package/src/capability.ts +0 -23
  174. package/src/diagnostics/codes/artifact.ts +12 -0
  175. package/src/diagnostics/codes/home.ts +12 -0
  176. package/src/diagnostics/codes/index.ts +6 -2
  177. package/src/diagnostics/codes/remote.ts +113 -0
  178. package/src/diagnostics/diagnostic.ts +3 -1
  179. package/src/duration.ts +29 -0
  180. package/src/ids.ts +33 -1
  181. package/src/index.ts +124 -8
  182. package/src/interaction.ts +42 -2
  183. package/src/manifest.ts +115 -24
  184. package/src/methods/artifact/export.ts +68 -0
  185. package/src/methods/artifact/import.ts +39 -0
  186. package/src/methods/hosted/push.ts +146 -0
  187. package/src/methods/hosted/submission.ts +34 -0
  188. package/src/methods/index.ts +36 -0
  189. package/src/methods/instance/status.ts +4 -0
  190. package/src/methods/mostra/initialize.ts +19 -3
  191. package/src/methods/port/relay-call.ts +58 -0
  192. package/src/methods/port/relay-cancel.ts +33 -0
  193. package/src/methods/port/relay-live.ts +48 -0
  194. package/src/methods/port/relay-reconcile.ts +71 -0
  195. package/src/methods/port/relay-run.ts +80 -0
  196. package/src/methods/port/submissions-deliver.ts +13 -1
  197. package/src/methods/relay/call-batch.ts +52 -0
  198. package/src/methods/relay/effect.ts +55 -0
  199. package/src/methods/relay/live-value.ts +54 -0
  200. package/src/methods/relay/run-update.ts +81 -0
  201. package/src/methods/remote/login-wait.ts +55 -0
  202. package/src/methods/remote/login.ts +72 -0
  203. package/src/methods/remote/logout.ts +42 -0
  204. package/src/methods/remote/status.ts +34 -0
  205. package/src/methods/remote/token.ts +39 -0
  206. package/src/methods/share/start.ts +12 -4
  207. package/src/methods/state/patch.ts +6 -0
  208. package/src/methods/view/url.ts +2 -1
  209. package/src/policy.ts +30 -0
  210. package/src/remote.ts +89 -0
  211. package/src/view.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"start.js","names":[],"sources":["../../../src/methods/share/start.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { ArtifactRef } from \"../../artifact.ts\";\nimport { CapabilityScope, Duration } from \"../../capability.ts\";\nimport { ArtifactId, ShareId, TokenId } from \"../../ids.ts\";\nimport { ViewerSpec } from \"../../interaction.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\n\n/**\n * How a share reaches its viewers (D158): `tailnet` through Tailscale Serve, to the people of the\n * user's tailnet, who are known by name; `funnel` through Tailscale Funnel and `cloudflare`\n * through a Cloudflare quick tunnel, both public, where the link is all that admits a viewer.\n */\nexport type ShareVia = \"tailnet\" | \"funnel\" | \"cloudflare\";\n\n/** The Zod schema of the `ShareVia` type. */\nexport const ShareVia: z.ZodType<ShareVia> = z\n .enum([\"tailnet\", \"funnel\", \"cloudflare\"])\n .register(wireRegistry, {\n id: \"ShareVia\",\n description: \"How a share reaches its viewers: tailnet, funnel or cloudflare.\",\n });\n\n/** The longest a public share (Funnel or Cloudflare) may last: 7 days (D158). */\nexport const PUBLIC_SHARE_MAX_TTL_MS: number = 7 * 24 * 60 * 60 * 1000;\n\n/** How long a public share lasts when its `ttl` isn't given: 1 hour (D63 item 5, D158). */\nexport const PUBLIC_SHARE_DEFAULT_TTL: Duration = \"1h\";\n\n/** The params of `share/start` (INTERFACES §6, D158). */\nexport interface ShareStartParams {\n /** The artifact to share; the link opens its latest version. */\n readonly artifact: ArtifactRef;\n /** The tunnel. A public one (`funnel`, `cloudflare`) is explicit: never a fallback. */\n readonly via: ShareVia;\n /**\n * How long the share and its link last, such as `30m` or `24h`. Public shares: 1 hour by\n * default, at most 7 days. Tailnet shares: until stopped, unless given.\n */\n readonly ttl?: Duration;\n /** What the share's link allows (D97). Default: every scope. */\n readonly scopes?: readonly CapabilityScope[];\n /**\n * The person the share's link acts for (D104). Absent: whoever the tailnet or a host's identity\n * port names, else the link's own viewer, never the home's local user (D158).\n */\n readonly viewer?: ViewerSpec;\n /** Makes retries idempotent: a repeated `requestId` returns the same share (H-03). */\n readonly requestId?: string;\n}\n\n/** A share, as `share/start` and `share/list` report it. */\nexport interface Share {\n /** The share's ID, for `share/stop`. */\n readonly shareId: string;\n /** The artifact shared. */\n readonly artifactId: string;\n /** The tunnel. */\n readonly via: ShareVia;\n /**\n * The share's capability URL, at the tunnel's address. Holding it is the authorization (D06);\n * absent once the share ended, and in `share/list` when the home's key can no longer show it.\n */\n readonly url?: string;\n /** The tunnel's host name: the tailnet device's, or the quick tunnel's random one. */\n readonly hostname: string;\n /**\n * The address the artifact's frame is served at over the tunnel, while the share is active:\n * on a tailnet, the second port of this device that viewers must be allowed to reach.\n */\n readonly artifactOrigin?: string;\n /**\n * How the artifact's frame authenticates over this tunnel (D70): `cookie` where the shell and\n * the artifact are one site (Tailscale), `worker` where they are two (Cloudflare).\n */\n readonly mode: \"cookie\" | \"worker\";\n /** The share's link, for `view/rotate` and `view/revoke`. */\n readonly tokenId: string;\n /** When the share started (RFC 3339, UTC). */\n readonly startedAt: string;\n /** When the share and its link end, if they do. */\n readonly expiresAt?: string;\n /** `active` while it serves; `stopped` once it ended. */\n readonly state: \"active\" | \"stopped\";\n /** When it ended. */\n readonly stoppedAt?: string;\n /**\n * Why it ended: `stopped` (`share/stop`), `expired` (its TTL), `tunnel` (its tunnel ended and\n * couldn't be set up again), `restart` (a quick tunnel can't outlive its instance), or\n * `revoked` (its link was revoked).\n */\n readonly stopReason?: \"stopped\" | \"expired\" | \"tunnel\" | \"restart\" | \"revoked\" | (string & {});\n}\n\nconst shareShape = {\n shareId: ShareId.schema,\n artifactId: ArtifactId.schema,\n via: ShareVia,\n url: z.string().min(1).exactOptional(),\n hostname: z.string().min(1),\n artifactOrigin: z.string().min(1).exactOptional(),\n mode: z.enum([\"cookie\", \"worker\"]),\n tokenId: TokenId.schema,\n startedAt: z.iso.datetime(),\n expiresAt: z.iso.datetime().exactOptional(),\n state: z.enum([\"active\", \"stopped\"]),\n stoppedAt: z.iso.datetime().exactOptional(),\n stopReason: z.string().min(1).exactOptional(),\n};\n\n/** The Zod schema of the `Share` type. */\nexport const Share: z.ZodType<Share> = z.object(shareShape).register(wireRegistry, {\n id: \"Share\",\n description: \"A share: its tunnel, link, address, frame mode and lifetime.\",\n});\n\n/** The result of `share/start`: the share, with its link. */\nexport type ShareStartResult = Share & { readonly url: string };\n\nconst params: z.ZodType<ShareStartParams> = z\n .object({\n artifact: ArtifactRef,\n via: ShareVia,\n ttl: Duration.exactOptional(),\n scopes: z.array(CapabilityScope).min(1).readonly().exactOptional(),\n viewer: ViewerSpec.exactOptional(),\n requestId: z.string().min(1).exactOptional(),\n })\n .register(wireRegistry, { id: \"ShareStartParams\" });\n\nconst result: z.ZodType<ShareStartResult> = z\n .object({ ...shareShape, url: z.string().min(1) })\n .register(wireRegistry, {\n id: \"ShareStartResult\",\n description: \"The share that started, with its capability URL.\",\n });\n\n/**\n * `share/start`: shares an artifact through a tunnel the instance drives (D158): Tailscale Serve\n * for the tailnet, or Tailscale Funnel or a Cloudflare quick tunnel for anyone with the link. It\n * answers once the tunnel serves, with a new link at the tunnel's address that works there only.\n * A missing or unready tool is a `MOSTRA_SHARE_*` diagnostic saying what to do.\n */\nexport const shareStartMethod: MethodDefinition<ShareStartParams, ShareStartResult> = defineMethod({\n method: \"share/start\",\n direction: \"client-to-instance\",\n mutating: true,\n params,\n result,\n});\n"],"mappings":";;;;;;;;;AAgBA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,IAAI,CAAC;AAAE,CAAC,CAAC,CACjD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;;;;;;AAQH,MAAa,mBAAyE,aAAa;CACjG,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA;AACF,CAAC"}
1
+ {"version":3,"file":"start.js","names":[],"sources":["../../../src/methods/share/start.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { ArtifactRef } from \"../../artifact.ts\";\nimport { CapabilityScope } from \"../../capability.ts\";\nimport { Duration } from \"../../duration.ts\";\nimport { ArtifactId, ShareId, TokenId } from \"../../ids.ts\";\nimport { ViewerSpec } from \"../../interaction.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\n\n/**\n * How a share reaches its viewers (D158): `tailnet` through Tailscale Serve, to the people of the\n * user's tailnet, who are known by name; `funnel` through Tailscale Funnel and `cloudflare`\n * through a Cloudflare quick tunnel, both public, where the link is all that admits a viewer.\n */\nexport type ShareVia = \"tailnet\" | \"funnel\" | \"cloudflare\" | \"remote\";\n\n/** The Zod schema of the `ShareVia` type. */\nexport const ShareVia: z.ZodType<ShareVia> = z\n .enum([\"tailnet\", \"funnel\", \"cloudflare\", \"remote\"])\n .register(wireRegistry, {\n id: \"ShareVia\",\n description:\n \"How a share reaches its viewers: tailnet, funnel or cloudflare, or remote: hosted on a remote server (D165).\",\n });\n\n/** The longest a public share (Funnel or Cloudflare) may last: 7 days (D158). */\nexport const PUBLIC_SHARE_MAX_TTL_MS: number = 7 * 24 * 60 * 60 * 1000;\n\n/** How long a public share lasts when its `ttl` isn't given: 1 hour (D63 item 5, D158). */\nexport const PUBLIC_SHARE_DEFAULT_TTL: Duration = \"1h\";\n\n/** The params of `share/start` (INTERFACES §6, D158). */\nexport interface ShareStartParams {\n /** The artifact to share; the link opens its latest version. */\n readonly artifact: ArtifactRef;\n /** The tunnel. A public one (`funnel`, `cloudflare`) is explicit: never a fallback. */\n readonly via: ShareVia;\n /** For `remote`: the server's API origin. Default: the home's default server (D165 item 15). */\n readonly server?: string;\n /**\n * How long the share and its link last, such as `30m` or `24h`. Public shares: 1 hour by\n * default, at most 7 days. Tailnet shares: until stopped, unless given.\n */\n readonly ttl?: Duration;\n /** What the share's link allows (D97). Default: every scope. */\n readonly scopes?: readonly CapabilityScope[];\n /**\n * The person the share's link acts for (D104). Absent: whoever the tailnet or a host's identity\n * port names, else the link's own viewer, never the home's local user (D158).\n */\n readonly viewer?: ViewerSpec;\n /** Makes retries idempotent: a repeated `requestId` returns the same share (H-03). */\n readonly requestId?: string;\n}\n\n/** A share, as `share/start` and `share/list` report it. */\nexport interface Share {\n /** The share's ID, for `share/stop`. */\n readonly shareId: string;\n /** The artifact shared. */\n readonly artifactId: string;\n /** The tunnel. */\n readonly via: ShareVia;\n /**\n * The share's capability URL, at the tunnel's address. Holding it is the authorization (D06);\n * absent once the share ended, and in `share/list` when the home's key can no longer show it.\n */\n readonly url?: string;\n /** The tunnel's host name: the tailnet device's, or the quick tunnel's random one. */\n readonly hostname: string;\n /**\n * The address the artifact's frame is served at over the tunnel, while the share is active:\n * on a tailnet, the second port of this device that viewers must be allowed to reach.\n */\n readonly artifactOrigin?: string;\n /**\n * How the artifact's frame authenticates over this tunnel (D70): `cookie` where the shell and\n * the artifact are one site (Tailscale), `worker` where they are two (Cloudflare).\n */\n readonly mode: \"cookie\" | \"worker\";\n /** The share's link, for `view/rotate` and `view/revoke`. */\n readonly tokenId: string;\n /** When the share started (RFC 3339, UTC). */\n readonly startedAt: string;\n /** When the share and its link end, if they do. */\n readonly expiresAt?: string;\n /** `active` while it serves; `stopped` once it ended. */\n readonly state: \"active\" | \"stopped\";\n /** When it ended. */\n readonly stoppedAt?: string;\n /**\n * Why it ended: `stopped` (`share/stop`), `expired` (its TTL), `tunnel` (its tunnel ended and\n * couldn't be set up again), `restart` (a quick tunnel can't outlive its instance), or\n * `revoked` (its link was revoked).\n */\n readonly stopReason?: \"stopped\" | \"expired\" | \"tunnel\" | \"restart\" | \"revoked\" | (string & {});\n}\n\nconst shareShape = {\n shareId: ShareId.schema,\n artifactId: ArtifactId.schema,\n via: ShareVia,\n url: z.string().min(1).exactOptional(),\n hostname: z.string().min(1),\n artifactOrigin: z.string().min(1).exactOptional(),\n mode: z.enum([\"cookie\", \"worker\"]),\n tokenId: TokenId.schema,\n startedAt: z.iso.datetime(),\n expiresAt: z.iso.datetime().exactOptional(),\n state: z.enum([\"active\", \"stopped\"]),\n stoppedAt: z.iso.datetime().exactOptional(),\n stopReason: z.string().min(1).exactOptional(),\n};\n\n/** The Zod schema of the `Share` type. */\nexport const Share: z.ZodType<Share> = z.object(shareShape).register(wireRegistry, {\n id: \"Share\",\n description: \"A share: its tunnel, link, address, frame mode and lifetime.\",\n});\n\n/** The result of `share/start`: the share, with its link. */\nexport type ShareStartResult = Share & { readonly url: string };\n\nconst params: z.ZodType<ShareStartParams> = z\n .object({\n artifact: ArtifactRef,\n via: ShareVia,\n server: z\n .string()\n .regex(/^https?:\\/\\/[^/?#\\s]+$/)\n .exactOptional(),\n ttl: Duration.exactOptional(),\n scopes: z.array(CapabilityScope).min(1).readonly().exactOptional(),\n viewer: ViewerSpec.exactOptional(),\n requestId: z.string().min(1).exactOptional(),\n })\n .register(wireRegistry, { id: \"ShareStartParams\" });\n\nconst result: z.ZodType<ShareStartResult> = z\n .object({ ...shareShape, url: z.string().min(1) })\n .register(wireRegistry, {\n id: \"ShareStartResult\",\n description: \"The share that started, with its capability URL.\",\n });\n\n/**\n * `share/start`: shares an artifact through a tunnel the instance drives (D158): Tailscale Serve\n * for the tailnet, or Tailscale Funnel or a Cloudflare quick tunnel for anyone with the link. It\n * answers once the tunnel serves, with a new link at the tunnel's address that works there only.\n * A missing or unready tool is a `MOSTRA_SHARE_*` diagnostic saying what to do.\n */\nexport const shareStartMethod: MethodDefinition<ShareStartParams, ShareStartResult> = defineMethod({\n method: \"share/start\",\n direction: \"client-to-instance\",\n mutating: true,\n params,\n result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Ac,EAAE,IAAI,mBAAmB,CAAC;AAEpD,MAAM,SAAsC,EACzC,OAAO;CAAE,GAAG;CAAY,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AAAE,CAAC,CAAC,CACjD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;;;;;;AAQH,MAAa,mBAAyE,aAAa;CACjG,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA;AACF,CAAC"}
@@ -20,6 +20,13 @@ export interface StatePatchParams {
20
20
  readonly mutationId: string;
21
21
  /** Who writes: `agent` (the default) or `host`, recorded as each field's last writer. */
22
22
  readonly as?: "agent" | "host";
23
+ /**
24
+ * The relayed run whose server code writes it (`state` in `@mostra/server`, D165 item 4): the
25
+ * change is recorded as that run's, as a local run's own write is.
26
+ */
27
+ readonly causation?: {
28
+ readonly runId: string;
29
+ };
23
30
  }
24
31
  /** The result of `state/patch`. */
25
32
  export type StatePatchResult = MutationResult;
@@ -1 +1 @@
1
- {"version":3,"file":"patch.d.ts","names":[],"sources":["../../../src/methods/state/patch.ts"],"mappings":";;;;;iBAQiB;;WAEN,UAAU;;WAEV,cAAc;;;;;WAKd,eAAe;;;;;WAKf;;WAEA;;;YAIC,mBAAmB;;;;;qBAgBlB,kBAAkB,iBAAiB,kBAAkB"}
1
+ {"version":3,"file":"patch.d.ts","names":[],"sources":["../../../src/methods/state/patch.ts"],"mappings":";;;;;iBAQiB;;WAEN,UAAU;;WAEV,cAAc;;;;;WAKd,eAAe;;;;;WAKf;;WAEA;;;;;WAKA;aAAuB;;;;YAItB,mBAAmB;;;;;qBAiBlB,kBAAkB,iBAAiB,kBAAkB"}
@@ -10,7 +10,8 @@ const params = z.object({
10
10
  ops: z.array(FieldOp).min(1).max(1e3).readonly(),
11
11
  baseRevision: DocumentRevision.exactOptional(),
12
12
  mutationId: MutationId.schema,
13
- as: z.enum(["agent", "host"]).exactOptional()
13
+ as: z.enum(["agent", "host"]).exactOptional(),
14
+ causation: z.object({ runId: z.string().min(1) }).exactOptional()
14
15
  }).register(wireRegistry, { id: "StatePatchParams" });
15
16
  /**
16
17
  * `state/patch`: writes an artifact's shared state with compare-and-set and per-field conflicts,
@@ -1 +1 @@
1
- {"version":3,"file":"patch.js","names":[],"sources":["../../../src/methods/state/patch.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { ArtifactRef } from \"../../artifact.ts\";\nimport { MutationId } from \"../../ids.ts\";\nimport { DocumentRevision, FieldOp, MutationResult } from \"../../interaction.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\n\n/** The params of `state/patch` (INTERFACES §6, D63, D106). */\nexport interface StatePatchParams {\n /** The artifact whose shared state to write. */\n readonly artifact: ArtifactRef;\n /** The field changes, applied together under one revision. */\n readonly ops: readonly FieldOp[];\n /**\n * The state revision the caller last read. A field changed after it is a conflict and keeps its\n * value; the other ops apply. Absent: every op applies, whatever changed in between.\n */\n readonly baseRevision?: DocumentRevision;\n /**\n * The change's ID, the idempotency key of this method (H-03): a retry with the same ID and\n * contents returns the recorded result.\n */\n readonly mutationId: string;\n /** Who writes: `agent` (the default) or `host`, recorded as each field's last writer. */\n readonly as?: \"agent\" | \"host\";\n}\n\n/** The result of `state/patch`. */\nexport type StatePatchResult = MutationResult;\n\nconst params: z.ZodType<StatePatchParams> = z\n .object({\n artifact: ArtifactRef,\n ops: z.array(FieldOp).min(1).max(1000).readonly(),\n baseRevision: DocumentRevision.exactOptional(),\n mutationId: MutationId.schema,\n as: z.enum([\"agent\", \"host\"]).exactOptional(),\n })\n .register(wireRegistry, { id: \"StatePatchParams\" });\n\n/**\n * `state/patch`: writes an artifact's shared state with compare-and-set and per-field conflicts,\n * through the same path as viewers' edits (D63). Changes append `state.changed`.\n */\nexport const statePatchMethod: MethodDefinition<StatePatchParams, StatePatchResult> = defineMethod({\n method: \"state/patch\",\n direction: \"client-to-instance\",\n mutating: true,\n params,\n result: MutationResult,\n});\n"],"mappings":";;;;;;;AA8BA,MAAM,SAAsC,EACzC,OAAO;CACN,UAAU;CACV,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAI,CAAC,CAAC,SAAS;CAChD,cAAc,iBAAiB,cAAc;CAC7C,YAAY,WAAW;CACvB,IAAI,EAAE,KAAK,CAAC,SAAS,MAAM,CAAC,CAAC,CAAC,cAAc;AAC9C,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,mBAAmB,CAAC;;;;;AAMpD,MAAa,mBAAyE,aAAa;CACjG,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA,QAAQ;AACV,CAAC"}
1
+ {"version":3,"file":"patch.js","names":[],"sources":["../../../src/methods/state/patch.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { ArtifactRef } from \"../../artifact.ts\";\nimport { MutationId } from \"../../ids.ts\";\nimport { DocumentRevision, FieldOp, MutationResult } from \"../../interaction.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\n\n/** The params of `state/patch` (INTERFACES §6, D63, D106). */\nexport interface StatePatchParams {\n /** The artifact whose shared state to write. */\n readonly artifact: ArtifactRef;\n /** The field changes, applied together under one revision. */\n readonly ops: readonly FieldOp[];\n /**\n * The state revision the caller last read. A field changed after it is a conflict and keeps its\n * value; the other ops apply. Absent: every op applies, whatever changed in between.\n */\n readonly baseRevision?: DocumentRevision;\n /**\n * The change's ID, the idempotency key of this method (H-03): a retry with the same ID and\n * contents returns the recorded result.\n */\n readonly mutationId: string;\n /** Who writes: `agent` (the default) or `host`, recorded as each field's last writer. */\n readonly as?: \"agent\" | \"host\";\n /**\n * The relayed run whose server code writes it (`state` in `@mostra/server`, D165 item 4): the\n * change is recorded as that run's, as a local run's own write is.\n */\n readonly causation?: { readonly runId: string };\n}\n\n/** The result of `state/patch`. */\nexport type StatePatchResult = MutationResult;\n\nconst params: z.ZodType<StatePatchParams> = z\n .object({\n artifact: ArtifactRef,\n ops: z.array(FieldOp).min(1).max(1000).readonly(),\n baseRevision: DocumentRevision.exactOptional(),\n mutationId: MutationId.schema,\n as: z.enum([\"agent\", \"host\"]).exactOptional(),\n causation: z.object({ runId: z.string().min(1) }).exactOptional(),\n })\n .register(wireRegistry, { id: \"StatePatchParams\" });\n\n/**\n * `state/patch`: writes an artifact's shared state with compare-and-set and per-field conflicts,\n * through the same path as viewers' edits (D63). Changes append `state.changed`.\n */\nexport const statePatchMethod: MethodDefinition<StatePatchParams, StatePatchResult> = defineMethod({\n method: \"state/patch\",\n direction: \"client-to-instance\",\n mutating: true,\n params,\n result: MutationResult,\n});\n"],"mappings":";;;;;;;AAmCA,MAAM,SAAsC,EACzC,OAAO;CACN,UAAU;CACV,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAI,CAAC,CAAC,SAAS;CAChD,cAAc,iBAAiB,cAAc;CAC7C,YAAY,WAAW;CACvB,IAAI,EAAE,KAAK,CAAC,SAAS,MAAM,CAAC,CAAC,CAAC,cAAc;CAC5C,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc;AAClE,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,mBAAmB,CAAC;;;;;AAMpD,MAAa,mBAAyE,aAAa;CACjG,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA,QAAQ;AACV,CAAC"}
@@ -1,6 +1,7 @@
1
+ import { Duration } from "../../duration.js";
1
2
  import { ArtifactRef } from "../../artifact.js";
2
3
  import { Viewer, ViewerSpec } from "../../interaction.js";
3
- import { CapabilityScope, Duration } from "../../capability.js";
4
+ import { CapabilityScope } from "../../capability.js";
4
5
  import { MethodDefinition } from "../../method.js";
5
6
  import * as z from "zod";
6
7
  //#region src/methods/view/url.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"url.d.ts","names":[],"sources":["../../../src/methods/view/url.ts"],"mappings":";;;;;;;iBASiB;;WAEN,UAAU;;;;;WAKV;;WAEA,kBAAkB;;WAElB,MAAM;;;;;WAKN,SAAS;;WAET;;;iBAIM;;WAEN;;WAEA;;WAEA,iBAAiB;;WAEjB;;WAEA,SAAS;;;YAIR,gBAAgB;;qBAGf,gBAAgB,EAAE,QAAQ;;;;;;qBA6B1B,eAAe,iBAAiB,eAAe"}
1
+ {"version":3,"file":"url.d.ts","names":[],"sources":["../../../src/methods/view/url.ts"],"mappings":";;;;;;;;iBAUiB;;WAEN,UAAU;;;;;WAKV;;WAEA,kBAAkB;;WAElB,MAAM;;;;;WAKN,SAAS;;WAET;;;iBAIM;;WAEN;;WAEA;;WAEA,iBAAiB;;WAEjB;;WAEA,SAAS;;;YAIR,gBAAgB;;qBAGf,gBAAgB,EAAE,QAAQ;;;;;;qBA6B1B,eAAe,iBAAiB,eAAe"}
@@ -1,8 +1,9 @@
1
1
  import { wireRegistry } from "../../wire-registry.js";
2
2
  import { TokenId, VersionId } from "../../ids.js";
3
+ import { Duration } from "../../duration.js";
3
4
  import { ArtifactRef } from "../../artifact.js";
4
5
  import { Viewer, ViewerSpec } from "../../interaction.js";
5
- import { CapabilityScope, Duration } from "../../capability.js";
6
+ import { CapabilityScope } from "../../capability.js";
6
7
  import { defineMethod } from "../../method.js";
7
8
  import * as z from "zod";
8
9
  //#region src/methods/view/url.ts
@@ -1 +1 @@
1
- {"version":3,"file":"url.js","names":[],"sources":["../../../src/methods/view/url.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { ArtifactRef } from \"../../artifact.ts\";\nimport { CapabilityScope, Duration } from \"../../capability.ts\";\nimport { TokenId, VersionId } from \"../../ids.ts\";\nimport { Viewer, ViewerSpec } from \"../../interaction.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\n\n/** The params of `view/url` (INTERFACES §6, D97). */\nexport interface ViewUrlParams {\n /** The artifact the link opens. */\n readonly artifact: ArtifactRef;\n /**\n * The version the link opens, by number or ID. Without it the link opens the artifact's latest\n * version whenever it is used.\n */\n readonly version?: number | string;\n /** What the link allows (D97). Default: every scope. `view` is always included. */\n readonly scopes?: readonly CapabilityScope[];\n /** How long the link works, such as `24h` or `7d`. Default: until it is revoked (D63). */\n readonly ttl?: Duration;\n /**\n * The person the link acts for (D104): its sessions draft, submit and sign as that viewer, so\n * `once` per-viewer gives each person one submission. Absent: the home's local user.\n */\n readonly viewer?: ViewerSpec;\n /** Makes retries idempotent: a repeated `requestId` returns the same link (H-03). */\n readonly requestId?: string;\n}\n\n/** A capability link: what `view/url` and `view/rotate` return. */\nexport interface CapabilityLink {\n /** The capability URL. Holding it is the authorization (D06); share it like a password. */\n readonly url: string;\n /** The token's ID, for `view/rotate` and `view/revoke`. Never a secret. */\n readonly tokenId: string;\n /** The scopes the link carries, `view` included. */\n readonly scopes: readonly CapabilityScope[];\n /** When the link stops working; absent when it works until revoked. */\n readonly expiresAt?: string;\n /** The viewer the link acts for, when it was minted with one (D104). */\n readonly viewer?: Viewer;\n}\n\n/** The result of `view/url`. */\nexport type ViewUrlResult = CapabilityLink;\n\n/** The Zod schema of the `CapabilityLink` type. */\nexport const CapabilityLink: z.ZodType<CapabilityLink> = z\n .object({\n url: z.string().min(1),\n tokenId: TokenId.schema,\n scopes: z.array(CapabilityScope).readonly(),\n expiresAt: z.iso.datetime().exactOptional(),\n viewer: Viewer.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"CapabilityLink\",\n description: \"A capability URL with its token ID, scopes and expiry.\",\n });\n\nconst params: z.ZodType<ViewUrlParams> = z\n .object({\n artifact: ArtifactRef,\n version: z.union([z.int().min(1), VersionId.schema]).exactOptional(),\n scopes: z.array(CapabilityScope).min(1).readonly().exactOptional(),\n ttl: Duration.exactOptional(),\n viewer: ViewerSpec.exactOptional(),\n requestId: z.string().min(1).exactOptional(),\n })\n .register(wireRegistry, { id: \"ViewUrlParams\" });\n\n/**\n * `view/url`: mints a new capability link to an artifact, with the scopes and lifetime asked for.\n * Each call mints a separate token that `view/revoke` ends on its own; the artifact's default link\n * is the publish receipt's `url`.\n */\nexport const viewUrlMethod: MethodDefinition<ViewUrlParams, ViewUrlResult> = defineMethod({\n method: \"view/url\",\n direction: \"client-to-instance\",\n mutating: true,\n params,\n result: CapabilityLink,\n});\n"],"mappings":";;;;;;;;;AAgDA,MAAa,iBAA4C,EACtD,OAAO;CACN,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACrB,SAAS,QAAQ;CACjB,QAAQ,EAAE,MAAM,eAAe,CAAC,CAAC,SAAS;CAC1C,WAAW,EAAE,IAAI,SAAS,CAAC,CAAC,cAAc;CAC1C,QAAQ,OAAO,cAAc;AAC/B,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;AAEH,MAAM,SAAmC,EACtC,OAAO;CACN,UAAU;CACV,SAAS,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,UAAU,MAAM,CAAC,CAAC,CAAC,cAAc;CACnE,QAAQ,EAAE,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;CACjE,KAAK,SAAS,cAAc;CAC5B,QAAQ,WAAW,cAAc;CACjC,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;AAC7C,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,gBAAgB,CAAC;;;;;;AAOjD,MAAa,gBAAgE,aAAa;CACxF,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA,QAAQ;AACV,CAAC"}
1
+ {"version":3,"file":"url.js","names":[],"sources":["../../../src/methods/view/url.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { ArtifactRef } from \"../../artifact.ts\";\nimport { CapabilityScope } from \"../../capability.ts\";\nimport { Duration } from \"../../duration.ts\";\nimport { TokenId, VersionId } from \"../../ids.ts\";\nimport { Viewer, ViewerSpec } from \"../../interaction.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\n\n/** The params of `view/url` (INTERFACES §6, D97). */\nexport interface ViewUrlParams {\n /** The artifact the link opens. */\n readonly artifact: ArtifactRef;\n /**\n * The version the link opens, by number or ID. Without it the link opens the artifact's latest\n * version whenever it is used.\n */\n readonly version?: number | string;\n /** What the link allows (D97). Default: every scope. `view` is always included. */\n readonly scopes?: readonly CapabilityScope[];\n /** How long the link works, such as `24h` or `7d`. Default: until it is revoked (D63). */\n readonly ttl?: Duration;\n /**\n * The person the link acts for (D104): its sessions draft, submit and sign as that viewer, so\n * `once` per-viewer gives each person one submission. Absent: the home's local user.\n */\n readonly viewer?: ViewerSpec;\n /** Makes retries idempotent: a repeated `requestId` returns the same link (H-03). */\n readonly requestId?: string;\n}\n\n/** A capability link: what `view/url` and `view/rotate` return. */\nexport interface CapabilityLink {\n /** The capability URL. Holding it is the authorization (D06); share it like a password. */\n readonly url: string;\n /** The token's ID, for `view/rotate` and `view/revoke`. Never a secret. */\n readonly tokenId: string;\n /** The scopes the link carries, `view` included. */\n readonly scopes: readonly CapabilityScope[];\n /** When the link stops working; absent when it works until revoked. */\n readonly expiresAt?: string;\n /** The viewer the link acts for, when it was minted with one (D104). */\n readonly viewer?: Viewer;\n}\n\n/** The result of `view/url`. */\nexport type ViewUrlResult = CapabilityLink;\n\n/** The Zod schema of the `CapabilityLink` type. */\nexport const CapabilityLink: z.ZodType<CapabilityLink> = z\n .object({\n url: z.string().min(1),\n tokenId: TokenId.schema,\n scopes: z.array(CapabilityScope).readonly(),\n expiresAt: z.iso.datetime().exactOptional(),\n viewer: Viewer.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"CapabilityLink\",\n description: \"A capability URL with its token ID, scopes and expiry.\",\n });\n\nconst params: z.ZodType<ViewUrlParams> = z\n .object({\n artifact: ArtifactRef,\n version: z.union([z.int().min(1), VersionId.schema]).exactOptional(),\n scopes: z.array(CapabilityScope).min(1).readonly().exactOptional(),\n ttl: Duration.exactOptional(),\n viewer: ViewerSpec.exactOptional(),\n requestId: z.string().min(1).exactOptional(),\n })\n .register(wireRegistry, { id: \"ViewUrlParams\" });\n\n/**\n * `view/url`: mints a new capability link to an artifact, with the scopes and lifetime asked for.\n * Each call mints a separate token that `view/revoke` ends on its own; the artifact's default link\n * is the publish receipt's `url`.\n */\nexport const viewUrlMethod: MethodDefinition<ViewUrlParams, ViewUrlResult> = defineMethod({\n method: \"view/url\",\n direction: \"client-to-instance\",\n mutating: true,\n params,\n result: CapabilityLink,\n});\n"],"mappings":";;;;;;;;;;AAiDA,MAAa,iBAA4C,EACtD,OAAO;CACN,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACrB,SAAS,QAAQ;CACjB,QAAQ,EAAE,MAAM,eAAe,CAAC,CAAC,SAAS;CAC1C,WAAW,EAAE,IAAI,SAAS,CAAC,CAAC,cAAc;CAC1C,QAAQ,OAAO,cAAc;AAC/B,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;AAEH,MAAM,SAAmC,EACtC,OAAO;CACN,UAAU;CACV,SAAS,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,UAAU,MAAM,CAAC,CAAC,CAAC,cAAc;CACnE,QAAQ,EAAE,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;CACjE,KAAK,SAAS,cAAc;CAC5B,QAAQ,WAAW,cAAc;CACjC,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;AAC7C,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,gBAAgB,CAAC;;;;;;AAOjD,MAAa,gBAAgE,aAAa;CACxF,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA,QAAQ;AACV,CAAC"}
@@ -0,0 +1,18 @@
1
+ import * as z from "zod";
2
+ //#region src/policy.d.ts
3
+ /**
4
+ * The submission policy an artifact requests (D10, D39, D63). The host decides the policy in force;
5
+ * the manifest only asks for one.
6
+ */
7
+ export type SubmissionPolicy = {
8
+ readonly policy: "once";
9
+ readonly scope?: "per-artifact" | "per-viewer";
10
+ } | {
11
+ readonly policy: "epochs";
12
+ } | {
13
+ readonly policy: "none";
14
+ };
15
+ /** The Zod schema of the `SubmissionPolicy` type. */
16
+ export declare const SubmissionPolicy: z.ZodType<SubmissionPolicy>;
17
+ //#endregion
18
+ //# sourceMappingURL=policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.ts","names":[],"sources":["../src/policy.ts"],"mappings":";;;;;;YAWY;WACG;WAAyB;;WACzB;;WACA;;;qBAGF,kBAAkB,EAAE,QAAQ"}
package/dist/policy.js ADDED
@@ -0,0 +1,23 @@
1
+ import { wireRegistry } from "./wire-registry.js";
2
+ import * as z from "zod";
3
+ //#region src/policy.ts
4
+ /**
5
+ * The submission policy (D10, D39, D63): a module of its own, so the shell bridge's view context
6
+ * reads it without the whole manifest schema in its bundle.
7
+ */
8
+ /** The Zod schema of the `SubmissionPolicy` type. */
9
+ const SubmissionPolicy = z.discriminatedUnion("policy", [
10
+ z.object({
11
+ policy: z.literal("once"),
12
+ scope: z.enum(["per-artifact", "per-viewer"]).exactOptional()
13
+ }),
14
+ z.object({ policy: z.literal("epochs") }),
15
+ z.object({ policy: z.literal("none") })
16
+ ]).register(wireRegistry, {
17
+ id: "SubmissionPolicy",
18
+ description: "A submission policy: once (per-artifact or per-viewer), epochs, or none."
19
+ });
20
+ //#endregion
21
+ export { SubmissionPolicy };
22
+
23
+ //# sourceMappingURL=policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.js","names":[],"sources":["../src/policy.ts"],"sourcesContent":["/**\n * The submission policy (D10, D39, D63): a module of its own, so the shell bridge's view context\n * reads it without the whole manifest schema in its bundle.\n */\nimport * as z from \"zod\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/**\n * The submission policy an artifact requests (D10, D39, D63). The host decides the policy in force;\n * the manifest only asks for one.\n */\nexport type SubmissionPolicy =\n | { readonly policy: \"once\"; readonly scope?: \"per-artifact\" | \"per-viewer\" }\n | { readonly policy: \"epochs\" }\n | { readonly policy: \"none\" };\n\n/** The Zod schema of the `SubmissionPolicy` type. */\nexport const SubmissionPolicy: z.ZodType<SubmissionPolicy> = z\n .discriminatedUnion(\"policy\", [\n z.object({\n policy: z.literal(\"once\"),\n scope: z.enum([\"per-artifact\", \"per-viewer\"]).exactOptional(),\n }),\n z.object({ policy: z.literal(\"epochs\") }),\n z.object({ policy: z.literal(\"none\") }),\n ])\n .register(wireRegistry, {\n id: \"SubmissionPolicy\",\n description: \"A submission policy: once (per-artifact or per-viewer), epochs, or none.\",\n });\n"],"mappings":";;;;;;;;AAiBA,MAAa,mBAAgD,EAC1D,mBAAmB,UAAU;CAC5B,EAAE,OAAO;EACP,QAAQ,EAAE,QAAQ,MAAM;EACxB,OAAO,EAAE,KAAK,CAAC,gBAAgB,YAAY,CAAC,CAAC,CAAC,cAAc;CAC9D,CAAC;CACD,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,QAAQ,EAAE,CAAC;CACxC,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,MAAM,EAAE,CAAC;AACxC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { Cursor } from "./ids.js";
2
+ import * as z from "zod";
3
+ //#region src/remote.d.ts
4
+ /** A server, by its API origin (`https://api.example`). */
5
+ export type ServerOrigin = string;
6
+ /** The Zod schema of the `ServerOrigin` type: an origin with no path. */
7
+ export declare const ServerOrigin: z.ZodType<ServerOrigin>;
8
+ /** The state of an instance's link to one server (INTERFACES §18.2). */
9
+ export type RemoteLinkState = "connected" | "connecting" | "offline" | "signed-out";
10
+ /** One server this home is linked to (`remote/status`). */
11
+ export interface RemoteLink {
12
+ /** The server's API origin. */
13
+ readonly server: ServerOrigin;
14
+ /** The account signed in there. */
15
+ readonly account: {
16
+ readonly id: string;
17
+ readonly name?: string;
18
+ };
19
+ /** This home's instance link on that server (`lnk_…`), kept across sign-outs. */
20
+ readonly instanceId: string;
21
+ /** The link's name, as the account's other instances see it. */
22
+ readonly name: string;
23
+ /** Whether this instance is the account's default instance (D165 item 1b). */
24
+ readonly default: boolean;
25
+ /** Whether the binding is open, being dialled, offline, or signed out. */
26
+ readonly state: RemoteLinkState;
27
+ /** When the link reached its state. */
28
+ readonly since: string;
29
+ /** Publishes of shared artifacts waiting to reach the server. */
30
+ readonly pendingPushes: number;
31
+ /** Why the link isn't connected, when it failed. */
32
+ readonly lastError?: string;
33
+ }
34
+ /** The Zod schema of the `RemoteLink` type. */
35
+ export declare const RemoteLink: z.ZodType<RemoteLink>;
36
+ /**
37
+ * What an owner instance tells its hosted home as it opens a binding session (INTERFACES §18.2):
38
+ * its link, the highest relay sequence it accepted, and the hosted home's position it committed,
39
+ * so a home restored to an earlier copy is found before it answers (D165, FAILURE_MODEL §11.2).
40
+ */
41
+ export interface OwnerLinkInfo {
42
+ /** The instance's `lnk_` ID on this server. */
43
+ readonly instanceId: string;
44
+ /** The highest relay sequence the owner's ledger accepted. */
45
+ readonly relayMark: number;
46
+ /** The hosted home's position the owner committed: its incarnation and cursor. */
47
+ readonly followed?: {
48
+ readonly incarnation: string;
49
+ readonly cursor: Cursor;
50
+ };
51
+ }
52
+ /** The Zod schema of the `OwnerLinkInfo` type. */
53
+ export declare const OwnerLinkInfo: z.ZodType<OwnerLinkInfo>;
54
+ //#endregion
55
+ //# sourceMappingURL=remote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.d.ts","names":[],"sources":["../src/remote.ts"],"mappings":";;;;YASY;;qBAGC,cAAc,EAAE,QAAQ;;YASzB;;iBAGK;;WAEN,QAAQ;;WAER;aAAoB;aAAqB;;;WAEzC;;WAEA;;WAEA;;WAEA,OAAO;;WAEP;;WAEA;;WAEA;;;qBAIE,YAAY,EAAE,QAAQ;;;;;;iBAsBlB;;WAEN;;WAEA;;WAEA;aAAsB;aAA8B,QAAQ;;;;qBAI1D,eAAe,EAAE,QAAQ"}
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;CAAE,IAAI,UAAU;CAAQ,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;AAAE,CAAC,CAAC,CACxD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AA2BH,MAAa,cAAsC,EAChD,OAAO;CACN,YAAY,WAAW;CACvB,QAAQ,OAAO;CACf,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,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;CACnD,QAAQ,EAAE,KAAK;EAAC;EAAQ;EAAU;EAAW;CAAQ,CAAC;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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,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;CAAE,IAAI,UAAU;CAAQ,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;AAAE,CAAC,CAAC,CACxD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AA2BH,MAAa,cAAsC,EAChD,OAAO;CACN,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W,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.9.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": "54 kB"
69
+ "limit": "60 kB"
70
70
  },
71
71
  {
72
72
  "name": "@mostra/protocol JSON-RPC core (D83, zod excluded)",