@0perator/operator 0.1.164 → 0.1.166
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 +37 -0
- package/dist/cli.js +3 -2
- package/dist/config/settings.js +27 -7
- package/dist/engine/grandmaster.js +3 -0
- package/dist/mcp/index.js +11 -2
- package/dist/selfimprove/index.js +20 -2
- package/dist/session.js +32 -8
- package/dist/tools/executor.js +2 -1
- package/dist/tools/result-cap.js +5 -2
- package/dist/tools/tool-output-spill.js +26 -0
- package/dist/util/slash.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,43 @@ Operator is AXE's terminal coding agent (npm `@0perator/operator`), running on A
|
|
|
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.166 — 2026-10-01 — Grandmaster wave: cache-stable prefix, flywheel anti-poison, lossless tool results, sub-agent economics
|
|
8
|
+
- **GW-04 — deterministic tool-schema prefix.** `McpHub.schemas()` now sorts by namespaced name so the
|
|
9
|
+
`[system+tools]` prefix is byte-identical across sessions/restarts — KV prefix-cache reuse is strictly
|
|
10
|
+
prefix-positional, so any reorder zeroed every downstream hit. Pairs with slot-save/restore reuse. (Audit also
|
|
11
|
+
confirmed the prefix is already stable *within* a session: MCP discovery is first-turn-only.) +3 parity tests.
|
|
12
|
+
- **GW-18 (client) — flywheel anti-poisoning.** `hasLeakedToolCall()` flags tool-call markup that leaked into
|
|
13
|
+
assistant text (the `--jinja`-off Qwen failure); the flywheel sink excludes those turns from the promotable
|
|
14
|
+
training corpus and tags every row `parse_fallback` — so Aurora can't be trained to emit tool markup as prose.
|
|
15
|
+
+14-fixture parser canary. (Server `--jinja` half is fleet-serving side.)
|
|
16
|
+
- **GW-10 — lossless tool-result eviction.** A >40K tool result no longer discards its middle forever: the FULL
|
|
17
|
+
output spills to `~/.axe/operator/tool-outputs/<id>.txt` and the model gets a pointer to re-read the omitted
|
|
18
|
+
middle via `file_read(offset/limit)`. `capToolResult` stays node-free (spill sink injected → web bundle safe);
|
|
19
|
+
wired for all local tools (the dominant token sink). Fewer tokens/turn → slower approach to the depth ceiling.
|
|
20
|
+
+4 tests.
|
|
21
|
+
- **GW-14 — sub-agent economics.** The `spawn_agent` description + sub-agent brief now state a RETURN CONTRACT
|
|
22
|
+
(report ~1-2k tokens, file:line pointers not pasted output — a bloated child report forces the parent to
|
|
23
|
+
compact), a SINGLE-WRITER rule, and effort-matching.
|
|
24
|
+
- **`/rc`** alias for `/remotecontrol`.
|
|
25
|
+
- Full suite: 790 passed, 0 failed (105 files). `tsc --noEmit` clean.
|
|
26
|
+
|
|
27
|
+
## 0.1.165 — 2026-10-01 — Robustness: deep-context swap-thrash guard + ESC-abort hardening
|
|
28
|
+
- **Swap-thrash guard (track · fix · prevent).** A long session could grow the live context past the box's RAM,
|
|
29
|
+
so model weights + KV cache spilled into swap and decode collapsed to ~0 tok/s (measured 2026-10-01: context
|
|
30
|
+
reached ~191K tokens on a 64GB box → 7.6GB swap → "88 tokens in 6 minutes"). The context *window* is a TOKEN
|
|
31
|
+
limit; the real cliff is a MEMORY limit the %-of-window compaction threshold can't see (it's the same % at any
|
|
32
|
+
RAM). Fix: `compactionCeilingTokens` now, when unset, applies a RAM-aware safe default —
|
|
33
|
+
`defaultCompactionCeiling(totalmem, window)` reserves ~28GB (≈model + OS/overhead) then ~3500 tok/GB of what's
|
|
34
|
+
left, clamped to [8000, 0.85·window] and deliberately BELOW the measured cliff — so proactive compaction fires
|
|
35
|
+
before swap on any box (64GB/300K → ~126K). An explicit `compaction.ceilingTokens` / `KODE_COMPACTION_CEILING_TOKENS`
|
|
36
|
+
still wins. The 0.1.164 token meter makes the trigger exact. `test/settings.test.mts` +8 regression tests lock
|
|
37
|
+
the ceiling below the cliff so this can't silently return.
|
|
38
|
+
- **ESC-abort hardening.** The main streaming abort path was already correct (verified by trace + a 6ms live
|
|
39
|
+
repro — no main-path bug); closed two narrower gaps: the compaction summarizer's `chat()` now carries the
|
|
40
|
+
abort signal (ESC during "compacting" tears it down), and `send()` arms the AbortController *before* first-turn
|
|
41
|
+
`maybeRecall`/MCP-discovery so ESC no longer no-ops in that window (`execute()` reuses the same controller).
|
|
42
|
+
- Full suite: 769 passed, 0 failed (104 files). `tsc --noEmit` clean.
|
|
43
|
+
|
|
7
44
|
## 0.1.164 — 2026-10-01 — Token meter (engine) + Switchboard messages inline in the transcript
|
|
8
45
|
- `src/engine/token-meter.ts` learns each endpoint's REAL chars-per-token online from the exact counts
|
|
9
46
|
the server already reports (`timings.prompt_n`, `usage.completion_tokens`): EMA (converges in ~10
|
package/dist/cli.js
CHANGED
|
@@ -461,7 +461,7 @@ function Root() {
|
|
|
461
461
|
maxTurnTokens: settings.maxTurnTokens, // opt-in per-turn cost ceiling (total tokens); undefined → no cap
|
|
462
462
|
maxRounds: settings.autonomy?.maxRounds, // soft per-turn round budget (default 40) — a real build isn't cut off at 10
|
|
463
463
|
compactionThreshold: compactionThreshold(settings), // settings.compaction.threshold / KODE_COMPACTION_THRESHOLD; undefined → 0.85
|
|
464
|
-
compactionCeilingTokens: compactionCeilingTokens(settings
|
|
464
|
+
compactionCeilingTokens: compactionCeilingTokens(settings, settings.endpoints.aurora.ctxWindow), // explicit setting/env wins; else a RAM-aware safe default caps context below the box's swap cliff (the "88 tok/6min" stall)
|
|
465
465
|
temperature: settings.temperature,
|
|
466
466
|
recall: settings.memory.recall,
|
|
467
467
|
models: settings.models, // /model registry overrides (router/models.ts has the built-in defaults)
|
|
@@ -1386,7 +1386,8 @@ function Root() {
|
|
|
1386
1386
|
}
|
|
1387
1387
|
break;
|
|
1388
1388
|
case "remotecontrol":
|
|
1389
|
-
case "remote":
|
|
1389
|
+
case "remote":
|
|
1390
|
+
case "rc": {
|
|
1390
1391
|
if (remoteRef.current) {
|
|
1391
1392
|
remoteRef.current.stop();
|
|
1392
1393
|
remoteRef.current = null;
|
package/dist/config/settings.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// default. Never throws — a missing or malformed file just falls back to defaults, same as an env
|
|
4
4
|
// var that was never set.
|
|
5
5
|
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
6
|
-
import { homedir } from "node:os";
|
|
6
|
+
import { homedir, totalmem } from "node:os";
|
|
7
7
|
import { join, dirname } from "node:path";
|
|
8
8
|
import { DEFAULT_MODEL_ID } from "../router/models.js";
|
|
9
9
|
// The sole endpoint: Aurora on :8097 at its REAL served context — 307,200 tokens (300K; the llama-server
|
|
@@ -161,14 +161,34 @@ export function compactionThreshold(s) {
|
|
|
161
161
|
const t = s.compaction?.threshold;
|
|
162
162
|
return typeof t === "number" && t >= 0.3 && t <= 0.95 ? t : undefined;
|
|
163
163
|
}
|
|
164
|
+
/** A RAM-aware SAFE default compaction ceiling (pure; exported for tests). The context window is a TOKEN
|
|
165
|
+
* limit, but the real failure is a MEMORY limit: model weights + KV cache must fit in RAM or macOS swaps and
|
|
166
|
+
* decode collapses to ~0 tok/s (measured 2026-10-01 on a 64GB box: context reached ~191K tok → 7.6GB swap →
|
|
167
|
+
* decode 26→2.7→0 tok/s). The %-of-window threshold can't see that cliff (it's the same % regardless of RAM),
|
|
168
|
+
* so we cap effective context by a budget derived from the box's RAM. Reserve ~28GB (≈20GB model + OS/app/KV
|
|
169
|
+
* overhead), then ~3500 tok/GB of what's left — deliberately BELOW the measured cliff (errs toward compacting
|
|
170
|
+
* a little early, which only costs some fidelity that retrieval reclaims; the alternative is the swap stall).
|
|
171
|
+
* Clamped to [8000, 0.85·window], so on a small window it never fires before the threshold path would. */
|
|
172
|
+
export function defaultCompactionCeiling(totalBytes, windowTokens) {
|
|
173
|
+
const totalGB = totalBytes / 2 ** 30;
|
|
174
|
+
const budgetGB = Math.max(0, totalGB - 28);
|
|
175
|
+
const raw = Math.floor(budgetGB * 3500);
|
|
176
|
+
const cap = Math.floor((windowTokens > 0 ? windowTokens : 0) * 0.85);
|
|
177
|
+
return Math.max(8000, Math.min(raw, cap));
|
|
178
|
+
}
|
|
164
179
|
/** The absolute-token proactive-compaction ceiling to hand runTurn: settings.compaction.ceilingTokens
|
|
165
|
-
* (env-overridden in loadSettings)
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
|
|
180
|
+
* (env-overridden in loadSettings), validated to a sane floor of 8000 tokens. When UNSET, we no longer leave
|
|
181
|
+
* it uncapped — we apply a RAM-aware safe default (defaultCompactionCeiling) so a large window can't grow the
|
|
182
|
+
* KV cache past the box's memory into swap (the "88 tokens in 6 minutes" stall). An explicit valid setting
|
|
183
|
+
* always wins. `windowTokens` is the active endpoint's context window; pass 0 if unknown (then only the floor
|
|
184
|
+
* applies). Resolved here so CLI, headless, and ACP surfaces read it identically. */
|
|
185
|
+
export function compactionCeilingTokens(s, windowTokens = 0) {
|
|
170
186
|
const t = s.compaction?.ceilingTokens;
|
|
171
|
-
|
|
187
|
+
if (typeof t === "number" && Number.isFinite(t) && t >= 8000)
|
|
188
|
+
return Math.floor(t);
|
|
189
|
+
if (windowTokens >= 8000)
|
|
190
|
+
return defaultCompactionCeiling(totalmem(), windowTokens);
|
|
191
|
+
return undefined;
|
|
172
192
|
}
|
|
173
193
|
/** Whether to auto-start a Remote Control host on session boot. An explicit setting/env wins
|
|
174
194
|
* (settings.remote.autostart / KODE_RC_AUTOSTART=1/0). Otherwise it is FEATURE-FLAGGED to the admin/VIP
|
|
@@ -69,6 +69,9 @@ export function buildBrief(input, cwd) {
|
|
|
69
69
|
schemaHintFor(type),
|
|
70
70
|
"```",
|
|
71
71
|
"Use null for any field you genuinely cannot fill.",
|
|
72
|
+
"Keep it COMPACT (aim ≤1-2k tokens): prefer file:line pointers and short summaries over pasting large file",
|
|
73
|
+
"contents, logs, or full command output — the parent re-reads sources itself, and a bloated answer lands in",
|
|
74
|
+
"its context and can force a compaction.",
|
|
72
75
|
].join("\n");
|
|
73
76
|
}
|
|
74
77
|
// Pull the last JSON object out of the child's output — prefer a fenced ```json block, else the last
|
package/dist/mcp/index.js
CHANGED
|
@@ -66,9 +66,18 @@ export class McpHub {
|
|
|
66
66
|
has(name) {
|
|
67
67
|
return this.tools.has(name);
|
|
68
68
|
}
|
|
69
|
-
/** OpenAI-format function schemas for every discovered remote tool (namespaced names).
|
|
69
|
+
/** OpenAI-format function schemas for every discovered remote tool (namespaced names), SORTED by name.
|
|
70
|
+
* KV prefix-cache reuse is strictly prefix-positional, so any reorder of the tools array zeroes every
|
|
71
|
+
* downstream cache hit. discover() may populate `this.tools` in nondeterministic (concurrent) order, so we
|
|
72
|
+
* sort here — making the serialized [tools] blob byte-identical across sessions and restarts (GW-04), which
|
|
73
|
+
* is what lets slot-save/restore reuse survive a reconnect instead of re-prefilling from scratch. */
|
|
70
74
|
schemas() {
|
|
71
|
-
return [...this.tools.values()]
|
|
75
|
+
return [...this.tools.values()]
|
|
76
|
+
.sort((a, b) => {
|
|
77
|
+
const an = `${a.server}${SEP}${a.def.name}`, bn = `${b.server}${SEP}${b.def.name}`;
|
|
78
|
+
return an < bn ? -1 : an > bn ? 1 : 0;
|
|
79
|
+
})
|
|
80
|
+
.map((t) => ({
|
|
72
81
|
type: "function",
|
|
73
82
|
function: {
|
|
74
83
|
name: `${t.server}${SEP}${t.def.name}`,
|
|
@@ -4,6 +4,20 @@
|
|
|
4
4
|
// REFLECTION. All sinks are best-effort and MUST never block or throw into a turn. Node imports are lazy
|
|
5
5
|
// (same mobile/JSCore-bundle discipline as services/preflight.ts) so the neutral bundle carries none of it.
|
|
6
6
|
const nodeImport = (m) => import(/* @vite-ignore */ m);
|
|
7
|
+
// GW-18 (flywheel gate): markers of a STRUCTURED tool call that leaked into the assistant's plain text instead
|
|
8
|
+
// of being parsed into tool_calls — the documented Qwen3 failure when the server runs without `--jinja` (the
|
|
9
|
+
// heuristic parser passes the XML through as content with finish_reason:"stop"). A turn like this is the worst
|
|
10
|
+
// possible training row: it's recorded as a "completed" turn, but the assistant text IS raw tool markup, so
|
|
11
|
+
// training on it teaches the model to EMIT the markup as prose — the agent self-poisons on its own parser bug.
|
|
12
|
+
// Also catches leaked think delimiters (reasoning that wasn't stripped). Err toward detection: a false positive
|
|
13
|
+
// only drops ONE turn from the corpus; a false negative poisons the model.
|
|
14
|
+
const TOOLCALL_LEAK = /<tool_call>|<\/tool_call>|<\|tool_call\|>|<function\s*=|<\/function>|<\/?think>/i;
|
|
15
|
+
/** True when assistant `content` contains leaked tool-call / think markup — i.e. the model's structured output
|
|
16
|
+
* was NOT parsed and bled into the text (a `--jinja`-off / template-mismatch parse fallback). Pure; exported
|
|
17
|
+
* for the parser canary. Such a turn must never be graded into the training corpus (GW-18). */
|
|
18
|
+
export function hasLeakedToolCall(content) {
|
|
19
|
+
return TOOLCALL_LEAK.test(content);
|
|
20
|
+
}
|
|
7
21
|
/** FLYWHEEL sink — append the turn as one JSONL row to a daily capture the fleet's training pipeline reads.
|
|
8
22
|
* A turn that produced content, ran ≥1 round, and wasn't cut for repetition/abort is marked graded:true,
|
|
9
23
|
* so downstream can filter to promotable trajectories without re-judging every row. */
|
|
@@ -19,8 +33,12 @@ async function captureFlywheel(r) {
|
|
|
19
33
|
// graded = a promotable trajectory. A turn that changed files but never ran a passing check
|
|
20
34
|
// (unverified, per the verify-before-done gate) is NOT promotable — that is precisely the hollow
|
|
21
35
|
// "done" this whole loop exists to stop the fleet from training on.
|
|
22
|
-
|
|
23
|
-
|
|
36
|
+
// A leaked/garbled tool call recorded as a "completed" turn would train the model to emit tool markup as
|
|
37
|
+
// prose (self-poisoning) — exclude it from promotable rows AND tag it so the pipeline can audit leak rate
|
|
38
|
+
// and the serving side (GW-01/GW-18 `--jinja`) can be verified by the trend going to ~0.
|
|
39
|
+
const parseFallback = hasLeakedToolCall(r.content);
|
|
40
|
+
const graded = !!r.content.trim() && r.stopReason !== "repetition" && r.rounds > 0 && !r.unverified && !parseFallback;
|
|
41
|
+
const row = JSON.stringify({ ts: Date.now(), graded, parse_fallback: parseFallback, ...r }) + "\n";
|
|
24
42
|
await appendFile(join(dir, `${new Date().toISOString().slice(0, 10)}.jsonl`), row);
|
|
25
43
|
}
|
|
26
44
|
catch { /* best-effort — capture never blocks or fails a turn */ }
|
package/dist/session.js
CHANGED
|
@@ -48,7 +48,14 @@ function makeSpawnTool(handler) {
|
|
|
48
48
|
"still working; call agent_status (no args) to see every sub-agent's real state before concluding " +
|
|
49
49
|
"otherwise. A sub-agent id is NOT a shell_background job id — never poll it with bash_output/bash_kill " +
|
|
50
50
|
"(those are for shell_background only and will just error); use agent_status to check on it, " +
|
|
51
|
-
"message_agent to nudge it, and stop_agent to actually halt it if the user asks you to stop/cancel it."
|
|
51
|
+
"message_agent to nudge it, and stop_agent to actually halt it if the user asks you to stop/cancel it. " +
|
|
52
|
+
"RETURN CONTRACT: in the task, tell the sub-agent to report back CONCISELY — a short findings list plus " +
|
|
53
|
+
"file:line pointers, NOT pasted large output (it can re-read files itself). Its report posts back into " +
|
|
54
|
+
"THIS conversation, so a bloated report bloats your own context and can trigger a compaction — scope the " +
|
|
55
|
+
"ask so ~1-2k tokens of findings is enough. SINGLE WRITER: keep file EDITS on one agent in sequence (you); " +
|
|
56
|
+
"spawn sub-agents for READ / SEARCH / REVIEW intelligence, not for parallel writes to the same files — two " +
|
|
57
|
+
"writers on one working tree corrupt each other. Match effort to the task: a lookup is one agent (or just " +
|
|
58
|
+
"do it inline); only genuinely independent, multi-step work is worth a spawn.",
|
|
52
59
|
parameters: {
|
|
53
60
|
type: "object",
|
|
54
61
|
properties: {
|
|
@@ -497,6 +504,10 @@ export class Session {
|
|
|
497
504
|
maxTokens: SUMMARY_MAX_TOKENS,
|
|
498
505
|
temperature: 0,
|
|
499
506
|
background: this.background, // a sub-agent's compaction summarize also yields to the interactive main turn
|
|
507
|
+
signal: this.ctrl?.signal, // ESC during "compacting" must tear down THIS request too, not just the main
|
|
508
|
+
// generation stream — without it a compaction summarize (which can be a large request on a slow/deep
|
|
509
|
+
// endpoint) runs to completion after the user already hit esc. Null ctrl (background pass outside a turn)
|
|
510
|
+
// → undefined → no abort, which is correct.
|
|
500
511
|
});
|
|
501
512
|
// Return "" on a genuinely empty response so compact()'s empty-summary guard fires and PRESERVES history
|
|
502
513
|
// rather than replacing it with a useless placeholder — the old "(summary unavailable)" sentinel was
|
|
@@ -600,12 +611,23 @@ export class Session {
|
|
|
600
611
|
async send(text, h = {}) {
|
|
601
612
|
if (this.ctrl)
|
|
602
613
|
throw new Error("Session.send called while a turn is in flight — serialize turns (the shell queues input)");
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
614
|
+
// Arm the interrupt controller BEFORE maybeRecall. The host flips status to "thinking" the instant send() is
|
|
615
|
+
// called, so an esc during first-turn memory recall / MCP discovery (which hit the network and can be slow)
|
|
616
|
+
// would otherwise no-op — this.ctrl was null until execute(). execute() reuses this same controller.
|
|
617
|
+
this.ctrl = new AbortController();
|
|
618
|
+
try {
|
|
619
|
+
await this.maybeRecall(text); // fold past-session memory into the system prompt on the first turn
|
|
620
|
+
if (this.ctrl.signal.aborted)
|
|
621
|
+
return { content: "", rounds: 0, toolCalls: 0, interrupted: true };
|
|
622
|
+
this.inner.resetTurn(); // re-evaluate routing from the smallest endpoint + clear last turn's unhealthy set
|
|
623
|
+
const active = findModel(this.registry, this.modelId);
|
|
624
|
+
if (active?.kind === "orchestrated")
|
|
625
|
+
return await this.sendMoa(text, h, active);
|
|
626
|
+
return await this.execute(text, h, this.router, this.sysWithThink());
|
|
627
|
+
}
|
|
628
|
+
finally {
|
|
629
|
+
this.ctrl = null; // execute() nulls on its own path too; this also covers the maybeRecall-abort early return
|
|
630
|
+
}
|
|
609
631
|
}
|
|
610
632
|
/** MOA turn (MOA-DESIGN.md): fan out to settings.moa's proposers in parallel, then run the
|
|
611
633
|
* aggregator through the SAME runTurn loop as a normal turn (execute) — pointed at the
|
|
@@ -645,7 +667,9 @@ export class Session {
|
|
|
645
667
|
async execute(text, h, router, sys, routeLabel) {
|
|
646
668
|
this.executor.resetTurn(); // clear the host executor's per-turn loop guard before this turn
|
|
647
669
|
this.lastSys = sys; // remember the EXACT system prompt this turn sends, so cache-safe compaction reuses it verbatim
|
|
648
|
-
|
|
670
|
+
// Reuse the controller send() already armed (so esc during maybeRecall / MOA fan-out is live); create one
|
|
671
|
+
// only if execute() is somehow entered without send() arming it (defensive — every caller goes via send).
|
|
672
|
+
const controller = this.ctrl ?? new AbortController();
|
|
649
673
|
this.ctrl = controller;
|
|
650
674
|
const _t0 = performance.now();
|
|
651
675
|
try {
|
package/dist/tools/executor.js
CHANGED
|
@@ -14,6 +14,7 @@ import { shellKeyStore } from "./shell-context.js";
|
|
|
14
14
|
// Re-exported for back-compat (existing importers reach it via executor.js) — moved to its own
|
|
15
15
|
// file since it's a pure helper with no node deps; see result-cap.ts for why that separation matters.
|
|
16
16
|
import { capToolResult } from "./result-cap.js";
|
|
17
|
+
import { spillToolOutput } from "./tool-output-spill.js"; // GW-10: lossless eviction — spill big outputs, hand back a re-readable pointer
|
|
17
18
|
export { TOOL_RESULT_MAX_CHARS, capToolResult } from "./result-cap.js";
|
|
18
19
|
// Command tools whose working directory should default to the executor root (they take an optional `cwd`).
|
|
19
20
|
const CWD_TOOLS = new Set(["bash", "shell_exec", "shell_background", "git", "git_command", "git_status"]);
|
|
@@ -79,7 +80,7 @@ export class Executor {
|
|
|
79
80
|
try {
|
|
80
81
|
// Run the tool inside THIS session's shell-key context so a persistent-shell tool (bash) picks
|
|
81
82
|
// this session's own ShellSession, not a process-wide singleton shared with other sub-agents.
|
|
82
|
-
const out = capToolResult(await shellKeyStore.run(this.shellKey, () => tool.run(args)));
|
|
83
|
+
const out = capToolResult(await shellKeyStore.run(this.shellKey, () => tool.run(args)), spillToolOutput);
|
|
83
84
|
// A file edit changed the workspace, so prior identical-call counts are stale — re-running the same
|
|
84
85
|
// test/build after an edit is verify-after-fix iteration, not a loop. Clear so repeats start fresh.
|
|
85
86
|
if (MUTATING_TOOLS.has(name))
|
package/dist/tools/result-cap.js
CHANGED
|
@@ -13,11 +13,14 @@
|
|
|
13
13
|
export const TOOL_RESULT_MAX_CHARS = 40_000; // ~40KB
|
|
14
14
|
const TOOL_RESULT_TAIL_CHARS = 2_000;
|
|
15
15
|
const TOOL_RESULT_HEAD_CHARS = TOOL_RESULT_MAX_CHARS - TOOL_RESULT_TAIL_CHARS;
|
|
16
|
-
export function capToolResult(result) {
|
|
16
|
+
export function capToolResult(result, spill) {
|
|
17
17
|
if (result.length <= TOOL_RESULT_MAX_CHARS)
|
|
18
18
|
return result;
|
|
19
19
|
const head = result.slice(0, TOOL_RESULT_HEAD_CHARS);
|
|
20
20
|
const tail = result.slice(-TOOL_RESULT_TAIL_CHARS);
|
|
21
|
-
const
|
|
21
|
+
const path = spill ? spill(result) : null;
|
|
22
|
+
const marker = path
|
|
23
|
+
? `\n…[${result.length} chars total; showing head+tail — FULL output saved to ${path} · re-read the omitted middle with file_read(path, offset, limit)]\n`
|
|
24
|
+
: `\n…[result truncated: ${TOOL_RESULT_MAX_CHARS} of ${result.length} chars — narrow your query]\n`;
|
|
22
25
|
return head + marker + tail;
|
|
23
26
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// GW-10 spill sink (NODE-ONLY — never import from the browser barrel; it uses node:fs). When a tool result
|
|
2
|
+
// exceeds capToolResult's cap, the FULL output is written here so nothing is lost: the model receives a pointer
|
|
3
|
+
// (the saved path) in place of the discarded middle and re-reads it on demand with file_read(offset/limit).
|
|
4
|
+
// Injected into capToolResult so that module stays node-free for kode-web. Best-effort: a failed write returns
|
|
5
|
+
// null and capToolResult falls back to the plain head+tail truncation — a spill must never fail a tool call.
|
|
6
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { homedir } from "node:os";
|
|
9
|
+
/** Where spilled tool outputs live. A flat dir under the operator home; the model is handed absolute paths. */
|
|
10
|
+
export function toolOutputDir() {
|
|
11
|
+
return join(homedir(), ".axe", "operator", "tool-outputs");
|
|
12
|
+
}
|
|
13
|
+
let _seq = 0; // process-local tiebreaker so two spills in the same ms don't collide
|
|
14
|
+
/** Persist `full` and return its absolute path, or null on any failure (caller degrades to head+tail). */
|
|
15
|
+
export function spillToolOutput(full) {
|
|
16
|
+
try {
|
|
17
|
+
const dir = toolOutputDir();
|
|
18
|
+
mkdirSync(dir, { recursive: true });
|
|
19
|
+
const path = join(dir, `${Date.now().toString(36)}-${(_seq++).toString(36)}.txt`);
|
|
20
|
+
writeFileSync(path, full);
|
|
21
|
+
return path;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
package/dist/util/slash.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
const KNOWN = new Set([
|
|
5
5
|
"help", "model", "route", "endpoints", "services", "audit", "dashboard", "plan", "mode",
|
|
6
6
|
"think", "ultrathink", "compact", "remember", "memory", "mcp", "whoami", "agents", "monitor",
|
|
7
|
-
"bg", "new", "clear", "exit", "quit", "stats", "login", "logout", "remote", "remotecontrol",
|
|
7
|
+
"bg", "new", "clear", "exit", "quit", "stats", "login", "logout", "remote", "remotecontrol", "rc",
|
|
8
8
|
]);
|
|
9
9
|
export function isSlashCommand(text) {
|
|
10
10
|
const t = text.trim();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0perator/operator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.166",
|
|
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": {
|