Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

workbenchthis machine

The so101 CLI runs under Node: `node bin/so101 --help` and `ports` no longer reach bun:sqlite #573

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

smith/arm:smith/570-the-so101-cli-runs-under-node-node-bin-s → main 1 commit fork

  • Merged. smith/570-the-so101-cli-runs-under-node-node-bin-s was merged into main as 7583cb5.

Review

Sign in to review this change.
2 files changed +42 −1
Software/so101/src/cli-node.test.ts added +41
@@ -0,0 +1,41 @@
1 import { expect, test } from "bun:test";
2 import { spawnSync } from "node:child_process";
3 import { readFileSync } from "node:fs";
4
5 // The README promises a fresh clone runs under Node 22.6+ (types stripped at load). A Bun-only import reached from the CLI
6 // (bun:sqlite, say) crashes it on a laptop while every Bun test passes.
7 const version = spawnSync("node", ["--version"], { encoding: "utf8" });
8 const [major = 0, minor = 0] = (version.stdout ?? "").replace(/^v/, "").split(".").map(Number);
9 const strips = version.status === 0 && (major > 22 || (major === 22 && minor >= 6));
10 const cli = new URL("../bin/so101", import.meta.url).pathname;
11
12 function so101(...args: string[]) {
13 return spawnSync("node", ["--experimental-strip-types", "--no-warnings", cli, ...args], { encoding: "utf8", timeout: 30_000 });
14 }
15
16 test.skipIf(!strips)("--help and ports run under Node", () => {
17 const help = so101("--help");
18 expect(help.stderr).toBe("");
19 expect(help.stdout).toContain("usage: so101");
20 expect(help.status).toBe(0);
21 expect(so101("ports").status).toBe(0);
22 });
23
24 test("the CLI's static imports never reach a bun: module", () => {
25 const seen = new Set<string>();
26 const offenders: string[] = [];
27 const walk = (url: URL) => {
28 if (seen.has(url.href)) return;
29 seen.add(url.href);
30 const source = readFileSync(url, "utf8");
31 // static only: `import … from "x"` and `export … from "x"`, not dynamic import()
32 for (const match of source.matchAll(/^\s*(?:import|export)\b[^;]*?\bfrom\s+["']([^"']+)["']|^\s*import\s+["']([^"']+)["']/gm)) {
33 const spec = match[1] ?? match[2] ?? "";
34 if (spec.startsWith("bun:") || spec === "bun") offenders.push(`${url.pathname} imports ${spec}`);
35 else if (spec.startsWith(".")) walk(new URL(spec, url));
36 }
37 };
38 walk(new URL("./cli.ts", import.meta.url));
39 expect(seen.size).toBeGreaterThan(3);
40 expect(offenders).toEqual([]);
41 });
Software/so101/src/cli.ts +1 −1
@@ -6,7 +6,6 @@ import { describeError, hex } from "./protocol.ts";
66 import { MAX_FRAME_STEP, MotionError, moveToPose, name as jointName, playTrajectory, recordTrajectory, sleep } from "./motion.ts";
77 import { streamLeader } from "./leader.ts";
88 import { assertPoseName, parsePoseFile, serializePoseFile, type PoseFile } from "./poses.ts";
9 import { startServer } from "./server.ts";
109 import { durationSeconds, largestStep, parseTrajectory, serializeTrajectory } from "./trajectory.ts";
1110 import {
1211 BAUD_RATES,
@@ -498,6 +497,7 @@ const COMMANDS: Record<string, Command> = {
498497 const [host, portText] = (values.listen ?? "0.0.0.0:8101").split(":");
499498 const port = bounded(integer(portText ?? "8101", "--listen port"), 1, 65535, "--listen port");
500499 return withBus(values, async (bus) => {
500 const { startServer } = await import("./server.ts"); // lazily: it reaches bun:sqlite, which Node lacks
501501 const server = await startServer(bus, { host, port, posesFile: values.file ?? "poses.json", modelDir: values.model, gainSyncMs: 2000 });
502502 console.log(`serving ${bus.path} on http://${host}:${server.port} — open it in a browser; the API is listed in src/server.ts`);
503503 console.log("ctrl-c to stop");

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs