bot-use 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -2
  3. package/index.d.ts +104 -0
  4. package/index.js +251 -0
  5. package/package.json +27 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dheeraj Pai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,72 @@
1
- # Temporary Holding Version
1
+ # bot-use (npm)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Let AI agents use robots.** A zero-dependency TypeScript/JavaScript client for the bot-use robot server.
4
+
5
+ [![bot-use: Claude, ChatGPT, Codex or Praxis-1 for robotics. SO-101 arms putting a banana on a plate, cleaning up and wiping a table.](https://bot-use.com/media/readme/hero.gif)](https://bot-use.com)
6
+
7
+ <!-- Video placeholders. npm can't play video in a README, so each poster is an image linking to the video.
8
+ To swap one in: replace the PNG at https://bot-use.com/media/readme/<name>.png with a real frame from the clip
9
+ and point the link at the clip. Posters live in site/media/readme/. -->
10
+
11
+ [![Your own app drives the robot](https://bot-use.com/media/readme/npm-app.png)](https://bot-use.com/#demo)
12
+
13
+ | | |
14
+ |---|---|
15
+ | [![Claude Code drives a real SO-101 arm](https://bot-use.com/media/readme/demo.png)](https://bot-use.com/#demo)<br>**An agent drives a real SO-101.** | [![Drive the arm from your phone](https://bot-use.com/media/readme/teleop.png)](https://bot-use.com/#can-do)<br>**Live teleop.** The same controls `BotUseTeleop` streams. |
16
+
17
+ The robot side (motor drivers, safety layer, 50-100 Hz control loop, calibration, camera) is the Python
18
+ package [`bot-use`](https://pypi.org/project/bot-use/). Run its server on the machine the robot is plugged into:
19
+
20
+ ```bash
21
+ uv add "bot-use[all]"
22
+ bot-use serve --port 8766 --token secret # or: bot-use --sim serve (no hardware)
23
+ ```
24
+
25
+ Then from Node 18+ or Bun:
26
+
27
+ ```bash
28
+ bun add bot-use
29
+ ```
30
+
31
+ ```ts
32
+ import { BotUse } from "bot-use";
33
+
34
+ const robot = new BotUse({ url: "http://127.0.0.1:8766", token: "secret" });
35
+ console.log((await robot.state()).text);
36
+ console.log((await robot.moveToPose("ready")).text); // a feedback digest you can hand to a model
37
+ const tools = await robot.tools(); // JSON-schema tool specs for any LLM SDK
38
+ await robot.call("pick_at", { cell: "C4" });
39
+ await robot.stop();
40
+ ```
41
+
42
+ ## Live teleop (`bu teleop`)
43
+
44
+ For custom apps (React Native, a web UI, a game controller bridge), stream the same controls the bot-use phone page
45
+ uses. The robot moves only while `hold(true)` is on and commands keep arriving (0.4 s deadman):
46
+
47
+ ```ts
48
+ import { BotUseTeleop } from "bot-use";
49
+
50
+ const t = await new BotUseTeleop({ url: "http://<robot-computer>:8770", key: "<key from the bu teleop URL>" }).connect();
51
+ t.onState = (s) => console.log(s.tip, s.grip);
52
+ t.hold(true);
53
+ const timer = setInterval(() => t.tip([0, 0, 3]), 33); // gripper up at 3 cm/s
54
+ setTimeout(() => { clearInterval(timer); t.hold(false); }, 1000);
55
+ ```
56
+
57
+ Also `joints({ elbow_flex: 30 })`, `jog(joint, degPerS)`, `grip(pct)`, `speed(f)`, `pose(name)`, `skill(name)`, `stop()`.
58
+
59
+ Robot-side errors (out of reach, unknown pose, latched fault) come back as `{ is_error: true, text }` so an
60
+ agent can read and correct them; transport errors throw `BotUseError`.
61
+
62
+ ## Usage data
63
+
64
+ This package collects usage data, on by default and never asked:
65
+ - **Sent:** which client class was created, package, OS and runtime versions, and the errors it sees. Keys, tokens and emails are masked.
66
+ - **Recorded by our analytics provider:** the IP address.
67
+ - **Recorded by the Python server, not this package:** what your robot is asked to do.
68
+
69
+ Full list: https://bot-use.com/docs.html#14_usage_data. Turn it off with `bu telemetry off`, `DO_NOT_TRACK=1` or
70
+ `BOT_USE_TELEMETRY=0`. Turning it off is recorded once, then nothing more is sent.
71
+
72
+ Docs: https://bot-use.com/docs · License: MIT
package/index.d.ts ADDED
@@ -0,0 +1,104 @@
1
+ export declare const version: string;
2
+
3
+ export interface ToolSpec {
4
+ name: string;
5
+ description: string;
6
+ input_schema: Record<string, unknown>;
7
+ }
8
+
9
+ export interface ToolImage {
10
+ mime_type: string;
11
+ base64: string;
12
+ }
13
+
14
+ export interface ToolResult {
15
+ /** The feedback digest: what happened, events, health. Written to be read by a model. */
16
+ text: string;
17
+ is_error: boolean;
18
+ data: Record<string, unknown> | null;
19
+ images: ToolImage[];
20
+ }
21
+
22
+ export interface Health {
23
+ ok: boolean;
24
+ robot: string;
25
+ version: string;
26
+ sim: boolean;
27
+ }
28
+
29
+ export interface BotUseOptions {
30
+ /** Default http://127.0.0.1:8766 (start the server with `bot-use serve`). */
31
+ url?: string;
32
+ /** Bearer token if the server was started with --token. */
33
+ token?: string;
34
+ /** Per-request timeout, default 180000 ms. */
35
+ timeoutMs?: number;
36
+ fetch?: typeof fetch;
37
+ }
38
+
39
+ export declare class BotUseError extends Error {
40
+ status?: number;
41
+ body?: unknown;
42
+ }
43
+
44
+ export interface MoveOptions {
45
+ /** 0.05..1 fraction of max joint speed. */
46
+ speed?: number;
47
+ /** false: return immediately; follow with watch(). */
48
+ wait?: boolean;
49
+ /** Also return a camera image after the move. */
50
+ look?: boolean;
51
+ }
52
+
53
+ export declare class BotUse {
54
+ constructor(options?: BotUseOptions);
55
+ readonly url: string;
56
+ health(): Promise<Health>;
57
+ tools(): Promise<ToolSpec[]>;
58
+ call(name: string, args?: Record<string, unknown>): Promise<ToolResult>;
59
+ state(): Promise<{ text: string; state: Record<string, unknown> }>;
60
+ look(camera?: string): Promise<Uint8Array>;
61
+ stop(): Promise<{ text: string }>;
62
+ moveToPose(name: string, opts?: MoveOptions): Promise<ToolResult>;
63
+ moveJoints(targets: Record<string, number>, opts?: MoveOptions & { relative?: boolean }): Promise<ToolResult>;
64
+ moveTip(xyz: { x?: number; y?: number; z?: number }, opts?: MoveOptions & { relative?: boolean }): Promise<ToolResult>;
65
+ grip(loadPct?: number): Promise<ToolResult>;
66
+ release(): Promise<ToolResult>;
67
+ watch(seconds?: number, opts?: { until?: string[]; look?: boolean }): Promise<ToolResult>;
68
+ nudge(d: { dx?: number; dy?: number; dz?: number }): Promise<ToolResult>;
69
+ runSkill(name: string, args?: Record<string, unknown>): Promise<ToolResult>;
70
+ }
71
+
72
+ export interface TeleopState {
73
+ t: "state";
74
+ deg: Record<string, number>;
75
+ rad: Record<string, number>;
76
+ tip: [number, number, number] | null;
77
+ grip: number | null;
78
+ faults: string[];
79
+ action: string | null;
80
+ hold: boolean;
81
+ msg: string;
82
+ temp: number;
83
+ }
84
+
85
+ /** Live teleoperation over the `bu teleop` WebSocket. The robot moves only while hold(true) and commands keep coming. */
86
+ export declare class BotUseTeleop {
87
+ constructor(options?: { url?: string; key?: string; WebSocketImpl?: typeof WebSocket });
88
+ state: TeleopState | null;
89
+ onState: ((s: TeleopState) => void) | null;
90
+ connect(): Promise<BotUseTeleop>;
91
+ hold(on: boolean): void;
92
+ tip(v: [number, number, number]): void;
93
+ joints(targets: Record<string, number>): void;
94
+ jog(joint: string, v: number): void;
95
+ grip(pct: number): void;
96
+ speed(f: number): void;
97
+ ping(): void;
98
+ pose(name: string): void;
99
+ skill(name: string, args?: Record<string, unknown>): void;
100
+ stop(): void;
101
+ close(): void;
102
+ }
103
+
104
+ export default BotUse;
package/index.js ADDED
@@ -0,0 +1,251 @@
1
+ // bot-use: TypeScript/JavaScript client for the bot-use robot server.
2
+ // The motors, safety layer and control loop run in Python on the robot machine (`bot-use serve`);
3
+ // this client calls its JSON API. Zero dependencies: uses the global fetch (Node 18+, Bun, Deno, browsers).
4
+
5
+ export const version = "0.1.0";
6
+
7
+ // ---------------------------------------------------------------- usage data (always on)
8
+ // Same setting as the Python CLI (`bu telemetry on|off`, saved in ~/.bot-use/usage.json). Never asks.
9
+ // Turning it off (`bu telemetry off`, DO_NOT_TRACK=1 or BOT_USE_TELEMETRY=0) is itself logged once, then nothing.
10
+ // Node / Bun only (never in a browser). Sends: which client class was created, package and runtime versions, OS and
11
+ // OS version, and errors the client sees (keys / tokens / emails masked). PostHog also records the IP address.
12
+ // What the robot is asked to do is recorded by the Python server. Details: https://bot-use.com/docs.html#14_usage_data
13
+ const POSTHOG_KEY = "phc_EoMHKFbx6j2wUFsf8ywqgHntY4vEXC3ZzLFoPJVjRRT";
14
+ const POSTHOG_HOST = "https://d18m0xvdtnkibr.cloudfront.net";
15
+ let usageState = null; // Promise<{ id, os } | null>: null when off
16
+
17
+ function scrub(text) {
18
+ return String(text ?? "")
19
+ .replace(/sk-(?:ant-)?[A-Za-z0-9_-]{12,}/g, "<key>")
20
+ .replace(/(?:ghp|gho|ghs|github_pat)_[A-Za-z0-9_]{16,}/g, "<key>")
21
+ .replace(/(bearer\s+)[A-Za-z0-9._-]{8,}/gi, "$1<key>")
22
+ .replace(/((?:api[_-]?key|token|secret|password)\s*[=:]\s*)\S+/gi, "$1<key>")
23
+ .replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g, "<email>")
24
+ .slice(0, 1000);
25
+ }
26
+
27
+ async function send(id, os, event, props) {
28
+ await globalThis.fetch(`${POSTHOG_HOST}/i/v0/e/`, {
29
+ method: "POST",
30
+ headers: { "Content-Type": "application/json" },
31
+ body: JSON.stringify({ api_key: POSTHOG_KEY, event, distinct_id: id,
32
+ properties: { product: "bot-use", surface: "npm", bot_use_version: version, ...os,
33
+ $process_person_profile: false, ...props } }),
34
+ signal: AbortSignal.timeout(3000),
35
+ });
36
+ }
37
+
38
+ function usage() {
39
+ usageState ??= (async () => {
40
+ const proc = globalThis.process;
41
+ if (!proc?.versions?.node || typeof globalThis.window !== "undefined") return null;
42
+ const env = proc.env ?? {};
43
+ if (env.BOT_USE_USAGE_ENDPOINT === "off") return null; // tests: no network
44
+ const flag = String(env.BOT_USE_TELEMETRY ?? "").toLowerCase();
45
+ const envOff = (env.DO_NOT_TRACK && env.DO_NOT_TRACK !== "0") ? "DO_NOT_TRACK"
46
+ : ["0", "off", "false", "no"].includes(flag) ? "BOT_USE_TELEMETRY=0" : null;
47
+ const [{ readFile, writeFile, mkdir }, { homedir, platform, arch, release }, { join }, { randomUUID }] = await Promise.all(
48
+ [import("node:fs/promises"), import("node:os"), import("node:path"), import("node:crypto")]);
49
+ const home = env.BOT_USE_HOME || join(homedir(), ".bot-use");
50
+ const file = join(home, "usage.json");
51
+ let saved = {};
52
+ try { saved = JSON.parse(await readFile(file, "utf8")); } catch { /* first run */ }
53
+ const save = async () => { try { await mkdir(home, { recursive: true }); await writeFile(file, JSON.stringify(saved, null, 2) + "\n"); } catch { /* read-only home */ } };
54
+ if (!saved.id) { saved.id = randomUUID(); await save(); } // a random install id, shared with the Python CLI
55
+ const os = { os: platform(), os_version: release(), arch: arch(),
56
+ runtime: proc.versions.bun ? `bun ${proc.versions.bun}` : `node ${proc.versions.node}` };
57
+ if (envOff) { // turned off by the environment: say so once, then stay quiet
58
+ if (!saved.env_off_logged) { saved.env_off_logged = true; await save(); await send(saved.id, os, "telemetry_disabled", { how: envOff }); }
59
+ return null;
60
+ }
61
+ if (saved.enabled === false) return null; // `bu telemetry off` already logged it
62
+ return { id: saved.id, os };
63
+ })().catch(() => null);
64
+ return usageState;
65
+ }
66
+
67
+ function reportUsage(event, props = {}) {
68
+ usage().then((u) => u && send(u.id, u.os, event, props)).catch(() => { /* stats never affect the robot client */ });
69
+ }
70
+
71
+ export class BotUseError extends Error {
72
+ constructor(message, status, body) {
73
+ super(message);
74
+ this.name = "BotUseError";
75
+ this.status = status;
76
+ this.body = body;
77
+ reportUsage("npm_client_error", { status: status ?? null, error_message: scrub(message) });
78
+ }
79
+ }
80
+
81
+ export class BotUse {
82
+ /**
83
+ * @param {{url?: string, token?: string, timeoutMs?: number, fetch?: typeof fetch}} [options]
84
+ */
85
+ constructor(options = {}) {
86
+ this.url = (options.url ?? "http://127.0.0.1:8766").replace(/\/+$/, "");
87
+ this.token = options.token;
88
+ this.timeoutMs = options.timeoutMs ?? 180_000; // motions can take a while
89
+ this._fetch = options.fetch ?? globalThis.fetch;
90
+ if (!this._fetch) throw new BotUseError("no fetch available: use Node 18+ or pass options.fetch");
91
+ reportUsage("npm_client_created", { client: "BotUse" });
92
+ }
93
+
94
+ async _request(method, path, body) {
95
+ const headers = { "Content-Type": "application/json" };
96
+ if (this.token) headers.Authorization = `Bearer ${this.token}`;
97
+ const controller = new AbortController();
98
+ const timer = setTimeout(() => controller.abort(), this.timeoutMs);
99
+ let res;
100
+ try {
101
+ res = await this._fetch(`${this.url}${path}`, {
102
+ method,
103
+ headers,
104
+ body: body === undefined ? undefined : JSON.stringify(body),
105
+ signal: controller.signal,
106
+ });
107
+ } catch (err) {
108
+ throw new BotUseError(`can't reach the bot-use server at ${this.url} (is \`bot-use serve\` running?): ${err}`);
109
+ } finally {
110
+ clearTimeout(timer);
111
+ }
112
+ return res;
113
+ }
114
+
115
+ async _json(method, path, body) {
116
+ const res = await this._request(method, path, body);
117
+ const text = await res.text();
118
+ let data;
119
+ try {
120
+ data = text ? JSON.parse(text) : {};
121
+ } catch {
122
+ throw new BotUseError(`bad JSON from server (${res.status})`, res.status, text);
123
+ }
124
+ if (!res.ok && res.status !== 422) {
125
+ throw new BotUseError(data.error ?? `HTTP ${res.status}`, res.status, data);
126
+ }
127
+ return data;
128
+ }
129
+
130
+ /** Server and robot info. */
131
+ health() {
132
+ return this._json("GET", "/health");
133
+ }
134
+
135
+ /** Tool specs ({name, description, input_schema}) to hand to any LLM SDK. */
136
+ tools() {
137
+ return this._json("GET", "/tools");
138
+ }
139
+
140
+ /** Call any tool. Errors from the robot come back as {is_error: true, text}, not exceptions. */
141
+ call(name, args = {}) {
142
+ return this._json("POST", `/tools/${encodeURIComponent(name)}`, args);
143
+ }
144
+
145
+ /** Current state: {text, state}. */
146
+ state() {
147
+ return this._json("GET", "/state");
148
+ }
149
+
150
+ /** Annotated camera image as bytes (JPEG). */
151
+ async look(camera) {
152
+ const q = camera ? `?camera=${encodeURIComponent(camera)}` : "";
153
+ const res = await this._request("GET", `/look${q}`);
154
+ if (!res.ok) throw new BotUseError(`look failed: HTTP ${res.status}`, res.status, await res.text());
155
+ return new Uint8Array(await res.arrayBuffer());
156
+ }
157
+
158
+ /** Stop all motion now. */
159
+ stop() {
160
+ return this._json("POST", "/stop");
161
+ }
162
+
163
+ // Convenience wrappers over call()
164
+ moveToPose(name, opts = {}) {
165
+ return this.call("move_to_pose", { name, ...opts });
166
+ }
167
+ moveJoints(targets, opts = {}) {
168
+ return this.call("move_joints", { targets, ...opts });
169
+ }
170
+ moveTip(xyz, opts = {}) {
171
+ return this.call("move_tip", { ...xyz, ...opts });
172
+ }
173
+ grip(loadPct = 30) {
174
+ return this.call("grip", { load_pct: loadPct });
175
+ }
176
+ release() {
177
+ return this.call("release");
178
+ }
179
+ watch(seconds = 3, opts = {}) {
180
+ return this.call("watch", { seconds, ...opts });
181
+ }
182
+ nudge(d) {
183
+ return this.call("nudge", d);
184
+ }
185
+ runSkill(name, args = {}) {
186
+ return this.call(name, args);
187
+ }
188
+ }
189
+
190
+ /**
191
+ * Live teleoperation over the `bu teleop` WebSocket (~30 Hz). The robot only moves while `hold(true)` is active
192
+ * and commands keep arriving; stop sending for 0.4 s and it holds position (deadman).
193
+ *
194
+ * const t = new BotUseTeleop({ url: "http://192.168.1.20:8770", key: "abc123" });
195
+ * t.onState = (s) => console.log(s.tip);
196
+ * await t.connect();
197
+ * t.hold(true);
198
+ * t.tip([0, 0, 3]); // tip up at 3 cm/s: call repeatedly (e.g. every 33 ms) while moving
199
+ * t.hold(false);
200
+ */
201
+ export class BotUseTeleop {
202
+ constructor({ url = "http://127.0.0.1:8770", key = "", WebSocketImpl } = {}) {
203
+ this.url = url.replace(/\/+$/, "");
204
+ this.key = key;
205
+ this._WS = WebSocketImpl ?? globalThis.WebSocket;
206
+ reportUsage("npm_client_created", { client: "BotUseTeleop" });
207
+ if (!this._WS) throw new BotUseError("no WebSocket available: use Node 22+, Bun, a browser, or pass WebSocketImpl");
208
+ this.onState = null;
209
+ this.state = null;
210
+ this.ws = null;
211
+ }
212
+
213
+ connect() {
214
+ const wsUrl = this.url.replace(/^http/, "ws") + "/ws?k=" + encodeURIComponent(this.key);
215
+ return new Promise((resolve, reject) => {
216
+ const ws = new this._WS(wsUrl);
217
+ this.ws = ws;
218
+ ws.onopen = () => resolve(this);
219
+ ws.onerror = (e) => reject(new BotUseError(`teleop connection failed: ${e?.message ?? e}`));
220
+ ws.onmessage = (e) => {
221
+ this.state = JSON.parse(typeof e.data === "string" ? e.data : e.data.toString());
222
+ this.onState?.(this.state);
223
+ };
224
+ });
225
+ }
226
+
227
+ _send(m) {
228
+ if (this.ws?.readyState === 1) this.ws.send(JSON.stringify(m));
229
+ }
230
+
231
+ /** Deadman: the arm moves only while this is on and commands keep coming. */
232
+ hold(on) { this._send({ t: "hold", on: !!on }); }
233
+ /** Gripper tip velocity [vx, vy, vz] in cm/s (x forward, y left, z up). */
234
+ tip(v) { this._send({ t: "tip", v }); }
235
+ /** Absolute joint targets in degrees, e.g. { elbow_flex: 30 }. */
236
+ joints(targets) { this._send({ t: "joints", targets }); }
237
+ /** Joint velocity in deg/s. */
238
+ jog(joint, v) { this._send({ t: "jog", joint, v }); }
239
+ /** Gripper opening, 0 = closed .. 100. */
240
+ grip(pct) { this._send({ t: "grip", pct }); }
241
+ /** 0.1..1 of each joint's max speed. */
242
+ speed(f) { this._send({ t: "speed", f }); }
243
+ /** Keep the deadman alive without moving. */
244
+ ping() { this._send({ t: "ping" }); }
245
+ pose(name) { this._send({ t: "pose", name }); }
246
+ skill(name, args = {}) { this._send({ t: "skill", name, args }); }
247
+ stop() { this._send({ t: "stop" }); }
248
+ close() { this.ws?.close(); }
249
+ }
250
+
251
+ export default BotUse;
package/package.json CHANGED
@@ -1,6 +1,29 @@
1
1
  {
2
2
  "name": "bot-use",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Let AI agents use robots: a zero-dependency client for the bot-use robot server (Python).",
5
+ "type": "module",
6
+ "main": "./index.js",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./index.d.ts",
11
+ "default": "./index.js"
12
+ }
13
+ },
14
+ "files": ["index.js", "index.d.ts", "README.md", "LICENSE"],
15
+ "scripts": {
16
+ "test": "BOT_USE_USAGE_ENDPOINT=off bun test"
17
+ },
18
+ "keywords": ["robotics", "robots", "ai", "agents", "llm", "mcp", "so-101", "bot-use"],
19
+ "author": "Dheeraj Pai",
20
+ "license": "MIT",
21
+ "homepage": "https://bot-use.com",
22
+ "engines": {
23
+ "node": ">=18"
24
+ },
25
+ "sideEffects": false,
26
+ "publishConfig": {
27
+ "access": "public"
28
+ }
29
+ }