@0perator/operator 0.1.334 → 0.1.335
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/engine/aurora.js +5 -1
- package/dist/tools/doc-text.js +24 -2
- package/dist/tools/paths.js +2 -3
- package/dist/tools/read-path.js +18 -0
- package/dist/tools/registry.js +19 -3
- package/package.json +1 -1
package/dist/engine/aurora.js
CHANGED
|
@@ -90,8 +90,12 @@ function isOperatorTrustedHost(h) {
|
|
|
90
90
|
return false;
|
|
91
91
|
if (isGatewayDomain(h))
|
|
92
92
|
return true;
|
|
93
|
-
|
|
93
|
+
// Private IPv4 LITERALS only — the old prefix test also matched hostnames like "10.evil.com" / "192.168.x.attacker.io",
|
|
94
|
+
// and the vision gateway + MOA now send the Operator token through this check (review of 0.1.334).
|
|
95
|
+
return PRIVATE_IPV4.some((re) => re.test(h)) || h === "localhost" || h === "[::1]" || h === "::1" || /^[a-z0-9-]+(\.[a-z0-9-]+)*\.local$/i.test(h);
|
|
94
96
|
}
|
|
97
|
+
const OCTET = "(25[0-5]|2[0-4]\\d|1?\\d?\\d)";
|
|
98
|
+
const PRIVATE_IPV4 = [`10(\\.${OCTET}){3}`, `127(\\.${OCTET}){3}`, `192\\.168(\\.${OCTET}){2}`, `172\\.(1[6-9]|2\\d|3[01])(\\.${OCTET}){2}`].map((s) => new RegExp(`^${s}$`));
|
|
95
99
|
// One operator identity per process. The node CLI sets this at boot from the keychain
|
|
96
100
|
// (setOperatorToken); browser/JSCore hosts inject per-call via AuroraOpts.token or not at all.
|
|
97
101
|
// A local :8097 never receives it (isRemoteBase gate), so it is safe to set unconditionally.
|
package/dist/tools/doc-text.js
CHANGED
|
@@ -104,10 +104,32 @@ async function pptxText(path) {
|
|
|
104
104
|
}
|
|
105
105
|
/** Extract a document's text, or null when the format isn't one we extract, the extractor is missing or
|
|
106
106
|
* fails, or the document carries no text layer (whitespace/page markers only). */
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
/** The path every extractor receives: absolute and an existing regular file, or null. Each extractor hands the path
|
|
108
|
+
* to a CLI as an argument (osascript after `-e <script>`, textutil, unzip); a relative "path" beginning with `-` was
|
|
109
|
+
* parsed as an OPTION — `-e<js>` ran as JavaScript from an auto-approved read tool (review of 0.1.334). An absolute
|
|
110
|
+
* path starts with "/" and can never be read as a flag. */
|
|
111
|
+
export async function safeDocPath(path) {
|
|
112
|
+
const nodePath = "node:path";
|
|
113
|
+
const nodeFs = "node:fs/promises"; // variable specifiers keep node out of the neutral graph
|
|
114
|
+
const { resolve } = await import(nodePath);
|
|
115
|
+
const { stat } = await import(nodeFs);
|
|
116
|
+
const abs = resolve(path);
|
|
117
|
+
if (!abs.startsWith("/"))
|
|
118
|
+
return null;
|
|
119
|
+
try {
|
|
120
|
+
return (await stat(abs)).isFile() ? abs : null;
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export async function extractDocText(rawPath) {
|
|
127
|
+
const ext = docExt(rawPath);
|
|
109
128
|
if (!DOC_TEXT_EXTS.has(ext))
|
|
110
129
|
return null;
|
|
130
|
+
const path = await safeDocPath(rawPath);
|
|
131
|
+
if (!path)
|
|
132
|
+
return null;
|
|
111
133
|
try {
|
|
112
134
|
const r = ext === "pdf" ? await pdfText(path) : ext === "xlsx" ? await xlsxText(path) : ext === "pptx" ? await pptxText(path) : await textutilText(path);
|
|
113
135
|
if (!r)
|
package/dist/tools/paths.js
CHANGED
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
// Node-free by construction (reads process.env only, no imports) so the tools module still loads in the
|
|
8
8
|
// headless conformance runner. Only a LEADING ~ is a home reference: bare "~" and "~/rest"; "~user" (a
|
|
9
9
|
// different account's home) and a ~ anywhere but the first character are left untouched, matching the shell.
|
|
10
|
-
export function expandPath(
|
|
11
|
-
const p = unshellPath(raw);
|
|
10
|
+
export function expandPath(p) {
|
|
12
11
|
const home = process.env.HOME ?? process.env.USERPROFILE ?? "";
|
|
13
12
|
if (!home)
|
|
14
13
|
return p;
|
|
@@ -18,7 +17,7 @@ export function expandPath(raw) {
|
|
|
18
17
|
return home + p.slice(1);
|
|
19
18
|
return p;
|
|
20
19
|
}
|
|
21
|
-
/** A path pasted from a terminal arrives shell-quoted: `~/Downloads/Expense\ Form.pdf` or `'~/My File.pdf'`. The file
|
|
20
|
+
/** Read-side only (tools/read-path.ts resolveReadPath): tried when the literal path does not exist. A path pasted from a terminal arrives shell-quoted: `~/Downloads/Expense\ Form.pdf` or `'~/My File.pdf'`. The file
|
|
22
21
|
* tools call fs directly, so the backslash or quotes become part of the name and the file "doesn't exist" — on
|
|
23
22
|
* 2026-10-28 that sent Quick Look a nonexistent path and image_analyze hung 47 minutes. Undo the quoting a shell
|
|
24
23
|
* would: one pair of wrapping quotes, and a backslash before a shell-special character. A backslash before
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Read-side path resolution for the file tools. A path pasted from a terminal arrives shell-quoted
|
|
2
|
+
// (`~/Downloads/Expense\ Form.pdf`), so the literal name "doesn't exist" — on 2026-10-28 that sent Quick Look a
|
|
3
|
+
// nonexistent file and image_analyze hung 47 minutes. The quoting is undone ONLY when the literal path does not exist
|
|
4
|
+
// and the unquoted one does: a real file whose name contains a backslash, quotes or edge spaces is always read as
|
|
5
|
+
// typed, and writes never use this (a write must never land on a different file than the one named).
|
|
6
|
+
import { expandPath, unshellPath } from "./paths.js";
|
|
7
|
+
const nodeImport = (m) => import(m);
|
|
8
|
+
export async function resolveReadPath(raw, exists) {
|
|
9
|
+
const literal = expandPath(raw);
|
|
10
|
+
const check = exists ?? (async (p) => {
|
|
11
|
+
const { access } = await nodeImport("node:fs/promises");
|
|
12
|
+
return access(p).then(() => true, () => false);
|
|
13
|
+
});
|
|
14
|
+
if (!literal || (await check(literal)))
|
|
15
|
+
return literal;
|
|
16
|
+
const unquoted = expandPath(unshellPath(raw));
|
|
17
|
+
return unquoted !== literal && (await check(unquoted)) ? unquoted : literal;
|
|
18
|
+
}
|
package/dist/tools/registry.js
CHANGED
|
@@ -24,6 +24,7 @@ import { formatGitStatus } from "./git-status.js";
|
|
|
24
24
|
import { DOC_TEXT_EXTS, describeDocText, docExt, extractDocText } from "./doc-text.js";
|
|
25
25
|
import { gatewayModelAllowed, resolveVisionGateway } from "./vision-gateway.js";
|
|
26
26
|
import { expandPath, assertContentSearchScope, assertShellHomeWideSearch, assertShellBlindDownload } from "./paths.js";
|
|
27
|
+
import { resolveReadPath } from "./read-path.js";
|
|
27
28
|
import { runMemoryTool } from "./memory.js";
|
|
28
29
|
import { documentGenerate } from "./document.js";
|
|
29
30
|
import { runCronTool } from "../autonomy/cron.js";
|
|
@@ -185,7 +186,7 @@ async function shellExec(args) {
|
|
|
185
186
|
const FILE_READ_DEFAULT_LIMIT_LINES = 2000;
|
|
186
187
|
const FILE_READ_MAX_CHARS = 40_000;
|
|
187
188
|
async function fileRead(args) {
|
|
188
|
-
const path =
|
|
189
|
+
const path = await resolveReadPath(str(args.path));
|
|
189
190
|
if (!path)
|
|
190
191
|
return "error: no path given";
|
|
191
192
|
const blocked = await deniedReadAsync(path); // sandbox on: refuse reads of credential paths (exfil guard)
|
|
@@ -1679,12 +1680,21 @@ function visionTargets(settings) {
|
|
|
1679
1680
|
// macOS Quick Look (qlmanage) covers all of these with no extra install, so image_analyze works on a
|
|
1680
1681
|
// deck/PDF/page the same way it works on a photo.
|
|
1681
1682
|
export const QUICKLOOK_TIMEOUT_MS = 30_000;
|
|
1683
|
+
/** A local media path as an ABSOLUTE path before it reaches qlmanage/sips/ffmpeg as an argument: a relative "path"
|
|
1684
|
+
* starting with "-" would be read as an option (sips has options that write files). URLs pass through. */
|
|
1685
|
+
async function absMediaPath(p) {
|
|
1686
|
+
if (/^https?:\/\//.test(p))
|
|
1687
|
+
return p;
|
|
1688
|
+
const { resolve } = await nodeImport("node:path");
|
|
1689
|
+
return resolve(p);
|
|
1690
|
+
}
|
|
1682
1691
|
const VISION_DOC_EXTS = new Set(["pdf", "pptx", "ppt", "docx", "doc", "html", "htm", "rtf", "odt", "odp", "pages", "key", "numbers", "xlsx", "xls", "epub", "webarchive", "md"]);
|
|
1683
1692
|
/** If `path` is a document (deck/PDF/page/sheet), render its first page to a PNG with macOS Quick Look and
|
|
1684
1693
|
* return that PNG path — so the vision pipeline SEES the document. Non-documents pass straight through; a
|
|
1685
1694
|
* render failure also passes through (the caller then fails with a clear "couldn't read" message). Quick
|
|
1686
1695
|
* Look only renders the first page, so multi-page docs are analyzed by their opening page. */
|
|
1687
1696
|
async function renderDocForVision(path) {
|
|
1697
|
+
path = await absMediaPath(path);
|
|
1688
1698
|
const ext = (path.split(".").pop() || "").toLowerCase();
|
|
1689
1699
|
if (!VISION_DOC_EXTS.has(ext))
|
|
1690
1700
|
return path;
|
|
@@ -1707,6 +1717,7 @@ async function renderDocForVision(path) {
|
|
|
1707
1717
|
}
|
|
1708
1718
|
}
|
|
1709
1719
|
async function visionImageDataUrl(image) {
|
|
1720
|
+
image = await absMediaPath(image);
|
|
1710
1721
|
if (/^https?:\/\//.test(image))
|
|
1711
1722
|
return image;
|
|
1712
1723
|
image = await renderDocForVision(image); // a document becomes a rendered PNG; an image is unchanged
|
|
@@ -1947,9 +1958,14 @@ async function imageInspect(args) {
|
|
|
1947
1958
|
}
|
|
1948
1959
|
async function imageAnalyze(args) {
|
|
1949
1960
|
const raw = str(args.image);
|
|
1950
|
-
const image = /^https?:\/\//.test(raw) ? raw :
|
|
1961
|
+
const image = /^https?:\/\//.test(raw) ? raw : await resolveReadPath(raw);
|
|
1951
1962
|
if (!image)
|
|
1952
1963
|
return "error: image_analyze needs an image or document (a local path or an http(s) url)";
|
|
1964
|
+
if (!/^https?:\/\//.test(image)) {
|
|
1965
|
+
const blocked = await deniedReadAsync(image); // same credential-path guard as file_read: it now returns document TEXT
|
|
1966
|
+
if (blocked)
|
|
1967
|
+
return `error: ${blocked}`;
|
|
1968
|
+
}
|
|
1953
1969
|
const question = str(args.question) || "Describe this image in detail.";
|
|
1954
1970
|
// A document is read by its TEXT first (every page, exact characters); only a document with no text layer
|
|
1955
1971
|
// (a scan) — or an explicit as_image — goes to vision as a rendered first page.
|
|
@@ -1980,7 +1996,7 @@ async function imageAnalyze(args) {
|
|
|
1980
1996
|
// (same Qwen2-VL endpoint, multi-image) describes what happens. Needs ffmpeg on PATH; verified the model
|
|
1981
1997
|
// synthesizes motion from ordered frames ("calm ocean with gentle waves, golden hue").
|
|
1982
1998
|
async function videoAnalyze(args) {
|
|
1983
|
-
const video = str(args.video);
|
|
1999
|
+
const video = str(args.video) ? await absMediaPath(await resolveReadPath(str(args.video))) : "";
|
|
1984
2000
|
if (!video)
|
|
1985
2001
|
return "error: video_analyze needs a video (a local path or an http(s) url)";
|
|
1986
2002
|
const question = str(args.question) || "These frames are sampled in order across a video. Describe what happens across the video.";
|