@0perator/operator 0.1.35 → 0.1.37
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/cli.js +27 -2
- package/dist/engine/agent.js +1 -0
- package/dist/engine/aurora.js +4 -0
- package/dist/session.js +61 -2
- package/dist/ui/App.js +3 -2
- package/dist/ui/QuestionPrompt.js +18 -0
- package/dist/ui/StatusRule.js +4 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -19,7 +19,7 @@ import { expandFileMentions } from "./util/mentions.js";
|
|
|
19
19
|
import { join } from "node:path";
|
|
20
20
|
import { homedir, hostname } from "node:os";
|
|
21
21
|
import { createHash } from "node:crypto";
|
|
22
|
-
const VERSION = "0.1.
|
|
22
|
+
const VERSION = "0.1.37";
|
|
23
23
|
// operator/settings.json (override path via KODE_TSI_SETTINGS), env vars still win — see config/settings.ts.
|
|
24
24
|
const settings = loadSettings();
|
|
25
25
|
// Propagate the resolved sandbox mode to the tool layer (registry reads KODE_SANDBOX at exec time).
|
|
@@ -151,6 +151,8 @@ const HELP = [
|
|
|
151
151
|
" /audit [n] recent tool + control-plane events from the audit trail (default 15)",
|
|
152
152
|
" /dashboard launch the live swarm console (watches every Operator session)",
|
|
153
153
|
" /plan plan mode: read-only research + propose a plan (/plan again to execute)",
|
|
154
|
+
" /think extended reasoning: Aurora thinks before answering (/think again = off)",
|
|
155
|
+
" /ultrathink deep, exhaustive reasoning for hard problems (/ultrathink again = off)",
|
|
154
156
|
" /compact force-compact the conversation now",
|
|
155
157
|
" /remember <note> store a note to recall in future sessions",
|
|
156
158
|
" /memory [query] show remembered notes (all, or matching query)",
|
|
@@ -188,6 +190,7 @@ function Root() {
|
|
|
188
190
|
const [bgAgents, setBgAgents] = useState([]);
|
|
189
191
|
const [authUser, setAuthUser] = useState(""); // signed-in identity for the status rule
|
|
190
192
|
const [planMode, setPlanMode] = useState(false); // /plan: read-only research + propose, shown as a status badge
|
|
193
|
+
const [thinkMode, setThinkMode] = useState("off"); // /think, /ultrathink badge
|
|
191
194
|
const [elapsed, setElapsed] = useState(0); // live seconds since the current turn started (ticked by a
|
|
192
195
|
const turnStartRef = useRef(0); // timer, so the clock advances even during a long reasoning
|
|
193
196
|
// phase where no content tokens stream — that was the "timer stuck" bug (Ink only re-renders on deltas).
|
|
@@ -195,6 +198,11 @@ function Root() {
|
|
|
195
198
|
// decision here and <ApprovalPrompt> renders it; the keystroke resolves the promise. "allow always"
|
|
196
199
|
// adds the tool to a per-session set so it stops prompting. (No approver ⇒ policy fail-safe denies.)
|
|
197
200
|
const [approval, setApproval] = useState(null);
|
|
201
|
+
// ask_user bridge: the model's clarification question, parked here until the owner picks an option.
|
|
202
|
+
const [question, setQuestion] = useState(null);
|
|
203
|
+
const askUser = useCallback((q, options) => new Promise((resolve) => {
|
|
204
|
+
setQuestion({ question: q, options, resolve: (a) => { setQuestion(null); resolve(a); } });
|
|
205
|
+
}), []);
|
|
198
206
|
const alwaysAllowRef = useRef(new Set());
|
|
199
207
|
// Pending gated approvals by id. Both the local keystroke and a remote follower's approval_response
|
|
200
208
|
// route through settleApproval — FIRST answer wins (§7); the map delete makes it idempotent.
|
|
@@ -234,6 +242,7 @@ function Root() {
|
|
|
234
242
|
recall: settings.memory.recall,
|
|
235
243
|
permissions: fgPermissions, // owner's policy + computer tools forced to "ask" when enabled (else bypass)
|
|
236
244
|
approve: approveFn, // renders the in-TUI approval prompt for any "ask" decision
|
|
245
|
+
askUser, // registers the ask_user tool so the model can put a clarifying question to the owner
|
|
237
246
|
telemetry: settings.telemetry, // local-only metrics by default
|
|
238
247
|
eventSink, eventActor: EVENT_ACTOR, sessionId: SESSION_ID, // frozen event stream (tool/control audit)
|
|
239
248
|
// Foreground only: lets Aurora delegate via spawn_agent. The bg factory below OMITS this, so a
|
|
@@ -567,6 +576,22 @@ function Root() {
|
|
|
567
576
|
: "plan mode OFF — back to normal execution.");
|
|
568
577
|
break;
|
|
569
578
|
}
|
|
579
|
+
case "think": {
|
|
580
|
+
const on = s.currentThinkMode() !== "think";
|
|
581
|
+
s.setThinkMode(on ? "think" : "off");
|
|
582
|
+
setThinkMode(on ? "think" : "off");
|
|
583
|
+
sys(on ? "✲ think ON — Aurora reasons (shown dimmed) before answering. /think again to turn off."
|
|
584
|
+
: "think off — back to fast direct answers.");
|
|
585
|
+
break;
|
|
586
|
+
}
|
|
587
|
+
case "ultrathink": {
|
|
588
|
+
const on = s.currentThinkMode() !== "ultrathink";
|
|
589
|
+
s.setThinkMode(on ? "ultrathink" : "off");
|
|
590
|
+
setThinkMode(on ? "ultrathink" : "off");
|
|
591
|
+
sys(on ? "✲✲ ultrathink ON — Aurora reasons deeply + exhaustively before answering (slower, deeper). /ultrathink again to turn off."
|
|
592
|
+
: "ultrathink off — back to fast direct answers.");
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
570
595
|
case "audit": {
|
|
571
596
|
// The human-supervisor view of the frozen event stream: recent tool decisions + control events
|
|
572
597
|
// (tier denials, signature lines, RC) straight from the audit JSONL. Read-only.
|
|
@@ -742,7 +767,7 @@ function Root() {
|
|
|
742
767
|
const liveMetrics = active
|
|
743
768
|
? `${SPIN[Math.floor(elapsed * 4) % SPIN.length]} ${fmtMeta(elapsed, liveTok)}`
|
|
744
769
|
: metrics;
|
|
745
|
-
return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, route: route, ctxPct: ctxPct, version: VERSION, metrics: liveMetrics, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, verbs: settings.verbs, bgAgents: bgAgents, onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, approval: approval, onApprovalDecide: (allow, always) => {
|
|
770
|
+
return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, route: route, ctxPct: ctxPct, version: VERSION, metrics: liveMetrics, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, approval: approval, question: question, onApprovalDecide: (allow, always) => {
|
|
746
771
|
const cur = approval;
|
|
747
772
|
if (cur)
|
|
748
773
|
settleApproval(cur.id, allow, always); // first-wins with any remote follower answer
|
package/dist/engine/agent.js
CHANGED
|
@@ -145,6 +145,7 @@ export async function runTurn(userInput, conversation, opts) {
|
|
|
145
145
|
maxTokens,
|
|
146
146
|
temperature: opts.temperature,
|
|
147
147
|
tools: opts.toolSchemas,
|
|
148
|
+
thinking: opts.thinking,
|
|
148
149
|
signal: opts.signal,
|
|
149
150
|
onDelta: opts.onDelta,
|
|
150
151
|
onReasoning: opts.onReasoning,
|
package/dist/engine/aurora.js
CHANGED
|
@@ -60,6 +60,10 @@ function requestBody(messages, o, stream) {
|
|
|
60
60
|
model: o.model, messages, stream,
|
|
61
61
|
max_tokens: o.maxTokens ?? 8192, temperature: o.temperature ?? 0.7,
|
|
62
62
|
...(o.tools?.length ? { tools: o.tools, tool_choice: "auto" } : {}),
|
|
63
|
+
// /think: re-enable the model's native reasoning for THIS request, overriding the server's
|
|
64
|
+
// enable_thinking:false default (set for speed). Verified this per-request override works on the
|
|
65
|
+
// Aurora build; reasoning arrives as reasoning_content and renders dimmed.
|
|
66
|
+
...(o.thinking ? { chat_template_kwargs: { enable_thinking: true } } : {}),
|
|
63
67
|
// NO repeat/presence/frequency penalty knobs — SPEC §1: they break tool-calling.
|
|
64
68
|
});
|
|
65
69
|
}
|
package/dist/session.js
CHANGED
|
@@ -39,6 +39,37 @@ function makeSpawnTool(handler) {
|
|
|
39
39
|
},
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
+
// The `ask_user` tool — the model pauses to ask the owner a structured multiple-choice question and gets
|
|
43
|
+
// the chosen option back as the tool result. safe:false (an interaction, not a speculative read). The
|
|
44
|
+
// handler (the shell) renders the prompt and blocks until the owner answers.
|
|
45
|
+
function makeAskTool(handler) {
|
|
46
|
+
return {
|
|
47
|
+
name: "ask_user",
|
|
48
|
+
safe: false,
|
|
49
|
+
description: "Ask the owner a single, clarifying multiple-choice question when the task is genuinely ambiguous " +
|
|
50
|
+
"and a wrong assumption would waste real work. Blocks until they choose, then returns the chosen " +
|
|
51
|
+
"option. Use SPARINGLY — prefer a sensible default and proceeding; never ask what you can determine " +
|
|
52
|
+
"from the code or the request. Provide 2-4 concrete, mutually-exclusive options.",
|
|
53
|
+
parameters: {
|
|
54
|
+
type: "object",
|
|
55
|
+
properties: {
|
|
56
|
+
question: { type: "string", description: "The clarifying question, one sentence." },
|
|
57
|
+
options: { type: "array", items: { type: "string" }, description: "2-4 concrete choices." },
|
|
58
|
+
},
|
|
59
|
+
required: ["question", "options"],
|
|
60
|
+
},
|
|
61
|
+
run: async (args) => {
|
|
62
|
+
const question = String(args.question ?? "").trim();
|
|
63
|
+
const options = Array.isArray(args.options) ? args.options.map((o) => String(o)).filter(Boolean) : [];
|
|
64
|
+
if (!question)
|
|
65
|
+
return "error: ask_user needs a question";
|
|
66
|
+
if (options.length < 2)
|
|
67
|
+
return "error: ask_user needs at least 2 options";
|
|
68
|
+
const answer = await handler(question, options.slice(0, 4));
|
|
69
|
+
return `The user chose: ${answer}`;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
42
73
|
const SUMMARY_MAX_TOKENS = 1200; // room for Aurora's reasoning before the summary content lands
|
|
43
74
|
export class Session {
|
|
44
75
|
convo = new Conversation();
|
|
@@ -64,12 +95,20 @@ export class Session {
|
|
|
64
95
|
wantRecall;
|
|
65
96
|
recallBlock = ""; // memory recalled on the first turn, folded into the system prompt thereafter
|
|
66
97
|
planMode = false; // /plan: research read-only + propose a plan, no mutations until the owner approves
|
|
98
|
+
thinkMode = "off"; // /think, /ultrathink — extended reasoning
|
|
67
99
|
recalled = false;
|
|
68
100
|
constructor(cfg = {}) {
|
|
69
101
|
// Per-session tool registry: the base set, plus `spawn_agent` when the shell provides a delegate
|
|
70
102
|
// handler (foreground only). Both the executor (dispatch) and localSchemas (what the model sees)
|
|
71
103
|
// are built from the same map, so the tool is advertised iff it's runnable.
|
|
72
|
-
|
|
104
|
+
let reg = registry;
|
|
105
|
+
if (cfg.spawnAgent || cfg.askUser) {
|
|
106
|
+
reg = new Map(registry);
|
|
107
|
+
if (cfg.spawnAgent)
|
|
108
|
+
reg.set("spawn_agent", makeSpawnTool(cfg.spawnAgent));
|
|
109
|
+
if (cfg.askUser)
|
|
110
|
+
reg.set("ask_user", makeAskTool(cfg.askUser));
|
|
111
|
+
}
|
|
73
112
|
this.executor = new Executor(reg);
|
|
74
113
|
this.localSchemas = toSchemas(reg);
|
|
75
114
|
this.inner = cfg.router ?? new AuroraRouter();
|
|
@@ -106,6 +145,17 @@ export class Session {
|
|
|
106
145
|
`(/plan) to let you execute.`;
|
|
107
146
|
return (base ?? "") + plan;
|
|
108
147
|
}
|
|
148
|
+
/** The system prompt with the ultrathink push appended when that mode is on. /think alone just enables
|
|
149
|
+
* the model's native reasoning (no prompt change needed); ultrathink also asks it to go deeper. */
|
|
150
|
+
sysWithThink() {
|
|
151
|
+
const base = this.sys();
|
|
152
|
+
if (this.thinkMode !== "ultrathink")
|
|
153
|
+
return base;
|
|
154
|
+
const push = `\n\n## ULTRATHINK (active)\nThink exhaustively before answering: reason step by step ` +
|
|
155
|
+
`through the whole problem, surface assumptions, weigh alternatives and edge cases, and check your ` +
|
|
156
|
+
`own work — then give the answer. Depth over speed for this turn.`;
|
|
157
|
+
return (base ?? "") + push;
|
|
158
|
+
}
|
|
109
159
|
/** Compose the tool executor: local tools + MCP (composite) with the permission/audit layer on top.
|
|
110
160
|
* withPermissions returns the composite UNCHANGED when the policy is inert (bypass) — zero overhead.
|
|
111
161
|
* In plan mode a read-only gated policy (no approver → mutating tools fail-safe deny) overrides the
|
|
@@ -127,6 +177,14 @@ export class Session {
|
|
|
127
177
|
inPlanMode() {
|
|
128
178
|
return this.planMode;
|
|
129
179
|
}
|
|
180
|
+
/** Set extended-reasoning mode (/think, /ultrathink). "think" re-enables Aurora's native reasoning for
|
|
181
|
+
* each turn; "ultrathink" also pushes for deeper step-by-step reasoning via the system prompt. */
|
|
182
|
+
setThinkMode(mode) {
|
|
183
|
+
this.thinkMode = mode;
|
|
184
|
+
}
|
|
185
|
+
currentThinkMode() {
|
|
186
|
+
return this.thinkMode;
|
|
187
|
+
}
|
|
130
188
|
/** Is the currently-selected endpoint reachable? Lets the shell fail clearly before a turn. */
|
|
131
189
|
health() {
|
|
132
190
|
return health(this.inner.base);
|
|
@@ -268,10 +326,11 @@ export class Session {
|
|
|
268
326
|
router: this.router,
|
|
269
327
|
tools: this.tools,
|
|
270
328
|
toolSchemas: this.allSchemas(),
|
|
271
|
-
systemPrompt: this.
|
|
329
|
+
systemPrompt: this.sysWithThink(),
|
|
272
330
|
summarize: this.summarize,
|
|
273
331
|
maxTokens: this.maxTokens,
|
|
274
332
|
temperature: this.temperature,
|
|
333
|
+
thinking: this.thinkMode !== "off", // /think, /ultrathink re-enable Aurora's native reasoning
|
|
275
334
|
signal: controller.signal,
|
|
276
335
|
onDelta: h.onDelta,
|
|
277
336
|
onReasoning: h.onReasoning,
|
package/dist/ui/App.js
CHANGED
|
@@ -8,11 +8,12 @@ import { ThinkingSpinner } from "./ThinkingSpinner.js";
|
|
|
8
8
|
import { StepSpinner, RecoverSpinner } from "./ActivitySpinner.js";
|
|
9
9
|
import { BgPanel } from "./BgPanel.js";
|
|
10
10
|
import { ApprovalPrompt } from "./ApprovalPrompt.js";
|
|
11
|
+
import { QuestionPrompt } from "./QuestionPrompt.js";
|
|
11
12
|
export function App(props) {
|
|
12
|
-
const { messages, live = null, status, thinkingVerb, verbs, stepLabel, route, ctxPct, version, build, metrics, authUser, tier, planMode, bgAgents, onSubmit, onQueue, onInterrupt, approval = null, onApprovalDecide } = props;
|
|
13
|
+
const { messages, live = null, status, thinkingVerb, verbs, stepLabel, route, ctxPct, version, build, metrics, authUser, tier, planMode, thinkMode, bgAgents, onSubmit, onQueue, onInterrupt, approval = null, onApprovalDecide, question = null } = props;
|
|
13
14
|
const thinking = status === "thinking" || status === "streaming";
|
|
14
15
|
const showSpinner = status === "recovering" || status === "executing" || thinking;
|
|
15
16
|
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Transcript, { entries: messages, live: live }), showSpinner && (_jsx(Box, { marginTop: 1, marginBottom: 1, children: status === "recovering" ? _jsx(RecoverSpinner, { active: true, label: stepLabel })
|
|
16
17
|
: status === "executing" ? _jsx(StepSpinner, { active: true, label: stepLabel })
|
|
17
|
-
: _jsx(ThinkingSpinner, { active: true, verb: thinkingVerb, verbs: verbs, metrics: metrics }) })), _jsx(BgPanel, { agents: bgAgents }), _jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }) }), _jsx(StatusRule, { route: route, ctxPct: ctxPct, version: version, build: build, user: authUser, tier: tier, planMode: planMode }), _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, disabled: status !== "idle", suspended: !!approval }), _jsx(InputRule, {})] }));
|
|
18
|
+
: _jsx(ThinkingSpinner, { active: true, verb: thinkingVerb, verbs: verbs, metrics: metrics }) })), _jsx(BgPanel, { agents: bgAgents }), _jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }) }), _jsx(QuestionPrompt, { pending: question }), _jsx(StatusRule, { route: route, ctxPct: ctxPct, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode }), _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, disabled: status !== "idle", suspended: !!approval || !!question }), _jsx(InputRule, {})] }));
|
|
18
19
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text, useInput } from "ink";
|
|
3
|
+
export function QuestionPrompt({ pending }) {
|
|
4
|
+
useInput((input, key) => {
|
|
5
|
+
if (!pending)
|
|
6
|
+
return;
|
|
7
|
+
if (key.ctrl && input.toLowerCase() === "c") {
|
|
8
|
+
pending.resolve(pending.options[0]);
|
|
9
|
+
return;
|
|
10
|
+
} // bail = first option
|
|
11
|
+
const n = Number(input);
|
|
12
|
+
if (Number.isInteger(n) && n >= 1 && n <= pending.options.length)
|
|
13
|
+
pending.resolve(pending.options[n - 1]);
|
|
14
|
+
}, { isActive: !!pending });
|
|
15
|
+
if (!pending)
|
|
16
|
+
return null;
|
|
17
|
+
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.question })] }), pending.options.map((o, i) => (_jsxs(Text, { children: [" ", _jsxs(Text, { color: "cyan", children: ["[", i + 1, "]"] }), " ", o] }, i))), _jsx(Text, { dimColor: true, children: " press 1-" + pending.options.length + " to choose" })] }));
|
|
18
|
+
}
|
package/dist/ui/StatusRule.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
|
-
export function StatusRule({ route, ctxPct, version, build, user, tier, planMode }) {
|
|
3
|
+
export function StatusRule({ route, ctxPct, version, build, user, tier, planMode, thinkMode }) {
|
|
4
4
|
const who = user ? `⬤ ${user} · ` : "";
|
|
5
5
|
const seat = tier && tier !== "admin" ? `⛨ ${tier} · ` : ""; // a narrowed seat is visible; the owner's admin is not
|
|
6
6
|
const plan = planMode ? `◔ plan · ` : ""; // read-only research mode is visible while active
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const think = thinkMode === "ultrathink" ? `✲✲ ultrathink · ` : thinkMode === "think" ? `✲ think · ` : "";
|
|
8
|
+
// Info block: think · plan · seat · identity · route · ctx% · version. One string so the width math is exact.
|
|
9
|
+
const info = `${think}${plan}${seat}${who}${route} · ${Math.round(ctxPct)}% · v${version}${build ? ` ·${build}` : ""}`;
|
|
9
10
|
// The full right-hand content, styled below in segments (✷ magenta, OPERATOR bold, info dim). This
|
|
10
11
|
// plain string is only used to measure width so the leading rule fills precisely.
|
|
11
12
|
const right = `✷ OPERATOR · ${info} ─`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0perator/operator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37",
|
|
4
4
|
"description": "Operator (KODE) — TypeScript + Ink terminal coding agent. Full-frame render, single-engine core shared across CLI/web/mobile; runs against a local Aurora model.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|