@askexenow/exe-os 0.8.80 → 0.8.82
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 +359 -267
- package/dist/bin/backfill-responses.js +357 -265
- package/dist/bin/backfill-vectors.js +339 -264
- package/dist/bin/cleanup-stale-review-tasks.js +315 -256
- package/dist/bin/cli.js +494 -240
- package/dist/bin/exe-agent.js +141 -46
- package/dist/bin/exe-assign.js +151 -63
- package/dist/bin/exe-boot.js +294 -115
- package/dist/bin/exe-call.js +76 -51
- package/dist/bin/exe-cloud.js +58 -45
- package/dist/bin/exe-dispatch.js +434 -277
- package/dist/bin/exe-doctor.js +317 -246
- package/dist/bin/exe-export-behaviors.js +328 -248
- package/dist/bin/exe-forget.js +314 -231
- package/dist/bin/exe-gateway.js +2676 -1402
- package/dist/bin/exe-heartbeat.js +329 -264
- package/dist/bin/exe-kill.js +324 -244
- package/dist/bin/exe-launch-agent.js +574 -463
- package/dist/bin/exe-link.js +1055 -95
- package/dist/bin/exe-new-employee.js +49 -54
- package/dist/bin/exe-pending-messages.js +310 -253
- package/dist/bin/exe-pending-notifications.js +299 -228
- package/dist/bin/exe-pending-reviews.js +314 -245
- package/dist/bin/exe-rename.js +259 -195
- package/dist/bin/exe-review.js +140 -64
- package/dist/bin/exe-search.js +543 -356
- package/dist/bin/exe-session-cleanup.js +463 -382
- package/dist/bin/exe-settings.js +129 -99
- package/dist/bin/exe-start.sh +6 -6
- package/dist/bin/exe-status.js +95 -36
- package/dist/bin/exe-team.js +116 -51
- package/dist/bin/git-sweep.js +482 -307
- package/dist/bin/graph-backfill.js +357 -245
- package/dist/bin/graph-export.js +324 -244
- package/dist/bin/install.js +33 -10
- package/dist/bin/scan-tasks.js +481 -307
- package/dist/bin/setup.js +1147 -140
- package/dist/bin/shard-migrate.js +321 -241
- package/dist/bin/update.js +1 -7
- package/dist/bin/wiki-sync.js +318 -238
- package/dist/gateway/index.js +2656 -1383
- package/dist/hooks/bug-report-worker.js +641 -472
- package/dist/hooks/commit-complete.js +482 -307
- package/dist/hooks/error-recall.js +363 -135
- package/dist/hooks/exe-heartbeat-hook.js +97 -27
- package/dist/hooks/ingest-worker.js +584 -397
- package/dist/hooks/ingest.js +123 -58
- package/dist/hooks/instructions-loaded.js +212 -82
- package/dist/hooks/notification.js +200 -70
- package/dist/hooks/post-compact.js +199 -81
- package/dist/hooks/pre-compact.js +352 -140
- package/dist/hooks/pre-tool-use.js +416 -278
- package/dist/hooks/prompt-ingest-worker.js +376 -299
- package/dist/hooks/prompt-submit.js +414 -188
- package/dist/hooks/response-ingest-worker.js +408 -338
- package/dist/hooks/session-end.js +209 -83
- package/dist/hooks/session-start.js +382 -158
- package/dist/hooks/stop.js +209 -83
- package/dist/hooks/subagent-stop.js +209 -85
- package/dist/hooks/summary-worker.js +606 -510
- package/dist/index.js +2133 -855
- package/dist/lib/cloud-sync.js +1175 -184
- package/dist/lib/config.js +1 -9
- package/dist/lib/consolidation.js +71 -34
- package/dist/lib/database.js +166 -14
- package/dist/lib/device-registry.js +189 -117
- package/dist/lib/embedder.js +6 -10
- package/dist/lib/employee-templates.js +134 -39
- package/dist/lib/employees.js +30 -7
- package/dist/lib/exe-daemon-client.js +5 -7
- package/dist/lib/exe-daemon.js +514 -152
- package/dist/lib/hybrid-search.js +543 -356
- package/dist/lib/identity-templates.js +15 -15
- package/dist/lib/identity.js +19 -15
- package/dist/lib/license.js +1 -7
- package/dist/lib/messaging.js +157 -135
- package/dist/lib/reminders.js +97 -0
- package/dist/lib/schedules.js +302 -231
- package/dist/lib/skill-learning.js +33 -27
- package/dist/lib/status-brief.js +11 -14
- package/dist/lib/store.js +326 -237
- package/dist/lib/task-router.js +105 -1
- package/dist/lib/tasks.js +233 -116
- package/dist/lib/tmux-routing.js +173 -56
- package/dist/lib/ws-client.js +13 -3
- package/dist/mcp/server.js +2009 -1015
- package/dist/mcp/tools/complete-reminder.js +97 -0
- package/dist/mcp/tools/create-reminder.js +97 -0
- package/dist/mcp/tools/create-task.js +426 -262
- package/dist/mcp/tools/deactivate-behavior.js +119 -44
- package/dist/mcp/tools/list-reminders.js +97 -0
- package/dist/mcp/tools/list-tasks.js +56 -57
- package/dist/mcp/tools/send-message.js +206 -143
- package/dist/mcp/tools/update-task.js +259 -85
- package/dist/runtime/index.js +495 -316
- package/dist/tui/App.js +1128 -919
- package/package.json +2 -10
- package/src/commands/exe/afk.md +8 -8
- package/src/commands/exe/assign.md +1 -1
- package/src/commands/exe/build-adv.md +1 -1
- package/src/commands/exe/call.md +10 -10
- package/src/commands/exe/employee-heartbeat.md +9 -6
- package/src/commands/exe/heartbeat.md +5 -5
- package/src/commands/exe/intercom.md +26 -15
- package/src/commands/exe/launch.md +2 -2
- package/src/commands/exe/new-employee.md +1 -1
- package/src/commands/exe/review.md +2 -2
- package/src/commands/exe/schedule.md +1 -1
- package/src/commands/exe/sessions.md +2 -2
- package/src/commands/exe.md +22 -20
|
@@ -62,7 +62,7 @@ function wrapWithRetry(client) {
|
|
|
62
62
|
return (sql) => retryOnBusy(() => target.execute(sql), "execute");
|
|
63
63
|
}
|
|
64
64
|
if (prop === "batch") {
|
|
65
|
-
return (stmts) => retryOnBusy(() => target.batch(stmts), "batch");
|
|
65
|
+
return (stmts, mode) => retryOnBusy(() => target.batch(stmts, mode), "batch");
|
|
66
66
|
}
|
|
67
67
|
return Reflect.get(target, prop, receiver);
|
|
68
68
|
}
|
|
@@ -78,6 +78,294 @@ var init_db_retry = __esm({
|
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
+
// src/lib/config.ts
|
|
82
|
+
var config_exports = {};
|
|
83
|
+
__export(config_exports, {
|
|
84
|
+
CONFIG_MIGRATIONS: () => CONFIG_MIGRATIONS,
|
|
85
|
+
CONFIG_PATH: () => CONFIG_PATH,
|
|
86
|
+
CURRENT_CONFIG_VERSION: () => CURRENT_CONFIG_VERSION,
|
|
87
|
+
DB_PATH: () => DB_PATH,
|
|
88
|
+
EXE_AI_DIR: () => EXE_AI_DIR,
|
|
89
|
+
LEGACY_LANCE_PATH: () => LEGACY_LANCE_PATH,
|
|
90
|
+
MODELS_DIR: () => MODELS_DIR,
|
|
91
|
+
loadConfig: () => loadConfig,
|
|
92
|
+
loadConfigFrom: () => loadConfigFrom,
|
|
93
|
+
loadConfigSync: () => loadConfigSync,
|
|
94
|
+
migrateConfig: () => migrateConfig,
|
|
95
|
+
saveConfig: () => saveConfig
|
|
96
|
+
});
|
|
97
|
+
import { readFile, writeFile, mkdir, chmod } from "fs/promises";
|
|
98
|
+
import { readFileSync, existsSync, renameSync } from "fs";
|
|
99
|
+
import path2 from "path";
|
|
100
|
+
import os from "os";
|
|
101
|
+
function resolveDataDir() {
|
|
102
|
+
if (process.env.EXE_OS_DIR) return process.env.EXE_OS_DIR;
|
|
103
|
+
if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
|
|
104
|
+
const newDir = path2.join(os.homedir(), ".exe-os");
|
|
105
|
+
const legacyDir = path2.join(os.homedir(), ".exe-mem");
|
|
106
|
+
if (!existsSync(newDir) && existsSync(legacyDir)) {
|
|
107
|
+
try {
|
|
108
|
+
renameSync(legacyDir, newDir);
|
|
109
|
+
process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
|
|
110
|
+
`);
|
|
111
|
+
} catch {
|
|
112
|
+
return legacyDir;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return newDir;
|
|
116
|
+
}
|
|
117
|
+
function migrateLegacyConfig(raw) {
|
|
118
|
+
if ("r2" in raw) {
|
|
119
|
+
process.stderr.write(
|
|
120
|
+
"[exe-os] Warning: config.json contains deprecated 'r2' field from v1.0. R2 sync has been replaced in v1.1. The 'r2' field will be ignored.\n"
|
|
121
|
+
);
|
|
122
|
+
delete raw.r2;
|
|
123
|
+
}
|
|
124
|
+
if ("syncIntervalMs" in raw) {
|
|
125
|
+
delete raw.syncIntervalMs;
|
|
126
|
+
}
|
|
127
|
+
return raw;
|
|
128
|
+
}
|
|
129
|
+
function migrateConfig(raw) {
|
|
130
|
+
const fromVersion = typeof raw.config_version === "number" ? raw.config_version : 0;
|
|
131
|
+
let currentVersion = fromVersion;
|
|
132
|
+
let migrated = false;
|
|
133
|
+
if (currentVersion > CURRENT_CONFIG_VERSION) {
|
|
134
|
+
return { config: raw, migrated: false, fromVersion };
|
|
135
|
+
}
|
|
136
|
+
for (const migration of CONFIG_MIGRATIONS) {
|
|
137
|
+
if (currentVersion === migration.from && migration.to <= CURRENT_CONFIG_VERSION) {
|
|
138
|
+
raw = migration.migrate(raw);
|
|
139
|
+
currentVersion = migration.to;
|
|
140
|
+
migrated = true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return { config: raw, migrated, fromVersion };
|
|
144
|
+
}
|
|
145
|
+
function normalizeScalingRoadmap(raw) {
|
|
146
|
+
const defaultAuto = DEFAULT_CONFIG.scalingRoadmap.rerankerAutoTrigger;
|
|
147
|
+
const userRoadmap = raw.scalingRoadmap ?? {};
|
|
148
|
+
const userAuto = userRoadmap.rerankerAutoTrigger ?? {};
|
|
149
|
+
if (userAuto.enabled === void 0 && raw.rerankerEnabled !== void 0) {
|
|
150
|
+
userAuto.enabled = raw.rerankerEnabled;
|
|
151
|
+
}
|
|
152
|
+
raw.scalingRoadmap = {
|
|
153
|
+
...userRoadmap,
|
|
154
|
+
rerankerAutoTrigger: { ...defaultAuto, ...userAuto }
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function normalizeSessionLifecycle(raw) {
|
|
158
|
+
const defaultSL = DEFAULT_CONFIG.sessionLifecycle;
|
|
159
|
+
const userSL = raw.sessionLifecycle ?? {};
|
|
160
|
+
raw.sessionLifecycle = { ...defaultSL, ...userSL };
|
|
161
|
+
}
|
|
162
|
+
function normalizeAutoUpdate(raw) {
|
|
163
|
+
const defaultAU = DEFAULT_CONFIG.autoUpdate;
|
|
164
|
+
const userAU = raw.autoUpdate ?? {};
|
|
165
|
+
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
166
|
+
}
|
|
167
|
+
async function loadConfig() {
|
|
168
|
+
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
169
|
+
await mkdir(dir, { recursive: true });
|
|
170
|
+
const configPath = path2.join(dir, "config.json");
|
|
171
|
+
if (!existsSync(configPath)) {
|
|
172
|
+
return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
|
|
173
|
+
}
|
|
174
|
+
const raw = await readFile(configPath, "utf-8");
|
|
175
|
+
try {
|
|
176
|
+
let parsed = JSON.parse(raw);
|
|
177
|
+
parsed = migrateLegacyConfig(parsed);
|
|
178
|
+
const { config: migratedCfg, migrated, fromVersion } = migrateConfig(parsed);
|
|
179
|
+
if (migrated) {
|
|
180
|
+
process.stderr.write(`[exe-os] Config migrated from v${fromVersion} to v${migratedCfg.config_version}
|
|
181
|
+
`);
|
|
182
|
+
try {
|
|
183
|
+
await writeFile(configPath, JSON.stringify(migratedCfg, null, 2) + "\n");
|
|
184
|
+
} catch {
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
normalizeScalingRoadmap(migratedCfg);
|
|
188
|
+
normalizeSessionLifecycle(migratedCfg);
|
|
189
|
+
normalizeAutoUpdate(migratedCfg);
|
|
190
|
+
const config = { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
|
|
191
|
+
if (config.dbPath.startsWith("~")) {
|
|
192
|
+
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
193
|
+
}
|
|
194
|
+
return config;
|
|
195
|
+
} catch {
|
|
196
|
+
return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function loadConfigSync() {
|
|
200
|
+
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
201
|
+
const configPath = path2.join(dir, "config.json");
|
|
202
|
+
if (!existsSync(configPath)) {
|
|
203
|
+
return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
|
|
204
|
+
}
|
|
205
|
+
try {
|
|
206
|
+
const raw = readFileSync(configPath, "utf-8");
|
|
207
|
+
let parsed = JSON.parse(raw);
|
|
208
|
+
parsed = migrateLegacyConfig(parsed);
|
|
209
|
+
const { config: migratedCfg } = migrateConfig(parsed);
|
|
210
|
+
normalizeScalingRoadmap(migratedCfg);
|
|
211
|
+
normalizeSessionLifecycle(migratedCfg);
|
|
212
|
+
normalizeAutoUpdate(migratedCfg);
|
|
213
|
+
return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
|
|
214
|
+
} catch {
|
|
215
|
+
return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
async function saveConfig(config) {
|
|
219
|
+
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
220
|
+
await mkdir(dir, { recursive: true });
|
|
221
|
+
const configPath = path2.join(dir, "config.json");
|
|
222
|
+
await writeFile(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
223
|
+
if (config.cloud?.apiKey) {
|
|
224
|
+
await chmod(configPath, 384);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
async function loadConfigFrom(configPath) {
|
|
228
|
+
const raw = await readFile(configPath, "utf-8");
|
|
229
|
+
try {
|
|
230
|
+
let parsed = JSON.parse(raw);
|
|
231
|
+
parsed = migrateLegacyConfig(parsed);
|
|
232
|
+
const { config: migratedCfg } = migrateConfig(parsed);
|
|
233
|
+
normalizeScalingRoadmap(migratedCfg);
|
|
234
|
+
normalizeSessionLifecycle(migratedCfg);
|
|
235
|
+
normalizeAutoUpdate(migratedCfg);
|
|
236
|
+
return { ...DEFAULT_CONFIG, ...migratedCfg };
|
|
237
|
+
} catch {
|
|
238
|
+
return { ...DEFAULT_CONFIG };
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
var EXE_AI_DIR, DB_PATH, MODELS_DIR, CONFIG_PATH, LEGACY_LANCE_PATH, CURRENT_CONFIG_VERSION, DEFAULT_CONFIG, CONFIG_MIGRATIONS;
|
|
242
|
+
var init_config = __esm({
|
|
243
|
+
"src/lib/config.ts"() {
|
|
244
|
+
"use strict";
|
|
245
|
+
EXE_AI_DIR = resolveDataDir();
|
|
246
|
+
DB_PATH = path2.join(EXE_AI_DIR, "memories.db");
|
|
247
|
+
MODELS_DIR = path2.join(EXE_AI_DIR, "models");
|
|
248
|
+
CONFIG_PATH = path2.join(EXE_AI_DIR, "config.json");
|
|
249
|
+
LEGACY_LANCE_PATH = path2.join(EXE_AI_DIR, "local.lance");
|
|
250
|
+
CURRENT_CONFIG_VERSION = 1;
|
|
251
|
+
DEFAULT_CONFIG = {
|
|
252
|
+
config_version: CURRENT_CONFIG_VERSION,
|
|
253
|
+
dbPath: DB_PATH,
|
|
254
|
+
modelFile: "jina-embeddings-v5-small-q4_k_m.gguf",
|
|
255
|
+
embeddingDim: 1024,
|
|
256
|
+
batchSize: 20,
|
|
257
|
+
flushIntervalMs: 1e4,
|
|
258
|
+
autoIngestion: true,
|
|
259
|
+
autoRetrieval: true,
|
|
260
|
+
searchMode: "hybrid",
|
|
261
|
+
hookSearchMode: "hybrid",
|
|
262
|
+
fileGrepEnabled: true,
|
|
263
|
+
splashEffect: true,
|
|
264
|
+
consolidationEnabled: true,
|
|
265
|
+
consolidationIntervalMs: 6 * 60 * 60 * 1e3,
|
|
266
|
+
consolidationModel: "claude-haiku-4-5-20251001",
|
|
267
|
+
consolidationMaxCallsPerRun: 20,
|
|
268
|
+
selfQueryRouter: true,
|
|
269
|
+
selfQueryModel: "claude-haiku-4-5-20251001",
|
|
270
|
+
rerankerEnabled: true,
|
|
271
|
+
scalingRoadmap: {
|
|
272
|
+
rerankerAutoTrigger: {
|
|
273
|
+
enabled: true,
|
|
274
|
+
broadQueryMinCardinality: 5e4,
|
|
275
|
+
fetchTopK: 150,
|
|
276
|
+
returnTopK: 5
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
graphRagEnabled: true,
|
|
280
|
+
wikiEnabled: false,
|
|
281
|
+
wikiUrl: "",
|
|
282
|
+
wikiApiKey: "",
|
|
283
|
+
wikiSyncIntervalMs: 30 * 60 * 1e3,
|
|
284
|
+
wikiWorkspaceMapping: {},
|
|
285
|
+
wikiAutoUpdate: true,
|
|
286
|
+
wikiAutoUpdateThreshold: 0.5,
|
|
287
|
+
wikiAutoUpdateCreateNew: true,
|
|
288
|
+
skillLearning: true,
|
|
289
|
+
skillThreshold: 3,
|
|
290
|
+
skillModel: "claude-haiku-4-5-20251001",
|
|
291
|
+
exeHeartbeat: {
|
|
292
|
+
enabled: true,
|
|
293
|
+
intervalSeconds: 60,
|
|
294
|
+
staleInProgressThresholdHours: 2
|
|
295
|
+
},
|
|
296
|
+
sessionLifecycle: {
|
|
297
|
+
idleKillEnabled: true,
|
|
298
|
+
idleKillTicksRequired: 3,
|
|
299
|
+
idleKillIntercomAckWindowMs: 1e4,
|
|
300
|
+
maxAutoInstances: 10
|
|
301
|
+
},
|
|
302
|
+
autoUpdate: {
|
|
303
|
+
checkOnBoot: true,
|
|
304
|
+
autoInstall: false,
|
|
305
|
+
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
CONFIG_MIGRATIONS = [
|
|
309
|
+
{
|
|
310
|
+
from: 0,
|
|
311
|
+
to: 1,
|
|
312
|
+
migrate: (cfg) => {
|
|
313
|
+
cfg.config_version = 1;
|
|
314
|
+
return cfg;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
];
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
// src/lib/employees.ts
|
|
322
|
+
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
323
|
+
import { existsSync as existsSync2, symlinkSync, readlinkSync, readFileSync as readFileSync2, renameSync as renameSync2, unlinkSync, writeFileSync } from "fs";
|
|
324
|
+
import { execSync as execSync2 } from "child_process";
|
|
325
|
+
import path3 from "path";
|
|
326
|
+
import os2 from "os";
|
|
327
|
+
function normalizeRole(role) {
|
|
328
|
+
return (role ?? "").trim().toLowerCase();
|
|
329
|
+
}
|
|
330
|
+
function isCoordinatorRole(role) {
|
|
331
|
+
return normalizeRole(role) === normalizeRole(COORDINATOR_ROLE);
|
|
332
|
+
}
|
|
333
|
+
function getCoordinatorEmployee(employees) {
|
|
334
|
+
return employees.find((e) => isCoordinatorRole(e.role));
|
|
335
|
+
}
|
|
336
|
+
function getCoordinatorName(employees = loadEmployeesSync()) {
|
|
337
|
+
return getCoordinatorEmployee(employees)?.name ?? DEFAULT_COORDINATOR_TEMPLATE_NAME;
|
|
338
|
+
}
|
|
339
|
+
async function loadEmployees(employeesPath = EMPLOYEES_PATH) {
|
|
340
|
+
if (!existsSync2(employeesPath)) {
|
|
341
|
+
return [];
|
|
342
|
+
}
|
|
343
|
+
const raw = await readFile2(employeesPath, "utf-8");
|
|
344
|
+
try {
|
|
345
|
+
return JSON.parse(raw);
|
|
346
|
+
} catch {
|
|
347
|
+
return [];
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function loadEmployeesSync(employeesPath = EMPLOYEES_PATH) {
|
|
351
|
+
if (!existsSync2(employeesPath)) return [];
|
|
352
|
+
try {
|
|
353
|
+
return JSON.parse(readFileSync2(employeesPath, "utf-8"));
|
|
354
|
+
} catch {
|
|
355
|
+
return [];
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
var EMPLOYEES_PATH, DEFAULT_COORDINATOR_TEMPLATE_NAME, COORDINATOR_ROLE;
|
|
359
|
+
var init_employees = __esm({
|
|
360
|
+
"src/lib/employees.ts"() {
|
|
361
|
+
"use strict";
|
|
362
|
+
init_config();
|
|
363
|
+
EMPLOYEES_PATH = path3.join(EXE_AI_DIR, "exe-employees.json");
|
|
364
|
+
DEFAULT_COORDINATOR_TEMPLATE_NAME = "exe";
|
|
365
|
+
COORDINATOR_ROLE = "COO";
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
|
|
81
369
|
// src/lib/database.ts
|
|
82
370
|
import { createClient } from "@libsql/client";
|
|
83
371
|
async function initDatabase(config) {
|
|
@@ -214,22 +502,24 @@ async function ensureSchema() {
|
|
|
214
502
|
ON behaviors(agent_id, active);
|
|
215
503
|
`);
|
|
216
504
|
try {
|
|
505
|
+
const coordinatorName = getCoordinatorName();
|
|
217
506
|
const existing = await client.execute({
|
|
218
|
-
sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id =
|
|
219
|
-
args: []
|
|
507
|
+
sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id = ?",
|
|
508
|
+
args: [coordinatorName]
|
|
220
509
|
});
|
|
221
510
|
if (Number(existing.rows[0]?.cnt) === 0) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
511
|
+
const seededAt = "2026-03-25T00:00:00Z";
|
|
512
|
+
for (const [domain, content] of [
|
|
513
|
+
["workflow", `Don't ask "keep going?" \u2014 just keep executing phases/plans autonomously`],
|
|
514
|
+
["tool-use", "Always use create_task MCP tool, never write .md files directly for task creation"],
|
|
515
|
+
["workflow", "Auto-start reviewing when idle and reviews are pending \u2014 never ask founder for permission"]
|
|
516
|
+
]) {
|
|
517
|
+
await client.execute({
|
|
518
|
+
sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
|
|
519
|
+
VALUES (hex(randomblob(16)), ?, NULL, ?, ?, 1, ?, ?)`,
|
|
520
|
+
args: [coordinatorName, domain, content, seededAt, seededAt]
|
|
521
|
+
});
|
|
522
|
+
}
|
|
233
523
|
}
|
|
234
524
|
} catch {
|
|
235
525
|
}
|
|
@@ -921,263 +1211,49 @@ async function ensureSchema() {
|
|
|
921
1211
|
} catch {
|
|
922
1212
|
}
|
|
923
1213
|
}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
_client = null;
|
|
931
|
-
_resilientClient = null;
|
|
932
|
-
initTurso = initDatabase;
|
|
933
|
-
}
|
|
934
|
-
});
|
|
935
|
-
|
|
936
|
-
// src/lib/config.ts
|
|
937
|
-
var config_exports = {};
|
|
938
|
-
__export(config_exports, {
|
|
939
|
-
CONFIG_MIGRATIONS: () => CONFIG_MIGRATIONS,
|
|
940
|
-
CONFIG_PATH: () => CONFIG_PATH,
|
|
941
|
-
COO_AGENT_NAME: () => COO_AGENT_NAME,
|
|
942
|
-
CURRENT_CONFIG_VERSION: () => CURRENT_CONFIG_VERSION,
|
|
943
|
-
DB_PATH: () => DB_PATH,
|
|
944
|
-
EXE_AI_DIR: () => EXE_AI_DIR,
|
|
945
|
-
LEGACY_LANCE_PATH: () => LEGACY_LANCE_PATH,
|
|
946
|
-
MODELS_DIR: () => MODELS_DIR,
|
|
947
|
-
loadConfig: () => loadConfig,
|
|
948
|
-
loadConfigFrom: () => loadConfigFrom,
|
|
949
|
-
loadConfigSync: () => loadConfigSync,
|
|
950
|
-
migrateConfig: () => migrateConfig,
|
|
951
|
-
saveConfig: () => saveConfig
|
|
952
|
-
});
|
|
953
|
-
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, chmod as chmod2 } from "fs/promises";
|
|
954
|
-
import { readFileSync, existsSync as existsSync2, renameSync } from "fs";
|
|
955
|
-
import path3 from "path";
|
|
956
|
-
import os2 from "os";
|
|
957
|
-
function resolveDataDir() {
|
|
958
|
-
if (process.env.EXE_OS_DIR) return process.env.EXE_OS_DIR;
|
|
959
|
-
if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
|
|
960
|
-
const newDir = path3.join(os2.homedir(), ".exe-os");
|
|
961
|
-
const legacyDir = path3.join(os2.homedir(), ".exe-mem");
|
|
962
|
-
if (!existsSync2(newDir) && existsSync2(legacyDir)) {
|
|
963
|
-
try {
|
|
964
|
-
renameSync(legacyDir, newDir);
|
|
965
|
-
process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
|
|
966
|
-
`);
|
|
967
|
-
} catch {
|
|
968
|
-
return legacyDir;
|
|
969
|
-
}
|
|
1214
|
+
try {
|
|
1215
|
+
await client.execute({
|
|
1216
|
+
sql: `ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0`,
|
|
1217
|
+
args: []
|
|
1218
|
+
});
|
|
1219
|
+
} catch {
|
|
970
1220
|
}
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
if ("r2" in raw) {
|
|
975
|
-
process.stderr.write(
|
|
976
|
-
"[exe-os] Warning: config.json contains deprecated 'r2' field from v1.0. R2 sync has been replaced in v1.1. The 'r2' field will be ignored.\n"
|
|
1221
|
+
try {
|
|
1222
|
+
await client.execute(
|
|
1223
|
+
`CREATE INDEX IF NOT EXISTS idx_memories_draft ON memories(draft) WHERE draft = 1`
|
|
977
1224
|
);
|
|
978
|
-
|
|
979
|
-
}
|
|
980
|
-
if ("syncIntervalMs" in raw) {
|
|
981
|
-
delete raw.syncIntervalMs;
|
|
982
|
-
}
|
|
983
|
-
return raw;
|
|
984
|
-
}
|
|
985
|
-
function migrateConfig(raw) {
|
|
986
|
-
const fromVersion = typeof raw.config_version === "number" ? raw.config_version : 0;
|
|
987
|
-
let currentVersion = fromVersion;
|
|
988
|
-
let migrated = false;
|
|
989
|
-
if (currentVersion > CURRENT_CONFIG_VERSION) {
|
|
990
|
-
return { config: raw, migrated: false, fromVersion };
|
|
991
|
-
}
|
|
992
|
-
for (const migration of CONFIG_MIGRATIONS) {
|
|
993
|
-
if (currentVersion === migration.from && migration.to <= CURRENT_CONFIG_VERSION) {
|
|
994
|
-
raw = migration.migrate(raw);
|
|
995
|
-
currentVersion = migration.to;
|
|
996
|
-
migrated = true;
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
return { config: raw, migrated, fromVersion };
|
|
1000
|
-
}
|
|
1001
|
-
function normalizeScalingRoadmap(raw) {
|
|
1002
|
-
const defaultAuto = DEFAULT_CONFIG.scalingRoadmap.rerankerAutoTrigger;
|
|
1003
|
-
const userRoadmap = raw.scalingRoadmap ?? {};
|
|
1004
|
-
const userAuto = userRoadmap.rerankerAutoTrigger ?? {};
|
|
1005
|
-
if (userAuto.enabled === void 0 && raw.rerankerEnabled !== void 0) {
|
|
1006
|
-
userAuto.enabled = raw.rerankerEnabled;
|
|
1007
|
-
}
|
|
1008
|
-
raw.scalingRoadmap = {
|
|
1009
|
-
...userRoadmap,
|
|
1010
|
-
rerankerAutoTrigger: { ...defaultAuto, ...userAuto }
|
|
1011
|
-
};
|
|
1012
|
-
}
|
|
1013
|
-
function normalizeSessionLifecycle(raw) {
|
|
1014
|
-
const defaultSL = DEFAULT_CONFIG.sessionLifecycle;
|
|
1015
|
-
const userSL = raw.sessionLifecycle ?? {};
|
|
1016
|
-
raw.sessionLifecycle = { ...defaultSL, ...userSL };
|
|
1017
|
-
}
|
|
1018
|
-
function normalizeAutoUpdate(raw) {
|
|
1019
|
-
const defaultAU = DEFAULT_CONFIG.autoUpdate;
|
|
1020
|
-
const userAU = raw.autoUpdate ?? {};
|
|
1021
|
-
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
1022
|
-
}
|
|
1023
|
-
async function loadConfig() {
|
|
1024
|
-
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
1025
|
-
await mkdir2(dir, { recursive: true });
|
|
1026
|
-
const configPath = path3.join(dir, "config.json");
|
|
1027
|
-
if (!existsSync2(configPath)) {
|
|
1028
|
-
return { ...DEFAULT_CONFIG, dbPath: path3.join(dir, "memories.db") };
|
|
1225
|
+
} catch {
|
|
1029
1226
|
}
|
|
1030
|
-
const raw = await readFile2(configPath, "utf-8");
|
|
1031
1227
|
try {
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
process.stderr.write(`[exe-os] Config migrated from v${fromVersion} to v${migratedCfg.config_version}
|
|
1037
|
-
`);
|
|
1038
|
-
try {
|
|
1039
|
-
await writeFile2(configPath, JSON.stringify(migratedCfg, null, 2) + "\n");
|
|
1040
|
-
} catch {
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
normalizeScalingRoadmap(migratedCfg);
|
|
1044
|
-
normalizeSessionLifecycle(migratedCfg);
|
|
1045
|
-
normalizeAutoUpdate(migratedCfg);
|
|
1046
|
-
const config = { ...DEFAULT_CONFIG, dbPath: path3.join(dir, "memories.db"), ...migratedCfg };
|
|
1047
|
-
if (config.dbPath.startsWith("~")) {
|
|
1048
|
-
config.dbPath = config.dbPath.replace(/^~/, os2.homedir());
|
|
1049
|
-
}
|
|
1050
|
-
return config;
|
|
1228
|
+
await client.execute({
|
|
1229
|
+
sql: `ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'`,
|
|
1230
|
+
args: []
|
|
1231
|
+
});
|
|
1051
1232
|
} catch {
|
|
1052
|
-
return { ...DEFAULT_CONFIG, dbPath: path3.join(dir, "memories.db") };
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
function loadConfigSync() {
|
|
1056
|
-
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
1057
|
-
const configPath = path3.join(dir, "config.json");
|
|
1058
|
-
if (!existsSync2(configPath)) {
|
|
1059
|
-
return { ...DEFAULT_CONFIG, dbPath: path3.join(dir, "memories.db") };
|
|
1060
1233
|
}
|
|
1061
1234
|
try {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
const { config: migratedCfg } = migrateConfig(parsed);
|
|
1066
|
-
normalizeScalingRoadmap(migratedCfg);
|
|
1067
|
-
normalizeSessionLifecycle(migratedCfg);
|
|
1068
|
-
normalizeAutoUpdate(migratedCfg);
|
|
1069
|
-
return { ...DEFAULT_CONFIG, dbPath: path3.join(dir, "memories.db"), ...migratedCfg };
|
|
1235
|
+
await client.execute(
|
|
1236
|
+
`CREATE INDEX IF NOT EXISTS idx_memories_type ON memories(memory_type)`
|
|
1237
|
+
);
|
|
1070
1238
|
} catch {
|
|
1071
|
-
return { ...DEFAULT_CONFIG, dbPath: path3.join(dir, "memories.db") };
|
|
1072
1239
|
}
|
|
1073
|
-
}
|
|
1074
|
-
async function saveConfig(config) {
|
|
1075
|
-
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
1076
|
-
await mkdir2(dir, { recursive: true });
|
|
1077
|
-
const configPath = path3.join(dir, "config.json");
|
|
1078
|
-
await writeFile2(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
1079
|
-
if (config.cloud?.apiKey) {
|
|
1080
|
-
await chmod2(configPath, 384);
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
async function loadConfigFrom(configPath) {
|
|
1084
|
-
const raw = await readFile2(configPath, "utf-8");
|
|
1085
1240
|
try {
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
normalizeSessionLifecycle(migratedCfg);
|
|
1091
|
-
normalizeAutoUpdate(migratedCfg);
|
|
1092
|
-
return { ...DEFAULT_CONFIG, ...migratedCfg };
|
|
1241
|
+
await client.execute({
|
|
1242
|
+
sql: `ALTER TABLE memories ADD COLUMN trajectory TEXT`,
|
|
1243
|
+
args: []
|
|
1244
|
+
});
|
|
1093
1245
|
} catch {
|
|
1094
|
-
return { ...DEFAULT_CONFIG };
|
|
1095
1246
|
}
|
|
1096
1247
|
}
|
|
1097
|
-
var
|
|
1098
|
-
var
|
|
1099
|
-
"src/lib/
|
|
1248
|
+
var _client, _resilientClient, initTurso;
|
|
1249
|
+
var init_database = __esm({
|
|
1250
|
+
"src/lib/database.ts"() {
|
|
1100
1251
|
"use strict";
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
LEGACY_LANCE_PATH = path3.join(EXE_AI_DIR, "local.lance");
|
|
1107
|
-
CURRENT_CONFIG_VERSION = 1;
|
|
1108
|
-
DEFAULT_CONFIG = {
|
|
1109
|
-
config_version: CURRENT_CONFIG_VERSION,
|
|
1110
|
-
dbPath: DB_PATH,
|
|
1111
|
-
modelFile: "jina-embeddings-v5-small-q4_k_m.gguf",
|
|
1112
|
-
embeddingDim: 1024,
|
|
1113
|
-
batchSize: 20,
|
|
1114
|
-
flushIntervalMs: 1e4,
|
|
1115
|
-
autoIngestion: true,
|
|
1116
|
-
autoRetrieval: true,
|
|
1117
|
-
searchMode: "hybrid",
|
|
1118
|
-
hookSearchMode: "hybrid",
|
|
1119
|
-
fileGrepEnabled: true,
|
|
1120
|
-
splashEffect: true,
|
|
1121
|
-
consolidationEnabled: true,
|
|
1122
|
-
consolidationIntervalMs: 6 * 60 * 60 * 1e3,
|
|
1123
|
-
consolidationModel: "claude-haiku-4-5-20251001",
|
|
1124
|
-
consolidationMaxCallsPerRun: 20,
|
|
1125
|
-
selfQueryRouter: true,
|
|
1126
|
-
selfQueryModel: "claude-haiku-4-5-20251001",
|
|
1127
|
-
rerankerEnabled: true,
|
|
1128
|
-
scalingRoadmap: {
|
|
1129
|
-
rerankerAutoTrigger: {
|
|
1130
|
-
enabled: true,
|
|
1131
|
-
broadQueryMinCardinality: 5e4,
|
|
1132
|
-
fetchTopK: 150,
|
|
1133
|
-
returnTopK: 5
|
|
1134
|
-
}
|
|
1135
|
-
},
|
|
1136
|
-
graphRagEnabled: true,
|
|
1137
|
-
wikiEnabled: false,
|
|
1138
|
-
wikiUrl: "",
|
|
1139
|
-
wikiApiKey: "",
|
|
1140
|
-
wikiSyncIntervalMs: 30 * 60 * 1e3,
|
|
1141
|
-
wikiWorkspaceMapping: {
|
|
1142
|
-
exe: "Executive",
|
|
1143
|
-
yoshi: "Engineering",
|
|
1144
|
-
mari: "Marketing",
|
|
1145
|
-
tom: "Engineering",
|
|
1146
|
-
sasha: "Production"
|
|
1147
|
-
},
|
|
1148
|
-
wikiAutoUpdate: true,
|
|
1149
|
-
wikiAutoUpdateThreshold: 0.5,
|
|
1150
|
-
wikiAutoUpdateCreateNew: true,
|
|
1151
|
-
skillLearning: true,
|
|
1152
|
-
skillThreshold: 3,
|
|
1153
|
-
skillModel: "claude-haiku-4-5-20251001",
|
|
1154
|
-
exeHeartbeat: {
|
|
1155
|
-
enabled: true,
|
|
1156
|
-
intervalSeconds: 60,
|
|
1157
|
-
staleInProgressThresholdHours: 2
|
|
1158
|
-
},
|
|
1159
|
-
sessionLifecycle: {
|
|
1160
|
-
idleKillEnabled: true,
|
|
1161
|
-
idleKillTicksRequired: 3,
|
|
1162
|
-
idleKillIntercomAckWindowMs: 1e4,
|
|
1163
|
-
maxAutoInstances: 10
|
|
1164
|
-
},
|
|
1165
|
-
autoUpdate: {
|
|
1166
|
-
checkOnBoot: true,
|
|
1167
|
-
autoInstall: false,
|
|
1168
|
-
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
1169
|
-
}
|
|
1170
|
-
};
|
|
1171
|
-
CONFIG_MIGRATIONS = [
|
|
1172
|
-
{
|
|
1173
|
-
from: 0,
|
|
1174
|
-
to: 1,
|
|
1175
|
-
migrate: (cfg) => {
|
|
1176
|
-
cfg.config_version = 1;
|
|
1177
|
-
return cfg;
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
];
|
|
1252
|
+
init_db_retry();
|
|
1253
|
+
init_employees();
|
|
1254
|
+
_client = null;
|
|
1255
|
+
_resilientClient = null;
|
|
1256
|
+
initTurso = initDatabase;
|
|
1181
1257
|
}
|
|
1182
1258
|
});
|
|
1183
1259
|
|
|
@@ -1194,12 +1270,12 @@ __export(shard_manager_exports, {
|
|
|
1194
1270
|
listShards: () => listShards,
|
|
1195
1271
|
shardExists: () => shardExists
|
|
1196
1272
|
});
|
|
1197
|
-
import
|
|
1198
|
-
import { existsSync as
|
|
1273
|
+
import path5 from "path";
|
|
1274
|
+
import { existsSync as existsSync4, mkdirSync, readdirSync } from "fs";
|
|
1199
1275
|
import { createClient as createClient2 } from "@libsql/client";
|
|
1200
1276
|
function initShardManager(encryptionKey) {
|
|
1201
1277
|
_encryptionKey = encryptionKey;
|
|
1202
|
-
if (!
|
|
1278
|
+
if (!existsSync4(SHARDS_DIR)) {
|
|
1203
1279
|
mkdirSync(SHARDS_DIR, { recursive: true });
|
|
1204
1280
|
}
|
|
1205
1281
|
_shardingEnabled = true;
|
|
@@ -1220,7 +1296,7 @@ function getShardClient(projectName) {
|
|
|
1220
1296
|
}
|
|
1221
1297
|
const cached = _shards.get(safeName);
|
|
1222
1298
|
if (cached) return cached;
|
|
1223
|
-
const dbPath =
|
|
1299
|
+
const dbPath = path5.join(SHARDS_DIR, `${safeName}.db`);
|
|
1224
1300
|
const client = createClient2({
|
|
1225
1301
|
url: `file:${dbPath}`,
|
|
1226
1302
|
encryptionKey: _encryptionKey
|
|
@@ -1230,10 +1306,10 @@ function getShardClient(projectName) {
|
|
|
1230
1306
|
}
|
|
1231
1307
|
function shardExists(projectName) {
|
|
1232
1308
|
const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1233
|
-
return
|
|
1309
|
+
return existsSync4(path5.join(SHARDS_DIR, `${safeName}.db`));
|
|
1234
1310
|
}
|
|
1235
1311
|
function listShards() {
|
|
1236
|
-
if (!
|
|
1312
|
+
if (!existsSync4(SHARDS_DIR)) return [];
|
|
1237
1313
|
return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
1238
1314
|
}
|
|
1239
1315
|
async function ensureShardSchema(client) {
|
|
@@ -1303,7 +1379,11 @@ async function ensureShardSchema(client) {
|
|
|
1303
1379
|
"ALTER TABLE memories ADD COLUMN source_path TEXT",
|
|
1304
1380
|
"ALTER TABLE memories ADD COLUMN source_type TEXT DEFAULT 'text'",
|
|
1305
1381
|
"ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3",
|
|
1306
|
-
"ALTER TABLE memories ADD COLUMN supersedes_id TEXT"
|
|
1382
|
+
"ALTER TABLE memories ADD COLUMN supersedes_id TEXT",
|
|
1383
|
+
// MS-11: draft staging, MS-6a: memory_type, MS-7: trajectory
|
|
1384
|
+
"ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0",
|
|
1385
|
+
"ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'",
|
|
1386
|
+
"ALTER TABLE memories ADD COLUMN trajectory TEXT"
|
|
1307
1387
|
]) {
|
|
1308
1388
|
try {
|
|
1309
1389
|
await client.execute(col);
|
|
@@ -1415,7 +1495,7 @@ var init_shard_manager = __esm({
|
|
|
1415
1495
|
"src/lib/shard-manager.ts"() {
|
|
1416
1496
|
"use strict";
|
|
1417
1497
|
init_config();
|
|
1418
|
-
SHARDS_DIR =
|
|
1498
|
+
SHARDS_DIR = path5.join(EXE_AI_DIR, "shards");
|
|
1419
1499
|
_shards = /* @__PURE__ */ new Map();
|
|
1420
1500
|
_encryptionKey = null;
|
|
1421
1501
|
_shardingEnabled = false;
|
|
@@ -1433,26 +1513,26 @@ var init_platform_procedures = __esm({
|
|
|
1433
1513
|
title: "What is exe-os \u2014 the operating model every agent must understand",
|
|
1434
1514
|
domain: "architecture",
|
|
1435
1515
|
priority: "p0",
|
|
1436
|
-
content: "Exe OS is an AI employee operating system. A founder runs 5-10 AI agents as a real org: COO
|
|
1516
|
+
content: "Exe OS is an AI employee operating system. A founder runs 5-10 AI agents as a real org: COO, CTO, CMO, engineers, and content production specialists. Each agent has identity, expertise, and experience layers \u2014 persistent memory that makes them better over time. All data is local-first, E2EE, owned by the user. The MCP server is the ONLY data interface \u2014 never access the DB directly."
|
|
1437
1517
|
},
|
|
1438
1518
|
{
|
|
1439
1519
|
title: "Mode 1 \u2014 how exe-os runs inside Claude Code",
|
|
1440
1520
|
domain: "architecture",
|
|
1441
1521
|
priority: "p0",
|
|
1442
|
-
content: "Mode 1: exe-os runs AS hooks + MCP + skills inside Claude Code. The founder opens CC
|
|
1522
|
+
content: "Mode 1: exe-os runs AS hooks + MCP + skills inside Claude Code. The founder opens CC and boots the COO. The COO manages employees in tmux sessions. Each coordinator session is a separate CC window/project. Employees run in their own tmux panes via create_task auto-spawn. The founder talks to the COO; the COO orchestrates the team. CC is the shell, exe-os is the brain."
|
|
1443
1523
|
},
|
|
1444
1524
|
{
|
|
1445
|
-
title: "Sessions explained \u2014
|
|
1525
|
+
title: "Sessions explained \u2014 coordinator session names and projects",
|
|
1446
1526
|
domain: "architecture",
|
|
1447
1527
|
priority: "p0",
|
|
1448
|
-
content: "Each
|
|
1528
|
+
content: "Each coordinator session is an isolated project session. One might be exe-os development, another might be exe-wiki. Each session spawns its own employees using {employee}-{coordinatorSession}. Sessions share the same memory DB but tasks are scoped to the session that created them. A founder can run multiple projects simultaneously. Sessions never interfere with each other."
|
|
1449
1529
|
},
|
|
1450
1530
|
// --- Hierarchy and dispatch ---
|
|
1451
1531
|
{
|
|
1452
1532
|
title: "Chain of command \u2014 who talks to whom",
|
|
1453
1533
|
domain: "workflow",
|
|
1454
1534
|
priority: "p0",
|
|
1455
|
-
content: "Founder
|
|
1535
|
+
content: "Founder -> COO -> CTO/CMO. CTO -> engineers. CMO -> content production. Never skip levels: the COO does not bypass managers for specialist work. Specialists report to their manager. If you need cross-team info, use ask_team_memory \u2014 don't read other agents' task folders. Each level owns dispatch downward and review upward."
|
|
1456
1536
|
},
|
|
1457
1537
|
{
|
|
1458
1538
|
title: "Single dispatch path \u2014 create_task only",
|
|
@@ -1462,30 +1542,30 @@ var init_platform_procedures = __esm({
|
|
|
1462
1542
|
},
|
|
1463
1543
|
// --- Session isolation ---
|
|
1464
1544
|
{
|
|
1465
|
-
title: "Session scoping \u2014 stay in your
|
|
1545
|
+
title: "Session scoping \u2014 stay in your coordinator boundary",
|
|
1466
1546
|
domain: "security",
|
|
1467
1547
|
priority: "p0",
|
|
1468
|
-
content: "Session scoping is mandatory. Managers dispatch to workers within their own
|
|
1548
|
+
content: "Session scoping is mandatory. Managers dispatch to workers within their own coordinator session ONLY. Employee sessions use {employee}-{coordinatorSession}. Cross-session dispatch is blocked by the system. Verify session names before dispatch. Tasks are scoped to the creating coordinator session."
|
|
1469
1549
|
},
|
|
1470
1550
|
{
|
|
1471
1551
|
title: "Session isolation \u2014 never touch another session's work",
|
|
1472
1552
|
domain: "workflow",
|
|
1473
1553
|
priority: "p0",
|
|
1474
|
-
content:
|
|
1554
|
+
content: "Sessions are isolated. A coordinator session owns ONLY tasks it dispatched. (1) Never close/update/cancel tasks from another coordinator session. (2) Never review work from a different session \u2014 report that it belongs to another session and skip. (3) Ignore other sessions' items in list_tasks results. (4) Employees inherit session: employee sessions work ONLY on their parent coordinator session's tasks. Cross-session work is a system violation."
|
|
1475
1555
|
},
|
|
1476
1556
|
// --- Engineering: session scoping in code ---
|
|
1477
1557
|
{
|
|
1478
1558
|
title: "Three-dimensional scoping \u2014 session, project, role \u2014 enforced in every query",
|
|
1479
1559
|
domain: "architecture",
|
|
1480
1560
|
priority: "p0",
|
|
1481
|
-
content: "Every DB query, notification, review count, and task operation MUST be scoped on 3 dimensions: (1) Session \u2014 filter by session_scope matching current
|
|
1561
|
+
content: "Every DB query, notification, review count, and task operation MUST be scoped on 3 dimensions: (1) Session \u2014 filter by session_scope matching the current coordinator session. (2) Project \u2014 filter by project_name. (3) Role \u2014 agents only see data at their hierarchy level. When writing ANY function that touches tasks, reviews, messages, or notifications: always accept a sessionScope parameter and pass it to the SQL WHERE clause. Unscoped queries are bugs. Test by running 2+ coordinator sessions simultaneously."
|
|
1482
1562
|
},
|
|
1483
1563
|
// --- Hard constraints ---
|
|
1484
1564
|
{
|
|
1485
1565
|
title: "What you CANNOT do in exe-os \u2014 hard constraints",
|
|
1486
1566
|
domain: "security",
|
|
1487
1567
|
priority: "p0",
|
|
1488
|
-
content: "NEVER: (1) Access the database directly \u2014 it's SQLCipher encrypted, always fails. Use MCP tools only. (2) Manually spawn tmux sessions \u2014 create_task handles it. (3) Run git checkout main \u2014 agents work in worktrees. (4) Modify another agent's in-progress task. (5) Push to remote \u2014
|
|
1568
|
+
content: "NEVER: (1) Access the database directly \u2014 it's SQLCipher encrypted, always fails. Use MCP tools only. (2) Manually spawn tmux sessions \u2014 create_task handles it. (3) Run git checkout main \u2014 agents work in worktrees. (4) Modify another agent's in-progress task. (5) Push to remote \u2014 the COO reviews and pushes. (6) Skip update_task(done) \u2014 it's the ONLY way your work gets reviewed. (7) Run git init."
|
|
1489
1569
|
},
|
|
1490
1570
|
// --- Operations ---
|
|
1491
1571
|
{
|
|
@@ -1607,8 +1687,8 @@ ${p.content}`).join("\n\n");
|
|
|
1607
1687
|
import net from "net";
|
|
1608
1688
|
import { spawn } from "child_process";
|
|
1609
1689
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
1610
|
-
import { existsSync as
|
|
1611
|
-
import
|
|
1690
|
+
import { existsSync as existsSync5, unlinkSync as unlinkSync2, readFileSync as readFileSync3, openSync, closeSync, statSync } from "fs";
|
|
1691
|
+
import path6 from "path";
|
|
1612
1692
|
import { fileURLToPath } from "url";
|
|
1613
1693
|
function handleData(chunk) {
|
|
1614
1694
|
_buffer += chunk.toString();
|
|
@@ -1634,9 +1714,9 @@ function handleData(chunk) {
|
|
|
1634
1714
|
}
|
|
1635
1715
|
}
|
|
1636
1716
|
function cleanupStaleFiles() {
|
|
1637
|
-
if (
|
|
1717
|
+
if (existsSync5(PID_PATH)) {
|
|
1638
1718
|
try {
|
|
1639
|
-
const pid = parseInt(
|
|
1719
|
+
const pid = parseInt(readFileSync3(PID_PATH, "utf8").trim(), 10);
|
|
1640
1720
|
if (pid > 0) {
|
|
1641
1721
|
try {
|
|
1642
1722
|
process.kill(pid, 0);
|
|
@@ -1647,21 +1727,21 @@ function cleanupStaleFiles() {
|
|
|
1647
1727
|
} catch {
|
|
1648
1728
|
}
|
|
1649
1729
|
try {
|
|
1650
|
-
|
|
1730
|
+
unlinkSync2(PID_PATH);
|
|
1651
1731
|
} catch {
|
|
1652
1732
|
}
|
|
1653
1733
|
try {
|
|
1654
|
-
|
|
1734
|
+
unlinkSync2(SOCKET_PATH);
|
|
1655
1735
|
} catch {
|
|
1656
1736
|
}
|
|
1657
1737
|
}
|
|
1658
1738
|
}
|
|
1659
1739
|
function findPackageRoot() {
|
|
1660
|
-
let dir =
|
|
1661
|
-
const { root } =
|
|
1740
|
+
let dir = path6.dirname(fileURLToPath(import.meta.url));
|
|
1741
|
+
const { root } = path6.parse(dir);
|
|
1662
1742
|
while (dir !== root) {
|
|
1663
|
-
if (
|
|
1664
|
-
dir =
|
|
1743
|
+
if (existsSync5(path6.join(dir, "package.json"))) return dir;
|
|
1744
|
+
dir = path6.dirname(dir);
|
|
1665
1745
|
}
|
|
1666
1746
|
return null;
|
|
1667
1747
|
}
|
|
@@ -1671,8 +1751,8 @@ function spawnDaemon() {
|
|
|
1671
1751
|
process.stderr.write("[exed-client] WARN: cannot find package root\n");
|
|
1672
1752
|
return;
|
|
1673
1753
|
}
|
|
1674
|
-
const daemonPath =
|
|
1675
|
-
if (!
|
|
1754
|
+
const daemonPath = path6.join(pkgRoot, "dist", "lib", "exe-daemon.js");
|
|
1755
|
+
if (!existsSync5(daemonPath)) {
|
|
1676
1756
|
process.stderr.write(`[exed-client] WARN: daemon script not found at ${daemonPath}
|
|
1677
1757
|
`);
|
|
1678
1758
|
return;
|
|
@@ -1680,7 +1760,7 @@ function spawnDaemon() {
|
|
|
1680
1760
|
const resolvedPath = daemonPath;
|
|
1681
1761
|
process.stderr.write(`[exed-client] Spawning daemon: ${resolvedPath}
|
|
1682
1762
|
`);
|
|
1683
|
-
const logPath =
|
|
1763
|
+
const logPath = path6.join(path6.dirname(SOCKET_PATH), "exed.log");
|
|
1684
1764
|
let stderrFd = "ignore";
|
|
1685
1765
|
try {
|
|
1686
1766
|
stderrFd = openSync(logPath, "a");
|
|
@@ -1691,6 +1771,10 @@ function spawnDaemon() {
|
|
|
1691
1771
|
stdio: ["ignore", "ignore", stderrFd],
|
|
1692
1772
|
env: {
|
|
1693
1773
|
...process.env,
|
|
1774
|
+
TMUX: void 0,
|
|
1775
|
+
// Daemon is global — must not inherit session scope
|
|
1776
|
+
TMUX_PANE: void 0,
|
|
1777
|
+
// Prevents resolveExeSession() from scoping to one session
|
|
1694
1778
|
EXE_DAEMON_SOCK: SOCKET_PATH,
|
|
1695
1779
|
EXE_DAEMON_PID: PID_PATH
|
|
1696
1780
|
}
|
|
@@ -1713,7 +1797,7 @@ function acquireSpawnLock() {
|
|
|
1713
1797
|
const stat = statSync(SPAWN_LOCK_PATH);
|
|
1714
1798
|
if (Date.now() - stat.mtimeMs > SPAWN_LOCK_STALE_MS) {
|
|
1715
1799
|
try {
|
|
1716
|
-
|
|
1800
|
+
unlinkSync2(SPAWN_LOCK_PATH);
|
|
1717
1801
|
} catch {
|
|
1718
1802
|
}
|
|
1719
1803
|
try {
|
|
@@ -1730,7 +1814,7 @@ function acquireSpawnLock() {
|
|
|
1730
1814
|
}
|
|
1731
1815
|
function releaseSpawnLock() {
|
|
1732
1816
|
try {
|
|
1733
|
-
|
|
1817
|
+
unlinkSync2(SPAWN_LOCK_PATH);
|
|
1734
1818
|
} catch {
|
|
1735
1819
|
}
|
|
1736
1820
|
}
|
|
@@ -1842,9 +1926,9 @@ async function pingDaemon() {
|
|
|
1842
1926
|
}
|
|
1843
1927
|
function killAndRespawnDaemon() {
|
|
1844
1928
|
process.stderr.write("[exed-client] Killing daemon for restart...\n");
|
|
1845
|
-
if (
|
|
1929
|
+
if (existsSync5(PID_PATH)) {
|
|
1846
1930
|
try {
|
|
1847
|
-
const pid = parseInt(
|
|
1931
|
+
const pid = parseInt(readFileSync3(PID_PATH, "utf8").trim(), 10);
|
|
1848
1932
|
if (pid > 0) {
|
|
1849
1933
|
try {
|
|
1850
1934
|
process.kill(pid, "SIGKILL");
|
|
@@ -1861,11 +1945,11 @@ function killAndRespawnDaemon() {
|
|
|
1861
1945
|
_connected = false;
|
|
1862
1946
|
_buffer = "";
|
|
1863
1947
|
try {
|
|
1864
|
-
|
|
1948
|
+
unlinkSync2(PID_PATH);
|
|
1865
1949
|
} catch {
|
|
1866
1950
|
}
|
|
1867
1951
|
try {
|
|
1868
|
-
|
|
1952
|
+
unlinkSync2(SOCKET_PATH);
|
|
1869
1953
|
} catch {
|
|
1870
1954
|
}
|
|
1871
1955
|
spawnDaemon();
|
|
@@ -1928,9 +2012,9 @@ var init_exe_daemon_client = __esm({
|
|
|
1928
2012
|
"src/lib/exe-daemon-client.ts"() {
|
|
1929
2013
|
"use strict";
|
|
1930
2014
|
init_config();
|
|
1931
|
-
SOCKET_PATH = process.env.EXE_DAEMON_SOCK ?? process.env.EXE_EMBED_SOCK ??
|
|
1932
|
-
PID_PATH = process.env.EXE_DAEMON_PID ?? process.env.EXE_EMBED_PID ??
|
|
1933
|
-
SPAWN_LOCK_PATH =
|
|
2015
|
+
SOCKET_PATH = process.env.EXE_DAEMON_SOCK ?? process.env.EXE_EMBED_SOCK ?? path6.join(EXE_AI_DIR, "exed.sock");
|
|
2016
|
+
PID_PATH = process.env.EXE_DAEMON_PID ?? process.env.EXE_EMBED_PID ?? path6.join(EXE_AI_DIR, "exed.pid");
|
|
2017
|
+
SPAWN_LOCK_PATH = path6.join(EXE_AI_DIR, "exed-spawn.lock");
|
|
1934
2018
|
SPAWN_LOCK_STALE_MS = 3e4;
|
|
1935
2019
|
CONNECT_TIMEOUT_MS = 15e3;
|
|
1936
2020
|
REQUEST_TIMEOUT_MS = 3e4;
|
|
@@ -2012,32 +2096,6 @@ var init_embedder = __esm({
|
|
|
2012
2096
|
}
|
|
2013
2097
|
});
|
|
2014
2098
|
|
|
2015
|
-
// src/lib/employees.ts
|
|
2016
|
-
import { readFile as readFile3, writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises";
|
|
2017
|
-
import { existsSync as existsSync5, symlinkSync, readlinkSync, readFileSync as readFileSync3, renameSync as renameSync2, unlinkSync as unlinkSync2, writeFileSync } from "fs";
|
|
2018
|
-
import { execSync as execSync2 } from "child_process";
|
|
2019
|
-
import path6 from "path";
|
|
2020
|
-
import os3 from "os";
|
|
2021
|
-
async function loadEmployees(employeesPath = EMPLOYEES_PATH) {
|
|
2022
|
-
if (!existsSync5(employeesPath)) {
|
|
2023
|
-
return [];
|
|
2024
|
-
}
|
|
2025
|
-
const raw = await readFile3(employeesPath, "utf-8");
|
|
2026
|
-
try {
|
|
2027
|
-
return JSON.parse(raw);
|
|
2028
|
-
} catch {
|
|
2029
|
-
return [];
|
|
2030
|
-
}
|
|
2031
|
-
}
|
|
2032
|
-
var EMPLOYEES_PATH;
|
|
2033
|
-
var init_employees = __esm({
|
|
2034
|
-
"src/lib/employees.ts"() {
|
|
2035
|
-
"use strict";
|
|
2036
|
-
init_config();
|
|
2037
|
-
EMPLOYEES_PATH = path6.join(EXE_AI_DIR, "exe-employees.json");
|
|
2038
|
-
}
|
|
2039
|
-
});
|
|
2040
|
-
|
|
2041
2099
|
// src/lib/license.ts
|
|
2042
2100
|
import { readFileSync as readFileSync4, writeFileSync as writeFileSync2, existsSync as existsSync6, mkdirSync as mkdirSync2 } from "fs";
|
|
2043
2101
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
@@ -2451,17 +2509,17 @@ init_memory();
|
|
|
2451
2509
|
init_database();
|
|
2452
2510
|
|
|
2453
2511
|
// src/lib/keychain.ts
|
|
2454
|
-
import { readFile, writeFile, unlink, mkdir, chmod } from "fs/promises";
|
|
2455
|
-
import { existsSync } from "fs";
|
|
2456
|
-
import
|
|
2457
|
-
import
|
|
2512
|
+
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
2513
|
+
import { existsSync as existsSync3 } from "fs";
|
|
2514
|
+
import path4 from "path";
|
|
2515
|
+
import os3 from "os";
|
|
2458
2516
|
var SERVICE = "exe-mem";
|
|
2459
2517
|
var ACCOUNT = "master-key";
|
|
2460
2518
|
function getKeyDir() {
|
|
2461
|
-
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ??
|
|
2519
|
+
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path4.join(os3.homedir(), ".exe-os");
|
|
2462
2520
|
}
|
|
2463
2521
|
function getKeyPath() {
|
|
2464
|
-
return
|
|
2522
|
+
return path4.join(getKeyDir(), "master.key");
|
|
2465
2523
|
}
|
|
2466
2524
|
async function tryKeytar() {
|
|
2467
2525
|
try {
|
|
@@ -2482,11 +2540,11 @@ async function getMasterKey() {
|
|
|
2482
2540
|
}
|
|
2483
2541
|
}
|
|
2484
2542
|
const keyPath = getKeyPath();
|
|
2485
|
-
if (!
|
|
2543
|
+
if (!existsSync3(keyPath)) {
|
|
2486
2544
|
return null;
|
|
2487
2545
|
}
|
|
2488
2546
|
try {
|
|
2489
|
-
const content = await
|
|
2547
|
+
const content = await readFile3(keyPath, "utf-8");
|
|
2490
2548
|
return Buffer.from(content.trim(), "base64");
|
|
2491
2549
|
} catch {
|
|
2492
2550
|
return null;
|
|
@@ -2659,7 +2717,10 @@ async function writeMemory(record) {
|
|
|
2659
2717
|
source_path: record.source_path ?? null,
|
|
2660
2718
|
source_type: record.source_type ?? null,
|
|
2661
2719
|
tier: record.tier ?? classifyTier(record),
|
|
2662
|
-
supersedes_id: record.supersedes_id ?? null
|
|
2720
|
+
supersedes_id: record.supersedes_id ?? null,
|
|
2721
|
+
draft: record.draft ? 1 : 0,
|
|
2722
|
+
memory_type: record.memory_type ?? "raw",
|
|
2723
|
+
trajectory: record.trajectory ? JSON.stringify(record.trajectory) : null
|
|
2663
2724
|
};
|
|
2664
2725
|
_pendingRecords.push(dbRow);
|
|
2665
2726
|
orgBus.emit({
|
|
@@ -2714,6 +2775,9 @@ async function flushBatch() {
|
|
|
2714
2775
|
const sourceType = row.source_type ?? null;
|
|
2715
2776
|
const tier = row.tier ?? 3;
|
|
2716
2777
|
const supersedesId = row.supersedes_id ?? null;
|
|
2778
|
+
const draft = row.draft ? 1 : 0;
|
|
2779
|
+
const memoryType = row.memory_type ?? "raw";
|
|
2780
|
+
const trajectory = row.trajectory ?? null;
|
|
2717
2781
|
return {
|
|
2718
2782
|
sql: hasVector ? `INSERT OR IGNORE INTO memories
|
|
2719
2783
|
(id, agent_id, agent_role, session_id, timestamp,
|
|
@@ -2721,15 +2785,15 @@ async function flushBatch() {
|
|
|
2721
2785
|
has_error, raw_text, vector, version, task_id, importance, status,
|
|
2722
2786
|
confidence, last_accessed,
|
|
2723
2787
|
workspace_id, document_id, user_id, char_offset, page_number,
|
|
2724
|
-
source_path, source_type, tier, supersedes_id)
|
|
2725
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories
|
|
2788
|
+
source_path, source_type, tier, supersedes_id, draft, memory_type, trajectory)
|
|
2789
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories
|
|
2726
2790
|
(id, agent_id, agent_role, session_id, timestamp,
|
|
2727
2791
|
tool_name, project_name,
|
|
2728
2792
|
has_error, raw_text, vector, version, task_id, importance, status,
|
|
2729
2793
|
confidence, last_accessed,
|
|
2730
2794
|
workspace_id, document_id, user_id, char_offset, page_number,
|
|
2731
|
-
source_path, source_type, tier, supersedes_id)
|
|
2732
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
2795
|
+
source_path, source_type, tier, supersedes_id, draft, memory_type, trajectory)
|
|
2796
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
2733
2797
|
args: hasVector ? [
|
|
2734
2798
|
row.id,
|
|
2735
2799
|
row.agent_id,
|
|
@@ -2755,7 +2819,10 @@ async function flushBatch() {
|
|
|
2755
2819
|
sourcePath,
|
|
2756
2820
|
sourceType,
|
|
2757
2821
|
tier,
|
|
2758
|
-
supersedesId
|
|
2822
|
+
supersedesId,
|
|
2823
|
+
draft,
|
|
2824
|
+
memoryType,
|
|
2825
|
+
trajectory
|
|
2759
2826
|
] : [
|
|
2760
2827
|
row.id,
|
|
2761
2828
|
row.agent_id,
|
|
@@ -2780,7 +2847,10 @@ async function flushBatch() {
|
|
|
2780
2847
|
sourcePath,
|
|
2781
2848
|
sourceType,
|
|
2782
2849
|
tier,
|
|
2783
|
-
supersedesId
|
|
2850
|
+
supersedesId,
|
|
2851
|
+
draft,
|
|
2852
|
+
memoryType,
|
|
2853
|
+
trajectory
|
|
2784
2854
|
]
|
|
2785
2855
|
};
|
|
2786
2856
|
};
|