mirror of
https://github.com/morluto/rea.git
synced 2026-11-15 19:23:24 +00:00
refactor(setup): require the platform in client-layer readers and private-profile helpers (#11074)
* refactor(setup): require the platform in client-layer readers and private-profile helpers * refactor(setup): drop the client-layer readers' unused host import
This commit is contained in:
1 parent
ce9bdc526a
commit
97ffa67f84
7 files changed
+23
-17
No files matched your search
@@ -293,7 +293,6 @@
|
||||
"src/application/Doctor.ts": 1,
|
||||
"src/application/DshCordisPatch.ts": 2,
|
||||
"src/application/JsonFiles.ts": 1,
|
||||
"src/application/McpClientRegistration.ts": 3,
|
||||
"src/application/SetupHost.ts": 1,
|
||||
"src/application/SupportedClients.ts": 2,
|
||||
"src/application/Uninstall.ts": 1,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { HOST_PLATFORM } from "../platform/HostPlatform.js";
|
||||
import { err, ok, type Result } from "../domain/result.js";
|
||||
import { RegularFileCleanupFailure } from "../filesystem/OwnedRegularFile.js";
|
||||
import { readRegularFileText } from "./RegularFileRead.js";
|
||||
@@ -295,7 +294,7 @@ export const inlineRegistrationOverride = (
|
||||
client: Pick<SetupClient, "configPath" | "configPaths">,
|
||||
sources: readonly ClientConfigurationSource[],
|
||||
desired: unknown,
|
||||
platform: NodeJS.Platform = HOST_PLATFORM.platform,
|
||||
platform: NodeJS.Platform,
|
||||
): ClientInlineConfiguration["origin"] | undefined => {
|
||||
const name = PRODUCT_IDENTITY.mcpServerKey;
|
||||
const inline = sources.filter(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { HOST_PLATFORM } from "../platform/HostPlatform.js";
|
||||
import { constants } from "node:fs";
|
||||
import { lstat, open, realpath, stat } from "node:fs/promises";
|
||||
import { dirname } from "node:path";
|
||||
@@ -41,7 +40,7 @@ export type PrivateProfilePermissions =
|
||||
*/
|
||||
export const privateProfileModesCurrent = async (
|
||||
configPath: string,
|
||||
platform: NodeJS.Platform = HOST_PLATFORM.platform,
|
||||
platform: NodeJS.Platform,
|
||||
): Promise<boolean> => {
|
||||
if (platform === "win32") return true;
|
||||
// Setup and `rea mcp add` publish a linked profile at its canonical path,
|
||||
@@ -136,9 +135,11 @@ export const securePrivateDirectory = async (
|
||||
return changed;
|
||||
};
|
||||
|
||||
/** Mode requests cannot establish Windows ACL privacy on this host. */
|
||||
export const privateProfilePermissions = (): PrivateProfilePermissions =>
|
||||
HOST_PLATFORM.platform === "win32"
|
||||
/** Mode requests cannot establish Windows ACL privacy on `platform`. */
|
||||
export const privateProfilePermissions = (
|
||||
platform: NodeJS.Platform,
|
||||
): PrivateProfilePermissions =>
|
||||
platform === "win32"
|
||||
? {
|
||||
kind: "requested_windows_modes",
|
||||
requestedDirectoryMode: PRIVATE_PROFILE_MODES.directory,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { RegularFileCleanupFailure } from "../filesystem/OwnedRegularFile.js";
|
||||
import { HOST_PLATFORM } from "../platform/HostPlatform.js";
|
||||
import { readClientPolicyBlock } from "./GeminiClientSettings.js";
|
||||
import {
|
||||
inlineRegistrationOrigins,
|
||||
@@ -165,7 +166,7 @@ export const readClientRegistrationInspections = async (
|
||||
const inspections: ClientRegistrationInspection[] = [];
|
||||
for (const client of await resolveSupportedClients(
|
||||
home,
|
||||
options.platform,
|
||||
options.platform ?? HOST_PLATFORM.platform,
|
||||
options.environment,
|
||||
options.systemPaths,
|
||||
)) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { mkdir } from "node:fs/promises";
|
||||
import { HOST_PLATFORM } from "../platform/HostPlatform.js";
|
||||
import { dirname } from "node:path";
|
||||
|
||||
import { AnalysisCleanupLeaseGroup } from "../artifacts/AnalysisCleanupLease.js";
|
||||
@@ -174,7 +175,10 @@ export const registerMcpClient = async (
|
||||
: {}),
|
||||
});
|
||||
checkCancellation();
|
||||
if (client.privateProfile !== undefined && process.platform !== "win32")
|
||||
if (
|
||||
client.privateProfile !== undefined &&
|
||||
HOST_PLATFORM.platform !== "win32"
|
||||
)
|
||||
await securePrivateDirectory(
|
||||
dirname(path),
|
||||
client.privateProfile.home,
|
||||
@@ -202,7 +206,7 @@ export const registerMcpClient = async (
|
||||
status: "configured",
|
||||
...(backupPath === undefined ? {} : { backupPath }),
|
||||
...(client.privateProfile !== undefined
|
||||
? { permissions: privateProfilePermissions() }
|
||||
? { permissions: privateProfilePermissions(HOST_PLATFORM.platform) }
|
||||
: {}),
|
||||
});
|
||||
});
|
||||
@@ -268,7 +272,7 @@ const unchangedRegistration = async (
|
||||
parsed.requiresRewrite === true ||
|
||||
!clientConfigurationValuesEqual(parsed.document, updated) ||
|
||||
(client.privateProfile !== undefined &&
|
||||
process.platform !== "win32" &&
|
||||
HOST_PLATFORM.platform !== "win32" &&
|
||||
((snapshot?.state.mode ?? 0) & 0o777) !== PRIVATE_PROFILE_MODES.file)
|
||||
)
|
||||
return undefined;
|
||||
@@ -284,7 +288,7 @@ const unchangedRegistration = async (
|
||||
checkCancellation();
|
||||
await verifyEffectiveRegistration(prepared, current.text);
|
||||
const permissionsChanged =
|
||||
client.privateProfile !== undefined && process.platform !== "win32"
|
||||
client.privateProfile !== undefined && HOST_PLATFORM.platform !== "win32"
|
||||
? await securePrivateDirectory(
|
||||
dirname(path),
|
||||
client.privateProfile.home,
|
||||
@@ -295,7 +299,7 @@ const unchangedRegistration = async (
|
||||
return {
|
||||
status: permissionsChanged ? "configured" : "unchanged",
|
||||
...(client.privateProfile !== undefined
|
||||
? { permissions: privateProfilePermissions() }
|
||||
? { permissions: privateProfilePermissions(HOST_PLATFORM.platform) }
|
||||
: {}),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1269,7 +1269,10 @@ const privateProfileCurrent = async (
|
||||
): Promise<boolean> =>
|
||||
client.privateProfile === undefined ||
|
||||
(original !== undefined &&
|
||||
(await privateProfileModesCurrent(client.configPath)));
|
||||
(await privateProfileModesCurrent(
|
||||
client.configPath,
|
||||
HOST_PLATFORM.platform,
|
||||
)));
|
||||
|
||||
const clientConfigurationDesired = async (
|
||||
client: SetupClient,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { HOST_PLATFORM } from "../platform/HostPlatform.js";
|
||||
import type {
|
||||
ClientRegistrationConnectionProfile,
|
||||
ClientRegistrationProfile,
|
||||
@@ -2104,7 +2103,7 @@ export const supportedClients = (
|
||||
*/
|
||||
export const resolveSupportedClients = async (
|
||||
home: string,
|
||||
platform: NodeJS.Platform = HOST_PLATFORM.platform,
|
||||
platform: NodeJS.Platform,
|
||||
env: ClientPathContext["env"] = process.env,
|
||||
systemPaths: ClientSystemPaths = {},
|
||||
): Promise<readonly SetupClient[]> => {
|
||||
|
||||
Reference in new issue
Block a user