mirror of
https://github.com/nightly-labs/openbot.git
synced 2026-12-02 02:33:10 +08:00
* feat: ship a Linux x64 AppImage OpenBot shipped macOS and Windows only. This adds the third target as an AppImage, the one Linux format electron-updater can update in place. - Pin `linux-x64` artifacts for codex, claude, opencode, and grok, so the in-app provider download works as it does on macOS. - Discover a CLI through `$SHELL` on Linux instead of `/bin/zsh`, which most distributions do not install, and look in `/usr/bin` as well. - Register the `openbot://` scheme on Linux, and update in place only when `APPIMAGE` says the app runs from an AppImage. - Report voice transcription as unavailable when the build carries no whisper binary, rather than failing at transcribe time. The composer offers no microphone on Linux. - Move the whisper and remote-desktop resources out of the shared `extraResources` list, because neither is built for Linux. - Ship an AppArmor profile for the Ubuntu 23.10 and Debian 13 user-namespace restriction. `--no-sandbox` stays out of the product and the documentation. - Add the release job, the package verifier, the download route, and the install and troubleshooting sections. Remote desktop stays unavailable on Linux, and the AppImage is unsigned, as the Windows installer is. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(linux): install a desktop entry and keep the sandbox on in CI The protocol registration on Linux goes through `xdg-settings`, which can only name a desktop entry that already exists. An AppImage has none, so the first start now writes `~/.local/share/applications/openbot.desktop` with an `Exec` that points at the running AppImage and accepts `%U`, and a failed registration is logged instead of ignored. Ubuntu 24.04 restricts unprivileged user namespaces through AppArmor, so the release job loads a narrow profile for the verification executable and gives the SUID helper the ownership a package manager would give it. `--no-sandbox` stays out of the tree: the launch check must prove what a real install does. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(linux): keep the launcher icon after the AppImage unmounts An AppImage mounts its resources in a temporary directory the runtime removes on exit, so a desktop entry that names the packaged icon loses it as soon as OpenBot is not running. The first start now copies the icon to `<data home>/icons` and names the copy. A copy that fails still leaves the entry, because the entry is what registers the invitation scheme. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
101 lines
4.2 KiB
TypeScript
101 lines
4.2 KiB
TypeScript
// @vitest-environment node
|
|
|
|
import { execFileSync } from "node:child_process";
|
|
import { chmod, mkdir, mkdtemp, readFile, rm, stat, symlink, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
import { loadAgentRuntimeLock } from "./agent-runtime-lock";
|
|
import { installCodexRuntime, validateCodexArchive } from "./install-codex-runtime";
|
|
import { sha256 } from "./remote-desktop-runtime-release";
|
|
|
|
const temporaryPaths: string[] = [];
|
|
|
|
afterEach(async () => {
|
|
await Promise.all(temporaryPaths.splice(0).map((path) => rm(path, { recursive: true, force: true })));
|
|
});
|
|
|
|
describe.runIf(process.platform !== "win32")("bundled Codex installer", () => {
|
|
// The fixture entrypoint is a shell script, so a Linux target installs and verifies on macOS too.
|
|
it.each([
|
|
["darwin-arm64", "aarch64-apple-darwin", "mac/arm64"],
|
|
["linux-x64", "x86_64-unknown-linux-musl", "linux/x64"],
|
|
] as const)(
|
|
"installs a verified %s package into %s and reuses the current runtime",
|
|
async (target, manifestTarget, directory) => {
|
|
const root = await temporaryRoot();
|
|
const fixture = join(root, "fixture");
|
|
const archive = join(root, "codex.tar.gz");
|
|
const output = join(root, "output");
|
|
await createPackage(fixture, manifestTarget);
|
|
createArchive(fixture, archive);
|
|
const archiveBytes = await readFile(archive);
|
|
const license = Buffer.from("Apache License fixture\n");
|
|
const lock = structuredClone(await loadAgentRuntimeLock());
|
|
lock.codex.artifacts[target].assetSha256 = sha256(archiveBytes);
|
|
lock.codex.licenseSha256 = sha256(license);
|
|
const fetchImpl = async (input: string | URL | Request) =>
|
|
new Response(String(input).endsWith("/LICENSE") ? license : archiveBytes, { status: 200 });
|
|
|
|
await expect(installCodexRuntime({ outputRoot: output, target, fetchImpl, lock })).resolves.toBe("installed");
|
|
await expect(installCodexRuntime({ outputRoot: output, target, fetchImpl, lock })).resolves.toBe("current");
|
|
await expect(readFile(join(output, directory, "codex-package.json"), "utf8")).resolves.toContain('"0.153.4"');
|
|
await expect(readFile(join(output, "licenses/Codex-Apache-2.0.txt"), "utf8")).resolves.toBe(
|
|
license.toString("utf8"),
|
|
);
|
|
const mode = (await stat(join(output, directory, "bin/codex"))).mode & 0o777;
|
|
expect(mode).toBe(0o755);
|
|
},
|
|
);
|
|
|
|
it("rejects links in an archive before extraction", async () => {
|
|
const root = await temporaryRoot();
|
|
const fixture = join(root, "fixture");
|
|
const archive = join(root, "unsafe.tar.gz");
|
|
await createPackage(fixture);
|
|
await symlink("codex", join(fixture, "bin/codex-link"));
|
|
createArchive(fixture, archive);
|
|
|
|
expect(() => validateCodexArchive(archive)).toThrow("link or a special file");
|
|
});
|
|
});
|
|
|
|
async function temporaryRoot(): Promise<string> {
|
|
const root = await mkdtemp(join(tmpdir(), "openbot-codex-runtime-test-"));
|
|
temporaryPaths.push(root);
|
|
return root;
|
|
}
|
|
|
|
async function createPackage(root: string, manifestTarget = "aarch64-apple-darwin"): Promise<void> {
|
|
await Promise.all([
|
|
mkdir(join(root, "bin"), { recursive: true }),
|
|
mkdir(join(root, "codex-path"), { recursive: true }),
|
|
mkdir(join(root, "codex-resources/zsh/bin"), { recursive: true }),
|
|
]);
|
|
await Promise.all([
|
|
writeFile(join(root, "bin/codex"), "#!/bin/sh\nprintf 'codex-cli 0.153.4\\n'\n"),
|
|
writeFile(join(root, "bin/codex-code-mode-host"), "host\n"),
|
|
writeFile(join(root, "codex-path/rg"), "rg\n"),
|
|
writeFile(join(root, "codex-resources/zsh/bin/zsh"), "zsh\n"),
|
|
writeFile(
|
|
join(root, "codex-package.json"),
|
|
`${JSON.stringify({
|
|
layoutVersion: 1,
|
|
version: "0.153.4",
|
|
target: manifestTarget,
|
|
variant: "codex",
|
|
entrypoint: "bin/codex",
|
|
resourcesDir: "codex-resources",
|
|
pathDir: "codex-path",
|
|
})}\n`,
|
|
),
|
|
]);
|
|
await chmod(join(root, "bin/codex"), 0o755);
|
|
}
|
|
|
|
function createArchive(root: string, archive: string): void {
|
|
execFileSync("tar", ["-czf", archive, "-C", root, "bin", "codex-package.json", "codex-path", "codex-resources"], {
|
|
stdio: "inherit",
|
|
});
|
|
}
|