@integrity-labs/agt-cli 0.27.150 → 0.27.152

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.
@@ -19,7 +19,7 @@ import {
19
19
  provisionStopHook,
20
20
  requireHost,
21
21
  safeWriteJsonAtomic
22
- } from "../chunk-CUHP2SVW.js";
22
+ } from "../chunk-CPXNNR4W.js";
23
23
  import {
24
24
  getProjectDir as getProjectDir2,
25
25
  getReadyTasks,
@@ -60,11 +60,12 @@ import {
60
60
  takeWatchdogGiveUpCount,
61
61
  takeZombieDetection,
62
62
  transcriptActivityAgeSeconds
63
- } from "../chunk-JLS7NQFE.js";
63
+ } from "../chunk-FF37P4BH.js";
64
64
  import {
65
65
  KANBAN_CHECK_COMMAND,
66
66
  MAX_AVATAR_ENV_URL_BYTES,
67
67
  SUPPRESS_SENTINEL,
68
+ StreamEncoder,
68
69
  appendDmFooter,
69
70
  attributeTranscriptUsageByRun,
70
71
  classifyActor,
@@ -89,7 +90,7 @@ import {
89
90
  resolveDmTarget,
90
91
  worseConnectivityOutcome,
91
92
  wrapScheduledTaskPrompt
92
- } from "../chunk-A75AOK6E.js";
93
+ } from "../chunk-FZTGR2AQ.js";
93
94
  import {
94
95
  parsePsRows,
95
96
  reapOrphanChannelMcps
@@ -100,8 +101,8 @@ import { createHash as createHash3 } from "crypto";
100
101
  import { readFileSync as readFileSync9, writeFileSync as writeFileSync4, appendFileSync, mkdirSync as mkdirSync4, chmodSync, existsSync as existsSync5, rmSync as rmSync2, readdirSync as readdirSync4, statSync as statSync3, unlinkSync, copyFileSync } from "fs";
101
102
  import https from "https";
102
103
  import { execFileSync as syncExecFile } from "child_process";
103
- import { join as join8, dirname as dirname3 } from "path";
104
- import { homedir as homedir4 } from "os";
104
+ import { join as join9, dirname as dirname3 } from "path";
105
+ import { homedir as homedir5 } from "os";
105
106
  import { fileURLToPath } from "url";
106
107
 
107
108
  // src/lib/mcp-config-drift.ts
@@ -1685,9 +1686,151 @@ var DirectChatSpawnGate = class {
1685
1686
  }
1686
1687
  };
1687
1688
 
1689
+ // src/lib/artifact-stream.ts
1690
+ import { join as join2 } from "path";
1691
+ import { homedir } from "os";
1692
+ import { readdir, stat, readFile } from "fs/promises";
1693
+ var ARTIFACT_STREAM_ENV = "AUGMENTED_ARTIFACT_STREAM_ENABLED";
1694
+ var ARTEFACT_ENTRY_FILE = "index.html";
1695
+ function isArtifactStreamingEnabled(env = process.env) {
1696
+ const v = env[ARTIFACT_STREAM_ENV];
1697
+ return v === "true" || v === "1";
1698
+ }
1699
+ function errMessage(err) {
1700
+ return err instanceof Error ? err.message : String(err);
1701
+ }
1702
+ var ArtifactStreamSession = class {
1703
+ constructor(agentId, clientToken, deps, meta = {}) {
1704
+ this.agentId = agentId;
1705
+ this.clientToken = clientToken;
1706
+ this.deps = deps;
1707
+ this.meta = meta;
1708
+ this.encoder = new StreamEncoder(deps.now ? { now: deps.now } : {});
1709
+ }
1710
+ encoder;
1711
+ draftId = null;
1712
+ creating = null;
1713
+ /** The draft id once created, else null. */
1714
+ get id() {
1715
+ return this.draftId;
1716
+ }
1717
+ /**
1718
+ * Create the draft on first use (idempotent via client_token — a manager
1719
+ * restart returns the same draft). Concurrent callers share one in-flight
1720
+ * request. Returns null on failure (best-effort; the next snapshot retries).
1721
+ */
1722
+ async ensureDraft() {
1723
+ if (this.draftId) return this.draftId;
1724
+ if (!this.creating) {
1725
+ this.creating = this.deps.api.post("/host/artifacts/draft", {
1726
+ agent_id: this.agentId,
1727
+ client_token: this.clientToken,
1728
+ kind: this.meta.kind ?? "other",
1729
+ ...this.meta.title ? { title: this.meta.title } : {}
1730
+ }).then((res) => {
1731
+ this.draftId = res?.id ?? null;
1732
+ return this.draftId;
1733
+ }).catch((err) => {
1734
+ this.deps.log?.(`[artifact-stream] draft create failed (${this.clientToken}): ${errMessage(err)}`);
1735
+ return null;
1736
+ }).finally(() => {
1737
+ this.creating = null;
1738
+ });
1739
+ }
1740
+ return this.creating;
1741
+ }
1742
+ /** Encode one snapshot and relay its frame(s). Best-effort, never throws. */
1743
+ async pushSnapshot(content) {
1744
+ const id = await this.ensureDraft();
1745
+ if (!id) return;
1746
+ const frames = this.encoder.encode(content);
1747
+ for (const frame of frames) {
1748
+ try {
1749
+ await this.deps.api.post(`/host/artifacts/${encodeURIComponent(id)}/stream`, {
1750
+ agent_id: this.agentId,
1751
+ frame
1752
+ });
1753
+ } catch (err) {
1754
+ this.deps.log?.(`[artifact-stream] frame ${frame.seq} failed (${id}): ${errMessage(err)}`);
1755
+ }
1756
+ }
1757
+ }
1758
+ };
1759
+ var ArtifactStreamScanner = class {
1760
+ constructor(agentId, artifactsDir, fsDeps, deps) {
1761
+ this.agentId = agentId;
1762
+ this.artifactsDir = artifactsDir;
1763
+ this.fsDeps = fsDeps;
1764
+ this.deps = deps;
1765
+ }
1766
+ sessions = /* @__PURE__ */ new Map();
1767
+ seenMtime = /* @__PURE__ */ new Map();
1768
+ scanning = false;
1769
+ /** One scan pass. Reads + streams every changed artefact. Never throws. */
1770
+ async scanOnce() {
1771
+ if (this.scanning) return;
1772
+ this.scanning = true;
1773
+ try {
1774
+ let names;
1775
+ try {
1776
+ names = await this.fsDeps.listArtefactNames(this.artifactsDir);
1777
+ } catch {
1778
+ return;
1779
+ }
1780
+ for (const name of names) {
1781
+ const file = join2(this.artifactsDir, name, ARTEFACT_ENTRY_FILE);
1782
+ const mtime = await this.fsDeps.mtimeMs(file).catch(() => null);
1783
+ if (mtime === null) continue;
1784
+ if (this.seenMtime.get(name) === mtime) continue;
1785
+ let content;
1786
+ try {
1787
+ content = await this.fsDeps.readFile(file);
1788
+ } catch (err) {
1789
+ this.deps.log?.(`[artifact-stream] read failed (${name}): ${errMessage(err)}`);
1790
+ continue;
1791
+ }
1792
+ this.seenMtime.set(name, mtime);
1793
+ await this.sessionFor(name).pushSnapshot(content);
1794
+ }
1795
+ const live = new Set(names);
1796
+ for (const key of this.seenMtime.keys()) if (!live.has(key)) this.seenMtime.delete(key);
1797
+ for (const key of this.sessions.keys()) if (!live.has(key)) this.sessions.delete(key);
1798
+ } finally {
1799
+ this.scanning = false;
1800
+ }
1801
+ }
1802
+ sessionFor(name) {
1803
+ let session = this.sessions.get(name);
1804
+ if (!session) {
1805
+ session = new ArtifactStreamSession(this.agentId, name, this.deps, { title: name });
1806
+ this.sessions.set(name, session);
1807
+ }
1808
+ return session;
1809
+ }
1810
+ };
1811
+ function artifactsDirFor(codeName) {
1812
+ return join2(homedir(), ".augmented", codeName, "artifacts");
1813
+ }
1814
+ var nodeArtifactFs = {
1815
+ async listArtefactNames(artifactsDir) {
1816
+ const entries = await readdir(artifactsDir, { withFileTypes: true });
1817
+ return entries.filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name);
1818
+ },
1819
+ async mtimeMs(filePath) {
1820
+ try {
1821
+ return (await stat(filePath)).mtimeMs;
1822
+ } catch {
1823
+ return null;
1824
+ }
1825
+ },
1826
+ readFile(filePath) {
1827
+ return readFile(filePath, "utf8");
1828
+ }
1829
+ };
1830
+
1688
1831
  // src/lib/usage-banner-monitor.ts
1689
1832
  var MIN_CHECK_INTERVAL_MS = 6e4;
1690
- var PANE_TAIL_LINES_FOR_BANNER = 200;
1833
+ var PANE_TAIL_LINES_FOR_BANNER = 5e3;
1691
1834
  var state = /* @__PURE__ */ new Map();
1692
1835
  async function maybeReportUsageBanner(args) {
1693
1836
  const { api: api2, codeName, agentId, log: log2 } = args;
@@ -1742,7 +1885,7 @@ async function maybeReportUsageBanner(args) {
1742
1885
 
1743
1886
  // src/lib/token-usage-monitor.ts
1744
1887
  import { readdirSync, readFileSync as readFileSync4, statSync } from "fs";
1745
- import { join as join2 } from "path";
1888
+ import { join as join3 } from "path";
1746
1889
  var MIN_CHECK_INTERVAL_MS2 = 6e4;
1747
1890
  var TRANSCRIPT_MTIME_WINDOW_MS = 2 * 24 * 60 * 60 * 1e3;
1748
1891
  var MAX_ENTRIES_PER_POST = 200;
@@ -1771,7 +1914,7 @@ async function maybeReportTokenUsage(args) {
1771
1914
  if (!name.endsWith(".jsonl")) continue;
1772
1915
  const sessionId = name.slice(0, -".jsonl".length);
1773
1916
  if (!sessionId) continue;
1774
- const path = join2(dir, name);
1917
+ const path = join3(dir, name);
1775
1918
  let st;
1776
1919
  try {
1777
1920
  st = statSync(path);
@@ -1869,7 +2012,7 @@ async function maybeReportTokenUsage(args) {
1869
2012
 
1870
2013
  // src/lib/conversation-evaluator.ts
1871
2014
  import { readdirSync as readdirSync2, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
1872
- import { join as join3 } from "path";
2015
+ import { join as join4 } from "path";
1873
2016
  var MIN_CHECK_INTERVAL_MS3 = 5 * 6e4;
1874
2017
  var TRANSCRIPT_MTIME_WINDOW_MS2 = 3 * 24 * 60 * 60 * 1e3;
1875
2018
  var WINDOW_PAD_MS = 5 * 6e4;
@@ -2106,7 +2249,7 @@ function readRecentTurns(dir, nowMs) {
2106
2249
  const turns = [];
2107
2250
  for (const name of entries) {
2108
2251
  if (!name.endsWith(".jsonl")) continue;
2109
- const full = join3(dir, name);
2252
+ const full = join4(dir, name);
2110
2253
  let mtimeMs;
2111
2254
  try {
2112
2255
  mtimeMs = statSync2(full).mtimeMs;
@@ -2286,10 +2429,10 @@ async function reportSkip2(api2, agentId, conversationId, log2, codeName) {
2286
2429
 
2287
2430
  // src/lib/activity-cache-monitor.ts
2288
2431
  import { existsSync as existsSync2, readFileSync as readFileSync6 } from "fs";
2289
- import { homedir } from "os";
2290
- import { join as join4 } from "path";
2432
+ import { homedir as homedir2 } from "os";
2433
+ import { join as join5 } from "path";
2291
2434
  var MIN_CHECK_INTERVAL_MS5 = 6e4;
2292
- var STATS_CACHE_PATH = join4(homedir(), ".claude", "stats-cache.json");
2435
+ var STATS_CACHE_PATH = join5(homedir2(), ".claude", "stats-cache.json");
2293
2436
  var ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
2294
2437
  var state5 = { lastObservedDate: null, lastCheckedAt: 0 };
2295
2438
  function selectNewDailyRows(raw, lastObservedDate) {
@@ -2785,9 +2928,9 @@ var GatewayClientPool = class extends EventEmitter {
2785
2928
  };
2786
2929
 
2787
2930
  // src/lib/claude-auth-detect.ts
2788
- import { readFile, readdir } from "fs/promises";
2789
- import { homedir as homedir2, platform } from "os";
2790
- import { join as join5 } from "path";
2931
+ import { readFile as readFile2, readdir as readdir2 } from "fs/promises";
2932
+ import { homedir as homedir3, platform } from "os";
2933
+ import { join as join6 } from "path";
2791
2934
  import { execFile as execFile2 } from "child_process";
2792
2935
  import { promisify } from "util";
2793
2936
  var execFileAsync = promisify(execFile2);
@@ -2802,17 +2945,17 @@ async function detectClaudeAuth() {
2802
2945
  }
2803
2946
  async function findClaudeCredentialsPaths() {
2804
2947
  const candidates = [
2805
- join5(homedir2(), ".claude", ".credentials.json"),
2806
- join5(homedir2(), ".claude", "credentials.json")
2948
+ join6(homedir3(), ".claude", ".credentials.json"),
2949
+ join6(homedir3(), ".claude", "credentials.json")
2807
2950
  ];
2808
2951
  const isLinuxRoot = platform() === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
2809
2952
  if (isLinuxRoot) {
2810
2953
  try {
2811
- const entries = await readdir("/home", { withFileTypes: true });
2954
+ const entries = await readdir2("/home", { withFileTypes: true });
2812
2955
  for (const entry of entries) {
2813
2956
  if (!entry.isDirectory()) continue;
2814
- candidates.push(join5("/home", entry.name, ".claude", ".credentials.json"));
2815
- candidates.push(join5("/home", entry.name, ".claude", "credentials.json"));
2957
+ candidates.push(join6("/home", entry.name, ".claude", ".credentials.json"));
2958
+ candidates.push(join6("/home", entry.name, ".claude", "credentials.json"));
2816
2959
  }
2817
2960
  } catch {
2818
2961
  }
@@ -2848,7 +2991,7 @@ async function readMacKeychain() {
2848
2991
  }
2849
2992
  async function readJsonSilently(path) {
2850
2993
  try {
2851
- const raw = await readFile(path, "utf-8");
2994
+ const raw = await readFile2(path, "utf-8");
2852
2995
  return JSON.parse(raw);
2853
2996
  } catch {
2854
2997
  return null;
@@ -2905,10 +3048,10 @@ function normalize(value) {
2905
3048
 
2906
3049
  // src/lib/channel-hash-cache.ts
2907
3050
  import { existsSync as existsSync3, readFileSync as readFileSync7, writeFileSync as writeFileSync2 } from "fs";
2908
- import { join as join6 } from "path";
3051
+ import { join as join7 } from "path";
2909
3052
  var CACHE_FILENAME = "channel-hash-cache.json";
2910
3053
  function getChannelHashCacheFile(configDir) {
2911
- return join6(configDir, CACHE_FILENAME);
3054
+ return join7(configDir, CACHE_FILENAME);
2912
3055
  }
2913
3056
  function loadChannelHashCache(target, configDir) {
2914
3057
  const path = getChannelHashCacheFile(configDir);
@@ -3509,14 +3652,14 @@ function partitionActionableByPoison(actionable, states, config2) {
3509
3652
 
3510
3653
  // src/lib/restart-flags.ts
3511
3654
  import { existsSync as existsSync4, mkdirSync as mkdirSync3, readdirSync as readdirSync3, readFileSync as readFileSync8, renameSync as renameSync2, rmSync, writeFileSync as writeFileSync3 } from "fs";
3512
- import { homedir as homedir3 } from "os";
3513
- import { join as join7 } from "path";
3655
+ import { homedir as homedir4 } from "os";
3656
+ import { join as join8 } from "path";
3514
3657
  import { randomUUID } from "crypto";
3515
3658
  function restartFlagsDir() {
3516
- return join7(homedir3(), ".augmented", "restart-flags");
3659
+ return join8(homedir4(), ".augmented", "restart-flags");
3517
3660
  }
3518
3661
  function flagPath(codeName) {
3519
- return join7(restartFlagsDir(), `${codeName}.flag`);
3662
+ return join8(restartFlagsDir(), `${codeName}.flag`);
3520
3663
  }
3521
3664
  function readRestartFlags() {
3522
3665
  const dir = restartFlagsDir();
@@ -3525,7 +3668,7 @@ function readRestartFlags() {
3525
3668
  for (const entry of readdirSync3(dir)) {
3526
3669
  if (!entry.endsWith(".flag")) continue;
3527
3670
  try {
3528
- const raw = readFileSync8(join7(dir, entry), "utf8");
3671
+ const raw = readFileSync8(join8(dir, entry), "utf8");
3529
3672
  const parsed = JSON.parse(raw);
3530
3673
  if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
3531
3674
  parsed.codeName = entry.replace(/\.flag$/, "");
@@ -4073,8 +4216,8 @@ function applyRestartAcks(args) {
4073
4216
  var GATEWAY_PORT_BASE = 18800;
4074
4217
  var GATEWAY_PORT_STEP = 10;
4075
4218
  var GATEWAY_PORT_MAX = 18899;
4076
- var AUGMENTED_DIR = join8(process.env["HOME"] ?? "/tmp", ".augmented");
4077
- var GATEWAY_PORTS_FILE = join8(AUGMENTED_DIR, "gateway-ports.json");
4219
+ var AUGMENTED_DIR = join9(process.env["HOME"] ?? "/tmp", ".augmented");
4220
+ var GATEWAY_PORTS_FILE = join9(AUGMENTED_DIR, "gateway-ports.json");
4078
4221
  var CHANNEL_SWEEP_INTERVAL_MS = (() => {
4079
4222
  const raw = parseInt(process.env["AGT_CHANNEL_SWEEP_INTERVAL_MS"] ?? "", 10);
4080
4223
  if (!Number.isFinite(raw)) return 5 * 60 * 1e3;
@@ -4447,7 +4590,7 @@ var runningMcpServerKeys = /* @__PURE__ */ new Map();
4447
4590
  var runningChannelSecretHashes = /* @__PURE__ */ new Map();
4448
4591
  function projectMcpHash(_codeName, projectDir) {
4449
4592
  try {
4450
- const raw = readFileSync9(join8(projectDir, ".mcp.json"), "utf-8");
4593
+ const raw = readFileSync9(join9(projectDir, ".mcp.json"), "utf-8");
4451
4594
  return createHash3("sha256").update(canonicalJson(JSON.parse(raw))).digest("hex");
4452
4595
  } catch {
4453
4596
  return null;
@@ -4455,7 +4598,7 @@ function projectMcpHash(_codeName, projectDir) {
4455
4598
  }
4456
4599
  function projectMcpKeys(_codeName, projectDir) {
4457
4600
  try {
4458
- const raw = readFileSync9(join8(projectDir, ".mcp.json"), "utf-8");
4601
+ const raw = readFileSync9(join9(projectDir, ".mcp.json"), "utf-8");
4459
4602
  const parsed = JSON.parse(raw);
4460
4603
  const servers = parsed.mcpServers;
4461
4604
  if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
@@ -4466,7 +4609,7 @@ function projectMcpKeys(_codeName, projectDir) {
4466
4609
  }
4467
4610
  function readMcpHttpServerConfig(projectDir, serverKey, env) {
4468
4611
  try {
4469
- const raw = readFileSync9(join8(projectDir, ".mcp.json"), "utf-8");
4612
+ const raw = readFileSync9(join9(projectDir, ".mcp.json"), "utf-8");
4470
4613
  const servers = JSON.parse(raw).mcpServers ?? {};
4471
4614
  const entry = servers[serverKey];
4472
4615
  if (entry && typeof entry.url === "string" && (entry.type === "http" || entry.type === void 0)) {
@@ -4494,7 +4637,7 @@ async function runAgentConnectivityProbes(agent, integrations, projectDir) {
4494
4637
  if (integrations.length === 0) return;
4495
4638
  const probeEnv = { ...process.env };
4496
4639
  try {
4497
- const envIntPath = join8(projectDir, ".env.integrations");
4640
+ const envIntPath = join9(projectDir, ".env.integrations");
4498
4641
  if (existsSync5(envIntPath)) {
4499
4642
  Object.assign(probeEnv, parseEnvIntegrations(readFileSync9(envIntPath, "utf-8")));
4500
4643
  }
@@ -4684,7 +4827,7 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
4684
4827
  function projectChannelSecretHash(projectDir) {
4685
4828
  try {
4686
4829
  const entries = parseEnvIntegrations(
4687
- readFileSync9(join8(projectDir, ".env.integrations"), "utf-8")
4830
+ readFileSync9(join9(projectDir, ".env.integrations"), "utf-8")
4688
4831
  );
4689
4832
  return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
4690
4833
  } catch {
@@ -4776,7 +4919,7 @@ var cachedMaintenanceWindow = null;
4776
4919
  var lastVersionCheckAt = 0;
4777
4920
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
4778
4921
  var lastResponsivenessProbeAt = 0;
4779
- var agtCliVersion = true ? "0.27.150" : "dev";
4922
+ var agtCliVersion = true ? "0.27.152" : "dev";
4780
4923
  function resolveBrewPath(execFileSync4) {
4781
4924
  try {
4782
4925
  const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
@@ -5027,7 +5170,7 @@ async function ensureFrameworkBinary(frameworkId) {
5027
5170
  var CLAUDE_CODE_UPGRADE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
5028
5171
  var claudeCodeUpgradeInFlight = false;
5029
5172
  function claudeCodeUpgradeMarkerPath() {
5030
- return join8(homedir4(), ".augmented", ".last-claude-code-upgrade-check");
5173
+ return join9(homedir5(), ".augmented", ".last-claude-code-upgrade-check");
5031
5174
  }
5032
5175
  function stampClaudeCodeUpgradeMarker() {
5033
5176
  try {
@@ -5090,7 +5233,7 @@ ${r.stderr}`;
5090
5233
  }
5091
5234
  var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
5092
5235
  function selfUpdateAppliedMarkerPath() {
5093
- return join8(homedir4(), ".augmented", ".last-self-update-applied");
5236
+ return join9(homedir5(), ".augmented", ".last-self-update-applied");
5094
5237
  }
5095
5238
  var selfUpdateUpToDateLogged = false;
5096
5239
  var restartAfterUpgrade = false;
@@ -5113,7 +5256,7 @@ async function checkAndUpdateCli() {
5113
5256
  const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
5114
5257
  if (!isBrewFormula && !isNpmGlobal) return;
5115
5258
  const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
5116
- const markerPath = join8(homedir4(), ".augmented", ".last-update-check");
5259
+ const markerPath = join9(homedir5(), ".augmented", ".last-update-check");
5117
5260
  try {
5118
5261
  const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
5119
5262
  if (Date.now() - lastCheck < UPDATE_CHECK_INTERVAL_MS) return;
@@ -5370,9 +5513,9 @@ async function applyClaudeAuthToEnv(childEnv, label) {
5370
5513
  throw new Error("claude_auth_mode=api_key but /host/exchange returned no decrypted key");
5371
5514
  }
5372
5515
  childEnv.ANTHROPIC_API_KEY = exchange.anthropicApiKey;
5373
- const claudeDir = join8(homedir4(), ".claude");
5516
+ const claudeDir = join9(homedir5(), ".claude");
5374
5517
  for (const filename of [".credentials.json", "credentials.json"]) {
5375
- const p = join8(claudeDir, filename);
5518
+ const p = join9(claudeDir, filename);
5376
5519
  if (existsSync5(p)) {
5377
5520
  try {
5378
5521
  rmSync2(p, { force: true });
@@ -5388,12 +5531,12 @@ async function applyClaudeAuthToEnv(childEnv, label) {
5388
5531
  var evalEmptyMcpConfigPath = null;
5389
5532
  function ensureEvalEmptyMcpConfig() {
5390
5533
  if (evalEmptyMcpConfigPath && existsSync5(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
5391
- const dir = join8(homedir4(), ".augmented");
5534
+ const dir = join9(homedir5(), ".augmented");
5392
5535
  try {
5393
5536
  mkdirSync4(dir, { recursive: true });
5394
5537
  } catch {
5395
5538
  }
5396
- const p = join8(dir, ".eval-empty-mcp.json");
5539
+ const p = join9(dir, ".eval-empty-mcp.json");
5397
5540
  writeFileSync4(p, JSON.stringify({ mcpServers: {} }));
5398
5541
  evalEmptyMcpConfigPath = p;
5399
5542
  return p;
@@ -5419,7 +5562,7 @@ async function runEvalClaude(prompt, model) {
5419
5562
  ""
5420
5563
  ];
5421
5564
  const { stdout } = await execFilePromiseLong(resolveClaudeBinary(), args, {
5422
- cwd: homedir4(),
5565
+ cwd: homedir5(),
5423
5566
  timeout: 12e4,
5424
5567
  stdin: "ignore",
5425
5568
  env: childEnv,
@@ -5498,10 +5641,10 @@ function freePort(codeName) {
5498
5641
  }
5499
5642
  }
5500
5643
  function getStateFile() {
5501
- return join8(config?.configDir ?? join8(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
5644
+ return join9(config?.configDir ?? join9(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
5502
5645
  }
5503
5646
  function channelHashCacheDir() {
5504
- return config?.configDir ?? join8(process.env["HOME"] ?? "/tmp", ".augmented");
5647
+ return config?.configDir ?? join9(process.env["HOME"] ?? "/tmp", ".augmented");
5505
5648
  }
5506
5649
  function loadChannelHashCache2() {
5507
5650
  loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
@@ -5512,7 +5655,7 @@ function saveChannelHashCache2() {
5512
5655
  var _channelQuarantineStore = null;
5513
5656
  function channelQuarantineStore() {
5514
5657
  if (!_channelQuarantineStore) {
5515
- const dir = config?.configDir ?? join8(process.env["HOME"] ?? "/tmp", ".augmented");
5658
+ const dir = config?.configDir ?? join9(process.env["HOME"] ?? "/tmp", ".augmented");
5516
5659
  _channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
5517
5660
  }
5518
5661
  return _channelQuarantineStore;
@@ -5567,7 +5710,7 @@ function log(msg) {
5567
5710
  `;
5568
5711
  if (!managerLogPath) {
5569
5712
  try {
5570
- managerLogPath = join8(homedir4(), ".augmented", "manager.log");
5713
+ managerLogPath = join9(homedir5(), ".augmented", "manager.log");
5571
5714
  mkdirSync4(dirname3(managerLogPath), { recursive: true });
5572
5715
  if (existsSync5(managerLogPath)) {
5573
5716
  chmodSync(managerLogPath, 384);
@@ -5622,12 +5765,12 @@ function parseSkillFrontmatter(content) {
5622
5765
  }
5623
5766
  async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
5624
5767
  const { readdirSync: readdirSync5, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync5 } = await import("fs");
5625
- const skillsDir = join8(configDir, codeName, "project", ".claude", "skills");
5626
- const claudeMdPath = join8(configDir, codeName, "project", "CLAUDE.md");
5768
+ const skillsDir = join9(configDir, codeName, "project", ".claude", "skills");
5769
+ const claudeMdPath = join9(configDir, codeName, "project", "CLAUDE.md");
5627
5770
  if (!ex(skillsDir) || !ex(claudeMdPath)) return;
5628
5771
  const entries = [];
5629
5772
  for (const dir of readdirSync5(skillsDir).sort()) {
5630
- const skillFile = join8(skillsDir, dir, "SKILL.md");
5773
+ const skillFile = join9(skillsDir, dir, "SKILL.md");
5631
5774
  if (!ex(skillFile)) continue;
5632
5775
  try {
5633
5776
  const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
@@ -5675,7 +5818,7 @@ ${SKILLS_INDEX_END}`;
5675
5818
  }
5676
5819
  async function migrateToProfiles() {
5677
5820
  const homeDir = process.env["HOME"] ?? "/tmp";
5678
- const sharedConfigPath = join8(homeDir, ".openclaw", "openclaw.json");
5821
+ const sharedConfigPath = join9(homeDir, ".openclaw", "openclaw.json");
5679
5822
  let sharedConfig;
5680
5823
  try {
5681
5824
  sharedConfig = JSON.parse(readFileSync9(sharedConfigPath, "utf-8"));
@@ -5691,19 +5834,19 @@ async function migrateToProfiles() {
5691
5834
  const codeName = agentEntry["id"];
5692
5835
  if (!codeName) continue;
5693
5836
  if (codeName === "main") continue;
5694
- const profileDir = join8(homeDir, `.openclaw-${codeName}`);
5695
- if (existsSync5(join8(profileDir, "openclaw.json"))) continue;
5837
+ const profileDir = join9(homeDir, `.openclaw-${codeName}`);
5838
+ if (existsSync5(join9(profileDir, "openclaw.json"))) continue;
5696
5839
  log(`Migrating agent '${codeName}' to per-agent profile`);
5697
5840
  if (adapter.seedProfileConfig) {
5698
5841
  adapter.seedProfileConfig(codeName);
5699
5842
  }
5700
- const sharedAuthDir = join8(homeDir, ".openclaw", "agents", codeName, "agent");
5701
- const profileAuthDir = join8(profileDir, "agents", codeName, "agent");
5702
- const authFile = join8(sharedAuthDir, "auth-profiles.json");
5843
+ const sharedAuthDir = join9(homeDir, ".openclaw", "agents", codeName, "agent");
5844
+ const profileAuthDir = join9(profileDir, "agents", codeName, "agent");
5845
+ const authFile = join9(sharedAuthDir, "auth-profiles.json");
5703
5846
  if (existsSync5(authFile)) {
5704
5847
  mkdirSync4(profileAuthDir, { recursive: true });
5705
5848
  const authContent = readFileSync9(authFile, "utf-8");
5706
- writeFileSync4(join8(profileAuthDir, "auth-profiles.json"), authContent);
5849
+ writeFileSync4(join9(profileAuthDir, "auth-profiles.json"), authContent);
5707
5850
  }
5708
5851
  allocatePort(codeName);
5709
5852
  migrated++;
@@ -5741,7 +5884,7 @@ function readGatewayToken(codeName) {
5741
5884
  }
5742
5885
  const homeDir = process.env["HOME"] ?? "/tmp";
5743
5886
  try {
5744
- const cfg = JSON.parse(readFileSync9(join8(homeDir, `.openclaw-${codeName}`, "openclaw.json"), "utf-8"));
5887
+ const cfg = JSON.parse(readFileSync9(join9(homeDir, `.openclaw-${codeName}`, "openclaw.json"), "utf-8"));
5745
5888
  return cfg?.gateway?.auth?.token;
5746
5889
  } catch {
5747
5890
  return void 0;
@@ -5750,7 +5893,7 @@ function readGatewayToken(codeName) {
5750
5893
  var GATEWAY_HUNG_TIMEOUT_MS = 5 * 6e4;
5751
5894
  function isGatewayHung(codeName) {
5752
5895
  const homeDir = process.env["HOME"] ?? "/tmp";
5753
- const jobsPath = join8(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
5896
+ const jobsPath = join9(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
5754
5897
  if (!existsSync5(jobsPath)) return false;
5755
5898
  try {
5756
5899
  const data = JSON.parse(readFileSync9(jobsPath, "utf-8"));
@@ -5786,13 +5929,13 @@ async function ensureGatewayRunning(codeName, adapter) {
5786
5929
  }
5787
5930
  await new Promise((r) => setTimeout(r, 2e3));
5788
5931
  const homeDir = process.env["HOME"] ?? "/tmp";
5789
- const cronJobsPath = join8(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
5932
+ const cronJobsPath = join9(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
5790
5933
  clearStaleCronRunState(cronJobsPath);
5791
5934
  } else {
5792
5935
  if (status.port) {
5793
5936
  try {
5794
5937
  const homeDir = process.env["HOME"] ?? "/tmp";
5795
- const configPath = join8(homeDir, `.openclaw-${codeName}`, "openclaw.json");
5938
+ const configPath = join9(homeDir, `.openclaw-${codeName}`, "openclaw.json");
5796
5939
  if (existsSync5(configPath)) {
5797
5940
  const cfg = JSON.parse(readFileSync9(configPath, "utf-8"));
5798
5941
  if (cfg.gateway?.port !== status.port) {
@@ -5818,7 +5961,7 @@ async function ensureGatewayRunning(codeName, adapter) {
5818
5961
  gatewaysStartedThisCycle.add(codeName);
5819
5962
  try {
5820
5963
  const homeDir = process.env["HOME"] ?? "/tmp";
5821
- const configPath = join8(homeDir, `.openclaw-${codeName}`, "openclaw.json");
5964
+ const configPath = join9(homeDir, `.openclaw-${codeName}`, "openclaw.json");
5822
5965
  if (existsSync5(configPath)) {
5823
5966
  const cfg = JSON.parse(readFileSync9(configPath, "utf-8"));
5824
5967
  if (!cfg.gateway) cfg.gateway = {};
@@ -5974,7 +6117,7 @@ async function pollCycle() {
5974
6117
  }
5975
6118
  try {
5976
6119
  const { detectHostSecurity } = await import("../host-security-6PDFG7F5.js");
5977
- const { collectDiagnostics } = await import("../persistent-session-ZLEK4KBF.js");
6120
+ const { collectDiagnostics } = await import("../persistent-session-THI6WSPJ.js");
5978
6121
  const diagCodeNames = [...agentState.persistentSessionAgents];
5979
6122
  const agentDiagnostics = diagCodeNames.length > 0 ? collectDiagnostics(diagCodeNames) : void 0;
5980
6123
  let tailscaleHostname;
@@ -6061,12 +6204,12 @@ async function pollCycle() {
6061
6204
  const {
6062
6205
  collectResponsivenessProbes,
6063
6206
  getResponsivenessIntervalMs
6064
- } = await import("../responsiveness-probe-3EUNCJDU.js");
6207
+ } = await import("../responsiveness-probe-UFF2EBGZ.js");
6065
6208
  const probeIntervalMs = getResponsivenessIntervalMs();
6066
6209
  if (now - lastResponsivenessProbeAt > probeIntervalMs) {
6067
6210
  const probeCodeNames = [...agentState.persistentSessionAgents];
6068
6211
  if (probeCodeNames.length > 0) {
6069
- const { takeAcpxExecFailureCount, creditAcpxExecFailureCount } = await import("../persistent-session-ZLEK4KBF.js");
6212
+ const { takeAcpxExecFailureCount, creditAcpxExecFailureCount } = await import("../persistent-session-THI6WSPJ.js");
6070
6213
  const drainedGiveUps = /* @__PURE__ */ new Map();
6071
6214
  const drainedAcpxFailures = /* @__PURE__ */ new Map();
6072
6215
  const probes = collectResponsivenessProbes(probeCodeNames).map((p) => {
@@ -6100,7 +6243,7 @@ async function pollCycle() {
6100
6243
  collectResponsivenessProbes,
6101
6244
  livePendingInboundOldestAgeSeconds,
6102
6245
  deadLetterPendingInbound
6103
- } = await import("../responsiveness-probe-3EUNCJDU.js");
6246
+ } = await import("../responsiveness-probe-UFF2EBGZ.js");
6104
6247
  const { getProjectDir: wedgeProjectDir } = await import("../claude-scheduler-FATCLHDM.js");
6105
6248
  const wedgeNow = /* @__PURE__ */ new Date();
6106
6249
  const liveAgents = agentState.persistentSessionAgents;
@@ -6329,7 +6472,7 @@ async function pollCycle() {
6329
6472
  }
6330
6473
  killAgentChannelProcesses(prev.codeName, { log });
6331
6474
  freePort(prev.codeName);
6332
- const agentDir = join8(adapter.getAgentDir(prev.codeName), "provision");
6475
+ const agentDir = join9(adapter.getAgentDir(prev.codeName), "provision");
6333
6476
  await cleanupAgentFiles(prev.codeName, agentDir);
6334
6477
  clearAgentCaches(prev.agentId, prev.codeName);
6335
6478
  }
@@ -6415,10 +6558,10 @@ async function pollCycle() {
6415
6558
  // pending-inbound marker. Best-effort: a write failure is logged by
6416
6559
  // the watchdog, never fails the poll cycle.
6417
6560
  signalGiveUp: (codeName) => {
6418
- const dir = join8(homedir4(), ".augmented", codeName);
6561
+ const dir = join9(homedir5(), ".augmented", codeName);
6419
6562
  if (!existsSync5(dir)) return;
6420
6563
  atomicWriteFileSync(
6421
- join8(dir, "watchdog-give-up.json"),
6564
+ join9(dir, "watchdog-give-up.json"),
6422
6565
  JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
6423
6566
  );
6424
6567
  }
@@ -6539,7 +6682,7 @@ async function processAgent(agent, agentStates) {
6539
6682
  }
6540
6683
  const now = (/* @__PURE__ */ new Date()).toISOString();
6541
6684
  const adapter = resolveAgentFramework(agent.code_name);
6542
- let agentDir = join8(adapter.getAgentDir(agent.code_name), "provision");
6685
+ let agentDir = join9(adapter.getAgentDir(agent.code_name), "provision");
6543
6686
  if (agent.status === "draft" || agent.status === "paused") {
6544
6687
  if (previousKnownStatus !== agent.status) {
6545
6688
  log(`Agent '${agent.code_name}' is ${agent.status}, skipping provisioning`);
@@ -6743,7 +6886,7 @@ async function processAgent(agent, agentStates) {
6743
6886
  const frameworkId = refreshData.agent.framework ?? "openclaw";
6744
6887
  agentFrameworkCache.set(agent.code_name, frameworkId);
6745
6888
  const frameworkAdapter = getFramework(frameworkId);
6746
- agentDir = join8(frameworkAdapter.getAgentDir(agent.code_name), "provision");
6889
+ agentDir = join9(frameworkAdapter.getAgentDir(agent.code_name), "provision");
6747
6890
  cacheAgentDeliveryMetadata(agent.code_name, refreshData);
6748
6891
  if (frameworkAdapter.migrateSecretStorage && !migratedSecretStorage.has(agent.code_name)) {
6749
6892
  try {
@@ -6786,7 +6929,7 @@ async function processAgent(agent, agentStates) {
6786
6929
  const changedFiles = [];
6787
6930
  mkdirSync4(agentDir, { recursive: true });
6788
6931
  for (const artifact of artifacts) {
6789
- const filePath = join8(agentDir, artifact.relativePath);
6932
+ const filePath = join9(agentDir, artifact.relativePath);
6790
6933
  let existingHash;
6791
6934
  let newHash;
6792
6935
  let writeContent = artifact.content;
@@ -6805,7 +6948,7 @@ async function processAgent(agent, agentStates) {
6805
6948
  };
6806
6949
  newHash = sha256(stripDynamicSections(artifact.content));
6807
6950
  try {
6808
- const projectClaudeMd = join8(config.configDir, agent.code_name, "project", "CLAUDE.md");
6951
+ const projectClaudeMd = join9(config.configDir, agent.code_name, "project", "CLAUDE.md");
6809
6952
  const existing = readFileSync9(projectClaudeMd, "utf-8");
6810
6953
  existingHash = sha256(stripDynamicSections(existing));
6811
6954
  } catch {
@@ -6846,12 +6989,12 @@ async function processAgent(agent, agentStates) {
6846
6989
  }
6847
6990
  }
6848
6991
  if (changedFiles.length > 0) {
6849
- const isFirst = !existsSync5(join8(agentDir, "CHARTER.md"));
6992
+ const isFirst = !existsSync5(join9(agentDir, "CHARTER.md"));
6850
6993
  const verb = isFirst ? "Provisioning" : "Updating";
6851
6994
  const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
6852
6995
  log(`${verb} '${agent.code_name}': ${fileNames}`);
6853
6996
  for (const file of changedFiles) {
6854
- const filePath = join8(agentDir, file.relativePath);
6997
+ const filePath = join9(agentDir, file.relativePath);
6855
6998
  mkdirSync4(dirname3(filePath), { recursive: true });
6856
6999
  if (file.relativePath === ".mcp.json") {
6857
7000
  safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
@@ -6860,12 +7003,12 @@ async function processAgent(agent, agentStates) {
6860
7003
  }
6861
7004
  }
6862
7005
  try {
6863
- const provSkillsDir = join8(agentDir, ".claude", "skills");
7006
+ const provSkillsDir = join9(agentDir, ".claude", "skills");
6864
7007
  if (existsSync5(provSkillsDir)) {
6865
7008
  for (const folder of readdirSync4(provSkillsDir)) {
6866
7009
  if (folder.startsWith("knowledge-")) {
6867
7010
  try {
6868
- rmSync2(join8(provSkillsDir, folder), { recursive: true });
7011
+ rmSync2(join9(provSkillsDir, folder), { recursive: true });
6869
7012
  } catch {
6870
7013
  }
6871
7014
  }
@@ -6878,7 +7021,7 @@ async function processAgent(agent, agentStates) {
6878
7021
  const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
6879
7022
  const hashes = /* @__PURE__ */ new Map();
6880
7023
  for (const file of trackedFiles2) {
6881
- const h = hashFile(join8(agentDir, file));
7024
+ const h = hashFile(join9(agentDir, file));
6882
7025
  if (h) hashes.set(file, h);
6883
7026
  }
6884
7027
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -6946,7 +7089,7 @@ async function processAgent(agent, agentStates) {
6946
7089
  if (written && existsSync5(agentDir)) {
6947
7090
  const driftedFiles = [];
6948
7091
  for (const [file, expectedHash] of written) {
6949
- const localHash = hashFile(join8(agentDir, file));
7092
+ const localHash = hashFile(join9(agentDir, file));
6950
7093
  if (localHash && localHash !== expectedHash) {
6951
7094
  driftedFiles.push(file);
6952
7095
  }
@@ -6957,7 +7100,7 @@ async function processAgent(agent, agentStates) {
6957
7100
  try {
6958
7101
  const localHashes = {};
6959
7102
  for (const file of driftedFiles) {
6960
- localHashes[file] = hashFile(join8(agentDir, file));
7103
+ localHashes[file] = hashFile(join9(agentDir, file));
6961
7104
  }
6962
7105
  await api.post("/host/drift", {
6963
7106
  agent_id: agent.agent_id,
@@ -7281,18 +7424,18 @@ async function processAgent(agent, agentStates) {
7281
7424
  if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? "openclaw") === "claude-code") {
7282
7425
  try {
7283
7426
  const agentProvisionDir = agentDir;
7284
- const projectDir = join8(homedir4(), ".augmented", agent.code_name, "project");
7427
+ const projectDir = join9(homedir5(), ".augmented", agent.code_name, "project");
7285
7428
  mkdirSync4(agentProvisionDir, { recursive: true });
7286
7429
  mkdirSync4(projectDir, { recursive: true });
7287
- const provisionMcpPath = join8(agentProvisionDir, ".mcp.json");
7288
- const projectMcpPath = join8(projectDir, ".mcp.json");
7430
+ const provisionMcpPath = join9(agentProvisionDir, ".mcp.json");
7431
+ const projectMcpPath = join9(projectDir, ".mcp.json");
7289
7432
  let mcpConfig = { mcpServers: {} };
7290
7433
  try {
7291
7434
  mcpConfig = JSON.parse(readFileSync9(provisionMcpPath, "utf-8"));
7292
7435
  if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
7293
7436
  } catch {
7294
7437
  }
7295
- const localDirectChatChannel = join8(homedir4(), ".augmented", "_mcp", "direct-chat-channel.js");
7438
+ const localDirectChatChannel = join9(homedir5(), ".augmented", "_mcp", "direct-chat-channel.js");
7296
7439
  const directChatTeamSettings = refreshData.team?.settings;
7297
7440
  const directChatTz = (() => {
7298
7441
  const tz = directChatTeamSettings?.["timezone"];
@@ -7322,7 +7465,7 @@ async function processAgent(agent, agentStates) {
7322
7465
  log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
7323
7466
  }
7324
7467
  }
7325
- const staleChannelsPath = join8(projectDir, ".mcp-channels.json");
7468
+ const staleChannelsPath = join9(projectDir, ".mcp-channels.json");
7326
7469
  if (existsSync5(staleChannelsPath)) {
7327
7470
  try {
7328
7471
  rmSync2(staleChannelsPath, { force: true });
@@ -7387,7 +7530,7 @@ async function processAgent(agent, agentStates) {
7387
7530
  }
7388
7531
  if (process.env.AGT_CONNECTIVITY_PROBE_ENABLED === "true") {
7389
7532
  try {
7390
- const probeProjectDir = join8(homedir4(), ".augmented", agent.code_name, "project");
7533
+ const probeProjectDir = join9(homedir5(), ".augmented", agent.code_name, "project");
7391
7534
  await runAgentConnectivityProbes(agent, integrations, probeProjectDir);
7392
7535
  } catch (err) {
7393
7536
  log(`Connectivity probe failed for '${agent.code_name}': ${err.message}`);
@@ -7405,8 +7548,8 @@ async function processAgent(agent, agentStates) {
7405
7548
  recordConfigChurnEvent(agent.agent_id, agent.code_name, FLAP_CHANNEL_INTEGRATIONS, intMembership);
7406
7549
  }
7407
7550
  if (intHash !== prevIntHash) {
7408
- const projectDir = join8(homedir4(), ".augmented", agent.code_name, "project");
7409
- const envIntPath = join8(projectDir, ".env.integrations");
7551
+ const projectDir = join9(homedir5(), ".augmented", agent.code_name, "project");
7552
+ const envIntPath = join9(projectDir, ".env.integrations");
7410
7553
  let preWriteEnv;
7411
7554
  try {
7412
7555
  preWriteEnv = readFileSync9(envIntPath, "utf-8");
@@ -7421,7 +7564,7 @@ async function processAgent(agent, agentStates) {
7421
7564
  let rotationHandled = true;
7422
7565
  if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
7423
7566
  try {
7424
- const projectMcpPath = join8(projectDir, ".mcp.json");
7567
+ const projectMcpPath = join9(projectDir, ".mcp.json");
7425
7568
  const postWriteEnv = readFileSync9(envIntPath, "utf-8");
7426
7569
  const mcpContent = readFileSync9(projectMcpPath, "utf-8");
7427
7570
  const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
@@ -7605,7 +7748,7 @@ async function processAgent(agent, agentStates) {
7605
7748
  if (agent.status === "active") {
7606
7749
  if (frameworkAdapter.installPlugin) {
7607
7750
  try {
7608
- const pluginPath = join8(process.cwd(), "packages", "openclaw-plugin-augmented", "src", "index.ts");
7751
+ const pluginPath = join9(process.cwd(), "packages", "openclaw-plugin-augmented", "src", "index.ts");
7609
7752
  if (existsSync5(pluginPath)) {
7610
7753
  frameworkAdapter.installPlugin(agent.code_name, "augmented", pluginPath, {
7611
7754
  agtHost: requireHost(),
@@ -7672,18 +7815,18 @@ async function processAgent(agent, agentStates) {
7672
7815
  }
7673
7816
  try {
7674
7817
  const { readdirSync: readdirSync5, rmSync: rmSync3 } = await import("fs");
7675
- const { homedir: homedir5 } = await import("os");
7818
+ const { homedir: homedir6 } = await import("os");
7676
7819
  const frameworkId2 = frameworkAdapter.id;
7677
7820
  const candidateSkillDirs = [
7678
7821
  // Claude Code — framework runtime tree
7679
- join8(homedir5(), ".augmented", agent.code_name, "skills"),
7822
+ join9(homedir6(), ".augmented", agent.code_name, "skills"),
7680
7823
  // Claude Code — project tree
7681
- join8(homedir5(), ".augmented", agent.code_name, "project", ".claude", "skills"),
7824
+ join9(homedir6(), ".augmented", agent.code_name, "project", ".claude", "skills"),
7682
7825
  // OpenClaw — framework runtime tree
7683
- join8(homedir5(), `.openclaw-${agent.code_name}`, "skills"),
7826
+ join9(homedir6(), `.openclaw-${agent.code_name}`, "skills"),
7684
7827
  // Defensive: legacy provision-side path, not currently an
7685
7828
  // install target but cheap to sweep.
7686
- join8(agentDir, ".claude", "skills")
7829
+ join9(agentDir, ".claude", "skills")
7687
7830
  ];
7688
7831
  const existingDirs = candidateSkillDirs.filter((d) => existsSync5(d));
7689
7832
  const discoveredEntries = /* @__PURE__ */ new Set();
@@ -7699,7 +7842,7 @@ async function processAgent(agent, agentStates) {
7699
7842
  }
7700
7843
  const removeSkillFolder = (entry, reason) => {
7701
7844
  for (const dir of existingDirs) {
7702
- const p = join8(dir, entry);
7845
+ const p = join9(dir, entry);
7703
7846
  if (existsSync5(p)) {
7704
7847
  rmSync3(p, { recursive: true, force: true });
7705
7848
  }
@@ -7879,7 +8022,7 @@ async function processAgent(agent, agentStates) {
7879
8022
  const sess = getSessionState(agent.code_name);
7880
8023
  let mcpJsonParsed = null;
7881
8024
  try {
7882
- const mcpPath = join8(getProjectDir(agent.code_name), ".mcp.json");
8025
+ const mcpPath = join9(getProjectDir(agent.code_name), ".mcp.json");
7883
8026
  mcpJsonParsed = JSON.parse(readFileSync9(mcpPath, "utf-8"));
7884
8027
  } catch {
7885
8028
  }
@@ -8089,7 +8232,7 @@ async function processAgent(agent, agentStates) {
8089
8232
  lastWorkTriggerAt.set(agent.code_name, triggerTs);
8090
8233
  if (agentFw === "openclaw" && gatewayRunning && gatewayPort) {
8091
8234
  const homeDir = process.env["HOME"] ?? "/tmp";
8092
- const jobsPath = join8(homeDir, `.openclaw-${agent.code_name}`, "cron", "jobs.json");
8235
+ const jobsPath = join9(homeDir, `.openclaw-${agent.code_name}`, "cron", "jobs.json");
8093
8236
  if (existsSync5(jobsPath)) {
8094
8237
  try {
8095
8238
  const jobsData = JSON.parse(readFileSync9(jobsPath, "utf-8"));
@@ -8229,7 +8372,7 @@ In progress for ${age} minutes \u2014 auto-failed`).catch(() => {
8229
8372
  if (trackedFiles.length > 0 && existsSync5(agentDir)) {
8230
8373
  const hashes = /* @__PURE__ */ new Map();
8231
8374
  for (const file of trackedFiles) {
8232
- const h = hashFile(join8(agentDir, file));
8375
+ const h = hashFile(join9(agentDir, file));
8233
8376
  if (h) hashes.set(file, h);
8234
8377
  }
8235
8378
  agentState.writtenHashes.set(agent.agent_id, hashes);
@@ -8263,16 +8406,16 @@ function cleanupStaleSessions(codeName) {
8263
8406
  lastCleanupAt.set(codeName, Date.now());
8264
8407
  const homeDir = process.env["HOME"] ?? "/tmp";
8265
8408
  for (const agentDir of ["main", codeName]) {
8266
- const sessionsDir = join8(homeDir, `.openclaw-${codeName}`, "agents", agentDir, "sessions");
8409
+ const sessionsDir = join9(homeDir, `.openclaw-${codeName}`, "agents", agentDir, "sessions");
8267
8410
  cleanupCronSessions(sessionsDir, CRON_SESSION_KEEP_COUNT);
8268
8411
  }
8269
- const cronRunsDir = join8(homeDir, `.openclaw-${codeName}`, "cron", "runs");
8412
+ const cronRunsDir = join9(homeDir, `.openclaw-${codeName}`, "cron", "runs");
8270
8413
  cleanupOldFiles(cronRunsDir, CRON_RUN_RETENTION_DAYS, ".jsonl");
8271
- const cronJobsPath = join8(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
8414
+ const cronJobsPath = join9(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
8272
8415
  clearStaleCronRunState(cronJobsPath);
8273
8416
  }
8274
8417
  function cleanupCronSessions(sessionsDir, keepCount) {
8275
- const indexPath = join8(sessionsDir, "sessions.json");
8418
+ const indexPath = join9(sessionsDir, "sessions.json");
8276
8419
  if (!existsSync5(indexPath)) return;
8277
8420
  try {
8278
8421
  const raw = readFileSync9(indexPath, "utf-8");
@@ -8288,7 +8431,7 @@ function cleanupCronSessions(sessionsDir, keepCount) {
8288
8431
  for (const entry of toDelete) {
8289
8432
  delete index[entry.key];
8290
8433
  if (entry.sessionId) {
8291
- const sessionFile = join8(sessionsDir, `${entry.sessionId}.jsonl`);
8434
+ const sessionFile = join9(sessionsDir, `${entry.sessionId}.jsonl`);
8292
8435
  try {
8293
8436
  if (existsSync5(sessionFile)) {
8294
8437
  unlinkSync(sessionFile);
@@ -8310,7 +8453,7 @@ function cleanupCronSessions(sessionsDir, keepCount) {
8310
8453
  delete index[parentKey];
8311
8454
  if (parentSessionId) {
8312
8455
  try {
8313
- const f = join8(sessionsDir, `${parentSessionId}.jsonl`);
8456
+ const f = join9(sessionsDir, `${parentSessionId}.jsonl`);
8314
8457
  if (existsSync5(f)) {
8315
8458
  unlinkSync(f);
8316
8459
  deletedFiles++;
@@ -8368,7 +8511,7 @@ function cleanupOldFiles(dir, maxAgeDays, ext) {
8368
8511
  try {
8369
8512
  for (const f of readdirSync4(dir)) {
8370
8513
  if (!f.endsWith(ext)) continue;
8371
- const fullPath = join8(dir, f);
8514
+ const fullPath = join9(dir, f);
8372
8515
  try {
8373
8516
  const st = statSync3(fullPath);
8374
8517
  if (st.mtimeMs < cutoff) {
@@ -8408,7 +8551,7 @@ var inFlightClaudeTasks = /* @__PURE__ */ new Set();
8408
8551
  var claudeTaskConcurrency = /* @__PURE__ */ new Map();
8409
8552
  var MAX_CLAUDE_CONCURRENCY = 2;
8410
8553
  function claudePidFilePath() {
8411
- return join8(homedir4(), ".augmented", "manager-claude-pids.json");
8554
+ return join9(homedir5(), ".augmented", "manager-claude-pids.json");
8412
8555
  }
8413
8556
  var inFlightClaudePids = /* @__PURE__ */ new Map();
8414
8557
  function registerClaudeSpawn(record) {
@@ -8748,7 +8891,7 @@ async function fireScheduledTaskViaKanban(codeName, agentId, task, prompt) {
8748
8891
  }
8749
8892
  async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
8750
8893
  const projectDir = getProjectDir2(codeName);
8751
- const mcpConfigPath = join8(projectDir, ".mcp.json");
8894
+ const mcpConfigPath = join9(projectDir, ".mcp.json");
8752
8895
  let runId = null;
8753
8896
  let kanbanItemId = null;
8754
8897
  let taskResult;
@@ -8756,7 +8899,7 @@ async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
8756
8899
  const priorRuns = await fetchPriorScheduledRuns(agentId, task.taskId);
8757
8900
  prompt = wrapScheduledTaskPrompt(prompt, { priorRuns });
8758
8901
  try {
8759
- const claudeMdPath = join8(projectDir, "CLAUDE.md");
8902
+ const claudeMdPath = join9(projectDir, "CLAUDE.md");
8760
8903
  const serverNames = [];
8761
8904
  if (existsSync5(mcpConfigPath)) {
8762
8905
  try {
@@ -8783,7 +8926,7 @@ async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
8783
8926
  claudeArgs.push("--system-prompt-file", claudeMdPath);
8784
8927
  }
8785
8928
  const childEnv = { ...process.env };
8786
- const envIntPath = join8(projectDir, ".env.integrations");
8929
+ const envIntPath = join9(projectDir, ".env.integrations");
8787
8930
  if (existsSync5(envIntPath)) {
8788
8931
  try {
8789
8932
  Object.assign(childEnv, parseEnvIntegrations(readFileSync9(envIntPath, "utf-8")));
@@ -8958,8 +9101,8 @@ var claudeAuthTupleBySession = /* @__PURE__ */ new Map();
8958
9101
  async function ensurePersistentSession(agent, tasks, boardItems, refreshData) {
8959
9102
  const codeName = agent.code_name;
8960
9103
  const projectDir = getProjectDir(codeName);
8961
- const mcpConfigPath = join8(projectDir, ".mcp.json");
8962
- const claudeMdPath = join8(projectDir, "CLAUDE.md");
9104
+ const mcpConfigPath = join9(projectDir, ".mcp.json");
9105
+ const claudeMdPath = join9(projectDir, "CLAUDE.md");
8963
9106
  if (restartBreaker.isTripped(codeName)) {
8964
9107
  const trip = restartBreaker.getTrip(codeName);
8965
9108
  return {
@@ -9593,7 +9736,7 @@ ${escapeXml(msg.content)}
9593
9736
  log(`[direct-chat] One-shot spawn for '${agent.codeName}' (msg=${msg.id}; host in-flight=${directChatSpawnGate.hostInFlight}, queued=${directChatSpawnGate.queuedCount})`);
9594
9737
  const { getProjectDir: ccProjectDir } = await import("../claude-scheduler-FATCLHDM.js");
9595
9738
  const projDir = ccProjectDir(agent.codeName);
9596
- const mcpConfigPath = join8(projDir, ".mcp.json");
9739
+ const mcpConfigPath = join9(projDir, ".mcp.json");
9597
9740
  const serverNames = [];
9598
9741
  if (existsSync5(mcpConfigPath)) {
9599
9742
  try {
@@ -9616,11 +9759,11 @@ ${escapeXml(msg.content)}
9616
9759
  "--allowedTools",
9617
9760
  allowedTools
9618
9761
  ];
9619
- const chatClaudeMd = join8(projDir, "CLAUDE.md");
9762
+ const chatClaudeMd = join9(projDir, "CLAUDE.md");
9620
9763
  if (existsSync5(chatClaudeMd)) {
9621
9764
  chatArgs.push("--system-prompt-file", chatClaudeMd);
9622
9765
  }
9623
- const envIntPath = join8(projDir, ".env.integrations");
9766
+ const envIntPath = join9(projDir, ".env.integrations");
9624
9767
  const childEnv = { ...process.env };
9625
9768
  if (existsSync5(envIntPath)) {
9626
9769
  try {
@@ -10002,8 +10145,8 @@ function getBuiltInSkillContent(skillId) {
10002
10145
  if (builtInSkillCache.has(skillId)) return builtInSkillCache.get(skillId);
10003
10146
  try {
10004
10147
  const candidates = [
10005
- join8(process.cwd(), "skills", skillId, "SKILL.md"),
10006
- join8(new URL(".", import.meta.url).pathname, "..", "..", "..", "..", "skills", skillId, "SKILL.md")
10148
+ join9(process.cwd(), "skills", skillId, "SKILL.md"),
10149
+ join9(new URL(".", import.meta.url).pathname, "..", "..", "..", "..", "skills", skillId, "SKILL.md")
10007
10150
  ];
10008
10151
  for (const candidate of candidates) {
10009
10152
  if (existsSync5(candidate)) {
@@ -10662,7 +10805,7 @@ async function processClaudePairSessions(agents) {
10662
10805
  killPairSession,
10663
10806
  pairTmuxSession,
10664
10807
  finalizeClaudePairOnboarding
10665
- } = await import("../claude-pair-runtime-3ZIOY3Z5.js");
10808
+ } = await import("../claude-pair-runtime-VSUJJO67.js");
10666
10809
  for (const pairId of pendingResp.cancelled_pair_ids ?? []) {
10667
10810
  log(`[claude-pair] sweeping orphan tmux session for pair ${pairId.slice(0, 8)}`);
10668
10811
  const killed = await killPairSession(pairTmuxSession(pairId));
@@ -10723,11 +10866,11 @@ async function processClaudePairSessions(agents) {
10723
10866
  });
10724
10867
  } else {
10725
10868
  const errKind = result.error.kind;
10726
- const errMessage = "message" in result.error ? result.error.message : void 0;
10869
+ const errMessage2 = "message" in result.error ? result.error.message : void 0;
10727
10870
  await reportAndCleanup(session.pair_id, {
10728
10871
  status: errKind === "no-session" ? "session_missing" : "failure",
10729
10872
  error_code: errKind,
10730
- error_message: errMessage
10873
+ error_message: errMessage2
10731
10874
  });
10732
10875
  }
10733
10876
  } else if (session.status === "code_submitted" && session.code) {
@@ -10756,11 +10899,11 @@ async function processClaudePairSessions(agents) {
10756
10899
  });
10757
10900
  } else {
10758
10901
  const errKind = result.error.kind;
10759
- const errMessage = "message" in result.error ? result.error.message : void 0;
10902
+ const errMessage2 = "message" in result.error ? result.error.message : void 0;
10760
10903
  await reportAndCleanup(session.pair_id, {
10761
10904
  status: errKind === "no-session" ? "session_missing" : "failure",
10762
10905
  error_code: errKind,
10763
- error_message: errMessage
10906
+ error_message: errMessage2
10764
10907
  });
10765
10908
  }
10766
10909
  }
@@ -10972,8 +11115,8 @@ function parseMemoryFile(raw, fallbackName) {
10972
11115
  };
10973
11116
  }
10974
11117
  async function syncMemories(agent, configDir, log2) {
10975
- const projectDir = join8(configDir, agent.code_name, "project");
10976
- const memoryDir = join8(projectDir, "memory");
11118
+ const projectDir = join9(configDir, agent.code_name, "project");
11119
+ const memoryDir = join9(projectDir, "memory");
10977
11120
  const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
10978
11121
  if (isFreshSync) {
10979
11122
  log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
@@ -10991,7 +11134,7 @@ async function syncMemories(agent, configDir, log2) {
10991
11134
  for (const file of readdirSync4(memoryDir)) {
10992
11135
  if (!file.endsWith(".md")) continue;
10993
11136
  try {
10994
- const raw = readFileSync9(join8(memoryDir, file), "utf-8");
11137
+ const raw = readFileSync9(join9(memoryDir, file), "utf-8");
10995
11138
  const fileHash = createHash3("sha256").update(raw).digest("hex").slice(0, 16);
10996
11139
  currentHashes.set(file, fileHash);
10997
11140
  if (prevHashes.get(file) === fileHash) continue;
@@ -11016,7 +11159,7 @@ async function syncMemories(agent, configDir, log2) {
11016
11159
  } catch (err) {
11017
11160
  for (const mem of changedMemories) {
11018
11161
  for (const [file] of currentHashes) {
11019
- const parsed = parseMemoryFile(readFileSync9(join8(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
11162
+ const parsed = parseMemoryFile(readFileSync9(join9(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
11020
11163
  if (parsed?.name === mem.name) currentHashes.delete(file);
11021
11164
  }
11022
11165
  }
@@ -11051,7 +11194,7 @@ async function downloadMemories(agent, memoryDir, log2, { force }) {
11051
11194
  const mem = dbMemories.memories[i];
11052
11195
  const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
11053
11196
  const slug = rawSlug || `memory-${i}`;
11054
- const filePath = join8(memoryDir, `${slug}.md`);
11197
+ const filePath = join9(memoryDir, `${slug}.md`);
11055
11198
  const desired = `---
11056
11199
  name: ${JSON.stringify(mem.name)}
11057
11200
  type: ${mem.type}
@@ -11172,6 +11315,43 @@ function stopCaffeinate() {
11172
11315
  log("caffeinate stopped");
11173
11316
  }
11174
11317
  }
11318
+ var artifactScanners = /* @__PURE__ */ new Map();
11319
+ var artifactStreamingInFlight = false;
11320
+ async function driveArtifactStreaming() {
11321
+ if (!isArtifactStreamingEnabled()) return;
11322
+ if (artifactStreamingInFlight) return;
11323
+ artifactStreamingInFlight = true;
11324
+ try {
11325
+ await driveArtifactStreamingInner();
11326
+ } finally {
11327
+ artifactStreamingInFlight = false;
11328
+ }
11329
+ }
11330
+ async function driveArtifactStreamingInner() {
11331
+ const liveIds = /* @__PURE__ */ new Set();
11332
+ for (const agent of state6.agents) {
11333
+ if (!agent.agentId || !agent.codeName || agent.status !== "active") continue;
11334
+ liveIds.add(agent.agentId);
11335
+ let scanner = artifactScanners.get(agent.agentId);
11336
+ if (!scanner) {
11337
+ scanner = new ArtifactStreamScanner(
11338
+ agent.agentId,
11339
+ artifactsDirFor(agent.codeName),
11340
+ nodeArtifactFs,
11341
+ { api, log }
11342
+ );
11343
+ artifactScanners.set(agent.agentId, scanner);
11344
+ }
11345
+ try {
11346
+ await scanner.scanOnce();
11347
+ } catch (err) {
11348
+ log(`[artifact-stream] scan failed for ${agent.codeName}: ${err.message}`);
11349
+ }
11350
+ }
11351
+ for (const id of artifactScanners.keys()) {
11352
+ if (!liveIds.has(id)) artifactScanners.delete(id);
11353
+ }
11354
+ }
11175
11355
  function startPolling() {
11176
11356
  if (!config || running) return;
11177
11357
  running = true;
@@ -11183,6 +11363,7 @@ function startPolling() {
11183
11363
  startGatewayPool();
11184
11364
  return pollCycle();
11185
11365
  }).then(() => {
11366
+ void driveArtifactStreaming();
11186
11367
  scheduleNext();
11187
11368
  });
11188
11369
  }
@@ -11205,7 +11386,10 @@ function scheduleNext() {
11205
11386
  restartNow();
11206
11387
  return;
11207
11388
  }
11208
- void pollCycle().then(scheduleNext);
11389
+ void pollCycle().then(() => {
11390
+ void driveArtifactStreaming();
11391
+ scheduleNext();
11392
+ });
11209
11393
  }, delayMs);
11210
11394
  }
11211
11395
  async function killAllAgtTmuxSessions() {
@@ -11298,7 +11482,7 @@ function startManager(opts) {
11298
11482
  log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
11299
11483
  }
11300
11484
  log(
11301
- `[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join8(homedir4(), ".augmented", "manager.log")}`
11485
+ `[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join9(homedir5(), ".augmented", "manager.log")}`
11302
11486
  );
11303
11487
  deployMcpAssets();
11304
11488
  reapOrphanChannelMcps({ log });
@@ -11429,14 +11613,14 @@ function restartRunningChannelMcps(basenames) {
11429
11613
  }
11430
11614
  }
11431
11615
  function deployMcpAssets() {
11432
- const targetDir = join8(homedir4(), ".augmented", "_mcp");
11616
+ const targetDir = join9(homedir5(), ".augmented", "_mcp");
11433
11617
  mkdirSync4(targetDir, { recursive: true });
11434
11618
  const moduleDir = dirname3(fileURLToPath(import.meta.url));
11435
11619
  let mcpSourceDir = "";
11436
11620
  let dir = moduleDir;
11437
11621
  for (let i = 0; i < 6; i++) {
11438
- const candidate = join8(dir, "dist", "mcp");
11439
- if (existsSync5(join8(candidate, "index.js"))) {
11622
+ const candidate = join9(dir, "dist", "mcp");
11623
+ if (existsSync5(join9(candidate, "index.js"))) {
11440
11624
  mcpSourceDir = candidate;
11441
11625
  break;
11442
11626
  }
@@ -11479,8 +11663,8 @@ function deployMcpAssets() {
11479
11663
  // natural session restart.
11480
11664
  "augmented-admin.js"
11481
11665
  ]) {
11482
- const src = join8(mcpSourceDir, file);
11483
- const dst = join8(targetDir, file);
11666
+ const src = join9(mcpSourceDir, file);
11667
+ const dst = join9(targetDir, file);
11484
11668
  if (!existsSync5(src)) continue;
11485
11669
  const before = fileHash(dst);
11486
11670
  try {
@@ -11498,14 +11682,14 @@ function deployMcpAssets() {
11498
11682
  log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
11499
11683
  restartRunningChannelMcps(changedBasenames);
11500
11684
  }
11501
- const localMcpPath = join8(targetDir, "index.js");
11685
+ const localMcpPath = join9(targetDir, "index.js");
11502
11686
  try {
11503
- const agentsDir = join8(homedir4(), ".augmented", "agents");
11687
+ const agentsDir = join9(homedir5(), ".augmented", "agents");
11504
11688
  if (existsSync5(agentsDir)) {
11505
11689
  for (const entry of readdirSync4(agentsDir, { withFileTypes: true })) {
11506
11690
  if (!entry.isDirectory()) continue;
11507
11691
  for (const subdir of ["provision", "project"]) {
11508
- const mcpJsonPath = join8(agentsDir, entry.name, subdir, ".mcp.json");
11692
+ const mcpJsonPath = join9(agentsDir, entry.name, subdir, ".mcp.json");
11509
11693
  try {
11510
11694
  const raw = readFileSync9(mcpJsonPath, "utf-8");
11511
11695
  if (!raw.includes("@integrity-labs/augmented-mcp")) continue;