Files
Rohit PrasadandDevika Verma d53e058eda Introduce OpenWorker Harness SDK (in beta), agent service cluster and relevant developer documentation (#844)
Allow developers to easily build AI apps without worrying about the harness part.
Bundles the Rust agent runtime as a SDK (Rust and TypeScript) for building desktop and web applications. Applications can manage a local harness or connect to an authenticated harness service on k8s with separately scaled workers and sandbox execution.

The implementation is primarily contained in harness/, with deployment tooling in deploy/, Markdown guides in docs/harness/guides/, and the static documentation site in docs-site/. It does not replace the existing Python harness or migrate OpenWorker Desktop.

Co-authored-by: Devika Verma <devikaverma11@gmail.com>
2026-11-06 09:45:20 -08:00

47 lines
1.3 KiB
JavaScript

import { spawn } from "node:child_process";
import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
const npm = process.platform === "win32" ? "npm.cmd" : "npm";
const run = (args) =>
new Promise((resolve, reject) => {
const p = spawn(npm, args, {
stdio: "inherit",
shell: process.platform === "win32",
});
p.on("exit", (code) =>
code === 0 ? resolve() : reject(new Error("Build failed")),
);
});
await run(["run", "sdk"]);
await run(["run", "build:main"]);
const vite = spawn(process.execPath, ["node_modules/vite/bin/vite.js"], {
stdio: "inherit",
});
let electron;
const close = () => {
electron?.kill();
vite.kill();
};
process.on("SIGINT", close);
process.on("SIGTERM", close);
try {
for (let n = 0; n < 100; n++) {
try {
if ((await fetch("http://127.0.0.1:5184")).ok) break;
} catch {}
if (n === 99) throw new Error("The app UI did not start.");
await new Promise((r) => setTimeout(r, 100));
}
electron = spawn(require("electron"), ["."], {
stdio: "inherit",
env: { ...process.env, ARCADE_DEV_URL: "http://127.0.0.1:5184" },
});
electron.on("exit", (code) => {
vite.kill();
process.exitCode = code ?? 0;
});
} catch (e) {
close();
throw e;
}