@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
@@ -1,3 +1,5 @@
1
+ import { Duration } from "./duration.js";
2
+ import { SubmissionPolicy } from "./policy.js";
1
3
  import * as z from "zod";
2
4
  //#region src/manifest.d.ts
3
5
  /** The families Mostra's templates and gallery know; any other string is allowed too. */
@@ -9,18 +11,6 @@ export interface ArtifactLink {
9
11
  /** The other artifact's ID. */
10
12
  readonly artifact: string;
11
13
  }
12
- /**
13
- * The submission policy an artifact requests (D10, D39, D63). The host decides the policy in force;
14
- * the manifest only asks for one.
15
- */
16
- export type SubmissionPolicy = {
17
- readonly policy: "once";
18
- readonly scope?: "per-artifact" | "per-viewer";
19
- } | {
20
- readonly policy: "epochs";
21
- } | {
22
- readonly policy: "none";
23
- };
24
14
  /** A live terminal session the artifact declares (ROUND-3 §5.1, D65). */
25
15
  export interface TerminalSpec {
26
16
  /** The program and its arguments. */
@@ -46,6 +36,45 @@ export type DemoSpec = {
46
36
  readonly attach: number;
47
37
  readonly bridge?: boolean;
48
38
  };
39
+ /**
40
+ * A count by choice the artifact opts into (D165 item 12, RM-07): every accepted submission adds
41
+ * one to the choice its viewer-scoped `field` holds, counted in the submit transaction, and viewers
42
+ * read the counts with `useLive("$tally/<field>")`. A value outside `choices`, or none, counts
43
+ * nothing, so free text is never shown.
44
+ */
45
+ export interface TallySpec {
46
+ /** The viewer-scoped field whose value is counted. */
47
+ readonly field: string;
48
+ /** The values counted: 2 to 50 distinct strings. */
49
+ readonly choices: readonly string[];
50
+ /** Below this many answers (default 0), viewers see only the total, never the counts. */
51
+ readonly minTotal?: number;
52
+ }
53
+ /** How the artifact behaves on a remote server (D165, INTERFACES §18). */
54
+ export interface HostedSettings {
55
+ /**
56
+ * Relayed action runs while the owner instance is away (D165 item 4): `queue` (the default)
57
+ * waits up to `limit` (default `24h`, at most `7d`), `fail` ends a run at once.
58
+ */
59
+ readonly offline?: {
60
+ readonly actions?: "queue" | "fail";
61
+ readonly limit?: Duration;
62
+ };
63
+ /** Who may trigger relayed actions (D159): `signed-in` (the default) or anyone with the `link`. */
64
+ readonly actions?: "signed-in" | "link";
65
+ /** Who may submit (D165 item 13): anyone with the `link` (the default), or `signed-in` viewers. */
66
+ readonly submissions?: "link" | "signed-in";
67
+ /** Link previews (D161): `generic` (the default) or the artifact's `title`. */
68
+ readonly preview?: "generic" | "title";
69
+ }
70
+ /** The longest offline limit a hosted artifact may set: 7 days (D165 item 4). */
71
+ export declare const HOSTED_OFFLINE_LIMIT_MAX_MS: number;
72
+ /** The offline limit of a hosted artifact that sets none: 24 hours (D165 item 4). */
73
+ export declare const HOSTED_OFFLINE_LIMIT_DEFAULT: Duration;
74
+ /** The fewest and most choices a tally counts (INTERFACES §18.4). */
75
+ export declare const TALLY_CHOICES_MIN = 2;
76
+ /** The most choices a tally counts. */
77
+ export declare const TALLY_CHOICES_MAX = 50;
49
78
  /** The artifact manifest (INTERFACES §2.2). Every field except `title` is optional. */
50
79
  export interface ArtifactManifest {
51
80
  /** The artifact's ID. Written by `mostra new`; without one, the artifact is bound to its source path at first publish (D51). */
@@ -84,14 +113,30 @@ export interface ArtifactManifest {
84
113
  readonly extraChecks?: readonly string[];
85
114
  readonly smoke?: boolean;
86
115
  };
116
+ /** Counts by choice of fixed-choice fields (D165 item 12). */
117
+ readonly tally?: readonly TallySpec[];
118
+ /** How the artifact behaves on a remote server (D165). */
119
+ readonly hosted?: HostedSettings;
87
120
  }
88
121
  /** The keys of the artifact manifest, in INTERFACES §2.2 order. Other keys are warnings (FAILURE_MODEL §10). */
89
122
  export declare const ARTIFACT_MANIFEST_KEYS: readonly (keyof ArtifactManifest)[];
90
123
  /** The Zod schema of the `ArtifactLink` type. */
91
124
  export declare const ArtifactLink: z.ZodType<ArtifactLink>;
92
- /** The Zod schema of the `SubmissionPolicy` type. */
93
- export declare const SubmissionPolicy: z.ZodType<SubmissionPolicy>;
125
+ /** The Zod schema of the `TallySpec` type. */
126
+ export declare const TallySpec: z.ZodType<TallySpec>;
127
+ /** The Zod schema of the `HostedSettings` type. */
128
+ export declare const HostedSettings: z.ZodType<HostedSettings>;
94
129
  /** The Zod schema of the `ArtifactManifest` type. Objects stay open, so newer keys pass through. */
95
130
  export declare const ArtifactManifest: z.ZodType<ArtifactManifest>;
131
+ /**
132
+ * The rules of a manifest that JSON Schema can't state, checked after its schema by everything
133
+ * that reads a manifest (D165 items 4, 12): a tally's choices are distinct, each field is tallied
134
+ * once, and an offline limit is at most 7 days. Answers the first problem, with its field's path.
135
+ */
136
+ export declare function manifestProblem(manifest: ArtifactManifest): {
137
+ readonly path: string;
138
+ readonly message: string;
139
+ } | undefined;
96
140
  //#endregion
141
+ export { SubmissionPolicy };
97
142
  //# sourceMappingURL=manifest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.d.ts","names":[],"sources":["../src/manifest.ts"],"mappings":";;;YAeY;;iBAaK;;WAEN;;WAEA;;;;;;YAOC;WACG;WAAyB;;WACzB;;WACA;;;iBAGE;;WAEN;;WAEA;;WAEA,MAAM,SAAS;;WAEf;;WAEA;;WAEA;;;YAIC;WAEG;WACA;WACA;WACA;;WAEA;WAAyB;;;iBAGvB;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;WAET,iBAAiB;;WAEjB;;WAEA,aAAa;;WAEb;aAAiB;aAAkC;;;WAEnD,YAAY,SAAS,eAAe;;WAEpC,QAAQ,SAAS,eAAe;;WAEhC;aACE;aACA;aACA;;;WAGF;aACE;aACA;aACA;aACA;;;;qBAKA,wCAAwC;;qBAkBxC,cAAc,EAAE,QAAQ;;qBAQxB,kBAAkB,EAAE,QAAQ;;qBAkC5B,kBAAkB,EAAE,QAAQ"}
1
+ {"version":3,"file":"manifest.d.ts","names":[],"sources":["../src/manifest.ts"],"mappings":";;;;;YAoBY;;iBAaK;;WAEN;;WAEA;;;iBAIM;;WAEN;;WAEA;;WAEA,MAAM,SAAS;;WAEf;;WAEA;;WAEA;;;YAIC;WAEG;WACA;WACA;WACA;;WAEA;WAAyB;;;;;;;;iBAQvB;;WAEN;;WAEA;;WAEA;;;iBAIM;;;;;WAKN;aAAqB;aAAqC,QAAQ;;;WAElE;;WAEA;;WAEA;;;qBAIE;;qBAGA,8BAA8B;;qBAG9B;;qBAEA;;iBAGI;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;WAET,iBAAiB;;WAEjB;;WAEA,aAAa;;WAEb;aAAiB;aAAkC;;;WAEnD,YAAY,SAAS,eAAe;;WAEpC,QAAQ,SAAS,eAAe;;WAEhC;aACE;aACA;aACA;;;WAGF;aACE;aACA;aACA;aACA;;;WAGF,iBAAiB;;WAEjB,SAAS;;;qBAIP,wCAAwC;;qBAoBxC,cAAc,EAAE,QAAQ;;qBA2BxB,WAAW,EAAE,QAAQ;;qBAiBrB,gBAAgB,EAAE,QAAQ;;qBAmB1B,kBAAkB,EAAE,QAAQ;;;;;;wBA8CzB,gBACd,UAAU;WACE;WAAuB"}
package/dist/manifest.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { wireRegistry } from "./wire-registry.js";
2
2
  import { ArtifactId } from "./ids.js";
3
+ import { Duration, durationMs } from "./duration.js";
4
+ import { SubmissionPolicy } from "./policy.js";
3
5
  import * as z from "zod";
4
6
  //#region src/manifest.ts
5
7
  /**
@@ -12,6 +14,14 @@ import * as z from "zod";
12
14
  * const checked = ArtifactManifest.safeParse(extracted);
13
15
  * ```
14
16
  */
17
+ /** The longest offline limit a hosted artifact may set: 7 days (D165 item 4). */
18
+ const HOSTED_OFFLINE_LIMIT_MAX_MS = 6048e5;
19
+ /** The offline limit of a hosted artifact that sets none: 24 hours (D165 item 4). */
20
+ const HOSTED_OFFLINE_LIMIT_DEFAULT = "24h";
21
+ /** The fewest and most choices a tally counts (INTERFACES §18.4). */
22
+ const TALLY_CHOICES_MIN = 2;
23
+ /** The most choices a tally counts. */
24
+ const TALLY_CHOICES_MAX = 50;
15
25
  /** The keys of the artifact manifest, in INTERFACES §2.2 order. Other keys are warnings (FAILURE_MODEL §10). */
16
26
  const ARTIFACT_MANIFEST_KEYS = [
17
27
  "id",
@@ -25,7 +35,9 @@ const ARTIFACT_MANIFEST_KEYS = [
25
35
  "terminals",
26
36
  "demos",
27
37
  "limits",
28
- "verify"
38
+ "verify",
39
+ "tally",
40
+ "hosted"
29
41
  ];
30
42
  const strings = z.array(z.string()).readonly();
31
43
  /** The Zod schema of the `ArtifactLink` type. */
@@ -36,18 +48,6 @@ const ArtifactLink = z.object({
36
48
  id: "ArtifactLink",
37
49
  description: "A related artifact: how this one relates (rel) and the other artifact's ID."
38
50
  });
39
- /** The Zod schema of the `SubmissionPolicy` type. */
40
- const SubmissionPolicy = z.discriminatedUnion("policy", [
41
- z.object({
42
- policy: z.literal("once"),
43
- scope: z.enum(["per-artifact", "per-viewer"]).exactOptional()
44
- }),
45
- z.object({ policy: z.literal("epochs") }),
46
- z.object({ policy: z.literal("none") })
47
- ]).register(wireRegistry, {
48
- id: "SubmissionPolicy",
49
- description: "A submission policy: once (per-artifact or per-viewer), epochs, or none."
50
- });
51
51
  const TerminalSpec = z.object({
52
52
  command: z.array(z.string()).min(1).readonly(),
53
53
  cwd: z.string().exactOptional(),
@@ -65,6 +65,28 @@ const DemoSpec = z.union([z.object({
65
65
  attach: z.int().min(1).max(65535),
66
66
  bridge: z.boolean().exactOptional()
67
67
  })]);
68
+ /** The Zod schema of the `TallySpec` type. */
69
+ const TallySpec = z.object({
70
+ field: z.string().min(1).max(256),
71
+ choices: z.array(z.string().min(1).max(256)).min(2).max(50).readonly(),
72
+ minTotal: z.int().min(0).exactOptional()
73
+ }).register(wireRegistry, {
74
+ id: "TallySpec",
75
+ description: "A count by choice of a viewer-scoped field: its field, 2 to 50 distinct choices and minTotal."
76
+ });
77
+ /** The Zod schema of the `HostedSettings` type. */
78
+ const HostedSettings = z.object({
79
+ offline: z.object({
80
+ actions: z.enum(["queue", "fail"]).exactOptional(),
81
+ limit: Duration.exactOptional()
82
+ }).exactOptional(),
83
+ actions: z.enum(["signed-in", "link"]).exactOptional(),
84
+ submissions: z.enum(["link", "signed-in"]).exactOptional(),
85
+ preview: z.enum(["generic", "title"]).exactOptional()
86
+ }).register(wireRegistry, {
87
+ id: "HostedSettings",
88
+ description: "How an artifact behaves on a remote server: offline actions, who may act and submit, previews."
89
+ });
68
90
  /** The Zod schema of the `ArtifactManifest` type. Objects stay open, so newer keys pass through. */
69
91
  const ArtifactManifest = z.object({
70
92
  id: ArtifactId.schema.exactOptional(),
@@ -90,12 +112,38 @@ const ArtifactManifest = z.object({
90
112
  frames: strings.exactOptional(),
91
113
  extraChecks: strings.exactOptional(),
92
114
  smoke: z.boolean().exactOptional()
93
- }).exactOptional()
115
+ }).exactOptional(),
116
+ tally: z.array(TallySpec).readonly().exactOptional(),
117
+ hosted: HostedSettings.exactOptional()
94
118
  }).register(wireRegistry, {
95
119
  id: "ArtifactManifest",
96
120
  description: "The artifact manifest (INTERFACES §2.2): literal metadata from the entry's defineArtifact call or MDX frontmatter."
97
121
  });
122
+ /**
123
+ * The rules of a manifest that JSON Schema can't state, checked after its schema by everything
124
+ * that reads a manifest (D165 items 4, 12): a tally's choices are distinct, each field is tallied
125
+ * once, and an offline limit is at most 7 days. Answers the first problem, with its field's path.
126
+ */
127
+ function manifestProblem(manifest) {
128
+ const fields = /* @__PURE__ */ new Set();
129
+ for (const [index, tally] of (manifest.tally ?? []).entries()) {
130
+ if (new Set(tally.choices).size !== tally.choices.length) return {
131
+ path: `tally.${index}.choices`,
132
+ message: "a tally's choices must be distinct"
133
+ };
134
+ if (fields.has(tally.field)) return {
135
+ path: `tally.${index}.field`,
136
+ message: `\`${tally.field}\` is tallied twice`
137
+ };
138
+ fields.add(tally.field);
139
+ }
140
+ const limit = manifest.hosted?.offline?.limit;
141
+ if (limit !== void 0 && durationMs(limit) > 6048e5) return {
142
+ path: "hosted.offline.limit",
143
+ message: "an offline limit is at most 7d"
144
+ };
145
+ }
98
146
  //#endregion
99
- export { ARTIFACT_MANIFEST_KEYS, ArtifactLink, ArtifactManifest, SubmissionPolicy };
147
+ export { ARTIFACT_MANIFEST_KEYS, ArtifactLink, ArtifactManifest, HOSTED_OFFLINE_LIMIT_DEFAULT, HOSTED_OFFLINE_LIMIT_MAX_MS, HostedSettings, SubmissionPolicy, TALLY_CHOICES_MAX, TALLY_CHOICES_MIN, TallySpec, manifestProblem };
100
148
 
101
149
  //# sourceMappingURL=manifest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.js","names":[],"sources":["../src/manifest.ts"],"sourcesContent":["/**\n * The artifact manifest (INTERFACES §2.2, D51): the metadata an artifact declares in its entry, as\n * `export const artifact = defineArtifact({...})` in TSX or as YAML frontmatter in MDX. Mostra reads\n * it statically, so every value is a literal. The same type checks `defineArtifact` for authors,\n * validates the extracted literal in the supervisor and travels on the wire in `artifact/get`.\n *\n * ```ts\n * const checked = ArtifactManifest.safeParse(extracted);\n * ```\n */\nimport * as z from \"zod\";\nimport { ArtifactId } from \"./ids.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** The families Mostra's templates and gallery know; any other string is allowed too. */\nexport type ArtifactFamily =\n | \"questionnaire\"\n | \"proposal\"\n | \"prototype\"\n | \"review\"\n | \"dashboard\"\n | \"deck\"\n | \"demo\"\n | \"inbox\"\n | \"tasks\"\n | (string & {});\n\n/** A related artifact (PRODUCT J6): a later round, a follow-up, a replacement. */\nexport interface ArtifactLink {\n /** How this artifact relates to the other one. */\n readonly rel: \"round-of\" | \"follows\" | \"replaces\" | (string & {});\n /** The other artifact's ID. */\n readonly artifact: string;\n}\n\n/**\n * The submission policy an artifact requests (D10, D39, D63). The host decides the policy in force;\n * the manifest only asks for one.\n */\nexport type SubmissionPolicy =\n | { readonly policy: \"once\"; readonly scope?: \"per-artifact\" | \"per-viewer\" }\n | { readonly policy: \"epochs\" }\n | { readonly policy: \"none\" };\n\n/** A live terminal session the artifact declares (ROUND-3 §5.1, D65). */\nexport interface TerminalSpec {\n /** The program and its arguments. */\n readonly command: readonly string[];\n /** Its working directory, relative to the artifact's source. */\n readonly cwd?: string;\n /** Extra environment variables. */\n readonly env?: Readonly<Record<string, string>>;\n /** The terminal's width in cells. */\n readonly cols?: number;\n /** The terminal's height in cells. */\n readonly rows?: number;\n /** Whether viewers may type into it. Sessions are read-only by default. */\n readonly input?: boolean;\n}\n\n/** A web demo the artifact declares (ROUND-3 §5.4, TM-08): a command to run, or a port to attach to. */\nexport type DemoSpec =\n | {\n readonly command: readonly string[];\n readonly cwd?: string;\n readonly ready?: string;\n readonly bridge?: boolean;\n }\n | { readonly attach: number; readonly bridge?: boolean };\n\n/** The artifact manifest (INTERFACES §2.2). Every field except `title` is optional. */\nexport interface ArtifactManifest {\n /** The artifact's ID. Written by `mostra new`; without one, the artifact is bound to its source path at first publish (D51). */\n readonly id?: string;\n /** The title people see. */\n readonly title: string;\n /** One or two sentences on what the artifact is for. */\n readonly description?: string;\n /** What kind of artifact it is; templates and the gallery group by it. */\n readonly family?: ArtifactFamily;\n /** Related artifacts. */\n readonly links?: readonly ArtifactLink[];\n /** How the artifact is built and served: `spa`, the default and the only mode in v1 (D19). */\n readonly mode?: \"spa\";\n /** The submission policy the artifact requests; the host decides (D39, D63). */\n readonly submission?: SubmissionPolicy;\n /** The kit's shadcn base (default `base`, D72) and theme. */\n readonly kit?: { readonly base?: \"base\" | \"radix\"; readonly theme?: string };\n /** Live terminal sessions by name (D65). */\n readonly terminals?: Readonly<Record<string, TerminalSpec>>;\n /** Web demos by name (D65). */\n readonly demos?: Readonly<Record<string, DemoSpec>>;\n /** Stability limits for the artifact's worker (D62). */\n readonly limits?: {\n readonly heapMb?: number;\n readonly watchdogMs?: number;\n readonly idleMinutes?: number;\n };\n /** `verify` settings (D65). */\n readonly verify?: {\n readonly viewports?: readonly string[];\n readonly frames?: readonly string[];\n readonly extraChecks?: readonly string[];\n readonly smoke?: boolean;\n };\n}\n\n/** The keys of the artifact manifest, in INTERFACES §2.2 order. Other keys are warnings (FAILURE_MODEL §10). */\nexport const ARTIFACT_MANIFEST_KEYS: readonly (keyof ArtifactManifest)[] = [\n \"id\",\n \"title\",\n \"description\",\n \"family\",\n \"links\",\n \"mode\",\n \"submission\",\n \"kit\",\n \"terminals\",\n \"demos\",\n \"limits\",\n \"verify\",\n];\n\nconst strings = z.array(z.string()).readonly();\n\n/** The Zod schema of the `ArtifactLink` type. */\nexport const ArtifactLink: z.ZodType<ArtifactLink> = z\n .object({ rel: z.string().min(1), artifact: z.string().min(1) })\n .register(wireRegistry, {\n id: \"ArtifactLink\",\n description: \"A related artifact: how this one relates (rel) and the other artifact's ID.\",\n });\n\n/** The Zod schema of the `SubmissionPolicy` type. */\nexport const SubmissionPolicy: z.ZodType<SubmissionPolicy> = z\n .discriminatedUnion(\"policy\", [\n z.object({\n policy: z.literal(\"once\"),\n scope: z.enum([\"per-artifact\", \"per-viewer\"]).exactOptional(),\n }),\n z.object({ policy: z.literal(\"epochs\") }),\n z.object({ policy: z.literal(\"none\") }),\n ])\n .register(wireRegistry, {\n id: \"SubmissionPolicy\",\n description: \"A submission policy: once (per-artifact or per-viewer), epochs, or none.\",\n });\n\nconst TerminalSpec: z.ZodType<TerminalSpec> = z.object({\n command: z.array(z.string()).min(1).readonly(),\n cwd: z.string().exactOptional(),\n env: z.record(z.string(), z.string()).readonly().exactOptional(),\n cols: z.int().min(1).exactOptional(),\n rows: z.int().min(1).exactOptional(),\n input: z.boolean().exactOptional(),\n});\n\nconst DemoSpec: z.ZodType<DemoSpec> = z.union([\n z.object({\n command: z.array(z.string()).min(1).readonly(),\n cwd: z.string().exactOptional(),\n ready: z.string().exactOptional(),\n bridge: z.boolean().exactOptional(),\n }),\n z.object({ attach: z.int().min(1).max(65535), bridge: z.boolean().exactOptional() }),\n]);\n\n/** The Zod schema of the `ArtifactManifest` type. Objects stay open, so newer keys pass through. */\nexport const ArtifactManifest: z.ZodType<ArtifactManifest> = z\n .object({\n id: ArtifactId.schema.exactOptional(),\n title: z.string().min(1),\n description: z.string().exactOptional(),\n family: z.string().min(1).exactOptional(),\n links: z.array(ArtifactLink).readonly().exactOptional(),\n mode: z.literal(\"spa\").exactOptional(),\n submission: SubmissionPolicy.exactOptional(),\n kit: z\n .object({\n base: z.enum([\"base\", \"radix\"]).exactOptional(),\n theme: z.string().exactOptional(),\n })\n .exactOptional(),\n terminals: z.record(z.string(), TerminalSpec).readonly().exactOptional(),\n demos: z.record(z.string(), DemoSpec).readonly().exactOptional(),\n limits: z\n .object({\n heapMb: z.int().min(1).exactOptional(),\n watchdogMs: z.int().min(1).exactOptional(),\n idleMinutes: z.number().min(0).exactOptional(),\n })\n .exactOptional(),\n verify: z\n .object({\n viewports: strings.exactOptional(),\n frames: strings.exactOptional(),\n extraChecks: strings.exactOptional(),\n smoke: z.boolean().exactOptional(),\n })\n .exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ArtifactManifest\",\n description:\n \"The artifact manifest (INTERFACES §2.2): literal metadata from the entry's defineArtifact call or MDX frontmatter.\",\n });\n"],"mappings":";;;;;;;;;;;;;;;AA4GA,MAAa,yBAA8D;CACzE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;;AAG7C,MAAa,eAAwC,EAClD,OAAO;CAAE,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAAG,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AAAE,CAAC,CAAC,CAC/D,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAGH,MAAa,mBAAgD,EAC1D,mBAAmB,UAAU;CAC5B,EAAE,OAAO;EACP,QAAQ,EAAE,QAAQ,MAAM;EACxB,OAAO,EAAE,KAAK,CAAC,gBAAgB,YAAY,CAAC,CAAC,CAAC,cAAc;CAC9D,CAAC;CACD,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,QAAQ,EAAE,CAAC;CACxC,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,MAAM,EAAE,CAAC;AACxC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CACtD,MAAM,EAAE,QAAQ,KAAK,CAAC,CAAC,cAAc;CACrC,YAAY,iBAAiB,cAAc;CAC3C,KAAK,EACF,OAAO;EACN,MAAM,EAAE,KAAK,CAAC,QAAQ,OAAO,CAAC,CAAC,CAAC,cAAc;EAC9C,OAAO,EAAE,OAAO,CAAC,CAAC,cAAc;CAClC,CAAC,CAAC,CACD,cAAc;CACjB,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;CACvE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;CAC/D,QAAQ,EACL,OAAO;EACN,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;EACrC,YAAY,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;EACzC,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;CAC/C,CAAC,CAAC,CACD,cAAc;CACjB,QAAQ,EACL,OAAO;EACN,WAAW,QAAQ,cAAc;EACjC,QAAQ,QAAQ,cAAc;EAC9B,aAAa,QAAQ,cAAc;EACnC,OAAO,EAAE,QAAQ,CAAC,CAAC,cAAc;CACnC,CAAC,CAAC,CACD,cAAc;AACnB,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC"}
1
+ {"version":3,"file":"manifest.js","names":[],"sources":["../src/manifest.ts"],"sourcesContent":["/**\n * The artifact manifest (INTERFACES §2.2, D51): the metadata an artifact declares in its entry, as\n * `export const artifact = defineArtifact({...})` in TSX or as YAML frontmatter in MDX. Mostra reads\n * it statically, so every value is a literal. The same type checks `defineArtifact` for authors,\n * validates the extracted literal in the supervisor and travels on the wire in `artifact/get`.\n *\n * ```ts\n * const checked = ArtifactManifest.safeParse(extracted);\n * ```\n */\nimport * as z from \"zod\";\nimport { Duration, durationMs } from \"./duration.ts\";\nimport { SubmissionPolicy } from \"./policy.ts\";\n\nexport { SubmissionPolicy };\n\nimport { ArtifactId } from \"./ids.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** The families Mostra's templates and gallery know; any other string is allowed too. */\nexport type ArtifactFamily =\n | \"questionnaire\"\n | \"proposal\"\n | \"prototype\"\n | \"review\"\n | \"dashboard\"\n | \"deck\"\n | \"demo\"\n | \"inbox\"\n | \"tasks\"\n | (string & {});\n\n/** A related artifact (PRODUCT J6): a later round, a follow-up, a replacement. */\nexport interface ArtifactLink {\n /** How this artifact relates to the other one. */\n readonly rel: \"round-of\" | \"follows\" | \"replaces\" | (string & {});\n /** The other artifact's ID. */\n readonly artifact: string;\n}\n\n/** A live terminal session the artifact declares (ROUND-3 §5.1, D65). */\nexport interface TerminalSpec {\n /** The program and its arguments. */\n readonly command: readonly string[];\n /** Its working directory, relative to the artifact's source. */\n readonly cwd?: string;\n /** Extra environment variables. */\n readonly env?: Readonly<Record<string, string>>;\n /** The terminal's width in cells. */\n readonly cols?: number;\n /** The terminal's height in cells. */\n readonly rows?: number;\n /** Whether viewers may type into it. Sessions are read-only by default. */\n readonly input?: boolean;\n}\n\n/** A web demo the artifact declares (ROUND-3 §5.4, TM-08): a command to run, or a port to attach to. */\nexport type DemoSpec =\n | {\n readonly command: readonly string[];\n readonly cwd?: string;\n readonly ready?: string;\n readonly bridge?: boolean;\n }\n | { readonly attach: number; readonly bridge?: boolean };\n\n/**\n * A count by choice the artifact opts into (D165 item 12, RM-07): every accepted submission adds\n * one to the choice its viewer-scoped `field` holds, counted in the submit transaction, and viewers\n * read the counts with `useLive(\"$tally/<field>\")`. A value outside `choices`, or none, counts\n * nothing, so free text is never shown.\n */\nexport interface TallySpec {\n /** The viewer-scoped field whose value is counted. */\n readonly field: string;\n /** The values counted: 2 to 50 distinct strings. */\n readonly choices: readonly string[];\n /** Below this many answers (default 0), viewers see only the total, never the counts. */\n readonly minTotal?: number;\n}\n\n/** How the artifact behaves on a remote server (D165, INTERFACES §18). */\nexport interface HostedSettings {\n /**\n * Relayed action runs while the owner instance is away (D165 item 4): `queue` (the default)\n * waits up to `limit` (default `24h`, at most `7d`), `fail` ends a run at once.\n */\n readonly offline?: { readonly actions?: \"queue\" | \"fail\"; readonly limit?: Duration };\n /** Who may trigger relayed actions (D159): `signed-in` (the default) or anyone with the `link`. */\n readonly actions?: \"signed-in\" | \"link\";\n /** Who may submit (D165 item 13): anyone with the `link` (the default), or `signed-in` viewers. */\n readonly submissions?: \"link\" | \"signed-in\";\n /** Link previews (D161): `generic` (the default) or the artifact's `title`. */\n readonly preview?: \"generic\" | \"title\";\n}\n\n/** The longest offline limit a hosted artifact may set: 7 days (D165 item 4). */\nexport const HOSTED_OFFLINE_LIMIT_MAX_MS: number = 7 * 24 * 60 * 60 * 1000;\n\n/** The offline limit of a hosted artifact that sets none: 24 hours (D165 item 4). */\nexport const HOSTED_OFFLINE_LIMIT_DEFAULT: Duration = \"24h\";\n\n/** The fewest and most choices a tally counts (INTERFACES §18.4). */\nexport const TALLY_CHOICES_MIN = 2;\n/** The most choices a tally counts. */\nexport const TALLY_CHOICES_MAX = 50;\n\n/** The artifact manifest (INTERFACES §2.2). Every field except `title` is optional. */\nexport interface ArtifactManifest {\n /** The artifact's ID. Written by `mostra new`; without one, the artifact is bound to its source path at first publish (D51). */\n readonly id?: string;\n /** The title people see. */\n readonly title: string;\n /** One or two sentences on what the artifact is for. */\n readonly description?: string;\n /** What kind of artifact it is; templates and the gallery group by it. */\n readonly family?: ArtifactFamily;\n /** Related artifacts. */\n readonly links?: readonly ArtifactLink[];\n /** How the artifact is built and served: `spa`, the default and the only mode in v1 (D19). */\n readonly mode?: \"spa\";\n /** The submission policy the artifact requests; the host decides (D39, D63). */\n readonly submission?: SubmissionPolicy;\n /** The kit's shadcn base (default `base`, D72) and theme. */\n readonly kit?: { readonly base?: \"base\" | \"radix\"; readonly theme?: string };\n /** Live terminal sessions by name (D65). */\n readonly terminals?: Readonly<Record<string, TerminalSpec>>;\n /** Web demos by name (D65). */\n readonly demos?: Readonly<Record<string, DemoSpec>>;\n /** Stability limits for the artifact's worker (D62). */\n readonly limits?: {\n readonly heapMb?: number;\n readonly watchdogMs?: number;\n readonly idleMinutes?: number;\n };\n /** `verify` settings (D65). */\n readonly verify?: {\n readonly viewports?: readonly string[];\n readonly frames?: readonly string[];\n readonly extraChecks?: readonly string[];\n readonly smoke?: boolean;\n };\n /** Counts by choice of fixed-choice fields (D165 item 12). */\n readonly tally?: readonly TallySpec[];\n /** How the artifact behaves on a remote server (D165). */\n readonly hosted?: HostedSettings;\n}\n\n/** The keys of the artifact manifest, in INTERFACES §2.2 order. Other keys are warnings (FAILURE_MODEL §10). */\nexport const ARTIFACT_MANIFEST_KEYS: readonly (keyof ArtifactManifest)[] = [\n \"id\",\n \"title\",\n \"description\",\n \"family\",\n \"links\",\n \"mode\",\n \"submission\",\n \"kit\",\n \"terminals\",\n \"demos\",\n \"limits\",\n \"verify\",\n \"tally\",\n \"hosted\",\n];\n\nconst strings = z.array(z.string()).readonly();\n\n/** The Zod schema of the `ArtifactLink` type. */\nexport const ArtifactLink: z.ZodType<ArtifactLink> = z\n .object({ rel: z.string().min(1), artifact: z.string().min(1) })\n .register(wireRegistry, {\n id: \"ArtifactLink\",\n description: \"A related artifact: how this one relates (rel) and the other artifact's ID.\",\n });\n\nconst TerminalSpec: z.ZodType<TerminalSpec> = z.object({\n command: z.array(z.string()).min(1).readonly(),\n cwd: z.string().exactOptional(),\n env: z.record(z.string(), z.string()).readonly().exactOptional(),\n cols: z.int().min(1).exactOptional(),\n rows: z.int().min(1).exactOptional(),\n input: z.boolean().exactOptional(),\n});\n\nconst DemoSpec: z.ZodType<DemoSpec> = z.union([\n z.object({\n command: z.array(z.string()).min(1).readonly(),\n cwd: z.string().exactOptional(),\n ready: z.string().exactOptional(),\n bridge: z.boolean().exactOptional(),\n }),\n z.object({ attach: z.int().min(1).max(65535), bridge: z.boolean().exactOptional() }),\n]);\n\n/** The Zod schema of the `TallySpec` type. */\nexport const TallySpec: z.ZodType<TallySpec> = z\n .object({\n field: z.string().min(1).max(256),\n choices: z\n .array(z.string().min(1).max(256))\n .min(TALLY_CHOICES_MIN)\n .max(TALLY_CHOICES_MAX)\n .readonly(),\n minTotal: z.int().min(0).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"TallySpec\",\n description:\n \"A count by choice of a viewer-scoped field: its field, 2 to 50 distinct choices and minTotal.\",\n });\n\n/** The Zod schema of the `HostedSettings` type. */\nexport const HostedSettings: z.ZodType<HostedSettings> = z\n .object({\n offline: z\n .object({\n actions: z.enum([\"queue\", \"fail\"]).exactOptional(),\n limit: Duration.exactOptional(),\n })\n .exactOptional(),\n actions: z.enum([\"signed-in\", \"link\"]).exactOptional(),\n submissions: z.enum([\"link\", \"signed-in\"]).exactOptional(),\n preview: z.enum([\"generic\", \"title\"]).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"HostedSettings\",\n description:\n \"How an artifact behaves on a remote server: offline actions, who may act and submit, previews.\",\n });\n\n/** The Zod schema of the `ArtifactManifest` type. Objects stay open, so newer keys pass through. */\nexport const ArtifactManifest: z.ZodType<ArtifactManifest> = z\n .object({\n id: ArtifactId.schema.exactOptional(),\n title: z.string().min(1),\n description: z.string().exactOptional(),\n family: z.string().min(1).exactOptional(),\n links: z.array(ArtifactLink).readonly().exactOptional(),\n mode: z.literal(\"spa\").exactOptional(),\n submission: SubmissionPolicy.exactOptional(),\n kit: z\n .object({\n base: z.enum([\"base\", \"radix\"]).exactOptional(),\n theme: z.string().exactOptional(),\n })\n .exactOptional(),\n terminals: z.record(z.string(), TerminalSpec).readonly().exactOptional(),\n demos: z.record(z.string(), DemoSpec).readonly().exactOptional(),\n limits: z\n .object({\n heapMb: z.int().min(1).exactOptional(),\n watchdogMs: z.int().min(1).exactOptional(),\n idleMinutes: z.number().min(0).exactOptional(),\n })\n .exactOptional(),\n verify: z\n .object({\n viewports: strings.exactOptional(),\n frames: strings.exactOptional(),\n extraChecks: strings.exactOptional(),\n smoke: z.boolean().exactOptional(),\n })\n .exactOptional(),\n tally: z.array(TallySpec).readonly().exactOptional(),\n hosted: HostedSettings.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ArtifactManifest\",\n description:\n \"The artifact manifest (INTERFACES §2.2): literal metadata from the entry's defineArtifact call or MDX frontmatter.\",\n });\n\n/**\n * The rules of a manifest that JSON Schema can't state, checked after its schema by everything\n * that reads a manifest (D165 items 4, 12): a tally's choices are distinct, each field is tallied\n * once, and an offline limit is at most 7 days. Answers the first problem, with its field's path.\n */\nexport function manifestProblem(\n manifest: ArtifactManifest,\n): { readonly path: string; readonly message: string } | undefined {\n const fields = new Set<string>();\n for (const [index, tally] of (manifest.tally ?? []).entries()) {\n if (new Set(tally.choices).size !== tally.choices.length) {\n return { path: `tally.${index}.choices`, message: \"a tally's choices must be distinct\" };\n }\n if (fields.has(tally.field)) {\n return { path: `tally.${index}.field`, message: `\\`${tally.field}\\` is tallied twice` };\n }\n fields.add(tally.field);\n }\n const limit = manifest.hosted?.offline?.limit;\n if (limit !== undefined && durationMs(limit) > HOSTED_OFFLINE_LIMIT_MAX_MS) {\n return { path: \"hosted.offline.limit\", message: \"an offline limit is at most 7d\" };\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiGA,MAAa,8BAAsC;;AAGnD,MAAa,+BAAyC;;AAGtD,MAAa,oBAAoB;;AAEjC,MAAa,oBAAoB;;AA4CjC,MAAa,yBAA8D;CACzE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;;AAG7C,MAAa,eAAwC,EAClD,OAAO;CAAE,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAAG,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AAAE,CAAC,CAAC,CAC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"zod";
4
+ //#region src/methods/artifact/export.d.ts
5
+ /**
6
+ * An export class (ARCHITECTURE §3, VR-07). `bundle` is the portable artifact package (RM-01,
7
+ * WP-29); WP-24 adds `static`, `html` and `snapshot`, and WP-17 `mcp-app`, additively.
8
+ */
9
+ export type ExportClass = "bundle";
10
+ /** The Zod schema of the `ExportClass` type. */
11
+ export declare const ExportClass: z.ZodType<ExportClass>;
12
+ /** The params of `artifact/export` (INTERFACES §6, §15). */
13
+ export interface ArtifactExportParams {
14
+ /** The artifact: its ID, or a source path it was published from. */
15
+ readonly artifact: ArtifactRef;
16
+ /** The version: a number or a version ID; the latest when absent. */
17
+ readonly version?: number | string;
18
+ /** What to write. */
19
+ readonly as: ExportClass;
20
+ /**
21
+ * Where: an absolute path. A bundle is a directory there, or one archive when the path ends in
22
+ * `.tar.zst`. It must not exist yet, or be an empty directory.
23
+ */
24
+ readonly out: string;
25
+ }
26
+ /** The result of `artifact/export`. */
27
+ export interface ArtifactExportResult {
28
+ /** What it wrote, as absolute paths: the bundle's directory or archive. */
29
+ readonly files: readonly string[];
30
+ /** The version exported. */
31
+ readonly versionId: string;
32
+ }
33
+ /**
34
+ * `artifact/export`: writes a published version out of the home. A `bundle` carries the version's
35
+ * builds, manifest, lockfile and source snapshot, so `artifact/import` (`mostra run <bundle>`) in
36
+ * another home makes it the same version, with the same artifact and version IDs (RM-01).
37
+ */
38
+ export declare const artifactExportMethod: MethodDefinition<ArtifactExportParams, ArtifactExportResult>;
39
+ //#endregion
40
+ //# sourceMappingURL=export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.d.ts","names":[],"sources":["../../../src/methods/artifact/export.ts"],"mappings":";;;;;;;;YASY;;qBAGC,aAAa,EAAE,QAAQ;;iBAKnB;;WAEN,UAAU;;WAEV;;WAEA,IAAI;;;;;WAKJ;;;iBAIM;;WAEN;;WAEA;;;;;;;qBAwBE,sBAAsB,iBAAiB,sBAAsB"}
@@ -0,0 +1,36 @@
1
+ import { wireRegistry } from "../../wire-registry.js";
2
+ import { ArtifactRef } from "../../artifact.js";
3
+ import { defineMethod } from "../../method.js";
4
+ import * as z from "zod";
5
+ //#region src/methods/artifact/export.ts
6
+ /** The Zod schema of the `ExportClass` type. */
7
+ const ExportClass = z.enum(["bundle"]).register(wireRegistry, {
8
+ id: "ExportClass",
9
+ description: "An export class (VR-07)."
10
+ });
11
+ const params = z.object({
12
+ artifact: ArtifactRef,
13
+ version: z.union([z.int().min(1), z.string().min(1)]).exactOptional(),
14
+ as: ExportClass,
15
+ out: z.string().min(1)
16
+ }).register(wireRegistry, { id: "ArtifactExportParams" });
17
+ const result = z.object({
18
+ files: z.array(z.string()).readonly(),
19
+ versionId: z.string()
20
+ }).register(wireRegistry, { id: "ArtifactExportResult" });
21
+ /**
22
+ * `artifact/export`: writes a published version out of the home. A `bundle` carries the version's
23
+ * builds, manifest, lockfile and source snapshot, so `artifact/import` (`mostra run <bundle>`) in
24
+ * another home makes it the same version, with the same artifact and version IDs (RM-01).
25
+ */
26
+ const artifactExportMethod = defineMethod({
27
+ method: "artifact/export",
28
+ direction: "client-to-instance",
29
+ mutating: false,
30
+ params,
31
+ result
32
+ });
33
+ //#endregion
34
+ export { ExportClass, artifactExportMethod };
35
+
36
+ //# sourceMappingURL=export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.js","names":[],"sources":["../../../src/methods/artifact/export.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { ArtifactRef } from \"../../artifact.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\n\n/**\n * An export class (ARCHITECTURE §3, VR-07). `bundle` is the portable artifact package (RM-01,\n * WP-29); WP-24 adds `static`, `html` and `snapshot`, and WP-17 `mcp-app`, additively.\n */\nexport type ExportClass = \"bundle\";\n\n/** The Zod schema of the `ExportClass` type. */\nexport const ExportClass: z.ZodType<ExportClass> = z\n .enum([\"bundle\"])\n .register(wireRegistry, { id: \"ExportClass\", description: \"An export class (VR-07).\" });\n\n/** The params of `artifact/export` (INTERFACES §6, §15). */\nexport interface ArtifactExportParams {\n /** The artifact: its ID, or a source path it was published from. */\n readonly artifact: ArtifactRef;\n /** The version: a number or a version ID; the latest when absent. */\n readonly version?: number | string;\n /** What to write. */\n readonly as: ExportClass;\n /**\n * Where: an absolute path. A bundle is a directory there, or one archive when the path ends in\n * `.tar.zst`. It must not exist yet, or be an empty directory.\n */\n readonly out: string;\n}\n\n/** The result of `artifact/export`. */\nexport interface ArtifactExportResult {\n /** What it wrote, as absolute paths: the bundle's directory or archive. */\n readonly files: readonly string[];\n /** The version exported. */\n readonly versionId: string;\n}\n\nconst params: z.ZodType<ArtifactExportParams> = z\n .object({\n artifact: ArtifactRef,\n version: z.union([z.int().min(1), z.string().min(1)]).exactOptional(),\n as: ExportClass,\n out: z.string().min(1),\n })\n .register(wireRegistry, { id: \"ArtifactExportParams\" });\n\nconst result: z.ZodType<ArtifactExportResult> = z\n .object({\n files: z.array(z.string()).readonly(),\n versionId: z.string(),\n })\n .register(wireRegistry, { id: \"ArtifactExportResult\" });\n\n/**\n * `artifact/export`: writes a published version out of the home. A `bundle` carries the version's\n * builds, manifest, lockfile and source snapshot, so `artifact/import` (`mostra run <bundle>`) in\n * another home makes it the same version, with the same artifact and version IDs (RM-01).\n */\nexport const artifactExportMethod: MethodDefinition<ArtifactExportParams, ArtifactExportResult> =\n defineMethod({\n method: \"artifact/export\",\n direction: \"client-to-instance\",\n mutating: false,\n params,\n result,\n });\n"],"mappings":";;;;;;AAYA,MAAa,cAAsC,EAChD,KAAK,CAAC,QAAQ,CAAC,CAAC,CAChB,SAAS,cAAc;CAAE,IAAI;CAAe,aAAa;AAA2B,CAAC;AAyBxF,MAAM,SAA0C,EAC7C,OAAO;CACN,UAAU;CACV,SAAS,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc;CACpE,IAAI;CACJ,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AACvB,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,uBAAuB,CAAC;AAExD,MAAM,SAA0C,EAC7C,OAAO;CACN,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;CACpC,WAAW,EAAE,OAAO;AACtB,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,uBAAuB,CAAC;;;;;;AAOxD,MAAa,uBACX,aAAa;CACX,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA;AACF,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { PublishReceipt } from "../../artifact.js";
2
+ import { MethodDefinition } from "../../method.js";
3
+ //#region src/methods/artifact/import.d.ts
4
+ /** The params of `artifact/import` (INTERFACES §15). */
5
+ export interface ArtifactImportParams {
6
+ /** A bundle `artifact/export` wrote: its directory or its `.tar.zst` archive, as an absolute path. */
7
+ readonly bundle: string;
8
+ /** Makes retries idempotent: a repeated `requestId` returns the recorded result (H-03). */
9
+ readonly requestId?: string;
10
+ }
11
+ /**
12
+ * The result of `artifact/import`: the receipt of the version it made, or found (`reused`), with
13
+ * the bundle's artifact and version IDs.
14
+ */
15
+ export type ArtifactImportResult = PublishReceipt;
16
+ /**
17
+ * `artifact/import`: makes a portable bundle a published version of this home (RM-01; the CLI's
18
+ * `mostra run <bundle>`): the same artifact ID, version ID and digests, checked against the
19
+ * bundle's files before anything is kept. Its server code runs here, against the bundle's lockfile.
20
+ */
21
+ export declare const artifactImportMethod: MethodDefinition<ArtifactImportParams, ArtifactImportResult>;
22
+ //#endregion
23
+ //# sourceMappingURL=import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.d.ts","names":[],"sources":["../../../src/methods/artifact/import.ts"],"mappings":";;;;iBAMiB;;WAEN;;WAEA;;;;;;YAOC,uBAAuB;;;;;;qBActB,sBAAsB,iBAAiB,sBAAsB"}
@@ -0,0 +1,25 @@
1
+ import { wireRegistry } from "../../wire-registry.js";
2
+ import { PublishReceipt } from "../../artifact.js";
3
+ import { defineMethod } from "../../method.js";
4
+ import * as z from "zod";
5
+ //#region src/methods/artifact/import.ts
6
+ const params = z.object({
7
+ bundle: z.string().min(1),
8
+ requestId: z.string().min(1).exactOptional()
9
+ }).register(wireRegistry, { id: "ArtifactImportParams" });
10
+ /**
11
+ * `artifact/import`: makes a portable bundle a published version of this home (RM-01; the CLI's
12
+ * `mostra run <bundle>`): the same artifact ID, version ID and digests, checked against the
13
+ * bundle's files before anything is kept. Its server code runs here, against the bundle's lockfile.
14
+ */
15
+ const artifactImportMethod = defineMethod({
16
+ method: "artifact/import",
17
+ direction: "client-to-instance",
18
+ mutating: true,
19
+ params,
20
+ result: PublishReceipt
21
+ });
22
+ //#endregion
23
+ export { artifactImportMethod };
24
+
25
+ //# sourceMappingURL=import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.js","names":[],"sources":["../../../src/methods/artifact/import.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { PublishReceipt } from \"../../artifact.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\n\n/** The params of `artifact/import` (INTERFACES §15). */\nexport interface ArtifactImportParams {\n /** A bundle `artifact/export` wrote: its directory or its `.tar.zst` archive, as an absolute path. */\n readonly bundle: string;\n /** Makes retries idempotent: a repeated `requestId` returns the recorded result (H-03). */\n readonly requestId?: string;\n}\n\n/**\n * The result of `artifact/import`: the receipt of the version it made, or found (`reused`), with\n * the bundle's artifact and version IDs.\n */\nexport type ArtifactImportResult = PublishReceipt;\n\nconst params: z.ZodType<ArtifactImportParams> = z\n .object({\n bundle: z.string().min(1),\n requestId: z.string().min(1).exactOptional(),\n })\n .register(wireRegistry, { id: \"ArtifactImportParams\" });\n\n/**\n * `artifact/import`: makes a portable bundle a published version of this home (RM-01; the CLI's\n * `mostra run <bundle>`): the same artifact ID, version ID and digests, checked against the\n * bundle's files before anything is kept. Its server code runs here, against the bundle's lockfile.\n */\nexport const artifactImportMethod: MethodDefinition<ArtifactImportParams, ArtifactImportResult> =\n defineMethod({\n method: \"artifact/import\",\n direction: \"client-to-instance\",\n mutating: true,\n params,\n result: PublishReceipt,\n });\n"],"mappings":";;;;;AAmBA,MAAM,SAA0C,EAC7C,OAAO;CACN,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACxB,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;AAC7C,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,uBAAuB,CAAC;;;;;;AAOxD,MAAa,uBACX,aAAa;CACX,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA,QAAQ;AACV,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { ArtifactRef } from "../../artifact.js";
2
+ import { MethodDefinition } from "../../method.js";
3
+ //#region src/methods/artifact/pause.d.ts
4
+ /** Who paused an artifact (D165 item 14). */
5
+ export type PausedBy = "owner" | "operator";
6
+ /** The params of `artifact/pause` (INTERFACES §18.2, D165 item 14). */
7
+ export interface ArtifactPauseParams {
8
+ /** The artifact to pause or resume. */
9
+ readonly artifact: ArtifactRef;
10
+ /** `true` pauses it, `false` resumes it. */
11
+ readonly paused: boolean;
12
+ /** Why, shown to viewers as text while it is paused. */
13
+ readonly reason?: string;
14
+ /** Makes retries idempotent: a repeated `requestId` returns the recorded result (H-03). */
15
+ readonly requestId?: string;
16
+ }
17
+ /** The result of `artifact/pause`: whether the artifact is paused now, and by whom. */
18
+ export interface ArtifactPauseResult {
19
+ /** Whether it is paused after the call. */
20
+ readonly paused: boolean;
21
+ /** Who paused it, while it is paused. */
22
+ readonly by?: PausedBy;
23
+ }
24
+ /**
25
+ * `artifact/pause`: pauses or resumes an artifact. While paused it stays viewable and its shell
26
+ * says so; submissions answer 423 `MOSTRA_SUBMIT_PAUSED` and actions 423 `MOSTRA_ACTION_PAUSED`,
27
+ * each keeping the draft; links stay valid. On an owner instance it acts on the local artifact and,
28
+ * for a hosted one, on every server it is hosted on. An operator's pause can't be resumed by the
29
+ * owner (`MOSTRA_REMOTE_PAUSED_BY_OPERATOR`).
30
+ */
31
+ export declare const artifactPauseMethod: MethodDefinition<ArtifactPauseParams, ArtifactPauseResult>;
32
+ //#endregion
33
+ //# sourceMappingURL=pause.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pause.d.ts","names":[],"sources":["../../../src/methods/artifact/pause.ts"],"mappings":";;;;YAMY;;iBAGK;;WAEN,UAAU;;WAEV;;WAEA;;WAEA;;;iBAIM;;WAEN;;WAEA,KAAK;;;;;;;;;qBA0BH,qBAAqB,iBAAiB,qBAAqB"}
@@ -0,0 +1,33 @@
1
+ import { wireRegistry } from "../../wire-registry.js";
2
+ import { ArtifactRef } from "../../artifact.js";
3
+ import { defineMethod } from "../../method.js";
4
+ import * as z from "zod";
5
+ //#region src/methods/artifact/pause.ts
6
+ const params = z.object({
7
+ artifact: ArtifactRef,
8
+ paused: z.boolean(),
9
+ reason: z.string().max(500).exactOptional(),
10
+ requestId: z.string().min(1).exactOptional()
11
+ }).register(wireRegistry, { id: "ArtifactPauseParams" });
12
+ const result = z.object({
13
+ paused: z.boolean(),
14
+ by: z.enum(["owner", "operator"]).exactOptional()
15
+ }).register(wireRegistry, { id: "ArtifactPauseResult" });
16
+ /**
17
+ * `artifact/pause`: pauses or resumes an artifact. While paused it stays viewable and its shell
18
+ * says so; submissions answer 423 `MOSTRA_SUBMIT_PAUSED` and actions 423 `MOSTRA_ACTION_PAUSED`,
19
+ * each keeping the draft; links stay valid. On an owner instance it acts on the local artifact and,
20
+ * for a hosted one, on every server it is hosted on. An operator's pause can't be resumed by the
21
+ * owner (`MOSTRA_REMOTE_PAUSED_BY_OPERATOR`).
22
+ */
23
+ const artifactPauseMethod = defineMethod({
24
+ method: "artifact/pause",
25
+ direction: "client-to-instance",
26
+ mutating: true,
27
+ params,
28
+ result
29
+ });
30
+ //#endregion
31
+ export { artifactPauseMethod };
32
+
33
+ //# sourceMappingURL=pause.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pause.js","names":[],"sources":["../../../src/methods/artifact/pause.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { ArtifactRef } from \"../../artifact.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\n\n/** Who paused an artifact (D165 item 14). */\nexport type PausedBy = \"owner\" | \"operator\";\n\n/** The params of `artifact/pause` (INTERFACES §18.2, D165 item 14). */\nexport interface ArtifactPauseParams {\n /** The artifact to pause or resume. */\n readonly artifact: ArtifactRef;\n /** `true` pauses it, `false` resumes it. */\n readonly paused: boolean;\n /** Why, shown to viewers as text while it is paused. */\n readonly reason?: string;\n /** Makes retries idempotent: a repeated `requestId` returns the recorded result (H-03). */\n readonly requestId?: string;\n}\n\n/** The result of `artifact/pause`: whether the artifact is paused now, and by whom. */\nexport interface ArtifactPauseResult {\n /** Whether it is paused after the call. */\n readonly paused: boolean;\n /** Who paused it, while it is paused. */\n readonly by?: PausedBy;\n}\n\nconst params: z.ZodType<ArtifactPauseParams> = z\n .object({\n artifact: ArtifactRef,\n paused: z.boolean(),\n reason: z.string().max(500).exactOptional(),\n requestId: z.string().min(1).exactOptional(),\n })\n .register(wireRegistry, { id: \"ArtifactPauseParams\" });\n\nconst result: z.ZodType<ArtifactPauseResult> = z\n .object({\n paused: z.boolean(),\n by: z.enum([\"owner\", \"operator\"]).exactOptional(),\n })\n .register(wireRegistry, { id: \"ArtifactPauseResult\" });\n\n/**\n * `artifact/pause`: pauses or resumes an artifact. While paused it stays viewable and its shell\n * says so; submissions answer 423 `MOSTRA_SUBMIT_PAUSED` and actions 423 `MOSTRA_ACTION_PAUSED`,\n * each keeping the draft; links stay valid. On an owner instance it acts on the local artifact and,\n * for a hosted one, on every server it is hosted on. An operator's pause can't be resumed by the\n * owner (`MOSTRA_REMOTE_PAUSED_BY_OPERATOR`).\n */\nexport const artifactPauseMethod: MethodDefinition<ArtifactPauseParams, ArtifactPauseResult> =\n defineMethod({\n method: \"artifact/pause\",\n direction: \"client-to-instance\",\n mutating: true,\n params,\n result,\n });\n"],"mappings":";;;;;AA4BA,MAAM,SAAyC,EAC5C,OAAO;CACN,UAAU;CACV,QAAQ,EAAE,QAAQ;CAClB,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,cAAc;CAC1C,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;AAC7C,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,sBAAsB,CAAC;AAEvD,MAAM,SAAyC,EAC5C,OAAO;CACN,QAAQ,EAAE,QAAQ;CAClB,IAAI,EAAE,KAAK,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,cAAc;AAClD,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,sBAAsB,CAAC;;;;;;;;AASvD,MAAa,sBACX,aAAa;CACX,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA;AACF,CAAC"}
@@ -1,4 +1,5 @@
1
- import { SubmissionPolicy } from "../../manifest.js";
1
+ import { SubmissionPolicy } from "../../policy.js";
2
+ import "../../manifest.js";
2
3
  import { PublishReceipt, SourceRef } from "../../artifact.js";
3
4
  import { MethodDefinition } from "../../method.js";
4
5
  //#region src/methods/artifact/publish.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"publish.d.ts","names":[],"sources":["../../../src/methods/artifact/publish.ts"],"mappings":";;;;;iBAOiB;;WAEN,QAAQ;;;;;WAKR;;WAEA,SAAS;;WAET;;;YAIC,wBAAwB;;;;;;qBAgBvB,uBAAuB,iBAAiB,uBAAuB"}
1
+ {"version":3,"file":"publish.d.ts","names":[],"sources":["../../../src/methods/artifact/publish.ts"],"mappings":";;;;;;iBAOiB;;WAEN,QAAQ;;;;;WAKR;;WAEA,SAAS;;WAET;;;YAIC,wBAAwB;;;;;;qBAgBvB,uBAAuB,iBAAiB,uBAAuB"}
@@ -1,5 +1,5 @@
1
1
  import { wireRegistry } from "../../wire-registry.js";
2
- import { SubmissionPolicy } from "../../manifest.js";
2
+ import { SubmissionPolicy } from "../../policy.js";
3
3
  import { PublishReceipt, SourceRef } from "../../artifact.js";
4
4
  import { defineMethod } from "../../method.js";
5
5
  import * as z from "zod";
@@ -0,0 +1,76 @@
1
+ import { SubmissionPolicy } from "../../policy.js";
2
+ import { MethodDefinition } from "../../method.js";
3
+ import * as z from "zod";
4
+ //#region src/methods/hosted/push.d.ts
5
+ /** One built file of a version: `[path, executable, sha256, size]` (DATA_MODEL §2). */
6
+ export type ListingEntry = readonly [path: string, executable: boolean, sha256: string, size: number];
7
+ /**
8
+ * A version as an owner instance pushes it to its hosted home (INTERFACES §18.2, D165 item 3): its
9
+ * identity, its manifest, registry and lockfile, and the listing of every built file, server files
10
+ * included, whose digest is `outputDigest`. Never sources, never server code.
11
+ */
12
+ export interface VersionPush {
13
+ /** The version ID (D89): the hosted home checks it against the artifact ID and both digests. */
14
+ readonly versionId: string;
15
+ /** Its number in the owner's home, kept in the hosted one. */
16
+ readonly number: number;
17
+ /** The source tree's digest (DATA_MODEL §2). */
18
+ readonly sourceDigest: string;
19
+ /** The environment's digest. */
20
+ readonly envDigest: string;
21
+ /** The output listing's digest: `listing` must hash to it. */
22
+ readonly outputDigest: string;
23
+ /** The version's `manifest.json`, as text. */
24
+ readonly manifest: string;
25
+ /** Its `registry.json`, as text. */
26
+ readonly registry: string;
27
+ /** Its `lock.yaml`, as text. */
28
+ readonly lock: string;
29
+ /** Every built file, server files included, as `[path, executable, sha256, size]`. */
30
+ readonly listing: readonly ListingEntry[];
31
+ /**
32
+ * The submission policy in force for the artifact in the owner's home (D102), which its hosted
33
+ * home follows: the owner's host decides it, never the server (D165 item 1).
34
+ */
35
+ readonly policy?: SubmissionPolicy;
36
+ }
37
+ /** The params of `hosted/push`. */
38
+ export interface HostedPushParams {
39
+ /** The artifact, by its own ID (its manifest's). */
40
+ readonly artifactId: string;
41
+ /** The version to host. */
42
+ readonly version: VersionPush;
43
+ /** Makes a retry idempotent; the push is idempotent by version ID anyway. */
44
+ readonly requestId?: string;
45
+ }
46
+ /** An artifact's hosted route: its `rte_` ID and random label (INTERFACES §18.4). */
47
+ export interface HostedRoute {
48
+ /** The route's `rte_` ID, in the hosted shell's paths (`/a/<routeId>`). */
49
+ readonly routeId: string;
50
+ /** The route's DNS label on the user-content domain, never issued twice. */
51
+ readonly label: string;
52
+ }
53
+ /** The result of `hosted/push`: the files the server still lacks, or the hosted version. */
54
+ export type HostedPushResult = {
55
+ readonly status: "complete";
56
+ readonly versionId: string;
57
+ readonly number: number;
58
+ readonly route: HostedRoute;
59
+ } | {
60
+ readonly status: "missing";
61
+ readonly files: readonly string[];
62
+ readonly route: HostedRoute;
63
+ };
64
+ /** The Zod schema of the `VersionPush` type. */
65
+ export declare const VersionPush: z.ZodType<VersionPush>;
66
+ /** The Zod schema of the `HostedRoute` type. */
67
+ export declare const HostedRoute: z.ZodType<HostedRoute>;
68
+ /**
69
+ * `hosted/push`: on a hosted home, makes a version of the owner's artifact hosted (D165 item 3).
70
+ * The server stores the client files the listing names, never the server files, and answers the
71
+ * SHA-256s it lacks until every client file was uploaded to `/files/<sha256>`. Idempotent by
72
+ * `versionId`; it mints the artifact's hosted route on the first push.
73
+ */
74
+ export declare const hostedPushMethod: MethodDefinition<HostedPushParams, HostedPushResult>;
75
+ //#endregion
76
+ //# sourceMappingURL=push.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push.d.ts","names":[],"sources":["../../../src/methods/hosted/push.ts"],"mappings":";;;;;YAOY,yBACV,cACA,qBACA,gBACA;;;;;;iBAQe;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA,kBAAkB;;;;;WAKlB,SAAS;;;iBAIH;;WAEN;;WAEA,SAAS;;WAET;;;iBAIM;;WAEN;;WAEA;;;YAIC;WAEG;WACA;WACA;WACA,OAAO;;WAEP;WAA4B;WAAmC,OAAO;;;qBAKxE,aAAa,EAAE,QAAQ;;qBAuBvB,aAAa,EAAE,QAAQ;;;;;;;qBAwCvB,kBAAkB,iBAAiB,kBAAkB"}