@0perator/operator 0.2.2-next.1 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/autonomy/index.js +14 -5
- package/dist/autonomy/session-factory.js +7 -1
- package/dist/cli.js +90 -19
- package/dist/config/features.js +7 -0
- package/dist/config/persona.js +6 -3
- package/dist/config/settings.js +17 -0
- package/dist/engine/agent.js +8 -0
- package/dist/engine/aurora.js +51 -12
- package/dist/engine/batch-hints.js +45 -0
- package/dist/engine/batch-scheduler.js +23 -7
- package/dist/engine/compaction.js +8 -1
- package/dist/engine/messages.js +5 -0
- package/dist/engine/native-vision-node.js +88 -10
- package/dist/engine/native-vision.js +25 -7
- package/dist/engine/rolling-summary.js +3 -2
- package/dist/engine/router-adapter.js +1 -0
- package/dist/engine/speed-compaction.js +7 -0
- package/dist/engine/token-meter.js +1 -1
- package/dist/mcp/index.js +2 -2
- package/dist/products/voice.js +44 -9
- package/dist/router/activation.js +132 -0
- package/dist/router/discovery.js +4 -3
- package/dist/router/model-list.js +79 -0
- package/dist/router/models.js +12 -1
- package/dist/router/router.js +0 -11
- package/dist/session.js +239 -33
- package/dist/tools/classes.js +2 -0
- package/dist/tools/deferred.js +11 -6
- package/dist/tools/executor.js +17 -3
- package/dist/tools/micro-assist.js +105 -0
- package/dist/tools/read-ledger.js +4 -0
- package/dist/tools/readonly-shell.js +92 -0
- package/dist/tools/registry.js +68 -61
- package/dist/tools/sandbox.js +1 -1
- package/dist/tools/semantic-compress.js +1 -9
- package/dist/tools/shell-session.js +56 -1
- package/dist/tools/tool-output-spill.js +1 -1
- package/dist/ui/ActivitySpinner.js +2 -2
- package/dist/ui/App.js +8 -8
- package/dist/ui/ApprovalPrompt.js +5 -4
- package/dist/ui/ArtifactPicker.js +4 -3
- package/dist/ui/AuthScreen.js +2 -1
- package/dist/ui/BgPanel.js +6 -6
- package/dist/ui/Composer.js +4 -3
- package/dist/ui/Header.js +2 -2
- package/dist/ui/Markdown.js +50 -77
- package/dist/ui/PlanPane.js +5 -5
- package/dist/ui/QuestionPrompt.js +2 -1
- package/dist/ui/SecretPrompt.js +2 -1
- package/dist/ui/SessionPicker.js +4 -3
- package/dist/ui/SkillFinder.js +3 -2
- package/dist/ui/StatsCard.js +2 -2
- package/dist/ui/StatusRule.js +2 -2
- package/dist/ui/SummaryCard.js +2 -2
- package/dist/ui/Table.js +25 -24
- package/dist/ui/ThinkingSpinner.js +2 -1
- package/dist/ui/ToolBatch.js +3 -3
- package/dist/ui/ToolStep.js +4 -4
- package/dist/ui/Transcript.js +12 -12
- package/dist/ui/UpdatePrompt.js +2 -1
- package/dist/ui/activationFlow.js +126 -0
- package/dist/ui/inline.js +109 -0
- package/dist/ui/modelPicker.js +12 -7
- package/dist/ui/theme.js +4 -0
- package/package.json +1 -1
package/dist/autonomy/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// operator run "<task>"|- [--model ID] [--permissions gated|audit|bypass] [--cwd DIR]
|
|
5
5
|
// [--output text|json|stream-json] [--json] [--log F] [--loop] [--max-turns N]
|
|
6
|
-
// [--max-seconds S] [--keep-awake]
|
|
6
|
+
// [--max-seconds S] [--keep-awake] [--activate]
|
|
7
7
|
// operator loop "<objective>" (alias for `run --loop`)
|
|
8
8
|
// operator board <list|add "<task>"|run|status> [--json] [--max N] [--keep-awake]
|
|
9
9
|
// operator routine <list|run <id>|install <id> [--crontab]|watch> [--keep-awake]
|
|
@@ -22,7 +22,8 @@ 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
|
+
import { modelRegistry, findModel, DEFAULT_ACTIVE_MODEL } from "../router/models.js";
|
|
26
|
+
import { activateForRun, ownerActivation } from "../router/activation.js";
|
|
26
27
|
const AUTONOMY_COMMANDS = new Set(["run", "loop", "board", "routine", "dream", "acp", "media-robot"]);
|
|
27
28
|
/** Split argv (after the subcommand) into --bool flags, --key value pairs, and positionals. `--` ends
|
|
28
29
|
* flag parsing so a task string starting with a dash is preserved. */
|
|
@@ -59,7 +60,7 @@ function parseFlags(args, valued) {
|
|
|
59
60
|
const VALUED = new Set(["log", "max-turns", "max-seconds", "max", "n", "source", "sink", "kind", "model", "permissions", "cwd", "output"]);
|
|
60
61
|
const OUTPUTS = ["text", "json", "stream-json"];
|
|
61
62
|
const PERMISSION_MODES = ["gated", "audit", "bypass"];
|
|
62
|
-
const RUN_USAGE = `usage: operator run "<task>"|- [--model ID] [--permissions gated|audit|bypass] [--cwd DIR] [--output text|json|stream-json] [--max-turns N] [--max-seconds S]`;
|
|
63
|
+
const RUN_USAGE = `usage: operator run "<task>"|- [--model ID] [--permissions gated|audit|bypass] [--cwd DIR] [--output text|json|stream-json] [--max-turns N] [--max-seconds S] [--activate]`;
|
|
63
64
|
/** Validate `operator run` flags. A string is the usage error (exit 2: the command line itself is wrong,
|
|
64
65
|
* the shell convention; 1 stays "the task failed"). */
|
|
65
66
|
export function runFlags(args) {
|
|
@@ -73,7 +74,7 @@ export function runFlags(args) {
|
|
|
73
74
|
const model = f.val.get("model");
|
|
74
75
|
if (model !== undefined && !model)
|
|
75
76
|
return "--model needs a model id";
|
|
76
|
-
return { output, model, permissions: pm, cwd: f.val.get("cwd") };
|
|
77
|
+
return { output, model, permissions: pm, cwd: f.val.get("cwd"), ...(f.bool.has("activate") ? { activate: true } : {}) };
|
|
77
78
|
}
|
|
78
79
|
/** `--model`: a registry id (`moa`, `cortana`, `gpt-oss-20b` …) selects that model — the same as `/model` — so an
|
|
79
80
|
* orchestrated profile like MoA really runs as MoA; any other string is a raw model name on the primary endpoint. */
|
|
@@ -301,7 +302,7 @@ export async function dispatchAutonomy(argv, settings) {
|
|
|
301
302
|
const rf = runFlags(argv.slice(3));
|
|
302
303
|
if (typeof rf === "string")
|
|
303
304
|
return usage(rf);
|
|
304
|
-
const { output, model, permissions: pm, cwd } = rf;
|
|
305
|
+
const { output, model, permissions: pm, cwd, activate } = rf;
|
|
305
306
|
if (cwd !== undefined) {
|
|
306
307
|
try {
|
|
307
308
|
process.chdir(cwd);
|
|
@@ -319,6 +320,14 @@ export async function dispatchAutonomy(argv, settings) {
|
|
|
319
320
|
if (pm)
|
|
320
321
|
settings.permissions = { ...settings.permissions, mode: pm };
|
|
321
322
|
const loop = cmd === "loop" || f.bool.has("loop");
|
|
323
|
+
if (activate) {
|
|
324
|
+
const id = findModel(modelRegistry(settings.models), model ?? settings.activeModel ?? DEFAULT_ACTIVE_MODEL)?.id;
|
|
325
|
+
const failed = id ? await activateForRun(id, ownerActivation(id), (t) => process.stderr.write(t)) : undefined;
|
|
326
|
+
if (failed) {
|
|
327
|
+
process.stderr.write(`operator: ${failed}\n`);
|
|
328
|
+
return 1;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
322
331
|
return withKeepAwake(wantKeepAwake(settings, f), "Operator run", () => runHeadless(settings, prompt, {
|
|
323
332
|
output,
|
|
324
333
|
logFile: f.val.get("log"),
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// session (persona + project context + handoff, the Aurora router, permissions, telemetry) but with NO
|
|
3
3
|
// Ink/TTY dependency, so `operator run/loop/board/dream` construct a real, tool-capable Session the same
|
|
4
4
|
// way the shell does. Kept deliberately small: it composes existing building blocks, it does not fork them.
|
|
5
|
+
import { cachedModelList, listedProfiles } from "../router/model-list.js";
|
|
5
6
|
import { randomUUID } from "node:crypto";
|
|
6
7
|
import { Session } from "../session.js";
|
|
7
8
|
import { AuroraRouter } from "../router/router.js";
|
|
@@ -10,7 +11,7 @@ import { composeSystemPrompt, subagentSystemPrompt } from "../config/persona.js"
|
|
|
10
11
|
import { SUBAGENT_ROLES, SUBAGENT_TOOL_DENY } from "../engine/grandmaster.js";
|
|
11
12
|
import { ensureScratchDir } from "../config/scratch.js";
|
|
12
13
|
import { modelCtxFor, leanHarnessFor, CHAIN_MODEL_ID } from "../router/models.js";
|
|
13
|
-
import { compactionThreshold, compactionCeilingTokens, compactionMinDecodeTps, turnWallClockMs, buildEndpointChain } from "../config/settings.js";
|
|
14
|
+
import { compactionThreshold, compactionCeilingTokens, compactionMinDecodeTps, compactionSpeedTargetTokens, compactionSummaryModel, turnWallClockMs, buildEndpointChain } from "../config/settings.js";
|
|
14
15
|
import { resolveMode } from "../classifier/modes.js";
|
|
15
16
|
import { classifierConfig } from "../classifier/config.js";
|
|
16
17
|
import { setSpeculation, speculationEnabled } from "../engine/aurora.js";
|
|
@@ -64,12 +65,15 @@ export function createAutonomySession(settings, opts = {}) {
|
|
|
64
65
|
temperature: settings.temperature,
|
|
65
66
|
recall: settings.memory.recall,
|
|
66
67
|
models: settings.models,
|
|
68
|
+
reasoningEffort: settings.ui?.effort,
|
|
69
|
+
voice: settings.services?.voice,
|
|
67
70
|
moa: settings.moa,
|
|
68
71
|
classifier: { mode: resolveMode(settings), endpoint: classifierConfig(settings).endpoint },
|
|
69
72
|
fastStart: settings.fastStart,
|
|
70
73
|
frontDoor: settings.frontDoor, // a message the gateway's front door answers (engine/front-door.ts) never runs a full turn
|
|
71
74
|
features: settings.features, // feature flags — registers flag-gated tools (e.g. cloudAgents) only when on
|
|
72
75
|
activeModel: settings.activeModel,
|
|
76
|
+
dynamicModels: () => listedProfiles(cachedModelList(), settings.models), // a saved pick from the gateway's list
|
|
73
77
|
fallbackModel: settings.fallbackModel,
|
|
74
78
|
contextPin: settings.contextPin, // the owner's /context choice (KODE_CONTEXT wins in loadSettings) holds for headless, ACP and delegated runs too
|
|
75
79
|
contextFloor: settings.contextFloor,
|
|
@@ -81,6 +85,8 @@ export function createAutonomySession(settings, opts = {}) {
|
|
|
81
85
|
compactionThreshold: compactionThreshold(settings),
|
|
82
86
|
compactionCeilingTokens: compactionCeilingTokens(settings, "autonomy"), // the owner's compaction.autonomyCeilingTokens / env, else no ceiling — never the interactive ceilingTokens, so a snappy interactive setting can't throttle an unattended build into a compaction-thrash loop
|
|
83
87
|
compactionMinDecodeTps: compactionMinDecodeTps(settings, "autonomy"), // only compaction.autonomyMinDecodeTps; the interactive floor never reaches an unattended run
|
|
88
|
+
compactionSpeedTargetTokens: compactionSpeedTargetTokens(settings),
|
|
89
|
+
compactionSummaryModel: compactionSummaryModel(settings),
|
|
84
90
|
sleepConsolidation: settings.autonomy?.sleepConsolidation, // headless autonomy ("operator run/loop/dream") consolidates on idle too (0.1.177)
|
|
85
91
|
...opts.extra,
|
|
86
92
|
});
|
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,8 @@ import { restKey } from "./ui/Composer.js";
|
|
|
13
13
|
import { mastheadLines } from "./ui/Masthead.js";
|
|
14
14
|
import { shouldPromptPlanExit, resolvePlanExit, PLAN_EXIT_OPTIONS } from "./ui/planExit.js";
|
|
15
15
|
import { initialMode, modePolicy, nextMode, parseMode, planToggleTarget } from "./permissions/modes.js";
|
|
16
|
-
import {
|
|
16
|
+
import { createActivationFlow } from "./ui/activationFlow.js";
|
|
17
|
+
import { FREE_ROW_PRESETS, PROVIDER_ROW_PRESETS, connectedAccounts, isMainModel, mainIds, looksLikeSecret, contextLine, contextPickerView, keyStoredLine, mainPickerView, markModelRows, modelLine, modelPickerView, onceEach, pickerAnswer, providerPickerView, rereadConfirmView, wantsContextStep, wantsRereadConfirm } from "./ui/modelPicker.js";
|
|
17
18
|
import { RemoteHost, toRemoteAgents } from "./remote/host.js";
|
|
18
19
|
import { GrantStore, grantsEnabled } from "./remote/grants.js";
|
|
19
20
|
import { REMOTE_SAFE_COMMANDS, REMOTE_SAFE_COMMAND_NAMES } from "./remote/safe-commands.js";
|
|
@@ -41,7 +42,7 @@ import { seedCalibration } from "./engine/calibration-seed.js";
|
|
|
41
42
|
import { AuroraRouter } from "./router/router.js";
|
|
42
43
|
import { BackgroundAgents } from "./background/index.js";
|
|
43
44
|
import { clearResumable, pickUpSaved, quitSummary, resumeOnReopen, saveResumable, startSaved } from "./background/resume.js";
|
|
44
|
-
import { loadSettings, saveSettings, settingsLoadProblems, compactionThreshold, compactionCeilingTokens, compactionMinDecodeTps, rcAutostart, eagerAuthAtBoot, applySeat, setActiveSeat, buildEndpointChain, parseContextArg, nextContextPin } from "./config/settings.js";
|
|
45
|
+
import { loadSettings, saveSettings, settingsLoadProblems, compactionThreshold, compactionCeilingTokens, compactionMinDecodeTps, compactionSpeedTargetTokens, compactionSummaryModel, rcAutostart, eagerAuthAtBoot, applySeat, setActiveSeat, buildEndpointChain, parseContextArg, nextContextPin } from "./config/settings.js";
|
|
45
46
|
import { resolveSeat } from "./auth/identity.js";
|
|
46
47
|
import { PermissionPolicy } from "./permissions/index.js";
|
|
47
48
|
import { caps } from "./ui/capabilities.js";
|
|
@@ -50,14 +51,15 @@ import { SUBAGENT_ROLES, SUBAGENT_TOOL_DENY, roleCanWrite } from "./engine/grand
|
|
|
50
51
|
import { applyToolsBinPath, operatorPath } from "./config/home.js";
|
|
51
52
|
import { ensureOperatorHome } from "./config/scaffold.js";
|
|
52
53
|
import { listLocalSkills, skillCommand } from "./config/skills-index.js";
|
|
53
|
-
import { modelCtxFor, leanHarnessFor, selectModel, modelRegistry, fmtCtx, shortName, BYO_PRESETS, CHAIN_MODEL_ID } from "./router/models.js";
|
|
54
|
+
import { modelCtxFor, leanHarnessFor, selectModel, modelRegistry, fmtCtx, shortName, BYO_PRESETS, CHAIN_MODEL_ID, EFFORT_LEVELS, parseEffort } from "./router/models.js";
|
|
54
55
|
import { fetchPortalModels, offlineNote, portalIdFor } from "./router/portal.js";
|
|
55
56
|
import { fetchFreeModels } from "./router/free-models.js";
|
|
56
57
|
import { fetchProviderModels } from "./router/provider-models.js";
|
|
58
|
+
import { cachedModelList, fetchModelList, listedProfiles } from "./router/model-list.js";
|
|
57
59
|
import { describeTurnError } from "./engine/net-error.js";
|
|
58
60
|
import { fallbackNotice, gatewayFallbackLine, primaryRecoveredLine, recoveryLine } from "./engine/continuation.js";
|
|
59
61
|
import { shownModelLabel } from "./engine/identity.js";
|
|
60
|
-
import { speedCompactionLine } from "./engine/speed-compaction.js";
|
|
62
|
+
import { speedCompactionLine, speedTargetMissedLine } from "./engine/speed-compaction.js";
|
|
61
63
|
import { hasByoToken, setByoToken } from "./auth/byo.js";
|
|
62
64
|
import { getDiscoveredModels } from "./router/discovery.js";
|
|
63
65
|
import { disposeShellSession, getAgentTasks, registry } from "./tools/registry.js";
|
|
@@ -157,7 +159,7 @@ if (process.argv.includes("--version") || process.argv.includes("-V")) {
|
|
|
157
159
|
}
|
|
158
160
|
if (process.argv.includes("--help")) {
|
|
159
161
|
process.stdout.write(mastheadLines(`v${VERSION}`).join("\n") +
|
|
160
|
-
"\n\nUsage:\n operator start the interactive session\n 0p short for operator (every subcommand works)\n operator --resume resume the last session in this directory\n operator update update to the latest release\n operator update --next install the next prerelease (built from develop); --latest goes back\n operator --fullscreen fullscreen layout: composer pinned to the bottom (or settings.ui.fullscreen)\n operator auth sign in / manage your AXE account\n operator gateway the local model runtime: start | stop | status | health | logs\n operator toolchain the llama-server store: status | verify | install | activate | rollback | migrate | which\n operator run <task>|- run one task headless (--model, --permissions, --output json, --cwd)\n operator selfimprove backfill [--since YYYY-MM-DD] [--dry-run]\n turn looped turns and mentor pairs into lessons\n operator --version print the version\n");
|
|
162
|
+
"\n\nUsage:\n operator start the interactive session\n 0p short for operator (every subcommand works)\n operator --resume resume the last session in this directory\n operator update update to the latest release\n operator update --next install the next prerelease (built from develop); --latest goes back\n operator --fullscreen fullscreen layout: composer pinned to the bottom (or settings.ui.fullscreen)\n operator auth sign in / manage your AXE account\n operator gateway the local model runtime: start | stop | status | health | logs\n operator toolchain the llama-server store: status | verify | install | activate | rollback | migrate | which\n operator run <task>|- run one task headless (--model, --activate, --permissions, --output json, --cwd)\n operator selfimprove backfill [--since YYYY-MM-DD] [--dry-run]\n turn looped turns and mentor pairs into lessons\n operator --version print the version\n");
|
|
161
163
|
process.exit(0);
|
|
162
164
|
}
|
|
163
165
|
// `operator selfimprove backfill …` — offline: folds the flywheel's looped turns and the mentor pairs into the global
|
|
@@ -621,7 +623,7 @@ const HELP = [
|
|
|
621
623
|
" /plan plan mode: read-only research + propose a plan (/plan again to execute)",
|
|
622
624
|
" /mode [auto|manual|plan|gated] set operating mode (autonomous · manual · plan · gated); Shift+Tab cycles the first three",
|
|
623
625
|
" /voice [on|off|status] voice mode: ctrl+t to talk (again to send), the answer is spoken back, esc stops it",
|
|
624
|
-
" /think
|
|
626
|
+
" /think [level] extended reasoning: Operator thinks before answering (/think again = off); a level sets this model's reasoning effort",
|
|
625
627
|
" /ultrathink deep, exhaustive reasoning for hard problems (/ultrathink again = off)",
|
|
626
628
|
" /compact force-compact the conversation now",
|
|
627
629
|
" /remember <note> store a note to recall in future sessions",
|
|
@@ -832,6 +834,9 @@ function Root() {
|
|
|
832
834
|
// Session reads them on every registry access (dynamicModels), so a fetched row is pickable the moment it lands.
|
|
833
835
|
const freeRowsRef = useRef([]);
|
|
834
836
|
const freeStaleRef = useRef(false); // served from the disk cache after a failed read → the rows say " · cached"
|
|
837
|
+
// The gateway's short model list (router/model-list.ts): the last one read until /model reads it again.
|
|
838
|
+
const listRef = useRef(null);
|
|
839
|
+
listRef.current ??= cachedModelList();
|
|
835
840
|
const sessionRef = useRef(null); // lazy — never reconstruct on re-render
|
|
836
841
|
// MCP opts the foreground session into the fleet MCP tool surface (off by default: local tools
|
|
837
842
|
// only, no network fan-out at session start). Background agents stay local-only + lean.
|
|
@@ -839,6 +844,8 @@ function Root() {
|
|
|
839
844
|
sessionRef.current = new Session({
|
|
840
845
|
systemPrompt: SYSTEM_PROMPT,
|
|
841
846
|
thinkMode, // start in the SAME mode the badge shows (settings.ui.reasoning, default "think") — it was only ever the badge that defaulted on
|
|
847
|
+
reasoningEffort: settings.ui?.effort,
|
|
848
|
+
voice: settings.services?.voice,
|
|
842
849
|
router: buildRouter(),
|
|
843
850
|
applyActiveModel: true, // the persisted /model choice still applies with the shell's chain injected
|
|
844
851
|
memory: buildMemory(settings.memory), // provider composite when configured; bare store (byte-identical) otherwise
|
|
@@ -852,11 +859,13 @@ function Root() {
|
|
|
852
859
|
sleepConsolidation: settings.autonomy?.sleepConsolidation, // idle "dreaming": consolidate transcript→memory + run the flywheel while the owner is away (0.1.177 — was never threaded through, so it never fired)
|
|
853
860
|
compactionThreshold: compactionThreshold(settings), // settings.compaction.threshold / KODE_COMPACTION_THRESHOLD; undefined → derived from the served window
|
|
854
861
|
compactionCeilingTokens: compactionCeilingTokens(settings, "interactive"), // the owner's compaction.ceilingTokens / env, else no ceiling. Headless autonomy reads its own (session-factory.ts)
|
|
862
|
+
compactionSpeedTargetTokens: compactionSpeedTargetTokens(settings), // compaction.speedTargetTokens: where that compaction lands
|
|
863
|
+
compactionSummaryModel: compactionSummaryModel(settings), // compaction.summaryModel: the background rolling pass only
|
|
855
864
|
compactionMinDecodeTps: compactionMinDecodeTps(settings, "interactive"), // compaction.minDecodeTps / KODE_COMPACT_MIN_TPS: compact when sustained decode falls under it; undefined → off
|
|
856
865
|
temperature: settings.temperature,
|
|
857
866
|
recall: settings.memory.recall,
|
|
858
867
|
models: MERGED_MODELS, // discovered fleet nodes + settings.models overrides (built-ins in router/models.ts)
|
|
859
|
-
dynamicModels: () => freeRowsRef.current, // the free vendor rows /model fetched this session
|
|
868
|
+
dynamicModels: () => [...listedProfiles(listRef.current ?? [], settings.models), ...freeRowsRef.current], // the gateway's list, and the free vendor rows /model fetched this session
|
|
860
869
|
moa: settings.moa,
|
|
861
870
|
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
|
|
862
871
|
fastStart: settings.fastStart, // fast-model-vs-real-turn race (feature: fastStart, default OFF)
|
|
@@ -989,6 +998,8 @@ function Root() {
|
|
|
989
998
|
toolAllow: SUBAGENT_ROLES[role]?.tools,
|
|
990
999
|
toolDeny: SUBAGENT_TOOL_DENY,
|
|
991
1000
|
models: settings.models,
|
|
1001
|
+
reasoningEffort: settings.ui?.effort,
|
|
1002
|
+
voice: settings.services?.voice,
|
|
992
1003
|
unattended: true, // nobody watches a background agent turn by turn: a real loop hard-stops (10/31: 54 rounds of warnings)
|
|
993
1004
|
router: new AuroraRouter(buildEndpointChain(settings)), // same multi-tier self-heal chain as the foreground
|
|
994
1005
|
memory: buildMemory(settings.memory), // sub-agents share the same provider-layer memory surface
|
|
@@ -1533,6 +1544,7 @@ function Root() {
|
|
|
1533
1544
|
setPhase("sent");
|
|
1534
1545
|
},
|
|
1535
1546
|
onSpeedCompaction: (e) => sys(speedCompactionLine(e)),
|
|
1547
|
+
onSpeedTargetMissed: (e) => sys(speedTargetMissedLine(e)),
|
|
1536
1548
|
onCompactionStart: ({ before }) => {
|
|
1537
1549
|
compactRef.current = { before, startedAt: Date.now(), ring: [], wrote: 0 };
|
|
1538
1550
|
setStepLabel("compacting context");
|
|
@@ -2276,8 +2288,8 @@ function Root() {
|
|
|
2276
2288
|
const pickerSeqRef = useRef(0);
|
|
2277
2289
|
const openPicker = useCallback((question, rows, entries, onAnswer) => {
|
|
2278
2290
|
const seq = ++pickerSeqRef.current;
|
|
2279
|
-
const pending = (shown, from) => ({
|
|
2280
|
-
question,
|
|
2291
|
+
const pending = (shown, from, asked = question) => ({
|
|
2292
|
+
question: asked,
|
|
2281
2293
|
options: shown,
|
|
2282
2294
|
key: seq, // a redraw of this open keeps the owner's place (QuestionPrompt.redrawState)
|
|
2283
2295
|
resolve: (answer, index) => {
|
|
@@ -2289,9 +2301,30 @@ function Root() {
|
|
|
2289
2301
|
},
|
|
2290
2302
|
});
|
|
2291
2303
|
setModelPicker(pending(rows, entries));
|
|
2292
|
-
return (shown, from) => { if (pickerSeqRef.current === seq)
|
|
2293
|
-
setModelPicker(pending(shown, from)); };
|
|
2304
|
+
return (shown, from, asked) => { if (pickerSeqRef.current === seq)
|
|
2305
|
+
setModelPicker(pending(shown, from, asked)); };
|
|
2294
2306
|
}, []);
|
|
2307
|
+
// /model on a row with `activation`: the flow draws in the same picker slot.
|
|
2308
|
+
const activationRef = useRef(null);
|
|
2309
|
+
activationRef.current ??= createActivationFlow({
|
|
2310
|
+
sys: (line) => sys(line),
|
|
2311
|
+
current: () => session.currentModel(),
|
|
2312
|
+
idle: () => statusRef.current === "idle",
|
|
2313
|
+
open: (question, rows, entries, onAnswer) => {
|
|
2314
|
+
const redraw = openPicker(question, rows, entries, (a) => { if ("entry" in a)
|
|
2315
|
+
onAnswer(a.entry); });
|
|
2316
|
+
const seq = pickerSeqRef.current;
|
|
2317
|
+
const isOpen = () => pickerSeqRef.current === seq;
|
|
2318
|
+
return {
|
|
2319
|
+
update: (q, r, e) => redraw(r, e, q),
|
|
2320
|
+
isOpen,
|
|
2321
|
+
close: () => { if (isOpen()) {
|
|
2322
|
+
pickerSeqRef.current++;
|
|
2323
|
+
setModelPicker(null);
|
|
2324
|
+
} },
|
|
2325
|
+
};
|
|
2326
|
+
},
|
|
2327
|
+
});
|
|
2295
2328
|
// "Context for this session": bare /context, and the step after a /model pick whose window beats the smallest pin.
|
|
2296
2329
|
const openContextPicker = useCallback(() => {
|
|
2297
2330
|
const { rows, pins } = contextPickerView(session.contextPin(), session.servedContext());
|
|
@@ -2326,6 +2359,13 @@ function Root() {
|
|
|
2326
2359
|
freeStaleRef.current = stale;
|
|
2327
2360
|
return changed;
|
|
2328
2361
|
}, []);
|
|
2362
|
+
const refreshModelList = useCallback(async () => {
|
|
2363
|
+
const list = await fetchModelList({ cloud: settings.endpoints.cloudFailover !== false });
|
|
2364
|
+
if (!list || JSON.stringify(list) === JSON.stringify(listRef.current))
|
|
2365
|
+
return false;
|
|
2366
|
+
listRef.current = list;
|
|
2367
|
+
return true;
|
|
2368
|
+
}, []);
|
|
2329
2369
|
const handleSlash = useCallback(async (cmd) => {
|
|
2330
2370
|
const [name, ...rest] = cmd.slice(1).split(/\s+/);
|
|
2331
2371
|
const arg = rest.join(" ").trim();
|
|
@@ -2397,8 +2437,14 @@ function Root() {
|
|
|
2397
2437
|
sys(note); });
|
|
2398
2438
|
return chosen;
|
|
2399
2439
|
};
|
|
2440
|
+
// A row with an activation command is switched to only once that command says the model is served.
|
|
2441
|
+
const activate = (id, then) => {
|
|
2442
|
+
const target = looksLikeSecret(id) ? undefined : s.resolveSelection(id);
|
|
2443
|
+
return !!target && activationRef.current.pick(target.id, then);
|
|
2444
|
+
};
|
|
2400
2445
|
if (arg) {
|
|
2401
|
-
apply(arg);
|
|
2446
|
+
if (!activate(arg, () => { apply(arg); }))
|
|
2447
|
+
apply(arg);
|
|
2402
2448
|
break;
|
|
2403
2449
|
}
|
|
2404
2450
|
// Each account is looked up at most once for this open, and only when a row needs it (a keychain miss spawns
|
|
@@ -2446,8 +2492,10 @@ function Root() {
|
|
|
2446
2492
|
const active = s.currentModel();
|
|
2447
2493
|
// Two screens (0.1.361): the main rows + "More models…", which opens every other row and the connect action.
|
|
2448
2494
|
const view = (more) => {
|
|
2449
|
-
const
|
|
2450
|
-
|
|
2495
|
+
const listed = listRef.current ?? [];
|
|
2496
|
+
const main = mainIds(s.modelRegistry(), listed.map((m) => m.id));
|
|
2497
|
+
const o = { active, main, down: new Set(listed.filter((m) => m.down).map((m) => m.id)), servedCtx: s.servedContext(), staleFree: freeStaleRef.current, cost: (m) => costOf(m.id), cols: termCols() };
|
|
2498
|
+
return more ? modelPickerView(s.modelRegistry().filter((m) => !isMainModel(m, main)), o) : mainPickerView(s.modelRegistry(), o);
|
|
2451
2499
|
};
|
|
2452
2500
|
let cat;
|
|
2453
2501
|
let refresh = () => { };
|
|
@@ -2456,7 +2504,9 @@ function Root() {
|
|
|
2456
2504
|
let onScreen = first.rows;
|
|
2457
2505
|
const redraw = openPicker(more ? "More models" : "Select a model", first.rows, first.entries, (a) => {
|
|
2458
2506
|
if ("typed" in a) {
|
|
2459
|
-
|
|
2507
|
+
const typed = a.typed;
|
|
2508
|
+
if (!activate(typed, () => { apply(typed); }))
|
|
2509
|
+
apply(typed);
|
|
2460
2510
|
return;
|
|
2461
2511
|
} // the typed-id escape: an explicit id skips the context step
|
|
2462
2512
|
if (a.entry.kind === "more") {
|
|
@@ -2468,8 +2518,10 @@ function Root() {
|
|
|
2468
2518
|
return;
|
|
2469
2519
|
}
|
|
2470
2520
|
const id = a.entry.profile.id;
|
|
2471
|
-
const go = () => { const chosen = apply(id); if (chosen && wantsContextStep(chosen, s.servedContext()))
|
|
2521
|
+
const go = (watched = true) => { const chosen = apply(id); if (watched && chosen && wantsContextStep(chosen, s.servedContext()))
|
|
2472
2522
|
openContextPicker(); };
|
|
2523
|
+
if (activate(id, go))
|
|
2524
|
+
return;
|
|
2473
2525
|
// A pick that costs a long re-read asks once, with the price: switch now, compact here first, or stay.
|
|
2474
2526
|
const cost = costOf(id);
|
|
2475
2527
|
if (!cost || !wantsRereadConfirm(cost)) {
|
|
@@ -2488,7 +2540,7 @@ function Root() {
|
|
|
2488
2540
|
if (c.entry === "switch")
|
|
2489
2541
|
go();
|
|
2490
2542
|
else if (c.entry === "compact") {
|
|
2491
|
-
flow.afterCompaction(go);
|
|
2543
|
+
flow.afterCompaction(() => go());
|
|
2492
2544
|
void slashRef.current("/compact");
|
|
2493
2545
|
} // compacts on the cache-warm model, then switches — before anything waiting can start a turn
|
|
2494
2546
|
else
|
|
@@ -2515,6 +2567,10 @@ function Root() {
|
|
|
2515
2567
|
} });
|
|
2516
2568
|
void refreshFreeRows(isConnected).then((changed) => { if (changed)
|
|
2517
2569
|
refresh(); });
|
|
2570
|
+
void refreshModelList().then((changed) => { if (changed) {
|
|
2571
|
+
refresh();
|
|
2572
|
+
remoteRef.current?.setCapabilities(buildCapabilities());
|
|
2573
|
+
} });
|
|
2518
2574
|
break;
|
|
2519
2575
|
}
|
|
2520
2576
|
case "context":
|
|
@@ -3111,7 +3167,22 @@ function Root() {
|
|
|
3111
3167
|
break;
|
|
3112
3168
|
}
|
|
3113
3169
|
case "think": {
|
|
3114
|
-
const
|
|
3170
|
+
const word = arg.trim().toLowerCase();
|
|
3171
|
+
if (word && word !== "on" && word !== "off") {
|
|
3172
|
+
const level = parseEffort(word);
|
|
3173
|
+
if (!level) {
|
|
3174
|
+
sys(`reasoning effort is ${s.currentReasoningEffort() ?? "the model's default"} — usage: /think ${EFFORT_LEVELS.join("|")}|default`);
|
|
3175
|
+
break;
|
|
3176
|
+
}
|
|
3177
|
+
const effort = s.setReasoningEffort(level);
|
|
3178
|
+
try {
|
|
3179
|
+
saveSettings({ ui: { ...loadSettings().ui, effort } });
|
|
3180
|
+
}
|
|
3181
|
+
catch { /* the session keeps it */ }
|
|
3182
|
+
sys(`reasoning effort for ${s.currentModel()}: ${s.currentReasoningEffort() ?? "the model's default"}. It applies from the next request; a model that writes it into its prompt re-reads the conversation once.`);
|
|
3183
|
+
break;
|
|
3184
|
+
}
|
|
3185
|
+
const on = word ? word === "on" : s.currentThinkMode() !== "think";
|
|
3115
3186
|
s.setThinkMode(on ? "think" : "off");
|
|
3116
3187
|
setThinkMode(on ? "think" : "off");
|
|
3117
3188
|
sys((on ? "✲ think ON — Operator reasons (shown dimmed) before answering. /think again to turn off."
|
|
@@ -3541,7 +3612,7 @@ function Root() {
|
|
|
3541
3612
|
submitRef.current(arg);
|
|
3542
3613
|
}
|
|
3543
3614
|
}
|
|
3544
|
-
}, [exit, sys, bg, authUser, approval, settleApproval, settleQuestion, applyMode, applyContext, openPicker, openContextPicker, refreshFreeRows, remoteCommand, remotePrompt]);
|
|
3615
|
+
}, [exit, sys, bg, authUser, approval, settleApproval, settleQuestion, applyMode, applyContext, openPicker, openContextPicker, refreshFreeRows, refreshModelList, remoteCommand, remotePrompt]);
|
|
3545
3616
|
const onSubmit = useCallback((text) => {
|
|
3546
3617
|
// A submit that arrives while a turn runs (a remote follower's prompt or command, a wake) takes the same path the
|
|
3547
3618
|
// keyboard does: a command by its mid-turn class, text as a steer — a second Session.send would throw mid-turn.
|
package/dist/config/features.js
CHANGED
|
@@ -77,6 +77,13 @@ export const FEATURES = {
|
|
|
77
77
|
default: false,
|
|
78
78
|
description: "Add craft_create (a second way to make an artifact; artifact_create is the stock one). The artifact library tools are always on",
|
|
79
79
|
},
|
|
80
|
+
/** micro assist (tools/micro-assist.ts): a large un-ranged file_read or long command output comes back as the `micro`
|
|
81
|
+
* MCP server's ranked verbatim extract plus a spill path, and Scribe is searched once for the first task. Default OFF
|
|
82
|
+
* until the reader passes its recall gate. Needs MCP on with the `micro` server; without it nothing changes. */
|
|
83
|
+
microAssist: {
|
|
84
|
+
default: false,
|
|
85
|
+
description: "Large reads and long output come back as a micro extract plus a spill path; one Scribe search for the first task",
|
|
86
|
+
},
|
|
80
87
|
};
|
|
81
88
|
/** Env var that overrides one feature: camelCase → UPPER_SNAKE, e.g. classifierGate → KODE_FEATURE_CLASSIFIER_GATE. */
|
|
82
89
|
export function featureEnvName(name) {
|
package/dist/config/persona.js
CHANGED
|
@@ -371,6 +371,8 @@ export function basePersona(_cwd = process.cwd(), opts = {}) {
|
|
|
371
371
|
`\nScratch dir (also \`$OPERATOR_SCRATCH\` in every shell) — temporary scripts, probe ` +
|
|
372
372
|
`output, downloads to inspect, intermediate files: ALWAYS here, never /tmp and never the repo root. It is ` +
|
|
373
373
|
`git-ignored and swept after a week, so nothing you keep belongs in it; name files \`<subject>-<thing>\`.` +
|
|
374
|
+
(typeof process !== "undefined" && process.platform === "darwin"
|
|
375
|
+
? `\nmacOS: BSD tools (no \`grep -P\`); Mac ssh is zsh: quote globs.` : "") +
|
|
374
376
|
ctxLine +
|
|
375
377
|
`\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
378
|
`the context window above if asked. What you may say about the model underneath is set by the "Active model" section at the end ` +
|
|
@@ -440,14 +442,14 @@ export function basePersona(_cwd = process.cwd(), opts = {}) {
|
|
|
440
442
|
`intent; a failed step is cancelled and replaced by a revised one. The owner watches the list live, so never ` +
|
|
441
443
|
`restate the numbered plan in prose round after round — narrate only what you are doing now.`) +
|
|
442
444
|
`\n## Parallel tool calls\nWhen the next few steps are INDEPENDENT, issue them as multiple tool calls in a ` +
|
|
443
|
-
`SINGLE message so they run
|
|
445
|
+
`SINGLE message so they run together — independent bash commands included. ` +
|
|
444
446
|
`Serialize only when one call's output feeds the next. Read several files with ONE read_files call.` +
|
|
445
447
|
`\n## Long-running commands\nBuilds, servers, watchers, test suites and batches go to shell_background from ` +
|
|
446
448
|
`the start; a finished job announces itself at your next turn, so do NOT poll bash_output in a loop.` +
|
|
447
449
|
`\n## Downloading files\nUse download_file (on demand), never curl/wget, and NEVER say a file is downloaded until its ` +
|
|
448
450
|
`completion notice says so; a 0-byte file, an HTML page with an .iso/.zip name or a failed hash is a FAILURE ` +
|
|
449
451
|
`to report and fix, not to retry blindly.` +
|
|
450
|
-
`\n## Finding things\nContent: the search tool scoped to a directory
|
|
452
|
+
`\n## Finding things\nContent: the search tool scoped to a directory, then file_read, not cat/sed. Never bash \`grep -r\` / \`rg\` / ` +
|
|
451
453
|
`\`find ~/ | grep\` over $HOME or / (it refuses those roots because they wedge the TUI for minutes). Check the ` +
|
|
452
454
|
`2-3 most likely directories first, batched in ONE message.\nA FLEET HOST / server name (acropolis, jl1, jla, …): ` +
|
|
453
455
|
`\`~/.ssh/config\` + \`ssh <name> 'hostname; uptime'\`, then \`gh repo view axetechnologies/<name>\`, then fleet ` +
|
|
@@ -496,7 +498,8 @@ export function harnessRules(cwd = process.cwd(), opts = {}) {
|
|
|
496
498
|
// (10/31: on JL2 Cortana never saw the rule). Static per session — cache-safe.
|
|
497
499
|
function subagentsSection(opts) {
|
|
498
500
|
return opts.interactive
|
|
499
|
-
? `\n## Sub-agents — you stay the lead\
|
|
501
|
+
? `\n## Sub-agents — you stay the lead\nDelegate to finish sooner: when work splits into independent parts, ` +
|
|
502
|
+
`call spawn_agent in the SAME round ` +
|
|
500
503
|
`you decide to (never announce it without the call; its description carries the brief format and rules) and ` +
|
|
501
504
|
`tell the owner who you are sending and why. While they run, do what does not depend on them and never redo a ` +
|
|
502
505
|
`step an agent is still working on. When a report or a STUCK notice arrives, check what the agent produced ` +
|
package/dist/config/settings.js
CHANGED
|
@@ -175,6 +175,13 @@ function readSettingsFile(path) {
|
|
|
175
175
|
return { kind: "broken", reason: `the top level is ${shapeOf(value)}, not an object` };
|
|
176
176
|
return { kind: "ok", value, text };
|
|
177
177
|
}
|
|
178
|
+
/** The settings.models rows exactly as the owner's file has them — no built-ins, env, managed policy or gateway rows.
|
|
179
|
+
* An unreadable file has none. */
|
|
180
|
+
export function ownerModelEntries() {
|
|
181
|
+
const read = readSettingsFile(settingsPath());
|
|
182
|
+
const models = read.kind === "ok" ? read.value.models : undefined;
|
|
183
|
+
return Array.isArray(models) ? models.filter(isPlainObject) : [];
|
|
184
|
+
}
|
|
178
185
|
const lastGoodPath = (path) => `${path}.last-good`;
|
|
179
186
|
/** Write `text` to `path` atomically: a temp file in the same directory, fsync, rename. A symlinked settings file
|
|
180
187
|
* keeps its link: the write lands on the target. */
|
|
@@ -410,6 +417,16 @@ export function compactionMinDecodeTps(s, mode = "interactive") {
|
|
|
410
417
|
const v = mode === "autonomy" ? s.compaction?.autonomyMinDecodeTps : s.compaction?.minDecodeTps;
|
|
411
418
|
return typeof v === "number" && Number.isFinite(v) && v > 0 ? v : undefined;
|
|
412
419
|
}
|
|
420
|
+
/** The request size a speed-triggered compaction must land at or under (`compaction.speedTargetTokens`), or undefined. */
|
|
421
|
+
export function compactionSpeedTargetTokens(s) {
|
|
422
|
+
const v = s.compaction?.speedTargetTokens;
|
|
423
|
+
return typeof v === "number" && Number.isFinite(v) && v >= 8000 ? Math.floor(v) : undefined;
|
|
424
|
+
}
|
|
425
|
+
/** The /model id the background rolling summary runs on (`compaction.summaryModel`), or undefined (the live endpoint). */
|
|
426
|
+
export function compactionSummaryModel(s) {
|
|
427
|
+
const v = s.compaction?.summaryModel;
|
|
428
|
+
return typeof v === "string" && v.trim() ? v.trim() : undefined;
|
|
429
|
+
}
|
|
413
430
|
/** The per-turn WALL-CLOCK budget (ms) to hand runTurn — the only bound on TIME, the brake on hour-long turns.
|
|
414
431
|
* settings.autonomy.maxTurnWallClockSec, env KODE_TURN_MAX_WALLCLOCK_SEC wins; 0/unset ⇒ undefined (no cap).
|
|
415
432
|
* Resolved here so headless/autonomy (and any surface that opts in) read it identically. */
|
package/dist/engine/agent.js
CHANGED
|
@@ -36,6 +36,7 @@ import { FILE_WRITE as MUTATING_TOOLS, POLLERS as LOOP_GUARD_EXEMPT, STATUS_TOOL
|
|
|
36
36
|
/** The executor's identical-call refusal, exactly (tools/executor.ts): a tool's own output that merely starts with
|
|
37
37
|
* "loop guard:" (a log, a grep of this source) is real output, not a refusal to be counted and replaced. */
|
|
38
38
|
export const EXECUTOR_REPEAT_REFUSAL = /^loop guard: "[^"]+" called \d+x with identical args this turn/;
|
|
39
|
+
import { batchHints } from "./batch-hints.js";
|
|
39
40
|
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, needsDeliverFindings, DELIVER_FINDINGS_NUDGE, EMPTY_REPLY_NUDGE, fallbackLine, noAnswer, closeStopNote, stopQuestion, stripEngineEcho } from "./continuation.js";
|
|
40
41
|
// Poll/status tools are meant to be called repeatedly while waiting on async work — NEVER a spin, so the
|
|
41
42
|
// loop guard skips them entirely (agent_status polls sub-agents, bash_output polls a background job).
|
|
@@ -795,6 +796,7 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
795
796
|
// Delegation-by-prose guard applies only where spawn_agent is actually offered (interactive foreground; a bg
|
|
796
797
|
// sub-agent has no spawn tool and must not be told to call one).
|
|
797
798
|
const hasSpawnTool = (opts.toolSchemas ?? []).some((s) => s?.function?.name === "spawn_agent");
|
|
799
|
+
const widen = opts.batchHints ? batchHints(hasSpawnTool) : undefined;
|
|
798
800
|
let announceNudges = 0;
|
|
799
801
|
let selfDialogueNudges = 0; // owner-facing: replies that react to a speaker who did not speak (continuation.ts)
|
|
800
802
|
let closingNudged = false; // owner-facing: one nudge to close with status + a steering question instead of a bare stop
|
|
@@ -1280,6 +1282,7 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
1280
1282
|
loopbackAuth: endpoint.loopbackAuth,
|
|
1281
1283
|
transport: endpoint.transport,
|
|
1282
1284
|
chatPath: endpoint.chatPath,
|
|
1285
|
+
...endpoint.reasoning,
|
|
1283
1286
|
maxTokens,
|
|
1284
1287
|
// Empty-retry perturbation: a greedy (temp 0) empty is deterministic, so the retry must change the
|
|
1285
1288
|
// sampling to escape it. One-shot — consumed right after this call so the normal path stays greedy.
|
|
@@ -1527,6 +1530,7 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
1527
1530
|
loopbackAuth: endpoint.loopbackAuth,
|
|
1528
1531
|
transport: endpoint.transport,
|
|
1529
1532
|
chatPath: endpoint.chatPath,
|
|
1533
|
+
...endpoint.reasoning,
|
|
1530
1534
|
maxTokens: clampMaxTokens(retryMessages, compactionOptsFor(endpoint), opts.maxTokens ?? 8192),
|
|
1531
1535
|
temperature: opts.temperature,
|
|
1532
1536
|
tools: opts.toolSchemas,
|
|
@@ -1548,6 +1552,7 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
1548
1552
|
// paths — a cut-off tool call and a cut-off text answer both carry stopReason "length".
|
|
1549
1553
|
if (response.stopReason === "length")
|
|
1550
1554
|
truncatedThisTurn = true;
|
|
1555
|
+
conversation.pendingReasoning = endpoint.reasoning?.preserveThinking ? response.reasoningContent : undefined;
|
|
1551
1556
|
// LOCAL truncated-tool-call recovery (_ai-docs 2026-10-19): a settled tool-calling round can carry a
|
|
1552
1557
|
// call whose arguments were cut off mid-JSON — stopReason is undefined here (a tool-calling turn is
|
|
1553
1558
|
// legitimately terminal), so the length latch above never saw it. The OLD engine dispatched the
|
|
@@ -1828,6 +1833,9 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
1828
1833
|
}
|
|
1829
1834
|
if (stalledNotConverging(response.toolCalls, toolMsgs, response.content))
|
|
1830
1835
|
return stopTurn(notConvergingNote(response.toolCalls), "stopped", rounds + 1);
|
|
1836
|
+
const hint = widen?.(response.toolCalls);
|
|
1837
|
+
if (hint)
|
|
1838
|
+
engineUser(hint);
|
|
1831
1839
|
continue;
|
|
1832
1840
|
}
|
|
1833
1841
|
// No structured tool_calls — check for text-encoded ones before treating this as final.
|
package/dist/engine/aurora.js
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
// runtime cycle. Reused to retry a transient transport drop at the fetch layer (see fetchChat).
|
|
3
3
|
import { classifyFailure, backoffMs, sleep } from "./selfheal.js";
|
|
4
4
|
import { globalTokenMeter } from "./token-meter.js";
|
|
5
|
+
/** What an endpoint refused lately (a route's fallback leg may run another template or build): not sent there again
|
|
6
|
+
* for ten minutes, then tried again, since the first leg may be back. */
|
|
7
|
+
const REFUSAL_TTL_MS = 10 * 60_000;
|
|
8
|
+
const recent = (m, key) => Date.now() - (m.get(key) ?? -REFUSAL_TTL_MS) < REFUSAL_TTL_MS;
|
|
9
|
+
const refusedVideo = new Map();
|
|
10
|
+
export function resetVideoRejections() { refusedVideo.clear(); }
|
|
11
|
+
const refusedEfforts = new Map();
|
|
12
|
+
const effortKey = (o) => `${o.base}|${o.model}|${o.reasoningEffort}`;
|
|
13
|
+
export function resetEffortRejections() { refusedEfforts.clear(); }
|
|
5
14
|
const _endpointGates = new Map();
|
|
6
15
|
/** The gate's key: one queue per (base, model). No model = the base alone (the pre-10/31 key). */
|
|
7
16
|
export function gateKey(base, model) { return model ? `${base}#${model}` : base; }
|
|
@@ -320,8 +329,16 @@ export function requestBody(messages, o, stream) {
|
|
|
320
329
|
// contract we should bank on.
|
|
321
330
|
const llama = o.transport !== "openai";
|
|
322
331
|
const cacheKnobs = shipsLlamaCacheKnobs(o.base, o.transport); // KV-reuse + speculation-off: llama.cpp semantics, ours to send
|
|
332
|
+
const keep = o.preserveThinking === true && cacheKnobs;
|
|
333
|
+
const kwargs = llama ? { ...(o.thinking ? { enable_thinking: true } : {}), ...(keep ? { preserve_thinking: true } : {}) } : keep ? { preserve_thinking: true } : {};
|
|
323
334
|
return JSON.stringify({
|
|
324
|
-
model: o.model,
|
|
335
|
+
model: o.model, stream,
|
|
336
|
+
messages: messages.map((m) => {
|
|
337
|
+
if (!m.reasoning)
|
|
338
|
+
return m;
|
|
339
|
+
const { reasoning, ...rest } = m;
|
|
340
|
+
return keep ? { ...rest, reasoning_content: reasoning } : rest;
|
|
341
|
+
}),
|
|
325
342
|
// Ask the server for an exact usage report on the final SSE chunk. Without this, llama.cpp omits
|
|
326
343
|
// `timings` on rounds that end in tool_calls (verified live), so the token meter under-counts a
|
|
327
344
|
// tool-heavy turn to near-zero and falls back to the chars/4 estimate. include_usage yields exact
|
|
@@ -342,7 +359,8 @@ export function requestBody(messages, o, stream) {
|
|
|
342
359
|
// 2026-10-19: request progress for EVERY llama-dialect stream (was cacheKnobs-only). A loopback Aurora /
|
|
343
360
|
// fleet node that doesn't ship the full cache knobs still benefits — the progress chunks keep the idle-gap
|
|
344
361
|
// fed through a long cold prefill instead of looking wedged. A server that ignores the field is harmless.
|
|
345
|
-
|
|
362
|
+
// 2026-12-03: our own gateway on the OpenAI wire too (cacheKnobs covers it and every llama endpoint).
|
|
363
|
+
...(stream && cacheKnobs ? { return_progress: true } : {}),
|
|
346
364
|
// GW-26 (2026-11-25): no per-request speculative field by default, tool rounds included — the server's
|
|
347
365
|
// --spec-type decides. ngram-mod drafts are verified by the target model, so the output is exact (the 27B dense model,
|
|
348
366
|
// 6 prompts: identical sha256 with and without it; a code edit 11.1 → 52-56 tok/s). The old tool-round
|
|
@@ -356,7 +374,9 @@ export function requestBody(messages, o, stream) {
|
|
|
356
374
|
// /think: re-enable the model's native reasoning for THIS request, overriding the server's
|
|
357
375
|
// enable_thinking:false default (set for speed). Verified this per-request override works on the
|
|
358
376
|
// Aurora build; reasoning arrives as reasoning_content and renders dimmed.
|
|
359
|
-
...(o.thinking
|
|
377
|
+
...(o.thinking && !llama ? { enable_thinking: true } : {}),
|
|
378
|
+
...(Object.keys(kwargs).length ? { chat_template_kwargs: kwargs } : {}),
|
|
379
|
+
...(o.reasoningEffort && !recent(refusedEfforts, effortKey(o)) ? { reasoning_effort: o.reasoningEffort } : {}),
|
|
360
380
|
// NO repeat/presence/frequency penalty knobs — SPEC §1: they break tool-calling.
|
|
361
381
|
});
|
|
362
382
|
}
|
|
@@ -464,12 +484,13 @@ export function createDecodeMonitor(floorTps = DECODE_FLOOR_TPS, windowTokens =
|
|
|
464
484
|
* The encoder is node-only (it reads the files), so it loads only when a message carries an image, through a
|
|
465
485
|
* variable specifier so the browser bundle never follows it. */
|
|
466
486
|
const nodeImport = (m) => import(m);
|
|
467
|
-
async function wireMessages(messages) {
|
|
487
|
+
async function wireMessages(messages, framesOnly) {
|
|
468
488
|
if (!messages.some((m) => m.images?.length))
|
|
469
489
|
return messages;
|
|
470
|
-
const [{ toWireMessages }, {
|
|
471
|
-
return toWireMessages(messages,
|
|
490
|
+
const [{ toWireMessages }, { encodeAttachment }] = await Promise.all([import("./native-vision.js"), nodeImport("./native-vision-node.js")]);
|
|
491
|
+
return toWireMessages(messages, (p) => encodeAttachment(p, framesOnly));
|
|
472
492
|
}
|
|
493
|
+
const carriesVideo = (wire) => wire.some((m) => Array.isArray(m.content) && m.content.some((p) => p.type === "input_video"));
|
|
473
494
|
/** Shared SSE parse loop. Yields each `data:` line's `choices[0].delta`, raw. */
|
|
474
495
|
async function* streamDeltas(messages, o) {
|
|
475
496
|
// Hold this endpoint's slot for the WHOLE request+stream lifetime — the one decode slot is busy the entire
|
|
@@ -490,13 +511,31 @@ async function* streamDeltas(messages, o) {
|
|
|
490
511
|
o.onSent?.();
|
|
491
512
|
}
|
|
492
513
|
catch { /* a UI callback never breaks the request */ }
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
514
|
+
const media = `${o.base}|${o.model}`;
|
|
515
|
+
let wire = await wireMessages(messages, !shipsLlamaCacheKnobs(o.base, o.transport) || recent(refusedVideo, media));
|
|
516
|
+
let res = await fetchChat(o, requestBody(wire, o, true));
|
|
517
|
+
let detail = "";
|
|
518
|
+
const readDetail = async () => { try {
|
|
519
|
+
return (await res.text()).slice(0, 500);
|
|
520
|
+
}
|
|
521
|
+
catch {
|
|
522
|
+
return ""; /* body already consumed / unreadable */
|
|
523
|
+
} };
|
|
524
|
+
if (!res.ok) {
|
|
525
|
+
detail = await readDetail();
|
|
526
|
+
if (carriesVideo(wire) && (await import("./native-vision.js")).videoRejected(res.status, detail)) {
|
|
527
|
+
refusedVideo.set(media, Date.now());
|
|
528
|
+
wire = await wireMessages(messages, true);
|
|
529
|
+
res = await fetchChat(o, requestBody(wire, o, true));
|
|
530
|
+
detail = res.ok ? "" : await readDetail();
|
|
531
|
+
}
|
|
532
|
+
if (!res.ok && o.reasoningEffort && !recent(refusedEfforts, effortKey(o)) && /reasoning.?effort/i.test(detail)) {
|
|
533
|
+
refusedEfforts.set(effortKey(o), Date.now());
|
|
534
|
+
res = await fetchChat(o, requestBody(wire, o, true));
|
|
535
|
+
detail = res.ok ? "" : await readDetail();
|
|
498
536
|
}
|
|
499
|
-
|
|
537
|
+
}
|
|
538
|
+
if (!res.ok || !res.body) {
|
|
500
539
|
// Carry the status + body so the self-heal policy can classify WHY (context vs shape vs busy),
|
|
501
540
|
// not just guess from the number. `retryAfterMs` honors a Retry-After header on 429/503.
|
|
502
541
|
const err = new Error(`${httpErrorLabel(o)} ${res.status}${detail ? `: ${detail}` : ""}`);
|