@askexenow/exe-os 0.9.93 → 0.9.95

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 (88) hide show
  1. package/deploy/compose/docker-compose.yml +1 -0
  2. package/dist/bin/agentic-ontology-backfill.js +65 -8
  3. package/dist/bin/agentic-reflection-backfill.js +54 -3
  4. package/dist/bin/agentic-semantic-label.js +54 -3
  5. package/dist/bin/backfill-conversations.js +69 -9
  6. package/dist/bin/backfill-responses.js +69 -9
  7. package/dist/bin/backfill-vectors.js +54 -3
  8. package/dist/bin/bulk-sync-postgres.js +66 -8
  9. package/dist/bin/cleanup-stale-review-tasks.js +121 -13
  10. package/dist/bin/cli.js +1561 -466
  11. package/dist/bin/customer-readiness.js +61 -0
  12. package/dist/bin/exe-agent.js +17 -3
  13. package/dist/bin/exe-assign.js +75 -9
  14. package/dist/bin/exe-boot.js +114 -12
  15. package/dist/bin/exe-call.js +17 -3
  16. package/dist/bin/exe-cloud.js +76 -10
  17. package/dist/bin/exe-dispatch.js +136 -18
  18. package/dist/bin/exe-doctor.js +75 -9
  19. package/dist/bin/exe-export-behaviors.js +75 -9
  20. package/dist/bin/exe-forget.js +94 -9
  21. package/dist/bin/exe-gateway.js +135 -18
  22. package/dist/bin/exe-heartbeat.js +121 -13
  23. package/dist/bin/exe-kill.js +75 -9
  24. package/dist/bin/exe-launch-agent.js +75 -9
  25. package/dist/bin/exe-new-employee.js +18 -4
  26. package/dist/bin/exe-pending-messages.js +121 -13
  27. package/dist/bin/exe-pending-notifications.js +121 -13
  28. package/dist/bin/exe-pending-reviews.js +121 -13
  29. package/dist/bin/exe-rename.js +75 -9
  30. package/dist/bin/exe-review.js +75 -9
  31. package/dist/bin/exe-search.js +100 -9
  32. package/dist/bin/exe-session-cleanup.js +136 -18
  33. package/dist/bin/exe-settings.js +1 -0
  34. package/dist/bin/exe-start-codex.js +65 -8
  35. package/dist/bin/exe-start-opencode.js +65 -8
  36. package/dist/bin/exe-status.js +121 -13
  37. package/dist/bin/exe-support.js +1 -0
  38. package/dist/bin/exe-team.js +75 -9
  39. package/dist/bin/git-sweep.js +136 -18
  40. package/dist/bin/graph-backfill.js +65 -8
  41. package/dist/bin/graph-export.js +75 -9
  42. package/dist/bin/intercom-check.js +136 -18
  43. package/dist/bin/scan-tasks.js +136 -18
  44. package/dist/bin/setup.js +55 -4
  45. package/dist/bin/shard-migrate.js +65 -8
  46. package/dist/bin/stack-update.js +5 -6
  47. package/dist/bin/update.js +1 -1
  48. package/dist/gateway/index.js +136 -18
  49. package/dist/hooks/bug-report-worker.js +136 -18
  50. package/dist/hooks/codex-stop-task-finalizer.js +126 -14
  51. package/dist/hooks/commit-complete.js +136 -18
  52. package/dist/hooks/error-recall.js +100 -9
  53. package/dist/hooks/ingest.js +75 -9
  54. package/dist/hooks/instructions-loaded.js +75 -9
  55. package/dist/hooks/notification.js +75 -9
  56. package/dist/hooks/post-compact.js +313 -50
  57. package/dist/hooks/post-tool-combined.js +436 -13
  58. package/dist/hooks/pre-compact.js +136 -18
  59. package/dist/hooks/pre-tool-use.js +121 -13
  60. package/dist/hooks/prompt-submit.js +194 -19
  61. package/dist/hooks/session-end.js +136 -18
  62. package/dist/hooks/session-start.js +146 -13
  63. package/dist/hooks/stop.js +121 -13
  64. package/dist/hooks/subagent-stop.js +121 -13
  65. package/dist/hooks/summary-worker.js +99 -7
  66. package/dist/index.js +136 -18
  67. package/dist/lib/cloud-sync.js +38 -0
  68. package/dist/lib/consolidation.js +3 -1
  69. package/dist/lib/database.js +37 -0
  70. package/dist/lib/db.js +37 -0
  71. package/dist/lib/device-registry.js +37 -0
  72. package/dist/lib/employee-templates.js +17 -3
  73. package/dist/lib/exe-daemon.js +916 -42
  74. package/dist/lib/hybrid-search.js +100 -9
  75. package/dist/lib/license.js +1 -1
  76. package/dist/lib/messaging.js +43 -4
  77. package/dist/lib/schedules.js +54 -3
  78. package/dist/lib/store.js +75 -9
  79. package/dist/lib/tasks.js +61 -9
  80. package/dist/lib/tmux-routing.js +61 -9
  81. package/dist/mcp/server.js +878 -42
  82. package/dist/mcp/tools/create-task.js +70 -12
  83. package/dist/mcp/tools/list-tasks.js +49 -5
  84. package/dist/mcp/tools/send-message.js +43 -4
  85. package/dist/mcp/tools/update-task.js +61 -9
  86. package/dist/runtime/index.js +136 -18
  87. package/dist/tui/App.js +135 -18
  88. package/package.json +1 -1
@@ -3334,6 +3334,20 @@ async function ensureSchema() {
3334
3334
  });
3335
3335
  } catch {
3336
3336
  }
3337
+ try {
3338
+ await client.execute({
3339
+ sql: `ALTER TABLE tasks ADD COLUMN spawn_runtime TEXT`,
3340
+ args: []
3341
+ });
3342
+ } catch {
3343
+ }
3344
+ try {
3345
+ await client.execute({
3346
+ sql: `ALTER TABLE tasks ADD COLUMN spawn_model TEXT`,
3347
+ args: []
3348
+ });
3349
+ } catch {
3350
+ }
3337
3351
  await client.executeMultiple(`
3338
3352
  CREATE VIRTUAL TABLE IF NOT EXISTS conversations_fts USING fts5(
3339
3353
  content_text,
@@ -3585,6 +3599,22 @@ async function ensureSchema() {
3585
3599
  );
3586
3600
  } catch {
3587
3601
  }
3602
+ for (const col of [
3603
+ "ALTER TABLE memories ADD COLUMN valid_from TEXT",
3604
+ "ALTER TABLE memories ADD COLUMN invalid_at TEXT"
3605
+ ]) {
3606
+ try {
3607
+ await client.execute(col);
3608
+ } catch {
3609
+ }
3610
+ }
3611
+ try {
3612
+ await client.execute({
3613
+ sql: `UPDATE memories SET valid_from = timestamp WHERE valid_from IS NULL`,
3614
+ args: []
3615
+ });
3616
+ } catch {
3617
+ }
3588
3618
  try {
3589
3619
  await client.execute({
3590
3620
  sql: `ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'`,
@@ -3627,6 +3657,13 @@ async function ensureSchema() {
3627
3657
  } catch {
3628
3658
  }
3629
3659
  }
3660
+ try {
3661
+ await client.execute({
3662
+ sql: `ALTER TABLE memories ADD COLUMN procedure_for TEXT`,
3663
+ args: []
3664
+ });
3665
+ } catch {
3666
+ }
3630
3667
  try {
3631
3668
  await client.execute({
3632
3669
  sql: `UPDATE tasks SET status = 'closed' WHERE status = 'done' AND result IS NOT NULL`,
@@ -3687,7 +3724,7 @@ import { pathToFileURL as pathToFileURL2 } from "url";
3687
3724
  import os8 from "os";
3688
3725
  import path10 from "path";
3689
3726
  import { jwtVerify, importSPKI } from "jose";
3690
- var LICENSE_PATH, CACHE_PATH, DEVICE_ID_PATH, PLAN_LIMITS;
3727
+ var LICENSE_PATH, CACHE_PATH, DEVICE_ID_PATH, API_BASE, PLAN_LIMITS;
3691
3728
  var init_license = __esm({
3692
3729
  "src/lib/license.ts"() {
3693
3730
  "use strict";
@@ -3695,6 +3732,7 @@ var init_license = __esm({
3695
3732
  LICENSE_PATH = path10.join(EXE_AI_DIR, "license.key");
3696
3733
  CACHE_PATH = path10.join(EXE_AI_DIR, "license-cache.json");
3697
3734
  DEVICE_ID_PATH = path10.join(EXE_AI_DIR, "device-id");
3735
+ API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://askexe.com/cloud";
3698
3736
  PLAN_LIMITS = {
3699
3737
  free: { devices: 1, employees: 1, memories: 5e3 },
3700
3738
  pro: { devices: 3, employees: 5, memories: 1e5 },
@@ -4351,8 +4389,8 @@ ${scopeMismatchWarning}` : scopeMismatchWarning;
4351
4389
  const complexity = input.complexity ?? "standard";
4352
4390
  const sessionScope = earlySessionScope;
4353
4391
  await client.execute({
4354
- sql: `INSERT INTO tasks (id, title, assigned_to, assigned_by, project_name, priority, status, task_file, blocked_by, parent_task_id, reviewer, context, complexity, budget_tokens, budget_fallback_model, tokens_used, tokens_warned_at, session_scope, created_at, updated_at)
4355
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
4392
+ sql: `INSERT INTO tasks (id, title, assigned_to, assigned_by, project_name, priority, status, task_file, blocked_by, parent_task_id, reviewer, context, complexity, budget_tokens, budget_fallback_model, tokens_used, tokens_warned_at, session_scope, spawn_runtime, spawn_model, created_at, updated_at)
4393
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
4356
4394
  args: [
4357
4395
  id,
4358
4396
  input.title,
@@ -4372,6 +4410,8 @@ ${scopeMismatchWarning}` : scopeMismatchWarning;
4372
4410
  0,
4373
4411
  null,
4374
4412
  sessionScope,
4413
+ input.spawnRuntime ?? null,
4414
+ input.spawnModel ?? null,
4375
4415
  now,
4376
4416
  now
4377
4417
  ]
@@ -4428,7 +4468,9 @@ ${input.context}
4428
4468
  budgetTokens: input.budgetTokens ?? null,
4429
4469
  budgetFallbackModel: input.budgetFallbackModel ?? null,
4430
4470
  tokensUsed: 0,
4431
- tokensWarnedAt: null
4471
+ tokensWarnedAt: null,
4472
+ spawnRuntime: input.spawnRuntime ?? null,
4473
+ spawnModel: input.spawnModel ?? null
4432
4474
  };
4433
4475
  }
4434
4476
  async function listTasks(input) {
@@ -4478,7 +4520,9 @@ async function listTasks(input) {
4478
4520
  budgetTokens: r.budget_tokens !== null ? Number(r.budget_tokens) : null,
4479
4521
  budgetFallbackModel: r.budget_fallback_model !== null ? String(r.budget_fallback_model) : null,
4480
4522
  tokensUsed: Number(r.tokens_used ?? 0),
4481
- tokensWarnedAt: r.tokens_warned_at !== null ? Number(r.tokens_warned_at) : null
4523
+ tokensWarnedAt: r.tokens_warned_at !== null ? Number(r.tokens_warned_at) : null,
4524
+ spawnRuntime: r.spawn_runtime !== null && r.spawn_runtime !== void 0 ? String(r.spawn_runtime) : null,
4525
+ spawnModel: r.spawn_model !== null && r.spawn_model !== void 0 ? String(r.spawn_model) : null
4482
4526
  }));
4483
4527
  }
4484
4528
  function isTmuxSessionAlive(identifier) {
@@ -5846,6 +5890,8 @@ async function updateTask(input) {
5846
5890
  budgetFallbackModel: row.budget_fallback_model !== void 0 && row.budget_fallback_model !== null ? String(row.budget_fallback_model) : null,
5847
5891
  tokensUsed: Number(row.tokens_used ?? 0),
5848
5892
  tokensWarnedAt: row.tokens_warned_at !== void 0 && row.tokens_warned_at !== null ? Number(row.tokens_warned_at) : null,
5893
+ spawnRuntime: row.spawn_runtime !== void 0 && row.spawn_runtime !== null ? String(row.spawn_runtime) : null,
5894
+ spawnModel: row.spawn_model !== void 0 && row.spawn_model !== null ? String(row.spawn_model) : null,
5849
5895
  nextTask
5850
5896
  };
5851
5897
  }
@@ -6338,9 +6384,13 @@ function getDispatchedBy(sessionKey) {
6338
6384
  }
6339
6385
  }
6340
6386
  function resolveExeSession() {
6387
+ if (process.env.EXE_SESSION_NAME) {
6388
+ return extractRootExe(process.env.EXE_SESSION_NAME) ?? process.env.EXE_SESSION_NAME;
6389
+ }
6341
6390
  const mySession = getMySession();
6342
6391
  if (!mySession) return null;
6343
6392
  const fromSessionName = extractRootExe(mySession);
6393
+ let candidate = null;
6344
6394
  try {
6345
6395
  const key = getSessionKey();
6346
6396
  const parentExe = getParentExe(key);
@@ -6351,13 +6401,47 @@ function resolveExeSession() {
6351
6401
  `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
6352
6402
  `
6353
6403
  );
6354
- return fromSessionName;
6404
+ candidate = fromSessionName;
6405
+ } else {
6406
+ candidate = fromCache;
6355
6407
  }
6356
- return fromCache;
6357
6408
  }
6358
6409
  } catch {
6359
6410
  }
6360
- return fromSessionName ?? mySession;
6411
+ if (!candidate) {
6412
+ candidate = fromSessionName ?? mySession;
6413
+ }
6414
+ if (candidate && isRootSession(candidate)) {
6415
+ try {
6416
+ const transport = getTransport();
6417
+ const liveSessions = transport.listSessions();
6418
+ if (!liveSessions.includes(candidate)) {
6419
+ const liveRoots = liveSessions.filter((s) => isRootSession(s));
6420
+ if (liveRoots.length === 1) {
6421
+ process.stderr.write(
6422
+ `[tmux-routing] WARN: resolved session "${candidate}" is dead. Using live coordinator "${liveRoots[0]}".
6423
+ `
6424
+ );
6425
+ return liveRoots[0];
6426
+ } else if (liveRoots.length > 1) {
6427
+ const base = candidate.replace(/\d+$/, "");
6428
+ const match = liveRoots.find((s) => s.startsWith(base));
6429
+ const chosen = match ?? liveRoots[0];
6430
+ process.stderr.write(
6431
+ `[tmux-routing] WARN: resolved session "${candidate}" is dead. ${liveRoots.length} live roots found, using "${chosen}".
6432
+ `
6433
+ );
6434
+ return chosen;
6435
+ }
6436
+ process.stderr.write(
6437
+ `[tmux-routing] WARN: resolved session "${candidate}" is dead and no live coordinator found.
6438
+ `
6439
+ );
6440
+ }
6441
+ } catch {
6442
+ }
6443
+ }
6444
+ return candidate;
6361
6445
  }
6362
6446
  function isEmployeeAlive(sessionName) {
6363
6447
  return getTransport().isAlive(sessionName);
@@ -6759,7 +6843,12 @@ function spawnEmployee(employeeName, exeSession, projectDir, opts) {
6759
6843
  }
6760
6844
  const spawnCwd = opts?.cwd ?? projectDir;
6761
6845
  const useExeAgent = !!(opts?.model && opts?.provider);
6762
- const agentRtConfig = getAgentRuntime(employeeName);
6846
+ const baseRtConfig = getAgentRuntime(employeeName);
6847
+ const agentRtConfig = {
6848
+ ...baseRtConfig,
6849
+ ...opts?.runtimeOverride ? { runtime: opts.runtimeOverride } : {},
6850
+ ...opts?.modelOverride ? { model: opts.modelOverride } : {}
6851
+ };
6763
6852
  const useCodex = !useExeAgent && agentRtConfig.runtime === "codex";
6764
6853
  const useOpencode = !useExeAgent && !useCodex && agentRtConfig.runtime === "opencode";
6765
6854
  const ccProvider = useExeAgent || useCodex || useOpencode ? DEFAULT_PROVIDER : detectActiveProvider();
@@ -8019,6 +8108,20 @@ var init_platform_procedures = __esm({
8019
8108
  priority: "p1",
8020
8109
  content: "Once per session (COO boot only, never repeat), call list_my_feature_requests to check if any previously filed feature requests have been shipped by AskExe. If any request has status 'shipped' with a shipped_version, surface it to the founder immediately: '\u{1F680} N feature(s) shipped \u2014 run exe-os update to get version X.Y.Z'. This is a one-time check at boot, not a recurring poll. If no requests exist or none are shipped, skip silently. If the MCP tool is unavailable or the network call fails, skip silently \u2014 this is informational, not blocking."
8021
8110
  },
8111
+ // --- Tool guidance ---
8112
+ {
8113
+ title: "How to use company_actions \u2014 execute business actions through gateway connectors",
8114
+ domain: "tools",
8115
+ priority: "p2",
8116
+ content: "The company_actions tool executes business actions through gateway connectors (e.g. send WhatsApp, trigger workflows, update CRM). It routes through the exe-gateway on the VPS. Actions are defined by the customer's gateway configuration \u2014 each connector (WhatsApp, Shopify, email, etc.) exposes specific actions. Use query_company_brain to find available data first, then company_actions to act on it. Requires gateway auth token. Read-only founders should NOT use this \u2014 it mutates external state."
8117
+ },
8118
+ // --- Release awareness ---
8119
+ {
8120
+ title: "What's New check \u2014 surface new features after update",
8121
+ domain: "support",
8122
+ priority: "p1",
8123
+ content: "Once per session (COO boot only, never repeat), check if the installed exe-os version is newer than the last session. If it is, read the bundled release-notes.json (at the package root) and surface a brief summary to the founder: 'Updated to exe-os vX.Y.Z \u2014 N new features, M fixes.' List the top 3 features by name. This helps the founder know what they got from the update. If release-notes.json doesn't exist or the version hasn't changed, skip silently. Never repeat this check in the same session."
8124
+ },
8022
8125
  // --- Platform vs Customer ownership ---
8023
8126
  {
8024
8127
  title: "What the platform provides vs what you customize",
@@ -8107,13 +8210,13 @@ var init_platform_procedures = __esm({
8107
8210
  title: "MCP tools \u2014 memory, decision, and search",
8108
8211
  domain: "tool-use",
8109
8212
  priority: "p1",
8110
- content: `memory(action="recall") / recall_my_memory: search your own memories (semantic + FTS). memory(action="ask_team") / ask_team_memory: search a colleague's memories by agent name. memory(action="store") / store_memory: persist a memory. memory(action="commit") / commit_memory: high-importance memory that survives consolidation. Requires summary. memory(action="search") / search_everything: unified search across memories, tasks, entities, conversations. memory(action="session_context") / get_session_context: temporal memory window. Requires session_id + target_timestamp. memory(action="consolidate") / consolidate_memories: merge duplicate/related memories. memory(action="cardinality") / get_memory_cardinality: count memories per agent. decision(action="store") / store_decision: record an architectural decision (domain, decision, rationale). decision(action="get") / get_decision: retrieve a past decision by domain or query.`
8213
+ content: `memory(action="recall") / recall_my_memory: search memories (semantic + FTS). Params: as_of (bi-temporal \u2014 what did I know at time X?), kind (decision|procedure|observation|raw|conversation|behavior), retrieval_mode (all|decisions_only|procedures_only|operational|recent_high_value). memory(action="ask_team") / ask_team_memory: search a colleague's memories. memory(action="store") / store_memory: persist a memory. Params: kind, procedure_for (domain tag for procedures). memory(action="commit") / commit_memory: high-importance, survives consolidation. Requires summary. memory(action="search") / search_everything: unified search across memories, tasks, entities, conversations. memory(action="session_context") / get_session_context: temporal window. Requires session_id + target_timestamp. memory(action="get_by_id"): fetch one memory by UUID with full untruncated text. memory(action="consolidate") / consolidate_memories: merge duplicate/related memories. memory(action="cardinality") / get_memory_cardinality: count memories per agent. memory(action="supersede"): replace an old memory with a new version (old_id + new text). decision(action="store") / store_decision: record an architectural decision (domain, decision, rationale). decision(action="get") / get_decision: retrieve a past decision by domain or query.`
8111
8214
  },
8112
8215
  {
8113
8216
  title: "MCP tools \u2014 task orchestration",
8114
8217
  domain: "tool-use",
8115
8218
  priority: "p1",
8116
- content: 'task(action="create") / create_task: dispatch work (title, assigned_to, context). The ONLY dispatch path. Auto-spawns session. task(action="list") / list_tasks: query tasks by status, assignee, project. task(action="get") / get_task: fetch full task details by task_id. task(action="update") / update_task: change status (in_progress, done, blocked, cancelled) + result summary. task(action="close") / close_task: finalize a reviewed task (COO only). task(action="checkpoint") / checkpoint_task: save progress state for crash recovery. task(action="resume") / resume_employee: re-spawn an employee session for an existing task.'
8219
+ content: 'task(action="create") / create_task: dispatch work (title, assigned_to, context). The ONLY dispatch path. Auto-spawns session. Params: blocked_by (task ID for dependency), parent_task_id (subtask hierarchy), reviewer, complexity (routine|standard|complex|critical), budget_tokens (max token cap), budget_fallback_model, spawn_runtime (override runtime: claude|codex|opencode), spawn_model (override model). task(action="list") / list_tasks: query tasks by status, assignee, project. task(action="get") / get_task: fetch full task details by task_id. task(action="update") / update_task: change status (in_progress, done, blocked, cancelled) + result summary. task(action="close") / close_task: finalize a reviewed task (COO only). task(action="checkpoint") / checkpoint_task: save progress state for crash recovery. task(action="resume") / resume_employee: re-spawn an employee session for an existing task.'
8117
8220
  },
8118
8221
  {
8119
8222
  title: "MCP tools \u2014 knowledge graph (GraphRAG)",
@@ -8143,7 +8246,7 @@ var init_platform_procedures = __esm({
8143
8246
  title: "MCP tools \u2014 admin, config, and operations",
8144
8247
  domain: "tool-use",
8145
8248
  priority: "p1",
8146
- content: 'config(action="list_employees"): view roster. config(action="agent_spend"): token usage per agent. config(action="daemon_health"): check exed status. config(action="license_status"): check license. config(action="cloud_sync"): force sync. config(action="memory_audit"): health check (dupes, null vectors). config(action="run_consolidation"): trigger memory consolidation. config(action="company_procedure", subaction="store|list|deactivate"): manage company procedures. config(action="global_procedure"): list all procedures (platform + company). config(action="create_trigger|list_triggers"): scheduled agent jobs. config(action="export_orchestration|import_orchestration"): portable org state. diagnostics(action="healthcheck|doctor|status_brief|check_update|cloud_status"): system diagnostics. mcp_ping(): daemon health + license status + tool usage stats.'
8249
+ content: 'config(action="list_employees"): view roster. config(action="set_agent_config"): view or change per-agent runtime + model. Call with no args to show all agents. config(action="agent_spend"): token usage per agent. config(action="daemon_health"): check exed status. config(action="license_status"): check license. config(action="cloud_sync"): force sync. Supports cloud_action param: status|sync|reupload. config(action="memory_audit"): health check (dupes, null vectors). config(action="run_consolidation"): trigger memory consolidation. config(action="worker_gate"): check spawn slot availability \u2014 alive/stale/reserved counts vs max. Use before dispatching. config(action="auto_wake_status"): orphaned tasks, blocked tasks, auto-wake retry status. config(action="orchestration_phase"): view/change org phase (phase_1_coo|phase_2_executives|phase_3_parallel_org). config(action="company_procedure", subaction="store|list|deactivate"): manage company procedures. config(action="global_procedure"): list all procedures (platform + company). config(action="create_trigger|list_triggers"): scheduled agent jobs. config(action="export_orchestration|import_orchestration"): portable org state. diagnostics(action="healthcheck|doctor|status_brief|check_update|cloud_status"): system diagnostics. diagnostics(action="pending_work_summary"): pending reviews + messages + notifications in one call. diagnostics(action="rename_employee"): rename an agent across all systems (roster, identity, DB, symlinks). diagnostics(action="tool_search"): semantic tool discovery \u2014 find relevant MCP tools by natural language query. diagnostics(action="drift"): identity drift detection \u2014 score how far an agent has drifted from its role. mcp_ping(): daemon health + license status + tool usage stats.'
8147
8250
  }
8148
8251
  ];
8149
8252
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -8827,6 +8930,8 @@ async function writeMemory(record) {
8827
8930
  source_type: record.source_type ?? null,
8828
8931
  tier: record.tier ?? classifyTier(record),
8829
8932
  supersedes_id: record.supersedes_id ?? null,
8933
+ valid_from: record.valid_from ?? record.timestamp,
8934
+ invalid_at: record.invalid_at ?? null,
8830
8935
  draft: record.draft ? 1 : 0,
8831
8936
  memory_type: memoryType,
8832
8937
  trajectory: record.trajectory ? JSON.stringify(record.trajectory) : null,
@@ -8845,7 +8950,8 @@ async function writeMemory(record) {
8845
8950
  token_cost: record.token_cost ?? null,
8846
8951
  audience: record.audience ?? null,
8847
8952
  language_type: record.language_type ?? inferLanguageType(record),
8848
- parent_memory_id: record.parent_memory_id ?? null
8953
+ parent_memory_id: record.parent_memory_id ?? null,
8954
+ procedure_for: record.procedure_for ?? null
8849
8955
  };
8850
8956
  _pendingRecords.push(dbRow);
8851
8957
  orgBus.emit({
@@ -8900,6 +9006,8 @@ async function flushBatch() {
8900
9006
  const sourceType = row.source_type ?? null;
8901
9007
  const tier = row.tier ?? 3;
8902
9008
  const supersedesId = row.supersedes_id ?? null;
9009
+ const validFrom = row.valid_from ?? row.timestamp;
9010
+ const invalidAt = row.invalid_at ?? null;
8903
9011
  const draft = row.draft ? 1 : 0;
8904
9012
  const memoryType = row.memory_type ?? "raw";
8905
9013
  const trajectory = row.trajectory ?? null;
@@ -8919,15 +9027,16 @@ async function flushBatch() {
8919
9027
  const audience = row.audience ?? null;
8920
9028
  const languageType = row.language_type ?? null;
8921
9029
  const parentMemoryId = row.parent_memory_id ?? null;
9030
+ const procedureFor = row.procedure_for ?? null;
8922
9031
  const cols = `id, agent_id, agent_role, session_id, timestamp,
8923
9032
  tool_name, project_name,
8924
9033
  has_error, raw_text, vector, version, task_id, importance, status,
8925
9034
  confidence, last_accessed,
8926
9035
  workspace_id, document_id, user_id, char_offset, page_number,
8927
- source_path, source_type, tier, supersedes_id, draft, memory_type, trajectory, content_hash,
9036
+ source_path, source_type, tier, supersedes_id, valid_from, invalid_at, draft, memory_type, trajectory, content_hash,
8928
9037
  intent, outcome, domain, referenced_entities, retrieval_count,
8929
9038
  chain_position, review_status, context_window_pct, file_paths, commit_hash,
8930
- duration_ms, token_cost, audience, language_type, parent_memory_id`;
9039
+ duration_ms, token_cost, audience, language_type, parent_memory_id, procedure_for`;
8931
9040
  const metaArgs = [
8932
9041
  intent,
8933
9042
  outcome,
@@ -8943,7 +9052,8 @@ async function flushBatch() {
8943
9052
  tokenCost,
8944
9053
  audience,
8945
9054
  languageType,
8946
- parentMemoryId
9055
+ parentMemoryId,
9056
+ procedureFor
8947
9057
  ];
8948
9058
  const baseArgs = [
8949
9059
  row.id,
@@ -8972,6 +9082,8 @@ async function flushBatch() {
8972
9082
  sourceType,
8973
9083
  tier,
8974
9084
  supersedesId,
9085
+ validFrom,
9086
+ invalidAt,
8975
9087
  draft,
8976
9088
  memoryType,
8977
9089
  trajectory,
@@ -8979,8 +9091,8 @@ async function flushBatch() {
8979
9091
  ];
8980
9092
  return {
8981
9093
  sql: hasVector ? `INSERT OR IGNORE INTO memories (${cols})
8982
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories (${cols})
8983
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
9094
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories (${cols})
9095
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
8984
9096
  args: hasVector ? [...baseArgs, vectorToBlob(row.vector), ...sharedArgs, ...metaArgs] : [...baseArgs, ...sharedArgs, ...metaArgs]
8985
9097
  };
8986
9098
  };
@@ -9096,6 +9208,12 @@ async function searchMemories(queryVector, agentId, options) {
9096
9208
  AND vector IS NOT NULL${statusFilter}${draftFilter}
9097
9209
  AND COALESCE(confidence, 0.7) >= 0.3`;
9098
9210
  const args = [agentId];
9211
+ if (options?.asOf) {
9212
+ sql += ` AND (valid_from IS NULL OR valid_from <= ?) AND (invalid_at IS NULL OR invalid_at > ?)`;
9213
+ args.push(options.asOf, options.asOf);
9214
+ } else {
9215
+ sql += ` AND invalid_at IS NULL`;
9216
+ }
9099
9217
  const scope = buildWikiScopeFilter(options, "");
9100
9218
  sql += scope.clause;
9101
9219
  args.push(...scope.args);