refactor(browser): return complete observation evidence

This commit is contained in:
morluto
2026-09-29 13:56:49 +08:00
parent 9d1f88cbe8
commit 0e2738ffb6
69 changed files with 747 additions and 1206 deletions
-15
View File
@@ -6,7 +6,6 @@ import type {
ElectronPageInspection,
InspectElectronPageInput,
} from "../domain/electronObservation.js";
import { MAX_ELECTRON_SCRIPT_SOURCE_BYTES } from "../domain/electronObservation.js";
import { createWebTextArtifact } from "../domain/webContentArtifact.js";
import type { CdpConnection } from "./CdpConnection.js";
import { CdpCaptureCompleteness } from "./CdpCaptureCompleteness.js";
@@ -91,8 +90,6 @@ const captureScriptSource = async (
reason: "source capture was not approved",
},
};
if (script.length > MAX_ELECTRON_SCRIPT_SOURCE_BYTES)
return sourceLimitResult(input.completeness);
const result = requiredRecord(
await input.connection.send(
"Debugger.getScriptSource",
@@ -102,9 +99,6 @@ const captureScriptSource = async (
),
);
const text = stringValue(result.scriptSource) ?? "";
const bytes = Buffer.byteLength(text);
if (bytes > MAX_ELECTRON_SCRIPT_SOURCE_BYTES)
return sourceLimitResult(input.completeness);
return {
source: {
included: true,
@@ -113,15 +107,6 @@ const captureScriptSource = async (
};
};
const sourceLimitResult = (
completeness: CdpCaptureCompleteness,
): { readonly source: ElectronScriptSource } => {
completeness.truncate("script_sources");
return {
source: { included: false, reason: "script source byte limit reached" },
};
};
const digest = (value: unknown): string => {
const encoded = canonicalize(value);
if (encoded === undefined) throw new TypeError("Expected canonical JSON");