@0perator/operator 0.1.50 → 0.1.52
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/CHANGELOG.md +38 -0
- package/dist/cli.js +89 -1
- package/dist/mcp/index.js +13 -0
- package/dist/remote/host.js +72 -1
- package/dist/session.js +5 -0
- package/dist/update.js +19 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,44 @@ Operator is AXE's terminal coding agent (npm `@0perator/operator`), running on t
|
|
|
4
4
|
Newest first. Every release bumps `src/cli.tsx` VERSION + `package.json`, adds an entry here, and ships to
|
|
5
5
|
npm + both git remotes (memjar/kode, axetechnologies/kode). Test counts are the full suite at that release.
|
|
6
6
|
|
|
7
|
+
## 0.1.52 — 2026-09-21
|
|
8
|
+
- Fixed: `operator update` on a source checkout failed cryptically ("git pull failed") when the tree was
|
|
9
|
+
dirty — common on a shared dev tree an agent is building in. It now detects the dirty tree, names the
|
|
10
|
+
uncommitted files, and points at `npm install -g @0perator/operator@latest` to update the INSTALLED
|
|
11
|
+
Operator instead, rather than a confusing hard-fail. Never auto-stashes (would clobber in-flight work).
|
|
12
|
+
- SPEC: deduped remote-session.md — capabilities + command frames now live only in the canonical
|
|
13
|
+
§5/§5a/§6/§6a; documented the ask_user / ask_user_response frames (pre-existing gap); recorded the
|
|
14
|
+
follower command policy (all-except exit/quit/login/logout/remotecontrol/remote; bg/services/dashboard
|
|
15
|
+
intentionally exposed per owner sign-off) + the capabilities summarization. (Nova, spec-rich-head-dedupe.)
|
|
16
|
+
|
|
17
|
+
## 0.1.51 — 2026-09-21
|
|
18
|
+
- Landed: **remote-control "rich head"** host side (SPEC/remote-session.md §11, PROPOSED — not part of
|
|
19
|
+
the v1 FROZEN envelope) — `RemoteHost` gains `RemoteCapabilities` (commands/skills/mcpServers/models/
|
|
20
|
+
mode/cwd/model) sent in the `snapshot` and re-sent as a `capabilities` state frame only when it
|
|
21
|
+
changes, plus a `command` drive frame (follower → host, `{name, args?}`) dispatched through the SAME
|
|
22
|
+
path a local `/name args` line takes. Client side (web command drawer, kode-mobile CommandSurface,
|
|
23
|
+
SPEC addendum) shipped separately in 0.1.50; this lands the host emit + dispatch handler.
|
|
24
|
+
- Owner decision: a follower may drive **every slash command except** `exit`/`quit` (kills the host
|
|
25
|
+
process), `login`/`logout` (mutates stored credentials), and `remotecontrol`/`remote` (a follower
|
|
26
|
+
could disconnect every other follower) — six hard-excluded case-labels. `bg`, `services`, and
|
|
27
|
+
`dashboard` are explicitly INCLUDED: `isOwnFrame()` (sessionId + ownerSub match) plus OPERATOR-token
|
|
28
|
+
relay auth means a follower is the authenticated owner on another device, not a third party.
|
|
29
|
+
`REMOTE_SAFE_COMMANDS` (`cli.tsx`) is the single allowlist for both what's advertised in
|
|
30
|
+
`capabilities.commands` and what `onCommand` will actually dispatch.
|
|
31
|
+
- Fixed (blocker, found in adversarial self-review — see `REMOTE_RICH_HEAD_AUDIT.md`): a
|
|
32
|
+
`capabilities.mcpServers` full tool enumeration at this fleet's real scale (600+ MCP tools across a
|
|
33
|
+
handful of servers) could exceed the SPEC §8 256 KB per-frame cap. `capCapabilities()` now sends each
|
|
34
|
+
server's name + true `toolCount` with `tools[]` capped to a 20-entry preview. Paired with the
|
|
35
|
+
pre-existing, previously-unenforced SPEC §8 snapshot cap: `capTranscript()` trims the snapshot to the
|
|
36
|
+
last 200 entries, then shrinks oldest-first until under 512 KB, marking `truncated: true` +
|
|
37
|
+
`omittedBefore: <seq>` when either bound bites.
|
|
38
|
+
- Tests: +15 vs 0.1.50 (10 from the host-side reference patch itself — `command` own/wrong-session/
|
|
39
|
+
mismatched-ownerSub/missing-name, capabilities in snapshot before/after connect, delta on change,
|
|
40
|
+
no-op on identical re-set; +5 from the blocker fix above — 600+ tool capabilities payload stays under
|
|
41
|
+
the 256 KB frame cap, toolCount survives the trim, small server lists pass through untrimmed,
|
|
42
|
+
200-entry snapshot truncation + `omittedBefore`, no false-positive truncation on a short transcript).
|
|
43
|
+
Suite 347/347; `tsc --noEmit` clean.
|
|
44
|
+
|
|
7
45
|
## 0.1.48 — 2026-09-21
|
|
8
46
|
- Added: `/model` command — pick between `aurora-1m` (default, :8097), `aurora-128k` (:8096, lighter
|
|
9
47
|
RAM), or `moa` (Mixture of Agents) via an interactive picker (`/model`) or directly (`/model <id>`).
|
package/dist/cli.js
CHANGED
|
@@ -22,7 +22,7 @@ import { homedir, hostname } from "node:os";
|
|
|
22
22
|
import { createHash } from "node:crypto";
|
|
23
23
|
// RELEASE CHECKLIST (every bump): update this + package.json "version", ADD A CHANGELOG.md ENTRY
|
|
24
24
|
// (improvements / fixes / tests), run the suite, then publish to npm + push both remotes.
|
|
25
|
-
const VERSION = "0.1.
|
|
25
|
+
const VERSION = "0.1.52";
|
|
26
26
|
// operator/settings.json (override path via KODE_TSI_SETTINGS), env vars still win — see config/settings.ts.
|
|
27
27
|
const settings = loadSettings();
|
|
28
28
|
// Propagate the resolved sandbox mode to the tool layer (registry reads KODE_SANDBOX at exec time).
|
|
@@ -241,6 +241,36 @@ const HELP = [
|
|
|
241
241
|
" /exit /quit leave operator",
|
|
242
242
|
"esc — interrupt a running turn (or quit when idle)",
|
|
243
243
|
].join("\n");
|
|
244
|
+
// Slash commands a remote-control FOLLOWER is allowed to drive (RemoteHost `command` frame →
|
|
245
|
+
// SPEC/remote-session.md extension; see REMOTE_RICH_HEAD_AUDIT.md). This is BOTH the allowlist enforced
|
|
246
|
+
// in the "remotecontrol" case's onCommand below AND what's advertised in RemoteCapabilities.commands —
|
|
247
|
+
// one list, so a follower's command palette never offers something the host will actually refuse.
|
|
248
|
+
// Deliberately excludes: exit/quit (kills the host process), login/logout (mutates the owner's stored
|
|
249
|
+
// AXE credentials), and remotecontrol/remote (a follower must never be able to kick every other
|
|
250
|
+
// follower off the session it's attached to). Those four are the only slash commands that act OUTSIDE
|
|
251
|
+
// the tool/permission system (direct switch-case side effects, ungated whether local or remote) —
|
|
252
|
+
// everything below still runs with the same local privilege a `prompt` frame already has today.
|
|
253
|
+
const REMOTE_SAFE_COMMANDS = [
|
|
254
|
+
{ name: "help", description: "list available commands" },
|
|
255
|
+
{ name: "model", description: "pick a model: aurora-1m · aurora-128k · moa (mixture-of-agents)", args: "[id]" },
|
|
256
|
+
{ name: "route", description: "pin routing to an endpoint, or auto (by size)", args: "[endpoint|auto]" },
|
|
257
|
+
{ name: "endpoints", description: "show the aurora endpoint + live health" },
|
|
258
|
+
{ name: "services", description: "ensure/inspect the service lever (aurora+autopilot+searxng); stop searxng", args: "[stop]" },
|
|
259
|
+
{ name: "audit", description: "recent tool + control-plane events from the audit trail", args: "[n]" },
|
|
260
|
+
{ name: "dashboard", description: "launch the live swarm console" },
|
|
261
|
+
{ name: "plan", description: "toggle plan mode (read-only research + propose a plan)" },
|
|
262
|
+
{ name: "think", description: "toggle extended reasoning" },
|
|
263
|
+
{ name: "ultrathink", description: "toggle deep, exhaustive reasoning" },
|
|
264
|
+
{ name: "compact", description: "force-compact the conversation now" },
|
|
265
|
+
{ name: "remember", description: "store a note to recall in future sessions", args: "<note>" },
|
|
266
|
+
{ name: "memory", description: "show remembered notes", args: "[query]" },
|
|
267
|
+
{ name: "mcp", description: "count of fleet MCP tools this session" },
|
|
268
|
+
{ name: "whoami", description: "show signed-in identity" },
|
|
269
|
+
{ name: "bg", description: "spawn a background sub-agent, list, or stop one", args: "<task|stop id>" },
|
|
270
|
+
{ name: "new", description: "start a fresh conversation" },
|
|
271
|
+
{ name: "clear", description: "clear the screen (keeps the conversation)" },
|
|
272
|
+
];
|
|
273
|
+
const REMOTE_SAFE_COMMAND_NAMES = new Set(REMOTE_SAFE_COMMANDS.map((c) => c.name));
|
|
244
274
|
let ID = 0;
|
|
245
275
|
const nextId = () => `e${++ID}`;
|
|
246
276
|
const firstLine = (s) => (s.split("\n")[0] ?? "").slice(0, 100);
|
|
@@ -388,6 +418,31 @@ function Root() {
|
|
|
388
418
|
const setStat = (s) => { statusRef.current = s; setStatus(s); remoteRef.current?.setActivity(s); };
|
|
389
419
|
const push = (e) => setEntries((prev) => [...prev, e]);
|
|
390
420
|
const submitRef = useRef(() => { });
|
|
421
|
+
// AXE skills fetched/saved THIS session (name -> a best-effort description) — there's no persistent
|
|
422
|
+
// skill-loader/registry in this codebase to read from (skills are hub-fetched on demand by the
|
|
423
|
+
// skill_fetch/skill_save tools, see tools/registry.ts), so this is the closest real signal for
|
|
424
|
+
// RemoteCapabilities.skills: "what has this session actually pulled in," tracked from onToolBatch
|
|
425
|
+
// below. Session-scoped by design — a fresh session starts with an empty list, matching /model's own
|
|
426
|
+
// lack of persistence across sessions.
|
|
427
|
+
const skillsRef = useRef(new Map());
|
|
428
|
+
// Assembles RemoteCapabilities from the real registries at call time — commands (the remote-safe
|
|
429
|
+
// allowlist above), skills (skillsRef), MCP servers (session.mcpServers() — empty until first-turn
|
|
430
|
+
// discovery has run, see session.ts maybeRecall), models (session.modelRegistry()), permission mode,
|
|
431
|
+
// cwd, and the active model. Cheap to call liberally: RemoteHost.setCapabilities() only touches the
|
|
432
|
+
// wire when the result actually differs from what's already been sent.
|
|
433
|
+
// mcpServers reports the REAL per-server tool count here (toolCount) alongside the full tools[] —
|
|
434
|
+
// RemoteHost.setCapabilities() is what trims tools[] to a wire-safe preview (REMOTE_RICH_HEAD_AUDIT.md
|
|
435
|
+
// §4 BLOCKER: this fleet's own MCP surface is 600+ tools, comfortably over the SPEC §8 256 KB frame
|
|
436
|
+
// cap if enumerated in full); building it honestly here means toolCount survives that trim intact.
|
|
437
|
+
const buildCapabilities = () => ({
|
|
438
|
+
commands: REMOTE_SAFE_COMMANDS,
|
|
439
|
+
skills: [...skillsRef.current.entries()].map(([name, description]) => ({ name, description })),
|
|
440
|
+
mcpServers: session.mcpServers().map((s) => ({ name: s.name, toolCount: s.tools.length, tools: s.tools })),
|
|
441
|
+
models: session.modelRegistry().map((m) => ({ id: m.id, label: m.label, ctx: m.ctx ?? 0, kind: m.kind })),
|
|
442
|
+
mode: settings.permissions.mode === "gated" ? "gated" : "auto", // "bypass"/"audit" both drive with no approval gate from a follower's POV
|
|
443
|
+
cwd: process.cwd(),
|
|
444
|
+
model: session.currentModel(),
|
|
445
|
+
});
|
|
391
446
|
// Backstop the slash-/ESC-quit paths: an ordinary terminal close or `kill` must still tear down any
|
|
392
447
|
// spawned stdio MCP subprocesses (session.shutdown), or they orphan. exit runs sync; SIGTERM exits after.
|
|
393
448
|
useEffect(() => {
|
|
@@ -517,6 +572,21 @@ function Root() {
|
|
|
517
572
|
};
|
|
518
573
|
push({ kind: "tool", step });
|
|
519
574
|
remoteRef.current?.toolStep(step);
|
|
575
|
+
// Track skills this session has actually pulled in, for RemoteCapabilities.skills (see
|
|
576
|
+
// skillsRef above) — the description is synthetic (this codebase has no skill metadata to
|
|
577
|
+
// read a real one from), not sourced from the fetched skillmd content.
|
|
578
|
+
if (!isErrorResult(ev.result)) {
|
|
579
|
+
if (ev.name === "skill_fetch") {
|
|
580
|
+
const slug = String(ev.args?.slug ?? "").trim();
|
|
581
|
+
if (slug)
|
|
582
|
+
skillsRef.current.set(slug, "loaded this session via skill_fetch");
|
|
583
|
+
}
|
|
584
|
+
else if (ev.name === "skill_save") {
|
|
585
|
+
const nm = String(ev.args?.name ?? "").trim();
|
|
586
|
+
if (nm)
|
|
587
|
+
skillsRef.current.set(nm, "saved to profile this session via skill_save");
|
|
588
|
+
}
|
|
589
|
+
}
|
|
520
590
|
}
|
|
521
591
|
liveText.current = "";
|
|
522
592
|
liveReasoning.current = "";
|
|
@@ -572,6 +642,9 @@ function Root() {
|
|
|
572
642
|
writeFileSync(SESSION_FILE, JSON.stringify(session.snapshot()));
|
|
573
643
|
}
|
|
574
644
|
catch { /* auto-save is best-effort */ }
|
|
645
|
+
// Re-check capabilities after every turn: MCP discovery (first-turn only) may have just landed,
|
|
646
|
+
// and any skill_fetch/skill_save this turn updated skillsRef above. A no-op diff never hits the wire.
|
|
647
|
+
remoteRef.current?.setCapabilities(buildCapabilities());
|
|
575
648
|
const q = queued.current;
|
|
576
649
|
queued.current = "";
|
|
577
650
|
if (q)
|
|
@@ -619,6 +692,7 @@ function Root() {
|
|
|
619
692
|
setRoute(s.currentModel());
|
|
620
693
|
saveSettings({ activeModel: s.currentModel() });
|
|
621
694
|
sys(`model → ${s.currentModel()} · ctx ${s.ctxPct()}% · turns ${s.turnCount()}`);
|
|
695
|
+
remoteRef.current?.setCapabilities(buildCapabilities()); // active model changed — re-sync attached followers
|
|
622
696
|
};
|
|
623
697
|
if (arg) {
|
|
624
698
|
apply(arg);
|
|
@@ -838,6 +912,19 @@ function Root() {
|
|
|
838
912
|
onApprovalResponse: (id, approve) => settleApproval(id, approve), // first-wins with local
|
|
839
913
|
onAskUserResponse: (id, answer) => settleQuestion(id, answer), // first-wins with local
|
|
840
914
|
onInterrupt: () => s.interrupt(), // follower cancels the turn
|
|
915
|
+
// A follower drove a slash command. Reuse the EXACT same path a local `/name args` line
|
|
916
|
+
// takes (submitRef → onSubmit → handleSlash) — never a second implementation of the
|
|
917
|
+
// switch — but only for names on the remote-safe allowlist; anything else is refused
|
|
918
|
+
// locally-visibly (sys + an audit event) rather than silently dropped or silently run.
|
|
919
|
+
onCommand: (name, args) => {
|
|
920
|
+
if (!REMOTE_SAFE_COMMAND_NAMES.has(name)) {
|
|
921
|
+
sys(`remote control: blocked "/${name}" from a follower — not exposed for remote dispatch`);
|
|
922
|
+
eventSink.emit({ kind: "control", session: SESSION_ID, actor: EVENT_ACTOR, control: { event: "rc_command_blocked", detail: name } });
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
eventSink.emit({ kind: "control", session: SESSION_ID, actor: EVENT_ACTOR, control: { event: "rc_command", detail: args ? `${name} ${args}` : name } });
|
|
926
|
+
submitRef.current(`/${name}${args ? " " + args : ""}`);
|
|
927
|
+
},
|
|
841
928
|
onState: (st, detail) => {
|
|
842
929
|
if (st === "live")
|
|
843
930
|
sys(`✷ remote control LIVE — session ${rh.id}\n Continue on your phone or at https://0perator.co/session/${rh.id}\n /remotecontrol again to stop.`);
|
|
@@ -853,6 +940,7 @@ function Root() {
|
|
|
853
940
|
},
|
|
854
941
|
});
|
|
855
942
|
remoteRef.current = rh;
|
|
943
|
+
rh.setCapabilities(buildCapabilities()); // cached now, so the very first attach's snapshot already carries it
|
|
856
944
|
rh.connect();
|
|
857
945
|
sys(`connecting remote control → ${url} …`);
|
|
858
946
|
break;
|
package/dist/mcp/index.js
CHANGED
|
@@ -86,6 +86,19 @@ export class McpHub {
|
|
|
86
86
|
toolCount() {
|
|
87
87
|
return this.tools.size;
|
|
88
88
|
}
|
|
89
|
+
/** Per-server tool inventory (unnamespaced names) — for capability advertising (e.g. the
|
|
90
|
+
* remote-control snapshot's `capabilities.mcpServers`), not for dispatch. Empty until discover()
|
|
91
|
+
* has run (or if it hasn't found anything yet). Server order follows first-discovered-tool order;
|
|
92
|
+
* not sorted, since callers so far only render or diff it, never rely on a stable ordering. */
|
|
93
|
+
serversWithTools() {
|
|
94
|
+
const bySrv = new Map();
|
|
95
|
+
for (const t of this.tools.values()) {
|
|
96
|
+
const list = bySrv.get(t.server) ?? [];
|
|
97
|
+
list.push({ name: t.def.name, description: t.def.description });
|
|
98
|
+
bySrv.set(t.server, list);
|
|
99
|
+
}
|
|
100
|
+
return [...bySrv.entries()].map(([name, tools]) => ({ name, tools }));
|
|
101
|
+
}
|
|
89
102
|
}
|
|
90
103
|
/** Compose the local executor with the MCP hub: local tools win, a namespaced name routes to MCP.
|
|
91
104
|
* With no hub (or an inert one) this is the local executor plus empty schemas — zero behavior change. */
|
package/dist/remote/host.js
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
const V = 1;
|
|
2
|
+
// SPEC §8 limits (relay-enforced per spec, but host.ts didn't honor either one — REMOTE_RICH_HEAD_AUDIT.md
|
|
3
|
+
// §1/§4 BLOCKER: this repo's own MCP surface is 600+ tools across a handful of servers, which put
|
|
4
|
+
// `capabilities.mcpServers` alone at 70-100+ KB before this fix, on top of an already-uncapped transcript.
|
|
5
|
+
// Enforced host-side as defense-in-depth (the relay may also cap/drop/error an oversized frame, but a
|
|
6
|
+
// follower deserves a `truncated` signal rather than a silently broken snapshot).
|
|
7
|
+
const SNAPSHOT_MAX_ENTRIES = 200; // SPEC §8: last 200 message-entries + their tool steps, whichever binds first
|
|
8
|
+
const SNAPSHOT_MAX_BYTES = 512 * 1024; // SPEC §8 snapshot cap
|
|
9
|
+
const MCP_TOOL_PREVIEW = 20; // per-server tool NAMES kept when a server's inventory is large — see capCapabilities
|
|
10
|
+
const byteLen = (v) => Buffer.byteLength(JSON.stringify(v), "utf8");
|
|
11
|
+
// BLOCKER fix (REMOTE_RICH_HEAD_AUDIT.md §4, "summarize, don't enumerate"): a server's `tools[]` is
|
|
12
|
+
// prefixed to MCP_TOOL_PREVIEW entries — `toolCount` still carries the real total, so a follower's UI
|
|
13
|
+
// can render "webhook (37 tools)" instead of either silently truncating names with no signal or paying
|
|
14
|
+
// ~150 bytes/tool for a 600+ tool fleet surface on every snapshot/capabilities delta. Called once from
|
|
15
|
+
// setCapabilities() (not per-send) so the stored `this.capabilities` used for change-detection and every
|
|
16
|
+
// later sendSnapshot() is already the capped shape.
|
|
17
|
+
function capCapabilities(caps) {
|
|
18
|
+
return {
|
|
19
|
+
...caps,
|
|
20
|
+
mcpServers: caps.mcpServers.map((s) => ({
|
|
21
|
+
name: s.name,
|
|
22
|
+
toolCount: s.tools.length,
|
|
23
|
+
tools: s.tools.length > MCP_TOOL_PREVIEW ? s.tools.slice(0, MCP_TOOL_PREVIEW) : s.tools,
|
|
24
|
+
})),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
2
27
|
export class RemoteHost {
|
|
3
28
|
url;
|
|
4
29
|
token;
|
|
@@ -18,6 +43,7 @@ export class RemoteHost {
|
|
|
18
43
|
liveTimer = null;
|
|
19
44
|
livePending = null;
|
|
20
45
|
turnN = 0;
|
|
46
|
+
capabilities = null;
|
|
21
47
|
constructor(url, token, meta, cb) {
|
|
22
48
|
this.url = url;
|
|
23
49
|
this.token = token;
|
|
@@ -97,6 +123,15 @@ export class RemoteHost {
|
|
|
97
123
|
if (this.isOwnFrame(f))
|
|
98
124
|
this.cb.onInterrupt();
|
|
99
125
|
break;
|
|
126
|
+
// A follower driving a slash command (e.g. /model, /new) through the SAME router a local owner
|
|
127
|
+
// types into. Same guard as every other drive frame; the SHELL is additionally responsible for
|
|
128
|
+
// allowlisting which command names it will actually dispatch (this class has no opinion on
|
|
129
|
+
// that — it just forwards a well-formed request through). `args` is the raw trailing string,
|
|
130
|
+
// exactly as typed after the command name locally.
|
|
131
|
+
case "command":
|
|
132
|
+
if (this.isOwnFrame(f) && typeof f.payload?.name === "string" && f.payload.name)
|
|
133
|
+
this.cb.onCommand(String(f.payload.name), typeof f.payload?.args === "string" ? f.payload.args : undefined);
|
|
134
|
+
break;
|
|
100
135
|
case "error":
|
|
101
136
|
this.cb.onState?.("error", f.payload?.message ?? f.payload?.code);
|
|
102
137
|
break;
|
|
@@ -125,7 +160,43 @@ export class RemoteHost {
|
|
|
125
160
|
state(type, payload) { this.send(type, this.sessionId, payload, ++this.seq); }
|
|
126
161
|
sendSnapshot() {
|
|
127
162
|
this.flushLive();
|
|
128
|
-
|
|
163
|
+
const { transcript, truncated, omittedBefore } = this.capTranscript(this.entries);
|
|
164
|
+
this.send("snapshot", this.sessionId, {
|
|
165
|
+
transcript, activity: this.activity, status: { ctxPct: this.ctxPct, route: this.route },
|
|
166
|
+
...(truncated ? { truncated: true, omittedBefore } : {}),
|
|
167
|
+
...(this.capabilities ? { capabilities: this.capabilities } : {}), // absent until the shell's first setCapabilities() call; already capped by capCapabilities() in setCapabilities()
|
|
168
|
+
}, this.seq);
|
|
169
|
+
}
|
|
170
|
+
/** SPEC §8 snapshot cap: last 200 message/tool entries, then shrink further (oldest-first) until the
|
|
171
|
+
* serialized transcript fits 512 KB — `capabilities` gets its own budget (capCapabilities), so this
|
|
172
|
+
* only accounts for the transcript half. `omittedBefore` is this host's CURRENT seq at truncation
|
|
173
|
+
* time (entries carry no seq of their own): enough for a follower to know only scrollback before
|
|
174
|
+
* "now" was cut, not that live driving is affected. Cheap to call on every attach — at most O(200)
|
|
175
|
+
* serializations of a shrinking slice, and attach is not a hot path. */
|
|
176
|
+
capTranscript(entries) {
|
|
177
|
+
let out = entries;
|
|
178
|
+
let truncated = false;
|
|
179
|
+
if (out.length > SNAPSHOT_MAX_ENTRIES) {
|
|
180
|
+
out = out.slice(-SNAPSHOT_MAX_ENTRIES);
|
|
181
|
+
truncated = true;
|
|
182
|
+
}
|
|
183
|
+
while (out.length > 1 && byteLen(out) > SNAPSHOT_MAX_BYTES) {
|
|
184
|
+
out = out.slice(1);
|
|
185
|
+
truncated = true;
|
|
186
|
+
}
|
|
187
|
+
return truncated ? { transcript: out, truncated, omittedBefore: this.seq } : { transcript: out, truncated };
|
|
188
|
+
}
|
|
189
|
+
/** Store the host's current capabilities and, if a session is already live and they actually
|
|
190
|
+
* changed, re-send them as a `capabilities` state frame so already-attached followers stay in
|
|
191
|
+
* sync (e.g. after a /model switch or a skill load — see RemoteCapabilities). Safe to call before
|
|
192
|
+
* "welcome"/connect(): the value is just cached for the next sendSnapshot(), nothing is sent. Safe
|
|
193
|
+
* to call on every turn: a no-op change never touches the wire (seq stays put). */
|
|
194
|
+
setCapabilities(caps) {
|
|
195
|
+
const capped = capCapabilities(caps);
|
|
196
|
+
const changed = JSON.stringify(capped) !== JSON.stringify(this.capabilities);
|
|
197
|
+
this.capabilities = capped;
|
|
198
|
+
if (changed && this.sessionId)
|
|
199
|
+
this.state("capabilities", capped);
|
|
129
200
|
}
|
|
130
201
|
// ── mirror upserts ────────────────────────────────────────────────────────
|
|
131
202
|
upsertMessage(id, role, content, reasoning) {
|
package/dist/session.js
CHANGED
|
@@ -340,6 +340,11 @@ export class Session {
|
|
|
340
340
|
mcpToolCount() {
|
|
341
341
|
return this.hub?.toolCount() ?? 0;
|
|
342
342
|
}
|
|
343
|
+
/** Per-server MCP tool inventory (0 servers until first turn / if MCP is off) — for capability
|
|
344
|
+
* advertising (RemoteHost.setCapabilities), not for dispatch. */
|
|
345
|
+
mcpServers() {
|
|
346
|
+
return this.hub?.serversWithTools() ?? [];
|
|
347
|
+
}
|
|
343
348
|
/** Tear down session resources (kills any spawned stdio MCP servers). Call on shell exit. */
|
|
344
349
|
shutdown() {
|
|
345
350
|
this.hub?.shutdown();
|
package/dist/update.js
CHANGED
|
@@ -34,9 +34,27 @@ export async function runUpdate() {
|
|
|
34
34
|
// kode-tsi lives in a subdir of the kode repo; build happens where package.json is.
|
|
35
35
|
const pkgDir = existsSync(join(repo, "kode-tsi", "package.json")) ? join(repo, "kode-tsi") : repo;
|
|
36
36
|
process.stderr.write(`operator update: source checkout at ${repo} — pulling + rebuilding\n`);
|
|
37
|
+
// A source checkout can be dirty — dev edits, or (common on a shared dev tree) an agent mid-build in
|
|
38
|
+
// it. `git pull --ff-only` would fail with a cryptic message; detect it first, name the files, and
|
|
39
|
+
// point at the npm path, instead of a confusing hard-fail. Never auto-stash: that could clobber an
|
|
40
|
+
// agent's in-flight work in the same tree.
|
|
41
|
+
let dirty = "";
|
|
42
|
+
try {
|
|
43
|
+
dirty = execSync(`git -C '${repo}' status --porcelain`, { encoding: "utf8" }).trim();
|
|
44
|
+
}
|
|
45
|
+
catch { /* treat as clean */ }
|
|
46
|
+
if (dirty) {
|
|
47
|
+
const files = dirty.split("\n").slice(0, 20).map((l) => " " + l).join("\n");
|
|
48
|
+
process.stderr.write(`operator update: this source checkout has uncommitted changes, so it can't fast-forward:\n${files}\n` +
|
|
49
|
+
(dirty.split("\n").length > 20 ? " …\n" : "") +
|
|
50
|
+
`Commit or stash them and re-run — or, if this tree is a shared dev build an agent is editing, ` +
|
|
51
|
+
`wait for that to finish. To update the INSTALLED Operator instead (leaving this dev tree alone), run:\n` +
|
|
52
|
+
` npm install -g ${PKG}@latest\n`);
|
|
53
|
+
return 1;
|
|
54
|
+
}
|
|
37
55
|
let code = run("git", ["-C", repo, "pull", "--ff-only"]);
|
|
38
56
|
if (code !== 0) {
|
|
39
|
-
process.stderr.write("operator update: `git pull` failed (
|
|
57
|
+
process.stderr.write("operator update: `git pull` failed (branch diverged from origin?) — check `git -C " + repo + " status`.\n");
|
|
40
58
|
return code;
|
|
41
59
|
}
|
|
42
60
|
code = run("npm", ["install", "--silent"], pkgDir);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0perator/operator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.52",
|
|
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": {
|