screw-bugs 0.1.7 → 0.1.9

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 (58) hide show
  1. package/README.md +83 -13
  2. package/dist/browser-playwright/launch.js +27 -10
  3. package/dist/browser-playwright/page.d.ts +50 -28
  4. package/dist/browser-playwright/page.js +101 -91
  5. package/dist/browser-playwright/recorder.d.ts +154 -0
  6. package/dist/browser-playwright/recorder.js +382 -0
  7. package/dist/build-info.json +3 -3
  8. package/dist/cli/commands.js +56 -11
  9. package/dist/cli/mcp.d.ts +11 -4
  10. package/dist/cli/mcp.js +86 -23
  11. package/dist/cli/operations.d.ts +30 -2
  12. package/dist/cli/operations.js +126 -20
  13. package/dist/cli/report-links.js +2 -2
  14. package/dist/cli/report-server.d.ts +41 -9
  15. package/dist/cli/report-server.js +139 -23
  16. package/dist/cli/share.d.ts +71 -4
  17. package/dist/cli/share.js +540 -109
  18. package/dist/cli/sign-in.d.ts +22 -10
  19. package/dist/cli/sign-in.js +23 -23
  20. package/dist/core/engine.js +54 -13
  21. package/dist/core/liveness.js +3 -1
  22. package/dist/core/services.d.ts +29 -4
  23. package/dist/core/share.d.ts +31 -0
  24. package/dist/core/share.js +139 -0
  25. package/dist/core/steps.d.ts +5 -0
  26. package/dist/core/steps.js +15 -1
  27. package/dist/core/video.d.ts +6 -0
  28. package/dist/core/video.js +8 -0
  29. package/dist/report/html.d.ts +4 -2
  30. package/dist/report/html.js +36 -13
  31. package/dist/report/icons.d.ts +3 -0
  32. package/dist/report/icons.js +5 -1
  33. package/dist/report/index.d.ts +3 -1
  34. package/dist/report/index.js +3 -1
  35. package/dist/report/live.d.ts +7 -0
  36. package/dist/report/live.js +135 -0
  37. package/dist/report/menu-bar.d.ts +3 -3
  38. package/dist/report/menu-bar.js +3 -3
  39. package/dist/report/player.d.ts +3 -3
  40. package/dist/report/player.js +3 -3
  41. package/dist/report/share-page.d.ts +48 -0
  42. package/dist/report/share-page.js +291 -0
  43. package/dist/report/styles.d.ts +2 -0
  44. package/dist/report/styles.js +2 -2
  45. package/dist/report/view.js +2 -0
  46. package/dist/report/walkthrough.d.ts +5 -2
  47. package/dist/report/walkthrough.js +17 -5
  48. package/dist/schema/accounts.js +10 -1
  49. package/dist/schema/evidence.d.ts +15 -8
  50. package/dist/schema/evidence.js +9 -4
  51. package/dist/schema/findings.js +1 -1
  52. package/dist/schema/job.d.ts +205 -65
  53. package/dist/schema/job.js +63 -11
  54. package/dist/schema/ledger.d.ts +80 -16
  55. package/dist/schema/ledger.js +36 -0
  56. package/dist/schema/share.d.ts +17 -0
  57. package/dist/schema/share.js +22 -0
  58. package/package.json +1 -1
@@ -5,7 +5,9 @@ export const JobId = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-
5
5
  message: 'A job ID has only letters, digits and dashes',
6
6
  })).pipe(Schema.brand('JobId'));
7
7
  /** One short line of plain text: not blank, at most `max` characters. */
8
- export const ShortLine = (max, description) => Schema.String.check(Schema.makeFilter((text) => (text.trim() ? undefined : 'Must not be blank')), Schema.isMaxLength(max, { message: `Use at most ${max} characters` })).annotate({
8
+ export const ShortLine = (max, description) => Schema.String.check(Schema.makeFilter((text) => (text.trim() ? undefined : 'Must not be blank'), {
9
+ toJsonSchema: () => ({ pattern: '\\S' }),
10
+ }), Schema.isMaxLength(max, { message: `Use at most ${max} characters` })).annotate({
9
11
  description: `${description ? `${description} ` : ''}One line, at most ${max} characters.`,
10
12
  });
11
13
  /**
@@ -25,6 +27,8 @@ export const Device = Schema.Literals(['desktop', 'mobile']);
25
27
  */
26
28
  const Slug = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/, {
27
29
  message: 'Use 1-64 letters, digits, dots, dashes or underscores, starting with a letter or digit',
30
+ // Effect leaves isPattern out of JSON Schema; this puts it in.
31
+ toJsonSchema: () => ({ pattern: '^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$' }),
28
32
  }));
29
33
  const targetKeys = ['role', 'text', 'label', 'alt', 'css'];
30
34
  /** Ways of finding an element, shared by a step's target and the frames it is in. */
@@ -43,6 +47,11 @@ const targetFields = {
43
47
  })),
44
48
  css: Schema.optionalKey(Schema.NonEmptyString.annotate({ description: 'A CSS selector.' })),
45
49
  };
50
+ /** {@link oneWay} in JSON Schema: exactly one way of finding the element, and name only with role. */
51
+ const oneWayJson = {
52
+ oneOf: targetKeys.map((key) => ({ required: [key] })),
53
+ dependentRequired: { name: ['role'] },
54
+ };
46
55
  const oneWay = (target) => {
47
56
  const set = targetKeys.filter((key) => target[key] !== undefined);
48
57
  if (set.length !== 1)
@@ -65,7 +74,7 @@ export const FrameTarget = Schema.Struct({
65
74
  })
66
75
  .check(Schema.makeFilter((target) => target.frame !== undefined
67
76
  ? 'A frame cannot have its own frame; give frames inside frames as a list, outermost first'
68
- : oneWay(target)))
77
+ : oneWay(target), { toJsonSchema: () => ({ ...oneWayJson, not: { required: ['frame'] } }) }))
69
78
  .annotate({
70
79
  description: 'The <iframe> element: exactly one of role (optionally with name), text, label, alt or css, such as {"css":"iframe.preview"}.',
71
80
  });
@@ -74,7 +83,7 @@ export const FramePath = Schema.Union([
74
83
  FrameTarget,
75
84
  Schema.Array(FrameTarget).check(Schema.makeFilter((frames) => frames.length >= 1 && frames.length <= FRAME_DEPTH_MAX
76
85
  ? undefined
77
- : `Give 1-${FRAME_DEPTH_MAX} frames, outermost first`)),
86
+ : `Give 1-${FRAME_DEPTH_MAX} frames, outermost first`, { toJsonSchema: () => ({ minItems: 1, maxItems: FRAME_DEPTH_MAX }) })),
78
87
  ]).annotate({
79
88
  description: 'Optional: the <iframe> it is in, found like a target, such as {"css":"iframe.preview"}; for ' +
80
89
  'frames inside frames, a list, outermost first. Same- and cross-origin frames both work.',
@@ -84,7 +93,7 @@ export const FramePath = Schema.Union([
84
93
  * first visible one in page order is used. With `frame`, it is looked for inside that `<iframe>`.
85
94
  */
86
95
  export const Target = Schema.Struct({ ...targetFields, frame: Schema.optionalKey(FramePath) })
87
- .check(Schema.makeFilter(oneWay))
96
+ .check(Schema.makeFilter(oneWay, { toJsonSchema: () => oneWayJson }))
88
97
  .annotate({
89
98
  description: 'Exactly one of role (optionally with name), text, label, alt or css. The first visible match ' +
90
99
  'is used. Add frame to look inside an <iframe>: {"frame":{"css":"iframe.preview"},"text":"Hi"}.',
@@ -105,9 +114,17 @@ export const TIMEOUT_MIN_MS = 100;
105
114
  export const TIMEOUT_MAX_MS = 180_000;
106
115
  const timeoutMs = (what) => Schema.optionalKey(
107
116
  // A plain number checked here, so a fraction gets the same plain error as one out of range.
108
- Schema.Number.check(Schema.makeFilter((ms) => Number.isInteger(ms) && ms >= TIMEOUT_MIN_MS && ms <= TIMEOUT_MAX_MS
117
+ // Finite, not Number: JSON has no NaN or Infinity, and Number's JSON Schema allows them as
118
+ // strings.
119
+ Schema.Finite.check(Schema.makeFilter((ms) => Number.isInteger(ms) && ms >= TIMEOUT_MIN_MS && ms <= TIMEOUT_MAX_MS
109
120
  ? undefined
110
- : `timeoutMs must be a whole number of milliseconds from ${TIMEOUT_MIN_MS} to ${TIMEOUT_MAX_MS} (180 s)`)).annotate({
121
+ : `timeoutMs must be a whole number of milliseconds from ${TIMEOUT_MIN_MS} to ${TIMEOUT_MAX_MS} (180 s)`, {
122
+ toJsonSchema: () => ({
123
+ type: 'integer',
124
+ minimum: TIMEOUT_MIN_MS,
125
+ maximum: TIMEOUT_MAX_MS,
126
+ }),
127
+ })).annotate({
111
128
  description: `Optional, ${TIMEOUT_MIN_MS}-${TIMEOUT_MAX_MS} ms: how long to wait ${what}.`,
112
129
  }));
113
130
  /** The most files one upload step may give, and the largest a file may be. */
@@ -195,6 +212,14 @@ export const Step = Schema.Union([
195
212
  description: 'Click an element. If it opens a page with an HTTP error status, here or in a new tab or ' +
196
213
  'window, the case fails. Later steps act on this page, not a new tab.',
197
214
  }),
215
+ Schema.Struct({
216
+ action: Schema.Literal('hover'),
217
+ target: Target,
218
+ timeoutMs: timeoutMs('for the element (default 5000)'),
219
+ }).annotate({
220
+ description: 'Move the pointer over an element, for controls that only show on hover, such as a ' +
221
+ "message's Reply button. The pointer stays there until the next action moves it.",
222
+ }),
198
223
  Schema.Struct({
199
224
  action: Schema.Literal('fill'),
200
225
  target: Target,
@@ -209,7 +234,7 @@ export const Step = Schema.Union([
209
234
  files: Schema.Array(UploadFile)
210
235
  .check(Schema.makeFilter((files) => files.length >= 1 && files.length <= UPLOAD_FILES_MAX
211
236
  ? undefined
212
- : `Give 1-${UPLOAD_FILES_MAX} files`))
237
+ : `Give 1-${UPLOAD_FILES_MAX} files`, { toJsonSchema: () => ({ minItems: 1, maxItems: UPLOAD_FILES_MAX }) }))
213
238
  .annotate({
214
239
  description: `1-${UPLOAD_FILES_MAX} files, each a path relative to the project (such as ` +
215
240
  'fixtures/resume.pdf) or {"path","about"}. You create them, with synthetic content; ' +
@@ -249,7 +274,7 @@ export const Step = Schema.Union([
249
274
  })
250
275
  .check(Schema.makeFilter((step) => step.target !== undefined && step.frame !== undefined
251
276
  ? 'With target, give the frame in the target itself'
252
- : undefined))
277
+ : undefined, { toJsonSchema: () => ({ not: { required: ['target', 'frame'] } }) }))
253
278
  .annotate({
254
279
  description: 'Expect this text not to show: not as visible text, not as the alt text of an image and ' +
255
280
  'not as an ARIA label. Without frame or target, the page and the frames visible in it ' +
@@ -277,9 +302,16 @@ export const Step = Schema.Union([
277
302
  })),
278
303
  by: Schema.optionalKey(
279
304
  // A plain number checked here, so a fraction gets the same plain error as one out of range.
280
- Schema.Number.check(Schema.makeFilter((px) => Number.isInteger(px) && px !== 0 && Math.abs(px) <= SCROLL_BY_MAX
305
+ Schema.Finite.check(Schema.makeFilter((px) => Number.isInteger(px) && px !== 0 && Math.abs(px) <= SCROLL_BY_MAX
281
306
  ? undefined
282
- : `by must be a whole number of pixels from -${SCROLL_BY_MAX} to ${SCROLL_BY_MAX}, not 0`)).annotate({
307
+ : `by must be a whole number of pixels from -${SCROLL_BY_MAX} to ${SCROLL_BY_MAX}, not 0`, {
308
+ toJsonSchema: () => ({
309
+ type: 'integer',
310
+ minimum: -SCROLL_BY_MAX,
311
+ maximum: SCROLL_BY_MAX,
312
+ not: { const: 0 },
313
+ }),
314
+ })).annotate({
283
315
  description: `Scroll the page, or with frame that frame, down this many CSS pixels (negative: up); at most ${SCROLL_BY_MAX}.`,
284
316
  })),
285
317
  frame: Schema.optionalKey(FramePath),
@@ -292,6 +324,11 @@ export const Step = Schema.Union([
292
324
  if (step.target !== undefined && step.frame !== undefined)
293
325
  return 'With target, give the frame in the target itself';
294
326
  return undefined;
327
+ }, {
328
+ toJsonSchema: () => ({
329
+ oneOf: [{ required: ['target'] }, { required: ['to'] }, { required: ['by'] }],
330
+ not: { required: ['target', 'frame'] },
331
+ }),
295
332
  }))
296
333
  .annotate({
297
334
  description: 'Scroll, then take a screenshot of what is in view: exactly one of target (into view), ' +
@@ -437,6 +474,18 @@ export const JobSpec = Schema.Struct({
437
474
  return cases[0]?.continue === true
438
475
  ? `The first case, "${cases[0].id}", cannot continue: there is no case before it to continue from. Remove "continue" from it, or put the case that sets the page up before it`
439
476
  : undefined;
477
+ },
478
+ // Unique IDs have no JSON Schema form (uniqueItems compares whole cases); the first
479
+ // case's continue does.
480
+ {
481
+ toJsonSchema: () => [
482
+ {
483
+ prefixItems: [
484
+ { not: { required: ['continue'], properties: { continue: { const: true } } } },
485
+ ],
486
+ },
487
+ true,
488
+ ],
440
489
  }))
441
490
  .annotate({
442
491
  description: 'Cases to run in order. Without cases, one "page loads" case runs.',
@@ -451,7 +500,10 @@ export const JobSpec = Schema.Struct({
451
500
  'are saved). A test account to run signed in as: a label from .screw-bugs/accounts.json whose about ' +
452
501
  'fits what the cases need (such as a user on a trial, or a paying one), or a new ' +
453
502
  '{"label":"paid-user","about":"Pro plan, paying monthly"} for the user to sign in to. ' +
454
- 'Without a saved session nothing starts and the reply gives a link for the user.',
503
+ 'Read .screw-bugs/accounts.json first: when the account the cases need is not saved ' +
504
+ 'there, get the app running and that user in place (the sign-in opens the app at once), ' +
505
+ 'then start the job before the rest of your preparation. Without a saved session ' +
506
+ 'nothing starts and the reply gives a link for the user, who signs in while you prepare.',
455
507
  })),
456
508
  });
457
509
  /**
@@ -50,7 +50,7 @@ export declare const CaseEntry: Schema.Struct<{
50
50
  readonly size: Schema.Number;
51
51
  }>>>;
52
52
  readonly action: Schema.optionalKey<Schema.Struct<{
53
- readonly kind: Schema.Literals<readonly ["click", "fill", "upload", "press", "scroll", "goto", "reload"]>;
53
+ readonly kind: Schema.Literals<readonly ["click", "hover", "fill", "upload", "press", "scroll", "goto", "reload"]>;
54
54
  readonly atMs: Schema.optionalKey<Schema.Number>;
55
55
  readonly point: Schema.optionalKey<Schema.Struct<{
56
56
  readonly x: Schema.Number;
@@ -155,6 +155,18 @@ export declare const BrowserRecord: Schema.Struct<{
155
155
  readonly version: Schema.String;
156
156
  }>;
157
157
  export type BrowserRecord = typeof BrowserRecord.Type;
158
+ /**
159
+ * Where a running job is: the case (1-based, in job order) and, once it started one, the step
160
+ * running in it, numbered as `CaseEntry.step` numbers steps (0 is the opening navigation), with
161
+ * its action (`click`). Saved with the heartbeat and when a case ends, so it may be a few seconds
162
+ * behind; only a running ledger has it.
163
+ */
164
+ export declare const RunProgress: Schema.Struct<{
165
+ readonly case: Schema.Int;
166
+ readonly step: Schema.optionalKey<Schema.Int>;
167
+ readonly kind: Schema.optionalKey<Schema.String>;
168
+ }>;
169
+ export type RunProgress = typeof RunProgress.Type;
158
170
  /** The running record of every case in a job; the source of truth for status and reports. */
159
171
  export declare const CaseLedger: Schema.Struct<{
160
172
  readonly jobId: Schema.brand<Schema.String, "JobId">;
@@ -201,7 +213,7 @@ export declare const CaseLedger: Schema.Struct<{
201
213
  readonly size: Schema.Number;
202
214
  }>>>;
203
215
  readonly action: Schema.optionalKey<Schema.Struct<{
204
- readonly kind: Schema.Literals<readonly ["click", "fill", "upload", "press", "scroll", "goto", "reload"]>;
216
+ readonly kind: Schema.Literals<readonly ["click", "hover", "fill", "upload", "press", "scroll", "goto", "reload"]>;
205
217
  readonly atMs: Schema.optionalKey<Schema.Number>;
206
218
  readonly point: Schema.optionalKey<Schema.Struct<{
207
219
  readonly x: Schema.Number;
@@ -329,6 +341,12 @@ export declare const CaseLedger: Schema.Struct<{
329
341
  }>>>;
330
342
  /** The screw-bugs version that ran the job. */
331
343
  readonly version: Schema.optionalKey<Schema.String>;
344
+ /** Where the job is while it runs (see `RunProgress`). */
345
+ readonly progress: Schema.optionalKey<Schema.Struct<{
346
+ readonly case: Schema.Int;
347
+ readonly step: Schema.optionalKey<Schema.Int>;
348
+ readonly kind: Schema.optionalKey<Schema.String>;
349
+ }>>;
332
350
  }>;
333
351
  export type CaseLedger = typeof CaseLedger.Type;
334
352
  /**
@@ -390,10 +408,10 @@ export declare const ReportBundle: Schema.Struct<{
390
408
  readonly steps: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
391
409
  readonly action: Schema.Literal<"goto">;
392
410
  readonly url: Schema.NonEmptyString;
393
- readonly timeoutMs: Schema.optionalKey<Schema.Number>;
411
+ readonly timeoutMs: Schema.optionalKey<Schema.Finite>;
394
412
  }>, Schema.Struct<{
395
413
  readonly action: Schema.Literal<"reload">;
396
- readonly timeoutMs: Schema.optionalKey<Schema.Number>;
414
+ readonly timeoutMs: Schema.optionalKey<Schema.Finite>;
397
415
  }>, Schema.Struct<{
398
416
  readonly action: Schema.Literal<"click">;
399
417
  readonly target: Schema.Struct<{
@@ -421,7 +439,35 @@ export declare const ReportBundle: Schema.Struct<{
421
439
  readonly frame: Schema.optionalKey<Schema.Unknown>;
422
440
  }>>]>>;
423
441
  }>;
424
- readonly timeoutMs: Schema.optionalKey<Schema.Number>;
442
+ readonly timeoutMs: Schema.optionalKey<Schema.Finite>;
443
+ }>, Schema.Struct<{
444
+ readonly action: Schema.Literal<"hover">;
445
+ readonly target: Schema.Struct<{
446
+ readonly role: Schema.optionalKey<Schema.NonEmptyString>;
447
+ readonly name: Schema.optionalKey<Schema.NonEmptyString>;
448
+ readonly text: Schema.optionalKey<Schema.NonEmptyString>;
449
+ readonly label: Schema.optionalKey<Schema.NonEmptyString>;
450
+ readonly alt: Schema.optionalKey<Schema.NonEmptyString>;
451
+ readonly css: Schema.optionalKey<Schema.NonEmptyString>;
452
+ readonly frame: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
453
+ readonly role: Schema.optionalKey<Schema.NonEmptyString>;
454
+ readonly name: Schema.optionalKey<Schema.NonEmptyString>;
455
+ readonly text: Schema.optionalKey<Schema.NonEmptyString>;
456
+ readonly label: Schema.optionalKey<Schema.NonEmptyString>;
457
+ readonly alt: Schema.optionalKey<Schema.NonEmptyString>;
458
+ readonly css: Schema.optionalKey<Schema.NonEmptyString>;
459
+ readonly frame: Schema.optionalKey<Schema.Unknown>;
460
+ }>, Schema.$Array<Schema.Struct<{
461
+ readonly role: Schema.optionalKey<Schema.NonEmptyString>;
462
+ readonly name: Schema.optionalKey<Schema.NonEmptyString>;
463
+ readonly text: Schema.optionalKey<Schema.NonEmptyString>;
464
+ readonly label: Schema.optionalKey<Schema.NonEmptyString>;
465
+ readonly alt: Schema.optionalKey<Schema.NonEmptyString>;
466
+ readonly css: Schema.optionalKey<Schema.NonEmptyString>;
467
+ readonly frame: Schema.optionalKey<Schema.Unknown>;
468
+ }>>]>>;
469
+ }>;
470
+ readonly timeoutMs: Schema.optionalKey<Schema.Finite>;
425
471
  }>, Schema.Struct<{
426
472
  readonly action: Schema.Literal<"fill">;
427
473
  readonly target: Schema.Struct<{
@@ -450,7 +496,7 @@ export declare const ReportBundle: Schema.Struct<{
450
496
  }>>]>>;
451
497
  }>;
452
498
  readonly value: Schema.String;
453
- readonly timeoutMs: Schema.optionalKey<Schema.Number>;
499
+ readonly timeoutMs: Schema.optionalKey<Schema.Finite>;
454
500
  }>, Schema.Struct<{
455
501
  readonly action: Schema.Literal<"upload">;
456
502
  readonly target: Schema.Struct<{
@@ -483,11 +529,11 @@ export declare const ReportBundle: Schema.Struct<{
483
529
  readonly about: Schema.optionalKey<Schema.String>;
484
530
  readonly allowMismatch: Schema.optionalKey<Schema.Boolean>;
485
531
  }>]>>;
486
- readonly timeoutMs: Schema.optionalKey<Schema.Number>;
532
+ readonly timeoutMs: Schema.optionalKey<Schema.Finite>;
487
533
  }>, Schema.Struct<{
488
534
  readonly action: Schema.Literal<"press">;
489
535
  readonly key: Schema.NonEmptyString;
490
- readonly timeoutMs: Schema.optionalKey<Schema.Number>;
536
+ readonly timeoutMs: Schema.optionalKey<Schema.Finite>;
491
537
  }>, Schema.Struct<{
492
538
  readonly action: Schema.Literal<"expectText">;
493
539
  readonly text: Schema.NonEmptyString;
@@ -508,7 +554,7 @@ export declare const ReportBundle: Schema.Struct<{
508
554
  readonly css: Schema.optionalKey<Schema.NonEmptyString>;
509
555
  readonly frame: Schema.optionalKey<Schema.Unknown>;
510
556
  }>>]>>;
511
- readonly timeoutMs: Schema.optionalKey<Schema.Number>;
557
+ readonly timeoutMs: Schema.optionalKey<Schema.Finite>;
512
558
  }>, Schema.Struct<{
513
559
  readonly action: Schema.Literal<"expectNoText">;
514
560
  readonly text: Schema.NonEmptyString;
@@ -554,7 +600,7 @@ export declare const ReportBundle: Schema.Struct<{
554
600
  readonly css: Schema.optionalKey<Schema.NonEmptyString>;
555
601
  readonly frame: Schema.optionalKey<Schema.Unknown>;
556
602
  }>>]>>;
557
- readonly timeoutMs: Schema.optionalKey<Schema.Number>;
603
+ readonly timeoutMs: Schema.optionalKey<Schema.Finite>;
558
604
  }>, Schema.Struct<{
559
605
  readonly action: Schema.Literal<"waitFor">;
560
606
  readonly target: Schema.Struct<{
@@ -583,7 +629,7 @@ export declare const ReportBundle: Schema.Struct<{
583
629
  }>>]>>;
584
630
  }>;
585
631
  readonly state: Schema.optionalKey<Schema.Literals<readonly ["visible", "hidden", "attached", "detached"]>>;
586
- readonly timeoutMs: Schema.optionalKey<Schema.Number>;
632
+ readonly timeoutMs: Schema.optionalKey<Schema.Finite>;
587
633
  }>, Schema.Struct<{
588
634
  readonly action: Schema.Literal<"scroll">;
589
635
  readonly target: Schema.optionalKey<Schema.Struct<{
@@ -612,7 +658,7 @@ export declare const ReportBundle: Schema.Struct<{
612
658
  }>>]>>;
613
659
  }>>;
614
660
  readonly to: Schema.optionalKey<Schema.Literals<readonly ["top", "bottom"]>>;
615
- readonly by: Schema.optionalKey<Schema.Number>;
661
+ readonly by: Schema.optionalKey<Schema.Finite>;
616
662
  readonly frame: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
617
663
  readonly role: Schema.optionalKey<Schema.NonEmptyString>;
618
664
  readonly name: Schema.optionalKey<Schema.NonEmptyString>;
@@ -630,11 +676,11 @@ export declare const ReportBundle: Schema.Struct<{
630
676
  readonly css: Schema.optionalKey<Schema.NonEmptyString>;
631
677
  readonly frame: Schema.optionalKey<Schema.Unknown>;
632
678
  }>>]>>;
633
- readonly timeoutMs: Schema.optionalKey<Schema.Number>;
679
+ readonly timeoutMs: Schema.optionalKey<Schema.Finite>;
634
680
  }>, Schema.Struct<{
635
681
  readonly action: Schema.Literal<"expectUrl">;
636
682
  readonly includes: Schema.NonEmptyString;
637
- readonly timeoutMs: Schema.optionalKey<Schema.Number>;
683
+ readonly timeoutMs: Schema.optionalKey<Schema.Finite>;
638
684
  }>, Schema.Struct<{
639
685
  readonly action: Schema.Literal<"expectLink">;
640
686
  readonly target: Schema.Struct<{
@@ -664,7 +710,7 @@ export declare const ReportBundle: Schema.Struct<{
664
710
  }>;
665
711
  readonly href: Schema.NonEmptyString;
666
712
  readonly match: Schema.optionalKey<Schema.Literals<readonly ["contains", "exact"]>>;
667
- readonly timeoutMs: Schema.optionalKey<Schema.Number>;
713
+ readonly timeoutMs: Schema.optionalKey<Schema.Finite>;
668
714
  }>, Schema.Struct<{
669
715
  readonly action: Schema.Literal<"screenshot">;
670
716
  readonly name: Schema.String;
@@ -724,7 +770,7 @@ export declare const ReportBundle: Schema.Struct<{
724
770
  readonly size: Schema.Number;
725
771
  }>>>;
726
772
  readonly action: Schema.optionalKey<Schema.Struct<{
727
- readonly kind: Schema.Literals<readonly ["click", "fill", "upload", "press", "scroll", "goto", "reload"]>;
773
+ readonly kind: Schema.Literals<readonly ["click", "hover", "fill", "upload", "press", "scroll", "goto", "reload"]>;
728
774
  readonly atMs: Schema.optionalKey<Schema.Number>;
729
775
  readonly point: Schema.optionalKey<Schema.Struct<{
730
776
  readonly x: Schema.Number;
@@ -852,6 +898,12 @@ export declare const ReportBundle: Schema.Struct<{
852
898
  }>>>;
853
899
  /** The screw-bugs version that ran the job. */
854
900
  readonly version: Schema.optionalKey<Schema.String>;
901
+ /** Where the job is while it runs (see `RunProgress`). */
902
+ readonly progress: Schema.optionalKey<Schema.Struct<{
903
+ readonly case: Schema.Int;
904
+ readonly step: Schema.optionalKey<Schema.Int>;
905
+ readonly kind: Schema.optionalKey<Schema.String>;
906
+ }>>;
855
907
  }>;
856
908
  readonly startedAt: Schema.String;
857
909
  readonly finishedAt: Schema.optionalKey<Schema.String>;
@@ -1000,6 +1052,12 @@ export declare const runFiles: {
1000
1052
  * `report.html`, by whoever writes that, never by itself or with `report-interrupted.html`.
1001
1053
  */
1002
1054
  readonly walkthrough: 'walkthrough.html';
1055
+ /**
1056
+ * The page a person watches a run on while it goes: written only by the run, when it starts and
1057
+ * with every ledger write, refreshing itself while the run is going; its last write links the
1058
+ * report (and the walkthrough). Never the report, and nothing else reads it.
1059
+ */
1060
+ readonly live: 'live.html';
1003
1061
  readonly evidenceDir: 'evidence';
1004
1062
  /** The evidence pack of an ended run, written by the run. */
1005
1063
  readonly evidence: 'evidence.json';
@@ -1058,3 +1116,9 @@ export type JudgedLedger = Omit<CaseLedger, 'cases'> & {
1058
1116
  * code's statuses.
1059
1117
  */
1060
1118
  export declare const judgedLedger: (ledger: CaseLedger, findings: Findings | undefined) => JudgedLedger;
1119
+ /**
1120
+ * Where a running job is, in words: `case 2 of 3 (reply-maya), step 4 (click)`, or without the
1121
+ * step before its case started one. Undefined unless the ledger is running and has a progress
1122
+ * that names one of its cases.
1123
+ */
1124
+ export declare const progressText: (ledger: Pick<CaseLedger, 'state' | 'cases' | 'progress'>) => string | undefined;
@@ -59,6 +59,17 @@ export const BrowserRecord = Schema.Struct({
59
59
  channel: Schema.optionalKey(Schema.String),
60
60
  version: Schema.String,
61
61
  });
62
+ /**
63
+ * Where a running job is: the case (1-based, in job order) and, once it started one, the step
64
+ * running in it, numbered as `CaseEntry.step` numbers steps (0 is the opening navigation), with
65
+ * its action (`click`). Saved with the heartbeat and when a case ends, so it may be a few seconds
66
+ * behind; only a running ledger has it.
67
+ */
68
+ export const RunProgress = Schema.Struct({
69
+ case: Schema.Int,
70
+ step: Schema.optionalKey(Schema.Int),
71
+ kind: Schema.optionalKey(Schema.String),
72
+ });
62
73
  /** The running record of every case in a job; the source of truth for status and reports. */
63
74
  export const CaseLedger = Schema.Struct({
64
75
  jobId: JobId,
@@ -83,6 +94,8 @@ export const CaseLedger = Schema.Struct({
83
94
  sessions: Schema.optionalKey(Schema.Array(Session)),
84
95
  /** The screw-bugs version that ran the job. */
85
96
  version: Schema.optionalKey(Schema.String),
97
+ /** Where the job is while it runs (see `RunProgress`). */
98
+ progress: Schema.optionalKey(RunProgress),
86
99
  });
87
100
  /**
88
101
  * A highlight of the agent's findings as the report draws it: its box on the screenshot, or in
@@ -170,6 +183,12 @@ export const runFiles = {
170
183
  * `report.html`, by whoever writes that, never by itself or with `report-interrupted.html`.
171
184
  */
172
185
  walkthrough: 'walkthrough.html',
186
+ /**
187
+ * The page a person watches a run on while it goes: written only by the run, when it starts and
188
+ * with every ledger write, refreshing itself while the run is going; its last write links the
189
+ * report (and the walkthrough). Never the report, and nothing else reads it.
190
+ */
191
+ live: 'live.html',
173
192
  evidenceDir: 'evidence',
174
193
  /** The evidence pack of an ended run, written by the run. */
175
194
  evidence: 'evidence.json',
@@ -247,3 +266,20 @@ export const judgedLedger = (ledger, findings) => {
247
266
  const failures = agentFailures(findings);
248
267
  return { ...ledger, cases: ledger.cases.map((entry) => judgedCase(entry, failures)) };
249
268
  };
269
+ /**
270
+ * Where a running job is, in words: `case 2 of 3 (reply-maya), step 4 (click)`, or without the
271
+ * step before its case started one. Undefined unless the ledger is running and has a progress
272
+ * that names one of its cases.
273
+ */
274
+ export const progressText = (ledger) => {
275
+ const { progress } = ledger;
276
+ if (ledger.state !== 'running' || progress === undefined)
277
+ return undefined;
278
+ const entry = ledger.cases[progress.case - 1];
279
+ if (entry === undefined)
280
+ return undefined;
281
+ const where = `case ${progress.case} of ${ledger.cases.length} (${entry.id})`;
282
+ return progress.step === undefined
283
+ ? where
284
+ : `${where}, step ${progress.step}${progress.kind !== undefined ? ` (${progress.kind})` : ''}`;
285
+ };
@@ -36,3 +36,20 @@ export declare const ShareErrorReply: Schema.Struct<{
36
36
  readonly message: Schema.String;
37
37
  }>;
38
38
  export type ShareErrorReply = typeof ShareErrorReply.Type;
39
+ /** Cloud's reply to a new share request. */
40
+ export declare const ShareRequestCreated: Schema.Struct<{
41
+ readonly id: Schema.String;
42
+ /** The pairing code the person types on Cloud, such as `K7QM-4MDX`. */
43
+ readonly code: Schema.String;
44
+ readonly confirmUrl: Schema.String;
45
+ /** Seconds to wait between claims. */
46
+ readonly interval: Schema.Number;
47
+ readonly expiresAt: Schema.String;
48
+ }>;
49
+ export type ShareRequestCreated = typeof ShareRequestCreated.Type;
50
+ /** Cloud's reply to a claim once the person confirmed: the ticket, and where to upload. */
51
+ export declare const ShareClaimed: Schema.Struct<{
52
+ readonly ticket: Schema.String;
53
+ readonly api: Schema.String;
54
+ }>;
55
+ export type ShareClaimed = typeof ShareClaimed.Type;
@@ -40,3 +40,25 @@ export const CompletedShare = Schema.Struct({
40
40
  });
41
41
  /** Every error reply of Cloud: a stable code and one sentence for people. */
42
42
  export const ShareErrorReply = Schema.Struct({ error: Schema.String, message: Schema.String });
43
+ /*
44
+ * The hand-off for a report opened from another device (`http://pop-os:<port>`, over a tailnet),
45
+ * where Cloud cannot send the browser back to a loopback callback. As `stripe login` does: the
46
+ * local server asks Cloud for a share request with the SHA-256 of a secret it keeps
47
+ * (`POST /api/share-requests`), shows the person the request's pairing code and sends them to
48
+ * `confirmUrl`, where they type the code and confirm; meanwhile it claims the request with the
49
+ * secret (`POST /api/share-requests/<id>/claim`) every `interval` seconds until Cloud gives the
50
+ * ticket, then uploads as above. Only the server that will receive the ticket shows the code, so
51
+ * a link someone else made cannot get a ticket into the person's account.
52
+ */
53
+ /** Cloud's reply to a new share request. */
54
+ export const ShareRequestCreated = Schema.Struct({
55
+ id: ShareTicket,
56
+ /** The pairing code the person types on Cloud, such as `K7QM-4MDX`. */
57
+ code: Schema.String.check(Schema.makeFilter((text) => /^[A-Z0-9]{4}-[A-Z0-9]{4}$/.test(text) ? undefined : 'Must look like ABCD-EFGH')),
58
+ confirmUrl: Schema.String,
59
+ /** Seconds to wait between claims. */
60
+ interval: Schema.Number,
61
+ expiresAt: Schema.String,
62
+ });
63
+ /** Cloud's reply to a claim once the person confirmed: the ticket, and where to upload. */
64
+ export const ShareClaimed = Schema.Struct({ ticket: ShareTicket, api: Schema.String });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screw-bugs",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Local browser QA for coding agents (MCP), people and CI.",
5
5
  "keywords": [
6
6
  "browser",