@0perator/operator 0.1.331 → 0.1.332
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp/config-options.js +10 -1
- package/dist/auth/byo.js +85 -9
- package/dist/auth/commands.js +1 -1
- package/dist/autonomy/delegate.js +3 -2
- package/dist/autonomy/session-factory.js +1 -0
- package/dist/cli.js +209 -61
- package/dist/config/persona.js +3 -1
- package/dist/config/settings.js +32 -1
- package/dist/engine/agent.js +8 -4
- package/dist/engine/anthropic-chat.js +28 -6
- package/dist/engine/anthropic.js +1 -1
- package/dist/engine/aurora.js +5 -1
- package/dist/engine/continuation.js +1 -1
- package/dist/engine/router-adapter.js +6 -5
- package/dist/engine/verify-gate.js +30 -3
- package/dist/remote/safe-commands.js +1 -1
- package/dist/router/discovery.js +23 -4
- package/dist/router/free-models.js +190 -0
- package/dist/router/models.js +138 -60
- package/dist/session.js +94 -23
- package/dist/tools/sandbox.js +1 -1
- package/dist/ui/App.js +4 -3
- package/dist/ui/Composer.js +16 -1
- package/dist/ui/QuestionPrompt.js +22 -4
- package/dist/ui/SecretPrompt.js +77 -0
- package/dist/ui/StatusRule.js +6 -6
- package/dist/ui/modelPicker.js +110 -0
- package/dist/ui/slashCommands.js +3 -1
- package/dist/util/slash.js +3 -2
- package/package.json +1 -1
package/dist/ui/App.js
CHANGED
|
@@ -20,6 +20,7 @@ import { backgroundHint } from "./liveTools.js";
|
|
|
20
20
|
import { useTick } from "./tick.js";
|
|
21
21
|
import { ApprovalPrompt } from "./ApprovalPrompt.js";
|
|
22
22
|
import { QuestionPrompt } from "./QuestionPrompt.js";
|
|
23
|
+
import { SecretPrompt } from "./SecretPrompt.js";
|
|
23
24
|
import { ArtifactPicker } from "./ArtifactPicker.js";
|
|
24
25
|
import { SessionPicker } from "./SessionPicker.js";
|
|
25
26
|
// Cap on live rows shown at once for a parallel tool batch — keeps the dynamic (non-Static) frame
|
|
@@ -36,7 +37,7 @@ function BackgroundHint({ rows }) {
|
|
|
36
37
|
return hint ? _jsx(Text, { dimColor: true, children: ` · ${hint}` }) : null;
|
|
37
38
|
}
|
|
38
39
|
export function App(props) {
|
|
39
|
-
const { messages, live = null, status, thinkingVerb, verbs, stepLabel, prefill = "", liveTools = [], route, ctxPct, version, build, fullscreen = false, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, shellJobs = [], onBackground, tasks = [], onSubmit, onQueue, queuedPreview = "", onInterrupt, onCycleMode, opMode, rcConnected = false, rcActive = false, caffeinated = false, approval = null, onApprovalDecide, question = null, modelPicker = null, planExitPicker = null, artifactsPicker = null, sessionsPicker = null } = props;
|
|
40
|
+
const { messages, live = null, status, thinkingVerb, verbs, stepLabel, prefill = "", liveTools = [], route, ctxPct, ctxPin, version, build, fullscreen = false, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, shellJobs = [], onBackground, tasks = [], onSubmit, onQueue, queuedPreview = "", onInterrupt, onCycleMode, onCycleContext, opMode, rcConnected = false, rcActive = false, caffeinated = false, approval = null, onApprovalDecide, question = null, modelPicker = null, secretPrompt = null, planExitPicker = null, artifactsPicker = null, sessionsPicker = null } = props;
|
|
40
41
|
useTerminalSize(); // subscribe so the inline pinned UI (status rule, composer, footer) reflows the instant the terminal resizes
|
|
41
42
|
const thinking = status === "thinking" || status === "streaming";
|
|
42
43
|
// A parallel batch (2+ live rows) gets its own per-call view instead of the single-line StepSpinner —
|
|
@@ -49,9 +50,9 @@ export function App(props) {
|
|
|
49
50
|
: _jsx(ThinkingSpinner, { active: true, verb: thinkingVerb, verbs: verbs, metrics: metrics }) })), showParallelRows && (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, paddingLeft: 1, children: [_jsxs(Text, { dimColor: true, children: ["running ", liveTools.length, " tools in parallel"] }), liveTools.slice(0, MAX_LIVE_TOOL_ROWS).map((step) => _jsx(ToolStep, { step: step }, step.id)), liveTools.length > MAX_LIVE_TOOL_ROWS ? _jsxs(Text, { dimColor: true, children: [" +", liveTools.length - MAX_LIVE_TOOL_ROWS, " more\u2026"] }) : null] })), _jsx(PlanPane, { tasks: tasks }), _jsx(BgPanel, { agents: bgAgents, jobs: shellJobs }), (thinking || status === "executing" || status === "recovering") && (_jsxs(Text, { dimColor: true, children: [` ${status === "executing" ? "running tools" : status === "recovering" ? "recovering" : status === "streaming" ? "writing" : prefill || "reasoning"} · esc to interrupt`, status === "executing" ? _jsx(BackgroundHint, { rows: liveTools }) : null] }))] }));
|
|
50
51
|
// Interactive prompts own the keyboard while up; kept out of the fullscreen clip region so they can't
|
|
51
52
|
// be scrolled off. The Composer is `suspended` (keystrokes route to the decision, not the draft).
|
|
52
|
-
const prompts = (_jsxs(_Fragment, { children: [_jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }) }), _jsx(QuestionPrompt, { pending: question }), _jsx(QuestionPrompt, { pending: modelPicker }), _jsx(QuestionPrompt, { pending: planExitPicker }), _jsx(ArtifactPicker, { pending: artifactsPicker }), _jsx(SessionPicker, { pending: sessionsPicker })] }));
|
|
53
|
+
const prompts = (_jsxs(_Fragment, { children: [_jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }) }), _jsx(QuestionPrompt, { pending: question }), _jsx(QuestionPrompt, { pending: modelPicker }), _jsx(SecretPrompt, { pending: secretPrompt }), _jsx(QuestionPrompt, { pending: planExitPicker }), _jsx(ArtifactPicker, { pending: artifactsPicker }), _jsx(SessionPicker, { pending: sessionsPicker })] }));
|
|
53
54
|
// The pinned bottom band: status rule, composer, bottom rule, then the mode/cycle FOOTER below the rule.
|
|
54
|
-
const bottom = (_jsxs(_Fragment, { children: [_jsx(StatusRule, { route: route, ctxPct: ctxPct, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode, sessionTokens: sessionTokens }), queuedPreview ? (_jsx(Text, { color: "yellow", children: `⏎ queued · sends when this turn ends (Esc to send now): ${queuedPreview.replace(/\n/g, " / ").slice(0, 120)}${queuedPreview.length > 120 ? "…" : ""}` })) : null, _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, onBackground: onBackground, onCycleMode: onCycleMode, disabled: status !== "idle", suspended: !!approval || !!question || !!modelPicker || !!planExitPicker || !!artifactsPicker || !!sessionsPicker }), _jsx(InputRule, {}), opMode && (_jsxs(Box, { justifyContent: "space-between", children: [_jsx(Text, { dimColor: true, children: ` ${opMode === "auto" ? "⎈ Autonomous" : opMode === "manual" ? "⊙ Manual" : "◑ Plan"} · shift+tab to cycle` }), _jsx(Text, { color: rcConnected ? "green" : rcActive ? "yellow" : "gray", bold: rcConnected || rcActive, dimColor: !rcConnected && !rcActive, children: `${caffeinated ? "☕ " : ""}${rcConnected ? "▮ rc live" : rcActive ? "▮ rc on" : "▯ rc"} ` })] }))] }));
|
|
55
|
+
const bottom = (_jsxs(_Fragment, { children: [_jsx(StatusRule, { route: route, ctxPct: ctxPct, ctxPin: ctxPin, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode, sessionTokens: sessionTokens }), queuedPreview ? (_jsx(Text, { color: "yellow", children: `⏎ queued · sends when this turn ends (Esc to send now): ${queuedPreview.replace(/\n/g, " / ").slice(0, 120)}${queuedPreview.length > 120 ? "…" : ""}` })) : null, _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, onBackground: onBackground, onCycleMode: onCycleMode, onCycleContext: onCycleContext, disabled: status !== "idle", suspended: !!approval || !!question || !!modelPicker || !!secretPrompt || !!planExitPicker || !!artifactsPicker || !!sessionsPicker }), _jsx(InputRule, {}), opMode && (_jsxs(Box, { justifyContent: "space-between", children: [_jsx(Text, { dimColor: true, children: ` ${opMode === "auto" ? "⎈ Autonomous" : opMode === "manual" ? "⊙ Manual" : "◑ Plan"} · shift+tab to cycle` }), _jsx(Text, { color: rcConnected ? "green" : rcActive ? "yellow" : "gray", bold: rcConnected || rcActive, dimColor: !rcConnected && !rcActive, children: `${caffeinated ? "☕ " : ""}${rcConnected ? "▮ rc live" : rcActive ? "▮ rc on" : "▯ rc"} ` })] }))] }));
|
|
55
56
|
// Fullscreen (opt-in): a full-terminal-height column. The transcript fills a clipped, bottom-anchored
|
|
56
57
|
// region (non-Static tail) so the newest output sits just above a composer pinned to the very bottom —
|
|
57
58
|
// no dead space. Off by default: inline keeps the terminal's native scrollback (mouse-scroll + copy).
|
package/dist/ui/Composer.js
CHANGED
|
@@ -21,8 +21,10 @@ import { matchSlashCommands } from "./slashCommands.js";
|
|
|
21
21
|
import { touchInput } from "../idle/activity.js";
|
|
22
22
|
const PASTE_START = "\x1b[200~";
|
|
23
23
|
const PASTE_END = "\x1b[201~";
|
|
24
|
-
export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended, onCycleMode, onBackground, prompt = "› " }) {
|
|
24
|
+
export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended, onCycleMode, onCycleContext, onBackground, prompt = "› " }) {
|
|
25
25
|
const [value, setValue] = useState("");
|
|
26
|
+
const suspendedRef = useRef(suspended); // read by the raw-stdin paste listener, registered once below
|
|
27
|
+
suspendedRef.current = suspended;
|
|
26
28
|
const [selIdx, setSelIdx] = useState(0); // highlighted row in the "/" command menu
|
|
27
29
|
const pasteCountRef = useRef(0);
|
|
28
30
|
const pasteBufRef = useRef(null); // non-null while inside a bracketed paste
|
|
@@ -60,6 +62,10 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended,
|
|
|
60
62
|
};
|
|
61
63
|
const onData = (chunk) => {
|
|
62
64
|
touchInput(); // any byte from the keyboard/paste is the owner being here (idle/activity.ts)
|
|
65
|
+
// A paste made while an overlay owns the keyboard is the overlay's (a typed reply, a provider key): capturing it
|
|
66
|
+
// here too would park a copy in the draft — and a chip expands into the next submitted turn and the history.
|
|
67
|
+
if (suspendedRef.current && pasteBufRef.current === null)
|
|
68
|
+
return;
|
|
63
69
|
const s = typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
64
70
|
if (pasteBufRef.current !== null) {
|
|
65
71
|
const end = s.indexOf(PASTE_END);
|
|
@@ -151,6 +157,11 @@ export function Composer({ onSubmit, onInterrupt, onQueue, disabled, suspended,
|
|
|
151
157
|
onBackground?.();
|
|
152
158
|
return;
|
|
153
159
|
}
|
|
160
|
+
// ctrl+x cycles the context pin, the hotkey twin of /context. Swallowed: never lands in the draft.
|
|
161
|
+
if (isContextCycleKey(ch, key)) {
|
|
162
|
+
onCycleContext?.();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
154
165
|
// ESC / Ctrl+C: apply the pure interruptPlan. ESC mid-turn with a pending draft flushes it into
|
|
155
166
|
// the queue (so it goes through right after the interrupt, via the turn-finally drain), then
|
|
156
167
|
// interrupts; an empty-draft ESC and every Ctrl+C are plain interrupts. See interruptPlan below.
|
|
@@ -325,3 +336,7 @@ export function interruptPlan(key, ctx) {
|
|
|
325
336
|
export function isBackgroundKey(ch, key) {
|
|
326
337
|
return !!key.ctrl && (ch === "b" || ch === "z");
|
|
327
338
|
}
|
|
339
|
+
/** ctrl+x — cycle the context pin (Ink reports it as "x" with ctrl). */
|
|
340
|
+
export function isContextCycleKey(ch, key) {
|
|
341
|
+
return !!key.ctrl && ch === "x";
|
|
342
|
+
}
|
|
@@ -16,6 +16,18 @@ export const CHAT_LABEL = "Chat about it — type your own reply";
|
|
|
16
16
|
export const DISCUSS = "Let's talk it through — I don't want to pick one of the listed options; discuss it with me.";
|
|
17
17
|
// Joins the chosen options for the model when multi-select confirms a set — a stable, readable delimiter.
|
|
18
18
|
export const MULTI_JOIN = "; ";
|
|
19
|
+
/** The state a same-picker redraw keeps: the owner's mode and typed buffer, and the highlight on the same row by its text
|
|
20
|
+
* (a leading portal marker ignored). null = a different picker (or none) — reset. */
|
|
21
|
+
export function redrawState(prev, next, st) {
|
|
22
|
+
if (!prev || !next || next.key === undefined || prev.key !== next.key)
|
|
23
|
+
return null;
|
|
24
|
+
if (st.highlight >= prev.options.length)
|
|
25
|
+
return { ...st, highlight: next.options.length }; // the chat row stays the chat row
|
|
26
|
+
const bare = (t) => t.replace(/^[●○✕?] /, "");
|
|
27
|
+
const was = bare(prev.options[st.highlight]);
|
|
28
|
+
const at = next.options.findIndex((o) => bare(o) === was);
|
|
29
|
+
return { ...st, highlight: at >= 0 ? at : Math.min(st.highlight, Math.max(0, next.options.length - 1)) };
|
|
30
|
+
}
|
|
19
31
|
// Flip option index `i` in/out of the (sorted) selection set — the Space/digit toggle in multi mode.
|
|
20
32
|
const toggleSelected = (sel, i) => sel.includes(i) ? sel.filter((x) => x !== i) : [...sel, i].sort((a, b) => a - b);
|
|
21
33
|
// Pure keystroke reducer (no React, no I/O) so the whole selection + free-text behavior is testable without
|
|
@@ -59,13 +71,13 @@ export function questionKey(st, input, key, options, multiSelect = false) {
|
|
|
59
71
|
const sel = (st.selected && st.selected.length ? st.selected : [st.highlight]).slice().sort((a, b) => a - b);
|
|
60
72
|
return { resolve: sel.map((i) => options[i]).join(MULTI_JOIN) };
|
|
61
73
|
}
|
|
62
|
-
return { resolve: options[st.highlight] };
|
|
74
|
+
return { resolve: options[st.highlight], index: st.highlight };
|
|
63
75
|
}
|
|
64
76
|
const n = Number(input);
|
|
65
77
|
if (Number.isInteger(n) && n >= 1 && n <= options.length) {
|
|
66
78
|
if (multiSelect)
|
|
67
79
|
return { state: { ...st, highlight: n - 1, selected: toggleSelected(st.selected ?? [], n - 1) } }; // digit toggles, doesn't commit
|
|
68
|
-
return { resolve: options[n - 1] };
|
|
80
|
+
return { resolve: options[n - 1], index: n - 1 };
|
|
69
81
|
}
|
|
70
82
|
if (n === options.length + 1)
|
|
71
83
|
return { state: { mode: "type", buffer: "", highlight: options.length, selected: st.selected } }; // open the free-text line
|
|
@@ -76,13 +88,19 @@ export function QuestionPrompt({ pending }) {
|
|
|
76
88
|
const [st, setSt] = useState({ mode: "choose", buffer: "", highlight: 0, selected: multi ? [] : undefined });
|
|
77
89
|
const qRef = useRef(null);
|
|
78
90
|
const [qLines, setQLines] = useState(1); // measured height of the (possibly wrapping) question line
|
|
79
|
-
|
|
91
|
+
const shownRef = useRef(null);
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
// A late redraw of the SAME picker must not move the owner's place (it used to jump the highlight to row 1 under their keys).
|
|
94
|
+
const prev = shownRef.current;
|
|
95
|
+
shownRef.current = pending ? { key: pending.key, options: pending.options } : null;
|
|
96
|
+
setSt((s) => redrawState(prev, pending, s) ?? { mode: "choose", buffer: "", highlight: 0, selected: pending?.multiSelect ? [] : undefined });
|
|
97
|
+
}, [pending]); // reset for each new question
|
|
80
98
|
useInput((input, key) => {
|
|
81
99
|
if (!pending)
|
|
82
100
|
return;
|
|
83
101
|
const a = questionKey(st, input, key, pending.options, pending.multiSelect);
|
|
84
102
|
if (a.resolve !== undefined)
|
|
85
|
-
pending.resolve(a.resolve);
|
|
103
|
+
pending.resolve(a.resolve, a.index);
|
|
86
104
|
else if (a.state)
|
|
87
105
|
setSt(a.state);
|
|
88
106
|
}, { isActive: !!pending });
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Masked key entry for /model's "+ Connect a provider key" (the reference's flow): the owner pastes a vendor API key
|
|
3
|
+
// and it goes straight to the keychain. A local overlay like QuestionPrompt — the Composer is suspended while it is up
|
|
4
|
+
// (and leaves pastes to it), and it is never relayed to remote followers. The value lives only in this component until
|
|
5
|
+
// Enter hands it to `store` (auth/byo.ts setByoToken): it never reaches the transcript, the archive, the input history,
|
|
6
|
+
// the audit trail or a log, and the frame is drawn from its LENGTH alone, so no character of it can ever be shown.
|
|
7
|
+
import { useEffect, useRef, useState } from "react";
|
|
8
|
+
import { Box, Text, useInput } from "ink";
|
|
9
|
+
// A paste arrives inside bracketed-paste markers (Ink strips a chunk's leading ESC, so "[200~" can lead it), often with a
|
|
10
|
+
// trailing newline; no vendor key carries whitespace or a control character, so all of that is dropped.
|
|
11
|
+
const PASTE_MARKER = /\x1b?\[20[01]~/g;
|
|
12
|
+
// Terminal reports reach useInput as printable text with the ESC sliced off: SGR mouse (fullscreen tracks every wheel and
|
|
13
|
+
// click) and cursor-position replies. Inside a masked field they would be stored as part of the key, unseen.
|
|
14
|
+
const TERMINAL_REPORT = /\x1b?\[<\d+;\d+;\d+[Mm]|\x1b?\[\d+;\d+R/g;
|
|
15
|
+
const NOT_KEY = /[\s\x00-\x1f\x7f]/g;
|
|
16
|
+
// Mask cells drawn at most: a 100+ character key stays on one line of an 80-column box; the count says the rest.
|
|
17
|
+
export const MASK_MAX = 32;
|
|
18
|
+
/** The characters of one input chunk that belong to the key. */
|
|
19
|
+
export function secretChars(input) {
|
|
20
|
+
return input.replace(PASTE_MARKER, "").replace(TERMINAL_REPORT, "").replace(NOT_KEY, "");
|
|
21
|
+
}
|
|
22
|
+
/** Pure keystroke reducer (no React, no I/O), like questionKey: the next value, the value to store (Enter), or a cancel
|
|
23
|
+
* (Esc / ctrl+c). ctrl+u clears; Enter on an empty value does nothing. */
|
|
24
|
+
export function secretKey(value, input, key) {
|
|
25
|
+
if (key.escape || (key.ctrl && input === "c"))
|
|
26
|
+
return { cancel: true };
|
|
27
|
+
if (key.return)
|
|
28
|
+
return value ? { submit: value } : {};
|
|
29
|
+
if (key.backspace || key.delete)
|
|
30
|
+
return { value: value.slice(0, -1) };
|
|
31
|
+
if (key.ctrl && input === "u")
|
|
32
|
+
return { value: "" };
|
|
33
|
+
if (key.ctrl || key.meta)
|
|
34
|
+
return {};
|
|
35
|
+
const add = secretChars(input);
|
|
36
|
+
return add ? { value: value + add } : {};
|
|
37
|
+
}
|
|
38
|
+
/** The mask for a value of `length` characters. */
|
|
39
|
+
export function maskFor(length) {
|
|
40
|
+
return "•".repeat(Math.min(length, MASK_MAX));
|
|
41
|
+
}
|
|
42
|
+
export function SecretPrompt({ pending }) {
|
|
43
|
+
// A ref, not state: a paste can land as several chunks (with Enter right behind them) before React re-renders, and
|
|
44
|
+
// each must extend what the last one typed. `size` is all the render ever sees.
|
|
45
|
+
const valueRef = useRef("");
|
|
46
|
+
const [size, setSize] = useState(0);
|
|
47
|
+
useEffect(() => { valueRef.current = ""; setSize(0); }, [pending]); // a new prompt never inherits the last value
|
|
48
|
+
useInput((input, key) => {
|
|
49
|
+
if (!pending)
|
|
50
|
+
return;
|
|
51
|
+
const a = secretKey(valueRef.current, input, key);
|
|
52
|
+
if (a.cancel) {
|
|
53
|
+
valueRef.current = "";
|
|
54
|
+
setSize(0);
|
|
55
|
+
pending.resolve("cancelled");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (a.submit !== undefined) {
|
|
59
|
+
valueRef.current = "";
|
|
60
|
+
setSize(0);
|
|
61
|
+
let ok = false;
|
|
62
|
+
try {
|
|
63
|
+
ok = pending.store(a.submit);
|
|
64
|
+
}
|
|
65
|
+
catch { /* an unwritable key file is a failed store, not a crash */ }
|
|
66
|
+
pending.resolve(ok ? "stored" : "failed");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (a.value !== undefined) {
|
|
70
|
+
valueRef.current = a.value;
|
|
71
|
+
setSize(a.value.length);
|
|
72
|
+
}
|
|
73
|
+
}, { isActive: !!pending });
|
|
74
|
+
if (!pending)
|
|
75
|
+
return null;
|
|
76
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsxs(Text, { color: "cyan", bold: true, children: ["? ", _jsx(Text, { color: "white", children: pending.title })] }), _jsxs(Text, { children: [" ", _jsx(Text, { color: "magenta", children: "› " }), maskFor(size), _jsx(Text, { color: "cyan", children: "\u258C" }), size ? _jsx(Text, { dimColor: true, children: ` ${size} characters` }) : null] }), _jsx(Text, { dimColor: true, children: " Enter to store · Esc to cancel · ctrl+u to clear — the key is never shown or logged" })] }));
|
|
77
|
+
}
|
package/dist/ui/StatusRule.js
CHANGED
|
@@ -40,7 +40,7 @@ export function truncateToWidth(s, max) {
|
|
|
40
40
|
}
|
|
41
41
|
// The dim `info` string (right of the wordmark) and the full measured `right` line, kept as one pure
|
|
42
42
|
// function so the width math is testable without a render. `info` = think · plan · seat · identity ·
|
|
43
|
-
// route · ctx% · version; `right` prefixes the ✷ OPERATOR wordmark and suffixes the trailing " ─". When
|
|
43
|
+
// route · ctx pin + ctx% · version; `right` prefixes the ✷ OPERATOR wordmark and suffixes the trailing " ─". When
|
|
44
44
|
// the terminal is too narrow to hold every badge, `info` is truncated so cellWidth(right) ≤ cols-3 —
|
|
45
45
|
// which keeps the leading fill ≥ 1 and the whole line at cols-1, so the rule never becomes the line that
|
|
46
46
|
// wraps (the creep bug) no matter how many badges are lit or how narrow the window.
|
|
@@ -51,12 +51,12 @@ export function statusRight(p, cols) {
|
|
|
51
51
|
const think = p.thinkMode === "ultrathink" ? `✲✲ ultrathink · ` : p.thinkMode === "think" ? `✲ think · ` : "";
|
|
52
52
|
const tok = p.sessionTokens && p.sessionTokens > 0 ? `Σ${fmtK(p.sessionTokens)} · ` : ""; // session token total
|
|
53
53
|
// ctx as a fill ring (○◔◑◕●) + the exact % — a glance shows how full the context window is, the number keeps precision.
|
|
54
|
-
// Show the
|
|
55
|
-
// (
|
|
56
|
-
// operator-1m into "aurora-300k",
|
|
57
|
-
// (api.axe.onl) — so the owner couldn't tell the local default from the broken remote. Route is the truth.
|
|
54
|
+
// Show the active model's id (operator-1m, cortana, claude-opus, moa, custom …), never the leg that answered
|
|
55
|
+
// ("cortana@192.168.1.103:8112" read as noise; /endpoints lists the legs). No display rewrite of the id: the old
|
|
56
|
+
// one turned operator-1m into "aurora-300k", indistinguishable from the dead cloud profile axe-aurora-300k.
|
|
58
57
|
const routeLabel = p.route;
|
|
59
|
-
|
|
58
|
+
const pin = p.ctxPin ? `ctx ${p.ctxPin} ` : "";
|
|
59
|
+
let info = `${think}${plan}${seat}${who}${routeLabel} · ${pin}${ring(p.ctxPct)} ${Math.round(p.ctxPct)}% · ${tok}v${p.version}${p.build ? ` ·${p.build}` : ""}`;
|
|
60
60
|
let right = `✷ OPERATOR · ${info} ─`;
|
|
61
61
|
const maxRight = cols - 3; // leaves fill ≥ 1 and total = cols-1
|
|
62
62
|
if (cellWidth(right) > maxRight) {
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// /model's pure half — the rows and their order, the "+ Connect a provider key" action, the context step and /context
|
|
2
|
+
// rows, the provider rows, and what a picked answer means — so cli.tsx only wires them to the Session (the same split as
|
|
3
|
+
// planExit.ts). Every picker here resolves by INDEX into the entries its rows were drawn from: row text can repeat.
|
|
4
|
+
import { BYO_PRESETS, fmtCtx, pickerRow, shortName } from "../router/models.js";
|
|
5
|
+
import { markPickerOptions, portalIdFor } from "../router/portal.js";
|
|
6
|
+
import { CONTEXT_PRESETS } from "../config/settings.js";
|
|
7
|
+
import { DISCUSS } from "./QuestionPrompt.js";
|
|
8
|
+
/** The last /model row: an action, never a ModelProfile — so the lists fed from the registry (the ACP dropdown, a
|
|
9
|
+
* follower's model list) can never offer it. */
|
|
10
|
+
export const CONNECT_ROW = "+ Connect a provider key (Anthropic, Google, Nous, OpenAI, …)";
|
|
11
|
+
/** Presets whose zero-price rows /model lists once their key is connected (router/free-models.ts) — OpenRouter's
|
|
12
|
+
* `:free` listing joins here. */
|
|
13
|
+
export const FREE_ROW_PRESETS = ["nous"];
|
|
14
|
+
// fleet → connected providers → free rows → MOA. The built-ins already list this box (JL2) before JL1.
|
|
15
|
+
const group = (m) => (m.kind === "orchestrated" ? 3 : m.tier === "free" ? 2 : m.byo ? 1 : 0);
|
|
16
|
+
/** The picker order of a visible registry: fleet rows, the connected providers, the free rows, then MOA — a stable
|
|
17
|
+
* partition, so registry order decides inside each group. */
|
|
18
|
+
export function pickerOrder(models) {
|
|
19
|
+
return models.map((m, i) => ({ m, i })).sort((a, b) => group(a.m) - group(b.m) || a.i - b.i).map(({ m }) => m);
|
|
20
|
+
}
|
|
21
|
+
/** The /model rows in picker order — pickerRow for each (the active single model shows its served window), " · cached"
|
|
22
|
+
* on free rows served from the disk cache — closed by the connect row. */
|
|
23
|
+
export function modelPickerView(models, o) {
|
|
24
|
+
const ordered = pickerOrder(models);
|
|
25
|
+
const rows = ordered.map((m) => {
|
|
26
|
+
const active = m.id === o.active;
|
|
27
|
+
const row = pickerRow(m, { servedCtx: active && m.kind === "single" ? o.servedCtx : undefined });
|
|
28
|
+
return `${row}${o.staleFree && m.tier === "free" ? " · cached" : ""}${active ? " (active)" : ""}`;
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
rows: [...rows, CONNECT_ROW],
|
|
32
|
+
entries: [...ordered.map((profile) => ({ kind: "model", profile })), { kind: "connect" }],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** The rows with the portal's live markers (● ○ ✕ ?) on the model rows — same count, same order; the connect row is
|
|
36
|
+
* never marked. `cat` undefined leaves them as they are. */
|
|
37
|
+
export function markModelRows(view, cat) {
|
|
38
|
+
const models = view.entries.flatMap((e) => (e.kind === "model" ? [e.profile] : []));
|
|
39
|
+
return [...markPickerOptions(view.rows.slice(0, models.length), models.map(portalIdFor), cat), ...view.rows.slice(models.length)];
|
|
40
|
+
}
|
|
41
|
+
/** Whether a /model pick earns the "Context for this session" step: a single model whose window beats the smallest
|
|
42
|
+
* pin (at or under it there is nothing to choose). */
|
|
43
|
+
export function wantsContextStep(p, window) {
|
|
44
|
+
return p.kind === "single" && window > Math.min(...CONTEXT_PRESETS);
|
|
45
|
+
}
|
|
46
|
+
/** The context rows — 1M, 600K, 300K, then "auto (served N)" — with the current choice moved to the top and marked;
|
|
47
|
+
* a pin that is no preset (KODE_CONTEXT=262144) gets its own row, so the current one is always on screen. */
|
|
48
|
+
export function contextPickerView(current, served) {
|
|
49
|
+
const choices = [...[...CONTEXT_PRESETS].sort((a, b) => b - a), undefined];
|
|
50
|
+
const pins = [current, ...choices.filter((p) => p !== current)];
|
|
51
|
+
const name = (p) => (p === undefined ? `auto (served ${served.toLocaleString("en-US")})` : fmtCtx(p));
|
|
52
|
+
return { rows: pins.map((p, i) => `${name(p)}${i === 0 ? " (current)" : ""}`), pins };
|
|
53
|
+
}
|
|
54
|
+
/** The line every context change prints: `context → 600K (served 1,048,576) · fill 12%`; a pin above the served
|
|
55
|
+
* window says the engine runs on the served one. */
|
|
56
|
+
export function contextLine(pin, served, fillPct) {
|
|
57
|
+
const clamp = pin !== undefined && pin > served ? ` — using ${fmtCtx(served)}` : "";
|
|
58
|
+
return `context → ${pin === undefined ? "auto" : fmtCtx(pin)} (served ${served.toLocaleString("en-US")}${clamp}) · fill ${fillPct}%`;
|
|
59
|
+
}
|
|
60
|
+
/** `has` (auth/byo.ts hasByoToken) asked at most once per account while one /model picker is open — a keychain miss
|
|
61
|
+
* spawns `security` (~20-50 ms), so the open looks up only the accounts a row needs, each once. */
|
|
62
|
+
export function onceEach(has) {
|
|
63
|
+
const seen = new Map();
|
|
64
|
+
return (account, endpoint) => {
|
|
65
|
+
const k = `${account}\u0000${endpoint ?? ""}`;
|
|
66
|
+
let v = seen.get(k);
|
|
67
|
+
if (v === undefined)
|
|
68
|
+
seen.set(k, (v = has(account, endpoint)));
|
|
69
|
+
return v;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** The connected accounts among the presets — one pass through `has` (pass the open's onceEach), each checked against
|
|
73
|
+
* its preset's own host so a vendor's env variable counts only there. */
|
|
74
|
+
export function connectedAccounts(has, presets = BYO_PRESETS) {
|
|
75
|
+
return new Set(Object.values(presets).filter((p) => has(p.account, p.endpoint)).map((p) => p.account));
|
|
76
|
+
}
|
|
77
|
+
/** The provider rows, from the presets in their order — never listByoAccounts, which sees only the file tier:
|
|
78
|
+
* `<label>`, plus " ✓ connected" for an account in `connected`. */
|
|
79
|
+
export function providerPickerView(connected, presets = BYO_PRESETS) {
|
|
80
|
+
const choices = Object.entries(presets).map(([preset, p]) => ({ preset, p }));
|
|
81
|
+
return { rows: choices.map(({ p }) => `${p.label}${connected.has(p.account) ? " ✓ connected" : ""}`), choices };
|
|
82
|
+
}
|
|
83
|
+
/** What a QuestionPrompt answer means for a picker whose rows were drawn from `entries`: the row picked (by index), the
|
|
84
|
+
* owner's typed reply, or null — the empty reply / ctrl+c that resolves DISCUSS is never applied as a choice. */
|
|
85
|
+
export function pickerAnswer(entries, answer, index) {
|
|
86
|
+
if (index !== undefined)
|
|
87
|
+
return index >= 0 && index < entries.length ? { entry: entries[index] } : null;
|
|
88
|
+
const typed = answer.trim();
|
|
89
|
+
return !typed || answer === DISCUSS ? null : { typed };
|
|
90
|
+
}
|
|
91
|
+
/** The /model line after a pick: `model → <id> · ctx N% · turns N`; a free row repeats its caveat instead. */
|
|
92
|
+
export function modelLine(id, chosen, ctxPct, turns) {
|
|
93
|
+
if (chosen?.tier === "free")
|
|
94
|
+
return `model → ${id} · ${chosen.desc ?? "free tier"}`;
|
|
95
|
+
return `model → ${id} · ctx ${ctxPct}% · turns ${turns}`;
|
|
96
|
+
}
|
|
97
|
+
/** After a key is stored: the rows it unlocked, by name — or why none show yet. */
|
|
98
|
+
export function keyStoredLine(account, rows, preset, free = false) {
|
|
99
|
+
if (rows.length)
|
|
100
|
+
return `${account} key stored — rows added: ${rows.map(shortName).join(", ")}`;
|
|
101
|
+
return free
|
|
102
|
+
? `${account} key stored — its free rows did not load yet; /model fetches them again`
|
|
103
|
+
: `${account} key stored — no /model row uses it yet: operator auth byo-model --preset ${preset} adds one`;
|
|
104
|
+
}
|
|
105
|
+
/** True for text that reads as a credential, not a model id (a vendor key prefix, or one long unbroken token): such text is
|
|
106
|
+
* never echoed back in an "unknown model" line, which would put it in the transcript and relay it to followers. */
|
|
107
|
+
export function looksLikeSecret(text) {
|
|
108
|
+
const t = text.trim();
|
|
109
|
+
return /^(?:sk-|sk_|ghp_|gho_|xai-|AIza|op_|key-)/.test(t) || /^[A-Za-z0-9_\-]{40,}$/.test(t);
|
|
110
|
+
}
|
package/dist/ui/slashCommands.js
CHANGED
|
@@ -4,7 +4,9 @@ export const SLASH_COMMANDS = [
|
|
|
4
4
|
{ name: "login", description: "sign in: /login opens the browser to approve; or /login <email> for a 6-digit code (then /login <code>), or /login <token>", args: "[email|code|token]" },
|
|
5
5
|
{ name: "logout", description: "sign out and clear stored credentials" },
|
|
6
6
|
{ name: "whoami", description: "show the signed-in identity" },
|
|
7
|
-
{ name: "model", description: "pick a model
|
|
7
|
+
{ name: "model", description: "pick a model — fleet, connected providers, free rows; + connect a key", args: "[id]" },
|
|
8
|
+
{ name: "context", description: "context window for this session: 1M · 600K · 300K · auto (ctrl+x cycles)", args: "[300k|600k|1m|auto]" },
|
|
9
|
+
{ name: "ctx", description: "alias of /context", args: "[300k|600k|1m|auto]" },
|
|
8
10
|
{ name: "route", description: "pin routing to an endpoint, or auto (by size)", args: "[endpoint|auto]" },
|
|
9
11
|
{ name: "endpoints", description: "show the Operator endpoint + live health" },
|
|
10
12
|
{ name: "services", description: "ensure/inspect the service lever (Operator+autopilot+searxng)", args: "[stop]" },
|
package/dist/util/slash.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// to handleSlash. A pasted path like "/Users/foo/bar" or multi-line text starting with "/" is NOT
|
|
3
3
|
// a slash command — it goes to the model as user input.
|
|
4
4
|
const KNOWN = new Set([
|
|
5
|
-
"help", "model", "route", "endpoints", "services", "audit", "dashboard", "plan", "mode",
|
|
5
|
+
"help", "model", "context", "ctx", "route", "endpoints", "services", "audit", "dashboard", "plan", "mode",
|
|
6
6
|
"think", "ultrathink", "compact", "remember", "memory", "mcp", "whoami", "agents", "jobs", "monitor",
|
|
7
7
|
"bg", "new", "clear", "exit", "quit", "stats", "login", "logout", "remote", "remotecontrol", "rc",
|
|
8
|
-
"artifacts", "sessions", "skills", "
|
|
8
|
+
"artifacts", "sessions", "skills", "skill", "allow", "caffeinate", "caffeine", "deep-research", "deepresearch",
|
|
9
|
+
"research", "pair",
|
|
9
10
|
]);
|
|
10
11
|
export function isSlashCommand(text) {
|
|
11
12
|
const t = text.trim();
|