@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,230 @@ 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 isCoordinatorName(agentName, employees = loadEmployeesSync()) {
|
|
269
|
+
if (!agentName) return false;
|
|
270
|
+
return agentName.toLowerCase() === getCoordinatorName(employees).toLowerCase();
|
|
271
|
+
}
|
|
272
|
+
function loadEmployeesSync(employeesPath = EMPLOYEES_PATH) {
|
|
273
|
+
if (!existsSync2(employeesPath)) return [];
|
|
274
|
+
try {
|
|
275
|
+
return JSON.parse(readFileSync2(employeesPath, "utf-8"));
|
|
276
|
+
} catch {
|
|
277
|
+
return [];
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
var EMPLOYEES_PATH, DEFAULT_COORDINATOR_TEMPLATE_NAME, COORDINATOR_ROLE;
|
|
281
|
+
var init_employees = __esm({
|
|
282
|
+
"src/lib/employees.ts"() {
|
|
283
|
+
"use strict";
|
|
284
|
+
init_config();
|
|
285
|
+
EMPLOYEES_PATH = path2.join(EXE_AI_DIR, "exe-employees.json");
|
|
286
|
+
DEFAULT_COORDINATOR_TEMPLATE_NAME = "exe";
|
|
287
|
+
COORDINATOR_ROLE = "COO";
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
|
|
67
291
|
// src/lib/database.ts
|
|
68
292
|
import { createClient } from "@libsql/client";
|
|
69
293
|
async function initDatabase(config) {
|
|
@@ -197,22 +421,24 @@ async function ensureSchema() {
|
|
|
197
421
|
ON behaviors(agent_id, active);
|
|
198
422
|
`);
|
|
199
423
|
try {
|
|
424
|
+
const coordinatorName = getCoordinatorName();
|
|
200
425
|
const existing = await client.execute({
|
|
201
|
-
sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id =
|
|
202
|
-
args: []
|
|
426
|
+
sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id = ?",
|
|
427
|
+
args: [coordinatorName]
|
|
203
428
|
});
|
|
204
429
|
if (Number(existing.rows[0]?.cnt) === 0) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
430
|
+
const seededAt = "2026-03-25T00:00:00Z";
|
|
431
|
+
for (const [domain, content] of [
|
|
432
|
+
["workflow", `Don't ask "keep going?" \u2014 just keep executing phases/plans autonomously`],
|
|
433
|
+
["tool-use", "Always use create_task MCP tool, never write .md files directly for task creation"],
|
|
434
|
+
["workflow", "Auto-start reviewing when idle and reviews are pending \u2014 never ask founder for permission"]
|
|
435
|
+
]) {
|
|
436
|
+
await client.execute({
|
|
437
|
+
sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
|
|
438
|
+
VALUES (hex(randomblob(16)), ?, NULL, ?, ?, 1, ?, ?)`,
|
|
439
|
+
args: [coordinatorName, domain, content, seededAt, seededAt]
|
|
440
|
+
});
|
|
441
|
+
}
|
|
216
442
|
}
|
|
217
443
|
} catch {
|
|
218
444
|
}
|
|
@@ -904,204 +1130,49 @@ async function ensureSchema() {
|
|
|
904
1130
|
} catch {
|
|
905
1131
|
}
|
|
906
1132
|
}
|
|
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
|
-
}
|
|
1133
|
+
try {
|
|
1134
|
+
await client.execute({
|
|
1135
|
+
sql: `ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0`,
|
|
1136
|
+
args: []
|
|
1137
|
+
});
|
|
1138
|
+
} catch {
|
|
937
1139
|
}
|
|
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"
|
|
1140
|
+
try {
|
|
1141
|
+
await client.execute(
|
|
1142
|
+
`CREATE INDEX IF NOT EXISTS idx_memories_draft ON memories(draft) WHERE draft = 1`
|
|
944
1143
|
);
|
|
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
|
-
}
|
|
1144
|
+
} catch {
|
|
965
1145
|
}
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
if (userAuto.enabled === void 0 && raw.rerankerEnabled !== void 0) {
|
|
973
|
-
userAuto.enabled = raw.rerankerEnabled;
|
|
1146
|
+
try {
|
|
1147
|
+
await client.execute({
|
|
1148
|
+
sql: `ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'`,
|
|
1149
|
+
args: []
|
|
1150
|
+
});
|
|
1151
|
+
} catch {
|
|
974
1152
|
}
|
|
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") };
|
|
1153
|
+
try {
|
|
1154
|
+
await client.execute(
|
|
1155
|
+
`CREATE INDEX IF NOT EXISTS idx_memories_type ON memories(memory_type)`
|
|
1156
|
+
);
|
|
1157
|
+
} catch {
|
|
996
1158
|
}
|
|
997
|
-
const raw = await readFile2(configPath, "utf-8");
|
|
998
1159
|
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;
|
|
1160
|
+
await client.execute({
|
|
1161
|
+
sql: `ALTER TABLE memories ADD COLUMN trajectory TEXT`,
|
|
1162
|
+
args: []
|
|
1163
|
+
});
|
|
1018
1164
|
} catch {
|
|
1019
|
-
return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
|
|
1020
1165
|
}
|
|
1021
1166
|
}
|
|
1022
|
-
var
|
|
1023
|
-
var
|
|
1024
|
-
"src/lib/
|
|
1167
|
+
var _client, _resilientClient, initTurso;
|
|
1168
|
+
var init_database = __esm({
|
|
1169
|
+
"src/lib/database.ts"() {
|
|
1025
1170
|
"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
|
-
];
|
|
1171
|
+
init_db_retry();
|
|
1172
|
+
init_employees();
|
|
1173
|
+
_client = null;
|
|
1174
|
+
_resilientClient = null;
|
|
1175
|
+
initTurso = initDatabase;
|
|
1105
1176
|
}
|
|
1106
1177
|
});
|
|
1107
1178
|
|
|
@@ -1118,12 +1189,12 @@ __export(shard_manager_exports, {
|
|
|
1118
1189
|
listShards: () => listShards,
|
|
1119
1190
|
shardExists: () => shardExists
|
|
1120
1191
|
});
|
|
1121
|
-
import
|
|
1122
|
-
import { existsSync as
|
|
1192
|
+
import path4 from "path";
|
|
1193
|
+
import { existsSync as existsSync4, mkdirSync, readdirSync } from "fs";
|
|
1123
1194
|
import { createClient as createClient2 } from "@libsql/client";
|
|
1124
1195
|
function initShardManager(encryptionKey) {
|
|
1125
1196
|
_encryptionKey = encryptionKey;
|
|
1126
|
-
if (!
|
|
1197
|
+
if (!existsSync4(SHARDS_DIR)) {
|
|
1127
1198
|
mkdirSync(SHARDS_DIR, { recursive: true });
|
|
1128
1199
|
}
|
|
1129
1200
|
_shardingEnabled = true;
|
|
@@ -1144,7 +1215,7 @@ function getShardClient(projectName) {
|
|
|
1144
1215
|
}
|
|
1145
1216
|
const cached = _shards.get(safeName);
|
|
1146
1217
|
if (cached) return cached;
|
|
1147
|
-
const dbPath =
|
|
1218
|
+
const dbPath = path4.join(SHARDS_DIR, `${safeName}.db`);
|
|
1148
1219
|
const client = createClient2({
|
|
1149
1220
|
url: `file:${dbPath}`,
|
|
1150
1221
|
encryptionKey: _encryptionKey
|
|
@@ -1154,10 +1225,10 @@ function getShardClient(projectName) {
|
|
|
1154
1225
|
}
|
|
1155
1226
|
function shardExists(projectName) {
|
|
1156
1227
|
const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1157
|
-
return
|
|
1228
|
+
return existsSync4(path4.join(SHARDS_DIR, `${safeName}.db`));
|
|
1158
1229
|
}
|
|
1159
1230
|
function listShards() {
|
|
1160
|
-
if (!
|
|
1231
|
+
if (!existsSync4(SHARDS_DIR)) return [];
|
|
1161
1232
|
return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
1162
1233
|
}
|
|
1163
1234
|
async function ensureShardSchema(client) {
|
|
@@ -1227,7 +1298,11 @@ async function ensureShardSchema(client) {
|
|
|
1227
1298
|
"ALTER TABLE memories ADD COLUMN source_path TEXT",
|
|
1228
1299
|
"ALTER TABLE memories ADD COLUMN source_type TEXT DEFAULT 'text'",
|
|
1229
1300
|
"ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3",
|
|
1230
|
-
"ALTER TABLE memories ADD COLUMN supersedes_id TEXT"
|
|
1301
|
+
"ALTER TABLE memories ADD COLUMN supersedes_id TEXT",
|
|
1302
|
+
// MS-11: draft staging, MS-6a: memory_type, MS-7: trajectory
|
|
1303
|
+
"ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0",
|
|
1304
|
+
"ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'",
|
|
1305
|
+
"ALTER TABLE memories ADD COLUMN trajectory TEXT"
|
|
1231
1306
|
]) {
|
|
1232
1307
|
try {
|
|
1233
1308
|
await client.execute(col);
|
|
@@ -1339,7 +1414,7 @@ var init_shard_manager = __esm({
|
|
|
1339
1414
|
"src/lib/shard-manager.ts"() {
|
|
1340
1415
|
"use strict";
|
|
1341
1416
|
init_config();
|
|
1342
|
-
SHARDS_DIR =
|
|
1417
|
+
SHARDS_DIR = path4.join(EXE_AI_DIR, "shards");
|
|
1343
1418
|
_shards = /* @__PURE__ */ new Map();
|
|
1344
1419
|
_encryptionKey = null;
|
|
1345
1420
|
_shardingEnabled = false;
|
|
@@ -1357,26 +1432,26 @@ var init_platform_procedures = __esm({
|
|
|
1357
1432
|
title: "What is exe-os \u2014 the operating model every agent must understand",
|
|
1358
1433
|
domain: "architecture",
|
|
1359
1434
|
priority: "p0",
|
|
1360
|
-
content: "Exe OS is an AI employee operating system. A founder runs 5-10 AI agents as a real org: COO
|
|
1435
|
+
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
1436
|
},
|
|
1362
1437
|
{
|
|
1363
1438
|
title: "Mode 1 \u2014 how exe-os runs inside Claude Code",
|
|
1364
1439
|
domain: "architecture",
|
|
1365
1440
|
priority: "p0",
|
|
1366
|
-
content: "Mode 1: exe-os runs AS hooks + MCP + skills inside Claude Code. The founder opens CC
|
|
1441
|
+
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
1442
|
},
|
|
1368
1443
|
{
|
|
1369
|
-
title: "Sessions explained \u2014
|
|
1444
|
+
title: "Sessions explained \u2014 coordinator session names and projects",
|
|
1370
1445
|
domain: "architecture",
|
|
1371
1446
|
priority: "p0",
|
|
1372
|
-
content: "Each
|
|
1447
|
+
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
1448
|
},
|
|
1374
1449
|
// --- Hierarchy and dispatch ---
|
|
1375
1450
|
{
|
|
1376
1451
|
title: "Chain of command \u2014 who talks to whom",
|
|
1377
1452
|
domain: "workflow",
|
|
1378
1453
|
priority: "p0",
|
|
1379
|
-
content: "Founder
|
|
1454
|
+
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
1455
|
},
|
|
1381
1456
|
{
|
|
1382
1457
|
title: "Single dispatch path \u2014 create_task only",
|
|
@@ -1386,30 +1461,30 @@ var init_platform_procedures = __esm({
|
|
|
1386
1461
|
},
|
|
1387
1462
|
// --- Session isolation ---
|
|
1388
1463
|
{
|
|
1389
|
-
title: "Session scoping \u2014 stay in your
|
|
1464
|
+
title: "Session scoping \u2014 stay in your coordinator boundary",
|
|
1390
1465
|
domain: "security",
|
|
1391
1466
|
priority: "p0",
|
|
1392
|
-
content: "Session scoping is mandatory. Managers dispatch to workers within their own
|
|
1467
|
+
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
1468
|
},
|
|
1394
1469
|
{
|
|
1395
1470
|
title: "Session isolation \u2014 never touch another session's work",
|
|
1396
1471
|
domain: "workflow",
|
|
1397
1472
|
priority: "p0",
|
|
1398
|
-
content:
|
|
1473
|
+
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
1474
|
},
|
|
1400
1475
|
// --- Engineering: session scoping in code ---
|
|
1401
1476
|
{
|
|
1402
1477
|
title: "Three-dimensional scoping \u2014 session, project, role \u2014 enforced in every query",
|
|
1403
1478
|
domain: "architecture",
|
|
1404
1479
|
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
|
|
1480
|
+
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
1481
|
},
|
|
1407
1482
|
// --- Hard constraints ---
|
|
1408
1483
|
{
|
|
1409
1484
|
title: "What you CANNOT do in exe-os \u2014 hard constraints",
|
|
1410
1485
|
domain: "security",
|
|
1411
1486
|
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
|
|
1487
|
+
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
1488
|
},
|
|
1414
1489
|
// --- Operations ---
|
|
1415
1490
|
{
|
|
@@ -1531,7 +1606,7 @@ ${p.content}`).join("\n\n");
|
|
|
1531
1606
|
import crypto from "crypto";
|
|
1532
1607
|
import { createReadStream } from "fs";
|
|
1533
1608
|
import { readdir, stat } from "fs/promises";
|
|
1534
|
-
import
|
|
1609
|
+
import path6 from "path";
|
|
1535
1610
|
import { createInterface } from "readline";
|
|
1536
1611
|
import { homedir } from "os";
|
|
1537
1612
|
import { parseArgs } from "util";
|
|
@@ -1543,17 +1618,17 @@ var EMBEDDING_DIM = 1024;
|
|
|
1543
1618
|
init_database();
|
|
1544
1619
|
|
|
1545
1620
|
// src/lib/keychain.ts
|
|
1546
|
-
import { readFile, writeFile, unlink, mkdir, chmod } from "fs/promises";
|
|
1547
|
-
import { existsSync } from "fs";
|
|
1548
|
-
import
|
|
1549
|
-
import
|
|
1621
|
+
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
1622
|
+
import { existsSync as existsSync3 } from "fs";
|
|
1623
|
+
import path3 from "path";
|
|
1624
|
+
import os3 from "os";
|
|
1550
1625
|
var SERVICE = "exe-mem";
|
|
1551
1626
|
var ACCOUNT = "master-key";
|
|
1552
1627
|
function getKeyDir() {
|
|
1553
|
-
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ??
|
|
1628
|
+
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path3.join(os3.homedir(), ".exe-os");
|
|
1554
1629
|
}
|
|
1555
1630
|
function getKeyPath() {
|
|
1556
|
-
return
|
|
1631
|
+
return path3.join(getKeyDir(), "master.key");
|
|
1557
1632
|
}
|
|
1558
1633
|
async function tryKeytar() {
|
|
1559
1634
|
try {
|
|
@@ -1574,11 +1649,11 @@ async function getMasterKey() {
|
|
|
1574
1649
|
}
|
|
1575
1650
|
}
|
|
1576
1651
|
const keyPath = getKeyPath();
|
|
1577
|
-
if (!
|
|
1652
|
+
if (!existsSync3(keyPath)) {
|
|
1578
1653
|
return null;
|
|
1579
1654
|
}
|
|
1580
1655
|
try {
|
|
1581
|
-
const content = await
|
|
1656
|
+
const content = await readFile3(keyPath, "utf-8");
|
|
1582
1657
|
return Buffer.from(content.trim(), "base64");
|
|
1583
1658
|
} catch {
|
|
1584
1659
|
return null;
|
|
@@ -1751,7 +1826,10 @@ async function writeMemory(record) {
|
|
|
1751
1826
|
source_path: record.source_path ?? null,
|
|
1752
1827
|
source_type: record.source_type ?? null,
|
|
1753
1828
|
tier: record.tier ?? classifyTier(record),
|
|
1754
|
-
supersedes_id: record.supersedes_id ?? null
|
|
1829
|
+
supersedes_id: record.supersedes_id ?? null,
|
|
1830
|
+
draft: record.draft ? 1 : 0,
|
|
1831
|
+
memory_type: record.memory_type ?? "raw",
|
|
1832
|
+
trajectory: record.trajectory ? JSON.stringify(record.trajectory) : null
|
|
1755
1833
|
};
|
|
1756
1834
|
_pendingRecords.push(dbRow);
|
|
1757
1835
|
orgBus.emit({
|
|
@@ -1806,6 +1884,9 @@ async function flushBatch() {
|
|
|
1806
1884
|
const sourceType = row.source_type ?? null;
|
|
1807
1885
|
const tier = row.tier ?? 3;
|
|
1808
1886
|
const supersedesId = row.supersedes_id ?? null;
|
|
1887
|
+
const draft = row.draft ? 1 : 0;
|
|
1888
|
+
const memoryType = row.memory_type ?? "raw";
|
|
1889
|
+
const trajectory = row.trajectory ?? null;
|
|
1809
1890
|
return {
|
|
1810
1891
|
sql: hasVector ? `INSERT OR IGNORE INTO memories
|
|
1811
1892
|
(id, agent_id, agent_role, session_id, timestamp,
|
|
@@ -1813,15 +1894,15 @@ async function flushBatch() {
|
|
|
1813
1894
|
has_error, raw_text, vector, version, task_id, importance, status,
|
|
1814
1895
|
confidence, last_accessed,
|
|
1815
1896
|
workspace_id, document_id, user_id, char_offset, page_number,
|
|
1816
|
-
source_path, source_type, tier, supersedes_id)
|
|
1817
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories
|
|
1897
|
+
source_path, source_type, tier, supersedes_id, draft, memory_type, trajectory)
|
|
1898
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories
|
|
1818
1899
|
(id, agent_id, agent_role, session_id, timestamp,
|
|
1819
1900
|
tool_name, project_name,
|
|
1820
1901
|
has_error, raw_text, vector, version, task_id, importance, status,
|
|
1821
1902
|
confidence, last_accessed,
|
|
1822
1903
|
workspace_id, document_id, user_id, char_offset, page_number,
|
|
1823
|
-
source_path, source_type, tier, supersedes_id)
|
|
1824
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
1904
|
+
source_path, source_type, tier, supersedes_id, draft, memory_type, trajectory)
|
|
1905
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
1825
1906
|
args: hasVector ? [
|
|
1826
1907
|
row.id,
|
|
1827
1908
|
row.agent_id,
|
|
@@ -1847,7 +1928,10 @@ async function flushBatch() {
|
|
|
1847
1928
|
sourcePath,
|
|
1848
1929
|
sourceType,
|
|
1849
1930
|
tier,
|
|
1850
|
-
supersedesId
|
|
1931
|
+
supersedesId,
|
|
1932
|
+
draft,
|
|
1933
|
+
memoryType,
|
|
1934
|
+
trajectory
|
|
1851
1935
|
] : [
|
|
1852
1936
|
row.id,
|
|
1853
1937
|
row.agent_id,
|
|
@@ -1872,7 +1956,10 @@ async function flushBatch() {
|
|
|
1872
1956
|
sourcePath,
|
|
1873
1957
|
sourceType,
|
|
1874
1958
|
tier,
|
|
1875
|
-
supersedesId
|
|
1959
|
+
supersedesId,
|
|
1960
|
+
draft,
|
|
1961
|
+
memoryType,
|
|
1962
|
+
trajectory
|
|
1876
1963
|
]
|
|
1877
1964
|
};
|
|
1878
1965
|
};
|
|
@@ -1919,12 +2006,12 @@ init_config();
|
|
|
1919
2006
|
import net from "net";
|
|
1920
2007
|
import { spawn } from "child_process";
|
|
1921
2008
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
1922
|
-
import { existsSync as
|
|
1923
|
-
import
|
|
2009
|
+
import { existsSync as existsSync5, unlinkSync as unlinkSync2, readFileSync as readFileSync3, openSync, closeSync, statSync } from "fs";
|
|
2010
|
+
import path5 from "path";
|
|
1924
2011
|
import { fileURLToPath } from "url";
|
|
1925
|
-
var SOCKET_PATH = process.env.EXE_DAEMON_SOCK ?? process.env.EXE_EMBED_SOCK ??
|
|
1926
|
-
var PID_PATH = process.env.EXE_DAEMON_PID ?? process.env.EXE_EMBED_PID ??
|
|
1927
|
-
var SPAWN_LOCK_PATH =
|
|
2012
|
+
var SOCKET_PATH = process.env.EXE_DAEMON_SOCK ?? process.env.EXE_EMBED_SOCK ?? path5.join(EXE_AI_DIR, "exed.sock");
|
|
2013
|
+
var PID_PATH = process.env.EXE_DAEMON_PID ?? process.env.EXE_EMBED_PID ?? path5.join(EXE_AI_DIR, "exed.pid");
|
|
2014
|
+
var SPAWN_LOCK_PATH = path5.join(EXE_AI_DIR, "exed-spawn.lock");
|
|
1928
2015
|
var SPAWN_LOCK_STALE_MS = 3e4;
|
|
1929
2016
|
var CONNECT_TIMEOUT_MS = 15e3;
|
|
1930
2017
|
var REQUEST_TIMEOUT_MS = 3e4;
|
|
@@ -1959,9 +2046,9 @@ function handleData(chunk) {
|
|
|
1959
2046
|
}
|
|
1960
2047
|
}
|
|
1961
2048
|
function cleanupStaleFiles() {
|
|
1962
|
-
if (
|
|
2049
|
+
if (existsSync5(PID_PATH)) {
|
|
1963
2050
|
try {
|
|
1964
|
-
const pid = parseInt(
|
|
2051
|
+
const pid = parseInt(readFileSync3(PID_PATH, "utf8").trim(), 10);
|
|
1965
2052
|
if (pid > 0) {
|
|
1966
2053
|
try {
|
|
1967
2054
|
process.kill(pid, 0);
|
|
@@ -1972,21 +2059,21 @@ function cleanupStaleFiles() {
|
|
|
1972
2059
|
} catch {
|
|
1973
2060
|
}
|
|
1974
2061
|
try {
|
|
1975
|
-
|
|
2062
|
+
unlinkSync2(PID_PATH);
|
|
1976
2063
|
} catch {
|
|
1977
2064
|
}
|
|
1978
2065
|
try {
|
|
1979
|
-
|
|
2066
|
+
unlinkSync2(SOCKET_PATH);
|
|
1980
2067
|
} catch {
|
|
1981
2068
|
}
|
|
1982
2069
|
}
|
|
1983
2070
|
}
|
|
1984
2071
|
function findPackageRoot() {
|
|
1985
|
-
let dir =
|
|
1986
|
-
const { root } =
|
|
2072
|
+
let dir = path5.dirname(fileURLToPath(import.meta.url));
|
|
2073
|
+
const { root } = path5.parse(dir);
|
|
1987
2074
|
while (dir !== root) {
|
|
1988
|
-
if (
|
|
1989
|
-
dir =
|
|
2075
|
+
if (existsSync5(path5.join(dir, "package.json"))) return dir;
|
|
2076
|
+
dir = path5.dirname(dir);
|
|
1990
2077
|
}
|
|
1991
2078
|
return null;
|
|
1992
2079
|
}
|
|
@@ -1996,8 +2083,8 @@ function spawnDaemon() {
|
|
|
1996
2083
|
process.stderr.write("[exed-client] WARN: cannot find package root\n");
|
|
1997
2084
|
return;
|
|
1998
2085
|
}
|
|
1999
|
-
const daemonPath =
|
|
2000
|
-
if (!
|
|
2086
|
+
const daemonPath = path5.join(pkgRoot, "dist", "lib", "exe-daemon.js");
|
|
2087
|
+
if (!existsSync5(daemonPath)) {
|
|
2001
2088
|
process.stderr.write(`[exed-client] WARN: daemon script not found at ${daemonPath}
|
|
2002
2089
|
`);
|
|
2003
2090
|
return;
|
|
@@ -2005,7 +2092,7 @@ function spawnDaemon() {
|
|
|
2005
2092
|
const resolvedPath = daemonPath;
|
|
2006
2093
|
process.stderr.write(`[exed-client] Spawning daemon: ${resolvedPath}
|
|
2007
2094
|
`);
|
|
2008
|
-
const logPath =
|
|
2095
|
+
const logPath = path5.join(path5.dirname(SOCKET_PATH), "exed.log");
|
|
2009
2096
|
let stderrFd = "ignore";
|
|
2010
2097
|
try {
|
|
2011
2098
|
stderrFd = openSync(logPath, "a");
|
|
@@ -2016,6 +2103,10 @@ function spawnDaemon() {
|
|
|
2016
2103
|
stdio: ["ignore", "ignore", stderrFd],
|
|
2017
2104
|
env: {
|
|
2018
2105
|
...process.env,
|
|
2106
|
+
TMUX: void 0,
|
|
2107
|
+
// Daemon is global — must not inherit session scope
|
|
2108
|
+
TMUX_PANE: void 0,
|
|
2109
|
+
// Prevents resolveExeSession() from scoping to one session
|
|
2019
2110
|
EXE_DAEMON_SOCK: SOCKET_PATH,
|
|
2020
2111
|
EXE_DAEMON_PID: PID_PATH
|
|
2021
2112
|
}
|
|
@@ -2038,7 +2129,7 @@ function acquireSpawnLock() {
|
|
|
2038
2129
|
const stat2 = statSync(SPAWN_LOCK_PATH);
|
|
2039
2130
|
if (Date.now() - stat2.mtimeMs > SPAWN_LOCK_STALE_MS) {
|
|
2040
2131
|
try {
|
|
2041
|
-
|
|
2132
|
+
unlinkSync2(SPAWN_LOCK_PATH);
|
|
2042
2133
|
} catch {
|
|
2043
2134
|
}
|
|
2044
2135
|
try {
|
|
@@ -2055,7 +2146,7 @@ function acquireSpawnLock() {
|
|
|
2055
2146
|
}
|
|
2056
2147
|
function releaseSpawnLock() {
|
|
2057
2148
|
try {
|
|
2058
|
-
|
|
2149
|
+
unlinkSync2(SPAWN_LOCK_PATH);
|
|
2059
2150
|
} catch {
|
|
2060
2151
|
}
|
|
2061
2152
|
}
|
|
@@ -2167,9 +2258,9 @@ async function pingDaemon() {
|
|
|
2167
2258
|
}
|
|
2168
2259
|
function killAndRespawnDaemon() {
|
|
2169
2260
|
process.stderr.write("[exed-client] Killing daemon for restart...\n");
|
|
2170
|
-
if (
|
|
2261
|
+
if (existsSync5(PID_PATH)) {
|
|
2171
2262
|
try {
|
|
2172
|
-
const pid = parseInt(
|
|
2263
|
+
const pid = parseInt(readFileSync3(PID_PATH, "utf8").trim(), 10);
|
|
2173
2264
|
if (pid > 0) {
|
|
2174
2265
|
try {
|
|
2175
2266
|
process.kill(pid, "SIGKILL");
|
|
@@ -2186,11 +2277,11 @@ function killAndRespawnDaemon() {
|
|
|
2186
2277
|
_connected = false;
|
|
2187
2278
|
_buffer = "";
|
|
2188
2279
|
try {
|
|
2189
|
-
|
|
2280
|
+
unlinkSync2(PID_PATH);
|
|
2190
2281
|
} catch {
|
|
2191
2282
|
}
|
|
2192
2283
|
try {
|
|
2193
|
-
|
|
2284
|
+
unlinkSync2(SOCKET_PATH);
|
|
2194
2285
|
} catch {
|
|
2195
2286
|
}
|
|
2196
2287
|
spawnDaemon();
|
|
@@ -2254,12 +2345,13 @@ function isMainModule(importMetaUrl) {
|
|
|
2254
2345
|
}
|
|
2255
2346
|
|
|
2256
2347
|
// src/bin/backfill-conversations.ts
|
|
2348
|
+
init_employees();
|
|
2257
2349
|
var TOOL_NAME = "backfill-conversation";
|
|
2258
2350
|
var MIN_MESSAGES = 3;
|
|
2259
2351
|
var MAX_SUMMARY_LENGTH = 4e3;
|
|
2260
2352
|
var MAX_WALK_DEPTH = 10;
|
|
2261
2353
|
async function findJsonlFiles(sinceDate, projectFilter) {
|
|
2262
|
-
const projectsDir =
|
|
2354
|
+
const projectsDir = path6.join(homedir(), ".claude", "projects");
|
|
2263
2355
|
const files = [];
|
|
2264
2356
|
async function walk(dir, depth = 0) {
|
|
2265
2357
|
if (depth > MAX_WALK_DEPTH) return;
|
|
@@ -2270,7 +2362,7 @@ async function findJsonlFiles(sinceDate, projectFilter) {
|
|
|
2270
2362
|
return;
|
|
2271
2363
|
}
|
|
2272
2364
|
for (const entry of entries) {
|
|
2273
|
-
const full =
|
|
2365
|
+
const full = path6.join(dir, entry.name);
|
|
2274
2366
|
if (entry.isDirectory()) {
|
|
2275
2367
|
if (entry.name === "subagents" || entry.name === "tool-results") continue;
|
|
2276
2368
|
await walk(full, depth + 1);
|
|
@@ -2295,7 +2387,7 @@ async function findJsonlFiles(sinceDate, projectFilter) {
|
|
|
2295
2387
|
if (!entry.isDirectory()) continue;
|
|
2296
2388
|
const decoded = decodeProjectDir(entry.name);
|
|
2297
2389
|
if (decoded.toLowerCase().includes(projectFilter.toLowerCase())) {
|
|
2298
|
-
await walk(
|
|
2390
|
+
await walk(path6.join(projectsDir, entry.name));
|
|
2299
2391
|
}
|
|
2300
2392
|
}
|
|
2301
2393
|
} else {
|
|
@@ -2312,14 +2404,14 @@ function decodeProjectDir(dirName) {
|
|
|
2312
2404
|
return dirName;
|
|
2313
2405
|
}
|
|
2314
2406
|
function projectNameFromPath(filePath) {
|
|
2315
|
-
const projectsDir =
|
|
2316
|
-
const relative =
|
|
2317
|
-
const projectDir = relative.split(
|
|
2407
|
+
const projectsDir = path6.join(homedir(), ".claude", "projects");
|
|
2408
|
+
const relative = path6.relative(projectsDir, filePath);
|
|
2409
|
+
const projectDir = relative.split(path6.sep)[0] ?? "unknown";
|
|
2318
2410
|
return decodeProjectDir(projectDir);
|
|
2319
2411
|
}
|
|
2320
2412
|
async function parseConversation(filePath) {
|
|
2321
2413
|
const conv = {
|
|
2322
|
-
sessionId:
|
|
2414
|
+
sessionId: path6.basename(filePath, ".jsonl"),
|
|
2323
2415
|
projectName: projectNameFromPath(filePath),
|
|
2324
2416
|
cwd: void 0,
|
|
2325
2417
|
startTime: void 0,
|
|
@@ -2383,7 +2475,7 @@ async function parseConversation(filePath) {
|
|
|
2383
2475
|
}
|
|
2384
2476
|
}
|
|
2385
2477
|
if (conv.cwd) {
|
|
2386
|
-
conv.projectName =
|
|
2478
|
+
conv.projectName = path6.basename(conv.cwd);
|
|
2387
2479
|
const worktreeMatch = conv.cwd.match(/\.worktrees\/([^/]+)/);
|
|
2388
2480
|
if (worktreeMatch?.[1]) {
|
|
2389
2481
|
conv.agentId = worktreeMatch[1];
|
|
@@ -2558,7 +2650,7 @@ async function backfillConversations(options) {
|
|
|
2558
2650
|
await writeMemory({
|
|
2559
2651
|
id: crypto.randomUUID(),
|
|
2560
2652
|
agent_id: conv.agentId,
|
|
2561
|
-
agent_role: conv.agentId === "exe" ? "COO" : "specialist",
|
|
2653
|
+
agent_role: isCoordinatorName(conv.agentId) || conv.agentId === "exe" ? "COO" : "specialist",
|
|
2562
2654
|
session_id: conv.sessionId,
|
|
2563
2655
|
timestamp: conv.startTime ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
2564
2656
|
tool_name: TOOL_NAME,
|