@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.
@@ -4403,7 +4403,7 @@ __export(tmux_routing_exports, {
4403
4403
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
4404
4404
  });
4405
4405
  import { execFileSync as execFileSync2, execSync as execSync6 } from "child_process";
4406
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync12, appendFileSync } from "fs";
4406
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync12, appendFileSync, readdirSync as readdirSync3 } from "fs";
4407
4407
  import path15 from "path";
4408
4408
  import os8 from "os";
4409
4409
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -4551,15 +4551,24 @@ function getDispatchedBy(sessionKey) {
4551
4551
  function resolveExeSession() {
4552
4552
  const mySession = getMySession();
4553
4553
  if (!mySession) return null;
4554
+ const fromSessionName = extractRootExe(mySession);
4554
4555
  try {
4555
4556
  const key = getSessionKey();
4556
4557
  const parentExe = getParentExe(key);
4557
4558
  if (parentExe) {
4558
- return extractRootExe(parentExe) ?? parentExe;
4559
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
4560
+ if (fromSessionName && fromCache !== fromSessionName) {
4561
+ process.stderr.write(
4562
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
4563
+ `
4564
+ );
4565
+ return fromSessionName;
4566
+ }
4567
+ return fromCache;
4559
4568
  }
4560
4569
  } catch {
4561
4570
  }
4562
- return extractRootExe(mySession) ?? mySession;
4571
+ return fromSessionName ?? mySession;
4563
4572
  }
4564
4573
  function isEmployeeAlive(sessionName) {
4565
4574
  return getTransport().isAlive(sessionName);
@@ -4724,6 +4733,24 @@ function sendIntercom(targetSession) {
4724
4733
  }
4725
4734
  } catch {
4726
4735
  }
4736
+ try {
4737
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
4738
+ const agent = baseAgentName(rawAgent);
4739
+ const taskDir = path15.join(process.cwd(), "exe", agent);
4740
+ if (existsSync12(taskDir)) {
4741
+ const files = readdirSync3(taskDir).filter(
4742
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
4743
+ );
4744
+ if (files.length === 0) {
4745
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
4746
+ return "debounced";
4747
+ }
4748
+ } else {
4749
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
4750
+ return "debounced";
4751
+ }
4752
+ } catch {
4753
+ }
4727
4754
  if (transport.isPaneInCopyMode(targetSession)) {
4728
4755
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
4729
4756
  transport.sendKeys(targetSession, "q");
@@ -5234,7 +5261,7 @@ __export(shard_manager_exports, {
5234
5261
  shardExists: () => shardExists
5235
5262
  });
5236
5263
  import path17 from "path";
5237
- import { existsSync as existsSync14, mkdirSync as mkdirSync7, readdirSync as readdirSync3 } from "fs";
5264
+ import { existsSync as existsSync14, mkdirSync as mkdirSync7, readdirSync as readdirSync4 } from "fs";
5238
5265
  import { createClient as createClient2 } from "@libsql/client";
5239
5266
  function initShardManager(encryptionKey) {
5240
5267
  _encryptionKey = encryptionKey;
@@ -5273,7 +5300,7 @@ function shardExists(projectName2) {
5273
5300
  }
5274
5301
  function listShards() {
5275
5302
  if (!existsSync14(SHARDS_DIR)) return [];
5276
- return readdirSync3(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
5303
+ return readdirSync4(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
5277
5304
  }
5278
5305
  async function ensureShardSchema(client) {
5279
5306
  await client.execute("PRAGMA journal_mode = WAL");
@@ -4408,7 +4408,7 @@ __export(tmux_routing_exports, {
4408
4408
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
4409
4409
  });
4410
4410
  import { execFileSync as execFileSync2, execSync as execSync6 } from "child_process";
4411
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync12, appendFileSync } from "fs";
4411
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync12, appendFileSync, readdirSync as readdirSync3 } from "fs";
4412
4412
  import path15 from "path";
4413
4413
  import os8 from "os";
4414
4414
  import { fileURLToPath as fileURLToPath3 } from "url";
@@ -4556,15 +4556,24 @@ function getDispatchedBy(sessionKey) {
4556
4556
  function resolveExeSession() {
4557
4557
  const mySession = getMySession();
4558
4558
  if (!mySession) return null;
4559
+ const fromSessionName = extractRootExe(mySession);
4559
4560
  try {
4560
4561
  const key = getSessionKey();
4561
4562
  const parentExe = getParentExe(key);
4562
4563
  if (parentExe) {
4563
- return extractRootExe(parentExe) ?? parentExe;
4564
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
4565
+ if (fromSessionName && fromCache !== fromSessionName) {
4566
+ process.stderr.write(
4567
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
4568
+ `
4569
+ );
4570
+ return fromSessionName;
4571
+ }
4572
+ return fromCache;
4564
4573
  }
4565
4574
  } catch {
4566
4575
  }
4567
- return extractRootExe(mySession) ?? mySession;
4576
+ return fromSessionName ?? mySession;
4568
4577
  }
4569
4578
  function isEmployeeAlive(sessionName) {
4570
4579
  return getTransport().isAlive(sessionName);
@@ -4729,6 +4738,24 @@ function sendIntercom(targetSession) {
4729
4738
  }
4730
4739
  } catch {
4731
4740
  }
4741
+ try {
4742
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
4743
+ const agent = baseAgentName(rawAgent);
4744
+ const taskDir = path15.join(process.cwd(), "exe", agent);
4745
+ if (existsSync12(taskDir)) {
4746
+ const files = readdirSync3(taskDir).filter(
4747
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
4748
+ );
4749
+ if (files.length === 0) {
4750
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
4751
+ return "debounced";
4752
+ }
4753
+ } else {
4754
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
4755
+ return "debounced";
4756
+ }
4757
+ } catch {
4758
+ }
4732
4759
  if (transport.isPaneInCopyMode(targetSession)) {
4733
4760
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
4734
4761
  transport.sendKeys(targetSession, "q");
@@ -5239,7 +5266,7 @@ __export(shard_manager_exports, {
5239
5266
  shardExists: () => shardExists
5240
5267
  });
5241
5268
  import path17 from "path";
5242
- import { existsSync as existsSync14, mkdirSync as mkdirSync7, readdirSync as readdirSync3 } from "fs";
5269
+ import { existsSync as existsSync14, mkdirSync as mkdirSync7, readdirSync as readdirSync4 } from "fs";
5243
5270
  import { createClient as createClient2 } from "@libsql/client";
5244
5271
  function initShardManager(encryptionKey) {
5245
5272
  _encryptionKey = encryptionKey;
@@ -5278,7 +5305,7 @@ function shardExists(projectName) {
5278
5305
  }
5279
5306
  function listShards() {
5280
5307
  if (!existsSync14(SHARDS_DIR)) return [];
5281
- return readdirSync3(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
5308
+ return readdirSync4(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
5282
5309
  }
5283
5310
  async function ensureShardSchema(client) {
5284
5311
  await client.execute("PRAGMA journal_mode = WAL");
@@ -6982,7 +6982,7 @@ __export(tmux_routing_exports, {
6982
6982
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
6983
6983
  });
6984
6984
  import { execFileSync as execFileSync2, execSync as execSync6 } from "child_process";
6985
- import { readFileSync as readFileSync12, writeFileSync as writeFileSync7, mkdirSync as mkdirSync8, existsSync as existsSync14, appendFileSync } from "fs";
6985
+ import { readFileSync as readFileSync12, writeFileSync as writeFileSync7, mkdirSync as mkdirSync8, existsSync as existsSync14, appendFileSync, readdirSync as readdirSync4 } from "fs";
6986
6986
  import path18 from "path";
6987
6987
  import os10 from "os";
6988
6988
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -7130,15 +7130,24 @@ function getDispatchedBy(sessionKey) {
7130
7130
  function resolveExeSession() {
7131
7131
  const mySession = getMySession();
7132
7132
  if (!mySession) return null;
7133
+ const fromSessionName = extractRootExe(mySession);
7133
7134
  try {
7134
7135
  const key = getSessionKey();
7135
7136
  const parentExe = getParentExe(key);
7136
7137
  if (parentExe) {
7137
- return extractRootExe(parentExe) ?? parentExe;
7138
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
7139
+ if (fromSessionName && fromCache !== fromSessionName) {
7140
+ process.stderr.write(
7141
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
7142
+ `
7143
+ );
7144
+ return fromSessionName;
7145
+ }
7146
+ return fromCache;
7138
7147
  }
7139
7148
  } catch {
7140
7149
  }
7141
- return extractRootExe(mySession) ?? mySession;
7150
+ return fromSessionName ?? mySession;
7142
7151
  }
7143
7152
  function isEmployeeAlive(sessionName) {
7144
7153
  return getTransport().isAlive(sessionName);
@@ -7303,6 +7312,24 @@ function sendIntercom(targetSession) {
7303
7312
  }
7304
7313
  } catch {
7305
7314
  }
7315
+ try {
7316
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
7317
+ const agent = baseAgentName(rawAgent);
7318
+ const taskDir = path18.join(process.cwd(), "exe", agent);
7319
+ if (existsSync14(taskDir)) {
7320
+ const files = readdirSync4(taskDir).filter(
7321
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
7322
+ );
7323
+ if (files.length === 0) {
7324
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
7325
+ return "debounced";
7326
+ }
7327
+ } else {
7328
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
7329
+ return "debounced";
7330
+ }
7331
+ } catch {
7332
+ }
7306
7333
  if (transport.isPaneInCopyMode(targetSession)) {
7307
7334
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
7308
7335
  transport.sendKeys(targetSession, "q");
@@ -2907,7 +2907,7 @@ __export(tmux_routing_exports, {
2907
2907
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
2908
2908
  });
2909
2909
  import { execFileSync as execFileSync2, execSync as execSync4 } from "child_process";
2910
- import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6, existsSync as existsSync11, appendFileSync } from "fs";
2910
+ import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6, existsSync as existsSync11, appendFileSync, readdirSync as readdirSync3 } from "fs";
2911
2911
  import path11 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 = path11.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");
@@ -4249,7 +4276,7 @@ var init_tasks_crud = __esm({
4249
4276
 
4250
4277
  // src/lib/tasks-review.ts
4251
4278
  import path13 from "path";
4252
- import { existsSync as existsSync13, readdirSync as readdirSync3, unlinkSync as unlinkSync4 } from "fs";
4279
+ import { existsSync as existsSync13, readdirSync as readdirSync4, unlinkSync as unlinkSync4 } from "fs";
4253
4280
  async function countPendingReviews(sessionScope) {
4254
4281
  const client = getClient();
4255
4282
  if (sessionScope) {
@@ -4432,7 +4459,7 @@ async function cleanupReviewFile(row, taskFile, _baseDir) {
4432
4459
  try {
4433
4460
  const cacheDir = path13.join(EXE_AI_DIR, "session-cache");
4434
4461
  if (existsSync13(cacheDir)) {
4435
- for (const f of readdirSync3(cacheDir)) {
4462
+ for (const f of readdirSync4(cacheDir)) {
4436
4463
  if (f.startsWith("review-notified-")) {
4437
4464
  unlinkSync4(path13.join(cacheDir, f));
4438
4465
  }
@@ -4402,7 +4402,7 @@ __export(tmux_routing_exports, {
4402
4402
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
4403
4403
  });
4404
4404
  import { execFileSync as execFileSync2, execSync as execSync6 } from "child_process";
4405
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync12, appendFileSync } from "fs";
4405
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, existsSync as existsSync12, appendFileSync, readdirSync as readdirSync3 } from "fs";
4406
4406
  import path15 from "path";
4407
4407
  import os8 from "os";
4408
4408
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -4550,15 +4550,24 @@ function getDispatchedBy(sessionKey) {
4550
4550
  function resolveExeSession() {
4551
4551
  const mySession = getMySession();
4552
4552
  if (!mySession) return null;
4553
+ const fromSessionName = extractRootExe(mySession);
4553
4554
  try {
4554
4555
  const key = getSessionKey();
4555
4556
  const parentExe = getParentExe(key);
4556
4557
  if (parentExe) {
4557
- return extractRootExe(parentExe) ?? parentExe;
4558
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
4559
+ if (fromSessionName && fromCache !== fromSessionName) {
4560
+ process.stderr.write(
4561
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
4562
+ `
4563
+ );
4564
+ return fromSessionName;
4565
+ }
4566
+ return fromCache;
4558
4567
  }
4559
4568
  } catch {
4560
4569
  }
4561
- return extractRootExe(mySession) ?? mySession;
4570
+ return fromSessionName ?? mySession;
4562
4571
  }
4563
4572
  function isEmployeeAlive(sessionName) {
4564
4573
  return getTransport().isAlive(sessionName);
@@ -4723,6 +4732,24 @@ function sendIntercom(targetSession) {
4723
4732
  }
4724
4733
  } catch {
4725
4734
  }
4735
+ try {
4736
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
4737
+ const agent = baseAgentName(rawAgent);
4738
+ const taskDir = path15.join(process.cwd(), "exe", agent);
4739
+ if (existsSync12(taskDir)) {
4740
+ const files = readdirSync3(taskDir).filter(
4741
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
4742
+ );
4743
+ if (files.length === 0) {
4744
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
4745
+ return "debounced";
4746
+ }
4747
+ } else {
4748
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
4749
+ return "debounced";
4750
+ }
4751
+ } catch {
4752
+ }
4726
4753
  if (transport.isPaneInCopyMode(targetSession)) {
4727
4754
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
4728
4755
  transport.sendKeys(targetSession, "q");
@@ -5233,7 +5260,7 @@ __export(shard_manager_exports, {
5233
5260
  shardExists: () => shardExists
5234
5261
  });
5235
5262
  import path17 from "path";
5236
- import { existsSync as existsSync14, mkdirSync as mkdirSync7, readdirSync as readdirSync3 } from "fs";
5263
+ import { existsSync as existsSync14, mkdirSync as mkdirSync7, readdirSync as readdirSync4 } from "fs";
5237
5264
  import { createClient as createClient2 } from "@libsql/client";
5238
5265
  function initShardManager(encryptionKey) {
5239
5266
  _encryptionKey = encryptionKey;
@@ -5272,7 +5299,7 @@ function shardExists(projectName) {
5272
5299
  }
5273
5300
  function listShards() {
5274
5301
  if (!existsSync14(SHARDS_DIR)) return [];
5275
- return readdirSync3(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
5302
+ return readdirSync4(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
5276
5303
  }
5277
5304
  async function ensureShardSchema(client) {
5278
5305
  await client.execute("PRAGMA journal_mode = WAL");
@@ -3768,7 +3768,7 @@ __export(tmux_routing_exports, {
3768
3768
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
3769
3769
  });
3770
3770
  import { execFileSync as execFileSync2, execSync as execSync5 } from "child_process";
3771
- import { readFileSync as readFileSync10, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6, existsSync as existsSync12, appendFileSync } from "fs";
3771
+ import { readFileSync as readFileSync10, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6, existsSync as existsSync12, appendFileSync, readdirSync as readdirSync3 } from "fs";
3772
3772
  import path13 from "path";
3773
3773
  import os8 from "os";
3774
3774
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -3916,15 +3916,24 @@ function getDispatchedBy(sessionKey) {
3916
3916
  function resolveExeSession() {
3917
3917
  const mySession = getMySession();
3918
3918
  if (!mySession) return null;
3919
+ const fromSessionName = extractRootExe(mySession);
3919
3920
  try {
3920
3921
  const key = getSessionKey();
3921
3922
  const parentExe = getParentExe(key);
3922
3923
  if (parentExe) {
3923
- return extractRootExe(parentExe) ?? parentExe;
3924
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
3925
+ if (fromSessionName && fromCache !== fromSessionName) {
3926
+ process.stderr.write(
3927
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
3928
+ `
3929
+ );
3930
+ return fromSessionName;
3931
+ }
3932
+ return fromCache;
3924
3933
  }
3925
3934
  } catch {
3926
3935
  }
3927
- return extractRootExe(mySession) ?? mySession;
3936
+ return fromSessionName ?? mySession;
3928
3937
  }
3929
3938
  function isEmployeeAlive(sessionName) {
3930
3939
  return getTransport().isAlive(sessionName);
@@ -4089,6 +4098,24 @@ function sendIntercom(targetSession) {
4089
4098
  }
4090
4099
  } catch {
4091
4100
  }
4101
+ try {
4102
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
4103
+ const agent = baseAgentName(rawAgent);
4104
+ const taskDir = path13.join(process.cwd(), "exe", agent);
4105
+ if (existsSync12(taskDir)) {
4106
+ const files = readdirSync3(taskDir).filter(
4107
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
4108
+ );
4109
+ if (files.length === 0) {
4110
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
4111
+ return "debounced";
4112
+ }
4113
+ } else {
4114
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
4115
+ return "debounced";
4116
+ }
4117
+ } catch {
4118
+ }
4092
4119
  if (transport.isPaneInCopyMode(targetSession)) {
4093
4120
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
4094
4121
  transport.sendKeys(targetSession, "q");
@@ -5110,7 +5137,7 @@ var init_tasks_crud = __esm({
5110
5137
 
5111
5138
  // src/lib/tasks-review.ts
5112
5139
  import path15 from "path";
5113
- import { existsSync as existsSync14, readdirSync as readdirSync3, unlinkSync as unlinkSync5 } from "fs";
5140
+ import { existsSync as existsSync14, readdirSync as readdirSync4, unlinkSync as unlinkSync5 } from "fs";
5114
5141
  async function countPendingReviews(sessionScope) {
5115
5142
  const client = getClient();
5116
5143
  if (sessionScope) {
@@ -5293,7 +5320,7 @@ async function cleanupReviewFile(row, taskFile, _baseDir) {
5293
5320
  try {
5294
5321
  const cacheDir = path15.join(EXE_AI_DIR, "session-cache");
5295
5322
  if (existsSync14(cacheDir)) {
5296
- for (const f of readdirSync3(cacheDir)) {
5323
+ for (const f of readdirSync4(cacheDir)) {
5297
5324
  if (f.startsWith("review-notified-")) {
5298
5325
  unlinkSync5(path15.join(cacheDir, f));
5299
5326
  }
@@ -6050,7 +6077,7 @@ __export(worker_gate_exports, {
6050
6077
  tryAcquireBackfillLock: () => tryAcquireBackfillLock,
6051
6078
  tryAcquireWorkerSlot: () => tryAcquireWorkerSlot
6052
6079
  });
6053
- import { readdirSync as readdirSync4, writeFileSync as writeFileSync8, unlinkSync as unlinkSync7, mkdirSync as mkdirSync8, existsSync as existsSync15 } from "fs";
6080
+ import { readdirSync as readdirSync5, writeFileSync as writeFileSync8, unlinkSync as unlinkSync7, mkdirSync as mkdirSync8, existsSync as existsSync15 } from "fs";
6054
6081
  import path18 from "path";
6055
6082
  function tryAcquireWorkerSlot() {
6056
6083
  try {
@@ -6058,7 +6085,7 @@ function tryAcquireWorkerSlot() {
6058
6085
  const reservationId = `res-${process.pid}-${Date.now()}`;
6059
6086
  const reservationPath = path18.join(WORKER_PID_DIR, `${reservationId}.pid`);
6060
6087
  writeFileSync8(reservationPath, String(process.pid));
6061
- const files = readdirSync4(WORKER_PID_DIR);
6088
+ const files = readdirSync5(WORKER_PID_DIR);
6062
6089
  let alive = 0;
6063
6090
  for (const f of files) {
6064
6091
  if (!f.endsWith(".pid")) continue;
@@ -2082,7 +2082,7 @@ var init_plan_limits = __esm({
2082
2082
  });
2083
2083
 
2084
2084
  // src/lib/tmux-routing.ts
2085
- import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, existsSync as existsSync8, appendFileSync } from "fs";
2085
+ import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, existsSync as existsSync8, 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({
@@ -2298,7 +2307,7 @@ __export(shard_manager_exports, {
2298
2307
  shardExists: () => shardExists
2299
2308
  });
2300
2309
  import path12 from "path";
2301
- import { existsSync as existsSync10, mkdirSync as mkdirSync6, readdirSync as readdirSync2 } from "fs";
2310
+ import { existsSync as existsSync10, mkdirSync as mkdirSync6, readdirSync as readdirSync3 } from "fs";
2302
2311
  import { createClient as createClient2 } from "@libsql/client";
2303
2312
  function initShardManager(encryptionKey) {
2304
2313
  _encryptionKey = encryptionKey;
@@ -2337,7 +2346,7 @@ function shardExists(projectName) {
2337
2346
  }
2338
2347
  function listShards() {
2339
2348
  if (!existsSync10(SHARDS_DIR)) return [];
2340
- return readdirSync2(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
2349
+ return readdirSync3(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
2341
2350
  }
2342
2351
  async function ensureShardSchema(client) {
2343
2352
  await client.execute("PRAGMA journal_mode = WAL");
@@ -4386,7 +4386,7 @@ __export(tmux_routing_exports, {
4386
4386
  verifyPaneAtCapacity: () => verifyPaneAtCapacity
4387
4387
  });
4388
4388
  import { execFileSync as execFileSync2, execSync as execSync7 } from "child_process";
4389
- import { readFileSync as readFileSync12, writeFileSync as writeFileSync8, mkdirSync as mkdirSync7, existsSync as existsSync12, appendFileSync } from "fs";
4389
+ import { readFileSync as readFileSync12, writeFileSync as writeFileSync8, mkdirSync as mkdirSync7, existsSync as existsSync12, appendFileSync, readdirSync as readdirSync4 } from "fs";
4390
4390
  import path16 from "path";
4391
4391
  import os8 from "os";
4392
4392
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -4534,15 +4534,24 @@ function getDispatchedBy(sessionKey) {
4534
4534
  function resolveExeSession() {
4535
4535
  const mySession = getMySession();
4536
4536
  if (!mySession) return null;
4537
+ const fromSessionName = extractRootExe(mySession);
4537
4538
  try {
4538
4539
  const key = getSessionKey();
4539
4540
  const parentExe = getParentExe(key);
4540
4541
  if (parentExe) {
4541
- return extractRootExe(parentExe) ?? parentExe;
4542
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
4543
+ if (fromSessionName && fromCache !== fromSessionName) {
4544
+ process.stderr.write(
4545
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
4546
+ `
4547
+ );
4548
+ return fromSessionName;
4549
+ }
4550
+ return fromCache;
4542
4551
  }
4543
4552
  } catch {
4544
4553
  }
4545
- return extractRootExe(mySession) ?? mySession;
4554
+ return fromSessionName ?? mySession;
4546
4555
  }
4547
4556
  function isEmployeeAlive(sessionName) {
4548
4557
  return getTransport().isAlive(sessionName);
@@ -4707,6 +4716,24 @@ function sendIntercom(targetSession) {
4707
4716
  }
4708
4717
  } catch {
4709
4718
  }
4719
+ try {
4720
+ const rawAgent = targetSession.split("-")[0] ?? targetSession;
4721
+ const agent = baseAgentName(rawAgent);
4722
+ const taskDir = path16.join(process.cwd(), "exe", agent);
4723
+ if (existsSync12(taskDir)) {
4724
+ const files = readdirSync4(taskDir).filter(
4725
+ (f) => f.endsWith(".md") && f !== "DONE.txt"
4726
+ );
4727
+ if (files.length === 0) {
4728
+ logIntercom(`SKIP \u2192 ${targetSession} (no task files in exe/${agent}/ \u2014 nothing to do)`);
4729
+ return "debounced";
4730
+ }
4731
+ } else {
4732
+ logIntercom(`SKIP \u2192 ${targetSession} (no task folder exe/${agent}/ \u2014 nothing to do)`);
4733
+ return "debounced";
4734
+ }
4735
+ } catch {
4736
+ }
4710
4737
  if (transport.isPaneInCopyMode(targetSession)) {
4711
4738
  logIntercom(`COPY_MODE \u2192 ${targetSession} (exiting copy mode first)`);
4712
4739
  transport.sendKeys(targetSession, "q");
@@ -5217,7 +5244,7 @@ __export(shard_manager_exports, {
5217
5244
  shardExists: () => shardExists
5218
5245
  });
5219
5246
  import path18 from "path";
5220
- import { existsSync as existsSync14, mkdirSync as mkdirSync8, readdirSync as readdirSync4 } from "fs";
5247
+ import { existsSync as existsSync14, mkdirSync as mkdirSync8, readdirSync as readdirSync5 } from "fs";
5221
5248
  import { createClient as createClient2 } from "@libsql/client";
5222
5249
  function initShardManager(encryptionKey) {
5223
5250
  _encryptionKey = encryptionKey;
@@ -5256,7 +5283,7 @@ function shardExists(projectName) {
5256
5283
  }
5257
5284
  function listShards() {
5258
5285
  if (!existsSync14(SHARDS_DIR)) return [];
5259
- return readdirSync4(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
5286
+ return readdirSync5(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
5260
5287
  }
5261
5288
  async function ensureShardSchema(client) {
5262
5289
  await client.execute("PRAGMA journal_mode = WAL");
@@ -2249,7 +2249,7 @@ var init_plan_limits = __esm({
2249
2249
  });
2250
2250
 
2251
2251
  // src/lib/tmux-routing.ts
2252
- import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, existsSync as existsSync8, appendFileSync } from "fs";
2252
+ import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5, existsSync as existsSync8, appendFileSync, readdirSync as readdirSync2 } from "fs";
2253
2253
  import path10 from "path";
2254
2254
  import os6 from "os";
2255
2255
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -2273,15 +2273,24 @@ function getParentExe(sessionKey) {
2273
2273
  function resolveExeSession() {
2274
2274
  const mySession = getMySession();
2275
2275
  if (!mySession) return null;
2276
+ const fromSessionName = extractRootExe(mySession);
2276
2277
  try {
2277
2278
  const key = getSessionKey();
2278
2279
  const parentExe = getParentExe(key);
2279
2280
  if (parentExe) {
2280
- return extractRootExe(parentExe) ?? parentExe;
2281
+ const fromCache = extractRootExe(parentExe) ?? parentExe;
2282
+ if (fromSessionName && fromCache !== fromSessionName) {
2283
+ process.stderr.write(
2284
+ `[tmux-routing] WARN: cache says "${fromCache}" but session name says "${fromSessionName}". Trusting session name.
2285
+ `
2286
+ );
2287
+ return fromSessionName;
2288
+ }
2289
+ return fromCache;
2281
2290
  }
2282
2291
  } catch {
2283
2292
  }
2284
- return extractRootExe(mySession) ?? mySession;
2293
+ return fromSessionName ?? mySession;
2285
2294
  }
2286
2295
  var SPAWN_LOCK_DIR, SESSION_CACHE, INTERCOM_LOG2, DEBOUNCE_FILE, DEBOUNCE_CLEANUP_AGE_MS;
2287
2296
  var init_tmux_routing = __esm({
@@ -2646,7 +2655,7 @@ __export(shard_manager_exports, {
2646
2655
  shardExists: () => shardExists
2647
2656
  });
2648
2657
  import path13 from "path";
2649
- import { existsSync as existsSync11, mkdirSync as mkdirSync6, readdirSync as readdirSync2 } from "fs";
2658
+ import { existsSync as existsSync11, mkdirSync as mkdirSync6, readdirSync as readdirSync3 } from "fs";
2650
2659
  import { createClient as createClient2 } from "@libsql/client";
2651
2660
  function initShardManager(encryptionKey) {
2652
2661
  _encryptionKey = encryptionKey;
@@ -2685,7 +2694,7 @@ function shardExists(projectName) {
2685
2694
  }
2686
2695
  function listShards() {
2687
2696
  if (!existsSync11(SHARDS_DIR)) return [];
2688
- return readdirSync2(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
2697
+ return readdirSync3(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
2689
2698
  }
2690
2699
  async function ensureShardSchema(client) {
2691
2700
  await client.execute("PRAGMA journal_mode = WAL");