@0perator/operator 0.1.344 → 0.1.345
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 +7 -2
- package/dist/autonomy/delegate.js +22 -2
- package/dist/autonomy/headless.js +6 -1
- package/dist/autonomy/index.js +10 -1
- package/dist/autonomy/session-factory.js +3 -0
- package/dist/classifier/route.js +46 -0
- package/dist/cli.js +10 -7
- package/dist/config/settings.js +5 -8
- package/dist/engine/agent.js +4 -3
- package/dist/engine/continuation.js +21 -0
- package/dist/engine/moa.js +28 -57
- package/dist/router/models.js +2 -1
- package/dist/session.js +50 -55
- package/package.json +1 -1
package/dist/acp/agent.js
CHANGED
|
@@ -15,6 +15,7 @@ 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
17
|
import { modelRegistry } from "../router/models.js";
|
|
18
|
+
import { moaTeam } from "../engine/moa.js";
|
|
18
19
|
import { hasByoToken } from "../auth/byo.js";
|
|
19
20
|
import { operatorPath } from "../config/home.js";
|
|
20
21
|
import { redactSecrets } from "../engine/redact.js";
|
|
@@ -182,8 +183,8 @@ export class OperatorAcpAgent {
|
|
|
182
183
|
* read from the Session itself so a /model-style switch elsewhere is reflected here too. */
|
|
183
184
|
modelOption(sessionId) {
|
|
184
185
|
const live = this.sessions.get(sessionId);
|
|
185
|
-
const moa = this.settings.moa;
|
|
186
|
-
return buildModelConfigOption(modelRegistry(this.settings.models), live?.session.currentModel() ?? "", !!moa
|
|
186
|
+
const moa = moaTeam(this.settings.moa);
|
|
187
|
+
return buildModelConfigOption(modelRegistry(this.settings.models), live?.session.currentModel() ?? "", !!moa, hasByoToken, // the builder is the single source of selector truth: hidden + unconnectable BYO
|
|
187
188
|
this.actor.tier === "admin"); // filtered there, active-but-hidden re-admitted there (never a lying currentValue)
|
|
188
189
|
}
|
|
189
190
|
/** SDK-0.4.5 legacy path (wire: session/set_model) — what Zed ships today. The spec-stable
|
|
@@ -237,6 +238,10 @@ export class OperatorAcpAgent {
|
|
|
237
238
|
const handlers = acpHandlers((update) => void this.conn.sessionUpdate({ sessionId: live.sid, update: update }).catch(() => { }), { calls: live.calls, cwd: live.cwd });
|
|
238
239
|
try {
|
|
239
240
|
const outcome = await live.session.send(text, handlers);
|
|
241
|
+
// An engine stop is never streamed (it isn't model output), so the editor would end the turn in silence: send the
|
|
242
|
+
// plain question as the turn's message.
|
|
243
|
+
if (outcome.display && !live.cancelled)
|
|
244
|
+
await this.conn.sessionUpdate({ sessionId: live.sid, update: { sessionUpdate: "agent_message_chunk", content: { type: "text", text: outcome.display } } }).catch(() => { });
|
|
240
245
|
return { stopReason: live.cancelled ? "cancelled" : acpStopReason(outcome) };
|
|
241
246
|
}
|
|
242
247
|
catch (e) {
|
|
@@ -40,6 +40,26 @@ let _depthStore = null;
|
|
|
40
40
|
function depthStore() {
|
|
41
41
|
return (_depthStore ??= nodeImport("node:async_hooks").then((m) => new m.AsyncLocalStorage()));
|
|
42
42
|
}
|
|
43
|
+
// The default sub-agent model for the turn in flight (a MoA turn sets its specialist). Async-context scoped, like the
|
|
44
|
+
// depth above, so two ACP sessions in one process never see each other's default.
|
|
45
|
+
let _defaultModelStore;
|
|
46
|
+
function defaultModelStore() {
|
|
47
|
+
return (_defaultModelStore ??= nodeImport("node:async_hooks").then((m) => new m.AsyncLocalStorage()));
|
|
48
|
+
}
|
|
49
|
+
/** Run `fn` with `modelId` as delegate_task's default model (the planner can still pass `model`). */
|
|
50
|
+
export async function withDelegateDefault(modelId, fn) {
|
|
51
|
+
return (await defaultModelStore()).run(modelId, fn);
|
|
52
|
+
}
|
|
53
|
+
/** The step's role (its prompt + scoped tool set): the turn router's trained head when the classifier is on (finds
|
|
54
|
+
* research steps 3× as often as the keyword rules on real prompts), the keyword rules otherwise. */
|
|
55
|
+
async function delegateRole(task, settings) {
|
|
56
|
+
const [{ resolveMode }, { classifierConfig }, { routeTurn, roleFor }] = await Promise.all([
|
|
57
|
+
import("../classifier/modes.js"), import("../classifier/config.js"), import("../classifier/route.js"),
|
|
58
|
+
]);
|
|
59
|
+
if (resolveMode(settings) === "off")
|
|
60
|
+
return inferType(task);
|
|
61
|
+
return roleFor(task, await routeTurn(task, classifierConfig(settings).endpoint));
|
|
62
|
+
}
|
|
43
63
|
/** Current delegation depth: the async-context depth, floored by KODE_DELEGATE_DEPTH. 0 = a planner. */
|
|
44
64
|
export async function delegationDepth() {
|
|
45
65
|
const scoped = (await depthStore()).getStore() ?? 0;
|
|
@@ -123,7 +143,7 @@ export async function runDelegateTask(args, deps = defaultDeps) {
|
|
|
123
143
|
const settings = await deps.loadSettings();
|
|
124
144
|
// Default sub-agent model is a SETTING (autonomy.delegateModel), not a hardcode, so a new sub-agent can be
|
|
125
145
|
// dropped in by changing one value — the planner still overrides per call via `args.model`.
|
|
126
|
-
const defaultModel = (settings.autonomy?.delegateModel ?? "").trim() || DEFAULT_DELEGATE_MODEL;
|
|
146
|
+
const defaultModel = (await defaultModelStore()).getStore() || (settings.autonomy?.delegateModel ?? "").trim() || DEFAULT_DELEGATE_MODEL;
|
|
127
147
|
const modelId = String(args.model ?? "").trim() || defaultModel;
|
|
128
148
|
// Gate BYO providers (Claude/OpenAI/Gemini/Qwen/…) on the user actually having stored that provider's key,
|
|
129
149
|
// the same check /model applies — so an unconnected provider fails fast with the actionable "store the key"
|
|
@@ -154,7 +174,7 @@ export async function runDelegateTask(args, deps = defaultDeps) {
|
|
|
154
174
|
let session;
|
|
155
175
|
try {
|
|
156
176
|
session = await deps.createSession(deriveDelegateSettings(settings, profile, auroraOverride), {
|
|
157
|
-
role:
|
|
177
|
+
role: await delegateRole(task, settings), // the child runs as a role (prompt + scoped tools), not a clone of the owner's session
|
|
158
178
|
extra: {
|
|
159
179
|
sessionId: id,
|
|
160
180
|
memory: new MemoryStore(`${dir}/Operator_Memory.jsonl`),
|
|
@@ -97,7 +97,12 @@ export async function runHeadless(settings, prompt, opts = {}) {
|
|
|
97
97
|
const outcome = await session.send(prompt, handlers);
|
|
98
98
|
reporter.event("done", { rounds: outcome.rounds, toolCalls: outcome.toolCalls, interrupted: outcome.interrupted, durationMs: Math.round(outcome.durationMs ?? 0) });
|
|
99
99
|
result = { rounds: outcome.rounds, toolCalls: outcome.toolCalls, interrupted: outcome.interrupted, durationMs: Math.round(outcome.durationMs ?? 0) };
|
|
100
|
-
|
|
100
|
+
if (outcome.display) {
|
|
101
|
+
streamed = "";
|
|
102
|
+
if (output === "text")
|
|
103
|
+
process.stdout.write("\n");
|
|
104
|
+
} // an engine stop always ends on its question, even after a cut-off stream
|
|
105
|
+
answer(outcome.display ?? outcome.content);
|
|
101
106
|
await session.flushRouteShadow(); // MOA phase-0: headless one-shot exits before fire-and-forget would land
|
|
102
107
|
return finish(outcome.interrupted ? 130 : 0);
|
|
103
108
|
}
|
package/dist/autonomy/index.js
CHANGED
|
@@ -22,6 +22,7 @@ import { boardPath, addTask, readBoard } from "./board.js";
|
|
|
22
22
|
import { routinesPath, readRoutines } from "./routines.js";
|
|
23
23
|
import { readableRoutine, nextFire, runRoutine, launchdPlist, launchdLabel, crontabLine } from "./routine-run.js";
|
|
24
24
|
import { ensureServices } from "../services/preflight.js";
|
|
25
|
+
import { modelRegistry } from "../router/models.js";
|
|
25
26
|
const AUTONOMY_COMMANDS = new Set(["run", "loop", "board", "routine", "dream", "acp", "media-robot"]);
|
|
26
27
|
/** Split argv (after the subcommand) into --bool flags, --key value pairs, and positionals. `--` ends
|
|
27
28
|
* flag parsing so a task string starting with a dash is preserved. */
|
|
@@ -74,6 +75,14 @@ export function runFlags(args) {
|
|
|
74
75
|
return "--model needs a model id";
|
|
75
76
|
return { output, model, permissions: pm, cwd: f.val.get("cwd") };
|
|
76
77
|
}
|
|
78
|
+
/** `--model`: a registry id (`moa`, `cortana`, `gpt-oss-20b` …) selects that model — the same as `/model` — so an
|
|
79
|
+
* orchestrated profile like MoA really runs as MoA; any other string is a raw model name on the primary endpoint. */
|
|
80
|
+
export function applyRunModel(settings, model) {
|
|
81
|
+
if (modelRegistry(settings.models).some((m) => m.id === model))
|
|
82
|
+
settings.activeModel = model;
|
|
83
|
+
else
|
|
84
|
+
settings.endpoints.aurora = { ...settings.endpoints.aurora, model };
|
|
85
|
+
}
|
|
77
86
|
function usage(msg) {
|
|
78
87
|
process.stderr.write(`operator: ${msg}\n${RUN_USAGE}\n`);
|
|
79
88
|
return 2;
|
|
@@ -307,7 +316,7 @@ export async function dispatchAutonomy(argv, settings) {
|
|
|
307
316
|
return usage("no task given");
|
|
308
317
|
// Flags beat settings and KODE_* the same way the env overrides beat the file: for this run only.
|
|
309
318
|
if (model)
|
|
310
|
-
settings
|
|
319
|
+
applyRunModel(settings, model);
|
|
311
320
|
if (pm)
|
|
312
321
|
settings.permissions = { ...settings.permissions, mode: pm };
|
|
313
322
|
const loop = cmd === "loop" || f.bool.has("loop");
|
|
@@ -11,6 +11,8 @@ import { SUBAGENT_ROLES } from "../engine/grandmaster.js";
|
|
|
11
11
|
import { ensureScratchDir } from "../config/scratch.js";
|
|
12
12
|
import { modelCtxFor, leanHarnessFor, DEFAULT_MODEL_ID } from "../router/models.js";
|
|
13
13
|
import { compactionThreshold, compactionCeilingTokens, turnWallClockMs, buildEndpointChain } from "../config/settings.js";
|
|
14
|
+
import { resolveMode } from "../classifier/modes.js";
|
|
15
|
+
import { classifierConfig } from "../classifier/config.js";
|
|
14
16
|
/** Build the Aurora router from settings — the headless twin of cli.tsx's buildRouter(). Both share the one
|
|
15
17
|
* multi-tier chain builder (primary → other fleet nodes → back-compat single failover → cloud), so a
|
|
16
18
|
* wedged/degraded endpoint fails over through the whole fleet before the turn can error. */
|
|
@@ -56,6 +58,7 @@ export function createAutonomySession(settings, opts = {}) {
|
|
|
56
58
|
recall: settings.memory.recall,
|
|
57
59
|
models: settings.models,
|
|
58
60
|
moa: settings.moa,
|
|
61
|
+
classifier: { mode: resolveMode(settings), endpoint: classifierConfig(settings).endpoint },
|
|
59
62
|
fastStart: settings.fastStart,
|
|
60
63
|
features: settings.features, // feature flags — registers flag-gated tools (e.g. cloudAgents) only when on
|
|
61
64
|
activeModel: settings.activeModel,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// The turn router client — operator-runtime/classifier (launchd co.0perator.classifier, 127.0.0.1:8400). One small
|
|
2
|
+
// encoder with two heads trained on real Operator prompts: will this request be answered without tools (a MoA turn
|
|
3
|
+
// then goes straight to the fast specialist instead of the planner), and which sub-agent role fits a step (its scoped
|
|
4
|
+
// tool set). Chosen 2026-10-31 on 382 real prompts over zero-shot GLiClass (AUC 0.765 vs 0.57–0.65).
|
|
5
|
+
// Advisory and never blocking: down, slow or malformed → null, and the caller does what it did before.
|
|
6
|
+
// Node-free (plain fetch) — safe for every bundle.
|
|
7
|
+
import { inferType } from "../engine/grandmaster.js";
|
|
8
|
+
const ROUTE_TIMEOUT_MS = 400; // the service answers in ~25–35 ms on CPU; anything slower is a sick service, not a slow one
|
|
9
|
+
const ROLES = ["research", "code-edit", "generic"];
|
|
10
|
+
const MIN_ROLE_P = 0.5;
|
|
11
|
+
export async function routeTurn(text, endpoint, timeoutMs = ROUTE_TIMEOUT_MS) {
|
|
12
|
+
const ctrl = new AbortController();
|
|
13
|
+
const timer = setTimeout(() => ctrl.abort(), timeoutMs);
|
|
14
|
+
try {
|
|
15
|
+
const res = await fetch(`${endpoint.replace(/\/$/, "")}/route`, {
|
|
16
|
+
method: "POST",
|
|
17
|
+
headers: { "content-type": "application/json" },
|
|
18
|
+
body: JSON.stringify({ text: text.slice(0, 4000) }),
|
|
19
|
+
signal: ctrl.signal,
|
|
20
|
+
});
|
|
21
|
+
if (!res.ok)
|
|
22
|
+
return null;
|
|
23
|
+
const j = (await res.json());
|
|
24
|
+
if ((j.route !== "direct" && j.route !== "work") || typeof j.p_direct !== "number")
|
|
25
|
+
return null;
|
|
26
|
+
const role = ROLES.includes(j.role) ? j.role : undefined;
|
|
27
|
+
return { route: j.route, pDirect: j.p_direct, role, roleP: j.role_p, latencyMs: j.latency_ms };
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
clearTimeout(timer);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** The sub-agent role for a delegated step. The keyword rules still own plan and review (the trained head has no
|
|
37
|
+
* examples of either); otherwise a confident classifier role wins — on real prompts it finds research steps 3× as
|
|
38
|
+
* often (12/31 vs 4/31) — and anything else falls back to the keyword rules. */
|
|
39
|
+
export function roleFor(task, route) {
|
|
40
|
+
const kw = inferType(task);
|
|
41
|
+
if (kw === "plan" || kw === "review")
|
|
42
|
+
return kw;
|
|
43
|
+
if (route?.role && (route.roleP ?? 0) >= MIN_ROLE_P)
|
|
44
|
+
return route.role;
|
|
45
|
+
return kw;
|
|
46
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -59,6 +59,8 @@ import { expandFileMentions } from "./util/mentions.js";
|
|
|
59
59
|
import { snapshotEphemeralImages } from "./util/screenshots.js";
|
|
60
60
|
import { isFeatureEnabled } from "./config/features.js";
|
|
61
61
|
import { classifyActVsAsk, actAskGateDirective } from "./engine/classifier.js";
|
|
62
|
+
import { resolveMode } from "./classifier/modes.js";
|
|
63
|
+
import { classifierConfig } from "./classifier/config.js";
|
|
62
64
|
import { throttle } from "./util/throttle.js";
|
|
63
65
|
import { isSlashCommand } from "./util/slash.js";
|
|
64
66
|
import * as compose from "./compose/client.js";
|
|
@@ -660,7 +662,8 @@ function Root() {
|
|
|
660
662
|
recall: settings.memory.recall,
|
|
661
663
|
models: MERGED_MODELS, // discovered fleet nodes + settings.models overrides (built-ins in router/models.ts)
|
|
662
664
|
dynamicModels: () => freeRowsRef.current, // the free vendor rows /model fetched this session
|
|
663
|
-
moa: settings.moa,
|
|
665
|
+
moa: settings.moa,
|
|
666
|
+
classifier: { mode: resolveMode(settings), endpoint: classifierConfig(settings).endpoint }, // the turn router (classifier/route.ts) // MOA proposers/aggregator config (MOA-DESIGN.md); absent = "/model moa" explains
|
|
664
667
|
fastStart: settings.fastStart, // fast-model-vs-real-turn race (feature: fastStart, default OFF)
|
|
665
668
|
features: settings.features, // feature flags — registers flag-gated tools (e.g. cloudAgents) only when on
|
|
666
669
|
activeModel: settings.activeModel, // persisted /model choice, applied at startup
|
|
@@ -1224,13 +1227,13 @@ function Root() {
|
|
|
1224
1227
|
// Keep the final answer's thinking (dim, above the answer), plus a dim note when generation was
|
|
1225
1228
|
// cut short — loop breaker, output-limit truncation, or content filter — so a short/odd answer
|
|
1226
1229
|
// is never a mystery.
|
|
1227
|
-
const stopNote = outcome.stopReason === "
|
|
1228
|
-
: outcome.stopReason === "
|
|
1229
|
-
:
|
|
1230
|
-
: undefined;
|
|
1230
|
+
const stopNote = outcome.stopReason === "length" ? "(truncated at the output limit — ask me to continue)"
|
|
1231
|
+
: outcome.stopReason === "content_filter" ? "(the model stopped — content filter)"
|
|
1232
|
+
: undefined;
|
|
1231
1233
|
const reasoning = [liveReasoning.current.trim(), stopNote].filter(Boolean).join("\n") || undefined;
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
+
const shown = outcome.display ?? outcome.content; // an engine stop reads as a question, not a bracketed note
|
|
1235
|
+
push({ kind: "message", message: { id: nextId(), role: "assistant", content: shown, reasoning } });
|
|
1236
|
+
remoteRef.current?.finalAssistant(shown, reasoning);
|
|
1234
1237
|
}
|
|
1235
1238
|
// Surface the turn's real metrics: wall time · output tokens @ decode tok/s · prefill size. The
|
|
1236
1239
|
// prefill number is the key one on a local model — it's where "0 tokens for N seconds" goes (the
|
package/dist/config/settings.js
CHANGED
|
@@ -75,15 +75,12 @@ const DEFAULTS = {
|
|
|
75
75
|
vision: { autostart: false, launchdLabel: "co.0perator.vision", plistPath: "~/Library/LaunchAgents/co.0perator.vision.plist", legacyLabels: ["axe.vision-bot"], url: "http://127.0.0.1:7788", remoteUrl: "http://192.168.1.103:8095" },
|
|
76
76
|
stopOnExit: { searxng: true }, // aurora/autopilot are shared + never stopped; only the SearXNG container is
|
|
77
77
|
},
|
|
78
|
-
// MOA (2026-10-
|
|
79
|
-
//
|
|
80
|
-
// Was
|
|
78
|
+
// MOA (2026-10-31, James): a planner/specialist team, Manus-style — Cortana plans, delegates each step to a
|
|
79
|
+
// gpt-oss-20b sub-agent, checks the result and writes the answer (and reads images). Both on JL1 through the gateway.
|
|
80
|
+
// Was parallel drafts (gpt-oss-20b + Cortana) merged by Cortana (10/30). settings.moa replaces it wholesale.
|
|
81
81
|
moa: {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
{ id: "cortana", endpoint: GATEWAY_BASE, model: "cortana" },
|
|
85
|
-
],
|
|
86
|
-
aggregator: { id: "cortana", endpoint: GATEWAY_BASE, model: "cortana" },
|
|
82
|
+
planner: { id: "cortana", endpoint: GATEWAY_BASE, model: "cortana" },
|
|
83
|
+
specialist: { id: "gpt-oss-20b" },
|
|
87
84
|
},
|
|
88
85
|
activeModel: DEFAULT_MODEL_ID, // /model default — the 1M endpoint, unchanged from before /model existed
|
|
89
86
|
// Autonomy: everything conservative. keepAwake off; dream OFF and read-mostly with a board-only
|
package/dist/engine/agent.js
CHANGED
|
@@ -27,7 +27,7 @@ const LOOP_GUARD_LIMIT = 5; // identical (name+args) calls in a turn before shor
|
|
|
27
27
|
// headroom before the guard fires. The narration/no-progress stalls below are the separate progress-gated stops.
|
|
28
28
|
import { DECISION_POINT_NUDGE, isBuildRequest, shouldHoldForDecision } from "./decision-points.js";
|
|
29
29
|
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
|
|
30
|
-
import { ANNOUNCE_NUDGE, ANNOUNCE_NUDGE_MAX, DELEGATION_NUDGE, detectAnnouncedDelegation, detectUnfinishedAction, engineNote, detectSelfDialogue, SELF_DIALOGUE_NUDGE, SELF_DIALOGUE_NUDGE_MAX, needsClosingSteer, CLOSING_NUDGE, CLOSING_NUDGE_UNATTENDED, EMPTY_REPLY_NUDGE, emptyReplyStatus, closeStopNote, stripEngineEcho, isEngineFinal } from "./continuation.js";
|
|
30
|
+
import { ANNOUNCE_NUDGE, ANNOUNCE_NUDGE_MAX, DELEGATION_NUDGE, detectAnnouncedDelegation, detectUnfinishedAction, engineNote, detectSelfDialogue, SELF_DIALOGUE_NUDGE, SELF_DIALOGUE_NUDGE_MAX, needsClosingSteer, CLOSING_NUDGE, CLOSING_NUDGE_UNATTENDED, EMPTY_REPLY_NUDGE, emptyReplyStatus, closeStopNote, stopQuestion, stripEngineEcho, isEngineFinal } from "./continuation.js";
|
|
31
31
|
// Poll/status tools are meant to be called repeatedly while waiting on async work — NEVER a spin, so the
|
|
32
32
|
// loop guard skips them entirely (agent_status polls sub-agents, bash_output polls a background job).
|
|
33
33
|
const LOOP_GUARD_EXEMPT = new Set(["agent_status", "bash_output"]);
|
|
@@ -641,7 +641,7 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
641
641
|
const stopTurn = (note, roundsRun, stopReason) => {
|
|
642
642
|
const text = closeStopNote(note, opts.preservedState?.()); // never a bare stop: the open items + how to steer
|
|
643
643
|
conversation.assistant(text);
|
|
644
|
-
return { content: text, rounds: roundsRun, toolCalls: toolCallTotal, stopReason, tokens: tokensTotal, genMs: genMsTotal, promptTokens: promptTokensTotal, promptMs: promptMsTotal };
|
|
644
|
+
return { content: text, display: stopQuestion(note, opts.preservedState?.()), rounds: roundsRun, toolCalls: toolCallTotal, stopReason, tokens: tokensTotal, genMs: genMsTotal, promptTokens: promptTokensTotal, promptMs: promptMsTotal };
|
|
645
645
|
};
|
|
646
646
|
/** Feed one settled tool batch to the converge guard; true ⇒ the turn has stalled and must stop. */
|
|
647
647
|
const stalledNotConverging = (calls, toolMsgs, content) => {
|
|
@@ -1477,7 +1477,8 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
1477
1477
|
? "(hit the output limit before an answer landed — ask me to continue and I'll pick up where I left off.)"
|
|
1478
1478
|
: emptyReplyStatus(opts.preservedState?.(), emptyRetries + 1)));
|
|
1479
1479
|
conversation.assistant(answer);
|
|
1480
|
-
|
|
1480
|
+
const display = final ? undefined : stopQuestion(answer, opts.preservedState?.()); // the engine's own empty/length status, said plainly
|
|
1481
|
+
return { content: answer, display, rounds: rounds + 1, toolCalls: toolCallTotal, stopReason: response.stopReason, tokens: tokensTotal, genMs: genMsTotal, promptTokens: promptTokensTotal, promptMs: promptMsTotal, unverified: unverified || undefined };
|
|
1481
1482
|
}
|
|
1482
1483
|
const timeoutMsg = `[stopped after ${rounds} tool rounds — the task may be unfinished; ask me to continue and I'll pick up where I left off]`;
|
|
1483
1484
|
return stopTurn(timeoutMsg, rounds);
|
|
@@ -155,6 +155,27 @@ function tasksBlock(activeTasks) {
|
|
|
155
155
|
const t = (activeTasks ?? "").replace(/^\[Your active task list[^\n]*\]\n?/, "").trim();
|
|
156
156
|
return t ? `\n\nOpen items:\n${t}` : "";
|
|
157
157
|
}
|
|
158
|
+
/** What the owner (or their client) reads when the engine ends a turn itself. The `[stopped — …]` / `[paused — …]` note
|
|
159
|
+
* stays in history and in `content` — the model and the flywheel, delegate and self-improve detectors key on it — but on
|
|
160
|
+
* screen a bracketed engine note reads as an error. This is the same situation said plainly, ending in a question. */
|
|
161
|
+
const STOP_QUESTIONS = [
|
|
162
|
+
{ match: /sub-agents? (?:are running|dispatched)|waiting on sub-agents/i, lead: "I've handed parts of this to helpers and will pick it up as soon as they report back.", ask: "" },
|
|
163
|
+
{ match: /repetition loop/i, lead: "That answer wasn't coming out right, so I held it back.", ask: "Want me to take another pass with a different approach, or is there one part you'd like me to focus on first?" },
|
|
164
|
+
{ match: /reasoned a long time/i, lead: "I've thought this through but haven't acted on it yet.", ask: "Should I go ahead with the next concrete step, or would you like to point me somewhere first?" },
|
|
165
|
+
{ match: /^\[paused/i, lead: "This is taking longer than I expected.", ask: "Want me to keep going from here?" },
|
|
166
|
+
{ match: /over this model's window/i, lead: "This conversation has grown too long for me to keep working in it.", ask: "Want me to compact it (/compact) and carry on?" },
|
|
167
|
+
{ match: /stopped after \d+ tool rounds/i, lead: "I've worked through a lot of steps and may not be finished.", ask: "Want me to continue from here?" },
|
|
168
|
+
{ match: /no reply came back/i, lead: "I didn't get a response back that time.", ask: "Want me to try again?" },
|
|
169
|
+
{ match: /hit the output limit/i, lead: "I ran out of room before finishing that answer.", ask: "Want me to continue?" },
|
|
170
|
+
{ match: /^\[stopped/i, lead: "I'm not making progress with the approach I was taking.", ask: "Should I try a different way, or can you tell me which part matters most?" },
|
|
171
|
+
];
|
|
172
|
+
/** The owner-facing version of an engine stop note, or undefined when `note` is not one (a normal answer). */
|
|
173
|
+
export function stopQuestion(note, activeTasks) {
|
|
174
|
+
const q = STOP_QUESTIONS.find((x) => x.match.test(note.trim()));
|
|
175
|
+
if (!q)
|
|
176
|
+
return undefined;
|
|
177
|
+
return [q.lead + tasksBlock(activeTasks), q.ask].filter(Boolean).join("\n\n");
|
|
178
|
+
}
|
|
158
179
|
/** The engine's own closing status when the model gives nothing: the active task list (when any) and a steer. */
|
|
159
180
|
export function emptyReplyStatus(activeTasks, tries) {
|
|
160
181
|
const tasks = tasksBlock(activeTasks) || "\n\nNo open items on the task list.";
|
package/dist/engine/moa.js
CHANGED
|
@@ -1,59 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
async function callProposer(p, messages) {
|
|
12
|
-
const t0 = performance.now();
|
|
13
|
-
const ctrl = new AbortController();
|
|
14
|
-
const timer = setTimeout(() => ctrl.abort(), PROPOSER_TIMEOUT_MS);
|
|
15
|
-
try {
|
|
16
|
-
const res = await fetch(`${p.endpoint.replace(/\/$/, "")}/chat/completions`, {
|
|
17
|
-
method: "POST",
|
|
18
|
-
// The same bearer scoping as every model call: the signed-in Operator token on the 0perator gateway (proposers
|
|
19
|
-
// default to it), nothing for a local server or a foreign host.
|
|
20
|
-
headers: { "content-type": "application/json", ...authHeaders({ base: p.endpoint, model: p.model }) },
|
|
21
|
-
body: JSON.stringify({ model: p.model, messages, stream: false }),
|
|
22
|
-
signal: ctrl.signal,
|
|
23
|
-
});
|
|
24
|
-
if (!res.ok)
|
|
25
|
-
return { id: p.id, content: "", ms: Math.round(performance.now() - t0), error: `http ${res.status}` };
|
|
26
|
-
const json = await res.json();
|
|
27
|
-
const content = String(json?.choices?.[0]?.message?.content ?? "").trim();
|
|
28
|
-
return { id: p.id, content, ms: Math.round(performance.now() - t0), error: content ? undefined : "empty completion" };
|
|
29
|
-
}
|
|
30
|
-
catch (e) {
|
|
31
|
-
return { id: p.id, content: "", ms: Math.round(performance.now() - t0), error: e.name || "error" };
|
|
32
|
-
}
|
|
33
|
-
finally {
|
|
34
|
-
clearTimeout(timer);
|
|
35
|
-
}
|
|
1
|
+
/** The team from settings.moa, new shape or the pre-10/31 one (aggregator → planner, first other proposer →
|
|
2
|
+
* specialist). Undefined when no planner is configured. A missing specialist falls back to the planner itself. */
|
|
3
|
+
export function moaTeam(cfg) {
|
|
4
|
+
const planner = cfg?.planner ?? cfg?.aggregator;
|
|
5
|
+
if (!planner)
|
|
6
|
+
return undefined;
|
|
7
|
+
const specialist = cfg?.specialist?.id?.trim()
|
|
8
|
+
|| cfg?.proposers?.find((p) => p.id !== planner.id)?.id
|
|
9
|
+
|| planner.id;
|
|
10
|
+
return { planner, specialist, prompt: cfg?.planner_prompt };
|
|
36
11
|
}
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
12
|
+
/** The planner's standing brief. Identical every turn for a given team, so it stays in the prompt cache. */
|
|
13
|
+
export function plannerBrief(team) {
|
|
14
|
+
if (team.prompt)
|
|
15
|
+
return team.prompt;
|
|
16
|
+
const s = team.specialist;
|
|
17
|
+
return [
|
|
18
|
+
`You are the planner of a two-model team: you (${team.planner.id}) plan, check and answer; ${s} is your specialist.`,
|
|
19
|
+
"- A question you can answer directly, answer directly — no plan, no delegation.",
|
|
20
|
+
"- Otherwise plan first: add each step to the task list (task_add), small and concrete, in order.",
|
|
21
|
+
`- Hand each self-contained step to the specialist with delegate_task (it runs on ${s} by default). The specialist sees`,
|
|
22
|
+
" only the task you write: include the goal, the inputs (paths, URLs, facts) and what to report back. Independent",
|
|
23
|
+
" steps can be delegated together.",
|
|
24
|
+
"- Do yourself: a single quick tool call, anything that needs reading an image (only you read images), and the final",
|
|
25
|
+
" answer.",
|
|
26
|
+
"- Check every report before marking the step done (task_update); fix or redo a wrong one instead of passing it on.",
|
|
27
|
+
"- Finish with the result for the owner — what was done and what it found — not a description of the process.",
|
|
28
|
+
`This mixture's team: planner ${team.planner.id}; specialist ${s}. Asked which models make up the mixture, name exactly these.`,
|
|
29
|
+
].join("\n");
|
|
42
30
|
}
|
|
43
|
-
/** Label + join the surviving (non-empty) drafts as "Candidate A: ..." (MOA-DESIGN.md), for the
|
|
44
|
-
* aggregator's input. Pure + testable without a network call. */
|
|
45
|
-
export function labelDrafts(drafts) {
|
|
46
|
-
return drafts
|
|
47
|
-
.filter((d) => d.content)
|
|
48
|
-
.map((d, i) => `Candidate ${String.fromCharCode(65 + i)} (${d.id}):\n${d.content}`)
|
|
49
|
-
.join("\n\n");
|
|
50
|
-
}
|
|
51
|
-
/** The team, as fact, for the aggregator. Without it the model guessed its own members from the fleet notes in the
|
|
52
|
-
* prompt (10/30: it named Aurora and the vision model while only Cortana had answered, Dolphin being down). */
|
|
53
|
-
export function teamLine(proposers, answered, aggregator) {
|
|
54
|
-
const missing = proposers.map((p) => p.id).filter((id) => !answered.includes(id));
|
|
55
|
-
return `This mixture's team: proposers ${proposers.map((p) => p.id).join(", ")}; aggregator ${aggregator}.` +
|
|
56
|
-
(missing.length ? ` Did not answer this turn: ${missing.join(", ")}.` : "") +
|
|
57
|
-
" Asked which models make up the mixture, name exactly these.";
|
|
58
|
-
}
|
|
59
|
-
export const DEFAULT_AGGREGATOR_PROMPT = "You are given candidate answers from several models. Synthesize the single best, correct, complete answer. Do not mention the candidates.";
|
package/dist/router/models.js
CHANGED
|
@@ -65,6 +65,7 @@ export const BUILTIN_MODELS = [
|
|
|
65
65
|
// claims MORE than the server's --ctx-size makes the engine overrun the wall and the server cuts a round
|
|
66
66
|
// mid-tool-call (0.1.259) — change this number ONLY when the server's --ctx-size changes.
|
|
67
67
|
{ id: "cortana", tier: "power", label: "Cortana", params: "35B-A3B", box: "JL1", kind: "single", desc: "Qwen3.6-35B-A3B abliterated, Q4_K_M", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: ["cortana", "cortana"], model: "/Volumes/Ai Storage/jl1-local/models/aurorax/Huihui-Qwen3.6-35B-A3B-abliterated.Q4_K_M.gguf", ctx: 262144 },
|
|
68
|
+
{ id: "gpt-oss-20b", tier: "economy", label: "gpt-oss", params: "20B-A3.6B", box: "JL1", kind: "single", desc: "OpenAI gpt-oss-20b, Q4_K_M — the MoA specialist (arena's best sub-agent)", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: ["gpt-oss-20b", "gpt-oss-20b"], model: "gpt-oss-20b", ctx: 65536 },
|
|
68
69
|
// Thor — huihui-ai QwQ-32B abliterated: a dense reasoning model that thinks before it answers. Served on JL1:8124
|
|
69
70
|
// (the portal lists it "available" = registered, loaded on demand); gateway-first like cortana. ctx 32768 = the
|
|
70
71
|
// server's --ctx-size. Mirrors the hand override JL2's settings.json carried under this id (now a no-op by id).
|
|
@@ -139,7 +140,7 @@ export const BUILTIN_MODELS = [
|
|
|
139
140
|
{ id: "axe-aurora-300k", tier: "power", label: "Aurora Code 1", params: "35B-A3B", box: "cloud", kind: "single", desc: "remote shared slot via api.0perator.co (api.axe.onl as fallback) — contended decode measured 1-4.6 tok/s vs local 24-47; cold >~100K prefills can hit the Cloudflare ~125s edge cutoff", endpoint: GATEWAY_BASE, endpoints: [GATEWAY_BASE, LEGACY_GATEWAY_BASE], model: "aurora-code-1", ctx: 307200, transport: "openai", hidden: true },
|
|
140
141
|
{ id: "operator-128k", tier: "economy", label: "Aurora Code 1", params: "35B-A3B", box: "JL2", 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 },
|
|
141
142
|
// ── orchestrated ────────────────────────────────────────────────────────────────────────────────────────
|
|
142
|
-
{ id: "moa", tier: "power_turbo", label: "MOA", box: "mixture of agents", kind: "orchestrated", desc: "the team slot — each
|
|
143
|
+
{ id: "moa", tier: "power_turbo", label: "MOA", box: "mixture of agents", kind: "orchestrated", desc: "the team slot — Cortana plans each request into steps and hands them to gpt-oss-20b specialists, checks their work, writes the answer and reads any images (settings.moa overrides)" },
|
|
143
144
|
];
|
|
144
145
|
export const OPERATOR_FREE_ACCOUNT = "0perator";
|
|
145
146
|
export const BYO_PRESETS = {
|
package/dist/session.js
CHANGED
|
@@ -13,7 +13,9 @@ import { engineRouter } from "./engine/router-adapter.js";
|
|
|
13
13
|
import { appendFileSync, mkdirSync } from "node:fs";
|
|
14
14
|
import { dirname } from "node:path";
|
|
15
15
|
import { operatorPath } from "./config/home.js";
|
|
16
|
-
import {
|
|
16
|
+
import { moaTeam, plannerBrief } from "./engine/moa.js";
|
|
17
|
+
import { routeTurn } from "./classifier/route.js";
|
|
18
|
+
import { withDelegateDefault } from "./autonomy/delegate.js";
|
|
17
19
|
import { routeShadowTurn, shadowPrompt } from "./moa/shadow.js"; // MOA phase-0 observability (KODE_MOA_SHADOW)
|
|
18
20
|
import { AuroraRouter } from "./router/router.js";
|
|
19
21
|
import { operatorAgentPersona } from "./config/operator-harness.js";
|
|
@@ -296,6 +298,7 @@ export class Session {
|
|
|
296
298
|
pin; // the owner's context pin (tokens); undefined = auto — read live by the engine router
|
|
297
299
|
servedByBase = new Map(); // raw n_ctx learned per base (probeServedContext)
|
|
298
300
|
moaConfig;
|
|
301
|
+
classifier;
|
|
299
302
|
fastStartConfig;
|
|
300
303
|
fastStartEnabled;
|
|
301
304
|
modelId = DEFAULT_MODEL_ID; // active /model selection
|
|
@@ -436,6 +439,7 @@ export class Session {
|
|
|
436
439
|
this.registry = modelRegistry(cfg.models);
|
|
437
440
|
this.isOwner = (cfg.eventActor?.tier ?? "admin") === "admin"; // set before the startup setModel so a persisted owner-only activeModel resolves for the owner
|
|
438
441
|
this.moaConfig = cfg.moa;
|
|
442
|
+
this.classifier = cfg.classifier;
|
|
439
443
|
this.fastStartConfig = cfg.fastStart;
|
|
440
444
|
this.fastStartEnabled = isFeatureEnabled("fastStart", { features: cfg.features }) && !!cfg.fastStart;
|
|
441
445
|
// Apply the persisted /model choice, unless a router was explicitly injected (tests / bg agents
|
|
@@ -825,6 +829,32 @@ export class Session {
|
|
|
825
829
|
currentModel() {
|
|
826
830
|
return this.modelId;
|
|
827
831
|
}
|
|
832
|
+
/** The endpoint chain for a single-endpoint profile (/model, and the MoA specialist's fast path). */
|
|
833
|
+
routerForProfile(profile) {
|
|
834
|
+
// BYO connectors carry their vendor bearer (never the Operator token — see authHeaders scoping);
|
|
835
|
+
// selectModel already refused the id if the key is not connected, so resolution can't miss here.
|
|
836
|
+
const token = profile.byo ? getByoToken(profile.byo, profileEndpoint(profile)) : undefined;
|
|
837
|
+
// A failover `endpoints` list builds one AuroraRouter endpoint per box (same model/alias on each), so
|
|
838
|
+
// the router hops primary->standby on a busy/5xx; a lone `endpoint` is the single-box case. Names carry
|
|
839
|
+
// the host so /route reads which box answered.
|
|
840
|
+
const bases = profile.endpoints?.length ? profile.endpoints : [profile.endpoint];
|
|
841
|
+
// A fleet entry that lists the AXE gateway beside direct LAN legs: authHeaders trusts LAN hosts, so
|
|
842
|
+
// without this the Operator bearer would ride along to the LAN leg. "" is falsy (no Authorization
|
|
843
|
+
// header) yet not nullish, so it also stops authHeaders falling back to the signed-in token.
|
|
844
|
+
const hasGatewayLeg = !profile.byo && bases.some((b) => requiresOperatorToken(b));
|
|
845
|
+
const eps = bases.map((ep, i) => ({
|
|
846
|
+
name: bases.length > 1 ? `${profile.id}@${endpointBase(ep).replace(/^https?:\/\//, "")}` : profile.id,
|
|
847
|
+
base: endpointBase(ep),
|
|
848
|
+
model: profile.endpointModels?.[i] ?? profile.model ?? profile.id,
|
|
849
|
+
ctxLimit: profile.ctx ?? this.inner.ctxLimit(),
|
|
850
|
+
token: token ?? (hasGatewayLeg && !requiresOperatorToken(ep) ? "" : undefined),
|
|
851
|
+
transport: profile.transport,
|
|
852
|
+
chatPath: profile.chatPath,
|
|
853
|
+
maxOutput: profile.maxOutput,
|
|
854
|
+
provider: profile.box,
|
|
855
|
+
}));
|
|
856
|
+
return new AuroraRouter(eps);
|
|
857
|
+
}
|
|
828
858
|
/** Switch the active model (/model). A "single" profile rebuilds the router to point at that
|
|
829
859
|
* endpoint — no server is started/stopped, this only changes which endpoint THIS session talks
|
|
830
860
|
* to. "moa" has no endpoint of its own; send() special-cases it (sendMoa) instead. Returns an
|
|
@@ -834,8 +864,8 @@ export class Session {
|
|
|
834
864
|
const { profile, error } = selectModel(this.liveRegistry(), id, hasByoToken, this.isOwner);
|
|
835
865
|
if (error || !profile)
|
|
836
866
|
return { ok: false, error };
|
|
837
|
-
if (profile.kind === "orchestrated" && !this.moaConfig
|
|
838
|
-
return { ok: false, error: `MOA needs a "moa" block (
|
|
867
|
+
if (profile.kind === "orchestrated" && !moaTeam(this.moaConfig)) {
|
|
868
|
+
return { ok: false, error: `MOA needs a "moa" block (planner + specialist) in settings.json` };
|
|
839
869
|
}
|
|
840
870
|
if (profile.kind === "single" && profile.id === DEFAULT_MODEL_ID && this.chain) {
|
|
841
871
|
// The default local model IS the shell's endpoint chain (the gateway's published port + its failover
|
|
@@ -845,29 +875,7 @@ export class Session {
|
|
|
845
875
|
this.router = this.wrap(this.inner);
|
|
846
876
|
}
|
|
847
877
|
else if (profile.kind === "single" && (profile.endpoint || profile.endpoints?.length)) {
|
|
848
|
-
|
|
849
|
-
// selectModel already refused the id if the key is not connected, so resolution can't miss here.
|
|
850
|
-
const token = profile.byo ? getByoToken(profile.byo, profileEndpoint(profile)) : undefined;
|
|
851
|
-
// A failover `endpoints` list builds one AuroraRouter endpoint per box (same model/alias on each), so
|
|
852
|
-
// the router hops primary->standby on a busy/5xx; a lone `endpoint` is the single-box case. Names carry
|
|
853
|
-
// the host so /route reads which box answered.
|
|
854
|
-
const bases = profile.endpoints?.length ? profile.endpoints : [profile.endpoint];
|
|
855
|
-
// A fleet entry that lists the AXE gateway beside direct LAN legs: authHeaders trusts LAN hosts, so
|
|
856
|
-
// without this the Operator bearer would ride along to the LAN leg. "" is falsy (no Authorization
|
|
857
|
-
// header) yet not nullish, so it also stops authHeaders falling back to the signed-in token.
|
|
858
|
-
const hasGatewayLeg = !profile.byo && bases.some((b) => requiresOperatorToken(b));
|
|
859
|
-
const eps = bases.map((ep, i) => ({
|
|
860
|
-
name: bases.length > 1 ? `${profile.id}@${endpointBase(ep).replace(/^https?:\/\//, "")}` : profile.id,
|
|
861
|
-
base: endpointBase(ep),
|
|
862
|
-
model: profile.endpointModels?.[i] ?? profile.model ?? profile.id,
|
|
863
|
-
ctxLimit: profile.ctx ?? this.inner.ctxLimit(),
|
|
864
|
-
token: token ?? (hasGatewayLeg && !requiresOperatorToken(ep) ? "" : undefined),
|
|
865
|
-
transport: profile.transport,
|
|
866
|
-
chatPath: profile.chatPath,
|
|
867
|
-
maxOutput: profile.maxOutput,
|
|
868
|
-
provider: profile.box,
|
|
869
|
-
}));
|
|
870
|
-
this.inner = new AuroraRouter(eps);
|
|
878
|
+
this.inner = this.routerForProfile(profile);
|
|
871
879
|
this.router = this.wrap(this.inner);
|
|
872
880
|
}
|
|
873
881
|
this.modelId = profile.id;
|
|
@@ -1182,36 +1190,23 @@ export class Session {
|
|
|
1182
1190
|
this.wakeTurn = false;
|
|
1183
1191
|
}
|
|
1184
1192
|
}
|
|
1185
|
-
/** MOA turn (
|
|
1186
|
-
*
|
|
1187
|
-
*
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
const
|
|
1193
|
-
const
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
survived: survivors.map((d) => d.id),
|
|
1200
|
-
latenciesMs: Object.fromEntries(drafts.map((d) => [d.id, d.ms])),
|
|
1201
|
-
});
|
|
1202
|
-
if (!survivors.length) {
|
|
1203
|
-
h.onRoute?.(active.id, this.ctxPct());
|
|
1204
|
-
this.modelId = DEFAULT_MODEL_ID; // fall back for this and future turns until /model moa retries
|
|
1205
|
-
const note = "MOA: every proposer failed or timed out — falling back to operator-1m for this reply.\n\n";
|
|
1206
|
-
h.onDelta?.(note);
|
|
1207
|
-
const res = await this.execute(text, h, this.router, this.sysWithThink());
|
|
1208
|
-
return { ...res, content: note + res.content };
|
|
1209
|
-
}
|
|
1210
|
-
const aggRouter = this.wrap(new AuroraRouter([
|
|
1211
|
-
{ name: moa.aggregator.id, base: endpointBase(moa.aggregator.endpoint), model: moa.aggregator.model, ctxLimit: this.inner.ctxLimit() },
|
|
1193
|
+
/** MOA turn (engine/moa.ts): the planner takes the turn through the SAME runTurn loop as any turn (execute), on its
|
|
1194
|
+
* own endpoint, with the planner brief in the system prompt — and every delegate_task in it defaults to the
|
|
1195
|
+
* specialist. The brief is fixed per team, so the system prompt stays byte-stable across turns. */
|
|
1196
|
+
async sendMoa(text, h, _active) {
|
|
1197
|
+
const team = moaTeam(this.moaConfig); // setModel refuses to select "moa" without one
|
|
1198
|
+
// The router (classifier/route.ts): a request it is confident needs no tools goes straight to the fast
|
|
1199
|
+
// specialist — no planner round, no planner prefill. Anything else, or no answer from the router, is planned.
|
|
1200
|
+
const route = this.classifier && this.classifier.mode !== "off" ? await routeTurn(text, this.classifier.endpoint) : null;
|
|
1201
|
+
const specialist = route?.route === "direct" ? this.liveRegistry().find((m) => m.id === team.specialist && m.kind === "single") : undefined;
|
|
1202
|
+
this.telemetry.record({ type: "moa", planner: team.planner.id, specialist: team.specialist, route: specialist ? "direct" : route ? "planned" : "unrouted", pDirect: route?.pDirect });
|
|
1203
|
+
if (specialist)
|
|
1204
|
+
return this.execute(text, h, this.wrap(this.routerForProfile(specialist)), this.sysWithThink(), specialist.id);
|
|
1205
|
+
const plannerRouter = this.wrap(new AuroraRouter([
|
|
1206
|
+
{ name: team.planner.id, base: endpointBase(team.planner.endpoint), model: team.planner.model, ctxLimit: this.inner.ctxLimit() },
|
|
1212
1207
|
]));
|
|
1213
|
-
const
|
|
1214
|
-
return this.execute(text, h,
|
|
1208
|
+
const sys = `${this.sysWithThink() ?? ""}\n\n## MOA: planner\n${plannerBrief(team)}`;
|
|
1209
|
+
return withDelegateDefault(team.specialist, () => this.execute(text, h, plannerRouter, sys, team.planner.id));
|
|
1215
1210
|
}
|
|
1216
1211
|
/** Fire scout (settings.fastStart) with a bounded, independent timeout — never the real turn's own
|
|
1217
1212
|
* abort signal, so a user esc during the real turn doesn't need to also race scout's cleanup. Any
|