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:
@@ -4,7 +4,5 @@ export const MCP_CONNECTION_START_FAILED =
|
||||
"REA could not start its MCP connection. Restart REA from your MCP client; run `rea doctor` if it fails again.";
|
||||
export const MCP_SHUTDOWN_FAILED =
|
||||
"REA could not close cleanly. End the REA process before starting it again.";
|
||||
export const MCP_PERMISSION_RELOAD_FAILED =
|
||||
"Reloaded permission policy failed unexpectedly";
|
||||
export const SERVER_START_FAILED =
|
||||
"REA could not start. Run `rea doctor`, then restart REA from your MCP client.";
|
||||
|
||||
+3
-45
@@ -1,64 +1,22 @@
|
||||
import { parseConfig } from "../config.js";
|
||||
import { readProjectPermissionStore } from "../application/ProjectPermissionStore.js";
|
||||
import type { PermissionAuthority } from "../application/PermissionAuthority.js";
|
||||
import type { PermissionGrant } from "../domain/permissionPolicy.js";
|
||||
import type { Logger } from "../logger.js";
|
||||
import type { RuntimeDependencies } from "./types.js";
|
||||
import type { RuntimeState } from "./state.js";
|
||||
import { MCP_PERMISSION_RELOAD_FAILED } from "./messages.js";
|
||||
|
||||
export const registerConfigReload = (input: {
|
||||
readonly dependencies: RuntimeDependencies;
|
||||
readonly permissionAuthority: PermissionAuthority;
|
||||
readonly runtimeState: RuntimeState;
|
||||
readonly serverLogger: Logger;
|
||||
}): (() => void) => {
|
||||
const { dependencies, permissionAuthority, runtimeState, serverLogger } =
|
||||
input;
|
||||
let reloadQueue = Promise.resolve();
|
||||
const { dependencies, runtimeState, serverLogger } = input;
|
||||
return (
|
||||
dependencies.registerReload?.(() => {
|
||||
const refreshed = parseConfig(dependencies.env);
|
||||
if (!refreshed.ok) {
|
||||
serverLogger.error("Reloaded permission policy is invalid");
|
||||
serverLogger.error("Reloaded REA configuration is invalid");
|
||||
return;
|
||||
}
|
||||
reloadQueue = reloadQueue
|
||||
.then(async () => {
|
||||
let projectGrants: readonly PermissionGrant[] = [];
|
||||
if (
|
||||
refreshed.value.permissionProjectRoot !== undefined &&
|
||||
refreshed.value.permissionProjectStore !== undefined
|
||||
) {
|
||||
const project = await (
|
||||
dependencies.readProjectPermissionStore ??
|
||||
readProjectPermissionStore
|
||||
)(
|
||||
refreshed.value.permissionProjectStore,
|
||||
refreshed.value.permissionProjectRoot,
|
||||
);
|
||||
if (!project.ok) {
|
||||
serverLogger.error("Reloaded project grants could not be read");
|
||||
return;
|
||||
}
|
||||
projectGrants = project.value?.grants ?? [];
|
||||
}
|
||||
const reloaded = await permissionAuthority.replaceConfiguredPolicy({
|
||||
ceilings: refreshed.value.permissionCeilings,
|
||||
administratorGrants: refreshed.value.administratorPermissionGrants,
|
||||
projectGrants,
|
||||
});
|
||||
if (!reloaded.ok) {
|
||||
serverLogger.error(
|
||||
"Reloaded permission policy could not be applied",
|
||||
);
|
||||
return;
|
||||
}
|
||||
runtimeState.currentConfig = refreshed.value;
|
||||
})
|
||||
.catch(() => {
|
||||
serverLogger.error(MCP_PERMISSION_RELOAD_FAILED);
|
||||
});
|
||||
runtimeState.currentConfig = refreshed.value;
|
||||
}) ?? (() => undefined)
|
||||
);
|
||||
};
|
||||
|
||||
+2
-11
@@ -1,7 +1,6 @@
|
||||
import type { StdioServerHandle } from "@modelcontextprotocol/server/stdio";
|
||||
|
||||
import type { BinarySession } from "../application/BinarySession.js";
|
||||
import type { PermissionAuthority } from "../application/PermissionAuthority.js";
|
||||
import type { Logger } from "../logger.js";
|
||||
import type { RuntimeDependencies } from "./types.js";
|
||||
import { MCP_SHUTDOWN_FAILED } from "./messages.js";
|
||||
@@ -9,7 +8,6 @@ import { MCP_SHUTDOWN_FAILED } from "./messages.js";
|
||||
export const createShutdown = (input: {
|
||||
readonly handle: StdioServerHandle;
|
||||
readonly session: BinarySession;
|
||||
readonly permissionAuthority: PermissionAuthority;
|
||||
readonly unregisterReload: () => void;
|
||||
readonly dependencies: RuntimeDependencies;
|
||||
readonly serverLogger: Logger;
|
||||
@@ -17,14 +15,8 @@ export const createShutdown = (input: {
|
||||
readonly shutdown: () => Promise<void>;
|
||||
readonly request: () => void;
|
||||
} => {
|
||||
const {
|
||||
handle,
|
||||
session,
|
||||
permissionAuthority,
|
||||
unregisterReload,
|
||||
dependencies,
|
||||
serverLogger,
|
||||
} = input;
|
||||
const { handle, session, unregisterReload, dependencies, serverLogger } =
|
||||
input;
|
||||
let shutdownPromise: Promise<void> | undefined;
|
||||
let unregisterShutdown = (): void => undefined;
|
||||
const shutdown = async (): Promise<void> => {
|
||||
@@ -33,7 +25,6 @@ export const createShutdown = (input: {
|
||||
unregisterShutdown();
|
||||
await handle.close();
|
||||
await session.close({ retainProviderDocuments: true });
|
||||
permissionAuthority.clearSessionGrants();
|
||||
})();
|
||||
return shutdownPromise;
|
||||
};
|
||||
|
||||
+5
-32
@@ -1,7 +1,6 @@
|
||||
import type { StdioServerHandle } from "@modelcontextprotocol/server/stdio";
|
||||
|
||||
import type { BinarySession } from "../application/BinarySession.js";
|
||||
import type { PermissionAuthority } from "../application/PermissionAuthority.js";
|
||||
import type { Logger } from "../logger.js";
|
||||
import {
|
||||
createServer,
|
||||
@@ -28,7 +27,6 @@ interface ServerContext {
|
||||
readonly logger: Logger;
|
||||
readonly serverLogger: Logger;
|
||||
readonly loadOptionalProviders: () => Promise<OptionalProviders>;
|
||||
readonly permissionAuthority: PermissionAuthority;
|
||||
readonly runtimeState: RuntimeState;
|
||||
}
|
||||
|
||||
@@ -58,19 +56,13 @@ export const startMcpTransport = async (
|
||||
() =>
|
||||
(dependencies.createServer ?? createServer)(session, session, {
|
||||
logger: serverContext.logger,
|
||||
processPolicy: () =>
|
||||
serverContext.runtimeState.currentConfig.processExecutionPolicy,
|
||||
permissionAuthority: serverContext.permissionAuthority,
|
||||
...optionalProviders,
|
||||
artifactIntegrityContinueEnabled: () =>
|
||||
javascriptReplayConfiguration: () =>
|
||||
serverContext.runtimeState.currentConfig
|
||||
.artifactIntegrityContinueEnabled,
|
||||
javascriptReplayPolicy: () =>
|
||||
serverContext.runtimeState.currentConfig.javascriptReplayPolicy,
|
||||
managedRuntimePolicy: () =>
|
||||
serverContext.runtimeState.currentConfig.managedRuntimePolicy,
|
||||
availabilityPolicy: () =>
|
||||
runtimeAvailability(serverContext.runtimeState),
|
||||
.javascriptReplayConfiguration,
|
||||
managedRuntimeConfiguration: () =>
|
||||
serverContext.runtimeState.currentConfig
|
||||
.managedRuntimeConfiguration,
|
||||
}),
|
||||
{
|
||||
onerror: () => {
|
||||
@@ -87,22 +79,3 @@ export const startMcpTransport = async (
|
||||
}
|
||||
return { ok: true, handle };
|
||||
};
|
||||
|
||||
const runtimeAvailability = (state: RuntimeState) => ({
|
||||
processCaptureEnabled:
|
||||
state.currentConfig.processExecutionPolicy.status === "enabled",
|
||||
browserObservationEnabled:
|
||||
state.currentConfig.browserObservationPolicy.status === "enabled",
|
||||
browserScenarioEnabled:
|
||||
state.currentConfig.browserScenarioPolicy.status === "enabled",
|
||||
electronObservationEnabled:
|
||||
state.currentConfig.electronObservationPolicy.status === "enabled",
|
||||
electronAutomationEnabled:
|
||||
state.currentConfig.electronAutomationPolicy.status === "enabled",
|
||||
v8InspectorObservationEnabled:
|
||||
state.currentConfig.v8InspectorObservationPolicy.status === "enabled",
|
||||
javascriptReplayEnabled:
|
||||
state.currentConfig.javascriptReplayPolicy.status === "enabled",
|
||||
managedRuntimeEnabled:
|
||||
state.currentConfig.managedRuntimePolicy.status === "enabled",
|
||||
});
|
||||
|
||||
@@ -9,5 +9,4 @@ export interface RuntimeDependencies {
|
||||
readonly loadOptionalProviders?: () => Promise<
|
||||
import("./transport.js").OptionalProviders
|
||||
>;
|
||||
readonly readProjectPermissionStore?: typeof import("../application/ProjectPermissionStore.js").readProjectPermissionStore;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user