@0perator/operator 0.1.345 → 0.1.346
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/autonomy/delegate.js +4 -3
- package/dist/autonomy/session-factory.js +2 -1
- package/dist/autonomy/subagent-model.js +20 -0
- package/dist/background/commands.js +7 -0
- package/dist/background/index.js +135 -14
- package/dist/background/notices.js +25 -3
- package/dist/cli.js +64 -32
- package/dist/config/persona.js +29 -16
- package/dist/engine/agent.js +9 -2
- package/dist/engine/anthropic-chat.js +2 -2
- package/dist/engine/aurora.js +8 -4
- package/dist/engine/continuation.js +30 -5
- package/dist/engine/grandmaster.js +18 -1
- package/dist/engine/loop-guard.js +23 -20
- package/dist/session.js +48 -26
- package/dist/ui/ActivitySpinner.js +11 -16
- package/dist/ui/BgPanel.js +35 -24
- package/dist/ui/PlanPane.js +26 -2
- package/dist/ui/ToolStep.js +16 -2
- package/package.json +1 -1
|
@@ -350,13 +350,12 @@ export class LoopGuard {
|
|
|
350
350
|
// else might.
|
|
351
351
|
export const AUTOPOST_POLLERS = new Set(["agent_status"]);
|
|
352
352
|
export const POLL_SPIN_DEFAULTS = { nudgeAfter: 2, stopAfter: 3 };
|
|
353
|
-
export const POLL_SPIN_NUDGE = "
|
|
354
|
-
"
|
|
355
|
-
"
|
|
356
|
-
"
|
|
357
|
-
export const POLL_SPIN_STOP = "[stopped — waiting on sub-agents: agent_status was polled repeatedly with no
|
|
358
|
-
"
|
|
359
|
-
"lost — the reports arrive on their own.]";
|
|
353
|
+
export const POLL_SPIN_NUDGE = "agent_status will not change faster by asking again — each report, and a STUCK notice if one stalls, arrives " +
|
|
354
|
+
"as a message on its own. Act on what it shows: steer an agent that is stuck or off its brief (message_agent), " +
|
|
355
|
+
"or stop it (stop_agent) and do its step yourself. Otherwise do the work that does not depend on them, or close " +
|
|
356
|
+
"the turn for the owner: one status line per agent (round, files written) and 2-3 options.";
|
|
357
|
+
export const POLL_SPIN_STOP = "[stopped — waiting on sub-agents: agent_status was polled repeatedly with no change. Their reports, and a notice if " +
|
|
358
|
+
"one gets stuck, arrive on their own. Nothing was lost.]";
|
|
360
359
|
/** Watches settled tool rounds for an auto-post-poller spin. Fed one round at a time via observe(); a
|
|
361
360
|
* productive (non-poller) tool OR a changed poll result resets the streak. Side-effect-free: the engine acts
|
|
362
361
|
* on the returned action (inject the nudge once, then end the turn). */
|
|
@@ -416,13 +415,14 @@ export const DISPATCH_TOOLS = new Set(["spawn_agent"]);
|
|
|
416
415
|
* alone has no independent work in it. */
|
|
417
416
|
export const DISPATCH_BOOKKEEPING = new Set(["task_add", "task_update", "task_list", "task_clear", "agent_status", "message_agent"]);
|
|
418
417
|
export const YIELD_DEFAULTS = { nudgeAfter: 1, stopAfter: 2 };
|
|
419
|
-
export const YIELD_NUDGE = "Your sub-agents are
|
|
420
|
-
"
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
418
|
+
export const YIELD_NUDGE = "Your sub-agents are working their steps and this round changed nothing. Do not redo their work: finish what does " +
|
|
419
|
+
"not depend on them, or close the turn — one status line per agent and 2-3 options for the owner.";
|
|
420
|
+
export const YIELD_STOP = "[turn ended — sub-agents are running on this model's only slot, so the turn hands it to them; each report " +
|
|
421
|
+
"arrives as a new message and resumes this conversation. Nothing was lost.]";
|
|
422
|
+
export const YIELD_DISPATCHED = "[turn ended — sub-agents dispatched onto this model's only slot, so the turn hands it to them now; each report " +
|
|
423
|
+
"arrives as a new message and resumes this conversation. Nothing was lost.]";
|
|
424
|
+
/** Supervising IS progress: stopping a sub-agent (to take its step over) or asking the owner never counts as idling. */
|
|
425
|
+
export const SUPERVISION_TOOLS = new Set(["stop_agent", "ask_user"]);
|
|
426
426
|
/** Watches settled tool rounds after a spawn_agent dispatch. Fed one round at a time via observe(); a MUTATING
|
|
427
427
|
* round resets the streak. The endpoint's slot count sets the policy: on ONE slot (the fleet default) the parent
|
|
428
428
|
* working beside its sub-agents is pure contention — every parent round waits behind a sub-agent round and then
|
|
@@ -442,24 +442,27 @@ export class YieldAfterDispatchGuard {
|
|
|
442
442
|
this.stopAfter = stopAfter;
|
|
443
443
|
this.dispatched = armed;
|
|
444
444
|
}
|
|
445
|
-
/** One settled round: the tools it ran (names), whether any call changed the workspace,
|
|
446
|
-
*
|
|
447
|
-
|
|
445
|
+
/** One settled round: the tools it ran (names), whether any call changed the workspace, how many requests the
|
|
446
|
+
* model endpoint serves at once (engine/aurora.ts endpointSlots — 1 unless KODE_ENDPOINT_SLOTS says more), and
|
|
447
|
+
* whether a live sub-agent is served from THIS turn's slot. Sub-agents on another server (10/31: Cortana main,
|
|
448
|
+
* gpt-oss-20b children) cannot be starved by the parent, so it never yields to them — it keeps working and
|
|
449
|
+
* supervising, with one nudge against redoing their work. */
|
|
450
|
+
observe(names, mutating, slots = 1, shared = true) {
|
|
448
451
|
const single = slots <= 1;
|
|
449
452
|
if (names.some((n) => DISPATCH_TOOLS.has(n))) {
|
|
450
453
|
this.dispatched = true;
|
|
451
454
|
this.streak = 0;
|
|
452
455
|
const pure = names.every((n) => DISPATCH_TOOLS.has(n) || DISPATCH_BOOKKEEPING.has(n));
|
|
453
|
-
return single && pure ? { action: "halt", streak: 0, message: YIELD_DISPATCHED } : { action: "allow", streak: 0 };
|
|
456
|
+
return shared && single && pure ? { action: "halt", streak: 0, message: YIELD_DISPATCHED } : { action: "allow", streak: 0 };
|
|
454
457
|
}
|
|
455
458
|
if (!this.dispatched)
|
|
456
459
|
return { action: "allow", streak: 0 };
|
|
457
|
-
if (mutating) {
|
|
460
|
+
if (mutating || names.some((n) => SUPERVISION_TOOLS.has(n))) {
|
|
458
461
|
this.streak = 0;
|
|
459
462
|
return { action: "allow", streak: 0 };
|
|
460
463
|
}
|
|
461
464
|
this.streak += 1;
|
|
462
|
-
if (single || this.streak >= this.stopAfter)
|
|
465
|
+
if (shared && (single || this.streak >= this.stopAfter))
|
|
463
466
|
return { action: "halt", streak: this.streak, message: YIELD_STOP };
|
|
464
467
|
if (this.streak >= this.nudgeAfter && !this.nudged) {
|
|
465
468
|
this.nudged = true;
|
package/dist/session.js
CHANGED
|
@@ -15,6 +15,7 @@ import { dirname } from "node:path";
|
|
|
15
15
|
import { operatorPath } from "./config/home.js";
|
|
16
16
|
import { moaTeam, plannerBrief } from "./engine/moa.js";
|
|
17
17
|
import { routeTurn } from "./classifier/route.js";
|
|
18
|
+
import { engineNote, isStatusAsk, STATUS_FIRST_NOTE } from "./engine/continuation.js";
|
|
18
19
|
import { withDelegateDefault } from "./autonomy/delegate.js";
|
|
19
20
|
import { routeShadowTurn, shadowPrompt } from "./moa/shadow.js"; // MOA phase-0 observability (KODE_MOA_SHADOW)
|
|
20
21
|
import { AuroraRouter } from "./router/router.js";
|
|
@@ -78,37 +79,49 @@ export function renderBudgetBlock(b) {
|
|
|
78
79
|
// The `spawn_agent` tool — a thin pass-through to the shell's delegate handler. The handler owns the
|
|
79
80
|
// policy (cap) and the reply text; the tool just guards against an empty task. safe:false so it's an
|
|
80
81
|
// action (gated when permissions are on), never run speculatively in the safe-parallel batch.
|
|
82
|
+
/** A brief shorter than this is not a brief (10/31: a sub-agent was spawned with the objective "agent"). 12 refused a
|
|
83
|
+
* complete 11-word brief in the e2e ("Create the file …/nova.md containing exactly three lines: red, green, blue"). */
|
|
84
|
+
const MIN_BRIEF_WORDS = 5;
|
|
81
85
|
function makeSpawnTool(handler) {
|
|
82
86
|
return {
|
|
83
87
|
name: "spawn_agent",
|
|
84
88
|
safe: false,
|
|
85
|
-
description: "Spawn sub-agents: isolated sessions
|
|
86
|
-
"sub-agent; several run in parallel (2 running + 2 queued by default).
|
|
87
|
-
"
|
|
88
|
-
" what does NOT depend on them
|
|
89
|
-
"
|
|
90
|
-
"
|
|
89
|
+
description: "Spawn sub-agents: isolated sessions, each with its own shell, on the sub-agent model (the result says which). " +
|
|
90
|
+
"One `tasks` entry = one sub-agent; several run in parallel (2 running + 2 queued by default). Make THIS call in " +
|
|
91
|
+
"the same round you decide to delegate, and in that message tell the owner who you are sending and why (one line " +
|
|
92
|
+
"per agent). You stay the lead: do what does NOT depend on them; never redo, re-spawn or poll for a step one is " +
|
|
93
|
+
"working on — each report, and a STUCK notice if one stalls, arrives as a message at the start of a later turn. " +
|
|
94
|
+
"agent_status shows rounds, files and stuck flags; message_agent steers; stop_agent stops one so you can take its " +
|
|
95
|
+
"step over (a sub-agent id is not a shell job id).\n" +
|
|
91
96
|
"USE FOR: reasoning-heavy or context-flooding subtasks, independent parallel workstreams (research per area, " +
|
|
92
97
|
"review per module, search per tree, drafting a file).\n" +
|
|
93
98
|
"DO NOT USE FOR: a single tool call; mechanical steps; anything that needs the user; edits to the same files " +
|
|
94
99
|
"from several agents.\n" +
|
|
95
100
|
"RULES: the sub-agent knows NOTHING of this conversation — brief it as a spec: **Objective** · **Context** " +
|
|
96
|
-
"(every path, id, fact) · **Deliverable** · **Constraints** · **Done**. A
|
|
97
|
-
"
|
|
98
|
-
"CONCISE report (~1-2k tokens).",
|
|
101
|
+
"(every path, id, fact) · **Deliverable** · **Constraints** · **Done**. A file deliverable needs role code-edit or " +
|
|
102
|
+
"generic. A report is a SELF-REPORT — open what it produced and check it against Done before you tell the owner. " +
|
|
103
|
+
"SINGLE WRITER: keep file edits on one agent. Ask for a CONCISE report (~1-2k tokens) listing the files it wrote.",
|
|
99
104
|
parameters: {
|
|
100
105
|
type: "object",
|
|
101
106
|
properties: {
|
|
102
107
|
tasks: { type: "array", items: { type: "string" }, description: "the brief(s); one entry per sub-agent" },
|
|
103
108
|
task: { type: "string", description: "a single brief (same as a one-entry `tasks`)" },
|
|
104
|
-
role: { type: "string", enum: ["research", "search", "review", "plan", "code-edit", "generic"], description: "research = web research on an outside subject (web tools only, cites URLs); search = find things in this repo; review = code review; plan = a plan
|
|
109
|
+
role: { type: "string", enum: ["research", "search", "review", "plan", "code-edit", "generic"], description: "research = web research on an outside subject (web tools only, cites URLs); search = find things in this repo; review = code review; plan = a plan — those four cannot write files; code-edit = change files (own worktree); generic = every tool. Set it when the deliverable is a file." },
|
|
105
110
|
agent: { type: "string", description: "optional repo-local persona from .operator/agents/ (listed under 'Repo-local harness')" },
|
|
111
|
+
names: { type: "array", items: { type: "string" }, description: "a short first name for each sub-agent, same order as `tasks` (you choose them, e.g. Nova, Atlas) — the owner sees and steers them by name" },
|
|
112
|
+
name: { type: "string", description: "the name for a single `task`" },
|
|
106
113
|
},
|
|
107
114
|
},
|
|
108
115
|
run: async (args) => {
|
|
109
116
|
const briefs = (Array.isArray(args.tasks) ? args.tasks.map((t) => String(t ?? "").trim()) : [String(args.task ?? "").trim()]).filter(Boolean);
|
|
110
117
|
if (!briefs.length)
|
|
111
118
|
return "error: spawn_agent needs `tasks` (an array of briefs — one per sub-agent) or `task`";
|
|
119
|
+
const names = Array.isArray(args.names) ? args.names.map((n) => String(n ?? "").trim()) : [String(args.name ?? "").trim()];
|
|
120
|
+
const thin = briefs.findIndex((b) => b.split(/\s+/).filter(Boolean).length < MIN_BRIEF_WORDS);
|
|
121
|
+
if (thin >= 0) {
|
|
122
|
+
return `error: spawn_agent brief ${thin + 1} is too short to act on ("${briefs[thin].slice(0, 60)}"). The sub-agent knows NOTHING ` +
|
|
123
|
+
`of this conversation: write **Objective** · **Context** (every path, id, fact) · **Deliverable** · **Done** — or do the step yourself.`;
|
|
124
|
+
}
|
|
112
125
|
const agent = String(args.agent ?? "").trim();
|
|
113
126
|
const roleArg = String(args.role ?? "").trim();
|
|
114
127
|
const role = ["research", "search", "review", "plan", "code-edit", "generic"].includes(roleArg) ? roleArg : undefined;
|
|
@@ -119,10 +132,10 @@ function makeSpawnTool(handler) {
|
|
|
119
132
|
? `You are acting as the "${agent}" sub-agent for this repo. Follow this persona:\n\n${persona}\n\n---\nYour task:\n${task}`
|
|
120
133
|
: `${task}\n\n(note: no .operator/agents/${agent}.md persona found — ran without it)`;
|
|
121
134
|
if (briefs.length === 1)
|
|
122
|
-
return handler(frame(briefs[0]), role);
|
|
135
|
+
return handler(frame(briefs[0]), role, names[0] || undefined);
|
|
123
136
|
// Fan-out: one spawn per brief, in order; the manager queues past its running cap and refuses past the
|
|
124
137
|
// in-flight cap — each line reports what happened to that brief, so a partial fan-out is never silent.
|
|
125
|
-
return briefs.map((t, i) => `[${i + 1}/${briefs.length}] ${handler(frame(t), role)}`).join("\n");
|
|
138
|
+
return briefs.map((t, i) => `[${i + 1}/${briefs.length}] ${handler(frame(t), role, names[i] || undefined)}`).join("\n");
|
|
126
139
|
},
|
|
127
140
|
};
|
|
128
141
|
}
|
|
@@ -133,12 +146,13 @@ function makeMessageTool(handler) {
|
|
|
133
146
|
return {
|
|
134
147
|
name: "message_agent",
|
|
135
148
|
safe: false,
|
|
136
|
-
description: "Send a message to a background sub-agent that is STILL RUNNING (
|
|
137
|
-
"
|
|
149
|
+
description: "Send a message to a background sub-agent that is STILL RUNNING (its id, like agent-1, or its name): it acts on " +
|
|
150
|
+
"it at its next round — steer it, add context, answer its question, or re-steer one that is stuck or off its " +
|
|
151
|
+
"brief (name the exact file or next step). No-op once it has finished.",
|
|
138
152
|
parameters: {
|
|
139
153
|
type: "object",
|
|
140
154
|
properties: {
|
|
141
|
-
id: { type: "string", description: "sub-agent id
|
|
155
|
+
id: { type: "string", description: "sub-agent id (agent-1) or name" },
|
|
142
156
|
text: { type: "string", description: "the message" },
|
|
143
157
|
},
|
|
144
158
|
required: ["id", "text"],
|
|
@@ -160,13 +174,13 @@ function makeStatusTool(handler) {
|
|
|
160
174
|
return {
|
|
161
175
|
name: "agent_status",
|
|
162
176
|
safe: true,
|
|
163
|
-
description: "Check background sub-agents WITHOUT re-spawning them: no `id` lists every one
|
|
164
|
-
"(queued/working/idle/stopped); `id` checks one. Use it
|
|
165
|
-
"
|
|
166
|
-
"on
|
|
177
|
+
description: "Check background sub-agents WITHOUT re-spawning them: no `id` lists every one — name, role, model, status " +
|
|
178
|
+
"(queued/working/idle/stopped), round, files written, and STUCK with the reason; `id` (or name) checks one. Use it " +
|
|
179
|
+
"when the owner asks for an update or BEFORE you steer, stop or take one over — not in a loop: reports and stuck " +
|
|
180
|
+
"notices arrive on their own. bash_output/bash_kill are for shell jobs and will error on a sub-agent id.",
|
|
167
181
|
parameters: {
|
|
168
182
|
type: "object",
|
|
169
|
-
properties: { id: { type: "string", description: "optional sub-agent id; omit to list all" } },
|
|
183
|
+
properties: { id: { type: "string", description: "optional sub-agent id or name; omit to list all" } },
|
|
170
184
|
},
|
|
171
185
|
run: async (args) => {
|
|
172
186
|
const id = String(args.id ?? "").trim();
|
|
@@ -182,13 +196,14 @@ function makeStopTool(handler) {
|
|
|
182
196
|
return {
|
|
183
197
|
name: "stop_agent",
|
|
184
198
|
safe: false,
|
|
185
|
-
description: "Stop a background sub-agent
|
|
186
|
-
"acknowledge it. `id` stops one; omit it (or \"all\") to stop every
|
|
187
|
-
"come back as its report
|
|
188
|
-
"write
|
|
199
|
+
description: "Stop a background sub-agent when the owner asks to stop, cancel or kill one (or all) — never just " +
|
|
200
|
+
"acknowledge it — or when it is STUCK. `id` (or name) stops one; omit it (or \"all\") to stop every " +
|
|
201
|
+
"running/queued one. Its PARTIAL findings come back as its report; then do its step yourself or re-brief a fresh " +
|
|
202
|
+
"agent, and tell the owner which. Research/search/review/plan agents write no files by design — judge them by " +
|
|
203
|
+
"rounds and notes, not files.",
|
|
189
204
|
parameters: {
|
|
190
205
|
type: "object",
|
|
191
|
-
properties: { id: { type: "string", description: "sub-agent id; omit or \"all\" for every one" } },
|
|
206
|
+
properties: { id: { type: "string", description: "sub-agent id or name; omit or \"all\" for every one" } },
|
|
192
207
|
},
|
|
193
208
|
run: async (args) => {
|
|
194
209
|
const id = String(args.id ?? "").trim();
|
|
@@ -327,6 +342,7 @@ export class Session {
|
|
|
327
342
|
maxTurnWallClockMs;
|
|
328
343
|
loopGuard;
|
|
329
344
|
liveAgents;
|
|
345
|
+
slotSharers;
|
|
330
346
|
wakeTurn = false; // the turn in flight was started by the shell to deliver a report / job notice, not typed by the owner
|
|
331
347
|
hooks;
|
|
332
348
|
cwd;
|
|
@@ -423,6 +439,8 @@ export class Session {
|
|
|
423
439
|
if (!allow.has(name))
|
|
424
440
|
reg.delete(name);
|
|
425
441
|
}
|
|
442
|
+
for (const name of cfg.toolDeny ?? [])
|
|
443
|
+
reg.delete(name);
|
|
426
444
|
this.executor = new Executor(reg, cfg.cwd, cfg.sessionId);
|
|
427
445
|
this.shellKey = this.executor.shellKey; // for disposeShell() on teardown
|
|
428
446
|
this.localSchemas = toSchemas(reg);
|
|
@@ -454,6 +472,7 @@ export class Session {
|
|
|
454
472
|
this.maxTurnWallClockMs = cfg.maxTurnWallClockMs;
|
|
455
473
|
this.loopGuard = cfg.loopGuard;
|
|
456
474
|
this.liveAgents = cfg.liveAgents;
|
|
475
|
+
this.slotSharers = cfg.slotSharers;
|
|
457
476
|
this.hooks = cfg.hooks;
|
|
458
477
|
this.cwd = cfg.cwd;
|
|
459
478
|
this.unattended = cfg.unattended === true;
|
|
@@ -1288,7 +1307,8 @@ export class Session {
|
|
|
1288
1307
|
// for the flywheel row — the per-step structure SRFT credit assignment needs. runTurn pushes the user
|
|
1289
1308
|
// message itself, so everything from here on is this turn's.
|
|
1290
1309
|
const convoStart = this.convo.all.length;
|
|
1291
|
-
const
|
|
1310
|
+
const statusFirst = isStatusAsk(text) ? engineNote(STATUS_FIRST_NOTE) : ""; // the owner's "update?" is answered before any work
|
|
1311
|
+
const carry = [this.skillNote, this.pinnedSkill(), statusFirst].filter(Boolean).join("\n\n");
|
|
1292
1312
|
this.skillNote = "";
|
|
1293
1313
|
if (carry)
|
|
1294
1314
|
text = `${carry}\n\n${text}`;
|
|
@@ -1304,6 +1324,7 @@ export class Session {
|
|
|
1304
1324
|
preservedState: this.background ? undefined : () => renderActiveTasks() ?? undefined, // a mid-turn compaction keeps the active task list — the FOREGROUND's; the list is one module store, so a sub-agent must not see (or close on) the owner's items
|
|
1305
1325
|
background: this.background, // endpoint gate: a sub-agent's rounds yield the shared slot to the main turn
|
|
1306
1326
|
liveSubAgents: this.wakeTurn ? this.liveAgents : undefined, // a wake turn with sub-agents live yields from its first idle round
|
|
1327
|
+
slotSharers: this.slotSharers, // …but only to sub-agents on THIS model's slot; children on another server never make it yield
|
|
1307
1328
|
maxTokens: this.maxTokens,
|
|
1308
1329
|
maxTurnTokens: this.maxTurnTokens, // opt-in per-turn cost ceiling (total tokens); undefined → no cap
|
|
1309
1330
|
maxTurnWallClockMs: this.maxTurnWallClockMs, // opt-in per-turn TIME ceiling; the brake on hour-long crawling turns
|
|
@@ -1329,6 +1350,7 @@ export class Session {
|
|
|
1329
1350
|
onServed: h.onServed,
|
|
1330
1351
|
onSelfHeal: (kind, attempt) => { this.telemetry.record({ type: "self_heal", kind, attempt }); h.onSelfHeal?.(kind, attempt); },
|
|
1331
1352
|
onCompaction: (e) => { this.telemetry.record({ type: "compaction", ...e }); h.onCompaction?.(e); },
|
|
1353
|
+
steer: h.steer,
|
|
1332
1354
|
// Truncation black-box: raw unparseable-args evidence → observability/blackbox.ts (content-bearing,
|
|
1333
1355
|
// local-only). NOT telemetry.jsonl — that stream is metrics-only by policy. A metrics-only marker
|
|
1334
1356
|
// still goes to telemetry so dashboards can count incidents without reading content.
|
|
@@ -5,41 +5,36 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
// tofu (same font-safety rule as the star).
|
|
6
6
|
// • StepSpinner — a tool batch is executing (braille run-spinner, cyan)
|
|
7
7
|
// • OrbitSpinner — a background sub-agent is working (rotating arc, violet)
|
|
8
|
-
import { useEffect, useRef
|
|
8
|
+
import { useEffect, useRef } from "react";
|
|
9
9
|
import { Text } from "ink";
|
|
10
10
|
import { theme } from "./theme.js";
|
|
11
11
|
import { useTick } from "./tick.js";
|
|
12
12
|
import { renderBar } from "./progressbar.js";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return;
|
|
18
|
-
const id = setInterval(() => setI((n) => (n + 1) % frames.length), tickMs);
|
|
19
|
-
return () => clearInterval(id);
|
|
20
|
-
}, [active, frames, tickMs]);
|
|
21
|
-
return frames[i];
|
|
13
|
+
// Every glyph advances off the ONE shared clock (tick.ts): a timer per spinner meant one full-frame redraw per
|
|
14
|
+
// working sub-agent per tick — the panel flashed harder with each agent added (10/31).
|
|
15
|
+
function useFrame(frames, active) {
|
|
16
|
+
return frames[useTick(active) % frames.length];
|
|
22
17
|
}
|
|
23
18
|
const BRAILLE = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]; // classic run-spinner
|
|
24
19
|
const ORBIT = ["◜", "◠", "◝", "◞", "◡", "◟"]; // a dot orbiting a ring — "something running elsewhere"
|
|
25
20
|
const SETTLE = ["◐", "◓", "◑", "◒"]; // a filling/turning disc — "adjusting, working it out" (NOT an error)
|
|
26
21
|
/** Tools are executing this turn. Distinct from the star: a cyan braille run-spinner + the tool name(s). */
|
|
27
|
-
export function StepSpinner({ active, label
|
|
28
|
-
const glyph = useFrame(BRAILLE, active
|
|
22
|
+
export function StepSpinner({ active, label }) {
|
|
23
|
+
const glyph = useFrame(BRAILLE, active);
|
|
29
24
|
if (!active)
|
|
30
25
|
return null;
|
|
31
26
|
return (_jsxs(Text, { color: theme.info, children: [glyph, " ", label ? `${label}…` : "running…"] }));
|
|
32
27
|
}
|
|
33
28
|
/** A background sub-agent is working. Distinct again: a violet rotating arc + the agent label. */
|
|
34
|
-
export function OrbitSpinner({ active, label
|
|
35
|
-
const glyph = useFrame(ORBIT, active
|
|
29
|
+
export function OrbitSpinner({ active, label }) {
|
|
30
|
+
const glyph = useFrame(ORBIT, active);
|
|
36
31
|
if (!active)
|
|
37
32
|
return null;
|
|
38
33
|
return (_jsxs(Text, { color: theme.accent, children: [glyph, " ", label ?? "sub-agent working", "\u2026"] }));
|
|
39
34
|
}
|
|
40
35
|
/** Just the animated orbit glyph (violet), for embedding in the bg-agents list beside a working agent. */
|
|
41
|
-
export function OrbitGlyph(
|
|
42
|
-
return _jsx(Text, { color: theme.accent, children: useFrame(ORBIT, true
|
|
36
|
+
export function OrbitGlyph() {
|
|
37
|
+
return _jsx(Text, { color: theme.accent, children: useFrame(ORBIT, true) });
|
|
43
38
|
}
|
|
44
39
|
/** Self-heal in progress (context compaction / reconnect). Shown INSTEAD of a raw "http 400" so a recovery
|
|
45
40
|
* reads as the agent working it out, not an error — a PINK turning disc + a calm label + a PINK bar that
|
package/dist/ui/BgPanel.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
3
|
import { OrbitGlyph } from "./ActivitySpinner.js";
|
|
4
4
|
import { theme } from "./theme.js";
|
|
@@ -20,9 +20,7 @@ function metrics(a) {
|
|
|
20
20
|
parts.push(`${(ms / 1000).toFixed(ms < 10000 ? 1 : 0)}s`);
|
|
21
21
|
return parts.join(" · ");
|
|
22
22
|
}
|
|
23
|
-
//
|
|
24
|
-
// verified badge + malformed warning. Terminals have no hover, so the verify failure
|
|
25
|
-
// reason is shown inline (capped) instead of as a tooltip; success collapses to a bare ✓.
|
|
23
|
+
// Cap a string to n chars with an ellipsis (lines in the dynamic frame must never wrap).
|
|
26
24
|
const cap = (s, n = 60) => (s.length > n ? `${s.slice(0, n - 1)}…` : s);
|
|
27
25
|
// Humanize a tool name into the verb an owner reads at a glance ("editing cli.py", not "file_edit cli.py").
|
|
28
26
|
// Falls back to the raw name (underscores→spaces) for anything not in the table, so a new/MCP tool never
|
|
@@ -54,27 +52,40 @@ export function roundActivity(a) {
|
|
|
54
52
|
export function missionLine(a) {
|
|
55
53
|
return a.progress?.trim() || roundActivity(a);
|
|
56
54
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
/** The ledger line (pure, testable): role title · model · what it has done — "wrote 2 (a.md, b.md) · read 14 · ran 3". */
|
|
56
|
+
export function ledgerLine(a) {
|
|
57
|
+
const done = [
|
|
58
|
+
a.written?.length ? `wrote ${a.written.length} (${a.written.slice(-2).map((p) => p.split("/").pop()).join(", ")})` : "",
|
|
59
|
+
a.reads ? `read ${a.reads}` : "",
|
|
60
|
+
a.commands ? `ran ${a.commands}` : "",
|
|
61
|
+
].filter(Boolean).join(" · ");
|
|
62
|
+
const verify = a.verified == null ? "" : a.verified ? "✓ verified" : `✗ unverified${a.verifyDetail ? `: ${cap(a.verifyDetail, 30)}` : ""}`;
|
|
63
|
+
return [a.title ?? "assistant", a.model, done || (a.status === "working" ? "nothing written yet" : ""), verify, a.malformed ? "⚠ malformed" : ""]
|
|
64
|
+
.filter(Boolean).join(" · ");
|
|
63
65
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
/** The third row (pure, testable): a stuck agent shows WHY and the exact commands to re-steer or stop it; a working one
|
|
67
|
+
* its current steps or thought; a finished one where its result went. Always exactly one line. */
|
|
68
|
+
export function detailLine(a) {
|
|
69
|
+
if (a.status === "working" && a.stuck)
|
|
70
|
+
return { text: `⚠ stuck: ${a.stuck} — /agents ${a.id} msg <steer> · /agents ${a.id} stop`, tone: "stuck" };
|
|
71
|
+
if (a.status === "idle")
|
|
72
|
+
return { text: "result posted — scroll up or /agents to review", tone: "dim" };
|
|
73
|
+
if (a.status === "stopped")
|
|
74
|
+
return { text: "errored — check transcript for details", tone: "dim" };
|
|
75
|
+
if (a.status === "queued")
|
|
76
|
+
return { text: "waiting for a free slot", tone: "dim" };
|
|
70
77
|
const steps = a.steps ?? [];
|
|
71
|
-
const stepLine = steps
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
const stepLine = steps.slice(-3).map((s) => s.name + (s.arg ? `(${s.arg})` : "") + (s.running ? " …" : "")).join(" · ");
|
|
79
|
+
const head = stepLine ? `↳ ${stepLine}` : a.thought ? `⋮ ${a.thought.replace(/^…/, "").trim()}` : "";
|
|
80
|
+
const tail = a.lastOutput ? `⤷ ${a.lastOutput}` : "";
|
|
81
|
+
return { text: [head, tail].filter(Boolean).join(" ") || "starting…", tone: "dim" };
|
|
82
|
+
}
|
|
83
|
+
// One agent = exactly THREE rows, whatever its state: name line, ledger line, detail line. A fixed height keeps Ink's
|
|
84
|
+
// in-place redraw anchored — rows that appeared and vanished as thoughts/outputs came and went changed the frame height
|
|
85
|
+
// every tick, and Ink repainted the whole frame (the flashing, 10/31).
|
|
86
|
+
function AgentRows({ a }) {
|
|
87
|
+
const d = detailLine(a);
|
|
88
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Box, { flexGrow: 1, flexShrink: 1, children: _jsxs(Text, { wrap: "truncate-end", children: [a.status === "working" ? _jsx(OrbitGlyph, {}) : _jsx(Text, { color: COLOR[a.status], children: GLYPH[a.status] }), " ", _jsx(Text, { bold: true, children: a.name ?? a.label }), a.name ? _jsx(Text, { dimColor: true, children: ` · ${cap(a.label, 40)}` }) : null, a.round != null ? ` · round ${a.round}` : "", a.status === "working" && missionLine(a) ? _jsxs(Text, { color: theme.accent, children: [" \u00B7 ", cap(missionLine(a), 36)] }) : null] }) }), _jsx(Box, { flexShrink: 0, marginLeft: 1, children: _jsx(Text, { dimColor: true, children: (() => { const m = metrics(a); const ds = DISPLAY_STATUS[a.status]; return m ? `${m} · ${ds}` : ds; })() }) })] }), _jsx(Box, { paddingLeft: 2, children: _jsx(Text, { dimColor: true, wrap: "truncate-end", children: ledgerLine(a) }) }), _jsx(Box, { paddingLeft: 2, children: d.tone === "stuck" ? _jsx(Text, { color: theme.error, wrap: "truncate-end", children: d.text }) : _jsx(Text, { dimColor: true, wrap: "truncate-end", children: cap(d.text, 110) }) })] }));
|
|
78
89
|
}
|
|
79
90
|
// Cap how many agent rows the DYNAMIC panel renders. Each agent is ~3 lines; a full fan-out (6–8 agents)
|
|
80
91
|
// makes the non-Static frame tall AND it re-renders on every sub-agent token — so when it sits near the
|
|
@@ -125,5 +136,5 @@ export function BgPanel({ agents, jobs = [], title = "sub-agents" }) {
|
|
|
125
136
|
// frame SHORT — BG_MAX_VISIBLE caps rows, activity lines are capped — so the box stays a few rows tall.
|
|
126
137
|
// If stray border rows ever reappear on a very long turn, drop `borderStyle`/`borderColor` for the
|
|
127
138
|
// borderless column (the label line alone still heads it).
|
|
128
|
-
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, borderStyle: "round", borderColor: theme.muted, paddingX: 1, children: [_jsx(Text, { dimColor: true, children: label }), shown.map((a) =>
|
|
139
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, borderStyle: "round", borderColor: theme.muted, paddingX: 1, children: [_jsx(Text, { dimColor: true, children: label }), shown.map((a) => _jsx(AgentRows, { a: a }, a.id)), hidden > 0 ? _jsx(Text, { dimColor: true, children: ` +${hidden} more running` }) : null, _jsx(ShellJobs, { jobs: jobs })] }));
|
|
129
140
|
}
|
package/dist/ui/PlanPane.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
3
|
import { theme } from "./theme.js";
|
|
4
4
|
import { bar } from "./chart.js";
|
|
@@ -10,6 +10,27 @@ export function planProgress(tasks) {
|
|
|
10
10
|
const done = tasks.filter((t) => t.status === "done").length;
|
|
11
11
|
return `${done}/${tasks.length} done`;
|
|
12
12
|
}
|
|
13
|
+
/** Rows the pane may take in the DYNAMIC frame. Uncapped, a 16-item plan plus the sub-agent box made the live frame
|
|
14
|
+
* taller than the terminal, and Ink then clears and redraws the whole screen on every tick — the flashing (10/31). */
|
|
15
|
+
export const PLAN_MAX_ROWS = 6;
|
|
16
|
+
/** The rows to show (pure, testable): in-progress first, then the next pending, then the most recent finished — in plan
|
|
17
|
+
* order — capped at `max`, plus how many were left out. */
|
|
18
|
+
export function visiblePlan(tasks, max = PLAN_MAX_ROWS) {
|
|
19
|
+
if (tasks.length <= max)
|
|
20
|
+
return { shown: tasks, hidden: 0 };
|
|
21
|
+
const pick = new Set();
|
|
22
|
+
for (const t of tasks)
|
|
23
|
+
if (t.status === "in_progress" && pick.size < max)
|
|
24
|
+
pick.add(t);
|
|
25
|
+
for (const t of tasks)
|
|
26
|
+
if (t.status === "pending" && pick.size < max)
|
|
27
|
+
pick.add(t);
|
|
28
|
+
for (const t of [...tasks].reverse())
|
|
29
|
+
if (finished(t) && pick.size < max)
|
|
30
|
+
pick.add(t);
|
|
31
|
+
const shown = tasks.filter((t) => pick.has(t));
|
|
32
|
+
return { shown, hidden: tasks.length - shown.length };
|
|
33
|
+
}
|
|
13
34
|
export function PlanPane({ tasks, title = "plan" }) {
|
|
14
35
|
if (!tasks.length)
|
|
15
36
|
return null;
|
|
@@ -20,5 +41,8 @@ export function PlanPane({ tasks, title = "plan" }) {
|
|
|
20
41
|
// Borderless: this pane renders in Ink's DYNAMIC region; a box border there orphans its rows into
|
|
21
42
|
// scrollback whenever the Static transcript grows during a long turn (the v0.1.92 line-flood). The
|
|
22
43
|
// dim header labels the group without a border.
|
|
23
|
-
return (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [_jsxs(Text, { dimColor: true, children: [`${title} · ${planProgress(tasks)} `, _jsx(Text, { color: theme.success, children: bar(tasks.filter((t) => t.status === "done").length, tasks.length, 8) })] }),
|
|
44
|
+
return (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [_jsxs(Text, { dimColor: true, children: [`${title} · ${planProgress(tasks)} `, _jsx(Text, { color: theme.success, children: bar(tasks.filter((t) => t.status === "done").length, tasks.length, 8) })] }), (() => {
|
|
45
|
+
const { shown, hidden } = visiblePlan(tasks);
|
|
46
|
+
return (_jsxs(_Fragment, { children: [shown.map((t) => (_jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { color: COLOR[t.status], children: [GLYPH[t.status], " "] }), _jsx(Text, { dimColor: finished(t), strikethrough: finished(t), children: t.text })] }, t.id))), hidden > 0 ? _jsx(Text, { dimColor: true, children: ` +${hidden} more` }) : null] }));
|
|
47
|
+
})()] }));
|
|
24
48
|
}
|
package/dist/ui/ToolStep.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
3
|
import { formatDuration } from "./format.js";
|
|
4
4
|
import { fileLink } from "./osc.js";
|
|
@@ -56,6 +56,16 @@ export function argsPreview(args) {
|
|
|
56
56
|
}
|
|
57
57
|
return parts.join(", ");
|
|
58
58
|
}
|
|
59
|
+
/** The call's title. A shell call reads as the command itself — "$ ls -la /path" — like a terminal prompt (owner, 10/31:
|
|
60
|
+
* "bash needs to just show $"); every other tool reads name(args). `note` is the shell call's description, shown dim. */
|
|
61
|
+
export function stepTitle(step) {
|
|
62
|
+
if (SHELL_TOOLS.has(step.name) && typeof step.args?.command === "string") {
|
|
63
|
+
const cmd = step.args.command.replace(/\s+/g, " ").trim();
|
|
64
|
+
const desc = typeof step.args.description === "string" && step.args.description.trim() ? step.args.description.trim() : undefined;
|
|
65
|
+
return { head: "$", body: cmd.length > 160 ? cmd.slice(0, 157) + "..." : cmd, note: desc };
|
|
66
|
+
}
|
|
67
|
+
return { head: step.name, body: `(${argsPreview(step.args)})` };
|
|
68
|
+
}
|
|
59
69
|
/** For shell tools with a description, the command is shown dim beneath the description line. */
|
|
60
70
|
export function shellCommandHint(step) {
|
|
61
71
|
if (!SHELL_TOOLS.has(step.name) || !step.args?.description)
|
|
@@ -86,5 +96,9 @@ export function ToolStep({ step }) {
|
|
|
86
96
|
// lands. Only RUNNING media rows get the bar — everything else renders exactly as before.
|
|
87
97
|
const isRunningMedia = toolKind(step.name) === "media" && step.status === "running";
|
|
88
98
|
const mediaFraction = isRunningMedia && elapsed != null ? mediaProgressFraction(elapsed, mediaEtaMs(step.name, step.args)) : undefined;
|
|
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) }), " ",
|
|
99
|
+
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) }), " ", (() => {
|
|
100
|
+
const t = stepTitle(step);
|
|
101
|
+
const head = step.status === "running" ? _jsx(ShimmerText, { text: t.head, frame: frame, palette: huePalette(KIND_HUE[toolKind(step.name)]) }) : t.head;
|
|
102
|
+
return _jsxs(_Fragment, { children: [head, t.head === "$" ? " " : "", t.body, t.note ? _jsx(Text, { dimColor: true, children: ` · ${t.note}` }) : null] });
|
|
103
|
+
})(), 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] }), 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)))] }));
|
|
90
104
|
}
|