@integrity-labs/agt-cli 0.28.263 → 0.28.265

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.
@@ -37,7 +37,7 @@ import {
37
37
  requireHost,
38
38
  safeWriteJsonAtomic,
39
39
  setConfigHash
40
- } from "../chunk-77QMM7RI.js";
40
+ } from "../chunk-PDE3XSVC.js";
41
41
  import {
42
42
  getProjectDir as getProjectDir2,
43
43
  getReadyTasks,
@@ -122,16 +122,16 @@ import {
122
122
  takeZombieDetection,
123
123
  transcriptActivityAgeSeconds,
124
124
  writeEgressAllowlist
125
- } from "../chunk-E45AAMBQ.js";
125
+ } from "../chunk-MWKR6B3T.js";
126
126
  import {
127
127
  reapOrphanChannelMcps
128
128
  } from "../chunk-XWVM4KPK.js";
129
129
 
130
130
  // src/lib/manager-worker.ts
131
131
  import { createHash as createHash11 } from "crypto";
132
- import { readFileSync as readFileSync14, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6, existsSync as existsSync8, rmSync as rmSync4, readdirSync as readdirSync5, statSync as statSync4, copyFileSync } from "fs";
132
+ import { readFileSync as readFileSync15, writeFileSync as writeFileSync7, mkdirSync as mkdirSync7, existsSync as existsSync9, rmSync as rmSync4, readdirSync as readdirSync5, statSync as statSync4, copyFileSync } from "fs";
133
133
  import { execFileSync as syncExecFile } from "child_process";
134
- import { join as join16, dirname as dirname5 } from "path";
134
+ import { join as join17, dirname as dirname6 } from "path";
135
135
  import { homedir as homedir9 } from "os";
136
136
  import { fileURLToPath } from "url";
137
137
 
@@ -3432,7 +3432,7 @@ function clearAgentState(agentId, codeName) {
3432
3432
  function sanitizeGlobalSkillId(codeName) {
3433
3433
  return codeName.trim().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
3434
3434
  }
3435
- function planGlobalSkillSync(globalSkills, prevIds, hashOf, knownHash) {
3435
+ function planGlobalSkillSync(globalSkills, prevIds, hashOf, knownHash, options) {
3436
3436
  const currentIds = /* @__PURE__ */ new Set();
3437
3437
  const installs = [];
3438
3438
  for (const gs of globalSkills ?? []) {
@@ -3446,14 +3446,44 @@ function planGlobalSkillSync(globalSkills, prevIds, hashOf, knownHash) {
3446
3446
  if (knownHash(skillId) === hash) continue;
3447
3447
  installs.push({ skillId, content, hash });
3448
3448
  }
3449
- const removes = [...prevIds].filter((id) => !currentIds.has(id));
3449
+ const desiredResolved = options?.desiredResolved ?? true;
3450
+ const removes = desiredResolved ? [...prevIds].filter((id) => !currentIds.has(id)) : [];
3450
3451
  return { installs, removes, currentIds };
3451
3452
  }
3452
3453
 
3454
+ // src/lib/manager/managed-skill-manifest.ts
3455
+ import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync11, writeFileSync as writeFileSync5 } from "fs";
3456
+ import { dirname as dirname4, join as join11 } from "path";
3457
+ var MANIFEST_VERSION = 1;
3458
+ function managedSkillManifestPath(agentRootDir) {
3459
+ return join11(agentRootDir, "managed-skills.json");
3460
+ }
3461
+ function readManagedSkillManifest(path) {
3462
+ try {
3463
+ if (!existsSync4(path)) return /* @__PURE__ */ new Set();
3464
+ const parsed = JSON.parse(readFileSync11(path, "utf-8"));
3465
+ const ids = Array.isArray(parsed?.globalSkillIds) ? parsed.globalSkillIds : [];
3466
+ return new Set(ids.filter((id) => typeof id === "string" && id.length > 0));
3467
+ } catch {
3468
+ return /* @__PURE__ */ new Set();
3469
+ }
3470
+ }
3471
+ function writeManagedSkillManifest(path, ids) {
3472
+ try {
3473
+ mkdirSync4(dirname4(path), { recursive: true });
3474
+ const body = {
3475
+ version: MANIFEST_VERSION,
3476
+ globalSkillIds: [...ids].sort()
3477
+ };
3478
+ writeFileSync5(path, JSON.stringify(body, null, 2));
3479
+ } catch {
3480
+ }
3481
+ }
3482
+
3453
3483
  // src/lib/manager/runtime.ts
3454
3484
  import { createHash as createHash6 } from "crypto";
3455
- import { readFileSync as readFileSync11, appendFileSync, mkdirSync as mkdirSync4, chmodSync, existsSync as existsSync4 } from "fs";
3456
- import { join as join11, dirname as dirname4 } from "path";
3485
+ import { readFileSync as readFileSync12, appendFileSync, mkdirSync as mkdirSync5, chmodSync, existsSync as existsSync5 } from "fs";
3486
+ import { join as join12, dirname as dirname5 } from "path";
3457
3487
  import { homedir as homedir5 } from "os";
3458
3488
  function redactForDiskLog(value) {
3459
3489
  try {
@@ -3474,9 +3504,9 @@ function log(msg) {
3474
3504
  `;
3475
3505
  if (!managerLogPath) {
3476
3506
  try {
3477
- managerLogPath = join11(homedir5(), ".augmented", "manager.log");
3478
- mkdirSync4(dirname4(managerLogPath), { recursive: true });
3479
- if (existsSync4(managerLogPath)) {
3507
+ managerLogPath = join12(homedir5(), ".augmented", "manager.log");
3508
+ mkdirSync5(dirname5(managerLogPath), { recursive: true });
3509
+ if (existsSync5(managerLogPath)) {
3480
3510
  chmodSync(managerLogPath, 384);
3481
3511
  }
3482
3512
  } catch {
@@ -3504,7 +3534,7 @@ function sha256(content) {
3504
3534
  }
3505
3535
  function hashFile(filePath) {
3506
3536
  try {
3507
- const content = readFileSync11(filePath, "utf-8");
3537
+ const content = readFileSync12(filePath, "utf-8");
3508
3538
  return sha256(content);
3509
3539
  } catch {
3510
3540
  return null;
@@ -3662,8 +3692,8 @@ function resolveModelChain(refreshData) {
3662
3692
  }
3663
3693
 
3664
3694
  // src/lib/manager/claude-auth.ts
3665
- import { existsSync as existsSync5, rmSync as rmSync2 } from "fs";
3666
- import { join as join12 } from "path";
3695
+ import { existsSync as existsSync6, rmSync as rmSync2 } from "fs";
3696
+ import { join as join13 } from "path";
3667
3697
  import { homedir as homedir6 } from "os";
3668
3698
  async function applyClaudeAuthToEnv(childEnv, label) {
3669
3699
  const apiKey = getApiKey();
@@ -3676,10 +3706,10 @@ async function applyClaudeAuthToEnv(childEnv, label) {
3676
3706
  throw new Error("claude_auth_mode=api_key but /host/exchange returned no decrypted key");
3677
3707
  }
3678
3708
  childEnv.ANTHROPIC_API_KEY = exchange.anthropicApiKey;
3679
- const claudeDir = join12(homedir6(), ".claude");
3709
+ const claudeDir = join13(homedir6(), ".claude");
3680
3710
  for (const filename of [".credentials.json", "credentials.json"]) {
3681
- const p = join12(claudeDir, filename);
3682
- if (existsSync5(p)) {
3711
+ const p = join13(claudeDir, filename);
3712
+ if (existsSync6(p)) {
3683
3713
  try {
3684
3714
  rmSync2(p, { force: true });
3685
3715
  log(`[${label}] Removed ${p} (api_key mode \u2014 preventing OAuth fallback)`);
@@ -3693,8 +3723,8 @@ async function applyClaudeAuthToEnv(childEnv, label) {
3693
3723
  }
3694
3724
 
3695
3725
  // src/lib/manager/kanban/parsers.ts
3696
- import { existsSync as existsSync6, readFileSync as readFileSync12 } from "fs";
3697
- import { join as join13 } from "path";
3726
+ import { existsSync as existsSync7, readFileSync as readFileSync13 } from "fs";
3727
+ import { join as join14 } from "path";
3698
3728
  var STANDUP_TEMPLATES = /* @__PURE__ */ new Set(["daily-standup", "end-of-day-summary"]);
3699
3729
  var TASK_UPDATE_TEMPLATES = /* @__PURE__ */ new Set(["hourly-status", "task-update"]);
3700
3730
  var PLAN_TEMPLATES = /* @__PURE__ */ new Set(["morning-plan"]);
@@ -3818,12 +3848,12 @@ function getBuiltInSkillContent(skillId) {
3818
3848
  if (builtInSkillCache.has(skillId)) return builtInSkillCache.get(skillId);
3819
3849
  try {
3820
3850
  const candidates = [
3821
- join13(process.cwd(), "skills", skillId, "SKILL.md"),
3822
- join13(new URL(".", import.meta.url).pathname, "..", "..", "..", "..", "..", "..", "skills", skillId, "SKILL.md")
3851
+ join14(process.cwd(), "skills", skillId, "SKILL.md"),
3852
+ join14(new URL(".", import.meta.url).pathname, "..", "..", "..", "..", "..", "..", "skills", skillId, "SKILL.md")
3823
3853
  ];
3824
3854
  for (const candidate of candidates) {
3825
- if (existsSync6(candidate)) {
3826
- const content = readFileSync12(candidate, "utf-8");
3855
+ if (existsSync7(candidate)) {
3856
+ const content = readFileSync13(candidate, "utf-8");
3827
3857
  const files = [{ relativePath: "SKILL.md", content }];
3828
3858
  builtInSkillCache.set(skillId, files);
3829
3859
  return files;
@@ -4956,9 +4986,9 @@ async function processClaudeTaskResult(codeName, agentId, templateId, rawOutput,
4956
4986
  // src/lib/manager/scheduler/execution.ts
4957
4987
  import { createHash as createHash10 } from "crypto";
4958
4988
  import { homedir as homedir7 } from "os";
4959
- import { join as join14 } from "path";
4989
+ import { join as join15 } from "path";
4960
4990
  function claudePidFilePath() {
4961
- return join14(homedir7(), ".augmented", "manager-claude-pids.json");
4991
+ return join15(homedir7(), ".augmented", "manager-claude-pids.json");
4962
4992
  }
4963
4993
  var inFlightClaudePids = /* @__PURE__ */ new Map();
4964
4994
  function registerClaudeSpawn(record) {
@@ -5158,24 +5188,24 @@ function partitionActionableByPoison(actionable, states, config2) {
5158
5188
  }
5159
5189
 
5160
5190
  // src/lib/restart-flags.ts
5161
- import { existsSync as existsSync7, mkdirSync as mkdirSync5, readdirSync as readdirSync4, readFileSync as readFileSync13, renameSync, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "fs";
5191
+ import { existsSync as existsSync8, mkdirSync as mkdirSync6, readdirSync as readdirSync4, readFileSync as readFileSync14, renameSync, rmSync as rmSync3, writeFileSync as writeFileSync6 } from "fs";
5162
5192
  import { homedir as homedir8 } from "os";
5163
- import { join as join15 } from "path";
5193
+ import { join as join16 } from "path";
5164
5194
  import { randomUUID } from "crypto";
5165
5195
  function restartFlagsDir() {
5166
- return join15(homedir8(), ".augmented", "restart-flags");
5196
+ return join16(homedir8(), ".augmented", "restart-flags");
5167
5197
  }
5168
5198
  function flagPath(codeName) {
5169
- return join15(restartFlagsDir(), `${codeName}.flag`);
5199
+ return join16(restartFlagsDir(), `${codeName}.flag`);
5170
5200
  }
5171
5201
  function readRestartFlags() {
5172
5202
  const dir = restartFlagsDir();
5173
- if (!existsSync7(dir)) return [];
5203
+ if (!existsSync8(dir)) return [];
5174
5204
  const out = [];
5175
5205
  for (const entry of readdirSync4(dir)) {
5176
5206
  if (!entry.endsWith(".flag")) continue;
5177
5207
  try {
5178
- const raw = readFileSync13(join15(dir, entry), "utf8");
5208
+ const raw = readFileSync14(join16(dir, entry), "utf8");
5179
5209
  const parsed = JSON.parse(raw);
5180
5210
  if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
5181
5211
  parsed.codeName = entry.replace(/\.flag$/, "");
@@ -5193,7 +5223,7 @@ function readRestartFlags() {
5193
5223
  }
5194
5224
  function deleteRestartFlag(codeName) {
5195
5225
  const path = flagPath(codeName);
5196
- if (existsSync7(path)) {
5226
+ if (existsSync8(path)) {
5197
5227
  rmSync3(path, { force: true });
5198
5228
  }
5199
5229
  }
@@ -6354,7 +6384,7 @@ var runningMcpServerKeys = /* @__PURE__ */ new Map();
6354
6384
  var runningChannelSecretHashes = /* @__PURE__ */ new Map();
6355
6385
  function projectMcpHash(_codeName, projectDir) {
6356
6386
  try {
6357
- const raw = readFileSync14(join16(projectDir, ".mcp.json"), "utf-8");
6387
+ const raw = readFileSync15(join17(projectDir, ".mcp.json"), "utf-8");
6358
6388
  return createHash11("sha256").update(canonicalJson(JSON.parse(raw))).digest("hex");
6359
6389
  } catch {
6360
6390
  return null;
@@ -6362,7 +6392,7 @@ function projectMcpHash(_codeName, projectDir) {
6362
6392
  }
6363
6393
  function projectMcpKeys(_codeName, projectDir) {
6364
6394
  try {
6365
- const raw = readFileSync14(join16(projectDir, ".mcp.json"), "utf-8");
6395
+ const raw = readFileSync15(join17(projectDir, ".mcp.json"), "utf-8");
6366
6396
  const parsed = JSON.parse(raw);
6367
6397
  const servers = parsed.mcpServers;
6368
6398
  if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
@@ -6456,7 +6486,7 @@ async function runAgentSessionToolBindProbes(agent, integrations, projectDir, op
6456
6486
  if (result && result.rebindCandidates.length > 0 && hostFlagStore().getBoolean("session-tool-rebind")) {
6457
6487
  let mcpJsonForRebind = null;
6458
6488
  try {
6459
- mcpJsonForRebind = JSON.parse(readFileSync14(join16(projectDir, ".mcp.json"), "utf-8"));
6489
+ mcpJsonForRebind = JSON.parse(readFileSync15(join17(projectDir, ".mcp.json"), "utf-8"));
6460
6490
  } catch {
6461
6491
  mcpJsonForRebind = null;
6462
6492
  }
@@ -6584,7 +6614,7 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
6584
6614
  function projectChannelSecretHash(projectDir) {
6585
6615
  try {
6586
6616
  const entries = parseEnvIntegrations(
6587
- readFileSync14(join16(projectDir, ".env.integrations"), "utf-8")
6617
+ readFileSync15(join17(projectDir, ".env.integrations"), "utf-8")
6588
6618
  );
6589
6619
  return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
6590
6620
  } catch {
@@ -6669,7 +6699,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
6669
6699
  var lastVersionCheckAt = 0;
6670
6700
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
6671
6701
  var lastResponsivenessProbeAt = 0;
6672
- var agtCliVersion = true ? "0.28.263" : "dev";
6702
+ var agtCliVersion = true ? "0.28.265" : "dev";
6673
6703
  function resolveBrewPath(execFileSync2) {
6674
6704
  try {
6675
6705
  const out = execFileSync2("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -6682,7 +6712,7 @@ function resolveBrewPath(execFileSync2) {
6682
6712
  "/usr/local/bin/brew"
6683
6713
  ];
6684
6714
  for (const path of fallbacks) {
6685
- if (existsSync8(path)) return path;
6715
+ if (existsSync9(path)) return path;
6686
6716
  }
6687
6717
  return null;
6688
6718
  }
@@ -6692,7 +6722,7 @@ function claudeBinaryInstalled(execFileSync2) {
6692
6722
  "/opt/homebrew/bin/claude",
6693
6723
  "/usr/local/bin/claude"
6694
6724
  ];
6695
- if (canonical.some((path) => existsSync8(path))) return true;
6725
+ if (canonical.some((path) => existsSync9(path))) return true;
6696
6726
  try {
6697
6727
  execFileSync2("which", ["claude"], { timeout: 5e3 });
6698
6728
  return true;
@@ -6764,7 +6794,7 @@ async function ensureToolkitCli(toolkitSlug) {
6764
6794
  toolkitCliEnsured.add(toolkitSlug);
6765
6795
  return;
6766
6796
  }
6767
- brewBinDir = dirname5(brewPath);
6797
+ brewBinDir = dirname6(brewPath);
6768
6798
  const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
6769
6799
  log(`[toolkit-install] ${toolkitSlug}: installing via brew (${pkg})\u2026`);
6770
6800
  if (isRoot) {
@@ -6845,8 +6875,8 @@ function claudeManagedSettingsPath() {
6845
6875
  function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
6846
6876
  try {
6847
6877
  let settings = {};
6848
- if (existsSync8(path)) {
6849
- const raw = readFileSync14(path, "utf-8").trim();
6878
+ if (existsSync9(path)) {
6879
+ const raw = readFileSync15(path, "utf-8").trim();
6850
6880
  if (raw) {
6851
6881
  let parsed;
6852
6882
  try {
@@ -6862,8 +6892,8 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
6862
6892
  }
6863
6893
  if (settings.channelsEnabled === true) return "ok";
6864
6894
  settings.channelsEnabled = true;
6865
- mkdirSync6(dirname5(path), { recursive: true });
6866
- writeFileSync6(path, `${JSON.stringify(settings, null, 2)}
6895
+ mkdirSync7(dirname6(path), { recursive: true });
6896
+ writeFileSync7(path, `${JSON.stringify(settings, null, 2)}
6867
6897
  `);
6868
6898
  log(`[managed-settings] set channelsEnabled:true in ${path} (ENG-5786 \u2014 unblocks Claude Code channels)`);
6869
6899
  return "ok";
@@ -6904,11 +6934,11 @@ async function ensureFrameworkBinary(frameworkId) {
6904
6934
  log(`Claude Code install failed: ${err.message}`);
6905
6935
  return;
6906
6936
  }
6907
- const brewBinDir = dirname5(brewPath);
6937
+ const brewBinDir = dirname6(brewPath);
6908
6938
  if (!process.env.PATH?.split(":").includes(brewBinDir)) {
6909
6939
  process.env.PATH = `${brewBinDir}:${process.env.PATH ?? ""}`;
6910
6940
  }
6911
- if (existsSync8("/home/linuxbrew/.linuxbrew/bin/claude")) {
6941
+ if (existsSync9("/home/linuxbrew/.linuxbrew/bin/claude")) {
6912
6942
  log("Claude Code installed successfully");
6913
6943
  } else {
6914
6944
  log("Claude Code install completed but binary not found at expected path \u2014 check brew logs");
@@ -6964,7 +6994,7 @@ ${r.stderr}`;
6964
6994
  }
6965
6995
  var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
6966
6996
  function selfUpdateAppliedMarkerPath() {
6967
- return join16(homedir9(), ".augmented", ".last-self-update-applied");
6997
+ return join17(homedir9(), ".augmented", ".last-self-update-applied");
6968
6998
  }
6969
6999
  var selfUpdateUpToDateLogged = false;
6970
7000
  var restartAfterUpgrade = false;
@@ -6988,7 +7018,7 @@ async function checkAndUpdateCli(opts) {
6988
7018
  const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
6989
7019
  if (!isBrewFormula && !isNpmGlobal) return "noop";
6990
7020
  const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
6991
- const markerPath = join16(homedir9(), ".augmented", ".last-update-check");
7021
+ const markerPath = join17(homedir9(), ".augmented", ".last-update-check");
6992
7022
  if (!force) {
6993
7023
  try {
6994
7024
  const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
@@ -7266,14 +7296,14 @@ async function checkClaudeAuth() {
7266
7296
  }
7267
7297
  var evalEmptyMcpConfigPath = null;
7268
7298
  function ensureEvalEmptyMcpConfig() {
7269
- if (evalEmptyMcpConfigPath && existsSync8(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
7270
- const dir = join16(homedir9(), ".augmented");
7299
+ if (evalEmptyMcpConfigPath && existsSync9(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
7300
+ const dir = join17(homedir9(), ".augmented");
7271
7301
  try {
7272
- mkdirSync6(dir, { recursive: true });
7302
+ mkdirSync7(dir, { recursive: true });
7273
7303
  } catch {
7274
7304
  }
7275
- const p = join16(dir, ".eval-empty-mcp.json");
7276
- writeFileSync6(p, JSON.stringify({ mcpServers: {} }));
7305
+ const p = join17(dir, ".eval-empty-mcp.json");
7306
+ writeFileSync7(p, JSON.stringify({ mcpServers: {} }));
7277
7307
  evalEmptyMcpConfigPath = p;
7278
7308
  return p;
7279
7309
  }
@@ -7364,10 +7394,10 @@ function resolveConversationEvalBackend() {
7364
7394
  return conversationEvalBackend;
7365
7395
  }
7366
7396
  function getStateFile() {
7367
- return join16(config?.configDir ?? join16(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
7397
+ return join17(config?.configDir ?? join17(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
7368
7398
  }
7369
7399
  function channelHashCacheDir() {
7370
- return config?.configDir ?? join16(process.env["HOME"] ?? "/tmp", ".augmented");
7400
+ return config?.configDir ?? join17(process.env["HOME"] ?? "/tmp", ".augmented");
7371
7401
  }
7372
7402
  function loadChannelHashCache2() {
7373
7403
  loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
@@ -7378,7 +7408,7 @@ function saveChannelHashCache2() {
7378
7408
  var _channelQuarantineStore = null;
7379
7409
  function channelQuarantineStore() {
7380
7410
  if (!_channelQuarantineStore) {
7381
- const dir = config?.configDir ?? join16(process.env["HOME"] ?? "/tmp", ".augmented");
7411
+ const dir = config?.configDir ?? join17(process.env["HOME"] ?? "/tmp", ".augmented");
7382
7412
  _channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
7383
7413
  }
7384
7414
  return _channelQuarantineStore;
@@ -7386,7 +7416,7 @@ function channelQuarantineStore() {
7386
7416
  var _hostFlagStore = null;
7387
7417
  function hostFlagStore() {
7388
7418
  if (!_hostFlagStore) {
7389
- const dir = config?.configDir ?? join16(process.env["HOME"] ?? "/tmp", ".augmented");
7419
+ const dir = config?.configDir ?? join17(process.env["HOME"] ?? "/tmp", ".augmented");
7390
7420
  _hostFlagStore = new HostFlagStore({ cachePath: defaultFlagsCachePath(dir), log });
7391
7421
  }
7392
7422
  return _hostFlagStore;
@@ -7453,13 +7483,13 @@ function parseSkillFrontmatter(content) {
7453
7483
  return out;
7454
7484
  }
7455
7485
  async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
7456
- const { readdirSync: readdirSync6, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync7 } = await import("fs");
7457
- const skillsDir = join16(configDir, codeName, "project", ".claude", "skills");
7458
- const claudeMdPath = join16(configDir, codeName, "project", "CLAUDE.md");
7486
+ const { readdirSync: readdirSync6, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync8 } = await import("fs");
7487
+ const skillsDir = join17(configDir, codeName, "project", ".claude", "skills");
7488
+ const claudeMdPath = join17(configDir, codeName, "project", "CLAUDE.md");
7459
7489
  if (!ex(skillsDir) || !ex(claudeMdPath)) return;
7460
7490
  const entries = [];
7461
7491
  for (const dir of readdirSync6(skillsDir).sort()) {
7462
- const skillFile = join16(skillsDir, dir, "SKILL.md");
7492
+ const skillFile = join17(skillsDir, dir, "SKILL.md");
7463
7493
  if (!ex(skillFile)) continue;
7464
7494
  try {
7465
7495
  const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
@@ -7501,7 +7531,7 @@ ${SKILLS_INDEX_END}`;
7501
7531
  next = current.trimEnd() + "\n\n" + section + "\n";
7502
7532
  }
7503
7533
  if (next !== current) {
7504
- writeFileSync7(claudeMdPath, next, "utf-8");
7534
+ writeFileSync8(claudeMdPath, next, "utf-8");
7505
7535
  log2(`Refreshed skills index in CLAUDE.md for '${codeName}' (${entries.length} skills)`);
7506
7536
  }
7507
7537
  }
@@ -7519,7 +7549,7 @@ function flushRestartedAgentDiagnostics(hostId, codeNames) {
7519
7549
  if (codeNames.length === 0) return;
7520
7550
  void (async () => {
7521
7551
  try {
7522
- const { collectDiagnostics } = await import("../persistent-session-OP4TXILO.js");
7552
+ const { collectDiagnostics } = await import("../persistent-session-K5RJ4BVF.js");
7523
7553
  await api.post("/host/heartbeat", {
7524
7554
  host_id: hostId,
7525
7555
  agent_diagnostics: collectDiagnostics(codeNames)
@@ -7617,7 +7647,7 @@ async function pollCycle() {
7617
7647
  }
7618
7648
  try {
7619
7649
  const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
7620
- const { collectDiagnostics } = await import("../persistent-session-OP4TXILO.js");
7650
+ const { collectDiagnostics } = await import("../persistent-session-K5RJ4BVF.js");
7621
7651
  const diagCodeNames = [...agentState.persistentSessionAgents];
7622
7652
  const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames) : void 0;
7623
7653
  let tailscaleHostname;
@@ -7765,7 +7795,7 @@ async function pollCycle() {
7765
7795
  const {
7766
7796
  collectResponsivenessProbes,
7767
7797
  getResponsivenessIntervalMs
7768
- } = await import("../responsiveness-probe-K2RGVZCR.js");
7798
+ } = await import("../responsiveness-probe-2PHY7QKJ.js");
7769
7799
  const probeIntervalMs = getResponsivenessIntervalMs();
7770
7800
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
7771
7801
  const probeCodeNames = [...agentState.persistentSessionAgents];
@@ -7797,7 +7827,7 @@ async function pollCycle() {
7797
7827
  collectResponsivenessProbes,
7798
7828
  livePendingInboundOldestAgeSeconds,
7799
7829
  parkPendingInbound
7800
- } = await import("../responsiveness-probe-K2RGVZCR.js");
7830
+ } = await import("../responsiveness-probe-2PHY7QKJ.js");
7801
7831
  const { getProjectDir: wedgeProjectDir } = await import("../claude-scheduler-FATCLHDM.js");
7802
7832
  const wedgeNow = /* @__PURE__ */ new Date();
7803
7833
  const liveAgents = agentState.persistentSessionAgents;
@@ -7886,13 +7916,13 @@ async function pollCycle() {
7886
7916
  );
7887
7917
  if (hostFlagStore().getBoolean("wedge-transient-notice")) {
7888
7918
  try {
7889
- const paneTail = readFileSync14(paneLogPath(codeName), "utf8").slice(-65536);
7919
+ const paneTail = readFileSync15(paneLogPath(codeName), "utf8").slice(-65536);
7890
7920
  const transient = detectTransientApiErrorInLog(paneTail);
7891
7921
  if (transient) {
7892
- const wedgeHome = join16(homedir9(), ".augmented", codeName);
7893
- if (existsSync8(wedgeHome)) {
7922
+ const wedgeHome = join17(homedir9(), ".augmented", codeName);
7923
+ if (existsSync9(wedgeHome)) {
7894
7924
  atomicWriteFileSync(
7895
- join16(wedgeHome, "watchdog-give-up.json"),
7925
+ join17(wedgeHome, "watchdog-give-up.json"),
7896
7926
  JSON.stringify({
7897
7927
  gave_up_at: wedgeNow.toISOString(),
7898
7928
  reason: "transient_overload"
@@ -8123,7 +8153,7 @@ async function pollCycle() {
8123
8153
  } catch {
8124
8154
  }
8125
8155
  killAgentChannelProcesses(prev.codeName, { log });
8126
- const agentDir = join16(adapter.getAgentDir(prev.codeName), "provision");
8156
+ const agentDir = join17(adapter.getAgentDir(prev.codeName), "provision");
8127
8157
  await cleanupAgentFiles(prev.codeName, agentDir);
8128
8158
  clearAgentCaches(prev.agentId, prev.codeName);
8129
8159
  }
@@ -8210,10 +8240,10 @@ async function pollCycle() {
8210
8240
  // pending-inbound marker. Best-effort: a write failure is logged by
8211
8241
  // the watchdog, never fails the poll cycle.
8212
8242
  signalGiveUp: (codeName) => {
8213
- const dir = join16(homedir9(), ".augmented", codeName);
8214
- if (!existsSync8(dir)) return;
8243
+ const dir = join17(homedir9(), ".augmented", codeName);
8244
+ if (!existsSync9(dir)) return;
8215
8245
  atomicWriteFileSync(
8216
- join16(dir, "watchdog-give-up.json"),
8246
+ join17(dir, "watchdog-give-up.json"),
8217
8247
  JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
8218
8248
  );
8219
8249
  }
@@ -8343,7 +8373,7 @@ async function processAgent(agent, agentStates) {
8343
8373
  }
8344
8374
  const now = (/* @__PURE__ */ new Date()).toISOString();
8345
8375
  const adapter = resolveAgentFramework(agent.code_name);
8346
- let agentDir = join16(adapter.getAgentDir(agent.code_name), "provision");
8376
+ let agentDir = join17(adapter.getAgentDir(agent.code_name), "provision");
8347
8377
  if (agent.status === "draft" || agent.status === "paused") {
8348
8378
  if (previousKnownStatus !== agent.status) {
8349
8379
  log(`Agent '${agent.code_name}' is ${agent.status}, skipping provisioning`);
@@ -8389,7 +8419,7 @@ async function processAgent(agent, agentStates) {
8389
8419
  const residuals = {
8390
8420
  gatewayRunning: false,
8391
8421
  portAllocated: false,
8392
- provisionDirExists: existsSync8(agentDir)
8422
+ provisionDirExists: existsSync9(agentDir)
8393
8423
  };
8394
8424
  if (!hasRevokedResiduals(residuals)) {
8395
8425
  agentStates.push({
@@ -8527,7 +8557,7 @@ async function processAgent(agent, agentStates) {
8527
8557
  const frameworkId = refreshData.agent.framework ?? DEFAULT_FRAMEWORK;
8528
8558
  agentFrameworkCache.set(agent.code_name, frameworkId);
8529
8559
  const frameworkAdapter = getFramework(frameworkId);
8530
- agentDir = join16(frameworkAdapter.getAgentDir(agent.code_name), "provision");
8560
+ agentDir = join17(frameworkAdapter.getAgentDir(agent.code_name), "provision");
8531
8561
  cacheAgentDeliveryMetadata(agent.code_name, refreshData);
8532
8562
  agentRestartTimezoneInputs.set(agent.code_name, {
8533
8563
  agentTimezone: typeof refreshData.agent.timezone === "string" ? refreshData.agent.timezone : null,
@@ -8572,9 +8602,9 @@ async function processAgent(agent, agentStates) {
8572
8602
  try {
8573
8603
  const artifacts = generateArtifacts(agent, refreshData, frameworkAdapter);
8574
8604
  const changedFiles = [];
8575
- mkdirSync6(agentDir, { recursive: true });
8605
+ mkdirSync7(agentDir, { recursive: true });
8576
8606
  for (const artifact of artifacts) {
8577
- const filePath = join16(agentDir, artifact.relativePath);
8607
+ const filePath = join17(agentDir, artifact.relativePath);
8578
8608
  let existingHash;
8579
8609
  let newHash;
8580
8610
  let writeContent = artifact.content;
@@ -8593,8 +8623,8 @@ async function processAgent(agent, agentStates) {
8593
8623
  };
8594
8624
  newHash = sha256(stripDynamicSections(artifact.content));
8595
8625
  try {
8596
- const projectClaudeMd = join16(config.configDir, agent.code_name, "project", "CLAUDE.md");
8597
- const existing = readFileSync14(projectClaudeMd, "utf-8");
8626
+ const projectClaudeMd = join17(config.configDir, agent.code_name, "project", "CLAUDE.md");
8627
+ const existing = readFileSync15(projectClaudeMd, "utf-8");
8598
8628
  existingHash = sha256(stripDynamicSections(existing));
8599
8629
  } catch {
8600
8630
  existingHash = null;
@@ -8612,7 +8642,7 @@ async function processAgent(agent, agentStates) {
8612
8642
  const generatorKeys = Object.keys(generatorServers);
8613
8643
  let existingRaw = "";
8614
8644
  try {
8615
- existingRaw = readFileSync14(filePath, "utf-8");
8645
+ existingRaw = readFileSync15(filePath, "utf-8");
8616
8646
  } catch {
8617
8647
  }
8618
8648
  const existingServers = parseMcp(existingRaw);
@@ -8634,26 +8664,26 @@ async function processAgent(agent, agentStates) {
8634
8664
  }
8635
8665
  }
8636
8666
  if (changedFiles.length > 0) {
8637
- const isFirst = !existsSync8(join16(agentDir, "CHARTER.md"));
8667
+ const isFirst = !existsSync9(join17(agentDir, "CHARTER.md"));
8638
8668
  const verb = isFirst ? "Provisioning" : "Updating";
8639
8669
  const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
8640
8670
  log(`${verb} '${agent.code_name}': ${fileNames}`);
8641
8671
  for (const file of changedFiles) {
8642
- const filePath = join16(agentDir, file.relativePath);
8643
- mkdirSync6(dirname5(filePath), { recursive: true });
8672
+ const filePath = join17(agentDir, file.relativePath);
8673
+ mkdirSync7(dirname6(filePath), { recursive: true });
8644
8674
  if (file.relativePath === ".mcp.json") {
8645
8675
  safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
8646
8676
  } else {
8647
- writeFileSync6(filePath, file.content);
8677
+ writeFileSync7(filePath, file.content);
8648
8678
  }
8649
8679
  }
8650
8680
  try {
8651
- const provSkillsDir = join16(agentDir, ".claude", "skills");
8652
- if (existsSync8(provSkillsDir)) {
8681
+ const provSkillsDir = join17(agentDir, ".claude", "skills");
8682
+ if (existsSync9(provSkillsDir)) {
8653
8683
  for (const folder of readdirSync5(provSkillsDir)) {
8654
8684
  if (folder.startsWith("knowledge-")) {
8655
8685
  try {
8656
- rmSync4(join16(provSkillsDir, folder), { recursive: true });
8686
+ rmSync4(join17(provSkillsDir, folder), { recursive: true });
8657
8687
  } catch {
8658
8688
  }
8659
8689
  }
@@ -8666,7 +8696,7 @@ async function processAgent(agent, agentStates) {
8666
8696
  const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
8667
8697
  const hashes = /* @__PURE__ */ new Map();
8668
8698
  for (const file of trackedFiles2) {
8669
- const h = hashFile(join16(agentDir, file));
8699
+ const h = hashFile(join17(agentDir, file));
8670
8700
  if (h) hashes.set(file, h);
8671
8701
  }
8672
8702
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -8684,14 +8714,14 @@ async function processAgent(agent, agentStates) {
8684
8714
  }
8685
8715
  if (Array.isArray(refreshData.workflows)) {
8686
8716
  try {
8687
- const provWorkflowsDir = join16(agentDir, ".claude", "workflows");
8688
- if (existsSync8(provWorkflowsDir)) {
8717
+ const provWorkflowsDir = join17(agentDir, ".claude", "workflows");
8718
+ if (existsSync9(provWorkflowsDir)) {
8689
8719
  const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
8690
8720
  for (const file of readdirSync5(provWorkflowsDir)) {
8691
8721
  if (!file.endsWith(".js")) continue;
8692
8722
  if (expected.has(file)) continue;
8693
8723
  try {
8694
- rmSync4(join16(provWorkflowsDir, file));
8724
+ rmSync4(join17(provWorkflowsDir, file));
8695
8725
  } catch {
8696
8726
  }
8697
8727
  }
@@ -8748,10 +8778,10 @@ async function processAgent(agent, agentStates) {
8748
8778
  }
8749
8779
  let lastDriftCheckAt = now;
8750
8780
  const written = agentState.writtenHashes.get(agent.agent_id);
8751
- if (written && existsSync8(agentDir)) {
8781
+ if (written && existsSync9(agentDir)) {
8752
8782
  const driftedFiles = [];
8753
8783
  for (const [file, expectedHash] of written) {
8754
- const localHash = hashFile(join16(agentDir, file));
8784
+ const localHash = hashFile(join17(agentDir, file));
8755
8785
  if (localHash && localHash !== expectedHash) {
8756
8786
  driftedFiles.push(file);
8757
8787
  }
@@ -8762,7 +8792,7 @@ async function processAgent(agent, agentStates) {
8762
8792
  try {
8763
8793
  const localHashes = {};
8764
8794
  for (const file of driftedFiles) {
8765
- localHashes[file] = hashFile(join16(agentDir, file));
8795
+ localHashes[file] = hashFile(join17(agentDir, file));
8766
8796
  }
8767
8797
  await api.post("/host/drift", {
8768
8798
  agent_id: agent.agent_id,
@@ -8949,15 +8979,15 @@ async function processAgent(agent, agentStates) {
8949
8979
  const addedChannels = [...restartDecision.added];
8950
8980
  const writeDmNoticeMarkers = isChannelAddRestart ? () => {
8951
8981
  try {
8952
- const agentAugmentedDir = join16(homedir9(), ".augmented", agent.code_name);
8953
- mkdirSync6(agentAugmentedDir, { recursive: true });
8982
+ const agentAugmentedDir = join17(homedir9(), ".augmented", agent.code_name);
8983
+ mkdirSync7(agentAugmentedDir, { recursive: true });
8954
8984
  const markerJson = JSON.stringify({
8955
8985
  version: 1,
8956
8986
  at: (/* @__PURE__ */ new Date()).toISOString(),
8957
8987
  added: addedChannels
8958
8988
  });
8959
8989
  for (const file of ["slack-channel-add-restart.json", "telegram-channel-add-restart.json"]) {
8960
- atomicWriteFileSync(join16(agentAugmentedDir, file), markerJson);
8990
+ atomicWriteFileSync(join17(agentAugmentedDir, file), markerJson);
8961
8991
  }
8962
8992
  } catch (err) {
8963
8993
  log(`[hot-reload] channel-add DM-notice marker write failed for '${agent.code_name}' (non-fatal): ${err.message}`);
@@ -9110,24 +9140,24 @@ async function processAgent(agent, agentStates) {
9110
9140
  if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK) === "claude-code") {
9111
9141
  try {
9112
9142
  const agentProvisionDir = agentDir;
9113
- const projectDir = join16(homedir9(), ".augmented", agent.code_name, "project");
9114
- mkdirSync6(agentProvisionDir, { recursive: true });
9115
- mkdirSync6(projectDir, { recursive: true });
9116
- const provisionMcpPath = join16(agentProvisionDir, ".mcp.json");
9117
- const projectMcpPath = join16(projectDir, ".mcp.json");
9143
+ const projectDir = join17(homedir9(), ".augmented", agent.code_name, "project");
9144
+ mkdirSync7(agentProvisionDir, { recursive: true });
9145
+ mkdirSync7(projectDir, { recursive: true });
9146
+ const provisionMcpPath = join17(agentProvisionDir, ".mcp.json");
9147
+ const projectMcpPath = join17(projectDir, ".mcp.json");
9118
9148
  let mcpConfig = { mcpServers: {} };
9119
9149
  try {
9120
- mcpConfig = JSON.parse(readFileSync14(provisionMcpPath, "utf-8"));
9150
+ mcpConfig = JSON.parse(readFileSync15(provisionMcpPath, "utf-8"));
9121
9151
  if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
9122
9152
  } catch {
9123
9153
  }
9124
- const localDirectChatChannel = join16(homedir9(), ".augmented", "_mcp", "direct-chat-channel.js");
9154
+ const localDirectChatChannel = join17(homedir9(), ".augmented", "_mcp", "direct-chat-channel.js");
9125
9155
  const directChatTeamSettings = refreshData.team?.settings;
9126
9156
  const directChatTz = (() => {
9127
9157
  const tz = directChatTeamSettings?.["timezone"];
9128
9158
  return typeof tz === "string" && tz.trim() !== "" ? tz.trim() : void 0;
9129
9159
  })();
9130
- if (existsSync8(localDirectChatChannel)) {
9160
+ if (existsSync9(localDirectChatChannel)) {
9131
9161
  const directChatEnv = {
9132
9162
  AGT_HOST: requireHost(),
9133
9163
  // ENG-5901 Track D: templated — the manager exports the real
@@ -9147,7 +9177,7 @@ async function processAgent(agent, agentStates) {
9147
9177
  // ~/.augmented/<codeName>/.current-turn-initiator.json. Note getAgentDir
9148
9178
  // returns the agent root (NOT the /provision subdir `agentDir` points at),
9149
9179
  // so it byte-matches the broker readers' path.
9150
- AGT_TURN_INITIATOR_FILE: join16(
9180
+ AGT_TURN_INITIATOR_FILE: join17(
9151
9181
  frameworkAdapter.getAgentDir(agent.code_name),
9152
9182
  ".current-turn-initiator.json"
9153
9183
  )
@@ -9167,8 +9197,8 @@ async function processAgent(agent, agentStates) {
9167
9197
  log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
9168
9198
  }
9169
9199
  }
9170
- const staleChannelsPath = join16(projectDir, ".mcp-channels.json");
9171
- if (existsSync8(staleChannelsPath)) {
9200
+ const staleChannelsPath = join17(projectDir, ".mcp-channels.json");
9201
+ if (existsSync9(staleChannelsPath)) {
9172
9202
  try {
9173
9203
  rmSync4(staleChannelsPath, { force: true });
9174
9204
  } catch {
@@ -9235,7 +9265,7 @@ async function processAgent(agent, agentStates) {
9235
9265
  }
9236
9266
  if (hostFlagStore().getBoolean("connectivity-probe")) {
9237
9267
  try {
9238
- const probeProjectDir = join16(homedir9(), ".augmented", agent.code_name, "project");
9268
+ const probeProjectDir = join17(homedir9(), ".augmented", agent.code_name, "project");
9239
9269
  await runAgentConnectivityProbes(agent, integrations, probeProjectDir);
9240
9270
  } catch (err) {
9241
9271
  log(`Connectivity probe failed for '${agent.code_name}': ${err.message}`);
@@ -9246,7 +9276,7 @@ async function processAgent(agent, agentStates) {
9246
9276
  const forceDue = attemptsLeft > 0;
9247
9277
  let probeRan = false;
9248
9278
  try {
9249
- const probeProjectDir = join16(homedir9(), ".augmented", agent.code_name, "project");
9279
+ const probeProjectDir = join17(homedir9(), ".augmented", agent.code_name, "project");
9250
9280
  probeRan = await runAgentSessionToolBindProbes(agent, integrations, probeProjectDir, { forceDue });
9251
9281
  } catch (err) {
9252
9282
  log(`Session-tool-bind probe failed for '${agent.code_name}': ${err.message}`);
@@ -9259,9 +9289,9 @@ async function processAgent(agent, agentStates) {
9259
9289
  }
9260
9290
  if (frameworkAdapter.removeMcpServer && frameworkAdapter.getMcpPath) {
9261
9291
  const mcpPath = frameworkAdapter.getMcpPath(agent.code_name);
9262
- if (mcpPath && existsSync8(mcpPath)) {
9292
+ if (mcpPath && existsSync9(mcpPath)) {
9263
9293
  try {
9264
- const cfg = JSON.parse(readFileSync14(mcpPath, "utf-8"));
9294
+ const cfg = JSON.parse(readFileSync15(mcpPath, "utf-8"));
9265
9295
  const expectedRemoteKeys = new Set(
9266
9296
  integrations.map((i) => i.definition_id)
9267
9297
  );
@@ -9286,11 +9316,11 @@ async function processAgent(agent, agentStates) {
9286
9316
  recordConfigChurnEvent(agent.agent_id, agent.code_name, FLAP_CHANNEL_INTEGRATIONS, intMembership);
9287
9317
  }
9288
9318
  if (intHash !== prevIntHash) {
9289
- const projectDir = join16(homedir9(), ".augmented", agent.code_name, "project");
9290
- const envIntPath = join16(projectDir, ".env.integrations");
9319
+ const projectDir = join17(homedir9(), ".augmented", agent.code_name, "project");
9320
+ const envIntPath = join17(projectDir, ".env.integrations");
9291
9321
  let preWriteEnv;
9292
9322
  try {
9293
- preWriteEnv = readFileSync14(envIntPath, "utf-8");
9323
+ preWriteEnv = readFileSync15(envIntPath, "utf-8");
9294
9324
  } catch {
9295
9325
  preWriteEnv = void 0;
9296
9326
  }
@@ -9302,9 +9332,9 @@ async function processAgent(agent, agentStates) {
9302
9332
  let rotationHandled = true;
9303
9333
  if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
9304
9334
  try {
9305
- const projectMcpPath = join16(projectDir, ".mcp.json");
9306
- const postWriteEnv = readFileSync14(envIntPath, "utf-8");
9307
- const mcpContent = readFileSync14(projectMcpPath, "utf-8");
9335
+ const projectMcpPath = join17(projectDir, ".mcp.json");
9336
+ const postWriteEnv = readFileSync15(envIntPath, "utf-8");
9337
+ const mcpContent = readFileSync15(projectMcpPath, "utf-8");
9308
9338
  const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
9309
9339
  const mcpJsonForReap = JSON.parse(mcpContent);
9310
9340
  const affectedServerKeys = findMcpServersUsingVars(mcpJsonForReap, changedVars);
@@ -9387,8 +9417,8 @@ async function processAgent(agent, agentStates) {
9387
9417
  const mcpPath = frameworkAdapter.getMcpPath(agent.code_name);
9388
9418
  if (mcpPath) {
9389
9419
  try {
9390
- const { readFileSync: readFileSync15 } = await import("fs");
9391
- const mcpConfig = JSON.parse(readFileSync15(mcpPath, "utf-8"));
9420
+ const { readFileSync: readFileSync16 } = await import("fs");
9421
+ const mcpConfig = JSON.parse(readFileSync16(mcpPath, "utf-8"));
9392
9422
  if (mcpConfig.mcpServers) {
9393
9423
  for (const key of Object.keys(mcpConfig.mcpServers)) {
9394
9424
  if (isManagedMcpServerKey(key) && !expectedServerIds.has(key)) {
@@ -9528,14 +9558,14 @@ async function processAgent(agent, agentStates) {
9528
9558
  const frameworkId2 = frameworkAdapter.id;
9529
9559
  const candidateSkillDirs = [
9530
9560
  // Claude Code — framework runtime tree
9531
- join16(homedir10(), ".augmented", agent.code_name, "skills"),
9561
+ join17(homedir10(), ".augmented", agent.code_name, "skills"),
9532
9562
  // Claude Code — project tree
9533
- join16(homedir10(), ".augmented", agent.code_name, "project", ".claude", "skills"),
9563
+ join17(homedir10(), ".augmented", agent.code_name, "project", ".claude", "skills"),
9534
9564
  // Defensive: legacy provision-side path, not currently an
9535
9565
  // install target but cheap to sweep.
9536
- join16(agentDir, ".claude", "skills")
9566
+ join17(agentDir, ".claude", "skills")
9537
9567
  ];
9538
- const existingDirs = candidateSkillDirs.filter((d) => existsSync8(d));
9568
+ const existingDirs = candidateSkillDirs.filter((d) => existsSync9(d));
9539
9569
  const discoveredEntries = /* @__PURE__ */ new Set();
9540
9570
  for (const dir of existingDirs) {
9541
9571
  try {
@@ -9549,8 +9579,8 @@ async function processAgent(agent, agentStates) {
9549
9579
  }
9550
9580
  const removeSkillFolder = (entry, reason) => {
9551
9581
  for (const dir of existingDirs) {
9552
- const p = join16(dir, entry);
9553
- if (existsSync8(p)) {
9582
+ const p = join17(dir, entry);
9583
+ if (existsSync9(p)) {
9554
9584
  rmSync5(p, { recursive: true, force: true });
9555
9585
  }
9556
9586
  }
@@ -9565,11 +9595,22 @@ async function processAgent(agent, agentStates) {
9565
9595
  log(`Integration skill cleanup failed for '${agent.code_name}': ${err.message}`);
9566
9596
  }
9567
9597
  try {
9598
+ const globalSkillsPayload = refreshAny.global_skills;
9599
+ const sharedSkillsPayload = refreshAny.shared_skills;
9600
+ const desiredResolved = globalSkillsPayload !== void 0 || sharedSkillsPayload !== void 0;
9601
+ const manifestPath = managedSkillManifestPath(
9602
+ join17(homedir9(), ".augmented", agent.code_name)
9603
+ );
9604
+ const prevIds = /* @__PURE__ */ new Set([
9605
+ ...agentState.knownGlobalSkillIds.get(agent.agent_id) ?? /* @__PURE__ */ new Set(),
9606
+ ...readManagedSkillManifest(manifestPath)
9607
+ ]);
9568
9608
  const plan = planGlobalSkillSync(
9569
- [...refreshAny.global_skills ?? [], ...refreshAny.shared_skills ?? []],
9570
- agentState.knownGlobalSkillIds.get(agent.agent_id) ?? /* @__PURE__ */ new Set(),
9609
+ [...globalSkillsPayload ?? [], ...sharedSkillsPayload ?? []],
9610
+ prevIds,
9571
9611
  (content) => createHash12("sha256").update(content).digest("hex").slice(0, 12),
9572
- (skillId) => agentState.knownSkillHashes.get(`global-skill:${agent.agent_id}:${skillId}`)
9612
+ (skillId) => agentState.knownSkillHashes.get(`global-skill:${agent.agent_id}:${skillId}`),
9613
+ { desiredResolved }
9573
9614
  );
9574
9615
  for (const { skillId, content, hash } of plan.installs) {
9575
9616
  frameworkAdapter.installSkillFiles(agent.code_name, skillId, [{ relativePath: "SKILL.md", content }]);
@@ -9577,23 +9618,30 @@ async function processAgent(agent, agentStates) {
9577
9618
  log(`Installed global skill '${skillId}' for '${agent.code_name}'`);
9578
9619
  }
9579
9620
  if (plan.removes.length) {
9580
- const { rmSync: rmSync5 } = await import("fs");
9581
- const { homedir: homedir10 } = await import("os");
9582
9621
  const globalSkillDirs = [
9583
- join16(homedir10(), ".augmented", agent.code_name, "skills"),
9584
- join16(homedir10(), ".augmented", agent.code_name, "project", ".claude", "skills"),
9585
- join16(agentDir, ".claude", "skills")
9622
+ join17(homedir9(), ".augmented", agent.code_name, "skills"),
9623
+ join17(homedir9(), ".augmented", agent.code_name, "project", ".claude", "skills"),
9624
+ join17(agentDir, ".claude", "skills")
9586
9625
  ];
9587
9626
  for (const id of plan.removes) {
9627
+ let prunedAny = false;
9588
9628
  for (const dir of globalSkillDirs) {
9589
- const p = join16(dir, id);
9590
- if (existsSync8(p)) rmSync5(p, { recursive: true, force: true });
9629
+ const p = join17(dir, id);
9630
+ if (existsSync9(p) && existsSync9(join17(p, "SKILL.md"))) {
9631
+ rmSync4(p, { recursive: true, force: true });
9632
+ prunedAny = true;
9633
+ }
9591
9634
  }
9592
9635
  agentState.knownSkillHashes.delete(`global-skill:${agent.agent_id}:${id}`);
9593
- log(`Removed unpublished global skill '${id}' for '${agent.code_name}'`);
9636
+ if (prunedAny) {
9637
+ log(`Pruned unassigned skill '${id}' for '${agent.code_name}' (ENG-7492)`);
9638
+ }
9594
9639
  }
9595
9640
  }
9596
9641
  agentState.knownGlobalSkillIds.set(agent.agent_id, plan.currentIds);
9642
+ if (desiredResolved) {
9643
+ writeManagedSkillManifest(manifestPath, plan.currentIds);
9644
+ }
9597
9645
  } catch (err) {
9598
9646
  log(`Global skill install failed for '${agent.code_name}': ${err.message}`);
9599
9647
  }
@@ -9761,8 +9809,8 @@ async function processAgent(agent, agentStates) {
9761
9809
  const sess = getSessionState(agent.code_name);
9762
9810
  let mcpJsonParsed = null;
9763
9811
  try {
9764
- const mcpPath = join16(getProjectDir(agent.code_name), ".mcp.json");
9765
- mcpJsonParsed = JSON.parse(readFileSync14(mcpPath, "utf-8"));
9812
+ const mcpPath = join17(getProjectDir(agent.code_name), ".mcp.json");
9813
+ mcpJsonParsed = JSON.parse(readFileSync15(mcpPath, "utf-8"));
9766
9814
  } catch {
9767
9815
  }
9768
9816
  reapMissingMcpSessions({
@@ -10032,10 +10080,10 @@ In progress for ${age} minutes \u2014 auto-failed`).catch(() => {
10032
10080
  }
10033
10081
  }
10034
10082
  const trackedFiles = frameworkAdapter.driftTrackedFiles();
10035
- if (trackedFiles.length > 0 && existsSync8(agentDir)) {
10083
+ if (trackedFiles.length > 0 && existsSync9(agentDir)) {
10036
10084
  const hashes = /* @__PURE__ */ new Map();
10037
10085
  for (const file of trackedFiles) {
10038
- const h = hashFile(join16(agentDir, file));
10086
+ const h = hashFile(join17(agentDir, file));
10039
10087
  if (h) hashes.set(file, h);
10040
10088
  }
10041
10089
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -10050,7 +10098,7 @@ In progress for ${age} minutes \u2014 auto-failed`).catch(() => {
10050
10098
  refreshData.agent.onboarding_state
10051
10099
  );
10052
10100
  const obStep = obState.step;
10053
- const markerPath = join16(homedir9(), ".augmented", agent.code_name, "onboarding-drive.json");
10101
+ const markerPath = join17(homedir9(), ".augmented", agent.code_name, "onboarding-drive.json");
10054
10102
  const marker = readOnboardingDriveMarker(markerPath);
10055
10103
  const decision = decideOnboardingDrive(obStep, marker, Date.now(), obState.generation ?? 0);
10056
10104
  if (decision.clearMarker) {
@@ -10113,8 +10161,8 @@ var egressAllowlistEqual = (a, b) => a.length === b.length && a.every((d, i) =>
10113
10161
  async function ensurePersistentSession(agent, tasks, boardItems, refreshData) {
10114
10162
  const codeName = agent.code_name;
10115
10163
  const projectDir = getProjectDir(codeName);
10116
- const mcpConfigPath = join16(projectDir, ".mcp.json");
10117
- const claudeMdPath = join16(projectDir, "CLAUDE.md");
10164
+ const mcpConfigPath = join17(projectDir, ".mcp.json");
10165
+ const claudeMdPath = join17(projectDir, "CLAUDE.md");
10118
10166
  if (restartBreaker.isTripped(codeName)) {
10119
10167
  const trip = restartBreaker.getTrip(codeName);
10120
10168
  return {
@@ -10623,7 +10671,7 @@ async function handleRestartDoorbell(agentId, requestedAt, restartReason) {
10623
10671
  void api.post("/host/restart-ack", { host_id: hostId, agent_id: agentId, restart_requested_at: requestedAt }).catch((err) => log(`[restart-lane] ack failed for '${codeName}': ${err.message}`));
10624
10672
  void (async () => {
10625
10673
  try {
10626
- const { collectDiagnostics } = await import("../persistent-session-OP4TXILO.js");
10674
+ const { collectDiagnostics } = await import("../persistent-session-K5RJ4BVF.js");
10627
10675
  await api.post("/host/heartbeat", {
10628
10676
  host_id: hostId,
10629
10677
  agent_diagnostics: collectDiagnostics([codeName])
@@ -10673,7 +10721,7 @@ async function respawnAgentAfterMcpStop(codeName, reason) {
10673
10721
  }
10674
10722
  try {
10675
10723
  const hostId = await getHostId();
10676
- const { collectDiagnostics } = await import("../persistent-session-OP4TXILO.js");
10724
+ const { collectDiagnostics } = await import("../persistent-session-K5RJ4BVF.js");
10677
10725
  await api.post("/host/heartbeat", {
10678
10726
  host_id: hostId,
10679
10727
  agent_diagnostics: collectDiagnostics([codeName])
@@ -10915,8 +10963,8 @@ async function processDirectChatMessage(agent, msg) {
10915
10963
  if (useDoorbell) {
10916
10964
  try {
10917
10965
  const doorbell = directChatDoorbellPath(agent.agentId, homedir9());
10918
- mkdirSync6(dirname5(doorbell), { recursive: true });
10919
- writeFileSync6(doorbell, String(Date.now()));
10966
+ mkdirSync7(dirname6(doorbell), { recursive: true });
10967
+ writeFileSync7(doorbell, String(Date.now()));
10920
10968
  log(`[direct-chat] Doorbell rung for '${agent.codeName}' (msg=${msg.id}) \u2014 in-session MCP will pull via the cursor`);
10921
10969
  return;
10922
10970
  } catch (err) {
@@ -10984,8 +11032,8 @@ ${formatRunMarker(run_id)}` : KANBAN_CHECK_COMMAND;
10984
11032
  if (run_id) openInjectedRunByCode.set(codeName, run_id);
10985
11033
  try {
10986
11034
  const doorbell = directChatDoorbellPath(agentId, homedir9());
10987
- mkdirSync6(dirname5(doorbell), { recursive: true });
10988
- writeFileSync6(doorbell, String(Date.now()));
11035
+ mkdirSync7(dirname6(doorbell), { recursive: true });
11036
+ writeFileSync7(doorbell, String(Date.now()));
10989
11037
  } catch (err) {
10990
11038
  log(`[kanban] doorbell ring failed for '${codeName}': ${err.message} (notice still queued)`);
10991
11039
  }
@@ -11064,7 +11112,7 @@ async function processClaudePairSessions(agents) {
11064
11112
  killPairSession,
11065
11113
  pairTmuxSession,
11066
11114
  finalizeClaudePairOnboarding
11067
- } = await import("../claude-pair-runtime-X5NJYZSK.js");
11115
+ } = await import("../claude-pair-runtime-YZ2PGUW3.js");
11068
11116
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
11069
11117
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
11070
11118
  const killed = await killPairSession(pairTmuxSession(pairId));
@@ -11307,8 +11355,8 @@ function parseMemoryFile(raw, fallbackName) {
11307
11355
  };
11308
11356
  }
11309
11357
  async function syncMemories(agent, configDir, log2) {
11310
- const projectDir = join16(configDir, agent.code_name, "project");
11311
- const memoryDir = join16(projectDir, "memory");
11358
+ const projectDir = join17(configDir, agent.code_name, "project");
11359
+ const memoryDir = join17(projectDir, "memory");
11312
11360
  const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
11313
11361
  if (isFreshSync) {
11314
11362
  log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
@@ -11319,14 +11367,14 @@ async function syncMemories(agent, configDir, log2) {
11319
11367
  }
11320
11368
  pendingFreshMemorySync.delete(agent.agent_id);
11321
11369
  }
11322
- if (existsSync8(memoryDir)) {
11370
+ if (existsSync9(memoryDir)) {
11323
11371
  const prevHashes = memoryFileHashes.get(agent.agent_id) ?? /* @__PURE__ */ new Map();
11324
11372
  const currentHashes = /* @__PURE__ */ new Map();
11325
11373
  const changedMemories = [];
11326
11374
  for (const file of readdirSync5(memoryDir)) {
11327
11375
  if (!file.endsWith(".md")) continue;
11328
11376
  try {
11329
- const raw = readFileSync14(join16(memoryDir, file), "utf-8");
11377
+ const raw = readFileSync15(join17(memoryDir, file), "utf-8");
11330
11378
  const fileHash = createHash11("sha256").update(raw).digest("hex").slice(0, 16);
11331
11379
  currentHashes.set(file, fileHash);
11332
11380
  if (prevHashes.get(file) === fileHash) continue;
@@ -11351,7 +11399,7 @@ async function syncMemories(agent, configDir, log2) {
11351
11399
  } catch (err) {
11352
11400
  for (const mem of changedMemories) {
11353
11401
  for (const [file] of currentHashes) {
11354
- const parsed = parseMemoryFile(readFileSync14(join16(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
11402
+ const parsed = parseMemoryFile(readFileSync15(join17(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
11355
11403
  if (parsed?.name === mem.name) currentHashes.delete(file);
11356
11404
  }
11357
11405
  }
@@ -11364,7 +11412,7 @@ async function syncMemories(agent, configDir, log2) {
11364
11412
  }
11365
11413
  }
11366
11414
  async function downloadMemories(agent, memoryDir, log2, { force }) {
11367
- const localFiles = existsSync8(memoryDir) ? readdirSync5(memoryDir).filter((f) => f.endsWith(".md")).sort() : [];
11415
+ const localFiles = existsSync9(memoryDir) ? readdirSync5(memoryDir).filter((f) => f.endsWith(".md")).sort() : [];
11368
11416
  const localListHash = createHash11("sha256").update(localFiles.join(",")).digest("hex").slice(0, 16);
11369
11417
  const prevLocalHash = lastLocalFileHash.get(agent.agent_id);
11370
11418
  const prevDownload = lastDownloadHash.get(agent.agent_id);
@@ -11379,14 +11427,14 @@ async function downloadMemories(agent, memoryDir, log2, { force }) {
11379
11427
  lastDownloadHash.set(agent.agent_id, responseHash);
11380
11428
  lastLocalFileHash.set(agent.agent_id, localListHash);
11381
11429
  if (dbMemories.memories?.length) {
11382
- mkdirSync6(memoryDir, { recursive: true });
11430
+ mkdirSync7(memoryDir, { recursive: true });
11383
11431
  let written = 0;
11384
11432
  let overwritten = 0;
11385
11433
  for (let i = 0; i < dbMemories.memories.length; i++) {
11386
11434
  const mem = dbMemories.memories[i];
11387
11435
  const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
11388
11436
  const slug = rawSlug || `memory-${i}`;
11389
- const filePath = join16(memoryDir, `${slug}.md`);
11437
+ const filePath = join17(memoryDir, `${slug}.md`);
11390
11438
  const desired = `---
11391
11439
  name: ${JSON.stringify(mem.name)}
11392
11440
  type: ${mem.type}
@@ -11395,17 +11443,17 @@ description: ${JSON.stringify(mem.content.slice(0, 200))}
11395
11443
 
11396
11444
  ${mem.content}
11397
11445
  `;
11398
- if (existsSync8(filePath)) {
11446
+ if (existsSync9(filePath)) {
11399
11447
  let existing = "";
11400
11448
  try {
11401
- existing = readFileSync14(filePath, "utf-8");
11449
+ existing = readFileSync15(filePath, "utf-8");
11402
11450
  } catch {
11403
11451
  }
11404
11452
  if (existing === desired) continue;
11405
- writeFileSync6(filePath, desired);
11453
+ writeFileSync7(filePath, desired);
11406
11454
  overwritten++;
11407
11455
  } else {
11408
- writeFileSync6(filePath, desired);
11456
+ writeFileSync7(filePath, desired);
11409
11457
  written++;
11410
11458
  }
11411
11459
  }
@@ -11422,7 +11470,7 @@ ${mem.content}
11422
11470
  }
11423
11471
  }
11424
11472
  async function cleanupAgentFiles(codeName, agentDir) {
11425
- if (existsSync8(agentDir)) {
11473
+ if (existsSync9(agentDir)) {
11426
11474
  try {
11427
11475
  rmSync4(agentDir, { recursive: true, force: true });
11428
11476
  log(`Removed provision directory for '${codeName}'`);
@@ -11655,8 +11703,8 @@ function startManager(opts) {
11655
11703
  config = opts;
11656
11704
  try {
11657
11705
  const stateFile = getStateFile();
11658
- if (existsSync8(stateFile)) {
11659
- const raw = readFileSync14(stateFile, "utf-8");
11706
+ if (existsSync9(stateFile)) {
11707
+ const raw = readFileSync15(stateFile, "utf-8");
11660
11708
  const parsed = JSON.parse(raw);
11661
11709
  if (Array.isArray(parsed.agents)) {
11662
11710
  state6.agents = parsed.agents;
@@ -11683,7 +11731,7 @@ function startManager(opts) {
11683
11731
  log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
11684
11732
  }
11685
11733
  log(
11686
- `[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join16(homedir9(), ".augmented", "manager.log")}`
11734
+ `[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join17(homedir9(), ".augmented", "manager.log")}`
11687
11735
  );
11688
11736
  deployMcpAssets();
11689
11737
  reapOrphanChannelMcps({ log });
@@ -11704,7 +11752,7 @@ async function reapOrphanedClaudePids() {
11704
11752
  const looksLikeClaude = (pid) => {
11705
11753
  if (process.platform !== "linux") return true;
11706
11754
  try {
11707
- const comm = readFileSync14(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
11755
+ const comm = readFileSync15(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
11708
11756
  return comm.includes("claude");
11709
11757
  } catch {
11710
11758
  return false;
@@ -11801,18 +11849,18 @@ function restartRunningChannelMcps(basenames) {
11801
11849
  }
11802
11850
  }
11803
11851
  function deployMcpAssets() {
11804
- const targetDir = join16(homedir9(), ".augmented", "_mcp");
11805
- mkdirSync6(targetDir, { recursive: true });
11806
- const moduleDir = dirname5(fileURLToPath(import.meta.url));
11852
+ const targetDir = join17(homedir9(), ".augmented", "_mcp");
11853
+ mkdirSync7(targetDir, { recursive: true });
11854
+ const moduleDir = dirname6(fileURLToPath(import.meta.url));
11807
11855
  let mcpSourceDir = "";
11808
11856
  let dir = moduleDir;
11809
11857
  for (let i = 0; i < 6; i++) {
11810
- const candidate = join16(dir, "dist", "mcp");
11811
- if (existsSync8(join16(candidate, "index.js"))) {
11858
+ const candidate = join17(dir, "dist", "mcp");
11859
+ if (existsSync9(join17(candidate, "index.js"))) {
11812
11860
  mcpSourceDir = candidate;
11813
11861
  break;
11814
11862
  }
11815
- const parent = dirname5(dir);
11863
+ const parent = dirname6(dir);
11816
11864
  if (parent === dir) break;
11817
11865
  dir = parent;
11818
11866
  }
@@ -11823,8 +11871,8 @@ function deployMcpAssets() {
11823
11871
  const changedBasenames = [];
11824
11872
  const fileHash = (p) => {
11825
11873
  try {
11826
- if (!existsSync8(p)) return null;
11827
- return createHash11("sha256").update(readFileSync14(p)).digest("hex");
11874
+ if (!existsSync9(p)) return null;
11875
+ return createHash11("sha256").update(readFileSync15(p)).digest("hex");
11828
11876
  } catch {
11829
11877
  return null;
11830
11878
  }
@@ -11877,9 +11925,9 @@ function deployMcpAssets() {
11877
11925
  // never needs restarting to pick up a key rotation either.
11878
11926
  "origami.js"
11879
11927
  ]) {
11880
- const src = join16(mcpSourceDir, file);
11881
- const dst = join16(targetDir, file);
11882
- if (!existsSync8(src)) continue;
11928
+ const src = join17(mcpSourceDir, file);
11929
+ const dst = join17(targetDir, file);
11930
+ if (!existsSync9(src)) continue;
11883
11931
  const before = fileHash(dst);
11884
11932
  try {
11885
11933
  copyFileSync(src, dst);
@@ -11896,23 +11944,23 @@ function deployMcpAssets() {
11896
11944
  log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
11897
11945
  restartRunningChannelMcps(changedBasenames);
11898
11946
  }
11899
- const localMcpPath = join16(targetDir, "index.js");
11947
+ const localMcpPath = join17(targetDir, "index.js");
11900
11948
  try {
11901
- const agentsDir = join16(homedir9(), ".augmented", "agents");
11902
- if (existsSync8(agentsDir)) {
11949
+ const agentsDir = join17(homedir9(), ".augmented", "agents");
11950
+ if (existsSync9(agentsDir)) {
11903
11951
  for (const entry of readdirSync5(agentsDir, { withFileTypes: true })) {
11904
11952
  if (!entry.isDirectory()) continue;
11905
11953
  for (const subdir of ["provision", "project"]) {
11906
- const mcpJsonPath = join16(agentsDir, entry.name, subdir, ".mcp.json");
11954
+ const mcpJsonPath = join17(agentsDir, entry.name, subdir, ".mcp.json");
11907
11955
  try {
11908
- const raw = readFileSync14(mcpJsonPath, "utf-8");
11956
+ const raw = readFileSync15(mcpJsonPath, "utf-8");
11909
11957
  if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
11910
11958
  const mcpConfig = JSON.parse(raw);
11911
11959
  const augServer = mcpConfig.mcpServers?.["augmented"];
11912
11960
  if (!augServer) continue;
11913
11961
  augServer.command = "node";
11914
11962
  augServer.args = [localMcpPath];
11915
- writeFileSync6(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
11963
+ writeFileSync7(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
11916
11964
  log(`[manager] Patched ${entry.name}/${subdir}/.mcp.json: npx \u2192 node`);
11917
11965
  } catch {
11918
11966
  }