@askexenow/exe-os 0.9.16 → 0.9.18

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 (97) hide show
  1. package/dist/bin/backfill-conversations.js +1242 -909
  2. package/dist/bin/backfill-responses.js +1245 -912
  3. package/dist/bin/backfill-vectors.js +1244 -906
  4. package/dist/bin/cleanup-stale-review-tasks.js +1870 -417
  5. package/dist/bin/cli.js +217 -107
  6. package/dist/bin/exe-agent-config.js +2 -2
  7. package/dist/bin/exe-agent.js +62 -0
  8. package/dist/bin/exe-assign.js +346 -10
  9. package/dist/bin/exe-boot.js +387 -32
  10. package/dist/bin/exe-call.js +72 -2
  11. package/dist/bin/exe-cloud.js +8 -0
  12. package/dist/bin/exe-dispatch.js +1821 -225
  13. package/dist/bin/exe-doctor.js +720 -52
  14. package/dist/bin/exe-export-behaviors.js +1429 -148
  15. package/dist/bin/exe-forget.js +1408 -34
  16. package/dist/bin/exe-gateway.js +1629 -1295
  17. package/dist/bin/exe-heartbeat.js +1899 -448
  18. package/dist/bin/exe-kill.js +1624 -346
  19. package/dist/bin/exe-launch-agent.js +726 -90
  20. package/dist/bin/exe-link.js +27 -8
  21. package/dist/bin/exe-new-employee.js +75 -9
  22. package/dist/bin/exe-pending-messages.js +2769 -1316
  23. package/dist/bin/exe-pending-notifications.js +2829 -1376
  24. package/dist/bin/exe-pending-reviews.js +2847 -1392
  25. package/dist/bin/exe-rename.js +89 -8
  26. package/dist/bin/exe-review.js +1494 -312
  27. package/dist/bin/exe-search.js +1608 -1300
  28. package/dist/bin/exe-session-cleanup.js +194 -91
  29. package/dist/bin/exe-settings.js +10 -2
  30. package/dist/bin/exe-start-codex.js +769 -120
  31. package/dist/bin/exe-start-opencode.js +763 -108
  32. package/dist/bin/exe-status.js +1887 -434
  33. package/dist/bin/exe-team.js +1782 -324
  34. package/dist/bin/git-sweep.js +408 -33
  35. package/dist/bin/graph-backfill.js +681 -27
  36. package/dist/bin/graph-export.js +1419 -141
  37. package/dist/bin/install.js +4 -8
  38. package/dist/bin/intercom-check.js +8641 -0
  39. package/dist/bin/scan-tasks.js +553 -38
  40. package/dist/bin/setup.js +82 -10
  41. package/dist/bin/shard-migrate.js +682 -28
  42. package/dist/gateway/index.js +1629 -1295
  43. package/dist/hooks/bug-report-worker.js +1136 -183
  44. package/dist/hooks/codex-stop-task-finalizer.js +1060 -107
  45. package/dist/hooks/commit-complete.js +408 -33
  46. package/dist/hooks/error-recall.js +1608 -1300
  47. package/dist/hooks/ingest-worker.js +250 -7966
  48. package/dist/hooks/ingest.js +707 -119
  49. package/dist/hooks/instructions-loaded.js +383 -20
  50. package/dist/hooks/notification.js +383 -20
  51. package/dist/hooks/post-compact.js +384 -21
  52. package/dist/hooks/{response-ingest-worker.js → post-tool-combined.js} +4157 -1716
  53. package/dist/hooks/pre-compact.js +486 -45
  54. package/dist/hooks/pre-tool-use.js +385 -22
  55. package/dist/hooks/prompt-submit.js +291 -96
  56. package/dist/hooks/session-end.js +490 -48
  57. package/dist/hooks/session-start.js +236 -22
  58. package/dist/hooks/stop.js +192 -50
  59. package/dist/hooks/subagent-stop.js +95 -18
  60. package/dist/hooks/summary-worker.js +205 -361
  61. package/dist/index.js +221 -105
  62. package/dist/lib/agent-config.js +2 -2
  63. package/dist/lib/cloud-sync.js +27 -8
  64. package/dist/lib/consolidation.js +437 -41
  65. package/dist/lib/database.js +20 -8
  66. package/dist/lib/db-daemon-client.js +2 -2
  67. package/dist/lib/db.js +20 -8
  68. package/dist/lib/device-registry.js +27 -8
  69. package/dist/lib/employee-templates.js +62 -0
  70. package/dist/lib/employees.js +2 -2
  71. package/dist/lib/exe-daemon.js +6703 -6259
  72. package/dist/lib/hybrid-search.js +1608 -1300
  73. package/dist/lib/identity.js +1 -1
  74. package/dist/lib/messaging.js +11 -3
  75. package/dist/lib/reminders.js +1 -1
  76. package/dist/lib/schedules.js +718 -26
  77. package/dist/lib/session-registry.js +11 -0
  78. package/dist/lib/skill-learning.js +639 -9
  79. package/dist/lib/store.js +676 -27
  80. package/dist/lib/tasks.js +665 -27
  81. package/dist/lib/tmux-routing.js +732 -94
  82. package/dist/lib/token-spend.js +1 -1
  83. package/dist/mcp/server.js +856 -383
  84. package/dist/mcp/tools/complete-reminder.js +1 -1
  85. package/dist/mcp/tools/create-reminder.js +1 -1
  86. package/dist/mcp/tools/create-task.js +616 -46
  87. package/dist/mcp/tools/deactivate-behavior.js +9 -1
  88. package/dist/mcp/tools/list-reminders.js +1 -1
  89. package/dist/mcp/tools/list-tasks.js +10 -2
  90. package/dist/mcp/tools/send-message.js +11 -3
  91. package/dist/mcp/tools/update-task.js +677 -39
  92. package/dist/runtime/index.js +425 -37
  93. package/dist/tui/App.js +365 -34
  94. package/package.json +5 -2
  95. package/src/commands/exe/intercom.md +6 -17
  96. package/dist/bin/wiki-sync.js +0 -2991
  97. package/dist/hooks/prompt-ingest-worker.js +0 -3979
@@ -303,15 +303,6 @@ var init_config = __esm({
303
303
  }
304
304
  });
305
305
 
306
- // src/types/memory.ts
307
- var EMBEDDING_DIM;
308
- var init_memory = __esm({
309
- "src/types/memory.ts"() {
310
- "use strict";
311
- EMBEDDING_DIM = 1024;
312
- }
313
- });
314
-
315
306
  // src/lib/db-retry.ts
316
307
  function isBusyError(err) {
317
308
  if (err instanceof Error) {
@@ -361,9 +352,9 @@ var MAX_RETRIES, BASE_DELAY_MS, MAX_JITTER_MS;
361
352
  var init_db_retry = __esm({
362
353
  "src/lib/db-retry.ts"() {
363
354
  "use strict";
364
- MAX_RETRIES = 3;
365
- BASE_DELAY_MS = 200;
366
- MAX_JITTER_MS = 300;
355
+ MAX_RETRIES = 5;
356
+ BASE_DELAY_MS = 250;
357
+ MAX_JITTER_MS = 400;
367
358
  }
368
359
  });
369
360
 
@@ -466,7 +457,7 @@ var init_agent_config = __esm({
466
457
  init_secure_files();
467
458
  AGENT_CONFIG_PATH = path2.join(EXE_AI_DIR, "agent-config.json");
468
459
  KNOWN_RUNTIMES = {
469
- claude: ["claude-opus-4", "claude-sonnet-4", "claude-haiku-4.5"],
460
+ claude: ["claude-opus-4.6", "claude-opus-4", "claude-sonnet-4.6", "claude-sonnet-4", "claude-haiku-4.5"],
470
461
  codex: ["gpt-5.4", "gpt-5.5", "gpt-5.3-codex-spark", "o3", "o4-mini"],
471
462
  opencode: ["anthropic/claude-sonnet-4-6", "openai/gpt-5.4", "google/gemini-2.5-pro", "deepseek/deepseek-r3", "minimax/minimax-m2.5"]
472
463
  };
@@ -476,7 +467,7 @@ var init_agent_config = __esm({
476
467
  opencode: "OpenCode (open source)"
477
468
  };
478
469
  DEFAULT_MODELS = {
479
- claude: "claude-opus-4",
470
+ claude: "claude-opus-4.6",
480
471
  codex: RUNTIME_TABLE.codex?.defaultModel ?? "gpt-5.4",
481
472
  opencode: RUNTIME_TABLE.opencode?.defaultModel ?? "anthropic/claude-sonnet-4-6"
482
473
  };
@@ -1323,6 +1314,15 @@ var init_database_adapter = __esm({
1323
1314
  }
1324
1315
  });
1325
1316
 
1317
+ // src/types/memory.ts
1318
+ var EMBEDDING_DIM;
1319
+ var init_memory = __esm({
1320
+ "src/types/memory.ts"() {
1321
+ "use strict";
1322
+ EMBEDDING_DIM = 1024;
1323
+ }
1324
+ });
1325
+
1326
1326
  // src/lib/daemon-auth.ts
1327
1327
  import crypto from "crypto";
1328
1328
  import path5 from "path";
@@ -1361,6 +1361,17 @@ var init_daemon_auth = __esm({
1361
1361
  });
1362
1362
 
1363
1363
  // src/lib/exe-daemon-client.ts
1364
+ var exe_daemon_client_exports = {};
1365
+ __export(exe_daemon_client_exports, {
1366
+ connectEmbedDaemon: () => connectEmbedDaemon,
1367
+ disconnectClient: () => disconnectClient,
1368
+ embedBatchViaClient: () => embedBatchViaClient,
1369
+ embedViaClient: () => embedViaClient,
1370
+ isClientConnected: () => isClientConnected,
1371
+ pingDaemon: () => pingDaemon,
1372
+ sendDaemonRequest: () => sendDaemonRequest,
1373
+ sendIngestRequest: () => sendIngestRequest
1374
+ });
1364
1375
  import net from "net";
1365
1376
  import os4 from "os";
1366
1377
  import { spawn } from "child_process";
@@ -1749,6 +1760,15 @@ async function embedViaClient(text, priority = "high") {
1749
1760
  );
1750
1761
  return !result.error && result.vectors?.[0] ? result.vectors[0] : null;
1751
1762
  }
1763
+ async function embedBatchViaClient(texts, priority = "high") {
1764
+ if (!_connected && !await connectEmbedDaemon()) return null;
1765
+ _requestCount++;
1766
+ const result = await retryThenRestart(
1767
+ () => sendRequest(texts, priority),
1768
+ "Batch embed"
1769
+ );
1770
+ return !result.error && result.vectors ? result.vectors : null;
1771
+ }
1752
1772
  function disconnectClient() {
1753
1773
  if (_socket) {
1754
1774
  _socket.destroy();
@@ -1765,6 +1785,17 @@ function disconnectClient() {
1765
1785
  function isClientConnected() {
1766
1786
  return _connected;
1767
1787
  }
1788
+ function sendIngestRequest(payload) {
1789
+ if (!_socket || !_connected) return false;
1790
+ try {
1791
+ const id = randomUUID();
1792
+ const token = process.env[DAEMON_TOKEN_ENV] ?? readDaemonToken();
1793
+ _socket.write(JSON.stringify({ id, token, type: "ingest", ...payload }) + "\n");
1794
+ return true;
1795
+ } catch {
1796
+ return false;
1797
+ }
1798
+ }
1768
1799
  var SOCKET_PATH, PID_PATH, SPAWN_LOCK_PATH, SPAWN_LOCK_STALE_MS, CONNECT_TIMEOUT_MS, REQUEST_TIMEOUT_MS, DAEMON_TOKEN_ENV, _socket, _connected, _buffer, _requestCount, _consecutiveFailures, HEALTH_CHECK_INTERVAL, MAX_RETRIES_BEFORE_RESTART, RETRY_DELAYS_MS, MIN_DAEMON_AGE_MS, _pending, MAX_BUFFER;
1769
1800
  var init_exe_daemon_client = __esm({
1770
1801
  "src/lib/exe-daemon-client.ts"() {
@@ -1793,6 +1824,15 @@ var init_exe_daemon_client = __esm({
1793
1824
  });
1794
1825
 
1795
1826
  // src/lib/daemon-protocol.ts
1827
+ var daemon_protocol_exports = {};
1828
+ __export(daemon_protocol_exports, {
1829
+ deserializeArgs: () => deserializeArgs,
1830
+ deserializeResultSet: () => deserializeResultSet,
1831
+ deserializeValue: () => deserializeValue,
1832
+ serializeArgs: () => serializeArgs,
1833
+ serializeResultSet: () => serializeResultSet,
1834
+ serializeValue: () => serializeValue
1835
+ });
1796
1836
  function serializeValue(v) {
1797
1837
  if (v === null || v === void 0) return null;
1798
1838
  if (typeof v === "bigint") return Number(v);
@@ -1817,6 +1857,32 @@ function deserializeValue(v) {
1817
1857
  }
1818
1858
  return v;
1819
1859
  }
1860
+ function serializeArgs(args) {
1861
+ return args.map(serializeValue);
1862
+ }
1863
+ function deserializeArgs(args) {
1864
+ return args.map(deserializeValue);
1865
+ }
1866
+ function serializeResultSet(rs) {
1867
+ const rows = [];
1868
+ for (const row of rs.rows) {
1869
+ const obj = {};
1870
+ for (let i = 0; i < rs.columns.length; i++) {
1871
+ const col = rs.columns[i];
1872
+ if (col !== void 0) {
1873
+ obj[col] = serializeValue(row[i]);
1874
+ }
1875
+ }
1876
+ rows.push(obj);
1877
+ }
1878
+ return {
1879
+ columns: [...rs.columns],
1880
+ columnTypes: [...rs.columnTypes ?? []],
1881
+ rows,
1882
+ rowsAffected: typeof rs.rowsAffected === "bigint" ? Number(rs.rowsAffected) : rs.rowsAffected ?? 0,
1883
+ lastInsertRowid: rs.lastInsertRowid != null ? typeof rs.lastInsertRowid === "bigint" ? Number(rs.lastInsertRowid) : rs.lastInsertRowid : null
1884
+ };
1885
+ }
1820
1886
  function deserializeResultSet(srs) {
1821
1887
  const rows = srs.rows.map((obj) => {
1822
1888
  const values = srs.columns.map(
@@ -1894,7 +1960,7 @@ function createDaemonDbClient(fallbackClient) {
1894
1960
  });
1895
1961
  if (response.error) {
1896
1962
  const errMsg = String(response.error);
1897
- if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed") {
1963
+ if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed" || errMsg === "DB not initialized") {
1898
1964
  process.stderr.write(`[db-daemon] Transport error (${errMsg}), falling back to direct
1899
1965
  `);
1900
1966
  return fallbackClient.execute(stmt);
@@ -1919,7 +1985,7 @@ function createDaemonDbClient(fallbackClient) {
1919
1985
  });
1920
1986
  if (response.error) {
1921
1987
  const errMsg = String(response.error);
1922
- if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed") {
1988
+ if (errMsg === "Not connected" || errMsg === "Request timeout" || errMsg === "Write failed" || errMsg === "DB not initialized") {
1923
1989
  process.stderr.write(`[db-daemon] Batch transport error (${errMsg}), falling back to direct
1924
1990
  `);
1925
1991
  return fallbackClient.batch(stmts, mode);
@@ -2042,7 +2108,7 @@ async function initDatabase(config) {
2042
2108
  });
2043
2109
  }, 3e4);
2044
2110
  _walCheckpointTimer.unref();
2045
- if (process.env.DATABASE_URL) {
2111
+ if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
2046
2112
  _adapterClient = await createPrismaDbAdapter(_resilientClient);
2047
2113
  }
2048
2114
  }
@@ -2053,7 +2119,7 @@ function getClient() {
2053
2119
  if (!_adapterClient) {
2054
2120
  throw new Error("Database client not initialized. Call initDatabase() first.");
2055
2121
  }
2056
- if (process.env.DATABASE_URL) {
2122
+ if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") {
2057
2123
  return _adapterClient;
2058
2124
  }
2059
2125
  if (process.env.EXE_IS_DAEMON === "1") {
@@ -2065,9 +2131,11 @@ function getClient() {
2065
2131
  return _resilientClient;
2066
2132
  }
2067
2133
  async function initDaemonClient() {
2068
- if (process.env.DATABASE_URL) return;
2134
+ if (process.env.DATABASE_URL && process.env.EXE_USE_POSTGRES === "1") return;
2069
2135
  if (process.env.EXE_IS_DAEMON === "1") return;
2136
+ if (process.env.VITEST) return;
2070
2137
  if (!_resilientClient) return;
2138
+ if (_daemonClient) return;
2071
2139
  try {
2072
2140
  const { initDaemonDbClient: initDaemonDbClient2 } = await Promise.resolve().then(() => (init_db_daemon_client(), db_daemon_client_exports));
2073
2141
  _daemonClient = await initDaemonDbClient2(_resilientClient);
@@ -2216,6 +2284,13 @@ async function ensureSchema() {
2216
2284
  });
2217
2285
  } catch {
2218
2286
  }
2287
+ try {
2288
+ await client.execute({
2289
+ sql: `ALTER TABLE behaviors ADD COLUMN vector F32_BLOB(${EMBEDDING_DIM})`,
2290
+ args: []
2291
+ });
2292
+ } catch {
2293
+ }
2219
2294
  try {
2220
2295
  await client.execute({
2221
2296
  sql: `ALTER TABLE tasks ADD COLUMN blocked_by TEXT`,
@@ -3086,6 +3161,7 @@ var init_database = __esm({
3086
3161
  init_db_retry();
3087
3162
  init_employees();
3088
3163
  init_database_adapter();
3164
+ init_memory();
3089
3165
  _client = null;
3090
3166
  _resilientClient = null;
3091
3167
  _walCheckpointTimer = null;
@@ -3638,6 +3714,68 @@ var init_platform_procedures = __esm({
3638
3714
  domain: "architecture",
3639
3715
  priority: "p0",
3640
3716
  content: "Tasks live in the DB. Intercom (tmux send-keys) is fire-and-forget \u2014 it may fail, get garbled, or arrive mid-work. Never rely on intercom for task delivery. The UserPromptSubmit hook checks the DB for new tasks on every prompt. Your operating procedures step 7 says check for next work. The daemon nudges idle agents as a speedup. If you have no tasks, you found them all."
3717
+ },
3718
+ // --- MCP is the ONLY data interface ---
3719
+ {
3720
+ title: "MCP disconnect \u2014 ask the user, never work around it",
3721
+ domain: "workflow",
3722
+ priority: "p0",
3723
+ content: "If MCP tools are unavailable, disconnected, or returning connection errors: STOP. Tell the user clearly: 'MCP server is disconnected. Please run /mcp to reconnect.' Do NOT attempt workarounds \u2014 no raw Node imports, no direct DB access, no CLI hacks, no daemon socket calls. MCP is the ONLY data interface. Working around it wastes time, hits bundling issues, and bypasses the contract boundary. Ask once, wait, proceed when reconnected."
3724
+ },
3725
+ // --- MCP Tool Catalog (Layer 0 — every agent knows what tools exist) ---
3726
+ {
3727
+ title: "MCP tools \u2014 memory and search",
3728
+ domain: "tool-use",
3729
+ priority: "p1",
3730
+ content: "recall_my_memory: search your own memories (semantic + FTS). ask_team_memory: search a colleague's memories by agent name. store_memory: persist a memory (decisions, summaries, context). commit_memory: high-importance memory that survives consolidation. search_everything: unified search across memories, tasks, entities, conversations. get_session_context: temporal window of memories around a timestamp. consolidate_memories: merge duplicate/related memories into insights. get_memory_cardinality: count memories per agent (health check)."
3731
+ },
3732
+ {
3733
+ title: "MCP tools \u2014 task orchestration",
3734
+ domain: "tool-use",
3735
+ priority: "p1",
3736
+ content: "create_task: dispatch work to an employee (auto-spawns session). The ONLY dispatch path. list_tasks: query tasks by status, assignee, project. get_task: fetch full task details by ID. update_task: change status (in_progress, done, blocked, cancelled) + add result summary. close_task: finalize a reviewed task (COO only). checkpoint_task: save progress state for crash recovery. resume_employee: re-spawn an employee session for an existing task."
3737
+ },
3738
+ {
3739
+ title: "MCP tools \u2014 knowledge graph (GraphRAG)",
3740
+ domain: "tool-use",
3741
+ priority: "p1",
3742
+ content: "query_relationships: find connections between entities in the knowledge graph. get_entity_neighbors: explore an entity's direct connections. get_hot_entities: find most-referenced entities (trending topics). get_graph_stats: graph health \u2014 entity/relationship counts, density. export_graph: export graph data for visualization. merge_entities: deduplicate entities (alias resolution). find_similar_trajectories: match tool-call patterns to past task solutions."
3743
+ },
3744
+ {
3745
+ title: "MCP tools \u2014 identity, behavior, and decisions",
3746
+ domain: "tool-use",
3747
+ priority: "p1",
3748
+ content: "get_identity: read an agent's exe.md (Layer 1 identity). update_identity: write an agent's exe.md. Identity > behavior \u2014 use for permanent rules. store_behavior: record a correction or pattern for an agent (Layer 2 expertise). list_behaviors: view an agent's active behaviors. deactivate_behavior: soft-delete a stale or conflicting behavior. store_decision: record an ADR (architectural decision record). get_decision: retrieve a past decision by query."
3749
+ },
3750
+ {
3751
+ title: "MCP tools \u2014 communication and messaging",
3752
+ domain: "tool-use",
3753
+ priority: "p1",
3754
+ content: "send_message: send supplementary context to another agent (NOT for actionable work \u2014 use create_task). acknowledge_messages: mark messages as read. send_whatsapp: send WhatsApp message via gateway (customer-facing alerts). query_conversations: search ingested conversations across all channels (WhatsApp, email, etc.)."
3755
+ },
3756
+ {
3757
+ title: "MCP tools \u2014 wiki, documents, and content",
3758
+ domain: "tool-use",
3759
+ priority: "p1",
3760
+ content: "create_wiki_page: create a wiki page in exe-wiki. list_wiki_pages: browse wiki pages. get_wiki_page: read a wiki page. update_wiki_page: edit a wiki page. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
3761
+ },
3762
+ {
3763
+ title: "MCP tools \u2014 system, operations, and admin",
3764
+ domain: "tool-use",
3765
+ priority: "p1",
3766
+ content: "get_agent_spend: token usage per agent/session (cost tracking). list_agent_sessions: view agent session history. get_session_kills: audit log of killed sessions. get_daemon_health: check exed daemon status. get_auto_wake_status: daemon auto-wake configuration. get_worker_gate: check worker deployment gates. run_memory_audit: health check \u2014 duplicates, null vectors, orphaned rows. run_consolidation: trigger sleep-time memory consolidation. cloud_sync: force a cloud sync cycle. backup_vps: trigger VPS backup."
3767
+ },
3768
+ {
3769
+ title: "MCP tools \u2014 config, licensing, and team",
3770
+ domain: "tool-use",
3771
+ priority: "p1",
3772
+ content: "set_agent_config: view/change per-agent runtime and model settings. list_employees: view the employee roster. add_person: add a person to the CRM contacts roster. list_people: browse CRM contacts. get_person: fetch contact details. get_license_status: check license validity. create_license: generate a new license key (admin). list_licenses: view all issued licenses. activate_license: activate a license on a device."
3773
+ },
3774
+ {
3775
+ title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
3776
+ domain: "tool-use",
3777
+ priority: "p1",
3778
+ content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done. global_procedure: manage Layer 0 procedures (actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
3641
3779
  }
3642
3780
  ];
3643
3781
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -3787,6 +3925,11 @@ async function initStore(options) {
3787
3925
  encryptionKey: hexKey
3788
3926
  });
3789
3927
  await retryOnBusy2(() => ensureSchema(), "ensureSchema");
3928
+ try {
3929
+ const { initDaemonClient: initDaemonClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
3930
+ await initDaemonClient2();
3931
+ } catch {
3932
+ }
3790
3933
  if (!options?.lightweight) {
3791
3934
  try {
3792
3935
  const { initShardManager: initShardManager2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
@@ -5715,7 +5858,7 @@ function rrfMergeMulti(lists, limit, k = RRF_K, weights) {
5715
5858
  const importance = normalizedImportance(e.record.importance);
5716
5859
  const confidence = sourceConfidence(e.record);
5717
5860
  const frecency = frecencyBoost(e.record.last_accessed, e.record.timestamp);
5718
- const baseScore = e.rrfScore * 0.35 + recency * 0.14 + importance * 0.21 + confidence * 0.3;
5861
+ const baseScore = e.rrfScore * 0.45 + recency * 0.24 + importance * 0.21 + confidence * 0.1;
5719
5862
  const finalScore = baseScore * (1 + 0.3 * frecency);
5720
5863
  return { score: finalScore, record: e.record };
5721
5864
  });
@@ -6604,6 +6747,77 @@ var init_task_scope = __esm({
6604
6747
  }
6605
6748
  });
6606
6749
 
6750
+ // src/bin/fast-db-init.ts
6751
+ var fast_db_init_exports = {};
6752
+ __export(fast_db_init_exports, {
6753
+ fastDbInit: () => fastDbInit
6754
+ });
6755
+ async function fastDbInit() {
6756
+ const { isInitialized: isInitialized2, getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
6757
+ if (isInitialized2()) {
6758
+ return getClient2();
6759
+ }
6760
+ try {
6761
+ const { connectEmbedDaemon: connectEmbedDaemon2, sendDaemonRequest: sendDaemonRequest2, isClientConnected: isClientConnected2 } = await Promise.resolve().then(() => (init_exe_daemon_client(), exe_daemon_client_exports));
6762
+ const { deserializeResultSet: deserializeResultSet2 } = await Promise.resolve().then(() => (init_daemon_protocol(), daemon_protocol_exports));
6763
+ await connectEmbedDaemon2();
6764
+ if (isClientConnected2()) {
6765
+ const daemonClient = {
6766
+ async execute(stmt) {
6767
+ const sql = typeof stmt === "string" ? stmt : stmt.sql;
6768
+ const args = typeof stmt === "string" ? [] : Array.isArray(stmt.args) ? stmt.args : [];
6769
+ const resp = await sendDaemonRequest2({ type: "db-execute", sql, args });
6770
+ if (resp.error) throw new Error(String(resp.error));
6771
+ if (resp.db) return deserializeResultSet2(resp.db);
6772
+ throw new Error("Unexpected daemon response");
6773
+ },
6774
+ async batch(stmts, mode) {
6775
+ const statements = stmts.map((s) => {
6776
+ const sql = typeof s === "string" ? s : s.sql;
6777
+ const args = typeof s === "string" ? [] : Array.isArray(s.args) ? s.args : [];
6778
+ return { sql, args };
6779
+ });
6780
+ const resp = await sendDaemonRequest2({ type: "db-batch", statements, mode: mode ?? "deferred" });
6781
+ if (resp.error) throw new Error(String(resp.error));
6782
+ const batchResults = resp["db-batch"];
6783
+ if (batchResults) return batchResults.map(deserializeResultSet2);
6784
+ throw new Error("Unexpected daemon batch response");
6785
+ },
6786
+ async transaction(_mode) {
6787
+ throw new Error("Transactions not supported via daemon socket");
6788
+ },
6789
+ async executeMultiple(_sql) {
6790
+ throw new Error("executeMultiple not supported via daemon socket");
6791
+ },
6792
+ async migrate(_stmts) {
6793
+ throw new Error("migrate not supported via daemon socket");
6794
+ },
6795
+ sync() {
6796
+ return Promise.resolve(void 0);
6797
+ },
6798
+ close() {
6799
+ },
6800
+ get closed() {
6801
+ return false;
6802
+ },
6803
+ get protocol() {
6804
+ return "file";
6805
+ }
6806
+ };
6807
+ return daemonClient;
6808
+ }
6809
+ } catch {
6810
+ }
6811
+ const { initStore: initStore2 } = await Promise.resolve().then(() => (init_store(), store_exports));
6812
+ await initStore2({ lightweight: true });
6813
+ return getClient2();
6814
+ }
6815
+ var init_fast_db_init = __esm({
6816
+ "src/bin/fast-db-init.ts"() {
6817
+ "use strict";
6818
+ }
6819
+ });
6820
+
6607
6821
  // src/lib/catchup-brief.ts
6608
6822
  var catchup_brief_exports = {};
6609
6823
  __export(catchup_brief_exports, {
@@ -6859,7 +7073,6 @@ process.stdin.on("data", (chunk) => {
6859
7073
  });
6860
7074
  process.stdin.on("end", async () => {
6861
7075
  try {
6862
- const { initStore: initStore2 } = await Promise.resolve().then(() => (init_store(), store_exports));
6863
7076
  const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
6864
7077
  const { lightweightSearch: lightweightSearch2 } = await Promise.resolve().then(() => (init_hybrid_search(), hybrid_search_exports));
6865
7078
  const { getActiveAgent: getActiveAgent2 } = await Promise.resolve().then(() => (init_active_agent2(), active_agent_exports));
@@ -6881,7 +7094,8 @@ process.stdin.on("end", async () => {
6881
7094
  } catch {
6882
7095
  }
6883
7096
  }
6884
- await initStore2({ dbPath: hookConfig.dbPath, lightweight: true });
7097
+ const { fastDbInit: fastDbInit2 } = await Promise.resolve().then(() => (init_fast_db_init(), fast_db_init_exports));
7098
+ await fastDbInit2();
6885
7099
  const agent = getActiveAgent2();
6886
7100
  const agentId = agent.agentId;
6887
7101
  if (agentId !== "default") {