@0perator/operator 0.1.40 → 0.1.41

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.
package/dist/cli.js CHANGED
@@ -19,7 +19,7 @@ import { expandFileMentions } from "./util/mentions.js";
19
19
  import { join } from "node:path";
20
20
  import { homedir, hostname } from "node:os";
21
21
  import { createHash } from "node:crypto";
22
- const VERSION = "0.1.40";
22
+ const VERSION = "0.1.41";
23
23
  // operator/settings.json (override path via KODE_TSI_SETTINGS), env vars still win — see config/settings.ts.
24
24
  const settings = loadSettings();
25
25
  // Propagate the resolved sandbox mode to the tool layer (registry reads KODE_SANDBOX at exec time).
@@ -55,14 +55,23 @@ if (settings.services?.stopOnExit?.searxng === false)
55
55
  // mobile bundle never sees these tools.
56
56
  let computerAskRules = {};
57
57
  let computerDenyRules = {};
58
+ let embodimentHub; // chauffeur, scoped to embodiment
58
59
  if (settings.computer.enabled) {
59
60
  const { COMPUTER_TOOLS, COMPUTER_TOOL_NAMES, setComputerEnabled } = await import("./tools/computer.js");
60
61
  const { registry } = await import("./tools/registry.js");
61
62
  setComputerEnabled(true);
62
63
  for (const t of COMPUTER_TOOLS)
63
64
  registry.set(t.name, t);
64
- computerAskRules = Object.fromEntries(COMPUTER_TOOL_NAMES.map((n) => [n, "ask"]));
65
- computerDenyRules = Object.fromEntries(COMPUTER_TOOL_NAMES.map((n) => [n, "deny"]));
65
+ // Embodiment also wires chauffeur (robust textual-AX computer use) when installed, as its OWN curated
66
+ // hub — not the whole fleet MCP surface. It fills osascript's blind spot: reading a modern/Electron UI.
67
+ // When the owner has opted into the full fleet (settings.mcp), chauffeur is already reachable there, so
68
+ // we don't double-wire; otherwise we inject the scoped hub so embodiment alone is enough.
69
+ const { buildChauffeurHub, CHAUFFEUR_TOOL_NAMES } = await import("./tools/chauffeur.js");
70
+ if (!settings.mcp)
71
+ embodimentHub = (await buildChauffeurHub()) ?? undefined;
72
+ const gated = [...COMPUTER_TOOL_NAMES, ...(embodimentHub ? CHAUFFEUR_TOOL_NAMES : [])];
73
+ computerAskRules = Object.fromEntries(gated.map((n) => [n, "ask"]));
74
+ computerDenyRules = Object.fromEntries(gated.map((n) => [n, "deny"]));
66
75
  }
67
76
  // Foreground policy = the owner's settings with computer tools forced to "ask". When computer control is
68
77
  // off, computerAskRules is empty, so this is behaviorally identical to settings.permissions (an empty
@@ -118,6 +127,25 @@ function loadProjectContext() {
118
127
  }
119
128
  return "";
120
129
  }
130
+ // Embodiment guidance, appended only when computer control is on. It steers Aurora to READ the screen
131
+ // with chauffeur's textual accessibility tree instead of hand-rolling osascript — the exact loop that
132
+ // failed on Slack (AppleScript can't read Electron UIs). chauffeur is reachable either via the scoped
133
+ // embodiment hub or the full fleet MCP.
134
+ const chauffeurReady = !!embodimentHub || settings.mcp;
135
+ const EMBODIMENT_GUIDE = settings.computer.enabled
136
+ ? `\n## Controlling this computer\nComputer control is ON (every action asks the owner first). Drive apps with ` +
137
+ `computer_app_open / computer_app_activate, computer_type, computer_key, computer_click, computer_screenshot.` +
138
+ (chauffeurReady
139
+ ? ` To SEE the screen, use chauffeur: call chauffeur:list_windows to enumerate windows (each with pid + ` +
140
+ `window_id + title), then chauffeur:get_window_state {pid, window_id} to read a window's UI as a TEXT ` +
141
+ `accessibility tree — labels, values, and clickable elements with coordinates. Act via chauffeur:click / ` +
142
+ `chauffeur:type_text / chauffeur:press_key using that element info. Do NOT hand-write osascript or System ` +
143
+ `Events to scrape a GUI: AppleScript cannot reliably read Electron apps (Slack, VS Code, Discord) and will ` +
144
+ `error — always read them with chauffeur:get_window_state instead.`
145
+ : ` NOTE: reliably READING on-screen UI (especially Electron apps like Slack) needs the chauffeur driver, ` +
146
+ `which is not installed here; computer_screenshot only saves a PNG you cannot read back yet. Do not ` +
147
+ `hand-write osascript to scrape a GUI — it will error on Electron apps.`)
148
+ : "";
121
149
  const SYSTEM_PROMPT = (settings.systemPrompt ??
122
150
  `You are Operator, AXE's terminal coding agent — built by AXE, running on AXE's Aurora model. Refer to ` +
123
151
  `yourself as Operator and to the platform as AXE; never call yourself or the platform Claude, ` +
@@ -140,7 +168,7 @@ const SYSTEM_PROMPT = (settings.systemPrompt ??
140
168
  `head -80","timeout_ms":60000}. Do NOT use an unbounded find / (too slow, it times out). Also check ` +
141
169
  `~/.axe/repos and any folder ls ~ revealed, and widen the pattern (a repo may be named slightly ` +
142
170
  `differently). Only report not-found after this real search, and say exactly where you looked.`) +
143
- loadProjectContext();
171
+ loadProjectContext() + EMBODIMENT_GUIDE;
144
172
  const MAX_BG = 4; // concurrent background sub-agents — all share the single Aurora 1M endpoint, so cap fan-out
145
173
  const HELP = [
146
174
  "commands:",
@@ -237,6 +265,7 @@ function Root() {
237
265
  systemPrompt: SYSTEM_PROMPT,
238
266
  router: buildRouter(),
239
267
  mcp: settings.mcp,
268
+ mcpHub: embodimentHub, // scoped chauffeur hub when embodiment is on (undefined otherwise → no change)
240
269
  maxTokens: settings.maxTokens,
241
270
  temperature: settings.temperature,
242
271
  recall: settings.memory.recall,
package/dist/mcp/index.js CHANGED
@@ -29,7 +29,10 @@ export class McpHub {
29
29
  return;
30
30
  this.clients.push(client);
31
31
  try {
32
+ const allow = s.tools && s.tools.length ? new Set(s.tools) : null;
32
33
  for (const def of await client.listTools()) {
34
+ if (allow && !allow.has(def.name))
35
+ continue; // curated allowlist: skip un-listed tools
33
36
  this.tools.set(`${s.name}${SEP}${def.name}`, { server: s.name, client, def });
34
37
  }
35
38
  }
@@ -0,0 +1,59 @@
1
+ // Chauffeur — the robust computer-use backend for Operator's embodiment (macOS + cross-platform). It is
2
+ // a separate driver process (com.axe.chauffeur, granted Accessibility + Screen Recording) that we speak
3
+ // to over MCP stdio. Why it exists alongside the osascript computer_* tools: osascript can DRIVE apps but
4
+ // has no reliable way to READ a modern UI — asked to read an Electron app (Slack) it returns -1728/-2740
5
+ // errors, so the model resorts to hand-rolled AppleScript and fails. Chauffeur returns the UI as TEXT
6
+ // (`list_windows`, `get_window_state` → an accessibility tree in markdown), which a local model can act on
7
+ // directly without vision. This module is node-only and imported solely from cli.tsx — never the mobile
8
+ // bundle — so it may reach for node builtins lazily like the rest of the embodiment path.
9
+ import { McpHub } from "../mcp/index.js";
10
+ // Curated allowlist: chauffeur exposes 56 tools; a local model's tool-calling drowns if we advertise them
11
+ // all, so we surface only the desktop-control essentials. Ordered read → window/app → input → clipboard.
12
+ export const CHAUFFEUR_TOOLS = [
13
+ "list_windows", "get_window_state", "get_desktop_state", "list_apps", // inspect (textual UI reads)
14
+ "launch_app", "bring_to_front", // window/app management
15
+ "click", "double_click", "right_click", "type_text", "press_key", "hotkey", // input
16
+ "scroll", "move_cursor", "drag", "invoke_menu", "set_value",
17
+ "clipboard_read", "clipboard_write",
18
+ ];
19
+ // The namespaced names the hub exposes to the model (server:tool) — used to force each to "ask" (fg) /
20
+ // "deny" (bg sub-agents), mirroring the osascript computer_* posture.
21
+ export const CHAUFFEUR_TOOL_NAMES = CHAUFFEUR_TOOLS.map((t) => `chauffeur:${t}`);
22
+ // Resolve the chauffeur binary: explicit override, then the fleet install path, else bare `chauffeur` on
23
+ // PATH. Returns null only when nothing is found, so cli.tsx can skip wiring a dead hub.
24
+ async function resolveBinary() {
25
+ const override = process.env.KODE_CHAUFFEUR_BIN;
26
+ if (override)
27
+ return override;
28
+ const { existsSync } = await import("node:fs");
29
+ const { homedir } = await import("node:os");
30
+ const local = `${homedir()}/.local/bin/chauffeur-local`;
31
+ if (existsSync(local))
32
+ return local;
33
+ // Fall back to PATH resolution; if `chauffeur` isn't there either, give up (no dead hub, no failed spawn).
34
+ try {
35
+ const { execFileSync } = await import("node:child_process");
36
+ const p = execFileSync("command", ["-v", "chauffeur"], { shell: "/bin/sh", encoding: "utf8" }).trim();
37
+ return p || null;
38
+ }
39
+ catch {
40
+ return null;
41
+ }
42
+ }
43
+ /** Build a chauffeur-only MCP hub (curated tools, `mcp --direct` so it self-contains without a daemon),
44
+ * or null when chauffeur isn't installed. Injected into the foreground Session when computer control is
45
+ * enabled, so embodiment gets the robust driver without turning on the whole fleet MCP surface. */
46
+ export async function buildChauffeurHub() {
47
+ const command = await resolveBinary();
48
+ if (!command)
49
+ return null;
50
+ const server = {
51
+ name: "chauffeur",
52
+ transport: "stdio",
53
+ command,
54
+ args: ["mcp", "--direct"], // --direct = own the runtime in-process; no separate `chauffeur serve` daemon
55
+ advertise: true,
56
+ tools: [...CHAUFFEUR_TOOLS], // curated allowlist (the McpHub filters discovery to these)
57
+ };
58
+ return new McpHub([server]);
59
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.40",
3
+ "version": "0.1.41",
4
4
  "description": "Operator (KODE) — TypeScript + Ink terminal coding agent. Full-frame render, single-engine core shared across CLI/web/mobile; runs against a local Aurora model.",
5
5
  "type": "module",
6
6
  "bin": {