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