@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
@@ -2808,6 +2808,20 @@ async function ensureSchema() {
2808
2808
  });
2809
2809
  } catch {
2810
2810
  }
2811
+ try {
2812
+ await client.execute({
2813
+ sql: `ALTER TABLE tasks ADD COLUMN spawn_runtime TEXT`,
2814
+ args: []
2815
+ });
2816
+ } catch {
2817
+ }
2818
+ try {
2819
+ await client.execute({
2820
+ sql: `ALTER TABLE tasks ADD COLUMN spawn_model TEXT`,
2821
+ args: []
2822
+ });
2823
+ } catch {
2824
+ }
2811
2825
  await client.executeMultiple(`
2812
2826
  CREATE VIRTUAL TABLE IF NOT EXISTS conversations_fts USING fts5(
2813
2827
  content_text,
@@ -3059,6 +3073,22 @@ async function ensureSchema() {
3059
3073
  );
3060
3074
  } catch {
3061
3075
  }
3076
+ for (const col of [
3077
+ "ALTER TABLE memories ADD COLUMN valid_from TEXT",
3078
+ "ALTER TABLE memories ADD COLUMN invalid_at TEXT"
3079
+ ]) {
3080
+ try {
3081
+ await client.execute(col);
3082
+ } catch {
3083
+ }
3084
+ }
3085
+ try {
3086
+ await client.execute({
3087
+ sql: `UPDATE memories SET valid_from = timestamp WHERE valid_from IS NULL`,
3088
+ args: []
3089
+ });
3090
+ } catch {
3091
+ }
3062
3092
  try {
3063
3093
  await client.execute({
3064
3094
  sql: `ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'`,
@@ -3101,6 +3131,13 @@ async function ensureSchema() {
3101
3131
  } catch {
3102
3132
  }
3103
3133
  }
3134
+ try {
3135
+ await client.execute({
3136
+ sql: `ALTER TABLE memories ADD COLUMN procedure_for TEXT`,
3137
+ args: []
3138
+ });
3139
+ } catch {
3140
+ }
3104
3141
  try {
3105
3142
  await client.execute({
3106
3143
  sql: `UPDATE tasks SET status = 'closed' WHERE status = 'done' AND result IS NOT NULL`,
@@ -4239,6 +4276,20 @@ var init_platform_procedures = __esm({
4239
4276
  priority: "p1",
4240
4277
  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."
4241
4278
  },
4279
+ // --- Tool guidance ---
4280
+ {
4281
+ title: "How to use company_actions \u2014 execute business actions through gateway connectors",
4282
+ domain: "tools",
4283
+ priority: "p2",
4284
+ 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."
4285
+ },
4286
+ // --- Release awareness ---
4287
+ {
4288
+ title: "What's New check \u2014 surface new features after update",
4289
+ domain: "support",
4290
+ priority: "p1",
4291
+ 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."
4292
+ },
4242
4293
  // --- Platform vs Customer ownership ---
4243
4294
  {
4244
4295
  title: "What the platform provides vs what you customize",
@@ -4327,13 +4378,13 @@ var init_platform_procedures = __esm({
4327
4378
  title: "MCP tools \u2014 memory, decision, and search",
4328
4379
  domain: "tool-use",
4329
4380
  priority: "p1",
4330
- 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.`
4381
+ 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.`
4331
4382
  },
4332
4383
  {
4333
4384
  title: "MCP tools \u2014 task orchestration",
4334
4385
  domain: "tool-use",
4335
4386
  priority: "p1",
4336
- 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.'
4387
+ 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.'
4337
4388
  },
4338
4389
  {
4339
4390
  title: "MCP tools \u2014 knowledge graph (GraphRAG)",
@@ -4363,7 +4414,7 @@ var init_platform_procedures = __esm({
4363
4414
  title: "MCP tools \u2014 admin, config, and operations",
4364
4415
  domain: "tool-use",
4365
4416
  priority: "p1",
4366
- 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.'
4417
+ 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.'
4367
4418
  }
4368
4419
  ];
4369
4420
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -5047,6 +5098,8 @@ async function writeMemory(record) {
5047
5098
  source_type: record.source_type ?? null,
5048
5099
  tier: record.tier ?? classifyTier(record),
5049
5100
  supersedes_id: record.supersedes_id ?? null,
5101
+ valid_from: record.valid_from ?? record.timestamp,
5102
+ invalid_at: record.invalid_at ?? null,
5050
5103
  draft: record.draft ? 1 : 0,
5051
5104
  memory_type: memoryType,
5052
5105
  trajectory: record.trajectory ? JSON.stringify(record.trajectory) : null,
@@ -5065,7 +5118,8 @@ async function writeMemory(record) {
5065
5118
  token_cost: record.token_cost ?? null,
5066
5119
  audience: record.audience ?? null,
5067
5120
  language_type: record.language_type ?? inferLanguageType(record),
5068
- parent_memory_id: record.parent_memory_id ?? null
5121
+ parent_memory_id: record.parent_memory_id ?? null,
5122
+ procedure_for: record.procedure_for ?? null
5069
5123
  };
5070
5124
  _pendingRecords.push(dbRow);
5071
5125
  orgBus.emit({
@@ -5120,6 +5174,8 @@ async function flushBatch() {
5120
5174
  const sourceType = row.source_type ?? null;
5121
5175
  const tier = row.tier ?? 3;
5122
5176
  const supersedesId = row.supersedes_id ?? null;
5177
+ const validFrom = row.valid_from ?? row.timestamp;
5178
+ const invalidAt = row.invalid_at ?? null;
5123
5179
  const draft = row.draft ? 1 : 0;
5124
5180
  const memoryType = row.memory_type ?? "raw";
5125
5181
  const trajectory = row.trajectory ?? null;
@@ -5139,15 +5195,16 @@ async function flushBatch() {
5139
5195
  const audience = row.audience ?? null;
5140
5196
  const languageType = row.language_type ?? null;
5141
5197
  const parentMemoryId = row.parent_memory_id ?? null;
5198
+ const procedureFor = row.procedure_for ?? null;
5142
5199
  const cols = `id, agent_id, agent_role, session_id, timestamp,
5143
5200
  tool_name, project_name,
5144
5201
  has_error, raw_text, vector, version, task_id, importance, status,
5145
5202
  confidence, last_accessed,
5146
5203
  workspace_id, document_id, user_id, char_offset, page_number,
5147
- source_path, source_type, tier, supersedes_id, draft, memory_type, trajectory, content_hash,
5204
+ source_path, source_type, tier, supersedes_id, valid_from, invalid_at, draft, memory_type, trajectory, content_hash,
5148
5205
  intent, outcome, domain, referenced_entities, retrieval_count,
5149
5206
  chain_position, review_status, context_window_pct, file_paths, commit_hash,
5150
- duration_ms, token_cost, audience, language_type, parent_memory_id`;
5207
+ duration_ms, token_cost, audience, language_type, parent_memory_id, procedure_for`;
5151
5208
  const metaArgs = [
5152
5209
  intent,
5153
5210
  outcome,
@@ -5163,7 +5220,8 @@ async function flushBatch() {
5163
5220
  tokenCost,
5164
5221
  audience,
5165
5222
  languageType,
5166
- parentMemoryId
5223
+ parentMemoryId,
5224
+ procedureFor
5167
5225
  ];
5168
5226
  const baseArgs = [
5169
5227
  row.id,
@@ -5192,6 +5250,8 @@ async function flushBatch() {
5192
5250
  sourceType,
5193
5251
  tier,
5194
5252
  supersedesId,
5253
+ validFrom,
5254
+ invalidAt,
5195
5255
  draft,
5196
5256
  memoryType,
5197
5257
  trajectory,
@@ -5199,8 +5259,8 @@ async function flushBatch() {
5199
5259
  ];
5200
5260
  return {
5201
5261
  sql: hasVector ? `INSERT OR IGNORE INTO memories (${cols})
5202
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories (${cols})
5203
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
5262
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories (${cols})
5263
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
5204
5264
  args: hasVector ? [...baseArgs, vectorToBlob(row.vector), ...sharedArgs, ...metaArgs] : [...baseArgs, ...sharedArgs, ...metaArgs]
5205
5265
  };
5206
5266
  };
@@ -5316,6 +5376,12 @@ async function searchMemories(queryVector, agentId, options) {
5316
5376
  AND vector IS NOT NULL${statusFilter}${draftFilter}
5317
5377
  AND COALESCE(confidence, 0.7) >= 0.3`;
5318
5378
  const args = [agentId];
5379
+ if (options?.asOf) {
5380
+ sql += ` AND (valid_from IS NULL OR valid_from <= ?) AND (invalid_at IS NULL OR invalid_at > ?)`;
5381
+ args.push(options.asOf, options.asOf);
5382
+ } else {
5383
+ sql += ` AND invalid_at IS NULL`;
5384
+ }
5319
5385
  const scope = buildWikiScopeFilter(options, "");
5320
5386
  sql += scope.clause;
5321
5387
  args.push(...scope.args);
@@ -5980,7 +6046,7 @@ import { pathToFileURL as pathToFileURL2 } from "url";
5980
6046
  import os8 from "os";
5981
6047
  import path11 from "path";
5982
6048
  import { jwtVerify, importSPKI } from "jose";
5983
- var LICENSE_PATH, CACHE_PATH, DEVICE_ID_PATH, PLAN_LIMITS;
6049
+ var LICENSE_PATH, CACHE_PATH, DEVICE_ID_PATH, API_BASE, PLAN_LIMITS;
5984
6050
  var init_license = __esm({
5985
6051
  "src/lib/license.ts"() {
5986
6052
  "use strict";
@@ -5988,6 +6054,7 @@ var init_license = __esm({
5988
6054
  LICENSE_PATH = path11.join(EXE_AI_DIR, "license.key");
5989
6055
  CACHE_PATH = path11.join(EXE_AI_DIR, "license-cache.json");
5990
6056
  DEVICE_ID_PATH = path11.join(EXE_AI_DIR, "device-id");
6057
+ API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://askexe.com/cloud";
5991
6058
  PLAN_LIMITS = {
5992
6059
  free: { devices: 1, employees: 1, memories: 5e3 },
5993
6060
  pro: { devices: 3, employees: 5, memories: 1e5 },
@@ -6566,8 +6633,8 @@ ${scopeMismatchWarning}` : scopeMismatchWarning;
6566
6633
  const complexity = input.complexity ?? "standard";
6567
6634
  const sessionScope = earlySessionScope;
6568
6635
  await client.execute({
6569
- 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)
6570
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
6636
+ 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)
6637
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
6571
6638
  args: [
6572
6639
  id,
6573
6640
  input.title,
@@ -6587,6 +6654,8 @@ ${scopeMismatchWarning}` : scopeMismatchWarning;
6587
6654
  0,
6588
6655
  null,
6589
6656
  sessionScope,
6657
+ input.spawnRuntime ?? null,
6658
+ input.spawnModel ?? null,
6590
6659
  now,
6591
6660
  now
6592
6661
  ]
@@ -6643,7 +6712,9 @@ ${input.context}
6643
6712
  budgetTokens: input.budgetTokens ?? null,
6644
6713
  budgetFallbackModel: input.budgetFallbackModel ?? null,
6645
6714
  tokensUsed: 0,
6646
- tokensWarnedAt: null
6715
+ tokensWarnedAt: null,
6716
+ spawnRuntime: input.spawnRuntime ?? null,
6717
+ spawnModel: input.spawnModel ?? null
6647
6718
  };
6648
6719
  }
6649
6720
  async function listTasks(input) {
@@ -6693,7 +6764,9 @@ async function listTasks(input) {
6693
6764
  budgetTokens: r.budget_tokens !== null ? Number(r.budget_tokens) : null,
6694
6765
  budgetFallbackModel: r.budget_fallback_model !== null ? String(r.budget_fallback_model) : null,
6695
6766
  tokensUsed: Number(r.tokens_used ?? 0),
6696
- tokensWarnedAt: r.tokens_warned_at !== null ? Number(r.tokens_warned_at) : null
6767
+ tokensWarnedAt: r.tokens_warned_at !== null ? Number(r.tokens_warned_at) : null,
6768
+ spawnRuntime: r.spawn_runtime !== null && r.spawn_runtime !== void 0 ? String(r.spawn_runtime) : null,
6769
+ spawnModel: r.spawn_model !== null && r.spawn_model !== void 0 ? String(r.spawn_model) : null
6697
6770
  }));
6698
6771
  }
6699
6772
  function isTmuxSessionAlive(identifier) {
@@ -7990,6 +8063,8 @@ async function updateTask(input) {
7990
8063
  budgetFallbackModel: row.budget_fallback_model !== void 0 && row.budget_fallback_model !== null ? String(row.budget_fallback_model) : null,
7991
8064
  tokensUsed: Number(row.tokens_used ?? 0),
7992
8065
  tokensWarnedAt: row.tokens_warned_at !== void 0 && row.tokens_warned_at !== null ? Number(row.tokens_warned_at) : null,
8066
+ spawnRuntime: row.spawn_runtime !== void 0 && row.spawn_runtime !== null ? String(row.spawn_runtime) : null,
8067
+ spawnModel: row.spawn_model !== void 0 && row.spawn_model !== null ? String(row.spawn_model) : null,
7993
8068
  nextTask
7994
8069
  };
7995
8070
  }
@@ -8482,9 +8557,13 @@ function getDispatchedBy(sessionKey) {
8482
8557
  }
8483
8558
  }
8484
8559
  function resolveExeSession() {
8560
+ if (process.env.EXE_SESSION_NAME) {
8561
+ return extractRootExe(process.env.EXE_SESSION_NAME) ?? process.env.EXE_SESSION_NAME;
8562
+ }
8485
8563
  const mySession = getMySession();
8486
8564
  if (!mySession) return null;
8487
8565
  const fromSessionName = extractRootExe(mySession);
8566
+ let candidate = null;
8488
8567
  try {
8489
8568
  const key = getSessionKey();
8490
8569
  const parentExe = getParentExe(key);
@@ -8495,13 +8574,47 @@ function resolveExeSession() {
8495
8574
  `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
8496
8575
  `
8497
8576
  );
8498
- return fromSessionName;
8577
+ candidate = fromSessionName;
8578
+ } else {
8579
+ candidate = fromCache;
8499
8580
  }
8500
- return fromCache;
8501
8581
  }
8502
8582
  } catch {
8503
8583
  }
8504
- return fromSessionName ?? mySession;
8584
+ if (!candidate) {
8585
+ candidate = fromSessionName ?? mySession;
8586
+ }
8587
+ if (candidate && isRootSession(candidate)) {
8588
+ try {
8589
+ const transport = getTransport();
8590
+ const liveSessions = transport.listSessions();
8591
+ if (!liveSessions.includes(candidate)) {
8592
+ const liveRoots = liveSessions.filter((s) => isRootSession(s));
8593
+ if (liveRoots.length === 1) {
8594
+ process.stderr.write(
8595
+ `[tmux-routing] WARN: resolved session "${candidate}" is dead. Using live coordinator "${liveRoots[0]}".
8596
+ `
8597
+ );
8598
+ return liveRoots[0];
8599
+ } else if (liveRoots.length > 1) {
8600
+ const base = candidate.replace(/\d+$/, "");
8601
+ const match = liveRoots.find((s) => s.startsWith(base));
8602
+ const chosen = match ?? liveRoots[0];
8603
+ process.stderr.write(
8604
+ `[tmux-routing] WARN: resolved session "${candidate}" is dead. ${liveRoots.length} live roots found, using "${chosen}".
8605
+ `
8606
+ );
8607
+ return chosen;
8608
+ }
8609
+ process.stderr.write(
8610
+ `[tmux-routing] WARN: resolved session "${candidate}" is dead and no live coordinator found.
8611
+ `
8612
+ );
8613
+ }
8614
+ } catch {
8615
+ }
8616
+ }
8617
+ return candidate;
8505
8618
  }
8506
8619
  function isEmployeeAlive(sessionName) {
8507
8620
  return getTransport().isAlive(sessionName);
@@ -8903,7 +9016,12 @@ function spawnEmployee(employeeName, exeSession2, projectDir, opts) {
8903
9016
  }
8904
9017
  const spawnCwd = opts?.cwd ?? projectDir;
8905
9018
  const useExeAgent = !!(opts?.model && opts?.provider);
8906
- const agentRtConfig = getAgentRuntime(employeeName);
9019
+ const baseRtConfig = getAgentRuntime(employeeName);
9020
+ const agentRtConfig = {
9021
+ ...baseRtConfig,
9022
+ ...opts?.runtimeOverride ? { runtime: opts.runtimeOverride } : {},
9023
+ ...opts?.modelOverride ? { model: opts.modelOverride } : {}
9024
+ };
8907
9025
  const useCodex = !useExeAgent && agentRtConfig.runtime === "codex";
8908
9026
  const useOpencode = !useExeAgent && !useCodex && agentRtConfig.runtime === "opencode";
8909
9027
  const ccProvider = useExeAgent || useCodex || useOpencode ? DEFAULT_PROVIDER : detectActiveProvider();
@@ -476,6 +476,7 @@ import { jwtVerify, importSPKI } from "jose";
476
476
  var LICENSE_PATH = path4.join(EXE_AI_DIR, "license.key");
477
477
  var CACHE_PATH = path4.join(EXE_AI_DIR, "license-cache.json");
478
478
  var DEVICE_ID_PATH = path4.join(EXE_AI_DIR, "device-id");
479
+ var API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://askexe.com/cloud";
479
480
 
480
481
  // src/lib/cloud-sync.ts
481
482
  init_config();
@@ -2637,6 +2637,20 @@ async function ensureSchema() {
2637
2637
  });
2638
2638
  } catch {
2639
2639
  }
2640
+ try {
2641
+ await client.execute({
2642
+ sql: `ALTER TABLE tasks ADD COLUMN spawn_runtime TEXT`,
2643
+ args: []
2644
+ });
2645
+ } catch {
2646
+ }
2647
+ try {
2648
+ await client.execute({
2649
+ sql: `ALTER TABLE tasks ADD COLUMN spawn_model TEXT`,
2650
+ args: []
2651
+ });
2652
+ } catch {
2653
+ }
2640
2654
  await client.executeMultiple(`
2641
2655
  CREATE VIRTUAL TABLE IF NOT EXISTS conversations_fts USING fts5(
2642
2656
  content_text,
@@ -2888,6 +2902,22 @@ async function ensureSchema() {
2888
2902
  );
2889
2903
  } catch {
2890
2904
  }
2905
+ for (const col of [
2906
+ "ALTER TABLE memories ADD COLUMN valid_from TEXT",
2907
+ "ALTER TABLE memories ADD COLUMN invalid_at TEXT"
2908
+ ]) {
2909
+ try {
2910
+ await client.execute(col);
2911
+ } catch {
2912
+ }
2913
+ }
2914
+ try {
2915
+ await client.execute({
2916
+ sql: `UPDATE memories SET valid_from = timestamp WHERE valid_from IS NULL`,
2917
+ args: []
2918
+ });
2919
+ } catch {
2920
+ }
2891
2921
  try {
2892
2922
  await client.execute({
2893
2923
  sql: `ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'`,
@@ -2930,6 +2960,13 @@ async function ensureSchema() {
2930
2960
  } catch {
2931
2961
  }
2932
2962
  }
2963
+ try {
2964
+ await client.execute({
2965
+ sql: `ALTER TABLE memories ADD COLUMN procedure_for TEXT`,
2966
+ args: []
2967
+ });
2968
+ } catch {
2969
+ }
2933
2970
  try {
2934
2971
  await client.execute({
2935
2972
  sql: `UPDATE tasks SET status = 'closed' WHERE status = 'done' AND result IS NOT NULL`,
@@ -3511,6 +3548,20 @@ var init_platform_procedures = __esm({
3511
3548
  priority: "p1",
3512
3549
  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."
3513
3550
  },
3551
+ // --- Tool guidance ---
3552
+ {
3553
+ title: "How to use company_actions \u2014 execute business actions through gateway connectors",
3554
+ domain: "tools",
3555
+ priority: "p2",
3556
+ 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."
3557
+ },
3558
+ // --- Release awareness ---
3559
+ {
3560
+ title: "What's New check \u2014 surface new features after update",
3561
+ domain: "support",
3562
+ priority: "p1",
3563
+ 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."
3564
+ },
3514
3565
  // --- Platform vs Customer ownership ---
3515
3566
  {
3516
3567
  title: "What the platform provides vs what you customize",
@@ -3599,13 +3650,13 @@ var init_platform_procedures = __esm({
3599
3650
  title: "MCP tools \u2014 memory, decision, and search",
3600
3651
  domain: "tool-use",
3601
3652
  priority: "p1",
3602
- 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.`
3653
+ 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.`
3603
3654
  },
3604
3655
  {
3605
3656
  title: "MCP tools \u2014 task orchestration",
3606
3657
  domain: "tool-use",
3607
3658
  priority: "p1",
3608
- 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.'
3659
+ 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.'
3609
3660
  },
3610
3661
  {
3611
3662
  title: "MCP tools \u2014 knowledge graph (GraphRAG)",
@@ -3635,7 +3686,7 @@ var init_platform_procedures = __esm({
3635
3686
  title: "MCP tools \u2014 admin, config, and operations",
3636
3687
  domain: "tool-use",
3637
3688
  priority: "p1",
3638
- 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.'
3689
+ 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.'
3639
3690
  }
3640
3691
  ];
3641
3692
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -5699,6 +5750,8 @@ async function flushBatch() {
5699
5750
  const sourceType = row.source_type ?? null;
5700
5751
  const tier = row.tier ?? 3;
5701
5752
  const supersedesId = row.supersedes_id ?? null;
5753
+ const validFrom = row.valid_from ?? row.timestamp;
5754
+ const invalidAt = row.invalid_at ?? null;
5702
5755
  const draft = row.draft ? 1 : 0;
5703
5756
  const memoryType = row.memory_type ?? "raw";
5704
5757
  const trajectory = row.trajectory ?? null;
@@ -5718,15 +5771,16 @@ async function flushBatch() {
5718
5771
  const audience = row.audience ?? null;
5719
5772
  const languageType = row.language_type ?? null;
5720
5773
  const parentMemoryId = row.parent_memory_id ?? null;
5774
+ const procedureFor = row.procedure_for ?? null;
5721
5775
  const cols = `id, agent_id, agent_role, session_id, timestamp,
5722
5776
  tool_name, project_name,
5723
5777
  has_error, raw_text, vector, version, task_id, importance, status,
5724
5778
  confidence, last_accessed,
5725
5779
  workspace_id, document_id, user_id, char_offset, page_number,
5726
- source_path, source_type, tier, supersedes_id, draft, memory_type, trajectory, content_hash,
5780
+ source_path, source_type, tier, supersedes_id, valid_from, invalid_at, draft, memory_type, trajectory, content_hash,
5727
5781
  intent, outcome, domain, referenced_entities, retrieval_count,
5728
5782
  chain_position, review_status, context_window_pct, file_paths, commit_hash,
5729
- duration_ms, token_cost, audience, language_type, parent_memory_id`;
5783
+ duration_ms, token_cost, audience, language_type, parent_memory_id, procedure_for`;
5730
5784
  const metaArgs = [
5731
5785
  intent,
5732
5786
  outcome,
@@ -5742,7 +5796,8 @@ async function flushBatch() {
5742
5796
  tokenCost,
5743
5797
  audience,
5744
5798
  languageType,
5745
- parentMemoryId
5799
+ parentMemoryId,
5800
+ procedureFor
5746
5801
  ];
5747
5802
  const baseArgs = [
5748
5803
  row.id,
@@ -5771,6 +5826,8 @@ async function flushBatch() {
5771
5826
  sourceType,
5772
5827
  tier,
5773
5828
  supersedesId,
5829
+ validFrom,
5830
+ invalidAt,
5774
5831
  draft,
5775
5832
  memoryType,
5776
5833
  trajectory,
@@ -5778,8 +5835,8 @@ async function flushBatch() {
5778
5835
  ];
5779
5836
  return {
5780
5837
  sql: hasVector ? `INSERT OR IGNORE INTO memories (${cols})
5781
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories (${cols})
5782
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
5838
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories (${cols})
5839
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
5783
5840
  args: hasVector ? [...baseArgs, vectorToBlob(row.vector), ...sharedArgs, ...metaArgs] : [...baseArgs, ...sharedArgs, ...metaArgs]
5784
5841
  };
5785
5842
  };