@mostra/protocol 0.11.0 → 0.13.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.
- package/dist/actions.d.ts +11 -3
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js.map +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/diagnostics/codes/index.d.ts +3 -2
- package/dist/diagnostics/codes/index.d.ts.map +1 -1
- package/dist/diagnostics/codes/index.js +3 -1
- package/dist/diagnostics/codes/index.js.map +1 -1
- package/dist/diagnostics/codes/remote.js +2 -2
- package/dist/diagnostics/codes/remote.js.map +1 -1
- package/dist/diagnostics/codes/team.d.ts +8 -0
- package/dist/diagnostics/codes/team.d.ts.map +1 -0
- package/dist/diagnostics/codes/team.js +44 -0
- package/dist/diagnostics/codes/team.js.map +1 -0
- package/dist/diagnostics/diagnostic.d.ts +1 -1
- package/dist/diagnostics/diagnostic.d.ts.map +1 -1
- package/dist/diagnostics/diagnostic.js +2 -1
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/index.d.ts +13 -6
- package/dist/index.js +11 -4
- package/dist/interaction.d.ts +12 -3
- package/dist/interaction.d.ts.map +1 -1
- package/dist/interaction.js +15 -12
- package/dist/interaction.js.map +1 -1
- package/dist/manifest.d.ts +3 -0
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +5 -2
- package/dist/manifest.js.map +1 -1
- package/dist/methods/index.d.ts.map +1 -1
- package/dist/methods/index.js +10 -2
- package/dist/methods/index.js.map +1 -1
- package/dist/methods/port/trusted-controls-policy.d.ts +1 -1
- package/dist/methods/results/get.d.ts +3 -1
- package/dist/methods/results/get.d.ts.map +1 -1
- package/dist/methods/results/get.js +4 -3
- package/dist/methods/results/get.js.map +1 -1
- package/dist/methods/results/list.d.ts +33 -0
- package/dist/methods/results/list.d.ts.map +1 -0
- package/dist/methods/results/list.js +35 -0
- package/dist/methods/results/list.js.map +1 -0
- package/dist/methods/roster/add.d.ts +47 -0
- package/dist/methods/roster/add.d.ts.map +1 -0
- package/dist/methods/roster/add.js +46 -0
- package/dist/methods/roster/add.js.map +1 -0
- package/dist/methods/roster/get.d.ts +18 -0
- package/dist/methods/roster/get.d.ts.map +1 -0
- package/dist/methods/roster/get.js +22 -0
- package/dist/methods/roster/get.js.map +1 -0
- package/dist/methods/roster/remove.d.ts +28 -0
- package/dist/methods/roster/remove.d.ts.map +1 -0
- package/dist/methods/roster/remove.js +31 -0
- package/dist/methods/roster/remove.js.map +1 -0
- package/dist/methods/share/start.d.ts +15 -2
- package/dist/methods/share/start.d.ts.map +1 -1
- package/dist/methods/share/start.js +5 -1
- package/dist/methods/share/start.js.map +1 -1
- package/dist/methods/state/get.d.ts +1 -1
- package/dist/methods/state/patch.d.ts +1 -1
- package/dist/methods/view/url.d.ts +1 -1
- package/dist/methods/wait/wait.d.ts +1 -1
- package/dist/operator.d.ts +93 -11
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js.map +1 -1
- package/dist/team-settings.d.ts +21 -0
- package/dist/team-settings.d.ts.map +1 -0
- package/dist/team-settings.js +27 -0
- package/dist/team-settings.js.map +1 -0
- package/dist/team.d.ts +221 -0
- package/dist/team.d.ts.map +1 -0
- package/dist/team.js +162 -0
- package/dist/team.js.map +1 -0
- package/dist/verify.d.ts +7 -0
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js.map +1 -1
- package/dist/worker.d.ts +1 -1
- package/package.json +1 -1
- package/schemas/protocol.draft-07.json +802 -79
- package/schemas/protocol.schema.json +782 -91
- package/src/actions.ts +8 -4
- package/src/diagnostics/codes/index.ts +6 -2
- package/src/diagnostics/codes/remote.ts +2 -2
- package/src/diagnostics/codes/team.ts +53 -0
- package/src/diagnostics/diagnostic.ts +3 -1
- package/src/index.ts +47 -2
- package/src/interaction.ts +24 -5
- package/src/manifest.ts +5 -0
- package/src/methods/index.ts +8 -0
- package/src/methods/results/get.ts +3 -2
- package/src/methods/results/list.ts +61 -0
- package/src/methods/roster/add.ts +77 -0
- package/src/methods/roster/get.ts +30 -0
- package/src/methods/roster/remove.ts +49 -0
- package/src/methods/share/start.ts +23 -3
- package/src/operator.ts +83 -10
- package/src/team-settings.ts +38 -0
- package/src/team.ts +398 -0
- package/src/verify.ts +7 -0
package/dist/team.d.ts
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { DEFAULT_TEAM_VISIBILITY, TeamSettings, TeamVisibility } from "./team-settings.js";
|
|
2
|
+
import { ViewerKind } from "./interaction.js";
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
//#region src/team.d.ts
|
|
5
|
+
/** The most expected respondents one artifact's roster holds. */
|
|
6
|
+
export declare const ROSTER_MAX = 1e3;
|
|
7
|
+
/**
|
|
8
|
+
* An expected respondent as a host or agent names them (D121): the host's stable key for the
|
|
9
|
+
* person (`view/url`'s `viewer.ref`, D104), their display name, and an email address a remote
|
|
10
|
+
* server may send an invitation to (its operator's `invitations` port; nothing is sent locally).
|
|
11
|
+
*/
|
|
12
|
+
export interface RespondentSpec {
|
|
13
|
+
/** The host's stable key for this person, such as an email or an account ID (D104). */
|
|
14
|
+
readonly ref: string;
|
|
15
|
+
/** The name people see; updated when given again. */
|
|
16
|
+
readonly name?: string;
|
|
17
|
+
/** Where a remote server's operator may send this person's invitation. Never sent by Mostra. */
|
|
18
|
+
readonly email?: string;
|
|
19
|
+
}
|
|
20
|
+
/** The Zod schema of the `RespondentSpec` type. */
|
|
21
|
+
export declare const RespondentSpec: z.ZodType<RespondentSpec>;
|
|
22
|
+
/**
|
|
23
|
+
* Where an expected respondent stands in the roster's current round (CO-03): `not-opened` (no view
|
|
24
|
+
* of the artifact since the round began), `drafting` (opened it or wrote their draft since), or
|
|
25
|
+
* `submitted` (a submission in the round). Open for later states on the wire.
|
|
26
|
+
*/
|
|
27
|
+
export type RespondentStatus = "not-opened" | "drafting" | "submitted";
|
|
28
|
+
/** The Zod schema of the `RespondentStatus` type. */
|
|
29
|
+
export declare const RespondentStatus: z.ZodType<RespondentStatus>;
|
|
30
|
+
/** How many respondents stand where, in the current round. */
|
|
31
|
+
export interface RosterCounts {
|
|
32
|
+
/** Every expected respondent. */
|
|
33
|
+
readonly total: number;
|
|
34
|
+
/** How many haven't opened the artifact in the round. */
|
|
35
|
+
readonly notOpened: number;
|
|
36
|
+
/** How many opened it or wrote their draft in the round, without submitting. */
|
|
37
|
+
readonly drafting: number;
|
|
38
|
+
/** How many submitted in the round. */
|
|
39
|
+
readonly submitted: number;
|
|
40
|
+
}
|
|
41
|
+
/** The Zod schema of the `RosterCounts` type. */
|
|
42
|
+
export declare const RosterCounts: z.ZodType<RosterCounts>;
|
|
43
|
+
/** One expected respondent as agents and hosts read it (`roster/get`): everything. */
|
|
44
|
+
export interface Respondent {
|
|
45
|
+
/** The host's stable key for the person. */
|
|
46
|
+
readonly ref: string;
|
|
47
|
+
/** The display name. */
|
|
48
|
+
readonly name?: string;
|
|
49
|
+
/** The invitation address, when one was given. */
|
|
50
|
+
readonly email?: string;
|
|
51
|
+
/** The viewer the person's personal link acts as (D104). */
|
|
52
|
+
readonly viewerId: string;
|
|
53
|
+
/** Where they stand in the current round. */
|
|
54
|
+
readonly status: RespondentStatus;
|
|
55
|
+
/** When they first opened the artifact. */
|
|
56
|
+
readonly openedAt?: string;
|
|
57
|
+
/** When they last opened it or wrote their draft. */
|
|
58
|
+
readonly activeAt?: string;
|
|
59
|
+
/** Their submission in the current round, when they made one. */
|
|
60
|
+
readonly submission?: {
|
|
61
|
+
readonly id: string;
|
|
62
|
+
readonly at: string;
|
|
63
|
+
};
|
|
64
|
+
/** How many submissions they made in all. */
|
|
65
|
+
readonly submissions: number;
|
|
66
|
+
/** Their personal link's token, for `view/rotate` and `view/revoke`; absent once revoked. */
|
|
67
|
+
readonly tokenId?: string;
|
|
68
|
+
/** When they joined the roster. */
|
|
69
|
+
readonly addedAt: string;
|
|
70
|
+
}
|
|
71
|
+
/** The Zod schema of the `Respondent` type. */
|
|
72
|
+
export declare const Respondent: z.ZodType<Respondent>;
|
|
73
|
+
/** An artifact's roster as agents and hosts read it (`roster/get`). */
|
|
74
|
+
export interface Roster {
|
|
75
|
+
/** The roster's round (D168): always 1 under `once`; under `epochs`, one more after each completion. */
|
|
76
|
+
readonly round: number;
|
|
77
|
+
/** Whether every expected respondent has submitted in the round; an empty roster never has. */
|
|
78
|
+
readonly complete: boolean;
|
|
79
|
+
/** What viewers see of each other (the manifest's `team.visibility`). */
|
|
80
|
+
readonly visibility: TeamVisibility;
|
|
81
|
+
/** How many stand where in the round. */
|
|
82
|
+
readonly counts: RosterCounts;
|
|
83
|
+
/** Every expected respondent, in the order they joined. */
|
|
84
|
+
readonly respondents: readonly Respondent[];
|
|
85
|
+
}
|
|
86
|
+
/** The Zod schema of the `Roster` type. */
|
|
87
|
+
export declare const Roster: z.ZodType<Roster>;
|
|
88
|
+
/**
|
|
89
|
+
* Another viewer as a page may see them: an opaque key that is stable for one viewer of one
|
|
90
|
+
* artifact (never a viewer or view ID, D104), their display name and how Mostra knows them.
|
|
91
|
+
*/
|
|
92
|
+
export interface Peer {
|
|
93
|
+
/** Stable for one viewer of one artifact, different across artifacts; `self` marks the page's own. */
|
|
94
|
+
readonly key: string;
|
|
95
|
+
/** Whether this is the page's own viewer. */
|
|
96
|
+
readonly self: boolean;
|
|
97
|
+
/** The display name, when one is known. */
|
|
98
|
+
readonly name?: string;
|
|
99
|
+
/** How Mostra knows the viewer. */
|
|
100
|
+
readonly kind: ViewerKind;
|
|
101
|
+
/** On a hosted link: whether a provider verified the name (D165 item 8). */
|
|
102
|
+
readonly verified?: boolean;
|
|
103
|
+
}
|
|
104
|
+
/** One respondent as a page sees them under the visibility policy. */
|
|
105
|
+
export interface RespondentForPage extends Peer {
|
|
106
|
+
/** Where they stand in the round. */
|
|
107
|
+
readonly status: RespondentStatus;
|
|
108
|
+
/** When they first opened the artifact. */
|
|
109
|
+
readonly openedAt?: string;
|
|
110
|
+
/** When they submitted in the round. */
|
|
111
|
+
readonly submittedAt?: string;
|
|
112
|
+
}
|
|
113
|
+
/** The Zod schema of the `RespondentForPage` type. */
|
|
114
|
+
export declare const RespondentForPage: z.ZodType<RespondentForPage>;
|
|
115
|
+
/**
|
|
116
|
+
* The roster as one page may see it (CO-03, CO-07): under `private` only the viewer's own entry,
|
|
117
|
+
* under `counts` also the counts and whether the round is complete, under `names` every respondent.
|
|
118
|
+
* The owner's page sees as under `names`.
|
|
119
|
+
*/
|
|
120
|
+
export interface RosterForPage {
|
|
121
|
+
/** The policy that decided what this answer holds. */
|
|
122
|
+
readonly visibility: TeamVisibility;
|
|
123
|
+
/** Whether this page's viewer sees everything as the artifact's owner. */
|
|
124
|
+
readonly owner: boolean;
|
|
125
|
+
/** The roster's round (always 1 under `once`). */
|
|
126
|
+
readonly round: number;
|
|
127
|
+
/** The viewer's own entry, when they are an expected respondent. */
|
|
128
|
+
readonly self?: RespondentForPage;
|
|
129
|
+
/** Under `counts` and `names`, and for the owner. */
|
|
130
|
+
readonly counts?: RosterCounts;
|
|
131
|
+
/** Under `counts` and `names`, and for the owner. */
|
|
132
|
+
readonly complete?: boolean;
|
|
133
|
+
/** Under `names`, and for the owner: every respondent, in the order they joined. */
|
|
134
|
+
readonly respondents?: readonly RespondentForPage[];
|
|
135
|
+
}
|
|
136
|
+
/** The Zod schema of the `RosterForPage` type. */
|
|
137
|
+
export declare const RosterForPage: z.ZodType<RosterForPage>;
|
|
138
|
+
/** `POST …/respondents`: reads the roster as the page may see it and follows it for a minute. */
|
|
139
|
+
export interface RespondentsRequest {
|
|
140
|
+
/** The view the page was opened as (D104). */
|
|
141
|
+
readonly viewId: string;
|
|
142
|
+
}
|
|
143
|
+
/** The Zod schema of the `RespondentsRequest` type. */
|
|
144
|
+
export declare const RespondentsRequest: z.ZodType<RespondentsRequest>;
|
|
145
|
+
/** The largest coordinate a shared cursor may carry, in CSS pixels. */
|
|
146
|
+
export declare const PRESENCE_COORDINATE_MAX = 1e7;
|
|
147
|
+
/** A shared pointer position, in the page's document coordinates (CSS pixels). */
|
|
148
|
+
export interface PresenceCursor {
|
|
149
|
+
/** From the document's left edge. */
|
|
150
|
+
readonly x: number;
|
|
151
|
+
/** From the document's top edge. */
|
|
152
|
+
readonly y: number;
|
|
153
|
+
}
|
|
154
|
+
/** The Zod schema of the `PresenceCursor` type. */
|
|
155
|
+
export declare const PresenceCursor: z.ZodType<PresenceCursor>;
|
|
156
|
+
/**
|
|
157
|
+
* A shared selection: the element the viewer is in (its `data-presence-id`, `id` or `name`) and,
|
|
158
|
+
* in a text input, the selected range.
|
|
159
|
+
*/
|
|
160
|
+
export interface PresenceSelection {
|
|
161
|
+
/** The element: its `data-presence-id`, `id` or `name`. */
|
|
162
|
+
readonly element?: string;
|
|
163
|
+
/** In a text input, where the selection starts. */
|
|
164
|
+
readonly start?: number;
|
|
165
|
+
/** In a text input, where it ends. */
|
|
166
|
+
readonly end?: number;
|
|
167
|
+
}
|
|
168
|
+
/** The Zod schema of the `PresenceSelection` type. */
|
|
169
|
+
export declare const PresenceSelection: z.ZodType<PresenceSelection>;
|
|
170
|
+
/**
|
|
171
|
+
* `POST …/presence`: the page joins presence for the next half minute, sharing what it gives
|
|
172
|
+
* (CO-04). `cursor` and `selection` replace what the page shared (`null` stops sharing it); `leave`
|
|
173
|
+
* ends the page's presence at once. Never stored.
|
|
174
|
+
*/
|
|
175
|
+
export interface PresenceRequest {
|
|
176
|
+
/** The view the page was opened as (D104). */
|
|
177
|
+
readonly viewId: string;
|
|
178
|
+
/** The pointer to share; `null` stops sharing it; absent leaves it as it was. */
|
|
179
|
+
readonly cursor?: PresenceCursor | null;
|
|
180
|
+
/** The selection to share; `null` stops sharing it; absent leaves it as it was. */
|
|
181
|
+
readonly selection?: PresenceSelection | null;
|
|
182
|
+
/** Ends the page's presence now. */
|
|
183
|
+
readonly leave?: true;
|
|
184
|
+
/**
|
|
185
|
+
* The page's own count of its presence posts, growing with each (a leave included): a post the
|
|
186
|
+
* gateway gets after one with a higher count, such as an update that overtook the page's leave,
|
|
187
|
+
* changes nothing.
|
|
188
|
+
*/
|
|
189
|
+
readonly seq?: number;
|
|
190
|
+
}
|
|
191
|
+
/** The Zod schema of the `PresenceRequest` type. */
|
|
192
|
+
export declare const PresenceRequest: z.ZodType<PresenceRequest>;
|
|
193
|
+
/** A viewer present on the artifact now, as a page may see them. */
|
|
194
|
+
export interface PresencePeer extends Peer {
|
|
195
|
+
/** Their pointer, when they share it. */
|
|
196
|
+
readonly cursor?: PresenceCursor;
|
|
197
|
+
/** Their selection, when they share it. */
|
|
198
|
+
readonly selection?: PresenceSelection;
|
|
199
|
+
/** When they last told Mostra anything. */
|
|
200
|
+
readonly at: string;
|
|
201
|
+
}
|
|
202
|
+
/** The Zod schema of the `PresencePeer` type. */
|
|
203
|
+
export declare const PresencePeer: z.ZodType<PresencePeer>;
|
|
204
|
+
/**
|
|
205
|
+
* Who is present, as one page may see it (CO-04, CO-07): under `names` (or for the owner) every
|
|
206
|
+
* present viewer with what they share; under `counts` how many others are present; under
|
|
207
|
+
* `private` only the page's own viewer.
|
|
208
|
+
*/
|
|
209
|
+
export interface PresenceState {
|
|
210
|
+
/** The policy that decided what this answer holds. */
|
|
211
|
+
readonly visibility: TeamVisibility;
|
|
212
|
+
/** Present viewers this page may see, its own first. */
|
|
213
|
+
readonly peers: readonly PresencePeer[];
|
|
214
|
+
/** How many other viewers are present, under `counts` and `names`. */
|
|
215
|
+
readonly others?: number;
|
|
216
|
+
}
|
|
217
|
+
/** The Zod schema of the `PresenceState` type. */
|
|
218
|
+
export declare const PresenceState: z.ZodType<PresenceState>;
|
|
219
|
+
//#endregion
|
|
220
|
+
export { DEFAULT_TEAM_VISIBILITY, TeamSettings, TeamVisibility };
|
|
221
|
+
//# sourceMappingURL=team.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"team.d.ts","names":[],"sources":["../src/team.ts"],"mappings":";;;;;qBAkBa;;;;;;iBAOI;;WAEN;;WAEA;;WAEA;;;qBAIE,gBA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ITY, TeamSettings, TeamVisibility } from "./team-settings.js";
|
|
4
|
+
import { ViewerKind } from "./interaction.js";
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
//#region src/team.ts
|
|
7
|
+
/**
|
|
8
|
+
* Team features (D121, D168; INTERFACES §2.3, §4, §6): expected respondents and their roster,
|
|
9
|
+
* respondent status, the visibility policy, and presence. The host protocol's `roster/*` methods,
|
|
10
|
+
* the browser protocol's `respondents` and `presence` routes and the client hooks
|
|
11
|
+
* (`useRespondents`, `usePresence`) speak these shapes. Presence is never stored (D47): its shapes
|
|
12
|
+
* travel only as ephemeral messages and answers.
|
|
13
|
+
*/
|
|
14
|
+
/** The most expected respondents one artifact's roster holds. */
|
|
15
|
+
const ROSTER_MAX = 1e3;
|
|
16
|
+
/** The Zod schema of the `RespondentSpec` type. */
|
|
17
|
+
const RespondentSpec = z.object({
|
|
18
|
+
ref: z.string().min(1).max(256),
|
|
19
|
+
name: z.string().min(1).max(256).exactOptional(),
|
|
20
|
+
email: z.string().max(320).regex(/^[^\s@]+@[^\s@]+$/).exactOptional()
|
|
21
|
+
}).register(wireRegistry, {
|
|
22
|
+
id: "RespondentSpec",
|
|
23
|
+
description: "An expected respondent: the host's stable key, a display name, an email."
|
|
24
|
+
});
|
|
25
|
+
/** The Zod schema of the `RespondentStatus` type. */
|
|
26
|
+
const RespondentStatus = z.enum([
|
|
27
|
+
"not-opened",
|
|
28
|
+
"drafting",
|
|
29
|
+
"submitted"
|
|
30
|
+
]).register(wireRegistry, {
|
|
31
|
+
id: "RespondentStatus",
|
|
32
|
+
description: "Where a respondent stands in the round: not-opened, drafting or submitted."
|
|
33
|
+
});
|
|
34
|
+
/** The Zod schema of the `RosterCounts` type. */
|
|
35
|
+
const RosterCounts = z.object({
|
|
36
|
+
total: z.int().min(0),
|
|
37
|
+
notOpened: z.int().min(0),
|
|
38
|
+
drafting: z.int().min(0),
|
|
39
|
+
submitted: z.int().min(0)
|
|
40
|
+
}).register(wireRegistry, {
|
|
41
|
+
id: "RosterCounts",
|
|
42
|
+
description: "How many respondents have not opened, are drafting, or submitted in the round."
|
|
43
|
+
});
|
|
44
|
+
/** The Zod schema of the `Respondent` type. */
|
|
45
|
+
const Respondent = z.object({
|
|
46
|
+
ref: z.string(),
|
|
47
|
+
name: z.string().exactOptional(),
|
|
48
|
+
email: z.string().exactOptional(),
|
|
49
|
+
viewerId: ViewerId.schema,
|
|
50
|
+
status: RespondentStatus,
|
|
51
|
+
openedAt: z.iso.datetime().exactOptional(),
|
|
52
|
+
activeAt: z.iso.datetime().exactOptional(),
|
|
53
|
+
submission: z.object({
|
|
54
|
+
id: SubmissionId.schema,
|
|
55
|
+
at: z.iso.datetime()
|
|
56
|
+
}).exactOptional(),
|
|
57
|
+
submissions: z.int().min(0),
|
|
58
|
+
tokenId: z.string().exactOptional(),
|
|
59
|
+
addedAt: z.iso.datetime()
|
|
60
|
+
}).register(wireRegistry, {
|
|
61
|
+
id: "Respondent",
|
|
62
|
+
description: "An expected respondent as agents and hosts read it: name, viewer, status and submission."
|
|
63
|
+
});
|
|
64
|
+
/** The Zod schema of the `Roster` type. */
|
|
65
|
+
const Roster = z.object({
|
|
66
|
+
round: z.int().min(1),
|
|
67
|
+
complete: z.boolean(),
|
|
68
|
+
visibility: TeamVisibility,
|
|
69
|
+
counts: RosterCounts,
|
|
70
|
+
respondents: z.array(Respondent).readonly()
|
|
71
|
+
}).register(wireRegistry, {
|
|
72
|
+
id: "Roster",
|
|
73
|
+
description: "An artifact's expected respondents with their status, the round and its counts."
|
|
74
|
+
});
|
|
75
|
+
const peerShape = {
|
|
76
|
+
key: z.string().min(1).max(64),
|
|
77
|
+
self: z.boolean(),
|
|
78
|
+
name: z.string().exactOptional(),
|
|
79
|
+
kind: ViewerKind,
|
|
80
|
+
verified: z.boolean().exactOptional()
|
|
81
|
+
};
|
|
82
|
+
/** The Zod schema of the `RespondentForPage` type. */
|
|
83
|
+
const RespondentForPage = z.object({
|
|
84
|
+
...peerShape,
|
|
85
|
+
status: RespondentStatus,
|
|
86
|
+
openedAt: z.iso.datetime().exactOptional(),
|
|
87
|
+
submittedAt: z.iso.datetime().exactOptional()
|
|
88
|
+
}).register(wireRegistry, {
|
|
89
|
+
id: "RespondentForPage",
|
|
90
|
+
description: "A respondent as a page sees them: key, name, status, when opened and submitted."
|
|
91
|
+
});
|
|
92
|
+
/** The Zod schema of the `RosterForPage` type. */
|
|
93
|
+
const RosterForPage = z.object({
|
|
94
|
+
visibility: TeamVisibility,
|
|
95
|
+
owner: z.boolean(),
|
|
96
|
+
round: z.int().min(1),
|
|
97
|
+
self: RespondentForPage.exactOptional(),
|
|
98
|
+
counts: RosterCounts.exactOptional(),
|
|
99
|
+
complete: z.boolean().exactOptional(),
|
|
100
|
+
respondents: z.array(RespondentForPage).readonly().exactOptional()
|
|
101
|
+
}).register(wireRegistry, {
|
|
102
|
+
id: "RosterForPage",
|
|
103
|
+
description: "The roster as a page may see it under the visibility policy (CO-07)."
|
|
104
|
+
});
|
|
105
|
+
/** The Zod schema of the `RespondentsRequest` type. */
|
|
106
|
+
const RespondentsRequest = z.object({ viewId: ViewId.schema }).register(wireRegistry, {
|
|
107
|
+
id: "RespondentsRequest",
|
|
108
|
+
description: "Reads the roster as the page may see it, and follows it for a minute."
|
|
109
|
+
});
|
|
110
|
+
/** The largest coordinate a shared cursor may carry, in CSS pixels. */
|
|
111
|
+
const PRESENCE_COORDINATE_MAX = 1e7;
|
|
112
|
+
/** The Zod schema of the `PresenceCursor` type. */
|
|
113
|
+
const PresenceCursor = z.object({
|
|
114
|
+
x: z.number().min(-1e7).max(PRESENCE_COORDINATE_MAX),
|
|
115
|
+
y: z.number().min(-1e7).max(PRESENCE_COORDINATE_MAX)
|
|
116
|
+
}).register(wireRegistry, {
|
|
117
|
+
id: "PresenceCursor",
|
|
118
|
+
description: "A shared pointer position in the page's document coordinates, in CSS pixels."
|
|
119
|
+
});
|
|
120
|
+
/** The Zod schema of the `PresenceSelection` type. */
|
|
121
|
+
const PresenceSelection = z.object({
|
|
122
|
+
element: z.string().min(1).max(256).exactOptional(),
|
|
123
|
+
start: z.int().min(0).max(PRESENCE_COORDINATE_MAX).exactOptional(),
|
|
124
|
+
end: z.int().min(0).max(PRESENCE_COORDINATE_MAX).exactOptional()
|
|
125
|
+
}).register(wireRegistry, {
|
|
126
|
+
id: "PresenceSelection",
|
|
127
|
+
description: "A shared selection: the element the viewer is in and the selected text range."
|
|
128
|
+
});
|
|
129
|
+
/** The Zod schema of the `PresenceRequest` type. */
|
|
130
|
+
const PresenceRequest = z.object({
|
|
131
|
+
viewId: ViewId.schema,
|
|
132
|
+
cursor: PresenceCursor.nullable().exactOptional(),
|
|
133
|
+
selection: PresenceSelection.nullable().exactOptional(),
|
|
134
|
+
leave: z.literal(true).exactOptional(),
|
|
135
|
+
seq: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).exactOptional()
|
|
136
|
+
}).register(wireRegistry, {
|
|
137
|
+
id: "PresenceRequest",
|
|
138
|
+
description: "Joins presence for half a minute, sharing a cursor and a selection, or leaves."
|
|
139
|
+
});
|
|
140
|
+
/** The Zod schema of the `PresencePeer` type. */
|
|
141
|
+
const PresencePeer = z.object({
|
|
142
|
+
...peerShape,
|
|
143
|
+
cursor: PresenceCursor.exactOptional(),
|
|
144
|
+
selection: PresenceSelection.exactOptional(),
|
|
145
|
+
at: z.iso.datetime()
|
|
146
|
+
}).register(wireRegistry, {
|
|
147
|
+
id: "PresencePeer",
|
|
148
|
+
description: "A viewer present now: key, name, and the cursor and selection they share."
|
|
149
|
+
});
|
|
150
|
+
/** The Zod schema of the `PresenceState` type. */
|
|
151
|
+
const PresenceState = z.object({
|
|
152
|
+
visibility: TeamVisibility,
|
|
153
|
+
peers: z.array(PresencePeer).readonly(),
|
|
154
|
+
others: z.int().min(0).exactOptional()
|
|
155
|
+
}).register(wireRegistry, {
|
|
156
|
+
id: "PresenceState",
|
|
157
|
+
description: "Who is present, as a page may see them under the visibility policy."
|
|
158
|
+
});
|
|
159
|
+
//#endregion
|
|
160
|
+
export { DEFAULT_TEAM_VISIBILITY, PRESENCE_COORDINATE_MAX, PresenceCursor, PresencePeer, PresenceRequest, PresenceSelection, PresenceState, ROSTER_MAX, Respondent, RespondentForPage, RespondentSpec, RespondentStatus, RespondentsRequest, Roster, RosterCounts, RosterForPage, TeamSettings, TeamVisibility };
|
|
161
|
+
|
|
162
|
+
//# sourceMappingURL=team.js.map
|
package/dist/team.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"team.js","names":[],"sources":["../src/team.ts"],"sourcesContent":["/**\n * Team features (D121, D168; INTERFACES §2.3, §4, §6): expected respondents and their roster,\n * respondent status, the visibility policy, and presence. The host protocol's `roster/*` methods,\n * the browser protocol's `respondents` and `presence` routes and the client hooks\n * (`useRespondents`, `usePresence`) speak these shapes. Presence is never stored (D47): its shapes\n * travel only as ephemeral messages and answers.\n */\nimport * as z from \"zod\";\nimport { SubmissionId, ViewerId, ViewId } from \"./ids.ts\";\nimport { ViewerKind } from \"./interaction.ts\";\nimport { DEFAULT_TEAM_VISIBILITY, TeamSettings, TeamVisibility } from \"./team-settings.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\nexport { DEFAULT_TEAM_VISIBILITY, TeamSettings, TeamVisibility };\n\n// ── Respondents ──────────────────────────────────────────────────────────────────────────────\n\n/** The most expected respondents one artifact's roster holds. */\nexport const ROSTER_MAX = 1000;\n\n/**\n * An expected respondent as a host or agent names them (D121): the host's stable key for the\n * person (`view/url`'s `viewer.ref`, D104), their display name, and an email address a remote\n * server may send an invitation to (its operator's `invitations` port; nothing is sent locally).\n */\nexport interface RespondentSpec {\n /** The host's stable key for this person, such as an email or an account ID (D104). */\n readonly ref: string;\n /** The name people see; updated when given again. */\n readonly name?: string;\n /** Where a remote server's operator may send this person's invitation. Never sent by Mostra. */\n readonly email?: string;\n}\n\n/** The Zod schema of the `RespondentSpec` type. */\nexport const RespondentSpec: z.ZodType<RespondentSpec> = z\n .object({\n ref: z.string().min(1).max(256),\n name: z.string().min(1).max(256).exactOptional(),\n email: z\n .string()\n .max(320)\n .regex(/^[^\\s@]+@[^\\s@]+$/)\n .exactOptional(),\n })\n .register(wireRegistry, {\n id: \"RespondentSpec\",\n description: \"An expected respondent: the host's stable key, a display name, an email.\",\n });\n\n/**\n * Where an expected respondent stands in the roster's current round (CO-03): `not-opened` (no view\n * of the artifact since the round began), `drafting` (opened it or wrote their draft since), or\n * `submitted` (a submission in the round). Open for later states on the wire.\n */\nexport type RespondentStatus = \"not-opened\" | \"drafting\" | \"submitted\";\n\n/** The Zod schema of the `RespondentStatus` type. */\nexport const RespondentStatus: z.ZodType<RespondentStatus> = z\n .enum([\"not-opened\", \"drafting\", \"submitted\"])\n .register(wireRegistry, {\n id: \"RespondentStatus\",\n description: \"Where a respondent stands in the round: not-opened, drafting or submitted.\",\n });\n\n/** How many respondents stand where, in the current round. */\nexport interface RosterCounts {\n /** Every expected respondent. */\n readonly total: number;\n /** How many haven't opened the artifact in the round. */\n readonly notOpened: number;\n /** How many opened it or wrote their draft in the round, without submitting. */\n readonly drafting: number;\n /** How many submitted in the round. */\n readonly submitted: number;\n}\n\n/** The Zod schema of the `RosterCounts` type. */\nexport const RosterCounts: z.ZodType<RosterCounts> = z\n .object({\n total: z.int().min(0),\n notOpened: z.int().min(0),\n drafting: z.int().min(0),\n submitted: z.int().min(0),\n })\n .register(wireRegistry, {\n id: \"RosterCounts\",\n description: \"How many respondents have not opened, are drafting, or submitted in the round.\",\n });\n\n/** One expected respondent as agents and hosts read it (`roster/get`): everything. */\nexport interface Respondent {\n /** The host's stable key for the person. */\n readonly ref: string;\n /** The display name. */\n readonly name?: string;\n /** The invitation address, when one was given. */\n readonly email?: string;\n /** The viewer the person's personal link acts as (D104). */\n readonly viewerId: string;\n /** Where they stand in the current round. */\n readonly status: RespondentStatus;\n /** When they first opened the artifact. */\n readonly openedAt?: string;\n /** When they last opened it or wrote their draft. */\n readonly activeAt?: string;\n /** Their submission in the current round, when they made one. */\n readonly submission?: { readonly id: string; readonly at: string };\n /** How many submissions they made in all. */\n readonly submissions: number;\n /** Their personal link's token, for `view/rotate` and `view/revoke`; absent once revoked. */\n readonly tokenId?: string;\n /** When they joined the roster. */\n readonly addedAt: string;\n}\n\n/** The Zod schema of the `Respondent` type. */\nexport const Respondent: z.ZodType<Respondent> = z\n .object({\n ref: z.string(),\n name: z.string().exactOptional(),\n email: z.string().exactOptional(),\n viewerId: ViewerId.schema,\n status: RespondentStatus,\n openedAt: z.iso.datetime().exactOptional(),\n activeAt: z.iso.datetime().exactOptional(),\n submission: z.object({ id: SubmissionId.schema, at: z.iso.datetime() }).exactOptional(),\n submissions: z.int().min(0),\n tokenId: z.string().exactOptional(),\n addedAt: z.iso.datetime(),\n })\n .register(wireRegistry, {\n id: \"Respondent\",\n description:\n \"An expected respondent as agents and hosts read it: name, viewer, status and submission.\",\n });\n\n/** An artifact's roster as agents and hosts read it (`roster/get`). */\nexport interface Roster {\n /** The roster's round (D168): always 1 under `once`; under `epochs`, one more after each completion. */\n readonly round: number;\n /** Whether every expected respondent has submitted in the round; an empty roster never has. */\n readonly complete: boolean;\n /** What viewers see of each other (the manifest's `team.visibility`). */\n readonly visibility: TeamVisibility;\n /** How many stand where in the round. */\n readonly counts: RosterCounts;\n /** Every expected respondent, in the order they joined. */\n readonly respondents: readonly Respondent[];\n}\n\n/** The Zod schema of the `Roster` type. */\nexport const Roster: z.ZodType<Roster> = z\n .object({\n round: z.int().min(1),\n complete: z.boolean(),\n visibility: TeamVisibility,\n counts: RosterCounts,\n respondents: z.array(Respondent).readonly(),\n })\n .register(wireRegistry, {\n id: \"Roster\",\n description: \"An artifact's expected respondents with their status, the round and its counts.\",\n });\n\n/**\n * Another viewer as a page may see them: an opaque key that is stable for one viewer of one\n * artifact (never a viewer or view ID, D104), their display name and how Mostra knows them.\n */\nexport interface Peer {\n /** Stable for one viewer of one artifact, different across artifacts; `self` marks the page's own. */\n readonly key: string;\n /** Whether this is the page's own viewer. */\n readonly self: boolean;\n /** The display name, when one is known. */\n readonly name?: string;\n /** How Mostra knows the viewer. */\n readonly kind: ViewerKind;\n /** On a hosted link: whether a provider verified the name (D165 item 8). */\n readonly verified?: boolean;\n}\n\nconst peerShape = {\n key: z.string().min(1).max(64),\n self: z.boolean(),\n name: z.string().exactOptional(),\n kind: ViewerKind,\n verified: z.boolean().exactOptional(),\n};\n\n/** One respondent as a page sees them under the visibility policy. */\nexport interface RespondentForPage extends Peer {\n /** Where they stand in the round. */\n readonly status: RespondentStatus;\n /** When they first opened the artifact. */\n readonly openedAt?: string;\n /** When they submitted in the round. */\n readonly submittedAt?: string;\n}\n\n/** The Zod schema of the `RespondentForPage` type. */\nexport const RespondentForPage: z.ZodType<RespondentForPage> = z\n .object({\n ...peerShape,\n status: RespondentStatus,\n openedAt: z.iso.datetime().exactOptional(),\n submittedAt: z.iso.datetime().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"RespondentForPage\",\n description: \"A respondent as a page sees them: key, name, status, when opened and submitted.\",\n });\n\n/**\n * The roster as one page may see it (CO-03, CO-07): under `private` only the viewer's own entry,\n * under `counts` also the counts and whether the round is complete, under `names` every respondent.\n * The owner's page sees as under `names`.\n */\nexport interface RosterForPage {\n /** The policy that decided what this answer holds. */\n readonly visibility: TeamVisibility;\n /** Whether this page's viewer sees everything as the artifact's owner. */\n readonly owner: boolean;\n /** The roster's round (always 1 under `once`). */\n readonly round: number;\n /** The viewer's own entry, when they are an expected respondent. */\n readonly self?: RespondentForPage;\n /** Under `counts` and `names`, and for the owner. */\n readonly counts?: RosterCounts;\n /** Under `counts` and `names`, and for the owner. */\n readonly complete?: boolean;\n /** Under `names`, and for the owner: every respondent, in the order they joined. */\n readonly respondents?: readonly RespondentForPage[];\n}\n\n/** The Zod schema of the `RosterForPage` type. */\nexport const RosterForPage: z.ZodType<RosterForPage> = z\n .object({\n visibility: TeamVisibility,\n owner: z.boolean(),\n round: z.int().min(1),\n self: RespondentForPage.exactOptional(),\n counts: RosterCounts.exactOptional(),\n complete: z.boolean().exactOptional(),\n respondents: z.array(RespondentForPage).readonly().exactOptional(),\n })\n .register(wireRegistry, {\n id: \"RosterForPage\",\n description: \"The roster as a page may see it under the visibility policy (CO-07).\",\n });\n\n/** `POST …/respondents`: reads the roster as the page may see it and follows it for a minute. */\nexport interface RespondentsRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n}\n\n/** The Zod schema of the `RespondentsRequest` type. */\nexport const RespondentsRequest: z.ZodType<RespondentsRequest> = z\n .object({ viewId: ViewId.schema })\n .register(wireRegistry, {\n id: \"RespondentsRequest\",\n description: \"Reads the roster as the page may see it, and follows it for a minute.\",\n });\n\n// ── Presence ─────────────────────────────────────────────────────────────────────────────────\n\n/** The largest coordinate a shared cursor may carry, in CSS pixels. */\nexport const PRESENCE_COORDINATE_MAX = 10_000_000;\n\n/** A shared pointer position, in the page's document coordinates (CSS pixels). */\nexport interface PresenceCursor {\n /** From the document's left edge. */\n readonly x: number;\n /** From the document's top edge. */\n readonly y: number;\n}\n\n/** The Zod schema of the `PresenceCursor` type. */\nexport const PresenceCursor: z.ZodType<PresenceCursor> = z\n .object({\n x: z.number().min(-PRESENCE_COORDINATE_MAX).max(PRESENCE_COORDINATE_MAX),\n y: z.number().min(-PRESENCE_COORDINATE_MAX).max(PRESENCE_COORDINATE_MAX),\n })\n .register(wireRegistry, {\n id: \"PresenceCursor\",\n description: \"A shared pointer position in the page's document coordinates, in CSS pixels.\",\n });\n\n/**\n * A shared selection: the element the viewer is in (its `data-presence-id`, `id` or `name`) and,\n * in a text input, the selected range.\n */\nexport interface PresenceSelection {\n /** The element: its `data-presence-id`, `id` or `name`. */\n readonly element?: string;\n /** In a text input, where the selection starts. */\n readonly start?: number;\n /** In a text input, where it ends. */\n readonly end?: number;\n}\n\n/** The Zod schema of the `PresenceSelection` type. */\nexport const PresenceSelection: z.ZodType<PresenceSelection> = z\n .object({\n element: z.string().min(1).max(256).exactOptional(),\n start: z.int().min(0).max(PRESENCE_COORDINATE_MAX).exactOptional(),\n end: z.int().min(0).max(PRESENCE_COORDINATE_MAX).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"PresenceSelection\",\n description: \"A shared selection: the element the viewer is in and the selected text range.\",\n });\n\n/**\n * `POST …/presence`: the page joins presence for the next half minute, sharing what it gives\n * (CO-04). `cursor` and `selection` replace what the page shared (`null` stops sharing it); `leave`\n * ends the page's presence at once. Never stored.\n */\nexport interface PresenceRequest {\n /** The view the page was opened as (D104). */\n readonly viewId: string;\n /** The pointer to share; `null` stops sharing it; absent leaves it as it was. */\n readonly cursor?: PresenceCursor | null;\n /** The selection to share; `null` stops sharing it; absent leaves it as it was. */\n readonly selection?: PresenceSelection | null;\n /** Ends the page's presence now. */\n readonly leave?: true;\n /**\n * The page's own count of its presence posts, growing with each (a leave included): a post the\n * gateway gets after one with a higher count, such as an update that overtook the page's leave,\n * changes nothing.\n */\n readonly seq?: number;\n}\n\n/** The Zod schema of the `PresenceRequest` type. */\nexport const PresenceRequest: z.ZodType<PresenceRequest> = z\n .object({\n viewId: ViewId.schema,\n cursor: PresenceCursor.nullable().exactOptional(),\n selection: PresenceSelection.nullable().exactOptional(),\n leave: z.literal(true).exactOptional(),\n seq: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"PresenceRequest\",\n description: \"Joins presence for half a minute, sharing a cursor and a selection, or leaves.\",\n });\n\n/** A viewer present on the artifact now, as a page may see them. */\nexport interface PresencePeer extends Peer {\n /** Their pointer, when they share it. */\n readonly cursor?: PresenceCursor;\n /** Their selection, when they share it. */\n readonly selection?: PresenceSelection;\n /** When they last told Mostra anything. */\n readonly at: string;\n}\n\n/** The Zod schema of the `PresencePeer` type. */\nexport const PresencePeer: z.ZodType<PresencePeer> = z\n .object({\n ...peerShape,\n cursor: PresenceCursor.exactOptional(),\n selection: PresenceSelection.exactOptional(),\n at: z.iso.datetime(),\n })\n .register(wireRegistry, {\n id: \"PresencePeer\",\n description: \"A viewer present now: key, name, and the cursor and selection they share.\",\n });\n\n/**\n * Who is present, as one page may see it (CO-04, CO-07): under `names` (or for the owner) every\n * present viewer with what they share; under `counts` how many others are present; under\n * `private` only the page's own viewer.\n */\nexport interface PresenceState {\n /** The policy that decided what this answer holds. */\n readonly visibility: TeamVisibility;\n /** Present viewers this page may see, its own first. */\n readonly peers: readonly PresencePeer[];\n /** How many other viewers are present, under `counts` and `names`. */\n readonly others?: number;\n}\n\n/** The Zod schema of the `PresenceState` type. */\nexport const PresenceState: z.ZodType<PresenceState> = z\n .object({\n visibility: TeamVisibility,\n peers: z.array(PresencePeer).readonly(),\n others: z.int().min(0).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"PresenceState\",\n description: \"Who is present, as a page may see them under the visibility policy.\",\n });\n"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAa,aAAa;;AAiB1B,MAAa,iBAA4C,EACtD,OAAO;CACN,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;CAC9B,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,cAAc;CAC/C,OAAO,EACJ,OAAO,CAAC,CACR,IAAI,GAAG,CAAC,CACR,MAAM,mBAAmB,CAAC,CAC1B,cAAc;AACnB,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAUH,MAAa,mBAAgD,EAC1D,KAAK;CAAC;CAAc;CAAY;AAAW,CAAC,CAAC,CAC7C,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAeH,MAAa,eAAwC,EAClD,OAAO;CACN,OAAO,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;CACpB,WAAW,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;CACxB,UAAU,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;CACvB,WAAW,EAAE,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IAAI;CACJ,aAAa;AACf,CAAC;;AAyBH,MAAa,kBAA8C,EACxD,OAAO;CACN,QAAQ,OAAO;CACf,QAAQ,eAAe,SAAS,CAAC,CAAC,cAAc;CAChD,WAAW,kBAAkB,SAAS,CAAC,CAAC,cAAc;CACtD,OAAO,EAAE,QAAQ,IAAI,CAAC,CAAC,cAAc;CACrC,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,OAAO,gBAAgB,CAAC,CAAC,cAAc;AACjF,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAaH,MAAa,eAAwC,EAClD,OAAO;CACN,GAAG;CACH,QAAQ,eAAe,cAAc;CACrC,WAAW,kBAAkB,cAAc;CAC3C,IAAI,EAAE,IAAI,SAAS;AACrB,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAiBH,MAAa,gBAA0C,EACpD,OAAO;CACN,YAAY;CACZ,OAAO,EAAE,MAAM,YAAY,CAAC,CAAC,SAAS;CACtC,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;AACvC,CAAC,CAAC,CACD,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC"}
|
package/dist/verify.d.ts
CHANGED
|
@@ -231,6 +231,13 @@ export interface RenderResult {
|
|
|
231
231
|
readonly timedOut: boolean;
|
|
232
232
|
/** When each step ended, in ms after the render started. */
|
|
233
233
|
readonly timingsMs: Readonly<Record<string, number>>;
|
|
234
|
+
/**
|
|
235
|
+
* Why the page was rendered a second time, in a fresh browser context, when it was: a
|
|
236
|
+
* connection the browser couldn't make for a reason of its own (Chromium's random local port
|
|
237
|
+
* colliding on Windows, `net::ERR_NO_BUFFER_SPACE`, D157, #132). The second render's findings
|
|
238
|
+
* are the answer's.
|
|
239
|
+
*/
|
|
240
|
+
readonly renderedAgain?: string;
|
|
234
241
|
}
|
|
235
242
|
/** `verify/compare`'s params; internal to Mostra. */
|
|
236
243
|
export interface CompareRequest {
|
package/dist/verify.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","names":[],"sources":["../src/verify.ts"],"mappings":";;;;YAUY;;qBAGC,kBAAkB,EAAE,QAAQ;;iBAQxB;;WAEN;;WAEA;;WAEA;;;qBAIE,4BAA4B;;;;;;wBAgBzB,aAAa;WAClB,oBAAoB;WACpB;;;iBA4BM;;WAEN;;WAEA;;WAEA;;;;;;;wBAkEK,oBAAoB,eAAe,iBAAiB;;iBAMnD;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA,gBAAgB;;WAEhB;;;iBAIM;;WAEN;;WAEA;;WAEA;;;iBAIM;;WAEN;;WAEA;;aAEE;;aAEA;;aAEA;;aAEA;;aAEA;;;WAGF,sBAAsB;;WAEtB,sBAAsB;;WAEtB,eAAe;;WAEf;;aAEE;;aAEA;;aAEA;;;WAGF;;;;;aAKE;;aAEA;;aAEA;eAA6B;eAA2B;;;aAExD;;;WAGF,WAAW,SAAS;;;qBAUlB,eAAe,EAAE,QAAQ;;qBAiDzB;;iBAGI;;WAEN;;WAEA;;WAEA;;;qBAIE,wBAAwB,EAAE,QAAQ;;;;;;;qBAiBlC;;;;;;qBAOA;;iBAGI;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;qBAIE;;WAEX;;WAEA;;;iBAIe;;WAEN;;WAEA,UAAU;;WAEV;;WAEA;;WAEA;;WAEA;;aAEE;;aAEA;;aAEA;;aAEA;;aAEA;eAAmB;eAAkC;;;;WAGvD;;;iBAIM;;WAEN;;WAEA,mBAAmB;;WAEnB;aAAwB;aAAuB;aAAwB;;;WAEvE;aAAkB;aAAuB;;;WAEzC,kBAAkB;;WAElB;;aAEE;;aAEA;;aAEA;;aAEA;;;WAGF;;WAEA,WAAW,SAAS;;;
|
|
1
|
+
{"version":3,"file":"verify.d.ts","names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**\n * `verify` (D29, D41, D55, D72, D138; INTERFACES §13): the verdict it returns, the viewports it\n * renders, and the image-token estimates every screenshot carries. Pure and free of I/O, so the\n * runtime, the verify runner, the CLI and the MCP server share one definition.\n */\nimport * as z from \"zod\";\nimport { Diagnostic } from \"./diagnostics/diagnostic.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** When a verdict's screenshots are handed to the caller (AX-05): images cost tokens. */\nexport type ScreenshotPolicy = \"on-failure\" | \"always\" | \"never\";\n\n/** The Zod schema of the `ScreenshotPolicy` type. */\nexport const ScreenshotPolicy: z.ZodType<ScreenshotPolicy, string> = z\n .enum([\"on-failure\", \"always\", \"never\"])\n .register(wireRegistry, {\n id: \"ScreenshotPolicy\",\n description: \"When screenshots are returned: on failure (the default), always or never.\",\n });\n\n/** One viewport verify renders at device pixel ratio 1. */\nexport interface VerifyViewport {\n /** Its name in the verdict: `desktop`, `mobile`, `tablet`, or `<width>x<height>`. */\n readonly name: string;\n /** Its width in CSS pixels, which at DPR 1 are the screenshot's pixels. */\n readonly width: number;\n /** Its height in CSS pixels. */\n readonly height: number;\n}\n\n/** The viewports verify renders when the manifest names none (ROUND-3 §9): desktop and mobile. */\nexport const DEFAULT_VIEWPORTS: readonly VerifyViewport[] = [\n { name: \"desktop\", width: 1280, height: 800 },\n { name: \"mobile\", width: 390, height: 844 },\n];\n\nconst NAMED_VIEWPORTS: Readonly<Record<string, VerifyViewport>> = {\n desktop: { name: \"desktop\", width: 1280, height: 800 },\n mobile: { name: \"mobile\", width: 390, height: 844 },\n tablet: { name: \"tablet\", width: 768, height: 1024 },\n};\n\n/**\n * The viewports a manifest's `verify.viewports` names (`desktop`, `mobile`, `tablet`, or\n * `<width>x<height>` from 200 to 4000 px), in its order and without repeats; the defaults when it\n * names none. Returns the names it couldn't read beside them.\n */\nexport function viewportsFor(names: readonly string[] | undefined): {\n readonly viewports: readonly VerifyViewport[];\n readonly unknown: readonly string[];\n} {\n if (names === undefined || names.length === 0)\n return { viewports: DEFAULT_VIEWPORTS, unknown: [] };\n const viewports: VerifyViewport[] = [];\n const unknown: string[] = [];\n for (const raw of names) {\n const name = raw.trim().toLowerCase();\n const sized = /^(\\d{3,4})x(\\d{3,4})$/.exec(name);\n const viewport =\n NAMED_VIEWPORTS[name] ??\n (sized ? { name, width: Number(sized[1]), height: Number(sized[2]) } : undefined);\n if (\n !viewport ||\n viewport.width < 200 ||\n viewport.height < 200 ||\n viewport.width > 4000 ||\n viewport.height > 4000\n ) {\n unknown.push(raw);\n continue;\n }\n if (!viewports.some((known) => known.name === viewport.name)) viewports.push(viewport);\n }\n return { viewports: viewports.length > 0 ? viewports : DEFAULT_VIEWPORTS, unknown };\n}\n\n/** What one image costs each model family to read (D138 item 9). */\nexport interface TokenEstimate {\n /** Claude's high-resolution tier (Claude 4.7 and later). */\n readonly claude: number;\n /** GPT at `detail: \"high\"` (gpt-5.5, gpt-5.6, gpt-6-astra). */\n readonly gpt: number;\n /** Gemini 3 and 4 at the default media resolution. */\n readonly gemini: number;\n}\n\n/** Claude: tokens of an image already within its tier's limits. */\nconst claudeTokens = (width: number, height: number): number =>\n Math.ceil(width / 28) * Math.ceil(height / 28);\n\n/**\n * The size Claude resizes an image to (its documented reference implementation): the largest\n * aspect-preserving size whose 28-px-rounded sides fit `maxEdge` and whose tokens fit `maxTokens`.\n */\nfunction claudeSize(\n width: number,\n height: number,\n maxEdge: number,\n maxTokens: number,\n): readonly [number, number] {\n const fits = (w: number, h: number): boolean =>\n Math.ceil(w / 28) * 28 <= maxEdge &&\n Math.ceil(h / 28) * 28 <= maxEdge &&\n claudeTokens(w, h) <= maxTokens;\n if (fits(width, height)) return [width, height];\n if (height > width) {\n const [h, w] = claudeSize(height, width, maxEdge, maxTokens);\n return [w, h];\n }\n const aspect = width / height;\n let lo = 1;\n let hi = width;\n while (lo + 1 < hi) {\n const mid = Math.floor((lo + hi) / 2);\n if (fits(mid, Math.max(Math.round(mid / aspect), 1))) lo = mid;\n else hi = mid;\n }\n return [lo, Math.max(Math.round(lo / aspect), 1)];\n}\n\n/** GPT at `detail: \"high\"`: fit 2048 × 2048, then a 2,500-patch budget, then the 1.2 multiplier. */\nfunction gptTokens(width: number, height: number): number {\n let w = width;\n let h = height;\n const edge = Math.min(1, 2048 / Math.max(w, h));\n if (edge < 1) {\n w = Math.max(1, Math.round(w * edge));\n h = Math.max(1, Math.round(h * edge));\n }\n let patches = Math.ceil(w / 32) * Math.ceil(h / 32);\n const budget = 2500;\n if (patches > budget) {\n const shrink = Math.sqrt((32 ** 2 * budget) / (w * h));\n const adjusted =\n shrink *\n Math.min(\n Math.floor((w * shrink) / 32) / ((w * shrink) / 32),\n Math.floor((h * shrink) / 32) / ((h * shrink) / 32),\n );\n patches = Math.ceil(Math.floor(w * adjusted) / 32) * Math.ceil(Math.floor(h * adjusted) / 32);\n }\n return Math.ceil(patches * 1.2);\n}\n\n/**\n * What an image of `width` × `height` pixels costs Claude, GPT and Gemini to read, by each\n * provider's published rule as verified on 2026-10-17 (VERIFIED_FACTS, WP-09). Estimates: harnesses\n * use them to budget, and each provider may round differently by a token.\n */\nexport function estimateImageTokens(width: number, height: number): TokenEstimate {\n const [cw, ch] = claudeSize(width, height, 2576, 4784);\n return { claude: claudeTokens(cw, ch), gpt: gptTokens(width, height), gemini: 1120 };\n}\n\n/** One screenshot in a verdict (AX-05). */\nexport interface VerdictScreenshot {\n /** The viewport's name. */\n readonly viewport: string;\n /** The PNG, at device pixel ratio 1. */\n readonly path: string;\n /** The image's width in pixels. */\n readonly width: number;\n /** The image's height in pixels. */\n readonly height: number;\n /** What reading the image costs each model family ({@link estimateImageTokens}). */\n readonly tokensEstimate: TokenEstimate;\n /** Whether the caller is handed the image: on failure, or when asked (`screenshots`). */\n readonly returned: boolean;\n}\n\n/** One ARIA snapshot in a verdict: the text-only picture of what a viewport shows. */\nexport interface VerdictAria {\n /** The viewport's name. */\n readonly viewport: string;\n /** The snapshot's YAML. */\n readonly path: string;\n /** A one-line count of what it holds: headings, controls, landmarks. */\n readonly summary: string;\n}\n\n/** The verdict of one `verify` run (INTERFACES §13). `status` is `fail` exactly when an error exists. */\nexport interface VerifyVerdict {\n /** `fail` when any diagnostic is an error, else `pass`. */\n readonly status: \"pass\" | \"fail\";\n /** What was verified. */\n readonly artifact: {\n /** The artifact, when it has one already: a manifest `id` or a published path. */\n readonly id?: string;\n /** The source path as the request named it. */\n readonly path: string;\n /** The snapshot's digest (DATA_MODEL §2); empty when verify couldn't read the source. */\n readonly sourceDigest: string;\n /** The environment's digest, `lockDigest` included (DATA_MODEL §2); empty likewise. */\n readonly envDigest: string;\n /** The version this source would publish as, when the artifact is known (D89). */\n readonly versionId?: string;\n };\n /** Every finding, errors first, identical ones folded with a `count`. */\n readonly diagnostics: readonly Diagnostic[];\n /** One per viewport rendered. */\n readonly screenshots: readonly VerdictScreenshot[];\n /** One per viewport rendered. */\n readonly aria: readonly VerdictAria[];\n /** What the smoke test did. */\n readonly smoke: {\n /** Controls the smoke test used. */\n readonly interactions: number;\n /** Server functions that don't check `dryRun()` and were refused instead of run (D55). */\n readonly skippedActions: readonly string[];\n /** Field writes the interactions caused. */\n readonly stateChanges: number;\n };\n /** What changed since the last passing version; empty when there is none. */\n readonly regressions: {\n /**\n * The last passing version: the newest whose recorded verdict passed (D138 item 4). When it is\n * this very source, nothing needed comparing.\n */\n readonly against?: string;\n /** Controls and landmarks the baseline had and this source doesn't, in brief. */\n readonly aria?: string;\n /** The share of pixels that differ from the baseline, per viewport. */\n readonly pixels?: readonly { readonly viewport: string; readonly ratio: number }[];\n /** Contracts the baseline had that this source drops: fields, actions, live sources, pages. */\n readonly contracts?: readonly string[];\n };\n /** How long each stage took, in milliseconds, and `total`. */\n readonly timingsMs: Readonly<Record<string, number>>;\n}\n\nconst tokenEstimate: z.ZodType<TokenEstimate> = z.object({\n claude: z.int().min(0),\n gpt: z.int().min(0),\n gemini: z.int().min(0),\n});\n\n/** The Zod schema of the `VerifyVerdict` type. */\nexport const VerifyVerdict: z.ZodType<VerifyVerdict> = z\n .object({\n status: z.enum([\"pass\", \"fail\"]),\n artifact: z.object({\n id: z.string().exactOptional(),\n path: z.string(),\n sourceDigest: z.string(),\n envDigest: z.string(),\n versionId: z.string().exactOptional(),\n }),\n diagnostics: z.array(Diagnostic).readonly(),\n screenshots: z\n .array(\n z.object({\n viewport: z.string(),\n path: z.string(),\n width: z.int().min(1),\n height: z.int().min(1),\n tokensEstimate: tokenEstimate,\n returned: z.boolean(),\n }),\n )\n .readonly(),\n aria: z\n .array(z.object({ viewport: z.string(), path: z.string(), summary: z.string() }))\n .readonly(),\n smoke: z.object({\n interactions: z.int().min(0),\n skippedActions: z.array(z.string()).readonly(),\n stateChanges: z.int().min(0),\n }),\n regressions: z.object({\n against: z.string().exactOptional(),\n aria: z.string().exactOptional(),\n pixels: z\n .array(z.object({ viewport: z.string(), ratio: z.number().min(0).max(1) }))\n .readonly()\n .exactOptional(),\n contracts: z.array(z.string()).readonly().exactOptional(),\n }),\n timingsMs: z.record(z.string(), z.number().min(0)),\n })\n .register(wireRegistry, {\n id: \"VerifyVerdict\",\n description:\n \"The verdict of artifact/verify: pass or fail, diagnostics, screenshots with token estimates, ARIA snapshots, the smoke test, regressions and timings.\",\n });\n\n/** The notification `artifact/verify` sends while it runs, when the client accepts it. */\nexport const ARTIFACT_PROGRESS = \"artifact/progress\";\n\n/** `artifact/progress`: one stage of a long request started or ended. */\nexport interface ArtifactProgressParams {\n /** The `progressToken` the request carried. */\n readonly progressToken: string;\n /** The stage that started: `prepare`, `compile`, `boot`, `render`, `smoke`, `regression`. */\n readonly stage: string;\n /** How much of the request is done, from 0 to 1, when known. */\n readonly fraction?: number;\n}\n\n/** The Zod schema of the `ArtifactProgressParams` type. */\nexport const ArtifactProgressParams: z.ZodType<ArtifactProgressParams> = z\n .object({\n progressToken: z.string().min(1),\n stage: z.string().min(1),\n fraction: z.number().min(0).max(1).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ArtifactProgressParams\",\n description: \"One stage of a long request (artifact/verify) started.\",\n });\n\n/**\n * The global the verify runner's recorder installs in every frame of a render: a page in the\n * `verify` target reports errors its React error boundaries caught through it, with their\n * `cause` chains, so the runner judges each by its cause (D138 items 2 and 3, Opus review finding\n * 3). Viewers' pages never have it.\n */\nexport const VERIFY_REPORT = \"__mostraVerifyReport\";\n\n/**\n * What a verify run's page tells the runner about its fields (D138 item 3), on\n * `globalThis[VERIFY_PROBE]` in the `verify` target only: every field it mounted, how, and with\n * which initial value's type; internal to Mostra.\n */\nexport const VERIFY_PROBE = \"__mostraVerify\";\n\n/** One mounted field, as the probe reports it; internal to Mostra. */\nexport interface ProbedField {\n /** The field ID. */\n readonly id: string;\n /** Its scope, as first mounted. */\n readonly scope: \"viewer\" | \"artifact\";\n /** The hook that named it: `useField`, `useChoice`, `useForm` or `storage`. */\n readonly hook: string;\n /** `typeof` its initial value, `array` or `null`. */\n readonly initialType: string;\n /** How many components have it mounted now. */\n readonly mounts: number;\n /** Other hook kinds, scopes or initial types it was mounted with, if any. */\n readonly conflicts: readonly string[];\n}\n\n/** The verify runner's methods (ARCHITECTURE §1): the supervisor asks, the runner answers; internal to Mostra. */\nexport const VERIFY_RUNNER_METHODS = {\n /** Opens one capability link in a fresh browser context and reports what the page did. */\n render: \"verify/render\",\n /** Compares two screenshots and writes their difference. */\n compare: \"verify/compare\",\n} as const;\n\n/** `verify/render`'s params; internal to Mostra. */\nexport interface RenderRequest {\n /** The capability link to open, as a viewer would (D138 item 1). */\n readonly url: string;\n /** The viewport to render at, DPR 1. */\n readonly viewport: VerifyViewport;\n /** The fixed time `Date` reports, in ms since the epoch: the same for every render of a run. */\n readonly clockMs: number;\n /** Where the screenshot and the ARIA snapshot are written, named after `name`. */\n readonly outDir: string;\n /** The render's name: its files are `<name>.png` and `<name>.aria.yml`. */\n readonly name: string;\n /** What to collect besides readiness and the page's own errors. */\n readonly collect: {\n /** A screenshot of the viewport. */\n readonly screenshot: boolean;\n /** The ARIA snapshot. */\n readonly aria: boolean;\n /** axe-core's violations. */\n readonly axe: boolean;\n /** The page's mounted fields, from the field probe. */\n readonly fields: boolean;\n /** Run the smoke test after rendering, within this budget. */\n readonly smoke?: { readonly maxInteractions: number; readonly maxMs: number };\n };\n /** When this render must have ended, in ms since the epoch. */\n readonly deadline: number;\n}\n\n/** `verify/render`'s answer; internal to Mostra. */\nexport interface RenderResult {\n /** Whether the page reported `mostra/ready`. */\n readonly ready: boolean;\n /** What the runner found: page errors, console output, failed requests, axe, smoke, blank. */\n readonly findings: readonly Diagnostic[];\n /** The screenshot written, when asked for. */\n readonly screenshot?: { readonly path: string; readonly width: number; readonly height: number };\n /** The ARIA snapshot written, and its text, when asked for. */\n readonly aria?: { readonly path: string; readonly text: string };\n /** The mounted fields the probe reported, when asked for. */\n readonly fields?: readonly ProbedField[];\n /** What the smoke test did, when asked for. */\n readonly smoke?: {\n /** Controls used. */\n readonly interactions: number;\n /** Field writes they caused. */\n readonly stateChanges: number;\n /** Server functions the sandbox refused during the smoke test. */\n readonly skipped: readonly string[];\n /** Whether it stopped at its budget. */\n readonly budget: boolean;\n };\n /** Whether the render ran past its deadline and stopped where it was. */\n readonly timedOut: boolean;\n /** When each step ended, in ms after the render started. */\n readonly timingsMs: Readonly<Record<string, number>>;\n}\n\n/** `verify/compare`'s params; internal to Mostra. */\nexport interface CompareRequest {\n /** The baseline's screenshot. */\n readonly a: string;\n /** The source's screenshot. */\n readonly b: string;\n /** Where to write the difference image. */\n readonly diff: string;\n}\n\n/** `verify/compare`'s answer; internal to Mostra. */\nexport interface CompareResult {\n /** The share of pixels that differ beyond pixelmatch's perceptual threshold. */\n readonly ratio: number;\n /** Whether the two images had different sizes (then `ratio` is 1). */\n readonly sizeChanged: boolean;\n}\n\n/** A one-line count of an ARIA snapshot: headings, controls and landmarks. */\nexport function ariaSummary(text: string): string {\n const counts = new Map<string, number>();\n for (const match of text.matchAll(/^\\s*- ([a-z]+)\\b/gm)) {\n const role = match[1] as string;\n counts.set(role, (counts.get(role) ?? 0) + 1);\n }\n const named: [string, string][] = [\n [\"heading\", \"headings\"],\n [\"button\", \"buttons\"],\n [\"link\", \"links\"],\n [\"textbox\", \"text fields\"],\n [\"checkbox\", \"checkboxes\"],\n [\"combobox\", \"comboboxes\"],\n [\"tab\", \"tabs\"],\n [\"img\", \"images\"],\n [\"table\", \"tables\"],\n ];\n const parts = named\n .filter(([role]) => counts.has(role))\n .map(([role, plural]) => `${counts.get(role)} ${counts.get(role) === 1 ? role : plural}`);\n const landmarks = [\n \"main\",\n \"navigation\",\n \"banner\",\n \"contentinfo\",\n \"form\",\n \"region\",\n \"dialog\",\n ].filter((role) => counts.has(role));\n if (landmarks.length > 0) parts.push(`landmarks: ${landmarks.join(\", \")}`);\n return parts.length > 0 ? parts.join(\", \") : \"no headings, controls or landmarks\";\n}\n"],"mappings":";;;;;;;;;;AAaA,MAAa,mBAAwD,EAClE,KAAK;CAAC;CAAc;CAAU;AAAO,CAAC,CAAC,CACvC,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAaH,MAAa,oBAA+C,CAC1D;CAAE,MAAM;CAAW,OAAO;CAAM,QAAQ;AAAI,GAC5C;CAAE,MAAM;CAAU,OAAO;CAAK,QAAQ;AAAI,CAC5C;AAEA,MAAM,kBAA4D;CAChE,SAAS;EAAE,MAAM;EAAW,OAAO;EAAM,QAAQ;CAAI;CACrD,QAAQ;EAAE,MAAM;EAAU,OAAO;EAAK,QAAQ;CAAI;CAClD,QAAQ;EAAE,MAAM;EAAU,OAAO;EAAK,QAAQ;CAAK;AACrD;;;;;;AAOA,SAAgB,aAAa,OAG3B;CACA,IAAI,UAAU,KAAA,KAAa,MAAM,WAAW,GAC1C,OAAO;EAAE,WAAW;EAAmB,SAAS,CAAC;CAAE;CACrD,MAAM,YAA8B,CAAC;CACrC,MAAM,UAAoB,CAAC;CAC3B,KAAK,MAAM,OAAO,OAAO;EACvB,MAAM,OAAO,IAAI,KAAK,CAAC,CAAC,YAAY;EACpC,MAAM,Q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EACA;CACF,CAAC,CAAC,QAAQ,SAAS,OAAO,IAAI,IAAI,CAAC;CACnC,IAAI,UAAU,SAAS,GAAG,MAAM,KAAK,cAAc,UAAU,KAAK,IAAI,GAAG;CACzE,OAAO,MAAM,SAAS,IAAI,MAAM,KAAK,IAAI,IAAI;AAC/C"}
|
|
1
|
+
{"version":3,"file":"verify.js","names":[],"sources":["../src/verify.ts"],"sourcesContent":["/**\n * `verify` (D29, D41, D55, D72, D138; INTERFACES §13): the verdict it returns, the viewports it\n * renders, and the image-token estimates every screenshot carries. Pure and free of I/O, so the\n * runtime, the verify runner, the CLI and the MCP server share one definition.\n */\nimport * as z from \"zod\";\nimport { Diagnostic } from \"./diagnostics/diagnostic.ts\";\nimport { wireRegistry } from \"./wire-registry.ts\";\n\n/** When a verdict's screenshots are handed to the caller (AX-05): images cost tokens. */\nexport type ScreenshotPolicy = \"on-failure\" | \"always\" | \"never\";\n\n/** The Zod schema of the `ScreenshotPolicy` type. */\nexport const ScreenshotPolicy: z.ZodType<ScreenshotPolicy, string> = z\n .enum([\"on-failure\", \"always\", \"never\"])\n .register(wireRegistry, {\n id: \"ScreenshotPolicy\",\n description: \"When screenshots are returned: on failure (the default), always or never.\",\n });\n\n/** One viewport verify renders at device pixel ratio 1. */\nexport interface VerifyViewport {\n /** Its name in the verdict: `desktop`, `mobile`, `tablet`, or `<width>x<height>`. */\n readonly name: string;\n /** Its width in CSS pixels, which at DPR 1 are the screenshot's pixels. */\n readonly width: number;\n /** Its height in CSS pixels. */\n readonly height: number;\n}\n\n/** The viewports verify renders when the manifest names none (ROUND-3 §9): desktop and mobile. */\nexport const DEFAULT_VIEWPORTS: readonly VerifyViewport[] = [\n { name: \"desktop\", width: 1280, height: 800 },\n { name: \"mobile\", width: 390, height: 844 },\n];\n\nconst NAMED_VIEWPORTS: Readonly<Record<string, VerifyViewport>> = {\n desktop: { name: \"desktop\", width: 1280, height: 800 },\n mobile: { name: \"mobile\", width: 390, height: 844 },\n tablet: { name: \"tablet\", width: 768, height: 1024 },\n};\n\n/**\n * The viewports a manifest's `verify.viewports` names (`desktop`, `mobile`, `tablet`, or\n * `<width>x<height>` from 200 to 4000 px), in its order and without repeats; the defaults when it\n * names none. Returns the names it couldn't read beside them.\n */\nexport function viewportsFor(names: readonly string[] | undefined): {\n readonly viewports: readonly VerifyViewport[];\n readonly unknown: readonly string[];\n} {\n if (names === undefined || names.length === 0)\n return { viewports: DEFAULT_VIEWPORTS, unknown: [] };\n const viewports: VerifyViewport[] = [];\n const unknown: string[] = [];\n for (const raw of names) {\n const name = raw.trim().toLowerCase();\n const sized = /^(\\d{3,4})x(\\d{3,4})$/.exec(name);\n const viewport =\n NAMED_VIEWPORTS[name] ??\n (sized ? { name, width: Number(sized[1]), height: Number(sized[2]) } : undefined);\n if (\n !viewport ||\n viewport.width < 200 ||\n viewport.height < 200 ||\n viewport.width > 4000 ||\n viewport.height > 4000\n ) {\n unknown.push(raw);\n continue;\n }\n if (!viewports.some((known) => known.name === viewport.name)) viewports.push(viewport);\n }\n return { viewports: viewports.length > 0 ? viewports : DEFAULT_VIEWPORTS, unknown };\n}\n\n/** What one image costs each model family to read (D138 item 9). */\nexport interface TokenEstimate {\n /** Claude's high-resolution tier (Claude 4.7 and later). */\n readonly claude: number;\n /** GPT at `detail: \"high\"` (gpt-5.5, gpt-5.6, gpt-6-astra). */\n readonly gpt: number;\n /** Gemini 3 and 4 at the default media resolution. */\n readonly gemini: number;\n}\n\n/** Claude: tokens of an image already within its tier's limits. */\nconst claudeTokens = (width: number, height: number): number =>\n Math.ceil(width / 28) * Math.ceil(height / 28);\n\n/**\n * The size Claude resizes an image to (its documented reference implementation): the largest\n * aspect-preserving size whose 28-px-rounded sides fit `maxEdge` and whose tokens fit `maxTokens`.\n */\nfunction claudeSize(\n width: number,\n height: number,\n maxEdge: number,\n maxTokens: number,\n): readonly [number, number] {\n const fits = (w: number, h: number): boolean =>\n Math.ceil(w / 28) * 28 <= maxEdge &&\n Math.ceil(h / 28) * 28 <= maxEdge &&\n claudeTokens(w, h) <= maxTokens;\n if (fits(width, height)) return [width, height];\n if (height > width) {\n const [h, w] = claudeSize(height, width, maxEdge, maxTokens);\n return [w, h];\n }\n const aspect = width / height;\n let lo = 1;\n let hi = width;\n while (lo + 1 < hi) {\n const mid = Math.floor((lo + hi) / 2);\n if (fits(mid, Math.max(Math.round(mid / aspect), 1))) lo = mid;\n else hi = mid;\n }\n return [lo, Math.max(Math.round(lo / aspect), 1)];\n}\n\n/** GPT at `detail: \"high\"`: fit 2048 × 2048, then a 2,500-patch budget, then the 1.2 multiplier. */\nfunction gptTokens(width: number, height: number): number {\n let w = width;\n let h = height;\n const edge = Math.min(1, 2048 / Math.max(w, h));\n if (edge < 1) {\n w = Math.max(1, Math.round(w * edge));\n h = Math.max(1, Math.round(h * edge));\n }\n let patches = Math.ceil(w / 32) * Math.ceil(h / 32);\n const budget = 2500;\n if (patches > budget) {\n const shrink = Math.sqrt((32 ** 2 * budget) / (w * h));\n const adjusted =\n shrink *\n Math.min(\n Math.floor((w * shrink) / 32) / ((w * shrink) / 32),\n Math.floor((h * shrink) / 32) / ((h * shrink) / 32),\n );\n patches = Math.ceil(Math.floor(w * adjusted) / 32) * Math.ceil(Math.floor(h * adjusted) / 32);\n }\n return Math.ceil(patches * 1.2);\n}\n\n/**\n * What an image of `width` × `height` pixels costs Claude, GPT and Gemini to read, by each\n * provider's published rule as verified on 2026-10-17 (VERIFIED_FACTS, WP-09). Estimates: harnesses\n * use them to budget, and each provider may round differently by a token.\n */\nexport function estimateImageTokens(width: number, height: number): TokenEstimate {\n const [cw, ch] = claudeSize(width, height, 2576, 4784);\n return { claude: claudeTokens(cw, ch), gpt: gptTokens(width, height), gemini: 1120 };\n}\n\n/** One screenshot in a verdict (AX-05). */\nexport interface VerdictScreenshot {\n /** The viewport's name. */\n readonly viewport: string;\n /** The PNG, at device pixel ratio 1. */\n readonly path: string;\n /** The image's width in pixels. */\n readonly width: number;\n /** The image's height in pixels. */\n readonly height: number;\n /** What reading the image costs each model family ({@link estimateImageTokens}). */\n readonly tokensEstimate: TokenEstimate;\n /** Whether the caller is handed the image: on failure, or when asked (`screenshots`). */\n readonly returned: boolean;\n}\n\n/** One ARIA snapshot in a verdict: the text-only picture of what a viewport shows. */\nexport interface VerdictAria {\n /** The viewport's name. */\n readonly viewport: string;\n /** The snapshot's YAML. */\n readonly path: string;\n /** A one-line count of what it holds: headings, controls, landmarks. */\n readonly summary: string;\n}\n\n/** The verdict of one `verify` run (INTERFACES §13). `status` is `fail` exactly when an error exists. */\nexport interface VerifyVerdict {\n /** `fail` when any diagnostic is an error, else `pass`. */\n readonly status: \"pass\" | \"fail\";\n /** What was verified. */\n readonly artifact: {\n /** The artifact, when it has one already: a manifest `id` or a published path. */\n readonly id?: string;\n /** The source path as the request named it. */\n readonly path: string;\n /** The snapshot's digest (DATA_MODEL §2); empty when verify couldn't read the source. */\n readonly sourceDigest: string;\n /** The environment's digest, `lockDigest` included (DATA_MODEL §2); empty likewise. */\n readonly envDigest: string;\n /** The version this source would publish as, when the artifact is known (D89). */\n readonly versionId?: string;\n };\n /** Every finding, errors first, identical ones folded with a `count`. */\n readonly diagnostics: readonly Diagnostic[];\n /** One per viewport rendered. */\n readonly screenshots: readonly VerdictScreenshot[];\n /** One per viewport rendered. */\n readonly aria: readonly VerdictAria[];\n /** What the smoke test did. */\n readonly smoke: {\n /** Controls the smoke test used. */\n readonly interactions: number;\n /** Server functions that don't check `dryRun()` and were refused instead of run (D55). */\n readonly skippedActions: readonly string[];\n /** Field writes the interactions caused. */\n readonly stateChanges: number;\n };\n /** What changed since the last passing version; empty when there is none. */\n readonly regressions: {\n /**\n * The last passing version: the newest whose recorded verdict passed (D138 item 4). When it is\n * this very source, nothing needed comparing.\n */\n readonly against?: string;\n /** Controls and landmarks the baseline had and this source doesn't, in brief. */\n readonly aria?: string;\n /** The share of pixels that differ from the baseline, per viewport. */\n readonly pixels?: readonly { readonly viewport: string; readonly ratio: number }[];\n /** Contracts the baseline had that this source drops: fields, actions, live sources, pages. */\n readonly contracts?: readonly string[];\n };\n /** How long each stage took, in milliseconds, and `total`. */\n readonly timingsMs: Readonly<Record<string, number>>;\n}\n\nconst tokenEstimate: z.ZodType<TokenEstimate> = z.object({\n claude: z.int().min(0),\n gpt: z.int().min(0),\n gemini: z.int().min(0),\n});\n\n/** The Zod schema of the `VerifyVerdict` type. */\nexport const VerifyVerdict: z.ZodType<VerifyVerdict> = z\n .object({\n status: z.enum([\"pass\", \"fail\"]),\n artifact: z.object({\n id: z.string().exactOptional(),\n path: z.string(),\n sourceDigest: z.string(),\n envDigest: z.string(),\n versionId: z.string().exactOptional(),\n }),\n diagnostics: z.array(Diagnostic).readonly(),\n screenshots: z\n .array(\n z.object({\n viewport: z.string(),\n path: z.string(),\n width: z.int().min(1),\n height: z.int().min(1),\n tokensEstimate: tokenEstimate,\n returned: z.boolean(),\n }),\n )\n .readonly(),\n aria: z\n .array(z.object({ viewport: z.string(), path: z.string(), summary: z.string() }))\n .readonly(),\n smoke: z.object({\n interactions: z.int().min(0),\n skippedActions: z.array(z.string()).readonly(),\n stateChanges: z.int().min(0),\n }),\n regressions: z.object({\n against: z.string().exactOptional(),\n aria: z.string().exactOptional(),\n pixels: z\n .array(z.object({ viewport: z.string(), ratio: z.number().min(0).max(1) }))\n .readonly()\n .exactOptional(),\n contracts: z.array(z.string()).readonly().exactOptional(),\n }),\n timingsMs: z.record(z.string(), z.number().min(0)),\n })\n .register(wireRegistry, {\n id: \"VerifyVerdict\",\n description:\n \"The verdict of artifact/verify: pass or fail, diagnostics, screenshots with token estimates, ARIA snapshots, the smoke test, regressions and timings.\",\n });\n\n/** The notification `artifact/verify` sends while it runs, when the client accepts it. */\nexport const ARTIFACT_PROGRESS = \"artifact/progress\";\n\n/** `artifact/progress`: one stage of a long request started or ended. */\nexport interface ArtifactProgressParams {\n /** The `progressToken` the request carried. */\n readonly progressToken: string;\n /** The stage that started: `prepare`, `compile`, `boot`, `render`, `smoke`, `regression`. */\n readonly stage: string;\n /** How much of the request is done, from 0 to 1, when known. */\n readonly fraction?: number;\n}\n\n/** The Zod schema of the `ArtifactProgressParams` type. */\nexport const ArtifactProgressParams: z.ZodType<ArtifactProgressParams> = z\n .object({\n progressToken: z.string().min(1),\n stage: z.string().min(1),\n fraction: z.number().min(0).max(1).exactOptional(),\n })\n .register(wireRegistry, {\n id: \"ArtifactProgressParams\",\n description: \"One stage of a long request (artifact/verify) started.\",\n });\n\n/**\n * The global the verify runner's recorder installs in every frame of a render: a page in the\n * `verify` target reports errors its React error boundaries caught through it, with their\n * `cause` chains, so the runner judges each by its cause (D138 items 2 and 3, Opus review finding\n * 3). Viewers' pages never have it.\n */\nexport const VERIFY_REPORT = \"__mostraVerifyReport\";\n\n/**\n * What a verify run's page tells the runner about its fields (D138 item 3), on\n * `globalThis[VERIFY_PROBE]` in the `verify` target only: every field it mounted, how, and with\n * which initial value's type; internal to Mostra.\n */\nexport const VERIFY_PROBE = \"__mostraVerify\";\n\n/** One mounted field, as the probe reports it; internal to Mostra. */\nexport interface ProbedField {\n /** The field ID. */\n readonly id: string;\n /** Its scope, as first mounted. */\n readonly scope: \"viewer\" | \"artifact\";\n /** The hook that named it: `useField`, `useChoice`, `useForm` or `storage`. */\n readonly hook: string;\n /** `typeof` its initial value, `array` or `null`. */\n readonly initialType: string;\n /** How many components have it mounted now. */\n readonly mounts: number;\n /** Other hook kinds, scopes or initial types it was mounted with, if any. */\n readonly conflicts: readonly string[];\n}\n\n/** The verify runner's methods (ARCHITECTURE §1): the supervisor asks, the runner answers; internal to Mostra. */\nexport const VERIFY_RUNNER_METHODS = {\n /** Opens one capability link in a fresh browser context and reports what the page did. */\n render: \"verify/render\",\n /** Compares two screenshots and writes their difference. */\n compare: \"verify/compare\",\n} as const;\n\n/** `verify/render`'s params; internal to Mostra. */\nexport interface RenderRequest {\n /** The capability link to open, as a viewer would (D138 item 1). */\n readonly url: string;\n /** The viewport to render at, DPR 1. */\n readonly viewport: VerifyViewport;\n /** The fixed time `Date` reports, in ms since the epoch: the same for every render of a run. */\n readonly clockMs: number;\n /** Where the screenshot and the ARIA snapshot are written, named after `name`. */\n readonly outDir: string;\n /** The render's name: its files are `<name>.png` and `<name>.aria.yml`. */\n readonly name: string;\n /** What to collect besides readiness and the page's own errors. */\n readonly collect: {\n /** A screenshot of the viewport. */\n readonly screenshot: boolean;\n /** The ARIA snapshot. */\n readonly aria: boolean;\n /** axe-core's violations. */\n readonly axe: boolean;\n /** The page's mounted fields, from the field probe. */\n readonly fields: boolean;\n /** Run the smoke test after rendering, within this budget. */\n readonly smoke?: { readonly maxInteractions: number; readonly maxMs: number };\n };\n /** When this render must have ended, in ms since the epoch. */\n readonly deadline: number;\n}\n\n/** `verify/render`'s answer; internal to Mostra. */\nexport interface RenderResult {\n /** Whether the page reported `mostra/ready`. */\n readonly ready: boolean;\n /** What the runner found: page errors, console output, failed requests, axe, smoke, blank. */\n readonly findings: readonly Diagnostic[];\n /** The screenshot written, when asked for. */\n readonly screenshot?: { readonly path: string; readonly width: number; readonly height: number };\n /** The ARIA snapshot written, and its text, when asked for. */\n readonly aria?: { readonly path: string; readonly text: string };\n /** The mounted fields the probe reported, when asked for. */\n readonly fields?: readonly ProbedField[];\n /** What the smoke test did, when asked for. */\n readonly smoke?: {\n /** Controls used. */\n readonly interactions: number;\n /** Field writes they caused. */\n readonly stateChanges: number;\n /** Server functions the sandbox refused during the smoke test. */\n readonly skipped: readonly string[];\n /** Whether it stopped at its budget. */\n readonly budget: boolean;\n };\n /** Whether the render ran past its deadline and stopped where it was. */\n readonly timedOut: boolean;\n /** When each step ended, in ms after the render started. */\n readonly timingsMs: Readonly<Record<string, number>>;\n /**\n * Why the page was rendered a second time, in a fresh browser context, when it was: a\n * connection the browser couldn't make for a reason of its own (Chromium's random local port\n * colliding on Windows, `net::ERR_NO_BUFFER_SPACE`, D157, #132). The second render's findings\n * are the answer's.\n */\n readonly renderedAgain?: string;\n}\n\n/** `verify/compare`'s params; internal to Mostra. */\nexport interface CompareRequest {\n /** The baseline's screenshot. */\n readonly a: string;\n /** The source's screenshot. */\n readonly b: string;\n /** Where to write the difference image. */\n readonly diff: string;\n}\n\n/** `verify/compare`'s answer; internal to Mostra. */\nexport interface CompareResult {\n /** The share of pixels that differ beyond pixelmatch's perceptual threshold. */\n readonly ratio: number;\n /** Whether the two images had different sizes (then `ratio` is 1). */\n readonly sizeChanged: boolean;\n}\n\n/** A one-line count of an ARIA snapshot: headings, controls and landmarks. */\nexport function ariaSummary(text: string): string {\n const counts = new Map<string, number>();\n for (const match of text.matchAll(/^\\s*- ([a-z]+)\\b/gm)) {\n const role = match[1] as string;\n counts.set(role, (counts.get(role) ?? 0) + 1);\n }\n const named: [string, string][] = [\n [\"heading\", \"headings\"],\n [\"button\", \"buttons\"],\n [\"link\", \"links\"],\n [\"textbox\", \"text fields\"],\n [\"checkbox\", \"checkboxes\"],\n [\"combobox\", \"comboboxes\"],\n [\"tab\", \"tabs\"],\n [\"img\", \"images\"],\n [\"table\", \"tables\"],\n ];\n const parts = named\n .filter(([role]) => counts.has(role))\n .map(([role, plural]) => `${counts.get(role)} ${counts.get(role) === 1 ? role : plural}`);\n const landmarks = [\n \"main\",\n \"navigation\",\n \"banner\",\n \"contentinfo\",\n \"form\",\n \"region\",\n \"dialog\",\n ].filter((role) => counts.has(role));\n if (landmarks.length > 0) parts.push(`landmarks: ${landmarks.join(\", \")}`);\n return parts.length > 0 ? parts.join(\", \") : \"no headings, controls or landmarks\";\n}\n"],"mappings":";;;;;;;;;;AAaA,MAAa,mBAAwD,EAClE,KAAK;CAAC;CAAc;CAAU;AAAO,CAAC,CAAC,CACvC,SAAS,cAAc;CACtB,IAAI;CACJ,aAAa;AACf,CAAC;;AAaH,MAAa,oBAA+C,CAC1D;CAAE,MAAM;CAAW,OAAO;CAAM,QAAQ;AAAI,GAC5C;CAAE,MAAM;CAAU,OAAO;CAAK,QAAQ;AAAI,CAC5C;AAEA,MAAM,kBAA4D;CAChE,SAAS;EAAE,MA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EACtB,CAAC,UAAU,SAAS;EACpB,CAAC,QAAQ,OAAO;EAChB,CAAC,WAAW,aAAa;EACzB,CAAC,YAAY,YAAY;EACzB,CAAC,YAAY,YAAY;EACzB,CAAC,OAAO,MAAM;EACd,CAAC,OAAO,QAAQ;EAChB,CAAC,SAAS,QAAQ;CAEF,CAAC,CAChB,QAAQ,CAAC,UAAU,OAAO,IAAI,IAAI,CAAC,CAAC,CACpC,KAAK,CAAC,MAAM,YAAY,GAAG,OAAO,IAAI,IAAI,EAAE,GAAG,OAAO,IAAI,IAAI,MAAM,IAAI,OAAO,QAAQ;CAC1F,MAAM,YAAY;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,QAAQ,SAAS,OAAO,IAAI,IAAI,CAAC;CACnC,IAAI,UAAU,SAAS,GAAG,MAAM,KAAK,cAAc,UAAU,KAAK,IAAI,GAAG;CACzE,OAAO,MAAM,SAAS,IAAI,MAAM,KAAK,IAAI,IAAI;AAC/C"}
|
package/dist/worker.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Frame, WireError } from "./serializer.js";
|
|
2
|
-
import { ActionError, Batches, RunProgress } from "./actions.js";
|
|
3
2
|
import { DocumentRevision, FieldOp, MutationResult } from "./interaction.js";
|
|
3
|
+
import { ActionError, Batches, RunProgress } from "./actions.js";
|
|
4
4
|
import * as z from "zod";
|
|
5
5
|
//#region src/worker.d.ts
|
|
6
6
|
/** The worker channel's revision, which a worker states in its `worker/start` answer. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mostra/protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Mostra's shared protocol vocabulary: IDs, dated revisions and diagnostics, with Zod schemas and generated JSON Schema.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "The Mostra Authors",
|