@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.
@@ -2907,7 +2907,7 @@ __export(tmux_routing_exports, {
2907
2907
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
2908
2908
  });
2909
2909
  import { execFileSync as execFileSync2, execSync as execSync6 } from "child_process";
2910
- import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync11, appendFileSync } from "fs";
2910
+ import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync11, appendFileSync, readdirSync as readdirSync3 } from "fs";
2911
2911
  import path14 from "path";
2912
2912
  import os7 from "os";
2913
2913
  import { fileURLToPath } from "url";
@@ -3055,15 +3055,24 @@ function getDispatchedBy(sessionKey) {
3055
3055
  function resolveExeSession() {
3056
3056
  const mySession = getMySession();
3057
3057
  if (!mySession) return null;
3058
+ const fromSessionName = extractRootExe(mySession);
3058
3059
  try {
3059
3060
  const key = getSessionKey();
3060
3061
  const parentExe = getParentExe(key);
3061
3062
  if (parentExe) {
3062
- return extractRootExe(parentExe) ?? parentExe;
3063
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
3064
+ if (fromSessionName && fromCache !== fromSessionName) {
3065
+ process.stderr.write(
3066
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
3067
+ `
3068
+ );
3069
+ return fromSessionName;
3070
+ }
3071
+ return fromCache;
3063
3072
  }
3064
3073
  } catch {
3065
3074
  }
3066
- return extractRootExe(mySession) ?? mySession;
3075
+ return fromSessionName ?? mySession;
3067
3076
  }
3068
3077
  function isEmployeeAlive(sessionName) {
3069
3078
  return getTransport().isAlive(sessionName);
@@ -3228,6 +3237,24 @@ function sendIntercom(targetSession) {
3228
3237
  }
3229
3238
  } catch {
3230
3239
  }
3240
+ try {
3241
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
3242
+ const agent = baseAgentName(rawAgent);
3243
+ const taskDir = path14.join(process.cwd(), "exe", agent);
3244
+ if (existsSync11(taskDir)) {
3245
+ const files = readdirSync3(taskDir).filter(
3246
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
3247
+ );
3248
+ if (files.length === 0) {
3249
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
3250
+ return "debounced";
3251
+ }
3252
+ } else {
3253
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
3254
+ return "debounced";
3255
+ }
3256
+ } catch {
3257
+ }
3231
3258
  if (transport.isPaneInCopyMode(targetSession)) {
3232
3259
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
3233
3260
  transport.sendKeys(targetSession, "q");
@@ -6624,7 +6624,7 @@ __export(tmux_routing_exports, {
6624
6624
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
6625
6625
  });
6626
6626
  import { execFileSync as execFileSync2, execSync as execSync7 } from "child_process";
6627
- import { readFileSync as readFileSync12, writeFileSync as writeFileSync9, mkdirSync as mkdirSync7, existsSync as existsSync14, appendFileSync } from "fs";
6627
+ import { readFileSync as readFileSync12, writeFileSync as writeFileSync9, mkdirSync as mkdirSync7, existsSync as existsSync14, appendFileSync, readdirSync as readdirSync5 } from "fs";
6628
6628
  import path18 from "path";
6629
6629
  import os8 from "os";
6630
6630
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -6772,15 +6772,24 @@ function getDispatchedBy(sessionKey) {
6772
6772
  function resolveExeSession() {
6773
6773
  const mySession = getMySession();
6774
6774
  if (!mySession) return null;
6775
+ const fromSessionName = extractRootExe(mySession);
6775
6776
  try {
6776
6777
  const key = getSessionKey();
6777
6778
  const parentExe = getParentExe(key);
6778
6779
  if (parentExe) {
6779
- return extractRootExe(parentExe) ?? parentExe;
6780
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
6781
+ if (fromSessionName && fromCache !== fromSessionName) {
6782
+ process.stderr.write(
6783
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
6784
+ `
6785
+ );
6786
+ return fromSessionName;
6787
+ }
6788
+ return fromCache;
6780
6789
  }
6781
6790
  } catch {
6782
6791
  }
6783
- return extractRootExe(mySession) ?? mySession;
6792
+ return fromSessionName ?? mySession;
6784
6793
  }
6785
6794
  function isEmployeeAlive(sessionName) {
6786
6795
  return getTransport().isAlive(sessionName);
@@ -6945,6 +6954,24 @@ function sendIntercom(targetSession) {
6945
6954
  }
6946
6955
  } catch {
6947
6956
  }
6957
+ try {
6958
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
6959
+ const agent = baseAgentName(rawAgent);
6960
+ const taskDir = path18.join(process.cwd(), "exe", agent);
6961
+ if (existsSync14(taskDir)) {
6962
+ const files = readdirSync5(taskDir).filter(
6963
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
6964
+ );
6965
+ if (files.length === 0) {
6966
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
6967
+ return "debounced";
6968
+ }
6969
+ } else {
6970
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
6971
+ return "debounced";
6972
+ }
6973
+ } catch {
6974
+ }
6948
6975
  if (transport.isPaneInCopyMode(targetSession)) {
6949
6976
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
6950
6977
  transport.sendKeys(targetSession, "q");
@@ -7982,7 +8009,7 @@ var init_tasks_crud = __esm({
7982
8009
 
7983
8010
  // src/lib/tasks-review.ts
7984
8011
  import path20 from "path";
7985
- import { existsSync as existsSync16, readdirSync as readdirSync5, unlinkSync as unlinkSync6 } from "fs";
8012
+ import { existsSync as existsSync16, readdirSync as readdirSync6, unlinkSync as unlinkSync6 } from "fs";
7986
8013
  async function countPendingReviews(sessionScope) {
7987
8014
  const client = getClient();
7988
8015
  if (sessionScope) {
@@ -8165,7 +8192,7 @@ async function cleanupReviewFile(row, taskFile, _baseDir) {
8165
8192
  try {
8166
8193
  const cacheDir = path20.join(EXE_AI_DIR, "session-cache");
8167
8194
  if (existsSync16(cacheDir)) {
8168
- for (const f of readdirSync5(cacheDir)) {
8195
+ for (const f of readdirSync6(cacheDir)) {
8169
8196
  if (f.startsWith("review-notified-")) {
8170
8197
  unlinkSync6(path20.join(cacheDir, f));
8171
8198
  }
@@ -8950,7 +8977,7 @@ __export(identity_exports, {
8950
8977
  updateIdentity: () => updateIdentity
8951
8978
  });
8952
8979
  import { existsSync as existsSync17, mkdirSync as mkdirSync9, readFileSync as readFileSync14, writeFileSync as writeFileSync11 } from "fs";
8953
- import { readdirSync as readdirSync6 } from "fs";
8980
+ import { readdirSync as readdirSync7 } from "fs";
8954
8981
  import path23 from "path";
8955
8982
  import { createHash as createHash2 } from "crypto";
8956
8983
  function ensureDir2() {
@@ -9032,7 +9059,7 @@ async function updateIdentity(agentId, content, updatedBy) {
9032
9059
  }
9033
9060
  function listIdentities() {
9034
9061
  ensureDir2();
9035
- const files = readdirSync6(IDENTITY_DIR).filter((f) => f.endsWith(".md"));
9062
+ const files = readdirSync7(IDENTITY_DIR).filter((f) => f.endsWith(".md"));
9036
9063
  const results = [];
9037
9064
  for (const file of files) {
9038
9065
  const agentId = file.replace(".md", "");
@@ -10327,7 +10354,7 @@ __export(worker_gate_exports, {
10327
10354
  tryAcquireBackfillLock: () => tryAcquireBackfillLock,
10328
10355
  tryAcquireWorkerSlot: () => tryAcquireWorkerSlot
10329
10356
  });
10330
- import { readdirSync as readdirSync9, writeFileSync as writeFileSync17, unlinkSync as unlinkSync8, mkdirSync as mkdirSync14, existsSync as existsSync25 } from "fs";
10357
+ import { readdirSync as readdirSync10, writeFileSync as writeFileSync17, unlinkSync as unlinkSync8, mkdirSync as mkdirSync14, existsSync as existsSync25 } from "fs";
10331
10358
  import path33 from "path";
10332
10359
  function tryAcquireWorkerSlot() {
10333
10360
  try {
@@ -10335,7 +10362,7 @@ function tryAcquireWorkerSlot() {
10335
10362
  const reservationId = `res-${process.pid}-${Date.now()}`;
10336
10363
  const reservationPath = path33.join(WORKER_PID_DIR, `${reservationId}.pid`);
10337
10364
  writeFileSync17(reservationPath, String(process.pid));
10338
- const files = readdirSync9(WORKER_PID_DIR);
10365
+ const files = readdirSync10(WORKER_PID_DIR);
10339
10366
  let alive = 0;
10340
10367
  for (const f of files) {
10341
10368
  if (!f.endsWith(".pid")) continue;
@@ -13496,14 +13523,14 @@ function registerListTriggers(server2) {
13496
13523
  import { z as z31 } from "zod";
13497
13524
 
13498
13525
  // src/automation/starter-packs/index.ts
13499
- import { readFileSync as readFileSync17, readdirSync as readdirSync7, existsSync as existsSync19 } from "fs";
13526
+ import { readFileSync as readFileSync17, readdirSync as readdirSync8, existsSync as existsSync19 } from "fs";
13500
13527
  import path25 from "path";
13501
13528
  import { fileURLToPath as fileURLToPath3 } from "url";
13502
13529
  var __dirname = path25.dirname(fileURLToPath3(import.meta.url));
13503
13530
  function listPacks() {
13504
13531
  const packsDir = path25.join(__dirname, ".");
13505
13532
  if (!existsSync19(packsDir)) return [];
13506
- return readdirSync7(packsDir, { withFileTypes: true }).filter(
13533
+ return readdirSync8(packsDir, { withFileTypes: true }).filter(
13507
13534
  (d) => d.isDirectory() && existsSync19(path25.join(packsDir, d.name, "custom-objects.json"))
13508
13535
  ).map((d) => d.name);
13509
13536
  }
@@ -13535,7 +13562,7 @@ function loadPack(industry) {
13535
13562
  }
13536
13563
  const wikiSeeds = [];
13537
13564
  if (existsSync19(wikiDir)) {
13538
- const files = readdirSync7(wikiDir).filter((f) => f.endsWith(".md"));
13565
+ const files = readdirSync8(wikiDir).filter((f) => f.endsWith(".md"));
13539
13566
  for (const file of files) {
13540
13567
  const content = readFileSync17(path25.join(wikiDir, file), "utf-8");
13541
13568
  const titleMatch = content.match(/^#\s+(.+)/m);
@@ -15655,13 +15682,13 @@ function registerQueryConversations(server2) {
15655
15682
 
15656
15683
  // src/mcp/tools/load-skill.ts
15657
15684
  import { z as z41 } from "zod";
15658
- import { readFileSync as readFileSync20, readdirSync as readdirSync8, statSync as statSync3 } from "fs";
15685
+ import { readFileSync as readFileSync20, readdirSync as readdirSync9, statSync as statSync3 } from "fs";
15659
15686
  import path30 from "path";
15660
15687
  import { homedir as homedir2 } from "os";
15661
15688
  var SKILLS_DIR = path30.join(homedir2(), ".claude", "skills");
15662
15689
  function listAvailableSkills() {
15663
15690
  try {
15664
- const entries = readdirSync8(SKILLS_DIR);
15691
+ const entries = readdirSync9(SKILLS_DIR);
15665
15692
  return entries.filter((entry) => {
15666
15693
  try {
15667
15694
  const entryPath = path30.join(SKILLS_DIR, entry);
@@ -17407,7 +17434,7 @@ function registerGetAutoWakeStatus(server2) {
17407
17434
  init_worker_gate();
17408
17435
  init_config();
17409
17436
  import { z as z58 } from "zod";
17410
- import { readdirSync as readdirSync10, existsSync as existsSync26 } from "fs";
17437
+ import { readdirSync as readdirSync11, existsSync as existsSync26 } from "fs";
17411
17438
  import path34 from "path";
17412
17439
  var WORKER_PID_DIR2 = path34.join(EXE_AI_DIR, "worker-pids");
17413
17440
  function countAliveWorkers() {
@@ -17416,7 +17443,7 @@ function countAliveWorkers() {
17416
17443
  let reservations = 0;
17417
17444
  try {
17418
17445
  if (!existsSync26(WORKER_PID_DIR2)) return { alive: 0, stale: 0, reservations: 0 };
17419
- const files = readdirSync10(WORKER_PID_DIR2);
17446
+ const files = readdirSync11(WORKER_PID_DIR2);
17420
17447
  for (const f of files) {
17421
17448
  if (!f.endsWith(".pid")) continue;
17422
17449
  if (f.startsWith("res-")) {
@@ -18322,7 +18349,7 @@ import { z as z60 } from "zod";
18322
18349
 
18323
18350
  // src/lib/cloud-sync.ts
18324
18351
  init_database();
18325
- import { readFileSync as readFileSync25, writeFileSync as writeFileSync19, existsSync as existsSync29, readdirSync as readdirSync11, mkdirSync as mkdirSync16, appendFileSync as appendFileSync2, unlinkSync as unlinkSync10, openSync as openSync2, closeSync as closeSync2 } from "fs";
18352
+ import { readFileSync as readFileSync25, writeFileSync as writeFileSync19, existsSync as existsSync29, readdirSync as readdirSync12, mkdirSync as mkdirSync16, appendFileSync as appendFileSync2, unlinkSync as unlinkSync10, openSync as openSync2, closeSync as closeSync2 } from "fs";
18326
18353
  import crypto16 from "crypto";
18327
18354
  import path37 from "path";
18328
18355
  import { homedir as homedir6 } from "os";
@@ -18800,7 +18827,7 @@ async function cloudSync(config2) {
18800
18827
  rosterResult.employees = employees.length;
18801
18828
  const idDir = path37.join(EXE_AI_DIR, "identity");
18802
18829
  if (existsSync29(idDir)) {
18803
- rosterResult.identities = readdirSync11(idDir).filter((f) => f.endsWith(".md")).length;
18830
+ rosterResult.identities = readdirSync12(idDir).filter((f) => f.endsWith(".md")).length;
18804
18831
  }
18805
18832
  } catch {
18806
18833
  }
@@ -18841,7 +18868,7 @@ function buildRosterBlob(paths) {
18841
18868
  }
18842
18869
  const identities = {};
18843
18870
  if (existsSync29(identityDir)) {
18844
- for (const file of readdirSync11(identityDir).filter((f) => f.endsWith(".md"))) {
18871
+ for (const file of readdirSync12(identityDir).filter((f) => f.endsWith(".md"))) {
18845
18872
  try {
18846
18873
  identities[file] = readFileSync25(path37.join(identityDir, file), "utf-8");
18847
18874
  } catch {
@@ -1525,7 +1525,7 @@ __export(tmux_routing_exports, {
1525
1525
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
1526
1526
  });
1527
1527
  import { execFileSync as execFileSync2, execSync as execSync4 } from "child_process";
1528
- import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, existsSync as existsSync9, appendFileSync } from "fs";
1528
+ import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, existsSync as existsSync9, appendFileSync, readdirSync as readdirSync2 } from "fs";
1529
1529
  import path9 from "path";
1530
1530
  import os6 from "os";
1531
1531
  import { fileURLToPath } from "url";
@@ -1673,15 +1673,24 @@ function getDispatchedBy(sessionKey) {
1673
1673
  function resolveExeSession() {
1674
1674
  const mySession = getMySession();
1675
1675
  if (!mySession) return null;
1676
+ const fromSessionName = extractRootExe(mySession);
1676
1677
  try {
1677
1678
  const key = getSessionKey();
1678
1679
  const parentExe = getParentExe(key);
1679
1680
  if (parentExe) {
1680
- return extractRootExe(parentExe) ?? parentExe;
1681
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
1682
+ if (fromSessionName && fromCache !== fromSessionName) {
1683
+ process.stderr.write(
1684
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
1685
+ `
1686
+ );
1687
+ return fromSessionName;
1688
+ }
1689
+ return fromCache;
1681
1690
  }
1682
1691
  } catch {
1683
1692
  }
1684
- return extractRootExe(mySession) ?? mySession;
1693
+ return fromSessionName ?? mySession;
1685
1694
  }
1686
1695
  function isEmployeeAlive(sessionName) {
1687
1696
  return getTransport().isAlive(sessionName);
@@ -1846,6 +1855,24 @@ function sendIntercom(targetSession) {
1846
1855
  }
1847
1856
  } catch {
1848
1857
  }
1858
+ try {
1859
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
1860
+ const agent = baseAgentName(rawAgent);
1861
+ const taskDir = path9.join(process.cwd(), "exe", agent);
1862
+ if (existsSync9(taskDir)) {
1863
+ const files = readdirSync2(taskDir).filter(
1864
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
1865
+ );
1866
+ if (files.length === 0) {
1867
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
1868
+ return "debounced";
1869
+ }
1870
+ } else {
1871
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
1872
+ return "debounced";
1873
+ }
1874
+ } catch {
1875
+ }
1849
1876
  if (transport.isPaneInCopyMode(targetSession)) {
1850
1877
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
1851
1878
  transport.sendKeys(targetSession, "q");
@@ -2867,7 +2894,7 @@ var init_tasks_crud = __esm({
2867
2894
 
2868
2895
  // src/lib/tasks-review.ts
2869
2896
  import path11 from "path";
2870
- import { existsSync as existsSync11, readdirSync as readdirSync2, unlinkSync as unlinkSync4 } from "fs";
2897
+ import { existsSync as existsSync11, readdirSync as readdirSync3, unlinkSync as unlinkSync4 } from "fs";
2871
2898
  async function countPendingReviews(sessionScope) {
2872
2899
  const client = getClient();
2873
2900
  if (sessionScope) {
@@ -3050,7 +3077,7 @@ async function cleanupReviewFile(row, taskFile, _baseDir) {
3050
3077
  try {
3051
3078
  const cacheDir = path11.join(EXE_AI_DIR, "session-cache");
3052
3079
  if (existsSync11(cacheDir)) {
3053
- for (const f of readdirSync2(cacheDir)) {
3080
+ for (const f of readdirSync3(cacheDir)) {
3054
3081
  if (f.startsWith("review-notified-")) {
3055
3082
  unlinkSync4(path11.join(cacheDir, f));
3056
3083
  }
@@ -3849,7 +3876,7 @@ __export(identity_exports, {
3849
3876
  updateIdentity: () => updateIdentity
3850
3877
  });
3851
3878
  import { existsSync as existsSync12, mkdirSync as mkdirSync8, readFileSync as readFileSync12, writeFileSync as writeFileSync9 } from "fs";
3852
- import { readdirSync as readdirSync4 } from "fs";
3879
+ import { readdirSync as readdirSync5 } from "fs";
3853
3880
  import path16 from "path";
3854
3881
  import { createHash } from "crypto";
3855
3882
  function ensureDir2() {
@@ -3931,7 +3958,7 @@ async function updateIdentity(agentId, content, updatedBy) {
3931
3958
  }
3932
3959
  function listIdentities() {
3933
3960
  ensureDir2();
3934
- const files = readdirSync4(IDENTITY_DIR).filter((f) => f.endsWith(".md"));
3961
+ const files = readdirSync5(IDENTITY_DIR).filter((f) => f.endsWith(".md"));
3935
3962
  const results = [];
3936
3963
  for (const file of files) {
3937
3964
  const agentId = file.replace(".md", "");
@@ -4523,7 +4550,7 @@ import { z } from "zod";
4523
4550
  init_config();
4524
4551
  init_session_key();
4525
4552
  init_employees();
4526
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync8, mkdirSync as mkdirSync7, unlinkSync as unlinkSync6, readdirSync as readdirSync3 } from "fs";
4553
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync8, mkdirSync as mkdirSync7, unlinkSync as unlinkSync6, readdirSync as readdirSync4 } from "fs";
4527
4554
  import { execSync as execSync7 } from "child_process";
4528
4555
  import path15 from "path";
4529
4556
  var CACHE_DIR = path15.join(EXE_AI_DIR, "session-cache");
@@ -535,7 +535,7 @@ var init_plan_limits = __esm({
535
535
  });
536
536
 
537
537
  // src/lib/tmux-routing.ts
538
- import { readFileSync as readFileSync8, writeFileSync as writeFileSync5, mkdirSync as mkdirSync4, existsSync as existsSync8, appendFileSync } from "fs";
538
+ import { readFileSync as readFileSync8, writeFileSync as writeFileSync5, mkdirSync as mkdirSync4, existsSync as existsSync8, appendFileSync, readdirSync as readdirSync2 } from "fs";
539
539
  import path9 from "path";
540
540
  import os6 from "os";
541
541
  import { fileURLToPath } from "url";
@@ -559,15 +559,24 @@ function getParentExe(sessionKey) {
559
559
  function resolveExeSession() {
560
560
  const mySession = getMySession();
561
561
  if (!mySession) return null;
562
+ const fromSessionName = extractRootExe(mySession);
562
563
  try {
563
564
  const key = getSessionKey();
564
565
  const parentExe = getParentExe(key);
565
566
  if (parentExe) {
566
- return extractRootExe(parentExe) ?? parentExe;
567
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
568
+ if (fromSessionName && fromCache !== fromSessionName) {
569
+ process.stderr.write(
570
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
571
+ `
572
+ );
573
+ return fromSessionName;
574
+ }
575
+ return fromCache;
567
576
  }
568
577
  } catch {
569
578
  }
570
- return extractRootExe(mySession) ?? mySession;
579
+ return fromSessionName ?? mySession;
571
580
  }
572
581
  var SPAWN_LOCK_DIR, SESSION_CACHE, INTERCOM_LOG2, DEBOUNCE_FILE, DEBOUNCE_CLEANUP_AGE_MS;
573
582
  var init_tmux_routing = __esm({
@@ -705,7 +714,7 @@ var init_tasks_crud = __esm({
705
714
 
706
715
  // src/lib/tasks-review.ts
707
716
  import path11 from "path";
708
- import { existsSync as existsSync10, readdirSync as readdirSync2, unlinkSync as unlinkSync3 } from "fs";
717
+ import { existsSync as existsSync10, readdirSync as readdirSync3, unlinkSync as unlinkSync3 } from "fs";
709
718
  var init_tasks_review = __esm({
710
719
  "src/lib/tasks-review.ts"() {
711
720
  "use strict";
@@ -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");
@@ -933,7 +960,7 @@ async function markFailed(messageId, reason) {
933
960
  init_config();
934
961
  init_session_key();
935
962
  init_employees();
936
- import { readFileSync as readFileSync8, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, unlinkSync as unlinkSync2, readdirSync } from "fs";
963
+ import { readFileSync as readFileSync8, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, unlinkSync as unlinkSync2, readdirSync as readdirSync2 } from "fs";
937
964
  import { execSync as execSync5 } from "child_process";
938
965
  import path9 from "path";
939
966
  var CACHE_DIR = path9.join(EXE_AI_DIR, "session-cache");
@@ -837,7 +837,7 @@ var init_plan_limits = __esm({
837
837
 
838
838
  // src/lib/tmux-routing.ts
839
839
  import { execFileSync as execFileSync2, execSync as execSync4 } from "child_process";
840
- import { readFileSync as readFileSync8, writeFileSync as writeFileSync5, mkdirSync as mkdirSync4, existsSync as existsSync8, appendFileSync } from "fs";
840
+ import { readFileSync as readFileSync8, writeFileSync as writeFileSync5, mkdirSync as mkdirSync4, existsSync as existsSync8, appendFileSync, readdirSync as readdirSync2 } from "fs";
841
841
  import path9 from "path";
842
842
  import os6 from "os";
843
843
  import { fileURLToPath } from "url";
@@ -872,15 +872,24 @@ function getDispatchedBy(sessionKey) {
872
872
  function resolveExeSession() {
873
873
  const mySession = getMySession();
874
874
  if (!mySession) return null;
875
+ const fromSessionName = extractRootExe(mySession);
875
876
  try {
876
877
  const key = getSessionKey();
877
878
  const parentExe = getParentExe(key);
878
879
  if (parentExe) {
879
- return extractRootExe(parentExe) ?? parentExe;
880
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
881
+ if (fromSessionName && fromCache !== fromSessionName) {
882
+ process.stderr.write(
883
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
884
+ `
885
+ );
886
+ return fromSessionName;
887
+ }
888
+ return fromCache;
880
889
  }
881
890
  } catch {
882
891
  }
883
- return extractRootExe(mySession) ?? mySession;
892
+ return fromSessionName ?? mySession;
884
893
  }
885
894
  function readDebounceState() {
886
895
  try {
@@ -1003,6 +1012,24 @@ function sendIntercom(targetSession) {
1003
1012
  }
1004
1013
  } catch {
1005
1014
  }
1015
+ try {
1016
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
1017
+ const agent = baseAgentName(rawAgent);
1018
+ const taskDir = path9.join(process.cwd(), "exe", agent);
1019
+ if (existsSync8(taskDir)) {
1020
+ const files = readdirSync2(taskDir).filter(
1021
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
1022
+ );
1023
+ if (files.length === 0) {
1024
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
1025
+ return "debounced";
1026
+ }
1027
+ } else {
1028
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
1029
+ return "debounced";
1030
+ }
1031
+ } catch {
1032
+ }
1006
1033
  if (transport.isPaneInCopyMode(targetSession)) {
1007
1034
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
1008
1035
  transport.sendKeys(targetSession, "q");
@@ -1402,7 +1429,7 @@ var init_tasks_crud = __esm({
1402
1429
 
1403
1430
  // src/lib/tasks-review.ts
1404
1431
  import path11 from "path";
1405
- import { existsSync as existsSync10, readdirSync as readdirSync2, unlinkSync as unlinkSync3 } from "fs";
1432
+ import { existsSync as existsSync10, readdirSync as readdirSync3, unlinkSync as unlinkSync3 } from "fs";
1406
1433
  async function cleanupReviewFile(row, taskFile, _baseDir) {
1407
1434
  if (String(row.assigned_by) !== "system" || !taskFile.includes("review-")) return;
1408
1435
  try {
@@ -1449,7 +1476,7 @@ async function cleanupReviewFile(row, taskFile, _baseDir) {
1449
1476
  try {
1450
1477
  const cacheDir = path11.join(EXE_AI_DIR, "session-cache");
1451
1478
  if (existsSync10(cacheDir)) {
1452
- for (const f of readdirSync2(cacheDir)) {
1479
+ for (const f of readdirSync3(cacheDir)) {
1453
1480
  if (f.startsWith("review-notified-")) {
1454
1481
  unlinkSync3(path11.join(cacheDir, f));
1455
1482
  }
@@ -2054,7 +2081,7 @@ __export(active_agent_exports, {
2054
2081
  resolveActiveAgentFromTmuxSession: () => resolveActiveAgentFromTmuxSession,
2055
2082
  writeActiveAgent: () => writeActiveAgent
2056
2083
  });
2057
- import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, unlinkSync as unlinkSync5, readdirSync as readdirSync3 } from "fs";
2084
+ import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, unlinkSync as unlinkSync5, readdirSync as readdirSync4 } from "fs";
2058
2085
  import { execSync as execSync6 } from "child_process";
2059
2086
  import path14 from "path";
2060
2087
  function isNameWithOptionalInstance(candidate, baseName) {
@@ -2162,7 +2189,7 @@ function getActiveAgent() {
2162
2189
  }
2163
2190
  function getAllActiveAgents() {
2164
2191
  try {
2165
- const files = readdirSync3(CACHE_DIR);
2192
+ const files = readdirSync4(CACHE_DIR);
2166
2193
  const sessions = [];
2167
2194
  for (const file of files) {
2168
2195
  if (!file.startsWith("active-agent-") || !file.endsWith(".json")) continue;
@@ -4513,7 +4513,7 @@ __export(tmux_routing_exports, {
4513
4513
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
4514
4514
  });
4515
4515
  import { execFileSync as execFileSync2, execSync as execSync7 } from "child_process";
4516
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync12, appendFileSync } from "fs";
4516
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync12, appendFileSync, readdirSync as readdirSync3 } from "fs";
4517
4517
  import path16 from "path";
4518
4518
  import os9 from "os";
4519
4519
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -4661,15 +4661,24 @@ function getDispatchedBy(sessionKey) {
4661
4661
  function resolveExeSession() {
4662
4662
  const mySession = getMySession();
4663
4663
  if (!mySession) return null;
4664
+ const fromSessionName = extractRootExe(mySession);
4664
4665
  try {
4665
4666
  const key = getSessionKey();
4666
4667
  const parentExe = getParentExe(key);
4667
4668
  if (parentExe) {
4668
- return extractRootExe(parentExe) ?? parentExe;
4669
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
4670
+ if (fromSessionName && fromCache !== fromSessionName) {
4671
+ process.stderr.write(
4672
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
4673
+ `
4674
+ );
4675
+ return fromSessionName;
4676
+ }
4677
+ return fromCache;
4669
4678
  }
4670
4679
  } catch {
4671
4680
  }
4672
- return extractRootExe(mySession) ?? mySession;
4681
+ return fromSessionName ?? mySession;
4673
4682
  }
4674
4683
  function isEmployeeAlive(sessionName) {
4675
4684
  return getTransport().isAlive(sessionName);
@@ -4834,6 +4843,24 @@ function sendIntercom(targetSession) {
4834
4843
  }
4835
4844
  } catch {
4836
4845
  }
4846
+ try {
4847
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
4848
+ const agent = baseAgentName(rawAgent);
4849
+ const taskDir = path16.join(process.cwd(), "exe", agent);
4850
+ if (existsSync12(taskDir)) {
4851
+ const files = readdirSync3(taskDir).filter(
4852
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
4853
+ );
4854
+ if (files.length === 0) {
4855
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
4856
+ return "debounced";
4857
+ }
4858
+ } else {
4859
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
4860
+ return "debounced";
4861
+ }
4862
+ } catch {
4863
+ }
4837
4864
  if (transport.isPaneInCopyMode(targetSession)) {
4838
4865
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
4839
4866
  transport.sendKeys(targetSession, "q");
@@ -5320,7 +5347,7 @@ __export(shard_manager_exports, {
5320
5347
  shardExists: () => shardExists
5321
5348
  });
5322
5349
  import path18 from "path";
5323
- import { existsSync as existsSync14, mkdirSync as mkdirSync7, readdirSync as readdirSync3 } from "fs";
5350
+ import { existsSync as existsSync14, mkdirSync as mkdirSync7, readdirSync as readdirSync4 } from "fs";
5324
5351
  import { createClient as createClient2 } from "@libsql/client";
5325
5352
  function initShardManager(encryptionKey) {
5326
5353
  _encryptionKey = encryptionKey;
@@ -5359,7 +5386,7 @@ function shardExists(projectName) {
5359
5386
  }
5360
5387
  function listShards() {
5361
5388
  if (!existsSync14(SHARDS_DIR)) return [];
5362
- return readdirSync3(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
5389
+ return readdirSync4(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
5363
5390
  }
5364
5391
  async function ensureShardSchema(client) {
5365
5392
  await client.execute("PRAGMA journal_mode = WAL");