Skip to content

Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.

Check the runtime health with Bun instead of python3 (#659)

Asem ahmed72bec0cf00a5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cc5dee86..c2067fd1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -63,6 +63,14 @@ The computer now mints a run for each Bot's browser session, mints a new one whe
and answers which run it is on. Nothing changes for a deployment that already reports one, and a
computer too old to answer leaves the ordering exactly where it was rather than refusing anything.
+### `scripts/start.sh` no longer needs python3
+
+The runtime health check in step 3 was a `python3` heredoc. On a machine without Python, and on
+Windows, where `python3` is usually the Microsoft Store alias that exits 49, the run stopped there
+with the server and worker up and the app never started. The check now runs in Bun, which the
+script already requires, with the same output and exit status, and `python3` is gone from the
+prerequisites in `docs/development.md`.
+
### An MCP tool that answers with a resource link is no longer read as an empty name
A tool that points at a file or a page often returns a `resource_link`: a URI, a name, and a
diff --git a/docs/development.md b/docs/development.md
index 08d7869e..ade36ded 100644
--- a/docs/development.md
+++ b/docs/development.md
@@ -2,7 +2,7 @@
## Setup
-Install Docker, [Bun](https://bun.sh) 1.3+, `lsof`, `python3`, `openssl`, and `curl`. The
+Install Docker, [Bun](https://bun.sh) 1.3+, `lsof`, `openssl`, and `curl`. The
Intelligence provisioning below also needs `npx` (Node); `scripts/start.sh` uses `openssl` to mint
the generated secrets on a first run.
diff --git a/scripts/start-restart-guard.test.ts b/scripts/start-restart-guard.test.ts
index 0373ff75..984255c0 100644
--- a/scripts/start-restart-guard.test.ts
+++ b/scripts/start-restart-guard.test.ts
@@ -133,7 +133,18 @@ exit 0
join(fakeBin, "sleep"),
"#!/usr/bin/env bash\nexit 0\n",
);
- await writeExecutable(join(fakeBin, "bun"), "#!/usr/bin/env bash\nexit 0\n");
+ // The runtime health check is a script piped into `bun run -`, so that one invocation is the real
+ // Bun: it is what decides whether the run carries on. Everything else Bun would start is faked.
+ await writeExecutable(
+ join(fakeBin, "bun"),
+ '#!/usr/bin/env bash\nif [ "$1" = run ] && [ "$2" = - ]; then exec "$REAL_BUN" "$@"; fi\nexit 0\n',
+ );
+ // What `python3` is on a stock Windows machine: the Microsoft Store alias, which runs nothing. A
+ // script that still needed it would stop at the health check in every test in this file.
+ await writeExecutable(
+ join(fakeBin, "python3"),
+ '#!/usr/bin/env bash\necho "Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Apps > Advanced app settings > App execution aliases." >&2\nexit 49\n',
+ );
try {
const child = Bun.spawn({
@@ -141,6 +152,7 @@ exit 0
cwd: directory,
env: {
PATH: `${fakeBin}:${process.env.PATH ?? ""}`,
+ REAL_BUN: process.execPath,
PKILL_LOG: logPath,
DOCKER_LOG: dockerLogPath,
CURL_LOG: curlLogPath,
@@ -189,6 +201,28 @@ describe("start.sh server restart guard", () => {
);
});
+describe("start.sh runtime health", () => {
+ /**
+ * THE LICENCE IS CHECKED WITHOUT PYTHON.
+ *
+ * The check used to be a `python3` heredoc. On Windows `python3` is usually the Microsoft Store
+ * alias, which exits 49, so `set -e` ended the run at "3/4 Runtime health" with the server and
+ * worker already up and the app never started. The fake `python3` beside this file's other fakes
+ * is that alias; the line below is only printed if the check ran, in Bun, and passed.
+ */
+ test("checks the licence and names the Bots without python3", async () => {
+ const result = await runStartWithStaleServerProbe(401);
+
+ expect({ exitCode: result.exitCode, stderr: result.stderr }).toEqual({
+ exitCode: 0,
+ stderr: "",
+ });
+ expect(result.stdout).toContain(
+ "licence valid · mode test · Bots: analyst",
+ );
+ });
+});
+
describe("start.sh under the wrong shell", () => {
/**
* THE WRONG INVOCATION SAYS SO, AND SAYING NOTHING IS THE DEFECT.
diff --git a/scripts/start.sh b/scripts/start.sh
index 58c1c6b9..06e57a94 100755
--- a/scripts/start.sh
+++ b/scripts/start.sh
@@ -147,7 +147,7 @@ holder() {
#
# When that happened here the cost was not a wrong answer, it was a wrong answer three stages later.
# `require_free_or_ours` reported "already up", the server was therefore never started, `wait_for`
-# printed a green "server ready", and the run died at stage 3 in `json.loads` on a mouthful of HTML —
+# printed a green "server ready", and the run died at stage 3 parsing a mouthful of HTML as JSON —
# a JSON parse error standing in for "that port belongs to something else".
#
# So each surface is asked for something only it can produce.
@@ -381,20 +381,26 @@ fi
info "3/4 Runtime health"
INFO="$(curl -fsS --max-time 8 "http://localhost:$SERVER_PORT/api/copilotkit/info")"
-python3 - "$INFO" <<'PY'
-import json, sys
-info = json.loads(sys.argv[1])
-status, agents = info.get("licenseStatus"), list(info.get("agents", {}))
-if status != "valid":
- print(f"\033[31m licence is '{status}', not 'valid'.\033[0m")
- print("\033[31m Check INTELLIGENCE_API_KEY: npx copilotkit@latest login && npx copilotkit@latest project select\033[0m")
- print("\033[31m See README.md for Intelligence setup.\033[0m")
- raise SystemExit(1)
-if not agents:
- print("\033[31m No Bots registered.\033[0m")
- raise SystemExit(1)
-print(f"\033[32m licence valid · mode {info.get('mode')} · Bots: {', '.join(agents)}\033[0m")
-PY
+# Read with Bun, which every run of this script already needs, rather than python3, which not every
+# machine has. On Windows `python3` is usually the Microsoft Store alias, which prints "Python was not
+# found" and exits 49, so the run stopped here with the server and worker up and the app never
+# started.
+bun run - "$INFO" <<'JS'
+const info = JSON.parse(process.argv[2]);
+const status = info.licenseStatus;
+const agents = Object.keys(info.agents ?? {});
+if (status !== "valid") {
+ console.log(`\x1b[31m licence is '${status}', not 'valid'.\x1b[0m`);
+ console.log("\x1b[31m Check INTELLIGENCE_API_KEY: npx copilotkit@latest login && npx copilotkit@latest project select\x1b[0m");
+ console.log("\x1b[31m See README.md for Intelligence setup.\x1b[0m");
+ process.exit(1);
+}
+if (agents.length === 0) {
+ console.log("\x1b[31m No Bots registered.\x1b[0m");
+ process.exit(1);
+}
+console.log(`\x1b[32m licence valid · mode ${info.mode} · Bots: ${agents.join(", ")}\x1b[0m`);
+JS
info "4/4 App"
require_free_or_ours "$APP_PORT" app