@mostra/protocol 0.10.0 → 0.12.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 (129) hide show
  1. package/dist/actions.d.ts +11 -3
  2. package/dist/actions.d.ts.map +1 -1
  3. package/dist/actions.js.map +1 -1
  4. package/dist/browser.d.ts +43 -1
  5. package/dist/browser.d.ts.map +1 -1
  6. package/dist/browser.js +29 -1
  7. package/dist/browser.js.map +1 -1
  8. package/dist/diagnostics/codes/action.d.ts +1 -1
  9. package/dist/diagnostics/codes/action.d.ts.map +1 -1
  10. package/dist/diagnostics/codes/action.js +12 -1
  11. package/dist/diagnostics/codes/action.js.map +1 -1
  12. package/dist/diagnostics/codes/index.d.ts +3 -2
  13. package/dist/diagnostics/codes/index.d.ts.map +1 -1
  14. package/dist/diagnostics/codes/index.js +3 -1
  15. package/dist/diagnostics/codes/index.js.map +1 -1
  16. package/dist/diagnostics/codes/remote.d.ts +1 -1
  17. package/dist/diagnostics/codes/remote.d.ts.map +1 -1
  18. package/dist/diagnostics/codes/remote.js +78 -1
  19. package/dist/diagnostics/codes/remote.js.map +1 -1
  20. package/dist/diagnostics/codes/submit.d.ts +1 -1
  21. package/dist/diagnostics/codes/submit.d.ts.map +1 -1
  22. package/dist/diagnostics/codes/submit.js +12 -1
  23. package/dist/diagnostics/codes/submit.js.map +1 -1
  24. package/dist/diagnostics/codes/team.d.ts +8 -0
  25. package/dist/diagnostics/codes/team.d.ts.map +1 -0
  26. package/dist/diagnostics/codes/team.js +44 -0
  27. package/dist/diagnostics/codes/team.js.map +1 -0
  28. package/dist/diagnostics/diagnostic.d.ts +1 -1
  29. package/dist/diagnostics/diagnostic.d.ts.map +1 -1
  30. package/dist/diagnostics/diagnostic.js +2 -1
  31. package/dist/diagnostics/diagnostic.js.map +1 -1
  32. package/dist/index.d.ts +17 -7
  33. package/dist/index.js +14 -4
  34. package/dist/interaction.d.ts +17 -3
  35. package/dist/interaction.d.ts.map +1 -1
  36. package/dist/interaction.js +17 -13
  37. package/dist/interaction.js.map +1 -1
  38. package/dist/manifest.d.ts +3 -0
  39. package/dist/manifest.d.ts.map +1 -1
  40. package/dist/manifest.js +5 -2
  41. package/dist/manifest.js.map +1 -1
  42. package/dist/methods/artifact/pause.d.ts +33 -0
  43. package/dist/methods/artifact/pause.d.ts.map +1 -0
  44. package/dist/methods/artifact/pause.js +33 -0
  45. package/dist/methods/artifact/pause.js.map +1 -0
  46. package/dist/methods/index.d.ts.map +1 -1
  47. package/dist/methods/index.js +16 -2
  48. package/dist/methods/index.js.map +1 -1
  49. package/dist/methods/port/relay-author.d.ts +28 -0
  50. package/dist/methods/port/relay-author.d.ts.map +1 -0
  51. package/dist/methods/port/relay-author.js +42 -0
  52. package/dist/methods/port/relay-author.js.map +1 -0
  53. package/dist/methods/port/trusted-controls-policy.d.ts +1 -1
  54. package/dist/methods/remote/link.d.ts +40 -0
  55. package/dist/methods/remote/link.d.ts.map +1 -0
  56. package/dist/methods/remote/link.js +40 -0
  57. package/dist/methods/remote/link.js.map +1 -0
  58. package/dist/methods/results/get.d.ts +3 -1
  59. package/dist/methods/results/get.d.ts.map +1 -1
  60. package/dist/methods/results/get.js +4 -3
  61. package/dist/methods/results/get.js.map +1 -1
  62. package/dist/methods/results/list.d.ts +33 -0
  63. package/dist/methods/results/list.d.ts.map +1 -0
  64. package/dist/methods/results/list.js +35 -0
  65. package/dist/methods/results/list.js.map +1 -0
  66. package/dist/methods/roster/add.d.ts +47 -0
  67. package/dist/methods/roster/add.d.ts.map +1 -0
  68. package/dist/methods/roster/add.js +46 -0
  69. package/dist/methods/roster/add.js.map +1 -0
  70. package/dist/methods/roster/get.d.ts +18 -0
  71. package/dist/methods/roster/get.d.ts.map +1 -0
  72. package/dist/methods/roster/get.js +22 -0
  73. package/dist/methods/roster/get.js.map +1 -0
  74. package/dist/methods/roster/remove.d.ts +28 -0
  75. package/dist/methods/roster/remove.d.ts.map +1 -0
  76. package/dist/methods/roster/remove.js +31 -0
  77. package/dist/methods/roster/remove.js.map +1 -0
  78. package/dist/methods/share/start.d.ts +15 -2
  79. package/dist/methods/share/start.d.ts.map +1 -1
  80. package/dist/methods/share/start.js +5 -1
  81. package/dist/methods/share/start.js.map +1 -1
  82. package/dist/methods/state/get.d.ts +1 -1
  83. package/dist/methods/state/patch.d.ts +1 -1
  84. package/dist/methods/view/url.d.ts +1 -1
  85. package/dist/methods/wait/wait.d.ts +1 -1
  86. package/dist/operator.d.ts +511 -0
  87. package/dist/operator.d.ts.map +1 -0
  88. package/dist/operator.js +134 -0
  89. package/dist/operator.js.map +1 -0
  90. package/dist/team-settings.d.ts +21 -0
  91. package/dist/team-settings.d.ts.map +1 -0
  92. package/dist/team-settings.js +27 -0
  93. package/dist/team-settings.js.map +1 -0
  94. package/dist/team.d.ts +221 -0
  95. package/dist/team.d.ts.map +1 -0
  96. package/dist/team.js +162 -0
  97. package/dist/team.js.map +1 -0
  98. package/dist/verify.d.ts +7 -0
  99. package/dist/verify.d.ts.map +1 -1
  100. package/dist/verify.js.map +1 -1
  101. package/dist/worker.d.ts +1 -1
  102. package/package.json +11 -1
  103. package/schemas/protocol.draft-07.json +1027 -45
  104. package/schemas/protocol.schema.json +996 -46
  105. package/src/actions.ts +8 -4
  106. package/src/browser.ts +64 -0
  107. package/src/diagnostics/codes/action.ts +12 -0
  108. package/src/diagnostics/codes/index.ts +6 -2
  109. package/src/diagnostics/codes/remote.ts +84 -0
  110. package/src/diagnostics/codes/submit.ts +12 -0
  111. package/src/diagnostics/codes/team.ts +53 -0
  112. package/src/diagnostics/diagnostic.ts +3 -1
  113. package/src/index.ts +66 -2
  114. package/src/interaction.ts +30 -5
  115. package/src/manifest.ts +5 -0
  116. package/src/methods/artifact/pause.ts +59 -0
  117. package/src/methods/index.ts +14 -0
  118. package/src/methods/port/relay-author.ts +57 -0
  119. package/src/methods/remote/link.ts +65 -0
  120. package/src/methods/results/get.ts +3 -2
  121. package/src/methods/results/list.ts +61 -0
  122. package/src/methods/roster/add.ts +77 -0
  123. package/src/methods/roster/get.ts +30 -0
  124. package/src/methods/roster/remove.ts +49 -0
  125. package/src/methods/share/start.ts +23 -3
  126. package/src/operator.ts +660 -0
  127. package/src/team-settings.ts +38 -0
  128. package/src/team.ts +398 -0
  129. package/src/verify.ts +7 -0
package/src/actions.ts CHANGED
@@ -11,6 +11,7 @@
11
11
  import * as z from "zod";
12
12
  import { ViewId } from "./ids.ts";
13
13
  import type { Frame, WireError } from "./serializer.ts";
14
+ import type { PresenceState, RosterForPage } from "./team.ts";
14
15
  import { wireRegistry } from "./wire-registry.ts";
15
16
 
16
17
  /** A value written by the serializer: its batches, in order (`serializeAll`). */
@@ -270,13 +271,16 @@ export interface LiveUpdate {
270
271
  }
271
272
 
272
273
  /**
273
- * An ephemeral message on a page's event stream (SSE `event: run` or `event: live`, without an
274
- * `id`, so a reconnect's cursor is untouched) or in a poll's `ephemeral`: lossy, coalesced, and
275
- * never stored as an event.
274
+ * An ephemeral message on a page's event stream (SSE `event: run`, `live`, `respondents` or
275
+ * `presence`, without an `id`, so a reconnect's cursor is untouched) or in a poll's `ephemeral`:
276
+ * lossy, coalesced, and never stored as an event. `respondents` and `presence` (D168) reach only a
277
+ * page that asked for them, so a version built before them never receives one.
276
278
  */
277
279
  export type EphemeralMessage =
278
280
  | { readonly kind: "run"; readonly run: RunDelta }
279
- | { readonly kind: "live"; readonly live: LiveUpdate };
281
+ | { readonly kind: "live"; readonly live: LiveUpdate }
282
+ | { readonly kind: "respondents"; readonly respondents: RosterForPage }
283
+ | { readonly kind: "presence"; readonly presence: PresenceState };
280
284
 
281
285
  /** `POST …/call/{fnId}`: a plain server-function call, no durable record (D54). */
282
286
  export interface CallRequest {
package/src/browser.ts CHANGED
@@ -237,8 +237,65 @@ export interface FrameTicket extends ViewContext {
237
237
  * (D70, D158 item 5). Absent: cookie mode.
238
238
  */
239
239
  readonly mode?: "worker";
240
+ /**
241
+ * The artifact is paused (D165 item 14): the shell says so, by whom and why (the reason as text);
242
+ * it takes no submissions and runs no actions until it is resumed (WP-30).
243
+ */
244
+ readonly paused?: { readonly by: "owner" | "operator"; readonly reason?: string };
245
+ /** On a remote server: what the hosted shell's trusted chrome shows around the page (D161). */
246
+ readonly hosted?: HostedChrome;
240
247
  }
241
248
 
249
+ /**
250
+ * The hosted shell's trusted chrome for one view (D161, ARCHITECTURE §15.8; WP-30). Every string an
251
+ * owner or operator supplies is rendered as text, never as markup.
252
+ */
253
+ export interface HostedChrome {
254
+ /** Who sent the page: the owner's display name, and the provider that verified it, if any. */
255
+ readonly sender?: { readonly name: string; readonly verifiedBy?: string };
256
+ /** Who this browser is to the page: signed in as an account, or anonymous (with a chosen name). */
257
+ readonly viewer: {
258
+ readonly kind: "account" | "anonymous" | "named";
259
+ readonly name?: string;
260
+ readonly verified: boolean;
261
+ };
262
+ /** Whether "Sign in" is offered (the viewer isn't signed in, and the server has a provider). */
263
+ readonly signIn: boolean;
264
+ /** The operator's footer wording in place of the shell's own; never hidden on a public link. */
265
+ readonly footer?: string;
266
+ /** The operator's line after "Your answer was sent.". */
267
+ readonly afterSubmit?: string;
268
+ /** The made-with mark, where the operator shows one. */
269
+ readonly madeWith?: { readonly href?: string };
270
+ /** A page shown before the artifact, once per browser and link. */
271
+ readonly interstitial?: { readonly kind: string; readonly message?: string };
272
+ }
273
+
274
+ const HostedChrome: z.ZodType<HostedChrome> = z.object({
275
+ sender: z
276
+ .object({ name: z.string().max(256), verifiedBy: z.string().max(64).exactOptional() })
277
+ .exactOptional(),
278
+ viewer: z.object({
279
+ kind: z.enum(["account", "anonymous", "named"]),
280
+ name: z.string().max(256).exactOptional(),
281
+ verified: z.boolean(),
282
+ }),
283
+ signIn: z.boolean(),
284
+ footer: z.string().max(500).exactOptional(),
285
+ afterSubmit: z.string().max(500).exactOptional(),
286
+ madeWith: z
287
+ .object({
288
+ href: z
289
+ .url({ protocol: /^https$/ })
290
+ .max(2_048)
291
+ .exactOptional(),
292
+ })
293
+ .exactOptional(),
294
+ interstitial: z
295
+ .object({ kind: z.string().max(64), message: z.string().max(2_000).exactOptional() })
296
+ .exactOptional(),
297
+ });
298
+
242
299
  /** The Zod schema of the `FrameTicket` type. */
243
300
  export const FrameTicket: z.ZodType<FrameTicket> = z
244
301
  .object({
@@ -257,6 +314,13 @@ export const FrameTicket: z.ZodType<FrameTicket> = z
257
314
  serverParked: z.literal(true).exactOptional(),
258
315
  devPreview: z.literal(true).exactOptional(),
259
316
  mode: z.literal("worker").exactOptional(),
317
+ paused: z
318
+ .object({
319
+ by: z.enum(["owner", "operator"]),
320
+ reason: z.string().max(500).exactOptional(),
321
+ })
322
+ .exactOptional(),
323
+ hosted: HostedChrome.exactOptional(),
260
324
  })
261
325
  .register(wireRegistry, {
262
326
  id: "FrameTicket",
@@ -14,6 +14,7 @@ export const actionDiagnosticCodes = [
14
14
  "MOSTRA_ACTION_TOO_LARGE",
15
15
  "MOSTRA_ACTION_RUN_NOT_FOUND",
16
16
  "MOSTRA_ACTION_EVENT_INVALID",
17
+ "MOSTRA_ACTION_PAUSED",
17
18
  // gen:codes
18
19
  ] as const;
19
20
 
@@ -121,5 +122,16 @@ export const actionDiagnostics: AreaCatalog<ActionDiagnosticCode> = {
121
122
  fix: "Use a type such as `host.reply-sent` and a small JSON payload. Put larger data in artifact state or a live source and send its key in the event.",
122
123
  },
123
124
  },
125
+ MOSTRA_ACTION_PAUSED: {
126
+ severity: "error",
127
+ phase: "host",
128
+ title: "Artifact paused, no actions run",
129
+ hint: "Wait until the page is resumed, then run the action again.",
130
+ docs: {
131
+ explanation:
132
+ "The artifact is paused, so its actions don't run: the run or call was refused before anything was recorded or sent to the owner's machine.",
133
+ fix: "The owner resumes it with `mostra resume <artifact>`; a pause by the server's operator is resumed only by the operator.",
134
+ },
135
+ },
124
136
  // gen:entries
125
137
  };
@@ -22,7 +22,6 @@ import { type NetworkDiagnosticCode, networkDiagnostics } from "./network.ts";
22
22
  import { type PlatformDiagnosticCode, platformDiagnostics } from "./platform.ts";
23
23
  import { type PublishDiagnosticCode, publishDiagnostics } from "./publish.ts";
24
24
  import { type RegressionDiagnosticCode, regressionDiagnostics } from "./regression.ts";
25
- // gen:area-imports
26
25
  import { type RemoteDiagnosticCode, remoteDiagnostics } from "./remote.ts";
27
26
  import { type RuntimeDiagnosticCode, runtimeDiagnostics } from "./runtime.ts";
28
27
  import { type SecretDiagnosticCode, secretDiagnostics } from "./secret.ts";
@@ -30,6 +29,8 @@ import { type ShareDiagnosticCode, shareDiagnostics } from "./share.ts";
30
29
  import { type SmokeDiagnosticCode, smokeDiagnostics } from "./smoke.ts";
31
30
  import { type SubmitDiagnosticCode, submitDiagnostics } from "./submit.ts";
32
31
  import { type TargetDiagnosticCode, targetDiagnostics } from "./target.ts";
32
+ // gen:area-imports
33
+ import { type TeamDiagnosticCode, teamDiagnostics } from "./team.ts";
33
34
  import { type TypeDiagnosticCode, typeDiagnostics } from "./type.ts";
34
35
  import { type VerifyDiagnosticCode, verifyDiagnostics } from "./verify.ts";
35
36
 
@@ -51,7 +52,6 @@ export { type NetworkDiagnosticCode, networkDiagnosticCodes } from "./network.ts
51
52
  export { type PlatformDiagnosticCode, platformDiagnosticCodes } from "./platform.ts";
52
53
  export { type PublishDiagnosticCode, publishDiagnosticCodes } from "./publish.ts";
53
54
  export { type RegressionDiagnosticCode, regressionDiagnosticCodes } from "./regression.ts";
54
- // gen:area-exports
55
55
  export { type RemoteDiagnosticCode, remoteDiagnosticCodes } from "./remote.ts";
56
56
  export { type RuntimeDiagnosticCode, runtimeDiagnosticCodes } from "./runtime.ts";
57
57
  export { type SecretDiagnosticCode, secretDiagnosticCodes } from "./secret.ts";
@@ -59,12 +59,15 @@ export { type ShareDiagnosticCode, shareDiagnosticCodes } from "./share.ts";
59
59
  export { type SmokeDiagnosticCode, smokeDiagnosticCodes } from "./smoke.ts";
60
60
  export { type SubmitDiagnosticCode, submitDiagnosticCodes } from "./submit.ts";
61
61
  export { type TargetDiagnosticCode, targetDiagnosticCodes } from "./target.ts";
62
+ // gen:area-exports
63
+ export { type TeamDiagnosticCode, teamDiagnosticCodes } from "./team.ts";
62
64
  export { type TypeDiagnosticCode, typeDiagnosticCodes } from "./type.ts";
63
65
  export { type VerifyDiagnosticCode, verifyDiagnosticCodes } from "./verify.ts";
64
66
 
65
67
  /** Every code in the catalog. Codes are semver surface and are never removed (AX-03). */
66
68
  export type KnownDiagnosticCode =
67
69
  // gen:area-codes
70
+ | TeamDiagnosticCode
68
71
  | RemoteDiagnosticCode
69
72
  | ShareDiagnosticCode
70
73
  | CliDiagnosticCode
@@ -96,6 +99,7 @@ export type KnownDiagnosticCode =
96
99
  /** Every cataloged code with its severity, phase, title, default hint and docs text. */
97
100
  export const diagnosticCatalog: Readonly<Record<KnownDiagnosticCode, DiagnosticSpec>> = {
98
101
  // gen:area-spreads
102
+ ...teamDiagnostics,
99
103
  ...remoteDiagnostics,
100
104
  ...shareDiagnostics,
101
105
  ...cliDiagnostics,
@@ -13,6 +13,13 @@ export const remoteDiagnosticCodes = [
13
13
  "MOSTRA_REMOTE_NOT_OWNER_INSTANCE",
14
14
  "MOSTRA_REMOTE_SIGN_IN_REQUIRED",
15
15
  "MOSTRA_REMOTE_RATE_LIMITED",
16
+ "MOSTRA_REMOTE_PAUSED_BY_OPERATOR",
17
+ "MOSTRA_REMOTE_LIMIT_REACHED",
18
+ "MOSTRA_REMOTE_OPERATOR_UNAVAILABLE",
19
+ "MOSTRA_REMOTE_NO_INSTANCE",
20
+ "MOSTRA_REMOTE_UNDER_REVIEW",
21
+ "MOSTRA_REMOTE_HOME_SUSPENDED",
22
+ "MOSTRA_REMOTE_HOME_MOVING",
16
23
  // gen:codes
17
24
  ] as const;
18
25
 
@@ -109,5 +116,82 @@ export const remoteDiagnostics: AreaCatalog<RemoteDiagnosticCode> = {
109
116
  fix: "Wait for the `Retry-After` the answer carries and try again. The limits are the server's `rateLimits` settings.",
110
117
  },
111
118
  },
119
+ MOSTRA_REMOTE_PAUSED_BY_OPERATOR: {
120
+ severity: "error",
121
+ phase: "host",
122
+ title: "Paused by the server's operator",
123
+ hint: "Contact the server's operator: only the operator resumes a pause it made.",
124
+ docs: {
125
+ explanation:
126
+ "The server's operator paused this hosted artifact, and an owner can't undo an operator's pause (D165 item 14). Views keep working and the links stay valid.",
127
+ fix: "Ask the server's operator why it was paused and to resume it.",
128
+ },
129
+ },
130
+ MOSTRA_REMOTE_LIMIT_REACHED: {
131
+ severity: "error",
132
+ phase: "host",
133
+ title: "The server's limit refused this",
134
+ hint: "Read the message for the server's limit, and try again once it allows the operation.",
135
+ docs: {
136
+ explanation:
137
+ "The server's operator refused the operation for this account (its `limits` port): a share, a version push, a link, a view, a submission, an action or an MCP call. The message is the operator's own. A refused submission keeps its draft.",
138
+ fix: "Follow the operator's message; its `Retry-After`, when present, says when to try again.",
139
+ },
140
+ },
141
+ MOSTRA_REMOTE_OPERATOR_UNAVAILABLE: {
142
+ severity: "error",
143
+ phase: "host",
144
+ title: "The server's operator didn't answer",
145
+ hint: "Try again in a moment; the server's operator didn't answer in time.",
146
+ docs: {
147
+ explanation:
148
+ "The server's operator module didn't answer in time (2 s for limits, 5 s for sign-in), so an operation that creates something (a share, a push, a link, authoring, a sign-in) was refused rather than allowed blind. Views, drafts and submissions never wait for it, and existing sessions keep working.",
149
+ fix: "Try again; if it lasts, the server's operator has to fix its operator module.",
150
+ },
151
+ },
152
+ MOSTRA_REMOTE_NO_INSTANCE: {
153
+ severity: "error",
154
+ phase: "host",
155
+ title: "No owner instance connected",
156
+ hint: "Start Mostra on the machine linked to this account (mostra daemon start), then try again.",
157
+ docs: {
158
+ explanation:
159
+ "Creating, verifying and publishing from a chat host run on the account's default owner instance, through the relay (D165 item 5), and no default instance is connected to the server now. Reading tools (list, wait, results, state, docs, open) keep working.",
160
+ fix: "Start Mostra on the linked machine (`mostra daemon start`, or `mostra daemon install` to keep it running); link a machine first with `mostra login <server> --default`.",
161
+ },
162
+ },
163
+ MOSTRA_REMOTE_UNDER_REVIEW: {
164
+ severity: "error",
165
+ phase: "host",
166
+ title: "This page is under review",
167
+ hint: "Nothing to do here: the server's operator is reviewing this page.",
168
+ docs: {
169
+ explanation:
170
+ "The server's operator quarantined this hosted page, or this version of it, while it reviews it. Its data is kept; the page shows a neutral notice instead of its content until the operator releases it.",
171
+ fix: "The owner can ask the server's operator about the review.",
172
+ },
173
+ },
174
+ MOSTRA_REMOTE_HOME_SUSPENDED: {
175
+ severity: "error",
176
+ phase: "host",
177
+ title: "This account's pages are suspended",
178
+ hint: "Contact the server's operator: this account's pages are suspended.",
179
+ docs: {
180
+ explanation:
181
+ "The server's operator suspended this account's hosted home: its pages, its owner instances' bindings, pushes and links are refused until the operator resumes it. Nothing was deleted.",
182
+ fix: "Ask the server's operator to resume the account.",
183
+ },
184
+ },
185
+ MOSTRA_REMOTE_HOME_MOVING: {
186
+ severity: "error",
187
+ phase: "host",
188
+ title: "This account's pages are moving",
189
+ hint: "Try again in a minute: this account's pages are moving between machines.",
190
+ docs: {
191
+ explanation:
192
+ "The server's operator is moving this account's hosted home to another data directory (`drainHome`), so the home is closed here until it serves again. Clients retry; nothing is lost.",
193
+ fix: "Retry shortly; the move ends when the operator releases the home on its new machine.",
194
+ },
195
+ },
112
196
  // gen:entries
113
197
  };
@@ -13,6 +13,7 @@ export const submitDiagnosticCodes = [
13
13
  "MOSTRA_SUBMIT_SIGNAL_INVALID",
14
14
  "MOSTRA_SUBMIT_CHANNEL_DENIED",
15
15
  "MOSTRA_SUBMIT_BLOCKED",
16
+ "MOSTRA_SUBMIT_PAUSED",
16
17
  // gen:codes
17
18
  ] as const;
18
19
 
@@ -109,5 +110,16 @@ export const submitDiagnostics: AreaCatalog<SubmitDiagnosticCode> = {
109
110
  fix: "Show `useSubmit().blockers` next to your submit button, or let the shell list them by label. Answer the required fields, fix the invalid values, and keep or take the conflicting values, then submit again.",
110
111
  },
111
112
  },
113
+ MOSTRA_SUBMIT_PAUSED: {
114
+ severity: "error",
115
+ phase: "host",
116
+ title: "Artifact paused, no answers taken",
117
+ hint: "Wait until the page is resumed, then submit again; the draft is kept.",
118
+ docs: {
119
+ explanation:
120
+ "The artifact is paused (`mostra pause`, or its server's operator paused it). A paused artifact stays viewable and its links stay valid, but it takes no submissions until it is resumed. Nothing was recorded, and the draft stays as it was.",
121
+ fix: "The owner resumes it with `mostra resume <artifact>`; a pause by the server's operator is resumed only by the operator.",
122
+ },
123
+ },
112
124
  // gen:entries
113
125
  };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Diagnostic codes of the TEAM area.
3
+ */
4
+ import type { AreaCatalog } from "../spec.ts";
5
+
6
+ /** The codes of the TEAM area, in the order they were added. */
7
+ export const teamDiagnosticCodes = [
8
+ "MOSTRA_TEAM_ROSTER_POLICY",
9
+ "MOSTRA_TEAM_ROSTER_TOO_LARGE",
10
+ "MOSTRA_TEAM_PRESENCE_RATE_LIMITED",
11
+ // gen:codes
12
+ ] as const;
13
+
14
+ /** The codes of the TEAM area. */
15
+ export type TeamDiagnosticCode = (typeof teamDiagnosticCodes)[number];
16
+
17
+ /** The TEAM area's catalog entries. */
18
+ export const teamDiagnostics: AreaCatalog<TeamDiagnosticCode> = {
19
+ MOSTRA_TEAM_ROSTER_POLICY: {
20
+ severity: "error",
21
+ phase: "host",
22
+ title: "This artifact's policy can't wait for every respondent",
23
+ hint: "Publish with the submission policy once per-viewer or epochs, then wait again; or wait for submitted.",
24
+ docs: {
25
+ explanation:
26
+ "`submitted:all` waits until every expected respondent has submitted, and `submitted:<N>` for N submissions. Both need a policy that takes a submission from each person: `once` with scope `per-viewer`, or `epochs`. Under `once` per-artifact the artifact takes one submission in all, so neither can be met beyond the first, and Mostra refuses the wait instead of letting it run forever.",
27
+ fix: "Publish again with `mostra publish <path> --policy once-per-viewer` (or `--policy epochs`), or wait for `submitted`.",
28
+ },
29
+ },
30
+ MOSTRA_TEAM_ROSTER_TOO_LARGE: {
31
+ severity: "error",
32
+ phase: "host",
33
+ title: "Roster larger than 1,000 respondents",
34
+ hint: "Name at most 1,000 expected respondents; share one link for everyone else instead.",
35
+ docs: {
36
+ explanation:
37
+ "A roster lists the people an artifact expects answers from, each with a personal link and a status. It holds at most 1,000 of them. Nothing was added: the roster is as it was.",
38
+ fix: "Remove respondents you no longer expect (`mostra roster remove`), or, for a page many people answer, share one link and wait for `submitted:<N>` instead.",
39
+ },
40
+ },
41
+ MOSTRA_TEAM_PRESENCE_RATE_LIMITED: {
42
+ severity: "error",
43
+ phase: "hygiene",
44
+ title: "Presence updates too fast",
45
+ hint: "Send presence at most 10 times a second; usePresence does this for you.",
46
+ docs: {
47
+ explanation:
48
+ "A page shares its viewer's cursor and selection through `POST /_mostra/v/<rev>/presence`. Each view may send 20 updates a second; past that the gateway answers 429 with `Retry-After`. Presence is never stored, so nothing is lost: the next update replaces the last one.",
49
+ fix: "Use `usePresence` from `@mostra/react`, which sends at most 10 updates a second, or throttle your own calls to the route.",
50
+ },
51
+ },
52
+ // gen:entries
53
+ };
@@ -40,7 +40,8 @@ export type DiagnosticArea =
40
40
  | "PLATFORM"
41
41
  | "ARTIFACT"
42
42
  | "CLI"
43
- | "REMOTE";
43
+ | "REMOTE"
44
+ | "TEAM";
44
45
 
45
46
  /** Every diagnostic area, in INTERFACES §13 order. */
46
47
  export const DIAGNOSTIC_AREAS: readonly DiagnosticArea[] = [
@@ -75,6 +76,7 @@ export const DIAGNOSTIC_AREAS: readonly DiagnosticArea[] = [
75
76
  "ARTIFACT",
76
77
  "CLI",
77
78
  "REMOTE",
79
+ "TEAM",
78
80
  ];
79
81
 
80
82
  /**
package/src/index.ts CHANGED
@@ -105,6 +105,7 @@ export {
105
105
  FRAME_SESSION_HEADER,
106
106
  FrameSessionFacts,
107
107
  FrameTicket,
108
+ type HostedChrome,
108
109
  OrphanedField,
109
110
  PollResult,
110
111
  REVIEW_SET_ID_PATTERN,
@@ -194,8 +195,10 @@ export {
194
195
  smokeDiagnosticCodes,
195
196
  submitDiagnosticCodes,
196
197
  type TargetDiagnosticCode,
198
+ type TeamDiagnosticCode,
197
199
  type TypeDiagnosticCode,
198
200
  targetDiagnosticCodes,
201
+ teamDiagnosticCodes,
199
202
  typeDiagnosticCodes,
200
203
  type VerifyDiagnosticCode,
201
204
  verifyDiagnosticCodes,
@@ -282,7 +285,7 @@ export {
282
285
  SubmitChannel,
283
286
  TrustedControl,
284
287
  Viewer,
285
- type ViewerKind,
288
+ ViewerKind,
286
289
  ViewerSpec,
287
290
  type Viewport,
288
291
  WaitCondition,
@@ -338,6 +341,12 @@ export {
338
341
  type ArtifactListResult,
339
342
  artifactListMethod,
340
343
  } from "./methods/artifact/list.ts";
344
+ export {
345
+ type ArtifactPauseParams,
346
+ type ArtifactPauseResult,
347
+ artifactPauseMethod,
348
+ type PausedBy,
349
+ } from "./methods/artifact/pause.ts";
341
350
  export {
342
351
  type ArtifactPublishParams,
343
352
  type ArtifactPublishResult,
@@ -462,6 +471,13 @@ export {
462
471
  type PortIdentityResolveResult,
463
472
  portIdentityResolveMethod,
464
473
  } from "./methods/port/identity-resolve.ts";
474
+ export {
475
+ type PortRelayAuthorParams,
476
+ type PortRelayAuthorResult,
477
+ portRelayAuthorMethod,
478
+ RELAY_AUTHOR_METHODS,
479
+ type RelayAuthorMethod,
480
+ } from "./methods/port/relay-author.ts";
465
481
  export {
466
482
  type PortRelayCallParams,
467
483
  type PortRelayCallResult,
@@ -531,6 +547,11 @@ export {
531
547
  type RelayRunUpdateResult,
532
548
  relayRunUpdateMethod,
533
549
  } from "./methods/relay/run-update.ts";
550
+ export {
551
+ type RemoteLinkParams,
552
+ type RemoteLinkResult,
553
+ remoteLinkMethod,
554
+ } from "./methods/remote/link.ts";
534
555
  export {
535
556
  type RemoteLoginParams,
536
557
  type RemoteLoginResult,
@@ -558,10 +579,32 @@ export {
558
579
  } from "./methods/remote/token.ts";
559
580
  export {
560
581
  type ResultsGetParams,
561
- type ResultsGetResult,
582
+ ResultsGetResult,
562
583
  ResultsMarkdown,
563
584
  resultsGetMethod,
564
585
  } from "./methods/results/get.ts";
586
+ export {
587
+ RESULTS_LIST_MAX,
588
+ type ResultsListParams,
589
+ type ResultsListResult,
590
+ resultsListMethod,
591
+ } from "./methods/results/list.ts";
592
+ export {
593
+ RespondentLink,
594
+ type RosterAddParams,
595
+ type RosterAddResult,
596
+ rosterAddMethod,
597
+ } from "./methods/roster/add.ts";
598
+ export {
599
+ type RosterGetParams,
600
+ type RosterGetResult,
601
+ rosterGetMethod,
602
+ } from "./methods/roster/get.ts";
603
+ export {
604
+ type RosterRemoveParams,
605
+ type RosterRemoveResult,
606
+ rosterRemoveMethod,
607
+ } from "./methods/roster/remove.ts";
565
608
  export {
566
609
  type SecretDeleteParams,
567
610
  type SecretDeleteResult,
@@ -691,6 +734,27 @@ export {
691
734
  type WireError,
692
735
  wireError,
693
736
  } from "./serializer.ts";
737
+ export {
738
+ DEFAULT_TEAM_VISIBILITY,
739
+ type Peer,
740
+ PRESENCE_COORDINATE_MAX,
741
+ PresenceCursor,
742
+ PresencePeer,
743
+ PresenceRequest,
744
+ PresenceSelection,
745
+ PresenceState,
746
+ Respondent,
747
+ RespondentForPage,
748
+ RespondentSpec,
749
+ RespondentStatus,
750
+ RespondentsRequest,
751
+ ROSTER_MAX,
752
+ Roster,
753
+ RosterCounts,
754
+ RosterForPage,
755
+ TeamSettings,
756
+ TeamVisibility,
757
+ } from "./team.ts";
694
758
  export {
695
759
  ARTIFACT_PROGRESS,
696
760
  ArtifactProgressParams,
@@ -29,6 +29,16 @@ export { ControlsPolicy, SubmitChannel, TrustedControl } from "./view.ts";
29
29
  */
30
30
  export type ViewerKind = "local" | "tailnet" | "token" | "host" | "account" | "anonymous";
31
31
 
32
+ /** The Zod schema of the `ViewerKind` type (inlined where it is used, never a definition of its own). */
33
+ export const ViewerKind: z.ZodType<ViewerKind> = z.enum([
34
+ "local",
35
+ "tailnet",
36
+ "token",
37
+ "host",
38
+ "account",
39
+ "anonymous",
40
+ ]);
41
+
32
42
  /**
33
43
  * A person who views an artifact (PRODUCT vocabulary). The home's local user is one viewer of kind
34
44
  * `local`; a link minted with `viewer` acts as a viewer of kind `token` (D104).
@@ -42,15 +52,21 @@ export interface Viewer {
42
52
  readonly name?: string;
43
53
  /** The host's own key for this person, as given to `view/url` (D104). */
44
54
  readonly ref?: string;
55
+ /**
56
+ * Whether an identity provider verified the name: `true` for a signed-in account, `false` for an
57
+ * anonymous viewer's self-chosen name (hosted links, D165 item 8). Absent for other kinds.
58
+ */
59
+ readonly verified?: boolean;
45
60
  }
46
61
 
47
62
  /** The Zod schema of the `Viewer` type. */
48
63
  export const Viewer: z.ZodType<Viewer> = z
49
64
  .object({
50
65
  id: ViewerId.schema,
51
- kind: z.enum(["local", "tailnet", "token", "host", "account", "anonymous"]),
66
+ kind: ViewerKind,
52
67
  name: z.string().exactOptional(),
53
68
  ref: z.string().exactOptional(),
69
+ verified: z.boolean().exactOptional(),
54
70
  })
55
71
  .register(wireRegistry, {
56
72
  id: "Viewer",
@@ -87,6 +103,12 @@ export interface Actor {
87
103
  readonly id?: string;
88
104
  /** A display name, when one is known. */
89
105
  readonly name?: string;
106
+ /**
107
+ * For a viewer, as a page sees another one (D168): an opaque key, stable for that viewer of this
108
+ * artifact, never their viewer ID (D104), so attribution, respondents and presence name one person
109
+ * alike.
110
+ */
111
+ readonly key?: string;
90
112
  }
91
113
 
92
114
  /** The Zod schema of the `Actor` type. */
@@ -95,6 +117,7 @@ export const Actor: z.ZodType<Actor> = z
95
117
  kind: z.enum(["viewer", "agent", "host", "mostra"]),
96
118
  id: z.string().exactOptional(),
97
119
  name: z.string().exactOptional(),
120
+ key: z.string().exactOptional(),
98
121
  })
99
122
  .register(wireRegistry, {
100
123
  id: "Actor",
@@ -381,8 +404,9 @@ export const EventFilter: z.ZodType<EventFilter> = z
381
404
  });
382
405
 
383
406
  /**
384
- * What `wait` waits for (ARCHITECTURE §6, D103): `submitted`, `signal:<name>`, `state:<fieldId>`
385
- * or `event:<type pattern>`.
407
+ * What `wait` waits for (ARCHITECTURE §6, D103, D168): `submitted`, `submitted:all` (every expected
408
+ * respondent submitted: the roster completed), `submitted:<N>` (N submissions, 1 to 10,000),
409
+ * `signal:<name>`, `state:<fieldId>` or `event:<type pattern>`.
386
410
  */
387
411
  export type WaitCondition = string;
388
412
 
@@ -394,11 +418,12 @@ export const WaitCondition: z.ZodType<WaitCondition> = z
394
418
  .string()
395
419
  .regex(
396
420
  // biome-ignore lint/suspicious/noControlCharactersInRegex: field IDs exclude control characters.
397
- /^(submitted|signal:[A-Za-z0-9][A-Za-z0-9._-]{0,63}|state:[^\u0000-\u001f\u007f]{1,256}|event:[a-z][a-zA-Z0-9_-]*(\.[a-zA-Z0-9_-]+)*(\.\*)?)$/,
421
+ /^(?:(submitted|signal:[A-Za-z0-9][A-Za-z0-9._-]{0,63}|state:[^\u0000-\u001f\u007f]{1,256}|event:[a-z][a-zA-Z0-9_-]*(\.[a-zA-Z0-9_-]+)*(\.\*)?)$|submitted:(?:all|[1-9][0-9]{0,3}|10000)$)/,
398
422
  )
399
423
  .register(wireRegistry, {
400
424
  id: "WaitCondition",
401
- description: "What wait waits for: submitted, signal:<name>, state:<fieldId> or event:<type>.",
425
+ description:
426
+ "What wait waits for: submitted, submitted:all, submitted:<N>, signal:<name>, state:<fieldId> or event:<type>.",
402
427
  });
403
428
 
404
429
  // ── Submissions, deliveries and results ──────────────────────────────────────────────────
package/src/manifest.ts CHANGED
@@ -15,6 +15,7 @@ import { SubmissionPolicy } from "./policy.ts";
15
15
  export { SubmissionPolicy };
16
16
 
17
17
  import { ArtifactId } from "./ids.ts";
18
+ import { TeamSettings } from "./team-settings.ts";
18
19
  import { wireRegistry } from "./wire-registry.ts";
19
20
 
20
21
  /** The families Mostra's templates and gallery know; any other string is allowed too. */
@@ -144,6 +145,8 @@ export interface ArtifactManifest {
144
145
  readonly tally?: readonly TallySpec[];
145
146
  /** How the artifact behaves on a remote server (D165). */
146
147
  readonly hosted?: HostedSettings;
148
+ /** Team settings: what viewers see of each other's status and presence (D168). */
149
+ readonly team?: TeamSettings;
147
150
  }
148
151
 
149
152
  /** The keys of the artifact manifest, in INTERFACES §2.2 order. Other keys are warnings (FAILURE_MODEL §10). */
@@ -162,6 +165,7 @@ export const ARTIFACT_MANIFEST_KEYS: readonly (keyof ArtifactManifest)[] = [
162
165
  "verify",
163
166
  "tally",
164
167
  "hosted",
168
+ "team",
165
169
  ];
166
170
 
167
171
  const strings = z.array(z.string()).readonly();
@@ -264,6 +268,7 @@ export const ArtifactManifest: z.ZodType<ArtifactManifest> = z
264
268
  .exactOptional(),
265
269
  tally: z.array(TallySpec).readonly().exactOptional(),
266
270
  hosted: HostedSettings.exactOptional(),
271
+ team: TeamSettings.exactOptional(),
267
272
  })
268
273
  .register(wireRegistry, {
269
274
  id: "ArtifactManifest",