@0perator/operator 0.1.277 → 0.1.282
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/acp/agent.js +8 -3
- package/dist/auth/commands.js +1 -0
- package/dist/autonomy/delegate.js +6 -11
- package/dist/autonomy/keepawake.js +2 -0
- package/dist/browser/cdp.js +5 -0
- package/dist/cli.js +103 -20
- package/dist/config/persona.js +24 -5
- package/dist/config/scaffold.js +1 -1
- package/dist/engine/agent.js +12 -0
- package/dist/engine/aurora.js +6 -0
- package/dist/engine/grandmaster.js +29 -4
- package/dist/mcp/stdio.js +2 -0
- package/dist/permissions/audit.js +29 -0
- package/dist/permissions/index.js +25 -13
- package/dist/remote/host.js +106 -5
- package/dist/services/preflight.js +1 -0
- package/dist/session-teardown.js +11 -0
- package/dist/session.js +42 -2
- package/dist/telemetry/events.js +22 -2
- package/dist/telemetry/ingest.js +574 -0
- package/dist/telemetry/lifecycle.js +35 -0
- package/dist/telemetry/sha256.js +75 -0
- package/dist/tools/document.js +203 -0
- package/dist/tools/registry.js +30 -2
- package/dist/tools/sandbox.js +3 -1
- package/dist/tools/shell-session.js +2 -0
- package/dist/ui/App.js +2 -2
- package/dist/util/owned-children.js +265 -0
- package/dist/util/screenshots.js +47 -0
- package/dist/util/teardown.js +64 -0
- package/package.json +4 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Snapshot ephemeral screenshot temp files the instant they enter the prompt.
|
|
2
|
+
//
|
|
3
|
+
// macOS hands a dragged screenshot to the terminal as a path under a per-user temp root
|
|
4
|
+
// (/var/folders/.../TemporaryItems/NSIRD_screencaptureui_*/Screenshot ....png) that the OS
|
|
5
|
+
// DELETES within seconds -- long before the model reasons and calls image_analyze, which then
|
|
6
|
+
// fails with "could not read a file" (and, scrambling for a substitute, can analyze the wrong
|
|
7
|
+
// file twice). So we copy any such ephemeral image to a durable attachments dir at INPUT time
|
|
8
|
+
// and rewrite the reference to the copy. Local paths (Desktop/Downloads) are stable and pass
|
|
9
|
+
// through untouched. Pure, synchronous, model-agnostic input preprocessing -- the same seam and
|
|
10
|
+
// shape as expandFileMentions, run on the user's text before it reaches the model.
|
|
11
|
+
import { statSync, copyFileSync, mkdirSync } from "node:fs";
|
|
12
|
+
import { operatorPath } from "../config/home.js";
|
|
13
|
+
// A path under the macOS per-user temp root (/var/folders, optionally /private-prefixed) or /tmp,
|
|
14
|
+
// ending in an image extension. "\\ " matches a shell-escaped space so a dragged screenshot's
|
|
15
|
+
// spaced filename ("Screenshot 2026-10-11 at 9.00.10 PM.png") is captured whole; "\S" covers the
|
|
16
|
+
// rest. Lazy so it stops at the first image extension and never spans two paths.
|
|
17
|
+
const EPHEMERAL_IMG_RE = /(?:\/private)?\/(?:var\/folders|tmp)\/(?:\\ |\S)+?\.(?:png|jpe?g|gif|webp|bmp|heic|heif|tiff?)/gi;
|
|
18
|
+
const MAX_SNAPSHOT_BYTES = 64 * 1024 * 1024;
|
|
19
|
+
let seq = 0;
|
|
20
|
+
// Replace every ephemeral screenshot/image path in `text` that still exists on disk with a durable
|
|
21
|
+
// copy under the operator home's attachments dir. Anything that cannot be snapshotted (already
|
|
22
|
+
// deleted, unreadable, too large) is left exactly as written -- the tool then surfaces its own
|
|
23
|
+
// clear "could not read a file" error. Returns text unchanged when nothing matched.
|
|
24
|
+
export function snapshotEphemeralImages(text) {
|
|
25
|
+
// Cheap bail-out: only the macOS screenshot/temp shapes are worth scanning.
|
|
26
|
+
if (!text || !/\/var\/folders\/|TemporaryItems|NSIRD_|\/tmp\//i.test(text))
|
|
27
|
+
return text;
|
|
28
|
+
let changed = false;
|
|
29
|
+
const out = text.replace(EPHEMERAL_IMG_RE, (match) => {
|
|
30
|
+
const real = match.replace(/\\ /g, " "); // unescape shell-escaped spaces for the fs call
|
|
31
|
+
try {
|
|
32
|
+
const st = statSync(real);
|
|
33
|
+
if (!st.isFile() || st.size === 0 || st.size > MAX_SNAPSHOT_BYTES)
|
|
34
|
+
return match;
|
|
35
|
+
const ext = (real.split(".").pop() || "png").toLowerCase();
|
|
36
|
+
mkdirSync(operatorPath("attachments"), { recursive: true, mode: 0o700 });
|
|
37
|
+
const dest = operatorPath("attachments", "shot-" + Date.now() + "-" + seq++ + "." + ext);
|
|
38
|
+
copyFileSync(real, dest);
|
|
39
|
+
changed = true;
|
|
40
|
+
return dest; // clean, space-free path -- no downstream escaping needed
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return match; // vanished / unreadable -- leave as-is; image_analyze reports it plainly
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return changed ? out : text;
|
|
47
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export class Teardown {
|
|
2
|
+
steps = [];
|
|
3
|
+
all;
|
|
4
|
+
seq = 0;
|
|
5
|
+
stepTimeoutMs;
|
|
6
|
+
onError;
|
|
7
|
+
constructor(opts = {}) {
|
|
8
|
+
this.stepTimeoutMs = opts.stepTimeoutMs ?? 3000;
|
|
9
|
+
this.onError = opts.onError ?? (() => { });
|
|
10
|
+
}
|
|
11
|
+
add(name, run, opts = {}) {
|
|
12
|
+
this.steps.push({ name, run, sync: opts.sync, order: opts.order ?? 50, seq: this.seq++, state: "idle" });
|
|
13
|
+
this.steps.sort((a, b) => a.order - b.order || a.seq - b.seq);
|
|
14
|
+
}
|
|
15
|
+
/** Names in execution order (tests, diagnostics). */
|
|
16
|
+
names() { return this.steps.map((s) => s.name); }
|
|
17
|
+
/** True once every registered step has finished. */
|
|
18
|
+
get finished() { return this.steps.length > 0 && this.steps.every((s) => s.state === "done"); }
|
|
19
|
+
/** Graceful teardown. Memoized: the first call does the work, every later call gets the same promise. Never rejects. */
|
|
20
|
+
run(reason) {
|
|
21
|
+
return (this.all ??= (async () => {
|
|
22
|
+
for (const s of [...this.steps]) {
|
|
23
|
+
if (s.state === "done")
|
|
24
|
+
continue;
|
|
25
|
+
s.state = "running";
|
|
26
|
+
let timer;
|
|
27
|
+
try {
|
|
28
|
+
await Promise.race([
|
|
29
|
+
Promise.resolve().then(() => s.run(reason)),
|
|
30
|
+
new Promise((_, rej) => { timer = setTimeout(() => rej(new Error(`step "${s.name}" timed out after ${this.stepTimeoutMs}ms`)), this.stepTimeoutMs); }),
|
|
31
|
+
]);
|
|
32
|
+
s.state = "done";
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
this.onError(s.name, e); // a hung step stays "running": runSync() will still try its sync half at process exit
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
})());
|
|
42
|
+
}
|
|
43
|
+
/** Synchronous teardown for a signal handler or `process.on("exit")`. Runs the sync half of every step that has not finished
|
|
44
|
+
* (so a finished step is never repeated) and marks it done. */
|
|
45
|
+
runSync(reason) {
|
|
46
|
+
for (const s of [...this.steps]) {
|
|
47
|
+
if (s.state === "done")
|
|
48
|
+
continue;
|
|
49
|
+
try {
|
|
50
|
+
if (s.sync)
|
|
51
|
+
s.sync(reason);
|
|
52
|
+
else {
|
|
53
|
+
const r = s.run(reason);
|
|
54
|
+
if (r && typeof r.catch === "function")
|
|
55
|
+
r.catch(() => { });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
this.onError(s.name, e);
|
|
60
|
+
}
|
|
61
|
+
s.state = "done";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0perator/operator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.282",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"operator": "dist/cli.js",
|
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
"@zed-industries/agent-client-protocol": "^0.4.5",
|
|
29
29
|
"chalk": "^5.6.2",
|
|
30
30
|
"ink": "^5.0.1",
|
|
31
|
+
"marked": "^12.0.2",
|
|
32
|
+
"pdfkit": "^0.15.2",
|
|
31
33
|
"qrcode": "^1.5.4",
|
|
32
34
|
"react": "^18.3.1",
|
|
33
35
|
"ws": "^8.18.0"
|
|
@@ -35,6 +37,7 @@
|
|
|
35
37
|
"devDependencies": {
|
|
36
38
|
"@biomejs/biome": "2.5.14",
|
|
37
39
|
"@types/node": "^22.20.3",
|
|
40
|
+
"@types/pdfkit": "^0.13.9",
|
|
38
41
|
"@types/qrcode": "^1.5.6",
|
|
39
42
|
"@types/react": "^18.3.3",
|
|
40
43
|
"ink-testing-library": "^3.0.0",
|