@askexenow/exe-os 0.9.8 → 0.9.9
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 +222 -49
- package/dist/bin/backfill-responses.js +221 -48
- package/dist/bin/backfill-vectors.js +225 -52
- package/dist/bin/cleanup-stale-review-tasks.js +150 -28
- package/dist/bin/cli.js +1295 -856
- package/dist/bin/exe-agent-config.js +36 -8
- package/dist/bin/exe-agent.js +14 -4
- package/dist/bin/exe-assign.js +221 -48
- package/dist/bin/exe-boot.js +778 -427
- package/dist/bin/exe-call.js +41 -13
- package/dist/bin/exe-cloud.js +163 -58
- package/dist/bin/exe-dispatch.js +276 -139
- package/dist/bin/exe-doctor.js +145 -27
- package/dist/bin/exe-export-behaviors.js +141 -23
- package/dist/bin/exe-forget.js +137 -19
- package/dist/bin/exe-gateway.js +677 -388
- package/dist/bin/exe-heartbeat.js +227 -108
- package/dist/bin/exe-kill.js +138 -20
- package/dist/bin/exe-launch-agent.js +172 -39
- package/dist/bin/exe-link.js +291 -100
- package/dist/bin/exe-new-employee.js +214 -106
- package/dist/bin/exe-pending-messages.js +395 -33
- package/dist/bin/exe-pending-notifications.js +684 -99
- package/dist/bin/exe-pending-reviews.js +420 -74
- package/dist/bin/exe-rename.js +147 -49
- package/dist/bin/exe-review.js +138 -20
- package/dist/bin/exe-search.js +240 -69
- package/dist/bin/exe-session-cleanup.js +440 -250
- package/dist/bin/exe-settings.js +61 -17
- package/dist/bin/exe-start-codex.js +158 -39
- package/dist/bin/exe-start-opencode.js +157 -38
- package/dist/bin/exe-status.js +151 -29
- package/dist/bin/exe-team.js +138 -20
- package/dist/bin/git-sweep.js +404 -212
- package/dist/bin/graph-backfill.js +137 -19
- package/dist/bin/graph-export.js +140 -22
- package/dist/bin/install.js +90 -61
- package/dist/bin/scan-tasks.js +412 -220
- package/dist/bin/setup.js +564 -293
- package/dist/bin/shard-migrate.js +139 -21
- package/dist/bin/update.js +138 -49
- package/dist/bin/wiki-sync.js +137 -19
- package/dist/gateway/index.js +533 -320
- package/dist/hooks/bug-report-worker.js +344 -193
- package/dist/hooks/codex-stop-task-finalizer.js +4678 -0
- package/dist/hooks/commit-complete.js +402 -210
- package/dist/hooks/error-recall.js +245 -74
- package/dist/hooks/exe-heartbeat-hook.js +16 -6
- package/dist/hooks/ingest-worker.js +3423 -3157
- package/dist/hooks/ingest.js +832 -97
- package/dist/hooks/instructions-loaded.js +227 -54
- package/dist/hooks/notification.js +216 -43
- package/dist/hooks/post-compact.js +239 -62
- package/dist/hooks/pre-compact.js +408 -216
- package/dist/hooks/pre-tool-use.js +268 -90
- package/dist/hooks/prompt-ingest-worker.js +352 -102
- package/dist/hooks/prompt-submit.js +541 -328
- package/dist/hooks/response-ingest-worker.js +372 -122
- package/dist/hooks/session-end.js +443 -240
- package/dist/hooks/session-start.js +313 -127
- package/dist/hooks/stop.js +293 -98
- package/dist/hooks/subagent-stop.js +239 -62
- package/dist/hooks/summary-worker.js +568 -236
- package/dist/index.js +538 -324
- package/dist/lib/agent-config.js +28 -6
- package/dist/lib/cloud-sync.js +284 -105
- package/dist/lib/config.js +30 -10
- package/dist/lib/consolidation.js +16 -6
- package/dist/lib/database.js +123 -25
- package/dist/lib/db-daemon-client.js +73 -19
- package/dist/lib/db.js +123 -25
- package/dist/lib/device-registry.js +133 -35
- package/dist/lib/embedder.js +107 -32
- package/dist/lib/employee-templates.js +14 -4
- package/dist/lib/employees.js +41 -13
- package/dist/lib/exe-daemon-client.js +88 -22
- package/dist/lib/exe-daemon.js +935 -587
- package/dist/lib/hybrid-search.js +240 -69
- package/dist/lib/identity.js +18 -8
- package/dist/lib/license.js +133 -48
- package/dist/lib/messaging.js +116 -56
- package/dist/lib/reminders.js +14 -4
- package/dist/lib/schedules.js +137 -19
- package/dist/lib/skill-learning.js +33 -6
- package/dist/lib/store.js +137 -19
- package/dist/lib/task-router.js +14 -4
- package/dist/lib/tasks.js +280 -234
- package/dist/lib/tmux-routing.js +172 -125
- package/dist/lib/token-spend.js +26 -8
- package/dist/mcp/server.js +1326 -609
- package/dist/mcp/tools/complete-reminder.js +14 -4
- package/dist/mcp/tools/create-reminder.js +14 -4
- package/dist/mcp/tools/create-task.js +306 -248
- package/dist/mcp/tools/deactivate-behavior.js +16 -6
- package/dist/mcp/tools/list-reminders.js +14 -4
- package/dist/mcp/tools/list-tasks.js +123 -107
- package/dist/mcp/tools/send-message.js +75 -29
- package/dist/mcp/tools/update-task.js +1848 -199
- package/dist/runtime/index.js +441 -248
- package/dist/tui/App.js +761 -424
- package/package.json +1 -1
|
@@ -64,9 +64,34 @@ var init_db_retry = __esm({
|
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
+
// src/lib/secure-files.ts
|
|
68
|
+
import { chmodSync, existsSync, mkdirSync } from "fs";
|
|
69
|
+
import { chmod, mkdir } from "fs/promises";
|
|
70
|
+
async function ensurePrivateDir(dirPath) {
|
|
71
|
+
await mkdir(dirPath, { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
72
|
+
try {
|
|
73
|
+
await chmod(dirPath, PRIVATE_DIR_MODE);
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function enforcePrivateFile(filePath) {
|
|
78
|
+
try {
|
|
79
|
+
await chmod(filePath, PRIVATE_FILE_MODE);
|
|
80
|
+
} catch {
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
var PRIVATE_DIR_MODE, PRIVATE_FILE_MODE;
|
|
84
|
+
var init_secure_files = __esm({
|
|
85
|
+
"src/lib/secure-files.ts"() {
|
|
86
|
+
"use strict";
|
|
87
|
+
PRIVATE_DIR_MODE = 448;
|
|
88
|
+
PRIVATE_FILE_MODE = 384;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
67
92
|
// src/lib/config.ts
|
|
68
|
-
import { readFile, writeFile
|
|
69
|
-
import { readFileSync, existsSync, renameSync } from "fs";
|
|
93
|
+
import { readFile, writeFile } from "fs/promises";
|
|
94
|
+
import { readFileSync, existsSync as existsSync2, renameSync } from "fs";
|
|
70
95
|
import path from "path";
|
|
71
96
|
import os from "os";
|
|
72
97
|
function resolveDataDir() {
|
|
@@ -74,7 +99,7 @@ function resolveDataDir() {
|
|
|
74
99
|
if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
|
|
75
100
|
const newDir = path.join(os.homedir(), ".exe-os");
|
|
76
101
|
const legacyDir = path.join(os.homedir(), ".exe-mem");
|
|
77
|
-
if (!
|
|
102
|
+
if (!existsSync2(newDir) && existsSync2(legacyDir)) {
|
|
78
103
|
try {
|
|
79
104
|
renameSync(legacyDir, newDir);
|
|
80
105
|
process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
|
|
@@ -137,9 +162,9 @@ function normalizeAutoUpdate(raw) {
|
|
|
137
162
|
}
|
|
138
163
|
async function loadConfig() {
|
|
139
164
|
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
140
|
-
await
|
|
165
|
+
await ensurePrivateDir(dir);
|
|
141
166
|
const configPath = path.join(dir, "config.json");
|
|
142
|
-
if (!
|
|
167
|
+
if (!existsSync2(configPath)) {
|
|
143
168
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
144
169
|
}
|
|
145
170
|
const raw = await readFile(configPath, "utf-8");
|
|
@@ -152,6 +177,7 @@ async function loadConfig() {
|
|
|
152
177
|
`);
|
|
153
178
|
try {
|
|
154
179
|
await writeFile(configPath, JSON.stringify(migratedCfg, null, 2) + "\n");
|
|
180
|
+
await enforcePrivateFile(configPath);
|
|
155
181
|
} catch {
|
|
156
182
|
}
|
|
157
183
|
}
|
|
@@ -171,6 +197,7 @@ var EXE_AI_DIR, DB_PATH, MODELS_DIR, CONFIG_PATH, LEGACY_LANCE_PATH, CURRENT_CON
|
|
|
171
197
|
var init_config = __esm({
|
|
172
198
|
"src/lib/config.ts"() {
|
|
173
199
|
"use strict";
|
|
200
|
+
init_secure_files();
|
|
174
201
|
EXE_AI_DIR = resolveDataDir();
|
|
175
202
|
DB_PATH = path.join(EXE_AI_DIR, "memories.db");
|
|
176
203
|
MODELS_DIR = path.join(EXE_AI_DIR, "models");
|
|
@@ -249,7 +276,7 @@ var init_config = __esm({
|
|
|
249
276
|
|
|
250
277
|
// src/lib/employees.ts
|
|
251
278
|
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
252
|
-
import { existsSync as
|
|
279
|
+
import { existsSync as existsSync3, symlinkSync, readlinkSync, readFileSync as readFileSync2, renameSync as renameSync2, unlinkSync, writeFileSync } from "fs";
|
|
253
280
|
import { execSync } from "child_process";
|
|
254
281
|
import path2 from "path";
|
|
255
282
|
import os2 from "os";
|
|
@@ -266,7 +293,7 @@ function getCoordinatorName(employees = loadEmployeesSync()) {
|
|
|
266
293
|
return getCoordinatorEmployee(employees)?.name ?? DEFAULT_COORDINATOR_TEMPLATE_NAME;
|
|
267
294
|
}
|
|
268
295
|
function loadEmployeesSync(employeesPath = EMPLOYEES_PATH) {
|
|
269
|
-
if (!
|
|
296
|
+
if (!existsSync3(employeesPath)) return [];
|
|
270
297
|
try {
|
|
271
298
|
return JSON.parse(readFileSync2(employeesPath, "utf-8"));
|
|
272
299
|
} catch {
|
|
@@ -1222,6 +1249,7 @@ async function ensureSchema() {
|
|
|
1222
1249
|
project TEXT NOT NULL,
|
|
1223
1250
|
summary TEXT NOT NULL,
|
|
1224
1251
|
task_file TEXT,
|
|
1252
|
+
session_scope TEXT,
|
|
1225
1253
|
read INTEGER NOT NULL DEFAULT 0,
|
|
1226
1254
|
created_at TEXT NOT NULL
|
|
1227
1255
|
);
|
|
@@ -1230,7 +1258,7 @@ async function ensureSchema() {
|
|
|
1230
1258
|
ON notifications(read);
|
|
1231
1259
|
|
|
1232
1260
|
CREATE INDEX IF NOT EXISTS idx_notifications_agent
|
|
1233
|
-
ON notifications(agent_id);
|
|
1261
|
+
ON notifications(agent_id, session_scope);
|
|
1234
1262
|
|
|
1235
1263
|
CREATE INDEX IF NOT EXISTS idx_notifications_task_file
|
|
1236
1264
|
ON notifications(task_file);
|
|
@@ -1268,6 +1296,7 @@ async function ensureSchema() {
|
|
|
1268
1296
|
target_agent TEXT NOT NULL,
|
|
1269
1297
|
target_project TEXT,
|
|
1270
1298
|
target_device TEXT NOT NULL DEFAULT 'local',
|
|
1299
|
+
session_scope TEXT,
|
|
1271
1300
|
content TEXT NOT NULL,
|
|
1272
1301
|
priority TEXT DEFAULT 'normal',
|
|
1273
1302
|
status TEXT DEFAULT 'pending',
|
|
@@ -1281,10 +1310,31 @@ async function ensureSchema() {
|
|
|
1281
1310
|
);
|
|
1282
1311
|
|
|
1283
1312
|
CREATE INDEX IF NOT EXISTS idx_messages_target
|
|
1284
|
-
ON messages(target_agent, status);
|
|
1313
|
+
ON messages(target_agent, session_scope, status);
|
|
1285
1314
|
|
|
1286
1315
|
CREATE INDEX IF NOT EXISTS idx_messages_conversation_order
|
|
1287
|
-
ON messages(target_agent, from_agent, server_seq);
|
|
1316
|
+
ON messages(target_agent, session_scope, from_agent, server_seq);
|
|
1317
|
+
`);
|
|
1318
|
+
try {
|
|
1319
|
+
await client.execute({
|
|
1320
|
+
sql: `ALTER TABLE notifications ADD COLUMN session_scope TEXT`,
|
|
1321
|
+
args: []
|
|
1322
|
+
});
|
|
1323
|
+
} catch {
|
|
1324
|
+
}
|
|
1325
|
+
try {
|
|
1326
|
+
await client.execute({
|
|
1327
|
+
sql: `ALTER TABLE messages ADD COLUMN session_scope TEXT`,
|
|
1328
|
+
args: []
|
|
1329
|
+
});
|
|
1330
|
+
} catch {
|
|
1331
|
+
}
|
|
1332
|
+
await client.executeMultiple(`
|
|
1333
|
+
CREATE INDEX IF NOT EXISTS idx_notifications_agent_scope_read
|
|
1334
|
+
ON notifications(agent_id, session_scope, read, created_at);
|
|
1335
|
+
|
|
1336
|
+
CREATE INDEX IF NOT EXISTS idx_messages_target_scope_status
|
|
1337
|
+
ON messages(target_agent, session_scope, status, created_at);
|
|
1288
1338
|
`);
|
|
1289
1339
|
try {
|
|
1290
1340
|
await client.execute({
|
|
@@ -1868,6 +1918,13 @@ async function ensureSchema() {
|
|
|
1868
1918
|
} catch {
|
|
1869
1919
|
}
|
|
1870
1920
|
}
|
|
1921
|
+
try {
|
|
1922
|
+
await client.execute({
|
|
1923
|
+
sql: `UPDATE tasks SET status = 'closed' WHERE status = 'done' AND result IS NOT NULL`,
|
|
1924
|
+
args: []
|
|
1925
|
+
});
|
|
1926
|
+
} catch {
|
|
1927
|
+
}
|
|
1871
1928
|
}
|
|
1872
1929
|
async function disposeDatabase() {
|
|
1873
1930
|
if (_walCheckpointTimer) {
|
|
@@ -1910,6 +1967,7 @@ var shard_manager_exports = {};
|
|
|
1910
1967
|
__export(shard_manager_exports, {
|
|
1911
1968
|
disposeShards: () => disposeShards,
|
|
1912
1969
|
ensureShardSchema: () => ensureShardSchema,
|
|
1970
|
+
getOpenShardCount: () => getOpenShardCount,
|
|
1913
1971
|
getReadyShardClient: () => getReadyShardClient,
|
|
1914
1972
|
getShardClient: () => getShardClient,
|
|
1915
1973
|
getShardsDir: () => getShardsDir,
|
|
@@ -1919,14 +1977,17 @@ __export(shard_manager_exports, {
|
|
|
1919
1977
|
shardExists: () => shardExists
|
|
1920
1978
|
});
|
|
1921
1979
|
import path5 from "path";
|
|
1922
|
-
import { existsSync as
|
|
1980
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync2, readdirSync } from "fs";
|
|
1923
1981
|
import { createClient as createClient2 } from "@libsql/client";
|
|
1924
1982
|
function initShardManager(encryptionKey) {
|
|
1925
1983
|
_encryptionKey = encryptionKey;
|
|
1926
|
-
if (!
|
|
1927
|
-
|
|
1984
|
+
if (!existsSync5(SHARDS_DIR)) {
|
|
1985
|
+
mkdirSync2(SHARDS_DIR, { recursive: true });
|
|
1928
1986
|
}
|
|
1929
1987
|
_shardingEnabled = true;
|
|
1988
|
+
if (_evictionTimer) clearInterval(_evictionTimer);
|
|
1989
|
+
_evictionTimer = setInterval(evictIdleShards, EVICTION_INTERVAL_MS);
|
|
1990
|
+
_evictionTimer.unref();
|
|
1930
1991
|
}
|
|
1931
1992
|
function isShardingEnabled() {
|
|
1932
1993
|
return _shardingEnabled;
|
|
@@ -1943,21 +2004,28 @@ function getShardClient(projectName) {
|
|
|
1943
2004
|
throw new Error(`Invalid project name for shard: "${projectName}"`);
|
|
1944
2005
|
}
|
|
1945
2006
|
const cached = _shards.get(safeName);
|
|
1946
|
-
if (cached)
|
|
2007
|
+
if (cached) {
|
|
2008
|
+
_shardLastAccess.set(safeName, Date.now());
|
|
2009
|
+
return cached;
|
|
2010
|
+
}
|
|
2011
|
+
while (_shards.size >= MAX_OPEN_SHARDS) {
|
|
2012
|
+
evictLRU();
|
|
2013
|
+
}
|
|
1947
2014
|
const dbPath = path5.join(SHARDS_DIR, `${safeName}.db`);
|
|
1948
2015
|
const client = createClient2({
|
|
1949
2016
|
url: `file:${dbPath}`,
|
|
1950
2017
|
encryptionKey: _encryptionKey
|
|
1951
2018
|
});
|
|
1952
2019
|
_shards.set(safeName, client);
|
|
2020
|
+
_shardLastAccess.set(safeName, Date.now());
|
|
1953
2021
|
return client;
|
|
1954
2022
|
}
|
|
1955
2023
|
function shardExists(projectName) {
|
|
1956
2024
|
const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1957
|
-
return
|
|
2025
|
+
return existsSync5(path5.join(SHARDS_DIR, `${safeName}.db`));
|
|
1958
2026
|
}
|
|
1959
2027
|
function listShards() {
|
|
1960
|
-
if (!
|
|
2028
|
+
if (!existsSync5(SHARDS_DIR)) return [];
|
|
1961
2029
|
return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
1962
2030
|
}
|
|
1963
2031
|
async function ensureShardSchema(client) {
|
|
@@ -2009,6 +2077,8 @@ async function ensureShardSchema(client) {
|
|
|
2009
2077
|
for (const col of [
|
|
2010
2078
|
"ALTER TABLE memories ADD COLUMN task_id TEXT",
|
|
2011
2079
|
"ALTER TABLE memories ADD COLUMN consolidated INTEGER NOT NULL DEFAULT 0",
|
|
2080
|
+
"ALTER TABLE memories ADD COLUMN author_device_id TEXT",
|
|
2081
|
+
"ALTER TABLE memories ADD COLUMN scope TEXT NOT NULL DEFAULT 'business'",
|
|
2012
2082
|
"ALTER TABLE memories ADD COLUMN importance INTEGER DEFAULT 5",
|
|
2013
2083
|
"ALTER TABLE memories ADD COLUMN status TEXT DEFAULT 'active'",
|
|
2014
2084
|
"ALTER TABLE memories ADD COLUMN wiki_synced INTEGER DEFAULT 0",
|
|
@@ -2146,21 +2216,69 @@ async function getReadyShardClient(projectName) {
|
|
|
2146
2216
|
await ensureShardSchema(client);
|
|
2147
2217
|
return client;
|
|
2148
2218
|
}
|
|
2219
|
+
function evictLRU() {
|
|
2220
|
+
let oldest = null;
|
|
2221
|
+
let oldestTime = Infinity;
|
|
2222
|
+
for (const [name, time] of _shardLastAccess) {
|
|
2223
|
+
if (time < oldestTime) {
|
|
2224
|
+
oldestTime = time;
|
|
2225
|
+
oldest = name;
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
if (oldest) {
|
|
2229
|
+
const client = _shards.get(oldest);
|
|
2230
|
+
if (client) {
|
|
2231
|
+
client.close();
|
|
2232
|
+
}
|
|
2233
|
+
_shards.delete(oldest);
|
|
2234
|
+
_shardLastAccess.delete(oldest);
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
function evictIdleShards() {
|
|
2238
|
+
const now = Date.now();
|
|
2239
|
+
const toEvict = [];
|
|
2240
|
+
for (const [name, lastAccess] of _shardLastAccess) {
|
|
2241
|
+
if (now - lastAccess > SHARD_IDLE_MS) {
|
|
2242
|
+
toEvict.push(name);
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
for (const name of toEvict) {
|
|
2246
|
+
const client = _shards.get(name);
|
|
2247
|
+
if (client) {
|
|
2248
|
+
client.close();
|
|
2249
|
+
}
|
|
2250
|
+
_shards.delete(name);
|
|
2251
|
+
_shardLastAccess.delete(name);
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
function getOpenShardCount() {
|
|
2255
|
+
return _shards.size;
|
|
2256
|
+
}
|
|
2149
2257
|
function disposeShards() {
|
|
2258
|
+
if (_evictionTimer) {
|
|
2259
|
+
clearInterval(_evictionTimer);
|
|
2260
|
+
_evictionTimer = null;
|
|
2261
|
+
}
|
|
2150
2262
|
for (const [, client] of _shards) {
|
|
2151
2263
|
client.close();
|
|
2152
2264
|
}
|
|
2153
2265
|
_shards.clear();
|
|
2266
|
+
_shardLastAccess.clear();
|
|
2154
2267
|
_shardingEnabled = false;
|
|
2155
2268
|
_encryptionKey = null;
|
|
2156
2269
|
}
|
|
2157
|
-
var SHARDS_DIR, _shards, _encryptionKey, _shardingEnabled;
|
|
2270
|
+
var SHARDS_DIR, SHARD_IDLE_MS, MAX_OPEN_SHARDS, EVICTION_INTERVAL_MS, _shards, _shardLastAccess, _evictionTimer, _encryptionKey, _shardingEnabled;
|
|
2158
2271
|
var init_shard_manager = __esm({
|
|
2159
2272
|
"src/lib/shard-manager.ts"() {
|
|
2160
2273
|
"use strict";
|
|
2161
2274
|
init_config();
|
|
2162
2275
|
SHARDS_DIR = path5.join(EXE_AI_DIR, "shards");
|
|
2276
|
+
SHARD_IDLE_MS = 5 * 60 * 1e3;
|
|
2277
|
+
MAX_OPEN_SHARDS = 10;
|
|
2278
|
+
EVICTION_INTERVAL_MS = 60 * 1e3;
|
|
2163
2279
|
_shards = /* @__PURE__ */ new Map();
|
|
2280
|
+
_shardLastAccess = /* @__PURE__ */ new Map();
|
|
2281
|
+
_evictionTimer = null;
|
|
2164
2282
|
_encryptionKey = null;
|
|
2165
2283
|
_shardingEnabled = false;
|
|
2166
2284
|
}
|
|
@@ -2457,7 +2575,7 @@ __export(active_agent_exports, {
|
|
|
2457
2575
|
resolveActiveAgentFromTmuxSession: () => resolveActiveAgentFromTmuxSession,
|
|
2458
2576
|
writeActiveAgent: () => writeActiveAgent
|
|
2459
2577
|
});
|
|
2460
|
-
import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, mkdirSync as
|
|
2578
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, mkdirSync as mkdirSync4, unlinkSync as unlinkSync3, readdirSync as readdirSync3 } from "fs";
|
|
2461
2579
|
import { execSync as execSync3 } from "child_process";
|
|
2462
2580
|
import path7 from "path";
|
|
2463
2581
|
function isNameWithOptionalInstance(candidate, baseName) {
|
|
@@ -2507,7 +2625,7 @@ function getMarkerPath() {
|
|
|
2507
2625
|
}
|
|
2508
2626
|
function writeActiveAgent(agentId, agentRole) {
|
|
2509
2627
|
try {
|
|
2510
|
-
|
|
2628
|
+
mkdirSync4(CACHE_DIR, { recursive: true });
|
|
2511
2629
|
writeFileSync3(
|
|
2512
2630
|
getMarkerPath(),
|
|
2513
2631
|
JSON.stringify({ agentId, agentRole, startedAt: (/* @__PURE__ */ new Date()).toISOString() })
|
|
@@ -2626,9 +2744,9 @@ var init_active_agent = __esm({
|
|
|
2626
2744
|
import os6 from "os";
|
|
2627
2745
|
import path8 from "path";
|
|
2628
2746
|
import {
|
|
2629
|
-
existsSync as
|
|
2747
|
+
existsSync as existsSync7,
|
|
2630
2748
|
lstatSync,
|
|
2631
|
-
mkdirSync as
|
|
2749
|
+
mkdirSync as mkdirSync5,
|
|
2632
2750
|
readlinkSync as readlinkSync2,
|
|
2633
2751
|
symlinkSync as symlinkSync2
|
|
2634
2752
|
} from "fs";
|
|
@@ -2654,18 +2772,19 @@ var init_mcp_prefix = __esm({
|
|
|
2654
2772
|
});
|
|
2655
2773
|
|
|
2656
2774
|
// src/lib/preferences.ts
|
|
2657
|
-
import { existsSync as
|
|
2775
|
+
import { existsSync as existsSync8, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
2658
2776
|
import path9 from "path";
|
|
2659
2777
|
import os7 from "os";
|
|
2660
2778
|
var init_preferences = __esm({
|
|
2661
2779
|
"src/lib/preferences.ts"() {
|
|
2662
2780
|
"use strict";
|
|
2781
|
+
init_secure_files();
|
|
2663
2782
|
}
|
|
2664
2783
|
});
|
|
2665
2784
|
|
|
2666
2785
|
// src/adapters/claude/installer.ts
|
|
2667
2786
|
import { readFile as readFile4, writeFile as writeFile4, mkdir as mkdir4, readdir } from "fs/promises";
|
|
2668
|
-
import { existsSync as
|
|
2787
|
+
import { existsSync as existsSync9, readFileSync as readFileSync5, writeFileSync as writeFileSync5, copyFileSync, mkdirSync as mkdirSync6 } from "fs";
|
|
2669
2788
|
import path10 from "path";
|
|
2670
2789
|
import os8 from "os";
|
|
2671
2790
|
import { execSync as execSync4 } from "child_process";
|
|
@@ -2676,7 +2795,7 @@ function resolvePackageRoot() {
|
|
|
2676
2795
|
const root = path10.parse(dir).root;
|
|
2677
2796
|
while (dir !== root) {
|
|
2678
2797
|
const pkgPath = path10.join(dir, "package.json");
|
|
2679
|
-
if (
|
|
2798
|
+
if (existsSync9(pkgPath)) {
|
|
2680
2799
|
try {
|
|
2681
2800
|
const pkg = JSON.parse(readFileSync5(pkgPath, "utf-8"));
|
|
2682
2801
|
if (pkg.name === "@askexenow/exe-os" || pkg.name === "exe-os") return dir;
|
|
@@ -2903,7 +3022,7 @@ __export(installer_exports, {
|
|
|
2903
3022
|
verifyOpenCodeHooks: () => verifyOpenCodeHooks
|
|
2904
3023
|
});
|
|
2905
3024
|
import { readFile as readFile5, writeFile as writeFile5, mkdir as mkdir5 } from "fs/promises";
|
|
2906
|
-
import { existsSync as
|
|
3025
|
+
import { existsSync as existsSync10, readFileSync as readFileSync6 } from "fs";
|
|
2907
3026
|
import path11 from "path";
|
|
2908
3027
|
import os9 from "os";
|
|
2909
3028
|
async function registerOpenCodeMcp(packageRoot, homeDir = os9.homedir()) {
|
|
@@ -2911,7 +3030,7 @@ async function registerOpenCodeMcp(packageRoot, homeDir = os9.homedir()) {
|
|
|
2911
3030
|
const configPath = path11.join(configDir, "opencode.json");
|
|
2912
3031
|
await mkdir5(configDir, { recursive: true });
|
|
2913
3032
|
let config = {};
|
|
2914
|
-
if (
|
|
3033
|
+
if (existsSync10(configPath)) {
|
|
2915
3034
|
try {
|
|
2916
3035
|
config = JSON.parse(await readFile5(configPath, "utf-8"));
|
|
2917
3036
|
} catch {
|
|
@@ -2945,7 +3064,7 @@ async function installOpenCodePlugin(packageRoot, homeDir = os9.homedir()) {
|
|
|
2945
3064
|
/__PACKAGE_ROOT__/g,
|
|
2946
3065
|
packageRoot.replace(/\\/g, "\\\\")
|
|
2947
3066
|
);
|
|
2948
|
-
if (
|
|
3067
|
+
if (existsSync10(pluginPath)) {
|
|
2949
3068
|
const existing = await readFile5(pluginPath, "utf-8");
|
|
2950
3069
|
if (existing === pluginContent) {
|
|
2951
3070
|
return false;
|
|
@@ -2957,14 +3076,14 @@ async function installOpenCodePlugin(packageRoot, homeDir = os9.homedir()) {
|
|
|
2957
3076
|
function verifyOpenCodeHooks(homeDir = os9.homedir()) {
|
|
2958
3077
|
const configPath = path11.join(homeDir, ".config", "opencode", "opencode.json");
|
|
2959
3078
|
const pluginPath = path11.join(homeDir, ".config", "opencode", "plugins", "exe-os.mjs");
|
|
2960
|
-
if (!
|
|
3079
|
+
if (!existsSync10(configPath)) return false;
|
|
2961
3080
|
try {
|
|
2962
3081
|
const config = JSON.parse(readFileSync6(configPath, "utf-8"));
|
|
2963
3082
|
if (!config.mcp?.["exe-os"]?.enabled) return false;
|
|
2964
3083
|
} catch {
|
|
2965
3084
|
return false;
|
|
2966
3085
|
}
|
|
2967
|
-
if (!
|
|
3086
|
+
if (!existsSync10(pluginPath)) return false;
|
|
2968
3087
|
return true;
|
|
2969
3088
|
}
|
|
2970
3089
|
async function runOpenCodeInstaller(homeDir) {
|
|
@@ -2992,7 +3111,7 @@ var init_installer2 = __esm({
|
|
|
2992
3111
|
import os10 from "os";
|
|
2993
3112
|
import path12 from "path";
|
|
2994
3113
|
import {
|
|
2995
|
-
existsSync as
|
|
3114
|
+
existsSync as existsSync11,
|
|
2996
3115
|
readFileSync as readFileSync7,
|
|
2997
3116
|
writeFileSync as writeFileSync6,
|
|
2998
3117
|
mkdirSync as mkdirSync7,
|
|
@@ -3006,7 +3125,7 @@ init_database();
|
|
|
3006
3125
|
|
|
3007
3126
|
// src/lib/keychain.ts
|
|
3008
3127
|
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
3009
|
-
import { existsSync as
|
|
3128
|
+
import { existsSync as existsSync4 } from "fs";
|
|
3010
3129
|
import path4 from "path";
|
|
3011
3130
|
import os4 from "os";
|
|
3012
3131
|
var SERVICE = "exe-mem";
|
|
@@ -3036,7 +3155,7 @@ async function getMasterKey() {
|
|
|
3036
3155
|
}
|
|
3037
3156
|
}
|
|
3038
3157
|
const keyPath = getKeyPath();
|
|
3039
|
-
if (!
|
|
3158
|
+
if (!existsSync4(keyPath)) {
|
|
3040
3159
|
process.stderr.write(
|
|
3041
3160
|
`[keychain] Key not found at ${keyPath} (HOME=${os4.homedir()}, EXE_OS_DIR=${process.env.EXE_OS_DIR ?? "unset"})
|
|
3042
3161
|
`
|
|
@@ -3352,8 +3471,8 @@ function vectorToBlob(vector) {
|
|
|
3352
3471
|
import os5 from "os";
|
|
3353
3472
|
import path6 from "path";
|
|
3354
3473
|
import {
|
|
3355
|
-
existsSync as
|
|
3356
|
-
mkdirSync as
|
|
3474
|
+
existsSync as existsSync6,
|
|
3475
|
+
mkdirSync as mkdirSync3,
|
|
3357
3476
|
readdirSync as readdirSync2,
|
|
3358
3477
|
statSync,
|
|
3359
3478
|
unlinkSync as unlinkSync2,
|
|
@@ -3400,7 +3519,7 @@ var BEHAVIORS_EXPORT_DIR = path6.join(
|
|
|
3400
3519
|
var STALE_EXPORT_AGE_MS = 60 * 60 * 1e3;
|
|
3401
3520
|
var EXPORT_BEHAVIOR_LIMIT = 30;
|
|
3402
3521
|
function sweepStaleBehaviorExports(now = Date.now()) {
|
|
3403
|
-
if (!
|
|
3522
|
+
if (!existsSync6(BEHAVIORS_EXPORT_DIR)) return;
|
|
3404
3523
|
let entries;
|
|
3405
3524
|
try {
|
|
3406
3525
|
entries = readdirSync2(BEHAVIORS_EXPORT_DIR);
|
|
@@ -3450,7 +3569,7 @@ function exportFilePath(agentId, projectName, sessionKey) {
|
|
|
3450
3569
|
);
|
|
3451
3570
|
}
|
|
3452
3571
|
async function exportBehaviorsForAgent(agentId, projectName, sessionKey) {
|
|
3453
|
-
|
|
3572
|
+
mkdirSync3(BEHAVIORS_EXPORT_DIR, { recursive: true });
|
|
3454
3573
|
sweepStaleBehaviorExports();
|
|
3455
3574
|
const behaviors = await listBehaviors(agentId, projectName, EXPORT_BEHAVIOR_LIMIT);
|
|
3456
3575
|
if (behaviors.length === 0) return null;
|
|
@@ -3492,7 +3611,7 @@ function resolveAgent(argv) {
|
|
|
3492
3611
|
function loadIdentity(agent) {
|
|
3493
3612
|
const dir = path12.join(os10.homedir(), ".exe-os", "identity");
|
|
3494
3613
|
const exact = path12.join(dir, `${agent}.md`);
|
|
3495
|
-
if (
|
|
3614
|
+
if (existsSync11(exact)) {
|
|
3496
3615
|
const content = readFileSync7(exact, "utf-8").trim();
|
|
3497
3616
|
if (content) return content;
|
|
3498
3617
|
}
|
|
@@ -3520,7 +3639,7 @@ function writeAgentFile(agent, identity, behaviorsPath) {
|
|
|
3520
3639
|
const agentDir = path12.join(os10.homedir(), ".config", "opencode", "agents");
|
|
3521
3640
|
mkdirSync7(agentDir, { recursive: true });
|
|
3522
3641
|
let content = identity;
|
|
3523
|
-
if (behaviorsPath &&
|
|
3642
|
+
if (behaviorsPath && existsSync11(behaviorsPath)) {
|
|
3524
3643
|
const behaviors = readFileSync7(behaviorsPath, "utf-8").trim();
|
|
3525
3644
|
if (behaviors) {
|
|
3526
3645
|
content += "\n\n" + behaviors;
|