@openape/ape-agent 2.0.1 → 2.0.2
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/bridge.mjs +85 -2
- package/package.json +3 -3
package/dist/bridge.mjs
CHANGED
|
@@ -1422,12 +1422,94 @@ import { existsSync as existsSync4, mkdirSync as mkdirSync3, readdirSync as read
|
|
|
1422
1422
|
import { homedir as homedir6 } from "os";
|
|
1423
1423
|
import { join as join6 } from "path";
|
|
1424
1424
|
|
|
1425
|
-
// ../../packages/apes/dist/chunk-
|
|
1425
|
+
// ../../packages/apes/dist/chunk-FRCNYDTR.js
|
|
1426
|
+
import { spawn } from "child_process";
|
|
1426
1427
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
1427
1428
|
import { homedir as homedir3 } from "os";
|
|
1428
1429
|
import { dirname, normalize, resolve } from "path";
|
|
1429
1430
|
import { execFileSync } from "child_process";
|
|
1430
1431
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
1432
|
+
var DEFAULT_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
1433
|
+
var MAX_STDIO_BYTES = 64 * 1024;
|
|
1434
|
+
var BIN = "ape-shell";
|
|
1435
|
+
function capStdio(s2) {
|
|
1436
|
+
const buf = Buffer.from(s2, "utf8");
|
|
1437
|
+
if (buf.byteLength <= MAX_STDIO_BYTES) return s2;
|
|
1438
|
+
return `${buf.subarray(0, MAX_STDIO_BYTES).toString("utf8")}
|
|
1439
|
+
[truncated to ${MAX_STDIO_BYTES} bytes]`;
|
|
1440
|
+
}
|
|
1441
|
+
var bashTools = [
|
|
1442
|
+
{
|
|
1443
|
+
name: "bash",
|
|
1444
|
+
description: "Run a shell command on the agent host. Every invocation goes through the OpenApe DDISA grant cycle \u2014 auto-approved if the owner has a matching YOLO scope, otherwise the owner gets a push notification to approve. Runs as the agent's macOS user, so file/network access is limited to what that user can see. Returns stdout, stderr, and exit code. For repeated command patterns ask the owner to set up a YOLO scope so approvals don't pile up.",
|
|
1445
|
+
parameters: {
|
|
1446
|
+
type: "object",
|
|
1447
|
+
properties: {
|
|
1448
|
+
cmd: {
|
|
1449
|
+
type: "string",
|
|
1450
|
+
description: "Shell command to run, e.g. `ls -la ~/Documents`, `git status`, `curl -fsSL https://example.com`. The whole string is passed to `bash -c`; quote internally as needed."
|
|
1451
|
+
},
|
|
1452
|
+
timeout_ms: {
|
|
1453
|
+
type: "number",
|
|
1454
|
+
description: "Wall-clock cap for the whole approval-and-run cycle in milliseconds. Default 300000 (5 min). Approval waits count against this budget."
|
|
1455
|
+
}
|
|
1456
|
+
},
|
|
1457
|
+
required: ["cmd"]
|
|
1458
|
+
},
|
|
1459
|
+
execute: async (args) => {
|
|
1460
|
+
const a2 = args;
|
|
1461
|
+
if (typeof a2.cmd !== "string" || a2.cmd.trim() === "") {
|
|
1462
|
+
throw new Error("cmd must be a non-empty string");
|
|
1463
|
+
}
|
|
1464
|
+
const timeout = typeof a2.timeout_ms === "number" && a2.timeout_ms > 0 ? a2.timeout_ms : DEFAULT_TIMEOUT_MS;
|
|
1465
|
+
return await new Promise((resolveResult) => {
|
|
1466
|
+
const child = spawn(BIN, ["-c", a2.cmd], {
|
|
1467
|
+
env: { ...process.env, APE_WAIT: "1" },
|
|
1468
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
1469
|
+
});
|
|
1470
|
+
let stdout2 = "";
|
|
1471
|
+
let stderr = "";
|
|
1472
|
+
let timedOut = false;
|
|
1473
|
+
let spawnError = null;
|
|
1474
|
+
child.stdout.on("data", (chunk) => {
|
|
1475
|
+
stdout2 += chunk.toString("utf8");
|
|
1476
|
+
});
|
|
1477
|
+
child.stderr.on("data", (chunk) => {
|
|
1478
|
+
stderr += chunk.toString("utf8");
|
|
1479
|
+
});
|
|
1480
|
+
child.on("error", (err) => {
|
|
1481
|
+
spawnError = err;
|
|
1482
|
+
});
|
|
1483
|
+
const timer = setTimeout(() => {
|
|
1484
|
+
timedOut = true;
|
|
1485
|
+
child.kill("SIGTERM");
|
|
1486
|
+
setTimeout(() => {
|
|
1487
|
+
try {
|
|
1488
|
+
child.kill("SIGKILL");
|
|
1489
|
+
} catch {
|
|
1490
|
+
}
|
|
1491
|
+
}, 5e3);
|
|
1492
|
+
}, timeout);
|
|
1493
|
+
child.on("close", (code) => {
|
|
1494
|
+
clearTimeout(timer);
|
|
1495
|
+
if (spawnError) {
|
|
1496
|
+
resolveResult({
|
|
1497
|
+
error: spawnError.message,
|
|
1498
|
+
hint: `Could not exec '${BIN}'. The agent host needs @openape/apes installed globally so ape-shell is on PATH.`
|
|
1499
|
+
});
|
|
1500
|
+
return;
|
|
1501
|
+
}
|
|
1502
|
+
resolveResult({
|
|
1503
|
+
stdout: capStdio(stdout2),
|
|
1504
|
+
stderr: capStdio(stderr),
|
|
1505
|
+
exit_code: code ?? -1,
|
|
1506
|
+
...timedOut ? { timed_out: true } : {}
|
|
1507
|
+
});
|
|
1508
|
+
});
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
];
|
|
1431
1513
|
var MAX_BYTES = 1024 * 1024;
|
|
1432
1514
|
function jailPath(input) {
|
|
1433
1515
|
if (typeof input !== "string" || input === "") {
|
|
@@ -1718,7 +1800,8 @@ var ALL_TOOLS = [
|
|
|
1718
1800
|
...httpTools,
|
|
1719
1801
|
...fileTools,
|
|
1720
1802
|
...tasksTools,
|
|
1721
|
-
...mailTools
|
|
1803
|
+
...mailTools,
|
|
1804
|
+
...bashTools
|
|
1722
1805
|
];
|
|
1723
1806
|
var TOOLS = Object.fromEntries(
|
|
1724
1807
|
ALL_TOOLS.map((t2) => [t2.name, t2])
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openape/ape-agent",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "OpenApe agent runtime: per-agent process that connects to chat.openape.ai, runs the LLM loop with tools + cron tasks, and streams replies back to owners.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"jose": "^5.9.0",
|
|
21
21
|
"ofetch": "^1.4.1",
|
|
22
22
|
"ws": "^8.18.0",
|
|
23
|
-
"@openape/
|
|
24
|
-
"@openape/
|
|
23
|
+
"@openape/cli-auth": "0.4.0",
|
|
24
|
+
"@openape/apes": "1.21.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@antfu/eslint-config": "^7.6.1",
|