@askexenow/exe-os 0.9.65 → 0.9.67

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.
Files changed (113) hide show
  1. package/deploy/stack-manifests/v0.9.json +54 -5
  2. package/dist/bin/age-ontology-load.js +61 -0
  3. package/dist/bin/agentic-ontology-backfill.js +4708 -0
  4. package/dist/bin/agentic-reflection-backfill.js +4144 -0
  5. package/dist/bin/{exe-link.js → agentic-semantic-label.js} +1532 -2173
  6. package/dist/bin/backfill-conversations.js +528 -20
  7. package/dist/bin/backfill-responses.js +528 -20
  8. package/dist/bin/backfill-vectors.js +255 -20
  9. package/dist/bin/bulk-sync-postgres.js +4876 -0
  10. package/dist/bin/cleanup-stale-review-tasks.js +529 -21
  11. package/dist/bin/cli.js +3471 -1491
  12. package/dist/bin/exe-agent-config.js +4 -0
  13. package/dist/bin/exe-agent.js +16 -0
  14. package/dist/bin/exe-assign.js +528 -20
  15. package/dist/bin/exe-boot.js +492 -54
  16. package/dist/bin/exe-call.js +16 -0
  17. package/dist/bin/exe-cloud.js +7415 -518
  18. package/dist/bin/exe-dispatch.js +540 -22
  19. package/dist/bin/exe-doctor.js +3404 -1225
  20. package/dist/bin/exe-export-behaviors.js +542 -24
  21. package/dist/bin/exe-forget.js +529 -21
  22. package/dist/bin/exe-gateway.js +595 -25
  23. package/dist/bin/exe-heartbeat.js +541 -24
  24. package/dist/bin/exe-kill.js +529 -21
  25. package/dist/bin/exe-launch-agent.js +2334 -1067
  26. package/dist/bin/exe-new-employee.js +324 -166
  27. package/dist/bin/exe-pending-messages.js +529 -21
  28. package/dist/bin/exe-pending-notifications.js +529 -21
  29. package/dist/bin/exe-pending-reviews.js +529 -21
  30. package/dist/bin/exe-rename.js +529 -21
  31. package/dist/bin/exe-review.js +529 -21
  32. package/dist/bin/exe-search.js +542 -24
  33. package/dist/bin/exe-session-cleanup.js +540 -22
  34. package/dist/bin/exe-settings.js +14 -0
  35. package/dist/bin/exe-start-codex.js +817 -144
  36. package/dist/bin/exe-start-opencode.js +776 -80
  37. package/dist/bin/exe-status.js +529 -21
  38. package/dist/bin/exe-team.js +529 -21
  39. package/dist/bin/git-sweep.js +540 -22
  40. package/dist/bin/graph-backfill.js +580 -21
  41. package/dist/bin/graph-export.js +529 -21
  42. package/dist/bin/graph-layer-benchmark.js +109 -0
  43. package/dist/bin/install.js +420 -289
  44. package/dist/bin/intercom-check.js +540 -22
  45. package/dist/bin/postgres-agentic-reflection-backfill.js +187 -0
  46. package/dist/bin/postgres-agentic-semantic-backfill.js +237 -0
  47. package/dist/bin/scan-tasks.js +540 -22
  48. package/dist/bin/setup.js +790 -206
  49. package/dist/bin/shard-migrate.js +528 -20
  50. package/dist/bin/update.js +4 -0
  51. package/dist/gateway/index.js +593 -23
  52. package/dist/hooks/bug-report-worker.js +651 -64
  53. package/dist/hooks/codex-stop-task-finalizer.js +540 -22
  54. package/dist/hooks/commit-complete.js +540 -22
  55. package/dist/hooks/error-recall.js +542 -24
  56. package/dist/hooks/exe-heartbeat-hook.js +4 -0
  57. package/dist/hooks/ingest-worker.js +4 -0
  58. package/dist/hooks/ingest.js +539 -22
  59. package/dist/hooks/instructions-loaded.js +529 -21
  60. package/dist/hooks/notification.js +529 -21
  61. package/dist/hooks/post-compact.js +529 -21
  62. package/dist/hooks/post-tool-combined.js +543 -25
  63. package/dist/hooks/pre-compact.js +772 -127
  64. package/dist/hooks/pre-tool-use.js +529 -21
  65. package/dist/hooks/prompt-submit.js +543 -25
  66. package/dist/hooks/session-end.js +673 -140
  67. package/dist/hooks/session-start.js +662 -26
  68. package/dist/hooks/stop.js +540 -23
  69. package/dist/hooks/subagent-stop.js +529 -21
  70. package/dist/hooks/summary-worker.js +571 -126
  71. package/dist/index.js +593 -23
  72. package/dist/lib/agent-config.js +4 -0
  73. package/dist/lib/cloud-sync.js +408 -47
  74. package/dist/lib/config.js +25 -1
  75. package/dist/lib/consolidation.js +5 -1
  76. package/dist/lib/database.js +128 -0
  77. package/dist/lib/db-daemon-client.js +4 -0
  78. package/dist/lib/db.js +128 -0
  79. package/dist/lib/device-registry.js +128 -0
  80. package/dist/lib/embedder.js +25 -1
  81. package/dist/lib/employee-templates.js +16 -0
  82. package/dist/lib/employees.js +4 -0
  83. package/dist/lib/exe-daemon-client.js +4 -0
  84. package/dist/lib/exe-daemon.js +3158 -930
  85. package/dist/lib/hybrid-search.js +542 -24
  86. package/dist/lib/identity.js +7 -0
  87. package/dist/lib/keychain.js +178 -22
  88. package/dist/lib/license.js +4 -0
  89. package/dist/lib/messaging.js +7 -0
  90. package/dist/lib/reminders.js +7 -0
  91. package/dist/lib/schedules.js +255 -20
  92. package/dist/lib/skill-learning.js +28 -1
  93. package/dist/lib/status-brief.js +39 -0
  94. package/dist/lib/store.js +528 -20
  95. package/dist/lib/task-router.js +4 -0
  96. package/dist/lib/tasks.js +28 -1
  97. package/dist/lib/tmux-routing.js +28 -1
  98. package/dist/lib/token-spend.js +7 -0
  99. package/dist/mcp/server.js +2739 -813
  100. package/dist/mcp/tools/complete-reminder.js +7 -0
  101. package/dist/mcp/tools/create-reminder.js +7 -0
  102. package/dist/mcp/tools/create-task.js +28 -1
  103. package/dist/mcp/tools/deactivate-behavior.js +7 -0
  104. package/dist/mcp/tools/list-reminders.js +7 -0
  105. package/dist/mcp/tools/list-tasks.js +7 -0
  106. package/dist/mcp/tools/send-message.js +7 -0
  107. package/dist/mcp/tools/update-task.js +28 -1
  108. package/dist/runtime/index.js +540 -22
  109. package/dist/tui/App.js +618 -29
  110. package/package.json +9 -5
  111. package/src/commands/exe/cloud.md +11 -8
  112. package/stack.release.json +3 -3
  113. package/src/commands/exe/link.md +0 -17
@@ -516,6 +516,11 @@ function normalizeAutoUpdate(raw) {
516
516
  const userAU = raw.autoUpdate ?? {};
517
517
  raw.autoUpdate = { ...defaultAU, ...userAU };
518
518
  }
519
+ function normalizeOrchestration(raw) {
520
+ const defaultOrg = DEFAULT_CONFIG.orchestration;
521
+ const userOrg = raw.orchestration ?? {};
522
+ raw.orchestration = { ...defaultOrg, ...userOrg };
523
+ }
519
524
  async function loadConfig() {
520
525
  const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
521
526
  await ensurePrivateDir(dir);
@@ -540,10 +545,15 @@ async function loadConfig() {
540
545
  normalizeScalingRoadmap(migratedCfg);
541
546
  normalizeSessionLifecycle(migratedCfg);
542
547
  normalizeAutoUpdate(migratedCfg);
548
+ normalizeOrchestration(migratedCfg);
543
549
  const config2 = { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
544
550
  if (config2.dbPath.startsWith("~")) {
545
551
  config2.dbPath = config2.dbPath.replace(/^~/, os2.homedir());
546
552
  }
553
+ const envDbPath = path2.join(dir, "memories.db");
554
+ if (process.env.EXE_OS_DIR && config2.dbPath !== envDbPath && !existsSync2(config2.dbPath) && existsSync2(envDbPath)) {
555
+ config2.dbPath = envDbPath;
556
+ }
547
557
  return config2;
548
558
  } catch {
549
559
  return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
@@ -563,7 +573,16 @@ function loadConfigSync() {
563
573
  normalizeScalingRoadmap(migratedCfg);
564
574
  normalizeSessionLifecycle(migratedCfg);
565
575
  normalizeAutoUpdate(migratedCfg);
566
- return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
576
+ normalizeOrchestration(migratedCfg);
577
+ const config2 = { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
578
+ if (config2.dbPath.startsWith("~")) {
579
+ config2.dbPath = config2.dbPath.replace(/^~/, os2.homedir());
580
+ }
581
+ const envDbPath = path2.join(dir, "memories.db");
582
+ if (process.env.EXE_OS_DIR && config2.dbPath !== envDbPath && !existsSync2(config2.dbPath) && existsSync2(envDbPath)) {
583
+ config2.dbPath = envDbPath;
584
+ }
585
+ return config2;
567
586
  } catch {
568
587
  return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
569
588
  }
@@ -584,6 +603,7 @@ async function loadConfigFrom(configPath) {
584
603
  normalizeScalingRoadmap(migratedCfg);
585
604
  normalizeSessionLifecycle(migratedCfg);
586
605
  normalizeAutoUpdate(migratedCfg);
606
+ normalizeOrchestration(migratedCfg);
587
607
  return { ...DEFAULT_CONFIG, ...migratedCfg };
588
608
  } catch {
589
609
  return { ...DEFAULT_CONFIG };
@@ -655,6 +675,10 @@ var init_config = __esm({
655
675
  checkOnBoot: true,
656
676
  autoInstall: false,
657
677
  checkIntervalMs: 24 * 60 * 60 * 1e3
678
+ },
679
+ orchestration: {
680
+ phase: "phase_1_coo",
681
+ phaseSetBy: "default"
658
682
  }
659
683
  };
660
684
  CONFIG_MIGRATIONS = [
@@ -2380,6 +2404,9 @@ function getClient() {
2380
2404
  if (_daemonClient && _daemonClient._isDaemonActive()) {
2381
2405
  return _daemonClient;
2382
2406
  }
2407
+ if (!_resilientClient) {
2408
+ return _adapterClient;
2409
+ }
2383
2410
  return _resilientClient;
2384
2411
  }
2385
2412
  async function initDaemonClient() {
@@ -3412,6 +3439,127 @@ async function ensureSchema() {
3412
3439
  VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
3413
3440
  END;
3414
3441
  `);
3442
+ await client.executeMultiple(`
3443
+ CREATE TABLE IF NOT EXISTS agent_sessions (
3444
+ id TEXT PRIMARY KEY,
3445
+ agent_id TEXT NOT NULL,
3446
+ project_name TEXT,
3447
+ started_at TEXT NOT NULL,
3448
+ last_event_at TEXT NOT NULL,
3449
+ event_count INTEGER NOT NULL DEFAULT 0,
3450
+ properties TEXT DEFAULT '{}'
3451
+ );
3452
+
3453
+ CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
3454
+ ON agent_sessions(agent_id, started_at);
3455
+
3456
+ CREATE TABLE IF NOT EXISTS agent_goals (
3457
+ id TEXT PRIMARY KEY,
3458
+ statement TEXT NOT NULL,
3459
+ owner_agent_id TEXT,
3460
+ project_name TEXT,
3461
+ status TEXT NOT NULL DEFAULT 'open',
3462
+ priority INTEGER NOT NULL DEFAULT 5,
3463
+ success_criteria TEXT,
3464
+ parent_goal_id TEXT,
3465
+ due_at TEXT,
3466
+ achieved_at TEXT,
3467
+ supersedes_id TEXT,
3468
+ created_at TEXT NOT NULL,
3469
+ updated_at TEXT NOT NULL,
3470
+ source_memory_id TEXT
3471
+ );
3472
+
3473
+ CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
3474
+ ON agent_goals(project_name, status, priority);
3475
+
3476
+ CREATE TABLE IF NOT EXISTS agent_events (
3477
+ id TEXT PRIMARY KEY,
3478
+ event_type TEXT NOT NULL,
3479
+ occurred_at TEXT NOT NULL,
3480
+ sequence_index INTEGER NOT NULL,
3481
+ actor_agent_id TEXT,
3482
+ agent_role TEXT,
3483
+ project_name TEXT,
3484
+ session_id TEXT,
3485
+ task_id TEXT,
3486
+ goal_id TEXT,
3487
+ parent_event_id TEXT,
3488
+ intention TEXT,
3489
+ outcome TEXT,
3490
+ evidence_memory_id TEXT,
3491
+ impact TEXT,
3492
+ payload TEXT DEFAULT '{}',
3493
+ created_at TEXT NOT NULL
3494
+ );
3495
+
3496
+ CREATE INDEX IF NOT EXISTS idx_agent_events_time
3497
+ ON agent_events(occurred_at, sequence_index);
3498
+
3499
+ CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
3500
+ ON agent_events(session_id, sequence_index);
3501
+
3502
+ CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
3503
+ ON agent_events(goal_id, occurred_at);
3504
+
3505
+ CREATE INDEX IF NOT EXISTS idx_agent_events_memory
3506
+ ON agent_events(evidence_memory_id);
3507
+
3508
+ CREATE TABLE IF NOT EXISTS agent_goal_links (
3509
+ id TEXT PRIMARY KEY,
3510
+ goal_id TEXT NOT NULL,
3511
+ link_type TEXT NOT NULL,
3512
+ target_id TEXT NOT NULL,
3513
+ target_type TEXT NOT NULL,
3514
+ created_at TEXT NOT NULL
3515
+ );
3516
+
3517
+ CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
3518
+ ON agent_goal_links(goal_id, target_type);
3519
+
3520
+ CREATE TABLE IF NOT EXISTS agent_semantic_labels (
3521
+ id TEXT PRIMARY KEY,
3522
+ source_memory_id TEXT NOT NULL,
3523
+ event_id TEXT,
3524
+ labeler TEXT NOT NULL,
3525
+ schema_version INTEGER NOT NULL DEFAULT 1,
3526
+ confidence REAL NOT NULL DEFAULT 0,
3527
+ labels TEXT NOT NULL,
3528
+ created_at TEXT NOT NULL,
3529
+ updated_at TEXT NOT NULL
3530
+ );
3531
+
3532
+ CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
3533
+ ON agent_semantic_labels(source_memory_id, labeler);
3534
+
3535
+ CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
3536
+ ON agent_semantic_labels(event_id);
3537
+
3538
+ CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
3539
+ id TEXT PRIMARY KEY,
3540
+ project_name TEXT,
3541
+ session_id TEXT,
3542
+ window_start_at TEXT NOT NULL,
3543
+ window_end_at TEXT NOT NULL,
3544
+ event_count INTEGER NOT NULL DEFAULT 0,
3545
+ goal_count INTEGER NOT NULL DEFAULT 0,
3546
+ success_count INTEGER NOT NULL DEFAULT 0,
3547
+ failure_count INTEGER NOT NULL DEFAULT 0,
3548
+ risk_count INTEGER NOT NULL DEFAULT 0,
3549
+ summary TEXT NOT NULL,
3550
+ learnings TEXT NOT NULL DEFAULT '[]',
3551
+ next_actions TEXT NOT NULL DEFAULT '[]',
3552
+ evidence_event_ids TEXT NOT NULL DEFAULT '[]',
3553
+ confidence REAL NOT NULL DEFAULT 0,
3554
+ created_at TEXT NOT NULL
3555
+ );
3556
+
3557
+ CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
3558
+ ON agent_reflection_checkpoints(project_name, window_end_at);
3559
+
3560
+ CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
3561
+ ON agent_reflection_checkpoints(session_id, window_end_at);
3562
+ `);
3415
3563
  try {
3416
3564
  await client.execute({
3417
3565
  sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
@@ -3629,7 +3777,7 @@ var init_embedder = __esm({
3629
3777
 
3630
3778
  // src/lib/keychain.ts
3631
3779
  import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
3632
- import { existsSync as existsSync7 } from "fs";
3780
+ import { existsSync as existsSync7, statSync as statSync2 } from "fs";
3633
3781
  import { execSync as execSync2 } from "child_process";
3634
3782
  import path8 from "path";
3635
3783
  import os6 from "os";
@@ -3639,29 +3787,78 @@ function getKeyDir() {
3639
3787
  function getKeyPath() {
3640
3788
  return path8.join(getKeyDir(), "master.key");
3641
3789
  }
3642
- function macKeychainGet() {
3790
+ function nativeKeychainAllowed() {
3791
+ return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
3792
+ }
3793
+ function linuxSecretAvailable() {
3794
+ if (!nativeKeychainAllowed()) return false;
3795
+ if (process.platform !== "linux") return false;
3796
+ if (linuxSecretAvailability !== null) return linuxSecretAvailability;
3797
+ try {
3798
+ execSync2("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
3799
+ } catch {
3800
+ linuxSecretAvailability = false;
3801
+ return false;
3802
+ }
3803
+ try {
3804
+ execSync2("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
3805
+ linuxSecretAvailability = true;
3806
+ } catch {
3807
+ linuxSecretAvailability = false;
3808
+ }
3809
+ return linuxSecretAvailability;
3810
+ }
3811
+ function isRootOnlyTrustedServerKeyFile(keyPath) {
3812
+ if (process.platform !== "linux") return false;
3813
+ try {
3814
+ const uid = typeof os6.userInfo().uid === "number" ? os6.userInfo().uid : -1;
3815
+ const st = statSync2(keyPath);
3816
+ if (!st.isFile() || (st.mode & 63) !== 0) return false;
3817
+ if (uid === 0) return true;
3818
+ const exeOsDir = process.env.EXE_OS_DIR;
3819
+ return Boolean(exeOsDir && path8.resolve(keyPath).startsWith(path8.resolve(exeOsDir) + path8.sep));
3820
+ } catch {
3821
+ return false;
3822
+ }
3823
+ }
3824
+ function macKeychainGet(service = SERVICE) {
3825
+ if (!nativeKeychainAllowed()) return null;
3643
3826
  if (process.platform !== "darwin") return null;
3644
3827
  try {
3645
3828
  return execSync2(
3646
- `security find-generic-password -s "${SERVICE}" -a "${ACCOUNT}" -w 2>/dev/null`,
3829
+ `security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
3647
3830
  { encoding: "utf-8", timeout: 5e3 }
3648
3831
  ).trim();
3649
3832
  } catch {
3650
3833
  return null;
3651
3834
  }
3652
3835
  }
3653
- function macKeychainSet(value) {
3836
+ function macKeychainSet(value, service = SERVICE) {
3837
+ if (!nativeKeychainAllowed()) return false;
3654
3838
  if (process.platform !== "darwin") return false;
3655
3839
  try {
3656
3840
  try {
3657
3841
  execSync2(
3658
- `security delete-generic-password -s "${SERVICE}" -a "${ACCOUNT}" 2>/dev/null`,
3842
+ `security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
3659
3843
  { timeout: 5e3 }
3660
3844
  );
3661
3845
  } catch {
3662
3846
  }
3663
3847
  execSync2(
3664
- `security add-generic-password -s "${SERVICE}" -a "${ACCOUNT}" -w "${value}"`,
3848
+ `security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
3849
+ { timeout: 5e3 }
3850
+ );
3851
+ return true;
3852
+ } catch {
3853
+ return false;
3854
+ }
3855
+ }
3856
+ function macKeychainDelete(service = SERVICE) {
3857
+ if (!nativeKeychainAllowed()) return false;
3858
+ if (process.platform !== "darwin") return false;
3859
+ try {
3860
+ execSync2(
3861
+ `security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
3665
3862
  { timeout: 5e3 }
3666
3863
  );
3667
3864
  return true;
@@ -3669,22 +3866,35 @@ function macKeychainSet(value) {
3669
3866
  return false;
3670
3867
  }
3671
3868
  }
3672
- function linuxSecretGet() {
3673
- if (process.platform !== "linux") return null;
3869
+ function linuxSecretGet(service = SERVICE) {
3870
+ if (!linuxSecretAvailable()) return null;
3674
3871
  try {
3675
3872
  return execSync2(
3676
- `secret-tool lookup service "${SERVICE}" account "${ACCOUNT}" 2>/dev/null`,
3873
+ `secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
3677
3874
  { encoding: "utf-8", timeout: 5e3 }
3678
3875
  ).trim();
3679
3876
  } catch {
3680
3877
  return null;
3681
3878
  }
3682
3879
  }
3683
- function linuxSecretSet(value) {
3880
+ function linuxSecretSet(value, service = SERVICE) {
3881
+ if (!linuxSecretAvailable()) return false;
3882
+ try {
3883
+ execSync2(
3884
+ `echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
3885
+ { timeout: 5e3 }
3886
+ );
3887
+ return true;
3888
+ } catch {
3889
+ return false;
3890
+ }
3891
+ }
3892
+ function linuxSecretDelete(service = SERVICE) {
3893
+ if (!nativeKeychainAllowed()) return false;
3684
3894
  if (process.platform !== "linux") return false;
3685
3895
  try {
3686
3896
  execSync2(
3687
- `echo -n "${value}" | secret-tool store --label="exe-os master key" service "${SERVICE}" account "${ACCOUNT}"`,
3897
+ `secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
3688
3898
  { timeout: 5e3 }
3689
3899
  );
3690
3900
  return true;
@@ -3693,6 +3903,7 @@ function linuxSecretSet(value) {
3693
3903
  }
3694
3904
  }
3695
3905
  async function tryKeytar() {
3906
+ if (!nativeKeychainAllowed()) return null;
3696
3907
  try {
3697
3908
  return await import("keytar");
3698
3909
  } catch {
@@ -3766,7 +3977,19 @@ async function writeMachineBoundFileFallback(b64) {
3766
3977
  return "plaintext";
3767
3978
  }
3768
3979
  async function getMasterKey() {
3769
- const nativeValue = macKeychainGet() ?? linuxSecretGet();
3980
+ let nativeValue = macKeychainGet() ?? linuxSecretGet();
3981
+ if (!nativeValue) {
3982
+ const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
3983
+ if (legacyValue) {
3984
+ const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
3985
+ if (migrated) {
3986
+ macKeychainDelete(LEGACY_SERVICE);
3987
+ linuxSecretDelete(LEGACY_SERVICE);
3988
+ process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
3989
+ }
3990
+ nativeValue = legacyValue;
3991
+ }
3992
+ }
3770
3993
  if (nativeValue) {
3771
3994
  return Buffer.from(nativeValue, "base64");
3772
3995
  }
@@ -3774,12 +3997,17 @@ async function getMasterKey() {
3774
3997
  if (keytar) {
3775
3998
  try {
3776
3999
  const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
3777
- if (keytarValue) {
3778
- const migrated = macKeychainSet(keytarValue) || linuxSecretSet(keytarValue);
4000
+ const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
4001
+ if (legacyKeytarValue) {
4002
+ const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
3779
4003
  if (migrated) {
3780
4004
  process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
4005
+ try {
4006
+ await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
4007
+ } catch {
4008
+ }
3781
4009
  }
3782
- return Buffer.from(keytarValue, "base64");
4010
+ return Buffer.from(legacyKeytarValue, "base64");
3783
4011
  }
3784
4012
  } catch {
3785
4013
  }
@@ -3804,7 +4032,7 @@ async function getMasterKey() {
3804
4032
  const decrypted = decryptWithMachineKey(content, machineKey);
3805
4033
  if (!decrypted) {
3806
4034
  process.stderr.write(
3807
- "[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os link import\n"
4035
+ "[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
3808
4036
  );
3809
4037
  return null;
3810
4038
  }
@@ -3813,6 +4041,9 @@ async function getMasterKey() {
3813
4041
  b64Value = content;
3814
4042
  }
3815
4043
  const key = Buffer.from(b64Value, "base64");
4044
+ if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
4045
+ return key;
4046
+ }
3816
4047
  const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
3817
4048
  if (migrated) {
3818
4049
  process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
@@ -3840,12 +4071,14 @@ async function getMasterKey() {
3840
4071
  return null;
3841
4072
  }
3842
4073
  }
3843
- var SERVICE, ACCOUNT, ENCRYPTED_PREFIX;
4074
+ var SERVICE, LEGACY_SERVICE, ACCOUNT, linuxSecretAvailability, ENCRYPTED_PREFIX;
3844
4075
  var init_keychain = __esm({
3845
4076
  "src/lib/keychain.ts"() {
3846
4077
  "use strict";
3847
- SERVICE = "exe-mem";
4078
+ SERVICE = "exe-os";
4079
+ LEGACY_SERVICE = "exe-mem";
3848
4080
  ACCOUNT = "master-key";
4081
+ linuxSecretAvailability = null;
3849
4082
  ENCRYPTED_PREFIX = "enc:";
3850
4083
  }
3851
4084
  });
@@ -4060,7 +4293,7 @@ __export(shard_manager_exports, {
4060
4293
  shardExists: () => shardExists
4061
4294
  });
4062
4295
  import path9 from "path";
4063
- import { existsSync as existsSync8, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync2 } from "fs";
4296
+ import { existsSync as existsSync8, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync3 } from "fs";
4064
4297
  import { createClient as createClient2 } from "@libsql/client";
4065
4298
  function initShardManager(encryptionKey) {
4066
4299
  _encryptionKey = encryptionKey;
@@ -4124,7 +4357,7 @@ async function auditShardHealth(options = {}) {
4124
4357
  const shards = [];
4125
4358
  for (const name of names) {
4126
4359
  const dbPath = path9.join(SHARDS_DIR, `${name}.db`);
4127
- const stat = statSync2(dbPath);
4360
+ const stat = statSync3(dbPath);
4128
4361
  const item = {
4129
4362
  name,
4130
4363
  path: dbPath,
@@ -4377,7 +4610,7 @@ async function getReadyShardClient(projectName) {
4377
4610
  _shardLastAccess.delete(safeName);
4378
4611
  const dbPath = path9.join(SHARDS_DIR, `${safeName}.db`);
4379
4612
  if (existsSync8(dbPath)) {
4380
- const stat = statSync2(dbPath);
4613
+ const stat = statSync3(dbPath);
4381
4614
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
4382
4615
  const archivedPath = path9.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
4383
4616
  renameSync3(dbPath, archivedPath);
@@ -4497,6 +4730,12 @@ var init_platform_procedures = __esm({
4497
4730
  priority: "p0",
4498
4731
  content: "Founder -> coordinator (the executive agent, internally routed as 'COO') -> CTO/CMO. CTO -> engineers. CMO -> content production. Never skip levels: the coordinator 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."
4499
4732
  },
4733
+ {
4734
+ title: "Customer orchestration maturity \u2014 recommend, never trap",
4735
+ domain: "workflow",
4736
+ priority: "p1",
4737
+ content: "New customers start best in Phase 1: founder \u2194 coordinator/Chief of Staff, building company context. Suggest Phase 2 executives when domain work repeats; suggest Phase 3 parallel execution only when review/permission gates are ready. This is guidance, not a blocker: users may jump phases anytime. Never overwrite their phase, role titles, identities, or custom org design."
4738
+ },
4500
4739
  {
4501
4740
  title: "Single dispatch path \u2014 create_task only",
4502
4741
  domain: "workflow",
@@ -4555,6 +4794,12 @@ var init_platform_procedures = __esm({
4555
4794
  priority: "p0",
4556
4795
  content: "exe-build-adv is MANDATORY for ALL work touching 3+ files. Run /exe-build-adv --auto BEFORE implementation. Pipeline: Spec \u2192 AC \u2192 Tests \u2192 Evaluate \u2192 Fix. No multi-file feature ships without pipeline artifacts. No exceptions \u2014 managers reject work without them."
4557
4796
  },
4797
+ {
4798
+ title: "Commit discipline \u2014 never leave verified work floating",
4799
+ domain: "workflow",
4800
+ priority: "p1",
4801
+ content: "After any code-change batch passes typecheck/tests/build, run git status, summarize changed files, and commit with a clear message before ending the session. If work must remain uncommitted for review/dogfood, explicitly say so, list the files, and state the blocker. Never imply work is complete while verified changes are still floating locally."
4802
+ },
4558
4803
  {
4559
4804
  title: "Desktop and TUI are the same product",
4560
4805
  domain: "architecture",
@@ -4872,6 +5117,274 @@ var init_memory_cards = __esm({
4872
5117
  }
4873
5118
  });
4874
5119
 
5120
+ // src/lib/agentic-ontology.ts
5121
+ var agentic_ontology_exports = {};
5122
+ __export(agentic_ontology_exports, {
5123
+ clean: () => clean,
5124
+ extractGoalCandidates: () => extractGoalCandidates,
5125
+ inferIntention: () => inferIntention,
5126
+ inferOntologyEventType: () => inferOntologyEventType,
5127
+ inferOutcome: () => inferOutcome,
5128
+ inferSemanticLabel: () => inferSemanticLabel,
5129
+ insertOntologyForBatch: () => insertOntologyForBatch,
5130
+ insertOntologyForMemory: () => insertOntologyForMemory,
5131
+ ontologyPayload: () => ontologyPayload,
5132
+ stableId: () => stableId2
5133
+ });
5134
+ import { createHash as createHash3 } from "crypto";
5135
+ function stableId2(...parts) {
5136
+ return createHash3("sha256").update(parts.map((p) => String(p ?? "")).join("::")).digest("hex").slice(0, 32);
5137
+ }
5138
+ function clean(text, max = 240) {
5139
+ return text.replace(/\u0000/g, "").replace(/```[\s\S]*?```/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
5140
+ }
5141
+ function inferOntologyEventType(row) {
5142
+ const lower = row.raw_text.toLowerCase();
5143
+ if (row.has_error) return "error";
5144
+ if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published)\b/.test(lower)) return "milestone";
5145
+ if (/\b(blocked|failed|error|bug|regression|broken)\b/.test(lower)) return "problem";
5146
+ if (/\b(decided|decision|adr|we chose|approved|rejected)\b/.test(lower)) return "decision";
5147
+ if (/\b(goal|need to|we need|want to|trying to|objective)\b/.test(lower)) return "goal_signal";
5148
+ if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) return "tool_action";
5149
+ if (row.tool_name.startsWith("memory_card")) return "memory_card";
5150
+ return "memory_observation";
5151
+ }
5152
+ function inferIntention(row) {
5153
+ if (row.intent) return clean(row.intent, 220);
5154
+ const text = clean(row.raw_text, 1e3);
5155
+ const patterns = [
5156
+ /(?:we need to|need to|let'?s|i want to|we should|goal is to|objective is to|trying to)\s+([^.!?\n]{8,220})/i,
5157
+ /(?:so that|in order to)\s+([^.!?\n]{8,220})/i,
5158
+ /(?:task|plan):\s*([^.!?\n]{8,220})/i
5159
+ ];
5160
+ for (const p of patterns) {
5161
+ const m = text.match(p);
5162
+ if (m?.[1]) return clean(m[1], 220);
5163
+ }
5164
+ if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) {
5165
+ return `${row.tool_name} during ${row.project_name}`;
5166
+ }
5167
+ return null;
5168
+ }
5169
+ function inferOutcome(row) {
5170
+ if (row.outcome) return clean(row.outcome, 220);
5171
+ if (row.has_error) return "error";
5172
+ const lower = row.raw_text.toLowerCase();
5173
+ if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published|passed)\b/.test(lower)) return "success_signal";
5174
+ if (/\b(blocked|failed|error|regression|broken|not working|could not)\b/.test(lower)) return "failure_signal";
5175
+ if (/\b(warning|risk|concern|caveat)\b/.test(lower)) return "risk_signal";
5176
+ return null;
5177
+ }
5178
+ function extractGoalCandidates(row) {
5179
+ const text = clean(row.raw_text, 1600);
5180
+ const patterns = [
5181
+ /(?:we need to|need to|i want to|we should|goal is to|objective is to|trying to|let'?s)\s+([^.!?\n]{12,220})/gi,
5182
+ /(?:success means|success criteria|so that)\s+([^.!?\n]{12,220})/gi
5183
+ ];
5184
+ const out = [];
5185
+ for (const pattern of patterns) {
5186
+ for (const m of text.matchAll(pattern)) {
5187
+ const candidate = clean(m[1] ?? "", 220);
5188
+ if (candidate.length >= 12 && !out.some((x) => x.toLowerCase() === candidate.toLowerCase())) out.push(candidate);
5189
+ if (out.length >= 3) return out;
5190
+ }
5191
+ }
5192
+ return out;
5193
+ }
5194
+ function uniq(values, max = 6) {
5195
+ const out = [];
5196
+ for (const value of values.map((v) => clean(v, 220)).filter(Boolean)) {
5197
+ if (!out.some((x) => x.toLowerCase() === value.toLowerCase())) out.push(value);
5198
+ if (out.length >= max) break;
5199
+ }
5200
+ return out;
5201
+ }
5202
+ function extractMatches(text, patterns, max = 5) {
5203
+ const out = [];
5204
+ for (const pattern of patterns) {
5205
+ for (const match of text.matchAll(pattern)) {
5206
+ const value = match[1] ?? match[0];
5207
+ if (value) out.push(value);
5208
+ if (out.length >= max) return uniq(out, max);
5209
+ }
5210
+ }
5211
+ return uniq(out, max);
5212
+ }
5213
+ function inferSemanticLabel(row) {
5214
+ const text = clean(row.raw_text, 2400);
5215
+ const eventType = inferOntologyEventType(row);
5216
+ const intention = inferIntention(row);
5217
+ const outcome = inferOutcome(row);
5218
+ const goals = extractGoalCandidates(row);
5219
+ const milestones = extractMatches(text, [
5220
+ /\b(?:completed|finished|fixed|resolved|shipped|deployed|published|pushed|passed)\b([^.!?\n]{0,180})/gi,
5221
+ /(?:milestone|done):\s*([^.!?\n]{8,220})/gi
5222
+ ]);
5223
+ const problems = extractMatches(text, [
5224
+ /\b(?:blocked by|failed because|bug|regression|broken|not working|error)\b([^.!?\n]{0,180})/gi,
5225
+ /(?:problem|issue|risk):\s*([^.!?\n]{8,220})/gi
5226
+ ]);
5227
+ const decisions = extractMatches(text, [
5228
+ /(?:decided|decision|adr|we chose|approved|rejected)\s+([^.!?\n]{8,220})/gi
5229
+ ]);
5230
+ const temporalAnchors = extractMatches(text, [
5231
+ /\b(\d{4}-\d{2}-\d{2}(?:[T ][0-9:.+-Z]+)?)\b/g,
5232
+ /\b(today|yesterday|tomorrow|this week|next week|last week|morning|afternoon|tonight)\b/gi
5233
+ ], 8);
5234
+ const nextActions = extractMatches(text, [
5235
+ /(?:next|todo|follow[- ]?up|remaining|need to)\s*:?\s*([^.!?\n]{8,220})/gi
5236
+ ]);
5237
+ const actors = uniq([
5238
+ row.agent_id,
5239
+ ...extractMatches(text, [/\b(?:agent|employee|owner|assignee)[:= ]+([a-zA-Z][a-zA-Z0-9_-]{1,40})/gi], 5)
5240
+ ], 6);
5241
+ const successSignals = milestones.length ? milestones : outcome === "success_signal" ? [clean(text, 180)] : [];
5242
+ const failureSignals = problems.length ? problems : outcome === "failure_signal" || row.has_error ? [clean(text, 180)] : [];
5243
+ const impact = successSignals.length && failureSignals.length ? "mixed" : failureSignals.length ? "negative" : successSignals.length ? "positive" : "neutral";
5244
+ const signalCount = goals.length + milestones.length + problems.length + decisions.length + nextActions.length;
5245
+ return {
5246
+ labeler: "deterministic",
5247
+ schemaVersion: 1,
5248
+ eventType,
5249
+ intention,
5250
+ outcome,
5251
+ impact,
5252
+ confidence: Math.min(0.95, 0.45 + signalCount * 0.08 + (intention ? 0.1 : 0) + (outcome ? 0.1 : 0)),
5253
+ goals,
5254
+ milestones,
5255
+ problems,
5256
+ decisions,
5257
+ actors,
5258
+ temporalAnchors,
5259
+ successSignals,
5260
+ failureSignals,
5261
+ nextActions,
5262
+ summary: clean(text, 280)
5263
+ };
5264
+ }
5265
+ function ontologyPayload(row) {
5266
+ const semantic = inferSemanticLabel(row);
5267
+ return {
5268
+ tool_name: row.tool_name,
5269
+ memory_version: row.version ?? null,
5270
+ domain: row.domain ?? null,
5271
+ trajectory: row.trajectory ? safeJson(row.trajectory) : null,
5272
+ semantic
5273
+ };
5274
+ }
5275
+ function safeJson(value) {
5276
+ try {
5277
+ return JSON.parse(value);
5278
+ } catch {
5279
+ return value.slice(0, 1e3);
5280
+ }
5281
+ }
5282
+ async function resolveClient(client) {
5283
+ if (client) return client;
5284
+ const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
5285
+ return getClient2();
5286
+ }
5287
+ async function insertOntologyForMemory(row, client) {
5288
+ const db = await resolveClient(client);
5289
+ const occurredAt = row.timestamp;
5290
+ const sequence = Number(row.version ?? 0) || Math.floor(new Date(occurredAt).getTime() / 1e3);
5291
+ const eventType = inferOntologyEventType(row);
5292
+ const intention = inferIntention(row);
5293
+ const outcome = inferOutcome(row);
5294
+ const eventId = stableId2("event", row.id);
5295
+ const now = (/* @__PURE__ */ new Date()).toISOString();
5296
+ await db.execute({
5297
+ sql: `INSERT INTO agent_sessions (id, agent_id, project_name, started_at, last_event_at, event_count, properties)
5298
+ VALUES (?, ?, ?, ?, ?, 1, ?)
5299
+ ON CONFLICT(id) DO UPDATE SET last_event_at = MAX(last_event_at, excluded.last_event_at),
5300
+ event_count = event_count + 1`,
5301
+ args: [row.session_id, row.agent_id, row.project_name, occurredAt, occurredAt, JSON.stringify({ agent_role: row.agent_role })]
5302
+ });
5303
+ await db.execute({
5304
+ sql: `INSERT OR IGNORE INTO agent_events
5305
+ (id, event_type, occurred_at, sequence_index, actor_agent_id, agent_role, project_name,
5306
+ session_id, task_id, goal_id, parent_event_id, intention, outcome, evidence_memory_id,
5307
+ impact, payload, created_at)
5308
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?, ?, ?)`,
5309
+ args: [
5310
+ eventId,
5311
+ eventType,
5312
+ occurredAt,
5313
+ sequence,
5314
+ row.agent_id,
5315
+ row.agent_role,
5316
+ row.project_name,
5317
+ row.session_id,
5318
+ row.task_id ?? null,
5319
+ intention,
5320
+ outcome,
5321
+ row.id,
5322
+ row.has_error ? "negative" : outcome === "success_signal" ? "positive" : "neutral",
5323
+ JSON.stringify(ontologyPayload(row)),
5324
+ now
5325
+ ]
5326
+ });
5327
+ const semantic = inferSemanticLabel(row);
5328
+ await db.execute({
5329
+ sql: `INSERT INTO agent_semantic_labels
5330
+ (id, source_memory_id, event_id, labeler, schema_version, confidence, labels, created_at, updated_at)
5331
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
5332
+ ON CONFLICT(id) DO UPDATE SET confidence = excluded.confidence,
5333
+ labels = excluded.labels, updated_at = excluded.updated_at`,
5334
+ args: [
5335
+ stableId2("semantic", row.id, semantic.labeler, semantic.schemaVersion),
5336
+ row.id,
5337
+ eventId,
5338
+ semantic.labeler,
5339
+ semantic.schemaVersion,
5340
+ semantic.confidence,
5341
+ JSON.stringify(semantic),
5342
+ now,
5343
+ now
5344
+ ]
5345
+ });
5346
+ for (const statement of extractGoalCandidates(row)) {
5347
+ const goalId = stableId2("goal", row.project_name, statement.toLowerCase());
5348
+ await db.execute({
5349
+ sql: `INSERT INTO agent_goals
5350
+ (id, statement, owner_agent_id, project_name, status, priority, success_criteria,
5351
+ parent_goal_id, due_at, achieved_at, supersedes_id, created_at, updated_at, source_memory_id)
5352
+ VALUES (?, ?, ?, ?, 'open', 5, NULL, NULL, NULL, NULL, NULL, ?, ?, ?)
5353
+ ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at`,
5354
+ args: [goalId, statement, row.agent_id, row.project_name, now, now, row.id]
5355
+ });
5356
+ await db.execute({
5357
+ sql: `INSERT OR IGNORE INTO agent_goal_links
5358
+ (id, goal_id, link_type, target_id, target_type, created_at)
5359
+ VALUES (?, ?, 'evidence', ?, 'memory', ?)`,
5360
+ args: [stableId2("goal_link", goalId, row.id, "memory"), goalId, row.id, now]
5361
+ });
5362
+ await db.execute({
5363
+ sql: `INSERT OR IGNORE INTO agent_goal_links
5364
+ (id, goal_id, link_type, target_id, target_type, created_at)
5365
+ VALUES (?, ?, 'event', ?, 'event', ?)`,
5366
+ args: [stableId2("goal_link", goalId, eventId, "event"), goalId, eventId, now]
5367
+ });
5368
+ }
5369
+ }
5370
+ async function insertOntologyForBatch(rows, client) {
5371
+ const db = await resolveClient(client);
5372
+ let count = 0;
5373
+ for (const row of rows) {
5374
+ try {
5375
+ await insertOntologyForMemory(row, db);
5376
+ count++;
5377
+ } catch {
5378
+ }
5379
+ }
5380
+ return count;
5381
+ }
5382
+ var init_agentic_ontology = __esm({
5383
+ "src/lib/agentic-ontology.ts"() {
5384
+ "use strict";
5385
+ }
5386
+ });
5387
+
4875
5388
  // src/lib/store.ts
4876
5389
  var store_exports = {};
4877
5390
  __export(store_exports, {
@@ -5215,6 +5728,11 @@ async function flushBatch() {
5215
5728
  await insertMemoryCardsForBatch2(batch);
5216
5729
  } catch {
5217
5730
  }
5731
+ try {
5732
+ const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
5733
+ await insertOntologyForBatch2(batch);
5734
+ } catch {
5735
+ }
5218
5736
  schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
5219
5737
  _pendingRecords.splice(0, batch.length);
5220
5738
  try {
@@ -5820,6 +6338,7 @@ __export(graph_rag_exports, {
5820
6338
  extractBatch: () => extractBatch,
5821
6339
  extractFromCode: () => extractFromCode,
5822
6340
  extractFromMemory: () => extractFromMemory,
6341
+ extractHeuristicMemoryGraph: () => extractHeuristicMemoryGraph,
5823
6342
  mergeEntities: () => mergeEntities,
5824
6343
  normalizeEntityName: () => normalizeEntityName,
5825
6344
  registerAlias: () => registerAlias,
@@ -5975,6 +6494,57 @@ function extractFromCode(source, filePath) {
5975
6494
  }
5976
6495
  return { entities, relationships, hyperedges: [] };
5977
6496
  }
6497
+ function pushUniqueEntity(entities, seen, name, type) {
6498
+ const normalized = normalizeEntityName(name);
6499
+ if (!normalized || normalized.length < 2) return;
6500
+ const key = `${normalized.toLowerCase()}::${type.toLowerCase()}`;
6501
+ if (seen.has(key)) return;
6502
+ seen.add(key);
6503
+ entities.push({ name: normalized.slice(0, 160), type });
6504
+ }
6505
+ function pushHeuristicRelationship(relationships, source, sourceType, target, targetType, relationship, confidence = 0.6) {
6506
+ if (!source || !target || source === target) return;
6507
+ relationships.push({
6508
+ source,
6509
+ sourceType,
6510
+ target,
6511
+ targetType,
6512
+ relationship,
6513
+ confidence,
6514
+ confidenceLabel: "inferred"
6515
+ });
6516
+ }
6517
+ function extractHeuristicMemoryGraph(content, agentId) {
6518
+ const entities = [];
6519
+ const relationships = [];
6520
+ const seen = /* @__PURE__ */ new Set();
6521
+ pushUniqueEntity(entities, seen, agentId, "person");
6522
+ const toolMatch = content.match(/^(Bash|Read|Edit|Write|Grep|Glob|AssistantResponse|Tool|Ran|Wrote|Edited):/m);
6523
+ if (toolMatch?.[1]) {
6524
+ pushUniqueEntity(entities, seen, toolMatch[1], "tool");
6525
+ pushHeuristicRelationship(relationships, agentId, "person", toolMatch[1], "tool", "uses", 0.75);
6526
+ }
6527
+ const repoMatches = [...content.matchAll(/\/Users\/[^/\s]+\/([A-Za-z0-9_.-]+)|\/opt\/([A-Za-z0-9_.-]+)/g)].map((m) => m[1] ?? m[2]).filter((repo) => Boolean(repo)).slice(0, 6);
6528
+ for (const repo of repoMatches) {
6529
+ pushUniqueEntity(entities, seen, repo, "project");
6530
+ pushHeuristicRelationship(relationships, agentId, "person", repo, "project", "worked_on", 0.7);
6531
+ }
6532
+ const pathMatches = new Set(
6533
+ (content.match(/(?:\/[\w .@-]+)+(?:\.[A-Za-z0-9]{1,10})|(?:[\w@.-]+\/)+[\w@.-]+\.(?:ts|tsx|js|jsx|json|md|yml|yaml|sql|py|go|rs|sh|css|html)/g) ?? []).slice(0, 10)
6534
+ );
6535
+ for (const filePath of pathMatches) {
6536
+ pushUniqueEntity(entities, seen, filePath, "file");
6537
+ pushHeuristicRelationship(relationships, agentId, "person", filePath, "file", "uses", 0.65);
6538
+ }
6539
+ const backtickTerms = [...content.matchAll(/`([^`\n]{2,80})`/g)].map((m) => m[1]).slice(0, 10);
6540
+ for (const term of backtickTerms) {
6541
+ if (!term || term.length < 2) continue;
6542
+ const type = term.includes("/") || /\.[A-Za-z0-9]{1,10}$/.test(term) ? "file" : "concept";
6543
+ pushUniqueEntity(entities, seen, term, type);
6544
+ pushHeuristicRelationship(relationships, agentId, "person", term, type, "uses", 0.55);
6545
+ }
6546
+ return { entities, relationships, hyperedges: [] };
6547
+ }
5978
6548
  async function extractFromMemory(content, agentId, model = "claude-haiku-4-5-20251001", filePath) {
5979
6549
  if (content.length < 50) {
5980
6550
  return { entities: [], relationships: [], hyperedges: [] };
@@ -6030,7 +6600,7 @@ async function extractFromMemory(content, agentId, model = "claude-haiku-4-5-202
6030
6600
  `
6031
6601
  );
6032
6602
  }
6033
- return { entities: [], relationships: [], hyperedges: [] };
6603
+ return extractHeuristicMemoryGraph(content, agentId);
6034
6604
  }
6035
6605
  async function storeExtraction(client, extraction, memoryId, timestamp) {
6036
6606
  let entitiesStored = 0;
@@ -6806,8 +7376,8 @@ async function validateLicense(apiKey, deviceId) {
6806
7376
  }
6807
7377
  function getCacheAgeMs() {
6808
7378
  try {
6809
- const { statSync: statSync3 } = __require("fs");
6810
- const s = statSync3(CACHE_PATH);
7379
+ const { statSync: statSync4 } = __require("fs");
7380
+ const s = statSync4(CACHE_PATH);
6811
7381
  return Date.now() - s.mtimeMs;
6812
7382
  } catch {
6813
7383
  return Infinity;