@0perator/operator 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/auth/commands.js +7 -3
- package/dist/auth/identity.js +1 -0
- package/dist/auth/staff.js +55 -0
- package/dist/autonomy/delegate-mode.js +2 -2
- package/dist/autonomy/delegate.js +41 -14
- package/dist/autonomy/headless.js +7 -4
- package/dist/autonomy/index.js +2 -4
- package/dist/autonomy/session-factory.js +11 -12
- package/dist/autonomy/subagent-model.js +17 -7
- package/dist/background/capacity.js +136 -0
- package/dist/background/evidence.js +42 -0
- package/dist/background/index.js +311 -44
- package/dist/background/lane-phase.js +60 -0
- package/dist/background/lane-summary.js +151 -0
- package/dist/background/notices.js +12 -3
- package/dist/background/synthesis.js +25 -0
- package/dist/bus/inbox.js +150 -6
- package/dist/cli.js +191 -96
- package/dist/config/features.js +3 -3
- package/dist/config/persona.js +29 -3
- package/dist/config/settings.js +261 -20
- package/dist/config/staff-prompt.js +12 -0
- package/dist/engine/agent.js +51 -40
- package/dist/engine/aurora.js +36 -4
- package/dist/engine/batch-scheduler.js +4 -13
- package/dist/engine/compaction.js +1 -1
- package/dist/engine/continuation.js +30 -32
- package/dist/engine/decision-points.js +2 -3
- package/dist/engine/fanout.js +16 -0
- package/dist/engine/loop-guard.js +26 -83
- package/dist/engine/messages.js +2 -2
- package/dist/engine/moa.js +16 -1
- package/dist/engine/native-vision-node.js +72 -0
- package/dist/engine/native-vision.js +103 -0
- package/dist/engine/verify-gate.js +37 -7
- package/dist/gateway-cli.js +14 -3
- package/dist/memory/live-progress.js +4 -5
- package/dist/moa/codeact-lane.js +98 -0
- package/dist/moa/codeact-sandbox.js +409 -0
- package/dist/moa/codeact.js +140 -0
- package/dist/permissions/artifact-visibility.js +10 -0
- package/dist/permissions/tier.js +4 -2
- package/dist/products/craft.js +2 -2
- package/dist/remote/grants.js +119 -0
- package/dist/remote/host.js +33 -5
- package/dist/router/models.js +24 -14
- package/dist/selfimprove/index.js +8 -6
- package/dist/services/preflight.js +35 -91
- package/dist/session.js +127 -41
- package/dist/skills/install-guard.js +68 -0
- package/dist/skills/install.js +67 -0
- package/dist/toolchain/manifest.json +13 -13
- package/dist/tools/background-result.js +1 -1
- package/dist/tools/classes.js +103 -0
- package/dist/tools/contract.js +1 -1
- package/dist/tools/craft.js +13 -2
- package/dist/tools/executor.js +25 -15
- package/dist/tools/generation-gateway.js +94 -0
- package/dist/tools/registry.js +83 -152
- package/dist/ui/App.js +15 -4
- package/dist/ui/BgPanel.js +15 -10
- package/dist/ui/Header.js +1 -6
- package/dist/ui/StatusRule.js +18 -7
- package/dist/ui/ToolStep.js +3 -3
- package/dist/ui/Transcript.js +36 -14
- package/dist/ui/batchLine.js +4 -4
- package/dist/ui/editdiff.js +2 -4
- package/dist/ui/format.js +4 -20
- package/dist/ui/liveTools.js +3 -3
- package/dist/ui/opsMode.js +20 -0
- package/dist/ui/types.js +0 -2
- package/dist/update-check.js +17 -6
- package/package.json +1 -1
- package/dist/tools/mutating.js +0 -15
package/dist/ui/Transcript.js
CHANGED
|
@@ -44,30 +44,36 @@ function entryKey(entry) {
|
|
|
44
44
|
// approaches the window height, and the worst moment is the settle transition when this frame is erased.
|
|
45
45
|
// So cap the live view to a small slice (≤ ~16 rows, less on short terminals): enough to watch the answer
|
|
46
46
|
// stream, while the full text always renders complete via <Static> once it settles. Pure (dimensions
|
|
47
|
-
// passed in) so the bound is unit-testable.
|
|
48
|
-
|
|
47
|
+
// passed in) so the bound is unit-testable. `budget` (inline mode) is the exact row count the caller measured
|
|
48
|
+
// as free; without it the budget is derived from the terminal height as before (fullscreen).
|
|
49
|
+
export function liveTail(s, rows, cols, budget) {
|
|
49
50
|
// Clamp degenerate dimensions: a minimized/detached terminal reports 0, and cols=0 divides to
|
|
50
51
|
// Infinity/NaN below — which walks `start` to 0 and returns the WHOLE message unbounded, ballooning the
|
|
51
52
|
// dynamic frame and stacking the streaming line into scrollback (the minimize-duplication bug). Guard
|
|
52
53
|
// here too (not just at the call site) since this is the pure, unit-tested unit — it must not trust its caller.
|
|
53
54
|
const c = cols > 0 ? cols : 80;
|
|
54
|
-
const
|
|
55
|
+
const cap = budget !== undefined ? Math.max(1, budget) : Math.max(6, Math.min((rows > 0 ? rows : 24) - 14, 16)); // rendered rows the live frame may occupy
|
|
55
56
|
const lines = s.split("\n");
|
|
56
57
|
// Walk up from the last line, counting the PHYSICAL rows each takes after wrapping, and keep only what
|
|
57
58
|
// fits the budget — so even all-long-wrapping lines can't push the dynamic frame past the window.
|
|
58
59
|
let used = 0, start = lines.length;
|
|
59
60
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
60
61
|
const wrapped = Math.max(1, Math.ceil(lines[i].length / c));
|
|
61
|
-
if (used + wrapped >
|
|
62
|
+
if (used + wrapped > cap && start !== lines.length)
|
|
62
63
|
break;
|
|
63
64
|
used += wrapped;
|
|
64
65
|
start = i;
|
|
65
|
-
if (used >=
|
|
66
|
+
if (used >= cap)
|
|
66
67
|
break;
|
|
67
68
|
}
|
|
69
|
+
// One streaming paragraph with no newline yet can wrap past the cap on its own: keep its newest rows.
|
|
70
|
+
if (used > cap) {
|
|
71
|
+
const last = lines[lines.length - 1];
|
|
72
|
+
return { text: last.slice(last.length - cap * c), clipped: lines.length - 1, used: cap };
|
|
73
|
+
}
|
|
68
74
|
if (start <= 0)
|
|
69
|
-
return { text: s, clipped: 0 };
|
|
70
|
-
return { text: lines.slice(start).join("\n"), clipped: start };
|
|
75
|
+
return { text: s, clipped: 0, used };
|
|
76
|
+
return { text: lines.slice(start).join("\n"), clipped: start, used };
|
|
71
77
|
}
|
|
72
78
|
// A Switchboard bus message rendered inline (SPEC §6, Switchboard surface). Static-rendered like any
|
|
73
79
|
// settled entry, so it's printed once and scrolls with history — anchored to when it arrived/was sent,
|
|
@@ -113,7 +119,7 @@ function ReportRow({ agent }) {
|
|
|
113
119
|
const name = body.split(" · ")[0];
|
|
114
120
|
return (_jsxs(Text, { children: [_jsx(Text, { color: tone === "done" ? theme.success : tone === "stopped" ? theme.blocked : theme.error, children: line.slice(0, 2) }), _jsx(Text, { bold: true, children: name }), _jsx(Text, { dimColor: true, children: body.slice(name.length) }), hint ? _jsx(Text, { color: theme.info, children: hint }) : null] }));
|
|
115
121
|
}
|
|
116
|
-
function renderEntry(entry, live = false) {
|
|
122
|
+
function renderEntry(entry, live = false, liveRows) {
|
|
117
123
|
if (entry.kind === "summary")
|
|
118
124
|
return _jsx(SummaryCard, { summary: entry.summary });
|
|
119
125
|
if (entry.kind === "report")
|
|
@@ -142,13 +148,29 @@ function renderEntry(entry, live = false) {
|
|
|
142
148
|
// process through the WHOLE workflow, not just the gap before the answer starts. Before the answer begins,
|
|
143
149
|
// reasoning tails the full window; once the answer is streaming, reasoning keeps showing at lower opacity in
|
|
144
150
|
// a small reserved band above it, and the answer stays primary.
|
|
151
|
+
// Inline mode passes liveRows: the rows the rest of the dynamic frame leaves free (App measures them). Every
|
|
152
|
+
// row of this block (both clip notices and the bottom margin) is then counted against it, so the frame stays
|
|
153
|
+
// under the terminal height. Ink clears the whole screen and repaints all history on every render once it
|
|
154
|
+
// reaches it, which is the inline flicker.
|
|
145
155
|
const rows = termRows(), cols = termCols();
|
|
146
156
|
const hasAnswer = !!message.content;
|
|
147
157
|
const reasoning = message.reasoning ?? "";
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
158
|
+
let r, a;
|
|
159
|
+
if (liveRows !== undefined) {
|
|
160
|
+
const room = liveRows - 1; // −1: this block's marginBottom
|
|
161
|
+
if (room < 2)
|
|
162
|
+
return null; // the panels below fill the window: the answer shows in full once it settles
|
|
163
|
+
const rBudget = (hasAnswer ? Math.min(6, Math.floor(room / 3)) : room) - 1; // −1: the band's clip notice
|
|
164
|
+
r = reasoning && rBudget >= 1 ? liveTail(reasoning, 0, cols, rBudget) : null;
|
|
165
|
+
const aBudget = room - (r ? r.used + (r.clipped > 0 ? 1 : 0) : 0) - 1; // −1: the answer's clip notice
|
|
166
|
+
a = hasAnswer && aBudget >= 1 ? liveTail(message.content, 0, cols, aBudget) : null;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
const rRows = hasAnswer ? Math.min(6, Math.max(0, Math.floor(rows / 3))) : rows; // dim band capped small once the answer is flowing
|
|
170
|
+
r = reasoning && rRows > 0 ? liveTail(reasoning, rRows, cols) : null;
|
|
171
|
+
const aRows = Math.max(1, rows - (r ? rRows + 1 : 0)); // answer gets the remaining height (−1 for the band's clip notice)
|
|
172
|
+
a = hasAnswer ? liveTail(message.content, aRows, cols) : null;
|
|
173
|
+
}
|
|
152
174
|
if (!r && !a)
|
|
153
175
|
return _jsx(Box, { marginBottom: 1 });
|
|
154
176
|
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [r && r.clipped > 0 ? _jsx(Text, { dimColor: true, children: `⋯ +${r.clipped} more thinking line${r.clipped === 1 ? "" : "s"} above` }) : null, r ? _jsx(Text, { dimColor: true, children: r.text }) : null, a && a.clipped > 0 ? _jsx(Text, { dimColor: true, children: `⋯ +${a.clipped} more line${a.clipped === 1 ? "" : "s"} above (full text shown when complete)` }) : null, a ? _jsx(Text, { children: a.text }) : null] }));
|
|
@@ -170,7 +192,7 @@ function renderEntry(entry, live = false) {
|
|
|
170
192
|
const TranscriptRow = React.memo(function TranscriptRow({ entry }) {
|
|
171
193
|
return _jsx(Box, { children: renderEntry(entry) });
|
|
172
194
|
});
|
|
173
|
-
export function Transcript({ entries, live, bounded, scrollBack = 0 }) {
|
|
195
|
+
export function Transcript({ entries, live, bounded, scrollBack = 0, liveRows }) {
|
|
174
196
|
if (bounded) {
|
|
175
197
|
// Fullscreen: no <Static>; render a wheel-scrollable window as a plain column the parent clips +
|
|
176
198
|
// bottom-anchors. scrollBack (from MouseProvider wheel events, via App) slides the window back through
|
|
@@ -182,5 +204,5 @@ export function Transcript({ entries, live, bounded, scrollBack = 0 }) {
|
|
|
182
204
|
? _jsx(Text, { dimColor: true, children: `⋯ ${newerOff} newer line(s) below — scroll down (new output jumps here)` })
|
|
183
205
|
: (live ? _jsx(Box, { children: renderEntry(live, true) }) : null)] }));
|
|
184
206
|
}
|
|
185
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: entries, children: (entry) => _jsx(Box, { children: renderEntry(entry) }, entryKey(entry)) }), live ? _jsx(Box, { children: renderEntry(live, true) }) : null] }));
|
|
207
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: entries, children: (entry) => _jsx(Box, { children: renderEntry(entry) }, entryKey(entry)) }), live ? _jsx(Box, { children: renderEntry(live, true, liveRows) }) : null] }));
|
|
186
208
|
}
|
package/dist/ui/batchLine.js
CHANGED
|
@@ -9,7 +9,7 @@ import { computeEditDiff } from "./editdiff.js";
|
|
|
9
9
|
import { fitSegments, seg } from "./fit.js";
|
|
10
10
|
import { fmtTok } from "./format.js";
|
|
11
11
|
import { humanStep } from "./BgPanel.js";
|
|
12
|
-
|
|
12
|
+
import { SHELL_ANY } from "../tools/classes.js";
|
|
13
13
|
const PATH_KEYS = ["path", "file", "filename"];
|
|
14
14
|
/** A row's time: sub-second precision while short ("80ms", "1.1s"), minutes past one ("2m 13s"). */
|
|
15
15
|
const rowTime = (ms) => (ms < 60_000 ? formatDuration(ms) : fmtElapsed(ms));
|
|
@@ -53,7 +53,7 @@ function tail(step, now) {
|
|
|
53
53
|
export function liveRow(step, cols, now = Date.now()) {
|
|
54
54
|
const t = tail(step, now);
|
|
55
55
|
const max = cols - 1 - 4; // paddingLeft + the status glyph (counted wide, as cellWidth does) + space
|
|
56
|
-
const shell =
|
|
56
|
+
const shell = SHELL_ANY.has(step.name) && typeof step.args?.command === "string";
|
|
57
57
|
const head = shell ? "$" : truncateToWidth(step.name, Math.max(1, Math.min(max - 2, Math.max(12, Math.floor(max * 0.6)))));
|
|
58
58
|
const args = step.args ?? {};
|
|
59
59
|
if (step.name === "delegate_task" && typeof args.task === "string") { // its title is the task the specialist works on
|
|
@@ -127,7 +127,7 @@ export function chipOf(step) {
|
|
|
127
127
|
const glyph = tone === "done" ? "✓" : tone === "error" ? "✗" : "⊘";
|
|
128
128
|
const path = PATH_KEYS.map((k) => a[k]).find((v) => typeof v === "string");
|
|
129
129
|
let label;
|
|
130
|
-
if (
|
|
130
|
+
if (SHELL_ANY.has(step.name) && typeof a.command === "string")
|
|
131
131
|
label = words(a.command, 2);
|
|
132
132
|
else if (/grep|search|find|glob/.test(step.name) && typeof (a.pattern ?? a.query) === "string")
|
|
133
133
|
label = `${/find|glob/.test(step.name) ? "find" : "grep"} "${String(a.pattern ?? a.query).slice(0, 24)}"`;
|
|
@@ -141,7 +141,7 @@ export function chipOf(step) {
|
|
|
141
141
|
label = step.name;
|
|
142
142
|
const tail = step.outcome === "blocked" ? "blocked" : step.outcome === "cancelled" ? "cancelled"
|
|
143
143
|
: step.exitCode !== undefined ? `exit ${step.exitCode}`
|
|
144
|
-
: (() => { const d = step.status === "done" ? computeEditDiff(step.name, step.args) : undefined; return d ? `+${d.added} -${d.removed}` : step.lines && !
|
|
144
|
+
: (() => { const d = step.status === "done" ? computeEditDiff(step.name, step.args) : undefined; return d ? `+${d.added} -${d.removed}` : step.lines && !SHELL_ANY.has(step.name) ? String(step.lines) : ""; })();
|
|
145
145
|
return { tone, glyph, label: tail ? `${label} ${tail}` : label, name: step.name };
|
|
146
146
|
}
|
|
147
147
|
/** The chip line: "⇉ 4 calls · 3.4s", then chips while they fit in cols−1, the rest folded into "+3 ✓ +1 ✗", then the
|
package/dist/ui/editdiff.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
const MAX_PREVIEW_LINES = 4;
|
|
2
2
|
const MAX_LINE_WIDTH = 100; // a single preview line is truncated, never left to wrap/flood the row
|
|
3
|
-
const EDIT_TOOL_NAMES = new Set(["file_edit", "multi_edit"]);
|
|
4
|
-
const WRITE_TOOL_NAMES = new Set(["file_write"]);
|
|
5
3
|
function splitLines(s) {
|
|
6
4
|
return s === "" ? [] : s.split("\n");
|
|
7
5
|
}
|
|
@@ -54,7 +52,7 @@ function lineDiff(oldLines, newLines) {
|
|
|
54
52
|
export function computeEditDiff(name, args) {
|
|
55
53
|
if (!args)
|
|
56
54
|
return undefined;
|
|
57
|
-
if (
|
|
55
|
+
if (name === "file_edit") {
|
|
58
56
|
const oldStr = args.old_string;
|
|
59
57
|
const newStr = args.new_string;
|
|
60
58
|
if (typeof oldStr !== "string" || typeof newStr !== "string")
|
|
@@ -67,7 +65,7 @@ export function computeEditDiff(name, args) {
|
|
|
67
65
|
const preview = script.length <= MAX_PREVIEW_LINES ? script.map((l) => ({ kind: l.kind, text: truncateLine(l.text) })) : undefined;
|
|
68
66
|
return { added, removed, preview };
|
|
69
67
|
}
|
|
70
|
-
if (
|
|
68
|
+
if (name === "file_write") {
|
|
71
69
|
const content = args.content;
|
|
72
70
|
if (typeof content !== "string")
|
|
73
71
|
return undefined;
|
package/dist/ui/format.js
CHANGED
|
@@ -28,26 +28,10 @@ export function fmtTok(n) {
|
|
|
28
28
|
return `${Math.round(v / 1000)}k`;
|
|
29
29
|
return `${(v / 1_000_000).toFixed(1)}M`;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (/^(error|loop guard|\[interrupted|\[timed out)/i.test(s))
|
|
36
|
-
return "fail";
|
|
37
|
-
const exit = exitCode(s);
|
|
38
|
-
if ((exit !== undefined && exit !== 0) || /^\(no output; exit \?\)/.test(s))
|
|
39
|
-
return "fail";
|
|
40
|
-
if (/\n\[timed out after [^\n]*\]$/.test(s))
|
|
41
|
-
return "fail";
|
|
42
|
-
return "ok";
|
|
43
|
-
}
|
|
44
|
-
/** A shell call's exit code from its result (registry.ts shellExec), or undefined: output then an `[exit N]` line —
|
|
45
|
-
* which shellResultNotes' `[note: …]`/`[hint: …]` lines and the result guard's notes may follow — or, for a command
|
|
46
|
-
* that printed nothing, `(no output; exit N)`. */
|
|
47
|
-
export function exitCode(result) {
|
|
48
|
-
const m = /(?:^|\n)\[exit (\d+)\](?:\n+\[[^\n]*\])*\s*$/.exec(result) ?? /^\s*\(no output; exit (\d+)\)/.exec(result);
|
|
49
|
-
return m ? Number(m[1]) : undefined;
|
|
50
|
-
}
|
|
31
|
+
// How a tool call ended (ok · fail · blocked · cancelled) and a shell result's exit code: one reading for the
|
|
32
|
+
// transcript, the live rows, the fold, the editor adapter and the loop guard (tools/classes.ts).
|
|
33
|
+
export { toolOutcome, exitCode } from "../tools/classes.js";
|
|
34
|
+
import { toolOutcome } from "../tools/classes.js";
|
|
51
35
|
// A tool result reads as an error/loop-guard/interrupt sentinel rather than real output — shared by the
|
|
52
36
|
// settled-transcript push (cli.tsx) and the live per-call row update (ui/liveTools.ts) so both classify
|
|
53
37
|
// a result the same way.
|
package/dist/ui/liveTools.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { settledFields } from "./fold.js";
|
|
2
|
+
import { SHELL_FOREGROUND } from "../tools/classes.js";
|
|
2
3
|
// Bulky payloads — never dumped (they'd bury the path and blow up the line); shown as a size instead.
|
|
3
4
|
export const BULK_ARGS = ["content", "text", "body", "data", "new_string", "old_string", "diff", "message"];
|
|
4
5
|
const BULK = new Set(BULK_ARGS);
|
|
@@ -168,11 +169,10 @@ export function settleLiveTool(rows, id, result, now = Date.now(), refused) {
|
|
|
168
169
|
});
|
|
169
170
|
return changed ? next : rows;
|
|
170
171
|
}
|
|
171
|
-
const SHELL_TOOLS = new Set(["bash", "shell_exec"]);
|
|
172
172
|
export const BACKGROUND_HINT_AFTER_MS = 2000;
|
|
173
173
|
/** Inline per-row variant of the hint, under the running command itself (matches Claude Code). */
|
|
174
174
|
export function rowBackgroundHint(step, now = Date.now(), inTmux = !!process.env.TMUX) {
|
|
175
|
-
if (!
|
|
175
|
+
if (!SHELL_FOREGROUND.has(step.name) || step.status !== "running")
|
|
176
176
|
return null;
|
|
177
177
|
if (now - (step.startedAt ?? now) <= BACKGROUND_HINT_AFTER_MS)
|
|
178
178
|
return null;
|
|
@@ -182,7 +182,7 @@ export function rowBackgroundHint(step, now = Date.now(), inTmux = !!process.env
|
|
|
182
182
|
* shell command has run past the threshold. Inside tmux ctrl+b is the prefix key, so the first press is
|
|
183
183
|
* swallowed by tmux: say "twice", and name the alias key that has no such clash. */
|
|
184
184
|
export function backgroundHint(rows, now = Date.now(), inTmux = !!process.env.TMUX) {
|
|
185
|
-
const slow = rows.some((r) =>
|
|
185
|
+
const slow = rows.some((r) => SHELL_FOREGROUND.has(r.name) && r.status === "running" && now - (r.startedAt ?? now) > BACKGROUND_HINT_AFTER_MS);
|
|
186
186
|
if (!slow)
|
|
187
187
|
return null;
|
|
188
188
|
return inTmux ? "ctrl+b ctrl+b (tmux) or ctrl+z to run in the background" : "ctrl+b to run in the background";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Team mode shows as "OPS" in the status rule's tier slot. The mode is the flag file `team on|off` writes
|
|
2
|
+
// (~/.axe/nimbus/team, TEAM_FLAG_FILE overrides it). The rule re-renders on every keystroke, so the read is cached
|
|
3
|
+
// for a second; any read failure means off — a missing flag must never break the frame.
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import { homedir } from "node:os";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
const TTL_MS = 1000;
|
|
8
|
+
let cached;
|
|
9
|
+
export function opsModeOn(now = Date.now()) {
|
|
10
|
+
const path = process.env.TEAM_FLAG_FILE || join(homedir(), ".axe", "nimbus", "team");
|
|
11
|
+
if (cached && cached.path === path && now - cached.at < TTL_MS)
|
|
12
|
+
return cached.on;
|
|
13
|
+
let on = false;
|
|
14
|
+
try {
|
|
15
|
+
on = readFileSync(path, "utf8").trim() === "on";
|
|
16
|
+
}
|
|
17
|
+
catch { /* off */ }
|
|
18
|
+
cached = { path, at: now, on };
|
|
19
|
+
return on;
|
|
20
|
+
}
|
package/dist/ui/types.js
CHANGED
package/dist/update-check.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
// The update-available prompt (ui/UpdatePrompt.tsx): an interactive start of a packaged install asks the public download
|
|
2
2
|
// URL (update.ts) which version each channel holds, in the background, and offers a newer one before the first turn.
|
|
3
3
|
// Never for a subcommand (`operator run`, acp, mcp, update…), a non-TTY, CI, a source checkout (it updates by git), or
|
|
4
|
-
// with settings.updates.check false / OPERATOR_NO_UPDATE_CHECK=1. The answer is cached ~
|
|
5
|
-
// state folder, with the version "skip until next version" chose.
|
|
4
|
+
// with settings.updates.check false / OPERATOR_NO_UPDATE_CHECK=1. The answer is cached ~4 h in the Operator home's
|
|
5
|
+
// state folder, with the version "skip until next version" chose. A sign-in (the TUI's /login, the shell's
|
|
6
|
+
// `operator auth login`) checks again past the cache, so a release out since the last check is offered right then.
|
|
7
|
+
// Every failure is silent: no offer.
|
|
6
8
|
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
7
9
|
import { dirname } from "node:path";
|
|
8
10
|
import { operatorPath } from "./config/home.js";
|
|
9
11
|
import { channelOf, distBase, distTagsAsync, installedVersion, installPackaged, isOlder, isReleaseInstall, platformLabel, VERSION } from "./update.js";
|
|
10
|
-
export const CHECK_TTL_MS =
|
|
12
|
+
export const CHECK_TTL_MS = 4 * 3600_000; // a release reaches a working day's next launch; a check is one small file
|
|
11
13
|
const FETCH_MS = 1500;
|
|
12
14
|
const REGISTRY_MS = 5000;
|
|
13
15
|
const NOTES = {
|
|
@@ -84,13 +86,13 @@ function writeState(state, path) {
|
|
|
84
86
|
writeFileSync(tmp, JSON.stringify(state, null, 2) + "\n", { mode: 0o600 });
|
|
85
87
|
renameSync(tmp, path);
|
|
86
88
|
}
|
|
87
|
-
/** The offer for this launch, or null. A check younger than CHECK_TTL_MS is reused
|
|
88
|
-
* something answered, so a launch without network asks again next time. */
|
|
89
|
+
/** The offer for this launch, or null. A check younger than CHECK_TTL_MS is reused unless `force`; a fresh one is
|
|
90
|
+
* written only when something answered, so a launch without network asks again next time. */
|
|
89
91
|
export async function checkForUpdate(current, o = {}) {
|
|
90
92
|
try {
|
|
91
93
|
const now = o.now ?? Date.now(), path = o.path ?? statePath();
|
|
92
94
|
const state = readState(path);
|
|
93
|
-
const fresh = typeof state.checkedAt === "number" && now >= state.checkedAt && now - state.checkedAt < CHECK_TTL_MS;
|
|
95
|
+
const fresh = !o.force && typeof state.checkedAt === "number" && now >= state.checkedAt && now - state.checkedAt < CHECK_TTL_MS;
|
|
94
96
|
let found = { latest: state.latest, next: state.next };
|
|
95
97
|
if (!fresh) {
|
|
96
98
|
found = await (o.fetch ?? ((own) => fetchVersions(own, { registry: !isReleaseInstall() })))(channelOf(current));
|
|
@@ -107,6 +109,15 @@ export async function checkForUpdate(current, o = {}) {
|
|
|
107
109
|
return null;
|
|
108
110
|
}
|
|
109
111
|
}
|
|
112
|
+
/** The check after a sign-in: every checkEnabled rule except the subcommand one (the shell's `operator auth login` is
|
|
113
|
+
* one), and past the cache. */
|
|
114
|
+
export function checkAfterSignIn(current, o, check = checkForUpdate) {
|
|
115
|
+
if (!checkEnabled({ ...o, argv: ["node", "operator"] }))
|
|
116
|
+
return Promise.resolve(null);
|
|
117
|
+
return check(current, { force: true });
|
|
118
|
+
}
|
|
119
|
+
/** The offer as plain text, for the shell. */
|
|
120
|
+
export const offerLine = (offer) => `Operator ${offer.version} is available (you have ${offer.current}). Run: ${offer.command}`;
|
|
110
121
|
/** "Skip until next version": this exact version is not offered again; a newer one is. */
|
|
111
122
|
export function skipVersion(version, path = statePath()) {
|
|
112
123
|
try {
|
package/package.json
CHANGED
package/dist/tools/mutating.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Single source of truth for "which tools mutate the workspace". A workspace edit resets the loop-guard
|
|
2
|
-
// call counts (re-running the SAME test/build after an edit is verify-after-fix iteration, not a spin), marks
|
|
3
|
-
// a turn as having changed files (verify-before-done), keeps the no-edit streak from ticking (the stuck-turn
|
|
4
|
-
// guard), and is the trigger for a checkpoint snapshot. Kept in a DEPENDENCY-FREE leaf module so both the
|
|
5
|
-
// engine (agent.ts, verify-gate.ts) and the tool layer (executor.ts) — and the coming checkpoints module —
|
|
6
|
-
// import ONE definition instead of three copies that could drift apart.
|
|
7
|
-
export const MUTATING_TOOLS = new Set(["file_write", "file_edit"]);
|
|
8
|
-
/** True when a tool call's name is a workspace mutation. Tolerates undefined (a malformed/partial call). */
|
|
9
|
-
export const isMutatingTool = (name) => MUTATING_TOOLS.has(name ?? "");
|
|
10
|
-
/** True when a mutating call actually LANDED. file_write/file_edit report failure as a returned `error: …`
|
|
11
|
-
* string (not a throw), and a gated/denied or loop-guarded call never ran, so the tool NAME alone proves
|
|
12
|
-
* nothing. The loop-guard clears its identical-call counts only on a landed mutation — a failing edit must not
|
|
13
|
-
* grant a spinning model a fresh runway (the model can otherwise alternate a failing edit with the same
|
|
14
|
-
* poisoned call forever). */
|
|
15
|
-
export const mutationLanded = (name, result) => isMutatingTool(name) && !/^(?:error|loop guard|permission denied)/i.test(result.trimStart());
|