@mostra/protocol 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/dist/actions.d.ts +30 -4
  2. package/dist/actions.d.ts.map +1 -1
  3. package/dist/actions.js +14 -4
  4. package/dist/actions.js.map +1 -1
  5. package/dist/artifact.d.ts +2 -1
  6. package/dist/artifact.d.ts.map +1 -1
  7. package/dist/artifact.js +2 -1
  8. package/dist/artifact.js.map +1 -1
  9. package/dist/browser.d.ts +5 -0
  10. package/dist/browser.d.ts.map +1 -1
  11. package/dist/browser.js +7 -2
  12. package/dist/browser.js.map +1 -1
  13. package/dist/capability.d.ts +0 -9
  14. package/dist/capability.d.ts.map +1 -1
  15. package/dist/capability.js +1 -17
  16. package/dist/capability.js.map +1 -1
  17. package/dist/diagnostics/codes/artifact.d.ts +1 -1
  18. package/dist/diagnostics/codes/artifact.d.ts.map +1 -1
  19. package/dist/diagnostics/codes/artifact.js +45 -1
  20. package/dist/diagnostics/codes/artifact.js.map +1 -1
  21. package/dist/diagnostics/codes/env.d.ts +1 -1
  22. package/dist/diagnostics/codes/env.d.ts.map +1 -1
  23. package/dist/diagnostics/codes/env.js +12 -1
  24. package/dist/diagnostics/codes/env.js.map +1 -1
  25. package/dist/diagnostics/codes/home.d.ts +1 -1
  26. package/dist/diagnostics/codes/home.d.ts.map +1 -1
  27. package/dist/diagnostics/codes/home.js +12 -1
  28. package/dist/diagnostics/codes/home.js.map +1 -1
  29. package/dist/diagnostics/codes/index.d.ts +3 -2
  30. package/dist/diagnostics/codes/index.d.ts.map +1 -1
  31. package/dist/diagnostics/codes/index.js +3 -1
  32. package/dist/diagnostics/codes/index.js.map +1 -1
  33. package/dist/diagnostics/codes/remote.d.ts +8 -0
  34. package/dist/diagnostics/codes/remote.d.ts.map +1 -0
  35. package/dist/diagnostics/codes/remote.js +99 -0
  36. package/dist/diagnostics/codes/remote.js.map +1 -0
  37. package/dist/diagnostics/codes/submit.js +3 -3
  38. package/dist/diagnostics/codes/submit.js.map +1 -1
  39. package/dist/diagnostics/diagnostic.d.ts +1 -1
  40. package/dist/diagnostics/diagnostic.d.ts.map +1 -1
  41. package/dist/diagnostics/diagnostic.js +2 -1
  42. package/dist/diagnostics/diagnostic.js.map +1 -1
  43. package/dist/duration.d.ts +13 -0
  44. package/dist/duration.d.ts.map +1 -0
  45. package/dist/duration.js +27 -0
  46. package/dist/duration.js.map +1 -0
  47. package/dist/hygiene.d.ts +4 -1
  48. package/dist/hygiene.d.ts.map +1 -1
  49. package/dist/hygiene.js +4 -0
  50. package/dist/hygiene.js.map +1 -1
  51. package/dist/ids.d.ts +17 -1
  52. package/dist/ids.d.ts.map +1 -1
  53. package/dist/ids.js +9 -1
  54. package/dist/ids.js.map +1 -1
  55. package/dist/index.d.ts +30 -8
  56. package/dist/index.js +30 -8
  57. package/dist/interaction.d.ts +28 -2
  58. package/dist/interaction.d.ts.map +1 -1
  59. package/dist/interaction.js +20 -5
  60. package/dist/interaction.js.map +1 -1
  61. package/dist/manifest.d.ts +59 -14
  62. package/dist/manifest.d.ts.map +1 -1
  63. package/dist/manifest.js +63 -15
  64. package/dist/manifest.js.map +1 -1
  65. package/dist/methods/artifact/export.d.ts +40 -0
  66. package/dist/methods/artifact/export.d.ts.map +1 -0
  67. package/dist/methods/artifact/export.js +36 -0
  68. package/dist/methods/artifact/export.js.map +1 -0
  69. package/dist/methods/artifact/import.d.ts +23 -0
  70. package/dist/methods/artifact/import.d.ts.map +1 -0
  71. package/dist/methods/artifact/import.js +25 -0
  72. package/dist/methods/artifact/import.js.map +1 -0
  73. package/dist/methods/artifact/publish.d.ts +2 -1
  74. package/dist/methods/artifact/publish.d.ts.map +1 -1
  75. package/dist/methods/artifact/publish.js +1 -1
  76. package/dist/methods/hosted/push.d.ts +76 -0
  77. package/dist/methods/hosted/push.d.ts.map +1 -0
  78. package/dist/methods/hosted/push.js +71 -0
  79. package/dist/methods/hosted/push.js.map +1 -0
  80. package/dist/methods/hosted/submission.d.ts +18 -0
  81. package/dist/methods/hosted/submission.d.ts.map +1 -0
  82. package/dist/methods/hosted/submission.js +23 -0
  83. package/dist/methods/hosted/submission.js.map +1 -0
  84. package/dist/methods/index.d.ts.map +1 -1
  85. package/dist/methods/index.js +38 -2
  86. package/dist/methods/index.js.map +1 -1
  87. package/dist/methods/instance/status.d.ts +3 -0
  88. package/dist/methods/instance/status.d.ts.map +1 -1
  89. package/dist/methods/instance/status.js +3 -1
  90. package/dist/methods/instance/status.js.map +1 -1
  91. package/dist/methods/mostra/initialize.d.ts +17 -3
  92. package/dist/methods/mostra/initialize.d.ts.map +1 -1
  93. package/dist/methods/mostra/initialize.js +11 -3
  94. package/dist/methods/mostra/initialize.js.map +1 -1
  95. package/dist/methods/port/relay-call.d.ts +33 -0
  96. package/dist/methods/port/relay-call.d.ts.map +1 -0
  97. package/dist/methods/port/relay-call.js +31 -0
  98. package/dist/methods/port/relay-call.js.map +1 -0
  99. package/dist/methods/port/relay-cancel.d.ts +16 -0
  100. package/dist/methods/port/relay-cancel.d.ts.map +1 -0
  101. package/dist/methods/port/relay-cancel.js +21 -0
  102. package/dist/methods/port/relay-cancel.js.map +1 -0
  103. package/dist/methods/port/relay-live.d.ts +25 -0
  104. package/dist/methods/port/relay-live.d.ts.map +1 -0
  105. package/dist/methods/port/relay-live.js +32 -0
  106. package/dist/methods/port/relay-live.js.map +1 -0
  107. package/dist/methods/port/relay-reconcile.d.ts +39 -0
  108. package/dist/methods/port/relay-reconcile.d.ts.map +1 -0
  109. package/dist/methods/port/relay-reconcile.js +35 -0
  110. package/dist/methods/port/relay-reconcile.js.map +1 -0
  111. package/dist/methods/port/relay-run.d.ts +47 -0
  112. package/dist/methods/port/relay-run.d.ts.map +1 -0
  113. package/dist/methods/port/relay-run.js +41 -0
  114. package/dist/methods/port/relay-run.js.map +1 -0
  115. package/dist/methods/port/submissions-deliver.d.ts +8 -0
  116. package/dist/methods/port/submissions-deliver.d.ts.map +1 -1
  117. package/dist/methods/port/submissions-deliver.js +4 -2
  118. package/dist/methods/port/submissions-deliver.js.map +1 -1
  119. package/dist/methods/relay/call-batch.d.ts +26 -0
  120. package/dist/methods/relay/call-batch.d.ts.map +1 -0
  121. package/dist/methods/relay/call-batch.js +30 -0
  122. package/dist/methods/relay/call-batch.js.map +1 -0
  123. package/dist/methods/relay/effect.d.ts +31 -0
  124. package/dist/methods/relay/effect.d.ts.map +1 -0
  125. package/dist/methods/relay/effect.js +30 -0
  126. package/dist/methods/relay/effect.js.map +1 -0
  127. package/dist/methods/relay/live-value.d.ts +33 -0
  128. package/dist/methods/relay/live-value.d.ts.map +1 -0
  129. package/dist/methods/relay/live-value.js +32 -0
  130. package/dist/methods/relay/live-value.js.map +1 -0
  131. package/dist/methods/relay/run-update.d.ts +46 -0
  132. package/dist/methods/relay/run-update.d.ts.map +1 -0
  133. package/dist/methods/relay/run-update.js +45 -0
  134. package/dist/methods/relay/run-update.js.map +1 -0
  135. package/dist/methods/remote/login-wait.d.ts +30 -0
  136. package/dist/methods/remote/login-wait.d.ts.map +1 -0
  137. package/dist/methods/remote/login-wait.js +36 -0
  138. package/dist/methods/remote/login-wait.js.map +1 -0
  139. package/dist/methods/remote/login.d.ts +41 -0
  140. package/dist/methods/remote/login.d.ts.map +1 -0
  141. package/dist/methods/remote/login.js +37 -0
  142. package/dist/methods/remote/login.js.map +1 -0
  143. package/dist/methods/remote/logout.d.ts +25 -0
  144. package/dist/methods/remote/logout.d.ts.map +1 -0
  145. package/dist/methods/remote/logout.js +28 -0
  146. package/dist/methods/remote/logout.js.map +1 -0
  147. package/dist/methods/remote/status.d.ts +14 -0
  148. package/dist/methods/remote/status.d.ts.map +1 -0
  149. package/dist/methods/remote/status.js +22 -0
  150. package/dist/methods/remote/status.js.map +1 -0
  151. package/dist/methods/remote/token.d.ts +19 -0
  152. package/dist/methods/remote/token.d.ts.map +1 -0
  153. package/dist/methods/remote/token.js +24 -0
  154. package/dist/methods/remote/token.js.map +1 -0
  155. package/dist/methods/share/start.d.ts +5 -2
  156. package/dist/methods/share/start.d.ts.map +1 -1
  157. package/dist/methods/share/start.js +6 -3
  158. package/dist/methods/share/start.js.map +1 -1
  159. package/dist/methods/state/patch.d.ts +7 -0
  160. package/dist/methods/state/patch.d.ts.map +1 -1
  161. package/dist/methods/state/patch.js +2 -1
  162. package/dist/methods/state/patch.js.map +1 -1
  163. package/dist/methods/view/url.d.ts +2 -1
  164. package/dist/methods/view/url.d.ts.map +1 -1
  165. package/dist/methods/view/url.js +2 -1
  166. package/dist/methods/view/url.js.map +1 -1
  167. package/dist/policy.d.ts +18 -0
  168. package/dist/policy.d.ts.map +1 -0
  169. package/dist/policy.js +23 -0
  170. package/dist/policy.js.map +1 -0
  171. package/dist/remote.d.ts +55 -0
  172. package/dist/remote.d.ts.map +1 -0
  173. package/dist/remote.js +52 -0
  174. package/dist/remote.js.map +1 -0
  175. package/dist/view.d.ts +1 -1
  176. package/dist/view.js +1 -1
  177. package/dist/view.js.map +1 -1
  178. package/package.json +2 -2
  179. package/schemas/protocol.draft-07.json +1607 -126
  180. package/schemas/protocol.schema.json +1543 -126
  181. package/src/actions.ts +45 -5
  182. package/src/browser.ts +6 -0
  183. package/src/capability.ts +0 -23
  184. package/src/diagnostics/codes/artifact.ts +48 -0
  185. package/src/diagnostics/codes/env.ts +12 -0
  186. package/src/diagnostics/codes/home.ts +12 -0
  187. package/src/diagnostics/codes/index.ts +6 -2
  188. package/src/diagnostics/codes/remote.ts +113 -0
  189. package/src/diagnostics/codes/submit.ts +3 -3
  190. package/src/diagnostics/diagnostic.ts +3 -1
  191. package/src/duration.ts +29 -0
  192. package/src/hygiene.ts +12 -1
  193. package/src/ids.ts +33 -1
  194. package/src/index.ts +124 -8
  195. package/src/interaction.ts +42 -2
  196. package/src/manifest.ts +115 -24
  197. package/src/methods/artifact/export.ts +68 -0
  198. package/src/methods/artifact/import.ts +39 -0
  199. package/src/methods/hosted/push.ts +146 -0
  200. package/src/methods/hosted/submission.ts +34 -0
  201. package/src/methods/index.ts +36 -0
  202. package/src/methods/instance/status.ts +4 -0
  203. package/src/methods/mostra/initialize.ts +19 -3
  204. package/src/methods/port/relay-call.ts +58 -0
  205. package/src/methods/port/relay-cancel.ts +33 -0
  206. package/src/methods/port/relay-live.ts +48 -0
  207. package/src/methods/port/relay-reconcile.ts +71 -0
  208. package/src/methods/port/relay-run.ts +80 -0
  209. package/src/methods/port/submissions-deliver.ts +13 -1
  210. package/src/methods/relay/call-batch.ts +52 -0
  211. package/src/methods/relay/effect.ts +55 -0
  212. package/src/methods/relay/live-value.ts +54 -0
  213. package/src/methods/relay/run-update.ts +81 -0
  214. package/src/methods/remote/login-wait.ts +55 -0
  215. package/src/methods/remote/login.ts +72 -0
  216. package/src/methods/remote/logout.ts +42 -0
  217. package/src/methods/remote/status.ts +34 -0
  218. package/src/methods/remote/token.ts +39 -0
  219. package/src/methods/share/start.ts +12 -4
  220. package/src/methods/state/patch.ts +6 -0
  221. package/src/methods/view/url.ts +2 -1
  222. package/src/policy.ts +30 -0
  223. package/src/remote.ts +89 -0
  224. package/src/view.ts +1 -1
package/dist/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,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Aa,EAAE,OAAO,CAAC,CAAC,cAAc;CACtC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;CACxC,OAAO,EAAE,MAAM,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc;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,CA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,KAAa,WAAW,KAAK,IAAA,QACzC,OAAO;EAAE,MAAM;EAAwB,SAAS;CAAiC;AAGrF"}
@@ -0,0 +1,40 @@
1
+ import { ArtifactRef } from "../../artifact.js";
2
+ import { MethodDefinition } from "../../method.js";
3
+ import * as z from "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"}
@@ -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"}
@@ -0,0 +1,71 @@
1
+ import { wireRegistry } from "../../wire-registry.js";
2
+ import { ArtifactId } from "../../ids.js";
3
+ import { SubmissionPolicy } from "../../policy.js";
4
+ import { defineMethod } from "../../method.js";
5
+ import * as z from "zod";
6
+ //#region src/methods/hosted/push.ts
7
+ const Sha256 = z.string().regex(/^[0-9a-f]{64}$/);
8
+ /** The Zod schema of the `VersionPush` type. */
9
+ const VersionPush = z.object({
10
+ versionId: z.string().min(1),
11
+ number: z.int().min(1),
12
+ sourceDigest: Sha256,
13
+ envDigest: Sha256,
14
+ outputDigest: Sha256,
15
+ manifest: z.string().max(4194304),
16
+ registry: z.string().max(16777216),
17
+ lock: z.string().max(16777216),
18
+ listing: z.array(z.tuple([
19
+ z.string().min(1),
20
+ z.boolean(),
21
+ Sha256,
22
+ z.int().min(0)
23
+ ]).readonly()).max(1e5).readonly(),
24
+ policy: SubmissionPolicy.exactOptional()
25
+ }).register(wireRegistry, {
26
+ id: "VersionPush",
27
+ description: "A version an owner pushes to its hosted home: its identity, manifest, registry, lockfile and output listing."
28
+ });
29
+ /** The Zod schema of the `HostedRoute` type. */
30
+ const HostedRoute = z.object({
31
+ routeId: z.string(),
32
+ label: z.string()
33
+ }).register(wireRegistry, {
34
+ id: "HostedRoute",
35
+ description: "An artifact's hosted route: its rte_ ID and random label."
36
+ });
37
+ const params = z.object({
38
+ artifactId: ArtifactId.schema,
39
+ version: VersionPush,
40
+ requestId: z.string().min(1).exactOptional()
41
+ }).register(wireRegistry, { id: "HostedPushParams" });
42
+ const result = z.discriminatedUnion("status", [z.object({
43
+ status: z.literal("complete"),
44
+ versionId: z.string(),
45
+ number: z.int(),
46
+ route: HostedRoute
47
+ }), z.object({
48
+ status: z.literal("missing"),
49
+ files: z.array(Sha256).readonly(),
50
+ route: HostedRoute
51
+ })]).register(wireRegistry, {
52
+ id: "HostedPushResult",
53
+ description: "A push's state: the client files the server still lacks, or the hosted version."
54
+ });
55
+ /**
56
+ * `hosted/push`: on a hosted home, makes a version of the owner's artifact hosted (D165 item 3).
57
+ * The server stores the client files the listing names, never the server files, and answers the
58
+ * SHA-256s it lacks until every client file was uploaded to `/files/<sha256>`. Idempotent by
59
+ * `versionId`; it mints the artifact's hosted route on the first push.
60
+ */
61
+ const hostedPushMethod = defineMethod({
62
+ method: "hosted/push",
63
+ direction: "client-to-instance",
64
+ mutating: true,
65
+ params,
66
+ result
67
+ });
68
+ //#endregion
69
+ export { HostedRoute, VersionPush, hostedPushMethod };
70
+
71
+ //# sourceMappingURL=push.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push.js","names":[],"sources":["../../../src/methods/hosted/push.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { ArtifactId } from \"../../ids.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { SubmissionPolicy } from \"../../policy.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\n\n/** One built file of a version: `[path, executable, sha256, size]` (DATA_MODEL §2). */\nexport type ListingEntry = readonly [\n path: string,\n executable: boolean,\n sha256: string,\n size: number,\n];\n\n/**\n * A version as an owner instance pushes it to its hosted home (INTERFACES §18.2, D165 item 3): its\n * identity, its manifest, registry and lockfile, and the listing of every built file, server files\n * included, whose digest is `outputDigest`. Never sources, never server code.\n */\nexport interface VersionPush {\n /** The version ID (D89): the hosted home checks it against the artifact ID and both digests. */\n readonly versionId: string;\n /** Its number in the owner's home, kept in the hosted one. */\n readonly number: number;\n /** The source tree's digest (DATA_MODEL §2). */\n readonly sourceDigest: string;\n /** The environment's digest. */\n readonly envDigest: string;\n /** The output listing's digest: `listing` must hash to it. */\n readonly outputDigest: string;\n /** The version's `manifest.json`, as text. */\n readonly manifest: string;\n /** Its `registry.json`, as text. */\n readonly registry: string;\n /** Its `lock.yaml`, as text. */\n readonly lock: string;\n /** Every built file, server files included, as `[path, executable, sha256, size]`. */\n readonly listing: readonly ListingEntry[];\n /**\n * The submission policy in force for the artifact in the owner's home (D102), which its hosted\n * home follows: the owner's host decides it, never the server (D165 item 1).\n */\n readonly policy?: SubmissionPolicy;\n}\n\n/** The params of `hosted/push`. */\nexport interface HostedPushParams {\n /** The artifact, by its own ID (its manifest's). */\n readonly artifactId: string;\n /** The version to host. */\n readonly version: VersionPush;\n /** Makes a retry idempotent; the push is idempotent by version ID anyway. */\n readonly requestId?: string;\n}\n\n/** An artifact's hosted route: its `rte_` ID and random label (INTERFACES §18.4). */\nexport interface HostedRoute {\n /** The route's `rte_` ID, in the hosted shell's paths (`/a/<routeId>`). */\n readonly routeId: string;\n /** The route's DNS label on the user-content domain, never issued twice. */\n readonly label: string;\n}\n\n/** The result of `hosted/push`: the files the server still lacks, or the hosted version. */\nexport type HostedPushResult =\n | {\n readonly status: \"complete\";\n readonly versionId: string;\n readonly number: number;\n readonly route: HostedRoute;\n }\n | { readonly status: \"missing\"; readonly files: readonly string[]; readonly route: HostedRoute };\n\nconst Sha256 = z.string().regex(/^[0-9a-f]{64}$/);\n\n/** The Zod schema of the `VersionPush` type. */\nexport const VersionPush: z.ZodType<VersionPush> = z\n .object({\n versionId: z.string().min(1),\n number: z.int().min(1),\n sourceDigest: Sha256,\n envDigest: Sha256,\n outputDigest: Sha256,\n manifest: z.string().max(4 * 1024 * 1024),\n registry: z.string().max(16 * 1024 * 1024),\n lock: z.string().max(16 * 1024 * 1024),\n listing: z\n .array(z.tuple([z.string().min(1), z.boolean(), Sha256, z.int().min(0)]).readonly())\n .max(100_000)\n .readonly(),\n policy: SubmissionPolicy.exactOptional(),\n })\n .register(wireRegistry, {\n id: \"VersionPush\",\n description:\n \"A version an owner pushes to its hosted home: its identity, manifest, registry, lockfile and output listing.\",\n });\n\n/** The Zod schema of the `HostedRoute` type. */\nexport const HostedRoute: z.ZodType<HostedRoute> = z\n .object({ routeId: z.string(), label: z.string() })\n .register(wireRegistry, {\n id: \"HostedRoute\",\n description: \"An artifact's hosted route: its rte_ ID and random label.\",\n });\n\nconst params: z.ZodType<HostedPushParams> = z\n .object({\n artifactId: ArtifactId.schema,\n version: VersionPush,\n requestId: z.string().min(1).exactOptional(),\n })\n .register(wireRegistry, { id: \"HostedPushParams\" });\n\nconst result: z.ZodType<HostedPushResult> = z\n .discriminatedUnion(\"status\", [\n z.object({\n status: z.literal(\"complete\"),\n versionId: z.string(),\n number: z.int(),\n route: HostedRoute,\n }),\n z.object({\n status: z.literal(\"missing\"),\n files: z.array(Sha256).readonly(),\n route: HostedRoute,\n }),\n ])\n .register(wireRegistry, {\n id: \"HostedPushResult\",\n description: \"A push's state: the client files the server still lacks, or the hosted version.\",\n });\n\n/**\n * `hosted/push`: on a hosted home, makes a version of the owner's artifact hosted (D165 item 3).\n * The server stores the client files the listing names, never the server files, and answers the\n * SHA-256s it lacks until every client file was uploaded to `/files/<sha256>`. Idempotent by\n * `versionId`; it mints the artifact's hosted route on the first push.\n */\nexport const hostedPushMethod: MethodDefinition<HostedPushParams, HostedPushResult> = defineMethod({\n method: \"hosted/push\",\n direction: \"client-to-instance\",\n mutating: true,\n params,\n result,\n});\n"],"mappings":";;;;;;AAyEA,MAAM,SAAS,EAAE,OAAO,CAAC,CAAC,MAAM,gBAAgB;;AAGhD,MAAa,cAAsC,EAChD,OAAO;CACN,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAC3B,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;CACrB,cAAc;CACd,WAAW;CACX,cAAc;CACd,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,OAAe;CACxC,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,QAAgB;CACzC,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,QAAgB;CACrC,SAAS,EACN,MAAM,EAAE,MAAM;EAAC,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;EAAG,EAAE,QAAQ;EAAG;EAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CACnF,IAAI,GAAO,CAAC,CACZ,SAAS;CACZ,QAAQ,iBAAiB,cAAc;AACzC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aACE;AACJ,CAAC;;AAGH,MAAa,cAAsC,EAChD,OAAO;CAAE,SAAS,EAAE,OAAO;CAAG,OAAO,EAAE,OAAO;AAAE,CAAC,CAAC,CAClD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;AAEH,MAAM,SAAsC,EACzC,OAAO;CACN,YAAY,WAAW;CACvB,SAAS;CACT,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;AAC7C,CAAC,CAAC,CACD,SAAS,cAAc,EAAE,IAAI,mBAAmB,CAAC;AAEpD,MAAM,SAAsC,EACzC,mBAAmB,UAAU,CAC5B,EAAE,OAAO;CACP,QAAQ,EAAE,QAAQ,UAAU;CAC5B,WAAW,EAAE,OAAO;CACpB,QAAQ,EAAE,IAAI;CACd,OAAO;AACT,CAAC,GACD,EAAE,OAAO;CACP,QAAQ,EAAE,QAAQ,SAAS;CAC3B,OAAO,EAAE,MAAM,MAAM,CAAC,CAAC,SAAS;CAChC,OAAO;AACT,CAAC,CACH,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;;;;;;AAQH,MAAa,mBAAyE,aAAa;CACjG,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA;AACF,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { MethodDefinition } from "../../method.js";
2
+ import { SubmissionEnvelope } from "../port/submissions-deliver.js";
3
+ //#region src/methods/hosted/submission.d.ts
4
+ /** The params of `hosted/submission` (INTERFACES §18.2). */
5
+ export interface HostedSubmissionParams {
6
+ /** The hosted submission the owner instance is missing. */
7
+ readonly submissionId: string;
8
+ }
9
+ /** The result of `hosted/submission`: the submission as its delivery to this owner carries it. */
10
+ export type HostedSubmissionResult = SubmissionEnvelope;
11
+ /**
12
+ * `hosted/submission`: an owner instance reads one of its artifacts' hosted submissions again,
13
+ * with its snapshot, when it follows a `submission.created` it doesn't hold (its home was restored
14
+ * from a backup taken before it, FAILURE_MODEL §11.2), and imports it as a delivery would.
15
+ */
16
+ export declare const hostedSubmissionMethod: MethodDefinition<HostedSubmissionParams, HostedSubmissionResult>;
17
+ //#endregion
18
+ //# sourceMappingURL=submission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"submission.d.ts","names":[],"sources":["../../../src/methods/hosted/submission.ts"],"mappings":";;;;iBAOiB;;WAEN;;;YAIC,yBAAyB;;;;;;qBAWxB,wBAAwB,iBACnC,wBACA"}
@@ -0,0 +1,23 @@
1
+ import { wireRegistry } from "../../wire-registry.js";
2
+ import { SubmissionId } from "../../ids.js";
3
+ import { defineMethod } from "../../method.js";
4
+ import { SubmissionEnvelope } from "../port/submissions-deliver.js";
5
+ import * as z from "zod";
6
+ //#region src/methods/hosted/submission.ts
7
+ const params = z.object({ submissionId: SubmissionId.schema }).register(wireRegistry, { id: "HostedSubmissionParams" });
8
+ /**
9
+ * `hosted/submission`: an owner instance reads one of its artifacts' hosted submissions again,
10
+ * with its snapshot, when it follows a `submission.created` it doesn't hold (its home was restored
11
+ * from a backup taken before it, FAILURE_MODEL §11.2), and imports it as a delivery would.
12
+ */
13
+ const hostedSubmissionMethod = defineMethod({
14
+ method: "hosted/submission",
15
+ direction: "client-to-instance",
16
+ mutating: false,
17
+ params,
18
+ result: SubmissionEnvelope
19
+ });
20
+ //#endregion
21
+ export { hostedSubmissionMethod };
22
+
23
+ //# sourceMappingURL=submission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"submission.js","names":[],"sources":["../../../src/methods/hosted/submission.ts"],"sourcesContent":["import * as z from \"zod\";\nimport { SubmissionId } from \"../../ids.ts\";\nimport { defineMethod, type MethodDefinition } from \"../../method.ts\";\nimport { wireRegistry } from \"../../wire-registry.ts\";\nimport { SubmissionEnvelope } from \"../port/submissions-deliver.ts\";\n\n/** The params of `hosted/submission` (INTERFACES §18.2). */\nexport interface HostedSubmissionParams {\n /** The hosted submission the owner instance is missing. */\n readonly submissionId: string;\n}\n\n/** The result of `hosted/submission`: the submission as its delivery to this owner carries it. */\nexport type HostedSubmissionResult = SubmissionEnvelope;\n\nconst params: z.ZodType<HostedSubmissionParams> = z\n .object({ submissionId: SubmissionId.schema })\n .register(wireRegistry, { id: \"HostedSubmissionParams\" });\n\n/**\n * `hosted/submission`: an owner instance reads one of its artifacts' hosted submissions again,\n * with its snapshot, when it follows a `submission.created` it doesn't hold (its home was restored\n * from a backup taken before it, FAILURE_MODEL §11.2), and imports it as a delivery would.\n */\nexport const hostedSubmissionMethod: MethodDefinition<\n HostedSubmissionParams,\n HostedSubmissionResult\n> = defineMethod({\n method: \"hosted/submission\",\n direction: \"client-to-instance\",\n mutating: false,\n params,\n result: SubmissionEnvelope,\n});\n"],"mappings":";;;;;;AAeA,MAAM,SAA4C,EAC/C,OAAO,EAAE,cAAc,aAAa,OAAO,CAAC,CAAC,CAC7C,SAAS,cAAc,EAAE,IAAI,yBAAyB,CAAC;;;;;;AAO1D,MAAa,yBAGT,aAAa;CACf,QAAQ;CACR,WAAW;CACX,UAAU;CACV;CACA,QAAQ;AACV,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/methods/index.ts"],"mappings":";;;qBAiDa,sBAAsB;;qBA6CtB,4BAA4B"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/methods/index.ts"],"mappings":";;;qBAmEa,sBAAsB;;qBA+DtB,4BAA4B"}