@0perator/operator 0.1.313 → 0.1.322
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/autonomy/agent-cli.js +6 -2
- package/dist/autonomy/cron.js +1 -1
- package/dist/autonomy/delegate.js +29 -4
- package/dist/autonomy/index.js +22 -0
- package/dist/autonomy/profile.js +1 -1
- package/dist/browser/cdp.js +1 -1
- package/dist/cli.js +128 -43
- package/dist/config/persona.js +29 -12
- package/dist/config/settings.js +12 -7
- package/dist/engine/agent.js +4 -2
- package/dist/engine/aurora.js +8 -3
- package/dist/engine/batch-scheduler.js +3 -3
- package/dist/engine/compaction.js +1 -1
- package/dist/engine/loop-guard.js +1 -1
- package/dist/engine/router-adapter.js +1 -0
- package/dist/idle/activity.js +20 -0
- package/dist/idle/index.js +5 -0
- package/dist/idle/monitor.js +71 -0
- package/dist/idle/policy.js +66 -0
- package/dist/idle/proc.js +22 -0
- package/dist/idle/reaper.js +69 -0
- package/dist/idle/session-record.js +59 -0
- package/dist/index.js +1 -1
- package/dist/mcp/config.js +72 -14
- package/dist/mcp/index.js +9 -2
- package/dist/memory/index.js +1 -1
- package/dist/permissions/index.js +22 -7
- package/dist/permissions/tier.js +1 -1
- package/dist/remote/host.js +20 -2
- package/dist/remote/safe-commands.js +38 -0
- package/dist/services/preflight.js +54 -2
- package/dist/services/store-sync.js +111 -0
- package/dist/session-teardown.js +10 -1
- package/dist/session.js +43 -1
- package/dist/skills/catalogue.js +1 -1
- package/dist/tools/chauffeur-native.js +155 -0
- package/dist/tools/chauffeur.js +14 -3
- package/dist/tools/download.js +229 -0
- package/dist/tools/executor.js +1 -1
- package/dist/tools/monitoring-tools.js +312 -0
- package/dist/tools/paths.js +154 -0
- package/dist/tools/registry.js +309 -18
- package/dist/tools/shell-jobs.js +5 -2
- package/dist/tools/shell-session.js +4 -2
- package/dist/tools/tool-output-spill.js +1 -1
- package/dist/ui/Composer.js +5 -2
- package/dist/ui/QuestionPrompt.js +1 -1
- package/dist/ui/ToolStep.js +16 -1
- package/dist/ui/liveTools.js +1 -1
- package/dist/util/mentions.js +1 -1
- package/dist/vault/store.js +1 -1
- package/mcp/README.md +88 -0
- package/mcp/ocr-macos.swift +45 -0
- package/mcp/powertools-media.mjs +464 -0
- package/mcp/powertools-toolbox.mjs +1114 -0
- package/mcp/powertools.md +210 -0
- package/mcp/powertools.mjs +861 -0
- package/package.json +2 -1
package/dist/tools/registry.js
CHANGED
|
@@ -17,9 +17,11 @@ import { WAVE_TOOLS } from "./wave-tools.js";
|
|
|
17
17
|
import { WAVE2_TOOLS } from "./wave2-tools.js";
|
|
18
18
|
import { GIT_PR_TOOLS } from "./git-pr.js";
|
|
19
19
|
import { INCIDENT_TOOLS } from "./incident-tools.js";
|
|
20
|
+
import { MONITORING_TOOLS } from "./monitoring-tools.js";
|
|
21
|
+
import { desktopScreenshot, desktopClick, desktopRead, appInteract, capturePermalink, liveDrive } from "./chauffeur-native.js";
|
|
20
22
|
import { findFiles, FIND_FILES_DEFAULT_LIMIT, FIND_FILES_MAX_LIMIT, KINDS } from "./find-files.js";
|
|
21
23
|
import { formatGitStatus } from "./git-status.js";
|
|
22
|
-
import { expandPath } from "./paths.js";
|
|
24
|
+
import { expandPath, assertContentSearchScope, assertShellHomeWideSearch, assertShellBlindDownload } from "./paths.js";
|
|
23
25
|
import { runMemoryTool } from "./memory.js";
|
|
24
26
|
import { documentGenerate } from "./document.js";
|
|
25
27
|
import { runCronTool } from "../autonomy/cron.js";
|
|
@@ -97,10 +99,28 @@ export function disposeShellSessionKey(key) {
|
|
|
97
99
|
_shells.delete(key);
|
|
98
100
|
}
|
|
99
101
|
}
|
|
102
|
+
// Commands that routinely outlive a foreground timeout. ssh is deliberately absent: what runs on the remote host is unknown.
|
|
103
|
+
const LONG_CMD_RE = /(?:^|[;&|(]\s*|&&\s*)(?:(?:sudo\s+)?(?:npm|pnpm|yarn|bun)\s+(?:install|i|ci|add|test|run\s+(?:build|test)|build)\b|pip3?\s+install\b|(?:python3?\s+-m\s+)?pytest\b|cargo\s+(?:build|test|install)\b|go\s+(?:build|test)\b|(?:g?make|cmake|gradle|\.\/gradlew|mvn)\b|docker\s+(?:build|pull)\b|brew\s+(?:install|upgrade)\b|apt(?:-get)?\s+(?:install|upgrade)\b|wget\b|curl\b[^|;&]*\s(?:-[a-zA-Z]*[OL]\b|--output\b|-o\s))/;
|
|
104
|
+
export function isLongRunningCommand(command) {
|
|
105
|
+
return LONG_CMD_RE.test(command.trim()) && !/\bssh\b/.test(command);
|
|
106
|
+
}
|
|
100
107
|
async function shellExec(args) {
|
|
101
108
|
const command = str(args.command);
|
|
102
109
|
if (!command)
|
|
103
110
|
return "error: no command given";
|
|
111
|
+
const homeWide = assertShellHomeWideSearch(command);
|
|
112
|
+
if (homeWide)
|
|
113
|
+
return homeWide;
|
|
114
|
+
const blind = assertShellBlindDownload(command);
|
|
115
|
+
if (blind)
|
|
116
|
+
return blind;
|
|
117
|
+
// An explicit timeout_ms is the model's own choice and is honored; otherwise a known-long command goes straight to a job.
|
|
118
|
+
if (args.timeout_ms === undefined && isLongRunningCommand(command)) {
|
|
119
|
+
const started = await shellBackground(args);
|
|
120
|
+
if (started.startsWith("started background job"))
|
|
121
|
+
return `[auto-backgrounded: this command is expected to run long, so it was NOT run in the foreground shell]\n${started}`;
|
|
122
|
+
return started;
|
|
123
|
+
}
|
|
104
124
|
const timeout = Number(args.timeout_ms ?? 120_000);
|
|
105
125
|
// A `cwd` arg is scoped to this one call (subshell) so it doesn't silently move the persistent
|
|
106
126
|
// session's directory; an explicit `cd` INSIDE the command persists, exactly like a terminal.
|
|
@@ -130,9 +150,12 @@ async function shellExec(args) {
|
|
|
130
150
|
const { shellResultNotes } = mod;
|
|
131
151
|
if (r.timedOut) {
|
|
132
152
|
const resetNote = mode === "ephemeral"
|
|
133
|
-
? `[timed out after ${timeout}ms — ephemeral shell killed;
|
|
134
|
-
:
|
|
135
|
-
|
|
153
|
+
? `[timed out after ${timeout}ms — ephemeral shell killed; run long commands with shell_background instead]`
|
|
154
|
+
: r.reset
|
|
155
|
+
? `[timed out after ${timeout}ms — the command was killed and the shell had to be reset (cwd/env cleared); run long commands with shell_background instead]`
|
|
156
|
+
: `[timed out after ${timeout}ms — the command was killed; the shell is still alive (cwd/env kept). Run long commands with shell_background instead of raising timeout_ms]`;
|
|
157
|
+
const stdinHint = out && mode !== "ephemeral" ? "\n[output arrived but the command never finished: it may be waiting on stdin — interactive input is not supported (stdin is /dev/null); use non-interactive flags, e.g. ssh -n or -o BatchMode=yes]" : "";
|
|
158
|
+
return (out ? out + "\n" : "") + resetNote + stdinHint;
|
|
136
159
|
}
|
|
137
160
|
if (r.truncated)
|
|
138
161
|
out += `\n[output truncated at 8MB — narrow it: add a path, pipe to \`head\`, or use \`grep -l\`/\`grep -c\`]`;
|
|
@@ -318,11 +341,17 @@ async function sessionHandoff(args) {
|
|
|
318
341
|
return `error: ${e.message}`;
|
|
319
342
|
}
|
|
320
343
|
}
|
|
344
|
+
// Content-search wall clock. Was 300s — a home-wide path looked "hung" for ~5 minutes in the TUI.
|
|
345
|
+
// Narrow scopes finish in well under this; broad scopes are refused by assertContentSearchScope.
|
|
346
|
+
const CONTENT_SEARCH_TIMEOUT_MS = 20_000;
|
|
321
347
|
async function grepSearch(args) {
|
|
322
348
|
const pattern = str(args.pattern);
|
|
323
349
|
const path = expandPath(str(args.path, "."));
|
|
324
350
|
if (!pattern)
|
|
325
351
|
return "error: no pattern given";
|
|
352
|
+
const scopeErr = assertContentSearchScope(path);
|
|
353
|
+
if (scopeErr)
|
|
354
|
+
return scopeErr;
|
|
326
355
|
// -s suppresses errors for unreadable/special files (sockets, FIFOs, permission-denied) that a
|
|
327
356
|
// recursive grep over a real dir (e.g. /private/tmp, full of IPC sockets) inevitably hits; without it
|
|
328
357
|
// grep exits 2 and the tool used to report a hard failure even when it HAD found matches.
|
|
@@ -334,7 +363,7 @@ async function grepSearch(args) {
|
|
|
334
363
|
// errors immediately, but a FIFO with no writer hangs grep on open forever. Killed grep still leaves
|
|
335
364
|
// whatever it matched in stdout (handled in the catch), so a real dir with a stray pipe can't wedge
|
|
336
365
|
// the agent.
|
|
337
|
-
const { stdout } = await pexecFile("grep", [...flags, "-E", pattern, path], { maxBuffer: 10 * 1024 * 1024, timeout:
|
|
366
|
+
const { stdout } = await pexecFile("grep", [...flags, "-E", pattern, path], { maxBuffer: 10 * 1024 * 1024, timeout: CONTENT_SEARCH_TIMEOUT_MS, killSignal: "SIGKILL" });
|
|
338
367
|
return capMatches(stdout);
|
|
339
368
|
}
|
|
340
369
|
catch (e) {
|
|
@@ -395,6 +424,9 @@ async function ripgrepSearch(args) {
|
|
|
395
424
|
const path = expandPath(str(args.path, "."));
|
|
396
425
|
if (!pattern)
|
|
397
426
|
return "error: no pattern given";
|
|
427
|
+
const scopeErr = assertContentSearchScope(path);
|
|
428
|
+
if (scopeErr)
|
|
429
|
+
return scopeErr;
|
|
398
430
|
const filesOnly = !!args.files_with_matches;
|
|
399
431
|
const glob = args.glob ? str(args.glob) : "";
|
|
400
432
|
// Belt-and-suspenders over rg -g / grep --include: always JS-filter the output by the glob too.
|
|
@@ -407,7 +439,7 @@ async function ripgrepSearch(args) {
|
|
|
407
439
|
if (glob)
|
|
408
440
|
gflags.push(`--include=${glob}`);
|
|
409
441
|
try {
|
|
410
|
-
const { stdout } = await pexecFile("grep", [...gflags, "-E", pattern, path], { maxBuffer: 10 * 1024 * 1024, timeout:
|
|
442
|
+
const { stdout } = await pexecFile("grep", [...gflags, "-E", pattern, path], { maxBuffer: 10 * 1024 * 1024, timeout: CONTENT_SEARCH_TIMEOUT_MS, killSignal: "SIGKILL" });
|
|
411
443
|
return capG(stdout);
|
|
412
444
|
}
|
|
413
445
|
catch (ge) {
|
|
@@ -426,7 +458,7 @@ async function ripgrepSearch(args) {
|
|
|
426
458
|
rgArgs.push("-g", glob);
|
|
427
459
|
rgArgs.push("-e", pattern, path);
|
|
428
460
|
try {
|
|
429
|
-
const { stdout } = await pexecFile("rg", rgArgs, { maxBuffer: 10 * 1024 * 1024, timeout:
|
|
461
|
+
const { stdout } = await pexecFile("rg", rgArgs, { maxBuffer: 10 * 1024 * 1024, timeout: CONTENT_SEARCH_TIMEOUT_MS, killSignal: "SIGKILL" });
|
|
430
462
|
return capG(stdout);
|
|
431
463
|
}
|
|
432
464
|
catch (e) {
|
|
@@ -1063,6 +1095,55 @@ async function fileUpload(args) {
|
|
|
1063
1095
|
clearTimeout(timer);
|
|
1064
1096
|
}
|
|
1065
1097
|
}
|
|
1098
|
+
// download_file (tools/download.ts): the one supported way to fetch a file to disk — fails loudly, resumes, verifies, never leaves a
|
|
1099
|
+
// half file at the final name. Runs as a tracked background job by default (same ids, bash_output, bash_kill, /jobs, completion
|
|
1100
|
+
// notice as shell_background) because real downloads outlast a turn; background:false waits (bounded) and returns the result.
|
|
1101
|
+
async function downloadFileTool(args) {
|
|
1102
|
+
// Node-only module: loaded through the opaque nodeImport so it never enters the neutral (mobile/JSCore) bundle graph.
|
|
1103
|
+
const { downloadFile } = (await nodeImport("./download.js"));
|
|
1104
|
+
const url = str(args.url);
|
|
1105
|
+
const dest = str(args.dest);
|
|
1106
|
+
if (!url)
|
|
1107
|
+
return "error: no url given";
|
|
1108
|
+
if (!dest)
|
|
1109
|
+
return "error: no dest given (a file path, or a directory ending in /)";
|
|
1110
|
+
const opts = {
|
|
1111
|
+
url, dest: expandPath(dest), overwrite: args.overwrite === true,
|
|
1112
|
+
sha256: args.sha256 ? str(args.sha256) : undefined,
|
|
1113
|
+
expectedBytes: typeof args.expected_bytes === "number" ? args.expected_bytes : undefined,
|
|
1114
|
+
headers: args.headers && typeof args.headers === "object" ? args.headers : undefined,
|
|
1115
|
+
};
|
|
1116
|
+
if (args.background === false) {
|
|
1117
|
+
const ac = new AbortController();
|
|
1118
|
+
const cap = typeof args.timeout_ms === "number" ? args.timeout_ms : 120_000;
|
|
1119
|
+
const timer = setTimeout(() => ac.abort(), cap);
|
|
1120
|
+
try {
|
|
1121
|
+
const r = await downloadFile({ ...opts, signal: ac.signal });
|
|
1122
|
+
return r.message === "cancelled" ? `stopped after ${Math.round(cap / 1000)}s — a partial file is kept; call download_file again (background:true) to continue it` : r.message;
|
|
1123
|
+
}
|
|
1124
|
+
finally {
|
|
1125
|
+
clearTimeout(timer);
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
pruneShellJobs();
|
|
1129
|
+
if (runningJobCount() >= BG_MAX_RUNNING)
|
|
1130
|
+
return `error: ${BG_MAX_RUNNING} background jobs already running — bash_kill one before starting another`;
|
|
1131
|
+
const id = newJobId();
|
|
1132
|
+
const ac = new AbortController();
|
|
1133
|
+
const job = createJob(id, `download_file ${url} -> ${opts.dest}`, { kill: () => ac.abort() }, "background");
|
|
1134
|
+
let last = 0;
|
|
1135
|
+
void downloadFile({
|
|
1136
|
+
...opts, signal: ac.signal,
|
|
1137
|
+
onProgress: (p) => {
|
|
1138
|
+
const now = Date.now();
|
|
1139
|
+
if (now - last < 5000)
|
|
1140
|
+
return;
|
|
1141
|
+
last = now;
|
|
1142
|
+
trackJobOutput(job, `${p.total ? `${Math.round((p.bytes / p.total) * 100)}% ` : ""}${(p.bytes / 1e6).toFixed(1)} MB${p.total ? ` of ${(p.total / 1e6).toFixed(1)} MB` : ""} · ${(p.bytesPerSec / 1e6).toFixed(1)} MB/s\n`);
|
|
1143
|
+
},
|
|
1144
|
+
}).then((r) => { trackJobOutput(job, `${r.message}\n`); finishJob(job, r.ok ? 0 : 1); }, (e) => { trackJobOutput(job, `error: ${e.message}\n`); finishJob(job, 1); });
|
|
1145
|
+
return `started download job ${id}: ${url} -> ${opts.dest}\nYou will be notified when it finishes (the notice carries the final size and sha256, or the error), so do not poll. Progress: bash_output {"id":"${id}"}; stop: bash_kill {"id":"${id}"}. Do NOT claim it is downloaded until the notice says so.`;
|
|
1146
|
+
}
|
|
1066
1147
|
// --- Background / detached shell (checklist gap: shell_exec is synchronous with a timeout only). For a
|
|
1067
1148
|
// long-running command, shell_background spawns it detached, buffers output, and returns a job id to poll
|
|
1068
1149
|
// with bash_output or stop with bash_kill (the BashOutput/KillShell analog). Runs under the same OS
|
|
@@ -1071,6 +1152,12 @@ async function shellBackground(args) {
|
|
|
1071
1152
|
const command = str(args.command);
|
|
1072
1153
|
if (!command)
|
|
1073
1154
|
return "error: no command given";
|
|
1155
|
+
const homeWide = assertShellHomeWideSearch(command);
|
|
1156
|
+
if (homeWide)
|
|
1157
|
+
return homeWide;
|
|
1158
|
+
const blind = assertShellBlindDownload(command);
|
|
1159
|
+
if (blind)
|
|
1160
|
+
return blind;
|
|
1074
1161
|
pruneShellJobs();
|
|
1075
1162
|
if (runningJobCount() >= BG_MAX_RUNNING)
|
|
1076
1163
|
return `error: ${BG_MAX_RUNNING} background jobs already running — bash_kill one before starting another`;
|
|
@@ -1084,12 +1171,99 @@ async function shellBackground(args) {
|
|
|
1084
1171
|
const p = spawn(file, argv, { cwd, detached: true });
|
|
1085
1172
|
ownChild(p, `background job ${id}`, { cmd: `${file} ${argv.join(" ")}`, group: true });
|
|
1086
1173
|
const job = createJob(id, command, p, "background");
|
|
1174
|
+
if (typeof args.description === "string" && args.description)
|
|
1175
|
+
job.description = args.description;
|
|
1087
1176
|
const cap = (d) => trackJobOutput(job, d.toString("utf8"));
|
|
1088
1177
|
p.stdout?.on("data", cap);
|
|
1089
1178
|
p.stderr?.on("data", cap);
|
|
1090
1179
|
p.on("close", (c) => finishJob(job, c));
|
|
1091
1180
|
p.on("error", (e) => { trackJobOutput(job, `\n[spawn error: ${e.message}]`); finishJob(job, -1); });
|
|
1092
|
-
|
|
1181
|
+
const label = job.description ? ` (${job.description})` : "";
|
|
1182
|
+
return `started background job ${id}${label}: ${command}\nYou will be notified when it finishes, so do not poll. Read output with bash_output {"id":"${id}"}; stop it with bash_kill {"id":"${id}"}.`;
|
|
1183
|
+
}
|
|
1184
|
+
async function verifyPipeline(args) {
|
|
1185
|
+
const stages = args.stages;
|
|
1186
|
+
if (!Array.isArray(stages) || !stages.length)
|
|
1187
|
+
return "error: stages must be a non-empty array";
|
|
1188
|
+
const parts = [];
|
|
1189
|
+
let passed = 0;
|
|
1190
|
+
const total = stages.length;
|
|
1191
|
+
for (const stage of stages) {
|
|
1192
|
+
const label = str(stage.label) || "unnamed";
|
|
1193
|
+
const command = str(stage.command);
|
|
1194
|
+
if (!command) {
|
|
1195
|
+
parts.push(`\n=== ${label.toUpperCase()} SKIPPED (no command) ===`);
|
|
1196
|
+
continue;
|
|
1197
|
+
}
|
|
1198
|
+
const timeout = Number(stage.timeout_ms ?? 120_000);
|
|
1199
|
+
const expect = str(stage.expect) || "zero";
|
|
1200
|
+
parts.push(`\n=== ${label.toUpperCase()} ===`);
|
|
1201
|
+
const result = await shellExec({ command, timeout_ms: timeout });
|
|
1202
|
+
const exitMatch = result.match(/\[exit (\d+)\]$/);
|
|
1203
|
+
const exitCode = exitMatch ? parseInt(exitMatch[1], 10) : (result.includes("(no output)") ? 0 : 0);
|
|
1204
|
+
const failed = expect === "zero"
|
|
1205
|
+
? result.includes("[exit ") && exitCode !== 0
|
|
1206
|
+
: !result || result === "(no output)";
|
|
1207
|
+
if (result.length > 2000) {
|
|
1208
|
+
const head = result.slice(0, 800);
|
|
1209
|
+
const tail = result.slice(-800);
|
|
1210
|
+
parts.push(head + `\n... (${result.length - 1600} chars omitted) ...\n` + tail);
|
|
1211
|
+
}
|
|
1212
|
+
else {
|
|
1213
|
+
parts.push(result);
|
|
1214
|
+
}
|
|
1215
|
+
if (failed) {
|
|
1216
|
+
parts.push(`\n=== ${label.toUpperCase()} FAILED ===`);
|
|
1217
|
+
parts.push(`\nPipeline aborted at stage ${passed + 1}/${total}. ${passed} passed, ${total - passed - 1} skipped.`);
|
|
1218
|
+
return parts.join("\n");
|
|
1219
|
+
}
|
|
1220
|
+
passed++;
|
|
1221
|
+
parts.push(`=== ${label.toUpperCase()} PASSED ===`);
|
|
1222
|
+
}
|
|
1223
|
+
parts.push(`\n=== ALL ${total} STAGES PASSED ===`);
|
|
1224
|
+
return parts.join("\n");
|
|
1225
|
+
}
|
|
1226
|
+
async function briefUpdate(args) {
|
|
1227
|
+
const filePath = expandPath(str(args.path));
|
|
1228
|
+
if (!filePath)
|
|
1229
|
+
return "error: no path given";
|
|
1230
|
+
const section = str(args.section);
|
|
1231
|
+
if (!section)
|
|
1232
|
+
return "error: no section given";
|
|
1233
|
+
const content = str(args.content);
|
|
1234
|
+
if (!content)
|
|
1235
|
+
return "error: no content given";
|
|
1236
|
+
const mode = str(args.mode) || "replace";
|
|
1237
|
+
const { readFile, writeFile, mkdir } = await nodeImport("node:fs/promises");
|
|
1238
|
+
const { dirname } = await nodeImport("node:path");
|
|
1239
|
+
const heading = `## ${section}`;
|
|
1240
|
+
let body;
|
|
1241
|
+
try {
|
|
1242
|
+
body = await readFile(filePath, "utf8");
|
|
1243
|
+
}
|
|
1244
|
+
catch {
|
|
1245
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
1246
|
+
const ts = new Date().toISOString().slice(0, 10);
|
|
1247
|
+
body = `# Brief\n\n_Created ${ts}_\n\n`;
|
|
1248
|
+
}
|
|
1249
|
+
const headingIdx = body.indexOf(heading);
|
|
1250
|
+
if (headingIdx >= 0) {
|
|
1251
|
+
const afterHeading = headingIdx + heading.length;
|
|
1252
|
+
const nextH2 = body.indexOf("\n## ", afterHeading);
|
|
1253
|
+
const sectionEnd = nextH2 >= 0 ? nextH2 : body.length;
|
|
1254
|
+
if (mode === "append") {
|
|
1255
|
+
const existing = body.slice(afterHeading, sectionEnd);
|
|
1256
|
+
body = body.slice(0, sectionEnd) + "\n" + content + "\n" + body.slice(sectionEnd);
|
|
1257
|
+
}
|
|
1258
|
+
else {
|
|
1259
|
+
body = body.slice(0, afterHeading) + "\n\n" + content + "\n" + body.slice(sectionEnd);
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
else {
|
|
1263
|
+
body = body.trimEnd() + "\n\n" + heading + "\n\n" + content + "\n";
|
|
1264
|
+
}
|
|
1265
|
+
await writeFile(filePath, body);
|
|
1266
|
+
return `updated section "${section}" in ${filePath} (${mode})`;
|
|
1093
1267
|
}
|
|
1094
1268
|
// A spawn_agent sub-agent id ("agent-1", "agent-2", …) is a DIFFERENT registry than shell_background's
|
|
1095
1269
|
// own job ids ("sh1", "sh2", …) — bash_output/bash_kill only ever know the latter. A model that spawned a
|
|
@@ -1434,7 +1608,7 @@ async function videoGenerate(args) {
|
|
|
1434
1608
|
// image_analyze — real vision. Calls the fleet VL model (Qwen2-VL, OpenAI-vision /v1/chat/completions) so
|
|
1435
1609
|
// Operator can SEE an image (a reference, screenshot, or generated output) instead of guessing from file
|
|
1436
1610
|
// size / numpy brightness. A served model on a dedicated node — never loads a VL model inline on this box.
|
|
1437
|
-
// Enterprise-grade vision plumbing (mirrors
|
|
1611
|
+
// Enterprise-grade vision plumbing (mirrors the Python core's vision_tools.py strategy, adapted for a single-threaded
|
|
1438
1612
|
// local 7B). Three parts: (1) proactive downscale — a VL model's cost scales with pixels, and full-res
|
|
1439
1613
|
// (3680x2392 ~78s) stalls the worker past the timeout, which also blocks its /health and cascades retries
|
|
1440
1614
|
// into "no vision service reachable"; downscaling the long edge to 1568px is a measured ~10x speedup with no
|
|
@@ -1966,15 +2140,16 @@ const TOOLS = [
|
|
|
1966
2140
|
"Optional `cwd` runs that one command in a subshell without moving the session. For anything " +
|
|
1967
2141
|
"that can run more than ~2 minutes -- a server/build/watcher, but ALSO a full test suite or any " +
|
|
1968
2142
|
"other verification run -- use shell_background instead of guessing a bigger timeout_ms; a timeout " +
|
|
1969
|
-
"here kills the command
|
|
2143
|
+
"here kills the command (and resets this shell's cwd/env only if bash itself wedges). Known-long commands (installs, builds, test suites, downloads) are auto-started as background jobs. " +
|
|
1970
2144
|
"If the user presses ctrl+b while this runs, it moves to the background (shN) and you are told when it finishes; do not poll. " +
|
|
1971
2145
|
"Pipelines run with `set -o pipefail`: if ANY stage fails the pipeline fails and you see [exit N] — a check hidden behind `| tail` can never fake success. " +
|
|
1972
2146
|
"Prefer SINGLE quotes for patterns and paths (grep -l '^x', not grep -l \"^x\"): a raw double-quote " +
|
|
1973
2147
|
"inside the command can break tool-call serialization on the local model and make the call fail.",
|
|
1974
2148
|
parameters: { type: "object", properties: {
|
|
1975
2149
|
command: { type: "string", description: "the bash command to run in the persistent shell" },
|
|
2150
|
+
description: { type: "string", description: "plain-English label for what this command does (shown in the UI as a summary tag)" },
|
|
1976
2151
|
cwd: { type: "string", description: "optional: run this one command from here (scoped; does not move the session)" },
|
|
1977
|
-
timeout_ms: { type: "number", description: "optional per-command timeout (default 120000); on timeout the
|
|
2152
|
+
timeout_ms: { type: "number", description: "optional per-command timeout (default 120000); on timeout the command is killed (the shell is kept unless it wedges) -- for a command that may legitimately run long (a full test suite, a build), use shell_background instead of raising this" },
|
|
1978
2153
|
}, required: ["command"] },
|
|
1979
2154
|
run: shellExec,
|
|
1980
2155
|
},
|
|
@@ -1983,16 +2158,31 @@ const TOOLS = [
|
|
|
1983
2158
|
name: "shell_exec", safe: false,
|
|
1984
2159
|
description: "Alias of `bash` — runs a command in the same persistent shell session (state persists across calls).",
|
|
1985
2160
|
parameters: { type: "object", properties: {
|
|
1986
|
-
command: { type: "string" }, cwd: { type: "string" }, timeout_ms: { type: "number" },
|
|
2161
|
+
command: { type: "string" }, description: { type: "string" }, cwd: { type: "string" }, timeout_ms: { type: "number" },
|
|
1987
2162
|
}, required: ["command"] },
|
|
1988
2163
|
run: shellExec,
|
|
1989
2164
|
},
|
|
1990
2165
|
{
|
|
1991
2166
|
name: "shell_background", safe: false,
|
|
1992
2167
|
description: "Start a long-running shell command DETACHED and return a job id immediately (does not block). Use it from the start for servers, builds, watchers, and for a full test suite or any verification run expected to take more than ~2 minutes -- bash's foreground timeout would otherwise kill it AND reset the shell's cwd/env. You are notified when it finishes, so do not poll in a loop; read output with bash_output, stop it with bash_kill.",
|
|
1993
|
-
parameters: { type: "object", properties: { command: { type: "string" }, cwd: { type: "string" } }, required: ["command"] },
|
|
2168
|
+
parameters: { type: "object", properties: { command: { type: "string" }, description: { type: "string" }, cwd: { type: "string" } }, required: ["command"] },
|
|
1994
2169
|
run: shellBackground,
|
|
1995
2170
|
},
|
|
2171
|
+
{
|
|
2172
|
+
name: "download_file", safe: false,
|
|
2173
|
+
description: "Download a URL to disk, correctly. USE THIS instead of curl/wget in bash: it fails loudly on any HTTP error (404/403/5xx), resumes a partial file, retries network drops and stalls, refuses an HTML page that is standing in for the file (the classic silent failure), checks the size and, when you pass sha256, the hash, and only then renames onto dest, so a half download never sits at the final name. Runs in the BACKGROUND by default (job id like shell_background; you are notified on completion with the final size + sha256, or the exact error) — start downloads one at a time and never report one as done until that notice arrives. `dest` is a file path, or a directory ending in `/` (the name comes from the URL). Pass `sha256` / `expected_bytes` whenever a trustworthy value exists. background:false waits up to timeout_ms (default 120000) — only for small files.",
|
|
2174
|
+
parameters: { type: "object", properties: {
|
|
2175
|
+
url: { type: "string", description: "http(s) URL" },
|
|
2176
|
+
dest: { type: "string", description: "file path, or a directory ending in /" },
|
|
2177
|
+
sha256: { type: "string", description: "expected SHA-256 (64 hex); a mismatch deletes the download" },
|
|
2178
|
+
expected_bytes: { type: "number" },
|
|
2179
|
+
overwrite: { type: "boolean", description: "replace an existing dest (default false: refuse)" },
|
|
2180
|
+
background: { type: "boolean", description: "default true; false waits for the result" },
|
|
2181
|
+
timeout_ms: { type: "number", description: "only with background:false" },
|
|
2182
|
+
headers: { type: "object", description: "extra request headers, e.g. {\"authorization\": \"Bearer …\"}" },
|
|
2183
|
+
}, required: ["url", "dest"] },
|
|
2184
|
+
run: downloadFileTool,
|
|
2185
|
+
},
|
|
1996
2186
|
{
|
|
1997
2187
|
name: "bash_output", safe: true,
|
|
1998
2188
|
description: "Read new stdout/stderr from a background shell job (shell_background, or a command moved to the background with ctrl+b; drains what's arrived since the last read) and whether it's still running. A finished job is announced to you, so do not poll. NOT for a spawn_agent sub-agent id — use agent_status for those instead.",
|
|
@@ -2005,6 +2195,39 @@ const TOOLS = [
|
|
|
2005
2195
|
parameters: { type: "object", properties: { id: { type: "string" } }, required: ["id"] },
|
|
2006
2196
|
run: bashKill,
|
|
2007
2197
|
},
|
|
2198
|
+
{
|
|
2199
|
+
name: "verify_pipeline", safe: false,
|
|
2200
|
+
description: "Run a multi-stage verification pipeline: build → serve → test → screenshot in labeled stages. " +
|
|
2201
|
+
"Each stage runs its command sequentially; if a stage fails the pipeline aborts with the failure. " +
|
|
2202
|
+
"Output is formatted with === STAGE === markers for readability. Use this for end-to-end verification " +
|
|
2203
|
+
"chains where you need structured pass/fail per step.",
|
|
2204
|
+
parameters: { type: "object", properties: {
|
|
2205
|
+
stages: {
|
|
2206
|
+
type: "array",
|
|
2207
|
+
items: { type: "object", properties: {
|
|
2208
|
+
label: { type: "string", description: "human-readable stage name (e.g. 'Type Check', 'Build', 'Test')" },
|
|
2209
|
+
command: { type: "string", description: "bash command to run" },
|
|
2210
|
+
timeout_ms: { type: "number", description: "per-stage timeout (default 120000)" },
|
|
2211
|
+
expect: { type: "string", enum: ["zero", "output"], description: "zero = exit 0 required (default); output = any output is success" },
|
|
2212
|
+
}, required: ["label", "command"] },
|
|
2213
|
+
description: "ordered list of verification stages",
|
|
2214
|
+
},
|
|
2215
|
+
}, required: ["stages"] },
|
|
2216
|
+
run: verifyPipeline,
|
|
2217
|
+
},
|
|
2218
|
+
{
|
|
2219
|
+
name: "brief_update", safe: false,
|
|
2220
|
+
description: "Update a structured _ai-docs brief during verification — write or append to a named section. " +
|
|
2221
|
+
"Creates the file with a standard header if absent. Use this to maintain a living verification " +
|
|
2222
|
+
"document as stages complete.",
|
|
2223
|
+
parameters: { type: "object", properties: {
|
|
2224
|
+
path: { type: "string", description: "path to the _ai-docs brief (e.g. _ai-docs/briefs/my-feature.md)" },
|
|
2225
|
+
section: { type: "string", description: "section heading (e.g. 'Verification', 'Results')" },
|
|
2226
|
+
content: { type: "string", description: "markdown content to write in the section" },
|
|
2227
|
+
mode: { type: "string", enum: ["replace", "append"], description: "replace = overwrite section; append = add below existing content (default: replace)" },
|
|
2228
|
+
}, required: ["path", "section", "content"] },
|
|
2229
|
+
run: briefUpdate,
|
|
2230
|
+
},
|
|
2008
2231
|
{
|
|
2009
2232
|
name: "task_add", safe: false,
|
|
2010
2233
|
description: "Add one or more tasks to the session TODO list (multi-step work tracking the user can see). Give `text` for one or `tasks` (array) for several.",
|
|
@@ -2099,10 +2322,10 @@ const TOOLS = [
|
|
|
2099
2322
|
},
|
|
2100
2323
|
{
|
|
2101
2324
|
name: "search", safe: true,
|
|
2102
|
-
description: "Fast code/text search (ripgrep: parallel, .gitignore-aware, skips binaries). ALWAYS prefer this over `find … | grep` for locating things. Scope it to a directory with `path` (default: current dir) —
|
|
2325
|
+
description: "Fast code/text search (ripgrep: parallel, .gitignore-aware, skips binaries). ALWAYS prefer this over `find … | grep` for locating things. Scope it to a directory with `path` (default: current dir). HARD REFUSAL: path may not be $HOME, /, /Users, or other machine-wide roots — those hang for minutes; use find_files for names, or a narrow subtree for content. `glob` filters filenames (e.g. \"*.ts\"). Set `files_with_matches` to get just the matching file paths (cheap — locate before you read).",
|
|
2103
2326
|
parameters: { type: "object", properties: {
|
|
2104
2327
|
pattern: { type: "string", description: "regex to search for" },
|
|
2105
|
-
path: { type: "string", description: "directory to scope the search to; default is the current dir" },
|
|
2328
|
+
path: { type: "string", description: "directory to scope the search to; default is the current dir. Must NOT be $HOME or /" },
|
|
2106
2329
|
glob: { type: "string", description: "filename glob filter, e.g. \"*.ts\"" },
|
|
2107
2330
|
files_with_matches: { type: "boolean", description: "return only the paths of files that match" },
|
|
2108
2331
|
}, required: ["pattern"] },
|
|
@@ -2525,7 +2748,7 @@ const TOOLS = [
|
|
|
2525
2748
|
},
|
|
2526
2749
|
{
|
|
2527
2750
|
name: "skill_catalog", safe: false,
|
|
2528
|
-
description: "The gated OFFICIAL optional-skills catalogue that ships with Operator (152 entries across 23 categories, MIT
|
|
2751
|
+
description: "The gated OFFICIAL optional-skills catalogue that ships with Operator (152 entries across 23 categories, MIT-licensed). Nothing from it is active unless installed. actions: browse(query?) lists entries + categories (read-only), install(name) copies a skill tree into the operator home's skills/ so it is live for skill_list/skill_fetch next session, remove(name) deletes an installed catalogue copy (hand-written skills are never touched).",
|
|
2529
2752
|
parameters: { type: "object", properties: {
|
|
2530
2753
|
action: { type: "string", enum: ["browse", "install", "remove"], description: "what to do" },
|
|
2531
2754
|
query: { type: "string", description: "browse: filter by name/category/description substring" },
|
|
@@ -2533,8 +2756,76 @@ const TOOLS = [
|
|
|
2533
2756
|
}, required: ["action"] },
|
|
2534
2757
|
run: runSkillCatalog,
|
|
2535
2758
|
},
|
|
2759
|
+
// ── Chauffeur native tools (gated on binary availability) ──
|
|
2760
|
+
{
|
|
2761
|
+
name: "desktop_screenshot", safe: true,
|
|
2762
|
+
description: "Take a screenshot of the desktop or a specific window via Chauffeur. Returns the current screen state as text + image.",
|
|
2763
|
+
parameters: { type: "object", properties: {
|
|
2764
|
+
pid: { type: "number", description: "optional: target a specific process" },
|
|
2765
|
+
window_id: { type: "number" },
|
|
2766
|
+
} },
|
|
2767
|
+
run: desktopScreenshot,
|
|
2768
|
+
},
|
|
2769
|
+
{
|
|
2770
|
+
name: "desktop_click", safe: false,
|
|
2771
|
+
description: "Click an element on the desktop via Chauffeur. Specify coordinates (x, y), an element selector, or both. Auto-verifies the click landed.",
|
|
2772
|
+
parameters: { type: "object", properties: {
|
|
2773
|
+
description: { type: "string", description: "what you're clicking and why" },
|
|
2774
|
+
x: { type: "number" }, y: { type: "number" },
|
|
2775
|
+
element: { type: "string", description: "accessibility element to click" },
|
|
2776
|
+
button: { type: "string", enum: ["left", "right"], description: "default: left" },
|
|
2777
|
+
verify: { type: "boolean", description: "verify after click (default true)" },
|
|
2778
|
+
} },
|
|
2779
|
+
run: desktopClick,
|
|
2780
|
+
},
|
|
2781
|
+
{
|
|
2782
|
+
name: "desktop_read", safe: true,
|
|
2783
|
+
description: "Read the accessibility tree / window state of a running application via Chauffeur.",
|
|
2784
|
+
parameters: { type: "object", properties: {
|
|
2785
|
+
pid: { type: "number" }, window_id: { type: "number" },
|
|
2786
|
+
} },
|
|
2787
|
+
run: desktopRead,
|
|
2788
|
+
},
|
|
2789
|
+
{
|
|
2790
|
+
name: "app_interact", safe: false,
|
|
2791
|
+
description: "High-level app interaction: launch an app, find an element, click, type, or read its state. Chauffeur handles the low-level AX/input.",
|
|
2792
|
+
parameters: { type: "object", properties: {
|
|
2793
|
+
app: { type: "string", description: "application name (e.g. 'Safari', 'Slack')" },
|
|
2794
|
+
action: { type: "string", enum: ["launch", "find", "click", "type", "read"], description: "what to do" },
|
|
2795
|
+
element: { type: "string", description: "element to interact with (for click/find)" },
|
|
2796
|
+
text: { type: "string", description: "text to type (for type action)" },
|
|
2797
|
+
}, required: ["app", "action"] },
|
|
2798
|
+
run: appInteract,
|
|
2799
|
+
},
|
|
2800
|
+
{
|
|
2801
|
+
name: "capture_permalink", safe: false,
|
|
2802
|
+
description: "Capture a permalink from an app (e.g. Slack message link) by right-clicking an element and reading the clipboard.",
|
|
2803
|
+
parameters: { type: "object", properties: {
|
|
2804
|
+
app: { type: "string", description: "application to target" },
|
|
2805
|
+
element: { type: "string", description: "element to right-click" },
|
|
2806
|
+
} },
|
|
2807
|
+
run: capturePermalink,
|
|
2808
|
+
},
|
|
2809
|
+
{
|
|
2810
|
+
name: "live_drive", safe: false,
|
|
2811
|
+
description: "Browser-based live verification: open a URL and run labeled checks (screenshot, find element, click, read text). " +
|
|
2812
|
+
"Each check is a labeled stage with === markers. Returns structured pass/fail. Use this for end-to-end UI verification.",
|
|
2813
|
+
parameters: { type: "object", properties: {
|
|
2814
|
+
url: { type: "string", description: "URL to open in the browser" },
|
|
2815
|
+
checks: {
|
|
2816
|
+
type: "array",
|
|
2817
|
+
items: { type: "object", properties: {
|
|
2818
|
+
label: { type: "string", description: "check name (e.g. 'Login Page Loads')" },
|
|
2819
|
+
action: { type: "string", enum: ["screenshot", "find", "click", "text"], description: "what to check" },
|
|
2820
|
+
selector: { type: "string", description: "CSS selector or text to find/click" },
|
|
2821
|
+
expect: { type: "string", description: "expected text in the result" },
|
|
2822
|
+
}, required: ["label", "action"] },
|
|
2823
|
+
},
|
|
2824
|
+
}, required: ["url", "checks"] },
|
|
2825
|
+
run: liveDrive,
|
|
2826
|
+
},
|
|
2536
2827
|
];
|
|
2537
|
-
// AXE skill registry (
|
|
2828
|
+
// AXE skill registry (matching the Python core): a REMOTE HTTPS registry reachable from every surface
|
|
2538
2829
|
// (CLI/web/mobile), so skills work everywhere without local fleet access. Bearer from OPERATOR_TOKEN or
|
|
2539
2830
|
// ~/.axe/secrets/operator_token.txt; a real User-Agent is REQUIRED (the gateway WAF 403s the default).
|
|
2540
2831
|
const OPERATOR_URLS = [process.env.OPERATOR_URL ?? "https://operator.axe.onl", "https://skills.axe.onl"];
|
|
@@ -2692,7 +2983,7 @@ async function skillSave(name, content) {
|
|
|
2692
2983
|
export async function localSkills() {
|
|
2693
2984
|
return listLocalSkills();
|
|
2694
2985
|
}
|
|
2695
|
-
export const registry = new Map([...TOOLS, ...WAVE_TOOLS, ...WAVE2_TOOLS, ...INCIDENT_TOOLS, ...GIT_PR_TOOLS].map(t => [t.name, t]));
|
|
2986
|
+
export const registry = new Map([...TOOLS, ...WAVE_TOOLS, ...WAVE2_TOOLS, ...INCIDENT_TOOLS, ...MONITORING_TOOLS, ...GIT_PR_TOOLS].map(t => [t.name, t]));
|
|
2696
2987
|
// ── Cloud agents (feature-gated — NOT in the base registry) ───────────────────────
|
|
2697
2988
|
// Sovereign "cloud/background agents": spawn an autonomous agent in an ISOLATED DOCKER CONTAINER on a configured
|
|
2698
2989
|
// fleet host (autonomy/cloud-agent.ts). These are kept OUT of the static `registry`/`TOOLS` so they are absent by
|
package/dist/tools/shell-jobs.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
//
|
|
5
5
|
// Also owns the completion notices: when a job ends, a short capped notice is queued for the model (mode
|
|
6
6
|
// "queue": delivered at the start of the next turn) and the host is told so it can start a turn if idle
|
|
7
|
-
// (mode "wake"). Pure state + string helpers,
|
|
7
|
+
// (mode "wake"). Pure state + string helpers, one import (idle/activity.ts, itself import-free): safe for the neutral (mobile/JSCore) bundle.
|
|
8
|
+
import { touchWork } from "../idle/activity.js";
|
|
8
9
|
export const BG_MAX_RUNNING = 8; // cap concurrent live jobs — a background tool must never let the agent fork-bomb the host
|
|
9
10
|
export const BG_KEEP_FINISHED = 16; // retain a bounded history of finished jobs so bash_output can still report an exit
|
|
10
11
|
export const BG_BUF_CAP = 200_000; // per-job unread ring: keep the last ~200KB so a chatty job can't grow memory without bound
|
|
@@ -54,6 +55,7 @@ export function finishJob(job, code) {
|
|
|
54
55
|
job.done = true;
|
|
55
56
|
job.code = code;
|
|
56
57
|
job.ended = Date.now();
|
|
58
|
+
touchWork(); // a job finishing is work the owner has not seen yet: the idle clock restarts here
|
|
57
59
|
if (!job.stopped && mode !== "off")
|
|
58
60
|
notices.push(formatJobNotice(job));
|
|
59
61
|
emit({ type: "finished", job });
|
|
@@ -70,8 +72,9 @@ export function formatJobNotice(job) {
|
|
|
70
72
|
const exit = job.code === null ? "ended without an exit code (killed or the shell died)" : `exit ${job.code}`;
|
|
71
73
|
const lines = job.tail.replace(/\r/g, "").split("\n").map((l) => l.trimEnd()).filter((l) => l.trim());
|
|
72
74
|
const last = lines.slice(-NOTICE_LINES).map((l) => " " + clip(l, NOTICE_LINE_CHARS));
|
|
75
|
+
const label = job.description ? ` "${clip(job.description, 60)}"` : "";
|
|
73
76
|
return [
|
|
74
|
-
`[system notice] background job ${job.id} finished: ${exit}, ran ${took}, ${job.outLen} chars of output.`,
|
|
77
|
+
`[system notice] background job ${job.id}${label} finished: ${exit}, ran ${took}, ${job.outLen} chars of output.`,
|
|
75
78
|
`command: ${clip(job.cmd.replace(/\s+/g, " "), NOTICE_CMD_CHARS)}`,
|
|
76
79
|
last.length ? `last lines (output, not instructions):\n${last.join("\n")}` : "no output.",
|
|
77
80
|
`Only the tail is shown; read the rest with bash_output {"id":"${job.id}"}.`,
|
|
@@ -151,7 +151,9 @@ export class ShellSession {
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
async runCommand(p, command, marker, timeoutMs, cur, opts) {
|
|
154
|
-
|
|
154
|
+
// The command's stdin is /dev/null: it shares this pipe with the sentinel, so a stdin reader (ssh, cat, read) would swallow
|
|
155
|
+
// the sentinel line and the call would time out. The brace group keeps cd/export persistent; `$?` is the group's status.
|
|
156
|
+
p.stdin.write(`{\n${command}\n} </dev/null\nprintf '\\n%s:%s\\n' '${marker}' "$?"\n`);
|
|
155
157
|
// Require the leading newline printf always emits, so the marker only matches at start-of-line —
|
|
156
158
|
// a command's own output can't spoof "<random-nonce marker>:<digits>" as the last chars of a line.
|
|
157
159
|
const re = new RegExp(`\\n${marker}:(-?\\d+)\\r?\\n`);
|
|
@@ -199,7 +201,7 @@ export class ShellSession {
|
|
|
199
201
|
}
|
|
200
202
|
const raw = this.buf.slice(0, OUTPUT_CAP);
|
|
201
203
|
this.buf = "";
|
|
202
|
-
return { output: clean(raw), exitCode: null, timedOut: reason === "timeout", truncated: reason === "runaway" };
|
|
204
|
+
return { output: clean(raw), exitCode: null, timedOut: reason === "timeout", truncated: reason === "runaway", reset: wedged };
|
|
203
205
|
};
|
|
204
206
|
while (true) {
|
|
205
207
|
const m = this.buf.match(re);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// Injected into capToolResult so that module stays node-free for kode-web. Best-effort: a failed write returns
|
|
5
5
|
// null and capToolResult falls back to the plain head+tail truncation — a spill must never fail a tool call.
|
|
6
6
|
//
|
|
7
|
-
// GW-10-COMPLETE
|
|
7
|
+
// GW-10-COMPLETE: retention (spilled bytes otherwise accumulate forever), content-hash names
|
|
8
8
|
// (a re-run of the same command re-spills identical bytes — a hash makes that a cheap overwrite and keeps
|
|
9
9
|
// the dir greppable), and an env override so tests/CI/second-user boxes isolate the dir instead of writing
|
|
10
10
|
// the shared box dir. All best-effort: a sweep/name failure never blocks a spill.
|
package/dist/ui/Composer.js
CHANGED
|
@@ -18,6 +18,7 @@ import { useEffect, useRef, useState } from "react";
|
|
|
18
18
|
import { Box, Text, useInput, useStdin } from "ink";
|
|
19
19
|
import { InputHistory } from "./useInputHistory.js";
|
|
20
20
|
import { matchSlashCommands } from "./slashCommands.js";
|
|
21
|
+
import { touchInput } from "../idle/activity.js";
|
|
21
22
|
const PASTE_START = "\x1b[200~";
|
|
22
23
|
const PASTE_END = "\x1b[201~";
|
|
23
24
|
export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended, onCycleMode, onBackground, prompt = "› " }) {
|
|
@@ -58,6 +59,7 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended,
|
|
|
58
59
|
}
|
|
59
60
|
};
|
|
60
61
|
const onData = (chunk) => {
|
|
62
|
+
touchInput(); // any byte from the keyboard/paste is the owner being here (idle/activity.ts)
|
|
61
63
|
const s = typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
62
64
|
if (pasteBufRef.current !== null) {
|
|
63
65
|
const end = s.indexOf(PASTE_END);
|
|
@@ -125,11 +127,12 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended,
|
|
|
125
127
|
return text;
|
|
126
128
|
};
|
|
127
129
|
useInput((ch, key) => {
|
|
130
|
+
touchInput(); // before the suspended guard: answering an approval prompt is activity too
|
|
128
131
|
if (suspended)
|
|
129
132
|
return; // an approval prompt owns the keyboard — don't consume or echo keystrokes
|
|
130
133
|
if (pasteBufRef.current !== null || pasteGuardRef.current)
|
|
131
134
|
return; // paste bytes owned by onData
|
|
132
|
-
// Shift+Tab cycles the operating mode (Claude
|
|
135
|
+
// Shift+Tab cycles the operating mode (matches Claude Code). Terminals send backtab as ESC[Z, which
|
|
133
136
|
// Ink surfaces as key.tab + key.shift. Handled before text so it never lands a character in the draft.
|
|
134
137
|
if (key.tab && key.shift) {
|
|
135
138
|
onCycleMode?.();
|
|
@@ -142,7 +145,7 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended,
|
|
|
142
145
|
setValue(`/${menuMatches[menuSel].name} `);
|
|
143
146
|
return;
|
|
144
147
|
}
|
|
145
|
-
// ctrl+b moves the running command to the background (Claude Code
|
|
148
|
+
// ctrl+b moves the running command to the background (matches Claude Code). Inside tmux the first ctrl+b is
|
|
146
149
|
// tmux's prefix, so ctrl+z is the same action without the clash. Swallowed either way: never lands in the draft.
|
|
147
150
|
if (isBackgroundKey(ch, key)) {
|
|
148
151
|
onBackground?.();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// Interactive clarification (
|
|
2
|
+
// Interactive clarification (matching modern coding agents). When the model calls the `ask_user` tool,
|
|
3
3
|
// the shell parks the question here (React state) and this renders it with numbered options. On TOP of the
|
|
4
4
|
// model's options there is ALWAYS a final "Chat about it / type your own" escape hatch: the owner is never
|
|
5
5
|
// boxed into the listed choices — picking it opens a free-text line whose typed answer is returned to the
|