@0perator/operator 0.1.322 → 0.1.326
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/dist/autonomy/index.js +1 -1
- package/dist/cli.js +14 -10
- package/dist/config/persona.js +14 -3
- package/dist/config/product-hosts.js +26 -0
- package/dist/config/settings.js +15 -12
- package/dist/consolidation/sleep.js +1 -17
- package/dist/engine/agent.js +15 -3
- package/dist/engine/aurora.js +10 -5
- package/dist/engine/compaction.js +1 -1
- package/dist/engine/continuation.js +16 -0
- package/dist/engine/loop-guard.js +14 -9
- package/dist/engine/rolling-summary.js +0 -2
- package/dist/flywheel/processor.js +3 -4
- package/dist/remote/host.js +26 -4
- package/dist/router/models.js +16 -2
- package/dist/session.js +40 -46
- package/dist/tools/document.js +1 -1
- package/dist/tools/registry.js +26 -12
- package/dist/ui/PlanPane.js +5 -4
- package/package.json +1 -1
package/dist/autonomy/index.js
CHANGED
|
@@ -237,7 +237,7 @@ export async function dispatchAutonomy(argv, settings) {
|
|
|
237
237
|
// dynamic Aurora endpoint from the operator-runtime server.json AND brings the launchd gateway UP if it
|
|
238
238
|
// is down. Mirror that FULL blueprint here — the same EnsureCfg (aurora launchd cfg + optional services) —
|
|
239
239
|
// so a headless `operator run/loop/board/routine` on a cold box self-heals instead of failing with a
|
|
240
|
-
// baseless "/v1/chat/completions" (Failed to parse URL) against
|
|
240
|
+
// baseless "/v1/chat/completions" (Failed to parse URL) against an unset (auto-discover) endpoints.aurora.base.
|
|
241
241
|
// Guarded to the empty-base case (the only time we must discover/start), and gateway-aware: carry the
|
|
242
242
|
// gateway's published api_key (server.json) onto the endpoint config so the router authenticates to it.
|
|
243
243
|
if (!settings.endpoints.aurora.base) {
|
package/dist/cli.js
CHANGED
|
@@ -667,7 +667,9 @@ function Root() {
|
|
|
667
667
|
return `spawned background sub-agent ${id}. Its result auto-posts to THIS conversation when done — ` +
|
|
668
668
|
`keep working, do not poll it. Do NOT call bash_output/bash_kill on ${id} (that's for shell_background ` +
|
|
669
669
|
`jobs only and will just error). Use agent_status to check on it, or message_agent to nudge it. ` +
|
|
670
|
-
`Never re-spawn ${id}'s task assuming it was lost — it wasn't
|
|
670
|
+
`Never re-spawn ${id}'s task assuming it was lost — it wasn't. When nothing else is independent of ${id}, ` +
|
|
671
|
+
`give a one-line status and END YOUR TURN — its report resumes this conversation; a turn that keeps ` +
|
|
672
|
+
`polling holds the model slot and starves it.`;
|
|
671
673
|
},
|
|
672
674
|
// The reverse channel: message a RUNNING sub-agent mid-flight (steer it / answer its question).
|
|
673
675
|
messageAgent: (id, text) => {
|
|
@@ -822,7 +824,7 @@ function Root() {
|
|
|
822
824
|
let reports = [];
|
|
823
825
|
try {
|
|
824
826
|
const preflight = await import("./services/preflight.js");
|
|
825
|
-
const bootBase = settings.endpoints.aurora.base; // ""
|
|
827
|
+
const bootBase = settings.endpoints.aurora.base; // "" = unset (auto-discover) until the gateway's published port resolves
|
|
826
828
|
const bootKeyBefore = settings.endpoints.aurora.apiKey;
|
|
827
829
|
const auroraCfg = { base: bootBase, ...settings.services?.aurora };
|
|
828
830
|
reports = await preflight.ensureServices({
|
|
@@ -841,8 +843,8 @@ function Root() {
|
|
|
841
843
|
const bootKey = auroraCfg.apiKey;
|
|
842
844
|
if (bootKey && !settings.endpoints.aurora.apiKey)
|
|
843
845
|
settings.endpoints.aurora.apiKey = bootKey;
|
|
844
|
-
// The Session — and its router — were built at first render, while aurora.base was still
|
|
845
|
-
//
|
|
846
|
+
// The Session — and its router — were built at first render, while aurora.base was still ""
|
|
847
|
+
// (unset — auto-discover). Mutating settings alone leaves that router probing a blank base ("Can't reach Operator"
|
|
846
848
|
// with the gateway up, 0.1.321). Rebuild the chain from the resolved settings and swap it in — the
|
|
847
849
|
// order the headless factory gets for free (ensureServices, THEN buildRouterFromSettings).
|
|
848
850
|
if (settings.endpoints.aurora.base !== bootBase || settings.endpoints.aurora.apiKey !== bootKeyBefore) {
|
|
@@ -2121,8 +2123,9 @@ function Root() {
|
|
|
2121
2123
|
eventSink.emit({ kind: "control", session: SESSION_ID, actor: EVENT_ACTOR, control: { event: "rc_no_token" } });
|
|
2122
2124
|
break;
|
|
2123
2125
|
}
|
|
2124
|
-
const
|
|
2125
|
-
const
|
|
2126
|
+
const { relayUrls, hostOf } = await import("./config/product-hosts.js");
|
|
2127
|
+
const urls = relayUrls(); // api.0perator.co first, api.axe.onl as fallback (KODE_RELAY_URL overrides, comma-separated)
|
|
2128
|
+
const rh = new RemoteHost(urls, token, { title: `Operator · ${process.cwd().split("/").pop() || "session"}`, cwd: process.cwd(), host: hostname(), surface: "cli" }, {
|
|
2126
2129
|
onPrompt: (text) => submitRef.current(text), // follower drives a turn
|
|
2127
2130
|
onApprovalResponse: (id, approve) => settleApproval(id, approve), // first-wins with local
|
|
2128
2131
|
onAskUserResponse: (id, answer) => settleQuestion(id, answer), // first-wins with local
|
|
@@ -2148,7 +2151,7 @@ function Root() {
|
|
|
2148
2151
|
onState: (st, detail) => {
|
|
2149
2152
|
setRcConnected(st === "live"); // footer controller icon: green when live, gray otherwise
|
|
2150
2153
|
if (st === "live")
|
|
2151
|
-
sys(`✷ remote control LIVE — session ${rh.id}\n Continue on your phone or at https://0perator.co/session/${rh.id}\n /remotecontrol again to stop.`);
|
|
2154
|
+
sys(`✷ remote control LIVE via ${hostOf(rh.relayUrl)} — session ${rh.id}\n Continue on your phone or at https://0perator.co/session/${rh.id}\n /remotecontrol again to stop.`);
|
|
2152
2155
|
// RC v2 A2: a drop is NOT a dead end — the host auto-reconnects to the SAME session id (no
|
|
2153
2156
|
// re-mint). Show the quiet reconnecting state; only a genuine setup error is surfaced hard.
|
|
2154
2157
|
else if (st === "connecting" && detail === "reconnecting")
|
|
@@ -2168,7 +2171,7 @@ function Root() {
|
|
|
2168
2171
|
setRcActive(true);
|
|
2169
2172
|
rh.setCapabilities(buildCapabilities()); // cached now, so the very first attach's snapshot already carries it
|
|
2170
2173
|
rh.connect();
|
|
2171
|
-
sys(`connecting remote control → ${
|
|
2174
|
+
sys(`connecting remote control → ${hostOf(rh.relayUrl)} …`);
|
|
2172
2175
|
break;
|
|
2173
2176
|
}
|
|
2174
2177
|
case "pair": {
|
|
@@ -2194,9 +2197,10 @@ function Root() {
|
|
|
2194
2197
|
eventSink.emit({ kind: "control", session: SESSION_ID, actor: EVENT_ACTOR, control: { event: "rc_no_token" } });
|
|
2195
2198
|
break;
|
|
2196
2199
|
}
|
|
2197
|
-
const
|
|
2200
|
+
const { relayUrls, hostOf } = await import("./config/product-hosts.js");
|
|
2201
|
+
const urls = relayUrls(); // api.0perator.co first, api.axe.onl as fallback (KODE_RELAY_URL overrides, comma-separated)
|
|
2198
2202
|
const code = newCode();
|
|
2199
|
-
const rh = new RemoteHost(
|
|
2203
|
+
const rh = new RemoteHost(urls, token, { title: `Operator · ${process.cwd().split("/").pop() || "session"}`, cwd: process.cwd(), host: hostname(), surface: "cli" }, {
|
|
2200
2204
|
onPrompt: (text) => submitRef.current(text),
|
|
2201
2205
|
onApprovalResponse: (id, approve) => settleApproval(id, approve),
|
|
2202
2206
|
onAskUserResponse: (id, answer) => settleQuestion(id, answer),
|
package/dist/config/persona.js
CHANGED
|
@@ -307,6 +307,12 @@ export function basePersona(cwd = process.cwd(), opts = {}) {
|
|
|
307
307
|
`progress / Next) so the owner sees where things stand at a glance without scrolling tool logs. This is ` +
|
|
308
308
|
`Operator's Explanatory default: clarity, reasoning, and diagrams are the norm, not the exception — but ` +
|
|
309
309
|
`keep every one of them tight, and never let the explanation delay or crowd out the tool calls themselves.`)) +
|
|
310
|
+
`\n## Task list — plan where the owner can see it\nFor multi-step work (3+ steps), or when the user gives several ` +
|
|
311
|
+
`tasks, write the plan FIRST with task_add — every step its own item, every "all N" instance enumerated — then ` +
|
|
312
|
+
`work it: exactly one task in_progress at a time (task_update), done only after you verified the step, never on ` +
|
|
313
|
+
`intent; a failed step is cancelled and replaced by a revised one. The list IS the plan and the owner watches it ` +
|
|
314
|
+
`live in the plan pane, so never restate the numbered plan in prose round after round — narrate only what you ` +
|
|
315
|
+
`are doing now.` +
|
|
310
316
|
`\n## Parallel tool calls\nWhen the next few steps are INDEPENDENT of each other, issue them as ` +
|
|
311
317
|
`multiple tool calls in a SINGLE message so they run in parallel — including independent bash ` +
|
|
312
318
|
`commands (they overlap for real; do NOT serialize unrelated shell work). Only serialize when one ` +
|
|
@@ -391,9 +397,14 @@ export function basePersona(cwd = process.cwd(), opts = {}) {
|
|
|
391
397
|
`when you're running low on context, call session_handoff to record what you did, the state, and the ` +
|
|
392
398
|
`next steps: your next session in this directory loads it automatically, so write it for your future self.` +
|
|
393
399
|
(opts.interactive
|
|
394
|
-
? `\n## Sub-agents\
|
|
395
|
-
`
|
|
396
|
-
`
|
|
400
|
+
? `\n## Sub-agents\nDecide and act in the SAME round: when the work splits into independent parts, call ` +
|
|
401
|
+
`spawn_agent NOW with every part in \`tasks\` (they run in parallel) — never write "I'll spawn sub-agents" or ` +
|
|
402
|
+
`"let me delegate" without making that call in the same round. For independent, parallelizable subtasks ` +
|
|
403
|
+
`(research per area, search a large tree, draft a file, a long build) give each a fully self-contained ` +
|
|
404
|
+
`instruction — it runs on another ` +
|
|
405
|
+
`session in parallel and posts its result back here. Do only the work that does NOT depend on it, then give ` +
|
|
406
|
+
`a one-line status and END YOUR TURN — the result resumes the conversation; a turn that keeps polling holds ` +
|
|
407
|
+
`the model slot and starves the sub-agents. The user watches each ` +
|
|
397
408
|
`sub-agent's live tokens + time in the background panel. Don't delegate trivial work you can do inline, ` +
|
|
398
409
|
`and don't spawn many at once — they all share this one model.\n` +
|
|
399
410
|
`WRITE THE BRIEF LIKE A SPEC, not a run-on paragraph — the child has NO memory of this chat, so a wall ` +
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// The product API host and its legacy fleet alias — ONE place for both names. They reach the same gateway
|
|
2
|
+
// (Cloudflare edge → JL2 Caddy :4100 → AuthGate verify → LiteLLM, and /session/ws → the RC relay), so the
|
|
3
|
+
// fallback covers an edge/zone failure of one NAME, never a different backend. Order matters: the product
|
|
4
|
+
// host first, the legacy host second. Both are trusted for the operator bearer in engine/aurora.ts
|
|
5
|
+
// (requiresOperatorToken) — keep that list in step with this one.
|
|
6
|
+
export const PRODUCT_API_HOST = "api.0perator.co";
|
|
7
|
+
export const LEGACY_API_HOST = "api.axe.onl";
|
|
8
|
+
export const API_HOSTS = [PRODUCT_API_HOST, LEGACY_API_HOST];
|
|
9
|
+
export const RELAY_URLS = API_HOSTS.map((h) => `wss://${h}/session/ws`);
|
|
10
|
+
/** The host part of a URL for status lines — or the raw string when it does not parse. A scheme-less
|
|
11
|
+
* KODE_RELAY_URL already fails inside RemoteHost's own error loop; a status line must never be the thing
|
|
12
|
+
* that throws (an unhandled rejection in a slash handler exits the whole CLI). */
|
|
13
|
+
export function hostOf(url) {
|
|
14
|
+
try {
|
|
15
|
+
return new URL(url).host;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return url;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Ordered relay URLs for the RC host. `KODE_RELAY_URL` overrides — comma-separated for an explicit order
|
|
22
|
+
* (a single URL still works exactly as before). */
|
|
23
|
+
export function relayUrls(env = process.env) {
|
|
24
|
+
const override = (env.KODE_RELAY_URL ?? "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
25
|
+
return override.length ? override : [...RELAY_URLS];
|
|
26
|
+
}
|
package/dist/config/settings.js
CHANGED
|
@@ -8,6 +8,7 @@ import { dirname } from "node:path";
|
|
|
8
8
|
import { operatorPath } from "./home.js";
|
|
9
9
|
import { applyManagedPolicy, loadManagedPolicy } from "./managed.js";
|
|
10
10
|
import { DEFAULT_MODEL_ID } from "../router/models.js";
|
|
11
|
+
import { LEGACY_API_HOST, PRODUCT_API_HOST } from "./product-hosts.js";
|
|
11
12
|
/** Resolve an endpoint's bearer from config/env/secret-file (first hit wins); undefined when none set
|
|
12
13
|
* (a local/un-gated endpoint). Keeps the raw key out of settings when `apiKeyEnv`/`apiKeyFile` are used. */
|
|
13
14
|
export function resolveEndpointApiKey(ep) {
|
|
@@ -33,7 +34,7 @@ export function resolveEndpointApiKey(ep) {
|
|
|
33
34
|
return undefined;
|
|
34
35
|
}
|
|
35
36
|
// Aurora endpoint is discovered from ~/.operator/runtime/server.json (dynamic port).
|
|
36
|
-
// The empty base below
|
|
37
|
+
// The empty base below means unset (auto-discover) — preflight reads server.json and resolves the real base_url
|
|
37
38
|
// before any request. ctxWindow MUST match the server's real --ctx-size. Override in settings.json.
|
|
38
39
|
const DEFAULTS = {
|
|
39
40
|
endpoints: {
|
|
@@ -304,15 +305,14 @@ function resolveModelMode(s) {
|
|
|
304
305
|
// The AXE cloud tier — AXE's own gateway (nginx + LiteLLM → llama.cpp), the LAST-RESORT failover reached
|
|
305
306
|
// only when the whole local fleet is wedged/degraded. Mirrors the `axe-aurora-300k` BUILTIN profile: same
|
|
306
307
|
// served model + window. The base is bare (no `/v1` — aurora.ts appends it); it carries NO explicit token
|
|
307
|
-
// because authHeaders() sends the operator bearer to
|
|
308
|
-
//
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
model: "aurora-code-1",
|
|
313
|
-
ctxLimit: 307200,
|
|
314
|
-
|
|
315
|
-
};
|
|
308
|
+
// because authHeaders() sends the operator bearer to the gateway domains automatically (credential-scope
|
|
309
|
+
// guard). Two legs for the SAME gateway, in order: the product name, then the legacy fleet name — a fallback
|
|
310
|
+
// for an edge/zone failure of one name (config/product-hosts.ts). Opt out with
|
|
311
|
+
// `settings.endpoints.cloudFailover === false` for a sovereign deployment that must never egress.
|
|
312
|
+
const CLOUD_FAILOVERS = [
|
|
313
|
+
{ name: "operator-cloud", base: `https://${PRODUCT_API_HOST}`, model: "aurora-code-1", ctxLimit: 307200, transport: "openai" },
|
|
314
|
+
{ name: "axe-cloud", base: `https://${LEGACY_API_HOST}`, model: "aurora-code-1", ctxLimit: 307200, transport: "openai" },
|
|
315
|
+
];
|
|
316
316
|
function hostLabel(base) {
|
|
317
317
|
try {
|
|
318
318
|
const u = new URL(base);
|
|
@@ -351,8 +351,11 @@ export function buildEndpointChain(s) {
|
|
|
351
351
|
if (failover)
|
|
352
352
|
add({ name: "failover", base: failover.base, model: failover.model, ctxLimit: failover.ctxWindow, token: resolveEndpointApiKey(failover) });
|
|
353
353
|
if (s.endpoints.cloudFailover !== false) {
|
|
354
|
-
|
|
355
|
-
|
|
354
|
+
// No explicit token: authHeaders scopes the signed-in operator bearer to the gateway domains. Resolving a
|
|
355
|
+
// per-endpoint key here would send a LOCAL gateway key (KODE_AURORA_TOKEN) to both public names and displace
|
|
356
|
+
// the operator identity (review finding, 2026-10-28).
|
|
357
|
+
for (const cloud of CLOUD_FAILOVERS)
|
|
358
|
+
add({ ...cloud });
|
|
356
359
|
}
|
|
357
360
|
return chain;
|
|
358
361
|
}
|
|
@@ -24,18 +24,6 @@ const DEFAULTS = {
|
|
|
24
24
|
modelTier: "fast",
|
|
25
25
|
maxLessonsPerFile: 50,
|
|
26
26
|
};
|
|
27
|
-
class SimpleIdleDetector {
|
|
28
|
-
lastActivity = Date.now();
|
|
29
|
-
recordActivity() {
|
|
30
|
-
this.lastActivity = Date.now();
|
|
31
|
-
}
|
|
32
|
-
isIdle() {
|
|
33
|
-
return (Date.now() - this.lastActivity) / 1000 >= 30; // default 30s idle threshold
|
|
34
|
-
}
|
|
35
|
-
idleSeconds() {
|
|
36
|
-
return (Date.now() - this.lastActivity) / 1000;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
27
|
/** Deduplicate a JSONL memory file. Returns the deduped notes. */
|
|
40
28
|
export function dedupMemoryFile(filepath) {
|
|
41
29
|
if (!existsSync(filepath))
|
|
@@ -185,7 +173,7 @@ export function curateLessons(candidates) {
|
|
|
185
173
|
existing.push(c);
|
|
186
174
|
groups.set(key, existing);
|
|
187
175
|
}
|
|
188
|
-
return [...groups.entries()].map(([
|
|
176
|
+
return [...groups.entries()].map(([, items]) => {
|
|
189
177
|
const type = items[0].type;
|
|
190
178
|
const count = items.reduce((s, i) => s + i.count, 0);
|
|
191
179
|
const total = items.reduce((s, i) => s + i.total, 0);
|
|
@@ -390,7 +378,3 @@ function hashInput(input) {
|
|
|
390
378
|
}
|
|
391
379
|
return hash.toString(36);
|
|
392
380
|
}
|
|
393
|
-
// Lazy require for node:fs in browser context
|
|
394
|
-
const require = (typeof globalThis !== "undefined" && globalThis.require)
|
|
395
|
-
? globalThis.require
|
|
396
|
-
: undefined;
|
package/dist/engine/agent.js
CHANGED
|
@@ -26,7 +26,7 @@ const LOOP_GUARD_LIMIT = 5; // identical (name+args) calls in a turn before shor
|
|
|
26
26
|
// with NO intervening edit (a true no-progress loop) trips this. Raised 3→5 so even a no-edit re-run has
|
|
27
27
|
// headroom before the guard fires. The narration/no-progress stalls below are the separate progress-gated stops.
|
|
28
28
|
import { MUTATING_TOOLS, mutationLanded } from "../tools/mutating.js"; // single source of truth (see tools/mutating.ts) — a LANDED workspace edit ⇒ prior identical-call counts are stale
|
|
29
|
-
import { ANNOUNCE_NUDGE, ANNOUNCE_NUDGE_MAX, detectUnfinishedAction } from "./continuation.js";
|
|
29
|
+
import { ANNOUNCE_NUDGE, ANNOUNCE_NUDGE_MAX, DELEGATION_NUDGE, detectAnnouncedDelegation, detectUnfinishedAction } from "./continuation.js";
|
|
30
30
|
// Poll/status tools are meant to be called repeatedly while waiting on async work — NEVER a spin, so the
|
|
31
31
|
// loop guard skips them entirely (agent_status polls sub-agents, bash_output polls a background job).
|
|
32
32
|
const LOOP_GUARD_EXEMPT = new Set(["agent_status", "bash_output"]);
|
|
@@ -550,6 +550,7 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
550
550
|
let thinkLatched = false; // once a think-spiral is detected, force thinking:false for the rest of the turn
|
|
551
551
|
let noEditStreak = 0; // consecutive tool rounds that changed no file — investigating, not fixing
|
|
552
552
|
let noEditNudged = false; // the soft no-edit nudge fires at most once per turn
|
|
553
|
+
let delegationNudged = false; // the delegation-by-prose nudge (continuation.ts) fires at most once per turn
|
|
553
554
|
let budgetWarned = false; // the one-time "near the time budget, converge" warning fires before the hard wall-clock stop
|
|
554
555
|
const touchedFiles = []; // files read/edited this turn (LRU) — re-surfaced by rehydration after a compaction
|
|
555
556
|
let compactionFailStreak = 0; // consecutive rounds still over budget after compaction fired — the circuit breaker
|
|
@@ -581,6 +582,9 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
581
582
|
// Turn-continuation: nudge a model that ends on an unperformed action announcement to actually do it (bounded).
|
|
582
583
|
const continuationEnabled = opts.turnContinuation?.enabled !== false && (opts.toolSchemas?.length ?? 0) > 0;
|
|
583
584
|
const continuationMax = Math.max(0, opts.turnContinuation?.maxNudges ?? ANNOUNCE_NUDGE_MAX);
|
|
585
|
+
// Delegation-by-prose guard applies only where spawn_agent is actually offered (interactive foreground; a bg
|
|
586
|
+
// sub-agent has no spawn tool and must not be told to call one).
|
|
587
|
+
const hasSpawnTool = (opts.toolSchemas ?? []).some((s) => s?.function?.name === "spawn_agent");
|
|
584
588
|
let announceNudges = 0;
|
|
585
589
|
let malformedCallNudges = 0; // bounded re-prompts for an unparseable text tool call
|
|
586
590
|
// Spectre fix (b): bounded auto-continue after a LENGTH truncation (see gate at finalize).
|
|
@@ -701,6 +705,7 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
701
705
|
threshold: opts.compactionThreshold,
|
|
702
706
|
ceilingTokens: opts.compactionCeilingTokens,
|
|
703
707
|
minKeepTurns: opts.minKeepTurns,
|
|
708
|
+
preservedState: opts.preservedState?.(), // the active task list rides with the summary
|
|
704
709
|
meter: globalTokenMeter, // SPEC §5: size to THIS endpoint's learned ratio, not chars/4
|
|
705
710
|
meterKey: endpointKey(ep.base, ep.model),
|
|
706
711
|
spill: opts.spill, // GW-10-COMPLETE: fitToWindow offloads (re-readable) when the host can write files
|
|
@@ -1144,11 +1149,18 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
1144
1149
|
noProgressStreak = progressed ? 0 : noProgressStreak + 1; // reset the stall counter on any real progress
|
|
1145
1150
|
noEditStreak = response.toolCalls.some((c) => MUTATING_TOOLS.has(c.function?.name ?? "")) ? 0 : noEditStreak + 1;
|
|
1146
1151
|
trackTouchedFiles(response.toolCalls, touchedFiles);
|
|
1152
|
+
// Delegation-by-prose guard: the round's narration said "spawn sub-agents / delegate" but none of its calls
|
|
1153
|
+
// delegated. Nudge ONCE per turn to make the call (tasks[] for parallel work) or stop announcing it — a
|
|
1154
|
+
// nudge, never a stop; the model may legitimately decide the work is sequential after all.
|
|
1155
|
+
if (!delegationNudged && hasSpawnTool && detectAnnouncedDelegation(response.content, response.toolCalls.map((c) => c.function?.name ?? ""))) {
|
|
1156
|
+
delegationNudged = true;
|
|
1157
|
+
conversation.user(DELEGATION_NUDGE);
|
|
1158
|
+
}
|
|
1147
1159
|
// Poll-spin guard: an agent_status spin (auto-post pending, no other work, no status change) wastes the
|
|
1148
1160
|
// turn — pollers are exempt from the loop guard above, so this catches them. Nudge once, then end the
|
|
1149
1161
|
// turn so the auto-posted sub-agent results resume it (rather than burning the budget re-checking).
|
|
1150
1162
|
if (pollSpin) {
|
|
1151
|
-
const ps = pollSpin.observe(response.toolCalls.map((c) => c.function.name), toolMsgs.map((m) => m.content ?? ""));
|
|
1163
|
+
const ps = pollSpin.observe(response.toolCalls.map((c) => c.function.name), toolMsgs.map((m) => m.content ?? ""), response.toolCalls.some((c) => MUTATING_TOOLS.has(c.function?.name ?? "")));
|
|
1152
1164
|
if (ps.action === "halt")
|
|
1153
1165
|
return stopTurn(ps.message, rounds + 1);
|
|
1154
1166
|
if (ps.action === "nudge") {
|
|
@@ -1196,7 +1208,7 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
1196
1208
|
noEditStreak = recovered.calls.some((c) => MUTATING_TOOLS.has(c.function?.name ?? "")) ? 0 : noEditStreak + 1;
|
|
1197
1209
|
trackTouchedFiles(recovered.calls, touchedFiles);
|
|
1198
1210
|
if (pollSpin) {
|
|
1199
|
-
const ps = pollSpin.observe(recovered.calls.map((c) => c.function.name), toolMsgs.map((m) => m.content ?? ""));
|
|
1211
|
+
const ps = pollSpin.observe(recovered.calls.map((c) => c.function.name), toolMsgs.map((m) => m.content ?? ""), recovered.calls.some((c) => MUTATING_TOOLS.has(c.function?.name ?? "")));
|
|
1200
1212
|
if (ps.action === "halt")
|
|
1201
1213
|
return stopTurn(ps.message, rounds + 1);
|
|
1202
1214
|
if (ps.action === "nudge") {
|
package/dist/engine/aurora.js
CHANGED
|
@@ -74,16 +74,21 @@ function hostOf(base) {
|
|
|
74
74
|
return "";
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
// The gateway domains that front the model with operator-bearer auth: the product domain and the legacy fleet
|
|
78
|
+
// domain (config/product-hosts.ts keeps the host names; this is the trust list — keep the two in step).
|
|
79
|
+
const GATEWAY_DOMAINS = ["0perator.co", "axe.onl"];
|
|
80
|
+
function isGatewayDomain(h) {
|
|
81
|
+
return GATEWAY_DOMAINS.some((d) => h === d || h.endsWith(`.${d}`));
|
|
82
|
+
}
|
|
83
|
+
/** True when `base` is an AXE gateway host that fronts the model with operator-bearer auth (…0perator.co /
|
|
84
|
+
* …axe.onl). LAN and loopback fleet nodes are trusted but unauthenticated, so they never need a signed-in identity. */
|
|
79
85
|
export function requiresOperatorToken(base) {
|
|
80
|
-
|
|
81
|
-
return h === "axe.onl" || h.endsWith(".axe.onl");
|
|
86
|
+
return isGatewayDomain(hostOf(base ?? ""));
|
|
82
87
|
}
|
|
83
88
|
function isOperatorTrustedHost(h) {
|
|
84
89
|
if (!h)
|
|
85
90
|
return false;
|
|
86
|
-
if (h
|
|
91
|
+
if (isGatewayDomain(h))
|
|
87
92
|
return true;
|
|
88
93
|
return /^(10\.|192\.168\.|127\.|localhost$|\[::1\]$)|^172\.(1[6-9]|2\d|3[01])\./.test(h) || h.endsWith(".local");
|
|
89
94
|
}
|
|
@@ -360,7 +360,7 @@ export async function compact(conversation, opts) {
|
|
|
360
360
|
// summary embeds specifics in prose); these blocks guarantee nothing critical was dropped.
|
|
361
361
|
const summaryMsg = {
|
|
362
362
|
role: "user", // never a 2nd system message — SPEC §1/§5
|
|
363
|
-
content: `[Compacted summary of ${evicted.length} earlier message(s)]\n${summaryText}${renderAnchorIndex(evicted)}${verbatimUserTail(evicted)}`,
|
|
363
|
+
content: `[Compacted summary of ${evicted.length} earlier message(s)]\n${summaryText}${renderAnchorIndex(evicted)}${verbatimUserTail(evicted)}${opts.preservedState ? `\n\n${opts.preservedState}` : ""}`,
|
|
364
364
|
};
|
|
365
365
|
// N1 VERIFIED COMPACTION: proof-of-preservation rides with the summary (shared helper now — the
|
|
366
366
|
// instant/prewritten path in session.ts MUST get the same guarantee, audit-engine §2).
|
|
@@ -53,3 +53,19 @@ export function detectUnfinishedAction(content) {
|
|
|
53
53
|
const head = lines.length > 1 && lines[0].endsWith(":") ? [lines[0]] : [];
|
|
54
54
|
return [...head, ...window].some((s) => ANNOUNCE_RE.test(s) && !HANDBACK_RE.test(s) && !DEFER_RE.test(s) && !CONDITIONAL_RE.test(s));
|
|
55
55
|
}
|
|
56
|
+
// Delegation announced in prose but not performed. detectUnfinishedAction covers a TEXT-ONLY turn ending on an
|
|
57
|
+
// announcement; this covers a TOOL round whose narration says the model will spawn sub-agents / delegate / fan out
|
|
58
|
+
// while none of its calls delegated — the live failure (2026-10-28): a model that kept running bash itself,
|
|
59
|
+
// restating "then spawn sub-agents for each subsystem" round after round, and never calling spawn_agent.
|
|
60
|
+
const DELEGATION_RE = /\b(?:(?:spawning|spawn)\s+(?:a |the |some |more )?(?:parallel )?(?:sub-?)?agents?|(?:spinning|spin)\s+up\s+(?:sub-?)?agents?|sub-?agents?\s+(?:to|for|will|in parallel|per|should)|delegat(?:e|es|ed|ing)\s+(?:to|the|this|these|that|those|each|research|work|it|tasks?)|(?:fanning|fan)\s+out)\b/i;
|
|
61
|
+
const DELEGATION_TOOLS = new Set(["spawn_agent", "delegate_task", "delegate_to_agent"]);
|
|
62
|
+
export const DELEGATION_NUDGE = "You said you would delegate, but this round made no spawn_agent call. If parts of the work are independent, call " +
|
|
63
|
+
"spawn_agent NOW with each part as an entry in `tasks` (they run in parallel) — otherwise do the work yourself. " +
|
|
64
|
+
"Do not announce delegation again without making the call.";
|
|
65
|
+
/** True when a tool round's narration announces delegation and none of the round's calls delegated. */
|
|
66
|
+
export function detectAnnouncedDelegation(content, calledTools) {
|
|
67
|
+
if (calledTools.some((n) => DELEGATION_TOOLS.has(n)))
|
|
68
|
+
return false;
|
|
69
|
+
const text = (content ?? "").trim();
|
|
70
|
+
return !!text && DELEGATION_RE.test(text);
|
|
71
|
+
}
|
|
@@ -351,9 +351,10 @@ export class LoopGuard {
|
|
|
351
351
|
export const AUTOPOST_POLLERS = new Set(["agent_status"]);
|
|
352
352
|
export const POLL_SPIN_DEFAULTS = { nudgeAfter: 2, stopAfter: 3 };
|
|
353
353
|
export const POLL_SPIN_NUDGE = "Sub-agent results auto-post to this conversation the moment they finish — you do not need to poll " +
|
|
354
|
-
"agent_status to learn that.
|
|
355
|
-
"
|
|
356
|
-
|
|
354
|
+
"agent_status to learn that. Reads and status checks while they run are not progress: finish only what does " +
|
|
355
|
+
"NOT depend on them, give a one-line status, and END YOUR TURN — the results resume this conversation on their " +
|
|
356
|
+
"own, and a turn that keeps polling holds the model slot and starves the sub-agents.";
|
|
357
|
+
export const POLL_SPIN_STOP = "[stopped — waiting on sub-agents: agent_status was polled repeatedly with no mutating work and no change in status. Sub-agent results " +
|
|
357
358
|
"auto-post when they finish and will resume this turn, so polling only burns time and tokens. Nothing was " +
|
|
358
359
|
"lost — the results arrive on their own.]";
|
|
359
360
|
/** Watches settled tool rounds for an auto-post-poller spin. Fed one round at a time via observe(); a
|
|
@@ -370,18 +371,22 @@ export class PollSpinGuard {
|
|
|
370
371
|
this.stopAfter = stopAfter;
|
|
371
372
|
}
|
|
372
373
|
reset() { this.streak = 0; this.nudged = false; this.lastHash = ""; }
|
|
373
|
-
/** One settled round: the tools it ran (names)
|
|
374
|
-
|
|
374
|
+
/** One settled round: the tools it ran (names), their results (index-aligned), and whether any call in the round
|
|
375
|
+
* CHANGED the workspace. Read-only work beside a poll is not progress — a parent that alternates agent_status
|
|
376
|
+
* with greps, reads and status bash while its sub-agents run is still waiting on them (the 2026-10-28 32-minute
|
|
377
|
+
* turn), and should end the turn so the auto-posted results resume it and the sub-agents get the model slot. */
|
|
378
|
+
observe(names, results, mutating = false) {
|
|
375
379
|
const pollers = names.filter((n) => AUTOPOST_POLLERS.has(n));
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
if (pollers.length === 0 || hasOther) {
|
|
380
|
+
// No auto-post poller, or a MUTATING call alongside it ⇒ progress, never a spin.
|
|
381
|
+
if (pollers.length === 0 || mutating) {
|
|
379
382
|
this.reset();
|
|
380
383
|
return { action: "allow", streak: 0 };
|
|
381
384
|
}
|
|
382
385
|
// A pure poll round. A changed poll result means a sub-agent's state moved (one finished / was added) —
|
|
383
386
|
// that IS new information, so the streak resets.
|
|
384
|
-
|
|
387
|
+
// Only the POLLERS' results count as "the status": a read-only tool's output changes every round (a
|
|
388
|
+
// different grep, a longer log) and must not look like a sub-agent moving.
|
|
389
|
+
const h = hash(pollers.join("\0") + "\u0001" + results.filter((_, i) => AUTOPOST_POLLERS.has(names[i])).join("\0"));
|
|
385
390
|
if (this.streak > 0 && h !== this.lastHash) {
|
|
386
391
|
this.reset();
|
|
387
392
|
this.lastHash = h;
|
|
@@ -20,7 +20,6 @@ export class RollingSummarizer {
|
|
|
20
20
|
opts;
|
|
21
21
|
lastUpdateTokens = 0;
|
|
22
22
|
lastUpdateBatches = 0;
|
|
23
|
-
lastUpdateTime = 0;
|
|
24
23
|
summaryCache = "";
|
|
25
24
|
dirty = false;
|
|
26
25
|
// GW-27-U2: how many user-turns the CURRENT cached summary covers (turnCount at fire time).
|
|
@@ -61,7 +60,6 @@ export class RollingSummarizer {
|
|
|
61
60
|
* (GW-27-U2). Omitted => coverage unknown => treated as covering nothing: safe, just falls back
|
|
62
61
|
* to the live summarize path. */
|
|
63
62
|
markSummaryFired(turnsCovered) {
|
|
64
|
-
this.lastUpdateTime = Date.now();
|
|
65
63
|
this.dirty = false;
|
|
66
64
|
this.coveredThroughTurns = typeof turnsCovered === "number" ? turnsCovered : 0;
|
|
67
65
|
}
|
|
@@ -28,10 +28,9 @@ export async function runMutationCheck(cwd, verifyCommand, diffSha) {
|
|
|
28
28
|
execSync("git stash push -m 'mutation-check-stash' -- .", { cwd, stdio: "pipe" });
|
|
29
29
|
// Revert to the pre-change state
|
|
30
30
|
execSync(`git checkout ${diffSha} -- .`, { cwd, stdio: "pipe" });
|
|
31
|
-
// Run verification
|
|
32
|
-
let verifyResult;
|
|
31
|
+
// Run verification — only pass/fail matters here, the output is not read
|
|
33
32
|
try {
|
|
34
|
-
|
|
33
|
+
execSync(verifyCommand, { cwd, encoding: "utf8", stdio: "pipe" });
|
|
35
34
|
}
|
|
36
35
|
catch (e) {
|
|
37
36
|
// Verify failed — good! The tests actually test something.
|
|
@@ -201,7 +200,7 @@ export class FlywheelProcessor {
|
|
|
201
200
|
/** Process all trajectories in the flywheel directory.
|
|
202
201
|
* Applies SRFT masking, runs mutation checks, and outputs cleaned trajectories. */
|
|
203
202
|
async processAll() {
|
|
204
|
-
const { readdirSync, readFileSync,
|
|
203
|
+
const { readdirSync, readFileSync, existsSync, mkdirSync } = await import("node:fs");
|
|
205
204
|
const { join } = await import("node:path");
|
|
206
205
|
const flywheelDir = this.opts.flywheelDir;
|
|
207
206
|
if (!existsSync(flywheelDir)) {
|
package/dist/remote/host.js
CHANGED
|
@@ -53,7 +53,6 @@ function capCapabilities(caps) {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
export class RemoteHost {
|
|
56
|
-
url;
|
|
57
56
|
token;
|
|
58
57
|
meta;
|
|
59
58
|
cb;
|
|
@@ -87,11 +86,20 @@ export class RemoteHost {
|
|
|
87
86
|
keepaliveTimer = null;
|
|
88
87
|
reconnectTimer = null;
|
|
89
88
|
reconnectAttempts = 0;
|
|
89
|
+
// Ordered relay URLs (product host first, legacy host as fallback — config/product-hosts.ts). Rotation is per
|
|
90
|
+
// ATTEMPT: any dial that never reaches `welcome` — the first connect or a post-drop re-dial — moves to the next
|
|
91
|
+
// URL. A drop itself never rotates, so a re-dial that welcomes keeps the name the host was on; names only change
|
|
92
|
+
// when the current one stops answering.
|
|
93
|
+
urls;
|
|
94
|
+
urlIdx = 0;
|
|
95
|
+
welcomedThisAttempt = false;
|
|
90
96
|
constructor(url, token, meta, cb, pairing) {
|
|
91
|
-
this.url = url;
|
|
92
97
|
this.token = token;
|
|
93
98
|
this.meta = meta;
|
|
94
99
|
this.cb = cb;
|
|
100
|
+
this.urls = (Array.isArray(url) ? url : [url]).filter(Boolean);
|
|
101
|
+
if (!this.urls.length)
|
|
102
|
+
throw new Error("RemoteHost needs at least one relay url");
|
|
95
103
|
if (pairing) {
|
|
96
104
|
this.sessionId = pairing.sessionId; // deterministic, so the QR's s=<sessionId> is known before connect
|
|
97
105
|
this.paired = true;
|
|
@@ -105,12 +113,14 @@ export class RemoteHost {
|
|
|
105
113
|
// session on a blip (the battlefield no-disconnect requirement). A deliberate stop() short-circuits it.
|
|
106
114
|
openSocket() {
|
|
107
115
|
this.cb.onState?.("connecting");
|
|
116
|
+
this.welcomedThisAttempt = false;
|
|
108
117
|
let ws;
|
|
109
118
|
try {
|
|
110
|
-
ws = new WebSocket(this.
|
|
119
|
+
ws = new WebSocket(this.relayUrl);
|
|
111
120
|
}
|
|
112
121
|
catch (e) {
|
|
113
122
|
this.cb.onState?.("error", String(e));
|
|
123
|
+
this.rotateUrl();
|
|
114
124
|
this.scheduleReconnect();
|
|
115
125
|
return;
|
|
116
126
|
}
|
|
@@ -122,11 +132,18 @@ export class RemoteHost {
|
|
|
122
132
|
});
|
|
123
133
|
ws.addEventListener("message", (ev) => this.onMessage(String(ev.data)));
|
|
124
134
|
ws.addEventListener("close", () => {
|
|
125
|
-
this.stopKeepalive();
|
|
126
135
|
if (this.closedByUs) {
|
|
136
|
+
this.stopKeepalive();
|
|
127
137
|
this.cb.onState?.("closed");
|
|
128
138
|
return;
|
|
129
139
|
}
|
|
140
|
+
// A superseded socket's late close (a `reconnect` re-dial that outran its closing handshake): not ours to
|
|
141
|
+
// rotate, re-dial, or stop the LIVE socket's keepalive.
|
|
142
|
+
if (ws !== this.ws)
|
|
143
|
+
return;
|
|
144
|
+
this.stopKeepalive();
|
|
145
|
+
if (!this.welcomedThisAttempt)
|
|
146
|
+
this.rotateUrl(); // this relay name never answered — try the next one
|
|
130
147
|
this.cb.onState?.("connecting", "reconnecting"); // NOT a hard error — we re-dial the same session
|
|
131
148
|
this.scheduleReconnect();
|
|
132
149
|
});
|
|
@@ -156,6 +173,10 @@ export class RemoteHost {
|
|
|
156
173
|
} }
|
|
157
174
|
get id() { return this.sessionId; }
|
|
158
175
|
get connected() { return !!this.ws && this.ws.readyState === 1; }
|
|
176
|
+
/** The relay URL this host is dialing (or live on) right now. */
|
|
177
|
+
get relayUrl() { return this.urls[this.urlIdx]; }
|
|
178
|
+
rotateUrl() { if (this.urls.length > 1)
|
|
179
|
+
this.urlIdx = (this.urlIdx + 1) % this.urls.length; }
|
|
159
180
|
stop() {
|
|
160
181
|
this.closedByUs = true;
|
|
161
182
|
if (this.liveTimer) {
|
|
@@ -196,6 +217,7 @@ export class RemoteHost {
|
|
|
196
217
|
}
|
|
197
218
|
switch (f.type) {
|
|
198
219
|
case "welcome":
|
|
220
|
+
this.welcomedThisAttempt = true;
|
|
199
221
|
this.sessionId = f.payload?.sessionId ?? this.sessionId;
|
|
200
222
|
this.ownerSub = f.payload?.ownerSub ?? null;
|
|
201
223
|
if (typeof f.payload?.epoch === "number")
|
package/dist/router/models.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// Model registry — /model + MOA (MOA-DESIGN.md). Three switchable profiles: two "single" profiles
|
|
2
|
+
// that just point THIS session's AuroraRouter at an already-running llama-server (no server is ever
|
|
3
|
+
// started/stopped by selecting one), and "moa" (mixture-of-agents), which has no endpoint of its
|
|
4
|
+
// own — it fans a turn out to settings.moa's proposers and synthesizes with an aggregator (see
|
|
5
|
+
// engine/moa.ts + Session.setModel/sendMoa). Kept dependency-free (no settings.ts import) so both
|
|
6
|
+
// settings.ts and session.ts can import it without a cycle.
|
|
7
|
+
// ── Model tiers (PV2-11) ────────────────────────────────────────────────────
|
|
8
|
+
// A COMPUTE/COST CLASS orthogonal to a profile's id, so routing can ask for a class instead of a
|
|
9
|
+
// name ("give me a lite model for this sub-task") and degrade predictably when a class is empty.
|
|
10
|
+
// Ladder, strongest → cheapest: power_turbo > power > economy > lite > free. "free" is reserved
|
|
11
|
+
// for genuinely no-cost promotional slots; nothing on the fleet maps to it today.
|
|
12
|
+
import { LEGACY_API_HOST, PRODUCT_API_HOST } from "../config/product-hosts.js"; // no imports of its own — no cycle
|
|
1
13
|
/** Fallback walk order, strongest → cheapest. */
|
|
2
14
|
export const TIER_LADDER = ["power_turbo", "power", "economy", "lite", "free"];
|
|
3
15
|
export const DEFAULT_MODEL_ID = "operator-1m";
|
|
@@ -13,7 +25,9 @@ export const MODEL_ALIASES = {
|
|
|
13
25
|
/** AXE's one shared model gateway (Caddy + AuthGate op_ verify + LiteLLM with server-side fallbacks, JL2).
|
|
14
26
|
* Fleet entries list it FIRST so one public name keeps answering when a box is down; the portal client
|
|
15
27
|
* (router/portal.ts) derives its host from this too, so the address lives in exactly one place. */
|
|
16
|
-
export const GATEWAY_BASE =
|
|
28
|
+
export const GATEWAY_BASE = `https://${PRODUCT_API_HOST}/v1`;
|
|
29
|
+
/** The legacy fleet name for the SAME gateway — the ordered fallback behind GATEWAY_BASE, never a different backend. */
|
|
30
|
+
export const LEGACY_GATEWAY_BASE = `https://${LEGACY_API_HOST}/v1`;
|
|
17
31
|
export const BUILTIN_MODELS = [
|
|
18
32
|
{ id: "operator-1m", tier: "power", label: "Operator 1M (local)", kind: "single", desc: "RECOMMENDED DEFAULT — local Aurora code model on this box's GPU (:8097, 24-47 tok/s measured, warm prefix-cache, no shared-slot contention); ctx 300K matched under the served 307,200 wall so compaction lands BEFORE the edge", endpoint: "http://127.0.0.1:8097/v1", model: "aurora-code-1", ctx: 1000000 },
|
|
19
33
|
{ id: "operator-128k", tier: "economy", label: "Operator 128K", kind: "single", desc: "128K context, lighter RAM (:8096) — slot not served on this fleet today; hidden from the picker, resolves by id when the slot comes up", endpoint: "http://127.0.0.1:8096/v1", model: "aurora-code-1", ctx: 131072, hidden: true },
|
|
@@ -35,7 +49,7 @@ export const BUILTIN_MODELS = [
|
|
|
35
49
|
// issues them, gating this profile behind an unconnectable BYO account hid our OWN flagship remote
|
|
36
50
|
// lane from our own picker (2026-10-12 picker-truth audit) — so it is a plain profile today. When V1
|
|
37
51
|
// ships, reintroduce the byo:"axe" SKU as a SEPARATE connector id, never by re-gating this one.
|
|
38
|
-
{ id: "axe-aurora-300k", tier: "power", label: "Aurora 300K (AXE cloud)", kind: "single", desc: "remote shared slot via api.axe.onl — big-context fallback, NOT default: contended decode measured 1-4.6 tok/s vs local 24-47 (JL1 serves everyone); cold >~100K prefills can also hit the Cloudflare ~125s edge cutoff", endpoint: GATEWAY_BASE, model: "aurora-code-1", ctx: 307200, transport: "openai" },
|
|
52
|
+
{ id: "axe-aurora-300k", tier: "power", label: "Aurora 300K (AXE cloud)", kind: "single", desc: "remote shared slot via api.0perator.co (api.axe.onl as fallback) — big-context fallback, NOT default: contended decode measured 1-4.6 tok/s vs local 24-47 (JL1 serves everyone); cold >~100K prefills can also hit the Cloudflare ~125s edge cutoff", endpoint: GATEWAY_BASE, endpoints: [GATEWAY_BASE, LEGACY_GATEWAY_BASE], model: "aurora-code-1", ctx: 307200, transport: "openai" },
|
|
39
53
|
// Spectre — the flagship, replacing Ghost (2026-10-07). Ghost 32B was the prior self-hosted abliterated
|
|
40
54
|
// Qwen3-VL-32B on this slot; retired when Spectre proved 4× faster at equal capability (its weights + restore
|
|
41
55
|
// command are kept at ~/.axe/logs/ghost-restore-cmd.txt — reversible). Spectre = Huihui-Qwen3.6-35B-A3B-
|
package/dist/session.js
CHANGED
|
@@ -20,7 +20,7 @@ import { modelRegistry, findModel, selectModel, visibleModels, endpointBase, DEF
|
|
|
20
20
|
import { FAST_START_INSTRUCTION, parseFastStartReply } from "./engine/fast-start.js";
|
|
21
21
|
import { getByoToken, hasByoToken } from "./auth/byo.js";
|
|
22
22
|
import { Executor } from "./tools/executor.js";
|
|
23
|
-
import { toSchemas, registry, disposeShellSessionKey, requestShellDetach, cloudAgentToolsFor } from "./tools/registry.js";
|
|
23
|
+
import { toSchemas, registry, disposeShellSessionKey, requestShellDetach, cloudAgentToolsFor, renderActiveTasks } from "./tools/registry.js";
|
|
24
24
|
import { isFeatureEnabled } from "./config/features.js";
|
|
25
25
|
import { MemoryStore } from "./memory/index.js";
|
|
26
26
|
import { McpHub, withMcp } from "./mcp/index.js";
|
|
@@ -77,56 +77,48 @@ function makeSpawnTool(handler) {
|
|
|
77
77
|
return {
|
|
78
78
|
name: "spawn_agent",
|
|
79
79
|
safe: false,
|
|
80
|
-
description: "
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"otherwise. A sub-agent id is NOT a shell_background job id — never poll it with bash_output/bash_kill " +
|
|
99
|
-
"(those are for shell_background only and will just error); use agent_status to check on it, " +
|
|
100
|
-
"message_agent to nudge it, and stop_agent to actually halt it if the user asks you to stop/cancel it. " +
|
|
101
|
-
"RETURN CONTRACT: in the task, tell the sub-agent to report back CONCISELY — a short findings list plus " +
|
|
102
|
-
"file:line pointers, NOT pasted large output (it can re-read files itself). Its report posts back into " +
|
|
103
|
-
"THIS conversation, so a bloated report bloats your own context and can trigger a compaction — scope the " +
|
|
104
|
-
"ask so ~1-2k tokens of findings is enough. SINGLE WRITER: keep file EDITS on one agent in sequence (you); " +
|
|
105
|
-
"spawn sub-agents for READ / SEARCH / REVIEW intelligence, not for parallel writes to the same files — two " +
|
|
106
|
-
"writers on one working tree corrupt each other. Match effort to the task: a lookup is one agent (or just " +
|
|
107
|
-
"do it inline); only genuinely independent, multi-step work is worth a spawn.",
|
|
80
|
+
description: "Spawn sub-agents: isolated sessions on the same model, each with its own shell; only each one's final report " +
|
|
81
|
+
"returns, auto-posted into THIS conversation when it finishes. Pass every subtask in `tasks` — one entry spawns " +
|
|
82
|
+
"one sub-agent, several run in parallel (2 at a time plus 2 queued by default — settings.background.maxConcurrent; " +
|
|
83
|
+
"past the cap the call tells you). When you decide to delegate, make THIS call in the same round — never announce " +
|
|
84
|
+
"\"I'll spawn sub-agents\" without calling spawn_agent. Keep working meanwhile: NEVER sleep, poll or wait for a " +
|
|
85
|
+
"result (agent_status checks state, message_agent steers, stop_agent halts; a sub-agent id is NOT a shell job id — " +
|
|
86
|
+
"bash_output/bash_kill will just error). NEVER re-spawn a task because its result hasn't arrived — it is still " +
|
|
87
|
+
"working. Then finish only what does NOT depend on them, give a one-line status and END YOUR TURN — reports " +
|
|
88
|
+
"re-enter as new messages; a turn that keeps polling holds the model slot and starves the sub-agents.\n" +
|
|
89
|
+
"USE FOR: reasoning-heavy subtasks, work that would flood your context, or independent parallel workstreams " +
|
|
90
|
+
"(research per area, review per module, search per tree, drafting a file).\n" +
|
|
91
|
+
"DO NOT USE FOR: a single tool call; mechanical steps with no reasoning; anything that needs the user (sub-agents " +
|
|
92
|
+
"cannot ask); edits to the same files from several agents.\n" +
|
|
93
|
+
"RULES: the sub-agent knows NOTHING of this conversation — put every path, id and fact in the brief, as a spec: " +
|
|
94
|
+
"**Objective** · **Context** · **Deliverable** · **Constraints** · **Done** (how it proves success). A sub-agent's " +
|
|
95
|
+
"report is a SELF-REPORT — verify side effects (writes, pushes, uploads) yourself before telling the user they " +
|
|
96
|
+
"happened. SINGLE WRITER: keep file edits on one agent (you) and delegate READ / SEARCH / REVIEW / DRAFT work. " +
|
|
97
|
+
"Ask for a CONCISE report (findings + file:line, ~1-2k tokens) — it lands in your context.",
|
|
108
98
|
parameters: {
|
|
109
99
|
type: "object",
|
|
110
100
|
properties: {
|
|
111
|
-
|
|
112
|
-
|
|
101
|
+
tasks: { type: "array", items: { type: "string" }, description: "The subtask brief(s). One entry spawns one sub-agent; several run in parallel. A single task is a one-entry array." },
|
|
102
|
+
task: { type: "string", description: "A single brief (the same as a one-entry `tasks`)." },
|
|
103
|
+
agent: { type: "string", description: "Optional: the name of a repo-local sub-agent persona from .operator/agents/ (listed in your context under 'Repo-local harness'). When set, that persona guides every sub-agent of this call." },
|
|
113
104
|
},
|
|
114
|
-
required: ["task"],
|
|
115
105
|
},
|
|
116
106
|
run: async (args) => {
|
|
117
|
-
const
|
|
118
|
-
if (!
|
|
119
|
-
return "error: spawn_agent needs
|
|
107
|
+
const briefs = (Array.isArray(args.tasks) ? args.tasks.map((t) => String(t ?? "").trim()) : [String(args.task ?? "").trim()]).filter(Boolean);
|
|
108
|
+
if (!briefs.length)
|
|
109
|
+
return "error: spawn_agent needs `tasks` (an array of briefs — one per sub-agent) or `task`";
|
|
120
110
|
const agent = String(args.agent ?? "").trim();
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
111
|
+
// A named repo-local persona: prepend it to the brief (the bg factory uses a fixed system prompt, so the
|
|
112
|
+
// persona rides in the task — a self-contained, low-risk way to specialize the sub-agent).
|
|
113
|
+
const persona = agent ? operatorAgentPersona(agent) : undefined;
|
|
114
|
+
const frame = (task) => !agent ? task : persona
|
|
115
|
+
? `You are acting as the "${agent}" sub-agent for this repo. Follow this persona:\n\n${persona}\n\n---\nYour task:\n${task}`
|
|
116
|
+
: `${task}\n\n(note: no .operator/agents/${agent}.md persona found — ran without it)`;
|
|
117
|
+
if (briefs.length === 1)
|
|
118
|
+
return handler(frame(briefs[0]));
|
|
119
|
+
// Fan-out: one spawn per brief, in order; the manager queues past its running cap and refuses past the
|
|
120
|
+
// in-flight cap — each line reports what happened to that brief, so a partial fan-out is never silent.
|
|
121
|
+
return briefs.map((t, i) => `[${i + 1}/${briefs.length}] ${handler(frame(t))}`).join("\n");
|
|
130
122
|
},
|
|
131
123
|
};
|
|
132
124
|
}
|
|
@@ -469,7 +461,7 @@ export class Session {
|
|
|
469
461
|
const sc = cfg.sleepConsolidation ?? { enabled: true, idleThresholdSec: 30, stepsBetweenPasses: 10, modelTier: "fast" };
|
|
470
462
|
this.sleepScheduler = createSleepScheduler({
|
|
471
463
|
consolidation: { ...sc, enabled: true },
|
|
472
|
-
onComplete: (
|
|
464
|
+
onComplete: () => {
|
|
473
465
|
this.telemetry.record({ type: "error", message: "consolidation completed" });
|
|
474
466
|
},
|
|
475
467
|
});
|
|
@@ -640,6 +632,7 @@ export class Session {
|
|
|
640
632
|
ctxWindow: this.inner.ctxLimit(),
|
|
641
633
|
systemPrompt: this.sys(),
|
|
642
634
|
summarize: this.summarize,
|
|
635
|
+
preservedState: renderActiveTasks() ?? undefined, // the active task list rides with the summary
|
|
643
636
|
minKeepTurns: 2,
|
|
644
637
|
tools: this.allSchemas(), // same full-request basis as the gate and the ctx% bar
|
|
645
638
|
meter: globalTokenMeter,
|
|
@@ -775,7 +768,7 @@ export class Session {
|
|
|
775
768
|
}
|
|
776
769
|
/** Re-point this session at a freshly built endpoint chain. The interactive shell constructs the Session at
|
|
777
770
|
* first render, BEFORE the boot lever has resolved the gateway's dynamic port (server.json) — the chain must
|
|
778
|
-
* follow that resolution or health() and every turn probe
|
|
771
|
+
* follow that resolution or health() and every turn probe "" (unset — auto-discover). Same swap setModel does. A
|
|
779
772
|
* non-default /model pick keeps owning routing; the chain then waits for `/model operator-1m`. */
|
|
780
773
|
useRouter(router) {
|
|
781
774
|
this.chain = router;
|
|
@@ -1185,6 +1178,7 @@ export class Session {
|
|
|
1185
1178
|
spill: spillToolOutput, // GW-10-COMPLETE: runTurn's fitToWindow offloads (node host)
|
|
1186
1179
|
systemPrompt: sys,
|
|
1187
1180
|
summarize: this.summarize,
|
|
1181
|
+
preservedState: () => renderActiveTasks() ?? undefined, // a mid-turn compaction keeps the active task list
|
|
1188
1182
|
background: this.background, // endpoint gate: a sub-agent's rounds yield the shared slot to the main turn
|
|
1189
1183
|
maxTokens: this.maxTokens,
|
|
1190
1184
|
maxTurnTokens: this.maxTurnTokens, // opt-in per-turn cost ceiling (total tokens); undefined → no cap
|
package/dist/tools/document.js
CHANGED
package/dist/tools/registry.js
CHANGED
|
@@ -1252,7 +1252,6 @@ async function briefUpdate(args) {
|
|
|
1252
1252
|
const nextH2 = body.indexOf("\n## ", afterHeading);
|
|
1253
1253
|
const sectionEnd = nextH2 >= 0 ? nextH2 : body.length;
|
|
1254
1254
|
if (mode === "append") {
|
|
1255
|
-
const existing = body.slice(afterHeading, sectionEnd);
|
|
1256
1255
|
body = body.slice(0, sectionEnd) + "\n" + content + "\n" + body.slice(sectionEnd);
|
|
1257
1256
|
}
|
|
1258
1257
|
else {
|
|
@@ -1301,11 +1300,20 @@ async function bashKill(args) {
|
|
|
1301
1300
|
}
|
|
1302
1301
|
const agentTasks = [];
|
|
1303
1302
|
let taskSeq = 0;
|
|
1303
|
+
const TASK_MARK = { pending: "[ ]", in_progress: "[>]", done: "[x]", cancelled: "[~]" };
|
|
1304
1304
|
function renderTasks() {
|
|
1305
1305
|
if (!agentTasks.length)
|
|
1306
1306
|
return "(no tasks yet)";
|
|
1307
|
-
|
|
1308
|
-
|
|
1307
|
+
return agentTasks.map((t) => `${TASK_MARK[t.status]} #${t.id} ${t.text}`).join("\n");
|
|
1308
|
+
}
|
|
1309
|
+
/** The ACTIVE plan (pending / in_progress only) for re-injection after a context compaction, or null when nothing is
|
|
1310
|
+
* active. Finished and cancelled items are left out on purpose — re-reading them after a compaction makes the model
|
|
1311
|
+
* redo work. The header names the event so the model reads it as its own preserved state, not new input. */
|
|
1312
|
+
export function renderActiveTasks() {
|
|
1313
|
+
const active = agentTasks.filter((t) => t.status === "pending" || t.status === "in_progress");
|
|
1314
|
+
if (!active.length)
|
|
1315
|
+
return null;
|
|
1316
|
+
return ["[Your active task list was preserved across context compaction]", ...active.map((t) => `${TASK_MARK[t.status]} #${t.id} ${t.text} (${t.status})`)].join("\n");
|
|
1309
1317
|
}
|
|
1310
1318
|
async function taskAdd(args) {
|
|
1311
1319
|
const items = Array.isArray(args.tasks) ? args.tasks.map(String) : [str(args.text)].filter(Boolean);
|
|
@@ -1327,10 +1335,16 @@ async function taskUpdate(args) {
|
|
|
1327
1335
|
return agentTasks.length
|
|
1328
1336
|
? `error: no task #${id}. task IDs are assigned by task_add (don't guess them) — current tasks:\n${renderTasks()}`
|
|
1329
1337
|
: `error: no tasks exist yet — call task_add first to create them (it returns each task's id), then task_update by that id.`;
|
|
1330
|
-
if (status !== "pending" && status !== "in_progress" && status !== "done")
|
|
1331
|
-
return "error: status must be pending | in_progress | done";
|
|
1338
|
+
if (status !== "pending" && status !== "in_progress" && status !== "done" && status !== "cancelled")
|
|
1339
|
+
return "error: status must be pending | in_progress | done | cancelled";
|
|
1340
|
+
// Exactly ONE step in progress at a time — enforced by code, not by asking: a second in_progress returns the
|
|
1341
|
+
// earlier one to pending and says so, so the plan pane always shows the single step being worked.
|
|
1342
|
+
const demoted = status === "in_progress" ? agentTasks.filter((x) => x.id !== id && x.status === "in_progress") : [];
|
|
1343
|
+
for (const d of demoted)
|
|
1344
|
+
d.status = "pending";
|
|
1332
1345
|
t.status = status;
|
|
1333
|
-
|
|
1346
|
+
const note = demoted.length ? ` (${demoted.map((d) => `#${d.id}`).join(", ")} returned to pending — one task in progress at a time)` : "";
|
|
1347
|
+
return `task #${id} → ${status}${note}\n${renderTasks()}`;
|
|
1334
1348
|
}
|
|
1335
1349
|
// Clear the plan. Default wipes the whole list (the model had no way to honor "clear the list / reset the
|
|
1336
1350
|
// plan / move on" — it could only mark items done). `completed_only` drops finished tasks and keeps the rest.
|
|
@@ -1338,7 +1352,7 @@ async function taskClear(args) {
|
|
|
1338
1352
|
const before = agentTasks.length;
|
|
1339
1353
|
if (Boolean(args.completed_only)) {
|
|
1340
1354
|
for (let i = agentTasks.length - 1; i >= 0; i--)
|
|
1341
|
-
if (agentTasks[i].status === "done")
|
|
1355
|
+
if (agentTasks[i].status === "done" || agentTasks[i].status === "cancelled")
|
|
1342
1356
|
agentTasks.splice(i, 1);
|
|
1343
1357
|
return `cleared ${before - agentTasks.length} completed task(s)\n${renderTasks()}`;
|
|
1344
1358
|
}
|
|
@@ -1840,7 +1854,7 @@ async function imageInspect(args) {
|
|
|
1840
1854
|
return "error: image_inspect needs an image (a local path or an http(s) url)";
|
|
1841
1855
|
const os = await nodeImport("node:os");
|
|
1842
1856
|
const { join } = await nodeImport("node:path");
|
|
1843
|
-
const { mkdtemp, writeFile, rm,
|
|
1857
|
+
const { mkdtemp, writeFile, rm, stat } = await nodeImport("node:fs/promises");
|
|
1844
1858
|
const { execFile } = await nodeImport("node:child_process");
|
|
1845
1859
|
const { promisify } = await nodeImport("node:util");
|
|
1846
1860
|
const pexec = promisify(execFile);
|
|
@@ -2230,20 +2244,20 @@ const TOOLS = [
|
|
|
2230
2244
|
},
|
|
2231
2245
|
{
|
|
2232
2246
|
name: "task_add", safe: false,
|
|
2233
|
-
description: "
|
|
2247
|
+
description: "Track a task list for multi-step work (3+ steps) or when the user gives several tasks — write it FIRST, before acting, with every step as its own item (for \"all N items\" work enumerate each instance so none is silently dropped). List order is priority. The owner sees this list live in the plan pane, so it REPLACES restating the plan in prose. Give `text` for one task or `tasks` (array) for several; returns each task's id.",
|
|
2234
2248
|
parameters: { type: "object", properties: { text: { type: "string" }, tasks: { type: "array", items: { type: "string" } } } },
|
|
2235
2249
|
run: taskAdd,
|
|
2236
2250
|
},
|
|
2237
2251
|
{
|
|
2238
2252
|
name: "task_list", safe: true,
|
|
2239
|
-
description: "Show the session
|
|
2253
|
+
description: "Show the session task list with each task's status ([ ] pending, [>] in progress, [x] done, [~] cancelled). Read it before resuming work after a compaction.",
|
|
2240
2254
|
parameters: { type: "object", properties: {} },
|
|
2241
2255
|
run: taskList,
|
|
2242
2256
|
},
|
|
2243
2257
|
{
|
|
2244
2258
|
name: "task_update", safe: false,
|
|
2245
|
-
description: "Set a task's status
|
|
2246
|
-
parameters: { type: "object", properties: { id: { type: "number" }, status: { type: "string", enum: ["pending", "in_progress", "done"] } }, required: ["id", "status"] },
|
|
2259
|
+
description: "Set a task's status: pending | in_progress | done | cancelled. Exactly ONE task in_progress at a time (marking another in_progress returns the previous one to pending). Mark `in_progress` when you start a step and `done` only after the work is VERIFIED — never on intent. If a step fails, mark it cancelled and task_add a revised one. Update as each step lands, not in a batch at the end.",
|
|
2260
|
+
parameters: { type: "object", properties: { id: { type: "number" }, status: { type: "string", enum: ["pending", "in_progress", "done", "cancelled"] } }, required: ["id", "status"] },
|
|
2247
2261
|
run: taskUpdate,
|
|
2248
2262
|
},
|
|
2249
2263
|
{
|
package/dist/ui/PlanPane.js
CHANGED
|
@@ -2,8 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
3
|
import { theme } from "./theme.js";
|
|
4
4
|
import { bar } from "./chart.js";
|
|
5
|
-
const GLYPH = { pending: "☐", in_progress: "◐", done: "☑" };
|
|
6
|
-
const COLOR = { pending: theme.muted, in_progress: theme.running, done: theme.success };
|
|
5
|
+
const GLYPH = { pending: "☐", in_progress: "◐", done: "☑", cancelled: "⊘" };
|
|
6
|
+
const COLOR = { pending: theme.muted, in_progress: theme.running, done: theme.success, cancelled: theme.muted };
|
|
7
|
+
const finished = (t) => t.status === "done" || t.status === "cancelled";
|
|
7
8
|
/** The header count "n/total done" (pure, testable). */
|
|
8
9
|
export function planProgress(tasks) {
|
|
9
10
|
const done = tasks.filter((t) => t.status === "done").length;
|
|
@@ -14,10 +15,10 @@ export function PlanPane({ tasks, title = "plan" }) {
|
|
|
14
15
|
return null;
|
|
15
16
|
// A fully-completed plan clears itself — once every step is done it has no live value and shouldn't keep
|
|
16
17
|
// occupying the frame. The per-step ✓ already showed as each landed; the finished list drops away.
|
|
17
|
-
if (tasks.every(
|
|
18
|
+
if (tasks.every(finished))
|
|
18
19
|
return null;
|
|
19
20
|
// Borderless: this pane renders in Ink's DYNAMIC region; a box border there orphans its rows into
|
|
20
21
|
// scrollback whenever the Static transcript grows during a long turn (the v0.1.92 line-flood). The
|
|
21
22
|
// dim header labels the group without a border.
|
|
22
|
-
return (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [_jsxs(Text, { dimColor: true, children: [`${title} · ${planProgress(tasks)} `, _jsx(Text, { color: theme.success, children: bar(tasks.filter((t) => t.status === "done").length, tasks.length, 8) })] }), tasks.map((t) => (_jsxs(Text, { children: [_jsxs(Text, { color: COLOR[t.status], children: [GLYPH[t.status], " "] }), _jsx(Text, { dimColor: t
|
|
23
|
+
return (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, children: [_jsxs(Text, { dimColor: true, children: [`${title} · ${planProgress(tasks)} `, _jsx(Text, { color: theme.success, children: bar(tasks.filter((t) => t.status === "done").length, tasks.length, 8) })] }), tasks.map((t) => (_jsxs(Text, { children: [_jsxs(Text, { color: COLOR[t.status], children: [GLYPH[t.status], " "] }), _jsx(Text, { dimColor: finished(t), strikethrough: finished(t), children: t.text })] }, t.id)))] }));
|
|
23
24
|
}
|