@0perator/operator 0.1.284 → 0.1.313
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 +24 -2
- package/dist/acp/agent.js +3 -2
- package/dist/acp/config-options.js +15 -1
- package/dist/acp/tool-map.js +2 -1
- package/dist/auth/commands.js +69 -13
- package/dist/autonomy/agent-cli.js +304 -0
- package/dist/autonomy/cloud-agent.js +439 -0
- package/dist/autonomy/cron-lifecycle.js +78 -0
- package/dist/autonomy/cron-lock.js +121 -0
- package/dist/autonomy/cron.js +216 -43
- package/dist/autonomy/delegate.js +5 -1
- package/dist/autonomy/incidents.js +135 -0
- package/dist/autonomy/session-factory.js +25 -16
- package/dist/background/index.js +40 -0
- package/dist/bus/inbox.js +20 -0
- package/dist/classifier/config.js +47 -0
- package/dist/classifier/modes.js +41 -0
- package/dist/classifier/types.js +1 -0
- package/dist/cli.js +529 -53
- package/dist/config/features.js +69 -0
- package/dist/config/persona.js +118 -99
- package/dist/config/scaffold.js +15 -0
- package/dist/config/settings.js +96 -6
- package/dist/consolidation/sleep.js +73 -11
- package/dist/engine/agent.js +275 -18
- package/dist/engine/anthropic-chat.js +343 -0
- package/dist/engine/aurora.js +101 -13
- package/dist/engine/batch-scheduler.js +41 -9
- package/dist/engine/classifier.js +85 -0
- package/dist/engine/compaction.js +24 -5
- package/dist/engine/fast-start.js +25 -0
- package/dist/engine/loop-guard.js +448 -0
- package/dist/engine/moa.js +5 -1
- package/dist/engine/net-error.js +24 -0
- package/dist/engine/repetition-guard.js +180 -0
- package/dist/engine/selfheal.js +8 -0
- package/dist/engine/toolcalls.js +51 -1
- package/dist/engine/verify-gate.js +2 -0
- package/dist/flywheel/processor.js +78 -31
- package/dist/flywheel/srft.js +13 -0
- package/dist/hooks/index.js +196 -0
- package/dist/mcp/config.js +21 -1
- package/dist/memory/index.js +0 -0
- package/dist/memory/providers.js +210 -0
- package/dist/memory/session-catalog.js +422 -0
- package/dist/memory/session-providers.js +121 -0
- package/dist/memory/session-sources.js +335 -0
- package/dist/memory/skylark.js +131 -0
- package/dist/models/bench.js +103 -0
- package/dist/models/registry.js +144 -0
- package/dist/models/switch.js +69 -0
- package/dist/observability/blackbox.js +37 -0
- package/dist/permissions/policy.js +31 -6
- package/dist/router/discovery.js +127 -0
- package/dist/router/models.js +117 -24
- package/dist/router/portal.js +100 -0
- package/dist/router/router.js +1 -1
- package/dist/services/preflight.js +55 -7
- package/dist/session.js +316 -46
- package/dist/tools/chauffeur.js +12 -0
- package/dist/tools/executor.js +19 -9
- package/dist/tools/find-files.js +483 -0
- package/dist/tools/git-pr.js +94 -0
- package/dist/tools/incident-tools.js +82 -0
- package/dist/tools/memory.js +12 -2
- package/dist/tools/registry.js +281 -85
- package/dist/tools/semantic-compress.js +124 -0
- package/dist/tools/shell-context.js +1 -0
- package/dist/tools/shell-jobs.js +160 -0
- package/dist/tools/shell-session.js +170 -4
- package/dist/tools/wave-tools.js +609 -0
- package/dist/tools/wave2-tools.js +411 -0
- package/dist/ui/App.js +15 -4
- package/dist/ui/BgPanel.js +30 -6
- package/dist/ui/Composer.js +11 -1
- package/dist/ui/QuestionPrompt.js +31 -11
- package/dist/ui/SessionPicker.js +86 -0
- package/dist/ui/StatusRule.js +5 -5
- package/dist/ui/ToolStep.js +2 -1
- package/dist/ui/Transcript.js +17 -1
- package/dist/ui/index.js +1 -1
- package/dist/ui/liveTools.js +21 -3
- package/dist/ui/slashCommands.js +2 -0
- package/dist/util/screenshots.js +74 -8
- package/dist/util/slash.js +2 -2
- package/package.json +8 -2
- package/dist/engine/cli.js +0 -1171
- package/dist/router/models.js.bak +0 -78
- package/dist/router/models.js.bak-1791259923 +0 -78
- package/dist/router/models.js.bak-pre-gateway +0 -78
- package/dist/router/models.js.bak-pre-patch2 +0 -78
- package/dist/router/models.js.bak2 +0 -78
- package/dist/services/model-autodetect.js +0 -240
- package/dist/tools/native-redirect.js +0 -140
- package/dist/tools/power-tools.js +0 -627
- package/dist/tools/registry.js.bak-1791259948 +0 -1914
- package/dist/tools/registry.js.bak-pre-plugins +0 -1914
- package/dist/ui/BusTray.js +0 -70
- package/dist/ui/resize.js +0 -160
package/dist/tools/registry.js
CHANGED
|
@@ -5,18 +5,33 @@
|
|
|
5
5
|
// JSCore engine for tool SCHEMAS (toSchemas), but the run() bodies below never execute there — the
|
|
6
6
|
// mobile app runs tools natively in Swift. nodeImport() keeps esbuild from statically resolving them.
|
|
7
7
|
const nodeImport = (m) => import(m);
|
|
8
|
-
import {
|
|
8
|
+
import { buildMemory } from "../memory/providers.js";
|
|
9
9
|
import { indexSessions, readSession, searchSessions } from "../memory/session-index.js";
|
|
10
|
+
import { formatHits, indexCatalog, readCatalogSession, searchCatalog, sessionSearchConfig, SESSION_SCOPES } from "../memory/session-catalog.js";
|
|
10
11
|
import { listLocalSkills, localSkillsDir as profileSkillsDir, resolveSkillFile } from "../config/skills-index.js";
|
|
11
12
|
import { operatorPath } from "../config/home.js";
|
|
12
13
|
import { ownChild } from "../util/owned-children.js";
|
|
14
|
+
import { BG_MAX_RUNNING, createJob, finishJob, newJobId, pruneShellJobs, runningJobCount, shellJobs, stopShellJob, trackJobOutput } from "./shell-jobs.js";
|
|
13
15
|
import { pexecFile } from "./exec.js";
|
|
16
|
+
import { WAVE_TOOLS } from "./wave-tools.js";
|
|
17
|
+
import { WAVE2_TOOLS } from "./wave2-tools.js";
|
|
18
|
+
import { GIT_PR_TOOLS } from "./git-pr.js";
|
|
19
|
+
import { INCIDENT_TOOLS } from "./incident-tools.js";
|
|
20
|
+
import { findFiles, FIND_FILES_DEFAULT_LIMIT, FIND_FILES_MAX_LIMIT, KINDS } from "./find-files.js";
|
|
14
21
|
import { formatGitStatus } from "./git-status.js";
|
|
15
22
|
import { expandPath } from "./paths.js";
|
|
16
23
|
import { runMemoryTool } from "./memory.js";
|
|
17
24
|
import { documentGenerate } from "./document.js";
|
|
18
25
|
import { runCronTool } from "../autonomy/cron.js";
|
|
19
26
|
import { runDelegateTask } from "../autonomy/delegate.js";
|
|
27
|
+
import { runDelegateToAgent, agentCliToolDescription } from "../autonomy/agent-cli.js";
|
|
28
|
+
import { runSpawnCloudAgent, runListCloudAgents, runCloudAgentStatus, runStopCloudAgent } from "../autonomy/cloud-agent.js";
|
|
29
|
+
import { isFeatureEnabled } from "../config/features.js";
|
|
30
|
+
import { BYO_PRESETS } from "../router/models.js";
|
|
31
|
+
// BYO cloud provider ids delegate_task can target once the owner has stored that provider's key (the preset
|
|
32
|
+
// table; a custom provider registered via `operator auth byo-model` works the same). Surfaced in the tool
|
|
33
|
+
// description so the model KNOWS the option exists — without it, it never delegates to a connected cloud.
|
|
34
|
+
const BYO_DELEGATE_PROVIDERS = Object.keys(BYO_PRESETS).join(", ");
|
|
20
35
|
import { runSessionRewind } from "../memory/session-rewind.js";
|
|
21
36
|
import { runSkillCatalog } from "../skills/catalogue.js";
|
|
22
37
|
import { runBrowser, runBrowserRead } from "../browser/session.js";
|
|
@@ -47,7 +62,24 @@ async function getShellSession() {
|
|
|
47
62
|
sess = new ShellSession();
|
|
48
63
|
_shells.set(key, sess);
|
|
49
64
|
}
|
|
50
|
-
return sess;
|
|
65
|
+
return { sess, key };
|
|
66
|
+
}
|
|
67
|
+
/** ctrl+b: hand the foreground session's running shell command to a background job. The tool call resolves
|
|
68
|
+
* right away (shellExec returns the "moved to background" result); returns false when nothing is running. */
|
|
69
|
+
export function requestShellDetach(key) {
|
|
70
|
+
return _shells.get(key)?.requestDetach() ?? false;
|
|
71
|
+
}
|
|
72
|
+
/** Take over a command that was just detached: it becomes job `id`, and the session gets a fresh shell that
|
|
73
|
+
* starts where the old one was (cwd only — exported variables, functions and aliases stay with the old shell). */
|
|
74
|
+
function adoptDetached(key, run, id, ShellSession, processCwd) {
|
|
75
|
+
const job = createJob(id, run.command, { kill: (sig) => run.kill(sig), pid: run.pid }, "moved");
|
|
76
|
+
job.started = run.startedAt;
|
|
77
|
+
trackJobOutput(job, run.partial);
|
|
78
|
+
run.setTap((chunk) => trackJobOutput(job, chunk));
|
|
79
|
+
void run.finished.then((r) => finishJob(job, r.exitCode));
|
|
80
|
+
const fresh = new ShellSession();
|
|
81
|
+
fresh.seedCwd(processCwd(run.pid));
|
|
82
|
+
_shells.set(key, fresh);
|
|
51
83
|
}
|
|
52
84
|
/** Kill EVERY persistent shell (and their process groups) on process shutdown so none orphan.
|
|
53
85
|
* Wired into the CLI's exit/SIGTERM handlers — no-op if no shell was ever started. */
|
|
@@ -75,12 +107,32 @@ async function shellExec(args) {
|
|
|
75
107
|
const cwd = args.cwd ? expandPath(str(args.cwd)) : undefined;
|
|
76
108
|
const toRun = cwd ? `( cd ${JSON.stringify(cwd)} && { ${command}; } )` : command;
|
|
77
109
|
try {
|
|
78
|
-
const
|
|
79
|
-
const
|
|
110
|
+
const { shellExecMode } = (await nodeImport("./shell-context.js"));
|
|
111
|
+
const mod = (await nodeImport("./shell-session.js"));
|
|
112
|
+
const mode = shellExecMode.getStore() ?? "persistent";
|
|
113
|
+
// Multi-shell rounds (Executor.executeParallel sets mode=ephemeral) must NOT share the persistent
|
|
114
|
+
// FIFO — concurrent stdin/sentinel framing would cross-wire output. One-shot bash overlaps for real.
|
|
115
|
+
// Lone bash stays persistent (cwd/env + ctrl+b detach).
|
|
116
|
+
let r;
|
|
117
|
+
let movedId = "";
|
|
118
|
+
if (mode === "ephemeral") {
|
|
119
|
+
r = await mod.runEphemeralShell(toRun, timeout);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
const { sess, key } = await getShellSession();
|
|
123
|
+
r = await sess.run(toRun, timeout, { onDetach: (run) => { movedId = newJobId(); adoptDetached(key, run, movedId, mod.ShellSession, mod.processCwd); } });
|
|
124
|
+
}
|
|
80
125
|
let out = r.output || "";
|
|
81
|
-
|
|
126
|
+
if (r.detached) {
|
|
127
|
+
const sofar = out ? `\nOutput so far:\n${out.split("\n").slice(-20).join("\n")}` : "";
|
|
128
|
+
return `moved to background as ${movedId}: ${command}\nIt keeps running. You will be notified when it finishes, so do not poll. bash_output {"id":"${movedId}"} reads its output, bash_kill {"id":"${movedId}"} stops it.\nThe shell restarted in the same directory (environment variables, functions and aliases from the old shell are not carried over). It is free for your next command.${sofar}`;
|
|
129
|
+
}
|
|
130
|
+
const { shellResultNotes } = mod;
|
|
82
131
|
if (r.timedOut) {
|
|
83
|
-
|
|
132
|
+
const resetNote = mode === "ephemeral"
|
|
133
|
+
? `[timed out after ${timeout}ms — ephemeral shell killed; narrow the command or pass a larger timeout_ms]`
|
|
134
|
+
: `[timed out after ${timeout}ms — the shell was reset (cwd/env cleared); narrow the command or pass a larger timeout_ms]`;
|
|
135
|
+
return (out ? out + "\n" : "") + resetNote;
|
|
84
136
|
}
|
|
85
137
|
if (r.truncated)
|
|
86
138
|
out += `\n[output truncated at 8MB — narrow it: add a path, pipe to \`head\`, or use \`grep -l\`/\`grep -c\`]`;
|
|
@@ -440,21 +492,37 @@ async function gitStatus(args) {
|
|
|
440
492
|
// isolation default — is honored however late it is set; an eager `new MemoryStore()` resolved the prod
|
|
441
493
|
// path before any test could redirect it.
|
|
442
494
|
let _memoryStore;
|
|
443
|
-
|
|
495
|
+
/** The tools' shared memory surface. Settings load lazily (node-only) so this stays out of the neutral
|
|
496
|
+
* browser graph; a node-free host — or no `memory.providers` configured — gets the bare MemoryStore,
|
|
497
|
+
* byte-identical to the pre-provider engine. Built once, like the old singleton. */
|
|
498
|
+
const memory = async () => {
|
|
499
|
+
if (_memoryStore)
|
|
500
|
+
return _memoryStore;
|
|
501
|
+
let cfg;
|
|
502
|
+
try {
|
|
503
|
+
const { loadSettings } = await nodeImport("../config/settings.js"); // variable-specifier load keeps settings out of the browser graph
|
|
504
|
+
cfg = loadSettings().memory;
|
|
505
|
+
}
|
|
506
|
+
catch { /* node-free host — local store only */ }
|
|
507
|
+
return (_memoryStore = buildMemory(cfg));
|
|
508
|
+
};
|
|
444
509
|
async function memoryStore(args) {
|
|
445
510
|
const text = str(args.text);
|
|
446
511
|
if (!text)
|
|
447
512
|
return "error: no text given";
|
|
448
513
|
const tags = Array.isArray(args.tags) ? args.tags.map(String) : [];
|
|
449
|
-
const
|
|
450
|
-
|
|
514
|
+
const supersedes = str(args.supersedes) || undefined;
|
|
515
|
+
const ok = await (await memory()).capture(text, tags, supersedes);
|
|
516
|
+
if (!ok)
|
|
517
|
+
return "error: could not store memory";
|
|
518
|
+
return `stored memory (${tags.join(",") || "no tags"})` + (supersedes ? `, superseding ${supersedes}` : "");
|
|
451
519
|
}
|
|
452
520
|
async function memorySearch(args) {
|
|
453
521
|
const query = str(args.query);
|
|
454
522
|
const limit = Number(args.limit ?? 10);
|
|
455
|
-
const hits = await memory().recall(query || undefined, limit);
|
|
523
|
+
const hits = await (await memory()).recall(query || undefined, limit);
|
|
456
524
|
return hits.length
|
|
457
|
-
? hits.map(h => `[${new Date(h.ts).toISOString()}] ${h.text}`).join("\n")
|
|
525
|
+
? hits.map(h => `[${h.id ?? "no-id"}] [${new Date(h.ts).toISOString()}] ${h.text}`).join("\n")
|
|
458
526
|
: "(no matches)";
|
|
459
527
|
}
|
|
460
528
|
// Git run for checkpoints, HARDENED so a checkpoint can never freeze the session (the "checkpoint… spins
|
|
@@ -539,7 +607,7 @@ async function checkpoint(args) {
|
|
|
539
607
|
const { stdout: sha } = await checkpointGit(["rev-parse", "--short", "HEAD"], workspace, 10_000);
|
|
540
608
|
if (push)
|
|
541
609
|
await checkpointGit(["push"], workspace, 120_000);
|
|
542
|
-
await memory().capture(summary, ["checkpoint", workspace]);
|
|
610
|
+
await (await memory()).capture(summary, ["checkpoint", workspace]);
|
|
543
611
|
return `checkpoint ${sha.trim()} — ${summary}${initialized ? " (new git repo initialized here)" : ""}${push ? " (pushed)" : ""}`;
|
|
544
612
|
}
|
|
545
613
|
catch (e) {
|
|
@@ -629,6 +697,45 @@ async function webSearch(args) {
|
|
|
629
697
|
clearTimeout(timer);
|
|
630
698
|
}
|
|
631
699
|
}
|
|
700
|
+
// Knowledge search — queries the vector knowledge base for semantic retrieval. safe/read-only.
|
|
701
|
+
// The wire client, config-resolution chain (env → operator-home kb.json → operator-named dotenv →
|
|
702
|
+
// unconfigured; decision 2026-10-21-config-resolution) and error taxonomy live in
|
|
703
|
+
// memory/skylark.ts — the ONE Skylark client, shared with the `skylark` memory provider
|
|
704
|
+
// (PV2-34 branch 2) so the tree never grows a second drifting implementation. This wrapper only
|
|
705
|
+
// maps the typed result onto the tool's user-facing strings.
|
|
706
|
+
async function knowledgeSearch(args) {
|
|
707
|
+
const q = str(args.query ?? args.q);
|
|
708
|
+
if (!q)
|
|
709
|
+
return "error: knowledge_search needs a query";
|
|
710
|
+
const n = Math.min(Math.max(Number(args.n ?? args.count ?? 5), 1), 20);
|
|
711
|
+
const { skylarkSearch } = await import("../memory/skylark.js");
|
|
712
|
+
const r = await skylarkSearch(q, n, Number(args.timeout_ms ?? 15_000));
|
|
713
|
+
if (!r.ok) {
|
|
714
|
+
switch (r.error) {
|
|
715
|
+
case "unconfigured":
|
|
716
|
+
// Branding boundary: actionable WITHOUT leaking internal env names or absolute paths — the
|
|
717
|
+
// full resolution chain (env overrides included) is documented in the README's Knowledge
|
|
718
|
+
// base section; the error points at the zero-knowledge-needed option only.
|
|
719
|
+
return 'error: knowledge_search — no access token configured. Add {"token": "…"} to kb.json ' +
|
|
720
|
+
"in the Operator home (chmod 600) — the README's Knowledge base section covers every option.";
|
|
721
|
+
case "unauthorized":
|
|
722
|
+
return "error: knowledge_search — knowledge base access token rejected (401)";
|
|
723
|
+
case "http":
|
|
724
|
+
return `error: knowledge_search — KB returned ${r.detail}. Is Skylark running?`;
|
|
725
|
+
case "timeout":
|
|
726
|
+
return "error searching knowledge base: timed out";
|
|
727
|
+
default:
|
|
728
|
+
return `error searching knowledge base: ${r.detail ?? "network failure"}`;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
if (!r.hits.length)
|
|
732
|
+
return "(no results in knowledge base)";
|
|
733
|
+
const out = r.hits.slice(0, n).map((h, i) => {
|
|
734
|
+
const snippet = String(h.text ?? "").replace(/\s+/g, " ").slice(0, 300);
|
|
735
|
+
return `${i + 1}. ${h.source}\n distance: ${h.distance.toFixed(4)}\n ${snippet}`;
|
|
736
|
+
}).join("\n\n");
|
|
737
|
+
return out || "(no results)";
|
|
738
|
+
}
|
|
632
739
|
// Retry a bot-blocked fetch through the AXE autopilot's real-browser /markdown route — same
|
|
633
740
|
// KODE_AUTOPILOT_URL backend web_search's /serp uses. Returns rendered markdown, or null if no
|
|
634
741
|
// backend is configured, the request fails, or the response has no usable body.
|
|
@@ -956,44 +1063,33 @@ async function fileUpload(args) {
|
|
|
956
1063
|
clearTimeout(timer);
|
|
957
1064
|
}
|
|
958
1065
|
}
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
const BG_BUF_CAP = 200_000; // per-job ring: keep the last ~200KB so a chatty job can't grow memory without bound
|
|
964
|
-
// Drop the oldest finished jobs once we exceed the retention budget — keeps `bgJobs` from growing across a
|
|
965
|
-
// long session. Running jobs are never pruned; insertion order (Map) makes "oldest finished" cheap.
|
|
966
|
-
function pruneBgJobs() {
|
|
967
|
-
const finished = [...bgJobs.entries()].filter(([, j]) => j.done);
|
|
968
|
-
for (let i = 0; i < finished.length - BG_KEEP_FINISHED; i++)
|
|
969
|
-
bgJobs.delete(finished[i][0]);
|
|
970
|
-
}
|
|
1066
|
+
// --- Background / detached shell (checklist gap: shell_exec is synchronous with a timeout only). For a
|
|
1067
|
+
// long-running command, shell_background spawns it detached, buffers output, and returns a job id to poll
|
|
1068
|
+
// with bash_output or stop with bash_kill (the BashOutput/KillShell analog). Runs under the same OS
|
|
1069
|
+
// sandbox wrap as shell_exec. child_process loads lazily (neutral bundle).
|
|
971
1070
|
async function shellBackground(args) {
|
|
972
1071
|
const command = str(args.command);
|
|
973
1072
|
if (!command)
|
|
974
1073
|
return "error: no command given";
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
if (running >= BG_MAX_RUNNING)
|
|
1074
|
+
pruneShellJobs();
|
|
1075
|
+
if (runningJobCount() >= BG_MAX_RUNNING)
|
|
978
1076
|
return `error: ${BG_MAX_RUNNING} background jobs already running — bash_kill one before starting another`;
|
|
979
1077
|
const cwd = args.cwd ? expandPath(str(args.cwd)) : undefined;
|
|
980
1078
|
const { spawn } = await nodeImport("node:child_process");
|
|
981
1079
|
const { file, args: argv } = await wrapShell(command); // same OS sandbox wrap as shell_exec
|
|
982
|
-
const id =
|
|
1080
|
+
const id = newJobId();
|
|
983
1081
|
// Its own process group, so the WHOLE job tree (`npm run dev` → node → …) can be stopped, not just the top shell. It used to be
|
|
984
1082
|
// "not detached: the job dies with Operator" — it did not: a running job outlived /exit, held the event loop open (Operator froze
|
|
985
1083
|
// after /exit) and was orphaned. Owned now: killed at exit, reaped by the next Operator if this one crashes.
|
|
986
1084
|
const p = spawn(file, argv, { cwd, detached: true });
|
|
987
1085
|
ownChild(p, `background job ${id}`, { cmd: `${file} ${argv.join(" ")}`, group: true });
|
|
988
|
-
const job =
|
|
989
|
-
const cap = (d) =>
|
|
990
|
-
job.buf = job.buf.slice(-BG_BUF_CAP); };
|
|
1086
|
+
const job = createJob(id, command, p, "background");
|
|
1087
|
+
const cap = (d) => trackJobOutput(job, d.toString("utf8"));
|
|
991
1088
|
p.stdout?.on("data", cap);
|
|
992
1089
|
p.stderr?.on("data", cap);
|
|
993
|
-
p.on("close", (c) =>
|
|
994
|
-
p.on("error", (e) => { job
|
|
995
|
-
|
|
996
|
-
return `started background job ${id}: ${command}\nPoll it with bash_output {"id":"${id}"}; stop it with bash_kill {"id":"${id}"}.`;
|
|
1090
|
+
p.on("close", (c) => finishJob(job, c));
|
|
1091
|
+
p.on("error", (e) => { trackJobOutput(job, `\n[spawn error: ${e.message}]`); finishJob(job, -1); });
|
|
1092
|
+
return `started background job ${id}: ${command}\nYou will be notified when it finishes, so do not poll. Read output with bash_output {"id":"${id}"}; stop it with bash_kill {"id":"${id}"}.`;
|
|
997
1093
|
}
|
|
998
1094
|
// A spawn_agent sub-agent id ("agent-1", "agent-2", …) is a DIFFERENT registry than shell_background's
|
|
999
1095
|
// own job ids ("sh1", "sh2", …) — bash_output/bash_kill only ever know the latter. A model that spawned a
|
|
@@ -1014,7 +1110,7 @@ async function bashOutput(args) {
|
|
|
1014
1110
|
const redirect = subAgentRedirect(id);
|
|
1015
1111
|
if (redirect)
|
|
1016
1112
|
return redirect;
|
|
1017
|
-
const job =
|
|
1113
|
+
const job = shellJobs.get(id);
|
|
1018
1114
|
if (!job)
|
|
1019
1115
|
return `error: no background job "${id}" (list ids from shell_background's return)`;
|
|
1020
1116
|
const out = job.buf;
|
|
@@ -1027,28 +1123,7 @@ async function bashKill(args) {
|
|
|
1027
1123
|
const redirect = subAgentRedirect(id);
|
|
1028
1124
|
if (redirect)
|
|
1029
1125
|
return redirect;
|
|
1030
|
-
|
|
1031
|
-
if (!job)
|
|
1032
|
-
return `error: no background job "${id}"`;
|
|
1033
|
-
if (job.done)
|
|
1034
|
-
return `job ${id} already finished (exit ${job.code})`;
|
|
1035
|
-
try {
|
|
1036
|
-
const pid = job.proc.pid;
|
|
1037
|
-
if (pid) {
|
|
1038
|
-
try {
|
|
1039
|
-
process.kill(-pid, "SIGTERM");
|
|
1040
|
-
}
|
|
1041
|
-
catch {
|
|
1042
|
-
job.proc.kill("SIGTERM");
|
|
1043
|
-
}
|
|
1044
|
-
} // the whole job group, falling back to the top process
|
|
1045
|
-
else
|
|
1046
|
-
job.proc.kill("SIGTERM");
|
|
1047
|
-
return `sent SIGTERM to background job ${id}`;
|
|
1048
|
-
}
|
|
1049
|
-
catch (e) {
|
|
1050
|
-
return `error killing ${id}: ${e?.message ?? e}`;
|
|
1051
|
-
}
|
|
1126
|
+
return stopShellJob(id);
|
|
1052
1127
|
}
|
|
1053
1128
|
const agentTasks = [];
|
|
1054
1129
|
let taskSeq = 0;
|
|
@@ -1371,22 +1446,30 @@ const VISION_COOLDOWN_MS = Math.max(10_000, Number(process.env.KODE_VISION_COOLD
|
|
|
1371
1446
|
const visionUnhealthy = new Map(); // base url -> epoch ms it may be retried after
|
|
1372
1447
|
/** Vision endpoints in priority order: KODE_VISION_URL, the fleet Qwen2-VL worker (JL1), then an optional
|
|
1373
1448
|
* cloud fallback. Each carries its own auth + model; local targets get a /health gate, cloud targets don't. */
|
|
1374
|
-
function visionTargets() {
|
|
1449
|
+
function visionTargets(settings) {
|
|
1375
1450
|
const seen = new Set();
|
|
1376
1451
|
const out = [];
|
|
1377
1452
|
const add = (u, auth, model, label) => {
|
|
1378
1453
|
if (!u)
|
|
1379
1454
|
return;
|
|
1380
|
-
const url = u.replace(/\/$/, "");
|
|
1381
|
-
if (seen.has(url))
|
|
1455
|
+
const url = u.trim().replace(/\/$/, "");
|
|
1456
|
+
if (!url || seen.has(url))
|
|
1382
1457
|
return;
|
|
1383
1458
|
seen.add(url);
|
|
1384
1459
|
const local = /\/\/(127\.0\.0\.1|localhost|192\.168\.|10\.|\[?::1)/.test(url) || /\.local(:|\/|$)/.test(url);
|
|
1385
1460
|
out.push({ url, auth, model, local, label });
|
|
1386
1461
|
};
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1462
|
+
// Priority order, every source explicit — no baked endpoints. A loopback target gets a /health gate + the
|
|
1463
|
+
// point-of-need auto-on; a remote one is tried as-is. settings carries the real URLs (services.vision.*),
|
|
1464
|
+
// so a different box/deploy is one config edit, not a code change. The local worker is tried BEFORE the
|
|
1465
|
+
// remote fleet node: it's on THIS box (zero LAN cost, revivable), and omitting it was the bug that sent
|
|
1466
|
+
// image_analyze straight to a possibly-down remote node with no local fallback.
|
|
1467
|
+
const v = settings.services?.vision;
|
|
1468
|
+
add(process.env.KODE_VISION_URL, mediaAuth(), undefined, "env-override"); // explicit hard override
|
|
1469
|
+
add(v?.url, mediaAuth(), undefined, "local"); // this box's managed worker (loopback → auto-on)
|
|
1470
|
+
add(v?.remoteUrl, mediaAuth(), undefined, "remote"); // LAN fallback (another fleet node)
|
|
1471
|
+
add(process.env.KODE_VISION_FALLBACK_URL, // cloud fallback (never health-gated)
|
|
1472
|
+
process.env.KODE_VISION_FALLBACK_KEY ? { Authorization: `Bearer ${process.env.KODE_VISION_FALLBACK_KEY}` } : {}, process.env.KODE_VISION_FALLBACK_MODEL || undefined, "cloud-fallback");
|
|
1390
1473
|
return out;
|
|
1391
1474
|
}
|
|
1392
1475
|
/** Read a local image, downscaling its long edge to VISION_MAX_EDGE first (macOS `sips`, then `ffmpeg`, then
|
|
@@ -1480,7 +1563,8 @@ async function visionImageDataUrl(image) {
|
|
|
1480
1563
|
* each independently, retry once on an empty body, and on timeout / 402 / 429 / auth-error mark the target
|
|
1481
1564
|
* unhealthy for a TTL and fall through to the next. Throws with the last error only when all are exhausted. */
|
|
1482
1565
|
async function visionComplete(parts, args, defaultTimeoutMs) {
|
|
1483
|
-
const
|
|
1566
|
+
const { loadSettings } = await nodeImport("../config/settings.js"); // variable-specifier load keeps settings out of the browser graph
|
|
1567
|
+
const targets = visionTargets(loadSettings());
|
|
1484
1568
|
const timeout = Math.max(5_000, Number(args.timeout_ms ?? defaultTimeoutMs));
|
|
1485
1569
|
const now = () => Date.now();
|
|
1486
1570
|
let lastErr = `no vision service reachable (tried ${targets.map((t) => t.url).join(", ")})`;
|
|
@@ -1490,9 +1574,17 @@ async function visionComplete(parts, args, defaultTimeoutMs) {
|
|
|
1490
1574
|
continue;
|
|
1491
1575
|
}
|
|
1492
1576
|
if (t.local && !(await imageHealthy(t.url))) {
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1577
|
+
// Media pipeline is off BY DEFAULT (ADR 2026-10-19 — GPU stays with Aurora), so a dead LOCAL vision
|
|
1578
|
+
// worker is the EXPECTED state, not an outage: bring it up at point of need (single-flight; repairs a
|
|
1579
|
+
// launchd-disabled job too) and re-probe before condemning the target. Loopback only — a remote LAN
|
|
1580
|
+
// worker (JL1) isn't served by this box's launchd job.
|
|
1581
|
+
const loopback = /\/\/(127\.0\.0\.1|localhost|\[?::1)/.test(t.url);
|
|
1582
|
+
const revived = loopback && await import("../services/preflight.js").then((m) => m.ensureVisionUp(t.url)).catch(() => false);
|
|
1583
|
+
if (!(revived && await imageHealthy(t.url))) {
|
|
1584
|
+
visionUnhealthy.set(t.url, now() + VISION_COOLDOWN_MS);
|
|
1585
|
+
lastErr = `${t.label} health check failed at ${t.url}`;
|
|
1586
|
+
continue;
|
|
1587
|
+
}
|
|
1496
1588
|
}
|
|
1497
1589
|
const model = str(args.model) || t.model || "mlx-community/Qwen2-VL-7B-Instruct-4bit";
|
|
1498
1590
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
@@ -1871,15 +1963,18 @@ const TOOLS = [
|
|
|
1871
1963
|
"in one call is still in effect on the next. So set things up ONCE and reuse them — do NOT " +
|
|
1872
1964
|
"re-run `source .../activate && ...` or re-`cd` on every call; activate/enter once, then just " +
|
|
1873
1965
|
"run the command. stdout and stderr come back merged (like a terminal) with the exit code. " +
|
|
1874
|
-
"Optional `cwd` runs that one command in a subshell without moving the session. For
|
|
1875
|
-
"
|
|
1966
|
+
"Optional `cwd` runs that one command in a subshell without moving the session. For anything " +
|
|
1967
|
+
"that can run more than ~2 minutes -- a server/build/watcher, but ALSO a full test suite or any " +
|
|
1968
|
+
"other verification run -- use shell_background instead of guessing a bigger timeout_ms; a timeout " +
|
|
1969
|
+
"here kills the command AND resets this shell's cwd/env, losing more than just that one call. " +
|
|
1970
|
+
"If the user presses ctrl+b while this runs, it moves to the background (shN) and you are told when it finishes; do not poll. " +
|
|
1876
1971
|
"Pipelines run with `set -o pipefail`: if ANY stage fails the pipeline fails and you see [exit N] — a check hidden behind `| tail` can never fake success. " +
|
|
1877
1972
|
"Prefer SINGLE quotes for patterns and paths (grep -l '^x', not grep -l \"^x\"): a raw double-quote " +
|
|
1878
1973
|
"inside the command can break tool-call serialization on the local model and make the call fail.",
|
|
1879
1974
|
parameters: { type: "object", properties: {
|
|
1880
1975
|
command: { type: "string", description: "the bash command to run in the persistent shell" },
|
|
1881
1976
|
cwd: { type: "string", description: "optional: run this one command from here (scoped; does not move the session)" },
|
|
1882
|
-
timeout_ms: { type: "number", description: "optional per-command timeout (default 120000); on timeout the shell is reset" },
|
|
1977
|
+
timeout_ms: { type: "number", description: "optional per-command timeout (default 120000); on timeout the shell is reset (cwd/env cleared) -- for a command that may legitimately run long (a full test suite, a build), use shell_background instead of raising this" },
|
|
1883
1978
|
}, required: ["command"] },
|
|
1884
1979
|
run: shellExec,
|
|
1885
1980
|
},
|
|
@@ -1894,19 +1989,19 @@ const TOOLS = [
|
|
|
1894
1989
|
},
|
|
1895
1990
|
{
|
|
1896
1991
|
name: "shell_background", safe: false,
|
|
1897
|
-
description: "Start a long-running shell command DETACHED and return a job id immediately (does not block).
|
|
1992
|
+
description: "Start a long-running shell command DETACHED and return a job id immediately (does not block). Use it from the start for servers, builds, watchers, and for a full test suite or any verification run expected to take more than ~2 minutes -- bash's foreground timeout would otherwise kill it AND reset the shell's cwd/env. You are notified when it finishes, so do not poll in a loop; read output with bash_output, stop it with bash_kill.",
|
|
1898
1993
|
parameters: { type: "object", properties: { command: { type: "string" }, cwd: { type: "string" } }, required: ["command"] },
|
|
1899
1994
|
run: shellBackground,
|
|
1900
1995
|
},
|
|
1901
1996
|
{
|
|
1902
1997
|
name: "bash_output", safe: true,
|
|
1903
|
-
description: "Read new stdout/stderr from a background job
|
|
1998
|
+
description: "Read new stdout/stderr from a background shell job (shell_background, or a command moved to the background with ctrl+b; drains what's arrived since the last read) and whether it's still running. A finished job is announced to you, so do not poll. NOT for a spawn_agent sub-agent id — use agent_status for those instead.",
|
|
1904
1999
|
parameters: { type: "object", properties: { id: { type: "string", description: "the job id from shell_background" } }, required: ["id"] },
|
|
1905
2000
|
run: bashOutput,
|
|
1906
2001
|
},
|
|
1907
2002
|
{
|
|
1908
2003
|
name: "bash_kill", safe: false,
|
|
1909
|
-
description: "Stop a running background job (SIGTERM)
|
|
2004
|
+
description: "Stop a running background shell job (SIGTERM): one from shell_background or one moved to the background with ctrl+b.",
|
|
1910
2005
|
parameters: { type: "object", properties: { id: { type: "string" } }, required: ["id"] },
|
|
1911
2006
|
run: bashKill,
|
|
1912
2007
|
},
|
|
@@ -2013,6 +2108,27 @@ const TOOLS = [
|
|
|
2013
2108
|
}, required: ["pattern"] },
|
|
2014
2109
|
run: ripgrepSearch,
|
|
2015
2110
|
},
|
|
2111
|
+
{
|
|
2112
|
+
name: "find_files", safe: true,
|
|
2113
|
+
description: "Find files anywhere on the machine by NAME or METADATA (kind, date, size, extension, author, Finder tags) — reads the OS search index (Spotlight / Windows Search / locate), so it is instant and covers the whole home directory by default. Use this for \"where is the file\" questions; use `search` for exact content/regex within a scoped directory. Results are absolute paths, newest first. Pass `path` to scope. `content: true` also matches the index's full-text content. `where` appends a raw backend predicate for power use — Spotlight: `kMDItemPixelHeight > 2000`; Windows Search SQL: `System.ItemType = '.docx'`. If the index is unavailable the tool falls back to scanning ONE directory (`path`, else the current dir) and says so on its first line. `details: true` returns `<path>\\t<size>\\t<modified ISO>\\t<kind>` per hit.",
|
|
2114
|
+
parameters: { type: "object", properties: {
|
|
2115
|
+
query: { type: "string", description: "words or a filename fragment (matches names; with content:true also full-text content)" },
|
|
2116
|
+
name: { type: "string", description: "filename fragment matched on the file name only" },
|
|
2117
|
+
path: { type: "string", description: "scope directory; default: the whole home dir (index) or the current dir (fallback)" },
|
|
2118
|
+
kind: { type: "string", enum: [...KINDS], description: "file kind filter" },
|
|
2119
|
+
modified_within: { type: "string", description: "only files changed within this window, e.g. 30m, 24h, 7d" },
|
|
2120
|
+
limit: { type: "number", description: `max results (default ${FIND_FILES_DEFAULT_LIMIT}, max ${FIND_FILES_MAX_LIMIT})` },
|
|
2121
|
+
content: { type: "boolean", description: "match the index's full-text content too, not only names" },
|
|
2122
|
+
min_size: { type: "string", description: "minimum size, e.g. 500KB, 10MB" },
|
|
2123
|
+
max_size: { type: "string", description: "maximum size, e.g. 1.5GB" },
|
|
2124
|
+
author: { type: "string", description: "document author (index metadata; ignored by the fallback)" },
|
|
2125
|
+
tags: { type: "array", items: { type: "string" }, description: "Finder tags / keywords (index metadata; ignored by the fallback)" },
|
|
2126
|
+
extension: { type: "string", description: "file extension, e.g. pdf" },
|
|
2127
|
+
where: { type: "string", description: "raw backend predicate appended verbatim (Spotlight query syntax or Windows Search SQL WHERE fragment); refused by the fallback" },
|
|
2128
|
+
details: { type: "boolean", description: "one line per hit: path, size, modified ISO, kind" },
|
|
2129
|
+
}, required: ["query"] },
|
|
2130
|
+
run: findFiles,
|
|
2131
|
+
},
|
|
2016
2132
|
{
|
|
2017
2133
|
name: "list_directory", safe: true,
|
|
2018
2134
|
description: "List entries in a directory.",
|
|
@@ -2044,7 +2160,7 @@ const TOOLS = [
|
|
|
2044
2160
|
},
|
|
2045
2161
|
{
|
|
2046
2162
|
name: "memory_search", safe: true,
|
|
2047
|
-
description: "Search stored memory notes by substring/tag match, most recent first.",
|
|
2163
|
+
description: "Search stored memory notes by substring/tag match, most recent first. Each result's leading [id] is what you pass to memory_store's `supersedes` to retract/correct it.",
|
|
2048
2164
|
parameters: { type: "object", properties: {
|
|
2049
2165
|
query: { type: "string" }, limit: { type: "number" },
|
|
2050
2166
|
} },
|
|
@@ -2052,9 +2168,10 @@ const TOOLS = [
|
|
|
2052
2168
|
},
|
|
2053
2169
|
{
|
|
2054
2170
|
name: "memory_store", safe: false,
|
|
2055
|
-
description: "Store a durable memory note with optional tags.",
|
|
2171
|
+
description: "Store a durable memory note with optional tags. If a stored note turns out to be wrong or outdated, don't just add a corrected note beside it -- pass `supersedes` (the [id] from memory_search) so the old one stops surfacing in future recall. Nothing is deleted (the old note stays on disk for history), it's just excluded going forward.",
|
|
2056
2172
|
parameters: { type: "object", properties: {
|
|
2057
2173
|
text: { type: "string" }, tags: { type: "array", items: { type: "string" } },
|
|
2174
|
+
supersedes: { type: "string", description: "id (from memory_search's [id]) of an earlier note this one corrects or retracts" },
|
|
2058
2175
|
}, required: ["text"] },
|
|
2059
2176
|
run: memoryStore,
|
|
2060
2177
|
},
|
|
@@ -2107,6 +2224,16 @@ const TOOLS = [
|
|
|
2107
2224
|
}, required: ["query"] },
|
|
2108
2225
|
run: webSearch,
|
|
2109
2226
|
},
|
|
2227
|
+
{
|
|
2228
|
+
name: "knowledge_search", safe: true,
|
|
2229
|
+
description: "Search the local Skylark knowledge base (vector KB) for semantic retrieval. Returns top hits with source, distance, and snippet. Use for retrieving past work, project context, and stored facts.",
|
|
2230
|
+
parameters: { type: "object", properties: {
|
|
2231
|
+
query: { type: "string", description: "the search query" },
|
|
2232
|
+
n: { type: "number", description: "max results (1-20, default 5)" },
|
|
2233
|
+
timeout_ms: { type: "number", description: "optional timeout in ms (default 15000)" },
|
|
2234
|
+
}, required: ["query"] },
|
|
2235
|
+
run: knowledgeSearch,
|
|
2236
|
+
},
|
|
2110
2237
|
{
|
|
2111
2238
|
name: "deep_research", safe: true,
|
|
2112
2239
|
description: "Deep, multi-source web research on a question → a cited brief. Haiku 4.5 plans several search angles, Operator fans out web_search + web_fetch across them, then Haiku synthesizes a thorough answer with inline source citations. Read-only. Use when one search isn't enough — comparisons, state-of-the-art surveys, sourced background. Requires a research API key to be configured.",
|
|
@@ -2227,7 +2354,7 @@ const TOOLS = [
|
|
|
2227
2354
|
},
|
|
2228
2355
|
{
|
|
2229
2356
|
name: "artifact_create",
|
|
2230
|
-
description: "Make a shareable ARTIFACT — an HTML page / dashboard / landing page, an SVG, a markdown doc, a DECK / PRESENTATION, or an interactive canvas — hosted on compose.casa, returning a public clickable URL. This is THE way to create an artifact / design / page / deck for the owner: NEVER write a local file or hunt for a 'compose' folder. Pass the full content; use content_type 'canvas' for interactive HTML/JS (animations, visualizations, presentations).",
|
|
2357
|
+
description: "Make a shareable ARTIFACT — an HTML page / dashboard / landing page, an SVG, a markdown doc, a DECK / PRESENTATION, or an interactive canvas — hosted on compose.casa, returning a public clickable URL. This is THE way to create an artifact / design / page / deck for the owner: NEVER write a local file or hunt for a 'compose' folder, AS LONG AS compose.casa IS REACHABLE. If this call errors (compose.casa down/502), that rule no longer applies to this request — write the content as a plain local file with file_create instead (a .md file for markdown/text content, matching what was asked for) rather than reaching for document_generate's PDF path just because it also produces a file; PDF is for when a PDF specifically was wanted, not a substitute hosted-artifact fallback. Pass the full content; use content_type 'canvas' for interactive HTML/JS (animations, visualizations, presentations).",
|
|
2231
2358
|
parameters: { type: "object", properties: {
|
|
2232
2359
|
content: { type: "string", description: "the full artifact content — a complete HTML document, SVG, or markdown" },
|
|
2233
2360
|
title: { type: "string", description: "a short title for the artifact" },
|
|
@@ -2287,24 +2414,34 @@ const TOOLS = [
|
|
|
2287
2414
|
},
|
|
2288
2415
|
{
|
|
2289
2416
|
name: "session_search", safe: true,
|
|
2290
|
-
description: "Search past
|
|
2417
|
+
description: "Search past agent sessions on this machine — Operator's own and other agents' (providers configured in agents.md) — by what was said in them (every term must appear in one message), newest first. Each hit: title · agent · messages · age · model · folder, the matching line with who said it, and an id for session_read. An empty query lists the newest sessions. scope: workspace (this folder), project (this git repo), all (default).",
|
|
2291
2418
|
parameters: { type: "object", properties: {
|
|
2292
|
-
query: { type: "string", description: "search terms (all must appear)" },
|
|
2419
|
+
query: { type: "string", description: "search terms (all must appear); empty lists the newest sessions" },
|
|
2420
|
+
scope: { type: "string", enum: SESSION_SCOPES, description: "workspace · project · all (default all)" },
|
|
2421
|
+
source: { type: "string", description: "only this agent's sessions: \"operator\" or a provider slug from agents.md (its name, lowercased, dashes for spaces)" },
|
|
2293
2422
|
limit: { type: "number", description: "max results (default 8)" },
|
|
2294
2423
|
}, required: ["query"] },
|
|
2295
2424
|
run: async (a) => {
|
|
2296
2425
|
await indexSessions();
|
|
2297
|
-
const
|
|
2298
|
-
|
|
2426
|
+
const limit = a.limit === undefined ? 8 : Number(a.limit);
|
|
2427
|
+
const cfg = await sessionSearchConfig();
|
|
2428
|
+
if (!cfg.enabled) { // off: Operator's own transcripts only, the pre-catalog behavior
|
|
2429
|
+
const hits = await searchSessions(str(a.query), limit);
|
|
2430
|
+
return hits.length ? hits.map((h) => `${h.id} — ${h.snippet}`).join("\n") : "no matches";
|
|
2431
|
+
}
|
|
2432
|
+
await indexCatalog(cfg.providers);
|
|
2433
|
+
const scope = SESSION_SCOPES.includes(str(a.scope)) ? str(a.scope) : "all";
|
|
2434
|
+
const source = str(a.source) || undefined;
|
|
2435
|
+
return formatHits(await searchCatalog(str(a.query), { scope, source, limit }));
|
|
2299
2436
|
},
|
|
2300
2437
|
},
|
|
2301
2438
|
{
|
|
2302
2439
|
name: "session_read", safe: true,
|
|
2303
|
-
description: "Read one past session
|
|
2440
|
+
description: "Read one past session by id (as returned by session_search) — Operator's own or another agent's. Returns readable text capped at 24k chars.",
|
|
2304
2441
|
parameters: { type: "object", properties: {
|
|
2305
2442
|
id: { type: "string", description: "the session id" },
|
|
2306
2443
|
}, required: ["id"] },
|
|
2307
|
-
run: async (a) => (await readSession(str(a.id))) ?? `error: no session '${str(a.id)}' found
|
|
2444
|
+
run: async (a) => (await readSession(str(a.id))) ?? (await readCatalogSession(str(a.id))) ?? `error: no session '${str(a.id)}' found (ids come from session_search)`,
|
|
2308
2445
|
},
|
|
2309
2446
|
{
|
|
2310
2447
|
name: "session_rewind", safe: false,
|
|
@@ -2329,13 +2466,23 @@ const TOOLS = [
|
|
|
2329
2466
|
},
|
|
2330
2467
|
{
|
|
2331
2468
|
name: "delegate_task", safe: false,
|
|
2332
|
-
description:
|
|
2469
|
+
description: `Hand ONE self-contained subtask to a sub-agent running on a chosen model and get its final answer back (blocks until it finishes). The sub-agent is a full headless Operator session with its own tools, but NO memory of this conversation and it cannot ask you questions — so \`task\` must carry everything it needs (paths, constraints, the exact output you want). \`model\` is any /model id. CHOOSE IT BY TOOL-LOAD: use "scout" (fast 4B) ONLY for self-contained, tool-LIGHT subtasks (a lookup, a summary, a single-file edit); a 4B model drives tools unreliably, so anything TOOL-HEAVY — reviewing a remote/GitHub repo, multi-file exploration, web research, debugging, a repo audit — MUST go to "cortana" (the flagship) or it will spin without real progress. Other fleet models: venice-24b, qwen3.8-flash, operator-1m. YOU CAN ALSO DELEGATE TO ANY CLOUD PROVIDER THE OWNER HAS CONNECTED (a stored vendor key): Claude via "claude-sonnet" (full tool-using), and any BYO provider — ${BYO_DELEGATE_PROVIDERS} — registered with "operator auth byo-model" (e.g. an OpenAI/Gemini/Groq/DeepSeek model id). A provider with NO stored key is refused with the exact command to store it, so a failed delegation is never silent — pick "cortana" if you're unsure a cloud key is connected. Use delegation to farm out an independent chunk while you keep planning; do not delegate what you can do in one tool call. Sub-agents cannot delegate further. The sub-agent runs with the owner's permission policy and can mutate the workspace.`,
|
|
2333
2470
|
parameters: { type: "object", properties: {
|
|
2334
2471
|
task: { type: "string", description: "the complete, self-contained subtask — the sub-agent sees only this" },
|
|
2335
2472
|
model: { type: "string", description: "registry model id to run it on (default \"scout\")" },
|
|
2336
2473
|
}, required: ["task"] },
|
|
2337
2474
|
run: (a) => runDelegateTask(a),
|
|
2338
2475
|
},
|
|
2476
|
+
{
|
|
2477
|
+
name: "delegate_to_agent", safe: false,
|
|
2478
|
+
description: agentCliToolDescription(),
|
|
2479
|
+
parameters: { type: "object", properties: {
|
|
2480
|
+
task: { type: "string", description: "the complete, self-contained task — the agent CLI sees only this and cannot ask you questions" },
|
|
2481
|
+
agent: { type: "string", description: "which local agent CLI to run it on (e.g. \"cursor-agent\", \"claude\", \"codex\") — only INSTALLED ones work" },
|
|
2482
|
+
model: { type: "string", description: "optional underlying model id for that CLI" },
|
|
2483
|
+
}, required: ["task", "agent"] },
|
|
2484
|
+
run: (a) => runDelegateToAgent(a),
|
|
2485
|
+
},
|
|
2339
2486
|
{
|
|
2340
2487
|
name: "browser", safe: false,
|
|
2341
2488
|
description: "Drive a REAL headless browser (Chrome over CDP) with session state that persists across calls — for JS-rendered pages, logins, forms, clicks. Text-first: prefer browser_read for content; use eval/click/fill/submit to act. actions: open(url) navigate(url) reload cache_bust? back forward click(selector settle_ms?) fill(selector,text) submit(selector) eval(js — awaits promises, returnByValue) screenshot() -> png path tab_select(index) tab_close(index?) close. Screenshot files land under the operator home's cache/browser/. Policy: http/https/about/data only (no file://, no chrome://). Login wall: NEVER guess credentials — ask the owner.",
|
|
@@ -2545,7 +2692,56 @@ async function skillSave(name, content) {
|
|
|
2545
2692
|
export async function localSkills() {
|
|
2546
2693
|
return listLocalSkills();
|
|
2547
2694
|
}
|
|
2548
|
-
export const registry = new Map(TOOLS.map(t => [t.name, t]));
|
|
2695
|
+
export const registry = new Map([...TOOLS, ...WAVE_TOOLS, ...WAVE2_TOOLS, ...INCIDENT_TOOLS, ...GIT_PR_TOOLS].map(t => [t.name, t]));
|
|
2696
|
+
// ── Cloud agents (feature-gated — NOT in the base registry) ───────────────────────
|
|
2697
|
+
// Sovereign "cloud/background agents": spawn an autonomous agent in an ISOLATED DOCKER CONTAINER on a configured
|
|
2698
|
+
// fleet host (autonomy/cloud-agent.ts). These are kept OUT of the static `registry`/`TOOLS` so they are absent by
|
|
2699
|
+
// default — the session wires them in ONLY when the `cloudAgents` feature flag is on (see cloudAgentToolsFor →
|
|
2700
|
+
// session.ts). All safe:false (they mutate a repo/branch and run arbitrary autonomous work on a remote host).
|
|
2701
|
+
const CLOUD_HOSTED_NOTE = "Runs in an ISOLATED DOCKER CONTAINER on a configured fleet host (settings.cloudAgents.hosts, over SSH or locally) — NOT in this process. It clones the repo, runs the chosen agent CLI headless + AUTONOMOUSLY on the task, commits to its own branch, pushes, and opens a PR. It runs in PARALLEL and is checkable anytime.";
|
|
2702
|
+
export const CLOUD_AGENT_TOOLS = [
|
|
2703
|
+
{
|
|
2704
|
+
name: "spawn_cloud_agent", safe: false,
|
|
2705
|
+
description: `Spawn an autonomous "cloud agent". ${CLOUD_HOSTED_NOTE} MUTATES a repo: it creates and pushes a new branch \`cloud/<id>\` and opens a PR against \`base_branch\`. Pick \`host\` from settings.cloudAgents.hosts (defaults to settings.cloudAgents.defaultHost) and \`agent\` from the agent-CLI registry (cursor-agent / claude / codex / operator). Secrets (git creds, agent API keys) are passed to the container at runtime from the environment — never baked in or logged. Returns a tracked id; follow it with cloud_agent_status / list_cloud_agents and stop it with stop_cloud_agent.`,
|
|
2706
|
+
parameters: { type: "object", properties: {
|
|
2707
|
+
task: { type: "string", description: "the complete, self-contained task the container's agent runs autonomously (it has no memory of this conversation)" },
|
|
2708
|
+
agent: { type: "string", description: "which agent CLI to run INSIDE the container (e.g. \"cursor-agent\", \"claude\", \"codex\")" },
|
|
2709
|
+
repo: { type: "string", description: "git URL (https or ssh) the container clones" },
|
|
2710
|
+
base_branch: { type: "string", description: "branch to base the work on (default \"main\")" },
|
|
2711
|
+
host: { type: "string", description: "cloud-agent host id from settings.cloudAgents.hosts (default: settings.cloudAgents.defaultHost)" },
|
|
2712
|
+
model: { type: "string", description: "optional underlying model id for the agent CLI" },
|
|
2713
|
+
}, required: ["task", "agent", "repo"] },
|
|
2714
|
+
run: (a) => runSpawnCloudAgent(a),
|
|
2715
|
+
},
|
|
2716
|
+
{
|
|
2717
|
+
name: "list_cloud_agents", safe: false,
|
|
2718
|
+
description: `List every tracked cloud agent (persisted under the operator home, so it survives restarts) with its id, status (provisioning/running/done/failed/stopped), host, container, branch and PR. ${CLOUD_HOSTED_NOTE}`,
|
|
2719
|
+
parameters: { type: "object", properties: {}, required: [] },
|
|
2720
|
+
run: (a) => runListCloudAgents(a),
|
|
2721
|
+
},
|
|
2722
|
+
{
|
|
2723
|
+
name: "cloud_agent_status", safe: false,
|
|
2724
|
+
description: `Check one cloud agent by id: docker-inspects its container on its host, tails the container log, and reports status + branch + PR. ${CLOUD_HOSTED_NOTE}`,
|
|
2725
|
+
parameters: { type: "object", properties: {
|
|
2726
|
+
id: { type: "string", description: "the cloud-agent id (from spawn_cloud_agent / list_cloud_agents)" },
|
|
2727
|
+
}, required: ["id"] },
|
|
2728
|
+
run: (a) => runCloudAgentStatus(a),
|
|
2729
|
+
},
|
|
2730
|
+
{
|
|
2731
|
+
name: "stop_cloud_agent", safe: false,
|
|
2732
|
+
description: `Stop and remove a cloud agent's container by id and mark it stopped. ${CLOUD_HOSTED_NOTE} Use when a run is wrong or no longer needed; already-pushed commits/PR are NOT deleted.`,
|
|
2733
|
+
parameters: { type: "object", properties: {
|
|
2734
|
+
id: { type: "string", description: "the cloud-agent id (from spawn_cloud_agent / list_cloud_agents)" },
|
|
2735
|
+
}, required: ["id"] },
|
|
2736
|
+
run: (a) => runStopCloudAgent(a),
|
|
2737
|
+
},
|
|
2738
|
+
];
|
|
2739
|
+
/** The cloud-agent tools when the `cloudAgents` feature flag is on, else []. The session merges these into its
|
|
2740
|
+
* per-session registry so both the executor (dispatch) and the model's schemas (toSchemas) include them iff the
|
|
2741
|
+
* flag resolves on — mirroring how spawn_agent is only advertised when it's runnable. Flag OFF ⇒ tools absent. */
|
|
2742
|
+
export function cloudAgentToolsFor(settings) {
|
|
2743
|
+
return isFeatureEnabled("cloudAgents", settings ?? undefined) ? CLOUD_AGENT_TOOLS : [];
|
|
2744
|
+
}
|
|
2549
2745
|
export function toSchemas(reg = registry) {
|
|
2550
2746
|
return [...reg.values()].map(t => ({
|
|
2551
2747
|
type: "function",
|