@askexenow/exe-os 0.9.34 → 0.9.36

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 (76) hide show
  1. package/dist/bin/backfill-conversations.js +212 -11
  2. package/dist/bin/backfill-responses.js +212 -11
  3. package/dist/bin/backfill-vectors.js +14 -3
  4. package/dist/bin/cleanup-stale-review-tasks.js +224 -12
  5. package/dist/bin/cli.js +265 -23
  6. package/dist/bin/exe-agent.js +1 -1
  7. package/dist/bin/exe-assign.js +217 -12
  8. package/dist/bin/exe-boot.js +25 -4
  9. package/dist/bin/exe-call.js +7 -5
  10. package/dist/bin/exe-dispatch.js +229 -13
  11. package/dist/bin/exe-doctor.js +14 -3
  12. package/dist/bin/exe-export-behaviors.js +301 -14
  13. package/dist/bin/exe-forget.js +245 -21
  14. package/dist/bin/exe-gateway.js +229 -13
  15. package/dist/bin/exe-heartbeat.js +224 -12
  16. package/dist/bin/exe-kill.js +224 -12
  17. package/dist/bin/exe-launch-agent.js +177 -9
  18. package/dist/bin/exe-link.js +8 -0
  19. package/dist/bin/exe-new-employee.js +26 -2
  20. package/dist/bin/exe-pending-messages.js +224 -12
  21. package/dist/bin/exe-pending-notifications.js +224 -12
  22. package/dist/bin/exe-pending-reviews.js +224 -12
  23. package/dist/bin/exe-rename.js +9 -1
  24. package/dist/bin/exe-review.js +224 -12
  25. package/dist/bin/exe-search.js +246 -21
  26. package/dist/bin/exe-session-cleanup.js +229 -13
  27. package/dist/bin/exe-start-codex.js +161 -5
  28. package/dist/bin/exe-start-opencode.js +172 -5
  29. package/dist/bin/exe-status.js +224 -12
  30. package/dist/bin/exe-team.js +224 -12
  31. package/dist/bin/git-sweep.js +229 -13
  32. package/dist/bin/graph-backfill.js +94 -3
  33. package/dist/bin/graph-export.js +224 -12
  34. package/dist/bin/install.js +25 -1
  35. package/dist/bin/intercom-check.js +229 -13
  36. package/dist/bin/scan-tasks.js +229 -13
  37. package/dist/bin/setup.js +15 -5
  38. package/dist/bin/shard-migrate.js +94 -3
  39. package/dist/gateway/index.js +229 -13
  40. package/dist/hooks/bug-report-worker.js +229 -13
  41. package/dist/hooks/codex-stop-task-finalizer.js +224 -12
  42. package/dist/hooks/commit-complete.js +229 -13
  43. package/dist/hooks/error-recall.js +246 -21
  44. package/dist/hooks/ingest.js +224 -12
  45. package/dist/hooks/instructions-loaded.js +224 -12
  46. package/dist/hooks/notification.js +224 -12
  47. package/dist/hooks/post-compact.js +224 -12
  48. package/dist/hooks/post-tool-combined.js +246 -21
  49. package/dist/hooks/pre-compact.js +229 -13
  50. package/dist/hooks/pre-tool-use.js +234 -18
  51. package/dist/hooks/prompt-submit.js +346 -23
  52. package/dist/hooks/session-end.js +229 -13
  53. package/dist/hooks/session-start.js +418 -42
  54. package/dist/hooks/stop.js +224 -12
  55. package/dist/hooks/subagent-stop.js +224 -12
  56. package/dist/hooks/summary-worker.js +15 -2
  57. package/dist/index.js +229 -13
  58. package/dist/lib/cloud-sync.js +8 -0
  59. package/dist/lib/consolidation.js +3 -1
  60. package/dist/lib/database.js +8 -0
  61. package/dist/lib/db.js +8 -0
  62. package/dist/lib/device-registry.js +8 -0
  63. package/dist/lib/employee-templates.js +7 -5
  64. package/dist/lib/exe-daemon.js +1776 -1433
  65. package/dist/lib/hybrid-search.js +246 -21
  66. package/dist/lib/schedules.js +14 -3
  67. package/dist/lib/store.js +217 -12
  68. package/dist/lib/tasks.js +5 -1
  69. package/dist/lib/tmux-routing.js +5 -1
  70. package/dist/mcp/server.js +331 -37
  71. package/dist/mcp/tools/create-task.js +5 -1
  72. package/dist/mcp/tools/update-task.js +5 -1
  73. package/dist/runtime/index.js +229 -13
  74. package/dist/tui/App.js +229 -13
  75. package/package.json +1 -1
  76. package/src/commands/exe/save.md +48 -0
@@ -2866,6 +2866,14 @@ async function ensureSchema() {
2866
2866
  );
2867
2867
  } catch {
2868
2868
  }
2869
+ try {
2870
+ await client.execute(
2871
+ `CREATE INDEX IF NOT EXISTS idx_memories_scoped_content_hash
2872
+ ON memories(content_hash, agent_id, project_name, memory_type)
2873
+ WHERE content_hash IS NOT NULL`
2874
+ );
2875
+ } catch {
2876
+ }
2869
2877
  await client.executeMultiple(`
2870
2878
  CREATE TABLE IF NOT EXISTS entities (
2871
2879
  id TEXT PRIMARY KEY,
@@ -6381,7 +6389,11 @@ function spawnEmployee(employeeName, exeSession, projectDir, opts) {
6381
6389
  }
6382
6390
  if (!useExeAgent && !useCodex && !useOpencode && !useBinSymlink) {
6383
6391
  if (agentRtConfig.runtime === "claude" && agentRtConfig.model) {
6384
- envPrefix = `${envPrefix} ANTHROPIC_MODEL=${agentRtConfig.model}`;
6392
+ let ccModel = agentRtConfig.model.replace(/(\d+)\.(\d+)/g, "$1-$2");
6393
+ if (/claude-(opus|sonnet)-4-[6-9]/.test(ccModel) && !ccModel.includes("[1m]")) {
6394
+ ccModel += "[1m]";
6395
+ }
6396
+ envPrefix = `${envPrefix} ANTHROPIC_MODEL=${ccModel}`;
6385
6397
  }
6386
6398
  }
6387
6399
  let spawnCommand;
@@ -6728,6 +6740,197 @@ var init_keychain = __esm({
6728
6740
  }
6729
6741
  });
6730
6742
 
6743
+ // src/lib/memory-write-governor.ts
6744
+ import { createHash } from "crypto";
6745
+ function normalizeMemoryText(text) {
6746
+ return text.replace(/\r\n/g, "\n").replace(/[ \t]+$/gm, "").replace(/\n{4,}/g, "\n\n\n").trim();
6747
+ }
6748
+ function classifyMemoryType(input) {
6749
+ if (input.memory_type && input.memory_type.trim()) return input.memory_type.trim();
6750
+ const tool = input.tool_name.toLowerCase();
6751
+ const text = input.raw_text.toLowerCase();
6752
+ if (tool.includes("store_decision") || tool.includes("decision")) return "decision";
6753
+ if (tool.includes("commit") || text.includes("adr-") || text.includes("architectural decision")) return "adr";
6754
+ if (tool.includes("store_behavior") || tool.includes("behavior")) return "behavior";
6755
+ if (tool.includes("global_procedure") || text.includes("organization-wide procedures")) return "procedure";
6756
+ if (tool.includes("send_whatsapp") || tool.includes("conversation")) return "conversation";
6757
+ if (tool === "store_memory" || tool === "manual") return "observation";
6758
+ return "raw";
6759
+ }
6760
+ function shouldDropMemory(text) {
6761
+ const normalized = normalizeMemoryText(text);
6762
+ if (normalized.length < 10) return { drop: true, reason: "too_short" };
6763
+ if (NOISE_DROP_PATTERNS.some((pattern) => pattern.test(normalized))) {
6764
+ return { drop: true, reason: "known_boilerplate_noise" };
6765
+ }
6766
+ return { drop: false };
6767
+ }
6768
+ function shouldSkipEmbedding(input) {
6769
+ const type = classifyMemoryType(input);
6770
+ if (HIGH_VALUE_SUPERSESSION_TYPES.has(type)) return false;
6771
+ if (type === "raw" && input.raw_text.length > 2e4) return true;
6772
+ if (SKIP_EMBED_PATTERNS.some((pattern) => pattern.test(input.raw_text))) return true;
6773
+ return false;
6774
+ }
6775
+ function hashMemoryContent(text) {
6776
+ return createHash("sha256").update(normalizeMemoryText(text)).digest("hex");
6777
+ }
6778
+ function scopedDedupArgs(input) {
6779
+ return [input.contentHash, input.agentId, input.projectName, input.memoryType];
6780
+ }
6781
+ function governMemoryRecord(record) {
6782
+ const normalized = normalizeMemoryText(record.raw_text);
6783
+ const memoryType = classifyMemoryType({
6784
+ raw_text: normalized,
6785
+ agent_id: record.agent_id,
6786
+ project_name: record.project_name,
6787
+ tool_name: record.tool_name,
6788
+ memory_type: record.memory_type
6789
+ });
6790
+ const drop = shouldDropMemory(normalized);
6791
+ const skipEmbedding = shouldSkipEmbedding({
6792
+ raw_text: normalized,
6793
+ agent_id: record.agent_id,
6794
+ project_name: record.project_name,
6795
+ tool_name: record.tool_name,
6796
+ memory_type: memoryType
6797
+ });
6798
+ return {
6799
+ record: {
6800
+ ...record,
6801
+ raw_text: normalized,
6802
+ memory_type: memoryType,
6803
+ vector: skipEmbedding ? null : record.vector
6804
+ },
6805
+ contentHash: hashMemoryContent(normalized),
6806
+ shouldDrop: drop.drop,
6807
+ dropReason: drop.reason,
6808
+ skipEmbedding,
6809
+ hygiene: {
6810
+ dedup: true,
6811
+ supersession: HIGH_VALUE_SUPERSESSION_TYPES.has(memoryType)
6812
+ }
6813
+ };
6814
+ }
6815
+ async function findScopedDuplicate(input) {
6816
+ const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
6817
+ const client = getClient2();
6818
+ const args = scopedDedupArgs(input);
6819
+ let sql = `SELECT id FROM memories
6820
+ WHERE content_hash = ?
6821
+ AND agent_id = ?
6822
+ AND project_name = ?
6823
+ AND COALESCE(memory_type, 'raw') = ?
6824
+ AND COALESCE(status, 'active') != 'deleted'`;
6825
+ if (input.excludeId) {
6826
+ sql += " AND id != ?";
6827
+ args.push(input.excludeId);
6828
+ }
6829
+ sql += " ORDER BY timestamp DESC LIMIT 1";
6830
+ const result = await client.execute({ sql, args });
6831
+ return result.rows[0]?.id ? String(result.rows[0].id) : null;
6832
+ }
6833
+ async function runPostWriteMemoryHygiene(memoryId) {
6834
+ try {
6835
+ const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
6836
+ const client = getClient2();
6837
+ const current = await client.execute({
6838
+ sql: `SELECT id, agent_id, project_name, memory_type, content_hash, supersedes_id,
6839
+ importance, timestamp
6840
+ FROM memories
6841
+ WHERE id = ?
6842
+ LIMIT 1`,
6843
+ args: [memoryId]
6844
+ });
6845
+ const row = current.rows[0];
6846
+ if (!row) return;
6847
+ const memoryType = String(row.memory_type ?? "raw");
6848
+ const contentHash = row.content_hash ? String(row.content_hash) : null;
6849
+ const agentId = String(row.agent_id);
6850
+ const projectName = String(row.project_name);
6851
+ if (contentHash) {
6852
+ await client.execute({
6853
+ sql: `UPDATE memories
6854
+ SET status = 'deleted',
6855
+ outcome = COALESCE(outcome, 'superseded')
6856
+ WHERE id != ?
6857
+ AND content_hash = ?
6858
+ AND agent_id = ?
6859
+ AND project_name = ?
6860
+ AND COALESCE(memory_type, 'raw') = ?
6861
+ AND COALESCE(status, 'active') = 'active'`,
6862
+ args: [memoryId, contentHash, agentId, projectName, memoryType]
6863
+ });
6864
+ }
6865
+ const supersedesId = row.supersedes_id ? String(row.supersedes_id) : null;
6866
+ if (supersedesId && HIGH_VALUE_SUPERSESSION_TYPES.has(memoryType)) {
6867
+ const old = await client.execute({
6868
+ sql: `SELECT importance FROM memories WHERE id = ? LIMIT 1`,
6869
+ args: [supersedesId]
6870
+ });
6871
+ const oldImportance = Number(old.rows[0]?.importance ?? 0);
6872
+ const newImportance = Number(row.importance ?? 0);
6873
+ await client.batch([
6874
+ {
6875
+ sql: `UPDATE memories
6876
+ SET status = 'archived',
6877
+ outcome = COALESCE(outcome, 'superseded')
6878
+ WHERE id = ?`,
6879
+ args: [supersedesId]
6880
+ },
6881
+ {
6882
+ sql: `UPDATE memories
6883
+ SET importance = MAX(COALESCE(importance, 5), ?),
6884
+ parent_memory_id = COALESCE(parent_memory_id, ?)
6885
+ WHERE id = ?`,
6886
+ args: [Math.max(oldImportance, newImportance), supersedesId, memoryId]
6887
+ }
6888
+ ], "write");
6889
+ }
6890
+ } catch (err) {
6891
+ process.stderr.write(
6892
+ `[memory-governor] post-write hygiene failed for ${memoryId}: ${err instanceof Error ? err.message : String(err)}
6893
+ `
6894
+ );
6895
+ }
6896
+ }
6897
+ function schedulePostWriteMemoryHygiene(memoryIds) {
6898
+ if (process.env.EXE_SKIP_MEMORY_HYGIENE === "1") return;
6899
+ if (memoryIds.length === 0) return;
6900
+ const run = () => {
6901
+ void Promise.all(memoryIds.map((id) => runPostWriteMemoryHygiene(id)));
6902
+ };
6903
+ if (typeof setImmediate === "function") setImmediate(run);
6904
+ else setTimeout(run, 0);
6905
+ }
6906
+ var HIGH_VALUE_SUPERSESSION_TYPES, NOISE_DROP_PATTERNS, SKIP_EMBED_PATTERNS;
6907
+ var init_memory_write_governor = __esm({
6908
+ "src/lib/memory-write-governor.ts"() {
6909
+ "use strict";
6910
+ HIGH_VALUE_SUPERSESSION_TYPES = /* @__PURE__ */ new Set([
6911
+ "decision",
6912
+ "adr",
6913
+ "behavior",
6914
+ "procedure"
6915
+ ]);
6916
+ NOISE_DROP_PATTERNS = [
6917
+ /^\s*\[📋\s+\d+\s+reviews?\s+pending\b/im,
6918
+ /^\s*<system-reminder>[\s\S]*?<\/system-reminder>\s*$/im,
6919
+ /^\s*The UserPromptSubmit hook checks the DB for new tasks/im,
6920
+ /^\s*Intercom is a speedup, not delivery/im,
6921
+ /^\s*Context bar reads as USAGE not remaining/im
6922
+ ];
6923
+ SKIP_EMBED_PATTERNS = [
6924
+ /tmux capture-pane\b/i,
6925
+ /docker ps\b/i,
6926
+ /docker images\b/i,
6927
+ /git status\b/i,
6928
+ /grep .*node_modules/i,
6929
+ /npm (install|ci)\b[\s\S]*(added \d+ packages|audited \d+ packages)/i
6930
+ ];
6931
+ }
6932
+ });
6933
+
6731
6934
  // src/lib/shard-manager.ts
6732
6935
  var shard_manager_exports = {};
6733
6936
  __export(shard_manager_exports, {
@@ -6892,7 +7095,8 @@ async function ensureShardSchema(client) {
6892
7095
  }
6893
7096
  for (const idx of [
6894
7097
  "CREATE INDEX IF NOT EXISTS idx_memories_tier ON memories(tier)",
6895
- "CREATE INDEX IF NOT EXISTS idx_memories_supersedes ON memories(supersedes_id) WHERE supersedes_id IS NOT NULL"
7098
+ "CREATE INDEX IF NOT EXISTS idx_memories_supersedes ON memories(supersedes_id) WHERE supersedes_id IS NOT NULL",
7099
+ "CREATE INDEX IF NOT EXISTS idx_memories_scoped_content_hash ON memories(content_hash, agent_id, project_name, memory_type) WHERE content_hash IS NOT NULL"
6896
7100
  ]) {
6897
7101
  try {
6898
7102
  await client.execute(idx);
@@ -7086,7 +7290,7 @@ var init_platform_procedures = __esm({
7086
7290
  title: "Chain of command \u2014 who talks to whom",
7087
7291
  domain: "workflow",
7088
7292
  priority: "p0",
7089
- 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."
7293
+ 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."
7090
7294
  },
7091
7295
  {
7092
7296
  title: "Single dispatch path \u2014 create_task only",
@@ -7317,7 +7521,6 @@ __export(store_exports, {
7317
7521
  vectorToBlob: () => vectorToBlob,
7318
7522
  writeMemory: () => writeMemory
7319
7523
  });
7320
- import { createHash } from "crypto";
7321
7524
  function isBusyError2(err) {
7322
7525
  if (err instanceof Error) {
7323
7526
  const msg = err.message.toLowerCase();
@@ -7431,17 +7634,24 @@ async function writeMemory(record) {
7431
7634
  `Expected ${EMBEDDING_DIM}-dim vector, got ${record.vector.length}`
7432
7635
  );
7433
7636
  }
7434
- const contentHash = createHash("md5").update(record.raw_text).digest("hex");
7435
- if (_pendingRecords.some((r) => r.content_hash === contentHash && r.agent_id === record.agent_id)) {
7637
+ const governed = governMemoryRecord(record);
7638
+ if (governed.shouldDrop) return;
7639
+ record = governed.record;
7640
+ const contentHash = governed.contentHash;
7641
+ const memoryType = record.memory_type ?? "raw";
7642
+ if (_pendingRecords.some(
7643
+ (r) => r.content_hash === contentHash && r.agent_id === record.agent_id && r.project_name === record.project_name && (r.memory_type ?? "raw") === memoryType
7644
+ )) {
7436
7645
  return;
7437
7646
  }
7438
7647
  try {
7439
- const client = getClient();
7440
- const existing = await client.execute({
7441
- sql: "SELECT id FROM memories WHERE content_hash = ? AND agent_id = ? LIMIT 1",
7442
- args: [contentHash, record.agent_id]
7648
+ const existing = await findScopedDuplicate({
7649
+ contentHash,
7650
+ agentId: record.agent_id,
7651
+ projectName: record.project_name,
7652
+ memoryType
7443
7653
  });
7444
- if (existing.rows.length > 0) return;
7654
+ if (existing) return;
7445
7655
  } catch {
7446
7656
  }
7447
7657
  const dbRow = {
@@ -7472,7 +7682,7 @@ async function writeMemory(record) {
7472
7682
  tier: record.tier ?? classifyTier(record),
7473
7683
  supersedes_id: record.supersedes_id ?? null,
7474
7684
  draft: record.draft ? 1 : 0,
7475
- memory_type: record.memory_type ?? "raw",
7685
+ memory_type: memoryType,
7476
7686
  trajectory: record.trajectory ? JSON.stringify(record.trajectory) : null,
7477
7687
  content_hash: contentHash,
7478
7688
  intent: record.intent ?? null,
@@ -7631,6 +7841,7 @@ async function flushBatch() {
7631
7841
  const globalClient = getClient();
7632
7842
  const globalStmts = batch.map(buildStmt);
7633
7843
  await globalClient.batch(globalStmts, "write");
7844
+ schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
7634
7845
  _pendingRecords.splice(0, batch.length);
7635
7846
  try {
7636
7847
  const { isShardingEnabled: isShardingEnabled2, getReadyShardClient: getReadyShardClient2 } = await Promise.resolve().then(() => (init_shard_manager(), shard_manager_exports));
@@ -7751,7 +7962,11 @@ async function searchMemories(queryVector, agentId, options) {
7751
7962
  sql += ` AND timestamp >= ?`;
7752
7963
  args.push(options.since);
7753
7964
  }
7754
- if (options?.memoryType) {
7965
+ if (options?.memoryTypes && options.memoryTypes.length > 0) {
7966
+ const uniqueTypes = [...new Set(options.memoryTypes)];
7967
+ sql += ` AND memory_type IN (${uniqueTypes.map(() => "?").join(",")})`;
7968
+ args.push(...uniqueTypes);
7969
+ } else if (options?.memoryType) {
7755
7970
  sql += ` AND memory_type = ?`;
7756
7971
  args.push(options.memoryType);
7757
7972
  }
@@ -7889,6 +8104,7 @@ var init_store = __esm({
7889
8104
  init_keychain();
7890
8105
  init_config();
7891
8106
  init_state_bus();
8107
+ init_memory_write_governor();
7892
8108
  INIT_MAX_RETRIES = 3;
7893
8109
  INIT_RETRY_DELAY_MS = 1e3;
7894
8110
  _pendingRecords = [];