@askexenow/exe-os 0.8.81 → 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 +475 -232
- 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 +328 -263
- 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 +1111 -913
- 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
|
|
|
@@ -1542,17 +1617,17 @@ var EMBEDDING_DIM = 1024;
|
|
|
1542
1617
|
init_database();
|
|
1543
1618
|
|
|
1544
1619
|
// src/lib/keychain.ts
|
|
1545
|
-
import { readFile, writeFile, unlink, mkdir, chmod } from "fs/promises";
|
|
1546
|
-
import { existsSync } from "fs";
|
|
1547
|
-
import
|
|
1548
|
-
import
|
|
1620
|
+
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
1621
|
+
import { existsSync as existsSync3 } from "fs";
|
|
1622
|
+
import path3 from "path";
|
|
1623
|
+
import os3 from "os";
|
|
1549
1624
|
var SERVICE = "exe-mem";
|
|
1550
1625
|
var ACCOUNT = "master-key";
|
|
1551
1626
|
function getKeyDir() {
|
|
1552
|
-
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ??
|
|
1627
|
+
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path3.join(os3.homedir(), ".exe-os");
|
|
1553
1628
|
}
|
|
1554
1629
|
function getKeyPath() {
|
|
1555
|
-
return
|
|
1630
|
+
return path3.join(getKeyDir(), "master.key");
|
|
1556
1631
|
}
|
|
1557
1632
|
async function tryKeytar() {
|
|
1558
1633
|
try {
|
|
@@ -1573,11 +1648,11 @@ async function getMasterKey() {
|
|
|
1573
1648
|
}
|
|
1574
1649
|
}
|
|
1575
1650
|
const keyPath = getKeyPath();
|
|
1576
|
-
if (!
|
|
1651
|
+
if (!existsSync3(keyPath)) {
|
|
1577
1652
|
return null;
|
|
1578
1653
|
}
|
|
1579
1654
|
try {
|
|
1580
|
-
const content = await
|
|
1655
|
+
const content = await readFile3(keyPath, "utf-8");
|
|
1581
1656
|
return Buffer.from(content.trim(), "base64");
|
|
1582
1657
|
} catch {
|
|
1583
1658
|
return null;
|
|
@@ -1750,7 +1825,10 @@ async function writeMemory(record) {
|
|
|
1750
1825
|
source_path: record.source_path ?? null,
|
|
1751
1826
|
source_type: record.source_type ?? null,
|
|
1752
1827
|
tier: record.tier ?? classifyTier(record),
|
|
1753
|
-
supersedes_id: record.supersedes_id ?? null
|
|
1828
|
+
supersedes_id: record.supersedes_id ?? null,
|
|
1829
|
+
draft: record.draft ? 1 : 0,
|
|
1830
|
+
memory_type: record.memory_type ?? "raw",
|
|
1831
|
+
trajectory: record.trajectory ? JSON.stringify(record.trajectory) : null
|
|
1754
1832
|
};
|
|
1755
1833
|
_pendingRecords.push(dbRow);
|
|
1756
1834
|
orgBus.emit({
|
|
@@ -1805,6 +1883,9 @@ async function flushBatch() {
|
|
|
1805
1883
|
const sourceType = row.source_type ?? null;
|
|
1806
1884
|
const tier = row.tier ?? 3;
|
|
1807
1885
|
const supersedesId = row.supersedes_id ?? null;
|
|
1886
|
+
const draft = row.draft ? 1 : 0;
|
|
1887
|
+
const memoryType = row.memory_type ?? "raw";
|
|
1888
|
+
const trajectory = row.trajectory ?? null;
|
|
1808
1889
|
return {
|
|
1809
1890
|
sql: hasVector ? `INSERT OR IGNORE INTO memories
|
|
1810
1891
|
(id, agent_id, agent_role, session_id, timestamp,
|
|
@@ -1812,15 +1893,15 @@ async function flushBatch() {
|
|
|
1812
1893
|
has_error, raw_text, vector, version, task_id, importance, status,
|
|
1813
1894
|
confidence, last_accessed,
|
|
1814
1895
|
workspace_id, document_id, user_id, char_offset, page_number,
|
|
1815
|
-
source_path, source_type, tier, supersedes_id)
|
|
1816
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories
|
|
1896
|
+
source_path, source_type, tier, supersedes_id, draft, memory_type, trajectory)
|
|
1897
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories
|
|
1817
1898
|
(id, agent_id, agent_role, session_id, timestamp,
|
|
1818
1899
|
tool_name, project_name,
|
|
1819
1900
|
has_error, raw_text, vector, version, task_id, importance, status,
|
|
1820
1901
|
confidence, last_accessed,
|
|
1821
1902
|
workspace_id, document_id, user_id, char_offset, page_number,
|
|
1822
|
-
source_path, source_type, tier, supersedes_id)
|
|
1823
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
1903
|
+
source_path, source_type, tier, supersedes_id, draft, memory_type, trajectory)
|
|
1904
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
1824
1905
|
args: hasVector ? [
|
|
1825
1906
|
row.id,
|
|
1826
1907
|
row.agent_id,
|
|
@@ -1846,7 +1927,10 @@ async function flushBatch() {
|
|
|
1846
1927
|
sourcePath,
|
|
1847
1928
|
sourceType,
|
|
1848
1929
|
tier,
|
|
1849
|
-
supersedesId
|
|
1930
|
+
supersedesId,
|
|
1931
|
+
draft,
|
|
1932
|
+
memoryType,
|
|
1933
|
+
trajectory
|
|
1850
1934
|
] : [
|
|
1851
1935
|
row.id,
|
|
1852
1936
|
row.agent_id,
|
|
@@ -1871,7 +1955,10 @@ async function flushBatch() {
|
|
|
1871
1955
|
sourcePath,
|
|
1872
1956
|
sourceType,
|
|
1873
1957
|
tier,
|
|
1874
|
-
supersedesId
|
|
1958
|
+
supersedesId,
|
|
1959
|
+
draft,
|
|
1960
|
+
memoryType,
|
|
1961
|
+
trajectory
|
|
1875
1962
|
]
|
|
1876
1963
|
};
|
|
1877
1964
|
};
|
|
@@ -1918,12 +2005,12 @@ init_config();
|
|
|
1918
2005
|
import net from "net";
|
|
1919
2006
|
import { spawn } from "child_process";
|
|
1920
2007
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
1921
|
-
import { existsSync as
|
|
1922
|
-
import
|
|
2008
|
+
import { existsSync as existsSync5, unlinkSync as unlinkSync2, readFileSync as readFileSync3, openSync, closeSync, statSync } from "fs";
|
|
2009
|
+
import path5 from "path";
|
|
1923
2010
|
import { fileURLToPath } from "url";
|
|
1924
|
-
var SOCKET_PATH = process.env.EXE_DAEMON_SOCK ?? process.env.EXE_EMBED_SOCK ??
|
|
1925
|
-
var PID_PATH = process.env.EXE_DAEMON_PID ?? process.env.EXE_EMBED_PID ??
|
|
1926
|
-
var SPAWN_LOCK_PATH =
|
|
2011
|
+
var SOCKET_PATH = process.env.EXE_DAEMON_SOCK ?? process.env.EXE_EMBED_SOCK ?? path5.join(EXE_AI_DIR, "exed.sock");
|
|
2012
|
+
var PID_PATH = process.env.EXE_DAEMON_PID ?? process.env.EXE_EMBED_PID ?? path5.join(EXE_AI_DIR, "exed.pid");
|
|
2013
|
+
var SPAWN_LOCK_PATH = path5.join(EXE_AI_DIR, "exed-spawn.lock");
|
|
1927
2014
|
var SPAWN_LOCK_STALE_MS = 3e4;
|
|
1928
2015
|
var CONNECT_TIMEOUT_MS = 15e3;
|
|
1929
2016
|
var REQUEST_TIMEOUT_MS = 3e4;
|
|
@@ -1958,9 +2045,9 @@ function handleData(chunk) {
|
|
|
1958
2045
|
}
|
|
1959
2046
|
}
|
|
1960
2047
|
function cleanupStaleFiles() {
|
|
1961
|
-
if (
|
|
2048
|
+
if (existsSync5(PID_PATH)) {
|
|
1962
2049
|
try {
|
|
1963
|
-
const pid = parseInt(
|
|
2050
|
+
const pid = parseInt(readFileSync3(PID_PATH, "utf8").trim(), 10);
|
|
1964
2051
|
if (pid > 0) {
|
|
1965
2052
|
try {
|
|
1966
2053
|
process.kill(pid, 0);
|
|
@@ -1971,21 +2058,21 @@ function cleanupStaleFiles() {
|
|
|
1971
2058
|
} catch {
|
|
1972
2059
|
}
|
|
1973
2060
|
try {
|
|
1974
|
-
|
|
2061
|
+
unlinkSync2(PID_PATH);
|
|
1975
2062
|
} catch {
|
|
1976
2063
|
}
|
|
1977
2064
|
try {
|
|
1978
|
-
|
|
2065
|
+
unlinkSync2(SOCKET_PATH);
|
|
1979
2066
|
} catch {
|
|
1980
2067
|
}
|
|
1981
2068
|
}
|
|
1982
2069
|
}
|
|
1983
2070
|
function findPackageRoot() {
|
|
1984
|
-
let dir =
|
|
1985
|
-
const { root } =
|
|
2071
|
+
let dir = path5.dirname(fileURLToPath(import.meta.url));
|
|
2072
|
+
const { root } = path5.parse(dir);
|
|
1986
2073
|
while (dir !== root) {
|
|
1987
|
-
if (
|
|
1988
|
-
dir =
|
|
2074
|
+
if (existsSync5(path5.join(dir, "package.json"))) return dir;
|
|
2075
|
+
dir = path5.dirname(dir);
|
|
1989
2076
|
}
|
|
1990
2077
|
return null;
|
|
1991
2078
|
}
|
|
@@ -1995,8 +2082,8 @@ function spawnDaemon() {
|
|
|
1995
2082
|
process.stderr.write("[exed-client] WARN: cannot find package root\n");
|
|
1996
2083
|
return;
|
|
1997
2084
|
}
|
|
1998
|
-
const daemonPath =
|
|
1999
|
-
if (!
|
|
2085
|
+
const daemonPath = path5.join(pkgRoot, "dist", "lib", "exe-daemon.js");
|
|
2086
|
+
if (!existsSync5(daemonPath)) {
|
|
2000
2087
|
process.stderr.write(`[exed-client] WARN: daemon script not found at ${daemonPath}
|
|
2001
2088
|
`);
|
|
2002
2089
|
return;
|
|
@@ -2004,7 +2091,7 @@ function spawnDaemon() {
|
|
|
2004
2091
|
const resolvedPath = daemonPath;
|
|
2005
2092
|
process.stderr.write(`[exed-client] Spawning daemon: ${resolvedPath}
|
|
2006
2093
|
`);
|
|
2007
|
-
const logPath =
|
|
2094
|
+
const logPath = path5.join(path5.dirname(SOCKET_PATH), "exed.log");
|
|
2008
2095
|
let stderrFd = "ignore";
|
|
2009
2096
|
try {
|
|
2010
2097
|
stderrFd = openSync(logPath, "a");
|
|
@@ -2015,6 +2102,10 @@ function spawnDaemon() {
|
|
|
2015
2102
|
stdio: ["ignore", "ignore", stderrFd],
|
|
2016
2103
|
env: {
|
|
2017
2104
|
...process.env,
|
|
2105
|
+
TMUX: void 0,
|
|
2106
|
+
// Daemon is global — must not inherit session scope
|
|
2107
|
+
TMUX_PANE: void 0,
|
|
2108
|
+
// Prevents resolveExeSession() from scoping to one session
|
|
2018
2109
|
EXE_DAEMON_SOCK: SOCKET_PATH,
|
|
2019
2110
|
EXE_DAEMON_PID: PID_PATH
|
|
2020
2111
|
}
|
|
@@ -2037,7 +2128,7 @@ function acquireSpawnLock() {
|
|
|
2037
2128
|
const stat2 = statSync(SPAWN_LOCK_PATH);
|
|
2038
2129
|
if (Date.now() - stat2.mtimeMs > SPAWN_LOCK_STALE_MS) {
|
|
2039
2130
|
try {
|
|
2040
|
-
|
|
2131
|
+
unlinkSync2(SPAWN_LOCK_PATH);
|
|
2041
2132
|
} catch {
|
|
2042
2133
|
}
|
|
2043
2134
|
try {
|
|
@@ -2054,7 +2145,7 @@ function acquireSpawnLock() {
|
|
|
2054
2145
|
}
|
|
2055
2146
|
function releaseSpawnLock() {
|
|
2056
2147
|
try {
|
|
2057
|
-
|
|
2148
|
+
unlinkSync2(SPAWN_LOCK_PATH);
|
|
2058
2149
|
} catch {
|
|
2059
2150
|
}
|
|
2060
2151
|
}
|
|
@@ -2166,9 +2257,9 @@ async function pingDaemon() {
|
|
|
2166
2257
|
}
|
|
2167
2258
|
function killAndRespawnDaemon() {
|
|
2168
2259
|
process.stderr.write("[exed-client] Killing daemon for restart...\n");
|
|
2169
|
-
if (
|
|
2260
|
+
if (existsSync5(PID_PATH)) {
|
|
2170
2261
|
try {
|
|
2171
|
-
const pid = parseInt(
|
|
2262
|
+
const pid = parseInt(readFileSync3(PID_PATH, "utf8").trim(), 10);
|
|
2172
2263
|
if (pid > 0) {
|
|
2173
2264
|
try {
|
|
2174
2265
|
process.kill(pid, "SIGKILL");
|
|
@@ -2185,11 +2276,11 @@ function killAndRespawnDaemon() {
|
|
|
2185
2276
|
_connected = false;
|
|
2186
2277
|
_buffer = "";
|
|
2187
2278
|
try {
|
|
2188
|
-
|
|
2279
|
+
unlinkSync2(PID_PATH);
|
|
2189
2280
|
} catch {
|
|
2190
2281
|
}
|
|
2191
2282
|
try {
|
|
2192
|
-
|
|
2283
|
+
unlinkSync2(SOCKET_PATH);
|
|
2193
2284
|
} catch {
|
|
2194
2285
|
}
|
|
2195
2286
|
spawnDaemon();
|
|
@@ -2253,13 +2344,14 @@ function isMainModule(importMetaUrl) {
|
|
|
2253
2344
|
}
|
|
2254
2345
|
|
|
2255
2346
|
// src/bin/backfill-responses.ts
|
|
2347
|
+
init_employees();
|
|
2256
2348
|
var MIN_LENGTH = 100;
|
|
2257
2349
|
var MAX_LENGTH = 5e3;
|
|
2258
2350
|
var SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
2259
2351
|
process.env.EXE_EMBED_PRIORITY = "low";
|
|
2260
2352
|
var MAX_WALK_DEPTH = 10;
|
|
2261
2353
|
async function findRecentJsonlFiles() {
|
|
2262
|
-
const projectsDir =
|
|
2354
|
+
const projectsDir = path6.join(homedir(), ".claude", "projects");
|
|
2263
2355
|
const cutoff = Date.now() - SEVEN_DAYS_MS;
|
|
2264
2356
|
const files = [];
|
|
2265
2357
|
async function walk(dir, depth = 0) {
|
|
@@ -2271,7 +2363,7 @@ async function findRecentJsonlFiles() {
|
|
|
2271
2363
|
return;
|
|
2272
2364
|
}
|
|
2273
2365
|
for (const entry of entries) {
|
|
2274
|
-
const full =
|
|
2366
|
+
const full = path6.join(dir, entry.name);
|
|
2275
2367
|
if (entry.isDirectory()) {
|
|
2276
2368
|
await walk(full, depth + 1);
|
|
2277
2369
|
} else if (entry.name.endsWith(".jsonl")) {
|
|
@@ -2287,9 +2379,9 @@ async function findRecentJsonlFiles() {
|
|
|
2287
2379
|
return files;
|
|
2288
2380
|
}
|
|
2289
2381
|
function projectNameFromPath(filePath) {
|
|
2290
|
-
const projectsDir =
|
|
2291
|
-
const relative =
|
|
2292
|
-
const projectDir = relative.split(
|
|
2382
|
+
const projectsDir = path6.join(homedir(), ".claude", "projects");
|
|
2383
|
+
const relative = path6.relative(projectsDir, filePath);
|
|
2384
|
+
const projectDir = relative.split(path6.sep)[0] ?? "";
|
|
2293
2385
|
const homeEncoded = homedir().replaceAll("/", "-");
|
|
2294
2386
|
if (projectDir.startsWith(homeEncoded + "-")) {
|
|
2295
2387
|
return projectDir.slice(homeEncoded.length + 1);
|
|
@@ -2365,7 +2457,7 @@ async function processFile(filePath, seenHashes, daemonConnected, stats) {
|
|
|
2365
2457
|
continue;
|
|
2366
2458
|
}
|
|
2367
2459
|
seenHashes.add(hash);
|
|
2368
|
-
const resolvedProject = fileCwd ?
|
|
2460
|
+
const resolvedProject = fileCwd ? path6.basename(fileCwd) : fallbackProject;
|
|
2369
2461
|
let vector = null;
|
|
2370
2462
|
if (daemonConnected) {
|
|
2371
2463
|
try {
|
|
@@ -2378,7 +2470,7 @@ async function processFile(filePath, seenHashes, daemonConnected, stats) {
|
|
|
2378
2470
|
await writeMemory({
|
|
2379
2471
|
id: crypto.randomUUID(),
|
|
2380
2472
|
agent_id: agentId,
|
|
2381
|
-
agent_role: agentId === "exe" ? "COO" : "specialist",
|
|
2473
|
+
agent_role: isCoordinatorName(agentId) || agentId === "exe" ? "COO" : "specialist",
|
|
2382
2474
|
session_id: entry.sessionId ?? "backfill",
|
|
2383
2475
|
timestamp: entry.timestamp ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
2384
2476
|
tool_name: "AssistantResponse",
|