switchroom 0.13.58 → 0.13.59

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.
@@ -16334,10 +16334,10 @@ __export(exports_client, {
16334
16334
  AuthBrokerClient: () => AuthBrokerClient
16335
16335
  });
16336
16336
  import * as net from "node:net";
16337
- import { existsSync as existsSync7 } from "node:fs";
16337
+ import { existsSync as existsSync6 } from "node:fs";
16338
16338
  import { homedir as homedir3 } from "node:os";
16339
16339
  import { randomUUID as randomUUID3 } from "node:crypto";
16340
- import { join as join9 } from "node:path";
16340
+ import { join as join8 } from "node:path";
16341
16341
  function reviveDate(v) {
16342
16342
  if (v == null)
16343
16343
  return null;
@@ -16347,7 +16347,7 @@ function reviveDate(v) {
16347
16347
  return Number.isNaN(d.getTime()) ? null : d;
16348
16348
  }
16349
16349
  function operatorSocketPath(home = homedir3()) {
16350
- return join9(home, ".switchroom", "state", "auth-broker-operator", "sock");
16350
+ return join8(home, ".switchroom", "state", "auth-broker-operator", "sock");
16351
16351
  }
16352
16352
  function resolveAuthBrokerSocketPath(opts) {
16353
16353
  if (opts?.socket)
@@ -16617,7 +16617,7 @@ async function withAuthBrokerClient(fn, opts) {
16617
16617
  }
16618
16618
  }
16619
16619
  function authBrokerSocketExists(opts) {
16620
- return existsSync7(resolveAuthBrokerSocketPath(opts));
16620
+ return existsSync6(resolveAuthBrokerSocketPath(opts));
16621
16621
  }
16622
16622
  var DEFAULT_TIMEOUT_MS = 5000, AuthBrokerError, AuthBrokerUnreachableError;
16623
16623
  var init_client = __esm(() => {
@@ -24109,7 +24109,7 @@ var init_schema = __esm(() => {
24109
24109
  });
24110
24110
 
24111
24111
  // ../src/config/paths.ts
24112
- import { existsSync as existsSync8 } from "node:fs";
24112
+ import { existsSync as existsSync7 } from "node:fs";
24113
24113
  import { resolve as resolve2 } from "node:path";
24114
24114
  function home() {
24115
24115
  return process.env.HOME ?? "/root";
@@ -24128,9 +24128,9 @@ function resolveDualPath(pathStr) {
24128
24128
  const absolute = resolve2(h, rest);
24129
24129
  if (rest.startsWith(`${DEFAULT_STATE_DIR}/`)) {
24130
24130
  const frag = rest.slice(DEFAULT_STATE_DIR.length + 1);
24131
- if (!existsSync8(absolute)) {
24131
+ if (!existsSync7(absolute)) {
24132
24132
  const legacy = resolve2(h, LEGACY_STATE_DIR, frag);
24133
- if (existsSync8(legacy)) {
24133
+ if (existsSync7(legacy)) {
24134
24134
  warnLegacyStateOnce(legacy);
24135
24135
  return legacy;
24136
24136
  }
@@ -24155,14 +24155,14 @@ var init_overlay_schema = __esm(() => {
24155
24155
  });
24156
24156
 
24157
24157
  // ../src/config/overlay-loader.ts
24158
- import { existsSync as existsSync9, readFileSync as readFileSync4, readdirSync, statSync as statSync2 } from "node:fs";
24158
+ import { existsSync as existsSync8, readFileSync as readFileSync4, readdirSync, statSync as statSync2 } from "node:fs";
24159
24159
  import { resolve as resolve3 } from "node:path";
24160
24160
  function overlayDirFor(agentName3, subdir) {
24161
24161
  const base = resolveDualPath(`~/.switchroom/agents/${agentName3}/${subdir}`);
24162
24162
  return resolve3(base);
24163
24163
  }
24164
24164
  function listYamlFiles(dir) {
24165
- if (!existsSync9(dir))
24165
+ if (!existsSync8(dir))
24166
24166
  return [];
24167
24167
  let entries;
24168
24168
  try {
@@ -24619,7 +24619,7 @@ function validateNotionWorkspaceConfig(config) {
24619
24619
  }
24620
24620
 
24621
24621
  // ../src/config/loader.ts
24622
- import { readFileSync as readFileSync5, existsSync as existsSync10 } from "node:fs";
24622
+ import { readFileSync as readFileSync5, existsSync as existsSync9 } from "node:fs";
24623
24623
  import { homedir as homedir5 } from "node:os";
24624
24624
  import { resolve as resolve4 } from "node:path";
24625
24625
  function formatZodErrors(error) {
@@ -24686,7 +24686,7 @@ function findConfigFile(startDir) {
24686
24686
  resolve4(userDir, "clerk.yml")
24687
24687
  ].filter(Boolean);
24688
24688
  for (const path of searchPaths) {
24689
- if (existsSync10(path)) {
24689
+ if (existsSync9(path)) {
24690
24690
  return path;
24691
24691
  }
24692
24692
  }
@@ -24694,7 +24694,7 @@ function findConfigFile(startDir) {
24694
24694
  }
24695
24695
  function loadConfig(configPath) {
24696
24696
  const filePath = configPath ?? findConfigFile();
24697
- if (!existsSync10(filePath)) {
24697
+ if (!existsSync9(filePath)) {
24698
24698
  throw new ConfigError(`Config file not found: ${filePath}`);
24699
24699
  }
24700
24700
  let raw;
@@ -24802,7 +24802,7 @@ __export(exports_history, {
24802
24802
  _resetForTests: () => _resetForTests
24803
24803
  });
24804
24804
  import { chmodSync as chmodSync2, mkdirSync as mkdirSync9 } from "fs";
24805
- import { join as join12 } from "path";
24805
+ import { join as join11 } from "path";
24806
24806
  function loadDatabaseClass() {
24807
24807
  if (DatabaseClass != null)
24808
24808
  return DatabaseClass;
@@ -24825,7 +24825,7 @@ function initHistory(stateDir, retentionDays = 30) {
24825
24825
  return;
24826
24826
  const Database = loadDatabaseClass();
24827
24827
  mkdirSync9(stateDir, { recursive: true, mode: 448 });
24828
- const path = join12(stateDir, "history.db");
24828
+ const path = join11(stateDir, "history.db");
24829
24829
  db = new Database(path, { create: true });
24830
24830
  db.exec("PRAGMA journal_mode = WAL");
24831
24831
  db.exec("PRAGMA synchronous = NORMAL");
@@ -25015,11 +25015,11 @@ var DatabaseClass = null, DEFAULT_LIMIT = 10, MAX_LIMIT = 50, db = null;
25015
25015
  var init_history = () => {};
25016
25016
 
25017
25017
  // quota-check.ts
25018
- import { readFileSync as readFileSync8, existsSync as existsSync13 } from "fs";
25019
- import { join as join13 } from "path";
25018
+ import { readFileSync as readFileSync8, existsSync as existsSync12 } from "fs";
25019
+ import { join as join12 } from "path";
25020
25020
  function readOauthToken(claudeConfigDir) {
25021
- const tokenFile = join13(claudeConfigDir, ".oauth-token");
25022
- if (!existsSync13(tokenFile))
25021
+ const tokenFile = join12(claudeConfigDir, ".oauth-token");
25022
+ if (!existsSync12(tokenFile))
25023
25023
  return null;
25024
25024
  try {
25025
25025
  const raw = readFileSync8(tokenFile, "utf-8").trim();
@@ -25501,7 +25501,7 @@ function isDockerRuntime() {
25501
25501
  import * as net3 from "node:net";
25502
25502
  import * as fs from "node:fs";
25503
25503
  import { homedir as homedir7 } from "node:os";
25504
- import { join as join17 } from "node:path";
25504
+ import { join as join16 } from "node:path";
25505
25505
  function defaultBrokerSocketPath() {
25506
25506
  if (fs.existsSync(OPERATOR_SOCKET_PATH))
25507
25507
  return OPERATOR_SOCKET_PATH;
@@ -25510,7 +25510,7 @@ function defaultBrokerSocketPath() {
25510
25510
  return LEGACY_SOCKET_PATH;
25511
25511
  }
25512
25512
  function vaultTokenFilePath(agentSlug) {
25513
- return join17(homedir7(), ".switchroom", "agents", agentSlug, ".vault-token");
25513
+ return join16(homedir7(), ".switchroom", "agents", agentSlug, ".vault-token");
25514
25514
  }
25515
25515
  function readVaultTokenFile(agentSlug) {
25516
25516
  const filePath = vaultTokenFilePath(agentSlug);
@@ -25665,8 +25665,8 @@ var DEFAULT_TIMEOUT_MS3 = 2000, LEGACY_SOCKET_PATH, OPERATOR_SOCKET_PATH;
25665
25665
  var init_client2 = __esm(() => {
25666
25666
  init_protocol2();
25667
25667
  init_peercred();
25668
- LEGACY_SOCKET_PATH = join17(homedir7(), ".switchroom", "vault-broker.sock");
25669
- OPERATOR_SOCKET_PATH = join17(homedir7(), ".switchroom", "broker-operator", "sock");
25668
+ LEGACY_SOCKET_PATH = join16(homedir7(), ".switchroom", "vault-broker.sock");
25669
+ OPERATOR_SOCKET_PATH = join16(homedir7(), ".switchroom", "broker-operator", "sock");
25670
25670
  });
25671
25671
 
25672
25672
  // ../src/drive/deep-links.ts
@@ -27855,15 +27855,15 @@ function renderAuthLine(state4, agentName3, now = Date.now()) {
27855
27855
  }
27856
27856
 
27857
27857
  // gateway/quota-cache.ts
27858
- import { existsSync as existsSync24, readFileSync as readFileSync22, writeFileSync as writeFileSync13, mkdirSync as mkdirSync11 } from "fs";
27859
- import { join as join21, dirname as dirname8 } from "path";
27858
+ import { existsSync as existsSync23, readFileSync as readFileSync22, writeFileSync as writeFileSync13, mkdirSync as mkdirSync11 } from "fs";
27859
+ import { join as join20, dirname as dirname8 } from "path";
27860
27860
  function defaultCachePath() {
27861
- return process.env.SWITCHROOM_QUOTA_CACHE_PATH ?? join21(process.env.HOME ?? "/tmp", ".switchroom", "quota-cache.json");
27861
+ return process.env.SWITCHROOM_QUOTA_CACHE_PATH ?? join20(process.env.HOME ?? "/tmp", ".switchroom", "quota-cache.json");
27862
27862
  }
27863
27863
  function readQuotaCache(opts = {}) {
27864
27864
  const path = opts.path ?? defaultCachePath();
27865
27865
  const now = opts.now ?? Date.now();
27866
- if (!existsSync24(path))
27866
+ if (!existsSync23(path))
27867
27867
  return null;
27868
27868
  let entry;
27869
27869
  try {
@@ -27904,8 +27904,8 @@ var init_quota_cache = __esm(() => {
27904
27904
  });
27905
27905
 
27906
27906
  // gateway/boot-probes.ts
27907
- import { readFileSync as readFileSync23, readdirSync as readdirSync4, existsSync as existsSync25 } from "fs";
27908
- import { join as join22 } from "path";
27907
+ import { readFileSync as readFileSync23, readdirSync as readdirSync4, existsSync as existsSync24 } from "fs";
27908
+ import { join as join21 } from "path";
27909
27909
  import { execFile as execFileCb } from "child_process";
27910
27910
  import { promisify as promisify3 } from "util";
27911
27911
  async function withTimeout(label, p, timeoutMs = PROBE_TIMEOUT_MS) {
@@ -27947,8 +27947,8 @@ function mapPlan(billingType, hasExtra) {
27947
27947
  }
27948
27948
  async function probeAccount(agentDir) {
27949
27949
  return withTimeout("Account", (async () => {
27950
- const claudeDir = join22(agentDir, ".claude");
27951
- const claudeJsonPath = join22(claudeDir, ".claude.json");
27950
+ const claudeDir = join21(agentDir, ".claude");
27951
+ const claudeJsonPath = join21(claudeDir, ".claude.json");
27952
27952
  let cfg = {};
27953
27953
  try {
27954
27954
  const raw = readFileSync23(claudeJsonPath, "utf8");
@@ -27969,10 +27969,10 @@ async function probeAccount(agentDir) {
27969
27969
  let tokenStr = "";
27970
27970
  let status = "ok";
27971
27971
  for (const candidate of [
27972
- join22(claudeDir, ".oauth-token.meta.json"),
27973
- join22(claudeDir, "accounts", "default", ".oauth-token.meta.json")
27972
+ join21(claudeDir, ".oauth-token.meta.json"),
27973
+ join21(claudeDir, "accounts", "default", ".oauth-token.meta.json")
27974
27974
  ]) {
27975
- if (existsSync25(candidate)) {
27975
+ if (existsSync24(candidate)) {
27976
27976
  try {
27977
27977
  const meta = JSON.parse(readFileSync23(candidate, "utf8"));
27978
27978
  if (meta.expiresAt) {
@@ -28149,7 +28149,7 @@ async function resolveTmuxSupervisorPid(agentName3, execFileImpl) {
28149
28149
  if (!cgroup)
28150
28150
  return null;
28151
28151
  const procsPath = `/sys/fs/cgroup${cgroup}/cgroup.procs`;
28152
- if (!existsSync25(procsPath))
28152
+ if (!existsSync24(procsPath))
28153
28153
  return null;
28154
28154
  const pidsRaw = readFileSync23(procsPath, "utf-8");
28155
28155
  const pids = pidsRaw.split(`
@@ -28356,9 +28356,9 @@ async function probeQuota(claudeConfigDir, _agentDir, fetchImpl = fetch, opts =
28356
28356
  let claudeDirForProbe = null;
28357
28357
  for (const candidate of [
28358
28358
  claudeConfigDir,
28359
- join22(claudeConfigDir, "accounts", "default")
28359
+ join21(claudeConfigDir, "accounts", "default")
28360
28360
  ]) {
28361
- if (existsSync25(join22(candidate, ".oauth-token"))) {
28361
+ if (existsSync24(join21(candidate, ".oauth-token"))) {
28362
28362
  claudeDirForProbe = candidate;
28363
28363
  break;
28364
28364
  }
@@ -28529,7 +28529,7 @@ async function probeUds(label, socketPath, opts = {}) {
28529
28529
  }
28530
28530
  return withTimeout(label, (async () => {
28531
28531
  if (!opts.connectImpl) {
28532
- if (!existsSync25(socketPath)) {
28532
+ if (!existsSync24(socketPath)) {
28533
28533
  return {
28534
28534
  status: "fail",
28535
28535
  label,
@@ -28593,7 +28593,7 @@ async function probeSkills(agentDir, opts = {}) {
28593
28593
  return withTimeout("Skills", (async () => {
28594
28594
  const fs2 = opts.fs ?? realSkillsFs;
28595
28595
  const max = opts.maxNamesShown ?? 3;
28596
- const skillsDir = join22(agentDir, ".claude", "skills");
28596
+ const skillsDir = join21(agentDir, ".claude", "skills");
28597
28597
  if (!fs2.exists(skillsDir)) {
28598
28598
  return { status: "ok", label: "Skills", detail: "no skills dir" };
28599
28599
  }
@@ -28608,17 +28608,17 @@ async function probeSkills(agentDir, opts = {}) {
28608
28608
  }
28609
28609
  const dangling = [];
28610
28610
  for (const name of entries) {
28611
- const skillPath = join22(skillsDir, name);
28611
+ const skillPath = join21(skillsDir, name);
28612
28612
  if (!fs2.exists(skillPath)) {
28613
28613
  dangling.push(name);
28614
28614
  continue;
28615
28615
  }
28616
- const skillMd = join22(skillPath, "SKILL.md");
28616
+ const skillMd = join21(skillPath, "SKILL.md");
28617
28617
  if (!fs2.exists(skillMd) && !fs2.exists(skillPath + ".md")) {
28618
28618
  continue;
28619
28619
  }
28620
28620
  }
28621
- const overlayDir = opts.overlaySkillsDir ?? join22(agentDir, "skills.d");
28621
+ const overlayDir = opts.overlaySkillsDir ?? join21(agentDir, "skills.d");
28622
28622
  const overlaySlugs = new Set;
28623
28623
  if (fs2.exists(overlayDir)) {
28624
28624
  let overlayEntries = [];
@@ -28673,16 +28673,16 @@ var init_boot_probes = __esm(() => {
28673
28673
  const { statSync: statSync7 } = __require("fs");
28674
28674
  return statSync7(p).mtimeMs;
28675
28675
  },
28676
- exists: (p) => existsSync25(p)
28676
+ exists: (p) => existsSync24(p)
28677
28677
  };
28678
28678
  realSkillsFs = {
28679
28679
  readdir: (p) => readdirSync4(p),
28680
- exists: (p) => existsSync25(p)
28680
+ exists: (p) => existsSync24(p)
28681
28681
  };
28682
28682
  });
28683
28683
 
28684
28684
  // gateway/boot-issue-cache.ts
28685
- import { existsSync as existsSync26, readFileSync as readFileSync24, writeFileSync as writeFileSync14, mkdirSync as mkdirSync12, renameSync as renameSync9 } from "fs";
28685
+ import { existsSync as existsSync25, readFileSync as readFileSync24, writeFileSync as writeFileSync14, mkdirSync as mkdirSync12, renameSync as renameSync9 } from "fs";
28686
28686
  import { dirname as dirname9 } from "path";
28687
28687
  function fingerprintProbe(key, r) {
28688
28688
  if (r.status === "ok")
@@ -28762,7 +28762,7 @@ function diffProbes(probes, cache, opts = {}) {
28762
28762
  return out;
28763
28763
  }
28764
28764
  function loadCache(path, now = Date.now) {
28765
- if (!existsSync26(path))
28765
+ if (!existsSync25(path))
28766
28766
  return { ...EMPTY_CACHE, probes: {} };
28767
28767
  let raw;
28768
28768
  try {
@@ -28833,7 +28833,7 @@ __export(exports_boot_card, {
28833
28833
  renderBootCard: () => renderBootCard,
28834
28834
  renderAccountRows: () => renderAuthLine
28835
28835
  });
28836
- import { join as join23 } from "path";
28836
+ import { join as join22 } from "path";
28837
28837
  function resolvePersonaName(slug, loadConfig3) {
28838
28838
  try {
28839
28839
  const config = loadConfig3 ? loadConfig3() : loadConfig();
@@ -28914,7 +28914,7 @@ function renderBootCard(opts) {
28914
28914
  `);
28915
28915
  }
28916
28916
  async function runAllProbes(opts) {
28917
- const claudeDir = join23(opts.agentDir, ".claude");
28917
+ const claudeDir = join22(opts.agentDir, ".claude");
28918
28918
  const probes = {};
28919
28919
  const slug = opts.agentSlug ?? opts.agentName;
28920
28920
  await Promise.allSettled([
@@ -29158,10 +29158,10 @@ import { randomBytes as randomBytes5, scryptSync, createCipheriv, createDecipher
29158
29158
  import {
29159
29159
  readFileSync as readFileSync31,
29160
29160
  writeFileSync as writeFileSync19,
29161
- existsSync as existsSync33,
29161
+ existsSync as existsSync32,
29162
29162
  renameSync as renameSync11,
29163
29163
  mkdirSync as mkdirSync18,
29164
- unlinkSync as unlinkSync13,
29164
+ unlinkSync as unlinkSync12,
29165
29165
  lstatSync,
29166
29166
  realpathSync
29167
29167
  } from "node:fs";
@@ -29196,7 +29196,7 @@ function normalizeSecrets(raw) {
29196
29196
  return out;
29197
29197
  }
29198
29198
  function openVault(passphrase, vaultPath) {
29199
- if (!existsSync33(vaultPath)) {
29199
+ if (!existsSync32(vaultPath)) {
29200
29200
  throw new VaultError(`Vault file not found: ${vaultPath}`);
29201
29201
  }
29202
29202
  let vaultFile;
@@ -29247,15 +29247,15 @@ var init_vault = __esm(() => {
29247
29247
  // ../src/vault/resolver.ts
29248
29248
  import {
29249
29249
  chmodSync as chmodSync4,
29250
- closeSync as closeSync8,
29250
+ closeSync as closeSync7,
29251
29251
  mkdirSync as mkdirSync19,
29252
29252
  mkdtempSync as mkdtempSync2,
29253
- openSync as openSync8,
29253
+ openSync as openSync7,
29254
29254
  rmSync as rmSync3,
29255
29255
  statSync as statSync11,
29256
29256
  writeSync as writeSync2
29257
29257
  } from "node:fs";
29258
- import { join as join32 } from "node:path";
29258
+ import { join as join31 } from "node:path";
29259
29259
  import { tmpdir } from "node:os";
29260
29260
  import { constants as fsConstants } from "node:fs";
29261
29261
  function isVaultReference(value) {
@@ -29307,26 +29307,26 @@ function materializationRoot() {
29307
29307
  return cachedRoot;
29308
29308
  const xdg = process.env.XDG_RUNTIME_DIR;
29309
29309
  if (xdg) {
29310
- const base = join32(xdg, "switchroom", "vault");
29310
+ const base = join31(xdg, "switchroom", "vault");
29311
29311
  mkdirSync19(base, { recursive: true, mode: 448 });
29312
- cachedRoot = mkdtempSync2(join32(base, "run-"));
29312
+ cachedRoot = mkdtempSync2(join31(base, "run-"));
29313
29313
  } else {
29314
- cachedRoot = mkdtempSync2(join32(tmpdir(), "switchroom-vault-"));
29314
+ cachedRoot = mkdtempSync2(join31(tmpdir(), "switchroom-vault-"));
29315
29315
  }
29316
29316
  chmodSync4(cachedRoot, 448);
29317
29317
  return cachedRoot;
29318
29318
  }
29319
29319
  function writeFileExclusive(filePath, content) {
29320
29320
  const buf = typeof content === "string" ? Buffer.from(content, "utf8") : content;
29321
- const fd = openSync8(filePath, fsConstants.O_WRONLY | fsConstants.O_CREAT | fsConstants.O_EXCL, 384);
29321
+ const fd = openSync7(filePath, fsConstants.O_WRONLY | fsConstants.O_CREAT | fsConstants.O_EXCL, 384);
29322
29322
  try {
29323
29323
  writeSync2(fd, buf);
29324
29324
  } finally {
29325
- closeSync8(fd);
29325
+ closeSync7(fd);
29326
29326
  }
29327
29327
  }
29328
29328
  function materializeFilesEntry(key, files) {
29329
- const dir = join32(materializationRoot(), key);
29329
+ const dir = join31(materializationRoot(), key);
29330
29330
  if (materializedDirs.has(dir)) {
29331
29331
  try {
29332
29332
  rmSync3(dir, { recursive: true, force: true });
@@ -29342,7 +29342,7 @@ function materializeFilesEntry(key, files) {
29342
29342
  if (filename.includes("/") || filename.includes("\\") || filename === ".." || filename === "." || filename.includes("\x00")) {
29343
29343
  throw new Error(`Refusing to materialize vault file with unsafe name: ${filename}`);
29344
29344
  }
29345
- const filePath = join32(dir, filename);
29345
+ const filePath = join31(dir, filename);
29346
29346
  const content = encoding === "base64" ? Buffer.from(value, "base64") : value;
29347
29347
  writeFileExclusive(filePath, content);
29348
29348
  }
@@ -29475,7 +29475,7 @@ __export(exports_materialize_bot_token, {
29475
29475
  materializeBotToken: () => materializeBotToken,
29476
29476
  BotTokenMaterializeError: () => BotTokenMaterializeError
29477
29477
  });
29478
- import { existsSync as existsSync34 } from "node:fs";
29478
+ import { existsSync as existsSync33 } from "node:fs";
29479
29479
  function pickConfiguredToken(config, agentName3) {
29480
29480
  if (agentName3) {
29481
29481
  const agent = config.agents?.[agentName3];
@@ -29489,7 +29489,7 @@ function tryDirectVaultRead(ref, config, passphrase) {
29489
29489
  if (!passphrase)
29490
29490
  return null;
29491
29491
  const vaultPath = resolvePath(config.vault?.path ?? "~/.switchroom/vault.enc");
29492
- if (!existsSync34(vaultPath))
29492
+ if (!existsSync33(vaultPath))
29493
29493
  return null;
29494
29494
  try {
29495
29495
  const secrets = openVault(passphrase, vaultPath);
@@ -29794,7 +29794,7 @@ __export(exports_tmux, {
29794
29794
  captureAgentPane: () => captureAgentPane
29795
29795
  });
29796
29796
  import { execFileSync as execFileSync4 } from "node:child_process";
29797
- import { mkdirSync as mkdirSync20, readdirSync as readdirSync6, statSync as statSync12, unlinkSync as unlinkSync14, writeFileSync as writeFileSync20 } from "node:fs";
29797
+ import { mkdirSync as mkdirSync20, readdirSync as readdirSync6, statSync as statSync12, unlinkSync as unlinkSync13, writeFileSync as writeFileSync20 } from "node:fs";
29798
29798
  import { resolve as resolve7 } from "node:path";
29799
29799
  function captureAgentPane(opts) {
29800
29800
  const { agentName: agentName3, agentDir, reason } = opts;
@@ -29908,7 +29908,7 @@ function pruneOldReports(dir, retain) {
29908
29908
  }).sort((a, b) => b.mtimeMs - a.mtimeMs);
29909
29909
  for (const stale of files.slice(retain)) {
29910
29910
  try {
29911
- unlinkSync14(stale.full);
29911
+ unlinkSync13(stale.full);
29912
29912
  } catch {}
29913
29913
  }
29914
29914
  }
@@ -30504,14 +30504,14 @@ import {
30504
30504
  renameSync as renameSync12,
30505
30505
  realpathSync as realpathSync2,
30506
30506
  chmodSync as chmodSync5,
30507
- openSync as openSync9,
30508
- closeSync as closeSync9,
30509
- existsSync as existsSync35,
30510
- unlinkSync as unlinkSync15,
30507
+ openSync as openSync8,
30508
+ closeSync as closeSync8,
30509
+ existsSync as existsSync34,
30510
+ unlinkSync as unlinkSync14,
30511
30511
  appendFileSync as appendFileSync3
30512
30512
  } from "fs";
30513
30513
  import { homedir as homedir12 } from "os";
30514
- import { join as join33, extname, sep as sep3, basename as basename7 } from "path";
30514
+ import { join as join32, extname, sep as sep3, basename as basename7 } from "path";
30515
30515
 
30516
30516
  // plugin-logger.ts
30517
30517
  import { appendFileSync, mkdirSync, renameSync, statSync, existsSync } from "fs";
@@ -38359,45 +38359,6 @@ function recordSilentTurnEnd(args, deps) {
38359
38359
  }
38360
38360
  var recordUndeliveredTurnEnd = recordSilentTurnEnd;
38361
38361
 
38362
- // ack-flag.ts
38363
- import { closeSync, existsSync as existsSync6, openSync, unlinkSync as unlinkSync2 } from "node:fs";
38364
- import { join as join7 } from "node:path";
38365
- var ACK_SENT_MARKER = "ack-sent.flag";
38366
- function markerPath() {
38367
- const dir = process.env.TELEGRAM_STATE_DIR;
38368
- if (!dir)
38369
- return null;
38370
- return join7(dir, ACK_SENT_MARKER);
38371
- }
38372
- function markAckSent() {
38373
- const path = markerPath();
38374
- if (path == null)
38375
- return;
38376
- if (existsSync6(path))
38377
- return;
38378
- try {
38379
- const fd = openSync(path, "w");
38380
- closeSync(fd);
38381
- } catch (err) {
38382
- process.stderr.write(`ack-flag: markAckSent failed path=${path}: ${err}
38383
- `);
38384
- }
38385
- }
38386
- function clearAckSent() {
38387
- const path = markerPath();
38388
- if (path == null)
38389
- return;
38390
- try {
38391
- unlinkSync2(path);
38392
- } catch (err) {
38393
- const code = err?.code;
38394
- if (code === "ENOENT")
38395
- return;
38396
- process.stderr.write(`ack-flag: clearAckSent failed path=${path}: ${err}
38397
- `);
38398
- }
38399
- }
38400
-
38401
38362
  // final-answer-detect.ts
38402
38363
  var FINAL_ANSWER_MIN_CHARS = 200;
38403
38364
  function isFinalAnswerReply(input) {
@@ -38821,7 +38782,7 @@ async function gatewayStartupRetry(fn, opts = {}) {
38821
38782
 
38822
38783
  // gateway/quarantine.ts
38823
38784
  import { mkdirSync as mkdirSync6, writeFileSync as writeFileSync4 } from "node:fs";
38824
- import { join as join8 } from "node:path";
38785
+ import { join as join7 } from "node:path";
38825
38786
  var QUARANTINE_FILENAME = "quarantine.json";
38826
38787
  function writeQuarantineMarker(telegramStateDir, reason, detail, nowFn = Date.now) {
38827
38788
  mkdirSync6(telegramStateDir, { recursive: true, mode: 448 });
@@ -38831,7 +38792,7 @@ function writeQuarantineMarker(telegramStateDir, reason, detail, nowFn = Date.no
38831
38792
  ts: nowFn(),
38832
38793
  detail
38833
38794
  };
38834
- writeFileSync4(join8(telegramStateDir, QUARANTINE_FILENAME), JSON.stringify(marker) + `
38795
+ writeFileSync4(join7(telegramStateDir, QUARANTINE_FILENAME), JSON.stringify(marker) + `
38835
38796
  `, "utf-8");
38836
38797
  }
38837
38798
 
@@ -39716,7 +39677,7 @@ import * as net2 from "node:net";
39716
39677
  init_protocol();
39717
39678
  import { homedir as homedir4 } from "node:os";
39718
39679
  import { randomUUID as randomUUID4 } from "node:crypto";
39719
- import { join as join10 } from "node:path";
39680
+ import { join as join9 } from "node:path";
39720
39681
  var DEFAULT_TIMEOUT_MS2 = 5000;
39721
39682
  function reviveDate2(v) {
39722
39683
  if (v == null)
@@ -39727,7 +39688,7 @@ function reviveDate2(v) {
39727
39688
  return Number.isNaN(d.getTime()) ? null : d;
39728
39689
  }
39729
39690
  function operatorSocketPath2(home = homedir4()) {
39730
- return join10(home, ".switchroom", "state", "auth-broker-operator", "sock");
39691
+ return join9(home, ".switchroom", "state", "auth-broker-operator", "sock");
39731
39692
  }
39732
39693
  function resolveAuthBrokerSocketPath2(opts) {
39733
39694
  if (opts?.socket)
@@ -40059,16 +40020,16 @@ function createFleetFallbackGate(opts) {
40059
40020
 
40060
40021
  // gateway/auth-add-flow.ts
40061
40022
  import { spawn } from "node:child_process";
40062
- import { existsSync as existsSync12, mkdirSync as mkdirSync8, readFileSync as readFileSync7, rmSync as rmSync2 } from "node:fs";
40023
+ import { existsSync as existsSync11, mkdirSync as mkdirSync8, readFileSync as readFileSync7, rmSync as rmSync2 } from "node:fs";
40063
40024
  import { homedir as homedir6 } from "node:os";
40064
- import { join as join11 } from "node:path";
40025
+ import { join as join10 } from "node:path";
40065
40026
  import { randomBytes as randomBytes2 } from "node:crypto";
40066
40027
 
40067
40028
  // ../src/auth/manager.ts
40068
40029
  import {
40069
40030
  readFileSync as readFileSync6,
40070
40031
  readdirSync as readdirSync2,
40071
- existsSync as existsSync11,
40032
+ existsSync as existsSync10,
40072
40033
  writeFileSync as writeFileSync5,
40073
40034
  mkdirSync as mkdirSync7,
40074
40035
  mkdtempSync,
@@ -40095,7 +40056,7 @@ function parseSetupTokenUrl(output) {
40095
40056
  }
40096
40057
  function readTokenFromCredentialsFile(credentialsFilePath) {
40097
40058
  try {
40098
- if (!existsSync11(credentialsFilePath))
40059
+ if (!existsSync10(credentialsFilePath))
40099
40060
  return null;
40100
40061
  const raw = readFileSync6(credentialsFilePath, "utf-8");
40101
40062
  const parsed = JSON.parse(raw);
@@ -40114,7 +40075,7 @@ function readTokenFromCredentialsFile(credentialsFilePath) {
40114
40075
  var pendingAuthAddFlows = new Map;
40115
40076
  function pickScratchDir(label, home2 = homedir6()) {
40116
40077
  const suffix = randomBytes2(8).toString("hex");
40117
- return join11(home2, ".switchroom", "accounts", ".in-progress", `${label}-${suffix}`);
40078
+ return join10(home2, ".switchroom", "accounts", ".in-progress", `${label}-${suffix}`);
40118
40079
  }
40119
40080
  function cleanScratchDir(scratchDir) {
40120
40081
  try {
@@ -40175,7 +40136,7 @@ async function startAccountAuthSession(label, opts = {}) {
40175
40136
  async function submitAccountAuthCode(flow, code, opts = {}) {
40176
40137
  const pollIntervalMs = opts.pollIntervalMs ?? 250;
40177
40138
  const pollTimeoutMs = opts.pollTimeoutMs ?? 120000;
40178
- const credentialsPath = join11(flow.scratchDir, ".credentials.json");
40139
+ const credentialsPath = join10(flow.scratchDir, ".credentials.json");
40179
40140
  if (!flow.child.stdin || flow.child.stdin.destroyed) {
40180
40141
  cleanScratchDir(flow.scratchDir);
40181
40142
  throw new Error("claude setup-token process stdin is not writable (child may have exited)");
@@ -40185,7 +40146,7 @@ async function submitAccountAuthCode(flow, code, opts = {}) {
40185
40146
  const deadline = Date.now() + pollTimeoutMs;
40186
40147
  while (Date.now() < deadline) {
40187
40148
  await new Promise((r) => setTimeout(r, pollIntervalMs));
40188
- if (existsSync12(credentialsPath)) {
40149
+ if (existsSync11(credentialsPath)) {
40189
40150
  const token = readTokenFromCredentialsFile(credentialsPath);
40190
40151
  if (token) {
40191
40152
  try {
@@ -41745,8 +41706,8 @@ function isTurnFlushSafetyEnabled(env = process.env) {
41745
41706
  }
41746
41707
 
41747
41708
  // handoff-continuity.ts
41748
- import { readFileSync as readFileSync9, unlinkSync as unlinkSync3, existsSync as existsSync14, writeFileSync as writeFileSync6, renameSync as renameSync2 } from "node:fs";
41749
- import { dirname as dirname7, join as join14 } from "node:path";
41709
+ import { readFileSync as readFileSync9, unlinkSync as unlinkSync2, existsSync as existsSync13, writeFileSync as writeFileSync6, renameSync as renameSync2 } from "node:fs";
41710
+ import { dirname as dirname7, join as join13 } from "node:path";
41750
41711
  var TOPIC_DISPLAY_MAX = 117;
41751
41712
  var HANDOFF_TOPIC_FILENAME = ".handoff-topic";
41752
41713
  var LAST_TURN_SUMMARY_FILENAME = ".last-turn-summary";
@@ -41757,8 +41718,8 @@ function resolveAgentDirFromEnv() {
41757
41718
  return dirname7(state3);
41758
41719
  }
41759
41720
  function readHandoffTopic(agentDir) {
41760
- const p = join14(agentDir, HANDOFF_TOPIC_FILENAME);
41761
- if (!existsSync14(p))
41721
+ const p = join13(agentDir, HANDOFF_TOPIC_FILENAME);
41722
+ if (!existsSync13(p))
41762
41723
  return null;
41763
41724
  let raw;
41764
41725
  try {
@@ -41776,8 +41737,8 @@ function readHandoffTopic(agentDir) {
41776
41737
  return topic;
41777
41738
  }
41778
41739
  function readLastTurnSummary(agentDir) {
41779
- const p = join14(agentDir, LAST_TURN_SUMMARY_FILENAME);
41780
- if (!existsSync14(p))
41740
+ const p = join13(agentDir, LAST_TURN_SUMMARY_FILENAME);
41741
+ if (!existsSync13(p))
41781
41742
  return null;
41782
41743
  let raw;
41783
41744
  try {
@@ -41796,16 +41757,16 @@ function readLastTurnSummary(agentDir) {
41796
41757
  }
41797
41758
  function consumeHandoffTopic(agentDir) {
41798
41759
  const primary = readHandoffTopic(agentDir);
41799
- const primaryPath = join14(agentDir, HANDOFF_TOPIC_FILENAME);
41800
- const fallbackPath = join14(agentDir, LAST_TURN_SUMMARY_FILENAME);
41760
+ const primaryPath = join13(agentDir, HANDOFF_TOPIC_FILENAME);
41761
+ const fallbackPath = join13(agentDir, LAST_TURN_SUMMARY_FILENAME);
41801
41762
  const removeFallback = () => {
41802
41763
  try {
41803
- unlinkSync3(fallbackPath);
41764
+ unlinkSync2(fallbackPath);
41804
41765
  } catch {}
41805
41766
  };
41806
41767
  if (primary !== null) {
41807
41768
  try {
41808
- unlinkSync3(primaryPath);
41769
+ unlinkSync2(primaryPath);
41809
41770
  } catch {}
41810
41771
  removeFallback();
41811
41772
  return primary;
@@ -41850,15 +41811,15 @@ function escapeMarkdownV2(s) {
41850
41811
  }
41851
41812
 
41852
41813
  // active-reactions.ts
41853
- import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, renameSync as renameSync3, existsSync as existsSync15, unlinkSync as unlinkSync4 } from "node:fs";
41854
- import { join as join15 } from "node:path";
41814
+ import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, renameSync as renameSync3, existsSync as existsSync14, unlinkSync as unlinkSync3 } from "node:fs";
41815
+ import { join as join14 } from "node:path";
41855
41816
  var ACTIVE_REACTIONS_FILENAME = ".active-reactions.json";
41856
41817
  function reactionsPath(agentDir) {
41857
- return join15(agentDir, ACTIVE_REACTIONS_FILENAME);
41818
+ return join14(agentDir, ACTIVE_REACTIONS_FILENAME);
41858
41819
  }
41859
41820
  function readActiveReactions(agentDir) {
41860
41821
  const p = reactionsPath(agentDir);
41861
- if (!existsSync15(p))
41822
+ if (!existsSync14(p))
41862
41823
  return [];
41863
41824
  let raw;
41864
41825
  try {
@@ -41888,7 +41849,7 @@ function writeActiveReactions(agentDir, reactions) {
41888
41849
  const p = reactionsPath(agentDir);
41889
41850
  if (reactions.length === 0) {
41890
41851
  try {
41891
- unlinkSync4(p);
41852
+ unlinkSync3(p);
41892
41853
  } catch {}
41893
41854
  return;
41894
41855
  }
@@ -41913,20 +41874,20 @@ function removeActiveReaction(agentDir, chatId, messageId) {
41913
41874
  }
41914
41875
  function clearActiveReactions(agentDir) {
41915
41876
  try {
41916
- unlinkSync4(reactionsPath(agentDir));
41877
+ unlinkSync3(reactionsPath(agentDir));
41917
41878
  } catch {}
41918
41879
  }
41919
41880
 
41920
41881
  // active-reactions.ts
41921
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync8, renameSync as renameSync4, existsSync as existsSync16, unlinkSync as unlinkSync5 } from "node:fs";
41922
- import { join as join16 } from "node:path";
41882
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync8, renameSync as renameSync4, existsSync as existsSync15, unlinkSync as unlinkSync4 } from "node:fs";
41883
+ import { join as join15 } from "node:path";
41923
41884
  var ACTIVE_REACTIONS_FILENAME2 = ".active-reactions.json";
41924
41885
  function reactionsPath2(agentDir) {
41925
- return join16(agentDir, ACTIVE_REACTIONS_FILENAME2);
41886
+ return join15(agentDir, ACTIVE_REACTIONS_FILENAME2);
41926
41887
  }
41927
41888
  function readActiveReactions2(agentDir) {
41928
41889
  const p = reactionsPath2(agentDir);
41929
- if (!existsSync16(p))
41890
+ if (!existsSync15(p))
41930
41891
  return [];
41931
41892
  let raw;
41932
41893
  try {
@@ -41954,7 +41915,7 @@ function readActiveReactions2(agentDir) {
41954
41915
  }
41955
41916
  function clearActiveReactions2(agentDir) {
41956
41917
  try {
41957
- unlinkSync5(reactionsPath2(agentDir));
41918
+ unlinkSync4(reactionsPath2(agentDir));
41958
41919
  } catch {}
41959
41920
  }
41960
41921
 
@@ -42807,14 +42768,14 @@ async function approvalRecord(args, opts) {
42807
42768
  }
42808
42769
 
42809
42770
  // quota-check.ts
42810
- import { readFileSync as readFileSync13, existsSync as existsSync18 } from "fs";
42811
- import { join as join18 } from "path";
42771
+ import { readFileSync as readFileSync13, existsSync as existsSync17 } from "fs";
42772
+ import { join as join17 } from "path";
42812
42773
  var OAUTH_BETA2 = "oauth-2025-04-20";
42813
42774
  var DEFAULT_USER_AGENT2 = "claude-cli/1.0.0 (external, cli)";
42814
42775
  var DEFAULT_PROBE_MODEL2 = "claude-haiku-4-5-20251001";
42815
42776
  function readOauthToken2(claudeConfigDir) {
42816
- const tokenFile = join18(claudeConfigDir, ".oauth-token");
42817
- if (!existsSync18(tokenFile))
42777
+ const tokenFile = join17(claudeConfigDir, ".oauth-token");
42778
+ if (!existsSync17(tokenFile))
42818
42779
  return null;
42819
42780
  try {
42820
42781
  const raw = readFileSync13(tokenFile, "utf-8").trim();
@@ -43413,7 +43374,7 @@ init_schema();
43413
43374
  init_paths();
43414
43375
  init_overlay_loader();
43415
43376
  init_merge();
43416
- import { readFileSync as readFileSync14, existsSync as existsSync19 } from "node:fs";
43377
+ import { readFileSync as readFileSync14, existsSync as existsSync18 } from "node:fs";
43417
43378
  import { homedir as homedir8 } from "node:os";
43418
43379
  import { resolve as resolve5 } from "node:path";
43419
43380
 
@@ -43489,7 +43450,7 @@ function findConfigFile2(startDir) {
43489
43450
  resolve5(userDir, "clerk.yml")
43490
43451
  ].filter(Boolean);
43491
43452
  for (const path of searchPaths) {
43492
- if (existsSync19(path)) {
43453
+ if (existsSync18(path)) {
43493
43454
  return path;
43494
43455
  }
43495
43456
  }
@@ -43497,7 +43458,7 @@ function findConfigFile2(startDir) {
43497
43458
  }
43498
43459
  function loadConfig2(configPath) {
43499
43460
  const filePath = configPath ?? findConfigFile2();
43500
- if (!existsSync19(filePath)) {
43461
+ if (!existsSync18(filePath)) {
43501
43462
  throw new ConfigError2(`Config file not found: ${filePath}`);
43502
43463
  }
43503
43464
  let raw;
@@ -43930,9 +43891,9 @@ function resolveOutboundTopic(config, event) {
43930
43891
  }
43931
43892
 
43932
43893
  // ../src/agents/perf.ts
43933
- import { existsSync as existsSync20, readFileSync as readFileSync15 } from "node:fs";
43894
+ import { existsSync as existsSync19, readFileSync as readFileSync15 } from "node:fs";
43934
43895
  function readTurnUsages(jsonlPath, lastN) {
43935
- if (!existsSync20(jsonlPath))
43896
+ if (!existsSync19(jsonlPath))
43936
43897
  return [];
43937
43898
  if (lastN <= 0)
43938
43899
  return [];
@@ -44076,7 +44037,7 @@ function nextCompactNotify(state3, ev) {
44076
44037
  }
44077
44038
 
44078
44039
  // gateway/hostd-dispatch.ts
44079
- import { existsSync as existsSync21 } from "node:fs";
44040
+ import { existsSync as existsSync20 } from "node:fs";
44080
44041
  import { randomBytes as randomBytes3 } from "node:crypto";
44081
44042
 
44082
44043
  // ../src/host-control/client.ts
@@ -44367,13 +44328,13 @@ function hostdSocketPath(agentName3) {
44367
44328
  function hostdWillBeUsed(agentName3) {
44368
44329
  if (!isHostdEnabled())
44369
44330
  return false;
44370
- return existsSync21(hostdSocketPath(agentName3));
44331
+ return existsSync20(hostdSocketPath(agentName3));
44371
44332
  }
44372
44333
  async function tryHostdDispatch(agentName3, req) {
44373
44334
  if (!isHostdEnabled())
44374
44335
  return "not-configured";
44375
44336
  const sockPath = hostdSocketPath(agentName3);
44376
- if (!existsSync21(sockPath))
44337
+ if (!existsSync20(sockPath))
44377
44338
  return "not-configured";
44378
44339
  try {
44379
44340
  return await hostdRequest({ socketPath: sockPath, timeoutMs: 5000 }, req);
@@ -44397,7 +44358,7 @@ async function hostdGetStatusOnce(agentName3, targetRequestId) {
44397
44358
  if (!isHostdEnabled())
44398
44359
  return "not-configured";
44399
44360
  const sockPath = hostdSocketPath(agentName3);
44400
- if (!existsSync21(sockPath))
44361
+ if (!existsSync20(sockPath))
44401
44362
  return "not-configured";
44402
44363
  try {
44403
44364
  const resp = await hostdRequest({ socketPath: sockPath, timeoutMs: 3000 }, {
@@ -44418,7 +44379,7 @@ async function pollHostdStatus(agentName3, targetRequestId, opts) {
44418
44379
  if (!isHostdEnabled())
44419
44380
  return "not-configured";
44420
44381
  const sockPath = hostdSocketPath(agentName3);
44421
- if (!existsSync21(sockPath))
44382
+ if (!existsSync20(sockPath))
44422
44383
  return "not-configured";
44423
44384
  const now = opts.now ?? Date.now;
44424
44385
  const sleep2 = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
@@ -44496,7 +44457,7 @@ function shouldSweepChatAtBoot(chatId) {
44496
44457
  }
44497
44458
 
44498
44459
  // gateway/ipc-server.ts
44499
- import { renameSync as renameSync5, unlinkSync as unlinkSync6 } from "fs";
44460
+ import { renameSync as renameSync5, unlinkSync as unlinkSync5 } from "fs";
44500
44461
  var MAX_BUFFER_SIZE = 1024 * 1024;
44501
44462
  var VALID_OPERATOR_KINDS = new Set([
44502
44463
  "credentials-expired",
@@ -44614,7 +44575,7 @@ function createIpcServer(options) {
44614
44575
  renameSync5(socketPath, socketPath + ".bak");
44615
44576
  } catch {}
44616
44577
  try {
44617
- unlinkSync6(socketPath + ".bak");
44578
+ unlinkSync5(socketPath + ".bak");
44618
44579
  } catch {}
44619
44580
  const clients = new Set;
44620
44581
  const agentIndex = new Map;
@@ -46677,7 +46638,7 @@ function escapeBody(s) {
46677
46638
  }
46678
46639
 
46679
46640
  // gateway/pid-file.ts
46680
- import { writeFileSync as writeFileSync9, readFileSync as readFileSync16, unlinkSync as unlinkSync7, renameSync as renameSync6 } from "node:fs";
46641
+ import { writeFileSync as writeFileSync9, readFileSync as readFileSync16, unlinkSync as unlinkSync6, renameSync as renameSync6 } from "node:fs";
46681
46642
  function writePidFile(path, record) {
46682
46643
  const tmp = `${path}.tmp-${process.pid}-${Date.now()}`;
46683
46644
  writeFileSync9(tmp, JSON.stringify(record), "utf-8");
@@ -46685,7 +46646,7 @@ function writePidFile(path, record) {
46685
46646
  }
46686
46647
  function clearPidFile(path) {
46687
46648
  try {
46688
- unlinkSync7(path);
46649
+ unlinkSync6(path);
46689
46650
  } catch {}
46690
46651
  }
46691
46652
 
@@ -46902,7 +46863,7 @@ function safeCount(fn) {
46902
46863
  }
46903
46864
 
46904
46865
  // gateway/session-marker.ts
46905
- import { writeFileSync as writeFileSync10, readFileSync as readFileSync18, renameSync as renameSync7, unlinkSync as unlinkSync8 } from "node:fs";
46866
+ import { writeFileSync as writeFileSync10, readFileSync as readFileSync18, renameSync as renameSync7, unlinkSync as unlinkSync7 } from "node:fs";
46906
46867
  function writeSessionMarker(path, marker) {
46907
46868
  const tmp = `${path}.tmp-${process.pid}-${Date.now()}`;
46908
46869
  writeFileSync10(tmp, JSON.stringify(marker), "utf-8");
@@ -46932,7 +46893,7 @@ function shouldFireRestartBanner(input) {
46932
46893
  }
46933
46894
 
46934
46895
  // gateway/clean-shutdown-marker.ts
46935
- import { writeFileSync as writeFileSync11, readFileSync as readFileSync19, renameSync as renameSync8, unlinkSync as unlinkSync9 } from "node:fs";
46896
+ import { writeFileSync as writeFileSync11, readFileSync as readFileSync19, renameSync as renameSync8, unlinkSync as unlinkSync8 } from "node:fs";
46936
46897
  var DEFAULT_MAX_AGE_MS = 60000;
46937
46898
  function writeCleanShutdownMarker(path, marker) {
46938
46899
  const tmp = `${path}.tmp-${process.pid}-${Date.now()}`;
@@ -46956,7 +46917,7 @@ function readCleanShutdownMarker(path) {
46956
46917
  }
46957
46918
  function clearCleanShutdownMarker(path) {
46958
46919
  try {
46959
- unlinkSync9(path);
46920
+ unlinkSync8(path);
46960
46921
  } catch {}
46961
46922
  }
46962
46923
  function shouldSuppressRecoveryBanner(marker, now, maxAgeMs = DEFAULT_MAX_AGE_MS) {
@@ -47736,16 +47697,16 @@ function classifyAdminGate(text, myAgentName) {
47736
47697
 
47737
47698
  // subagent-watcher.ts
47738
47699
  import {
47739
- existsSync as existsSync23,
47740
- openSync as openSync3,
47700
+ existsSync as existsSync22,
47701
+ openSync as openSync2,
47741
47702
  readSync,
47742
47703
  statSync as statSync6,
47743
- closeSync as closeSync3,
47704
+ closeSync as closeSync2,
47744
47705
  watch,
47745
47706
  readdirSync as readdirSync3,
47746
47707
  readFileSync as readFileSync21
47747
47708
  } from "fs";
47748
- import { join as join20 } from "path";
47709
+ import { join as join19 } from "path";
47749
47710
 
47750
47711
  // operator-events.ts
47751
47712
  var DEFAULT_OPERATOR_EVENT_COOLDOWN_MS2 = 5 * 60000;
@@ -47987,29 +47948,29 @@ function bumpSubagentActivity(db2, args) {
47987
47948
 
47988
47949
  // gateway/turn-active-marker.ts
47989
47950
  import {
47990
- closeSync as closeSync2,
47991
- existsSync as existsSync22,
47951
+ closeSync,
47952
+ existsSync as existsSync21,
47992
47953
  mkdirSync as mkdirSync10,
47993
- openSync as openSync2,
47954
+ openSync,
47994
47955
  readFileSync as readFileSync20,
47995
47956
  statSync as statSync5,
47996
- unlinkSync as unlinkSync10,
47957
+ unlinkSync as unlinkSync9,
47997
47958
  utimesSync,
47998
47959
  writeFileSync as writeFileSync12
47999
47960
  } from "node:fs";
48000
- import { join as join19 } from "node:path";
47961
+ import { join as join18 } from "node:path";
48001
47962
  var TURN_ACTIVE_MARKER_FILE = "turn-active.json";
48002
47963
  function touchTurnActiveMarker(stateDir) {
48003
- const path = join19(stateDir, TURN_ACTIVE_MARKER_FILE);
48004
- if (!existsSync22(path))
47964
+ const path = join18(stateDir, TURN_ACTIVE_MARKER_FILE);
47965
+ if (!existsSync21(path))
48005
47966
  return;
48006
47967
  const now = new Date;
48007
47968
  try {
48008
47969
  utimesSync(path, now, now);
48009
47970
  } catch {
48010
47971
  try {
48011
- const fd = openSync2(path, "r+");
48012
- closeSync2(fd);
47972
+ const fd = openSync(path, "r+");
47973
+ closeSync(fd);
48013
47974
  } catch {}
48014
47975
  }
48015
47976
  }
@@ -48223,11 +48184,11 @@ function startSubagentWatcher(config) {
48223
48184
  clearTimeout(ref.ref);
48224
48185
  });
48225
48186
  const fs2 = config.fs ?? {
48226
- existsSync: existsSync23,
48187
+ existsSync: existsSync22,
48227
48188
  readdirSync: readdirSync3,
48228
48189
  statSync: statSync6,
48229
- openSync: openSync3,
48230
- closeSync: closeSync3,
48190
+ openSync: openSync2,
48191
+ closeSync: closeSync2,
48231
48192
  readSync,
48232
48193
  watch
48233
48194
  };
@@ -48457,8 +48418,8 @@ function startSubagentWatcher(config) {
48457
48418
  function rescanSubagentDirs() {
48458
48419
  if (stopped)
48459
48420
  return;
48460
- const claudeHome = join20(agentDir, ".claude");
48461
- const projectsRoot = join20(claudeHome, "projects");
48421
+ const claudeHome = join19(agentDir, ".claude");
48422
+ const projectsRoot = join19(claudeHome, "projects");
48462
48423
  if (!fs2.existsSync(projectsRoot))
48463
48424
  return;
48464
48425
  let projectDirs;
@@ -48475,7 +48436,7 @@ function startSubagentWatcher(config) {
48475
48436
  }
48476
48437
  continue;
48477
48438
  }
48478
- const projectPath = join20(projectsRoot, pDir);
48439
+ const projectPath = join19(projectsRoot, pDir);
48479
48440
  let sessionDirs;
48480
48441
  try {
48481
48442
  sessionDirs = fs2.readdirSync(projectPath);
@@ -48485,7 +48446,7 @@ function startSubagentWatcher(config) {
48485
48446
  for (const sDir of sessionDirs) {
48486
48447
  if (sDir.endsWith(".jsonl"))
48487
48448
  continue;
48488
- const subagentsPath = join20(projectPath, sDir, "subagents");
48449
+ const subagentsPath = join19(projectPath, sDir, "subagents");
48489
48450
  if (!fs2.existsSync(subagentsPath))
48490
48451
  continue;
48491
48452
  if (!dirWatchers.has(subagentsPath)) {
@@ -48493,7 +48454,7 @@ function startSubagentWatcher(config) {
48493
48454
  const w = fs2.watch(subagentsPath, (_event, filename) => {
48494
48455
  if (!filename || !filename.toString().startsWith("agent-") || !filename.toString().endsWith(".jsonl"))
48495
48456
  return;
48496
- const filePath = join20(subagentsPath, filename.toString());
48457
+ const filePath = join19(subagentsPath, filename.toString());
48497
48458
  if (!knownFiles.has(filePath)) {
48498
48459
  scanSubagentsDir(subagentsPath);
48499
48460
  }
@@ -48518,7 +48479,7 @@ function startSubagentWatcher(config) {
48518
48479
  for (const e of entries) {
48519
48480
  if (!e.startsWith("agent-") || !e.endsWith(".jsonl"))
48520
48481
  continue;
48521
- const filePath = join20(subagentsPath, e);
48482
+ const filePath = join19(subagentsPath, e);
48522
48483
  if (knownFiles.has(filePath))
48523
48484
  continue;
48524
48485
  const agentId = e.slice("agent-".length, -".jsonl".length);
@@ -48635,15 +48596,15 @@ function determineRestartReason(opts) {
48635
48596
  init_boot_card();
48636
48597
 
48637
48598
  // gateway/update-announce.ts
48638
- import { existsSync as existsSync27, mkdirSync as mkdirSync13, openSync as openSync4, closeSync as closeSync4, readFileSync as readFileSync25 } from "node:fs";
48639
- import { join as join25 } from "node:path";
48599
+ import { existsSync as existsSync26, mkdirSync as mkdirSync13, openSync as openSync3, closeSync as closeSync3, readFileSync as readFileSync25 } from "node:fs";
48600
+ import { join as join24 } from "node:path";
48640
48601
  import { homedir as homedir10 } from "node:os";
48641
48602
 
48642
48603
  // ../src/host-control/audit-reader.ts
48643
48604
  import { homedir as homedir9 } from "node:os";
48644
- import { join as join24 } from "node:path";
48605
+ import { join as join23 } from "node:path";
48645
48606
  function defaultAuditLogPath(home2 = homedir9()) {
48646
- return join24(home2, ".switchroom", "host-control-audit.log");
48607
+ return join23(home2, ".switchroom", "host-control-audit.log");
48647
48608
  }
48648
48609
  function parseAuditLine(line) {
48649
48610
  const trimmed = line.trim();
@@ -48749,7 +48710,7 @@ function readAndFilter(raw, filters, limit) {
48749
48710
  var DEFAULT_LOOKBACK_MS = 10 * 60 * 1000;
48750
48711
  function readLastTerminalUpdateAudit(opts = {}) {
48751
48712
  const path = opts.auditLogPath ?? defaultAuditLogPath();
48752
- const exists = opts.exists ?? existsSync27;
48713
+ const exists = opts.exists ?? existsSync26;
48753
48714
  const readFile = opts.readFile ?? ((p) => readFileSync25(p, "utf-8"));
48754
48715
  if (!exists(path))
48755
48716
  return null;
@@ -48811,18 +48772,18 @@ function renderUpdateOutcomeLine(entry) {
48811
48772
  `);
48812
48773
  }
48813
48774
  function claimUpdateAnnouncement(requestId, opts = {}) {
48814
- const stateDir = opts.stateDir ?? process.env.TELEGRAM_STATE_DIR ?? join25(homedir10(), ".switchroom");
48815
- const dir = join25(stateDir, "update-announced");
48775
+ const stateDir = opts.stateDir ?? process.env.TELEGRAM_STATE_DIR ?? join24(homedir10(), ".switchroom");
48776
+ const dir = join24(stateDir, "update-announced");
48816
48777
  try {
48817
48778
  mkdirSync13(dir, { recursive: true });
48818
48779
  } catch {
48819
48780
  return false;
48820
48781
  }
48821
48782
  const safeId = requestId.replace(/[^A-Za-z0-9_.-]/g, "_").slice(0, 200);
48822
- const path = join25(dir, safeId);
48783
+ const path = join24(dir, safeId);
48823
48784
  try {
48824
- const fd = openSync4(path, "wx");
48825
- closeSync4(fd);
48785
+ const fd = openSync3(path, "wx");
48786
+ closeSync3(fd);
48826
48787
  return true;
48827
48788
  } catch {
48828
48789
  return false;
@@ -49039,24 +49000,24 @@ function createIssuesCardHandle(opts) {
49039
49000
  }
49040
49001
 
49041
49002
  // issues-watcher.ts
49042
- import { existsSync as existsSync29, statSync as statSync8 } from "node:fs";
49043
- import { join as join27 } from "node:path";
49003
+ import { existsSync as existsSync28, statSync as statSync8 } from "node:fs";
49004
+ import { join as join26 } from "node:path";
49044
49005
 
49045
49006
  // ../src/issues/store.ts
49046
49007
  import {
49047
- closeSync as closeSync5,
49048
- existsSync as existsSync28,
49008
+ closeSync as closeSync4,
49009
+ existsSync as existsSync27,
49049
49010
  mkdirSync as mkdirSync14,
49050
- openSync as openSync5,
49011
+ openSync as openSync4,
49051
49012
  readdirSync as readdirSync5,
49052
49013
  readFileSync as readFileSync27,
49053
49014
  renameSync as renameSync10,
49054
49015
  statSync as statSync7,
49055
- unlinkSync as unlinkSync11,
49016
+ unlinkSync as unlinkSync10,
49056
49017
  writeFileSync as writeFileSync16,
49057
49018
  writeSync
49058
49019
  } from "node:fs";
49059
- import { join as join26 } from "node:path";
49020
+ import { join as join25 } from "node:path";
49060
49021
  import { randomBytes as randomBytes4 } from "node:crypto";
49061
49022
  import { execSync } from "node:child_process";
49062
49023
 
@@ -49072,8 +49033,8 @@ var SEVERITY_RANK2 = {
49072
49033
  var ISSUES_FILE = "issues.jsonl";
49073
49034
  var ISSUES_LOCK = "issues.lock";
49074
49035
  function readAll(stateDir) {
49075
- const path = join26(stateDir, ISSUES_FILE);
49076
- if (!existsSync28(path))
49036
+ const path = join25(stateDir, ISSUES_FILE);
49037
+ if (!existsSync27(path))
49077
49038
  return [];
49078
49039
  let raw;
49079
49040
  try {
@@ -49109,7 +49070,7 @@ function list(stateDir, opts = {}) {
49109
49070
  });
49110
49071
  }
49111
49072
  function resolve6(stateDir, fingerprint, nowFn = Date.now) {
49112
- if (!existsSync28(join26(stateDir, ISSUES_FILE)))
49073
+ if (!existsSync27(join25(stateDir, ISSUES_FILE)))
49113
49074
  return 0;
49114
49075
  return withLock(stateDir, () => {
49115
49076
  const all = readAll(stateDir);
@@ -49127,7 +49088,7 @@ function resolve6(stateDir, fingerprint, nowFn = Date.now) {
49127
49088
  });
49128
49089
  }
49129
49090
  function writeAll(stateDir, events) {
49130
- const path = join26(stateDir, ISSUES_FILE);
49091
+ const path = join25(stateDir, ISSUES_FILE);
49131
49092
  sweepOrphanTmpFiles(stateDir);
49132
49093
  const tmp = `${path}.tmp-${process.pid}-${randomBytes4(4).toString("hex")}`;
49133
49094
  const body = events.length === 0 ? "" : events.map((e) => JSON.stringify(e)).join(`
@@ -49149,11 +49110,11 @@ function sweepOrphanTmpFiles(stateDir) {
49149
49110
  for (const entry of entries) {
49150
49111
  if (!entry.startsWith(TMP_PREFIX))
49151
49112
  continue;
49152
- const tmpPath2 = join26(stateDir, entry);
49113
+ const tmpPath2 = join25(stateDir, entry);
49153
49114
  try {
49154
49115
  const stat = statSync7(tmpPath2);
49155
49116
  if (stat.mtimeMs < cutoff) {
49156
- unlinkSync11(tmpPath2);
49117
+ unlinkSync10(tmpPath2);
49157
49118
  }
49158
49119
  } catch {}
49159
49120
  }
@@ -49161,12 +49122,12 @@ function sweepOrphanTmpFiles(stateDir) {
49161
49122
  var LOCK_RETRY_MS = 25;
49162
49123
  var LOCK_TIMEOUT_MS = 1e4;
49163
49124
  function withLock(stateDir, fn) {
49164
- const lockPath = join26(stateDir, ISSUES_LOCK);
49125
+ const lockPath = join25(stateDir, ISSUES_LOCK);
49165
49126
  const startedAt = Date.now();
49166
49127
  let fd = null;
49167
49128
  while (fd === null) {
49168
49129
  try {
49169
- fd = openSync5(lockPath, "wx");
49130
+ fd = openSync4(lockPath, "wx");
49170
49131
  try {
49171
49132
  writeSync(fd, String(process.pid));
49172
49133
  } catch {}
@@ -49186,10 +49147,10 @@ function withLock(stateDir, fn) {
49186
49147
  return fn();
49187
49148
  } finally {
49188
49149
  try {
49189
- closeSync5(fd);
49150
+ closeSync4(fd);
49190
49151
  } catch {}
49191
49152
  try {
49192
- unlinkSync11(lockPath);
49153
+ unlinkSync10(lockPath);
49193
49154
  } catch {}
49194
49155
  }
49195
49156
  }
@@ -49203,13 +49164,13 @@ function tryStealStaleLock(lockPath) {
49203
49164
  const pid = Number(pidStr);
49204
49165
  if (!Number.isFinite(pid) || pid <= 0) {
49205
49166
  try {
49206
- unlinkSync11(lockPath);
49167
+ unlinkSync10(lockPath);
49207
49168
  } catch {}
49208
49169
  return true;
49209
49170
  }
49210
49171
  if (pid === process.pid) {
49211
49172
  try {
49212
- unlinkSync11(lockPath);
49173
+ unlinkSync10(lockPath);
49213
49174
  } catch {}
49214
49175
  return true;
49215
49176
  }
@@ -49224,7 +49185,7 @@ function tryStealStaleLock(lockPath) {
49224
49185
  return false;
49225
49186
  }
49226
49187
  try {
49227
- unlinkSync11(lockPath);
49188
+ unlinkSync10(lockPath);
49228
49189
  } catch {}
49229
49190
  return true;
49230
49191
  }
@@ -49246,7 +49207,7 @@ function isIssueEvent(v) {
49246
49207
  // issues-watcher.ts
49247
49208
  var DEFAULT_POLL_INTERVAL_MS2 = 2000;
49248
49209
  function startIssuesWatcher(opts) {
49249
- const path = join27(opts.stateDir, ISSUES_FILE);
49210
+ const path = join26(opts.stateDir, ISSUES_FILE);
49250
49211
  const log = opts.log ?? (() => {});
49251
49212
  const intervalMs = opts.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS2;
49252
49213
  const setIntervalFn = opts.setInterval ?? setInterval;
@@ -49294,7 +49255,7 @@ function startIssuesWatcher(opts) {
49294
49255
  };
49295
49256
  }
49296
49257
  function defaultSignatureProvider(path) {
49297
- if (!existsSync29(path))
49258
+ if (!existsSync28(path))
49298
49259
  return null;
49299
49260
  try {
49300
49261
  const stat = statSync8(path);
@@ -49534,8 +49495,8 @@ function skillBasenameFromPath2(input) {
49534
49495
  }
49535
49496
 
49536
49497
  // credits-watch.ts
49537
- import { readFileSync as readFileSync28, writeFileSync as writeFileSync17, existsSync as existsSync30, mkdirSync as mkdirSync15 } from "fs";
49538
- import { join as join28 } from "path";
49498
+ import { readFileSync as readFileSync28, writeFileSync as writeFileSync17, existsSync as existsSync29, mkdirSync as mkdirSync15 } from "fs";
49499
+ import { join as join27 } from "path";
49539
49500
  var STATE_FILE = "credits-watch.json";
49540
49501
  var FATAL_REASONS = new Set([
49541
49502
  "out_of_credits",
@@ -49547,8 +49508,8 @@ function emptyCreditState() {
49547
49508
  return { lastNotifiedReason: null, lastNotifiedAt: 0 };
49548
49509
  }
49549
49510
  function readClaudeJsonOverage(claudeConfigDir) {
49550
- const path = join28(claudeConfigDir, ".claude.json");
49551
- if (!existsSync30(path))
49511
+ const path = join27(claudeConfigDir, ".claude.json");
49512
+ if (!existsSync29(path))
49552
49513
  return null;
49553
49514
  let raw;
49554
49515
  try {
@@ -49632,8 +49593,8 @@ function escapeHtml10(s) {
49632
49593
  return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
49633
49594
  }
49634
49595
  function loadCreditState(stateDir) {
49635
- const path = join28(stateDir, STATE_FILE);
49636
- if (!existsSync30(path))
49596
+ const path = join27(stateDir, STATE_FILE);
49597
+ if (!existsSync29(path))
49637
49598
  return emptyCreditState();
49638
49599
  try {
49639
49600
  const raw = readFileSync28(path, "utf-8");
@@ -49649,54 +49610,54 @@ function loadCreditState(stateDir) {
49649
49610
  }
49650
49611
  function saveCreditState(stateDir, state4) {
49651
49612
  mkdirSync15(stateDir, { recursive: true });
49652
- const path = join28(stateDir, STATE_FILE);
49613
+ const path = join27(stateDir, STATE_FILE);
49653
49614
  writeFileSync17(path, JSON.stringify(state4, null, 2) + `
49654
49615
  `, { mode: 384 });
49655
49616
  }
49656
49617
 
49657
49618
  // gateway/turn-active-marker.ts
49658
49619
  import {
49659
- closeSync as closeSync6,
49660
- existsSync as existsSync31,
49620
+ closeSync as closeSync5,
49621
+ existsSync as existsSync30,
49661
49622
  mkdirSync as mkdirSync16,
49662
- openSync as openSync6,
49623
+ openSync as openSync5,
49663
49624
  readFileSync as readFileSync29,
49664
49625
  statSync as statSync9,
49665
- unlinkSync as unlinkSync12,
49626
+ unlinkSync as unlinkSync11,
49666
49627
  utimesSync as utimesSync2,
49667
49628
  writeFileSync as writeFileSync18
49668
49629
  } from "node:fs";
49669
- import { join as join29 } from "node:path";
49630
+ import { join as join28 } from "node:path";
49670
49631
  var TURN_ACTIVE_MARKER_FILE2 = "turn-active.json";
49671
49632
  function writeTurnActiveMarker(stateDir, marker) {
49672
49633
  try {
49673
49634
  mkdirSync16(stateDir, { recursive: true });
49674
- writeFileSync18(join29(stateDir, TURN_ACTIVE_MARKER_FILE2), JSON.stringify(marker, null, 2) + `
49635
+ writeFileSync18(join28(stateDir, TURN_ACTIVE_MARKER_FILE2), JSON.stringify(marker, null, 2) + `
49675
49636
  `, { mode: 384 });
49676
49637
  } catch {}
49677
49638
  }
49678
49639
  function touchTurnActiveMarker2(stateDir) {
49679
- const path = join29(stateDir, TURN_ACTIVE_MARKER_FILE2);
49680
- if (!existsSync31(path))
49640
+ const path = join28(stateDir, TURN_ACTIVE_MARKER_FILE2);
49641
+ if (!existsSync30(path))
49681
49642
  return;
49682
49643
  const now = new Date;
49683
49644
  try {
49684
49645
  utimesSync2(path, now, now);
49685
49646
  } catch {
49686
49647
  try {
49687
- const fd = openSync6(path, "r+");
49688
- closeSync6(fd);
49648
+ const fd = openSync5(path, "r+");
49649
+ closeSync5(fd);
49689
49650
  } catch {}
49690
49651
  }
49691
49652
  }
49692
49653
  function removeTurnActiveMarker(stateDir) {
49693
49654
  try {
49694
- unlinkSync12(join29(stateDir, TURN_ACTIVE_MARKER_FILE2));
49655
+ unlinkSync11(join28(stateDir, TURN_ACTIVE_MARKER_FILE2));
49695
49656
  } catch {}
49696
49657
  }
49697
49658
  function sweepStaleTurnActiveMarker(stateDir, opts) {
49698
- const path = join29(stateDir, TURN_ACTIVE_MARKER_FILE2);
49699
- if (!existsSync31(path))
49659
+ const path = join28(stateDir, TURN_ACTIVE_MARKER_FILE2);
49660
+ if (!existsSync30(path))
49700
49661
  return false;
49701
49662
  const now = opts.now ?? Date.now();
49702
49663
  try {
@@ -49710,7 +49671,7 @@ function sweepStaleTurnActiveMarker(stateDir, opts) {
49710
49671
  try {
49711
49672
  payload = readFileSync29(path, "utf8");
49712
49673
  } catch {}
49713
- unlinkSync12(path);
49674
+ unlinkSync11(path);
49714
49675
  if (opts.onRemove) {
49715
49676
  try {
49716
49677
  opts.onRemove({
@@ -49727,10 +49688,10 @@ function sweepStaleTurnActiveMarker(stateDir, opts) {
49727
49688
  }
49728
49689
 
49729
49690
  // ../src/build-info.ts
49730
- var VERSION = "0.13.58";
49731
- var COMMIT_SHA = "20818078";
49732
- var COMMIT_DATE = "2026-05-27T22:11:23Z";
49733
- var LATEST_PR = 1928;
49691
+ var VERSION = "0.13.59";
49692
+ var COMMIT_SHA = "0f0b953e";
49693
+ var COMMIT_DATE = "2026-05-28T00:31:56Z";
49694
+ var LATEST_PR = 1936;
49734
49695
  var COMMITS_AHEAD_OF_TAG = 0;
49735
49696
 
49736
49697
  // gateway/boot-version.ts
@@ -49804,11 +49765,11 @@ init_peercred();
49804
49765
  import * as net4 from "node:net";
49805
49766
  import * as fs2 from "node:fs";
49806
49767
  import { homedir as homedir11 } from "node:os";
49807
- import { join as join30 } from "node:path";
49768
+ import { join as join29 } from "node:path";
49808
49769
  var DEFAULT_TIMEOUT_MS4 = 2000;
49809
49770
  var UNLOCK_TIMEOUT_MS = 30000;
49810
- var LEGACY_SOCKET_PATH2 = join30(homedir11(), ".switchroom", "vault-broker.sock");
49811
- var OPERATOR_SOCKET_PATH2 = join30(homedir11(), ".switchroom", "broker-operator", "sock");
49771
+ var LEGACY_SOCKET_PATH2 = join29(homedir11(), ".switchroom", "vault-broker.sock");
49772
+ var OPERATOR_SOCKET_PATH2 = join29(homedir11(), ".switchroom", "broker-operator", "sock");
49812
49773
  function defaultBrokerSocketPath2() {
49813
49774
  if (fs2.existsSync(OPERATOR_SOCKET_PATH2))
49814
49775
  return OPERATOR_SOCKET_PATH2;
@@ -50031,7 +49992,7 @@ function resolveVaultApprovalPosture(broker) {
50031
49992
 
50032
49993
  // registry/turns-schema.ts
50033
49994
  import { chmodSync as chmodSync3, mkdirSync as mkdirSync17 } from "fs";
50034
- import { join as join31 } from "path";
49995
+ import { join as join30 } from "path";
50035
49996
  var DatabaseClass2 = null;
50036
49997
  function loadDatabaseClass2() {
50037
49998
  if (DatabaseClass2 != null)
@@ -50090,9 +50051,9 @@ function applySchema(db2) {
50090
50051
  }
50091
50052
  function openTurnsDb(agentDir) {
50092
50053
  const Database = loadDatabaseClass2();
50093
- const dir = join31(agentDir, "telegram");
50054
+ const dir = join30(agentDir, "telegram");
50094
50055
  mkdirSync17(dir, { recursive: true, mode: 448 });
50095
- const path = join31(dir, "registry.db");
50056
+ const path = join30(dir, "registry.db");
50096
50057
  const db2 = new Database(path, { create: true });
50097
50058
  applySchema(db2);
50098
50059
  try {
@@ -50233,11 +50194,11 @@ installGlobalErrorHandlers();
50233
50194
  process.on("beforeExit", () => {
50234
50195
  shutdownAnalytics();
50235
50196
  });
50236
- var STATE_DIR = process.env.TELEGRAM_STATE_DIR ?? join33(homedir12(), ".claude", "channels", "telegram");
50237
- var ACCESS_FILE = join33(STATE_DIR, "access.json");
50238
- var APPROVED_DIR = join33(STATE_DIR, "approved");
50239
- var ENV_FILE = join33(STATE_DIR, ".env");
50240
- var INBOX_DIR = join33(STATE_DIR, "inbox");
50197
+ var STATE_DIR = process.env.TELEGRAM_STATE_DIR ?? join32(homedir12(), ".claude", "channels", "telegram");
50198
+ var ACCESS_FILE = join32(STATE_DIR, "access.json");
50199
+ var APPROVED_DIR = join32(STATE_DIR, "approved");
50200
+ var ENV_FILE = join32(STATE_DIR, ".env");
50201
+ var INBOX_DIR = join32(STATE_DIR, "inbox");
50241
50202
  function triggerSelfRestart(targetAgent, reason, delayMs = 300) {
50242
50203
  const isDocker = process.env.SWITCHROOM_RUNTIME === "docker";
50243
50204
  const selfAgent = process.env.SWITCHROOM_AGENT_NAME;
@@ -50428,7 +50389,7 @@ function assertSendable(f) {
50428
50389
  } catch {
50429
50390
  throw new Error(`refusing to send file \u2014 cannot resolve real path: ${f}`);
50430
50391
  }
50431
- const inbox = join33(stateReal, "inbox");
50392
+ const inbox = join32(stateReal, "inbox");
50432
50393
  if (real.startsWith(stateReal + sep3) && !real.startsWith(inbox + sep3)) {
50433
50394
  throw new Error(`refusing to send channel state: ${f}`);
50434
50395
  }
@@ -50534,7 +50495,7 @@ var HISTORY_ENABLED = HISTORY_ACCESS.historyEnabled !== false;
50534
50495
  if (HISTORY_ENABLED) {
50535
50496
  try {
50536
50497
  initHistory(STATE_DIR, HISTORY_ACCESS.historyRetentionDays ?? 30);
50537
- process.stderr.write(`telegram gateway: history capture enabled at ${join33(STATE_DIR, "history.db")}
50498
+ process.stderr.write(`telegram gateway: history capture enabled at ${join32(STATE_DIR, "history.db")}
50538
50499
  `);
50539
50500
  } catch (err) {
50540
50501
  process.stderr.write(`telegram gateway: history init failed (${err.message}) \u2014 capture disabled
@@ -50551,10 +50512,10 @@ try {
50551
50512
  process.stderr.write(`telegram gateway: turn-registry boot-reaper stamped ${reaped} orphaned turn(s) as ended_via='restart'
50552
50513
  `);
50553
50514
  } else {
50554
- process.stderr.write(`telegram gateway: turn-registry initialized at ${join33(agentDir, "telegram", "registry.db")}
50515
+ process.stderr.write(`telegram gateway: turn-registry initialized at ${join32(agentDir, "telegram", "registry.db")}
50555
50516
  `);
50556
50517
  }
50557
- const pendingEnvPath = join33(agentDir, ".pending-turn.env");
50518
+ const pendingEnvPath = join32(agentDir, ".pending-turn.env");
50558
50519
  try {
50559
50520
  const pending2 = findMostRecentInterruptedTurn(turnsDb);
50560
50521
  if (pending2 != null) {
@@ -50574,7 +50535,7 @@ try {
50574
50535
  renameSync12(pendingEnvTmp, pendingEnvPath);
50575
50536
  process.stderr.write(`telegram gateway: pending-turn env written to ${pendingEnvPath} turnKey=${pending2.turn_key} endedVia=${pending2.ended_via ?? "open"}
50576
50537
  `);
50577
- } else if (existsSync35(pendingEnvPath)) {
50538
+ } else if (existsSync34(pendingEnvPath)) {
50578
50539
  rmSync4(pendingEnvPath, { force: true });
50579
50540
  process.stderr.write(`telegram gateway: pending-turn env cleared (clean previous shutdown)
50580
50541
  `);
@@ -50628,7 +50589,7 @@ function checkApprovals() {
50628
50589
  return;
50629
50590
  }
50630
50591
  for (const senderId of files) {
50631
- const file = join33(APPROVED_DIR, senderId);
50592
+ const file = join32(APPROVED_DIR, senderId);
50632
50593
  bot.api.sendMessage(senderId, "Paired! Say hi to Claude.").then(() => rmSync4(file, { force: true }), (err) => {
50633
50594
  process.stderr.write(`telegram gateway: failed to send approval confirm: ${err}
50634
50595
  `);
@@ -51505,11 +51466,11 @@ var unpinProgressCardForChat = null;
51505
51466
  var getPinnedProgressCardMessageId = null;
51506
51467
  var completeProgressCardTurn = null;
51507
51468
  var subagentWatcher = null;
51508
- var SOCKET_PATH = process.env.SWITCHROOM_GATEWAY_SOCKET ?? join33(STATE_DIR, "gateway.sock");
51469
+ var SOCKET_PATH = process.env.SWITCHROOM_GATEWAY_SOCKET ?? join32(STATE_DIR, "gateway.sock");
51509
51470
  mkdirSync21(STATE_DIR, { recursive: true, mode: 448 });
51510
- var GATEWAY_PID_PATH = process.env.SWITCHROOM_GATEWAY_PID_FILE ?? join33(STATE_DIR, "gateway.pid.json");
51511
- var GATEWAY_SESSION_MARKER_PATH = process.env.SWITCHROOM_GATEWAY_SESSION_MARKER ?? join33(STATE_DIR, "gateway-session.json");
51512
- var GATEWAY_CLEAN_SHUTDOWN_MARKER_PATH = process.env.SWITCHROOM_GATEWAY_CLEAN_SHUTDOWN_MARKER ?? join33(STATE_DIR, "clean-shutdown.json");
51471
+ var GATEWAY_PID_PATH = process.env.SWITCHROOM_GATEWAY_PID_FILE ?? join32(STATE_DIR, "gateway.pid.json");
51472
+ var GATEWAY_SESSION_MARKER_PATH = process.env.SWITCHROOM_GATEWAY_SESSION_MARKER ?? join32(STATE_DIR, "gateway-session.json");
51473
+ var GATEWAY_CLEAN_SHUTDOWN_MARKER_PATH = process.env.SWITCHROOM_GATEWAY_CLEAN_SHUTDOWN_MARKER ?? join32(STATE_DIR, "clean-shutdown.json");
51513
51474
  var GATEWAY_STARTED_AT_MS = Date.now();
51514
51475
  var BOOT_CARD_ENABLED = process.env.SWITCHROOM_BOOT_CARD !== "false";
51515
51476
  var activeBootCard = null;
@@ -51538,7 +51499,7 @@ function ensureIssuesCard(chatId, threadId) {
51538
51499
  bot: botApi,
51539
51500
  log: (msg) => process.stderr.write(`telegram gateway: ${msg}
51540
51501
  `),
51541
- persistPath: join33(stateDir, "issues-card.json")
51502
+ persistPath: join32(stateDir, "issues-card.json")
51542
51503
  });
51543
51504
  activeIssuesWatcher = startIssuesWatcher({
51544
51505
  stateDir,
@@ -51707,13 +51668,13 @@ startTimer2({
51707
51668
  }
51708
51669
  });
51709
51670
  var inboundSpool = STATIC ? undefined : createInboundSpool({
51710
- path: join33(STATE_DIR, "inbound-spool.jsonl"),
51671
+ path: join32(STATE_DIR, "inbound-spool.jsonl"),
51711
51672
  fs: {
51712
51673
  appendFileSync: (p, d) => appendFileSync3(p, d),
51713
51674
  readFileSync: (p) => readFileSync32(p, "utf8"),
51714
51675
  writeFileSync: (p, d) => writeFileSync21(p, d),
51715
51676
  renameSync: (a, b) => renameSync12(a, b),
51716
- existsSync: (p) => existsSync35(p),
51677
+ existsSync: (p) => existsSync34(p),
51717
51678
  statSizeSync: (p) => statSync13(p).size
51718
51679
  }
51719
51680
  });
@@ -52526,12 +52487,6 @@ ${url}`;
52526
52487
  });
52527
52488
  noteOutbound(statusKey(chat_id, threadId), Date.now());
52528
52489
  noteOutbound2(statusKey(chat_id, threadId), Date.now());
52529
- try {
52530
- markAckSent();
52531
- } catch (err) {
52532
- process.stderr.write(`telegram gateway: markAckSent failed: ${err}
52533
- `);
52534
- }
52535
52490
  if (isFinalAnswerReply({ text: rawText, disableNotification })) {
52536
52491
  clearSilentEndState(statusKey(chat_id, threadId));
52537
52492
  }
@@ -52859,12 +52814,6 @@ async function executeStreamReply(args) {
52859
52814
  const sKey = statusKey(streamChatId, streamThreadId);
52860
52815
  noteOutbound(sKey, Date.now());
52861
52816
  noteOutbound2(sKey, Date.now());
52862
- try {
52863
- markAckSent();
52864
- } catch (err) {
52865
- process.stderr.write(`telegram gateway: markAckSent (stream_reply) failed: ${err}
52866
- `);
52867
- }
52868
52817
  if (isFinalAnswerReply({
52869
52818
  text: args.text ?? "",
52870
52819
  disableNotification: args.disable_notification === true,
@@ -53215,10 +53164,10 @@ async function executeSendGif(rawArgs) {
53215
53164
  };
53216
53165
  }
53217
53166
  async function publishToTelegraph(text, shortName, authorName) {
53218
- const accountPath = join33(STATE_DIR, "telegraph-account.json");
53167
+ const accountPath = join32(STATE_DIR, "telegraph-account.json");
53219
53168
  let account = null;
53220
53169
  try {
53221
- if (existsSync35(accountPath)) {
53170
+ if (existsSync34(accountPath)) {
53222
53171
  const raw = readFileSync32(accountPath, "utf-8");
53223
53172
  const parsed = JSON.parse(raw);
53224
53173
  if (parsed.shortName && parsed.accessToken) {
@@ -53779,7 +53728,6 @@ function handleSessionEvent(ev) {
53779
53728
  if (ev.chatId) {
53780
53729
  const enqThreadId = ev.threadId != null ? Number(ev.threadId) : undefined;
53781
53730
  clearPending(statusKey(ev.chatId, enqThreadId), "handback");
53782
- clearAckSent();
53783
53731
  }
53784
53732
  if (ev.chatId) {
53785
53733
  const prior = currentTurn;
@@ -53883,12 +53831,6 @@ function handleSessionEvent(ev) {
53883
53831
  if (!turn.replyCalled && !isTelegramSurfaceTool(name)) {
53884
53832
  const rendered = registerAndRender(turn.toolActivity, name);
53885
53833
  if (rendered != null) {
53886
- try {
53887
- markAckSent();
53888
- } catch (err) {
53889
- process.stderr.write(`telegram gateway: activity-summary markAckSent failed: ${err}
53890
- `);
53891
- }
53892
53834
  turn.activityPendingRender = rendered;
53893
53835
  if (turn.activityInFlight == null) {
53894
53836
  turn.activityInFlight = drainActivitySummary(turn);
@@ -55262,7 +55204,7 @@ function restartMarkerPath() {
55262
55204
  const agentDir = resolveAgentDirFromEnv();
55263
55205
  if (!agentDir)
55264
55206
  return null;
55265
- return join33(agentDir, "restart-pending.json");
55207
+ return join32(agentDir, "restart-pending.json");
55266
55208
  }
55267
55209
  function writeRestartMarker(marker) {
55268
55210
  const p = restartMarkerPath();
@@ -55386,7 +55328,7 @@ var _dockerReachable;
55386
55328
  function isDockerReachable() {
55387
55329
  if (_dockerReachable !== undefined)
55388
55330
  return _dockerReachable;
55389
- if (!existsSync35("/var/run/docker.sock")) {
55331
+ if (!existsSync34("/var/run/docker.sock")) {
55390
55332
  _dockerReachable = false;
55391
55333
  return _dockerReachable;
55392
55334
  }
@@ -55403,11 +55345,11 @@ function _resetDockerReachableCache() {
55403
55345
  }
55404
55346
  function spawnSwitchroomDetached(args, onFailure) {
55405
55347
  const fullArgs = SWITCHROOM_CONFIG ? ["--config", SWITCHROOM_CONFIG, ...args] : args;
55406
- const logPath = join33(STATE_DIR, "detached-spawn.log");
55348
+ const logPath = join32(STATE_DIR, "detached-spawn.log");
55407
55349
  let outFd = null;
55408
55350
  try {
55409
55351
  mkdirSync21(STATE_DIR, { recursive: true });
55410
- outFd = openSync9(logPath, "a");
55352
+ outFd = openSync8(logPath, "a");
55411
55353
  writeFileSync21(logPath, `
55412
55354
  [${new Date().toISOString()}] spawn ${SWITCHROOM_CLI} ${fullArgs.join(" ")}
55413
55355
  `, { flag: "a" });
@@ -55422,7 +55364,7 @@ function spawnSwitchroomDetached(args, onFailure) {
55422
55364
  });
55423
55365
  if (outFd != null) {
55424
55366
  try {
55425
- closeSync9(outFd);
55367
+ closeSync8(outFd);
55426
55368
  } catch {}
55427
55369
  }
55428
55370
  if (onFailure) {
@@ -55776,8 +55718,8 @@ bot.use(async (ctx, next) => {
55776
55718
  });
55777
55719
  function readRecentDenialsForAgent(agentName3, windowMs, limit) {
55778
55720
  try {
55779
- const auditPath = join33(homedir12(), ".switchroom", "vault-audit.log");
55780
- if (!existsSync35(auditPath))
55721
+ const auditPath = join32(homedir12(), ".switchroom", "vault-audit.log");
55722
+ if (!existsSync34(auditPath))
55781
55723
  return [];
55782
55724
  const raw = readFileSync32(auditPath, "utf8");
55783
55725
  return recentDenialsFromAuditLog(raw, { agentName: agentName3, windowMs, limit });
@@ -55830,7 +55772,7 @@ async function buildAgentMetadata(agentName3) {
55830
55772
  try {
55831
55773
  const agentDir = resolveAgentDirFromEnv();
55832
55774
  if (agentDir) {
55833
- const raw = readFileSync32(join33(agentDir, ".claude", ".claude.json"), "utf8");
55775
+ const raw = readFileSync32(join32(agentDir, ".claude", ".claude.json"), "utf8");
55834
55776
  claudeJson = JSON.parse(raw);
55835
55777
  }
55836
55778
  } catch {}
@@ -56044,10 +55986,10 @@ bot.command("restart", async (ctx) => {
56044
55986
  function flushAgentHandoff(agentDir) {
56045
55987
  let removed = 0;
56046
55988
  for (const fname of [".handoff.md", ".handoff-topic"]) {
56047
- const p = join33(agentDir, fname);
55989
+ const p = join32(agentDir, fname);
56048
55990
  try {
56049
- if (existsSync35(p)) {
56050
- unlinkSync15(p);
55991
+ if (existsSync34(p)) {
55992
+ unlinkSync14(p);
56051
55993
  removed++;
56052
55994
  }
56053
55995
  } catch (err) {
@@ -56102,7 +56044,7 @@ async function handleNewOrResetCommand(ctx, kind) {
56102
56044
  writeRestartMarker({ chat_id: chatId, thread_id: threadId ?? null, ack_message_id: ackId, ts: Date.now() });
56103
56045
  if (agentDir != null) {
56104
56046
  try {
56105
- writeFileSync21(join33(agentDir, ".force-fresh-session"), `${kind} at ${new Date().toISOString()}
56047
+ writeFileSync21(join32(agentDir, ".force-fresh-session"), `${kind} at ${new Date().toISOString()}
56106
56048
  `, "utf8");
56107
56049
  } catch (err) {
56108
56050
  process.stderr.write(`telegram gateway: failed to write force-fresh marker: ${err}
@@ -56463,14 +56405,14 @@ bot.command("interrupt", async (ctx) => {
56463
56405
  var lockoutOps = {
56464
56406
  readFileSync: (p, enc) => readFileSync32(p, enc),
56465
56407
  writeFileSync: (p, data, opts) => writeFileSync21(p, data, opts),
56466
- existsSync: (p) => existsSync35(p),
56408
+ existsSync: (p) => existsSync34(p),
56467
56409
  mkdirSync: (p, opts) => mkdirSync21(p, opts),
56468
- joinPath: (...parts) => join33(...parts)
56410
+ joinPath: (...parts) => join32(...parts)
56469
56411
  };
56470
56412
  var FLEET_FALLBACK_DEDUP_MS = 30000;
56471
56413
  function isAuthBrokerSocketReachable() {
56472
56414
  try {
56473
- return existsSync35(resolveAuthBrokerSocketPath2());
56415
+ return existsSync34(resolveAuthBrokerSocketPath2());
56474
56416
  } catch {
56475
56417
  return false;
56476
56418
  }
@@ -56531,7 +56473,7 @@ async function runCreditWatch() {
56531
56473
  if (!agentDir)
56532
56474
  return;
56533
56475
  const agentName3 = getMyAgentName();
56534
- const claudeConfigDir = join33(agentDir, ".claude");
56476
+ const claudeConfigDir = join32(agentDir, ".claude");
56535
56477
  const stateDir = STATE_DIR;
56536
56478
  const reason = readClaudeJsonOverage(claudeConfigDir);
56537
56479
  const prev = loadCreditState(stateDir);
@@ -56741,9 +56683,9 @@ async function handleVaultRecentDenialCallback(ctx, data) {
56741
56683
  return;
56742
56684
  }
56743
56685
  const { token, id } = result;
56744
- const tokenPath = join33(homedir12(), ".switchroom", "agents", agentName3, ".vault-token");
56686
+ const tokenPath = join32(homedir12(), ".switchroom", "agents", agentName3, ".vault-token");
56745
56687
  try {
56746
- mkdirSync21(join33(homedir12(), ".switchroom", "agents", agentName3), { recursive: true });
56688
+ mkdirSync21(join32(homedir12(), ".switchroom", "agents", agentName3), { recursive: true });
56747
56689
  writeFileSync21(tokenPath, token, { mode: 384 });
56748
56690
  } catch (err) {
56749
56691
  await switchroomReply(ctx, `<b>Grant created (${escapeHtmlForTg(id)}) but token write failed:</b> ${escapeHtmlForTg(String(err))}
@@ -56820,9 +56762,9 @@ async function performVaultAccessApproval(ctx, pending2, stageId, senderId, atte
56820
56762
  return;
56821
56763
  }
56822
56764
  const { token, id } = result;
56823
- const tokenPath = join33(homedir12(), ".switchroom", "agents", pending2.agent, ".vault-token");
56765
+ const tokenPath = join32(homedir12(), ".switchroom", "agents", pending2.agent, ".vault-token");
56824
56766
  try {
56825
- mkdirSync21(join33(homedir12(), ".switchroom", "agents", pending2.agent), { recursive: true });
56767
+ mkdirSync21(join32(homedir12(), ".switchroom", "agents", pending2.agent), { recursive: true });
56826
56768
  writeFileSync21(tokenPath, token, { mode: 384 });
56827
56769
  } catch (err) {
56828
56770
  await switchroomReply(ctx, `<b>Grant created (${escapeHtmlForTg(id)}) but token write failed:</b> ${escapeHtmlForTg(String(err))}
@@ -57298,9 +57240,9 @@ async function executeGrantWizard(ctx, chatId, state4) {
57298
57240
  return;
57299
57241
  }
57300
57242
  const { token, id } = result;
57301
- const tokenPath = join33(homedir12(), ".switchroom", "agents", state4.agent, ".vault-token");
57243
+ const tokenPath = join32(homedir12(), ".switchroom", "agents", state4.agent, ".vault-token");
57302
57244
  try {
57303
- mkdirSync21(join33(homedir12(), ".switchroom", "agents", state4.agent), { recursive: true });
57245
+ mkdirSync21(join32(homedir12(), ".switchroom", "agents", state4.agent), { recursive: true });
57304
57246
  writeFileSync21(tokenPath, token, { mode: 384 });
57305
57247
  } catch (err) {
57306
57248
  await switchroomReply(ctx, `<b>Grant created but token write failed:</b> ${escapeHtmlForTg(String(err))}`, { html: true });
@@ -58158,7 +58100,7 @@ bot.command("usage", async (ctx) => {
58158
58100
  await switchroomReply(ctx, "<b>/usage:</b> cannot resolve agent dir.", { html: true });
58159
58101
  return;
58160
58102
  }
58161
- const result = await fetchQuota2({ claudeConfigDir: join33(agentDir, ".claude") });
58103
+ const result = await fetchQuota2({ claudeConfigDir: join32(agentDir, ".claude") });
58162
58104
  if (!result.ok) {
58163
58105
  await switchroomReply(ctx, `<b>/usage:</b> ${escapeHtmlForTg(result.reason)}`, { html: true });
58164
58106
  return;
@@ -58703,7 +58645,7 @@ async function maybeTranscribeVoice(fileId, mimeType, language) {
58703
58645
  let apiKey = null;
58704
58646
  try {
58705
58647
  const path = __require("path").join(__require("os").homedir(), ".switchroom", "openai-api-key");
58706
- if (existsSync35(path)) {
58648
+ if (existsSync34(path)) {
58707
58649
  apiKey = readFileSync32(path, "utf-8").trim();
58708
58650
  }
58709
58651
  } catch (err) {
@@ -59564,7 +59506,7 @@ var didOneTimeSetup = false;
59564
59506
  agentName: agentDisplayName,
59565
59507
  agentSlug,
59566
59508
  version: formatBootVersion(),
59567
- agentDir: agentDir ?? join33(homedir12(), ".switchroom", "agents", agentSlug),
59509
+ agentDir: agentDir ?? join32(homedir12(), ".switchroom", "agents", agentSlug),
59568
59510
  gatewayInfo: { pid: process.pid, startedAtMs: GATEWAY_STARTED_AT_MS },
59569
59511
  restartReason: reason,
59570
59512
  restartAgeMs: markerAgeMs,