@0perator/operator 0.1.330 → 0.1.332
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp/config-options.js +10 -1
- package/dist/auth/byo.js +85 -9
- package/dist/auth/commands.js +1 -1
- package/dist/autonomy/delegate.js +3 -2
- package/dist/autonomy/headless.js +18 -7
- package/dist/autonomy/session-factory.js +3 -0
- package/dist/cli.js +264 -61
- package/dist/config/persona.js +14 -2
- package/dist/config/scratch.js +90 -0
- package/dist/config/settings.js +32 -1
- package/dist/engine/agent.js +98 -42
- package/dist/engine/anthropic-chat.js +28 -6
- package/dist/engine/anthropic.js +1 -1
- package/dist/engine/aurora.js +5 -1
- package/dist/engine/compaction.js +5 -2
- package/dist/engine/continuation.js +98 -0
- package/dist/engine/router-adapter.js +6 -5
- package/dist/engine/verify-gate.js +30 -3
- package/dist/memory/live-progress.js +83 -0
- package/dist/remote/safe-commands.js +1 -1
- package/dist/router/discovery.js +23 -4
- package/dist/router/free-models.js +190 -0
- package/dist/router/models.js +138 -60
- package/dist/selfimprove/index.js +2 -1
- package/dist/services/preflight.js +1 -1
- package/dist/session.js +95 -24
- package/dist/tools/sandbox.js +1 -1
- package/dist/tools/shell-session.js +3 -2
- package/dist/ui/App.js +4 -3
- package/dist/ui/Composer.js +16 -1
- package/dist/ui/QuestionPrompt.js +22 -4
- package/dist/ui/SecretPrompt.js +77 -0
- package/dist/ui/StatusRule.js +6 -6
- package/dist/ui/modelPicker.js +110 -0
- package/dist/ui/slashCommands.js +3 -1
- package/dist/util/caffeinate.js +52 -0
- package/dist/util/slash.js +3 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9,6 +9,7 @@ import { render, Box, Text, useApp } from "ink";
|
|
|
9
9
|
import { App } from "./ui/index.js";
|
|
10
10
|
import { mastheadLines } from "./ui/Masthead.js";
|
|
11
11
|
import { shouldPromptPlanExit, resolvePlanExit, PLAN_EXIT_OPTIONS } from "./ui/planExit.js";
|
|
12
|
+
import { FREE_ROW_PRESETS, connectedAccounts, looksLikeSecret, contextLine, contextPickerView, keyStoredLine, markModelRows, modelLine, modelPickerView, onceEach, pickerAnswer, providerPickerView, wantsContextStep } from "./ui/modelPicker.js";
|
|
12
13
|
import { RemoteHost } from "./remote/host.js";
|
|
13
14
|
import { REMOTE_SAFE_COMMANDS, REMOTE_SAFE_COMMAND_NAMES } from "./remote/safe-commands.js";
|
|
14
15
|
import { newCode, pairURL } from "./remote/pairing.js";
|
|
@@ -22,7 +23,7 @@ import { cacheBustNotice } from "./engine/aurora.js";
|
|
|
22
23
|
import { seedCalibration } from "./engine/calibration-seed.js";
|
|
23
24
|
import { AuroraRouter } from "./router/router.js";
|
|
24
25
|
import { BackgroundAgents } from "./background/index.js";
|
|
25
|
-
import { loadSettings, saveSettings, compactionThreshold, compactionCeilingTokens, rcAutostart, applySeat, setActiveSeat, buildEndpointChain } from "./config/settings.js";
|
|
26
|
+
import { loadSettings, saveSettings, compactionThreshold, compactionCeilingTokens, rcAutostart, applySeat, setActiveSeat, buildEndpointChain, parseContextArg, nextContextPin } from "./config/settings.js";
|
|
26
27
|
import { resolveSeat } from "./auth/identity.js";
|
|
27
28
|
import { PermissionPolicy } from "./permissions/index.js";
|
|
28
29
|
import { caps } from "./ui/capabilities.js";
|
|
@@ -30,14 +31,18 @@ import { composeSystemPrompt, appendMemory } from "./config/persona.js";
|
|
|
30
31
|
import { applyToolsBinPath, operatorPath } from "./config/home.js";
|
|
31
32
|
import { ensureOperatorHome } from "./config/scaffold.js";
|
|
32
33
|
import { listLocalSkills } from "./config/skills-index.js";
|
|
33
|
-
import { modelCtxFor, leanHarnessFor, selectModel, modelRegistry, DEFAULT_MODEL_ID } from "./router/models.js";
|
|
34
|
-
import { fetchPortalModels,
|
|
34
|
+
import { modelCtxFor, leanHarnessFor, selectModel, modelRegistry, fmtCtx, shortName, BYO_PRESETS, DEFAULT_MODEL_ID } from "./router/models.js";
|
|
35
|
+
import { fetchPortalModels, offlineNote, portalIdFor } from "./router/portal.js";
|
|
36
|
+
import { fetchFreeModels } from "./router/free-models.js";
|
|
35
37
|
import { describeTurnError } from "./engine/net-error.js";
|
|
36
|
-
import { hasByoToken } from "./auth/byo.js";
|
|
38
|
+
import { hasByoToken, setByoToken } from "./auth/byo.js";
|
|
37
39
|
import { getDiscoveredModels } from "./router/discovery.js";
|
|
38
40
|
import { disposeShellSession, getAgentTasks, registry } from "./tools/registry.js";
|
|
39
41
|
import { drainJobNotices, getJobNoticeMode, listShellJobs, onJobEvent, parseJobsArgs, pendingJobNotices, renderJobsList, runningJobCount, setJobNoticeMode, stopShellJob } from "./tools/shell-jobs.js";
|
|
40
42
|
import { drainAgentReports, onAgentReport, pendingAgentReports, queueAgentReport } from "./background/notices.js";
|
|
43
|
+
import { ensureScratchDir } from "./config/scratch.js";
|
|
44
|
+
import { caffeinateEnabled, startCaffeinate } from "./util/caffeinate.js";
|
|
45
|
+
import { recordLiveProgress, roundProgressed, settleLiveProgress, touchedPaths } from "./memory/live-progress.js";
|
|
41
46
|
import { lastActiveAt as idleLastActiveAt, resolveIdlePolicy, startIdleMonitor, touchWork } from "./idle/index.js";
|
|
42
47
|
import { disposeBrowserNow } from "./browser/session.js";
|
|
43
48
|
import { EventSink, defaultEventsFile } from "./telemetry/events.js";
|
|
@@ -475,11 +480,16 @@ const chauffeurReady = !!chauffeurServer || settings.mcp;
|
|
|
475
480
|
// section) so the model stays uncensored.
|
|
476
481
|
const LEAN_HARNESS = leanHarnessFor(settings.activeModel, settings.models);
|
|
477
482
|
// TODO(R1b): built once at startup — a mid-session /model does not rebuild it (ctxTokens + lean follow the startup model).
|
|
483
|
+
// Scratch dir for this project (`<cwd>/.operator/.op-writes`): created here so every tool subprocess inherits
|
|
484
|
+
// OPERATOR_SCRATCH and the persona can point the model at a real path. Skipped for auth/version/help (SKIP_SEAT).
|
|
485
|
+
if (!SKIP_SEAT)
|
|
486
|
+
ensureScratchDir(process.cwd());
|
|
478
487
|
const SYSTEM_PROMPT = composeSystemPrompt({ settings, cwd: process.cwd(), ctxTokens: modelCtxFor(settings.activeModel, settings.models), lean: LEAN_HARNESS, interactive: true, chauffeurReady });
|
|
479
488
|
const HELP = [
|
|
480
489
|
"commands:",
|
|
481
490
|
" /help this list",
|
|
482
|
-
" /model [id] pick a model
|
|
491
|
+
" /model [id] pick a model — fleet, connected providers, free rows; + connect a key",
|
|
492
|
+
" /context [300k|600k|1m|auto] context window for this session (alias /ctx); also Ctrl+X to cycle",
|
|
483
493
|
" /endpoints show the Operator endpoint + live health",
|
|
484
494
|
" /services ensure/inspect the service lever (Operator+autopilot+searxng); /services stop",
|
|
485
495
|
" /audit [n] recent tool + control-plane events from the audit trail (default 15)",
|
|
@@ -577,8 +587,10 @@ function Root() {
|
|
|
577
587
|
remoteRef.current?.askUser(id, q, options); // mirror to followers (owner-scoped; follower prompt is single-select)
|
|
578
588
|
}), [settleQuestion]);
|
|
579
589
|
// /model picker: same QuestionPrompt UI pattern as ask_user, but purely local (never relayed) —
|
|
580
|
-
// it's a session setting, not something the model is asking.
|
|
590
|
+
// it's a session setting, not something the model is asking. Its context step, /context and the provider
|
|
591
|
+
// step share the slot; the provider key itself goes into the masked SecretPrompt, never a QuestionPrompt.
|
|
581
592
|
const [modelPicker, setModelPicker] = useState(null);
|
|
593
|
+
const [secretPrompt, setSecretPrompt] = useState(null);
|
|
582
594
|
// Plan-mode "Approve & run": true once an assistant turn has completed while still in plan mode
|
|
583
595
|
// (i.e. the model actually proposed something), reset whenever a fresh plan-mode session starts.
|
|
584
596
|
// Gates the exit-time picker below — plan mode toggled on/off with no proposal stays silent.
|
|
@@ -618,6 +630,10 @@ function Root() {
|
|
|
618
630
|
remoteRef.current?.approvalRequest(id, name, args); // mirror to followers (owner-scoped)
|
|
619
631
|
});
|
|
620
632
|
}, [settleApproval]);
|
|
633
|
+
// The free vendor rows (router/free-models.ts), fetched when /model opens with that gateway's key connected; the
|
|
634
|
+
// Session reads them on every registry access (dynamicModels), so a fetched row is pickable the moment it lands.
|
|
635
|
+
const freeRowsRef = useRef([]);
|
|
636
|
+
const freeStaleRef = useRef(false); // served from the disk cache after a failed read → the rows say " · cached"
|
|
621
637
|
const sessionRef = useRef(null); // lazy — never reconstruct on re-render
|
|
622
638
|
// MCP opts the foreground session into the fleet MCP tool surface (off by default: local tools
|
|
623
639
|
// only, no network fan-out at session start). Background agents stay local-only + lean.
|
|
@@ -640,10 +656,12 @@ function Root() {
|
|
|
640
656
|
temperature: settings.temperature,
|
|
641
657
|
recall: settings.memory.recall,
|
|
642
658
|
models: MERGED_MODELS, // discovered fleet nodes + settings.models overrides (built-ins in router/models.ts)
|
|
659
|
+
dynamicModels: () => freeRowsRef.current, // the free vendor rows /model fetched this session
|
|
643
660
|
moa: settings.moa, // MOA proposers/aggregator config (MOA-DESIGN.md); absent = "/model moa" explains
|
|
644
661
|
fastStart: settings.fastStart, // fast-model-vs-real-turn race (feature: fastStart, default OFF)
|
|
645
662
|
features: settings.features, // feature flags — registers flag-gated tools (e.g. cloudAgents) only when on
|
|
646
663
|
activeModel: settings.activeModel, // persisted /model choice, applied at startup
|
|
664
|
+
contextPin: settings.contextPin, // persisted /context · ctrl+x choice (KODE_CONTEXT wins); unset = the served window
|
|
647
665
|
permissions: fgPermissions, // owner's policy + computer tools forced to "ask" when enabled (else bypass)
|
|
648
666
|
approve: approveFn, // renders the in-TUI approval prompt for any "ask" decision
|
|
649
667
|
askUser, // registers the ask_user tool so the model can put a clarifying question to the owner
|
|
@@ -727,6 +745,7 @@ function Root() {
|
|
|
727
745
|
});
|
|
728
746
|
}
|
|
729
747
|
const session = sessionRef.current;
|
|
748
|
+
const [ctxPin, setCtxPin] = useState(() => session.contextPin()); // the footer's "ctx 600K" — the pin the engine took, undefined = auto
|
|
730
749
|
// Background sub-agents run on their own Session against the same single Aurora 1M endpoint as the
|
|
731
750
|
// foreground — one model, one context tier.
|
|
732
751
|
const bgRef = useRef(null);
|
|
@@ -740,6 +759,7 @@ function Root() {
|
|
|
740
759
|
loopGuard: settings.loopGuard,
|
|
741
760
|
hooks: settings.hooks, // sub-agents are gated by the same hooks (e.g. git-safety)
|
|
742
761
|
maxRoundsHard: 50, // a focused delegated sub-agent that hits 50 rounds isn't converging — cap it well below the foreground's 200 so a review/fix agent can't run away to round 40+ burning the shared Aurora (seen live 09-26)
|
|
762
|
+
contextPin: sessionRef.current?.contextPin() ?? settings.contextPin, // a sub-agent runs on the owner's current window choice, not the full served one
|
|
743
763
|
background: true, // endpoint gate: this is a sub-agent — its Aurora requests yield the shared single slot to the interactive main turn (fixes the sub-agent-contention crawl + "4 min for a prompt")
|
|
744
764
|
cwd, // isolation: a code-editing bg agent gets its own worktree dir here so it can't touch the foreground tree
|
|
745
765
|
temperature: settings.temperature,
|
|
@@ -759,6 +779,8 @@ function Root() {
|
|
|
759
779
|
const tokHist = useRef([]); // per-turn decode tok/s, for the /stats throughput sparkline
|
|
760
780
|
const toolTotal = useRef(0); // cumulative tool calls this session, for /stats
|
|
761
781
|
const liveText = useRef("");
|
|
782
|
+
const touchedThisTurn = useRef([]); // files written/edited this turn, for the live progress journal
|
|
783
|
+
const lastNarrationRef = useRef(""); // the narration that preceded the current tool batch (liveText is cleared when the batch starts)
|
|
762
784
|
const liveReasoning = useRef(""); // current completion's reasoning ("thinking"), shown dim + above the answer
|
|
763
785
|
const liveTokRef = useRef(0); // per-token count accumulated by the stream; flushed to liveTok on the throttled tick
|
|
764
786
|
// Coalesced live-frame update: applies the accumulated stream refs in ONE render, rate-limited to ~15fps,
|
|
@@ -805,7 +827,7 @@ function Root() {
|
|
|
805
827
|
commands: REMOTE_SAFE_COMMANDS,
|
|
806
828
|
skills: [...skillsRef.current.entries()].map(([name, description]) => ({ name, description })),
|
|
807
829
|
mcpServers: session.mcpServers().map((s) => ({ name: s.name, toolCount: s.tools.length, tools: s.tools })),
|
|
808
|
-
models: session.modelRegistry().map((m) => ({ id: m.id, label: m
|
|
830
|
+
models: session.modelRegistry().map((m) => ({ id: m.id, label: shortName(m), ctx: m.ctx ?? 0, kind: m.kind })),
|
|
809
831
|
mode: opModeRef.current, // live operating mode (Plan/Manual/Autonomous) — a follower can read + drive it via /mode
|
|
810
832
|
cwd: process.cwd(),
|
|
811
833
|
model: session.currentModel(),
|
|
@@ -869,6 +891,13 @@ function Root() {
|
|
|
869
891
|
setBootDetail(a?.detail ?? `no response from ${settings.endpoints.aurora.base}`);
|
|
870
892
|
return;
|
|
871
893
|
}
|
|
894
|
+
// The primary's served window, learned now rather than after the first overflow — AFTER the lever, so the gateway's
|
|
895
|
+
// dynamic port is the base probed (Session probes loopback/LAN only, ≤1.5 s, never a cloud leg). Never blocks boot;
|
|
896
|
+
// a pin above the served window gets its one clamp line.
|
|
897
|
+
void session.probeServedContext().then((r) => {
|
|
898
|
+
if (r.note)
|
|
899
|
+
push({ kind: "message", message: { id: nextId(), role: "system", content: r.note } });
|
|
900
|
+
}).catch(() => { });
|
|
872
901
|
if (RESUME) {
|
|
873
902
|
try {
|
|
874
903
|
const saved = JSON.parse(readFileSync(SESSION_FILE, "utf8"));
|
|
@@ -974,6 +1003,7 @@ function Root() {
|
|
|
974
1003
|
setLive(null);
|
|
975
1004
|
setLiveTok(0); // reset the live counter at the start of the turn
|
|
976
1005
|
turnStartRef.current = Date.now();
|
|
1006
|
+
touchedThisTurn.current = [];
|
|
977
1007
|
turnCachedRef.current = 0;
|
|
978
1008
|
setElapsed(0);
|
|
979
1009
|
setStat("thinking");
|
|
@@ -992,9 +1022,12 @@ function Root() {
|
|
|
992
1022
|
}
|
|
993
1023
|
const outcome = await session.send(expandFileMentions(snapshotEphemeralImages(toSend)), {
|
|
994
1024
|
onRoute: (label, pct) => {
|
|
995
|
-
|
|
1025
|
+
// The owner reads the model, not the leg that answered ("cortana", never "cortana@192.168.1.103:8112");
|
|
1026
|
+
// /endpoints still lists the legs and their health.
|
|
1027
|
+
const model = session.currentModel();
|
|
1028
|
+
setRoute(model);
|
|
996
1029
|
setCtxPct(pct);
|
|
997
|
-
remoteRef.current?.setStatus(pct,
|
|
1030
|
+
remoteRef.current?.setStatus(pct, model, session.sessionTokens());
|
|
998
1031
|
// GW-06 oracle seed (once, fire-and-forget): a fresh meter cold-starts at chars/4 (4.0) — measured
|
|
999
1032
|
// truth on agent traffic is ~2.15 (aurora-tier0/calibrate-token-meter.py), i.e. the gate fires LATE
|
|
1000
1033
|
// for the first rounds. Seed ONE weight-1 observation from the endpoint's own tokenizer
|
|
@@ -1078,6 +1111,8 @@ function Root() {
|
|
|
1078
1111
|
const preThought = liveReasoning.current.trim();
|
|
1079
1112
|
if (preThought)
|
|
1080
1113
|
push({ kind: "message", message: { id: nextId(), role: "assistant", content: "", reasoning: preThought } });
|
|
1114
|
+
if (liveText.current.trim())
|
|
1115
|
+
lastNarrationRef.current = liveText.current; // keep it for the live progress journal
|
|
1081
1116
|
liveText.current = "";
|
|
1082
1117
|
liveReasoning.current = "";
|
|
1083
1118
|
setLive(null);
|
|
@@ -1089,6 +1124,13 @@ function Root() {
|
|
|
1089
1124
|
setLiveTools((rows) => settleLiveTool(rows, id, result));
|
|
1090
1125
|
},
|
|
1091
1126
|
onToolBatch: (events, durationMs) => {
|
|
1127
|
+
// Live progress journal: after every round that changed something, the request, the task list, the files
|
|
1128
|
+
// touched and the last narration are rewritten at the end of this directory's handoff file — a cutoff
|
|
1129
|
+
// (killed session, wedged model, empty reply) loses nothing the next session cannot resume from.
|
|
1130
|
+
if (roundProgressed(events)) {
|
|
1131
|
+
touchedThisTurn.current.push(...touchedPaths(events));
|
|
1132
|
+
recordLiveProgress(process.env.KODE_HANDOFF_FILE, { session: SESSION_ID, cwd: process.cwd(), request: text, tasks: getAgentTasks(), touched: touchedThisTurn.current, narration: lastNarrationRef.current });
|
|
1133
|
+
}
|
|
1092
1134
|
const steps = [];
|
|
1093
1135
|
for (const ev of events) {
|
|
1094
1136
|
const step = {
|
|
@@ -1132,6 +1174,9 @@ function Root() {
|
|
|
1132
1174
|
}, turnDirective, { wake: opts?.wake === true });
|
|
1133
1175
|
// A completed (not interrupted) turn while still in plan mode counts as "a plan was proposed" —
|
|
1134
1176
|
// arms the exit-time Approve & run picker (see applyMode).
|
|
1177
|
+
// The turn ended normally: settle the live progress block so the next session is not told to resume a finished turn.
|
|
1178
|
+
if (!outcome.interrupted && touchedThisTurn.current.length)
|
|
1179
|
+
settleLiveProgress(process.env.KODE_HANDOFF_FILE, { session: SESSION_ID, cwd: process.cwd(), request: text, tasks: getAgentTasks(), touched: touchedThisTurn.current, narration: lastNarrationRef.current });
|
|
1135
1180
|
if (!outcome.interrupted && session.inPlanMode())
|
|
1136
1181
|
planProposedRef.current = true;
|
|
1137
1182
|
if (outcome.interrupted) {
|
|
@@ -1180,8 +1225,8 @@ function Root() {
|
|
|
1180
1225
|
}
|
|
1181
1226
|
}
|
|
1182
1227
|
catch (e) {
|
|
1183
|
-
const
|
|
1184
|
-
push({ kind: "message", message: { id: nextId(), role: "assistant", content: describeTurnError(e.message, { label:
|
|
1228
|
+
const activeModel = session.modelRegistry().find((m) => m.id === session.currentModel());
|
|
1229
|
+
push({ kind: "message", message: { id: nextId(), role: "assistant", content: describeTurnError(e.message, { label: activeModel && shortName(activeModel), bases: session.endpoints().map((x) => x.base) }) } });
|
|
1185
1230
|
}
|
|
1186
1231
|
finally {
|
|
1187
1232
|
tracker.noteTurn();
|
|
@@ -1244,6 +1289,28 @@ function Root() {
|
|
|
1244
1289
|
push({ kind: "message", message: { id: nextId(), role: "system", content: text } });
|
|
1245
1290
|
remoteRef.current?.system(text);
|
|
1246
1291
|
}, []);
|
|
1292
|
+
// A follower drove a slash command. Reuse the EXACT same path a local `/name args` line takes (submitRef → onSubmit →
|
|
1293
|
+
// handleSlash) — never a second implementation of the switch — but only for names on the remote-safe allowlist;
|
|
1294
|
+
// anything else is refused locally-visibly (sys + an audit event) rather than silently dropped or silently run.
|
|
1295
|
+
const remoteCommand = useCallback((name, args) => {
|
|
1296
|
+
if (!REMOTE_SAFE_COMMAND_NAMES.has(name)) {
|
|
1297
|
+
sys(`remote control: blocked "/${name}" from a follower — not exposed for remote dispatch`);
|
|
1298
|
+
eventSink.emit({ kind: "control", session: SESSION_ID, actor: EVENT_ACTOR, control: { event: "rc_command_blocked", detail: name } });
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
eventSink.emit({ kind: "control", session: SESSION_ID, actor: EVENT_ACTOR, control: { event: "rc_command", detail: args ? `${name} ${args}` : name } });
|
|
1302
|
+
submitRef.current(`/${name}${args ? " " + args : ""}`);
|
|
1303
|
+
}, [sys]);
|
|
1304
|
+
// A follower's prompt that reads as a slash command takes the command path, allowlist included: the prompt frame must
|
|
1305
|
+
// not be a side door around it (/allow, /mode, /context typed on the phone would otherwise run host-side).
|
|
1306
|
+
const remotePrompt = useCallback((text) => {
|
|
1307
|
+
if (isSlashCommand(text)) {
|
|
1308
|
+
const [name, ...rest] = text.trim().slice(1).split(/\s+/);
|
|
1309
|
+
remoteCommand(name, rest.join(" "));
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
submitRef.current(text);
|
|
1313
|
+
}, [remoteCommand]);
|
|
1247
1314
|
// Idle-session policy (idle/): end a session nobody has touched for a while, never one that is working. This is the one entry that
|
|
1248
1315
|
// mounts an interactive TUI, so headless/ACP/serve sessions are never subject to it. Ends through the SAME Teardown as /exit.
|
|
1249
1316
|
useEffect(() => {
|
|
@@ -1265,6 +1332,31 @@ function Root() {
|
|
|
1265
1332
|
teardown.add("idle-monitor", () => mon.stop(), { order: 20 });
|
|
1266
1333
|
return () => mon.stop();
|
|
1267
1334
|
}, []);
|
|
1335
|
+
// Keep the Mac awake for the life of the session (settings.caffeinate, default on; KODE_CAFFEINATE=0 off; /caffeinate
|
|
1336
|
+
// toggles). `caffeinate -w <pid>` dies with this process, so it can never outlive the session.
|
|
1337
|
+
const caffeineRef = useRef(null);
|
|
1338
|
+
const [caffeinated, setCaffeinated] = useState(false);
|
|
1339
|
+
const setCaffeine = useCallback((on) => {
|
|
1340
|
+
if (on && !caffeineRef.current?.active) {
|
|
1341
|
+
caffeineRef.current = startCaffeinate();
|
|
1342
|
+
setCaffeinated(caffeineRef.current.active);
|
|
1343
|
+
return caffeineRef.current.active;
|
|
1344
|
+
}
|
|
1345
|
+
if (!on && caffeineRef.current) {
|
|
1346
|
+
caffeineRef.current.stop();
|
|
1347
|
+
caffeineRef.current = null;
|
|
1348
|
+
setCaffeinated(false);
|
|
1349
|
+
}
|
|
1350
|
+
return caffeineRef.current?.active ?? false;
|
|
1351
|
+
}, []);
|
|
1352
|
+
useEffect(() => {
|
|
1353
|
+
if (boot !== "ready")
|
|
1354
|
+
return;
|
|
1355
|
+
if (caffeinateEnabled(settings.caffeinate))
|
|
1356
|
+
setCaffeine(true);
|
|
1357
|
+
teardown.add("caffeinate", () => { setCaffeine(false); }, { order: 25 });
|
|
1358
|
+
return () => { setCaffeine(false); };
|
|
1359
|
+
}, [boot, setCaffeine]);
|
|
1268
1360
|
// Say so when this launch cleaned up after a previous one — silently killing processes would be worse than the orphans.
|
|
1269
1361
|
useEffect(() => {
|
|
1270
1362
|
const n = REAPED.killed.length;
|
|
@@ -1324,6 +1416,68 @@ function Root() {
|
|
|
1324
1416
|
}
|
|
1325
1417
|
performModeSwitch(next, quiet);
|
|
1326
1418
|
}, [performModeSwitch, sys]);
|
|
1419
|
+
// One path for every context change — /context, ctrl+x and the /model step: pin the engine (it runs on min(served,
|
|
1420
|
+
// pin) from the next round), persist the choice, light the footer badge, and say what it runs on now.
|
|
1421
|
+
const applyContext = useCallback((pin) => {
|
|
1422
|
+
session.setContextPin(pin);
|
|
1423
|
+
saveSettings({ contextPin: session.contextPin() });
|
|
1424
|
+
setCtxPin(session.contextPin());
|
|
1425
|
+
setCtxPct(session.ctxPct());
|
|
1426
|
+
sys(contextLine(session.contextPin(), session.servedContext(), session.ctxPct()));
|
|
1427
|
+
}, [sys]);
|
|
1428
|
+
// The /model, context and provider pickers share the one local QuestionPrompt slot. A row resolves by INDEX into the
|
|
1429
|
+
// entries it was drawn from (row text can repeat); the empty reply / ctrl+c (DISCUSS) closes the picker without
|
|
1430
|
+
// applying anything. The returned redraw re-renders the SAME picker while it is still the one on screen (portal
|
|
1431
|
+
// markers, late free rows) and is a no-op once it closed or another took its place.
|
|
1432
|
+
const pickerSeqRef = useRef(0);
|
|
1433
|
+
const openPicker = useCallback((question, rows, entries, onAnswer) => {
|
|
1434
|
+
const seq = ++pickerSeqRef.current;
|
|
1435
|
+
const pending = (shown, from) => ({
|
|
1436
|
+
question,
|
|
1437
|
+
options: shown,
|
|
1438
|
+
key: seq, // a redraw of this open keeps the owner's place (QuestionPrompt.redrawState)
|
|
1439
|
+
resolve: (answer, index) => {
|
|
1440
|
+
pickerSeqRef.current++;
|
|
1441
|
+
setModelPicker(null);
|
|
1442
|
+
const a = pickerAnswer(from, answer, index);
|
|
1443
|
+
if (a)
|
|
1444
|
+
onAnswer(a);
|
|
1445
|
+
},
|
|
1446
|
+
});
|
|
1447
|
+
setModelPicker(pending(rows, entries));
|
|
1448
|
+
return (shown, from) => { if (pickerSeqRef.current === seq)
|
|
1449
|
+
setModelPicker(pending(shown, from)); };
|
|
1450
|
+
}, []);
|
|
1451
|
+
// "Context for this session": bare /context, and the step after a /model pick whose window beats the smallest pin.
|
|
1452
|
+
const openContextPicker = useCallback(() => {
|
|
1453
|
+
const { rows, pins } = contextPickerView(session.contextPin(), session.servedContext());
|
|
1454
|
+
openPicker("Context for this session", rows, pins, (a) => {
|
|
1455
|
+
if ("entry" in a) {
|
|
1456
|
+
applyContext(a.entry);
|
|
1457
|
+
return;
|
|
1458
|
+
}
|
|
1459
|
+
const pin = parseContextArg(a.typed); // a typed reply takes the /context argument grammar
|
|
1460
|
+
if (pin === undefined)
|
|
1461
|
+
sys(`"${a.typed}" is not a context size — 300k · 600k · 1m · auto`);
|
|
1462
|
+
else
|
|
1463
|
+
applyContext(pin ?? undefined);
|
|
1464
|
+
});
|
|
1465
|
+
}, [openPicker, applyContext, sys]);
|
|
1466
|
+
// ctrl+x: the next stop of auto → 300K → 600K → 1M → auto, through the same path /context takes.
|
|
1467
|
+
const onCycleContext = useCallback(() => { applyContext(nextContextPin(session.contextPin())); }, [applyContext]);
|
|
1468
|
+
// The free rows behind a connected free-tier key (FREE_ROW_PRESETS): ≤4 s, then the 10-min disk cache, so a picker
|
|
1469
|
+
// never waits on them. Resolves true when the rows changed — an open picker redraws only for news.
|
|
1470
|
+
const refreshFreeRows = useCallback(async (isConnected) => {
|
|
1471
|
+
const presets = FREE_ROW_PRESETS.map((k) => BYO_PRESETS[k]).filter((p) => p && isConnected(p.account, p.endpoint));
|
|
1472
|
+
const lists = await Promise.all(presets.map((p) => fetchFreeModels(p)));
|
|
1473
|
+
const models = lists.flatMap((l) => l.models);
|
|
1474
|
+
const stale = lists.some((l) => l.stale);
|
|
1475
|
+
const sig = (ms, st) => `${st}|${ms.map((m) => m.id).join(",")}`;
|
|
1476
|
+
const changed = sig(models, stale) !== sig(freeRowsRef.current, freeStaleRef.current);
|
|
1477
|
+
freeRowsRef.current = models;
|
|
1478
|
+
freeStaleRef.current = stale;
|
|
1479
|
+
return changed;
|
|
1480
|
+
}, []);
|
|
1327
1481
|
const handleSlash = useCallback(async (cmd) => {
|
|
1328
1482
|
const [name, ...rest] = cmd.slice(1).split(/\s+/);
|
|
1329
1483
|
const arg = rest.join(" ").trim();
|
|
@@ -1357,51 +1511,112 @@ function Root() {
|
|
|
1357
1511
|
// status rule right away — the router only updates its label mid-turn (onRoute), and MOA has
|
|
1358
1512
|
// no router of its own at all, so this is the one place that's always accurate immediately.
|
|
1359
1513
|
const apply = (id) => {
|
|
1514
|
+
if (looksLikeSecret(id)) {
|
|
1515
|
+
sys("that looks like an API key — use “+ Connect a provider key” in /model; nothing was stored or shown");
|
|
1516
|
+
return undefined;
|
|
1517
|
+
}
|
|
1360
1518
|
const r = s.setModel(id);
|
|
1361
1519
|
if (!r.ok) {
|
|
1362
1520
|
sys(`${r.error} — run /model for the list`);
|
|
1363
|
-
return;
|
|
1521
|
+
return undefined;
|
|
1364
1522
|
}
|
|
1365
1523
|
setRoute(s.currentModel());
|
|
1366
1524
|
saveSettings({ activeModel: s.currentModel() });
|
|
1367
|
-
|
|
1525
|
+
const chosen = s.modelRegistry().find((m) => m.id === s.currentModel());
|
|
1526
|
+
sys(modelLine(s.currentModel(), chosen, s.ctxPct(), s.turnCount())); // a free row repeats its caveat here
|
|
1368
1527
|
remoteRef.current?.setCapabilities(buildCapabilities()); // active model changed — re-sync attached followers
|
|
1369
1528
|
// One honest line when the portal reports the chosen model down. Non-blocking (cache or ≤3s), silent when
|
|
1370
1529
|
// the portal is unreachable or doesn't know the model — selection is never refused on portal state.
|
|
1371
|
-
const chosen = s.modelRegistry().find((m) => m.id === s.currentModel());
|
|
1372
1530
|
if (chosen)
|
|
1373
|
-
void fetchPortalModels().then((cat) => { const note = offlineNote(chosen
|
|
1531
|
+
void fetchPortalModels().then((cat) => { const note = offlineNote(shortName(chosen), cat?.get(portalIdFor(chosen))); if (note)
|
|
1374
1532
|
sys(note); });
|
|
1533
|
+
return chosen;
|
|
1375
1534
|
};
|
|
1376
1535
|
if (arg) {
|
|
1377
1536
|
apply(arg);
|
|
1378
1537
|
break;
|
|
1379
1538
|
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
const
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1539
|
+
// Each account is looked up at most once for this open, and only when a row needs it (a keychain miss spawns
|
|
1540
|
+
// `security`): the free-row check now, the full preset list only if the provider step opens.
|
|
1541
|
+
const isConnected = onceEach(hasByoToken);
|
|
1542
|
+
// The masked prompt (ui/SecretPrompt.tsx) hands the key straight to setByoToken (keychain via `security -i` on
|
|
1543
|
+
// STDIN, else the 0600 file); what comes back is the outcome, never the value. Then /model re-opens with the rows
|
|
1544
|
+
// the key unlocked — through submitRef, the same path a typed /model takes.
|
|
1545
|
+
const askKey = ({ preset, p }) => setSecretPrompt({
|
|
1546
|
+
title: `Paste your ${p.label} API key`,
|
|
1547
|
+
store: (value) => setByoToken(p.account, value),
|
|
1548
|
+
resolve: (outcome) => {
|
|
1549
|
+
setSecretPrompt(null);
|
|
1550
|
+
if (outcome === "cancelled")
|
|
1551
|
+
return;
|
|
1552
|
+
if (outcome === "failed") {
|
|
1553
|
+
sys(`${p.account} key not stored — the keychain refused it, or it is not one printable token (no spaces or quotes)`);
|
|
1554
|
+
return;
|
|
1555
|
+
}
|
|
1556
|
+
eventSink.emit({ kind: "control", session: SESSION_ID, actor: EVENT_ACTOR, control: { event: "credential_stored", detail: `byo account=${p.account} via /model` } });
|
|
1557
|
+
const free = FREE_ROW_PRESETS.includes(preset);
|
|
1558
|
+
void (free ? refreshFreeRows((a, e) => a === p.account || isConnected(a, e)) : Promise.resolve(false)).then(() => {
|
|
1559
|
+
sys(keyStoredLine(p.account, s.modelRegistry().filter((m) => m.byo === p.account), preset, free));
|
|
1560
|
+
remoteRef.current?.setCapabilities(buildCapabilities()); // the new rows reach attached followers too
|
|
1561
|
+
submitRef.current("/model");
|
|
1562
|
+
});
|
|
1391
1563
|
},
|
|
1392
1564
|
});
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1565
|
+
const connectProvider = () => {
|
|
1566
|
+
const { rows, choices } = providerPickerView(connectedAccounts(isConnected));
|
|
1567
|
+
openPicker("Connect a provider — then paste its API key", rows, choices, (a) => { if ("entry" in a)
|
|
1568
|
+
askKey(a.entry); });
|
|
1569
|
+
};
|
|
1570
|
+
const active = s.currentModel();
|
|
1571
|
+
const view = () => modelPickerView(s.modelRegistry(), { active, servedCtx: s.servedContext(), staleFree: freeStaleRef.current });
|
|
1572
|
+
const first = view();
|
|
1573
|
+
let onScreen = first.rows;
|
|
1574
|
+
let cat;
|
|
1575
|
+
const redraw = openPicker("Select a model", first.rows, first.entries, (a) => {
|
|
1576
|
+
if ("typed" in a) {
|
|
1577
|
+
apply(a.typed);
|
|
1398
1578
|
return;
|
|
1399
|
-
|
|
1400
|
-
if (
|
|
1579
|
+
} // the typed-id escape: an explicit id skips the context step
|
|
1580
|
+
if (a.entry.kind === "connect") {
|
|
1581
|
+
connectProvider();
|
|
1401
1582
|
return;
|
|
1402
|
-
|
|
1403
|
-
|
|
1583
|
+
}
|
|
1584
|
+
const chosen = apply(a.entry.profile.id);
|
|
1585
|
+
if (chosen && wantsContextStep(chosen, s.servedContext()))
|
|
1586
|
+
openContextPicker();
|
|
1404
1587
|
});
|
|
1588
|
+
// Live state markers from the portal and the free rows: the picker opens instantly; whichever lands re-renders
|
|
1589
|
+
// the SAME picker (markers on the same rows, free rows in their place before MOA) — only when something changed.
|
|
1590
|
+
const refresh = () => {
|
|
1591
|
+
const v = view();
|
|
1592
|
+
const rows = markModelRows(v, cat);
|
|
1593
|
+
if (rows.length === onScreen.length && rows.every((t, i) => t === onScreen[i]))
|
|
1594
|
+
return;
|
|
1595
|
+
onScreen = rows;
|
|
1596
|
+
redraw(rows, v.entries);
|
|
1597
|
+
};
|
|
1598
|
+
void fetchPortalModels().then((c) => { if (c) {
|
|
1599
|
+
cat = c;
|
|
1600
|
+
refresh();
|
|
1601
|
+
} });
|
|
1602
|
+
void refreshFreeRows(isConnected).then((changed) => { if (changed)
|
|
1603
|
+
refresh(); });
|
|
1604
|
+
break;
|
|
1605
|
+
}
|
|
1606
|
+
case "context":
|
|
1607
|
+
case "ctx": {
|
|
1608
|
+
// The engine's window under the served one: `/context 600k | 600000 | 1m | auto` applies at once; bare opens the
|
|
1609
|
+
// picker with the current choice first. Persisted (settings.contextPin); ctrl+x cycles the same stops.
|
|
1610
|
+
if (!arg) {
|
|
1611
|
+
openContextPicker();
|
|
1612
|
+
break;
|
|
1613
|
+
}
|
|
1614
|
+
const pin = parseContextArg(arg);
|
|
1615
|
+
if (pin === undefined) {
|
|
1616
|
+
sys(`usage: /context [300k|600k|1m|auto] — "${arg}" is not a context size`);
|
|
1617
|
+
break;
|
|
1618
|
+
}
|
|
1619
|
+
applyContext(pin ?? undefined);
|
|
1405
1620
|
break;
|
|
1406
1621
|
}
|
|
1407
1622
|
case "artifacts": {
|
|
@@ -2108,6 +2323,14 @@ function Root() {
|
|
|
2108
2323
|
sys(id ? `spawned ${id} in the background — /bg to list · /bg stop ${id} to cancel` : bg.capacityLine());
|
|
2109
2324
|
}
|
|
2110
2325
|
break;
|
|
2326
|
+
case "caffeinate":
|
|
2327
|
+
case "caffeine": {
|
|
2328
|
+
const want = arg === "off" ? false : arg === "on" ? true : !caffeineRef.current?.active;
|
|
2329
|
+
const active = setCaffeine(want);
|
|
2330
|
+
sys(active ? "☕ caffeinate on — this Mac stays awake while the session runs (/caffeinate off to allow sleep)"
|
|
2331
|
+
: want ? "caffeinate unavailable here (macOS only, needs /usr/bin/caffeinate)" : "caffeinate off — the Mac may sleep while idle");
|
|
2332
|
+
break;
|
|
2333
|
+
}
|
|
2111
2334
|
case "remotecontrol":
|
|
2112
2335
|
case "remote":
|
|
2113
2336
|
case "rc": {
|
|
@@ -2140,7 +2363,7 @@ function Root() {
|
|
|
2140
2363
|
const { relayUrls, hostOf } = await import("./config/product-hosts.js");
|
|
2141
2364
|
const urls = relayUrls(); // api.0perator.co first, api.axe.onl as fallback (KODE_RELAY_URL overrides, comma-separated)
|
|
2142
2365
|
const rh = new RemoteHost(urls, token, { title: `Operator · ${process.cwd().split("/").pop() || "session"}`, cwd: process.cwd(), host: hostname(), surface: "cli" }, {
|
|
2143
|
-
onPrompt:
|
|
2366
|
+
onPrompt: remotePrompt, // follower drives a turn (slash-shaped → the allowlisted command path)
|
|
2144
2367
|
onApprovalResponse: (id, approve) => settleApproval(id, approve), // first-wins with local
|
|
2145
2368
|
onAskUserResponse: (id, answer) => settleQuestion(id, answer), // first-wins with local
|
|
2146
2369
|
onInterrupt: () => s.interrupt(), // follower cancels the turn
|
|
@@ -2149,19 +2372,7 @@ function Root() {
|
|
|
2149
2372
|
// Both return a boolean the host turns into an agent_ack so the row shows ✓ / couldn't.
|
|
2150
2373
|
onAgentStop: (id) => bgRef.current?.requestStop(id) ?? false,
|
|
2151
2374
|
onAgentSteer: (id, text) => bgRef.current?.sendToAgent(id, text) ?? false,
|
|
2152
|
-
|
|
2153
|
-
// takes (submitRef → onSubmit → handleSlash) — never a second implementation of the
|
|
2154
|
-
// switch — but only for names on the remote-safe allowlist; anything else is refused
|
|
2155
|
-
// locally-visibly (sys + an audit event) rather than silently dropped or silently run.
|
|
2156
|
-
onCommand: (name, args) => {
|
|
2157
|
-
if (!REMOTE_SAFE_COMMAND_NAMES.has(name)) {
|
|
2158
|
-
sys(`remote control: blocked "/${name}" from a follower — not exposed for remote dispatch`);
|
|
2159
|
-
eventSink.emit({ kind: "control", session: SESSION_ID, actor: EVENT_ACTOR, control: { event: "rc_command_blocked", detail: name } });
|
|
2160
|
-
return;
|
|
2161
|
-
}
|
|
2162
|
-
eventSink.emit({ kind: "control", session: SESSION_ID, actor: EVENT_ACTOR, control: { event: "rc_command", detail: args ? `${name} ${args}` : name } });
|
|
2163
|
-
submitRef.current(`/${name}${args ? " " + args : ""}`);
|
|
2164
|
-
},
|
|
2375
|
+
onCommand: remoteCommand,
|
|
2165
2376
|
onState: (st, detail) => {
|
|
2166
2377
|
setRcConnected(st === "live"); // footer controller icon: green when live, gray otherwise
|
|
2167
2378
|
if (st === "live")
|
|
@@ -2215,21 +2426,13 @@ function Root() {
|
|
|
2215
2426
|
const urls = relayUrls(); // api.0perator.co first, api.axe.onl as fallback (KODE_RELAY_URL overrides, comma-separated)
|
|
2216
2427
|
const code = newCode();
|
|
2217
2428
|
const rh = new RemoteHost(urls, token, { title: `Operator · ${process.cwd().split("/").pop() || "session"}`, cwd: process.cwd(), host: hostname(), surface: "cli" }, {
|
|
2218
|
-
onPrompt:
|
|
2429
|
+
onPrompt: remotePrompt,
|
|
2219
2430
|
onApprovalResponse: (id, approve) => settleApproval(id, approve),
|
|
2220
2431
|
onAskUserResponse: (id, answer) => settleQuestion(id, answer),
|
|
2221
2432
|
onInterrupt: () => s.interrupt(),
|
|
2222
2433
|
onAgentStop: (id) => bgRef.current?.requestStop(id) ?? false, // RC v2 B1 (paired mode)
|
|
2223
2434
|
onAgentSteer: (id, text) => bgRef.current?.sendToAgent(id, text) ?? false,
|
|
2224
|
-
onCommand:
|
|
2225
|
-
if (!REMOTE_SAFE_COMMAND_NAMES.has(cmdName)) {
|
|
2226
|
-
sys(`remote control: blocked "/${cmdName}" from a follower — not exposed for remote dispatch`);
|
|
2227
|
-
eventSink.emit({ kind: "control", session: SESSION_ID, actor: EVENT_ACTOR, control: { event: "rc_command_blocked", detail: cmdName } });
|
|
2228
|
-
return;
|
|
2229
|
-
}
|
|
2230
|
-
eventSink.emit({ kind: "control", session: SESSION_ID, actor: EVENT_ACTOR, control: { event: "rc_command", detail: cmdArgs ? `${cmdName} ${cmdArgs}` : cmdName } });
|
|
2231
|
-
submitRef.current(`/${cmdName}${cmdArgs ? " " + cmdArgs : ""}`);
|
|
2232
|
-
},
|
|
2435
|
+
onCommand: remoteCommand,
|
|
2233
2436
|
onState: (st, detail) => {
|
|
2234
2437
|
setRcConnected(st === "live");
|
|
2235
2438
|
if (st === "connecting" && detail === "reconnecting")
|
|
@@ -2255,7 +2458,7 @@ function Root() {
|
|
|
2255
2458
|
}
|
|
2256
2459
|
default: sys(`unknown command /${name} — try /help`);
|
|
2257
2460
|
}
|
|
2258
|
-
}, [exit, sys, bg, authUser, approval, settleApproval, settleQuestion, applyMode]);
|
|
2461
|
+
}, [exit, sys, bg, authUser, approval, settleApproval, settleQuestion, applyMode, applyContext, openPicker, openContextPicker, refreshFreeRows, remoteCommand, remotePrompt]);
|
|
2259
2462
|
const onSubmit = useCallback((text) => {
|
|
2260
2463
|
if (isSlashCommand(text)) {
|
|
2261
2464
|
void handleSlash(text.trim());
|
|
@@ -2387,7 +2590,7 @@ function Root() {
|
|
|
2387
2590
|
? `${spin} reading your prompt… (${fmtDuration(elapsed)})`
|
|
2388
2591
|
: `${spin} ${fmtMeta(elapsed, liveTok)}`
|
|
2389
2592
|
: metrics;
|
|
2390
|
-
return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, prefill: prefill, liveTools: liveTools, route: route, ctxPct: ctxPct, version: VERSION, fullscreen: FULLSCREEN, metrics: liveMetrics, sessionTokens: session.sessionTokens() + liveTok, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, shellJobs: shellJobs, onBackground: onBackground, tasks: tasks, onSubmit: onSubmit, onQueue: onQueue, queuedPreview: queuedPreview, onInterrupt: onInterrupt, onCycleMode: onCycleMode, opMode: opMode, rcConnected: rcConnected, rcActive: rcActive, approval: approval, question: question, modelPicker: modelPicker, planExitPicker: planExitPicker, artifactsPicker: artifactsPicker, sessionsPicker: sessionsPicker, onApprovalDecide: (allow, always) => {
|
|
2593
|
+
return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, prefill: prefill, liveTools: liveTools, route: route, ctxPct: ctxPct, ctxPin: ctxPin ? fmtCtx(ctxPin) : undefined, version: VERSION, fullscreen: FULLSCREEN, metrics: liveMetrics, sessionTokens: session.sessionTokens() + liveTok, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, shellJobs: shellJobs, onBackground: onBackground, tasks: tasks, onSubmit: onSubmit, onQueue: onQueue, queuedPreview: queuedPreview, onInterrupt: onInterrupt, onCycleMode: onCycleMode, onCycleContext: onCycleContext, opMode: opMode, rcConnected: rcConnected, rcActive: rcActive, caffeinated: caffeinated, approval: approval, question: question, modelPicker: modelPicker, secretPrompt: secretPrompt, planExitPicker: planExitPicker, artifactsPicker: artifactsPicker, sessionsPicker: sessionsPicker, onApprovalDecide: (allow, always) => {
|
|
2391
2594
|
const cur = approval;
|
|
2392
2595
|
if (cur)
|
|
2393
2596
|
settleApproval(cur.id, allow, always); // first-wins with any remote follower answer
|
package/dist/config/persona.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { readFileSync, appendFileSync, mkdirSync } from "node:fs";
|
|
6
6
|
import { join, dirname } from "node:path";
|
|
7
7
|
import { operatorPath } from "./home.js";
|
|
8
|
+
import { scratchDirFor } from "./scratch.js";
|
|
8
9
|
import { renderHarnessContext } from "./operator-harness.js";
|
|
9
10
|
import { renderToolCatalogue } from "../tools/registry.js";
|
|
10
11
|
import { renderSkillsIndex } from "./skills-index.js";
|
|
@@ -191,7 +192,9 @@ export function basePersona(cwd = process.cwd(), opts = {}) {
|
|
|
191
192
|
`has passed in front of you. Tests must assert BEHAVIOR (the CLI runs, a dependency resolves, the ` +
|
|
192
193
|
`output is correct), not merely that files exist — green tests that assert nothing are not proof, and ` +
|
|
193
194
|
`"all tests pass" while the program is broken is the worst possible report. If you did not run it, say ` +
|
|
194
|
-
`so plainly instead of calling it done
|
|
195
|
+
`so plainly instead of calling it done. A document deliverable has runnable checks too — a link check, ` +
|
|
196
|
+
`\`docker compose config\` on an embedded compose block, a script that sums the tables, a linter — run ` +
|
|
197
|
+
`them; and a "checked <date>" stamp on a product row is written only in the turn that opened that page.` +
|
|
195
198
|
`\n## How I work — the AXE self-check\nBefore acting: for a bug I state the ROOT CAUSE in one line ` +
|
|
196
199
|
`(not the symptom) and how I confirmed it; I reuse the nearest existing pattern (a new pattern needs a ` +
|
|
197
200
|
`reason); I stay scoped to exactly what was asked and don't touch the data layer or infra unless asked. ` +
|
|
@@ -201,6 +204,9 @@ export function basePersona(cwd = process.cwd(), opts = {}) {
|
|
|
201
204
|
`a conventional \`type(scope): subject\` with explicit paths (never a blanket add in a shared checkout) ` +
|
|
202
205
|
`and no AI / Co-Authored-By / Claude-Session trailers.` +
|
|
203
206
|
`\n## This machine\nWorking dir: ${cwd}` +
|
|
207
|
+
`\nScratch dir: ${scratchDirFor(cwd)} (also \`$OPERATOR_SCRATCH\` in every shell) — temporary scripts, probe ` +
|
|
208
|
+
`output, downloads to inspect, intermediate files: ALWAYS here, never /tmp and never the repo root. It is ` +
|
|
209
|
+
`git-ignored and swept after a week, so nothing you keep belongs in it; name files \`<subject>-<thing>\`.` +
|
|
204
210
|
ctxLine +
|
|
205
211
|
`\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. When asked what you are or which model you run on, ` +
|
|
206
212
|
`say you are Operator (AXE's agent) and give the context window above. Never name, guess or compare backend models (do not say ` +
|
|
@@ -280,7 +286,7 @@ export function basePersona(cwd = process.cwd(), opts = {}) {
|
|
|
280
286
|
// shipped as "...rather than guessing.the script to a file…" — no heading, no space (the persona
|
|
281
287
|
// regression test's red on main was the witness). Restored as its own section; do not re-splice.
|
|
282
288
|
`\n## Running scripts — never inline a multi-line script\nFor anything more than a ONE-LINE snippet, write ` +
|
|
283
|
-
`the script to a file with file_write and run the file (\`python3 /
|
|
289
|
+
`the script to a file in the scratch dir with file_write and run the file (\`python3 "$OPERATOR_SCRATCH/probe.py"\`). Do NOT embed a ` +
|
|
284
290
|
`multi-line program inside \`python3 -c "…"\` or \`bash -c "…"\`: the newlines, \`#\` comments and quotes ` +
|
|
285
291
|
`have to be escaped inside the tool-call JSON, and a slip there breaks the whole call (\`500: missing ` +
|
|
286
292
|
`closing quote\`) and wastes the turn. A short one-liner inline is fine; a real script goes to a file first.` +
|
|
@@ -295,6 +301,12 @@ export function basePersona(cwd = process.cwd(), opts = {}) {
|
|
|
295
301
|
`Keep it to ONE short line and put your tool calls in the SAME message right after it — narration must ` +
|
|
296
302
|
`NEVER delay, crowd out, or replace the actual tool call, and never grow long enough to push a big ` +
|
|
297
303
|
`tool-call argument late in your output where it can get cut off.` +
|
|
304
|
+
`\n## Talking to the owner — never to yourself\nThe owner speaks only in user messages. Anything that starts with ` +
|
|
305
|
+
`"[engine note" is the engine, not the owner: act on it silently or with one line of status, never reply to it ` +
|
|
306
|
+
`("you're right", "good point") and never narrate "the user said". Never write a line for the owner and then ` +
|
|
307
|
+
`answer it. When you have something to say, say it TO the owner as a status: what is done, what you are doing, ` +
|
|
308
|
+
`what you need. Never end a turn on nothing: if you cannot finish, close with one line per open task and ONE ` +
|
|
309
|
+
`question whose answer steers the next step.` +
|
|
298
310
|
(opts.lean ? "" : (`\n## Explain your thinking — tables, diagrams, status (Explanatory default)\nThe owner follows a long ` +
|
|
299
311
|
`session by reading YOUR words, not your tool output — so make your reasoning legible, not just your ` +
|
|
300
312
|
`actions. The one-line what-and-why before each batch (above) is the floor; on top of it: for anything ` +
|