Files
paseo/scripts/trace-daemon-dist.test.mjs
T
paseo-bot[bot] ed87679c67 fix(nix): ship the OpenCode v2 bridge plugin in the daemon closure (#5988)
The Nix package copies only what scripts/trace-daemon.mjs lists. The list
named the v1 bridge bundle but not opencode/v2/bridge-plugin.bundle.mjs,
so creating an OpenCode v2 agent from the Nix package failed with
"Bundled OpenCode bridge plugin artifact is missing".

List every bridge bundle under opencode/, and add a dist test that
installs the traced closure the way nix/package.nix does and loads the
bridge plugin for each OpenCode version from it.

Closes #5926

Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
2026-10-03 23:16:11 +01:00

47 lines
1.7 KiB
JavaScript

import assert from "node:assert/strict";
import { execFile } from "node:child_process";
import { cp, mkdtemp, rm } from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import test from "node:test";
import { fileURLToPath, pathToFileURL } from "node:url";
import { promisify } from "node:util";
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const bridgeModule = "packages/server/dist/server/server/agent/providers/opencode/bridge.js";
// Mirrors nix/package.nix's installPhase: copy every traced path into $out.
async function installTracedDaemon(outRoot) {
const { stdout } = await promisify(execFile)(
process.execPath,
[path.join(repoRoot, "scripts/trace-daemon.mjs")],
{ cwd: repoRoot, maxBuffer: 64 * 1024 * 1024 },
);
for (const file of stdout.split("\n").filter(Boolean)) {
await cp(path.join(repoRoot, file), path.join(outRoot, file), {
recursive: true,
verbatimSymlinks: true,
});
}
}
test("traced daemon closure ships the OpenCode bridge plugin for every OpenCode version", async () => {
const outRoot = await mkdtemp(path.join(os.tmpdir(), "trace-daemon-dist-"));
try {
await installTracedDaemon(outRoot);
const installedBridgeUrl = pathToFileURL(path.join(outRoot, bridgeModule)).href;
const { loadOpenCodeBridgePluginArtifact } = await import(installedBridgeUrl);
for (const version of [1, 2]) {
const artifact = await loadOpenCodeBridgePluginArtifact(
installedBridgeUrl,
undefined,
version,
);
assert.ok(artifact.byteLength > 0, `OpenCode v${version} bridge plugin is empty`);
}
} finally {
await rm(outRoot, { recursive: true, force: true });
}
});