screw-bugs 0.1.8 → 0.1.10

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 (107) hide show
  1. package/README.md +49 -34
  2. package/dist/browser-playwright/capture.js +1 -1
  3. package/dist/browser-playwright/launch.js +27 -10
  4. package/dist/browser-playwright/page.d.ts +48 -26
  5. package/dist/browser-playwright/page.js +86 -89
  6. package/dist/browser-playwright/recorder.d.ts +154 -0
  7. package/dist/browser-playwright/recorder.js +382 -0
  8. package/dist/build-info.json +3 -3
  9. package/dist/cli/app.js +6 -2
  10. package/dist/cli/commands.js +4 -3
  11. package/dist/cli/doctor.d.ts +17 -2
  12. package/dist/cli/doctor.js +62 -4
  13. package/dist/cli/mcp.js +2 -2
  14. package/dist/cli/report-server.d.ts +19 -10
  15. package/dist/cli/report-server.js +43 -18
  16. package/dist/cli/share.js +2 -2
  17. package/dist/cli/sign-in.d.ts +9 -3
  18. package/dist/cli/sign-in.js +12 -9
  19. package/dist/cli/tailnet.d.ts +57 -0
  20. package/dist/cli/tailnet.js +82 -0
  21. package/dist/core/index.d.ts +1 -14
  22. package/dist/core/index.js +3 -14
  23. package/dist/report/index.d.ts +1 -10
  24. package/dist/report/index.js +3 -10
  25. package/dist/schema/index.d.ts +1 -9
  26. package/dist/schema/index.js +3 -9
  27. package/package.json +14 -14
  28. package/dist/core/accounts.d.ts +0 -40
  29. package/dist/core/accounts.js +0 -95
  30. package/dist/core/css.d.ts +0 -95
  31. package/dist/core/css.js +0 -436
  32. package/dist/core/engine.d.ts +0 -75
  33. package/dist/core/engine.js +0 -554
  34. package/dist/core/errors.d.ts +0 -85
  35. package/dist/core/errors.js +0 -36
  36. package/dist/core/evidence.d.ts +0 -14
  37. package/dist/core/evidence.js +0 -131
  38. package/dist/core/labels.d.ts +0 -47
  39. package/dist/core/labels.js +0 -199
  40. package/dist/core/liveness.d.ts +0 -45
  41. package/dist/core/liveness.js +0 -66
  42. package/dist/core/marks.d.ts +0 -63
  43. package/dist/core/marks.js +0 -410
  44. package/dist/core/services.d.ts +0 -574
  45. package/dist/core/services.js +0 -25
  46. package/dist/core/share.d.ts +0 -68
  47. package/dist/core/share.js +0 -318
  48. package/dist/core/steps.d.ts +0 -106
  49. package/dist/core/steps.js +0 -722
  50. package/dist/core/uploads.d.ts +0 -49
  51. package/dist/core/uploads.js +0 -133
  52. package/dist/core/video.d.ts +0 -47
  53. package/dist/core/video.js +0 -233
  54. package/dist/core/viewport.d.ts +0 -28
  55. package/dist/core/viewport.js +0 -50
  56. package/dist/report/assets.d.ts +0 -34
  57. package/dist/report/assets.js +0 -105
  58. package/dist/report/bug.d.ts +0 -11
  59. package/dist/report/bug.js +0 -20
  60. package/dist/report/html.d.ts +0 -47
  61. package/dist/report/html.js +0 -923
  62. package/dist/report/icons.d.ts +0 -51
  63. package/dist/report/icons.js +0 -93
  64. package/dist/report/live.d.ts +0 -7
  65. package/dist/report/live.js +0 -135
  66. package/dist/report/logos.d.ts +0 -4
  67. package/dist/report/logos.js +0 -19
  68. package/dist/report/markup.d.ts +0 -50
  69. package/dist/report/markup.js +0 -156
  70. package/dist/report/menu-bar.d.ts +0 -60
  71. package/dist/report/menu-bar.js +0 -157
  72. package/dist/report/player.d.ts +0 -102
  73. package/dist/report/player.js +0 -315
  74. package/dist/report/pr-summary.d.ts +0 -11
  75. package/dist/report/pr-summary.js +0 -119
  76. package/dist/report/sha256.d.ts +0 -9
  77. package/dist/report/sha256.js +0 -97
  78. package/dist/report/share-page.d.ts +0 -48
  79. package/dist/report/share-page.js +0 -291
  80. package/dist/report/shots.d.ts +0 -59
  81. package/dist/report/shots.js +0 -280
  82. package/dist/report/sign-in.d.ts +0 -41
  83. package/dist/report/sign-in.js +0 -568
  84. package/dist/report/styles.d.ts +0 -3
  85. package/dist/report/styles.js +0 -274
  86. package/dist/report/view.d.ts +0 -296
  87. package/dist/report/view.js +0 -702
  88. package/dist/report/walkthrough.d.ts +0 -93
  89. package/dist/report/walkthrough.js +0 -716
  90. package/dist/schema/accounts.d.ts +0 -137
  91. package/dist/schema/accounts.js +0 -121
  92. package/dist/schema/config.d.ts +0 -7
  93. package/dist/schema/config.js +0 -6
  94. package/dist/schema/doctor.d.ts +0 -46
  95. package/dist/schema/doctor.js +0 -30
  96. package/dist/schema/evidence.d.ts +0 -1115
  97. package/dist/schema/evidence.js +0 -565
  98. package/dist/schema/findings.d.ts +0 -161
  99. package/dist/schema/findings.js +0 -82
  100. package/dist/schema/job.d.ts +0 -1905
  101. package/dist/schema/job.js +0 -577
  102. package/dist/schema/ledger.d.ts +0 -1124
  103. package/dist/schema/ledger.js +0 -285
  104. package/dist/schema/share.d.ts +0 -55
  105. package/dist/schema/share.js +0 -64
  106. package/dist/schema/status.d.ts +0 -7
  107. package/dist/schema/status.js +0 -11
@@ -1,565 +0,0 @@
1
- import { Schema } from 'effect';
2
- import { CaseStatus } from './status.js';
3
- /*
4
- * What a run records besides statuses: when each case and step happened in the session's video,
5
- * the screenshots it took with the boxes of the elements the steps acted on, and a few short facts
6
- * about the page. Every field the ledger gained for this is optional, so ledgers of older runs
7
- * still read.
8
- */
9
- /** A rectangle on a screenshot, in image pixels (CSS pixels times the device pixel ratio). */
10
- export const Box = Schema.Struct({
11
- x: Schema.Number,
12
- y: Schema.Number,
13
- width: Schema.Number,
14
- height: Schema.Number,
15
- });
16
- /**
17
- * The page's visual viewport when boxes were measured: what of the page's layout a phone's screen
18
- * (and so a screenshot of the viewport, and the video) shows. `scale` is how many CSS pixels of
19
- * the viewport Playwright set one CSS pixel of the layout is shown as (0.41 for a page without a
20
- * viewport meta tag laid out 980 wide on a 402 wide phone, 2 for one zoomed in twice), and `x` and
21
- * `y` are where its top left is in the layout viewport, in layout CSS pixels (moved by pinch zoom).
22
- * Boxes saved with it already account for it; on a desktop it is `{ scale: 1, x: 0, y: 0 }`.
23
- */
24
- export const VisualViewport = Schema.Struct({
25
- scale: Schema.Number,
26
- x: Schema.Number,
27
- y: Schema.Number,
28
- });
29
- /**
30
- * Why a screenshot was taken: `step` at a step that acts on or finds an element (click, fill,
31
- * expectText), `named` by a screenshot step, `failure` when the case stopped.
32
- */
33
- export const ShotKind = Schema.Literals(['step', 'named', 'failure']);
34
- /** One screenshot of a case, as the ledger records it. */
35
- export const Shot = Schema.Struct({
36
- /** Such as `01-03`: case and screenshot number. What agents name a screenshot by. */
37
- id: Schema.String,
38
- /** Relative to the run folder, such as `evidence/01/03-step2-click.png`. */
39
- path: Schema.String,
40
- /** The name it was saved under: the job's own for `named`, else such as `step2-click`. */
41
- name: Schema.String,
42
- kind: ShotKind,
43
- /** The step it belongs to, numbered as `CaseEntry.step`. */
44
- step: Schema.Int,
45
- /** The whole page (`true`), or what was in the viewport. */
46
- fullPage: Schema.Boolean,
47
- /** Image size in pixels. */
48
- width: Schema.Int,
49
- height: Schema.Int,
50
- /** Where the element the step acted on was, when it had one and it could be measured. */
51
- target: Schema.optionalKey(Box),
52
- /** Where its text and images were inside `target` (see `Candidate.content`), when measured. */
53
- targetContent: Schema.optionalKey(Box),
54
- /** Why the element the step acted on has no box here although it was measured, in words. */
55
- targetProblem: Schema.optionalKey(Schema.String),
56
- /** The page state saved with it (a {@link ShotPage}), relative to the run folder. */
57
- page: Schema.optionalKey(Schema.String),
58
- /** When it was taken, in ms from the start of the session's video. */
59
- atMs: Schema.optionalKey(Schema.Number),
60
- /**
61
- * When `target` was measured, in ms from the start of the session's video: what the video
62
- * shows the box at, before the image was taken. Missing in older ledgers.
63
- */
64
- targetAtMs: Schema.optionalKey(Schema.Number),
65
- /**
66
- * The visual viewport `target` and the saved page state were measured in, which their boxes
67
- * account for (see `VisualViewport`). Missing in older ledgers, whose boxes are in the page's
68
- * layout: right on a desktop, but possibly scaled or moved on a phone (see `boxesDrawable`); and
69
- * when it could not be told for sure, with the boxes as older runs measured them.
70
- */
71
- visual: Schema.optionalKey(VisualViewport),
72
- });
73
- /**
74
- * What a step did to the page, by its action: `click` (and an `upload` through a file chooser)
75
- * moved the mouse and pressed it; `hover` moved the mouse over an element without pressing it;
76
- * `fill` typed into a field; `press` pressed a key; `scroll`, `goto` and `reload` moved or loaded
77
- * the page.
78
- */
79
- export const ActionKind = Schema.Literals([
80
- 'click',
81
- 'hover',
82
- 'fill',
83
- 'upload',
84
- 'press',
85
- 'scroll',
86
- 'goto',
87
- 'reload',
88
- ]);
89
- /** A point in the viewport, in CSS pixels. */
90
- export const Point = Schema.Struct({ x: Schema.Number, y: Schema.Number });
91
- /**
92
- * The action a step performed, as it happened, for drawing it over the video: when, and for one
93
- * that acted on an element, where. Never what was typed: the job's own step says that.
94
- */
95
- export const StepAction = Schema.Struct({
96
- kind: ActionKind,
97
- /**
98
- * When it happened, in ms from the start of the session's video (as `StepTiming`): for a click
99
- * or a key, when the browser dispatched its input event to the page (the mouse press, the key
100
- * going down), not when the page's handlers for it were done. Missing when that event was not
101
- * seen (see `point`), and always for a fill and for files set on a file input directly: a page
102
- * can make their edits itself, so an edit is no proof of when they acted. Always missing for a
103
- * hover too: when the page moves or scrolls under a pointer that stands still, the browser
104
- * itself sends trusted mouse events (`mouseover`, and in some versions `mousemove`), at a time
105
- * the page chooses, so none proves when or where a hover moved the mouse.
106
- */
107
- atMs: Schema.optionalKey(Schema.Number),
108
- /**
109
- * Where the mouse pressed, in the viewport as the video shows it (`viewport`, in its CSS pixels):
110
- * the point of the trusted mouse event the browser dispatched to the page's main frame for it,
111
- * where it was on the screen, so a page laid out wider than the viewport or zoomed in is
112
- * accounted for. Only for actions that pressed the mouse, and only when that event was seen
113
- * (not in a child frame, nor one stopped before it reached its element) and where it showed was
114
- * certain.
115
- */
116
- point: Schema.optionalKey(Point),
117
- /**
118
- * The element acted on, in the viewport in CSS pixels: for a scroll, measured after it. Older
119
- * runs may have one for a click, a fill or a key too.
120
- */
121
- target: Schema.optionalKey(Box),
122
- /**
123
- * The visual viewport's scale when `target` was measured, which it accounts for: it is where the
124
- * element showed in the viewport, not where it was in the page's layout. Missing in older runs,
125
- * whose `target` is in the layout (see `boxesDrawable`).
126
- */
127
- scale: Schema.optionalKey(Schema.Number),
128
- /** The viewport's size in CSS pixels then, which `point` and `target` are measured against. */
129
- viewport: Schema.optionalKey(Schema.Struct({ width: Schema.Number, height: Schema.Number })),
130
- });
131
- /** Why an element a step checked or acted on did not show to a person (see `OnScreen`). */
132
- export const OnScreenProblem = Schema.Literals(['clipped', 'covered', 'offscreen', 'transparent']);
133
- /**
134
- * How the element a step checked or acted on showed on the screen, measured by code as the step
135
- * ran: for a check (waitFor visible, expectText, expectLink) once it held, for a click before it
136
- * and for a fill or a hover after it. A measurement only, for whoever writes the case up: it never changes
137
- * a status.
138
- */
139
- export const OnScreen = Schema.Struct({
140
- /** How much of the element's box was on the screen, after clipping, from 0 to 1. */
141
- shown: Schema.Number,
142
- /**
143
- * Why it did not show, when it did not: `clipped` by an element around it, `covered` by one
144
- * painted over it, `offscreen` (outside the viewport where scrolling the page does not bring it,
145
- * or outside its frame) or `transparent` (opacity below 0.1 with what holds it).
146
- */
147
- problem: Schema.optionalKey(OnScreenProblem),
148
- /** The element that clips, covers or fades it, in a few words, such as `div[role="menu"]`. */
149
- by: Schema.optionalKey(Schema.String),
150
- /** For `clipped`: the element that clips it scrolls there, so scrolling it would show it. */
151
- scrolls: Schema.optionalKey(Schema.Boolean),
152
- });
153
- /** When one step ran, in ms from the start of the session's video. Numbered as `CaseEntry.step`. */
154
- export const StepTiming = Schema.Struct({
155
- index: Schema.Int,
156
- startMs: Schema.Number,
157
- endMs: Schema.Number,
158
- /** For an upload step: the files it sent, by name and size in bytes (never their contents). */
159
- files: Schema.optionalKey(Schema.Array(Schema.Struct({ name: Schema.String, size: Schema.Number }))),
160
- /** What it did to the page, when it acted. Missing in older ledgers and for checks. */
161
- action: Schema.optionalKey(StepAction),
162
- /** How its element showed on the screen, when it was measured (see `OnScreen`). */
163
- onScreen: Schema.optionalKey(OnScreen),
164
- });
165
- /**
166
- * An image visible in a page when the case ended: its alternative text (the `alt` of an `<img>`,
167
- * or the ARIA label of an element with role img, such as an `<svg>` logo), where it comes from
168
- * (`data:` URLs shortened) and its size on the page in CSS pixels.
169
- */
170
- export const ImageFact = Schema.Struct({
171
- alt: Schema.optionalKey(Schema.String),
172
- src: Schema.optionalKey(Schema.String),
173
- width: Schema.Number,
174
- height: Schema.Number,
175
- });
176
- /** A link visible in a page when the case ended: its text and its absolute address. */
177
- export const LinkFact = Schema.Struct({
178
- text: Schema.optionalKey(Schema.String),
179
- href: Schema.String,
180
- });
181
- /** A response with an HTTP error status that the case's pages got, documents or not. */
182
- export const HttpErrorFact = Schema.Struct({ url: Schema.String, status: Schema.Int });
183
- /**
184
- * A few short facts about the page when the case ended, for an agent writing it up. One line
185
- * each and capped; never DOM or logs. Nothing is recorded from a page that went off the web.
186
- */
187
- export const PageFacts = Schema.Struct({
188
- url: Schema.String,
189
- title: Schema.optionalKey(Schema.String),
190
- /**
191
- * Visible text near the element of the step that decided the case, or the start of the page's
192
- * visible text when it had none or it was not found. At most `FACT_TEXT_MAX` characters.
193
- */
194
- text: Schema.optionalKey(Schema.String),
195
- /** At most `HTTP_ERRORS_MAX`, in the order they came. */
196
- httpErrors: Schema.Array(HttpErrorFact),
197
- /** Images visible in the page, at most `FACT_IMAGES_MAX`, in page order. */
198
- images: Schema.optionalKey(Schema.Array(ImageFact)),
199
- /** Links visible in the page, at most `FACT_LINKS_MAX`, in page order. */
200
- links: Schema.optionalKey(Schema.Array(LinkFact)),
201
- /**
202
- * The start of the visible text of each frame visible in the page (an `<iframe>` preview), at
203
- * most `FACT_FRAMES_MAX`, in page order, each cut to `FACT_TEXT_MAX` characters; with its
204
- * images and links, as for the page.
205
- */
206
- frames: Schema.optionalKey(Schema.Array(Schema.Struct({
207
- url: Schema.String,
208
- text: Schema.optionalKey(Schema.String),
209
- images: Schema.optionalKey(Schema.Array(ImageFact)),
210
- links: Schema.optionalKey(Schema.Array(LinkFact)),
211
- }))),
212
- });
213
- export const FACT_TEXT_MAX = 200;
214
- export const HTTP_ERRORS_MAX = 5;
215
- export const FACT_FRAMES_MAX = 3;
216
- export const FACT_IMAGES_MAX = 12;
217
- export const FACT_LINKS_MAX = 12;
218
- /** Image sources and link addresses are cut to this many characters. */
219
- export const URL_MAX = 300;
220
- /** A stretch of a session's video, in ms on its clock. */
221
- export const StillStretch = Schema.Struct({ fromMs: Schema.Number, toMs: Schema.Number });
222
- /**
223
- * One test user in one browser, start to end, recorded as one continuous video. A run without a
224
- * login is one session; jobs have at most one account today, so a run has one session.
225
- */
226
- export const Session = Schema.Struct({
227
- /** 1-based. */
228
- number: Schema.Int,
229
- /** The account it logged in with, when it did. */
230
- account: Schema.optionalKey(Schema.String),
231
- startedAt: Schema.String,
232
- endedAt: Schema.optionalKey(Schema.String),
233
- /** How long the session ran, from the start of its video to its end, in ms. */
234
- durationMs: Schema.optionalKey(Schema.Number),
235
- /** Relative to the run folder, such as `video/session-1.webm`, once it was saved. */
236
- video: Schema.optionalKey(Schema.String),
237
- /** The length the video file itself gives, in ms. */
238
- videoDurationMs: Schema.optionalKey(Schema.Number),
239
- /** Why the video is missing or incomplete, in plain language. Never changes a status. */
240
- videoProblem: Schema.optionalKey(Schema.String),
241
- /**
242
- * The stretches of the video in which its picture did not change, in ms on its clock, measured
243
- * from the saved video once the session ended. Missing when that could not be measured (older
244
- * runs, no video); empty when nothing stood still.
245
- */
246
- still: Schema.optionalKey(Schema.Array(StillStretch)),
247
- });
248
- /**
249
- * Attributes of an element that a CSS selector may name, such as `data-test`, `title`, `href` or
250
- * `aria-label`, as they are in the page: at most `ATTRS_MAX`, values cut to `ATTR_VALUE_MAX`
251
- * characters. Never `id`, `class` or `data-testid` (saved as such), `style`, event handlers or
252
- * `value`, which may hold what was typed.
253
- */
254
- export const Attributes = Schema.Record(Schema.String, Schema.String);
255
- export const ATTRS_MAX = 12;
256
- export const ATTR_VALUE_MAX = 120;
257
- /** What a selector may name about an element besides the element it is in. */
258
- const nodeFields = {
259
- tag: Schema.String,
260
- id: Schema.optionalKey(Schema.String),
261
- classes: Schema.optionalKey(Schema.Array(Schema.String)),
262
- testId: Schema.optionalKey(Schema.String),
263
- attrs: Schema.optionalKey(Attributes),
264
- /** Attributes in `attrs` whose values were cut to `ATTR_VALUE_MAX` characters. */
265
- cutAttrs: Schema.optionalKey(Schema.Array(Schema.String)),
266
- /**
267
- * Attributes it has whose values are not saved (such as `style` or `value`), at most
268
- * `ATTRS_MAX` names; a selector that names one cannot be checked.
269
- */
270
- omittedAttrs: Schema.optionalKey(Schema.Array(Schema.String)),
271
- /** It had more attributes than `attrs` and `omittedAttrs` name. */
272
- moreAttrs: Schema.optionalKey(Schema.Boolean),
273
- /** It had more classes than `classes` holds. */
274
- moreClasses: Schema.optionalKey(Schema.Boolean),
275
- /** Not an HTML element, such as an `<svg>`: HTML never folds the case of its attributes. */
276
- foreign: Schema.optionalKey(Schema.Boolean),
277
- };
278
- /** An element around an `<iframe>`, as `ShotFrame.ancestors` lists them. */
279
- export const AncestorNode = Schema.Struct(nodeFields);
280
- /**
281
- * An element that holds a saved one, for selectors that name what an element is in, such as
282
- * `.clients img`: its tag, ID, classes, test ID and attributes, and the element it is in.
283
- */
284
- export const PageNode = Schema.Struct({
285
- ...nodeFields,
286
- /** The element it is in, as an index into `ShotPage.nodes`; missing at the top of its document. */
287
- parent: Schema.optionalKey(Schema.Int),
288
- });
289
- /** At most this many elements that hold saved ones are saved per document. */
290
- export const NODES_MAX = 800;
291
- /** An element on the page when a screenshot was taken, as a highlight can name it. */
292
- export const Candidate = Schema.Struct({
293
- tag: Schema.String,
294
- role: Schema.optionalKey(Schema.String),
295
- /** Accessible name, as far as the page gives one. */
296
- name: Schema.optionalKey(Schema.String),
297
- /** Visible text, cut short. */
298
- text: Schema.optionalKey(Schema.String),
299
- /** For form fields: the text of their label. */
300
- label: Schema.optionalKey(Schema.String),
301
- /**
302
- * For images: their alternative text, the `alt` of an `<img>` or the ARIA label of an element
303
- * with role img, such as an `<svg>` logo. Missing in older sidecars, as are `src` and `href`.
304
- */
305
- alt: Schema.optionalKey(Schema.String),
306
- /** For images: where they come from, cut to `URL_MAX` characters; `data:` URLs shortened. */
307
- src: Schema.optionalKey(Schema.String),
308
- /** For links: their absolute address, cut to `URL_MAX` characters. */
309
- href: Schema.optionalKey(Schema.String),
310
- id: Schema.optionalKey(Schema.String),
311
- classes: Schema.optionalKey(Schema.Array(Schema.String)),
312
- testId: Schema.optionalKey(Schema.String),
313
- /** Its other attributes a CSS selector may name (see `Attributes`); missing in older sidecars. */
314
- attrs: Schema.optionalKey(Attributes),
315
- /** Attributes in `attrs` whose values were cut to `ATTR_VALUE_MAX` characters. */
316
- cutAttrs: Schema.optionalKey(Schema.Array(Schema.String)),
317
- /**
318
- * Attributes it has whose values are not saved (such as `style` or `value`), at most
319
- * `ATTRS_MAX` names; a selector that names one cannot be checked.
320
- */
321
- omittedAttrs: Schema.optionalKey(Schema.Array(Schema.String)),
322
- /** It had more attributes than `attrs` and `omittedAttrs` name. */
323
- moreAttrs: Schema.optionalKey(Schema.Boolean),
324
- /** It had more classes than `classes` holds. */
325
- moreClasses: Schema.optionalKey(Schema.Boolean),
326
- /** Not an HTML element, such as an `<svg>`: HTML never folds the case of its attributes. */
327
- foreign: Schema.optionalKey(Schema.Boolean),
328
- /**
329
- * The element it is in, as an index into `ShotPage.nodes`, for selectors that name it. Missing
330
- * at the top of its document, when there was no room to save it, and in older sidecars.
331
- */
332
- up: Schema.optionalKey(Schema.Int),
333
- /** It is in an element that was not saved, as there was no room (see `NODES_MAX`). */
334
- upCut: Schema.optionalKey(Schema.Boolean),
335
- /** On the screenshot, in image pixels. */
336
- box: Box,
337
- /**
338
- * The part of `box` its visible text and images take up, in image pixels: a wide element's text
339
- * may be centred, right-aligned or right-to-left. Missing when it has none, and in older sidecars.
340
- */
341
- content: Schema.optionalKey(Box),
342
- /** Index of the nearest candidate that contains this one in the page. */
343
- parent: Schema.optionalKey(Schema.Int),
344
- /**
345
- * False when the element was in the page but not visible when the screenshot was taken: almost
346
- * transparent (such as a section that fades in on scroll), or cut away by an ancestor's
347
- * overflow. Missing when it was visible, and in older sidecars.
348
- */
349
- visible: Schema.optionalKey(Schema.Boolean),
350
- /**
351
- * The frame it is in, as an index into `ShotPage.frames`; missing for the page itself. Its box
352
- * is on the image like any other, and may reach past the part of the frame that shows.
353
- */
354
- frame: Schema.optionalKey(Schema.Int),
355
- });
356
- /**
357
- * What a page held beyond the candidates saved with its screenshot, when it held more than
358
- * `CANDIDATES_MAX`: enough to tell whether a highlight that matches one saved element could match
359
- * one that was not saved too. Keys are made by `candidateKeys`.
360
- */
361
- export const Truncated = Schema.Struct({
362
- /** Elements a highlight could name that were found, saved or not. */
363
- found: Schema.Int,
364
- /** False when the page was too big to look at whole, so no match can be called unique. */
365
- complete: Schema.Boolean,
366
- /**
367
- * For each key a saved candidate has, how many elements that were not saved have it too. Keys
368
- * no unsaved element has are left out.
369
- */
370
- unsaved: Schema.Record(Schema.String, Schema.Int),
371
- /** Saved candidates with a role that hold an unsaved element of the same role. */
372
- nested: Schema.Array(Schema.Int),
373
- });
374
- /**
375
- * A frame visible on a screenshot (an `<iframe>` showing a preview): its `<iframe>` element, as a
376
- * highlight's `frame` names it, and where its document shows on the image. Elements inside it
377
- * are candidates with this frame's index.
378
- */
379
- export const ShotFrame = Schema.Struct({
380
- /** The `<iframe>` element, matched like a candidate. */
381
- tag: Schema.String,
382
- role: Schema.optionalKey(Schema.String),
383
- /** Its `title` or ARIA label. */
384
- name: Schema.optionalKey(Schema.String),
385
- id: Schema.optionalKey(Schema.String),
386
- classes: Schema.optionalKey(Schema.Array(Schema.String)),
387
- testId: Schema.optionalKey(Schema.String),
388
- /** Its other attributes, as a candidate's (see `Attributes`); missing in older sidecars. */
389
- attrs: Schema.optionalKey(Attributes),
390
- /** Attributes in `attrs` whose values were cut to `ATTR_VALUE_MAX` characters. */
391
- cutAttrs: Schema.optionalKey(Schema.Array(Schema.String)),
392
- /**
393
- * Attributes it has whose values are not saved (such as `style` or `value`), at most
394
- * `ATTRS_MAX` names; a selector that names one cannot be checked.
395
- */
396
- omittedAttrs: Schema.optionalKey(Schema.Array(Schema.String)),
397
- /** It had more attributes than `attrs` and `omittedAttrs` name. */
398
- moreAttrs: Schema.optionalKey(Schema.Boolean),
399
- /** It had more classes than `classes` holds. */
400
- moreClasses: Schema.optionalKey(Schema.Boolean),
401
- /** Not an HTML element, such as an `<svg>`: HTML never folds the case of its attributes. */
402
- foreign: Schema.optionalKey(Schema.Boolean),
403
- /**
404
- * The elements it is in, in the document it is in, innermost first (at most `FRAME_ANCESTORS_MAX`),
405
- * for selectors such as `.preview-pane iframe`. Missing in older sidecars.
406
- */
407
- ancestors: Schema.optionalKey(Schema.Array(AncestorNode)),
408
- /** It is in more elements than `ancestors` holds. */
409
- moreAncestors: Schema.optionalKey(Schema.Boolean),
410
- /** The frame it is in, as an index into `ShotPage.frames`; missing for the page itself. */
411
- parent: Schema.optionalKey(Schema.Int),
412
- /**
413
- * The part of its document that shows on the image, in image pixels: inside the `<iframe>`'s
414
- * border and padding, and inside the frame it is in and the image.
415
- */
416
- box: Box,
417
- url: Schema.String,
418
- /**
419
- * Set when not every element of its document was saved (see `Truncated`); `nested` counts
420
- * among this frame's own candidates, in the order they are saved.
421
- */
422
- truncated: Schema.optionalKey(Truncated),
423
- /** Why none of its elements were saved, such as a frame that did not answer in time. */
424
- unread: Schema.optionalKey(Schema.String),
425
- /**
426
- * How many frames in its document could not be described (see `ShotPage.framesUnread`).
427
- * Missing when none, and in older sidecars.
428
- */
429
- framesUnread: Schema.optionalKey(Schema.Int),
430
- });
431
- /** At most this many frames are saved per screenshot, and this many elements of each one. */
432
- export const FRAMES_MAX = 8;
433
- export const FRAME_CANDIDATES_MAX = 150;
434
- /** At most this many elements of all frames together, on top of the page's own. */
435
- export const FRAME_CANDIDATES_TOTAL = 400;
436
- /** At most this many elements around an `<iframe>` are saved with it. */
437
- export const FRAME_ANCESTORS_MAX = 12;
438
- /**
439
- * The page state saved next to a screenshot (`<shot>.json`): the elements a highlight may name,
440
- * so it can be placed after the browser is gone.
441
- */
442
- export const ShotPage = Schema.Struct({
443
- version: Schema.Literal(1),
444
- url: Schema.String,
445
- /** Image size in pixels, and image pixels per CSS pixel. */
446
- width: Schema.Int,
447
- height: Schema.Int,
448
- scale: Schema.Number,
449
- /** The page's own elements first, then those of each frame. */
450
- candidates: Schema.Array(Candidate),
451
- /** Set when not every element was saved; sidecars from before it was recorded lack it. */
452
- truncated: Schema.optionalKey(Truncated),
453
- /** Frames visible on the image, at most `FRAMES_MAX`, outer ones before those inside them. */
454
- frames: Schema.optionalKey(Schema.Array(ShotFrame)),
455
- /** How many frames were visible, when more than `frames` holds. */
456
- framesFound: Schema.optionalKey(Schema.Int),
457
- /**
458
- * How many frames in the page itself could not be described, so whether they showed or what
459
- * they are is unknown: a frame a highlight names cannot be told apart from them. Frames inside
460
- * a frame are counted in that frame's `framesUnread`. Missing when none, and in older sidecars.
461
- */
462
- framesUnread: Schema.optionalKey(Schema.Int),
463
- /**
464
- * The elements that hold candidates, of the page and then of each frame, which candidates'
465
- * `up` point into. Missing in older sidecars.
466
- */
467
- nodes: Schema.optionalKey(Schema.Array(PageNode)),
468
- /**
469
- * The visual viewport the boxes were measured in, which they account for (see `Shot.visual`).
470
- * Missing in older sidecars, and when it could not be told for sure.
471
- */
472
- visual: Schema.optionalKey(VisualViewport),
473
- });
474
- /**
475
- * The exact-match keys of a candidate, as `Truncated.unsaved` counts them: its role, its role
476
- * with its name, its text, its label, its alt text (each whitespace-collapsed and lower case, as highlights
477
- * match them), its ID and its test ID. `captureState` makes the same keys inside the page.
478
- */
479
- export const candidateKey = {
480
- role: (role) => JSON.stringify(['role', matchText(role)]),
481
- roleName: (role, name) => JSON.stringify(['role', matchText(role), matchText(name)]),
482
- text: (text) => JSON.stringify(['text', matchText(text)]),
483
- label: (label) => JSON.stringify(['label', matchText(label)]),
484
- alt: (alt) => JSON.stringify(['alt', matchText(alt)]),
485
- id: (id) => JSON.stringify(['id', id]),
486
- testId: (testId) => JSON.stringify(['testId', testId]),
487
- };
488
- /** Text the way highlights compare it: whitespace collapsed, trimmed, lower case. */
489
- export const matchText = (text) => (text ?? '').replace(/\s+/g, ' ').trim().toLowerCase();
490
- /** Every key of `candidateKey` that `c` has. */
491
- export const candidateKeys = (c) => [
492
- ...(c.role !== undefined ? [candidateKey.role(c.role)] : []),
493
- ...(c.role !== undefined && c.name !== undefined ? [candidateKey.roleName(c.role, c.name)] : []),
494
- ...(c.text !== undefined ? [candidateKey.text(c.text)] : []),
495
- ...(c.label !== undefined ? [candidateKey.label(c.label)] : []),
496
- ...(c.alt !== undefined ? [candidateKey.alt(c.alt)] : []),
497
- ...(c.id !== undefined ? [candidateKey.id(c.id)] : []),
498
- ...(c.testId !== undefined ? [candidateKey.testId(c.testId)] : []),
499
- ];
500
- /** At most this many candidates are saved per screenshot. */
501
- export const CANDIDATES_MAX = 400;
502
- /** A step of a case as the evidence pack gives it. */
503
- export const EvidenceStep = Schema.Struct({
504
- index: Schema.Int,
505
- /** Such as `click button "Sign in"`. */
506
- text: Schema.String,
507
- state: Schema.Literals(['ran', 'decided', 'not-run']),
508
- startMs: Schema.optionalKey(Schema.Number),
509
- endMs: Schema.optionalKey(Schema.Number),
510
- /** For an upload step: the names of the files it sends. */
511
- files: Schema.optionalKey(Schema.Array(Schema.String)),
512
- /**
513
- * How its element showed on the screen, measured as it ran (see `OnScreen`); every check of
514
- * an element or text that held has one, so each can be compared with its screenshot.
515
- */
516
- onScreen: Schema.optionalKey(OnScreen),
517
- /** The ID of the screenshot taken for this step, when there is one (see `EvidenceCase.shots`). */
518
- shot: Schema.optionalKey(Schema.String),
519
- });
520
- /** What an agent needs to write up one case, and the IDs its findings may refer to. */
521
- export const EvidenceCase = Schema.Struct({
522
- id: Schema.String,
523
- title: Schema.String,
524
- status: CaseStatus,
525
- step: Schema.optionalKey(Schema.Int),
526
- reason: Schema.optionalKey(Schema.String),
527
- /** What the job said success looks like. */
528
- success: Schema.optionalKey(Schema.String),
529
- /** The case before it, on whose page it started (`CaseSpec.continue`). */
530
- continuedFrom: Schema.optionalKey(Schema.String),
531
- session: Schema.optionalKey(Schema.Int),
532
- startMs: Schema.optionalKey(Schema.Number),
533
- endMs: Schema.optionalKey(Schema.Number),
534
- steps: Schema.Array(EvidenceStep),
535
- /** The only timecodes key moments may use for this case, in ms, ascending. */
536
- timecodes: Schema.Array(Schema.Number),
537
- shots: Schema.Array(Schema.Struct({
538
- id: Schema.String,
539
- name: Schema.String,
540
- kind: ShotKind,
541
- step: Schema.Int,
542
- path: Schema.String,
543
- /**
544
- * The page state saved with it (a `ShotPage`): every element a highlight may name, with
545
- * images' alt text and source and links' addresses.
546
- */
547
- page: Schema.optionalKey(Schema.String),
548
- })),
549
- facts: Schema.optionalKey(PageFacts),
550
- });
551
- /** `evidence.json`: the full evidence pack of an ended run. `run_status` replies with a digest. */
552
- export const EvidencePack = Schema.Struct({
553
- version: Schema.Literal(1),
554
- jobId: Schema.String,
555
- state: Schema.String,
556
- /** The note every report carries: cases ran in order, in one browser session. */
557
- sessionNote: Schema.String,
558
- videos: Schema.Array(Schema.Struct({
559
- session: Schema.Int,
560
- path: Schema.optionalKey(Schema.String),
561
- durationMs: Schema.optionalKey(Schema.Number),
562
- problem: Schema.optionalKey(Schema.String),
563
- })),
564
- cases: Schema.Array(EvidenceCase),
565
- });