@0perator/operator 0.1.360-next.1 → 0.2.0
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/README.md +1 -1
- package/dist/autonomy/delegate-mode.js +159 -0
- package/dist/autonomy/delegate.js +1 -1
- package/dist/autonomy/session-factory.js +8 -2
- package/dist/background/index.js +26 -2
- package/dist/background/resume.js +125 -0
- package/dist/browser/engine.js +163 -0
- package/dist/browser/session.js +172 -134
- package/dist/cli.js +261 -70
- package/dist/config/settings.js +28 -7
- package/dist/config/skills-index.js +4 -0
- package/dist/engine/agent.js +1 -1
- package/dist/engine/aurora.js +22 -13
- package/dist/engine/compaction.js +1 -1
- package/dist/engine/moa.js +2 -1
- package/dist/engine/selfheal.js +1 -1
- package/dist/engine/speed-compaction.js +37 -0
- package/dist/engine/toolcalls.js +6 -6
- package/dist/gateway-cli.js +14 -5
- package/dist/index.js +3 -0
- package/dist/mcp/phone-server.js +30 -0
- package/dist/permissions/index.js +33 -17
- package/dist/permissions/signature.js +5 -0
- package/dist/phone-cli.js +65 -0
- package/dist/remote/host.js +31 -2
- package/dist/router/models.js +49 -25
- package/dist/selfimprove/index.js +1 -1
- package/dist/services/preflight.js +31 -8
- package/dist/session.js +96 -14
- package/dist/tools/deferred.js +1 -0
- package/dist/tools/device/android.js +227 -0
- package/dist/tools/device/classify.js +127 -0
- package/dist/tools/device/deps.js +69 -0
- package/dist/tools/device/desktop.js +82 -0
- package/dist/tools/device/harness.js +262 -0
- package/dist/tools/device/iphone.js +206 -0
- package/dist/tools/device/mirroring-jxa.js +146 -0
- package/dist/tools/device/setup.js +90 -0
- package/dist/tools/device/tools.js +70 -0
- package/dist/tools/device/types.js +19 -0
- package/dist/tools/registry.js +242 -48
- package/dist/tools/vision-media.js +162 -0
- package/dist/ui/App.js +4 -3
- package/dist/ui/ApprovalPrompt.js +10 -4
- package/dist/ui/BgPanel.js +2 -2
- package/dist/ui/UpdatePrompt.js +40 -0
- package/dist/ui/modelPicker.js +26 -8
- package/dist/ui/slashCommands.js +1 -0
- package/dist/update-check.js +134 -0
- package/dist/update.js +82 -13
- package/dist/util/slash.js +2 -2
- package/package.json +4 -2
- package/src/tools/device/NOTICE +37 -0
- package/dist/browser/cdp.js +0 -271
package/dist/remote/host.js
CHANGED
|
@@ -28,7 +28,7 @@ const RECONNECT_MAX_MS = 15_000;
|
|
|
28
28
|
// control frames stay plaintext so the relay can route blind. These sets mirror the mobile's frozen
|
|
29
29
|
// dataFrameTypes byte-for-byte (kode-mobile RemoteSession.swift). The INNER encrypted bytes are
|
|
30
30
|
// JSON.stringify(payloadDict) — just the payload dict, never {type,payload}.
|
|
31
|
-
const DATA_HOST_TYPES = new Set(["snapshot", "transcript", "tool_step", "activity", "status", "capabilities", "approval_request", "ask_user", "delta"]);
|
|
31
|
+
const DATA_HOST_TYPES = new Set(["snapshot", "transcript", "tool_step", "activity", "status", "capabilities", "approval_request", "ask_user", "delta", "agents"]);
|
|
32
32
|
const DATA_DRIVE_TYPES = new Set(["prompt", "command", "approval_response", "ask_user_response", "interrupt", "agent_stop", "agent_steer"]);
|
|
33
33
|
// A paired snapshot is encrypted (base64 ≈ 1.37× plaintext), and the relay drops/truncates any frame over
|
|
34
34
|
// its 256 KB cap — which would corrupt ciphertext. Cap the paired snapshot's plaintext so the encrypted
|
|
@@ -42,6 +42,13 @@ const SNAPSHOT_MAX_BYTES_PAIRED = 170 * 1024;
|
|
|
42
42
|
const SNAPSHOT_MAX_ENTRIES = 200; // SPEC §8: last 200 message-entries + their tool steps, whichever binds first
|
|
43
43
|
const SNAPSHOT_MAX_BYTES = 512 * 1024; // SPEC §8 snapshot cap
|
|
44
44
|
const MCP_TOOL_PREVIEW = 20; // per-server tool NAMES kept when a server's inventory is large — see capCapabilities
|
|
45
|
+
/** The shell's agent list as followers see it: live ones and finished ones until they decommission. */
|
|
46
|
+
export function toRemoteAgents(list) {
|
|
47
|
+
return list.map((a) => ({
|
|
48
|
+
id: a.id, name: a.name ?? a.id, label: a.label, status: a.status, round: a.round ?? 0,
|
|
49
|
+
...(a.resumed ? { resumed: true } : {}), ...(a.endKind ? { endKind: a.endKind } : {}), ...(a.headline ? { headline: a.headline } : {}),
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
45
52
|
const byteLen = (v) => Buffer.byteLength(JSON.stringify(v), "utf8");
|
|
46
53
|
// BLOCKER fix (REMOTE_RICH_HEAD_AUDIT.md §4, "summarize, don't enumerate"): a server's `tools[]` is
|
|
47
54
|
// prefixed to MCP_TOOL_PREVIEW entries — `toolCount` still carries the real total, so a follower's UI
|
|
@@ -79,6 +86,7 @@ export class RemoteHost {
|
|
|
79
86
|
livePending = null;
|
|
80
87
|
turnN = 0;
|
|
81
88
|
capabilities = null;
|
|
89
|
+
agentRows = [];
|
|
82
90
|
// Paired (QR) mode — set from the one-time code the owner shows as a QR. When paired, the host registers
|
|
83
91
|
// its pairingId with the relay and e2e-encrypts every DATA-frame payload with frameKey; the relay (and
|
|
84
92
|
// anyone but the scanning phone) sees only ciphertext.
|
|
@@ -236,7 +244,7 @@ export class RemoteHost {
|
|
|
236
244
|
if (typeof f.payload?.epoch === "number")
|
|
237
245
|
this.epoch = f.payload.epoch; // RC v2 A2
|
|
238
246
|
this.reconnectAttempts = 0; // a successful welcome resets the backoff ladder
|
|
239
|
-
this.
|
|
247
|
+
this.register();
|
|
240
248
|
if (this.paired && this.pairingId)
|
|
241
249
|
this.send("pair-register", this.sessionId, { pairingId: this.pairingId }); // control frame (plaintext) — binds pairingId -> this session at the relay
|
|
242
250
|
// RC v2 A2: a welcome AFTER the first is a RESUME. While the socket was down, state frames were dropped
|
|
@@ -353,8 +361,29 @@ export class RemoteHost {
|
|
|
353
361
|
...(this.epoch != null ? { epoch: this.epoch } : {}), // RC v2 A2: the reliable place to stamp epoch (welcome fires pre-attach)
|
|
354
362
|
...(truncated ? { truncated: true, omittedBefore } : {}),
|
|
355
363
|
...(this.capabilities ? { capabilities: this.capabilities } : {}), // absent until the shell's first setCapabilities() call; already capped by capCapabilities() in setCapabilities()
|
|
364
|
+
...(this.agentRows.length ? { agents: this.agentRows } : {}),
|
|
356
365
|
}, this.seq);
|
|
357
366
|
}
|
|
367
|
+
/** The session row on the relay's list carries how many agents work here, so a phone shows "N agents working" without
|
|
368
|
+
* attaching. Re-sent whenever that count changes; an older relay keeps the fields it knows. */
|
|
369
|
+
register() {
|
|
370
|
+
const agentsWorking = this.agentRows.filter((a) => a.status === "working" || a.status === "queued").length;
|
|
371
|
+
this.send("register", this.sessionId, { title: this.meta.title, surface: this.meta.surface ?? "cli", cwd: this.meta.cwd, host: this.meta.host, agentsWorking });
|
|
372
|
+
}
|
|
373
|
+
/** The host's background agents. Sent as an `agents` state frame when they change (never on an identical list). */
|
|
374
|
+
setAgents(rows) {
|
|
375
|
+
const next = rows.map((a) => ({ ...a }));
|
|
376
|
+
if (JSON.stringify(next) === JSON.stringify(this.agentRows))
|
|
377
|
+
return;
|
|
378
|
+
const working = (r) => r.filter((a) => a.status === "working" || a.status === "queued").length;
|
|
379
|
+
const countChanged = working(next) !== working(this.agentRows);
|
|
380
|
+
this.agentRows = next;
|
|
381
|
+
if (!this.sessionId)
|
|
382
|
+
return;
|
|
383
|
+
this.state("agents", { agents: next });
|
|
384
|
+
if (countChanged)
|
|
385
|
+
this.register();
|
|
386
|
+
}
|
|
358
387
|
/** SPEC §8 snapshot cap: last 200 message/tool entries, then shrink further (oldest-first) until the
|
|
359
388
|
* serialized transcript fits 512 KB — `capabilities` gets its own budget (capCapabilities), so this
|
|
360
389
|
* only accounts for the transcript half. `omittedBefore` is this host's CURRENT seq at truncation
|
package/dist/router/models.js
CHANGED
|
@@ -13,7 +13,18 @@
|
|
|
13
13
|
import { LEGACY_API_HOST, PRODUCT_API_HOST } from "../config/product-hosts.js"; // no imports of its own — no cycle
|
|
14
14
|
/** Fallback walk order, strongest → cheapest. */
|
|
15
15
|
export const TIER_LADDER = ["power_turbo", "power", "economy", "lite", "free"];
|
|
16
|
+
/** The Aurora row whose endpoints are the shell's own chain (endpoints.aurora + its failover legs). Since 0.1.361 it is
|
|
17
|
+
* no longer the model a fresh install starts on — that is DEFAULT_ACTIVE_MODEL. */
|
|
16
18
|
export const DEFAULT_MODEL_ID = "operator-1m";
|
|
19
|
+
/** The model a session starts on when settings.activeModel is not set (a fresh install): the router's
|
|
20
|
+
* `operator-flash` route. A persisted activeModel always wins. */
|
|
21
|
+
export const DEFAULT_ACTIVE_MODEL = "operator-flash";
|
|
22
|
+
/** Rows retired from the picker (11/25): never in /model or the ACP dropdown, still resolvable by id so a persisted
|
|
23
|
+
* activeModel, a script or a delegate target keeps working. A settings.models row with one of these ids is hidden too
|
|
24
|
+
* unless it says `hidden: false`. */
|
|
25
|
+
export const RETIRED_MODEL_IDS = new Set([
|
|
26
|
+
"operator-1m", "aurora", "cortana", "thor", "scout", "casanova", "falcon-h1-34b", "belmont-30b", "venice-24b", "dolphin-7b",
|
|
27
|
+
]);
|
|
17
28
|
// Back-compat aliases: the user-facing ids were renamed aurora-* -> operator-* (the outward name is
|
|
18
29
|
// Operator; "aurora" is the internal model, never shown). The OLD ids still resolve — a persisted
|
|
19
30
|
// settings.activeModel: "aurora-1m", a `/model aurora-1m`, or any muscle memory keeps working — so the
|
|
@@ -38,37 +49,39 @@ export const LEGACY_GATEWAY_BASE = `https://${LEGACY_API_HOST}/v1`;
|
|
|
38
49
|
const ANTHROPIC_BASE = "https://api.anthropic.com/v1";
|
|
39
50
|
const GEMINI_BASE = "https://generativelanguage.googleapis.com/v1beta/openai"; // Google's OpenAI-compatible surface — no native transport
|
|
40
51
|
const GEMINI_CHAT_PATH = "/chat/completions"; // the base already carries its version: …/v1beta/openai/chat/completions
|
|
41
|
-
const QWEN_BASE = "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1";
|
|
42
52
|
/** Output ceilings (ModelProfile.maxOutput) — only where the vendor's limit is cited. Anthropic: the current Claude
|
|
43
|
-
* family's max_tokens ceiling (a larger value is a 400).
|
|
44
|
-
* 2026-10-28 — "Range of max_tokens should be [1, 131072]". */
|
|
53
|
+
* family's max_tokens ceiling (a larger value is a 400). */
|
|
45
54
|
export const ANTHROPIC_MAX_OUTPUT = 128_000;
|
|
46
|
-
const QWEN_FLASH_MAX_OUTPUT = 131_072;
|
|
47
55
|
const NOUS_BASE = "https://inference-api.nousresearch.com/v1";
|
|
48
|
-
// Registry order IS picker order (visibleModels keeps it): the local row, then the gateway rows, then the
|
|
56
|
+
// Registry order IS picker order (visibleModels keeps it): the main three, the local row, then the gateway rows, then the
|
|
49
57
|
// connected-provider rows (hidden until their key is connected), then the by-id-only lanes, then MOA. Free
|
|
50
58
|
// vendor rows (tier "free") arrive at runtime through Session.dynamicModels and land after all of these.
|
|
51
59
|
// A deployment's own servers (direct endpoints, owner-only trials, its labels and descriptions) are NOT listed
|
|
52
60
|
// here: they come from settings.models, which adds rows and overrides these by id (modelRegistry).
|
|
53
61
|
export const BUILTIN_MODELS = [
|
|
62
|
+
// ── main (0.1.361): the three /model rows, in this order (ui/modelPicker.ts MAIN_MODEL_IDS) ─────────────────
|
|
63
|
+
// Router routes of the same name, gateway-first like every gateway row. `ctx` is the window the route serves.
|
|
64
|
+
{ id: "operator-flash", tier: "power", label: "Operator-Flash", params: "125B-A6B", box: "gateway", kind: "single", desc: "the default model: a fast MoE with n-gram speculation", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: ["operator-flash", "operator-flash"], model: "operator-flash", ctx: 131072 },
|
|
65
|
+
{ id: "kimi-linear-48b", tier: "power", label: "Kimi-Linear", params: "48B-A3B", box: "gateway", kind: "single", desc: "long-context MoE", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: ["kimi-linear-48b", "kimi-linear-48b"], model: "kimi-linear-48b", ctx: 262144 },
|
|
66
|
+
{ id: "operator-dense", tier: "power", label: "Operator-Dense", params: "27B", box: "gateway", kind: "single", desc: "dense model with n-gram and MTP speculation; loads on demand", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: ["operator-dense", "operator-dense"], model: "operator-dense", ctx: 131072 },
|
|
54
67
|
// ── local ───────────────────────────────────────────────────────────────────────────────────────────────
|
|
55
|
-
// THE one Aurora row (0.1.332). The 300K/600K/1M choice is a
|
|
56
|
-
// Ctrl+X) applied over the served window — not three profiles of one
|
|
57
|
-
// gateway-less fallback; on a gateway box Session.setModel restores the shell's chain
|
|
58
|
-
// dynamic port + the fleet and cloud legs buildEndpointChain assembles).
|
|
59
|
-
{ id: "operator-1m", tier: "power", label: "Aurora Code 1", params: "35B-A3B", box: "local", kind: "single", desc: "
|
|
68
|
+
// THE one Aurora row (0.1.332), retired from the picker 11/25 (RETIRED_MODEL_IDS). The 300K/600K/1M choice is a
|
|
69
|
+
// context PIN (settings.contextPin, /context, Ctrl+X) applied over the served window — not three profiles of one
|
|
70
|
+
// model. The static :8097 is the gateway-less fallback; on a gateway box Session.setModel restores the shell's chain
|
|
71
|
+
// for this id (the dynamic port + the fleet and cloud legs buildEndpointChain assembles).
|
|
72
|
+
{ id: "operator-1m", tier: "power", label: "Aurora Code 1", params: "35B-A3B", box: "local", kind: "single", desc: "served on this machine; the gateway takes over when it is down", endpoint: "http://127.0.0.1:8097/v1", model: "aurora-code-1", ctx: 1000000, hidden: true },
|
|
60
73
|
// ── gateway ─────────────────────────────────────────────────────────────────────────────────────────────
|
|
61
74
|
// GATEWAY-FIRST: the local gateway when this machine runs one, then the public face. `ctx` is the window the
|
|
62
75
|
// gateway serves. The 0.1.260 lesson stands: a profile that claims MORE than the server's --ctx-size makes the
|
|
63
76
|
// engine overrun the wall and the server cuts a round mid-tool-call (0.1.259) — change a number ONLY when the
|
|
64
|
-
// served window changes.
|
|
65
|
-
{ id: "cortana", tier: "power", label: "Cortana", params: "35B-A3B", box: "gateway", kind: "single", desc: "general model with vision", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: ["cortana", "cortana"], model: "cortana", ctx: 262144 },
|
|
77
|
+
// served window changes. cortana, thor and scout are retired from the picker (RETIRED_MODEL_IDS) and resolve by id.
|
|
78
|
+
{ id: "cortana", tier: "power", label: "Cortana", params: "35B-A3B", box: "gateway", kind: "single", desc: "general model with vision", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: ["cortana", "cortana"], model: "cortana", ctx: 262144, hidden: true },
|
|
66
79
|
{ id: "gpt-oss-20b", tier: "economy", label: "gpt-oss", params: "20B-A3.6B", box: "gateway", kind: "single", desc: "OpenAI gpt-oss-20b — the MoA specialist", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: ["gpt-oss-20b", "gpt-oss-20b"], model: "gpt-oss-20b", ctx: 65536 },
|
|
67
|
-
{ id: "thor", tier: "power", label: "Thor", params: "32B", box: "gateway", kind: "single", desc: "reasoning model — thinks before answering", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: ["thor", "thor"], model: "thor", ctx: 32768 },
|
|
68
|
-
{ id: "scout", tier: "lite", label: "Scout", params: "4B", box: "gateway", kind: "single", desc: "fast small model", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: ["scout", "scout"], model: "scout", ctx: 32000 },
|
|
80
|
+
{ id: "thor", tier: "power", label: "Thor", params: "32B", box: "gateway", kind: "single", desc: "reasoning model — thinks before answering", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: ["thor", "thor"], model: "thor", ctx: 32768, hidden: true },
|
|
81
|
+
{ id: "scout", tier: "lite", label: "Scout", params: "4B", box: "gateway", kind: "single", desc: "fast small model", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: ["scout", "scout"], model: "scout", ctx: 32000, hidden: true },
|
|
69
82
|
// ── connected providers (BYO: hidden until the vendor key is connected — /model "+ Connect a provider key") ──
|
|
70
83
|
// Claude — BYO Anthropic connectors, so "delegate to Claude" and `/model claude-sonnet` work. Unlike the
|
|
71
|
-
//
|
|
84
|
+
// OpenAI-dialect connectors, Claude speaks the NATIVE Anthropic Messages wire — transport
|
|
72
85
|
// "anthropic" routes it through engine/anthropic-chat.ts (x-api-key auth from the BYO "anthropic" key; the
|
|
73
86
|
// Operator token is NEVER sent here — authHeaders scoping + anthropic-chat's own key resolution). Model ids
|
|
74
87
|
// are the vendor's complete 5.5-family ids (never a date suffix); ctx is the documented 1M, self-clamps to served truth.
|
|
@@ -79,12 +92,6 @@ export const BUILTIN_MODELS = [
|
|
|
79
92
|
// strict openai dialect is what that surface accepts). Same "gemini" key account as the byo-model preset.
|
|
80
93
|
{ id: "gemini-pro", tier: "power_turbo", label: "Gemini 2.5 Pro", box: "Google", kind: "single", desc: "BYO Google — Gemini 2.5 Pro over the OpenAI-compatible base, your Gemini key", endpoint: GEMINI_BASE, model: "gemini-2.5-pro", ctx: 1000000, byo: "gemini", transport: "openai", chatPath: GEMINI_CHAT_PATH },
|
|
81
94
|
{ id: "gemini-flash", tier: "economy", label: "Gemini 2.5 Flash", box: "Google", kind: "single", desc: "BYO Google — the fast Gemini tier, your Gemini key", endpoint: GEMINI_BASE, model: "gemini-2.5-flash", ctx: 1000000, byo: "gemini", transport: "openai", chatPath: GEMINI_CHAT_PATH },
|
|
82
|
-
// QwenCloud Token Plan BYO connectors (SPEC/providers.md §2 "API-key connectors"). Same keychain
|
|
83
|
-
// account ("qwen") serves both; the picker hides them until connected (§1 honest availability), and
|
|
84
|
-
// authHeaders NEVER sends the Operator token to this host. ctx starts conservative and self-clamps
|
|
85
|
-
// to the served truth (observeContext).
|
|
86
|
-
{ id: "qwen3.8-max", tier: "power_turbo", label: "Qwen 3.8 Max", box: "QwenCloud", kind: "single", desc: "BYO QwenCloud Token Plan — credits from your plan", endpoint: QWEN_BASE, model: "qwen3.8-max", ctx: 262144, byo: "qwen", transport: "openai" },
|
|
87
|
-
{ id: "qwen3.8-flash", tier: "economy", label: "Qwen 3.8 Flash", box: "QwenCloud", kind: "single", desc: "BYO QwenCloud Token Plan — fast tier, your credits", endpoint: QWEN_BASE, model: "qwen3.8-flash", ctx: 262144, maxOutput: QWEN_FLASH_MAX_OUTPUT, byo: "qwen", transport: "openai" },
|
|
88
95
|
// ── by-id lanes (hidden from the picker, still resolve) ────────────────────────────────────────────────
|
|
89
96
|
// The cloud slot of the SAME Aurora, folded out of the picker in 0.1.332 (one Aurora row; the cloud legs ride
|
|
90
97
|
// in buildEndpointChain's failover chain). Reachable by id for scripts. api.0perator.co is AXE's OWN gateway
|
|
@@ -114,7 +121,6 @@ export const BYO_PRESETS = {
|
|
|
114
121
|
openrouter: { label: "OpenRouter", box: "OpenRouter", endpoint: "https://openrouter.ai/api/v1", model: "openai/gpt-5", ctx: 200000, account: "openrouter", envAlias: "OPENROUTER_API_KEY" },
|
|
115
122
|
together: { label: "Together", box: "Together", endpoint: "https://api.together.xyz/v1", model: "meta-llama/Llama-3.3-70B-Instruct-Turbo", ctx: 131072, account: "together", envAlias: "TOGETHER_API_KEY" },
|
|
116
123
|
xai: { label: "xAI Grok", box: "xAI", endpoint: "https://api.x.ai/v1", model: "grok-4", ctx: 256000, account: "xai", envAlias: "XAI_API_KEY" },
|
|
117
|
-
qwen: { label: "QwenCloud", box: "QwenCloud", endpoint: QWEN_BASE, model: "qwen3.8-max", ctx: 262144, account: "qwen" },
|
|
118
124
|
// Nous Portal — the free cloud tier (router/free-models.ts lists its `:free` rows once this key is connected;
|
|
119
125
|
// the vendor requires an account even for free models). 50 RPM / 500k TPM; prompts may be used for training.
|
|
120
126
|
// 0perator's own free catalog (portal router behind AuthGate): the free models we serve with OUR provider accounts,
|
|
@@ -132,14 +138,32 @@ export function modelRegistry(overrides) {
|
|
|
132
138
|
if (!overrides?.length)
|
|
133
139
|
return BUILTIN_MODELS;
|
|
134
140
|
const byId = new Map(BUILTIN_MODELS.map((m) => [m.id, m]));
|
|
135
|
-
for (const m of overrides)
|
|
136
|
-
|
|
141
|
+
for (const m of overrides) {
|
|
142
|
+
const merged = { ...byId.get(m.id), ...m };
|
|
143
|
+
byId.set(m.id, RETIRED_MODEL_IDS.has(m.id) && merged.hidden === undefined ? { ...merged, hidden: true } : merged);
|
|
144
|
+
}
|
|
137
145
|
return [...byId.values()];
|
|
138
146
|
}
|
|
139
147
|
export function findModel(registry, id) {
|
|
140
148
|
const canon = MODEL_ALIASES[id] ?? id; // aurora-1m -> operator-1m (old ids keep resolving)
|
|
141
149
|
return registry.find((m) => m.id === canon);
|
|
142
150
|
}
|
|
151
|
+
/** The router capability a failed turn falls back to when settings.fallbackModel is unset (11/25: the gateway's `main`
|
|
152
|
+
* route — Kimi/Athena behind the router — replaced the launchd-owned Aurora row as the fallback). */
|
|
153
|
+
export const DEFAULT_FALLBACK_MODEL = "main";
|
|
154
|
+
/** The model that answers a turn whose own legs all failed (Session.turnModel). A registry row with that id answers as
|
|
155
|
+
* itself; any other id is a router capability, reached through the gateway (loopback first, then the public face).
|
|
156
|
+
* Never the launchd-owned default row: a fallback must not wake a model the owner parked, so that id resolves to the
|
|
157
|
+
* default capability instead. */
|
|
158
|
+
export function fallbackProfile(registry, id) {
|
|
159
|
+
const want = id?.trim() || DEFAULT_FALLBACK_MODEL;
|
|
160
|
+
const canon = MODEL_ALIASES[want] ?? want;
|
|
161
|
+
const name = canon === DEFAULT_MODEL_ID ? DEFAULT_FALLBACK_MODEL : canon;
|
|
162
|
+
const row = findModel(registry, name);
|
|
163
|
+
if (row?.kind === "single")
|
|
164
|
+
return row;
|
|
165
|
+
return { id: name, label: name, box: "gateway", kind: "single", desc: "router capability", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: [name, name], model: name };
|
|
166
|
+
}
|
|
143
167
|
/** The tier of a model id (alias-aware), or undefined when the profile has none. */
|
|
144
168
|
export function tierOf(registry, id) {
|
|
145
169
|
return findModel(registry, id)?.tier;
|
|
@@ -191,7 +215,7 @@ export function modelCtxFor(id, overrides) {
|
|
|
191
215
|
return Number.POSITIVE_INFINITY;
|
|
192
216
|
return findModel(modelRegistry(overrides), id)?.ctx ?? Number.POSITIVE_INFINITY;
|
|
193
217
|
}
|
|
194
|
-
/** ctx window below which the lean harness (no heavy memory/handoff) kicks in. Aurora
|
|
218
|
+
/** ctx window below which the lean harness (no heavy memory/handoff) kicks in. Aurora and the gateway models (128K+) stay
|
|
195
219
|
* full; a self-hosted small model (8K, or a 16K bump) goes lean. */
|
|
196
220
|
export const LEAN_HARNESS_CTX = 32768;
|
|
197
221
|
/** The default served-window floor for the model a session runs its full harness on (settings.contextFloor): below it
|
|
@@ -12,7 +12,7 @@ import { inferType } from "../engine/grandmaster.js";
|
|
|
12
12
|
import { methodFromSteps, mergeSkill, skillClassSlug } from "./skills.js";
|
|
13
13
|
const nodeImport = (m) => import(/* @vite-ignore */ m);
|
|
14
14
|
// GW-18 (flywheel gate): markers of a STRUCTURED tool call that leaked into the assistant's plain text instead
|
|
15
|
-
// of being parsed into tool_calls —
|
|
15
|
+
// of being parsed into tool_calls — a documented failure of XML tool-call models when the server runs without `--jinja` (the
|
|
16
16
|
// heuristic parser passes the XML through as content with finish_reason:"stop"). A turn like this is the worst
|
|
17
17
|
// possible training row: it's recorded as a "completed" turn, but the assistant text IS raw tool markup, so
|
|
18
18
|
// training on it teaches the model to EMIT the markup as prose — the agent self-poisons on its own parser bug.
|
|
@@ -18,6 +18,17 @@
|
|
|
18
18
|
// • SearXNG is session-scoped and owned by tools/searxng.ts (lazy start + idle/exit stop) — the only
|
|
19
19
|
// service Operator tears down, via stopSessionServices() below.
|
|
20
20
|
const nodeImport = (m) => import(/* @vite-ignore */ m);
|
|
21
|
+
/** True when `launchctl print-disabled` output lists `label` as disabled (`"label" => disabled`, or `true` on older
|
|
22
|
+
* macOS). A job the owner disabled is never started by Operator: `kickstart -k` would run a disabled job that is still
|
|
23
|
+
* loaded, and `enable` + `bootstrap` would undo the owner's `launchctl disable`. */
|
|
24
|
+
export function isLaunchdDisabled(printDisabled, label) {
|
|
25
|
+
const esc = label.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
26
|
+
return new RegExp(`"${esc}"\\s*=>\\s*(disabled|true)\\b`).test(printDisabled);
|
|
27
|
+
}
|
|
28
|
+
/** The one line a turn shows when the job it needs is disabled. */
|
|
29
|
+
export function disabledLine(name, label) {
|
|
30
|
+
return `${name} is disabled in launchd (${label}) — not starting it; using the next backend`;
|
|
31
|
+
}
|
|
21
32
|
function expandHome(p) {
|
|
22
33
|
return p.startsWith("~/") ? `${process.env.HOME ?? ""}${p.slice(1)}` : p;
|
|
23
34
|
}
|
|
@@ -128,21 +139,26 @@ async function kickLaunchd(name, cfg, onProgress) {
|
|
|
128
139
|
}
|
|
129
140
|
return { name, state: "skipped", detail: `not installed (${expandHome(cfg.plistPath)} missing) — run: operator setup-services` };
|
|
130
141
|
}
|
|
142
|
+
const run = cfg.launchctl ?? launchctl;
|
|
143
|
+
const disabled = await run(["print-disabled", `gui/${uid}`]);
|
|
144
|
+
if (disabled.code === 0 && isLaunchdDisabled(disabled.out, label))
|
|
145
|
+
return { name, state: "disabled", detail: disabledLine(name, label) };
|
|
131
146
|
onProgress?.(`starting ${name} via launchd…`);
|
|
132
147
|
const target = `gui/${uid}/${label}`;
|
|
133
148
|
// 1) fast path: the job is loaded but its port died — kick it.
|
|
134
|
-
const kick = await
|
|
149
|
+
const kick = await run(["kickstart", "-k", target]);
|
|
135
150
|
if (kick.code !== 0) {
|
|
136
151
|
// 2) not cleanly loaded — clear any half-state (bootout, ignore "no such process") then bootstrap
|
|
137
152
|
// the plist fresh and start it. Tolerate the known bootstrap I/O-error(5) race: the job usually
|
|
138
|
-
// still lands in the domain, so we poll the port regardless of the exit code.
|
|
153
|
+
// still lands in the domain, so we poll the port regardless of the exit code. `enable` clears a
|
|
154
|
+
// stale override only: a job the owner disabled was refused above.
|
|
139
155
|
if (!cfg.plistPath)
|
|
140
156
|
return { name, state: "down", detail: `down (kickstart failed: ${kick.out.slice(0, 80)}; no plistPath to bootstrap)` };
|
|
141
|
-
await
|
|
157
|
+
await run(["bootout", target]).catch(() => undefined);
|
|
142
158
|
await new Promise((res) => setTimeout(res, 1500)); // let the old proc release the port + mlock
|
|
143
|
-
await
|
|
144
|
-
await
|
|
145
|
-
await
|
|
159
|
+
await run(["enable", target]);
|
|
160
|
+
await run(["bootstrap", `gui/${uid}`, expandHome(cfg.plistPath)]);
|
|
161
|
+
await run(["kickstart", target]);
|
|
146
162
|
}
|
|
147
163
|
return null;
|
|
148
164
|
}
|
|
@@ -228,14 +244,21 @@ export async function waitForAurora(cfg, waitSec, signal) {
|
|
|
228
244
|
/** The Session's onDemand hook for a local Aurora: before a turn on the default model, make sure the gateway is
|
|
229
245
|
* serving (start it if not), and when its published base or key changed write them onto `endpoint` and return
|
|
230
246
|
* `rebuild()`. Inert where Aurora is not a local launchd job, so a remote endpoint is never probed per turn. */
|
|
231
|
-
export function auroraOnDemand(endpoint, svc, rebuild, onProgress) {
|
|
247
|
+
export function auroraOnDemand(endpoint, svc, rebuild, onProgress, onDisabled) {
|
|
232
248
|
let local;
|
|
249
|
+
let told = false;
|
|
233
250
|
return async (signal) => {
|
|
234
251
|
local ??= localAuroraJob(svc ?? {});
|
|
235
252
|
if (!(await local))
|
|
236
253
|
return null;
|
|
237
254
|
const cfg = { ...svc, base: endpoint.base, apiKey: endpoint.apiKey };
|
|
238
|
-
await ensureAurora(cfg, onProgress, signal);
|
|
255
|
+
const report = await ensureAurora(cfg, onProgress, signal);
|
|
256
|
+
if (report.state === "disabled") {
|
|
257
|
+
if (!told && report.detail)
|
|
258
|
+
onDisabled?.(report.detail); // once per session: the router's next leg answers every turn
|
|
259
|
+
told = true;
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
239
262
|
if (cfg.base === endpoint.base && cfg.apiKey === endpoint.apiKey)
|
|
240
263
|
return null;
|
|
241
264
|
endpoint.base = cfg.base;
|
package/dist/session.js
CHANGED
|
@@ -9,22 +9,24 @@ import { homedir } from "node:os";
|
|
|
9
9
|
import { chat, health, reachable, gateKey, isRemoteBase, shipsLlamaCacheKnobs, requiresOperatorToken, operatorTrustedUrl } from "./engine/aurora.js";
|
|
10
10
|
import { claimSlot, releaseSlot } from "./engine/kv-slot.js";
|
|
11
11
|
import { randomUUID } from "node:crypto";
|
|
12
|
+
import { recordDecodeSample, speedCompactionDue } from "./engine/speed-compaction.js";
|
|
12
13
|
import { compact, compactionSplit, fitToWindow, turnStarts, SUMMARY_INSTRUCTION, stripTrailingOrphanToolCall, pickSummaryContent, renderAnchorIndex, verbatimUserTail, applyAnchorVerification } from "./engine/compaction.js";
|
|
13
14
|
import { globalTokenMeter, endpointKey } from "./engine/token-meter.js";
|
|
14
15
|
import { spillToolOutput } from "./tools/tool-output-spill.js"; // GW-10-COMPLETE: node-side spill sink
|
|
15
16
|
import { engineRouter } from "./engine/router-adapter.js";
|
|
16
|
-
import { appendFileSync, mkdirSync } from "node:fs";
|
|
17
|
+
import { appendFileSync, existsSync, mkdirSync, realpathSync } from "node:fs";
|
|
17
18
|
import { dirname } from "node:path";
|
|
18
19
|
import { operatorPath } from "./config/home.js";
|
|
19
20
|
import { moaTeam, plannerBrief } from "./engine/moa.js";
|
|
20
21
|
import { routeTurn } from "./classifier/route.js";
|
|
21
22
|
import { engineNote, isStatusAsk, STATUS_FIRST_NOTE } from "./engine/continuation.js";
|
|
22
23
|
import { withDelegateDefault } from "./autonomy/delegate.js";
|
|
24
|
+
import { withDelegateGuard } from "./autonomy/delegate-mode.js";
|
|
23
25
|
import { routeShadowTurn, shadowPrompt } from "./moa/shadow.js"; // MOA phase-0 observability (KODE_MOA_SHADOW)
|
|
24
26
|
import { AuroraRouter } from "./router/router.js";
|
|
25
27
|
import { operatorAgentPersona } from "./config/operator-harness.js";
|
|
26
28
|
import { progressDeadline, summaryCeilingMs, DeadlineError } from "./engine/progress-deadline.js";
|
|
27
|
-
import { modelRegistry, findModel, selectModel, visibleModels, endpointBase, profileEndpoint, fmtCtx, MIN_CONTEXT_PIN, AGENT_CTX_FLOOR, AGENT_CTX_TARGET, DEFAULT_MODEL_ID, LEAN_HARNESS_CTX } from "./router/models.js";
|
|
29
|
+
import { modelRegistry, findModel, fallbackProfile, selectModel, visibleModels, endpointBase, profileEndpoint, fmtCtx, MIN_CONTEXT_PIN, AGENT_CTX_FLOOR, AGENT_CTX_TARGET, DEFAULT_MODEL_ID, LEAN_HARNESS_CTX } from "./router/models.js";
|
|
28
30
|
import { probeServed, usableCtx } from "./router/discovery.js";
|
|
29
31
|
import { FAST_START_INSTRUCTION, parseFastStartReply } from "./engine/fast-start.js";
|
|
30
32
|
import { askFrontDoor, recentTurns } from "./engine/front-door.js";
|
|
@@ -429,6 +431,9 @@ export class Session {
|
|
|
429
431
|
maxRoundsHard;
|
|
430
432
|
compactionThreshold;
|
|
431
433
|
compactionCeilingTokens;
|
|
434
|
+
compactionMinDecodeTps;
|
|
435
|
+
decodeSamples = []; // the last measured turns' decode, for the speed trigger
|
|
436
|
+
fallbackModelId; // settings.fallbackModel (turnModel)
|
|
432
437
|
background;
|
|
433
438
|
owner;
|
|
434
439
|
temperature;
|
|
@@ -574,6 +579,8 @@ export class Session {
|
|
|
574
579
|
this.maxRoundsHard = cfg.maxRoundsHard;
|
|
575
580
|
this.compactionThreshold = cfg.compactionThreshold;
|
|
576
581
|
this.compactionCeilingTokens = cfg.compactionCeilingTokens;
|
|
582
|
+
this.compactionMinDecodeTps = cfg.compactionMinDecodeTps;
|
|
583
|
+
this.fallbackModelId = cfg.fallbackModel;
|
|
577
584
|
this.contextFloor = cfg.contextFloor ?? AGENT_CTX_FLOOR;
|
|
578
585
|
this.background = cfg.background ?? false;
|
|
579
586
|
this.owner = cfg.owner;
|
|
@@ -680,7 +687,14 @@ export class Session {
|
|
|
680
687
|
: this.policy;
|
|
681
688
|
const approve = this.planMode ? undefined : this.approve; // no approver in plan mode = hard read-only
|
|
682
689
|
const base = withPermissions(withMcp(this.executor, this.hub), policy, { approve, sink: this.eventSink, actor: this.eventActor, session: this.sessionId });
|
|
683
|
-
|
|
690
|
+
// Delegate mode's fence sits above the gate: a call it refuses never asks the owner to approve it. Off = pass-through.
|
|
691
|
+
const guarded = withDelegateGuard(base, { cwd: this.cwd ?? process.cwd(), exists: existsSync, realpath: (p) => { try {
|
|
692
|
+
return realpathSync(p);
|
|
693
|
+
}
|
|
694
|
+
catch {
|
|
695
|
+
return p;
|
|
696
|
+
} } });
|
|
697
|
+
const hooked = withHooks(guarded, this.hooks, { cwd: this.cwd ?? process.cwd(), session: this.sessionId ?? "" });
|
|
684
698
|
if (this.nativeDeferred)
|
|
685
699
|
return withNativeDeferred(hooked, this.nativeDeferred);
|
|
686
700
|
return this.deferred ? withDeferred(hooked, this.deferred) : hooked;
|
|
@@ -790,7 +804,13 @@ export class Session {
|
|
|
790
804
|
* selected endpoint's. */
|
|
791
805
|
healthTarget() {
|
|
792
806
|
const planner = findModel(this.liveRegistry(), this.modelId)?.kind === "orchestrated" ? moaTeam(this.moaConfig)?.planner : undefined;
|
|
793
|
-
|
|
807
|
+
if (!planner)
|
|
808
|
+
return this.inner.base;
|
|
809
|
+
if (planner.endpoint)
|
|
810
|
+
return endpointBase(planner.endpoint);
|
|
811
|
+
const row = findModel(this.liveRegistry(), planner.id);
|
|
812
|
+
const ep = row ? profileEndpoint(row) : undefined;
|
|
813
|
+
return ep ? endpointBase(ep) : this.inner.base;
|
|
794
814
|
}
|
|
795
815
|
/** Is the endpoint the current model talks to reachable? Lets the shell fail clearly before a turn. Probes the
|
|
796
816
|
* way reachable() does, because a non-default model's endpoint is often the portal router, which has /healthz
|
|
@@ -1047,6 +1067,7 @@ export class Session {
|
|
|
1047
1067
|
/** Reset the conversation to empty (for /new). */
|
|
1048
1068
|
reset() {
|
|
1049
1069
|
this.convo.replaceAll([]);
|
|
1070
|
+
this.decodeSamples = [];
|
|
1050
1071
|
this.rollingSummarizer.clear(); // clear the rolling summary on new session
|
|
1051
1072
|
this.planApproval.clear(); // a fresh conversation has no reviewed plan
|
|
1052
1073
|
this.planReviewTold = false; // …and has not been told the mode
|
|
@@ -1096,7 +1117,7 @@ export class Session {
|
|
|
1096
1117
|
/** The model answering this turn — the /model pick, or the default row once the pick's fallback took the turn — so a
|
|
1097
1118
|
* read or decode rate is credited to the model that did the work, never to the owner's pick. */
|
|
1098
1119
|
answeringModel() {
|
|
1099
|
-
return this.turnFellBack ?
|
|
1120
|
+
return this.turnFellBack ? fallbackProfile(this.liveRegistry(), this.fallbackModelId).id : this.modelId;
|
|
1100
1121
|
}
|
|
1101
1122
|
/** The endpoint chain for a single-endpoint profile (/model, and the MoA specialist's fast path). */
|
|
1102
1123
|
routerForProfile(profile) {
|
|
@@ -1125,17 +1146,19 @@ export class Session {
|
|
|
1125
1146
|
return new AuroraRouter(eps);
|
|
1126
1147
|
}
|
|
1127
1148
|
/** A turn's model as the owner reads it, and its fallback (runTurn's TurnModel): when every leg of another model
|
|
1128
|
-
* fails, or it keeps finishing with nothing,
|
|
1129
|
-
* the
|
|
1149
|
+
* fails, or it keeps finishing with nothing, settings.fallbackModel answers that turn (default: the router's `main`,
|
|
1150
|
+
* never the launchd-owned Aurora row) — the owner's choice stays, so the next turn tries the chosen model first again.
|
|
1151
|
+
* A row with `fallback: false`, or the fallback itself, keeps its turns on its own legs. */
|
|
1130
1152
|
turnModel(id) {
|
|
1131
1153
|
const reg = this.liveRegistry();
|
|
1132
1154
|
const profile = findModel(reg, id);
|
|
1133
1155
|
if (profile?.kind !== "single")
|
|
1134
1156
|
return undefined;
|
|
1135
|
-
const
|
|
1157
|
+
const fb = fallbackProfile(reg, this.fallbackModelId);
|
|
1158
|
+
const use = profile.id === fb.id || profile.fallback === false ? undefined : fb;
|
|
1136
1159
|
return {
|
|
1137
1160
|
name: profile.label,
|
|
1138
|
-
fallback:
|
|
1161
|
+
fallback: use ? () => { this.turnFellBack = true; return { name: use.label, router: this.wrap(this.routerForProfile(use)) }; } : undefined,
|
|
1139
1162
|
};
|
|
1140
1163
|
}
|
|
1141
1164
|
/** Switch the active model (/model). A "single" profile rebuilds the router to point at that
|
|
@@ -1143,12 +1166,37 @@ export class Session {
|
|
|
1143
1166
|
* to. "moa" has no endpoint of its own; send() special-cases it (sendMoa) instead. Returns an
|
|
1144
1167
|
* error instead of throwing, so the shell can show it inline: an unknown id, or "moa" selected
|
|
1145
1168
|
* with no settings.moa configured. */
|
|
1169
|
+
/** `/delegate planner`: a /model id plans MoA turns (moa.plannerModel), with `specialist` as the executor when given.
|
|
1170
|
+
* "" clears it back to moa.planner. Applies from the next MoA turn (sendMoa reads the team per turn). Refused when
|
|
1171
|
+
* the id cannot run: unknown, no endpoint of its own, or a provider row whose key is not stored. */
|
|
1172
|
+
setMoaPlanner(plannerModel, specialist) {
|
|
1173
|
+
for (const id of [plannerModel, specialist]) {
|
|
1174
|
+
if (!id)
|
|
1175
|
+
continue;
|
|
1176
|
+
const p = selectModel(this.liveRegistry(), id, hasByoToken, this.isOwner);
|
|
1177
|
+
if (p.error || p.profile?.kind !== "single")
|
|
1178
|
+
return { ok: false, error: p.error ?? `"${id}" has no endpoint of its own` };
|
|
1179
|
+
}
|
|
1180
|
+
this.moaConfig = { ...this.moaConfig, plannerModel, ...(specialist ? { specialist: { id: specialist } } : {}) };
|
|
1181
|
+
return { ok: true };
|
|
1182
|
+
}
|
|
1183
|
+
moaTeam() {
|
|
1184
|
+
return moaTeam(this.moaConfig);
|
|
1185
|
+
}
|
|
1146
1186
|
setModel(id) {
|
|
1147
1187
|
const { profile, error } = selectModel(this.liveRegistry(), id, hasByoToken, this.isOwner);
|
|
1148
1188
|
if (error || !profile)
|
|
1149
1189
|
return { ok: false, error };
|
|
1150
|
-
|
|
1151
|
-
|
|
1190
|
+
this.decodeSamples = []; // another model's rate says nothing about this one
|
|
1191
|
+
if (profile.kind === "orchestrated") {
|
|
1192
|
+
const team = moaTeam(this.moaConfig);
|
|
1193
|
+
if (!team)
|
|
1194
|
+
return { ok: false, error: `MOA needs a "moa" block (planner + specialist) in settings.json` };
|
|
1195
|
+
if (!team.planner.endpoint) { // a /model id as the planner: it must resolve, and a provider row needs its key stored
|
|
1196
|
+
const p = selectModel(this.liveRegistry(), team.planner.id, hasByoToken, this.isOwner);
|
|
1197
|
+
if (p.error || p.profile?.kind !== "single")
|
|
1198
|
+
return { ok: false, error: `MoA planner: ${p.error ?? `"${team.planner.id}" has no endpoint of its own`}` };
|
|
1199
|
+
}
|
|
1152
1200
|
}
|
|
1153
1201
|
if (profile.kind === "single" && profile.id === DEFAULT_MODEL_ID && this.chain) {
|
|
1154
1202
|
// The default local model IS the shell's endpoint chain (the gateway's published port + its failover
|
|
@@ -1498,6 +1546,9 @@ export class Session {
|
|
|
1498
1546
|
return { content: "", rounds: 0, toolCalls: 0, interrupted: true };
|
|
1499
1547
|
}
|
|
1500
1548
|
await this.maybeRecall(text); // fold past-session memory into the system prompt on the first turn
|
|
1549
|
+
if (this.ctrl.signal.aborted)
|
|
1550
|
+
return { content: "", rounds: 0, toolCalls: 0, interrupted: true };
|
|
1551
|
+
await this.maybeSpeedCompact(h);
|
|
1501
1552
|
if (this.ctrl.signal.aborted)
|
|
1502
1553
|
return { content: "", rounds: 0, toolCalls: 0, interrupted: true };
|
|
1503
1554
|
this.inner.resetTurn(); // re-evaluate routing from the smallest endpoint + clear last turn's unhealthy set
|
|
@@ -1517,6 +1568,32 @@ export class Session {
|
|
|
1517
1568
|
this.turnThinkOff = false;
|
|
1518
1569
|
}
|
|
1519
1570
|
}
|
|
1571
|
+
/** Speed-aware compaction: the last measured turns decoded under compaction.minDecodeTps at a request big enough
|
|
1572
|
+
* for compaction to help, so compact now, before this turn's first request. The samples are cleared either way, so
|
|
1573
|
+
* the next trigger needs two fresh slow turns. A failed summarizer leaves the conversation as it was. */
|
|
1574
|
+
async maybeSpeedCompact(h) {
|
|
1575
|
+
const due = speedCompactionDue(this.decodeSamples, this.compactionMinDecodeTps, this.requestEstimate());
|
|
1576
|
+
if (!due)
|
|
1577
|
+
return;
|
|
1578
|
+
this.decodeSamples = [];
|
|
1579
|
+
h.onSpeedCompaction?.(due);
|
|
1580
|
+
const before = due.ctxTokens;
|
|
1581
|
+
h.onCompactionStart?.({ before });
|
|
1582
|
+
this.turnHandlers = h;
|
|
1583
|
+
let skipped;
|
|
1584
|
+
try {
|
|
1585
|
+
await this.compactNowInner();
|
|
1586
|
+
}
|
|
1587
|
+
catch {
|
|
1588
|
+
skipped = "summarizer_error"; // the turn still runs; the window-fill gate stays the backstop
|
|
1589
|
+
}
|
|
1590
|
+
finally {
|
|
1591
|
+
this.turnHandlers = undefined;
|
|
1592
|
+
const after = this.requestEstimate();
|
|
1593
|
+
this.telemetry.record({ type: "compaction", before, after, trigger: "decode", tps: Math.round(due.tps * 10) / 10, floorTps: due.floorTps, ...(skipped ? { skipped } : {}) });
|
|
1594
|
+
h.onCompactionEnd?.({ before, after });
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1520
1597
|
/** The front door (engine/front-door.ts). On the default model and MOA, the gateway answers a message its classifier
|
|
1521
1598
|
* is confident needs no tools with its fast model in this session's voice; the reply joins the conversation like any
|
|
1522
1599
|
* other. Returns null to run the turn as usual: the gateway says work (the owner sees its status line at once), it
|
|
@@ -1561,8 +1638,11 @@ export class Session {
|
|
|
1561
1638
|
this.telemetry.record({ type: "moa", planner: team.planner.id, specialist: team.specialist, route: specialist ? "direct" : route || fd === "work" ? "planned" : "unrouted", pDirect: route?.pDirect });
|
|
1562
1639
|
if (specialist)
|
|
1563
1640
|
return this.execute(text, h, this.wrap(this.routerForProfile(specialist)), this.sysWithThink(), specialist.id);
|
|
1564
|
-
const
|
|
1565
|
-
|
|
1641
|
+
const plannerRow = team.planner.endpoint ? undefined : findModel(this.liveRegistry(), team.planner.id);
|
|
1642
|
+
if (!team.planner.endpoint && plannerRow?.kind !== "single")
|
|
1643
|
+
throw new Error(`MoA planner "${team.planner.id}" is not a /model id with an endpoint`);
|
|
1644
|
+
const plannerRouter = this.wrap(plannerRow?.kind === "single" ? this.routerForProfile(plannerRow) : new AuroraRouter([
|
|
1645
|
+
{ name: team.planner.id, base: endpointBase(team.planner.endpoint), model: team.planner.model ?? team.planner.id, ctxLimit: this.inner.ctxLimit() },
|
|
1566
1646
|
]));
|
|
1567
1647
|
const sys = `${this.sysWithThink() ?? ""}\n\n## MOA: planner\n${plannerBrief(team)}`;
|
|
1568
1648
|
return withDelegateDefault(team.specialist, () => this.execute(text, h, plannerRouter, sys, team.planner.id));
|
|
@@ -1710,7 +1790,7 @@ export class Session {
|
|
|
1710
1790
|
onServed: h.onServed,
|
|
1711
1791
|
onSelfHeal: (kind, attempt, step) => { this.telemetry.record({ type: "self_heal", kind, attempt }); h.onSelfHeal?.(kind, attempt, step); },
|
|
1712
1792
|
model: this.turnModel(turnModelId),
|
|
1713
|
-
onFallback: (e) => { this.telemetry.record({ type: "model_fallback", from: turnModelId, to:
|
|
1793
|
+
onFallback: (e) => { this.telemetry.record({ type: "model_fallback", from: turnModelId, to: fallbackProfile(this.liveRegistry(), this.fallbackModelId).id, reason: e.reason, legs: e.legs.length }); h.onFallback?.(e); },
|
|
1714
1794
|
onCompaction: (e) => { this.telemetry.record({ type: "compaction", ...e }); h.onCompaction?.(e); },
|
|
1715
1795
|
onLoopCompaction: (e) => {
|
|
1716
1796
|
if (e.replaced > 0)
|
|
@@ -1795,6 +1875,8 @@ export class Session {
|
|
|
1795
1875
|
}
|
|
1796
1876
|
}
|
|
1797
1877
|
this.sessionTokensTotal += (res.tokens ?? 0) + (res.promptTokens ?? 0); // cumulative session spend
|
|
1878
|
+
if (!this.turnFellBack)
|
|
1879
|
+
this.decodeSamples = recordDecodeSample(this.decodeSamples, { tokens: res.tokens, genMs: res.genMs, ctxTokens: this.requestEstimate() });
|
|
1798
1880
|
// Instant compaction: feed token counts to the rolling summarizer. When a round ends without
|
|
1799
1881
|
// tool calls and we've crossed the threshold, the summarizer triggers a background summary.
|
|
1800
1882
|
const shouldSummarize = this.rollingSummarizer.feedRound(res.tokens ?? 0, res.toolCalls);
|
package/dist/tools/deferred.js
CHANGED
|
@@ -202,6 +202,7 @@ const SYNONYMS = new Map(Object.entries({
|
|
|
202
202
|
login: "browser", log: "log_tail", click: "desktop browser", window: "desktop", server: "background", daemon: "background",
|
|
203
203
|
subagent: "agent", conversation: "session", chat: "session", movie: "video", clip: "video", healthy: "health", uptime: "health",
|
|
204
204
|
kanban: "board", outage: "incident", playbook: "skill", cron: "cronjob", commit: "checkpoint", test: "validate verify",
|
|
205
|
+
iphone: "phone", android: "phone", mobile: "phone", tap: "phone_tap", swipe: "phone_swipe", adb: "phone",
|
|
205
206
|
}).map(([k, v]) => [stem(k), v.split(" ").map((x) => (x.includes("_") ? x : stem(x)))]));
|
|
206
207
|
function nativeSearch(cat, query) {
|
|
207
208
|
const all = [...cat.native.values(), ...cat.mcp.values()];
|