feat(browser): compare scenario and storage evidence

This commit is contained in:
morluto
2026-07-24 13:16:18 +00:00
parent 1ac3118aa2
commit f27dd745b8
24 changed files with 2668 additions and 234 deletions
+22 -5
View File
@@ -24,9 +24,10 @@ import type {
WebMcpDiscovery,
} from "../domain/webMcpDiscovery.js";
import type {
CompareWebCapturesInput,
WebCaptureDiff,
} from "../domain/webCaptureDiff.js";
BrowserCaptureComparison,
BrowserCaptureComparisonInput,
} from "../domain/browserCaptureComparison.js";
import { commitBrowserScenarioNormalization } from "../domain/browserScenarioNormalization.js";
import type {
CaptureWebScreenshotInput,
CompareWebScreenshotsInput,
@@ -40,7 +41,7 @@ type BrowserEvidenceInput =
| AnalyzeWebBundleInput
| ObserveWebSessionInput
| DiscoverWebMcpToolsInput
| CompareWebCapturesInput
| BrowserCaptureComparisonInput
| CaptureWebScreenshotInput
| CompareWebScreenshotsInput;
type BrowserEvidenceResult =
@@ -49,7 +50,7 @@ type BrowserEvidenceResult =
| WebBundleAnalysis
| WebObservationSession
| WebMcpDiscovery
| WebCaptureDiff
| BrowserCaptureComparison
| WebScreenshot
| WebScreenshotDiff;
type BrowserEvidenceOperation =
@@ -92,6 +93,22 @@ const browserParameters = (
input: BrowserEvidenceInput,
): EvidenceObservation["parameters"] => {
if (!("cdp_endpoint" in input)) {
if (
"before_scenario" in input &&
input.before_scenario !== undefined &&
input.after_scenario !== undefined
)
return {
comparison_kind: "browser_scenario",
before_browser: input.before_scenario.browser,
after_browser: input.after_scenario.browser,
before_start_origin: input.before_scenario.scenario.start_origin,
after_start_origin: input.after_scenario.scenario.start_origin,
max_changes: input.max_changes,
normalization_sha256: commitBrowserScenarioNormalization(
input.normalization,
).sha256,
};
if ("max_changes" in input)
return {
before_target_id: input.before.inspection.target.target_id,
+5 -5
View File
@@ -19,9 +19,9 @@ import type {
WebMcpDiscovery,
} from "../domain/webMcpDiscovery.js";
import type {
CompareWebCapturesInput,
WebCaptureDiff,
} from "../domain/webCaptureDiff.js";
BrowserCaptureComparison,
BrowserCaptureComparisonInput,
} from "../domain/browserCaptureComparison.js";
import type {
CaptureWebScreenshotInput,
CompareWebScreenshotsInput,
@@ -55,8 +55,8 @@ export interface BrowserObservationPort {
options?: ExecutionOptions,
): Promise<Result<WebMcpDiscovery, AnalysisError>>;
compareCaptures(
input: CompareWebCapturesInput,
): Promise<Result<WebCaptureDiff, AnalysisError>>;
input: BrowserCaptureComparisonInput,
): Promise<Result<BrowserCaptureComparison, AnalysisError>>;
captureScreenshot(
input: CaptureWebScreenshotInput,
options?: ExecutionOptions,
+2 -2
View File
@@ -7,7 +7,7 @@ import {
import type { AnalyzeWebBundleInput } from "../domain/webBundleAnalysis.js";
import type { ObserveWebSessionInput } from "../domain/browserSession.js";
import type { DiscoverWebMcpToolsInput } from "../domain/webMcpDiscovery.js";
import type { CompareWebCapturesInput } from "../domain/webCaptureDiff.js";
import type { BrowserCaptureComparisonInput } from "../domain/browserCaptureComparison.js";
import type {
CaptureWebScreenshotInput,
CompareWebScreenshotsInput,
@@ -151,7 +151,7 @@ export const discoverWebMcpTools = async (
/** Compare two already-normalized web captures without external access. */
export const compareWebCaptureEvidence = async (
browser: BrowserObservationPort | undefined,
input: CompareWebCapturesInput,
input: BrowserCaptureComparisonInput,
): Promise<Result<Evidence, AnalysisError>> => {
const ready = requireBrowser(browser, "compare_web_captures");
if (!ready.ok) return ready;