@0perator/operator 0.2.0 → 0.2.2-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/auth/byo.js +1 -1
- package/dist/auth/commands.js +15 -5
- package/dist/auth/identity.js +1 -0
- package/dist/auth/staff.js +55 -0
- package/dist/autonomy/agent-cli.js +1 -1
- package/dist/autonomy/delegate-mode.js +2 -2
- package/dist/autonomy/delegate.js +41 -14
- package/dist/autonomy/headless.js +37 -10
- package/dist/autonomy/index.js +2 -4
- package/dist/autonomy/pr-isolation.js +92 -0
- package/dist/autonomy/pr-preflight.js +474 -0
- package/dist/autonomy/session-factory.js +13 -12
- package/dist/autonomy/subagent-model.js +17 -7
- package/dist/background/capacity.js +136 -0
- package/dist/background/evidence.js +42 -0
- package/dist/background/index.js +311 -44
- package/dist/background/lane-phase.js +60 -0
- package/dist/background/lane-summary.js +151 -0
- package/dist/background/notices.js +12 -3
- package/dist/background/synthesis.js +25 -0
- package/dist/browser/capture.js +505 -0
- package/dist/browser/engine.js +4 -3
- package/dist/browser/page-capture.js +167 -0
- package/dist/browser/png.js +116 -0
- package/dist/browser/visual-compare.js +229 -0
- package/dist/bus/beam-drop.js +55 -0
- package/dist/bus/inbox.js +157 -7
- package/dist/cli.js +316 -120
- package/dist/config/features.js +3 -3
- package/dist/config/managed.js +40 -1
- package/dist/config/persona.js +80 -29
- package/dist/config/product-hosts.js +2 -0
- package/dist/config/settings.js +289 -31
- package/dist/config/skills-index.js +37 -14
- package/dist/config/staff-prompt.js +12 -0
- package/dist/engine/agent.js +52 -41
- package/dist/engine/aurora.js +54 -13
- package/dist/engine/batch-scheduler.js +4 -13
- package/dist/engine/compaction.js +1 -1
- package/dist/engine/continuation.js +66 -32
- package/dist/engine/decision-points.js +2 -3
- package/dist/engine/fanout.js +16 -0
- package/dist/engine/identity.js +42 -0
- package/dist/engine/loop-guard.js +26 -83
- package/dist/engine/messages.js +2 -2
- package/dist/engine/moa.js +23 -1
- package/dist/engine/native-vision-node.js +72 -0
- package/dist/engine/native-vision.js +103 -0
- package/dist/engine/net-error.js +15 -0
- package/dist/engine/rolling-summary.js +142 -93
- package/dist/engine/verify-gate.js +37 -7
- package/dist/engine/waterfall.js +33 -0
- package/dist/gateway-cli.js +24 -4
- package/dist/memory/live-progress.js +4 -5
- package/dist/memory/session-index.js +3 -3
- package/dist/moa/codeact-lane.js +98 -0
- package/dist/moa/codeact-sandbox.js +409 -0
- package/dist/moa/codeact.js +140 -0
- package/dist/permissions/artifact-visibility.js +10 -0
- package/dist/permissions/index.js +2 -1
- package/dist/permissions/policy.js +9 -2
- package/dist/permissions/tier.js +13 -3
- package/dist/products/craft.js +92 -3
- package/dist/products/temple.js +20 -1
- package/dist/products/voice.js +112 -0
- package/dist/remote/grants.js +119 -0
- package/dist/remote/host.js +33 -5
- package/dist/router/free-models.js +5 -9
- package/dist/router/models.js +80 -26
- package/dist/router/provider-models.js +78 -0
- package/dist/router/router.js +15 -3
- package/dist/selfimprove/index.js +8 -6
- package/dist/selfimprove/lessons.js +23 -0
- package/dist/services/preflight.js +35 -91
- package/dist/session.js +316 -125
- package/dist/skills/catalogue.js +5 -2
- package/dist/skills/finder.js +4 -4
- package/dist/skills/install-guard.js +68 -0
- package/dist/skills/install.js +67 -0
- package/dist/toolchain/manifest.json +13 -13
- package/dist/tools/background-result.js +1 -1
- package/dist/tools/beam.js +246 -0
- package/dist/tools/classes.js +103 -0
- package/dist/tools/contract.js +1 -1
- package/dist/tools/craft.js +36 -2
- package/dist/tools/deferred.js +7 -3
- package/dist/tools/doc-text.js +1 -1
- package/dist/tools/executor.js +25 -15
- package/dist/tools/generation-gateway.js +94 -0
- package/dist/tools/registry.js +135 -158
- package/dist/tools/sandbox.js +6 -6
- package/dist/ui/App.js +17 -6
- package/dist/ui/ApprovalPrompt.js +1 -1
- package/dist/ui/BgPanel.js +15 -10
- package/dist/ui/Composer.js +44 -2
- package/dist/ui/Header.js +1 -6
- package/dist/ui/StatusRule.js +20 -8
- package/dist/ui/ToolStep.js +3 -3
- package/dist/ui/Transcript.js +41 -14
- package/dist/ui/batchLine.js +4 -4
- package/dist/ui/editdiff.js +2 -4
- package/dist/ui/format.js +4 -20
- package/dist/ui/liveTools.js +3 -3
- package/dist/ui/modelPicker.js +10 -6
- package/dist/ui/opsMode.js +20 -0
- package/dist/ui/phase.js +4 -2
- package/dist/ui/slashCommands.js +1 -0
- package/dist/ui/types.js +0 -2
- package/dist/ui/voice.js +185 -0
- package/dist/update-check.js +17 -6
- package/dist/update.js +1 -2
- package/dist/util/audio-io.js +82 -0
- package/dist/util/slash.js +2 -2
- package/dist/vision/pairs.js +239 -0
- package/package.json +1 -1
- package/dist/tools/mutating.js +0 -15
package/dist/cli.js
CHANGED
|
@@ -13,8 +13,9 @@ 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 { FREE_ROW_PRESETS, connectedAccounts, isMainModel, looksLikeSecret, contextLine, contextPickerView, keyStoredLine, mainPickerView, markModelRows, modelLine, modelPickerView, onceEach, pickerAnswer, providerPickerView, rereadConfirmView, wantsContextStep, wantsRereadConfirm } from "./ui/modelPicker.js";
|
|
16
|
+
import { FREE_ROW_PRESETS, PROVIDER_ROW_PRESETS, connectedAccounts, isMainModel, looksLikeSecret, contextLine, contextPickerView, keyStoredLine, mainPickerView, markModelRows, modelLine, modelPickerView, onceEach, pickerAnswer, providerPickerView, rereadConfirmView, wantsContextStep, wantsRereadConfirm } from "./ui/modelPicker.js";
|
|
17
17
|
import { RemoteHost, toRemoteAgents } from "./remote/host.js";
|
|
18
|
+
import { GrantStore, grantsEnabled } from "./remote/grants.js";
|
|
18
19
|
import { REMOTE_SAFE_COMMANDS, REMOTE_SAFE_COMMAND_NAMES } from "./remote/safe-commands.js";
|
|
19
20
|
import { newCode, pairURL } from "./remote/pairing.js";
|
|
20
21
|
import { qrToTerminal } from "./ui/qr.js";
|
|
@@ -28,7 +29,7 @@ import { createDecode, decodeRate, decodeRound, deltasApprox, dueCheck, noteDeco
|
|
|
28
29
|
import { isRunawayRepetition } from "./engine/repetition-guard.js";
|
|
29
30
|
import { createLedger, interruptedLine, ledgerParts, noteCompaction, noteGenEnd, noteGenStart, noteRead, noteRound, noteTools, noteWait } from "./ui/turnLedger.js";
|
|
30
31
|
import { termCols } from "./ui/term.js";
|
|
31
|
-
import { pollBus, pollSent, selfAgent, buildMentorWake, selectReadyWakes } from "./bus/inbox.js";
|
|
32
|
+
import { pollBus, pollSent, selfAgent, buildMentorWake, selectReadyWakes, isAutoReport, wakeRoot } from "./bus/inbox.js";
|
|
32
33
|
import { isErrorResult } from "./ui/format.js";
|
|
33
34
|
import { feedFold, foldStep, settleFold, settledFields } from "./ui/fold.js";
|
|
34
35
|
import { turnScoped } from "./ui/turnScope.js";
|
|
@@ -40,31 +41,39 @@ import { seedCalibration } from "./engine/calibration-seed.js";
|
|
|
40
41
|
import { AuroraRouter } from "./router/router.js";
|
|
41
42
|
import { BackgroundAgents } from "./background/index.js";
|
|
42
43
|
import { clearResumable, pickUpSaved, quitSummary, resumeOnReopen, saveResumable, startSaved } from "./background/resume.js";
|
|
43
|
-
import { loadSettings, saveSettings, compactionThreshold, compactionCeilingTokens, compactionMinDecodeTps, rcAutostart, eagerAuthAtBoot, applySeat, setActiveSeat, buildEndpointChain, parseContextArg, nextContextPin } from "./config/settings.js";
|
|
44
|
+
import { loadSettings, saveSettings, settingsLoadProblems, compactionThreshold, compactionCeilingTokens, compactionMinDecodeTps, rcAutostart, eagerAuthAtBoot, applySeat, setActiveSeat, buildEndpointChain, parseContextArg, nextContextPin } from "./config/settings.js";
|
|
44
45
|
import { resolveSeat } from "./auth/identity.js";
|
|
45
46
|
import { PermissionPolicy } from "./permissions/index.js";
|
|
46
47
|
import { caps } from "./ui/capabilities.js";
|
|
47
|
-
import { composeSystemPrompt, appendMemory, subagentSystemPrompt } from "./config/persona.js";
|
|
48
|
+
import { composeSystemPrompt, appendMemory, memoryBudgetNote, subagentSystemPrompt } from "./config/persona.js";
|
|
48
49
|
import { SUBAGENT_ROLES, SUBAGENT_TOOL_DENY, roleCanWrite } from "./engine/grandmaster.js";
|
|
49
50
|
import { applyToolsBinPath, operatorPath } from "./config/home.js";
|
|
50
51
|
import { ensureOperatorHome } from "./config/scaffold.js";
|
|
51
52
|
import { listLocalSkills, skillCommand } from "./config/skills-index.js";
|
|
52
|
-
import { modelCtxFor, leanHarnessFor, selectModel, modelRegistry, fmtCtx, shortName, BYO_PRESETS,
|
|
53
|
+
import { modelCtxFor, leanHarnessFor, selectModel, modelRegistry, fmtCtx, shortName, BYO_PRESETS, CHAIN_MODEL_ID } from "./router/models.js";
|
|
53
54
|
import { fetchPortalModels, offlineNote, portalIdFor } from "./router/portal.js";
|
|
54
55
|
import { fetchFreeModels } from "./router/free-models.js";
|
|
56
|
+
import { fetchProviderModels } from "./router/provider-models.js";
|
|
55
57
|
import { describeTurnError } from "./engine/net-error.js";
|
|
56
|
-
import { fallbackNotice, primaryRecoveredLine, recoveryLine } from "./engine/continuation.js";
|
|
58
|
+
import { fallbackNotice, gatewayFallbackLine, primaryRecoveredLine, recoveryLine } from "./engine/continuation.js";
|
|
59
|
+
import { shownModelLabel } from "./engine/identity.js";
|
|
57
60
|
import { speedCompactionLine } from "./engine/speed-compaction.js";
|
|
58
61
|
import { hasByoToken, setByoToken } from "./auth/byo.js";
|
|
59
62
|
import { getDiscoveredModels } from "./router/discovery.js";
|
|
60
63
|
import { disposeShellSession, getAgentTasks, registry } from "./tools/registry.js";
|
|
61
64
|
import { applySandboxMode } from "./tools/sandbox.js";
|
|
62
65
|
import { drainJobNotices, getJobNoticeMode, listShellJobs, onJobEvent, parseJobsArgs, pendingJobNotices, renderJobsList, runningJobCount, setJobNoticeMode, stopShellJob } from "./tools/shell-jobs.js";
|
|
63
|
-
import { drainAgentNotices, onAgentReport,
|
|
66
|
+
import { drainAgentNotices, onAgentReport, agentReportsDue, queueAgentReport, queueAgentNotice, formatStuckNotice, setReportGate } from "./background/notices.js";
|
|
67
|
+
import { delegateCapacity, liveDelegateRoute } from "./background/capacity.js";
|
|
68
|
+
import { laneSummary } from "./background/lane-summary.js";
|
|
69
|
+
import { missingLine, synthesisState } from "./background/synthesis.js";
|
|
64
70
|
import { reportLine, deliveredLine } from "./ui/reportLine.js";
|
|
65
71
|
import { pushCollapsed, popCollapsed, dropCollapsed } from "./ui/expand.js";
|
|
66
72
|
import { ensureScratchDir } from "./config/scratch.js";
|
|
67
73
|
import { caffeinateEnabled, startCaffeinate } from "./util/caffeinate.js";
|
|
74
|
+
import { installHint, pickPlayer, pickRecorder, playWav, recordWav } from "./util/audio-io.js";
|
|
75
|
+
import { findVoiceGateway, speak, transcribe, voiceConfig } from "./products/voice.js";
|
|
76
|
+
import { createVoice, voiceIntent, voiceLine } from "./ui/voice.js";
|
|
68
77
|
import { recordLiveProgress, roundProgressed, settleLiveProgress, touchedPaths } from "./memory/live-progress.js";
|
|
69
78
|
import { lastActiveAt as idleLastActiveAt, resolveIdlePolicy, startIdleMonitor, touchWork } from "./idle/index.js";
|
|
70
79
|
import { disposeBrowserNow } from "./browser/session.js";
|
|
@@ -75,14 +84,15 @@ import { Teardown } from "./util/teardown.js";
|
|
|
75
84
|
import { installProcessTeardown } from "./session-teardown.js";
|
|
76
85
|
import { createStoreClient, resolveStoreKey } from "./services/store-sync.js";
|
|
77
86
|
import { reapStaleChildren } from "./util/owned-children.js";
|
|
78
|
-
import { readFileSync, writeFileSync, mkdirSync, readdirSync, statSync, existsSync } from "node:fs";
|
|
87
|
+
import { readFileSync, writeFileSync, mkdirSync, mkdtempSync, readdirSync, rmSync, statSync, existsSync } from "node:fs";
|
|
79
88
|
import { expandFileMentions } from "./util/mentions.js";
|
|
80
89
|
import { snapshotEphemeralImages } from "./util/screenshots.js";
|
|
81
90
|
import { isFeatureEnabled } from "./config/features.js";
|
|
82
91
|
import { classifyActVsAsk, actAskGateDirective } from "./engine/classifier.js";
|
|
83
92
|
import { resolveMode } from "./classifier/modes.js";
|
|
84
|
-
import { subagentModelFor, servingModelFor } from "./autonomy/subagent-model.js";
|
|
93
|
+
import { subagentModelFor, servingModelFor, delegateRouteFor } from "./autonomy/subagent-model.js";
|
|
85
94
|
import { parseDelegate, delegateStatusLines, delegateGuardOn, setDelegateSettings } from "./autonomy/delegate-mode.js";
|
|
95
|
+
import { setPrPreflightSettings } from "./autonomy/pr-preflight.js";
|
|
86
96
|
import { classifierConfig } from "./classifier/config.js";
|
|
87
97
|
import { throttle } from "./util/throttle.js";
|
|
88
98
|
import { isSlashCommand } from "./util/slash.js";
|
|
@@ -100,7 +110,7 @@ import { catalogEntry, continuationContext, folderExists, indexCatalog, searchCa
|
|
|
100
110
|
import { titleFrom } from "./memory/session-sources.js";
|
|
101
111
|
import { execFile } from "node:child_process";
|
|
102
112
|
import { join, dirname } from "node:path";
|
|
103
|
-
import { homedir, hostname } from "node:os";
|
|
113
|
+
import { homedir, hostname, tmpdir } from "node:os";
|
|
104
114
|
import { createHash, randomUUID } from "node:crypto";
|
|
105
115
|
// RELEASE CHECKLIST (every bump): update this + package.json "version", ADD A CHANGELOG.md ENTRY
|
|
106
116
|
// (improvements / fixes / tests), run the suite, then publish to npm + push both remotes.
|
|
@@ -125,15 +135,16 @@ function ctxBadge(n) {
|
|
|
125
135
|
return n >= 1024 ? `${Math.round(n / 1024)}K` : String(n);
|
|
126
136
|
}
|
|
127
137
|
// The model the session will actually start on — NOT the raw persisted id. Mirrors Session's startup
|
|
128
|
-
// resolution (session.ts: setModel(cfg.activeModel) else
|
|
138
|
+
// resolution (session.ts: setModel(cfg.activeModel) else CHAIN_MODEL_ID) so the boot masthead badges the
|
|
129
139
|
// window of the model that answers, not a persisted id that the owner-only gate / missing-endpoint check
|
|
130
|
-
// drops back to
|
|
140
|
+
// drops back to the chain row, or a retired id that resolves to its successor. Pure (selectModel is a pure reducer,
|
|
141
|
+
// no health I/O), so the fast paths stay instant.
|
|
131
142
|
function startupModelId(s, actor) {
|
|
132
143
|
const id = s.activeModel;
|
|
133
|
-
if (!id || id ===
|
|
134
|
-
return
|
|
144
|
+
if (!id || id === CHAIN_MODEL_ID)
|
|
145
|
+
return CHAIN_MODEL_ID;
|
|
135
146
|
const isOwner = (actor.tier ?? "admin") === "admin";
|
|
136
|
-
return selectModel(modelRegistry(s.models), id, hasByoToken, isOwner).profile
|
|
147
|
+
return selectModel(modelRegistry(s.models), id, hasByoToken, isOwner).profile?.id ?? CHAIN_MODEL_ID;
|
|
137
148
|
}
|
|
138
149
|
// Fast paths that must NOT mount Ink/React (so `operator --version` works with no TTY and returns instantly)
|
|
139
150
|
// — and must not do ANY identity I/O either. They used to sit BELOW the boot credential load, so even
|
|
@@ -158,7 +169,10 @@ if (process.argv[2] === "selfimprove") {
|
|
|
158
169
|
}
|
|
159
170
|
// operator/settings.json (override path via KODE_TSI_SETTINGS), env vars still win — see config/settings.ts.
|
|
160
171
|
const settings = loadSettings();
|
|
172
|
+
for (const p of settingsLoadProblems())
|
|
173
|
+
process.stderr.write(`[operator] ⚠ settings: ${p}\n`);
|
|
161
174
|
setDelegateSettings(settings.delegate); // delegate mode's guard, read per tool call by every session in this process
|
|
175
|
+
setPrPreflightSettings(settings.prPreflight); // the PR preflight, read per tool call the same way
|
|
162
176
|
// Enterprise first-run: make the operator home's contract explicit BEFORE any module writes into it (0700
|
|
163
177
|
// root, ignore-everything .gitignore, README, settings.example.json, home.json). Idempotent, never throws.
|
|
164
178
|
const HOME_SCAFFOLD = ensureOperatorHome({ version: VERSION });
|
|
@@ -193,6 +207,8 @@ if (settings.selfImprove?.memory === false)
|
|
|
193
207
|
process.env.KODE_SELFIMPROVE_MEMORY = "0"; // opt out of the closed loop (a looped or stuck turn leaves a lesson in the global memories.md) — ON by default
|
|
194
208
|
if (settings.verifyGate?.enabled === false)
|
|
195
209
|
process.env.KODE_VERIFY_GATE = "0"; // opt out of verify-before-done
|
|
210
|
+
if (settings.identity?.discloseModel === true)
|
|
211
|
+
process.env.KODE_DISCLOSE_MODEL ??= "1"; // the owner's own fleet may name the serving model
|
|
196
212
|
if (settings.verifyGate?.maxNudges != null)
|
|
197
213
|
process.env.KODE_VERIFY_GATE_MAX = String(settings.verifyGate.maxNudges);
|
|
198
214
|
if (settings.background?.maxConcurrent != null)
|
|
@@ -225,7 +241,7 @@ if (settings.services?.stopOnExit?.searxng === false)
|
|
|
225
241
|
process.env.KODE_STOP_SEARXNG_ON_EXIT = "0";
|
|
226
242
|
// Remote-engine auth. When this Operator points at a REMOTE engine (KODE_AURORA=https://api.axe.onl),
|
|
227
243
|
// the gateway fronts the model with operator-token auth, so the model call must carry the bearer. Load
|
|
228
|
-
// it once at boot from the keychain (or KODE_OPERATOR_TOKEN) and hand it to the engine; a
|
|
244
|
+
// it once at boot from the keychain (or KODE_OPERATOR_TOKEN) and hand it to the engine; a loopback endpoint
|
|
229
245
|
// never receives it (aurora.ts only sends to a non-loopback base), so this is safe on JL1 and costs
|
|
230
246
|
// nothing there. This is what lets a thin client (a 4 GB MacBook) run Operator against JL1's Aurora.
|
|
231
247
|
let bootCreds = null;
|
|
@@ -481,9 +497,14 @@ let REAPED = { owners: 0, killed: [], skipped: 0 };
|
|
|
481
497
|
let UPDATE_CHECK = Promise.resolve(null);
|
|
482
498
|
let UPDATE_ASKED_AT = 0;
|
|
483
499
|
let UPDATE_NOW = null;
|
|
484
|
-
//
|
|
485
|
-
|
|
486
|
-
|
|
500
|
+
// After a sign-in (the TUI's /login, the shell's `operator auth login`): the same check, gated the same way, past the cache.
|
|
501
|
+
async function checkOnSignIn() {
|
|
502
|
+
const { checkAfterSignIn } = await import("./update-check.js");
|
|
503
|
+
const { isSourceCheckout } = await import("./update.js");
|
|
504
|
+
return checkAfterSignIn(VERSION, { env: process.env, tty: !!process.stdin.isTTY && !!process.stdout.isTTY, settings, sourceCheckout: isSourceCheckout() });
|
|
505
|
+
}
|
|
506
|
+
// Build the endpoint router from the shell chain (buildEndpointChain): the local router's `main` unless the owner named
|
|
507
|
+
// a primary, then the cloud tier. No size-based routing decision remains.
|
|
487
508
|
function buildRouter() {
|
|
488
509
|
// Primary first; the fleet nodes + optional failover + cloud tier are reached only via the router's
|
|
489
510
|
// health-gated recover() when the current endpoint errors/degrades (routeBySize always picks the primary
|
|
@@ -530,6 +551,12 @@ function formatAgentDeepView(a) {
|
|
|
530
551
|
lines.push(` task: ${a.task.length > 120 ? a.task.slice(0, 119) + "…" : a.task}`);
|
|
531
552
|
if (a.model)
|
|
532
553
|
lines.push(` model: ${a.model}${a.lane ? ` · ${a.lane}` : ""}`);
|
|
554
|
+
if (a.leg)
|
|
555
|
+
lines.push(` backend: ${a.leg}`);
|
|
556
|
+
if (a.status === "working" || a.status === "queued")
|
|
557
|
+
lines.push(` doing: ${laneSummary(a, Date.now())}`);
|
|
558
|
+
if (a.queueReason && a.status === "queued")
|
|
559
|
+
lines.push(` waiting: ${a.queueReason}`);
|
|
533
560
|
lines.push(` round: ${a.round ?? 0}`);
|
|
534
561
|
const tokStr = a.tokens != null && a.tokens > 0 ? (a.tokens >= 1000 ? `${(a.tokens / 1000).toFixed(1)}k` : `${a.tokens}`) : "0";
|
|
535
562
|
lines.push(` tokens: ${tokStr}`);
|
|
@@ -593,6 +620,7 @@ const HELP = [
|
|
|
593
620
|
" /sessions [query] search Operator's and other agents' sessions (providers in agents.md) and pick one up",
|
|
594
621
|
" /plan plan mode: read-only research + propose a plan (/plan again to execute)",
|
|
595
622
|
" /mode [auto|manual|plan|gated] set operating mode (autonomous · manual · plan · gated); Shift+Tab cycles the first three",
|
|
623
|
+
" /voice [on|off|status] voice mode: ctrl+t to talk (again to send), the answer is spoken back, esc stops it",
|
|
596
624
|
" /think extended reasoning: Operator thinks before answering (/think again = off)",
|
|
597
625
|
" /ultrathink deep, exhaustive reasoning for hard problems (/ultrathink again = off)",
|
|
598
626
|
" /compact force-compact the conversation now",
|
|
@@ -613,6 +641,7 @@ const HELP = [
|
|
|
613
641
|
"esc — interrupt a running turn (or quit when idle); after a stop, 1-4 pick the next step",
|
|
614
642
|
"ctrl+y — use what you have: cut a long reasoning stream (or a loop) short and answer from what it has (think-off)",
|
|
615
643
|
"ctrl+g — find a skill or tool: search the AXE hub (65K+ skills), your profile and the catalogue · use · run · create a skill",
|
|
644
|
+
"ctrl+u — clear the draft (⌘⌫ sends it in iTerm2 natural text editing and Ghostty) · ctrl+w or option+⌫ — delete the previous word",
|
|
616
645
|
"ctrl+o — expand the latest collapsed batch or sub-agent report; press again for the one before it",
|
|
617
646
|
"↓ on an empty input: the conversation switcher (main + each sub-agent) · ←/→ pick · enter opens it · type to talk to it",
|
|
618
647
|
"while a turn runs: enter steers it (goes in before the next model call) · tab queues for after the turn · esc stops it (a typed draft goes right after) · ↑ on an empty input edits the last pending message · backspace on an empty input cancels it",
|
|
@@ -675,7 +704,7 @@ function Root() {
|
|
|
675
704
|
const [liveTools, setLiveTools] = useState([]); // one row per call in the CURRENT batch,
|
|
676
705
|
// live: seeded "running" by onToolStart, each flips to done/error independently as onToolResult fires
|
|
677
706
|
// for it — see ui/liveTools.ts. Cleared once the batch settles (onToolBatch).
|
|
678
|
-
const [route, setRoute] = useState(
|
|
707
|
+
const [route, setRoute] = useState(CHAIN_MODEL_ID);
|
|
679
708
|
const [ctxPct, setCtxPct] = useState(0);
|
|
680
709
|
const seededRef = useRef(false); // GW-06: oracle cold-start seed fires once per process, on first route
|
|
681
710
|
const cacheReqsRef = useRef(0); // GW-05: requests since process start — index 1 legitimately misses everything
|
|
@@ -756,6 +785,9 @@ function Root() {
|
|
|
756
785
|
const [updatePrompt, setUpdatePrompt] = useState(null);
|
|
757
786
|
const [finder, setFinder] = useState(null); // ctrl+g — the skills and tools finder
|
|
758
787
|
const alwaysAllowRef = useRef(new Set());
|
|
788
|
+
// Scoped "Always allow" grants from a remote follower (grants.v1, KODE_GRANTS=1). Exact tool + derived target,
|
|
789
|
+
// this process's session or 24 h, revocable; see remote/grants.ts. Separate from the keyboard's per-tool set above.
|
|
790
|
+
const grantsRef = useRef(new GrantStore());
|
|
759
791
|
// Remembers the email a `/login <email>` sent a 6-digit code to, so the follow-up `/login <code>`
|
|
760
792
|
// knows which address to verify against — the in-session twin of the shell's email-code login.
|
|
761
793
|
const pendingLoginEmailRef = useRef(null);
|
|
@@ -765,7 +797,7 @@ function Root() {
|
|
|
765
797
|
// Pending gated approvals by id. Both the local keystroke and a remote follower's approval_response
|
|
766
798
|
// route through settleApproval — FIRST answer wins (§7); the map delete makes it idempotent.
|
|
767
799
|
const pendingApprovals = useRef(new Map());
|
|
768
|
-
const settleApproval = useCallback((id, allow, always = false) => {
|
|
800
|
+
const settleApproval = useCallback((id, allow, always = false, grant) => {
|
|
769
801
|
const resolve = pendingApprovals.current.get(id);
|
|
770
802
|
if (!resolve)
|
|
771
803
|
return; // already settled (first-wins)
|
|
@@ -774,12 +806,21 @@ function Root() {
|
|
|
774
806
|
setApproval((cur) => {
|
|
775
807
|
if (cur && cur.id === id && allow && always && !cur.ctx?.once)
|
|
776
808
|
alwaysAllowRef.current.add(cur.name);
|
|
809
|
+
// A grant covers exactly this call's derived target; a signature (ctx.once) prompt is never granted.
|
|
810
|
+
if (cur && cur.id === id && allow && grant && grantsEnabled() && !cur.ctx?.once
|
|
811
|
+
&& grantsRef.current.add(cur.name, cur.args, grant.scope, SESSION_ID)) {
|
|
812
|
+
remoteRef.current?.setGrants(grantsRef.current.list());
|
|
813
|
+
}
|
|
777
814
|
return cur && cur.id === id ? null : cur;
|
|
778
815
|
});
|
|
779
816
|
}, []);
|
|
780
817
|
const approveFn = useCallback((name, args, ctx) => {
|
|
781
818
|
if (!ctx?.once && alwaysAllowRef.current.has(name))
|
|
782
|
-
return Promise.resolve(true); // a phone
|
|
819
|
+
return Promise.resolve(true); // a ctx.once prompt (phone line, ask-each-call seat tool) asks every time
|
|
820
|
+
if (!ctx?.once && grantsEnabled() && grantsRef.current.use(name, args, SESSION_ID)) {
|
|
821
|
+
remoteRef.current?.setGrants(grantsRef.current.list()); // the use count moved
|
|
822
|
+
return Promise.resolve(true);
|
|
823
|
+
}
|
|
783
824
|
const id = "ap_" + Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
|
|
784
825
|
return new Promise((resolve) => {
|
|
785
826
|
pendingApprovals.current.set(id, resolve);
|
|
@@ -792,19 +833,6 @@ function Root() {
|
|
|
792
833
|
const freeRowsRef = useRef([]);
|
|
793
834
|
const freeStaleRef = useRef(false); // served from the disk cache after a failed read → the rows say " · cached"
|
|
794
835
|
const sessionRef = useRef(null); // lazy — never reconstruct on re-render
|
|
795
|
-
// Aurora loads on demand (owner, 11/03): the first turn that needs a local Aurora starts the launchd gateway, and boot
|
|
796
|
-
// never does. The hook is built on first use; it is inert where Aurora is not a launchd job on this box.
|
|
797
|
-
const auroraHookRef = useRef(null);
|
|
798
|
-
const auroraForTurn = async (signal) => {
|
|
799
|
-
if (!auroraHookRef.current) {
|
|
800
|
-
const { auroraOnDemand } = await import("./services/preflight.js");
|
|
801
|
-
auroraHookRef.current = auroraOnDemand(settings.endpoints.aurora, settings.services?.aurora, buildRouter, () => {
|
|
802
|
-
push({ kind: "message", message: { id: nextId(), role: "system", content: "aurora is not loaded — loading it for this turn…" } });
|
|
803
|
-
setPhase("loading");
|
|
804
|
-
}, (line) => push({ kind: "message", message: { id: nextId(), role: "system", content: line } }));
|
|
805
|
-
}
|
|
806
|
-
return auroraHookRef.current(signal);
|
|
807
|
-
};
|
|
808
836
|
// MCP opts the foreground session into the fleet MCP tool surface (off by default: local tools
|
|
809
837
|
// only, no network fan-out at session start). Background agents stay local-only + lean.
|
|
810
838
|
if (!sessionRef.current) {
|
|
@@ -813,7 +841,6 @@ function Root() {
|
|
|
813
841
|
thinkMode, // start in the SAME mode the badge shows (settings.ui.reasoning, default "think") — it was only ever the badge that defaulted on
|
|
814
842
|
router: buildRouter(),
|
|
815
843
|
applyActiveModel: true, // the persisted /model choice still applies with the shell's chain injected
|
|
816
|
-
onDemand: auroraForTurn,
|
|
817
844
|
memory: buildMemory(settings.memory), // provider composite when configured; bare store (byte-identical) otherwise
|
|
818
845
|
mcp: settings.mcp,
|
|
819
846
|
mcpHub: embodimentHub, // scoped chauffeur hub when embodiment is on (undefined otherwise → no change)
|
|
@@ -850,11 +877,12 @@ function Root() {
|
|
|
850
877
|
// sub-agent can't spawn more (no fork bombs). BackgroundAgents itself is the single source of truth
|
|
851
878
|
// for the cap (running + queued) — it refuses ("") past it, so there's exactly one number to keep in
|
|
852
879
|
// sync, not a second constant here that can drift from the manager's own.
|
|
853
|
-
|
|
880
|
+
spawnSlots: () => (sessionRef.current?.currentModel() === "moa" ? bgRef.current?.freeLanes() : undefined), // a planner fan-out is sized to the free lanes
|
|
881
|
+
spawnAgent: (task, role, name, opts) => {
|
|
854
882
|
const mgr = bgRef.current;
|
|
855
883
|
if (!mgr)
|
|
856
884
|
return "background manager not ready yet — retry in a moment";
|
|
857
|
-
const id = mgr.spawn(task, role, name);
|
|
885
|
+
const id = mgr.spawn(task, role, name, undefined, opts);
|
|
858
886
|
if (!id)
|
|
859
887
|
return mgr.capacityLine();
|
|
860
888
|
const a = mgr.list().find((x) => x.id === id);
|
|
@@ -871,7 +899,8 @@ function Root() {
|
|
|
871
899
|
? "It runs on YOUR model's only slot: tell the owner the plan, then end the turn so it gets the slot."
|
|
872
900
|
: "It runs on its own server beside you: keep working on what does not depend on it, and review its work when it reports.") +
|
|
873
901
|
` Its report — or a STUCK notice — arrives as a message at the start of a later turn, never mid-turn; do not poll for it. ` +
|
|
874
|
-
`bash_output/bash_kill do not work on ${id}; never re-spawn its task while it runs
|
|
902
|
+
`bash_output/bash_kill do not work on ${id}; never re-spawn its task while it runs.` +
|
|
903
|
+
(a?.evidence ? ` WARNING: ${a.evidence}.` : "");
|
|
875
904
|
},
|
|
876
905
|
// The reverse channel: message a RUNNING sub-agent mid-flight (steer it / answer its question).
|
|
877
906
|
messageAgent: (id, text) => {
|
|
@@ -924,7 +953,7 @@ function Root() {
|
|
|
924
953
|
const mgr = bgRef.current;
|
|
925
954
|
if (!mgr)
|
|
926
955
|
return "background manager not ready yet — retry in a moment";
|
|
927
|
-
const by = routeLabel(sessionRef.current?.currentModel() ?? ""); // the orchestrator stopped it — the owner's line says which model
|
|
956
|
+
const by = shownModelLabel(routeLabel(sessionRef.current?.currentModel() ?? "")); // the orchestrator stopped it — the owner's line says which model
|
|
928
957
|
if (!id) {
|
|
929
958
|
const stopped = mgr.requestStopAll("orchestrator", by);
|
|
930
959
|
return stopped.length ? `stopped ${stopped.length} sub-agent(s): ${stopped.join(", ")}.` : "no running or queued sub-agents to stop.";
|
|
@@ -942,7 +971,8 @@ function Root() {
|
|
|
942
971
|
// and-capability-catalog.md). The model is resolved PER SPAWN (autonomy/subagent-model.ts): the MoA specialist
|
|
943
972
|
// under /model moa, else the owner's setting, else gpt-oss-20b — never silently another provider (10/31: a
|
|
944
973
|
// background agent on aurora-code-1 looped 51 rounds while Cortana was the selected model).
|
|
945
|
-
const
|
|
974
|
+
const onDelegateRouteRef = useRef(false); // the owner's delegate route answered at the router: sub-agents run there, even under moa
|
|
975
|
+
const subagentModel = () => subagentModelFor(settings, sessionRef.current?.currentModel(), onDelegateRouteRef.current);
|
|
946
976
|
const bgRef = useRef(null);
|
|
947
977
|
// Every finished sub-agent's full report, by id (live or retired), for ctrl+o and `/agents <name> report` — the
|
|
948
978
|
// transcript shows one line per agent (ui/reportLine.ts). collapsedRef is ctrl+o's newest-first stack.
|
|
@@ -1003,6 +1033,20 @@ function Root() {
|
|
|
1003
1033
|
}, (agent, round, how) => {
|
|
1004
1034
|
setEntries((prev) => [...prev, { kind: "message", message: { id: nextId(), role: "system", content: `→ ${agent.name ?? agent.id} took it ${how === "round" ? `at round ${round}` : "as a follow-up turn"}` } }]);
|
|
1005
1035
|
});
|
|
1036
|
+
// Smart slots: the lane count follows the delegate route's live capacity at the router (static cap without one).
|
|
1037
|
+
const registry = modelRegistry(settings.models);
|
|
1038
|
+
const mainModel = () => servingModelFor(settings, sessionRef.current?.currentModel());
|
|
1039
|
+
bgRef.current.setCapacity(delegateCapacity(registry, subagentModel(), mainModel));
|
|
1040
|
+
void liveDelegateRoute(registry, delegateRouteFor(settings), mainModel).then((route) => {
|
|
1041
|
+
if (!route)
|
|
1042
|
+
return;
|
|
1043
|
+
onDelegateRouteRef.current = true;
|
|
1044
|
+
bgRef.current?.setCapacity(route);
|
|
1045
|
+
});
|
|
1046
|
+
setReportGate(() => {
|
|
1047
|
+
const s = synthesisState(bgRef.current?.list() ?? [], Date.now());
|
|
1048
|
+
return { ready: s.ready, missing: missingLine(s.missing) };
|
|
1049
|
+
});
|
|
1006
1050
|
}
|
|
1007
1051
|
const bg = bgRef.current;
|
|
1008
1052
|
// Talking to sub-agents (A3.4): "@Nova <text>" and the conversation switcher on the mode line. `openConv` is the
|
|
@@ -1093,6 +1137,7 @@ function Root() {
|
|
|
1093
1137
|
} };
|
|
1094
1138
|
const push = (e) => setEntries((prev) => [...prev, e]);
|
|
1095
1139
|
const submitRef = useRef(() => { });
|
|
1140
|
+
const voiceRef = useRef(null); // /voice: set only while voice mode is on
|
|
1096
1141
|
const slashRef = useRef(async () => { }); // handleSlash, awaitable (the drain runs staged commands in order)
|
|
1097
1142
|
// AXE skills fetched/saved THIS session (name -> a best-effort description) — there's no persistent
|
|
1098
1143
|
// skill-loader/registry in this codebase to read from (skills are hub-fetched on demand by the
|
|
@@ -1137,8 +1182,8 @@ function Root() {
|
|
|
1137
1182
|
useEffect(() => { tracker.start(session.currentModel()); }, [session]);
|
|
1138
1183
|
useEffect(() => {
|
|
1139
1184
|
void (async () => {
|
|
1140
|
-
// Service lever:
|
|
1141
|
-
//
|
|
1185
|
+
// Service lever: resolve the gateway's published endpoint (Aurora is retired: reported, never started) and bring
|
|
1186
|
+
// the optional companions up via launchd BEFORE gating on health.
|
|
1142
1187
|
let reports = [];
|
|
1143
1188
|
try {
|
|
1144
1189
|
const preflight = await import("./services/preflight.js");
|
|
@@ -1147,7 +1192,6 @@ function Root() {
|
|
|
1147
1192
|
const auroraCfg = { base: bootBase, ...settings.services?.aurora };
|
|
1148
1193
|
reports = await preflight.ensureServices({
|
|
1149
1194
|
aurora: auroraCfg,
|
|
1150
|
-
auroraOnDemand: true, // resolve and report Aurora only: the turn that needs it loads it
|
|
1151
1195
|
autopilot: settings.services?.autopilot,
|
|
1152
1196
|
vision: settings.services?.vision,
|
|
1153
1197
|
onProgress: setBootDetail,
|
|
@@ -1171,21 +1215,18 @@ function Root() {
|
|
|
1171
1215
|
}
|
|
1172
1216
|
}
|
|
1173
1217
|
catch { /* preflight is best-effort — fall through to the authoritative health check */ }
|
|
1174
|
-
|
|
1175
|
-
//
|
|
1176
|
-
|
|
1177
|
-
//
|
|
1178
|
-
|
|
1179
|
-
// shell chain; any other gateway row (operator-flash, the fresh-install default) has its own public leg.
|
|
1180
|
-
const laterLegs = session.currentModel() === DEFAULT_MODEL_ID ? buildEndpointChain(settings).map((e) => e.base) : session.endpoints().map((e) => e.base);
|
|
1218
|
+
const primaryOk = await session.health().catch(() => false);
|
|
1219
|
+
// No local model is not a failed boot when a later leg of the same chain answers: the router falls through to it
|
|
1220
|
+
// on the first turn (a new user's machine has only the cloud tier). The chain row's legs are the shell chain; any
|
|
1221
|
+
// other gateway row (operator-flash, the fresh-install default) has its own public leg.
|
|
1222
|
+
const laterLegs = session.currentModel() === CHAIN_MODEL_ID ? buildEndpointChain(settings).map((e) => e.base) : session.endpoints().map((e) => e.base);
|
|
1181
1223
|
const ok = primaryOk || (await anyReachable(laterLegs.slice(1)).catch(() => false));
|
|
1182
1224
|
setBoot(ok ? "ready" : "down");
|
|
1225
|
+
const modelNote = session.takeModelNote(); // a persisted retired activeModel runs on its successor: said once
|
|
1226
|
+
if (modelNote)
|
|
1227
|
+
push({ kind: "message", message: { id: nextId(), role: "system", content: modelNote } });
|
|
1183
1228
|
if (!ok) {
|
|
1184
|
-
|
|
1185
|
-
// Another model (moa, cortana) failed on its own endpoint: name that one, not Aurora's.
|
|
1186
|
-
setBootDetail(session.currentModel() === DEFAULT_MODEL_ID
|
|
1187
|
-
? a?.detail ?? `no response from ${session.healthTarget()}`
|
|
1188
|
-
: `${session.currentModel()}: no response from ${session.healthTarget()}`);
|
|
1229
|
+
setBootDetail(`${session.currentModel()}: no response from ${session.healthTarget()}`);
|
|
1189
1230
|
return;
|
|
1190
1231
|
}
|
|
1191
1232
|
// The primary's served window, learned now rather than after the first overflow — AFTER the lever, so the gateway's
|
|
@@ -1234,7 +1275,7 @@ function Root() {
|
|
|
1234
1275
|
}
|
|
1235
1276
|
}
|
|
1236
1277
|
// Confirm, once in scrollback, what the lever did (started = it was down and we brought it up).
|
|
1237
|
-
const line = reports.map((r) => `${r.name} ${r.state === "up" ? "✓" : r.state === "started" ? "✓ started" : r.state === "idle" ? "
|
|
1278
|
+
const line = reports.map((r) => `${r.name} ${r.state === "up" ? "✓" : r.state === "started" ? "✓ started" : r.state === "idle" ? "retired, not started" : "✗"}`).join(" · ");
|
|
1238
1279
|
if (line) {
|
|
1239
1280
|
// SearXNG is lazy (starts on first web_search), but if a backend is ALREADY reachable — an explicit
|
|
1240
1281
|
// KODE_SEARXNG_URL, or a container still up from a prior session — show ✓ instead of a misleading
|
|
@@ -1353,7 +1394,7 @@ function Root() {
|
|
|
1353
1394
|
noteWait(ledgerRef.current, Math.max(0, held));
|
|
1354
1395
|
if (held < HOLD_RECEIPT_MS)
|
|
1355
1396
|
return;
|
|
1356
|
-
sys(holdReceipt(routeLabel(session.answeringModel()), held, termCols()));
|
|
1397
|
+
sys(holdReceipt(shownModelLabel(routeLabel(session.answeringModel())), held, termCols()));
|
|
1357
1398
|
};
|
|
1358
1399
|
// The round's first reasoning/content chunk: a read of RECEIPT_MIN_MS or more settles one dim receipt into scrollback
|
|
1359
1400
|
// (and to followers) — what was read, how fast, what was cached, when the first token came.
|
|
@@ -1371,7 +1412,7 @@ function Root() {
|
|
|
1371
1412
|
if (!st || st.elapsedMs < RECEIPT_MIN_MS)
|
|
1372
1413
|
return;
|
|
1373
1414
|
readReceiptRef.current = true;
|
|
1374
|
-
sys(readReceipt(st, termCols(), { model: routeLabel(session.answeringModel()), firstTokenMs: Date.now() - turnStartRef.current }));
|
|
1415
|
+
sys(readReceipt(st, termCols(), { model: shownModelLabel(routeLabel(session.answeringModel())), firstTokenMs: Date.now() - turnStartRef.current }));
|
|
1375
1416
|
};
|
|
1376
1417
|
const startTurn = useCallback(async (text, opts) => {
|
|
1377
1418
|
setNextSteps(null); // a new turn retires the last stop's one-key strip
|
|
@@ -1387,7 +1428,7 @@ function Root() {
|
|
|
1387
1428
|
// Sub-agent reports read as ONE hand-off line for the owner; the model still gets every report in full, unchanged.
|
|
1388
1429
|
const heads = [
|
|
1389
1430
|
...(jobs ? jobs.split("\n\n").map((n) => "⤷ " + n.split("\n")[0].replace(/^\[system notice\] /, "")) : []),
|
|
1390
|
-
...(owners.length ? [deliveredLine(owners, routeLabel(session.currentModel()), termCols())] : []),
|
|
1431
|
+
...(owners.length ? [deliveredLine(owners, shownModelLabel(routeLabel(session.currentModel())), termCols())] : []),
|
|
1391
1432
|
].join("\n");
|
|
1392
1433
|
push({ kind: "message", message: { id: nextId(), role: "system", content: heads } });
|
|
1393
1434
|
remoteRef.current?.system(heads);
|
|
@@ -1497,6 +1538,8 @@ function Root() {
|
|
|
1497
1538
|
},
|
|
1498
1539
|
onCompactionWrite: (n) => { if (compactRef.current)
|
|
1499
1540
|
compactRef.current.wrote = n; }, // drawn on the 500 ms clock, not per delta
|
|
1541
|
+
onCompactionCoverage: (e) => { if (compactRef.current)
|
|
1542
|
+
Object.assign(compactRef.current, e, { ring: [], wrote: 0 }); }, // a new pass: its own read and write
|
|
1500
1543
|
onCompactionEnd: ({ before, after }) => {
|
|
1501
1544
|
const c = compactRef.current;
|
|
1502
1545
|
compactRef.current = null;
|
|
@@ -1598,7 +1641,7 @@ function Root() {
|
|
|
1598
1641
|
if (lastFallbackRef.current === key)
|
|
1599
1642
|
return;
|
|
1600
1643
|
lastFallbackRef.current = key;
|
|
1601
|
-
sys(
|
|
1644
|
+
sys(gatewayFallbackLine({ from: fallbackFrom, backend }));
|
|
1602
1645
|
},
|
|
1603
1646
|
onPrimaryRestored: (backend) => {
|
|
1604
1647
|
// The primary answered again after we'd been on a fallback: clear the degraded state and say so ONCE, so a
|
|
@@ -1629,6 +1672,9 @@ function Root() {
|
|
|
1629
1672
|
sys(`↻ loop recovery ${e.attempt}/${e.max}: ${calls} came back refused as repeats — ` +
|
|
1630
1673
|
`${e.rounds === 1 ? "that round" : `those ${e.rounds} rounds`} became one note of their results; reviewing and continuing`);
|
|
1631
1674
|
},
|
|
1675
|
+
onAutoReport: (to) => {
|
|
1676
|
+
sys(`↗ this wake turn ended without a report, so its final answer was delivered to ${to.join(", ")} (marked auto-delivered)`);
|
|
1677
|
+
},
|
|
1632
1678
|
onAutoContinue: (round) => {
|
|
1633
1679
|
push({ kind: "message", message: { id: nextId(), role: "assistant", content: `↻ still working — auto-continuing past ${round} tool rounds`, reasoning: "" } });
|
|
1634
1680
|
},
|
|
@@ -1798,6 +1844,7 @@ function Root() {
|
|
|
1798
1844
|
const shown = outcome.display ?? outcome.content; // an engine stop reads as a question, not a bracketed note
|
|
1799
1845
|
push({ kind: "message", message: { id: nextId(), role: "assistant", content: shown, reasoning } });
|
|
1800
1846
|
remoteRef.current?.finalAssistant(shown, reasoning);
|
|
1847
|
+
voiceRef.current?.voice.answer(shown); // voice mode speaks a short version of the final answer
|
|
1801
1848
|
// An engine stop's question is answered with one key: its own options, verbatim. A reply cut by the repetition
|
|
1802
1849
|
// check is stashed for "show what it had" — on screen only; the engine keeps it out of history by design.
|
|
1803
1850
|
if (outcome.stopKind) {
|
|
@@ -1896,7 +1943,7 @@ function Root() {
|
|
|
1896
1943
|
command: (cmd) => slashRef.current(cmd),
|
|
1897
1944
|
submit: (text) => submitRef.current(text),
|
|
1898
1945
|
start: (text, opts) => { void startTurn(text, opts); },
|
|
1899
|
-
wakeDue: () => (getJobNoticeMode() === "wake" && pendingJobNotices() > 0) ||
|
|
1946
|
+
wakeDue: () => (getJobNoticeMode() === "wake" && pendingJobNotices() > 0) || agentReportsDue(),
|
|
1900
1947
|
}), []);
|
|
1901
1948
|
const sendTurn = useCallback((text, opts) => flow.send(text, opts), [flow]);
|
|
1902
1949
|
const drainRef = useRef(() => { });
|
|
@@ -1923,6 +1970,17 @@ function Root() {
|
|
|
1923
1970
|
push({ kind: "message", message: { id: nextId(), role: "system", content: text } });
|
|
1924
1971
|
remoteRef.current?.system(text);
|
|
1925
1972
|
}, []);
|
|
1973
|
+
useEffect(() => { for (const p of settingsLoadProblems())
|
|
1974
|
+
sys(`⚠ settings: ${p}`); }, [sys]);
|
|
1975
|
+
// A settings write that fails (locked, unreadable file, disk) is named; the running session keeps the change.
|
|
1976
|
+
const persist = useCallback((patch) => {
|
|
1977
|
+
try {
|
|
1978
|
+
saveSettings(patch);
|
|
1979
|
+
}
|
|
1980
|
+
catch (e) {
|
|
1981
|
+
sys(`⚠ not saved to settings.json: ${e instanceof Error ? e.message : String(e)}`);
|
|
1982
|
+
}
|
|
1983
|
+
}, [sys]);
|
|
1926
1984
|
// A model turn is running (compacting is the one non-idle state with no next round to apply a setting to).
|
|
1927
1985
|
const turnRunning = () => statusRef.current !== "idle" && statusRef.current !== "compacting";
|
|
1928
1986
|
// /think rides in the system prompt (session.ts sysWithThink), so the turn after a toggle re-reads everything past the
|
|
@@ -2031,6 +2089,73 @@ function Root() {
|
|
|
2031
2089
|
sys(picked.line);
|
|
2032
2090
|
}, [boot]);
|
|
2033
2091
|
useEffect(() => { remoteRef.current?.setAgents(toRemoteAgents(bgAgents)); }, [bgAgents, rcActive]);
|
|
2092
|
+
// Say so when a memories file is over its budget: the model is told in its prompt, the owner should be too.
|
|
2093
|
+
useEffect(() => {
|
|
2094
|
+
if (boot !== "ready")
|
|
2095
|
+
return;
|
|
2096
|
+
try {
|
|
2097
|
+
const note = memoryBudgetNote();
|
|
2098
|
+
if (note)
|
|
2099
|
+
sys(note);
|
|
2100
|
+
}
|
|
2101
|
+
catch { /* unreadable memory files are reported elsewhere */ }
|
|
2102
|
+
}, [boot]);
|
|
2103
|
+
// /voice — speech in and out around THIS session (ui/voice.ts): what was said becomes the owner's turn as text, the
|
|
2104
|
+
// session's model answers as usual, and the answer is spoken. The recorder and player are owned children; the scratch
|
|
2105
|
+
// directory holds a recording or a reply only while it is in use.
|
|
2106
|
+
const [voiceUi, setVoiceUi] = useState(null);
|
|
2107
|
+
const stopVoice = useCallback(() => {
|
|
2108
|
+
const v = voiceRef.current;
|
|
2109
|
+
if (!v)
|
|
2110
|
+
return false;
|
|
2111
|
+
voiceRef.current = null;
|
|
2112
|
+
v.voice.off();
|
|
2113
|
+
try {
|
|
2114
|
+
rmSync(v.dir, { recursive: true, force: true });
|
|
2115
|
+
}
|
|
2116
|
+
catch { /* best-effort */ }
|
|
2117
|
+
setVoiceUi(null);
|
|
2118
|
+
return true;
|
|
2119
|
+
}, []);
|
|
2120
|
+
const startVoice = useCallback(async () => {
|
|
2121
|
+
const recorder = pickRecorder(), player = pickPlayer();
|
|
2122
|
+
if (!recorder)
|
|
2123
|
+
return `${installHint("recorder")} — voice stays off`;
|
|
2124
|
+
if (!player)
|
|
2125
|
+
return `${installHint("player")} — voice stays off`;
|
|
2126
|
+
const cfg = voiceConfig(settings.services?.voice);
|
|
2127
|
+
const found = await findVoiceGateway(cfg);
|
|
2128
|
+
if ("error" in found)
|
|
2129
|
+
return `${found.error} — voice stays off`;
|
|
2130
|
+
if (voiceRef.current)
|
|
2131
|
+
return "voice is already on — ctrl+t to talk";
|
|
2132
|
+
const dir = mkdtempSync(join(tmpdir(), "operator-voice-"));
|
|
2133
|
+
const voice = createVoice({
|
|
2134
|
+
record: () => recordWav(recorder, dir),
|
|
2135
|
+
play: (wav) => playWav(player, dir, wav),
|
|
2136
|
+
transcribe: (wav, onWait) => transcribe(found.ok, cfg, wav, { onWait }),
|
|
2137
|
+
speak: (text, onWait) => speak(found.ok, cfg, text, { onWait }),
|
|
2138
|
+
onHeard: (text) => submitRef.current(text),
|
|
2139
|
+
onState: (state, note) => {
|
|
2140
|
+
const line = voiceLine(state, { note, autoStop: recorder.autoStop });
|
|
2141
|
+
setVoiceUi(line ? { line, recording: state === "recording" } : null);
|
|
2142
|
+
},
|
|
2143
|
+
onError: (line) => sys(`voice: ${line}`),
|
|
2144
|
+
});
|
|
2145
|
+
voiceRef.current = { voice, dir, about: `recorder ${recorder.bin} · player ${player.bin} · ${found.ok.label} · routes ${cfg.sttRoute}, ${cfg.ttsRoute}` };
|
|
2146
|
+
voice.on();
|
|
2147
|
+
return `voice on — ctrl+t to talk, ctrl+t again to send${recorder.autoStop ? " (or just pause)" : ""}; the answer is spoken back and esc stops it; typing works as usual (/voice off)`;
|
|
2148
|
+
}, [sys]);
|
|
2149
|
+
const onVoiceKey = useCallback(() => {
|
|
2150
|
+
if (voiceRef.current)
|
|
2151
|
+
voiceRef.current.voice.key();
|
|
2152
|
+
else
|
|
2153
|
+
sys("voice is off — /voice turns it on");
|
|
2154
|
+
}, [sys]);
|
|
2155
|
+
useEffect(() => {
|
|
2156
|
+
teardown.add("voice", () => { stopVoice(); }, { order: 25 });
|
|
2157
|
+
return () => { stopVoice(); };
|
|
2158
|
+
}, [stopVoice]);
|
|
2034
2159
|
// Say so when this launch cleaned up after a previous one — silently killing processes would be worse than the orphans.
|
|
2035
2160
|
useEffect(() => {
|
|
2036
2161
|
const n = REAPED.killed.length;
|
|
@@ -2038,6 +2163,24 @@ function Root() {
|
|
|
2038
2163
|
sys(`cleaned up ${n} leftover process${n === 1 ? "" : "es"} from a previous session that did not exit cleanly (${[...new Set(REAPED.killed.map((k) => k.label))].join(", ")}).`);
|
|
2039
2164
|
}, []);
|
|
2040
2165
|
// A newer build (update-check.ts): the prompt before the first turn; once the owner has typed or a turn runs, one line.
|
|
2166
|
+
// After a /login the prompt comes up at once, or when the running turn ends.
|
|
2167
|
+
const showUpdatePrompt = (offer) => setUpdatePrompt({
|
|
2168
|
+
current: offer.current, version: offer.version, notes: offer.notes, command: offer.command,
|
|
2169
|
+
resolve: (choice) => {
|
|
2170
|
+
setUpdatePrompt(null);
|
|
2171
|
+
if (choice === "update") {
|
|
2172
|
+
UPDATE_NOW = offer;
|
|
2173
|
+
void teardown.run("quit");
|
|
2174
|
+
exit();
|
|
2175
|
+
return;
|
|
2176
|
+
}
|
|
2177
|
+
if (choice === "skip-version") {
|
|
2178
|
+
void import("./update-check.js").then(({ skipVersion }) => skipVersion(offer.version));
|
|
2179
|
+
sys(`Skipped ${offer.version} · Operator asks again when a newer version is out`);
|
|
2180
|
+
}
|
|
2181
|
+
},
|
|
2182
|
+
});
|
|
2183
|
+
const signInOfferRef = useRef(null);
|
|
2041
2184
|
useEffect(() => {
|
|
2042
2185
|
void UPDATE_CHECK.then((offer) => {
|
|
2043
2186
|
if (!offer)
|
|
@@ -2046,24 +2189,24 @@ function Root() {
|
|
|
2046
2189
|
sys(`Update available · ${offer.current} → ${offer.version} · run \`${offer.command}\` (release notes: ${offer.notes})`);
|
|
2047
2190
|
return;
|
|
2048
2191
|
}
|
|
2049
|
-
|
|
2050
|
-
current: offer.current, version: offer.version, notes: offer.notes, command: offer.command,
|
|
2051
|
-
resolve: (choice) => {
|
|
2052
|
-
setUpdatePrompt(null);
|
|
2053
|
-
if (choice === "update") {
|
|
2054
|
-
UPDATE_NOW = offer;
|
|
2055
|
-
void teardown.run("quit");
|
|
2056
|
-
exit();
|
|
2057
|
-
return;
|
|
2058
|
-
}
|
|
2059
|
-
if (choice === "skip-version") {
|
|
2060
|
-
void import("./update-check.js").then(({ skipVersion }) => skipVersion(offer.version));
|
|
2061
|
-
sys(`Skipped ${offer.version} · Operator asks again when a newer version is out`);
|
|
2062
|
-
}
|
|
2063
|
-
},
|
|
2064
|
-
});
|
|
2192
|
+
showUpdatePrompt(offer);
|
|
2065
2193
|
});
|
|
2066
2194
|
}, []);
|
|
2195
|
+
useEffect(() => {
|
|
2196
|
+
const offer = signInOfferRef.current;
|
|
2197
|
+
if (offer && status === "idle") {
|
|
2198
|
+
signInOfferRef.current = null;
|
|
2199
|
+
showUpdatePrompt(offer);
|
|
2200
|
+
}
|
|
2201
|
+
}, [status]);
|
|
2202
|
+
const offerUpdateAfterSignIn = () => void checkOnSignIn().then((offer) => {
|
|
2203
|
+
if (!offer)
|
|
2204
|
+
return;
|
|
2205
|
+
if (statusRef.current === "idle")
|
|
2206
|
+
showUpdatePrompt(offer);
|
|
2207
|
+
else
|
|
2208
|
+
signInOfferRef.current = offer;
|
|
2209
|
+
});
|
|
2067
2210
|
// The actual mode switch — policy, plan flag, status badge, and follower-facing capabilities, all in
|
|
2068
2211
|
// lockstep. Factored out of applyMode so the plan-exit picker below can perform it from a resolve
|
|
2069
2212
|
// callback without re-entering (and re-gating) applyMode itself.
|
|
@@ -2118,11 +2261,11 @@ function Root() {
|
|
|
2118
2261
|
// pin) from the next round), persist the choice, light the footer badge, and say what it runs on now.
|
|
2119
2262
|
const applyContext = useCallback((pin) => {
|
|
2120
2263
|
session.setContextPin(pin);
|
|
2121
|
-
|
|
2264
|
+
persist({ contextPin: session.contextPin() });
|
|
2122
2265
|
setCtxPin(session.contextPin());
|
|
2123
2266
|
setCtxPct(session.ctxPct());
|
|
2124
2267
|
sys(contextLine(session.contextPin(), session.servedContext(), session.ctxPct()) + (turnRunning() ? " · from the next round" : ""));
|
|
2125
|
-
}, [sys]);
|
|
2268
|
+
}, [sys, persist]);
|
|
2126
2269
|
// The /model, context and provider pickers share the one local QuestionPrompt slot. A row resolves by INDEX into the
|
|
2127
2270
|
// entries it was drawn from (row text can repeat); the empty reply / ctrl+c (DISCUSS) closes the picker without
|
|
2128
2271
|
// applying anything. The returned redraw re-renders the SAME picker while it is still the one on screen (portal
|
|
@@ -2163,12 +2306,16 @@ function Root() {
|
|
|
2163
2306
|
}, [openPicker, applyContext, sys]);
|
|
2164
2307
|
// ctrl+x: the next stop of auto → 300K → 600K → 1M → auto, through the same path /context takes.
|
|
2165
2308
|
const onCycleContext = useCallback(() => { applyContext(nextContextPin(session.contextPin())); }, [applyContext]);
|
|
2166
|
-
// The free rows behind a connected free-tier key (FREE_ROW_PRESETS)
|
|
2167
|
-
// never waits on them. Resolves true when the rows
|
|
2309
|
+
// The free rows behind a connected free-tier key (FREE_ROW_PRESETS) and a signed-in provider's own rows
|
|
2310
|
+
// (PROVIDER_ROW_PRESETS): ≤4 s, then their caches, so a picker never waits on them. Resolves true when the rows
|
|
2311
|
+
// changed — an open picker redraws only for news.
|
|
2168
2312
|
const refreshFreeRows = useCallback(async (isConnected) => {
|
|
2169
|
-
const
|
|
2170
|
-
const lists = await Promise.all(
|
|
2171
|
-
|
|
2313
|
+
const live = (keys) => keys.filter((k) => BYO_PRESETS[k] && isConnected(BYO_PRESETS[k].account, BYO_PRESETS[k].endpoint));
|
|
2314
|
+
const [lists, providerRows] = await Promise.all([
|
|
2315
|
+
Promise.all(live(FREE_ROW_PRESETS).map((k) => fetchFreeModels(BYO_PRESETS[k]))),
|
|
2316
|
+
Promise.all(live(PROVIDER_ROW_PRESETS).map((k) => fetchProviderModels(k, BYO_PRESETS[k]))),
|
|
2317
|
+
]);
|
|
2318
|
+
const models = [...providerRows.flat(), ...lists.flatMap((l) => l.models)];
|
|
2172
2319
|
const stale = lists.some((l) => l.stale);
|
|
2173
2320
|
const sig = (ms, st) => `${st}|${ms.map((m) => m.id).join(",")}`;
|
|
2174
2321
|
const changed = sig(models, stale) !== sig(freeRowsRef.current, freeStaleRef.current);
|
|
@@ -2230,8 +2377,10 @@ function Root() {
|
|
|
2230
2377
|
sys(`${r.error} — run /model for the list`);
|
|
2231
2378
|
return undefined;
|
|
2232
2379
|
}
|
|
2380
|
+
if (r.note)
|
|
2381
|
+
sys(r.note);
|
|
2233
2382
|
setRoute(s.currentModel());
|
|
2234
|
-
|
|
2383
|
+
persist({ activeModel: s.currentModel() });
|
|
2235
2384
|
const chosen = s.modelRegistry().find((m) => m.id === s.currentModel());
|
|
2236
2385
|
sys(modelLine(s.currentModel(), chosen, s.ctxPct(), s.turnCount(), cost)); // a free row repeats its caveat here
|
|
2237
2386
|
// Arm the phase line's forecast of what the next message may re-read on this model (the line above names the cost).
|
|
@@ -2277,8 +2426,19 @@ function Root() {
|
|
|
2277
2426
|
});
|
|
2278
2427
|
const connectProvider = () => {
|
|
2279
2428
|
const { rows, choices } = providerPickerView(connectedAccounts(isConnected));
|
|
2280
|
-
openPicker("Connect a provider — then paste its API key", rows, choices, (a) => {
|
|
2281
|
-
|
|
2429
|
+
openPicker("Connect a provider — then paste its API key", rows, choices, (a) => {
|
|
2430
|
+
if (!("entry" in a))
|
|
2431
|
+
return;
|
|
2432
|
+
// A sign-in provider takes no pasted key: signed in, its rows are already in /model; signed out, say how.
|
|
2433
|
+
if (a.entry.p.signIn) {
|
|
2434
|
+
if (isConnected(a.entry.p.account, a.entry.p.endpoint))
|
|
2435
|
+
submitRef.current("/model");
|
|
2436
|
+
else
|
|
2437
|
+
sys(`${a.entry.p.label} uses your Operator sign-in — /login, then /model lists its models`);
|
|
2438
|
+
return;
|
|
2439
|
+
}
|
|
2440
|
+
askKey(a.entry);
|
|
2441
|
+
});
|
|
2282
2442
|
};
|
|
2283
2443
|
const active = s.currentModel();
|
|
2284
2444
|
// Two screens (0.1.361): the main rows + "More models…", which opens every other row and the connect action.
|
|
@@ -2313,7 +2473,7 @@ function Root() {
|
|
|
2313
2473
|
go();
|
|
2314
2474
|
return;
|
|
2315
2475
|
}
|
|
2316
|
-
const here = s.currentModel()
|
|
2476
|
+
const here = s.currentModel();
|
|
2317
2477
|
const est = s.compactionEstimate();
|
|
2318
2478
|
const v = rereadConfirmView({
|
|
2319
2479
|
target: a.entry.profile.label, current: here, cost,
|
|
@@ -2560,6 +2720,8 @@ function Root() {
|
|
|
2560
2720
|
},
|
|
2561
2721
|
onCompactionWrite: (w) => { if (compactRef.current)
|
|
2562
2722
|
compactRef.current.wrote = w; },
|
|
2723
|
+
onCompactionCoverage: (e) => { if (compactRef.current)
|
|
2724
|
+
Object.assign(compactRef.current, e, { ring: [], wrote: 0 }); },
|
|
2563
2725
|
});
|
|
2564
2726
|
sys(n > 0
|
|
2565
2727
|
? `compacted · freed ~${n.toLocaleString()} tokens · ctx ${beforePct}%→${s.ctxPct()}%`
|
|
@@ -2654,12 +2816,11 @@ function Root() {
|
|
|
2654
2816
|
// In-session IO: sys lines for output, the system opener for the browser. No poll dots in the TUI —
|
|
2655
2817
|
// a single "Waiting for approval…" line is clearer than a growing dot run next to the transcript.
|
|
2656
2818
|
const inkIO = { log: (m) => sys(m), error: (m) => sys(m), ask: async () => "", openBrowser };
|
|
2819
|
+
const signedIn = (token, who) => { setOperatorToken(token); setAuthUser(who); offerUpdateAfterSignIn(); };
|
|
2657
2820
|
const runBrowserLogin = async () => {
|
|
2658
2821
|
const r = await signInWithBrowser(inkIO);
|
|
2659
|
-
if (r.ok && r.account && r.token)
|
|
2660
|
-
|
|
2661
|
-
setAuthUser(r.account.email ?? r.account.external_id);
|
|
2662
|
-
}
|
|
2822
|
+
if (r.ok && r.account && r.token)
|
|
2823
|
+
signedIn(r.token, r.account.email ?? r.account.external_id);
|
|
2663
2824
|
else if (!r.ok && r.reason !== "denied")
|
|
2664
2825
|
sys("try /login <email> to sign in by code instead");
|
|
2665
2826
|
};
|
|
@@ -2685,10 +2846,9 @@ function Root() {
|
|
|
2685
2846
|
const v = await signupVerify(email, a);
|
|
2686
2847
|
if (v.ok) {
|
|
2687
2848
|
await saveCredentials({ token: v.token, user: v.account.external_id, host: authBase(), issuedAt: Date.now() });
|
|
2688
|
-
setOperatorToken(v.token);
|
|
2689
|
-
setAuthUser(v.account.email ?? v.account.external_id);
|
|
2690
2849
|
pendingLoginEmailRef.current = null;
|
|
2691
2850
|
sys(`✓ signed in as ${v.account.email ?? v.account.external_id}`);
|
|
2851
|
+
signedIn(v.token, v.account.email ?? v.account.external_id);
|
|
2692
2852
|
}
|
|
2693
2853
|
else if (v.error === "invalid_code")
|
|
2694
2854
|
sys("wrong code — /login <code> to try again");
|
|
@@ -2726,10 +2886,8 @@ function Root() {
|
|
|
2726
2886
|
}
|
|
2727
2887
|
// Otherwise treat it as a pasted personal access token (trimmed of stray whitespace/dots in sign-in.ts).
|
|
2728
2888
|
const rtok = await signInWithToken(a, inkIO);
|
|
2729
|
-
if (rtok.ok && rtok.account && rtok.token)
|
|
2730
|
-
|
|
2731
|
-
setAuthUser(rtok.account.email ?? rtok.account.external_id);
|
|
2732
|
-
}
|
|
2889
|
+
if (rtok.ok && rtok.account && rtok.token)
|
|
2890
|
+
signedIn(rtok.token, rtok.account.email ?? rtok.account.external_id);
|
|
2733
2891
|
else if (!rtok.ok)
|
|
2734
2892
|
sys("did you mean /login <email>?");
|
|
2735
2893
|
break;
|
|
@@ -2741,17 +2899,17 @@ function Root() {
|
|
|
2741
2899
|
if (a === "on") {
|
|
2742
2900
|
sys("enabling MCP tools…");
|
|
2743
2901
|
const n = await s.enableMcp();
|
|
2744
|
-
|
|
2902
|
+
persist({ mcp: true });
|
|
2745
2903
|
sys(n > 0 ? `MCP on · ${n} fleet tools available (saved — on for new sessions too)` : "MCP on (saved), but no tools were discovered — the MCP gateway may be unreachable; it retries next session");
|
|
2746
2904
|
}
|
|
2747
2905
|
else if (a === "off") {
|
|
2748
|
-
|
|
2906
|
+
persist({ mcp: false });
|
|
2749
2907
|
sys("MCP off for new sessions (saved) — tools already loaded stay until you restart");
|
|
2750
2908
|
}
|
|
2751
2909
|
else if (a === "reload") {
|
|
2752
2910
|
sys("reloading MCP from disk (base + the extra MCP config)…");
|
|
2753
2911
|
const n = await s.reloadMcp();
|
|
2754
|
-
|
|
2912
|
+
persist({ mcp: true });
|
|
2755
2913
|
sys(n > 0 ? `MCP reloaded · ${n} fleet tools` : "MCP reloaded, but no tools discovered — check mcp_servers.json and the extra MCP config");
|
|
2756
2914
|
}
|
|
2757
2915
|
else if (a === "add") {
|
|
@@ -2774,7 +2932,7 @@ function Root() {
|
|
|
2774
2932
|
env: { POWERTOOLS_ROOT: absRoot },
|
|
2775
2933
|
});
|
|
2776
2934
|
const n = await s.reloadMcp();
|
|
2777
|
-
|
|
2935
|
+
persist({ mcp: true });
|
|
2778
2936
|
sys(`powertools added · root=${absRoot} · wrote ${written} · ${n} fleet tools (alias: pt)`);
|
|
2779
2937
|
}
|
|
2780
2938
|
catch (e) {
|
|
@@ -2854,7 +3012,7 @@ function Root() {
|
|
|
2854
3012
|
const setGuard = (patch) => {
|
|
2855
3013
|
settings.delegate = { ...settings.delegate, ...patch };
|
|
2856
3014
|
setDelegateSettings(settings.delegate);
|
|
2857
|
-
|
|
3015
|
+
persist({ delegate: patch });
|
|
2858
3016
|
};
|
|
2859
3017
|
const status = () => {
|
|
2860
3018
|
const team = s.moaTeam();
|
|
@@ -2874,7 +3032,7 @@ function Root() {
|
|
|
2874
3032
|
}
|
|
2875
3033
|
const patch = { plannerModel: a.model, ...(executor ? { specialist: { id: executor } } : {}) };
|
|
2876
3034
|
settings.moa = { ...settings.moa, ...patch };
|
|
2877
|
-
|
|
3035
|
+
persist({ moa: patch });
|
|
2878
3036
|
const onMoa = s.currentModel() === "moa";
|
|
2879
3037
|
sys(`delegate · planner ${a.model} → executor ${s.moaTeam()?.specialist}${onMoa ? (turnRunning() ? " · from the next turn" : "") : " · switching to /model moa"}`);
|
|
2880
3038
|
if (!onMoa)
|
|
@@ -2888,7 +3046,7 @@ function Root() {
|
|
|
2888
3046
|
break;
|
|
2889
3047
|
}
|
|
2890
3048
|
settings.autonomy = { ...settings.autonomy, subagentModel: a.model };
|
|
2891
|
-
|
|
3049
|
+
persist({ autonomy: { subagentModel: a.model } });
|
|
2892
3050
|
sys(`delegate · sub-agents (spawn_agent, delegate_task default) run on ${a.model}${s.currentModel() === "moa" ? ` — under /model moa the executor ${s.moaTeam()?.specialist} takes them` : ""}`);
|
|
2893
3051
|
break;
|
|
2894
3052
|
}
|
|
@@ -2899,7 +3057,7 @@ function Root() {
|
|
|
2899
3057
|
else if (a.kind === "off") {
|
|
2900
3058
|
s.setMoaPlanner("");
|
|
2901
3059
|
settings.moa = { ...settings.moa, plannerModel: "" };
|
|
2902
|
-
|
|
3060
|
+
persist({ moa: { plannerModel: "" } });
|
|
2903
3061
|
setGuard({ guard: false, allowPush: false });
|
|
2904
3062
|
}
|
|
2905
3063
|
sys(status());
|
|
@@ -3067,8 +3225,8 @@ function Root() {
|
|
|
3067
3225
|
break;
|
|
3068
3226
|
}
|
|
3069
3227
|
case "services": {
|
|
3070
|
-
// The lever, on demand: `/services` probes + starts any down launchd service
|
|
3071
|
-
// tears down only the session-scoped SearXNG
|
|
3228
|
+
// The lever, on demand: `/services` probes + starts any down optional launchd service (never Aurora: retired,
|
|
3229
|
+
// reported only); `/services stop` tears down only the session-scoped SearXNG.
|
|
3072
3230
|
if (arg === "stop") {
|
|
3073
3231
|
const { stopSessionServices } = await import("./services/preflight.js");
|
|
3074
3232
|
await stopSessionServices({ searxng: true });
|
|
@@ -3196,6 +3354,18 @@ function Root() {
|
|
|
3196
3354
|
sys(id ? `spawned ${id} in the background — /bg to list · /bg stop ${id} to cancel` : bg.capacityLine());
|
|
3197
3355
|
}
|
|
3198
3356
|
break;
|
|
3357
|
+
case "voice": {
|
|
3358
|
+
const want = voiceIntent(arg, !!voiceRef.current);
|
|
3359
|
+
if (!want)
|
|
3360
|
+
sys("usage: /voice [on|off|status]");
|
|
3361
|
+
else if (want === "status")
|
|
3362
|
+
sys(voiceRef.current ? `voice on (${voiceRef.current.voice.state()}) · ${voiceRef.current.about}` : "voice off — /voice turns it on");
|
|
3363
|
+
else if (want === "off")
|
|
3364
|
+
sys(stopVoice() ? "voice off" : "voice is already off");
|
|
3365
|
+
else
|
|
3366
|
+
sys(voiceRef.current ? "voice is already on — ctrl+t to talk" : await startVoice());
|
|
3367
|
+
break;
|
|
3368
|
+
}
|
|
3199
3369
|
case "caffeinate":
|
|
3200
3370
|
case "caffeine": {
|
|
3201
3371
|
const want = arg === "off" ? false : arg === "on" ? true : !caffeineRef.current?.active;
|
|
@@ -3238,7 +3408,14 @@ function Root() {
|
|
|
3238
3408
|
let lost = false; // an outage is said once; the re-dials behind it are silent until the relay answers
|
|
3239
3409
|
const rh = new RemoteHost(urls, token, { title: `Operator · ${process.cwd().split("/").pop() || "session"}`, cwd: process.cwd(), host: hostname(), surface: "cli" }, {
|
|
3240
3410
|
onPrompt: remotePrompt, // follower drives a turn (slash-shaped → the allowlisted command path)
|
|
3241
|
-
onApprovalResponse: (id, approve) => settleApproval(id, approve), // first-wins with local
|
|
3411
|
+
onApprovalResponse: (id, approve, grant) => settleApproval(id, approve, false, grant), // first-wins with local
|
|
3412
|
+
onGrantRevoke: (req) => {
|
|
3413
|
+
if ("all" in req)
|
|
3414
|
+
grantsRef.current.revokeAll();
|
|
3415
|
+
else
|
|
3416
|
+
grantsRef.current.revoke(req.id);
|
|
3417
|
+
rh.setGrants(grantsRef.current.list());
|
|
3418
|
+
},
|
|
3242
3419
|
onAskUserResponse: (id, answer) => settleQuestion(id, answer), // first-wins with local
|
|
3243
3420
|
onInterrupt: () => s.interrupt(), // follower cancels the turn
|
|
3244
3421
|
// RC v2 B1: a follower tapped Stop/Steer on a sub-agent row → the SAME BackgroundAgents the local
|
|
@@ -3308,7 +3485,14 @@ function Root() {
|
|
|
3308
3485
|
let lost = false;
|
|
3309
3486
|
const rh = new RemoteHost(urls, token, { title: `Operator · ${process.cwd().split("/").pop() || "session"}`, cwd: process.cwd(), host: hostname(), surface: "cli" }, {
|
|
3310
3487
|
onPrompt: remotePrompt,
|
|
3311
|
-
onApprovalResponse: (id, approve) => settleApproval(id, approve),
|
|
3488
|
+
onApprovalResponse: (id, approve, grant) => settleApproval(id, approve, false, grant),
|
|
3489
|
+
onGrantRevoke: (req) => {
|
|
3490
|
+
if ("all" in req)
|
|
3491
|
+
grantsRef.current.revokeAll();
|
|
3492
|
+
else
|
|
3493
|
+
grantsRef.current.revoke(req.id);
|
|
3494
|
+
rh.setGrants(grantsRef.current.list());
|
|
3495
|
+
},
|
|
3312
3496
|
onAskUserResponse: (id, answer) => settleQuestion(id, answer),
|
|
3313
3497
|
onInterrupt: () => s.interrupt(),
|
|
3314
3498
|
onAgentStop: (id) => bgRef.current?.requestStop(id) ?? false, // RC v2 B1 (paired mode)
|
|
@@ -3691,6 +3875,8 @@ function Root() {
|
|
|
3691
3875
|
// that had already ended, quit the session). Ctrl-C at rest quits on the second press.
|
|
3692
3876
|
const quitArmedRef = useRef(0);
|
|
3693
3877
|
const onInterrupt = useCallback((key) => {
|
|
3878
|
+
if (key === "esc" && voiceRef.current?.voice.esc())
|
|
3879
|
+
return; // a recording, a transcription or playback: esc ends that and nothing else
|
|
3694
3880
|
if (statusRef.current !== "idle")
|
|
3695
3881
|
return session.interrupt();
|
|
3696
3882
|
const act = restKey(key, quitArmedRef.current, Date.now(), QUIT_CONFIRM_MS);
|
|
@@ -3767,11 +3953,15 @@ function Root() {
|
|
|
3767
3953
|
// no message is dropped. settings.wakeOnMentor.from narrows which senders may drive a turn (unset = any).
|
|
3768
3954
|
if (isFeatureEnabled("wakeOnMentor", settings)) {
|
|
3769
3955
|
const allow = settings.wakeOnMentor?.from;
|
|
3770
|
-
const eligible = allow?.length ? incoming.filter((m) => allow.includes(m.from)) : incoming;
|
|
3956
|
+
const eligible = (allow?.length ? incoming.filter((m) => allow.includes(m.from)) : incoming).filter((m) => !isAutoReport(m));
|
|
3771
3957
|
wakeBuffer.push(...eligible);
|
|
3772
3958
|
const ready = selectReadyWakes(wakeBuffer, lastWakeBySource, now, WAKE_COOLDOWN_MS);
|
|
3773
|
-
const
|
|
3959
|
+
const rootPolicy = allow?.length ? { roots: settings.wakeOnMentor?.roots ?? [join(homedir(), "work")] } : undefined;
|
|
3960
|
+
const wakeText = ready.length ? buildMentorWake(ready, undefined, rootPolicy) : null;
|
|
3774
3961
|
if (wakeText) {
|
|
3962
|
+
const dir = wakeRoot(wakeText);
|
|
3963
|
+
if (dir)
|
|
3964
|
+
sys(`↳ wake from ${[...new Set(ready.map((m) => m.from))].join(", ")}: this turn runs in ${dir} (from the brief)`);
|
|
3775
3965
|
if (statusRef.current === "idle")
|
|
3776
3966
|
submitRef.current?.(wakeText);
|
|
3777
3967
|
else
|
|
@@ -3793,8 +3983,8 @@ function Root() {
|
|
|
3793
3983
|
if (boot === "checking")
|
|
3794
3984
|
return _jsx(Text, { dimColor: true, children: bootDetail || "connecting to Operator…" });
|
|
3795
3985
|
if (boot === "down") {
|
|
3796
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: "red", children: "Can't reach Operator on the configured endpoint." }), bootDetail ? _jsx(Text, { dimColor: true, children: bootDetail }) : null, session.currentModel() ===
|
|
3797
|
-
?
|
|
3986
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: "red", children: "Can't reach Operator on the configured endpoint." }), bootDetail ? _jsx(Text, { dimColor: true, children: bootDetail }) : null, session.currentModel() === CHAIN_MODEL_ID
|
|
3987
|
+
? _jsx(Text, { dimColor: true, children: "No leg of the chain answered (the local router's main route, then the cloud tier). Check the router, or sign in for the cloud tier." })
|
|
3798
3988
|
: _jsxs(Text, { dimColor: true, children: ["Start on another model: set \"activeModel\" in settings.json to one /model lists, then /model ", session.currentModel(), " once it is reachable."] })] }));
|
|
3799
3989
|
}
|
|
3800
3990
|
// While a turn runs, show a LIVE line: braille spinner + climbing token count + live tok/s + elapsed
|
|
@@ -3842,20 +4032,20 @@ function Root() {
|
|
|
3842
4032
|
// The main turn as a lane (TUI plan #11): its model, its plan step and phase, its clock and tokens.
|
|
3843
4033
|
const stepAt = tasks.findIndex((t) => t.status === "in_progress");
|
|
3844
4034
|
const mainLane = status !== "idle" && shownPhase
|
|
3845
|
-
? { model: routeLabel(session.answeringModel()), activity: `${stepVerb && stepAt >= 0 ? `step ${stepAt + 1}/${tasks.length} · ` : ""}${phaseWord(shownPhase)}`, elapsedMs: elapsed * 1000, tokens: liveTok }
|
|
4035
|
+
? { model: shownModelLabel(routeLabel(session.answeringModel())), activity: `${stepVerb && stepAt >= 0 ? `step ${stepAt + 1}/${tasks.length} · ` : ""}${phaseWord(shownPhase)}`, elapsedMs: elapsed * 1000, tokens: liveTok }
|
|
3846
4036
|
: null;
|
|
3847
4037
|
const compactRead = compactRef.current ? readStats(compactRef.current.ring) : undefined;
|
|
3848
4038
|
const phaseView = shownPhase
|
|
3849
4039
|
? {
|
|
3850
|
-
phase: shownPhase, model: routeLabel(session.answeringModel()), tokens: liveTok, label: stepLabel,
|
|
4040
|
+
phase: shownPhase, model: shownModelLabel(routeLabel(session.answeringModel())), tokens: liveTok, label: stepLabel,
|
|
3851
4041
|
read: shownPhase === "reading" ? readStats(readRingRef.current, roundStartRef.current) : undefined,
|
|
3852
4042
|
queue: shownPhase === "queued" ? gateQueueRef.current ?? undefined : undefined,
|
|
3853
|
-
compaction: shownPhase === "compacting" && compactRef.current ? { before: compactRef.current.before, read: compactRead, wrote: compactRef.current.wrote, approx: vendorStream } : undefined,
|
|
4043
|
+
compaction: shownPhase === "compacting" && compactRef.current ? { before: compactRef.current.before, read: compactRead, wrote: compactRef.current.wrote, approx: vendorStream, covered: compactRef.current.covered, reading: compactRef.current.reading } : undefined,
|
|
3854
4044
|
expect: expectRef.current && (shownPhase === "waiting" || shownPhase === "sent") ? expectSegs(expectRef.current) : undefined,
|
|
3855
4045
|
decode: shownPhase === "thinking" || shownPhase === "writing" || shownPhase === "drafting" ? decodeView() : undefined,
|
|
3856
4046
|
}
|
|
3857
4047
|
: null;
|
|
3858
|
-
return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, phase: phaseView, fold: liveFold, delegate: delegate, thinkingVerb: stepVerb ?? triage ?? phaseVerb(shownPhase ?? undefined, phaseView?.read), liveTools: liveTools, route: route, ctxPct: ctxPct, ctxWindow: session.currentModel() === "moa" ? (ctxPin ? fmtCtx(ctxPin) : undefined) : fmtCtx(ctxPin ? Math.min(ctxPin, session.servedContext()) : session.servedContext()), 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, mainLane: mainLane, mainServing: servingModelFor(settings, session.currentModel()), maxRunning: bg.limits().running, onBackground: onBackground, tasks: tasks, planNow: planLive ? Date.now() : lastTurnEndRef.current, onSubmit: onSubmit, onQueue: onQueue, onSteer: onSteer, pending: pending, nextSteps: nextSteps ?? undefined, onPickNext: onPickNext, onDismissNext: onDismissNext, agents: bgAgents, onAgentMessage: onAgentMessage, conversations: convs, switcher: { focused: switcher.focused, sel: Math.max(0, convs.findIndex((c) => c.id === switcher.sel)), open: openConv }, onSwitcher: onSwitcher, onFocusSwitcher: onFocusSwitcher, conversationPane: conversationPane, onSendTo: onSendTo, actOffer: active ? actNowOffer(actRef.current, Date.now(), { thinking: thinkMode !== "off" }) : null, onActNow: onActNow, finder: finder, onOpenFinder: onOpenFinder, onEditQueued: popQueued, onDropQueued: onDropQueued, onInterrupt: onInterrupt, onExpand: onExpand, 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, update: updatePrompt, onApprovalDecide: (allow, always) => {
|
|
4048
|
+
return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, phase: phaseView, fold: liveFold, delegate: delegate, thinkingVerb: stepVerb ?? triage ?? phaseVerb(shownPhase ?? undefined, phaseView?.read), liveTools: liveTools, route: route, ctxPct: ctxPct, ctxWindow: session.currentModel() === "moa" ? (ctxPin ? fmtCtx(ctxPin) : undefined) : fmtCtx(ctxPin ? Math.min(ctxPin, session.servedContext()) : session.servedContext()), 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, mainLane: mainLane, mainServing: servingModelFor(settings, session.currentModel()), maxRunning: bg.limits().running, lanePool: bg.slotState().line, laneWarnings: bg.evidenceWarnings(), onBackground: onBackground, tasks: tasks, planNow: planLive ? Date.now() : lastTurnEndRef.current, onSubmit: onSubmit, onQueue: onQueue, onSteer: onSteer, pending: pending, nextSteps: nextSteps ?? undefined, onPickNext: onPickNext, onDismissNext: onDismissNext, agents: bgAgents, onAgentMessage: onAgentMessage, conversations: convs, switcher: { focused: switcher.focused, sel: Math.max(0, convs.findIndex((c) => c.id === switcher.sel)), open: openConv }, onSwitcher: onSwitcher, onFocusSwitcher: onFocusSwitcher, conversationPane: conversationPane, onSendTo: onSendTo, actOffer: active ? actNowOffer(actRef.current, Date.now(), { thinking: thinkMode !== "off" }) : null, onActNow: onActNow, finder: finder, onOpenFinder: onOpenFinder, onEditQueued: popQueued, onDropQueued: onDropQueued, onInterrupt: onInterrupt, onExpand: onExpand, onCycleMode: onCycleMode, onCycleContext: onCycleContext, opMode: opMode, rcConnected: rcConnected, rcActive: rcActive, caffeinated: caffeinated, voice: voiceUi, onVoiceKey: onVoiceKey, approval: approval, question: question, modelPicker: modelPicker, secretPrompt: secretPrompt, planExitPicker: planExitPicker, artifactsPicker: artifactsPicker, sessionsPicker: sessionsPicker, update: updatePrompt, onApprovalDecide: (allow, always) => {
|
|
3859
4049
|
const cur = approval;
|
|
3860
4050
|
if (cur)
|
|
3861
4051
|
settleApproval(cur.id, allow, always); // first-wins with any remote follower answer
|
|
@@ -3866,7 +4056,13 @@ function Root() {
|
|
|
3866
4056
|
// (--version/--help fast paths hoisted to the top of the module — they must never touch keychain/network.)
|
|
3867
4057
|
if (process.argv[2] === "auth") {
|
|
3868
4058
|
const { runAuth } = await import("./auth/commands.js");
|
|
3869
|
-
|
|
4059
|
+
const code = await runAuth(process.argv.slice(3), settings);
|
|
4060
|
+
if (code === 0 && process.argv[3] === "login") {
|
|
4061
|
+
const offer = await checkOnSignIn();
|
|
4062
|
+
if (offer)
|
|
4063
|
+
console.log(`\n${(await import("./update-check.js")).offerLine(offer)}`);
|
|
4064
|
+
}
|
|
4065
|
+
process.exit(code);
|
|
3870
4066
|
}
|
|
3871
4067
|
// `operator audit verify|tail` and `operator doctor` — the enterprise review surface: prove the audit trail is
|
|
3872
4068
|
// intact, and show exactly what policy/seat/home posture is in force. Plain console, no TTY needed.
|