@askexenow/exe-os 0.9.5 → 0.9.7

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.
@@ -2071,7 +2071,7 @@ var init_plan_limits = __esm({
2071
2071
  });
2072
2072
 
2073
2073
  // src/lib/tmux-routing.ts
2074
- import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, existsSync as existsSync9, appendFileSync } from "fs";
2074
+ import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, existsSync as existsSync9, appendFileSync, readdirSync as readdirSync2 } from "fs";
2075
2075
  import path10 from "path";
2076
2076
  import os6 from "os";
2077
2077
  import { fileURLToPath } from "url";
@@ -2095,15 +2095,24 @@ function getParentExe(sessionKey) {
2095
2095
  function resolveExeSession() {
2096
2096
  const mySession = getMySession();
2097
2097
  if (!mySession) return null;
2098
+ const fromSessionName = extractRootExe(mySession);
2098
2099
  try {
2099
2100
  const key = getSessionKey();
2100
2101
  const parentExe = getParentExe(key);
2101
2102
  if (parentExe) {
2102
- return extractRootExe(parentExe) ?? parentExe;
2103
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
2104
+ if (fromSessionName && fromCache !== fromSessionName) {
2105
+ process.stderr.write(
2106
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
2107
+ `
2108
+ );
2109
+ return fromSessionName;
2110
+ }
2111
+ return fromCache;
2103
2112
  }
2104
2113
  } catch {
2105
2114
  }
2106
- return extractRootExe(mySession) ?? mySession;
2115
+ return fromSessionName ?? mySession;
2107
2116
  }
2108
2117
  var SPAWN_LOCK_DIR, SESSION_CACHE, INTERCOM_LOG2, DEBOUNCE_FILE, DEBOUNCE_CLEANUP_AGE_MS;
2109
2118
  var init_tmux_routing = __esm({
package/dist/bin/cli.js CHANGED
@@ -10423,7 +10423,7 @@ __export(tmux_routing_exports, {
10423
10423
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
10424
10424
  });
10425
10425
  import { execFileSync as execFileSync2, execSync as execSync8 } from "child_process";
10426
- import { readFileSync as readFileSync18, writeFileSync as writeFileSync14, mkdirSync as mkdirSync15, existsSync as existsSync21, appendFileSync as appendFileSync2 } from "fs";
10426
+ import { readFileSync as readFileSync18, writeFileSync as writeFileSync14, mkdirSync as mkdirSync15, existsSync as existsSync21, appendFileSync as appendFileSync2, readdirSync as readdirSync6 } from "fs";
10427
10427
  import path26 from "path";
10428
10428
  import os13 from "os";
10429
10429
  import { fileURLToPath as fileURLToPath4 } from "url";
@@ -10571,15 +10571,24 @@ function getDispatchedBy(sessionKey) {
10571
10571
  function resolveExeSession() {
10572
10572
  const mySession = getMySession();
10573
10573
  if (!mySession) return null;
10574
+ const fromSessionName = extractRootExe(mySession);
10574
10575
  try {
10575
10576
  const key = getSessionKey();
10576
10577
  const parentExe = getParentExe(key);
10577
10578
  if (parentExe) {
10578
- return extractRootExe(parentExe) ?? parentExe;
10579
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
10580
+ if (fromSessionName && fromCache !== fromSessionName) {
10581
+ process.stderr.write(
10582
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
10583
+ `
10584
+ );
10585
+ return fromSessionName;
10586
+ }
10587
+ return fromCache;
10579
10588
  }
10580
10589
  } catch {
10581
10590
  }
10582
- return extractRootExe(mySession) ?? mySession;
10591
+ return fromSessionName ?? mySession;
10583
10592
  }
10584
10593
  function isEmployeeAlive(sessionName) {
10585
10594
  return getTransport().isAlive(sessionName);
@@ -10744,6 +10753,24 @@ function sendIntercom(targetSession) {
10744
10753
  }
10745
10754
  } catch {
10746
10755
  }
10756
+ try {
10757
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
10758
+ const agent = baseAgentName(rawAgent);
10759
+ const taskDir = path26.join(process.cwd(), "exe", agent);
10760
+ if (existsSync21(taskDir)) {
10761
+ const files = readdirSync6(taskDir).filter(
10762
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
10763
+ );
10764
+ if (files.length === 0) {
10765
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
10766
+ return "debounced";
10767
+ }
10768
+ } else {
10769
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
10770
+ return "debounced";
10771
+ }
10772
+ } catch {
10773
+ }
10747
10774
  if (transport.isPaneInCopyMode(targetSession)) {
10748
10775
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
10749
10776
  transport.sendKeys(targetSession, "q");
@@ -11411,7 +11438,7 @@ __export(active_agent_exports, {
11411
11438
  resolveActiveAgentFromTmuxSession: () => resolveActiveAgentFromTmuxSession,
11412
11439
  writeActiveAgent: () => writeActiveAgent
11413
11440
  });
11414
- import { readFileSync as readFileSync19, writeFileSync as writeFileSync15, mkdirSync as mkdirSync16, unlinkSync as unlinkSync9, readdirSync as readdirSync6 } from "fs";
11441
+ import { readFileSync as readFileSync19, writeFileSync as writeFileSync15, mkdirSync as mkdirSync16, unlinkSync as unlinkSync9, readdirSync as readdirSync7 } from "fs";
11415
11442
  import { execSync as execSync9 } from "child_process";
11416
11443
  import path27 from "path";
11417
11444
  function isNameWithOptionalInstance(candidate, baseName) {
@@ -11519,7 +11546,7 @@ function getActiveAgent() {
11519
11546
  }
11520
11547
  function getAllActiveAgents() {
11521
11548
  try {
11522
- const files = readdirSync6(CACHE_DIR);
11549
+ const files = readdirSync7(CACHE_DIR);
11523
11550
  const sessions = [];
11524
11551
  for (const file of files) {
11525
11552
  if (!file.startsWith("active-agent-") || !file.endsWith(".json")) continue;
@@ -13106,7 +13133,7 @@ import {
13106
13133
  writeFileSync as writeFileSync17,
13107
13134
  mkdirSync as mkdirSync17,
13108
13135
  chmodSync,
13109
- readdirSync as readdirSync7,
13136
+ readdirSync as readdirSync8,
13110
13137
  unlinkSync as unlinkSync12
13111
13138
  } from "fs";
13112
13139
  import path30 from "path";
@@ -13138,7 +13165,7 @@ function generateSessionWrappers(packageRoot, homeDir) {
13138
13165
  return { created: 0, pathConfigured: false };
13139
13166
  }
13140
13167
  try {
13141
- for (const f of readdirSync7(binDir)) {
13168
+ for (const f of readdirSync8(binDir)) {
13142
13169
  if (f === "exe-start") continue;
13143
13170
  const fPath = path30.join(binDir, f);
13144
13171
  try {
@@ -28613,7 +28640,7 @@ var init_installer3 = __esm({
28613
28640
  });
28614
28641
 
28615
28642
  // src/bin/cli.ts
28616
- import { existsSync as existsSync29, readFileSync as readFileSync26, writeFileSync as writeFileSync19, readdirSync as readdirSync8, rmSync } from "fs";
28643
+ import { existsSync as existsSync29, readFileSync as readFileSync26, writeFileSync as writeFileSync19, readdirSync as readdirSync9, rmSync } from "fs";
28617
28644
  import path43 from "path";
28618
28645
  import os18 from "os";
28619
28646
  var args = process.argv.slice(2);
@@ -29025,7 +29052,7 @@ async function runClaudeUninstall(flags = []) {
29025
29052
  if (existsSync29(skillsDir)) {
29026
29053
  let skillCount = 0;
29027
29054
  try {
29028
- const entries = readdirSync8(skillsDir);
29055
+ const entries = readdirSync9(skillsDir);
29029
29056
  for (const entry of entries) {
29030
29057
  if (entry.startsWith("exe")) {
29031
29058
  const fullPath = path43.join(skillsDir, entry);
@@ -29058,7 +29085,7 @@ async function runClaudeUninstall(flags = []) {
29058
29085
  if (existsSync29(agentsDir)) {
29059
29086
  let agentCount = 0;
29060
29087
  try {
29061
- const entries = readdirSync8(agentsDir).filter((f) => f.endsWith(".md"));
29088
+ const entries = readdirSync9(agentsDir).filter((f) => f.endsWith(".md"));
29062
29089
  let knownNames = /* @__PURE__ */ new Set();
29063
29090
  const rosterPath = path43.join(exeOsDir, "exe-employees.json");
29064
29091
  if (existsSync29(rosterPath)) {
@@ -29086,7 +29113,7 @@ async function runClaudeUninstall(flags = []) {
29086
29113
  if (existsSync29(projectsDir)) {
29087
29114
  let projectCount = 0;
29088
29115
  try {
29089
- const projects = readdirSync8(projectsDir);
29116
+ const projects = readdirSync9(projectsDir);
29090
29117
  for (const proj of projects) {
29091
29118
  const projSettings = path43.join(projectsDir, proj, "settings.json");
29092
29119
  if (!existsSync29(projSettings)) continue;
@@ -5743,7 +5743,7 @@ __export(tmux_routing_exports, {
5743
5743
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
5744
5744
  });
5745
5745
  import { execFileSync as execFileSync2, execSync as execSync7 } from "child_process";
5746
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync7, existsSync as existsSync14, appendFileSync } from "fs";
5746
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync7, existsSync as existsSync14, appendFileSync, readdirSync as readdirSync4 } from "fs";
5747
5747
  import path17 from "path";
5748
5748
  import os9 from "os";
5749
5749
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -5891,15 +5891,24 @@ function getDispatchedBy(sessionKey) {
5891
5891
  function resolveExeSession() {
5892
5892
  const mySession = getMySession();
5893
5893
  if (!mySession) return null;
5894
+ const fromSessionName = extractRootExe(mySession);
5894
5895
  try {
5895
5896
  const key = getSessionKey();
5896
5897
  const parentExe = getParentExe(key);
5897
5898
  if (parentExe) {
5898
- return extractRootExe(parentExe) ?? parentExe;
5899
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
5900
+ if (fromSessionName && fromCache !== fromSessionName) {
5901
+ process.stderr.write(
5902
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
5903
+ `
5904
+ );
5905
+ return fromSessionName;
5906
+ }
5907
+ return fromCache;
5899
5908
  }
5900
5909
  } catch {
5901
5910
  }
5902
- return extractRootExe(mySession) ?? mySession;
5911
+ return fromSessionName ?? mySession;
5903
5912
  }
5904
5913
  function isEmployeeAlive(sessionName) {
5905
5914
  return getTransport().isAlive(sessionName);
@@ -6064,6 +6073,24 @@ function sendIntercom(targetSession) {
6064
6073
  }
6065
6074
  } catch {
6066
6075
  }
6076
+ try {
6077
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
6078
+ const agent = baseAgentName(rawAgent);
6079
+ const taskDir = path17.join(process.cwd(), "exe", agent);
6080
+ if (existsSync14(taskDir)) {
6081
+ const files = readdirSync4(taskDir).filter(
6082
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
6083
+ );
6084
+ if (files.length === 0) {
6085
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
6086
+ return "debounced";
6087
+ }
6088
+ } else {
6089
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
6090
+ return "debounced";
6091
+ }
6092
+ } catch {
6093
+ }
6067
6094
  if (transport.isPaneInCopyMode(targetSession)) {
6068
6095
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
6069
6096
  transport.sendKeys(targetSession, "q");
@@ -6521,7 +6548,7 @@ __export(worker_gate_exports, {
6521
6548
  tryAcquireBackfillLock: () => tryAcquireBackfillLock,
6522
6549
  tryAcquireWorkerSlot: () => tryAcquireWorkerSlot
6523
6550
  });
6524
- import { readdirSync as readdirSync5, writeFileSync as writeFileSync9, unlinkSync as unlinkSync8, mkdirSync as mkdirSync9, existsSync as existsSync15 } from "fs";
6551
+ import { readdirSync as readdirSync6, writeFileSync as writeFileSync9, unlinkSync as unlinkSync8, mkdirSync as mkdirSync9, existsSync as existsSync15 } from "fs";
6525
6552
  import path19 from "path";
6526
6553
  function tryAcquireWorkerSlot() {
6527
6554
  try {
@@ -6529,7 +6556,7 @@ function tryAcquireWorkerSlot() {
6529
6556
  const reservationId = `res-${process.pid}-${Date.now()}`;
6530
6557
  const reservationPath = path19.join(WORKER_PID_DIR, `${reservationId}.pid`);
6531
6558
  writeFileSync9(reservationPath, String(process.pid));
6532
- const files = readdirSync5(WORKER_PID_DIR);
6559
+ const files = readdirSync6(WORKER_PID_DIR);
6533
6560
  let alive = 0;
6534
6561
  for (const f of files) {
6535
6562
  if (!f.endsWith(".pid")) continue;
@@ -6954,7 +6981,7 @@ __export(cloud_sync_exports, {
6954
6981
  mergeRosterFromRemote: () => mergeRosterFromRemote,
6955
6982
  recordRosterDeletion: () => recordRosterDeletion
6956
6983
  });
6957
- import { readFileSync as readFileSync14, writeFileSync as writeFileSync11, existsSync as existsSync17, readdirSync as readdirSync6, mkdirSync as mkdirSync11, appendFileSync as appendFileSync2, unlinkSync as unlinkSync10, openSync as openSync2, closeSync as closeSync2 } from "fs";
6984
+ import { readFileSync as readFileSync14, writeFileSync as writeFileSync11, existsSync as existsSync17, readdirSync as readdirSync7, mkdirSync as mkdirSync11, appendFileSync as appendFileSync2, unlinkSync as unlinkSync10, openSync as openSync2, closeSync as closeSync2 } from "fs";
6958
6985
  import crypto7 from "crypto";
6959
6986
  import path21 from "path";
6960
6987
  import { homedir as homedir2 } from "os";
@@ -7360,7 +7387,7 @@ async function cloudSync(config) {
7360
7387
  rosterResult.employees = employees.length;
7361
7388
  const idDir = path21.join(EXE_AI_DIR, "identity");
7362
7389
  if (existsSync17(idDir)) {
7363
- rosterResult.identities = readdirSync6(idDir).filter((f) => f.endsWith(".md")).length;
7390
+ rosterResult.identities = readdirSync7(idDir).filter((f) => f.endsWith(".md")).length;
7364
7391
  }
7365
7392
  } catch {
7366
7393
  }
@@ -7411,7 +7438,7 @@ function buildRosterBlob(paths) {
7411
7438
  }
7412
7439
  const identities = {};
7413
7440
  if (existsSync17(identityDir)) {
7414
- for (const file of readdirSync6(identityDir).filter((f) => f.endsWith(".md"))) {
7441
+ for (const file of readdirSync7(identityDir).filter((f) => f.endsWith(".md"))) {
7415
7442
  try {
7416
7443
  identities[file] = readFileSync14(path21.join(identityDir, file), "utf-8");
7417
7444
  } catch {
@@ -8209,7 +8236,7 @@ var init_schedules = __esm({
8209
8236
  init_employees();
8210
8237
  import path22 from "path";
8211
8238
  import { mkdir as mkdir5, writeFile as writeFile6 } from "fs/promises";
8212
- import { existsSync as existsSync18, readFileSync as readFileSync15, readdirSync as readdirSync7, unlinkSync as unlinkSync11 } from "fs";
8239
+ import { existsSync as existsSync18, readFileSync as readFileSync15, readdirSync as readdirSync8, unlinkSync as unlinkSync11 } from "fs";
8213
8240
  import os10 from "os";
8214
8241
 
8215
8242
  // src/lib/employee-templates.ts
@@ -8712,7 +8739,7 @@ init_notifications();
8712
8739
  init_config();
8713
8740
  init_session_key();
8714
8741
  init_employees();
8715
- import { readFileSync as readFileSync12, writeFileSync as writeFileSync8, mkdirSync as mkdirSync8, unlinkSync as unlinkSync7, readdirSync as readdirSync4 } from "fs";
8742
+ import { readFileSync as readFileSync12, writeFileSync as writeFileSync8, mkdirSync as mkdirSync8, unlinkSync as unlinkSync7, readdirSync as readdirSync5 } from "fs";
8716
8743
  import { execSync as execSync8 } from "child_process";
8717
8744
  import path18 from "path";
8718
8745
  var CACHE_DIR = path18.join(EXE_AI_DIR, "session-cache");
@@ -8819,18 +8846,18 @@ async function boot(options) {
8819
8846
  } catch {
8820
8847
  }
8821
8848
  try {
8822
- const { readdirSync: readdirSync8, readFileSync: readFs } = await import("fs");
8849
+ const { readdirSync: readdirSync9, readFileSync: readFs } = await import("fs");
8823
8850
  const { STATUS_RE: STATUS_RE2, PRIORITY_RE: PRIORITY_RE2, TITLE_RE: TITLE_RE2 } = await Promise.resolve().then(() => (init_task_scanner(), task_scanner_exports));
8824
8851
  const { getProjectName: getProjectName2 } = await Promise.resolve().then(() => (init_project_name(), project_name_exports));
8825
8852
  const exeDir = "exe";
8826
- const entries = readdirSync8(exeDir, { withFileTypes: true });
8853
+ const entries = readdirSync9(exeDir, { withFileTypes: true });
8827
8854
  const employeeDirs = entries.filter((e) => e.isDirectory() && !["output", "research"].includes(e.name));
8828
8855
  for (const dir of employeeDirs) {
8829
8856
  const employee = dir.name;
8830
8857
  const taskDir = path22.join(exeDir, employee);
8831
8858
  let files;
8832
8859
  try {
8833
- files = readdirSync8(taskDir).filter((f) => f.endsWith(".md"));
8860
+ files = readdirSync9(taskDir).filter((f) => f.endsWith(".md"));
8834
8861
  } catch {
8835
8862
  continue;
8836
8863
  }
@@ -8926,7 +8953,7 @@ async function boot(options) {
8926
8953
  for (const reviewDirName of /* @__PURE__ */ new Set(["exe", coordinatorName])) {
8927
8954
  const reviewDir = path22.join(process.cwd(), "exe", reviewDirName);
8928
8955
  if (existsSync18(reviewDir)) {
8929
- for (const f of readdirSync7(reviewDir)) {
8956
+ for (const f of readdirSync8(reviewDir)) {
8930
8957
  if (f.startsWith("review-") && f.endsWith(".md")) {
8931
8958
  try {
8932
8959
  unlinkSync11(path22.join(reviewDir, f));
@@ -3915,7 +3915,7 @@ __export(tmux_routing_exports, {
3915
3915
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
3916
3916
  });
3917
3917
  import { execFileSync as execFileSync2, execSync as execSync6 } from "child_process";
3918
- import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync11, appendFileSync } from "fs";
3918
+ import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync11, appendFileSync, readdirSync as readdirSync3 } from "fs";
3919
3919
  import path14 from "path";
3920
3920
  import os7 from "os";
3921
3921
  import { fileURLToPath } from "url";
@@ -4063,15 +4063,24 @@ function getDispatchedBy(sessionKey) {
4063
4063
  function resolveExeSession() {
4064
4064
  const mySession = getMySession();
4065
4065
  if (!mySession) return null;
4066
+ const fromSessionName = extractRootExe(mySession);
4066
4067
  try {
4067
4068
  const key = getSessionKey();
4068
4069
  const parentExe = getParentExe(key);
4069
4070
  if (parentExe) {
4070
- return extractRootExe(parentExe) ?? parentExe;
4071
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
4072
+ if (fromSessionName && fromCache !== fromSessionName) {
4073
+ process.stderr.write(
4074
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
4075
+ `
4076
+ );
4077
+ return fromSessionName;
4078
+ }
4079
+ return fromCache;
4071
4080
  }
4072
4081
  } catch {
4073
4082
  }
4074
- return extractRootExe(mySession) ?? mySession;
4083
+ return fromSessionName ?? mySession;
4075
4084
  }
4076
4085
  function isEmployeeAlive(sessionName) {
4077
4086
  return getTransport().isAlive(sessionName);
@@ -4236,6 +4245,24 @@ function sendIntercom(targetSession) {
4236
4245
  }
4237
4246
  } catch {
4238
4247
  }
4248
+ try {
4249
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
4250
+ const agent = baseAgentName(rawAgent);
4251
+ const taskDir = path14.join(process.cwd(), "exe", agent);
4252
+ if (existsSync11(taskDir)) {
4253
+ const files = readdirSync3(taskDir).filter(
4254
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
4255
+ );
4256
+ if (files.length === 0) {
4257
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
4258
+ return "debounced";
4259
+ }
4260
+ } else {
4261
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
4262
+ return "debounced";
4263
+ }
4264
+ } catch {
4265
+ }
4239
4266
  if (transport.isPaneInCopyMode(targetSession)) {
4240
4267
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
4241
4268
  transport.sendKeys(targetSession, "q");
@@ -4656,7 +4683,7 @@ __export(shard_manager_exports, {
4656
4683
  shardExists: () => shardExists
4657
4684
  });
4658
4685
  import path16 from "path";
4659
- import { existsSync as existsSync13, mkdirSync as mkdirSync7, readdirSync as readdirSync3 } from "fs";
4686
+ import { existsSync as existsSync13, mkdirSync as mkdirSync7, readdirSync as readdirSync4 } from "fs";
4660
4687
  import { createClient as createClient2 } from "@libsql/client";
4661
4688
  function initShardManager(encryptionKey) {
4662
4689
  _encryptionKey = encryptionKey;
@@ -4695,7 +4722,7 @@ function shardExists(projectName) {
4695
4722
  }
4696
4723
  function listShards() {
4697
4724
  if (!existsSync13(SHARDS_DIR)) return [];
4698
- return readdirSync3(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
4725
+ return readdirSync4(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
4699
4726
  }
4700
4727
  async function ensureShardSchema(client) {
4701
4728
  await client.execute("PRAGMA journal_mode = WAL");
@@ -8634,7 +8634,7 @@ __export(tmux_routing_exports, {
8634
8634
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
8635
8635
  });
8636
8636
  import { execFileSync as execFileSync2, execSync as execSync6 } from "child_process";
8637
- import { readFileSync as readFileSync12, writeFileSync as writeFileSync7, mkdirSync as mkdirSync8, existsSync as existsSync14, appendFileSync } from "fs";
8637
+ import { readFileSync as readFileSync12, writeFileSync as writeFileSync7, mkdirSync as mkdirSync8, existsSync as existsSync14, appendFileSync, readdirSync as readdirSync4 } from "fs";
8638
8638
  import path18 from "path";
8639
8639
  import os10 from "os";
8640
8640
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -8782,15 +8782,24 @@ function getDispatchedBy(sessionKey) {
8782
8782
  function resolveExeSession() {
8783
8783
  const mySession = getMySession();
8784
8784
  if (!mySession) return null;
8785
+ const fromSessionName = extractRootExe(mySession);
8785
8786
  try {
8786
8787
  const key = getSessionKey();
8787
8788
  const parentExe = getParentExe(key);
8788
8789
  if (parentExe) {
8789
- return extractRootExe(parentExe) ?? parentExe;
8790
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
8791
+ if (fromSessionName && fromCache !== fromSessionName) {
8792
+ process.stderr.write(
8793
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
8794
+ `
8795
+ );
8796
+ return fromSessionName;
8797
+ }
8798
+ return fromCache;
8790
8799
  }
8791
8800
  } catch {
8792
8801
  }
8793
- return extractRootExe(mySession) ?? mySession;
8802
+ return fromSessionName ?? mySession;
8794
8803
  }
8795
8804
  function isEmployeeAlive(sessionName) {
8796
8805
  return getTransport().isAlive(sessionName);
@@ -8955,6 +8964,24 @@ function sendIntercom(targetSession) {
8955
8964
  }
8956
8965
  } catch {
8957
8966
  }
8967
+ try {
8968
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
8969
+ const agent = baseAgentName(rawAgent);
8970
+ const taskDir = path18.join(process.cwd(), "exe", agent);
8971
+ if (existsSync14(taskDir)) {
8972
+ const files = readdirSync4(taskDir).filter(
8973
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
8974
+ );
8975
+ if (files.length === 0) {
8976
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
8977
+ return "debounced";
8978
+ }
8979
+ } else {
8980
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
8981
+ return "debounced";
8982
+ }
8983
+ } catch {
8984
+ }
8958
8985
  if (transport.isPaneInCopyMode(targetSession)) {
8959
8986
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
8960
8987
  transport.sendKeys(targetSession, "q");
@@ -2108,7 +2108,7 @@ var init_plan_limits = __esm({
2108
2108
  });
2109
2109
 
2110
2110
  // src/lib/tmux-routing.ts
2111
- import { readFileSync as readFileSync8, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, existsSync as existsSync10, appendFileSync } from "fs";
2111
+ import { readFileSync as readFileSync8, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, existsSync as existsSync10, appendFileSync, readdirSync as readdirSync3 } from "fs";
2112
2112
  import path11 from "path";
2113
2113
  import os7 from "os";
2114
2114
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -2132,15 +2132,24 @@ function getParentExe(sessionKey) {
2132
2132
  function resolveExeSession() {
2133
2133
  const mySession = getMySession();
2134
2134
  if (!mySession) return null;
2135
+ const fromSessionName = extractRootExe(mySession);
2135
2136
  try {
2136
2137
  const key = getSessionKey();
2137
2138
  const parentExe = getParentExe(key);
2138
2139
  if (parentExe) {
2139
- return extractRootExe(parentExe) ?? parentExe;
2140
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
2141
+ if (fromSessionName && fromCache !== fromSessionName) {
2142
+ process.stderr.write(
2143
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
2144
+ `
2145
+ );
2146
+ return fromSessionName;
2147
+ }
2148
+ return fromCache;
2140
2149
  }
2141
2150
  } catch {
2142
2151
  }
2143
- return extractRootExe(mySession) ?? mySession;
2152
+ return fromSessionName ?? mySession;
2144
2153
  }
2145
2154
  function isExeSession(sessionName) {
2146
2155
  const matchesBaseWithInstance = (baseName) => sessionName === baseName || sessionName.startsWith(baseName) && /^\d+$/.test(sessionName.slice(baseName.length));
@@ -2172,7 +2181,7 @@ var init_tmux_routing = __esm({
2172
2181
 
2173
2182
  // src/lib/tasks-review.ts
2174
2183
  import path12 from "path";
2175
- import { existsSync as existsSync11, readdirSync as readdirSync3, unlinkSync as unlinkSync3 } from "fs";
2184
+ import { existsSync as existsSync11, readdirSync as readdirSync4, unlinkSync as unlinkSync3 } from "fs";
2176
2185
  async function listPendingReviews(limit, sessionScope) {
2177
2186
  const client = getClient();
2178
2187
  if (sessionScope) {
@@ -5751,7 +5751,7 @@ __export(tmux_routing_exports, {
5751
5751
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
5752
5752
  });
5753
5753
  import { execFileSync as execFileSync2, execSync as execSync6 } from "child_process";
5754
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync7, existsSync as existsSync14, appendFileSync } from "fs";
5754
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync7, existsSync as existsSync14, appendFileSync, readdirSync as readdirSync4 } from "fs";
5755
5755
  import path17 from "path";
5756
5756
  import os9 from "os";
5757
5757
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -5899,15 +5899,24 @@ function getDispatchedBy(sessionKey) {
5899
5899
  function resolveExeSession() {
5900
5900
  const mySession = getMySession();
5901
5901
  if (!mySession) return null;
5902
+ const fromSessionName = extractRootExe(mySession);
5902
5903
  try {
5903
5904
  const key = getSessionKey();
5904
5905
  const parentExe = getParentExe(key);
5905
5906
  if (parentExe) {
5906
- return extractRootExe(parentExe) ?? parentExe;
5907
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
5908
+ if (fromSessionName && fromCache !== fromSessionName) {
5909
+ process.stderr.write(
5910
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
5911
+ `
5912
+ );
5913
+ return fromSessionName;
5914
+ }
5915
+ return fromCache;
5907
5916
  }
5908
5917
  } catch {
5909
5918
  }
5910
- return extractRootExe(mySession) ?? mySession;
5919
+ return fromSessionName ?? mySession;
5911
5920
  }
5912
5921
  function isEmployeeAlive(sessionName) {
5913
5922
  return getTransport().isAlive(sessionName);
@@ -6072,6 +6081,24 @@ function sendIntercom(targetSession) {
6072
6081
  }
6073
6082
  } catch {
6074
6083
  }
6084
+ try {
6085
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
6086
+ const agent = baseAgentName(rawAgent);
6087
+ const taskDir = path17.join(process.cwd(), "exe", agent);
6088
+ if (existsSync14(taskDir)) {
6089
+ const files = readdirSync4(taskDir).filter(
6090
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
6091
+ );
6092
+ if (files.length === 0) {
6093
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
6094
+ return "debounced";
6095
+ }
6096
+ } else {
6097
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
6098
+ return "debounced";
6099
+ }
6100
+ } catch {
6101
+ }
6075
6102
  if (transport.isPaneInCopyMode(targetSession)) {
6076
6103
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
6077
6104
  transport.sendKeys(targetSession, "q");
@@ -2082,7 +2082,7 @@ var init_plan_limits = __esm({
2082
2082
  });
2083
2083
 
2084
2084
  // src/lib/tmux-routing.ts
2085
- import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, existsSync as existsSync9, appendFileSync } from "fs";
2085
+ import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, existsSync as existsSync9, appendFileSync, readdirSync as readdirSync2 } from "fs";
2086
2086
  import path10 from "path";
2087
2087
  import os6 from "os";
2088
2088
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -2106,15 +2106,24 @@ function getParentExe(sessionKey) {
2106
2106
  function resolveExeSession() {
2107
2107
  const mySession = getMySession();
2108
2108
  if (!mySession) return null;
2109
+ const fromSessionName = extractRootExe(mySession);
2109
2110
  try {
2110
2111
  const key = getSessionKey();
2111
2112
  const parentExe = getParentExe(key);
2112
2113
  if (parentExe) {
2113
- return extractRootExe(parentExe) ?? parentExe;
2114
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
2115
+ if (fromSessionName && fromCache !== fromSessionName) {
2116
+ process.stderr.write(
2117
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
2118
+ `
2119
+ );
2120
+ return fromSessionName;
2121
+ }
2122
+ return fromCache;
2114
2123
  }
2115
2124
  } catch {
2116
2125
  }
2117
- return extractRootExe(mySession) ?? mySession;
2126
+ return fromSessionName ?? mySession;
2118
2127
  }
2119
2128
  var SPAWN_LOCK_DIR, SESSION_CACHE, INTERCOM_LOG2, DEBOUNCE_FILE, DEBOUNCE_CLEANUP_AGE_MS;
2120
2129
  var init_tmux_routing = __esm({