@blazediff/agent 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -10,6 +10,56 @@ interface Verdict {
10
10
  action: VerdictAction;
11
11
  }
12
12
 
13
+ interface JudgeInput {
14
+ entry: ManifestEntry;
15
+ baselinePath: string;
16
+ actualPath: string;
17
+ diffPath?: string;
18
+ regions?: RegionSummary[];
19
+ diffPercentage?: number;
20
+ severity?: string;
21
+ heuristicVerdict: Verdict;
22
+ /**
23
+ * Fired the moment the judge starts real work on this test, *after* any
24
+ * internal queueing (e.g. waiting on a single-instance ML model). The CLI
25
+ * uses this to print the "judging X" line at the correct pipeline moment
26
+ * rather than when the call was merely scheduled.
27
+ */
28
+ onJudgingStart?: () => void;
29
+ }
30
+ type JudgmentRequestRegion = RegionSummary;
31
+ type JudgeFailureReason = "model-load" | "read" | "internal";
32
+ type JudgeOutput = {
33
+ kind: "judged";
34
+ verdict: Verdict;
35
+ rationale?: string;
36
+ confidence?: number;
37
+ } | {
38
+ kind: "deferred";
39
+ requestPath: string;
40
+ } | {
41
+ /**
42
+ * The judge could not produce a verdict (model load failed, crop read
43
+ * threw, …). `fallback` is the deterministic heuristic verdict the
44
+ * caller should adopt; `error` is the originating error for diagnostics.
45
+ */
46
+ kind: "failed";
47
+ reason: JudgeFailureReason;
48
+ error: Error;
49
+ fallback: Verdict;
50
+ };
51
+ interface Judge {
52
+ readonly name: string;
53
+ judge(input: JudgeInput, cwd: string): Promise<JudgeOutput>;
54
+ /**
55
+ * Optional one-time load step (e.g. streaming model weights). Run once after
56
+ * capture and before judging so the cost surfaces as its own phase instead of
57
+ * stalling the first test silently.
58
+ */
59
+ warmup?(): Promise<void>;
60
+ }
61
+ type JudgeBackend = "none" | "host" | "local";
62
+
13
63
  declare const STABILITY_HOOKS_VERSION = 1;
14
64
  /**
15
65
  * Context handed to a harness. `params` is intentionally generic — a harness
@@ -87,6 +137,8 @@ interface AgentConfig {
87
137
  framework?: string;
88
138
  packageManager?: "npm" | "pnpm" | "yarn" | "bun";
89
139
  baseUrl?: string;
140
+ /** default judge backend for `check`, set by `onboard --stack` */
141
+ judge?: JudgeBackend;
90
142
  }
91
143
  interface CaptureOptions {
92
144
  id: string;
@@ -118,11 +170,16 @@ interface CheckResult {
118
170
  diffPercentage?: number;
119
171
  severity?: string;
120
172
  regions?: RegionSummary[];
173
+ /** Natural pixel dimensions of the compared image (for region overlay scaling). */
174
+ width?: number;
175
+ height?: number;
121
176
  verdict?: Verdict;
122
177
  diffPath?: string;
123
178
  actualPath?: string;
124
179
  baselinePath?: string;
125
180
  message?: string;
181
+ /** Human decision recorded by `review` (re-baselined or confirmed regression). */
182
+ review?: "approved" | "rejected";
126
183
  }
127
184
 
128
185
  interface SubCapture {
@@ -231,32 +288,6 @@ declare function discover(opts: DiscoverOptions): Promise<DiscoveredRoute[]>;
231
288
  */
232
289
  declare function loadEnvFiles(cwd?: string): string[];
233
290
 
234
- interface JudgeInput {
235
- entry: ManifestEntry;
236
- baselinePath: string;
237
- actualPath: string;
238
- diffPath?: string;
239
- regions?: RegionSummary[];
240
- diffPercentage?: number;
241
- severity?: string;
242
- heuristicVerdict: Verdict;
243
- }
244
- type JudgmentRequestRegion = RegionSummary;
245
- type JudgeOutput = {
246
- kind: "judged";
247
- verdict: Verdict;
248
- rationale?: string;
249
- confidence?: number;
250
- } | {
251
- kind: "deferred";
252
- requestPath: string;
253
- };
254
- interface Judge {
255
- readonly name: string;
256
- judge(input: JudgeInput, cwd: string): Promise<JudgeOutput>;
257
- }
258
- type JudgeBackend = "none" | "host";
259
-
260
291
  interface ApplyJudgmentsResult {
261
292
  report: CheckReport;
262
293
  applied: string[];
@@ -268,7 +299,7 @@ interface ApplyJudgmentsOptions {
268
299
  onEvent?: (event: RunEvent) => void;
269
300
  junitPath?: string;
270
301
  }
271
- declare function applyJudgments(opts?: ApplyJudgmentsOptions | string): Promise<ApplyJudgmentsResult>;
302
+ declare function applyJudgments(opts?: ApplyJudgmentsOptions): Promise<ApplyJudgmentsResult>;
272
303
 
273
304
  interface JudgmentRequest {
274
305
  id: string;
@@ -310,8 +341,15 @@ interface JudgmentInterrupt {
310
341
 
311
342
  type ResumeMap = Record<string, Verdict>;
312
343
  type RunEvent = {
344
+ type: "captured";
345
+ entryId: string;
346
+ } | {
313
347
  type: "result";
314
348
  result: CheckResult;
349
+ } | {
350
+ type: "judging";
351
+ entryId: string;
352
+ url: string;
315
353
  } | {
316
354
  type: "interrupt";
317
355
  interrupt: JudgmentInterrupt;
@@ -374,15 +412,80 @@ declare const paths: (cwd?: string) => {
374
412
  config: string;
375
413
  manifest: string;
376
414
  harnesses: string;
377
- authHarness: string;
378
415
  baselines: string;
379
416
  actual: string;
380
417
  judgments: string;
381
418
  checkpoints: string;
382
- summary: string;
419
+ report: string;
383
420
  gitignore: string;
384
421
  serverLog: string;
385
422
  serverPid: string;
386
423
  };
387
424
 
388
- export { type AgentConfig, type ApplyJudgmentsResult, type BrowsersInstallOptions, type BrowsersInstallResult, type CaptureOptions, type CaptureRouteInput, type CaptureRouteResult, type CheckOptions, type CheckReport, type CheckResult, type DevServerConfig, type DiffOptions, type DiffOutcome, type DiscoveredRoute, type Harness, type HarnessContext, HarnessError, type HarnessRef, type Judge, type JudgeBackend, type JudgeInput, type JudgeOutput, type JudgmentRequest, type JudgmentRequestRegion, type Manifest, type ManifestEntry, type RegionSummary, type ResumeMap, type ResumeOptions, type RunCapturesOptions, type RunCapturesReport, type RunEvent, type RunOptions, STABILITY_HOOKS_VERSION, type Verdict, type VerdictAction, type VerdictLabel, type Viewport, type WaitFor, type WaitForSelector, applyJudgments, assertLeftLoginPage, captureScreenshot, configHash, diffEntry, discover, installBrowsers, loadConfig, loadEnvFiles, loadHarness, loadManifest, paths, resolveBaseUrl, resolveHarnessFile, resolveJudge, resumeGraph, runCaptures, runCheck, runGraph, saveConfig, saveManifest, threadIdFor };
425
+ /** Persist the machine-readable check report consumed by `review`. */
426
+ declare function writeReport(report: CheckReport, cwd?: string): Promise<string>;
427
+ /** Read `.blazediff/report.json`, or null when absent/unparseable. */
428
+ declare function readReport(cwd?: string): Promise<CheckReport | null>;
429
+
430
+ type ReviewStatus = "unreviewed" | "approved" | "rejected";
431
+ /** Design's CSS tint classes; mapped from the agent's VerdictLabel. */
432
+ type ReviewClass = "intentional-likely" | "regression" | "layout-shift";
433
+ interface ReviewRegion {
434
+ id: number;
435
+ bbox: {
436
+ x: number;
437
+ y: number;
438
+ w: number;
439
+ h: number;
440
+ };
441
+ kind: string;
442
+ pixels: number;
443
+ change: number;
444
+ }
445
+ interface ReviewEntry {
446
+ id: string;
447
+ name: string;
448
+ url: string;
449
+ width: number;
450
+ height: number;
451
+ diff: number;
452
+ classification: ReviewClass;
453
+ severity: string;
454
+ action: string;
455
+ summary: string;
456
+ changes: string[];
457
+ regions: ReviewRegion[];
458
+ status: ReviewStatus;
459
+ reviewedAt?: string;
460
+ reviewedBy?: string;
461
+ }
462
+ interface ReviewRunMeta {
463
+ name: string;
464
+ baseline: string;
465
+ candidate: string;
466
+ startedAt: string;
467
+ threshold: number;
468
+ total: number;
469
+ failed: number;
470
+ passed: number;
471
+ }
472
+ interface ReviewPayload {
473
+ meta: ReviewRunMeta;
474
+ entries: ReviewEntry[];
475
+ }
476
+
477
+ /**
478
+ * Approve = accept the reviewed candidate: promote the existing
479
+ * `actual/<id>.png` to the baseline (no re-screenshot) and drop the now-stale
480
+ * actual/diff/judgment artifacts. The report entry flips to a passing,
481
+ * approved state so it stays green in CI and lingers in the UI's "Done" tab.
482
+ */
483
+ declare function approveEntry(id: string, cwd?: string): Promise<ReviewEntry | null>;
484
+ /**
485
+ * Reject = confirm a regression. Write a `regression-likely` verdict.json so
486
+ * `check --apply-judgments` keeps the entry failing, and record the decision
487
+ * in the report so the UI reflects it on reload.
488
+ */
489
+ declare function rejectEntry(id: string, cwd?: string): Promise<ReviewEntry | null>;
490
+
491
+ export { type AgentConfig, type ApplyJudgmentsResult, type BrowsersInstallOptions, type BrowsersInstallResult, type CaptureOptions, type CaptureRouteInput, type CaptureRouteResult, type CheckOptions, type CheckReport, type CheckResult, type DevServerConfig, type DiffOptions, type DiffOutcome, type DiscoveredRoute, type Harness, type HarnessContext, HarnessError, type HarnessRef, type Judge, type JudgeBackend, type JudgeInput, type JudgeOutput, type JudgmentRequest, type JudgmentRequestRegion, type Manifest, type ManifestEntry, type RegionSummary, type ResumeMap, type ResumeOptions, type ReviewEntry, type ReviewPayload, type ReviewRegion, type ReviewRunMeta, type ReviewStatus, type RunCapturesOptions, type RunCapturesReport, type RunEvent, type RunOptions, STABILITY_HOOKS_VERSION, type Verdict, type VerdictAction, type VerdictLabel, type Viewport, type WaitFor, type WaitForSelector, applyJudgments, approveEntry, assertLeftLoginPage, captureScreenshot, configHash, diffEntry, discover, installBrowsers, loadConfig, loadEnvFiles, loadHarness, loadManifest, paths, readReport, rejectEntry, resolveBaseUrl, resolveHarnessFile, resolveJudge, resumeGraph, runCaptures, runCheck, runGraph, saveConfig, saveManifest, threadIdFor, writeReport };
package/dist/index.d.ts CHANGED
@@ -10,6 +10,56 @@ interface Verdict {
10
10
  action: VerdictAction;
11
11
  }
12
12
 
13
+ interface JudgeInput {
14
+ entry: ManifestEntry;
15
+ baselinePath: string;
16
+ actualPath: string;
17
+ diffPath?: string;
18
+ regions?: RegionSummary[];
19
+ diffPercentage?: number;
20
+ severity?: string;
21
+ heuristicVerdict: Verdict;
22
+ /**
23
+ * Fired the moment the judge starts real work on this test, *after* any
24
+ * internal queueing (e.g. waiting on a single-instance ML model). The CLI
25
+ * uses this to print the "judging X" line at the correct pipeline moment
26
+ * rather than when the call was merely scheduled.
27
+ */
28
+ onJudgingStart?: () => void;
29
+ }
30
+ type JudgmentRequestRegion = RegionSummary;
31
+ type JudgeFailureReason = "model-load" | "read" | "internal";
32
+ type JudgeOutput = {
33
+ kind: "judged";
34
+ verdict: Verdict;
35
+ rationale?: string;
36
+ confidence?: number;
37
+ } | {
38
+ kind: "deferred";
39
+ requestPath: string;
40
+ } | {
41
+ /**
42
+ * The judge could not produce a verdict (model load failed, crop read
43
+ * threw, …). `fallback` is the deterministic heuristic verdict the
44
+ * caller should adopt; `error` is the originating error for diagnostics.
45
+ */
46
+ kind: "failed";
47
+ reason: JudgeFailureReason;
48
+ error: Error;
49
+ fallback: Verdict;
50
+ };
51
+ interface Judge {
52
+ readonly name: string;
53
+ judge(input: JudgeInput, cwd: string): Promise<JudgeOutput>;
54
+ /**
55
+ * Optional one-time load step (e.g. streaming model weights). Run once after
56
+ * capture and before judging so the cost surfaces as its own phase instead of
57
+ * stalling the first test silently.
58
+ */
59
+ warmup?(): Promise<void>;
60
+ }
61
+ type JudgeBackend = "none" | "host" | "local";
62
+
13
63
  declare const STABILITY_HOOKS_VERSION = 1;
14
64
  /**
15
65
  * Context handed to a harness. `params` is intentionally generic — a harness
@@ -87,6 +137,8 @@ interface AgentConfig {
87
137
  framework?: string;
88
138
  packageManager?: "npm" | "pnpm" | "yarn" | "bun";
89
139
  baseUrl?: string;
140
+ /** default judge backend for `check`, set by `onboard --stack` */
141
+ judge?: JudgeBackend;
90
142
  }
91
143
  interface CaptureOptions {
92
144
  id: string;
@@ -118,11 +170,16 @@ interface CheckResult {
118
170
  diffPercentage?: number;
119
171
  severity?: string;
120
172
  regions?: RegionSummary[];
173
+ /** Natural pixel dimensions of the compared image (for region overlay scaling). */
174
+ width?: number;
175
+ height?: number;
121
176
  verdict?: Verdict;
122
177
  diffPath?: string;
123
178
  actualPath?: string;
124
179
  baselinePath?: string;
125
180
  message?: string;
181
+ /** Human decision recorded by `review` (re-baselined or confirmed regression). */
182
+ review?: "approved" | "rejected";
126
183
  }
127
184
 
128
185
  interface SubCapture {
@@ -231,32 +288,6 @@ declare function discover(opts: DiscoverOptions): Promise<DiscoveredRoute[]>;
231
288
  */
232
289
  declare function loadEnvFiles(cwd?: string): string[];
233
290
 
234
- interface JudgeInput {
235
- entry: ManifestEntry;
236
- baselinePath: string;
237
- actualPath: string;
238
- diffPath?: string;
239
- regions?: RegionSummary[];
240
- diffPercentage?: number;
241
- severity?: string;
242
- heuristicVerdict: Verdict;
243
- }
244
- type JudgmentRequestRegion = RegionSummary;
245
- type JudgeOutput = {
246
- kind: "judged";
247
- verdict: Verdict;
248
- rationale?: string;
249
- confidence?: number;
250
- } | {
251
- kind: "deferred";
252
- requestPath: string;
253
- };
254
- interface Judge {
255
- readonly name: string;
256
- judge(input: JudgeInput, cwd: string): Promise<JudgeOutput>;
257
- }
258
- type JudgeBackend = "none" | "host";
259
-
260
291
  interface ApplyJudgmentsResult {
261
292
  report: CheckReport;
262
293
  applied: string[];
@@ -268,7 +299,7 @@ interface ApplyJudgmentsOptions {
268
299
  onEvent?: (event: RunEvent) => void;
269
300
  junitPath?: string;
270
301
  }
271
- declare function applyJudgments(opts?: ApplyJudgmentsOptions | string): Promise<ApplyJudgmentsResult>;
302
+ declare function applyJudgments(opts?: ApplyJudgmentsOptions): Promise<ApplyJudgmentsResult>;
272
303
 
273
304
  interface JudgmentRequest {
274
305
  id: string;
@@ -310,8 +341,15 @@ interface JudgmentInterrupt {
310
341
 
311
342
  type ResumeMap = Record<string, Verdict>;
312
343
  type RunEvent = {
344
+ type: "captured";
345
+ entryId: string;
346
+ } | {
313
347
  type: "result";
314
348
  result: CheckResult;
349
+ } | {
350
+ type: "judging";
351
+ entryId: string;
352
+ url: string;
315
353
  } | {
316
354
  type: "interrupt";
317
355
  interrupt: JudgmentInterrupt;
@@ -374,15 +412,80 @@ declare const paths: (cwd?: string) => {
374
412
  config: string;
375
413
  manifest: string;
376
414
  harnesses: string;
377
- authHarness: string;
378
415
  baselines: string;
379
416
  actual: string;
380
417
  judgments: string;
381
418
  checkpoints: string;
382
- summary: string;
419
+ report: string;
383
420
  gitignore: string;
384
421
  serverLog: string;
385
422
  serverPid: string;
386
423
  };
387
424
 
388
- export { type AgentConfig, type ApplyJudgmentsResult, type BrowsersInstallOptions, type BrowsersInstallResult, type CaptureOptions, type CaptureRouteInput, type CaptureRouteResult, type CheckOptions, type CheckReport, type CheckResult, type DevServerConfig, type DiffOptions, type DiffOutcome, type DiscoveredRoute, type Harness, type HarnessContext, HarnessError, type HarnessRef, type Judge, type JudgeBackend, type JudgeInput, type JudgeOutput, type JudgmentRequest, type JudgmentRequestRegion, type Manifest, type ManifestEntry, type RegionSummary, type ResumeMap, type ResumeOptions, type RunCapturesOptions, type RunCapturesReport, type RunEvent, type RunOptions, STABILITY_HOOKS_VERSION, type Verdict, type VerdictAction, type VerdictLabel, type Viewport, type WaitFor, type WaitForSelector, applyJudgments, assertLeftLoginPage, captureScreenshot, configHash, diffEntry, discover, installBrowsers, loadConfig, loadEnvFiles, loadHarness, loadManifest, paths, resolveBaseUrl, resolveHarnessFile, resolveJudge, resumeGraph, runCaptures, runCheck, runGraph, saveConfig, saveManifest, threadIdFor };
425
+ /** Persist the machine-readable check report consumed by `review`. */
426
+ declare function writeReport(report: CheckReport, cwd?: string): Promise<string>;
427
+ /** Read `.blazediff/report.json`, or null when absent/unparseable. */
428
+ declare function readReport(cwd?: string): Promise<CheckReport | null>;
429
+
430
+ type ReviewStatus = "unreviewed" | "approved" | "rejected";
431
+ /** Design's CSS tint classes; mapped from the agent's VerdictLabel. */
432
+ type ReviewClass = "intentional-likely" | "regression" | "layout-shift";
433
+ interface ReviewRegion {
434
+ id: number;
435
+ bbox: {
436
+ x: number;
437
+ y: number;
438
+ w: number;
439
+ h: number;
440
+ };
441
+ kind: string;
442
+ pixels: number;
443
+ change: number;
444
+ }
445
+ interface ReviewEntry {
446
+ id: string;
447
+ name: string;
448
+ url: string;
449
+ width: number;
450
+ height: number;
451
+ diff: number;
452
+ classification: ReviewClass;
453
+ severity: string;
454
+ action: string;
455
+ summary: string;
456
+ changes: string[];
457
+ regions: ReviewRegion[];
458
+ status: ReviewStatus;
459
+ reviewedAt?: string;
460
+ reviewedBy?: string;
461
+ }
462
+ interface ReviewRunMeta {
463
+ name: string;
464
+ baseline: string;
465
+ candidate: string;
466
+ startedAt: string;
467
+ threshold: number;
468
+ total: number;
469
+ failed: number;
470
+ passed: number;
471
+ }
472
+ interface ReviewPayload {
473
+ meta: ReviewRunMeta;
474
+ entries: ReviewEntry[];
475
+ }
476
+
477
+ /**
478
+ * Approve = accept the reviewed candidate: promote the existing
479
+ * `actual/<id>.png` to the baseline (no re-screenshot) and drop the now-stale
480
+ * actual/diff/judgment artifacts. The report entry flips to a passing,
481
+ * approved state so it stays green in CI and lingers in the UI's "Done" tab.
482
+ */
483
+ declare function approveEntry(id: string, cwd?: string): Promise<ReviewEntry | null>;
484
+ /**
485
+ * Reject = confirm a regression. Write a `regression-likely` verdict.json so
486
+ * `check --apply-judgments` keeps the entry failing, and record the decision
487
+ * in the report so the UI reflects it on reload.
488
+ */
489
+ declare function rejectEntry(id: string, cwd?: string): Promise<ReviewEntry | null>;
490
+
491
+ export { type AgentConfig, type ApplyJudgmentsResult, type BrowsersInstallOptions, type BrowsersInstallResult, type CaptureOptions, type CaptureRouteInput, type CaptureRouteResult, type CheckOptions, type CheckReport, type CheckResult, type DevServerConfig, type DiffOptions, type DiffOutcome, type DiscoveredRoute, type Harness, type HarnessContext, HarnessError, type HarnessRef, type Judge, type JudgeBackend, type JudgeInput, type JudgeOutput, type JudgmentRequest, type JudgmentRequestRegion, type Manifest, type ManifestEntry, type RegionSummary, type ResumeMap, type ResumeOptions, type ReviewEntry, type ReviewPayload, type ReviewRegion, type ReviewRunMeta, type ReviewStatus, type RunCapturesOptions, type RunCapturesReport, type RunEvent, type RunOptions, STABILITY_HOOKS_VERSION, type Verdict, type VerdictAction, type VerdictLabel, type Viewport, type WaitFor, type WaitForSelector, applyJudgments, approveEntry, assertLeftLoginPage, captureScreenshot, configHash, diffEntry, discover, installBrowsers, loadConfig, loadEnvFiles, loadHarness, loadManifest, paths, readReport, rejectEntry, resolveBaseUrl, resolveHarnessFile, resolveJudge, resumeGraph, runCaptures, runCheck, runGraph, saveConfig, saveManifest, threadIdFor, writeReport };