@0perator/operator 0.2.1 → 0.2.2-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/auth/byo.js +1 -1
- package/dist/auth/commands.js +8 -2
- package/dist/autonomy/agent-cli.js +1 -1
- package/dist/autonomy/headless.js +30 -6
- package/dist/autonomy/pr-isolation.js +92 -0
- package/dist/autonomy/pr-preflight.js +474 -0
- package/dist/autonomy/session-factory.js +2 -0
- package/dist/browser/capture.js +505 -0
- package/dist/browser/engine.js +4 -3
- package/dist/browser/page-capture.js +167 -0
- package/dist/browser/png.js +116 -0
- package/dist/browser/visual-compare.js +229 -0
- package/dist/bus/beam-drop.js +55 -0
- package/dist/bus/inbox.js +7 -1
- package/dist/cli.js +130 -26
- package/dist/config/managed.js +40 -1
- package/dist/config/persona.js +86 -41
- package/dist/config/product-hosts.js +2 -0
- package/dist/config/settings.js +30 -13
- package/dist/config/skills-index.js +37 -14
- package/dist/engine/agent.js +1 -1
- package/dist/engine/aurora.js +18 -9
- package/dist/engine/continuation.js +36 -0
- package/dist/engine/identity.js +42 -0
- package/dist/engine/moa.js +7 -0
- package/dist/engine/net-error.js +15 -0
- package/dist/engine/rolling-summary.js +142 -93
- package/dist/engine/waterfall.js +33 -0
- package/dist/gateway-cli.js +10 -1
- package/dist/memory/session-index.js +3 -3
- package/dist/permissions/index.js +2 -1
- package/dist/permissions/policy.js +9 -2
- package/dist/permissions/tier.js +9 -1
- package/dist/products/craft.js +90 -1
- package/dist/products/temple.js +20 -1
- package/dist/products/voice.js +112 -0
- package/dist/router/free-models.js +5 -9
- package/dist/router/models.js +58 -14
- package/dist/router/provider-models.js +78 -0
- package/dist/router/router.js +15 -3
- package/dist/selfimprove/lessons.js +23 -0
- package/dist/session.js +192 -87
- package/dist/skills/catalogue.js +5 -2
- package/dist/skills/finder.js +4 -4
- package/dist/skills/install-guard.js +1 -1
- package/dist/tools/beam.js +246 -0
- package/dist/tools/craft.js +23 -0
- package/dist/tools/deferred.js +7 -3
- package/dist/tools/doc-text.js +1 -1
- package/dist/tools/registry.js +55 -9
- package/dist/tools/sandbox.js +6 -6
- package/dist/ui/App.js +3 -3
- package/dist/ui/ApprovalPrompt.js +1 -1
- package/dist/ui/Composer.js +44 -2
- package/dist/ui/StatusRule.js +2 -1
- package/dist/ui/Transcript.js +5 -0
- package/dist/ui/modelPicker.js +10 -6
- package/dist/ui/phase.js +4 -2
- package/dist/ui/slashCommands.js +1 -0
- package/dist/ui/voice.js +185 -0
- package/dist/update.js +1 -2
- package/dist/util/audio-io.js +82 -0
- package/dist/util/slash.js +2 -2
- package/dist/vision/pairs.js +239 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ 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
18
|
import { GrantStore, grantsEnabled } from "./remote/grants.js";
|
|
19
19
|
import { REMOTE_SAFE_COMMANDS, REMOTE_SAFE_COMMAND_NAMES } from "./remote/safe-commands.js";
|
|
@@ -45,7 +45,7 @@ import { loadSettings, saveSettings, settingsLoadProblems, compactionThreshold,
|
|
|
45
45
|
import { resolveSeat } from "./auth/identity.js";
|
|
46
46
|
import { PermissionPolicy } from "./permissions/index.js";
|
|
47
47
|
import { caps } from "./ui/capabilities.js";
|
|
48
|
-
import { composeSystemPrompt, appendMemory, memoryBudgetNote, subagentSystemPrompt } from "./config/persona.js";
|
|
48
|
+
import { composeSystemPrompt, appendMemory, memoryBudgetNote, subagentSystemPrompt, handoffNotice } from "./config/persona.js";
|
|
49
49
|
import { SUBAGENT_ROLES, SUBAGENT_TOOL_DENY, roleCanWrite } from "./engine/grandmaster.js";
|
|
50
50
|
import { applyToolsBinPath, operatorPath } from "./config/home.js";
|
|
51
51
|
import { ensureOperatorHome } from "./config/scaffold.js";
|
|
@@ -53,8 +53,10 @@ import { listLocalSkills, skillCommand } from "./config/skills-index.js";
|
|
|
53
53
|
import { modelCtxFor, leanHarnessFor, selectModel, modelRegistry, fmtCtx, shortName, BYO_PRESETS, CHAIN_MODEL_ID } from "./router/models.js";
|
|
54
54
|
import { fetchPortalModels, offlineNote, portalIdFor } from "./router/portal.js";
|
|
55
55
|
import { fetchFreeModels } from "./router/free-models.js";
|
|
56
|
+
import { fetchProviderModels } from "./router/provider-models.js";
|
|
56
57
|
import { describeTurnError } from "./engine/net-error.js";
|
|
57
|
-
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";
|
|
58
60
|
import { speedCompactionLine } from "./engine/speed-compaction.js";
|
|
59
61
|
import { hasByoToken, setByoToken } from "./auth/byo.js";
|
|
60
62
|
import { getDiscoveredModels } from "./router/discovery.js";
|
|
@@ -69,6 +71,9 @@ import { reportLine, deliveredLine } from "./ui/reportLine.js";
|
|
|
69
71
|
import { pushCollapsed, popCollapsed, dropCollapsed } from "./ui/expand.js";
|
|
70
72
|
import { ensureScratchDir } from "./config/scratch.js";
|
|
71
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";
|
|
72
77
|
import { recordLiveProgress, roundProgressed, settleLiveProgress, touchedPaths } from "./memory/live-progress.js";
|
|
73
78
|
import { lastActiveAt as idleLastActiveAt, resolveIdlePolicy, startIdleMonitor, touchWork } from "./idle/index.js";
|
|
74
79
|
import { disposeBrowserNow } from "./browser/session.js";
|
|
@@ -79,7 +84,7 @@ import { Teardown } from "./util/teardown.js";
|
|
|
79
84
|
import { installProcessTeardown } from "./session-teardown.js";
|
|
80
85
|
import { createStoreClient, resolveStoreKey } from "./services/store-sync.js";
|
|
81
86
|
import { reapStaleChildren } from "./util/owned-children.js";
|
|
82
|
-
import { readFileSync, writeFileSync, mkdirSync, readdirSync, statSync, existsSync } from "node:fs";
|
|
87
|
+
import { readFileSync, writeFileSync, mkdirSync, mkdtempSync, readdirSync, rmSync, statSync, existsSync } from "node:fs";
|
|
83
88
|
import { expandFileMentions } from "./util/mentions.js";
|
|
84
89
|
import { snapshotEphemeralImages } from "./util/screenshots.js";
|
|
85
90
|
import { isFeatureEnabled } from "./config/features.js";
|
|
@@ -87,6 +92,7 @@ import { classifyActVsAsk, actAskGateDirective } from "./engine/classifier.js";
|
|
|
87
92
|
import { resolveMode } from "./classifier/modes.js";
|
|
88
93
|
import { subagentModelFor, servingModelFor, delegateRouteFor } from "./autonomy/subagent-model.js";
|
|
89
94
|
import { parseDelegate, delegateStatusLines, delegateGuardOn, setDelegateSettings } from "./autonomy/delegate-mode.js";
|
|
95
|
+
import { setPrPreflightSettings } from "./autonomy/pr-preflight.js";
|
|
90
96
|
import { classifierConfig } from "./classifier/config.js";
|
|
91
97
|
import { throttle } from "./util/throttle.js";
|
|
92
98
|
import { isSlashCommand } from "./util/slash.js";
|
|
@@ -104,7 +110,7 @@ import { catalogEntry, continuationContext, folderExists, indexCatalog, searchCa
|
|
|
104
110
|
import { titleFrom } from "./memory/session-sources.js";
|
|
105
111
|
import { execFile } from "node:child_process";
|
|
106
112
|
import { join, dirname } from "node:path";
|
|
107
|
-
import { homedir, hostname } from "node:os";
|
|
113
|
+
import { homedir, hostname, tmpdir } from "node:os";
|
|
108
114
|
import { createHash, randomUUID } from "node:crypto";
|
|
109
115
|
// RELEASE CHECKLIST (every bump): update this + package.json "version", ADD A CHANGELOG.md ENTRY
|
|
110
116
|
// (improvements / fixes / tests), run the suite, then publish to npm + push both remotes.
|
|
@@ -166,6 +172,7 @@ const settings = loadSettings();
|
|
|
166
172
|
for (const p of settingsLoadProblems())
|
|
167
173
|
process.stderr.write(`[operator] ⚠ settings: ${p}\n`);
|
|
168
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
|
|
169
176
|
// Enterprise first-run: make the operator home's contract explicit BEFORE any module writes into it (0700
|
|
170
177
|
// root, ignore-everything .gitignore, README, settings.example.json, home.json). Idempotent, never throws.
|
|
171
178
|
const HOME_SCAFFOLD = ensureOperatorHome({ version: VERSION });
|
|
@@ -200,6 +207,8 @@ if (settings.selfImprove?.memory === false)
|
|
|
200
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
|
|
201
208
|
if (settings.verifyGate?.enabled === false)
|
|
202
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
|
|
203
212
|
if (settings.verifyGate?.maxNudges != null)
|
|
204
213
|
process.env.KODE_VERIFY_GATE_MAX = String(settings.verifyGate.maxNudges);
|
|
205
214
|
if (settings.background?.maxConcurrent != null)
|
|
@@ -232,7 +241,7 @@ if (settings.services?.stopOnExit?.searxng === false)
|
|
|
232
241
|
process.env.KODE_STOP_SEARXNG_ON_EXIT = "0";
|
|
233
242
|
// Remote-engine auth. When this Operator points at a REMOTE engine (KODE_AURORA=https://api.axe.onl),
|
|
234
243
|
// the gateway fronts the model with operator-token auth, so the model call must carry the bearer. Load
|
|
235
|
-
// 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
|
|
236
245
|
// never receives it (aurora.ts only sends to a non-loopback base), so this is safe on JL1 and costs
|
|
237
246
|
// nothing there. This is what lets a thin client (a 4 GB MacBook) run Operator against JL1's Aurora.
|
|
238
247
|
let bootCreds = null;
|
|
@@ -494,9 +503,8 @@ async function checkOnSignIn() {
|
|
|
494
503
|
const { isSourceCheckout } = await import("./update.js");
|
|
495
504
|
return checkAfterSignIn(VERSION, { env: process.env, tty: !!process.stdin.isTTY && !!process.stdout.isTTY, settings, sourceCheckout: isSourceCheckout() });
|
|
496
505
|
}
|
|
497
|
-
// Build the endpoint router
|
|
498
|
-
//
|
|
499
|
-
// 1,048,576-token context at full speed). No size-based routing decision remains.
|
|
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.
|
|
500
508
|
function buildRouter() {
|
|
501
509
|
// Primary first; the fleet nodes + optional failover + cloud tier are reached only via the router's
|
|
502
510
|
// health-gated recover() when the current endpoint errors/degrades (routeBySize always picks the primary
|
|
@@ -612,6 +620,7 @@ const HELP = [
|
|
|
612
620
|
" /sessions [query] search Operator's and other agents' sessions (providers in agents.md) and pick one up",
|
|
613
621
|
" /plan plan mode: read-only research + propose a plan (/plan again to execute)",
|
|
614
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",
|
|
615
624
|
" /think extended reasoning: Operator thinks before answering (/think again = off)",
|
|
616
625
|
" /ultrathink deep, exhaustive reasoning for hard problems (/ultrathink again = off)",
|
|
617
626
|
" /compact force-compact the conversation now",
|
|
@@ -632,6 +641,7 @@ const HELP = [
|
|
|
632
641
|
"esc — interrupt a running turn (or quit when idle); after a stop, 1-4 pick the next step",
|
|
633
642
|
"ctrl+y — use what you have: cut a long reasoning stream (or a loop) short and answer from what it has (think-off)",
|
|
634
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",
|
|
635
645
|
"ctrl+o — expand the latest collapsed batch or sub-agent report; press again for the one before it",
|
|
636
646
|
"↓ on an empty input: the conversation switcher (main + each sub-agent) · ←/→ pick · enter opens it · type to talk to it",
|
|
637
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",
|
|
@@ -806,7 +816,7 @@ function Root() {
|
|
|
806
816
|
}, []);
|
|
807
817
|
const approveFn = useCallback((name, args, ctx) => {
|
|
808
818
|
if (!ctx?.once && alwaysAllowRef.current.has(name))
|
|
809
|
-
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
|
|
810
820
|
if (!ctx?.once && grantsEnabled() && grantsRef.current.use(name, args, SESSION_ID)) {
|
|
811
821
|
remoteRef.current?.setGrants(grantsRef.current.list()); // the use count moved
|
|
812
822
|
return Promise.resolve(true);
|
|
@@ -943,7 +953,7 @@ function Root() {
|
|
|
943
953
|
const mgr = bgRef.current;
|
|
944
954
|
if (!mgr)
|
|
945
955
|
return "background manager not ready yet — retry in a moment";
|
|
946
|
-
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
|
|
947
957
|
if (!id) {
|
|
948
958
|
const stopped = mgr.requestStopAll("orchestrator", by);
|
|
949
959
|
return stopped.length ? `stopped ${stopped.length} sub-agent(s): ${stopped.join(", ")}.` : "no running or queued sub-agents to stop.";
|
|
@@ -1127,6 +1137,7 @@ function Root() {
|
|
|
1127
1137
|
} };
|
|
1128
1138
|
const push = (e) => setEntries((prev) => [...prev, e]);
|
|
1129
1139
|
const submitRef = useRef(() => { });
|
|
1140
|
+
const voiceRef = useRef(null); // /voice: set only while voice mode is on
|
|
1130
1141
|
const slashRef = useRef(async () => { }); // handleSlash, awaitable (the drain runs staged commands in order)
|
|
1131
1142
|
// AXE skills fetched/saved THIS session (name -> a best-effort description) — there's no persistent
|
|
1132
1143
|
// skill-loader/registry in this codebase to read from (skills are hub-fetched on demand by the
|
|
@@ -1273,6 +1284,9 @@ function Root() {
|
|
|
1273
1284
|
const sxUp = await probeSearxng().catch(() => false);
|
|
1274
1285
|
push({ kind: "message", message: { id: nextId(), role: "system", content: `services: ${line} · searxng ${sxUp ? "✓" : "lazy"}` } });
|
|
1275
1286
|
}
|
|
1287
|
+
const earlier = handoffNotice();
|
|
1288
|
+
if (earlier)
|
|
1289
|
+
push({ kind: "message", message: { id: nextId(), role: "system", content: earlier } });
|
|
1276
1290
|
// Remote-control auto-start (rcAutostart: explicit remote.autostart / KODE_RC_AUTOSTART wins, else
|
|
1277
1291
|
// ON for admin/VIP tier only — feature-flagged rollout). When enabled and this box is signed in, bring
|
|
1278
1292
|
// up an RC host on boot by driving the EXACT /remotecontrol path
|
|
@@ -1383,7 +1397,7 @@ function Root() {
|
|
|
1383
1397
|
noteWait(ledgerRef.current, Math.max(0, held));
|
|
1384
1398
|
if (held < HOLD_RECEIPT_MS)
|
|
1385
1399
|
return;
|
|
1386
|
-
sys(holdReceipt(routeLabel(session.answeringModel()), held, termCols()));
|
|
1400
|
+
sys(holdReceipt(shownModelLabel(routeLabel(session.answeringModel())), held, termCols()));
|
|
1387
1401
|
};
|
|
1388
1402
|
// The round's first reasoning/content chunk: a read of RECEIPT_MIN_MS or more settles one dim receipt into scrollback
|
|
1389
1403
|
// (and to followers) — what was read, how fast, what was cached, when the first token came.
|
|
@@ -1401,7 +1415,7 @@ function Root() {
|
|
|
1401
1415
|
if (!st || st.elapsedMs < RECEIPT_MIN_MS)
|
|
1402
1416
|
return;
|
|
1403
1417
|
readReceiptRef.current = true;
|
|
1404
|
-
sys(readReceipt(st, termCols(), { model: routeLabel(session.answeringModel()), firstTokenMs: Date.now() - turnStartRef.current }));
|
|
1418
|
+
sys(readReceipt(st, termCols(), { model: shownModelLabel(routeLabel(session.answeringModel())), firstTokenMs: Date.now() - turnStartRef.current }));
|
|
1405
1419
|
};
|
|
1406
1420
|
const startTurn = useCallback(async (text, opts) => {
|
|
1407
1421
|
setNextSteps(null); // a new turn retires the last stop's one-key strip
|
|
@@ -1417,7 +1431,7 @@ function Root() {
|
|
|
1417
1431
|
// Sub-agent reports read as ONE hand-off line for the owner; the model still gets every report in full, unchanged.
|
|
1418
1432
|
const heads = [
|
|
1419
1433
|
...(jobs ? jobs.split("\n\n").map((n) => "⤷ " + n.split("\n")[0].replace(/^\[system notice\] /, "")) : []),
|
|
1420
|
-
...(owners.length ? [deliveredLine(owners, routeLabel(session.currentModel()), termCols())] : []),
|
|
1434
|
+
...(owners.length ? [deliveredLine(owners, shownModelLabel(routeLabel(session.currentModel())), termCols())] : []),
|
|
1421
1435
|
].join("\n");
|
|
1422
1436
|
push({ kind: "message", message: { id: nextId(), role: "system", content: heads } });
|
|
1423
1437
|
remoteRef.current?.system(heads);
|
|
@@ -1527,6 +1541,8 @@ function Root() {
|
|
|
1527
1541
|
},
|
|
1528
1542
|
onCompactionWrite: (n) => { if (compactRef.current)
|
|
1529
1543
|
compactRef.current.wrote = n; }, // drawn on the 500 ms clock, not per delta
|
|
1544
|
+
onCompactionCoverage: (e) => { if (compactRef.current)
|
|
1545
|
+
Object.assign(compactRef.current, e, { ring: [], wrote: 0 }); }, // a new pass: its own read and write
|
|
1530
1546
|
onCompactionEnd: ({ before, after }) => {
|
|
1531
1547
|
const c = compactRef.current;
|
|
1532
1548
|
compactRef.current = null;
|
|
@@ -1628,7 +1644,7 @@ function Root() {
|
|
|
1628
1644
|
if (lastFallbackRef.current === key)
|
|
1629
1645
|
return;
|
|
1630
1646
|
lastFallbackRef.current = key;
|
|
1631
|
-
sys(
|
|
1647
|
+
sys(gatewayFallbackLine({ from: fallbackFrom, backend }));
|
|
1632
1648
|
},
|
|
1633
1649
|
onPrimaryRestored: (backend) => {
|
|
1634
1650
|
// The primary answered again after we'd been on a fallback: clear the degraded state and say so ONCE, so a
|
|
@@ -1831,6 +1847,7 @@ function Root() {
|
|
|
1831
1847
|
const shown = outcome.display ?? outcome.content; // an engine stop reads as a question, not a bracketed note
|
|
1832
1848
|
push({ kind: "message", message: { id: nextId(), role: "assistant", content: shown, reasoning } });
|
|
1833
1849
|
remoteRef.current?.finalAssistant(shown, reasoning);
|
|
1850
|
+
voiceRef.current?.voice.answer(shown); // voice mode speaks a short version of the final answer
|
|
1834
1851
|
// An engine stop's question is answered with one key: its own options, verbatim. A reply cut by the repetition
|
|
1835
1852
|
// check is stashed for "show what it had" — on screen only; the engine keeps it out of history by design.
|
|
1836
1853
|
if (outcome.stopKind) {
|
|
@@ -2086,6 +2103,62 @@ function Root() {
|
|
|
2086
2103
|
}
|
|
2087
2104
|
catch { /* unreadable memory files are reported elsewhere */ }
|
|
2088
2105
|
}, [boot]);
|
|
2106
|
+
// /voice — speech in and out around THIS session (ui/voice.ts): what was said becomes the owner's turn as text, the
|
|
2107
|
+
// session's model answers as usual, and the answer is spoken. The recorder and player are owned children; the scratch
|
|
2108
|
+
// directory holds a recording or a reply only while it is in use.
|
|
2109
|
+
const [voiceUi, setVoiceUi] = useState(null);
|
|
2110
|
+
const stopVoice = useCallback(() => {
|
|
2111
|
+
const v = voiceRef.current;
|
|
2112
|
+
if (!v)
|
|
2113
|
+
return false;
|
|
2114
|
+
voiceRef.current = null;
|
|
2115
|
+
v.voice.off();
|
|
2116
|
+
try {
|
|
2117
|
+
rmSync(v.dir, { recursive: true, force: true });
|
|
2118
|
+
}
|
|
2119
|
+
catch { /* best-effort */ }
|
|
2120
|
+
setVoiceUi(null);
|
|
2121
|
+
return true;
|
|
2122
|
+
}, []);
|
|
2123
|
+
const startVoice = useCallback(async () => {
|
|
2124
|
+
const recorder = pickRecorder(), player = pickPlayer();
|
|
2125
|
+
if (!recorder)
|
|
2126
|
+
return `${installHint("recorder")} — voice stays off`;
|
|
2127
|
+
if (!player)
|
|
2128
|
+
return `${installHint("player")} — voice stays off`;
|
|
2129
|
+
const cfg = voiceConfig(settings.services?.voice);
|
|
2130
|
+
const found = await findVoiceGateway(cfg);
|
|
2131
|
+
if ("error" in found)
|
|
2132
|
+
return `${found.error} — voice stays off`;
|
|
2133
|
+
if (voiceRef.current)
|
|
2134
|
+
return "voice is already on — ctrl+t to talk";
|
|
2135
|
+
const dir = mkdtempSync(join(tmpdir(), "operator-voice-"));
|
|
2136
|
+
const voice = createVoice({
|
|
2137
|
+
record: () => recordWav(recorder, dir),
|
|
2138
|
+
play: (wav) => playWav(player, dir, wav),
|
|
2139
|
+
transcribe: (wav, onWait) => transcribe(found.ok, cfg, wav, { onWait }),
|
|
2140
|
+
speak: (text, onWait) => speak(found.ok, cfg, text, { onWait }),
|
|
2141
|
+
onHeard: (text) => submitRef.current(text),
|
|
2142
|
+
onState: (state, note) => {
|
|
2143
|
+
const line = voiceLine(state, { note, autoStop: recorder.autoStop });
|
|
2144
|
+
setVoiceUi(line ? { line, recording: state === "recording" } : null);
|
|
2145
|
+
},
|
|
2146
|
+
onError: (line) => sys(`voice: ${line}`),
|
|
2147
|
+
});
|
|
2148
|
+
voiceRef.current = { voice, dir, about: `recorder ${recorder.bin} · player ${player.bin} · ${found.ok.label} · routes ${cfg.sttRoute}, ${cfg.ttsRoute}` };
|
|
2149
|
+
voice.on();
|
|
2150
|
+
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)`;
|
|
2151
|
+
}, [sys]);
|
|
2152
|
+
const onVoiceKey = useCallback(() => {
|
|
2153
|
+
if (voiceRef.current)
|
|
2154
|
+
voiceRef.current.voice.key();
|
|
2155
|
+
else
|
|
2156
|
+
sys("voice is off — /voice turns it on");
|
|
2157
|
+
}, [sys]);
|
|
2158
|
+
useEffect(() => {
|
|
2159
|
+
teardown.add("voice", () => { stopVoice(); }, { order: 25 });
|
|
2160
|
+
return () => { stopVoice(); };
|
|
2161
|
+
}, [stopVoice]);
|
|
2089
2162
|
// Say so when this launch cleaned up after a previous one — silently killing processes would be worse than the orphans.
|
|
2090
2163
|
useEffect(() => {
|
|
2091
2164
|
const n = REAPED.killed.length;
|
|
@@ -2236,12 +2309,16 @@ function Root() {
|
|
|
2236
2309
|
}, [openPicker, applyContext, sys]);
|
|
2237
2310
|
// ctrl+x: the next stop of auto → 300K → 600K → 1M → auto, through the same path /context takes.
|
|
2238
2311
|
const onCycleContext = useCallback(() => { applyContext(nextContextPin(session.contextPin())); }, [applyContext]);
|
|
2239
|
-
// The free rows behind a connected free-tier key (FREE_ROW_PRESETS)
|
|
2240
|
-
// never waits on them. Resolves true when the rows
|
|
2312
|
+
// The free rows behind a connected free-tier key (FREE_ROW_PRESETS) and a signed-in provider's own rows
|
|
2313
|
+
// (PROVIDER_ROW_PRESETS): ≤4 s, then their caches, so a picker never waits on them. Resolves true when the rows
|
|
2314
|
+
// changed — an open picker redraws only for news.
|
|
2241
2315
|
const refreshFreeRows = useCallback(async (isConnected) => {
|
|
2242
|
-
const
|
|
2243
|
-
const lists = await Promise.all(
|
|
2244
|
-
|
|
2316
|
+
const live = (keys) => keys.filter((k) => BYO_PRESETS[k] && isConnected(BYO_PRESETS[k].account, BYO_PRESETS[k].endpoint));
|
|
2317
|
+
const [lists, providerRows] = await Promise.all([
|
|
2318
|
+
Promise.all(live(FREE_ROW_PRESETS).map((k) => fetchFreeModels(BYO_PRESETS[k]))),
|
|
2319
|
+
Promise.all(live(PROVIDER_ROW_PRESETS).map((k) => fetchProviderModels(k, BYO_PRESETS[k]))),
|
|
2320
|
+
]);
|
|
2321
|
+
const models = [...providerRows.flat(), ...lists.flatMap((l) => l.models)];
|
|
2245
2322
|
const stale = lists.some((l) => l.stale);
|
|
2246
2323
|
const sig = (ms, st) => `${st}|${ms.map((m) => m.id).join(",")}`;
|
|
2247
2324
|
const changed = sig(models, stale) !== sig(freeRowsRef.current, freeStaleRef.current);
|
|
@@ -2352,8 +2429,19 @@ function Root() {
|
|
|
2352
2429
|
});
|
|
2353
2430
|
const connectProvider = () => {
|
|
2354
2431
|
const { rows, choices } = providerPickerView(connectedAccounts(isConnected));
|
|
2355
|
-
openPicker("Connect a provider — then paste its API key", rows, choices, (a) => {
|
|
2356
|
-
|
|
2432
|
+
openPicker("Connect a provider — then paste its API key", rows, choices, (a) => {
|
|
2433
|
+
if (!("entry" in a))
|
|
2434
|
+
return;
|
|
2435
|
+
// A sign-in provider takes no pasted key: signed in, its rows are already in /model; signed out, say how.
|
|
2436
|
+
if (a.entry.p.signIn) {
|
|
2437
|
+
if (isConnected(a.entry.p.account, a.entry.p.endpoint))
|
|
2438
|
+
submitRef.current("/model");
|
|
2439
|
+
else
|
|
2440
|
+
sys(`${a.entry.p.label} uses your Operator sign-in — /login, then /model lists its models`);
|
|
2441
|
+
return;
|
|
2442
|
+
}
|
|
2443
|
+
askKey(a.entry);
|
|
2444
|
+
});
|
|
2357
2445
|
};
|
|
2358
2446
|
const active = s.currentModel();
|
|
2359
2447
|
// Two screens (0.1.361): the main rows + "More models…", which opens every other row and the connect action.
|
|
@@ -2635,6 +2723,8 @@ function Root() {
|
|
|
2635
2723
|
},
|
|
2636
2724
|
onCompactionWrite: (w) => { if (compactRef.current)
|
|
2637
2725
|
compactRef.current.wrote = w; },
|
|
2726
|
+
onCompactionCoverage: (e) => { if (compactRef.current)
|
|
2727
|
+
Object.assign(compactRef.current, e, { ring: [], wrote: 0 }); },
|
|
2638
2728
|
});
|
|
2639
2729
|
sys(n > 0
|
|
2640
2730
|
? `compacted · freed ~${n.toLocaleString()} tokens · ctx ${beforePct}%→${s.ctxPct()}%`
|
|
@@ -3267,6 +3357,18 @@ function Root() {
|
|
|
3267
3357
|
sys(id ? `spawned ${id} in the background — /bg to list · /bg stop ${id} to cancel` : bg.capacityLine());
|
|
3268
3358
|
}
|
|
3269
3359
|
break;
|
|
3360
|
+
case "voice": {
|
|
3361
|
+
const want = voiceIntent(arg, !!voiceRef.current);
|
|
3362
|
+
if (!want)
|
|
3363
|
+
sys("usage: /voice [on|off|status]");
|
|
3364
|
+
else if (want === "status")
|
|
3365
|
+
sys(voiceRef.current ? `voice on (${voiceRef.current.voice.state()}) · ${voiceRef.current.about}` : "voice off — /voice turns it on");
|
|
3366
|
+
else if (want === "off")
|
|
3367
|
+
sys(stopVoice() ? "voice off" : "voice is already off");
|
|
3368
|
+
else
|
|
3369
|
+
sys(voiceRef.current ? "voice is already on — ctrl+t to talk" : await startVoice());
|
|
3370
|
+
break;
|
|
3371
|
+
}
|
|
3270
3372
|
case "caffeinate":
|
|
3271
3373
|
case "caffeine": {
|
|
3272
3374
|
const want = arg === "off" ? false : arg === "on" ? true : !caffeineRef.current?.active;
|
|
@@ -3776,6 +3878,8 @@ function Root() {
|
|
|
3776
3878
|
// that had already ended, quit the session). Ctrl-C at rest quits on the second press.
|
|
3777
3879
|
const quitArmedRef = useRef(0);
|
|
3778
3880
|
const onInterrupt = useCallback((key) => {
|
|
3881
|
+
if (key === "esc" && voiceRef.current?.voice.esc())
|
|
3882
|
+
return; // a recording, a transcription or playback: esc ends that and nothing else
|
|
3779
3883
|
if (statusRef.current !== "idle")
|
|
3780
3884
|
return session.interrupt();
|
|
3781
3885
|
const act = restKey(key, quitArmedRef.current, Date.now(), QUIT_CONFIRM_MS);
|
|
@@ -3931,20 +4035,20 @@ function Root() {
|
|
|
3931
4035
|
// The main turn as a lane (TUI plan #11): its model, its plan step and phase, its clock and tokens.
|
|
3932
4036
|
const stepAt = tasks.findIndex((t) => t.status === "in_progress");
|
|
3933
4037
|
const mainLane = status !== "idle" && shownPhase
|
|
3934
|
-
? { model: routeLabel(session.answeringModel()), activity: `${stepVerb && stepAt >= 0 ? `step ${stepAt + 1}/${tasks.length} · ` : ""}${phaseWord(shownPhase)}`, elapsedMs: elapsed * 1000, tokens: liveTok }
|
|
4038
|
+
? { model: shownModelLabel(routeLabel(session.answeringModel())), activity: `${stepVerb && stepAt >= 0 ? `step ${stepAt + 1}/${tasks.length} · ` : ""}${phaseWord(shownPhase)}`, elapsedMs: elapsed * 1000, tokens: liveTok }
|
|
3935
4039
|
: null;
|
|
3936
4040
|
const compactRead = compactRef.current ? readStats(compactRef.current.ring) : undefined;
|
|
3937
4041
|
const phaseView = shownPhase
|
|
3938
4042
|
? {
|
|
3939
|
-
phase: shownPhase, model: routeLabel(session.answeringModel()), tokens: liveTok, label: stepLabel,
|
|
4043
|
+
phase: shownPhase, model: shownModelLabel(routeLabel(session.answeringModel())), tokens: liveTok, label: stepLabel,
|
|
3940
4044
|
read: shownPhase === "reading" ? readStats(readRingRef.current, roundStartRef.current) : undefined,
|
|
3941
4045
|
queue: shownPhase === "queued" ? gateQueueRef.current ?? undefined : undefined,
|
|
3942
|
-
compaction: shownPhase === "compacting" && compactRef.current ? { before: compactRef.current.before, read: compactRead, wrote: compactRef.current.wrote, approx: vendorStream } : undefined,
|
|
4046
|
+
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,
|
|
3943
4047
|
expect: expectRef.current && (shownPhase === "waiting" || shownPhase === "sent") ? expectSegs(expectRef.current) : undefined,
|
|
3944
4048
|
decode: shownPhase === "thinking" || shownPhase === "writing" || shownPhase === "drafting" ? decodeView() : undefined,
|
|
3945
4049
|
}
|
|
3946
4050
|
: null;
|
|
3947
|
-
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, approval: approval, question: question, modelPicker: modelPicker, secretPrompt: secretPrompt, planExitPicker: planExitPicker, artifactsPicker: artifactsPicker, sessionsPicker: sessionsPicker, update: updatePrompt, onApprovalDecide: (allow, always) => {
|
|
4051
|
+
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) => {
|
|
3948
4052
|
const cur = approval;
|
|
3949
4053
|
if (cur)
|
|
3950
4054
|
settleApproval(cur.id, allow, always); // first-wins with any remote follower answer
|
package/dist/config/managed.js
CHANGED
|
@@ -25,6 +25,8 @@ export const LOCKDOWN = {
|
|
|
25
25
|
computer: { enabled: false },
|
|
26
26
|
mcp: false,
|
|
27
27
|
selfImprove: { flywheel: false },
|
|
28
|
+
skylark: { share: false },
|
|
29
|
+
visionPairs: { enabled: false },
|
|
28
30
|
};
|
|
29
31
|
export function systemManagedPaths(plat = process.platform, env = process.env) {
|
|
30
32
|
if (plat === "darwin")
|
|
@@ -89,7 +91,7 @@ export function validateManagedPolicy(raw) {
|
|
|
89
91
|
const policy = {};
|
|
90
92
|
if (!isObj(raw))
|
|
91
93
|
return { policy, errors: ["policy must be a JSON object"], unknown: [] };
|
|
92
|
-
const known = new Set(["permissions", "sandbox", "computer", "mcp", "selfImprove", "unrestricted", "auth", "$schema", "_comment"]);
|
|
94
|
+
const known = new Set(["permissions", "sandbox", "computer", "mcp", "selfImprove", "skylark", "visionPairs", "unrestricted", "auth", "$schema", "_comment"]);
|
|
93
95
|
const unknown = Object.keys(raw).filter((k) => !known.has(k));
|
|
94
96
|
if (raw.permissions !== undefined) {
|
|
95
97
|
if (!isObj(raw.permissions))
|
|
@@ -142,6 +144,36 @@ export function validateManagedPolicy(raw) {
|
|
|
142
144
|
else
|
|
143
145
|
errors.push("selfImprove.flywheel must be a boolean");
|
|
144
146
|
}
|
|
147
|
+
if (raw.skylark !== undefined) {
|
|
148
|
+
const ok = isObj(raw.skylark) && Object.keys(raw.skylark).length > 0 &&
|
|
149
|
+
Object.entries(raw.skylark).every(([k, v]) => (k === "enabled" || k === "share") && v === false);
|
|
150
|
+
if (ok)
|
|
151
|
+
policy.skylark = raw.skylark;
|
|
152
|
+
else
|
|
153
|
+
errors.push("skylark.enabled / skylark.share may only be set to false (a policy can turn Skylark off, never on)");
|
|
154
|
+
}
|
|
155
|
+
if (raw.visionPairs !== undefined) {
|
|
156
|
+
const vp = raw.visionPairs;
|
|
157
|
+
const list = (v, what, re) => {
|
|
158
|
+
if (v === undefined)
|
|
159
|
+
return undefined;
|
|
160
|
+
if (!Array.isArray(v) || v.length > 500 || !v.every((x) => typeof x === "string" && x.trim().length > 0 && x.length <= 200 && re.test(x.trim()))) {
|
|
161
|
+
errors.push(`visionPairs.${what} must be a list of up to 500 plain strings`);
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
return [...new Set(v.map((x) => x.trim()))];
|
|
165
|
+
};
|
|
166
|
+
if (!isObj(vp) || !Object.keys(vp).every((k) => k === "enabled" || k === "denyHosts" || k === "denyPaths"))
|
|
167
|
+
errors.push("visionPairs accepts only enabled (false), denyHosts and denyPaths");
|
|
168
|
+
else if (vp.enabled !== undefined && vp.enabled !== false)
|
|
169
|
+
errors.push("visionPairs.enabled may only be set to false");
|
|
170
|
+
else {
|
|
171
|
+
const denyHosts = list(vp.denyHosts, "denyHosts", /^[A-Za-z0-9.*-]+$/);
|
|
172
|
+
const denyPaths = list(vp.denyPaths, "denyPaths", /^[^\/\u0000]+$/);
|
|
173
|
+
if (vp.enabled === false || denyHosts || denyPaths)
|
|
174
|
+
policy.visionPairs = { ...(vp.enabled === false ? { enabled: false } : {}), ...(denyHosts ? { denyHosts } : {}), ...(denyPaths ? { denyPaths } : {}) };
|
|
175
|
+
}
|
|
176
|
+
}
|
|
145
177
|
if (raw.unrestricted !== undefined) {
|
|
146
178
|
if (typeof raw.unrestricted === "boolean")
|
|
147
179
|
policy.unrestricted = raw.unrestricted;
|
|
@@ -224,6 +256,13 @@ export function applyManagedPolicy(s, load) {
|
|
|
224
256
|
out.mcp = p.mcp;
|
|
225
257
|
if (p.selfImprove)
|
|
226
258
|
out.selfImprove = { ...s.selfImprove, flywheel: p.selfImprove.flywheel };
|
|
259
|
+
if (p.skylark)
|
|
260
|
+
out.skylark = { ...s.skylark, ...p.skylark };
|
|
261
|
+
if (p.visionPairs) {
|
|
262
|
+
const union = (a, b) => (a || b ? [...new Set([...(a ?? []), ...(b ?? [])])] : undefined);
|
|
263
|
+
const denyHosts = union(s.visionPairs?.denyHosts, p.visionPairs.denyHosts), denyPaths = union(s.visionPairs?.denyPaths, p.visionPairs.denyPaths);
|
|
264
|
+
out.visionPairs = { ...s.visionPairs, ...(p.visionPairs.enabled === false ? { enabled: false } : {}), ...(denyHosts ? { denyHosts } : {}), ...(denyPaths ? { denyPaths } : {}) };
|
|
265
|
+
}
|
|
227
266
|
if (p.unrestricted === false)
|
|
228
267
|
out.unrestricted = false;
|
|
229
268
|
return out;
|