feat(setup)!: expand agent integrations and verify updates (#577)
* feat(setup)!: expand agent integrations and simplify onboarding Add native configuration formats for OpenCode, Antigravity, GitHub Copilot CLI, VS Code, and Devin. Preserve JSONC comments and unrelated settings while making setup and uninstall ownership-aware and idempotent. Select agent targets before planning, separate discovery from intent, and keep agent-only setup independent of optional provider prerequisites. Cover configuration boundaries and interactive behavior in packaged checks. BREAKING CHANGE: unscoped setup refreshes only existing REA-owned registrations. Use --all-detected to configure every detected client. Setup JSON contains a compact doctor summary; use rea doctor for full diagnostics. Cancellation and successful dry runs now exit successfully. * feat(cli)!: replace upgrade with verified updates Resolve an exact release through npm's configured registry, update only the identified installation, and verify its new executable before reporting success. Return a read-only maintenance plan for existing enabled REA integrations. BREAKING CHANGE: replace rea upgrade with rea update; no alias is retained. Successful update JSON uses status "updated", reports the verified installed version, and returns an unapplied maintenance plan instead of opening setup.
This commit is contained in:
+321
-104
@@ -8,6 +8,7 @@ import {
|
||||
runDoctor,
|
||||
systemDoctorHost,
|
||||
type DoctorHost,
|
||||
type DoctorReport,
|
||||
type DoctorScope,
|
||||
} from "./Doctor.js";
|
||||
import {
|
||||
@@ -23,9 +24,10 @@ import {
|
||||
canonicalSkillNeedsInstall,
|
||||
installCanonicalSkill,
|
||||
} from "./SetupSkill.js";
|
||||
import { discoverSetupActions } from "./SetupPlan.js";
|
||||
import { discoverSetupState, planSetupActions } from "./SetupPlan.js";
|
||||
import {
|
||||
clientConfigurationAligned,
|
||||
configureClientConfiguration,
|
||||
configureJsonClient,
|
||||
configureTomlClient,
|
||||
inspectClientConfiguration,
|
||||
@@ -44,10 +46,20 @@ export type SetupProviderEnvironment = Readonly<Record<string, string>>;
|
||||
|
||||
export { canonicalSkillNeedsInstall, installCanonicalSkill };
|
||||
|
||||
const registrationCommand = (): readonly string[] =>
|
||||
process.env.npm_command === "exec"
|
||||
/** Resolve the executable and arguments used in a managed MCP registration. */
|
||||
export const setupRegistrationCommand = (
|
||||
platform: NodeJS.Platform,
|
||||
useNpmRunner: boolean = process.env.npm_command === "exec",
|
||||
): readonly string[] =>
|
||||
useNpmRunner
|
||||
? PRODUCT_IDENTITY.mcpCommand.split(" ")
|
||||
: [resolve(process.argv[1] ?? PRODUCT_IDENTITY.cliBinary), "mcp"];
|
||||
: platform === "win32"
|
||||
? [
|
||||
process.execPath,
|
||||
resolve(process.argv[1] ?? PRODUCT_IDENTITY.cliBinary),
|
||||
"mcp",
|
||||
]
|
||||
: [resolve(process.argv[1] ?? PRODUCT_IDENTITY.cliBinary), "mcp"];
|
||||
|
||||
/** Result of one backup/write/readback transaction. */
|
||||
export type ClientConfigurationResult =
|
||||
@@ -81,6 +93,7 @@ export interface SetupHost {
|
||||
installHopper(replaceExisting: boolean): Promise<SetupHopperInstallResult>;
|
||||
providerEnvironment?(): Promise<SetupProviderEnvironment>;
|
||||
detectedClients(): Promise<readonly SetupClient[]>;
|
||||
supportedClients?(): Promise<readonly SetupClient[]>;
|
||||
configureClient(
|
||||
client: SetupClient,
|
||||
providerEnvironment: SetupProviderEnvironment,
|
||||
@@ -102,15 +115,44 @@ export interface SetupHost {
|
||||
}
|
||||
/** Structured setup outcome carrying remediation instead of prompting. */
|
||||
export interface SetupResult {
|
||||
readonly status: "planned" | "needs_confirmation" | "ready" | "needs_human";
|
||||
readonly status:
|
||||
| "planned"
|
||||
| "cancelled"
|
||||
| "needs_confirmation"
|
||||
| "ready"
|
||||
| "needs_human";
|
||||
readonly plannedActions: readonly SetupAction[];
|
||||
readonly appliedActions: readonly string[];
|
||||
readonly clients: Readonly<Record<string, ClientConfigurationResult>>;
|
||||
readonly doctor: Awaited<ReturnType<typeof runDoctor>>;
|
||||
readonly doctor: SetupDoctorSummary;
|
||||
/** Supported-client discovery state captured before setup mutations. */
|
||||
readonly clientStates: readonly SetupClientState[];
|
||||
readonly remediation?: string;
|
||||
readonly code?: SetupFailureCode;
|
||||
}
|
||||
|
||||
/** Relevant health and identity evidence for the selected setup scope. */
|
||||
export interface SetupDoctorSummary {
|
||||
readonly healthy: boolean;
|
||||
readonly environment_healthy: boolean;
|
||||
readonly scope: DoctorReport["scope"];
|
||||
readonly hopperPath?: string;
|
||||
readonly availableProviders: readonly string[];
|
||||
readonly providerInspections?: DoctorReport["providerInspections"];
|
||||
readonly identity?: Pick<
|
||||
NonNullable<DoctorReport["identity"]>,
|
||||
"skill" | "registrations"
|
||||
>;
|
||||
}
|
||||
|
||||
/** Read-only state for one supported client location. */
|
||||
export interface SetupClientState {
|
||||
readonly client: SetupClient;
|
||||
readonly detected: boolean;
|
||||
readonly configured: boolean;
|
||||
readonly status: "configured" | "missing" | "needs_configuration" | "invalid";
|
||||
}
|
||||
|
||||
/** One concrete setup mutation disclosed before approval. */
|
||||
export interface SetupAction {
|
||||
readonly id: string;
|
||||
@@ -135,6 +177,8 @@ export interface SetupOptions {
|
||||
readonly clientIds?: readonly string[];
|
||||
readonly installSkill?: boolean;
|
||||
readonly readinessScope?: DoctorScope;
|
||||
readonly dryRun?: boolean;
|
||||
readonly allDetectedClients?: boolean;
|
||||
readonly onProgress?: (event: SetupProgressEvent) => void;
|
||||
}
|
||||
|
||||
@@ -150,11 +194,21 @@ export interface SetupProgressEvent {
|
||||
export interface SetupConfirmationDecision {
|
||||
readonly approved: boolean;
|
||||
readonly selectedActionIds: readonly string[];
|
||||
readonly cancelled?: boolean;
|
||||
}
|
||||
|
||||
/** Adapter-owned interactive confirmation for a fully discovered setup plan. */
|
||||
/** Read-only context shown while selecting clients or reviewing exact actions. */
|
||||
export interface SetupConfirmationContext {
|
||||
readonly stage: "select" | "confirm";
|
||||
readonly clientStates: readonly SetupClientState[];
|
||||
readonly selectedClientIds: readonly string[];
|
||||
readonly clientSelectionAllowed: boolean;
|
||||
}
|
||||
|
||||
/** Adapter-owned selection and confirmation for the setup workflow. */
|
||||
export type SetupConfirmation = (
|
||||
actions: readonly SetupAction[],
|
||||
context?: SetupConfirmationContext,
|
||||
) => Promise<boolean | SetupConfirmationDecision>;
|
||||
|
||||
/** Discover, approve, and apply setup actions idempotently. */
|
||||
@@ -166,44 +220,179 @@ export const runSetup = async (
|
||||
const appliedActions: string[] = [];
|
||||
let plannedActions: readonly SetupAction[] = [];
|
||||
const clients: Record<string, ClientConfigurationResult> = {};
|
||||
let clientStates: readonly SetupClientState[] = [];
|
||||
let readinessScope = options.readinessScope;
|
||||
const fail = (remediation: string) =>
|
||||
setupFailure(
|
||||
remediation,
|
||||
[host, plannedActions, appliedActions, clients],
|
||||
options.readinessScope,
|
||||
[host, plannedActions, appliedActions, clients, clientStates],
|
||||
readinessScope,
|
||||
);
|
||||
const unsupported = await hostRemediation(host, options.installHopper);
|
||||
const unsupported = await hostRemediation(host, false);
|
||||
if (unsupported !== undefined) return fail(unsupported);
|
||||
let hopperPath = await host.hopperPath();
|
||||
let providerEnvironment = await initialProviderEnvironment(host, hopperPath);
|
||||
const discovery = await discoverSetupActions({
|
||||
const discovery = await discoverSetupState({
|
||||
host,
|
||||
providerEnvironment,
|
||||
command: registrationCommand(),
|
||||
forceHopperInstall: options.installHopper,
|
||||
proposeHopper: options.proposeHopper ?? true,
|
||||
selectedClientIds: options.clientIds,
|
||||
installSkillSelection: options.installSkill,
|
||||
proposeHopper:
|
||||
options.proposeHopper ?? (confirm !== undefined && !options.structured),
|
||||
doctorScope: options.readinessScope,
|
||||
});
|
||||
if (discovery.blocker !== undefined) return fail(discovery.blocker);
|
||||
const selection = await resolveSetupSelection(options, discovery, confirm);
|
||||
plannedActions = selection.plannedActions;
|
||||
if (!selection.approved)
|
||||
clientStates = discovery.clientStates;
|
||||
const clientSelectionAllowed =
|
||||
options.clientIds === undefined &&
|
||||
options.readinessScope?.clients === undefined &&
|
||||
options.allDetectedClients !== true &&
|
||||
options.installHopper !== true &&
|
||||
options.installSkill === undefined;
|
||||
const interactiveSelection =
|
||||
confirm !== undefined && !options.structured && clientSelectionAllowed;
|
||||
let selectedClientIds = options.allDetectedClients
|
||||
? discovery.detectedClientIds
|
||||
: (options.clientIds ??
|
||||
options.readinessScope?.clients ??
|
||||
discovery.defaultClientIds);
|
||||
let skillSelected =
|
||||
options.installSkill === true ||
|
||||
(options.installSkill !== false && selectedClientIds.length > 0);
|
||||
let installSkill = skillSelected && discovery.skillNeedsInstall;
|
||||
let planDiscovery = discovery;
|
||||
if (interactiveSelection) {
|
||||
const offerSkillAction =
|
||||
options.installSkill !== false && discovery.skillNeedsInstall;
|
||||
const selectionActions = await planSetupActions({
|
||||
discovery,
|
||||
host,
|
||||
providerEnvironment,
|
||||
command: setupRegistrationCommand(host.platform),
|
||||
clientIds: [],
|
||||
installSkill: offerSkillAction,
|
||||
});
|
||||
const decision = await confirm(selectionActions.plannedActions, {
|
||||
stage: "select",
|
||||
clientStates,
|
||||
selectedClientIds: discovery.defaultClientIds,
|
||||
clientSelectionAllowed,
|
||||
});
|
||||
if (isSetupDecisionCancelled(decision))
|
||||
return setupCancelled(
|
||||
selectionActions.plannedActions,
|
||||
clients,
|
||||
clientStates,
|
||||
discovery.initialDoctor,
|
||||
);
|
||||
const selectedActionIds = new Set(
|
||||
typeof decision === "boolean"
|
||||
? decision
|
||||
? [
|
||||
...selectionActions.plannedActions.map(({ id }) => id),
|
||||
...discovery.defaultClientIds.map(
|
||||
(id) => `configure_client:${id}`,
|
||||
),
|
||||
]
|
||||
: []
|
||||
: decision.selectedActionIds,
|
||||
);
|
||||
selectedClientIds = [...selectedActionIds]
|
||||
.filter((id) => id.startsWith("configure_client:"))
|
||||
.map((id) => id.slice("configure_client:".length));
|
||||
const proposedInstallAction = selectionActions.plannedActions.some(
|
||||
({ id }) => id === "install_hopper",
|
||||
);
|
||||
planDiscovery = {
|
||||
...discovery,
|
||||
installHopper:
|
||||
options.installHopper ||
|
||||
(proposedInstallAction && selectedActionIds.has("install_hopper")),
|
||||
};
|
||||
skillSelected =
|
||||
options.installSkill === true ||
|
||||
(selectedActionIds.has("install_skill") &&
|
||||
selectedClientIds.length === 0) ||
|
||||
(options.installSkill !== false && selectedClientIds.length > 0);
|
||||
installSkill = skillSelected && discovery.skillNeedsInstall;
|
||||
}
|
||||
const planned = await planSetupActions({
|
||||
discovery: planDiscovery,
|
||||
host,
|
||||
providerEnvironment,
|
||||
command: setupRegistrationCommand(host.platform),
|
||||
clientIds: selectedClientIds,
|
||||
installSkill,
|
||||
});
|
||||
plannedActions = planned.plannedActions;
|
||||
if (planned.blocker !== undefined) return fail(planned.blocker);
|
||||
const hopperBlocker = await hostRemediation(
|
||||
host,
|
||||
planDiscovery.installHopper,
|
||||
);
|
||||
if (hopperBlocker !== undefined) return fail(hopperBlocker);
|
||||
const planSelection = {
|
||||
installHopper: planDiscovery.installHopper,
|
||||
installSkill,
|
||||
skillSelected,
|
||||
selectedClients: planned.selectedClients,
|
||||
clientsToConfigure: planned.clientsToConfigure,
|
||||
};
|
||||
readinessScope = resolvedReadinessScope(
|
||||
options.readinessScope,
|
||||
planSelection,
|
||||
);
|
||||
|
||||
if (options.dryRun === true)
|
||||
return {
|
||||
status: confirm === undefined ? "needs_confirmation" : "planned",
|
||||
status: "planned",
|
||||
plannedActions,
|
||||
appliedActions,
|
||||
clients,
|
||||
doctor: discovery.initialDoctor,
|
||||
remediation:
|
||||
"Review the setup plan, then rerun interactively or with --yes.",
|
||||
doctor: summarizeDoctor(discovery.initialDoctor),
|
||||
clientStates,
|
||||
};
|
||||
|
||||
let detectedClients: readonly SetupClient[] = selection.detectedClients;
|
||||
let approved = options.approved || plannedActions.length === 0;
|
||||
let interactiveApproval = false;
|
||||
if (!approved && confirm !== undefined && !options.structured) {
|
||||
const decision = await confirm?.(plannedActions, {
|
||||
stage: "confirm",
|
||||
clientStates,
|
||||
selectedClientIds,
|
||||
clientSelectionAllowed: false,
|
||||
});
|
||||
if (decision !== undefined) {
|
||||
if (isSetupDecisionCancelled(decision))
|
||||
return setupCancelled(
|
||||
plannedActions,
|
||||
clients,
|
||||
clientStates,
|
||||
discovery.initialDoctor,
|
||||
);
|
||||
approved = typeof decision === "boolean" ? decision : decision.approved;
|
||||
interactiveApproval = approved;
|
||||
}
|
||||
}
|
||||
if (!approved)
|
||||
return {
|
||||
status: confirm === undefined ? "needs_confirmation" : "cancelled",
|
||||
plannedActions,
|
||||
appliedActions,
|
||||
clients,
|
||||
doctor: summarizeDoctor(discovery.initialDoctor),
|
||||
clientStates,
|
||||
...(confirm === undefined
|
||||
? {
|
||||
remediation:
|
||||
"Review the setup plan, then rerun interactively or with --yes.",
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
|
||||
let selectedClients: readonly SetupClient[] =
|
||||
planSelection.clientsToConfigure;
|
||||
if (
|
||||
selection.installHopper &&
|
||||
(selection.interactiveApproval || options.installHopper)
|
||||
planSelection.installHopper &&
|
||||
(interactiveApproval || options.installHopper)
|
||||
) {
|
||||
const install = await installHopperAction({
|
||||
host,
|
||||
@@ -211,18 +400,19 @@ export const runSetup = async (
|
||||
plannedActions,
|
||||
appliedActions,
|
||||
clients,
|
||||
detectedClients,
|
||||
selectedClients,
|
||||
providerEnvironment,
|
||||
doctorScope: options.readinessScope,
|
||||
doctorScope: readinessScope,
|
||||
clientStates,
|
||||
});
|
||||
if ("failure" in install) return install.failure;
|
||||
({ hopperPath, providerEnvironment, detectedClients } = install);
|
||||
({ hopperPath, providerEnvironment, selectedClients } = install);
|
||||
}
|
||||
const clientFailure = await configureDetectedClients({
|
||||
host,
|
||||
detectedClients,
|
||||
detectedClients: selectedClients,
|
||||
providerEnvironment,
|
||||
command: registrationCommand(),
|
||||
command: setupRegistrationCommand(host.platform),
|
||||
clients,
|
||||
appliedActions,
|
||||
...(options.onProgress === undefined
|
||||
@@ -231,13 +421,13 @@ export const runSetup = async (
|
||||
});
|
||||
if (clientFailure !== undefined) return fail(clientFailure);
|
||||
if (
|
||||
selection.installSkill &&
|
||||
planSelection.installSkill &&
|
||||
!(await installSkillAction(host, options, appliedActions))
|
||||
)
|
||||
return fail(
|
||||
"REA analysis skill could not be installed or verified. Check permissions for `~/.agents/skills`, then rerun setup.",
|
||||
);
|
||||
const doctor = await host.doctor(options.readinessScope);
|
||||
const doctor = summarizeDoctor(await host.doctor(readinessScope));
|
||||
const remediation = finalSetupRemediation(
|
||||
host.platform,
|
||||
appliedActions.includes("installed_hopper"),
|
||||
@@ -250,59 +440,21 @@ export const runSetup = async (
|
||||
appliedActions,
|
||||
clients,
|
||||
doctor,
|
||||
clientStates,
|
||||
...(remediation === undefined ? {} : { remediation }),
|
||||
};
|
||||
};
|
||||
|
||||
const resolveSetupSelection = async (
|
||||
options: SetupOptions,
|
||||
discovery: Awaited<ReturnType<typeof discoverSetupActions>>,
|
||||
confirm: SetupConfirmation | undefined,
|
||||
) => {
|
||||
let { installHopper, installSkill, detectedClients, plannedActions } =
|
||||
discovery;
|
||||
let approved = options.approved || plannedActions.length === 0;
|
||||
let interactiveApproval = false;
|
||||
if (!approved && confirm !== undefined && !options.structured) {
|
||||
const decision = await confirm(plannedActions);
|
||||
if (typeof decision === "boolean") {
|
||||
interactiveApproval = decision;
|
||||
approved = decision;
|
||||
} else {
|
||||
const selected = new Set(decision.selectedActionIds);
|
||||
plannedActions = plannedActions.filter(({ id }) => selected.has(id));
|
||||
installHopper = plannedActions.some(
|
||||
({ kind }) => kind === "install_hopper",
|
||||
);
|
||||
installSkill = plannedActions.some(
|
||||
({ kind }) => kind === "install_skill",
|
||||
);
|
||||
detectedClients = detectedClients.filter((client) =>
|
||||
selected.has(`configure_client:${client.name}`),
|
||||
);
|
||||
interactiveApproval = decision.approved;
|
||||
approved = decision.approved;
|
||||
}
|
||||
}
|
||||
return {
|
||||
approved,
|
||||
interactiveApproval,
|
||||
installHopper,
|
||||
installSkill,
|
||||
detectedClients,
|
||||
plannedActions,
|
||||
};
|
||||
};
|
||||
|
||||
const installHopperAction = async (input: {
|
||||
readonly host: SetupHost;
|
||||
readonly options: SetupOptions;
|
||||
readonly plannedActions: readonly SetupAction[];
|
||||
readonly appliedActions: string[];
|
||||
readonly clients: Readonly<Record<string, ClientConfigurationResult>>;
|
||||
readonly detectedClients: readonly SetupClient[];
|
||||
readonly selectedClients: readonly SetupClient[];
|
||||
readonly providerEnvironment: SetupProviderEnvironment;
|
||||
readonly doctorScope: DoctorScope | undefined;
|
||||
readonly clientStates: readonly SetupClientState[];
|
||||
}) => {
|
||||
const label = "Hopper deep-analysis provider";
|
||||
emitProgress(input.options, {
|
||||
@@ -324,7 +476,8 @@ const installHopperAction = async (input: {
|
||||
plannedActions: input.plannedActions,
|
||||
appliedActions: input.appliedActions,
|
||||
clients: input.clients,
|
||||
doctor: await input.host.doctor(input.doctorScope),
|
||||
doctor: summarizeDoctor(await input.host.doctor(input.doctorScope)),
|
||||
clientStates: input.clientStates,
|
||||
code: installed.code,
|
||||
remediation: installed.remediation,
|
||||
},
|
||||
@@ -344,11 +497,11 @@ const installHopperAction = async (input: {
|
||||
return {
|
||||
hopperPath: installed.launcherPath,
|
||||
providerEnvironment,
|
||||
detectedClients: await filterClientsNeedingConfigure(
|
||||
selectedClients: await filterClientsNeedingConfigure(
|
||||
input.host,
|
||||
input.detectedClients,
|
||||
input.selectedClients,
|
||||
providerEnvironment,
|
||||
registrationCommand(),
|
||||
setupRegistrationCommand(input.host.platform),
|
||||
),
|
||||
};
|
||||
};
|
||||
@@ -385,21 +538,25 @@ const installSkillAction = async (
|
||||
|
||||
const setupFailure = async (
|
||||
remediation: string,
|
||||
[host, plannedActions, appliedActions, clients]: readonly [
|
||||
[host, plannedActions, appliedActions, clients, clientStates]: readonly [
|
||||
SetupHost,
|
||||
readonly SetupAction[],
|
||||
readonly string[],
|
||||
Readonly<Record<string, ClientConfigurationResult>>,
|
||||
readonly SetupClientState[],
|
||||
],
|
||||
scope?: DoctorScope,
|
||||
): Promise<SetupResult> => ({
|
||||
status: "needs_human",
|
||||
plannedActions,
|
||||
appliedActions,
|
||||
clients,
|
||||
doctor: await host.doctor(scope),
|
||||
remediation,
|
||||
});
|
||||
): Promise<SetupResult> => {
|
||||
return {
|
||||
status: "needs_human",
|
||||
plannedActions,
|
||||
appliedActions,
|
||||
clients,
|
||||
doctor: summarizeDoctor(await host.doctor(scope)),
|
||||
clientStates,
|
||||
remediation,
|
||||
};
|
||||
};
|
||||
|
||||
const emitProgress = (options: SetupOptions, event: SetupProgressEvent): void =>
|
||||
options.onProgress?.(event);
|
||||
@@ -440,14 +597,78 @@ const finalSetupRemediation = (
|
||||
: "Run rea doctor and apply each reported remediation.";
|
||||
};
|
||||
|
||||
const isSetupDecisionCancelled = (
|
||||
decision: boolean | SetupConfirmationDecision,
|
||||
): boolean =>
|
||||
typeof decision === "boolean" ? !decision : decision.cancelled === true;
|
||||
|
||||
const setupCancelled = (
|
||||
plannedActions: readonly SetupAction[],
|
||||
clients: Readonly<Record<string, ClientConfigurationResult>>,
|
||||
clientStates: readonly SetupClientState[],
|
||||
doctor: DoctorReport,
|
||||
): SetupResult => ({
|
||||
status: "cancelled",
|
||||
plannedActions,
|
||||
appliedActions: [],
|
||||
clients,
|
||||
doctor: summarizeDoctor(doctor),
|
||||
clientStates,
|
||||
});
|
||||
|
||||
const resolvedReadinessScope = (
|
||||
requested: DoctorScope | undefined,
|
||||
selection: {
|
||||
readonly selectedClients: readonly SetupClient[];
|
||||
readonly installHopper: boolean;
|
||||
readonly skillSelected?: boolean;
|
||||
},
|
||||
): DoctorScope => ({
|
||||
clients: selection.selectedClients.map(({ name }) => name),
|
||||
providers: selection.installHopper
|
||||
? ["hopper"]
|
||||
: (requested?.providers ?? []),
|
||||
skill: selection.skillSelected === true || requested?.skill === true,
|
||||
});
|
||||
|
||||
const summarizeDoctor = (report: DoctorReport): SetupDoctorSummary => ({
|
||||
healthy: report.healthy,
|
||||
environment_healthy: report.environment_healthy,
|
||||
scope: report.scope,
|
||||
availableProviders: [
|
||||
...(report.hopperPath !== undefined &&
|
||||
report.checks
|
||||
.filter(({ name }) => name.startsWith("hopper"))
|
||||
.every(({ ok }) => ok)
|
||||
? ["hopper"]
|
||||
: []),
|
||||
...(report.providerInspections ?? [])
|
||||
.filter(({ available }) => available)
|
||||
.map(({ id }) => id),
|
||||
],
|
||||
...(report.hopperPath === undefined ? {} : { hopperPath: report.hopperPath }),
|
||||
...(report.providerInspections === undefined
|
||||
? {}
|
||||
: { providerInspections: report.providerInspections }),
|
||||
...(report.identity === undefined
|
||||
? {}
|
||||
: {
|
||||
identity: {
|
||||
skill: report.identity.skill,
|
||||
registrations: report.identity.registrations,
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
const hostRemediation = async (
|
||||
host: SetupHost,
|
||||
forceHopperInstall: boolean,
|
||||
installHopper: boolean,
|
||||
): Promise<string | undefined> => {
|
||||
if (host.platform !== "darwin" && host.platform !== "linux")
|
||||
return "REA supports Hopper on macOS and selected 64-bit Linux distributions.";
|
||||
if (!supportsNodeVersion(host.nodeVersion))
|
||||
return "Install Node.js 22.19+ or 24.11+ and rerun setup.";
|
||||
if (!installHopper) return undefined;
|
||||
if (host.platform !== "darwin" && host.platform !== "linux")
|
||||
return "REA supports Hopper on macOS and selected 64-bit Linux distributions.";
|
||||
if (host.platform === "darwin") {
|
||||
const version = await host.macosVersion();
|
||||
return version === undefined || major(version) < 12
|
||||
@@ -455,13 +676,6 @@ const hostRemediation = async (
|
||||
: undefined;
|
||||
}
|
||||
if ((await host.linuxDistribution())?.supported === true) return undefined;
|
||||
const providerEnvironment = await host.providerEnvironment?.();
|
||||
if (
|
||||
!forceHopperInstall &&
|
||||
providerEnvironment !== undefined &&
|
||||
Object.keys(providerEnvironment).length > 0
|
||||
)
|
||||
return undefined;
|
||||
return "Automated Hopper setup supports Ubuntu 24.04+, Fedora 41+, and 64-bit Arch Linux; configure an existing supported provider instead.";
|
||||
};
|
||||
|
||||
@@ -493,12 +707,11 @@ export const systemSetupHost = (
|
||||
return setupInstallFailure(result.reason);
|
||||
},
|
||||
detectedClients: () => detectClients(homedir()),
|
||||
supportedClients: () => Promise.resolve(supportedClients(homedir())),
|
||||
configureClient: (client, providerEnvironment, command) =>
|
||||
client.format === "unsupported"
|
||||
? Promise.resolve({ status: "skipped" })
|
||||
: client.format === "toml"
|
||||
? configureTomlClient(client, providerEnvironment, command)
|
||||
: configureJsonClient(client, providerEnvironment, command),
|
||||
: configureClientConfiguration(client, providerEnvironment, command),
|
||||
clientNeedsConfigure: (client, providerEnvironment, command) =>
|
||||
clientConfigurationAligned(client, providerEnvironment, command).then(
|
||||
(aligned) => !aligned,
|
||||
@@ -510,14 +723,18 @@ export const systemSetupHost = (
|
||||
};
|
||||
};
|
||||
|
||||
/** Detect supported agents from stable per-user installation markers. */
|
||||
/** Detect supported agents from their config files or stable installation markers. */
|
||||
export const detectClients = async (
|
||||
home: string,
|
||||
): Promise<readonly SetupClient[]> => {
|
||||
const detected: SetupClient[] = [];
|
||||
for (const candidate of supportedClients(home))
|
||||
if (await exists(candidate.markerPath ?? candidate.configPath))
|
||||
detected.push(candidate);
|
||||
for (const candidate of supportedClients(home)) {
|
||||
const [hasConfig, hasMarker] = await Promise.all([
|
||||
exists(candidate.configPath),
|
||||
candidate.markerPath === undefined ? false : exists(candidate.markerPath),
|
||||
]);
|
||||
if (hasConfig || hasMarker) detected.push(candidate);
|
||||
}
|
||||
return detected;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user