@mostra/protocol 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/dist/actions.d.ts +30 -4
  2. package/dist/actions.d.ts.map +1 -1
  3. package/dist/actions.js +14 -4
  4. package/dist/actions.js.map +1 -1
  5. package/dist/artifact.d.ts +2 -1
  6. package/dist/artifact.d.ts.map +1 -1
  7. package/dist/artifact.js +2 -1
  8. package/dist/artifact.js.map +1 -1
  9. package/dist/browser.d.ts +5 -0
  10. package/dist/browser.d.ts.map +1 -1
  11. package/dist/browser.js +7 -2
  12. package/dist/browser.js.map +1 -1
  13. package/dist/capability.d.ts +0 -9
  14. package/dist/capability.d.ts.map +1 -1
  15. package/dist/capability.js +1 -17
  16. package/dist/capability.js.map +1 -1
  17. package/dist/diagnostics/codes/artifact.d.ts +1 -1
  18. package/dist/diagnostics/codes/artifact.d.ts.map +1 -1
  19. package/dist/diagnostics/codes/artifact.js +12 -1
  20. package/dist/diagnostics/codes/artifact.js.map +1 -1
  21. package/dist/diagnostics/codes/home.d.ts +1 -1
  22. package/dist/diagnostics/codes/home.d.ts.map +1 -1
  23. package/dist/diagnostics/codes/home.js +12 -1
  24. package/dist/diagnostics/codes/home.js.map +1 -1
  25. package/dist/diagnostics/codes/index.d.ts +3 -2
  26. package/dist/diagnostics/codes/index.d.ts.map +1 -1
  27. package/dist/diagnostics/codes/index.js +3 -1
  28. package/dist/diagnostics/codes/index.js.map +1 -1
  29. package/dist/diagnostics/codes/remote.d.ts +8 -0
  30. package/dist/diagnostics/codes/remote.d.ts.map +1 -0
  31. package/dist/diagnostics/codes/remote.js +99 -0
  32. package/dist/diagnostics/codes/remote.js.map +1 -0
  33. package/dist/diagnostics/diagnostic.d.ts +1 -1
  34. package/dist/diagnostics/diagnostic.d.ts.map +1 -1
  35. package/dist/diagnostics/diagnostic.js +2 -1
  36. package/dist/diagnostics/diagnostic.js.map +1 -1
  37. package/dist/duration.d.ts +13 -0
  38. package/dist/duration.d.ts.map +1 -0
  39. package/dist/duration.js +27 -0
  40. package/dist/duration.js.map +1 -0
  41. package/dist/ids.d.ts +17 -1
  42. package/dist/ids.d.ts.map +1 -1
  43. package/dist/ids.js +9 -1
  44. package/dist/ids.js.map +1 -1
  45. package/dist/index.d.ts +30 -8
  46. package/dist/index.js +30 -8
  47. package/dist/interaction.d.ts +28 -2
  48. package/dist/interaction.d.ts.map +1 -1
  49. package/dist/interaction.js +20 -5
  50. package/dist/interaction.js.map +1 -1
  51. package/dist/manifest.d.ts +59 -14
  52. package/dist/manifest.d.ts.map +1 -1
  53. package/dist/manifest.js +63 -15
  54. package/dist/manifest.js.map +1 -1
  55. package/dist/methods/artifact/export.d.ts +40 -0
  56. package/dist/methods/artifact/export.d.ts.map +1 -0
  57. package/dist/methods/artifact/export.js +36 -0
  58. package/dist/methods/artifact/export.js.map +1 -0
  59. package/dist/methods/artifact/import.d.ts +23 -0
  60. package/dist/methods/artifact/import.d.ts.map +1 -0
  61. package/dist/methods/artifact/import.js +25 -0
  62. package/dist/methods/artifact/import.js.map +1 -0
  63. package/dist/methods/artifact/publish.d.ts +2 -1
  64. package/dist/methods/artifact/publish.d.ts.map +1 -1
  65. package/dist/methods/artifact/publish.js +1 -1
  66. package/dist/methods/hosted/push.d.ts +76 -0
  67. package/dist/methods/hosted/push.d.ts.map +1 -0
  68. package/dist/methods/hosted/push.js +71 -0
  69. package/dist/methods/hosted/push.js.map +1 -0
  70. package/dist/methods/hosted/submission.d.ts +18 -0
  71. package/dist/methods/hosted/submission.d.ts.map +1 -0
  72. package/dist/methods/hosted/submission.js +23 -0
  73. package/dist/methods/hosted/submission.js.map +1 -0
  74. package/dist/methods/index.d.ts.map +1 -1
  75. package/dist/methods/index.js +38 -2
  76. package/dist/methods/index.js.map +1 -1
  77. package/dist/methods/instance/status.d.ts +3 -0
  78. package/dist/methods/instance/status.d.ts.map +1 -1
  79. package/dist/methods/instance/status.js +3 -1
  80. package/dist/methods/instance/status.js.map +1 -1
  81. package/dist/methods/mostra/initialize.d.ts +17 -3
  82. package/dist/methods/mostra/initialize.d.ts.map +1 -1
  83. package/dist/methods/mostra/initialize.js +11 -3
  84. package/dist/methods/mostra/initialize.js.map +1 -1
  85. package/dist/methods/port/relay-call.d.ts +33 -0
  86. package/dist/methods/port/relay-call.d.ts.map +1 -0
  87. package/dist/methods/port/relay-call.js +31 -0
  88. package/dist/methods/port/relay-call.js.map +1 -0
  89. package/dist/methods/port/relay-cancel.d.ts +16 -0
  90. package/dist/methods/port/relay-cancel.d.ts.map +1 -0
  91. package/dist/methods/port/relay-cancel.js +21 -0
  92. package/dist/methods/port/relay-cancel.js.map +1 -0
  93. package/dist/methods/port/relay-live.d.ts +25 -0
  94. package/dist/methods/port/relay-live.d.ts.map +1 -0
  95. package/dist/methods/port/relay-live.js +32 -0
  96. package/dist/methods/port/relay-live.js.map +1 -0
  97. package/dist/methods/port/relay-reconcile.d.ts +39 -0
  98. package/dist/methods/port/relay-reconcile.d.ts.map +1 -0
  99. package/dist/methods/port/relay-reconcile.js +35 -0
  100. package/dist/methods/port/relay-reconcile.js.map +1 -0
  101. package/dist/methods/port/relay-run.d.ts +47 -0
  102. package/dist/methods/port/relay-run.d.ts.map +1 -0
  103. package/dist/methods/port/relay-run.js +41 -0
  104. package/dist/methods/port/relay-run.js.map +1 -0
  105. package/dist/methods/port/submissions-deliver.d.ts +8 -0
  106. package/dist/methods/port/submissions-deliver.d.ts.map +1 -1
  107. package/dist/methods/port/submissions-deliver.js +4 -2
  108. package/dist/methods/port/submissions-deliver.js.map +1 -1
  109. package/dist/methods/relay/call-batch.d.ts +26 -0
  110. package/dist/methods/relay/call-batch.d.ts.map +1 -0
  111. package/dist/methods/relay/call-batch.js +30 -0
  112. package/dist/methods/relay/call-batch.js.map +1 -0
  113. package/dist/methods/relay/effect.d.ts +31 -0
  114. package/dist/methods/relay/effect.d.ts.map +1 -0
  115. package/dist/methods/relay/effect.js +30 -0
  116. package/dist/methods/relay/effect.js.map +1 -0
  117. package/dist/methods/relay/live-value.d.ts +33 -0
  118. package/dist/methods/relay/live-value.d.ts.map +1 -0
  119. package/dist/methods/relay/live-value.js +32 -0
  120. package/dist/methods/relay/live-value.js.map +1 -0
  121. package/dist/methods/relay/run-update.d.ts +46 -0
  122. package/dist/methods/relay/run-update.d.ts.map +1 -0
  123. package/dist/methods/relay/run-update.js +45 -0
  124. package/dist/methods/relay/run-update.js.map +1 -0
  125. package/dist/methods/remote/login-wait.d.ts +30 -0
  126. package/dist/methods/remote/login-wait.d.ts.map +1 -0
  127. package/dist/methods/remote/login-wait.js +36 -0
  128. package/dist/methods/remote/login-wait.js.map +1 -0
  129. package/dist/methods/remote/login.d.ts +41 -0
  130. package/dist/methods/remote/login.d.ts.map +1 -0
  131. package/dist/methods/remote/login.js +37 -0
  132. package/dist/methods/remote/login.js.map +1 -0
  133. package/dist/methods/remote/logout.d.ts +25 -0
  134. package/dist/methods/remote/logout.d.ts.map +1 -0
  135. package/dist/methods/remote/logout.js +28 -0
  136. package/dist/methods/remote/logout.js.map +1 -0
  137. package/dist/methods/remote/status.d.ts +14 -0
  138. package/dist/methods/remote/status.d.ts.map +1 -0
  139. package/dist/methods/remote/status.js +22 -0
  140. package/dist/methods/remote/status.js.map +1 -0
  141. package/dist/methods/remote/token.d.ts +19 -0
  142. package/dist/methods/remote/token.d.ts.map +1 -0
  143. package/dist/methods/remote/token.js +24 -0
  144. package/dist/methods/remote/token.js.map +1 -0
  145. package/dist/methods/share/start.d.ts +5 -2
  146. package/dist/methods/share/start.d.ts.map +1 -1
  147. package/dist/methods/share/start.js +6 -3
  148. package/dist/methods/share/start.js.map +1 -1
  149. package/dist/methods/state/patch.d.ts +7 -0
  150. package/dist/methods/state/patch.d.ts.map +1 -1
  151. package/dist/methods/state/patch.js +2 -1
  152. package/dist/methods/state/patch.js.map +1 -1
  153. package/dist/methods/view/url.d.ts +2 -1
  154. package/dist/methods/view/url.d.ts.map +1 -1
  155. package/dist/methods/view/url.js +2 -1
  156. package/dist/methods/view/url.js.map +1 -1
  157. package/dist/policy.d.ts +18 -0
  158. package/dist/policy.d.ts.map +1 -0
  159. package/dist/policy.js +23 -0
  160. package/dist/policy.js.map +1 -0
  161. package/dist/remote.d.ts +55 -0
  162. package/dist/remote.d.ts.map +1 -0
  163. package/dist/remote.js +52 -0
  164. package/dist/remote.js.map +1 -0
  165. package/dist/view.d.ts +1 -1
  166. package/dist/view.js +1 -1
  167. package/dist/view.js.map +1 -1
  168. package/package.json +2 -2
  169. package/schemas/protocol.draft-07.json +1607 -126
  170. package/schemas/protocol.schema.json +1543 -126
  171. package/src/actions.ts +45 -5
  172. package/src/browser.ts +6 -0
  173. package/src/capability.ts +0 -23
  174. package/src/diagnostics/codes/artifact.ts +12 -0
  175. package/src/diagnostics/codes/home.ts +12 -0
  176. package/src/diagnostics/codes/index.ts +6 -2
  177. package/src/diagnostics/codes/remote.ts +113 -0
  178. package/src/diagnostics/diagnostic.ts +3 -1
  179. package/src/duration.ts +29 -0
  180. package/src/ids.ts +33 -1
  181. package/src/index.ts +124 -8
  182. package/src/interaction.ts +42 -2
  183. package/src/manifest.ts +115 -24
  184. package/src/methods/artifact/export.ts +68 -0
  185. package/src/methods/artifact/import.ts +39 -0
  186. package/src/methods/hosted/push.ts +146 -0
  187. package/src/methods/hosted/submission.ts +34 -0
  188. package/src/methods/index.ts +36 -0
  189. package/src/methods/instance/status.ts +4 -0
  190. package/src/methods/mostra/initialize.ts +19 -3
  191. package/src/methods/port/relay-call.ts +58 -0
  192. package/src/methods/port/relay-cancel.ts +33 -0
  193. package/src/methods/port/relay-live.ts +48 -0
  194. package/src/methods/port/relay-reconcile.ts +71 -0
  195. package/src/methods/port/relay-run.ts +80 -0
  196. package/src/methods/port/submissions-deliver.ts +13 -1
  197. package/src/methods/relay/call-batch.ts +52 -0
  198. package/src/methods/relay/effect.ts +55 -0
  199. package/src/methods/relay/live-value.ts +54 -0
  200. package/src/methods/relay/run-update.ts +81 -0
  201. package/src/methods/remote/login-wait.ts +55 -0
  202. package/src/methods/remote/login.ts +72 -0
  203. package/src/methods/remote/logout.ts +42 -0
  204. package/src/methods/remote/status.ts +34 -0
  205. package/src/methods/remote/token.ts +39 -0
  206. package/src/methods/share/start.ts +12 -4
  207. package/src/methods/state/patch.ts +6 -0
  208. package/src/methods/view/url.ts +2 -1
  209. package/src/policy.ts +30 -0
  210. package/src/remote.ts +89 -0
  211. package/src/view.ts +1 -1
package/src/index.ts CHANGED
@@ -22,6 +22,7 @@ export {
22
22
  LiveRequest,
23
23
  type LiveState,
24
24
  type LiveUpdate,
25
+ READABLE_LIVE_KEY_PATTERN,
25
26
  RUN_KEY_MAX,
26
27
  RUN_LOG_MAX,
27
28
  RUN_LOG_TRUNCATED,
@@ -36,6 +37,8 @@ export {
36
37
  type RunStatus,
37
38
  SECRET_NAME_PATTERN,
38
39
  SECRET_VALUE_MAX,
40
+ TALLY_LIVE_PREFIX,
41
+ type TallyValue,
39
42
  } from "./actions.ts";
40
43
  export {
41
44
  ArtifactDetail,
@@ -106,6 +109,7 @@ export {
106
109
  PollResult,
107
110
  REVIEW_SET_ID_PATTERN,
108
111
  readViewContext,
112
+ SHELL_SESSION_HEADER,
109
113
  ShellSubmitRequest,
110
114
  SIGNAL_PAYLOAD_MAX_BYTES,
111
115
  SignalRequest,
@@ -135,14 +139,7 @@ export {
135
139
  isWindowsBundle,
136
140
  } from "./bundle.ts";
137
141
  export { canonicalJson } from "./canonical.ts";
138
- export {
139
- ALL_SCOPES,
140
- CapabilityScope,
141
- Duration,
142
- durationMs,
143
- normalizeScopes,
144
- scopeAllows,
145
- } from "./capability.ts";
142
+ export { ALL_SCOPES, CapabilityScope, normalizeScopes, scopeAllows } from "./capability.ts";
146
143
  export {
147
144
  type A11yDiagnosticCode,
148
145
  type ActionDiagnosticCode,
@@ -183,8 +180,10 @@ export {
183
180
  platformDiagnosticCodes,
184
181
  publishDiagnosticCodes,
185
182
  type RegressionDiagnosticCode,
183
+ type RemoteDiagnosticCode,
186
184
  type RuntimeDiagnosticCode,
187
185
  regressionDiagnosticCodes,
186
+ remoteDiagnosticCodes,
188
187
  runtimeDiagnosticCodes,
189
188
  type SecretDiagnosticCode,
190
189
  type ShareDiagnosticCode,
@@ -219,6 +218,7 @@ export {
219
218
  type DiagnosticSpec,
220
219
  docsUrl,
221
220
  } from "./diagnostics/spec.ts";
221
+ export { Duration, durationMs } from "./duration.ts";
222
222
  export {
223
223
  CSRF_HEADER,
224
224
  checkRequest,
@@ -233,16 +233,20 @@ export {
233
233
  safePath,
234
234
  } from "./hygiene.ts";
235
235
  export {
236
+ AccountId,
236
237
  ArtifactId,
237
238
  CommentId,
238
239
  Cursor,
239
240
  DeliveryId,
240
241
  type GeneratedIdKind,
242
+ HomeId,
241
243
  type Id,
242
244
  type IdBody,
243
245
  type IdKind,
244
246
  type IdPrefix,
247
+ LinkId,
245
248
  MutationId,
249
+ RouteId,
246
250
  RunId,
247
251
  ShareId,
248
252
  SubmissionId,
@@ -260,6 +264,7 @@ export {
260
264
  DeliveryStatus,
261
265
  DocumentRevision,
262
266
  EventFilter,
267
+ EventOrigin,
263
268
  EventRecord,
264
269
  EventTypePattern,
265
270
  FIELD_ID_MAX_LENGTH,
@@ -288,7 +293,14 @@ export {
288
293
  ArtifactLink,
289
294
  ArtifactManifest,
290
295
  type DemoSpec,
296
+ HOSTED_OFFLINE_LIMIT_DEFAULT,
297
+ HOSTED_OFFLINE_LIMIT_MAX_MS,
298
+ HostedSettings,
299
+ manifestProblem,
291
300
  SubmissionPolicy,
301
+ TALLY_CHOICES_MAX,
302
+ TALLY_CHOICES_MIN,
303
+ TallySpec,
292
304
  type TerminalSpec,
293
305
  } from "./manifest.ts";
294
306
  export {
@@ -304,11 +316,22 @@ export {
304
316
  type ArtifactCreateResult,
305
317
  artifactCreateMethod,
306
318
  } from "./methods/artifact/create.ts";
319
+ export {
320
+ type ArtifactExportParams,
321
+ type ArtifactExportResult,
322
+ artifactExportMethod,
323
+ ExportClass,
324
+ } from "./methods/artifact/export.ts";
307
325
  export {
308
326
  type ArtifactGetParams,
309
327
  type ArtifactGetResult,
310
328
  artifactGetMethod,
311
329
  } from "./methods/artifact/get.ts";
330
+ export {
331
+ type ArtifactImportParams,
332
+ type ArtifactImportResult,
333
+ artifactImportMethod,
334
+ } from "./methods/artifact/import.ts";
312
335
  export {
313
336
  type ArtifactListFilter,
314
337
  type ArtifactListParams,
@@ -372,6 +395,19 @@ export {
372
395
  type GcVersion,
373
396
  gcRunMethod,
374
397
  } from "./methods/gc/run.ts";
398
+ export {
399
+ type HostedPushParams,
400
+ type HostedPushResult,
401
+ HostedRoute,
402
+ hostedPushMethod,
403
+ type ListingEntry,
404
+ VersionPush,
405
+ } from "./methods/hosted/push.ts";
406
+ export {
407
+ type HostedSubmissionParams,
408
+ type HostedSubmissionResult,
409
+ hostedSubmissionMethod,
410
+ } from "./methods/hosted/submission.ts";
375
411
  export { hostMethods, hostNotifications } from "./methods/index.ts";
376
412
  export {
377
413
  type InstanceCheck,
@@ -426,6 +462,34 @@ export {
426
462
  type PortIdentityResolveResult,
427
463
  portIdentityResolveMethod,
428
464
  } from "./methods/port/identity-resolve.ts";
465
+ export {
466
+ type PortRelayCallParams,
467
+ type PortRelayCallResult,
468
+ portRelayCallMethod,
469
+ } from "./methods/port/relay-call.ts";
470
+ export {
471
+ type PortRelayCancelParams,
472
+ type PortRelayCancelResult,
473
+ portRelayCancelMethod,
474
+ } from "./methods/port/relay-cancel.ts";
475
+ export {
476
+ type PortRelayLiveParams,
477
+ type PortRelayLiveResult,
478
+ portRelayLiveMethod,
479
+ } from "./methods/port/relay-live.ts";
480
+ export {
481
+ type PortRelayReconcileParams,
482
+ type PortRelayReconcileResult,
483
+ portRelayReconcileMethod,
484
+ type RelayHeld,
485
+ type RelayReconciled,
486
+ } from "./methods/port/relay-reconcile.ts";
487
+ export {
488
+ type PortRelayRunParams,
489
+ type PortRelayRunResult,
490
+ portRelayRunMethod,
491
+ RelayViewer,
492
+ } from "./methods/port/relay-run.ts";
429
493
  export {
430
494
  type PortSecretsGetParams,
431
495
  type PortSecretsGetResult,
@@ -446,6 +510,52 @@ export {
446
510
  type PortTrustedControlsPolicyResult,
447
511
  portTrustedControlsPolicyMethod,
448
512
  } from "./methods/port/trusted-controls-policy.ts";
513
+ export {
514
+ type RelayCallBatchParams,
515
+ type RelayCallBatchResult,
516
+ relayCallBatchMethod,
517
+ } from "./methods/relay/call-batch.ts";
518
+ export {
519
+ type RelayEffectParams,
520
+ type RelayEffectResult,
521
+ relayEffectMethod,
522
+ } from "./methods/relay/effect.ts";
523
+ export {
524
+ type RelayLiveValueParams,
525
+ type RelayLiveValueResult,
526
+ relayLiveValueMethod,
527
+ } from "./methods/relay/live-value.ts";
528
+ export {
529
+ type RelayRunEnd,
530
+ type RelayRunUpdateParams,
531
+ type RelayRunUpdateResult,
532
+ relayRunUpdateMethod,
533
+ } from "./methods/relay/run-update.ts";
534
+ export {
535
+ type RemoteLoginParams,
536
+ type RemoteLoginResult,
537
+ remoteLoginMethod,
538
+ } from "./methods/remote/login.ts";
539
+ export {
540
+ type RemoteLoginWaitParams,
541
+ type RemoteLoginWaitResult,
542
+ remoteLoginWaitMethod,
543
+ } from "./methods/remote/login-wait.ts";
544
+ export {
545
+ type RemoteLogoutParams,
546
+ type RemoteLogoutResult,
547
+ remoteLogoutMethod,
548
+ } from "./methods/remote/logout.ts";
549
+ export {
550
+ type RemoteStatusParams,
551
+ type RemoteStatusResult,
552
+ remoteStatusMethod,
553
+ } from "./methods/remote/status.ts";
554
+ export {
555
+ type RemoteTokenParams,
556
+ type RemoteTokenResult,
557
+ remoteTokenMethod,
558
+ } from "./methods/remote/token.ts";
449
559
  export {
450
560
  type ResultsGetParams,
451
561
  type ResultsGetResult,
@@ -526,6 +636,12 @@ export {
526
636
  waitMethod,
527
637
  } from "./methods/wait/wait.ts";
528
638
  export { receivable } from "./receive.ts";
639
+ export {
640
+ OwnerLinkInfo,
641
+ RemoteLink,
642
+ type RemoteLinkState,
643
+ ServerOrigin,
644
+ } from "./remote.ts";
529
645
  export {
530
646
  HOST_PROTOCOL_REVISIONS,
531
647
  negotiateRevision,
@@ -23,7 +23,11 @@ export { ControlsPolicy, SubmitChannel, TrustedControl } from "./view.ts";
23
23
  // ── Viewers and actors ────────────────────────────────────────────────────────────────────
24
24
 
25
25
  /** How Mostra knows a viewer (DATA_MODEL §3 `viewer.kind`). */
26
- export type ViewerKind = "local" | "tailnet" | "token" | "host";
26
+ /**
27
+ * How Mostra knows a viewer: `account` and `anonymous` are hosted links' (a signed-in person, and
28
+ * one per browser who isn't signed in, D165 item 8).
29
+ */
30
+ export type ViewerKind = "local" | "tailnet" | "token" | "host" | "account" | "anonymous";
27
31
 
28
32
  /**
29
33
  * A person who views an artifact (PRODUCT vocabulary). The home's local user is one viewer of kind
@@ -44,7 +48,7 @@ export interface Viewer {
44
48
  export const Viewer: z.ZodType<Viewer> = z
45
49
  .object({
46
50
  id: ViewerId.schema,
47
- kind: z.enum(["local", "tailnet", "token", "host"]),
51
+ kind: z.enum(["local", "tailnet", "token", "host", "account", "anonymous"]),
48
52
  name: z.string().exactOptional(),
49
53
  ref: z.string().exactOptional(),
50
54
  })
@@ -263,6 +267,36 @@ export const MutationResult: z.ZodType<MutationResult> = z
263
267
 
264
268
  // ── Events ────────────────────────────────────────────────────────────────────────────────
265
269
 
270
+ /**
271
+ * Where an owner instance's copy of a hosted record came from (INTERFACES §18.2, D165 item 1): the
272
+ * server, the hosted home, its incarnation and the record's cursor there (a submission's is the
273
+ * cursor of its `submission.created`).
274
+ */
275
+ export interface EventOrigin {
276
+ /** The server's API origin. */
277
+ readonly server: string;
278
+ /** The hosted home's `hom_` ID. */
279
+ readonly home: string;
280
+ /** The hosted home's incarnation when the record was copied. */
281
+ readonly incarnation: string;
282
+ /** The record's cursor in the hosted home. */
283
+ readonly cursor: Cursor;
284
+ }
285
+
286
+ /** The Zod schema of the `EventOrigin` type. */
287
+ export const EventOrigin: z.ZodType<EventOrigin> = z
288
+ .object({
289
+ server: z.string().min(1),
290
+ home: z.string().min(1),
291
+ incarnation: z.string().min(1),
292
+ cursor: Cursor.schema,
293
+ })
294
+ .register(wireRegistry, {
295
+ id: "EventOrigin",
296
+ description:
297
+ "Where an owner's copy of a hosted record came from: server, home, incarnation, cursor.",
298
+ }) as z.ZodType<EventOrigin>;
299
+
266
300
  /**
267
301
  * One durable event (DATA_MODEL §4). Its cursor is its stable ID and its place in the home-wide
268
302
  * order; `seq` orders an artifact's own events without gaps.
@@ -284,6 +318,8 @@ export interface EventRecord {
284
318
  readonly causation?: Readonly<Record<string, string>>;
285
319
  /** The event's data; sensitive field values are redacted (D52). */
286
320
  readonly payload: Readonly<Record<string, unknown>>;
321
+ /** For an event an owner instance copied from its hosted home: where it came from. */
322
+ readonly origin?: EventOrigin;
287
323
  }
288
324
 
289
325
  /** The Zod schema of the `EventRecord` type. */
@@ -297,6 +333,7 @@ export const EventRecord: z.ZodType<EventRecord> = z
297
333
  actor: Actor,
298
334
  causation: z.record(z.string(), z.string()).exactOptional(),
299
335
  payload: z.record(z.string(), z.unknown()),
336
+ origin: EventOrigin.exactOptional(),
300
337
  })
301
338
  .register(wireRegistry, {
302
339
  id: "EventRecord",
@@ -553,6 +590,8 @@ export interface Results {
553
590
  readonly digest: string;
554
591
  readonly delivery: DeliveryState;
555
592
  readonly deliveries: readonly DeliveryStatus[];
593
+ /** For a submission imported from a hosted home: where it came from (D165 item 1). */
594
+ readonly origin?: EventOrigin;
556
595
  };
557
596
  /** The draft's fields by ID, dotted IDs nested (D52). */
558
597
  readonly answers: Readonly<Record<string, unknown>>;
@@ -669,6 +708,7 @@ export const Results: z.ZodType<Results> = z
669
708
  digest: z.string().regex(/^[0-9a-f]{64}$/),
670
709
  delivery: z.enum(["pending", "delivered", "rejected", "undeliverable"]),
671
710
  deliveries: z.array(DeliveryStatus).readonly(),
711
+ origin: EventOrigin.exactOptional(),
672
712
  }),
673
713
  answers: z.record(z.string(), z.unknown()),
674
714
  fields: z
package/src/manifest.ts CHANGED
@@ -9,6 +9,11 @@
9
9
  * ```
10
10
  */
11
11
  import * as z from "zod";
12
+ import { Duration, durationMs } from "./duration.ts";
13
+ import { SubmissionPolicy } from "./policy.ts";
14
+
15
+ export { SubmissionPolicy };
16
+
12
17
  import { ArtifactId } from "./ids.ts";
13
18
  import { wireRegistry } from "./wire-registry.ts";
14
19
 
@@ -33,15 +38,6 @@ export interface ArtifactLink {
33
38
  readonly artifact: string;
34
39
  }
35
40
 
36
- /**
37
- * The submission policy an artifact requests (D10, D39, D63). The host decides the policy in force;
38
- * the manifest only asks for one.
39
- */
40
- export type SubmissionPolicy =
41
- | { readonly policy: "once"; readonly scope?: "per-artifact" | "per-viewer" }
42
- | { readonly policy: "epochs" }
43
- | { readonly policy: "none" };
44
-
45
41
  /** A live terminal session the artifact declares (ROUND-3 §5.1, D65). */
46
42
  export interface TerminalSpec {
47
43
  /** The program and its arguments. */
@@ -68,6 +64,47 @@ export type DemoSpec =
68
64
  }
69
65
  | { readonly attach: number; readonly bridge?: boolean };
70
66
 
67
+ /**
68
+ * A count by choice the artifact opts into (D165 item 12, RM-07): every accepted submission adds
69
+ * one to the choice its viewer-scoped `field` holds, counted in the submit transaction, and viewers
70
+ * read the counts with `useLive("$tally/<field>")`. A value outside `choices`, or none, counts
71
+ * nothing, so free text is never shown.
72
+ */
73
+ export interface TallySpec {
74
+ /** The viewer-scoped field whose value is counted. */
75
+ readonly field: string;
76
+ /** The values counted: 2 to 50 distinct strings. */
77
+ readonly choices: readonly string[];
78
+ /** Below this many answers (default 0), viewers see only the total, never the counts. */
79
+ readonly minTotal?: number;
80
+ }
81
+
82
+ /** How the artifact behaves on a remote server (D165, INTERFACES §18). */
83
+ export interface HostedSettings {
84
+ /**
85
+ * Relayed action runs while the owner instance is away (D165 item 4): `queue` (the default)
86
+ * waits up to `limit` (default `24h`, at most `7d`), `fail` ends a run at once.
87
+ */
88
+ readonly offline?: { readonly actions?: "queue" | "fail"; readonly limit?: Duration };
89
+ /** Who may trigger relayed actions (D159): `signed-in` (the default) or anyone with the `link`. */
90
+ readonly actions?: "signed-in" | "link";
91
+ /** Who may submit (D165 item 13): anyone with the `link` (the default), or `signed-in` viewers. */
92
+ readonly submissions?: "link" | "signed-in";
93
+ /** Link previews (D161): `generic` (the default) or the artifact's `title`. */
94
+ readonly preview?: "generic" | "title";
95
+ }
96
+
97
+ /** The longest offline limit a hosted artifact may set: 7 days (D165 item 4). */
98
+ export const HOSTED_OFFLINE_LIMIT_MAX_MS: number = 7 * 24 * 60 * 60 * 1000;
99
+
100
+ /** The offline limit of a hosted artifact that sets none: 24 hours (D165 item 4). */
101
+ export const HOSTED_OFFLINE_LIMIT_DEFAULT: Duration = "24h";
102
+
103
+ /** The fewest and most choices a tally counts (INTERFACES §18.4). */
104
+ export const TALLY_CHOICES_MIN = 2;
105
+ /** The most choices a tally counts. */
106
+ export const TALLY_CHOICES_MAX = 50;
107
+
71
108
  /** The artifact manifest (INTERFACES §2.2). Every field except `title` is optional. */
72
109
  export interface ArtifactManifest {
73
110
  /** The artifact's ID. Written by `mostra new`; without one, the artifact is bound to its source path at first publish (D51). */
@@ -103,6 +140,10 @@ export interface ArtifactManifest {
103
140
  readonly extraChecks?: readonly string[];
104
141
  readonly smoke?: boolean;
105
142
  };
143
+ /** Counts by choice of fixed-choice fields (D165 item 12). */
144
+ readonly tally?: readonly TallySpec[];
145
+ /** How the artifact behaves on a remote server (D165). */
146
+ readonly hosted?: HostedSettings;
106
147
  }
107
148
 
108
149
  /** The keys of the artifact manifest, in INTERFACES §2.2 order. Other keys are warnings (FAILURE_MODEL §10). */
@@ -119,6 +160,8 @@ export const ARTIFACT_MANIFEST_KEYS: readonly (keyof ArtifactManifest)[] = [
119
160
  "demos",
120
161
  "limits",
121
162
  "verify",
163
+ "tally",
164
+ "hosted",
122
165
  ];
123
166
 
124
167
  const strings = z.array(z.string()).readonly();
@@ -131,21 +174,6 @@ export const ArtifactLink: z.ZodType<ArtifactLink> = z
131
174
  description: "A related artifact: how this one relates (rel) and the other artifact's ID.",
132
175
  });
133
176
 
134
- /** The Zod schema of the `SubmissionPolicy` type. */
135
- export const SubmissionPolicy: z.ZodType<SubmissionPolicy> = z
136
- .discriminatedUnion("policy", [
137
- z.object({
138
- policy: z.literal("once"),
139
- scope: z.enum(["per-artifact", "per-viewer"]).exactOptional(),
140
- }),
141
- z.object({ policy: z.literal("epochs") }),
142
- z.object({ policy: z.literal("none") }),
143
- ])
144
- .register(wireRegistry, {
145
- id: "SubmissionPolicy",
146
- description: "A submission policy: once (per-artifact or per-viewer), epochs, or none.",
147
- });
148
-
149
177
  const TerminalSpec: z.ZodType<TerminalSpec> = z.object({
150
178
  command: z.array(z.string()).min(1).readonly(),
151
179
  cwd: z.string().exactOptional(),
@@ -165,6 +193,42 @@ const DemoSpec: z.ZodType<DemoSpec> = z.union([
165
193
  z.object({ attach: z.int().min(1).max(65535), bridge: z.boolean().exactOptional() }),
166
194
  ]);
167
195
 
196
+ /** The Zod schema of the `TallySpec` type. */
197
+ export const TallySpec: z.ZodType<TallySpec> = z
198
+ .object({
199
+ field: z.string().min(1).max(256),
200
+ choices: z
201
+ .array(z.string().min(1).max(256))
202
+ .min(TALLY_CHOICES_MIN)
203
+ .max(TALLY_CHOICES_MAX)
204
+ .readonly(),
205
+ minTotal: z.int().min(0).exactOptional(),
206
+ })
207
+ .register(wireRegistry, {
208
+ id: "TallySpec",
209
+ description:
210
+ "A count by choice of a viewer-scoped field: its field, 2 to 50 distinct choices and minTotal.",
211
+ });
212
+
213
+ /** The Zod schema of the `HostedSettings` type. */
214
+ export const HostedSettings: z.ZodType<HostedSettings> = z
215
+ .object({
216
+ offline: z
217
+ .object({
218
+ actions: z.enum(["queue", "fail"]).exactOptional(),
219
+ limit: Duration.exactOptional(),
220
+ })
221
+ .exactOptional(),
222
+ actions: z.enum(["signed-in", "link"]).exactOptional(),
223
+ submissions: z.enum(["link", "signed-in"]).exactOptional(),
224
+ preview: z.enum(["generic", "title"]).exactOptional(),
225
+ })
226
+ .register(wireRegistry, {
227
+ id: "HostedSettings",
228
+ description:
229
+ "How an artifact behaves on a remote server: offline actions, who may act and submit, previews.",
230
+ });
231
+
168
232
  /** The Zod schema of the `ArtifactManifest` type. Objects stay open, so newer keys pass through. */
169
233
  export const ArtifactManifest: z.ZodType<ArtifactManifest> = z
170
234
  .object({
@@ -198,9 +262,36 @@ export const ArtifactManifest: z.ZodType<ArtifactManifest> = z
198
262
  smoke: z.boolean().exactOptional(),
199
263
  })
200
264
  .exactOptional(),
265
+ tally: z.array(TallySpec).readonly().exactOptional(),
266
+ hosted: HostedSettings.exactOptional(),
201
267
  })
202
268
  .register(wireRegistry, {
203
269
  id: "ArtifactManifest",
204
270
  description:
205
271
  "The artifact manifest (INTERFACES §2.2): literal metadata from the entry's defineArtifact call or MDX frontmatter.",
206
272
  });
273
+
274
+ /**
275
+ * The rules of a manifest that JSON Schema can't state, checked after its schema by everything
276
+ * that reads a manifest (D165 items 4, 12): a tally's choices are distinct, each field is tallied
277
+ * once, and an offline limit is at most 7 days. Answers the first problem, with its field's path.
278
+ */
279
+ export function manifestProblem(
280
+ manifest: ArtifactManifest,
281
+ ): { readonly path: string; readonly message: string } | undefined {
282
+ const fields = new Set<string>();
283
+ for (const [index, tally] of (manifest.tally ?? []).entries()) {
284
+ if (new Set(tally.choices).size !== tally.choices.length) {
285
+ return { path: `tally.${index}.choices`, message: "a tally's choices must be distinct" };
286
+ }
287
+ if (fields.has(tally.field)) {
288
+ return { path: `tally.${index}.field`, message: `\`${tally.field}\` is tallied twice` };
289
+ }
290
+ fields.add(tally.field);
291
+ }
292
+ const limit = manifest.hosted?.offline?.limit;
293
+ if (limit !== undefined && durationMs(limit) > HOSTED_OFFLINE_LIMIT_MAX_MS) {
294
+ return { path: "hosted.offline.limit", message: "an offline limit is at most 7d" };
295
+ }
296
+ return undefined;
297
+ }
@@ -0,0 +1,68 @@
1
+ import * as z from "zod";
2
+ import { ArtifactRef } from "../../artifact.ts";
3
+ import { defineMethod, type MethodDefinition } from "../../method.ts";
4
+ import { wireRegistry } from "../../wire-registry.ts";
5
+
6
+ /**
7
+ * An export class (ARCHITECTURE §3, VR-07). `bundle` is the portable artifact package (RM-01,
8
+ * WP-29); WP-24 adds `static`, `html` and `snapshot`, and WP-17 `mcp-app`, additively.
9
+ */
10
+ export type ExportClass = "bundle";
11
+
12
+ /** The Zod schema of the `ExportClass` type. */
13
+ export const ExportClass: z.ZodType<ExportClass> = z
14
+ .enum(["bundle"])
15
+ .register(wireRegistry, { id: "ExportClass", description: "An export class (VR-07)." });
16
+
17
+ /** The params of `artifact/export` (INTERFACES §6, §15). */
18
+ export interface ArtifactExportParams {
19
+ /** The artifact: its ID, or a source path it was published from. */
20
+ readonly artifact: ArtifactRef;
21
+ /** The version: a number or a version ID; the latest when absent. */
22
+ readonly version?: number | string;
23
+ /** What to write. */
24
+ readonly as: ExportClass;
25
+ /**
26
+ * Where: an absolute path. A bundle is a directory there, or one archive when the path ends in
27
+ * `.tar.zst`. It must not exist yet, or be an empty directory.
28
+ */
29
+ readonly out: string;
30
+ }
31
+
32
+ /** The result of `artifact/export`. */
33
+ export interface ArtifactExportResult {
34
+ /** What it wrote, as absolute paths: the bundle's directory or archive. */
35
+ readonly files: readonly string[];
36
+ /** The version exported. */
37
+ readonly versionId: string;
38
+ }
39
+
40
+ const params: z.ZodType<ArtifactExportParams> = z
41
+ .object({
42
+ artifact: ArtifactRef,
43
+ version: z.union([z.int().min(1), z.string().min(1)]).exactOptional(),
44
+ as: ExportClass,
45
+ out: z.string().min(1),
46
+ })
47
+ .register(wireRegistry, { id: "ArtifactExportParams" });
48
+
49
+ const result: z.ZodType<ArtifactExportResult> = z
50
+ .object({
51
+ files: z.array(z.string()).readonly(),
52
+ versionId: z.string(),
53
+ })
54
+ .register(wireRegistry, { id: "ArtifactExportResult" });
55
+
56
+ /**
57
+ * `artifact/export`: writes a published version out of the home. A `bundle` carries the version's
58
+ * builds, manifest, lockfile and source snapshot, so `artifact/import` (`mostra run <bundle>`) in
59
+ * another home makes it the same version, with the same artifact and version IDs (RM-01).
60
+ */
61
+ export const artifactExportMethod: MethodDefinition<ArtifactExportParams, ArtifactExportResult> =
62
+ defineMethod({
63
+ method: "artifact/export",
64
+ direction: "client-to-instance",
65
+ mutating: false,
66
+ params,
67
+ result,
68
+ });
@@ -0,0 +1,39 @@
1
+ import * as z from "zod";
2
+ import { PublishReceipt } from "../../artifact.ts";
3
+ import { defineMethod, type MethodDefinition } from "../../method.ts";
4
+ import { wireRegistry } from "../../wire-registry.ts";
5
+
6
+ /** The params of `artifact/import` (INTERFACES §15). */
7
+ export interface ArtifactImportParams {
8
+ /** A bundle `artifact/export` wrote: its directory or its `.tar.zst` archive, as an absolute path. */
9
+ readonly bundle: string;
10
+ /** Makes retries idempotent: a repeated `requestId` returns the recorded result (H-03). */
11
+ readonly requestId?: string;
12
+ }
13
+
14
+ /**
15
+ * The result of `artifact/import`: the receipt of the version it made, or found (`reused`), with
16
+ * the bundle's artifact and version IDs.
17
+ */
18
+ export type ArtifactImportResult = PublishReceipt;
19
+
20
+ const params: z.ZodType<ArtifactImportParams> = z
21
+ .object({
22
+ bundle: z.string().min(1),
23
+ requestId: z.string().min(1).exactOptional(),
24
+ })
25
+ .register(wireRegistry, { id: "ArtifactImportParams" });
26
+
27
+ /**
28
+ * `artifact/import`: makes a portable bundle a published version of this home (RM-01; the CLI's
29
+ * `mostra run <bundle>`): the same artifact ID, version ID and digests, checked against the
30
+ * bundle's files before anything is kept. Its server code runs here, against the bundle's lockfile.
31
+ */
32
+ export const artifactImportMethod: MethodDefinition<ArtifactImportParams, ArtifactImportResult> =
33
+ defineMethod({
34
+ method: "artifact/import",
35
+ direction: "client-to-instance",
36
+ mutating: true,
37
+ params,
38
+ result: PublishReceipt,
39
+ });