@0perator/operator 0.1.41 → 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 +15 -6
- package/dist/session.js +3 -2
- package/dist/tools/chauffeur.js +12 -7
- 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).
|
|
@@ -66,12 +66,17 @@ if (settings.computer.enabled) {
|
|
|
66
66
|
// hub — not the whole fleet MCP surface. It fills osascript's blind spot: reading a modern/Electron UI.
|
|
67
67
|
// When the owner has opted into the full fleet (settings.mcp), chauffeur is already reachable there, so
|
|
68
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");
|
|
69
|
+
const { buildChauffeurHub, CHAUFFEUR_ACTION_NAMES, CHAUFFEUR_TOOL_NAMES } = await import("./tools/chauffeur.js");
|
|
70
70
|
if (!settings.mcp)
|
|
71
71
|
embodimentHub = (await buildChauffeurHub()) ?? undefined;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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"]));
|
|
75
80
|
}
|
|
76
81
|
// Foreground policy = the owner's settings with computer tools forced to "ask". When computer control is
|
|
77
82
|
// off, computerAskRules is empty, so this is behaviorally identical to settings.permissions (an empty
|
|
@@ -141,7 +146,11 @@ const EMBODIMENT_GUIDE = settings.computer.enabled
|
|
|
141
146
|
`accessibility tree — labels, values, and clickable elements with coordinates. Act via chauffeur:click / ` +
|
|
142
147
|
`chauffeur:type_text / chauffeur:press_key using that element info. Do NOT hand-write osascript or System ` +
|
|
143
148
|
`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
|
|
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.`
|
|
145
154
|
: ` NOTE: reliably READING on-screen UI (especially Electron apps like Slack) needs the chauffeur driver, ` +
|
|
146
155
|
`which is not installed here; computer_screenshot only saves a PNG you cannot read back yet. Do not ` +
|
|
147
156
|
`hand-write osascript to scrape a GUI — it will error on Electron apps.`)
|
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
|
}
|
package/dist/tools/chauffeur.js
CHANGED
|
@@ -8,16 +8,21 @@
|
|
|
8
8
|
// bundle — so it may reach for node builtins lazily like the rest of the embodiment path.
|
|
9
9
|
import { McpHub } from "../mcp/index.js";
|
|
10
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.
|
|
12
|
-
|
|
13
|
-
|
|
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 = [
|
|
14
18
|
"launch_app", "bring_to_front", // window/app management
|
|
15
19
|
"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",
|
|
20
|
+
"scroll", "move_cursor", "drag", "invoke_menu", "set_value", "clipboard_write",
|
|
18
21
|
];
|
|
19
|
-
|
|
20
|
-
//
|
|
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}`);
|
|
21
26
|
export const CHAUFFEUR_TOOL_NAMES = CHAUFFEUR_TOOLS.map((t) => `chauffeur:${t}`);
|
|
22
27
|
// Resolve the chauffeur binary: explicit override, then the fleet install path, else bare `chauffeur` on
|
|
23
28
|
// PATH. Returns null only when nothing is found, so cli.tsx can skip wiring a dead hub.
|
|
@@ -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": {
|