@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/paths.js
CHANGED
|
@@ -17,3 +17,157 @@ export function expandPath(p) {
|
|
|
17
17
|
return home + p.slice(1);
|
|
18
18
|
return p;
|
|
19
19
|
}
|
|
20
|
+
/** Strip trailing slashes; keep "/" as "/". */
|
|
21
|
+
function normPath(p) {
|
|
22
|
+
if (!p)
|
|
23
|
+
return p;
|
|
24
|
+
const n = p.replace(/\/+$/, "");
|
|
25
|
+
return n || "/";
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolve a search path to an absolute string without node:path (neutral-safe).
|
|
29
|
+
* Relative paths join against `cwd` (default process.cwd()).
|
|
30
|
+
*/
|
|
31
|
+
export function resolveSearchPath(raw, cwd) {
|
|
32
|
+
const expanded = expandPath(raw || ".");
|
|
33
|
+
if (expanded.startsWith("/") || /^[A-Za-z]:[\\/]/.test(expanded))
|
|
34
|
+
return normPath(expanded);
|
|
35
|
+
const base = normPath(cwd ?? (typeof process !== "undefined" ? process.cwd() : ".")) || ".";
|
|
36
|
+
if (expanded === "." || expanded === "")
|
|
37
|
+
return base;
|
|
38
|
+
return normPath(`${base}/${expanded}`);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Hard gate for content search (`search` / `grep_search`): refuse scopes that walk the whole
|
|
42
|
+
* machine or the owner's home. Soft "never search ~" in the tool description is not enough —
|
|
43
|
+
* models still pass path=$HOME and hang for minutes (300s tool timeout). Point them at
|
|
44
|
+
* find_files (name index) or a narrow subtree instead.
|
|
45
|
+
*
|
|
46
|
+
* Returns an error string to surface to the model, or null when the scope is OK.
|
|
47
|
+
*/
|
|
48
|
+
export function assertContentSearchScope(rawPath, cwd) {
|
|
49
|
+
const abs = resolveSearchPath(rawPath || ".", cwd);
|
|
50
|
+
const home = normPath(process.env.HOME ?? process.env.USERPROFILE ?? "");
|
|
51
|
+
// Top-level roots that always mean "search the world".
|
|
52
|
+
const BROAD = new Set([
|
|
53
|
+
"/",
|
|
54
|
+
"/Users",
|
|
55
|
+
"/home",
|
|
56
|
+
"/private",
|
|
57
|
+
"/var",
|
|
58
|
+
"/private/var",
|
|
59
|
+
"/tmp",
|
|
60
|
+
"/private/tmp",
|
|
61
|
+
"/System",
|
|
62
|
+
"/Library",
|
|
63
|
+
"/Applications",
|
|
64
|
+
]);
|
|
65
|
+
if (BROAD.has(abs) || (home && abs === home)) {
|
|
66
|
+
return (`error: content search refused at "${rawPath || "."}" (resolves to ${abs}) — that scope is ` +
|
|
67
|
+
`home/machine-wide and will hang for minutes. For a FILE/PROJECT NAME use find_files ` +
|
|
68
|
+
`{"query":"…"}. For CONTENT, pass a narrow path (cwd subtree, ~/work/<repo>, ~/.axe/repos/<name>). ` +
|
|
69
|
+
`For a fleet host/box (e.g. acropolis): read ~/.ssh/config, \`gh repo view\`, AGENTS.md — ` +
|
|
70
|
+
`do not ripgrep $HOME.`);
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
const SHELL_REFUSE_MSG = "error: shell content search refused — recursive grep/rg/find over $HOME (or /, /Users, /tmp) " +
|
|
75
|
+
"hangs for minutes. Use the `search` tool with a narrow path, or find_files for names. " +
|
|
76
|
+
"For a fleet host/box: ~/.ssh/config → gh repo view → AGENTS.md. Do not bypass with bash.";
|
|
77
|
+
/**
|
|
78
|
+
* Heuristic gate for bash / shell_exec / shell_background: catch the common bypass where the model
|
|
79
|
+
* is refused by `search(path=$HOME)` and retries via `grep -r … ~` / `rg … $HOME` / unbounded `find ~`.
|
|
80
|
+
* Conservative — only fires on recursive content tools aimed at a broad root, not every mention of HOME.
|
|
81
|
+
*/
|
|
82
|
+
export function assertShellHomeWideSearch(command) {
|
|
83
|
+
if (!command || !command.trim())
|
|
84
|
+
return null;
|
|
85
|
+
const home = normPath(process.env.HOME ?? process.env.USERPROFILE ?? "");
|
|
86
|
+
// Normalize absolute home + ~ + $HOME spellings so one matcher covers all.
|
|
87
|
+
let c = command;
|
|
88
|
+
if (home) {
|
|
89
|
+
// Escape for literal split; replace all occurrences with the token $HOME.
|
|
90
|
+
c = c.split(home).join("$HOME");
|
|
91
|
+
}
|
|
92
|
+
c = c.replace(/(^|[\s"'=(])~(?=\/|[\s"')|;&#`$]|$)/g, "$1$HOME");
|
|
93
|
+
c = c.replace(/\$\{HOME\}/g, "$HOME");
|
|
94
|
+
// Bare roots only — `$HOME/work/foo` must still be allowed. Trailing slash OK; a subpath is not.
|
|
95
|
+
// (Avoid template literals here — a backtick in the char class would terminate them.)
|
|
96
|
+
const bare = "(?:^|[\\s\"'=(])(?:\\$HOME|/Users|/home|/tmp|/)\\/?(?=[\\s\"')|;&#`]|$)";
|
|
97
|
+
const hasBareBroadRoot = new RegExp(bare).test(c);
|
|
98
|
+
if (!hasBareBroadRoot)
|
|
99
|
+
return null;
|
|
100
|
+
// grep/egrep/fgrep with a recursive flag (-r, -R, or combined like -rn / -rni).
|
|
101
|
+
const isRecursiveGrep = /\b(?:grep|egrep|fgrep|ggrep)\b/.test(c) &&
|
|
102
|
+
/(?:^|\s)-[A-Za-z0-9-]*[rR][A-Za-z0-9-]*(?:\s|=|$)/.test(c);
|
|
103
|
+
const isRg = /\brg\b/.test(c);
|
|
104
|
+
// find $HOME / /Users without a tight maxdepth (1–3) — the classic hang.
|
|
105
|
+
const isFindHome = /\bfind\b/.test(c) &&
|
|
106
|
+
!/-maxdepth\s+[123]\b/.test(c);
|
|
107
|
+
if (isRecursiveGrep || isRg || isFindHome)
|
|
108
|
+
return SHELL_REFUSE_MSG;
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
export const BLIND_DOWNLOAD_MSG = "refused: `curl … -o/-O <file>` without `-f` / `--fail` (or `--fail-with-body`) saves an HTTP error page as if it were the file, and " +
|
|
112
|
+
"a silent `-s` hides that it happened — the 0-byte / HTML-instead-of-ISO failure. Use the `download_file` tool " +
|
|
113
|
+
"(fails loudly, resumes, retries, verifies size/sha256, never leaves a half file), or add `-f` (and `--retry 5 -C -`) " +
|
|
114
|
+
"and check the size afterwards. Run long transfers with shell_background or download_file, one at a time.";
|
|
115
|
+
/**
|
|
116
|
+
* Hard gate for bash / shell_exec / shell_background: a `curl` that writes to a FILE without failing on HTTP errors.
|
|
117
|
+
* Soft persona guidance did not stop the model; this does. Conservative — a response written to /dev/null or stdout,
|
|
118
|
+
* `curl … | jq`, and `curl -fsSL -o f url` all pass.
|
|
119
|
+
*/
|
|
120
|
+
export function assertShellBlindDownload(command) {
|
|
121
|
+
if (!command || !/\bcurl\b/.test(command))
|
|
122
|
+
return null;
|
|
123
|
+
// Split on shell separators so `curl -f … && curl -o f …` is judged per command.
|
|
124
|
+
for (const seg of command.split(/&&|\|\||;|\||\n|&(?!>)/)) {
|
|
125
|
+
const toks = seg.trim().split(/\s+/);
|
|
126
|
+
// The command word: skip `VAR=val`, sudo/nohup/time/command and `timeout N` so `echo "use curl -o x"` is not mistaken for a curl.
|
|
127
|
+
let k = 0;
|
|
128
|
+
while (k < toks.length && (/^[A-Za-z_][A-Za-z0-9_]*=/.test(toks[k]) || ["sudo", "nohup", "time", "command", "exec"].includes(toks[k]) || (toks[k] === "timeout" && ++k)))
|
|
129
|
+
k++;
|
|
130
|
+
if (!(toks[k] === "curl" || toks[k]?.endsWith("/curl")))
|
|
131
|
+
continue;
|
|
132
|
+
const args = toks.slice(k + 1);
|
|
133
|
+
let toFile = false;
|
|
134
|
+
let fails = false;
|
|
135
|
+
for (let i = 0; i < args.length; i++) {
|
|
136
|
+
const a = args[i];
|
|
137
|
+
if (a === "-O" || a === "--remote-name" || a === "--remote-name-all") {
|
|
138
|
+
toFile = true;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (a === "-o" || a === "--output") {
|
|
142
|
+
const target = args[i + 1] ?? "";
|
|
143
|
+
if (target !== "/dev/null" && target !== "-" && target !== "NUL")
|
|
144
|
+
toFile = true;
|
|
145
|
+
i++;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (/^--output=/.test(a)) {
|
|
149
|
+
if (!/^--output=(\/dev\/null|-|NUL)$/.test(a))
|
|
150
|
+
toFile = true;
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (a === "--fail" || a === "--fail-with-body" || a === "--fail-early") {
|
|
154
|
+
fails = true;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
// combined short flags: -fsSL, -sfL, -fL … ; an arg that is -o/-O fused (-sLo file) also writes to a file
|
|
158
|
+
if (/^-[A-Za-z]+$/.test(a)) {
|
|
159
|
+
if (a.includes("f"))
|
|
160
|
+
fails = true;
|
|
161
|
+
if (a.includes("O"))
|
|
162
|
+
toFile = true;
|
|
163
|
+
if (a.endsWith("o") && a.length > 2) {
|
|
164
|
+
toFile = !/^(\/dev\/null|-|NUL)$/.test(args[i + 1] ?? "");
|
|
165
|
+
i++;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (toFile && !fails)
|
|
170
|
+
return BLIND_DOWNLOAD_MSG;
|
|
171
|
+
}
|
|
172
|
+
return null;
|
|
173
|
+
}
|