@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.
@@ -6813,7 +6813,7 @@ __export(tmux_routing_exports, {
6813
6813
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
6814
6814
  });
6815
6815
  import { execFileSync as execFileSync2, execSync as execSync8 } from "child_process";
6816
- import { readFileSync as readFileSync13, writeFileSync as writeFileSync8, mkdirSync as mkdirSync8, existsSync as existsSync16, appendFileSync } from "fs";
6816
+ import { readFileSync as readFileSync13, writeFileSync as writeFileSync8, mkdirSync as mkdirSync8, existsSync as existsSync16, appendFileSync, readdirSync as readdirSync6 } from "fs";
6817
6817
  import path20 from "path";
6818
6818
  import os9 from "os";
6819
6819
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -6961,15 +6961,24 @@ function getDispatchedBy(sessionKey) {
6961
6961
  function resolveExeSession() {
6962
6962
  const mySession = getMySession();
6963
6963
  if (!mySession) return null;
6964
+ const fromSessionName = extractRootExe(mySession);
6964
6965
  try {
6965
6966
  const key = getSessionKey();
6966
6967
  const parentExe = getParentExe(key);
6967
6968
  if (parentExe) {
6968
- return extractRootExe(parentExe) ?? parentExe;
6969
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
6970
+ if (fromSessionName && fromCache !== fromSessionName) {
6971
+ process.stderr.write(
6972
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
6973
+ `
6974
+ );
6975
+ return fromSessionName;
6976
+ }
6977
+ return fromCache;
6969
6978
  }
6970
6979
  } catch {
6971
6980
  }
6972
- return extractRootExe(mySession) ?? mySession;
6981
+ return fromSessionName ?? mySession;
6973
6982
  }
6974
6983
  function isEmployeeAlive(sessionName) {
6975
6984
  return getTransport().isAlive(sessionName);
@@ -7134,6 +7143,24 @@ function sendIntercom(targetSession) {
7134
7143
  }
7135
7144
  } catch {
7136
7145
  }
7146
+ try {
7147
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
7148
+ const agent = baseAgentName(rawAgent);
7149
+ const taskDir = path20.join(process.cwd(), "exe", agent);
7150
+ if (existsSync16(taskDir)) {
7151
+ const files = readdirSync6(taskDir).filter(
7152
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
7153
+ );
7154
+ if (files.length === 0) {
7155
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
7156
+ return "debounced";
7157
+ }
7158
+ } else {
7159
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
7160
+ return "debounced";
7161
+ }
7162
+ } catch {
7163
+ }
7137
7164
  if (transport.isPaneInCopyMode(targetSession)) {
7138
7165
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
7139
7166
  transport.sendKeys(targetSession, "q");
@@ -4588,7 +4588,7 @@ __export(tmux_routing_exports, {
4588
4588
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
4589
4589
  });
4590
4590
  import { execFileSync as execFileSync2, execSync as execSync7 } from "child_process";
4591
- import { readFileSync as readFileSync12, writeFileSync as writeFileSync8, mkdirSync as mkdirSync7, existsSync as existsSync12, appendFileSync } from "fs";
4591
+ import { readFileSync as readFileSync12, writeFileSync as writeFileSync8, mkdirSync as mkdirSync7, existsSync as existsSync12, appendFileSync, readdirSync as readdirSync4 } from "fs";
4592
4592
  import path16 from "path";
4593
4593
  import os8 from "os";
4594
4594
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -4736,15 +4736,24 @@ function getDispatchedBy(sessionKey) {
4736
4736
  function resolveExeSession() {
4737
4737
  const mySession = getMySession();
4738
4738
  if (!mySession) return null;
4739
+ const fromSessionName = extractRootExe(mySession);
4739
4740
  try {
4740
4741
  const key = getSessionKey();
4741
4742
  const parentExe = getParentExe(key);
4742
4743
  if (parentExe) {
4743
- return extractRootExe(parentExe) ?? parentExe;
4744
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
4745
+ if (fromSessionName && fromCache !== fromSessionName) {
4746
+ process.stderr.write(
4747
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
4748
+ `
4749
+ );
4750
+ return fromSessionName;
4751
+ }
4752
+ return fromCache;
4744
4753
  }
4745
4754
  } catch {
4746
4755
  }
4747
- return extractRootExe(mySession) ?? mySession;
4756
+ return fromSessionName ?? mySession;
4748
4757
  }
4749
4758
  function isEmployeeAlive(sessionName) {
4750
4759
  return getTransport().isAlive(sessionName);
@@ -4909,6 +4918,24 @@ function sendIntercom(targetSession) {
4909
4918
  }
4910
4919
  } catch {
4911
4920
  }
4921
+ try {
4922
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
4923
+ const agent = baseAgentName(rawAgent);
4924
+ const taskDir = path16.join(process.cwd(), "exe", agent);
4925
+ if (existsSync12(taskDir)) {
4926
+ const files = readdirSync4(taskDir).filter(
4927
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
4928
+ );
4929
+ if (files.length === 0) {
4930
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
4931
+ return "debounced";
4932
+ }
4933
+ } else {
4934
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
4935
+ return "debounced";
4936
+ }
4937
+ } catch {
4938
+ }
4912
4939
  if (transport.isPaneInCopyMode(targetSession)) {
4913
4940
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
4914
4941
  transport.sendKeys(targetSession, "q");
@@ -5419,7 +5446,7 @@ __export(shard_manager_exports, {
5419
5446
  shardExists: () => shardExists
5420
5447
  });
5421
5448
  import path18 from "path";
5422
- import { existsSync as existsSync14, mkdirSync as mkdirSync8, readdirSync as readdirSync4 } from "fs";
5449
+ import { existsSync as existsSync14, mkdirSync as mkdirSync8, readdirSync as readdirSync5 } from "fs";
5423
5450
  import { createClient as createClient2 } from "@libsql/client";
5424
5451
  function initShardManager(encryptionKey) {
5425
5452
  _encryptionKey = encryptionKey;
@@ -5458,7 +5485,7 @@ function shardExists(projectName) {
5458
5485
  }
5459
5486
  function listShards() {
5460
5487
  if (!existsSync14(SHARDS_DIR)) return [];
5461
- return readdirSync4(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
5488
+ return readdirSync5(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
5462
5489
  }
5463
5490
  async function ensureShardSchema(client) {
5464
5491
  await client.execute("PRAGMA journal_mode = WAL");
@@ -5390,7 +5390,7 @@ var init_plan_limits = __esm({
5390
5390
  });
5391
5391
 
5392
5392
  // src/lib/tmux-routing.ts
5393
- import { readFileSync as readFileSync10, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6, existsSync as existsSync12, appendFileSync } from "fs";
5393
+ import { readFileSync as readFileSync10, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6, existsSync as existsSync12, appendFileSync, readdirSync as readdirSync4 } from "fs";
5394
5394
  import path15 from "path";
5395
5395
  import os7 from "os";
5396
5396
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -5414,15 +5414,24 @@ function getParentExe(sessionKey) {
5414
5414
  function resolveExeSession() {
5415
5415
  const mySession = getMySession();
5416
5416
  if (!mySession) return null;
5417
+ const fromSessionName = extractRootExe(mySession);
5417
5418
  try {
5418
5419
  const key = getSessionKey();
5419
5420
  const parentExe = getParentExe(key);
5420
5421
  if (parentExe) {
5421
- return extractRootExe(parentExe) ?? parentExe;
5422
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
5423
+ if (fromSessionName && fromCache !== fromSessionName) {
5424
+ process.stderr.write(
5425
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
5426
+ `
5427
+ );
5428
+ return fromSessionName;
5429
+ }
5430
+ return fromCache;
5422
5431
  }
5423
5432
  } catch {
5424
5433
  }
5425
- return extractRootExe(mySession) ?? mySession;
5434
+ return fromSessionName ?? mySession;
5426
5435
  }
5427
5436
  var SPAWN_LOCK_DIR, SESSION_CACHE, INTERCOM_LOG2, DEBOUNCE_FILE, DEBOUNCE_CLEANUP_AGE_MS;
5428
5437
  var init_tmux_routing = __esm({
@@ -2114,7 +2114,7 @@ var init_plan_limits = __esm({
2114
2114
  });
2115
2115
 
2116
2116
  // src/lib/tmux-routing.ts
2117
- import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, existsSync as existsSync8, appendFileSync } from "fs";
2117
+ import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, existsSync as existsSync8, appendFileSync, readdirSync as readdirSync2 } from "fs";
2118
2118
  import path10 from "path";
2119
2119
  import os6 from "os";
2120
2120
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -2138,15 +2138,24 @@ function getParentExe(sessionKey) {
2138
2138
  function resolveExeSession() {
2139
2139
  const mySession = getMySession();
2140
2140
  if (!mySession) return null;
2141
+ const fromSessionName = extractRootExe(mySession);
2141
2142
  try {
2142
2143
  const key = getSessionKey();
2143
2144
  const parentExe = getParentExe(key);
2144
2145
  if (parentExe) {
2145
- return extractRootExe(parentExe) ?? parentExe;
2146
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
2147
+ if (fromSessionName && fromCache !== fromSessionName) {
2148
+ process.stderr.write(
2149
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
2150
+ `
2151
+ );
2152
+ return fromSessionName;
2153
+ }
2154
+ return fromCache;
2146
2155
  }
2147
2156
  } catch {
2148
2157
  }
2149
- return extractRootExe(mySession) ?? mySession;
2158
+ return fromSessionName ?? mySession;
2150
2159
  }
2151
2160
  var SPAWN_LOCK_DIR, SESSION_CACHE, INTERCOM_LOG2, DEBOUNCE_FILE, DEBOUNCE_CLEANUP_AGE_MS;
2152
2161
  var init_tmux_routing = __esm({
@@ -2330,7 +2339,7 @@ __export(shard_manager_exports, {
2330
2339
  shardExists: () => shardExists
2331
2340
  });
2332
2341
  import path12 from "path";
2333
- import { existsSync as existsSync10, mkdirSync as mkdirSync6, readdirSync as readdirSync2 } from "fs";
2342
+ import { existsSync as existsSync10, mkdirSync as mkdirSync6, readdirSync as readdirSync3 } from "fs";
2334
2343
  import { createClient as createClient2 } from "@libsql/client";
2335
2344
  function initShardManager(encryptionKey) {
2336
2345
  _encryptionKey = encryptionKey;
@@ -2369,7 +2378,7 @@ function shardExists(projectName) {
2369
2378
  }
2370
2379
  function listShards() {
2371
2380
  if (!existsSync10(SHARDS_DIR)) return [];
2372
- return readdirSync2(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
2381
+ return readdirSync3(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
2373
2382
  }
2374
2383
  async function ensureShardSchema(client) {
2375
2384
  await client.execute("PRAGMA journal_mode = WAL");
@@ -2089,7 +2089,7 @@ var init_plan_limits = __esm({
2089
2089
  });
2090
2090
 
2091
2091
  // src/lib/tmux-routing.ts
2092
- import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, existsSync as existsSync8, appendFileSync } from "fs";
2092
+ import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, existsSync as existsSync8, appendFileSync, readdirSync as readdirSync2 } from "fs";
2093
2093
  import path10 from "path";
2094
2094
  import os6 from "os";
2095
2095
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -2113,15 +2113,24 @@ function getParentExe(sessionKey) {
2113
2113
  function resolveExeSession() {
2114
2114
  const mySession = getMySession();
2115
2115
  if (!mySession) return null;
2116
+ const fromSessionName = extractRootExe(mySession);
2116
2117
  try {
2117
2118
  const key = getSessionKey();
2118
2119
  const parentExe = getParentExe(key);
2119
2120
  if (parentExe) {
2120
- return extractRootExe(parentExe) ?? parentExe;
2121
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
2122
+ if (fromSessionName && fromCache !== fromSessionName) {
2123
+ process.stderr.write(
2124
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
2125
+ `
2126
+ );
2127
+ return fromSessionName;
2128
+ }
2129
+ return fromCache;
2121
2130
  }
2122
2131
  } catch {
2123
2132
  }
2124
- return extractRootExe(mySession) ?? mySession;
2133
+ return fromSessionName ?? mySession;
2125
2134
  }
2126
2135
  var SPAWN_LOCK_DIR, SESSION_CACHE, INTERCOM_LOG2, DEBOUNCE_FILE, DEBOUNCE_CLEANUP_AGE_MS;
2127
2136
  var init_tmux_routing = __esm({
@@ -2305,7 +2314,7 @@ __export(shard_manager_exports, {
2305
2314
  shardExists: () => shardExists
2306
2315
  });
2307
2316
  import path12 from "path";
2308
- import { existsSync as existsSync10, mkdirSync as mkdirSync6, readdirSync as readdirSync2 } from "fs";
2317
+ import { existsSync as existsSync10, mkdirSync as mkdirSync6, readdirSync as readdirSync3 } from "fs";
2309
2318
  import { createClient as createClient2 } from "@libsql/client";
2310
2319
  function initShardManager(encryptionKey) {
2311
2320
  _encryptionKey = encryptionKey;
@@ -2344,7 +2353,7 @@ function shardExists(projectName) {
2344
2353
  }
2345
2354
  function listShards() {
2346
2355
  if (!existsSync10(SHARDS_DIR)) return [];
2347
- return readdirSync2(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
2356
+ return readdirSync3(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
2348
2357
  }
2349
2358
  async function ensureShardSchema(client) {
2350
2359
  await client.execute("PRAGMA journal_mode = WAL");
@@ -3442,7 +3442,7 @@ var init_plan_limits = __esm({
3442
3442
  });
3443
3443
 
3444
3444
  // src/lib/tmux-routing.ts
3445
- import { readFileSync as readFileSync9, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, existsSync as existsSync11, appendFileSync } from "fs";
3445
+ import { readFileSync as readFileSync9, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, existsSync as existsSync11, appendFileSync, readdirSync as readdirSync3 } from "fs";
3446
3446
  import path12 from "path";
3447
3447
  import os8 from "os";
3448
3448
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -3466,15 +3466,24 @@ function getParentExe(sessionKey) {
3466
3466
  function resolveExeSession() {
3467
3467
  const mySession = getMySession();
3468
3468
  if (!mySession) return null;
3469
+ const fromSessionName = extractRootExe(mySession);
3469
3470
  try {
3470
3471
  const key = getSessionKey();
3471
3472
  const parentExe = getParentExe(key);
3472
3473
  if (parentExe) {
3473
- return extractRootExe(parentExe) ?? parentExe;
3474
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
3475
+ if (fromSessionName && fromCache !== fromSessionName) {
3476
+ process.stderr.write(
3477
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
3478
+ `
3479
+ );
3480
+ return fromSessionName;
3481
+ }
3482
+ return fromCache;
3474
3483
  }
3475
3484
  } catch {
3476
3485
  }
3477
- return extractRootExe(mySession) ?? mySession;
3486
+ return fromSessionName ?? mySession;
3478
3487
  }
3479
3488
  var SPAWN_LOCK_DIR, SESSION_CACHE, INTERCOM_LOG2, DEBOUNCE_FILE, DEBOUNCE_CLEANUP_AGE_MS;
3480
3489
  var init_tmux_routing = __esm({
@@ -3601,7 +3610,7 @@ __export(worker_gate_exports, {
3601
3610
  tryAcquireBackfillLock: () => tryAcquireBackfillLock,
3602
3611
  tryAcquireWorkerSlot: () => tryAcquireWorkerSlot
3603
3612
  });
3604
- import { readdirSync as readdirSync3, writeFileSync as writeFileSync6, unlinkSync as unlinkSync4, mkdirSync as mkdirSync6, existsSync as existsSync12 } from "fs";
3613
+ import { readdirSync as readdirSync4, writeFileSync as writeFileSync6, unlinkSync as unlinkSync4, mkdirSync as mkdirSync6, existsSync as existsSync12 } from "fs";
3605
3614
  import path13 from "path";
3606
3615
  function tryAcquireWorkerSlot() {
3607
3616
  try {
@@ -3609,7 +3618,7 @@ function tryAcquireWorkerSlot() {
3609
3618
  const reservationId = `res-${process.pid}-${Date.now()}`;
3610
3619
  const reservationPath = path13.join(WORKER_PID_DIR, `${reservationId}.pid`);
3611
3620
  writeFileSync6(reservationPath, String(process.pid));
3612
- const files = readdirSync3(WORKER_PID_DIR);
3621
+ const files = readdirSync4(WORKER_PID_DIR);
3613
3622
  let alive = 0;
3614
3623
  for (const f of files) {
3615
3624
  if (!f.endsWith(".pid")) continue;
@@ -4034,7 +4043,7 @@ __export(cloud_sync_exports, {
4034
4043
  mergeRosterFromRemote: () => mergeRosterFromRemote,
4035
4044
  recordRosterDeletion: () => recordRosterDeletion
4036
4045
  });
4037
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync8, existsSync as existsSync14, readdirSync as readdirSync4, mkdirSync as mkdirSync8, appendFileSync as appendFileSync2, unlinkSync as unlinkSync6, openSync as openSync2, closeSync as closeSync2 } from "fs";
4046
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync8, existsSync as existsSync14, readdirSync as readdirSync5, mkdirSync as mkdirSync8, appendFileSync as appendFileSync2, unlinkSync as unlinkSync6, openSync as openSync2, closeSync as closeSync2 } from "fs";
4038
4047
  import crypto3 from "crypto";
4039
4048
  import path15 from "path";
4040
4049
  import { homedir as homedir2 } from "os";
@@ -4440,7 +4449,7 @@ async function cloudSync(config) {
4440
4449
  rosterResult.employees = employees.length;
4441
4450
  const idDir = path15.join(EXE_AI_DIR, "identity");
4442
4451
  if (existsSync14(idDir)) {
4443
- rosterResult.identities = readdirSync4(idDir).filter((f) => f.endsWith(".md")).length;
4452
+ rosterResult.identities = readdirSync5(idDir).filter((f) => f.endsWith(".md")).length;
4444
4453
  }
4445
4454
  } catch {
4446
4455
  }
@@ -4491,7 +4500,7 @@ function buildRosterBlob(paths) {
4491
4500
  }
4492
4501
  const identities = {};
4493
4502
  if (existsSync14(identityDir)) {
4494
- for (const file of readdirSync4(identityDir).filter((f) => f.endsWith(".md"))) {
4503
+ for (const file of readdirSync5(identityDir).filter((f) => f.endsWith(".md"))) {
4495
4504
  try {
4496
4505
  identities[file] = readFileSync11(path15.join(identityDir, file), "utf-8");
4497
4506
  } catch {
package/dist/index.js CHANGED
@@ -4814,7 +4814,7 @@ __export(tmux_routing_exports, {
4814
4814
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
4815
4815
  });
4816
4816
  import { execFileSync as execFileSync2, execSync as execSync7 } from "child_process";
4817
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync12, appendFileSync } from "fs";
4817
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync12, appendFileSync, readdirSync as readdirSync3 } from "fs";
4818
4818
  import path16 from "path";
4819
4819
  import os9 from "os";
4820
4820
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -4962,15 +4962,24 @@ function getDispatchedBy(sessionKey) {
4962
4962
  function resolveExeSession() {
4963
4963
  const mySession = getMySession();
4964
4964
  if (!mySession) return null;
4965
+ const fromSessionName = extractRootExe(mySession);
4965
4966
  try {
4966
4967
  const key = getSessionKey();
4967
4968
  const parentExe = getParentExe(key);
4968
4969
  if (parentExe) {
4969
- return extractRootExe(parentExe) ?? parentExe;
4970
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
4971
+ if (fromSessionName && fromCache !== fromSessionName) {
4972
+ process.stderr.write(
4973
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
4974
+ `
4975
+ );
4976
+ return fromSessionName;
4977
+ }
4978
+ return fromCache;
4970
4979
  }
4971
4980
  } catch {
4972
4981
  }
4973
- return extractRootExe(mySession) ?? mySession;
4982
+ return fromSessionName ?? mySession;
4974
4983
  }
4975
4984
  function isEmployeeAlive(sessionName) {
4976
4985
  return getTransport().isAlive(sessionName);
@@ -5135,6 +5144,24 @@ function sendIntercom(targetSession) {
5135
5144
  }
5136
5145
  } catch {
5137
5146
  }
5147
+ try {
5148
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
5149
+ const agent = baseAgentName(rawAgent);
5150
+ const taskDir = path16.join(process.cwd(), "exe", agent);
5151
+ if (existsSync12(taskDir)) {
5152
+ const files = readdirSync3(taskDir).filter(
5153
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
5154
+ );
5155
+ if (files.length === 0) {
5156
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
5157
+ return "debounced";
5158
+ }
5159
+ } else {
5160
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
5161
+ return "debounced";
5162
+ }
5163
+ } catch {
5164
+ }
5138
5165
  if (transport.isPaneInCopyMode(targetSession)) {
5139
5166
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
5140
5167
  transport.sendKeys(targetSession, "q");
@@ -5621,7 +5648,7 @@ __export(shard_manager_exports, {
5621
5648
  shardExists: () => shardExists
5622
5649
  });
5623
5650
  import path18 from "path";
5624
- import { existsSync as existsSync14, mkdirSync as mkdirSync7, readdirSync as readdirSync3 } from "fs";
5651
+ import { existsSync as existsSync14, mkdirSync as mkdirSync7, readdirSync as readdirSync4 } from "fs";
5625
5652
  import { createClient as createClient2 } from "@libsql/client";
5626
5653
  function initShardManager(encryptionKey) {
5627
5654
  _encryptionKey = encryptionKey;
@@ -5660,7 +5687,7 @@ function shardExists(projectName) {
5660
5687
  }
5661
5688
  function listShards() {
5662
5689
  if (!existsSync14(SHARDS_DIR)) return [];
5663
- return readdirSync3(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
5690
+ return readdirSync4(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
5664
5691
  }
5665
5692
  async function ensureShardSchema(client) {
5666
5693
  await client.execute("PRAGMA journal_mode = WAL");
@@ -5014,7 +5014,7 @@ __export(tmux_routing_exports, {
5014
5014
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
5015
5015
  });
5016
5016
  import { execFileSync as execFileSync2, execSync as execSync7 } from "child_process";
5017
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync12, appendFileSync } from "fs";
5017
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync12, appendFileSync, readdirSync as readdirSync3 } from "fs";
5018
5018
  import path15 from "path";
5019
5019
  import os8 from "os";
5020
5020
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -5162,15 +5162,24 @@ function getDispatchedBy(sessionKey) {
5162
5162
  function resolveExeSession() {
5163
5163
  const mySession = getMySession();
5164
5164
  if (!mySession) return null;
5165
+ const fromSessionName = extractRootExe(mySession);
5165
5166
  try {
5166
5167
  const key = getSessionKey();
5167
5168
  const parentExe = getParentExe(key);
5168
5169
  if (parentExe) {
5169
- return extractRootExe(parentExe) ?? parentExe;
5170
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
5171
+ if (fromSessionName && fromCache !== fromSessionName) {
5172
+ process.stderr.write(
5173
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
5174
+ `
5175
+ );
5176
+ return fromSessionName;
5177
+ }
5178
+ return fromCache;
5170
5179
  }
5171
5180
  } catch {
5172
5181
  }
5173
- return extractRootExe(mySession) ?? mySession;
5182
+ return fromSessionName ?? mySession;
5174
5183
  }
5175
5184
  function isEmployeeAlive(sessionName) {
5176
5185
  return getTransport().isAlive(sessionName);
@@ -5335,6 +5344,24 @@ function sendIntercom(targetSession) {
5335
5344
  }
5336
5345
  } catch {
5337
5346
  }
5347
+ try {
5348
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
5349
+ const agent = baseAgentName(rawAgent);
5350
+ const taskDir = path15.join(process.cwd(), "exe", agent);
5351
+ if (existsSync12(taskDir)) {
5352
+ const files = readdirSync3(taskDir).filter(
5353
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
5354
+ );
5355
+ if (files.length === 0) {
5356
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
5357
+ return "debounced";
5358
+ }
5359
+ } else {
5360
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
5361
+ return "debounced";
5362
+ }
5363
+ } catch {
5364
+ }
5338
5365
  if (transport.isPaneInCopyMode(targetSession)) {
5339
5366
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
5340
5367
  transport.sendKeys(targetSession, "q");
@@ -6820,7 +6847,7 @@ __export(shard_manager_exports, {
6820
6847
  shardExists: () => shardExists
6821
6848
  });
6822
6849
  import path18 from "path";
6823
- import { existsSync as existsSync16, mkdirSync as mkdirSync7, readdirSync as readdirSync3 } from "fs";
6850
+ import { existsSync as existsSync16, mkdirSync as mkdirSync7, readdirSync as readdirSync4 } from "fs";
6824
6851
  import { createClient as createClient2 } from "@libsql/client";
6825
6852
  function initShardManager(encryptionKey) {
6826
6853
  _encryptionKey = encryptionKey;
@@ -6859,7 +6886,7 @@ function shardExists(projectName) {
6859
6886
  }
6860
6887
  function listShards() {
6861
6888
  if (!existsSync16(SHARDS_DIR)) return [];
6862
- return readdirSync3(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
6889
+ return readdirSync4(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
6863
6890
  }
6864
6891
  async function ensureShardSchema(client) {
6865
6892
  await client.execute("PRAGMA journal_mode = WAL");
@@ -548,7 +548,7 @@ var init_plan_limits = __esm({
548
548
 
549
549
  // src/lib/tmux-routing.ts
550
550
  import { execFileSync as execFileSync2, execSync as execSync4 } from "child_process";
551
- import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, mkdirSync as mkdirSync4, existsSync as existsSync7, appendFileSync } from "fs";
551
+ import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, mkdirSync as mkdirSync4, existsSync as existsSync7, appendFileSync, readdirSync } from "fs";
552
552
  import path8 from "path";
553
553
  import os5 from "os";
554
554
  import { fileURLToPath } from "url";
@@ -599,15 +599,24 @@ function getParentExe(sessionKey) {
599
599
  function resolveExeSession() {
600
600
  const mySession = getMySession();
601
601
  if (!mySession) return null;
602
+ const fromSessionName = extractRootExe(mySession);
602
603
  try {
603
604
  const key = getSessionKey();
604
605
  const parentExe = getParentExe(key);
605
606
  if (parentExe) {
606
- return extractRootExe(parentExe) ?? parentExe;
607
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
608
+ if (fromSessionName && fromCache !== fromSessionName) {
609
+ process.stderr.write(
610
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
611
+ `
612
+ );
613
+ return fromSessionName;
614
+ }
615
+ return fromCache;
607
616
  }
608
617
  } catch {
609
618
  }
610
- return extractRootExe(mySession) ?? mySession;
619
+ return fromSessionName ?? mySession;
611
620
  }
612
621
  function isEmployeeAlive(sessionName) {
613
622
  return getTransport().isAlive(sessionName);
@@ -733,6 +742,24 @@ function sendIntercom(targetSession) {
733
742
  }
734
743
  } catch {
735
744
  }
745
+ try {
746
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
747
+ const agent = baseAgentName(rawAgent);
748
+ const taskDir = path8.join(process.cwd(), "exe", agent);
749
+ if (existsSync7(taskDir)) {
750
+ const files = readdirSync(taskDir).filter(
751
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
752
+ );
753
+ if (files.length === 0) {
754
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
755
+ return "debounced";
756
+ }
757
+ } else {
758
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
759
+ return "debounced";
760
+ }
761
+ } catch {
762
+ }
736
763
  if (transport.isPaneInCopyMode(targetSession)) {
737
764
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
738
765
  transport.sendKeys(targetSession, "q");
package/dist/lib/tasks.js CHANGED
@@ -1320,7 +1320,7 @@ __export(tmux_routing_exports, {
1320
1320
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
1321
1321
  });
1322
1322
  import { execFileSync as execFileSync2, execSync as execSync4 } from "child_process";
1323
- import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, existsSync as existsSync9, appendFileSync } from "fs";
1323
+ import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, existsSync as existsSync9, appendFileSync, readdirSync as readdirSync2 } from "fs";
1324
1324
  import path9 from "path";
1325
1325
  import os6 from "os";
1326
1326
  import { fileURLToPath } from "url";
@@ -1468,15 +1468,24 @@ function getDispatchedBy(sessionKey) {
1468
1468
  function resolveExeSession() {
1469
1469
  const mySession = getMySession();
1470
1470
  if (!mySession) return null;
1471
+ const fromSessionName = extractRootExe(mySession);
1471
1472
  try {
1472
1473
  const key = getSessionKey();
1473
1474
  const parentExe = getParentExe(key);
1474
1475
  if (parentExe) {
1475
- return extractRootExe(parentExe) ?? parentExe;
1476
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
1477
+ if (fromSessionName && fromCache !== fromSessionName) {
1478
+ process.stderr.write(
1479
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
1480
+ `
1481
+ );
1482
+ return fromSessionName;
1483
+ }
1484
+ return fromCache;
1476
1485
  }
1477
1486
  } catch {
1478
1487
  }
1479
- return extractRootExe(mySession) ?? mySession;
1488
+ return fromSessionName ?? mySession;
1480
1489
  }
1481
1490
  function isEmployeeAlive(sessionName) {
1482
1491
  return getTransport().isAlive(sessionName);
@@ -1641,6 +1650,24 @@ function sendIntercom(targetSession) {
1641
1650
  }
1642
1651
  } catch {
1643
1652
  }
1653
+ try {
1654
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
1655
+ const agent = baseAgentName(rawAgent);
1656
+ const taskDir = path9.join(process.cwd(), "exe", agent);
1657
+ if (existsSync9(taskDir)) {
1658
+ const files = readdirSync2(taskDir).filter(
1659
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
1660
+ );
1661
+ if (files.length === 0) {
1662
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
1663
+ return "debounced";
1664
+ }
1665
+ } else {
1666
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
1667
+ return "debounced";
1668
+ }
1669
+ } catch {
1670
+ }
1644
1671
  if (transport.isPaneInCopyMode(targetSession)) {
1645
1672
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
1646
1673
  transport.sendKeys(targetSession, "q");
@@ -2662,7 +2689,7 @@ var init_tasks_crud = __esm({
2662
2689
 
2663
2690
  // src/lib/tasks-review.ts
2664
2691
  import path11 from "path";
2665
- import { existsSync as existsSync11, readdirSync as readdirSync2, unlinkSync as unlinkSync4 } from "fs";
2692
+ import { existsSync as existsSync11, readdirSync as readdirSync3, unlinkSync as unlinkSync4 } from "fs";
2666
2693
  async function countPendingReviews(sessionScope) {
2667
2694
  const client = getClient();
2668
2695
  if (sessionScope) {
@@ -2845,7 +2872,7 @@ async function cleanupReviewFile(row, taskFile, _baseDir) {
2845
2872
  try {
2846
2873
  const cacheDir = path11.join(EXE_AI_DIR, "session-cache");
2847
2874
  if (existsSync11(cacheDir)) {
2848
- for (const f of readdirSync2(cacheDir)) {
2875
+ for (const f of readdirSync3(cacheDir)) {
2849
2876
  if (f.startsWith("review-notified-")) {
2850
2877
  unlinkSync4(path11.join(cacheDir, f));
2851
2878
  }