@0perator/operator 0.1.277 → 0.1.283
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 +32 -5
- package/dist/flywheel/processor.js +5 -43
- package/dist/flywheel/srft.js +43 -0
- 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 +207 -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,75 @@
|
|
|
1
|
+
// sha256 of a UTF-8 string as lowercase hex. Sync by design: the permission wrapper hashes tool args on the hot
|
|
2
|
+
// path and must not await. Two paths, one digest: Node's native hash when reachable (process.getBuiltinModule —
|
|
3
|
+
// no static `node:` import, so this stays loadable in the JSCore/browser bundle, same discipline as config/home.ts)
|
|
4
|
+
// and a pure-JS implementation for hosts that have no node builtins.
|
|
5
|
+
const K = new Uint32Array([
|
|
6
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
7
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
8
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
9
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
10
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
11
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
12
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
13
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
14
|
+
]);
|
|
15
|
+
/** Pure-JS SHA-256 over raw bytes. Exported for the cross-check against node:crypto in the tests. */
|
|
16
|
+
export function sha256PureBytes(msg) {
|
|
17
|
+
const h = new Uint32Array([0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19]);
|
|
18
|
+
const len = msg.length;
|
|
19
|
+
const padded = new Uint8Array(((len + 9 + 63) >> 6) << 6);
|
|
20
|
+
padded.set(msg);
|
|
21
|
+
padded[len] = 0x80;
|
|
22
|
+
const dv = new DataView(padded.buffer);
|
|
23
|
+
dv.setUint32(padded.length - 8, Math.floor((len * 8) / 0x100000000));
|
|
24
|
+
dv.setUint32(padded.length - 4, (len * 8) >>> 0);
|
|
25
|
+
const w = new Uint32Array(64);
|
|
26
|
+
for (let off = 0; off < padded.length; off += 64) {
|
|
27
|
+
for (let i = 0; i < 16; i++)
|
|
28
|
+
w[i] = dv.getUint32(off + i * 4);
|
|
29
|
+
for (let i = 16; i < 64; i++) {
|
|
30
|
+
const a = w[i - 15], b = w[i - 2];
|
|
31
|
+
const s0 = ((a >>> 7) | (a << 25)) ^ ((a >>> 18) | (a << 14)) ^ (a >>> 3);
|
|
32
|
+
const s1 = ((b >>> 17) | (b << 15)) ^ ((b >>> 19) | (b << 13)) ^ (b >>> 10);
|
|
33
|
+
w[i] = (w[i - 16] + s0 + w[i - 7] + s1) >>> 0;
|
|
34
|
+
}
|
|
35
|
+
let a = h[0], b = h[1], c = h[2], d = h[3], e = h[4], f = h[5], g = h[6], hh = h[7];
|
|
36
|
+
for (let i = 0; i < 64; i++) {
|
|
37
|
+
const S1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7));
|
|
38
|
+
const ch = (e & f) ^ (~e & g);
|
|
39
|
+
const t1 = (hh + S1 + ch + K[i] + w[i]) >>> 0;
|
|
40
|
+
const S0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10));
|
|
41
|
+
const maj = (a & b) ^ (a & c) ^ (b & c);
|
|
42
|
+
const t2 = (S0 + maj) >>> 0;
|
|
43
|
+
hh = g;
|
|
44
|
+
g = f;
|
|
45
|
+
f = e;
|
|
46
|
+
e = (d + t1) >>> 0;
|
|
47
|
+
d = c;
|
|
48
|
+
c = b;
|
|
49
|
+
b = a;
|
|
50
|
+
a = (t1 + t2) >>> 0;
|
|
51
|
+
}
|
|
52
|
+
h[0] += a;
|
|
53
|
+
h[1] += b;
|
|
54
|
+
h[2] += c;
|
|
55
|
+
h[3] += d;
|
|
56
|
+
h[4] += e;
|
|
57
|
+
h[5] += f;
|
|
58
|
+
h[6] += g;
|
|
59
|
+
h[7] += hh;
|
|
60
|
+
}
|
|
61
|
+
return Array.from(h, (x) => x.toString(16).padStart(8, "0")).join("");
|
|
62
|
+
}
|
|
63
|
+
function sha256Native(s) {
|
|
64
|
+
try {
|
|
65
|
+
const proc = globalThis.process;
|
|
66
|
+
const crypto = proc?.getBuiltinModule?.("node:crypto");
|
|
67
|
+
return crypto?.createHash("sha256").update(s, "utf8").digest("hex");
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export function sha256Hex(s) {
|
|
74
|
+
return sha256Native(s) ?? sha256PureBytes(new TextEncoder().encode(s));
|
|
75
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// document_generate — turn markdown (or plain text) into a real, downloadable PDF, with NO external
|
|
2
|
+
// renderer (no Chrome/pandoc/wkhtmltopdf). Pure-JS via pdfkit + marked, so it works on any machine
|
|
3
|
+
// Operator runs on (the owner's box AND an end-user download alike). Produces a clean, professional
|
|
4
|
+
// report/brief/deck-notes PDF: title page, headings, paragraphs with inline bold/italic/code/links,
|
|
5
|
+
// bullet + numbered lists, blockquotes, code blocks, tables, horizontal rules, and local images.
|
|
6
|
+
//
|
|
7
|
+
// Lazy-imports pdfkit/marked/node:fs INSIDE the handler so merely importing this module stays cheap and
|
|
8
|
+
// node-pure (registry.ts is node-only, but we keep the same discipline the rest of the tools use).
|
|
9
|
+
const INK = "#111111";
|
|
10
|
+
const MUTE = "#6b7280";
|
|
11
|
+
const RULE = "#d1d5db";
|
|
12
|
+
const LINK = "#2563eb";
|
|
13
|
+
const CODE_BG = "#f3f4f6";
|
|
14
|
+
export async function documentGenerate(args) {
|
|
15
|
+
const content = String(args.content ?? "").trim();
|
|
16
|
+
if (!content)
|
|
17
|
+
return "error: document_generate needs `content` (markdown or plain text)";
|
|
18
|
+
const title = String(args.title ?? "").trim();
|
|
19
|
+
const subtitle = String(args.subtitle ?? "").trim();
|
|
20
|
+
// VARIABLE specifiers: esbuild must not statically resolve these (node-only deps; a literal here drags
|
|
21
|
+
// pdfkit + node builtins into the iOS neutral engine bundle via registry.ts's static tool catalogue —
|
|
22
|
+
// the exact breakage test/neutral-graph.test.mts now catches at suite time). Same idiom as nodeImport.
|
|
23
|
+
const nodeReq = (m) => import(m);
|
|
24
|
+
const PDFDocument = (await nodeReq("pdfkit")).default;
|
|
25
|
+
const { marked } = await nodeReq("marked");
|
|
26
|
+
const fs = await nodeReq("node:fs");
|
|
27
|
+
const path = await nodeReq("node:path");
|
|
28
|
+
const { operatorPath } = await import("../config/home.js");
|
|
29
|
+
// Resolve the output path: honor an explicit `out`, else a durable attachments copy.
|
|
30
|
+
let out = String(args.out ?? "").trim();
|
|
31
|
+
if (!out) {
|
|
32
|
+
const dir = operatorPath("attachments");
|
|
33
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
34
|
+
const slug = (title || "document").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "document";
|
|
35
|
+
out = path.join(dir, `${slug}-${Date.now()}.pdf`);
|
|
36
|
+
}
|
|
37
|
+
else if (!out.toLowerCase().endsWith(".pdf")) {
|
|
38
|
+
out = out + ".pdf";
|
|
39
|
+
}
|
|
40
|
+
fs.mkdirSync(path.dirname(out), { recursive: true });
|
|
41
|
+
const doc = new PDFDocument({ size: "LETTER", margins: { top: 64, bottom: 64, left: 64, right: 64 }, bufferPages: true, info: { Title: title || "Operator document" } });
|
|
42
|
+
const stream = fs.createWriteStream(out);
|
|
43
|
+
doc.pipe(stream);
|
|
44
|
+
const LEFT = doc.page.margins.left;
|
|
45
|
+
const WIDTH = doc.page.width - doc.page.margins.left - doc.page.margins.right;
|
|
46
|
+
// --- cover / title ---
|
|
47
|
+
if (title) {
|
|
48
|
+
doc.moveDown(2);
|
|
49
|
+
doc.fillColor(INK).font("Helvetica-Bold").fontSize(28).text(title, { align: "left" });
|
|
50
|
+
if (subtitle)
|
|
51
|
+
doc.moveDown(0.4).fillColor(MUTE).font("Helvetica").fontSize(13).text(subtitle);
|
|
52
|
+
doc.moveDown(0.8);
|
|
53
|
+
doc.strokeColor(RULE).lineWidth(1).moveTo(LEFT, doc.y).lineTo(LEFT + WIDTH, doc.y).stroke();
|
|
54
|
+
doc.moveDown(1);
|
|
55
|
+
doc.fillColor(INK);
|
|
56
|
+
}
|
|
57
|
+
const tokens = marked.lexer(content);
|
|
58
|
+
for (const t of tokens)
|
|
59
|
+
renderBlock(doc, t, LEFT, WIDTH);
|
|
60
|
+
// --- footer page numbers ---
|
|
61
|
+
const range = doc.bufferedPageRange();
|
|
62
|
+
for (let i = range.start; i < range.start + range.count; i++) {
|
|
63
|
+
doc.switchToPage(i);
|
|
64
|
+
const y = doc.page.height - 40;
|
|
65
|
+
doc.fillColor(MUTE).font("Helvetica").fontSize(9)
|
|
66
|
+
.text(`${i - range.start + 1} / ${range.count}`, LEFT, y, { width: WIDTH, align: "center" });
|
|
67
|
+
}
|
|
68
|
+
doc.end();
|
|
69
|
+
await new Promise((resolve, reject) => {
|
|
70
|
+
stream.on("finish", () => resolve());
|
|
71
|
+
stream.on("error", reject);
|
|
72
|
+
});
|
|
73
|
+
const bytes = fs.statSync(out).size;
|
|
74
|
+
return `created PDF → ${out} (${(bytes / 1024).toFixed(0)} KB, ${range.count} page${range.count === 1 ? "" : "s"})`;
|
|
75
|
+
}
|
|
76
|
+
function renderBlock(doc, t, left, width) {
|
|
77
|
+
switch (t.type) {
|
|
78
|
+
case "heading": {
|
|
79
|
+
const sizes = { 1: 20, 2: 16, 3: 13, 4: 12, 5: 11, 6: 11 };
|
|
80
|
+
doc.moveDown(0.6).fillColor(INK).font("Helvetica-Bold").fontSize(sizes[t.depth || 2] || 13);
|
|
81
|
+
renderInline(doc, t.tokens || [{ type: "text", text: t.text }], left, width);
|
|
82
|
+
doc.moveDown(0.3);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case "paragraph": {
|
|
86
|
+
doc.fillColor(INK).font("Helvetica").fontSize(11);
|
|
87
|
+
renderInline(doc, t.tokens || [{ type: "text", text: t.text }], left, width);
|
|
88
|
+
doc.moveDown(0.6);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case "list": {
|
|
92
|
+
const ordered = !!t.ordered;
|
|
93
|
+
let n = typeof t.start === "number" ? t.start : 1;
|
|
94
|
+
for (const item of t.items || []) {
|
|
95
|
+
const marker = ordered ? `${n++}.` : "•";
|
|
96
|
+
doc.font("Helvetica").fontSize(11).fillColor(INK);
|
|
97
|
+
doc.text(marker, left, doc.y, { continued: true, width: 20 });
|
|
98
|
+
const itemInline = (item.tokens && item.tokens[0] && item.tokens[0].tokens) || [{ type: "text", text: item.text }];
|
|
99
|
+
renderInline(doc, itemInline, left + 18, width - 18, left + 18);
|
|
100
|
+
doc.moveDown(0.2);
|
|
101
|
+
}
|
|
102
|
+
doc.moveDown(0.4);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
case "code": {
|
|
106
|
+
doc.font("Courier").fontSize(9.5).fillColor(INK);
|
|
107
|
+
const txt = t.text || "";
|
|
108
|
+
const h = doc.heightOfString(txt, { width: width - 20 }) + 12;
|
|
109
|
+
const y = doc.y;
|
|
110
|
+
doc.rect(left, y, width, h).fill(CODE_BG);
|
|
111
|
+
doc.fillColor(INK).text(txt, left + 10, y + 6, { width: width - 20 });
|
|
112
|
+
doc.moveDown(0.6);
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case "blockquote": {
|
|
116
|
+
const y0 = doc.y;
|
|
117
|
+
doc.font("Helvetica-Oblique").fontSize(11).fillColor(MUTE);
|
|
118
|
+
doc.text((t.text || "").trim(), left + 14, doc.y, { width: width - 14 });
|
|
119
|
+
doc.strokeColor(RULE).lineWidth(3).moveTo(left + 2, y0).lineTo(left + 2, doc.y).stroke();
|
|
120
|
+
doc.moveDown(0.6).fillColor(INK);
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
case "hr": {
|
|
124
|
+
doc.moveDown(0.3).strokeColor(RULE).lineWidth(1).moveTo(left, doc.y).lineTo(left + width, doc.y).stroke();
|
|
125
|
+
doc.moveDown(0.6);
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case "table": {
|
|
129
|
+
renderTable(doc, t, left, width);
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case "space":
|
|
133
|
+
doc.moveDown(0.4);
|
|
134
|
+
break;
|
|
135
|
+
default:
|
|
136
|
+
if (t.text) {
|
|
137
|
+
doc.font("Helvetica").fontSize(11).fillColor(INK).text(t.text, { width });
|
|
138
|
+
doc.moveDown(0.4);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function renderInline(doc, tokens, x, width, indentX) {
|
|
143
|
+
if (!tokens.length) {
|
|
144
|
+
doc.text(" ", { width });
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
tokens.forEach((t, i) => {
|
|
148
|
+
const last = i === tokens.length - 1;
|
|
149
|
+
const base = { continued: !last, width };
|
|
150
|
+
if (i === 0 && indentX !== undefined) {
|
|
151
|
+
base.indent = 0;
|
|
152
|
+
}
|
|
153
|
+
switch (t.type) {
|
|
154
|
+
case "strong":
|
|
155
|
+
doc.font("Helvetica-Bold").text(t.text || "", base);
|
|
156
|
+
doc.font("Helvetica");
|
|
157
|
+
break;
|
|
158
|
+
case "em":
|
|
159
|
+
doc.font("Helvetica-Oblique").text(t.text || "", base);
|
|
160
|
+
doc.font("Helvetica");
|
|
161
|
+
break;
|
|
162
|
+
case "codespan":
|
|
163
|
+
doc.font("Courier").fillColor("#b91c1c").text(t.text || "", base);
|
|
164
|
+
doc.font("Helvetica").fillColor(INK);
|
|
165
|
+
break;
|
|
166
|
+
case "link":
|
|
167
|
+
doc.fillColor(LINK).text(t.text || t.href || "", { ...base, link: t.href, underline: true });
|
|
168
|
+
doc.fillColor(INK);
|
|
169
|
+
break;
|
|
170
|
+
case "br":
|
|
171
|
+
doc.text("\n", base);
|
|
172
|
+
break;
|
|
173
|
+
default: doc.text(t.text ?? t.raw ?? "", base);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
function renderTable(doc, t, left, width) {
|
|
178
|
+
const header = (t.header || []).map((h) => h.text);
|
|
179
|
+
const rows = (t.rows || []).map((r) => r.map((c) => c.text));
|
|
180
|
+
const cols = header.length || (rows[0]?.length ?? 0);
|
|
181
|
+
if (!cols)
|
|
182
|
+
return;
|
|
183
|
+
const colW = width / cols;
|
|
184
|
+
const pad = 5;
|
|
185
|
+
const rowH = (cells, bold) => {
|
|
186
|
+
doc.font(bold ? "Helvetica-Bold" : "Helvetica").fontSize(10);
|
|
187
|
+
let max = 14;
|
|
188
|
+
for (const c of cells)
|
|
189
|
+
max = Math.max(max, doc.heightOfString(c || "", { width: colW - pad * 2 }) + 8);
|
|
190
|
+
const y = doc.y;
|
|
191
|
+
cells.forEach((c, i) => {
|
|
192
|
+
const x = left + i * colW;
|
|
193
|
+
if (bold) {
|
|
194
|
+
doc.rect(x, y, colW, max).fill(CODE_BG);
|
|
195
|
+
doc.fillColor(INK);
|
|
196
|
+
}
|
|
197
|
+
doc.strokeColor(RULE).lineWidth(0.5).rect(x, y, colW, max).stroke();
|
|
198
|
+
doc.fillColor(INK).text(c || "", x + pad, y + 4, { width: colW - pad * 2 });
|
|
199
|
+
});
|
|
200
|
+
doc.y = y + max;
|
|
201
|
+
};
|
|
202
|
+
if (header.length)
|
|
203
|
+
rowH(header, true);
|
|
204
|
+
for (const r of rows)
|
|
205
|
+
rowH(r, false);
|
|
206
|
+
doc.moveDown(0.6);
|
|
207
|
+
}
|
package/dist/tools/registry.js
CHANGED
|
@@ -9,10 +9,12 @@ import { MemoryStore } from "../memory/index.js";
|
|
|
9
9
|
import { indexSessions, readSession, searchSessions } from "../memory/session-index.js";
|
|
10
10
|
import { listLocalSkills, localSkillsDir as profileSkillsDir, resolveSkillFile } from "../config/skills-index.js";
|
|
11
11
|
import { operatorPath } from "../config/home.js";
|
|
12
|
+
import { ownChild } from "../util/owned-children.js";
|
|
12
13
|
import { pexecFile } from "./exec.js";
|
|
13
14
|
import { formatGitStatus } from "./git-status.js";
|
|
14
15
|
import { expandPath } from "./paths.js";
|
|
15
16
|
import { runMemoryTool } from "./memory.js";
|
|
17
|
+
import { documentGenerate } from "./document.js";
|
|
16
18
|
import { runCronTool } from "../autonomy/cron.js";
|
|
17
19
|
import { runDelegateTask } from "../autonomy/delegate.js";
|
|
18
20
|
import { runSessionRewind } from "../memory/session-rewind.js";
|
|
@@ -978,7 +980,11 @@ async function shellBackground(args) {
|
|
|
978
980
|
const { spawn } = await nodeImport("node:child_process");
|
|
979
981
|
const { file, args: argv } = await wrapShell(command); // same OS sandbox wrap as shell_exec
|
|
980
982
|
const id = `sh${++bgSeq}`;
|
|
981
|
-
|
|
983
|
+
// Its own process group, so the WHOLE job tree (`npm run dev` → node → …) can be stopped, not just the top shell. It used to be
|
|
984
|
+
// "not detached: the job dies with Operator" — it did not: a running job outlived /exit, held the event loop open (Operator froze
|
|
985
|
+
// after /exit) and was orphaned. Owned now: killed at exit, reaped by the next Operator if this one crashes.
|
|
986
|
+
const p = spawn(file, argv, { cwd, detached: true });
|
|
987
|
+
ownChild(p, `background job ${id}`, { cmd: `${file} ${argv.join(" ")}`, group: true });
|
|
982
988
|
const job = { proc: p, buf: "", done: false, code: null, started: Date.now(), cmd: command };
|
|
983
989
|
const cap = (d) => { job.buf += d.toString("utf8"); if (job.buf.length > BG_BUF_CAP)
|
|
984
990
|
job.buf = job.buf.slice(-BG_BUF_CAP); };
|
|
@@ -1027,7 +1033,17 @@ async function bashKill(args) {
|
|
|
1027
1033
|
if (job.done)
|
|
1028
1034
|
return `job ${id} already finished (exit ${job.code})`;
|
|
1029
1035
|
try {
|
|
1030
|
-
job.proc.
|
|
1036
|
+
const pid = job.proc.pid;
|
|
1037
|
+
if (pid) {
|
|
1038
|
+
try {
|
|
1039
|
+
process.kill(-pid, "SIGTERM");
|
|
1040
|
+
}
|
|
1041
|
+
catch {
|
|
1042
|
+
job.proc.kill("SIGTERM");
|
|
1043
|
+
}
|
|
1044
|
+
} // the whole job group, falling back to the top process
|
|
1045
|
+
else
|
|
1046
|
+
job.proc.kill("SIGTERM");
|
|
1031
1047
|
return `sent SIGTERM to background job ${id}`;
|
|
1032
1048
|
}
|
|
1033
1049
|
catch (e) {
|
|
@@ -1787,6 +1803,7 @@ async function voiceSpeak(args) {
|
|
|
1787
1803
|
if (play && process.platform === "darwin") {
|
|
1788
1804
|
try {
|
|
1789
1805
|
const { spawn } = await nodeImport("node:child_process");
|
|
1806
|
+
// owned-exempt: short-lived playback, deliberately detached so it finishes after the turn
|
|
1790
1807
|
spawn("afplay", [out], { detached: true, stdio: "ignore" }).unref(); // fire-and-forget; don't block the turn on playback
|
|
1791
1808
|
played = true;
|
|
1792
1809
|
}
|
|
@@ -2218,6 +2235,17 @@ const TOOLS = [
|
|
|
2218
2235
|
}, required: ["content"] },
|
|
2219
2236
|
run: artifactCreate,
|
|
2220
2237
|
},
|
|
2238
|
+
{
|
|
2239
|
+
name: "document_generate",
|
|
2240
|
+
description: "Generate a real, downloadable PDF from markdown (or plain text) — a report, brief, client deliverable, or presentation handout — with NO external renderer (no Chrome/pandoc needed; works on any machine Operator runs). Pass `content` as markdown: headings, **bold**/*italic*, `code`, bullet + numbered lists, tables, code blocks, blockquotes, links, and local images all render with clean typography + page numbers. Optional `title`/`subtitle` add a cover header; `out` sets the path (default a durable attachments/ file). Returns the PDF path to open or send. Use THIS for a downloadable document/deck FILE; use artifact_create for a hosted, shareable HTML page URL.",
|
|
2241
|
+
parameters: { type: "object", properties: {
|
|
2242
|
+
content: { type: "string", description: "the document body as markdown (or plain text)" },
|
|
2243
|
+
title: { type: "string", description: "optional title, rendered as a cover header" },
|
|
2244
|
+
subtitle: { type: "string", description: "optional subtitle / byline under the title" },
|
|
2245
|
+
out: { type: "string", description: "output .pdf path (default a durable attachments/<slug>-<ts>.pdf)" },
|
|
2246
|
+
}, required: ["content"] },
|
|
2247
|
+
run: documentGenerate,
|
|
2248
|
+
},
|
|
2221
2249
|
{
|
|
2222
2250
|
name: "skill_list", safe: true,
|
|
2223
2251
|
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.",
|
package/dist/tools/sandbox.js
CHANGED
|
@@ -70,7 +70,9 @@ const SECRET_READ_FILES = [`${HOME}/.netrc`, `${HOME}/.git-credentials`];
|
|
|
70
70
|
// evidence — so the sandbox treats these exactly like ~/.ssh. Resolved per call (KODE_HOME / KODE_PROFILE
|
|
71
71
|
// can differ per process); ordinary state (memories, skills, sessions) stays writable.
|
|
72
72
|
const OP_WRITE_PROTECTED_FILES = ["settings.json", "settings.local.json", "managed-settings.json", "identity.json", "home.json", "credentials.json", "byo.json", "events.jsonl"];
|
|
73
|
-
|
|
73
|
+
// `run` holds the per-session pidfiles util/owned-children.ts reaps from: Operator (unsandboxed) trusts them to stop processes, so the agent
|
|
74
|
+
// must not be able to plant one naming a process it wants dead.
|
|
75
|
+
const OP_WRITE_PROTECTED_DIRS = ["vault", "audit", "run"];
|
|
74
76
|
const OP_SECRET_FILES = ["credentials.json", "byo.json"];
|
|
75
77
|
const OP_SECRET_DIRS = ["vault"];
|
|
76
78
|
const opPaths = (names) => names.map((n) => resolve(`${get_operator_home()}/${n}`));
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
//
|
|
15
15
|
// node-only; imported lazily from the tool layer so the neutral (mobile) bundle never pulls it.
|
|
16
16
|
import { wrapInteractiveShell } from "./sandbox.js";
|
|
17
|
+
import { ownChild } from "../util/owned-children.js";
|
|
17
18
|
// Variable-specifier dynamic import: esbuild --platform=neutral (the mobile/JSCore purity gate)
|
|
18
19
|
// STATICALLY resolves a string-literal `import("node:...")` and errors on it, but cannot resolve a
|
|
19
20
|
// variable specifier, so the Node builtin stays out of the neutral bundle. Same idiom as
|
|
@@ -45,6 +46,7 @@ export class ShellSession {
|
|
|
45
46
|
stdio: ["pipe", "pipe", "pipe"],
|
|
46
47
|
detached: true, // own process group, so killShell() can reap grandchildren (`&` jobs), not just bash
|
|
47
48
|
});
|
|
49
|
+
ownChild(p, "shell session", { cmd: `${file} ${args.join(" ")}`, group: true }); // killed at exit, reaped if we crash (it is its own session: it would outlive us)
|
|
48
50
|
p.stdout.setEncoding("utf8");
|
|
49
51
|
p.stderr.setEncoding("utf8");
|
|
50
52
|
const onData = (d) => { this.buf += d; };
|
package/dist/ui/App.js
CHANGED
|
@@ -25,7 +25,7 @@ import { ArtifactPicker } from "./ArtifactPicker.js";
|
|
|
25
25
|
// calls at once; anything past the cap is summarized as a count instead of another row.
|
|
26
26
|
const MAX_LIVE_TOOL_ROWS = 6;
|
|
27
27
|
export function App(props) {
|
|
28
|
-
const { messages, live = null, status, thinkingVerb, verbs, stepLabel, liveTools = [], route, ctxPct, version, build, fullscreen = false, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, tasks = [], onSubmit, onQueue, queuedPreview = "", onInterrupt, onCycleMode, opMode, rcConnected = false, approval = null, onApprovalDecide, question = null, modelPicker = null, planExitPicker = null, artifactsPicker = null } = props;
|
|
28
|
+
const { messages, live = null, status, thinkingVerb, verbs, stepLabel, liveTools = [], route, ctxPct, version, build, fullscreen = false, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, tasks = [], onSubmit, onQueue, queuedPreview = "", onInterrupt, onCycleMode, opMode, rcConnected = false, rcActive = false, approval = null, onApprovalDecide, question = null, modelPicker = null, planExitPicker = null, artifactsPicker = null } = props;
|
|
29
29
|
useTerminalSize(); // subscribe so the inline pinned UI (status rule, composer, footer) reflows the instant the terminal resizes
|
|
30
30
|
const thinking = status === "thinking" || status === "streaming";
|
|
31
31
|
// A parallel batch (2+ live rows) gets its own per-call view instead of the single-line StepSpinner —
|
|
@@ -40,7 +40,7 @@ export function App(props) {
|
|
|
40
40
|
// be scrolled off. The Composer is `suspended` (keystrokes route to the decision, not the draft).
|
|
41
41
|
const prompts = (_jsxs(_Fragment, { children: [_jsx(ApprovalPrompt, { approval: approval, onDecide: onApprovalDecide ?? (() => { }) }), _jsx(QuestionPrompt, { pending: question }), _jsx(QuestionPrompt, { pending: modelPicker }), _jsx(QuestionPrompt, { pending: planExitPicker }), _jsx(ArtifactPicker, { pending: artifactsPicker })] }));
|
|
42
42
|
// The pinned bottom band: status rule, composer, bottom rule, then the mode/cycle FOOTER below the rule.
|
|
43
|
-
const bottom = (_jsxs(_Fragment, { children: [_jsx(StatusRule, { route: route, ctxPct: ctxPct, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode, sessionTokens: sessionTokens }), queuedPreview ? (_jsx(Text, { color: "yellow", children: `⏎ queued · sends when this turn ends (Esc to send now): ${queuedPreview.replace(/\n/g, " / ").slice(0, 120)}${queuedPreview.length > 120 ? "…" : ""}` })) : null, _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, onCycleMode: onCycleMode, disabled: status !== "idle", suspended: !!approval || !!question || !!modelPicker || !!planExitPicker || !!artifactsPicker }), _jsx(InputRule, {}), opMode && (_jsxs(Box, { justifyContent: "space-between", children: [_jsx(Text, { dimColor: true, children: ` ${opMode === "auto" ? "⎈ Autonomous" : opMode === "manual" ? "⊙ Manual" : "◑ Plan"} · shift+tab to cycle` }), _jsx(Text, { color: rcConnected ? "green" : "gray", bold: rcConnected, children: `${rcConnected ? "▮" : "▯"}
|
|
43
|
+
const bottom = (_jsxs(_Fragment, { children: [_jsx(StatusRule, { route: route, ctxPct: ctxPct, version: version, build: build, user: authUser, tier: tier, planMode: planMode, thinkMode: thinkMode, sessionTokens: sessionTokens }), queuedPreview ? (_jsx(Text, { color: "yellow", children: `⏎ queued · sends when this turn ends (Esc to send now): ${queuedPreview.replace(/\n/g, " / ").slice(0, 120)}${queuedPreview.length > 120 ? "…" : ""}` })) : null, _jsx(Composer, { onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, onCycleMode: onCycleMode, disabled: status !== "idle", suspended: !!approval || !!question || !!modelPicker || !!planExitPicker || !!artifactsPicker }), _jsx(InputRule, {}), opMode && (_jsxs(Box, { justifyContent: "space-between", children: [_jsx(Text, { dimColor: true, children: ` ${opMode === "auto" ? "⎈ Autonomous" : opMode === "manual" ? "⊙ Manual" : "◑ Plan"} · shift+tab to cycle` }), _jsx(Text, { color: rcConnected ? "green" : rcActive ? "yellow" : "gray", bold: rcConnected || rcActive, dimColor: !rcConnected && !rcActive, children: `${rcConnected ? "▮ rc live" : rcActive ? "▮ rc on" : "▯ rc"} ` })] }))] }));
|
|
44
44
|
// Fullscreen (opt-in): a full-terminal-height column. The transcript fills a clipped, bottom-anchored
|
|
45
45
|
// region (non-Static tail) so the newest output sits just above a composer pinned to the very bottom —
|
|
46
46
|
// no dead space. Off by default: inline keeps the terminal's native scrollback (mouse-scroll + copy).
|