@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
package/dist/lib/store.js
CHANGED
|
@@ -47,7 +47,7 @@ function wrapWithRetry(client) {
|
|
|
47
47
|
return (sql) => retryOnBusy(() => target.execute(sql), "execute");
|
|
48
48
|
}
|
|
49
49
|
if (prop === "batch") {
|
|
50
|
-
return (stmts) => retryOnBusy(() => target.batch(stmts), "batch");
|
|
50
|
+
return (stmts, mode) => retryOnBusy(() => target.batch(stmts, mode), "batch");
|
|
51
51
|
}
|
|
52
52
|
return Reflect.get(target, prop, receiver);
|
|
53
53
|
}
|
|
@@ -63,6 +63,226 @@ var init_db_retry = __esm({
|
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
+
// src/lib/config.ts
|
|
67
|
+
import { readFile, writeFile, mkdir, chmod } from "fs/promises";
|
|
68
|
+
import { readFileSync, existsSync, renameSync } from "fs";
|
|
69
|
+
import path from "path";
|
|
70
|
+
import os from "os";
|
|
71
|
+
function resolveDataDir() {
|
|
72
|
+
if (process.env.EXE_OS_DIR) return process.env.EXE_OS_DIR;
|
|
73
|
+
if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
|
|
74
|
+
const newDir = path.join(os.homedir(), ".exe-os");
|
|
75
|
+
const legacyDir = path.join(os.homedir(), ".exe-mem");
|
|
76
|
+
if (!existsSync(newDir) && existsSync(legacyDir)) {
|
|
77
|
+
try {
|
|
78
|
+
renameSync(legacyDir, newDir);
|
|
79
|
+
process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
|
|
80
|
+
`);
|
|
81
|
+
} catch {
|
|
82
|
+
return legacyDir;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return newDir;
|
|
86
|
+
}
|
|
87
|
+
function migrateLegacyConfig(raw) {
|
|
88
|
+
if ("r2" in raw) {
|
|
89
|
+
process.stderr.write(
|
|
90
|
+
"[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"
|
|
91
|
+
);
|
|
92
|
+
delete raw.r2;
|
|
93
|
+
}
|
|
94
|
+
if ("syncIntervalMs" in raw) {
|
|
95
|
+
delete raw.syncIntervalMs;
|
|
96
|
+
}
|
|
97
|
+
return raw;
|
|
98
|
+
}
|
|
99
|
+
function migrateConfig(raw) {
|
|
100
|
+
const fromVersion = typeof raw.config_version === "number" ? raw.config_version : 0;
|
|
101
|
+
let currentVersion = fromVersion;
|
|
102
|
+
let migrated = false;
|
|
103
|
+
if (currentVersion > CURRENT_CONFIG_VERSION) {
|
|
104
|
+
return { config: raw, migrated: false, fromVersion };
|
|
105
|
+
}
|
|
106
|
+
for (const migration of CONFIG_MIGRATIONS) {
|
|
107
|
+
if (currentVersion === migration.from && migration.to <= CURRENT_CONFIG_VERSION) {
|
|
108
|
+
raw = migration.migrate(raw);
|
|
109
|
+
currentVersion = migration.to;
|
|
110
|
+
migrated = true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return { config: raw, migrated, fromVersion };
|
|
114
|
+
}
|
|
115
|
+
function normalizeScalingRoadmap(raw) {
|
|
116
|
+
const defaultAuto = DEFAULT_CONFIG.scalingRoadmap.rerankerAutoTrigger;
|
|
117
|
+
const userRoadmap = raw.scalingRoadmap ?? {};
|
|
118
|
+
const userAuto = userRoadmap.rerankerAutoTrigger ?? {};
|
|
119
|
+
if (userAuto.enabled === void 0 && raw.rerankerEnabled !== void 0) {
|
|
120
|
+
userAuto.enabled = raw.rerankerEnabled;
|
|
121
|
+
}
|
|
122
|
+
raw.scalingRoadmap = {
|
|
123
|
+
...userRoadmap,
|
|
124
|
+
rerankerAutoTrigger: { ...defaultAuto, ...userAuto }
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function normalizeSessionLifecycle(raw) {
|
|
128
|
+
const defaultSL = DEFAULT_CONFIG.sessionLifecycle;
|
|
129
|
+
const userSL = raw.sessionLifecycle ?? {};
|
|
130
|
+
raw.sessionLifecycle = { ...defaultSL, ...userSL };
|
|
131
|
+
}
|
|
132
|
+
function normalizeAutoUpdate(raw) {
|
|
133
|
+
const defaultAU = DEFAULT_CONFIG.autoUpdate;
|
|
134
|
+
const userAU = raw.autoUpdate ?? {};
|
|
135
|
+
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
136
|
+
}
|
|
137
|
+
async function loadConfig() {
|
|
138
|
+
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
139
|
+
await mkdir(dir, { recursive: true });
|
|
140
|
+
const configPath = path.join(dir, "config.json");
|
|
141
|
+
if (!existsSync(configPath)) {
|
|
142
|
+
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
143
|
+
}
|
|
144
|
+
const raw = await readFile(configPath, "utf-8");
|
|
145
|
+
try {
|
|
146
|
+
let parsed = JSON.parse(raw);
|
|
147
|
+
parsed = migrateLegacyConfig(parsed);
|
|
148
|
+
const { config: migratedCfg, migrated, fromVersion } = migrateConfig(parsed);
|
|
149
|
+
if (migrated) {
|
|
150
|
+
process.stderr.write(`[exe-os] Config migrated from v${fromVersion} to v${migratedCfg.config_version}
|
|
151
|
+
`);
|
|
152
|
+
try {
|
|
153
|
+
await writeFile(configPath, JSON.stringify(migratedCfg, null, 2) + "\n");
|
|
154
|
+
} catch {
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
normalizeScalingRoadmap(migratedCfg);
|
|
158
|
+
normalizeSessionLifecycle(migratedCfg);
|
|
159
|
+
normalizeAutoUpdate(migratedCfg);
|
|
160
|
+
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
161
|
+
if (config.dbPath.startsWith("~")) {
|
|
162
|
+
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
163
|
+
}
|
|
164
|
+
return config;
|
|
165
|
+
} catch {
|
|
166
|
+
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
var EXE_AI_DIR, DB_PATH, MODELS_DIR, CONFIG_PATH, LEGACY_LANCE_PATH, CURRENT_CONFIG_VERSION, DEFAULT_CONFIG, CONFIG_MIGRATIONS;
|
|
170
|
+
var init_config = __esm({
|
|
171
|
+
"src/lib/config.ts"() {
|
|
172
|
+
"use strict";
|
|
173
|
+
EXE_AI_DIR = resolveDataDir();
|
|
174
|
+
DB_PATH = path.join(EXE_AI_DIR, "memories.db");
|
|
175
|
+
MODELS_DIR = path.join(EXE_AI_DIR, "models");
|
|
176
|
+
CONFIG_PATH = path.join(EXE_AI_DIR, "config.json");
|
|
177
|
+
LEGACY_LANCE_PATH = path.join(EXE_AI_DIR, "local.lance");
|
|
178
|
+
CURRENT_CONFIG_VERSION = 1;
|
|
179
|
+
DEFAULT_CONFIG = {
|
|
180
|
+
config_version: CURRENT_CONFIG_VERSION,
|
|
181
|
+
dbPath: DB_PATH,
|
|
182
|
+
modelFile: "jina-embeddings-v5-small-q4_k_m.gguf",
|
|
183
|
+
embeddingDim: 1024,
|
|
184
|
+
batchSize: 20,
|
|
185
|
+
flushIntervalMs: 1e4,
|
|
186
|
+
autoIngestion: true,
|
|
187
|
+
autoRetrieval: true,
|
|
188
|
+
searchMode: "hybrid",
|
|
189
|
+
hookSearchMode: "hybrid",
|
|
190
|
+
fileGrepEnabled: true,
|
|
191
|
+
splashEffect: true,
|
|
192
|
+
consolidationEnabled: true,
|
|
193
|
+
consolidationIntervalMs: 6 * 60 * 60 * 1e3,
|
|
194
|
+
consolidationModel: "claude-haiku-4-5-20251001",
|
|
195
|
+
consolidationMaxCallsPerRun: 20,
|
|
196
|
+
selfQueryRouter: true,
|
|
197
|
+
selfQueryModel: "claude-haiku-4-5-20251001",
|
|
198
|
+
rerankerEnabled: true,
|
|
199
|
+
scalingRoadmap: {
|
|
200
|
+
rerankerAutoTrigger: {
|
|
201
|
+
enabled: true,
|
|
202
|
+
broadQueryMinCardinality: 5e4,
|
|
203
|
+
fetchTopK: 150,
|
|
204
|
+
returnTopK: 5
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
graphRagEnabled: true,
|
|
208
|
+
wikiEnabled: false,
|
|
209
|
+
wikiUrl: "",
|
|
210
|
+
wikiApiKey: "",
|
|
211
|
+
wikiSyncIntervalMs: 30 * 60 * 1e3,
|
|
212
|
+
wikiWorkspaceMapping: {},
|
|
213
|
+
wikiAutoUpdate: true,
|
|
214
|
+
wikiAutoUpdateThreshold: 0.5,
|
|
215
|
+
wikiAutoUpdateCreateNew: true,
|
|
216
|
+
skillLearning: true,
|
|
217
|
+
skillThreshold: 3,
|
|
218
|
+
skillModel: "claude-haiku-4-5-20251001",
|
|
219
|
+
exeHeartbeat: {
|
|
220
|
+
enabled: true,
|
|
221
|
+
intervalSeconds: 60,
|
|
222
|
+
staleInProgressThresholdHours: 2
|
|
223
|
+
},
|
|
224
|
+
sessionLifecycle: {
|
|
225
|
+
idleKillEnabled: true,
|
|
226
|
+
idleKillTicksRequired: 3,
|
|
227
|
+
idleKillIntercomAckWindowMs: 1e4,
|
|
228
|
+
maxAutoInstances: 10
|
|
229
|
+
},
|
|
230
|
+
autoUpdate: {
|
|
231
|
+
checkOnBoot: true,
|
|
232
|
+
autoInstall: false,
|
|
233
|
+
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
CONFIG_MIGRATIONS = [
|
|
237
|
+
{
|
|
238
|
+
from: 0,
|
|
239
|
+
to: 1,
|
|
240
|
+
migrate: (cfg) => {
|
|
241
|
+
cfg.config_version = 1;
|
|
242
|
+
return cfg;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
];
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
// src/lib/employees.ts
|
|
250
|
+
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
251
|
+
import { existsSync as existsSync2, symlinkSync, readlinkSync, readFileSync as readFileSync2, renameSync as renameSync2, unlinkSync, writeFileSync } from "fs";
|
|
252
|
+
import { execSync } from "child_process";
|
|
253
|
+
import path2 from "path";
|
|
254
|
+
import os2 from "os";
|
|
255
|
+
function normalizeRole(role) {
|
|
256
|
+
return (role ?? "").trim().toLowerCase();
|
|
257
|
+
}
|
|
258
|
+
function isCoordinatorRole(role) {
|
|
259
|
+
return normalizeRole(role) === normalizeRole(COORDINATOR_ROLE);
|
|
260
|
+
}
|
|
261
|
+
function getCoordinatorEmployee(employees) {
|
|
262
|
+
return employees.find((e) => isCoordinatorRole(e.role));
|
|
263
|
+
}
|
|
264
|
+
function getCoordinatorName(employees = loadEmployeesSync()) {
|
|
265
|
+
return getCoordinatorEmployee(employees)?.name ?? DEFAULT_COORDINATOR_TEMPLATE_NAME;
|
|
266
|
+
}
|
|
267
|
+
function loadEmployeesSync(employeesPath = EMPLOYEES_PATH) {
|
|
268
|
+
if (!existsSync2(employeesPath)) return [];
|
|
269
|
+
try {
|
|
270
|
+
return JSON.parse(readFileSync2(employeesPath, "utf-8"));
|
|
271
|
+
} catch {
|
|
272
|
+
return [];
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
var EMPLOYEES_PATH, DEFAULT_COORDINATOR_TEMPLATE_NAME, COORDINATOR_ROLE;
|
|
276
|
+
var init_employees = __esm({
|
|
277
|
+
"src/lib/employees.ts"() {
|
|
278
|
+
"use strict";
|
|
279
|
+
init_config();
|
|
280
|
+
EMPLOYEES_PATH = path2.join(EXE_AI_DIR, "exe-employees.json");
|
|
281
|
+
DEFAULT_COORDINATOR_TEMPLATE_NAME = "exe";
|
|
282
|
+
COORDINATOR_ROLE = "COO";
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
|
|
66
286
|
// src/lib/database.ts
|
|
67
287
|
import { createClient } from "@libsql/client";
|
|
68
288
|
async function initDatabase(config) {
|
|
@@ -196,22 +416,24 @@ async function ensureSchema() {
|
|
|
196
416
|
ON behaviors(agent_id, active);
|
|
197
417
|
`);
|
|
198
418
|
try {
|
|
419
|
+
const coordinatorName = getCoordinatorName();
|
|
199
420
|
const existing = await client.execute({
|
|
200
|
-
sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id =
|
|
201
|
-
args: []
|
|
421
|
+
sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id = ?",
|
|
422
|
+
args: [coordinatorName]
|
|
202
423
|
});
|
|
203
424
|
if (Number(existing.rows[0]?.cnt) === 0) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
425
|
+
const seededAt = "2026-03-25T00:00:00Z";
|
|
426
|
+
for (const [domain, content] of [
|
|
427
|
+
["workflow", `Don't ask "keep going?" \u2014 just keep executing phases/plans autonomously`],
|
|
428
|
+
["tool-use", "Always use create_task MCP tool, never write .md files directly for task creation"],
|
|
429
|
+
["workflow", "Auto-start reviewing when idle and reviews are pending \u2014 never ask founder for permission"]
|
|
430
|
+
]) {
|
|
431
|
+
await client.execute({
|
|
432
|
+
sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
|
|
433
|
+
VALUES (hex(randomblob(16)), ?, NULL, ?, ?, 1, ?, ?)`,
|
|
434
|
+
args: [coordinatorName, domain, content, seededAt, seededAt]
|
|
435
|
+
});
|
|
436
|
+
}
|
|
215
437
|
}
|
|
216
438
|
} catch {
|
|
217
439
|
}
|
|
@@ -903,6 +1125,39 @@ async function ensureSchema() {
|
|
|
903
1125
|
} catch {
|
|
904
1126
|
}
|
|
905
1127
|
}
|
|
1128
|
+
try {
|
|
1129
|
+
await client.execute({
|
|
1130
|
+
sql: `ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0`,
|
|
1131
|
+
args: []
|
|
1132
|
+
});
|
|
1133
|
+
} catch {
|
|
1134
|
+
}
|
|
1135
|
+
try {
|
|
1136
|
+
await client.execute(
|
|
1137
|
+
`CREATE INDEX IF NOT EXISTS idx_memories_draft ON memories(draft) WHERE draft = 1`
|
|
1138
|
+
);
|
|
1139
|
+
} catch {
|
|
1140
|
+
}
|
|
1141
|
+
try {
|
|
1142
|
+
await client.execute({
|
|
1143
|
+
sql: `ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'`,
|
|
1144
|
+
args: []
|
|
1145
|
+
});
|
|
1146
|
+
} catch {
|
|
1147
|
+
}
|
|
1148
|
+
try {
|
|
1149
|
+
await client.execute(
|
|
1150
|
+
`CREATE INDEX IF NOT EXISTS idx_memories_type ON memories(memory_type)`
|
|
1151
|
+
);
|
|
1152
|
+
} catch {
|
|
1153
|
+
}
|
|
1154
|
+
try {
|
|
1155
|
+
await client.execute({
|
|
1156
|
+
sql: `ALTER TABLE memories ADD COLUMN trajectory TEXT`,
|
|
1157
|
+
args: []
|
|
1158
|
+
});
|
|
1159
|
+
} catch {
|
|
1160
|
+
}
|
|
906
1161
|
}
|
|
907
1162
|
async function disposeDatabase() {
|
|
908
1163
|
if (_client) {
|
|
@@ -916,6 +1171,7 @@ var init_database = __esm({
|
|
|
916
1171
|
"src/lib/database.ts"() {
|
|
917
1172
|
"use strict";
|
|
918
1173
|
init_db_retry();
|
|
1174
|
+
init_employees();
|
|
919
1175
|
_client = null;
|
|
920
1176
|
_resilientClient = null;
|
|
921
1177
|
initTurso = initDatabase;
|
|
@@ -923,195 +1179,6 @@ var init_database = __esm({
|
|
|
923
1179
|
}
|
|
924
1180
|
});
|
|
925
1181
|
|
|
926
|
-
// src/lib/config.ts
|
|
927
|
-
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, chmod as chmod2 } from "fs/promises";
|
|
928
|
-
import { readFileSync, existsSync as existsSync2, renameSync } from "fs";
|
|
929
|
-
import path2 from "path";
|
|
930
|
-
import os2 from "os";
|
|
931
|
-
function resolveDataDir() {
|
|
932
|
-
if (process.env.EXE_OS_DIR) return process.env.EXE_OS_DIR;
|
|
933
|
-
if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
|
|
934
|
-
const newDir = path2.join(os2.homedir(), ".exe-os");
|
|
935
|
-
const legacyDir = path2.join(os2.homedir(), ".exe-mem");
|
|
936
|
-
if (!existsSync2(newDir) && existsSync2(legacyDir)) {
|
|
937
|
-
try {
|
|
938
|
-
renameSync(legacyDir, newDir);
|
|
939
|
-
process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
|
|
940
|
-
`);
|
|
941
|
-
} catch {
|
|
942
|
-
return legacyDir;
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
return newDir;
|
|
946
|
-
}
|
|
947
|
-
function migrateLegacyConfig(raw) {
|
|
948
|
-
if ("r2" in raw) {
|
|
949
|
-
process.stderr.write(
|
|
950
|
-
"[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"
|
|
951
|
-
);
|
|
952
|
-
delete raw.r2;
|
|
953
|
-
}
|
|
954
|
-
if ("syncIntervalMs" in raw) {
|
|
955
|
-
delete raw.syncIntervalMs;
|
|
956
|
-
}
|
|
957
|
-
return raw;
|
|
958
|
-
}
|
|
959
|
-
function migrateConfig(raw) {
|
|
960
|
-
const fromVersion = typeof raw.config_version === "number" ? raw.config_version : 0;
|
|
961
|
-
let currentVersion = fromVersion;
|
|
962
|
-
let migrated = false;
|
|
963
|
-
if (currentVersion > CURRENT_CONFIG_VERSION) {
|
|
964
|
-
return { config: raw, migrated: false, fromVersion };
|
|
965
|
-
}
|
|
966
|
-
for (const migration of CONFIG_MIGRATIONS) {
|
|
967
|
-
if (currentVersion === migration.from && migration.to <= CURRENT_CONFIG_VERSION) {
|
|
968
|
-
raw = migration.migrate(raw);
|
|
969
|
-
currentVersion = migration.to;
|
|
970
|
-
migrated = true;
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
return { config: raw, migrated, fromVersion };
|
|
974
|
-
}
|
|
975
|
-
function normalizeScalingRoadmap(raw) {
|
|
976
|
-
const defaultAuto = DEFAULT_CONFIG.scalingRoadmap.rerankerAutoTrigger;
|
|
977
|
-
const userRoadmap = raw.scalingRoadmap ?? {};
|
|
978
|
-
const userAuto = userRoadmap.rerankerAutoTrigger ?? {};
|
|
979
|
-
if (userAuto.enabled === void 0 && raw.rerankerEnabled !== void 0) {
|
|
980
|
-
userAuto.enabled = raw.rerankerEnabled;
|
|
981
|
-
}
|
|
982
|
-
raw.scalingRoadmap = {
|
|
983
|
-
...userRoadmap,
|
|
984
|
-
rerankerAutoTrigger: { ...defaultAuto, ...userAuto }
|
|
985
|
-
};
|
|
986
|
-
}
|
|
987
|
-
function normalizeSessionLifecycle(raw) {
|
|
988
|
-
const defaultSL = DEFAULT_CONFIG.sessionLifecycle;
|
|
989
|
-
const userSL = raw.sessionLifecycle ?? {};
|
|
990
|
-
raw.sessionLifecycle = { ...defaultSL, ...userSL };
|
|
991
|
-
}
|
|
992
|
-
function normalizeAutoUpdate(raw) {
|
|
993
|
-
const defaultAU = DEFAULT_CONFIG.autoUpdate;
|
|
994
|
-
const userAU = raw.autoUpdate ?? {};
|
|
995
|
-
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
996
|
-
}
|
|
997
|
-
async function loadConfig() {
|
|
998
|
-
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
999
|
-
await mkdir2(dir, { recursive: true });
|
|
1000
|
-
const configPath = path2.join(dir, "config.json");
|
|
1001
|
-
if (!existsSync2(configPath)) {
|
|
1002
|
-
return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
|
|
1003
|
-
}
|
|
1004
|
-
const raw = await readFile2(configPath, "utf-8");
|
|
1005
|
-
try {
|
|
1006
|
-
let parsed = JSON.parse(raw);
|
|
1007
|
-
parsed = migrateLegacyConfig(parsed);
|
|
1008
|
-
const { config: migratedCfg, migrated, fromVersion } = migrateConfig(parsed);
|
|
1009
|
-
if (migrated) {
|
|
1010
|
-
process.stderr.write(`[exe-os] Config migrated from v${fromVersion} to v${migratedCfg.config_version}
|
|
1011
|
-
`);
|
|
1012
|
-
try {
|
|
1013
|
-
await writeFile2(configPath, JSON.stringify(migratedCfg, null, 2) + "\n");
|
|
1014
|
-
} catch {
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
normalizeScalingRoadmap(migratedCfg);
|
|
1018
|
-
normalizeSessionLifecycle(migratedCfg);
|
|
1019
|
-
normalizeAutoUpdate(migratedCfg);
|
|
1020
|
-
const config = { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
|
|
1021
|
-
if (config.dbPath.startsWith("~")) {
|
|
1022
|
-
config.dbPath = config.dbPath.replace(/^~/, os2.homedir());
|
|
1023
|
-
}
|
|
1024
|
-
return config;
|
|
1025
|
-
} catch {
|
|
1026
|
-
return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
var EXE_AI_DIR, DB_PATH, MODELS_DIR, CONFIG_PATH, LEGACY_LANCE_PATH, CURRENT_CONFIG_VERSION, DEFAULT_CONFIG, CONFIG_MIGRATIONS;
|
|
1030
|
-
var init_config = __esm({
|
|
1031
|
-
"src/lib/config.ts"() {
|
|
1032
|
-
"use strict";
|
|
1033
|
-
EXE_AI_DIR = resolveDataDir();
|
|
1034
|
-
DB_PATH = path2.join(EXE_AI_DIR, "memories.db");
|
|
1035
|
-
MODELS_DIR = path2.join(EXE_AI_DIR, "models");
|
|
1036
|
-
CONFIG_PATH = path2.join(EXE_AI_DIR, "config.json");
|
|
1037
|
-
LEGACY_LANCE_PATH = path2.join(EXE_AI_DIR, "local.lance");
|
|
1038
|
-
CURRENT_CONFIG_VERSION = 1;
|
|
1039
|
-
DEFAULT_CONFIG = {
|
|
1040
|
-
config_version: CURRENT_CONFIG_VERSION,
|
|
1041
|
-
dbPath: DB_PATH,
|
|
1042
|
-
modelFile: "jina-embeddings-v5-small-q4_k_m.gguf",
|
|
1043
|
-
embeddingDim: 1024,
|
|
1044
|
-
batchSize: 20,
|
|
1045
|
-
flushIntervalMs: 1e4,
|
|
1046
|
-
autoIngestion: true,
|
|
1047
|
-
autoRetrieval: true,
|
|
1048
|
-
searchMode: "hybrid",
|
|
1049
|
-
hookSearchMode: "hybrid",
|
|
1050
|
-
fileGrepEnabled: true,
|
|
1051
|
-
splashEffect: true,
|
|
1052
|
-
consolidationEnabled: true,
|
|
1053
|
-
consolidationIntervalMs: 6 * 60 * 60 * 1e3,
|
|
1054
|
-
consolidationModel: "claude-haiku-4-5-20251001",
|
|
1055
|
-
consolidationMaxCallsPerRun: 20,
|
|
1056
|
-
selfQueryRouter: true,
|
|
1057
|
-
selfQueryModel: "claude-haiku-4-5-20251001",
|
|
1058
|
-
rerankerEnabled: true,
|
|
1059
|
-
scalingRoadmap: {
|
|
1060
|
-
rerankerAutoTrigger: {
|
|
1061
|
-
enabled: true,
|
|
1062
|
-
broadQueryMinCardinality: 5e4,
|
|
1063
|
-
fetchTopK: 150,
|
|
1064
|
-
returnTopK: 5
|
|
1065
|
-
}
|
|
1066
|
-
},
|
|
1067
|
-
graphRagEnabled: true,
|
|
1068
|
-
wikiEnabled: false,
|
|
1069
|
-
wikiUrl: "",
|
|
1070
|
-
wikiApiKey: "",
|
|
1071
|
-
wikiSyncIntervalMs: 30 * 60 * 1e3,
|
|
1072
|
-
wikiWorkspaceMapping: {
|
|
1073
|
-
exe: "Executive",
|
|
1074
|
-
yoshi: "Engineering",
|
|
1075
|
-
mari: "Marketing",
|
|
1076
|
-
tom: "Engineering",
|
|
1077
|
-
sasha: "Production"
|
|
1078
|
-
},
|
|
1079
|
-
wikiAutoUpdate: true,
|
|
1080
|
-
wikiAutoUpdateThreshold: 0.5,
|
|
1081
|
-
wikiAutoUpdateCreateNew: true,
|
|
1082
|
-
skillLearning: true,
|
|
1083
|
-
skillThreshold: 3,
|
|
1084
|
-
skillModel: "claude-haiku-4-5-20251001",
|
|
1085
|
-
exeHeartbeat: {
|
|
1086
|
-
enabled: true,
|
|
1087
|
-
intervalSeconds: 60,
|
|
1088
|
-
staleInProgressThresholdHours: 2
|
|
1089
|
-
},
|
|
1090
|
-
sessionLifecycle: {
|
|
1091
|
-
idleKillEnabled: true,
|
|
1092
|
-
idleKillTicksRequired: 3,
|
|
1093
|
-
idleKillIntercomAckWindowMs: 1e4,
|
|
1094
|
-
maxAutoInstances: 10
|
|
1095
|
-
},
|
|
1096
|
-
autoUpdate: {
|
|
1097
|
-
checkOnBoot: true,
|
|
1098
|
-
autoInstall: false,
|
|
1099
|
-
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
1100
|
-
}
|
|
1101
|
-
};
|
|
1102
|
-
CONFIG_MIGRATIONS = [
|
|
1103
|
-
{
|
|
1104
|
-
from: 0,
|
|
1105
|
-
to: 1,
|
|
1106
|
-
migrate: (cfg) => {
|
|
1107
|
-
cfg.config_version = 1;
|
|
1108
|
-
return cfg;
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
];
|
|
1112
|
-
}
|
|
1113
|
-
});
|
|
1114
|
-
|
|
1115
1182
|
// src/lib/shard-manager.ts
|
|
1116
1183
|
var shard_manager_exports = {};
|
|
1117
1184
|
__export(shard_manager_exports, {
|
|
@@ -1125,12 +1192,12 @@ __export(shard_manager_exports, {
|
|
|
1125
1192
|
listShards: () => listShards,
|
|
1126
1193
|
shardExists: () => shardExists
|
|
1127
1194
|
});
|
|
1128
|
-
import
|
|
1129
|
-
import { existsSync as
|
|
1195
|
+
import path4 from "path";
|
|
1196
|
+
import { existsSync as existsSync4, mkdirSync, readdirSync } from "fs";
|
|
1130
1197
|
import { createClient as createClient2 } from "@libsql/client";
|
|
1131
1198
|
function initShardManager(encryptionKey) {
|
|
1132
1199
|
_encryptionKey = encryptionKey;
|
|
1133
|
-
if (!
|
|
1200
|
+
if (!existsSync4(SHARDS_DIR)) {
|
|
1134
1201
|
mkdirSync(SHARDS_DIR, { recursive: true });
|
|
1135
1202
|
}
|
|
1136
1203
|
_shardingEnabled = true;
|
|
@@ -1151,7 +1218,7 @@ function getShardClient(projectName) {
|
|
|
1151
1218
|
}
|
|
1152
1219
|
const cached = _shards.get(safeName);
|
|
1153
1220
|
if (cached) return cached;
|
|
1154
|
-
const dbPath =
|
|
1221
|
+
const dbPath = path4.join(SHARDS_DIR, `${safeName}.db`);
|
|
1155
1222
|
const client = createClient2({
|
|
1156
1223
|
url: `file:${dbPath}`,
|
|
1157
1224
|
encryptionKey: _encryptionKey
|
|
@@ -1161,10 +1228,10 @@ function getShardClient(projectName) {
|
|
|
1161
1228
|
}
|
|
1162
1229
|
function shardExists(projectName) {
|
|
1163
1230
|
const safeName = projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1164
|
-
return
|
|
1231
|
+
return existsSync4(path4.join(SHARDS_DIR, `${safeName}.db`));
|
|
1165
1232
|
}
|
|
1166
1233
|
function listShards() {
|
|
1167
|
-
if (!
|
|
1234
|
+
if (!existsSync4(SHARDS_DIR)) return [];
|
|
1168
1235
|
return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
1169
1236
|
}
|
|
1170
1237
|
async function ensureShardSchema(client) {
|
|
@@ -1234,7 +1301,11 @@ async function ensureShardSchema(client) {
|
|
|
1234
1301
|
"ALTER TABLE memories ADD COLUMN source_path TEXT",
|
|
1235
1302
|
"ALTER TABLE memories ADD COLUMN source_type TEXT DEFAULT 'text'",
|
|
1236
1303
|
"ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3",
|
|
1237
|
-
"ALTER TABLE memories ADD COLUMN supersedes_id TEXT"
|
|
1304
|
+
"ALTER TABLE memories ADD COLUMN supersedes_id TEXT",
|
|
1305
|
+
// MS-11: draft staging, MS-6a: memory_type, MS-7: trajectory
|
|
1306
|
+
"ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0",
|
|
1307
|
+
"ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'",
|
|
1308
|
+
"ALTER TABLE memories ADD COLUMN trajectory TEXT"
|
|
1238
1309
|
]) {
|
|
1239
1310
|
try {
|
|
1240
1311
|
await client.execute(col);
|
|
@@ -1346,7 +1417,7 @@ var init_shard_manager = __esm({
|
|
|
1346
1417
|
"src/lib/shard-manager.ts"() {
|
|
1347
1418
|
"use strict";
|
|
1348
1419
|
init_config();
|
|
1349
|
-
SHARDS_DIR =
|
|
1420
|
+
SHARDS_DIR = path4.join(EXE_AI_DIR, "shards");
|
|
1350
1421
|
_shards = /* @__PURE__ */ new Map();
|
|
1351
1422
|
_encryptionKey = null;
|
|
1352
1423
|
_shardingEnabled = false;
|
|
@@ -1364,26 +1435,26 @@ var init_platform_procedures = __esm({
|
|
|
1364
1435
|
title: "What is exe-os \u2014 the operating model every agent must understand",
|
|
1365
1436
|
domain: "architecture",
|
|
1366
1437
|
priority: "p0",
|
|
1367
|
-
content: "Exe OS is an AI employee operating system. A founder runs 5-10 AI agents as a real org: COO
|
|
1438
|
+
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."
|
|
1368
1439
|
},
|
|
1369
1440
|
{
|
|
1370
1441
|
title: "Mode 1 \u2014 how exe-os runs inside Claude Code",
|
|
1371
1442
|
domain: "architecture",
|
|
1372
1443
|
priority: "p0",
|
|
1373
|
-
content: "Mode 1: exe-os runs AS hooks + MCP + skills inside Claude Code. The founder opens CC
|
|
1444
|
+
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."
|
|
1374
1445
|
},
|
|
1375
1446
|
{
|
|
1376
|
-
title: "Sessions explained \u2014
|
|
1447
|
+
title: "Sessions explained \u2014 coordinator session names and projects",
|
|
1377
1448
|
domain: "architecture",
|
|
1378
1449
|
priority: "p0",
|
|
1379
|
-
content: "Each
|
|
1450
|
+
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."
|
|
1380
1451
|
},
|
|
1381
1452
|
// --- Hierarchy and dispatch ---
|
|
1382
1453
|
{
|
|
1383
1454
|
title: "Chain of command \u2014 who talks to whom",
|
|
1384
1455
|
domain: "workflow",
|
|
1385
1456
|
priority: "p0",
|
|
1386
|
-
content: "Founder
|
|
1457
|
+
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."
|
|
1387
1458
|
},
|
|
1388
1459
|
{
|
|
1389
1460
|
title: "Single dispatch path \u2014 create_task only",
|
|
@@ -1393,30 +1464,30 @@ var init_platform_procedures = __esm({
|
|
|
1393
1464
|
},
|
|
1394
1465
|
// --- Session isolation ---
|
|
1395
1466
|
{
|
|
1396
|
-
title: "Session scoping \u2014 stay in your
|
|
1467
|
+
title: "Session scoping \u2014 stay in your coordinator boundary",
|
|
1397
1468
|
domain: "security",
|
|
1398
1469
|
priority: "p0",
|
|
1399
|
-
content: "Session scoping is mandatory. Managers dispatch to workers within their own
|
|
1470
|
+
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."
|
|
1400
1471
|
},
|
|
1401
1472
|
{
|
|
1402
1473
|
title: "Session isolation \u2014 never touch another session's work",
|
|
1403
1474
|
domain: "workflow",
|
|
1404
1475
|
priority: "p0",
|
|
1405
|
-
content:
|
|
1476
|
+
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."
|
|
1406
1477
|
},
|
|
1407
1478
|
// --- Engineering: session scoping in code ---
|
|
1408
1479
|
{
|
|
1409
1480
|
title: "Three-dimensional scoping \u2014 session, project, role \u2014 enforced in every query",
|
|
1410
1481
|
domain: "architecture",
|
|
1411
1482
|
priority: "p0",
|
|
1412
|
-
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
|
|
1483
|
+
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."
|
|
1413
1484
|
},
|
|
1414
1485
|
// --- Hard constraints ---
|
|
1415
1486
|
{
|
|
1416
1487
|
title: "What you CANNOT do in exe-os \u2014 hard constraints",
|
|
1417
1488
|
domain: "security",
|
|
1418
1489
|
priority: "p0",
|
|
1419
|
-
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
|
|
1490
|
+
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."
|
|
1420
1491
|
},
|
|
1421
1492
|
// --- Operations ---
|
|
1422
1493
|
{
|
|
@@ -1541,17 +1612,17 @@ var EMBEDDING_DIM = 1024;
|
|
|
1541
1612
|
init_database();
|
|
1542
1613
|
|
|
1543
1614
|
// src/lib/keychain.ts
|
|
1544
|
-
import { readFile, writeFile, unlink, mkdir, chmod } from "fs/promises";
|
|
1545
|
-
import { existsSync } from "fs";
|
|
1546
|
-
import
|
|
1547
|
-
import
|
|
1615
|
+
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
1616
|
+
import { existsSync as existsSync3 } from "fs";
|
|
1617
|
+
import path3 from "path";
|
|
1618
|
+
import os3 from "os";
|
|
1548
1619
|
var SERVICE = "exe-mem";
|
|
1549
1620
|
var ACCOUNT = "master-key";
|
|
1550
1621
|
function getKeyDir() {
|
|
1551
|
-
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ??
|
|
1622
|
+
return process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? path3.join(os3.homedir(), ".exe-os");
|
|
1552
1623
|
}
|
|
1553
1624
|
function getKeyPath() {
|
|
1554
|
-
return
|
|
1625
|
+
return path3.join(getKeyDir(), "master.key");
|
|
1555
1626
|
}
|
|
1556
1627
|
async function tryKeytar() {
|
|
1557
1628
|
try {
|
|
@@ -1572,11 +1643,11 @@ async function getMasterKey() {
|
|
|
1572
1643
|
}
|
|
1573
1644
|
}
|
|
1574
1645
|
const keyPath = getKeyPath();
|
|
1575
|
-
if (!
|
|
1646
|
+
if (!existsSync3(keyPath)) {
|
|
1576
1647
|
return null;
|
|
1577
1648
|
}
|
|
1578
1649
|
try {
|
|
1579
|
-
const content = await
|
|
1650
|
+
const content = await readFile3(keyPath, "utf-8");
|
|
1580
1651
|
return Buffer.from(content.trim(), "base64");
|
|
1581
1652
|
} catch {
|
|
1582
1653
|
return null;
|
|
@@ -1749,7 +1820,10 @@ async function writeMemory(record) {
|
|
|
1749
1820
|
source_path: record.source_path ?? null,
|
|
1750
1821
|
source_type: record.source_type ?? null,
|
|
1751
1822
|
tier: record.tier ?? classifyTier(record),
|
|
1752
|
-
supersedes_id: record.supersedes_id ?? null
|
|
1823
|
+
supersedes_id: record.supersedes_id ?? null,
|
|
1824
|
+
draft: record.draft ? 1 : 0,
|
|
1825
|
+
memory_type: record.memory_type ?? "raw",
|
|
1826
|
+
trajectory: record.trajectory ? JSON.stringify(record.trajectory) : null
|
|
1753
1827
|
};
|
|
1754
1828
|
_pendingRecords.push(dbRow);
|
|
1755
1829
|
orgBus.emit({
|
|
@@ -1804,6 +1878,9 @@ async function flushBatch() {
|
|
|
1804
1878
|
const sourceType = row.source_type ?? null;
|
|
1805
1879
|
const tier = row.tier ?? 3;
|
|
1806
1880
|
const supersedesId = row.supersedes_id ?? null;
|
|
1881
|
+
const draft = row.draft ? 1 : 0;
|
|
1882
|
+
const memoryType = row.memory_type ?? "raw";
|
|
1883
|
+
const trajectory = row.trajectory ?? null;
|
|
1807
1884
|
return {
|
|
1808
1885
|
sql: hasVector ? `INSERT OR IGNORE INTO memories
|
|
1809
1886
|
(id, agent_id, agent_role, session_id, timestamp,
|
|
@@ -1811,15 +1888,15 @@ async function flushBatch() {
|
|
|
1811
1888
|
has_error, raw_text, vector, version, task_id, importance, status,
|
|
1812
1889
|
confidence, last_accessed,
|
|
1813
1890
|
workspace_id, document_id, user_id, char_offset, page_number,
|
|
1814
|
-
source_path, source_type, tier, supersedes_id)
|
|
1815
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories
|
|
1891
|
+
source_path, source_type, tier, supersedes_id, draft, memory_type, trajectory)
|
|
1892
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories
|
|
1816
1893
|
(id, agent_id, agent_role, session_id, timestamp,
|
|
1817
1894
|
tool_name, project_name,
|
|
1818
1895
|
has_error, raw_text, vector, version, task_id, importance, status,
|
|
1819
1896
|
confidence, last_accessed,
|
|
1820
1897
|
workspace_id, document_id, user_id, char_offset, page_number,
|
|
1821
|
-
source_path, source_type, tier, supersedes_id)
|
|
1822
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
1898
|
+
source_path, source_type, tier, supersedes_id, draft, memory_type, trajectory)
|
|
1899
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
1823
1900
|
args: hasVector ? [
|
|
1824
1901
|
row.id,
|
|
1825
1902
|
row.agent_id,
|
|
@@ -1845,7 +1922,10 @@ async function flushBatch() {
|
|
|
1845
1922
|
sourcePath,
|
|
1846
1923
|
sourceType,
|
|
1847
1924
|
tier,
|
|
1848
|
-
supersedesId
|
|
1925
|
+
supersedesId,
|
|
1926
|
+
draft,
|
|
1927
|
+
memoryType,
|
|
1928
|
+
trajectory
|
|
1849
1929
|
] : [
|
|
1850
1930
|
row.id,
|
|
1851
1931
|
row.agent_id,
|
|
@@ -1870,7 +1950,10 @@ async function flushBatch() {
|
|
|
1870
1950
|
sourcePath,
|
|
1871
1951
|
sourceType,
|
|
1872
1952
|
tier,
|
|
1873
|
-
supersedesId
|
|
1953
|
+
supersedesId,
|
|
1954
|
+
draft,
|
|
1955
|
+
memoryType,
|
|
1956
|
+
trajectory
|
|
1874
1957
|
]
|
|
1875
1958
|
};
|
|
1876
1959
|
};
|
|
@@ -1939,6 +2022,8 @@ async function searchMemories(queryVector, agentId, options) {
|
|
|
1939
2022
|
const limit = options?.limit ?? 10;
|
|
1940
2023
|
const statusFilter = options?.includeArchived ? "" : `
|
|
1941
2024
|
AND COALESCE(status, 'active') = 'active'`;
|
|
2025
|
+
const draftFilter = options?.includeDrafts ? "" : `
|
|
2026
|
+
AND (draft = 0 OR draft IS NULL)`;
|
|
1942
2027
|
let sql = `SELECT id, agent_id, agent_role, session_id, timestamp,
|
|
1943
2028
|
tool_name, project_name,
|
|
1944
2029
|
has_error, raw_text, vector, importance, status,
|
|
@@ -1948,7 +2033,7 @@ async function searchMemories(queryVector, agentId, options) {
|
|
|
1948
2033
|
source_path, source_type
|
|
1949
2034
|
FROM memories
|
|
1950
2035
|
WHERE agent_id = ?
|
|
1951
|
-
AND vector IS NOT NULL${statusFilter}
|
|
2036
|
+
AND vector IS NOT NULL${statusFilter}${draftFilter}
|
|
1952
2037
|
AND COALESCE(confidence, 0.7) >= 0.3`;
|
|
1953
2038
|
const args = [agentId];
|
|
1954
2039
|
const scope = buildWikiScopeFilter(options, "");
|
|
@@ -1970,6 +2055,10 @@ async function searchMemories(queryVector, agentId, options) {
|
|
|
1970
2055
|
sql += ` AND timestamp >= ?`;
|
|
1971
2056
|
args.push(options.since);
|
|
1972
2057
|
}
|
|
2058
|
+
if (options?.memoryType) {
|
|
2059
|
+
sql += ` AND memory_type = ?`;
|
|
2060
|
+
args.push(options.memoryType);
|
|
2061
|
+
}
|
|
1973
2062
|
sql += ` ORDER BY vector_distance_cos(vector, vector32(?))`;
|
|
1974
2063
|
args.push(vectorToBlob(queryVector));
|
|
1975
2064
|
sql += ` LIMIT ?`;
|