feat(server): advertise available tools dynamically
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { TOOL_CONTRACTS } from "../contracts/toolContracts.js";
|
||||
import type { ClientFeatureAvailability } from "../contracts/toolOutputSchemaPrimitives.js";
|
||||
import type { JsonValue } from "../domain/jsonValue.js";
|
||||
|
||||
const statusSchema = z.object({
|
||||
@@ -19,6 +20,7 @@ const statusSchema = z.object({
|
||||
|
||||
type ToolAvailabilityReason =
|
||||
| "available"
|
||||
| "client_capability_missing"
|
||||
| "target_required"
|
||||
| "provider_missing"
|
||||
| "provider_unavailable"
|
||||
@@ -32,15 +34,41 @@ type ProviderDescriptor = {
|
||||
readonly reason: string | null;
|
||||
readonly availability_code?: string | null;
|
||||
};
|
||||
type AvailabilityPolicy = {
|
||||
export type AvailabilityPolicy = {
|
||||
readonly processCaptureEnabled: boolean;
|
||||
readonly evidenceFileRoots: number;
|
||||
readonly investigationInputRoots: number;
|
||||
readonly browserObservationEnabled?: boolean;
|
||||
readonly browserScenarioEnabled?: boolean;
|
||||
readonly electronObservationEnabled?: boolean;
|
||||
readonly v8InspectorObservationEnabled?: boolean;
|
||||
readonly javascriptReplayEnabled?: boolean;
|
||||
readonly managedRuntimeEnabled?: boolean;
|
||||
};
|
||||
|
||||
type ClientFeatureName = keyof ClientFeatureAvailability;
|
||||
|
||||
const NO_CLIENT_FEATURES: ClientFeatureAvailability = {
|
||||
elicitation_form: false,
|
||||
elicitation_url: false,
|
||||
roots: false,
|
||||
sampling: false,
|
||||
};
|
||||
|
||||
const CLIENT_FEATURE_REQUIREMENTS: Readonly<
|
||||
Record<
|
||||
string,
|
||||
{
|
||||
readonly required: readonly ClientFeatureName[];
|
||||
readonly optional: readonly ClientFeatureName[];
|
||||
}
|
||||
>
|
||||
> = {
|
||||
capture_process_scenario: {
|
||||
required: [],
|
||||
optional: ["elicitation_form"],
|
||||
},
|
||||
};
|
||||
type Availability = {
|
||||
readonly reason: ToolAvailabilityReason;
|
||||
readonly remediation: string | null;
|
||||
@@ -82,10 +110,11 @@ const ENHANCED_REQUIREMENTS: Readonly<Record<string, readonly string[]>> = {
|
||||
],
|
||||
};
|
||||
|
||||
/** Build stable per-operation availability without hiding familiar tools. */
|
||||
/** Build stable per-operation availability for discovery and tool visibility. */
|
||||
export const buildCapabilityInventory = (
|
||||
sessionStatus: JsonValue,
|
||||
policy: AvailabilityPolicy,
|
||||
clientFeatures: ClientFeatureAvailability = NO_CLIENT_FEATURES,
|
||||
) => {
|
||||
const status = statusSchema.parse(sessionStatus);
|
||||
const descriptors = new Map<string, ProviderDescriptor>(
|
||||
@@ -107,12 +136,22 @@ export const buildCapabilityInventory = (
|
||||
descriptors,
|
||||
policy,
|
||||
});
|
||||
const clientRequirements = clientRequirementsFor(
|
||||
contract.name,
|
||||
clientFeatures,
|
||||
);
|
||||
const clientBlocked = clientRequirements.missing_required.length > 0;
|
||||
return {
|
||||
name: contract.name,
|
||||
surface: contract.kind,
|
||||
available: availability.reason === "available",
|
||||
reason: availability.reason,
|
||||
remediation: availability.remediation,
|
||||
available: availability.reason === "available" && !clientBlocked,
|
||||
reason: clientBlocked
|
||||
? ("client_capability_missing" as const)
|
||||
: availability.reason,
|
||||
remediation: clientBlocked
|
||||
? `Use an MCP client that supports: ${clientRequirements.missing_required.join(", ")}.`
|
||||
: availability.remediation,
|
||||
client_requirements: clientRequirements,
|
||||
effects: { ...contract.effects },
|
||||
annotations: {
|
||||
read_only: contract.annotations.readOnlyHint ?? false,
|
||||
@@ -124,6 +163,26 @@ export const buildCapabilityInventory = (
|
||||
}).sort((left, right) => left.name.localeCompare(right.name));
|
||||
};
|
||||
|
||||
const clientRequirementsFor = (
|
||||
name: string,
|
||||
clientFeatures: ClientFeatureAvailability,
|
||||
) => {
|
||||
const requirements = CLIENT_FEATURE_REQUIREMENTS[name] ?? {
|
||||
required: [],
|
||||
optional: [],
|
||||
};
|
||||
return {
|
||||
required: [...requirements.required],
|
||||
optional: [...requirements.optional],
|
||||
missing_required: requirements.required.filter(
|
||||
(feature) => !clientFeatures[feature],
|
||||
),
|
||||
missing_optional: requirements.optional.filter(
|
||||
(feature) => !clientFeatures[feature],
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
const availabilityFor = (context: AvailabilityContext): Availability => {
|
||||
const javascriptApplication = javascriptApplicationAvailability(context);
|
||||
if (javascriptApplication !== null) return javascriptApplication;
|
||||
@@ -156,6 +215,8 @@ const policyAvailability = ({
|
||||
kind,
|
||||
policy,
|
||||
}: AvailabilityContext): Availability | null => {
|
||||
const browser = browserPolicyAvailability(name, kind, policy);
|
||||
if (browser !== null) return browser;
|
||||
if (name === "capture_process_scenario" && !policy.processCaptureEnabled)
|
||||
return {
|
||||
reason: "policy_disabled",
|
||||
@@ -187,14 +248,6 @@ const policyAvailability = ({
|
||||
reason: "policy_disabled",
|
||||
remediation: "Configure or grant an evidence_read root.",
|
||||
};
|
||||
if (kind === "browser-provider")
|
||||
return policy.browserObservationEnabled === true
|
||||
? { reason: "available", remediation: null }
|
||||
: {
|
||||
reason: "policy_disabled",
|
||||
remediation:
|
||||
"Enable browser observation and configure exact CDP endpoint and page origins.",
|
||||
};
|
||||
if (kind === "electron-provider")
|
||||
return policy.electronObservationEnabled === true
|
||||
? { reason: "available", remediation: null }
|
||||
@@ -203,16 +256,47 @@ const policyAvailability = ({
|
||||
remediation:
|
||||
"Enable Electron observation and configure a loopback CDP endpoint and canonical file roots.",
|
||||
};
|
||||
if (kind === "runtime-provider")
|
||||
return policy.v8InspectorObservationEnabled === true
|
||||
? { reason: "available", remediation: null }
|
||||
: {
|
||||
reason: "policy_disabled",
|
||||
remediation:
|
||||
"Enable V8 Inspector observation and configure exact loopback endpoints plus canonical file roots or exact origins.",
|
||||
};
|
||||
if (kind === "session") return { reason: "available", remediation: null };
|
||||
return null;
|
||||
};
|
||||
|
||||
const browserPolicyAvailability = (
|
||||
name: string,
|
||||
kind: ToolKind,
|
||||
policy: AvailabilityPolicy,
|
||||
): Availability | null => {
|
||||
if (name === "capture_browser_scenario")
|
||||
return policy.browserScenarioEnabled === true
|
||||
? { reason: "available", remediation: null }
|
||||
: {
|
||||
reason: "policy_disabled",
|
||||
remediation:
|
||||
"Enable browser scenarios and configure exact executable roots or loopback CDP endpoints, page origins, and environment secret names.",
|
||||
};
|
||||
if (kind !== "browser-provider") return null;
|
||||
return policy.browserObservationEnabled === true
|
||||
? { reason: "available", remediation: null }
|
||||
: {
|
||||
reason: "policy_disabled",
|
||||
remediation:
|
||||
"Enable browser observation and configure exact CDP endpoint and page origins.",
|
||||
};
|
||||
};
|
||||
|
||||
const targetAvailability = ({
|
||||
kind,
|
||||
targetKind,
|
||||
targetOpen,
|
||||
}: AvailabilityContext): Availability | null => {
|
||||
if (!targetOpen)
|
||||
if (!targetOpen && (kind === "official-proxy" || kind === "enhanced"))
|
||||
return {
|
||||
reason: "target_required",
|
||||
remediation: "Call open_binary with a supported local target.",
|
||||
@@ -238,6 +322,13 @@ const providerAvailability = ({
|
||||
}: AvailabilityContext): Availability => {
|
||||
if (kind === "enhanced") return composedAvailability(name, descriptors);
|
||||
const descriptor = descriptors.get(name);
|
||||
if (
|
||||
descriptor === undefined &&
|
||||
(kind === "artifact-provider" ||
|
||||
kind === "managed-provider" ||
|
||||
kind === "native-provider")
|
||||
)
|
||||
return { reason: "available", remediation: null };
|
||||
if (descriptor === undefined)
|
||||
return {
|
||||
reason: "provider_missing",
|
||||
|
||||
@@ -23,6 +23,7 @@ const grantSchema = z.object({
|
||||
capability: z.enum([
|
||||
"process_capture",
|
||||
"browser_observe",
|
||||
"browser_automate",
|
||||
"electron_observe",
|
||||
"evidence_read",
|
||||
"evidence_write",
|
||||
|
||||
@@ -66,6 +66,15 @@ export const MCP_RESOURCE_TEMPLATE_CATALOG = [
|
||||
uri_template:
|
||||
"rea://reconstruction-coverage/{workspaceId}/revision/{revision}",
|
||||
},
|
||||
{
|
||||
name: "reconstruction-obligation-ledger-page",
|
||||
uri_template:
|
||||
"rea://evidence/{evidenceId}/reconstruction-obligation-ledger",
|
||||
},
|
||||
{
|
||||
name: "reconstruction-readiness-report",
|
||||
uri_template: "rea://evidence/{evidenceId}/reconstruction-readiness-report",
|
||||
},
|
||||
{
|
||||
name: "javascript-application-graph-page",
|
||||
uri_template:
|
||||
|
||||
@@ -14,7 +14,9 @@ import { registerProcessCommands } from "./cliProcessCommands.js";
|
||||
import { registerPolicyCommands } from "./cliPolicyCommands.js";
|
||||
import { registerBrowserCommands } from "./cliBrowserCommands.js";
|
||||
import { registerAdvancedBrowserCommands } from "./cliBrowserAdvancedCommands.js";
|
||||
import { registerBrowserScenarioCommands } from "./cliBrowserScenarioCommands.js";
|
||||
import { registerElectronCommands } from "./cliElectronCommands.js";
|
||||
import { registerJavaScriptRuntimeObservationCommands } from "./cliJavaScriptRuntimeCommands.js";
|
||||
import { registerApplicationCommands } from "./cliApplicationCommands.js";
|
||||
import type { CliInstance } from "./cli/types.js";
|
||||
|
||||
@@ -60,7 +62,9 @@ export const createCli = (): CliInstance => {
|
||||
registerPolicyCommands(cli, logger);
|
||||
registerBrowserCommands(cli, logger);
|
||||
registerAdvancedBrowserCommands(cli, logger);
|
||||
registerBrowserScenarioCommands(cli, logger);
|
||||
registerElectronCommands(cli, logger);
|
||||
registerJavaScriptRuntimeObservationCommands(cli, logger);
|
||||
registerApplicationCommands(cli, logger);
|
||||
return cli;
|
||||
};
|
||||
|
||||
@@ -3,12 +3,14 @@ import { Cli, z } from "incur";
|
||||
import {
|
||||
compareApplicationVersionsEvidenceValidated,
|
||||
compareJavaScriptExportShapesEvidenceValidated,
|
||||
compareSourceToBundleEvidenceValidated,
|
||||
traceApplicationFeatureEvidenceValidated,
|
||||
} from "./application/JavaScriptApplicationWorkflowService.js";
|
||||
import { traceJavaScriptSemanticsEvidenceValidated } from "./application/JavaScriptSemanticTraceService.js";
|
||||
import {
|
||||
resolveCompareApplicationVersionsRequest,
|
||||
resolveCompareJavaScriptExportShapesRequest,
|
||||
resolveCompareSourceToBundleRequest,
|
||||
resolveTraceApplicationFeatureRequest,
|
||||
resolveTraceJavaScriptSemanticsRequest,
|
||||
} from "./application/ApplicationWorkflowEvidenceResolver.js";
|
||||
@@ -25,6 +27,14 @@ import {
|
||||
reconstructionCoverageCommitInputSchema,
|
||||
reconstructionCoverageQueryInputSchema,
|
||||
} from "./application/ReconstructionCoverageService.js";
|
||||
import {
|
||||
buildReconstructionObligationLedgerEvidenceValidated,
|
||||
resolveReconstructionObligationLedgerRequest,
|
||||
} from "./application/ReconstructionObligationLedgerService.js";
|
||||
import {
|
||||
evaluateReconstructionReadinessValidated,
|
||||
resolveReconstructionReadinessRequest,
|
||||
} from "./application/ReconstructionReadinessService.js";
|
||||
import {
|
||||
authorizeFileReadWithDeferredWrite,
|
||||
authorizeRootPermission,
|
||||
@@ -80,6 +90,15 @@ export const registerApplicationCommands = (
|
||||
resolveInput: resolveCompareApplicationVersionsRequest,
|
||||
workflow: compareApplicationVersionsEvidenceValidated,
|
||||
});
|
||||
registerJsonCommand({
|
||||
cli,
|
||||
logger,
|
||||
name: CLI_COMMANDS.compareSourceToBundle,
|
||||
description:
|
||||
"Compare committed historical source with authenticated application Evidence",
|
||||
resolveInput: resolveCompareSourceToBundleRequest,
|
||||
workflow: compareSourceToBundleEvidenceValidated,
|
||||
});
|
||||
registerJsonCommand({
|
||||
cli,
|
||||
logger,
|
||||
@@ -136,9 +155,36 @@ export const registerApplicationCommands = (
|
||||
workflow: (config, authority, input) =>
|
||||
executeNodeCharacterization(replayDependencies(config, authority), input),
|
||||
});
|
||||
registerObligationLedgerCommand(cli, logger);
|
||||
registerReadinessCommand(cli, logger);
|
||||
registerCoverageCommands(cli, logger);
|
||||
};
|
||||
|
||||
const registerObligationLedgerCommand = (
|
||||
cli: CliInstance,
|
||||
logger: Logger,
|
||||
): void =>
|
||||
registerJsonCommand({
|
||||
cli,
|
||||
logger,
|
||||
name: CLI_COMMANDS.buildReconstructionObligationLedger,
|
||||
description:
|
||||
"Generate a deterministic Evidence-backed reconstruction obligation ledger page",
|
||||
resolveInput: resolveReconstructionObligationLedgerRequest,
|
||||
workflow: buildReconstructionObligationLedgerEvidenceValidated,
|
||||
});
|
||||
|
||||
const registerReadinessCommand = (cli: CliInstance, logger: Logger): void =>
|
||||
registerJsonCommand({
|
||||
cli,
|
||||
logger,
|
||||
name: CLI_COMMANDS.evaluateReconstructionReadiness,
|
||||
description:
|
||||
"Evaluate a complete Evidence-backed reconstruction readiness journey",
|
||||
resolveInput: resolveReconstructionReadinessRequest,
|
||||
workflow: evaluateReconstructionReadinessValidated,
|
||||
});
|
||||
|
||||
interface AuthorizedJsonCommandOptions {
|
||||
readonly cli: CliInstance;
|
||||
readonly logger: Logger;
|
||||
|
||||
@@ -16,6 +16,7 @@ export const CLI_COMMANDS = Object.freeze({
|
||||
search: "search",
|
||||
importReferenceSource: "import-reference-source",
|
||||
inventoryArtifact: "inventory-artifact",
|
||||
inspectArtifact: "inspect-artifact",
|
||||
extractArtifact: "extract-artifact",
|
||||
inspectManagedArtifact: "inspect-managed-artifact",
|
||||
inspectManagedMembers: "inspect-managed-members",
|
||||
@@ -45,18 +46,24 @@ export const CLI_COMMANDS = Object.freeze({
|
||||
compareWebCaptures: "compare-web-captures",
|
||||
captureWebScreenshot: "capture-web-screenshot",
|
||||
compareWebScreenshots: "compare-web-screenshots",
|
||||
captureBrowserScenario: "capture-browser-scenario",
|
||||
listElectronTargets: "list-electron-targets",
|
||||
inspectElectronPage: "inspect-electron-page",
|
||||
listJavaScriptRuntimeTargets: "list-javascript-runtime-targets",
|
||||
observeJavaScriptRuntime: "observe-javascript-runtime",
|
||||
analyzeJavaScriptApplication: "analyze-javascript-application",
|
||||
reconcileJavaScriptRuntime: "reconcile-javascript-runtime",
|
||||
traceApplicationFeature: "trace-application-feature",
|
||||
traceJavaScriptSemantics: "trace-javascript-semantics",
|
||||
compareApplicationVersions: "compare-application-versions",
|
||||
compareSourceToBundle: "compare-source-to-bundle",
|
||||
compareJavaScriptExportShapes: "compare-javascript-export-shapes",
|
||||
runReplayMachine: "run-replay-machine",
|
||||
runControlledReplay: "run-controlled-replay",
|
||||
prepareNodeCharacterization: "prepare-node-characterization",
|
||||
executeNodeCharacterization: "execute-node-characterization",
|
||||
buildReconstructionObligationLedger: "build-reconstruction-obligation-ledger",
|
||||
evaluateReconstructionReadiness: "evaluate-reconstruction-readiness",
|
||||
commitReconstructionCoverage: "commit-reconstruction-coverage",
|
||||
queryReconstructionCoverage: "query-reconstruction-coverage",
|
||||
});
|
||||
|
||||
@@ -19,6 +19,7 @@ import { CLI_COMMANDS } from "./cliCommandNames.js";
|
||||
const capabilitySchema = z.enum([
|
||||
"process_capture",
|
||||
"browser_observe",
|
||||
"browser_automate",
|
||||
"electron_observe",
|
||||
"evidence_read",
|
||||
"evidence_write",
|
||||
|
||||
@@ -54,9 +54,21 @@ const environmentSchema = z
|
||||
REA_BROWSER_OBSERVE_ENABLED: z.enum(["true", "false"]).default("false"),
|
||||
REA_BROWSER_CDP_ENDPOINTS_JSON: z.string().default("[]"),
|
||||
REA_BROWSER_ALLOWED_ORIGINS_JSON: z.string().default("[]"),
|
||||
REA_BROWSER_SCENARIO_ENABLED: z.enum(["true", "false"]).default("false"),
|
||||
REA_BROWSER_SCENARIO_AUTO_GRANT: z.enum(["true", "false"]).default("false"),
|
||||
REA_BROWSER_SCENARIO_EXECUTABLE_ROOTS_JSON: z.string().default("[]"),
|
||||
REA_BROWSER_SCENARIO_CDP_ENDPOINTS_JSON: z.string().default("[]"),
|
||||
REA_BROWSER_SCENARIO_ALLOWED_ORIGINS_JSON: z.string().default("[]"),
|
||||
REA_BROWSER_SCENARIO_ALLOWED_ENV_JSON: z.string().default("[]"),
|
||||
REA_ELECTRON_OBSERVE_ENABLED: z.enum(["true", "false"]).default("false"),
|
||||
REA_ELECTRON_CDP_ENDPOINTS_JSON: z.string().default("[]"),
|
||||
REA_ELECTRON_FILE_ROOTS_JSON: z.string().default("[]"),
|
||||
REA_V8_INSPECTOR_OBSERVE_ENABLED: z
|
||||
.enum(["true", "false"])
|
||||
.default("false"),
|
||||
REA_V8_INSPECTOR_ENDPOINTS_JSON: z.string().default("[]"),
|
||||
REA_V8_INSPECTOR_FILE_ROOTS_JSON: z.string().default("[]"),
|
||||
REA_V8_INSPECTOR_ALLOWED_ORIGINS_JSON: z.string().default("[]"),
|
||||
REA_JAVASCRIPT_REPLAY_ENABLED: z.enum(["true", "false"]).default("false"),
|
||||
REA_JAVASCRIPT_REPLAY_ROOTS_JSON: z.string().default("[]"),
|
||||
REA_JAVASCRIPT_REPLAY_NODE_PATH: z
|
||||
|
||||
+165
-34
@@ -41,12 +41,34 @@ interface ParsedArrays {
|
||||
readonly secretPatterns: readonly string[];
|
||||
readonly browserEndpoints: readonly string[];
|
||||
readonly browserOrigins: readonly string[];
|
||||
readonly browserScenarioExecutableRoots: readonly string[];
|
||||
readonly browserScenarioEndpoints: readonly string[];
|
||||
readonly browserScenarioOrigins: readonly string[];
|
||||
readonly browserScenarioEnvironment: readonly string[];
|
||||
readonly electronEndpoints: readonly string[];
|
||||
readonly electronFileRoots: readonly string[];
|
||||
readonly v8InspectorEndpoints: readonly string[];
|
||||
readonly v8InspectorFileRoots: readonly string[];
|
||||
readonly v8InspectorOrigins: readonly string[];
|
||||
readonly javascriptReplayRoots: readonly string[];
|
||||
readonly managedRuntimeRoots: readonly string[];
|
||||
}
|
||||
|
||||
type ParsedObservationArrays = Pick<
|
||||
ParsedArrays,
|
||||
| "browserEndpoints"
|
||||
| "browserOrigins"
|
||||
| "browserScenarioExecutableRoots"
|
||||
| "browserScenarioEndpoints"
|
||||
| "browserScenarioOrigins"
|
||||
| "browserScenarioEnvironment"
|
||||
| "electronEndpoints"
|
||||
| "electronFileRoots"
|
||||
| "v8InspectorEndpoints"
|
||||
| "v8InspectorFileRoots"
|
||||
| "v8InspectorOrigins"
|
||||
>;
|
||||
|
||||
const parseAllArrays = (
|
||||
env: Environment,
|
||||
): Result<ParsedArrays, ConfigurationError> => {
|
||||
@@ -92,31 +114,8 @@ const parseAllArrays = (
|
||||
"REA_REFERENCE_SECRET_PATTERNS_JSON",
|
||||
);
|
||||
if (!secretPatterns.ok) return secretPatterns;
|
||||
const browserEndpoints = parseBrowserArray(
|
||||
env.REA_BROWSER_CDP_ENDPOINTS_JSON,
|
||||
"REA_BROWSER_CDP_ENDPOINTS_JSON",
|
||||
browserEndpointSchema,
|
||||
16,
|
||||
);
|
||||
if (!browserEndpoints.ok) return browserEndpoints;
|
||||
const browserOrigins = parseBrowserArray(
|
||||
env.REA_BROWSER_ALLOWED_ORIGINS_JSON,
|
||||
"REA_BROWSER_ALLOWED_ORIGINS_JSON",
|
||||
browserOriginSchema,
|
||||
32,
|
||||
);
|
||||
if (!browserOrigins.ok) return browserOrigins;
|
||||
const electronEndpoints = parseBrowserArray(
|
||||
env.REA_ELECTRON_CDP_ENDPOINTS_JSON,
|
||||
"REA_ELECTRON_CDP_ENDPOINTS_JSON",
|
||||
browserEndpointSchema,
|
||||
16,
|
||||
);
|
||||
if (!electronEndpoints.ok) return electronEndpoints;
|
||||
const electronFileRoots = parseElectronFileRoots(
|
||||
env.REA_ELECTRON_FILE_ROOTS_JSON,
|
||||
);
|
||||
if (!electronFileRoots.ok) return electronFileRoots;
|
||||
const observations = parseObservationArrays(env);
|
||||
if (!observations.ok) return observations;
|
||||
const javascriptReplayRoots = parseAbsoluteRoots(
|
||||
env.REA_JAVASCRIPT_REPLAY_ROOTS_JSON,
|
||||
"REA_JAVASCRIPT_REPLAY_ROOTS_JSON",
|
||||
@@ -137,15 +136,98 @@ const parseAllArrays = (
|
||||
analysisSnapshotRoots: analysisSnapshotRoots.value,
|
||||
referenceRoots: referenceRoots.value,
|
||||
secretPatterns: secretPatterns.value,
|
||||
browserEndpoints: browserEndpoints.value,
|
||||
browserOrigins: browserOrigins.value,
|
||||
electronEndpoints: electronEndpoints.value,
|
||||
electronFileRoots: electronFileRoots.value,
|
||||
...observations.value,
|
||||
javascriptReplayRoots: javascriptReplayRoots.value,
|
||||
managedRuntimeRoots: managedRuntimeRoots.value,
|
||||
});
|
||||
};
|
||||
|
||||
const parseObservationArrays = (
|
||||
env: Environment,
|
||||
): Result<ParsedObservationArrays, ConfigurationError> => {
|
||||
const browserEndpoints = parseBrowserArray(
|
||||
env.REA_BROWSER_CDP_ENDPOINTS_JSON,
|
||||
"REA_BROWSER_CDP_ENDPOINTS_JSON",
|
||||
browserEndpointSchema,
|
||||
16,
|
||||
);
|
||||
if (!browserEndpoints.ok) return browserEndpoints;
|
||||
const browserOrigins = parseBrowserArray(
|
||||
env.REA_BROWSER_ALLOWED_ORIGINS_JSON,
|
||||
"REA_BROWSER_ALLOWED_ORIGINS_JSON",
|
||||
browserOriginSchema,
|
||||
32,
|
||||
);
|
||||
if (!browserOrigins.ok) return browserOrigins;
|
||||
const browserScenarioExecutableRoots = parseAbsoluteRoots(
|
||||
env.REA_BROWSER_SCENARIO_EXECUTABLE_ROOTS_JSON,
|
||||
"REA_BROWSER_SCENARIO_EXECUTABLE_ROOTS_JSON",
|
||||
);
|
||||
if (!browserScenarioExecutableRoots.ok) return browserScenarioExecutableRoots;
|
||||
const browserScenarioEndpoints = parseBrowserArray(
|
||||
env.REA_BROWSER_SCENARIO_CDP_ENDPOINTS_JSON,
|
||||
"REA_BROWSER_SCENARIO_CDP_ENDPOINTS_JSON",
|
||||
browserEndpointSchema,
|
||||
16,
|
||||
);
|
||||
if (!browserScenarioEndpoints.ok) return browserScenarioEndpoints;
|
||||
const browserScenarioOrigins = parseBrowserArray(
|
||||
env.REA_BROWSER_SCENARIO_ALLOWED_ORIGINS_JSON,
|
||||
"REA_BROWSER_SCENARIO_ALLOWED_ORIGINS_JSON",
|
||||
browserOriginSchema,
|
||||
32,
|
||||
);
|
||||
if (!browserScenarioOrigins.ok) return browserScenarioOrigins;
|
||||
const browserScenarioEnvironment = parseStringArray(
|
||||
env.REA_BROWSER_SCENARIO_ALLOWED_ENV_JSON,
|
||||
"REA_BROWSER_SCENARIO_ALLOWED_ENV_JSON",
|
||||
);
|
||||
if (!browserScenarioEnvironment.ok) return browserScenarioEnvironment;
|
||||
const electronEndpoints = parseBrowserArray(
|
||||
env.REA_ELECTRON_CDP_ENDPOINTS_JSON,
|
||||
"REA_ELECTRON_CDP_ENDPOINTS_JSON",
|
||||
browserEndpointSchema,
|
||||
16,
|
||||
);
|
||||
if (!electronEndpoints.ok) return electronEndpoints;
|
||||
const electronFileRoots = parseElectronFileRoots(
|
||||
env.REA_ELECTRON_FILE_ROOTS_JSON,
|
||||
);
|
||||
if (!electronFileRoots.ok) return electronFileRoots;
|
||||
const v8InspectorEndpoints = parseBrowserArray(
|
||||
env.REA_V8_INSPECTOR_ENDPOINTS_JSON,
|
||||
"REA_V8_INSPECTOR_ENDPOINTS_JSON",
|
||||
browserEndpointSchema,
|
||||
16,
|
||||
);
|
||||
if (!v8InspectorEndpoints.ok) return v8InspectorEndpoints;
|
||||
const v8InspectorFileRoots = parseAbsoluteRoots(
|
||||
env.REA_V8_INSPECTOR_FILE_ROOTS_JSON,
|
||||
"REA_V8_INSPECTOR_FILE_ROOTS_JSON",
|
||||
);
|
||||
if (!v8InspectorFileRoots.ok) return v8InspectorFileRoots;
|
||||
const v8InspectorOrigins = parseBrowserArray(
|
||||
env.REA_V8_INSPECTOR_ALLOWED_ORIGINS_JSON,
|
||||
"REA_V8_INSPECTOR_ALLOWED_ORIGINS_JSON",
|
||||
browserOriginSchema,
|
||||
32,
|
||||
);
|
||||
if (!v8InspectorOrigins.ok) return v8InspectorOrigins;
|
||||
return ok({
|
||||
browserEndpoints: browserEndpoints.value,
|
||||
browserOrigins: browserOrigins.value,
|
||||
browserScenarioExecutableRoots: browserScenarioExecutableRoots.value,
|
||||
browserScenarioEndpoints: browserScenarioEndpoints.value,
|
||||
browserScenarioOrigins: browserScenarioOrigins.value,
|
||||
browserScenarioEnvironment: browserScenarioEnvironment.value,
|
||||
electronEndpoints: electronEndpoints.value,
|
||||
electronFileRoots: electronFileRoots.value,
|
||||
v8InspectorEndpoints: v8InspectorEndpoints.value,
|
||||
v8InspectorFileRoots: v8InspectorFileRoots.value,
|
||||
v8InspectorOrigins: v8InspectorOrigins.value,
|
||||
});
|
||||
};
|
||||
|
||||
const parseAbsoluteRoots = (
|
||||
value: string,
|
||||
name: string,
|
||||
@@ -187,6 +269,25 @@ const appendBrowserObservationCeiling = (
|
||||
);
|
||||
};
|
||||
|
||||
const appendBrowserScenarioCeiling = (
|
||||
ceilings: PermissionCeiling[],
|
||||
env: Environment,
|
||||
arrays: ParsedArrays,
|
||||
): void => {
|
||||
if (env.REA_BROWSER_SCENARIO_ENABLED !== "true") return;
|
||||
ceilings.push(
|
||||
permissionScope("browser_automate", [], {
|
||||
executables: arrays.browserScenarioExecutableRoots,
|
||||
environment_names: arrays.browserScenarioEnvironment,
|
||||
origins: [
|
||||
...arrays.browserScenarioEndpoints,
|
||||
...arrays.browserScenarioOrigins,
|
||||
],
|
||||
network: browserNetworkScope(arrays.browserScenarioOrigins),
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
const appendElectronObservationCeiling = (
|
||||
ceilings: PermissionCeiling[],
|
||||
env: Environment,
|
||||
@@ -201,6 +302,20 @@ const appendElectronObservationCeiling = (
|
||||
);
|
||||
};
|
||||
|
||||
const appendV8InspectorObservationCeiling = (
|
||||
ceilings: PermissionCeiling[],
|
||||
env: Environment,
|
||||
arrays: ParsedArrays,
|
||||
): void => {
|
||||
if (env.REA_V8_INSPECTOR_OBSERVE_ENABLED !== "true") return;
|
||||
ceilings.push(
|
||||
permissionScope("v8_inspector_observe", arrays.v8InspectorFileRoots, {
|
||||
origins: [...arrays.v8InspectorEndpoints, ...arrays.v8InspectorOrigins],
|
||||
network: "loopback",
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
const appendNativeMountCeiling = (
|
||||
ceilings: PermissionCeiling[],
|
||||
env: Environment,
|
||||
@@ -261,7 +376,9 @@ const buildPermissionCeilings = (
|
||||
];
|
||||
appendProcessCaptureCeiling(ceilings, env, arrays);
|
||||
appendBrowserObservationCeiling(ceilings, env, arrays);
|
||||
appendBrowserScenarioCeiling(ceilings, env, arrays);
|
||||
appendElectronObservationCeiling(ceilings, env, arrays);
|
||||
appendV8InspectorObservationCeiling(ceilings, env, arrays);
|
||||
appendNativeMountCeiling(ceilings, env);
|
||||
appendJavaScriptReplayCeiling(ceilings, env, arrays);
|
||||
appendManagedRuntimeCeiling(ceilings, env, arrays);
|
||||
@@ -306,9 +423,21 @@ const buildAppConfig = (
|
||||
browserObservationEnabled: env.REA_BROWSER_OBSERVE_ENABLED === "true",
|
||||
browserCdpEndpoints: arrays.browserEndpoints,
|
||||
browserAllowedOrigins: arrays.browserOrigins,
|
||||
browserScenarioPolicy: {
|
||||
enabled: env.REA_BROWSER_SCENARIO_ENABLED === "true",
|
||||
executableRoots: arrays.browserScenarioExecutableRoots,
|
||||
cdpEndpoints: arrays.browserScenarioEndpoints,
|
||||
allowedOrigins: arrays.browserScenarioOrigins,
|
||||
allowedEnvironment: arrays.browserScenarioEnvironment,
|
||||
},
|
||||
electronObservationEnabled: env.REA_ELECTRON_OBSERVE_ENABLED === "true",
|
||||
electronCdpEndpoints: arrays.electronEndpoints,
|
||||
electronFileRoots: arrays.electronFileRoots,
|
||||
v8InspectorObservationEnabled:
|
||||
env.REA_V8_INSPECTOR_OBSERVE_ENABLED === "true",
|
||||
v8InspectorEndpoints: arrays.v8InspectorEndpoints,
|
||||
v8InspectorFileRoots: arrays.v8InspectorFileRoots,
|
||||
v8InspectorAllowedOrigins: arrays.v8InspectorOrigins,
|
||||
javascriptReplayPolicy: {
|
||||
enabled: env.REA_JAVASCRIPT_REPLAY_ENABLED === "true",
|
||||
roots: arrays.javascriptReplayRoots,
|
||||
@@ -325,11 +454,13 @@ const buildAppConfig = (
|
||||
},
|
||||
permissionCeilings,
|
||||
administratorPermissionGrants: administratorGrants(
|
||||
env.REA_PROCESS_CAPTURE_AUTO_GRANT === "true"
|
||||
? permissionCeilings
|
||||
: permissionCeilings.filter(
|
||||
({ capability }) => capability !== "process_capture",
|
||||
),
|
||||
permissionCeilings.filter(
|
||||
({ capability }) =>
|
||||
(capability !== "process_capture" ||
|
||||
env.REA_PROCESS_CAPTURE_AUTO_GRANT === "true") &&
|
||||
(capability !== "browser_automate" ||
|
||||
env.REA_BROWSER_SCENARIO_AUTO_GRANT === "true"),
|
||||
),
|
||||
),
|
||||
permissionProjectRoot: env.REA_PERMISSION_PROJECT_ROOT,
|
||||
permissionProjectStore: env.REA_PERMISSION_PROJECT_STORE,
|
||||
|
||||
@@ -28,9 +28,20 @@ export interface AppConfig {
|
||||
readonly browserObservationEnabled: boolean;
|
||||
readonly browserCdpEndpoints: readonly string[];
|
||||
readonly browserAllowedOrigins: readonly string[];
|
||||
readonly browserScenarioPolicy: {
|
||||
readonly enabled: boolean;
|
||||
readonly executableRoots: readonly string[];
|
||||
readonly cdpEndpoints: readonly string[];
|
||||
readonly allowedOrigins: readonly string[];
|
||||
readonly allowedEnvironment: readonly string[];
|
||||
};
|
||||
readonly electronObservationEnabled: boolean;
|
||||
readonly electronCdpEndpoints: readonly string[];
|
||||
readonly electronFileRoots: readonly string[];
|
||||
readonly v8InspectorObservationEnabled: boolean;
|
||||
readonly v8InspectorEndpoints: readonly string[];
|
||||
readonly v8InspectorFileRoots: readonly string[];
|
||||
readonly v8InspectorAllowedOrigins: readonly string[];
|
||||
readonly javascriptReplayPolicy: {
|
||||
readonly enabled: boolean;
|
||||
readonly roots: readonly string[];
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { applicationVersionComparisonResultSchema } from "../domain/javascriptApplicationVersionComparisonSchemas.js";
|
||||
import { z } from "zod";
|
||||
import { applicationFeatureTraceResultSchema } from "../domain/javascriptFeatureTraceSchemas.js";
|
||||
import { javaScriptSemanticTraceResultSchema } from "../domain/javascriptSemanticTraceSchemas.js";
|
||||
import { javaScriptExportShapeComparisonResultSchema } from "../domain/javascriptExportShapeComparisonSchemas.js";
|
||||
import { sourceToBundleComparisonResultSchema } from "../domain/sourceToBundleComparisonSchemas.js";
|
||||
import {
|
||||
compareApplicationVersionsRequestSchema,
|
||||
compareJavaScriptExportShapesRequestSchema,
|
||||
compareSourceToBundleRequestSchema,
|
||||
traceApplicationFeatureRequestSchema,
|
||||
traceJavaScriptSemanticsRequestSchema,
|
||||
} from "./applicationWorkflowInputContracts.js";
|
||||
@@ -24,6 +27,14 @@ import {
|
||||
reconstructionCoverageQueryInputSchema,
|
||||
} from "../application/ReconstructionCoverageService.js";
|
||||
import { reconstructionClosureResultSchema } from "../domain/reconstructionCoverage.js";
|
||||
import {
|
||||
reconstructionObligationLedgerInputSchema,
|
||||
reconstructionObligationLedgerPageSchema,
|
||||
} from "../domain/reconstructionObligationLedgerSchemas.js";
|
||||
import {
|
||||
reconstructionReadinessInputSchema,
|
||||
reconstructionReadinessReportSchema,
|
||||
} from "../domain/reconstructionReadinessSchemas.js";
|
||||
import { jsonObjectSchema } from "../domain/jsonValue.js";
|
||||
import type { ToolContract } from "./toolContracts.js";
|
||||
import { toolContractMetadata } from "./toolEffects.js";
|
||||
@@ -32,7 +43,9 @@ import {
|
||||
JAVASCRIPT_APPLICATION_VERSION_COMPARISON_EXAMPLE,
|
||||
JAVASCRIPT_EXPORT_SHAPE_COMPARISON_EXAMPLE,
|
||||
JAVASCRIPT_FEATURE_TRACE_EXAMPLE,
|
||||
SOURCE_TO_BUNDLE_COMPARISON_EXAMPLE,
|
||||
} from "./javascriptApplicationWorkflowExamples.js";
|
||||
import { RECONSTRUCTION_READINESS_EXAMPLE } from "./reconstructionReadinessExample.js";
|
||||
|
||||
const traceOutputSchema = evidenceResultOf(applicationFeatureTraceResultSchema);
|
||||
const semanticTraceOutputSchema = evidenceResultOf(
|
||||
@@ -41,9 +54,35 @@ const semanticTraceOutputSchema = evidenceResultOf(
|
||||
const comparisonOutputSchema = evidenceResultOf(
|
||||
applicationVersionComparisonResultSchema,
|
||||
);
|
||||
const sourceToBundleOutputSchema = evidenceResultOf(
|
||||
sourceToBundleComparisonResultSchema,
|
||||
);
|
||||
const exportShapeComparisonOutputSchema = evidenceResultOf(
|
||||
javaScriptExportShapeComparisonResultSchema,
|
||||
);
|
||||
const reconstructionObligationLedgerOutputSchema = evidenceResultOf(
|
||||
reconstructionObligationLedgerPageSchema,
|
||||
);
|
||||
const reconstructionReadinessOutputSchema = evidenceResultOf(
|
||||
reconstructionReadinessReportSchema
|
||||
.pick({
|
||||
schema: true,
|
||||
schema_version: true,
|
||||
report_id: true,
|
||||
source_digest: true,
|
||||
report_digest: true,
|
||||
status: true,
|
||||
summary: true,
|
||||
metrics: true,
|
||||
})
|
||||
.extend({
|
||||
report_resource_uri: z
|
||||
.string()
|
||||
.regex(
|
||||
/^rea:\/\/evidence\/ev_[a-f0-9]{64}\/reconstruction-readiness-report$/u,
|
||||
),
|
||||
}),
|
||||
);
|
||||
const HASH = "0".repeat(64);
|
||||
const NODE_PREPARATION_EXAMPLE = jsonObjectSchema.parse({
|
||||
preparation_approved: true,
|
||||
@@ -162,6 +201,22 @@ export const APPLICATION_TOOL_CONTRACTS = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "compare_source_to_bundle",
|
||||
...toolContractMetadata("compare_source_to_bundle"),
|
||||
description:
|
||||
"Compare a cryptographically committed HistoricalSourceGraph/v1 with authenticated JavaScript Application Graph Evidence supplied directly or by session Evidence ID. Uses explicit exact-digest, source-map path, current-path, suffix, and basename signals with stable weights. Classifies unchanged, modified, removed, split, merged, duplicated, and unknown; incomplete coverage and ambiguous weak signals never become absence or forced matches.",
|
||||
kind: "application",
|
||||
inputSchema: compareSourceToBundleRequestSchema,
|
||||
outputSchema: sourceToBundleOutputSchema,
|
||||
examples: [
|
||||
{
|
||||
title:
|
||||
"Compare committed historical source with a shipped bundle graph",
|
||||
input: SOURCE_TO_BUNDLE_COMPARISON_EXAMPLE,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "compare_javascript_export_shapes",
|
||||
...toolContractMetadata("compare_javascript_export_shapes"),
|
||||
@@ -264,6 +319,55 @@ export const APPLICATION_TOOL_CONTRACTS = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "build_reconstruction_obligation_ledger",
|
||||
...toolContractMetadata("build_reconstruction_obligation_ledger"),
|
||||
description:
|
||||
"Generate one deterministic page of a ReconstructionObligationLedger/v1 from an authenticated Evidence v2 bundle, reviewed obligations, and an explicit reconstruction manifest. Static candidates remain candidates; duplicate ownership, missing original or reconstruction cases, missing parser/type, weak verifier authority, unenumerated claims, contradictions, dependencies, and residual unknowns fail closed. Every page carries the same full-ledger closure digest and typed per-obligation diagnostics.",
|
||||
kind: "application",
|
||||
inputSchema: reconstructionObligationLedgerInputSchema,
|
||||
outputSchema: reconstructionObligationLedgerOutputSchema,
|
||||
examples: [
|
||||
{
|
||||
title: "Generate the first obligation-ledger page",
|
||||
input: {
|
||||
evidence_bundle: {
|
||||
bundle_version: 2,
|
||||
artifacts: [],
|
||||
providers: [],
|
||||
environments: [],
|
||||
scenarios: [],
|
||||
captures: [],
|
||||
unknowns: [],
|
||||
records: [],
|
||||
},
|
||||
reviewed_obligations: [],
|
||||
manifest: {
|
||||
schema_version: 1,
|
||||
bindings: [],
|
||||
contradictions: [],
|
||||
},
|
||||
limits: { max_obligations: 1_000 },
|
||||
page: { offset: 0, limit: 50 },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "evaluate_reconstruction_readiness",
|
||||
...toolContractMetadata("evaluate_reconstruction_readiness"),
|
||||
description:
|
||||
"Evaluate the fixed nine-stage public reconstruction journey into a deterministic ReconstructionReadinessReport/v1. Exact capability limits, provider routing, CLI/MCP status parity, bounded authority, partial-order comparison, contradictions, obligation closure, cleanup, and replay digests fail closed. Aggregate pass is emitted only when every required stage and check passes with attributable Evidence.",
|
||||
kind: "application",
|
||||
inputSchema: reconstructionReadinessInputSchema,
|
||||
outputSchema: reconstructionReadinessOutputSchema,
|
||||
examples: [
|
||||
{
|
||||
title: "Evaluate the complete synthetic reconstruction journey",
|
||||
input: RECONSTRUCTION_READINESS_EXAMPLE,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "commit_reconstruction_coverage",
|
||||
...toolContractMetadata("commit_reconstruction_coverage"),
|
||||
|
||||
@@ -18,6 +18,8 @@ export const TOOL_EXAMPLE_OVERRIDES: Readonly<
|
||||
procedure_callers: { procedure: "main" },
|
||||
procedure_info: { procedure: "main" },
|
||||
read_function_instructions: { procedure: "main" },
|
||||
read_bytes: { address: "0x1000", length: 16 },
|
||||
address_to_file_offset: { address: "0x1000" },
|
||||
procedure_references: { procedure: "main" },
|
||||
procedure_pseudo_code: { procedure: "main" },
|
||||
resolve_containing_procedure: { address: "0x1000" },
|
||||
@@ -34,6 +36,8 @@ export const TOOL_EXAMPLE_OVERRIDES: Readonly<
|
||||
find_xrefs_to_name: { name: "malloc" },
|
||||
analyze_function: { procedure: "main" },
|
||||
trace_feature: { query: "license" },
|
||||
find_code_for_string: { query: "authorization failed" },
|
||||
trace_call_path: { start: "0x1000", goal: "0x1100" },
|
||||
open_binary: { path: "/tmp/fixture" },
|
||||
import_evidence_bundle: { path: "evidence.json" },
|
||||
capture_process_scenario: {
|
||||
|
||||
@@ -26,6 +26,7 @@ export const TOOL_KINDS = [
|
||||
"managed-provider",
|
||||
"browser-provider",
|
||||
"electron-provider",
|
||||
"runtime-provider",
|
||||
"application",
|
||||
"session",
|
||||
] as const;
|
||||
|
||||
@@ -27,8 +27,9 @@ import { NATIVE_TOOL_CONTRACTS } from "./nativeToolContracts.js";
|
||||
import { ARTIFACT_TOOL_CONTRACTS } from "./artifactToolContracts.js";
|
||||
import { MANAGED_TOOL_CONTRACTS } from "./managedToolContracts.js";
|
||||
import { MANAGED_WORKFLOW_TOOL_CONTRACTS } from "./managedWorkflowToolContracts.js";
|
||||
import { BROWSER_TOOL_CONTRACTS } from "./browserToolContracts.js";
|
||||
import { BROWSER_PROVIDER_TOOL_CONTRACTS } from "./browserProviderToolContracts.js";
|
||||
import { ELECTRON_TOOL_CONTRACTS } from "./electronToolContracts.js";
|
||||
import { JAVASCRIPT_RUNTIME_OBSERVATION_TOOL_CONTRACTS } from "./javascriptRuntimeObservationToolContracts.js";
|
||||
import { APPLICATION_TOOL_CONTRACTS } from "./applicationToolContracts.js";
|
||||
import {
|
||||
closeBinaryInputSchema,
|
||||
@@ -38,6 +39,8 @@ import type { ToolContract, ToolExample } from "./toolContractTypes.js";
|
||||
import { toolContractMetadata } from "./toolEffects.js";
|
||||
import { binarySessionInputSchema } from "./sessionStatusContract.js";
|
||||
import { functionInstructionInputSchema } from "./functionInstructionContract.js";
|
||||
import { HOPPER_MEMORY_TOOL_DEFINITIONS } from "./hopperMemoryContracts.js";
|
||||
import { analysisSearchInput } from "./analysisSearchContract.js";
|
||||
|
||||
export { binarySessionInputSchema } from "./sessionStatusContract.js";
|
||||
|
||||
@@ -51,27 +54,10 @@ const address = z
|
||||
);
|
||||
const optionalAddress = address.optional();
|
||||
const procedure = z.string().describe("The procedure name or address");
|
||||
const searchPattern = z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(256)
|
||||
.describe("The literal text or bounded regex pattern to search for");
|
||||
const caseSensitive = z
|
||||
.boolean()
|
||||
.default(false)
|
||||
.describe("Whether to match case");
|
||||
const pagination = {
|
||||
offset: z.number().int().min(0).default(0),
|
||||
limit: z.number().int().min(1).max(500).default(100),
|
||||
};
|
||||
const searchInput = {
|
||||
pattern: searchPattern,
|
||||
mode: z.enum(["literal", "regex"]).default("literal"),
|
||||
case_sensitive: caseSensitive,
|
||||
offset: z.number().int().min(0).default(0),
|
||||
limit: z.number().int().min(1).max(100).default(100),
|
||||
document,
|
||||
};
|
||||
|
||||
const exampleInputSchema = z.record(z.string(), jsonValueSchema);
|
||||
const examplesFor = (
|
||||
@@ -246,6 +232,9 @@ export const OFFICIAL_TOOL_CONTRACTS = [
|
||||
"Read one offset-paginated window of raw instructions for an analyzed procedure without decompilation, caller discovery, or whole-program string/name scans. Use this fast path for instruction-level orientation; follow next_offset when truncated.",
|
||||
functionInstructionInputSchema,
|
||||
),
|
||||
...HOPPER_MEMORY_TOOL_DEFINITIONS.map(({ name, description, inputSchema }) =>
|
||||
official(name, description, inputSchema),
|
||||
),
|
||||
official(
|
||||
"procedure_references",
|
||||
"Return a bounded set of raw incoming or outgoing reference edges for one procedure. Endpoint procedures are resolved only from provider containment; Ghidra preserves observed reference kinds while providers without kind authority mark them unavailable.",
|
||||
@@ -271,12 +260,12 @@ export const OFFICIAL_TOOL_CONTRACTS = [
|
||||
official(
|
||||
"search_procedures",
|
||||
"Search analyzed procedure names using literal matching by default or regex opt-in. Providers bound search work and reject regex constructs, paths, candidates, or cumulative work outside their finite budgets. Results are deterministic and offset-paginated.",
|
||||
z.object(searchInput),
|
||||
z.object(analysisSearchInput),
|
||||
),
|
||||
official(
|
||||
"search_strings",
|
||||
"Search analyzed strings using literal matching by default or regex opt-in. Providers bound search work and reject regex constructs, paths, candidates, or cumulative work outside their finite budgets. Results are deterministic, offset-paginated, and explicitly truncated.",
|
||||
z.object(searchInput),
|
||||
z.object(analysisSearchInput),
|
||||
),
|
||||
official(
|
||||
"set_address_name",
|
||||
@@ -375,6 +364,16 @@ export const ENHANCED_TOOL_CONTRACTS = [
|
||||
"Trace a bounded literal feature query through matching strings and procedures, xrefs, and truthful containing-procedure resolution. Returns the operation budget, truncation, and residual unknowns; unknown_registry_approved: true records them durably without inferring reference kinds.",
|
||||
enhancedInputSchemas.trace_feature,
|
||||
),
|
||||
enhanced(
|
||||
"find_code_for_string",
|
||||
"Resolve one literal string query to bounded analyzed string entries, xrefs, and truthful containing-procedure candidates. Returns an Evidence ID, exact operation budget, truncation, and residual unknowns; it never infers reference kinds or runtime reachability.",
|
||||
enhancedInputSchemas.find_code_for_string,
|
||||
),
|
||||
enhanced(
|
||||
"trace_call_path",
|
||||
"Trace a deterministic bounded caller or callee path from one exact procedure address, optionally stopping at a goal. Returns visited nodes, direct-call edges, one shortest traversal path, failures, frontier, consumed limits, an Evidence ID, and explicit residual unknowns without claiming unresolved indirect calls are absent.",
|
||||
enhancedInputSchemas.trace_call_path,
|
||||
),
|
||||
] as const satisfies readonly ToolContract[];
|
||||
|
||||
/** Session-owned Evidence bundle export options. */
|
||||
@@ -521,8 +520,9 @@ export const TOOL_CONTRACTS = [
|
||||
...ARTIFACT_TOOL_CONTRACTS,
|
||||
...MANAGED_TOOL_CONTRACTS,
|
||||
...MANAGED_WORKFLOW_TOOL_CONTRACTS,
|
||||
...BROWSER_TOOL_CONTRACTS,
|
||||
...BROWSER_PROVIDER_TOOL_CONTRACTS,
|
||||
...ELECTRON_TOOL_CONTRACTS,
|
||||
...JAVASCRIPT_RUNTIME_OBSERVATION_TOOL_CONTRACTS,
|
||||
...APPLICATION_TOOL_CONTRACTS,
|
||||
...SESSION_TOOL_CONTRACTS,
|
||||
] as const;
|
||||
|
||||
@@ -61,6 +61,8 @@ export const TOOL_EFFECTS: Readonly<Record<string, ToolEffects>> = {
|
||||
procedure_callers: evidence,
|
||||
procedure_info: evidence,
|
||||
read_function_instructions: evidence,
|
||||
read_bytes: evidence,
|
||||
address_to_file_offset: evidence,
|
||||
procedure_references: evidence,
|
||||
procedure_pseudo_code: evidence,
|
||||
resolve_containing_procedure: evidence,
|
||||
@@ -88,12 +90,15 @@ export const TOOL_EFFECTS: Readonly<Record<string, ToolEffects>> = {
|
||||
binary_overview: evidence,
|
||||
analyze_function: evidence,
|
||||
trace_feature: effects({ mutatesSession: true, idempotent: false }),
|
||||
find_code_for_string: effects({ mutatesSession: true, idempotent: false }),
|
||||
trace_call_path: effects({ mutatesSession: true, idempotent: false }),
|
||||
inspect_macho: nativeEvidence,
|
||||
inspect_signature: nativeEvidence,
|
||||
inspect_plist: nativeEvidence,
|
||||
list_architectures: nativeEvidence,
|
||||
demangle_swift: nativeEvidence,
|
||||
inventory_artifact: evidence,
|
||||
inspect_artifact: evidence,
|
||||
extract_artifact: effects({ mutatesSession: true, writesFilesystem: true }),
|
||||
inspect_managed_artifact: evidence,
|
||||
inspect_managed_members: evidence,
|
||||
@@ -111,14 +116,29 @@ export const TOOL_EFFECTS: Readonly<Record<string, ToolEffects>> = {
|
||||
compare_web_captures: browserEvidence,
|
||||
capture_web_screenshot: browserEvidence,
|
||||
compare_web_screenshots: browserEvidence,
|
||||
capture_browser_scenario: effects({
|
||||
mutatesTarget: true,
|
||||
mutatesSession: true,
|
||||
writesFilesystem: true,
|
||||
launchesProcess: true,
|
||||
accessesNetwork: true,
|
||||
changesUiState: true,
|
||||
mayDiscardData: true,
|
||||
idempotent: false,
|
||||
}),
|
||||
list_electron_targets: browserEvidence,
|
||||
inspect_electron_page: browserEvidence,
|
||||
list_javascript_runtime_targets: browserEvidence,
|
||||
observe_javascript_runtime: browserEvidence,
|
||||
analyze_javascript_application: evidence,
|
||||
reconcile_javascript_runtime: evidence,
|
||||
trace_application_feature: evidence,
|
||||
trace_javascript_semantics: evidence,
|
||||
compare_application_versions: evidence,
|
||||
compare_source_to_bundle: evidence,
|
||||
compare_javascript_export_shapes: evidence,
|
||||
build_reconstruction_obligation_ledger: evidence,
|
||||
evaluate_reconstruction_readiness: evidence,
|
||||
run_replay_machine: effects(),
|
||||
run_controlled_replay: effects({
|
||||
mutatesSession: true,
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
artifactExtractionResultSchema,
|
||||
artifactInventoryResultSchema,
|
||||
} from "../domain/artifactGraph.js";
|
||||
import { artifactInspectionResultSchema } from "../domain/artifactInspection.js";
|
||||
import {
|
||||
managedArtifactInspectionSchema,
|
||||
managedMemberInspectionSchema,
|
||||
@@ -46,6 +47,7 @@ import {
|
||||
addressedEntry,
|
||||
bounded,
|
||||
containingProcedureResolution,
|
||||
clientFeatureAvailabilitySchema,
|
||||
functionDossierOutput,
|
||||
graphNode,
|
||||
lifecycleResultOf,
|
||||
@@ -87,6 +89,21 @@ export const officialOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
procedure_callers: resultOf(addressList),
|
||||
procedure_info: procedureInfoOutput,
|
||||
read_function_instructions: resultOf(functionInstructionWindowSchema),
|
||||
read_bytes: resultOf(
|
||||
z.object({
|
||||
address: z.string(),
|
||||
requested_bytes: z.number().int().min(1).max(4_096),
|
||||
returned_bytes: z.number().int().min(0).max(4_096),
|
||||
bytes_hex: z.string().regex(/^(?:[a-f0-9]{2})*$/u),
|
||||
complete: z.boolean(),
|
||||
}),
|
||||
),
|
||||
address_to_file_offset: resultOf(
|
||||
z.object({
|
||||
address: z.string(),
|
||||
file_offset: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
|
||||
}),
|
||||
),
|
||||
procedure_references: resultOf(
|
||||
z.object({
|
||||
procedure: procedureIdentity,
|
||||
@@ -118,6 +135,71 @@ export const officialOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
xrefs: resultOf(addressList),
|
||||
};
|
||||
|
||||
const literalTraceOutput = resultOf(
|
||||
z.object({
|
||||
query: z.string(),
|
||||
search_mode: z.literal("literal"),
|
||||
operations_used: z.number().int().min(0),
|
||||
operation_budget: z.number().int().min(1),
|
||||
matches: z.array(
|
||||
z.object({
|
||||
type: z.enum(["string", "procedure"]),
|
||||
address: z.string(),
|
||||
value: z.string(),
|
||||
}),
|
||||
),
|
||||
references: z.array(
|
||||
z.object({
|
||||
target_address: z.string(),
|
||||
source_address: z.string(),
|
||||
containing_procedure: containingProcedureResolution,
|
||||
}),
|
||||
),
|
||||
truncated: z.boolean(),
|
||||
residual_unknowns: z.array(z.string()),
|
||||
}),
|
||||
);
|
||||
|
||||
const callPathTraceOutput = resultOf(
|
||||
z.object({
|
||||
start: z.string(),
|
||||
goal: z.string().nullable(),
|
||||
direction: z.enum(["forward", "backward"]),
|
||||
goal_status: z.enum(["not_requested", "reached", "not_reached"]),
|
||||
nodes: z.array(
|
||||
z.object({
|
||||
address: z.string(),
|
||||
depth: z.number().int().min(0),
|
||||
}),
|
||||
),
|
||||
edges: z.array(
|
||||
z.object({
|
||||
source_address: z.string(),
|
||||
target_address: z.string(),
|
||||
discovery_depth: z.number().int().min(1),
|
||||
}),
|
||||
),
|
||||
traversal_path: z.array(z.string()),
|
||||
failures: z.array(
|
||||
z.object({
|
||||
address: z.string(),
|
||||
error: analysisErrorProjectionSchema,
|
||||
}),
|
||||
),
|
||||
frontier: z.array(z.string()),
|
||||
limits: z.object({
|
||||
max_depth: z.number().int().min(1),
|
||||
max_nodes: z.number().int().min(1),
|
||||
max_operations: z.number().int().min(1),
|
||||
nodes_visited: z.number().int().min(1),
|
||||
operations_used: z.number().int().min(0),
|
||||
}),
|
||||
truncated: z.boolean(),
|
||||
residual_unknowns: z.array(z.string()),
|
||||
limitations: z.array(z.string()),
|
||||
}),
|
||||
);
|
||||
|
||||
/** Exact structured-content schemas for composed analysis workflows. */
|
||||
export const enhancedOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
swift_classes: symbolDiscoveryOutput("classes"),
|
||||
@@ -190,30 +272,9 @@ export const enhancedOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
}),
|
||||
),
|
||||
analyze_function: functionDossierOutput,
|
||||
trace_feature: resultOf(
|
||||
z.object({
|
||||
query: z.string(),
|
||||
search_mode: z.literal("literal"),
|
||||
operations_used: z.number().int().min(0),
|
||||
operation_budget: z.number().int().min(1),
|
||||
matches: z.array(
|
||||
z.object({
|
||||
type: z.enum(["string", "procedure"]),
|
||||
address: z.string(),
|
||||
value: z.string(),
|
||||
}),
|
||||
),
|
||||
references: z.array(
|
||||
z.object({
|
||||
target_address: z.string(),
|
||||
source_address: z.string(),
|
||||
containing_procedure: containingProcedureResolution,
|
||||
}),
|
||||
),
|
||||
truncated: z.boolean(),
|
||||
residual_unknowns: z.array(z.string()),
|
||||
}),
|
||||
),
|
||||
trace_feature: literalTraceOutput,
|
||||
find_code_for_string: literalTraceOutput,
|
||||
trace_call_path: callPathTraceOutput,
|
||||
};
|
||||
|
||||
/** Exact Evidence v2 schemas for provider-neutral native inspection. */
|
||||
@@ -228,6 +289,7 @@ export const nativeOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
/** Exact Evidence v2 schemas for provider-neutral artifact graph operations. */
|
||||
export const artifactOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
inventory_artifact: resultOf(artifactInventoryResultSchema),
|
||||
inspect_artifact: resultOf(artifactInspectionResultSchema),
|
||||
extract_artifact: resultOf(artifactExtractionResultSchema),
|
||||
};
|
||||
|
||||
@@ -319,6 +381,7 @@ export const sessionOutputSchemas: Readonly<Record<string, z.ZodObject>> = {
|
||||
next_cursor: z.number().int().min(0).nullable(),
|
||||
has_more: z.boolean(),
|
||||
}),
|
||||
client_features: clientFeatureAvailabilitySchema,
|
||||
}),
|
||||
z.union([
|
||||
sessionProvider.extend({
|
||||
|
||||
@@ -207,12 +207,31 @@ const providerTargetSupport = z.discriminatedUnion("status", [
|
||||
}),
|
||||
]);
|
||||
|
||||
const clientFeatureNameSchema = z.enum([
|
||||
"elicitation_form",
|
||||
"elicitation_url",
|
||||
"roots",
|
||||
"sampling",
|
||||
]);
|
||||
|
||||
/** Negotiated MCP client features that affect REA workflow availability. */
|
||||
export const clientFeatureAvailabilitySchema = z.object({
|
||||
elicitation_form: z.boolean(),
|
||||
elicitation_url: z.boolean(),
|
||||
roots: z.boolean(),
|
||||
sampling: z.boolean(),
|
||||
});
|
||||
export type ClientFeatureAvailability = z.infer<
|
||||
typeof clientFeatureAvailabilitySchema
|
||||
>;
|
||||
|
||||
export const toolAvailability = z.object({
|
||||
name: z.string(),
|
||||
surface: z.string(),
|
||||
available: z.boolean(),
|
||||
reason: z.enum([
|
||||
"available",
|
||||
"client_capability_missing",
|
||||
"target_required",
|
||||
"provider_missing",
|
||||
"provider_unavailable",
|
||||
@@ -221,6 +240,12 @@ export const toolAvailability = z.object({
|
||||
"policy_disabled",
|
||||
]),
|
||||
remediation: z.string().nullable(),
|
||||
client_requirements: z.object({
|
||||
required: z.array(clientFeatureNameSchema),
|
||||
optional: z.array(clientFeatureNameSchema),
|
||||
missing_required: z.array(clientFeatureNameSchema),
|
||||
missing_optional: z.array(clientFeatureNameSchema),
|
||||
}),
|
||||
effects: z.strictObject({
|
||||
mutatesTarget: z.boolean(),
|
||||
mutatesSession: z.boolean(),
|
||||
|
||||
+9
-22
@@ -1,4 +1,10 @@
|
||||
import type { JsonValue } from "./jsonValue.js";
|
||||
import type {
|
||||
BrowserObservationFailureReason,
|
||||
BrowserObservationOperation,
|
||||
} from "./browserObservationErrors.js";
|
||||
|
||||
export type { BrowserObservationOperation } from "./browserObservationErrors.js";
|
||||
import type {
|
||||
MissingPermissionScope,
|
||||
PermissionRequest,
|
||||
@@ -258,34 +264,13 @@ export class ProviderAdapterError extends AnalysisError {
|
||||
}
|
||||
}
|
||||
|
||||
/** Public browser and Electron operations that can fail at a CDP boundary. */
|
||||
export type BrowserObservationOperation =
|
||||
| "list_browser_targets"
|
||||
| "inspect_web_page"
|
||||
| "analyze_web_bundle"
|
||||
| "observe_web_session"
|
||||
| "discover_webmcp_tools"
|
||||
| "compare_web_captures"
|
||||
| "capture_web_screenshot"
|
||||
| "compare_web_screenshots"
|
||||
| "list_electron_targets"
|
||||
| "inspect_electron_page";
|
||||
|
||||
/** A bounded passive browser observation failed at its CDP boundary. */
|
||||
export class BrowserObservationError extends AnalysisError {
|
||||
readonly _tag = "BrowserObservationError";
|
||||
|
||||
constructor(
|
||||
readonly operation: BrowserObservationOperation,
|
||||
readonly reason:
|
||||
| "endpoint_unreachable"
|
||||
| "invalid_endpoint_response"
|
||||
| "target_not_found"
|
||||
| "target_not_allowed"
|
||||
| "target_changed"
|
||||
| "protocol_error"
|
||||
| "disconnected"
|
||||
| "payload_limit",
|
||||
readonly reason: BrowserObservationFailureReason,
|
||||
options?: ErrorOptions,
|
||||
) {
|
||||
super(`Browser observation ${operation} failed: ${reason}`, options);
|
||||
@@ -299,6 +284,7 @@ export class ArtifactOperationError extends AnalysisError {
|
||||
constructor(
|
||||
readonly operation:
|
||||
| "inventory_artifact"
|
||||
| "inspect_artifact"
|
||||
| "extract_artifact"
|
||||
| "analyze_javascript_application",
|
||||
readonly reason:
|
||||
@@ -441,6 +427,7 @@ export type HopperDiagnosticType =
|
||||
| "remote"
|
||||
| "authorization"
|
||||
| "invalid_request"
|
||||
| "capability_unavailable"
|
||||
| "bridge_exception";
|
||||
|
||||
/** Hopper's JSON-RPC endpoint returned an expected remote error response. */
|
||||
|
||||
@@ -6,7 +6,9 @@ import { err, ok, type Result } from "./result.js";
|
||||
export type PermissionCapability =
|
||||
| "process_capture"
|
||||
| "browser_observe"
|
||||
| "browser_automate"
|
||||
| "electron_observe"
|
||||
| "v8_inspector_observe"
|
||||
| "evidence_read"
|
||||
| "evidence_write"
|
||||
| "investigation_input"
|
||||
|
||||
@@ -12,6 +12,8 @@ import { projectAnalysisError } from "./domain/errors.js";
|
||||
import { loadConfiguredPermissionAuthority } from "./application/PermissionConfiguration.js";
|
||||
import { CdpBrowserProvider } from "./browser/CdpBrowserProvider.js";
|
||||
import { CdpElectronProvider } from "./browser/CdpElectronProvider.js";
|
||||
import { V8InspectorProvider } from "./browser/V8InspectorProvider.js";
|
||||
import { PlaywrightBrowserScenarioProvider } from "./browser/PlaywrightBrowserScenarioProvider.js";
|
||||
import type { RuntimeDependencies } from "./main/types.js";
|
||||
import { SERVER_START_FAILED } from "./main/messages.js";
|
||||
import { createRuntimeState } from "./main/state.js";
|
||||
@@ -72,7 +74,9 @@ export const run = async (
|
||||
|
||||
const session = createBinarySession(config.value, logger);
|
||||
const browserObservation = new CdpBrowserProvider();
|
||||
const browserScenarioCapture = new PlaywrightBrowserScenarioProvider();
|
||||
const electronObservation = new CdpElectronProvider();
|
||||
const javascriptRuntimeObservation = new V8InspectorProvider();
|
||||
const opened = await openInitialTarget(
|
||||
session,
|
||||
config.value,
|
||||
@@ -85,7 +89,9 @@ export const run = async (
|
||||
logger,
|
||||
serverLogger,
|
||||
browserObservation,
|
||||
browserScenarioCapture,
|
||||
electronObservation,
|
||||
javascriptRuntimeObservation,
|
||||
permissionAuthority: permissionAuthority.value,
|
||||
runtimeState,
|
||||
});
|
||||
|
||||
+35
-31
@@ -3,6 +3,8 @@ import type { StdioServerHandle } from "@modelcontextprotocol/server/stdio";
|
||||
import type { BinarySession } from "../application/BinarySession.js";
|
||||
import type { CdpBrowserProvider } from "../browser/CdpBrowserProvider.js";
|
||||
import type { CdpElectronProvider } from "../browser/CdpElectronProvider.js";
|
||||
import type { V8InspectorProvider } from "../browser/V8InspectorProvider.js";
|
||||
import type { PlaywrightBrowserScenarioProvider } from "../browser/PlaywrightBrowserScenarioProvider.js";
|
||||
import type { PermissionAuthority } from "../application/PermissionAuthority.js";
|
||||
import type { Logger } from "../logger.js";
|
||||
import { createServer } from "../server/createServer.js";
|
||||
@@ -19,7 +21,9 @@ interface ServerContext {
|
||||
readonly logger: Logger;
|
||||
readonly serverLogger: Logger;
|
||||
readonly browserObservation: CdpBrowserProvider;
|
||||
readonly browserScenarioCapture: PlaywrightBrowserScenarioProvider;
|
||||
readonly electronObservation: CdpElectronProvider;
|
||||
readonly javascriptRuntimeObservation: V8InspectorProvider;
|
||||
readonly permissionAuthority: PermissionAuthority;
|
||||
readonly runtimeState: RuntimeState;
|
||||
}
|
||||
@@ -55,7 +59,10 @@ export const startMcpTransport = async (
|
||||
serverContext.runtimeState.snapshotPolicy,
|
||||
permissionAuthority: serverContext.permissionAuthority,
|
||||
browserObservation: serverContext.browserObservation,
|
||||
browserScenarioCapture: serverContext.browserScenarioCapture,
|
||||
electronObservation: serverContext.electronObservation,
|
||||
javascriptRuntimeObservation:
|
||||
serverContext.javascriptRuntimeObservation,
|
||||
artifactIntegrityContinueEnabled: () =>
|
||||
serverContext.runtimeState.currentConfig
|
||||
.artifactIntegrityContinueEnabled,
|
||||
@@ -63,37 +70,8 @@ export const startMcpTransport = async (
|
||||
serverContext.runtimeState.javascriptReplayPolicy,
|
||||
managedRuntimePolicy:
|
||||
serverContext.runtimeState.managedRuntimePolicy,
|
||||
availabilityPolicy: () => ({
|
||||
processCaptureEnabled:
|
||||
serverContext.runtimeState.currentConfig.processExecutionPolicy
|
||||
.enabled,
|
||||
evidenceFileRoots:
|
||||
serverContext.runtimeState.currentConfig.evidenceFilePolicy
|
||||
.roots.length,
|
||||
investigationInputRoots:
|
||||
serverContext.runtimeState.currentConfig.investigationInputRoots
|
||||
.length,
|
||||
browserObservationEnabled:
|
||||
serverContext.runtimeState.currentConfig
|
||||
.browserObservationEnabled &&
|
||||
serverContext.runtimeState.currentConfig.browserCdpEndpoints
|
||||
.length > 0 &&
|
||||
serverContext.runtimeState.currentConfig.browserAllowedOrigins
|
||||
.length > 0,
|
||||
electronObservationEnabled:
|
||||
serverContext.runtimeState.currentConfig
|
||||
.electronObservationEnabled &&
|
||||
serverContext.runtimeState.currentConfig.electronCdpEndpoints
|
||||
.length > 0 &&
|
||||
serverContext.runtimeState.currentConfig.electronFileRoots
|
||||
.length > 0,
|
||||
javascriptReplayEnabled:
|
||||
serverContext.runtimeState.currentConfig.javascriptReplayPolicy
|
||||
.enabled,
|
||||
managedRuntimeEnabled:
|
||||
serverContext.runtimeState.currentConfig.managedRuntimePolicy
|
||||
.enabled,
|
||||
}),
|
||||
availabilityPolicy: () =>
|
||||
runtimeAvailability(serverContext.runtimeState),
|
||||
},
|
||||
);
|
||||
liveServers.add(server);
|
||||
@@ -114,3 +92,29 @@ export const startMcpTransport = async (
|
||||
}
|
||||
return { ok: true, handle, liveServers };
|
||||
};
|
||||
|
||||
const runtimeAvailability = (state: RuntimeState) => ({
|
||||
processCaptureEnabled: state.currentConfig.processExecutionPolicy.enabled,
|
||||
evidenceFileRoots: state.currentConfig.evidenceFilePolicy.roots.length,
|
||||
investigationInputRoots: state.currentConfig.investigationInputRoots.length,
|
||||
browserObservationEnabled:
|
||||
state.currentConfig.browserObservationEnabled &&
|
||||
state.currentConfig.browserCdpEndpoints.length > 0 &&
|
||||
state.currentConfig.browserAllowedOrigins.length > 0,
|
||||
browserScenarioEnabled:
|
||||
state.currentConfig.browserScenarioPolicy.enabled &&
|
||||
state.currentConfig.browserScenarioPolicy.allowedOrigins.length > 0 &&
|
||||
(state.currentConfig.browserScenarioPolicy.executableRoots.length > 0 ||
|
||||
state.currentConfig.browserScenarioPolicy.cdpEndpoints.length > 0),
|
||||
electronObservationEnabled:
|
||||
state.currentConfig.electronObservationEnabled &&
|
||||
state.currentConfig.electronCdpEndpoints.length > 0 &&
|
||||
state.currentConfig.electronFileRoots.length > 0,
|
||||
v8InspectorObservationEnabled:
|
||||
state.currentConfig.v8InspectorObservationEnabled &&
|
||||
state.currentConfig.v8InspectorEndpoints.length > 0 &&
|
||||
(state.currentConfig.v8InspectorFileRoots.length > 0 ||
|
||||
state.currentConfig.v8InspectorAllowedOrigins.length > 0),
|
||||
javascriptReplayEnabled: state.currentConfig.javascriptReplayPolicy.enabled,
|
||||
managedRuntimeEnabled: state.currentConfig.managedRuntimePolicy.enabled,
|
||||
});
|
||||
|
||||
+28
-2
@@ -105,11 +105,16 @@ const inspectProductionMcpSession = async (
|
||||
client.listResources(undefined, request),
|
||||
client.listResourceTemplates(undefined, request),
|
||||
client.readResource({ uri: "rea://server/identity" }, request),
|
||||
client.callTool({ name: "binary_session", arguments: {} }, request),
|
||||
client.callTool(
|
||||
{ name: "binary_session", arguments: { detail: "full" } },
|
||||
request,
|
||||
),
|
||||
]);
|
||||
const expectedToolNames =
|
||||
availableToolNames(requestFlow.structuredContent) ?? [];
|
||||
const inventory = {
|
||||
tools: compareInventory(
|
||||
CATALOG_IDENTITY.tools.map(({ name }) => name),
|
||||
expectedToolNames,
|
||||
tools.tools.map(({ name }) => name),
|
||||
),
|
||||
prompts: compareInventory(
|
||||
@@ -177,6 +182,27 @@ const inspectProductionMcpSession = async (
|
||||
};
|
||||
};
|
||||
|
||||
const availableToolNames = (
|
||||
structuredContent: unknown,
|
||||
): readonly string[] | undefined => {
|
||||
if (typeof structuredContent !== "object" || structuredContent === null)
|
||||
return undefined;
|
||||
const result = Reflect.get(structuredContent, "result");
|
||||
if (typeof result !== "object" || result === null) return undefined;
|
||||
const availability = Reflect.get(result, "tool_availability");
|
||||
if (!Array.isArray(availability)) return undefined;
|
||||
const names: string[] = [];
|
||||
for (const item of availability) {
|
||||
if (typeof item !== "object" || item === null) return undefined;
|
||||
const name = Reflect.get(item, "name");
|
||||
const available = Reflect.get(item, "available");
|
||||
if (typeof name !== "string" || typeof available !== "boolean")
|
||||
return undefined;
|
||||
if (available) names.push(name);
|
||||
}
|
||||
return names;
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispatcher entry for `rea mcp doctor`, kept separate from Incur MCP setup.
|
||||
* @public
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
import type { McpServer, RegisteredTool } from "@modelcontextprotocol/server";
|
||||
|
||||
import {
|
||||
buildCapabilityInventory,
|
||||
type AvailabilityPolicy,
|
||||
} from "../application/CapabilityInventory.js";
|
||||
import type { BinarySessionPort } from "../application/BinarySession.js";
|
||||
import type { ClientFeatureAvailability } from "../contracts/toolOutputSchemaPrimitives.js";
|
||||
|
||||
interface ToolAvailabilityController {
|
||||
/** Apply current session, policy, host, provider, and client availability. */
|
||||
synchronize(): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Track public SDK tool handles and keep their visible state synchronized with
|
||||
* the same availability projection returned by `binary_session`.
|
||||
*/
|
||||
export const installDynamicToolAvailability = (
|
||||
server: McpServer,
|
||||
session: BinarySessionPort,
|
||||
policy: () => AvailabilityPolicy,
|
||||
): ToolAvailabilityController => {
|
||||
const tools = new Map<string, RegisteredTool>();
|
||||
const originalRegisterTool = server.registerTool.bind(server);
|
||||
const originalSendToolListChanged = server.sendToolListChanged.bind(server);
|
||||
let synchronizing = false;
|
||||
const controller: ToolAvailabilityController = {
|
||||
synchronize: () => {
|
||||
if (synchronizing) return false;
|
||||
synchronizing = true;
|
||||
try {
|
||||
const availability = new Map<string, boolean>(
|
||||
buildCapabilityInventory(
|
||||
session.status(),
|
||||
policy(),
|
||||
clientFeatures(server),
|
||||
).map((item) => [item.name, item.available]),
|
||||
);
|
||||
let changed = false;
|
||||
for (const [name, tool] of tools) {
|
||||
const enabled = availability.get(name) === true;
|
||||
if (tool.enabled === enabled) continue;
|
||||
changed = true;
|
||||
if (enabled) tool.enable();
|
||||
else tool.disable();
|
||||
}
|
||||
return changed;
|
||||
} finally {
|
||||
synchronizing = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const wrappedRegisterTool = (...args: unknown[]): unknown => {
|
||||
const name = args[0];
|
||||
if (typeof name !== "string")
|
||||
throw new TypeError("MCP tool registration requires a string name");
|
||||
const registered: unknown = Reflect.apply(
|
||||
originalRegisterTool,
|
||||
server,
|
||||
args,
|
||||
);
|
||||
if (!isRegisteredTool(registered))
|
||||
throw new TypeError(`MCP SDK did not return a tool handle for ${name}`);
|
||||
tools.set(name, registered);
|
||||
return registered;
|
||||
};
|
||||
if (!Reflect.set(server, "registerTool", wrappedRegisterTool))
|
||||
throw new TypeError("Unable to install dynamic MCP tool registration");
|
||||
if (
|
||||
!Reflect.set(server, "sendToolListChanged", () => {
|
||||
if (controller.synchronize()) originalSendToolListChanged();
|
||||
})
|
||||
)
|
||||
throw new TypeError("Unable to install dynamic MCP tool notifications");
|
||||
|
||||
return controller;
|
||||
};
|
||||
|
||||
const clientFeatures = (server: McpServer): ClientFeatureAvailability => {
|
||||
const capabilities = server.server.getClientCapabilities();
|
||||
return {
|
||||
elicitation_form: capabilities?.elicitation?.form !== undefined,
|
||||
elicitation_url: capabilities?.elicitation?.url !== undefined,
|
||||
roots: capabilities?.roots !== undefined,
|
||||
sampling: capabilities?.sampling !== undefined,
|
||||
};
|
||||
};
|
||||
|
||||
const isRegisteredTool = (value: unknown): value is RegisteredTool => {
|
||||
if (typeof value !== "object" || value === null) return false;
|
||||
return (
|
||||
typeof Reflect.get(value, "enabled") === "boolean" &&
|
||||
typeof Reflect.get(value, "enable") === "function" &&
|
||||
typeof Reflect.get(value, "disable") === "function"
|
||||
);
|
||||
};
|
||||
@@ -25,14 +25,24 @@ import { registerEvidenceResources } from "./registerEvidenceResources.js";
|
||||
import { createServerIdentity } from "../serverIdentity.js";
|
||||
import type { PermissionAuthority } from "../application/PermissionAuthority.js";
|
||||
import type { BrowserObservationPort } from "../application/BrowserObservationPort.js";
|
||||
import type { BrowserScenarioCapturePort } from "../application/BrowserScenarioCapturePort.js";
|
||||
import { registerBrowserTools } from "./registerBrowserTools.js";
|
||||
import { registerBrowserScenarioTool } from "./registerBrowserScenarioTool.js";
|
||||
import type { ElectronObservationPort } from "../application/ElectronObservationPort.js";
|
||||
import { registerElectronTools } from "./registerElectronTools.js";
|
||||
import type { JavaScriptRuntimeObservationPort } from "../application/JavaScriptRuntimeObservationPort.js";
|
||||
import { registerJavaScriptRuntimeObservationTools } from "./registerJavaScriptRuntimeObservationTools.js";
|
||||
import { registerApplicationTools } from "./registerApplicationTools.js";
|
||||
import type { SessionAvailability } from "./sessionAvailabilityPolicy.js";
|
||||
import { sessionAvailabilityPolicy } from "./sessionAvailabilityPolicy.js";
|
||||
import {
|
||||
DENY_EVIDENCE_FILE_POLICY,
|
||||
DENY_PROCESS_POLICY,
|
||||
} from "./sessionToolPolicies.js";
|
||||
import { installDynamicToolAvailability } from "./DynamicToolAvailability.js";
|
||||
|
||||
const TARGET_FREE_INSTRUCTIONS =
|
||||
"REA analyzes shipped artifacts. Route: ASAR/JavaScript -> analyze_javascript_application (configured root required); archive/package -> inventory_artifact; managed PE/CLI -> inspect_managed_artifact; browser/Electron runtime -> list_browser_targets/list_electron_targets; native binary/database -> open_binary, then binary_overview. Check binary_session for policy. Start with summaries and cite Evidence IDs. Never repeat identical analysis or read full Evidence without a specific need.";
|
||||
"REA analyzes shipped artifacts. Route: ASAR/JavaScript -> analyze_javascript_application (configured root); archive/package -> inspect_artifact; managed PE/CLI -> inspect_managed_artifact; passive browser/Electron -> list_browser_targets/list_electron_targets; approved browser interaction -> capture_browser_scenario; Node/Electron Inspector -> list_javascript_runtime_targets; native binary/database -> open_binary, then binary_overview. Check binary_session policy. Start with summaries and cite Evidence IDs. Never repeat identical analysis or read full Evidence without need.";
|
||||
|
||||
const ACTIVE_TARGET_INSTRUCTIONS =
|
||||
"REA analyzes the active reverse-engineering target. Start native analysis with binary_overview, then narrow with analyze_function, literal search, callers, callees, and xrefs. Prefer summary views, never repeat an identical call, and read full Evidence only when the task requires it.";
|
||||
@@ -57,7 +67,9 @@ export interface CreateServerOptions {
|
||||
readonly analysisSnapshotFilePolicy?: EvidenceFilePolicy;
|
||||
readonly permissionAuthority?: PermissionAuthority;
|
||||
readonly browserObservation?: BrowserObservationPort;
|
||||
readonly browserScenarioCapture?: BrowserScenarioCapturePort;
|
||||
readonly electronObservation?: ElectronObservationPort;
|
||||
readonly javascriptRuntimeObservation?: JavaScriptRuntimeObservationPort;
|
||||
readonly artifactIntegrityContinueEnabled?: () => boolean;
|
||||
readonly javascriptReplayPolicy?: JavaScriptReplayPolicy;
|
||||
readonly javascriptReplayHost?: JavaScriptReplayHost;
|
||||
@@ -66,6 +78,32 @@ export interface CreateServerOptions {
|
||||
readonly availabilityPolicy?: () => SessionAvailability;
|
||||
}
|
||||
|
||||
const installSessionToolAvailability = (
|
||||
server: McpServer,
|
||||
session: BinarySessionPort | undefined,
|
||||
options: CreateServerOptions,
|
||||
) => {
|
||||
if (session === undefined) return undefined;
|
||||
const policy = sessionAvailabilityPolicy(options.availabilityPolicy, {
|
||||
processPolicy: options.processPolicy ?? DENY_PROCESS_POLICY,
|
||||
evidenceFilePolicy: options.evidenceFilePolicy ?? DENY_EVIDENCE_FILE_POLICY,
|
||||
investigationInputRoots: options.investigationInputRoots ?? [],
|
||||
optionalFeatures: {
|
||||
browserObservationEnabled: options.browserObservation !== undefined,
|
||||
browserScenarioEnabled: options.browserScenarioCapture !== undefined,
|
||||
electronObservationEnabled: options.electronObservation !== undefined,
|
||||
v8InspectorObservationEnabled:
|
||||
options.javascriptRuntimeObservation !== undefined,
|
||||
javascriptReplayEnabled: options.javascriptReplayPolicy?.enabled ?? false,
|
||||
managedRuntimeEnabled: options.managedRuntimePolicy?.enabled ?? false,
|
||||
},
|
||||
});
|
||||
return {
|
||||
policy,
|
||||
controller: installDynamicToolAvailability(server, session, policy),
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Construct one MCP server without acquiring subprocess resources.
|
||||
* Supplying a session adds target lifecycle tools; omitting it retains the
|
||||
@@ -106,9 +144,12 @@ export const createServer = (
|
||||
: TARGET_FREE_INSTRUCTIONS,
|
||||
},
|
||||
);
|
||||
const dynamicTools = installSessionToolAvailability(server, session, options);
|
||||
server.server.onclose = () => {
|
||||
permissionAuthority?.clearSessionGrants();
|
||||
};
|
||||
if (dynamicTools !== undefined)
|
||||
server.server.oninitialized = () => server.sendToolListChanged();
|
||||
session?.onAvailabilityChanged?.(() => server.sendToolListChanged());
|
||||
registerServerIdentityResource(server, startedAt);
|
||||
const toolLogger = logger.child({ layer: "server" });
|
||||
@@ -132,6 +173,9 @@ export const createServer = (
|
||||
registerEvidenceResources(server, session);
|
||||
registerSessionTools(server, session, toolLogger, {
|
||||
...options,
|
||||
...(dynamicTools === undefined
|
||||
? {}
|
||||
: { availabilityPolicy: dynamicTools.policy }),
|
||||
...(permissionAuthority === undefined ? {} : { permissionAuthority }),
|
||||
startedAt,
|
||||
processCaptureElicitation: {
|
||||
@@ -155,6 +199,7 @@ export const createServer = (
|
||||
},
|
||||
});
|
||||
}
|
||||
dynamicTools?.controller.synchronize();
|
||||
return server;
|
||||
};
|
||||
|
||||
@@ -310,12 +355,24 @@ const registerObservationTools = ({
|
||||
permissionAuthority,
|
||||
recordEvidence,
|
||||
});
|
||||
registerBrowserScenarioTool(server, {
|
||||
logger,
|
||||
provider: options.browserScenarioCapture,
|
||||
permissionAuthority,
|
||||
recordEvidence,
|
||||
});
|
||||
registerElectronTools(server, {
|
||||
logger,
|
||||
electron: options.electronObservation,
|
||||
permissionAuthority,
|
||||
recordEvidence,
|
||||
});
|
||||
registerJavaScriptRuntimeObservationTools(server, {
|
||||
logger,
|
||||
runtime: options.javascriptRuntimeObservation,
|
||||
permissionAuthority,
|
||||
recordEvidence,
|
||||
});
|
||||
registerApplicationTools(server, {
|
||||
logger,
|
||||
recordEvidence,
|
||||
|
||||
@@ -3,10 +3,13 @@ import type { McpServer } from "@modelcontextprotocol/server";
|
||||
import { registerTraceFeatureTool } from "./registerApplicationTools/traceFeature.js";
|
||||
import { registerTraceJavaScriptSemanticsTool } from "./registerApplicationTools/traceSemantics.js";
|
||||
import { registerCompareApplicationVersionsTool } from "./registerApplicationTools/compareVersions.js";
|
||||
import { registerCompareSourceToBundleTool } from "./registerApplicationTools/compareSourceToBundle.js";
|
||||
import { registerCompareJavaScriptExportShapesTool } from "./registerApplicationTools/compareExportShapes.js";
|
||||
import { registerControlledReplayTool } from "./registerApplicationTools/controlledReplay.js";
|
||||
import { registerCharacterizationTools } from "./registerApplicationTools/characterization.js";
|
||||
import { registerCoverageTools } from "./registerApplicationTools/coverage.js";
|
||||
import { registerReconstructionObligationLedgerTool } from "./registerApplicationTools/obligationLedger.js";
|
||||
import { registerReconstructionReadinessTool } from "./registerApplicationTools/readiness.js";
|
||||
import type { ApplicationToolRegistration } from "./registerApplicationTools/types.js";
|
||||
|
||||
export type { ApplicationToolRegistration };
|
||||
@@ -19,8 +22,11 @@ export const registerApplicationTools = (
|
||||
registerTraceFeatureTool(server, options);
|
||||
registerTraceJavaScriptSemanticsTool(server, options);
|
||||
registerCompareApplicationVersionsTool(server, options);
|
||||
registerCompareSourceToBundleTool(server, options);
|
||||
registerCompareJavaScriptExportShapesTool(server, options);
|
||||
registerControlledReplayTool(server, options);
|
||||
registerCharacterizationTools(server, options);
|
||||
registerReconstructionObligationLedgerTool(server, options);
|
||||
registerReconstructionReadinessTool(server, options);
|
||||
registerCoverageTools(server, options);
|
||||
};
|
||||
|
||||
@@ -10,6 +10,8 @@ import canonicalize from "canonicalize";
|
||||
import type { BinarySessionPort } from "../application/BinarySessionPort.js";
|
||||
import type { JsonValue } from "../domain/jsonValue.js";
|
||||
import { registerJavaScriptApplicationGraphResource } from "./registerJavaScriptApplicationGraphResource.js";
|
||||
import { registerReconstructionObligationLedgerResource } from "./registerReconstructionObligationLedgerResource.js";
|
||||
import { registerReconstructionReadinessResource } from "./registerReconstructionReadinessResource.js";
|
||||
|
||||
const evidenceUri = (evidenceId: string): string =>
|
||||
`rea://evidence/${evidenceId}`;
|
||||
@@ -27,6 +29,8 @@ export const registerEvidenceResources = (
|
||||
registerArtifactPageResource(server, session);
|
||||
registerFunctionDossierResource(server, session);
|
||||
registerEvidenceSectionResource(server, session);
|
||||
registerReconstructionObligationLedgerResource(server, session);
|
||||
registerReconstructionReadinessResource(server, session);
|
||||
registerJavaScriptApplicationGraphResource(server, session);
|
||||
registerResidualUnknownResource(server, session);
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ import type {
|
||||
import type { BinarySessionPort } from "../application/BinarySession.js";
|
||||
import type { ToolContract } from "../contracts/toolContracts.js";
|
||||
import type { BinaryTarget } from "../domain/binaryTarget.js";
|
||||
import { createEvidence } from "../domain/evidence.js";
|
||||
import { createEvidence, type Evidence } from "../domain/evidence.js";
|
||||
import { jsonObjectSchema } from "../domain/jsonValue.js";
|
||||
import type { Logger } from "../logger.js";
|
||||
import { logToolExecution } from "./toolLogging.js";
|
||||
@@ -27,6 +27,10 @@ interface EvidenceToolRegistration {
|
||||
readonly activeTarget: (() => BinaryTarget | undefined) | undefined;
|
||||
readonly recordEvidence: BinarySessionPort["recordEvidence"] | undefined;
|
||||
readonly permissionAuthority?: PermissionAuthority;
|
||||
readonly sourceEvidence?: (
|
||||
operation: Exclude<AnalysisOperation, "health">,
|
||||
result: import("../domain/jsonValue.js").JsonValue,
|
||||
) => readonly Evidence[];
|
||||
}
|
||||
|
||||
/** Register provider-backed contracts that return atomic Evidence v2 observations. */
|
||||
@@ -92,6 +96,8 @@ export const registerEvidenceTools = (
|
||||
terminal: true,
|
||||
});
|
||||
if (!execution.ok) return toCallToolResult(execution, contract);
|
||||
const sourceEvidence =
|
||||
options.sourceEvidence?.(contract.name, execution.value.result) ?? [];
|
||||
const evidence = createEvidence(
|
||||
execution.value.subject ?? options.activeTarget?.(),
|
||||
execution.value.provider,
|
||||
@@ -102,8 +108,14 @@ export const registerEvidenceTools = (
|
||||
rawResult: execution.value.rawResult,
|
||||
limitations: execution.value.limitations,
|
||||
locations: execution.value.locations,
|
||||
evidenceLinks: sourceEvidence.map(({ evidence_id: id }) => id),
|
||||
},
|
||||
);
|
||||
for (const source of sourceEvidence) {
|
||||
const sourceRecorded = options.recordEvidence?.(source);
|
||||
if (sourceRecorded !== undefined && !sourceRecorded.ok)
|
||||
return toCallToolResult(sourceRecorded, contract);
|
||||
}
|
||||
const recorded = options.recordEvidence?.(evidence);
|
||||
return recorded !== undefined && !recorded.ok
|
||||
? toCallToolResult(recorded, contract)
|
||||
@@ -135,7 +147,7 @@ const permissionRequest = (
|
||||
operation_identity: `extract_artifact:${parameters.output_root}`,
|
||||
};
|
||||
if (
|
||||
operation === "inventory_artifact" &&
|
||||
["inventory_artifact", "inspect_artifact"].includes(operation) &&
|
||||
parameters.native_mount_approved === true
|
||||
)
|
||||
return {
|
||||
@@ -145,7 +157,7 @@ const permissionRequest = (
|
||||
environment_names: [],
|
||||
network: "none" as const,
|
||||
mount: true,
|
||||
operation_identity: "inventory_artifact:native_mount",
|
||||
operation_identity: `${operation}:native_mount`,
|
||||
};
|
||||
return undefined;
|
||||
};
|
||||
|
||||
@@ -10,6 +10,7 @@ import { toCallToolResult } from "./toolResult.js";
|
||||
import { jsonObjectSchema } from "../domain/jsonValue.js";
|
||||
import { createServerIdentity } from "../serverIdentity.js";
|
||||
import { buildCapabilityInventory } from "../application/CapabilityInventory.js";
|
||||
import type { ClientFeatureAvailability } from "../contracts/toolOutputSchemaPrimitives.js";
|
||||
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";
|
||||
import { safeParseToolInput } from "./toolInputValidation.js";
|
||||
import type { SessionAvailability } from "./sessionAvailabilityPolicy.js";
|
||||
@@ -44,11 +45,18 @@ export const registerSessionStatusTool = (
|
||||
const parsed = parsedInput.value;
|
||||
const client = server.server.getClientVersion();
|
||||
const clientCapabilities = server.server.getClientCapabilities();
|
||||
const clientFeatures: ClientFeatureAvailability = {
|
||||
elicitation_form: clientCapabilities?.elicitation?.form !== undefined,
|
||||
elicitation_url: clientCapabilities?.elicitation?.url !== undefined,
|
||||
roots: clientCapabilities?.roots !== undefined,
|
||||
sampling: clientCapabilities?.sampling !== undefined,
|
||||
};
|
||||
const status = session.status();
|
||||
const statusObject = jsonObjectSchema.parse(status);
|
||||
const toolAvailability = buildCapabilityInventory(
|
||||
status,
|
||||
availabilityPolicy(),
|
||||
clientFeatures,
|
||||
);
|
||||
const serverIdentity = createServerIdentity({
|
||||
startedAt,
|
||||
@@ -78,14 +86,7 @@ export const registerSessionStatusTool = (
|
||||
status: statusObject,
|
||||
toolAvailability,
|
||||
serverIdentity,
|
||||
clientFeatures: {
|
||||
elicitation_form:
|
||||
clientCapabilities?.elicitation?.form !== undefined,
|
||||
elicitation_url:
|
||||
clientCapabilities?.elicitation?.url !== undefined,
|
||||
roots: clientCapabilities?.roots !== undefined,
|
||||
sampling: clientCapabilities?.sampling !== undefined,
|
||||
},
|
||||
clientFeatures,
|
||||
}),
|
||||
},
|
||||
contract,
|
||||
@@ -101,7 +102,7 @@ const projectSessionStatus = (options: {
|
||||
>;
|
||||
readonly toolAvailability: readonly ToolAvailability[];
|
||||
readonly serverIdentity: ReturnType<typeof createServerIdentity>;
|
||||
readonly clientFeatures: Readonly<Record<string, boolean>>;
|
||||
readonly clientFeatures: ClientFeatureAvailability;
|
||||
}) => {
|
||||
if (options.input.detail === "full")
|
||||
return jsonObjectSchema.parse({
|
||||
@@ -139,6 +140,7 @@ const projectSessionStatus = (options: {
|
||||
next_cursor: nextCursor < filtered.length ? nextCursor : null,
|
||||
has_more: nextCursor < filtered.length,
|
||||
},
|
||||
client_features: options.clientFeatures,
|
||||
});
|
||||
}
|
||||
return jsonObjectSchema.parse({
|
||||
@@ -182,7 +184,7 @@ const recommendedActions = (
|
||||
: []),
|
||||
...(!open
|
||||
? [
|
||||
"Route the supplied target directly: ASAR/JavaScript to analyze_javascript_application, packages to inventory_artifact, managed PE/CLI to inspect_managed_artifact, browser/Electron runtimes to their list-target tools, and native binaries to open_binary.",
|
||||
"Route the supplied target directly: ASAR/JavaScript to analyze_javascript_application, unfamiliar packages to inspect_artifact, managed PE/CLI to inspect_managed_artifact, browser/Electron runtimes to their list-target tools, and native binaries to open_binary.",
|
||||
]
|
||||
: [
|
||||
"Continue from the active target with binary_overview or a bounded target-specific query.",
|
||||
|
||||
@@ -351,12 +351,11 @@ export const registerSessionTools = (
|
||||
contracts: [openContract, closeContract, statusContract],
|
||||
snapshotFilePolicy: analysisSnapshotFilePolicy,
|
||||
startedAt: options.startedAt ?? new Date().toISOString(),
|
||||
availabilityPolicy: sessionAvailabilityPolicy(
|
||||
options.availabilityPolicy,
|
||||
availabilityPolicy: sessionAvailabilityPolicy(options.availabilityPolicy, {
|
||||
processPolicy,
|
||||
evidenceFilePolicy,
|
||||
options.investigationInputRoots ?? [],
|
||||
),
|
||||
investigationInputRoots: options.investigationInputRoots ?? [],
|
||||
}),
|
||||
...(options.permissionAuthority === undefined
|
||||
? {}
|
||||
: { permissionAuthority: options.permissionAuthority }),
|
||||
|
||||
@@ -6,25 +6,48 @@ export interface SessionAvailability {
|
||||
readonly evidenceFileRoots: number;
|
||||
readonly investigationInputRoots: number;
|
||||
readonly browserObservationEnabled?: boolean;
|
||||
readonly browserScenarioEnabled?: boolean;
|
||||
readonly electronObservationEnabled?: boolean;
|
||||
readonly v8InspectorObservationEnabled?: boolean;
|
||||
readonly javascriptReplayEnabled?: boolean;
|
||||
readonly managedRuntimeEnabled?: boolean;
|
||||
}
|
||||
|
||||
export interface SessionAvailabilityDefaults {
|
||||
readonly processPolicy: ProcessExecutionPolicy;
|
||||
readonly evidenceFilePolicy: EvidenceFilePolicy;
|
||||
readonly investigationInputRoots: readonly string[];
|
||||
readonly optionalFeatures?: Pick<
|
||||
SessionAvailability,
|
||||
| "browserObservationEnabled"
|
||||
| "browserScenarioEnabled"
|
||||
| "electronObservationEnabled"
|
||||
| "v8InspectorObservationEnabled"
|
||||
| "javascriptReplayEnabled"
|
||||
| "managedRuntimeEnabled"
|
||||
>;
|
||||
}
|
||||
|
||||
/** Select configured availability reporting or the target-free defaults. */
|
||||
export const sessionAvailabilityPolicy = (
|
||||
configured: (() => SessionAvailability) | undefined,
|
||||
processPolicy: ProcessExecutionPolicy,
|
||||
evidenceFilePolicy: EvidenceFilePolicy,
|
||||
investigationInputRoots: readonly string[],
|
||||
defaults: SessionAvailabilityDefaults,
|
||||
): (() => SessionAvailability) =>
|
||||
configured ??
|
||||
(() => ({
|
||||
processCaptureEnabled: processPolicy.enabled,
|
||||
evidenceFileRoots: evidenceFilePolicy.roots.length,
|
||||
investigationInputRoots: investigationInputRoots.length,
|
||||
browserObservationEnabled: false,
|
||||
electronObservationEnabled: false,
|
||||
javascriptReplayEnabled: false,
|
||||
managedRuntimeEnabled: false,
|
||||
processCaptureEnabled: defaults.processPolicy.enabled,
|
||||
evidenceFileRoots: defaults.evidenceFilePolicy.roots.length,
|
||||
investigationInputRoots: defaults.investigationInputRoots.length,
|
||||
browserObservationEnabled:
|
||||
defaults.optionalFeatures?.browserObservationEnabled ?? false,
|
||||
browserScenarioEnabled:
|
||||
defaults.optionalFeatures?.browserScenarioEnabled ?? false,
|
||||
electronObservationEnabled:
|
||||
defaults.optionalFeatures?.electronObservationEnabled ?? false,
|
||||
v8InspectorObservationEnabled:
|
||||
defaults.optionalFeatures?.v8InspectorObservationEnabled ?? false,
|
||||
javascriptReplayEnabled:
|
||||
defaults.optionalFeatures?.javascriptReplayEnabled ?? false,
|
||||
managedRuntimeEnabled:
|
||||
defaults.optionalFeatures?.managedRuntimeEnabled ?? false,
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user