@mostra/protocol 0.9.0 → 0.11.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 (241) 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 +47 -0
  10. package/dist/browser.d.ts.map +1 -1
  11. package/dist/browser.js +36 -3
  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/action.d.ts +1 -1
  18. package/dist/diagnostics/codes/action.d.ts.map +1 -1
  19. package/dist/diagnostics/codes/action.js +12 -1
  20. package/dist/diagnostics/codes/action.js.map +1 -1
  21. package/dist/diagnostics/codes/artifact.d.ts +1 -1
  22. package/dist/diagnostics/codes/artifact.d.ts.map +1 -1
  23. package/dist/diagnostics/codes/artifact.js +12 -1
  24. package/dist/diagnostics/codes/artifact.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 +176 -0
  36. package/dist/diagnostics/codes/remote.js.map +1 -0
  37. package/dist/diagnostics/codes/submit.d.ts +1 -1
  38. package/dist/diagnostics/codes/submit.d.ts.map +1 -1
  39. package/dist/diagnostics/codes/submit.js +12 -1
  40. package/dist/diagnostics/codes/submit.js.map +1 -1
  41. package/dist/diagnostics/diagnostic.d.ts +1 -1
  42. package/dist/diagnostics/diagnostic.d.ts.map +1 -1
  43. package/dist/diagnostics/diagnostic.js +2 -1
  44. package/dist/diagnostics/diagnostic.js.map +1 -1
  45. package/dist/duration.d.ts +13 -0
  46. package/dist/duration.d.ts.map +1 -0
  47. package/dist/duration.js +27 -0
  48. package/dist/duration.js.map +1 -0
  49. package/dist/ids.d.ts +17 -1
  50. package/dist/ids.d.ts.map +1 -1
  51. package/dist/ids.js +9 -1
  52. package/dist/ids.js.map +1 -1
  53. package/dist/index.d.ts +33 -8
  54. package/dist/index.js +33 -8
  55. package/dist/interaction.d.ts +33 -2
  56. package/dist/interaction.d.ts.map +1 -1
  57. package/dist/interaction.js +22 -6
  58. package/dist/interaction.js.map +1 -1
  59. package/dist/manifest.d.ts +59 -14
  60. package/dist/manifest.d.ts.map +1 -1
  61. package/dist/manifest.js +63 -15
  62. package/dist/manifest.js.map +1 -1
  63. package/dist/methods/artifact/export.d.ts +40 -0
  64. package/dist/methods/artifact/export.d.ts.map +1 -0
  65. package/dist/methods/artifact/export.js +36 -0
  66. package/dist/methods/artifact/export.js.map +1 -0
  67. package/dist/methods/artifact/import.d.ts +23 -0
  68. package/dist/methods/artifact/import.d.ts.map +1 -0
  69. package/dist/methods/artifact/import.js +25 -0
  70. package/dist/methods/artifact/import.js.map +1 -0
  71. package/dist/methods/artifact/pause.d.ts +33 -0
  72. package/dist/methods/artifact/pause.d.ts.map +1 -0
  73. package/dist/methods/artifact/pause.js +33 -0
  74. package/dist/methods/artifact/pause.js.map +1 -0
  75. package/dist/methods/artifact/publish.d.ts +2 -1
  76. package/dist/methods/artifact/publish.d.ts.map +1 -1
  77. package/dist/methods/artifact/publish.js +1 -1
  78. package/dist/methods/hosted/push.d.ts +76 -0
  79. package/dist/methods/hosted/push.d.ts.map +1 -0
  80. package/dist/methods/hosted/push.js +71 -0
  81. package/dist/methods/hosted/push.js.map +1 -0
  82. package/dist/methods/hosted/submission.d.ts +18 -0
  83. package/dist/methods/hosted/submission.d.ts.map +1 -0
  84. package/dist/methods/hosted/submission.js +23 -0
  85. package/dist/methods/hosted/submission.js.map +1 -0
  86. package/dist/methods/index.d.ts.map +1 -1
  87. package/dist/methods/index.js +44 -2
  88. package/dist/methods/index.js.map +1 -1
  89. package/dist/methods/instance/status.d.ts +3 -0
  90. package/dist/methods/instance/status.d.ts.map +1 -1
  91. package/dist/methods/instance/status.js +3 -1
  92. package/dist/methods/instance/status.js.map +1 -1
  93. package/dist/methods/mostra/initialize.d.ts +17 -3
  94. package/dist/methods/mostra/initialize.d.ts.map +1 -1
  95. package/dist/methods/mostra/initialize.js +11 -3
  96. package/dist/methods/mostra/initialize.js.map +1 -1
  97. package/dist/methods/port/relay-author.d.ts +28 -0
  98. package/dist/methods/port/relay-author.d.ts.map +1 -0
  99. package/dist/methods/port/relay-author.js +42 -0
  100. package/dist/methods/port/relay-author.js.map +1 -0
  101. package/dist/methods/port/relay-call.d.ts +33 -0
  102. package/dist/methods/port/relay-call.d.ts.map +1 -0
  103. package/dist/methods/port/relay-call.js +31 -0
  104. package/dist/methods/port/relay-call.js.map +1 -0
  105. package/dist/methods/port/relay-cancel.d.ts +16 -0
  106. package/dist/methods/port/relay-cancel.d.ts.map +1 -0
  107. package/dist/methods/port/relay-cancel.js +21 -0
  108. package/dist/methods/port/relay-cancel.js.map +1 -0
  109. package/dist/methods/port/relay-live.d.ts +25 -0
  110. package/dist/methods/port/relay-live.d.ts.map +1 -0
  111. package/dist/methods/port/relay-live.js +32 -0
  112. package/dist/methods/port/relay-live.js.map +1 -0
  113. package/dist/methods/port/relay-reconcile.d.ts +39 -0
  114. package/dist/methods/port/relay-reconcile.d.ts.map +1 -0
  115. package/dist/methods/port/relay-reconcile.js +35 -0
  116. package/dist/methods/port/relay-reconcile.js.map +1 -0
  117. package/dist/methods/port/relay-run.d.ts +47 -0
  118. package/dist/methods/port/relay-run.d.ts.map +1 -0
  119. package/dist/methods/port/relay-run.js +41 -0
  120. package/dist/methods/port/relay-run.js.map +1 -0
  121. package/dist/methods/port/submissions-deliver.d.ts +8 -0
  122. package/dist/methods/port/submissions-deliver.d.ts.map +1 -1
  123. package/dist/methods/port/submissions-deliver.js +4 -2
  124. package/dist/methods/port/submissions-deliver.js.map +1 -1
  125. package/dist/methods/relay/call-batch.d.ts +26 -0
  126. package/dist/methods/relay/call-batch.d.ts.map +1 -0
  127. package/dist/methods/relay/call-batch.js +30 -0
  128. package/dist/methods/relay/call-batch.js.map +1 -0
  129. package/dist/methods/relay/effect.d.ts +31 -0
  130. package/dist/methods/relay/effect.d.ts.map +1 -0
  131. package/dist/methods/relay/effect.js +30 -0
  132. package/dist/methods/relay/effect.js.map +1 -0
  133. package/dist/methods/relay/live-value.d.ts +33 -0
  134. package/dist/methods/relay/live-value.d.ts.map +1 -0
  135. package/dist/methods/relay/live-value.js +32 -0
  136. package/dist/methods/relay/live-value.js.map +1 -0
  137. package/dist/methods/relay/run-update.d.ts +46 -0
  138. package/dist/methods/relay/run-update.d.ts.map +1 -0
  139. package/dist/methods/relay/run-update.js +45 -0
  140. package/dist/methods/relay/run-update.js.map +1 -0
  141. package/dist/methods/remote/link.d.ts +40 -0
  142. package/dist/methods/remote/link.d.ts.map +1 -0
  143. package/dist/methods/remote/link.js +40 -0
  144. package/dist/methods/remote/link.js.map +1 -0
  145. package/dist/methods/remote/login-wait.d.ts +30 -0
  146. package/dist/methods/remote/login-wait.d.ts.map +1 -0
  147. package/dist/methods/remote/login-wait.js +36 -0
  148. package/dist/methods/remote/login-wait.js.map +1 -0
  149. package/dist/methods/remote/login.d.ts +41 -0
  150. package/dist/methods/remote/login.d.ts.map +1 -0
  151. package/dist/methods/remote/login.js +37 -0
  152. package/dist/methods/remote/login.js.map +1 -0
  153. package/dist/methods/remote/logout.d.ts +25 -0
  154. package/dist/methods/remote/logout.d.ts.map +1 -0
  155. package/dist/methods/remote/logout.js +28 -0
  156. package/dist/methods/remote/logout.js.map +1 -0
  157. package/dist/methods/remote/status.d.ts +14 -0
  158. package/dist/methods/remote/status.d.ts.map +1 -0
  159. package/dist/methods/remote/status.js +22 -0
  160. package/dist/methods/remote/status.js.map +1 -0
  161. package/dist/methods/remote/token.d.ts +19 -0
  162. package/dist/methods/remote/token.d.ts.map +1 -0
  163. package/dist/methods/remote/token.js +24 -0
  164. package/dist/methods/remote/token.js.map +1 -0
  165. package/dist/methods/share/start.d.ts +5 -2
  166. package/dist/methods/share/start.d.ts.map +1 -1
  167. package/dist/methods/share/start.js +6 -3
  168. package/dist/methods/share/start.js.map +1 -1
  169. package/dist/methods/state/patch.d.ts +7 -0
  170. package/dist/methods/state/patch.d.ts.map +1 -1
  171. package/dist/methods/state/patch.js +2 -1
  172. package/dist/methods/state/patch.js.map +1 -1
  173. package/dist/methods/view/url.d.ts +2 -1
  174. package/dist/methods/view/url.d.ts.map +1 -1
  175. package/dist/methods/view/url.js +2 -1
  176. package/dist/methods/view/url.js.map +1 -1
  177. package/dist/operator.d.ts +464 -0
  178. package/dist/operator.d.ts.map +1 -0
  179. package/dist/operator.js +134 -0
  180. package/dist/operator.js.map +1 -0
  181. package/dist/policy.d.ts +18 -0
  182. package/dist/policy.d.ts.map +1 -0
  183. package/dist/policy.js +23 -0
  184. package/dist/policy.js.map +1 -0
  185. package/dist/remote.d.ts +55 -0
  186. package/dist/remote.d.ts.map +1 -0
  187. package/dist/remote.js +52 -0
  188. package/dist/remote.js.map +1 -0
  189. package/dist/view.d.ts +1 -1
  190. package/dist/view.js +1 -1
  191. package/dist/view.js.map +1 -1
  192. package/package.json +12 -2
  193. package/schemas/protocol.draft-07.json +1839 -99
  194. package/schemas/protocol.schema.json +1787 -111
  195. package/src/actions.ts +45 -5
  196. package/src/browser.ts +70 -0
  197. package/src/capability.ts +0 -23
  198. package/src/diagnostics/codes/action.ts +12 -0
  199. package/src/diagnostics/codes/artifact.ts +12 -0
  200. package/src/diagnostics/codes/home.ts +12 -0
  201. package/src/diagnostics/codes/index.ts +6 -2
  202. package/src/diagnostics/codes/remote.ts +197 -0
  203. package/src/diagnostics/codes/submit.ts +12 -0
  204. package/src/diagnostics/diagnostic.ts +3 -1
  205. package/src/duration.ts +29 -0
  206. package/src/ids.ts +33 -1
  207. package/src/index.ts +143 -8
  208. package/src/interaction.ts +48 -2
  209. package/src/manifest.ts +115 -24
  210. package/src/methods/artifact/export.ts +68 -0
  211. package/src/methods/artifact/import.ts +39 -0
  212. package/src/methods/artifact/pause.ts +59 -0
  213. package/src/methods/hosted/push.ts +146 -0
  214. package/src/methods/hosted/submission.ts +34 -0
  215. package/src/methods/index.ts +42 -0
  216. package/src/methods/instance/status.ts +4 -0
  217. package/src/methods/mostra/initialize.ts +19 -3
  218. package/src/methods/port/relay-author.ts +57 -0
  219. package/src/methods/port/relay-call.ts +58 -0
  220. package/src/methods/port/relay-cancel.ts +33 -0
  221. package/src/methods/port/relay-live.ts +48 -0
  222. package/src/methods/port/relay-reconcile.ts +71 -0
  223. package/src/methods/port/relay-run.ts +80 -0
  224. package/src/methods/port/submissions-deliver.ts +13 -1
  225. package/src/methods/relay/call-batch.ts +52 -0
  226. package/src/methods/relay/effect.ts +55 -0
  227. package/src/methods/relay/live-value.ts +54 -0
  228. package/src/methods/relay/run-update.ts +81 -0
  229. package/src/methods/remote/link.ts +65 -0
  230. package/src/methods/remote/login-wait.ts +55 -0
  231. package/src/methods/remote/login.ts +72 -0
  232. package/src/methods/remote/logout.ts +42 -0
  233. package/src/methods/remote/status.ts +34 -0
  234. package/src/methods/remote/token.ts +39 -0
  235. package/src/methods/share/start.ts +12 -4
  236. package/src/methods/state/patch.ts +6 -0
  237. package/src/methods/view/url.ts +2 -1
  238. package/src/operator.ts +621 -0
  239. package/src/policy.ts +30 -0
  240. package/src/remote.ts +89 -0
  241. package/src/view.ts +1 -1
package/dist/actions.d.ts CHANGED
@@ -27,11 +27,12 @@ export declare const RUN_LOG_TRUNCATED = "[log truncated at 1 MB]";
27
27
  export declare const RUN_KEY_MAX = 256;
28
28
  /**
29
29
  * A run's state (D24, ARCHITECTURE §7). `queued`: recorded, not yet started in a worker.
30
- * `running`: started. `waiting` is reserved for a remote server's run that waits for its owner's
31
- * instance (WP-28, D117); a page that doesn't know it treats it like `queued`. The others are
32
- * final.
30
+ * `running`: started. `waiting`: a remote server's run that waits for its owner's instance (D165
31
+ * item 4); a page that doesn't know it treats it like `queued`. `unknown`: a relayed run whose
32
+ * owner never reported its end within the artifact's offline limit, which may have taken effect;
33
+ * the owner's later report replaces it once. The others are final.
33
34
  */
34
- export type RunStatus = "queued" | "running" | "waiting" | "succeeded" | "failed" | "cancelled";
35
+ export type RunStatus = "queued" | "running" | "waiting" | "succeeded" | "failed" | "cancelled" | "unknown";
35
36
  /** Every run status. */
36
37
  export declare const RUN_STATUSES: readonly RunStatus[];
37
38
  /** Whether a run in `status` has ended. */
@@ -88,6 +89,11 @@ export interface RunState {
88
89
  readonly logFrom?: number;
89
90
  /** The index of the first batch in `batches`, as `logFrom`; absent: 0. */
90
91
  readonly batchFrom?: number;
92
+ /**
93
+ * On a remote server: the run is `running` on its owner's instance, which can't be reached now
94
+ * (D165 item 4); it ends when the owner reports, or becomes `unknown` past the offline limit.
95
+ */
96
+ readonly ownerUnreachable?: boolean;
91
97
  }
92
98
  /** The Zod schema of the `RunState` type. */
93
99
  export declare const RunState: z.ZodType<RunState>;
@@ -146,6 +152,11 @@ export interface LiveState {
146
152
  * streams, whose first value may never come (WP-14's Opus review).
147
153
  */
148
154
  readonly awaiting?: boolean;
155
+ /**
156
+ * `true` on a hosted page while the artifact's owner instance is offline, so its producers
157
+ * can't refresh the value: the last value stays, with its `at` (D165 item 4).
158
+ */
159
+ readonly ownerOffline?: boolean;
149
160
  }
150
161
  /** One live update on the event stream: never stored as an event (D63, LL-04). */
151
162
  export interface LiveUpdate {
@@ -252,6 +263,21 @@ export interface RunCancelRequest {
252
263
  export declare const RunCancelRequest: z.ZodType<RunCancelRequest>;
253
264
  /** The keys of live sources: like JavaScript export names, which is what `live.ts` declares. */
254
265
  export declare const LIVE_KEY_PATTERN: RegExp;
266
+ /**
267
+ * The reserved live keys of tallies (D165 item 12, INTERFACES §18.4): `$tally/<field>` reads the
268
+ * count by choice of a manifest `tally` entry. No producer or push writes one (their keys follow
269
+ * {@link LIVE_KEY_PATTERN}); only a page reads them.
270
+ */
271
+ export declare const TALLY_LIVE_PREFIX = "$tally/";
272
+ /** The value of a tally's live key: the counts by choice, or only the total below `minTotal`. */
273
+ export interface TallyValue {
274
+ /** Each listed choice's count, absent while fewer than `minTotal` answers were counted. */
275
+ readonly counts?: Readonly<Record<string, number>>;
276
+ /** How many answers were counted: answers, never people. */
277
+ readonly total: number;
278
+ }
279
+ /** The keys a page may read: a source's ({@link LIVE_KEY_PATTERN}) or a tally's (`$tally/<field>`). */
280
+ export declare const READABLE_LIVE_KEY_PATTERN: RegExp;
255
281
  /** The largest live value, in characters of serialized JSON (DATA_MODEL §5's 4 MiB). */
256
282
  export declare const LIVE_VALUE_MAX: number;
257
283
  /** The ring size of a pushed source in append mode that no `defineLive` sized. */
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","names":[],"sources":["../src/actions.ts"],"mappings":";;;;YAgBY,6BAA6B;;;;;qBAM5B,SAAS,EAAE,QAAQ;;iBASf,oBAAoB;;WAE1B;;;qBAIE,aAAa,EAAE,QAAQ;;qBAYvB;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;;;;;;YAQD;;qBAGC,uBAAuB;;wBAUpB,iBAAiB,QAAQ;;;;;;;YAU7B;;iBAGK;;WAEN;;WAEA;;;qBAIE,aAAa,EAAE,QAAQ;;;;;iBAcnB;;WAEN;;WAEA;;WAEA;;WAEA,QAAQ;;WAER,SAAS;;WAET,WAAW;;WAEX;;WAEA,SAAS;;WAET,QAAQ;;WAER;;WA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
48
  "failed",
49
- "cancelled"
49
+ "cancelled",
50
+ "unknown"
50
51
  ];
51
52
  /** Whether a run in `status` has ended. */
52
53
  function isFinalRunStatus(status) {
@@ -78,7 +79,8 @@ const RunState = z.object({
78
79
  finishedAt: z.string().exactOptional(),
79
80
  joined: z.boolean().exactOptional(),
80
81
  logFrom: z.number().int().nonnegative().exactOptional(),
81
- batchFrom: z.number().int().nonnegative().exactOptional()
82
+ batchFrom: z.number().int().nonnegative().exactOptional(),
83
+ ownerUnreachable: z.boolean().exactOptional()
82
84
  }).register(wireRegistry, {
83
85
  id: "RunState",
84
86
  description: "An action run: status, progress, log and the result written so far."
@@ -126,6 +128,14 @@ const RunCancelRequest = z.object({ viewId: ViewId.schema }).register(wireRegist
126
128
  });
127
129
  /** The keys of live sources: like JavaScript export names, which is what `live.ts` declares. */
128
130
  const LIVE_KEY_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]{0,127}$/;
131
+ /**
132
+ * The reserved live keys of tallies (D165 item 12, INTERFACES §18.4): `$tally/<field>` reads the
133
+ * count by choice of a manifest `tally` entry. No producer or push writes one (their keys follow
134
+ * {@link LIVE_KEY_PATTERN}); only a page reads them.
135
+ */
136
+ const TALLY_LIVE_PREFIX = "$tally/";
137
+ /** The keys a page may read: a source's ({@link LIVE_KEY_PATTERN}) or a tally's (`$tally/<field>`). */
138
+ const READABLE_LIVE_KEY_PATTERN = /^(?:[A-Za-z_$][A-Za-z0-9_$]{0,127}$|\$tally\/[^\u0000-\u001f\u007f]{1,256}$)/;
129
139
  /** The largest live value, in characters of serialized JSON (DATA_MODEL §5's 4 MiB). */
130
140
  const LIVE_VALUE_MAX = 4194304;
131
141
  /** The ring size of a pushed source in append mode that no `defineLive` sized. */
@@ -136,7 +146,7 @@ const LIVE_RING_MAX = 1e5;
136
146
  const LiveRequest = z.object({
137
147
  viewId: ViewId.schema,
138
148
  keys: z.array(z.object({
139
- key: z.string().regex(LIVE_KEY_PATTERN),
149
+ key: z.string().regex(READABLE_LIVE_KEY_PATTERN),
140
150
  window: z.int().min(1).max(LIVE_RING_MAX).exactOptional(),
141
151
  refresh: z.boolean().exactOptional()
142
152
  })).max(256).readonly()
@@ -149,6 +159,6 @@ const SECRET_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_.-]{0,127}$/;
149
159
  /** The largest secret value, in UTF-8 bytes. */
150
160
  const SECRET_VALUE_MAX = 65536;
151
161
  //#endregion
152
- export { ACTION_ARGS_MAX, ACTION_RESULT_MAX, ActionError, Batches, CallRequest, LIVE_KEY_PATTERN, LIVE_RING_DEFAULT, LIVE_RING_MAX, LIVE_VALUE_MAX, LiveRequest, RUN_KEY_MAX, RUN_LOG_MAX, RUN_LOG_TRUNCATED, RUN_STATUSES, RunAttachRequest, RunCancelRequest, RunProgress, RunRequest, RunState, SECRET_NAME_PATTERN, SECRET_VALUE_MAX, isFinalRunStatus };
162
+ export { ACTION_ARGS_MAX, ACTION_RESULT_MAX, ActionError, Batches, CallRequest, LIVE_KEY_PATTERN, LIVE_RING_DEFAULT, LIVE_RING_MAX, LIVE_VALUE_MAX, LiveRequest, READABLE_LIVE_KEY_PATTERN, RUN_KEY_MAX, RUN_LOG_MAX, RUN_LOG_TRUNCATED, RUN_STATUSES, RunAttachRequest, RunCancelRequest, RunProgress, RunRequest, RunState, SECRET_NAME_PATTERN, SECRET_VALUE_MAX, TALLY_LIVE_PREFIX, isFinalRunStatus };
153
163
 
154
164
  //# sourceMappingURL=actions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","names":[],"sources":["../src/actions.ts"],"sourcesContent":["/**\n * Actions, live data and secrets (INTERFACES §2.4, §4, §6; D24, D44, D54, D56): the shapes the\n * browser protocol, the host protocol and the worker channel share. Server-function arguments and\n * results travel as the serializer's batches (`Batches`).\n *\n * ```ts\n * const run: RunState = await post(\"runs\", { viewId, fnId: \"actions.ts#sendReply\", args, clientKey });\n * if (run.status === \"succeeded\") show(await deserializeAll(run.batches));\n * ```\n */\nimport * as z from \"zod\";\nimport { ViewId } from \"./ids.ts\";\nimport type { Frame, WireError } from \"./serializer.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** A value written by the serializer: its batches, in order (`serializeAll`). */\nexport type Batches = readonly (readonly Frame[])[];\n\n/**\n * The Zod schema of the `Batches` type: a list of batches, each a list of frames. The frames\n * themselves are checked by the reader (`ValueReader`), which refuses anything malformed.\n */\nexport const Batches: z.ZodType<Batches> = z\n .array(z.array(z.record(z.string(), z.unknown())).readonly())\n .readonly()\n .register(wireRegistry, {\n id: \"Batches\",\n description: \"A serialized server-function value: its batches of frames, in order.\",\n }) as unknown as z.ZodType<Batches>;\n\n/** An error as runs, calls and live sources report it. */\nexport interface ActionError extends WireError {\n /** The stack of the thrown error, kept in the run log and never sent to a page. */\n readonly stack?: string;\n}\n\n/** The Zod schema of the `ActionError` type. */\nexport const ActionError: z.ZodType<ActionError> = z\n .object({\n message: z.string(),\n code: z.string().exactOptional(),\n stack: z.string().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ActionError\",\n description: \"An error from server code: its message and diagnostic code.\",\n });\n\n/** The largest serialized arguments a call or run takes, in characters of JSON. */\nexport const ACTION_ARGS_MAX: number = 16 * 1024 * 1024;\n\n/** The largest serialized result a run keeps, in characters of JSON (larger fails the run). */\nexport const ACTION_RESULT_MAX: number = 16 * 1024 * 1024;\n\n/** The cap of a run's log, in UTF-16 code units of its lines (D47's 1 MB). */\nexport const RUN_LOG_MAX: number = 1024 * 1024;\n\n/** The line a capped log ends with. */\nexport const RUN_LOG_TRUNCATED = \"[log truncated at 1 MB]\";\n\n/** The longest run key, in characters. */\nexport const RUN_KEY_MAX = 256;\n\n/**\n * A run's state (D24, ARCHITECTURE §7). `queued`: recorded, not yet started in a worker.\n * `running`: started. `waiting` is reserved for a remote server's run that waits for its owner's\n * instance (WP-28, D117); a page that doesn't know it treats it like `queued`. The others are\n * final.\n */\nexport type RunStatus = \"queued\" | \"running\" | \"waiting\" | \"succeeded\" | \"failed\" | \"cancelled\";\n\n/** Every run status. */\nexport const RUN_STATUSES: readonly RunStatus[] = [\n \"queued\",\n \"running\",\n \"waiting\",\n \"succeeded\",\n \"failed\",\n \"cancelled\",\n];\n\n/** Whether a run in `status` has ended. */\nexport function isFinalRunStatus(status: RunStatus): boolean {\n return status === \"succeeded\" || status === \"failed\" || status === \"cancelled\";\n}\n\n/**\n * Why a run ended the way it did, beside its status: `interrupted` (its worker or the instance\n * stopped while it ran, D24), `threw` (the action threw), `unserializable` (its result is outside\n * the type set), `too-large`, `parked` (its artifact's worker keeps crashing), `cancelled` (by a\n * viewer), `unknown-function`. Later releases add reasons.\n */\nexport type RunReason = string;\n\n/** A run's progress, as the action last reported it. */\nexport interface RunProgress {\n /** From 0 to 1. */\n readonly fraction?: number;\n /** One short line for people. */\n readonly message?: string;\n}\n\n/** The Zod schema of the `RunProgress` type. */\nexport const RunProgress: z.ZodType<RunProgress> = z\n .object({\n fraction: z.number().min(0).max(1).exactOptional(),\n message: z.string().max(1000).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"RunProgress\",\n description: \"A run's progress: fraction and message.\",\n });\n\n/**\n * One action run as a page reads it (D54): its state, progress, log and the result written so far.\n * A result that is an async iterable grows item by item while the run is `running`.\n */\nexport interface RunState {\n /** The run's `run_` ID. */\n readonly runId: string;\n /** The server function it runs: `<module path>#<export>`. */\n readonly fnId: string;\n /** The idempotency key it was started with, if any. */\n readonly key?: string;\n /** The run's state. */\n readonly status: RunStatus;\n /** Why it ended, for `failed` and `cancelled`. */\n readonly reason?: RunReason;\n /** Its latest progress. */\n readonly progress?: RunProgress;\n /** The log lines, capped at 1 MB with a marker line. */\n readonly log: readonly string[];\n /** The result's batches so far. */\n readonly batches: Batches;\n /** For `failed`: what went wrong, without the stack. */\n readonly error?: WireError;\n /** When it was recorded. */\n readonly startedAt: string;\n /** When it ended. */\n readonly finishedAt?: string;\n /** Whether this request joined a run that already existed (a key or a retried `clientKey`). */\n readonly joined?: boolean;\n /**\n * The index of the first line in `log`, when the request said which lines the page holds\n * (`RunAttachRequest.held`); absent: 0, the whole log.\n */\n readonly logFrom?: number;\n /** The index of the first batch in `batches`, as `logFrom`; absent: 0. */\n readonly batchFrom?: number;\n}\n\n/** The Zod schema of the `RunState` type. */\nexport const RunState: z.ZodType<RunState> = z\n .object({\n runId: z.string(),\n fnId: z.string(),\n key: z.string().exactOptional(),\n status: z.enum(RUN_STATUSES as [RunStatus, ...RunStatus[]]),\n reason: z.string().exactOptional(),\n progress: RunProgress.exactOptional(),\n log: z.array(z.string()).readonly(),\n batches: Batches,\n error: z.object({ message: z.string(), code: z.string().exactOptional() }).exactOptional(),\n startedAt: z.string(),\n finishedAt: z.string().exactOptional(),\n joined: z.boolean().exactOptional(),\n logFrom: z.number().int().nonnegative().exactOptional(),\n batchFrom: z.number().int().nonnegative().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"RunState\",\n description: \"An action run: status, progress, log and the result written so far.\",\n });\n\n/**\n * What changed in a run since a page last heard: a lossy notification on the event stream. Lines\n * start at `logFrom` and batches at `batchFrom`; a page that holds fewer reads the run again\n * (`runs/attach`).\n */\nexport interface RunDelta {\n /** The run's `run_` ID. */\n readonly runId: string;\n /** The run's state. */\n readonly status: RunStatus;\n /** Why it ended so, for `failed` and `cancelled`. */\n readonly reason?: RunReason;\n /** Its latest progress. */\n readonly progress?: RunProgress;\n /** The index of the first line in `log`. */\n readonly logFrom: number;\n /** Log lines, starting at `logFrom`. */\n readonly log: readonly string[];\n /** The index of the first batch in `batches`. */\n readonly batchFrom: number;\n /** Result batches, starting at `batchFrom`. */\n readonly batches: Batches;\n /** What went wrong. */\n readonly error?: WireError;\n /** When it ended. */\n readonly finishedAt?: string;\n}\n\n/** A live source's value as a page reads it (D56). */\nexport interface LiveState {\n /** The idempotency key it was started with, if any. */\n readonly key: string;\n /** The value's revision, a decimal string that only grows; absent before any value. */\n readonly revision?: string;\n /** When the value was produced. */\n readonly at?: string;\n /** The latest value, serialized. */\n readonly value?: Batches;\n /**\n * Append mode (`useLive(key, { mode: \"append\" })`): the values kept in the source's ring, oldest\n * first, at most the window the page asked for.\n */\n readonly ring?: readonly {\n readonly revision: string;\n readonly at: string;\n readonly value: Batches;\n }[];\n /** The producer's last failure, while the last good value stays (FAILURE_MODEL §6). */\n readonly error?: WireError;\n /**\n * `true` while the source has no value and no failure and the artifact's latest version has a\n * producer whose first `load` is on its way: the page shows it loading, and verify waits for it.\n * Absent for a key nothing produces (one only `mostra push` writes) and for a source that only\n * streams, whose first value may never come (WP-14's Opus review).\n */\n readonly awaiting?: boolean;\n}\n\n/** One live update on the event stream: never stored as an event (D63, LL-04). */\nexport interface LiveUpdate {\n /** The live source's key. */\n readonly key: string;\n /** The value's revision. */\n readonly revision?: string;\n /** When the value was produced. */\n readonly at?: string;\n /** The value, serialized. */\n readonly value?: Batches;\n /** What went wrong. */\n readonly error?: WireError;\n /**\n * `false` when a source read as {@link LiveState.awaiting} turned out to have no first `load`\n * (its producer only streams): the page stops waiting for a first value.\n */\n readonly awaiting?: boolean;\n}\n\n/**\n * An ephemeral message on a page's event stream (SSE `event: run` or `event: live`, without an\n * `id`, so a reconnect's cursor is untouched) or in a poll's `ephemeral`: lossy, coalesced, and\n * never stored as an event.\n */\nexport type EphemeralMessage =\n | { readonly kind: \"run\"; readonly run: RunDelta }\n | { readonly kind: \"live\"; readonly live: LiveUpdate };\n\n/** `POST …/call/{fnId}`: a plain server-function call, no durable record (D54). */\nexport interface CallRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** The arguments, serialized as one array value. */\n readonly args: Batches;\n}\n\n/** The Zod schema of the `CallRequest` type. */\nexport const CallRequest: z.ZodType<CallRequest> = z\n .object({ viewId: ViewId.schema, args: Batches })\n .register(wireRegistry, {\n id: \"CallRequest\",\n description: \"A plain server-function call: the view and the serialized arguments.\",\n });\n\n/**\n * One line of a plain call's answer (`application/x-ndjson`): a batch of the result, then the end.\n */\nexport type CallLine =\n | { readonly batch: readonly Frame[] }\n | { readonly end: { readonly status: \"succeeded\" } }\n | { readonly end: { readonly status: \"failed\"; readonly error: WireError } };\n\n/** `POST …/runs`: start a durable action run, or join one (D54, AC-02, AC-03). */\nexport interface RunRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** `<module path>#<export>`. */\n readonly fnId: string;\n /** The arguments, serialized as one array value. */\n readonly args: Batches;\n /** The author's idempotency key: one run per artifact, function and key, ever. */\n readonly key?: string;\n /** A fresh ID per invocation, so a retried request joins the run it already started. */\n readonly clientKey: string;\n}\n\n/** The Zod schema of the `RunRequest` type. */\nexport const RunRequest: z.ZodType<RunRequest> = z\n .object({\n viewId: ViewId.schema,\n fnId: z.string().min(3).max(1024),\n args: Batches,\n key: z.string().min(1).max(RUN_KEY_MAX).exactOptional(),\n clientKey: z.string().min(8).max(64),\n })\n .register(wireRegistry, {\n id: \"RunRequest\",\n description: \"Start or join an action run: the function, its arguments and keys.\",\n });\n\n/**\n * `POST …/runs/attach`: read runs and hear their changes on the event stream for the next minute\n * (re-attach after a reload, AC-02). By ID, or by function and key.\n */\nexport interface RunAttachRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** Runs by ID. */\n readonly runIds?: readonly string[];\n /** Runs by function and key. */\n readonly keyed?: readonly { readonly fnId: string; readonly key: string }[];\n /**\n * What the page already holds of runs it names by ID: so many log lines and batches. Each such\n * run's answer starts there (`RunState.logFrom`, `batchFrom`), so a page renewing its interest\n * doesn't read the whole run again (Opus review 14).\n */\n readonly held?: readonly {\n readonly runId: string;\n readonly log: number;\n readonly batches: number;\n }[];\n}\n\n/** The Zod schema of the `RunAttachRequest` type. */\nexport const RunAttachRequest: z.ZodType<RunAttachRequest> = z\n .object({\n viewId: ViewId.schema,\n runIds: z.array(z.string().max(64)).max(100).readonly().exactOptional(),\n keyed: z\n .array(\n z.object({ fnId: z.string().min(3).max(1024), key: z.string().min(1).max(RUN_KEY_MAX) }),\n )\n .max(100)\n .readonly()\n .exactOptional(),\n held: z\n .array(\n z.object({\n runId: z.string().max(64),\n log: z.number().int().nonnegative(),\n batches: z.number().int().nonnegative(),\n }),\n )\n .max(100)\n .readonly()\n .exactOptional(),\n })\n .register(wireRegistry, {\n id: \"RunAttachRequest\",\n description: \"Runs a page reads and follows: by ID, or by function and key.\",\n });\n\n/** `POST …/runs/{id}/cancel`. */\nexport interface RunCancelRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n}\n\n/** The Zod schema of the `RunCancelRequest` type. */\nexport const RunCancelRequest: z.ZodType<RunCancelRequest> = z\n .object({ viewId: ViewId.schema })\n .register(wireRegistry, { id: \"RunCancelRequest\", description: \"Cancel a run, from a view.\" });\n\n/** The keys of live sources: like JavaScript export names, which is what `live.ts` declares. */\nexport const LIVE_KEY_PATTERN: RegExp = /^[A-Za-z_$][A-Za-z0-9_$]{0,127}$/;\n\n/** The largest live value, in characters of serialized JSON (DATA_MODEL §5's 4 MiB). */\nexport const LIVE_VALUE_MAX: number = 4 * 1024 * 1024;\n\n/** The ring size of a pushed source in append mode that no `defineLive` sized. */\nexport const LIVE_RING_DEFAULT = 1024;\n\n/** The largest ring a source may keep. */\nexport const LIVE_RING_MAX = 100_000;\n\n/**\n * `POST …/live`: read live sources and keep their producers running for this view for the next\n * minute (D56, LL-04); a page asks again while it shows them.\n */\nexport interface LiveRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /**\n * The sources, each with its append window; `refresh` asks the source's producer to load again\n * now (`useLive`'s `refresh()`).\n */\n readonly keys: readonly {\n readonly key: string;\n readonly window?: number;\n readonly refresh?: boolean;\n }[];\n}\n\n/** The Zod schema of the `LiveRequest` type. */\nexport const LiveRequest: z.ZodType<LiveRequest> = z\n .object({\n viewId: ViewId.schema,\n keys: z\n .array(\n z.object({\n key: z.string().regex(LIVE_KEY_PATTERN),\n window: z.int().min(1).max(LIVE_RING_MAX).exactOptional(),\n refresh: z.boolean().exactOptional(),\n }),\n )\n .max(256)\n .readonly(),\n })\n .register(wireRegistry, {\n id: \"LiveRequest\",\n description: \"Live sources a page reads and keeps running: keys and append windows.\",\n });\n\n/** Secret names: letters, digits, `_`, `.` and `-`, starting with a letter or `_` (D44). */\nexport const SECRET_NAME_PATTERN: RegExp = /^[A-Za-z_][A-Za-z0-9_.-]{0,127}$/;\n\n/** The largest secret value, in UTF-8 bytes. */\nexport const SECRET_VALUE_MAX: number = 64 * 1024;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,MAAa,UAA8B,EACxC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAC5D,SAAS,CAAC,CACV,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AASH,MAAa,cAAsC,EAChD,OAAO;CACN,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO,CAAC,CAAC,cAAc;CAC/B,OAAO,EAAE,OAAO,CAAC,CAAC,cAAc;AAClC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,kBAA0B;;AAGvC,MAAa,oBAA4B;;AAGzC,MAAa,cAAsB;;AAGnC,MAAa,oBAAoB;;AAGjC,MAAa,cAAc;;AAW3B,MAAa,eAAqC;CAChD;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,SAAgB,iBAAiB,QAA4B;CAC3D,OAAO,WAAW,eAAe,WAAW,YAAY,WAAW;AACrE;;AAmBA,MAAa,cAAsC,EAChD,OAAO;CACN,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;CACjD,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,GAAI,CAAC,CAAC,cAAc;AAC9C,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAyCH,MAAa,WAAgC,EAC1C,OAAO;CACN,OAAO,EA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C,CAAC,cAAc;CACrC,CAAC,CACH,CAAC,CACA,IAAI,GAAG,CAAC,CACR,SAAS;AACd,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,sBAA8B;;AAG3C,MAAa,mBAA2B"}
1
+ {"version":3,"file":"actions.js","names":[],"sources":["../src/actions.ts"],"sourcesContent":["/**\n * Actions, live data and secrets (INTERFACES §2.4, §4, §6; D24, D44, D54, D56): the shapes the\n * browser protocol, the host protocol and the worker channel share. Server-function arguments and\n * results travel as the serializer's batches (`Batches`).\n *\n * ```ts\n * const run: RunState = await post(\"runs\", { viewId, fnId: \"actions.ts#sendReply\", args, clientKey });\n * if (run.status === \"succeeded\") show(await deserializeAll(run.batches));\n * ```\n */\nimport * as z from \"zod\";\nimport { ViewId } from \"./ids.ts\";\nimport type { Frame, WireError } from \"./serializer.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** A value written by the serializer: its batches, in order (`serializeAll`). */\nexport type Batches = readonly (readonly Frame[])[];\n\n/**\n * The Zod schema of the `Batches` type: a list of batches, each a list of frames. The frames\n * themselves are checked by the reader (`ValueReader`), which refuses anything malformed.\n */\nexport const Batches: z.ZodType<Batches> = z\n .array(z.array(z.record(z.string(), z.unknown())).readonly())\n .readonly()\n .register(wireRegistry, {\n id: \"Batches\",\n description: \"A serialized server-function value: its batches of frames, in order.\",\n }) as unknown as z.ZodType<Batches>;\n\n/** An error as runs, calls and live sources report it. */\nexport interface ActionError extends WireError {\n /** The stack of the thrown error, kept in the run log and never sent to a page. */\n readonly stack?: string;\n}\n\n/** The Zod schema of the `ActionError` type. */\nexport const ActionError: z.ZodType<ActionError> = z\n .object({\n message: z.string(),\n code: z.string().exactOptional(),\n stack: z.string().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ActionError\",\n description: \"An error from server code: its message and diagnostic code.\",\n });\n\n/** The largest serialized arguments a call or run takes, in characters of JSON. */\nexport const ACTION_ARGS_MAX: number = 16 * 1024 * 1024;\n\n/** The largest serialized result a run keeps, in characters of JSON (larger fails the run). */\nexport const ACTION_RESULT_MAX: number = 16 * 1024 * 1024;\n\n/** The cap of a run's log, in UTF-16 code units of its lines (D47's 1 MB). */\nexport const RUN_LOG_MAX: number = 1024 * 1024;\n\n/** The line a capped log ends with. */\nexport const RUN_LOG_TRUNCATED = \"[log truncated at 1 MB]\";\n\n/** The longest run key, in characters. */\nexport const RUN_KEY_MAX = 256;\n\n/**\n * A run's state (D24, ARCHITECTURE §7). `queued`: recorded, not yet started in a worker.\n * `running`: started. `waiting`: a remote server's run that waits for its owner's instance (D165\n * item 4); a page that doesn't know it treats it like `queued`. `unknown`: a relayed run whose\n * owner never reported its end within the artifact's offline limit, which may have taken effect;\n * the owner's later report replaces it once. The others are final.\n */\nexport type RunStatus =\n | \"queued\"\n | \"running\"\n | \"waiting\"\n | \"succeeded\"\n | \"failed\"\n | \"cancelled\"\n | \"unknown\";\n\n/** Every run status. */\nexport const RUN_STATUSES: readonly RunStatus[] = [\n \"queued\",\n \"running\",\n \"waiting\",\n \"succeeded\",\n \"failed\",\n \"cancelled\",\n \"unknown\",\n];\n\n/** Whether a run in `status` has ended. */\nexport function isFinalRunStatus(status: RunStatus): boolean {\n return status === \"succeeded\" || status === \"failed\" || status === \"cancelled\";\n}\n\n/**\n * Why a run ended the way it did, beside its status: `interrupted` (its worker or the instance\n * stopped while it ran, D24), `threw` (the action threw), `unserializable` (its result is outside\n * the type set), `too-large`, `parked` (its artifact's worker keeps crashing), `cancelled` (by a\n * viewer), `unknown-function`. Later releases add reasons.\n */\nexport type RunReason = string;\n\n/** A run's progress, as the action last reported it. */\nexport interface RunProgress {\n /** From 0 to 1. */\n readonly fraction?: number;\n /** One short line for people. */\n readonly message?: string;\n}\n\n/** The Zod schema of the `RunProgress` type. */\nexport const RunProgress: z.ZodType<RunProgress> = z\n .object({\n fraction: z.number().min(0).max(1).exactOptional(),\n message: z.string().max(1000).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"RunProgress\",\n description: \"A run's progress: fraction and message.\",\n });\n\n/**\n * One action run as a page reads it (D54): its state, progress, log and the result written so far.\n * A result that is an async iterable grows item by item while the run is `running`.\n */\nexport interface RunState {\n /** The run's `run_` ID. */\n readonly runId: string;\n /** The server function it runs: `<module path>#<export>`. */\n readonly fnId: string;\n /** The idempotency key it was started with, if any. */\n readonly key?: string;\n /** The run's state. */\n readonly status: RunStatus;\n /** Why it ended, for `failed` and `cancelled`. */\n readonly reason?: RunReason;\n /** Its latest progress. */\n readonly progress?: RunProgress;\n /** The log lines, capped at 1 MB with a marker line. */\n readonly log: readonly string[];\n /** The result's batches so far. */\n readonly batches: Batches;\n /** For `failed`: what went wrong, without the stack. */\n readonly error?: WireError;\n /** When it was recorded. */\n readonly startedAt: string;\n /** When it ended. */\n readonly finishedAt?: string;\n /** Whether this request joined a run that already existed (a key or a retried `clientKey`). */\n readonly joined?: boolean;\n /**\n * The index of the first line in `log`, when the request said which lines the page holds\n * (`RunAttachRequest.held`); absent: 0, the whole log.\n */\n readonly logFrom?: number;\n /** The index of the first batch in `batches`, as `logFrom`; absent: 0. */\n readonly batchFrom?: number;\n /**\n * On a remote server: the run is `running` on its owner's instance, which can't be reached now\n * (D165 item 4); it ends when the owner reports, or becomes `unknown` past the offline limit.\n */\n readonly ownerUnreachable?: boolean;\n}\n\n/** The Zod schema of the `RunState` type. */\nexport const RunState: z.ZodType<RunState> = z\n .object({\n runId: z.string(),\n fnId: z.string(),\n key: z.string().exactOptional(),\n status: z.enum(RUN_STATUSES as [RunStatus, ...RunStatus[]]),\n reason: z.string().exactOptional(),\n progress: RunProgress.exactOptional(),\n log: z.array(z.string()).readonly(),\n batches: Batches,\n error: z.object({ message: z.string(), code: z.string().exactOptional() }).exactOptional(),\n startedAt: z.string(),\n finishedAt: z.string().exactOptional(),\n joined: z.boolean().exactOptional(),\n logFrom: z.number().int().nonnegative().exactOptional(),\n batchFrom: z.number().int().nonnegative().exactOptional(),\n ownerUnreachable: z.boolean().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"RunState\",\n description: \"An action run: status, progress, log and the result written so far.\",\n });\n\n/**\n * What changed in a run since a page last heard: a lossy notification on the event stream. Lines\n * start at `logFrom` and batches at `batchFrom`; a page that holds fewer reads the run again\n * (`runs/attach`).\n */\nexport interface RunDelta {\n /** The run's `run_` ID. */\n readonly runId: string;\n /** The run's state. */\n readonly status: RunStatus;\n /** Why it ended so, for `failed` and `cancelled`. */\n readonly reason?: RunReason;\n /** Its latest progress. */\n readonly progress?: RunProgress;\n /** The index of the first line in `log`. */\n readonly logFrom: number;\n /** Log lines, starting at `logFrom`. */\n readonly log: readonly string[];\n /** The index of the first batch in `batches`. */\n readonly batchFrom: number;\n /** Result batches, starting at `batchFrom`. */\n readonly batches: Batches;\n /** What went wrong. */\n readonly error?: WireError;\n /** When it ended. */\n readonly finishedAt?: string;\n}\n\n/** A live source's value as a page reads it (D56). */\nexport interface LiveState {\n /** The idempotency key it was started with, if any. */\n readonly key: string;\n /** The value's revision, a decimal string that only grows; absent before any value. */\n readonly revision?: string;\n /** When the value was produced. */\n readonly at?: string;\n /** The latest value, serialized. */\n readonly value?: Batches;\n /**\n * Append mode (`useLive(key, { mode: \"append\" })`): the values kept in the source's ring, oldest\n * first, at most the window the page asked for.\n */\n readonly ring?: readonly {\n readonly revision: string;\n readonly at: string;\n readonly value: Batches;\n }[];\n /** The producer's last failure, while the last good value stays (FAILURE_MODEL §6). */\n readonly error?: WireError;\n /**\n * `true` while the source has no value and no failure and the artifact's latest version has a\n * producer whose first `load` is on its way: the page shows it loading, and verify waits for it.\n * Absent for a key nothing produces (one only `mostra push` writes) and for a source that only\n * streams, whose first value may never come (WP-14's Opus review).\n */\n readonly awaiting?: boolean;\n /**\n * `true` on a hosted page while the artifact's owner instance is offline, so its producers\n * can't refresh the value: the last value stays, with its `at` (D165 item 4).\n */\n readonly ownerOffline?: boolean;\n}\n\n/** One live update on the event stream: never stored as an event (D63, LL-04). */\nexport interface LiveUpdate {\n /** The live source's key. */\n readonly key: string;\n /** The value's revision. */\n readonly revision?: string;\n /** When the value was produced. */\n readonly at?: string;\n /** The value, serialized. */\n readonly value?: Batches;\n /** What went wrong. */\n readonly error?: WireError;\n /**\n * `false` when a source read as {@link LiveState.awaiting} turned out to have no first `load`\n * (its producer only streams): the page stops waiting for a first value.\n */\n readonly awaiting?: boolean;\n}\n\n/**\n * An ephemeral message on a page's event stream (SSE `event: run` or `event: live`, without an\n * `id`, so a reconnect's cursor is untouched) or in a poll's `ephemeral`: lossy, coalesced, and\n * never stored as an event.\n */\nexport type EphemeralMessage =\n | { readonly kind: \"run\"; readonly run: RunDelta }\n | { readonly kind: \"live\"; readonly live: LiveUpdate };\n\n/** `POST …/call/{fnId}`: a plain server-function call, no durable record (D54). */\nexport interface CallRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** The arguments, serialized as one array value. */\n readonly args: Batches;\n}\n\n/** The Zod schema of the `CallRequest` type. */\nexport const CallRequest: z.ZodType<CallRequest> = z\n .object({ viewId: ViewId.schema, args: Batches })\n .register(wireRegistry, {\n id: \"CallRequest\",\n description: \"A plain server-function call: the view and the serialized arguments.\",\n });\n\n/**\n * One line of a plain call's answer (`application/x-ndjson`): a batch of the result, then the end.\n */\nexport type CallLine =\n | { readonly batch: readonly Frame[] }\n | { readonly end: { readonly status: \"succeeded\" } }\n | { readonly end: { readonly status: \"failed\"; readonly error: WireError } };\n\n/** `POST …/runs`: start a durable action run, or join one (D54, AC-02, AC-03). */\nexport interface RunRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** `<module path>#<export>`. */\n readonly fnId: string;\n /** The arguments, serialized as one array value. */\n readonly args: Batches;\n /** The author's idempotency key: one run per artifact, function and key, ever. */\n readonly key?: string;\n /** A fresh ID per invocation, so a retried request joins the run it already started. */\n readonly clientKey: string;\n}\n\n/** The Zod schema of the `RunRequest` type. */\nexport const RunRequest: z.ZodType<RunRequest> = z\n .object({\n viewId: ViewId.schema,\n fnId: z.string().min(3).max(1024),\n args: Batches,\n key: z.string().min(1).max(RUN_KEY_MAX).exactOptional(),\n clientKey: z.string().min(8).max(64),\n })\n .register(wireRegistry, {\n id: \"RunRequest\",\n description: \"Start or join an action run: the function, its arguments and keys.\",\n });\n\n/**\n * `POST …/runs/attach`: read runs and hear their changes on the event stream for the next minute\n * (re-attach after a reload, AC-02). By ID, or by function and key.\n */\nexport interface RunAttachRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** Runs by ID. */\n readonly runIds?: readonly string[];\n /** Runs by function and key. */\n readonly keyed?: readonly { readonly fnId: string; readonly key: string }[];\n /**\n * What the page already holds of runs it names by ID: so many log lines and batches. Each such\n * run's answer starts there (`RunState.logFrom`, `batchFrom`), so a page renewing its interest\n * doesn't read the whole run again (Opus review 14).\n */\n readonly held?: readonly {\n readonly runId: string;\n readonly log: number;\n readonly batches: number;\n }[];\n}\n\n/** The Zod schema of the `RunAttachRequest` type. */\nexport const RunAttachRequest: z.ZodType<RunAttachRequest> = z\n .object({\n viewId: ViewId.schema,\n runIds: z.array(z.string().max(64)).max(100).readonly().exactOptional(),\n keyed: z\n .array(\n z.object({ fnId: z.string().min(3).max(1024), key: z.string().min(1).max(RUN_KEY_MAX) }),\n )\n .max(100)\n .readonly()\n .exactOptional(),\n held: z\n .array(\n z.object({\n runId: z.string().max(64),\n log: z.number().int().nonnegative(),\n batches: z.number().int().nonnegative(),\n }),\n )\n .max(100)\n .readonly()\n .exactOptional(),\n })\n .register(wireRegistry, {\n id: \"RunAttachRequest\",\n description: \"Runs a page reads and follows: by ID, or by function and key.\",\n });\n\n/** `POST …/runs/{id}/cancel`. */\nexport interface RunCancelRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n}\n\n/** The Zod schema of the `RunCancelRequest` type. */\nexport const RunCancelRequest: z.ZodType<RunCancelRequest> = z\n .object({ viewId: ViewId.schema })\n .register(wireRegistry, { id: \"RunCancelRequest\", description: \"Cancel a run, from a view.\" });\n\n/** The keys of live sources: like JavaScript export names, which is what `live.ts` declares. */\nexport const LIVE_KEY_PATTERN: RegExp = /^[A-Za-z_$][A-Za-z0-9_$]{0,127}$/;\n\n/**\n * The reserved live keys of tallies (D165 item 12, INTERFACES §18.4): `$tally/<field>` reads the\n * count by choice of a manifest `tally` entry. No producer or push writes one (their keys follow\n * {@link LIVE_KEY_PATTERN}); only a page reads them.\n */\nexport const TALLY_LIVE_PREFIX = \"$tally/\";\n\n/** The value of a tally's live key: the counts by choice, or only the total below `minTotal`. */\nexport interface TallyValue {\n /** Each listed choice's count, absent while fewer than `minTotal` answers were counted. */\n readonly counts?: Readonly<Record<string, number>>;\n /** How many answers were counted: answers, never people. */\n readonly total: number;\n}\n\n/** The keys a page may read: a source's ({@link LIVE_KEY_PATTERN}) or a tally's (`$tally/<field>`). */\nexport const READABLE_LIVE_KEY_PATTERN: RegExp =\n // biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are what it refuses.\n /^(?:[A-Za-z_$][A-Za-z0-9_$]{0,127}$|\\$tally\\/[^\\u0000-\\u001f\\u007f]{1,256}$)/;\n\n/** The largest live value, in characters of serialized JSON (DATA_MODEL §5's 4 MiB). */\nexport const LIVE_VALUE_MAX: number = 4 * 1024 * 1024;\n\n/** The ring size of a pushed source in append mode that no `defineLive` sized. */\nexport const LIVE_RING_DEFAULT = 1024;\n\n/** The largest ring a source may keep. */\nexport const LIVE_RING_MAX = 100_000;\n\n/**\n * `POST …/live`: read live sources and keep their producers running for this view for the next\n * minute (D56, LL-04); a page asks again while it shows them.\n */\nexport interface LiveRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /**\n * The sources, each with its append window; `refresh` asks the source's producer to load again\n * now (`useLive`'s `refresh()`).\n */\n readonly keys: readonly {\n readonly key: string;\n readonly window?: number;\n readonly refresh?: boolean;\n }[];\n}\n\n/** The Zod schema of the `LiveRequest` type. */\nexport const LiveRequest: z.ZodType<LiveRequest> = z\n .object({\n viewId: ViewId.schema,\n keys: z\n .array(\n z.object({\n key: z.string().regex(READABLE_LIVE_KEY_PATTERN),\n window: z.int().min(1).max(LIVE_RING_MAX).exactOptional(),\n refresh: z.boolean().exactOptional(),\n }),\n )\n .max(256)\n .readonly(),\n })\n .register(wireRegistry, {\n id: \"LiveRequest\",\n description: \"Live sources a page reads and keeps running: keys and append windows.\",\n });\n\n/** Secret names: letters, digits, `_`, `.` and `-`, starting with a letter or `_` (D44). */\nexport const SECRET_NAME_PATTERN: RegExp = /^[A-Za-z_][A-Za-z0-9_.-]{0,127}$/;\n\n/** The largest secret value, in UTF-8 bytes. */\nexport const SECRET_VALUE_MAX: number = 64 * 1024;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,MAAa,UAA8B,EACxC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAC5D,SAAS,CAAC,CACV,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AASH,MAAa,cAAsC,EAChD,OAAO;CACN,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO,CAAC,CAAC,cAAc;CAC/B,OAAO,EAAE,OAAO,CAAC,CAAC,cAAc;AAClC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,kBAA0B;;AAGvC,MAAa,oBAA4B;;AAGzC,MAAa,cAAsB;;AAGnC,MAAa,oBAAoB;;AAGjC,MAAa,cAAc;;AAmB3B,MAAa,eAAqC;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,SAAgB,iBAAiB,QAA4B;CAC3D,OAAO,WAAW,eAAe,WAAW,YAAY,WAAW;AACrE;;AAmBA,MAAa,cAAsC,EAChD,OAAO;CACN,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc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B;;AAGjC,MAAa,gBAAgB;;AAqB7B,MAAa,cAAsC,EAChD,OAAO;CACN,QAAQ,OAAO;CACf,MAAM,EACH,MACC,EAAE,OAAO;EACP,KAAK,EAAE,OAAO,CAAC,CAAC,MAAM,yBAAyB;EAC/C,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,cAAc;EACxD,SAAS,EAAE,QAAQ,CAAC,CAAC,cAAc;CACrC,CAAC,CACH,CAAC,CACA,IAAI,GAAG,CAAC,CACR,SAAS;AACd,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,sBAA8B;;AAG3C,MAAa,mBAA2B"}
@@ -1,4 +1,5 @@
1
- import { ArtifactLink, ArtifactManifest, SubmissionPolicy } from "./manifest.js";
1
+ import { SubmissionPolicy } from "./policy.js";
2
+ import { ArtifactLink, ArtifactManifest } from "./manifest.js";
2
3
  import * as z from "zod";
3
4
  //#region src/artifact.d.ts
4
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"artifact.d.ts","names":[],"sources":["../src/artifact.ts"],"mappings":";;;;;;;YAqBY;WAAuB;;WAA4B;;;YAGnD;WAAyB;;WAAkC;;;qBAG1D,WAAW,EAAE,QAAQ;;qBASrB,aAAa,EAAE,QAAQ;;iBAQnB;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;;;WAKA;;;iBAIM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA,gBAAgB;;WAEhB;;WAEA,SAAS;;WAET;;WAEA;;WAEA,gBAAgB;;;iBAIV,uBAAuB;;WAE7B,UAAU;;WAEV,mBAAmB;;;;;;iBAOb;;WAEN;;WAEA;;WAEA;;;;;;WAMA;;;;;WAKA;;WAEA;;WAEA;;WAEA;;;qBAIE,gBAAgB,EAAE,QAAQ;;qBA2B1B,iBAAiB,EAAE,QAAQ;;qBAQ3B,gBAAgB,EAAE,QAAQ;;qBAY1B,gBAAgB,EAAE,QAAQ"}
1
+ {"version":3,"file":"artifact.d.ts","names":[],"sources":["../src/artifact.ts"],"mappings":";;;;;;;;YAqBY;WAAuB;;WAA4B;;;YAGnD;WAAyB;;WAAkC;;;qBAG1D,WAAW,EAAE,QAAQ;;qBASrB,aAAa,EAAE,QAAQ;;iBAQnB;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;;;WAKA;;;iBAIM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA,gBAAgB;;WAEhB;;WAEA,SAAS;;WAET;;WAEA;;WAEA,gBAAgB;;;iBAIV,uBAAuB;;WAE7B,UAAU;;WAEV,mBAAmB;;;;;;iBAOb;;WAEN;;WAEA;;WAEA;;;;;;WAMA;;;;;WAKA;;WAEA;;WAEA;;WAEA;;;qBAIE,gBAAgB,EAAE,QAAQ;;qBA2B1B,iBAAiB,EAAE,QAAQ;;qBAQ3B,gBAAgB,EAAE,QAAQ;;qBAY1B,gBAAgB,EAAE,QAAQ"}
package/dist/artifact.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { wireRegistry } from "./wire-registry.js";
2
2
  import { ArtifactId, Cursor, TokenId, VersionId } from "./ids.js";
3
- import { ArtifactLink, ArtifactManifest, SubmissionPolicy } from "./manifest.js";
3
+ import { SubmissionPolicy } from "./policy.js";
4
+ import { ArtifactLink, ArtifactManifest } from "./manifest.js";
4
5
  import * as z from "zod";
5
6
  //#region src/artifact.ts
6
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"artifact.js","names":[],"sources":["../src/artifact.ts"],"sourcesContent":["/**\n * Artifacts and versions as clients see them (INTERFACES §6): how a client names an artifact or its\n * source, and the summaries `artifact/list`, `artifact/get` and `artifact/publish` return.\n */\nimport * as z from \"zod\";\nimport { ArtifactId, Cursor, TokenId, VersionId } from \"./ids.ts\";\nimport { ArtifactLink, ArtifactManifest, SubmissionPolicy } from \"./manifest.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/**\n * An absolute file system path: the client resolves relative paths against its own directory.\n * POSIX `/…`, and on Windows a drive path (`C:\\…`, `C:/…`) or a UNC path (`\\\\server\\share\\…`,\n * WP-W1, D150); a drive-relative `C:x` or a root-relative `\\x` isn't absolute. The Windows forms\n * are alternatives beside the POSIX one, which the schema gate reads as a widening (D32).\n */\nexport const AbsolutePath: z.ZodString = z.string().regex(/^(?:\\/|[A-Za-z]:[\\\\/]|\\\\\\\\[^\\\\])/);\n\n/**\n * Where to build an artifact from: a source path (a `.tsx`, `.jsx` or `.mdx` file, or a directory\n * with an `index` entry), or an artifact ID, meaning the path it was last published from.\n */\nexport type SourceRef = { readonly path: string } | { readonly artifactId: string };\n\n/** Names an artifact: by its ID, or by a source path bound to it. */\nexport type ArtifactRef = { readonly artifactId: string } | { readonly path: string };\n\n/** The Zod schema of the `SourceRef` type. */\nexport const SourceRef: z.ZodType<SourceRef> = z\n .union([z.object({ path: AbsolutePath }), z.object({ artifactId: ArtifactId.schema })])\n .register(wireRegistry, {\n id: \"SourceRef\",\n description:\n \"Where to build an artifact from: an absolute source path, or an artifact ID (its last published source path).\",\n });\n\n/** The Zod schema of the `ArtifactRef` type. */\nexport const ArtifactRef: z.ZodType<ArtifactRef> = z\n .union([z.object({ artifactId: ArtifactId.schema }), z.object({ path: AbsolutePath })])\n .register(wireRegistry, {\n id: \"ArtifactRef\",\n description: \"Names an artifact by its ID or by an absolute source path bound to it.\",\n });\n\n/** One published version. */\nexport interface VersionSummary {\n /** The content-addressed version ID (D89). */\n readonly id: string;\n /** The per-artifact version number, for people: 1, 2, 3 … */\n readonly number: number;\n /** When it was published (RFC 3339, UTC). */\n readonly publishedAt: string;\n /** SHA-256 of the source tree's canonical listing, lowercase hex (DATA_MODEL §2). */\n readonly sourceDigest: string;\n /** SHA-256 of the build environment's canonical JSON, lowercase hex (DATA_MODEL §2). */\n readonly envDigest: string;\n /** SHA-256 of the build output's canonical listing: recorded, never identity (VR-01). */\n readonly outputDigest: string;\n /** Diagnostic codes a forced publish recorded (D41); absent when none. */\n readonly forcedDiagnostics?: readonly string[];\n /**\n * When `mostra gc` removed the version's files (D140): its ID and number stay, but it can't be\n * opened until its exact source is published again. Absent for a version whose files exist.\n */\n readonly collected?: string;\n}\n\n/** One artifact, as `artifact/list` returns it. Metadata comes from the latest version's manifest. */\nexport interface ArtifactSummary {\n /** The artifact ID. */\n readonly id: string;\n /** The title people see. */\n readonly title: string;\n /** What the artifact is for. */\n readonly description?: string;\n /** What kind of artifact it is. */\n readonly family?: string;\n /** Related artifacts. */\n readonly links: readonly ArtifactLink[];\n /** The render mode of the latest version. */\n readonly mode: \"spa\";\n /** The submission policy requested at publish or in the manifest; the host decides (D39). */\n readonly policy?: SubmissionPolicy;\n /** The source path the artifact was last published from. */\n readonly source?: string;\n /** When the artifact was first published (RFC 3339, UTC). */\n readonly createdAt: string;\n /** The version viewers are offered. */\n readonly latestVersion?: VersionSummary;\n}\n\n/** One artifact in full, as `artifact/get` returns it. */\nexport interface ArtifactDetail extends ArtifactSummary {\n /** The latest version's manifest. */\n readonly manifest: ArtifactManifest;\n /** Every version, newest number first. */\n readonly versions: readonly VersionSummary[];\n}\n\n/**\n * The receipt of `artifact/publish` (INTERFACES §6, H-07). Everything it names is durable before the\n * response is sent.\n */\nexport interface PublishReceipt {\n /** The artifact the version belongs to. */\n readonly artifactId: string;\n /** The content-addressed version ID (D89). */\n readonly versionId: string;\n /** The version number. */\n readonly version: number;\n /**\n * The capability URL: the artifact's default link (D97), the same for every publish until it is\n * rotated or revoked. Instances with the gateway (WP-05 on) always set it; optional on\n * the wire so instances without it can publish (D90).\n */\n readonly url?: string;\n /**\n * The ID of the token behind `url`, the artifact's default link (D97), for `view/rotate` and\n * `view/revoke`. Present whenever `url` is.\n */\n readonly tokenId?: string;\n /** The event cursor of the version's `version.published` event; `wait` and events read after it. */\n readonly cursor: string;\n /** `true` when this artifact already had this exact source and environment as a version. */\n readonly reused: boolean;\n /** The error codes a forced publish recorded (D41). */\n readonly forcedDiagnostics?: readonly string[];\n}\n\n/** The Zod schema of the `VersionSummary` type. */\nexport const VersionSummary: z.ZodType<VersionSummary> = z\n .object({\n id: VersionId.schema,\n number: z.int().min(1),\n publishedAt: z.iso.datetime(),\n sourceDigest: z.string().regex(/^[0-9a-f]{64}$/),\n envDigest: z.string().regex(/^[0-9a-f]{64}$/),\n outputDigest: z.string().regex(/^[0-9a-f]{64}$/),\n forcedDiagnostics: z.array(z.string()).readonly().exactOptional(),\n collected: z.iso.datetime().exactOptional(),\n })\n .register(wireRegistry, { id: \"VersionSummary\", description: \"One published version.\" });\n\nconst summaryShape = {\n id: ArtifactId.schema,\n title: z.string(),\n description: z.string().exactOptional(),\n family: z.string().exactOptional(),\n links: z.array(ArtifactLink).readonly(),\n mode: z.literal(\"spa\"),\n policy: SubmissionPolicy.exactOptional(),\n source: z.string().exactOptional(),\n createdAt: z.iso.datetime(),\n latestVersion: VersionSummary.exactOptional(),\n};\n\n/** The Zod schema of the `ArtifactSummary` type. */\nexport const ArtifactSummary: z.ZodType<ArtifactSummary> = z\n .object(summaryShape)\n .register(wireRegistry, {\n id: \"ArtifactSummary\",\n description: \"One artifact: metadata from its latest version, its source and latest version.\",\n });\n\n/** The Zod schema of the `ArtifactDetail` type. */\nexport const ArtifactDetail: z.ZodType<ArtifactDetail> = z\n .object({\n ...summaryShape,\n manifest: ArtifactManifest,\n versions: z.array(VersionSummary).readonly(),\n })\n .register(wireRegistry, {\n id: \"ArtifactDetail\",\n description: \"One artifact in full: its summary, the latest manifest and every version.\",\n });\n\n/** The Zod schema of the `PublishReceipt` type. */\nexport const PublishReceipt: z.ZodType<PublishReceipt> = z\n .object({\n artifactId: ArtifactId.schema,\n versionId: VersionId.schema,\n version: z.int().min(1),\n url: z.string().exactOptional(),\n tokenId: TokenId.schema.exactOptional(),\n cursor: Cursor.schema,\n reused: z.boolean(),\n forcedDiagnostics: z.array(z.string()).readonly().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"PublishReceipt\",\n description:\n \"The receipt of artifact/publish: artifact, version, number, capability URL when served, event cursor, reuse.\",\n });\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,eAA4B,EAAE,OAAO,CAAC,CAAC,MAAM,kCAAkC;;AAY5F,MAAa,YAAkC,EAC5C,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,WAAW,OAAO,CAAC,CAAC,CAAC,CAAC,CACtF,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC;;AAGH,MAAa,cAAsC,EAChD,MAAM,CAAC,EAAE,OAAO,EAAE,YAAY,WAAW,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC,CAAC,CAAC,CAAC,CACtF,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAwFH,MAAa,iBAA4C,EACtD,OAAO;CACN,IAAI,UAAU;CACd,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;CACrB,aAAa,EAAE,IAAI,SAAS;CAC5B,cAAc,EAAE,OAAO,CAAC,CAAC,MAAM,gBAAgB;CAC/C,WAAW,EAAE,OAAO,CAAC,CAAC,MAAM,gBAAgB;CAC5C,cAAc,EAAE,OAAO,CAAC,CAAC,MAAM,gBAAgB;CAC/C,mBAAmB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;CAChE,WAAW,EAAE,IAAI,SAAS,CAAC,CAAC,cAAc;AAC5C,CAAC,CAAC,CACD,SAAS,cAAc;CAAE,IAAI;CAAkB,aAAa;AAAyB,CAAC;AAEzF,MAAM,eAAe;CACnB,IAAI,WAAW;CACf,OAAO,EAAE,OAAO;CAChB,aAAa,EAAE,OAAO,CAAC,CAAC,cAAc;CACtC,QAAQ,EAAE,OAAO,CAAC,CAAC,cAAc;CACjC,OAAO,EAAE,MAAM,YAAY,CAAC,CAAC,SAAS;CACtC,MAAM,EAAE,QAAQ,KAAK;CACrB,QAAQ,iBAAiB,cAAc;CACvC,QAAQ,EAAE,OAAO,CAAC,CAAC,cAAc;CACjC,WAAW,EAAE,IAAI,SAAS;CAC1B,eAAe,eAAe,cAAc;AAC9C;;AAGA,MAAa,kBAA8C,EACxD,OAAO,YAAY,CAAC,CACpB,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,iBAA4C,EACtD,OAAO;CACN,GAAG;CACH,UAAU;CACV,UAAU,EAAE,MAAM,cAAc,CAAC,CAAC,SAAS;AAC7C,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,iBAA4C,EACtD,OAAO;CACN,YAAY,WAAW;CACvB,WAAW,UAAU;CACrB,SAAS,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;CACtB,KAAK,EAAE,OAAO,CAAC,CAAC,cAAc;CAC9B,SAAS,QAAQ,OAAO,cAAc;CACtC,QAAQ,OAAO;CACf,QAAQ,EAAE,QAAQ;CAClB,mBAAmB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;AAClE,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC"}
1
+ {"version":3,"file":"artifact.js","names":[],"sources":["../src/artifact.ts"],"sourcesContent":["/**\n * Artifacts and versions as clients see them (INTERFACES §6): how a client names an artifact or its\n * source, and the summaries `artifact/list`, `artifact/get` and `artifact/publish` return.\n */\nimport * as z from \"zod\";\nimport { ArtifactId, Cursor, TokenId, VersionId } from \"./ids.ts\";\nimport { ArtifactLink, ArtifactManifest, SubmissionPolicy } from \"./manifest.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/**\n * An absolute file system path: the client resolves relative paths against its own directory.\n * POSIX `/…`, and on Windows a drive path (`C:\\…`, `C:/…`) or a UNC path (`\\\\server\\share\\…`,\n * WP-W1, D150); a drive-relative `C:x` or a root-relative `\\x` isn't absolute. The Windows forms\n * are alternatives beside the POSIX one, which the schema gate reads as a widening (D32).\n */\nexport const AbsolutePath: z.ZodString = z.string().regex(/^(?:\\/|[A-Za-z]:[\\\\/]|\\\\\\\\[^\\\\])/);\n\n/**\n * Where to build an artifact from: a source path (a `.tsx`, `.jsx` or `.mdx` file, or a directory\n * with an `index` entry), or an artifact ID, meaning the path it was last published from.\n */\nexport type SourceRef = { readonly path: string } | { readonly artifactId: string };\n\n/** Names an artifact: by its ID, or by a source path bound to it. */\nexport type ArtifactRef = { readonly artifactId: string } | { readonly path: string };\n\n/** The Zod schema of the `SourceRef` type. */\nexport const SourceRef: z.ZodType<SourceRef> = z\n .union([z.object({ path: AbsolutePath }), z.object({ artifactId: ArtifactId.schema })])\n .register(wireRegistry, {\n id: \"SourceRef\",\n description:\n \"Where to build an artifact from: an absolute source path, or an artifact ID (its last published source path).\",\n });\n\n/** The Zod schema of the `ArtifactRef` type. */\nexport const ArtifactRef: z.ZodType<ArtifactRef> = z\n .union([z.object({ artifactId: ArtifactId.schema }), z.object({ path: AbsolutePath })])\n .register(wireRegistry, {\n id: \"ArtifactRef\",\n description: \"Names an artifact by its ID or by an absolute source path bound to it.\",\n });\n\n/** One published version. */\nexport interface VersionSummary {\n /** The content-addressed version ID (D89). */\n readonly id: string;\n /** The per-artifact version number, for people: 1, 2, 3 … */\n readonly number: number;\n /** When it was published (RFC 3339, UTC). */\n readonly publishedAt: string;\n /** SHA-256 of the source tree's canonical listing, lowercase hex (DATA_MODEL §2). */\n readonly sourceDigest: string;\n /** SHA-256 of the build environment's canonical JSON, lowercase hex (DATA_MODEL §2). */\n readonly envDigest: string;\n /** SHA-256 of the build output's canonical listing: recorded, never identity (VR-01). */\n readonly outputDigest: string;\n /** Diagnostic codes a forced publish recorded (D41); absent when none. */\n readonly forcedDiagnostics?: readonly string[];\n /**\n * When `mostra gc` removed the version's files (D140): its ID and number stay, but it can't be\n * opened until its exact source is published again. Absent for a version whose files exist.\n */\n readonly collected?: string;\n}\n\n/** One artifact, as `artifact/list` returns it. Metadata comes from the latest version's manifest. */\nexport interface ArtifactSummary {\n /** The artifact ID. */\n readonly id: string;\n /** The title people see. */\n readonly title: string;\n /** What the artifact is for. */\n readonly description?: string;\n /** What kind of artifact it is. */\n readonly family?: string;\n /** Related artifacts. */\n readonly links: readonly ArtifactLink[];\n /** The render mode of the latest version. */\n readonly mode: \"spa\";\n /** The submission policy requested at publish or in the manifest; the host decides (D39). */\n readonly policy?: SubmissionPolicy;\n /** The source path the artifact was last published from. */\n readonly source?: string;\n /** When the artifact was first published (RFC 3339, UTC). */\n readonly createdAt: string;\n /** The version viewers are offered. */\n readonly latestVersion?: VersionSummary;\n}\n\n/** One artifact in full, as `artifact/get` returns it. */\nexport interface ArtifactDetail extends ArtifactSummary {\n /** The latest version's manifest. */\n readonly manifest: ArtifactManifest;\n /** Every version, newest number first. */\n readonly versions: readonly VersionSummary[];\n}\n\n/**\n * The receipt of `artifact/publish` (INTERFACES §6, H-07). Everything it names is durable before the\n * response is sent.\n */\nexport interface PublishReceipt {\n /** The artifact the version belongs to. */\n readonly artifactId: string;\n /** The content-addressed version ID (D89). */\n readonly versionId: string;\n /** The version number. */\n readonly version: number;\n /**\n * The capability URL: the artifact's default link (D97), the same for every publish until it is\n * rotated or revoked. Instances with the gateway (WP-05 on) always set it; optional on\n * the wire so instances without it can publish (D90).\n */\n readonly url?: string;\n /**\n * The ID of the token behind `url`, the artifact's default link (D97), for `view/rotate` and\n * `view/revoke`. Present whenever `url` is.\n */\n readonly tokenId?: string;\n /** The event cursor of the version's `version.published` event; `wait` and events read after it. */\n readonly cursor: string;\n /** `true` when this artifact already had this exact source and environment as a version. */\n readonly reused: boolean;\n /** The error codes a forced publish recorded (D41). */\n readonly forcedDiagnostics?: readonly string[];\n}\n\n/** The Zod schema of the `VersionSummary` type. */\nexport const VersionSummary: z.ZodType<VersionSummary> = z\n .object({\n id: VersionId.schema,\n number: z.int().min(1),\n publishedAt: z.iso.datetime(),\n sourceDigest: z.string().regex(/^[0-9a-f]{64}$/),\n envDigest: z.string().regex(/^[0-9a-f]{64}$/),\n outputDigest: z.string().regex(/^[0-9a-f]{64}$/),\n forcedDiagnostics: z.array(z.string()).readonly().exactOptional(),\n collected: z.iso.datetime().exactOptional(),\n })\n .register(wireRegistry, { id: \"VersionSummary\", description: \"One published version.\" });\n\nconst summaryShape = {\n id: ArtifactId.schema,\n title: z.string(),\n description: z.string().exactOptional(),\n family: z.string().exactOptional(),\n links: z.array(ArtifactLink).readonly(),\n mode: z.literal(\"spa\"),\n policy: SubmissionPolicy.exactOptional(),\n source: z.string().exactOptional(),\n createdAt: z.iso.datetime(),\n latestVersion: VersionSummary.exactOptional(),\n};\n\n/** The Zod schema of the `ArtifactSummary` type. */\nexport const ArtifactSummary: z.ZodType<ArtifactSummary> = z\n .object(summaryShape)\n .register(wireRegistry, {\n id: \"ArtifactSummary\",\n description: \"One artifact: metadata from its latest version, its source and latest version.\",\n });\n\n/** The Zod schema of the `ArtifactDetail` type. */\nexport const ArtifactDetail: z.ZodType<ArtifactDetail> = z\n .object({\n ...summaryShape,\n manifest: ArtifactManifest,\n versions: z.array(VersionSummary).readonly(),\n })\n .register(wireRegistry, {\n id: \"ArtifactDetail\",\n description: \"One artifact in full: its summary, the latest manifest and every version.\",\n });\n\n/** The Zod schema of the `PublishReceipt` type. */\nexport const PublishReceipt: z.ZodType<PublishReceipt> = z\n .object({\n artifactId: ArtifactId.schema,\n versionId: VersionId.schema,\n version: z.int().min(1),\n url: z.string().exactOptional(),\n tokenId: TokenId.schema.exactOptional(),\n cursor: Cursor.schema,\n reused: z.boolean(),\n forcedDiagnostics: z.array(z.string()).readonly().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"PublishReceipt\",\n description:\n \"The receipt of artifact/publish: artifact, version, number, capability URL when served, event cursor, reuse.\",\n });\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,MAAa,eAA4B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,IAAI,SAAS;CAC1B,eAAe,eAAe,cAAc;AAC9C;;AAGA,MAAa,kBAA8C,EACxD,OAAO,YAAY,CAAC,CACpB,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,iBAA4C,EACtD,OAAO;CACN,GAAG;CACH,UAAU;CACV,UAAU,EAAE,MAAM,cAAc,CAAC,CAAC,SAAS;AAC7C,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,iBAA4C,EACtD,OAAO;CACN,YAAY,WAAW;CACvB,WAAW,UAAU;CACrB,SAAS,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;CACtB,KAAK,EAAE,OAAO,CAAC,CAAC,cAAc;CAC9B,SAAS,QAAQ,OAAO,cAAc;CACtC,QAAQ,OAAO;CACf,QAAQ,EAAE,QAAQ;CAClB,mBAAmB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;AAClE,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC"}
package/dist/browser.d.ts CHANGED
@@ -126,6 +126,48 @@ export interface FrameTicket extends ViewContext {
126
126
  * (D70, D158 item 5). Absent: cookie mode.
127
127
  */
128
128
  readonly mode?: "worker";
129
+ /**
130
+ * The artifact is paused (D165 item 14): the shell says so, by whom and why (the reason as text);
131
+ * it takes no submissions and runs no actions until it is resumed (WP-30).
132
+ */
133
+ readonly paused?: {
134
+ readonly by: "owner" | "operator";
135
+ readonly reason?: string;
136
+ };
137
+ /** On a remote server: what the hosted shell's trusted chrome shows around the page (D161). */
138
+ readonly hosted?: HostedChrome;
139
+ }
140
+ /**
141
+ * The hosted shell's trusted chrome for one view (D161, ARCHITECTURE §15.8; WP-30). Every string an
142
+ * owner or operator supplies is rendered as text, never as markup.
143
+ */
144
+ export interface HostedChrome {
145
+ /** Who sent the page: the owner's display name, and the provider that verified it, if any. */
146
+ readonly sender?: {
147
+ readonly name: string;
148
+ readonly verifiedBy?: string;
149
+ };
150
+ /** Who this browser is to the page: signed in as an account, or anonymous (with a chosen name). */
151
+ readonly viewer: {
152
+ readonly kind: "account" | "anonymous" | "named";
153
+ readonly name?: string;
154
+ readonly verified: boolean;
155
+ };
156
+ /** Whether "Sign in" is offered (the viewer isn't signed in, and the server has a provider). */
157
+ readonly signIn: boolean;
158
+ /** The operator's footer wording in place of the shell's own; never hidden on a public link. */
159
+ readonly footer?: string;
160
+ /** The operator's line after "Your answer was sent.". */
161
+ readonly afterSubmit?: string;
162
+ /** The made-with mark, where the operator shows one. */
163
+ readonly madeWith?: {
164
+ readonly href?: string;
165
+ };
166
+ /** A page shown before the artifact, once per browser and link. */
167
+ readonly interstitial?: {
168
+ readonly kind: string;
169
+ readonly message?: string;
170
+ };
129
171
  }
130
172
  /** The Zod schema of the `FrameTicket` type. */
131
173
  export declare const FrameTicket: z.ZodType<FrameTicket>;
@@ -134,6 +176,11 @@ export declare const FrameTicket: z.ZodType<FrameTicket>;
134
176
  * its frame session's secret, which no cookie can carry across sites.
135
177
  */
136
178
  export declare const FRAME_SESSION_HEADER = "x-mostra-frame";
179
+ /**
180
+ * The header a hosted shell sends its session's secret in (INTERFACES §18.4, D165 item 8): no
181
+ * cookie is ever set or read on a hosted host, so no tenant page can toss, shadow or crowd one out.
182
+ */
183
+ export declare const SHELL_SESSION_HEADER = "x-mostra-shell";
137
184
  /**
138
185
  * `POST /_mostra/enter` on the artifact's origin: the bootstrap page exchanges the shell's
139
186
  * single-use frame ticket, from `/_mostra/enter#t=…`, for a worker-mode frame session.
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","names":[],"sources":["../src/browser.ts"],"mappings":";;;;;;qBA0Ca;;qBAGA;;qBAGA;;iBAGI;;WAEN;;WAEA;;WAEA,cAAc;;WAEd;;WAEA,cAAc;;;qBAIZ,eAAe,EAAE,QAAQ;;iBAcrB;;WAEN;;WAEA,kBAAkB;;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N;;WAEA,kBAAkB;;;qBAIhB,oBAAoB,EAAE,QAAQ;;;;;;iBAY1B;;WAEN;;WAEA;;WAEA,cAAc;;WAEd;;WAEA;;WAEA;;;qBAIE,eAAe,EAAE,QAAQ;;iBAgBrB;;WAEN;;;qBAIE,eAAe,EAAE,QAAQ;;iBAQrB;;WAEN;;WAEA;;WAEA;;WAEA;;;qBAIE,eAAe,EAAE,QAAQ;;;;;;iBAiBrB;;WAEN,SAAS;;WAET,kBAAkB;;;qBAIhB,WAAW,EAAE,QAAQ"}
package/dist/browser.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { wireRegistry } from "./wire-registry.js";
2
2
  import { ArtifactId, Cursor, MutationId, ViewId } from "./ids.js";
3
- import { SubmissionPolicy } from "./manifest.js";
3
+ import { SubmissionPolicy } from "./policy.js";
4
4
  import { REVIEW_SET_ID_PATTERN, SubmitChannel, TrustedControl, VersionRef, ViewContext, ViewContextWire, readViewContext } from "./view.js";
5
5
  import { DocumentRevision, EventRecord, FieldOp, FieldState, SubmissionSummary, Viewer } from "./interaction.js";
6
6
  import * as z from "zod";
@@ -82,6 +82,29 @@ const PollResult = z.object({
82
82
  id: "PollResult",
83
83
  description: "A long-poll answer: the cursor, the events after the asked one, and a snapshot."
84
84
  });
85
+ const HostedChrome = z.object({
86
+ sender: z.object({
87
+ name: z.string().max(256),
88
+ verifiedBy: z.string().max(64).exactOptional()
89
+ }).exactOptional(),
90
+ viewer: z.object({
91
+ kind: z.enum([
92
+ "account",
93
+ "anonymous",
94
+ "named"
95
+ ]),
96
+ name: z.string().max(256).exactOptional(),
97
+ verified: z.boolean()
98
+ }),
99
+ signIn: z.boolean(),
100
+ footer: z.string().max(500).exactOptional(),
101
+ afterSubmit: z.string().max(500).exactOptional(),
102
+ madeWith: z.object({ href: z.url({ protocol: /^https$/ }).max(2048).exactOptional() }).exactOptional(),
103
+ interstitial: z.object({
104
+ kind: z.string().max(64),
105
+ message: z.string().max(2e3).exactOptional()
106
+ }).exactOptional()
107
+ });
85
108
  /** The Zod schema of the `FrameTicket` type. */
86
109
  const FrameTicket = z.object({
87
110
  artifactId: ArtifactId.schema,
@@ -103,7 +126,12 @@ const FrameTicket = z.object({
103
126
  pinned: z.boolean(),
104
127
  serverParked: z.literal(true).exactOptional(),
105
128
  devPreview: z.literal(true).exactOptional(),
106
- mode: z.literal("worker").exactOptional()
129
+ mode: z.literal("worker").exactOptional(),
130
+ paused: z.object({
131
+ by: z.enum(["owner", "operator"]),
132
+ reason: z.string().max(500).exactOptional()
133
+ }).exactOptional(),
134
+ hosted: HostedChrome.exactOptional()
107
135
  }).register(wireRegistry, {
108
136
  id: "FrameTicket",
109
137
  description: "A frame ticket: the view it opens, where to load it, and the view's controls."
@@ -113,6 +141,11 @@ const FrameTicket = z.object({
113
141
  * its frame session's secret, which no cookie can carry across sites.
114
142
  */
115
143
  const FRAME_SESSION_HEADER = "x-mostra-frame";
144
+ /**
145
+ * The header a hosted shell sends its session's secret in (INTERFACES §18.4, D165 item 8): no
146
+ * cookie is ever set or read on a hosted host, so no tenant page can toss, shadow or crowd one out.
147
+ */
148
+ const SHELL_SESSION_HEADER = "x-mostra-shell";
116
149
  /** The Zod schema of the `EnterRequest` type. */
117
150
  const EnterRequest = z.object({ ticket: z.string().min(1).max(64) }).register(wireRegistry, {
118
151
  id: "EnterRequest",
@@ -194,6 +227,6 @@ const CarryOver = z.object({
194
227
  description: "The viewer's answers a version doesn't carry over."
195
228
  });
196
229
  //#endregion
197
- export { BROWSER_PROTOCOL_REVISION, BROWSER_PROTOCOL_REVISIONS, CarryOver, ChooseRequest, DocumentSnapshot, EnterRequest, EnterResult, FRAME_SESSION_HEADER, FieldsRequest, FollowRequest, FrameSessionFacts, FrameTicket, OrphanedField, PollResult, REVIEW_SET_ID_PATTERN, SIGNAL_PAYLOAD_MAX_BYTES, ShellSubmitRequest, SignalRequest, StreamSnapshot, StreamTicket, StreamTicketRequest, SubmitRequest, VersionRef, ViewContext, ViewContextWire, readViewContext };
230
+ export { BROWSER_PROTOCOL_REVISION, BROWSER_PROTOCOL_REVISIONS, CarryOver, ChooseRequest, DocumentSnapshot, EnterRequest, EnterResult, FRAME_SESSION_HEADER, FieldsRequest, FollowRequest, FrameSessionFacts, FrameTicket, OrphanedField, PollResult, REVIEW_SET_ID_PATTERN, SHELL_SESSION_HEADER, SIGNAL_PAYLOAD_MAX_BYTES, ShellSubmitRequest, SignalRequest, StreamSnapshot, StreamTicket, StreamTicketRequest, SubmitRequest, VersionRef, ViewContext, ViewContextWire, readViewContext };
198
231
 
199
232
  //# sourceMappingURL=browser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.js","names":[],"sources":["../src/browser.ts"],"sourcesContent":["/**\n * The browser protocol (INTERFACES §4, D106): what the client runtime in an artifact's frame sends\n * to the gateway and receives from it. Published versions embed the client runtime, so a gateway\n * serves every revision it ever shipped (FAILURE_MODEL §7); within a revision payloads only grow.\n * Paths are `/_mostra/v/{revision}/…` on the artifact's origin.\n *\n * ```ts\n * const body: FieldsRequest = { mutationId, scope: \"viewer\", baseRevision: \"3\", viewId, ops };\n * await fetch(`/_mostra/v/${BROWSER_PROTOCOL_REVISION}/fields`, { method: \"POST\", body: … });\n * ```\n */\nimport * as z from \"zod\";\nimport type { EphemeralMessage } from \"./actions.ts\";\nimport { ArtifactId, Cursor, MutationId, ViewId } from \"./ids.ts\";\nimport {\n DocumentRevision,\n EventRecord,\n FieldOp,\n FieldState,\n SubmissionSummary,\n Viewer,\n} from \"./interaction.ts\";\nimport { SubmissionPolicy } from \"./manifest.ts\";\nimport {\n REVIEW_SET_ID_PATTERN,\n SubmitChannel,\n TrustedControl,\n VersionRef,\n type ViewContext,\n} from \"./view.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\nexport {\n type DeliveryTarget,\n REVIEW_SET_ID_PATTERN,\n readViewContext,\n VersionRef,\n ViewContext,\n ViewContextWire,\n} from \"./view.ts\";\n\n/** Every browser-protocol revision this release serves, oldest first. */\nexport const BROWSER_PROTOCOL_REVISIONS: readonly [\"2026-10-15\"] = [\"2026-10-15\"];\n\n/** The newest browser-protocol revision: what a client runtime built now speaks. */\nexport const BROWSER_PROTOCOL_REVISION = \"2026-10-15\";\n\n/** The longest JSON a signal's payload may be, in UTF-8 bytes (D106). */\nexport const SIGNAL_PAYLOAD_MAX_BYTES: number = 64 * 1024;\n\n/** `POST …/fields`: one mutation of the viewer's draft or the artifact's state. */\nexport interface FieldsRequest {\n /** A fresh `mut_` ID per change; a retry repeats it and gets the recorded result. */\n readonly mutationId: string;\n /** Which document: the viewer's draft or the artifact's shared state. */\n readonly scope: \"viewer\" | \"artifact\";\n /** The document revision the page last saw; fields changed after it come back as conflicts. */\n readonly baseRevision: DocumentRevision;\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** The field changes, applied together under one revision. */\n readonly ops: readonly FieldOp[];\n}\n\n/** The Zod schema of the `FieldsRequest` type. */\nexport const FieldsRequest: z.ZodType<FieldsRequest> = z\n .object({\n mutationId: MutationId.schema,\n scope: z.enum([\"viewer\", \"artifact\"]),\n baseRevision: DocumentRevision,\n viewId: ViewId.schema,\n ops: z.array(FieldOp).min(1).max(1000).readonly(),\n })\n .register(wireRegistry, {\n id: \"FieldsRequest\",\n description: \"A browser mutation: its ID, scope, base revision, view and field ops.\",\n });\n\n/** `POST …/submit`: submit the viewer's draft from the artifact's own code (D40). */\nexport interface SubmitRequest {\n /** The view the page was opened as (D104); its version is what the submission names. */\n readonly viewId: string;\n /** The draft revision the viewer saw; another one is `MOSTRA_SUBMIT_REVISION_MOVED`. */\n readonly expectedRevision: DocumentRevision;\n /** Always `artifact` on this route; the shell's trusted Submit is the `shell` channel (D40). */\n readonly channel: \"artifact\";\n}\n\n/** The Zod schema of the `SubmitRequest` type. */\nexport const SubmitRequest: z.ZodType<SubmitRequest> = z\n .object({\n viewId: ViewId.schema,\n expectedRevision: DocumentRevision,\n channel: z.literal(\"artifact\"),\n })\n .register(wireRegistry, {\n id: \"SubmitRequest\",\n description: \"A browser submit: the view and the draft revision the viewer saw.\",\n });\n\n/** `POST …/signal`: raise a named signal for the host's attention (IN-09). */\nexport interface SignalRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** Letters, digits, `.`, `_` and `-`; `submit` is reserved. */\n readonly name: string;\n /** Any JSON, at most 64 KiB. */\n readonly payload?: unknown;\n}\n\n/** The Zod schema of the `SignalRequest` type. */\nexport const SignalRequest: z.ZodType<SignalRequest> = z\n .object({\n viewId: ViewId.schema,\n name: z.string().min(1).max(64),\n payload: z.unknown().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"SignalRequest\",\n description: \"A browser signal: the view, the signal's name and an optional JSON payload.\",\n }) as z.ZodType<SignalRequest>;\n\n/** A document as the page loads it: its revision and fields. */\nexport interface DocumentSnapshot {\n /** The document's revision. */\n readonly revision: DocumentRevision;\n /** The draft's epoch (D103); 1 for artifact state. */\n readonly epoch: number;\n /** Every field by ID. */\n readonly fields: Readonly<Record<string, FieldState>>;\n}\n\n/** The Zod schema of the `DocumentSnapshot` type. */\nexport const DocumentSnapshot: z.ZodType<DocumentSnapshot> = z\n .object({\n revision: DocumentRevision,\n epoch: z.int().min(1),\n fields: z.record(z.string(), FieldState),\n })\n .register(wireRegistry, {\n id: \"DocumentSnapshot\",\n description: \"A document's revision, epoch and fields, as a page loads it.\",\n });\n\n/**\n * The first message of a browser event stream, and a poll's `snapshot`: where the page stands,\n * so it renders the canonical draft and state before applying events after `cursor`.\n */\nexport interface StreamSnapshot {\n /** Events after this cursor follow. */\n readonly cursor: string;\n /** Who the page acts as. */\n readonly viewer: Viewer;\n /** The viewer's draft. */\n readonly draft: DocumentSnapshot;\n /** The artifact's shared state. */\n readonly state: DocumentSnapshot;\n /** The submission that closed this draft, or this viewer's latest under `epochs`. */\n readonly submission?: SubmissionSummary;\n /**\n * The artifact's latest version when the snapshot was read (WP-07): a reader that missed its\n * `version.published` event (published between a frame ticket and the stream, or compacted)\n * still learns of it.\n */\n readonly latest?: VersionRef;\n}\n\n/** The Zod schema of the `StreamSnapshot` type. */\nexport const StreamSnapshot: z.ZodType<StreamSnapshot> = z\n .object({\n cursor: Cursor.schema,\n viewer: Viewer,\n draft: DocumentSnapshot,\n state: DocumentSnapshot,\n submission: SubmissionSummary.exactOptional(),\n latest: VersionRef.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"StreamSnapshot\",\n description: \"Where a page stands: cursor, viewer, draft, artifact state and its submission.\",\n });\n\n/** `GET …/events/poll`: the long-poll answer on the same cursor as the stream (D47). */\nexport interface PollResult {\n /** Where the next poll continues. */\n readonly cursor: string;\n /** The events for this page after the cursor asked for, in order. */\n readonly events: readonly EventRecord[];\n /** Present when the poll asked for none or its cursor was compacted away. */\n readonly snapshot?: StreamSnapshot;\n /**\n * Run and live updates for this view since its last poll (WP-08): lossy and never stored as\n * events, the long-poll's counterpart of the stream's `run` and `live` messages.\n */\n readonly ephemeral?: readonly EphemeralMessage[];\n}\n\n/** The Zod schema of the `PollResult` type. */\nexport const PollResult: z.ZodType<PollResult> = z\n .object({\n cursor: Cursor.schema,\n events: z.array(EventRecord).readonly(),\n snapshot: StreamSnapshot.exactOptional(),\n ephemeral: z.array(z.record(z.string(), z.unknown())).readonly().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"PollResult\",\n description: \"A long-poll answer: the cursor, the events after the asked one, and a snapshot.\",\n }) as unknown as z.ZodType<PollResult>;\n\n/**\n * `POST /a/{artifactId}/_mostra/ticket`'s answer on the shell origin: a single-use frame ticket,\n * the view it opens and what the shell needs to render the view's trusted controls (D104, D108).\n */\nexport interface FrameTicket extends ViewContext {\n /** The frame's entry URL, carrying the single-use ticket. */\n readonly src: string;\n /** The artifact's origin: the only origin the bridge accepts messages from. */\n readonly artifactOrigin: string;\n /** Whether this viewer follows the artifact's new versions (D63). */\n readonly follow: boolean;\n /** Whether the link opens this version only (D97 item 9): then the shell offers no newer one. */\n readonly pinned: boolean;\n /**\n * The version's server code keeps crashing and is parked (WP-08, FAILURE_MODEL §2): the shell\n * says so, since the page's actions and live data won't work until a new publish.\n */\n readonly serverParked?: true;\n /**\n * The frame shows `mostra dev`'s development preview of unpublished source (D140 item 12): the\n * shell says so, and it is never a published version.\n */\n readonly devPreview?: true;\n /**\n * `worker` when the shell and the artifact are two sites (a Cloudflare quick tunnel, a host's\n * addresses on two hosts): the frame enters through the bootstrap page and a service worker\n * (D70, D158 item 5). Absent: cookie mode.\n */\n readonly mode?: \"worker\";\n}\n\n/** The Zod schema of the `FrameTicket` type. */\nexport const FrameTicket: z.ZodType<FrameTicket> = z\n .object({\n artifactId: ArtifactId.schema,\n viewId: ViewId.schema,\n version: VersionRef,\n latest: VersionRef,\n policy: SubmissionPolicy,\n submitChannels: z.array(SubmitChannel).min(1).max(2).readonly(),\n controls: z.array(TrustedControl).max(32).readonly(),\n target: z.enum([\"live\", \"static\", \"mcp-app\", \"verify\"]),\n src: z.string().min(1),\n artifactOrigin: z.string().min(1),\n follow: z.boolean(),\n pinned: z.boolean(),\n serverParked: z.literal(true).exactOptional(),\n devPreview: z.literal(true).exactOptional(),\n mode: z.literal(\"worker\").exactOptional(),\n })\n .register(wireRegistry, {\n id: \"FrameTicket\",\n description: \"A frame ticket: the view it opens, where to load it, and the view's controls.\",\n });\n\n// ── Frame sessions in worker mode (WP-13, D70, D158 item 5) ───────────────────────────────\n\n/**\n * The header Mostra's service worker adds to every same-origin request of a worker-mode frame:\n * its frame session's secret, which no cookie can carry across sites.\n */\nexport const FRAME_SESSION_HEADER = \"x-mostra-frame\";\n\n/**\n * `POST /_mostra/enter` on the artifact's origin: the bootstrap page exchanges the shell's\n * single-use frame ticket, from `/_mostra/enter#t=…`, for a worker-mode frame session.\n */\nexport interface EnterRequest {\n /** The frame ticket. */\n readonly ticket: string;\n}\n\n/** The Zod schema of the `EnterRequest` type. */\nexport const EnterRequest: z.ZodType<EnterRequest> = z\n .object({ ticket: z.string().min(1).max(64) })\n .register(wireRegistry, { id: \"EnterRequest\", description: \"A frame ticket to exchange.\" });\n\n/** The answer to `EnterRequest`. */\nexport interface EnterResult {\n /** The frame session's secret, which the service worker sends as `X-Mostra-Frame`. */\n readonly session: string;\n /** The shell's origin: the only page the bootstrap reports to. */\n readonly shellOrigin: string;\n}\n\n/** The Zod schema of the `EnterResult` type. */\nexport const EnterResult: z.ZodType<EnterResult> = z\n .object({ session: z.string().min(1), shellOrigin: z.string().min(1) })\n .register(wireRegistry, {\n id: \"EnterResult\",\n description: \"A worker-mode frame session's secret and the shell's origin.\",\n });\n\n/**\n * `POST /_mostra/v/{rev}/ticket`: a single-use ticket that opens one event stream, long poll or\n * WebSocket of this session without it (`?ticket=`), so the request can bypass the service\n * worker (VERIFIED_FACTS: Firefox stalls on endless responses a worker passes on).\n */\nexport interface StreamTicketRequest {\n /** What it opens: `stream` (events and polls, the default) or `socket` (a WebSocket). */\n readonly purpose?: \"stream\" | \"socket\";\n}\n\n/** The Zod schema of the `StreamTicketRequest` type. */\nexport const StreamTicketRequest: z.ZodType<StreamTicketRequest> = z\n .object({ purpose: z.enum([\"stream\", \"socket\"]).exactOptional() })\n .register(wireRegistry, { id: \"StreamTicketRequest\" });\n\n/** The answer to a `StreamTicketRequest`. */\nexport interface StreamTicket {\n /** The ticket: 130 bits, single-use. */\n readonly ticket: string;\n /** When it stops working, 60 s after it was minted. */\n readonly expiresAt: string;\n}\n\n/** The Zod schema of the `StreamTicket` type. */\nexport const StreamTicket: z.ZodType<StreamTicket> = z\n .object({ ticket: z.string().min(1), expiresAt: z.iso.datetime() })\n .register(wireRegistry, {\n id: \"StreamTicket\",\n description: \"A single-use ticket for one stream, poll or WebSocket.\",\n });\n\n/**\n * `GET /_mostra/session` on the artifact's origin: the frame session's facts for same-origin code.\n */\nexport interface FrameSessionFacts {\n /** The CSRF token every mutation sends as `X-Mostra-CSRF`. */\n readonly csrf: string;\n /** The artifact the frame shows. */\n readonly artifactId: string;\n /** The shell's exact origin: the bridge's only peer. */\n readonly shellOrigin: string;\n /** The link's scopes. */\n readonly scopes: readonly string[];\n /** The viewer the page acts as (WP-07). */\n readonly viewer?: Viewer;\n /** The version the frame session entered. */\n readonly version?: VersionRef;\n /** How the frame authenticates (D70): absent means `cookie`. */\n readonly mode?: \"cookie\" | \"worker\";\n /**\n * `false` where event streams don't pass (a Cloudflare quick tunnel holds responses back until\n * they end): the page long-polls from the start (D47). Absent means streams pass.\n */\n readonly streams?: boolean;\n}\n\n/** The Zod schema of the `FrameSessionFacts` type. */\nexport const FrameSessionFacts: z.ZodType<FrameSessionFacts> = z\n .object({\n csrf: z.string().min(1),\n artifactId: ArtifactId.schema,\n shellOrigin: z.string().min(1),\n scopes: z.array(z.string()).readonly(),\n viewer: Viewer.exactOptional(),\n version: VersionRef.exactOptional(),\n mode: z.enum([\"cookie\", \"worker\"]).exactOptional(),\n streams: z.boolean().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"FrameSessionFacts\",\n description: \"A frame session's CSRF token, shell origin, scopes, viewer, version and mode.\",\n });\n\n// ── The shell's own routes (WP-07, on the shell origin) ──────────────────────────────────\n\n/**\n * `POST /a/{artifactId}/_mostra/v/{rev}/submit`: the shell's trusted Submit (the `shell` channel,\n * D40). Only the shell's page can send it: the route takes the shell's session, its exact origin\n * and its CSRF token, none of which an artifact's page has.\n */\nexport interface ShellSubmitRequest {\n /** The view the shell's frame shows (D104); its version is what the submission names. */\n readonly viewId: string;\n /** The draft revision the viewer saw, after the frame flushed its saves. */\n readonly expectedRevision: DocumentRevision;\n}\n\n/** The Zod schema of the `ShellSubmitRequest` type. */\nexport const ShellSubmitRequest: z.ZodType<ShellSubmitRequest> = z\n .object({ viewId: ViewId.schema, expectedRevision: DocumentRevision })\n .register(wireRegistry, {\n id: \"ShellSubmitRequest\",\n description: \"The shell's trusted Submit: the view and the draft revision the viewer saw.\",\n });\n\n/**\n * `POST /a/{artifactId}/_mostra/v/{rev}/review/choose`: the shell's trusted Choose (D65, D113).\n * It writes the viewer's draft field `review.<reviewSetId>.choice` like any mutation, so a stale\n * base revision comes back as a conflict.\n */\nexport interface ChooseRequest {\n /** The view the shell's frame shows. */\n readonly viewId: string;\n /** A fresh `mut_` ID; a retry repeats it. */\n readonly mutationId: string;\n /** The draft revision the shell last saw. */\n readonly baseRevision: DocumentRevision;\n /** The review set. */\n readonly reviewSetId: string;\n /** The chosen candidate's ID. */\n readonly candidateId: string;\n /** The candidate's label, kept with the choice for results. */\n readonly label?: string;\n}\n\n/** The Zod schema of the `ChooseRequest` type. */\nexport const ChooseRequest: z.ZodType<ChooseRequest> = z\n .object({\n viewId: ViewId.schema,\n mutationId: MutationId.schema,\n baseRevision: DocumentRevision,\n reviewSetId: z.string().regex(REVIEW_SET_ID_PATTERN),\n candidateId: z.string().min(1).max(256),\n label: z.string().max(256).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ChooseRequest\",\n description:\n \"The shell's trusted Choose: the view, mutation, base revision, set and candidate.\",\n });\n\n/** `POST /a/{artifactId}/_mostra/v/{rev}/follow`: the viewer's \"Always follow this artifact\" (D63). */\nexport interface FollowRequest {\n /** `true` to load new versions automatically, `false` to stop. */\n readonly follow: boolean;\n}\n\n/** The Zod schema of the `FollowRequest` type. */\nexport const FollowRequest: z.ZodType<FollowRequest> = z\n .object({ follow: z.boolean() })\n .register(wireRegistry, {\n id: \"FollowRequest\",\n description: \"Whether the viewer follows the artifact's new versions.\",\n });\n\n/** A draft field a version doesn't cover (D42, D109): kept, shown read-only and delivered. */\nexport interface OrphanedField {\n /** The field's ID. */\n readonly id: string;\n /** Its label, when it has one. */\n readonly label?: string;\n /** Its value. */\n readonly value: unknown;\n /** The version whose view last wrote it. */\n readonly fromVersion: number;\n}\n\n/** The Zod schema of the `OrphanedField` type. */\nexport const OrphanedField: z.ZodType<OrphanedField> = z\n .object({\n id: z.string(),\n label: z.string().exactOptional(),\n value: z.unknown(),\n fromVersion: z.int().min(1),\n })\n .register(wireRegistry, {\n id: \"OrphanedField\",\n description: \"A draft field a version doesn't cover: its ID, label, value and source version.\",\n }) as z.ZodType<OrphanedField>;\n\n/**\n * `GET /a/{artifactId}/_mostra/v/{rev}/carry?version=<number>`: which of the viewer's answers a\n * version doesn't carry over (D42, D109). The banner counts them before a switch; the \"Not\n * carried over\" panel lists them for the version shown.\n */\nexport interface CarryOver {\n /** The version asked about. */\n readonly version: VersionRef;\n /** The viewer's draft fields the version doesn't cover. */\n readonly orphans: readonly OrphanedField[];\n}\n\n/** The Zod schema of the `CarryOver` type. */\nexport const CarryOver: z.ZodType<CarryOver> = z\n .object({ version: VersionRef, orphans: z.array(OrphanedField).readonly() })\n .register(wireRegistry, {\n id: \"CarryOver\",\n description: \"The viewer's answers a version doesn't carry over.\",\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0CA,MAAa,6BAAsD,CAAC,YAAY;;AAGhF,MAAa,4BAA4B;;AAGzC,MAAa,2BAAmC;;AAiBhD,MAAa,gBAA0C,EACpD,OAAO;CACN,YAAY,WAAW;CACvB,OAAO,EAAE,KAAK,CAAC,UAAU,UAAU,CAAC;CACpC,cAAc;CACd,QAAQ,OAAO;CACf,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAI,CAAC,CAAC,SAAS;AAClD,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAaH,MAAa,gBAA0C,EACpD,OAAO;CACN,QAAQ,OAAO;CACf,kBAAkB;CAClB,SAAS,EAAE,QAAQ,UAAU;AAC/B,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAaH,MAAa,gBAA0C,EACpD,OAAO;CACN,QAAQ,OAAO;CACf,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;CAC9B,SAAS,EAAE,QAAQ,CAAC,CAAC,cAAc;AACrC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAaH,MA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browser.ts"],"sourcesContent":["/**\n * The browser protocol (INTERFACES §4, D106): what the client runtime in an artifact's frame sends\n * to the gateway and receives from it. Published versions embed the client runtime, so a gateway\n * serves every revision it ever shipped (FAILURE_MODEL §7); within a revision payloads only grow.\n * Paths are `/_mostra/v/{revision}/…` on the artifact's origin.\n *\n * ```ts\n * const body: FieldsRequest = { mutationId, scope: \"viewer\", baseRevision: \"3\", viewId, ops };\n * await fetch(`/_mostra/v/${BROWSER_PROTOCOL_REVISION}/fields`, { method: \"POST\", body: … });\n * ```\n */\nimport * as z from \"zod\";\nimport type { EphemeralMessage } from \"./actions.ts\";\nimport { ArtifactId, Cursor, MutationId, ViewId } from \"./ids.ts\";\nimport {\n DocumentRevision,\n EventRecord,\n FieldOp,\n FieldState,\n SubmissionSummary,\n Viewer,\n} from \"./interaction.ts\";\nimport { SubmissionPolicy } from \"./manifest.ts\";\nimport {\n REVIEW_SET_ID_PATTERN,\n SubmitChannel,\n TrustedControl,\n VersionRef,\n type ViewContext,\n} from \"./view.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\nexport {\n type DeliveryTarget,\n REVIEW_SET_ID_PATTERN,\n readViewContext,\n VersionRef,\n ViewContext,\n ViewContextWire,\n} from \"./view.ts\";\n\n/** Every browser-protocol revision this release serves, oldest first. */\nexport const BROWSER_PROTOCOL_REVISIONS: readonly [\"2026-10-15\"] = [\"2026-10-15\"];\n\n/** The newest browser-protocol revision: what a client runtime built now speaks. */\nexport const BROWSER_PROTOCOL_REVISION = \"2026-10-15\";\n\n/** The longest JSON a signal's payload may be, in UTF-8 bytes (D106). */\nexport const SIGNAL_PAYLOAD_MAX_BYTES: number = 64 * 1024;\n\n/** `POST …/fields`: one mutation of the viewer's draft or the artifact's state. */\nexport interface FieldsRequest {\n /** A fresh `mut_` ID per change; a retry repeats it and gets the recorded result. */\n readonly mutationId: string;\n /** Which document: the viewer's draft or the artifact's shared state. */\n readonly scope: \"viewer\" | \"artifact\";\n /** The document revision the page last saw; fields changed after it come back as conflicts. */\n readonly baseRevision: DocumentRevision;\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** The field changes, applied together under one revision. */\n readonly ops: readonly FieldOp[];\n}\n\n/** The Zod schema of the `FieldsRequest` type. */\nexport const FieldsRequest: z.ZodType<FieldsRequest> = z\n .object({\n mutationId: MutationId.schema,\n scope: z.enum([\"viewer\", \"artifact\"]),\n baseRevision: DocumentRevision,\n viewId: ViewId.schema,\n ops: z.array(FieldOp).min(1).max(1000).readonly(),\n })\n .register(wireRegistry, {\n id: \"FieldsRequest\",\n description: \"A browser mutation: its ID, scope, base revision, view and field ops.\",\n });\n\n/** `POST …/submit`: submit the viewer's draft from the artifact's own code (D40). */\nexport interface SubmitRequest {\n /** The view the page was opened as (D104); its version is what the submission names. */\n readonly viewId: string;\n /** The draft revision the viewer saw; another one is `MOSTRA_SUBMIT_REVISION_MOVED`. */\n readonly expectedRevision: DocumentRevision;\n /** Always `artifact` on this route; the shell's trusted Submit is the `shell` channel (D40). */\n readonly channel: \"artifact\";\n}\n\n/** The Zod schema of the `SubmitRequest` type. */\nexport const SubmitRequest: z.ZodType<SubmitRequest> = z\n .object({\n viewId: ViewId.schema,\n expectedRevision: DocumentRevision,\n channel: z.literal(\"artifact\"),\n })\n .register(wireRegistry, {\n id: \"SubmitRequest\",\n description: \"A browser submit: the view and the draft revision the viewer saw.\",\n });\n\n/** `POST …/signal`: raise a named signal for the host's attention (IN-09). */\nexport interface SignalRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** Letters, digits, `.`, `_` and `-`; `submit` is reserved. */\n readonly name: string;\n /** Any JSON, at most 64 KiB. */\n readonly payload?: unknown;\n}\n\n/** The Zod schema of the `SignalRequest` type. */\nexport const SignalRequest: z.ZodType<SignalRequest> = z\n .object({\n viewId: ViewId.schema,\n name: z.string().min(1).max(64),\n payload: z.unknown().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"SignalRequest\",\n description: \"A browser signal: the view, the signal's name and an optional JSON payload.\",\n }) as z.ZodType<SignalRequest>;\n\n/** A document as the page loads it: its revision and fields. */\nexport interface DocumentSnapshot {\n /** The document's revision. */\n readonly revision: DocumentRevision;\n /** The draft's epoch (D103); 1 for artifact state. */\n readonly epoch: number;\n /** Every field by ID. */\n readonly fields: Readonly<Record<string, FieldState>>;\n}\n\n/** The Zod schema of the `DocumentSnapshot` type. */\nexport const DocumentSnapshot: z.ZodType<DocumentSnapshot> = z\n .object({\n revision: DocumentRevision,\n epoch: z.int().min(1),\n fields: z.record(z.string(), FieldState),\n })\n .register(wireRegistry, {\n id: \"DocumentSnapshot\",\n description: \"A document's revision, epoch and fields, as a page loads it.\",\n });\n\n/**\n * The first message of a browser event stream, and a poll's `snapshot`: where the page stands,\n * so it renders the canonical draft and state before applying events after `cursor`.\n */\nexport interface StreamSnapshot {\n /** Events after this cursor follow. */\n readonly cursor: string;\n /** Who the page acts as. */\n readonly viewer: Viewer;\n /** The viewer's draft. */\n readonly draft: DocumentSnapshot;\n /** The artifact's shared state. */\n readonly state: DocumentSnapshot;\n /** The submission that closed this draft, or this viewer's latest under `epochs`. */\n readonly submission?: SubmissionSummary;\n /**\n * The artifact's latest version when the snapshot was read (WP-07): a reader that missed its\n * `version.published` event (published between a frame ticket and the stream, or compacted)\n * still learns of it.\n */\n readonly latest?: VersionRef;\n}\n\n/** The Zod schema of the `StreamSnapshot` type. */\nexport const StreamSnapshot: z.ZodType<StreamSnapshot> = z\n .object({\n cursor: Cursor.schema,\n viewer: Viewer,\n draft: DocumentSnapshot,\n state: DocumentSnapshot,\n submission: SubmissionSummary.exactOptional(),\n latest: VersionRef.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"StreamSnapshot\",\n description: \"Where a page stands: cursor, viewer, draft, artifact state and its submission.\",\n });\n\n/** `GET …/events/poll`: the long-poll answer on the same cursor as the stream (D47). */\nexport interface PollResult {\n /** Where the next poll continues. */\n readonly cursor: string;\n /** The events for this page after the cursor asked for, in order. */\n readonly events: readonly EventRecord[];\n /** Present when the poll asked for none or its cursor was compacted away. */\n readonly snapshot?: StreamSnapshot;\n /**\n * Run and live updates for this view since its last poll (WP-08): lossy and never stored as\n * events, the long-poll's counterpart of the stream's `run` and `live` messages.\n */\n readonly ephemeral?: readonly EphemeralMessage[];\n}\n\n/** The Zod schema of the `PollResult` type. */\nexport const PollResult: z.ZodType<PollResult> = z\n .object({\n cursor: Cursor.schema,\n events: z.array(EventRecord).readonly(),\n snapshot: StreamSnapshot.exactOptional(),\n ephemeral: z.array(z.record(z.string(), z.unknown())).readonly().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"PollResult\",\n description: \"A long-poll answer: the cursor, the events after the asked one, and a snapshot.\",\n }) as unknown as z.ZodType<PollResult>;\n\n/**\n * `POST /a/{artifactId}/_mostra/ticket`'s answer on the shell origin: a single-use frame ticket,\n * the view it opens and what the shell needs to render the view's trusted controls (D104, D108).\n */\nexport interface FrameTicket extends ViewContext {\n /** The frame's entry URL, carrying the single-use ticket. */\n readonly src: string;\n /** The artifact's origin: the only origin the bridge accepts messages from. */\n readonly artifactOrigin: string;\n /** Whether this viewer follows the artifact's new versions (D63). */\n readonly follow: boolean;\n /** Whether the link opens this version only (D97 item 9): then the shell offers no newer one. */\n readonly pinned: boolean;\n /**\n * The version's server code keeps crashing and is parked (WP-08, FAILURE_MODEL §2): the shell\n * says so, since the page's actions and live data won't work until a new publish.\n */\n readonly serverParked?: true;\n /**\n * The frame shows `mostra dev`'s development preview of unpublished source (D140 item 12): the\n * shell says so, and it is never a published version.\n */\n readonly devPreview?: true;\n /**\n * `worker` when the shell and the artifact are two sites (a Cloudflare quick tunnel, a host's\n * addresses on two hosts): the frame enters through the bootstrap page and a service worker\n * (D70, D158 item 5). Absent: cookie mode.\n */\n readonly mode?: \"worker\";\n /**\n * The artifact is paused (D165 item 14): the shell says so, by whom and why (the reason as text);\n * it takes no submissions and runs no actions until it is resumed (WP-30).\n */\n readonly paused?: { readonly by: \"owner\" | \"operator\"; readonly reason?: string };\n /** On a remote server: what the hosted shell's trusted chrome shows around the page (D161). */\n readonly hosted?: HostedChrome;\n}\n\n/**\n * The hosted shell's trusted chrome for one view (D161, ARCHITECTURE §15.8; WP-30). Every string an\n * owner or operator supplies is rendered as text, never as markup.\n */\nexport interface HostedChrome {\n /** Who sent the page: the owner's display name, and the provider that verified it, if any. */\n readonly sender?: { readonly name: string; readonly verifiedBy?: string };\n /** Who this browser is to the page: signed in as an account, or anonymous (with a chosen name). */\n readonly viewer: {\n readonly kind: \"account\" | \"anonymous\" | \"named\";\n readonly name?: string;\n readonly verified: boolean;\n };\n /** Whether \"Sign in\" is offered (the viewer isn't signed in, and the server has a provider). */\n readonly signIn: boolean;\n /** The operator's footer wording in place of the shell's own; never hidden on a public link. */\n readonly footer?: string;\n /** The operator's line after \"Your answer was sent.\". */\n readonly afterSubmit?: string;\n /** The made-with mark, where the operator shows one. */\n readonly madeWith?: { readonly href?: string };\n /** A page shown before the artifact, once per browser and link. */\n readonly interstitial?: { readonly kind: string; readonly message?: string };\n}\n\nconst HostedChrome: z.ZodType<HostedChrome> = z.object({\n sender: z\n .object({ name: z.string().max(256), verifiedBy: z.string().max(64).exactOptional() })\n .exactOptional(),\n viewer: z.object({\n kind: z.enum([\"account\", \"anonymous\", \"named\"]),\n name: z.string().max(256).exactOptional(),\n verified: z.boolean(),\n }),\n signIn: z.boolean(),\n footer: z.string().max(500).exactOptional(),\n afterSubmit: z.string().max(500).exactOptional(),\n madeWith: z\n .object({\n href: z\n .url({ protocol: /^https$/ })\n .max(2_048)\n .exactOptional(),\n })\n .exactOptional(),\n interstitial: z\n .object({ kind: z.string().max(64), message: z.string().max(2_000).exactOptional() })\n .exactOptional(),\n});\n\n/** The Zod schema of the `FrameTicket` type. */\nexport const FrameTicket: z.ZodType<FrameTicket> = z\n .object({\n artifactId: ArtifactId.schema,\n viewId: ViewId.schema,\n version: VersionRef,\n latest: VersionRef,\n policy: SubmissionPolicy,\n submitChannels: z.array(SubmitChannel).min(1).max(2).readonly(),\n controls: z.array(TrustedControl).max(32).readonly(),\n target: z.enum([\"live\", \"static\", \"mcp-app\", \"verify\"]),\n src: z.string().min(1),\n artifactOrigin: z.string().min(1),\n follow: z.boolean(),\n pinned: z.boolean(),\n serverParked: z.literal(true).exactOptional(),\n devPreview: z.literal(true).exactOptional(),\n mode: z.literal(\"worker\").exactOptional(),\n paused: z\n .object({\n by: z.enum([\"owner\", \"operator\"]),\n reason: z.string().max(500).exactOptional(),\n })\n .exactOptional(),\n hosted: HostedChrome.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"FrameTicket\",\n description: \"A frame ticket: the view it opens, where to load it, and the view's controls.\",\n });\n\n// ── Frame sessions in worker mode (WP-13, D70, D158 item 5) ───────────────────────────────\n\n/**\n * The header Mostra's service worker adds to every same-origin request of a worker-mode frame:\n * its frame session's secret, which no cookie can carry across sites.\n */\nexport const FRAME_SESSION_HEADER = \"x-mostra-frame\";\n\n/**\n * The header a hosted shell sends its session's secret in (INTERFACES §18.4, D165 item 8): no\n * cookie is ever set or read on a hosted host, so no tenant page can toss, shadow or crowd one out.\n */\nexport const SHELL_SESSION_HEADER = \"x-mostra-shell\";\n\n/**\n * `POST /_mostra/enter` on the artifact's origin: the bootstrap page exchanges the shell's\n * single-use frame ticket, from `/_mostra/enter#t=…`, for a worker-mode frame session.\n */\nexport interface EnterRequest {\n /** The frame ticket. */\n readonly ticket: string;\n}\n\n/** The Zod schema of the `EnterRequest` type. */\nexport const EnterRequest: z.ZodType<EnterRequest> = z\n .object({ ticket: z.string().min(1).max(64) })\n .register(wireRegistry, { id: \"EnterRequest\", description: \"A frame ticket to exchange.\" });\n\n/** The answer to `EnterRequest`. */\nexport interface EnterResult {\n /** The frame session's secret, which the service worker sends as `X-Mostra-Frame`. */\n readonly session: string;\n /** The shell's origin: the only page the bootstrap reports to. */\n readonly shellOrigin: string;\n}\n\n/** The Zod schema of the `EnterResult` type. */\nexport const EnterResult: z.ZodType<EnterResult> = z\n .object({ session: z.string().min(1), shellOrigin: z.string().min(1) })\n .register(wireRegistry, {\n id: \"EnterResult\",\n description: \"A worker-mode frame session's secret and the shell's origin.\",\n });\n\n/**\n * `POST /_mostra/v/{rev}/ticket`: a single-use ticket that opens one event stream, long poll or\n * WebSocket of this session without it (`?ticket=`), so the request can bypass the service\n * worker (VERIFIED_FACTS: Firefox stalls on endless responses a worker passes on).\n */\nexport interface StreamTicketRequest {\n /** What it opens: `stream` (events and polls, the default) or `socket` (a WebSocket). */\n readonly purpose?: \"stream\" | \"socket\";\n}\n\n/** The Zod schema of the `StreamTicketRequest` type. */\nexport const StreamTicketRequest: z.ZodType<StreamTicketRequest> = z\n .object({ purpose: z.enum([\"stream\", \"socket\"]).exactOptional() })\n .register(wireRegistry, { id: \"StreamTicketRequest\" });\n\n/** The answer to a `StreamTicketRequest`. */\nexport interface StreamTicket {\n /** The ticket: 130 bits, single-use. */\n readonly ticket: string;\n /** When it stops working, 60 s after it was minted. */\n readonly expiresAt: string;\n}\n\n/** The Zod schema of the `StreamTicket` type. */\nexport const StreamTicket: z.ZodType<StreamTicket> = z\n .object({ ticket: z.string().min(1), expiresAt: z.iso.datetime() })\n .register(wireRegistry, {\n id: \"StreamTicket\",\n description: \"A single-use ticket for one stream, poll or WebSocket.\",\n });\n\n/**\n * `GET /_mostra/session` on the artifact's origin: the frame session's facts for same-origin code.\n */\nexport interface FrameSessionFacts {\n /** The CSRF token every mutation sends as `X-Mostra-CSRF`. */\n readonly csrf: string;\n /** The artifact the frame shows. */\n readonly artifactId: string;\n /** The shell's exact origin: the bridge's only peer. */\n readonly shellOrigin: string;\n /** The link's scopes. */\n readonly scopes: readonly string[];\n /** The viewer the page acts as (WP-07). */\n readonly viewer?: Viewer;\n /** The version the frame session entered. */\n readonly version?: VersionRef;\n /** How the frame authenticates (D70): absent means `cookie`. */\n readonly mode?: \"cookie\" | \"worker\";\n /**\n * `false` where event streams don't pass (a Cloudflare quick tunnel holds responses back until\n * they end): the page long-polls from the start (D47). Absent means streams pass.\n */\n readonly streams?: boolean;\n}\n\n/** The Zod schema of the `FrameSessionFacts` type. */\nexport const FrameSessionFacts: z.ZodType<FrameSessionFacts> = z\n .object({\n csrf: z.string().min(1),\n artifactId: ArtifactId.schema,\n shellOrigin: z.string().min(1),\n scopes: z.array(z.string()).readonly(),\n viewer: Viewer.exactOptional(),\n version: VersionRef.exactOptional(),\n mode: z.enum([\"cookie\", \"worker\"]).exactOptional(),\n streams: z.boolean().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"FrameSessionFacts\",\n description: \"A frame session's CSRF token, shell origin, scopes, viewer, version and mode.\",\n });\n\n// ── The shell's own routes (WP-07, on the shell origin) ──────────────────────────────────\n\n/**\n * `POST /a/{artifactId}/_mostra/v/{rev}/submit`: the shell's trusted Submit (the `shell` channel,\n * D40). Only the shell's page can send it: the route takes the shell's session, its exact origin\n * and its CSRF token, none of which an artifact's page has.\n */\nexport interface ShellSubmitRequest {\n /** The view the shell's frame shows (D104); its version is what the submission names. */\n readonly viewId: string;\n /** The draft revision the viewer saw, after the frame flushed its saves. */\n readonly expectedRevision: DocumentRevision;\n}\n\n/** The Zod schema of the `ShellSubmitRequest` type. */\nexport const ShellSubmitRequest: z.ZodType<ShellSubmitRequest> = z\n .object({ viewId: ViewId.schema, expectedRevision: DocumentRevision })\n .register(wireRegistry, {\n id: \"ShellSubmitRequest\",\n description: \"The shell's trusted Submit: the view and the draft revision the viewer saw.\",\n });\n\n/**\n * `POST /a/{artifactId}/_mostra/v/{rev}/review/choose`: the shell's trusted Choose (D65, D113).\n * It writes the viewer's draft field `review.<reviewSetId>.choice` like any mutation, so a stale\n * base revision comes back as a conflict.\n */\nexport interface ChooseRequest {\n /** The view the shell's frame shows. */\n readonly viewId: string;\n /** A fresh `mut_` ID; a retry repeats it. */\n readonly mutationId: string;\n /** The draft revision the shell last saw. */\n readonly baseRevision: DocumentRevision;\n /** The review set. */\n readonly reviewSetId: string;\n /** The chosen candidate's ID. */\n readonly candidateId: string;\n /** The candidate's label, kept with the choice for results. */\n readonly label?: string;\n}\n\n/** The Zod schema of the `ChooseRequest` type. */\nexport const ChooseRequest: z.ZodType<ChooseRequest> = z\n .object({\n viewId: ViewId.schema,\n mutationId: MutationId.schema,\n baseRevision: DocumentRevision,\n reviewSetId: z.string().regex(REVIEW_SET_ID_PATTERN),\n candidateId: z.string().min(1).max(256),\n label: z.string().max(256).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ChooseRequest\",\n description:\n \"The shell's trusted Choose: the view, mutation, base revision, set and candidate.\",\n });\n\n/** `POST /a/{artifactId}/_mostra/v/{rev}/follow`: the viewer's \"Always follow this artifact\" (D63). */\nexport interface FollowRequest {\n /** `true` to load new versions automatically, `false` to stop. */\n readonly follow: boolean;\n}\n\n/** The Zod schema of the `FollowRequest` type. */\nexport const FollowRequest: z.ZodType<FollowRequest> = z\n .object({ follow: z.boolean() })\n .register(wireRegistry, {\n id: \"FollowRequest\",\n description: \"Whether the viewer follows the artifact's new versions.\",\n });\n\n/** A draft field a version doesn't cover (D42, D109): kept, shown read-only and delivered. */\nexport interface OrphanedField {\n /** The field's ID. */\n readonly id: string;\n /** Its label, when it has one. */\n readonly label?: string;\n /** Its value. */\n readonly value: unknown;\n /** The version whose view last wrote it. */\n readonly fromVersion: number;\n}\n\n/** The Zod schema of the `OrphanedField` type. */\nexport const OrphanedField: z.ZodType<OrphanedField> = z\n .object({\n id: z.string(),\n label: z.string().exactOptional(),\n value: z.unknown(),\n fromVersion: z.int().min(1),\n })\n .register(wireRegistry, {\n id: \"OrphanedField\",\n description: \"A draft field a version doesn't cover: its ID, label, value and source version.\",\n }) as z.ZodType<OrphanedField>;\n\n/**\n * `GET /a/{artifactId}/_mostra/v/{rev}/carry?version=<number>`: which of the viewer's answers a\n * version doesn't carry over (D42, D109). The banner counts them before a switch; the \"Not\n * carried over\" panel lists them for the version shown.\n */\nexport interface CarryOver {\n /** The version asked about. */\n readonly version: VersionRef;\n /** The viewer's draft fields the version doesn't cover. */\n readonly orphans: readonly OrphanedField[];\n}\n\n/** The Zod schema of the `CarryOver` type. */\nexport const CarryOver: z.ZodType<CarryOver> = z\n .object({ version: VersionRef, orphans: z.array(OrphanedField).readonly() })\n .register(wireRegistry, {\n id: \"CarryOver\",\n description: \"The viewer's answers a version doesn't carry over.\",\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0CA,MAAa,6BAAsD,CAAC,YAAY;;AAGhF,MAAa,4BAA4B;;AAGzC,MAAa,2BAAmC;;AAiBhD,MAAa,gBAA0C,EACpD,OAAO;CACN,YAAY,WAAW;CACvB,OAAO,EAAE,KAAK,CAAC,UAAU,UAAU,CAAC;CACpC,cAAc;CACd,QAAQ,OAAO;CACf,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAI,CAAC,CAAC,SAAS;AAClD,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAaH,MAAa,gBAA0C,EACpD,OAAO;CACN,QAAQ,OAAO;CACf,kBAAkB;CAClB,SAAS,EAAE,QAAQ,UAAU;AAC/B,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAaH,MAAa,gBAA0C,EACpD,OAAO;CACN,QAAQ,OAAO;CACf,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;CAC9B,SAAS,EAAE,QAAQ,CAAC,CAAC,cAAc;AACrC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAaH,MAAa,mBAAgD,EAC1D,OAAO;CACN,UAAU;CACV,OAAO,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;CACpB,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,UAAU;AACzC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AA0BH,MAAa,iBAA4C,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,WAAW;CACvB,cAAc;CACd,aAAa,EAAE,OAAO,CAAC,CAAC,MAAM,qBAAqB;CACnD,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;CACtC,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,cAAc;AAC3C,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC;;AASH,MAAa,gBAA0C,EACpD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,CAC/B,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAeH,MAAa,gBAA0C,EACpD,OAAO;CACN,IAAI,EAAE,OAAO;CACb,OAAO,EAAE,OAAO,CAAC,CAAC,cAAc;CAChC,OAAO,EAAE,QAAQ;CACjB,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;AAC5B,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAeH,MAAa,YAAkC,EAC5C,OAAO;CAAE,SAAS;CAAY,SAAS,EAAE,MAAM,aAAa,CAAC,CAAC,SAAS;AAAE,CAAC,CAAC,CAC3E,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC"}
@@ -15,15 +15,6 @@ export type CapabilityScope = "view" | "draft" | "submit" | "review" | "signal"
15
15
  export declare const CapabilityScope: z.ZodType<CapabilityScope>;
16
16
  /** Every scope at once: what a link minted without `scopes`, and every default link, carries. */
17
17
  export declare const ALL_SCOPES: readonly CapabilityScope[];
18
- /**
19
- * A duration: a positive whole number and a unit, `s`, `m`, `h` or `d` (`30m`, `24h`, `7d`), as
20
- * INTERFACES §1 writes durations in flags and manifests.
21
- */
22
- export type Duration = `${number}${"s" | "m" | "h" | "d"}`;
23
- /** The Zod schema of the `Duration` type. */
24
- export declare const Duration: z.ZodType<Duration>;
25
- /** The length of a `Duration` in milliseconds. */
26
- export declare function durationMs(duration: Duration): number;
27
18
  /**
28
19
  * The scopes a token holds after normalization: `view` added, duplicates removed, sorted, so equal
29
20
  * grants compare equal.
@@ -1 +1 @@
1
- {"version":3,"file":"capability.d.ts","names":[],"sources":["../src/capability.ts"],"mappings":";;;;;;;;;;;;YAkBY;;qBASC,iBAAiB,EAAE,QAAQ;;qBAU3B,qBAAqB;;;;;YAatB;;qBAGC,UAAU,EAAE,QAAQ;;wBAWjB,WAAW,UAAU;;;;;wBASrB,gBAAgB,iBAAiB,oBAAoB;;;;;wBAQrD,YACd,iBAAiB,mBACjB,UAAU"}
1
+ {"version":3,"file":"capability.d.ts","names":[],"sources":["../src/capability.ts"],"mappings":";;;;;;;;;;;;YAkBY;;qBASC,iBAAiB,EAAE,QAAQ;;qBAU3B,qBAAqB;;;;;wBAalB,gBAAgB,iBAAiB,oBAAoB;;;;;wBAQrD,YACd,iBAAiB,mBACjB,UAAU"}