Files
paseo/packages/server/scripts/build-opencode-bridge-plugin.mjs
T
Matt CowgerandMohamed Boudra 74613e4bc3 feat(opencode): reuse running OpenCode v2 services (#7435)
* feat(opencode): connect v2 client to an existing server

* feat(providers): reuse running agent servers

Keep shared server sessions isolated and retain native tools while refreshes reuse the running service.

* fix(providers): recognize formatted bridge manifests

Managed plugin ownership must survive harmless JSON formatting changes.

* test(providers): distinguish isolated session bindings

Use separate session identities to verify that dedicated helpers keep their environments isolated.

---------

Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
2026-10-31 18:55:24 +07:00

37 lines
1002 B
JavaScript

import { copyFile, mkdir } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { build } from "esbuild";
for (const directory of ["", "v2/"]) {
const sourcePath = fileURLToPath(
new URL(
`../src/server/agent/providers/opencode/${directory}bridge-plugin.mjs`,
import.meta.url,
),
);
const outputPath = fileURLToPath(
new URL(
`../dist/server/server/agent/providers/opencode/${directory}bridge-plugin.bundle.mjs`,
import.meta.url,
),
);
await mkdir(path.dirname(outputPath), { recursive: true });
await build({
entryPoints: [sourcePath],
bundle: true,
format: "esm",
platform: "neutral",
mainFields: ["module", "main"],
target: "es2022",
outfile: outputPath,
});
if (directory === "v2/") {
await copyFile(
new URL("../src/server/agent/providers/opencode/v2/state.mjs", import.meta.url),
path.join(path.dirname(outputPath), "state.mjs"),
);
}
}