@0perator/operator 0.1.40 → 0.1.42
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 +42 -4
- package/dist/mcp/index.js +3 -0
- package/dist/session.js +3 -2
- package/dist/tools/chauffeur.js +64 -0
- package/dist/ui/QuestionPrompt.js +46 -8
- package/package.json +1 -1
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.
|
|
22
|
+
const VERSION = "0.1.42";
|
|
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,28 @@ 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
|
-
|
|
65
|
-
|
|
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_ACTION_NAMES, CHAUFFEUR_TOOL_NAMES } = await import("./tools/chauffeur.js");
|
|
70
|
+
if (!settings.mcp)
|
|
71
|
+
embodimentHub = (await buildChauffeurHub()) ?? undefined;
|
|
72
|
+
// Foreground: computer_* and chauffeur ACTIONS prompt ("ask"); chauffeur READS (list_windows,
|
|
73
|
+
// get_window_state, …) are intentionally NOT gated, so the model reads the screen freely and completes
|
|
74
|
+
// a task end-to-end without walking the owner through each step. Only real input/mutation asks.
|
|
75
|
+
const askNames = [...COMPUTER_TOOL_NAMES, ...(embodimentHub ? CHAUFFEUR_ACTION_NAMES : [])];
|
|
76
|
+
computerAskRules = Object.fromEntries(askNames.map((n) => [n, "ask"]));
|
|
77
|
+
// Background sub-agents have no approver, so DENY every embodiment tool, reads included.
|
|
78
|
+
const denyNames = [...COMPUTER_TOOL_NAMES, ...(embodimentHub ? CHAUFFEUR_TOOL_NAMES : [])];
|
|
79
|
+
computerDenyRules = Object.fromEntries(denyNames.map((n) => [n, "deny"]));
|
|
66
80
|
}
|
|
67
81
|
// Foreground policy = the owner's settings with computer tools forced to "ask". When computer control is
|
|
68
82
|
// off, computerAskRules is empty, so this is behaviorally identical to settings.permissions (an empty
|
|
@@ -118,6 +132,29 @@ function loadProjectContext() {
|
|
|
118
132
|
}
|
|
119
133
|
return "";
|
|
120
134
|
}
|
|
135
|
+
// Embodiment guidance, appended only when computer control is on. It steers Aurora to READ the screen
|
|
136
|
+
// with chauffeur's textual accessibility tree instead of hand-rolling osascript — the exact loop that
|
|
137
|
+
// failed on Slack (AppleScript can't read Electron UIs). chauffeur is reachable either via the scoped
|
|
138
|
+
// embodiment hub or the full fleet MCP.
|
|
139
|
+
const chauffeurReady = !!embodimentHub || settings.mcp;
|
|
140
|
+
const EMBODIMENT_GUIDE = settings.computer.enabled
|
|
141
|
+
? `\n## Controlling this computer\nComputer control is ON (every action asks the owner first). Drive apps with ` +
|
|
142
|
+
`computer_app_open / computer_app_activate, computer_type, computer_key, computer_click, computer_screenshot.` +
|
|
143
|
+
(chauffeurReady
|
|
144
|
+
? ` To SEE the screen, use chauffeur: call chauffeur:list_windows to enumerate windows (each with pid + ` +
|
|
145
|
+
`window_id + title), then chauffeur:get_window_state {pid, window_id} to read a window's UI as a TEXT ` +
|
|
146
|
+
`accessibility tree — labels, values, and clickable elements with coordinates. Act via chauffeur:click / ` +
|
|
147
|
+
`chauffeur:type_text / chauffeur:press_key using that element info. Do NOT hand-write osascript or System ` +
|
|
148
|
+
`Events to scrape a GUI: AppleScript cannot reliably read Electron apps (Slack, VS Code, Discord) and will ` +
|
|
149
|
+
`error — always read them with chauffeur:get_window_state instead. Work the task END-TO-END from the ` +
|
|
150
|
+
`owner's one natural-language instruction: read the screen, decide, and act by chaining these tools ` +
|
|
151
|
+
`yourself, then report the result — do NOT narrate or stop to make the owner walk through each step. ` +
|
|
152
|
+
`Reads (list_windows/get_window_state) run without a prompt; only actions ask for approval. Use ask_user ` +
|
|
153
|
+
`ONLY for a genuine decision that is the owner's to make — never to step through a task you can just do.`
|
|
154
|
+
: ` NOTE: reliably READING on-screen UI (especially Electron apps like Slack) needs the chauffeur driver, ` +
|
|
155
|
+
`which is not installed here; computer_screenshot only saves a PNG you cannot read back yet. Do not ` +
|
|
156
|
+
`hand-write osascript to scrape a GUI — it will error on Electron apps.`)
|
|
157
|
+
: "";
|
|
121
158
|
const SYSTEM_PROMPT = (settings.systemPrompt ??
|
|
122
159
|
`You are Operator, AXE's terminal coding agent — built by AXE, running on AXE's Aurora model. Refer to ` +
|
|
123
160
|
`yourself as Operator and to the platform as AXE; never call yourself or the platform Claude, ` +
|
|
@@ -140,7 +177,7 @@ const SYSTEM_PROMPT = (settings.systemPrompt ??
|
|
|
140
177
|
`head -80","timeout_ms":60000}. Do NOT use an unbounded find / (too slow, it times out). Also check ` +
|
|
141
178
|
`~/.axe/repos and any folder ls ~ revealed, and widen the pattern (a repo may be named slightly ` +
|
|
142
179
|
`differently). Only report not-found after this real search, and say exactly where you looked.`) +
|
|
143
|
-
loadProjectContext();
|
|
180
|
+
loadProjectContext() + EMBODIMENT_GUIDE;
|
|
144
181
|
const MAX_BG = 4; // concurrent background sub-agents — all share the single Aurora 1M endpoint, so cap fan-out
|
|
145
182
|
const HELP = [
|
|
146
183
|
"commands:",
|
|
@@ -237,6 +274,7 @@ function Root() {
|
|
|
237
274
|
systemPrompt: SYSTEM_PROMPT,
|
|
238
275
|
router: buildRouter(),
|
|
239
276
|
mcp: settings.mcp,
|
|
277
|
+
mcpHub: embodimentHub, // scoped chauffeur hub when embodiment is on (undefined otherwise → no change)
|
|
240
278
|
maxTokens: settings.maxTokens,
|
|
241
279
|
temperature: settings.temperature,
|
|
242
280
|
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
|
}
|
package/dist/session.js
CHANGED
|
@@ -49,7 +49,8 @@ function makeAskTool(handler) {
|
|
|
49
49
|
description: "Ask the owner a single, clarifying multiple-choice question when the task is genuinely ambiguous " +
|
|
50
50
|
"and a wrong assumption would waste real work. Blocks until they choose, then returns the chosen " +
|
|
51
51
|
"option. Use SPARINGLY — prefer a sensible default and proceeding; never ask what you can determine " +
|
|
52
|
-
"from the code or the request. Provide 2-4 concrete, mutually-exclusive options
|
|
52
|
+
"from the code or the request. Provide 2-4 concrete, mutually-exclusive options — the owner ALWAYS " +
|
|
53
|
+
"also gets a free-text 'type your own' choice, so list the likely paths, don't try to enumerate every one.",
|
|
53
54
|
parameters: {
|
|
54
55
|
type: "object",
|
|
55
56
|
properties: {
|
|
@@ -66,7 +67,7 @@ function makeAskTool(handler) {
|
|
|
66
67
|
if (options.length < 2)
|
|
67
68
|
return "error: ask_user needs at least 2 options";
|
|
68
69
|
const answer = await handler(question, options.slice(0, 4));
|
|
69
|
-
return `The user
|
|
70
|
+
return `The user replied: ${answer}`;
|
|
70
71
|
},
|
|
71
72
|
};
|
|
72
73
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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. Split into READS (non-destructive inspection —
|
|
12
|
+
// run WITHOUT an approval prompt so the model can read the screen freely and the owner isn't walked
|
|
13
|
+
// through each step) and ACTIONS (input/mutation — always gated "ask" in the foreground, "deny" in bg).
|
|
14
|
+
export const CHAUFFEUR_READ_TOOLS = [
|
|
15
|
+
"list_windows", "get_window_state", "get_desktop_state", "list_apps", "clipboard_read",
|
|
16
|
+
];
|
|
17
|
+
export const CHAUFFEUR_ACTION_TOOLS = [
|
|
18
|
+
"launch_app", "bring_to_front", // window/app management
|
|
19
|
+
"click", "double_click", "right_click", "type_text", "press_key", "hotkey", // input
|
|
20
|
+
"scroll", "move_cursor", "drag", "invoke_menu", "set_value", "clipboard_write",
|
|
21
|
+
];
|
|
22
|
+
export const CHAUFFEUR_TOOLS = [...CHAUFFEUR_READ_TOOLS, ...CHAUFFEUR_ACTION_TOOLS];
|
|
23
|
+
// Namespaced names (server:tool) the hub exposes. ACTION names are what cli.tsx forces to "ask" (fg);
|
|
24
|
+
// ALL names are what it "deny"s for background sub-agents (no computer use of any kind off the main seat).
|
|
25
|
+
export const CHAUFFEUR_ACTION_NAMES = CHAUFFEUR_ACTION_TOOLS.map((t) => `chauffeur:${t}`);
|
|
26
|
+
export const CHAUFFEUR_TOOL_NAMES = CHAUFFEUR_TOOLS.map((t) => `chauffeur:${t}`);
|
|
27
|
+
// Resolve the chauffeur binary: explicit override, then the fleet install path, else bare `chauffeur` on
|
|
28
|
+
// PATH. Returns null only when nothing is found, so cli.tsx can skip wiring a dead hub.
|
|
29
|
+
async function resolveBinary() {
|
|
30
|
+
const override = process.env.KODE_CHAUFFEUR_BIN;
|
|
31
|
+
if (override)
|
|
32
|
+
return override;
|
|
33
|
+
const { existsSync } = await import("node:fs");
|
|
34
|
+
const { homedir } = await import("node:os");
|
|
35
|
+
const local = `${homedir()}/.local/bin/chauffeur-local`;
|
|
36
|
+
if (existsSync(local))
|
|
37
|
+
return local;
|
|
38
|
+
// Fall back to PATH resolution; if `chauffeur` isn't there either, give up (no dead hub, no failed spawn).
|
|
39
|
+
try {
|
|
40
|
+
const { execFileSync } = await import("node:child_process");
|
|
41
|
+
const p = execFileSync("command", ["-v", "chauffeur"], { shell: "/bin/sh", encoding: "utf8" }).trim();
|
|
42
|
+
return p || null;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Build a chauffeur-only MCP hub (curated tools, `mcp --direct` so it self-contains without a daemon),
|
|
49
|
+
* or null when chauffeur isn't installed. Injected into the foreground Session when computer control is
|
|
50
|
+
* enabled, so embodiment gets the robust driver without turning on the whole fleet MCP surface. */
|
|
51
|
+
export async function buildChauffeurHub() {
|
|
52
|
+
const command = await resolveBinary();
|
|
53
|
+
if (!command)
|
|
54
|
+
return null;
|
|
55
|
+
const server = {
|
|
56
|
+
name: "chauffeur",
|
|
57
|
+
transport: "stdio",
|
|
58
|
+
command,
|
|
59
|
+
args: ["mcp", "--direct"], // --direct = own the runtime in-process; no separate `chauffeur serve` daemon
|
|
60
|
+
advertise: true,
|
|
61
|
+
tools: [...CHAUFFEUR_TOOLS], // curated allowlist (the McpHub filters discovery to these)
|
|
62
|
+
};
|
|
63
|
+
return new McpHub([server]);
|
|
64
|
+
}
|
|
@@ -1,18 +1,56 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Interactive clarification (parity with modern coding agents). When the model calls the `ask_user` tool,
|
|
3
|
+
// the shell parks the question here (React state) and this renders it with numbered options. On TOP of the
|
|
4
|
+
// model's options there is ALWAYS a final "Chat about it / type your own" escape hatch: the owner is never
|
|
5
|
+
// boxed into the listed choices — picking it opens a free-text line whose typed answer is returned to the
|
|
6
|
+
// model verbatim. useInput is active ONLY while a question is pending (the Composer is suspended meanwhile),
|
|
7
|
+
// so a digit selects an option rather than typing into the prompt. Mirrors ApprovalPrompt.
|
|
8
|
+
import { useEffect, useState } from "react";
|
|
2
9
|
import { Box, Text, useInput } from "ink";
|
|
10
|
+
// The always-present final choice. Selecting it lets the owner type their own reply (or just talk it
|
|
11
|
+
// through) instead of picking one of the model's options — so every prompt has an out.
|
|
12
|
+
export const CHAT_LABEL = "Chat about it — type your own reply";
|
|
13
|
+
// Returned to the model when the owner opens the chat line but sends it empty: a clear signal to stop
|
|
14
|
+
// offering a menu and discuss, rather than a blank answer.
|
|
15
|
+
export const DISCUSS = "Let's talk it through — I don't want to pick one of the listed options; discuss it with me.";
|
|
16
|
+
// Pure keystroke reducer (no React, no I/O) so the whole selection + free-text behavior is testable without
|
|
17
|
+
// a TTY. Returns either the next state, or a `resolve` string = the answer to hand back to the model.
|
|
18
|
+
export function questionKey(st, input, key, options) {
|
|
19
|
+
if (st.mode === "type") {
|
|
20
|
+
if (key.return)
|
|
21
|
+
return { resolve: st.buffer.trim() || DISCUSS };
|
|
22
|
+
if (key.escape)
|
|
23
|
+
return { state: { mode: "choose", buffer: "" } }; // back to the menu
|
|
24
|
+
if (key.backspace || key.delete)
|
|
25
|
+
return { state: { ...st, buffer: st.buffer.slice(0, -1) } };
|
|
26
|
+
if (input && !key.ctrl && !key.meta)
|
|
27
|
+
return { state: { ...st, buffer: st.buffer + input } };
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
if (key.ctrl && input.toLowerCase() === "c")
|
|
31
|
+
return { resolve: options[0] }; // bail = first option
|
|
32
|
+
const chatIndex = options.length + 1;
|
|
33
|
+
const n = Number(input);
|
|
34
|
+
if (Number.isInteger(n) && n >= 1 && n <= options.length)
|
|
35
|
+
return { resolve: options[n - 1] };
|
|
36
|
+
if (n === chatIndex)
|
|
37
|
+
return { state: { mode: "type", buffer: "" } }; // open the free-text line
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
3
40
|
export function QuestionPrompt({ pending }) {
|
|
41
|
+
const [st, setSt] = useState({ mode: "choose", buffer: "" });
|
|
42
|
+
useEffect(() => { setSt({ mode: "choose", buffer: "" }); }, [pending]); // reset for each new question
|
|
4
43
|
useInput((input, key) => {
|
|
5
44
|
if (!pending)
|
|
6
45
|
return;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (Number.isInteger(n) && n >= 1 && n <= pending.options.length)
|
|
13
|
-
pending.resolve(pending.options[n - 1]);
|
|
46
|
+
const a = questionKey(st, input, key, pending.options);
|
|
47
|
+
if (a.resolve !== undefined)
|
|
48
|
+
pending.resolve(a.resolve);
|
|
49
|
+
else if (a.state)
|
|
50
|
+
setSt(a.state);
|
|
14
51
|
}, { isActive: !!pending });
|
|
15
52
|
if (!pending)
|
|
16
53
|
return null;
|
|
17
|
-
|
|
54
|
+
const chatIndex = pending.options.length + 1;
|
|
55
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsxs(Text, { color: "cyan", bold: true, children: ["? ", _jsx(Text, { color: "white", children: pending.question })] }), pending.options.map((o, i) => (_jsxs(Text, { children: [" ", _jsxs(Text, { color: "cyan", children: ["[", i + 1, "]"] }), " ", o] }, i))), _jsxs(Text, { children: [" ", _jsxs(Text, { color: "cyan", children: ["[", chatIndex, "]"] }), " ", _jsx(Text, { color: "magenta", children: CHAT_LABEL })] }), st.mode === "type" ? (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { children: [_jsx(Text, { color: "magenta", children: "› " }), st.buffer, _jsx(Text, { color: "cyan", children: "\u258C" })] }), _jsx(Text, { dimColor: true, children: " type your reply · Enter to send · Esc for the menu" })] })) : (_jsx(Text, { dimColor: true, children: ` press 1-${chatIndex} to choose (${chatIndex} = type your own)` }))] }));
|
|
18
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0perator/operator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.42",
|
|
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": {
|