abtars 0.1.0-alpha.24 → 0.1.0-alpha.26

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.
@@ -538,20 +538,36 @@ async function runInteractive(existing) {
538
538
  await fetch(`${botUrl}/deleteWebhook`);
539
539
  } catch {
540
540
  }
541
- process.stdout.write("\nSend /start to your bot on Telegram now... (waiting 30s)\n");
542
541
  try {
543
- const res = await fetch(`${botUrl}/getUpdates?timeout=30&allowed_updates=["message"]`);
544
- const data = await res.json();
545
- const id = data.result?.find((u) => u.message?.chat?.id)?.message?.chat?.id;
546
- if (id) {
547
- detectedChatId = String(id);
542
+ const quick = await fetch(`${botUrl}/getUpdates?timeout=2&allowed_updates=${encodeURIComponent('["message"]')}`);
543
+ const qData = await quick.json();
544
+ const qId = qData.result?.find((u) => u.message?.chat?.id)?.message?.chat?.id;
545
+ if (qId) {
546
+ detectedChatId = String(qId);
548
547
  process.stdout.write(`\u2713 Detected your chat ID: ${detectedChatId}
549
548
  `);
550
- } else {
551
- process.stdout.write("\u26A0 No message received \u2014 enter manually below.\n");
552
549
  }
553
550
  } catch {
554
- process.stdout.write("\u26A0 Could not reach Telegram API \u2014 enter manually below.\n");
551
+ }
552
+ if (!detectedChatId) {
553
+ process.stdout.write("\n\u2192 Send /start to your bot on Telegram, then press Enter here.\n");
554
+ await new Promise((resolve) => {
555
+ process.stdin.once("data", () => resolve());
556
+ });
557
+ try {
558
+ const res = await fetch(`${botUrl}/getUpdates?timeout=10&allowed_updates=${encodeURIComponent('["message"]')}`);
559
+ const data = await res.json();
560
+ const id = data.result?.find((u) => u.message?.chat?.id)?.message?.chat?.id;
561
+ if (id) {
562
+ detectedChatId = String(id);
563
+ process.stdout.write(`\u2713 Detected your chat ID: ${detectedChatId}
564
+ `);
565
+ } else {
566
+ process.stdout.write("\u26A0 No message received \u2014 enter manually below.\n");
567
+ }
568
+ } catch {
569
+ process.stdout.write("\u26A0 Could not reach Telegram API \u2014 enter manually below.\n");
570
+ }
555
571
  }
556
572
  }
557
573
  const telegramChatId = await text({
@@ -1069,40 +1085,15 @@ Next: run 'abtars update' to stage the release, then start the bridge.
1069
1085
  `);
1070
1086
  return 0;
1071
1087
  }
1072
- const { confirm: confirm2 } = await import("./dist-J3T4XVKX.js");
1073
- const startCmds = [];
1074
- if (answers.installMode === "simple") {
1075
- startCmds.push("abtars start");
1076
- } else {
1077
- if (process.platform === "darwin") {
1078
- startCmds.push(`launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.abtars.watchdog.plist`);
1079
- } else if (process.platform === "linux") {
1080
- startCmds.push(`systemctl --user daemon-reload`);
1081
- startCmds.push(`systemctl --user enable --now abtars-watchdog`);
1082
- }
1083
- }
1084
1088
  process.stdout.write(`
1085
- \u2500\u2500 Start the bridge \u2500\u2500
1086
- `);
1087
- const { spawn: spawn2 } = await import("node:child_process");
1088
- if (startCmds.length > 0) {
1089
- for (const cmd of startCmds) process.stdout.write(` \u2192 ${cmd}
1090
- `);
1091
- const run2 = await confirm2({ message: `Enable and start the watchdog service?`, initialValue: true });
1092
- if (run2 === true) {
1093
- for (const cmd of startCmds) {
1094
- await new Promise((resolve) => {
1095
- const child = spawn2("bash", ["-lc", cmd], { stdio: "inherit" });
1096
- child.on("exit", () => resolve());
1097
- });
1098
- }
1099
- } else {
1100
- process.stdout.write(` \u2192 skipped (run manually)
1089
+ \u2713 Onboarding complete.
1101
1090
  `);
1102
- }
1103
- }
1104
1091
  process.stdout.write(`
1105
- \u2713 Onboarding complete.
1092
+ Next: start the bridge
1093
+ `);
1094
+ process.stdout.write(` Daemon mode: sudo $(which abtars) daemon install
1095
+ `);
1096
+ process.stdout.write(` Manual mode: abtars start
1106
1097
  `);
1107
1098
  return 0;
1108
1099
  }
@@ -1260,6 +1251,8 @@ Rollback complete: ${target}
1260
1251
  }
1261
1252
 
1262
1253
  // src/cli/commands/status.ts
1254
+ import { readFileSync as readFileSync3 } from "node:fs";
1255
+ import { join as join7 } from "node:path";
1263
1256
  async function status() {
1264
1257
  const paths = packagePaths("abtars");
1265
1258
  const manifest = await readManifest(paths.manifest);
@@ -1299,7 +1292,24 @@ Run 'abtars install' to set up.
1299
1292
  ` bridge: ${alive ? "\u25CF running" : "\u2717 dead"} (pid ${lock.content.pid})${lock.stale ? " \u2014 STALE" : ""}`
1300
1293
  );
1301
1294
  } else {
1302
- lines.push(` bridge: \u25CB stopped`);
1295
+ try {
1296
+ const bridgeLock = JSON.parse(readFileSync3(join7(paths.home, "bridge.lock"), "utf-8"));
1297
+ if (bridgeLock.pid) {
1298
+ const alive = (() => {
1299
+ try {
1300
+ process.kill(bridgeLock.pid, 0);
1301
+ return true;
1302
+ } catch {
1303
+ return false;
1304
+ }
1305
+ })();
1306
+ lines.push(` bridge: ${alive ? "\u25CF running" : "\u2717 dead"} (pid ${bridgeLock.pid})`);
1307
+ } else {
1308
+ lines.push(` bridge: \u25CB stopped`);
1309
+ }
1310
+ } catch {
1311
+ lines.push(` bridge: \u25CB stopped`);
1312
+ }
1303
1313
  }
1304
1314
  process.stdout.write(`${lines.join("\n")}
1305
1315
  `);
@@ -1318,15 +1328,15 @@ Re-run 'abtars update' or 'abtars rollback' to reconcile.
1318
1328
  // src/cli/commands/update.ts
1319
1329
  init_log_and_swallow();
1320
1330
  import { hostname as hostname2 } from "node:os";
1321
- import { join as join9, dirname as dirname3 } from "node:path";
1322
- import { readFileSync as readFileSync4, existsSync as existsSync7, mkdirSync as mkdirSync2 } from "node:fs";
1331
+ import { join as join10, dirname as dirname3 } from "node:path";
1332
+ import { readFileSync as readFileSync5, existsSync as existsSync7, mkdirSync as mkdirSync2 } from "node:fs";
1323
1333
  import { copyFile as copyFile2, mkdir as mkdir4, chmod, readdir, readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
1324
1334
 
1325
1335
  // src/cli/update-sources/local.ts
1326
1336
  import { spawnSync as spawnSync2 } from "node:child_process";
1327
1337
  import { existsSync as existsSync5 } from "node:fs";
1328
1338
  import { copyFile, cp, mkdir as mkdir2, readFile as readFile2, rm, writeFile as writeFile2 } from "node:fs/promises";
1329
- import { join as join7 } from "node:path";
1339
+ import { join as join8 } from "node:path";
1330
1340
  var LocalBuildError = class extends Error {
1331
1341
  constructor(message, hint) {
1332
1342
  super(hint ? `${message}
@@ -1388,7 +1398,7 @@ ${upstream} is ahead by ${behind} commit${behind === 1 ? "" : "s"}.`,
1388
1398
  return { commit, branch };
1389
1399
  }
1390
1400
  async function readPackageVersion(repoRoot) {
1391
- const pkg = JSON.parse(await readFile2(join7(repoRoot, "package.json"), "utf-8"));
1401
+ const pkg = JSON.parse(await readFile2(join8(repoRoot, "package.json"), "utf-8"));
1392
1402
  if (typeof pkg.version !== "string") {
1393
1403
  throw new LocalBuildError("package.json has no version field.");
1394
1404
  }
@@ -1396,30 +1406,30 @@ async function readPackageVersion(repoRoot) {
1396
1406
  }
1397
1407
  function makeLocalBuildSource(opts = {}) {
1398
1408
  const repoRoot = opts.repoRoot ?? process.cwd();
1399
- const isNpmPackage = !existsSync5(join7(repoRoot, ".git"));
1409
+ const isNpmPackage = !existsSync5(join8(repoRoot, ".git"));
1400
1410
  return {
1401
1411
  name: "local",
1402
1412
  async prepare(ctx) {
1403
1413
  if (isNpmPackage) {
1404
- const bundleDir = join7(repoRoot, "bundle");
1414
+ const bundleDir = join8(repoRoot, "bundle");
1405
1415
  if (!existsSync5(bundleDir)) {
1406
1416
  throw new Error(`No bundle/ found at ${repoRoot}. Run from the abtars npm package or a git checkout.`);
1407
1417
  }
1408
1418
  const pkgVersion2 = await readPackageVersion(repoRoot);
1409
1419
  const version2 = pkgVersion2;
1410
- const stagedPath2 = join7(ctx.releasesDir, version2);
1420
+ const stagedPath2 = join8(ctx.releasesDir, version2);
1411
1421
  await rm(stagedPath2, { recursive: true, force: true });
1412
1422
  await mkdir2(stagedPath2, { recursive: true });
1413
- await cp(bundleDir, join7(stagedPath2, "bundle"), { recursive: true });
1414
- const coreDir = join7(repoRoot, "core");
1415
- if (existsSync5(coreDir)) await cp(coreDir, join7(stagedPath2, "core"), { recursive: true });
1416
- const scriptsSrc = join7(repoRoot, "scripts");
1417
- if (existsSync5(scriptsSrc)) await cp(scriptsSrc, join7(stagedPath2, "scripts"), { recursive: true });
1418
- const configSrc = join7(repoRoot, "config");
1419
- if (existsSync5(configSrc)) await cp(configSrc, join7(stagedPath2, "config"), { recursive: true });
1420
- const manifestSrc = join7(repoRoot, "install-manifest.json");
1421
- if (existsSync5(manifestSrc)) await copyFile(manifestSrc, join7(stagedPath2, "install-manifest.json"));
1422
- await writeFile2(join7(stagedPath2, "package.json"), JSON.stringify({ type: "module", name: "abtars", version: version2 }, null, 2) + "\n");
1423
+ await cp(bundleDir, join8(stagedPath2, "bundle"), { recursive: true });
1424
+ const coreDir = join8(repoRoot, "core");
1425
+ if (existsSync5(coreDir)) await cp(coreDir, join8(stagedPath2, "core"), { recursive: true });
1426
+ const scriptsSrc = join8(repoRoot, "scripts");
1427
+ if (existsSync5(scriptsSrc)) await cp(scriptsSrc, join8(stagedPath2, "scripts"), { recursive: true });
1428
+ const configSrc = join8(repoRoot, "config");
1429
+ if (existsSync5(configSrc)) await cp(configSrc, join8(stagedPath2, "config"), { recursive: true });
1430
+ const manifestSrc = join8(repoRoot, "install-manifest.json");
1431
+ if (existsSync5(manifestSrc)) await copyFile(manifestSrc, join8(stagedPath2, "install-manifest.json"));
1432
+ await writeFile2(join8(stagedPath2, "package.json"), JSON.stringify({ type: "module", name: "abtars", version: version2 }, null, 2) + "\n");
1423
1433
  process.stdout.write(`\u2713 staged ${version2} (from npm package)
1424
1434
  `);
1425
1435
  return { version: version2, stagedPath: stagedPath2, commit: null, branch: null, packageLockHash: null, source: "local" };
@@ -1433,30 +1443,30 @@ function makeLocalBuildSource(opts = {}) {
1433
1443
  const useBundle = process.env["AGENTBRIDGE_BUILD_MODE"] !== "tsc";
1434
1444
  if (useBundle) {
1435
1445
  runCmd("npm", ["run", "bundle"], repoRoot);
1436
- const stagedPath2 = join7(ctx.releasesDir, version);
1446
+ const stagedPath2 = join8(ctx.releasesDir, version);
1437
1447
  await rm(stagedPath2, { recursive: true, force: true });
1438
1448
  await mkdir2(stagedPath2, { recursive: true });
1439
- await cp(join7(repoRoot, "bundle"), join7(stagedPath2, "bundle"), { recursive: true });
1440
- const coreSkillsSrc = join7(repoRoot, "core", "skills");
1449
+ await cp(join8(repoRoot, "bundle"), join8(stagedPath2, "bundle"), { recursive: true });
1450
+ const coreSkillsSrc = join8(repoRoot, "core", "skills");
1441
1451
  if (existsSync5(coreSkillsSrc)) {
1442
- await cp(coreSkillsSrc, join7(stagedPath2, "core", "skills"), { recursive: true });
1452
+ await cp(coreSkillsSrc, join8(stagedPath2, "core", "skills"), { recursive: true });
1443
1453
  }
1444
- await writeFile2(join7(stagedPath2, "package.json"), JSON.stringify({ type: "module", name: "abtars", version }, null, 2) + "\n");
1445
- await copyFile(join7(repoRoot, "install-manifest.json"), join7(stagedPath2, "install-manifest.json"));
1446
- const packageLockHash2 = await hashFile(join7(repoRoot, "package-lock.json"));
1454
+ await writeFile2(join8(stagedPath2, "package.json"), JSON.stringify({ type: "module", name: "abtars", version }, null, 2) + "\n");
1455
+ await copyFile(join8(repoRoot, "install-manifest.json"), join8(stagedPath2, "install-manifest.json"));
1456
+ const packageLockHash2 = await hashFile(join8(repoRoot, "package-lock.json"));
1447
1457
  return { version, stagedPath: stagedPath2, commit, branch, packageLockHash: packageLockHash2, source: "local" };
1448
1458
  }
1449
1459
  runCmd("npm", ["run", "build"], repoRoot);
1450
- const stagedPath = join7(ctx.releasesDir, version);
1460
+ const stagedPath = join8(ctx.releasesDir, version);
1451
1461
  await rm(stagedPath, { recursive: true, force: true });
1452
1462
  await mkdir2(stagedPath, { recursive: true });
1453
- await cp(join7(repoRoot, "dist"), join7(stagedPath, "dist"), { recursive: true });
1454
- await copyFile(join7(repoRoot, "install-manifest.json"), join7(stagedPath, "install-manifest.json"));
1463
+ await cp(join8(repoRoot, "dist"), join8(stagedPath, "dist"), { recursive: true });
1464
+ await copyFile(join8(repoRoot, "install-manifest.json"), join8(stagedPath, "install-manifest.json"));
1455
1465
  await rm(ctx.nodeModulesDir, { recursive: true, force: true });
1456
1466
  await mkdir2(ctx.nodeModulesDir, { recursive: true });
1457
1467
  const rsyncResult = spawnSync2(
1458
1468
  "rsync",
1459
- ["-aL", "--quiet", `${join7(repoRoot, "node_modules")}/`, `${ctx.nodeModulesDir}/`],
1469
+ ["-aL", "--quiet", `${join8(repoRoot, "node_modules")}/`, `${ctx.nodeModulesDir}/`],
1460
1470
  { stdio: "inherit" }
1461
1471
  );
1462
1472
  if (rsyncResult.status !== 0) {
@@ -1465,7 +1475,7 @@ function makeLocalBuildSource(opts = {}) {
1465
1475
  `Ensure rsync is installed. Falling back to node cp would re-create symlinks.`
1466
1476
  );
1467
1477
  }
1468
- const packageLockHash = await hashFile(join7(repoRoot, "package-lock.json"));
1478
+ const packageLockHash = await hashFile(join8(repoRoot, "package-lock.json"));
1469
1479
  return { version, stagedPath, commit, branch, packageLockHash, source: "local" };
1470
1480
  }
1471
1481
  };
@@ -1473,9 +1483,9 @@ function makeLocalBuildSource(opts = {}) {
1473
1483
 
1474
1484
  // src/cli/update-sources/npm.ts
1475
1485
  import { spawnSync as spawnSync3 } from "node:child_process";
1476
- import { existsSync as existsSync6, readFileSync as readFileSync3, unlinkSync as unlinkSync4 } from "node:fs";
1486
+ import { existsSync as existsSync6, readFileSync as readFileSync4, unlinkSync as unlinkSync4 } from "node:fs";
1477
1487
  import { mkdir as mkdir3, rm as rm2 } from "node:fs/promises";
1478
- import { join as join8 } from "node:path";
1488
+ import { join as join9 } from "node:path";
1479
1489
  var TIMEOUT_MS = 6e4;
1480
1490
  function run(cmd, args, cwd) {
1481
1491
  const r = spawnSync3(cmd, args, { cwd, encoding: "utf-8", timeout: TIMEOUT_MS });
@@ -1485,7 +1495,7 @@ function run(cmd, args, cwd) {
1485
1495
  }
1486
1496
  function readLocalVersion(home) {
1487
1497
  try {
1488
- const pkg = JSON.parse(readFileSync3(join8(home, "current", "package.json"), "utf-8"));
1498
+ const pkg = JSON.parse(readFileSync4(join9(home, "current", "package.json"), "utf-8"));
1489
1499
  return pkg.version ?? null;
1490
1500
  } catch {
1491
1501
  return null;
@@ -1500,12 +1510,12 @@ function makeNpmSource(packageName) {
1500
1510
  if (latest === current) {
1501
1511
  throw new Error(`Already at latest version (${latest}). Nothing to update.`);
1502
1512
  }
1503
- const stagedPath = join8(ctx.releasesDir, latest);
1513
+ const stagedPath = join9(ctx.releasesDir, latest);
1504
1514
  await rm2(stagedPath, { recursive: true, force: true });
1505
1515
  await mkdir3(stagedPath, { recursive: true });
1506
1516
  run("npm", ["pack", `${packageName}@${latest}`, "--pack-destination", stagedPath], stagedPath);
1507
1517
  const tgzName = `${packageName}-${latest}.tgz`.replace("@", "").replace("/", "-");
1508
- const tgzPath = join8(stagedPath, tgzName);
1518
+ const tgzPath = join9(stagedPath, tgzName);
1509
1519
  run("tar", ["-xzf", tgzPath, "--strip-components=1"], stagedPath);
1510
1520
  if (existsSync6(tgzPath)) unlinkSync4(tgzPath);
1511
1521
  run("npm", ["install", "--omit=dev", "--no-audit", "--no-fund"], stagedPath);
@@ -1517,7 +1527,7 @@ function makeNpmSource(packageName) {
1517
1527
  // src/cli/commands/update.ts
1518
1528
  function readJsonField2(file, field) {
1519
1529
  try {
1520
- return JSON.parse(readFileSync4(file, "utf-8"))[field];
1530
+ return JSON.parse(readFileSync5(file, "utf-8"))[field];
1521
1531
  } catch {
1522
1532
  return void 0;
1523
1533
  }
@@ -1530,18 +1540,18 @@ Use --source local (default) or --source npm.
1530
1540
  return 2;
1531
1541
  }
1532
1542
  const paths = packagePaths("abtars");
1533
- if (!existsSync7(paths.releases) && existsSync7(join9(paths.home, "current"))) {
1543
+ if (!existsSync7(paths.releases) && existsSync7(join10(paths.home, "current"))) {
1534
1544
  process.stdout.write("Migrating old layout \u2192 releases/...\n");
1535
1545
  mkdirSync2(paths.releases, { recursive: true });
1536
1546
  }
1537
1547
  const release = await acquireLock(paths.lock, `update --source ${opts.source}`);
1538
1548
  try {
1539
1549
  let repoRoot = opts.repoRoot ?? process.cwd();
1540
- if (!opts.repoRoot && !existsSync7(join9(repoRoot, ".git"))) {
1550
+ if (!opts.repoRoot && !existsSync7(join10(repoRoot, ".git"))) {
1541
1551
  const { realpathSync } = await import("node:fs");
1542
1552
  const scriptPath = realpathSync(process.argv[1] ?? "");
1543
- const candidate = join9(dirname3(scriptPath), "..");
1544
- if (existsSync7(join9(candidate, "bundle"))) repoRoot = candidate;
1553
+ const candidate = join10(dirname3(scriptPath), "..");
1554
+ if (existsSync7(join10(candidate, "bundle"))) repoRoot = candidate;
1545
1555
  }
1546
1556
  const source = opts.source === "npm" ? makeNpmSource("abtars") : makeLocalBuildSource({ repoRoot, allowStale: opts.fromLocal });
1547
1557
  if (opts.fromLocal) {
@@ -1558,10 +1568,10 @@ Use --source local (default) or --source npm.
1558
1568
  process.stdout.write(`\u2713 staged ${staged.version} at ${staged.stagedPath}
1559
1569
  `);
1560
1570
  {
1561
- const pkgPath = join9(staged.stagedPath, "package.json");
1562
- const { readFileSync: readFileSync5, writeFileSync: writeFileSync2 } = await import("node:fs");
1571
+ const pkgPath = join10(staged.stagedPath, "package.json");
1572
+ const { readFileSync: readFileSync6, writeFileSync: writeFileSync2 } = await import("node:fs");
1563
1573
  try {
1564
- const pkg = JSON.parse(readFileSync5(pkgPath, "utf-8"));
1574
+ const pkg = JSON.parse(readFileSync6(pkgPath, "utf-8"));
1565
1575
  const externals = { patchright: "^1.59.4", "rettiwt-api": "^4.1.3" };
1566
1576
  pkg.dependencies = { ...pkg.dependencies, ...externals };
1567
1577
  writeFileSync2(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
@@ -1576,13 +1586,13 @@ Use --source local (default) or --source npm.
1576
1586
  }
1577
1587
  {
1578
1588
  const { existsSync: existsSync8, unlinkSync: unlinkSync5, symlinkSync } = await import("node:fs");
1579
- const mainLink = join9(staged.stagedPath, "main.js");
1589
+ const mainLink = join10(staged.stagedPath, "main.js");
1580
1590
  try {
1581
1591
  unlinkSync5(mainLink);
1582
1592
  } catch (err) {
1583
1593
  logAndSwallow("update", "op", err);
1584
1594
  }
1585
- const entry = existsSync8(join9(staged.stagedPath, "bundle", "abtars.js")) ? "bundle/abtars.js" : "dist/main.js";
1595
+ const entry = existsSync8(join10(staged.stagedPath, "bundle", "abtars.js")) ? "bundle/abtars.js" : "dist/main.js";
1586
1596
  symlinkSync(entry, mainLink);
1587
1597
  }
1588
1598
  const { existsSync: ex2, symlinkSync: sl2, mkdirSync: mk2, unlinkSync: ul2 } = await import("node:fs");
@@ -1590,18 +1600,18 @@ Use --source local (default) or --source npm.
1590
1600
  await activate(paths.current, staged.version);
1591
1601
  process.stdout.write(`\u2713 current -> releases/${staged.version}
1592
1602
  `);
1593
- const globalModules = join9(dn2(process.execPath), "..", "lib", "node_modules");
1594
- const abmindHome = process.env["ABMIND_HOME"] ?? join9(process.env["HOME"] ?? "", ".abmind");
1603
+ const globalModules = join10(dn2(process.execPath), "..", "lib", "node_modules");
1604
+ const abmindHome = process.env["ABMIND_HOME"] ?? join10(process.env["HOME"] ?? "", ".abmind");
1595
1605
  const links = [];
1596
- const globalAbmind = join9(globalModules, "abmind");
1606
+ const globalAbmind = join10(globalModules, "abmind");
1597
1607
  if (ex2(globalAbmind)) links.push({ name: "abmind", target: globalAbmind });
1598
- const bsq3 = join9(abmindHome, "lib", "node_modules", "better-sqlite3");
1608
+ const bsq3 = join10(abmindHome, "lib", "node_modules", "better-sqlite3");
1599
1609
  if (ex2(bsq3)) links.push({ name: "better-sqlite3", target: bsq3 });
1600
1610
  if (links.length > 0) {
1601
- const newNm = join9(paths.home, "current", "node_modules");
1611
+ const newNm = join10(paths.home, "current", "node_modules");
1602
1612
  mk2(newNm, { recursive: true });
1603
1613
  for (const { name, target } of links) {
1604
- const dest = join9(newNm, name);
1614
+ const dest = join10(newNm, name);
1605
1615
  try {
1606
1616
  if (ex2(dest)) ul2(dest);
1607
1617
  } catch {
@@ -1648,10 +1658,10 @@ Use --source local (default) or --source npm.
1648
1658
  process.stdout.write(`
1649
1659
  Update complete: ${staged.version}
1650
1660
  `);
1651
- const transportJson = join9(paths.home, "config", "transport.json");
1661
+ const transportJson = join10(paths.home, "config", "transport.json");
1652
1662
  if (existsSync7(transportJson)) {
1653
1663
  try {
1654
- const tc = JSON.parse(readFileSync4(transportJson, "utf-8"));
1664
+ const tc = JSON.parse(readFileSync5(transportJson, "utf-8"));
1655
1665
  let cleared = false;
1656
1666
  for (const agent of Object.values(tc.agents ?? {})) {
1657
1667
  if (agent.demoted) {
@@ -1679,8 +1689,8 @@ Update complete: ${staged.version}
1679
1689
  const { loadManifest } = await import("./install-manifest-QRWID3KZ.js");
1680
1690
  const sourceRoot = staged.stagedPath;
1681
1691
  const installManifest = loadManifest(sourceRoot);
1682
- const repoScripts = join9(sourceRoot, "scripts");
1683
- const destScripts = join9(paths.home, "scripts");
1692
+ const repoScripts = join10(sourceRoot, "scripts");
1693
+ const destScripts = join10(paths.home, "scripts");
1684
1694
  await mkdir4(destScripts, { recursive: true });
1685
1695
  const allScriptFiles = await readdir(repoScripts).catch(() => []);
1686
1696
  const matchesInclude = (name) => installManifest.scripts.include.some((pattern) => {
@@ -1696,30 +1706,30 @@ Update complete: ${staged.version}
1696
1706
  return name.endsWith(ext);
1697
1707
  };
1698
1708
  for (const name of scriptFiles) {
1699
- await copyFile2(join9(repoScripts, name), join9(destScripts, name));
1700
- if (isExecutable(name)) await chmod(join9(destScripts, name), 493);
1709
+ await copyFile2(join10(repoScripts, name), join10(destScripts, name));
1710
+ if (isExecutable(name)) await chmod(join10(destScripts, name), 493);
1701
1711
  if (isExecutable(name)) {
1702
- await copyFile2(join9(repoScripts, name), join9(paths.home, name));
1703
- await chmod(join9(paths.home, name), 493);
1712
+ await copyFile2(join10(repoScripts, name), join10(paths.home, name));
1713
+ await chmod(join10(paths.home, name), 493);
1704
1714
  }
1705
1715
  const macService = installManifest.services.supervised.macos;
1706
1716
  if (macService && name === macService.plist && process.platform === "darwin" && home && installMode === "supervised") {
1707
- const launchAgentsDir = join9(home, "Library", "LaunchAgents");
1717
+ const launchAgentsDir = join10(home, "Library", "LaunchAgents");
1708
1718
  await mkdir4(launchAgentsDir, { recursive: true });
1709
- const dst = join9(launchAgentsDir, name);
1719
+ const dst = join10(launchAgentsDir, name);
1710
1720
  const oldContent = await readFile3(dst, "utf-8").catch(() => "");
1711
- let templated = await readFile3(join9(repoScripts, name), "utf-8");
1721
+ let templated = await readFile3(join10(repoScripts, name), "utf-8");
1712
1722
  for (const ph of macService.placeholders) templated = templated.replaceAll(ph, home);
1713
1723
  await writeFile3(dst, templated);
1714
1724
  if (oldContent !== templated) serviceChanged = true;
1715
1725
  }
1716
1726
  const linuxService = installManifest.services.supervised.linux;
1717
1727
  if (linuxService?.units.includes(name) && process.platform === "linux" && home && installMode === "supervised") {
1718
- const systemdDir = join9(home, ".config", "systemd", "user");
1728
+ const systemdDir = join10(home, ".config", "systemd", "user");
1719
1729
  await mkdir4(systemdDir, { recursive: true });
1720
- const dst = join9(systemdDir, name);
1730
+ const dst = join10(systemdDir, name);
1721
1731
  const oldContent = await readFile3(dst, "utf-8").catch(() => "");
1722
- await copyFile2(join9(repoScripts, name), dst);
1732
+ await copyFile2(join10(repoScripts, name), dst);
1723
1733
  const newContent = await readFile3(dst, "utf-8").catch(() => "");
1724
1734
  if (oldContent !== newContent) serviceChanged = true;
1725
1735
  }
@@ -1734,8 +1744,8 @@ Update complete: ${staged.version}
1734
1744
  process.stdout.write(`\u2713 wrappers refreshed (${installManifest.cliWrappers.length} files)
1735
1745
  `);
1736
1746
  const { rmSync: rmSync2, cpSync, readdirSync: readdirSync3 } = await import("node:fs");
1737
- const skillsCoreSrc = join9(staged.stagedPath, "core", "skills");
1738
- const skillsCoreDst = join9(paths.home, "skills", "core");
1747
+ const skillsCoreSrc = join10(staged.stagedPath, "core", "skills");
1748
+ const skillsCoreDst = join10(paths.home, "skills", "core");
1739
1749
  if (existsSync7(skillsCoreSrc)) {
1740
1750
  rmSync2(skillsCoreDst, { recursive: true, force: true });
1741
1751
  cpSync(skillsCoreSrc, skillsCoreDst, { recursive: true });
@@ -1745,30 +1755,30 @@ Update complete: ${staged.version}
1745
1755
  `);
1746
1756
  }
1747
1757
  for (const d of ["custom", "downloaded", "self"]) {
1748
- await mkdir4(join9(paths.home, "skills", d), { recursive: true });
1758
+ await mkdir4(join10(paths.home, "skills", d), { recursive: true });
1749
1759
  }
1750
1760
  for (const stale of ["memory", "ops", "tools", "coding"]) {
1751
- const p = join9(paths.home, "skills", stale);
1761
+ const p = join10(paths.home, "skills", stale);
1752
1762
  if (existsSync7(p)) {
1753
1763
  rmSync2(p, { recursive: true, force: true });
1754
1764
  }
1755
1765
  }
1756
- const releaseConfig = join9(staged.stagedPath, "config");
1757
- const destConfig = join9(paths.home, "config");
1766
+ const releaseConfig = join10(staged.stagedPath, "config");
1767
+ const destConfig = join10(paths.home, "config");
1758
1768
  if (existsSync7(releaseConfig)) {
1759
1769
  for (const f of readdirSync3(releaseConfig)) {
1760
- const src = join9(releaseConfig, f);
1770
+ const src = join10(releaseConfig, f);
1761
1771
  if (f.endsWith(".example")) {
1762
- cpSync(src, join9(destConfig, f));
1763
- const target = join9(destConfig, f.replace(".example", ""));
1772
+ cpSync(src, join10(destConfig, f));
1773
+ const target = join10(destConfig, f.replace(".example", ""));
1764
1774
  if (!existsSync7(target)) cpSync(src, target);
1765
1775
  }
1766
1776
  }
1767
- const defaultTransport = join9(releaseConfig, "transport.default.json");
1768
- if (existsSync7(defaultTransport)) cpSync(defaultTransport, join9(destConfig, "transport.default.json"));
1777
+ const defaultTransport = join10(releaseConfig, "transport.default.json");
1778
+ if (existsSync7(defaultTransport)) cpSync(defaultTransport, join10(destConfig, "transport.default.json"));
1769
1779
  }
1770
- const coreSrc = join9(staged.stagedPath, "core");
1771
- const coreDst = join9(paths.home, "core");
1780
+ const coreSrc = join10(staged.stagedPath, "core");
1781
+ const coreDst = join10(paths.home, "core");
1772
1782
  if (existsSync7(coreSrc)) {
1773
1783
  await mkdir4(coreDst, { recursive: true });
1774
1784
  cpSync(coreSrc, coreDst, { recursive: true });
@@ -1789,7 +1799,7 @@ Update complete: ${staged.version}
1789
1799
  process.stdout.write(`\u2713 invariants: ${invariantResults.join(", ")}
1790
1800
  `);
1791
1801
  }
1792
- const doctorPath = join9(paths.home, "scripts", "doctor.sh");
1802
+ const doctorPath = join10(paths.home, "scripts", "doctor.sh");
1793
1803
  if (existsSync7(doctorPath)) {
1794
1804
  process.stdout.write("\n\u{1FA7A} Health check...\n");
1795
1805
  try {
@@ -1808,7 +1818,7 @@ Update complete: ${staged.version}
1808
1818
  }
1809
1819
  if (restartMode === "supervised-daemon" || restartMode === "supervised") {
1810
1820
  process.stdout.write("\nRestarting bridge via watchdog...\n");
1811
- const wdLock = join9(paths.home, "watchdog.lock");
1821
+ const wdLock = join10(paths.home, "watchdog.lock");
1812
1822
  const wdPid = readJsonField2(wdLock, "pid");
1813
1823
  if (wdPid && wdPid > 0) {
1814
1824
  try {