Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
import assert from "node:assert/strict";
import test from "node:test";
import { remoteHostErrorKey } from "../src/lib/remote-host-errors.ts";
import { remoteEn, remoteZh } from "../src/locales/remote.ts";
test("remoteHostErrorKey maps a failed SSH bootstrap to a dedicated message", () => {
const error = Object.assign(new Error("ssh command failed with exit code 255: Permission denied, please try again."), {
errorCode: "HOST_BOOTSTRAP_FAILED",
});
assert.equal(remoteHostErrorKey(error), "remote:hostBootstrapFailed");
});
test("remoteHostErrorKey reads the IPC-wire `code` field as a fallback", () => {
const error = Object.assign(new Error("bootstrap failed"), { code: "HOST_BOOTSTRAP_FAILED" });
assert.equal(remoteHostErrorKey(error), "remote:hostBootstrapFailed");
});
test("remoteHostErrorKey falls back to the generic message for an unmapped code", () => {
const error = Object.assign(new Error("boom"), { errorCode: "SOME_UNKNOWN_CODE" });
assert.equal(remoteHostErrorKey(error), "remote:operationFailed");
});
test("only an explicit unpublished macOS target gets the platform explanation", () => {
for (const target of ["darwin-x64", "darwin-arm64"]) {
assert.equal(remoteHostErrorKey({ code: "HOST_BOOTSTRAP_FAILED", details: { target } }), "remote:hostPlatformUnsupported");
}
for (const target of ["linux-x64", "unknown", null]) {
assert.equal(remoteHostErrorKey({ code: "HOST_BOOTSTRAP_FAILED", details: { target } }), "remote:hostBootstrapFailed");
}
assert.match(remoteEn.hostPlatformUnsupported, /Linux/);
assert.match(remoteZh.hostPlatformUnsupported, /macOS/);
});
test("hostBootstrapFailed has an English and Chinese translation distinct from the generic fallback", () => {
assert.equal(typeof remoteEn.hostBootstrapFailed, "string");
assert.equal(typeof remoteZh.hostBootstrapFailed, "string");
assert.notEqual(remoteEn.hostBootstrapFailed, remoteEn.operationFailed);
assert.notEqual(remoteZh.hostBootstrapFailed, remoteZh.operationFailed);
});