@0perator/operator 0.1.263 → 0.1.274
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/client.js +8 -0
- package/dist/autonomy/delegate.js +21 -2
- package/dist/autonomy/session-factory.js +4 -0
- package/dist/cli.js +221 -70
- package/dist/config/persona.js +41 -15
- package/dist/config/settings.js +47 -6
- package/dist/engine/agent.js +36 -7
- package/dist/engine/anthropic.js +48 -0
- package/dist/engine/batch-scheduler.js +68 -21
- package/dist/mcp/index.js +2 -1
- package/dist/permissions/index.js +11 -4
- package/dist/remote/host.js +46 -5
- package/dist/remote/pairing.js +70 -0
- package/dist/router/models.js +8 -1
- package/dist/services/model-autodetect.js +240 -0
- package/dist/services/preflight.js +46 -2
- package/dist/session.js +19 -2
- package/dist/tools/deferred.js +2 -1
- package/dist/tools/executor.js +15 -3
- package/dist/tools/native-redirect.js +140 -0
- package/dist/tools/power-tools.js +627 -0
- package/dist/tools/registry.js +375 -41
- package/dist/tools/searxng.js +8 -1
- package/dist/ui/App.js +5 -4
- package/dist/ui/BgPanel.js +13 -1
- package/dist/ui/Composer.js +28 -1
- package/dist/ui/ToolStep.js +1 -1
- package/dist/ui/format.js +18 -0
- package/dist/ui/liveTools.js +2 -5
- package/dist/ui/qr.js +10 -0
- package/dist/ui/resize.js +160 -0
- package/dist/ui/slashCommands.js +43 -0
- package/dist/ui/term.js +22 -0
- package/dist/util/slash.js +1 -1
- package/package.json +3 -1
package/dist/tools/registry.js
CHANGED
|
@@ -11,7 +11,9 @@ import { listLocalSkills, localSkillsDir as profileSkillsDir, resolveSkillFile }
|
|
|
11
11
|
import { operatorPath } from "../config/home.js";
|
|
12
12
|
import { pexecFile } from "./exec.js";
|
|
13
13
|
import { formatGitStatus } from "./git-status.js";
|
|
14
|
+
import { POWER_TOOLS, disabledPowerToolNames } from "./power-tools.js";
|
|
14
15
|
import { expandPath } from "./paths.js";
|
|
16
|
+
import { nativeToolRedirect } from "./native-redirect.js";
|
|
15
17
|
import { runMemoryTool } from "./memory.js";
|
|
16
18
|
import { runCronTool } from "../autonomy/cron.js";
|
|
17
19
|
import { runDelegateTask } from "../autonomy/delegate.js";
|
|
@@ -63,10 +65,17 @@ export function disposeShellSessionKey(key) {
|
|
|
63
65
|
_shells.delete(key);
|
|
64
66
|
}
|
|
65
67
|
}
|
|
68
|
+
// Redirect-once memory for nativeToolRedirect (tools/native-redirect.ts): the commands it already pointed at a
|
|
69
|
+
// native tool, so the identical re-issue (a legitimate non-media install) is let through. Shared by shell_exec
|
|
70
|
+
// and shell_background — one attempt ledger, whichever door the model uses.
|
|
71
|
+
const nativeRedirectSeen = new Set();
|
|
66
72
|
async function shellExec(args) {
|
|
67
73
|
const command = str(args.command);
|
|
68
74
|
if (!command)
|
|
69
75
|
return "error: no command given";
|
|
76
|
+
const redirect = nativeToolRedirect(command, nativeRedirectSeen);
|
|
77
|
+
if (redirect)
|
|
78
|
+
return redirect; // "you already have image_generate" — a tool RESULT, never run, never a 2nd system message
|
|
70
79
|
const timeout = Number(args.timeout_ms ?? 120_000);
|
|
71
80
|
// A `cwd` arg is scoped to this one call (subshell) so it doesn't silently move the persistent
|
|
72
81
|
// session's directory; an explicit `cd` INSIDE the command persists, exactly like a terminal.
|
|
@@ -713,6 +722,117 @@ function authHeaders(args) {
|
|
|
713
722
|
}
|
|
714
723
|
return h;
|
|
715
724
|
}
|
|
725
|
+
// deep_research: Haiku 4.5 plans a few search angles, Operator fans out web_search + web_fetch across them,
|
|
726
|
+
// then Haiku synthesizes a cited brief. The one tool that calls a cloud model DIRECTLY (src/engine/anthropic),
|
|
727
|
+
// so it needs KODE_ANTHROPIC_KEY / ANTHROPIC_API_KEY; without it the tool returns a clear error, never hangs.
|
|
728
|
+
async function deepResearch(args) {
|
|
729
|
+
const question = str(args.question ?? args.query);
|
|
730
|
+
if (!question)
|
|
731
|
+
return "error: deep_research needs a question";
|
|
732
|
+
const { anthropicComplete, anthropicKey } = await import("../engine/anthropic.js");
|
|
733
|
+
if (!anthropicKey())
|
|
734
|
+
return "error: deep_research is not configured — no research API key available"; // key env vars in AGENTS.md
|
|
735
|
+
const maxAngles = Math.min(Math.max(Number(args.angles ?? 4), 1), 6);
|
|
736
|
+
const maxSources = Math.min(Math.max(Number(args.max_sources ?? 6), 1), 12);
|
|
737
|
+
const deadline = Date.now() + Number(args.timeout_ms ?? 240_000);
|
|
738
|
+
// 1. Haiku decomposes the question into focused, non-overlapping search angles.
|
|
739
|
+
let angles = [question];
|
|
740
|
+
try {
|
|
741
|
+
const plan = await anthropicComplete("You are a research planner. Given a question, reply with ONLY a JSON array of 3-5 focused, non-overlapping web-search queries that together answer it. No prose, no code fence.", question, { maxTokens: 400, timeoutMs: 60_000 });
|
|
742
|
+
const parsed = JSON.parse(plan.replace(/```(?:json)?/g, "").trim());
|
|
743
|
+
if (Array.isArray(parsed)) {
|
|
744
|
+
const a = parsed.filter((x) => typeof x === "string" && x.trim()).slice(0, maxAngles);
|
|
745
|
+
if (a.length)
|
|
746
|
+
angles = a;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
catch { /* fall back to the raw question as the single angle */ }
|
|
750
|
+
// 2. Fan out web_search on each angle; collect unique source URLs from the formatted results.
|
|
751
|
+
const urls = [];
|
|
752
|
+
const seen = new Set();
|
|
753
|
+
const searchBlocks = [];
|
|
754
|
+
for (const a of angles) {
|
|
755
|
+
if (Date.now() > deadline)
|
|
756
|
+
break;
|
|
757
|
+
const out = await webSearch({ query: a, count: 5 }).catch((e) => `(search failed: ${String(e?.message ?? e)})`);
|
|
758
|
+
searchBlocks.push(`### ${a}\n${out}`);
|
|
759
|
+
for (const m of out.matchAll(/https?:\/\/[^\s)\]]+/g)) {
|
|
760
|
+
const u = m[0].replace(/[.,)\]]+$/, "");
|
|
761
|
+
if (!seen.has(u)) {
|
|
762
|
+
seen.add(u);
|
|
763
|
+
urls.push(u);
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
// 3. Fetch the top sources (read-only), capped so one research call can't fan out forever.
|
|
768
|
+
const fetched = [];
|
|
769
|
+
for (const u of urls.slice(0, maxSources)) {
|
|
770
|
+
if (Date.now() > deadline)
|
|
771
|
+
break;
|
|
772
|
+
const body = await webFetch({ url: u, timeout_ms: 25_000 }).catch(() => "");
|
|
773
|
+
if (body && body.length > 200)
|
|
774
|
+
fetched.push(`SOURCE: ${u}\n${body.slice(0, 6_000)}`);
|
|
775
|
+
}
|
|
776
|
+
// 4. Haiku synthesizes a cited brief from the searches + fetched sources.
|
|
777
|
+
const context = [
|
|
778
|
+
`QUESTION: ${question}`,
|
|
779
|
+
`\n## Search results\n${searchBlocks.join("\n\n")}`,
|
|
780
|
+
fetched.length ? `\n## Fetched sources\n${fetched.join("\n\n---\n\n")}` : "(no sources could be fetched; synthesize from the search snippets)",
|
|
781
|
+
].join("\n");
|
|
782
|
+
const report = await anthropicComplete("You are a rigorous research analyst. Using ONLY the supplied search results and sources, write a thorough, well-structured answer to the question. Cite every claim inline with its source URL in [brackets]. Call out disagreements and gaps. If the evidence is thin, say so — never invent facts or URLs. End with a short 'Sources' list of the URLs you actually used.", context, { maxTokens: 4096, timeoutMs: 120_000 });
|
|
783
|
+
return `${report}\n\n— deep_research · ${angles.length} angles · ${fetched.length}/${urls.length} sources read`;
|
|
784
|
+
}
|
|
785
|
+
// email_send: deliver an email through the AXE Quill SMTP engine (iCloud transport), so the owner can say
|
|
786
|
+
// "email me what you made" and Operator actually sends it. `to` defaults to the signed-in owner's address
|
|
787
|
+
// (email sign-in → external_id IS the email), so a bare "email me" resolves without asking. The Quill
|
|
788
|
+
// endpoint + bearer come from env (KODE_QUILL_URL / KODE_QUILL_KEY / KODE_QUILL_FROM) — NEVER hardcode the
|
|
789
|
+
// fleet email key in the repo; an unconfigured box returns a clear error instead of failing silently.
|
|
790
|
+
async function emailSend(args) {
|
|
791
|
+
const subject = str(args.subject).trim();
|
|
792
|
+
const body = str(args.body ?? args.text).trim();
|
|
793
|
+
if (!subject)
|
|
794
|
+
return "error: email_send needs a subject";
|
|
795
|
+
if (!body)
|
|
796
|
+
return "error: email_send needs a body";
|
|
797
|
+
let to = str(args.to).trim().toLowerCase();
|
|
798
|
+
if (!to) {
|
|
799
|
+
try {
|
|
800
|
+
const { loadCredentials } = await import("../auth/store.js");
|
|
801
|
+
const creds = await loadCredentials().catch(() => null);
|
|
802
|
+
to = (creds?.user ?? "").toLowerCase(); // email sign-in: external_id == the owner's email
|
|
803
|
+
}
|
|
804
|
+
catch { /* no creds module / not signed in */ }
|
|
805
|
+
}
|
|
806
|
+
if (!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(to)) {
|
|
807
|
+
return "error: no recipient — pass `to`, or sign in with your email so \"email me\" can reach you";
|
|
808
|
+
}
|
|
809
|
+
const key = process.env.KODE_QUILL_KEY;
|
|
810
|
+
if (!key)
|
|
811
|
+
return "error: email sending isn't configured on this machine (Quill key missing). Ask the fleet owner to set it.";
|
|
812
|
+
const url = process.env.KODE_QUILL_URL || "http://127.0.0.1:8025/send";
|
|
813
|
+
const from = process.env.KODE_QUILL_FROM || "axetechnology@icloud.com";
|
|
814
|
+
const html = args.html != null ? str(args.html) : undefined;
|
|
815
|
+
const ctrl = new AbortController();
|
|
816
|
+
const timer = setTimeout(() => ctrl.abort(), 25_000);
|
|
817
|
+
try {
|
|
818
|
+
const res = await fetch(url, {
|
|
819
|
+
method: "POST",
|
|
820
|
+
headers: { "content-type": "application/json", "Authorization": `Bearer ${key}` },
|
|
821
|
+
body: JSON.stringify({ to, subject, text: body, ...(html ? { html } : {}), from_addr: from }),
|
|
822
|
+
signal: ctrl.signal,
|
|
823
|
+
});
|
|
824
|
+
if (!res.ok)
|
|
825
|
+
return `error: email send failed (HTTP ${res.status}) ${(await res.text().catch(() => "")).slice(0, 160)}`;
|
|
826
|
+
const j = await res.json().catch(() => ({}));
|
|
827
|
+
return `email sent to ${to} — "${subject}"${j && typeof j === "object" && "id" in j ? ` (id ${str(j.id)})` : ""}`;
|
|
828
|
+
}
|
|
829
|
+
catch (e) {
|
|
830
|
+
return `error: email send failed — ${e instanceof Error ? e.message : String(e)}`;
|
|
831
|
+
}
|
|
832
|
+
finally {
|
|
833
|
+
clearTimeout(timer);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
716
836
|
const HTTP_BODY_CAP = 200_000; // cap a response body so one huge payload can't balloon the model's context
|
|
717
837
|
/** Public render fallback for web_fetch's 403/429 path: Jina Reader (r.jina.ai/<url> returns
|
|
718
838
|
* markdown; keyless 20 RPM, Bearer KODE_JINA_KEY for more; KODE_JINA_URL swaps to a self-hosted
|
|
@@ -853,6 +973,9 @@ async function shellBackground(args) {
|
|
|
853
973
|
const command = str(args.command);
|
|
854
974
|
if (!command)
|
|
855
975
|
return "error: no command given";
|
|
976
|
+
const redirect = nativeToolRedirect(command, nativeRedirectSeen);
|
|
977
|
+
if (redirect)
|
|
978
|
+
return redirect;
|
|
856
979
|
pruneBgJobs();
|
|
857
980
|
const running = [...bgJobs.values()].filter((j) => !j.done).length;
|
|
858
981
|
if (running >= BG_MAX_RUNNING)
|
|
@@ -942,7 +1065,9 @@ async function taskUpdate(args) {
|
|
|
942
1065
|
const status = str(args.status);
|
|
943
1066
|
const t = agentTasks.find((x) => x.id === id);
|
|
944
1067
|
if (!t)
|
|
945
|
-
return
|
|
1068
|
+
return agentTasks.length
|
|
1069
|
+
? `error: no task #${id}. task IDs are assigned by task_add (don't guess them) — current tasks:\n${renderTasks()}`
|
|
1070
|
+
: `error: no tasks exist yet — call task_add first to create them (it returns each task's id), then task_update by that id.`;
|
|
946
1071
|
if (status !== "pending" && status !== "in_progress" && status !== "done")
|
|
947
1072
|
return "error: status must be pending | in_progress | done";
|
|
948
1073
|
t.status = status;
|
|
@@ -1000,6 +1125,15 @@ function mediaAuth() {
|
|
|
1000
1125
|
const t = process.env.KODE_MEDIA_TOKEN;
|
|
1001
1126
|
return t ? { Authorization: `Bearer ${t}` } : {};
|
|
1002
1127
|
}
|
|
1128
|
+
/** Failure semantics for every media/vision/voice worker error: a worker that does not answer is an OUTAGE of a
|
|
1129
|
+
* shared fleet service, not a missing capability. Said in the tool result so the model retries/reports instead
|
|
1130
|
+
* of "working around" the tool by installing ComfyUI/diffusers/a CLI and pulling weights onto the serving box
|
|
1131
|
+
* (live aurora session 10-09: the old "Bring up the flux-worker" wording + the loop nudge's "work around it"
|
|
1132
|
+
* became a mandate to build a stack). `what` = "image"|"video"|"vision"|"voice"; `tool` = the tool to keep using. */
|
|
1133
|
+
function outage(what, tool) {
|
|
1134
|
+
return `${what} service is DOWN (outage): retry once; if still down, TELL THE OWNER. Do NOT install ComfyUI/diffusers/CLIs ` +
|
|
1135
|
+
`or download model weights to substitute — the capability already exists as \`${tool}\`.`;
|
|
1136
|
+
}
|
|
1003
1137
|
/** Is an image endpoint reachable + ready? Fast /health probe so we fail over off a dead endpoint BEFORE
|
|
1004
1138
|
* committing to a ~tens-of-seconds generation, instead of hanging the whole turn on it. */
|
|
1005
1139
|
async function imageHealthy(base) {
|
|
@@ -1075,16 +1209,20 @@ async function imageGenerate(args) {
|
|
|
1075
1209
|
const prompt = str(args.prompt);
|
|
1076
1210
|
if (!prompt)
|
|
1077
1211
|
return "error: image_generate needs a prompt";
|
|
1078
|
-
const size = /^\d+x\d+$/.test(str(args.size)) ? str(args.size) : "512x512";
|
|
1079
1212
|
const n = Math.max(1, Math.min(Number(args.n) || 1, 4));
|
|
1080
1213
|
const wantExpand = args.expand === true || str(args.expand) === "true"; // ask the broker to rewrite the prompt via Aurora (never blocks; used:false = ran on the original)
|
|
1081
1214
|
// Route reference-bearing requests to the IDENTITY broker (preserve a SPECIFIC face via IP-Adapter-FaceID);
|
|
1082
1215
|
// plain text-to-image stays on flux. Try identity first when a reference is given, fall back to flux if the
|
|
1083
1216
|
// identity node is asleep — a request never hard-fails just because one broker is down.
|
|
1217
|
+
// `quality:"photoreal"` ALSO goes to the identity broker, with NO reference: its worker runs plain RealVisXL
|
|
1218
|
+
// (SDXL) text-to-image when no face is given (identity_applied:false) — the photoreal text-only path, so a
|
|
1219
|
+
// model that wants photoreal calls this tool instead of building its own SDXL/ComfyUI stack. Fast flux-schnell
|
|
1220
|
+
// stays the default; photoreal that cannot reach the identity broker falls back to flux and SAYS so.
|
|
1084
1221
|
const wantIdentity = !!str(args.reference);
|
|
1222
|
+
const wantPhotoreal = /^photo-?real(?:istic)?$/i.test(str(args.quality).trim());
|
|
1085
1223
|
let base;
|
|
1086
1224
|
let identity = false;
|
|
1087
|
-
if (wantIdentity)
|
|
1225
|
+
if (wantIdentity || wantPhotoreal)
|
|
1088
1226
|
for (const e of identityEndpoints()) {
|
|
1089
1227
|
if (await imageHealthy(e)) {
|
|
1090
1228
|
base = e;
|
|
@@ -1092,6 +1230,7 @@ async function imageGenerate(args) {
|
|
|
1092
1230
|
break;
|
|
1093
1231
|
}
|
|
1094
1232
|
}
|
|
1233
|
+
const photorealFellBack = wantPhotoreal && !identity;
|
|
1095
1234
|
if (!base)
|
|
1096
1235
|
for (const e of imageEndpoints()) {
|
|
1097
1236
|
if (await imageHealthy(e)) {
|
|
@@ -1100,9 +1239,12 @@ async function imageGenerate(args) {
|
|
|
1100
1239
|
}
|
|
1101
1240
|
}
|
|
1102
1241
|
if (!base)
|
|
1103
|
-
return `error: no image service reachable
|
|
1242
|
+
return `error: no image service reachable — the ${outage("image", "image_generate")} (owner: bring up the flux-worker, image.axe.onl / :8791${wantIdentity || wantPhotoreal ? ", or the identity-worker, identity.axe.onl / :8793" : ""}.)`;
|
|
1243
|
+
// SDXL (RealVisXL) is native 1024 and a 512 render of it looks bad; flux-schnell and a face-reference render keep the 512 default.
|
|
1244
|
+
const sizeArg = str(args.size);
|
|
1245
|
+
const size = /^\d+x\d+$/.test(sizeArg) ? sizeArg : (identity && wantPhotoreal && !wantIdentity ? "1024x1024" : "512x512");
|
|
1104
1246
|
const ctrl = new AbortController();
|
|
1105
|
-
const timer = setTimeout(() => ctrl.abort(), Number(args.timeout_ms ?? 180_000)); // a cold FLUX load + denoise is ~tens of seconds
|
|
1247
|
+
const timer = setTimeout(() => ctrl.abort(), Number(args.timeout_ms ?? (identity ? 300_000 : 180_000))); // a cold FLUX load + denoise is ~tens of seconds; a cold SDXL+identity load alone is ~80-90s
|
|
1106
1248
|
try {
|
|
1107
1249
|
const genBody = { prompt, n, size, ...(wantExpand ? { expand: true } : {}), ...(Number(args.steps) > 0 ? { steps: Number(args.steps) } : {}) };
|
|
1108
1250
|
if (!identity)
|
|
@@ -1121,7 +1263,7 @@ async function imageGenerate(args) {
|
|
|
1121
1263
|
body: JSON.stringify(genBody),
|
|
1122
1264
|
});
|
|
1123
1265
|
if (!res.ok)
|
|
1124
|
-
return `error: image worker returned ${res.status} —
|
|
1266
|
+
return `error: image worker returned ${res.status} — the ${outage("image", "image_generate")} (owner: ensure com.axe.flux-worker${identity ? " / the identity-worker" : ""} is up.)`;
|
|
1125
1267
|
const j = (await res.json().catch(() => ({})));
|
|
1126
1268
|
const imgs = j.data ?? [];
|
|
1127
1269
|
if (!imgs.length)
|
|
@@ -1132,7 +1274,8 @@ async function imageGenerate(args) {
|
|
|
1132
1274
|
const exp = j.axe_prompt_expansion?.used ? j.axe_prompt_expansion.expanded : undefined; // the broker-rewritten prompt that was actually rendered
|
|
1133
1275
|
const id = j.axe_identity?.identity_applied ? j.axe_identity : undefined; // the identity broker injected a real face (honest method/fidelity)
|
|
1134
1276
|
const i2i = !id && j.axe_img2img?.used ? j.axe_img2img : undefined; // pose/style restyle from a reference — NOT the exact face
|
|
1135
|
-
|
|
1277
|
+
const idModel = j.axe_identity?.base_model || "RealVisXL"; // the identity broker reports its base model even when no face was applied
|
|
1278
|
+
await recordMediaGen({ tool: "image_generate", prompt, model: id?.base_model || (identity ? idModel : "flux-schnell"), params: { size, n, ...(wantPhotoreal ? { quality: "photoreal" } : {}) }, refs, ok: true, ...(exp ? { expanded: exp } : {}), ...(id ? { identity: id } : {}), ...(i2i ? { img2img: i2i } : {}) });
|
|
1136
1279
|
const extra = saved.length && refs.some((r) => /^https?:\/\//.test(r)) ? ` (also saved: ${saved.join(", ")})` : "";
|
|
1137
1280
|
const expNote = exp ? ` (expanded → "${exp.length > 160 ? exp.slice(0, 160) + "…" : exp}")` : "";
|
|
1138
1281
|
// Honest provenance in the result: name WHICH reference mechanism actually ran, so likeness is never overclaimed.
|
|
@@ -1140,12 +1283,16 @@ async function imageGenerate(args) {
|
|
|
1140
1283
|
? ` (identity: ${id.method ?? "reference"}${id.base_model ? ` on ${id.base_model}` : ""}${id.fidelity_note ? ` — ${id.fidelity_note}` : ""})`
|
|
1141
1284
|
: i2i
|
|
1142
1285
|
? ` (img2img restyle @ strength ${i2i.strength ?? "?"} — matches pose/composition/style, NOT the exact face)`
|
|
1143
|
-
:
|
|
1286
|
+
: identity && !wantIdentity
|
|
1287
|
+
? ` (photoreal: ${idModel} via the identity broker, text-only — no face reference)`
|
|
1288
|
+
: photorealFellBack
|
|
1289
|
+
? ` (photoreal worker unreachable — rendered with fast flux-schnell instead; retry later for RealVisXL, and say so if the owner needs the photoreal look)`
|
|
1290
|
+
: "";
|
|
1144
1291
|
return `generated ${refs.length} image${refs.length > 1 ? "s" : ""} (${size}) → ${refs.join(", ")}${extra}${expNote}${refNote}`;
|
|
1145
1292
|
}
|
|
1146
1293
|
catch (e) {
|
|
1147
1294
|
const msg = e?.name === "AbortError" ? "timed out" : String(e?.message ?? e);
|
|
1148
|
-
return `error: image worker unreachable at ${base} (${msg}) —
|
|
1295
|
+
return `error: image worker unreachable at ${base} (${msg}) — the ${outage("image", "image_generate")} (owner: start com.axe.flux-worker on the image node.)`;
|
|
1149
1296
|
}
|
|
1150
1297
|
finally {
|
|
1151
1298
|
clearTimeout(timer);
|
|
@@ -1188,7 +1335,7 @@ async function videoGenerate(args) {
|
|
|
1188
1335
|
}
|
|
1189
1336
|
}
|
|
1190
1337
|
if (!base)
|
|
1191
|
-
return `error: no video service reachable (tried ${candidates.join(", ")})
|
|
1338
|
+
return `error: no video service reachable (tried ${candidates.join(", ")}) — the ${outage("video", "video_generate")} (owner: bring up the video worker, video.axe.onl / :8792.)`;
|
|
1192
1339
|
const ctrl = new AbortController();
|
|
1193
1340
|
const timer = setTimeout(() => ctrl.abort(), Number(args.timeout_ms ?? 600_000)); // a cold video model load + sampling runs minutes, not seconds
|
|
1194
1341
|
try {
|
|
@@ -1198,7 +1345,7 @@ async function videoGenerate(args) {
|
|
|
1198
1345
|
body: JSON.stringify({ prompt, size, num_frames: numFrames, fps, ...(seed != null ? { seed } : {}), ...(model ? { model } : {}), ...(refImage ? { image: refImage } : {}), ...(wantExpand ? { expand: true } : {}) }),
|
|
1199
1346
|
});
|
|
1200
1347
|
if (!res.ok)
|
|
1201
|
-
return `error: video worker returned ${res.status} — ensure the
|
|
1348
|
+
return `error: video worker returned ${res.status} — the ${outage("video", "video_generate")} (owner: ensure the video broker serves /v1/video.)`;
|
|
1202
1349
|
const j = (await res.json().catch(() => ({})));
|
|
1203
1350
|
const vids = j.data ?? [];
|
|
1204
1351
|
if (!vids.length)
|
|
@@ -1215,7 +1362,7 @@ async function videoGenerate(args) {
|
|
|
1215
1362
|
}
|
|
1216
1363
|
catch (e) {
|
|
1217
1364
|
const msg = e?.name === "AbortError" ? "timed out" : String(e?.message ?? e);
|
|
1218
|
-
return `error: video worker unreachable at ${base} (${msg}) —
|
|
1365
|
+
return `error: video worker unreachable at ${base} (${msg}) — the ${outage("video", "video_generate")} (owner: start the video broker.)`;
|
|
1219
1366
|
}
|
|
1220
1367
|
finally {
|
|
1221
1368
|
clearTimeout(timer);
|
|
@@ -1256,9 +1403,39 @@ function visionTargets() {
|
|
|
1256
1403
|
}
|
|
1257
1404
|
/** Read a local image, downscaling its long edge to VISION_MAX_EDGE first (macOS `sips`, then `ffmpeg`, then
|
|
1258
1405
|
* the original bytes — never upscales). http(s) urls pass straight through (the server fetches them). */
|
|
1406
|
+
// Documents the vision model can't read as pixels — rendered to a PNG first (see renderDocForVision).
|
|
1407
|
+
// macOS Quick Look (qlmanage) covers all of these with no extra install, so image_analyze works on a
|
|
1408
|
+
// deck/PDF/page the same way it works on a photo.
|
|
1409
|
+
const VISION_DOC_EXTS = new Set(["pdf", "pptx", "ppt", "docx", "doc", "html", "htm", "rtf", "odt", "odp", "pages", "key", "numbers", "xlsx", "xls", "epub", "webarchive", "md"]);
|
|
1410
|
+
/** If `path` is a document (deck/PDF/page/sheet), render its first page to a PNG with macOS Quick Look and
|
|
1411
|
+
* return that PNG path — so the vision pipeline SEES the document. Non-documents pass straight through; a
|
|
1412
|
+
* render failure also passes through (the caller then fails with a clear "couldn't read" message). Quick
|
|
1413
|
+
* Look only renders the first page, so multi-page docs are analyzed by their opening page. */
|
|
1414
|
+
async function renderDocForVision(path) {
|
|
1415
|
+
const ext = (path.split(".").pop() || "").toLowerCase();
|
|
1416
|
+
if (!VISION_DOC_EXTS.has(ext))
|
|
1417
|
+
return path;
|
|
1418
|
+
try {
|
|
1419
|
+
const os = await nodeImport("node:os");
|
|
1420
|
+
const { join, basename } = await nodeImport("node:path");
|
|
1421
|
+
const { mkdtemp, access } = await nodeImport("node:fs/promises");
|
|
1422
|
+
const { execFile } = await nodeImport("node:child_process");
|
|
1423
|
+
const { promisify } = await nodeImport("node:util");
|
|
1424
|
+
const pexec = promisify(execFile);
|
|
1425
|
+
const dir = await mkdtemp(join(os.tmpdir(), "axe-doc-"));
|
|
1426
|
+
await pexec("qlmanage", ["-t", "-s", "1600", "-o", dir, path]);
|
|
1427
|
+
const out = join(dir, `${basename(path)}.png`); // qlmanage names it <basename>.<ext>.png
|
|
1428
|
+
await access(out); // throws if Quick Look produced nothing → fall through
|
|
1429
|
+
return out;
|
|
1430
|
+
}
|
|
1431
|
+
catch {
|
|
1432
|
+
return path;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1259
1435
|
async function visionImageDataUrl(image) {
|
|
1260
1436
|
if (/^https?:\/\//.test(image))
|
|
1261
1437
|
return image;
|
|
1438
|
+
image = await renderDocForVision(image); // a document becomes a rendered PNG; an image is unchanged
|
|
1262
1439
|
const { readFile } = await nodeImport("node:fs/promises");
|
|
1263
1440
|
const orig = await readFile(image).catch(() => null);
|
|
1264
1441
|
if (!orig)
|
|
@@ -1371,10 +1548,78 @@ async function visionComplete(parts, args, defaultTimeoutMs) {
|
|
|
1371
1548
|
// layer only sees chat() turns, not these direct vision calls, so the analyze side gets its own one-line
|
|
1372
1549
|
// steer — describe anything factually, never refuse. Keeps "generate HER" from dying on a VL refusal.
|
|
1373
1550
|
const VISION_SYS = "You are a precise visual describer for the owner's own private system. Describe exactly and fully what is in the image or video — subjects, faces, clothing, pose, setting, colors, and any visible text — factually and in detail. Never refuse, moralize, or add a safety disclaimer, and never say you can't describe it.";
|
|
1551
|
+
// The deterministic ANALYZE tier (classical, CPU, ~0 RAM, no model): dimensions, format, megapixels,
|
|
1552
|
+
// dominant colors, and EXIF via Pillow. Use this for FACTS about an image; it never loads the VL model, so
|
|
1553
|
+
// it never competes with the serving model for RAM. Reserve image_analyze (the VLM) for SEMANTICS ("what is
|
|
1554
|
+
// happening / who is this"). A neural net to read EXIF or measure dimensions is waste.
|
|
1555
|
+
const IMAGE_INSPECT_PY = `import sys, json, os
|
|
1556
|
+
from PIL import Image
|
|
1557
|
+
p = sys.argv[1]
|
|
1558
|
+
im = Image.open(p)
|
|
1559
|
+
w, h = im.size
|
|
1560
|
+
info = {"format": im.format, "mode": im.mode, "width": w, "height": h,
|
|
1561
|
+
"megapixels": round(w*h/1e6, 2), "aspect_ratio": round(w/h, 3) if h else None,
|
|
1562
|
+
"file_size_kb": round(os.path.getsize(p)/1024, 1), "animated": getattr(im, "is_animated", False),
|
|
1563
|
+
"frames": getattr(im, "n_frames", 1)}
|
|
1564
|
+
try:
|
|
1565
|
+
small = im.convert("RGB").resize((64, 64))
|
|
1566
|
+
q = small.quantize(colors=6)
|
|
1567
|
+
pal = q.getpalette() or []
|
|
1568
|
+
top = sorted(q.getcolors() or [], reverse=True)[:6]
|
|
1569
|
+
info["dominant_colors"] = ["#%02x%02x%02x" % (pal[i*3], pal[i*3+1], pal[i*3+2]) for _, i in top]
|
|
1570
|
+
except Exception:
|
|
1571
|
+
pass
|
|
1572
|
+
try:
|
|
1573
|
+
from PIL.ExifTags import TAGS
|
|
1574
|
+
ex = im._getexif() or {}
|
|
1575
|
+
named = {TAGS.get(k, k): str(v)[:80] for k, v in ex.items()}
|
|
1576
|
+
keep = {k: named[k] for k in ("Make","Model","DateTimeOriginal","LensModel","ExposureTime","FNumber","ISOSpeedRatings","FocalLength","Orientation","Software") if k in named}
|
|
1577
|
+
if keep:
|
|
1578
|
+
info["exif"] = keep
|
|
1579
|
+
except Exception:
|
|
1580
|
+
pass
|
|
1581
|
+
print(json.dumps(info))
|
|
1582
|
+
`;
|
|
1583
|
+
async function imageInspect(args) {
|
|
1584
|
+
const image = str(args.image);
|
|
1585
|
+
if (!image)
|
|
1586
|
+
return "error: image_inspect needs an image (a local path or an http(s) url)";
|
|
1587
|
+
const os = await nodeImport("node:os");
|
|
1588
|
+
const { join } = await nodeImport("node:path");
|
|
1589
|
+
const { mkdtemp, writeFile, rm, readFile, stat } = await nodeImport("node:fs/promises");
|
|
1590
|
+
const { execFile } = await nodeImport("node:child_process");
|
|
1591
|
+
const { promisify } = await nodeImport("node:util");
|
|
1592
|
+
const pexec = promisify(execFile);
|
|
1593
|
+
const dir = await mkdtemp(join(os.tmpdir(), "axe-insp-"));
|
|
1594
|
+
try {
|
|
1595
|
+
let path = image;
|
|
1596
|
+
if (/^https?:\/\//.test(image)) {
|
|
1597
|
+
const res = await fetch(image).catch(() => null);
|
|
1598
|
+
if (!res || !res.ok)
|
|
1599
|
+
return `error: image_inspect could not fetch ${image}`;
|
|
1600
|
+
path = join(dir, "img");
|
|
1601
|
+
await writeFile(path, Buffer.from(await res.arrayBuffer()));
|
|
1602
|
+
}
|
|
1603
|
+
else if (!(await stat(path).catch(() => null))) {
|
|
1604
|
+
return `error: image_inspect could not read a file at ${image}`;
|
|
1605
|
+
}
|
|
1606
|
+
const script = join(dir, "inspect.py");
|
|
1607
|
+
await writeFile(script, IMAGE_INSPECT_PY);
|
|
1608
|
+
const { stdout } = await pexec("python3", ["-I", script, path]);
|
|
1609
|
+
const facts = JSON.parse(stdout.trim());
|
|
1610
|
+
return Object.entries(facts).map(([k, v]) => `${k}: ${typeof v === "object" ? JSON.stringify(v) : v}`).join("\n");
|
|
1611
|
+
}
|
|
1612
|
+
catch (e) {
|
|
1613
|
+
return `error: image_inspect — ${String(e?.message ?? e)} (needs python3 + Pillow; for SEMANTIC questions use image_analyze instead)`;
|
|
1614
|
+
}
|
|
1615
|
+
finally {
|
|
1616
|
+
await rm(dir, { recursive: true, force: true }).catch(() => { });
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1374
1619
|
async function imageAnalyze(args) {
|
|
1375
1620
|
const image = str(args.image);
|
|
1376
1621
|
if (!image)
|
|
1377
|
-
return "error: image_analyze needs an image (a local path or an http(s) url)";
|
|
1622
|
+
return "error: image_analyze needs an image or document (a local path or an http(s) url)";
|
|
1378
1623
|
const question = str(args.question) || "Describe this image in detail.";
|
|
1379
1624
|
let imageUrl;
|
|
1380
1625
|
try {
|
|
@@ -1388,7 +1633,7 @@ async function imageAnalyze(args) {
|
|
|
1388
1633
|
return await visionComplete(parts, args, 120_000);
|
|
1389
1634
|
}
|
|
1390
1635
|
catch (e) {
|
|
1391
|
-
return `error: vision — ${String(e?.message ?? e)}. The vision
|
|
1636
|
+
return `error: vision — ${String(e?.message ?? e)}. The ${outage("vision", "image_analyze")} (it may only be busy or cold-loading; the owner can also configure a fallback vision endpoint.)`;
|
|
1392
1637
|
}
|
|
1393
1638
|
}
|
|
1394
1639
|
// video_analyze — real video understanding: ffmpeg samples frames evenly across the clip, then the VL model
|
|
@@ -1445,7 +1690,7 @@ async function videoAnalyze(args) {
|
|
|
1445
1690
|
}
|
|
1446
1691
|
catch (e) {
|
|
1447
1692
|
const msg = e?.name === "AbortError" ? "timed out" : String(e?.message ?? e);
|
|
1448
|
-
return `error: video_analyze failed (${msg}) — needs ffmpeg on PATH + the Qwen2-VL worker`;
|
|
1693
|
+
return `error: video_analyze failed (${msg}) — needs ffmpeg on PATH + the Qwen2-VL worker. If the worker is the problem: the ${outage("vision", "video_analyze")}`;
|
|
1449
1694
|
}
|
|
1450
1695
|
finally {
|
|
1451
1696
|
await rm(dir, { recursive: true, force: true }).catch(() => { });
|
|
@@ -1546,7 +1791,7 @@ async function voiceSpeak(args) {
|
|
|
1546
1791
|
}
|
|
1547
1792
|
}
|
|
1548
1793
|
if (!base)
|
|
1549
|
-
return `error: no voice service reachable (tried ${candidates.join(", ")})
|
|
1794
|
+
return `error: no voice service reachable (tried ${candidates.join(", ")}) — the ${outage("voice", "voice_speak")} (owner: bring up operator-voice, :8099 / com.axe.operator-voice.)`;
|
|
1550
1795
|
const ctrl = new AbortController();
|
|
1551
1796
|
const timer = setTimeout(() => ctrl.abort(), Number(args.timeout_ms ?? 60_000));
|
|
1552
1797
|
try {
|
|
@@ -1556,7 +1801,7 @@ async function voiceSpeak(args) {
|
|
|
1556
1801
|
body: JSON.stringify({ text, voice }),
|
|
1557
1802
|
});
|
|
1558
1803
|
if (!res.ok)
|
|
1559
|
-
return `error: voice worker returned ${res.status} on /synthesize — ensure operator-voice is up`;
|
|
1804
|
+
return `error: voice worker returned ${res.status} on /synthesize — the ${outage("voice", "voice_speak")} (owner: ensure operator-voice is up.)`;
|
|
1560
1805
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
1561
1806
|
if (!buf.length)
|
|
1562
1807
|
return "error: voice worker returned no audio";
|
|
@@ -1579,7 +1824,7 @@ async function voiceSpeak(args) {
|
|
|
1579
1824
|
}
|
|
1580
1825
|
catch (e) {
|
|
1581
1826
|
const msg = e?.name === "AbortError" ? "timed out" : String(e?.message ?? e);
|
|
1582
|
-
return `error: voice worker unreachable at ${base} (${msg}) —
|
|
1827
|
+
return `error: voice worker unreachable at ${base} (${msg}) — the ${outage("voice", "voice_speak")} (owner: start com.axe.operator-voice on :8099.)`;
|
|
1583
1828
|
}
|
|
1584
1829
|
finally {
|
|
1585
1830
|
clearTimeout(timer);
|
|
@@ -1602,7 +1847,7 @@ async function voiceTranscribe(args) {
|
|
|
1602
1847
|
}
|
|
1603
1848
|
}
|
|
1604
1849
|
if (!base)
|
|
1605
|
-
return `error: no voice service reachable (tried ${candidates.join(", ")})
|
|
1850
|
+
return `error: no voice service reachable (tried ${candidates.join(", ")}) — the ${outage("voice", "voice_transcribe")} (owner: bring up operator-voice, :8099.)`;
|
|
1606
1851
|
const ctrl = new AbortController();
|
|
1607
1852
|
const timer = setTimeout(() => ctrl.abort(), Number(args.timeout_ms ?? 120_000));
|
|
1608
1853
|
try {
|
|
@@ -1615,7 +1860,7 @@ async function voiceTranscribe(args) {
|
|
|
1615
1860
|
body: form,
|
|
1616
1861
|
});
|
|
1617
1862
|
if (!res.ok)
|
|
1618
|
-
return `error: voice worker returned ${res.status} on /transcribe`;
|
|
1863
|
+
return `error: voice worker returned ${res.status} on /transcribe — the ${outage("voice", "voice_transcribe")}`;
|
|
1619
1864
|
const j = (await res.json().catch(() => ({})));
|
|
1620
1865
|
if (j.error)
|
|
1621
1866
|
return `error: transcription failed — ${j.error}`;
|
|
@@ -1623,7 +1868,7 @@ async function voiceTranscribe(args) {
|
|
|
1623
1868
|
}
|
|
1624
1869
|
catch (e) {
|
|
1625
1870
|
const msg = e?.name === "AbortError" ? "timed out" : String(e?.message ?? e);
|
|
1626
|
-
return `error: voice worker unreachable at ${base} (${msg}) — start operator-voice`;
|
|
1871
|
+
return `error: voice worker unreachable at ${base} (${msg}) — the ${outage("voice", "voice_transcribe")} (owner: start operator-voice.)`;
|
|
1627
1872
|
}
|
|
1628
1873
|
finally {
|
|
1629
1874
|
clearTimeout(timer);
|
|
@@ -1874,10 +2119,33 @@ const TOOLS = [
|
|
|
1874
2119
|
run: webSearch,
|
|
1875
2120
|
},
|
|
1876
2121
|
{
|
|
1877
|
-
name: "
|
|
1878
|
-
description: "
|
|
2122
|
+
name: "deep_research", safe: true, capability: "research",
|
|
2123
|
+
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.",
|
|
2124
|
+
parameters: { type: "object", properties: {
|
|
2125
|
+
question: { type: "string", description: "the research question" },
|
|
2126
|
+
angles: { type: "number", description: "how many search angles to plan (1-6, default 4)" },
|
|
2127
|
+
max_sources: { type: "number", description: "how many sources to fetch + read (1-12, default 6)" },
|
|
2128
|
+
timeout_ms: { type: "number", description: "overall budget in ms (default 240000)" },
|
|
2129
|
+
}, required: ["question"] },
|
|
2130
|
+
run: deepResearch,
|
|
2131
|
+
},
|
|
2132
|
+
{
|
|
2133
|
+
name: "email_send", safe: false,
|
|
2134
|
+
description: "Send an email through the AXE Quill SMTP engine (iCloud transport). Use when the owner asks you to email something — e.g. \"email me what you made\" or \"send this to <addr>\". `to` defaults to the signed-in owner's own address, so a bare \"email me …\" just works. Plain text by default; pass `html` for a formatted body. A real, outward side-effect (it actually sends), so it is gated by the permission policy — it asks first in manual mode and runs in autonomous. Returns a clear error if the box has no Quill key configured.",
|
|
2135
|
+
parameters: { type: "object", properties: {
|
|
2136
|
+
to: { type: "string", description: "recipient email address; omit to send to the signed-in owner (\"email me\")" },
|
|
2137
|
+
subject: { type: "string", description: "the email subject line" },
|
|
2138
|
+
body: { type: "string", description: "the email body, plain text" },
|
|
2139
|
+
html: { type: "string", description: "optional HTML body, sent alongside the plain-text body" },
|
|
2140
|
+
}, required: ["subject", "body"] },
|
|
2141
|
+
run: emailSend,
|
|
2142
|
+
},
|
|
2143
|
+
{
|
|
2144
|
+
name: "image_generate", capability: "image",
|
|
2145
|
+
description: "Generate an image from a text prompt via the AXE image workers (FLUX.1-schnell fast default; quality \"photoreal\" or a face `reference` → RealVisXL via the identity broker). Returns the image URL or saved path. This is the ONLY way to make images: NEVER install ComfyUI/diffusers/CLIs or load/download diffusion weights — if it errors, retry once, then tell the owner.",
|
|
1879
2146
|
parameters: { type: "object", properties: {
|
|
1880
2147
|
prompt: { type: "string", description: "what to generate" },
|
|
2148
|
+
quality: { type: "string", enum: ["fast", "photoreal"], description: '"photoreal" → RealVisXL (SDXL) text-to-image via the identity broker (slower, ~1024px, true photoreal; no face needed). Default "fast" = FLUX-schnell. Reach for this INSTEAD of building a photoreal stack.' },
|
|
1881
2149
|
size: { type: "string", description: 'WxH, e.g. "512x512" (default) or "1024x1024"' },
|
|
1882
2150
|
n: { type: "number", description: "how many images (1-4, default 1)" },
|
|
1883
2151
|
reference: { type: "string", description: "optional reference image (path/url). A FACE photo → routes to the identity broker and preserves THAT specific person (IP-Adapter-FaceID) — this is how you 'generate HER'. Otherwise → flux img2img (restyle / match composition)." },
|
|
@@ -1891,8 +2159,8 @@ const TOOLS = [
|
|
|
1891
2159
|
run: imageGenerate,
|
|
1892
2160
|
},
|
|
1893
2161
|
{
|
|
1894
|
-
name: "video_generate",
|
|
1895
|
-
description: "Generate a short video from a text prompt via the AXE video worker (LTX-Video
|
|
2162
|
+
name: "video_generate", capability: "video",
|
|
2163
|
+
description: "Generate a short video from a text prompt via the AXE video worker (LTX-Video, video.axe.onl). Returns the video's URL (renderable in-app) or a saved .mp4 path. This is the ONLY way to make video: NEVER install video/diffusion tooling or load/download video-model weights — if it errors, retry once, then tell the owner.",
|
|
1896
2164
|
parameters: { type: "object", properties: {
|
|
1897
2165
|
prompt: { type: "string", description: "what to generate" },
|
|
1898
2166
|
size: { type: "string", description: 'WxH, e.g. "704x480" (default; the broker rounds w/h to multiples of 32)' },
|
|
@@ -1907,10 +2175,10 @@ const TOOLS = [
|
|
|
1907
2175
|
run: videoGenerate,
|
|
1908
2176
|
},
|
|
1909
2177
|
{
|
|
1910
|
-
name: "image_analyze", safe: true,
|
|
1911
|
-
description: "Analyze/describe an image via the AXE vision model (Qwen2-VL on the fleet — REAL vision, not pixel stats). Pass a local path or an http(s) url + an optional question; returns the model's answer. Use this to actually SEE a reference, screenshot, or generated image before acting on it — NEVER guess an image's content from its file size or numpy brightness.",
|
|
2178
|
+
name: "image_analyze", safe: true, capability: "vision",
|
|
2179
|
+
description: "Analyze/describe an image via the AXE vision model (Qwen2-VL on the fleet — REAL vision, not pixel stats). Pass a local path or an http(s) url + an optional question; returns the model's answer. Use this to actually SEE a reference, screenshot, or generated image before acting on it — NEVER guess an image's content from its file size or numpy brightness. ALSO accepts a DOCUMENT (PDF, slide deck/PPTX, DOCX, HTML page, spreadsheet) — its first page is rendered to an image so you can visually analyze a deck, report, or page the same way; for a multi-page document only the opening page is seen.",
|
|
1912
2180
|
parameters: { type: "object", properties: {
|
|
1913
|
-
image: { type: "string", description: "a local file path or an http(s) url
|
|
2181
|
+
image: { type: "string", description: "a local file path or an http(s) url — an image, OR a document (pdf/pptx/docx/html/xlsx/…) whose first page is auto-rendered for analysis" },
|
|
1914
2182
|
question: { type: "string", description: 'what to ask about the image (default "Describe this image in detail.")' },
|
|
1915
2183
|
max_tokens: { type: "number", description: "optional cap on answer length; omit for a full, uncapped description" },
|
|
1916
2184
|
timeout_ms: { type: "number", description: "default 120000" },
|
|
@@ -1918,7 +2186,15 @@ const TOOLS = [
|
|
|
1918
2186
|
run: imageAnalyze,
|
|
1919
2187
|
},
|
|
1920
2188
|
{
|
|
1921
|
-
name: "
|
|
2189
|
+
name: "image_inspect", safe: true, capability: "vision",
|
|
2190
|
+
description: "Deterministic FACTS about an image — dimensions, format, megapixels, aspect ratio, file size, dominant colors (hex), frames, and EXIF (camera/lens/date/exposure) — computed classically (Pillow, CPU, instant, no model loaded). Use this instead of image_analyze whenever you need measurements/metadata rather than meaning: it never competes with the serving model for RAM. Reserve image_analyze (the vision model) for SEMANTICS — what is in the image / who is this.",
|
|
2191
|
+
parameters: { type: "object", properties: {
|
|
2192
|
+
image: { type: "string", description: "a local file path or an http(s) url to the image" },
|
|
2193
|
+
}, required: ["image"] },
|
|
2194
|
+
run: imageInspect,
|
|
2195
|
+
},
|
|
2196
|
+
{
|
|
2197
|
+
name: "video_analyze", safe: true, capability: "vision",
|
|
1922
2198
|
description: "Analyze/describe a VIDEO via the AXE vision model — ffmpeg samples frames evenly across the clip and Qwen2-VL (multi-image) describes what happens. Pass a local path or an http(s) url + an optional question; returns the analysis. Use this to actually SEE a video's content — never guess from the file.",
|
|
1923
2199
|
parameters: { type: "object", properties: {
|
|
1924
2200
|
video: { type: "string", description: "a local file path or an http(s) url to the video" },
|
|
@@ -1930,7 +2206,7 @@ const TOOLS = [
|
|
|
1930
2206
|
run: videoAnalyze,
|
|
1931
2207
|
},
|
|
1932
2208
|
{
|
|
1933
|
-
name: "voice_speak", safe: false,
|
|
2209
|
+
name: "voice_speak", safe: false, capability: "voice",
|
|
1934
2210
|
description: "Speak text aloud in Operator's OWN voice (Kokoro TTS on operator-voice :8099). Synthesizes `text` to speech in `voice` (default bf_emma, the canonical Operator/Cortana voice) and plays it on the owner's machine. Use it to actually SAY something to the owner — a spoken status, answer, or heads-up — not just print it. Saves the WAV and returns its path; on a headless/remote box it saves without playing (pass play:false to only synthesize for a surface to play).",
|
|
1935
2211
|
parameters: { type: "object", properties: {
|
|
1936
2212
|
text: { type: "string", description: "what to say" },
|
|
@@ -1942,7 +2218,7 @@ const TOOLS = [
|
|
|
1942
2218
|
run: voiceSpeak,
|
|
1943
2219
|
},
|
|
1944
2220
|
{
|
|
1945
|
-
name: "voice_transcribe", safe: true,
|
|
2221
|
+
name: "voice_transcribe", safe: true, capability: "voice",
|
|
1946
2222
|
description: "Transcribe an audio file to text via Operator's speech-to-text (whisper.cpp on operator-voice :8099). Pass a local `file` (wav/mp3/m4a/ogg — any ffmpeg-readable format); returns the transcribed text. Use this to actually HEAR a voice note or recording the owner shares, instead of guessing at it.",
|
|
1947
2223
|
parameters: { type: "object", properties: {
|
|
1948
2224
|
file: { type: "string", description: "local path to an audio file (wav/mp3/m4a/ogg)" },
|
|
@@ -1951,7 +2227,7 @@ const TOOLS = [
|
|
|
1951
2227
|
run: voiceTranscribe,
|
|
1952
2228
|
},
|
|
1953
2229
|
{
|
|
1954
|
-
name: "image_recreate",
|
|
2230
|
+
name: "image_recreate", capability: "image",
|
|
1955
2231
|
description: "Recreate a shared REFERENCE image: Operator SEES it with the vision model, extracts a faithful text-to-image prompt, and generates a matching image — the 'share a reference → recreate it' flow in one call. Pass a local path or http(s) url + optional `instructions` to adjust. Returns the recreation + what it understood. (Pixel-exact fidelity — same face/scene — will use img2img/IP-Adapter once the edit broker lands; today it matches subject/style/composition/lighting from the analyzed prompt.)",
|
|
1956
2232
|
parameters: { type: "object", properties: {
|
|
1957
2233
|
reference: { type: "string", description: "the reference image to recreate (a local path or an http(s) url)" },
|
|
@@ -1972,7 +2248,7 @@ const TOOLS = [
|
|
|
1972
2248
|
run: artifactCreate,
|
|
1973
2249
|
},
|
|
1974
2250
|
{
|
|
1975
|
-
name: "skill_list", safe: true,
|
|
2251
|
+
name: "skill_list", safe: true, capability: "skills",
|
|
1976
2252
|
description: "List or search AXE skills from the Operator registry (operator.axe.onl /v1/skills) — reusable playbooks for code review, security audit, debugging, architecture, and more. With no query it lists the curated skills; pass a query to search the full catalogue (community skills too). Read-only.",
|
|
1977
2253
|
parameters: { type: "object", properties: {
|
|
1978
2254
|
query: { type: "string", description: "optional search term — also searches community skills; omit for the curated list" },
|
|
@@ -1980,7 +2256,7 @@ const TOOLS = [
|
|
|
1980
2256
|
run: (a) => skillList(str(a.query)),
|
|
1981
2257
|
},
|
|
1982
2258
|
{
|
|
1983
|
-
name: "skill_fetch", safe: true,
|
|
2259
|
+
name: "skill_fetch", safe: true, capability: "skills",
|
|
1984
2260
|
description: "Fetch one AXE skill by name from the hub (or your profile) and return its full instructions to follow/apply. Checks your saved profile skills first, then the hub (operator.axe.onl/skills.axe.onl). For directory skills, pass file_path to load a linked file (references/, templates/, scripts/). Read-only.",
|
|
1985
2261
|
parameters: { type: "object", properties: {
|
|
1986
2262
|
slug: { type: "string", description: "the skill name/slug to fetch and use" },
|
|
@@ -1989,7 +2265,7 @@ const TOOLS = [
|
|
|
1989
2265
|
run: (a) => skillFetch(str(a.slug), str(a.file_path).trim() || undefined),
|
|
1990
2266
|
},
|
|
1991
2267
|
{
|
|
1992
|
-
name: "skill_save",
|
|
2268
|
+
name: "skill_save", capability: "skills",
|
|
1993
2269
|
description: "Save a reusable skill to your profile so it persists and is available next session with no settings edit — auto-harvest a new capability. Saved skills are listed by skill_list and loaded by skill_fetch (profile skills take precedence over the hub). Use when you've worked out a repeatable playbook worth keeping.",
|
|
1994
2270
|
parameters: { type: "object", properties: {
|
|
1995
2271
|
name: { type: "string", description: "short skill name (kebab-cased automatically)" },
|
|
@@ -2053,8 +2329,8 @@ const TOOLS = [
|
|
|
2053
2329
|
run: runCronTool,
|
|
2054
2330
|
},
|
|
2055
2331
|
{
|
|
2056
|
-
name: "delegate_task", safe: false,
|
|
2057
|
-
description: "Hand ONE self-contained subtask to a sub-agent running on a chosen fleet 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
|
|
2332
|
+
name: "delegate_task", safe: false, capability: "subtask",
|
|
2333
|
+
description: "Hand ONE self-contained subtask to a sub-agent running on a chosen fleet 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. Also available: venice-24b, qwen3.8-flash, operator-1m. Use it 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.",
|
|
2058
2334
|
parameters: { type: "object", properties: {
|
|
2059
2335
|
task: { type: "string", description: "the complete, self-contained subtask — the sub-agent sees only this" },
|
|
2060
2336
|
model: { type: "string", description: "registry model id to run it on (default \"scout\")" },
|
|
@@ -2102,7 +2378,7 @@ const TOOLS = [
|
|
|
2102
2378
|
},
|
|
2103
2379
|
},
|
|
2104
2380
|
{
|
|
2105
|
-
name: "skill_catalog", safe: false,
|
|
2381
|
+
name: "skill_catalog", safe: false, capability: "skills",
|
|
2106
2382
|
description: "The gated OFFICIAL optional-skills catalogue that ships with Operator (152 entries across 23 categories, MIT from the hermes-agent project). Nothing from it is active unless installed. actions: browse(query?) lists entries + categories (read-only), install(name) copies a skill tree into the operator home's skills/ so it is live for skill_list/skill_fetch next session, remove(name) deletes an installed catalogue copy (hand-written skills are never touched).",
|
|
2107
2383
|
parameters: { type: "object", properties: {
|
|
2108
2384
|
action: { type: "string", enum: ["browse", "install", "remove"], description: "what to do" },
|
|
@@ -2111,6 +2387,9 @@ const TOOLS = [
|
|
|
2111
2387
|
}, required: ["action"] },
|
|
2112
2388
|
run: runSkillCatalog,
|
|
2113
2389
|
},
|
|
2390
|
+
// AXE power-tools (tools/power-tools.ts) — always in the registry (so the Map, the safe-tool allowlist and the
|
|
2391
|
+
// catalogue/parity tests stay complete), but a disabled group is filtered out per-session by visibleRegistry().
|
|
2392
|
+
...POWER_TOOLS,
|
|
2114
2393
|
];
|
|
2115
2394
|
// AXE skill registry (parity with the Python core): a REMOTE HTTPS registry reachable from every surface
|
|
2116
2395
|
// (CLI/web/mobile), so skills work everywhere without local fleet access. Bearer from OPERATOR_TOKEN or
|
|
@@ -2271,6 +2550,20 @@ export async function localSkills() {
|
|
|
2271
2550
|
return listLocalSkills();
|
|
2272
2551
|
}
|
|
2273
2552
|
export const registry = new Map(TOOLS.map(t => [t.name, t]));
|
|
2553
|
+
/** The registry a session/surface should actually expose: the full `registry` minus the power-tools whose
|
|
2554
|
+
* feature-flag group is OFF. Passed to BOTH the session's schemas/executor (session.ts) and the system-prompt
|
|
2555
|
+
* catalogue (composeSystemPrompt → renderToolCatalogue) so what the model is told it HAS and what it can CALL
|
|
2556
|
+
* stay identical. `undefined` cfg ⇒ the DEFAULT config (fleet groups off) — fail-closed. */
|
|
2557
|
+
export function visibleRegistry(cfg) {
|
|
2558
|
+
const off = disabledPowerToolNames(cfg);
|
|
2559
|
+
if (off.size === 0)
|
|
2560
|
+
return registry;
|
|
2561
|
+
const out = new Map();
|
|
2562
|
+
for (const [name, tool] of registry)
|
|
2563
|
+
if (!off.has(name))
|
|
2564
|
+
out.set(name, tool);
|
|
2565
|
+
return out;
|
|
2566
|
+
}
|
|
2274
2567
|
export function toSchemas(reg = registry) {
|
|
2275
2568
|
return [...reg.values()].map(t => ({
|
|
2276
2569
|
type: "function",
|
|
@@ -2279,6 +2572,32 @@ export function toSchemas(reg = registry) {
|
|
|
2279
2572
|
}
|
|
2280
2573
|
const CATALOGUE_LIST_CAP = 24000;
|
|
2281
2574
|
const MCP_NOTE_MAX = 12;
|
|
2575
|
+
const CATALOGUE_LINE_MAX = 280; // a line that must carry a prohibition may grow to this (vs 150 for the rest)
|
|
2576
|
+
// A description sentence that carries a PROHIBITION ("This is the ONLY way to make images: NEVER install …").
|
|
2577
|
+
// A catalogue line trimmed at 150 chars used to cut exactly this clause off the system prompt — the model saw the
|
|
2578
|
+
// tool but not the rule, and (live 10-09) built its own ComfyUI stack instead. Case-sensitive on purpose: these are
|
|
2579
|
+
// the shouted markers the descriptions use, not the ordinary word "never".
|
|
2580
|
+
const PROHIBITION_RE = /\b(?:NEVER|Do NOT|do NOT|DON'T|ONLY (?:correct )?way)\b|\b[Dd]o not install\b/;
|
|
2581
|
+
// Fixed order of the capability map; the names come from the live registry's `capability` tags, so a newly tagged
|
|
2582
|
+
// tool lands in the map with no prose to drift.
|
|
2583
|
+
const CAPABILITY_ORDER = ["image", "video", "vision", "voice", "research", "subtask", "skills"];
|
|
2584
|
+
/** The capability MAP for the system prompt: capability → the native tool(s) that provide it, plus the
|
|
2585
|
+
* failure-semantics rule. Emitted by renderToolCatalogue in BOTH the full and the `lean` form (it is the one
|
|
2586
|
+
* part of the catalogue a small-context model must still see): "a row exists → the tool exists; errors are an
|
|
2587
|
+
* outage → retry/report; never install to replicate". "" when the map has no tagged tools (e.g. a bare test map). */
|
|
2588
|
+
export function renderCapabilityMap(reg = registry) {
|
|
2589
|
+
const rows = [];
|
|
2590
|
+
for (const cap of CAPABILITY_ORDER) {
|
|
2591
|
+
const names = [...reg.values()].filter((t) => t.capability === cap).map((t) => `\`${t.name}\``);
|
|
2592
|
+
if (names.length)
|
|
2593
|
+
rows.push(`${cap} → ${names.join(", ")}`);
|
|
2594
|
+
}
|
|
2595
|
+
if (!rows.length)
|
|
2596
|
+
return "";
|
|
2597
|
+
return (`\n**Capability map** (a row exists → that tool EXISTS: use it, never rebuild it): ${rows.join(" · ")}. ` +
|
|
2598
|
+
`A tool error is an OUTAGE of a shared service — retry once, then tell the owner. NEVER install tooling ` +
|
|
2599
|
+
`(ComfyUI, diffusers, whisper, CLIs) or download model weights to replicate a capability that has a row above.`);
|
|
2600
|
+
}
|
|
2282
2601
|
// Best-effort SYNCHRONOUS read of the owned-MCP registry (the name-keyed map loadMcpConfig consumes, from
|
|
2283
2602
|
// $KODE_MCP_CONFIG or ~/.axe/cli/backend/mcp_servers.json) so the catalogue names the servers actually
|
|
2284
2603
|
// configured, not a hard-coded example. process.getBuiltinModule (Node ≥20.16) keeps this module free of a
|
|
@@ -2320,13 +2639,27 @@ function ownedMcpNote() {
|
|
|
2320
2639
|
// small-context model) skips the per-tool list — it duplicates the schemas attached to every request — and
|
|
2321
2640
|
// keeps only the surface summary; the list is also char-capped so a large merged map can't blow the prompt.
|
|
2322
2641
|
export function renderToolCatalogue(reg = registry, opts = {}) {
|
|
2642
|
+
const wordCut = (t, n) => {
|
|
2643
|
+
const cut = t.slice(0, n);
|
|
2644
|
+
const sp = cut.lastIndexOf(" ");
|
|
2645
|
+
return (sp > 60 ? cut.slice(0, sp) : cut) + "…";
|
|
2646
|
+
};
|
|
2323
2647
|
const short = (d) => {
|
|
2324
2648
|
const one = d.replace(/\s+/g, " ").trim();
|
|
2325
2649
|
if (one.length <= 150)
|
|
2326
2650
|
return one;
|
|
2327
|
-
const
|
|
2328
|
-
|
|
2329
|
-
|
|
2651
|
+
const m = PROHIBITION_RE.exec(one);
|
|
2652
|
+
if (!m)
|
|
2653
|
+
return wordCut(one, 150);
|
|
2654
|
+
// Never truncate a prohibition away: keep through the end of the sentence that carries it; if that is too long
|
|
2655
|
+
// to stay contiguous with the head, a short head + the prohibition sentence itself.
|
|
2656
|
+
const dot = one.indexOf(". ", m.index);
|
|
2657
|
+
const end = dot < 0 ? one.length : dot + 1;
|
|
2658
|
+
if (end <= CATALOGUE_LINE_MAX)
|
|
2659
|
+
return one.slice(0, end);
|
|
2660
|
+
const prev = one.lastIndexOf(". ", m.index);
|
|
2661
|
+
const clause = one.slice(prev < 0 ? 0 : prev + 2, end);
|
|
2662
|
+
return `${wordCut(one, 100)} ${clause.length > CATALOGUE_LINE_MAX ? one.slice(m.index, end) : clause}`;
|
|
2330
2663
|
};
|
|
2331
2664
|
let head;
|
|
2332
2665
|
if (opts.lean) {
|
|
@@ -2350,6 +2683,7 @@ export function renderToolCatalogue(reg = registry, opts = {}) {
|
|
|
2350
2683
|
}
|
|
2351
2684
|
return (`\n\n## Your capabilities — the full surface (use a tool you HAVE; don't claim one you don't)\n` +
|
|
2352
2685
|
head +
|
|
2686
|
+
renderCapabilityMap(reg) +
|
|
2353
2687
|
`\n\n**MCP tools** — with the MCP layer on (the owner types \`/mcp on\`) more tools load from configured servers and ` +
|
|
2354
2688
|
`appear alongside the native ones.` +
|
|
2355
2689
|
ownedMcpNote() +
|