@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/bin/git-sweep.js
CHANGED
|
@@ -357,7 +357,7 @@ function wrapWithRetry(client) {
|
|
|
357
357
|
return (sql) => retryOnBusy(() => target.execute(sql), "execute");
|
|
358
358
|
}
|
|
359
359
|
if (prop === "batch") {
|
|
360
|
-
return (stmts) => retryOnBusy(() => target.batch(stmts), "batch");
|
|
360
|
+
return (stmts, mode) => retryOnBusy(() => target.batch(stmts, mode), "batch");
|
|
361
361
|
}
|
|
362
362
|
return Reflect.get(target, prop, receiver);
|
|
363
363
|
}
|
|
@@ -373,6 +373,240 @@ var init_db_retry = __esm({
|
|
|
373
373
|
}
|
|
374
374
|
});
|
|
375
375
|
|
|
376
|
+
// src/lib/config.ts
|
|
377
|
+
import { readFile, writeFile, mkdir, chmod } from "fs/promises";
|
|
378
|
+
import { readFileSync as readFileSync3, existsSync as existsSync3, renameSync as renameSync2 } from "fs";
|
|
379
|
+
import path3 from "path";
|
|
380
|
+
import os3 from "os";
|
|
381
|
+
function resolveDataDir() {
|
|
382
|
+
if (process.env.EXE_OS_DIR) return process.env.EXE_OS_DIR;
|
|
383
|
+
if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
|
|
384
|
+
const newDir = path3.join(os3.homedir(), ".exe-os");
|
|
385
|
+
const legacyDir = path3.join(os3.homedir(), ".exe-mem");
|
|
386
|
+
if (!existsSync3(newDir) && existsSync3(legacyDir)) {
|
|
387
|
+
try {
|
|
388
|
+
renameSync2(legacyDir, newDir);
|
|
389
|
+
process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
|
|
390
|
+
`);
|
|
391
|
+
} catch {
|
|
392
|
+
return legacyDir;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
return newDir;
|
|
396
|
+
}
|
|
397
|
+
function migrateLegacyConfig(raw) {
|
|
398
|
+
if ("r2" in raw) {
|
|
399
|
+
process.stderr.write(
|
|
400
|
+
"[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"
|
|
401
|
+
);
|
|
402
|
+
delete raw.r2;
|
|
403
|
+
}
|
|
404
|
+
if ("syncIntervalMs" in raw) {
|
|
405
|
+
delete raw.syncIntervalMs;
|
|
406
|
+
}
|
|
407
|
+
return raw;
|
|
408
|
+
}
|
|
409
|
+
function migrateConfig(raw) {
|
|
410
|
+
const fromVersion = typeof raw.config_version === "number" ? raw.config_version : 0;
|
|
411
|
+
let currentVersion = fromVersion;
|
|
412
|
+
let migrated = false;
|
|
413
|
+
if (currentVersion > CURRENT_CONFIG_VERSION) {
|
|
414
|
+
return { config: raw, migrated: false, fromVersion };
|
|
415
|
+
}
|
|
416
|
+
for (const migration of CONFIG_MIGRATIONS) {
|
|
417
|
+
if (currentVersion === migration.from && migration.to <= CURRENT_CONFIG_VERSION) {
|
|
418
|
+
raw = migration.migrate(raw);
|
|
419
|
+
currentVersion = migration.to;
|
|
420
|
+
migrated = true;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return { config: raw, migrated, fromVersion };
|
|
424
|
+
}
|
|
425
|
+
function normalizeScalingRoadmap(raw) {
|
|
426
|
+
const defaultAuto = DEFAULT_CONFIG.scalingRoadmap.rerankerAutoTrigger;
|
|
427
|
+
const userRoadmap = raw.scalingRoadmap ?? {};
|
|
428
|
+
const userAuto = userRoadmap.rerankerAutoTrigger ?? {};
|
|
429
|
+
if (userAuto.enabled === void 0 && raw.rerankerEnabled !== void 0) {
|
|
430
|
+
userAuto.enabled = raw.rerankerEnabled;
|
|
431
|
+
}
|
|
432
|
+
raw.scalingRoadmap = {
|
|
433
|
+
...userRoadmap,
|
|
434
|
+
rerankerAutoTrigger: { ...defaultAuto, ...userAuto }
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
function normalizeSessionLifecycle(raw) {
|
|
438
|
+
const defaultSL = DEFAULT_CONFIG.sessionLifecycle;
|
|
439
|
+
const userSL = raw.sessionLifecycle ?? {};
|
|
440
|
+
raw.sessionLifecycle = { ...defaultSL, ...userSL };
|
|
441
|
+
}
|
|
442
|
+
function normalizeAutoUpdate(raw) {
|
|
443
|
+
const defaultAU = DEFAULT_CONFIG.autoUpdate;
|
|
444
|
+
const userAU = raw.autoUpdate ?? {};
|
|
445
|
+
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
446
|
+
}
|
|
447
|
+
async function loadConfig() {
|
|
448
|
+
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
449
|
+
await mkdir(dir, { recursive: true });
|
|
450
|
+
const configPath = path3.join(dir, "config.json");
|
|
451
|
+
if (!existsSync3(configPath)) {
|
|
452
|
+
return { ...DEFAULT_CONFIG, dbPath: path3.join(dir, "memories.db") };
|
|
453
|
+
}
|
|
454
|
+
const raw = await readFile(configPath, "utf-8");
|
|
455
|
+
try {
|
|
456
|
+
let parsed = JSON.parse(raw);
|
|
457
|
+
parsed = migrateLegacyConfig(parsed);
|
|
458
|
+
const { config: migratedCfg, migrated, fromVersion } = migrateConfig(parsed);
|
|
459
|
+
if (migrated) {
|
|
460
|
+
process.stderr.write(`[exe-os] Config migrated from v${fromVersion} to v${migratedCfg.config_version}
|
|
461
|
+
`);
|
|
462
|
+
try {
|
|
463
|
+
await writeFile(configPath, JSON.stringify(migratedCfg, null, 2) + "\n");
|
|
464
|
+
} catch {
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
normalizeScalingRoadmap(migratedCfg);
|
|
468
|
+
normalizeSessionLifecycle(migratedCfg);
|
|
469
|
+
normalizeAutoUpdate(migratedCfg);
|
|
470
|
+
const config = { ...DEFAULT_CONFIG, dbPath: path3.join(dir, "memories.db"), ...migratedCfg };
|
|
471
|
+
if (config.dbPath.startsWith("~")) {
|
|
472
|
+
config.dbPath = config.dbPath.replace(/^~/, os3.homedir());
|
|
473
|
+
}
|
|
474
|
+
return config;
|
|
475
|
+
} catch {
|
|
476
|
+
return { ...DEFAULT_CONFIG, dbPath: path3.join(dir, "memories.db") };
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
var EXE_AI_DIR, DB_PATH, MODELS_DIR, CONFIG_PATH, LEGACY_LANCE_PATH, CURRENT_CONFIG_VERSION, DEFAULT_CONFIG, CONFIG_MIGRATIONS;
|
|
480
|
+
var init_config = __esm({
|
|
481
|
+
"src/lib/config.ts"() {
|
|
482
|
+
"use strict";
|
|
483
|
+
EXE_AI_DIR = resolveDataDir();
|
|
484
|
+
DB_PATH = path3.join(EXE_AI_DIR, "memories.db");
|
|
485
|
+
MODELS_DIR = path3.join(EXE_AI_DIR, "models");
|
|
486
|
+
CONFIG_PATH = path3.join(EXE_AI_DIR, "config.json");
|
|
487
|
+
LEGACY_LANCE_PATH = path3.join(EXE_AI_DIR, "local.lance");
|
|
488
|
+
CURRENT_CONFIG_VERSION = 1;
|
|
489
|
+
DEFAULT_CONFIG = {
|
|
490
|
+
config_version: CURRENT_CONFIG_VERSION,
|
|
491
|
+
dbPath: DB_PATH,
|
|
492
|
+
modelFile: "jina-embeddings-v5-small-q4_k_m.gguf",
|
|
493
|
+
embeddingDim: 1024,
|
|
494
|
+
batchSize: 20,
|
|
495
|
+
flushIntervalMs: 1e4,
|
|
496
|
+
autoIngestion: true,
|
|
497
|
+
autoRetrieval: true,
|
|
498
|
+
searchMode: "hybrid",
|
|
499
|
+
hookSearchMode: "hybrid",
|
|
500
|
+
fileGrepEnabled: true,
|
|
501
|
+
splashEffect: true,
|
|
502
|
+
consolidationEnabled: true,
|
|
503
|
+
consolidationIntervalMs: 6 * 60 * 60 * 1e3,
|
|
504
|
+
consolidationModel: "claude-haiku-4-5-20251001",
|
|
505
|
+
consolidationMaxCallsPerRun: 20,
|
|
506
|
+
selfQueryRouter: true,
|
|
507
|
+
selfQueryModel: "claude-haiku-4-5-20251001",
|
|
508
|
+
rerankerEnabled: true,
|
|
509
|
+
scalingRoadmap: {
|
|
510
|
+
rerankerAutoTrigger: {
|
|
511
|
+
enabled: true,
|
|
512
|
+
broadQueryMinCardinality: 5e4,
|
|
513
|
+
fetchTopK: 150,
|
|
514
|
+
returnTopK: 5
|
|
515
|
+
}
|
|
516
|
+
},
|
|
517
|
+
graphRagEnabled: true,
|
|
518
|
+
wikiEnabled: false,
|
|
519
|
+
wikiUrl: "",
|
|
520
|
+
wikiApiKey: "",
|
|
521
|
+
wikiSyncIntervalMs: 30 * 60 * 1e3,
|
|
522
|
+
wikiWorkspaceMapping: {},
|
|
523
|
+
wikiAutoUpdate: true,
|
|
524
|
+
wikiAutoUpdateThreshold: 0.5,
|
|
525
|
+
wikiAutoUpdateCreateNew: true,
|
|
526
|
+
skillLearning: true,
|
|
527
|
+
skillThreshold: 3,
|
|
528
|
+
skillModel: "claude-haiku-4-5-20251001",
|
|
529
|
+
exeHeartbeat: {
|
|
530
|
+
enabled: true,
|
|
531
|
+
intervalSeconds: 60,
|
|
532
|
+
staleInProgressThresholdHours: 2
|
|
533
|
+
},
|
|
534
|
+
sessionLifecycle: {
|
|
535
|
+
idleKillEnabled: true,
|
|
536
|
+
idleKillTicksRequired: 3,
|
|
537
|
+
idleKillIntercomAckWindowMs: 1e4,
|
|
538
|
+
maxAutoInstances: 10
|
|
539
|
+
},
|
|
540
|
+
autoUpdate: {
|
|
541
|
+
checkOnBoot: true,
|
|
542
|
+
autoInstall: false,
|
|
543
|
+
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
CONFIG_MIGRATIONS = [
|
|
547
|
+
{
|
|
548
|
+
from: 0,
|
|
549
|
+
to: 1,
|
|
550
|
+
migrate: (cfg) => {
|
|
551
|
+
cfg.config_version = 1;
|
|
552
|
+
return cfg;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
];
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
// src/lib/employees.ts
|
|
560
|
+
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
561
|
+
import { existsSync as existsSync4, symlinkSync, readlinkSync, readFileSync as readFileSync4, renameSync as renameSync3, unlinkSync, writeFileSync as writeFileSync3 } from "fs";
|
|
562
|
+
import { execSync as execSync3 } from "child_process";
|
|
563
|
+
import path4 from "path";
|
|
564
|
+
import os4 from "os";
|
|
565
|
+
function normalizeRole(role) {
|
|
566
|
+
return (role ?? "").trim().toLowerCase();
|
|
567
|
+
}
|
|
568
|
+
function isCoordinatorRole(role) {
|
|
569
|
+
return normalizeRole(role) === normalizeRole(COORDINATOR_ROLE);
|
|
570
|
+
}
|
|
571
|
+
function getCoordinatorEmployee(employees) {
|
|
572
|
+
return employees.find((e) => isCoordinatorRole(e.role));
|
|
573
|
+
}
|
|
574
|
+
function getCoordinatorName(employees = loadEmployeesSync()) {
|
|
575
|
+
return getCoordinatorEmployee(employees)?.name ?? DEFAULT_COORDINATOR_TEMPLATE_NAME;
|
|
576
|
+
}
|
|
577
|
+
function isCoordinatorName(agentName, employees = loadEmployeesSync()) {
|
|
578
|
+
if (!agentName) return false;
|
|
579
|
+
return agentName.toLowerCase() === getCoordinatorName(employees).toLowerCase();
|
|
580
|
+
}
|
|
581
|
+
function loadEmployeesSync(employeesPath = EMPLOYEES_PATH) {
|
|
582
|
+
if (!existsSync4(employeesPath)) return [];
|
|
583
|
+
try {
|
|
584
|
+
return JSON.parse(readFileSync4(employeesPath, "utf-8"));
|
|
585
|
+
} catch {
|
|
586
|
+
return [];
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
function getEmployee(employees, name) {
|
|
590
|
+
return employees.find((e) => e.name.toLowerCase() === name.toLowerCase());
|
|
591
|
+
}
|
|
592
|
+
function isMultiInstance(agentName, employees) {
|
|
593
|
+
const roster = employees ?? loadEmployeesSync();
|
|
594
|
+
const emp = getEmployee(roster, agentName);
|
|
595
|
+
if (!emp) return false;
|
|
596
|
+
return MULTI_INSTANCE_ROLES.has(emp.role.toLowerCase());
|
|
597
|
+
}
|
|
598
|
+
var EMPLOYEES_PATH, DEFAULT_COORDINATOR_TEMPLATE_NAME, COORDINATOR_ROLE, MULTI_INSTANCE_ROLES;
|
|
599
|
+
var init_employees = __esm({
|
|
600
|
+
"src/lib/employees.ts"() {
|
|
601
|
+
"use strict";
|
|
602
|
+
init_config();
|
|
603
|
+
EMPLOYEES_PATH = path4.join(EXE_AI_DIR, "exe-employees.json");
|
|
604
|
+
DEFAULT_COORDINATOR_TEMPLATE_NAME = "exe";
|
|
605
|
+
COORDINATOR_ROLE = "COO";
|
|
606
|
+
MULTI_INSTANCE_ROLES = /* @__PURE__ */ new Set(["principal engineer", "content production specialist", "staff code reviewer"]);
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
|
|
376
610
|
// src/lib/database.ts
|
|
377
611
|
var database_exports = {};
|
|
378
612
|
__export(database_exports, {
|
|
@@ -520,22 +754,24 @@ async function ensureSchema() {
|
|
|
520
754
|
ON behaviors(agent_id, active);
|
|
521
755
|
`);
|
|
522
756
|
try {
|
|
757
|
+
const coordinatorName = getCoordinatorName();
|
|
523
758
|
const existing = await client.execute({
|
|
524
|
-
sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id =
|
|
525
|
-
args: []
|
|
759
|
+
sql: "SELECT COUNT(*) as cnt FROM behaviors WHERE agent_id = ?",
|
|
760
|
+
args: [coordinatorName]
|
|
526
761
|
});
|
|
527
762
|
if (Number(existing.rows[0]?.cnt) === 0) {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
763
|
+
const seededAt = "2026-03-25T00:00:00Z";
|
|
764
|
+
for (const [domain, content] of [
|
|
765
|
+
["workflow", `Don't ask "keep going?" \u2014 just keep executing phases/plans autonomously`],
|
|
766
|
+
["tool-use", "Always use create_task MCP tool, never write .md files directly for task creation"],
|
|
767
|
+
["workflow", "Auto-start reviewing when idle and reviews are pending \u2014 never ask founder for permission"]
|
|
768
|
+
]) {
|
|
769
|
+
await client.execute({
|
|
770
|
+
sql: `INSERT INTO behaviors (id, agent_id, project_name, domain, content, active, created_at, updated_at)
|
|
771
|
+
VALUES (hex(randomblob(16)), ?, NULL, ?, ?, 1, ?, ?)`,
|
|
772
|
+
args: [coordinatorName, domain, content, seededAt, seededAt]
|
|
773
|
+
});
|
|
774
|
+
}
|
|
539
775
|
}
|
|
540
776
|
} catch {
|
|
541
777
|
}
|
|
@@ -1208,264 +1444,76 @@ async function ensureSchema() {
|
|
|
1208
1444
|
try {
|
|
1209
1445
|
await client.execute({
|
|
1210
1446
|
sql: `ALTER TABLE memories ADD COLUMN supersedes_id TEXT`,
|
|
1211
|
-
args: []
|
|
1212
|
-
});
|
|
1213
|
-
} catch {
|
|
1214
|
-
}
|
|
1215
|
-
try {
|
|
1216
|
-
await client.execute(
|
|
1217
|
-
`CREATE INDEX IF NOT EXISTS idx_memories_supersedes ON memories(supersedes_id) WHERE supersedes_id IS NOT NULL`
|
|
1218
|
-
);
|
|
1219
|
-
} catch {
|
|
1220
|
-
}
|
|
1221
|
-
for (const col of [
|
|
1222
|
-
"ALTER TABLE tasks ADD COLUMN checkpoint TEXT",
|
|
1223
|
-
"ALTER TABLE tasks ADD COLUMN checkpoint_count INTEGER DEFAULT 0"
|
|
1224
|
-
]) {
|
|
1225
|
-
try {
|
|
1226
|
-
await client.execute(col);
|
|
1227
|
-
} catch {
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
async function disposeDatabase() {
|
|
1232
|
-
if (_client) {
|
|
1233
|
-
_client.close();
|
|
1234
|
-
_client = null;
|
|
1235
|
-
_resilientClient = null;
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
var _client, _resilientClient, initTurso, disposeTurso;
|
|
1239
|
-
var init_database = __esm({
|
|
1240
|
-
"src/lib/database.ts"() {
|
|
1241
|
-
"use strict";
|
|
1242
|
-
init_db_retry();
|
|
1243
|
-
_client = null;
|
|
1244
|
-
_resilientClient = null;
|
|
1245
|
-
initTurso = initDatabase;
|
|
1246
|
-
disposeTurso = disposeDatabase;
|
|
1247
|
-
}
|
|
1248
|
-
});
|
|
1249
|
-
|
|
1250
|
-
// src/lib/config.ts
|
|
1251
|
-
import { readFile, writeFile, mkdir, chmod } from "fs/promises";
|
|
1252
|
-
import { readFileSync as readFileSync3, existsSync as existsSync3, renameSync as renameSync2 } from "fs";
|
|
1253
|
-
import path3 from "path";
|
|
1254
|
-
import os3 from "os";
|
|
1255
|
-
function resolveDataDir() {
|
|
1256
|
-
if (process.env.EXE_OS_DIR) return process.env.EXE_OS_DIR;
|
|
1257
|
-
if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
|
|
1258
|
-
const newDir = path3.join(os3.homedir(), ".exe-os");
|
|
1259
|
-
const legacyDir = path3.join(os3.homedir(), ".exe-mem");
|
|
1260
|
-
if (!existsSync3(newDir) && existsSync3(legacyDir)) {
|
|
1261
|
-
try {
|
|
1262
|
-
renameSync2(legacyDir, newDir);
|
|
1263
|
-
process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
|
|
1264
|
-
`);
|
|
1265
|
-
} catch {
|
|
1266
|
-
return legacyDir;
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
return newDir;
|
|
1270
|
-
}
|
|
1271
|
-
function migrateLegacyConfig(raw) {
|
|
1272
|
-
if ("r2" in raw) {
|
|
1273
|
-
process.stderr.write(
|
|
1274
|
-
"[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"
|
|
1275
|
-
);
|
|
1276
|
-
delete raw.r2;
|
|
1277
|
-
}
|
|
1278
|
-
if ("syncIntervalMs" in raw) {
|
|
1279
|
-
delete raw.syncIntervalMs;
|
|
1280
|
-
}
|
|
1281
|
-
return raw;
|
|
1282
|
-
}
|
|
1283
|
-
function migrateConfig(raw) {
|
|
1284
|
-
const fromVersion = typeof raw.config_version === "number" ? raw.config_version : 0;
|
|
1285
|
-
let currentVersion = fromVersion;
|
|
1286
|
-
let migrated = false;
|
|
1287
|
-
if (currentVersion > CURRENT_CONFIG_VERSION) {
|
|
1288
|
-
return { config: raw, migrated: false, fromVersion };
|
|
1447
|
+
args: []
|
|
1448
|
+
});
|
|
1449
|
+
} catch {
|
|
1289
1450
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1451
|
+
try {
|
|
1452
|
+
await client.execute(
|
|
1453
|
+
`CREATE INDEX IF NOT EXISTS idx_memories_supersedes ON memories(supersedes_id) WHERE supersedes_id IS NOT NULL`
|
|
1454
|
+
);
|
|
1455
|
+
} catch {
|
|
1456
|
+
}
|
|
1457
|
+
for (const col of [
|
|
1458
|
+
"ALTER TABLE tasks ADD COLUMN checkpoint TEXT",
|
|
1459
|
+
"ALTER TABLE tasks ADD COLUMN checkpoint_count INTEGER DEFAULT 0"
|
|
1460
|
+
]) {
|
|
1461
|
+
try {
|
|
1462
|
+
await client.execute(col);
|
|
1463
|
+
} catch {
|
|
1295
1464
|
}
|
|
1296
1465
|
}
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
if (userAuto.enabled === void 0 && raw.rerankerEnabled !== void 0) {
|
|
1304
|
-
userAuto.enabled = raw.rerankerEnabled;
|
|
1466
|
+
try {
|
|
1467
|
+
await client.execute({
|
|
1468
|
+
sql: `ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0`,
|
|
1469
|
+
args: []
|
|
1470
|
+
});
|
|
1471
|
+
} catch {
|
|
1305
1472
|
}
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
}
|
|
1311
|
-
function normalizeSessionLifecycle(raw) {
|
|
1312
|
-
const defaultSL = DEFAULT_CONFIG.sessionLifecycle;
|
|
1313
|
-
const userSL = raw.sessionLifecycle ?? {};
|
|
1314
|
-
raw.sessionLifecycle = { ...defaultSL, ...userSL };
|
|
1315
|
-
}
|
|
1316
|
-
function normalizeAutoUpdate(raw) {
|
|
1317
|
-
const defaultAU = DEFAULT_CONFIG.autoUpdate;
|
|
1318
|
-
const userAU = raw.autoUpdate ?? {};
|
|
1319
|
-
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
1320
|
-
}
|
|
1321
|
-
async function loadConfig() {
|
|
1322
|
-
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
1323
|
-
await mkdir(dir, { recursive: true });
|
|
1324
|
-
const configPath = path3.join(dir, "config.json");
|
|
1325
|
-
if (!existsSync3(configPath)) {
|
|
1326
|
-
return { ...DEFAULT_CONFIG, dbPath: path3.join(dir, "memories.db") };
|
|
1473
|
+
try {
|
|
1474
|
+
await client.execute(
|
|
1475
|
+
`CREATE INDEX IF NOT EXISTS idx_memories_draft ON memories(draft) WHERE draft = 1`
|
|
1476
|
+
);
|
|
1477
|
+
} catch {
|
|
1327
1478
|
}
|
|
1328
|
-
const raw = await readFile(configPath, "utf-8");
|
|
1329
1479
|
try {
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
process.stderr.write(`[exe-os] Config migrated from v${fromVersion} to v${migratedCfg.config_version}
|
|
1335
|
-
`);
|
|
1336
|
-
try {
|
|
1337
|
-
await writeFile(configPath, JSON.stringify(migratedCfg, null, 2) + "\n");
|
|
1338
|
-
} catch {
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
normalizeScalingRoadmap(migratedCfg);
|
|
1342
|
-
normalizeSessionLifecycle(migratedCfg);
|
|
1343
|
-
normalizeAutoUpdate(migratedCfg);
|
|
1344
|
-
const config = { ...DEFAULT_CONFIG, dbPath: path3.join(dir, "memories.db"), ...migratedCfg };
|
|
1345
|
-
if (config.dbPath.startsWith("~")) {
|
|
1346
|
-
config.dbPath = config.dbPath.replace(/^~/, os3.homedir());
|
|
1347
|
-
}
|
|
1348
|
-
return config;
|
|
1480
|
+
await client.execute({
|
|
1481
|
+
sql: `ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'`,
|
|
1482
|
+
args: []
|
|
1483
|
+
});
|
|
1349
1484
|
} catch {
|
|
1350
|
-
return { ...DEFAULT_CONFIG, dbPath: path3.join(dir, "memories.db") };
|
|
1351
1485
|
}
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
EXE_AI_DIR = resolveDataDir();
|
|
1358
|
-
DB_PATH = path3.join(EXE_AI_DIR, "memories.db");
|
|
1359
|
-
MODELS_DIR = path3.join(EXE_AI_DIR, "models");
|
|
1360
|
-
CONFIG_PATH = path3.join(EXE_AI_DIR, "config.json");
|
|
1361
|
-
LEGACY_LANCE_PATH = path3.join(EXE_AI_DIR, "local.lance");
|
|
1362
|
-
CURRENT_CONFIG_VERSION = 1;
|
|
1363
|
-
DEFAULT_CONFIG = {
|
|
1364
|
-
config_version: CURRENT_CONFIG_VERSION,
|
|
1365
|
-
dbPath: DB_PATH,
|
|
1366
|
-
modelFile: "jina-embeddings-v5-small-q4_k_m.gguf",
|
|
1367
|
-
embeddingDim: 1024,
|
|
1368
|
-
batchSize: 20,
|
|
1369
|
-
flushIntervalMs: 1e4,
|
|
1370
|
-
autoIngestion: true,
|
|
1371
|
-
autoRetrieval: true,
|
|
1372
|
-
searchMode: "hybrid",
|
|
1373
|
-
hookSearchMode: "hybrid",
|
|
1374
|
-
fileGrepEnabled: true,
|
|
1375
|
-
splashEffect: true,
|
|
1376
|
-
consolidationEnabled: true,
|
|
1377
|
-
consolidationIntervalMs: 6 * 60 * 60 * 1e3,
|
|
1378
|
-
consolidationModel: "claude-haiku-4-5-20251001",
|
|
1379
|
-
consolidationMaxCallsPerRun: 20,
|
|
1380
|
-
selfQueryRouter: true,
|
|
1381
|
-
selfQueryModel: "claude-haiku-4-5-20251001",
|
|
1382
|
-
rerankerEnabled: true,
|
|
1383
|
-
scalingRoadmap: {
|
|
1384
|
-
rerankerAutoTrigger: {
|
|
1385
|
-
enabled: true,
|
|
1386
|
-
broadQueryMinCardinality: 5e4,
|
|
1387
|
-
fetchTopK: 150,
|
|
1388
|
-
returnTopK: 5
|
|
1389
|
-
}
|
|
1390
|
-
},
|
|
1391
|
-
graphRagEnabled: true,
|
|
1392
|
-
wikiEnabled: false,
|
|
1393
|
-
wikiUrl: "",
|
|
1394
|
-
wikiApiKey: "",
|
|
1395
|
-
wikiSyncIntervalMs: 30 * 60 * 1e3,
|
|
1396
|
-
wikiWorkspaceMapping: {
|
|
1397
|
-
exe: "Executive",
|
|
1398
|
-
yoshi: "Engineering",
|
|
1399
|
-
mari: "Marketing",
|
|
1400
|
-
tom: "Engineering",
|
|
1401
|
-
sasha: "Production"
|
|
1402
|
-
},
|
|
1403
|
-
wikiAutoUpdate: true,
|
|
1404
|
-
wikiAutoUpdateThreshold: 0.5,
|
|
1405
|
-
wikiAutoUpdateCreateNew: true,
|
|
1406
|
-
skillLearning: true,
|
|
1407
|
-
skillThreshold: 3,
|
|
1408
|
-
skillModel: "claude-haiku-4-5-20251001",
|
|
1409
|
-
exeHeartbeat: {
|
|
1410
|
-
enabled: true,
|
|
1411
|
-
intervalSeconds: 60,
|
|
1412
|
-
staleInProgressThresholdHours: 2
|
|
1413
|
-
},
|
|
1414
|
-
sessionLifecycle: {
|
|
1415
|
-
idleKillEnabled: true,
|
|
1416
|
-
idleKillTicksRequired: 3,
|
|
1417
|
-
idleKillIntercomAckWindowMs: 1e4,
|
|
1418
|
-
maxAutoInstances: 10
|
|
1419
|
-
},
|
|
1420
|
-
autoUpdate: {
|
|
1421
|
-
checkOnBoot: true,
|
|
1422
|
-
autoInstall: false,
|
|
1423
|
-
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
1424
|
-
}
|
|
1425
|
-
};
|
|
1426
|
-
CONFIG_MIGRATIONS = [
|
|
1427
|
-
{
|
|
1428
|
-
from: 0,
|
|
1429
|
-
to: 1,
|
|
1430
|
-
migrate: (cfg) => {
|
|
1431
|
-
cfg.config_version = 1;
|
|
1432
|
-
return cfg;
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
];
|
|
1486
|
+
try {
|
|
1487
|
+
await client.execute(
|
|
1488
|
+
`CREATE INDEX IF NOT EXISTS idx_memories_type ON memories(memory_type)`
|
|
1489
|
+
);
|
|
1490
|
+
} catch {
|
|
1436
1491
|
}
|
|
1437
|
-
});
|
|
1438
|
-
|
|
1439
|
-
// src/lib/employees.ts
|
|
1440
|
-
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
1441
|
-
import { existsSync as existsSync4, symlinkSync, readlinkSync, readFileSync as readFileSync4, renameSync as renameSync3, unlinkSync, writeFileSync as writeFileSync3 } from "fs";
|
|
1442
|
-
import { execSync as execSync3 } from "child_process";
|
|
1443
|
-
import path4 from "path";
|
|
1444
|
-
import os4 from "os";
|
|
1445
|
-
function loadEmployeesSync(employeesPath = EMPLOYEES_PATH) {
|
|
1446
|
-
if (!existsSync4(employeesPath)) return [];
|
|
1447
1492
|
try {
|
|
1448
|
-
|
|
1493
|
+
await client.execute({
|
|
1494
|
+
sql: `ALTER TABLE memories ADD COLUMN trajectory TEXT`,
|
|
1495
|
+
args: []
|
|
1496
|
+
});
|
|
1449
1497
|
} catch {
|
|
1450
|
-
return [];
|
|
1451
1498
|
}
|
|
1452
1499
|
}
|
|
1453
|
-
function
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
if (!emp) return false;
|
|
1460
|
-
return MULTI_INSTANCE_ROLES.has(emp.role.toLowerCase());
|
|
1500
|
+
async function disposeDatabase() {
|
|
1501
|
+
if (_client) {
|
|
1502
|
+
_client.close();
|
|
1503
|
+
_client = null;
|
|
1504
|
+
_resilientClient = null;
|
|
1505
|
+
}
|
|
1461
1506
|
}
|
|
1462
|
-
var
|
|
1463
|
-
var
|
|
1464
|
-
"src/lib/
|
|
1507
|
+
var _client, _resilientClient, initTurso, disposeTurso;
|
|
1508
|
+
var init_database = __esm({
|
|
1509
|
+
"src/lib/database.ts"() {
|
|
1465
1510
|
"use strict";
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1511
|
+
init_db_retry();
|
|
1512
|
+
init_employees();
|
|
1513
|
+
_client = null;
|
|
1514
|
+
_resilientClient = null;
|
|
1515
|
+
initTurso = initDatabase;
|
|
1516
|
+
disposeTurso = disposeDatabase;
|
|
1469
1517
|
}
|
|
1470
1518
|
});
|
|
1471
1519
|
|
|
@@ -1721,6 +1769,7 @@ __export(tasks_crud_exports, {
|
|
|
1721
1769
|
ensureArchitectureDoc: () => ensureArchitectureDoc,
|
|
1722
1770
|
ensureGitignoreExe: () => ensureGitignoreExe,
|
|
1723
1771
|
extractParentFromContext: () => extractParentFromContext,
|
|
1772
|
+
isTmuxSessionAlive: () => isTmuxSessionAlive,
|
|
1724
1773
|
listTasks: () => listTasks,
|
|
1725
1774
|
resolveTask: () => resolveTask,
|
|
1726
1775
|
slugify: () => slugify,
|
|
@@ -1971,6 +2020,36 @@ async function listTasks(input) {
|
|
|
1971
2020
|
tokensWarnedAt: r.tokens_warned_at !== null ? Number(r.tokens_warned_at) : null
|
|
1972
2021
|
}));
|
|
1973
2022
|
}
|
|
2023
|
+
function isTmuxSessionAlive(identifier) {
|
|
2024
|
+
if (!identifier || identifier === "unknown") return true;
|
|
2025
|
+
try {
|
|
2026
|
+
if (identifier.startsWith("%")) {
|
|
2027
|
+
const output = execSync4("tmux list-panes -a -F '#{pane_id}'", {
|
|
2028
|
+
timeout: 2e3,
|
|
2029
|
+
encoding: "utf8",
|
|
2030
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
2031
|
+
});
|
|
2032
|
+
return output.split("\n").some((l) => l.trim() === identifier);
|
|
2033
|
+
} else {
|
|
2034
|
+
execSync4(`tmux has-session -t ${JSON.stringify(identifier)}`, {
|
|
2035
|
+
timeout: 2e3,
|
|
2036
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
2037
|
+
});
|
|
2038
|
+
return true;
|
|
2039
|
+
}
|
|
2040
|
+
} catch {
|
|
2041
|
+
if (identifier.startsWith("%")) return true;
|
|
2042
|
+
try {
|
|
2043
|
+
execSync4("tmux list-sessions", {
|
|
2044
|
+
timeout: 2e3,
|
|
2045
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
2046
|
+
});
|
|
2047
|
+
return false;
|
|
2048
|
+
} catch {
|
|
2049
|
+
return true;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
1974
2053
|
function checkStaleCompletion(taskContext, taskCreatedAt) {
|
|
1975
2054
|
if (!taskContext) return null;
|
|
1976
2055
|
if (!DELEGATION_KEYWORDS.test(taskContext)) return null;
|
|
@@ -2033,13 +2112,59 @@ ${input.result}` : `\u26A0\uFE0F ${warning}`;
|
|
|
2033
2112
|
});
|
|
2034
2113
|
if (claim.rowsAffected === 0) {
|
|
2035
2114
|
const current = await client.execute({
|
|
2036
|
-
sql: "SELECT status, assigned_tmux FROM tasks WHERE id = ?",
|
|
2115
|
+
sql: "SELECT status, assigned_tmux, assigned_by FROM tasks WHERE id = ?",
|
|
2037
2116
|
args: [taskId]
|
|
2038
2117
|
});
|
|
2039
2118
|
const cur = current.rows[0];
|
|
2040
|
-
const
|
|
2041
|
-
const
|
|
2042
|
-
|
|
2119
|
+
const curStatus = cur?.status ?? "unknown";
|
|
2120
|
+
const claimedBySession = cur?.assigned_tmux ?? "";
|
|
2121
|
+
const assignedBy = cur?.assigned_by ?? "";
|
|
2122
|
+
if (curStatus === "in_progress" && claimedBySession && !isTmuxSessionAlive(claimedBySession)) {
|
|
2123
|
+
process.stderr.write(
|
|
2124
|
+
`[tasks] Auto-releasing dead claim on ${taskId} (was ${claimedBySession})
|
|
2125
|
+
`
|
|
2126
|
+
);
|
|
2127
|
+
await client.execute({
|
|
2128
|
+
sql: "UPDATE tasks SET status = 'open', assigned_tmux = NULL, updated_at = ? WHERE id = ?",
|
|
2129
|
+
args: [now, taskId]
|
|
2130
|
+
});
|
|
2131
|
+
const retried = await client.execute({
|
|
2132
|
+
sql: `UPDATE tasks SET status = 'in_progress', assigned_tmux = ?, updated_at = ? WHERE id = ? AND status = 'open'`,
|
|
2133
|
+
args: [tmuxSession, now, taskId]
|
|
2134
|
+
});
|
|
2135
|
+
if (retried.rowsAffected > 0) {
|
|
2136
|
+
try {
|
|
2137
|
+
await writeCheckpoint({
|
|
2138
|
+
taskId,
|
|
2139
|
+
step: "reclaimed_dead_session",
|
|
2140
|
+
contextSummary: `Task reclaimed after dead session ${claimedBySession} released.`
|
|
2141
|
+
});
|
|
2142
|
+
} catch {
|
|
2143
|
+
}
|
|
2144
|
+
return { row, taskFile, now, taskId };
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
if (curStatus === "in_progress" && input.callerAgentId && (input.callerAgentId === assignedBy || input.callerAgentId === "exe")) {
|
|
2148
|
+
process.stderr.write(
|
|
2149
|
+
`[tasks] Assigner override: ${input.callerAgentId} reclaiming ${taskId}
|
|
2150
|
+
`
|
|
2151
|
+
);
|
|
2152
|
+
await client.execute({
|
|
2153
|
+
sql: `UPDATE tasks SET status = 'in_progress', assigned_tmux = ?, updated_at = ? WHERE id = ?`,
|
|
2154
|
+
args: [tmuxSession, now, taskId]
|
|
2155
|
+
});
|
|
2156
|
+
try {
|
|
2157
|
+
await writeCheckpoint({
|
|
2158
|
+
taskId,
|
|
2159
|
+
step: "assigner_override",
|
|
2160
|
+
contextSummary: `Task force-reclaimed by assigner ${input.callerAgentId}.`
|
|
2161
|
+
});
|
|
2162
|
+
} catch {
|
|
2163
|
+
}
|
|
2164
|
+
return { row, taskFile, now, taskId };
|
|
2165
|
+
}
|
|
2166
|
+
const claimedBy = claimedBySession ? ` (claimed by ${claimedBySession})` : "";
|
|
2167
|
+
throw new Error(`${TASK_ALREADY_CLAIMED_PREFIX}: task ${taskId} is ${curStatus}${claimedBy}`);
|
|
2043
2168
|
}
|
|
2044
2169
|
try {
|
|
2045
2170
|
await writeCheckpoint({
|
|
@@ -2137,7 +2262,7 @@ var init_tasks_crud = __esm({
|
|
|
2137
2262
|
"use strict";
|
|
2138
2263
|
init_database();
|
|
2139
2264
|
init_task_scope();
|
|
2140
|
-
DELEGATION_KEYWORDS = /parallel|delegate|wave|
|
|
2265
|
+
DELEGATION_KEYWORDS = /parallel|delegate|wave|worktree|multi-instance/i;
|
|
2141
2266
|
TASK_ALREADY_CLAIMED_PREFIX = "TASK_ALREADY_CLAIMED";
|
|
2142
2267
|
}
|
|
2143
2268
|
});
|
|
@@ -2494,7 +2619,7 @@ function findSessionForProject(projectName2) {
|
|
|
2494
2619
|
const sessions = listSessions();
|
|
2495
2620
|
for (const s of sessions) {
|
|
2496
2621
|
const proj = s.projectDir.split("/").filter(Boolean).pop();
|
|
2497
|
-
if (proj === projectName2 && s.agentId === "exe") return s;
|
|
2622
|
+
if (proj === projectName2 && (s.agentId === "exe" || isCoordinatorName(s.agentId))) return s;
|
|
2498
2623
|
}
|
|
2499
2624
|
return null;
|
|
2500
2625
|
}
|
|
@@ -2534,12 +2659,13 @@ var init_session_scope = __esm({
|
|
|
2534
2659
|
init_session_registry();
|
|
2535
2660
|
init_project_name();
|
|
2536
2661
|
init_tmux_routing();
|
|
2662
|
+
init_employees();
|
|
2537
2663
|
}
|
|
2538
2664
|
});
|
|
2539
2665
|
|
|
2540
2666
|
// src/lib/tasks-notify.ts
|
|
2541
2667
|
async function dispatchTaskToEmployee(input) {
|
|
2542
|
-
if (input.assignedTo === "exe") return { dispatched: "skipped" };
|
|
2668
|
+
if (input.assignedTo === "exe" || isCoordinatorName(input.assignedTo)) return { dispatched: "skipped" };
|
|
2543
2669
|
let crossProject = false;
|
|
2544
2670
|
if (input.projectName) {
|
|
2545
2671
|
try {
|
|
@@ -2982,6 +3108,24 @@ async function updateTask(input) {
|
|
|
2982
3108
|
});
|
|
2983
3109
|
} catch {
|
|
2984
3110
|
}
|
|
3111
|
+
const assignedAgent = String(row.assigned_to);
|
|
3112
|
+
if (!isCoordinatorName(assignedAgent)) {
|
|
3113
|
+
try {
|
|
3114
|
+
const draftClient = getClient();
|
|
3115
|
+
if (input.status === "done") {
|
|
3116
|
+
await draftClient.execute({
|
|
3117
|
+
sql: `UPDATE memories SET draft = 0 WHERE agent_id = ? AND draft = 1`,
|
|
3118
|
+
args: [assignedAgent]
|
|
3119
|
+
});
|
|
3120
|
+
} else if (input.status === "cancelled") {
|
|
3121
|
+
await draftClient.execute({
|
|
3122
|
+
sql: `DELETE FROM memories WHERE agent_id = ? AND draft = 1`,
|
|
3123
|
+
args: [assignedAgent]
|
|
3124
|
+
});
|
|
3125
|
+
}
|
|
3126
|
+
} catch {
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
2985
3129
|
try {
|
|
2986
3130
|
const client = getClient();
|
|
2987
3131
|
const cascaded = await client.execute({
|
|
@@ -3000,8 +3144,8 @@ async function updateTask(input) {
|
|
|
3000
3144
|
}
|
|
3001
3145
|
const isTerminal = input.status === "done" || input.status === "needs_review";
|
|
3002
3146
|
if (isTerminal) {
|
|
3003
|
-
const
|
|
3004
|
-
if (!
|
|
3147
|
+
const isCoordinator = String(row.assigned_to) === "exe" || isCoordinatorName(String(row.assigned_to));
|
|
3148
|
+
if (!isCoordinator) {
|
|
3005
3149
|
notifyTaskDone();
|
|
3006
3150
|
}
|
|
3007
3151
|
await markTaskNotificationsRead(taskFile);
|
|
@@ -3025,7 +3169,7 @@ async function updateTask(input) {
|
|
|
3025
3169
|
}
|
|
3026
3170
|
}
|
|
3027
3171
|
}
|
|
3028
|
-
if (input.status === "done" && String(row.assigned_to) !== "exe" && !process.env.VITEST) {
|
|
3172
|
+
if (input.status === "done" && String(row.assigned_to) !== "exe" && !isCoordinatorName(String(row.assigned_to)) && !process.env.VITEST) {
|
|
3029
3173
|
Promise.resolve().then(() => (init_skill_learning(), skill_learning_exports)).then(
|
|
3030
3174
|
({ captureAndLearn: captureAndLearn2 }) => captureAndLearn2({
|
|
3031
3175
|
taskId,
|
|
@@ -3041,7 +3185,7 @@ async function updateTask(input) {
|
|
|
3041
3185
|
});
|
|
3042
3186
|
}
|
|
3043
3187
|
let nextTask;
|
|
3044
|
-
if (isTerminal && String(row.assigned_to) !== "exe") {
|
|
3188
|
+
if (isTerminal && String(row.assigned_to) !== "exe" && !isCoordinatorName(String(row.assigned_to))) {
|
|
3045
3189
|
try {
|
|
3046
3190
|
nextTask = await findNextTask(String(row.assigned_to));
|
|
3047
3191
|
} catch {
|
|
@@ -3068,12 +3212,14 @@ async function updateTask(input) {
|
|
|
3068
3212
|
async function deleteTask(taskId, baseDir) {
|
|
3069
3213
|
const client = getClient();
|
|
3070
3214
|
const { taskFile, assignedTo, assignedBy, taskSlug } = await deleteTaskCore(taskId, baseDir);
|
|
3071
|
-
const
|
|
3215
|
+
const coordinatorName = getCoordinatorName();
|
|
3216
|
+
const reviewer = assignedBy || coordinatorName;
|
|
3072
3217
|
const reviewSlug = `review-${assignedTo}-${taskSlug}`;
|
|
3073
3218
|
const reviewFile = `exe/${reviewer}/${reviewSlug}.md`;
|
|
3219
|
+
const legacyReviewFile = `exe/${coordinatorName}/${reviewSlug}.md`;
|
|
3074
3220
|
await client.execute({
|
|
3075
|
-
sql: "DELETE FROM tasks WHERE task_file = ? OR task_file = ?",
|
|
3076
|
-
args: [reviewFile, `exe/exe/${reviewSlug}.md`]
|
|
3221
|
+
sql: "DELETE FROM tasks WHERE task_file = ? OR task_file = ? OR task_file = ?",
|
|
3222
|
+
args: [reviewFile, legacyReviewFile, `exe/exe/${reviewSlug}.md`]
|
|
3077
3223
|
});
|
|
3078
3224
|
await markAsReadByTaskFile(taskFile);
|
|
3079
3225
|
await markAsReadByTaskFile(reviewFile);
|
|
@@ -3085,6 +3231,7 @@ var init_tasks = __esm({
|
|
|
3085
3231
|
init_config();
|
|
3086
3232
|
init_notifications();
|
|
3087
3233
|
init_state_bus();
|
|
3234
|
+
init_employees();
|
|
3088
3235
|
init_tasks_crud();
|
|
3089
3236
|
init_tasks_review();
|
|
3090
3237
|
init_tasks_crud();
|
|
@@ -3170,7 +3317,7 @@ function _resetLastRelaunchCache() {
|
|
|
3170
3317
|
}
|
|
3171
3318
|
async function lastResumeCreatedAtMs(agentId) {
|
|
3172
3319
|
const client = getClient();
|
|
3173
|
-
const cmScope = sessionScopeFilter();
|
|
3320
|
+
const cmScope = sessionScopeFilter(null);
|
|
3174
3321
|
const result = await client.execute({
|
|
3175
3322
|
sql: `SELECT MAX(created_at) AS last_created_at
|
|
3176
3323
|
FROM tasks
|
|
@@ -3195,7 +3342,7 @@ async function createOrRefreshResumeTask(agentId, projectDir, openTasks) {
|
|
|
3195
3342
|
const client = getClient();
|
|
3196
3343
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3197
3344
|
const context = buildResumeContext(agentId, openTasks);
|
|
3198
|
-
const rdScope = sessionScopeFilter();
|
|
3345
|
+
const rdScope = sessionScopeFilter(null);
|
|
3199
3346
|
const existing = await client.execute({
|
|
3200
3347
|
sql: `SELECT id FROM tasks
|
|
3201
3348
|
WHERE assigned_to = ?
|
|
@@ -3229,7 +3376,7 @@ async function pollCapacityDead() {
|
|
|
3229
3376
|
const transport = getTransport();
|
|
3230
3377
|
const relaunched = [];
|
|
3231
3378
|
const registered = listSessions().filter(
|
|
3232
|
-
(s) => s.agentId !== "exe"
|
|
3379
|
+
(s) => s.agentId !== "exe" && !isCoordinatorName(s.agentId)
|
|
3233
3380
|
);
|
|
3234
3381
|
if (registered.length === 0) return [];
|
|
3235
3382
|
let liveSessions;
|
|
@@ -3289,7 +3436,7 @@ async function pollCapacityDead() {
|
|
|
3289
3436
|
reason: "capacity"
|
|
3290
3437
|
});
|
|
3291
3438
|
const client = getClient();
|
|
3292
|
-
const rlScope = sessionScopeFilter();
|
|
3439
|
+
const rlScope = sessionScopeFilter(null);
|
|
3293
3440
|
const openTasks = await client.execute({
|
|
3294
3441
|
sql: `SELECT id, title, priority, task_file, status
|
|
3295
3442
|
FROM tasks
|
|
@@ -3343,6 +3490,7 @@ var init_capacity_monitor = __esm({
|
|
|
3343
3490
|
init_session_kill_telemetry();
|
|
3344
3491
|
init_tmux_routing();
|
|
3345
3492
|
init_task_scope();
|
|
3493
|
+
init_employees();
|
|
3346
3494
|
CAPACITY_PATTERNS = [
|
|
3347
3495
|
/conversation is too long/i,
|
|
3348
3496
|
/maximum context length/i,
|
|
@@ -3492,7 +3640,7 @@ function employeeSessionName(employee, exeSession, instance) {
|
|
|
3492
3640
|
exeSession = root;
|
|
3493
3641
|
} else {
|
|
3494
3642
|
throw new Error(
|
|
3495
|
-
`Invalid
|
|
3643
|
+
`Invalid coordinator session "${exeSession}" \u2014 contains a dash but no recognizable root session. Pass a root session name.`
|
|
3496
3644
|
);
|
|
3497
3645
|
}
|
|
3498
3646
|
}
|
|
@@ -3512,8 +3660,10 @@ function parseParentExe(sessionName, agentId) {
|
|
|
3512
3660
|
return match?.[1] ?? null;
|
|
3513
3661
|
}
|
|
3514
3662
|
function extractRootExe(name) {
|
|
3515
|
-
|
|
3516
|
-
|
|
3663
|
+
if (!name) return null;
|
|
3664
|
+
if (!name.includes("-")) return name;
|
|
3665
|
+
const parts = name.split("-").filter(Boolean);
|
|
3666
|
+
return parts.length > 0 ? parts[parts.length - 1] : null;
|
|
3517
3667
|
}
|
|
3518
3668
|
function registerParentExe(sessionKey, parentExe, dispatchedBy) {
|
|
3519
3669
|
if (!existsSync10(SESSION_CACHE)) {
|
|
@@ -3658,12 +3808,14 @@ function isSessionBusy(sessionName) {
|
|
|
3658
3808
|
return state === "thinking" || state === "tool";
|
|
3659
3809
|
}
|
|
3660
3810
|
function isExeSession(sessionName) {
|
|
3661
|
-
|
|
3811
|
+
const matchesBaseWithInstance = (baseName) => sessionName === baseName || sessionName.startsWith(baseName) && /^\d+$/.test(sessionName.slice(baseName.length));
|
|
3812
|
+
const coordinatorName = getCoordinatorName();
|
|
3813
|
+
return matchesBaseWithInstance(coordinatorName) || matchesBaseWithInstance("exe");
|
|
3662
3814
|
}
|
|
3663
3815
|
function sendIntercom(targetSession) {
|
|
3664
3816
|
const transport = getTransport();
|
|
3665
3817
|
if (isExeSession(targetSession)) {
|
|
3666
|
-
logIntercom(`
|
|
3818
|
+
logIntercom(`SKIP_COORDINATOR \u2192 ${targetSession} (coordinator sessions use prompt-submit hook)`);
|
|
3667
3819
|
return "skipped_exe";
|
|
3668
3820
|
}
|
|
3669
3821
|
if (isDebounced(targetSession)) {
|
|
@@ -3715,7 +3867,7 @@ function notifyParentExe(sessionKey) {
|
|
|
3715
3867
|
if (result === "failed") {
|
|
3716
3868
|
const rootExe = resolveExeSession();
|
|
3717
3869
|
if (rootExe && rootExe !== target) {
|
|
3718
|
-
process.stderr.write(`[intercom] notifyParentExe: dispatcher ${target} dead, falling back to root
|
|
3870
|
+
process.stderr.write(`[intercom] notifyParentExe: dispatcher ${target} dead, falling back to root coordinator session ${rootExe}
|
|
3719
3871
|
`);
|
|
3720
3872
|
const fallback = sendIntercom(rootExe);
|
|
3721
3873
|
return fallback !== "failed";
|
|
@@ -3725,8 +3877,8 @@ function notifyParentExe(sessionKey) {
|
|
|
3725
3877
|
return true;
|
|
3726
3878
|
}
|
|
3727
3879
|
function ensureEmployee(employeeName, exeSession, projectDir, opts) {
|
|
3728
|
-
if (employeeName === "exe") {
|
|
3729
|
-
return { status: "failed", sessionName: "", error: "
|
|
3880
|
+
if (employeeName === "exe" || isCoordinatorName(employeeName)) {
|
|
3881
|
+
return { status: "failed", sessionName: "", error: "The COO is not a dispatchable employee" };
|
|
3730
3882
|
}
|
|
3731
3883
|
try {
|
|
3732
3884
|
assertEmployeeLimitSync();
|
|
@@ -3735,8 +3887,8 @@ function ensureEmployee(employeeName, exeSession, projectDir, opts) {
|
|
|
3735
3887
|
return { status: "failed", sessionName: "", error: err.message };
|
|
3736
3888
|
}
|
|
3737
3889
|
}
|
|
3738
|
-
if (
|
|
3739
|
-
const bare = employeeName.
|
|
3890
|
+
if (employeeName.includes("-")) {
|
|
3891
|
+
const bare = employeeName.split("-")[0].replace(/\d+$/, "");
|
|
3740
3892
|
return {
|
|
3741
3893
|
status: "failed",
|
|
3742
3894
|
sessionName: "",
|
|
@@ -3755,7 +3907,7 @@ function ensureEmployee(employeeName, exeSession, projectDir, opts) {
|
|
|
3755
3907
|
return {
|
|
3756
3908
|
status: "failed",
|
|
3757
3909
|
sessionName: "",
|
|
3758
|
-
error: `Invalid
|
|
3910
|
+
error: `Invalid coordinator session "${exeSession}" \u2014 contains a dash but no recognizable root session. Pass a root session name.`
|
|
3759
3911
|
};
|
|
3760
3912
|
}
|
|
3761
3913
|
}
|
|
@@ -3912,8 +4064,8 @@ function spawnEmployee(employeeName, exeSession, projectDir, opts) {
|
|
|
3912
4064
|
const ctxContent = [
|
|
3913
4065
|
`## Session Context`,
|
|
3914
4066
|
`You are running in tmux session: ${sessionName}.`,
|
|
3915
|
-
`Your parent
|
|
3916
|
-
`Your employees (if any) use the -${exeSession} suffix
|
|
4067
|
+
`Your parent coordinator session is ${exeSession}.`,
|
|
4068
|
+
`Your employees (if any) use the -${exeSession} suffix.`
|
|
3917
4069
|
].join("\n");
|
|
3918
4070
|
writeFileSync6(ctxFile, ctxContent);
|
|
3919
4071
|
sessionContextFlag = ` --append-system-prompt-file ${ctxFile}`;
|
|
@@ -4017,6 +4169,7 @@ var init_tmux_routing = __esm({
|
|
|
4017
4169
|
init_provider_table();
|
|
4018
4170
|
init_intercom_queue();
|
|
4019
4171
|
init_plan_limits();
|
|
4172
|
+
init_employees();
|
|
4020
4173
|
SPAWN_LOCK_DIR = path13.join(os6.homedir(), ".exe-os", "spawn-locks");
|
|
4021
4174
|
SESSION_CACHE = path13.join(os6.homedir(), ".exe-os", "session-cache");
|
|
4022
4175
|
BEHAVIORS_EXPORT_TIMEOUT_MS = 1e4;
|
|
@@ -4234,7 +4387,11 @@ async function ensureShardSchema(client) {
|
|
|
4234
4387
|
"ALTER TABLE memories ADD COLUMN source_path TEXT",
|
|
4235
4388
|
"ALTER TABLE memories ADD COLUMN source_type TEXT DEFAULT 'text'",
|
|
4236
4389
|
"ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3",
|
|
4237
|
-
"ALTER TABLE memories ADD COLUMN supersedes_id TEXT"
|
|
4390
|
+
"ALTER TABLE memories ADD COLUMN supersedes_id TEXT",
|
|
4391
|
+
// MS-11: draft staging, MS-6a: memory_type, MS-7: trajectory
|
|
4392
|
+
"ALTER TABLE memories ADD COLUMN draft INTEGER DEFAULT 0",
|
|
4393
|
+
"ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'",
|
|
4394
|
+
"ALTER TABLE memories ADD COLUMN trajectory TEXT"
|
|
4238
4395
|
]) {
|
|
4239
4396
|
try {
|
|
4240
4397
|
await client.execute(col);
|
|
@@ -4364,26 +4521,26 @@ var init_platform_procedures = __esm({
|
|
|
4364
4521
|
title: "What is exe-os \u2014 the operating model every agent must understand",
|
|
4365
4522
|
domain: "architecture",
|
|
4366
4523
|
priority: "p0",
|
|
4367
|
-
content: "Exe OS is an AI employee operating system. A founder runs 5-10 AI agents as a real org: COO
|
|
4524
|
+
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."
|
|
4368
4525
|
},
|
|
4369
4526
|
{
|
|
4370
4527
|
title: "Mode 1 \u2014 how exe-os runs inside Claude Code",
|
|
4371
4528
|
domain: "architecture",
|
|
4372
4529
|
priority: "p0",
|
|
4373
|
-
content: "Mode 1: exe-os runs AS hooks + MCP + skills inside Claude Code. The founder opens CC
|
|
4530
|
+
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."
|
|
4374
4531
|
},
|
|
4375
4532
|
{
|
|
4376
|
-
title: "Sessions explained \u2014
|
|
4533
|
+
title: "Sessions explained \u2014 coordinator session names and projects",
|
|
4377
4534
|
domain: "architecture",
|
|
4378
4535
|
priority: "p0",
|
|
4379
|
-
content: "Each
|
|
4536
|
+
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."
|
|
4380
4537
|
},
|
|
4381
4538
|
// --- Hierarchy and dispatch ---
|
|
4382
4539
|
{
|
|
4383
4540
|
title: "Chain of command \u2014 who talks to whom",
|
|
4384
4541
|
domain: "workflow",
|
|
4385
4542
|
priority: "p0",
|
|
4386
|
-
content: "Founder
|
|
4543
|
+
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."
|
|
4387
4544
|
},
|
|
4388
4545
|
{
|
|
4389
4546
|
title: "Single dispatch path \u2014 create_task only",
|
|
@@ -4393,30 +4550,30 @@ var init_platform_procedures = __esm({
|
|
|
4393
4550
|
},
|
|
4394
4551
|
// --- Session isolation ---
|
|
4395
4552
|
{
|
|
4396
|
-
title: "Session scoping \u2014 stay in your
|
|
4553
|
+
title: "Session scoping \u2014 stay in your coordinator boundary",
|
|
4397
4554
|
domain: "security",
|
|
4398
4555
|
priority: "p0",
|
|
4399
|
-
content: "Session scoping is mandatory. Managers dispatch to workers within their own
|
|
4556
|
+
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."
|
|
4400
4557
|
},
|
|
4401
4558
|
{
|
|
4402
4559
|
title: "Session isolation \u2014 never touch another session's work",
|
|
4403
4560
|
domain: "workflow",
|
|
4404
4561
|
priority: "p0",
|
|
4405
|
-
content:
|
|
4562
|
+
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."
|
|
4406
4563
|
},
|
|
4407
4564
|
// --- Engineering: session scoping in code ---
|
|
4408
4565
|
{
|
|
4409
4566
|
title: "Three-dimensional scoping \u2014 session, project, role \u2014 enforced in every query",
|
|
4410
4567
|
domain: "architecture",
|
|
4411
4568
|
priority: "p0",
|
|
4412
|
-
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
|
|
4569
|
+
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."
|
|
4413
4570
|
},
|
|
4414
4571
|
// --- Hard constraints ---
|
|
4415
4572
|
{
|
|
4416
4573
|
title: "What you CANNOT do in exe-os \u2014 hard constraints",
|
|
4417
4574
|
domain: "security",
|
|
4418
4575
|
priority: "p0",
|
|
4419
|
-
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
|
|
4576
|
+
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."
|
|
4420
4577
|
},
|
|
4421
4578
|
// --- Operations ---
|
|
4422
4579
|
{
|
|
@@ -4656,7 +4813,10 @@ async function writeMemory(record) {
|
|
|
4656
4813
|
source_path: record.source_path ?? null,
|
|
4657
4814
|
source_type: record.source_type ?? null,
|
|
4658
4815
|
tier: record.tier ?? classifyTier(record),
|
|
4659
|
-
supersedes_id: record.supersedes_id ?? null
|
|
4816
|
+
supersedes_id: record.supersedes_id ?? null,
|
|
4817
|
+
draft: record.draft ? 1 : 0,
|
|
4818
|
+
memory_type: record.memory_type ?? "raw",
|
|
4819
|
+
trajectory: record.trajectory ? JSON.stringify(record.trajectory) : null
|
|
4660
4820
|
};
|
|
4661
4821
|
_pendingRecords.push(dbRow);
|
|
4662
4822
|
orgBus.emit({
|
|
@@ -4711,6 +4871,9 @@ async function flushBatch() {
|
|
|
4711
4871
|
const sourceType = row.source_type ?? null;
|
|
4712
4872
|
const tier = row.tier ?? 3;
|
|
4713
4873
|
const supersedesId = row.supersedes_id ?? null;
|
|
4874
|
+
const draft = row.draft ? 1 : 0;
|
|
4875
|
+
const memoryType = row.memory_type ?? "raw";
|
|
4876
|
+
const trajectory = row.trajectory ?? null;
|
|
4714
4877
|
return {
|
|
4715
4878
|
sql: hasVector ? `INSERT OR IGNORE INTO memories
|
|
4716
4879
|
(id, agent_id, agent_role, session_id, timestamp,
|
|
@@ -4718,15 +4881,15 @@ async function flushBatch() {
|
|
|
4718
4881
|
has_error, raw_text, vector, version, task_id, importance, status,
|
|
4719
4882
|
confidence, last_accessed,
|
|
4720
4883
|
workspace_id, document_id, user_id, char_offset, page_number,
|
|
4721
|
-
source_path, source_type, tier, supersedes_id)
|
|
4722
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories
|
|
4884
|
+
source_path, source_type, tier, supersedes_id, draft, memory_type, trajectory)
|
|
4885
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories
|
|
4723
4886
|
(id, agent_id, agent_role, session_id, timestamp,
|
|
4724
4887
|
tool_name, project_name,
|
|
4725
4888
|
has_error, raw_text, vector, version, task_id, importance, status,
|
|
4726
4889
|
confidence, last_accessed,
|
|
4727
4890
|
workspace_id, document_id, user_id, char_offset, page_number,
|
|
4728
|
-
source_path, source_type, tier, supersedes_id)
|
|
4729
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
4891
|
+
source_path, source_type, tier, supersedes_id, draft, memory_type, trajectory)
|
|
4892
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
4730
4893
|
args: hasVector ? [
|
|
4731
4894
|
row.id,
|
|
4732
4895
|
row.agent_id,
|
|
@@ -4752,7 +4915,10 @@ async function flushBatch() {
|
|
|
4752
4915
|
sourcePath,
|
|
4753
4916
|
sourceType,
|
|
4754
4917
|
tier,
|
|
4755
|
-
supersedesId
|
|
4918
|
+
supersedesId,
|
|
4919
|
+
draft,
|
|
4920
|
+
memoryType,
|
|
4921
|
+
trajectory
|
|
4756
4922
|
] : [
|
|
4757
4923
|
row.id,
|
|
4758
4924
|
row.agent_id,
|
|
@@ -4777,7 +4943,10 @@ async function flushBatch() {
|
|
|
4777
4943
|
sourcePath,
|
|
4778
4944
|
sourceType,
|
|
4779
4945
|
tier,
|
|
4780
|
-
supersedesId
|
|
4946
|
+
supersedesId,
|
|
4947
|
+
draft,
|
|
4948
|
+
memoryType,
|
|
4949
|
+
trajectory
|
|
4781
4950
|
]
|
|
4782
4951
|
};
|
|
4783
4952
|
};
|
|
@@ -4846,6 +5015,8 @@ async function searchMemories(queryVector, agentId, options) {
|
|
|
4846
5015
|
const limit = options?.limit ?? 10;
|
|
4847
5016
|
const statusFilter = options?.includeArchived ? "" : `
|
|
4848
5017
|
AND COALESCE(status, 'active') = 'active'`;
|
|
5018
|
+
const draftFilter = options?.includeDrafts ? "" : `
|
|
5019
|
+
AND (draft = 0 OR draft IS NULL)`;
|
|
4849
5020
|
let sql = `SELECT id, agent_id, agent_role, session_id, timestamp,
|
|
4850
5021
|
tool_name, project_name,
|
|
4851
5022
|
has_error, raw_text, vector, importance, status,
|
|
@@ -4855,7 +5026,7 @@ async function searchMemories(queryVector, agentId, options) {
|
|
|
4855
5026
|
source_path, source_type
|
|
4856
5027
|
FROM memories
|
|
4857
5028
|
WHERE agent_id = ?
|
|
4858
|
-
AND vector IS NOT NULL${statusFilter}
|
|
5029
|
+
AND vector IS NOT NULL${statusFilter}${draftFilter}
|
|
4859
5030
|
AND COALESCE(confidence, 0.7) >= 0.3`;
|
|
4860
5031
|
const args2 = [agentId];
|
|
4861
5032
|
const scope = buildWikiScopeFilter(options, "");
|
|
@@ -4877,6 +5048,10 @@ async function searchMemories(queryVector, agentId, options) {
|
|
|
4877
5048
|
sql += ` AND timestamp >= ?`;
|
|
4878
5049
|
args2.push(options.since);
|
|
4879
5050
|
}
|
|
5051
|
+
if (options?.memoryType) {
|
|
5052
|
+
sql += ` AND memory_type = ?`;
|
|
5053
|
+
args2.push(options.memoryType);
|
|
5054
|
+
}
|
|
4880
5055
|
sql += ` ORDER BY vector_distance_cos(vector, vector32(?))`;
|
|
4881
5056
|
args2.push(vectorToBlob(queryVector));
|
|
4882
5057
|
sql += ` LIMIT ?`;
|