@0perator/operator 0.2.1 → 0.2.2-next.1
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/auth/byo.js +1 -1
- package/dist/auth/commands.js +8 -2
- package/dist/autonomy/agent-cli.js +1 -1
- package/dist/autonomy/headless.js +30 -6
- package/dist/autonomy/pr-isolation.js +92 -0
- package/dist/autonomy/pr-preflight.js +474 -0
- package/dist/autonomy/session-factory.js +2 -0
- package/dist/browser/capture.js +505 -0
- package/dist/browser/engine.js +4 -3
- package/dist/browser/page-capture.js +167 -0
- package/dist/browser/png.js +116 -0
- package/dist/browser/visual-compare.js +229 -0
- package/dist/bus/beam-drop.js +55 -0
- package/dist/bus/inbox.js +7 -1
- package/dist/cli.js +130 -26
- package/dist/config/managed.js +40 -1
- package/dist/config/persona.js +86 -41
- package/dist/config/product-hosts.js +2 -0
- package/dist/config/settings.js +30 -13
- package/dist/config/skills-index.js +37 -14
- package/dist/engine/agent.js +1 -1
- package/dist/engine/aurora.js +18 -9
- package/dist/engine/continuation.js +36 -0
- package/dist/engine/identity.js +42 -0
- package/dist/engine/moa.js +7 -0
- package/dist/engine/net-error.js +15 -0
- package/dist/engine/rolling-summary.js +142 -93
- package/dist/engine/waterfall.js +33 -0
- package/dist/gateway-cli.js +10 -1
- package/dist/memory/session-index.js +3 -3
- package/dist/permissions/index.js +2 -1
- package/dist/permissions/policy.js +9 -2
- package/dist/permissions/tier.js +9 -1
- package/dist/products/craft.js +90 -1
- package/dist/products/temple.js +20 -1
- package/dist/products/voice.js +112 -0
- package/dist/router/free-models.js +5 -9
- package/dist/router/models.js +58 -14
- package/dist/router/provider-models.js +78 -0
- package/dist/router/router.js +15 -3
- package/dist/selfimprove/lessons.js +23 -0
- package/dist/session.js +192 -87
- package/dist/skills/catalogue.js +5 -2
- package/dist/skills/finder.js +4 -4
- package/dist/skills/install-guard.js +1 -1
- package/dist/tools/beam.js +246 -0
- package/dist/tools/craft.js +23 -0
- package/dist/tools/deferred.js +7 -3
- package/dist/tools/doc-text.js +1 -1
- package/dist/tools/registry.js +55 -9
- package/dist/tools/sandbox.js +6 -6
- package/dist/ui/App.js +3 -3
- package/dist/ui/ApprovalPrompt.js +1 -1
- package/dist/ui/Composer.js +44 -2
- package/dist/ui/StatusRule.js +2 -1
- package/dist/ui/Transcript.js +5 -0
- package/dist/ui/modelPicker.js +10 -6
- package/dist/ui/phase.js +4 -2
- package/dist/ui/slashCommands.js +1 -0
- package/dist/ui/voice.js +185 -0
- package/dist/update.js +1 -2
- package/dist/util/audio-io.js +82 -0
- package/dist/util/slash.js +2 -2
- package/dist/vision/pairs.js +239 -0
- package/package.json +1 -1
package/dist/config/persona.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// picks up the SAME project context + handoff the TUI does, without importing cli.tsx (which mounts
|
|
4
4
|
// Ink and refuses a non-TTY). Pure, best-effort, never throws — a missing file is normal.
|
|
5
5
|
import { readFileSync, appendFileSync, mkdirSync, existsSync, writeFileSync, renameSync, realpathSync, statSync, chmodSync } from "node:fs";
|
|
6
|
+
import { execFileSync } from "node:child_process";
|
|
6
7
|
import { join, dirname } from "node:path";
|
|
7
8
|
import { operatorPath, globalMemoriesPath } from "./home.js";
|
|
8
9
|
import { renderHarnessContext } from "./operator-harness.js";
|
|
@@ -11,7 +12,7 @@ import { isFeatureEnabled } from "./features.js";
|
|
|
11
12
|
import { renderSkillsIndex } from "./skills-index.js";
|
|
12
13
|
import { decisionPointsEnabled } from "../engine/decision-points.js";
|
|
13
14
|
import { SUBAGENT_ROLES, SUBAGENT_TOOL_DENY } from "../engine/grandmaster.js";
|
|
14
|
-
import { LESSONS_HEADING, isLessonHeading, mergeLessons, parseLessonTag, reinforcedRules, splitLessons } from "../selfimprove/lessons.js";
|
|
15
|
+
import { LESSONS_HEADING, PROMPT_LESSONS, isLessonHeading, mergeLessons, parseLessonTag, reinforcedRules, splitLessons, topLessons } from "../selfimprove/lessons.js";
|
|
15
16
|
import { redactSecrets } from "../engine/redact.js";
|
|
16
17
|
import { fitWhole, splitItems, splitSections } from "./memory-sections.js";
|
|
17
18
|
import { freshHandoff, withoutSettled } from "../memory/live-progress.js";
|
|
@@ -54,11 +55,32 @@ export function projectMemoriesPath(cwd = process.cwd()) {
|
|
|
54
55
|
return join(cwd, ".operator", "memories.md");
|
|
55
56
|
}
|
|
56
57
|
const unitSize = (u) => u.text.length + 2;
|
|
58
|
+
/** A file index entry (`- name.md: what it covers`) keeps one short line; the file itself is read on demand. */
|
|
59
|
+
export const INDEX_LINE_CHARS = 80;
|
|
60
|
+
const INDEX_ENTRY = /^- [\w./-]+\.md\b/;
|
|
61
|
+
/** A section whose every list item names a .md file is an index: each entry cut to `max` chars at a word. Pure. */
|
|
62
|
+
export function compactFileIndex(text, max = INDEX_LINE_CHARS) {
|
|
63
|
+
const lines = text.split("\n");
|
|
64
|
+
const items = lines.filter((l) => /^[-*] /.test(l));
|
|
65
|
+
if (!items.length || !items.every((l) => INDEX_ENTRY.test(l)))
|
|
66
|
+
return text;
|
|
67
|
+
const clip = (l) => {
|
|
68
|
+
if (l.length <= max)
|
|
69
|
+
return l;
|
|
70
|
+
const cut = l.slice(0, max - 1);
|
|
71
|
+
const sp = cut.lastIndexOf(" ");
|
|
72
|
+
return (sp > max / 2 ? cut.slice(0, sp) : cut).replace(/[\s,;:—-]+$/, "") + "…";
|
|
73
|
+
};
|
|
74
|
+
return lines.map((l) => (INDEX_ENTRY.test(l) ? clip(l) : l)).join("\n");
|
|
75
|
+
}
|
|
57
76
|
/** A file's units: each headed section whole, and the facts of its flat list (the text before the first heading). */
|
|
58
|
-
function fileUnits(rest) {
|
|
59
|
-
return splitSections(rest).flatMap((section) =>
|
|
60
|
-
|
|
61
|
-
|
|
77
|
+
function fileUnits(rest, indexLineChars = INDEX_LINE_CHARS) {
|
|
78
|
+
return splitSections(rest).flatMap((section) => {
|
|
79
|
+
if (!section.heading)
|
|
80
|
+
return splitItems(section.text).map((text) => ({ text, fact: true }));
|
|
81
|
+
const text = compactFileIndex(section.text, indexLineChars);
|
|
82
|
+
return [{ text, section: { ...section, text } }];
|
|
83
|
+
});
|
|
62
84
|
}
|
|
63
85
|
/** One file's sections and facts under `budget` in priority order — `ahead` first (the lessons), then the rules sections,
|
|
64
86
|
* `between` (the taught lessons), the flat facts newest first, the notes sections — rendered as the rules, the facts,
|
|
@@ -78,36 +100,38 @@ function fitFile(units, budget, ahead = [], between = []) {
|
|
|
78
100
|
return { fit, shown, droppedNames };
|
|
79
101
|
}
|
|
80
102
|
const leftOut = (names, where) => names.length ? `\n(left out for the memory budget: ${names.join(", ")} — read ${where} for them)` : "";
|
|
81
|
-
/** The memory blocks of the system prompt: the lessons of both files as one list, then the global file's sections,
|
|
82
|
-
* the project file's — each file under its own MEMORY_BUDGET, whole lessons and sections only. Pure. */
|
|
83
|
-
export function renderMemories(global, project) {
|
|
103
|
+
/** The memory blocks of the system prompt: the top lessons of both files as one list, then the global file's sections,
|
|
104
|
+
* then the project file's — each file under its own MEMORY_BUDGET, whole lessons and sections only. Pure. */
|
|
105
|
+
export function renderMemories(global, project, opts = {}) {
|
|
84
106
|
const taught = reinforcedRules(global?.text ?? "");
|
|
85
107
|
const g = splitLessons(global?.text ?? "", taught);
|
|
86
108
|
const p = project ? splitLessons(project.text, taught) : undefined;
|
|
87
|
-
const
|
|
109
|
+
const top = topLessons(mergeLessons(g.lessons, p?.lessons ?? []), opts.lessons ?? PROMPT_LESSONS);
|
|
110
|
+
const lessons = top.kept.map(redactSecrets); // a line an older build wrote unmasked
|
|
88
111
|
const auto = [...lessons.filter((l) => parseLessonTag(l)?.kind !== "taught"), ...g.other, ...(p?.other ?? [])].map((text) => ({ text }));
|
|
89
112
|
const fromReviewers = lessons.filter((l) => parseLessonTag(l)?.kind === "taught").map((text) => ({ text }));
|
|
90
113
|
const where = global?.path ?? "memories.md";
|
|
91
114
|
let out = "";
|
|
92
|
-
const gf = fitFile(fileUnits(g.rest), MEMORY_BUDGET.global, auto, fromReviewers);
|
|
115
|
+
const gf = fitFile(fileUnits(g.rest, opts.indexLineChars), MEMORY_BUDGET.global, auto, fromReviewers);
|
|
93
116
|
const keptLessons = [...auto, ...fromReviewers].filter((u) => gf.fit.kept.has(u));
|
|
94
117
|
const droppedLessons = auto.length + fromReviewers.length - keptLessons.length;
|
|
95
118
|
if (keptLessons.length) {
|
|
96
119
|
out += `\n\n${LESSONS_HEADING}\n${keptLessons.map((u) => u.text).join("\n")}` +
|
|
97
|
-
(droppedLessons ? `\n(${droppedLessons} older lesson${droppedLessons === 1 ? "" : "s"} left out for the memory budget — all of them are in ${where})` : "")
|
|
120
|
+
(droppedLessons ? `\n(${droppedLessons} older lesson${droppedLessons === 1 ? "" : "s"} left out for the memory budget — all of them are in ${where})` : "") +
|
|
121
|
+
(top.rest ? `\n(${top.rest} more lesson${top.rest === 1 ? "" : "s"} not loaded: memory_search finds them; all are in ${where})` : "");
|
|
98
122
|
}
|
|
99
123
|
if (gf.shown.length || gf.droppedNames.length) {
|
|
100
124
|
out += `\n\n## Global memory (memories.md — applies to every project)\n${gf.shown.join("\n\n")}${leftOut(gf.droppedNames, where)}`;
|
|
101
125
|
}
|
|
102
126
|
if (project && p) {
|
|
103
|
-
const pf = fitFile(fileUnits(p.rest), MEMORY_BUDGET.project);
|
|
127
|
+
const pf = fitFile(fileUnits(p.rest, opts.indexLineChars), MEMORY_BUDGET.project);
|
|
104
128
|
if (pf.shown.length || pf.droppedNames.length) {
|
|
105
129
|
out += `\n\n## Project memory (${project.name} — this repo)\n${pf.shown.join("\n\n")}${leftOut(pf.droppedNames, project.name)}`;
|
|
106
130
|
}
|
|
107
131
|
}
|
|
108
132
|
return out;
|
|
109
133
|
}
|
|
110
|
-
export function loadMemories(cwd = process.cwd()) {
|
|
134
|
+
export function loadMemories(cwd = process.cwd(), opts = {}) {
|
|
111
135
|
let global;
|
|
112
136
|
try {
|
|
113
137
|
global = { text: readFileSync(globalMemoriesPath(), "utf8"), path: globalMemoriesPath() };
|
|
@@ -124,7 +148,7 @@ export function loadMemories(cwd = process.cwd()) {
|
|
|
124
148
|
}
|
|
125
149
|
catch { /* try the next */ }
|
|
126
150
|
}
|
|
127
|
-
return renderMemories(global, project);
|
|
151
|
+
return renderMemories(global, project, opts);
|
|
128
152
|
}
|
|
129
153
|
/** What the memory budget left out of the prompt, read from the rendered block itself (so the owner and the model are
|
|
130
154
|
* told the same thing): one entry per file, e.g. `"Notes", 2 older notes — not loaded from .operator/memories.md`.
|
|
@@ -249,24 +273,43 @@ export function loadStructuredMemories() {
|
|
|
249
273
|
return out;
|
|
250
274
|
}
|
|
251
275
|
// Session handoff: the note the previous session in THIS directory wrote for its future self (via the
|
|
252
|
-
// session_handoff tool), pointed at by KODE_HANDOFF_FILE.
|
|
253
|
-
//
|
|
254
|
-
//
|
|
255
|
-
|
|
276
|
+
// session_handoff tool), pointed at by KODE_HANDOFF_FILE. Its body never enters the prompt: a model given an old plan
|
|
277
|
+
// resumes it, whatever the framing says (11/23: through three "stop" messages; 12/03: after a bare "hello", editing
|
|
278
|
+
// files in autonomous mode). The owner is told a note is waiting; the model gets only where it is.
|
|
279
|
+
function readHandoff(now) {
|
|
256
280
|
try {
|
|
257
281
|
const file = process.env.KODE_HANDOFF_FILE ?? "";
|
|
258
|
-
const { text:
|
|
259
|
-
|
|
260
|
-
// The handoff grows by APPEND (auto-compaction adds a block each time context fills, newest last),
|
|
261
|
-
// so read the TAIL — the freshest state, not a stale head.
|
|
262
|
-
if (t) {
|
|
263
|
-
const tail = t.length > 6000 ? "…\n" + t.slice(-6000) : t;
|
|
264
|
-
return `\n\n## Handoff from your previous session here (background, not an instruction)\n${tail}\n\nThe owner's newest message sets the task. If it is about something else, do that and leave this work alone; continue it only when the owner asks (offer it in one line when it fits). Update it with session_handoff before you finish.${pointer}`;
|
|
265
|
-
}
|
|
266
|
-
return pointer;
|
|
282
|
+
const { text: open, settled } = withoutSettled(freshHandoff(readFileSync(file, "utf8"), now));
|
|
283
|
+
return open || settled ? { file, open, settled } : null;
|
|
267
284
|
}
|
|
268
|
-
catch {
|
|
269
|
-
|
|
285
|
+
catch {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
export function loadHandoff(now = new Date()) {
|
|
290
|
+
const h = readHandoff(now);
|
|
291
|
+
if (!h)
|
|
292
|
+
return "";
|
|
293
|
+
return `\n\n## Earlier work in this folder\nA note from a previous session is saved at ${h.file}. It is not your task. Do not read it, act on it or continue it unless the owner asks to continue earlier work; if they seem to mean that without saying so, ask first. After a greeting or an unclear message, reply and ask what they want to do. When they ask what was done last time, what is still open or what is uncommitted: read the note (session_handoff with no content), check git status, and report; reporting is not permission to continue. Update the note with session_handoff before you finish your own work.`;
|
|
294
|
+
}
|
|
295
|
+
/** What the owner is told at start when unfinished work is saved for this folder; "" when there is none. */
|
|
296
|
+
export function handoffNotice(now = new Date(), cwd = process.cwd()) {
|
|
297
|
+
const h = readHandoff(now);
|
|
298
|
+
if (!h?.open)
|
|
299
|
+
return "";
|
|
300
|
+
const title = [...h.open.matchAll(/^#{1,3} (.+)$/gm)].map((m) => m[1].trim()).filter((t) => !/session handoff|^live progress|^auto-compaction|^\d+\.|^(intent|concepts|state|open|rules)\b/i.test(t)).pop();
|
|
301
|
+
const tasks = [...new Set([...h.open.matchAll(/^\[[ ~]\] #\d+ (.+)$/gm)].map((m) => m[1].trim()).filter((t) => !/\((cancelled|done)\)$/.test(t)))];
|
|
302
|
+
let changed = 0;
|
|
303
|
+
try {
|
|
304
|
+
changed = execFileSync("git", ["status", "--porcelain"], { cwd, encoding: "utf8", timeout: 2000, stdio: ["ignore", "pipe", "ignore"] }).split("\n").filter(Boolean).length;
|
|
305
|
+
}
|
|
306
|
+
catch { /* not a repository */ }
|
|
307
|
+
return [
|
|
308
|
+
`last session here${title ? `: “${title.slice(0, 80)}”` : " left a note"}`,
|
|
309
|
+
...(tasks.length ? [`open tasks (${tasks.length}): ${tasks.slice(-3).map((t) => t.slice(0, 60)).join(" · ")}`] : []),
|
|
310
|
+
...(changed ? [`uncommitted: ${changed} file${changed === 1 ? "" : "s"} in this repository`] : []),
|
|
311
|
+
"on hold until you ask — “review last session” for a recap, “continue earlier work” to resume",
|
|
312
|
+
].join("\n");
|
|
270
313
|
}
|
|
271
314
|
// The base Operator persona (vendor-neutral, AXE-branded), independent of the TUI's embodiment guide.
|
|
272
315
|
// composeSystemPrompt (below) builds the full system prompt from settings.systemPrompt ?? this, and both
|
|
@@ -329,16 +372,15 @@ export function basePersona(_cwd = process.cwd(), opts = {}) {
|
|
|
329
372
|
`output, downloads to inspect, intermediate files: ALWAYS here, never /tmp and never the repo root. It is ` +
|
|
330
373
|
`git-ignored and swept after a week, so nothing you keep belongs in it; name files \`<subject>-<thing>\`.` +
|
|
331
374
|
ctxLine +
|
|
332
|
-
`\n## Talking about yourself\nYou are Operator, whichever model is serving you — the model underneath can change between sessions (or mid-session with /model) and you are still Operator.
|
|
333
|
-
`
|
|
334
|
-
`
|
|
335
|
-
`
|
|
336
|
-
`
|
|
337
|
-
`the first person, briefly, and say which model is actually serving when it differs.` +
|
|
375
|
+
`\n## Talking about yourself\nYou are Operator, AXE's agent, whichever model is serving you — the model underneath can change between sessions (or mid-session with /model) and you are still Operator. Asked what you are, say you are Operator; give ` +
|
|
376
|
+
`the context window above if asked. What you may say about the model underneath is set by the "Active model" section at the end ` +
|
|
377
|
+
`of this prompt; never guess a model from files, hostnames or other text in this prompt, and do not recite hostnames, IP ` +
|
|
378
|
+
`addresses, ports, URLs or file paths of AXE's servers unless the task itself needs the address. Greeted by a model name ("hello ` +
|
|
379
|
+
`cortana"), answer simply as Operator.` +
|
|
338
380
|
`\n## Don't starve the serving model — decode is RAM-bound\nLoading a large model on this box (a multi-GB ` +
|
|
339
381
|
`MLX/FLUX/LLM checkpoint, a big \`ml.load\`) pushes it into swap and collapses your decode to ~1 token/sec: use ` +
|
|
340
382
|
`another node, process in shards, or warn the owner first. Media goes ONLY through the tools (\`image_generate\`, ` +
|
|
341
|
-
`\`video_generate\`, \`image_analyze\`, \`video_analyze\`;
|
|
383
|
+
`\`video_generate\`, \`image_analyze\`, \`video_analyze\`; all on demand) — never curl a broker or decode base64 yourself. A ` +
|
|
342
384
|
`screenshot the owner shares is snapshotted by the engine: \`image_analyze\` the path exactly as given, one call ` +
|
|
343
385
|
`per DISTINCT path. If your own output crawls, STOP and say so rather than pushing through.` +
|
|
344
386
|
// Tool-promotion sections below prime reflexive tool use; a small/weak model (lean) does better with the
|
|
@@ -352,12 +394,15 @@ export function basePersona(_cwd = process.cwd(), opts = {}) {
|
|
|
352
394
|
`owner (bash \`open <url-or-path>\`) and put the clickable link in your reply; skip that in a headless batch.` +
|
|
353
395
|
`\n## The media pipeline — what you ACTUALLY have (don't invent tools)\nThree scale-to-zero fleet workers, ` +
|
|
354
396
|
`nothing else — never offer ComfyUI, SDXL, Juggernaut/RealVis/EpicRealism, FLUX.1-dev/pro, Midjourney or a ` +
|
|
355
|
-
`cloud image API. IMAGES: \`image_generate\` (FLUX.1-schnell) — the quality lever is \`expand: true\` (the ` +
|
|
397
|
+
`cloud image API. IMAGES: \`image_generate\` (on demand; FLUX.1-schnell) — the quality lever is \`expand: true\` (the ` +
|
|
356
398
|
`prompt is rewritten richer) plus a larger \`size\`. LIKENESS: a FACE photo as \`reference\` routes to the ` +
|
|
357
399
|
`identity broker and keeps that exact person; if the result's \`axe_identity\` says \`identity_applied\` false ` +
|
|
358
400
|
`or a weak \`fidelity_note\`, SAY so — never pass a look-alike off as a match. VIDEO: \`video_generate\` ` +
|
|
359
401
|
`(on demand; LTX-Video); \`reference_image\` makes that image the FIRST FRAME. VISION: \`image_analyze\` / ` +
|
|
360
402
|
`\`video_analyze\`; a document (PDF, DOCX, XLSX, PPTX) is read as TEXT, every page.` +
|
|
403
|
+
`\n## Reproducing a web page's design (on demand)\n\`tool_call page_capture\` the reference (exact tokens, outline, screenshot ` +
|
|
404
|
+
`tiles), build from those values, then \`tool_call visual_compare\` reference vs yours and fix the top finding ` +
|
|
405
|
+
`until the mismatch is small. Never from web_fetch text alone.` +
|
|
361
406
|
`\n## Deep research — \`deep_research\` (on demand; cited, multi-source)\nFor a comparison, a state-of-the-art survey ` +
|
|
362
407
|
`or sourced background use \`deep_research\` (planned angles, inline citations); a single lookup is faster ` +
|
|
363
408
|
`with plain \`web_search\`.`)) +
|
|
@@ -555,18 +600,18 @@ export function composeSystemPrompt(o) {
|
|
|
555
600
|
// basePersona carries (decision points and sub-agents included).
|
|
556
601
|
const personaOpts = { ctxTokens: o.ctxTokens, interactive, lean, decisionPoints: o.settings.decisionPoints };
|
|
557
602
|
const identity = custom ? custom + harnessRules(cwd, personaOpts) : basePersona(cwd, personaOpts);
|
|
558
|
-
// Local-skills index (
|
|
559
|
-
// skill_list
|
|
603
|
+
// Local-skills index (names only, 4k cap) — the model must KNOW skills exist without spending a call; what each
|
|
604
|
+
// does comes from skill_list and the body from skill_fetch, on demand like the deferred tools. Skipped in lean (small-ctx) mode like
|
|
560
605
|
// the other heavy sections. Appended exactly like renderToolCatalogue, right before it.
|
|
561
606
|
const skillsIdx = lean ? "" : renderSkillsIndex();
|
|
562
607
|
// `deferredTools`: the same split the Session advertises (tools/deferred.ts) — fixed for the session, so cache-safe.
|
|
563
608
|
const deferred = isFeatureEnabled("deferredTools", o.settings);
|
|
564
609
|
return (identity +
|
|
565
610
|
loadProjectContext(cwd) +
|
|
566
|
-
(lean ? "" : loadStructuredMemories() + loadMemories(cwd)) +
|
|
611
|
+
(lean ? "" : loadStructuredMemories() + loadMemories(cwd, { lessons: o.settings.memory?.promptLessons, indexLineChars: o.settings.memory?.indexLineChars })) +
|
|
567
612
|
renderHarnessContext(cwd) +
|
|
568
613
|
(lean ? LEAN_NOTE : loadHandoff()) +
|
|
569
|
-
(skillsIdx ? `\n\n## Skills installed locally (
|
|
614
|
+
(skillsIdx ? `\n\n## Skills installed locally (names only: skill_list says what each does, skill_fetch <name> loads one, skill_fetch <name> <file_path> reads its references/templates/scripts)\n${skillsIdx}` : "") +
|
|
570
615
|
renderToolCatalogue(sessionTools(o.settings), { lean, deferred }) +
|
|
571
616
|
(interactive ? renderEmbodimentGuide(!!o.settings.computer?.enabled, o.chauffeurReady ?? !!o.settings.mcp) : ""));
|
|
572
617
|
}
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
export const PRODUCT_API_HOST = "api.0perator.co";
|
|
7
7
|
export const LEGACY_API_HOST = "api.axe.onl";
|
|
8
8
|
export const API_HOSTS = [PRODUCT_API_HOST, LEGACY_API_HOST];
|
|
9
|
+
/** Operator Portal's name for the same edge and router (BYO_PRESETS.portal): the gateway as a provider. */
|
|
10
|
+
export const INFERENCE_API_HOST = "inference.0perator.co";
|
|
9
11
|
export const RELAY_URLS = API_HOSTS.map((h) => `wss://${h}/session/ws`);
|
|
10
12
|
/** The host part of a URL for status lines — or the raw string when it does not parse. A scheme-less
|
|
11
13
|
* KODE_RELAY_URL already fails inside RemoteHost's own error loop; a status line must never be the thing
|
package/dist/config/settings.js
CHANGED
|
@@ -8,7 +8,7 @@ import { randomBytes } from "node:crypto";
|
|
|
8
8
|
import { dirname } from "node:path";
|
|
9
9
|
import { operatorPath } from "./home.js";
|
|
10
10
|
import { applyManagedPolicy, loadManagedPolicy } from "./managed.js";
|
|
11
|
-
import { MIN_CONTEXT_PIN, DEFAULT_ACTIVE_MODEL, GATEWAY_BASE, LOCAL_GATEWAY_BASE } from "../router/models.js";
|
|
11
|
+
import { MIN_CONTEXT_PIN, DEFAULT_ACTIVE_MODEL, GATEWAY_BASE, LOCAL_GATEWAY_BASE, gatewayModelFor, isRetiredAuroraBase } from "../router/models.js";
|
|
12
12
|
import { LEGACY_API_HOST, PRODUCT_API_HOST } from "./product-hosts.js";
|
|
13
13
|
/** Resolve an endpoint's bearer from config/env/secret-file (first hit wins); undefined when none set
|
|
14
14
|
* (a local/un-gated endpoint). Keeps the raw key out of settings when `apiKeyEnv`/`apiKeyFile` are used. */
|
|
@@ -42,7 +42,7 @@ const DEFAULTS = {
|
|
|
42
42
|
// Fallback literal for hosts without a running operator-runtime gateway (mobile, browser, dev).
|
|
43
43
|
// Fleet nodes with ~/.operator/runtime/server.json dynamically override this at startup via the
|
|
44
44
|
// gateway-discovery path in cli.tsx — single source of truth, enterprise-safe for both postures.
|
|
45
|
-
aurora: { base:
|
|
45
|
+
aurora: { base: LOCAL_GATEWAY_BASE.replace(/\/v1\/?$/, ""), ctxWindow: 262144, model: "main" }, // == DEFAULT_AURORA_ENDPOINT: the local router's `main`
|
|
46
46
|
// No built-in standby: a deployment names its own in settings.json (endpoints.failover — same model and the
|
|
47
47
|
// same real window as the primary, so a failover holds a live session instead of truncating it).
|
|
48
48
|
},
|
|
@@ -75,12 +75,13 @@ 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" },
|
|
76
76
|
stopOnExit: { searxng: true }, // aurora/autopilot are shared + never stopped; only the SearXNG container is
|
|
77
77
|
},
|
|
78
|
-
// MOA (2026-
|
|
79
|
-
//
|
|
80
|
-
//
|
|
78
|
+
// MOA (2026-11-30, James): the cloud planner holds the planner + composer seat (plans, checks, writes the answer)
|
|
79
|
+
// through the gateway's planner-cloud route; the specialist is the gateway's operator-flash route = the JL1 worker,
|
|
80
|
+
// then the JL2 worker (no cloud leg). Sub-agents use the gateway's subagent pool (JL2 first, then JL1). The previous
|
|
81
|
+
// team's two routes were retired from the gateway 2026-11-30. settings.moa replaces it wholesale.
|
|
81
82
|
moa: {
|
|
82
|
-
planner: { id: "
|
|
83
|
-
specialist: { id: "
|
|
83
|
+
planner: { id: "planner-cloud", endpoint: GATEWAY_BASE, model: "planner-cloud" },
|
|
84
|
+
specialist: { id: "operator-flash" },
|
|
84
85
|
},
|
|
85
86
|
activeModel: DEFAULT_ACTIVE_MODEL, // /model default for a fresh install: the router's operator-flash route (0.1.361; was the Aurora row)
|
|
86
87
|
// Autonomy: everything conservative. keepAwake off; dream OFF and read-mostly with a board-only
|
|
@@ -502,9 +503,23 @@ const CLOUD_FAILOVERS = [
|
|
|
502
503
|
{ name: "axe-cloud", base: `https://${LEGACY_API_HOST}`, model: "main", ctxLimit: 307200, transport: "openai" },
|
|
503
504
|
];
|
|
504
505
|
/** The shipped endpoints.aurora literal (DEFAULTS) — a box that never named its own primary. */
|
|
505
|
-
const DEFAULT_AURORA_ENDPOINT =
|
|
506
|
+
const DEFAULT_AURORA_ENDPOINT = DEFAULTS.endpoints.aurora;
|
|
506
507
|
function isDefaultAuroraLiteral(e) {
|
|
507
|
-
return e.base.replace(/\/+$/, "") === DEFAULT_AURORA_ENDPOINT.base && e.
|
|
508
|
+
return e.base.replace(/\/+$/, "") === DEFAULT_AURORA_ENDPOINT.base && e.ctxWindow === DEFAULT_AURORA_ENDPOINT.ctxWindow && !e.apiKey && !e.apiKeyEnv && !e.apiKeyFile;
|
|
509
|
+
}
|
|
510
|
+
/** A saved endpoints.aurora (or failover) on the retired :8097 moves to the router's `main`, never an error. Its model
|
|
511
|
+
* id stays when the gateway serves it (operator-flash); Aurora's own ids (aurora-code-1, aurora, operator-1m) become
|
|
512
|
+
* `main`. A failover there is dropped: the cloud tier already backs the router. Pure. */
|
|
513
|
+
export function migrateRetiredAurora(s) {
|
|
514
|
+
const { aurora, failover } = s.endpoints;
|
|
515
|
+
if (!isRetiredAuroraBase(aurora.base) && !isRetiredAuroraBase(failover?.base))
|
|
516
|
+
return s;
|
|
517
|
+
const endpoints = { ...s.endpoints };
|
|
518
|
+
if (isRetiredAuroraBase(aurora.base))
|
|
519
|
+
endpoints.aurora = { ...DEFAULT_AURORA_ENDPOINT, model: gatewayModelFor(aurora.model) };
|
|
520
|
+
if (isRetiredAuroraBase(failover?.base))
|
|
521
|
+
delete endpoints.failover;
|
|
522
|
+
return { ...s, endpoints };
|
|
508
523
|
}
|
|
509
524
|
/** The local router's `main` capability (the one door, loopback): the default primary when the owner named none. */
|
|
510
525
|
const ROUTER_MAIN = { name: "main", base: LOCAL_GATEWAY_BASE.replace(/\/v1\/?$/, ""), model: "main", ctxLimit: 262144 };
|
|
@@ -538,10 +553,12 @@ export function buildEndpointChain(s) {
|
|
|
538
553
|
seen.add(key);
|
|
539
554
|
chain.push(ep);
|
|
540
555
|
};
|
|
541
|
-
// 11/25: the built-in primary is the local router's `main` capability
|
|
542
|
-
//
|
|
556
|
+
// 11/25: the built-in primary is the local router's `main` capability (or the model a migrated :8097 setting named);
|
|
557
|
+
// an owner's own endpoints.aurora (or the gateway's discovered port) stays first.
|
|
543
558
|
if (isDefaultAuroraLiteral(aurora))
|
|
544
|
-
add({ ...ROUTER_MAIN });
|
|
559
|
+
add({ ...ROUTER_MAIN, model: aurora.model });
|
|
560
|
+
else if (isRetiredAuroraBase(aurora.base))
|
|
561
|
+
add({ ...ROUTER_MAIN, model: gatewayModelFor(aurora.model) });
|
|
545
562
|
else
|
|
546
563
|
add({ name: "operator-1m", base: aurora.base, model: aurora.model, ctxLimit: aurora.ctxWindow, token: resolveEndpointApiKey(aurora), loopbackAuth: true });
|
|
547
564
|
for (const base of (s.fleet?.auroraNodes ?? []).filter(Boolean)) {
|
|
@@ -596,7 +613,7 @@ export function loadSettings() {
|
|
|
596
613
|
// structuredClone the base so a returned settings object never aliases the module-level DEFAULTS —
|
|
597
614
|
// deepMerge only recurses into keys the override touches, so an untouched nested endpoint would
|
|
598
615
|
// otherwise flow through by reference and a later mutation would corrupt defaults process-wide.
|
|
599
|
-
const merged = applyEnv(deepMerge(structuredClone(DEFAULTS), file));
|
|
616
|
+
const merged = migrateRetiredAurora(applyEnv(deepMerge(structuredClone(DEFAULTS), file)));
|
|
600
617
|
// Managed policy goes LAST: over defaults, the user's file and env. Absent file = identity function.
|
|
601
618
|
const managed = loadManagedPolicy();
|
|
602
619
|
const flywheelPinned = (isPlainObject(file) && isPlainObject(file.selfImprove) && typeof file.selfImprove.flywheel === "boolean") ||
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// renderSkillsIndex is sync so composeSystemPrompt can drop it in without going async.
|
|
4
4
|
import { get_operator_home } from "./home.js";
|
|
5
5
|
const INDEX_CAP = 4000;
|
|
6
|
-
const INDEX_DESC = 57;
|
|
7
6
|
function nodeBuiltins() {
|
|
8
7
|
try {
|
|
9
8
|
const proc = globalThis.process;
|
|
@@ -43,6 +42,33 @@ function field(fm, key) {
|
|
|
43
42
|
const m = fm.match(new RegExp(`^${key}:\\s*(.*)$`, "m"));
|
|
44
43
|
return m ? yamlScalar(m[1]) : "";
|
|
45
44
|
}
|
|
45
|
+
/** `metadata.operator.tags` from a skill's frontmatter, inline (`[a, b]`) or as a `- a` list. Skills written
|
|
46
|
+
* before the key was renamed carry `metadata.hermes`, which is read when `operator` is absent. */
|
|
47
|
+
export function skillTags(raw) {
|
|
48
|
+
const fm = frontmatter(raw);
|
|
49
|
+
const meta = fm && /^metadata:[ \t]*\r?\n((?:[ \t]+.*(?:\r?\n|$))*)/m.exec(fm)?.[1];
|
|
50
|
+
if (!meta)
|
|
51
|
+
return [];
|
|
52
|
+
for (const key of ["operator", "hermes"]) {
|
|
53
|
+
const block = new RegExp(`^([ \\t]+)${key}:[ \\t]*\\r?\\n((?:\\1[ \\t]+.*(?:\\r?\\n|$))*)`, "m").exec(meta)?.[2];
|
|
54
|
+
if (block === undefined)
|
|
55
|
+
continue;
|
|
56
|
+
const m = /^[ \t]+tags:[ \t]*(.*)$/m.exec(block);
|
|
57
|
+
if (!m)
|
|
58
|
+
return [];
|
|
59
|
+
if (m[1].trim().startsWith("["))
|
|
60
|
+
return m[1].trim().replace(/^\[|\]$/g, "").split(",").map(yamlScalar).filter(Boolean);
|
|
61
|
+
const items = [];
|
|
62
|
+
for (const line of block.slice(m.index + m[0].length).split(/\r?\n/).slice(1)) {
|
|
63
|
+
const li = /^[ \t]+-[ \t]+(.*)$/.exec(line);
|
|
64
|
+
if (!li)
|
|
65
|
+
break;
|
|
66
|
+
items.push(yamlScalar(li[1]));
|
|
67
|
+
}
|
|
68
|
+
return items.filter(Boolean);
|
|
69
|
+
}
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
46
72
|
function parseDescription(raw) {
|
|
47
73
|
const fm = frontmatter(raw);
|
|
48
74
|
if (fm) {
|
|
@@ -84,7 +110,7 @@ function readSkill(fs, file) {
|
|
|
84
110
|
catch { /* empty */ }
|
|
85
111
|
const fallback = file.replace(/\\/g, "/").split("/").pop()?.replace(/\.md$/i, "") || "skill";
|
|
86
112
|
const leaf = fallback === "SKILL" ? (file.replace(/\\/g, "/").split("/").slice(-2, -1)[0] || "skill") : fallback;
|
|
87
|
-
return { name: parseName(raw, leaf), description: parseDescription(raw) };
|
|
113
|
+
return { name: parseName(raw, leaf), description: parseDescription(raw), tags: skillTags(raw) };
|
|
88
114
|
}
|
|
89
115
|
export function listLocalSkills() {
|
|
90
116
|
const b = nodeBuiltins();
|
|
@@ -107,7 +133,7 @@ export function listLocalSkills() {
|
|
|
107
133
|
const full = b.path.join(root, ent.name);
|
|
108
134
|
if (ent.isFile() && ent.name.endsWith(".md")) {
|
|
109
135
|
const meta = readSkill(b.fs, full);
|
|
110
|
-
found.push({ name: meta.name, file: full, dir: false, description: meta.description });
|
|
136
|
+
found.push({ name: meta.name, file: full, dir: false, description: meta.description, tags: meta.tags });
|
|
111
137
|
}
|
|
112
138
|
}
|
|
113
139
|
const walk = (dir, depth) => {
|
|
@@ -127,7 +153,7 @@ export function listLocalSkills() {
|
|
|
127
153
|
const skillMd = b.path.join(full, "SKILL.md");
|
|
128
154
|
if (isFile(b.fs, skillMd)) {
|
|
129
155
|
const meta = readSkill(b.fs, skillMd);
|
|
130
|
-
found.push({ name: meta.name, file: skillMd, dir: true, root: full, description: meta.description });
|
|
156
|
+
found.push({ name: meta.name, file: skillMd, dir: true, root: full, description: meta.description, tags: meta.tags });
|
|
131
157
|
}
|
|
132
158
|
else {
|
|
133
159
|
walk(full, depth + 1);
|
|
@@ -160,20 +186,17 @@ export function resolveSkillFile(skillRoot, filePath) {
|
|
|
160
186
|
return null;
|
|
161
187
|
return target;
|
|
162
188
|
}
|
|
189
|
+
/** The installed skills' names, comma-separated, under INDEX_CAP: what each does is skill_list's answer, its body
|
|
190
|
+
* skill_fetch's (the deferred tools' split: names in the prompt, the rest on demand). */
|
|
163
191
|
export function renderSkillsIndex() {
|
|
164
|
-
const
|
|
165
|
-
if (!skills.length)
|
|
166
|
-
return "";
|
|
167
|
-
const lines = [];
|
|
192
|
+
const names = [];
|
|
168
193
|
let used = 0;
|
|
169
|
-
for (const s of
|
|
170
|
-
const
|
|
171
|
-
const line = `${s.name}: ${desc}`;
|
|
172
|
-
const next = used + line.length + (lines.length ? 1 : 0);
|
|
194
|
+
for (const s of listLocalSkills()) {
|
|
195
|
+
const next = used + s.name.length + (names.length ? 2 : 0);
|
|
173
196
|
if (next > INDEX_CAP)
|
|
174
197
|
break;
|
|
175
|
-
|
|
198
|
+
names.push(s.name);
|
|
176
199
|
used = next;
|
|
177
200
|
}
|
|
178
|
-
return
|
|
201
|
+
return names.join(", ");
|
|
179
202
|
}
|
package/dist/engine/agent.js
CHANGED
|
@@ -845,7 +845,7 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
845
845
|
const seen = legFailures.find((l) => l.model === model && l.host === host);
|
|
846
846
|
if (seen)
|
|
847
847
|
return Object.assign(seen, { cause, detail, tries: seen.tries + 1 });
|
|
848
|
-
const leg = { model, host, cause, detail, tries: 1 };
|
|
848
|
+
const leg = { model, host, cause, detail, tries: 1, role: fallback ? "backup" : "primary" };
|
|
849
849
|
legFailures.push(leg);
|
|
850
850
|
return leg;
|
|
851
851
|
};
|
package/dist/engine/aurora.js
CHANGED
|
@@ -204,6 +204,8 @@ const LOOP_MIN_LINE_LEN = 12; // ignore short/structural lines (braces, bullets,
|
|
|
204
204
|
const LOOP_LINE_REPEATS = 6; // same substantial line seen this many times => degenerate
|
|
205
205
|
const LOOP_TAIL = 260; // chars of tail scanned for a back-to-back repeating cycle
|
|
206
206
|
const LOOP_CHECK_EVERY = 200; // only run the scan every ~N new chars (cheap amortization)
|
|
207
|
+
const LOOP_SCAN_TAIL = 4000; // repeats are counted in this much of the tail: a loop piles up there, while a long
|
|
208
|
+
// round that redrafts the same code between fresh work spreads its repeats out
|
|
207
209
|
const RUNAWAY_CHARS = 120_000; // a round is capped at max_tokens (~8k => ~33k chars); far past that is a
|
|
208
210
|
// decode loop or a stream/render duplication, never a real answer — hard stop.
|
|
209
211
|
function hasAlpha(s) {
|
|
@@ -215,8 +217,9 @@ function hasAlpha(s) {
|
|
|
215
217
|
function normLoop(s) {
|
|
216
218
|
return s.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
|
|
217
219
|
}
|
|
218
|
-
/** True once the accumulated text is provably looping — a
|
|
219
|
-
* a short cycle repeated
|
|
220
|
+
/** True once the accumulated text is provably looping — a substantial line or 8-word phrase repeated within the
|
|
221
|
+
* recent tail (exact OR normalized), a short cycle repeated at the very end (raw OR normalized), or a runaway past
|
|
222
|
+
* any sane single-round length. */
|
|
220
223
|
export function isDegenerate(text) {
|
|
221
224
|
if (text.length < LOOP_MIN_LINE_LEN * 3)
|
|
222
225
|
return false;
|
|
@@ -224,10 +227,11 @@ export function isDegenerate(text) {
|
|
|
224
227
|
// or a render/stream duplication. Catches the class even when the repeat isn't a clean line/cycle.
|
|
225
228
|
if (text.length > RUNAWAY_CHARS)
|
|
226
229
|
return true;
|
|
227
|
-
|
|
230
|
+
const recent = text.slice(-LOOP_SCAN_TAIL);
|
|
231
|
+
// (a) a substantial line repeated many times in the recent tail — counted both exact and fuzzy-normalized.
|
|
228
232
|
const exact = new Map();
|
|
229
233
|
const norm = new Map();
|
|
230
|
-
for (const raw of
|
|
234
|
+
for (const raw of recent.split("\n")) {
|
|
231
235
|
const line = raw.trim();
|
|
232
236
|
if (line.length < LOOP_MIN_LINE_LEN || !hasAlpha(line))
|
|
233
237
|
continue;
|
|
@@ -243,9 +247,9 @@ export function isDegenerate(text) {
|
|
|
243
247
|
norm.set(nl, nn);
|
|
244
248
|
}
|
|
245
249
|
}
|
|
246
|
-
// (c) a normalized word n-gram repeated many times
|
|
247
|
-
// that is one long line with trailing junk, so it's neither line- nor
|
|
248
|
-
const words = normLoop(
|
|
250
|
+
// (c) a normalized word n-gram repeated many times in the recent tail — catches a run-together / garbled loop
|
|
251
|
+
// that is one long line with trailing junk, so it's neither line- nor cycle-aligned.
|
|
252
|
+
const words = normLoop(recent).split(" ").filter(Boolean);
|
|
249
253
|
const N = 8;
|
|
250
254
|
if (words.length >= N * LOOP_LINE_REPEATS) {
|
|
251
255
|
const grams = new Map();
|
|
@@ -394,6 +398,11 @@ async function fetchChat(o, body) {
|
|
|
394
398
|
throw e;
|
|
395
399
|
// Only a transient transport error is retryable; a thrown fetch never carries an HTTP status, so
|
|
396
400
|
// classifyFailure returns "transient" here — but gate on it so any non-transient throw fails fast.
|
|
401
|
+
// No headers in time means the server is still queued or reading: sending the same long prompt again starts it over.
|
|
402
|
+
if (e.cause?.code === "UND_ERR_HEADERS_TIMEOUT") {
|
|
403
|
+
lastErr = e;
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
397
406
|
if (classifyFailure(e) !== "transient" || attempt >= FETCH_TRIES - 1) {
|
|
398
407
|
lastErr = e;
|
|
399
408
|
break;
|
|
@@ -533,7 +542,7 @@ async function* streamDeltas(messages, o) {
|
|
|
533
542
|
const wallLeft = wallMs > 0 ? wallMs - (Date.now() - startedAt) : Infinity;
|
|
534
543
|
const budget = Math.min(idleLeft, wallLeft);
|
|
535
544
|
if (budget <= 0)
|
|
536
|
-
throw new Error("
|
|
545
|
+
throw new Error("model stream stalled — deadline exceeded before read (decode wedged; transient)");
|
|
537
546
|
let timer;
|
|
538
547
|
let raced;
|
|
539
548
|
try {
|
|
@@ -548,7 +557,7 @@ async function* streamDeltas(messages, o) {
|
|
|
548
557
|
}
|
|
549
558
|
if (raced === "timeout") {
|
|
550
559
|
void reader.cancel().catch(() => { });
|
|
551
|
-
throw new Error(`
|
|
560
|
+
throw new Error(`model stream stalled — no bytes within ${Math.round(budget / 1000)}s (decode wedged; transient)`);
|
|
552
561
|
}
|
|
553
562
|
const { value, done } = raced;
|
|
554
563
|
lastByteAt = Date.now();
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// FINAL sentence is a first-person announcement of a tool-shaped action, and never on a question, a hand-back
|
|
10
10
|
// ("let me know…"), a deferral ("…in a follow-up"), a contingency ("if that fails, I'll…"), or a summary report.
|
|
11
11
|
// Dependency-free leaf (agent.ts is also bundled for the browser).
|
|
12
|
+
import { discloseModel, shownCause, shownCauses, shownModel, sentence } from "./identity.js";
|
|
12
13
|
/** At most this many continuation nudges per turn — the model can never be forced into an unbounded turn. */
|
|
13
14
|
export const ANNOUNCE_NUDGE_MAX = 2;
|
|
14
15
|
export const ANNOUNCE_NUDGE = "You described the next action but didn't perform it — proceed now: call the tool(s) to do it.";
|
|
@@ -233,6 +234,10 @@ export function stopQuestion(kind, activeTasks) {
|
|
|
233
234
|
}
|
|
234
235
|
/** The owner's one line when the model's fallback answered this turn: what failed, why, and what answered. */
|
|
235
236
|
export function fallbackLine(o) {
|
|
237
|
+
if (!discloseModel()) {
|
|
238
|
+
const why = o.silent ? `the primary model sent ${o.silent} empty replies` : `the primary model's server is failing (${shownCauses((o.cause ?? "").split("; "))})`;
|
|
239
|
+
return `${sentence(why)} — a backup model answered this turn`;
|
|
240
|
+
}
|
|
236
241
|
const what = o.silent ? `${o.from} sent ${o.silent} empty replies` : `${o.from}'s server is failing (${o.cause})`;
|
|
237
242
|
return `${what} — ${o.to} answered this turn`;
|
|
238
243
|
}
|
|
@@ -240,6 +245,10 @@ export function fallbackLine(o) {
|
|
|
240
245
|
* answer never reads as a broken model. */
|
|
241
246
|
export function recoveryLine(s) {
|
|
242
247
|
const n = s.next;
|
|
248
|
+
if (!discloseModel()) {
|
|
249
|
+
const next = n.kind === "leg" ? "reconnecting" : n.kind === "fallback" ? "a backup model takes this turn" : `retrying in ${Math.max(1, Math.round(n.waitMs / 1000))} s`;
|
|
250
|
+
return `${sentence(shownModel(s.failed.model, s.failed.role ?? "primary"))}: ${shownCause(s.failed.cause)} — ${next}`;
|
|
251
|
+
}
|
|
243
252
|
const next = n.kind === "leg" ? `reconnecting via ${n.host}` : n.kind === "fallback" ? `${n.to} takes this turn` : `retrying in ${Math.max(1, Math.round(n.waitMs / 1000))} s`;
|
|
244
253
|
return `${s.failed.model} at ${s.failed.host}: ${s.failed.cause} — ${next}`;
|
|
245
254
|
}
|
|
@@ -250,12 +259,16 @@ export function fallbackNotice(e) {
|
|
|
250
259
|
/** Shown when the primary recovers after the session had been served from a fallback — so a degraded stretch
|
|
251
260
|
* reads as temporary, never a silent permanent downgrade. `primary` is the box that answered (x-0perator-backend). */
|
|
252
261
|
export function primaryRecoveredLine(primary) {
|
|
262
|
+
if (!discloseModel())
|
|
263
|
+
return "✓ The primary model is back — answers are served from it again";
|
|
253
264
|
return `✓ ${primary} is back — answers are served from it again`;
|
|
254
265
|
}
|
|
255
266
|
/** A turn nothing answered — every leg of the owner's model and of its fallback failed, or finished with nothing in the
|
|
256
267
|
* reply: each leg's cause in the order tried, and what the next turn does. `note` stays in history (the next turn's model
|
|
257
268
|
* reads it; the result's stopKind is "unanswered"); `display` is what the owner reads. Never "want me to try again?". */
|
|
258
269
|
export function noAnswer(o) {
|
|
270
|
+
if (!discloseModel())
|
|
271
|
+
return neutralNoAnswer(o);
|
|
259
272
|
const legs = o.tried.map((l) => {
|
|
260
273
|
const more = [l.detail, l.tries > 1 ? `${l.tries} tries` : undefined].filter(Boolean);
|
|
261
274
|
return `- ${l.model} at ${l.host}: ${l.cause}${more.length ? ` (${more.join(", ")})` : ""}`;
|
|
@@ -267,6 +280,29 @@ export function noAnswer(o) {
|
|
|
267
280
|
display: `Nothing answered this turn. I tried, in order:\n${legs}\n${next}${tasks}`,
|
|
268
281
|
};
|
|
269
282
|
}
|
|
283
|
+
/** noAnswer with the serving model confidential: each role's causes, without hosts, upstream ids or a server's words.
|
|
284
|
+
* The note stays neutral too: the next turn's model reads it. */
|
|
285
|
+
function neutralNoAnswer(o) {
|
|
286
|
+
const byLine = new Map();
|
|
287
|
+
for (const l of o.tried) {
|
|
288
|
+
const line = `- ${shownModel(l.model, l.role ?? "primary")}: ${shownCause(l.cause)}`;
|
|
289
|
+
byLine.set(line, (byLine.get(line) ?? 0) + l.tries);
|
|
290
|
+
}
|
|
291
|
+
const legs = [...byLine].map(([line, tries]) => (tries > 1 ? `${line} (${tries} tries)` : line)).join("\n");
|
|
292
|
+
const next = `Next: the next turn tries the primary model first again${o.fallback ? ", then a backup model" : ""}.`;
|
|
293
|
+
const tasks = tasksBlock(o.tasks);
|
|
294
|
+
return {
|
|
295
|
+
note: `[no answer — nothing answered this turn. Tried, in order:\n${legs}\n${next}]${tasks}`,
|
|
296
|
+
display: `Nothing answered this turn. I tried, in order:\n${legs}\n${next}${tasks}`,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
/** The TUI's line when a gateway answered from another box (AgentOpts.onServed, x-0perator-fallback): the selected
|
|
300
|
+
* model is down and another is replying under its name. */
|
|
301
|
+
export function gatewayFallbackLine(o) {
|
|
302
|
+
if (!discloseModel())
|
|
303
|
+
return "⚠ The selected model is unavailable — this answer came from a backup model (gateway fallback)";
|
|
304
|
+
return `⚠ ${o.from} is unavailable — this answer came from ${o.backend ?? "another backend"} (gateway fallback)`;
|
|
305
|
+
}
|
|
270
306
|
/** Append the active task list and a steer to an engine stop note. A yield (sub-agents will resume the turn) gets its
|
|
271
307
|
* own steer: the owner can always take the delegated work back. */
|
|
272
308
|
export function closeStopNote(note, activeTasks, kind) {
|