@0perator/operator 0.1.352 → 0.1.353

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.
Files changed (90) hide show
  1. package/dist/acp/agent.js +2 -2
  2. package/dist/acp/tool-map.js +5 -4
  3. package/dist/autonomy/delegate.js +54 -1
  4. package/dist/autonomy/headless.js +2 -0
  5. package/dist/autonomy/session-factory.js +1 -0
  6. package/dist/background/index.js +86 -10
  7. package/dist/background/notices.js +16 -4
  8. package/dist/cli.js +1066 -175
  9. package/dist/config/home.js +6 -0
  10. package/dist/config/memory-sections.js +92 -0
  11. package/dist/config/persona.js +144 -26
  12. package/dist/config/settings.js +15 -4
  13. package/dist/consolidation/scheduler.js +9 -2
  14. package/dist/consolidation/sleep.js +39 -278
  15. package/dist/engine/agent.js +444 -76
  16. package/dist/engine/anthropic-chat.js +13 -2
  17. package/dist/engine/aurora.js +43 -19
  18. package/dist/engine/batch-scheduler.js +27 -3
  19. package/dist/engine/compaction.js +12 -5
  20. package/dist/engine/continuation.js +14 -12
  21. package/dist/engine/contract.js +1 -1
  22. package/dist/engine/decision-points.js +7 -1
  23. package/dist/engine/front-door.js +59 -0
  24. package/dist/engine/grandmaster.js +13 -1
  25. package/dist/engine/loop-guard.js +694 -0
  26. package/dist/engine/owner-act.js +52 -0
  27. package/dist/engine/verify-gate.js +52 -0
  28. package/dist/flywheel/processor.js +3 -1
  29. package/dist/flywheel/srft.js +8 -4
  30. package/dist/hooks/index.js +12 -8
  31. package/dist/mcp/index.js +9 -4
  32. package/dist/permissions/index.js +32 -11
  33. package/dist/permissions/modes.js +42 -0
  34. package/dist/permissions/plan-review.js +100 -0
  35. package/dist/permissions/policy.js +16 -5
  36. package/dist/permissions/signature.js +8 -3
  37. package/dist/remote/safe-commands.js +1 -1
  38. package/dist/router/read-rates.js +152 -0
  39. package/dist/selfimprove/backfill.js +174 -0
  40. package/dist/selfimprove/index.js +146 -57
  41. package/dist/selfimprove/lessons.js +429 -0
  42. package/dist/selfimprove/sync.js +58 -0
  43. package/dist/session.js +350 -30
  44. package/dist/skills/finder.js +219 -0
  45. package/dist/tools/deferred.js +28 -18
  46. package/dist/tools/executor.js +7 -3
  47. package/dist/tools/registry.js +34 -4
  48. package/dist/ui/ActivitySpinner.js +21 -12
  49. package/dist/ui/App.js +107 -30
  50. package/dist/ui/ApprovalPrompt.js +5 -3
  51. package/dist/ui/ArtifactPicker.js +3 -3
  52. package/dist/ui/BgPanel.js +105 -5
  53. package/dist/ui/Composer.js +85 -9
  54. package/dist/ui/PlanPane.js +72 -8
  55. package/dist/ui/QuestionPrompt.js +6 -4
  56. package/dist/ui/SecretPrompt.js +8 -3
  57. package/dist/ui/SessionPicker.js +2 -2
  58. package/dist/ui/SkillFinder.js +153 -0
  59. package/dist/ui/StatusRule.js +5 -2
  60. package/dist/ui/SummaryCard.js +3 -1
  61. package/dist/ui/ThinkingSpinner.js +11 -2
  62. package/dist/ui/ToolBatch.js +11 -2
  63. package/dist/ui/ToolStep.js +36 -13
  64. package/dist/ui/Transcript.js +13 -2
  65. package/dist/ui/actNow.js +61 -0
  66. package/dist/ui/batchLine.js +165 -0
  67. package/dist/ui/conversations.js +154 -0
  68. package/dist/ui/decodeHealth.js +77 -0
  69. package/dist/ui/expand.js +17 -0
  70. package/dist/ui/fit.js +40 -0
  71. package/dist/ui/fitTail.js +14 -0
  72. package/dist/ui/fold.js +149 -0
  73. package/dist/ui/format.js +46 -2
  74. package/dist/ui/liveTools.js +163 -13
  75. package/dist/ui/modelPicker.js +78 -6
  76. package/dist/ui/nextStep.js +103 -0
  77. package/dist/ui/pending.js +57 -0
  78. package/dist/ui/phase.js +105 -0
  79. package/dist/ui/planExit.js +0 -5
  80. package/dist/ui/progressbar.js +4 -26
  81. package/dist/ui/readForecast.js +44 -0
  82. package/dist/ui/readProgress.js +119 -0
  83. package/dist/ui/reportLine.js +62 -0
  84. package/dist/ui/slashCommands.js +1 -1
  85. package/dist/ui/theme.js +1 -0
  86. package/dist/ui/turnFlow.js +72 -0
  87. package/dist/ui/turnLedger.js +121 -0
  88. package/dist/ui/turnScope.js +11 -0
  89. package/dist/util/slash.js +18 -0
  90. package/package.json +1 -1
@@ -0,0 +1,121 @@
1
+ // Where a turn's time went (TUI plan #6). An interrupted turn used to end on "⎋ interrupted — output above kept" with
2
+ // its numbers thrown away, and a 33-minute turn closed on one line with nothing about whether the half hour went to
3
+ // reading, generating, tools or a loop. Every part is measured: reading from each round's last prompt_progress time_ms
4
+ // (the summed onCacheStats promptMs is sparse — llama.cpp omits timings on many tool rounds), tools from onToolBatch's
5
+ // duration, generating in the shell from a round's first chunk to its end; "other" is the named remainder, so the parts
6
+ // always sum to the wall time. Pure: cli.tsx feeds it from the handlers it already has.
7
+ import { fitSegments, seg } from "./fit.js";
8
+ import { cellWidth } from "./StatusRule.js";
9
+ import { fmtElapsed, fmtTok } from "./format.js";
10
+ /** A read of this many fresh tokens with nothing cached counts as a cold read (the cacheBustNotice rule). */
11
+ export const COLD_READ_MIN = 8000;
12
+ export function createLedger() {
13
+ return { readMs: 0, genMs: 0, toolMs: 0, waitMs: 0, compactMs: 0, fresh: 0, cached: 0, coldReads: 0, coldTokens: 0, wrote: false, roundRead: false };
14
+ }
15
+ /** A round's read finished (its first token, or the end of a round that streamed nothing): count it once. `cache` is
16
+ * NaN when the server reported no cache numbers at all — never counted as a cold read (unknown is not zero). */
17
+ export function noteRead(l, r) {
18
+ if (l.roundRead)
19
+ return;
20
+ l.roundRead = true;
21
+ l.readMs += Math.max(0, r.ms);
22
+ l.fresh += r.fresh;
23
+ l.cached += Number.isFinite(r.cache) ? r.cache : 0;
24
+ if (r.cache === 0 && r.fresh >= COLD_READ_MIN) {
25
+ l.coldReads += 1;
26
+ l.coldTokens += r.fresh;
27
+ }
28
+ }
29
+ export function noteGenStart(l, now, content) {
30
+ if (content)
31
+ l.wrote = true;
32
+ if (l.genStart === undefined)
33
+ l.genStart = now;
34
+ }
35
+ /** The round's stream ended (tools start, the batch settles, or the turn ends). */
36
+ export function noteGenEnd(l, now) {
37
+ if (l.genStart !== undefined) {
38
+ l.genMs += Math.max(0, now - l.genStart);
39
+ l.genStart = undefined;
40
+ }
41
+ }
42
+ /** A new round: its read has not been counted yet. */
43
+ export function noteRound(l) {
44
+ l.roundRead = false;
45
+ }
46
+ export function noteTools(l, ms) {
47
+ l.toolMs += Math.max(0, ms);
48
+ }
49
+ export function noteWait(l, ms) {
50
+ l.waitMs += Math.max(0, ms);
51
+ }
52
+ export function noteCompaction(l, ms) {
53
+ l.compactMs += Math.max(0, ms);
54
+ }
55
+ /** The parts, summing exactly to `wallMs`: when the measured parts overrun the wall (clocks from two machines), the
56
+ * shell-measured generating time gives way first; "other" is never negative. */
57
+ export function ledgerParts(l, wallMs) {
58
+ let left = wallMs;
59
+ const take = (ms) => { const v = Math.max(0, Math.min(ms, left)); left -= v; return v; };
60
+ const readMs = take(l.readMs), toolMs = take(l.toolMs), compactMs = take(l.compactMs), waitMs = take(l.waitMs), genMs = take(l.genMs);
61
+ return { readMs, genMs, toolMs, waitMs, compactMs, otherMs: left };
62
+ }
63
+ function readNote(l) {
64
+ if (l.coldReads)
65
+ return `${l.coldReads} cold read${l.coldReads === 1 ? "" : "s"}: ${fmtTok(l.coldTokens)}`;
66
+ return l.cached > 0 ? `${fmtTok(l.fresh)} new, ${fmtTok(l.cached)} reused` : `${fmtTok(l.fresh)} new, nothing cached`;
67
+ }
68
+ const SPLIT_COLS = 60;
69
+ /** The card's "time" rows: parts largest first (anything under a second left out), the parentheticals drop below 100
70
+ * cols, and below 60 cols the ledger splits over two lines. `inner` is the width inside the card's border. */
71
+ export function ledgerLines(p, l, inner) {
72
+ const parts = [];
73
+ const gen = l.wrote ? "generating" : "thinking";
74
+ if (p.genMs >= 1000)
75
+ parts.push([p.genMs, seg(`${gen} ${fmtElapsed(p.genMs)}`)]);
76
+ if (p.readMs >= 1000)
77
+ parts.push([p.readMs, seg(inner >= 100 && (l.fresh || l.coldReads) ? [`reading ${fmtElapsed(p.readMs)} (${readNote(l)})`, `reading ${fmtElapsed(p.readMs)}`] : `reading ${fmtElapsed(p.readMs)}`, 2, true)]);
78
+ if (p.toolMs >= 1000)
79
+ parts.push([p.toolMs, seg(`tools ${fmtElapsed(p.toolMs)}`)]);
80
+ if (p.compactMs >= 1000)
81
+ parts.push([p.compactMs, seg(`compacting ${fmtElapsed(p.compactMs)}`)]);
82
+ if (p.waitMs >= 1000)
83
+ parts.push([p.waitMs, seg(`waiting ${fmtElapsed(p.waitMs)}`)]);
84
+ if (p.otherMs >= 1000)
85
+ parts.push([p.otherMs, seg(`other ${fmtElapsed(p.otherMs)}`)]);
86
+ const segs = parts.sort((a, b) => b[0] - a[0]).map(([, s]) => s);
87
+ if (!segs.length)
88
+ return [];
89
+ if (inner < SPLIT_COLS && segs.length > 2) {
90
+ return [fitSegments(segs.slice(0, 2), inner, { lead: "time " }), fitSegments(segs.slice(2), inner, { lead: " " })];
91
+ }
92
+ return [fitSegments(segs, inner, { lead: "time " })];
93
+ }
94
+ /** The interrupted receipt: when, where the time went (the read in flight included), and that the output stayed.
95
+ * Narrowing is two-phase: every parenthetical goes first, then the smallest parts; the floor is
96
+ * "interrupted at 7m 43s · output above kept". */
97
+ export function interruptedLine(wallMs, p, l, tokens, cols) {
98
+ const gen = l.wrote ? "generating" : "thinking";
99
+ const parts = [];
100
+ if (p.readMs >= 1000)
101
+ parts.push({ ms: p.readMs, full: l.fresh ? `reading ${fmtElapsed(p.readMs)} (${readNote({ ...l, coldReads: 0, coldTokens: 0 })})` : `reading ${fmtElapsed(p.readMs)}`, short: `reading ${fmtElapsed(p.readMs)}` });
102
+ if (p.genMs >= 1000)
103
+ parts.push({ ms: p.genMs, full: tokens ? `${gen} ${fmtElapsed(p.genMs)} (${fmtTok(tokens)} tok)` : `${gen} ${fmtElapsed(p.genMs)}`, short: `${gen} ${fmtElapsed(p.genMs)}` });
104
+ if (p.toolMs >= 1000)
105
+ parts.push({ ms: p.toolMs, full: `tools ${fmtElapsed(p.toolMs)}`, short: `tools ${fmtElapsed(p.toolMs)}` });
106
+ if (p.compactMs >= 1000)
107
+ parts.push({ ms: p.compactMs, full: `compacting ${fmtElapsed(p.compactMs)}`, short: `compacting ${fmtElapsed(p.compactMs)}` });
108
+ if (p.waitMs >= 1000)
109
+ parts.push({ ms: p.waitMs, full: `waiting ${fmtElapsed(p.waitMs)}`, short: `waiting ${fmtElapsed(p.waitMs)}` });
110
+ parts.sort((a, b) => b.ms - a.ms);
111
+ const head = seg(`interrupted at ${fmtElapsed(wallMs)}`);
112
+ const tail = seg("output above kept");
113
+ const full = `⎋ ${[head.forms[0], ...parts.map((x) => x.full), tail.forms[0]].join(" · ")}`;
114
+ if (cellWidth(full) <= cols - 1)
115
+ return full;
116
+ return fitSegments([head, ...parts.map((x, i) => seg(x.short, 10 + i)), tail], cols, { lead: "⎋ " });
117
+ }
118
+ /** The 'repetition' stop's line: how much the last round streamed, and for how long, before the check cut it. */
119
+ export function repetitionLine(chars, ms, inner) {
120
+ return fitSegments([seg(`the last round streamed ${fmtTok(chars)} chars over ${fmtElapsed(ms)}`), seg("before the repetition check stopped it", 2)], inner, { sep: " " });
121
+ }
@@ -0,0 +1,11 @@
1
+ // A turn's handlers stop at its end (review F14). esc ends the turn at once, but the tool in flight keeps running and the
2
+ // engine still reports its batch when it returns — seconds later, into an idle TUI (left stuck in "thinking") or into
3
+ // the next turn, whose live rows, read ring, ledger and fold it would reset. Each turn's handlers carry its id.
4
+ /** `handlers` with every function made a no-op (returning undefined) unless `current()` is still `turn`. */
5
+ export function turnScoped(handlers, turn, current) {
6
+ const out = {};
7
+ for (const [k, v] of Object.entries(handlers)) {
8
+ out[k] = typeof v === "function" ? (...a) => (current() === turn ? v(...a) : undefined) : v;
9
+ }
10
+ return out;
11
+ }
@@ -8,6 +8,7 @@ const KNOWN = new Set([
8
8
  "artifacts", "sessions", "skills", "skill", "allow", "caffeinate", "caffeine", "deep-research", "deepresearch",
9
9
  "research", "pair",
10
10
  ]);
11
+ export const KNOWN_COMMANDS = KNOWN;
11
12
  export function isSlashCommand(text) {
12
13
  const t = text.trim();
13
14
  if (!t.startsWith("/") || t.includes("\n"))
@@ -15,3 +16,20 @@ export function isSlashCommand(text) {
15
16
  const cmd = t.slice(1).split(/\s+/)[0];
16
17
  return KNOWN.has(cmd);
17
18
  }
19
+ /** When a command typed mid-turn applies (TUI A3.2). "now": read-only or self-contained — it runs at once and the turn
20
+ * keeps going. "next": a setting the engine reads per request or per tool call — it applies at once, from the turn's
21
+ * next step. "after": it would swap the model, the conversation, the tool surface or the session under a running turn
22
+ * — it is staged and runs on its own when the turn ends. Every KNOWN command has a class; a new command must pick one. */
23
+ export const MIDTURN = {
24
+ help: "now", agents: "now", jobs: "now", stats: "now", endpoints: "now", audit: "now", memory: "now", skills: "now",
25
+ skill: "now", whoami: "now", monitor: "now", remember: "now", caffeinate: "now", caffeine: "now", bg: "now", dashboard: "now",
26
+ think: "next", ultrathink: "next", context: "next", ctx: "next", mode: "next", plan: "next", allow: "next",
27
+ model: "after", new: "after", compact: "after", clear: "after", route: "after", mcp: "after", login: "after", logout: "after",
28
+ remote: "after", remotecontrol: "after", rc: "after", pair: "after", sessions: "after", artifacts: "after", services: "after",
29
+ "deep-research": "after", deepresearch: "after", research: "after", exit: "after", quit: "after",
30
+ };
31
+ /** The mid-turn class of a slash command line (its first token); "after" for anything unclassified — the safe side. */
32
+ export function midTurnClass(text) {
33
+ const cmd = text.trim().slice(1).split(/\s+/)[0] ?? "";
34
+ return MIDTURN[cmd] ?? "after";
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.352",
3
+ "version": "0.1.353",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "operator": "dist/cli.js",