@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
package/dist/lib/store.js CHANGED
@@ -2549,6 +2549,20 @@ async function ensureSchema() {
2549
2549
  });
2550
2550
  } catch {
2551
2551
  }
2552
+ try {
2553
+ await client.execute({
2554
+ sql: `ALTER TABLE tasks ADD COLUMN spawn_runtime TEXT`,
2555
+ args: []
2556
+ });
2557
+ } catch {
2558
+ }
2559
+ try {
2560
+ await client.execute({
2561
+ sql: `ALTER TABLE tasks ADD COLUMN spawn_model TEXT`,
2562
+ args: []
2563
+ });
2564
+ } catch {
2565
+ }
2552
2566
  await client.executeMultiple(`
2553
2567
  CREATE VIRTUAL TABLE IF NOT EXISTS conversations_fts USING fts5(
2554
2568
  content_text,
@@ -2800,6 +2814,22 @@ async function ensureSchema() {
2800
2814
  );
2801
2815
  } catch {
2802
2816
  }
2817
+ for (const col of [
2818
+ "ALTER TABLE memories ADD COLUMN valid_from TEXT",
2819
+ "ALTER TABLE memories ADD COLUMN invalid_at TEXT"
2820
+ ]) {
2821
+ try {
2822
+ await client.execute(col);
2823
+ } catch {
2824
+ }
2825
+ }
2826
+ try {
2827
+ await client.execute({
2828
+ sql: `UPDATE memories SET valid_from = timestamp WHERE valid_from IS NULL`,
2829
+ args: []
2830
+ });
2831
+ } catch {
2832
+ }
2803
2833
  try {
2804
2834
  await client.execute({
2805
2835
  sql: `ALTER TABLE memories ADD COLUMN memory_type TEXT DEFAULT 'raw'`,
@@ -2842,6 +2872,13 @@ async function ensureSchema() {
2842
2872
  } catch {
2843
2873
  }
2844
2874
  }
2875
+ try {
2876
+ await client.execute({
2877
+ sql: `ALTER TABLE memories ADD COLUMN procedure_for TEXT`,
2878
+ args: []
2879
+ });
2880
+ } catch {
2881
+ }
2845
2882
  try {
2846
2883
  await client.execute({
2847
2884
  sql: `UPDATE tasks SET status = 'closed' WHERE status = 'done' AND result IS NOT NULL`,
@@ -3423,6 +3460,20 @@ var init_platform_procedures = __esm({
3423
3460
  priority: "p1",
3424
3461
  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."
3425
3462
  },
3463
+ // --- Tool guidance ---
3464
+ {
3465
+ title: "How to use company_actions \u2014 execute business actions through gateway connectors",
3466
+ domain: "tools",
3467
+ priority: "p2",
3468
+ 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."
3469
+ },
3470
+ // --- Release awareness ---
3471
+ {
3472
+ title: "What's New check \u2014 surface new features after update",
3473
+ domain: "support",
3474
+ priority: "p1",
3475
+ 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."
3476
+ },
3426
3477
  // --- Platform vs Customer ownership ---
3427
3478
  {
3428
3479
  title: "What the platform provides vs what you customize",
@@ -3511,13 +3562,13 @@ var init_platform_procedures = __esm({
3511
3562
  title: "MCP tools \u2014 memory, decision, and search",
3512
3563
  domain: "tool-use",
3513
3564
  priority: "p1",
3514
- 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.`
3565
+ 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.`
3515
3566
  },
3516
3567
  {
3517
3568
  title: "MCP tools \u2014 task orchestration",
3518
3569
  domain: "tool-use",
3519
3570
  priority: "p1",
3520
- 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.'
3571
+ 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.'
3521
3572
  },
3522
3573
  {
3523
3574
  title: "MCP tools \u2014 knowledge graph (GraphRAG)",
@@ -3547,7 +3598,7 @@ var init_platform_procedures = __esm({
3547
3598
  title: "MCP tools \u2014 admin, config, and operations",
3548
3599
  domain: "tool-use",
3549
3600
  priority: "p1",
3550
- 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.'
3601
+ 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.'
3551
3602
  }
3552
3603
  ];
3553
3604
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -4768,6 +4819,8 @@ async function writeMemory(record) {
4768
4819
  source_type: record.source_type ?? null,
4769
4820
  tier: record.tier ?? classifyTier(record),
4770
4821
  supersedes_id: record.supersedes_id ?? null,
4822
+ valid_from: record.valid_from ?? record.timestamp,
4823
+ invalid_at: record.invalid_at ?? null,
4771
4824
  draft: record.draft ? 1 : 0,
4772
4825
  memory_type: memoryType,
4773
4826
  trajectory: record.trajectory ? JSON.stringify(record.trajectory) : null,
@@ -4786,7 +4839,8 @@ async function writeMemory(record) {
4786
4839
  token_cost: record.token_cost ?? null,
4787
4840
  audience: record.audience ?? null,
4788
4841
  language_type: record.language_type ?? inferLanguageType(record),
4789
- parent_memory_id: record.parent_memory_id ?? null
4842
+ parent_memory_id: record.parent_memory_id ?? null,
4843
+ procedure_for: record.procedure_for ?? null
4790
4844
  };
4791
4845
  _pendingRecords.push(dbRow);
4792
4846
  orgBus.emit({
@@ -4841,6 +4895,8 @@ async function flushBatch() {
4841
4895
  const sourceType = row.source_type ?? null;
4842
4896
  const tier = row.tier ?? 3;
4843
4897
  const supersedesId = row.supersedes_id ?? null;
4898
+ const validFrom = row.valid_from ?? row.timestamp;
4899
+ const invalidAt = row.invalid_at ?? null;
4844
4900
  const draft = row.draft ? 1 : 0;
4845
4901
  const memoryType = row.memory_type ?? "raw";
4846
4902
  const trajectory = row.trajectory ?? null;
@@ -4860,15 +4916,16 @@ async function flushBatch() {
4860
4916
  const audience = row.audience ?? null;
4861
4917
  const languageType = row.language_type ?? null;
4862
4918
  const parentMemoryId = row.parent_memory_id ?? null;
4919
+ const procedureFor = row.procedure_for ?? null;
4863
4920
  const cols = `id, agent_id, agent_role, session_id, timestamp,
4864
4921
  tool_name, project_name,
4865
4922
  has_error, raw_text, vector, version, task_id, importance, status,
4866
4923
  confidence, last_accessed,
4867
4924
  workspace_id, document_id, user_id, char_offset, page_number,
4868
- source_path, source_type, tier, supersedes_id, draft, memory_type, trajectory, content_hash,
4925
+ source_path, source_type, tier, supersedes_id, valid_from, invalid_at, draft, memory_type, trajectory, content_hash,
4869
4926
  intent, outcome, domain, referenced_entities, retrieval_count,
4870
4927
  chain_position, review_status, context_window_pct, file_paths, commit_hash,
4871
- duration_ms, token_cost, audience, language_type, parent_memory_id`;
4928
+ duration_ms, token_cost, audience, language_type, parent_memory_id, procedure_for`;
4872
4929
  const metaArgs = [
4873
4930
  intent,
4874
4931
  outcome,
@@ -4884,7 +4941,8 @@ async function flushBatch() {
4884
4941
  tokenCost,
4885
4942
  audience,
4886
4943
  languageType,
4887
- parentMemoryId
4944
+ parentMemoryId,
4945
+ procedureFor
4888
4946
  ];
4889
4947
  const baseArgs = [
4890
4948
  row.id,
@@ -4913,6 +4971,8 @@ async function flushBatch() {
4913
4971
  sourceType,
4914
4972
  tier,
4915
4973
  supersedesId,
4974
+ validFrom,
4975
+ invalidAt,
4916
4976
  draft,
4917
4977
  memoryType,
4918
4978
  trajectory,
@@ -4920,8 +4980,8 @@ async function flushBatch() {
4920
4980
  ];
4921
4981
  return {
4922
4982
  sql: hasVector ? `INSERT OR IGNORE INTO memories (${cols})
4923
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories (${cols})
4924
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
4983
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, vector32(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` : `INSERT OR IGNORE INTO memories (${cols})
4984
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
4925
4985
  args: hasVector ? [...baseArgs, vectorToBlob(row.vector), ...sharedArgs, ...metaArgs] : [...baseArgs, ...sharedArgs, ...metaArgs]
4926
4986
  };
4927
4987
  };
@@ -5037,6 +5097,12 @@ async function searchMemories(queryVector, agentId, options) {
5037
5097
  AND vector IS NOT NULL${statusFilter}${draftFilter}
5038
5098
  AND COALESCE(confidence, 0.7) >= 0.3`;
5039
5099
  const args = [agentId];
5100
+ if (options?.asOf) {
5101
+ sql += ` AND (valid_from IS NULL OR valid_from <= ?) AND (invalid_at IS NULL OR invalid_at > ?)`;
5102
+ args.push(options.asOf, options.asOf);
5103
+ } else {
5104
+ sql += ` AND invalid_at IS NULL`;
5105
+ }
5040
5106
  const scope = buildWikiScopeFilter(options, "");
5041
5107
  sql += scope.clause;
5042
5108
  args.push(...scope.args);
package/dist/lib/tasks.js CHANGED
@@ -961,7 +961,7 @@ import { pathToFileURL as pathToFileURL2 } from "url";
961
961
  import os6 from "os";
962
962
  import path7 from "path";
963
963
  import { jwtVerify, importSPKI } from "jose";
964
- var LICENSE_PATH, CACHE_PATH, DEVICE_ID_PATH, PLAN_LIMITS;
964
+ var LICENSE_PATH, CACHE_PATH, DEVICE_ID_PATH, API_BASE, PLAN_LIMITS;
965
965
  var init_license = __esm({
966
966
  "src/lib/license.ts"() {
967
967
  "use strict";
@@ -969,6 +969,7 @@ var init_license = __esm({
969
969
  LICENSE_PATH = path7.join(EXE_AI_DIR, "license.key");
970
970
  CACHE_PATH = path7.join(EXE_AI_DIR, "license-cache.json");
971
971
  DEVICE_ID_PATH = path7.join(EXE_AI_DIR, "device-id");
972
+ API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://askexe.com/cloud";
972
973
  PLAN_LIMITS = {
973
974
  free: { devices: 1, employees: 1, memories: 5e3 },
974
975
  pro: { devices: 3, employees: 5, memories: 1e5 },
@@ -1975,9 +1976,13 @@ function getDispatchedBy(sessionKey) {
1975
1976
  }
1976
1977
  }
1977
1978
  function resolveExeSession() {
1979
+ if (process.env.EXE_SESSION_NAME) {
1980
+ return extractRootExe(process.env.EXE_SESSION_NAME) ?? process.env.EXE_SESSION_NAME;
1981
+ }
1978
1982
  const mySession = getMySession();
1979
1983
  if (!mySession) return null;
1980
1984
  const fromSessionName = extractRootExe(mySession);
1985
+ let candidate = null;
1981
1986
  try {
1982
1987
  const key = getSessionKey();
1983
1988
  const parentExe = getParentExe(key);
@@ -1988,13 +1993,47 @@ function resolveExeSession() {
1988
1993
  `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
1989
1994
  `
1990
1995
  );
1991
- return fromSessionName;
1996
+ candidate = fromSessionName;
1997
+ } else {
1998
+ candidate = fromCache;
1992
1999
  }
1993
- return fromCache;
1994
2000
  }
1995
2001
  } catch {
1996
2002
  }
1997
- return fromSessionName ?? mySession;
2003
+ if (!candidate) {
2004
+ candidate = fromSessionName ?? mySession;
2005
+ }
2006
+ if (candidate && isRootSession(candidate)) {
2007
+ try {
2008
+ const transport = getTransport();
2009
+ const liveSessions = transport.listSessions();
2010
+ if (!liveSessions.includes(candidate)) {
2011
+ const liveRoots = liveSessions.filter((s) => isRootSession(s));
2012
+ if (liveRoots.length === 1) {
2013
+ process.stderr.write(
2014
+ `[tmux-routing] WARN: resolved session "${candidate}" is dead. Using live coordinator "${liveRoots[0]}".
2015
+ `
2016
+ );
2017
+ return liveRoots[0];
2018
+ } else if (liveRoots.length > 1) {
2019
+ const base = candidate.replace(/\d+$/, "");
2020
+ const match = liveRoots.find((s) => s.startsWith(base));
2021
+ const chosen = match ?? liveRoots[0];
2022
+ process.stderr.write(
2023
+ `[tmux-routing] WARN: resolved session "${candidate}" is dead. ${liveRoots.length} live roots found, using "${chosen}".
2024
+ `
2025
+ );
2026
+ return chosen;
2027
+ }
2028
+ process.stderr.write(
2029
+ `[tmux-routing] WARN: resolved session "${candidate}" is dead and no live coordinator found.
2030
+ `
2031
+ );
2032
+ }
2033
+ } catch {
2034
+ }
2035
+ }
2036
+ return candidate;
1998
2037
  }
1999
2038
  function isEmployeeAlive(sessionName) {
2000
2039
  return getTransport().isAlive(sessionName);
@@ -2396,7 +2435,12 @@ function spawnEmployee(employeeName, exeSession, projectDir, opts) {
2396
2435
  }
2397
2436
  const spawnCwd = opts?.cwd ?? projectDir;
2398
2437
  const useExeAgent = !!(opts?.model && opts?.provider);
2399
- const agentRtConfig = getAgentRuntime(employeeName);
2438
+ const baseRtConfig = getAgentRuntime(employeeName);
2439
+ const agentRtConfig = {
2440
+ ...baseRtConfig,
2441
+ ...opts?.runtimeOverride ? { runtime: opts.runtimeOverride } : {},
2442
+ ...opts?.modelOverride ? { model: opts.modelOverride } : {}
2443
+ };
2400
2444
  const useCodex = !useExeAgent && agentRtConfig.runtime === "codex";
2401
2445
  const useOpencode = !useExeAgent && !useCodex && agentRtConfig.runtime === "opencode";
2402
2446
  const ccProvider = useExeAgent || useCodex || useOpencode ? DEFAULT_PROVIDER : detectActiveProvider();
@@ -3034,8 +3078,8 @@ ${scopeMismatchWarning}` : scopeMismatchWarning;
3034
3078
  const complexity = input.complexity ?? "standard";
3035
3079
  const sessionScope = earlySessionScope;
3036
3080
  await client.execute({
3037
- 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)
3038
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
3081
+ 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)
3082
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
3039
3083
  args: [
3040
3084
  id,
3041
3085
  input.title,
@@ -3055,6 +3099,8 @@ ${scopeMismatchWarning}` : scopeMismatchWarning;
3055
3099
  0,
3056
3100
  null,
3057
3101
  sessionScope,
3102
+ input.spawnRuntime ?? null,
3103
+ input.spawnModel ?? null,
3058
3104
  now,
3059
3105
  now
3060
3106
  ]
@@ -3111,7 +3157,9 @@ ${input.context}
3111
3157
  budgetTokens: input.budgetTokens ?? null,
3112
3158
  budgetFallbackModel: input.budgetFallbackModel ?? null,
3113
3159
  tokensUsed: 0,
3114
- tokensWarnedAt: null
3160
+ tokensWarnedAt: null,
3161
+ spawnRuntime: input.spawnRuntime ?? null,
3162
+ spawnModel: input.spawnModel ?? null
3115
3163
  };
3116
3164
  }
3117
3165
  async function listTasks(input) {
@@ -3161,7 +3209,9 @@ async function listTasks(input) {
3161
3209
  budgetTokens: r.budget_tokens !== null ? Number(r.budget_tokens) : null,
3162
3210
  budgetFallbackModel: r.budget_fallback_model !== null ? String(r.budget_fallback_model) : null,
3163
3211
  tokensUsed: Number(r.tokens_used ?? 0),
3164
- tokensWarnedAt: r.tokens_warned_at !== null ? Number(r.tokens_warned_at) : null
3212
+ tokensWarnedAt: r.tokens_warned_at !== null ? Number(r.tokens_warned_at) : null,
3213
+ spawnRuntime: r.spawn_runtime !== null && r.spawn_runtime !== void 0 ? String(r.spawn_runtime) : null,
3214
+ spawnModel: r.spawn_model !== null && r.spawn_model !== void 0 ? String(r.spawn_model) : null
3165
3215
  }));
3166
3216
  }
3167
3217
  function isTmuxSessionAlive(identifier) {
@@ -4628,6 +4678,8 @@ async function updateTask(input) {
4628
4678
  budgetFallbackModel: row.budget_fallback_model !== void 0 && row.budget_fallback_model !== null ? String(row.budget_fallback_model) : null,
4629
4679
  tokensUsed: Number(row.tokens_used ?? 0),
4630
4680
  tokensWarnedAt: row.tokens_warned_at !== void 0 && row.tokens_warned_at !== null ? Number(row.tokens_warned_at) : null,
4681
+ spawnRuntime: row.spawn_runtime !== void 0 && row.spawn_runtime !== null ? String(row.spawn_runtime) : null,
4682
+ spawnModel: row.spawn_model !== void 0 && row.spawn_model !== null ? String(row.spawn_model) : null,
4631
4683
  nextTask
4632
4684
  };
4633
4685
  }
@@ -961,7 +961,7 @@ import { pathToFileURL as pathToFileURL2 } from "url";
961
961
  import os6 from "os";
962
962
  import path7 from "path";
963
963
  import { jwtVerify, importSPKI } from "jose";
964
- var LICENSE_PATH, CACHE_PATH, DEVICE_ID_PATH, PLAN_LIMITS;
964
+ var LICENSE_PATH, CACHE_PATH, DEVICE_ID_PATH, API_BASE, PLAN_LIMITS;
965
965
  var init_license = __esm({
966
966
  "src/lib/license.ts"() {
967
967
  "use strict";
@@ -969,6 +969,7 @@ var init_license = __esm({
969
969
  LICENSE_PATH = path7.join(EXE_AI_DIR, "license.key");
970
970
  CACHE_PATH = path7.join(EXE_AI_DIR, "license-cache.json");
971
971
  DEVICE_ID_PATH = path7.join(EXE_AI_DIR, "device-id");
972
+ API_BASE = process.env.EXE_CLOUD_ENDPOINT ?? "https://askexe.com/cloud";
972
973
  PLAN_LIMITS = {
973
974
  free: { devices: 1, employees: 1, memories: 5e3 },
974
975
  pro: { devices: 3, employees: 5, memories: 1e5 },
@@ -1619,8 +1620,8 @@ ${scopeMismatchWarning}` : scopeMismatchWarning;
1619
1620
  const complexity = input.complexity ?? "standard";
1620
1621
  const sessionScope = earlySessionScope;
1621
1622
  await client.execute({
1622
- 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)
1623
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
1623
+ 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)
1624
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
1624
1625
  args: [
1625
1626
  id,
1626
1627
  input.title,
@@ -1640,6 +1641,8 @@ ${scopeMismatchWarning}` : scopeMismatchWarning;
1640
1641
  0,
1641
1642
  null,
1642
1643
  sessionScope,
1644
+ input.spawnRuntime ?? null,
1645
+ input.spawnModel ?? null,
1643
1646
  now,
1644
1647
  now
1645
1648
  ]
@@ -1696,7 +1699,9 @@ ${input.context}
1696
1699
  budgetTokens: input.budgetTokens ?? null,
1697
1700
  budgetFallbackModel: input.budgetFallbackModel ?? null,
1698
1701
  tokensUsed: 0,
1699
- tokensWarnedAt: null
1702
+ tokensWarnedAt: null,
1703
+ spawnRuntime: input.spawnRuntime ?? null,
1704
+ spawnModel: input.spawnModel ?? null
1700
1705
  };
1701
1706
  }
1702
1707
  async function listTasks(input) {
@@ -1746,7 +1751,9 @@ async function listTasks(input) {
1746
1751
  budgetTokens: r.budget_tokens !== null ? Number(r.budget_tokens) : null,
1747
1752
  budgetFallbackModel: r.budget_fallback_model !== null ? String(r.budget_fallback_model) : null,
1748
1753
  tokensUsed: Number(r.tokens_used ?? 0),
1749
- tokensWarnedAt: r.tokens_warned_at !== null ? Number(r.tokens_warned_at) : null
1754
+ tokensWarnedAt: r.tokens_warned_at !== null ? Number(r.tokens_warned_at) : null,
1755
+ spawnRuntime: r.spawn_runtime !== null && r.spawn_runtime !== void 0 ? String(r.spawn_runtime) : null,
1756
+ spawnModel: r.spawn_model !== null && r.spawn_model !== void 0 ? String(r.spawn_model) : null
1750
1757
  }));
1751
1758
  }
1752
1759
  function isTmuxSessionAlive(identifier) {
@@ -3521,6 +3528,8 @@ async function updateTask(input) {
3521
3528
  budgetFallbackModel: row.budget_fallback_model !== void 0 && row.budget_fallback_model !== null ? String(row.budget_fallback_model) : null,
3522
3529
  tokensUsed: Number(row.tokens_used ?? 0),
3523
3530
  tokensWarnedAt: row.tokens_warned_at !== void 0 && row.tokens_warned_at !== null ? Number(row.tokens_warned_at) : null,
3531
+ spawnRuntime: row.spawn_runtime !== void 0 && row.spawn_runtime !== null ? String(row.spawn_runtime) : null,
3532
+ spawnModel: row.spawn_model !== void 0 && row.spawn_model !== null ? String(row.spawn_model) : null,
3524
3533
  nextTask
3525
3534
  };
3526
3535
  }
@@ -4013,9 +4022,13 @@ function getDispatchedBy(sessionKey) {
4013
4022
  }
4014
4023
  }
4015
4024
  function resolveExeSession() {
4025
+ if (process.env.EXE_SESSION_NAME) {
4026
+ return extractRootExe(process.env.EXE_SESSION_NAME) ?? process.env.EXE_SESSION_NAME;
4027
+ }
4016
4028
  const mySession = getMySession();
4017
4029
  if (!mySession) return null;
4018
4030
  const fromSessionName = extractRootExe(mySession);
4031
+ let candidate = null;
4019
4032
  try {
4020
4033
  const key = getSessionKey();
4021
4034
  const parentExe = getParentExe(key);
@@ -4026,13 +4039,47 @@ function resolveExeSession() {
4026
4039
  `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
4027
4040
  `
4028
4041
  );
4029
- return fromSessionName;
4042
+ candidate = fromSessionName;
4043
+ } else {
4044
+ candidate = fromCache;
4030
4045
  }
4031
- return fromCache;
4032
4046
  }
4033
4047
  } catch {
4034
4048
  }
4035
- return fromSessionName ?? mySession;
4049
+ if (!candidate) {
4050
+ candidate = fromSessionName ?? mySession;
4051
+ }
4052
+ if (candidate && isRootSession(candidate)) {
4053
+ try {
4054
+ const transport = getTransport();
4055
+ const liveSessions = transport.listSessions();
4056
+ if (!liveSessions.includes(candidate)) {
4057
+ const liveRoots = liveSessions.filter((s) => isRootSession(s));
4058
+ if (liveRoots.length === 1) {
4059
+ process.stderr.write(
4060
+ `[tmux-routing] WARN: resolved session "${candidate}" is dead. Using live coordinator "${liveRoots[0]}".
4061
+ `
4062
+ );
4063
+ return liveRoots[0];
4064
+ } else if (liveRoots.length > 1) {
4065
+ const base = candidate.replace(/\d+$/, "");
4066
+ const match = liveRoots.find((s) => s.startsWith(base));
4067
+ const chosen = match ?? liveRoots[0];
4068
+ process.stderr.write(
4069
+ `[tmux-routing] WARN: resolved session "${candidate}" is dead. ${liveRoots.length} live roots found, using "${chosen}".
4070
+ `
4071
+ );
4072
+ return chosen;
4073
+ }
4074
+ process.stderr.write(
4075
+ `[tmux-routing] WARN: resolved session "${candidate}" is dead and no live coordinator found.
4076
+ `
4077
+ );
4078
+ }
4079
+ } catch {
4080
+ }
4081
+ }
4082
+ return candidate;
4036
4083
  }
4037
4084
  function isEmployeeAlive(sessionName) {
4038
4085
  return getTransport().isAlive(sessionName);
@@ -4434,7 +4481,12 @@ function spawnEmployee(employeeName, exeSession, projectDir, opts) {
4434
4481
  }
4435
4482
  const spawnCwd = opts?.cwd ?? projectDir;
4436
4483
  const useExeAgent = !!(opts?.model && opts?.provider);
4437
- const agentRtConfig = getAgentRuntime(employeeName);
4484
+ const baseRtConfig = getAgentRuntime(employeeName);
4485
+ const agentRtConfig = {
4486
+ ...baseRtConfig,
4487
+ ...opts?.runtimeOverride ? { runtime: opts.runtimeOverride } : {},
4488
+ ...opts?.modelOverride ? { model: opts.modelOverride } : {}
4489
+ };
4438
4490
  const useCodex = !useExeAgent && agentRtConfig.runtime === "codex";
4439
4491
  const useOpencode = !useExeAgent && !useCodex && agentRtConfig.runtime === "opencode";
4440
4492
  const ccProvider = useExeAgent || useCodex || useOpencode ? DEFAULT_PROVIDER : detectActiveProvider();