@0perator/operator 0.1.47 → 0.1.50
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 +60 -0
- package/dist/cli.js +63 -12
- package/dist/config/settings.js +20 -2
- package/dist/engine/agent.js +53 -0
- package/dist/engine/moa.js +44 -0
- package/dist/permissions/tier.js +1 -1
- package/dist/remote/host.js +29 -3
- package/dist/router/models.js +35 -0
- package/dist/session.js +92 -8
- package/dist/tools/registry.js +51 -22
- package/dist/tools/sandbox.js +11 -0
- package/dist/tools/shell-session.js +145 -0
- package/dist/ui/App.js +2 -2
- package/dist/ui/QuestionPrompt.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,66 @@ 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.48 — 2026-09-21
|
|
8
|
+
- Added: `/model` command — pick between `aurora-1m` (default, :8097), `aurora-128k` (:8096, lighter
|
|
9
|
+
RAM), or `moa` (Mixture of Agents) via an interactive picker (`/model`) or directly (`/model <id>`).
|
|
10
|
+
A single-profile switch rebuilds the session's router to point at that endpoint (`router/models.ts`,
|
|
11
|
+
`Session.setModel`) — no server is ever started/stopped, it only changes which endpoint THIS session
|
|
12
|
+
talks to. The choice persists to `operator/settings.json` (`activeModel`, `saveSettings`) and is
|
|
13
|
+
reapplied at startup. See `MOA-DESIGN.md`.
|
|
14
|
+
- Added: MOA (Mixture of Agents) execution mode (`engine/moa.ts`) — a turn fans out in PARALLEL to
|
|
15
|
+
`settings.moa`'s proposers (plain, tool-free chat completions), then runs the aggregator through the
|
|
16
|
+
normal turn loop (tool-calling, streaming, self-heal, telemetry all reused — v1 is aggregator-only
|
|
17
|
+
tool-calling) with the labelled candidate drafts folded into its system prompt. A proposer
|
|
18
|
+
failing/timing out is dropped, not fatal; zero survivors fall back to `aurora-1m` for that reply with
|
|
19
|
+
a clear note. `/model moa` without a `moa` block in settings explains what's missing instead of
|
|
20
|
+
running. Telemetry records which proposers ran, per-proposer latency, and which drafts survived.
|
|
21
|
+
- Added: `ask_user` remote-control relay emit (`RemoteHost.askUser`) — a clarification question is now
|
|
22
|
+
mirrored to `/remotecontrol` followers as a distinct `ask_user` frame (not folded into
|
|
23
|
+
`approval_request`); the follower's `ask_user_response` races first-wins against a local answer, same
|
|
24
|
+
pattern as approvals. Local (non-remote) `ask_user` is unchanged.
|
|
25
|
+
- Tests: +37 (`router/models.ts` registry + selection reducer, `engine/moa.ts` fan-out against real
|
|
26
|
+
local HTTP servers incl. a failing proposer, `Session.setModel`/MOA dispatch, `activeModel`
|
|
27
|
+
persistence round-trip, `RemoteHost` ask_user frame shape + response routing). Suite 317/317.
|
|
28
|
+
|
|
29
|
+
## 0.1.50 — 2026-09-21
|
|
30
|
+
- Hardening from a Carmack/Karpathy/Boris/Hinton master review of the 0.1.49 bash tool + anti-loop:
|
|
31
|
+
- **Fixed (blocker):** enterprise-tier allowlist denied the new `bash` tool (only `shell_exec` was listed),
|
|
32
|
+
so every enterprise seat broke on the first shell command. `bash` added to `ENTERPRISE_ALLOW`.
|
|
33
|
+
- **Fixed (blocker):** the process-wide `ShellSession` had no serialization — a foreground turn and a
|
|
34
|
+
background sub-agent both calling `bash` could stomp each other's buffer and cross-deliver output/exit
|
|
35
|
+
codes. Added a FIFO promise-queue so overlapping calls run one-at-a-time; sentinel regex anchored to
|
|
36
|
+
start-of-line; fast-fail when the shell dies mid-command; bounded buffer so a runaway (`yes`) can't OOM.
|
|
37
|
+
- **Fixed (would false-stop real work):** the narration-loop guard now gates on PROGRESS — repeated prose
|
|
38
|
+
only counts as a loop when the prior tool batch returned nothing new, so a model using a fixed template
|
|
39
|
+
over productive, varying work is never wrongly halted. Fingerprint is Unicode-aware (non-Latin narration
|
|
40
|
+
no longer exempt) and strips embedded tool-call JSON (text-recovered calls fingerprint the prose).
|
|
41
|
+
- Carmack shell-systems pass: spawn the persistent shell **detached** and kill by process GROUP so a
|
|
42
|
+
timed-out command's backgrounded grandchildren (`&` jobs) don't orphan (#6); wire `disposeShellSession()`
|
|
43
|
+
into the CLI exit/SIGTERM handlers so the shell never orphans on normal exit (#5, previously dead code);
|
|
44
|
+
add a `stdin` error handler so an EPIPE from a kill/write race can't crash the whole CLI (#7). The
|
|
45
|
+
`exit`-kills-bash fast-fail (#3) and buffer bound (#8 memory) already landed above.
|
|
46
|
+
- Known follow-ups (flagged by the review, not in this release): the permissions-layer `executeParallel`
|
|
47
|
+
fans unsafe tools through parallel `execute()` instead of the executor's sequential path (#1 — bash is
|
|
48
|
+
already covered by the queue above; other unsafe tools get a focused fix); backgrounded-child output can
|
|
49
|
+
bleed into the next command's buffer (#4 — needs per-job fds, a design change).
|
|
50
|
+
- Tests: +1 concurrency (overlapping run() serialize cleanly). Suite 332/332.
|
|
51
|
+
|
|
52
|
+
## 0.1.49 — 2026-09-21
|
|
53
|
+
- Added: **frontier `bash` tool** — a PERSISTENT shell session. `cd`, exported env vars, activated
|
|
54
|
+
venvs and shell functions now survive across bash calls like a real terminal, so the model sets
|
|
55
|
+
up once and reuses it instead of re-running `source .../activate && ...` on every call (the root
|
|
56
|
+
cause of the clumsy heredoc gymnastics + repeated-call loops seen in the wild). stdout/stderr come
|
|
57
|
+
back merged with the exit code; a per-command timeout kills+respawns the shell so a runaway command
|
|
58
|
+
can never wedge the session. `shell_exec` kept as a back-compat alias to the same engine.
|
|
59
|
+
- Implementation: `src/tools/shell-session.ts` (ShellSession, sentinel-framed, sandbox-wrapped via
|
|
60
|
+
`wrapInteractiveShell`); `registry.ts` routes shell_exec/bash through one per-process session; a
|
|
61
|
+
scoped `cwd` arg runs in a subshell so it doesn't silently move the session.
|
|
62
|
+
- Tests: +4 shell-session (cwd persists, env persists, stderr+exit surfaced, timeout recovers).
|
|
63
|
+
- 0.1.48 (Nova, merged earlier): /model command + MOA (Mixture of Agents) execution mode + model
|
|
64
|
+
registry (aurora-1m / aurora-128k / moa); ask_user remote-control relay emit; QuestionPrompt Ctrl-C
|
|
65
|
+
→ DISCUSS; RemoteHost inbound-frame sessionId/ownerSub guard. Variant B web on 0perator.co.
|
|
66
|
+
|
|
7
67
|
## 0.1.47 — 2026-09-21
|
|
8
68
|
- Added: agent-cursor overlay tools curated into chauffeur's unprompted read set
|
|
9
69
|
(`set_agent_cursor_enabled`, `set_agent_cursor_theme`, `get_agent_cursor_state`) so the owner can SEE the
|
package/dist/cli.js
CHANGED
|
@@ -12,7 +12,8 @@ import { RemoteHost } from "./remote/host.js";
|
|
|
12
12
|
import { Session } from "./session.js";
|
|
13
13
|
import { AuroraRouter } from "./router/router.js";
|
|
14
14
|
import { BackgroundAgents } from "./background/index.js";
|
|
15
|
-
import { loadSettings } from "./config/settings.js";
|
|
15
|
+
import { loadSettings, saveSettings } from "./config/settings.js";
|
|
16
|
+
import { disposeShellSession } from "./tools/registry.js";
|
|
16
17
|
import { EventSink } from "./telemetry/events.js";
|
|
17
18
|
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
18
19
|
import { expandFileMentions } from "./util/mentions.js";
|
|
@@ -21,7 +22,7 @@ import { homedir, hostname } from "node:os";
|
|
|
21
22
|
import { createHash } from "node:crypto";
|
|
22
23
|
// RELEASE CHECKLIST (every bump): update this + package.json "version", ADD A CHANGELOG.md ENTRY
|
|
23
24
|
// (improvements / fixes / tests), run the suite, then publish to npm + push both remotes.
|
|
24
|
-
const VERSION = "0.1.
|
|
25
|
+
const VERSION = "0.1.50";
|
|
25
26
|
// operator/settings.json (override path via KODE_TSI_SETTINGS), env vars still win — see config/settings.ts.
|
|
26
27
|
const settings = loadSettings();
|
|
27
28
|
// Propagate the resolved sandbox mode to the tool layer (registry reads KODE_SANDBOX at exec time).
|
|
@@ -221,7 +222,7 @@ const MAX_BG = 4; // concurrent background sub-agents — all share the single A
|
|
|
221
222
|
const HELP = [
|
|
222
223
|
"commands:",
|
|
223
224
|
" /help this list",
|
|
224
|
-
" /model
|
|
225
|
+
" /model [id] pick a model: aurora-1m · aurora-128k · moa (mixture-of-agents)",
|
|
225
226
|
" /endpoints show the aurora endpoint + live health",
|
|
226
227
|
" /services ensure/inspect the service lever (aurora+autopilot+searxng); /services stop",
|
|
227
228
|
" /audit [n] recent tool + control-plane events from the audit trail (default 15)",
|
|
@@ -274,11 +275,28 @@ function Root() {
|
|
|
274
275
|
// decision here and <ApprovalPrompt> renders it; the keystroke resolves the promise. "allow always"
|
|
275
276
|
// adds the tool to a per-session set so it stops prompting. (No approver ⇒ policy fail-safe denies.)
|
|
276
277
|
const [approval, setApproval] = useState(null);
|
|
277
|
-
// ask_user bridge: the model's clarification question, parked here until the owner
|
|
278
|
+
// ask_user bridge: the model's clarification question, parked here until the owner — locally, or a
|
|
279
|
+
// remote follower during /remotecontrol — picks an option. Mirrors the approval bridge's
|
|
280
|
+
// first-wins: both a local pick and a follower's ask_user_response settle through settleQuestion.
|
|
278
281
|
const [question, setQuestion] = useState(null);
|
|
282
|
+
const pendingQuestions = useRef(new Map());
|
|
283
|
+
const settleQuestion = useCallback((id, answer) => {
|
|
284
|
+
const resolve = pendingQuestions.current.get(id);
|
|
285
|
+
if (!resolve)
|
|
286
|
+
return; // already settled (first-wins)
|
|
287
|
+
pendingQuestions.current.delete(id);
|
|
288
|
+
resolve(answer);
|
|
289
|
+
setQuestion((cur) => (cur && cur.id === id ? null : cur));
|
|
290
|
+
}, []);
|
|
279
291
|
const askUser = useCallback((q, options) => new Promise((resolve) => {
|
|
280
|
-
|
|
281
|
-
|
|
292
|
+
const id = "q_" + Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
|
|
293
|
+
pendingQuestions.current.set(id, resolve);
|
|
294
|
+
setQuestion({ id, question: q, options, resolve: (a) => settleQuestion(id, a) });
|
|
295
|
+
remoteRef.current?.askUser(id, q, options); // mirror to followers (owner-scoped)
|
|
296
|
+
}), [settleQuestion]);
|
|
297
|
+
// /model picker: same QuestionPrompt UI pattern as ask_user, but purely local (never relayed) —
|
|
298
|
+
// it's a session setting, not something the model is asking.
|
|
299
|
+
const [modelPicker, setModelPicker] = useState(null);
|
|
282
300
|
const alwaysAllowRef = useRef(new Set());
|
|
283
301
|
// Pending gated approvals by id. Both the local keystroke and a remote follower's approval_response
|
|
284
302
|
// route through settleApproval — FIRST answer wins (§7); the map delete makes it idempotent.
|
|
@@ -317,6 +335,9 @@ function Root() {
|
|
|
317
335
|
maxTokens: settings.maxTokens,
|
|
318
336
|
temperature: settings.temperature,
|
|
319
337
|
recall: settings.memory.recall,
|
|
338
|
+
models: settings.models, // /model registry overrides (router/models.ts has the built-in defaults)
|
|
339
|
+
moa: settings.moa, // MOA proposers/aggregator config (MOA-DESIGN.md); absent = "/model moa" explains
|
|
340
|
+
activeModel: settings.activeModel, // persisted /model choice, applied at startup
|
|
320
341
|
permissions: fgPermissions, // owner's policy + computer tools forced to "ask" when enabled (else bypass)
|
|
321
342
|
approve: approveFn, // renders the in-TUI approval prompt for any "ask" decision
|
|
322
343
|
askUser, // registers the ask_user tool so the model can put a clarifying question to the owner
|
|
@@ -370,8 +391,8 @@ function Root() {
|
|
|
370
391
|
// Backstop the slash-/ESC-quit paths: an ordinary terminal close or `kill` must still tear down any
|
|
371
392
|
// spawned stdio MCP subprocesses (session.shutdown), or they orphan. exit runs sync; SIGTERM exits after.
|
|
372
393
|
useEffect(() => {
|
|
373
|
-
const onExit = () => session.shutdown();
|
|
374
|
-
const onTerm = () => { session.shutdown(); process.exit(0); };
|
|
394
|
+
const onExit = () => { session.shutdown(); disposeShellSession(); };
|
|
395
|
+
const onTerm = () => { session.shutdown(); disposeShellSession(); process.exit(0); };
|
|
375
396
|
process.once("exit", onExit);
|
|
376
397
|
process.once("SIGTERM", onTerm);
|
|
377
398
|
return () => { process.off("exit", onExit); process.off("SIGTERM", onTerm); };
|
|
@@ -585,9 +606,38 @@ function Root() {
|
|
|
585
606
|
setCtxPct(0);
|
|
586
607
|
sys("started a fresh conversation");
|
|
587
608
|
break;
|
|
588
|
-
case "model":
|
|
589
|
-
|
|
609
|
+
case "model": {
|
|
610
|
+
// Apply a selection (picker choice or `/model <id>`), persist it, and reflect it on the
|
|
611
|
+
// status rule right away — the router only updates its label mid-turn (onRoute), and MOA has
|
|
612
|
+
// no router of its own at all, so this is the one place that's always accurate immediately.
|
|
613
|
+
const apply = (id) => {
|
|
614
|
+
const r = s.setModel(id);
|
|
615
|
+
if (!r.ok) {
|
|
616
|
+
sys(`${r.error} — run /model for the list`);
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
setRoute(s.currentModel());
|
|
620
|
+
saveSettings({ activeModel: s.currentModel() });
|
|
621
|
+
sys(`model → ${s.currentModel()} · ctx ${s.ctxPct()}% · turns ${s.turnCount()}`);
|
|
622
|
+
};
|
|
623
|
+
if (arg) {
|
|
624
|
+
apply(arg);
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
const active = s.currentModel();
|
|
628
|
+
const models = s.modelRegistry();
|
|
629
|
+
const options = models.map((m) => `${m.label}${m.id === active ? " (active)" : ""}`);
|
|
630
|
+
setModelPicker({
|
|
631
|
+
question: "Select a model",
|
|
632
|
+
options,
|
|
633
|
+
resolve: (answer) => {
|
|
634
|
+
setModelPicker(null);
|
|
635
|
+
const idx = options.indexOf(answer);
|
|
636
|
+
apply(idx >= 0 ? models[idx].id : answer.trim());
|
|
637
|
+
},
|
|
638
|
+
});
|
|
590
639
|
break;
|
|
640
|
+
}
|
|
591
641
|
case "route":
|
|
592
642
|
if (s.pinRoute(arg || "auto"))
|
|
593
643
|
sys(arg && arg !== "auto" ? `routing pinned to ${arg}` : "routing set to auto (by size)");
|
|
@@ -786,6 +836,7 @@ function Root() {
|
|
|
786
836
|
const rh = new RemoteHost(url, token, { title: `Operator · ${process.cwd().split("/").pop() || "session"}`, cwd: process.cwd(), host: hostname(), surface: "cli" }, {
|
|
787
837
|
onPrompt: (text) => submitRef.current(text), // follower drives a turn
|
|
788
838
|
onApprovalResponse: (id, approve) => settleApproval(id, approve), // first-wins with local
|
|
839
|
+
onAskUserResponse: (id, answer) => settleQuestion(id, answer), // first-wins with local
|
|
789
840
|
onInterrupt: () => s.interrupt(), // follower cancels the turn
|
|
790
841
|
onState: (st, detail) => {
|
|
791
842
|
if (st === "live")
|
|
@@ -808,7 +859,7 @@ function Root() {
|
|
|
808
859
|
}
|
|
809
860
|
default: sys(`unknown command /${name} — try /help`);
|
|
810
861
|
}
|
|
811
|
-
}, [exit, sys, bg, authUser, approval, settleApproval]);
|
|
862
|
+
}, [exit, sys, bg, authUser, approval, settleApproval, settleQuestion]);
|
|
812
863
|
const onSubmit = useCallback((text) => {
|
|
813
864
|
const t = text.trim();
|
|
814
865
|
if (t.startsWith("/")) {
|
|
@@ -857,7 +908,7 @@ function Root() {
|
|
|
857
908
|
? `${spin} reading your prompt… (${fmtDuration(elapsed)})`
|
|
858
909
|
: `${spin} ${fmtMeta(elapsed, liveTok)}`
|
|
859
910
|
: metrics;
|
|
860
|
-
return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, route: route, ctxPct: ctxPct, version: VERSION, metrics: liveMetrics, sessionTokens: session.sessionTokens() + liveTok, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, approval: approval, question: question, onApprovalDecide: (allow, always) => {
|
|
911
|
+
return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, route: route, ctxPct: ctxPct, version: VERSION, metrics: liveMetrics, sessionTokens: session.sessionTokens() + liveTok, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, approval: approval, question: question, modelPicker: modelPicker, onApprovalDecide: (allow, always) => {
|
|
861
912
|
const cur = approval;
|
|
862
913
|
if (cur)
|
|
863
914
|
settleApproval(cur.id, allow, always); // first-wins with any remote follower answer
|
package/dist/config/settings.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// agent's settings.json. Loaded once at startup by cli.tsx. Precedence: env var > settings.json > built-in
|
|
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
|
-
import { readFileSync } from "node:fs";
|
|
5
|
+
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
6
6
|
import { homedir } from "node:os";
|
|
7
|
-
import { join } from "node:path";
|
|
7
|
+
import { join, dirname } from "node:path";
|
|
8
|
+
import { DEFAULT_MODEL_ID } from "../router/models.js";
|
|
8
9
|
// The sole endpoint: Aurora on :8097 at its REAL served context — 1,048,576 tokens (the native window
|
|
9
10
|
// of the Qwen3.5-MoE hybrid-linear-attention base; verified via /props). This is the one model
|
|
10
11
|
// kode/operator serves. Override base/model in settings.json to point at any OpenAI-compatible server.
|
|
@@ -33,6 +34,7 @@ const DEFAULTS = {
|
|
|
33
34
|
autopilot: { autostart: true, launchdLabel: "com.axe.autopilot", plistPath: "~/Library/LaunchAgents/com.axe.autopilot.plist", url: "http://127.0.0.1:9333" },
|
|
34
35
|
stopOnExit: { searxng: true }, // aurora/autopilot are shared + never stopped; only the SearXNG container is
|
|
35
36
|
},
|
|
37
|
+
activeModel: DEFAULT_MODEL_ID, // /model default — the 1M endpoint, unchanged from before /model existed
|
|
36
38
|
};
|
|
37
39
|
function settingsPath() {
|
|
38
40
|
return process.env.KODE_TSI_SETTINGS ?? join(homedir(), ".axe", "operator", "settings.json");
|
|
@@ -118,3 +120,19 @@ export function loadSettings() {
|
|
|
118
120
|
// otherwise flow through by reference and a later mutation would corrupt defaults process-wide.
|
|
119
121
|
return applyEnv(deepMerge(structuredClone(DEFAULTS), file));
|
|
120
122
|
}
|
|
123
|
+
/** Persist a partial settings patch onto whatever's on disk (deep-merged, file values win over
|
|
124
|
+
* defaults for anything the patch doesn't touch), so a runtime choice like /model survives a
|
|
125
|
+
* restart. Best-effort — same "never throws" contract as loadSettings; a write failure just means
|
|
126
|
+
* the choice doesn't survive a restart, it doesn't affect the running process. */
|
|
127
|
+
export function saveSettings(patch) {
|
|
128
|
+
const path = settingsPath();
|
|
129
|
+
const current = readSettingsFile(path);
|
|
130
|
+
const merged = deepMerge(isPlainObject(current) ? current : {}, patch);
|
|
131
|
+
try {
|
|
132
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
133
|
+
writeFileSync(path, JSON.stringify(merged, null, 2) + "\n", "utf8");
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
/* best-effort — see loadSettings */
|
|
137
|
+
}
|
|
138
|
+
}
|
package/dist/engine/agent.js
CHANGED
|
@@ -9,7 +9,34 @@ import { compact, needsCompaction, clampMaxTokens } from "./compaction.js";
|
|
|
9
9
|
import { classifyFailure, backoffMs, sleep } from "./selfheal.js";
|
|
10
10
|
const MAX_SELF_HEAL_PER_TURN = 3;
|
|
11
11
|
const LOOP_GUARD_LIMIT = 3;
|
|
12
|
+
const CONTENT_LOOP_LIMIT = 3; // same substantial assistant narration this many rounds ⇒ stuck, even if tool args vary
|
|
12
13
|
const MAX_EMPTY_RETRIES = 1; // one nudge on an empty "dud" round before finalizing
|
|
14
|
+
/** Fingerprint of an assistant round's PROSE, for catching a model narrating in circles while its
|
|
15
|
+
* tools make no progress (the "12× Empty outputs" burn). Strips embedded tool-call JSON / code fences
|
|
16
|
+
* so the fingerprint is the PROSE, stable even when the (varying) call args live inside the content
|
|
17
|
+
* (text-recovered calls). Unicode-aware (\p{L}\p{N}) so non-Latin narration isn't normalized to "" and
|
|
18
|
+
* silently exempted. */
|
|
19
|
+
function contentSignature(content) {
|
|
20
|
+
return (content || "")
|
|
21
|
+
.replace(/```[\s\S]*?```/g, " ") // fenced code / tool blocks
|
|
22
|
+
.replace(/\{[\s\S]*?\}/g, " ") // inline JSON (text-encoded tool calls)
|
|
23
|
+
.toLowerCase()
|
|
24
|
+
.normalize("NFKC")
|
|
25
|
+
.replace(/[^\p{L}\p{N} ]+/gu, " ")
|
|
26
|
+
.replace(/\s+/g, " ")
|
|
27
|
+
.trim()
|
|
28
|
+
.slice(0, 200);
|
|
29
|
+
}
|
|
30
|
+
/** A tool batch "progressed" if any result carried real content (not empty, not a (no output)/error/
|
|
31
|
+
* loop-guard sentinel). Gates the narration-loop guard: repeated prose is only a loop when the tools it
|
|
32
|
+
* reacts to aren't advancing — so templated narration over PRODUCTIVE, varying work is never mistaken
|
|
33
|
+
* for a loop. */
|
|
34
|
+
function batchProgressed(toolMsgs) {
|
|
35
|
+
return toolMsgs.some((tm) => {
|
|
36
|
+
const c = (tm.content || "").trim();
|
|
37
|
+
return c.length > 0 && !/^\(no output|^error[:\s]|^loop guard/i.test(c);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
13
40
|
/** Thrown by runTurn when the turn is interrupted via AgentOpts.signal (SPEC §9). One type for hosts to catch. */
|
|
14
41
|
export class TurnAbortedError extends Error {
|
|
15
42
|
constructor() {
|
|
@@ -106,6 +133,8 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
106
133
|
const softRounds = opts.maxRounds ?? 10;
|
|
107
134
|
const hardCap = opts.maxRoundsHard ?? Math.max(40, softRounds * 4);
|
|
108
135
|
const callCounts = new Map();
|
|
136
|
+
const contentSigs = new Map(); // per-round prose fingerprints → the narration loop guard
|
|
137
|
+
let progressed = true; // did the PREVIOUS tool batch advance? gates the guard (progress clears it)
|
|
109
138
|
let selfHealBudget = MAX_SELF_HEAL_PER_TURN;
|
|
110
139
|
conversation.user(userInput);
|
|
111
140
|
let rounds = 0;
|
|
@@ -199,6 +228,28 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
199
228
|
continue;
|
|
200
229
|
}
|
|
201
230
|
}
|
|
231
|
+
// Narration loop guard: a spinning model emits the SAME prose across rounds while its tools return
|
|
232
|
+
// nothing new (the "12× Empty outputs…" burn). Gate on PROGRESS so templated narration over
|
|
233
|
+
// productive, varying work is never mistaken for a loop — a batch that advanced clears the counter;
|
|
234
|
+
// gate on RAW length so non-Latin narration still qualifies. Fires only when prose repeats AND the
|
|
235
|
+
// prior batch didn't advance.
|
|
236
|
+
if (progressed) {
|
|
237
|
+
contentSigs.clear();
|
|
238
|
+
}
|
|
239
|
+
else if (response.content.trim().length >= 40) {
|
|
240
|
+
const csig = contentSignature(response.content);
|
|
241
|
+
if (csig) {
|
|
242
|
+
const seen = (contentSigs.get(csig) ?? 0) + 1;
|
|
243
|
+
contentSigs.set(csig, seen);
|
|
244
|
+
if (seen >= CONTENT_LOOP_LIMIT) {
|
|
245
|
+
const gist = response.content.trim().split("\n", 1)[0].slice(0, 200);
|
|
246
|
+
const stuck = `[stopped — I repeated the same step ${seen}× while the tools returned nothing new, ` +
|
|
247
|
+
`which usually means a tool isn't doing what I expect. Where I'm stuck: ${gist}\nTell me how you'd like to proceed.]`;
|
|
248
|
+
conversation.assistant(stuck);
|
|
249
|
+
return { content: stuck, rounds: rounds + 1, toolCalls: toolCallTotal, tokens: tokensTotal, genMs: genMsTotal, promptTokens: promptTokensTotal, promptMs: promptMsTotal };
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
202
253
|
if (response.toolCalls.length > 0) {
|
|
203
254
|
throwIfAborted(opts.signal); // don't dispatch a tool batch for a turn the user already cancelled
|
|
204
255
|
conversation.assistant(response.content, response.toolCalls);
|
|
@@ -206,6 +257,7 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
206
257
|
for (const tm of toolMsgs)
|
|
207
258
|
conversation.tool(tm.tool_call_id, tm.content);
|
|
208
259
|
toolCallTotal += response.toolCalls.length;
|
|
260
|
+
progressed = batchProgressed(toolMsgs);
|
|
209
261
|
continue;
|
|
210
262
|
}
|
|
211
263
|
// No structured tool_calls — check for text-encoded ones before treating this as final.
|
|
@@ -217,6 +269,7 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
217
269
|
for (const tm of toolMsgs)
|
|
218
270
|
conversation.tool(tm.tool_call_id, tm.content);
|
|
219
271
|
toolCallTotal += recovered.calls.length;
|
|
272
|
+
progressed = batchProgressed(toolMsgs);
|
|
220
273
|
continue;
|
|
221
274
|
}
|
|
222
275
|
const final = stripScratchpad(recovered.cleanedContent);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const PROPOSER_TIMEOUT_MS = 60_000;
|
|
2
|
+
/** One proposer call: a plain (non-streaming, tool-free) OpenAI-compatible chat completion. Never
|
|
3
|
+
* throws — a failure or timeout comes back as a draft with empty content + an `error`, so the
|
|
4
|
+
* caller can drop it without the whole fan-out failing (a proposer is a nice-to-have, not a
|
|
5
|
+
* dependency). */
|
|
6
|
+
async function callProposer(p, messages) {
|
|
7
|
+
const t0 = performance.now();
|
|
8
|
+
const ctrl = new AbortController();
|
|
9
|
+
const timer = setTimeout(() => ctrl.abort(), PROPOSER_TIMEOUT_MS);
|
|
10
|
+
try {
|
|
11
|
+
const res = await fetch(`${p.endpoint.replace(/\/$/, "")}/chat/completions`, {
|
|
12
|
+
method: "POST",
|
|
13
|
+
headers: { "content-type": "application/json" },
|
|
14
|
+
body: JSON.stringify({ model: p.model, messages, stream: false }),
|
|
15
|
+
signal: ctrl.signal,
|
|
16
|
+
});
|
|
17
|
+
if (!res.ok)
|
|
18
|
+
return { id: p.id, content: "", ms: Math.round(performance.now() - t0), error: `http ${res.status}` };
|
|
19
|
+
const json = await res.json();
|
|
20
|
+
const content = String(json?.choices?.[0]?.message?.content ?? "").trim();
|
|
21
|
+
return { id: p.id, content, ms: Math.round(performance.now() - t0), error: content ? undefined : "empty completion" };
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
return { id: p.id, content: "", ms: Math.round(performance.now() - t0), error: e.name || "error" };
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
clearTimeout(timer);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Fan a turn out to every proposer in PARALLEL. Never throws or rejects — always resolves with one
|
|
31
|
+
* draft per proposer (empty content + `error` set on failure/timeout), so the caller decides how
|
|
32
|
+
* many survivors are enough (Session.sendMoa: >=1 aggregates, 0 falls back to aurora-1m). */
|
|
33
|
+
export function fanOutProposers(proposers, messages) {
|
|
34
|
+
return Promise.all(proposers.map((p) => callProposer(p, messages)));
|
|
35
|
+
}
|
|
36
|
+
/** Label + join the surviving (non-empty) drafts as "Candidate A: ..." (MOA-DESIGN.md), for the
|
|
37
|
+
* aggregator's input. Pure + testable without a network call. */
|
|
38
|
+
export function labelDrafts(drafts) {
|
|
39
|
+
return drafts
|
|
40
|
+
.filter((d) => d.content)
|
|
41
|
+
.map((d, i) => `Candidate ${String.fromCharCode(65 + i)} (${d.id}):\n${d.content}`)
|
|
42
|
+
.join("\n\n");
|
|
43
|
+
}
|
|
44
|
+
export const DEFAULT_AGGREGATOR_PROMPT = "You are given candidate answers from several models. Synthesize the single best, correct, complete answer. Do not mention the candidates.";
|
package/dist/permissions/tier.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// tools mcp__*, computer_* control, future privileged tools) is denied, so new tools are safe-by-default.
|
|
3
3
|
const ENTERPRISE_ALLOW = new Set([
|
|
4
4
|
"file_read", "file_write", "file_edit", "grep_search", "list_directory",
|
|
5
|
-
"shell_exec", "shell_background", "bash_output", "bash_kill",
|
|
5
|
+
"bash", "shell_exec", "shell_background", "bash_output", "bash_kill",
|
|
6
6
|
"git_command", "checkpoint", "task_add", "task_list", "task_update",
|
|
7
7
|
"memory_search", "memory_store", "web_fetch", "web_search",
|
|
8
8
|
"skill_list", "skill_fetch", "skill_save",
|
package/dist/remote/host.js
CHANGED
|
@@ -76,22 +76,43 @@ export class RemoteHost {
|
|
|
76
76
|
case "attach": // a follower joined — send a full snapshot BEFORE any further delta (§8)
|
|
77
77
|
this.sendSnapshot();
|
|
78
78
|
break;
|
|
79
|
+
// Drive frames (follower -> host actions). Defense-in-depth: the relay is SUPPOSED to only
|
|
80
|
+
// ever forward a frame that belongs to this connection's session, but a relay bug or a
|
|
81
|
+
// compromised relay could still hand us a stray/spoofed frame for a different session — so
|
|
82
|
+
// never act on one until it's checked against our own sessionId (+ ownerSub, if the frame
|
|
83
|
+
// carries one). isOwnFrame() also refuses everything before "welcome" has set sessionId.
|
|
79
84
|
case "prompt":
|
|
80
|
-
if (typeof f.payload?.text === "string")
|
|
85
|
+
if (this.isOwnFrame(f) && typeof f.payload?.text === "string")
|
|
81
86
|
this.cb.onPrompt(f.payload.text);
|
|
82
87
|
break;
|
|
83
88
|
case "approval_response":
|
|
84
|
-
if (f.payload?.id)
|
|
89
|
+
if (this.isOwnFrame(f) && f.payload?.id)
|
|
85
90
|
this.cb.onApprovalResponse(String(f.payload.id), !!f.payload.approve);
|
|
86
91
|
break;
|
|
92
|
+
case "ask_user_response":
|
|
93
|
+
if (this.isOwnFrame(f) && f.payload?.id)
|
|
94
|
+
this.cb.onAskUserResponse(String(f.payload.id), String(f.payload?.answer ?? ""));
|
|
95
|
+
break;
|
|
87
96
|
case "interrupt":
|
|
88
|
-
this.
|
|
97
|
+
if (this.isOwnFrame(f))
|
|
98
|
+
this.cb.onInterrupt();
|
|
89
99
|
break;
|
|
90
100
|
case "error":
|
|
91
101
|
this.cb.onState?.("error", f.payload?.message ?? f.payload?.code);
|
|
92
102
|
break;
|
|
93
103
|
}
|
|
94
104
|
}
|
|
105
|
+
/** True iff a drive frame's sessionId matches ours (and its ownerSub too, when the frame carries
|
|
106
|
+
* one — the relay doesn't always stamp it, so its absence is not itself a rejection). Before
|
|
107
|
+
* "welcome" there's no sessionId to compare against yet, so nothing drive-worthy is trusted. */
|
|
108
|
+
isOwnFrame(f) {
|
|
109
|
+
if (!this.sessionId || f.sessionId !== this.sessionId)
|
|
110
|
+
return false;
|
|
111
|
+
const claimedOwner = f.payload?.ownerSub;
|
|
112
|
+
if (this.ownerSub && claimedOwner !== undefined && claimedOwner !== this.ownerSub)
|
|
113
|
+
return false;
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
95
116
|
send(type, sessionId, payload, seq = null) {
|
|
96
117
|
if (!this.ws || this.ws.readyState !== 1)
|
|
97
118
|
return;
|
|
@@ -169,4 +190,9 @@ export class RemoteHost {
|
|
|
169
190
|
setActivity(state, label) { this.activity = state; this.state("activity", { state, ...(label ? { label } : {}) }); }
|
|
170
191
|
setStatus(ctxPct, route) { this.ctxPct = ctxPct; this.route = route; this.state("status", { ctxPct, route }); }
|
|
171
192
|
approvalRequest(id, tool, args) { this.state("approval_request", { id, tool, args }); }
|
|
193
|
+
/** Mirrors an ask_user clarification to followers — a DISTINCT frame type from approval_request
|
|
194
|
+
* (not folded into it), matching the web/mobile follower's contract. A local answer and a
|
|
195
|
+
* follower's ask_user_response race first-wins in the host (settleQuestion in cli.tsx); local
|
|
196
|
+
* ask_user keeps working unchanged when no remote-control session is active. */
|
|
197
|
+
askUser(id, question, options) { this.state("ask_user", { id, question, options }); }
|
|
172
198
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const DEFAULT_MODEL_ID = "aurora-1m";
|
|
2
|
+
export const BUILTIN_MODELS = [
|
|
3
|
+
{ id: "aurora-1m", label: "Aurora 1M", kind: "single", desc: "1,048,576-token context (:8097)", endpoint: "http://127.0.0.1:8097/v1", model: "aurora-code-1", ctx: 1048576 },
|
|
4
|
+
{ id: "aurora-128k", label: "Aurora 128K", kind: "single", desc: "128K context, lighter RAM (:8096)", endpoint: "http://127.0.0.1:8096/v1", model: "aurora-code-1", ctx: 131072 },
|
|
5
|
+
{ id: "moa", label: "MOA (Mixture of Agents)", kind: "orchestrated", desc: "fan out to proposers, synthesize with an aggregator" },
|
|
6
|
+
];
|
|
7
|
+
/** The runtime registry: the built-ins, with any settings.models entries merged in (overriding a
|
|
8
|
+
* built-in by id, or adding a new one) — same shape either way, so /model doesn't care which. */
|
|
9
|
+
export function modelRegistry(overrides) {
|
|
10
|
+
if (!overrides?.length)
|
|
11
|
+
return BUILTIN_MODELS;
|
|
12
|
+
const byId = new Map(BUILTIN_MODELS.map((m) => [m.id, m]));
|
|
13
|
+
for (const m of overrides)
|
|
14
|
+
byId.set(m.id, { ...byId.get(m.id), ...m });
|
|
15
|
+
return [...byId.values()];
|
|
16
|
+
}
|
|
17
|
+
export function findModel(registry, id) {
|
|
18
|
+
return registry.find((m) => m.id === id);
|
|
19
|
+
}
|
|
20
|
+
/** Pure selection reducer for /model — no I/O (no settings read/write, no router mutation), so it's
|
|
21
|
+
* directly testable. The moa-needs-config check lives in Session.setModel (it needs settings.moa,
|
|
22
|
+
* which this module intentionally doesn't import). */
|
|
23
|
+
export function selectModel(registry, id) {
|
|
24
|
+
const profile = findModel(registry, id);
|
|
25
|
+
if (!profile)
|
|
26
|
+
return { error: `unknown model "${id}" — choices: ${registry.map((m) => m.id).join(", ")}` };
|
|
27
|
+
if (profile.kind === "single" && !profile.endpoint)
|
|
28
|
+
return { error: `model "${id}" has no endpoint configured` };
|
|
29
|
+
return { profile };
|
|
30
|
+
}
|
|
31
|
+
/** Strip a trailing /v1 so a ModelProfile/MoaAggregator endpoint can feed the AuroraRouter, whose
|
|
32
|
+
* base is bare (engine/aurora.ts's chat() appends /v1/chat/completions itself). */
|
|
33
|
+
export function endpointBase(endpoint) {
|
|
34
|
+
return endpoint.replace(/\/v1\/?$/, "");
|
|
35
|
+
}
|
package/dist/session.js
CHANGED
|
@@ -6,7 +6,9 @@ import { Conversation } from "./engine/messages.js";
|
|
|
6
6
|
import { chat, health } from "./engine/aurora.js";
|
|
7
7
|
import { summaryPrompt, compact } from "./engine/compaction.js";
|
|
8
8
|
import { engineRouter } from "./engine/router-adapter.js";
|
|
9
|
+
import { fanOutProposers, labelDrafts, DEFAULT_AGGREGATOR_PROMPT } from "./engine/moa.js";
|
|
9
10
|
import { AuroraRouter } from "./router/router.js";
|
|
11
|
+
import { modelRegistry, findModel, selectModel, endpointBase, DEFAULT_MODEL_ID } from "./router/models.js";
|
|
10
12
|
import { Executor } from "./tools/executor.js";
|
|
11
13
|
import { toSchemas, registry } from "./tools/registry.js";
|
|
12
14
|
import { MemoryStore } from "./memory/index.js";
|
|
@@ -74,8 +76,11 @@ function makeAskTool(handler) {
|
|
|
74
76
|
const SUMMARY_MAX_TOKENS = 1200; // room for Aurora's reasoning before the summary content lands
|
|
75
77
|
export class Session {
|
|
76
78
|
convo = new Conversation();
|
|
77
|
-
inner;
|
|
78
|
-
router;
|
|
79
|
+
inner; // was readonly — /model rebuilds it for a "single" profile switch
|
|
80
|
+
router; // rebuilt alongside inner (setModel)
|
|
81
|
+
registry; // /model's choices — built-ins + any settings.models
|
|
82
|
+
moaConfig;
|
|
83
|
+
modelId = DEFAULT_MODEL_ID; // active /model selection
|
|
79
84
|
executor;
|
|
80
85
|
localSchemas;
|
|
81
86
|
hub;
|
|
@@ -115,6 +120,14 @@ export class Session {
|
|
|
115
120
|
this.localSchemas = toSchemas(reg);
|
|
116
121
|
this.inner = cfg.router ?? new AuroraRouter();
|
|
117
122
|
this.router = engineRouter(this.inner);
|
|
123
|
+
this.registry = modelRegistry(cfg.models);
|
|
124
|
+
this.moaConfig = cfg.moa;
|
|
125
|
+
// Apply the persisted /model choice, unless a router was explicitly injected (tests / bg agents
|
|
126
|
+
// pinned to a fixed endpoint) — an injected router owns routing, /model doesn't override it.
|
|
127
|
+
if (!cfg.router && cfg.activeModel && cfg.activeModel !== DEFAULT_MODEL_ID) {
|
|
128
|
+
if (!this.setModel(cfg.activeModel).ok)
|
|
129
|
+
this.modelId = DEFAULT_MODEL_ID; // unavailable at startup → quiet fallback
|
|
130
|
+
}
|
|
118
131
|
this.systemPrompt = cfg.systemPrompt;
|
|
119
132
|
this.maxTokens = cfg.maxTokens ?? 2048;
|
|
120
133
|
this.temperature = cfg.temperature ?? 0.7;
|
|
@@ -237,10 +250,38 @@ export class Session {
|
|
|
237
250
|
turnCount() {
|
|
238
251
|
return this.convo.all.filter((m) => m.role === "user").length;
|
|
239
252
|
}
|
|
240
|
-
/** Currently-selected endpoint name (for /model). */
|
|
253
|
+
/** Currently-selected endpoint name (for /route, and a single-profile /model turn's status). */
|
|
241
254
|
currentRoute() {
|
|
242
255
|
return this.inner.currentName();
|
|
243
256
|
}
|
|
257
|
+
/** All model profiles the owner can pick between (/model) — built-ins plus any settings.models
|
|
258
|
+
* overrides passed in at construction. */
|
|
259
|
+
modelRegistry() {
|
|
260
|
+
return this.registry;
|
|
261
|
+
}
|
|
262
|
+
/** The active /model selection (id), for the status line + persistence. */
|
|
263
|
+
currentModel() {
|
|
264
|
+
return this.modelId;
|
|
265
|
+
}
|
|
266
|
+
/** Switch the active model (/model). A "single" profile rebuilds the router to point at that
|
|
267
|
+
* endpoint — no server is started/stopped, this only changes which endpoint THIS session talks
|
|
268
|
+
* to. "moa" has no endpoint of its own; send() special-cases it (sendMoa) instead. Returns an
|
|
269
|
+
* error instead of throwing, so the shell can show it inline: an unknown id, or "moa" selected
|
|
270
|
+
* with no settings.moa configured. */
|
|
271
|
+
setModel(id) {
|
|
272
|
+
const { profile, error } = selectModel(this.registry, id);
|
|
273
|
+
if (error || !profile)
|
|
274
|
+
return { ok: false, error };
|
|
275
|
+
if (profile.kind === "orchestrated" && !this.moaConfig?.proposers?.length) {
|
|
276
|
+
return { ok: false, error: `MOA needs a "moa" block (proposers + aggregator) in settings.json — see MOA-DESIGN.md` };
|
|
277
|
+
}
|
|
278
|
+
if (profile.kind === "single" && profile.endpoint) {
|
|
279
|
+
this.inner = new AuroraRouter([{ name: profile.id, base: endpointBase(profile.endpoint), model: profile.model ?? profile.id, ctxLimit: profile.ctx ?? this.inner.ctxLimit() }]);
|
|
280
|
+
this.router = engineRouter(this.inner);
|
|
281
|
+
}
|
|
282
|
+
this.modelId = profile.id;
|
|
283
|
+
return { ok: true };
|
|
284
|
+
}
|
|
244
285
|
/** The full conversation, for persistence (auto-save / --resume). */
|
|
245
286
|
snapshot() {
|
|
246
287
|
return this.convo.all.map((m) => ({ ...m }));
|
|
@@ -316,22 +357,65 @@ export class Session {
|
|
|
316
357
|
return this.memory.recallText(query, limit);
|
|
317
358
|
}
|
|
318
359
|
/** Run one user turn to completion, streaming via handlers. Resolves with the settled outcome;
|
|
319
|
-
* an interrupt resolves (interrupted:true), it does not throw — only a real transport error does.
|
|
360
|
+
* an interrupt resolves (interrupted:true), it does not throw — only a real transport error does.
|
|
361
|
+
* Dispatches to sendMoa when the active /model is "moa"; otherwise runs the normal single-model
|
|
362
|
+
* turn against whatever setModel last pointed the router at. */
|
|
320
363
|
async send(text, h = {}) {
|
|
321
364
|
if (this.ctrl)
|
|
322
365
|
throw new Error("Session.send called while a turn is in flight — serialize turns (the shell queues input)");
|
|
323
366
|
await this.maybeRecall(text); // fold past-session memory into the system prompt on the first turn
|
|
324
|
-
this.executor.resetTurn(); // clear the host executor's per-turn loop guard before this turn
|
|
325
367
|
this.inner.resetTurn(); // re-evaluate routing from the smallest endpoint + clear last turn's unhealthy set
|
|
368
|
+
const active = findModel(this.registry, this.modelId);
|
|
369
|
+
if (active?.kind === "orchestrated")
|
|
370
|
+
return this.sendMoa(text, h, active);
|
|
371
|
+
return this.execute(text, h, this.router, this.sysWithThink());
|
|
372
|
+
}
|
|
373
|
+
/** MOA turn (MOA-DESIGN.md): fan out to settings.moa's proposers in parallel, then run the
|
|
374
|
+
* aggregator through the SAME runTurn loop as a normal turn (execute) — pointed at the
|
|
375
|
+
* aggregator's endpoint, with the labelled drafts + aggregator_prompt folded into the system
|
|
376
|
+
* prompt. That reuse is what makes tool-calling, streaming, self-heal and telemetry "just work"
|
|
377
|
+
* for the aggregator without a second implementation. Zero survivors falls back to aurora-1m for
|
|
378
|
+
* this (and, until /model moa again, every subsequent) turn — a clear note prefixes the reply. */
|
|
379
|
+
async sendMoa(text, h, active) {
|
|
380
|
+
const moa = this.moaConfig; // setModel refuses to select "moa" without this
|
|
381
|
+
const history = [...this.convo.all, { role: "user", content: text }];
|
|
382
|
+
const drafts = await fanOutProposers(moa.proposers, history);
|
|
383
|
+
const survivors = drafts.filter((d) => d.content);
|
|
384
|
+
this.telemetry.record({
|
|
385
|
+
type: "moa",
|
|
386
|
+
proposers: moa.proposers.map((p) => p.id),
|
|
387
|
+
survived: survivors.map((d) => d.id),
|
|
388
|
+
latenciesMs: Object.fromEntries(drafts.map((d) => [d.id, d.ms])),
|
|
389
|
+
});
|
|
390
|
+
if (!survivors.length) {
|
|
391
|
+
h.onRoute?.(active.id, this.ctxPct());
|
|
392
|
+
this.modelId = DEFAULT_MODEL_ID; // fall back for this and future turns until /model moa retries
|
|
393
|
+
const note = "MOA: every proposer failed or timed out — falling back to aurora-1m for this reply.\n\n";
|
|
394
|
+
h.onDelta?.(note);
|
|
395
|
+
const res = await this.execute(text, h, this.router, this.sysWithThink());
|
|
396
|
+
return { ...res, content: note + res.content };
|
|
397
|
+
}
|
|
398
|
+
const aggRouter = engineRouter(new AuroraRouter([
|
|
399
|
+
{ name: moa.aggregator.id, base: endpointBase(moa.aggregator.endpoint), model: moa.aggregator.model, ctxLimit: this.inner.ctxLimit() },
|
|
400
|
+
]));
|
|
401
|
+
const aggSys = `${this.sysWithThink() ?? ""}\n\n## MOA aggregation\n${moa.aggregator_prompt ?? DEFAULT_AGGREGATOR_PROMPT}\n\n${labelDrafts(drafts)}`;
|
|
402
|
+
return this.execute(text, h, aggRouter, aggSys, moa.aggregator.id);
|
|
403
|
+
}
|
|
404
|
+
/** Shared turn execution: runs the tool-calling loop (runTurn) against the given router + system
|
|
405
|
+
* prompt, streaming via handlers, and records telemetry. Used by both a normal single-model turn
|
|
406
|
+
* (send) and a MOA aggregator turn (sendMoa) — the only difference between them is which router
|
|
407
|
+
* and system prompt they pass in. */
|
|
408
|
+
async execute(text, h, router, sys, routeLabel) {
|
|
409
|
+
this.executor.resetTurn(); // clear the host executor's per-turn loop guard before this turn
|
|
326
410
|
const controller = new AbortController();
|
|
327
411
|
this.ctrl = controller;
|
|
328
412
|
const _t0 = performance.now();
|
|
329
413
|
try {
|
|
330
414
|
const res = await runTurn(text, this.convo, {
|
|
331
|
-
router
|
|
415
|
+
router,
|
|
332
416
|
tools: this.tools,
|
|
333
417
|
toolSchemas: this.allSchemas(),
|
|
334
|
-
systemPrompt:
|
|
418
|
+
systemPrompt: sys,
|
|
335
419
|
summarize: this.summarize,
|
|
336
420
|
maxTokens: this.maxTokens,
|
|
337
421
|
temperature: this.temperature,
|
|
@@ -339,7 +423,7 @@ export class Session {
|
|
|
339
423
|
signal: controller.signal,
|
|
340
424
|
onDelta: h.onDelta,
|
|
341
425
|
onReasoning: h.onReasoning,
|
|
342
|
-
onRoute: (ep) => h.onRoute?.(ep.label ?? "aurora", this.ctxPct()),
|
|
426
|
+
onRoute: (ep) => h.onRoute?.(routeLabel ?? ep.label ?? "aurora", this.ctxPct()),
|
|
343
427
|
onToolStart: h.onToolStart,
|
|
344
428
|
onToolBatch: h.onToolBatch,
|
|
345
429
|
onAutoContinue: h.onAutoContinue,
|
package/dist/tools/registry.js
CHANGED
|
@@ -14,35 +14,47 @@ import { ensureSearxng, noteSearxngUsed } from "./searxng.js";
|
|
|
14
14
|
function str(v, fallback = "") {
|
|
15
15
|
return v === undefined || v === null ? fallback : String(v);
|
|
16
16
|
}
|
|
17
|
+
// One persistent shell per Operator process (frontier-grade: cwd/env/venv persist across calls,
|
|
18
|
+
// like a real terminal — so the model sources a venv or `cd`s ONCE, not on every call). Lazily
|
|
19
|
+
// created; survives for the process lifetime.
|
|
20
|
+
let _shellSession = null;
|
|
21
|
+
async function getShellSession() {
|
|
22
|
+
if (!_shellSession) {
|
|
23
|
+
const { ShellSession } = await import("./shell-session.js");
|
|
24
|
+
_shellSession = new ShellSession();
|
|
25
|
+
}
|
|
26
|
+
return _shellSession;
|
|
27
|
+
}
|
|
28
|
+
/** Kill the persistent shell (and its process group) on process shutdown so it never orphans.
|
|
29
|
+
* Wired into the CLI's exit/SIGTERM handlers — no-op if a shell was never started. */
|
|
30
|
+
export function disposeShellSession() {
|
|
31
|
+
_shellSession?.dispose();
|
|
32
|
+
_shellSession = null;
|
|
33
|
+
}
|
|
17
34
|
async function shellExec(args) {
|
|
18
35
|
const command = str(args.command);
|
|
19
36
|
if (!command)
|
|
20
37
|
return "error: no command given";
|
|
21
|
-
const cwd = args.cwd ? expandPath(str(args.cwd)) : undefined;
|
|
22
38
|
const timeout = Number(args.timeout_ms ?? 120_000);
|
|
23
|
-
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
const fmt = (o, err) => (o + (err ? `\n[stderr]\n${err}` : "")).trim();
|
|
39
|
+
// A `cwd` arg is scoped to this one call (subshell) so it doesn't silently move the persistent
|
|
40
|
+
// session's directory; an explicit `cd` INSIDE the command persists, exactly like a terminal.
|
|
41
|
+
const cwd = args.cwd ? expandPath(str(args.cwd)) : undefined;
|
|
42
|
+
const toRun = cwd ? `( cd ${JSON.stringify(cwd)} && { ${command}; } )` : command;
|
|
28
43
|
try {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// on no-match, `| head` can SIGPIPE a producer, `test`/`diff` signal via exit code. So NEVER discard
|
|
35
|
-
// real output — surface it. Only when there's genuinely nothing do we report the exit tersely.
|
|
36
|
-
const out = fmt(String(e.stdout ?? ""), String(e.stderr ?? ""));
|
|
37
|
-
if (e.code === "ERR_CHILD_PROCESS_STDIO_MAXBUFFER") {
|
|
38
|
-
return (out ? out + "\n" : "") + `[output exceeded ${Math.round(MAXBUF / 1e6)}MB and was truncated — narrow it: add a path, pipe to \`head\`, or use \`grep -l\`/\`grep -c\`]`;
|
|
39
|
-
}
|
|
40
|
-
if (e.killed || /ETIMEDOUT|timed out/i.test(String(e.message ?? ""))) {
|
|
41
|
-
return (out ? out + "\n" : "") + `[timed out after ${timeout}ms — narrow the command or pass a larger timeout_ms]`;
|
|
44
|
+
const sess = await getShellSession();
|
|
45
|
+
const r = await sess.run(toRun, timeout);
|
|
46
|
+
let out = r.output || "";
|
|
47
|
+
if (r.timedOut) {
|
|
48
|
+
return (out ? out + "\n" : "") + `[timed out after ${timeout}ms — the shell was reset (cwd/env cleared); narrow the command or pass a larger timeout_ms]`;
|
|
42
49
|
}
|
|
50
|
+
if (r.truncated)
|
|
51
|
+
out += `\n[output truncated at 8MB — narrow it: add a path, pipe to \`head\`, or use \`grep -l\`/\`grep -c\`]`;
|
|
43
52
|
if (out)
|
|
44
|
-
return out; //
|
|
45
|
-
return `(no output; exit ${
|
|
53
|
+
return out; // real output — including non-zero exits (grep no-match, diff, test)
|
|
54
|
+
return r.exitCode === 0 ? "(no output)" : `(no output; exit ${r.exitCode ?? "?"})`;
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
return `error running command: ${String(e?.message ?? e)}`;
|
|
46
58
|
}
|
|
47
59
|
}
|
|
48
60
|
// Un-ranged reads default to a bounded window (like the host Read tool) instead of dumping an entire
|
|
@@ -490,8 +502,25 @@ async function taskUpdate(args) {
|
|
|
490
502
|
}
|
|
491
503
|
const TOOLS = [
|
|
492
504
|
{
|
|
505
|
+
name: "bash", safe: false,
|
|
506
|
+
description: "Run a bash command in a PERSISTENT shell session — a real terminal that stays open across " +
|
|
507
|
+
"calls. State PERSISTS: a `cd`, an exported variable, an activated venv, or a defined function " +
|
|
508
|
+
"in one call is still in effect on the next. So set things up ONCE and reuse them — do NOT " +
|
|
509
|
+
"re-run `source .../activate && ...` or re-`cd` on every call; activate/enter once, then just " +
|
|
510
|
+
"run the command. stdout and stderr come back merged (like a terminal) with the exit code. " +
|
|
511
|
+
"Optional `cwd` runs that one command in a subshell without moving the session. For a " +
|
|
512
|
+
"long-running server/build/watcher use shell_background instead so this shell isn't blocked.",
|
|
513
|
+
parameters: { type: "object", properties: {
|
|
514
|
+
command: { type: "string", description: "the bash command to run in the persistent shell" },
|
|
515
|
+
cwd: { type: "string", description: "optional: run this one command from here (scoped; does not move the session)" },
|
|
516
|
+
timeout_ms: { type: "number", description: "optional per-command timeout (default 120000); on timeout the shell is reset" },
|
|
517
|
+
}, required: ["command"] },
|
|
518
|
+
run: shellExec,
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
// Back-compat alias: older prompts/skills call `shell_exec`. Same persistent-session engine as `bash`.
|
|
493
522
|
name: "shell_exec", safe: false,
|
|
494
|
-
description: "
|
|
523
|
+
description: "Alias of `bash` — runs a command in the same persistent shell session (state persists across calls).",
|
|
495
524
|
parameters: { type: "object", properties: {
|
|
496
525
|
command: { type: "string" }, cwd: { type: "string" }, timeout_ms: { type: "number" },
|
|
497
526
|
}, required: ["command"] },
|
package/dist/tools/sandbox.js
CHANGED
|
@@ -204,3 +204,14 @@ export async function wrapShell(command) {
|
|
|
204
204
|
}
|
|
205
205
|
return { file: "/bin/bash", args: ["-c", command] };
|
|
206
206
|
}
|
|
207
|
+
/** Argv for a PERSISTENT interactive shell (reads commands on stdin) under the same OS sandbox
|
|
208
|
+
* as wrapShell. Used by ShellSession so cwd/env persist across bash tool calls like a real
|
|
209
|
+
* terminal. `-i` is deliberately omitted: an interactive shell would emit prompts/job-control
|
|
210
|
+
* noise; the session drives framing itself with a sentinel. */
|
|
211
|
+
export async function wrapInteractiveShell() {
|
|
212
|
+
const mode = sandboxMode();
|
|
213
|
+
if (mode !== "off" && (await hasSandboxExec())) {
|
|
214
|
+
return { file: "/usr/bin/sandbox-exec", args: ["-p", seatbeltProfile(mode), "/bin/bash", "-s"] };
|
|
215
|
+
}
|
|
216
|
+
return { file: "/bin/bash", args: ["-s"] };
|
|
217
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Persistent interactive shell — the difference between a clumsy one-shot exec and a frontier
|
|
2
|
+
// bash tool. A single bash process is kept alive per Operator session, so `cd`, exported env
|
|
3
|
+
// vars, activated venvs and shell functions PERSIST across bash tool calls exactly like a real
|
|
4
|
+
// terminal. This is why the model no longer needs to re-run `source .../activate && ...` on
|
|
5
|
+
// every call: it sources once and the state sticks.
|
|
6
|
+
//
|
|
7
|
+
// Framing: each command is written to the shell's stdin followed by a sentinel that prints a
|
|
8
|
+
// unique nonce and `$?`. We read stdout+stderr (merged, like a terminal) until the sentinel
|
|
9
|
+
// line appears; everything before it is the command's output, and the nonce line carries the
|
|
10
|
+
// exit code. On a per-command timeout we kill and transparently respawn the shell (cwd/env are
|
|
11
|
+
// lost only in that exceptional case), so a runaway command can never wedge the session.
|
|
12
|
+
//
|
|
13
|
+
// node-only; imported lazily from the tool layer so the neutral (mobile) bundle never pulls it.
|
|
14
|
+
import { wrapInteractiveShell } from "./sandbox.js";
|
|
15
|
+
const SENTINEL = "__KODE_SH_DONE__";
|
|
16
|
+
const OUTPUT_CAP = 8 * 1024 * 1024; // 8MB per command; beyond this we truncate and say so
|
|
17
|
+
export class ShellSession {
|
|
18
|
+
proc = null;
|
|
19
|
+
buf = "";
|
|
20
|
+
cwd;
|
|
21
|
+
starting = null;
|
|
22
|
+
constructor(cwd) {
|
|
23
|
+
this.cwd = cwd;
|
|
24
|
+
}
|
|
25
|
+
async ensure() {
|
|
26
|
+
if (this.proc && this.proc.exitCode === null && !this.proc.killed)
|
|
27
|
+
return;
|
|
28
|
+
if (this.starting)
|
|
29
|
+
return this.starting;
|
|
30
|
+
this.starting = (async () => {
|
|
31
|
+
const { spawn } = await import("node:child_process");
|
|
32
|
+
const { file, args } = await wrapInteractiveShell();
|
|
33
|
+
const p = spawn(file, args, {
|
|
34
|
+
cwd: this.cwd,
|
|
35
|
+
env: { ...process.env, PS1: "", PROMPT_COMMAND: "", TERM: "dumb" },
|
|
36
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
37
|
+
detached: true, // own process group, so killShell() can reap grandchildren (`&` jobs), not just bash
|
|
38
|
+
});
|
|
39
|
+
p.stdout.setEncoding("utf8");
|
|
40
|
+
p.stderr.setEncoding("utf8");
|
|
41
|
+
const onData = (d) => { this.buf += d; };
|
|
42
|
+
p.stdout.on("data", onData);
|
|
43
|
+
p.stderr.on("data", onData); // merge stderr into the same stream, like a real terminal
|
|
44
|
+
p.on("exit", () => { this.proc = null; });
|
|
45
|
+
p.on("error", () => { this.proc = null; });
|
|
46
|
+
// A write to a closed pipe (e.g. a timeout-kill racing an in-flight write) emits 'error' on stdin;
|
|
47
|
+
// unhandled, Node throws and takes down the whole CLI. Swallow it — the run loop already fails safe.
|
|
48
|
+
p.stdin.on("error", () => { });
|
|
49
|
+
this.proc = p;
|
|
50
|
+
// Don't let the long-lived shell (or its pipes) keep the process alive at exit — a tool's
|
|
51
|
+
// background shell must never block Operator (or a test runner) from exiting cleanly.
|
|
52
|
+
// Streams over pipes are Sockets (which have unref) but TS types them as Readable/Writable
|
|
53
|
+
// (no unref); cast. p.unref() on the ChildProcess is the load-bearing one.
|
|
54
|
+
try {
|
|
55
|
+
p.unref();
|
|
56
|
+
p.stdout?.unref?.();
|
|
57
|
+
p.stderr?.unref?.();
|
|
58
|
+
p.stdin?.unref?.();
|
|
59
|
+
}
|
|
60
|
+
catch { /* */ }
|
|
61
|
+
// Quiet the shell and disable history expansion so commands frame cleanly.
|
|
62
|
+
p.stdin.write("export PS1='' PROMPT_COMMAND=''; set +o history 2>/dev/null; true\n");
|
|
63
|
+
await new Promise((r) => setTimeout(r, 30));
|
|
64
|
+
this.buf = "";
|
|
65
|
+
})();
|
|
66
|
+
try {
|
|
67
|
+
await this.starting;
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
this.starting = null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// One FIFO for ALL run() calls. Background sub-agents share this process-wide shell, so without
|
|
74
|
+
// serialization two concurrent calls would stomp each other's buffer/sentinel and cross-deliver
|
|
75
|
+
// output + exit codes. The queue makes overlapping calls wait their turn on the one real shell.
|
|
76
|
+
queue = Promise.resolve();
|
|
77
|
+
/** Run one command in the persistent shell and return its merged output + exit code.
|
|
78
|
+
* Serialized: concurrent callers execute one-at-a-time in arrival order. */
|
|
79
|
+
run(command, timeoutMs = 120_000) {
|
|
80
|
+
const prev = this.queue;
|
|
81
|
+
let release;
|
|
82
|
+
this.queue = new Promise((r) => (release = r));
|
|
83
|
+
return prev.catch(() => { }).then(() => this.runLocked(command, timeoutMs)).finally(() => release());
|
|
84
|
+
}
|
|
85
|
+
async runLocked(command, timeoutMs = 120_000) {
|
|
86
|
+
await this.ensure();
|
|
87
|
+
const p = this.proc;
|
|
88
|
+
if (!p)
|
|
89
|
+
return { output: "error: shell failed to start", exitCode: null, timedOut: false, truncated: false };
|
|
90
|
+
const nonce = Math.random().toString(36).slice(2, 10);
|
|
91
|
+
const marker = `${SENTINEL}${nonce}`;
|
|
92
|
+
this.buf = "";
|
|
93
|
+
p.stdin.write(`${command}\nprintf '\\n%s:%s\\n' '${marker}' "$?"\n`);
|
|
94
|
+
// Require the leading newline printf always emits, so the marker only matches at start-of-line —
|
|
95
|
+
// a command's own output can't spoof "<random-nonce marker>:<digits>" as the last chars of a line.
|
|
96
|
+
const re = new RegExp(`\\n${marker}:(-?\\d+)\\r?\\n`);
|
|
97
|
+
const HARD_BUF = OUTPUT_CAP * 4; // bound memory even if the sentinel never arrives (e.g. `yes`)
|
|
98
|
+
const deadline = Date.now() + Math.max(1000, timeoutMs);
|
|
99
|
+
const finish = (out, exitCode, timedOut, truncated) => {
|
|
100
|
+
if (timedOut || exitCode === null) {
|
|
101
|
+
this.killShell(p);
|
|
102
|
+
this.proc = null;
|
|
103
|
+
}
|
|
104
|
+
this.buf = "";
|
|
105
|
+
return { output: out.replace(/\r/g, "").replace(/\n+$/, ""), exitCode, timedOut, truncated };
|
|
106
|
+
};
|
|
107
|
+
while (true) {
|
|
108
|
+
const m = this.buf.match(re);
|
|
109
|
+
if (m) {
|
|
110
|
+
const raw = this.buf.slice(0, m.index);
|
|
111
|
+
return finish(raw.length > OUTPUT_CAP ? raw.slice(0, OUTPUT_CAP) : raw, Number(m[1]), false, raw.length > OUTPUT_CAP);
|
|
112
|
+
}
|
|
113
|
+
// Shell died mid-command (crash / `exit` / OOM-kill): fail fast instead of spinning to the deadline.
|
|
114
|
+
if (p.exitCode !== null || this.proc !== p)
|
|
115
|
+
return finish(this.buf.slice(0, OUTPUT_CAP), null, false, false);
|
|
116
|
+
// Runaway output that never reaches the sentinel: stop before it balloons memory.
|
|
117
|
+
if (this.buf.length > HARD_BUF)
|
|
118
|
+
return finish(this.buf.slice(0, OUTPUT_CAP), null, false, true);
|
|
119
|
+
if (Date.now() > deadline)
|
|
120
|
+
return finish(this.buf.slice(0, OUTPUT_CAP), null, true, false);
|
|
121
|
+
await new Promise((r) => setTimeout(r, 15));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** SIGKILL the shell AND its process group (spawned detached), so backgrounded grandchildren (`&` jobs)
|
|
125
|
+
* don't survive as orphans. Falls back to a plain kill if the group signal fails. */
|
|
126
|
+
killShell(p) {
|
|
127
|
+
try {
|
|
128
|
+
if (p?.pid)
|
|
129
|
+
process.kill(-p.pid, "SIGKILL");
|
|
130
|
+
else
|
|
131
|
+
p?.kill("SIGKILL");
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
try {
|
|
135
|
+
p?.kill("SIGKILL");
|
|
136
|
+
}
|
|
137
|
+
catch { /* already gone */ }
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
dispose() {
|
|
141
|
+
this.killShell(this.proc);
|
|
142
|
+
this.proc = null;
|
|
143
|
+
this.buf = "";
|
|
144
|
+
}
|
|
145
|
+
}
|
package/dist/ui/App.js
CHANGED
|
@@ -10,10 +10,10 @@ import { BgPanel } from "./BgPanel.js";
|
|
|
10
10
|
import { ApprovalPrompt } from "./ApprovalPrompt.js";
|
|
11
11
|
import { QuestionPrompt } from "./QuestionPrompt.js";
|
|
12
12
|
export function App(props) {
|
|
13
|
-
const { messages, live = null, status, thinkingVerb, verbs, stepLabel, route, ctxPct, version, build, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, onSubmit, onQueue, onInterrupt, approval = null, onApprovalDecide, question = null } = props;
|
|
13
|
+
const { messages, live = null, status, thinkingVerb, verbs, stepLabel, route, ctxPct, version, build, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, onSubmit, onQueue, onInterrupt, approval = null, onApprovalDecide, question = null, modelPicker = null } = props;
|
|
14
14
|
const thinking = status === "thinking" || status === "streaming";
|
|
15
15
|
const showSpinner = status === "recovering" || status === "executing" || thinking;
|
|
16
16
|
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Transcript, { entries: messages, live: live }), showSpinner && (_jsx(Box, { marginTop: 1, marginBottom: 1, children: status === "recovering" ? _jsx(RecoverSpinner, { active: true, label: stepLabel })
|
|
17
17
|
: status === "executing" ? _jsx(StepSpinner, { active: true, label: stepLabel })
|
|
18
|
-
: _jsx(ThinkingSpinner, { active: true, verb: thinkingVerb, verbs: verbs, metrics: metrics }) })), _jsx(BgPanel, { agents: bgAgents }), _jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }) }), _jsx(QuestionPrompt, { pending: question }), _jsx(StatusRule, { route: route, ctxPct: ctxPct, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode, sessionTokens: sessionTokens }), _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, disabled: status !== "idle", suspended: !!approval || !!question }), _jsx(InputRule, {})] }));
|
|
18
|
+
: _jsx(ThinkingSpinner, { active: true, verb: thinkingVerb, verbs: verbs, metrics: metrics }) })), _jsx(BgPanel, { agents: bgAgents }), _jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }) }), _jsx(QuestionPrompt, { pending: question }), _jsx(QuestionPrompt, { pending: modelPicker }), _jsx(StatusRule, { route: route, ctxPct: ctxPct, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode, sessionTokens: sessionTokens }), _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, disabled: status !== "idle", suspended: !!approval || !!question || !!modelPicker }), _jsx(InputRule, {})] }));
|
|
19
19
|
}
|
|
@@ -28,7 +28,7 @@ export function questionKey(st, input, key, options) {
|
|
|
28
28
|
return {};
|
|
29
29
|
}
|
|
30
30
|
if (key.ctrl && input.toLowerCase() === "c")
|
|
31
|
-
return { resolve:
|
|
31
|
+
return { resolve: DISCUSS }; // bail = discuss, NEVER a silently-picked real answer
|
|
32
32
|
const chatIndex = options.length + 1;
|
|
33
33
|
const n = Number(input);
|
|
34
34
|
if (Number.isInteger(n) && n >= 1 && n <= options.length)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0perator/operator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.50",
|
|
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": {
|