mirror of
https://github.com/morluto/rea.git
synced 2026-12-01 11:01:11 +00:00
Resolve bare REA launchers using the registration's effective PATH and verify the resulting installation before setup or uninstall changes an entry. Share the parsed environment through registration workflows and keep unproven launchers unknown. Cover npm shim lookup on Windows and use deterministic ownership fixtures for layered removal. Fixes #15026. Co-authored-by: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com> Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
1178 lines
41 KiB
TypeScript
1178 lines
41 KiB
TypeScript
import { HOST_PLATFORM } from "../../../src/platform/HostPlatform.js";
|
|
import { currentClientRegistrationCommand } from "../../../src/application/ClientRegistrationIdentity.js";
|
|
import {
|
|
lstat as fsLstat,
|
|
mkdir,
|
|
open as fsOpen,
|
|
readFile,
|
|
realpath as fsRealpath,
|
|
rename,
|
|
writeFile,
|
|
type FileHandle,
|
|
} from "node:fs/promises";
|
|
import { basename, dirname, join } from "node:path";
|
|
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
import {
|
|
readClientRegistrationInspections,
|
|
readClientRegistrationStatuses,
|
|
} from "../../../src/application/ClientRegistrationStatus.js";
|
|
import { planIntegrationMaintenance } from "../../../src/application/UpdateMaintenance.js";
|
|
import { ArtifactResourceScope } from "../../../src/resources/ArtifactResourceScope.js";
|
|
import { ok } from "../../../src/domain/result.js";
|
|
import type { DoctorHost } from "../../../src/application/Doctor.js";
|
|
import { ConfigurationError } from "../../../src/domain/configurationErrors.js";
|
|
import {
|
|
filterClientsNeedingConfigure,
|
|
systemSetupHost,
|
|
} from "../../../src/application/SetupHost.js";
|
|
import { RegularFileCleanupFailure } from "../../../src/filesystem/OwnedRegularFile.js";
|
|
import { configureDetectedClients } from "../../../src/application/SetupClients.js";
|
|
import { configureClientConfiguration } from "../../../src/application/SetupClientConfiguration.js";
|
|
import {
|
|
systemUninstallHost,
|
|
runUninstall,
|
|
} from "../../../src/application/Uninstall.js";
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
import { phaseGate } from "../../support/lifecycleHarness.js";
|
|
import { withVerifierCleanup } from "../../../scripts/lib/verifier-cleanup.mjs";
|
|
import { supportedClientRegistrationProfile } from "../../fixtures/clientRegistrationProfile.js";
|
|
|
|
vi.mock("node:fs/promises", async (importOriginal) => {
|
|
const actual = await importOriginal<typeof import("node:fs/promises")>();
|
|
return {
|
|
...actual,
|
|
open: vi.fn(actual.open),
|
|
lstat: vi.fn(actual.lstat),
|
|
realpath: vi.fn(actual.realpath),
|
|
};
|
|
});
|
|
|
|
const openMock = vi.mocked(fsOpen);
|
|
const lstatMock = vi.mocked(fsLstat);
|
|
const realpathMock = vi.mocked(fsRealpath);
|
|
let actualFs: typeof import("node:fs/promises");
|
|
|
|
beforeEach(async () => {
|
|
actualFs =
|
|
await vi.importActual<typeof import("node:fs/promises")>(
|
|
"node:fs/promises",
|
|
);
|
|
openMock.mockImplementation((...args) => actualFs.open(...args));
|
|
lstatMock.mockImplementation((...args) => actualFs.lstat(...args));
|
|
realpathMock.mockImplementation((...args) => actualFs.realpath(...args));
|
|
});
|
|
|
|
afterEach(() => {
|
|
openMock.mockReset();
|
|
lstatMock.mockReset();
|
|
realpathMock.mockReset();
|
|
});
|
|
|
|
const holdReadHandle = (
|
|
path: string | ((path: string) => boolean),
|
|
reason: string,
|
|
initiallyHeld = true,
|
|
maxFailures = Number.POSITIVE_INFINITY,
|
|
) => {
|
|
const closeAttempts: FileHandle[] = [];
|
|
let released = false;
|
|
let held = initiallyHeld;
|
|
let remainingFailures = maxFailures;
|
|
openMock.mockImplementation(async (...args) => {
|
|
const handle = await actualFs.open(...args);
|
|
const opened = String(args[0]);
|
|
if (!(typeof path === "string" ? opened === path : path(opened)))
|
|
return handle;
|
|
const nativeClose = handle.close.bind(handle);
|
|
vi.spyOn(handle, "close").mockImplementation(async () => {
|
|
closeAttempts.push(handle);
|
|
if (held && !released && remainingFailures > 0) {
|
|
remainingFailures -= 1;
|
|
throw new Error(reason);
|
|
}
|
|
await nativeClose();
|
|
});
|
|
return handle;
|
|
});
|
|
return {
|
|
closeAttempts,
|
|
hold: () => {
|
|
held = true;
|
|
},
|
|
release: () => {
|
|
released = true;
|
|
},
|
|
};
|
|
};
|
|
|
|
/** Linux setup host with its VS Code client configuration directory prepared. */
|
|
const preparedVsCodeSetupHost = async (prefix: string) => {
|
|
const home = await createTestTempDirectory(prefix);
|
|
const host = systemSetupHost(
|
|
{ platform: "linux", homeDirectory: home } as DoctorHost,
|
|
{ HOME: home, XDG_CONFIG_HOME: join(home, "xdg") },
|
|
);
|
|
const client = (await host.supportedClients()).find(
|
|
({ name }) => name === "vscode",
|
|
);
|
|
if (client === undefined) throw new Error("VS Code setup client missing");
|
|
await mkdir(dirname(client.configPath), { recursive: true });
|
|
return { home, host, client };
|
|
};
|
|
|
|
/** Release the held read handle and verify host cleanup retries that same owner. */
|
|
const expectCloseReclaimsHandle = async (
|
|
host: { close?: () => Promise<unknown> },
|
|
closeAttempts: readonly object[],
|
|
release: () => void,
|
|
) => {
|
|
const attemptsBeforeClose = closeAttempts.length;
|
|
release();
|
|
expect(await host.close?.()).toBeUndefined();
|
|
expect(closeAttempts).toHaveLength(attemptsBeforeClose + 1);
|
|
expect(closeAttempts.at(-1)).toBe(closeAttempts[0]);
|
|
};
|
|
|
|
/** Give up on the assertion path: release the handle and let cleanup close it. */
|
|
const cleanupHeldHandle = async (
|
|
host: { close?: () => Promise<unknown> },
|
|
release: () => void,
|
|
) => {
|
|
release();
|
|
await host.close?.();
|
|
};
|
|
|
|
it("retains invalid UTF-8 diagnostics and the uninstall read owner when close fails", async () => {
|
|
const home = await createTestTempDirectory("rea-uninstall-utf8-close-");
|
|
const path = join(home, "client.json");
|
|
const original = Buffer.from([0xff]);
|
|
await writeFile(path, original);
|
|
const { closeAttempts, release } = holdReadHandle(
|
|
path,
|
|
"held uninstall handle",
|
|
);
|
|
const host = systemUninstallHost(home, undefined, { HOME: home }, "linux");
|
|
try {
|
|
expect(
|
|
await host.removeClient({
|
|
name: "cursor",
|
|
registrationProfile: supportedClientRegistrationProfile("cursor"),
|
|
format: "json",
|
|
configPath: path,
|
|
}),
|
|
).toMatchObject({
|
|
status: "failed",
|
|
detail: expect.stringContaining("not valid UTF-8"),
|
|
});
|
|
expect(Buffer.compare(await readFile(path), original)).toBe(0);
|
|
expect(closeAttempts).toHaveLength(3);
|
|
expect(closeAttempts.every((handle) => handle === closeAttempts[0])).toBe(
|
|
true,
|
|
);
|
|
await expectCloseReclaimsHandle(host, closeAttempts, release);
|
|
} finally {
|
|
await cleanupHeldHandle(host, release);
|
|
}
|
|
});
|
|
|
|
it("stops uninstall and retains the backup read owner when its close fails", async () => {
|
|
const home = await createTestTempDirectory("rea-uninstall-backup-close-");
|
|
const path = join(home, "client.json");
|
|
const client = {
|
|
name: "cursor",
|
|
registrationProfile: supportedClientRegistrationProfile("cursor"),
|
|
format: "json",
|
|
configPath: path,
|
|
} as const;
|
|
await writeFile(path, '{"keep":"before setup"}\n');
|
|
expect(
|
|
await configureClientConfiguration(client, {}, [
|
|
"npx",
|
|
"-y",
|
|
"rea-agents@6.6.0",
|
|
"mcp",
|
|
]),
|
|
).toMatchObject({ status: "configured" });
|
|
const configured = await readFile(path, "utf8");
|
|
const { closeAttempts, release } = holdReadHandle(
|
|
`${path}.rea.backup`,
|
|
"held backup handle",
|
|
);
|
|
const host = systemUninstallHost(home, undefined, { HOME: home }, "linux");
|
|
try {
|
|
expect(await host.removeClient(client)).toEqual({
|
|
name: "cursor",
|
|
status: "failed",
|
|
detail: expect.stringMatching(
|
|
/could not be backed up.*no change.*permissions.*uninstall/i,
|
|
),
|
|
});
|
|
expect(await readFile(path, "utf8")).toBe(configured);
|
|
expect(closeAttempts).toHaveLength(2);
|
|
await expectCloseReclaimsHandle(host, closeAttempts, release);
|
|
} finally {
|
|
await cleanupHeldHandle(host, release);
|
|
}
|
|
});
|
|
|
|
it("reports a completed uninstall edit while publication cleanup remains owned", async () => {
|
|
const home = await createTestTempDirectory(
|
|
"rea-uninstall-publication-close-",
|
|
);
|
|
const path = join(home, ".cursor", "mcp.json");
|
|
const cache = join(home, ".rea", "cache", "marker");
|
|
const original =
|
|
'{"mcpServers":{"rea":{"command":"npx","args":["-y","rea-agents@6.6.0","mcp"]},"peer":{}}}\n';
|
|
await mkdir(dirname(path), { recursive: true });
|
|
await mkdir(dirname(cache), { recursive: true });
|
|
await writeFile(path, original);
|
|
await writeFile(cache, "keep");
|
|
const configDirectory = await fsRealpath(dirname(path));
|
|
let stagingDirectory: string | undefined;
|
|
const { release } = holdReadHandle((opened) => {
|
|
const directory = dirname(opened);
|
|
if (
|
|
basename(opened) !== "content" ||
|
|
dirname(directory) !== configDirectory ||
|
|
!basename(directory).startsWith(".rea-config-")
|
|
)
|
|
return false;
|
|
stagingDirectory = directory;
|
|
return true;
|
|
}, "held configuration publication handle");
|
|
const host = systemUninstallHost(home, undefined, { HOME: home }, "linux");
|
|
try {
|
|
const result = await runUninstall(true, host);
|
|
if (stagingDirectory === undefined)
|
|
throw new Error("Uninstall did not stage an edit");
|
|
expect(result.status).toBe("failed");
|
|
expect(result.cleanup?.resources).toEqual([stagingDirectory]);
|
|
expect(JSON.parse(await readFile(path, "utf8"))).toEqual({
|
|
mcpServers: { peer: {} },
|
|
});
|
|
expect(await readFile(`${path}.rea.backup`, "utf8")).toBe(original);
|
|
expect(await readFile(cache, "utf8")).toBe("keep");
|
|
const client = result.items.find(({ name }) => name === "cursor");
|
|
expect(client).toMatchObject({
|
|
status: "failed",
|
|
configuration_path: path,
|
|
});
|
|
expect(client?.detail).toContain(`Removed registration from ${path}`);
|
|
expect(client?.detail).toContain(`${path}.rea.backup`);
|
|
|
|
release();
|
|
expect(await host.close?.()).toBeUndefined();
|
|
await expect(fsLstat(stagingDirectory)).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
expect(result.cleanup).toBeUndefined();
|
|
} finally {
|
|
await cleanupHeldHandle(host, release);
|
|
}
|
|
});
|
|
|
|
it.each(["owned registration", "shadowed duplicate"] as const)(
|
|
"stops uninstall and preserves managed data after a $0 ownership read cannot close",
|
|
async (scenario) => {
|
|
// The first read proves ownership even if close fails. The shadowed row
|
|
// also refuses the edit, so its refusal must preserve the ownership fact.
|
|
const home = await createTestTempDirectory("rea-freebuff-ownership-close-");
|
|
const setupHost = systemSetupHost(
|
|
{ platform: "linux", homeDirectory: home } as DoctorHost,
|
|
{ HOME: home },
|
|
);
|
|
const client = (await setupHost.supportedClients()).find(
|
|
({ name }) => name === "freebuff",
|
|
);
|
|
if (client === undefined) throw new Error("freebuff client missing");
|
|
const path = client.configPath;
|
|
await mkdir(dirname(path), { recursive: true });
|
|
if (scenario === "shadowed duplicate") {
|
|
await writeFile(
|
|
path,
|
|
'{"mcpServers":{"rea":{"command":"foreign-server","args":[]},"rea":{"command":"npx","args":["-y","rea-agents@6.6.0","mcp"]}}}',
|
|
);
|
|
} else {
|
|
await writeFile(path, '{"mcpServers":{"other":{"command":"other"}}}');
|
|
expect(
|
|
await configureClientConfiguration(client, {}, [
|
|
"npx",
|
|
"-y",
|
|
"rea-agents@6.6.0",
|
|
"mcp",
|
|
]),
|
|
).toMatchObject({ status: "configured" });
|
|
}
|
|
const registration = await readFile(path, "utf8");
|
|
const marker = join(home, ".rea", "cache", "marker");
|
|
await mkdir(dirname(marker), { recursive: true });
|
|
await writeFile(marker, "managed data");
|
|
const { release } = holdReadHandle(path, "held ownership read handle");
|
|
const host = systemUninstallHost(home, undefined, { HOME: home }, "linux");
|
|
try {
|
|
const result = await runUninstall(true, host);
|
|
expect(result.status).toBe("failed");
|
|
expect(result.items).toContainEqual(
|
|
expect.objectContaining({ name: "freebuff", status: "failed" }),
|
|
);
|
|
expect(result.items).toContainEqual(
|
|
expect.objectContaining({
|
|
name: "uninstall",
|
|
status: "skipped",
|
|
detail: expect.stringContaining(
|
|
"No REA registration, skill, or data was removed",
|
|
),
|
|
}),
|
|
);
|
|
expect(await readFile(path, "utf8")).toBe(registration);
|
|
expect(await readFile(marker, "utf8")).toBe("managed data");
|
|
} finally {
|
|
await cleanupHeldHandle(host, release);
|
|
}
|
|
},
|
|
);
|
|
|
|
it("stops removal when a completed reread leaves its handle unreleased", async () => {
|
|
// Greptile P1: preflight and reread both complete with a foreign-only row,
|
|
// but the reread handle cannot be closed even by the cleanup retry. REA
|
|
// still owns that open handle, so removal must stop before purge: serving
|
|
// the completed text would let removeAll delete managed data while the
|
|
// incomplete cleanup is only reported later, by close().
|
|
const home = await createTestTempDirectory("rea-freebuff-reread-leak-");
|
|
const setupHost = systemSetupHost(
|
|
{ platform: "linux", homeDirectory: home } as DoctorHost,
|
|
{ HOME: home },
|
|
);
|
|
const client = (await setupHost.supportedClients()).find(
|
|
({ name }) => name === "freebuff",
|
|
);
|
|
if (client === undefined) throw new Error("freebuff client missing");
|
|
await mkdir(dirname(client.configPath), { recursive: true });
|
|
await writeFile(
|
|
client.configPath,
|
|
'{"mcpServers":{"rea":{"command":"foreign-server","args":[]}}}',
|
|
);
|
|
const marker = join(home, ".rea", "cache", "marker");
|
|
await mkdir(dirname(marker), { recursive: true });
|
|
await writeFile(marker, "managed data");
|
|
const { hold, release } = holdReadHandle(
|
|
client.configPath,
|
|
"held removal reread handle",
|
|
false,
|
|
);
|
|
const base = systemUninstallHost(home, undefined, { HOME: home }, "linux");
|
|
const host = {
|
|
...base,
|
|
inspectSkill: async () => {
|
|
hold();
|
|
return base.inspectSkill?.();
|
|
},
|
|
};
|
|
try {
|
|
const result = await runUninstall(true, host);
|
|
expect(result.status).toBe("failed");
|
|
expect(result.items).toContainEqual(
|
|
expect.objectContaining({
|
|
name: "freebuff",
|
|
status: "failed",
|
|
detail: expect.stringContaining("its resources could not be released"),
|
|
}),
|
|
);
|
|
expect(result.items).toContainEqual(
|
|
expect.objectContaining({
|
|
name: "uninstall",
|
|
status: "skipped",
|
|
detail: expect.stringContaining("Uninstall stopped at this failure"),
|
|
}),
|
|
);
|
|
// Managed data must survive an unreleased read handle.
|
|
await expect(readFile(marker, "utf8")).resolves.toBe("managed data");
|
|
} finally {
|
|
await cleanupHeldHandle(host, release);
|
|
}
|
|
});
|
|
|
|
it("keeps the shared registration fail-closed when ZCode's probe is unresolved", async () => {
|
|
// A denied profile probe leaves ZCode's applicability unresolved, so the
|
|
// malformed shared registration blocks uninstall before it can edit Cursor.
|
|
// A definitively absent profile leaves the file to ZCode's owner, FreeBuff.
|
|
const home = await createTestTempDirectory("rea-zcode-fallback-unresolved-");
|
|
const fallback = join(home, ".agents", "mcp.json");
|
|
const profile = join(home, ".zcode", "cli");
|
|
const cursor = join(home, ".cursor", "mcp.json");
|
|
const original =
|
|
'{"mcpServers":{"rea":{"command":"npx","args":["-y","rea-agents@6.6.0","mcp"]}}}';
|
|
await mkdir(dirname(fallback), { recursive: true });
|
|
await mkdir(dirname(cursor), { recursive: true });
|
|
await writeFile(fallback, "{ malformed");
|
|
await writeFile(cursor, original);
|
|
lstatMock.mockImplementation((path) =>
|
|
String(path) === profile
|
|
? Promise.reject(
|
|
Object.assign(new Error("EACCES: permission denied, lstat"), {
|
|
code: "EACCES",
|
|
}),
|
|
)
|
|
: actualFs.lstat(path),
|
|
);
|
|
const unresolved = systemUninstallHost(
|
|
home,
|
|
undefined,
|
|
{ HOME: home },
|
|
"linux",
|
|
);
|
|
try {
|
|
const rows = (await unresolved.clients()).filter(
|
|
(candidate) => candidate.configPath === fallback,
|
|
);
|
|
// One physical file, one owner: FreeBuff edits the shared file once and
|
|
// ZCode reports that same outcome instead of racing it to "absent".
|
|
expect(rows).toHaveLength(1);
|
|
expect(rows[0]).toMatchObject({ name: "freebuff", sharedWith: ["zcode"] });
|
|
// Fail-closed: the unresolved reader carries no unverified softening, so a
|
|
// failed read blocks removal instead of retaining around the purge.
|
|
expect(rows[0]?.applicability).toBeUndefined();
|
|
const blocked = await runUninstall(false, unresolved);
|
|
expect(blocked.status).toBe("failed");
|
|
expect(blocked.items).toContainEqual(
|
|
expect.objectContaining({ name: "freebuff", status: "failed" }),
|
|
);
|
|
expect(await readFile(cursor, "utf8")).toBe(original);
|
|
} finally {
|
|
await unresolved.close?.();
|
|
}
|
|
lstatMock.mockImplementation((...args) => actualFs.lstat(...args));
|
|
const absent = systemUninstallHost(home, undefined, { HOME: home }, "linux");
|
|
try {
|
|
const rows = (await absent.clients()).filter(
|
|
(candidate) => candidate.configPath === fallback,
|
|
);
|
|
expect(rows).toHaveLength(1);
|
|
// Definitive absence keeps ZCode out of another product's primary storage.
|
|
expect(rows[0]?.sharedWith).toBeUndefined();
|
|
const continued = await runUninstall(false, absent);
|
|
expect(continued.status).toBe("complete");
|
|
expect(continued.items).toContainEqual(
|
|
expect.objectContaining({ name: "cursor", status: "removed" }),
|
|
);
|
|
expect(JSON.parse(await readFile(cursor, "utf8"))).toEqual({
|
|
mcpServers: {},
|
|
});
|
|
expect(await readFile(fallback, "utf8")).toBe("{ malformed");
|
|
} finally {
|
|
await absent.close?.();
|
|
}
|
|
});
|
|
|
|
it("removes a shared registration once and reports that outcome to both clients", async () => {
|
|
// ZCode and FreeBuff both load ~/.agents/mcp.json. Queuing it per client
|
|
// removed the row as ZCode and then reported FreeBuff as "absent", losing
|
|
// the outcome for the client that owns the file, and it read and edited one
|
|
// shared resource twice.
|
|
const home = await createTestTempDirectory("rea-shared-removal-once-");
|
|
const shared = join(home, ".agents", "mcp.json");
|
|
await mkdir(join(home, ".zcode", "cli"), { recursive: true });
|
|
await mkdir(join(home, ".config", "freebuff-desktop"), { recursive: true });
|
|
expect(
|
|
await configureClientConfiguration(
|
|
{
|
|
name: "freebuff",
|
|
registrationProfile: supportedClientRegistrationProfile("freebuff"),
|
|
format: "json",
|
|
configPath: shared,
|
|
},
|
|
{},
|
|
["npx", "-y", "rea-agents@6.6.0", "mcp"],
|
|
),
|
|
).toMatchObject({ status: "configured" });
|
|
const host = systemUninstallHost(home, undefined, { HOME: home }, "linux");
|
|
try {
|
|
const result = await runUninstall(false, host);
|
|
expect(result.status).toBe("complete");
|
|
expect(result.items).toContainEqual(
|
|
expect.objectContaining({
|
|
name: "freebuff",
|
|
status: "removed",
|
|
configuration_path: shared,
|
|
}),
|
|
);
|
|
// The fallback reader reports the owner's removal, never "absent".
|
|
const zcode = result.items.find(({ name }) => name === "zcode");
|
|
expect(zcode?.actions).toContainEqual(
|
|
expect.objectContaining({
|
|
status: "removed",
|
|
configuration_path: shared,
|
|
}),
|
|
);
|
|
expect(zcode?.actions).not.toContainEqual(
|
|
expect.objectContaining({
|
|
status: "skipped",
|
|
configuration_path: shared,
|
|
}),
|
|
);
|
|
expect(JSON.parse(await readFile(shared, "utf8"))).toEqual({
|
|
mcpServers: {},
|
|
});
|
|
} finally {
|
|
await host.close?.();
|
|
}
|
|
});
|
|
|
|
it.each([true, false])(
|
|
"projects only the shared table's outcome to ZCode (shared row owned: %s)",
|
|
async (sharedOwned) => {
|
|
const home = await createTestTempDirectory("rea-shared-table-outcome-");
|
|
const shared = join(home, ".agents", "mcp.json");
|
|
const zcodePath = join(home, ".zcode", "cli", "config.json");
|
|
await mkdir(dirname(shared), { recursive: true });
|
|
await mkdir(dirname(zcodePath), { recursive: true });
|
|
await mkdir(join(home, ".config", "freebuff-desktop"), { recursive: true });
|
|
await writeFile(zcodePath, '{"mcp":{"servers":{}}}');
|
|
await writeFile(
|
|
shared,
|
|
JSON.stringify({
|
|
mcp: {
|
|
rea: {
|
|
type: "local",
|
|
command: sharedOwned
|
|
? ["foreign-server", "mcp"]
|
|
: ["npx", "-y", "rea-agents@6.6.0", "mcp"],
|
|
},
|
|
},
|
|
mcpServers: {
|
|
rea: sharedOwned
|
|
? {
|
|
command: "npx",
|
|
args: ["-y", "rea-agents@6.6.0", "mcp"],
|
|
}
|
|
: { command: "foreign-server", args: ["mcp"] },
|
|
},
|
|
}),
|
|
);
|
|
const host = systemUninstallHost(
|
|
home,
|
|
undefined,
|
|
{ HOME: home, OPENCODE_CONFIG: shared },
|
|
"linux",
|
|
);
|
|
try {
|
|
const claimants = (await host.clients())
|
|
.filter(({ configPath }) => configPath === shared)
|
|
.map(({ name }) => name)
|
|
.sort();
|
|
expect(claimants).toEqual(["freebuff", "opencode"]);
|
|
const result = await runUninstall(false, host);
|
|
expect(result.status).toBe("complete");
|
|
const sharedServerStatus = sharedOwned ? "removed" : "retained";
|
|
expect(
|
|
result.items.find(({ name }) => name === "freebuff"),
|
|
).toMatchObject({
|
|
status: sharedServerStatus,
|
|
configuration_path: shared,
|
|
});
|
|
for (const [client, status] of [
|
|
["zcode", sharedServerStatus],
|
|
["opencode", sharedOwned ? "retained" : "removed"],
|
|
] as const) {
|
|
const resultForClient = result.items.find(
|
|
({ name }) => name === client,
|
|
);
|
|
expect(resultForClient?.status).toBe(status);
|
|
expect(
|
|
resultForClient?.actions?.filter(
|
|
({ configuration_path }) => configuration_path === shared,
|
|
),
|
|
).toEqual([expect.objectContaining({ status })]);
|
|
}
|
|
const remaining = JSON.parse(await readFile(shared, "utf8"));
|
|
expect(remaining.mcp).toEqual(
|
|
sharedOwned
|
|
? { rea: { type: "local", command: ["foreign-server", "mcp"] } }
|
|
: {},
|
|
);
|
|
expect(remaining.mcpServers).toEqual(
|
|
sharedOwned
|
|
? {}
|
|
: { rea: { command: "foreign-server", args: ["mcp"] } },
|
|
);
|
|
} finally {
|
|
await host.close?.();
|
|
}
|
|
},
|
|
);
|
|
|
|
it("does not treat a dangling FreeBuff profile link as installed", async () => {
|
|
// Setup and doctor follow ~/.config/freebuff-desktop and reject a link whose
|
|
// target is gone. Discovery must agree: counting the leftover link as an
|
|
// installed product turns an unrelated malformed shared file into a blocking
|
|
// failure that stops every other REA removal.
|
|
const home = await createTestTempDirectory("rea-freebuff-dangling-profile-");
|
|
const shared = join(home, ".agents", "mcp.json");
|
|
const profile = join(home, ".config", "freebuff-desktop");
|
|
const cursor = join(home, ".cursor", "mcp.json");
|
|
await mkdir(dirname(shared), { recursive: true });
|
|
await writeFile(shared, "{ not json");
|
|
await mkdir(dirname(cursor), { recursive: true });
|
|
await writeFile(cursor, '{"keep":"before setup"}\n');
|
|
expect(
|
|
await configureClientConfiguration(
|
|
{
|
|
name: "cursor",
|
|
registrationProfile: supportedClientRegistrationProfile("cursor"),
|
|
format: "json",
|
|
configPath: cursor,
|
|
},
|
|
{},
|
|
["npx", "-y", "rea-agents@6.6.0", "mcp"],
|
|
),
|
|
).toMatchObject({ status: "configured" });
|
|
lstatMock.mockImplementation((path) =>
|
|
String(path) === profile
|
|
? Promise.resolve({
|
|
isFile: () => false,
|
|
isDirectory: () => false,
|
|
isSymbolicLink: () => true,
|
|
} as unknown as Awaited<ReturnType<typeof fsLstat>>)
|
|
: actualFs.lstat(path),
|
|
);
|
|
realpathMock.mockImplementation((path) =>
|
|
String(path) === profile
|
|
? Promise.reject(
|
|
Object.assign(
|
|
new Error("ENOENT: no such file or directory, realpath"),
|
|
{ code: "ENOENT" },
|
|
),
|
|
)
|
|
: actualFs.realpath(path),
|
|
);
|
|
const host = systemUninstallHost(home, undefined, { HOME: home }, "linux");
|
|
try {
|
|
const result = await runUninstall(false, host);
|
|
expect(result.status).toBe("complete");
|
|
// The unrelated registration is removed instead of blocked.
|
|
expect(result.items).toContainEqual(
|
|
expect.objectContaining({ name: "cursor", status: "removed" }),
|
|
);
|
|
expect(JSON.parse(await readFile(cursor, "utf8"))).not.toHaveProperty(
|
|
"mcpServers.rea",
|
|
);
|
|
expect(result.items).toContainEqual(
|
|
expect.objectContaining({ name: "freebuff", status: "retained" }),
|
|
);
|
|
} finally {
|
|
await host.close?.();
|
|
}
|
|
});
|
|
|
|
it("serves a completed removal reread when its close retry releases the handle", async () => {
|
|
// Preflight saw no owned row; another writer adds one before removal. The
|
|
// reread's first close fails but its cleanup retry releases the handle:
|
|
// the completed text is the ownership evidence that drives removal of the
|
|
// concurrently added row instead of softening to retained and leaving it
|
|
// active while data is purged.
|
|
const home = await createTestTempDirectory("rea-freebuff-reread-close-");
|
|
const setupHost = systemSetupHost(
|
|
{ platform: "linux", homeDirectory: home } as DoctorHost,
|
|
{ HOME: home },
|
|
);
|
|
const client = (await setupHost.supportedClients()).find(
|
|
({ name }) => name === "freebuff",
|
|
);
|
|
if (client === undefined) throw new Error("freebuff client missing");
|
|
await mkdir(dirname(client.configPath), { recursive: true });
|
|
await writeFile(
|
|
client.configPath,
|
|
'{"mcpServers":{"rea":{"command":"foreign-server","args":[]}}}',
|
|
);
|
|
const cacheOwned = join(home, ".rea", "cache", "owned");
|
|
await mkdir(dirname(cacheOwned), { recursive: true });
|
|
await writeFile(cacheOwned, "owned\n");
|
|
const { hold, release } = holdReadHandle(
|
|
client.configPath,
|
|
"held removal reread handle",
|
|
false,
|
|
1,
|
|
);
|
|
const base = systemUninstallHost(home, undefined, { HOME: home }, "linux");
|
|
const host = {
|
|
...base,
|
|
inspectSkill: async () => {
|
|
// Another writer registers REA between preflight and removal.
|
|
await writeFile(
|
|
client.configPath,
|
|
'{"mcpServers":{"rea":{"command":"npx","args":["-y","rea-agents@6.6.0","mcp"]}}}',
|
|
);
|
|
hold();
|
|
return base.inspectSkill?.();
|
|
},
|
|
};
|
|
try {
|
|
const result = await runUninstall(true, host);
|
|
expect(result.status).toBe("complete");
|
|
expect(result.items).toContainEqual(
|
|
expect.objectContaining({ name: "freebuff", status: "removed" }),
|
|
);
|
|
expect(await readFile(client.configPath, "utf8")).not.toContain("rea");
|
|
await expect(readFile(cacheOwned)).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
} finally {
|
|
await cleanupHeldHandle(host, release);
|
|
}
|
|
});
|
|
|
|
describe("ZCode fallback cleanup ownership", () => {
|
|
it.each(["preflight", "configure"])(
|
|
"retains a failed ZCode fallback close during %s until host cleanup",
|
|
async (operation) => {
|
|
const home = await createTestTempDirectory("rea-zcode-fallback-close-");
|
|
const host = systemSetupHost(
|
|
{ platform: "linux", homeDirectory: home } as DoctorHost,
|
|
{ HOME: home },
|
|
);
|
|
const client = (await host.supportedClients()).find(
|
|
({ name }) => name === "zcode",
|
|
);
|
|
if (client?.zcodeFallbackPath === undefined)
|
|
throw new Error("ZCode fallback path missing");
|
|
const fallback = client.zcodeFallbackPath;
|
|
await mkdir(dirname(fallback), { recursive: true });
|
|
const original = '{"mcpServers":{"other":{"command":"other"}}}\n';
|
|
await writeFile(fallback, original);
|
|
const { closeAttempts, release } = holdReadHandle(
|
|
fallback,
|
|
"held fallback handle",
|
|
);
|
|
try {
|
|
const action =
|
|
operation === "preflight"
|
|
? host.inspectClientConfiguration?.(client, {}, [
|
|
"npx",
|
|
"-y",
|
|
"rea-agents@6.6.0",
|
|
"mcp",
|
|
])
|
|
: host.configureClient(client, {}, [
|
|
"npx",
|
|
"-y",
|
|
"rea-agents@6.6.0",
|
|
"mcp",
|
|
]);
|
|
if (action === undefined) throw new Error("setup preflight missing");
|
|
await expect(action).rejects.toMatchObject({
|
|
_tag: "ConfigurationError",
|
|
cause: expect.any(RegularFileCleanupFailure),
|
|
cleanup: { resources: [fallback] },
|
|
});
|
|
expect(closeAttempts).toHaveLength(2);
|
|
expect(closeAttempts[0]).toBe(closeAttempts[1]);
|
|
expect(await readFile(fallback, "utf8")).toBe(original);
|
|
await expect(readFile(client.configPath)).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
await expectCloseReclaimsHandle(host, closeAttempts, release);
|
|
} finally {
|
|
await cleanupHeldHandle(host, release);
|
|
}
|
|
},
|
|
);
|
|
});
|
|
|
|
describe("setup client configuration cleanup ownership", () => {
|
|
it.each([
|
|
["valid UTF-8", Buffer.from('{"servers": {"other": {}}}\n')],
|
|
["malformed UTF-8", Buffer.from([0xff])],
|
|
] as const)(
|
|
"stops configuration and retains the %s read owner until host close",
|
|
async (encoding, original) => {
|
|
const { host, client } = await preparedVsCodeSetupHost(
|
|
"rea-setup-config-close-",
|
|
);
|
|
await writeFile(client.configPath, original);
|
|
|
|
const { closeAttempts, release } = holdReadHandle(
|
|
client.configPath,
|
|
"test holds the config handle open",
|
|
);
|
|
const configure = vi.spyOn(host, "configureClient");
|
|
|
|
try {
|
|
const failure = await filterClientsNeedingConfigure(
|
|
host,
|
|
[client],
|
|
{ providerEnvironment: {} },
|
|
["npx", "-y", "rea-agents@6.6.0", "mcp"],
|
|
)
|
|
.then((detectedClients) =>
|
|
configureDetectedClients({
|
|
host,
|
|
detectedClients,
|
|
providerEnvironment: {},
|
|
command: ["npx", "-y", "rea-agents@6.6.0", "mcp"],
|
|
clients: {},
|
|
appliedActions: [],
|
|
}),
|
|
)
|
|
.then(
|
|
() => undefined,
|
|
(cause: unknown) => cause,
|
|
);
|
|
expect(failure).toBeInstanceOf(ConfigurationError);
|
|
if (!(failure instanceof ConfigurationError))
|
|
throw new Error(
|
|
"Expected the configuration failure to retain cleanup authority",
|
|
);
|
|
if (encoding === "malformed UTF-8")
|
|
expect(failure).toMatchObject({
|
|
cause: {
|
|
outcome: { kind: "failed", cause: expect.any(TypeError) },
|
|
},
|
|
});
|
|
expect(failure).toMatchObject({
|
|
_tag: "ConfigurationError",
|
|
cause: expect.any(RegularFileCleanupFailure),
|
|
cleanup: {
|
|
resources: [client.configPath],
|
|
reason: expect.stringContaining(
|
|
"test holds the config handle open",
|
|
),
|
|
},
|
|
});
|
|
expect(configure).not.toHaveBeenCalled();
|
|
expect(closeAttempts).toHaveLength(2);
|
|
expect(closeAttempts[0]).toBe(closeAttempts[1]);
|
|
expect(
|
|
Buffer.compare(await readFile(client.configPath), original),
|
|
).toBe(0);
|
|
|
|
await expectCloseReclaimsHandle(host, closeAttempts, release);
|
|
expect(failure.cleanupIncomplete).toBe(false);
|
|
expect(failure.cleanupResources).toEqual([]);
|
|
} finally {
|
|
await cleanupHeldHandle(host, release);
|
|
}
|
|
},
|
|
);
|
|
|
|
it("waits for an admitted configuration read and rejects later admissions", async () => {
|
|
const { host, client } = await preparedVsCodeSetupHost(
|
|
"rea-setup-config-inflight-",
|
|
);
|
|
await writeFile(client.configPath, '{"servers": {}}\n');
|
|
|
|
const configurationRead = phaseGate();
|
|
let heldRead = false;
|
|
openMock.mockImplementation(async (...args) => {
|
|
const handle = await actualFs.open(...args);
|
|
if (String(args[0]) !== client.configPath || heldRead) return handle;
|
|
heldRead = true;
|
|
const nativeRead = handle.read.bind(handle);
|
|
vi.spyOn(handle, "read").mockImplementation(async (...readArgs) => {
|
|
await configurationRead.hold();
|
|
return nativeRead(...readArgs);
|
|
});
|
|
return handle;
|
|
});
|
|
|
|
let hostCloseFinished = false;
|
|
const alignment = host.clientNeedsConfigure(client, {}, [
|
|
"npx",
|
|
"-y",
|
|
"rea-agents@6.6.0",
|
|
"mcp",
|
|
]);
|
|
let closeResult: ReturnType<NonNullable<typeof host.close>> | undefined;
|
|
await withVerifierCleanup(async () => {
|
|
await configurationRead.reached(alignment, "configuration read");
|
|
|
|
const close = host.close;
|
|
if (close === undefined) throw new Error("Setup host close is missing");
|
|
closeResult = close().then((result) => {
|
|
hostCloseFinished = true;
|
|
return result;
|
|
});
|
|
|
|
const lateAdmission = await host
|
|
.clientNeedsConfigure(client, {}, [
|
|
"npx",
|
|
"-y",
|
|
"rea-agents@6.6.0",
|
|
"mcp",
|
|
])
|
|
.then(
|
|
() => undefined,
|
|
(cause: unknown) => cause,
|
|
);
|
|
expect(lateAdmission).toBeInstanceOf(ConfigurationError);
|
|
expect(lateAdmission).toMatchObject({
|
|
message: expect.stringContaining("Artifact resource scope is closed"),
|
|
});
|
|
expect(hostCloseFinished).toBe(false);
|
|
|
|
configurationRead.release();
|
|
await expect(alignment).resolves.toBe(true);
|
|
expect(await closeResult).toBeUndefined();
|
|
expect(hostCloseFinished).toBe(true);
|
|
}, [
|
|
configurationRead.release,
|
|
async () => {
|
|
await alignment;
|
|
},
|
|
async () => {
|
|
await closeResult;
|
|
},
|
|
async () => {
|
|
await host.close?.();
|
|
},
|
|
]);
|
|
});
|
|
});
|
|
|
|
const unscopedRegistrationReaders = [
|
|
...["configuration", "policy"].flatMap((source) =>
|
|
["completed", "failed"].map((readOutcome) => ({
|
|
name: "inspections",
|
|
source,
|
|
readOutcome,
|
|
read: (home: string, environment: NodeJS.ProcessEnv) =>
|
|
readClientRegistrationInspections(home, "/current/rea", {
|
|
platform: HOST_PLATFORM.platform,
|
|
environment,
|
|
}),
|
|
})),
|
|
),
|
|
{
|
|
name: "statuses",
|
|
source: "configuration",
|
|
readOutcome: "completed",
|
|
read: (home: string, environment: NodeJS.ProcessEnv) =>
|
|
readClientRegistrationStatuses(home, "/current/rea", {
|
|
platform: HOST_PLATFORM.platform,
|
|
environment,
|
|
}),
|
|
},
|
|
{
|
|
name: "maintenance plan",
|
|
source: "policy",
|
|
readOutcome: "failed",
|
|
read: (
|
|
home: string,
|
|
environment: NodeJS.ProcessEnv,
|
|
execute: Parameters<typeof planIntegrationMaintenance>[3],
|
|
) =>
|
|
planIntegrationMaintenance(home, "/current/rea", environment, execute, {
|
|
platform: HOST_PLATFORM.platform,
|
|
}),
|
|
},
|
|
];
|
|
|
|
it.each(unscopedRegistrationReaders)(
|
|
"$name transfers the exact $source owner after a $readOutcome read without a supplied scope",
|
|
async ({ read, source, readOutcome }) => {
|
|
const home = await createTestTempDirectory(
|
|
"rea-registration-unscoped-close-",
|
|
);
|
|
const config = join(
|
|
home,
|
|
source === "policy" ? ".gemini/settings.json" : ".cursor/mcp.json",
|
|
);
|
|
await mkdir(dirname(config), { recursive: true });
|
|
const registration =
|
|
'{"mcpServers":{"rea":{"command":"npx","args":["-y","rea-agents@6.6.0","mcp"]}}}\n';
|
|
await writeFile(config, registration);
|
|
const heldPath = source === "policy" ? join(home, "system.json") : config;
|
|
const heldText = source === "policy" ? "{}\n" : registration;
|
|
await writeFile(
|
|
heldPath,
|
|
readOutcome === "failed" ? Buffer.from([0xff]) : heldText,
|
|
);
|
|
const environment = {
|
|
HOME: home,
|
|
GEMINI_CLI_SYSTEM_SETTINGS_PATH: join(home, "system.json"),
|
|
GEMINI_CLI_SYSTEM_DEFAULTS_PATH: join(home, "absent-defaults.json"),
|
|
};
|
|
const held = holdReadHandle(
|
|
heldPath,
|
|
"held standalone registration descriptor",
|
|
);
|
|
const execute = vi.fn(async () =>
|
|
ok('{"status":"planned","plannedActions":[]}'),
|
|
);
|
|
try {
|
|
const outcome = await read(home, environment, execute).then(
|
|
(value) => ({ kind: "returned" as const, value }),
|
|
(cause: unknown) => ({ kind: "threw" as const, cause }),
|
|
);
|
|
expect(outcome).toMatchObject({
|
|
kind: "threw",
|
|
cause: expect.any(RegularFileCleanupFailure),
|
|
});
|
|
if (
|
|
outcome.kind !== "threw" ||
|
|
!(outcome.cause instanceof RegularFileCleanupFailure)
|
|
)
|
|
throw new Error("Read lost its failed cleanup owner");
|
|
const failure = outcome.cause;
|
|
expect(failure.path).toBe(heldPath);
|
|
if (readOutcome === "completed")
|
|
expect(failure.outcome).toEqual({ kind: "completed", value: heldText });
|
|
else
|
|
expect(failure.outcome).toMatchObject({
|
|
kind: "failed",
|
|
cause: { _tag: "InvalidUtf8FileError", path: heldPath },
|
|
});
|
|
expect(failure.owner.handle).toBe(held.closeAttempts[0]);
|
|
await expect(failure.owner.close()).rejects.toThrow("held standalone");
|
|
await rename(heldPath, `${heldPath}.retired`);
|
|
await writeFile(heldPath, "replacement");
|
|
held.release();
|
|
await failure.owner.close();
|
|
expect(failure.owner.handle.fd).toBe(-1);
|
|
expect(new Set(held.closeAttempts).size).toBe(1);
|
|
expect(await readFile(heldPath, "utf8")).toBe("replacement");
|
|
expect(execute).not.toHaveBeenCalled();
|
|
} finally {
|
|
held.release();
|
|
for (const handle of new Set(held.closeAttempts)) await handle.close();
|
|
}
|
|
},
|
|
);
|
|
|
|
it("keeps a supplied registration scope responsible for diagnostics and cleanup retry", async () => {
|
|
const home = await createTestTempDirectory("rea-registration-scoped-close-");
|
|
const config = join(home, ".cursor/mcp.json");
|
|
await mkdir(dirname(config), { recursive: true });
|
|
await writeFile(
|
|
config,
|
|
'{"mcpServers":{"rea":{"command":"npx","args":["-y","rea-agents@6.6.0","mcp"]}}}',
|
|
);
|
|
const held = holdReadHandle(config, "held scoped registration descriptor");
|
|
const resources = new ArtifactResourceScope();
|
|
try {
|
|
expect(
|
|
(
|
|
await readClientRegistrationStatuses(home, "/current/rea", {
|
|
platform: HOST_PLATFORM.platform,
|
|
environment: { HOME: home },
|
|
resources,
|
|
})
|
|
).find((status) => status.client === "cursor"),
|
|
).toMatchObject({ state: "invalid", command: [] });
|
|
expect(resources.hasPending).toBe(true);
|
|
await expect(resources.close()).rejects.toThrow();
|
|
held.release();
|
|
await resources.close();
|
|
expect(resources.hasPending).toBe(false);
|
|
expect(new Set(held.closeAttempts).size).toBe(1);
|
|
expect(held.closeAttempts[0]!.fd).toBe(-1);
|
|
} finally {
|
|
held.release();
|
|
await resources.close();
|
|
}
|
|
});
|
|
|
|
it("keeps a supplied maintenance scope responsible for a refresh-check read whose close fails", async () => {
|
|
const home = await createTestTempDirectory("rea-maintenance-refusal-close-");
|
|
const config = join(home, ".cursor/mcp.json");
|
|
await mkdir(dirname(config), { recursive: true });
|
|
const environment = { HOME: home };
|
|
const [command, ...args] = currentClientRegistrationCommand({
|
|
entrypointPath: "/current/rea",
|
|
environment,
|
|
});
|
|
await writeFile(
|
|
config,
|
|
JSON.stringify({ mcpServers: { rea: { command, args } } }),
|
|
);
|
|
// The registration inspection reads the file first; fail only the close of
|
|
// the refresh check's later read of the same file.
|
|
const closeAttempts: FileHandle[] = [];
|
|
let opens = 0;
|
|
let released = false;
|
|
openMock.mockImplementation(async (...openArgs) => {
|
|
const handle = await actualFs.open(...openArgs);
|
|
if (String(openArgs[0]) !== config) return handle;
|
|
opens += 1;
|
|
if (opens === 1) return handle;
|
|
const nativeClose = handle.close.bind(handle);
|
|
vi.spyOn(handle, "close").mockImplementation(async () => {
|
|
closeAttempts.push(handle);
|
|
if (!released) throw new Error("held refresh-check descriptor");
|
|
await nativeClose();
|
|
});
|
|
return handle;
|
|
});
|
|
const resources = new ArtifactResourceScope();
|
|
const execute = vi.fn(async () =>
|
|
ok('{"status":"planned","plannedActions":[]}'),
|
|
);
|
|
try {
|
|
const maintenance = await planIntegrationMaintenance(
|
|
home,
|
|
"/current/rea",
|
|
environment,
|
|
execute,
|
|
{ platform: HOST_PLATFORM.platform, resources },
|
|
);
|
|
expect(maintenance.status).toBe("unavailable");
|
|
expect(closeAttempts.length).toBeGreaterThan(0);
|
|
// The scope owns the failed close, so its close retries it.
|
|
expect(resources.hasPending).toBe(true);
|
|
await expect(resources.close()).rejects.toThrow();
|
|
released = true;
|
|
await resources.close();
|
|
expect(resources.hasPending).toBe(false);
|
|
expect(closeAttempts.every((handle) => handle.fd === -1)).toBe(true);
|
|
expect(execute).not.toHaveBeenCalled();
|
|
} finally {
|
|
released = true;
|
|
await resources.close();
|
|
}
|
|
});
|
|
|
|
it.each([
|
|
["system file", "linux", "system/opencode.json", "{}"],
|
|
[
|
|
"managed preferences",
|
|
"darwin",
|
|
"managed/ai.opencode.managed.plist",
|
|
'<?xml version="1.0"?><plist version="1.0"><dict/></plist>',
|
|
],
|
|
] as const)(
|
|
"retains the owner of an OpenCode %s read whose close fails",
|
|
async (_, platform, relative, content) => {
|
|
const home = await createTestTempDirectory("rea-opencode-upper-close-");
|
|
await mkdir(join(home, ".config", "opencode"), { recursive: true });
|
|
const path = join(home, relative);
|
|
await mkdir(dirname(path), { recursive: true });
|
|
await writeFile(path, content);
|
|
const { closeAttempts, release } = holdReadHandle(path, "held upper file");
|
|
const resources = new ArtifactResourceScope();
|
|
try {
|
|
const statuses = await readClientRegistrationStatuses(home, "rea", {
|
|
platform,
|
|
environment: {},
|
|
resources,
|
|
scope: "user",
|
|
systemPaths: {
|
|
openCodeSystemDirectory: join(home, "system"),
|
|
openCodeManagedPreferencesDirectory: join(home, "managed"),
|
|
},
|
|
});
|
|
expect(
|
|
statuses.find(({ client }) => client === "opencode"),
|
|
).toMatchObject({ state: "unknown" });
|
|
const attempts = closeAttempts.length;
|
|
release();
|
|
await resources.close();
|
|
expect(closeAttempts.length).toBeGreaterThan(attempts);
|
|
expect(closeAttempts.at(-1)).toBe(closeAttempts[0]);
|
|
} finally {
|
|
release();
|
|
await resources.close();
|
|
}
|
|
},
|
|
);
|