@0perator/operator 0.1.360-next.1 → 0.2.0
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 +1 -1
- package/dist/autonomy/delegate-mode.js +159 -0
- package/dist/autonomy/delegate.js +1 -1
- package/dist/autonomy/session-factory.js +8 -2
- package/dist/background/index.js +26 -2
- package/dist/background/resume.js +125 -0
- package/dist/browser/engine.js +163 -0
- package/dist/browser/session.js +172 -134
- package/dist/cli.js +261 -70
- package/dist/config/settings.js +28 -7
- package/dist/config/skills-index.js +4 -0
- package/dist/engine/agent.js +1 -1
- package/dist/engine/aurora.js +22 -13
- package/dist/engine/compaction.js +1 -1
- package/dist/engine/moa.js +2 -1
- package/dist/engine/selfheal.js +1 -1
- package/dist/engine/speed-compaction.js +37 -0
- package/dist/engine/toolcalls.js +6 -6
- package/dist/gateway-cli.js +14 -5
- package/dist/index.js +3 -0
- package/dist/mcp/phone-server.js +30 -0
- package/dist/permissions/index.js +33 -17
- package/dist/permissions/signature.js +5 -0
- package/dist/phone-cli.js +65 -0
- package/dist/remote/host.js +31 -2
- package/dist/router/models.js +49 -25
- package/dist/selfimprove/index.js +1 -1
- package/dist/services/preflight.js +31 -8
- package/dist/session.js +96 -14
- package/dist/tools/deferred.js +1 -0
- package/dist/tools/device/android.js +227 -0
- package/dist/tools/device/classify.js +127 -0
- package/dist/tools/device/deps.js +69 -0
- package/dist/tools/device/desktop.js +82 -0
- package/dist/tools/device/harness.js +262 -0
- package/dist/tools/device/iphone.js +206 -0
- package/dist/tools/device/mirroring-jxa.js +146 -0
- package/dist/tools/device/setup.js +90 -0
- package/dist/tools/device/tools.js +70 -0
- package/dist/tools/device/types.js +19 -0
- package/dist/tools/registry.js +242 -48
- package/dist/tools/vision-media.js +162 -0
- package/dist/ui/App.js +4 -3
- package/dist/ui/ApprovalPrompt.js +10 -4
- package/dist/ui/BgPanel.js +2 -2
- package/dist/ui/UpdatePrompt.js +40 -0
- package/dist/ui/modelPicker.js +26 -8
- package/dist/ui/slashCommands.js +1 -0
- package/dist/update-check.js +134 -0
- package/dist/update.js +82 -13
- package/dist/util/slash.js +2 -2
- package/package.json +4 -2
- package/src/tools/device/NOTICE +37 -0
- package/dist/browser/cdp.js +0 -271
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// `operator phone setup` and phone_status: scan every backend this OS has, print a checklist (✓ done, ✗ the step that
|
|
2
|
+
// is missing, · not reached yet, – not available on this OS) and the ONE next action. It only reads: no app is opened,
|
|
3
|
+
// no permission is requested (macOS never shows a dialog for it), nothing is tapped. The optional last step — one
|
|
4
|
+
// screenshot and a vision description — runs only when the owner says yes.
|
|
5
|
+
import { deviceDeps } from "./deps.js";
|
|
6
|
+
import { osName } from "./desktop.js";
|
|
7
|
+
import { scanDevices, phoneScreenshot } from "./harness.js";
|
|
8
|
+
const failure = (s) => (s.fix ? `${s.detail} → ${s.fix}` : s.detail);
|
|
9
|
+
function ladder(steps, failedAt, failText) {
|
|
10
|
+
return steps.map((text, i) => i < failedAt ? { mark: "✓", text } : i === failedAt ? { mark: "✗", text: failText ? `${text} — ${failText}` : text } : { mark: "·", text });
|
|
11
|
+
}
|
|
12
|
+
function androidItems(s) {
|
|
13
|
+
const steps = ["adb installed", "phone plugged in (USB debugging on)", "this computer allowed on the phone", "phone unlocked"];
|
|
14
|
+
const at = { "missing-tool": 0, "no-device": 1, unauthorized: 2, offline: 2, locked: 3, ready: 4, unreachable: 0 };
|
|
15
|
+
const items = ladder(steps, at[s.state] ?? 0, s.state === "ready" ? undefined : failure(s));
|
|
16
|
+
if (s.state === "ready")
|
|
17
|
+
items.push({ mark: "✓", text: s.detail });
|
|
18
|
+
return items;
|
|
19
|
+
}
|
|
20
|
+
function iphoneItems(s) {
|
|
21
|
+
if (s.state === "unsupported" && !/macOS \d/.test(s.detail))
|
|
22
|
+
return [{ mark: "–", text: s.detail }];
|
|
23
|
+
const steps = ["macOS 15 or later", "iPhone Mirroring app present", "Accessibility permission", "Screen Recording permission", "iPhone Mirroring open", "iPhone paired", "mirroring session live"];
|
|
24
|
+
let at = 7;
|
|
25
|
+
if (s.state === "unsupported")
|
|
26
|
+
at = 0;
|
|
27
|
+
else if (s.state === "missing-tool")
|
|
28
|
+
at = 1;
|
|
29
|
+
else if (s.state === "permission")
|
|
30
|
+
at = /Accessibility/.test(s.detail) ? 2 : 3;
|
|
31
|
+
else if (s.state === "not-running")
|
|
32
|
+
at = 4;
|
|
33
|
+
else if (s.state === "not-paired")
|
|
34
|
+
at = 5;
|
|
35
|
+
else if (s.state === "blocked" || s.state === "unreachable")
|
|
36
|
+
at = 6;
|
|
37
|
+
const items = ladder(steps, at, s.state === "ready" ? undefined : failure(s));
|
|
38
|
+
if (s.state === "ready")
|
|
39
|
+
items.push({ mark: "✓", text: s.detail });
|
|
40
|
+
return items;
|
|
41
|
+
}
|
|
42
|
+
function desktopItems(s) {
|
|
43
|
+
if (s.state === "unsupported")
|
|
44
|
+
return [{ mark: "–", text: s.detail }];
|
|
45
|
+
return [{ mark: s.state === "ready" ? "✓" : "✗", text: s.state === "ready" ? "Chauffeur reachable (this Mac)" : `Chauffeur reachable — ${failure(s)}` }];
|
|
46
|
+
}
|
|
47
|
+
// How far along a backend got, to pick the next action from the one closest to working.
|
|
48
|
+
const PROGRESS = { "missing-tool": 1, "no-device": 2, unauthorized: 3, offline: 3, permission: 3, "not-running": 4, "not-paired": 5, locked: 6, blocked: 6 };
|
|
49
|
+
export async function setupReport() {
|
|
50
|
+
const statuses = await scanDevices();
|
|
51
|
+
const by = (k) => statuses.find((s) => s.kind === k);
|
|
52
|
+
const sections = [
|
|
53
|
+
{ title: "Android (adb)", items: androidItems(by("android")) },
|
|
54
|
+
{ title: "iPhone (iPhone Mirroring)", items: iphoneItems(by("iphone")) },
|
|
55
|
+
{ title: `Desktop (${osName(deviceDeps().platform)})`, items: desktopItems(by("desktop")) },
|
|
56
|
+
];
|
|
57
|
+
const ready = statuses.filter((s) => s.state === "ready" && s.kind !== "desktop").map((s) => s.kind);
|
|
58
|
+
let next;
|
|
59
|
+
if (ready.length)
|
|
60
|
+
next = `ready: ${ready.join(" and ")}. Optional last step: one screenshot + a description to confirm Operator sees the phone.`;
|
|
61
|
+
else {
|
|
62
|
+
const phones = statuses.filter((s) => s.kind !== "desktop" && s.fix && s.state !== "unsupported");
|
|
63
|
+
const best = phones.sort((a, b) => (PROGRESS[b.state] ?? 0) - (PROGRESS[a.state] ?? 0))[0];
|
|
64
|
+
next = best ? `${best.kind}: ${best.fix}` : "plug in an Android phone with USB debugging on, or open iPhone Mirroring on a Mac with macOS 15+";
|
|
65
|
+
}
|
|
66
|
+
return { os: osName(deviceDeps().platform), sections, next, ready, statuses };
|
|
67
|
+
}
|
|
68
|
+
export function renderSetup(r) {
|
|
69
|
+
const lines = [`Phone setup — ${r.os}`, ""];
|
|
70
|
+
for (const s of r.sections) {
|
|
71
|
+
lines.push(s.title);
|
|
72
|
+
for (const i of s.items)
|
|
73
|
+
lines.push(` ${i.mark} ${i.text}`);
|
|
74
|
+
lines.push("");
|
|
75
|
+
}
|
|
76
|
+
lines.push(`Next: ${r.next}`);
|
|
77
|
+
return lines.join("\n");
|
|
78
|
+
}
|
|
79
|
+
/** The harmless read-only check: one screenshot of the ready phone and what vision sees on it. */
|
|
80
|
+
export async function readOnlyCheck(device) {
|
|
81
|
+
return phoneScreenshot({ ...(device ? { device } : {}), describe: true });
|
|
82
|
+
}
|
|
83
|
+
/** phone_status: the same checklist; `check: true` adds the read-only screenshot + description (the caller confirmed). */
|
|
84
|
+
export async function phoneStatus(args) {
|
|
85
|
+
const r = await setupReport();
|
|
86
|
+
const text = renderSetup(r);
|
|
87
|
+
if (args.check !== true || !r.ready.length)
|
|
88
|
+
return text;
|
|
89
|
+
return `${text}\n\n--- read-only check ---\n${await readOnlyCheck(typeof args.device === "string" ? args.device : undefined)}`;
|
|
90
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { phoneKey, phoneOpenApp, phoneRead, phoneScreenshot, phoneSwipe, phoneTap, phoneType } from "./harness.js";
|
|
2
|
+
import { phoneStatus } from "./setup.js";
|
|
3
|
+
import { DEVICE_KEYS } from "./types.js";
|
|
4
|
+
const BINS = ["adb", "osascript", "screencapture", "chauffeur-local", "chauffeur", "sh"];
|
|
5
|
+
const device = { type: "string", description: 'iphone | android | desktop | an adb serial; default: the one phone that is ready' };
|
|
6
|
+
const intent = { type: "string", enum: ["spend", "send", "account"], description: "declare it when the step pays, sends or changes an account: the owner is asked with a screenshot" };
|
|
7
|
+
const verify = { type: "boolean", description: "default true: a screenshot after the action (its path is returned)" };
|
|
8
|
+
const describe = { type: "boolean", description: "also describe the after screenshot with vision" };
|
|
9
|
+
const ACTION = { v: 1, effects: ["device"], bins: BINS, audit: ["device", "x", "y", "key", "name", "direction"] };
|
|
10
|
+
export const PHONE_TOOLS = [
|
|
11
|
+
{
|
|
12
|
+
name: "phone_status",
|
|
13
|
+
contract: { v: 1, effects: ["read", "device"], bins: [...BINS, "sw_vers"] },
|
|
14
|
+
description: "Setup checklist: which phones and screens Operator can drive here (iPhone via iPhone Mirroring, Android via adb, this desktop), what is done, what is missing, and the one next action.",
|
|
15
|
+
parameters: { type: "object", properties: { check: { type: "boolean", description: "also take one screenshot and describe it (read-only); only after the owner said yes" }, device } },
|
|
16
|
+
run: phoneStatus,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "phone_screenshot",
|
|
20
|
+
contract: { v: 1, effects: ["device", "write"], bins: BINS },
|
|
21
|
+
description: "Screenshot the phone (or desktop): returns the PNG path and its pixel size. Coordinates for phone_tap and phone_swipe are pixels in this image. describe: true adds a vision description.",
|
|
22
|
+
parameters: { type: "object", properties: { device, describe: { type: "boolean" }, question: { type: "string", description: "what to ask vision about the screen" } } },
|
|
23
|
+
run: phoneScreenshot,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "phone_read",
|
|
27
|
+
contract: { v: 1, effects: ["device", "write"], bins: BINS },
|
|
28
|
+
description: "Read the text on the phone screen with positions: Android's accessibility tree, the iPhone window's OCR, Chauffeur on the desktop; vision when none can read it.",
|
|
29
|
+
parameters: { type: "object", properties: { device, vision: { type: "boolean", description: "default true: fall back to vision when no text is readable" } } },
|
|
30
|
+
run: phoneRead,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "phone_tap",
|
|
34
|
+
contract: ACTION,
|
|
35
|
+
description: "Tap on the phone: by x, y (pixels in the latest phone_screenshot) or by the visible text of a button. Screenshot after by default.",
|
|
36
|
+
parameters: { type: "object", properties: { device, x: { type: "number" }, y: { type: "number" }, text: { type: "string", description: "visible label to tap instead of x, y" }, intent, verify, describe } },
|
|
37
|
+
run: phoneTap,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "phone_type",
|
|
41
|
+
contract: ACTION,
|
|
42
|
+
description: "Type text into the focused field on the phone (iPhone: pasted, exact; Android: ASCII). submit: true presses enter after it. Tap the field first.",
|
|
43
|
+
parameters: { type: "object", properties: { device, text: { type: "string" }, submit: { type: "boolean" }, keystrokes: { type: "boolean", description: "iPhone: real key presses instead of paste (US layout, autocorrect applies)" }, intent, verify, describe }, required: ["text"] },
|
|
44
|
+
run: phoneType,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "phone_swipe",
|
|
48
|
+
contract: ACTION,
|
|
49
|
+
description: "Swipe on the phone: direction up/down/left/right (\"up\" scrolls to content further down), or x1, y1 → x2, y2 in screenshot pixels.",
|
|
50
|
+
parameters: { type: "object", properties: { device, direction: { type: "string", enum: ["up", "down", "left", "right"] }, x1: { type: "number" }, y1: { type: "number" }, x2: { type: "number" }, y2: { type: "number" }, duration_ms: { type: "number" }, text: { type: "string", description: "the control it slides, e.g. \"slide to pay\"" }, intent, verify, describe } },
|
|
51
|
+
run: phoneSwipe,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "phone_key",
|
|
55
|
+
contract: ACTION,
|
|
56
|
+
description: "Press a key on the phone: home, back (Android only), recents, enter, delete, volume, … iPhone home/recents/search are Mirroring's Cmd+1/2/3.",
|
|
57
|
+
parameters: { type: "object", properties: { device, key: { type: "string", enum: [...DEVICE_KEYS] }, intent, verify, describe }, required: ["key"] },
|
|
58
|
+
run: phoneKey,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "phone_open_app",
|
|
62
|
+
contract: ACTION,
|
|
63
|
+
description: "Open an app on the phone by name (\"Settings\", \"Maps\"); on Android a package id works too. iPhone opens it through Spotlight.",
|
|
64
|
+
parameters: { type: "object", properties: { device, name: { type: "string" }, verify, describe }, required: ["name"] },
|
|
65
|
+
run: phoneOpenApp,
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
export const PHONE_TOOL_NAMES = PHONE_TOOLS.map((t) => t.name);
|
|
69
|
+
/** The tools that act (and ask outside Autonomous mode); the reads run unprompted like chauffeur's reads. */
|
|
70
|
+
export const PHONE_ACTION_NAMES = ["phone_tap", "phone_type", "phone_swipe", "phone_key", "phone_open_app"];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// One interface for every screen Operator drives: the macOS desktop, an iPhone through iPhone Mirroring, an Android
|
|
2
|
+
// phone over adb, and the Windows / Linux desktops still to come. A backend owns everything platform-specific; the
|
|
3
|
+
// tools, the permission gate, the audit trail and the skill are shared (harness.ts, tools.ts). Coordinates are always
|
|
4
|
+
// in the pixels of the backend's latest screenshot, the image the model looked at.
|
|
5
|
+
/** Keys a phone or desktop understands by name. Not every backend has every key (iOS has no Back). */
|
|
6
|
+
export const DEVICE_KEYS = ["home", "back", "recents", "enter", "delete", "tab", "space", "escape", "up", "down", "left",
|
|
7
|
+
"right", "volume_up", "volume_down", "power", "search", "menu"];
|
|
8
|
+
export class Unsupported extends Error {
|
|
9
|
+
constructor(message) { super(message); this.name = "Unsupported"; }
|
|
10
|
+
}
|
|
11
|
+
/** A device the owner has to act on before Operator can (plug in, unlock, tap Allow, grant a permission). */
|
|
12
|
+
export class NeedsOwner extends Error {
|
|
13
|
+
fix;
|
|
14
|
+
constructor(message, fix) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.fix = fix;
|
|
17
|
+
this.name = "NeedsOwner";
|
|
18
|
+
}
|
|
19
|
+
}
|
package/dist/tools/registry.js
CHANGED
|
@@ -26,6 +26,7 @@ import { findFiles, FIND_FILES_DEFAULT_LIMIT, FIND_FILES_MAX_LIMIT, KINDS } from
|
|
|
26
26
|
import { formatGitStatus } from "./git-status.js";
|
|
27
27
|
import { DOC_TEXT_EXTS, describeDocText, docExt, extractDocText } from "./doc-text.js";
|
|
28
28
|
import { askVision, visionGateways, VISION_LIMITS } from "./vision-gateway.js";
|
|
29
|
+
import { DESIGN_PROBE_JS, DESIGN_QUESTION, MEDIA_CAPS, downloadVideoPage, evenTimes, fmtTime, formatDesignRead, grabFrames, isVideoPageUrl, parseTimestamps } from "./vision-media.js";
|
|
29
30
|
import { expandPath, assertContentSearchScope, assertShellHomeWideSearch, assertShellBlindDownload } from "./paths.js";
|
|
30
31
|
import { resolveReadPath } from "./read-path.js";
|
|
31
32
|
import { recordRead, getRead, forgetReads, seenView } from "./read-ledger.js"; // per-session read-state (pure, node-free — stays out of the neutral graph)
|
|
@@ -44,7 +45,7 @@ import { BYO_PRESETS } from "../router/models.js";
|
|
|
44
45
|
const BYO_DELEGATE_PROVIDERS = Object.keys(BYO_PRESETS).join(", ");
|
|
45
46
|
import { runSessionRewind } from "../memory/session-rewind.js";
|
|
46
47
|
import { runSkillCatalog } from "../skills/catalogue.js";
|
|
47
|
-
import { runBrowser, runBrowserRead } from "../browser/session.js";
|
|
48
|
+
import { runBrowser, runBrowserRead, pageCaptureHooks } from "../browser/session.js";
|
|
48
49
|
import { deniedWriteAsync, deniedReadAsync, wrapShell } from "./sandbox.js";
|
|
49
50
|
import { ensureSearxng, noteSearxngUsed } from "./searxng.js";
|
|
50
51
|
// execFile helper lives in ./exec (shared with computer.ts — one copy, not two).
|
|
@@ -1856,11 +1857,56 @@ async function flatColour(pexec, image, bmp) {
|
|
|
1856
1857
|
}
|
|
1857
1858
|
// Only a file this light for its pixel count is checked for flatness: a real picture never pays the extra sips call.
|
|
1858
1859
|
const BLANK_BYTES_PER_PX = 0.1;
|
|
1860
|
+
const IMAGE_URL_MAX_BYTES = 25_000_000;
|
|
1861
|
+
// A vision server may not fetch URLs (llama-server built without TLS answers "HTTPS is not supported"), so an
|
|
1862
|
+
// http(s) image is downloaded here and sent as bytes, like a local file.
|
|
1863
|
+
async function fetchImageToTemp(url) {
|
|
1864
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(30_000), headers: { "user-agent": "Mozilla/5.0 (Operator image_analyze)" } });
|
|
1865
|
+
if (!res.ok)
|
|
1866
|
+
throw new Error(`${url} returned ${res.status}`);
|
|
1867
|
+
const type = (res.headers.get("content-type") || "").split(";")[0].trim();
|
|
1868
|
+
if (type && !type.startsWith("image/"))
|
|
1869
|
+
throw new Error(`${url} is ${type}, not an image`);
|
|
1870
|
+
const buf = Buffer.from(await res.arrayBuffer());
|
|
1871
|
+
if (buf.length > IMAGE_URL_MAX_BYTES)
|
|
1872
|
+
throw new Error(`${url} is ${buf.length} bytes (cap ${IMAGE_URL_MAX_BYTES})`);
|
|
1873
|
+
const ext = type === "image/jpeg" ? "jpg" : type === "image/webp" ? "webp" : type === "image/gif" ? "gif" : "png";
|
|
1874
|
+
const os = await nodeImport("node:os");
|
|
1875
|
+
const { join } = await nodeImport("node:path");
|
|
1876
|
+
const { mkdtemp, writeFile } = await nodeImport("node:fs/promises");
|
|
1877
|
+
const file = join(await mkdtemp(join(os.tmpdir(), "axe-iu-")), `image.${ext}`);
|
|
1878
|
+
await writeFile(file, buf);
|
|
1879
|
+
return file;
|
|
1880
|
+
}
|
|
1881
|
+
// A transparent image is flattened onto white first: measured 11/25, the same Google wordmark read as "Coca-Cola"
|
|
1882
|
+
// with its alpha channel and as "the Google logo" on white. No ffprobe/ffmpeg, or no alpha: the image is unchanged.
|
|
1883
|
+
async function flattenAlpha(image) {
|
|
1884
|
+
if (!/\.(png|webp|gif)$/i.test(image))
|
|
1885
|
+
return image;
|
|
1886
|
+
try {
|
|
1887
|
+
const { execFile } = await nodeImport("node:child_process");
|
|
1888
|
+
const { promisify } = await nodeImport("node:util");
|
|
1889
|
+
const pexec = promisify(execFile);
|
|
1890
|
+
const { stdout } = await pexec("ffprobe", ["-v", "error", "-select_streams", "v:0", "-show_entries", "stream=pix_fmt", "-of", "csv=p=0", image]);
|
|
1891
|
+
if (!/a|pal8/.test(stdout.trim()))
|
|
1892
|
+
return image;
|
|
1893
|
+
const os = await nodeImport("node:os");
|
|
1894
|
+
const { join } = await nodeImport("node:path");
|
|
1895
|
+
const { mkdtemp } = await nodeImport("node:fs/promises");
|
|
1896
|
+
const out = join(await mkdtemp(join(os.tmpdir(), "axe-ia-")), "flat.png");
|
|
1897
|
+
await pexec("ffmpeg", ["-v", "error", "-y", "-i", image, "-filter_complex", "color=white,format=rgb24[bg];[bg][0:v]scale2ref[bg][fg];[bg][fg]overlay=shortest=1:format=auto,format=rgb24", "-frames:v", "1", out]);
|
|
1898
|
+
return out;
|
|
1899
|
+
}
|
|
1900
|
+
catch {
|
|
1901
|
+
return image;
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1859
1904
|
async function visionImageDataUrl(image, lim) {
|
|
1860
1905
|
image = await absMediaPath(image);
|
|
1861
1906
|
if (/^https?:\/\//.test(image))
|
|
1862
|
-
|
|
1907
|
+
image = await fetchImageToTemp(image);
|
|
1863
1908
|
image = await renderDocForVision(image); // a document becomes a rendered PNG; an image is unchanged
|
|
1909
|
+
image = await flattenAlpha(image);
|
|
1864
1910
|
const { readFile } = await nodeImport("node:fs/promises");
|
|
1865
1911
|
const orig = await readFile(image).catch(() => null);
|
|
1866
1912
|
if (!orig)
|
|
@@ -1895,6 +1941,15 @@ async function visionImageDataUrl(image, lim) {
|
|
|
1895
1941
|
shrank = true;
|
|
1896
1942
|
}
|
|
1897
1943
|
catch {
|
|
1944
|
+
try {
|
|
1945
|
+
// Without sips the size comes from ffprobe, so an image already small enough keeps its own bytes and
|
|
1946
|
+
// type on every OS instead of being re-encoded as JPEG.
|
|
1947
|
+
const { stdout } = await pexec("ffprobe", ["-v", "error", "-select_streams", "v:0", "-show_entries", "stream=width,height", "-of", "csv=p=0:s=x", image]);
|
|
1948
|
+
const [w, h] = stdout.trim().split("x").map(Number);
|
|
1949
|
+
if (w && h && Math.max(w, h) <= lim.maxEdge && buf.length <= lim.maxBytes)
|
|
1950
|
+
return { url: `data:${mime};base64,${buf.toString("base64")}` };
|
|
1951
|
+
}
|
|
1952
|
+
catch { /* no ffprobe: fall through to the resize */ }
|
|
1898
1953
|
try {
|
|
1899
1954
|
// non-macOS / sips missing → ffmpeg; min() clamps the fit-box to the image so it never upscales.
|
|
1900
1955
|
await pexec("ffmpeg", ["-nostdin", "-y", "-loglevel", "error", "-i", image, "-vf", `scale='min(iw,${lim.maxEdge})':'min(ih,${lim.maxEdge})':force_original_aspect_ratio=decrease`, out]);
|
|
@@ -1968,6 +2023,13 @@ async function imageInspect(args) {
|
|
|
1968
2023
|
const image = str(args.image);
|
|
1969
2024
|
if (!image)
|
|
1970
2025
|
return "error: image_inspect needs an image (a local path or an http(s) url)";
|
|
2026
|
+
const facts = await imageFacts(image);
|
|
2027
|
+
if (typeof facts === "string")
|
|
2028
|
+
return `error: image_inspect ${facts}`;
|
|
2029
|
+
return Object.entries(facts).map(([k, v]) => `${k}: ${typeof v === "object" ? JSON.stringify(v) : v}`).join("\n");
|
|
2030
|
+
}
|
|
2031
|
+
/** image_inspect's measurements as an object, or why there are none ("could not …" / "— <reason> (needs …)"). */
|
|
2032
|
+
async function imageFacts(image) {
|
|
1971
2033
|
const os = await nodeImport("node:os");
|
|
1972
2034
|
const { join } = await nodeImport("node:path");
|
|
1973
2035
|
const { mkdtemp, writeFile, rm, stat } = await nodeImport("node:fs/promises");
|
|
@@ -1980,31 +2042,33 @@ async function imageInspect(args) {
|
|
|
1980
2042
|
if (/^https?:\/\//.test(image)) {
|
|
1981
2043
|
const res = await fetch(image).catch(() => null);
|
|
1982
2044
|
if (!res || !res.ok)
|
|
1983
|
-
return `
|
|
2045
|
+
return `could not fetch ${image}`;
|
|
1984
2046
|
path = join(dir, "img");
|
|
1985
2047
|
await writeFile(path, Buffer.from(await res.arrayBuffer()));
|
|
1986
2048
|
}
|
|
1987
2049
|
else if (!(await stat(path).catch(() => null))) {
|
|
1988
|
-
return `
|
|
2050
|
+
return `could not read a file at ${image}`;
|
|
1989
2051
|
}
|
|
1990
2052
|
const script = join(dir, "inspect.py");
|
|
1991
2053
|
await writeFile(script, IMAGE_INSPECT_PY);
|
|
1992
2054
|
const { stdout } = await pexec("python3", ["-I", script, path]);
|
|
1993
|
-
|
|
1994
|
-
return Object.entries(facts).map(([k, v]) => `${k}: ${typeof v === "object" ? JSON.stringify(v) : v}`).join("\n");
|
|
2055
|
+
return JSON.parse(stdout.trim());
|
|
1995
2056
|
}
|
|
1996
2057
|
catch (e) {
|
|
1997
|
-
return
|
|
2058
|
+
return `— ${String(e?.message ?? e)} (needs python3 + Pillow; for SEMANTIC questions use image_analyze instead)`;
|
|
1998
2059
|
}
|
|
1999
2060
|
finally {
|
|
2000
2061
|
await rm(dir, { recursive: true, force: true }).catch(() => { });
|
|
2001
2062
|
}
|
|
2002
2063
|
}
|
|
2064
|
+
const flag = (v) => v === true || str(v) === "true";
|
|
2003
2065
|
async function imageAnalyze(args) {
|
|
2066
|
+
if (str(args.page))
|
|
2067
|
+
return analyzePage(args);
|
|
2004
2068
|
const raw = str(args.image);
|
|
2005
2069
|
const image = /^https?:\/\//.test(raw) ? raw : await resolveReadPath(raw);
|
|
2006
2070
|
if (!image)
|
|
2007
|
-
return "error: image_analyze needs an image or document (a local path or an http(s) url)";
|
|
2071
|
+
return "error: image_analyze needs an image or document (a local path or an http(s) url), or a web `page` url";
|
|
2008
2072
|
if (!/^https?:\/\//.test(image)) {
|
|
2009
2073
|
const blocked = await deniedReadAsync(image); // same credential-path guard as file_read: it now returns document TEXT
|
|
2010
2074
|
if (blocked)
|
|
@@ -2027,29 +2091,104 @@ async function imageAnalyze(args) {
|
|
|
2027
2091
|
// downscales a large local image first; http(s) passes through
|
|
2028
2092
|
img = await visionImageDataUrl(image, { maxEdge: visionLimit(v, "maxEdge", 256), maxBytes: visionLimit(v, "maxBytes", 100_000) });
|
|
2029
2093
|
}
|
|
2030
|
-
catch {
|
|
2031
|
-
return
|
|
2094
|
+
catch (e) {
|
|
2095
|
+
return /^https?:\/\//.test(image)
|
|
2096
|
+
? `error: image_analyze could not download ${image}: ${e.message}`
|
|
2097
|
+
: `error: image_analyze could not read a file at ${image} (pass a local path or an http(s) url)`;
|
|
2032
2098
|
}
|
|
2033
2099
|
if ("blank" in img)
|
|
2034
2100
|
return `error: image is blank (${img.blank}) — ${image}. Nothing to analyze; capture it again.`;
|
|
2035
|
-
const
|
|
2101
|
+
const design = flag(args.design);
|
|
2102
|
+
const ask = design ? designQuestion(args) : question;
|
|
2103
|
+
const parts = [{ type: "text", text: ask }, { type: "image_url", image_url: { url: img.url } }];
|
|
2036
2104
|
try {
|
|
2037
|
-
|
|
2105
|
+
const seen = await visionComplete(parts, args, v);
|
|
2106
|
+
if (!design)
|
|
2107
|
+
return seen;
|
|
2108
|
+
const facts = await imageFacts(image);
|
|
2109
|
+
return formatDesignRead({ source: image, seen, ...measuredPixels(facts) });
|
|
2038
2110
|
}
|
|
2039
2111
|
catch (e) {
|
|
2040
2112
|
return `error: ${String(e?.message ?? e)}`;
|
|
2041
2113
|
}
|
|
2042
2114
|
}
|
|
2115
|
+
const designQuestion = (args) => str(args.question) ? `${DESIGN_QUESTION} Also answer: ${str(args.question)}` : DESIGN_QUESTION;
|
|
2116
|
+
function measuredPixels(facts) {
|
|
2117
|
+
if (typeof facts === "string")
|
|
2118
|
+
return { paletteNote: `image_inspect ${facts}` };
|
|
2119
|
+
const palette = Array.isArray(facts.dominant_colors) ? facts.dominant_colors : [];
|
|
2120
|
+
return { size: `${facts.width}×${facts.height} px`, palette, ...(palette.length ? {} : { paletteNote: "Pillow returned no colours" }) };
|
|
2121
|
+
}
|
|
2122
|
+
// image_analyze `page`: render a web page in the `browser` tool's headless Chrome (a tab of its own), save the
|
|
2123
|
+
// screenshot, then ask vision. A long full-page capture goes to vision as viewport slices, top to bottom. `design`
|
|
2124
|
+
// adds what the page's CSS computes and the screenshot's real palette above the model's read.
|
|
2125
|
+
const PAGE_VIEW = { width: 1280, height: 800, tiles: 4 };
|
|
2126
|
+
async function analyzePage(args) {
|
|
2127
|
+
const page = str(args.page);
|
|
2128
|
+
if (!/^https?:\/\//.test(page))
|
|
2129
|
+
return "error: page must be an http(s) url (a local file goes in `image`)";
|
|
2130
|
+
const design = flag(args.design);
|
|
2131
|
+
let shot;
|
|
2132
|
+
try {
|
|
2133
|
+
shot = await pageCaptureHooks.capture(page, { ...PAGE_VIEW, fullPage: flag(args.full_page), probe: design ? DESIGN_PROBE_JS : undefined });
|
|
2134
|
+
}
|
|
2135
|
+
catch (e) {
|
|
2136
|
+
return `error: could not render ${page} — ${String(e?.message ?? e)}`;
|
|
2137
|
+
}
|
|
2138
|
+
const cut = shot.height < shot.fullHeight && flag(args.full_page) ? `, cut at ${shot.height} of ${shot.fullHeight} px` : "";
|
|
2139
|
+
const head = `page ${shot.finalUrl}${shot.status && shot.status >= 400 ? ` (HTTP ${shot.status})` : ""} — "${shot.title}"\nscreenshot ${shot.path} (${shot.width}×${shot.height}${cut})`;
|
|
2140
|
+
if (shot.loadError)
|
|
2141
|
+
return `error: ${page} did not load (${shot.loadError}). Screenshot of what Chrome showed: ${shot.path}`;
|
|
2142
|
+
const v = await visionSettings();
|
|
2143
|
+
const images = shot.tiles.length ? shot.tiles : [shot.path];
|
|
2144
|
+
// Several slices are read in one request: smaller slices keep it inside a CPU vision server's window and time.
|
|
2145
|
+
const lim = { maxEdge: Math.min(visionLimit(v, "maxEdge", 256), images.length > 1 ? 1024 : Infinity), maxBytes: visionLimit(v, "maxBytes", 100_000) };
|
|
2146
|
+
if (images.length > 1 && args.timeout_ms === undefined)
|
|
2147
|
+
args = { ...args, timeout_ms: 300_000 };
|
|
2148
|
+
const question = design ? designQuestion(args) : str(args.question) || "Describe this web page as rendered: what it is, its layout, and the visible text that matters.";
|
|
2149
|
+
const parts = [{ type: "text", text: images.length > 1 ? `${question} (${images.length} slices of one page, top to bottom)` : question }];
|
|
2150
|
+
for (const p of images) {
|
|
2151
|
+
const img = await visionImageDataUrl(p, lim).catch(() => null);
|
|
2152
|
+
if (!img)
|
|
2153
|
+
return `${head}\nerror: could not read the screenshot back`;
|
|
2154
|
+
if ("blank" in img)
|
|
2155
|
+
return `${head}\nerror: the page rendered blank (${img.blank}) — nothing to analyze`;
|
|
2156
|
+
parts.push({ type: "image_url", image_url: { url: img.url } });
|
|
2157
|
+
}
|
|
2158
|
+
let seen;
|
|
2159
|
+
try {
|
|
2160
|
+
seen = await visionComplete(parts, args, v);
|
|
2161
|
+
}
|
|
2162
|
+
catch (e) {
|
|
2163
|
+
return `${head}\nerror: ${String(e?.message ?? e)}`;
|
|
2164
|
+
}
|
|
2165
|
+
if (!design)
|
|
2166
|
+
return `${head}\n\n${seen}`;
|
|
2167
|
+
const css = shot.probe && typeof shot.probe === "object" ? shot.probe : undefined;
|
|
2168
|
+
const pixels = measuredPixels(await imageFacts(shot.path));
|
|
2169
|
+
return `${head}\n\n${formatDesignRead({ source: shot.finalUrl, seen, ...pixels, ...(css ? { css } : {}) })}`;
|
|
2170
|
+
}
|
|
2043
2171
|
// video_analyze — real video understanding: ffmpeg samples frames evenly across the clip, then the VL model
|
|
2044
|
-
// (same
|
|
2172
|
+
// (same vision endpoint, multi-image) describes what happens. Needs ffmpeg on PATH; verified the model
|
|
2045
2173
|
// synthesizes motion from ordered frames ("calm ocean with gentle waves, golden hue").
|
|
2174
|
+
// A video PAGE link (YouTube, Vimeo, … or any url that answers HTML) resolves to a file through yt-dlp, inside
|
|
2175
|
+
// MEDIA_CAPS; frames are single ffmpeg seeks at `timestamps` or evenly spaced times, so a long video is never decoded
|
|
2176
|
+
// whole. `save_frames` / `analyze: false` keep the frames as PNGs in Operator's cache and return their paths;
|
|
2177
|
+
// analyze: false asks no model.
|
|
2046
2178
|
async function videoAnalyze(args) {
|
|
2047
|
-
const
|
|
2179
|
+
const raw = str(args.video);
|
|
2180
|
+
const isUrl = /^https?:\/\//.test(raw);
|
|
2181
|
+
const video = !raw ? "" : isUrl ? raw : await absMediaPath(await resolveReadPath(raw));
|
|
2048
2182
|
if (!video)
|
|
2049
|
-
return "error: video_analyze needs a video (a local path
|
|
2183
|
+
return "error: video_analyze needs a video (a local path, an http(s) video url, or a video page link)";
|
|
2050
2184
|
const question = str(args.question) || "These frames are sampled in order across a video. Describe what happens across the video.";
|
|
2051
|
-
const
|
|
2052
|
-
|
|
2185
|
+
const times = parseTimestamps(args.timestamps);
|
|
2186
|
+
if (typeof times === "string")
|
|
2187
|
+
return `error: video_analyze ${times}`;
|
|
2188
|
+
const nFrames = times.length || Math.max(2, Math.min(Number(args.frames) || 8, MEDIA_CAPS.maxFrames));
|
|
2189
|
+
const analyze = args.analyze !== false && str(args.analyze) !== "false";
|
|
2190
|
+
const caps = { maxDurationS: Number(args.max_duration_s) > 0 ? Number(args.max_duration_s) : MEDIA_CAPS.maxDurationS, maxBytes: MEDIA_CAPS.maxBytes };
|
|
2191
|
+
const { mkdtemp, mkdir, readFile, rm, writeFile, readdir } = await nodeImport("node:fs/promises");
|
|
2053
2192
|
const os = await nodeImport("node:os");
|
|
2054
2193
|
const { join } = await nodeImport("node:path");
|
|
2055
2194
|
const { execFile } = await nodeImport("node:child_process");
|
|
@@ -2058,39 +2197,87 @@ async function videoAnalyze(args) {
|
|
|
2058
2197
|
const dir = await mkdtemp(join(os.tmpdir(), "axe-va-"));
|
|
2059
2198
|
try {
|
|
2060
2199
|
let src = video;
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2200
|
+
let title = "";
|
|
2201
|
+
if (isUrl) {
|
|
2202
|
+
let page = isVideoPageUrl(video);
|
|
2203
|
+
if (!page) {
|
|
2204
|
+
const r = await fetch(video).catch(() => null);
|
|
2205
|
+
if (!r || !r.ok)
|
|
2206
|
+
return `error: video_analyze could not fetch ${video}${r ? ` (HTTP ${r.status})` : ""}`;
|
|
2207
|
+
page = /text\/html/i.test(r.headers.get("content-type") ?? "");
|
|
2208
|
+
const size = Number(r.headers.get("content-length")) || 0;
|
|
2209
|
+
if (page || size > caps.maxBytes)
|
|
2210
|
+
await r.body?.cancel().catch(() => { });
|
|
2211
|
+
if (!page && size > caps.maxBytes)
|
|
2212
|
+
return `error: ${video} is ${Math.round(size / 1e6)} MB, over the ${caps.maxBytes / 1e6} MB cap`;
|
|
2213
|
+
if (!page) {
|
|
2214
|
+
src = join(dir, "src.mp4");
|
|
2215
|
+
await writeFile(src, Buffer.from(await r.arrayBuffer()));
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
if (page) {
|
|
2219
|
+
const got = await downloadVideoPage(video, dir, caps);
|
|
2220
|
+
if ("error" in got)
|
|
2221
|
+
return `error: ${got.error}`;
|
|
2222
|
+
src = got.path;
|
|
2223
|
+
title = got.title;
|
|
2224
|
+
}
|
|
2074
2225
|
}
|
|
2075
|
-
|
|
2226
|
+
let duration = 0;
|
|
2076
2227
|
try {
|
|
2077
|
-
await pexec("
|
|
2228
|
+
const { stdout } = await pexec("ffprobe", ["-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", src]);
|
|
2229
|
+
duration = parseFloat(stdout.trim()) || 0;
|
|
2230
|
+
}
|
|
2231
|
+
catch { /* ffprobe missing → sample at a default rate below */ }
|
|
2232
|
+
const label = `${title ? `"${title}" ` : ""}${fmtTime(duration)}`;
|
|
2233
|
+
const late = times.filter((t) => duration > 0 && t > duration);
|
|
2234
|
+
if (late.length)
|
|
2235
|
+
return `error: ${late.map(fmtTime).join(", ")} ${late.length === 1 ? "is" : "are"} past the end (the video is ${fmtTime(duration)})`;
|
|
2236
|
+
const picks = times.length ? times : duration > 0 ? evenTimes(duration, nFrames) : [];
|
|
2237
|
+
const keepDir = flag(args.save_frames) || !analyze ? operatorPath("cache", "frames", `video-${Date.now()}`) : "";
|
|
2238
|
+
let saved = [];
|
|
2239
|
+
let missedNote = "";
|
|
2240
|
+
if (keepDir) {
|
|
2241
|
+
if (!picks.length)
|
|
2242
|
+
return "error: video_analyze could not read the video's length (is ffprobe installed?), so pass `timestamps` to save frames";
|
|
2243
|
+
await mkdir(keepDir, { recursive: true });
|
|
2244
|
+
const got = await grabFrames(src, picks, keepDir, "frame", MEDIA_CAPS.frameEdge);
|
|
2245
|
+
if (!got.frames.length)
|
|
2246
|
+
return "error: ffmpeg saved no frames — is it installed, and is the input a valid video?";
|
|
2247
|
+
saved = got.frames;
|
|
2248
|
+
if (got.missed.length)
|
|
2249
|
+
missedNote = `\nno frame at ${got.missed.map(fmtTime).join(", ")} (ffmpeg returned none)`;
|
|
2250
|
+
}
|
|
2251
|
+
const savedLines = saved.map((f) => `${f.path} (at ${fmtTime(f.t)})`).join("\n") + missedNote;
|
|
2252
|
+
if (!analyze)
|
|
2253
|
+
return `${saved.length} frame${saved.length === 1 ? "" : "s"} saved from ${title ? `"${title}"` : video} (video ${fmtTime(duration)}), no model asked:\n${savedLines}`;
|
|
2254
|
+
let picked;
|
|
2255
|
+
let at = "";
|
|
2256
|
+
if (picks.length) {
|
|
2257
|
+
const got = (await grabFrames(src, picks, dir, "f", MEDIA_CAPS.analyzeWidth)).frames;
|
|
2258
|
+
picked = got.map((f) => f.path);
|
|
2259
|
+
at = ` at ${got.map((f) => fmtTime(f.t)).join(", ")}`;
|
|
2078
2260
|
}
|
|
2079
|
-
|
|
2080
|
-
|
|
2261
|
+
else {
|
|
2262
|
+
try {
|
|
2263
|
+
await pexec("ffmpeg", ["-nostdin", "-y", "-loglevel", "error", "-i", src, "-vf", `scale=${MEDIA_CAPS.analyzeWidth}:-1,fps=2`, "-frames:v", String(nFrames * 3), join(dir, "f%03d.png")]);
|
|
2264
|
+
}
|
|
2265
|
+
catch {
|
|
2266
|
+
return "error: ffmpeg failed to sample frames — is it installed, and is the input a valid video?";
|
|
2267
|
+
}
|
|
2268
|
+
const files = (await readdir(dir)).filter((f) => /^f\d+\.png$/.test(f)).sort();
|
|
2269
|
+
const step = Math.max(1, Math.floor(files.length / nFrames));
|
|
2270
|
+
picked = files.filter((_f, i) => i % step === 0).slice(0, nFrames).map((f) => join(dir, f));
|
|
2081
2271
|
}
|
|
2082
|
-
|
|
2083
|
-
if (!files.length)
|
|
2272
|
+
if (!picked.length)
|
|
2084
2273
|
return "error: no frames extracted from the video (is it a valid video file?)";
|
|
2085
|
-
const
|
|
2086
|
-
const picked = files.filter((_f, i) => i % step === 0).slice(0, nFrames);
|
|
2087
|
-
const parts = [{ type: "text", text: `${question} (${picked.length} frames, in order)` }];
|
|
2274
|
+
const parts = [{ type: "text", text: `${question} (${picked.length} frames, in order${at})` }];
|
|
2088
2275
|
for (const f of picked) {
|
|
2089
|
-
const b = await readFile(
|
|
2276
|
+
const b = await readFile(f);
|
|
2090
2277
|
parts.push({ type: "image_url", image_url: { url: `data:image/png;base64,${b.toString("base64")}` } });
|
|
2091
2278
|
}
|
|
2092
2279
|
const text = await visionComplete(parts, args, await visionSettings(), 180_000);
|
|
2093
|
-
return `video analysis (${picked.length} frames) → ${text}`;
|
|
2280
|
+
return `video analysis (${picked.length} frames${duration ? ` of ${label}` : ""}) → ${text}${saved.length ? `\nframes saved:\n${savedLines}` : ""}`;
|
|
2094
2281
|
}
|
|
2095
2282
|
catch (e) {
|
|
2096
2283
|
const msg = e?.name === "AbortError" ? "timed out" : String(e?.message ?? e);
|
|
@@ -2632,15 +2819,18 @@ const TOOLS = [
|
|
|
2632
2819
|
},
|
|
2633
2820
|
{
|
|
2634
2821
|
name: "image_analyze", safe: true,
|
|
2635
|
-
contract: { v:
|
|
2822
|
+
contract: { v: 2, effects: ["read", "fetch"], bins: ["osascript", "textutil", "unzip", "qlmanage", "sips", "ffmpeg", "chrome", "python3"] },
|
|
2636
2823
|
description: "SEE an image with real vision (the gateway's `vision` route): a local path or http(s) url + an optional question → the model's answer. Use it on a reference, screenshot or generated image before acting — never guess content from file size or pixel stats. A DOCUMENT (PDF, DOCX, XLSX, PPTX, RTF, HTML) returns its extracted TEXT, every page; only an image-only document is rendered (first page). as_image: true looks at a document's first page as a picture.",
|
|
2637
2824
|
parameters: { type: "object", properties: {
|
|
2638
2825
|
image: { type: "string", description: "local path or http(s) url — an image, or a document (returned as text)" },
|
|
2826
|
+
page: { type: "string", description: "web page url: screenshot + see it" },
|
|
2827
|
+
full_page: { type: "boolean" },
|
|
2828
|
+
design: { type: "boolean", description: "layout, real palette, fonts, parts" },
|
|
2639
2829
|
question: { type: "string", description: "default \"Describe this image in detail.\"" },
|
|
2640
2830
|
max_tokens: { type: "number", description: "answer cap (default 1024)" },
|
|
2641
2831
|
timeout_ms: { type: "number", description: "default 120000" },
|
|
2642
2832
|
as_image: { type: "boolean", description: "document: look at its first page as an image (layout, charts)" },
|
|
2643
|
-
}, required: [
|
|
2833
|
+
}, required: [] },
|
|
2644
2834
|
run: imageAnalyze,
|
|
2645
2835
|
},
|
|
2646
2836
|
{
|
|
@@ -2654,12 +2844,16 @@ const TOOLS = [
|
|
|
2654
2844
|
},
|
|
2655
2845
|
{
|
|
2656
2846
|
name: "video_analyze", safe: true,
|
|
2657
|
-
contract: { v:
|
|
2658
|
-
description: "SEE a video: frames sampled evenly
|
|
2847
|
+
contract: { v: 2, effects: ["read", "fetch"], bins: ["ffprobe", "ffmpeg", "yt-dlp"] },
|
|
2848
|
+
description: "SEE a video: frames sampled evenly (or at timestamps) are described by the VL model (the gateway's `vision` route). A local path, video url, or video page link (YouTube, Vimeo: needs yt-dlp) + an optional question. Frame capture: save_frames returns PNG paths; analyze: false skips the model. Never guess a video's content from the file.",
|
|
2659
2849
|
parameters: { type: "object", properties: {
|
|
2660
|
-
video: { type: "string", description: "local path or
|
|
2850
|
+
video: { type: "string", description: "local path or url" },
|
|
2661
2851
|
question: { type: "string", description: "default: describe what happens" },
|
|
2662
2852
|
frames: { type: "number", description: "2-16 (default 8)" },
|
|
2853
|
+
timestamps: { type: "string", description: "e.g. \"5, 1:30\"" },
|
|
2854
|
+
save_frames: { type: "boolean" },
|
|
2855
|
+
analyze: { type: "boolean", description: "default true" },
|
|
2856
|
+
max_duration_s: { type: "number", description: "page links (default 1800)" },
|
|
2663
2857
|
max_tokens: { type: "number", description: "answer cap (default 1024)" },
|
|
2664
2858
|
timeout_ms: { type: "number", description: "default 180000" },
|
|
2665
2859
|
}, required: ["video"] },
|
|
@@ -2847,11 +3041,11 @@ const TOOLS = [
|
|
|
2847
3041
|
{
|
|
2848
3042
|
name: "browser", safe: false,
|
|
2849
3043
|
contract: { v: 1, effects: ["fetch", "egress", "exec", "write"], bins: ["chrome"] },
|
|
2850
|
-
description: "Drive a REAL headless browser (
|
|
3044
|
+
description: "Drive a REAL headless browser (Playwright); state persists across calls — JS pages, logins, forms, clicks. Prefer browser_read for content. Actions: open/navigate(url) reload back forward click(selector) fill(selector, text) submit(selector) eval(js, awaits promises) screenshot → png path, tab_select/tab_close(index) close. http/https/about/data URLs only. Login wall: NEVER guess credentials — ask the owner.",
|
|
2851
3045
|
parameters: { type: "object", properties: {
|
|
2852
3046
|
action: { type: "string", enum: ["open", "navigate", "reload", "back", "forward", "click", "fill", "submit", "eval", "screenshot", "tab_select", "tab_close", "close"], description: "the browser action" },
|
|
2853
3047
|
url: { type: "string", description: "for open|navigate" },
|
|
2854
|
-
selector: { type: "string", description: "CSS selector for click|fill|submit" },
|
|
3048
|
+
selector: { type: "string", description: "CSS/Playwright selector for click|fill|submit" },
|
|
2855
3049
|
text: { type: "string", description: "value for fill" },
|
|
2856
3050
|
js: { type: "string", description: "JS expression for eval" },
|
|
2857
3051
|
index: { type: "number", description: "tab index" },
|