@askexenow/exe-os 0.9.16 → 0.9.18
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/bin/backfill-conversations.js +1242 -909
- package/dist/bin/backfill-responses.js +1245 -912
- package/dist/bin/backfill-vectors.js +1244 -906
- package/dist/bin/cleanup-stale-review-tasks.js +1870 -417
- package/dist/bin/cli.js +217 -107
- package/dist/bin/exe-agent-config.js +2 -2
- package/dist/bin/exe-agent.js +62 -0
- package/dist/bin/exe-assign.js +346 -10
- package/dist/bin/exe-boot.js +387 -32
- package/dist/bin/exe-call.js +72 -2
- package/dist/bin/exe-cloud.js +8 -0
- package/dist/bin/exe-dispatch.js +1821 -225
- package/dist/bin/exe-doctor.js +720 -52
- package/dist/bin/exe-export-behaviors.js +1429 -148
- package/dist/bin/exe-forget.js +1408 -34
- package/dist/bin/exe-gateway.js +1629 -1295
- package/dist/bin/exe-heartbeat.js +1899 -448
- package/dist/bin/exe-kill.js +1624 -346
- package/dist/bin/exe-launch-agent.js +726 -90
- package/dist/bin/exe-link.js +27 -8
- package/dist/bin/exe-new-employee.js +75 -9
- package/dist/bin/exe-pending-messages.js +2769 -1316
- package/dist/bin/exe-pending-notifications.js +2829 -1376
- package/dist/bin/exe-pending-reviews.js +2847 -1392
- package/dist/bin/exe-rename.js +89 -8
- package/dist/bin/exe-review.js +1494 -312
- package/dist/bin/exe-search.js +1608 -1300
- package/dist/bin/exe-session-cleanup.js +194 -91
- package/dist/bin/exe-settings.js +10 -2
- package/dist/bin/exe-start-codex.js +769 -120
- package/dist/bin/exe-start-opencode.js +763 -108
- package/dist/bin/exe-status.js +1887 -434
- package/dist/bin/exe-team.js +1782 -324
- package/dist/bin/git-sweep.js +408 -33
- package/dist/bin/graph-backfill.js +681 -27
- package/dist/bin/graph-export.js +1419 -141
- package/dist/bin/install.js +4 -8
- package/dist/bin/intercom-check.js +8641 -0
- package/dist/bin/scan-tasks.js +553 -38
- package/dist/bin/setup.js +82 -10
- package/dist/bin/shard-migrate.js +682 -28
- package/dist/gateway/index.js +1629 -1295
- package/dist/hooks/bug-report-worker.js +1136 -183
- package/dist/hooks/codex-stop-task-finalizer.js +1060 -107
- package/dist/hooks/commit-complete.js +408 -33
- package/dist/hooks/error-recall.js +1608 -1300
- package/dist/hooks/ingest-worker.js +250 -7966
- package/dist/hooks/ingest.js +707 -119
- package/dist/hooks/instructions-loaded.js +383 -20
- package/dist/hooks/notification.js +383 -20
- package/dist/hooks/post-compact.js +384 -21
- package/dist/hooks/{response-ingest-worker.js → post-tool-combined.js} +4157 -1716
- package/dist/hooks/pre-compact.js +486 -45
- package/dist/hooks/pre-tool-use.js +385 -22
- package/dist/hooks/prompt-submit.js +291 -96
- package/dist/hooks/session-end.js +490 -48
- package/dist/hooks/session-start.js +236 -22
- package/dist/hooks/stop.js +192 -50
- package/dist/hooks/subagent-stop.js +95 -18
- package/dist/hooks/summary-worker.js +205 -361
- package/dist/index.js +221 -105
- package/dist/lib/agent-config.js +2 -2
- package/dist/lib/cloud-sync.js +27 -8
- package/dist/lib/consolidation.js +437 -41
- package/dist/lib/database.js +20 -8
- package/dist/lib/db-daemon-client.js +2 -2
- package/dist/lib/db.js +20 -8
- package/dist/lib/device-registry.js +27 -8
- package/dist/lib/employee-templates.js +62 -0
- package/dist/lib/employees.js +2 -2
- package/dist/lib/exe-daemon.js +6703 -6259
- package/dist/lib/hybrid-search.js +1608 -1300
- package/dist/lib/identity.js +1 -1
- package/dist/lib/messaging.js +11 -3
- package/dist/lib/reminders.js +1 -1
- package/dist/lib/schedules.js +718 -26
- package/dist/lib/session-registry.js +11 -0
- package/dist/lib/skill-learning.js +639 -9
- package/dist/lib/store.js +676 -27
- package/dist/lib/tasks.js +665 -27
- package/dist/lib/tmux-routing.js +732 -94
- package/dist/lib/token-spend.js +1 -1
- package/dist/mcp/server.js +856 -383
- package/dist/mcp/tools/complete-reminder.js +1 -1
- package/dist/mcp/tools/create-reminder.js +1 -1
- package/dist/mcp/tools/create-task.js +616 -46
- package/dist/mcp/tools/deactivate-behavior.js +9 -1
- package/dist/mcp/tools/list-reminders.js +1 -1
- package/dist/mcp/tools/list-tasks.js +10 -2
- package/dist/mcp/tools/send-message.js +11 -3
- package/dist/mcp/tools/update-task.js +677 -39
- package/dist/runtime/index.js +425 -37
- package/dist/tui/App.js +365 -34
- package/package.json +5 -2
- package/src/commands/exe/intercom.md +6 -17
- package/dist/bin/wiki-sync.js +0 -2991
- package/dist/hooks/prompt-ingest-worker.js +0 -3979
|
@@ -15,6 +15,15 @@ var __export = (target, all) => {
|
|
|
15
15
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
// src/types/memory.ts
|
|
19
|
+
var EMBEDDING_DIM;
|
|
20
|
+
var init_memory = __esm({
|
|
21
|
+
"src/types/memory.ts"() {
|
|
22
|
+
"use strict";
|
|
23
|
+
EMBEDDING_DIM = 1024;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
18
27
|
// src/lib/db-retry.ts
|
|
19
28
|
function isBusyError(err) {
|
|
20
29
|
if (err instanceof Error) {
|
|
@@ -64,9 +73,9 @@ var MAX_RETRIES, BASE_DELAY_MS, MAX_JITTER_MS;
|
|
|
64
73
|
var init_db_retry = __esm({
|
|
65
74
|
"src/lib/db-retry.ts"() {
|
|
66
75
|
"use strict";
|
|
67
|
-
MAX_RETRIES =
|
|
68
|
-
BASE_DELAY_MS =
|
|
69
|
-
MAX_JITTER_MS =
|
|
76
|
+
MAX_RETRIES = 5;
|
|
77
|
+
BASE_DELAY_MS = 250;
|
|
78
|
+
MAX_JITTER_MS = 400;
|
|
70
79
|
}
|
|
71
80
|
});
|
|
72
81
|
|
|
@@ -392,7 +401,7 @@ var init_agent_config = __esm({
|
|
|
392
401
|
init_secure_files();
|
|
393
402
|
AGENT_CONFIG_PATH = path2.join(EXE_AI_DIR, "agent-config.json");
|
|
394
403
|
KNOWN_RUNTIMES = {
|
|
395
|
-
claude: ["claude-opus-4", "claude-sonnet-4", "claude-haiku-4.5"],
|
|
404
|
+
claude: ["claude-opus-4.6", "claude-opus-4", "claude-sonnet-4.6", "claude-sonnet-4", "claude-haiku-4.5"],
|
|
396
405
|
codex: ["gpt-5.4", "gpt-5.5", "gpt-5.3-codex-spark", "o3", "o4-mini"],
|
|
397
406
|
opencode: ["anthropic/claude-sonnet-4-6", "openai/gpt-5.4", "google/gemini-2.5-pro", "deepseek/deepseek-r3", "minimax/minimax-m2.5"]
|
|
398
407
|
};
|
|
@@ -402,7 +411,7 @@ var init_agent_config = __esm({
|
|
|
402
411
|
opencode: "OpenCode (open source)"
|
|
403
412
|
};
|
|
404
413
|
DEFAULT_MODELS = {
|
|
405
|
-
claude: "claude-opus-4",
|
|
414
|
+
claude: "claude-opus-4.6",
|
|
406
415
|
codex: RUNTIME_TABLE.codex?.defaultModel ?? "gpt-5.4",
|
|
407
416
|
opencode: RUNTIME_TABLE.opencode?.defaultModel ?? "anthropic/claude-sonnet-4-6"
|
|
408
417
|
};
|
|
@@ -1249,7 +1258,538 @@ var init_database_adapter = __esm({
|
|
|
1249
1258
|
}
|
|
1250
1259
|
});
|
|
1251
1260
|
|
|
1261
|
+
// src/lib/daemon-auth.ts
|
|
1262
|
+
import crypto from "crypto";
|
|
1263
|
+
import path5 from "path";
|
|
1264
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "fs";
|
|
1265
|
+
function normalizeToken(token) {
|
|
1266
|
+
if (!token) return null;
|
|
1267
|
+
const trimmed = token.trim();
|
|
1268
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
1269
|
+
}
|
|
1270
|
+
function readDaemonToken() {
|
|
1271
|
+
try {
|
|
1272
|
+
if (!existsSync5(DAEMON_TOKEN_PATH)) return null;
|
|
1273
|
+
return normalizeToken(readFileSync4(DAEMON_TOKEN_PATH, "utf8"));
|
|
1274
|
+
} catch {
|
|
1275
|
+
return null;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
function ensureDaemonToken(seed) {
|
|
1279
|
+
const existing = readDaemonToken();
|
|
1280
|
+
if (existing) return existing;
|
|
1281
|
+
const token = normalizeToken(seed) ?? crypto.randomBytes(32).toString("hex");
|
|
1282
|
+
ensurePrivateDirSync(EXE_AI_DIR);
|
|
1283
|
+
writeFileSync3(DAEMON_TOKEN_PATH, `${token}
|
|
1284
|
+
`, "utf8");
|
|
1285
|
+
enforcePrivateFileSync(DAEMON_TOKEN_PATH);
|
|
1286
|
+
return token;
|
|
1287
|
+
}
|
|
1288
|
+
var DAEMON_TOKEN_PATH;
|
|
1289
|
+
var init_daemon_auth = __esm({
|
|
1290
|
+
"src/lib/daemon-auth.ts"() {
|
|
1291
|
+
"use strict";
|
|
1292
|
+
init_config();
|
|
1293
|
+
init_secure_files();
|
|
1294
|
+
DAEMON_TOKEN_PATH = path5.join(EXE_AI_DIR, "exed.token");
|
|
1295
|
+
}
|
|
1296
|
+
});
|
|
1297
|
+
|
|
1298
|
+
// src/lib/exe-daemon-client.ts
|
|
1299
|
+
import net from "net";
|
|
1300
|
+
import os4 from "os";
|
|
1301
|
+
import { spawn } from "child_process";
|
|
1302
|
+
import { randomUUID } from "crypto";
|
|
1303
|
+
import { existsSync as existsSync6, unlinkSync as unlinkSync2, readFileSync as readFileSync5, openSync, closeSync, statSync } from "fs";
|
|
1304
|
+
import path6 from "path";
|
|
1305
|
+
import { fileURLToPath } from "url";
|
|
1306
|
+
function handleData(chunk) {
|
|
1307
|
+
_buffer += chunk.toString();
|
|
1308
|
+
if (_buffer.length > MAX_BUFFER) {
|
|
1309
|
+
_buffer = "";
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
let newlineIdx;
|
|
1313
|
+
while ((newlineIdx = _buffer.indexOf("\n")) !== -1) {
|
|
1314
|
+
const line = _buffer.slice(0, newlineIdx).trim();
|
|
1315
|
+
_buffer = _buffer.slice(newlineIdx + 1);
|
|
1316
|
+
if (!line) continue;
|
|
1317
|
+
try {
|
|
1318
|
+
const response = JSON.parse(line);
|
|
1319
|
+
const id = response.id;
|
|
1320
|
+
if (!id) continue;
|
|
1321
|
+
const entry = _pending.get(id);
|
|
1322
|
+
if (entry) {
|
|
1323
|
+
clearTimeout(entry.timer);
|
|
1324
|
+
_pending.delete(id);
|
|
1325
|
+
entry.resolve(response);
|
|
1326
|
+
}
|
|
1327
|
+
} catch {
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
function cleanupStaleFiles() {
|
|
1332
|
+
if (existsSync6(PID_PATH)) {
|
|
1333
|
+
try {
|
|
1334
|
+
const pid = parseInt(readFileSync5(PID_PATH, "utf8").trim(), 10);
|
|
1335
|
+
if (pid > 0) {
|
|
1336
|
+
try {
|
|
1337
|
+
process.kill(pid, 0);
|
|
1338
|
+
return;
|
|
1339
|
+
} catch {
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
} catch {
|
|
1343
|
+
}
|
|
1344
|
+
try {
|
|
1345
|
+
unlinkSync2(PID_PATH);
|
|
1346
|
+
} catch {
|
|
1347
|
+
}
|
|
1348
|
+
try {
|
|
1349
|
+
unlinkSync2(SOCKET_PATH);
|
|
1350
|
+
} catch {
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
function findPackageRoot() {
|
|
1355
|
+
let dir = path6.dirname(fileURLToPath(import.meta.url));
|
|
1356
|
+
const { root } = path6.parse(dir);
|
|
1357
|
+
while (dir !== root) {
|
|
1358
|
+
if (existsSync6(path6.join(dir, "package.json"))) return dir;
|
|
1359
|
+
dir = path6.dirname(dir);
|
|
1360
|
+
}
|
|
1361
|
+
return null;
|
|
1362
|
+
}
|
|
1363
|
+
function getAvailableMemoryGB() {
|
|
1364
|
+
if (process.platform === "darwin") {
|
|
1365
|
+
try {
|
|
1366
|
+
const { execSync: execSync6 } = __require("child_process");
|
|
1367
|
+
const vmstat = execSync6("vm_stat", { encoding: "utf8" });
|
|
1368
|
+
const pageSize = 16384;
|
|
1369
|
+
const pageSizeMatch = vmstat.match(/page size of (\d+) bytes/);
|
|
1370
|
+
const actualPageSize = pageSizeMatch ? parseInt(pageSizeMatch[1], 10) : pageSize;
|
|
1371
|
+
const free = vmstat.match(/Pages free:\s+(\d+)/);
|
|
1372
|
+
const inactive = vmstat.match(/Pages inactive:\s+(\d+)/);
|
|
1373
|
+
const speculative = vmstat.match(/Pages speculative:\s+(\d+)/);
|
|
1374
|
+
const freePages = free ? parseInt(free[1], 10) : 0;
|
|
1375
|
+
const inactivePages = inactive ? parseInt(inactive[1], 10) : 0;
|
|
1376
|
+
const speculativePages = speculative ? parseInt(speculative[1], 10) : 0;
|
|
1377
|
+
return (freePages + inactivePages + speculativePages) * actualPageSize / (1024 * 1024 * 1024);
|
|
1378
|
+
} catch {
|
|
1379
|
+
return os4.freemem() / (1024 * 1024 * 1024);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
return os4.freemem() / (1024 * 1024 * 1024);
|
|
1383
|
+
}
|
|
1384
|
+
function spawnDaemon() {
|
|
1385
|
+
const freeGB = getAvailableMemoryGB();
|
|
1386
|
+
const totalGB = os4.totalmem() / (1024 * 1024 * 1024);
|
|
1387
|
+
if (totalGB <= 8) {
|
|
1388
|
+
process.stderr.write(
|
|
1389
|
+
`[exed-client] SKIP: ${totalGB.toFixed(0)}GB system \u2014 embedding daemon disabled. Using keyword search only. Minimum 16GB recommended for vector search.
|
|
1390
|
+
`
|
|
1391
|
+
);
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
if (totalGB <= 16 && freeGB < 2) {
|
|
1395
|
+
process.stderr.write(
|
|
1396
|
+
`[exed-client] SKIP: low memory (${freeGB.toFixed(1)}GB available / ${totalGB.toFixed(0)}GB total). Embedding daemon not started \u2014 using keyword search only.
|
|
1397
|
+
`
|
|
1398
|
+
);
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
const pkgRoot = findPackageRoot();
|
|
1402
|
+
if (!pkgRoot) {
|
|
1403
|
+
process.stderr.write("[exed-client] WARN: cannot find package root\n");
|
|
1404
|
+
return;
|
|
1405
|
+
}
|
|
1406
|
+
const daemonPath = path6.join(pkgRoot, "dist", "lib", "exe-daemon.js");
|
|
1407
|
+
if (!existsSync6(daemonPath)) {
|
|
1408
|
+
process.stderr.write(`[exed-client] WARN: daemon script not found at ${daemonPath}
|
|
1409
|
+
`);
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
const resolvedPath = daemonPath;
|
|
1413
|
+
const daemonToken = ensureDaemonToken(process.env[DAEMON_TOKEN_ENV] ?? null);
|
|
1414
|
+
process.stderr.write(`[exed-client] Spawning daemon: ${resolvedPath}
|
|
1415
|
+
`);
|
|
1416
|
+
const logPath = path6.join(path6.dirname(SOCKET_PATH), "exed.log");
|
|
1417
|
+
let stderrFd = "ignore";
|
|
1418
|
+
try {
|
|
1419
|
+
stderrFd = openSync(logPath, "a");
|
|
1420
|
+
} catch {
|
|
1421
|
+
}
|
|
1422
|
+
const heapCapMB = totalGB <= 8 ? 256 : 512;
|
|
1423
|
+
const nodeArgs = [`--max-old-space-size=${heapCapMB}`, resolvedPath];
|
|
1424
|
+
const child = spawn(process.execPath, nodeArgs, {
|
|
1425
|
+
detached: true,
|
|
1426
|
+
stdio: ["ignore", "ignore", stderrFd],
|
|
1427
|
+
env: {
|
|
1428
|
+
...process.env,
|
|
1429
|
+
TMUX: void 0,
|
|
1430
|
+
// Daemon is global — must not inherit session scope
|
|
1431
|
+
TMUX_PANE: void 0,
|
|
1432
|
+
// Prevents resolveExeSession() from scoping to one session
|
|
1433
|
+
EXE_DAEMON_SOCK: SOCKET_PATH,
|
|
1434
|
+
EXE_DAEMON_PID: PID_PATH,
|
|
1435
|
+
[DAEMON_TOKEN_ENV]: daemonToken
|
|
1436
|
+
}
|
|
1437
|
+
});
|
|
1438
|
+
child.unref();
|
|
1439
|
+
if (typeof stderrFd === "number") {
|
|
1440
|
+
try {
|
|
1441
|
+
closeSync(stderrFd);
|
|
1442
|
+
} catch {
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
function acquireSpawnLock() {
|
|
1447
|
+
try {
|
|
1448
|
+
const fd = openSync(SPAWN_LOCK_PATH, "wx");
|
|
1449
|
+
closeSync(fd);
|
|
1450
|
+
return true;
|
|
1451
|
+
} catch {
|
|
1452
|
+
try {
|
|
1453
|
+
const stat = statSync(SPAWN_LOCK_PATH);
|
|
1454
|
+
if (Date.now() - stat.mtimeMs > SPAWN_LOCK_STALE_MS) {
|
|
1455
|
+
try {
|
|
1456
|
+
unlinkSync2(SPAWN_LOCK_PATH);
|
|
1457
|
+
} catch {
|
|
1458
|
+
}
|
|
1459
|
+
try {
|
|
1460
|
+
const fd = openSync(SPAWN_LOCK_PATH, "wx");
|
|
1461
|
+
closeSync(fd);
|
|
1462
|
+
return true;
|
|
1463
|
+
} catch {
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
} catch {
|
|
1467
|
+
}
|
|
1468
|
+
return false;
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
function releaseSpawnLock() {
|
|
1472
|
+
try {
|
|
1473
|
+
unlinkSync2(SPAWN_LOCK_PATH);
|
|
1474
|
+
} catch {
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
function connectToSocket() {
|
|
1478
|
+
return new Promise((resolve) => {
|
|
1479
|
+
if (_socket && _connected) {
|
|
1480
|
+
resolve(true);
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
const socket = net.createConnection({ path: SOCKET_PATH });
|
|
1484
|
+
const connectTimeout = setTimeout(() => {
|
|
1485
|
+
socket.destroy();
|
|
1486
|
+
resolve(false);
|
|
1487
|
+
}, 2e3);
|
|
1488
|
+
socket.on("connect", () => {
|
|
1489
|
+
clearTimeout(connectTimeout);
|
|
1490
|
+
_socket = socket;
|
|
1491
|
+
_connected = true;
|
|
1492
|
+
_buffer = "";
|
|
1493
|
+
socket.on("data", handleData);
|
|
1494
|
+
socket.on("close", () => {
|
|
1495
|
+
_connected = false;
|
|
1496
|
+
_socket = null;
|
|
1497
|
+
for (const [id, entry] of _pending) {
|
|
1498
|
+
clearTimeout(entry.timer);
|
|
1499
|
+
_pending.delete(id);
|
|
1500
|
+
entry.resolve({ error: "Connection closed" });
|
|
1501
|
+
}
|
|
1502
|
+
});
|
|
1503
|
+
socket.on("error", () => {
|
|
1504
|
+
_connected = false;
|
|
1505
|
+
_socket = null;
|
|
1506
|
+
});
|
|
1507
|
+
resolve(true);
|
|
1508
|
+
});
|
|
1509
|
+
socket.on("error", () => {
|
|
1510
|
+
clearTimeout(connectTimeout);
|
|
1511
|
+
resolve(false);
|
|
1512
|
+
});
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
async function connectEmbedDaemon() {
|
|
1516
|
+
if (_socket && _connected) return true;
|
|
1517
|
+
if (await connectToSocket()) return true;
|
|
1518
|
+
if (acquireSpawnLock()) {
|
|
1519
|
+
try {
|
|
1520
|
+
cleanupStaleFiles();
|
|
1521
|
+
spawnDaemon();
|
|
1522
|
+
} finally {
|
|
1523
|
+
releaseSpawnLock();
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
const start = Date.now();
|
|
1527
|
+
let delay2 = 100;
|
|
1528
|
+
while (Date.now() - start < CONNECT_TIMEOUT_MS) {
|
|
1529
|
+
await new Promise((r) => setTimeout(r, delay2));
|
|
1530
|
+
if (await connectToSocket()) return true;
|
|
1531
|
+
delay2 = Math.min(delay2 * 2, 3e3);
|
|
1532
|
+
}
|
|
1533
|
+
return false;
|
|
1534
|
+
}
|
|
1535
|
+
function sendDaemonRequest(payload, timeoutMs = REQUEST_TIMEOUT_MS) {
|
|
1536
|
+
return new Promise((resolve) => {
|
|
1537
|
+
if (!_socket || !_connected) {
|
|
1538
|
+
resolve({ error: "Not connected" });
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1541
|
+
const id = randomUUID();
|
|
1542
|
+
const token = process.env[DAEMON_TOKEN_ENV] ?? readDaemonToken();
|
|
1543
|
+
const timer = setTimeout(() => {
|
|
1544
|
+
_pending.delete(id);
|
|
1545
|
+
resolve({ error: "Request timeout" });
|
|
1546
|
+
}, timeoutMs);
|
|
1547
|
+
_pending.set(id, { resolve, timer });
|
|
1548
|
+
try {
|
|
1549
|
+
_socket.write(JSON.stringify({ id, token, ...payload }) + "\n");
|
|
1550
|
+
} catch {
|
|
1551
|
+
clearTimeout(timer);
|
|
1552
|
+
_pending.delete(id);
|
|
1553
|
+
resolve({ error: "Write failed" });
|
|
1554
|
+
}
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
function isClientConnected() {
|
|
1558
|
+
return _connected;
|
|
1559
|
+
}
|
|
1560
|
+
var SOCKET_PATH, PID_PATH, SPAWN_LOCK_PATH, SPAWN_LOCK_STALE_MS, CONNECT_TIMEOUT_MS, REQUEST_TIMEOUT_MS, DAEMON_TOKEN_ENV, _socket, _connected, _buffer, _pending, MAX_BUFFER;
|
|
1561
|
+
var init_exe_daemon_client = __esm({
|
|
1562
|
+
"src/lib/exe-daemon-client.ts"() {
|
|
1563
|
+
"use strict";
|
|
1564
|
+
init_config();
|
|
1565
|
+
init_daemon_auth();
|
|
1566
|
+
SOCKET_PATH = process.env.EXE_DAEMON_SOCK ?? process.env.EXE_EMBED_SOCK ?? path6.join(EXE_AI_DIR, "exed.sock");
|
|
1567
|
+
PID_PATH = process.env.EXE_DAEMON_PID ?? process.env.EXE_EMBED_PID ?? path6.join(EXE_AI_DIR, "exed.pid");
|
|
1568
|
+
SPAWN_LOCK_PATH = path6.join(EXE_AI_DIR, "exed-spawn.lock");
|
|
1569
|
+
SPAWN_LOCK_STALE_MS = 3e4;
|
|
1570
|
+
CONNECT_TIMEOUT_MS = 15e3;
|
|
1571
|
+
REQUEST_TIMEOUT_MS = 3e4;
|
|
1572
|
+
DAEMON_TOKEN_ENV = "EXE_DAEMON_TOKEN";
|
|
1573
|
+
_socket = null;
|
|
1574
|
+
_connected = false;
|
|
1575
|
+
_buffer = "";
|
|
1576
|
+
_pending = /* @__PURE__ */ new Map();
|
|
1577
|
+
MAX_BUFFER = 1e7;
|
|
1578
|
+
}
|
|
1579
|
+
});
|
|
1580
|
+
|
|
1581
|
+
// src/lib/daemon-protocol.ts
|
|
1582
|
+
function serializeValue(v) {
|
|
1583
|
+
if (v === null || v === void 0) return null;
|
|
1584
|
+
if (typeof v === "bigint") return Number(v);
|
|
1585
|
+
if (typeof v === "boolean") return v ? 1 : 0;
|
|
1586
|
+
if (v instanceof Uint8Array) {
|
|
1587
|
+
return { __blob: Buffer.from(v).toString("base64") };
|
|
1588
|
+
}
|
|
1589
|
+
if (ArrayBuffer.isView(v)) {
|
|
1590
|
+
return { __blob: Buffer.from(v.buffer, v.byteOffset, v.byteLength).toString("base64") };
|
|
1591
|
+
}
|
|
1592
|
+
if (v instanceof ArrayBuffer) {
|
|
1593
|
+
return { __blob: Buffer.from(v).toString("base64") };
|
|
1594
|
+
}
|
|
1595
|
+
if (typeof v === "string" || typeof v === "number") return v;
|
|
1596
|
+
return String(v);
|
|
1597
|
+
}
|
|
1598
|
+
function deserializeValue(v) {
|
|
1599
|
+
if (v === null) return null;
|
|
1600
|
+
if (typeof v === "object" && v !== null && "__blob" in v) {
|
|
1601
|
+
const buf = Buffer.from(v.__blob, "base64");
|
|
1602
|
+
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
1603
|
+
}
|
|
1604
|
+
return v;
|
|
1605
|
+
}
|
|
1606
|
+
function deserializeResultSet(srs) {
|
|
1607
|
+
const rows = srs.rows.map((obj) => {
|
|
1608
|
+
const values = srs.columns.map(
|
|
1609
|
+
(col) => deserializeValue(obj[col] ?? null)
|
|
1610
|
+
);
|
|
1611
|
+
const row = values;
|
|
1612
|
+
for (let i = 0; i < srs.columns.length; i++) {
|
|
1613
|
+
const col = srs.columns[i];
|
|
1614
|
+
if (col !== void 0) {
|
|
1615
|
+
row[col] = values[i] ?? null;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
Object.defineProperty(row, "length", {
|
|
1619
|
+
value: values.length,
|
|
1620
|
+
enumerable: false
|
|
1621
|
+
});
|
|
1622
|
+
return row;
|
|
1623
|
+
});
|
|
1624
|
+
return {
|
|
1625
|
+
columns: srs.columns,
|
|
1626
|
+
columnTypes: srs.columnTypes ?? [],
|
|
1627
|
+
rows,
|
|
1628
|
+
rowsAffected: srs.rowsAffected,
|
|
1629
|
+
lastInsertRowid: srs.lastInsertRowid != null ? BigInt(srs.lastInsertRowid) : void 0,
|
|
1630
|
+
toJSON: () => ({
|
|
1631
|
+
columns: srs.columns,
|
|
1632
|
+
columnTypes: srs.columnTypes ?? [],
|
|
1633
|
+
rows: srs.rows,
|
|
1634
|
+
rowsAffected: srs.rowsAffected,
|
|
1635
|
+
lastInsertRowid: srs.lastInsertRowid
|
|
1636
|
+
})
|
|
1637
|
+
};
|
|
1638
|
+
}
|
|
1639
|
+
var init_daemon_protocol = __esm({
|
|
1640
|
+
"src/lib/daemon-protocol.ts"() {
|
|
1641
|
+
"use strict";
|
|
1642
|
+
}
|
|
1643
|
+
});
|
|
1644
|
+
|
|
1645
|
+
// src/lib/db-daemon-client.ts
|
|
1646
|
+
var db_daemon_client_exports = {};
|
|
1647
|
+
__export(db_daemon_client_exports, {
|
|
1648
|
+
createDaemonDbClient: () => createDaemonDbClient,
|
|
1649
|
+
initDaemonDbClient: () => initDaemonDbClient
|
|
1650
|
+
});
|
|
1651
|
+
function normalizeStatement2(stmt) {
|
|
1652
|
+
if (typeof stmt === "string") {
|
|
1653
|
+
return { sql: stmt, args: [] };
|
|
1654
|
+
}
|
|
1655
|
+
const sql = stmt.sql;
|
|
1656
|
+
let args = [];
|
|
1657
|
+
if (Array.isArray(stmt.args)) {
|
|
1658
|
+
args = stmt.args.map((v) => serializeValue(v));
|
|
1659
|
+
} else if (stmt.args && typeof stmt.args === "object") {
|
|
1660
|
+
const named = {};
|
|
1661
|
+
for (const [key, val] of Object.entries(stmt.args)) {
|
|
1662
|
+
named[key] = serializeValue(val);
|
|
1663
|
+
}
|
|
1664
|
+
return { sql, args: named };
|
|
1665
|
+
}
|
|
1666
|
+
return { sql, args };
|
|
1667
|
+
}
|
|
1668
|
+
function createDaemonDbClient(fallbackClient) {
|
|
1669
|
+
let _useDaemon = false;
|
|
1670
|
+
const client = {
|
|
1671
|
+
async execute(stmt) {
|
|
1672
|
+
if (!_useDaemon || !isClientConnected()) {
|
|
1673
|
+
return fallbackClient.execute(stmt);
|
|
1674
|
+
}
|
|
1675
|
+
const { sql, args } = normalizeStatement2(stmt);
|
|
1676
|
+
const response = await sendDaemonRequest({
|
|
1677
|
+
type: "db-execute",
|
|
1678
|
+
sql,
|
|
1679
|
+
args
|
|
1680
|
+
});
|
|
1681
|
+
if (response.error) {
|
|
1682
|
+
const errMsg = String(response.error);
|
|
1683
|
+
if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed" || errMsg === "DB not initialized") {
|
|
1684
|
+
process.stderr.write(`[db-daemon] Transport error (${errMsg}), falling back to direct
|
|
1685
|
+
`);
|
|
1686
|
+
return fallbackClient.execute(stmt);
|
|
1687
|
+
}
|
|
1688
|
+
throw new Error(errMsg);
|
|
1689
|
+
}
|
|
1690
|
+
if (response.db) {
|
|
1691
|
+
return deserializeResultSet(response.db);
|
|
1692
|
+
}
|
|
1693
|
+
process.stderr.write("[db-daemon] Unexpected response shape, falling back to direct\n");
|
|
1694
|
+
return fallbackClient.execute(stmt);
|
|
1695
|
+
},
|
|
1696
|
+
async batch(stmts, mode) {
|
|
1697
|
+
if (!_useDaemon || !isClientConnected()) {
|
|
1698
|
+
return fallbackClient.batch(stmts, mode);
|
|
1699
|
+
}
|
|
1700
|
+
const statements = stmts.map(normalizeStatement2);
|
|
1701
|
+
const response = await sendDaemonRequest({
|
|
1702
|
+
type: "db-batch",
|
|
1703
|
+
statements,
|
|
1704
|
+
mode: mode ?? "deferred"
|
|
1705
|
+
});
|
|
1706
|
+
if (response.error) {
|
|
1707
|
+
const errMsg = String(response.error);
|
|
1708
|
+
if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed" || errMsg === "DB not initialized") {
|
|
1709
|
+
process.stderr.write(`[db-daemon] Batch transport error (${errMsg}), falling back to direct
|
|
1710
|
+
`);
|
|
1711
|
+
return fallbackClient.batch(stmts, mode);
|
|
1712
|
+
}
|
|
1713
|
+
throw new Error(errMsg);
|
|
1714
|
+
}
|
|
1715
|
+
const batchResults = response["db-batch"];
|
|
1716
|
+
if (batchResults) {
|
|
1717
|
+
return batchResults.map(deserializeResultSet);
|
|
1718
|
+
}
|
|
1719
|
+
process.stderr.write("[db-daemon] Unexpected batch response shape, falling back to direct\n");
|
|
1720
|
+
return fallbackClient.batch(stmts, mode);
|
|
1721
|
+
},
|
|
1722
|
+
// Transaction support — delegate to fallback (transactions need direct connection)
|
|
1723
|
+
async transaction(mode) {
|
|
1724
|
+
return fallbackClient.transaction(mode);
|
|
1725
|
+
},
|
|
1726
|
+
// executeMultiple — delegate to fallback (used only for schema migrations)
|
|
1727
|
+
async executeMultiple(sql) {
|
|
1728
|
+
return fallbackClient.executeMultiple(sql);
|
|
1729
|
+
},
|
|
1730
|
+
// migrate — delegate to fallback
|
|
1731
|
+
async migrate(stmts) {
|
|
1732
|
+
return fallbackClient.migrate(stmts);
|
|
1733
|
+
},
|
|
1734
|
+
// Sync mode — delegate to fallback
|
|
1735
|
+
sync() {
|
|
1736
|
+
return fallbackClient.sync();
|
|
1737
|
+
},
|
|
1738
|
+
close() {
|
|
1739
|
+
_useDaemon = false;
|
|
1740
|
+
},
|
|
1741
|
+
get closed() {
|
|
1742
|
+
return fallbackClient.closed;
|
|
1743
|
+
},
|
|
1744
|
+
get protocol() {
|
|
1745
|
+
return fallbackClient.protocol;
|
|
1746
|
+
}
|
|
1747
|
+
};
|
|
1748
|
+
return {
|
|
1749
|
+
...client,
|
|
1750
|
+
/** Enable daemon routing (call after confirming daemon is connected) */
|
|
1751
|
+
_enableDaemon() {
|
|
1752
|
+
_useDaemon = true;
|
|
1753
|
+
},
|
|
1754
|
+
/** Check if daemon routing is active */
|
|
1755
|
+
_isDaemonActive() {
|
|
1756
|
+
return _useDaemon && isClientConnected();
|
|
1757
|
+
}
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1760
|
+
async function initDaemonDbClient(fallbackClient) {
|
|
1761
|
+
if (process.env.EXE_IS_DAEMON === "1") return null;
|
|
1762
|
+
const connected = await connectEmbedDaemon();
|
|
1763
|
+
if (!connected) {
|
|
1764
|
+
process.stderr.write("[db-daemon] Daemon unavailable \u2014 using direct SQLite\n");
|
|
1765
|
+
return null;
|
|
1766
|
+
}
|
|
1767
|
+
const client = createDaemonDbClient(fallbackClient);
|
|
1768
|
+
client._enableDaemon();
|
|
1769
|
+
process.stderr.write("[db-daemon] DB routing through daemon (single-writer)\n");
|
|
1770
|
+
return client;
|
|
1771
|
+
}
|
|
1772
|
+
var init_db_daemon_client = __esm({
|
|
1773
|
+
"src/lib/db-daemon-client.ts"() {
|
|
1774
|
+
"use strict";
|
|
1775
|
+
init_exe_daemon_client();
|
|
1776
|
+
init_daemon_protocol();
|
|
1777
|
+
}
|
|
1778
|
+
});
|
|
1779
|
+
|
|
1252
1780
|
// src/lib/database.ts
|
|
1781
|
+
var database_exports = {};
|
|
1782
|
+
__export(database_exports, {
|
|
1783
|
+
disposeDatabase: () => disposeDatabase,
|
|
1784
|
+
disposeTurso: () => disposeTurso,
|
|
1785
|
+
ensureSchema: () => ensureSchema,
|
|
1786
|
+
getClient: () => getClient,
|
|
1787
|
+
getRawClient: () => getRawClient,
|
|
1788
|
+
initDaemonClient: () => initDaemonClient,
|
|
1789
|
+
initDatabase: () => initDatabase,
|
|
1790
|
+
initTurso: () => initTurso,
|
|
1791
|
+
isInitialized: () => isInitialized
|
|
1792
|
+
});
|
|
1253
1793
|
import { createClient } from "@libsql/client";
|
|
1254
1794
|
async function initDatabase(config) {
|
|
1255
1795
|
if (_walCheckpointTimer) {
|
|
@@ -1288,15 +1828,18 @@ async function initDatabase(config) {
|
|
|
1288
1828
|
});
|
|
1289
1829
|
}, 3e4);
|
|
1290
1830
|
_walCheckpointTimer.unref();
|
|
1291
|
-
if (process.env.DATABASE_URL) {
|
|
1831
|
+
if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
|
|
1292
1832
|
_adapterClient = await createPrismaDbAdapter(_resilientClient);
|
|
1293
1833
|
}
|
|
1294
1834
|
}
|
|
1835
|
+
function isInitialized() {
|
|
1836
|
+
return _adapterClient !== null || _client !== null;
|
|
1837
|
+
}
|
|
1295
1838
|
function getClient() {
|
|
1296
1839
|
if (!_adapterClient) {
|
|
1297
1840
|
throw new Error("Database client not initialized. Call initDatabase() first.");
|
|
1298
1841
|
}
|
|
1299
|
-
if (process.env.DATABASE_URL) {
|
|
1842
|
+
if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
|
|
1300
1843
|
return _adapterClient;
|
|
1301
1844
|
}
|
|
1302
1845
|
if (process.env.EXE_IS_DAEMON === "1") {
|
|
@@ -1307,6 +1850,22 @@ function getClient() {
|
|
|
1307
1850
|
}
|
|
1308
1851
|
return _resilientClient;
|
|
1309
1852
|
}
|
|
1853
|
+
async function initDaemonClient() {
|
|
1854
|
+
if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") return;
|
|
1855
|
+
if (process.env.EXE_IS_DAEMON === "1") return;
|
|
1856
|
+
if (process.env.VITEST) return;
|
|
1857
|
+
if (!_resilientClient) return;
|
|
1858
|
+
if (_daemonClient) return;
|
|
1859
|
+
try {
|
|
1860
|
+
const { initDaemonDbClient: initDaemonDbClient2 } = await Promise.resolve().then(() => (init_db_daemon_client(), db_daemon_client_exports));
|
|
1861
|
+
_daemonClient = await initDaemonDbClient2(_resilientClient);
|
|
1862
|
+
} catch (err) {
|
|
1863
|
+
process.stderr.write(
|
|
1864
|
+
`[database] Daemon client init failed (non-fatal): ${err instanceof Error ? err.message : String(err)}
|
|
1865
|
+
`
|
|
1866
|
+
);
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1310
1869
|
function getRawClient() {
|
|
1311
1870
|
if (!_client) {
|
|
1312
1871
|
throw new Error("Database client not initialized. Call initDatabase() first.");
|
|
@@ -1445,6 +2004,13 @@ async function ensureSchema() {
|
|
|
1445
2004
|
});
|
|
1446
2005
|
} catch {
|
|
1447
2006
|
}
|
|
2007
|
+
try {
|
|
2008
|
+
await client.execute({
|
|
2009
|
+
sql: `ALTER TABLE behaviors ADD COLUMN vector F32_BLOB(${EMBEDDING_DIM})`,
|
|
2010
|
+
args: []
|
|
2011
|
+
});
|
|
2012
|
+
} catch {
|
|
2013
|
+
}
|
|
1448
2014
|
try {
|
|
1449
2015
|
await client.execute({
|
|
1450
2016
|
sql: `ALTER TABLE tasks ADD COLUMN blocked_by TEXT`,
|
|
@@ -2315,6 +2881,7 @@ var init_database = __esm({
|
|
|
2315
2881
|
init_db_retry();
|
|
2316
2882
|
init_employees();
|
|
2317
2883
|
init_database_adapter();
|
|
2884
|
+
init_memory();
|
|
2318
2885
|
_client = null;
|
|
2319
2886
|
_resilientClient = null;
|
|
2320
2887
|
_walCheckpointTimer = null;
|
|
@@ -2339,12 +2906,12 @@ __export(shard_manager_exports, {
|
|
|
2339
2906
|
listShards: () => listShards,
|
|
2340
2907
|
shardExists: () => shardExists
|
|
2341
2908
|
});
|
|
2342
|
-
import
|
|
2343
|
-
import { existsSync as
|
|
2909
|
+
import path8 from "path";
|
|
2910
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync2, readdirSync } from "fs";
|
|
2344
2911
|
import { createClient as createClient2 } from "@libsql/client";
|
|
2345
2912
|
function initShardManager(encryptionKey) {
|
|
2346
2913
|
_encryptionKey = encryptionKey;
|
|
2347
|
-
if (!
|
|
2914
|
+
if (!existsSync8(SHARDS_DIR)) {
|
|
2348
2915
|
mkdirSync2(SHARDS_DIR, { recursive: true });
|
|
2349
2916
|
}
|
|
2350
2917
|
_shardingEnabled = true;
|
|
@@ -2374,7 +2941,7 @@ function getShardClient(projectName) {
|
|
|
2374
2941
|
while (_shards.size >= MAX_OPEN_SHARDS) {
|
|
2375
2942
|
evictLRU();
|
|
2376
2943
|
}
|
|
2377
|
-
const dbPath =
|
|
2944
|
+
const dbPath = path8.join(SHARDS_DIR, `${safeName}.db`);
|
|
2378
2945
|
const client = createClient2({
|
|
2379
2946
|
url: `file:${dbPath}`,
|
|
2380
2947
|
encryptionKey: _encryptionKey
|
|
@@ -2385,10 +2952,10 @@ function getShardClient(projectName) {
|
|
|
2385
2952
|
}
|
|
2386
2953
|
function shardExists(projectName) {
|
|
2387
2954
|
const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
2388
|
-
return
|
|
2955
|
+
return existsSync8(path8.join(SHARDS_DIR, `${safeName}.db`));
|
|
2389
2956
|
}
|
|
2390
2957
|
function listShards() {
|
|
2391
|
-
if (!
|
|
2958
|
+
if (!existsSync8(SHARDS_DIR)) return [];
|
|
2392
2959
|
return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
2393
2960
|
}
|
|
2394
2961
|
async function ensureShardSchema(client) {
|
|
@@ -2635,7 +3202,7 @@ var init_shard_manager = __esm({
|
|
|
2635
3202
|
"src/lib/shard-manager.ts"() {
|
|
2636
3203
|
"use strict";
|
|
2637
3204
|
init_config();
|
|
2638
|
-
SHARDS_DIR =
|
|
3205
|
+
SHARDS_DIR = path8.join(EXE_AI_DIR, "shards");
|
|
2639
3206
|
SHARD_IDLE_MS = 5 * 60 * 1e3;
|
|
2640
3207
|
MAX_OPEN_SHARDS = 10;
|
|
2641
3208
|
EVICTION_INTERVAL_MS = 60 * 1e3;
|
|
@@ -2755,6 +3322,68 @@ var init_platform_procedures = __esm({
|
|
|
2755
3322
|
domain: "architecture",
|
|
2756
3323
|
priority: "p0",
|
|
2757
3324
|
content: "Tasks live in the DB. Intercom (tmux send-keys) is fire-and-forget \u2014 it may fail, get garbled, or arrive mid-work. Never rely on intercom for task delivery. The UserPromptSubmit hook checks the DB for new tasks on every prompt. Your operating procedures step 7 says check for next work. The daemon nudges idle agents as a speedup. If you have no tasks, you found them all."
|
|
3325
|
+
},
|
|
3326
|
+
// --- MCP is the ONLY data interface ---
|
|
3327
|
+
{
|
|
3328
|
+
title: "MCP disconnect \u2014 ask the user, never work around it",
|
|
3329
|
+
domain: "workflow",
|
|
3330
|
+
priority: "p0",
|
|
3331
|
+
content: "If MCP tools are unavailable, disconnected, or returning connection errors: STOP. Tell the user clearly: 'MCP server is disconnected. Please run /mcp to reconnect.' Do NOT attempt workarounds \u2014 no raw Node imports, no direct DB access, no CLI hacks, no daemon socket calls. MCP is the ONLY data interface. Working around it wastes time, hits bundling issues, and bypasses the contract boundary. Ask once, wait, proceed when reconnected."
|
|
3332
|
+
},
|
|
3333
|
+
// --- MCP Tool Catalog (Layer 0 — every agent knows what tools exist) ---
|
|
3334
|
+
{
|
|
3335
|
+
title: "MCP tools \u2014 memory and search",
|
|
3336
|
+
domain: "tool-use",
|
|
3337
|
+
priority: "p1",
|
|
3338
|
+
content: "recall_my_memory: search your own memories (semantic + FTS). ask_team_memory: search a colleague's memories by agent name. store_memory: persist a memory (decisions, summaries, context). commit_memory: high-importance memory that survives consolidation. search_everything: unified search across memories, tasks, entities, conversations. get_session_context: temporal window of memories around a timestamp. consolidate_memories: merge duplicate/related memories into insights. get_memory_cardinality: count memories per agent (health check)."
|
|
3339
|
+
},
|
|
3340
|
+
{
|
|
3341
|
+
title: "MCP tools \u2014 task orchestration",
|
|
3342
|
+
domain: "tool-use",
|
|
3343
|
+
priority: "p1",
|
|
3344
|
+
content: "create_task: dispatch work to an employee (auto-spawns session). The ONLY dispatch path. list_tasks: query tasks by status, assignee, project. get_task: fetch full task details by ID. update_task: change status (in_progress, done, blocked, cancelled) + add result summary. close_task: finalize a reviewed task (COO only). checkpoint_task: save progress state for crash recovery. resume_employee: re-spawn an employee session for an existing task."
|
|
3345
|
+
},
|
|
3346
|
+
{
|
|
3347
|
+
title: "MCP tools \u2014 knowledge graph (GraphRAG)",
|
|
3348
|
+
domain: "tool-use",
|
|
3349
|
+
priority: "p1",
|
|
3350
|
+
content: "query_relationships: find connections between entities in the knowledge graph. get_entity_neighbors: explore an entity's direct connections. get_hot_entities: find most-referenced entities (trending topics). get_graph_stats: graph health \u2014 entity/relationship counts, density. export_graph: export graph data for visualization. merge_entities: deduplicate entities (alias resolution). find_similar_trajectories: match tool-call patterns to past task solutions."
|
|
3351
|
+
},
|
|
3352
|
+
{
|
|
3353
|
+
title: "MCP tools \u2014 identity, behavior, and decisions",
|
|
3354
|
+
domain: "tool-use",
|
|
3355
|
+
priority: "p1",
|
|
3356
|
+
content: "get_identity: read an agent's exe.md (Layer 1 identity). update_identity: write an agent's exe.md. Identity > behavior \u2014 use for permanent rules. store_behavior: record a correction or pattern for an agent (Layer 2 expertise). list_behaviors: view an agent's active behaviors. deactivate_behavior: soft-delete a stale or conflicting behavior. store_decision: record an ADR (architectural decision record). get_decision: retrieve a past decision by query."
|
|
3357
|
+
},
|
|
3358
|
+
{
|
|
3359
|
+
title: "MCP tools \u2014 communication and messaging",
|
|
3360
|
+
domain: "tool-use",
|
|
3361
|
+
priority: "p1",
|
|
3362
|
+
content: "send_message: send supplementary context to another agent (NOT for actionable work \u2014 use create_task). acknowledge_messages: mark messages as read. send_whatsapp: send WhatsApp message via gateway (customer-facing alerts). query_conversations: search ingested conversations across all channels (WhatsApp, email, etc.)."
|
|
3363
|
+
},
|
|
3364
|
+
{
|
|
3365
|
+
title: "MCP tools \u2014 wiki, documents, and content",
|
|
3366
|
+
domain: "tool-use",
|
|
3367
|
+
priority: "p1",
|
|
3368
|
+
content: "create_wiki_page: create a wiki page in exe-wiki. list_wiki_pages: browse wiki pages. get_wiki_page: read a wiki page. update_wiki_page: edit a wiki page. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
|
|
3369
|
+
},
|
|
3370
|
+
{
|
|
3371
|
+
title: "MCP tools \u2014 system, operations, and admin",
|
|
3372
|
+
domain: "tool-use",
|
|
3373
|
+
priority: "p1",
|
|
3374
|
+
content: "get_agent_spend: token usage per agent/session (cost tracking). list_agent_sessions: view agent session history. get_session_kills: audit log of killed sessions. get_daemon_health: check exed daemon status. get_auto_wake_status: daemon auto-wake configuration. get_worker_gate: check worker deployment gates. run_memory_audit: health check \u2014 duplicates, null vectors, orphaned rows. run_consolidation: trigger sleep-time memory consolidation. cloud_sync: force a cloud sync cycle. backup_vps: trigger VPS backup."
|
|
3375
|
+
},
|
|
3376
|
+
{
|
|
3377
|
+
title: "MCP tools \u2014 config, licensing, and team",
|
|
3378
|
+
domain: "tool-use",
|
|
3379
|
+
priority: "p1",
|
|
3380
|
+
content: "set_agent_config: view/change per-agent runtime and model settings. list_employees: view the employee roster. add_person: add a person to the CRM contacts roster. list_people: browse CRM contacts. get_person: fetch contact details. get_license_status: check license validity. create_license: generate a new license key (admin). list_licenses: view all issued licenses. activate_license: activate a license on a device."
|
|
3381
|
+
},
|
|
3382
|
+
{
|
|
3383
|
+
title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
|
|
3384
|
+
domain: "tool-use",
|
|
3385
|
+
priority: "p1",
|
|
3386
|
+
content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done. global_procedure: manage Layer 0 procedures (actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
|
|
2758
3387
|
}
|
|
2759
3388
|
];
|
|
2760
3389
|
PLATFORM_PROCEDURE_TITLES = new Set(
|
|
@@ -2771,7 +3400,7 @@ __export(global_procedures_exports, {
|
|
|
2771
3400
|
loadGlobalProcedures: () => loadGlobalProcedures,
|
|
2772
3401
|
storeGlobalProcedure: () => storeGlobalProcedure
|
|
2773
3402
|
});
|
|
2774
|
-
import { randomUUID } from "crypto";
|
|
3403
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
2775
3404
|
async function loadGlobalProcedures() {
|
|
2776
3405
|
const client = getClient();
|
|
2777
3406
|
const result = await client.execute({
|
|
@@ -2800,7 +3429,7 @@ ${sections.join("\n\n")}
|
|
|
2800
3429
|
`;
|
|
2801
3430
|
}
|
|
2802
3431
|
async function storeGlobalProcedure(input) {
|
|
2803
|
-
const id =
|
|
3432
|
+
const id = randomUUID2();
|
|
2804
3433
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2805
3434
|
const client = getClient();
|
|
2806
3435
|
await client.execute({
|
|
@@ -3529,9 +4158,9 @@ __export(active_agent_exports, {
|
|
|
3529
4158
|
resolveActiveAgentFromTmuxSession: () => resolveActiveAgentFromTmuxSession,
|
|
3530
4159
|
writeActiveAgent: () => writeActiveAgent
|
|
3531
4160
|
});
|
|
3532
|
-
import { readFileSync as
|
|
4161
|
+
import { readFileSync as readFileSync6, writeFileSync as writeFileSync5, mkdirSync as mkdirSync4, unlinkSync as unlinkSync4, readdirSync as readdirSync3 } from "fs";
|
|
3533
4162
|
import { execSync as execSync4 } from "child_process";
|
|
3534
|
-
import
|
|
4163
|
+
import path10 from "path";
|
|
3535
4164
|
function isNameWithOptionalInstance(candidate, baseName) {
|
|
3536
4165
|
if (candidate === baseName) return true;
|
|
3537
4166
|
if (!candidate.startsWith(baseName)) return false;
|
|
@@ -3575,12 +4204,12 @@ function resolveActiveAgentFromTmuxSession(sessionName) {
|
|
|
3575
4204
|
return null;
|
|
3576
4205
|
}
|
|
3577
4206
|
function getMarkerPath() {
|
|
3578
|
-
return
|
|
4207
|
+
return path10.join(CACHE_DIR, `active-agent-${getSessionKey()}.json`);
|
|
3579
4208
|
}
|
|
3580
4209
|
function writeActiveAgent(agentId, agentRole) {
|
|
3581
4210
|
try {
|
|
3582
4211
|
mkdirSync4(CACHE_DIR, { recursive: true });
|
|
3583
|
-
|
|
4212
|
+
writeFileSync5(
|
|
3584
4213
|
getMarkerPath(),
|
|
3585
4214
|
JSON.stringify({ agentId, agentRole, startedAt: (/* @__PURE__ */ new Date()).toISOString() })
|
|
3586
4215
|
);
|
|
@@ -3589,21 +4218,21 @@ function writeActiveAgent(agentId, agentRole) {
|
|
|
3589
4218
|
}
|
|
3590
4219
|
function clearActiveAgent() {
|
|
3591
4220
|
try {
|
|
3592
|
-
|
|
4221
|
+
unlinkSync4(getMarkerPath());
|
|
3593
4222
|
} catch {
|
|
3594
4223
|
}
|
|
3595
4224
|
}
|
|
3596
4225
|
function getActiveAgent() {
|
|
3597
4226
|
try {
|
|
3598
4227
|
const markerPath = getMarkerPath();
|
|
3599
|
-
const raw =
|
|
4228
|
+
const raw = readFileSync6(markerPath, "utf8");
|
|
3600
4229
|
const data = JSON.parse(raw);
|
|
3601
4230
|
if (data.agentId) {
|
|
3602
4231
|
if (data.startedAt) {
|
|
3603
4232
|
const age = Date.now() - new Date(data.startedAt).getTime();
|
|
3604
4233
|
if (age > STALE_MS) {
|
|
3605
4234
|
try {
|
|
3606
|
-
|
|
4235
|
+
unlinkSync4(markerPath);
|
|
3607
4236
|
} catch {
|
|
3608
4237
|
}
|
|
3609
4238
|
} else {
|
|
@@ -3644,14 +4273,14 @@ function getAllActiveAgents() {
|
|
|
3644
4273
|
const key = file.slice("active-agent-".length, -".json".length);
|
|
3645
4274
|
if (key === "undefined") continue;
|
|
3646
4275
|
try {
|
|
3647
|
-
const raw =
|
|
4276
|
+
const raw = readFileSync6(path10.join(CACHE_DIR, file), "utf8");
|
|
3648
4277
|
const data = JSON.parse(raw);
|
|
3649
4278
|
if (!data.agentId) continue;
|
|
3650
4279
|
if (data.startedAt) {
|
|
3651
4280
|
const age = Date.now() - new Date(data.startedAt).getTime();
|
|
3652
4281
|
if (age > STALE_MS) {
|
|
3653
4282
|
try {
|
|
3654
|
-
|
|
4283
|
+
unlinkSync4(path10.join(CACHE_DIR, file));
|
|
3655
4284
|
} catch {
|
|
3656
4285
|
}
|
|
3657
4286
|
continue;
|
|
@@ -3674,11 +4303,11 @@ function getAllActiveAgents() {
|
|
|
3674
4303
|
function cleanupSessionMarkers() {
|
|
3675
4304
|
const key = getSessionKey();
|
|
3676
4305
|
try {
|
|
3677
|
-
|
|
4306
|
+
unlinkSync4(path10.join(CACHE_DIR, `active-agent-${key}.json`));
|
|
3678
4307
|
} catch {
|
|
3679
4308
|
}
|
|
3680
4309
|
try {
|
|
3681
|
-
|
|
4310
|
+
unlinkSync4(path10.join(CACHE_DIR, "active-agent-undefined.json"));
|
|
3682
4311
|
} catch {
|
|
3683
4312
|
}
|
|
3684
4313
|
}
|
|
@@ -3689,33 +4318,34 @@ var init_active_agent = __esm({
|
|
|
3689
4318
|
init_config();
|
|
3690
4319
|
init_session_key();
|
|
3691
4320
|
init_employees();
|
|
3692
|
-
CACHE_DIR =
|
|
4321
|
+
CACHE_DIR = path10.join(EXE_AI_DIR, "session-cache");
|
|
3693
4322
|
STALE_MS = 24 * 60 * 60 * 1e3;
|
|
3694
4323
|
}
|
|
3695
4324
|
});
|
|
3696
4325
|
|
|
3697
4326
|
// src/bin/exe-launch-agent.ts
|
|
3698
|
-
import
|
|
3699
|
-
import
|
|
3700
|
-
import { existsSync as
|
|
4327
|
+
import os7 from "os";
|
|
4328
|
+
import path11 from "path";
|
|
4329
|
+
import { existsSync as existsSync10, readFileSync as readFileSync7, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, readdirSync as readdirSync4 } from "fs";
|
|
3701
4330
|
import { spawnSync } from "child_process";
|
|
3702
4331
|
|
|
3703
4332
|
// src/lib/store.ts
|
|
3704
|
-
|
|
4333
|
+
init_memory();
|
|
3705
4334
|
init_database();
|
|
4335
|
+
import { createHash } from "crypto";
|
|
3706
4336
|
|
|
3707
4337
|
// src/lib/keychain.ts
|
|
3708
4338
|
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
3709
|
-
import { existsSync as
|
|
3710
|
-
import
|
|
3711
|
-
import
|
|
4339
|
+
import { existsSync as existsSync7 } from "fs";
|
|
4340
|
+
import path7 from "path";
|
|
4341
|
+
import os5 from "os";
|
|
3712
4342
|
var SERVICE = "exe-mem";
|
|
3713
4343
|
var ACCOUNT = "master-key";
|
|
3714
4344
|
function getKeyDir() {
|
|
3715
|
-
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ??
|
|
4345
|
+
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path7.join(os5.homedir(), ".exe-os");
|
|
3716
4346
|
}
|
|
3717
4347
|
function getKeyPath() {
|
|
3718
|
-
return
|
|
4348
|
+
return path7.join(getKeyDir(), "master.key");
|
|
3719
4349
|
}
|
|
3720
4350
|
async function tryKeytar() {
|
|
3721
4351
|
try {
|
|
@@ -3736,9 +4366,9 @@ async function getMasterKey() {
|
|
|
3736
4366
|
}
|
|
3737
4367
|
}
|
|
3738
4368
|
const keyPath = getKeyPath();
|
|
3739
|
-
if (!
|
|
4369
|
+
if (!existsSync7(keyPath)) {
|
|
3740
4370
|
process.stderr.write(
|
|
3741
|
-
`[keychain] Key not found at ${keyPath} (HOME=${
|
|
4371
|
+
`[keychain] Key not found at ${keyPath} (HOME=${os5.homedir()}, EXE_OS_DIR=${process.env.EXE_OS_DIR ?? "unset"})
|
|
3742
4372
|
`
|
|
3743
4373
|
);
|
|
3744
4374
|
return null;
|
|
@@ -3867,6 +4497,11 @@ async function initStore(options) {
|
|
|
3867
4497
|
encryptionKey: hexKey
|
|
3868
4498
|
});
|
|
3869
4499
|
await retryOnBusy2(() => ensureSchema(), "ensureSchema");
|
|
4500
|
+
try {
|
|
4501
|
+
const { initDaemonClient: initDaemonClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
4502
|
+
await initDaemonClient2();
|
|
4503
|
+
} catch {
|
|
4504
|
+
}
|
|
3870
4505
|
if (!options?.lightweight) {
|
|
3871
4506
|
try {
|
|
3872
4507
|
const { initShardManager: initShardManager2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
|
|
@@ -4049,24 +4684,24 @@ function vectorToBlob(vector) {
|
|
|
4049
4684
|
}
|
|
4050
4685
|
|
|
4051
4686
|
// src/lib/behaviors-export.ts
|
|
4052
|
-
import
|
|
4053
|
-
import
|
|
4687
|
+
import os6 from "os";
|
|
4688
|
+
import path9 from "path";
|
|
4054
4689
|
import {
|
|
4055
|
-
existsSync as
|
|
4690
|
+
existsSync as existsSync9,
|
|
4056
4691
|
mkdirSync as mkdirSync3,
|
|
4057
4692
|
readdirSync as readdirSync2,
|
|
4058
|
-
statSync,
|
|
4059
|
-
unlinkSync as
|
|
4060
|
-
writeFileSync as
|
|
4693
|
+
statSync as statSync2,
|
|
4694
|
+
unlinkSync as unlinkSync3,
|
|
4695
|
+
writeFileSync as writeFileSync4
|
|
4061
4696
|
} from "fs";
|
|
4062
4697
|
|
|
4063
4698
|
// src/lib/behaviors.ts
|
|
4064
4699
|
init_database();
|
|
4065
|
-
import
|
|
4700
|
+
import crypto2 from "crypto";
|
|
4066
4701
|
async function listBehaviors(agentId, projectName, limit = 30) {
|
|
4067
4702
|
const client = getClient();
|
|
4068
4703
|
const result = await client.execute({
|
|
4069
|
-
sql: `SELECT id, agent_id, project_name, domain, priority, content, active, created_at, updated_at
|
|
4704
|
+
sql: `SELECT id, agent_id, project_name, domain, priority, content, active, created_at, updated_at, vector
|
|
4070
4705
|
FROM behaviors
|
|
4071
4706
|
WHERE agent_id = ? AND active = 1
|
|
4072
4707
|
AND (project_name IS NULL OR project_name = ?)
|
|
@@ -4087,20 +4722,21 @@ async function listBehaviors(agentId, projectName, limit = 30) {
|
|
|
4087
4722
|
content: String(r.content),
|
|
4088
4723
|
active: Number(r.active),
|
|
4089
4724
|
created_at: String(r.created_at),
|
|
4090
|
-
updated_at: String(r.updated_at)
|
|
4725
|
+
updated_at: String(r.updated_at),
|
|
4726
|
+
vector: r.vector ? Array.from(new Float32Array(r.vector)) : null
|
|
4091
4727
|
}));
|
|
4092
4728
|
}
|
|
4093
4729
|
|
|
4094
4730
|
// src/lib/behaviors-export.ts
|
|
4095
|
-
var BEHAVIORS_EXPORT_DIR =
|
|
4096
|
-
|
|
4731
|
+
var BEHAVIORS_EXPORT_DIR = path9.join(
|
|
4732
|
+
os6.homedir(),
|
|
4097
4733
|
".exe-os",
|
|
4098
4734
|
"behaviors-export"
|
|
4099
4735
|
);
|
|
4100
4736
|
var STALE_EXPORT_AGE_MS = 60 * 60 * 1e3;
|
|
4101
4737
|
var EXPORT_BEHAVIOR_LIMIT = 30;
|
|
4102
4738
|
function sweepStaleBehaviorExports(now = Date.now()) {
|
|
4103
|
-
if (!
|
|
4739
|
+
if (!existsSync9(BEHAVIORS_EXPORT_DIR)) return;
|
|
4104
4740
|
let entries;
|
|
4105
4741
|
try {
|
|
4106
4742
|
entries = readdirSync2(BEHAVIORS_EXPORT_DIR);
|
|
@@ -4108,11 +4744,11 @@ function sweepStaleBehaviorExports(now = Date.now()) {
|
|
|
4108
4744
|
return;
|
|
4109
4745
|
}
|
|
4110
4746
|
for (const entry of entries) {
|
|
4111
|
-
const filePath =
|
|
4747
|
+
const filePath = path9.join(BEHAVIORS_EXPORT_DIR, entry);
|
|
4112
4748
|
try {
|
|
4113
|
-
const stat =
|
|
4749
|
+
const stat = statSync2(filePath);
|
|
4114
4750
|
if (now - stat.mtimeMs > STALE_EXPORT_AGE_MS) {
|
|
4115
|
-
|
|
4751
|
+
unlinkSync3(filePath);
|
|
4116
4752
|
}
|
|
4117
4753
|
} catch {
|
|
4118
4754
|
}
|
|
@@ -4141,10 +4777,10 @@ function renderBehaviorExport(behaviors) {
|
|
|
4141
4777
|
}
|
|
4142
4778
|
function exportFilePath(agentId, projectName, sessionKey) {
|
|
4143
4779
|
if (!sessionKey) {
|
|
4144
|
-
return
|
|
4780
|
+
return path9.join(BEHAVIORS_EXPORT_DIR, `${agentId}.md`);
|
|
4145
4781
|
}
|
|
4146
4782
|
const safeProject = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
4147
|
-
return
|
|
4783
|
+
return path9.join(
|
|
4148
4784
|
BEHAVIORS_EXPORT_DIR,
|
|
4149
4785
|
`${agentId}-${safeProject}-${sessionKey}.md`
|
|
4150
4786
|
);
|
|
@@ -4156,7 +4792,7 @@ async function exportBehaviorsForAgent(agentId, projectName, sessionKey) {
|
|
|
4156
4792
|
if (behaviors.length === 0) return null;
|
|
4157
4793
|
const body = renderBehaviorExport(behaviors);
|
|
4158
4794
|
const target = exportFilePath(agentId, projectName, sessionKey);
|
|
4159
|
-
|
|
4795
|
+
writeFileSync4(target, body, "utf-8");
|
|
4160
4796
|
return target;
|
|
4161
4797
|
}
|
|
4162
4798
|
|
|
@@ -4215,7 +4851,7 @@ function parseBasename(basename) {
|
|
|
4215
4851
|
return { agent, provider };
|
|
4216
4852
|
}
|
|
4217
4853
|
function resolveAgent(argv) {
|
|
4218
|
-
const invokedAs =
|
|
4854
|
+
const invokedAs = path11.basename(argv[1] ?? "");
|
|
4219
4855
|
if (invokedAs && invokedAs !== "exe-launch-agent" && !invokedAs.endsWith(".js")) {
|
|
4220
4856
|
const { agent: agent2, provider } = parseBasename(invokedAs.toLowerCase());
|
|
4221
4857
|
return { agent: agent2, provider, passthrough: argv.slice(2) };
|
|
@@ -4244,20 +4880,20 @@ async function isKnownAgent(agent) {
|
|
|
4244
4880
|
}
|
|
4245
4881
|
}
|
|
4246
4882
|
function identityPathFor(agent) {
|
|
4247
|
-
const dir =
|
|
4248
|
-
const exactPath =
|
|
4249
|
-
if (
|
|
4883
|
+
const dir = path11.join(os7.homedir(), ".exe-os", "identity");
|
|
4884
|
+
const exactPath = path11.join(dir, `${agent}.md`);
|
|
4885
|
+
if (existsSync10(exactPath)) return exactPath;
|
|
4250
4886
|
try {
|
|
4251
4887
|
const files = readdirSync4(dir);
|
|
4252
4888
|
const match = files.find((f) => f.toLowerCase() === `${agent.toLowerCase()}.md`);
|
|
4253
|
-
if (match) return
|
|
4889
|
+
if (match) return path11.join(dir, match);
|
|
4254
4890
|
} catch {
|
|
4255
4891
|
}
|
|
4256
4892
|
return exactPath;
|
|
4257
4893
|
}
|
|
4258
4894
|
function leanMcpConfigFor(agent) {
|
|
4259
|
-
const p =
|
|
4260
|
-
return
|
|
4895
|
+
const p = path11.join(os7.homedir(), ".exe-os", "mcp-configs", `${agent}-lean.json`);
|
|
4896
|
+
return existsSync10(p) ? p : null;
|
|
4261
4897
|
}
|
|
4262
4898
|
var _ccHelpOutput = null;
|
|
4263
4899
|
function getCcHelpOutput() {
|
|
@@ -4280,39 +4916,39 @@ function _resetCcHelpCache() {
|
|
|
4280
4916
|
function buildLaunchPlan(agent, behaviorsPath, passthrough, _hasAgentFlag, _provider) {
|
|
4281
4917
|
const args = ["--dangerously-skip-permissions"];
|
|
4282
4918
|
const idPath = identityPathFor(agent);
|
|
4283
|
-
const ccAgentPath =
|
|
4919
|
+
const ccAgentPath = path11.join(os7.homedir(), ".claude", "agents", `${agent}.md`);
|
|
4284
4920
|
let effectiveCcPath = null;
|
|
4285
|
-
if (
|
|
4921
|
+
if (existsSync10(ccAgentPath)) {
|
|
4286
4922
|
effectiveCcPath = ccAgentPath;
|
|
4287
4923
|
} else {
|
|
4288
4924
|
try {
|
|
4289
|
-
const ccAgentDir =
|
|
4925
|
+
const ccAgentDir = path11.join(os7.homedir(), ".claude", "agents");
|
|
4290
4926
|
const ccFiles = readdirSync4(ccAgentDir);
|
|
4291
4927
|
const ccMatch = ccFiles.find((f) => f.toLowerCase() === `${agent.toLowerCase()}.md`);
|
|
4292
|
-
if (ccMatch) effectiveCcPath =
|
|
4928
|
+
if (ccMatch) effectiveCcPath = path11.join(ccAgentDir, ccMatch);
|
|
4293
4929
|
} catch {
|
|
4294
4930
|
}
|
|
4295
4931
|
}
|
|
4296
|
-
const effectiveIdPath =
|
|
4932
|
+
const effectiveIdPath = existsSync10(idPath) ? idPath : effectiveCcPath;
|
|
4297
4933
|
let identityContent = null;
|
|
4298
|
-
if (effectiveIdPath &&
|
|
4934
|
+
if (effectiveIdPath && existsSync10(effectiveIdPath)) {
|
|
4299
4935
|
try {
|
|
4300
|
-
const content =
|
|
4936
|
+
const content = readFileSync7(effectiveIdPath, "utf-8");
|
|
4301
4937
|
if (content.trim().length > 0) identityContent = content;
|
|
4302
4938
|
} catch {
|
|
4303
4939
|
}
|
|
4304
4940
|
}
|
|
4305
4941
|
if (!identityContent) {
|
|
4306
4942
|
try {
|
|
4307
|
-
const rosterPath =
|
|
4308
|
-
if (
|
|
4309
|
-
const roster = JSON.parse(
|
|
4943
|
+
const rosterPath = path11.join(os7.homedir(), ".exe-os", "exe-employees.json");
|
|
4944
|
+
if (existsSync10(rosterPath)) {
|
|
4945
|
+
const roster = JSON.parse(readFileSync7(rosterPath, "utf8"));
|
|
4310
4946
|
const emp = roster.find((e) => e.name.toLowerCase() === agent.toLowerCase());
|
|
4311
4947
|
if (emp?.systemPrompt && emp.systemPrompt.trim().length > 20) {
|
|
4312
4948
|
identityContent = emp.systemPrompt;
|
|
4313
4949
|
try {
|
|
4314
|
-
const dir =
|
|
4315
|
-
if (!
|
|
4950
|
+
const dir = path11.dirname(idPath);
|
|
4951
|
+
if (!existsSync10(dir)) mkdirSync5(dir, { recursive: true });
|
|
4316
4952
|
const hasFrontmatter = identityContent.trimStart().startsWith("---");
|
|
4317
4953
|
const fileContent = hasFrontmatter ? identityContent : `---
|
|
4318
4954
|
role: ${(emp.role ?? "employee").toLowerCase()}
|
|
@@ -4324,7 +4960,7 @@ updated_at: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
|
4324
4960
|
---
|
|
4325
4961
|
|
|
4326
4962
|
${identityContent}`;
|
|
4327
|
-
|
|
4963
|
+
writeFileSync6(idPath, fileContent, "utf-8");
|
|
4328
4964
|
identityContent = fileContent;
|
|
4329
4965
|
process.stderr.write(`[exe-launch-agent] self-healed missing identity file: ${idPath}
|
|
4330
4966
|
`);
|
|
@@ -4352,15 +4988,15 @@ ${identityContent}`;
|
|
|
4352
4988
|
args.push("--system-prompt", getSessionPrompt(identityContent));
|
|
4353
4989
|
} else {
|
|
4354
4990
|
try {
|
|
4355
|
-
const tmpPath =
|
|
4356
|
-
mkdirSync5(
|
|
4357
|
-
|
|
4991
|
+
const tmpPath = path11.join(os7.homedir(), ".exe-os", "session-cache", `${agent}-identity.md`);
|
|
4992
|
+
mkdirSync5(path11.dirname(tmpPath), { recursive: true });
|
|
4993
|
+
writeFileSync6(tmpPath, identityContent, "utf-8");
|
|
4358
4994
|
args.push("--append-system-prompt-file", tmpPath);
|
|
4359
4995
|
} catch {
|
|
4360
4996
|
}
|
|
4361
4997
|
}
|
|
4362
4998
|
}
|
|
4363
|
-
if (behaviorsPath &&
|
|
4999
|
+
if (behaviorsPath && existsSync10(behaviorsPath)) {
|
|
4364
5000
|
args.push("--append-system-prompt-file", behaviorsPath);
|
|
4365
5001
|
}
|
|
4366
5002
|
const leanMcp = leanMcpConfigFor(agent);
|
|
@@ -4481,28 +5117,28 @@ async function main() {
|
|
|
4481
5117
|
_resetCcAgentSupportCache();
|
|
4482
5118
|
const hasAgentFlag = claudeSupportsAgentFlag();
|
|
4483
5119
|
if (hasAgentFlag) {
|
|
4484
|
-
const ccAgentDir =
|
|
4485
|
-
const ccAgentFile =
|
|
4486
|
-
if (!
|
|
5120
|
+
const ccAgentDir = path11.join(os7.homedir(), ".claude", "agents");
|
|
5121
|
+
const ccAgentFile = path11.join(ccAgentDir, `${agent}.md`);
|
|
5122
|
+
if (!existsSync10(ccAgentFile)) {
|
|
4487
5123
|
const exeIdentity = identityPathFor(agent);
|
|
4488
5124
|
let sourceFile = null;
|
|
4489
|
-
if (
|
|
5125
|
+
if (existsSync10(exeIdentity)) {
|
|
4490
5126
|
sourceFile = exeIdentity;
|
|
4491
5127
|
} else {
|
|
4492
5128
|
try {
|
|
4493
|
-
const identityDir =
|
|
5129
|
+
const identityDir = path11.dirname(exeIdentity);
|
|
4494
5130
|
const files = readdirSync4(identityDir);
|
|
4495
5131
|
const match = files.find((f) => f.toLowerCase() === `${agent.toLowerCase()}.md`);
|
|
4496
|
-
if (match) sourceFile =
|
|
5132
|
+
if (match) sourceFile = path11.join(identityDir, match);
|
|
4497
5133
|
} catch {
|
|
4498
5134
|
}
|
|
4499
5135
|
}
|
|
4500
5136
|
if (sourceFile) {
|
|
4501
5137
|
try {
|
|
4502
5138
|
mkdirSync5(ccAgentDir, { recursive: true });
|
|
4503
|
-
let content =
|
|
5139
|
+
let content = readFileSync7(sourceFile, "utf-8");
|
|
4504
5140
|
content = content.replace(/\$\{agent_id\}/g, baseAgentName(agent));
|
|
4505
|
-
|
|
5141
|
+
writeFileSync6(ccAgentFile, content, "utf-8");
|
|
4506
5142
|
process.stderr.write(
|
|
4507
5143
|
`[exe-launch-agent] auto-provisioned ${ccAgentFile} from ${sourceFile}
|
|
4508
5144
|
`
|
|
@@ -4522,7 +5158,7 @@ async function main() {
|
|
|
4522
5158
|
const empRole = (() => {
|
|
4523
5159
|
try {
|
|
4524
5160
|
const emps = __require("fs").readFileSync(
|
|
4525
|
-
|
|
5161
|
+
path11.join(os7.homedir(), ".exe-os", "exe-employees.json"),
|
|
4526
5162
|
"utf-8"
|
|
4527
5163
|
);
|
|
4528
5164
|
const found = JSON.parse(emps).find(
|