mirror of
https://github.com/morluto/rea.git
synced 2026-11-12 09:52:27 +00:00
* docs(desktop): clarify gzip scrub limits * fix(setup): own desktop build process cleanup * fix(doctor): compare desktop settings with resolved defaults * fix(desktop): refuse a build runtime whose export takes no task ends Several tasks pass --task-end to the build computer's export, so a runtime packed before it now fails at the start of the capture with the repack fix, as a runtime without synthetic seeds already did, rather than at export. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * style(desktop): format the noisy-record draft files with the pinned oxfmt Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(desktop): give the root-array draft test its own describe The records describe grew past the 150-line lint limit with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(doctor): inspect client-recorded desktop runners * fix(doctor): reuse matching runner probes * fix(setup): propagate cancellation to desktop actions * fix(desktop): rewrite a download's launch keys written with spaces around = The desktop entry parser accepts `Exec = notes %F` and an indented `TryExec =notes`, so the install script now matches those keys the same way instead of leaving the original program in place. Adds the feature's tasks.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(desktop): keep why a measured run failed in its solve record A solve that returned an outcome dropped the runner's error, so a run that failed to deploy, solve or verify was retried with no reason recorded. The record, the measure result and difficulty.json now carry it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(setup): stop Hopper on cancel, never report a cancelled setup ready, and keep a failed action's client setting - The Hopper install gets setup's signal: Linux already honoured it, and the macOS installer now stops its downloads and stops before mounting or copying. - runSetup checks the signal after the final doctor and close, so a cancellation there raises instead of returning ready. - A failed pack or agentenv install no longer writes its archive or runner to client configs, so the setting the client already had stays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(setup): keep the completed setup result in a cancellation after cleanup A cancellation during the final doctor or host close carried only the applied actions, dropping each client's result and backup path and the doctor report. It now carries the whole result as setup_result, as doctor's cancellation carries its report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(desktop): move launch execution to boundary suite * fix(desktop): redact build schema failure output * refactor(desktop): normalize schema failure once * fix(desktop): omit unsafe schema parser snippets * fix(desktop): preserve draft change and selected path evidence * test(desktop): group retained dconf note regressions * fix(desktop): respect archive entry format in draft checks * test(desktop): separate unowned-file draft note cases * fix(desktop): preserve explicitly selected journal documents * fix(xml): avoid scanning selected ancestors per tag * fix(desktop): exclude covered text runs from draft counts * fix: preserve text when drafting desktop checks * fix: restore nested desktop state aliases * refactor: share UUID recognition across draft checks * fix: retain multiline XML attribute context * fix: retain relationship identifiers in task drafts * docs: clarify desktop draft identifier handling * test(desktop): type formatting run cases as pairs * fix(desktop): carry document format into selector evaluation * test(desktop): separate markup boundary regression group * fix(desktop): propagate formats through draft selectors * fix(desktop): switch selector format within archive entries * test(desktop): remove duplicate seed filename case * fix(setup): retain diagnostics when cancellation overlaps failure * refactor(setup): keep command cancellation at its owner * test(setup): verify cancellation at the application boundary * test(desktop): pass JSON format in exported index parity * docs(desktop): clarify task checks before scratch export * fix(desktop): respell selected paths in file URLs * test(desktop): group captured document spelling cases * test(desktop): run installer scripts at boundary * style(desktop): remove trailing blank line * fix(desktop): bound draft preview serialization * fix(desktop): restore selected state aliases * fix(desktop): respect entry format in draft noise * test(desktop): match exported alias evidence at its JSON boundary * fix(desktop): retain app state logs in exported seeds * fix: align desktop numeric seed comparisons * test(desktop): keep one draft exclusion fixture import * test(desktop): retain log eligibility across draft test groups * fix(doctor): resolve empty registered desktop runner * style: fix desktop launch test formatting * style: format native command path schema * fix(desktop): map selected external launch paths * style(desktop): format seed document regressions * test(desktop): group launch URL regressions * fix(desktop): omit redundant nested state aliases * fix(desktop): compare added free text as a whole * fix(desktop): check recompressed seeds as shipped * docs(desktop): clarify recovered seed format * test(desktop): group shipped gzip seed checks * fix: retain quoted identifier text in task drafts * fix: recognize Unicode XML in desktop state readers * fix(desktop): bound nested draft checks * fix(desktop): explain missing arrays in truncated views * fix(desktop): find XML type references in archives * test(desktop): remove duplicated capture assertions * fix(desktop): retain nested omitted text boundaries * style(desktop): format draft value imports * test(desktop): group model and draft value checks * fix(desktop): map captured launch paths once * refactor: remove unused whole-text guard state * refactor: stop passing unused text children * test: align free-text checks with whole-note policy * fix: validate recompressed desktop archive seeds * style(desktop): format archive seed regression * fix(desktop): retain placed-item sibling guards * fix(desktop): preserve archive paths and bound doctor reads * fix(doctor): refuse non-files before descriptor admission * fix(setup): track remaining cleanup resources across retries * test(desktop): specify XML format in heap pairing fixture * fix(setup): skip Hopper launch after cancelled copy * fix: preserve task measurement limits and cleanup * fix(desktop): retain reported solve sandbox cleanup * test(desktop): check retained log seed admission * fix(doctor): query agentenv for model endpoint * fix(doctor): preserve uncertainty for empty endpoint override * fix(desktop): redact runtime schema errors * fix(desktop): normalize captured file URLs * fix(desktop): report seeded files by capture path * fix(desktop): retain startup readiness failure stage * fix(desktop): retain JSON date checks * fix(desktop): preserve archive formatting checks * fix(desktop): preserve explicitly selected journal files * fix(desktop): report build command transport limits * docs(desktop): clarify unreadable dconf versions * test(desktop): remove duplicate history regression * fix(desktop): align XML names with exported reader * fix(desktop): create selected state alias targets * fix(desktop): inspect supported runtime archives * fix(desktop): keep ordinary text checks exact * fix(desktop): verify registered build host paths * fix(desktop): retain record identity in draft checks * test(desktop): preserve text reference numbers * fix(desktop): bound download install input reads * fix(desktop): match placed notes by whole text * test(desktop): match multiple task export results * fix(desktop): retain failed measurement file closes * fix(setup): retain completed actions on cancellation * test(setup): retain cancelled installer result * fix(desktop): scrub XML independently of reader compatibility * fix(desktop): preserve file aliases and reader diagnostics * style(desktop): format review fixes * fix(desktop): inspect archives with registered runner * test(desktop): verify registered archive interpreter * style(desktop): format capture review fixes * style(desktop): format review changes * feat(desktop): target agentenv-framework 0.9.1464 Desktop bundles, setup's --install-agentenv and the doctor's exact-version check now target 0.9.1464, which keeps an exported app's data/get call, holds the computer fixture above boot dialogs, leaves an unresolved setting's build unverified rather than failed, and mounts lock packages instead of copying them into the image. The web environment lane stays on 0.9.1431. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(desktop): retain per-solve sandbox cleanup roots * test(desktop): expect the solve cleanup helper among the shipped agentenv helpers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(desktop): clean up a stopped solve's sandboxes through agentenv 0.9.1482 agentenv-framework 0.9.1482 lists the local sandboxes under a root (local_sandbox_ids) and rebuilds one killed while it wrote its port map for teardown. The solve cleanup helper now terminates each sandbox agentenv lists, keeping its Docker and host-process checks, and reports anything else left under the root. Desktop bundles, setup's --install-agentenv and the doctor's version check target 0.9.1482. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(desktop): verify a killed solve's cleanup once its sandbox root is empty A solve's sandboxes are all local under its private root, and agentenv now keeps a sandbox's folder until its teardown is confirmed. So when the helper ends without a report and REA's cleanup empties that root, the cleanup is verified: a cancelled solve ends as a cancellation and a solve past its deadline as a failed run, rather than as cleanup the measure cannot vouch for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(desktop): target agentenv-framework 0.9.1485 0.9.1485 keeps a local sandbox's folder until its teardown is confirmed, which the solve cleanup's verified result relies on. (0.9.1484 failed to publish.) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(desktop): record a solve stopped before it reports as failed, not as a refused request A helper killed from outside or stopped at its deadline left no report, so the measure refused with invalid input and told the caller to fix its model endpoint. A helper a signal ended now gives a failed solve of unknown cost, which the measure records and stops on; one that exits on its own without a report still ends the measure as a solve that could not run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(desktop): check verifier behavior after selector changes * test(windows): verify rejected writes during cleanup by effect * fix(desktop): preserve selected alias target kinds in exports * fix(cli): retain caller capture paths in environment builds * fix(ghidra): classify oversized endpoint records consistently * test: align model and Evidence expectations with current contracts * fix(desktop): reconcile upstream sandbox cleanup recovery * fix(docs): link cleanup qualification as repository evidence --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
465 lines
17 KiB
TypeScript
465 lines
17 KiB
TypeScript
import { DESKTOP_EXPORT_FRAMEWORK_VERSION } from "../domain/desktop/appExport.js";
|
|
import type { execFileOutput } from "../process/ExecFileOutput.js";
|
|
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
|
|
import type { ClientRegistrationStatus } from "./ClientRegistrationStatus.js";
|
|
import type { DoctorCheck, DoctorHost, DoctorSkillState } from "./Doctor.js";
|
|
import { nodeCheck } from "./DoctorDiagnostics.js";
|
|
import { DESKTOP_BUILD_PROVIDER_ID } from "./DoctorProviderIds.js";
|
|
import type { DoctorScopeReport } from "./DoctorScope.js";
|
|
|
|
/** Free space agentenv's images need where Docker keeps them. */
|
|
export const DESKTOP_BUILD_MIN_FREE_BYTES = 20 * 1000 ** 3;
|
|
|
|
/** The command that installs the agentenv-framework release bundles target. */
|
|
export const AGENTENV_INSTALL_COMMAND = `uv tool install agentenv-framework==${DESKTOP_EXPORT_FRAMEWORK_VERSION}`;
|
|
|
|
/** How a build setting's program was found: set in the environment, or on PATH. */
|
|
export type DesktopBuildCommand =
|
|
| {
|
|
readonly status: "found";
|
|
readonly path: string;
|
|
readonly source: "environment" | "path";
|
|
}
|
|
| { readonly status: "missing" }
|
|
| { readonly status: "invalid"; readonly value: string };
|
|
|
|
/** What a desktop build host has, read without changing anything. */
|
|
export interface DesktopBuildFacts {
|
|
readonly ps: { readonly found: boolean; readonly detail: string };
|
|
readonly docker: DesktopBuildCommand;
|
|
readonly daemon:
|
|
| { readonly status: "reachable"; readonly rootDirectory: string }
|
|
| {
|
|
readonly status: "permission_denied" | "unreachable";
|
|
readonly detail: string;
|
|
}
|
|
| { readonly status: "unchecked" };
|
|
readonly disk:
|
|
| { readonly path: string; readonly freeBytes: number }
|
|
| { readonly path: string; readonly error: string };
|
|
readonly agentEnv: DesktopBuildCommand & {
|
|
readonly version?: string | undefined;
|
|
};
|
|
readonly archive: {
|
|
readonly path: string;
|
|
readonly source: "environment" | "cache";
|
|
readonly status: "current" | "missing" | "stale" | "unknown";
|
|
readonly detail?: string;
|
|
};
|
|
/** Each considered client's registration, by setting names only. */
|
|
readonly registrations: readonly {
|
|
readonly client: string;
|
|
readonly registered: boolean;
|
|
readonly unrecorded: readonly string[];
|
|
readonly unresolved: readonly string[];
|
|
readonly differing?: readonly string[];
|
|
readonly unchecked?: readonly string[];
|
|
/** Version check of this client's recorded runner, without the recorded path. */
|
|
readonly runner?: {
|
|
readonly status: "current" | "stale" | "invalid" | "unknown";
|
|
readonly version?: string;
|
|
};
|
|
}[];
|
|
/** Build settings this terminal's environment sets. */
|
|
readonly environmentSettings: readonly string[];
|
|
/** Where a solve endpoint is configured; null means its configuration is unknown. */
|
|
readonly solveEndpoint: string | null | undefined;
|
|
/** Names of agentenv sandbox containers; undefined when Docker was not reachable. */
|
|
readonly leftoverContainers: readonly string[] | undefined;
|
|
}
|
|
|
|
/** What a facts reader gets from doctor: its environment, bounded runner and registration reader. */
|
|
export interface DesktopBuildFactsInput {
|
|
readonly signal: AbortSignal;
|
|
readonly resources: ArtifactResourceScope;
|
|
readonly environment: Readonly<NodeJS.ProcessEnv>;
|
|
readonly platform: NodeJS.Platform;
|
|
readonly run: typeof execFileOutput;
|
|
readonly clientIds: readonly string[];
|
|
readonly registrations: (
|
|
clientIds: readonly string[] | undefined,
|
|
settings: Readonly<Record<string, string>>,
|
|
owned?: undefined,
|
|
observe?: (client: string, name: string, value: string) => void,
|
|
) => Promise<readonly ClientRegistrationStatus[]>;
|
|
}
|
|
|
|
/** What doctor already knows that the build checks reuse. */
|
|
export interface DesktopBuildContext {
|
|
readonly host: Pick<DoctorHost, "platform" | "architecture" | "runtime">;
|
|
readonly clients: readonly string[];
|
|
readonly skill: {
|
|
readonly state: DoctorSkillState;
|
|
readonly remediation: string | null;
|
|
};
|
|
}
|
|
|
|
const INFORMATIONAL = new Set([
|
|
`${DESKTOP_BUILD_PROVIDER_ID}-solve-endpoint`,
|
|
`${DESKTOP_BUILD_PROVIDER_ID}-leftover-containers`,
|
|
]);
|
|
|
|
/** Whether a desktop build check reports without deciding health. */
|
|
export const isDesktopBuildInformationalCheck = (name: string): boolean =>
|
|
INFORMATIONAL.has(name);
|
|
|
|
const named = (name: string) => `${DESKTOP_BUILD_PROVIDER_ID}-${name}`;
|
|
|
|
const result = (
|
|
name: string,
|
|
ok: boolean,
|
|
detail: string,
|
|
outcome: {
|
|
readonly classification: Exclude<DoctorCheck["classification"], "healthy">;
|
|
readonly remediation: string;
|
|
readonly details?: DoctorCheck["details"];
|
|
},
|
|
): DoctorCheck => ({
|
|
name: named(name),
|
|
ok,
|
|
classification: ok ? "healthy" : outcome.classification,
|
|
detail,
|
|
...(outcome.details === undefined ? {} : { details: outcome.details }),
|
|
...(ok ? {} : { remediation: outcome.remediation }),
|
|
});
|
|
|
|
/** The desktop build checks a doctor scope selects, read through its host. */
|
|
export const selectedDesktopBuildChecks = async (
|
|
host: DoctorHost,
|
|
scope: DoctorScopeReport,
|
|
skill: DesktopBuildContext["skill"],
|
|
): Promise<readonly DoctorCheck[]> =>
|
|
scope.providers.includes(DESKTOP_BUILD_PROVIDER_ID) &&
|
|
host.desktopBuildFacts !== undefined
|
|
? desktopBuildChecks(await host.desktopBuildFacts(scope.clients), {
|
|
host,
|
|
clients: scope.clients,
|
|
skill,
|
|
})
|
|
: [];
|
|
|
|
const setupCommand = (clients: readonly string[]): string =>
|
|
clients.length === 1
|
|
? `rea setup --client ${clients[0]} --desktop-build`
|
|
: "rea setup --client <client> --desktop-build";
|
|
|
|
/** The desktop build checks, required first and informational last. */
|
|
export const desktopBuildChecks = (
|
|
facts: DesktopBuildFacts,
|
|
context: DesktopBuildContext,
|
|
): readonly DoctorCheck[] => [
|
|
hostCheck(context.host),
|
|
{ ...nodeCheck(context.host), name: named("node") },
|
|
result("ps", facts.ps.found, facts.ps.detail, {
|
|
classification: "missing_dependency",
|
|
remediation:
|
|
"Install procps, whose ps REA's process supervisor runs: sudo apt install procps.",
|
|
}),
|
|
dockerCheck(facts.docker),
|
|
daemonCheck(facts.daemon),
|
|
diskCheck(facts.disk),
|
|
agentEnvCheck(facts),
|
|
archiveCheck(facts.archive, context.clients),
|
|
registrationCheck(facts, context.clients),
|
|
skillCheck(context.skill),
|
|
solveEndpointCheck(facts.solveEndpoint),
|
|
leftoverContainersCheck(facts.leftoverContainers),
|
|
];
|
|
|
|
const hostCheck = (host: DesktopBuildContext["host"]): DoctorCheck =>
|
|
result(
|
|
"host",
|
|
host.platform === "linux" &&
|
|
(host.architecture === "x64" || host.architecture === "arm64"),
|
|
`${host.platform} ${host.architecture}`,
|
|
{
|
|
classification: "unsupported_host",
|
|
remediation:
|
|
"Builds run on a Linux host on amd64 or arm64 and target its own architecture; run REA on such a host.",
|
|
},
|
|
);
|
|
|
|
const commandDetail = (command: DesktopBuildCommand, name: string): string =>
|
|
command.status === "found"
|
|
? `${command.path} (${command.source === "environment" ? name : "PATH"})`
|
|
: command.status === "invalid"
|
|
? `${name}=${command.value} is not an absolute path to a program.`
|
|
: `${name} is unset and none is on PATH.`;
|
|
|
|
const dockerCheck = (docker: DesktopBuildCommand): DoctorCheck =>
|
|
result(
|
|
"docker",
|
|
docker.status === "found",
|
|
commandDetail(docker, "REA_DOCKER_COMMAND"),
|
|
{
|
|
classification:
|
|
docker.status === "invalid" ? "config_drift" : "missing_dependency",
|
|
remediation:
|
|
docker.status === "invalid"
|
|
? "Set REA_DOCKER_COMMAND to the absolute path of the Docker CLI, or unset it to use docker on PATH."
|
|
: "Install Docker Engine: https://docs.docker.com/engine/install/",
|
|
},
|
|
);
|
|
|
|
const daemonCheck = (daemon: DesktopBuildFacts["daemon"]): DoctorCheck =>
|
|
result(
|
|
"docker-daemon",
|
|
daemon.status === "reachable",
|
|
daemon.status === "reachable"
|
|
? `Docker keeps its data in ${daemon.rootDirectory}.`
|
|
: daemon.status === "unchecked"
|
|
? "Not checked without a Docker CLI."
|
|
: daemon.detail,
|
|
daemon.status === "unreachable"
|
|
? {
|
|
classification: "runtime_failure",
|
|
remediation:
|
|
"Start Docker (sudo systemctl start docker), then rerun rea doctor --provider desktop_build.",
|
|
}
|
|
: {
|
|
classification: "config_drift",
|
|
remediation:
|
|
"Let your user reach Docker without sudo: sudo usermod -aG docker $USER, then log out and in again.",
|
|
},
|
|
);
|
|
|
|
const diskCheck = (disk: DesktopBuildFacts["disk"]): DoctorCheck => {
|
|
const gb = (bytes: number) => `${(bytes / 1000 ** 3).toFixed(1)} GB`;
|
|
return "error" in disk
|
|
? result("disk", false, `${disk.path}: ${disk.error}`, {
|
|
classification: "unknown",
|
|
remediation: `Check that ${disk.path} is readable, then rerun rea doctor --provider desktop_build.`,
|
|
})
|
|
: result(
|
|
"disk",
|
|
disk.freeBytes >= DESKTOP_BUILD_MIN_FREE_BYTES,
|
|
`${gb(disk.freeBytes)} free in ${disk.path}.`,
|
|
{
|
|
classification: "missing_dependency",
|
|
remediation: `Free at least ${gb(DESKTOP_BUILD_MIN_FREE_BYTES)} in ${disk.path}, or move Docker's data root (data-root in /etc/docker/daemon.json) to a larger disk.`,
|
|
details: { path: disk.path, free_bytes: disk.freeBytes },
|
|
},
|
|
);
|
|
};
|
|
|
|
const agentEnvCheck = (facts: DesktopBuildFacts): DoctorCheck => {
|
|
const { agentEnv } = facts;
|
|
const clients = facts.registrations.filter(({ registered }) => registered);
|
|
if (
|
|
clients.some(
|
|
({ runner, unresolved }) =>
|
|
runner !== undefined || unresolved.includes("REA_AGENT_ENV_COMMAND"),
|
|
)
|
|
) {
|
|
const rows = clients.map(({ client, runner, unresolved }) => ({
|
|
client,
|
|
...(runner ??
|
|
(unresolved.includes("REA_AGENT_ENV_COMMAND")
|
|
? { status: "unknown" as const }
|
|
: agentEnv.status !== "found"
|
|
? { status: "invalid" as const }
|
|
: agentEnv.version === undefined
|
|
? { status: "unknown" as const }
|
|
: {
|
|
status:
|
|
agentEnv.version === DESKTOP_EXPORT_FRAMEWORK_VERSION
|
|
? ("current" as const)
|
|
: ("stale" as const),
|
|
version: agentEnv.version,
|
|
})),
|
|
}));
|
|
const healthy = rows.every(({ status }) => status === "current");
|
|
return result(
|
|
"agent-env",
|
|
healthy,
|
|
rows
|
|
.map(({ client, status }) => `${client}'s runner is ${status}.`)
|
|
.join(" "),
|
|
{
|
|
classification: rows.some(({ status }) => status === "unknown")
|
|
? "unknown"
|
|
: "missing_dependency",
|
|
remediation: `${AGENTENV_INSTALL_COMMAND}, or rea setup --desktop-build --install-agentenv.`,
|
|
details: {
|
|
expected_version: DESKTOP_EXPORT_FRAMEWORK_VERSION,
|
|
clients: rows,
|
|
},
|
|
},
|
|
);
|
|
}
|
|
const pinned = agentEnv.version === DESKTOP_EXPORT_FRAMEWORK_VERSION;
|
|
const detail =
|
|
agentEnv.status !== "found"
|
|
? commandDetail(agentEnv, "REA_AGENT_ENV_COMMAND")
|
|
: `${commandDetail(agentEnv, "REA_AGENT_ENV_COMMAND")} reports ${agentEnv.version === undefined ? "no version" : `agentenv-framework ${agentEnv.version}`}; bundles target ${DESKTOP_EXPORT_FRAMEWORK_VERSION}.`;
|
|
return result("agent-env", agentEnv.status === "found" && pinned, detail, {
|
|
classification:
|
|
agentEnv.status === "invalid" ? "config_drift" : "missing_dependency",
|
|
remediation:
|
|
agentEnv.status === "invalid"
|
|
? `Set REA_AGENT_ENV_COMMAND to the absolute path of agent-env, or unset it to use agent-env on PATH. To install it: ${AGENTENV_INSTALL_COMMAND}`
|
|
: `${AGENTENV_INSTALL_COMMAND}, or rea setup --desktop-build --install-agentenv.`,
|
|
details: { expected_version: DESKTOP_EXPORT_FRAMEWORK_VERSION },
|
|
});
|
|
};
|
|
|
|
const archiveCheck = (
|
|
archive: DesktopBuildFacts["archive"],
|
|
clients: readonly string[],
|
|
): DoctorCheck =>
|
|
result(
|
|
"archive",
|
|
archive.status === "current",
|
|
archive.detail ??
|
|
(archive.status === "current"
|
|
? `${archive.path} holds this REA version.`
|
|
: `${archive.path} is missing.`),
|
|
{
|
|
classification: archive.status === "unknown" ? "unknown" : "config_drift",
|
|
remediation:
|
|
archive.source === "environment"
|
|
? `Repack it with npm run pack:build-computer-runtime -- ${archive.path}, or unset REA_BUILD_COMPUTER_REA_ARCHIVE and run ${setupCommand(clients)}.`
|
|
: `Run ${setupCommand(clients)} to pack it.`,
|
|
details: { path: archive.path, source: archive.source },
|
|
},
|
|
);
|
|
|
|
const registrationCheck = (
|
|
facts: DesktopBuildFacts,
|
|
clients: readonly string[],
|
|
): DoctorCheck => {
|
|
const set = new Set(facts.environmentSettings);
|
|
const gaps = facts.registrations.map(
|
|
({
|
|
client,
|
|
registered,
|
|
unrecorded,
|
|
unresolved,
|
|
differing = [],
|
|
unchecked = [],
|
|
runner,
|
|
}) => ({
|
|
client,
|
|
registered,
|
|
missing: unrecorded.filter((name) => !set.has(name)),
|
|
unresolved: [...unresolved],
|
|
...(differing.length === 0 ? {} : { differing: [...differing] }),
|
|
...(unchecked.length === 0 ? {} : { unchecked: [...unchecked] }),
|
|
...(runner === undefined ? {} : { runner }),
|
|
}),
|
|
);
|
|
const failing = gaps.filter(
|
|
({ registered, missing, differing, runner }) =>
|
|
!registered ||
|
|
missing.length > 0 ||
|
|
(differing ?? []).some(
|
|
(name) =>
|
|
name !== "REA_AGENT_ENV_COMMAND" || runner?.status !== "current",
|
|
),
|
|
);
|
|
const unknown = gaps.filter(
|
|
({ unresolved, unchecked }) =>
|
|
unresolved.length > 0 || (unchecked?.length ?? 0) > 0,
|
|
);
|
|
const repair = failing[0]?.client ?? unknown[0]?.client;
|
|
const remediation = failing.some(
|
|
({ differing }) => (differing?.length ?? 0) > 0,
|
|
)
|
|
? "Correct or remove the failed settings in the client's REA registration, then restart the client and run doctor again."
|
|
: unknown.length > 0
|
|
? "Check the unverified settings in the client's REA registration, then restart the client and run doctor again."
|
|
: `Run ${setupCommand(repair === undefined ? clients : [repair])}, then restart the client.`;
|
|
return result(
|
|
"registration",
|
|
gaps.length > 0 && failing.length === 0 && unknown.length === 0,
|
|
gaps.length === 0
|
|
? "No REA registration was found."
|
|
: gaps.map(registrationDetail).join(" "),
|
|
{
|
|
classification:
|
|
failing.length === 0 && gaps.length > 0 ? "unknown" : "config_drift",
|
|
remediation,
|
|
details: { registrations: gaps },
|
|
},
|
|
);
|
|
};
|
|
|
|
const registrationDetail = (gap: {
|
|
readonly client: string;
|
|
readonly registered: boolean;
|
|
readonly missing: readonly string[];
|
|
readonly unresolved: readonly string[];
|
|
readonly differing?: readonly string[];
|
|
readonly unchecked?: readonly string[];
|
|
}): string => {
|
|
if (!gap.registered) return `${gap.client} does not register REA.`;
|
|
const details = [
|
|
...(gap.missing.length === 0
|
|
? []
|
|
: [
|
|
`${gap.client}'s registration does not record ${gap.missing.join(", ")}, and this environment does not set them.`,
|
|
]),
|
|
...(gap.unresolved.length === 0
|
|
? []
|
|
: [`REA could not read ${gap.client}'s ${gap.unresolved.join(", ")}.`]),
|
|
...(gap.differing === undefined
|
|
? []
|
|
: [
|
|
`${gap.client}'s recorded ${gap.differing.join(", ")} failed verification.`,
|
|
]),
|
|
...(gap.unchecked === undefined
|
|
? []
|
|
: [
|
|
`REA could not verify ${gap.client}'s recorded ${gap.unchecked.join(", ")}.`,
|
|
]),
|
|
];
|
|
return details.length > 0
|
|
? details.join(" ")
|
|
: `${gap.client}'s registration records the build settings, or this environment sets them.`;
|
|
};
|
|
|
|
const skillCheck = (skill: DesktopBuildContext["skill"]): DoctorCheck =>
|
|
result(
|
|
"skill",
|
|
skill.state === "aligned",
|
|
`The installed REA skill, with its desktop-build reference, is ${skill.state}.`,
|
|
{
|
|
classification: skill.state === "unknown" ? "unknown" : "config_drift",
|
|
remediation:
|
|
skill.remediation ?? "Run rea setup --skill to update the REA skill.",
|
|
},
|
|
);
|
|
|
|
const solveEndpointCheck = (where: string | null | undefined): DoctorCheck =>
|
|
result(
|
|
"solve-endpoint",
|
|
where !== undefined && where !== null,
|
|
where === null
|
|
? "REA could not determine whether agentenv has a model endpoint configured."
|
|
: where === undefined
|
|
? "No model endpoint is configured for solver runs."
|
|
: `A model endpoint is configured in ${where}; its availability was not checked.`,
|
|
{
|
|
classification: where === null ? "unknown" : "missing_dependency",
|
|
remediation:
|
|
"For solver runs, export LITELLM_BASE_URL and LITELLM_API_KEY in the shell that starts the agent, or set base_url and api_key under [model] in .agentenv/config.toml.",
|
|
},
|
|
);
|
|
|
|
const leftoverContainersCheck = (
|
|
containers: readonly string[] | undefined,
|
|
): DoctorCheck =>
|
|
result(
|
|
"leftover-containers",
|
|
containers === undefined || containers.length === 0,
|
|
containers === undefined
|
|
? "Not checked without a reachable Docker daemon."
|
|
: containers.length === 0
|
|
? "No agentenv sandbox containers are left."
|
|
: `${String(containers.length)} agentenv sandbox containers remain: ${containers.join(", ")}.`,
|
|
{
|
|
classification: "config_drift",
|
|
remediation: `If no build is running, remove them: docker rm -f ${(containers ?? []).join(" ")}`,
|
|
},
|
|
);
|