@0perator/operator 0.1.283 → 0.1.285
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/acp/agent.js +2 -2
- package/dist/acp/config-options.js +13 -1
- package/dist/autonomy/headless.js +2 -0
- package/dist/engine/moa.js +5 -1
- package/dist/moa/shadow.js +61 -0
- package/dist/router/models.js +18 -16
- package/dist/session.js +38 -0
- package/package.json +1 -1
package/dist/acp/agent.js
CHANGED
|
@@ -14,7 +14,7 @@ import { readFileSync, rmSync, statSync } from "node:fs";
|
|
|
14
14
|
import { isAbsolute } from "node:path";
|
|
15
15
|
import { PROTOCOL_VERSION, RequestError } from "@zed-industries/agent-client-protocol";
|
|
16
16
|
import { createAutonomySession } from "../autonomy/session-factory.js";
|
|
17
|
-
import { modelRegistry
|
|
17
|
+
import { modelRegistry } from "../router/models.js";
|
|
18
18
|
import { hasByoToken } from "../auth/byo.js";
|
|
19
19
|
import { operatorPath } from "../config/home.js";
|
|
20
20
|
import { redactSecrets } from "../engine/redact.js";
|
|
@@ -183,7 +183,7 @@ export class OperatorAcpAgent {
|
|
|
183
183
|
modelOption(sessionId) {
|
|
184
184
|
const live = this.sessions.get(sessionId);
|
|
185
185
|
const moa = this.settings.moa;
|
|
186
|
-
return buildModelConfigOption(
|
|
186
|
+
return buildModelConfigOption(modelRegistry(this.settings.models), live?.session.currentModel() ?? "", !!moa?.proposers?.length, hasByoToken); // filtered there, active-but-hidden re-admitted there (never a lying currentValue)
|
|
187
187
|
}
|
|
188
188
|
/** SDK-0.4.5 legacy path (wire: session/set_model) — what Zed ships today. The spec-stable
|
|
189
189
|
* session/set_config_option is translated onto this method by the run.ts shim; both client
|
|
@@ -2,14 +2,26 @@
|
|
|
2
2
|
* MOA is omitted unless a moa block exists in settings (setModel refuses it otherwise, and a
|
|
3
3
|
* dropdown that can fail is the dishonesty SPEC/providers.md §1 bans). Descriptions carry ctx
|
|
4
4
|
* size and kind so the user can price a switch with their eyes. */
|
|
5
|
-
export function buildModelConfigOption(registry, currentId, moaAvailable) {
|
|
5
|
+
export function buildModelConfigOption(registry, currentId, moaAvailable, hasByo) {
|
|
6
6
|
const options = [];
|
|
7
7
|
for (const p of registry) {
|
|
8
|
+
if (p.hidden)
|
|
9
|
+
continue; // picker truth: down slots aren't offered…
|
|
10
|
+
if (p.byo && !(hasByo ? hasByo(p.byo) : false))
|
|
11
|
+
continue; // …nor unconnectable connectors
|
|
8
12
|
if (p.kind === "orchestrated" && !moaAvailable)
|
|
9
13
|
continue;
|
|
10
14
|
const bits = [p.desc, p.kind === "single" && p.ctx ? `${Math.round(p.ctx / 1000)}k ctx` : null, p.kind === "orchestrated" ? "mixture-of-agents" : null].filter(Boolean);
|
|
11
15
|
options.push({ value: p.id, name: p.label, description: bits.join(" · ") || undefined });
|
|
12
16
|
}
|
|
17
|
+
// …but a selector that misreports the session's REAL model is the deeper dishonesty: if the
|
|
18
|
+
// active profile is hidden (switched-to before it went down, scripted, or aliased), it joins
|
|
19
|
+
// the list labeled as such — selectModel resolves hidden ids, so the option is never a dead end.
|
|
20
|
+
if (currentId && !options.some((o) => o.value === currentId)) {
|
|
21
|
+
const cur = registry.find((p) => p.id === currentId);
|
|
22
|
+
if (cur)
|
|
23
|
+
options.push({ value: cur.id, name: cur.label, description: "active — hidden from the picker" });
|
|
24
|
+
}
|
|
13
25
|
return {
|
|
14
26
|
id: "model",
|
|
15
27
|
name: "Model",
|
|
@@ -49,12 +49,14 @@ export async function runHeadless(settings, prompt, opts = {}) {
|
|
|
49
49
|
reporter.event("done", { reason: res.reason, turns: res.turns, toolCalls: res.toolCalls });
|
|
50
50
|
if (res.lastContent)
|
|
51
51
|
reporter.line(res.lastContent);
|
|
52
|
+
await session.flushRouteShadow(); // MOA phase-0: the last turn's shadow record must not die with the process
|
|
52
53
|
return res.reason === "error" ? 1 : res.reason === "interrupted" ? 130 : 0;
|
|
53
54
|
}
|
|
54
55
|
const outcome = await session.send(prompt, handlers);
|
|
55
56
|
reporter.event("done", { rounds: outcome.rounds, toolCalls: outcome.toolCalls, interrupted: outcome.interrupted, durationMs: Math.round(outcome.durationMs ?? 0) });
|
|
56
57
|
if (outcome.content)
|
|
57
58
|
reporter.line(outcome.content);
|
|
59
|
+
await session.flushRouteShadow(); // MOA phase-0: headless one-shot exits before fire-and-forget would land
|
|
58
60
|
return outcome.interrupted ? 130 : 0;
|
|
59
61
|
}
|
|
60
62
|
catch (e) {
|
package/dist/engine/moa.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// Fan-out budget per proposer. 60s default: generous for a draft, hard enough that a contended
|
|
2
|
+
// JL1 slot times out gracefully instead of stalling the aggregator (measured 2026-10-12: same
|
|
3
|
+
// task 1.1s local vs 60s+ timeout on the shared lane). Env-overridable — heavy offline drafts on
|
|
4
|
+
// a slow link want more; JSC/mobile has no process, so this reads the same way agent.ts reads env.
|
|
5
|
+
const PROPOSER_TIMEOUT_MS = Math.min(600_000, Math.max(5_000, Number(globalThis.process?.env?.KODE_PROPOSER_TIMEOUT_MS) || 60_000));
|
|
2
6
|
/** One proposer call: a plain (non-streaming, tool-free) OpenAI-compatible chat completion. Never
|
|
3
7
|
* throws — a failure or timeout comes back as a draft with empty content + an `error`, so the
|
|
4
8
|
* caller can drop it without the whole fan-out failing (a proposer is a nice-to-have, not a
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// MOA phase-0 route shadow — pure observability for the mixture-of-agents dispatch plan.
|
|
2
|
+
// A gate-not-voice classifier labels the turn's opening request into one of 9 route labels;
|
|
3
|
+
// we log (label, model-that-actually-ran, cost) so a week of real traffic answers the ONLY
|
|
4
|
+
// question that decides lane placement: what share of turns is actually CHAT/SUMMARIZE/WRITE
|
|
5
|
+
// (fast lane) vs CODE/SECURITY (heavy/top). NOTHING here changes routing, blocks a turn, or
|
|
6
|
+
// leaves the machine: env-gated (KODE_MOA_SHADOW), fire-and-forget, every failure swallowed.
|
|
7
|
+
//
|
|
8
|
+
// The classifier is deliberately strict — parseRouteLabel accepts ONE word and nothing else;
|
|
9
|
+
// prose answers ("This is a coding request") are null, not a guess. That is the same contract
|
|
10
|
+
// the Alfred-class 186M gate will ship under: a gate that rambles is a gate that lies.
|
|
11
|
+
// Node-free by construction (plain fetch + caller-supplied file path) — safe for any graph.
|
|
12
|
+
export const ROUTE_LABELS = ["CHAT", "OPERATE", "VISION", "CODE", "DATA", "SECURITY", "WRITE", "SUMMARIZE", "MATH"];
|
|
13
|
+
/** Planned lane per label (MOA design, 2026-10-12): fast=small resident model, operate=tool-format
|
|
14
|
+
* model, heavy=aurora-class, top=true-MoA fanout (SECURITY only for now), vision=media surface. */
|
|
15
|
+
export const TIER_BY_LABEL = {
|
|
16
|
+
CHAT: "fast", SUMMARIZE: "fast", WRITE: "fast",
|
|
17
|
+
OPERATE: "operate",
|
|
18
|
+
CODE: "heavy", DATA: "heavy", MATH: "heavy",
|
|
19
|
+
SECURITY: "top",
|
|
20
|
+
VISION: "vision",
|
|
21
|
+
};
|
|
22
|
+
/** Teacher prompt: 9 labels, one word, nothing else. Kept tiny on purpose — the shadow call is
|
|
23
|
+
* billed to the session's own model and must stay a rounding error (~1 completion token). */
|
|
24
|
+
export function shadowPrompt(text) {
|
|
25
|
+
const head = text.slice(0, 400);
|
|
26
|
+
return `Classify the REQUEST below into exactly one word: CHAT, OPERATE, VISION, CODE, DATA, SECURITY, WRITE, SUMMARIZE, or MATH.
|
|
27
|
+
Rules: CODE=writing/fixing code. OPERATE=running tools/system actions. WRITE=prose drafting. SUMMARIZE=condensing. DATA=tables/analytics. SECURITY=threats/vulns/auth. MATH=numeric/formal. VISION=images. CHAT=everything else.
|
|
28
|
+
Output ONE word, nothing else.
|
|
29
|
+
|
|
30
|
+
REQUEST: """${head}"""`;
|
|
31
|
+
}
|
|
32
|
+
/** STRICT parse: one word only (punctuation/spacing tolerated), case-insensitive. Multi-word or
|
|
33
|
+
* unknown answers are refusals to gate — return null, never guess. */
|
|
34
|
+
export function parseRouteLabel(out) {
|
|
35
|
+
const w = out.trim().replace(/[.!?,;:"'`]/g, "").toUpperCase();
|
|
36
|
+
if (!w || /\s/.test(w))
|
|
37
|
+
return null;
|
|
38
|
+
return ROUTE_LABELS.includes(w) ? w : null;
|
|
39
|
+
}
|
|
40
|
+
/** Fire-and-forget one shadow record for a completed turn. `classify` is injected so tests run
|
|
41
|
+
* offline and production can use any teacher endpoint (session wires aurora chat). Never throws;
|
|
42
|
+
* never awaits longer than the caller's own abort policy — the whole point is that observability
|
|
43
|
+
* cannot degrade the thing it observes. */
|
|
44
|
+
export async function routeShadowTurn(opts) {
|
|
45
|
+
if (!opts.enabled)
|
|
46
|
+
return;
|
|
47
|
+
const t0 = Date.now();
|
|
48
|
+
try {
|
|
49
|
+
const raw = await opts.classify(opts.text);
|
|
50
|
+
const label = parseRouteLabel(raw);
|
|
51
|
+
const ev = {
|
|
52
|
+
ts: new Date().toISOString(), label, tier: label ? TIER_BY_LABEL[label] : null,
|
|
53
|
+
model: opts.model, promptTokens: opts.promptTokens, genTokens: opts.genTokens,
|
|
54
|
+
turnMs: opts.turnMs, classifyMs: Date.now() - t0,
|
|
55
|
+
};
|
|
56
|
+
await opts.append(JSON.stringify(ev));
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
/* shadow telemetry is allowed to die in silence — never into a turn */
|
|
60
|
+
}
|
|
61
|
+
}
|
package/dist/router/models.js
CHANGED
|
@@ -9,22 +9,21 @@ export const MODEL_ALIASES = {
|
|
|
9
9
|
"spectre": "cortana", // flagship renamed Spectre -> Cortana 35B (2026-10-07); old id keeps resolving
|
|
10
10
|
};
|
|
11
11
|
export const BUILTIN_MODELS = [
|
|
12
|
-
{ id: "operator-1m", label: "Operator
|
|
13
|
-
{ id: "operator-128k", label: "Operator 128K", kind: "single", desc: "128K context, lighter RAM (:8096)", endpoint: "http://127.0.0.1:8096/v1", model: "aurora-code-1", ctx: 131072 },
|
|
12
|
+
{ id: "operator-1m", 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: 300000 },
|
|
13
|
+
{ id: "operator-128k", 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 },
|
|
14
14
|
// QwenCloud Token Plan BYO connectors (SPEC/providers.md §2 "API-key connectors"). Same keychain
|
|
15
15
|
// account ("qwen") serves both; the picker hides them until connected (§1 honest availability), and
|
|
16
16
|
// authHeaders NEVER sends the Operator token to this host. ctx starts conservative and self-clamps
|
|
17
17
|
// to the served truth (observeContext).
|
|
18
18
|
{ id: "qwen3.8-max", label: "Qwen 3.8 Max", kind: "single", desc: "BYO QwenCloud Token Plan — credits from your plan", endpoint: "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1", model: "qwen3.8-max", ctx: 262144, byo: "qwen", transport: "openai" },
|
|
19
19
|
{ id: "qwen3.8-flash", label: "Qwen 3.8 Flash", kind: "single", desc: "BYO QwenCloud Token Plan — fast tier, your credits", endpoint: "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1", model: "qwen3.8-flash", ctx: 262144, byo: "qwen", transport: "openai" },
|
|
20
|
-
// AXE Token Plan
|
|
21
|
-
// (
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
{ id: "axe-aurora-300k", label: "AXE Aurora 300K (API)", kind: "single", desc: "BYO AXE Token Plan — agent-tuned 300K reasoner via api.axe.onl", endpoint: "https://api.axe.onl/v1", model: "aurora-code-1", ctx: 307200, byo: "axe", transport: "openai" },
|
|
20
|
+
// AXE Token Plan: api.axe.onl is AXE's OWN gateway (nginx + LiteLLM) and the Operator token is its
|
|
21
|
+
// native auth (authHeaders scoping sends it to *.axe.onl — aurora.ts). Third-party `sk-axe-…` virtual
|
|
22
|
+
// keys are the V1 vendor plan (_ai-docs/architecture/axe-model-vendor.md); until the gateway actually
|
|
23
|
+
// issues them, gating this profile behind an unconnectable BYO account hid our OWN flagship remote
|
|
24
|
+
// lane from our own picker (2026-10-12 picker-truth audit) — so it is a plain profile today. When V1
|
|
25
|
+
// ships, reintroduce the byo:"axe" SKU as a SEPARATE connector id, never by re-gating this one.
|
|
26
|
+
{ id: "axe-aurora-300k", 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: "https://api.axe.onl/v1", model: "aurora-code-1", ctx: 307200, transport: "openai" },
|
|
28
27
|
// Spectre — the flagship, replacing Ghost (2026-10-07). Ghost 32B was the prior self-hosted abliterated
|
|
29
28
|
// Qwen3-VL-32B on this slot; retired when Spectre proved 4× faster at equal capability (its weights + restore
|
|
30
29
|
// command are kept at ~/.axe/logs/ghost-restore-cmd.txt — reversible). Spectre = Huihui-Qwen3.6-35B-A3B-
|
|
@@ -36,7 +35,7 @@ export const BUILTIN_MODELS = [
|
|
|
36
35
|
// truncated a round at token 32767 (finish=length) mid-tool-call, and that cut call poisoned the session (0.1.259).
|
|
37
36
|
// 32000 sits just UNDER the real wall (margin) AND under LEAN_HARNESS_CTX so Cortana drops the heavy memory/handoff
|
|
38
37
|
// (which alone was ~16K = half the window) — persona + unrestricted layer kept. Raise ONLY if the server's --ctx-size does.
|
|
39
|
-
{ id: "cortana", label: "Cortana 35B", kind: "single", desc: "flagship — abliterated Qwen3.6-35B-A3B
|
|
38
|
+
{ id: "cortana", label: "Cortana 35B (JL1)", kind: "single", desc: "flagship MoE — abliterated Qwen3.6-35B-A3B (~3B active; ~40 tok/s ONLY when JL1 is quiet — shares the box with the 300K cloud slots and fell to 1-4 tok/s under fleet load; pick for vision/uncensored jobs, prefer Operator 1M local otherwise)", endpoint: "http://192.168.1.103:8112/v1", model: "/Volumes/Ai Storage/jl1-local/models/aurorax/Huihui-Qwen3.6-35B-A3B-abliterated.Q4_K_M.gguf", ctx: 262144 },
|
|
40
39
|
// Qwen3-4B — fast LOCAL tier (stock qwen3-4b-mlx-q4, 2.26GB MLX 4-bit, ctx 40960) served via mlx_lm.server
|
|
41
40
|
// on JL1:8110. Qwen3 vocab (151936) — the same family as ghost-32b, so it's the review-recommended quick tier
|
|
42
41
|
// AND the vocab lineage for ghost spec-decode (the actual draft is Qwen3-0.6B, too small to list here). Runs
|
|
@@ -47,15 +46,18 @@ export const BUILTIN_MODELS = [
|
|
|
47
46
|
// (Q4_K_M, ~14GB) with a bolted-on Mistral-Small-3.1 mmproj for vision. Dense 24B (not MoE), served on
|
|
48
47
|
// JL1:8114 via llama.cpp (--jinja, q8 KV). ctx 32768 ≥ LEAN_HARNESS_CTX → full harness. A quick drop-in to
|
|
49
48
|
// test a smaller/different flavour alongside Spectre without the 35B footprint.
|
|
50
|
-
{ id: "venice-24b", label: "Venice 24B", kind: "single", desc: "lighter uncensored tier — Dolphin-Mistral-24B-Venice + vision (JL1:8114,
|
|
49
|
+
{ id: "venice-24b", label: "Venice 24B", kind: "single", desc: "lighter uncensored tier — Dolphin-Mistral-24B-Venice + vision (JL1:8114) — slot stopped today; hidden from the picker, resolves by id once launched", endpoint: "http://192.168.1.103:8114/v1", model: "/Volumes/Ai Storage/exotic-models/dolphin-mistral-24b-venice-gguf/cognitivecomputations_Dolphin-Mistral-24B-Venice-Edition-Q4_K_M.gguf", ctx: 32768, hidden: true },
|
|
51
50
|
// Code tier for the coding/Replit-clone surface — Qwen2.5-Coder-3B has a real chat template + tool-calling
|
|
52
51
|
// + FIM (ollama reports "completion, tools, insert"), unlike StarCoder2/replit-code (completion-only, can't
|
|
53
52
|
// drive an agent loop). Ollama on JL1, on-demand (loads ~3GB, so SELECT only when JL1 swap has headroom).
|
|
54
53
|
// ctx 32000 stays just under the 32768 train wall (the 0.1.259/260 overrun bug) and below LEAN_HARNESS_CTX
|
|
55
54
|
// so a 3B gets the lean harness. LICENCE: Qwen Research Licence (non-commercial) — fine for owner/eval use;
|
|
56
|
-
// the paid product should use an Apache-2.0 size (qwen2.5-coder 1.5b/7b).
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
// the paid product should use an Apache-2.0 size (qwen2.5-coder 1.5b/7b).
|
|
56
|
+
// transport:"openai" = Ollama /v1. ENDPOINT FIX 2026-10-12: was 127.0.0.1:11434, which only resolves
|
|
57
|
+
// ON JL1 — every laptop picker entry pointed at its own dead loopback. LAN address like the other
|
|
58
|
+
// JL1 slots.
|
|
59
|
+
{ id: "qwen-coder", label: "Qwen Coder 3B (JL1)", kind: "single", desc: "code tier — Qwen2.5-Coder-3B Q4_K_M (chat + tool-calling + FIM), Ollama on JL1:11434 (on-demand ~3GB); Qwen Research Licence, non-commercial", endpoint: "http://192.168.1.103:11434/v1", model: "qwen2.5-coder:3b", ctx: 32000, transport: "openai" },
|
|
60
|
+
{ id: "moa", label: "MOA (Mixture of Agents)", kind: "orchestrated", desc: "the team slot — fans each turn to aurora-local + Cortana 35B + Qwen-Coder 3B proposers (settings.moa, 60s fan-out, graceful per-draft failure) and synthesizes with local Aurora as agent-loop aggregator; roster + benchmark in _ai-docs" },
|
|
59
61
|
];
|
|
60
62
|
/** The runtime registry: the built-ins, with any settings.models entries merged in (overriding a
|
|
61
63
|
* built-in by id, or adding a new one) — same shape either way, so /model doesn't care which. */
|
|
@@ -102,7 +104,7 @@ export function selectModel(registry, id, hasByo) {
|
|
|
102
104
|
/** The picker-truth view of a registry: drops BYO profiles whose key isn't connected (and ALL
|
|
103
105
|
* unresolvable ones when the resolver is absent — a picker must never offer what setModel refuses). */
|
|
104
106
|
export function visibleModels(registry, hasByo) {
|
|
105
|
-
return registry.filter((p) => !p.byo || (hasByo ? hasByo(p.byo) : false));
|
|
107
|
+
return registry.filter((p) => !p.hidden && (!p.byo || (hasByo ? hasByo(p.byo) : false)));
|
|
106
108
|
}
|
|
107
109
|
/** Strip a trailing /v1 so a ModelProfile/MoaAggregator endpoint can feed the AuroraRouter, whose
|
|
108
110
|
* base is bare (engine/aurora.ts's chat() appends /v1/chat/completions itself). */
|
package/dist/session.js
CHANGED
|
@@ -12,6 +12,7 @@ import { appendFileSync, mkdirSync } from "node:fs";
|
|
|
12
12
|
import { dirname } from "node:path";
|
|
13
13
|
import { operatorPath } from "./config/home.js";
|
|
14
14
|
import { fanOutProposers, labelDrafts, DEFAULT_AGGREGATOR_PROMPT } from "./engine/moa.js";
|
|
15
|
+
import { routeShadowTurn, shadowPrompt } from "./moa/shadow.js"; // MOA phase-0 observability (KODE_MOA_SHADOW)
|
|
15
16
|
import { AuroraRouter } from "./router/router.js";
|
|
16
17
|
import { operatorAgentPersona } from "./config/operator-harness.js";
|
|
17
18
|
import { modelRegistry, findModel, selectModel, visibleModels, endpointBase, DEFAULT_MODEL_ID, LEAN_HARNESS_CTX } from "./router/models.js";
|
|
@@ -271,6 +272,12 @@ export class Session {
|
|
|
271
272
|
wantRecall;
|
|
272
273
|
recallBlock = ""; // memory recalled on the first turn, folded into the system prompt thereafter
|
|
273
274
|
sessionTokensTotal = 0; // cumulative prefill+output tokens across all turns (Claude-Code-style session total)
|
|
275
|
+
_shadowPending = Promise.resolve(); // MOA phase-0: in-flight route-shadow record (never rejects)
|
|
276
|
+
/** Await the in-flight route-shadow record before a short-lived process exits — fire-and-forget alone
|
|
277
|
+
* would drop the last turn's telemetry silently. Interactive sessions need not call this (the process
|
|
278
|
+
* outlives the 15s-abort classification); `operator run` headless MUST. Safe to call anytime, twice,
|
|
279
|
+
* from anywhere: the pending promise is swapped and failures were already swallowed by the module. */
|
|
280
|
+
async flushRouteShadow() { const p = this._shadowPending; this._shadowPending = Promise.resolve(); await p; }
|
|
274
281
|
planMode = false; // /plan: research read-only + propose a plan, no mutations until the owner approves
|
|
275
282
|
thinkMode = "off"; // /think, /ultrathink — extended reasoning
|
|
276
283
|
recalled = false;
|
|
@@ -917,6 +924,37 @@ export class Session {
|
|
|
917
924
|
turnContinuation: { enabled: process.env.KODE_TURN_CONTINUATION !== "0" && !this.planMode },
|
|
918
925
|
});
|
|
919
926
|
this.telemetry.record({ type: "turn", rounds: res.rounds, toolCalls: res.toolCalls, interrupted: false, durationMs: Math.round(performance.now() - _t0), ctxPct: this.ctxPct(), stopReason: res.stopReason });
|
|
927
|
+
// MOA phase-0 ROUTE SHADOW (observability ONLY — routing is untouched): ON by default, opt out with
|
|
928
|
+
// KODE_MOA_SHADOW=0. Labels
|
|
929
|
+
// the turn with the gate's own 9-label contract and appends {label, model-that-ran, cost} to
|
|
930
|
+
// ~/.axe/operator/route-shadow/<date>.jsonl. The classifier runs as a BACKGROUND-priority call on
|
|
931
|
+
// the endpoint gate (a main turn always outranks it) with a 15s abort, and routeShadowTurn swallows
|
|
932
|
+
// every failure — observability that can degrade the observed thing is not observability.
|
|
933
|
+
if (process.env.KODE_MOA_SHADOW !== "0") {
|
|
934
|
+
const prof = findModel(this.registry, this.modelId);
|
|
935
|
+
const shadowBase = prof?.endpoint ? endpointBase(prof.endpoint) : undefined;
|
|
936
|
+
if (shadowBase) {
|
|
937
|
+
const shadowTok = prof?.byo ? getByoToken(prof.byo) : undefined;
|
|
938
|
+
const shadowModel = prof?.model ?? this.modelId;
|
|
939
|
+
this._shadowPending = routeShadowTurn({
|
|
940
|
+
enabled: true,
|
|
941
|
+
text,
|
|
942
|
+
model: this.currentModel(),
|
|
943
|
+
promptTokens: res.promptTokens,
|
|
944
|
+
genTokens: res.tokens,
|
|
945
|
+
turnMs: Math.round(performance.now() - _t0),
|
|
946
|
+
classify: async (t) => (await chat([{ role: "user", content: shadowPrompt(t) }], {
|
|
947
|
+
base: shadowBase, model: shadowModel, token: shadowTok, transport: prof?.transport,
|
|
948
|
+
maxTokens: 8, temperature: 0, background: true, signal: AbortSignal.timeout(15000),
|
|
949
|
+
})).content,
|
|
950
|
+
append: async (line) => {
|
|
951
|
+
const p = operatorPath("route-shadow", `${new Date().toISOString().slice(0, 10)}.jsonl`);
|
|
952
|
+
mkdirSync(dirname(p), { recursive: true, mode: 0o700 });
|
|
953
|
+
appendFileSync(p, line + "\n", { encoding: "utf8", mode: 0o600 });
|
|
954
|
+
},
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
}
|
|
920
958
|
this.sessionTokensTotal += (res.tokens ?? 0) + (res.promptTokens ?? 0); // cumulative session spend
|
|
921
959
|
// Instant compaction: feed token counts to the rolling summarizer. When a round ends without
|
|
922
960
|
// tool calls and we've crossed the threshold, the summarizer triggers a background summary.
|