92c79d80c7
- Implement the OMP Browser Relay extension with WebSocket communication and CDP RPC execution. - Add browser relay server, daemon management, and bridge multiplexing in the coding agent. - Introduce CLI commands and settings schema options for configuring and installing the relay. - Add utility functions and test suites supporting environment parsing and relay lifecycle handling.
55 lines
2.1 KiB
TypeScript
55 lines
2.1 KiB
TypeScript
/**
|
|
* Builds the browser relay extension and its distribution artifacts:
|
|
* - `dist/extension/` — unpacked extension (load via chrome://extensions)
|
|
* - `dist/omp-browser-relay-extension.zip` — packaged extension for GH releases
|
|
* - `../coding-agent/src/tools/browser/relay/extension-assets/*.txt` —
|
|
* generated text assets embedded into the omp CLI so `omp browser-relay
|
|
* install` works from the compiled binary (same committed-generated-output
|
|
* pattern as tool-views.generated.js). Re-run this script after touching
|
|
* anything under `extension/` and commit the regenerated assets.
|
|
*
|
|
* Dependency-free on purpose: CI runs this without `bun install`.
|
|
*/
|
|
import * as fs from "node:fs/promises";
|
|
import * as path from "node:path";
|
|
import { $ } from "bun";
|
|
|
|
const root = path.resolve(import.meta.dir, "..");
|
|
const dist = path.join(root, "dist");
|
|
const distExtension = path.join(dist, "extension");
|
|
const assetsDir = path.resolve(root, "../coding-agent/src/tools/browser/relay/extension-assets");
|
|
|
|
await fs.rm(dist, { recursive: true, force: true });
|
|
await fs.mkdir(distExtension, { recursive: true });
|
|
|
|
const bundle = await Bun.build({
|
|
entrypoints: [path.join(root, "extension/background.ts")],
|
|
outdir: distExtension,
|
|
target: "browser",
|
|
sourcemap: "none",
|
|
});
|
|
if (!bundle.success) {
|
|
for (const log of bundle.logs) console.error(log);
|
|
process.exit(1);
|
|
}
|
|
|
|
for (const file of ["manifest.json", "options.html", "options.js"]) {
|
|
await Bun.write(path.join(distExtension, file), Bun.file(path.join(root, "extension", file)));
|
|
}
|
|
|
|
const zip = await $`zip -qr ../omp-browser-relay-extension.zip .`.cwd(distExtension).nothrow();
|
|
if (zip.exitCode !== 0) {
|
|
console.error("zip failed:", zip.stderr.toString());
|
|
process.exit(1);
|
|
}
|
|
|
|
await fs.rm(assetsDir, { recursive: true, force: true });
|
|
for (const file of ["background.js", "manifest.json", "options.html", "options.js"]) {
|
|
await Bun.write(path.join(assetsDir, `${file}.txt`), Bun.file(path.join(distExtension, file)));
|
|
}
|
|
|
|
console.log("built:");
|
|
console.log(` ${distExtension}`);
|
|
console.log(` ${path.join(dist, "omp-browser-relay-extension.zip")}`);
|
|
console.log(` ${assetsDir} (embedded CLI assets — commit these)`);
|