screw-bugs 0.1.9 → 0.1.11

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 (102) hide show
  1. package/README.md +100 -54
  2. package/dist/browser-playwright/capture.js +1 -1
  3. package/dist/build-info.json +3 -3
  4. package/dist/cli/app.js +6 -2
  5. package/dist/cli/commands.js +4 -3
  6. package/dist/cli/doctor.d.ts +17 -2
  7. package/dist/cli/doctor.js +62 -4
  8. package/dist/cli/mcp.js +7 -4
  9. package/dist/cli/report-server.d.ts +19 -10
  10. package/dist/cli/report-server.js +43 -18
  11. package/dist/cli/share.js +2 -2
  12. package/dist/cli/sign-in.d.ts +9 -3
  13. package/dist/cli/sign-in.js +12 -9
  14. package/dist/cli/tailnet.d.ts +57 -0
  15. package/dist/cli/tailnet.js +82 -0
  16. package/dist/core/index.d.ts +1 -14
  17. package/dist/core/index.js +3 -14
  18. package/dist/report/index.d.ts +1 -10
  19. package/dist/report/index.js +3 -10
  20. package/dist/schema/index.d.ts +1 -9
  21. package/dist/schema/index.js +3 -9
  22. package/package.json +14 -14
  23. package/dist/core/accounts.d.ts +0 -40
  24. package/dist/core/accounts.js +0 -95
  25. package/dist/core/css.d.ts +0 -95
  26. package/dist/core/css.js +0 -436
  27. package/dist/core/engine.d.ts +0 -75
  28. package/dist/core/engine.js +0 -560
  29. package/dist/core/errors.d.ts +0 -85
  30. package/dist/core/errors.js +0 -36
  31. package/dist/core/evidence.d.ts +0 -14
  32. package/dist/core/evidence.js +0 -131
  33. package/dist/core/labels.d.ts +0 -47
  34. package/dist/core/labels.js +0 -199
  35. package/dist/core/liveness.d.ts +0 -45
  36. package/dist/core/liveness.js +0 -66
  37. package/dist/core/marks.d.ts +0 -63
  38. package/dist/core/marks.js +0 -410
  39. package/dist/core/services.d.ts +0 -579
  40. package/dist/core/services.js +0 -25
  41. package/dist/core/share.d.ts +0 -68
  42. package/dist/core/share.js +0 -318
  43. package/dist/core/steps.d.ts +0 -106
  44. package/dist/core/steps.js +0 -722
  45. package/dist/core/uploads.d.ts +0 -49
  46. package/dist/core/uploads.js +0 -133
  47. package/dist/core/video.d.ts +0 -53
  48. package/dist/core/video.js +0 -241
  49. package/dist/core/viewport.d.ts +0 -28
  50. package/dist/core/viewport.js +0 -50
  51. package/dist/report/assets.d.ts +0 -34
  52. package/dist/report/assets.js +0 -105
  53. package/dist/report/bug.d.ts +0 -11
  54. package/dist/report/bug.js +0 -20
  55. package/dist/report/html.d.ts +0 -47
  56. package/dist/report/html.js +0 -923
  57. package/dist/report/icons.d.ts +0 -51
  58. package/dist/report/icons.js +0 -93
  59. package/dist/report/live.d.ts +0 -7
  60. package/dist/report/live.js +0 -135
  61. package/dist/report/logos.d.ts +0 -4
  62. package/dist/report/logos.js +0 -19
  63. package/dist/report/markup.d.ts +0 -50
  64. package/dist/report/markup.js +0 -156
  65. package/dist/report/menu-bar.d.ts +0 -60
  66. package/dist/report/menu-bar.js +0 -157
  67. package/dist/report/player.d.ts +0 -102
  68. package/dist/report/player.js +0 -315
  69. package/dist/report/pr-summary.d.ts +0 -11
  70. package/dist/report/pr-summary.js +0 -119
  71. package/dist/report/sha256.d.ts +0 -9
  72. package/dist/report/sha256.js +0 -97
  73. package/dist/report/share-page.d.ts +0 -48
  74. package/dist/report/share-page.js +0 -291
  75. package/dist/report/shots.d.ts +0 -59
  76. package/dist/report/shots.js +0 -280
  77. package/dist/report/sign-in.d.ts +0 -41
  78. package/dist/report/sign-in.js +0 -568
  79. package/dist/report/styles.d.ts +0 -3
  80. package/dist/report/styles.js +0 -274
  81. package/dist/report/view.d.ts +0 -296
  82. package/dist/report/view.js +0 -702
  83. package/dist/report/walkthrough.d.ts +0 -93
  84. package/dist/report/walkthrough.js +0 -716
  85. package/dist/schema/accounts.d.ts +0 -137
  86. package/dist/schema/accounts.js +0 -121
  87. package/dist/schema/config.d.ts +0 -7
  88. package/dist/schema/config.js +0 -6
  89. package/dist/schema/doctor.d.ts +0 -46
  90. package/dist/schema/doctor.js +0 -30
  91. package/dist/schema/evidence.d.ts +0 -1115
  92. package/dist/schema/evidence.js +0 -565
  93. package/dist/schema/findings.d.ts +0 -161
  94. package/dist/schema/findings.js +0 -82
  95. package/dist/schema/job.d.ts +0 -1905
  96. package/dist/schema/job.js +0 -577
  97. package/dist/schema/ledger.d.ts +0 -1124
  98. package/dist/schema/ledger.js +0 -285
  99. package/dist/schema/share.d.ts +0 -55
  100. package/dist/schema/share.js +0 -64
  101. package/dist/schema/status.d.ts +0 -7
  102. package/dist/schema/status.js +0 -11
@@ -1,95 +0,0 @@
1
- /** An attribute selector, such as `[data-test="preview"]` or `[href*=linkedin i]`. */
2
- export interface AttributeTest {
3
- readonly name: string;
4
- /** Undefined for `[name]`: the attribute is there, whatever its value. */
5
- readonly op?: '=' | '~=' | '|=' | '^=' | '$=' | '*=';
6
- readonly value?: string;
7
- /** `i` compares ignoring ASCII case, `s` with it; without one, as HTML says for the attribute. */
8
- readonly flag?: 'i' | 's';
9
- }
10
- /** One compound selector: everything about one element, such as `iframe.preview[title=Hi]`. */
11
- export interface Compound {
12
- /** Lower case; undefined for `*` or none. */
13
- readonly tag?: string;
14
- readonly ids: ReadonlyArray<string>;
15
- readonly classes: ReadonlyArray<string>;
16
- readonly attributes: ReadonlyArray<AttributeTest>;
17
- readonly not: ReadonlyArray<Compound>;
18
- }
19
- /** A compound and how it relates to the one before it: inside it anywhere, or right inside it. */
20
- export interface Part {
21
- readonly compound: Compound;
22
- /** How this part relates to the one before it; undefined for the first. */
23
- readonly combinator?: 'descendant' | 'child';
24
- }
25
- /** A selector list: an element matches when it matches any of them, judged by its last part. */
26
- export type Selector = ReadonlyArray<ReadonlyArray<Part>>;
27
- /** A selector, or why it cannot be matched against saved page state, in words. */
28
- export type Parsed = {
29
- readonly _tag: 'selector';
30
- readonly selector: Selector;
31
- } | {
32
- readonly _tag: 'unsupported';
33
- readonly reason: string;
34
- };
35
- /** What a highlight's CSS can check, besides the element itself and the frame it is in. */
36
- export declare const SUPPORTED_CSS: string;
37
- /**
38
- * Parses `css` into the selectors `matches` takes, or says in words what of it cannot be matched
39
- * against saved page state (see `SUPPORTED_CSS`).
40
- */
41
- export declare const parseSelector: (css: string) => Parsed;
42
- /**
43
- * An attribute's value as saved: `cut` when only its start was kept, so it is longer than `value`.
44
- */
45
- export interface AttributeValue {
46
- readonly value: string;
47
- readonly cut?: boolean | undefined;
48
- }
49
- /**
50
- * An element as a selector sees it: its own attributes, and the element it is in. What was not
51
- * saved whole is said, so a selector that depends on it is not taken as matching or not.
52
- */
53
- export interface CssElement {
54
- readonly tag: string;
55
- readonly id?: string | undefined;
56
- readonly classes?: ReadonlyArray<string> | undefined;
57
- /** More classes than `classes` holds. */
58
- readonly classesCut?: boolean | undefined;
59
- /**
60
- * An attribute's value, undefined when it does not have it (as far as was saved), or `unsaved`
61
- * when it has it but its value was not saved.
62
- */
63
- readonly attribute: (name: string) => AttributeValue | 'unsaved' | undefined;
64
- /** More attributes than were saved, so one `attribute` does not give may still be there. */
65
- readonly attributesCut?: boolean | undefined;
66
- /** Not an HTML element (such as an `<svg>`), whose attribute values HTML never folds. */
67
- readonly foreign?: boolean | undefined;
68
- /** The element it is in; undefined at the top of its document, or when that was not saved. */
69
- readonly parent: () => CssElement | undefined;
70
- /** It is in an element that was not saved, so `parent` stops short of the top. */
71
- readonly parentCut?: boolean | undefined;
72
- }
73
- /**
74
- * Whether something holds: true, false, or undefined when it depends on what was not saved (an
75
- * attribute value cut short, attributes, classes or ancestors left out).
76
- */
77
- export type Maybe = boolean | undefined;
78
- /**
79
- * Attributes whose values HTML compares ignoring ASCII case in selectors, on HTML elements, unless
80
- * the selector says `s` (HTML's list of case-insensitive attribute values).
81
- */
82
- export declare const CASE_INSENSITIVE_ATTRIBUTES: ReadonlySet<string>;
83
- /** Whether `el` matches any selector of the list; undefined when that depends on what was not saved. */
84
- export declare const selectorMatches: (selector: Selector, el: CssElement) => Maybe;
85
- /** Whether the selector looks at an element's ancestors at all. */
86
- export declare const usesAncestors: (selector: Selector) => boolean;
87
- /**
88
- * The ID or test ID that every element matching `selector` exactly has, when it is one compound
89
- * with one: what `Truncated.unsaved` can count.
90
- */
91
- export declare const selectorKey: (selector: Selector) => {
92
- readonly id: string;
93
- } | {
94
- readonly testId: string;
95
- } | undefined;
package/dist/core/css.js DELETED
@@ -1,436 +0,0 @@
1
- /*
2
- * CSS selectors, matched in pure code against the elements saved with a screenshot rather than a
3
- * live page, so that a highlight can name an element with the selector a step used. What can be
4
- * told from what is saved is supported: tags, `*`, `#id`, `.class`, attribute selectors with every
5
- * operator and the `i` and `s` flags, `:not()` of those, selector lists, and the descendant and
6
- * child combinators over the element's saved ancestors. Pseudo-classes that need what is not
7
- * saved, such as `:nth-child()` or `:hover`, are refused in words, never guessed.
8
- */
9
- /** What a highlight's CSS can check, besides the element itself and the frame it is in. */
10
- export const SUPPORTED_CSS = 'tags, #id, .class and [attribute] selectors (=, ~=, |=, ^=, $=, *=, with i), :not(), lists ' +
11
- 'and the descendant and child combinators';
12
- const isSpace = (ch) => ch !== undefined && /\s/.test(ch);
13
- const isNameChar = (ch) => ch !== undefined && (/[\w-]/.test(ch) || ch.charCodeAt(0) >= 0x80);
14
- /** Reads selectors from left to right; every method returns undefined on what it does not take. */
15
- class Reader {
16
- text;
17
- at = 0;
18
- constructor(text) {
19
- this.text = text;
20
- }
21
- get done() {
22
- return this.at >= this.text.length;
23
- }
24
- peek(offset = 0) {
25
- return this.text[this.at + offset];
26
- }
27
- skipSpace() {
28
- const from = this.at;
29
- while (isSpace(this.peek()))
30
- this.at++;
31
- return this.at > from;
32
- }
33
- /** A CSS escape after its backslash: up to 6 hex digits and one space, or any one character. */
34
- escape() {
35
- const hex = /^[0-9a-fA-F]{1,6}/.exec(this.text.slice(this.at))?.[0];
36
- if (hex !== undefined) {
37
- this.at += hex.length;
38
- if (isSpace(this.peek()))
39
- this.at++;
40
- const code = Number.parseInt(hex, 16);
41
- return code === 0 || code > 0x10ffff ? '�' : String.fromCodePoint(code);
42
- }
43
- const ch = this.peek();
44
- if (ch === undefined)
45
- return undefined;
46
- this.at++;
47
- return ch;
48
- }
49
- ident() {
50
- let out = '';
51
- for (;;) {
52
- const ch = this.peek();
53
- if (ch === '\\') {
54
- this.at++;
55
- const escaped = this.escape();
56
- if (escaped === undefined)
57
- return undefined;
58
- out += escaped;
59
- }
60
- else if (isNameChar(ch)) {
61
- out += ch;
62
- this.at++;
63
- }
64
- else
65
- break;
66
- }
67
- return out === '' || /^-?\d/.test(out) ? undefined : out;
68
- }
69
- quoted() {
70
- const quote = this.peek();
71
- if (quote !== '"' && quote !== "'")
72
- return undefined;
73
- this.at++;
74
- let out = '';
75
- for (;;) {
76
- const ch = this.peek();
77
- if (ch === undefined)
78
- return undefined;
79
- this.at++;
80
- if (ch === quote)
81
- return out;
82
- if (ch === '\\') {
83
- const escaped = this.escape();
84
- if (escaped === undefined)
85
- return undefined;
86
- out += escaped;
87
- }
88
- else
89
- out += ch;
90
- }
91
- }
92
- }
93
- const unsupported = (reason) => ({ _tag: 'unsupported', reason });
94
- /** The pseudo-class or other text at `reader`, for saying what is not supported. */
95
- const pseudoAt = (reader) => {
96
- const rest = reader.text.slice(reader.at);
97
- return /^::?[\w-]+(\([^)]*\))?/.exec(rest)?.[0] ?? rest.slice(0, 20);
98
- };
99
- const attributeOf = (reader) => {
100
- reader.skipSpace();
101
- const name = reader.ident();
102
- if (name === undefined)
103
- return 'an attribute selector without a name';
104
- reader.skipSpace();
105
- if (reader.peek() === ']') {
106
- reader.at++;
107
- return { name: name.toLowerCase() };
108
- }
109
- const two = `${reader.peek() ?? ''}${reader.peek(1) ?? ''}`;
110
- if (reader.done)
111
- return 'an attribute selector that does not end with ]';
112
- const op = ['~=', '|=', '^=', '$=', '*='].find((o) => o === two) ??
113
- (reader.peek() === '=' ? '=' : undefined);
114
- if (op === undefined)
115
- return `an attribute selector it cannot read, at "${reader.text.slice(reader.at, reader.at + 20)}"`;
116
- reader.at += op.length;
117
- reader.skipSpace();
118
- const value = reader.peek() === '"' || reader.peek() === "'" ? reader.quoted() : reader.ident();
119
- if (value === undefined)
120
- return 'an attribute selector without a value it can read';
121
- reader.skipSpace();
122
- const flag = reader.peek()?.toLowerCase();
123
- if (flag === 'i' || flag === 's') {
124
- reader.at++;
125
- reader.skipSpace();
126
- }
127
- if (reader.peek() !== ']')
128
- return 'an attribute selector that does not end with ]';
129
- reader.at++;
130
- return {
131
- name: name.toLowerCase(),
132
- op,
133
- value,
134
- ...(flag === 'i' || flag === 's' ? { flag } : {}),
135
- };
136
- };
137
- /** One compound selector; inside `:not()`, `inNot` stops it at `)`. */
138
- const compoundOf = (reader, inNot = false) => {
139
- let tag;
140
- const ids = [];
141
- const classes = [];
142
- const attributes = [];
143
- const not = [];
144
- let any = false;
145
- if (reader.peek() === '*') {
146
- reader.at++;
147
- any = true;
148
- }
149
- else if (isNameChar(reader.peek()) || reader.peek() === '\\') {
150
- const name = reader.ident();
151
- if (name === undefined)
152
- return 'a tag name it cannot read';
153
- tag = name.toLowerCase();
154
- any = true;
155
- }
156
- for (;;) {
157
- const ch = reader.peek();
158
- if (ch === '#' || ch === '.') {
159
- reader.at++;
160
- const name = reader.ident();
161
- if (name === undefined)
162
- return ch === '#' ? 'an #id without a name' : 'a .class without a name';
163
- (ch === '#' ? ids : classes).push(name);
164
- }
165
- else if (ch === '[') {
166
- reader.at++;
167
- const test = attributeOf(reader);
168
- if (typeof test === 'string')
169
- return test;
170
- attributes.push(test);
171
- }
172
- else if (ch === ':') {
173
- if (inNot || !reader.text.startsWith(':not(', reader.at))
174
- return `"${pseudoAt(reader)}"`;
175
- reader.at += ':not('.length;
176
- for (;;) {
177
- reader.skipSpace();
178
- const inner = compoundOf(reader, true);
179
- if (typeof inner === 'string')
180
- return inner;
181
- not.push(inner);
182
- reader.skipSpace();
183
- if (reader.peek() === ',') {
184
- reader.at++;
185
- continue;
186
- }
187
- if (reader.peek() !== ')')
188
- return 'a :not() that does not end with )';
189
- reader.at++;
190
- break;
191
- }
192
- }
193
- else
194
- break;
195
- any = true;
196
- }
197
- if (!any)
198
- return 'nothing it can read';
199
- return { ...(tag !== undefined ? { tag } : {}), ids, classes, attributes, not };
200
- };
201
- /**
202
- * Parses `css` into the selectors `matches` takes, or says in words what of it cannot be matched
203
- * against saved page state (see `SUPPORTED_CSS`).
204
- */
205
- export const parseSelector = (css) => {
206
- const reader = new Reader(css.trim());
207
- if (reader.done)
208
- return unsupported('the CSS selector is empty');
209
- const list = [];
210
- let parts = [];
211
- let combinator;
212
- for (;;) {
213
- const compound = compoundOf(reader);
214
- if (typeof compound === 'string')
215
- return unsupported(compound.startsWith('"')
216
- ? `the CSS selector uses ${compound}, which cannot be checked against the page state saved with the screenshot`
217
- : `the CSS selector has ${compound}`);
218
- parts.push({ compound, ...(combinator !== undefined ? { combinator } : {}) });
219
- const spaced = reader.skipSpace();
220
- const ch = reader.peek();
221
- if (ch === undefined)
222
- break;
223
- if (ch === ',') {
224
- reader.at++;
225
- reader.skipSpace();
226
- list.push(parts);
227
- parts = [];
228
- combinator = undefined;
229
- continue;
230
- }
231
- if (ch === '>' && reader.peek(1) === '>')
232
- return unsupported('the CSS selector uses ">>", which chains Playwright selectors and cannot be checked against the page state saved with the screenshot');
233
- if (ch === '>') {
234
- reader.at++;
235
- reader.skipSpace();
236
- combinator = 'child';
237
- continue;
238
- }
239
- if (ch === '+' || ch === '~')
240
- return unsupported(`the CSS selector uses the "${ch}" combinator, which needs the element's siblings, and those are not saved with the screenshot`);
241
- if (!spaced)
242
- return unsupported(`the CSS selector uses "${pseudoAt(reader)}", which it cannot read`);
243
- combinator = 'descendant';
244
- }
245
- list.push(parts);
246
- return { _tag: 'selector', selector: list };
247
- };
248
- const and = (values) => {
249
- let sure = true;
250
- for (const value of values) {
251
- const v = value();
252
- if (v === false)
253
- return false;
254
- if (v === undefined)
255
- sure = false;
256
- }
257
- return sure ? true : undefined;
258
- };
259
- const not = (value) => (value === undefined ? undefined : !value);
260
- /**
261
- * Attributes whose values HTML compares ignoring ASCII case in selectors, on HTML elements, unless
262
- * the selector says `s` (HTML's list of case-insensitive attribute values).
263
- */
264
- export const CASE_INSENSITIVE_ATTRIBUTES = new Set([
265
- 'accept',
266
- 'accept-charset',
267
- 'align',
268
- 'alink',
269
- 'axis',
270
- 'bgcolor',
271
- 'charset',
272
- 'checked',
273
- 'clear',
274
- 'codetype',
275
- 'color',
276
- 'compact',
277
- 'declare',
278
- 'defer',
279
- 'dir',
280
- 'direction',
281
- 'disabled',
282
- 'enctype',
283
- 'face',
284
- 'frame',
285
- 'hreflang',
286
- 'http-equiv',
287
- 'lang',
288
- 'language',
289
- 'link',
290
- 'media',
291
- 'method',
292
- 'multiple',
293
- 'nohref',
294
- 'noresize',
295
- 'noshade',
296
- 'nowrap',
297
- 'readonly',
298
- 'rel',
299
- 'rev',
300
- 'rules',
301
- 'scope',
302
- 'scrolling',
303
- 'selected',
304
- 'shape',
305
- 'target',
306
- 'text',
307
- 'type',
308
- 'valign',
309
- 'valuetype',
310
- 'vlink',
311
- ]);
312
- /** ASCII letters in lower case, and nothing else changed, as CSS folds case. */
313
- const asciiLower = (text) => text.replace(/[A-Z]/g, (ch) => ch.toLowerCase());
314
- /**
315
- * Whether an attribute value of which only `have` is known (all of it, or with `cut` its start)
316
- * stands in relation `op` to `want`.
317
- */
318
- const compare = (op, have, want, cut) => {
319
- // What is known of a value cut short: its start, and that more follows.
320
- const starts = (prefix) => have.length >= prefix.length
321
- ? have.startsWith(prefix)
322
- : prefix.startsWith(have)
323
- ? cut
324
- ? undefined
325
- : false
326
- : false;
327
- switch (op) {
328
- case '=':
329
- if (!cut)
330
- return have === want;
331
- return want.length <= have.length ? false : want.startsWith(have) ? undefined : false;
332
- case '^=':
333
- return want !== '' && (cut ? starts(want) : have.startsWith(want));
334
- case '$=':
335
- return want === '' ? false : cut ? undefined : have.endsWith(want);
336
- case '*=':
337
- return want === '' ? false : have.includes(want) ? true : cut ? undefined : false;
338
- case '~=': {
339
- if (want === '' || /\s/.test(want))
340
- return false;
341
- const words = have.split(/\s+/);
342
- // The last word of a value cut short may go on.
343
- const whole = cut ? words.slice(0, -1) : words;
344
- return whole.includes(want) ? true : cut ? undefined : false;
345
- }
346
- case '|=': {
347
- if (!cut)
348
- return have === want || have.startsWith(`${want}-`);
349
- // Longer than `want` and starting with it: only `want-…` can match.
350
- return want.length < have.length ? have.startsWith(`${want}-`) : starts(`${want}-`);
351
- }
352
- }
353
- };
354
- const attributeMatches = (el, test) => {
355
- const have = el.attribute(test.name);
356
- if (have === 'unsaved')
357
- return undefined;
358
- if (have === undefined)
359
- return el.attributesCut === true ? undefined : false;
360
- if (test.op === undefined || test.value === undefined)
361
- return true;
362
- const fold = test.flag === 'i' ||
363
- (test.flag === undefined && el.foreign !== true && CASE_INSENSITIVE_ATTRIBUTES.has(test.name));
364
- const [h, w] = fold ? [asciiLower(have.value), asciiLower(test.value)] : [have.value, test.value];
365
- return compare(test.op, h, w, have.cut === true);
366
- };
367
- const compoundMatches = (el, compound) => and([
368
- () => compound.tag === undefined || el.tag.toLowerCase() === compound.tag,
369
- ...compound.ids.map((id) => () => el.id === id),
370
- ...compound.classes.map((name) => () => (el.classes?.includes(name) ?? false) ? true : el.classesCut === true ? undefined : false),
371
- ...compound.attributes.map((test) => () => attributeMatches(el, test)),
372
- ...compound.not.map((inner) => () => not(compoundMatches(el, inner))),
373
- ]);
374
- /** Whether `el` matches `parts[0..last]`, with `parts[last]` on `el` itself. */
375
- const partsMatch = (el, parts, last) => {
376
- const part = parts[last];
377
- if (part === undefined)
378
- return true;
379
- const own = compoundMatches(el, part.compound);
380
- if (own === false || last === 0)
381
- return own;
382
- let rest = false;
383
- if (part.combinator === 'child') {
384
- const up = el.parent();
385
- rest =
386
- up !== undefined
387
- ? partsMatch(up, parts, last - 1)
388
- : el.parentCut === true
389
- ? undefined
390
- : false;
391
- }
392
- else {
393
- let at = el;
394
- for (let up = el.parent(); up !== undefined; at = up, up = up.parent()) {
395
- const there = partsMatch(up, parts, last - 1);
396
- if (there === true) {
397
- rest = true;
398
- break;
399
- }
400
- if (there === undefined)
401
- rest = undefined;
402
- }
403
- if (rest === false && at.parentCut === true)
404
- rest = undefined;
405
- }
406
- return rest === false ? false : own === true && rest === true ? true : undefined;
407
- };
408
- /** Whether `el` matches any selector of the list; undefined when that depends on what was not saved. */
409
- export const selectorMatches = (selector, el) => {
410
- let sure = true;
411
- for (const parts of selector) {
412
- const v = partsMatch(el, parts, parts.length - 1);
413
- if (v === true)
414
- return true;
415
- if (v === undefined)
416
- sure = false;
417
- }
418
- return sure ? false : undefined;
419
- };
420
- /** Whether the selector looks at an element's ancestors at all. */
421
- export const usesAncestors = (selector) => selector.some((parts) => parts.length > 1);
422
- /**
423
- * The ID or test ID that every element matching `selector` exactly has, when it is one compound
424
- * with one: what `Truncated.unsaved` can count.
425
- */
426
- export const selectorKey = (selector) => {
427
- const [parts] = selector;
428
- if (selector.length !== 1 || parts?.length !== 1)
429
- return undefined;
430
- const { compound } = parts[0];
431
- const [id] = compound.ids;
432
- if (id !== undefined)
433
- return { id };
434
- const test = compound.attributes.find((a) => a.name === 'data-testid' && a.op === '=' && a.flag !== 'i' && a.value !== '');
435
- return test?.value !== undefined ? { testId: test.value } : undefined;
436
- };
@@ -1,75 +0,0 @@
1
- import { Context, Effect, Layer } from 'effect';
2
- import { type Answer, type CaseLedger, Findings, type JobId, type JobSpec, type PlacedMark, type ReportBundle } from '../schema/index.js';
3
- import { FindingsRejected, NotImplemented, RunNotEnded, type RunNotFound, SignInNeeded, StorageFailed } from './errors.js';
4
- import { AccountBook, Browser, Notifier, ReportRenderer, Storage, type UploadSource } from './services.js';
5
- /**
6
- * The longest one write of `report.html` or `ledger.json` may take. A run's
7
- * writes are uninterruptible, so its final state is never half recorded; this bound keeps a hung
8
- * disk from holding up the first Ctrl+C forever. A write that times out never leaves a half-written
9
- * file: storage writes a temporary file, then renames it.
10
- */
11
- export declare const WRITE_TIMEOUT_MS = 5000;
12
- /**
13
- * How many times a report is rendered at most when what it is made from keeps changing as it is
14
- * written (see `renderReport`).
15
- */
16
- export declare const REPORT_ATTEMPTS = 3;
17
- declare const Engine_base: Context.ServiceClass<Engine, "screw-bugs/Engine", {
18
- /**
19
- * Returns as soon as the job is recorded; the run continues in the background. `uploads` are
20
- * the files its upload steps send, checked by the caller beforehand; an upload step whose
21
- * file is not among them is blocked. A job with an account starts only from a session that
22
- * may still work (see `needsSignIn`); otherwise nothing is recorded or started.
23
- */
24
- readonly startRun: (spec: JobSpec, options?: {
25
- readonly uploads?: ReadonlyArray<UploadSource> | undefined;
26
- }) => Effect.Effect<JobId, SignInNeeded | StorageFailed>;
27
- /** Waits for a run this process started, then returns its final ledger. */
28
- readonly awaitRun: (jobId: JobId) => Effect.Effect<CaseLedger, RunNotFound | StorageFailed>;
29
- /**
30
- * Stops a run this process started, as Ctrl+C does, and waits until its final report and
31
- * ledger are written (or their writes time out). Does nothing for any other run.
32
- */
33
- readonly stopRun: (jobId: JobId) => Effect.Effect<void>;
34
- readonly status: (jobId: JobId) => Effect.Effect<CaseLedger, RunNotFound | StorageFailed>;
35
- readonly answer: (answer: Answer) => Effect.Effect<void, RunNotFound | NotImplemented>;
36
- /**
37
- * (Re)writes a run's report from its current ledger; returns its path and contents. Its own
38
- * `report.html`, or with `interrupted`, `report-interrupted.html` (see `Storage`). The caller
39
- * decides which one the run may get.
40
- */
41
- readonly writeReport: (jobId: JobId, options?: {
42
- readonly interrupted?: boolean;
43
- }) => Effect.Effect<{
44
- readonly path: string;
45
- readonly bundle: ReportBundle;
46
- }, RunNotFound | StorageFailed>;
47
- /**
48
- * (Re)writes only a run's `walkthrough.html` from its current ledger, as `writeReport` would
49
- * with its report, and returns its path; the report is left as it is. The caller decides
50
- * whether the run may get one (never an interrupted run).
51
- */
52
- readonly writeWalkthrough: (jobId: JobId) => Effect.Effect<string, RunNotFound | StorageFailed>;
53
- /**
54
- * The report bundle of a run as it is now, with the agent's write-up if it gave one, naming
55
- * its `walkthrough.html` when the run folder has one beside its own `report.html`.
56
- */
57
- readonly bundle: (jobId: JobId) => Effect.Effect<ReportBundle, RunNotFound | StorageFailed>;
58
- /**
59
- * Checks an agent's findings against an ended run (`checkFindings`), saves them as
60
- * `findings.json`, and draws their highlights onto copies of the screenshots. Writes no
61
- * report: whoever calls it decides which report the run may get.
62
- */
63
- readonly submitFindings: (jobId: JobId, findings: Findings) => Effect.Effect<{
64
- /** Absolute path of `findings.json`. */
65
- readonly path: string;
66
- readonly marks: Readonly<Record<string, ReadonlyArray<PlacedMark>>>;
67
- /** Absolute paths of the annotated copies written. */
68
- readonly annotated: ReadonlyArray<string>;
69
- }, RunNotFound | StorageFailed | RunNotEnded | FindingsRejected>;
70
- }>;
71
- /** Executes runs. The CLI and the MCP server are thin callers of this. */
72
- export declare class Engine extends Engine_base {
73
- static readonly layer: Layer.Layer<Engine, never, AccountBook | Browser | Notifier | ReportRenderer | Storage>;
74
- }
75
- export {};