@0perator/operator 0.2.1 → 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 +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 +126 -25
- package/dist/config/managed.js +40 -1
- package/dist/config/persona.js +51 -26
- 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";
|
|
@@ -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
|
|
@@ -1383,7 +1394,7 @@ function Root() {
|
|
|
1383
1394
|
noteWait(ledgerRef.current, Math.max(0, held));
|
|
1384
1395
|
if (held < HOLD_RECEIPT_MS)
|
|
1385
1396
|
return;
|
|
1386
|
-
sys(holdReceipt(routeLabel(session.answeringModel()), held, termCols()));
|
|
1397
|
+
sys(holdReceipt(shownModelLabel(routeLabel(session.answeringModel())), held, termCols()));
|
|
1387
1398
|
};
|
|
1388
1399
|
// The round's first reasoning/content chunk: a read of RECEIPT_MIN_MS or more settles one dim receipt into scrollback
|
|
1389
1400
|
// (and to followers) — what was read, how fast, what was cached, when the first token came.
|
|
@@ -1401,7 +1412,7 @@ function Root() {
|
|
|
1401
1412
|
if (!st || st.elapsedMs < RECEIPT_MIN_MS)
|
|
1402
1413
|
return;
|
|
1403
1414
|
readReceiptRef.current = true;
|
|
1404
|
-
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 }));
|
|
1405
1416
|
};
|
|
1406
1417
|
const startTurn = useCallback(async (text, opts) => {
|
|
1407
1418
|
setNextSteps(null); // a new turn retires the last stop's one-key strip
|
|
@@ -1417,7 +1428,7 @@ function Root() {
|
|
|
1417
1428
|
// Sub-agent reports read as ONE hand-off line for the owner; the model still gets every report in full, unchanged.
|
|
1418
1429
|
const heads = [
|
|
1419
1430
|
...(jobs ? jobs.split("\n\n").map((n) => "⤷ " + n.split("\n")[0].replace(/^\[system notice\] /, "")) : []),
|
|
1420
|
-
...(owners.length ? [deliveredLine(owners, routeLabel(session.currentModel()), termCols())] : []),
|
|
1431
|
+
...(owners.length ? [deliveredLine(owners, shownModelLabel(routeLabel(session.currentModel())), termCols())] : []),
|
|
1421
1432
|
].join("\n");
|
|
1422
1433
|
push({ kind: "message", message: { id: nextId(), role: "system", content: heads } });
|
|
1423
1434
|
remoteRef.current?.system(heads);
|
|
@@ -1527,6 +1538,8 @@ function Root() {
|
|
|
1527
1538
|
},
|
|
1528
1539
|
onCompactionWrite: (n) => { if (compactRef.current)
|
|
1529
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
|
|
1530
1543
|
onCompactionEnd: ({ before, after }) => {
|
|
1531
1544
|
const c = compactRef.current;
|
|
1532
1545
|
compactRef.current = null;
|
|
@@ -1628,7 +1641,7 @@ function Root() {
|
|
|
1628
1641
|
if (lastFallbackRef.current === key)
|
|
1629
1642
|
return;
|
|
1630
1643
|
lastFallbackRef.current = key;
|
|
1631
|
-
sys(
|
|
1644
|
+
sys(gatewayFallbackLine({ from: fallbackFrom, backend }));
|
|
1632
1645
|
},
|
|
1633
1646
|
onPrimaryRestored: (backend) => {
|
|
1634
1647
|
// The primary answered again after we'd been on a fallback: clear the degraded state and say so ONCE, so a
|
|
@@ -1831,6 +1844,7 @@ function Root() {
|
|
|
1831
1844
|
const shown = outcome.display ?? outcome.content; // an engine stop reads as a question, not a bracketed note
|
|
1832
1845
|
push({ kind: "message", message: { id: nextId(), role: "assistant", content: shown, reasoning } });
|
|
1833
1846
|
remoteRef.current?.finalAssistant(shown, reasoning);
|
|
1847
|
+
voiceRef.current?.voice.answer(shown); // voice mode speaks a short version of the final answer
|
|
1834
1848
|
// An engine stop's question is answered with one key: its own options, verbatim. A reply cut by the repetition
|
|
1835
1849
|
// check is stashed for "show what it had" — on screen only; the engine keeps it out of history by design.
|
|
1836
1850
|
if (outcome.stopKind) {
|
|
@@ -2086,6 +2100,62 @@ function Root() {
|
|
|
2086
2100
|
}
|
|
2087
2101
|
catch { /* unreadable memory files are reported elsewhere */ }
|
|
2088
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]);
|
|
2089
2159
|
// Say so when this launch cleaned up after a previous one — silently killing processes would be worse than the orphans.
|
|
2090
2160
|
useEffect(() => {
|
|
2091
2161
|
const n = REAPED.killed.length;
|
|
@@ -2236,12 +2306,16 @@ function Root() {
|
|
|
2236
2306
|
}, [openPicker, applyContext, sys]);
|
|
2237
2307
|
// ctrl+x: the next stop of auto → 300K → 600K → 1M → auto, through the same path /context takes.
|
|
2238
2308
|
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
|
|
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.
|
|
2241
2312
|
const refreshFreeRows = useCallback(async (isConnected) => {
|
|
2242
|
-
const
|
|
2243
|
-
const lists = await Promise.all(
|
|
2244
|
-
|
|
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)];
|
|
2245
2319
|
const stale = lists.some((l) => l.stale);
|
|
2246
2320
|
const sig = (ms, st) => `${st}|${ms.map((m) => m.id).join(",")}`;
|
|
2247
2321
|
const changed = sig(models, stale) !== sig(freeRowsRef.current, freeStaleRef.current);
|
|
@@ -2352,8 +2426,19 @@ function Root() {
|
|
|
2352
2426
|
});
|
|
2353
2427
|
const connectProvider = () => {
|
|
2354
2428
|
const { rows, choices } = providerPickerView(connectedAccounts(isConnected));
|
|
2355
|
-
openPicker("Connect a provider — then paste its API key", rows, choices, (a) => {
|
|
2356
|
-
|
|
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
|
+
});
|
|
2357
2442
|
};
|
|
2358
2443
|
const active = s.currentModel();
|
|
2359
2444
|
// Two screens (0.1.361): the main rows + "More models…", which opens every other row and the connect action.
|
|
@@ -2635,6 +2720,8 @@ function Root() {
|
|
|
2635
2720
|
},
|
|
2636
2721
|
onCompactionWrite: (w) => { if (compactRef.current)
|
|
2637
2722
|
compactRef.current.wrote = w; },
|
|
2723
|
+
onCompactionCoverage: (e) => { if (compactRef.current)
|
|
2724
|
+
Object.assign(compactRef.current, e, { ring: [], wrote: 0 }); },
|
|
2638
2725
|
});
|
|
2639
2726
|
sys(n > 0
|
|
2640
2727
|
? `compacted · freed ~${n.toLocaleString()} tokens · ctx ${beforePct}%→${s.ctxPct()}%`
|
|
@@ -3267,6 +3354,18 @@ function Root() {
|
|
|
3267
3354
|
sys(id ? `spawned ${id} in the background — /bg to list · /bg stop ${id} to cancel` : bg.capacityLine());
|
|
3268
3355
|
}
|
|
3269
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
|
+
}
|
|
3270
3369
|
case "caffeinate":
|
|
3271
3370
|
case "caffeine": {
|
|
3272
3371
|
const want = arg === "off" ? false : arg === "on" ? true : !caffeineRef.current?.active;
|
|
@@ -3776,6 +3875,8 @@ function Root() {
|
|
|
3776
3875
|
// that had already ended, quit the session). Ctrl-C at rest quits on the second press.
|
|
3777
3876
|
const quitArmedRef = useRef(0);
|
|
3778
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
|
|
3779
3880
|
if (statusRef.current !== "idle")
|
|
3780
3881
|
return session.interrupt();
|
|
3781
3882
|
const act = restKey(key, quitArmedRef.current, Date.now(), QUIT_CONFIRM_MS);
|
|
@@ -3931,20 +4032,20 @@ function Root() {
|
|
|
3931
4032
|
// The main turn as a lane (TUI plan #11): its model, its plan step and phase, its clock and tokens.
|
|
3932
4033
|
const stepAt = tasks.findIndex((t) => t.status === "in_progress");
|
|
3933
4034
|
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 }
|
|
4035
|
+
? { model: shownModelLabel(routeLabel(session.answeringModel())), activity: `${stepVerb && stepAt >= 0 ? `step ${stepAt + 1}/${tasks.length} · ` : ""}${phaseWord(shownPhase)}`, elapsedMs: elapsed * 1000, tokens: liveTok }
|
|
3935
4036
|
: null;
|
|
3936
4037
|
const compactRead = compactRef.current ? readStats(compactRef.current.ring) : undefined;
|
|
3937
4038
|
const phaseView = shownPhase
|
|
3938
4039
|
? {
|
|
3939
|
-
phase: shownPhase, model: routeLabel(session.answeringModel()), tokens: liveTok, label: stepLabel,
|
|
4040
|
+
phase: shownPhase, model: shownModelLabel(routeLabel(session.answeringModel())), tokens: liveTok, label: stepLabel,
|
|
3940
4041
|
read: shownPhase === "reading" ? readStats(readRingRef.current, roundStartRef.current) : undefined,
|
|
3941
4042
|
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,
|
|
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,
|
|
3943
4044
|
expect: expectRef.current && (shownPhase === "waiting" || shownPhase === "sent") ? expectSegs(expectRef.current) : undefined,
|
|
3944
4045
|
decode: shownPhase === "thinking" || shownPhase === "writing" || shownPhase === "drafting" ? decodeView() : undefined,
|
|
3945
4046
|
}
|
|
3946
4047
|
: 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) => {
|
|
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) => {
|
|
3948
4049
|
const cur = approval;
|
|
3949
4050
|
if (cur)
|
|
3950
4051
|
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;
|
package/dist/config/persona.js
CHANGED
|
@@ -11,7 +11,7 @@ import { isFeatureEnabled } from "./features.js";
|
|
|
11
11
|
import { renderSkillsIndex } from "./skills-index.js";
|
|
12
12
|
import { decisionPointsEnabled } from "../engine/decision-points.js";
|
|
13
13
|
import { SUBAGENT_ROLES, SUBAGENT_TOOL_DENY } from "../engine/grandmaster.js";
|
|
14
|
-
import { LESSONS_HEADING, isLessonHeading, mergeLessons, parseLessonTag, reinforcedRules, splitLessons } from "../selfimprove/lessons.js";
|
|
14
|
+
import { LESSONS_HEADING, PROMPT_LESSONS, isLessonHeading, mergeLessons, parseLessonTag, reinforcedRules, splitLessons, topLessons } from "../selfimprove/lessons.js";
|
|
15
15
|
import { redactSecrets } from "../engine/redact.js";
|
|
16
16
|
import { fitWhole, splitItems, splitSections } from "./memory-sections.js";
|
|
17
17
|
import { freshHandoff, withoutSettled } from "../memory/live-progress.js";
|
|
@@ -54,11 +54,32 @@ export function projectMemoriesPath(cwd = process.cwd()) {
|
|
|
54
54
|
return join(cwd, ".operator", "memories.md");
|
|
55
55
|
}
|
|
56
56
|
const unitSize = (u) => u.text.length + 2;
|
|
57
|
+
/** A file index entry (`- name.md: what it covers`) keeps one short line; the file itself is read on demand. */
|
|
58
|
+
export const INDEX_LINE_CHARS = 80;
|
|
59
|
+
const INDEX_ENTRY = /^- [\w./-]+\.md\b/;
|
|
60
|
+
/** A section whose every list item names a .md file is an index: each entry cut to `max` chars at a word. Pure. */
|
|
61
|
+
export function compactFileIndex(text, max = INDEX_LINE_CHARS) {
|
|
62
|
+
const lines = text.split("\n");
|
|
63
|
+
const items = lines.filter((l) => /^[-*] /.test(l));
|
|
64
|
+
if (!items.length || !items.every((l) => INDEX_ENTRY.test(l)))
|
|
65
|
+
return text;
|
|
66
|
+
const clip = (l) => {
|
|
67
|
+
if (l.length <= max)
|
|
68
|
+
return l;
|
|
69
|
+
const cut = l.slice(0, max - 1);
|
|
70
|
+
const sp = cut.lastIndexOf(" ");
|
|
71
|
+
return (sp > max / 2 ? cut.slice(0, sp) : cut).replace(/[\s,;:—-]+$/, "") + "…";
|
|
72
|
+
};
|
|
73
|
+
return lines.map((l) => (INDEX_ENTRY.test(l) ? clip(l) : l)).join("\n");
|
|
74
|
+
}
|
|
57
75
|
/** A file's units: each headed section whole, and the facts of its flat list (the text before the first heading). */
|
|
58
|
-
function fileUnits(rest) {
|
|
59
|
-
return splitSections(rest).flatMap((section) =>
|
|
60
|
-
|
|
61
|
-
|
|
76
|
+
function fileUnits(rest, indexLineChars = INDEX_LINE_CHARS) {
|
|
77
|
+
return splitSections(rest).flatMap((section) => {
|
|
78
|
+
if (!section.heading)
|
|
79
|
+
return splitItems(section.text).map((text) => ({ text, fact: true }));
|
|
80
|
+
const text = compactFileIndex(section.text, indexLineChars);
|
|
81
|
+
return [{ text, section: { ...section, text } }];
|
|
82
|
+
});
|
|
62
83
|
}
|
|
63
84
|
/** One file's sections and facts under `budget` in priority order — `ahead` first (the lessons), then the rules sections,
|
|
64
85
|
* `between` (the taught lessons), the flat facts newest first, the notes sections — rendered as the rules, the facts,
|
|
@@ -78,36 +99,38 @@ function fitFile(units, budget, ahead = [], between = []) {
|
|
|
78
99
|
return { fit, shown, droppedNames };
|
|
79
100
|
}
|
|
80
101
|
const leftOut = (names, where) => names.length ? `\n(left out for the memory budget: ${names.join(", ")} — read ${where} for them)` : "";
|
|
81
|
-
/** The memory blocks of the system prompt: the lessons of both files as one list, then the global file's sections,
|
|
82
|
-
* the project file's — each file under its own MEMORY_BUDGET, whole lessons and sections only. Pure. */
|
|
83
|
-
export function renderMemories(global, project) {
|
|
102
|
+
/** The memory blocks of the system prompt: the top lessons of both files as one list, then the global file's sections,
|
|
103
|
+
* then the project file's — each file under its own MEMORY_BUDGET, whole lessons and sections only. Pure. */
|
|
104
|
+
export function renderMemories(global, project, opts = {}) {
|
|
84
105
|
const taught = reinforcedRules(global?.text ?? "");
|
|
85
106
|
const g = splitLessons(global?.text ?? "", taught);
|
|
86
107
|
const p = project ? splitLessons(project.text, taught) : undefined;
|
|
87
|
-
const
|
|
108
|
+
const top = topLessons(mergeLessons(g.lessons, p?.lessons ?? []), opts.lessons ?? PROMPT_LESSONS);
|
|
109
|
+
const lessons = top.kept.map(redactSecrets); // a line an older build wrote unmasked
|
|
88
110
|
const auto = [...lessons.filter((l) => parseLessonTag(l)?.kind !== "taught"), ...g.other, ...(p?.other ?? [])].map((text) => ({ text }));
|
|
89
111
|
const fromReviewers = lessons.filter((l) => parseLessonTag(l)?.kind === "taught").map((text) => ({ text }));
|
|
90
112
|
const where = global?.path ?? "memories.md";
|
|
91
113
|
let out = "";
|
|
92
|
-
const gf = fitFile(fileUnits(g.rest), MEMORY_BUDGET.global, auto, fromReviewers);
|
|
114
|
+
const gf = fitFile(fileUnits(g.rest, opts.indexLineChars), MEMORY_BUDGET.global, auto, fromReviewers);
|
|
93
115
|
const keptLessons = [...auto, ...fromReviewers].filter((u) => gf.fit.kept.has(u));
|
|
94
116
|
const droppedLessons = auto.length + fromReviewers.length - keptLessons.length;
|
|
95
117
|
if (keptLessons.length) {
|
|
96
118
|
out += `\n\n${LESSONS_HEADING}\n${keptLessons.map((u) => u.text).join("\n")}` +
|
|
97
|
-
(droppedLessons ? `\n(${droppedLessons} older lesson${droppedLessons === 1 ? "" : "s"} left out for the memory budget — all of them are in ${where})` : "")
|
|
119
|
+
(droppedLessons ? `\n(${droppedLessons} older lesson${droppedLessons === 1 ? "" : "s"} left out for the memory budget — all of them are in ${where})` : "") +
|
|
120
|
+
(top.rest ? `\n(${top.rest} more lesson${top.rest === 1 ? "" : "s"} not loaded: memory_search finds them; all are in ${where})` : "");
|
|
98
121
|
}
|
|
99
122
|
if (gf.shown.length || gf.droppedNames.length) {
|
|
100
123
|
out += `\n\n## Global memory (memories.md — applies to every project)\n${gf.shown.join("\n\n")}${leftOut(gf.droppedNames, where)}`;
|
|
101
124
|
}
|
|
102
125
|
if (project && p) {
|
|
103
|
-
const pf = fitFile(fileUnits(p.rest), MEMORY_BUDGET.project);
|
|
126
|
+
const pf = fitFile(fileUnits(p.rest, opts.indexLineChars), MEMORY_BUDGET.project);
|
|
104
127
|
if (pf.shown.length || pf.droppedNames.length) {
|
|
105
128
|
out += `\n\n## Project memory (${project.name} — this repo)\n${pf.shown.join("\n\n")}${leftOut(pf.droppedNames, project.name)}`;
|
|
106
129
|
}
|
|
107
130
|
}
|
|
108
131
|
return out;
|
|
109
132
|
}
|
|
110
|
-
export function loadMemories(cwd = process.cwd()) {
|
|
133
|
+
export function loadMemories(cwd = process.cwd(), opts = {}) {
|
|
111
134
|
let global;
|
|
112
135
|
try {
|
|
113
136
|
global = { text: readFileSync(globalMemoriesPath(), "utf8"), path: globalMemoriesPath() };
|
|
@@ -124,7 +147,7 @@ export function loadMemories(cwd = process.cwd()) {
|
|
|
124
147
|
}
|
|
125
148
|
catch { /* try the next */ }
|
|
126
149
|
}
|
|
127
|
-
return renderMemories(global, project);
|
|
150
|
+
return renderMemories(global, project, opts);
|
|
128
151
|
}
|
|
129
152
|
/** What the memory budget left out of the prompt, read from the rendered block itself (so the owner and the model are
|
|
130
153
|
* told the same thing): one entry per file, e.g. `"Notes", 2 older notes — not loaded from .operator/memories.md`.
|
|
@@ -329,16 +352,15 @@ export function basePersona(_cwd = process.cwd(), opts = {}) {
|
|
|
329
352
|
`output, downloads to inspect, intermediate files: ALWAYS here, never /tmp and never the repo root. It is ` +
|
|
330
353
|
`git-ignored and swept after a week, so nothing you keep belongs in it; name files \`<subject>-<thing>\`.` +
|
|
331
354
|
ctxLine +
|
|
332
|
-
`\n## Talking about yourself\nYou are Operator, whichever model is serving you — the model underneath can change between sessions (or mid-session with /model) and you are still Operator.
|
|
333
|
-
`
|
|
334
|
-
`
|
|
335
|
-
`
|
|
336
|
-
`
|
|
337
|
-
`the first person, briefly, and say which model is actually serving when it differs.` +
|
|
355
|
+
`\n## Talking about yourself\nYou are Operator, AXE's agent, whichever model is serving you — the model underneath can change between sessions (or mid-session with /model) and you are still Operator. Asked what you are, say you are Operator; give ` +
|
|
356
|
+
`the context window above if asked. What you may say about the model underneath is set by the "Active model" section at the end ` +
|
|
357
|
+
`of this prompt; never guess a model from files, hostnames or other text in this prompt, and do not recite hostnames, IP ` +
|
|
358
|
+
`addresses, ports, URLs or file paths of AXE's servers unless the task itself needs the address. Greeted by a model name ("hello ` +
|
|
359
|
+
`cortana"), answer simply as Operator.` +
|
|
338
360
|
`\n## Don't starve the serving model — decode is RAM-bound\nLoading a large model on this box (a multi-GB ` +
|
|
339
361
|
`MLX/FLUX/LLM checkpoint, a big \`ml.load\`) pushes it into swap and collapses your decode to ~1 token/sec: use ` +
|
|
340
362
|
`another node, process in shards, or warn the owner first. Media goes ONLY through the tools (\`image_generate\`, ` +
|
|
341
|
-
`\`video_generate\`, \`image_analyze\`, \`video_analyze\`;
|
|
363
|
+
`\`video_generate\`, \`image_analyze\`, \`video_analyze\`; all on demand) — never curl a broker or decode base64 yourself. A ` +
|
|
342
364
|
`screenshot the owner shares is snapshotted by the engine: \`image_analyze\` the path exactly as given, one call ` +
|
|
343
365
|
`per DISTINCT path. If your own output crawls, STOP and say so rather than pushing through.` +
|
|
344
366
|
// Tool-promotion sections below prime reflexive tool use; a small/weak model (lean) does better with the
|
|
@@ -352,12 +374,15 @@ export function basePersona(_cwd = process.cwd(), opts = {}) {
|
|
|
352
374
|
`owner (bash \`open <url-or-path>\`) and put the clickable link in your reply; skip that in a headless batch.` +
|
|
353
375
|
`\n## The media pipeline — what you ACTUALLY have (don't invent tools)\nThree scale-to-zero fleet workers, ` +
|
|
354
376
|
`nothing else — never offer ComfyUI, SDXL, Juggernaut/RealVis/EpicRealism, FLUX.1-dev/pro, Midjourney or a ` +
|
|
355
|
-
`cloud image API. IMAGES: \`image_generate\` (FLUX.1-schnell) — the quality lever is \`expand: true\` (the ` +
|
|
377
|
+
`cloud image API. IMAGES: \`image_generate\` (on demand; FLUX.1-schnell) — the quality lever is \`expand: true\` (the ` +
|
|
356
378
|
`prompt is rewritten richer) plus a larger \`size\`. LIKENESS: a FACE photo as \`reference\` routes to the ` +
|
|
357
379
|
`identity broker and keeps that exact person; if the result's \`axe_identity\` says \`identity_applied\` false ` +
|
|
358
380
|
`or a weak \`fidelity_note\`, SAY so — never pass a look-alike off as a match. VIDEO: \`video_generate\` ` +
|
|
359
381
|
`(on demand; LTX-Video); \`reference_image\` makes that image the FIRST FRAME. VISION: \`image_analyze\` / ` +
|
|
360
382
|
`\`video_analyze\`; a document (PDF, DOCX, XLSX, PPTX) is read as TEXT, every page.` +
|
|
383
|
+
`\n## Reproducing a web page's design (on demand)\n\`tool_call page_capture\` the reference (exact tokens, outline, screenshot ` +
|
|
384
|
+
`tiles), build from those values, then \`tool_call visual_compare\` reference vs yours and fix the top finding ` +
|
|
385
|
+
`until the mismatch is small. Never from web_fetch text alone.` +
|
|
361
386
|
`\n## Deep research — \`deep_research\` (on demand; cited, multi-source)\nFor a comparison, a state-of-the-art survey ` +
|
|
362
387
|
`or sourced background use \`deep_research\` (planned angles, inline citations); a single lookup is faster ` +
|
|
363
388
|
`with plain \`web_search\`.`)) +
|
|
@@ -555,18 +580,18 @@ export function composeSystemPrompt(o) {
|
|
|
555
580
|
// basePersona carries (decision points and sub-agents included).
|
|
556
581
|
const personaOpts = { ctxTokens: o.ctxTokens, interactive, lean, decisionPoints: o.settings.decisionPoints };
|
|
557
582
|
const identity = custom ? custom + harnessRules(cwd, personaOpts) : basePersona(cwd, personaOpts);
|
|
558
|
-
// Local-skills index (
|
|
559
|
-
// skill_list
|
|
583
|
+
// Local-skills index (names only, 4k cap) — the model must KNOW skills exist without spending a call; what each
|
|
584
|
+
// does comes from skill_list and the body from skill_fetch, on demand like the deferred tools. Skipped in lean (small-ctx) mode like
|
|
560
585
|
// the other heavy sections. Appended exactly like renderToolCatalogue, right before it.
|
|
561
586
|
const skillsIdx = lean ? "" : renderSkillsIndex();
|
|
562
587
|
// `deferredTools`: the same split the Session advertises (tools/deferred.ts) — fixed for the session, so cache-safe.
|
|
563
588
|
const deferred = isFeatureEnabled("deferredTools", o.settings);
|
|
564
589
|
return (identity +
|
|
565
590
|
loadProjectContext(cwd) +
|
|
566
|
-
(lean ? "" : loadStructuredMemories() + loadMemories(cwd)) +
|
|
591
|
+
(lean ? "" : loadStructuredMemories() + loadMemories(cwd, { lessons: o.settings.memory?.promptLessons, indexLineChars: o.settings.memory?.indexLineChars })) +
|
|
567
592
|
renderHarnessContext(cwd) +
|
|
568
593
|
(lean ? LEAN_NOTE : loadHandoff()) +
|
|
569
|
-
(skillsIdx ? `\n\n## Skills installed locally (
|
|
594
|
+
(skillsIdx ? `\n\n## Skills installed locally (names only: skill_list says what each does, skill_fetch <name> loads one, skill_fetch <name> <file_path> reads its references/templates/scripts)\n${skillsIdx}` : "") +
|
|
570
595
|
renderToolCatalogue(sessionTools(o.settings), { lean, deferred }) +
|
|
571
596
|
(interactive ? renderEmbodimentGuide(!!o.settings.computer?.enabled, o.chauffeurReady ?? !!o.settings.mcp) : ""));
|
|
572
597
|
}
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
export const PRODUCT_API_HOST = "api.0perator.co";
|
|
7
7
|
export const LEGACY_API_HOST = "api.axe.onl";
|
|
8
8
|
export const API_HOSTS = [PRODUCT_API_HOST, LEGACY_API_HOST];
|
|
9
|
+
/** Operator Portal's name for the same edge and router (BYO_PRESETS.portal): the gateway as a provider. */
|
|
10
|
+
export const INFERENCE_API_HOST = "inference.0perator.co";
|
|
9
11
|
export const RELAY_URLS = API_HOSTS.map((h) => `wss://${h}/session/ws`);
|
|
10
12
|
/** The host part of a URL for status lines — or the raw string when it does not parse. A scheme-less
|
|
11
13
|
* KODE_RELAY_URL already fails inside RemoteHost's own error loop; a status line must never be the thing
|