@0perator/operator 0.1.359 → 0.1.360-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard/index.html +2 -2
- package/dist/autonomy/cloud-agent.js +2 -2
- package/dist/autonomy/headless.js +15 -6
- package/dist/autonomy/session-factory.js +2 -1
- package/dist/background/notices.js +1 -1
- package/dist/browser/session.js +7 -0
- package/dist/cli.js +94 -52
- package/dist/config/features.js +6 -5
- package/dist/config/persona.js +57 -40
- package/dist/config/settings.js +39 -55
- package/dist/config/toolchain.js +14 -1
- package/dist/engine/agent.js +72 -33
- package/dist/engine/aurora.js +24 -2
- package/dist/engine/compaction.js +27 -7
- package/dist/engine/decision-points.js +16 -4
- package/dist/engine/kv-slot.js +87 -0
- package/dist/engine/loop-guard.js +49 -18
- package/dist/engine/messages.js +8 -1
- package/dist/engine/progress-deadline.js +37 -0
- package/dist/engine/verify-gate.js +134 -9
- package/dist/enterprise/cli.js +13 -1
- package/dist/mcp/craft-server.js +5 -3
- package/dist/memory/live-progress.js +35 -6
- package/dist/permissions/policy.js +8 -0
- package/dist/permissions/signature.js +9 -0
- package/dist/products/artifact-library.js +47 -0
- package/dist/products/craft.js +58 -94
- package/dist/products/temple.js +230 -0
- package/dist/remote/host.js +28 -1
- package/dist/router/discovery.js +23 -6
- package/dist/router/models.js +29 -70
- package/dist/services/preflight.js +3 -41
- package/dist/session.js +121 -38
- package/dist/skills/catalogue.js +2 -0
- package/dist/skills/finder.js +1 -1
- package/dist/toolchain/toolchain.py +20 -3
- package/dist/tools/background-result.js +26 -0
- package/dist/tools/chauffeur-native.js +6 -0
- package/dist/tools/craft.js +17 -6
- package/dist/tools/deferred.js +64 -30
- package/dist/tools/executor.js +4 -2
- package/dist/tools/paths.js +3 -3
- package/dist/tools/read-ledger.js +44 -0
- package/dist/tools/registry.js +218 -264
- package/dist/tools/sandbox.js +52 -39
- package/dist/tools/shell-context.js +5 -0
- package/dist/tools/shell-session.js +61 -29
- package/dist/tools/vision-gateway.js +79 -34
- package/dist/tools/wave-tools.js +2 -2
- package/dist/tools/wave2-tools.js +6 -6
- package/dist/ui/ArtifactPicker.js +2 -2
- package/dist/ui/Composer.js +9 -2
- package/dist/ui/StatusRule.js +1 -1
- package/dist/ui/modelPicker.js +1 -1
- package/dist/ui/nextStep.js +1 -0
- package/dist/ui/pending.js +10 -0
- package/dist/update.js +87 -9
- package/dist/util/retry.js +34 -0
- package/dist/util/slash.js +2 -1
- package/dist/vault/tool.js +3 -1
- package/mcp/powertools-toolbox.mjs +166 -1
- package/package.json +9 -13
- package/dashboard/README.md +0 -62
- package/dist/compose/client.js +0 -56
- package/mcp/README.md +0 -88
- package/mcp/powertools.md +0 -210
package/dist/tools/sandbox.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
// Sandboxed execution (SPEC §11 / enterprise hardening). Two independent, defense-in-depth layers
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Sandboxed execution (SPEC §11 / enterprise hardening). Two independent, defense-in-depth layers. The
|
|
2
|
+
// default is "workspace" (config/settings.ts), a real OS floor for the shell; "off" is the explicit opt-out
|
|
3
|
+
// for a box that needs unconfined writes:
|
|
4
4
|
//
|
|
5
5
|
// 1. Portable JS write-guards (deniedWrite) — deny writes to credential/key/system paths on ANY OS,
|
|
6
6
|
// wired into file_write/file_edit. In "strict" mode, writes are also confined to an allowlist
|
|
7
7
|
// (workspace + home + tmp). Pure path math, unit-tested, no platform dependency.
|
|
8
8
|
// 2. OS process sandbox (wrapShell) — on macOS, run shell_exec/git under `sandbox-exec` (seatbelt) so
|
|
9
|
-
// even a shell command can't write outside the
|
|
10
|
-
// Falls back to a no-op where sandbox-exec is unavailable (the JS guards still apply to file tools)
|
|
9
|
+
// even a shell command can't write outside the workspace (and, in strict, can't reach the network).
|
|
10
|
+
// Falls back to a no-op where sandbox-exec is unavailable (the JS guards still apply to file tools);
|
|
11
|
+
// `operator doctor` reports when a configured mode has no OS layer to enforce it.
|
|
11
12
|
//
|
|
12
|
-
// Mode: KODE_SANDBOX = "off"
|
|
13
|
-
// (confine writes to workspace/tmp, deny network).
|
|
13
|
+
// Mode: KODE_SANDBOX = "off" | "workspace" (DEFAULT: confine shell writes to the workspace/tmp, allow
|
|
14
|
+
// network) | "strict" (confine shell writes to the workspace/tmp, deny network). Resolved settings reach
|
|
15
|
+
// this layer via the env bridge (applySandboxMode, called at boot), since this platform-neutral module
|
|
16
|
+
// must not import config/settings.ts.
|
|
14
17
|
// No static node:os / node:path imports — a top-level `import "node:..."` breaks the platform:neutral
|
|
15
18
|
// bundle (registry.ts pulls this module in, and it reaches the mobile JSCore engine). HOME comes from
|
|
16
19
|
// the env; a minimal single-arg POSIX resolve() is inlined below. These sandbox functions only ever
|
|
@@ -33,6 +36,25 @@ export function sandboxMode() {
|
|
|
33
36
|
const m = (process.env.KODE_SANDBOX ?? "off").toLowerCase();
|
|
34
37
|
return m === "workspace" || m === "strict" ? m : "off";
|
|
35
38
|
}
|
|
39
|
+
// Bridge the RESOLVED (managed-overridden) settings.sandbox.mode into the env the enforcement layer reads.
|
|
40
|
+
// sandboxMode() reads ONLY process.env.KODE_SANDBOX because the tool layer is a platform-neutral module that
|
|
41
|
+
// must not import config/settings.ts, so boot derives that var from the resolved mode (cli.tsx). Without this
|
|
42
|
+
// a settings.json / managed policy that says "strict" reports as in force while the shell runs unconfined —
|
|
43
|
+
// the false-assurance gap. Idempotent; returns the mode now in force.
|
|
44
|
+
export function applySandboxMode(mode) {
|
|
45
|
+
process.env.KODE_SANDBOX = mode;
|
|
46
|
+
return sandboxMode();
|
|
47
|
+
}
|
|
48
|
+
// Whether the OS process-sandbox layer (seatbelt on macOS, bwrap on Linux) is actually present to enforce an
|
|
49
|
+
// active mode. When a mode is on but this is false, wrapShell silently runs plain bash — the shell is
|
|
50
|
+
// UNCONFINED and only the JS file-guards apply — so `operator doctor` must say so instead of claiming the mode.
|
|
51
|
+
export async function osSandboxAvailable() {
|
|
52
|
+
if (process.platform === "darwin")
|
|
53
|
+
return hasSandboxExec();
|
|
54
|
+
if (process.platform === "linux")
|
|
55
|
+
return hasBubblewrap();
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
36
58
|
// macOS (APFS) and Windows default to CASE-INSENSITIVE filesystems — the Mac Studio fleet — so a denylist
|
|
37
59
|
// compared byte-exact is bypassable with a case variant: `file_write ~/.axe/operator/Settings.json` (or
|
|
38
60
|
// `~/.Ssh/authorized_keys`) resolves to the same real file but misses a lowercase `settings.json` match, so
|
|
@@ -204,21 +226,20 @@ export async function deniedReadAsync(path) {
|
|
|
204
226
|
}
|
|
205
227
|
export function seatbeltProfile(mode) {
|
|
206
228
|
const q = (s) => s.replace(/"/g, '\\"');
|
|
207
|
-
const denySub = denyWriteSubpaths().map((d) => `(subpath "${q(d)}")`).join(" ");
|
|
208
|
-
const denyFiles = denyWriteFiles().map((f) => `(literal "${q(f)}")`).join(" ");
|
|
209
229
|
// Read-containment: block reads of credential paths in BOTH modes so a shell command can't read+exfil
|
|
210
230
|
// secrets. Scoped to real secrets so /usr,/etc,/bin stay readable and normal commands still run.
|
|
211
231
|
const denyReadSub = secretReadSubpaths().map((d) => `(subpath "${q(d)}")`).join(" ");
|
|
212
232
|
const denyReadFiles = secretReadFiles().map((f) => `(literal "${q(f)}")`).join(" ");
|
|
213
233
|
const denyRead = `(deny file-read* ${denyReadSub} ${denyReadFiles})`;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
234
|
+
// BOTH workspace and strict confine writes to the allowlist (cwd + operator home + tmp/scratch): deny ALL
|
|
235
|
+
// writes, re-allow the roots, then re-deny the credential/system/op-policy paths on top (SBPL is
|
|
236
|
+
// last-match-wins) so a write can't land there even when an allow-root contains it (e.g. cwd == $HOME).
|
|
237
|
+
// The two modes differ only in the network: workspace leaves it open, strict cuts it.
|
|
238
|
+
const allow = allowedWriteRoots().concat("/dev").map((r) => `(subpath "${q(r)}")`).join(" ");
|
|
239
|
+
const denySub = denyWriteSubpaths().map((d) => `(subpath "${q(d)}")`).join(" ");
|
|
240
|
+
const denyFiles = denyWriteFiles().map((f) => `(literal "${q(f)}")`).join(" ");
|
|
241
|
+
const net = mode === "strict" ? "(deny network*)" : "";
|
|
242
|
+
return `(version 1)(allow default)(deny file-write*)(allow file-write* ${allow})(deny file-write* ${denySub} ${denyFiles})${denyRead}${net}`;
|
|
222
243
|
}
|
|
223
244
|
/** Bubblewrap (bwrap) argv enforcing the SAME intent as seatbeltProfile(), for the Linux fleet where
|
|
224
245
|
* macOS sandbox-exec doesn't exist — hasSandboxExec() hardcodes false off-darwin, so KODE_SANDBOX=
|
|
@@ -230,30 +251,22 @@ export function seatbeltProfile(mode) {
|
|
|
230
251
|
* tests. NOTE: kernel enforcement must be validated on a real Linux node — untestable on macOS/JL1. */
|
|
231
252
|
export function bwrapArgs(mode) {
|
|
232
253
|
const a = [];
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
254
|
+
// BOTH modes confine writes: the whole FS is read-only except the allow-roots (cwd + operator home + tmp),
|
|
255
|
+
// with the credential/system/op-policy paths re-bound read-only on top so a write can't land there even
|
|
256
|
+
// when an allow-root contains them (cwd == $HOME). The modes differ only in the network: strict cuts it,
|
|
257
|
+
// workspace leaves it connected.
|
|
258
|
+
a.push("--ro-bind", "/", "/"); // whole FS read-only …
|
|
259
|
+
a.push("--proc", "/proc", "--dev", "/dev");
|
|
260
|
+
for (const root of allowedWriteRoots())
|
|
261
|
+
a.push("--bind-try", root, root); // … except the allow-roots
|
|
262
|
+
for (const d of denyWriteSubpaths())
|
|
263
|
+
a.push("--ro-bind-try", resolve(d), resolve(d)); // protected dirs stay read-only (incl. operator policy/audit dirs)
|
|
264
|
+
for (const f of denyWriteFiles())
|
|
265
|
+
a.push("--ro-bind-try", resolve(f), resolve(f)); // protected files stay read-only (incl. operator policy files)
|
|
266
|
+
if (mode === "strict")
|
|
243
267
|
a.push("--unshare-net"); // strict: no network
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
a.push("--bind", "/", "/"); // workspace: FS writable …
|
|
247
|
-
a.push("--proc", "/proc", "--dev", "/dev");
|
|
248
|
-
for (const d of denyWriteSubpaths())
|
|
249
|
-
a.push("--ro-bind-try", resolve(d), resolve(d)); // … protected dirs read-only
|
|
250
|
-
for (const f of DENY_WRITE_FILES)
|
|
251
|
-
a.push("--ro-bind-try", "/dev/null", resolve(f)); // protected files masked
|
|
252
|
-
for (const f of opPaths(OP_WRITE_PROTECTED_FILES))
|
|
253
|
-
a.push("--ro-bind-try", f, f); // operator policy files: readable, not writable
|
|
254
|
-
}
|
|
255
268
|
// Read-containment (BOTH modes): mask secret dirs with an empty tmpfs, secret files with /dev/null,
|
|
256
|
-
// so a shell command can't read + exfil credentials. Placed last so it wins over the
|
|
269
|
+
// so a shell command can't read + exfil credentials. Placed last so it wins over the read-only binds.
|
|
257
270
|
for (const d of secretReadSubpaths())
|
|
258
271
|
a.push("--tmpfs", resolve(d));
|
|
259
272
|
for (const f of secretReadFiles())
|
|
@@ -16,3 +16,8 @@ export const DEFAULT_SHELL_KEY = "__main__";
|
|
|
16
16
|
* getShellSession() to pick this session's own ShellSession from the per-key map. */
|
|
17
17
|
export const shellKeyStore = new AsyncLocalStorage();
|
|
18
18
|
export const shellExecMode = new AsyncLocalStorage();
|
|
19
|
+
/** The turn's abort signal (esc) for the in-flight tool call. Set by Executor.execute() around each tool.run
|
|
20
|
+
* and read by shellExec (registry.ts) so a long-running bash/shell_exec command's process group is killed on
|
|
21
|
+
* interrupt (FIX 5). A side-channel, not a Tool.run param, so tools that use their 2nd param for test DI
|
|
22
|
+
* (findFiles' FindDeps) keep their signature. undefined when no turn signal is wired. */
|
|
23
|
+
export const shellSignalStore = new AsyncLocalStorage();
|
|
@@ -170,21 +170,29 @@ export class ShellSession {
|
|
|
170
170
|
this.buf = "";
|
|
171
171
|
return { output: clean(raw), exitCode: null, timedOut: false, truncated: false };
|
|
172
172
|
};
|
|
173
|
-
// Per-command timeout / runaway: abandon ONLY the stuck command by
|
|
174
|
-
// then let bash reap them and print the pending sentinel — bash (and its cwd/env) survives. Only
|
|
175
|
-
//
|
|
173
|
+
// Per-command timeout / runaway / abort: abandon ONLY the stuck command by signalling bash's descendants,
|
|
174
|
+
// then let bash reap them and print the pending sentinel — bash (and its cwd/env) survives. Only if the
|
|
175
|
+
// sentinel never comes back AND bash is genuinely wedged do we respawn (cwd/env-loss case). An abort (esc,
|
|
176
|
+
// FIX 5) SIGTERMs the command's process group first, then escalates to SIGKILL for a process that ignores it.
|
|
176
177
|
const abandon = async (reason) => {
|
|
177
|
-
const
|
|
178
|
+
const aborted = reason === "aborted";
|
|
179
|
+
const killed = await this.killDescendants(p.pid, aborted ? "SIGTERM" : "SIGKILL");
|
|
178
180
|
const grace = Date.now() + 2000;
|
|
181
|
+
const escalateAt = aborted ? Date.now() + 400 : Infinity; // SIGTERM grace before SIGKILL
|
|
182
|
+
let escalated = !aborted;
|
|
179
183
|
while (Date.now() < grace) {
|
|
180
184
|
const m = this.buf.match(re);
|
|
181
185
|
if (m) { // bash recovered on its own — shell (cwd/env) preserved
|
|
182
186
|
const raw = cap(this.buf.slice(0, m.index));
|
|
183
187
|
this.buf = "";
|
|
184
|
-
return { output: clean(raw), exitCode: Number(m[1]), timedOut: reason === "timeout", truncated: reason === "runaway" || raw.length >= OUTPUT_CAP };
|
|
188
|
+
return { output: clean(raw), exitCode: Number(m[1]), timedOut: reason === "timeout", truncated: reason === "runaway" || raw.length >= OUTPUT_CAP, aborted: aborted || undefined };
|
|
185
189
|
}
|
|
186
190
|
if (p.exitCode !== null || this.proc !== p)
|
|
187
191
|
break; // bash itself died
|
|
192
|
+
if (!escalated && Date.now() >= escalateAt) {
|
|
193
|
+
escalated = true;
|
|
194
|
+
await this.killDescendants(p.pid, "SIGKILL");
|
|
195
|
+
}
|
|
188
196
|
await new Promise((r) => setTimeout(r, 15));
|
|
189
197
|
}
|
|
190
198
|
// No sentinel within grace. Wedged if bash died, or its stdin no longer accepts writes, or
|
|
@@ -202,7 +210,7 @@ export class ShellSession {
|
|
|
202
210
|
}
|
|
203
211
|
const raw = this.buf.slice(0, OUTPUT_CAP);
|
|
204
212
|
this.buf = "";
|
|
205
|
-
return { output: clean(raw), exitCode: null, timedOut: reason === "timeout", truncated: reason === "runaway", reset: wedged };
|
|
213
|
+
return { output: clean(raw), exitCode: null, timedOut: reason === "timeout", truncated: reason === "runaway", reset: wedged, aborted: aborted || undefined };
|
|
206
214
|
};
|
|
207
215
|
while (true) {
|
|
208
216
|
const m = this.buf.match(re);
|
|
@@ -214,6 +222,9 @@ export class ShellSession {
|
|
|
214
222
|
// Shell died mid-command (crash / `exit` / OOM-kill): fail fast instead of spinning to the deadline.
|
|
215
223
|
if (p.exitCode !== null || this.proc !== p)
|
|
216
224
|
return deadShell();
|
|
225
|
+
// Turn interrupt (esc): kill the in-flight command's process group and stop waiting on it (FIX 5).
|
|
226
|
+
if (opts?.signal?.aborted)
|
|
227
|
+
return abandon("aborted");
|
|
217
228
|
if (cur.detachReq && opts?.onDetach)
|
|
218
229
|
return this.handOff(p, re, cur, clean, opts.onDetach);
|
|
219
230
|
// Runaway output that never reaches the sentinel: stop before it balloons memory.
|
|
@@ -265,10 +276,11 @@ export class ShellSession {
|
|
|
265
276
|
onDetach({ pid: p.pid, command: cur.command, startedAt: cur.startedAt, partial, setTap: (fn) => { this.tap = fn; }, finished, kill });
|
|
266
277
|
return { output: partial, exitCode: null, timedOut: false, truncated: false, detached: true };
|
|
267
278
|
}
|
|
268
|
-
/** Collect and
|
|
269
|
-
* touching `pid` itself, so the persistent bash survives a per-command timeout. One `ps` snapshot,
|
|
270
|
-
* deepest-first kill so a parent can't re-fork after its child dies.
|
|
271
|
-
|
|
279
|
+
/** Collect and signal every descendant of `pid` (the stuck/aborted command's process subtree) WITHOUT
|
|
280
|
+
* touching `pid` itself, so the persistent bash survives a per-command timeout or an abort. One `ps` snapshot,
|
|
281
|
+
* deepest-first kill so a parent can't re-fork after its child dies. `sig` defaults to SIGKILL (timeout/runaway);
|
|
282
|
+
* an abort sends SIGTERM first, then escalates to SIGKILL. Returns how many were signalled. */
|
|
283
|
+
async killDescendants(pid, sig = "SIGKILL") {
|
|
272
284
|
try {
|
|
273
285
|
const { execFile } = await nodeImport("node:child_process");
|
|
274
286
|
const out = await new Promise((res) => {
|
|
@@ -296,7 +308,7 @@ export class ShellSession {
|
|
|
296
308
|
}
|
|
297
309
|
for (const v of victims.reverse()) {
|
|
298
310
|
try {
|
|
299
|
-
process.kill(v,
|
|
311
|
+
process.kill(v, sig);
|
|
300
312
|
}
|
|
301
313
|
catch { /* already gone */ }
|
|
302
314
|
}
|
|
@@ -357,7 +369,7 @@ export async function processCwd(pid) {
|
|
|
357
369
|
/** One-shot bash for parallel batches — no shared cwd/env with the persistent session (and no FIFO
|
|
358
370
|
* contention). Same result shape as ShellSession.run so shellExec can format either path identically.
|
|
359
371
|
* pipefail + stderr-merge mirror the persistent shell's framing so exit trailers stay honest. */
|
|
360
|
-
export async function runEphemeralShell(command, timeoutMs = 120_000, cwd) {
|
|
372
|
+
export async function runEphemeralShell(command, timeoutMs = 120_000, cwd, signal) {
|
|
361
373
|
const { spawn } = await nodeImport("node:child_process");
|
|
362
374
|
const { wrapShell } = await nodeImport("./sandbox.js");
|
|
363
375
|
const framed = `set -o pipefail; exec 2>&1; ${command}`;
|
|
@@ -371,50 +383,66 @@ export async function runEphemeralShell(command, timeoutMs = 120_000, cwd) {
|
|
|
371
383
|
detached: true,
|
|
372
384
|
});
|
|
373
385
|
ownChild(p, "ephemeral shell", { cmd: `${file} ${args.join(" ")}`, group: true });
|
|
386
|
+
const killGroup = (sig) => { try {
|
|
387
|
+
if (p.pid)
|
|
388
|
+
process.kill(-p.pid, sig);
|
|
389
|
+
else
|
|
390
|
+
p.kill(sig);
|
|
391
|
+
}
|
|
392
|
+
catch { /* already gone */ } };
|
|
374
393
|
let buf = "";
|
|
375
394
|
const onData = (d) => {
|
|
376
395
|
buf += typeof d === "string" ? d : d.toString("utf8");
|
|
377
|
-
if (buf.length > OUTPUT_CAP_LOCAL * 4)
|
|
378
|
-
|
|
379
|
-
if (p.pid)
|
|
380
|
-
process.kill(-p.pid, "SIGKILL");
|
|
381
|
-
else
|
|
382
|
-
p.kill("SIGKILL");
|
|
383
|
-
}
|
|
384
|
-
catch { /* */ }
|
|
385
|
-
}
|
|
396
|
+
if (buf.length > OUTPUT_CAP_LOCAL * 4)
|
|
397
|
+
killGroup("SIGKILL");
|
|
386
398
|
};
|
|
387
399
|
p.stdout?.setEncoding("utf8");
|
|
388
400
|
p.stderr?.setEncoding("utf8");
|
|
389
401
|
p.stdout?.on("data", onData);
|
|
390
402
|
p.stderr?.on("data", onData);
|
|
391
403
|
let settled = false;
|
|
404
|
+
let aborted = false;
|
|
405
|
+
// Turn interrupt (esc, FIX 5): an ephemeral one-shot runs in its OWN process group, so kill the whole group.
|
|
406
|
+
const onAbort = () => { aborted = true; killGroup("SIGTERM"); setTimeout(() => killGroup("SIGKILL"), 400).unref?.(); };
|
|
392
407
|
const finish = (r) => { if (!settled) {
|
|
393
408
|
settled = true;
|
|
394
409
|
clearTimeout(timer);
|
|
410
|
+
signal?.removeEventListener("abort", onAbort);
|
|
395
411
|
resolve(r);
|
|
396
412
|
} };
|
|
397
413
|
const timer = setTimeout(() => {
|
|
398
|
-
|
|
399
|
-
if (p.pid)
|
|
400
|
-
process.kill(-p.pid, "SIGKILL");
|
|
401
|
-
else
|
|
402
|
-
p.kill("SIGKILL");
|
|
403
|
-
}
|
|
404
|
-
catch { /* */ }
|
|
414
|
+
killGroup("SIGKILL");
|
|
405
415
|
const raw = buf.length > OUTPUT_CAP_LOCAL ? buf.slice(0, OUTPUT_CAP_LOCAL) : buf;
|
|
406
416
|
finish({ output: raw.replace(/\r/g, "").replace(/\n+$/, ""), exitCode: null, timedOut: true, truncated: buf.length > OUTPUT_CAP_LOCAL });
|
|
407
417
|
}, Math.max(1000, timeoutMs));
|
|
418
|
+
if (signal) {
|
|
419
|
+
if (signal.aborted)
|
|
420
|
+
onAbort();
|
|
421
|
+
else
|
|
422
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
423
|
+
}
|
|
408
424
|
p.on("error", (e) => {
|
|
409
425
|
finish({ output: `error: shell failed to start: ${e.message}`, exitCode: null, timedOut: false, truncated: false });
|
|
410
426
|
});
|
|
411
427
|
p.on("close", (code) => {
|
|
412
428
|
const truncated = buf.length > OUTPUT_CAP_LOCAL;
|
|
413
429
|
const raw = truncated ? buf.slice(0, OUTPUT_CAP_LOCAL) : buf;
|
|
414
|
-
finish({ output: raw.replace(/\r/g, "").replace(/\n+$/, ""), exitCode: code, timedOut: false, truncated });
|
|
430
|
+
finish({ output: raw.replace(/\r/g, "").replace(/\n+$/, ""), exitCode: code, timedOut: false, truncated, aborted: aborted || undefined });
|
|
415
431
|
});
|
|
416
432
|
});
|
|
417
433
|
}
|
|
434
|
+
// A build/test tool that found no project where it ran (11/23: a session started in ~ ran `npm test` there, got "no
|
|
435
|
+
// package.json" and reported it as expected). Matched on lower-cased output; returns the manifest the tool wanted.
|
|
436
|
+
const MISSING_MANIFEST = [
|
|
437
|
+
[/enoent[^\n]*package\.json|could not read package\.json|no package\.json/, "package.json"],
|
|
438
|
+
[/could not find `?cargo\.toml`?/, "Cargo.toml"],
|
|
439
|
+
[/go\.mod file not found|go: cannot find main module/, "go.mod"],
|
|
440
|
+
[/does not appear to be a python project|neither 'setup\.py' nor 'pyproject\.toml' found|no pyproject\.toml/, "pyproject.toml"],
|
|
441
|
+
[/no targets specified and no makefile found/, "Makefile"],
|
|
442
|
+
];
|
|
443
|
+
export function missingManifest(lowerOutput) {
|
|
444
|
+
return MISSING_MANIFEST.find(([re]) => re.test(lowerOutput))?.[1];
|
|
445
|
+
}
|
|
418
446
|
export function shellResultNotes(command, exitCode, output) {
|
|
419
447
|
const notes = [];
|
|
420
448
|
let code = exitCode;
|
|
@@ -435,6 +463,10 @@ export function shellResultNotes(command, exitCode, output) {
|
|
|
435
463
|
if (command.includes("|") && code === 1) {
|
|
436
464
|
notes.push("[note: pipefail is ON — exit 1 may come from ANY stage; if an early stage legitimately exits 1 (grep no-match), split the pipeline to see which part failed.]");
|
|
437
465
|
}
|
|
466
|
+
const manifest = missingManifest(out);
|
|
467
|
+
if (manifest) {
|
|
468
|
+
notes.push(`[note: this ran in a folder with no ${manifest}, so it checked nothing. cd to the project's root (the folder that holds ${manifest}) and run it again. A check run from the wrong folder is a failed check, never an expected one.]`);
|
|
469
|
+
}
|
|
438
470
|
if (/ambiguous argument .* unknown revision or path/.test(out)) {
|
|
439
471
|
notes.push("[hint: git can't resolve that ref HERE — either the name shadows a path (disambiguate: `git <cmd> <rev> -- <path>`), or the branch doesn't exist in THIS checkout (worktrees/other clones hold their own local branches). Check first with `git rev-parse --verify <ref>` or `git branch -a`; don't retry variants blind.]");
|
|
440
472
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
// One
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// gateway
|
|
5
|
-
// none; the local router on loopback (no token) when /healthz says the route is up; else the public
|
|
6
|
-
// gateway with the signed-in Operator token. No token and no local router → none (the direct chain). The
|
|
7
|
-
// engine never adds a cloud provider here — which servers back `vision` is the route's decision.
|
|
1
|
+
// One door for vision: image_analyze / video_analyze speak OpenAI-vision to OUR gateway's `vision` route, and
|
|
2
|
+
// the router owns which model servers back it. The engine holds no endpoint list, probes nothing and starts
|
|
3
|
+
// nothing: it asks the local router on loopback (no token), then the public gateway with the signed-in
|
|
4
|
+
// Operator token. `services.vision.gateway` pins one URL instead; "off" turns vision off.
|
|
8
5
|
import { getOperatorToken, operatorTrustedUrl } from "../engine/aurora.js";
|
|
6
|
+
import { retry, retryAfterMs, realClock, ROUTE_RETRY } from "../util/retry.js";
|
|
9
7
|
export const LOCAL_VISION_GATEWAY = "http://127.0.0.1:8620/v1";
|
|
10
8
|
export const PUBLIC_VISION_GATEWAY = "https://api.0perator.co/v1";
|
|
11
9
|
export const DEFAULT_VISION_ROUTE = "vision";
|
|
12
|
-
|
|
10
|
+
/** Request-side limits (overridable in `services.vision`). Time on a vision call is image tokens plus the
|
|
11
|
+
* model's reasoning tokens. 2048 px keeps small terminal text readable (measured on a GPU leg: 3.8 s, against
|
|
12
|
+
* 1.4 s at 1024 px where it is not); `maxBytes` re-encodes a PNG that is small enough in pixels but heavy.
|
|
13
|
+
* `timeoutMs` is the deadline for the whole call: every gateway, every retry. */
|
|
14
|
+
export const VISION_LIMITS = { maxEdge: 2048, maxBytes: 2_000_000, maxTokens: 1024, timeoutMs: 120_000 };
|
|
13
15
|
const isLoopback = (u) => /^https?:\/\/(127\.0\.0\.1|localhost|\[::1\])(:|\/|$)/.test(u);
|
|
14
16
|
function tokenFor(base) {
|
|
15
17
|
if (isLoopback(base) || !operatorTrustedUrl(base))
|
|
@@ -17,39 +19,82 @@ function tokenFor(base) {
|
|
|
17
19
|
const token = getOperatorToken() || process.env.KODE_OPERATOR_TOKEN;
|
|
18
20
|
return token ? { Authorization: `Bearer ${token}` } : {};
|
|
19
21
|
}
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return r.ok;
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export async function resolveVisionGateway(s, o = {}) {
|
|
32
|
-
const v = s.services?.vision;
|
|
33
|
-
const model = v?.model?.trim() || DEFAULT_VISION_ROUTE;
|
|
34
|
-
const gw = v?.gateway?.trim();
|
|
22
|
+
/** The gateways to ask, in order. A signed-out public gateway stays in the list with `skip` set, so the
|
|
23
|
+
* "vision is down" line can say why it was not asked. */
|
|
24
|
+
export function visionGateways(v = {}) {
|
|
25
|
+
const model = v.model?.trim() || DEFAULT_VISION_ROUTE;
|
|
26
|
+
const gw = v.gateway?.trim();
|
|
35
27
|
if (gw === "off")
|
|
36
|
-
return
|
|
28
|
+
return [];
|
|
37
29
|
if (gw && gw !== "auto") {
|
|
38
30
|
const base = gw.replace(/\/$/, "");
|
|
39
|
-
return { base, model, auth: tokenFor(base), label: "gateway" };
|
|
31
|
+
return [{ base, model, auth: tokenFor(base), label: "gateway" }];
|
|
40
32
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return { base: local, model, auth: {}, label: "local gateway" };
|
|
47
|
-
const pub = (o.publicBase ?? PUBLIC_VISION_GATEWAY).replace(/\/$/, "");
|
|
48
|
-
const auth = tokenFor(pub);
|
|
49
|
-
return auth.Authorization ? { base: pub, model, auth, label: "0perator gateway" } : null;
|
|
33
|
+
const auth = tokenFor(PUBLIC_VISION_GATEWAY);
|
|
34
|
+
return [
|
|
35
|
+
{ base: LOCAL_VISION_GATEWAY, model, auth: {}, label: "local gateway" },
|
|
36
|
+
{ base: PUBLIC_VISION_GATEWAY, model, auth, label: "0perator gateway", ...(auth.Authorization ? {} : { skip: "not signed in" }) },
|
|
37
|
+
];
|
|
50
38
|
}
|
|
51
39
|
/** A per-call `model` the agent may pick on the gateway: only our own vision routes (`vision`, `vision-jl2`,
|
|
52
40
|
* …). A catalog id (`vendor/model:free`) would send a private image to a third-party provider. */
|
|
53
41
|
export function gatewayModelAllowed(model) {
|
|
54
42
|
return /^vision(-[a-z0-9]+)*$/i.test(model);
|
|
55
43
|
}
|
|
44
|
+
/** One POST to one gateway: the answer, or why there is none in plain words (never the response body). Busy
|
|
45
|
+
* (503, 429) and refused are worth another attempt; a caller's fault, another 5xx or a timeout is not. */
|
|
46
|
+
async function postVision(gw, req, timeoutMs, now) {
|
|
47
|
+
try {
|
|
48
|
+
const res = await fetch(`${gw.base}/chat/completions`, {
|
|
49
|
+
method: "POST", signal: AbortSignal.timeout(timeoutMs),
|
|
50
|
+
headers: { "Content-Type": "application/json", "User-Agent": "operator/kode-tsi", ...gw.auth },
|
|
51
|
+
body: JSON.stringify({
|
|
52
|
+
model: req.model && gatewayModelAllowed(req.model) ? req.model : gw.model,
|
|
53
|
+
messages: [{ role: "system", content: req.system }, { role: "user", content: req.parts }],
|
|
54
|
+
max_tokens: req.maxTokens, temperature: 0,
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
if (res.status === 503 || res.status === 429)
|
|
58
|
+
return { error: `returned ${res.status}`, retry: true, retryAfterMs: retryAfterMs(res.headers.get("retry-after"), now) };
|
|
59
|
+
if (!res.ok)
|
|
60
|
+
return { error: `returned ${res.status}` };
|
|
61
|
+
// A reasoning model spends tokens before it answers: the answer is message.content, never the reasoning.
|
|
62
|
+
const j = (await res.json());
|
|
63
|
+
const text = j.choices?.[0]?.message?.content?.trim();
|
|
64
|
+
if (text)
|
|
65
|
+
return { ok: text };
|
|
66
|
+
return { error: j.choices?.[0]?.finish_reason === "length" ? `spent all ${req.maxTokens} tokens before answering` : "returned no text" };
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
const name = e?.name;
|
|
70
|
+
if (name === "TimeoutError" || name === "AbortError")
|
|
71
|
+
return { error: `timed out after ${Math.round(timeoutMs / 1000)}s` };
|
|
72
|
+
return name === "SyntaxError" ? { error: "returned no text" } : { error: "unreachable", retry: true };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** Ask each gateway in order, retrying a busy one (util/retry.ts) before moving on, all inside one deadline
|
|
76
|
+
* of `req.timeoutMs`. A gateway's attempt may use the time left divided by the gateways still to ask, so a
|
|
77
|
+
* hung first gateway cannot spend the next one's share. Throws one plain line when none answers. */
|
|
78
|
+
export async function askVision(gateways, req, clock = realClock) {
|
|
79
|
+
if (!gateways.length)
|
|
80
|
+
throw new Error("vision is off (services.vision.gateway is \"off\")");
|
|
81
|
+
const deadline = clock.now() + req.timeoutMs;
|
|
82
|
+
const down = [];
|
|
83
|
+
let toAsk = gateways.filter((g) => !g.skip).length;
|
|
84
|
+
for (const gw of gateways) {
|
|
85
|
+
if (gw.skip) {
|
|
86
|
+
down.push(`${gw.label}: ${gw.skip}`);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const share = toAsk--;
|
|
90
|
+
if (clock.now() >= deadline) {
|
|
91
|
+
down.push(`${gw.label}: not asked, out of time`);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const { result, attempts } = await retry(() => postVision(gw, req, Math.max(1, Math.ceil((deadline - clock.now()) / share)), clock.now()), { ...ROUTE_RETRY, deadline }, clock);
|
|
95
|
+
if ("ok" in result)
|
|
96
|
+
return result.ok;
|
|
97
|
+
down.push(`${gw.label}: ${result.error} (${attempts} attempt${attempts === 1 ? "" : "s"})`);
|
|
98
|
+
}
|
|
99
|
+
throw new Error(`vision is down: ${down.join("; ")}. Not worth retrying this turn.`);
|
|
100
|
+
}
|
package/dist/tools/wave-tools.js
CHANGED
|
@@ -448,8 +448,8 @@ export const WAVE_TOOLS = [
|
|
|
448
448
|
description: "Create a new file. Errors if file already exists (use file_write to overwrite). Creates parent dirs.",
|
|
449
449
|
parameters: { type: "object", properties: {
|
|
450
450
|
path: { type: "string" },
|
|
451
|
-
content: { type: "string", description: "
|
|
452
|
-
}, required: ["path"] },
|
|
451
|
+
content: { type: "string", description: "\"\" = empty file" },
|
|
452
|
+
}, required: ["path", "content"] },
|
|
453
453
|
run: fileCreateRun,
|
|
454
454
|
},
|
|
455
455
|
{
|
|
@@ -196,7 +196,7 @@ async function sqlExecRun(args) {
|
|
|
196
196
|
const opts = { timeout: 30_000, maxBuffer: 10 * 1024 * 1024, encoding: "utf8" };
|
|
197
197
|
if (engine === "sqlite") {
|
|
198
198
|
if (!db)
|
|
199
|
-
return "error: database path
|
|
199
|
+
return "error: sql_exec needs `database` — the sqlite file path, e.g. database: \"./app.db\"";
|
|
200
200
|
if (!flagSafe(db))
|
|
201
201
|
return "error: database path must not start with '-'";
|
|
202
202
|
// argv keeps /bin/sh out, but sqlite3 itself runs a dot-command query (.shell, .system, .output); -safe refuses them.
|
|
@@ -209,7 +209,7 @@ async function sqlExecRun(args) {
|
|
|
209
209
|
}
|
|
210
210
|
if (engine === "psql") {
|
|
211
211
|
if (!db)
|
|
212
|
-
return "error: connection string
|
|
212
|
+
return "error: sql_exec needs `database` — the psql connection string, e.g. database: \"postgres://localhost/app\"";
|
|
213
213
|
if (!flagSafe(db))
|
|
214
214
|
return "error: connection string must not start with '-'";
|
|
215
215
|
// psql -c runs a string that starts with a backslash as a meta-command, and \! is a shell.
|
|
@@ -382,13 +382,13 @@ export const WAVE2_TOOLS = [
|
|
|
382
382
|
},
|
|
383
383
|
{
|
|
384
384
|
name: "sql_exec", safe: false,
|
|
385
|
-
contract: { v:
|
|
385
|
+
contract: { v: 2, effects: ["read", "write", "destructive", "exec"], bins: ["sqlite3", "psql"] },
|
|
386
386
|
description: "Execute SQL against a database. Engines: sqlite (default; database = file path) and psql (database = connection string).",
|
|
387
387
|
parameters: { type: "object", properties: {
|
|
388
388
|
query: { type: "string", description: "SQL to execute" },
|
|
389
|
-
database: { type: "string"
|
|
390
|
-
engine: { type: "string", description: "sqlite or psql
|
|
391
|
-
}, required: ["query"] },
|
|
389
|
+
database: { type: "string" },
|
|
390
|
+
engine: { type: "string", description: "sqlite or psql" },
|
|
391
|
+
}, required: ["query", "database"] },
|
|
392
392
|
run: sqlExecRun,
|
|
393
393
|
},
|
|
394
394
|
{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// The /artifacts browser
|
|
2
|
+
// The /artifacts browser: the owner's Temple artifact picker, modelled on QuestionPrompt —
|
|
3
3
|
// a pure keystroke reducer (testable without a TTY) + useInput gated while the picker is up, rendered as a
|
|
4
4
|
// bordered inline box above the composer (Operator has no alt-screen modal system; see App.tsx prompts).
|
|
5
5
|
// P1 scope: the owner's library ("Mine") with live search, and per-row actions attach / copy-url / delete /
|
|
@@ -98,7 +98,7 @@ export function ArtifactPicker({ pending, suspended = false }) {
|
|
|
98
98
|
if (!pending)
|
|
99
99
|
return null;
|
|
100
100
|
const { loading, error, note } = pending;
|
|
101
|
-
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsxs(Text, { color: "cyan", bold: true, children: ["◆ Artifacts ", _jsx(Text, { color: "cyan", bold: true, children: "[Mine]" }), _jsx(Text, { dimColor: true, children: " All Shared (soon)" })] }), st.mode === "search" ? (_jsxs(Text, { children: [_jsx(Text, { color: "magenta", children: "search› " }), st.query, _jsx(Text, { color: "cyan", children: "\u258C" })] })) : null, loading ? _jsx(Text, { dimColor: true, children: " loading…" }) : null, error ? _jsx(Text, { color: "red", children: " " + error }) : null, !loading && !error && n === 0 ? (_jsx(Text, { dimColor: true, children: st.query ? ` no artifacts match "${st.query}"` : " no artifacts yet —
|
|
101
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsxs(Text, { color: "cyan", bold: true, children: ["◆ Artifacts ", _jsx(Text, { color: "cyan", bold: true, children: "[Mine]" }), _jsx(Text, { dimColor: true, children: " All Shared (soon)" })] }), st.mode === "search" ? (_jsxs(Text, { children: [_jsx(Text, { color: "magenta", children: "search› " }), st.query, _jsx(Text, { color: "cyan", children: "\u258C" })] })) : null, loading ? _jsx(Text, { dimColor: true, children: " loading…" }) : null, error ? _jsx(Text, { color: "red", children: " " + error }) : null, !loading && !error && n === 0 ? (_jsx(Text, { dimColor: true, children: st.query ? ` no artifacts match "${st.query}"` : " no artifacts yet — ask Operator to make one" })) : null, !loading && !error && items.slice(start, end).map((it, i) => {
|
|
102
102
|
const idx = start + i;
|
|
103
103
|
const sel = idx === hi;
|
|
104
104
|
const armed = st.confirmDeleteId === it.id;
|
package/dist/ui/Composer.js
CHANGED
|
@@ -191,7 +191,7 @@ export function Composer({ onSubmit, onInterrupt, onQueue, onSteer, disabled, su
|
|
|
191
191
|
// ESC / Ctrl+C: apply the pure interruptPlan. ESC mid-turn with a pending draft flushes it into
|
|
192
192
|
// the queue (so it goes through right after the interrupt, via the turn-finally drain), then
|
|
193
193
|
// interrupts; an empty-draft ESC and every Ctrl+C are plain interrupts. See interruptPlan below.
|
|
194
|
-
// With the next-step strip up, Esc closes it; Ctrl+C keeps its meaning (at rest: quit) — review F13.
|
|
194
|
+
// With the next-step strip up, Esc closes it; Ctrl+C keeps its meaning (at rest: twice to quit) — review F13.
|
|
195
195
|
if (key.escape && nextSteps > 0) {
|
|
196
196
|
onDismissNext?.();
|
|
197
197
|
return;
|
|
@@ -204,7 +204,7 @@ export function Composer({ onSubmit, onInterrupt, onQueue, onSteer, disabled, su
|
|
|
204
204
|
onQueue(text);
|
|
205
205
|
}
|
|
206
206
|
if (plan.interrupt)
|
|
207
|
-
onInterrupt();
|
|
207
|
+
onInterrupt(key.escape ? "esc" : "ctrl-c");
|
|
208
208
|
return;
|
|
209
209
|
}
|
|
210
210
|
// After a stop, a digit on an empty draft picks a next step; any other typed key hides the strip and types normally.
|
|
@@ -401,6 +401,13 @@ export function interruptPlan(key, ctx) {
|
|
|
401
401
|
return { flushDraft: false, interrupt: true };
|
|
402
402
|
return { flushDraft: false, interrupt: false };
|
|
403
403
|
}
|
|
404
|
+
/** What Esc / Ctrl+C do when no turn is running. Esc does nothing: it only ever interrupts. Ctrl+C quits on a second
|
|
405
|
+
* press inside `confirmMs`; the first one arms it. */
|
|
406
|
+
export function restKey(key, armedAt, now, confirmMs) {
|
|
407
|
+
if (key === "esc")
|
|
408
|
+
return "ignore";
|
|
409
|
+
return now - armedAt < confirmMs ? "quit" : "arm";
|
|
410
|
+
}
|
|
404
411
|
/** Where Enter sends a committed draft. At rest it submits. While a turn runs, plain text STEERS — it goes in before the
|
|
405
412
|
* turn's next model call, as an owner message — and a known /command queues (the shell decides whether it runs now or
|
|
406
413
|
* after the turn). Without a steer sink it queues, as before. */
|
package/dist/ui/StatusRule.js
CHANGED
|
@@ -57,7 +57,7 @@ export function statusRight(p, cols) {
|
|
|
57
57
|
const tok = p.sessionTokens && p.sessionTokens > 0 ? `Σ${fmtK(p.sessionTokens)} · ` : ""; // session token total
|
|
58
58
|
// ctx as a fill ring (○◔◑◕●) + the exact % — a glance shows how full the context window is, the number keeps precision.
|
|
59
59
|
// Show the active model (cortana, claude-opus, moa, custom …) and the window it runs on, never the leg that answered
|
|
60
|
-
// ("cortana@192.
|
|
60
|
+
// ("cortana@192.0.2.10:8112" read as noise; /endpoints lists the legs). The default model reads as "aurora", not
|
|
61
61
|
// its id operator-1m (owner, 11/03: "just aurora 300k"), and the window is the one served, not a pin above it.
|
|
62
62
|
const window = p.ctxWindow ? ` ${p.ctxWindow}` : "";
|
|
63
63
|
let info = `${think}${plan}${seat}${who}${routeLabel(p.route)}${window} ${ring(p.ctxPct)} ${Math.round(p.ctxPct)}% · ${tok}v${p.version}${p.build ? ` ·${p.build}` : ""}`;
|
package/dist/ui/modelPicker.js
CHANGED
|
@@ -14,7 +14,7 @@ export const CONNECT_ROW = "+ Connect a provider key (Anthropic, Google, Nous, O
|
|
|
14
14
|
/** Presets whose zero-price rows /model lists once their key is connected (router/free-models.ts) — OpenRouter's
|
|
15
15
|
* `:free` listing joins here. */
|
|
16
16
|
export const FREE_ROW_PRESETS = ["operator", "nous"];
|
|
17
|
-
// fleet → connected providers → free rows → MOA. The built-ins already list
|
|
17
|
+
// fleet → connected providers → free rows → MOA. The built-ins already list the local row before the gateway rows.
|
|
18
18
|
const group = (m) => (m.kind === "orchestrated" ? 3 : m.tier === "free" ? 2 : m.byo ? 1 : 0);
|
|
19
19
|
/** The picker order of a visible registry: fleet rows, the connected providers, the free rows, then MOA — a stable
|
|
20
20
|
* partition, so registry order decides inside each group. */
|
package/dist/ui/nextStep.js
CHANGED
|
@@ -53,6 +53,7 @@ function stopSteps(kind, o) {
|
|
|
53
53
|
case "rounds": return [send("continue", "continue", "Continue from here."), send("continue, think off", "no-think", "Continue from here.", true)];
|
|
54
54
|
case "unanswered": return [send("send it again", "again", "Answer my last message — nothing answered it last time."), { label: "model…", short: "model", action: { kind: "model" } }];
|
|
55
55
|
case "length": return [send("continue", "continue", "Continue exactly where you stopped.")];
|
|
56
|
+
case "context_floor": return [{ label: "model…", short: "model", action: { kind: "model" } }];
|
|
56
57
|
case "yield": return [
|
|
57
58
|
send("keep going meanwhile", "go", "Keep going on the next step meanwhile."),
|
|
58
59
|
send("take a step over yourself", "take over", "Take the delegated step over yourself."),
|
package/dist/ui/pending.js
CHANGED
|
@@ -4,8 +4,18 @@
|
|
|
4
4
|
// hint widths are unit-tested without a TTY.
|
|
5
5
|
import { seg } from "./fit.js";
|
|
6
6
|
import { fitWithTail } from "./fitTail.js";
|
|
7
|
+
import { isSlashCommand, midTurnClass } from "../util/slash.js";
|
|
7
8
|
const PREVIEW_MIN = 24; // cells a preview keeps before the key hints give way (fitTail.ts)
|
|
8
9
|
const preview = (texts) => texts.join("\n").replace(/\s*\n\s*/g, " / ");
|
|
10
|
+
/** Where a line queued while a turn runs goes (util/slash.ts MIDTURN): a "now" or "next" command runs at once and the
|
|
11
|
+
* turn keeps going; an "after" command is staged; text waits for the turn to end. At rest nothing runs from here. */
|
|
12
|
+
export function queueRoute(text, busy) {
|
|
13
|
+
const cmd = text.trim();
|
|
14
|
+
if (!busy || !isSlashCommand(cmd))
|
|
15
|
+
return { item: { kind: "after", text } };
|
|
16
|
+
const cls = midTurnClass(cmd);
|
|
17
|
+
return cls === "after" ? { item: { kind: "command", text: cmd } } : { run: cmd, cls };
|
|
18
|
+
}
|
|
9
19
|
/** ↑ / ⌫ act on the most recent pending item, whichever kind it is. */
|
|
10
20
|
export function popLatest(items) {
|
|
11
21
|
if (!items.length)
|