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
@@ -1,3 +1,4 @@
import { createHash } from "node:crypto";
import { readFile } from "node:fs/promises";
import { z } from "zod";
@@ -11,6 +12,7 @@ import {
import {
AnalysisInputError,
AnalysisProtocolError,
EvidenceIntegrityError,
type AnalysisError,
} from "../domain/errors.js";
import { createEvidence, type Evidence } from "../domain/evidence.js";
@@ -41,16 +43,29 @@ export const compareManagedMembersEvidenceValidated = (
}
};
interface ManagedMemberComparisonPathDependencies {
readonly resolveTarget: typeof parseBinaryTarget;
readonly readBytes: (path: string) => Promise<Buffer>;
}
const DEFAULT_PATH_DEPENDENCIES: ManagedMemberComparisonPathDependencies = {
resolveTarget: parseBinaryTarget,
readBytes: readFile,
};
/** Inspect two local PE artifacts and return one derived comparison Evidence. */
export const compareManagedMemberPaths = async (input: {
readonly leftPath: string;
readonly rightPath: string;
}): Promise<Result<Evidence, AnalysisError>> => {
export const compareManagedMemberPaths = async (
input: {
readonly leftPath: string;
readonly rightPath: string;
},
dependencies: ManagedMemberComparisonPathDependencies = DEFAULT_PATH_DEPENDENCIES,
): Promise<Result<Evidence, AnalysisError>> => {
const operation = "compare_managed_members";
try {
const [leftTarget, rightTarget] = await Promise.all([
parseBinaryTarget(input.leftPath),
parseBinaryTarget(input.rightPath),
dependencies.resolveTarget(input.leftPath),
dependencies.resolveTarget(input.rightPath),
]);
if (!leftTarget.ok)
return err(
@@ -61,9 +76,21 @@ export const compareManagedMemberPaths = async (input: {
new AnalysisInputError(operation, { cause: rightTarget.error }),
);
const [leftBytes, rightBytes] = await Promise.all([
readFile(leftTarget.value.path),
readFile(rightTarget.value.path),
dependencies.readBytes(leftTarget.value.path),
dependencies.readBytes(rightTarget.value.path),
]);
for (const [target, bytes] of [
[leftTarget.value, leftBytes],
[rightTarget.value, rightBytes],
] as const) {
const observedSha256 = createHash("sha256").update(bytes).digest("hex");
if (observedSha256 !== target.sha256)
return err(
new EvidenceIntegrityError(
`Managed artifact digest changed after open: expected ${target.sha256}, observed ${observedSha256} at ${target.path}`,
),
);
}
const leftInspection = inspectManagedMembersBytes(
leftBytes,
leftTarget.value,