@0perator/operator 0.1.285 → 0.1.321
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 +24 -2
- package/dist/acp/agent.js +2 -1
- package/dist/acp/config-options.js +3 -1
- package/dist/acp/tool-map.js +2 -1
- package/dist/auth/commands.js +69 -13
- package/dist/autonomy/agent-cli.js +308 -0
- package/dist/autonomy/cloud-agent.js +439 -0
- package/dist/autonomy/cron-lifecycle.js +78 -0
- package/dist/autonomy/cron-lock.js +121 -0
- package/dist/autonomy/cron.js +217 -44
- package/dist/autonomy/delegate.js +34 -5
- package/dist/autonomy/incidents.js +135 -0
- package/dist/autonomy/index.js +22 -0
- package/dist/autonomy/profile.js +1 -1
- package/dist/autonomy/session-factory.js +25 -16
- package/dist/background/index.js +40 -0
- package/dist/browser/cdp.js +1 -1
- package/dist/bus/inbox.js +20 -0
- package/dist/classifier/config.js +47 -0
- package/dist/classifier/modes.js +41 -0
- package/dist/classifier/types.js +1 -0
- package/dist/cli.js +645 -93
- package/dist/config/features.js +69 -0
- package/dist/config/persona.js +143 -107
- package/dist/config/scaffold.js +15 -0
- package/dist/config/settings.js +107 -12
- package/dist/consolidation/sleep.js +73 -11
- package/dist/engine/agent.js +279 -20
- package/dist/engine/anthropic-chat.js +343 -0
- package/dist/engine/aurora.js +109 -16
- package/dist/engine/batch-scheduler.js +41 -9
- package/dist/engine/classifier.js +85 -0
- package/dist/engine/compaction.js +25 -6
- package/dist/engine/fast-start.js +25 -0
- package/dist/engine/loop-guard.js +448 -0
- package/dist/engine/net-error.js +24 -0
- package/dist/engine/repetition-guard.js +180 -0
- package/dist/engine/router-adapter.js +1 -0
- package/dist/engine/selfheal.js +8 -0
- package/dist/engine/toolcalls.js +51 -1
- package/dist/engine/verify-gate.js +2 -0
- package/dist/flywheel/processor.js +78 -31
- package/dist/flywheel/srft.js +13 -0
- package/dist/hooks/index.js +196 -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 +93 -15
- package/dist/mcp/index.js +9 -2
- package/dist/memory/index.js +0 -0
- package/dist/memory/providers.js +210 -0
- package/dist/memory/session-catalog.js +422 -0
- package/dist/memory/session-providers.js +121 -0
- package/dist/memory/session-sources.js +335 -0
- package/dist/memory/skylark.js +131 -0
- package/dist/models/bench.js +103 -0
- package/dist/models/registry.js +144 -0
- package/dist/models/switch.js +69 -0
- package/dist/observability/blackbox.js +37 -0
- package/dist/permissions/index.js +22 -7
- package/dist/permissions/policy.js +31 -6
- package/dist/permissions/tier.js +1 -1
- package/dist/remote/host.js +20 -2
- package/dist/remote/safe-commands.js +38 -0
- package/dist/router/discovery.js +127 -0
- package/dist/router/models.js +107 -16
- package/dist/router/portal.js +100 -0
- package/dist/router/router.js +1 -1
- package/dist/services/preflight.js +108 -8
- package/dist/services/store-sync.js +111 -0
- package/dist/session-teardown.js +10 -1
- package/dist/session.js +338 -46
- package/dist/skills/catalogue.js +1 -1
- package/dist/tools/chauffeur-native.js +155 -0
- package/dist/tools/chauffeur.js +26 -3
- package/dist/tools/download.js +229 -0
- package/dist/tools/executor.js +19 -9
- package/dist/tools/find-files.js +483 -0
- package/dist/tools/git-pr.js +94 -0
- package/dist/tools/incident-tools.js +82 -0
- package/dist/tools/memory.js +12 -2
- package/dist/tools/monitoring-tools.js +312 -0
- package/dist/tools/paths.js +154 -0
- package/dist/tools/registry.js +582 -95
- package/dist/tools/semantic-compress.js +124 -0
- package/dist/tools/shell-context.js +1 -0
- package/dist/tools/shell-jobs.js +163 -0
- package/dist/tools/shell-session.js +174 -6
- package/dist/tools/tool-output-spill.js +1 -1
- package/dist/tools/wave-tools.js +609 -0
- package/dist/tools/wave2-tools.js +411 -0
- package/dist/ui/App.js +15 -4
- package/dist/ui/BgPanel.js +30 -6
- package/dist/ui/Composer.js +15 -2
- package/dist/ui/QuestionPrompt.js +32 -12
- package/dist/ui/SessionPicker.js +86 -0
- package/dist/ui/StatusRule.js +5 -5
- package/dist/ui/ToolStep.js +17 -1
- package/dist/ui/Transcript.js +17 -1
- package/dist/ui/index.js +1 -1
- package/dist/ui/liveTools.js +21 -3
- package/dist/ui/slashCommands.js +2 -0
- package/dist/util/mentions.js +1 -1
- package/dist/util/screenshots.js +74 -8
- package/dist/util/slash.js +2 -2
- 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 +9 -2
|
@@ -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
|
|
@@ -14,14 +14,20 @@ export const CHAT_LABEL = "Chat about it — type your own reply";
|
|
|
14
14
|
// Returned to the model when the owner opens the chat line but sends it empty: a clear signal to stop
|
|
15
15
|
// offering a menu and discuss, rather than a blank answer.
|
|
16
16
|
export const DISCUSS = "Let's talk it through — I don't want to pick one of the listed options; discuss it with me.";
|
|
17
|
+
// Joins the chosen options for the model when multi-select confirms a set — a stable, readable delimiter.
|
|
18
|
+
export const MULTI_JOIN = "; ";
|
|
19
|
+
// Flip option index `i` in/out of the (sorted) selection set — the Space/digit toggle in multi mode.
|
|
20
|
+
const toggleSelected = (sel, i) => sel.includes(i) ? sel.filter((x) => x !== i) : [...sel, i].sort((a, b) => a - b);
|
|
17
21
|
// Pure keystroke reducer (no React, no I/O) so the whole selection + free-text behavior is testable without
|
|
18
|
-
// a TTY. Returns either the next state, or a `resolve` string = the answer to hand back to the model.
|
|
19
|
-
|
|
22
|
+
// a TTY. Returns either the next state, or a `resolve` string = the answer to hand back to the model. In
|
|
23
|
+
// multi-select mode Space (or a digit) toggles an option and Enter confirms the whole SET (joined); single
|
|
24
|
+
// mode is unchanged — a digit or Enter resolves immediately. The chat escape works identically in both.
|
|
25
|
+
export function questionKey(st, input, key, options, multiSelect = false) {
|
|
20
26
|
if (st.mode === "type") {
|
|
21
27
|
if (key.return)
|
|
22
28
|
return { resolve: st.buffer.trim() || DISCUSS };
|
|
23
29
|
if (key.escape)
|
|
24
|
-
return { state: { mode: "choose", buffer: "", highlight: st.highlight } }; // back to the menu
|
|
30
|
+
return { state: { mode: "choose", buffer: "", highlight: st.highlight, selected: st.selected } }; // back to the menu
|
|
25
31
|
if (key.backspace || key.delete)
|
|
26
32
|
return { state: { ...st, buffer: st.buffer.slice(0, -1) } };
|
|
27
33
|
if (input && !key.ctrl && !key.meta)
|
|
@@ -30,6 +36,7 @@ export function questionKey(st, input, key, options) {
|
|
|
30
36
|
}
|
|
31
37
|
if (key.ctrl && input.toLowerCase() === "c")
|
|
32
38
|
return { resolve: DISCUSS }; // bail = discuss, NEVER a silently-picked real answer
|
|
39
|
+
const chatIndex = options.length; // 0-based index of the chat escape
|
|
33
40
|
const total = options.length + 1; // options + chat escape
|
|
34
41
|
if (key.upArrow) {
|
|
35
42
|
const next = st.highlight <= 0 ? total - 1 : st.highlight - 1;
|
|
@@ -39,28 +46,41 @@ export function questionKey(st, input, key, options) {
|
|
|
39
46
|
const next = st.highlight >= total - 1 ? 0 : st.highlight + 1;
|
|
40
47
|
return { state: { ...st, highlight: next } };
|
|
41
48
|
}
|
|
49
|
+
// Multi-select: Space toggles the highlighted option (never the chat escape) without committing.
|
|
50
|
+
if (multiSelect && input === " " && st.highlight < options.length) {
|
|
51
|
+
return { state: { ...st, selected: toggleSelected(st.selected ?? [], st.highlight) } };
|
|
52
|
+
}
|
|
42
53
|
if (key.return) {
|
|
43
|
-
const chatIndex = options.length; // 0-based
|
|
44
54
|
if (st.highlight === chatIndex)
|
|
45
|
-
return { state: { mode: "type", buffer: "", highlight: st.highlight } };
|
|
55
|
+
return { state: { mode: "type", buffer: "", highlight: st.highlight, selected: st.selected } };
|
|
56
|
+
if (multiSelect) {
|
|
57
|
+
// Confirm the SET. Nothing toggled yet ⇒ treat Enter on the highlighted row as picking just that one,
|
|
58
|
+
// so Enter is never a dead key.
|
|
59
|
+
const sel = (st.selected && st.selected.length ? st.selected : [st.highlight]).slice().sort((a, b) => a - b);
|
|
60
|
+
return { resolve: sel.map((i) => options[i]).join(MULTI_JOIN) };
|
|
61
|
+
}
|
|
46
62
|
return { resolve: options[st.highlight] };
|
|
47
63
|
}
|
|
48
64
|
const n = Number(input);
|
|
49
|
-
if (Number.isInteger(n) && n >= 1 && n <= options.length)
|
|
65
|
+
if (Number.isInteger(n) && n >= 1 && n <= options.length) {
|
|
66
|
+
if (multiSelect)
|
|
67
|
+
return { state: { ...st, highlight: n - 1, selected: toggleSelected(st.selected ?? [], n - 1) } }; // digit toggles, doesn't commit
|
|
50
68
|
return { resolve: options[n - 1] };
|
|
69
|
+
}
|
|
51
70
|
if (n === options.length + 1)
|
|
52
|
-
return { state: { mode: "type", buffer: "", highlight: options.length } }; // open the free-text line
|
|
71
|
+
return { state: { mode: "type", buffer: "", highlight: options.length, selected: st.selected } }; // open the free-text line
|
|
53
72
|
return {};
|
|
54
73
|
}
|
|
55
74
|
export function QuestionPrompt({ pending }) {
|
|
56
|
-
const
|
|
75
|
+
const multi = !!pending?.multiSelect;
|
|
76
|
+
const [st, setSt] = useState({ mode: "choose", buffer: "", highlight: 0, selected: multi ? [] : undefined });
|
|
57
77
|
const qRef = useRef(null);
|
|
58
78
|
const [qLines, setQLines] = useState(1); // measured height of the (possibly wrapping) question line
|
|
59
|
-
useEffect(() => { setSt({ mode: "choose", buffer: "", highlight: 0 }); }, [pending]); // reset for each new question
|
|
79
|
+
useEffect(() => { setSt({ mode: "choose", buffer: "", highlight: 0, selected: pending?.multiSelect ? [] : undefined }); }, [pending]); // reset for each new question
|
|
60
80
|
useInput((input, key) => {
|
|
61
81
|
if (!pending)
|
|
62
82
|
return;
|
|
63
|
-
const a = questionKey(st, input, key, pending.options);
|
|
83
|
+
const a = questionKey(st, input, key, pending.options, pending.multiSelect);
|
|
64
84
|
if (a.resolve !== undefined)
|
|
65
85
|
pending.resolve(a.resolve);
|
|
66
86
|
else if (a.state)
|
|
@@ -87,5 +107,5 @@ export function QuestionPrompt({ pending }) {
|
|
|
87
107
|
if (!pending)
|
|
88
108
|
return null;
|
|
89
109
|
const chatIndex = pending.options.length; // 0-based highlight index for the chat escape
|
|
90
|
-
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsx(Box, { ref: qRef, children: _jsxs(Text, { color: "cyan", bold: true, children: ["? ", _jsx(Text, { color: "white", children: pending.question })] }) }), pending.options.map((o, i) => (_jsxs(Text, { children: [" ", st.mode === "choose" && st.highlight === i ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }),
|
|
110
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsx(Box, { ref: qRef, children: _jsxs(Text, { color: "cyan", bold: true, children: ["? ", _jsx(Text, { color: "white", children: pending.question })] }) }), pending.options.map((o, i) => (_jsxs(Text, { children: [" ", st.mode === "choose" && st.highlight === i ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }), _jsx(Text, { color: "cyan", children: multi ? (st.selected?.includes(i) ? "[x]" : "[ ]") : `[${i + 1}]` }), " ", _jsx(Text, { bold: st.mode === "choose" && st.highlight === i, children: o })] }, i))), _jsxs(Text, { children: [" ", st.mode === "choose" && st.highlight === chatIndex ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }), _jsxs(Text, { color: "cyan", children: ["[", chatIndex + 1, "]"] }), " ", _jsx(Text, { color: "magenta", bold: st.mode === "choose" && st.highlight === chatIndex, children: CHAT_LABEL })] }), st.mode === "type" ? (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { children: [_jsx(Text, { color: "magenta", children: "› " }), st.buffer, _jsx(Text, { color: "cyan", children: "\u258C" })] }), _jsx(Text, { dimColor: true, children: " type your reply · Enter to send · Esc for the menu" })] })) : multi ? (_jsxs(Text, { dimColor: true, children: [" ↑/↓ to move · Space (or 1-", chatIndex, ") to toggle · Enter to confirm · ", chatIndex + 1, " to type your own"] })) : (_jsxs(Text, { dimColor: true, children: [" ↑/↓ to move · Enter to pick · or press 1-", chatIndex + 1, " to jump"] }))] }));
|
|
91
111
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// The /sessions browser: search Operator's and other agents' sessions on this machine (providers configured
|
|
3
|
+
// in agents.md — memory/session-catalog.ts) by what was said in it, then pick one up. Same shape as ArtifactPicker — a
|
|
4
|
+
// pure keystroke reducer (testable without a TTY) + useInput gated while the picker is up, drawn as a
|
|
5
|
+
// bordered inline box above the composer. The search box is always live: typing filters, Tab cycles the
|
|
6
|
+
// scope (Workspace = this folder, Project = this git repo, All), ↑/↓ move, Enter opens, Esc clears the
|
|
7
|
+
// query and then closes.
|
|
8
|
+
import { useEffect, useRef, useState } from "react";
|
|
9
|
+
import { Box, Text, useInput } from "ink";
|
|
10
|
+
import { SESSION_SCOPES, metaLine, roleLabel } from "../memory/session-catalog.js";
|
|
11
|
+
const VISIBLE = 5; // sessions on screen (3 lines each); the list scrolls within it
|
|
12
|
+
const SCOPE_LABEL = { workspace: "Workspace", project: "Project", all: "All" };
|
|
13
|
+
// Pure keystroke reducer: next state and/or an intent. Any query or scope change re-runs the search.
|
|
14
|
+
export function sessionKey(st, input, key, n) {
|
|
15
|
+
const hi = Math.min(Math.max(st.highlight, 0), Math.max(0, n - 1));
|
|
16
|
+
if (key.escape) {
|
|
17
|
+
if (st.query) {
|
|
18
|
+
const next = { ...st, query: "", highlight: 0 };
|
|
19
|
+
return { state: next, intent: { kind: "query", query: "", scope: st.scope } };
|
|
20
|
+
}
|
|
21
|
+
return { intent: { kind: "close" } };
|
|
22
|
+
}
|
|
23
|
+
if (key.tab) {
|
|
24
|
+
const i = SESSION_SCOPES.indexOf(st.scope);
|
|
25
|
+
const scope = SESSION_SCOPES[(i + (key.shift ? SESSION_SCOPES.length - 1 : 1)) % SESSION_SCOPES.length];
|
|
26
|
+
return { state: { ...st, scope, highlight: 0 }, intent: { kind: "query", query: st.query, scope } };
|
|
27
|
+
}
|
|
28
|
+
if (key.upArrow)
|
|
29
|
+
return { state: { ...st, highlight: n ? (hi <= 0 ? n - 1 : hi - 1) : 0 } };
|
|
30
|
+
if (key.downArrow)
|
|
31
|
+
return { state: { ...st, highlight: n ? (hi >= n - 1 ? 0 : hi + 1) : 0 } };
|
|
32
|
+
if (key.return)
|
|
33
|
+
return n ? { intent: { kind: "open", id: "" } } : {}; // id filled in by the caller (it has the rows)
|
|
34
|
+
if (key.backspace || key.delete) {
|
|
35
|
+
if (!st.query)
|
|
36
|
+
return {};
|
|
37
|
+
const query = st.query.slice(0, -1);
|
|
38
|
+
return { state: { ...st, query, highlight: 0 }, intent: { kind: "query", query, scope: st.scope } };
|
|
39
|
+
}
|
|
40
|
+
if (input && !key.ctrl && !key.meta) {
|
|
41
|
+
const query = st.query + input;
|
|
42
|
+
return { state: { ...st, query, highlight: 0 }, intent: { kind: "query", query, scope: st.scope } };
|
|
43
|
+
}
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
function windowFor(n, hi) {
|
|
47
|
+
if (n <= VISIBLE)
|
|
48
|
+
return { start: 0, end: n };
|
|
49
|
+
const start = Math.max(0, Math.min(hi - Math.floor(VISIBLE / 2), n - VISIBLE));
|
|
50
|
+
return { start, end: start + VISIBLE };
|
|
51
|
+
}
|
|
52
|
+
export function SessionPicker({ pending }) {
|
|
53
|
+
const [st, setSt] = useState({ scope: "all", query: "", highlight: 0 });
|
|
54
|
+
const wasOpen = useRef(false);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const open = !!pending;
|
|
57
|
+
if (open && !wasOpen.current)
|
|
58
|
+
setSt({ scope: pending.initialScope ?? "all", query: pending.initialQuery ?? "", highlight: 0 });
|
|
59
|
+
wasOpen.current = open;
|
|
60
|
+
}, [pending]);
|
|
61
|
+
const items = pending?.items ?? [];
|
|
62
|
+
const n = items.length;
|
|
63
|
+
const hi = Math.min(Math.max(st.highlight, 0), Math.max(0, n - 1));
|
|
64
|
+
useInput((input, key) => {
|
|
65
|
+
if (!pending)
|
|
66
|
+
return;
|
|
67
|
+
const a = sessionKey(st, input, key, n);
|
|
68
|
+
if (a.state)
|
|
69
|
+
setSt(a.state);
|
|
70
|
+
if (a.intent?.kind === "open") {
|
|
71
|
+
const row = items[hi];
|
|
72
|
+
if (row)
|
|
73
|
+
pending.onIntent({ kind: "open", id: row.id });
|
|
74
|
+
}
|
|
75
|
+
else if (a.intent)
|
|
76
|
+
pending.onIntent(a.intent);
|
|
77
|
+
}, { isActive: !!pending });
|
|
78
|
+
if (!pending)
|
|
79
|
+
return null;
|
|
80
|
+
const { loading, error, note } = pending;
|
|
81
|
+
const { start, end } = windowFor(n, hi);
|
|
82
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsxs(Text, { color: "cyan", bold: true, children: ["◆ Agent sessions ", SESSION_SCOPES.map((sc) => (_jsxs(Text, { color: sc === st.scope ? "cyan" : undefined, bold: sc === st.scope, dimColor: sc !== st.scope, children: [sc === st.scope ? `[${SCOPE_LABEL[sc]}]` : ` ${SCOPE_LABEL[sc]} `, " "] }, sc))), _jsx(Text, { dimColor: true, children: loading ? "indexing…" : `${n} session${n === 1 ? "" : "s"} · newest first` })] }), _jsxs(Text, { children: [_jsx(Text, { color: "magenta", children: "search› " }), st.query, _jsx(Text, { color: "cyan", children: "\u258C" })] }), error ? _jsx(Text, { color: "red", children: " " + error }) : null, !loading && !error && n === 0 ? (_jsx(Text, { dimColor: true, children: st.query ? ` no session in ${SCOPE_LABEL[st.scope]} mentions "${st.query}" — Tab widens the scope` : ` no sessions in ${SCOPE_LABEL[st.scope]} yet — Tab widens the scope` })) : null, items.slice(start, end).map((it, i) => {
|
|
83
|
+
const sel = start + i === hi;
|
|
84
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [sel ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }), _jsx(Text, { bold: sel, children: it.title }), _jsx(Text, { dimColor: true, children: " " + metaLine(it) })] }), _jsx(Text, { dimColor: true, wrap: "truncate-end", children: " " + (it.snippet ? `${roleLabel(it.role)}${it.role ? ": " : ""}${it.snippet}` : "") }), _jsxs(Text, { dimColor: true, wrap: "truncate-end", children: [" " + (it.cwd ?? ""), it.gone ? _jsx(Text, { color: "yellow", children: " folder gone" }) : null] })] }, it.id));
|
|
85
|
+
}), n > end ? _jsx(Text, { dimColor: true, children: ` ⋯ +${n - end} more` }) : null, note ? _jsx(Text, { color: "green", children: " " + note }) : null, _jsx(Text, { dimColor: true, children: " type to search · Tab scope · ↑/↓ move · Enter open · Esc clear/close" })] }));
|
|
86
|
+
}
|
package/dist/ui/StatusRule.js
CHANGED
|
@@ -51,11 +51,11 @@ export function statusRight(p, cols) {
|
|
|
51
51
|
const think = p.thinkMode === "ultrathink" ? `✲✲ ultrathink · ` : p.thinkMode === "think" ? `✲ think · ` : "";
|
|
52
52
|
const tok = p.sessionTokens && p.sessionTokens > 0 ? `Σ${fmtK(p.sessionTokens)} · ` : ""; // session token total
|
|
53
53
|
// ctx as a fill ring (○◔◑◕●) + the exact % — a glance shows how full the context window is, the number keeps precision.
|
|
54
|
-
//
|
|
55
|
-
// the
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
const routeLabel = p.route
|
|
54
|
+
// Show the real route id (operator-1m, operator-128k, moa, custom …) — the outward name IS operator-*
|
|
55
|
+
// (the aurora-* model is internal, never shown; see router/models.ts). The old display rewrite turned
|
|
56
|
+
// operator-1m into "aurora-300k", which was indistinguishable from the dead cloud profile axe-aurora-300k
|
|
57
|
+
// (api.axe.onl) — so the owner couldn't tell the local default from the broken remote. Route is the truth.
|
|
58
|
+
const routeLabel = p.route;
|
|
59
59
|
let info = `${think}${plan}${seat}${who}${routeLabel} · ${ring(p.ctxPct)} ${Math.round(p.ctxPct)}% · ${tok}v${p.version}${p.build ? ` ·${p.build}` : ""}`;
|
|
60
60
|
let right = `✷ OPERATOR · ${info} ─`;
|
|
61
61
|
const maxRight = cols - 3; // leaves fill ≥ 1 and total = cols-1
|
package/dist/ui/ToolStep.js
CHANGED
|
@@ -5,6 +5,7 @@ import { fileLink } from "./osc.js";
|
|
|
5
5
|
import { theme } from "./theme.js";
|
|
6
6
|
import { computeEditDiff } from "./editdiff.js";
|
|
7
7
|
import { useTick } from "./tick.js";
|
|
8
|
+
import { rowBackgroundHint } from "./liveTools.js";
|
|
8
9
|
import { glyphFor, toolKind, KIND_HUE } from "./toolicons.js";
|
|
9
10
|
import { renderBar, mediaEtaMs, mediaProgressFraction } from "./progressbar.js";
|
|
10
11
|
import { ShimmerText, huePalette } from "./shimmer.js";
|
|
@@ -18,11 +19,16 @@ const COLOR = { selected: theme.muted, running: theme.running, done: theme.succe
|
|
|
18
19
|
const KEY_ARGS = ["path", "file", "filename", "command", "cmd", "pattern", "url", "query", "workspace", "cwd", "name"];
|
|
19
20
|
// Bulky payloads — never dumped (they'd bury the path and blow up the line); shown as a size instead.
|
|
20
21
|
const BULK_ARGS = ["content", "text", "body", "data", "new_string", "old_string", "diff", "message"];
|
|
22
|
+
const SHELL_TOOLS = new Set(["bash", "shell_exec", "shell_background"]);
|
|
21
23
|
export function argsPreview(args) {
|
|
22
24
|
if (!args)
|
|
23
25
|
return "";
|
|
24
26
|
const parts = [];
|
|
25
27
|
const seen = new Set();
|
|
28
|
+
// Shell tools with a description: show ONLY the description as the primary label (command goes dim below).
|
|
29
|
+
if (typeof args.description === "string" && args.description) {
|
|
30
|
+
return args.description;
|
|
31
|
+
}
|
|
26
32
|
// 1) identifying keys, in full — the file name/path is the point, so it is NEVER clipped.
|
|
27
33
|
for (const k of KEY_ARGS) {
|
|
28
34
|
const v = args[k];
|
|
@@ -50,6 +56,16 @@ export function argsPreview(args) {
|
|
|
50
56
|
}
|
|
51
57
|
return parts.join(", ");
|
|
52
58
|
}
|
|
59
|
+
/** For shell tools with a description, the command is shown dim beneath the description line. */
|
|
60
|
+
export function shellCommandHint(step) {
|
|
61
|
+
if (!SHELL_TOOLS.has(step.name) || !step.args?.description)
|
|
62
|
+
return null;
|
|
63
|
+
const cmd = step.args.command;
|
|
64
|
+
if (typeof cmd !== "string")
|
|
65
|
+
return null;
|
|
66
|
+
const trimmed = cmd.replace(/\s+/g, " ").trim();
|
|
67
|
+
return trimmed.length > 120 ? trimmed.slice(0, 117) + "..." : trimmed;
|
|
68
|
+
}
|
|
53
69
|
export function ToolStep({ step }) {
|
|
54
70
|
// ONE shared animation clock (tick.ts) drives both the per-action icon animation AND the live elapsed timer,
|
|
55
71
|
// so a running row needs no setInterval of its own — this replaces N per-row 250ms timers with a single
|
|
@@ -70,5 +86,5 @@ export function ToolStep({ step }) {
|
|
|
70
86
|
// lands. Only RUNNING media rows get the bar — everything else renders exactly as before.
|
|
71
87
|
const isRunningMedia = toolKind(step.name) === "media" && step.status === "running";
|
|
72
88
|
const mediaFraction = isRunningMedia && elapsed != null ? mediaProgressFraction(elapsed, mediaEtaMs(step.name, step.args)) : undefined;
|
|
73
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: step.status === "running" ? KIND_HUE[toolKind(step.name)] : COLOR[step.status], bold: true, children: glyphFor(step.name, step.status, frame) }), " ", step.status === "running" ? _jsx(ShimmerText, { text: step.name, frame: frame, palette: huePalette(KIND_HUE[toolKind(step.name)]) }) : step.name, "(", argsPreview(step.args), ")", mediaFraction != null ? (_jsxs(Text, { children: [" ", _jsx(Text, { color: theme.mediaProgress, children: renderBar(mediaFraction) }), " ", Math.round(mediaFraction * 100), "%"] })) : null, elapsed != null ? _jsxs(Text, { dimColor: true, children: [" ", formatDuration(elapsed)] }) : null, editDiff ? (_jsxs(Text, { children: [" ", _jsxs(Text, { color: theme.success, children: ["+", editDiff.added] }), " ", _jsxs(Text, { color: theme.error, children: ["-", editDiff.removed] })] })) : null] }), step.summary ? step.summary.split("\n").map((l, i) => (_jsxs(Text, { dimColor: true, children: [" ", l] }, `sm${i}`))) : null, editDiff?.preview?.map((l, i) => (_jsxs(Text, { color: l.kind === "add" ? theme.success : theme.error, children: [" ", l.kind === "add" ? "+ " : "- ", l.text] }, i)))] }));
|
|
89
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: step.status === "running" ? KIND_HUE[toolKind(step.name)] : COLOR[step.status], bold: true, children: glyphFor(step.name, step.status, frame) }), " ", step.status === "running" ? _jsx(ShimmerText, { text: step.name, frame: frame, palette: huePalette(KIND_HUE[toolKind(step.name)]) }) : step.name, "(", argsPreview(step.args), ")", mediaFraction != null ? (_jsxs(Text, { children: [" ", _jsx(Text, { color: theme.mediaProgress, children: renderBar(mediaFraction) }), " ", Math.round(mediaFraction * 100), "%"] })) : null, elapsed != null ? _jsxs(Text, { dimColor: true, children: [" ", formatDuration(elapsed)] }) : null, editDiff ? (_jsxs(Text, { children: [" ", _jsxs(Text, { color: theme.success, children: ["+", editDiff.added] }), " ", _jsxs(Text, { color: theme.error, children: ["-", editDiff.removed] })] })) : null] }), shellCommandHint(step) ? _jsxs(Text, { dimColor: true, children: [" ", shellCommandHint(step)] }) : null, rowBackgroundHint(step, now) ? _jsxs(Text, { dimColor: true, children: [" ", rowBackgroundHint(step, now)] }) : null, step.summary ? step.summary.split("\n").map((l, i) => (_jsxs(Text, { dimColor: true, children: [" ", l] }, `sm${i}`))) : null, editDiff?.preview?.map((l, i) => (_jsxs(Text, { color: l.kind === "add" ? theme.success : theme.error, children: [" ", l.kind === "add" ? "+ " : "- ", l.text] }, i)))] }));
|
|
74
90
|
}
|
package/dist/ui/Transcript.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Scrollback (SPEC §6). Settled entries render via Ink's <Static> — written once to stdout and
|
|
3
|
+
// never re-diffed, which is what actually makes the prompt-echo/scroll/overwrite bug class
|
|
4
|
+
// (endemic to the ANSI-cursor Python core) impossible here: new lines only ever get appended
|
|
5
|
+
// below, terminal scrollback is never touched again. Only the in-flight entry re-renders live.
|
|
6
|
+
import React from "react";
|
|
2
7
|
import { Box, Static, Text } from "ink";
|
|
3
8
|
import { ToolStep } from "./ToolStep.js";
|
|
4
9
|
import { Markdown } from "./Markdown.js";
|
|
@@ -144,6 +149,16 @@ function renderEntry(entry, live = false) {
|
|
|
144
149
|
}
|
|
145
150
|
return _jsx(ToolStep, { step: entry.step });
|
|
146
151
|
}
|
|
152
|
+
// One settled transcript row, MEMOIZED. In fullscreen there is no <Static>, so every App re-render (a
|
|
153
|
+
// sub-agent token tick, the ~15fps live stream, a spinner-driven parent render) otherwise re-runs renderEntry
|
|
154
|
+
// for the WHOLE visible window and Ink repaints all of it — the full-frame flash. Settled entries are
|
|
155
|
+
// immutable (append-only; their object reference never changes), so React.memo on the entry reference lets the
|
|
156
|
+
// reconciler skip every unchanged row and Ink repaints only what actually changed (the live line + glyph).
|
|
157
|
+
// `cols` is a deliberate second key so a terminal RESIZE still re-wraps settled rows (BusCard wraps to width),
|
|
158
|
+
// while a same-width tick does not — it is read inside renderEntry via termCols(), passed here only to bust the memo.
|
|
159
|
+
const TranscriptRow = React.memo(function TranscriptRow({ entry }) {
|
|
160
|
+
return _jsx(Box, { children: renderEntry(entry) });
|
|
161
|
+
});
|
|
147
162
|
export function Transcript({ entries, live, bounded, scrollBack = 0 }) {
|
|
148
163
|
if (bounded) {
|
|
149
164
|
// Fullscreen: no <Static>; render a wheel-scrollable window as a plain column the parent clips +
|
|
@@ -151,7 +166,8 @@ export function Transcript({ entries, live, bounded, scrollBack = 0 }) {
|
|
|
151
166
|
// history; at 0 it's the newest `BOUNDED_TAIL` entries with the live stream pinned below.
|
|
152
167
|
const { start, end, olderOff, newerOff } = boundedWindow(entries.length, scrollBack);
|
|
153
168
|
const tail = entries.slice(start, end);
|
|
154
|
-
|
|
169
|
+
const cols = termCols(); // memo key: a resize re-wraps settled rows, a per-tick re-render does not
|
|
170
|
+
return (_jsxs(Box, { flexDirection: "column", children: [olderOff > 0 ? (_jsx(Text, { dimColor: true, children: `⋯ ${olderOff} earlier line(s) scrolled off` })) : null, tail.map((entry) => _jsx(TranscriptRow, { entry: entry, cols: cols }, entryKey(entry))), newerOff > 0
|
|
155
171
|
? _jsx(Text, { dimColor: true, children: `⋯ ${newerOff} newer line(s) below — scroll down (new output jumps here)` })
|
|
156
172
|
: (live ? _jsx(Box, { children: renderEntry(live, true) }) : null)] }));
|
|
157
173
|
}
|
package/dist/ui/index.js
CHANGED
|
@@ -8,4 +8,4 @@ export { ToolStep } from "./ToolStep.js";
|
|
|
8
8
|
export { BgPanel } from "./BgPanel.js";
|
|
9
9
|
export * from "./types.js";
|
|
10
10
|
export { formatDuration, isErrorResult } from "./format.js";
|
|
11
|
-
export { seedLiveTools, settleLiveTool } from "./liveTools.js";
|
|
11
|
+
export { seedLiveTools, settleLiveTool, backgroundHint } from "./liveTools.js";
|
package/dist/ui/liveTools.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { isErrorResult, resultPreview } from "./format.js";
|
|
2
2
|
/** Seed one live row per call, all "running" from the same instant — the batch was just dispatched
|
|
3
|
-
* together
|
|
4
|
-
*
|
|
5
|
-
* correctly once ToolStep renders it, per-row, independent of the others). */
|
|
3
|
+
* together. Reads and independent bash/shell_exec overlap; conflicting writes and device barriers
|
|
4
|
+
* still serialize (BTX). Each row's own elapsed timer ticks per-row once ToolStep renders it. */
|
|
6
5
|
export function seedLiveTools(calls, now = Date.now()) {
|
|
7
6
|
return calls.map((c) => ({ id: c.id, name: c.name, args: c.args, status: "running", startedAt: now }));
|
|
8
7
|
}
|
|
@@ -19,3 +18,22 @@ export function settleLiveTool(rows, id, result, now = Date.now()) {
|
|
|
19
18
|
});
|
|
20
19
|
return changed ? next : rows;
|
|
21
20
|
}
|
|
21
|
+
const SHELL_TOOLS = new Set(["bash", "shell_exec"]);
|
|
22
|
+
export const BACKGROUND_HINT_AFTER_MS = 2000;
|
|
23
|
+
/** Inline per-row variant of the hint, under the running command itself (matches Claude Code). */
|
|
24
|
+
export function rowBackgroundHint(step, now = Date.now(), inTmux = !!process.env.TMUX) {
|
|
25
|
+
if (!SHELL_TOOLS.has(step.name) || step.status !== "running")
|
|
26
|
+
return null;
|
|
27
|
+
if (now - (step.startedAt ?? now) <= BACKGROUND_HINT_AFTER_MS)
|
|
28
|
+
return null;
|
|
29
|
+
return inTmux ? "(ctrl+b ctrl+b or ctrl+z to run in background)" : "(ctrl+b to run in background)";
|
|
30
|
+
}
|
|
31
|
+
/** The muted hint shown once a shell command has run a while: how to move it to the background. Null while no
|
|
32
|
+
* shell command has run past the threshold. Inside tmux ctrl+b is the prefix key, so the first press is
|
|
33
|
+
* swallowed by tmux: say "twice", and name the alias key that has no such clash. */
|
|
34
|
+
export function backgroundHint(rows, now = Date.now(), inTmux = !!process.env.TMUX) {
|
|
35
|
+
const slow = rows.some((r) => SHELL_TOOLS.has(r.name) && r.status === "running" && now - (r.startedAt ?? now) > BACKGROUND_HINT_AFTER_MS);
|
|
36
|
+
if (!slow)
|
|
37
|
+
return null;
|
|
38
|
+
return inTmux ? "ctrl+b ctrl+b (tmux) or ctrl+z to run in the background" : "ctrl+b to run in the background";
|
|
39
|
+
}
|
package/dist/ui/slashCommands.js
CHANGED
|
@@ -19,11 +19,13 @@ export const SLASH_COMMANDS = [
|
|
|
19
19
|
{ name: "ultrathink", description: "toggle deep, exhaustive reasoning for hard problems" },
|
|
20
20
|
{ name: "agents", description: "detailed sub-agent status: running/queued/done/errored + metrics" },
|
|
21
21
|
{ name: "bg", description: "spawn a background sub-agent, list, or stop one", args: "<task|stop id>" },
|
|
22
|
+
{ name: "jobs", description: "background shell jobs: list, or stop one (ctrl+b moves a running command here)", args: "[stop id]" },
|
|
22
23
|
{ name: "monitor", description: "toggle the live event stream (tool decisions, turns, control)" },
|
|
23
24
|
{ name: "audit", description: "recent tool + control-plane events from the audit trail", args: "[n]" },
|
|
24
25
|
{ name: "stats", description: "session dashboard: turns · tools · tokens · throughput · context fill" },
|
|
25
26
|
{ name: "dashboard", description: "launch the live swarm console (watches every Operator session)" },
|
|
26
27
|
{ name: "artifacts", description: "browse + attach your Compose artifacts: search · attach · copy url · delete" },
|
|
28
|
+
{ name: "sessions", description: "search Operator's and other agents' sessions (providers in agents.md) and pick one up", args: "[query]" },
|
|
27
29
|
{ name: "remember", description: "store a note to recall in future sessions", args: "<note>" },
|
|
28
30
|
{ name: "memory", description: "show remembered notes (all, or matching a query)", args: "[query]" },
|
|
29
31
|
{ name: "compact", description: "force-compact the conversation now" },
|
package/dist/util/mentions.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @file mentions (
|
|
1
|
+
// @file mentions (matching modern coding agents): when the owner types `@path`, inline that file's content into the
|
|
2
2
|
// SENT prompt (the visible message keeps the @path as typed). Only tokens that resolve to a real file are
|
|
3
3
|
// expanded — `@someone` that isn't a path is left untouched — and each file is bounded + oversized/dir
|
|
4
4
|
// paths are skipped, so a stray `@node_modules/...` can't blow the context. Matched at a word boundary so
|
package/dist/util/screenshots.js
CHANGED
|
@@ -7,16 +7,79 @@
|
|
|
7
7
|
// file twice). So we copy any such ephemeral image to a durable attachments dir at INPUT time
|
|
8
8
|
// and rewrite the reference to the copy. Local paths (Desktop/Downloads) are stable and pass
|
|
9
9
|
// through untouched. Pure, synchronous, model-agnostic input preprocessing -- the same seam and
|
|
10
|
-
// shape as expandFileMentions, run on the user's text before it reaches the model.
|
|
11
|
-
|
|
10
|
+
// shape as expandFileMentions, run on the user's text before it reaches the model. The durable
|
|
11
|
+
// copies are themselves swept on a retention policy (sweepAttachments, below) so the attachments
|
|
12
|
+
// dir doesn't grow forever.
|
|
13
|
+
import { statSync, copyFileSync, mkdirSync, readdirSync, rmSync, readFileSync } from "node:fs";
|
|
14
|
+
import { createHash } from "node:crypto";
|
|
15
|
+
import { join } from "node:path";
|
|
12
16
|
import { operatorPath } from "../config/home.js";
|
|
17
|
+
// Retention sweep for the attachments dir -- mirrors tool-output-spill.ts's sweepToolOutputs (the
|
|
18
|
+
// established pattern in this codebase for a cache dir that otherwise grows forever). Every snapshotted
|
|
19
|
+
// screenshot gets a unique name and nothing ever deleted it, so the dir accumulated multi-MB PNGs
|
|
20
|
+
// indefinitely with no bound. Age out first, then cap total bytes, oldest-first.
|
|
21
|
+
const ATTACHMENT_RETENTION_MS = 7 * 24 * 3600_000; // a week -- long enough to re-check a recent analysis
|
|
22
|
+
const ATTACHMENT_MAX_DIR_BYTES = 250 * 1024 * 1024; // hard ceiling (250MB) on the attachments dir
|
|
23
|
+
const ATTACHMENT_SWEEP_INTERVAL_MS = 3600_000; // at most once per hour, from snapshotEphemeralImages
|
|
24
|
+
let _lastAttachmentSweep = 0;
|
|
25
|
+
/** Best-effort retention sweep for operatorPath("attachments"): age out >ATTACHMENT_RETENTION_MS files,
|
|
26
|
+
* then cap the dir at ATTACHMENT_MAX_DIR_BYTES oldest-first. force:true bypasses the hourly throttle
|
|
27
|
+
* (tests / an explicit "clean it now"). Never throws -- attachments are copies of already-ephemeral
|
|
28
|
+
* originals, so a failed sweep just leaves the cache a bit fuller, never loses anything unrecoverable. */
|
|
29
|
+
export function sweepAttachments(dir = operatorPath("attachments"), opts = {}) {
|
|
30
|
+
const now = Date.now();
|
|
31
|
+
if (!opts.force && now - _lastAttachmentSweep < ATTACHMENT_SWEEP_INTERVAL_MS)
|
|
32
|
+
return;
|
|
33
|
+
_lastAttachmentSweep = now;
|
|
34
|
+
let entries;
|
|
35
|
+
try {
|
|
36
|
+
entries = readdirSync(dir)
|
|
37
|
+
.filter((f) => f.startsWith("shot-"))
|
|
38
|
+
.map((f) => {
|
|
39
|
+
try {
|
|
40
|
+
const st = statSync(join(dir, f));
|
|
41
|
+
return { f, mtime: st.mtimeMs, size: st.size };
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
.filter((x) => !!x);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return;
|
|
51
|
+
} // dir missing = nothing to sweep
|
|
52
|
+
for (const e of entries) {
|
|
53
|
+
if (now - e.mtime > ATTACHMENT_RETENTION_MS) {
|
|
54
|
+
try {
|
|
55
|
+
rmSync(join(dir, e.f));
|
|
56
|
+
}
|
|
57
|
+
catch { /* raced; fine */ }
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const alive = entries.filter((e) => now - e.mtime <= ATTACHMENT_RETENTION_MS);
|
|
61
|
+
let total = alive.reduce((n, e) => n + e.size, 0);
|
|
62
|
+
if (total > ATTACHMENT_MAX_DIR_BYTES) {
|
|
63
|
+
for (const e of [...alive].sort((a, b) => a.mtime - b.mtime)) {
|
|
64
|
+
if (total <= ATTACHMENT_MAX_DIR_BYTES)
|
|
65
|
+
break;
|
|
66
|
+
try {
|
|
67
|
+
rmSync(join(dir, e.f));
|
|
68
|
+
total -= e.size;
|
|
69
|
+
}
|
|
70
|
+
catch { /* skip */ }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
13
74
|
// A path under the macOS per-user temp root (/var/folders, optionally /private-prefixed) or /tmp,
|
|
14
|
-
// ending in an image extension.
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
|
|
75
|
+
// ending in an image extension. Directory segments never contain a real space, so they're matched
|
|
76
|
+
// as shell-escaped-space-or-non-slash runs; the FINAL (filename) segment is matched separately and
|
|
77
|
+
// allows literal spaces too -- a dragged screenshot's name ("Screenshot 2026-10-11 at 9.00.10 PM.png")
|
|
78
|
+
// reaches this regex with real, unescaped spaces as often as shell-escaped ones, depending on how the
|
|
79
|
+
// path was typed/pasted/quoted into the TUI (not always a shell). Excluding quotes/newlines from the
|
|
80
|
+
// filename segment keeps the lazy match from swallowing a wrapping quote or spanning two paths.
|
|
81
|
+
const EPHEMERAL_IMG_RE = /(?:\/private)?\/(?:var\/folders|tmp)\/(?:\\ |[^\s/])+(?:\/(?:\\ |[^\s/])+)*\/[^\n"']+?\.(?:png|jpe?g|gif|webp|bmp|heic|heif|tiff?)/gi;
|
|
18
82
|
const MAX_SNAPSHOT_BYTES = 64 * 1024 * 1024;
|
|
19
|
-
let seq = 0;
|
|
20
83
|
// Replace every ephemeral screenshot/image path in `text` that still exists on disk with a durable
|
|
21
84
|
// copy under the operator home's attachments dir. Anything that cannot be snapshotted (already
|
|
22
85
|
// deleted, unreadable, too large) is left exactly as written -- the tool then surfaces its own
|
|
@@ -34,7 +97,10 @@ export function snapshotEphemeralImages(text) {
|
|
|
34
97
|
return match;
|
|
35
98
|
const ext = (real.split(".").pop() || "png").toLowerCase();
|
|
36
99
|
mkdirSync(operatorPath("attachments"), { recursive: true, mode: 0o700 });
|
|
37
|
-
|
|
100
|
+
sweepAttachments();
|
|
101
|
+
const bytes = readFileSync(real);
|
|
102
|
+
const hash = createHash("sha1").update(bytes).digest("hex").slice(0, 12);
|
|
103
|
+
const dest = operatorPath("attachments", "shot-" + hash + "." + ext);
|
|
38
104
|
copyFileSync(real, dest);
|
|
39
105
|
changed = true;
|
|
40
106
|
return dest; // clean, space-free path -- no downstream escaping needed
|
package/dist/util/slash.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
// a slash command — it goes to the model as user input.
|
|
4
4
|
const KNOWN = new Set([
|
|
5
5
|
"help", "model", "route", "endpoints", "services", "audit", "dashboard", "plan", "mode",
|
|
6
|
-
"think", "ultrathink", "compact", "remember", "memory", "mcp", "whoami", "agents", "monitor",
|
|
6
|
+
"think", "ultrathink", "compact", "remember", "memory", "mcp", "whoami", "agents", "jobs", "monitor",
|
|
7
7
|
"bg", "new", "clear", "exit", "quit", "stats", "login", "logout", "remote", "remotecontrol", "rc",
|
|
8
|
-
"artifacts", "skills", "deep-research", "deepresearch", "research", "pair",
|
|
8
|
+
"artifacts", "sessions", "skills", "deep-research", "deepresearch", "research", "pair",
|
|
9
9
|
]);
|
|
10
10
|
export function isSlashCommand(text) {
|
|
11
11
|
const t = text.trim();
|
package/dist/vault/store.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Credential vault (HV3-02b) — origin-bound website logins for the browser, keychain-first.
|
|
2
|
-
// THE CONTRACT (inherited from the
|
|
2
|
+
// THE CONTRACT (inherited from the reference playbook and enforced by test):
|
|
3
3
|
// 1. Secrets NEVER enter model context: they are not returned by any tool, not accepted as tool
|
|
4
4
|
// arguments, and not logged. Save happens on the CLI TTY (operator vault add); fill takes a
|
|
5
5
|
// HANDLE + selectors only — the password goes straight from keychain into the page over CDP.
|
package/mcp/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# kode-tsi MCP servers (stdio)
|
|
2
|
+
|
|
3
|
+
## powertools (canonical — slices 1–5 + classics)
|
|
4
|
+
|
|
5
|
+
**Register as:** `powertools` (short alias `pt` fine in local config)
|
|
6
|
+
**File:** `powertools.mjs` (v0.4) + `powertools-toolbox.mjs` (§4) + `powertools-media.mjs` (`convert`/`scan`)
|
|
7
|
+
**Tests:** `../test/powertools-mcp.test.mjs` · `../test/powertools-media.test.mjs`
|
|
8
|
+
**Brief:** `../_ai-docs/2026-10-24-cli-power-mcp-brief.md`
|
|
9
|
+
**SOP:** `../_ai-docs/sops/brief-slice-protocol.md`
|
|
10
|
+
**Full catalogue:** [`powertools.md`](./powertools.md) — every tool, model usage, toolbox + media
|
|
11
|
+
**Classics map:** `../_ai-docs/research/2026-10-24-forgotten-powertools.md`
|
|
12
|
+
|
|
13
|
+
Zero-dep stdio JSON-RPC MCP.
|
|
14
|
+
|
|
15
|
+
| Tool | Binary | Notes |
|
|
16
|
+
|------|--------|--------|
|
|
17
|
+
| `json_query` | jq | inline or root path |
|
|
18
|
+
| `yaml_query` | yq | `--security-disable-file-ops` |
|
|
19
|
+
| `find_files` | fd | typed params only |
|
|
20
|
+
| `search_text` | rg | typed params only |
|
|
21
|
+
| `disk_usage` | duf | JSON mounts |
|
|
22
|
+
| `list_ports` | lsof | listening TCP |
|
|
23
|
+
| `hash_file` | shasum | SHA-1/256/512 |
|
|
24
|
+
| `hex_dump` | xxd | capped length |
|
|
25
|
+
| `dns_lookup` | dig | hostname + type only |
|
|
26
|
+
| `diff_files` | diff | unified, two root paths |
|
|
27
|
+
| `sqlite_query` | sqlite3 | `-readonly`; SELECT/WITH/PRAGMA |
|
|
28
|
+
| `process_list` | ps | fixed columns |
|
|
29
|
+
| `tool_status` | — | always present |
|
|
30
|
+
| §4 toolbox (25) | various | see `powertools.md` — file_info…watch_health_loop; mutate/SSH gated |
|
|
31
|
+
| `convert` | sips/ffmpeg | images/video/audio/pdf → typed formats; mutate gate |
|
|
32
|
+
| `scan` | tesseract / Vision + ffmpeg | OCR image/PDF; sample+OCR video frames (no VL) |
|
|
33
|
+
|
|
34
|
+
Guardrails: argv-only spawn, cleared `env: {}` (media uses allowlisted PATH/HOME overlay), `POWERTOOLS_ROOT` required (no cwd fail-open), soft-miss (missing bins omit tools — server still starts), 5s default timeout (media up to 180s), 64 KiB output cap. Mutate/SSH: `POWERTOOLS_ALLOW_MUTATE`, `POWERTOOLS_SSH_HOSTS`, `POWERTOOLS_SSH_CMDS`, `POWERTOOLS_RESPAWN_UNITS`.
|
|
35
|
+
|
|
36
|
+
### Verify
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
cd <repo-root> # e.g. /Users/jl2/work/kode-cli-power
|
|
40
|
+
node --test kode-tsi/test/powertools-mcp.test.mjs kode-tsi/test/powertools-media.test.mjs
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Core brew: `jq` `yq` `fd` `ripgrep` `duf` `ffmpeg` (`tesseract` on Linux for `scan`). Classics usually ship with macOS: `lsof` `shasum` `xxd` `dig` `diff` `sqlite3` `ps` `sips`.
|
|
44
|
+
|
|
45
|
+
### Where Operator reads MCP config
|
|
46
|
+
|
|
47
|
+
1. `$KODE_MCP_CONFIG` if set (base file), else operator-home / legacy `mcp_servers.json`
|
|
48
|
+
2. **Merge-load:** if `$KODE_MCP_EXTRA` is set, that JSON is layered on top (same name → extra wins)
|
|
49
|
+
|
|
50
|
+
Secrets: sibling `.mcp_secrets.json` for `${VAR}` expansion.
|
|
51
|
+
|
|
52
|
+
### Live drive (no restart)
|
|
53
|
+
|
|
54
|
+
```text
|
|
55
|
+
/mcp add powertools /path/to/sandbox # upserts writable overlay + reload
|
|
56
|
+
/mcp reload # rediscover after editing config
|
|
57
|
+
/mcp on|off # saved setting
|
|
58
|
+
/mcp # status + per-server inventory
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Writable overlay: `$KODE_MCP_EXTRA` if set, else `$KODE_HOME/mcp_servers.json`.
|
|
62
|
+
|
|
63
|
+
Manual overlay still works:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
ROOT=/Users/jl2/work/kode-cli-power
|
|
67
|
+
export KODE_MCP_EXTRA=/tmp/powertools-extra.json
|
|
68
|
+
cat > "$KODE_MCP_EXTRA" <<EOF
|
|
69
|
+
{
|
|
70
|
+
"powertools": {
|
|
71
|
+
"command": "node",
|
|
72
|
+
"args": ["$ROOT/kode-tsi/mcp/powertools.mjs"],
|
|
73
|
+
"env": { "POWERTOOLS_ROOT": "$ROOT" }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
EOF
|
|
77
|
+
operator
|
|
78
|
+
# /mcp reload
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Frozen / not this server
|
|
82
|
+
|
|
83
|
+
- `src/tools/cli-power.py` — frozen unsafe prototype; do not extend.
|
|
84
|
+
- Skills under `operator-home/skills-catalogue/cli-power/` — retargeted to powertools MCP / bash; do not point at `cli-power.py`.
|
|
85
|
+
|
|
86
|
+
### Remote control
|
|
87
|
+
|
|
88
|
+
Follower `/mcp` stays **blocked** (`REMOTE_ESCALATION_COMMANDS`). Prefer `/pair` (QR e2e) over long-lived token RC when sharing a session.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env swift
|
|
2
|
+
// ocr-macos.swift — Vision-framework OCR for powertools `scan` (macOS).
|
|
3
|
+
// Usage: swift ocr-macos.swift <image-path>
|
|
4
|
+
// argv-only; no network. Prints recognized text to stdout.
|
|
5
|
+
|
|
6
|
+
import Foundation
|
|
7
|
+
import Vision
|
|
8
|
+
import AppKit
|
|
9
|
+
|
|
10
|
+
guard CommandLine.arguments.count >= 2 else {
|
|
11
|
+
fputs("usage: ocr-macos.swift <image-path>\n", stderr)
|
|
12
|
+
exit(2)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let path = CommandLine.arguments[1]
|
|
16
|
+
guard FileManager.default.fileExists(atPath: path) else {
|
|
17
|
+
fputs("error: file not found\n", stderr)
|
|
18
|
+
exit(1)
|
|
19
|
+
}
|
|
20
|
+
guard let img = NSImage(contentsOfFile: path),
|
|
21
|
+
let tiff = img.tiffRepresentation,
|
|
22
|
+
let rep = NSBitmapImageRep(data: tiff),
|
|
23
|
+
let cg = rep.cgImage else {
|
|
24
|
+
fputs("error: could not decode image (try convert to=jpg first)\n", stderr)
|
|
25
|
+
exit(1)
|
|
26
|
+
}
|
|
27
|
+
if cg.width <= 2 || cg.height <= 2 {
|
|
28
|
+
fputs("error: image too small for OCR (need >2px each side)\n", stderr)
|
|
29
|
+
exit(1)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let request = VNRecognizeTextRequest()
|
|
33
|
+
request.recognitionLevel = .accurate
|
|
34
|
+
request.usesLanguageCorrection = true
|
|
35
|
+
|
|
36
|
+
let handler = VNImageRequestHandler(cgImage: cg, options: [:])
|
|
37
|
+
do {
|
|
38
|
+
try handler.perform([request])
|
|
39
|
+
} catch {
|
|
40
|
+
fputs("error: \(error.localizedDescription)\n", stderr)
|
|
41
|
+
exit(1)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let lines = (request.results ?? []).compactMap { $0.topCandidates(1).first?.string }
|
|
45
|
+
print(lines.joined(separator: "\n"))
|