@0perator/operator 0.1.335 → 0.1.337

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.
@@ -72,7 +72,7 @@ export function deriveDelegateSettings(base, profile, endpointOverride) {
72
72
  endpoints: {
73
73
  aurora: {
74
74
  base: endpoint,
75
- model: profile.model ?? profile.id,
75
+ model: endpointOverride ? (profile.model ?? profile.id) : (profile.endpointModels?.[0] ?? profile.model ?? profile.id),
76
76
  ctxWindow: profile.ctx ?? base.endpoints.aurora.ctxWindow,
77
77
  },
78
78
  },
@@ -120,8 +120,11 @@ export async function runDelegateTask(args, deps = defaultDeps) {
120
120
  const task = String(args.task ?? "").trim();
121
121
  if (!task)
122
122
  return "error: delegate_task needs a non-empty `task` — a self-contained subtask; the sub-agent sees nothing else";
123
- const modelId = String(args.model ?? "").trim() || DEFAULT_DELEGATE_MODEL;
124
123
  const settings = await deps.loadSettings();
124
+ // Default sub-agent model is a SETTING (autonomy.delegateModel), not a hardcode, so a new sub-agent can be
125
+ // dropped in by changing one value — the planner still overrides per call via `args.model`.
126
+ const defaultModel = (settings.autonomy?.delegateModel ?? "").trim() || DEFAULT_DELEGATE_MODEL;
127
+ const modelId = String(args.model ?? "").trim() || defaultModel;
125
128
  // Gate BYO providers (Claude/OpenAI/Gemini/Qwen/…) on the user actually having stored that provider's key,
126
129
  // the same check /model applies — so an unconnected provider fails fast with the actionable "store the key"
127
130
  // error BEFORE a sub-agent session is spun up (and before setModel would refuse it anyway, more expensively).
package/dist/cli.js CHANGED
@@ -515,6 +515,7 @@ const HELP = [
515
515
  " /clear clear the screen (keeps the conversation)",
516
516
  " /exit /quit leave operator",
517
517
  "esc — interrupt a running turn (or quit when idle)",
518
+ "while a turn runs: enter queues a message · esc sends it now · ↑ on an empty input edits the last queued · backspace on an empty input cancels it",
518
519
  ].join("\n");
519
520
  // Slash commands a remote-control FOLLOWER is allowed to drive (RemoteHost `command` frame →
520
521
  // SPEC/remote-session.md extension; see REMOTE_RICH_HEAD_AUDIT.md). This is BOTH the allowlist enforced
@@ -793,8 +794,8 @@ function Root() {
793
794
  setLive(has ? { kind: "message", message: { id: "live", role: "assistant", content: liveText.current, reasoning: liveReasoning.current || undefined } } : null);
794
795
  setLiveTok(liveTokRef.current);
795
796
  }, 64)).current;
796
- const queued = useRef("");
797
- const [queuedPreview, setQueuedPreview] = useState(""); // reactive mirror of the queue, shown above the composer so a type-while-thinking message is VISIBLE
797
+ const queued = useRef([]); // type-while-thinking messages, oldest first; drained as one turn when the turn ends
798
+ const [queuedPreview, setQueuedPreview] = useState([]); // reactive mirror of the queue, shown above the composer so a type-while-thinking message is VISIBLE
798
799
  const statusRef = useRef("idle");
799
800
  // Remote-control host (SPEC/remote-session.md): non-null only while /remotecontrol is active. Every
800
801
  // state mutation below also mirrors to it so attached followers see identical transcript/tool/activity.
@@ -1250,9 +1251,9 @@ function Root() {
1250
1251
  // Re-check capabilities after every turn: MCP discovery (first-turn only) may have just landed,
1251
1252
  // and any skill_fetch/skill_save this turn updated skillsRef above. A no-op diff never hits the wire.
1252
1253
  remoteRef.current?.setCapabilities(buildCapabilities());
1253
- const q = queued.current;
1254
- queued.current = "";
1255
- setQueuedPreview("");
1254
+ const q = queued.current.join("\n");
1255
+ queued.current = [];
1256
+ setQueuedPreview([]);
1256
1257
  if (q)
1257
1258
  submitRef.current(q);
1258
1259
  else
@@ -1268,7 +1269,7 @@ function Root() {
1268
1269
  const jobs = getJobNoticeMode() === "wake" && pendingJobNotices() > 0;
1269
1270
  if (!jobs && pendingAgentReports() === 0)
1270
1271
  return;
1271
- if (statusRef.current !== "idle" || queued.current)
1272
+ if (statusRef.current !== "idle" || queued.current.length)
1272
1273
  return;
1273
1274
  void sendTurn("", { wake: true });
1274
1275
  };
@@ -2468,7 +2469,19 @@ function Root() {
2468
2469
  void sendTurn(text);
2469
2470
  }, [sendTurn, handleSlash]);
2470
2471
  submitRef.current = onSubmit;
2471
- const onQueue = useCallback((text) => { queued.current = queued.current ? `${queued.current}\n${text}` : text; setQueuedPreview(queued.current); }, []);
2472
+ const onQueue = useCallback((text) => { queued.current = [...queued.current, text]; setQueuedPreview(queued.current); }, []);
2473
+ // ↑ / Backspace on an empty draft act on the most recent queued message: edit pops it back into the draft (Enter
2474
+ // re-queues it, or sends it if the turn has ended); drop discards it and echoes the full text so nothing vanishes silently.
2475
+ const popQueued = useCallback(() => {
2476
+ const text = queued.current.at(-1);
2477
+ if (text === undefined)
2478
+ return undefined;
2479
+ queued.current = queued.current.slice(0, -1);
2480
+ setQueuedPreview(queued.current);
2481
+ return text;
2482
+ }, []);
2483
+ const onDropQueued = useCallback(() => { const text = popQueued(); if (text !== undefined)
2484
+ sys(`queued message cancelled (not sent): ${text}`); }, [popQueued, sys]);
2472
2485
  // Shift+Tab cycles the operating mode (matches Claude Code). auto→manual→plan→auto. Auto drives with
2473
2486
  // no approval gate; Manual gates mutating tools through the approve() bridge; Plan is read-only research.
2474
2487
  const onCycleMode = useCallback(() => {
@@ -2591,7 +2604,7 @@ function Root() {
2591
2604
  ? `${spin} reading your prompt… (${fmtDuration(elapsed)})`
2592
2605
  : `${spin} ${fmtMeta(elapsed, liveTok)}`
2593
2606
  : metrics;
2594
- return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, prefill: prefill, liveTools: liveTools, route: route, ctxPct: ctxPct, ctxPin: ctxPin ? fmtCtx(ctxPin) : undefined, version: VERSION, fullscreen: FULLSCREEN, metrics: liveMetrics, sessionTokens: session.sessionTokens() + liveTok, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, shellJobs: shellJobs, onBackground: onBackground, tasks: tasks, onSubmit: onSubmit, onQueue: onQueue, queuedPreview: queuedPreview, onInterrupt: onInterrupt, onCycleMode: onCycleMode, onCycleContext: onCycleContext, opMode: opMode, rcConnected: rcConnected, rcActive: rcActive, caffeinated: caffeinated, approval: approval, question: question, modelPicker: modelPicker, secretPrompt: secretPrompt, planExitPicker: planExitPicker, artifactsPicker: artifactsPicker, sessionsPicker: sessionsPicker, onApprovalDecide: (allow, always) => {
2607
+ return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, prefill: prefill, liveTools: liveTools, route: route, ctxPct: ctxPct, ctxPin: ctxPin ? fmtCtx(ctxPin) : undefined, version: VERSION, fullscreen: FULLSCREEN, metrics: liveMetrics, sessionTokens: session.sessionTokens() + liveTok, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, shellJobs: shellJobs, onBackground: onBackground, tasks: tasks, onSubmit: onSubmit, onQueue: onQueue, queuedPreview: queuedPreview, onEditQueued: popQueued, onDropQueued: onDropQueued, onInterrupt: onInterrupt, onCycleMode: onCycleMode, onCycleContext: onCycleContext, opMode: opMode, rcConnected: rcConnected, rcActive: rcActive, caffeinated: caffeinated, approval: approval, question: question, modelPicker: modelPicker, secretPrompt: secretPrompt, planExitPicker: planExitPicker, artifactsPicker: artifactsPicker, sessionsPicker: sessionsPicker, onApprovalDecide: (allow, always) => {
2595
2608
  const cur = approval;
2596
2609
  if (cur)
2597
2610
  settleApproval(cur.id, allow, always); // first-wins with any remote follower answer
@@ -5,7 +5,6 @@
5
5
  import { readFileSync, appendFileSync, mkdirSync } from "node:fs";
6
6
  import { join, dirname } from "node:path";
7
7
  import { operatorPath } from "./home.js";
8
- import { scratchDirFor } from "./scratch.js";
9
8
  import { renderHarnessContext } from "./operator-harness.js";
10
9
  import { renderToolCatalogue } from "../tools/registry.js";
11
10
  import { renderSkillsIndex } from "./skills-index.js";
@@ -206,18 +205,19 @@ export function basePersona(cwd = process.cwd(), opts = {}) {
206
205
  `find, and verify by running.) I record the non-obvious WHY in the repo's _ai-docs/, and commit clean: ` +
207
206
  `a conventional \`type(scope): subject\` with explicit paths (never a blanket add in a shared checkout) ` +
208
207
  `and no AI / Co-Authored-By / Claude-Session trailers.` +
209
- `\n## This machine\nWorking dir: ${cwd}` +
210
- `\nScratch dir: ${scratchDirFor(cwd)} (also \`$OPERATOR_SCRATCH\` in every shell) — temporary scripts, probe ` +
208
+ `\n## This machine\nWorking dir and scratch dir: named in the session context at the top of the conversation.` +
209
+ `\nScratch dir (also \`$OPERATOR_SCRATCH\` in every shell) — temporary scripts, probe ` +
211
210
  `output, downloads to inspect, intermediate files: ALWAYS here, never /tmp and never the repo root. It is ` +
212
211
  `git-ignored and swept after a week, so nothing you keep belongs in it; name files \`<subject>-<thing>\`.` +
213
212
  ctxLine +
214
213
  `\n## Talking about yourself\nYou are Operator, whichever model is serving you — the model underneath can change between sessions (or mid-session with /model) and you are still Operator. When asked what you are or which model you run on, ` +
215
- `say you are Operator (AXE's agent) and give the context window above. Never name, guess or compare backend models (do not say ` +
216
- `"I am Cortana" or "this is Aurora"), and do not recite hostnames, IP addresses, ports, URLs or file paths for a model's server ` +
217
- `("running on <host> at <ip>:<port>") unless the owner asks where it runs or you need the address to do the task — you cannot see ` +
218
- `which backend answered; the footer and /model show the route. If the owner greets you by a model name ("hello cortana"), answer ` +
219
- `as Operator in the first person, briefly, without confirming or denying which model it is.` +
220
- `\n## Don't starve the serving model — decode is RAM-bound\nYour own model is served locally on THIS box. ` +
214
+ `say you are Operator (AXE's agent) running on the model named in the "Active model" section at the end of this prompt, and give ` +
215
+ `the context window above. Never guess the model from files, hostnames or other text in this prompt, and do not recite hostnames, ` +
216
+ `IP addresses, ports, URLs or file paths for a model's server ("running on <host> at <ip>:<port>") unless the owner asks where it ` +
217
+ `runs or you need the address to do the task. If the owner greets you by a model name ("hello cortana"), answer as Operator in ` +
218
+ `the first person, briefly, and say which model is actually serving when it differs.` +
219
+ `\n## Don't starve the serving model — decode is RAM-bound\nYour model is served on a fleet box (the "Active model" section names ` +
220
+ `it), and the models served on THIS box are RAM-bound too. ` +
221
221
  `Loading another large model into memory here (a multi-GB MLX/FLUX/LLM checkpoint, a big \`ml.load\`) competes ` +
222
222
  `for RAM, pushes the box into swap, and collapses your decode to ~1 token/sec — a turn then grinds for an hour ` +
223
223
  `producing almost nothing. Before loading heavy weights on this box: do it on a different node if one is ` +
@@ -89,12 +89,35 @@ export function sanitizeToolCallArgs(messages) {
89
89
  });
90
90
  return changed ? out : messages;
91
91
  }
92
+ // Per-session facts (working dir, scratch dir) ride between these tags in the system prompt string, and
93
+ // placeSessionContext moves them onto the first user message. Chat templates render tool schemas AFTER the
94
+ // system text, so anything that differs between sessions inside the system message makes the server re-prefill
95
+ // every tool schema (~20K tokens) for each new session or delegated sub-agent. Out of it, [system + tools] is
96
+ // byte-identical across sessions on the same model and stays in the server's prompt cache.
97
+ export const SESSION_CONTEXT_OPEN = "\n<session-context>\n";
98
+ export const SESSION_CONTEXT_CLOSE = "\n</session-context>";
99
+ /** Moves the tagged session context out of the system prompt and in front of the first user message. Text
100
+ * appended after the closing tag (a think directive, a turn directive, MOA drafts) stays in the system prompt.
101
+ * With no user message to carry it, the system prompt is returned untouched. */
102
+ export function placeSessionContext(systemPrompt, conversation) {
103
+ const open = systemPrompt?.indexOf(SESSION_CONTEXT_OPEN) ?? -1;
104
+ const close = open >= 0 ? systemPrompt.indexOf(SESSION_CONTEXT_CLOSE, open) : -1;
105
+ const first = conversation.findIndex((m) => m.role === "user");
106
+ if (close < 0 || first < 0)
107
+ return { system: systemPrompt, conversation };
108
+ const sys = systemPrompt;
109
+ const context = sys.slice(open + SESSION_CONTEXT_OPEN.length, close);
110
+ const system = sys.slice(0, open) + sys.slice(close + SESSION_CONTEXT_CLOSE.length);
111
+ const carried = conversation.map((m, i) => i === first ? { ...m, content: `<session-context>\n${context}\n</session-context>\n\n${m.content}` } : m);
112
+ return { system: system || undefined, conversation: carried };
113
+ }
92
114
  /** Prepends the system prompt (if any), repairs interrupted tool pairs, neutralizes any unparseable tool-call
93
115
  * arguments (so a poisoned history never 500s the server), and validates the result. */
94
116
  export function buildMessages(systemPrompt, conversation) {
95
- const withSystem = systemPrompt
96
- ? [{ role: "system", content: systemPrompt }, ...conversation]
97
- : [...conversation];
117
+ const placed = placeSessionContext(systemPrompt, conversation);
118
+ const withSystem = placed.system
119
+ ? [{ role: "system", content: placed.system }, ...placed.conversation]
120
+ : [...placed.conversation];
98
121
  const messages = sanitizeToolCallArgs(repairToolPairs(withSystem));
99
122
  assertValidMessages(messages);
100
123
  return messages;
@@ -24,10 +24,14 @@ export const MODEL_ALIASES = {
24
24
  "aurora-128k": "operator-128k",
25
25
  "spectre": "cortana", // flagship renamed Spectre -> Cortana 35B (2026-10-07); old id keeps resolving
26
26
  };
27
- /** AXE's one shared model gateway (Caddy + AuthGate op_ verify + LiteLLM with server-side fallbacks, JL2).
28
- * Fleet entries list it FIRST so one public name keeps answering when a box is down; the portal client
29
- * (router/portal.ts) derives its host from this too, so the address lives in exactly one place. */
27
+ /** AXE's one shared model gateway, public face (Caddy + AuthGate op_ verify in front of the portal router, JL2).
28
+ * The portal client (router/portal.ts) derives its host from this too, so the address lives in exactly one place. */
30
29
  export const GATEWAY_BASE = `https://${PRODUCT_API_HOST}/v1`;
30
+ /** The same gateway on this box's loopback. Fleet entries list it FIRST and the public face second, so a local
31
+ * agent never round-trips through the Cloudflare tunnel (one Cortana turn: 107 s via the edge, 16 s local) and
32
+ * every model goes through the gateway, never a box's raw LAN port. A box without a local gateway fails this leg
33
+ * at connect and falls through to the public face. */
34
+ export const LOCAL_GATEWAY_BASE = process.env.KODE_LOCAL_GATEWAY_URL ?? "http://127.0.0.1:8620/v1";
31
35
  /** The legacy fleet name for the SAME gateway — the ordered fallback behind GATEWAY_BASE, never a different backend. */
32
36
  export const LEGACY_GATEWAY_BASE = `https://${LEGACY_API_HOST}/v1`;
33
37
  // Vendor bases shared by the built-in BYO rows and BYO_PRESETS, so a row and its preset can never drift apart.
@@ -60,17 +64,17 @@ export const BUILTIN_MODELS = [
60
64
  // ctx 262144 = the served n_ctx (JL1 /props, verified 2026-10-28). The 0.1.260 lesson stands: a profile that
61
65
  // claims MORE than the server's --ctx-size makes the engine overrun the wall and the server cuts a round
62
66
  // mid-tool-call (0.1.259) — change this number ONLY when the server's --ctx-size changes.
63
- { id: "cortana", tier: "power", label: "Cortana", params: "35B-A3B", box: "JL1", kind: "single", desc: "Qwen3.6-35B-A3B abliterated, Q4_K_M", endpoint: "http://192.168.1.103:8112/v1", endpoints: [GATEWAY_BASE, "http://192.168.1.103:8112/v1"], endpointModels: ["cortana", "/Volumes/Ai Storage/jl1-local/models/aurorax/Huihui-Qwen3.6-35B-A3B-abliterated.Q4_K_M.gguf"], model: "/Volumes/Ai Storage/jl1-local/models/aurorax/Huihui-Qwen3.6-35B-A3B-abliterated.Q4_K_M.gguf", ctx: 262144 },
67
+ { id: "cortana", tier: "power", label: "Cortana", params: "35B-A3B", box: "JL1", kind: "single", desc: "Qwen3.6-35B-A3B abliterated, Q4_K_M", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: ["cortana", "cortana"], model: "/Volumes/Ai Storage/jl1-local/models/aurorax/Huihui-Qwen3.6-35B-A3B-abliterated.Q4_K_M.gguf", ctx: 262144 },
64
68
  // Thor — huihui-ai QwQ-32B abliterated: a dense reasoning model that thinks before it answers. Served on JL1:8124
65
69
  // (the portal lists it "available" = registered, loaded on demand); gateway-first like cortana. ctx 32768 = the
66
70
  // server's --ctx-size. Mirrors the hand override JL2's settings.json carried under this id (now a no-op by id).
67
- { id: "thor", tier: "power", label: "Thor", params: "32B", box: "JL1", kind: "single", desc: "QwQ-32B abliterated reasoning model — thinks before answering", endpoint: "http://192.168.1.103:8124/v1", endpoints: [GATEWAY_BASE, "http://192.168.1.103:8124/v1"], endpointModels: ["thor", "/Volumes/Ai Storage/axe-models/thor-32b/huihui-ai_QwQ-32B-abliterated-Q4_K_M.gguf"], model: "/Volumes/Ai Storage/axe-models/thor-32b/huihui-ai_QwQ-32B-abliterated-Q4_K_M.gguf", ctx: 32768 },
71
+ { id: "thor", tier: "power", label: "Thor", params: "32B", box: "JL1", kind: "single", desc: "QwQ-32B abliterated reasoning model — thinks before answering", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: ["thor", "thor"], model: "/Volumes/Ai Storage/axe-models/thor-32b/huihui-ai_QwQ-32B-abliterated-Q4_K_M.gguf", ctx: 32768 },
68
72
  // Qwen3-4B — fast LOCAL tier (stock qwen3-4b-mlx-q4, 2.26GB MLX 4-bit, ctx 40960) served via mlx_lm.server
69
73
  // on JL1:8110. Qwen3 vocab (151936) — the same family as ghost-32b, so it's the review-recommended quick tier
70
74
  // AND the vocab lineage for ghost spec-decode (the actual draft is Qwen3-0.6B, too small to list here). Runs
71
75
  // /no_think for speed. Picked (2026-10-07) from a fleet-wide 3B-class review; no 3B had been execution-graded,
72
76
  // so this is the evidence-led default pending a dyno/coding-eval bench. 40960 ≥ LEAN_HARNESS_CTX → full harness.
73
- { id: "scout", tier: "lite", label: "Scout", params: "4B", box: "JL1", kind: "single", desc: "fast local tier — Qwen3-4B /no_think, Qwen3 vocab (JL1:8110, MLX 4-bit; gateway-first, LAN direct as failover)", endpoint: "http://192.168.1.103:8110/v1", endpoints: [GATEWAY_BASE, "http://192.168.1.103:8110/v1"], endpointModels: ["scout", "/Volumes/Ai Storage/axe-models/qwen3-4b-mlx-q4"], model: "/Volumes/Ai Storage/axe-models/qwen3-4b-mlx-q4", ctx: 32000 },
77
+ { id: "scout", tier: "lite", label: "Scout", params: "4B", box: "JL1", kind: "single", desc: "fast local tier — Qwen3-4B /no_think, Qwen3 vocab (JL1:8110, MLX 4-bit; local gateway first, public gateway as failover)", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: ["scout", "scout"], model: "/Volumes/Ai Storage/axe-models/qwen3-4b-mlx-q4", ctx: 32000 },
74
78
  // Falcon-H1-34B — a NOVEL architecture nobody else on the fleet runs: hybrid SSM+attention, trained with a
75
79
  // genuinely long native context (no YaRN stretch needed — 262144 is baked into the GGUF's own metadata,
76
80
  // confirmed via gguf-py header read, rope.freq_base ≈1e11). Served JL1:8101, q8_0 KV, parallel=1. Not one
package/dist/session.js CHANGED
@@ -3,7 +3,8 @@
3
3
  // that maps these callbacks onto React state; a test can drive the same `send()` directly.
4
4
  import { runTurn, TurnAbortedError } from "./engine/agent.js";
5
5
  import { recordTruncation } from "./observability/blackbox.js";
6
- import { Conversation } from "./engine/messages.js";
6
+ import { Conversation, placeSessionContext, SESSION_CONTEXT_OPEN, SESSION_CONTEXT_CLOSE } from "./engine/messages.js";
7
+ import { scratchDirFor } from "./config/scratch.js";
7
8
  import { chat, health, requiresOperatorToken, operatorTrustedUrl } from "./engine/aurora.js";
8
9
  import { compact, fitToWindow, turnStarts, SUMMARY_INSTRUCTION, stripTrailingOrphanToolCall, pickSummaryContent, renderAnchorIndex, verbatimUserTail, applyAnchorVerification } from "./engine/compaction.js";
9
10
  import { globalTokenMeter, endpointKey } from "./engine/token-meter.js";
@@ -485,6 +486,23 @@ export class Session {
485
486
  });
486
487
  }
487
488
  }
489
+ /** Which model is actually serving, rebuilt every turn so it follows /model. Last in the prompt and marked
490
+ * authoritative, because a SOUL.md or AGENTS.md naming the box's usual model once made Cortana answer "I'm Aurora". */
491
+ activeModelBlock() {
492
+ const p = this.liveRegistry().find((m) => m.id === this.modelId);
493
+ const name = p ? `${p.label}${p.params ? ` ${p.params}` : ""}` : this.modelId;
494
+ return `\n\n## Active model\nThis session is served by ${name}${p?.box ? ` on ${p.box}` : ""} (model id \`${this.modelId}\`). ` +
495
+ `This is authoritative: it overrides any model named elsewhere in this prompt or in project files, and it changes ` +
496
+ `when the owner runs /model. Asked which model you run on, say you are Operator running on ${name}.`;
497
+ }
498
+ /** This session's working and scratch dirs, tagged so buildMessages carries them on the first user message
499
+ * rather than in the system prompt (see engine/messages.ts SESSION_CONTEXT_OPEN for why). */
500
+ sessionContextBlock() {
501
+ const cwd = this.cwd ?? process.cwd();
502
+ return `${SESSION_CONTEXT_OPEN}Working directory: ${cwd}\nScratch dir: ${scratchDirFor(cwd)}\nRelative paths and shell ` +
503
+ `commands resolve in the working directory. This is authoritative over any working dir named elsewhere; create ` +
504
+ `files there unless the owner names another path.${SESSION_CONTEXT_CLOSE}`;
505
+ }
488
506
  /** The effective system prompt: the base persona plus any memory recalled this session, plus any
489
507
  * active skill. Injected as ONE system prompt — never a second system message, which 400s llama.cpp's
490
508
  * chat template. */
@@ -494,6 +512,7 @@ export class Session {
494
512
  : this.systemPrompt;
495
513
  if (this.activeSkillBlock)
496
514
  base = (base ?? "") + this.activeSkillBlock;
515
+ base = (base ?? "") + this.activeModelBlock() + this.sessionContextBlock();
497
516
  if (!this.planMode)
498
517
  return base;
499
518
  // Plan mode: the model researches read-only and proposes a plan; the read-only enforcement is in
@@ -883,10 +902,10 @@ export class Session {
883
902
  // message. The server prefix-matches to the end of span and prefills only the instruction, instead of
884
903
  // re-prefilling the whole span from scratch (the old system-less/tool-less summaryPrompt path did the
885
904
  // latter — the documented cost trap). Empty content falls back to Aurora's reasoning channel.
886
- const sys = this.lastSys ?? this.sys();
905
+ const placed = placeSessionContext(this.lastSys ?? this.sys(), stripTrailingOrphanToolCall(span));
887
906
  const messages = [
888
- ...(sys ? [{ role: "system", content: sys }] : []),
889
- ...stripTrailingOrphanToolCall(span),
907
+ ...(placed.system ? [{ role: "system", content: placed.system }] : []),
908
+ ...placed.conversation,
890
909
  { role: "user", content: SUMMARY_INSTRUCTION },
891
910
  ];
892
911
  // A small-context active model (e.g. a self-hosted 8K Venice) can't summarize its OWN overflow — the
@@ -1321,7 +1340,7 @@ export class Session {
1321
1340
  const shadowBase = prof?.endpoint && prof.transport !== "anthropic" ? endpointBase(prof.endpoint) : undefined;
1322
1341
  if (shadowBase) {
1323
1342
  const shadowTok = prof?.byo ? getByoToken(prof.byo, prof.endpoint) : undefined;
1324
- const shadowModel = prof?.model ?? this.modelId;
1343
+ const shadowModel = prof?.endpointModels?.[0] ?? prof?.model ?? this.modelId;
1325
1344
  this._shadowPending = routeShadowTurn({
1326
1345
  enabled: true,
1327
1346
  text,
package/dist/ui/App.js CHANGED
@@ -28,6 +28,14 @@ import { SessionPicker } from "./SessionPicker.js";
28
28
  // the non-Static portion approaches the terminal height). A batch rarely runs more than a handful of
29
29
  // calls at once; anything past the cap is summarized as a count instead of another row.
30
30
  const MAX_LIVE_TOOL_ROWS = 6;
31
+ /** The yellow line above the composer while messages wait for the turn to end: count, the keys that act on the queue,
32
+ * then a one-line preview of everything queued (newlines as " / ", capped at 120 chars). */
33
+ export function queuedHint(queued) {
34
+ const preview = queued.join("\n").replace(/\n/g, " / ");
35
+ const head = queued.length > 1 ? `⏎ ${queued.length} queued · send together when this turn ends` : "⏎ queued · sends when this turn ends";
36
+ const keys = queued.length > 1 ? "Esc send now · ↑ edit last · ⌫ cancel last" : "Esc send now · ↑ edit · ⌫ cancel";
37
+ return `${head} · ${keys}: ${preview.slice(0, 120)}${preview.length > 120 ? "…" : ""}`;
38
+ }
31
39
  // Muted "ctrl+b to run in the background" tail on the phase line, once a shell command has run past ~2s. Ticks
32
40
  // on the shared animation clock only while a shell command is running, so it appears without any other event.
33
41
  function BackgroundHint({ rows }) {
@@ -37,7 +45,7 @@ function BackgroundHint({ rows }) {
37
45
  return hint ? _jsx(Text, { dimColor: true, children: ` · ${hint}` }) : null;
38
46
  }
39
47
  export function App(props) {
40
- const { messages, live = null, status, thinkingVerb, verbs, stepLabel, prefill = "", liveTools = [], route, ctxPct, ctxPin, version, build, fullscreen = false, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, shellJobs = [], onBackground, tasks = [], onSubmit, onQueue, queuedPreview = "", onInterrupt, onCycleMode, onCycleContext, opMode, rcConnected = false, rcActive = false, caffeinated = false, approval = null, onApprovalDecide, question = null, modelPicker = null, secretPrompt = null, planExitPicker = null, artifactsPicker = null, sessionsPicker = null } = props;
48
+ const { messages, live = null, status, thinkingVerb, verbs, stepLabel, prefill = "", liveTools = [], route, ctxPct, ctxPin, version, build, fullscreen = false, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, shellJobs = [], onBackground, tasks = [], onSubmit, onQueue, queuedPreview = [], onEditQueued, onDropQueued, onInterrupt, onCycleMode, onCycleContext, opMode, rcConnected = false, rcActive = false, caffeinated = false, approval = null, onApprovalDecide, question = null, modelPicker = null, secretPrompt = null, planExitPicker = null, artifactsPicker = null, sessionsPicker = null } = props;
41
49
  useTerminalSize(); // subscribe so the inline pinned UI (status rule, composer, footer) reflows the instant the terminal resizes
42
50
  const thinking = status === "thinking" || status === "streaming";
43
51
  // A parallel batch (2+ live rows) gets its own per-call view instead of the single-line StepSpinner —
@@ -52,7 +60,7 @@ export function App(props) {
52
60
  // be scrolled off. The Composer is `suspended` (keystrokes route to the decision, not the draft).
53
61
  const prompts = (_jsxs(_Fragment, { children: [_jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }) }), _jsx(QuestionPrompt, { pending: question }), _jsx(QuestionPrompt, { pending: modelPicker }), _jsx(SecretPrompt, { pending: secretPrompt }), _jsx(QuestionPrompt, { pending: planExitPicker }), _jsx(ArtifactPicker, { pending: artifactsPicker }), _jsx(SessionPicker, { pending: sessionsPicker })] }));
54
62
  // The pinned bottom band: status rule, composer, bottom rule, then the mode/cycle FOOTER below the rule.
55
- const bottom = (_jsxs(_Fragment, { children: [_jsx(StatusRule, { route: route, ctxPct: ctxPct, ctxPin: ctxPin, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode, sessionTokens: sessionTokens }), queuedPreview ? (_jsx(Text, { color: "yellow", children: `⏎ queued · sends when this turn ends (Esc to send now): ${queuedPreview.replace(/\n/g, " / ").slice(0, 120)}${queuedPreview.length > 120 ? "…" : ""}` })) : null, _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, onBackground: onBackground, onCycleMode: onCycleMode, onCycleContext: onCycleContext, disabled: status !== "idle", suspended: !!approval || !!question || !!modelPicker || !!secretPrompt || !!planExitPicker || !!artifactsPicker || !!sessionsPicker }), _jsx(InputRule, {}), opMode && (_jsxs(Box, { justifyContent: "space-between", children: [_jsx(Text, { dimColor: true, children: ` ${opMode === "auto" ? "⎈ Autonomous" : opMode === "manual" ? "⊙ Manual" : "◑ Plan"} · shift+tab to cycle` }), _jsx(Text, { color: rcConnected ? "green" : rcActive ? "yellow" : "gray", bold: rcConnected || rcActive, dimColor: !rcConnected && !rcActive, children: `${caffeinated ? "☕ " : ""}${rcConnected ? "▮ rc live" : rcActive ? "▮ rc on" : "▯ rc"} ` })] }))] }));
63
+ const bottom = (_jsxs(_Fragment, { children: [_jsx(StatusRule, { route: route, ctxPct: ctxPct, ctxPin: ctxPin, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode, sessionTokens: sessionTokens }), queuedPreview.length ? _jsx(Text, { color: "yellow", children: queuedHint(queuedPreview) }) : null, _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, queued: queuedPreview.length, onEditQueued: onEditQueued, onDropQueued: onDropQueued, onInterrupt: onInterrupt, onBackground: onBackground, onCycleMode: onCycleMode, onCycleContext: onCycleContext, disabled: status !== "idle", suspended: !!approval || !!question || !!modelPicker || !!secretPrompt || !!planExitPicker || !!artifactsPicker || !!sessionsPicker }), _jsx(InputRule, {}), opMode && (_jsxs(Box, { justifyContent: "space-between", children: [_jsx(Text, { dimColor: true, children: ` ${opMode === "auto" ? "⎈ Autonomous" : opMode === "manual" ? "⊙ Manual" : "◑ Plan"} · shift+tab to cycle` }), _jsx(Text, { color: rcConnected ? "green" : rcActive ? "yellow" : "gray", bold: rcConnected || rcActive, dimColor: !rcConnected && !rcActive, children: `${caffeinated ? "☕ " : ""}${rcConnected ? "▮ rc live" : rcActive ? "▮ rc on" : "▯ rc"} ` })] }))] }));
56
64
  // Fullscreen (opt-in): a full-terminal-height column. The transcript fills a clipped, bottom-anchored
57
65
  // region (non-Static tail) so the newest output sits just above a composer pinned to the very bottom —
58
66
  // no dead space. Off by default: inline keeps the terminal's native scrollback (mouse-scroll + copy).
@@ -21,7 +21,7 @@ import { matchSlashCommands } from "./slashCommands.js";
21
21
  import { touchInput } from "../idle/activity.js";
22
22
  const PASTE_START = "\x1b[200~";
23
23
  const PASTE_END = "\x1b[201~";
24
- export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended, onCycleMode, onCycleContext, onBackground, prompt = "› " }) {
24
+ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended, onCycleMode, onCycleContext, onBackground, queued = 0, onEditQueued, onDropQueued, prompt = "› " }) {
25
25
  const [value, setValue] = useState("");
26
26
  const suspendedRef = useRef(suspended); // read by the raw-stdin paste listener, registered once below
27
27
  suspendedRef.current = suspended;
@@ -194,6 +194,19 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended,
194
194
  onSubmit(text);
195
195
  return;
196
196
  }
197
+ // Queued messages (Claude Code's ↑-to-edit): on an empty draft ↑ pulls the most recent one back for editing and
198
+ // Backspace drops it. Ahead of history recall, which gets ↑ back once the queue is empty.
199
+ const queuedPlan = queuedKeyPlan(key, { draftEmpty: value === "", queued });
200
+ if (queuedPlan === "edit") {
201
+ const text = onEditQueued?.();
202
+ if (text !== undefined)
203
+ setValue(text);
204
+ return;
205
+ }
206
+ if (queuedPlan === "drop") {
207
+ onDropQueued?.();
208
+ return;
209
+ }
197
210
  // ↑/↓ navigate the "/" menu when it's open — takes priority over history recall so arrows move the
198
211
  // highlight instead of clobbering the "/command" draft. Wraps around.
199
212
  if ((key.upArrow || key.downArrow) && menuMatches.length > 0) {
@@ -332,6 +345,18 @@ export function interruptPlan(key, ctx) {
332
345
  return { flushDraft: false, interrupt: true };
333
346
  return { flushDraft: false, interrupt: false };
334
347
  }
348
+ /** Pure decision for ↑ / Backspace while messages are queued. Only an EMPTY draft is eligible, so typing, deleting
349
+ * and history recall are untouched while there is text in the box: ↑ = "edit" (pop the most recent queued message
350
+ * into the draft), Backspace/Delete = "drop" (discard it). Anything else, or an empty queue, is null. */
351
+ export function queuedKeyPlan(key, ctx) {
352
+ if (!ctx.draftEmpty || ctx.queued <= 0)
353
+ return null;
354
+ if (key.upArrow)
355
+ return "edit";
356
+ if (key.backspace || key.delete)
357
+ return "drop";
358
+ return null;
359
+ }
335
360
  /** ctrl+b, or its tmux-safe alias ctrl+z (the shell's own "send to background" key). */
336
361
  export function isBackgroundKey(ch, key) {
337
362
  return !!key.ctrl && (ch === "b" || ch === "z");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.335",
3
+ "version": "0.1.337",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "operator": "dist/cli.js",