@0perator/operator 0.1.235 → 0.1.261
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/README.md +2 -1
- package/dashboard/server.mjs +1 -1
- package/dist/acp/agent.js +290 -62
- package/dist/acp/auth.js +44 -0
- package/dist/acp/prompt.js +41 -0
- package/dist/acp/run.js +40 -15
- package/dist/acp/tool-map.js +48 -0
- package/dist/auth/byo.js +15 -8
- package/dist/auth/client.js +12 -6
- package/dist/auth/commands.js +39 -4
- package/dist/auth/identity.js +136 -0
- package/dist/auth/store.js +7 -5
- package/dist/autonomy/board.js +3 -2
- package/dist/autonomy/cron.js +332 -0
- package/dist/autonomy/delegate.js +168 -0
- package/dist/autonomy/media-robot.js +2 -3
- package/dist/autonomy/routines.js +5 -4
- package/dist/autonomy/session-factory.js +6 -1
- package/dist/browser/cdp.js +266 -0
- package/dist/browser/session.js +286 -0
- package/dist/cli.js +75 -11
- package/dist/config/brand.js +3 -3
- package/dist/config/home.js +70 -0
- package/dist/config/managed.js +230 -0
- package/dist/config/persona.js +59 -9
- package/dist/config/scaffold.js +142 -0
- package/dist/config/settings.js +38 -4
- package/dist/config/skills-index.js +175 -0
- package/dist/consolidation/scheduler.js +3 -3
- package/dist/consolidation/sleep.js +3 -3
- package/dist/engine/agent.js +80 -13
- package/dist/engine/aurora.js +6 -0
- package/dist/engine/batch-scheduler.js +128 -0
- package/dist/engine/json-repair.js +105 -0
- package/dist/engine/messages.js +50 -3
- package/dist/engine/rolling-summary.js +7 -5
- package/dist/enterprise/cli.js +137 -0
- package/dist/flywheel/processor.js +30 -2
- package/dist/flywheel/secret-gate.js +123 -0
- package/dist/mcp/index.js +18 -24
- package/dist/memory/index.js +0 -0
- package/dist/memory/session-index.js +324 -0
- package/dist/memory/session-rewind.js +92 -0
- package/dist/memory/state-maintenance.js +441 -0
- package/dist/observability/index.js +3 -3
- package/dist/permissions/index.js +24 -12
- package/dist/router/models.js +27 -8
- package/dist/selfimprove/index.js +9 -7
- package/dist/session.js +16 -6
- package/dist/skills/catalogue.js +167 -0
- package/dist/telemetry/audit-verify.js +94 -0
- package/dist/telemetry/events.js +86 -6
- package/dist/telemetry/lifecycle.js +18 -0
- package/dist/tools/deferred.js +117 -0
- package/dist/tools/executor.js +19 -20
- package/dist/tools/memory.js +117 -0
- package/dist/tools/registry.js +152 -21
- package/dist/tools/sandbox.js +63 -17
- package/dist/tools/searxng.js +2 -2
- package/dist/tools/tool-output-spill.js +2 -2
- package/dist/ui/Transcript.js +14 -2
- package/dist/ui/useInputHistory.js +3 -3
- package/dist/vault/cli.js +48 -0
- package/dist/vault/store.js +157 -0
- package/dist/vault/tool.js +50 -0
- package/package.json +3 -5
- package/CHANGELOG.md +0 -2487
- package/dist/ui/BusTray.js +0 -70
package/dist/tools/executor.js
CHANGED
|
@@ -17,10 +17,14 @@ import { shellKeyStore } from "./shell-context.js";
|
|
|
17
17
|
import { capToolResult } from "./result-cap.js";
|
|
18
18
|
import { spillToolOutput } from "./tool-output-spill.js"; // GW-10: lossless eviction — spill big outputs, hand back a re-readable pointer
|
|
19
19
|
export { TOOL_RESULT_MAX_CHARS, capToolResult } from "./result-cap.js";
|
|
20
|
+
import { runBatch, defaultClassify, defaultKeys } from "../engine/batch-scheduler.js";
|
|
20
21
|
// Command tools whose working directory should default to the executor root (they take an optional `cwd`).
|
|
21
22
|
const CWD_TOOLS = new Set(["bash", "shell_exec", "shell_background", "git", "git_command", "git_status"]);
|
|
22
23
|
// Args that name a filesystem path the file tools read/write; a RELATIVE one is resolved under the root.
|
|
23
24
|
const PATH_ARGS = ["path", "file", "filename", "workspace"];
|
|
25
|
+
// Tools that take an optional `workspace` and otherwise fall back to process.cwd() — a rooted session must
|
|
26
|
+
// default it to its own root or the call lands in whatever directory the host process happens to run in.
|
|
27
|
+
const WORKSPACE_TOOLS = new Set(["checkpoint"]);
|
|
24
28
|
/** Reroot a tool call's args under `root` so a session's file/shell tools all act inside its own directory
|
|
25
29
|
* (e.g. a background agent's git worktree) instead of the shared process cwd. Pure: relative path args are
|
|
26
30
|
* joined under root; command tools default their cwd to root; absolute and ~ paths are left untouched
|
|
@@ -36,6 +40,8 @@ export function rootArgs(name, args, root) {
|
|
|
36
40
|
a.cwd = join(root, a.cwd);
|
|
37
41
|
else if (a.cwd == null && CWD_TOOLS.has(name))
|
|
38
42
|
a.cwd = root;
|
|
43
|
+
if (a.workspace == null && WORKSPACE_TOOLS.has(name))
|
|
44
|
+
a.workspace = root;
|
|
39
45
|
return a;
|
|
40
46
|
}
|
|
41
47
|
const LOOP_GUARD_THRESHOLD = 5; // must match agent.ts LOOP_GUARD_LIMIT so this secondary guard never fires first
|
|
@@ -93,26 +99,19 @@ export class Executor {
|
|
|
93
99
|
return `error running ${name}: ${e?.message ?? e}`;
|
|
94
100
|
}
|
|
95
101
|
}
|
|
102
|
+
sched = {
|
|
103
|
+
classify: defaultClassify("", (n) => this.reg.get(n)?.safe === true),
|
|
104
|
+
keys: defaultKeys,
|
|
105
|
+
};
|
|
96
106
|
async executeParallel(calls, onSettle) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
while (i < calls.length) {
|
|
107
|
-
if (!this.reg.get(calls[i].name)?.safe) {
|
|
108
|
-
await runAt(i++);
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
const batch = [];
|
|
112
|
-
while (i < calls.length && this.reg.get(calls[i].name)?.safe)
|
|
113
|
-
batch.push(runAt(i++));
|
|
114
|
-
await Promise.all(batch);
|
|
115
|
-
}
|
|
116
|
-
return results;
|
|
107
|
+
// BTX: one shared DAG scheduler (engine/batch-scheduler.ts) — per-resource write chains,
|
|
108
|
+
// reads wait only for conflicting prior writes, device tools barrier-serialize. This replaces
|
|
109
|
+
// the 0.1.225 contiguous walk: same guarantees, strictly more overlap.
|
|
110
|
+
return runBatch(calls, {
|
|
111
|
+
classify: this.sched.classify,
|
|
112
|
+
keys: (n, a) => this.sched.keys(n, a),
|
|
113
|
+
runOne: (c) => this.execute(c.name, c.args),
|
|
114
|
+
onSettle,
|
|
115
|
+
});
|
|
117
116
|
}
|
|
118
117
|
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Browser-safe: this module is reachable from the engine bundle through the tool registry, so the
|
|
2
|
+
// node builtins load via dynamic import — the same nodeImport pattern as registry.ts / sandbox.ts —
|
|
3
|
+
// keeping esbuild --platform=neutral from statically resolving them (index.browser.ts must stay
|
|
4
|
+
// node-free). On the mobile surface the tools run natively in Swift and never hit this path.
|
|
5
|
+
import { operatorPath } from "../config/home.js";
|
|
6
|
+
const nodeImport = (m) => import(/* @vite-ignore */ m);
|
|
7
|
+
let _fs = null;
|
|
8
|
+
let _path = null;
|
|
9
|
+
async function fsp() {
|
|
10
|
+
if (!_fs)
|
|
11
|
+
_fs = (await nodeImport("node:fs"));
|
|
12
|
+
if (!_path)
|
|
13
|
+
_path = (await nodeImport("node:path"));
|
|
14
|
+
return { fs: _fs, path: _path };
|
|
15
|
+
}
|
|
16
|
+
const BUDGETS = { memory: 2200, user: 1375 };
|
|
17
|
+
const TARGETS = { memory: "MEMORY.md", user: "USER.md" };
|
|
18
|
+
function filePath(target) { return operatorPath("memories", TARGETS[target]); }
|
|
19
|
+
function lockPath(target) { return filePath(target) + ".lock"; }
|
|
20
|
+
const LOCK_STALE_MS = 30_000; // a lock older than this belongs to a crashed writer — reclaim it
|
|
21
|
+
async function acquireLock(target) {
|
|
22
|
+
const { fs, path } = await fsp();
|
|
23
|
+
const lp = lockPath(target);
|
|
24
|
+
fs.mkdirSync(path.dirname(lp), { recursive: true });
|
|
25
|
+
const pid = globalThis.process?.pid ?? 0;
|
|
26
|
+
// "wx" = atomic create-exclusive — the race-free lock (existsSync+writeFileSync is TOCTOU).
|
|
27
|
+
// On EEXIST: reclaim the lock if it is stale (writer crashed), else report the live holder.
|
|
28
|
+
for (let attempt = 0;; attempt++) {
|
|
29
|
+
try {
|
|
30
|
+
fs.writeFileSync(lp, `${pid}\n`, { flag: "wx" });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
if (e?.code !== "EEXIST")
|
|
35
|
+
throw e;
|
|
36
|
+
let ageMs = 0;
|
|
37
|
+
try {
|
|
38
|
+
ageMs = Date.now() - fs.statSync(lp).mtimeMs;
|
|
39
|
+
}
|
|
40
|
+
catch { /* vanished mid-check — retry */ }
|
|
41
|
+
if (ageMs < LOCK_STALE_MS) {
|
|
42
|
+
let holder = "?";
|
|
43
|
+
try {
|
|
44
|
+
holder = fs.readFileSync(lp, "utf8").trim() || "?";
|
|
45
|
+
}
|
|
46
|
+
catch { /* best-effort */ }
|
|
47
|
+
throw new Error(`memory: ${target} is locked by pid ${holder} (${lp}) — another write is in progress`);
|
|
48
|
+
}
|
|
49
|
+
if (attempt >= 1)
|
|
50
|
+
throw new Error(`memory: ${target} lock could not be reclaimed (${lp})`);
|
|
51
|
+
try {
|
|
52
|
+
fs.unlinkSync(lp);
|
|
53
|
+
}
|
|
54
|
+
catch { /* someone else reclaimed it — loop retries the create */ }
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function releaseLock(target) {
|
|
59
|
+
try {
|
|
60
|
+
const { fs } = await fsp();
|
|
61
|
+
fs.unlinkSync(lockPath(target));
|
|
62
|
+
}
|
|
63
|
+
catch { /* best-effort */ }
|
|
64
|
+
}
|
|
65
|
+
export async function runMemoryTool(args) {
|
|
66
|
+
const target = String(args.target ?? "memory");
|
|
67
|
+
if (!TARGETS[target])
|
|
68
|
+
return `error: target must be 'memory' or 'user', got '${target}'`;
|
|
69
|
+
const ops = args.operations;
|
|
70
|
+
if (!Array.isArray(ops) || !ops.length)
|
|
71
|
+
return "error: operations must be a non-empty array of {action, content?, old_text?}";
|
|
72
|
+
const { fs, path } = await fsp();
|
|
73
|
+
const fp = filePath(target);
|
|
74
|
+
await acquireLock(target);
|
|
75
|
+
try {
|
|
76
|
+
let text = "";
|
|
77
|
+
try {
|
|
78
|
+
text = fs.readFileSync(fp, "utf8");
|
|
79
|
+
}
|
|
80
|
+
catch { /* file may not exist yet */ }
|
|
81
|
+
for (const op of ops) {
|
|
82
|
+
switch (op.action) {
|
|
83
|
+
case "add":
|
|
84
|
+
if (!op.content)
|
|
85
|
+
return "error: add needs content";
|
|
86
|
+
text = text ? text.trimEnd() + "\n" + op.content + "\n" : op.content + "\n";
|
|
87
|
+
break;
|
|
88
|
+
case "replace":
|
|
89
|
+
if (!op.old_text || !op.content)
|
|
90
|
+
return "error: replace needs old_text and content";
|
|
91
|
+
if (!text.includes(op.old_text))
|
|
92
|
+
return `error: old_text not found in ${TARGETS[target]}`;
|
|
93
|
+
text = text.replace(op.old_text, op.content);
|
|
94
|
+
break;
|
|
95
|
+
case "remove":
|
|
96
|
+
if (!op.old_text)
|
|
97
|
+
return "error: remove needs old_text";
|
|
98
|
+
if (!text.includes(op.old_text))
|
|
99
|
+
return `error: old_text not found in ${TARGETS[target]}`;
|
|
100
|
+
text = text.replace(op.old_text, "");
|
|
101
|
+
break;
|
|
102
|
+
default:
|
|
103
|
+
return `error: unknown action '${op.action}' — use add, replace, or remove`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
text = text.replace(/\n{3,}/g, "\n\n").trim() + "\n";
|
|
107
|
+
const budget = BUDGETS[target];
|
|
108
|
+
if (text.length > budget)
|
|
109
|
+
return `error: result is ${text.length} chars, exceeds ${target} budget of ${budget} — reduce content`;
|
|
110
|
+
fs.mkdirSync(path.dirname(fp), { recursive: true });
|
|
111
|
+
fs.writeFileSync(fp, text);
|
|
112
|
+
return `wrote ${TARGETS[target]} (${text.length}/${budget} chars, ${ops.length} op${ops.length === 1 ? "" : "s"} applied)`;
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
await releaseLock(target);
|
|
116
|
+
}
|
|
117
|
+
}
|
package/dist/tools/registry.js
CHANGED
|
@@ -6,9 +6,18 @@
|
|
|
6
6
|
// mobile app runs tools natively in Swift. nodeImport() keeps esbuild from statically resolving them.
|
|
7
7
|
const nodeImport = (m) => import(m);
|
|
8
8
|
import { MemoryStore } from "../memory/index.js";
|
|
9
|
+
import { indexSessions, readSession, searchSessions } from "../memory/session-index.js";
|
|
10
|
+
import { listLocalSkills, localSkillsDir as profileSkillsDir, resolveSkillFile } from "../config/skills-index.js";
|
|
11
|
+
import { operatorPath } from "../config/home.js";
|
|
9
12
|
import { pexecFile } from "./exec.js";
|
|
10
13
|
import { formatGitStatus } from "./git-status.js";
|
|
11
14
|
import { expandPath } from "./paths.js";
|
|
15
|
+
import { runMemoryTool } from "./memory.js";
|
|
16
|
+
import { runCronTool } from "../autonomy/cron.js";
|
|
17
|
+
import { runDelegateTask } from "../autonomy/delegate.js";
|
|
18
|
+
import { runSessionRewind } from "../memory/session-rewind.js";
|
|
19
|
+
import { runSkillCatalog } from "../skills/catalogue.js";
|
|
20
|
+
import { runBrowser, runBrowserRead } from "../browser/session.js";
|
|
12
21
|
import { deniedWriteAsync, deniedReadAsync, wrapShell } from "./sandbox.js";
|
|
13
22
|
import { ensureSearxng, noteSearxngUsed } from "./searxng.js";
|
|
14
23
|
// execFile helper lives in ./exec (shared with computer.ts — one copy, not two).
|
|
@@ -1018,8 +1027,8 @@ async function recordMediaGen(rec) {
|
|
|
1018
1027
|
try {
|
|
1019
1028
|
const { appendFile, mkdir } = await nodeImport("node:fs/promises");
|
|
1020
1029
|
const os = await nodeImport("node:os");
|
|
1021
|
-
const {
|
|
1022
|
-
const file = process.env.KODE_MEDIA_PROVENANCE_FILE ||
|
|
1030
|
+
const { dirname } = await nodeImport("node:path");
|
|
1031
|
+
const file = process.env.KODE_MEDIA_PROVENANCE_FILE || operatorPath("media-gen.jsonl");
|
|
1023
1032
|
const line = JSON.stringify({ ts: new Date().toISOString(), node: os.hostname(), ...rec }) + "\n";
|
|
1024
1033
|
await mkdir(dirname(file), { recursive: true }).catch(() => { });
|
|
1025
1034
|
await appendFile(file, line, { encoding: "utf8", mode: 0o600 });
|
|
@@ -1894,11 +1903,12 @@ const TOOLS = [
|
|
|
1894
1903
|
},
|
|
1895
1904
|
{
|
|
1896
1905
|
name: "skill_fetch", safe: true,
|
|
1897
|
-
description: "Fetch one AXE skill by name from the hub (or your profile) and return its full instructions to follow/apply. Checks your saved profile skills first, then the hub (operator.axe.onl/skills.axe.onl). Read-only.",
|
|
1906
|
+
description: "Fetch one AXE skill by name from the hub (or your profile) and return its full instructions to follow/apply. Checks your saved profile skills first, then the hub (operator.axe.onl/skills.axe.onl). For directory skills, pass file_path to load a linked file (references/, templates/, scripts/). Read-only.",
|
|
1898
1907
|
parameters: { type: "object", properties: {
|
|
1899
1908
|
slug: { type: "string", description: "the skill name/slug to fetch and use" },
|
|
1909
|
+
file_path: { type: "string", description: "optional path inside a directory skill (e.g. references/foo.md); rejected if it escapes the skill directory" },
|
|
1900
1910
|
}, required: ["slug"] },
|
|
1901
|
-
run: (a) => skillFetch(str(a.slug)),
|
|
1911
|
+
run: (a) => skillFetch(str(a.slug), str(a.file_path).trim() || undefined),
|
|
1902
1912
|
},
|
|
1903
1913
|
{
|
|
1904
1914
|
name: "skill_save",
|
|
@@ -1909,6 +1919,120 @@ const TOOLS = [
|
|
|
1909
1919
|
}, required: ["name", "content"] },
|
|
1910
1920
|
run: (a) => skillSave(str(a.name), str(a.content)),
|
|
1911
1921
|
},
|
|
1922
|
+
{
|
|
1923
|
+
name: "memory", safe: false,
|
|
1924
|
+
description: "Batch-edit the structured memory files (memories/MEMORY.md or memories/USER.md) under the operator home. Each operation adds, replaces, or removes text. Budget-checked on the final result; atomic single write with a lockfile.",
|
|
1925
|
+
parameters: { type: "object", properties: {
|
|
1926
|
+
target: { type: "string", enum: ["memory", "user"], description: "which file to edit (default: memory)" },
|
|
1927
|
+
operations: { type: "array", items: { type: "object", properties: {
|
|
1928
|
+
action: { type: "string", enum: ["add", "replace", "remove"] },
|
|
1929
|
+
content: { type: "string", description: "text to add or the replacement (add/replace)" },
|
|
1930
|
+
old_text: { type: "string", description: "text to find (replace/remove)" },
|
|
1931
|
+
}, required: ["action"] } },
|
|
1932
|
+
}, required: ["operations"] },
|
|
1933
|
+
run: runMemoryTool,
|
|
1934
|
+
},
|
|
1935
|
+
{
|
|
1936
|
+
name: "session_search", safe: true,
|
|
1937
|
+
description: "Search past session transcripts (indexed from the operator home's sessions/) — incrementally indexes them, then full-text search. Returns 'id — snippet' lines; pass an id to session_read for the full transcript.",
|
|
1938
|
+
parameters: { type: "object", properties: {
|
|
1939
|
+
query: { type: "string", description: "search terms (all must appear)" },
|
|
1940
|
+
limit: { type: "number", description: "max results (default 8)" },
|
|
1941
|
+
}, required: ["query"] },
|
|
1942
|
+
run: async (a) => {
|
|
1943
|
+
await indexSessions();
|
|
1944
|
+
const hits = await searchSessions(str(a.query), a.limit === undefined ? 8 : Number(a.limit));
|
|
1945
|
+
return hits.length ? hits.map((h) => `${h.id} — ${h.snippet}`).join("\n") : "no matches";
|
|
1946
|
+
},
|
|
1947
|
+
},
|
|
1948
|
+
{
|
|
1949
|
+
name: "session_read", safe: true,
|
|
1950
|
+
description: "Read one past session transcript by id (the id as returned by session_search). Returns readable text capped at 24k chars.",
|
|
1951
|
+
parameters: { type: "object", properties: {
|
|
1952
|
+
id: { type: "string", description: "the session id" },
|
|
1953
|
+
}, required: ["id"] },
|
|
1954
|
+
run: async (a) => (await readSession(str(a.id))) ?? `error: no session '${str(a.id)}' found under the operator home`,
|
|
1955
|
+
},
|
|
1956
|
+
{
|
|
1957
|
+
name: "session_rewind", safe: false,
|
|
1958
|
+
description: "Truncate a saved session transcript back before the last N user turns (owner undo for a gone-wrong thread). NEVER empties a transcript (refuses when N >= user-turn count), writes a full rewind copy next to the original first, and the session index resyncs on next maintenance. Working-tree files are NOT touched — revert those with git yourself (checkpoints are ordinary commits).",
|
|
1959
|
+
parameters: { type: "object", properties: {
|
|
1960
|
+
id: { type: "string", description: "session id (from session_search)" },
|
|
1961
|
+
turns: { type: "number", description: "user turns to drop (default 1, max 50)" },
|
|
1962
|
+
}, required: ["id"] },
|
|
1963
|
+
run: runSessionRewind,
|
|
1964
|
+
},
|
|
1965
|
+
{
|
|
1966
|
+
name: "cronjob", safe: false,
|
|
1967
|
+
description: "Manage scheduled headless agent runs (cron/jobs.json under the operator home). create adds a job; list shows jobs with next/last run; remove deletes by id; run forces one job now on a fresh headless session. Each execution is logged to cron/executions.jsonl with its output saved under cron/output/.",
|
|
1968
|
+
parameters: { type: "object", properties: {
|
|
1969
|
+
action: { type: "string", enum: ["create", "list", "remove", "run"], description: "what to do" },
|
|
1970
|
+
name: { type: "string", description: "create: optional human-readable job name" },
|
|
1971
|
+
schedule: { description: "create: 5-field cron string (\"30 2 * * *\"), interval minutes (30), or {kind:'interval',everyMinutes} / {kind:'cron',expr}" },
|
|
1972
|
+
task: { type: "string", description: "create: the prompt run headlessly on each fire" },
|
|
1973
|
+
id: { type: "string", description: "remove/run: the job id (from create or list)" },
|
|
1974
|
+
}, required: ["action"] },
|
|
1975
|
+
run: runCronTool,
|
|
1976
|
+
},
|
|
1977
|
+
{
|
|
1978
|
+
name: "delegate_task", safe: false,
|
|
1979
|
+
description: "Hand ONE self-contained subtask to a sub-agent running on a chosen fleet model and get its final answer back (blocks until it finishes). The sub-agent is a full headless Operator session with its own tools, but NO memory of this conversation and it cannot ask you questions — so `task` must carry everything it needs (paths, constraints, the exact output you want). `model` is any /model id; default \"scout\" (fast 4B local tier — cheap for lookups, summaries, bulk edits); \"cortana\" is the flagship for hard subtasks, also venice-24b, qwen3.8-flash, operator-1m. Use it to farm out an independent chunk while you keep planning; do not delegate what you can do in one tool call. Sub-agents cannot delegate further. The sub-agent runs with the owner's permission policy and can mutate the workspace.",
|
|
1980
|
+
parameters: { type: "object", properties: {
|
|
1981
|
+
task: { type: "string", description: "the complete, self-contained subtask — the sub-agent sees only this" },
|
|
1982
|
+
model: { type: "string", description: "registry model id to run it on (default \"scout\")" },
|
|
1983
|
+
}, required: ["task"] },
|
|
1984
|
+
run: (a) => runDelegateTask(a),
|
|
1985
|
+
},
|
|
1986
|
+
{
|
|
1987
|
+
name: "browser", safe: false,
|
|
1988
|
+
description: "Drive a REAL headless browser (Chrome over CDP) with session state that persists across calls — for JS-rendered pages, logins, forms, clicks. Text-first: prefer browser_read for content; use eval/click/fill/submit to act. actions: open(url) navigate(url) reload cache_bust? back forward click(selector settle_ms?) fill(selector,text) submit(selector) eval(js — awaits promises, returnByValue) screenshot() -> png path tab_select(index) tab_close(index?) close. Screenshot files land under the operator home's cache/browser/. Policy: http/https/about/data only (no file://, no chrome://). Login wall: NEVER guess credentials — ask the owner.",
|
|
1989
|
+
parameters: { type: "object", properties: {
|
|
1990
|
+
action: { type: "string", enum: ["open", "navigate", "reload", "back", "forward", "click", "fill", "submit", "eval", "screenshot", "tab_select", "tab_close", "close"], description: "the browser action" },
|
|
1991
|
+
url: { type: "string", description: "http(s)/about/data URL for open|navigate" },
|
|
1992
|
+
selector: { type: "string", description: "CSS selector for click|fill|submit" },
|
|
1993
|
+
text: { type: "string", description: "value for fill" },
|
|
1994
|
+
js: { type: "string", description: "JS expression for eval (returnByValue; awaits promises)" },
|
|
1995
|
+
index: { type: "number", description: "tab index for tab_select|tab_close" },
|
|
1996
|
+
settle_ms: { type: "number", description: "post-click settle (default 250)" },
|
|
1997
|
+
cache_bust: { type: "boolean", description: "reload: ignore cache" },
|
|
1998
|
+
}, required: ["action"] },
|
|
1999
|
+
run: runBrowser,
|
|
2000
|
+
},
|
|
2001
|
+
{
|
|
2002
|
+
name: "browser_read", safe: true,
|
|
2003
|
+
description: "Read the active browser page — no mutation. actions: info (title/url/readyState) text(max_chars? — page innerText) tab_list (index tabs). Uses the SAME persistent browser as the gated 'browser' tool (an active tab must exist — open it first with browser).",
|
|
2004
|
+
parameters: { type: "object", properties: {
|
|
2005
|
+
action: { type: "string", enum: ["info", "text", "tab_list"], description: "what to read" },
|
|
2006
|
+
max_chars: { type: "number", description: "text() cap (default 20000, max 100000)" },
|
|
2007
|
+
}, required: ["action"] },
|
|
2008
|
+
run: runBrowserRead,
|
|
2009
|
+
},
|
|
2010
|
+
{
|
|
2011
|
+
name: "browser_vault", safe: false,
|
|
2012
|
+
description: "Origin-bound website credentials from the owner's vault (macOS keychain first, encrypted-file fallback). THE RULE: never type a password yourself, never ask for one in chat, never repeat one back — this tool's results deliberately withhold values. actions: list (handles + users + bound origins; NO secrets), fill(handle, user_selector, password_selector — fills the ACTIVE browser page after exact origin match; open the login page with the browser tool first). When the vault has no item for an origin: tell the owner to run the add command in their terminal — do not guess.",
|
|
2013
|
+
parameters: { type: "object", properties: {
|
|
2014
|
+
action: { type: "string", enum: ["list", "fill"], description: "what to do" },
|
|
2015
|
+
handle: { type: "string", description: "fill: the vault handle from list" },
|
|
2016
|
+
user_selector: { type: "string", description: "fill: CSS selector of the username field" },
|
|
2017
|
+
password_selector: { type: "string", description: "fill: CSS selector of the password field" },
|
|
2018
|
+
}, required: ["action"] },
|
|
2019
|
+
run: async (args) => {
|
|
2020
|
+
// dynamic by-variable import keeps the node-touching vault out of the neutral bundle (purity)
|
|
2021
|
+
const t = await nodeImport("../vault/tool.js");
|
|
2022
|
+
const hooks = await nodeImport("../browser/session.js");
|
|
2023
|
+
return t.runBrowserVault(args, hooks.browserSessionHooks);
|
|
2024
|
+
},
|
|
2025
|
+
},
|
|
2026
|
+
{
|
|
2027
|
+
name: "skill_catalog", safe: false,
|
|
2028
|
+
description: "The gated OFFICIAL optional-skills catalogue that ships with Operator (152 entries across 23 categories, MIT from the hermes-agent project). 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).",
|
|
2029
|
+
parameters: { type: "object", properties: {
|
|
2030
|
+
action: { type: "string", enum: ["browse", "install", "remove"], description: "what to do" },
|
|
2031
|
+
query: { type: "string", description: "browse: filter by name/category/description substring" },
|
|
2032
|
+
name: { type: "string", description: "install/remove: exact skill name from browse" },
|
|
2033
|
+
}, required: ["action"] },
|
|
2034
|
+
run: runSkillCatalog,
|
|
2035
|
+
},
|
|
1912
2036
|
];
|
|
1913
2037
|
// AXE skill registry (parity with the Python core): a REMOTE HTTPS registry reachable from every surface
|
|
1914
2038
|
// (CLI/web/mobile), so skills work everywhere without local fleet access. Bearer from OPERATOR_TOKEN or
|
|
@@ -1959,7 +2083,11 @@ const isCommunitySkill = (s) => {
|
|
|
1959
2083
|
export async function skillList(query) {
|
|
1960
2084
|
// Prefer the ranked /search when a query is given; fall back to the full list.
|
|
1961
2085
|
const local = await localSkills();
|
|
1962
|
-
const localBlock = local.length ? `your profile skills:\n${local.map((l) =>
|
|
2086
|
+
const localBlock = local.length ? `your profile skills:\n${local.map((l) => {
|
|
2087
|
+
const flag = l.dir ? "profile, dir" : "profile";
|
|
2088
|
+
const desc = l.description.replace(/\s+/g, " ").trim().slice(0, 140);
|
|
2089
|
+
return `• ${l.name} (${flag})${desc ? ` — ${desc}` : ""}`;
|
|
2090
|
+
}).join("\n")}\n\n` : "";
|
|
1963
2091
|
// The AXE skills catalogue (operator.axe.onl / skills.axe.onl → the axe-skills-catalogue, hub.serve)
|
|
1964
2092
|
// serves the VERSIONED contract: `/v1/skills`, `/v1/skills/search?q=`, `/v1/skills/<slug>` (verified
|
|
1965
2093
|
// live, 200 with real data). When the tool reports "unreachable" the origin/tunnel is DOWN, not a
|
|
@@ -1985,13 +2113,27 @@ export async function skillList(query) {
|
|
|
1985
2113
|
});
|
|
1986
2114
|
return `${localBlock}${arr.length} hub skill${arr.length === 1 ? "" : "s"} (skill_fetch <name> to use one):\n${lines.join("\n")}${hiddenNote}`;
|
|
1987
2115
|
}
|
|
1988
|
-
async function skillFetch(slug) {
|
|
2116
|
+
async function skillFetch(slug, filePath) {
|
|
1989
2117
|
if (!slug)
|
|
1990
2118
|
return "error: skill_fetch needs a slug (name)";
|
|
1991
2119
|
// Personal profile skills win over the hub (a user's own saved version is
|
|
1992
2120
|
// theirs to trust), and work even when the hub is unreachable.
|
|
1993
2121
|
for (const ls of await localSkills()) {
|
|
1994
|
-
if (ls.name === slug || ls.name === slugify(slug)) {
|
|
2122
|
+
if (ls.name === slug || ls.name === slugify(slug) || slugify(ls.name) === slugify(slug)) {
|
|
2123
|
+
if (filePath) {
|
|
2124
|
+
if (!ls.dir || !ls.root)
|
|
2125
|
+
return `error: skill '${ls.name}' is a flat profile skill — file_path is only for directory skills`;
|
|
2126
|
+
const target = resolveSkillFile(ls.root, filePath);
|
|
2127
|
+
if (!target)
|
|
2128
|
+
return "error: file_path escapes skill directory";
|
|
2129
|
+
try {
|
|
2130
|
+
const { readFile } = await nodeImport("node:fs/promises");
|
|
2131
|
+
return `# skill: ${ls.name} (profile) ${filePath}\n\n${await readFile(target, "utf8")}`.slice(0, 24000);
|
|
2132
|
+
}
|
|
2133
|
+
catch {
|
|
2134
|
+
return `error: file_path '${filePath}' not found in skill '${ls.name}'`;
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
1995
2137
|
try {
|
|
1996
2138
|
const { readFile } = await nodeImport("node:fs/promises");
|
|
1997
2139
|
return `# skill: ${ls.name} (profile)\n\n${await readFile(ls.file, "utf8")}`.slice(0, 24000);
|
|
@@ -2025,9 +2167,7 @@ function slugify(s) {
|
|
|
2025
2167
|
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64) || "skill";
|
|
2026
2168
|
}
|
|
2027
2169
|
async function localSkillsDir() {
|
|
2028
|
-
|
|
2029
|
-
const { join } = await nodeImport("node:path");
|
|
2030
|
-
return join(homedir(), ".axe", "operator", "skills");
|
|
2170
|
+
return profileSkillsDir();
|
|
2031
2171
|
}
|
|
2032
2172
|
async function skillSave(name, content) {
|
|
2033
2173
|
if (!name || !content)
|
|
@@ -2049,17 +2189,8 @@ async function skillSave(name, content) {
|
|
|
2049
2189
|
return `error saving skill: ${e.message}`;
|
|
2050
2190
|
}
|
|
2051
2191
|
}
|
|
2052
|
-
async function localSkills() {
|
|
2053
|
-
|
|
2054
|
-
const { readdir } = await nodeImport("node:fs/promises");
|
|
2055
|
-
const { join } = await nodeImport("node:path");
|
|
2056
|
-
const dir = await localSkillsDir();
|
|
2057
|
-
const files = (await readdir(dir).catch(() => []));
|
|
2058
|
-
return files.filter((f) => f.endsWith(".md")).map((f) => ({ name: f.replace(/\.md$/, ""), file: join(dir, f) }));
|
|
2059
|
-
}
|
|
2060
|
-
catch {
|
|
2061
|
-
return [];
|
|
2062
|
-
}
|
|
2192
|
+
export async function localSkills() {
|
|
2193
|
+
return listLocalSkills();
|
|
2063
2194
|
}
|
|
2064
2195
|
export const registry = new Map(TOOLS.map(t => [t.name, t]));
|
|
2065
2196
|
export function toSchemas(reg = registry) {
|
package/dist/tools/sandbox.js
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
// bundle (registry.ts pulls this module in, and it reaches the mobile JSCore engine). HOME comes from
|
|
16
16
|
// the env; a minimal single-arg POSIX resolve() is inlined below. These sandbox functions only ever
|
|
17
17
|
// run on the node CLI (tools execute natively on mobile), so this changes no behavior there.
|
|
18
|
+
import { get_operator_home } from "../config/home.js";
|
|
18
19
|
function resolve(p) {
|
|
19
20
|
const abs = p.startsWith("/") ? p : `${process.cwd()}/${p}`;
|
|
20
21
|
const out = [];
|
|
@@ -32,6 +33,16 @@ export function sandboxMode() {
|
|
|
32
33
|
const m = (process.env.KODE_SANDBOX ?? "off").toLowerCase();
|
|
33
34
|
return m === "workspace" || m === "strict" ? m : "off";
|
|
34
35
|
}
|
|
36
|
+
// macOS (APFS) and Windows default to CASE-INSENSITIVE filesystems — the Mac Studio fleet — so a denylist
|
|
37
|
+
// compared byte-exact is bypassable with a case variant: `file_write ~/.axe/operator/Settings.json` (or
|
|
38
|
+
// `~/.Ssh/authorized_keys`) resolves to the same real file but misses a lowercase `settings.json` match, so
|
|
39
|
+
// the agent rewrites its own policy or reads a secret. Fold case on those platforms for EVERY path
|
|
40
|
+
// comparison. Direction is safe: a deny-list that over-matches blocks MORE (never less); the strict-mode
|
|
41
|
+
// allow-roots also fold, which is correct because the case variants ARE the same directory there. A
|
|
42
|
+
// case-sensitive volume (rare on macOS, opt-in) is unaffected. Per-volume detection would be exact but needs
|
|
43
|
+
// fs on a hot path; the platform default is the safe, dependency-free call. (verified bypass, 2026-10-07 review)
|
|
44
|
+
const CASE_INSENSITIVE_FS = process.platform === "darwin" || process.platform === "win32";
|
|
45
|
+
const cf = (s) => (CASE_INSENSITIVE_FS ? s.toLowerCase() : s);
|
|
35
46
|
const HOME = process.env.HOME ?? "";
|
|
36
47
|
// Never writable when the sandbox is on, even inside home — protects credentials/keys/shell rc from an
|
|
37
48
|
// errant model action. (Reads are unaffected; only writes are blocked.)
|
|
@@ -53,17 +64,41 @@ const SECRET_READ_SUBPATHS = [
|
|
|
53
64
|
`${HOME}/.axe/secrets`, `${HOME}/.kube`, `${HOME}/.docker`,
|
|
54
65
|
];
|
|
55
66
|
const SECRET_READ_FILES = [`${HOME}/.netrc`, `${HOME}/.git-credentials`];
|
|
67
|
+
// The Operator home guards ITS OWN policy, credentials and audit trail from the agent it hosts. A
|
|
68
|
+
// prompt-injected model that can `file_write` ~/.axe/operator/settings.json simply rewrites its own
|
|
69
|
+
// permissions to bypass+admin for the next launch, and one that can truncate events.jsonl erases the
|
|
70
|
+
// evidence — so the sandbox treats these exactly like ~/.ssh. Resolved per call (KODE_HOME / KODE_PROFILE
|
|
71
|
+
// can differ per process); ordinary state (memories, skills, sessions) stays writable.
|
|
72
|
+
const OP_WRITE_PROTECTED_FILES = ["settings.json", "settings.local.json", "managed-settings.json", "identity.json", "home.json", "credentials.json", "byo.json", "events.jsonl"];
|
|
73
|
+
const OP_WRITE_PROTECTED_DIRS = ["vault", "audit"];
|
|
74
|
+
const OP_SECRET_FILES = ["credentials.json", "byo.json"];
|
|
75
|
+
const OP_SECRET_DIRS = ["vault"];
|
|
76
|
+
const opPaths = (names) => names.map((n) => resolve(`${get_operator_home()}/${n}`));
|
|
77
|
+
function denyWriteSubpaths() { return [...DENY_WRITE_SUBPATHS, ...opPaths(OP_WRITE_PROTECTED_DIRS)]; }
|
|
78
|
+
function denyWriteFiles() { return [...DENY_WRITE_FILES, ...opPaths(OP_WRITE_PROTECTED_FILES)]; }
|
|
79
|
+
function secretReadSubpaths() { return [...SECRET_READ_SUBPATHS, ...opPaths(OP_SECRET_DIRS)]; }
|
|
80
|
+
function secretReadFiles() { return [...SECRET_READ_FILES, ...opPaths(OP_SECRET_FILES)]; }
|
|
81
|
+
// Session roots registered at runtime (an ACP editor session rooted outside process.cwd()): strict mode
|
|
82
|
+
// confines writes to the workspace, and "the workspace" is the session's root, not the host process cwd.
|
|
83
|
+
const extraWriteRoots = new Set();
|
|
84
|
+
export function allowSandboxWriteRoot(root) {
|
|
85
|
+
const r = resolve(root);
|
|
86
|
+
extraWriteRoots.add(r);
|
|
87
|
+
return () => { extraWriteRoots.delete(r); };
|
|
88
|
+
}
|
|
56
89
|
// In strict mode, writes must land under one of these roots.
|
|
57
90
|
function allowedWriteRoots() {
|
|
58
|
-
|
|
91
|
+
const opHome = get_operator_home();
|
|
92
|
+
return [process.cwd(), opHome, "/tmp", "/private/tmp", process.env.TMPDIR ?? "/tmp", ...extraWriteRoots].filter(Boolean).map((p) => resolve(p));
|
|
59
93
|
}
|
|
60
94
|
/** Core check on an already-resolved absolute path (lexical or realpath'd). */
|
|
61
95
|
function checkDenied(p, original) {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
96
|
+
const pf = cf(p);
|
|
97
|
+
const under = (root) => { const rf = cf(root); return pf === rf || pf.startsWith(rf.endsWith("/") ? rf : rf + "/"); };
|
|
98
|
+
for (const f of denyWriteFiles())
|
|
99
|
+
if (pf === cf(resolve(f)))
|
|
65
100
|
return `sandbox: writing ${original} is blocked (protected file)`;
|
|
66
|
-
for (const d of
|
|
101
|
+
for (const d of denyWriteSubpaths())
|
|
67
102
|
if (under(resolve(d)))
|
|
68
103
|
return `sandbox: writing under ${d} is blocked (protected path)`;
|
|
69
104
|
if (sandboxMode() === "strict" && !allowedWriteRoots().some(under)) {
|
|
@@ -133,11 +168,12 @@ export async function deniedWriteAsync(path) {
|
|
|
133
168
|
* outside the workspace + deny network). */
|
|
134
169
|
/** Core secret-read check on an already-resolved absolute path. */
|
|
135
170
|
function checkReadDenied(p, original) {
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
171
|
+
const pf = cf(p);
|
|
172
|
+
const under = (root) => { const rf = cf(root); return pf === rf || pf.startsWith(rf.endsWith("/") ? rf : rf + "/"); };
|
|
173
|
+
for (const f of secretReadFiles())
|
|
174
|
+
if (pf === cf(resolve(f)))
|
|
139
175
|
return `sandbox: reading ${original} is blocked (secret file)`;
|
|
140
|
-
for (const d of
|
|
176
|
+
for (const d of secretReadSubpaths())
|
|
141
177
|
if (under(resolve(d)))
|
|
142
178
|
return `sandbox: reading under ${d} is blocked (secret path)`;
|
|
143
179
|
return null;
|
|
@@ -166,16 +202,19 @@ export async function deniedReadAsync(path) {
|
|
|
166
202
|
}
|
|
167
203
|
export function seatbeltProfile(mode) {
|
|
168
204
|
const q = (s) => s.replace(/"/g, '\\"');
|
|
169
|
-
const denySub =
|
|
170
|
-
const denyFiles =
|
|
205
|
+
const denySub = denyWriteSubpaths().map((d) => `(subpath "${q(d)}")`).join(" ");
|
|
206
|
+
const denyFiles = denyWriteFiles().map((f) => `(literal "${q(f)}")`).join(" ");
|
|
171
207
|
// Read-containment: block reads of credential paths in BOTH modes so a shell command can't read+exfil
|
|
172
208
|
// secrets. Scoped to real secrets so /usr,/etc,/bin stay readable and normal commands still run.
|
|
173
|
-
const denyReadSub =
|
|
174
|
-
const denyReadFiles =
|
|
209
|
+
const denyReadSub = secretReadSubpaths().map((d) => `(subpath "${q(d)}")`).join(" ");
|
|
210
|
+
const denyReadFiles = secretReadFiles().map((f) => `(literal "${q(f)}")`).join(" ");
|
|
175
211
|
const denyRead = `(deny file-read* ${denyReadSub} ${denyReadFiles})`;
|
|
176
212
|
if (mode === "strict") {
|
|
177
213
|
const allow = allowedWriteRoots().concat("/dev").map((r) => `(subpath "${q(r)}")`).join(" ");
|
|
178
|
-
|
|
214
|
+
// SBPL is last-match-wins: the operator home is an allowed root (memory, sessions…), so its protected
|
|
215
|
+
// policy/secret/audit paths are re-denied AFTER the allow.
|
|
216
|
+
const opHome = [...opPaths(OP_WRITE_PROTECTED_DIRS).map((d) => `(subpath "${q(d)}")`), ...opPaths(OP_WRITE_PROTECTED_FILES).map((f) => `(literal "${q(f)}")`)].join(" ");
|
|
217
|
+
return `(version 1)(allow default)(deny file-write*)(allow file-write* ${allow})(deny file-write* ${opHome})${denyRead}(deny network*)`;
|
|
179
218
|
}
|
|
180
219
|
return `(version 1)(allow default)(deny file-write* ${denySub} ${denyFiles})${denyRead}`;
|
|
181
220
|
}
|
|
@@ -194,21 +233,28 @@ export function bwrapArgs(mode) {
|
|
|
194
233
|
a.push("--proc", "/proc", "--dev", "/dev");
|
|
195
234
|
for (const root of allowedWriteRoots())
|
|
196
235
|
a.push("--bind-try", root, root); // … except the allow-roots
|
|
236
|
+
// the operator home is an allow-root, so its policy/audit paths are re-bound read-only on top of it
|
|
237
|
+
for (const d of opPaths(OP_WRITE_PROTECTED_DIRS))
|
|
238
|
+
a.push("--ro-bind-try", d, d);
|
|
239
|
+
for (const f of opPaths(OP_WRITE_PROTECTED_FILES))
|
|
240
|
+
a.push("--ro-bind-try", f, f);
|
|
197
241
|
a.push("--unshare-net"); // strict: no network
|
|
198
242
|
}
|
|
199
243
|
else {
|
|
200
244
|
a.push("--bind", "/", "/"); // workspace: FS writable …
|
|
201
245
|
a.push("--proc", "/proc", "--dev", "/dev");
|
|
202
|
-
for (const d of
|
|
246
|
+
for (const d of denyWriteSubpaths())
|
|
203
247
|
a.push("--ro-bind-try", resolve(d), resolve(d)); // … protected dirs read-only
|
|
204
248
|
for (const f of DENY_WRITE_FILES)
|
|
205
249
|
a.push("--ro-bind-try", "/dev/null", resolve(f)); // protected files masked
|
|
250
|
+
for (const f of opPaths(OP_WRITE_PROTECTED_FILES))
|
|
251
|
+
a.push("--ro-bind-try", f, f); // operator policy files: readable, not writable
|
|
206
252
|
}
|
|
207
253
|
// Read-containment (BOTH modes): mask secret dirs with an empty tmpfs, secret files with /dev/null,
|
|
208
254
|
// so a shell command can't read + exfil credentials. Placed last so it wins over the writable binds.
|
|
209
|
-
for (const d of
|
|
255
|
+
for (const d of secretReadSubpaths())
|
|
210
256
|
a.push("--tmpfs", resolve(d));
|
|
211
|
-
for (const f of
|
|
257
|
+
for (const f of secretReadFiles())
|
|
212
258
|
a.push("--ro-bind", "/dev/null", resolve(f));
|
|
213
259
|
a.push("--die-with-parent");
|
|
214
260
|
return a;
|
package/dist/tools/searxng.js
CHANGED
|
@@ -69,8 +69,8 @@ async function dockerAvailable() {
|
|
|
69
69
|
/** Write ~/.axe/operator/searxng/settings.yml (json API on + a secret) if absent; return the dir. */
|
|
70
70
|
async function ensureSettingsDir() {
|
|
71
71
|
const fs = await nodeImport("node:fs/promises");
|
|
72
|
-
const
|
|
73
|
-
const dir =
|
|
72
|
+
const { operatorPath } = await import("../config/home.js");
|
|
73
|
+
const dir = operatorPath("searxng");
|
|
74
74
|
await fs.mkdir(dir, { recursive: true });
|
|
75
75
|
const file = `${dir}/settings.yml`;
|
|
76
76
|
try {
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
import { createHash } from "node:crypto";
|
|
12
12
|
import { mkdirSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
13
13
|
import { join } from "node:path";
|
|
14
|
-
import {
|
|
14
|
+
import { operatorPath } from "../config/home.js";
|
|
15
15
|
const RETENTION_MS = 14 * 24 * 3600_000; // spill files older than 14 days are pruned
|
|
16
16
|
const MAX_DIR_BYTES = 500 * 1024 * 1024; // hard ceiling on the spill dir (500MB)
|
|
17
17
|
const SWEEP_INTERVAL_MS = 3600_000; // at most once per hour, from spillToolOutput
|
|
18
18
|
/** Where spilled tool outputs live. A flat dir under the operator home; the model is handed absolute paths.
|
|
19
19
|
* KODE_TOOL_OUTPUT_DIR overrides it (tests/CI/second-user isolation). */
|
|
20
20
|
export function toolOutputDir() {
|
|
21
|
-
return process.env.KODE_TOOL_OUTPUT_DIR ||
|
|
21
|
+
return process.env.KODE_TOOL_OUTPUT_DIR || operatorPath("tool-outputs");
|
|
22
22
|
}
|
|
23
23
|
let _lastSweep = 0;
|
|
24
24
|
/** Best-effort retention sweep: age out >RETENTION_MS files, then cap the dir at MAX_DIR_BYTES oldest-first.
|
package/dist/ui/Transcript.js
CHANGED
|
@@ -89,6 +89,16 @@ function BusCard({ entry }) {
|
|
|
89
89
|
const clipped = all.length - shown.length;
|
|
90
90
|
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Text, { color: "cyan", children: [SB_MARK, " ", arrow, " ", _jsx(Text, { bold: true, children: who }), msg.subject ? ` [${msg.subject}]` : "", _jsx(Text, { dimColor: true, children: ` ${lead}${hhmm(at)}` })] }), shown.map((l, i) => _jsx(Text, { dimColor: true, children: " " + l }, i)), clipped > 0 ? _jsx(Text, { dimColor: true, children: ` ⋯ +${clipped} more line${clipped === 1 ? "" : "s"}` }) : null] }));
|
|
91
91
|
}
|
|
92
|
+
// A settled "thinking" transcript can be a wall of text — worse when a reasoning model circles before
|
|
93
|
+
// answering (the answer below is what matters). Show only the last REASONING_TAIL_LINES, dimmed, with a
|
|
94
|
+
// count of what's hidden. The LIVE stream is already window-bounded (liveTail); this bounds scrollback.
|
|
95
|
+
const REASONING_TAIL_LINES = 6;
|
|
96
|
+
function clampReasoning(s) {
|
|
97
|
+
const lines = s.split("\n");
|
|
98
|
+
if (lines.length <= REASONING_TAIL_LINES)
|
|
99
|
+
return { text: s, hidden: 0 };
|
|
100
|
+
return { text: lines.slice(-REASONING_TAIL_LINES).join("\n"), hidden: lines.length - REASONING_TAIL_LINES };
|
|
101
|
+
}
|
|
92
102
|
function renderEntry(entry, live = false) {
|
|
93
103
|
if (entry.kind === "summary")
|
|
94
104
|
return _jsx(SummaryCard, { summary: entry.summary });
|
|
@@ -127,8 +137,10 @@ function renderEntry(entry, live = false) {
|
|
|
127
137
|
return _jsx(Box, { marginBottom: 1 });
|
|
128
138
|
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [r && r.clipped > 0 ? _jsx(Text, { dimColor: true, children: `⋯ +${r.clipped} more thinking line${r.clipped === 1 ? "" : "s"} above` }) : null, r ? _jsx(Text, { dimColor: true, children: r.text }) : null, a && a.clipped > 0 ? _jsx(Text, { dimColor: true, children: `⋯ +${a.clipped} more line${a.clipped === 1 ? "" : "s"} above (full text shown when complete)` }) : null, a ? _jsx(Text, { children: a.text }) : null] }));
|
|
129
139
|
}
|
|
130
|
-
// Thought process first, dimmed
|
|
131
|
-
|
|
140
|
+
// Thought process first, dimmed and tail-bounded (the answer below is what matters); the real answer
|
|
141
|
+
// follows at full weight.
|
|
142
|
+
const thoughts = message.reasoning ? clampReasoning(message.reasoning) : null;
|
|
143
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [thoughts && thoughts.hidden > 0 ? _jsx(Text, { dimColor: true, children: `⋯ ${thoughts.hidden} earlier thinking line${thoughts.hidden === 1 ? "" : "s"} hidden` }) : null, thoughts ? _jsx(Text, { dimColor: true, children: thoughts.text }) : null, message.content ? _jsx(Markdown, { content: message.content }) : null] }));
|
|
132
144
|
}
|
|
133
145
|
return _jsx(ToolStep, { step: entry.step });
|
|
134
146
|
}
|