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,579 +0,0 @@
1
- import { Context, type Effect, type Scope } from 'effect';
2
- import type { AccountEntry, Box, Candidate, CaseLedger, Device, ElementTarget, JobId, JobRecord, JobSpec, JobState, OnScreen, PageFacts, PageNode, Point, ReportBundle, SavedSession, ShotFrame, SignInInput, StillStretch, Target, Truncated, VisualViewport, WaitState } from '../schema/index.js';
3
- import type { BrowserNotFound, PageActionFailed, RunNotFound, StorageFailed } from './errors.js';
4
- export type BrowserKind = 'chrome' | 'msedge' | 'playwright-chromium';
5
- export interface BrowserInfo {
6
- readonly kind: BrowserKind;
7
- /** Playwright's browser type, such as `chromium`. */
8
- readonly type: string;
9
- /** The channel it was launched with, such as `chrome`; undefined for Playwright's own build. */
10
- readonly channel: string | undefined;
11
- readonly version: string;
12
- }
13
- /**
14
- * A main-frame document load, in the case's page or in a tab or window the case opened, that did
15
- * not work out. `step` is the index (as given to `BrowserPage.settle`) of the step during which it
16
- * started.
17
- */
18
- export type LoadProblem = {
19
- readonly step: number;
20
- readonly inNewTab: boolean;
21
- } & ({
22
- readonly _tag: 'HttpError';
23
- readonly status: number;
24
- } | {
25
- readonly _tag: 'LoadFailed';
26
- readonly error: string;
27
- } | {
28
- readonly _tag: 'Unfinished';
29
- readonly timeoutMs: number;
30
- });
31
- /** Where a case's browser went that screw-bugs must not capture, such as a `data:` frame. */
32
- export interface Refusal {
33
- /** Such as `data:`. */
34
- readonly scheme: string;
35
- /** The case's page, a frame inside a page, or a page the case opened in a new tab or window. */
36
- readonly where: 'page' | 'frame' | 'window';
37
- }
38
- /** What a screenshot captured besides the image: its size and the page state for highlights. */
39
- export interface ShotCapture {
40
- /** Image size in pixels, and image pixels per CSS pixel. */
41
- readonly width: number;
42
- readonly height: number;
43
- readonly scale: number;
44
- readonly url: string;
45
- /**
46
- * The box of the `target` asked for, when it could be measured and at least part of it is on the
47
- * image; never a guess.
48
- */
49
- readonly target: Box | undefined;
50
- /** Where the text and images of `target` are inside it (see `Candidate.content`), when measured. */
51
- readonly targetContent?: Box | undefined;
52
- /**
53
- * How long after the screenshot was asked for `target` was measured, in ms, when it has a box:
54
- * the moment the box is true of, which can be seconds before the image is taken.
55
- */
56
- readonly targetAfterMs?: number | undefined;
57
- /** Why `target` has no box although it was measured, such as it being off the image. */
58
- readonly targetProblem?: string | undefined;
59
- /**
60
- * The visual viewport `target` and the boxes below were measured in, which they account for (see
61
- * `Shot.visual`); undefined when that could not be told for sure, with boxes as older runs had.
62
- */
63
- readonly visual?: VisualViewport | undefined;
64
- /** Elements on the page a highlight may name (see `ShotPage`), at most `CANDIDATES_MAX`. */
65
- readonly candidates: ReadonlyArray<Candidate>;
66
- /** Set when the page held more elements than `candidates` (see `Truncated`). */
67
- readonly truncated?: Truncated | undefined;
68
- /** Frames visible on the image (see `ShotPage.frames`); their elements are in `candidates`. */
69
- readonly frames?: ReadonlyArray<ShotFrame> | undefined;
70
- /** How many frames were visible, when more than `frames` holds. */
71
- readonly framesFound?: number | undefined;
72
- /** How many frames in the page itself could not be described (see `ShotPage.framesUnread`). */
73
- readonly framesUnread?: number | undefined;
74
- /** The elements that hold candidates (see `ShotPage.nodes`). */
75
- readonly nodes?: ReadonlyArray<PageNode> | undefined;
76
- }
77
- /** The frames something is in, outermost first (see `framesOf`); empty for the page itself. */
78
- export type Frames = ReadonlyArray<ElementTarget>;
79
- /** What a scroll step scrolls: an element into view, or the page or a frame to an end or by pixels. */
80
- export type ScrollTo = {
81
- readonly _tag: 'target';
82
- readonly target: Target;
83
- } | {
84
- readonly _tag: 'end';
85
- readonly to: 'top' | 'bottom';
86
- readonly frames: Frames;
87
- } | {
88
- readonly _tag: 'by';
89
- readonly by: number;
90
- readonly frames: Frames;
91
- };
92
- /** What a step looked for and did not find: a text, or an element. */
93
- export type Sought = {
94
- readonly _tag: 'text';
95
- readonly text: string;
96
- } | {
97
- readonly _tag: 'element';
98
- readonly target: ElementTarget;
99
- };
100
- /**
101
- * Where something a step did not find is after all, outside where the step looked
102
- * (see `BrowserPage.findElsewhere`).
103
- */
104
- export interface Elsewhere {
105
- /** In the page itself, outside every frame. Only looked for when the step named a frame. */
106
- readonly inPage: boolean;
107
- /**
108
- * Up to 2 of the visible frames it is in, each as the frames that lead to it, outermost first,
109
- * found the way a person would name them (see `frameSelector`).
110
- */
111
- readonly frames: ReadonlyArray<Frames>;
112
- /** How many of the visible frames looked in hold it. */
113
- readonly count: number;
114
- }
115
- /** Where text that should not show did (see `BrowserPage.watchText`). */
116
- export interface TextSeen {
117
- /** How it showed: as visible text, as the alt text of an image, or as an ARIA label. */
118
- readonly as: 'text' | 'alt' | 'label';
119
- /** The text, alt text or label that holds it, around it and cut short. */
120
- readonly value: string;
121
- /** Where in its document, as a short selector such as `.clients`; undefined when nothing says. */
122
- readonly near?: string | undefined;
123
- /**
124
- * The frames it is in, outermost first, found the way a person would name them (see
125
- * `frameSelector`); empty for where the step looked itself.
126
- */
127
- readonly frames: Frames;
128
- }
129
- /** What `BrowserPage.watchText` saw. */
130
- export type TextWatch = {
131
- readonly _tag: 'absent';
132
- } | {
133
- readonly _tag: 'shown';
134
- readonly seen: TextSeen;
135
- }
136
- /** Nothing showed where it looked within the wait, so its absence would prove nothing. */
137
- | {
138
- readonly _tag: 'empty';
139
- }
140
- /** Not all of where it had to look could be read, such as a frame that did not answer. */
141
- | {
142
- readonly _tag: 'incomplete';
143
- readonly reason: string;
144
- };
145
- /**
146
- * Where `BrowserPage.watchText` looks: in `target`, or else the document `frames` lead to (the
147
- * page itself when empty); the frames visible inside it too.
148
- */
149
- export interface TextScope {
150
- readonly frames: Frames;
151
- readonly target?: Target | undefined;
152
- }
153
- /**
154
- * When and where an action of `BrowserPage` happened, for drawing it over the video
155
- * (`StepAction`). Times are relative, so the caller puts them on the video's clock.
156
- */
157
- export interface ActionTrace {
158
- /**
159
- * How long after the operation was called it acted, in ms: when the browser dispatched the
160
- * click or the key to the page, or the load started. Missing when that was not seen, for a
161
- * fill or files set on a file input directly (a page can make their edits itself), and for a
162
- * hover (see `StepAction.atMs`).
163
- */
164
- readonly afterMs?: number | undefined;
165
- /**
166
- * Where the mouse pressed, in the viewport in CSS pixels, as the video shows it (not in the
167
- * page's layout, which a phone may show scaled or zoomed), when it did and that is certain.
168
- */
169
- readonly point?: Point | undefined;
170
- /**
171
- * The element acted on, in the viewport in CSS pixels, where it showed (not in the page's layout,
172
- * which a phone may show scaled or zoomed), when it could be measured and that is certain.
173
- */
174
- readonly target?: Box | undefined;
175
- /** The visual viewport's scale `target` was measured at, which it accounts for. */
176
- readonly scale?: number | undefined;
177
- /** The viewport's size in CSS pixels, which `point` and `target` are measured against. */
178
- readonly viewport?: {
179
- readonly width: number;
180
- readonly height: number;
181
- } | undefined;
182
- }
183
- /** How long an operation may wait; without one, the adapter's default for it. */
184
- export interface Wait {
185
- readonly timeoutMs?: number | undefined;
186
- }
187
- /**
188
- * A file an upload step sends, as checked before the run started: `path` as the job gives it,
189
- * `absolute` where it really is (links resolved), and its size in bytes.
190
- */
191
- export interface UploadSource {
192
- readonly path: string;
193
- readonly absolute: string;
194
- readonly size: number;
195
- }
196
- /**
197
- * The tab a session's cases run in, one after another. The adapter owns the default timeouts
198
- * (`DEFAULT_WAIT_MS`, `DEFAULT_LOAD_MS`); a step's `timeoutMs` replaces them. Every operation gives
199
- * up rather than hanging.
200
- */
201
- export interface BrowserPage {
202
- /**
203
- * goto, reload, click, hover, fill, upload and press fail only when the action itself could not be
204
- * performed. What the documents they load come to is judged by `settle`. Each says when it
205
- * acted and, for an element, where (see `ActionTrace`).
206
- */
207
- readonly goto: (url: string, wait?: Wait) => Effect.Effect<ActionTrace, PageActionFailed>;
208
- readonly reload: (wait?: Wait) => Effect.Effect<ActionTrace, PageActionFailed>;
209
- readonly click: (target: Target, wait?: Wait) => Effect.Effect<ActionTrace, PageActionFailed>;
210
- /**
211
- * Moves the mouse over `target` (waiting for it like `click` does, and scrolling it into view),
212
- * so the page's own hover styles and handlers run; the mouse stays there until the next action
213
- * moves it. Records no time or point (see `StepAction.atMs`).
214
- */
215
- readonly hover: (target: Target, wait?: Wait) => Effect.Effect<ActionTrace, PageActionFailed>;
216
- readonly fill: (target: Target, value: string, wait?: Wait) => Effect.Effect<ActionTrace, PageActionFailed>;
217
- /**
218
- * Sets `files` (absolute paths) on the file input `target` matches, hidden or not, or else
219
- * clicks `target` and sets them on the file chooser that opens. Fails when there is neither,
220
- * or when a single-file input or chooser is given more than one file.
221
- */
222
- readonly upload: (target: Target, files: ReadonlyArray<string>, wait?: Wait) => Effect.Effect<ActionTrace, PageActionFailed>;
223
- readonly press: (key: string) => Effect.Effect<ActionTrace, PageActionFailed>;
224
- /**
225
- * The absolute URL the element links to, when it is (or is inside) a link with an `href`, so
226
- * a click can be refused before it goes anywhere. Waits for the element like `click` does.
227
- */
228
- readonly linkUrl: (target: Target, wait?: Wait) => Effect.Effect<string | undefined, PageActionFailed>;
229
- /** Waits for the text to be visible, in the page or in `frames`. False means it never was. */
230
- readonly hasText: (text: string, wait?: Wait, frames?: Frames) => Effect.Effect<boolean, PageActionFailed>;
231
- /**
232
- * Waits until where `scope` says shows anything at all (any visible text or image, waiting for
233
- * `target` or the frame like `click` does), and every frame inside it does too, then watches it
234
- * for `watchMs` for `text`, as visible text, image alt text or an ARIA label. `absent` only
235
- * when every look in that time read all of it; `incomplete` when, by the end of the wait, not
236
- * all of it could be read; `empty` when nothing showed within the wait.
237
- */
238
- readonly watchText: (text: string, scope: TextScope, watchMs: number, wait?: Wait) => Effect.Effect<TextWatch, PageActionFailed>;
239
- /**
240
- * Waits until `target` reaches `state` (see `WaitState`). False means it did not in time; a
241
- * failure means it could not be looked for.
242
- */
243
- readonly waitFor: (target: Target, state: WaitState, wait?: Wait) => Effect.Effect<boolean, PageActionFailed>;
244
- /**
245
- * How `target` shows on the screen now (see `OnScreen`), for the step's record; never changes
246
- * what the step decided. For a `check` (a step that held: waitFor visible, expectText,
247
- * expectLink), the best of its visible matches, scrolling the page to one that only the page's
248
- * scrolling keeps off the screen, as a person would. For an `act` (a click, hover or fill), the match
249
- * the action takes, as it is: the action scrolls to it, through anything that scrolls. While it
250
- * does not show, it is measured again for a few seconds (at most `wait`'s timeout, after one
251
- * whole look at the first match), for what is still moving into place. Undefined when nothing matches visibly or it could not be measured. Never fails.
252
- */
253
- readonly onScreen: (target: Target, use: 'check' | 'act', wait?: Wait) => Effect.Effect<OnScreen | undefined>;
254
- /**
255
- * Why the elements `target` matches are in the page but none is visible, such as `display:
256
- * none on div.menu`, for a step that did not see it; with how many are there. Undefined when
257
- * none is in the page or nothing says why. Never fails.
258
- */
259
- readonly hiddenWhy: (target: Target) => Effect.Effect<{
260
- readonly count: number;
261
- readonly why: string;
262
- } | undefined>;
263
- /**
264
- * Scrolls an element into view (waiting for it like `click`), or the page or a frame (waiting
265
- * for the frame) to its top or bottom or by some pixels down.
266
- */
267
- readonly scroll: (to: ScrollTo, wait?: Wait) => Effect.Effect<ActionTrace, PageActionFailed>;
268
- /** Waits for the URL to contain `includes`. */
269
- readonly urlIncludes: (includes: string, wait?: Wait) => Effect.Effect<boolean, PageActionFailed>;
270
- readonly url: Effect.Effect<string>;
271
- /**
272
- * Called before step `next` runs, and before the case is judged. Waits until no main-frame
273
- * document of any of the case's pages is loading (each for the time it was given from when it
274
- * started), then judges every one that started since the last call, and from now on counts
275
- * new ones as step `next`'s, giving each `loadTimeoutMs` (see `loadTimeoutOf`). Resolves with
276
- * the problem of the earliest step, if any.
277
- */
278
- readonly settle: (next: number, loadTimeoutMs: number) => Effect.Effect<LoadProblem | undefined>;
279
- /**
280
- * The first navigation of the case to a URL that is not http or https, in any frame of any of
281
- * its pages (popups included); undefined while there was none. From then on nothing of the
282
- * case's pages may be captured.
283
- */
284
- readonly refused: Effect.Effect<Refusal | undefined>;
285
- /**
286
- * Looks for `sought`, which a step did not find in `frames` (the page itself when empty), in the
287
- * page itself and in the visible frames, as they are now, without waiting. Bounded in time and in
288
- * how many frames it reads; undefined when it is nowhere else, or when that could not be told.
289
- * Never fails.
290
- */
291
- readonly findElsewhere: (sought: Sought, frames: Frames) => Effect.Effect<Elsewhere | undefined>;
292
- /**
293
- * Saves a PNG at `path`, an absolute file path: the whole page, or what is in the viewport. With
294
- * `target`, that element is scrolled into view first when it can be, and its box is measured,
295
- * without waiting for it.
296
- */
297
- readonly screenshot: (path: string, options: {
298
- readonly fullPage: boolean;
299
- readonly target?: Target | undefined;
300
- }) => Effect.Effect<ShotCapture, PageActionFailed>;
301
- /**
302
- * Short facts about the page now (see `PageFacts`); with `text`, the visible text near
303
- * `target`, or the start of the page's when there is none or it is not found. Never fails.
304
- */
305
- readonly facts: (options: {
306
- readonly target: Target | undefined;
307
- readonly text: boolean;
308
- }) => Effect.Effect<PageFacts>;
309
- }
310
- /**
311
- * One test user in one browser, start to end: one context and one tab, recorded as one
312
- * continuous video. Cases share its cookies and storage. Closed when its scope closes.
313
- */
314
- export interface BrowserSessionPage {
315
- readonly page: BrowserPage;
316
- /**
317
- * Called before each case: closes tabs and windows the last case opened and starts watching
318
- * page loads afresh, so nothing of the last case is judged against this one. With `continues`,
319
- * the case goes on from the page the last case left (`CaseSpec.continue`): a way off the web
320
- * that case took is not forgotten, since its page may still show it.
321
- */
322
- readonly beginCase: (options?: {
323
- readonly continues?: boolean;
324
- }) => Effect.Effect<void>;
325
- /** Why the browser stopped working (it crashed or closed), once it has. */
326
- readonly crashed: Effect.Effect<string | undefined>;
327
- /** When the video started, in epoch ms from `Clock`. */
328
- readonly videoStartedAt: number;
329
- /**
330
- * Closes the session and saves its video at the path it was opened with. Resolves with why
331
- * there is no video, when recording was not possible. Safe to call more than once.
332
- */
333
- readonly close: Effect.Effect<{
334
- readonly videoProblem: string | undefined;
335
- }>;
336
- }
337
- /** An open browser. Closed when its scope closes. */
338
- export interface BrowserSession {
339
- readonly info: BrowserInfo;
340
- /**
341
- * A session in a fresh context. With `video`, it is recorded: the recorder works in `dir` (an
342
- * absolute folder path), and the video is saved at `path` (an absolute file path inside it).
343
- */
344
- readonly newSession: (options: {
345
- readonly device: Device;
346
- readonly video: {
347
- readonly dir: string;
348
- readonly path: string;
349
- } | undefined;
350
- /** A saved session (an account's storage state, as JSON text) the context starts from. */
351
- readonly session?: string | undefined;
352
- }) => Effect.Effect<BrowserSessionPage, PageActionFailed, Scope.Scope>;
353
- }
354
- /** A screenshot to draw boxes on, for copies people can paste where no overlay is possible. */
355
- export interface AnnotateJob {
356
- /** Absolute paths of the screenshot and the copy to write. */
357
- readonly image: string;
358
- readonly out: string;
359
- /** Image size in pixels. */
360
- readonly width: number;
361
- readonly height: number;
362
- readonly marks: ReadonlyArray<{
363
- readonly box: Box;
364
- readonly color: 'red' | 'green';
365
- /** Short text drawn by the box, such as its number. */
366
- readonly label: string;
367
- }>;
368
- /** Boxes of the page's other elements, which labels keep off where they can. */
369
- readonly obstacles?: ReadonlyArray<Box>;
370
- }
371
- /**
372
- * Whether browser sessions can be recorded as video. Every run is recorded, so without it no run
373
- * starts: `problem` says what is missing and `command` gets it.
374
- */
375
- export type VideoSupport = {
376
- readonly ok: true;
377
- } | {
378
- readonly ok: false;
379
- readonly problem: string;
380
- readonly command: string;
381
- };
382
- declare const Browser_base: Context.ServiceClass<Browser, "screw-bugs/Browser", {
383
- readonly detect: Effect.Effect<BrowserInfo, BrowserNotFound>;
384
- /** Whether sessions can be recorded; looked up without downloading or launching anything. */
385
- readonly videoSupport: Effect.Effect<VideoSupport>;
386
- /**
387
- * Where the saved video at `file` (an absolute path) stands still (see `stillStretches`);
388
- * undefined when that could not be measured. Reads the video only.
389
- */
390
- readonly stillVideo: (file: string) => Effect.Effect<ReadonlyArray<StillStretch> | undefined>;
391
- readonly open: (options: {
392
- readonly headed: boolean;
393
- /**
394
- * The device its sessions are on (desktop when left out): the browser renders at its scale,
395
- * so their videos have its resolution.
396
- */
397
- readonly device?: Device | undefined;
398
- }) => Effect.Effect<BrowserSession, BrowserNotFound, Scope.Scope>;
399
- /** What `device` emulates, for people reading a run: "Desktop", "iPhone 17 (Chromium)". */
400
- readonly deviceLabel: (device: Device) => string;
401
- /**
402
- * Draws the boxes onto copies of screenshots, in a browser of its own that opens nothing but
403
- * them. Resolves with the copies it wrote; one that fails is left out.
404
- */
405
- readonly annotate: (jobs: ReadonlyArray<AnnotateJob>) => Effect.Effect<ReadonlyArray<string>, BrowserNotFound>;
406
- /**
407
- * A browser for a person to sign in with from the live view (see `SignInBrowser`), open at
408
- * `url` in a fresh context. Closed with the scope.
409
- */
410
- readonly signIn: (url: string) => Effect.Effect<SignInBrowser, BrowserNotFound | PageActionFailed, Scope.Scope>;
411
- }>;
412
- /** Finds and launches a browser. Headless unless `headed` is set (used for logins). */
413
- export declare class Browser extends Browser_base {
414
- }
415
- /** A frame of the live view: what the active tab shows, as a JPEG. */
416
- export interface SignInFrame {
417
- /** Counts up with every frame, so a viewer can ask for the next one. */
418
- readonly seq: number;
419
- /** The JPEG, base64-encoded, as the browser sent it. */
420
- readonly jpeg: string;
421
- /** The viewport the frame shows, in CSS pixels. */
422
- readonly width: number;
423
- readonly height: number;
424
- /** The address of the tab it shows. */
425
- readonly url: string;
426
- }
427
- /** How the app names itself where the sign-in opened, for the live view to show the person. */
428
- export interface SignInSite {
429
- /** Its page's title, on one line; undefined when it had none or the page was another site's. */
430
- readonly title: string | undefined;
431
- /** Addresses of its icons on the app's own origin, best first, for the live view to fetch. */
432
- readonly icons: ReadonlyArray<string>;
433
- }
434
- /**
435
- * A headless browser a person drives from a web page (the live view) to sign in to an account:
436
- * frames of the active tab out; their mouse, wheel, keys and text in. Popups are followed: the
437
- * newest open tab is the active one. Nothing typed is recorded or kept.
438
- */
439
- export interface SignInBrowser {
440
- /** The app's title and icon, read once when the first page loaded. */
441
- readonly site: SignInSite;
442
- /**
443
- * The newest frame if it is newer than `after`, else the next one, waiting up to `waitMs`;
444
- * undefined when none came (the page sends a frame only when something changed).
445
- */
446
- readonly frame: (after: number, waitMs: number) => Effect.Effect<SignInFrame | undefined>;
447
- /**
448
- * Plays one input into the active tab; false when it could not be played (Playwright failed or
449
- * it took too long), so the person is told before saving.
450
- */
451
- readonly input: (input: SignInInput) => Effect.Effect<boolean>;
452
- /**
453
- * The session as Playwright's storage state (JSON text), with only the cookies the browser sends
454
- * to `origin` (see `sentTo`) and that origin's storage, so another site's sign-in (such as
455
- * GitHub's) is not kept.
456
- */
457
- readonly save: (origin: string) => Effect.Effect<string, PageActionFailed>;
458
- }
459
- /** A run as listed by `screw-bugs runs`. */
460
- export interface RunSummary {
461
- readonly job: JobRecord;
462
- /** Undefined when the ledger is missing or unreadable. */
463
- readonly ledger: CaseLedger | undefined;
464
- }
465
- declare const Storage_base: Context.ServiceClass<Storage, "screw-bugs/Storage", {
466
- readonly createRun: (spec: JobSpec) => Effect.Effect<JobId, StorageFailed>;
467
- readonly readJob: (jobId: JobId) => Effect.Effect<JobRecord, RunNotFound | StorageFailed>;
468
- readonly readLedger: (jobId: JobId) => Effect.Effect<CaseLedger, RunNotFound | StorageFailed>;
469
- readonly writeLedger: (ledger: CaseLedger) => Effect.Effect<void, StorageFailed>;
470
- /** Most recent first. */
471
- readonly listRuns: (limit: number) => Effect.Effect<ReadonlyArray<RunSummary>, StorageFailed>;
472
- /**
473
- * Writes the run's own `report.html` and returns its path, then deletes a leftover
474
- * `report-interrupted.html`. Only the run itself, or `screw-bugs report` once the run has
475
- * ended, writes it.
476
- */
477
- readonly writeReport: (jobId: JobId, html: string) => Effect.Effect<string, StorageFailed>;
478
- /**
479
- * Writes `report-interrupted.html`, the report of a run whose process is gone, and returns
480
- * its path. It never touches `report.html`.
481
- */
482
- readonly writeInterruptedReport: (jobId: JobId, html: string) => Effect.Effect<string, StorageFailed>;
483
- /**
484
- * The run's report to show: `report.html` when it exists, otherwise
485
- * `report-interrupted.html` when that does, otherwise undefined.
486
- */
487
- readonly findReport: (jobId: JobId) => Effect.Effect<string | undefined>;
488
- readonly runDir: (jobId: JobId) => string;
489
- /**
490
- * Absolute path of an evidence file, such as `01/02-after-login.png`; the ledger records it as
491
- * `evidence/<fileName>`. Missing folders on the way are created by whoever writes the file.
492
- */
493
- readonly evidencePath: (jobId: JobId, fileName: string) => string;
494
- /** Absolute path of a file in the run folder, such as `video/session-1.webm`. */
495
- readonly filePath: (jobId: JobId, relative: string) => string;
496
- /**
497
- * Writes a text file in the run folder (`evidence.json`, `findings.json`, a screenshot's page
498
- * state), creating folders on the way; atomically, like the ledger.
499
- */
500
- readonly writeFile: (jobId: JobId, relative: string, text: string) => Effect.Effect<void, StorageFailed>;
501
- /** A text file in the run folder; undefined when it does not exist. */
502
- readonly readFile: (jobId: JobId, relative: string) => Effect.Effect<string | undefined, StorageFailed>;
503
- /** The size and first `headBytes` bytes of a file in the run folder, if it exists. */
504
- readonly probe: (jobId: JobId, relative: string, headBytes: number) => Effect.Effect<{
505
- readonly size: number;
506
- readonly head: Uint8Array;
507
- } | undefined>;
508
- }>;
509
- /**
510
- * Runs, ledgers and evidence. Paths it returns are absolute. Everything is read back from
511
- * storage, so a run started by one process can be checked from another.
512
- */
513
- export declare class Storage extends Storage_base {
514
- }
515
- /**
516
- * What `live.html` (`runFiles.live`) shows: the job and its ledger as just written. Once the run
517
- * has ended (the ledger says so), `report` and `walkthrough` name the pages written with its
518
- * report, relative to the run folder, when they were.
519
- */
520
- export interface LivePage {
521
- readonly spec: JobSpec;
522
- readonly ledger: CaseLedger;
523
- readonly report?: string | undefined;
524
- readonly walkthrough?: string | undefined;
525
- }
526
- declare const ReportRenderer_base: Context.ServiceClass<ReportRenderer, "screw-bugs/ReportRenderer", {
527
- readonly html: (bundle: ReportBundle) => string;
528
- /** The run's walkthrough (`runFiles.walkthrough`): its video and every step as a script. */
529
- readonly walkthrough: (bundle: ReportBundle) => string;
530
- /** The page a person watches the run on while it goes (`runFiles.live`). */
531
- readonly live: (page: LivePage) => string;
532
- }>;
533
- /**
534
- * Turns a run into its HTML report. Pure: the `report` module provides it, and the engine writes
535
- * what it returns through `Storage`.
536
- */
537
- export declare class ReportRenderer extends ReportRenderer_base {
538
- }
539
- /** A saved account and where its session is. */
540
- export interface SavedAccount {
541
- readonly entry: AccountEntry;
542
- /** Absolute path of its session (Playwright's storage state), which runs start from. */
543
- readonly sessionPath: string;
544
- /** What the session file says about itself; undefined when it is missing or unreadable. */
545
- readonly session: SavedSession | undefined;
546
- /**
547
- * The session file's whole text as it was read with `session`, which a run starts from: the
548
- * file itself may be replaced (another sign-in) or removed meanwhile.
549
- */
550
- readonly sessionText: string | undefined;
551
- }
552
- declare const AccountBook_base: Context.ServiceClass<AccountBook, "screw-bugs/AccountBook", {
553
- /** Absolute path of `accounts.json`, which agents read to pick an account. */
554
- readonly file: string;
555
- readonly list: Effect.Effect<ReadonlyArray<AccountEntry>, StorageFailed>;
556
- readonly find: (label: string) => Effect.Effect<SavedAccount | undefined, StorageFailed>;
557
- /** Saves a session (storage state as JSON text) for `entry`, replacing any for its label. */
558
- readonly save: (entry: AccountEntry, session: string) => Effect.Effect<void, StorageFailed>;
559
- /** Removes an account and its session; false when there was none. */
560
- readonly remove: (label: string) => Effect.Effect<boolean, StorageFailed>;
561
- }>;
562
- /**
563
- * The project's test accounts: `accounts.json` (labels, what each user is, where and when it was
564
- * signed in; never a secret) and one session file each, readable by the user alone.
565
- */
566
- export declare class AccountBook extends AccountBook_base {
567
- }
568
- export interface JobEvent {
569
- readonly jobId: JobId;
570
- readonly state: JobState;
571
- readonly message: string;
572
- }
573
- declare const Notifier_base: Context.ServiceClass<Notifier, "screw-bugs/Notifier", {
574
- readonly notify: (event: JobEvent) => Effect.Effect<void>;
575
- }>;
576
- /** Tells the outside world about job progress (terminal, MCP client, later screw-bugs Cloud). */
577
- export declare class Notifier extends Notifier_base {
578
- }
579
- export {};
@@ -1,25 +0,0 @@
1
- import { Context } from 'effect';
2
- /** Finds and launches a browser. Headless unless `headed` is set (used for logins). */
3
- export class Browser extends Context.Service()('screw-bugs/Browser') {
4
- }
5
- /**
6
- * Runs, ledgers and evidence. Paths it returns are absolute. Everything is read back from
7
- * storage, so a run started by one process can be checked from another.
8
- */
9
- export class Storage extends Context.Service()('screw-bugs/Storage') {
10
- }
11
- /**
12
- * Turns a run into its HTML report. Pure: the `report` module provides it, and the engine writes
13
- * what it returns through `Storage`.
14
- */
15
- export class ReportRenderer extends Context.Service()('screw-bugs/ReportRenderer') {
16
- }
17
- /**
18
- * The project's test accounts: `accounts.json` (labels, what each user is, where and when it was
19
- * signed in; never a secret) and one session file each, readable by the user alone.
20
- */
21
- export class AccountBook extends Context.Service()('screw-bugs/AccountBook') {
22
- }
23
- /** Tells the outside world about job progress (terminal, MCP client, later screw-bugs Cloud). */
24
- export class Notifier extends Context.Service()('screw-bugs/Notifier') {
25
- }
@@ -1,68 +0,0 @@
1
- import type { ReportBundle, Step } from '../schema/index.js';
2
- /** The folders of a run whose files a share may hold. */
3
- export declare const SHARE_DIRS: readonly ['evidence', 'annotated', 'video'];
4
- /** The file types a share may hold, by extension. */
5
- export declare const SHARE_EXTENSIONS: ReadonlySet<string>;
6
- /**
7
- * Whether Cloud takes a file at `path` (relative to the run folder): under one of `SHARE_DIRS`,
8
- * plain segments only (no `..`, hidden files or escapes), an image or video, at most 200
9
- * characters. The same rule as Cloud's own.
10
- */
11
- export declare const shareable: (path: string) => boolean;
12
- /**
13
- * The files of the run a share of `bundle` holds: every screenshot, annotated copy and session
14
- * video the bundle links to that Cloud takes (`shareable`), each once, in a stable order.
15
- */
16
- export declare const shareFiles: (bundle: ReportBundle) => ReadonlyArray<string>;
17
- /** What a secret is replaced with in a shared bundle. */
18
- export declare const HIDDEN = "hidden";
19
- /**
20
- * `url` without what may be a secret: a user name and password, and the values of query and
21
- * fragment parameters with secret-looking names (`?token=hidden`). Unchanged, byte for byte, when
22
- * it has none, or does not parse.
23
- */
24
- export declare const scrubUrl: (url: string) => string;
25
- /** `text` with every URL in it scrubbed (`scrubUrl`). */
26
- export declare const scrubText: (text: string) => string;
27
- /** Whether `step` types into a field that takes a secret (see `SECRET_FIELD`). */
28
- export declare const typesSecret: (step: Step) => boolean;
29
- /**
30
- * `bundle` as it may leave the machine: what was typed into a field that takes a secret (a
31
- * password, a code, a token, see `typesSecret`) is `hidden`, and so are the credentials and
32
- * secret-looking parameters of every URL in it (`scrubUrl`), wherever they appear (the target, its
33
- * steps, page addresses, reasons, the write-up). What it cannot know stays: a secret in a URL's
34
- * path or in free text, or typed into a field named like any other, and whatever the screenshots
35
- * and video show.
36
- */
37
- export declare const scrubBundle: (bundle: ReportBundle) => ReportBundle;
38
- /** The screenshots of `bundle` a share may hold as WebP instead: its PNGs, of `shareFiles`. */
39
- export declare const encodableFiles: (bundle: ReportBundle) => ReadonlySet<string>;
40
- /** Where the WebP of the screenshot at `path` goes: the same path, ending `.webp`. */
41
- export declare const webpPath: (path: string) => string;
42
- /**
43
- * `bundle` with its file paths changed as `renames` says (old path to new), wherever the bundle
44
- * names them: each case's evidence, their names and shots, and the annotated copies.
45
- */
46
- export declare const renameFiles: (bundle: ReportBundle, renames: ReadonlyMap<string, string>) => ReportBundle;
47
- /** An image's size in pixels. */
48
- export interface PixelSize {
49
- readonly width: number;
50
- readonly height: number;
51
- }
52
- /**
53
- * The most pixels a WebP image has on a side. A browser asked to encode a taller screenshot (a
54
- * long full-page one) gives a cut-down image, so such screenshots are never offered.
55
- */
56
- export declare const WEBP_MAX_SIDE = 16383;
57
- /** How many bytes of a PNG `pngSize` reads: the signature and the IHDR chunk's size fields. */
58
- export declare const PNG_HEADER_BYTES = 24;
59
- /** The size of the PNG whose first bytes are `bytes`, or undefined for anything else. */
60
- export declare const pngSize: (bytes: Uint8Array) => PixelSize | undefined;
61
- /**
62
- * The size of the WebP file `bytes`, or undefined unless it is one whole still image: a RIFF
63
- * `WEBP` container whose length is the file's, made of chunks that fill it exactly (each padded
64
- * to an even length), holding one lossy (`VP8 `) or lossless (`VP8L`) image with data in it,
65
- * first or after an extended header (`VP8X`, not animated) whose canvas is the image's size.
66
- * It does not decode the image, so a file can still be broken inside its image data.
67
- */
68
- export declare const webpSize: (bytes: Uint8Array) => PixelSize | undefined;