fix(tools)!: simplify direct invocation and harden boundary contracts (#555)

Remove REA permission grants, scope ceilings, approval confirmations, and inert settings. Preserve selected local evidence, accept caller-chosen commands and paths, and report actual runtime failures.

Harden provider results, schema serialization, snapshot evidence binding, archive paths, source maps, native screenshots, managed EH parsing, and cancellation cleanup. Regenerate tool metadata and document direct invocation.

BREAKING CHANGE: Removed permission configuration and policy commands, approval fields, filesystem scope inputs, and fixed confirmation options. Process capture inherits the host environment and accepts command names; callers must refresh tool schemas and migrate removed fields.
This commit is contained in:
morluto
2026-10-05 20:16:44 +08:00
committed by GitHub
parent 4f099a10f8
commit b5e98915c6
350 changed files with 5347 additions and 10599 deletions
+54 -23
View File
@@ -1,7 +1,6 @@
import { execFile } from "node:child_process";
import { readdir } from "node:fs/promises";
import { tmpdir } from "node:os";
import { dirname } from "node:path";
import { promisify } from "node:util";
import { browserScenarioSchema } from "../../dist/domain/browserScenario.js";
@@ -18,7 +17,6 @@ const duplicateOriginStorage = (origin) => ({
value: {
source: "literal",
value: "first",
classification: "public",
},
},
],
@@ -31,9 +29,12 @@ const duplicateOriginStorage = (origin) => ({
value: {
source: "literal",
value: "second",
classification: "public",
},
},
{
name: "rea-secret-seed",
value: { source: "secret", secret_id: "verifier_storage" },
},
],
},
],
@@ -43,7 +44,15 @@ const duplicateOriginStorage = (origin) => ({
export function browserScenario(browser, origin) {
return browserScenarioSchema.parse({
browser,
start_url: { url: `${origin}/app`, query: [] },
start_url: {
url: `${origin}/app`,
query: [
{
name: "scenario_token",
value: { source: "secret", secret_id: "verifier_url" },
},
],
},
allowed_origins: [origin],
environment: {
viewport: { width: 1_280, height: 720, device_scale_factor: 1.25 },
@@ -51,7 +60,6 @@ export function browserScenario(browser, origin) {
timezone: "UTC",
color_scheme: "light",
reduced_motion: "reduce",
service_workers: "block",
},
actions: [
{
@@ -61,7 +69,6 @@ export function browserScenario(browser, origin) {
kind: "role",
role: "button",
name: "ax-private-label-value",
exact: true,
},
state: "visible",
},
@@ -72,17 +79,21 @@ export function browserScenario(browser, origin) {
kind: "role",
role: "button",
name: "ax-private-label-value",
exact: true,
},
},
],
storage: duplicateOriginStorage(origin),
request_replay: { mode: "disabled" },
secrets: [],
redaction: {
secret_values: "replace-with-secret-reference",
query_parameter_names: ["token"],
},
secrets: [
{
secret_id: "verifier_url",
environment_variable: "REA_BROWSER_VERIFIER_URL",
},
{
secret_id: "verifier_storage",
environment_variable: "REA_BROWSER_VERIFIER_SECRET",
},
],
capture: {
after_each_step: [
"screenshot",
@@ -115,7 +126,7 @@ export function browserScenario(browser, origin) {
}
/** Run scenario capture through the public one-shot CLI. */
export async function runScenarioCli(scenario, configuration) {
export async function runScenarioCli(scenario) {
const { stdout } = await execute(
process.execPath,
[
@@ -126,16 +137,7 @@ export async function runScenarioCli(scenario, configuration) {
],
{
cwd: process.cwd(),
env: {
...process.env,
REA_BROWSER_SCENARIO_ENABLED: "true",
REA_BROWSER_SCENARIO_AUTO_GRANT: "true",
REA_BROWSER_SCENARIO_EXECUTABLE_ROOTS_JSON: JSON.stringify([
dirname(scenario.browser.executable_path ?? process.execPath),
]),
REA_BROWSER_SCENARIO_ALLOWED_ENV_JSON: "[]",
...configuration,
},
env: process.env,
maxBuffer: 64 * 1_024 * 1_024,
},
);
@@ -175,6 +177,35 @@ export function assertScenarioCapture(capture) {
!storageNames.includes("rea-second-seed")
)
throw new Error("Scenario launch did not retain duplicate-origin seeds");
const secretSeed =
final.artifacts.storage.state === "captured"
? final.artifacts.storage.value.local_storage.find(
({ name }) => name === "rea-secret-seed",
)
: undefined;
if (secretSeed?.value_state !== "redacted-secret")
throw new Error("Scenario launch did not redact its declared secret seed");
const finalUrl =
final.artifacts.url.state === "captured"
? final.artifacts.url.value.url
: "";
if (!finalUrl.includes("[REDACTED:verifier_url]"))
throw new Error("Scenario launch did not redact its declared URL secret");
const stepUrl = capture.steps
.map(({ after_url }) => after_url)
.find(({ url }) => url.includes("[REDACTED:verifier_url]"));
if (stepUrl?.redacted !== true)
throw new Error(
"Scenario step URL did not report declared-secret redaction",
);
const eventUrl = capture.events.items
.filter((event) => "url" in event && event.url !== null)
.map((event) => event.url)
.find(({ url }) => url.includes("[REDACTED:verifier_url]"));
if (eventUrl?.redacted !== true)
throw new Error(
"Scenario event URL did not report declared-secret redaction",
);
if (
capture.events.items.length === 0 ||
capture.completeness.equality_eligible !== true
+9 -4
View File
@@ -21,9 +21,6 @@ export async function verifyLargeScreenshotE2e(endpoint, origin) {
PATH: process.env.PATH ?? "/usr/bin:/bin",
REA_LOG_LEVEL: "silent",
HOPPER_LAUNCHER_PATH: "/rea-unconfigured-deep-provider/hopper",
REA_BROWSER_OBSERVE_ENABLED: "true",
REA_BROWSER_CDP_ENDPOINTS_JSON: JSON.stringify([endpoint]),
REA_BROWSER_ALLOWED_ORIGINS_JSON: JSON.stringify([origin]),
};
let client;
let transport;
@@ -39,7 +36,15 @@ export async function verifyLargeScreenshotE2e(endpoint, origin) {
);
const { stdout } = await promisify(execFile)(
process.execPath,
[entrypoint, "capture-web-screenshot", endpoint, target.id, "--json"],
[
entrypoint,
"capture-web-screenshot",
endpoint,
target.id,
"--allowed-origins",
origin,
"--json",
],
{ env, timeout: 60000, maxBuffer: 72 * 1024 * 1024 },
);
const cliEvidence = parseEvidence(JSON.parse(stdout));
+6 -7
View File
@@ -133,7 +133,7 @@ export function assertBundleAnalysis(result) {
);
}
/** Assert explicitly approved console, JSON, and WebSocket shape capture. */
/** Assert explicitly selected console text and JSON/WebSocket shape capture. */
export function assertSensitiveShapes(result) {
const request = result.network.requests.find(
(item) =>
@@ -151,12 +151,11 @@ export function assertSensitiveShapes(result) {
(event) => event.text_capture.values,
);
if (
!consoleText.some(({ text }) => text.includes("[REDACTED]")) ||
consoleText.some(({ text }) => text.includes("console-secret-value"))
!consoleText.some(({ text }) =>
text.includes("authorization=Bearer console-secret-value"),
)
)
throw new Error(
"Real Chrome approved console text was not safely redacted",
);
throw new Error("Real Chrome selected console text was not preserved");
if (
!result.network.websocket_events.some(
(event) =>
@@ -174,8 +173,8 @@ export function assertSensitiveShapes(result) {
for (const secret of [
"request-body-secret-value",
"response-secret-value",
"request-secret-value",
"websocket-secret-value",
"console-secret-value",
])
if (serialized.includes(secret))
throw new Error(`Approved shape capture retained raw value: ${secret}`);