@0perator/operator 0.1.43 → 0.1.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +35 -16
- package/dist/engine/agent.js +6 -2
- package/dist/engine/aurora.js +5 -3
- package/dist/mcp/client.js +14 -3
- package/dist/session.js +5 -0
- package/dist/tools/chauffeur.js +3 -0
- package/dist/ui/App.js +2 -2
- package/dist/ui/StatusRule.js +9 -1
- package/dist/ui/ToolStep.js +34 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -19,7 +19,7 @@ import { expandFileMentions } from "./util/mentions.js";
|
|
|
19
19
|
import { join } from "node:path";
|
|
20
20
|
import { homedir, hostname } from "node:os";
|
|
21
21
|
import { createHash } from "node:crypto";
|
|
22
|
-
const VERSION = "0.1.
|
|
22
|
+
const VERSION = "0.1.45";
|
|
23
23
|
// operator/settings.json (override path via KODE_TSI_SETTINGS), env vars still win — see config/settings.ts.
|
|
24
24
|
const settings = loadSettings();
|
|
25
25
|
// Propagate the resolved sandbox mode to the tool layer (registry reads KODE_SANDBOX at exec time).
|
|
@@ -141,16 +141,22 @@ const EMBODIMENT_GUIDE = settings.computer.enabled
|
|
|
141
141
|
? `\n## Controlling this computer\nComputer control is ON (every action asks the owner first). Drive apps with ` +
|
|
142
142
|
`computer_app_open / computer_app_activate, computer_type, computer_key, computer_click, computer_screenshot.` +
|
|
143
143
|
(chauffeurReady
|
|
144
|
-
? ` To SEE the screen
|
|
145
|
-
`
|
|
146
|
-
`
|
|
147
|
-
|
|
148
|
-
`
|
|
149
|
-
|
|
150
|
-
`
|
|
151
|
-
`
|
|
152
|
-
`
|
|
153
|
-
|
|
144
|
+
? ` To SEE the screen use the chauffeur tools — NEVER shell_exec/osascript/System Events to read or drive ` +
|
|
145
|
+
`a GUI (AppleScript cannot read Electron apps like Slack/VS Code/Discord and just errors). Correct usage, ` +
|
|
146
|
+
`follow it exactly:\n` +
|
|
147
|
+
`- Do NOT pass a "session" argument to any chauffeur tool. Omit it — the implicit session is used ` +
|
|
148
|
+
`automatically. (Inventing a session label causes "session has ended" errors.)\n` +
|
|
149
|
+
`- To read a window: call chauffeur:list_windows, take a window_id + pid FROM THAT RESULT, then ` +
|
|
150
|
+
`immediately chauffeur:get_window_state {pid, window_id} → a TEXT accessibility tree (roles, labels, ` +
|
|
151
|
+
`values, clickable elements + coordinates). window_ids go stale, so always list_windows again right ` +
|
|
152
|
+
`before get_window_state; never reuse an old id.\n` +
|
|
153
|
+
`- To act: chauffeur:click / chauffeur:type_text / chauffeur:press_key, addressing elements by the info ` +
|
|
154
|
+
`from the latest get_window_state.\n` +
|
|
155
|
+
`- If ANY chauffeur tool returns "session has ended", call chauffeur:start_session ONCE (no arguments), ` +
|
|
156
|
+
`then retry the read — do not loop the failing call.\n` +
|
|
157
|
+
`Work END-TO-END from the owner's one instruction: read → decide → act by chaining these tools yourself, ` +
|
|
158
|
+
`then report the result. Reads run without a prompt; only actions ask. Use ask_user only for a genuine ` +
|
|
159
|
+
`owner decision — never to walk through a task you can just do.`
|
|
154
160
|
: ` NOTE: reliably READING on-screen UI (especially Electron apps like Slack) needs the chauffeur driver, ` +
|
|
155
161
|
`which is not installed here; computer_screenshot only saves a PNG you cannot read back yet. Do not ` +
|
|
156
162
|
`hand-write osascript to scrape a GUI — it will error on Electron apps.`)
|
|
@@ -480,12 +486,19 @@ function Root() {
|
|
|
480
486
|
push({ kind: "message", message: { id: nextId(), role: "assistant", content: outcome.content, reasoning } });
|
|
481
487
|
remoteRef.current?.finalAssistant(outcome.content, reasoning);
|
|
482
488
|
}
|
|
483
|
-
// Surface the turn's real
|
|
484
|
-
|
|
489
|
+
// Surface the turn's real metrics: wall time · output tokens @ decode tok/s · prefill size. The
|
|
490
|
+
// prefill number is the key one on a local model — it's where "0 tokens for N seconds" goes (the
|
|
491
|
+
// model reading the prompt), otherwise invisible.
|
|
492
|
+
if (!outcome.interrupted && (outcome.tokens || outcome.durationMs || outcome.promptTokens)) {
|
|
485
493
|
const tok = outcome.tokens ?? 0;
|
|
486
494
|
const durationMs = outcome.durationMs ?? 0;
|
|
487
495
|
const secs = durationMs / 1000;
|
|
488
|
-
|
|
496
|
+
const tps = outcome.genMs && outcome.genMs > 0 ? Math.round(tok / (outcome.genMs / 1000)) : 0;
|
|
497
|
+
const prefill = outcome.promptTokens ?? 0;
|
|
498
|
+
const parts = [fmtDuration(secs), `${fmtTokens(tok).replace(/ tokens?$/, " tok")}${tps ? ` @ ${tps} tok/s` : ""}`];
|
|
499
|
+
if (prefill)
|
|
500
|
+
parts.push(`${fmtTokens(prefill).replace(/ tokens?$/, "")} prefill`);
|
|
501
|
+
setMetrics(`(${parts.join(" · ")})`);
|
|
489
502
|
// Feed the same numbers to the frozen event stream (dashboard + mobile). Gated on telemetry.enabled.
|
|
490
503
|
if (emitTelemetry) {
|
|
491
504
|
eventSink.emit({ kind: "turn", session: SESSION_ID, actor: EVENT_ACTOR,
|
|
@@ -802,10 +815,16 @@ function Root() {
|
|
|
802
815
|
// turn's numbers mid-turn — the clock always moves.
|
|
803
816
|
const SPIN = "⣾⣽⣻⢿⡿⣟⣯⣷";
|
|
804
817
|
const active = status === "streaming" || status === "thinking" || status === "executing" || status === "recovering";
|
|
818
|
+
const spin = SPIN[Math.floor(elapsed * 4) % SPIN.length];
|
|
819
|
+
// Before the first token streams, the model is PREFILLING (reading the prompt) — that's the "0 tokens
|
|
820
|
+
// for N seconds" the user sees. Label it honestly instead of showing a frozen "0 tokens", so a slow
|
|
821
|
+
// local prefill reads as work in progress, not a hang. Once tokens flow, show the live count + elapsed.
|
|
805
822
|
const liveMetrics = active
|
|
806
|
-
?
|
|
823
|
+
? liveTok === 0
|
|
824
|
+
? `${spin} reading your prompt… (${fmtDuration(elapsed)})`
|
|
825
|
+
: `${spin} ${fmtMeta(elapsed, liveTok)}`
|
|
807
826
|
: metrics;
|
|
808
|
-
return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, route: route, ctxPct: ctxPct, version: VERSION, metrics: liveMetrics, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, approval: approval, question: question, onApprovalDecide: (allow, always) => {
|
|
827
|
+
return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, route: route, ctxPct: ctxPct, version: VERSION, metrics: liveMetrics, sessionTokens: session.sessionTokens() + liveTok, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, approval: approval, question: question, onApprovalDecide: (allow, always) => {
|
|
809
828
|
const cur = approval;
|
|
810
829
|
if (cur)
|
|
811
830
|
settleApproval(cur.id, allow, always); // first-wins with any remote follower answer
|
package/dist/engine/agent.js
CHANGED
|
@@ -112,6 +112,8 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
112
112
|
let toolCallTotal = 0;
|
|
113
113
|
let tokensTotal = 0; // output tokens summed across rounds (from llama.cpp timings)
|
|
114
114
|
let genMsTotal = 0; // server-side generation ms summed across rounds
|
|
115
|
+
let promptTokensTotal = 0; // prompt tokens PREFILLED, summed across rounds
|
|
116
|
+
let promptMsTotal = 0; // prefill ms summed across rounds
|
|
115
117
|
let emptyRetries = 0; // reasoning models sometimes return a "dud" round (no content, no tool calls)
|
|
116
118
|
for (; rounds < hardCap; rounds++) {
|
|
117
119
|
throwIfAborted(opts.signal); // stop before spending another round (covers compaction below too)
|
|
@@ -152,6 +154,8 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
152
154
|
});
|
|
153
155
|
tokensTotal += response.tokens ?? 0;
|
|
154
156
|
genMsTotal += response.genMs ?? 0; // accumulate real gen metrics across rounds
|
|
157
|
+
promptTokensTotal += response.promptTokens ?? 0;
|
|
158
|
+
promptMsTotal += response.promptMs ?? 0; // and prefill (the invisible wall-time cost)
|
|
155
159
|
break;
|
|
156
160
|
}
|
|
157
161
|
catch (err) {
|
|
@@ -243,9 +247,9 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
243
247
|
? "(hit the output limit before an answer landed — ask me to continue and I'll pick up where I left off.)"
|
|
244
248
|
: "(the model returned an empty response — try rephrasing.)");
|
|
245
249
|
conversation.assistant(answer);
|
|
246
|
-
return { content: answer, rounds: rounds + 1, toolCalls: toolCallTotal, stopReason: response.stopReason, tokens: tokensTotal, genMs: genMsTotal };
|
|
250
|
+
return { content: answer, rounds: rounds + 1, toolCalls: toolCallTotal, stopReason: response.stopReason, tokens: tokensTotal, genMs: genMsTotal, promptTokens: promptTokensTotal, promptMs: promptMsTotal };
|
|
247
251
|
}
|
|
248
252
|
const timeoutMsg = `[stopped after ${hardCap} tool rounds — the task may be unfinished; ask me to continue and I'll pick up where I left off]`;
|
|
249
253
|
conversation.assistant(timeoutMsg);
|
|
250
|
-
return { content: timeoutMsg, rounds, toolCalls: toolCallTotal, tokens: tokensTotal, genMs: genMsTotal };
|
|
254
|
+
return { content: timeoutMsg, rounds, toolCalls: toolCallTotal, tokens: tokensTotal, genMs: genMsTotal, promptTokens: promptTokensTotal, promptMs: promptMsTotal };
|
|
251
255
|
}
|
package/dist/engine/aurora.js
CHANGED
|
@@ -111,7 +111,7 @@ async function* streamDeltas(messages, o) {
|
|
|
111
111
|
const j = JSON.parse(d);
|
|
112
112
|
// llama.cpp sends a final chunk carrying `timings` (predicted_n/_ms); OpenAI servers send `usage`.
|
|
113
113
|
if (j.timings || j.usage)
|
|
114
|
-
o.onMeta?.({ tokens: j.timings?.predicted_n ?? j.usage?.completion_tokens, genMs: j.timings?.predicted_ms });
|
|
114
|
+
o.onMeta?.({ tokens: j.timings?.predicted_n ?? j.usage?.completion_tokens, genMs: j.timings?.predicted_ms, promptTokens: j.timings?.prompt_n ?? j.usage?.prompt_tokens, promptMs: j.timings?.prompt_ms });
|
|
115
115
|
const choice = j.choices?.[0];
|
|
116
116
|
// finish_reason is a sibling of delta (often on a final chunk whose delta is {} or absent).
|
|
117
117
|
// Attach it to the yielded delta, and still yield a bare {finish_reason} when there's no delta,
|
|
@@ -163,7 +163,9 @@ export async function chat(messages, o) {
|
|
|
163
163
|
const meta = {};
|
|
164
164
|
const oo = { ...o, onMeta: (m) => { if (m.tokens != null)
|
|
165
165
|
meta.tokens = m.tokens; if (m.genMs != null)
|
|
166
|
-
meta.genMs = m.genMs;
|
|
166
|
+
meta.genMs = m.genMs; if (m.promptTokens != null)
|
|
167
|
+
meta.promptTokens = m.promptTokens; if (m.promptMs != null)
|
|
168
|
+
meta.promptMs = m.promptMs; o.onMeta?.(m); } };
|
|
167
169
|
for await (const delta of streamDeltas(messages, oo)) {
|
|
168
170
|
if (delta.content) {
|
|
169
171
|
content += delta.content;
|
|
@@ -216,7 +218,7 @@ export async function chat(messages, o) {
|
|
|
216
218
|
// "length" isn't a truncated ANSWER, so only flag length/content_filter when NO tool calls were made.
|
|
217
219
|
const apiStop = finishReason === "length" ? "length" : finishReason === "content_filter" ? "content_filter" : undefined;
|
|
218
220
|
const stopReason = degenerate ? "repetition" : (acc.size === 0 ? apiStop : undefined);
|
|
219
|
-
return { content, toolCalls, reasoningContent: reasoning || undefined, stopReason, tokens: meta.tokens, genMs: meta.genMs };
|
|
221
|
+
return { content, toolCalls, reasoningContent: reasoning || undefined, stopReason, tokens: meta.tokens, genMs: meta.genMs, promptTokens: meta.promptTokens, promptMs: meta.promptMs };
|
|
220
222
|
}
|
|
221
223
|
/** GET {base}/health → true iff {"status":"ok"}. Used by Router (SPEC §4) for self-heal failover. */
|
|
222
224
|
export async function health(base) {
|
package/dist/mcp/client.js
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
/** Flatten an MCP tools/call result
|
|
1
|
+
/** Flatten an MCP tools/call result to a single string (shared by both transports). Includes the machine-
|
|
2
|
+
* readable `structuredContent` when present: for many tools the text content is only a human summary
|
|
3
|
+
* ("Found 76 windows.") and the data the model must act on (ids, elements, coordinates) lives in
|
|
4
|
+
* structuredContent — dropping it left the model blind and looping. */
|
|
2
5
|
export function flattenResult(result) {
|
|
3
6
|
const text = (result?.content ?? [])
|
|
4
7
|
.map((c) => (c.type === "text" ? c.text ?? "" : `[${c.type}]`))
|
|
5
8
|
.join("\n")
|
|
6
9
|
.trim();
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
let structured = "";
|
|
11
|
+
if (result?.structuredContent !== undefined && result.structuredContent !== null) {
|
|
12
|
+
try {
|
|
13
|
+
structured = JSON.stringify(result.structuredContent);
|
|
14
|
+
}
|
|
15
|
+
catch { /* non-serializable → skip */ }
|
|
16
|
+
}
|
|
17
|
+
// Prefer both: the human line as a header, then the JSON payload the model parses. Either alone is valid.
|
|
18
|
+
const body = structured ? (text ? `${text}\n${structured}` : structured) : (text || "(no content)");
|
|
19
|
+
return result?.isError ? `error: ${body}` : body;
|
|
9
20
|
}
|
|
10
21
|
let RPC_ID = 0;
|
|
11
22
|
export class McpHttpClient {
|
package/dist/session.js
CHANGED
|
@@ -95,6 +95,7 @@ export class Session {
|
|
|
95
95
|
memory;
|
|
96
96
|
wantRecall;
|
|
97
97
|
recallBlock = ""; // memory recalled on the first turn, folded into the system prompt thereafter
|
|
98
|
+
sessionTokensTotal = 0; // cumulative prefill+output tokens across all turns (Claude-Code-style session total)
|
|
98
99
|
planMode = false; // /plan: research read-only + propose a plan, no mutations until the owner approves
|
|
99
100
|
thinkMode = "off"; // /think, /ultrathink — extended reasoning
|
|
100
101
|
recalled = false;
|
|
@@ -195,6 +196,9 @@ export class Session {
|
|
|
195
196
|
const chars = JSON.stringify(this.convo.all).length + (this.sys()?.length ?? 0);
|
|
196
197
|
return Math.min(99, Math.round((Math.ceil(chars / 4) / this.inner.ctxLimit()) * 100));
|
|
197
198
|
}
|
|
199
|
+
/** Cumulative tokens (prefill + output) across every turn this session — the Claude-Code-style running
|
|
200
|
+
* session total for the status rule, so the real spend is visible (not just the current completion). */
|
|
201
|
+
sessionTokens() { return this.sessionTokensTotal; }
|
|
198
202
|
/** Abort the in-flight turn (ESC / Stop). No-op when idle. */
|
|
199
203
|
interrupt() {
|
|
200
204
|
this.ctrl?.abort();
|
|
@@ -342,6 +346,7 @@ export class Session {
|
|
|
342
346
|
onSelfHeal: (kind, attempt) => { this.telemetry.record({ type: "self_heal", kind, attempt }); h.onSelfHeal?.(kind, attempt); },
|
|
343
347
|
});
|
|
344
348
|
this.telemetry.record({ type: "turn", rounds: res.rounds, toolCalls: res.toolCalls, interrupted: false, durationMs: Math.round(performance.now() - _t0), ctxPct: this.ctxPct(), stopReason: res.stopReason });
|
|
349
|
+
this.sessionTokensTotal += (res.tokens ?? 0) + (res.promptTokens ?? 0); // cumulative session spend
|
|
345
350
|
return { ...res, interrupted: false, durationMs: Math.round(performance.now() - _t0) };
|
|
346
351
|
}
|
|
347
352
|
catch (e) {
|
package/dist/tools/chauffeur.js
CHANGED
|
@@ -13,6 +13,9 @@ import { McpHub } from "../mcp/index.js";
|
|
|
13
13
|
// through each step) and ACTIONS (input/mutation — always gated "ask" in the foreground, "deny" in bg).
|
|
14
14
|
export const CHAUFFEUR_READ_TOOLS = [
|
|
15
15
|
"list_windows", "get_window_state", "get_desktop_state", "list_apps", "clipboard_read",
|
|
16
|
+
// Session lifecycle (control, non-mutating → unprompted). Chauffeur is session-based: without these the
|
|
17
|
+
// model can't recover from a "session has ended" error and every stateful read fails in a loop.
|
|
18
|
+
"start_session", "get_session", "list_sessions",
|
|
16
19
|
];
|
|
17
20
|
export const CHAUFFEUR_ACTION_TOOLS = [
|
|
18
21
|
"launch_app", "bring_to_front", // window/app management
|
package/dist/ui/App.js
CHANGED
|
@@ -10,10 +10,10 @@ import { BgPanel } from "./BgPanel.js";
|
|
|
10
10
|
import { ApprovalPrompt } from "./ApprovalPrompt.js";
|
|
11
11
|
import { QuestionPrompt } from "./QuestionPrompt.js";
|
|
12
12
|
export function App(props) {
|
|
13
|
-
const { messages, live = null, status, thinkingVerb, verbs, stepLabel, route, ctxPct, version, build, metrics, authUser, tier, planMode, thinkMode, bgAgents, onSubmit, onQueue, onInterrupt, approval = null, onApprovalDecide, question = null } = props;
|
|
13
|
+
const { messages, live = null, status, thinkingVerb, verbs, stepLabel, route, ctxPct, version, build, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, onSubmit, onQueue, onInterrupt, approval = null, onApprovalDecide, question = null } = props;
|
|
14
14
|
const thinking = status === "thinking" || status === "streaming";
|
|
15
15
|
const showSpinner = status === "recovering" || status === "executing" || thinking;
|
|
16
16
|
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Transcript, { entries: messages, live: live }), showSpinner && (_jsx(Box, { marginTop: 1, marginBottom: 1, children: status === "recovering" ? _jsx(RecoverSpinner, { active: true, label: stepLabel })
|
|
17
17
|
: status === "executing" ? _jsx(StepSpinner, { active: true, label: stepLabel })
|
|
18
|
-
: _jsx(ThinkingSpinner, { active: true, verb: thinkingVerb, verbs: verbs, metrics: metrics }) })), _jsx(BgPanel, { agents: bgAgents }), _jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }) }), _jsx(QuestionPrompt, { pending: question }), _jsx(StatusRule, { route: route, ctxPct: ctxPct, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode }), _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, disabled: status !== "idle", suspended: !!approval || !!question }), _jsx(InputRule, {})] }));
|
|
18
|
+
: _jsx(ThinkingSpinner, { active: true, verb: thinkingVerb, verbs: verbs, metrics: metrics }) })), _jsx(BgPanel, { agents: bgAgents }), _jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }) }), _jsx(QuestionPrompt, { pending: question }), _jsx(StatusRule, { route: route, ctxPct: ctxPct, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode, sessionTokens: sessionTokens }), _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, disabled: status !== "idle", suspended: !!approval || !!question }), _jsx(InputRule, {})] }));
|
|
19
19
|
}
|
package/dist/ui/StatusRule.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
|
+
// Compact token count for the status rule: 1234 -> "1.2k", 45231 -> "45k", 800 -> "800".
|
|
4
|
+
function fmtK(n) {
|
|
5
|
+
if (n < 1000)
|
|
6
|
+
return String(n);
|
|
7
|
+
const k = n / 1000;
|
|
8
|
+
return `${k >= 10 ? Math.round(k) : k.toFixed(1)}k`;
|
|
9
|
+
}
|
|
3
10
|
// Conservative terminal cell width: ASCII, Latin punctuation (·), and the box-drawing block (─, ≤ U+257F)
|
|
4
11
|
// are one cell; anything above the box-drawing block is a symbol/dingbat/geometric glyph the terminal
|
|
5
12
|
// font is free to render two cells wide, so we count it as 2. Over-estimating is safe (a shorter rule);
|
|
@@ -39,7 +46,8 @@ export function statusRight(p, cols) {
|
|
|
39
46
|
const seat = p.tier && p.tier !== "admin" ? `⛨ ${p.tier} · ` : ""; // a narrowed seat shows; owner's admin doesn't
|
|
40
47
|
const plan = p.planMode ? `◔ plan · ` : ""; // read-only research mode is visible while active
|
|
41
48
|
const think = p.thinkMode === "ultrathink" ? `✲✲ ultrathink · ` : p.thinkMode === "think" ? `✲ think · ` : "";
|
|
42
|
-
|
|
49
|
+
const tok = p.sessionTokens && p.sessionTokens > 0 ? `Σ${fmtK(p.sessionTokens)} · ` : ""; // session token total
|
|
50
|
+
let info = `${think}${plan}${seat}${who}${p.route} · ${Math.round(p.ctxPct)}% · ${tok}v${p.version}${p.build ? ` ·${p.build}` : ""}`;
|
|
43
51
|
let right = `✷ OPERATOR · ${info} ─`;
|
|
44
52
|
const maxRight = cols - 3; // leaves fill ≥ 1 and total = cols-1
|
|
45
53
|
if (cellWidth(right) > maxRight) {
|
package/dist/ui/ToolStep.js
CHANGED
|
@@ -6,13 +6,42 @@ import { Box, Text } from "ink";
|
|
|
6
6
|
import { formatDuration } from "./format.js";
|
|
7
7
|
const GLYPH = { selected: "○", running: "◐", done: "✓", error: "✗" };
|
|
8
8
|
const COLOR = { selected: "gray", running: "#e8a33d", done: "green", error: "red" };
|
|
9
|
-
|
|
9
|
+
// Args that identify WHAT a tool acted on — a path, a command, a URL. These are shown FIRST and IN FULL
|
|
10
|
+
// (never truncated), so you can always read the exact file name / path a tool wrote or read. Order matters:
|
|
11
|
+
// path-like keys first.
|
|
12
|
+
const KEY_ARGS = ["path", "file", "filename", "command", "cmd", "pattern", "url", "query", "workspace", "cwd", "name"];
|
|
13
|
+
// Bulky payloads — never dumped (they'd bury the path and blow up the line); shown as a size instead.
|
|
14
|
+
const BULK_ARGS = ["content", "text", "body", "data", "new_string", "old_string", "diff", "message"];
|
|
15
|
+
export function argsPreview(args) {
|
|
10
16
|
if (!args)
|
|
11
17
|
return "";
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
const parts = [];
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
// 1) identifying keys, in full — the file name/path is the point, so it is NEVER clipped.
|
|
21
|
+
for (const k of KEY_ARGS) {
|
|
22
|
+
const v = args[k];
|
|
23
|
+
if (v != null && (typeof v === "string" || typeof v === "number")) {
|
|
24
|
+
parts.push(`${k}: ${v}`);
|
|
25
|
+
seen.add(k);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// 2) bulky payloads → just a length, never the content.
|
|
29
|
+
for (const k of BULK_ARGS) {
|
|
30
|
+
if (typeof args[k] === "string") {
|
|
31
|
+
parts.push(`${k}: ${args[k].length} chars`);
|
|
32
|
+
seen.add(k);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// 3) any remaining scalar args, each individually trimmed (never at the cost of the path above).
|
|
36
|
+
for (const [k, v] of Object.entries(args)) {
|
|
37
|
+
if (seen.has(k))
|
|
38
|
+
continue;
|
|
39
|
+
const s = typeof v === "string" ? v : JSON.stringify(v);
|
|
40
|
+
if (s == null)
|
|
41
|
+
continue;
|
|
42
|
+
parts.push(`${k}=${s.length > 40 ? `${s.slice(0, 37)}...` : s}`);
|
|
43
|
+
}
|
|
44
|
+
return parts.join(", ");
|
|
16
45
|
}
|
|
17
46
|
export function ToolStep({ step }) {
|
|
18
47
|
const [now, setNow] = useState(() => Date.now());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0perator/operator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.45",
|
|
4
4
|
"description": "Operator (KODE) — TypeScript + Ink terminal coding agent. Full-frame render, single-engine core shared across CLI/web/mobile; runs against a local Aurora model.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|