@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
|
@@ -48,7 +48,7 @@ function wrapWithRetry(client) {
|
|
|
48
48
|
return (sql) => retryOnBusy(() => target.execute(sql), "execute");
|
|
49
49
|
}
|
|
50
50
|
if (prop === "batch") {
|
|
51
|
-
return (stmts) => retryOnBusy(() => target.batch(stmts), "batch");
|
|
51
|
+
return (stmts, mode) => retryOnBusy(() => target.batch(stmts, mode), "batch");
|
|
52
52
|
}
|
|
53
53
|
return Reflect.get(target, prop, receiver);
|
|
54
54
|
}
|
|
@@ -64,6 +64,226 @@ var init_db_retry = __esm({
|
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
+
// src/lib/config.ts
|
|
68
|
+
import { readFile, writeFile, mkdir, chmod } from "fs/promises";
|
|
69
|
+
import { readFileSync, existsSync, renameSync } from "fs";
|
|
70
|
+
import path from "path";
|
|
71
|
+
import os from "os";
|
|
72
|
+
function resolveDataDir() {
|
|
73
|
+
if (process.env.EXE_OS_DIR) return process.env.EXE_OS_DIR;
|
|
74
|
+
if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
|
|
75
|
+
const newDir = path.join(os.homedir(), ".exe-os");
|
|
76
|
+
const legacyDir = path.join(os.homedir(), ".exe-mem");
|
|
77
|
+
if (!existsSync(newDir) && existsSync(legacyDir)) {
|
|
78
|
+
try {
|
|
79
|
+
renameSync(legacyDir, newDir);
|
|
80
|
+
process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
|
|
81
|
+
`);
|
|
82
|
+
} catch {
|
|
83
|
+
return legacyDir;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return newDir;
|
|
87
|
+
}
|
|
88
|
+
function migrateLegacyConfig(raw) {
|
|
89
|
+
if ("r2" in raw) {
|
|
90
|
+
process.stderr.write(
|
|
91
|
+
"[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"
|
|
92
|
+
);
|
|
93
|
+
delete raw.r2;
|
|
94
|
+
}
|
|
95
|
+
if ("syncIntervalMs" in raw) {
|
|
96
|
+
delete raw.syncIntervalMs;
|
|
97
|
+
}
|
|
98
|
+
return raw;
|
|
99
|
+
}
|
|
100
|
+
function migrateConfig(raw) {
|
|
101
|
+
const fromVersion = typeof raw.config_version === "number" ? raw.config_version : 0;
|
|
102
|
+
let currentVersion = fromVersion;
|
|
103
|
+
let migrated = false;
|
|
104
|
+
if (currentVersion > CURRENT_CONFIG_VERSION) {
|
|
105
|
+
return { config: raw, migrated: false, fromVersion };
|
|
106
|
+
}
|
|
107
|
+
for (const migration of CONFIG_MIGRATIONS) {
|
|
108
|
+
if (currentVersion === migration.from && migration.to <= CURRENT_CONFIG_VERSION) {
|
|
109
|
+
raw = migration.migrate(raw);
|
|
110
|
+
currentVersion = migration.to;
|
|
111
|
+
migrated = true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return { config: raw, migrated, fromVersion };
|
|
115
|
+
}
|
|
116
|
+
function normalizeScalingRoadmap(raw) {
|
|
117
|
+
const defaultAuto = DEFAULT_CONFIG.scalingRoadmap.rerankerAutoTrigger;
|
|
118
|
+
const userRoadmap = raw.scalingRoadmap ?? {};
|
|
119
|
+
const userAuto = userRoadmap.rerankerAutoTrigger ?? {};
|
|
120
|
+
if (userAuto.enabled === void 0 && raw.rerankerEnabled !== void 0) {
|
|
121
|
+
userAuto.enabled = raw.rerankerEnabled;
|
|
122
|
+
}
|
|
123
|
+
raw.scalingRoadmap = {
|
|
124
|
+
...userRoadmap,
|
|
125
|
+
rerankerAutoTrigger: { ...defaultAuto, ...userAuto }
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function normalizeSessionLifecycle(raw) {
|
|
129
|
+
const defaultSL = DEFAULT_CONFIG.sessionLifecycle;
|
|
130
|
+
const userSL = raw.sessionLifecycle ?? {};
|
|
131
|
+
raw.sessionLifecycle = { ...defaultSL, ...userSL };
|
|
132
|
+
}
|
|
133
|
+
function normalizeAutoUpdate(raw) {
|
|
134
|
+
const defaultAU = DEFAULT_CONFIG.autoUpdate;
|
|
135
|
+
const userAU = raw.autoUpdate ?? {};
|
|
136
|
+
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
137
|
+
}
|
|
138
|
+
async function loadConfig() {
|
|
139
|
+
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
140
|
+
await mkdir(dir, { recursive: true });
|
|
141
|
+
const configPath = path.join(dir, "config.json");
|
|
142
|
+
if (!existsSync(configPath)) {
|
|
143
|
+
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
144
|
+
}
|
|
145
|
+
const raw = await readFile(configPath, "utf-8");
|
|
146
|
+
try {
|
|
147
|
+
let parsed = JSON.parse(raw);
|
|
148
|
+
parsed = migrateLegacyConfig(parsed);
|
|
149
|
+
const { config: migratedCfg, migrated, fromVersion } = migrateConfig(parsed);
|
|
150
|
+
if (migrated) {
|
|
151
|
+
process.stderr.write(`[exe-os] Config migrated from v${fromVersion} to v${migratedCfg.config_version}
|
|
152
|
+
`);
|
|
153
|
+
try {
|
|
154
|
+
await writeFile(configPath, JSON.stringify(migratedCfg, null, 2) + "\n");
|
|
155
|
+
} catch {
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
normalizeScalingRoadmap(migratedCfg);
|
|
159
|
+
normalizeSessionLifecycle(migratedCfg);
|
|
160
|
+
normalizeAutoUpdate(migratedCfg);
|
|
161
|
+
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
162
|
+
if (config.dbPath.startsWith("~")) {
|
|
163
|
+
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
164
|
+
}
|
|
165
|
+
return config;
|
|
166
|
+
} catch {
|
|
167
|
+
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
var EXE_AI_DIR, DB_PATH, MODELS_DIR, CONFIG_PATH, LEGACY_LANCE_PATH, CURRENT_CONFIG_VERSION, DEFAULT_CONFIG, CONFIG_MIGRATIONS;
|
|
171
|
+
var init_config = __esm({
|
|
172
|
+
"src/lib/config.ts"() {
|
|
173
|
+
"use strict";
|
|
174
|
+
EXE_AI_DIR = resolveDataDir();
|
|
175
|
+
DB_PATH = path.join(EXE_AI_DIR, "memories.db");
|
|
176
|
+
MODELS_DIR = path.join(EXE_AI_DIR, "models");
|
|
177
|
+
CONFIG_PATH = path.join(EXE_AI_DIR, "config.json");
|
|
178
|
+
LEGACY_LANCE_PATH = path.join(EXE_AI_DIR, "local.lance");
|
|
179
|
+
CURRENT_CONFIG_VERSION = 1;
|
|
180
|
+
DEFAULT_CONFIG = {
|
|
181
|
+
config_version: CURRENT_CONFIG_VERSION,
|
|
182
|
+
dbPath: DB_PATH,
|
|
183
|
+
modelFile: "jina-embeddings-v5-small-q4_k_m.gguf",
|
|
184
|
+
embeddingDim: 1024,
|
|
185
|
+
batchSize: 20,
|
|
186
|
+
flushIntervalMs: 1e4,
|
|
187
|
+
autoIngestion: true,
|
|
188
|
+
autoRetrieval: true,
|
|
189
|
+
searchMode: "hybrid",
|
|
190
|
+
hookSearchMode: "hybrid",
|
|
191
|
+
fileGrepEnabled: true,
|
|
192
|
+
splashEffect: true,
|
|
193
|
+
consolidationEnabled: true,
|
|
194
|
+
consolidationIntervalMs: 6 * 60 * 60 * 1e3,
|
|
195
|
+
consolidationModel: "claude-haiku-4-5-20251001",
|
|
196
|
+
consolidationMaxCallsPerRun: 20,
|
|
197
|
+
selfQueryRouter: true,
|
|
198
|
+
selfQueryModel: "claude-haiku-4-5-20251001",
|
|
199
|
+
rerankerEnabled: true,
|
|
200
|
+
scalingRoadmap: {
|
|
201
|
+
rerankerAutoTrigger: {
|
|
202
|
+
enabled: true,
|
|
203
|
+
broadQueryMinCardinality: 5e4,
|
|
204
|
+
fetchTopK: 150,
|
|
205
|
+
returnTopK: 5
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
graphRagEnabled: true,
|
|
209
|
+
wikiEnabled: false,
|
|
210
|
+
wikiUrl: "",
|
|
211
|
+
wikiApiKey: "",
|
|
212
|
+
wikiSyncIntervalMs: 30 * 60 * 1e3,
|
|
213
|
+
wikiWorkspaceMapping: {},
|
|
214
|
+
wikiAutoUpdate: true,
|
|
215
|
+
wikiAutoUpdateThreshold: 0.5,
|
|
216
|
+
wikiAutoUpdateCreateNew: true,
|
|
217
|
+
skillLearning: true,
|
|
218
|
+
skillThreshold: 3,
|
|
219
|
+
skillModel: "claude-haiku-4-5-20251001",
|
|
220
|
+
exeHeartbeat: {
|
|
221
|
+
enabled: true,
|
|
222
|
+
intervalSeconds: 60,
|
|
223
|
+
staleInProgressThresholdHours: 2
|
|
224
|
+
},
|
|
225
|
+
sessionLifecycle: {
|
|
226
|
+
idleKillEnabled: true,
|
|
227
|
+
idleKillTicksRequired: 3,
|
|
228
|
+
idleKillIntercomAckWindowMs: 1e4,
|
|
229
|
+
maxAutoInstances: 10
|
|
230
|
+
},
|
|
231
|
+
autoUpdate: {
|
|
232
|
+
checkOnBoot: true,
|
|
233
|
+
autoInstall: false,
|
|
234
|
+
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
CONFIG_MIGRATIONS = [
|
|
238
|
+
{
|
|
239
|
+
from: 0,
|
|
240
|
+
to: 1,
|
|
241
|
+
migrate: (cfg) => {
|
|
242
|
+
cfg.config_version = 1;
|
|
243
|
+
return cfg;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
];
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// src/lib/employees.ts
|
|
251
|
+
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
252
|
+
import { existsSync as existsSync2, symlinkSync, readlinkSync, readFileSync as readFileSync2, renameSync as renameSync2, unlinkSync, writeFileSync } from "fs";
|
|
253
|
+
import { execSync } from "child_process";
|
|
254
|
+
import path2 from "path";
|
|
255
|
+
import os2 from "os";
|
|
256
|
+
function normalizeRole(role) {
|
|
257
|
+
return (role ?? "").trim().toLowerCase();
|
|
258
|
+
}
|
|
259
|
+
function isCoordinatorRole(role) {
|
|
260
|
+
return normalizeRole(role) === normalizeRole(COORDINATOR_ROLE);
|
|
261
|
+
}
|
|
262
|
+
function getCoordinatorEmployee(employees) {
|
|
263
|
+
return employees.find((e) => isCoordinatorRole(e.role));
|
|
264
|
+
}
|
|
265
|
+
function getCoordinatorName(employees = loadEmployeesSync()) {
|
|
266
|
+
return getCoordinatorEmployee(employees)?.name ?? DEFAULT_COORDINATOR_TEMPLATE_NAME;
|
|
267
|
+
}
|
|
268
|
+
function loadEmployeesSync(employeesPath = EMPLOYEES_PATH) {
|
|
269
|
+
if (!existsSync2(employeesPath)) return [];
|
|
270
|
+
try {
|
|
271
|
+
return JSON.parse(readFileSync2(employeesPath, "utf-8"));
|
|
272
|
+
} catch {
|
|
273
|
+
return [];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
var EMPLOYEES_PATH, DEFAULT_COORDINATOR_TEMPLATE_NAME, COORDINATOR_ROLE;
|
|
277
|
+
var init_employees = __esm({
|
|
278
|
+
"src/lib/employees.ts"() {
|
|
279
|
+
"use strict";
|
|
280
|
+
init_config();
|
|
281
|
+
EMPLOYEES_PATH = path2.join(EXE_AI_DIR, "exe-employees.json");
|
|
282
|
+
DEFAULT_COORDINATOR_TEMPLATE_NAME = "exe";
|
|
283
|
+
COORDINATOR_ROLE = "COO";
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
|
|
67
287
|
// src/lib/database.ts
|
|
68
288
|
import { createClient } from "@libsql/client";
|
|
69
289
|
async function initDatabase(config) {
|
|
@@ -197,22 +417,24 @@ async function ensureSchema() {
|
|
|
197
417
|
ON behaviors(agent_id, active);
|
|
198
418
|
`);
|
|
199
419
|
try {
|
|
420
|
+
const coordinatorName = getCoordinatorName();
|
|
200
421
|
const existing = await client.execute({
|
|
201
|
-
sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id =
|
|
202
|
-
args: []
|
|
422
|
+
sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id = ?",
|
|
423
|
+
args: [coordinatorName]
|
|
203
424
|
});
|
|
204
425
|
if (Number(existing.rows[0]?.cnt) === 0) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
426
|
+
const seededAt = "2026-03-25T00:00:00Z";
|
|
427
|
+
for (const [domain, content] of [
|
|
428
|
+
["workflow", `Don't ask "keep going?" \u2014 just keep executing phases/plans autonomously`],
|
|
429
|
+
["tool-use", "Always use create_task MCP tool, never write .md files directly for task creation"],
|
|
430
|
+
["workflow", "Auto-start reviewing when idle and reviews are pending \u2014 never ask founder for permission"]
|
|
431
|
+
]) {
|
|
432
|
+
await client.execute({
|
|
433
|
+
sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
|
|
434
|
+
VALUES (hex(randomblob(16)), ?, NULL, ?, ?, 1, ?, ?)`,
|
|
435
|
+
args: [coordinatorName, domain, content, seededAt, seededAt]
|
|
436
|
+
});
|
|
437
|
+
}
|
|
216
438
|
}
|
|
217
439
|
} catch {
|
|
218
440
|
}
|
|
@@ -904,204 +1126,49 @@ async function ensureSchema() {
|
|
|
904
1126
|
} catch {
|
|
905
1127
|
}
|
|
906
1128
|
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
_client = null;
|
|
914
|
-
_resilientClient = null;
|
|
915
|
-
initTurso = initDatabase;
|
|
916
|
-
}
|
|
917
|
-
});
|
|
918
|
-
|
|
919
|
-
// src/lib/config.ts
|
|
920
|
-
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, chmod as chmod2 } from "fs/promises";
|
|
921
|
-
import { readFileSync, existsSync as existsSync2, renameSync } from "fs";
|
|
922
|
-
import path2 from "path";
|
|
923
|
-
import os2 from "os";
|
|
924
|
-
function resolveDataDir() {
|
|
925
|
-
if (process.env.EXE_OS_DIR) return process.env.EXE_OS_DIR;
|
|
926
|
-
if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
|
|
927
|
-
const newDir = path2.join(os2.homedir(), ".exe-os");
|
|
928
|
-
const legacyDir = path2.join(os2.homedir(), ".exe-mem");
|
|
929
|
-
if (!existsSync2(newDir) && existsSync2(legacyDir)) {
|
|
930
|
-
try {
|
|
931
|
-
renameSync(legacyDir, newDir);
|
|
932
|
-
process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
|
|
933
|
-
`);
|
|
934
|
-
} catch {
|
|
935
|
-
return legacyDir;
|
|
936
|
-
}
|
|
1129
|
+
try {
|
|
1130
|
+
await client.execute({
|
|
1131
|
+
sql: `ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0`,
|
|
1132
|
+
args: []
|
|
1133
|
+
});
|
|
1134
|
+
} catch {
|
|
937
1135
|
}
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
if ("r2" in raw) {
|
|
942
|
-
process.stderr.write(
|
|
943
|
-
"[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"
|
|
1136
|
+
try {
|
|
1137
|
+
await client.execute(
|
|
1138
|
+
`CREATE INDEX IF NOT EXISTS idx_memories_draft ON memories(draft) WHERE draft = 1`
|
|
944
1139
|
);
|
|
945
|
-
|
|
946
|
-
}
|
|
947
|
-
if ("syncIntervalMs" in raw) {
|
|
948
|
-
delete raw.syncIntervalMs;
|
|
949
|
-
}
|
|
950
|
-
return raw;
|
|
951
|
-
}
|
|
952
|
-
function migrateConfig(raw) {
|
|
953
|
-
const fromVersion = typeof raw.config_version === "number" ? raw.config_version : 0;
|
|
954
|
-
let currentVersion = fromVersion;
|
|
955
|
-
let migrated = false;
|
|
956
|
-
if (currentVersion > CURRENT_CONFIG_VERSION) {
|
|
957
|
-
return { config: raw, migrated: false, fromVersion };
|
|
958
|
-
}
|
|
959
|
-
for (const migration of CONFIG_MIGRATIONS) {
|
|
960
|
-
if (currentVersion === migration.from && migration.to <= CURRENT_CONFIG_VERSION) {
|
|
961
|
-
raw = migration.migrate(raw);
|
|
962
|
-
currentVersion = migration.to;
|
|
963
|
-
migrated = true;
|
|
964
|
-
}
|
|
1140
|
+
} catch {
|
|
965
1141
|
}
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
if (userAuto.enabled === void 0 && raw.rerankerEnabled !== void 0) {
|
|
973
|
-
userAuto.enabled = raw.rerankerEnabled;
|
|
1142
|
+
try {
|
|
1143
|
+
await client.execute({
|
|
1144
|
+
sql: `ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'`,
|
|
1145
|
+
args: []
|
|
1146
|
+
});
|
|
1147
|
+
} catch {
|
|
974
1148
|
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
}
|
|
980
|
-
function normalizeSessionLifecycle(raw) {
|
|
981
|
-
const defaultSL = DEFAULT_CONFIG.sessionLifecycle;
|
|
982
|
-
const userSL = raw.sessionLifecycle ?? {};
|
|
983
|
-
raw.sessionLifecycle = { ...defaultSL, ...userSL };
|
|
984
|
-
}
|
|
985
|
-
function normalizeAutoUpdate(raw) {
|
|
986
|
-
const defaultAU = DEFAULT_CONFIG.autoUpdate;
|
|
987
|
-
const userAU = raw.autoUpdate ?? {};
|
|
988
|
-
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
989
|
-
}
|
|
990
|
-
async function loadConfig() {
|
|
991
|
-
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
992
|
-
await mkdir2(dir, { recursive: true });
|
|
993
|
-
const configPath = path2.join(dir, "config.json");
|
|
994
|
-
if (!existsSync2(configPath)) {
|
|
995
|
-
return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
|
|
1149
|
+
try {
|
|
1150
|
+
await client.execute(
|
|
1151
|
+
`CREATE INDEX IF NOT EXISTS idx_memories_type ON memories(memory_type)`
|
|
1152
|
+
);
|
|
1153
|
+
} catch {
|
|
996
1154
|
}
|
|
997
|
-
const raw = await readFile2(configPath, "utf-8");
|
|
998
1155
|
try {
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
process.stderr.write(`[exe-os] Config migrated from v${fromVersion} to v${migratedCfg.config_version}
|
|
1004
|
-
`);
|
|
1005
|
-
try {
|
|
1006
|
-
await writeFile2(configPath, JSON.stringify(migratedCfg, null, 2) + "\n");
|
|
1007
|
-
} catch {
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
normalizeScalingRoadmap(migratedCfg);
|
|
1011
|
-
normalizeSessionLifecycle(migratedCfg);
|
|
1012
|
-
normalizeAutoUpdate(migratedCfg);
|
|
1013
|
-
const config = { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
|
|
1014
|
-
if (config.dbPath.startsWith("~")) {
|
|
1015
|
-
config.dbPath = config.dbPath.replace(/^~/, os2.homedir());
|
|
1016
|
-
}
|
|
1017
|
-
return config;
|
|
1156
|
+
await client.execute({
|
|
1157
|
+
sql: `ALTER TABLE memories ADD COLUMN trajectory TEXT`,
|
|
1158
|
+
args: []
|
|
1159
|
+
});
|
|
1018
1160
|
} catch {
|
|
1019
|
-
return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
|
|
1020
1161
|
}
|
|
1021
1162
|
}
|
|
1022
|
-
var
|
|
1023
|
-
var
|
|
1024
|
-
"src/lib/
|
|
1163
|
+
var _client, _resilientClient, initTurso;
|
|
1164
|
+
var init_database = __esm({
|
|
1165
|
+
"src/lib/database.ts"() {
|
|
1025
1166
|
"use strict";
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
CURRENT_CONFIG_VERSION = 1;
|
|
1032
|
-
DEFAULT_CONFIG = {
|
|
1033
|
-
config_version: CURRENT_CONFIG_VERSION,
|
|
1034
|
-
dbPath: DB_PATH,
|
|
1035
|
-
modelFile: "jina-embeddings-v5-small-q4_k_m.gguf",
|
|
1036
|
-
embeddingDim: 1024,
|
|
1037
|
-
batchSize: 20,
|
|
1038
|
-
flushIntervalMs: 1e4,
|
|
1039
|
-
autoIngestion: true,
|
|
1040
|
-
autoRetrieval: true,
|
|
1041
|
-
searchMode: "hybrid",
|
|
1042
|
-
hookSearchMode: "hybrid",
|
|
1043
|
-
fileGrepEnabled: true,
|
|
1044
|
-
splashEffect: true,
|
|
1045
|
-
consolidationEnabled: true,
|
|
1046
|
-
consolidationIntervalMs: 6 * 60 * 60 * 1e3,
|
|
1047
|
-
consolidationModel: "claude-haiku-4-5-20251001",
|
|
1048
|
-
consolidationMaxCallsPerRun: 20,
|
|
1049
|
-
selfQueryRouter: true,
|
|
1050
|
-
selfQueryModel: "claude-haiku-4-5-20251001",
|
|
1051
|
-
rerankerEnabled: true,
|
|
1052
|
-
scalingRoadmap: {
|
|
1053
|
-
rerankerAutoTrigger: {
|
|
1054
|
-
enabled: true,
|
|
1055
|
-
broadQueryMinCardinality: 5e4,
|
|
1056
|
-
fetchTopK: 150,
|
|
1057
|
-
returnTopK: 5
|
|
1058
|
-
}
|
|
1059
|
-
},
|
|
1060
|
-
graphRagEnabled: true,
|
|
1061
|
-
wikiEnabled: false,
|
|
1062
|
-
wikiUrl: "",
|
|
1063
|
-
wikiApiKey: "",
|
|
1064
|
-
wikiSyncIntervalMs: 30 * 60 * 1e3,
|
|
1065
|
-
wikiWorkspaceMapping: {
|
|
1066
|
-
exe: "Executive",
|
|
1067
|
-
yoshi: "Engineering",
|
|
1068
|
-
mari: "Marketing",
|
|
1069
|
-
tom: "Engineering",
|
|
1070
|
-
sasha: "Production"
|
|
1071
|
-
},
|
|
1072
|
-
wikiAutoUpdate: true,
|
|
1073
|
-
wikiAutoUpdateThreshold: 0.5,
|
|
1074
|
-
wikiAutoUpdateCreateNew: true,
|
|
1075
|
-
skillLearning: true,
|
|
1076
|
-
skillThreshold: 3,
|
|
1077
|
-
skillModel: "claude-haiku-4-5-20251001",
|
|
1078
|
-
exeHeartbeat: {
|
|
1079
|
-
enabled: true,
|
|
1080
|
-
intervalSeconds: 60,
|
|
1081
|
-
staleInProgressThresholdHours: 2
|
|
1082
|
-
},
|
|
1083
|
-
sessionLifecycle: {
|
|
1084
|
-
idleKillEnabled: true,
|
|
1085
|
-
idleKillTicksRequired: 3,
|
|
1086
|
-
idleKillIntercomAckWindowMs: 1e4,
|
|
1087
|
-
maxAutoInstances: 10
|
|
1088
|
-
},
|
|
1089
|
-
autoUpdate: {
|
|
1090
|
-
checkOnBoot: true,
|
|
1091
|
-
autoInstall: false,
|
|
1092
|
-
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
1093
|
-
}
|
|
1094
|
-
};
|
|
1095
|
-
CONFIG_MIGRATIONS = [
|
|
1096
|
-
{
|
|
1097
|
-
from: 0,
|
|
1098
|
-
to: 1,
|
|
1099
|
-
migrate: (cfg) => {
|
|
1100
|
-
cfg.config_version = 1;
|
|
1101
|
-
return cfg;
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
];
|
|
1167
|
+
init_db_retry();
|
|
1168
|
+
init_employees();
|
|
1169
|
+
_client = null;
|
|
1170
|
+
_resilientClient = null;
|
|
1171
|
+
initTurso = initDatabase;
|
|
1105
1172
|
}
|
|
1106
1173
|
});
|
|
1107
1174
|
|
|
@@ -1118,12 +1185,12 @@ __export(shard_manager_exports, {
|
|
|
1118
1185
|
listShards: () => listShards,
|
|
1119
1186
|
shardExists: () => shardExists
|
|
1120
1187
|
});
|
|
1121
|
-
import
|
|
1122
|
-
import { existsSync as
|
|
1188
|
+
import path4 from "path";
|
|
1189
|
+
import { existsSync as existsSync4, mkdirSync, readdirSync } from "fs";
|
|
1123
1190
|
import { createClient as createClient2 } from "@libsql/client";
|
|
1124
1191
|
function initShardManager(encryptionKey) {
|
|
1125
1192
|
_encryptionKey = encryptionKey;
|
|
1126
|
-
if (!
|
|
1193
|
+
if (!existsSync4(SHARDS_DIR)) {
|
|
1127
1194
|
mkdirSync(SHARDS_DIR, { recursive: true });
|
|
1128
1195
|
}
|
|
1129
1196
|
_shardingEnabled = true;
|
|
@@ -1144,7 +1211,7 @@ function getShardClient(projectName) {
|
|
|
1144
1211
|
}
|
|
1145
1212
|
const cached = _shards.get(safeName);
|
|
1146
1213
|
if (cached) return cached;
|
|
1147
|
-
const dbPath =
|
|
1214
|
+
const dbPath = path4.join(SHARDS_DIR, `${safeName}.db`);
|
|
1148
1215
|
const client = createClient2({
|
|
1149
1216
|
url: `file:${dbPath}`,
|
|
1150
1217
|
encryptionKey: _encryptionKey
|
|
@@ -1154,10 +1221,10 @@ function getShardClient(projectName) {
|
|
|
1154
1221
|
}
|
|
1155
1222
|
function shardExists(projectName) {
|
|
1156
1223
|
const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1157
|
-
return
|
|
1224
|
+
return existsSync4(path4.join(SHARDS_DIR, `${safeName}.db`));
|
|
1158
1225
|
}
|
|
1159
1226
|
function listShards() {
|
|
1160
|
-
if (!
|
|
1227
|
+
if (!existsSync4(SHARDS_DIR)) return [];
|
|
1161
1228
|
return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
1162
1229
|
}
|
|
1163
1230
|
async function ensureShardSchema(client) {
|
|
@@ -1227,7 +1294,11 @@ async function ensureShardSchema(client) {
|
|
|
1227
1294
|
"ALTER TABLE memories ADD COLUMN source_path TEXT",
|
|
1228
1295
|
"ALTER TABLE memories ADD COLUMN source_type TEXT DEFAULT 'text'",
|
|
1229
1296
|
"ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3",
|
|
1230
|
-
"ALTER TABLE memories ADD COLUMN supersedes_id TEXT"
|
|
1297
|
+
"ALTER TABLE memories ADD COLUMN supersedes_id TEXT",
|
|
1298
|
+
// MS-11: draft staging, MS-6a: memory_type, MS-7: trajectory
|
|
1299
|
+
"ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0",
|
|
1300
|
+
"ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'",
|
|
1301
|
+
"ALTER TABLE memories ADD COLUMN trajectory TEXT"
|
|
1231
1302
|
]) {
|
|
1232
1303
|
try {
|
|
1233
1304
|
await client.execute(col);
|
|
@@ -1339,7 +1410,7 @@ var init_shard_manager = __esm({
|
|
|
1339
1410
|
"src/lib/shard-manager.ts"() {
|
|
1340
1411
|
"use strict";
|
|
1341
1412
|
init_config();
|
|
1342
|
-
SHARDS_DIR =
|
|
1413
|
+
SHARDS_DIR = path4.join(EXE_AI_DIR, "shards");
|
|
1343
1414
|
_shards = /* @__PURE__ */ new Map();
|
|
1344
1415
|
_encryptionKey = null;
|
|
1345
1416
|
_shardingEnabled = false;
|
|
@@ -1357,26 +1428,26 @@ var init_platform_procedures = __esm({
|
|
|
1357
1428
|
title: "What is exe-os \u2014 the operating model every agent must understand",
|
|
1358
1429
|
domain: "architecture",
|
|
1359
1430
|
priority: "p0",
|
|
1360
|
-
content: "Exe OS is an AI employee operating system. A founder runs 5-10 AI agents as a real org: COO
|
|
1431
|
+
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."
|
|
1361
1432
|
},
|
|
1362
1433
|
{
|
|
1363
1434
|
title: "Mode 1 \u2014 how exe-os runs inside Claude Code",
|
|
1364
1435
|
domain: "architecture",
|
|
1365
1436
|
priority: "p0",
|
|
1366
|
-
content: "Mode 1: exe-os runs AS hooks + MCP + skills inside Claude Code. The founder opens CC
|
|
1437
|
+
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."
|
|
1367
1438
|
},
|
|
1368
1439
|
{
|
|
1369
|
-
title: "Sessions explained \u2014
|
|
1440
|
+
title: "Sessions explained \u2014 coordinator session names and projects",
|
|
1370
1441
|
domain: "architecture",
|
|
1371
1442
|
priority: "p0",
|
|
1372
|
-
content: "Each
|
|
1443
|
+
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."
|
|
1373
1444
|
},
|
|
1374
1445
|
// --- Hierarchy and dispatch ---
|
|
1375
1446
|
{
|
|
1376
1447
|
title: "Chain of command \u2014 who talks to whom",
|
|
1377
1448
|
domain: "workflow",
|
|
1378
1449
|
priority: "p0",
|
|
1379
|
-
content: "Founder
|
|
1450
|
+
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."
|
|
1380
1451
|
},
|
|
1381
1452
|
{
|
|
1382
1453
|
title: "Single dispatch path \u2014 create_task only",
|
|
@@ -1386,30 +1457,30 @@ var init_platform_procedures = __esm({
|
|
|
1386
1457
|
},
|
|
1387
1458
|
// --- Session isolation ---
|
|
1388
1459
|
{
|
|
1389
|
-
title: "Session scoping \u2014 stay in your
|
|
1460
|
+
title: "Session scoping \u2014 stay in your coordinator boundary",
|
|
1390
1461
|
domain: "security",
|
|
1391
1462
|
priority: "p0",
|
|
1392
|
-
content: "Session scoping is mandatory. Managers dispatch to workers within their own
|
|
1463
|
+
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."
|
|
1393
1464
|
},
|
|
1394
1465
|
{
|
|
1395
1466
|
title: "Session isolation \u2014 never touch another session's work",
|
|
1396
1467
|
domain: "workflow",
|
|
1397
1468
|
priority: "p0",
|
|
1398
|
-
content:
|
|
1469
|
+
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."
|
|
1399
1470
|
},
|
|
1400
1471
|
// --- Engineering: session scoping in code ---
|
|
1401
1472
|
{
|
|
1402
1473
|
title: "Three-dimensional scoping \u2014 session, project, role \u2014 enforced in every query",
|
|
1403
1474
|
domain: "architecture",
|
|
1404
1475
|
priority: "p0",
|
|
1405
|
-
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
|
|
1476
|
+
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."
|
|
1406
1477
|
},
|
|
1407
1478
|
// --- Hard constraints ---
|
|
1408
1479
|
{
|
|
1409
1480
|
title: "What you CANNOT do in exe-os \u2014 hard constraints",
|
|
1410
1481
|
domain: "security",
|
|
1411
1482
|
priority: "p0",
|
|
1412
|
-
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
|
|
1483
|
+
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."
|
|
1413
1484
|
},
|
|
1414
1485
|
// --- Operations ---
|
|
1415
1486
|
{
|
|
@@ -1531,17 +1602,17 @@ ${p.content}`).join("\n\n");
|
|
|
1531
1602
|
init_database();
|
|
1532
1603
|
|
|
1533
1604
|
// src/lib/keychain.ts
|
|
1534
|
-
import { readFile, writeFile, unlink, mkdir, chmod } from "fs/promises";
|
|
1535
|
-
import { existsSync } from "fs";
|
|
1536
|
-
import
|
|
1537
|
-
import
|
|
1605
|
+
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
1606
|
+
import { existsSync as existsSync3 } from "fs";
|
|
1607
|
+
import path3 from "path";
|
|
1608
|
+
import os3 from "os";
|
|
1538
1609
|
var SERVICE = "exe-mem";
|
|
1539
1610
|
var ACCOUNT = "master-key";
|
|
1540
1611
|
function getKeyDir() {
|
|
1541
|
-
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ??
|
|
1612
|
+
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path3.join(os3.homedir(), ".exe-os");
|
|
1542
1613
|
}
|
|
1543
1614
|
function getKeyPath() {
|
|
1544
|
-
return
|
|
1615
|
+
return path3.join(getKeyDir(), "master.key");
|
|
1545
1616
|
}
|
|
1546
1617
|
async function tryKeytar() {
|
|
1547
1618
|
try {
|
|
@@ -1562,11 +1633,11 @@ async function getMasterKey() {
|
|
|
1562
1633
|
}
|
|
1563
1634
|
}
|
|
1564
1635
|
const keyPath = getKeyPath();
|
|
1565
|
-
if (!
|
|
1636
|
+
if (!existsSync3(keyPath)) {
|
|
1566
1637
|
return null;
|
|
1567
1638
|
}
|
|
1568
1639
|
try {
|
|
1569
|
-
const content = await
|
|
1640
|
+
const content = await readFile3(keyPath, "utf-8");
|
|
1570
1641
|
return Buffer.from(content.trim(), "base64");
|
|
1571
1642
|
} catch {
|
|
1572
1643
|
return null;
|