@integrity-labs/agt-cli 0.28.36 → 0.28.37
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.
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
requireHost,
|
|
24
24
|
safeWriteJsonAtomic,
|
|
25
25
|
setConfigHash
|
|
26
|
-
} from "../chunk-
|
|
26
|
+
} from "../chunk-T3CD664K.js";
|
|
27
27
|
import {
|
|
28
28
|
getProjectDir as getProjectDir2,
|
|
29
29
|
getReadyTasks,
|
|
@@ -107,12 +107,38 @@ import {
|
|
|
107
107
|
|
|
108
108
|
// src/lib/manager-worker.ts
|
|
109
109
|
import { createHash as createHash6 } from "crypto";
|
|
110
|
-
import { readFileSync as
|
|
110
|
+
import { readFileSync as readFileSync14, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, existsSync as existsSync9, rmSync as rmSync3, readdirSync as readdirSync5, statSync as statSync4, unlinkSync, copyFileSync } from "fs";
|
|
111
111
|
import { execFileSync as syncExecFile } from "child_process";
|
|
112
|
-
import { join as
|
|
113
|
-
import { homedir as
|
|
112
|
+
import { join as join16, dirname as dirname4 } from "path";
|
|
113
|
+
import { homedir as homedir9 } from "os";
|
|
114
114
|
import { fileURLToPath } from "url";
|
|
115
115
|
|
|
116
|
+
// src/lib/claude-code-upgrade-throttle.ts
|
|
117
|
+
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
118
|
+
import { dirname, join } from "path";
|
|
119
|
+
import { homedir } from "os";
|
|
120
|
+
var CLAUDE_CODE_UPGRADE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
121
|
+
function claudeCodeUpgradeMarkerPath() {
|
|
122
|
+
return join(homedir(), ".augmented", ".last-claude-code-upgrade-check");
|
|
123
|
+
}
|
|
124
|
+
function stampClaudeCodeUpgradeMarker() {
|
|
125
|
+
try {
|
|
126
|
+
const markerPath = claudeCodeUpgradeMarkerPath();
|
|
127
|
+
mkdirSync(dirname(markerPath), { recursive: true });
|
|
128
|
+
writeFileSync(markerPath, String(Date.now()));
|
|
129
|
+
} catch {
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function claudeCodeUpgradeThrottled() {
|
|
133
|
+
try {
|
|
134
|
+
const lastCheck = parseInt(readFileSync(claudeCodeUpgradeMarkerPath(), "utf-8").trim(), 10);
|
|
135
|
+
if (!Number.isFinite(lastCheck)) return false;
|
|
136
|
+
return Date.now() - lastCheck < CLAUDE_CODE_UPGRADE_CHECK_INTERVAL_MS;
|
|
137
|
+
} catch {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
116
142
|
// src/lib/mcp-config-drift.ts
|
|
117
143
|
import { createHash } from "crypto";
|
|
118
144
|
function decideMcpDriftAction(currentHash, knownHash) {
|
|
@@ -767,8 +793,8 @@ function extractSlackBehaviourSubset(config2) {
|
|
|
767
793
|
}
|
|
768
794
|
|
|
769
795
|
// src/lib/channel-quarantine.ts
|
|
770
|
-
import { readFileSync } from "fs";
|
|
771
|
-
import { join } from "path";
|
|
796
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
797
|
+
import { join as join2 } from "path";
|
|
772
798
|
var ESSENTIAL_CHANNEL_KEYS = /* @__PURE__ */ new Set(["direct-chat", "augmented"]);
|
|
773
799
|
var OPTIONAL_CHANNEL_KEYS = /* @__PURE__ */ new Set([
|
|
774
800
|
"telegram",
|
|
@@ -797,7 +823,7 @@ function classifyChannelCriticality(serverKey, entry) {
|
|
|
797
823
|
return "essential";
|
|
798
824
|
}
|
|
799
825
|
function defaultQuarantinePath(configDir) {
|
|
800
|
-
return
|
|
826
|
+
return join2(configDir, "channel-quarantine.json");
|
|
801
827
|
}
|
|
802
828
|
var ChannelQuarantineStore = class {
|
|
803
829
|
path;
|
|
@@ -808,7 +834,7 @@ var ChannelQuarantineStore = class {
|
|
|
808
834
|
load() {
|
|
809
835
|
if (this.cache) return this.cache;
|
|
810
836
|
try {
|
|
811
|
-
const raw =
|
|
837
|
+
const raw = readFileSync2(this.path, "utf-8");
|
|
812
838
|
const parsed = JSON.parse(raw);
|
|
813
839
|
this.cache = isQuarantineFile(parsed) ? parsed : {};
|
|
814
840
|
} catch {
|
|
@@ -1395,8 +1421,8 @@ function runCliProbe(binary, args, opts = {}) {
|
|
|
1395
1421
|
}
|
|
1396
1422
|
|
|
1397
1423
|
// src/lib/self-update-coalesce.ts
|
|
1398
|
-
import { readFileSync as
|
|
1399
|
-
import { dirname } from "path";
|
|
1424
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
1425
|
+
import { dirname as dirname2 } from "path";
|
|
1400
1426
|
var DEFAULT_SELF_UPDATE_COALESCE_MS = 30 * 60 * 1e3;
|
|
1401
1427
|
function resolveCoalesceWindowMs(env = process.env) {
|
|
1402
1428
|
const raw = env.AGT_SELF_UPDATE_COALESCE_MS;
|
|
@@ -1405,7 +1431,7 @@ function resolveCoalesceWindowMs(env = process.env) {
|
|
|
1405
1431
|
if (!Number.isFinite(parsed) || parsed < 0) return DEFAULT_SELF_UPDATE_COALESCE_MS;
|
|
1406
1432
|
return Math.trunc(parsed);
|
|
1407
1433
|
}
|
|
1408
|
-
function readLastSelfUpdateAppliedMs(markerPath, now = Date.now(), read = (p) =>
|
|
1434
|
+
function readLastSelfUpdateAppliedMs(markerPath, now = Date.now(), read = (p) => readFileSync3(p, "utf-8")) {
|
|
1409
1435
|
let raw;
|
|
1410
1436
|
try {
|
|
1411
1437
|
raw = read(markerPath);
|
|
@@ -1418,8 +1444,8 @@ function readLastSelfUpdateAppliedMs(markerPath, now = Date.now(), read = (p) =>
|
|
|
1418
1444
|
return v;
|
|
1419
1445
|
}
|
|
1420
1446
|
function stampLastSelfUpdateApplied(markerPath, now = Date.now(), write = (p, v) => {
|
|
1421
|
-
|
|
1422
|
-
|
|
1447
|
+
mkdirSync2(dirname2(p), { recursive: true });
|
|
1448
|
+
writeFileSync2(p, v);
|
|
1423
1449
|
}) {
|
|
1424
1450
|
try {
|
|
1425
1451
|
write(markerPath, String(now));
|
|
@@ -1549,11 +1575,11 @@ function decideRestartGate(opts) {
|
|
|
1549
1575
|
}
|
|
1550
1576
|
|
|
1551
1577
|
// src/lib/claude-pid-tracker.ts
|
|
1552
|
-
import { existsSync, readFileSync as
|
|
1578
|
+
import { existsSync, readFileSync as readFileSync4 } from "fs";
|
|
1553
1579
|
function readPidFile(path) {
|
|
1554
1580
|
if (!existsSync(path)) return { version: 1, spawns: [] };
|
|
1555
1581
|
try {
|
|
1556
|
-
const raw = JSON.parse(
|
|
1582
|
+
const raw = JSON.parse(readFileSync4(path, "utf-8"));
|
|
1557
1583
|
if (raw.version !== 1 || !Array.isArray(raw.spawns)) return { version: 1, spawns: [] };
|
|
1558
1584
|
const spawns = raw.spawns.filter(
|
|
1559
1585
|
(s) => !!s && typeof s.pid === "number" && Number.isFinite(s.pid) && s.pid > 0
|
|
@@ -1606,7 +1632,7 @@ function formatReaperBootLine(opts) {
|
|
|
1606
1632
|
}
|
|
1607
1633
|
|
|
1608
1634
|
// src/lib/direct-chat-spawn-gate.ts
|
|
1609
|
-
import { join as
|
|
1635
|
+
import { join as join3 } from "path";
|
|
1610
1636
|
var DEFAULT_DIRECT_CHAT_HOST_CONCURRENCY = 2;
|
|
1611
1637
|
var DEFAULT_DIRECT_CHAT_PER_AGENT_CONCURRENCY = 1;
|
|
1612
1638
|
var DEFAULT_DIRECT_CHAT_MAX_AGE_MS = 30 * 6e4;
|
|
@@ -1619,7 +1645,7 @@ function directChatMaxAgeMs() {
|
|
|
1619
1645
|
return Number.isFinite(raw) && raw >= 0 ? raw : DEFAULT_DIRECT_CHAT_MAX_AGE_MS;
|
|
1620
1646
|
}
|
|
1621
1647
|
function directChatDoorbellPath(agentId, home) {
|
|
1622
|
-
return
|
|
1648
|
+
return join3(home, ".augmented", agentId, "direct-chat-doorbell");
|
|
1623
1649
|
}
|
|
1624
1650
|
function isDirectChatMessageExpired(createdAt, nowMs, maxAgeMs) {
|
|
1625
1651
|
if (!maxAgeMs || maxAgeMs <= 0) return false;
|
|
@@ -1722,8 +1748,8 @@ function collectEnvGates(env) {
|
|
|
1722
1748
|
}
|
|
1723
1749
|
|
|
1724
1750
|
// src/lib/artifact-stream.ts
|
|
1725
|
-
import { join as
|
|
1726
|
-
import { homedir } from "os";
|
|
1751
|
+
import { join as join4 } from "path";
|
|
1752
|
+
import { homedir as homedir2 } from "os";
|
|
1727
1753
|
import { readdir, stat, readFile } from "fs/promises";
|
|
1728
1754
|
var ARTEFACT_ENTRY_FILE = "index.html";
|
|
1729
1755
|
function errMessage(err) {
|
|
@@ -1808,7 +1834,7 @@ var ArtifactStreamScanner = class {
|
|
|
1808
1834
|
return;
|
|
1809
1835
|
}
|
|
1810
1836
|
for (const name of names) {
|
|
1811
|
-
const file =
|
|
1837
|
+
const file = join4(this.artifactsDir, name, ARTEFACT_ENTRY_FILE);
|
|
1812
1838
|
const mtime = await this.fsDeps.mtimeMs(file).catch(() => null);
|
|
1813
1839
|
if (mtime === null) continue;
|
|
1814
1840
|
if (this.seenMtime.get(name) === mtime) continue;
|
|
@@ -1839,7 +1865,7 @@ var ArtifactStreamScanner = class {
|
|
|
1839
1865
|
}
|
|
1840
1866
|
};
|
|
1841
1867
|
function artifactsDirFor(codeName) {
|
|
1842
|
-
return
|
|
1868
|
+
return join4(homedir2(), ".augmented", codeName, "artifacts");
|
|
1843
1869
|
}
|
|
1844
1870
|
var nodeArtifactFs = {
|
|
1845
1871
|
async listArtefactNames(artifactsDir) {
|
|
@@ -1914,8 +1940,8 @@ async function maybeReportUsageBanner(args) {
|
|
|
1914
1940
|
}
|
|
1915
1941
|
|
|
1916
1942
|
// src/lib/token-usage-monitor.ts
|
|
1917
|
-
import { readdirSync, readFileSync as
|
|
1918
|
-
import { join as
|
|
1943
|
+
import { readdirSync, readFileSync as readFileSync5, statSync } from "fs";
|
|
1944
|
+
import { join as join5 } from "path";
|
|
1919
1945
|
var MIN_CHECK_INTERVAL_MS2 = 6e4;
|
|
1920
1946
|
var TRANSCRIPT_MTIME_WINDOW_MS = 2 * 24 * 60 * 60 * 1e3;
|
|
1921
1947
|
var MAX_ENTRIES_PER_POST = 200;
|
|
@@ -1944,7 +1970,7 @@ async function maybeReportTokenUsage(args) {
|
|
|
1944
1970
|
if (!name.endsWith(".jsonl")) continue;
|
|
1945
1971
|
const sessionId = name.slice(0, -".jsonl".length);
|
|
1946
1972
|
if (!sessionId) continue;
|
|
1947
|
-
const path =
|
|
1973
|
+
const path = join5(dir, name);
|
|
1948
1974
|
let st;
|
|
1949
1975
|
try {
|
|
1950
1976
|
st = statSync(path);
|
|
@@ -1960,7 +1986,7 @@ async function maybeReportTokenUsage(args) {
|
|
|
1960
1986
|
}
|
|
1961
1987
|
let content;
|
|
1962
1988
|
try {
|
|
1963
|
-
content =
|
|
1989
|
+
content = readFileSync5(path, "utf-8");
|
|
1964
1990
|
} catch (err) {
|
|
1965
1991
|
log2(`[token-usage] read failed for '${codeName}/${name}': ${err.message}`);
|
|
1966
1992
|
continue;
|
|
@@ -2041,8 +2067,8 @@ async function maybeReportTokenUsage(args) {
|
|
|
2041
2067
|
}
|
|
2042
2068
|
|
|
2043
2069
|
// src/lib/workflow-run-reconciler.ts
|
|
2044
|
-
import { readdirSync as readdirSync2, readFileSync as
|
|
2045
|
-
import { join as
|
|
2070
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync6, statSync as statSync2 } from "fs";
|
|
2071
|
+
import { join as join6 } from "path";
|
|
2046
2072
|
var MIN_CHECK_INTERVAL_MS3 = 5 * 6e4;
|
|
2047
2073
|
var SETTLE_MS = 3e4;
|
|
2048
2074
|
var TRANSCRIPT_MTIME_WINDOW_MS2 = 2 * 24 * 60 * 60 * 1e3;
|
|
@@ -2061,7 +2087,7 @@ function collectJsonlRecursive(dir, minMtimeMs, out, depth) {
|
|
|
2061
2087
|
return;
|
|
2062
2088
|
}
|
|
2063
2089
|
for (const name of entries) {
|
|
2064
|
-
const p =
|
|
2090
|
+
const p = join6(dir, name);
|
|
2065
2091
|
let st;
|
|
2066
2092
|
try {
|
|
2067
2093
|
st = statSync2(p);
|
|
@@ -2084,7 +2110,7 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
|
|
|
2084
2110
|
return out;
|
|
2085
2111
|
}
|
|
2086
2112
|
for (const name of entries) {
|
|
2087
|
-
const path =
|
|
2113
|
+
const path = join6(transcriptDir, name);
|
|
2088
2114
|
let st;
|
|
2089
2115
|
try {
|
|
2090
2116
|
st = statSync2(path);
|
|
@@ -2096,7 +2122,7 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
|
|
|
2096
2122
|
continue;
|
|
2097
2123
|
}
|
|
2098
2124
|
if (st.isDirectory()) {
|
|
2099
|
-
collectJsonlRecursive(
|
|
2125
|
+
collectJsonlRecursive(join6(path, "subagents"), minMtimeMs, out, 0);
|
|
2100
2126
|
}
|
|
2101
2127
|
}
|
|
2102
2128
|
return out;
|
|
@@ -2141,7 +2167,7 @@ async function maybeReconcileWorkflowRunTokens(args) {
|
|
|
2141
2167
|
const contents = [];
|
|
2142
2168
|
for (const path of files) {
|
|
2143
2169
|
try {
|
|
2144
|
-
contents.push(
|
|
2170
|
+
contents.push(readFileSync6(path, "utf-8"));
|
|
2145
2171
|
} catch {
|
|
2146
2172
|
}
|
|
2147
2173
|
}
|
|
@@ -2186,8 +2212,8 @@ async function maybeReconcileWorkflowRunTokens(args) {
|
|
|
2186
2212
|
}
|
|
2187
2213
|
|
|
2188
2214
|
// src/lib/conversation-evaluator.ts
|
|
2189
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
2190
|
-
import { join as
|
|
2215
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync7, statSync as statSync3 } from "fs";
|
|
2216
|
+
import { join as join7 } from "path";
|
|
2191
2217
|
var MIN_CHECK_INTERVAL_MS4 = 5 * 6e4;
|
|
2192
2218
|
var TRANSCRIPT_MTIME_WINDOW_MS3 = 3 * 24 * 60 * 60 * 1e3;
|
|
2193
2219
|
var WINDOW_PAD_MS = 5 * 6e4;
|
|
@@ -2424,7 +2450,7 @@ function readRecentTurns(dir, nowMs) {
|
|
|
2424
2450
|
const turns = [];
|
|
2425
2451
|
for (const name of entries) {
|
|
2426
2452
|
if (!name.endsWith(".jsonl")) continue;
|
|
2427
|
-
const full =
|
|
2453
|
+
const full = join7(dir, name);
|
|
2428
2454
|
let mtimeMs;
|
|
2429
2455
|
try {
|
|
2430
2456
|
mtimeMs = statSync3(full).mtimeMs;
|
|
@@ -2434,7 +2460,7 @@ function readRecentTurns(dir, nowMs) {
|
|
|
2434
2460
|
if (nowMs - mtimeMs > TRANSCRIPT_MTIME_WINDOW_MS3) continue;
|
|
2435
2461
|
let content;
|
|
2436
2462
|
try {
|
|
2437
|
-
content =
|
|
2463
|
+
content = readFileSync7(full, "utf8");
|
|
2438
2464
|
} catch {
|
|
2439
2465
|
continue;
|
|
2440
2466
|
}
|
|
@@ -2603,11 +2629,11 @@ async function reportSkip2(api2, agentId, conversationId, log2, codeName) {
|
|
|
2603
2629
|
}
|
|
2604
2630
|
|
|
2605
2631
|
// src/lib/activity-cache-monitor.ts
|
|
2606
|
-
import { existsSync as existsSync2, readFileSync as
|
|
2607
|
-
import { homedir as
|
|
2608
|
-
import { join as
|
|
2632
|
+
import { existsSync as existsSync2, readFileSync as readFileSync8 } from "fs";
|
|
2633
|
+
import { homedir as homedir3 } from "os";
|
|
2634
|
+
import { join as join8 } from "path";
|
|
2609
2635
|
var MIN_CHECK_INTERVAL_MS6 = 6e4;
|
|
2610
|
-
var STATS_CACHE_PATH =
|
|
2636
|
+
var STATS_CACHE_PATH = join8(homedir3(), ".claude", "stats-cache.json");
|
|
2611
2637
|
var ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
2612
2638
|
var state5 = { lastObservedDate: null, lastCheckedAt: 0 };
|
|
2613
2639
|
function selectNewDailyRows(raw, lastObservedDate) {
|
|
@@ -2655,7 +2681,7 @@ async function maybeReportActivityCache(args) {
|
|
|
2655
2681
|
}
|
|
2656
2682
|
let raw;
|
|
2657
2683
|
try {
|
|
2658
|
-
raw =
|
|
2684
|
+
raw = readFileSync8(STATS_CACHE_PATH, "utf-8");
|
|
2659
2685
|
} catch (err) {
|
|
2660
2686
|
log2(`[activity-cache] readFileSync failed: ${err.message}`);
|
|
2661
2687
|
return;
|
|
@@ -3104,8 +3130,8 @@ var GatewayClientPool = class extends EventEmitter {
|
|
|
3104
3130
|
|
|
3105
3131
|
// src/lib/claude-auth-detect.ts
|
|
3106
3132
|
import { readFile as readFile2, readdir as readdir2 } from "fs/promises";
|
|
3107
|
-
import { homedir as
|
|
3108
|
-
import { join as
|
|
3133
|
+
import { homedir as homedir4, platform } from "os";
|
|
3134
|
+
import { join as join9 } from "path";
|
|
3109
3135
|
import { execFile as execFile2 } from "child_process";
|
|
3110
3136
|
import { promisify } from "util";
|
|
3111
3137
|
var execFileAsync = promisify(execFile2);
|
|
@@ -3120,8 +3146,8 @@ async function detectClaudeAuth() {
|
|
|
3120
3146
|
}
|
|
3121
3147
|
async function findClaudeCredentialsPaths() {
|
|
3122
3148
|
const candidates = [
|
|
3123
|
-
|
|
3124
|
-
|
|
3149
|
+
join9(homedir4(), ".claude", ".credentials.json"),
|
|
3150
|
+
join9(homedir4(), ".claude", "credentials.json")
|
|
3125
3151
|
];
|
|
3126
3152
|
const isLinuxRoot = platform() === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
|
|
3127
3153
|
if (isLinuxRoot) {
|
|
@@ -3129,8 +3155,8 @@ async function findClaudeCredentialsPaths() {
|
|
|
3129
3155
|
const entries = await readdir2("/home", { withFileTypes: true });
|
|
3130
3156
|
for (const entry of entries) {
|
|
3131
3157
|
if (!entry.isDirectory()) continue;
|
|
3132
|
-
candidates.push(
|
|
3133
|
-
candidates.push(
|
|
3158
|
+
candidates.push(join9("/home", entry.name, ".claude", ".credentials.json"));
|
|
3159
|
+
candidates.push(join9("/home", entry.name, ".claude", "credentials.json"));
|
|
3134
3160
|
}
|
|
3135
3161
|
} catch {
|
|
3136
3162
|
}
|
|
@@ -3222,18 +3248,18 @@ function normalize(value) {
|
|
|
3222
3248
|
}
|
|
3223
3249
|
|
|
3224
3250
|
// src/lib/channel-hash-cache.ts
|
|
3225
|
-
import { existsSync as existsSync3, readFileSync as
|
|
3226
|
-
import { join as
|
|
3251
|
+
import { existsSync as existsSync3, readFileSync as readFileSync9, writeFileSync as writeFileSync3 } from "fs";
|
|
3252
|
+
import { join as join10 } from "path";
|
|
3227
3253
|
var CACHE_FILENAME = "channel-hash-cache.json";
|
|
3228
3254
|
function getChannelHashCacheFile(configDir) {
|
|
3229
|
-
return
|
|
3255
|
+
return join10(configDir, CACHE_FILENAME);
|
|
3230
3256
|
}
|
|
3231
3257
|
function loadChannelHashCache(target, configDir) {
|
|
3232
3258
|
const path = getChannelHashCacheFile(configDir);
|
|
3233
3259
|
if (!existsSync3(path)) return;
|
|
3234
3260
|
let parsed;
|
|
3235
3261
|
try {
|
|
3236
|
-
parsed = JSON.parse(
|
|
3262
|
+
parsed = JSON.parse(readFileSync9(path, "utf-8"));
|
|
3237
3263
|
} catch {
|
|
3238
3264
|
return;
|
|
3239
3265
|
}
|
|
@@ -3247,7 +3273,7 @@ function saveChannelHashCache(source, configDir) {
|
|
|
3247
3273
|
const obj = {};
|
|
3248
3274
|
for (const [key, value] of source) obj[key] = value;
|
|
3249
3275
|
try {
|
|
3250
|
-
|
|
3276
|
+
writeFileSync3(path, JSON.stringify(obj, null, 2));
|
|
3251
3277
|
} catch {
|
|
3252
3278
|
}
|
|
3253
3279
|
}
|
|
@@ -3634,9 +3660,9 @@ function planGlobalSkillSync(globalSkills, prevIds, hashOf, knownHash) {
|
|
|
3634
3660
|
|
|
3635
3661
|
// src/lib/manager/runtime.ts
|
|
3636
3662
|
import { createHash as createHash4 } from "crypto";
|
|
3637
|
-
import { readFileSync as
|
|
3638
|
-
import { join as
|
|
3639
|
-
import { homedir as
|
|
3663
|
+
import { readFileSync as readFileSync10, appendFileSync, mkdirSync as mkdirSync3, chmodSync, existsSync as existsSync4 } from "fs";
|
|
3664
|
+
import { join as join11, dirname as dirname3 } from "path";
|
|
3665
|
+
import { homedir as homedir5 } from "os";
|
|
3640
3666
|
function redactForDiskLog(value) {
|
|
3641
3667
|
try {
|
|
3642
3668
|
return value.replace(/\b(Bearer\s+)[A-Za-z0-9._-]+\b/gi, "$1[REDACTED]").replace(/\bxox[baprs]-[A-Za-z0-9-]+\b/g, "[REDACTED-SLACK]").replace(/\btlk_[A-Za-z0-9._-]+\b/g, "[REDACTED-HOST]").replace(/\bsk-ant-[A-Za-z0-9_-]+\b/g, "[REDACTED-ANTHROPIC]").replace(/\b\d{8,12}:[A-Za-z0-9_-]{30,}\b/g, "[REDACTED-TELEGRAM]").replace(
|
|
@@ -3656,8 +3682,8 @@ function log(msg) {
|
|
|
3656
3682
|
`;
|
|
3657
3683
|
if (!managerLogPath) {
|
|
3658
3684
|
try {
|
|
3659
|
-
managerLogPath =
|
|
3660
|
-
|
|
3685
|
+
managerLogPath = join11(homedir5(), ".augmented", "manager.log");
|
|
3686
|
+
mkdirSync3(dirname3(managerLogPath), { recursive: true });
|
|
3661
3687
|
if (existsSync4(managerLogPath)) {
|
|
3662
3688
|
chmodSync(managerLogPath, 384);
|
|
3663
3689
|
}
|
|
@@ -3686,7 +3712,7 @@ function sha256(content) {
|
|
|
3686
3712
|
}
|
|
3687
3713
|
function hashFile(filePath) {
|
|
3688
3714
|
try {
|
|
3689
|
-
const content =
|
|
3715
|
+
const content = readFileSync10(filePath, "utf-8");
|
|
3690
3716
|
return sha256(content);
|
|
3691
3717
|
} catch {
|
|
3692
3718
|
return null;
|
|
@@ -3786,8 +3812,8 @@ function resolveModelChain(refreshData) {
|
|
|
3786
3812
|
|
|
3787
3813
|
// src/lib/manager/claude-auth.ts
|
|
3788
3814
|
import { existsSync as existsSync5, rmSync } from "fs";
|
|
3789
|
-
import { join as
|
|
3790
|
-
import { homedir as
|
|
3815
|
+
import { join as join12 } from "path";
|
|
3816
|
+
import { homedir as homedir6 } from "os";
|
|
3791
3817
|
async function applyClaudeAuthToEnv(childEnv, label) {
|
|
3792
3818
|
const apiKey = getApiKey();
|
|
3793
3819
|
if (!apiKey) {
|
|
@@ -3799,9 +3825,9 @@ async function applyClaudeAuthToEnv(childEnv, label) {
|
|
|
3799
3825
|
throw new Error("claude_auth_mode=api_key but /host/exchange returned no decrypted key");
|
|
3800
3826
|
}
|
|
3801
3827
|
childEnv.ANTHROPIC_API_KEY = exchange.anthropicApiKey;
|
|
3802
|
-
const claudeDir =
|
|
3828
|
+
const claudeDir = join12(homedir6(), ".claude");
|
|
3803
3829
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
3804
|
-
const p =
|
|
3830
|
+
const p = join12(claudeDir, filename);
|
|
3805
3831
|
if (existsSync5(p)) {
|
|
3806
3832
|
try {
|
|
3807
3833
|
rmSync(p, { force: true });
|
|
@@ -3816,8 +3842,8 @@ async function applyClaudeAuthToEnv(childEnv, label) {
|
|
|
3816
3842
|
}
|
|
3817
3843
|
|
|
3818
3844
|
// src/lib/manager/kanban/parsers.ts
|
|
3819
|
-
import { existsSync as existsSync6, readFileSync as
|
|
3820
|
-
import { join as
|
|
3845
|
+
import { existsSync as existsSync6, readFileSync as readFileSync11 } from "fs";
|
|
3846
|
+
import { join as join13 } from "path";
|
|
3821
3847
|
var STANDUP_TEMPLATES = /* @__PURE__ */ new Set(["daily-standup", "end-of-day-summary"]);
|
|
3822
3848
|
var TASK_UPDATE_TEMPLATES = /* @__PURE__ */ new Set(["hourly-status", "task-update"]);
|
|
3823
3849
|
var PLAN_TEMPLATES = /* @__PURE__ */ new Set(["morning-plan"]);
|
|
@@ -3937,12 +3963,12 @@ function getBuiltInSkillContent(skillId) {
|
|
|
3937
3963
|
if (builtInSkillCache.has(skillId)) return builtInSkillCache.get(skillId);
|
|
3938
3964
|
try {
|
|
3939
3965
|
const candidates = [
|
|
3940
|
-
|
|
3941
|
-
|
|
3966
|
+
join13(process.cwd(), "skills", skillId, "SKILL.md"),
|
|
3967
|
+
join13(new URL(".", import.meta.url).pathname, "..", "..", "..", "..", "..", "..", "skills", skillId, "SKILL.md")
|
|
3942
3968
|
];
|
|
3943
3969
|
for (const candidate of candidates) {
|
|
3944
3970
|
if (existsSync6(candidate)) {
|
|
3945
|
-
const content =
|
|
3971
|
+
const content = readFileSync11(candidate, "utf-8");
|
|
3946
3972
|
const files = [{ relativePath: "SKILL.md", content }];
|
|
3947
3973
|
builtInSkillCache.set(skillId, files);
|
|
3948
3974
|
return files;
|
|
@@ -4409,9 +4435,9 @@ async function sendTaskNotification(agentCodeName, channel, to, text) {
|
|
|
4409
4435
|
|
|
4410
4436
|
// src/lib/manager/scheduler.ts
|
|
4411
4437
|
import { createHash as createHash5 } from "crypto";
|
|
4412
|
-
import { readFileSync as
|
|
4413
|
-
import { homedir as
|
|
4414
|
-
import { join as
|
|
4438
|
+
import { readFileSync as readFileSync12, existsSync as existsSync7 } from "fs";
|
|
4439
|
+
import { homedir as homedir7 } from "os";
|
|
4440
|
+
import { join as join14 } from "path";
|
|
4415
4441
|
|
|
4416
4442
|
// src/lib/delivery-schedule-link.ts
|
|
4417
4443
|
function envSuffixFor2(codeName) {
|
|
@@ -4662,7 +4688,7 @@ var inFlightClaudeTasks = /* @__PURE__ */ new Set();
|
|
|
4662
4688
|
var claudeTaskConcurrency = /* @__PURE__ */ new Map();
|
|
4663
4689
|
var MAX_CLAUDE_CONCURRENCY = 2;
|
|
4664
4690
|
function claudePidFilePath() {
|
|
4665
|
-
return
|
|
4691
|
+
return join14(homedir7(), ".augmented", "manager-claude-pids.json");
|
|
4666
4692
|
}
|
|
4667
4693
|
var inFlightClaudePids = /* @__PURE__ */ new Map();
|
|
4668
4694
|
function registerClaudeSpawn(record) {
|
|
@@ -4998,7 +5024,7 @@ async function fireScheduledTaskViaKanban(codeName, agentId, task, prompt) {
|
|
|
4998
5024
|
}
|
|
4999
5025
|
async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
|
|
5000
5026
|
const projectDir = getProjectDir2(codeName);
|
|
5001
|
-
const mcpConfigPath =
|
|
5027
|
+
const mcpConfigPath = join14(projectDir, ".mcp.json");
|
|
5002
5028
|
let runId = null;
|
|
5003
5029
|
let kanbanItemId = null;
|
|
5004
5030
|
let taskResult;
|
|
@@ -5006,11 +5032,11 @@ async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
|
|
|
5006
5032
|
const priorRuns = await fetchPriorScheduledRuns(agentId, task.taskId);
|
|
5007
5033
|
prompt = wrapScheduledTaskPrompt(prompt, { priorRuns });
|
|
5008
5034
|
try {
|
|
5009
|
-
const claudeMdPath =
|
|
5035
|
+
const claudeMdPath = join14(projectDir, "CLAUDE.md");
|
|
5010
5036
|
const serverNames = [];
|
|
5011
5037
|
if (existsSync7(mcpConfigPath)) {
|
|
5012
5038
|
try {
|
|
5013
|
-
const d = JSON.parse(
|
|
5039
|
+
const d = JSON.parse(readFileSync12(mcpConfigPath, "utf-8"));
|
|
5014
5040
|
if (d.mcpServers) serverNames.push(...Object.keys(d.mcpServers));
|
|
5015
5041
|
} catch {
|
|
5016
5042
|
}
|
|
@@ -5033,10 +5059,10 @@ async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
|
|
|
5033
5059
|
claudeArgs.push("--system-prompt-file", claudeMdPath);
|
|
5034
5060
|
}
|
|
5035
5061
|
const childEnv = { ...process.env };
|
|
5036
|
-
const envIntPath =
|
|
5062
|
+
const envIntPath = join14(projectDir, ".env.integrations");
|
|
5037
5063
|
if (existsSync7(envIntPath)) {
|
|
5038
5064
|
try {
|
|
5039
|
-
Object.assign(childEnv, parseEnvIntegrations(
|
|
5065
|
+
Object.assign(childEnv, parseEnvIntegrations(readFileSync12(envIntPath, "utf-8")));
|
|
5040
5066
|
} catch {
|
|
5041
5067
|
}
|
|
5042
5068
|
}
|
|
@@ -5342,15 +5368,15 @@ function partitionActionableByPoison(actionable, states, config2) {
|
|
|
5342
5368
|
}
|
|
5343
5369
|
|
|
5344
5370
|
// src/lib/restart-flags.ts
|
|
5345
|
-
import { existsSync as existsSync8, mkdirSync as
|
|
5346
|
-
import { homedir as
|
|
5347
|
-
import { join as
|
|
5371
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync4, readdirSync as readdirSync4, readFileSync as readFileSync13, renameSync, rmSync as rmSync2, writeFileSync as writeFileSync4 } from "fs";
|
|
5372
|
+
import { homedir as homedir8 } from "os";
|
|
5373
|
+
import { join as join15 } from "path";
|
|
5348
5374
|
import { randomUUID } from "crypto";
|
|
5349
5375
|
function restartFlagsDir() {
|
|
5350
|
-
return
|
|
5376
|
+
return join15(homedir8(), ".augmented", "restart-flags");
|
|
5351
5377
|
}
|
|
5352
5378
|
function flagPath(codeName) {
|
|
5353
|
-
return
|
|
5379
|
+
return join15(restartFlagsDir(), `${codeName}.flag`);
|
|
5354
5380
|
}
|
|
5355
5381
|
function readRestartFlags() {
|
|
5356
5382
|
const dir = restartFlagsDir();
|
|
@@ -5359,7 +5385,7 @@ function readRestartFlags() {
|
|
|
5359
5385
|
for (const entry of readdirSync4(dir)) {
|
|
5360
5386
|
if (!entry.endsWith(".flag")) continue;
|
|
5361
5387
|
try {
|
|
5362
|
-
const raw =
|
|
5388
|
+
const raw = readFileSync13(join15(dir, entry), "utf8");
|
|
5363
5389
|
const parsed = JSON.parse(raw);
|
|
5364
5390
|
if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
|
|
5365
5391
|
parsed.codeName = entry.replace(/\.flag$/, "");
|
|
@@ -5912,8 +5938,8 @@ function applyRestartAcks(args) {
|
|
|
5912
5938
|
var GATEWAY_PORT_BASE = 18800;
|
|
5913
5939
|
var GATEWAY_PORT_STEP = 10;
|
|
5914
5940
|
var GATEWAY_PORT_MAX = 18899;
|
|
5915
|
-
var AUGMENTED_DIR =
|
|
5916
|
-
var GATEWAY_PORTS_FILE =
|
|
5941
|
+
var AUGMENTED_DIR = join16(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
5942
|
+
var GATEWAY_PORTS_FILE = join16(AUGMENTED_DIR, "gateway-ports.json");
|
|
5917
5943
|
var CHANNEL_SWEEP_INTERVAL_MS = (() => {
|
|
5918
5944
|
const raw = parseInt(process.env["AGT_CHANNEL_SWEEP_INTERVAL_MS"] ?? "", 10);
|
|
5919
5945
|
if (!Number.isFinite(raw)) return 5 * 60 * 1e3;
|
|
@@ -6411,7 +6437,7 @@ var runningMcpServerKeys = /* @__PURE__ */ new Map();
|
|
|
6411
6437
|
var runningChannelSecretHashes = /* @__PURE__ */ new Map();
|
|
6412
6438
|
function projectMcpHash(_codeName, projectDir) {
|
|
6413
6439
|
try {
|
|
6414
|
-
const raw =
|
|
6440
|
+
const raw = readFileSync14(join16(projectDir, ".mcp.json"), "utf-8");
|
|
6415
6441
|
return createHash6("sha256").update(canonicalJson(JSON.parse(raw))).digest("hex");
|
|
6416
6442
|
} catch {
|
|
6417
6443
|
return null;
|
|
@@ -6419,7 +6445,7 @@ function projectMcpHash(_codeName, projectDir) {
|
|
|
6419
6445
|
}
|
|
6420
6446
|
function projectMcpKeys(_codeName, projectDir) {
|
|
6421
6447
|
try {
|
|
6422
|
-
const raw =
|
|
6448
|
+
const raw = readFileSync14(join16(projectDir, ".mcp.json"), "utf-8");
|
|
6423
6449
|
const parsed = JSON.parse(raw);
|
|
6424
6450
|
const servers = parsed.mcpServers;
|
|
6425
6451
|
if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
|
|
@@ -6430,7 +6456,7 @@ function projectMcpKeys(_codeName, projectDir) {
|
|
|
6430
6456
|
}
|
|
6431
6457
|
function readMcpHttpServerConfig(projectDir, serverKey, env) {
|
|
6432
6458
|
try {
|
|
6433
|
-
const raw =
|
|
6459
|
+
const raw = readFileSync14(join16(projectDir, ".mcp.json"), "utf-8");
|
|
6434
6460
|
const servers = JSON.parse(raw).mcpServers ?? {};
|
|
6435
6461
|
const entry = servers[serverKey];
|
|
6436
6462
|
if (entry && typeof entry.url === "string" && (entry.type === "http" || entry.type === void 0)) {
|
|
@@ -6468,9 +6494,9 @@ async function runAgentConnectivityProbes(agent, integrations, projectDir) {
|
|
|
6468
6494
|
if (integrations.length === 0) return;
|
|
6469
6495
|
const probeEnv = { ...process.env };
|
|
6470
6496
|
try {
|
|
6471
|
-
const envIntPath =
|
|
6497
|
+
const envIntPath = join16(projectDir, ".env.integrations");
|
|
6472
6498
|
if (existsSync9(envIntPath)) {
|
|
6473
|
-
Object.assign(probeEnv, parseEnvIntegrations(
|
|
6499
|
+
Object.assign(probeEnv, parseEnvIntegrations(readFileSync14(envIntPath, "utf-8")));
|
|
6474
6500
|
}
|
|
6475
6501
|
} catch {
|
|
6476
6502
|
}
|
|
@@ -6683,7 +6709,7 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
|
|
|
6683
6709
|
function projectChannelSecretHash(projectDir) {
|
|
6684
6710
|
try {
|
|
6685
6711
|
const entries = parseEnvIntegrations(
|
|
6686
|
-
|
|
6712
|
+
readFileSync14(join16(projectDir, ".env.integrations"), "utf-8")
|
|
6687
6713
|
);
|
|
6688
6714
|
return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
|
|
6689
6715
|
} catch {
|
|
@@ -6771,7 +6797,7 @@ var cachedMaintenanceWindow = null;
|
|
|
6771
6797
|
var lastVersionCheckAt = 0;
|
|
6772
6798
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
6773
6799
|
var lastResponsivenessProbeAt = 0;
|
|
6774
|
-
var agtCliVersion = true ? "0.28.
|
|
6800
|
+
var agtCliVersion = true ? "0.28.37" : "dev";
|
|
6775
6801
|
function resolveBrewPath(execFileSync4) {
|
|
6776
6802
|
try {
|
|
6777
6803
|
const out = execFileSync4("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -6866,7 +6892,7 @@ async function ensureToolkitCli(toolkitSlug) {
|
|
|
6866
6892
|
toolkitCliEnsured.add(toolkitSlug);
|
|
6867
6893
|
return;
|
|
6868
6894
|
}
|
|
6869
|
-
brewBinDir =
|
|
6895
|
+
brewBinDir = dirname4(brewPath);
|
|
6870
6896
|
const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
|
|
6871
6897
|
log(`[toolkit-install] ${toolkitSlug}: installing via brew (${pkg})\u2026`);
|
|
6872
6898
|
if (isRoot) {
|
|
@@ -6948,7 +6974,7 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
|
|
|
6948
6974
|
try {
|
|
6949
6975
|
let settings = {};
|
|
6950
6976
|
if (existsSync9(path)) {
|
|
6951
|
-
const raw =
|
|
6977
|
+
const raw = readFileSync14(path, "utf-8").trim();
|
|
6952
6978
|
if (raw) {
|
|
6953
6979
|
let parsed;
|
|
6954
6980
|
try {
|
|
@@ -6964,8 +6990,8 @@ function ensureClaudeManagedSettings(path = claudeManagedSettingsPath()) {
|
|
|
6964
6990
|
}
|
|
6965
6991
|
if (settings.channelsEnabled === true) return "ok";
|
|
6966
6992
|
settings.channelsEnabled = true;
|
|
6967
|
-
|
|
6968
|
-
|
|
6993
|
+
mkdirSync5(dirname4(path), { recursive: true });
|
|
6994
|
+
writeFileSync5(path, `${JSON.stringify(settings, null, 2)}
|
|
6969
6995
|
`);
|
|
6970
6996
|
log(`[managed-settings] set channelsEnabled:true in ${path} (ENG-5786 \u2014 unblocks Claude Code channels)`);
|
|
6971
6997
|
return "ok";
|
|
@@ -7006,7 +7032,7 @@ async function ensureFrameworkBinary(frameworkId) {
|
|
|
7006
7032
|
log(`Claude Code install failed: ${err.message}`);
|
|
7007
7033
|
return;
|
|
7008
7034
|
}
|
|
7009
|
-
const brewBinDir =
|
|
7035
|
+
const brewBinDir = dirname4(brewPath);
|
|
7010
7036
|
if (!process.env.PATH?.split(":").includes(brewBinDir)) {
|
|
7011
7037
|
process.env.PATH = `${brewBinDir}:${process.env.PATH ?? ""}`;
|
|
7012
7038
|
}
|
|
@@ -7019,26 +7045,7 @@ async function ensureFrameworkBinary(frameworkId) {
|
|
|
7019
7045
|
}
|
|
7020
7046
|
agentRuntimeAuthenticated = await checkClaudeAuth();
|
|
7021
7047
|
}
|
|
7022
|
-
var CLAUDE_CODE_UPGRADE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
7023
7048
|
var claudeCodeUpgradeInFlight = false;
|
|
7024
|
-
function claudeCodeUpgradeMarkerPath() {
|
|
7025
|
-
return join15(homedir8(), ".augmented", ".last-claude-code-upgrade-check");
|
|
7026
|
-
}
|
|
7027
|
-
function stampClaudeCodeUpgradeMarker() {
|
|
7028
|
-
try {
|
|
7029
|
-
writeFileSync4(claudeCodeUpgradeMarkerPath(), String(Date.now()));
|
|
7030
|
-
} catch {
|
|
7031
|
-
}
|
|
7032
|
-
}
|
|
7033
|
-
function claudeCodeUpgradeThrottled() {
|
|
7034
|
-
try {
|
|
7035
|
-
const lastCheck = parseInt(readFileSync13(claudeCodeUpgradeMarkerPath(), "utf-8").trim(), 10);
|
|
7036
|
-
if (!Number.isFinite(lastCheck)) return false;
|
|
7037
|
-
return Date.now() - lastCheck < CLAUDE_CODE_UPGRADE_CHECK_INTERVAL_MS;
|
|
7038
|
-
} catch {
|
|
7039
|
-
return false;
|
|
7040
|
-
}
|
|
7041
|
-
}
|
|
7042
7049
|
async function maybeUpgradeClaudeCode() {
|
|
7043
7050
|
if (claudeCodeUpgradeInFlight) return;
|
|
7044
7051
|
if (claudeCodeUpgradeThrottled()) return;
|
|
@@ -7085,7 +7092,7 @@ ${r.stderr}`;
|
|
|
7085
7092
|
}
|
|
7086
7093
|
var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
7087
7094
|
function selfUpdateAppliedMarkerPath() {
|
|
7088
|
-
return
|
|
7095
|
+
return join16(homedir9(), ".augmented", ".last-self-update-applied");
|
|
7089
7096
|
}
|
|
7090
7097
|
var selfUpdateUpToDateLogged = false;
|
|
7091
7098
|
var restartAfterUpgrade = false;
|
|
@@ -7108,7 +7115,7 @@ async function checkAndUpdateCli() {
|
|
|
7108
7115
|
const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
|
|
7109
7116
|
if (!isBrewFormula && !isNpmGlobal) return;
|
|
7110
7117
|
const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
|
|
7111
|
-
const markerPath =
|
|
7118
|
+
const markerPath = join16(homedir9(), ".augmented", ".last-update-check");
|
|
7112
7119
|
try {
|
|
7113
7120
|
const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
|
|
7114
7121
|
if (Date.now() - lastCheck < UPDATE_CHECK_INTERVAL_MS) return;
|
|
@@ -7366,13 +7373,13 @@ async function checkClaudeAuth() {
|
|
|
7366
7373
|
var evalEmptyMcpConfigPath = null;
|
|
7367
7374
|
function ensureEvalEmptyMcpConfig() {
|
|
7368
7375
|
if (evalEmptyMcpConfigPath && existsSync9(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
|
|
7369
|
-
const dir =
|
|
7376
|
+
const dir = join16(homedir9(), ".augmented");
|
|
7370
7377
|
try {
|
|
7371
|
-
|
|
7378
|
+
mkdirSync5(dir, { recursive: true });
|
|
7372
7379
|
} catch {
|
|
7373
7380
|
}
|
|
7374
|
-
const p =
|
|
7375
|
-
|
|
7381
|
+
const p = join16(dir, ".eval-empty-mcp.json");
|
|
7382
|
+
writeFileSync5(p, JSON.stringify({ mcpServers: {} }));
|
|
7376
7383
|
evalEmptyMcpConfigPath = p;
|
|
7377
7384
|
return p;
|
|
7378
7385
|
}
|
|
@@ -7397,7 +7404,7 @@ async function runEvalClaude(prompt, model) {
|
|
|
7397
7404
|
""
|
|
7398
7405
|
];
|
|
7399
7406
|
const { stdout } = await execFilePromiseLong(resolveClaudeBinary(), args, {
|
|
7400
|
-
cwd:
|
|
7407
|
+
cwd: homedir9(),
|
|
7401
7408
|
timeout: 12e4,
|
|
7402
7409
|
stdin: "ignore",
|
|
7403
7410
|
env: childEnv,
|
|
@@ -7446,14 +7453,14 @@ function resolveConversationEvalBackend() {
|
|
|
7446
7453
|
}
|
|
7447
7454
|
function loadGatewayPorts() {
|
|
7448
7455
|
try {
|
|
7449
|
-
return JSON.parse(
|
|
7456
|
+
return JSON.parse(readFileSync14(GATEWAY_PORTS_FILE, "utf-8"));
|
|
7450
7457
|
} catch {
|
|
7451
7458
|
return {};
|
|
7452
7459
|
}
|
|
7453
7460
|
}
|
|
7454
7461
|
function saveGatewayPorts(ports) {
|
|
7455
|
-
|
|
7456
|
-
|
|
7462
|
+
mkdirSync5(AUGMENTED_DIR, { recursive: true });
|
|
7463
|
+
writeFileSync5(GATEWAY_PORTS_FILE, JSON.stringify(ports, null, 2));
|
|
7457
7464
|
}
|
|
7458
7465
|
function allocatePort(codeName) {
|
|
7459
7466
|
const ports = loadGatewayPorts();
|
|
@@ -7476,10 +7483,10 @@ function freePort(codeName) {
|
|
|
7476
7483
|
}
|
|
7477
7484
|
}
|
|
7478
7485
|
function getStateFile() {
|
|
7479
|
-
return
|
|
7486
|
+
return join16(config?.configDir ?? join16(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
|
|
7480
7487
|
}
|
|
7481
7488
|
function channelHashCacheDir() {
|
|
7482
|
-
return config?.configDir ??
|
|
7489
|
+
return config?.configDir ?? join16(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
7483
7490
|
}
|
|
7484
7491
|
function loadChannelHashCache2() {
|
|
7485
7492
|
loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
|
|
@@ -7490,7 +7497,7 @@ function saveChannelHashCache2() {
|
|
|
7490
7497
|
var _channelQuarantineStore = null;
|
|
7491
7498
|
function channelQuarantineStore() {
|
|
7492
7499
|
if (!_channelQuarantineStore) {
|
|
7493
|
-
const dir = config?.configDir ??
|
|
7500
|
+
const dir = config?.configDir ?? join16(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
7494
7501
|
_channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
|
|
7495
7502
|
}
|
|
7496
7503
|
return _channelQuarantineStore;
|
|
@@ -7498,7 +7505,7 @@ function channelQuarantineStore() {
|
|
|
7498
7505
|
var _hostFlagStore = null;
|
|
7499
7506
|
function hostFlagStore() {
|
|
7500
7507
|
if (!_hostFlagStore) {
|
|
7501
|
-
const dir = config?.configDir ??
|
|
7508
|
+
const dir = config?.configDir ?? join16(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
7502
7509
|
_hostFlagStore = new HostFlagStore({ cachePath: defaultFlagsCachePath(dir), log });
|
|
7503
7510
|
}
|
|
7504
7511
|
return _hostFlagStore;
|
|
@@ -7549,13 +7556,13 @@ function parseSkillFrontmatter(content) {
|
|
|
7549
7556
|
return out;
|
|
7550
7557
|
}
|
|
7551
7558
|
async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
|
|
7552
|
-
const { readdirSync: readdirSync6, readFileSync: rfs, existsSync: ex, writeFileSync:
|
|
7553
|
-
const skillsDir =
|
|
7554
|
-
const claudeMdPath =
|
|
7559
|
+
const { readdirSync: readdirSync6, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync6 } = await import("fs");
|
|
7560
|
+
const skillsDir = join16(configDir, codeName, "project", ".claude", "skills");
|
|
7561
|
+
const claudeMdPath = join16(configDir, codeName, "project", "CLAUDE.md");
|
|
7555
7562
|
if (!ex(skillsDir) || !ex(claudeMdPath)) return;
|
|
7556
7563
|
const entries = [];
|
|
7557
7564
|
for (const dir of readdirSync6(skillsDir).sort()) {
|
|
7558
|
-
const skillFile =
|
|
7565
|
+
const skillFile = join16(skillsDir, dir, "SKILL.md");
|
|
7559
7566
|
if (!ex(skillFile)) continue;
|
|
7560
7567
|
try {
|
|
7561
7568
|
const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
|
|
@@ -7597,16 +7604,16 @@ ${SKILLS_INDEX_END}`;
|
|
|
7597
7604
|
next = current.trimEnd() + "\n\n" + section + "\n";
|
|
7598
7605
|
}
|
|
7599
7606
|
if (next !== current) {
|
|
7600
|
-
|
|
7607
|
+
writeFileSync6(claudeMdPath, next, "utf-8");
|
|
7601
7608
|
log2(`Refreshed skills index in CLAUDE.md for '${codeName}' (${entries.length} skills)`);
|
|
7602
7609
|
}
|
|
7603
7610
|
}
|
|
7604
7611
|
async function migrateToProfiles() {
|
|
7605
7612
|
const homeDir = process.env["HOME"] ?? "/tmp";
|
|
7606
|
-
const sharedConfigPath =
|
|
7613
|
+
const sharedConfigPath = join16(homeDir, ".openclaw", "openclaw.json");
|
|
7607
7614
|
let sharedConfig;
|
|
7608
7615
|
try {
|
|
7609
|
-
sharedConfig = JSON.parse(
|
|
7616
|
+
sharedConfig = JSON.parse(readFileSync14(sharedConfigPath, "utf-8"));
|
|
7610
7617
|
} catch {
|
|
7611
7618
|
return;
|
|
7612
7619
|
}
|
|
@@ -7619,19 +7626,19 @@ async function migrateToProfiles() {
|
|
|
7619
7626
|
const codeName = agentEntry["id"];
|
|
7620
7627
|
if (!codeName) continue;
|
|
7621
7628
|
if (codeName === "main") continue;
|
|
7622
|
-
const profileDir =
|
|
7623
|
-
if (existsSync9(
|
|
7629
|
+
const profileDir = join16(homeDir, `.openclaw-${codeName}`);
|
|
7630
|
+
if (existsSync9(join16(profileDir, "openclaw.json"))) continue;
|
|
7624
7631
|
log(`Migrating agent '${codeName}' to per-agent profile`);
|
|
7625
7632
|
if (adapter.seedProfileConfig) {
|
|
7626
7633
|
adapter.seedProfileConfig(codeName);
|
|
7627
7634
|
}
|
|
7628
|
-
const sharedAuthDir =
|
|
7629
|
-
const profileAuthDir =
|
|
7630
|
-
const authFile =
|
|
7635
|
+
const sharedAuthDir = join16(homeDir, ".openclaw", "agents", codeName, "agent");
|
|
7636
|
+
const profileAuthDir = join16(profileDir, "agents", codeName, "agent");
|
|
7637
|
+
const authFile = join16(sharedAuthDir, "auth-profiles.json");
|
|
7631
7638
|
if (existsSync9(authFile)) {
|
|
7632
|
-
|
|
7633
|
-
const authContent =
|
|
7634
|
-
|
|
7639
|
+
mkdirSync5(profileAuthDir, { recursive: true });
|
|
7640
|
+
const authContent = readFileSync14(authFile, "utf-8");
|
|
7641
|
+
writeFileSync5(join16(profileAuthDir, "auth-profiles.json"), authContent);
|
|
7635
7642
|
}
|
|
7636
7643
|
allocatePort(codeName);
|
|
7637
7644
|
migrated++;
|
|
@@ -7647,7 +7654,7 @@ function readGatewayToken(codeName) {
|
|
|
7647
7654
|
}
|
|
7648
7655
|
const homeDir = process.env["HOME"] ?? "/tmp";
|
|
7649
7656
|
try {
|
|
7650
|
-
const cfg = JSON.parse(
|
|
7657
|
+
const cfg = JSON.parse(readFileSync14(join16(homeDir, `.openclaw-${codeName}`, "openclaw.json"), "utf-8"));
|
|
7651
7658
|
return cfg?.gateway?.auth?.token;
|
|
7652
7659
|
} catch {
|
|
7653
7660
|
return void 0;
|
|
@@ -7656,10 +7663,10 @@ function readGatewayToken(codeName) {
|
|
|
7656
7663
|
var GATEWAY_HUNG_TIMEOUT_MS = 5 * 6e4;
|
|
7657
7664
|
function isGatewayHung(codeName) {
|
|
7658
7665
|
const homeDir = process.env["HOME"] ?? "/tmp";
|
|
7659
|
-
const jobsPath =
|
|
7666
|
+
const jobsPath = join16(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
|
|
7660
7667
|
if (!existsSync9(jobsPath)) return false;
|
|
7661
7668
|
try {
|
|
7662
|
-
const data = JSON.parse(
|
|
7669
|
+
const data = JSON.parse(readFileSync14(jobsPath, "utf-8"));
|
|
7663
7670
|
const jobs = data.jobs ?? data;
|
|
7664
7671
|
if (!Array.isArray(jobs)) return false;
|
|
7665
7672
|
const now = Date.now();
|
|
@@ -7692,19 +7699,19 @@ async function ensureGatewayRunning(codeName, adapter) {
|
|
|
7692
7699
|
}
|
|
7693
7700
|
await new Promise((r) => setTimeout(r, 2e3));
|
|
7694
7701
|
const homeDir = process.env["HOME"] ?? "/tmp";
|
|
7695
|
-
const cronJobsPath =
|
|
7702
|
+
const cronJobsPath = join16(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
|
|
7696
7703
|
clearStaleCronRunState(cronJobsPath);
|
|
7697
7704
|
} else {
|
|
7698
7705
|
if (status.port) {
|
|
7699
7706
|
try {
|
|
7700
7707
|
const homeDir = process.env["HOME"] ?? "/tmp";
|
|
7701
|
-
const configPath =
|
|
7708
|
+
const configPath = join16(homeDir, `.openclaw-${codeName}`, "openclaw.json");
|
|
7702
7709
|
if (existsSync9(configPath)) {
|
|
7703
|
-
const cfg = JSON.parse(
|
|
7710
|
+
const cfg = JSON.parse(readFileSync14(configPath, "utf-8"));
|
|
7704
7711
|
if (cfg.gateway?.port !== status.port) {
|
|
7705
7712
|
if (!cfg.gateway) cfg.gateway = {};
|
|
7706
7713
|
cfg.gateway.port = status.port;
|
|
7707
|
-
|
|
7714
|
+
writeFileSync5(configPath, JSON.stringify(cfg, null, 2));
|
|
7708
7715
|
}
|
|
7709
7716
|
}
|
|
7710
7717
|
} catch {
|
|
@@ -7724,12 +7731,12 @@ async function ensureGatewayRunning(codeName, adapter) {
|
|
|
7724
7731
|
gatewaysStartedThisCycle.add(codeName);
|
|
7725
7732
|
try {
|
|
7726
7733
|
const homeDir = process.env["HOME"] ?? "/tmp";
|
|
7727
|
-
const configPath =
|
|
7734
|
+
const configPath = join16(homeDir, `.openclaw-${codeName}`, "openclaw.json");
|
|
7728
7735
|
if (existsSync9(configPath)) {
|
|
7729
|
-
const cfg = JSON.parse(
|
|
7736
|
+
const cfg = JSON.parse(readFileSync14(configPath, "utf-8"));
|
|
7730
7737
|
if (!cfg.gateway) cfg.gateway = {};
|
|
7731
7738
|
cfg.gateway.port = port;
|
|
7732
|
-
|
|
7739
|
+
writeFileSync5(configPath, JSON.stringify(cfg, null, 2));
|
|
7733
7740
|
}
|
|
7734
7741
|
} catch {
|
|
7735
7742
|
}
|
|
@@ -8289,7 +8296,7 @@ async function pollCycle() {
|
|
|
8289
8296
|
}
|
|
8290
8297
|
killAgentChannelProcesses(prev.codeName, { log });
|
|
8291
8298
|
freePort(prev.codeName);
|
|
8292
|
-
const agentDir =
|
|
8299
|
+
const agentDir = join16(adapter.getAgentDir(prev.codeName), "provision");
|
|
8293
8300
|
await cleanupAgentFiles(prev.codeName, agentDir);
|
|
8294
8301
|
clearAgentCaches(prev.agentId, prev.codeName);
|
|
8295
8302
|
}
|
|
@@ -8375,10 +8382,10 @@ async function pollCycle() {
|
|
|
8375
8382
|
// pending-inbound marker. Best-effort: a write failure is logged by
|
|
8376
8383
|
// the watchdog, never fails the poll cycle.
|
|
8377
8384
|
signalGiveUp: (codeName) => {
|
|
8378
|
-
const dir =
|
|
8385
|
+
const dir = join16(homedir9(), ".augmented", codeName);
|
|
8379
8386
|
if (!existsSync9(dir)) return;
|
|
8380
8387
|
atomicWriteFileSync(
|
|
8381
|
-
|
|
8388
|
+
join16(dir, "watchdog-give-up.json"),
|
|
8382
8389
|
JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
8383
8390
|
);
|
|
8384
8391
|
}
|
|
@@ -8505,7 +8512,7 @@ async function processAgent(agent, agentStates) {
|
|
|
8505
8512
|
}
|
|
8506
8513
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
8507
8514
|
const adapter = resolveAgentFramework(agent.code_name);
|
|
8508
|
-
let agentDir =
|
|
8515
|
+
let agentDir = join16(adapter.getAgentDir(agent.code_name), "provision");
|
|
8509
8516
|
if (agent.status === "draft" || agent.status === "paused") {
|
|
8510
8517
|
if (previousKnownStatus !== agent.status) {
|
|
8511
8518
|
log(`Agent '${agent.code_name}' is ${agent.status}, skipping provisioning`);
|
|
@@ -8709,7 +8716,7 @@ async function processAgent(agent, agentStates) {
|
|
|
8709
8716
|
const frameworkId = refreshData.agent.framework ?? "openclaw";
|
|
8710
8717
|
agentFrameworkCache.set(agent.code_name, frameworkId);
|
|
8711
8718
|
const frameworkAdapter = getFramework(frameworkId);
|
|
8712
|
-
agentDir =
|
|
8719
|
+
agentDir = join16(frameworkAdapter.getAgentDir(agent.code_name), "provision");
|
|
8713
8720
|
cacheAgentDeliveryMetadata(agent.code_name, refreshData);
|
|
8714
8721
|
if (frameworkAdapter.migrateSecretStorage && !migratedSecretStorage.has(agent.code_name)) {
|
|
8715
8722
|
try {
|
|
@@ -8750,9 +8757,9 @@ async function processAgent(agent, agentStates) {
|
|
|
8750
8757
|
try {
|
|
8751
8758
|
const artifacts = generateArtifacts(agent, refreshData, frameworkAdapter);
|
|
8752
8759
|
const changedFiles = [];
|
|
8753
|
-
|
|
8760
|
+
mkdirSync5(agentDir, { recursive: true });
|
|
8754
8761
|
for (const artifact of artifacts) {
|
|
8755
|
-
const filePath =
|
|
8762
|
+
const filePath = join16(agentDir, artifact.relativePath);
|
|
8756
8763
|
let existingHash;
|
|
8757
8764
|
let newHash;
|
|
8758
8765
|
let writeContent = artifact.content;
|
|
@@ -8771,8 +8778,8 @@ async function processAgent(agent, agentStates) {
|
|
|
8771
8778
|
};
|
|
8772
8779
|
newHash = sha256(stripDynamicSections(artifact.content));
|
|
8773
8780
|
try {
|
|
8774
|
-
const projectClaudeMd =
|
|
8775
|
-
const existing =
|
|
8781
|
+
const projectClaudeMd = join16(config.configDir, agent.code_name, "project", "CLAUDE.md");
|
|
8782
|
+
const existing = readFileSync14(projectClaudeMd, "utf-8");
|
|
8776
8783
|
existingHash = sha256(stripDynamicSections(existing));
|
|
8777
8784
|
} catch {
|
|
8778
8785
|
existingHash = null;
|
|
@@ -8790,7 +8797,7 @@ async function processAgent(agent, agentStates) {
|
|
|
8790
8797
|
const generatorKeys = Object.keys(generatorServers);
|
|
8791
8798
|
let existingRaw = "";
|
|
8792
8799
|
try {
|
|
8793
|
-
existingRaw =
|
|
8800
|
+
existingRaw = readFileSync14(filePath, "utf-8");
|
|
8794
8801
|
} catch {
|
|
8795
8802
|
}
|
|
8796
8803
|
const existingServers = parseMcp(existingRaw);
|
|
@@ -8812,26 +8819,26 @@ async function processAgent(agent, agentStates) {
|
|
|
8812
8819
|
}
|
|
8813
8820
|
}
|
|
8814
8821
|
if (changedFiles.length > 0) {
|
|
8815
|
-
const isFirst = !existsSync9(
|
|
8822
|
+
const isFirst = !existsSync9(join16(agentDir, "CHARTER.md"));
|
|
8816
8823
|
const verb = isFirst ? "Provisioning" : "Updating";
|
|
8817
8824
|
const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
|
|
8818
8825
|
log(`${verb} '${agent.code_name}': ${fileNames}`);
|
|
8819
8826
|
for (const file of changedFiles) {
|
|
8820
|
-
const filePath =
|
|
8821
|
-
|
|
8827
|
+
const filePath = join16(agentDir, file.relativePath);
|
|
8828
|
+
mkdirSync5(dirname4(filePath), { recursive: true });
|
|
8822
8829
|
if (file.relativePath === ".mcp.json") {
|
|
8823
8830
|
safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
|
|
8824
8831
|
} else {
|
|
8825
|
-
|
|
8832
|
+
writeFileSync5(filePath, file.content);
|
|
8826
8833
|
}
|
|
8827
8834
|
}
|
|
8828
8835
|
try {
|
|
8829
|
-
const provSkillsDir =
|
|
8836
|
+
const provSkillsDir = join16(agentDir, ".claude", "skills");
|
|
8830
8837
|
if (existsSync9(provSkillsDir)) {
|
|
8831
8838
|
for (const folder of readdirSync5(provSkillsDir)) {
|
|
8832
8839
|
if (folder.startsWith("knowledge-")) {
|
|
8833
8840
|
try {
|
|
8834
|
-
rmSync3(
|
|
8841
|
+
rmSync3(join16(provSkillsDir, folder), { recursive: true });
|
|
8835
8842
|
} catch {
|
|
8836
8843
|
}
|
|
8837
8844
|
}
|
|
@@ -8844,7 +8851,7 @@ async function processAgent(agent, agentStates) {
|
|
|
8844
8851
|
const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
|
|
8845
8852
|
const hashes = /* @__PURE__ */ new Map();
|
|
8846
8853
|
for (const file of trackedFiles2) {
|
|
8847
|
-
const h = hashFile(
|
|
8854
|
+
const h = hashFile(join16(agentDir, file));
|
|
8848
8855
|
if (h) hashes.set(file, h);
|
|
8849
8856
|
}
|
|
8850
8857
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -8862,14 +8869,14 @@ async function processAgent(agent, agentStates) {
|
|
|
8862
8869
|
}
|
|
8863
8870
|
if (Array.isArray(refreshData.workflows)) {
|
|
8864
8871
|
try {
|
|
8865
|
-
const provWorkflowsDir =
|
|
8872
|
+
const provWorkflowsDir = join16(agentDir, ".claude", "workflows");
|
|
8866
8873
|
if (existsSync9(provWorkflowsDir)) {
|
|
8867
8874
|
const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
|
|
8868
8875
|
for (const file of readdirSync5(provWorkflowsDir)) {
|
|
8869
8876
|
if (!file.endsWith(".js")) continue;
|
|
8870
8877
|
if (expected.has(file)) continue;
|
|
8871
8878
|
try {
|
|
8872
|
-
rmSync3(
|
|
8879
|
+
rmSync3(join16(provWorkflowsDir, file));
|
|
8873
8880
|
} catch {
|
|
8874
8881
|
}
|
|
8875
8882
|
}
|
|
@@ -8929,7 +8936,7 @@ async function processAgent(agent, agentStates) {
|
|
|
8929
8936
|
if (written && existsSync9(agentDir)) {
|
|
8930
8937
|
const driftedFiles = [];
|
|
8931
8938
|
for (const [file, expectedHash] of written) {
|
|
8932
|
-
const localHash = hashFile(
|
|
8939
|
+
const localHash = hashFile(join16(agentDir, file));
|
|
8933
8940
|
if (localHash && localHash !== expectedHash) {
|
|
8934
8941
|
driftedFiles.push(file);
|
|
8935
8942
|
}
|
|
@@ -8940,7 +8947,7 @@ async function processAgent(agent, agentStates) {
|
|
|
8940
8947
|
try {
|
|
8941
8948
|
const localHashes = {};
|
|
8942
8949
|
for (const file of driftedFiles) {
|
|
8943
|
-
localHashes[file] = hashFile(
|
|
8950
|
+
localHashes[file] = hashFile(join16(agentDir, file));
|
|
8944
8951
|
}
|
|
8945
8952
|
await api.post("/host/drift", {
|
|
8946
8953
|
agent_id: agent.agent_id,
|
|
@@ -9264,18 +9271,18 @@ async function processAgent(agent, agentStates) {
|
|
|
9264
9271
|
if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? "openclaw") === "claude-code") {
|
|
9265
9272
|
try {
|
|
9266
9273
|
const agentProvisionDir = agentDir;
|
|
9267
|
-
const projectDir =
|
|
9268
|
-
|
|
9269
|
-
|
|
9270
|
-
const provisionMcpPath =
|
|
9271
|
-
const projectMcpPath =
|
|
9274
|
+
const projectDir = join16(homedir9(), ".augmented", agent.code_name, "project");
|
|
9275
|
+
mkdirSync5(agentProvisionDir, { recursive: true });
|
|
9276
|
+
mkdirSync5(projectDir, { recursive: true });
|
|
9277
|
+
const provisionMcpPath = join16(agentProvisionDir, ".mcp.json");
|
|
9278
|
+
const projectMcpPath = join16(projectDir, ".mcp.json");
|
|
9272
9279
|
let mcpConfig = { mcpServers: {} };
|
|
9273
9280
|
try {
|
|
9274
|
-
mcpConfig = JSON.parse(
|
|
9281
|
+
mcpConfig = JSON.parse(readFileSync14(provisionMcpPath, "utf-8"));
|
|
9275
9282
|
if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
|
|
9276
9283
|
} catch {
|
|
9277
9284
|
}
|
|
9278
|
-
const localDirectChatChannel =
|
|
9285
|
+
const localDirectChatChannel = join16(homedir9(), ".augmented", "_mcp", "direct-chat-channel.js");
|
|
9279
9286
|
const directChatTeamSettings = refreshData.team?.settings;
|
|
9280
9287
|
const directChatTz = (() => {
|
|
9281
9288
|
const tz = directChatTeamSettings?.["timezone"];
|
|
@@ -9305,7 +9312,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9305
9312
|
log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
|
|
9306
9313
|
}
|
|
9307
9314
|
}
|
|
9308
|
-
const staleChannelsPath =
|
|
9315
|
+
const staleChannelsPath = join16(projectDir, ".mcp-channels.json");
|
|
9309
9316
|
if (existsSync9(staleChannelsPath)) {
|
|
9310
9317
|
try {
|
|
9311
9318
|
rmSync3(staleChannelsPath, { force: true });
|
|
@@ -9370,7 +9377,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9370
9377
|
}
|
|
9371
9378
|
if (process.env.AGT_CONNECTIVITY_PROBE_ENABLED === "true") {
|
|
9372
9379
|
try {
|
|
9373
|
-
const probeProjectDir =
|
|
9380
|
+
const probeProjectDir = join16(homedir9(), ".augmented", agent.code_name, "project");
|
|
9374
9381
|
await runAgentConnectivityProbes(agent, integrations, probeProjectDir);
|
|
9375
9382
|
} catch (err) {
|
|
9376
9383
|
log(`Connectivity probe failed for '${agent.code_name}': ${err.message}`);
|
|
@@ -9388,11 +9395,11 @@ async function processAgent(agent, agentStates) {
|
|
|
9388
9395
|
recordConfigChurnEvent(agent.agent_id, agent.code_name, FLAP_CHANNEL_INTEGRATIONS, intMembership);
|
|
9389
9396
|
}
|
|
9390
9397
|
if (intHash !== prevIntHash) {
|
|
9391
|
-
const projectDir =
|
|
9392
|
-
const envIntPath =
|
|
9398
|
+
const projectDir = join16(homedir9(), ".augmented", agent.code_name, "project");
|
|
9399
|
+
const envIntPath = join16(projectDir, ".env.integrations");
|
|
9393
9400
|
let preWriteEnv;
|
|
9394
9401
|
try {
|
|
9395
|
-
preWriteEnv =
|
|
9402
|
+
preWriteEnv = readFileSync14(envIntPath, "utf-8");
|
|
9396
9403
|
} catch {
|
|
9397
9404
|
preWriteEnv = void 0;
|
|
9398
9405
|
}
|
|
@@ -9404,9 +9411,9 @@ async function processAgent(agent, agentStates) {
|
|
|
9404
9411
|
let rotationHandled = true;
|
|
9405
9412
|
if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
|
|
9406
9413
|
try {
|
|
9407
|
-
const projectMcpPath =
|
|
9408
|
-
const postWriteEnv =
|
|
9409
|
-
const mcpContent =
|
|
9414
|
+
const projectMcpPath = join16(projectDir, ".mcp.json");
|
|
9415
|
+
const postWriteEnv = readFileSync14(envIntPath, "utf-8");
|
|
9416
|
+
const mcpContent = readFileSync14(projectMcpPath, "utf-8");
|
|
9410
9417
|
const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
|
|
9411
9418
|
const mcpJsonForReap = JSON.parse(mcpContent);
|
|
9412
9419
|
const affectedServerKeys = findMcpServersUsingVars(mcpJsonForReap, changedVars);
|
|
@@ -9486,8 +9493,8 @@ async function processAgent(agent, agentStates) {
|
|
|
9486
9493
|
const mcpPath = frameworkAdapter.getMcpPath(agent.code_name);
|
|
9487
9494
|
if (mcpPath) {
|
|
9488
9495
|
try {
|
|
9489
|
-
const { readFileSync:
|
|
9490
|
-
const mcpConfig = JSON.parse(
|
|
9496
|
+
const { readFileSync: readFileSync15 } = await import("fs");
|
|
9497
|
+
const mcpConfig = JSON.parse(readFileSync15(mcpPath, "utf-8"));
|
|
9491
9498
|
if (mcpConfig.mcpServers) {
|
|
9492
9499
|
const managedPrefixes = [
|
|
9493
9500
|
"composio_",
|
|
@@ -9588,7 +9595,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9588
9595
|
if (agent.status === "active") {
|
|
9589
9596
|
if (frameworkAdapter.installPlugin) {
|
|
9590
9597
|
try {
|
|
9591
|
-
const pluginPath =
|
|
9598
|
+
const pluginPath = join16(process.cwd(), "packages", "openclaw-plugin-augmented", "src", "index.ts");
|
|
9592
9599
|
if (existsSync9(pluginPath)) {
|
|
9593
9600
|
frameworkAdapter.installPlugin(agent.code_name, "augmented", pluginPath, {
|
|
9594
9601
|
agtHost: requireHost(),
|
|
@@ -9655,18 +9662,18 @@ async function processAgent(agent, agentStates) {
|
|
|
9655
9662
|
}
|
|
9656
9663
|
try {
|
|
9657
9664
|
const { readdirSync: readdirSync6, rmSync: rmSync4 } = await import("fs");
|
|
9658
|
-
const { homedir:
|
|
9665
|
+
const { homedir: homedir10 } = await import("os");
|
|
9659
9666
|
const frameworkId2 = frameworkAdapter.id;
|
|
9660
9667
|
const candidateSkillDirs = [
|
|
9661
9668
|
// Claude Code — framework runtime tree
|
|
9662
|
-
|
|
9669
|
+
join16(homedir10(), ".augmented", agent.code_name, "skills"),
|
|
9663
9670
|
// Claude Code — project tree
|
|
9664
|
-
|
|
9671
|
+
join16(homedir10(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
9665
9672
|
// OpenClaw — framework runtime tree
|
|
9666
|
-
|
|
9673
|
+
join16(homedir10(), `.openclaw-${agent.code_name}`, "skills"),
|
|
9667
9674
|
// Defensive: legacy provision-side path, not currently an
|
|
9668
9675
|
// install target but cheap to sweep.
|
|
9669
|
-
|
|
9676
|
+
join16(agentDir, ".claude", "skills")
|
|
9670
9677
|
];
|
|
9671
9678
|
const existingDirs = candidateSkillDirs.filter((d) => existsSync9(d));
|
|
9672
9679
|
const discoveredEntries = /* @__PURE__ */ new Set();
|
|
@@ -9682,7 +9689,7 @@ async function processAgent(agent, agentStates) {
|
|
|
9682
9689
|
}
|
|
9683
9690
|
const removeSkillFolder = (entry, reason) => {
|
|
9684
9691
|
for (const dir of existingDirs) {
|
|
9685
|
-
const p =
|
|
9692
|
+
const p = join16(dir, entry);
|
|
9686
9693
|
if (existsSync9(p)) {
|
|
9687
9694
|
rmSync4(p, { recursive: true, force: true });
|
|
9688
9695
|
}
|
|
@@ -9711,16 +9718,16 @@ async function processAgent(agent, agentStates) {
|
|
|
9711
9718
|
}
|
|
9712
9719
|
if (plan.removes.length) {
|
|
9713
9720
|
const { rmSync: rmSync4 } = await import("fs");
|
|
9714
|
-
const { homedir:
|
|
9721
|
+
const { homedir: homedir10 } = await import("os");
|
|
9715
9722
|
const globalSkillDirs = [
|
|
9716
|
-
|
|
9717
|
-
|
|
9718
|
-
|
|
9719
|
-
|
|
9723
|
+
join16(homedir10(), ".augmented", agent.code_name, "skills"),
|
|
9724
|
+
join16(homedir10(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
9725
|
+
join16(homedir10(), `.openclaw-${agent.code_name}`, "skills"),
|
|
9726
|
+
join16(agentDir, ".claude", "skills")
|
|
9720
9727
|
];
|
|
9721
9728
|
for (const id of plan.removes) {
|
|
9722
9729
|
for (const dir of globalSkillDirs) {
|
|
9723
|
-
const p =
|
|
9730
|
+
const p = join16(dir, id);
|
|
9724
9731
|
if (existsSync9(p)) rmSync4(p, { recursive: true, force: true });
|
|
9725
9732
|
}
|
|
9726
9733
|
agentState.knownSkillHashes.delete(`global-skill:${agent.agent_id}:${id}`);
|
|
@@ -9896,8 +9903,8 @@ async function processAgent(agent, agentStates) {
|
|
|
9896
9903
|
const sess = getSessionState(agent.code_name);
|
|
9897
9904
|
let mcpJsonParsed = null;
|
|
9898
9905
|
try {
|
|
9899
|
-
const mcpPath =
|
|
9900
|
-
mcpJsonParsed = JSON.parse(
|
|
9906
|
+
const mcpPath = join16(getProjectDir(agent.code_name), ".mcp.json");
|
|
9907
|
+
mcpJsonParsed = JSON.parse(readFileSync14(mcpPath, "utf-8"));
|
|
9901
9908
|
} catch {
|
|
9902
9909
|
}
|
|
9903
9910
|
reapMissingMcpSessions({
|
|
@@ -10106,10 +10113,10 @@ async function processAgent(agent, agentStates) {
|
|
|
10106
10113
|
lastWorkTriggerAt.set(agent.code_name, triggerTs);
|
|
10107
10114
|
if (agentFw === "openclaw" && gatewayRunning && gatewayPort) {
|
|
10108
10115
|
const homeDir = process.env["HOME"] ?? "/tmp";
|
|
10109
|
-
const jobsPath =
|
|
10116
|
+
const jobsPath = join16(homeDir, `.openclaw-${agent.code_name}`, "cron", "jobs.json");
|
|
10110
10117
|
if (existsSync9(jobsPath)) {
|
|
10111
10118
|
try {
|
|
10112
|
-
const jobsData = JSON.parse(
|
|
10119
|
+
const jobsData = JSON.parse(readFileSync14(jobsPath, "utf-8"));
|
|
10113
10120
|
const kanbanJob = (jobsData.jobs ?? []).find(
|
|
10114
10121
|
(j) => typeof j.name === "string" && j.name.includes("kanban-work")
|
|
10115
10122
|
);
|
|
@@ -10246,7 +10253,7 @@ In progress for ${age} minutes \u2014 auto-failed`).catch(() => {
|
|
|
10246
10253
|
if (trackedFiles.length > 0 && existsSync9(agentDir)) {
|
|
10247
10254
|
const hashes = /* @__PURE__ */ new Map();
|
|
10248
10255
|
for (const file of trackedFiles) {
|
|
10249
|
-
const h = hashFile(
|
|
10256
|
+
const h = hashFile(join16(agentDir, file));
|
|
10250
10257
|
if (h) hashes.set(file, h);
|
|
10251
10258
|
}
|
|
10252
10259
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -10280,19 +10287,19 @@ function cleanupStaleSessions(codeName) {
|
|
|
10280
10287
|
lastCleanupAt.set(codeName, Date.now());
|
|
10281
10288
|
const homeDir = process.env["HOME"] ?? "/tmp";
|
|
10282
10289
|
for (const agentDir of ["main", codeName]) {
|
|
10283
|
-
const sessionsDir =
|
|
10290
|
+
const sessionsDir = join16(homeDir, `.openclaw-${codeName}`, "agents", agentDir, "sessions");
|
|
10284
10291
|
cleanupCronSessions(sessionsDir, CRON_SESSION_KEEP_COUNT);
|
|
10285
10292
|
}
|
|
10286
|
-
const cronRunsDir =
|
|
10293
|
+
const cronRunsDir = join16(homeDir, `.openclaw-${codeName}`, "cron", "runs");
|
|
10287
10294
|
cleanupOldFiles(cronRunsDir, CRON_RUN_RETENTION_DAYS, ".jsonl");
|
|
10288
|
-
const cronJobsPath =
|
|
10295
|
+
const cronJobsPath = join16(homeDir, `.openclaw-${codeName}`, "cron", "jobs.json");
|
|
10289
10296
|
clearStaleCronRunState(cronJobsPath);
|
|
10290
10297
|
}
|
|
10291
10298
|
function cleanupCronSessions(sessionsDir, keepCount) {
|
|
10292
|
-
const indexPath =
|
|
10299
|
+
const indexPath = join16(sessionsDir, "sessions.json");
|
|
10293
10300
|
if (!existsSync9(indexPath)) return;
|
|
10294
10301
|
try {
|
|
10295
|
-
const raw =
|
|
10302
|
+
const raw = readFileSync14(indexPath, "utf-8");
|
|
10296
10303
|
const index = JSON.parse(raw);
|
|
10297
10304
|
const cronRunKeys = Object.keys(index).filter((k) => k.includes(":cron:") && k.includes(":run:")).map((k) => ({
|
|
10298
10305
|
key: k,
|
|
@@ -10305,7 +10312,7 @@ function cleanupCronSessions(sessionsDir, keepCount) {
|
|
|
10305
10312
|
for (const entry of toDelete) {
|
|
10306
10313
|
delete index[entry.key];
|
|
10307
10314
|
if (entry.sessionId) {
|
|
10308
|
-
const sessionFile =
|
|
10315
|
+
const sessionFile = join16(sessionsDir, `${entry.sessionId}.jsonl`);
|
|
10309
10316
|
try {
|
|
10310
10317
|
if (existsSync9(sessionFile)) {
|
|
10311
10318
|
unlinkSync(sessionFile);
|
|
@@ -10327,7 +10334,7 @@ function cleanupCronSessions(sessionsDir, keepCount) {
|
|
|
10327
10334
|
delete index[parentKey];
|
|
10328
10335
|
if (parentSessionId) {
|
|
10329
10336
|
try {
|
|
10330
|
-
const f =
|
|
10337
|
+
const f = join16(sessionsDir, `${parentSessionId}.jsonl`);
|
|
10331
10338
|
if (existsSync9(f)) {
|
|
10332
10339
|
unlinkSync(f);
|
|
10333
10340
|
deletedFiles++;
|
|
@@ -10337,7 +10344,7 @@ function cleanupCronSessions(sessionsDir, keepCount) {
|
|
|
10337
10344
|
}
|
|
10338
10345
|
}
|
|
10339
10346
|
}
|
|
10340
|
-
|
|
10347
|
+
writeFileSync5(indexPath, JSON.stringify(index));
|
|
10341
10348
|
if (toDelete.length > 0) {
|
|
10342
10349
|
log(`Cleaned ${toDelete.length} cron session(s) and ${deletedFiles} file(s) from ${sessionsDir}`);
|
|
10343
10350
|
}
|
|
@@ -10348,7 +10355,7 @@ var STALE_RUN_TIMEOUT_MS = 5 * 6e4;
|
|
|
10348
10355
|
function clearStaleCronRunState(jobsPath) {
|
|
10349
10356
|
if (!existsSync9(jobsPath)) return;
|
|
10350
10357
|
try {
|
|
10351
|
-
const raw =
|
|
10358
|
+
const raw = readFileSync14(jobsPath, "utf-8");
|
|
10352
10359
|
const data = JSON.parse(raw);
|
|
10353
10360
|
const jobs = data.jobs ?? data;
|
|
10354
10361
|
if (!Array.isArray(jobs)) return;
|
|
@@ -10373,7 +10380,7 @@ function clearStaleCronRunState(jobsPath) {
|
|
|
10373
10380
|
}
|
|
10374
10381
|
}
|
|
10375
10382
|
if (changed) {
|
|
10376
|
-
|
|
10383
|
+
writeFileSync5(jobsPath, JSON.stringify(data, null, 2));
|
|
10377
10384
|
}
|
|
10378
10385
|
} catch {
|
|
10379
10386
|
}
|
|
@@ -10385,7 +10392,7 @@ function cleanupOldFiles(dir, maxAgeDays, ext) {
|
|
|
10385
10392
|
try {
|
|
10386
10393
|
for (const f of readdirSync5(dir)) {
|
|
10387
10394
|
if (!f.endsWith(ext)) continue;
|
|
10388
|
-
const fullPath =
|
|
10395
|
+
const fullPath = join16(dir, f);
|
|
10389
10396
|
try {
|
|
10390
10397
|
const st = statSync4(fullPath);
|
|
10391
10398
|
if (st.mtimeMs < cutoff) {
|
|
@@ -10407,8 +10414,8 @@ var claudeAuthTupleBySession = /* @__PURE__ */ new Map();
|
|
|
10407
10414
|
async function ensurePersistentSession(agent, tasks, boardItems, refreshData) {
|
|
10408
10415
|
const codeName = agent.code_name;
|
|
10409
10416
|
const projectDir = getProjectDir(codeName);
|
|
10410
|
-
const mcpConfigPath =
|
|
10411
|
-
const claudeMdPath =
|
|
10417
|
+
const mcpConfigPath = join16(projectDir, ".mcp.json");
|
|
10418
|
+
const claudeMdPath = join16(projectDir, "CLAUDE.md");
|
|
10412
10419
|
if (restartBreaker.isTripped(codeName)) {
|
|
10413
10420
|
const trip = restartBreaker.getTrip(codeName);
|
|
10414
10421
|
return {
|
|
@@ -11007,9 +11014,9 @@ async function processDirectChatMessage(agent, msg) {
|
|
|
11007
11014
|
if (isSessionHealthy(agent.codeName)) {
|
|
11008
11015
|
if (hostFlagStore().getBoolean("direct-chat-doorbell")) {
|
|
11009
11016
|
try {
|
|
11010
|
-
const doorbell = directChatDoorbellPath(agent.agentId,
|
|
11011
|
-
|
|
11012
|
-
|
|
11017
|
+
const doorbell = directChatDoorbellPath(agent.agentId, homedir9());
|
|
11018
|
+
mkdirSync5(dirname4(doorbell), { recursive: true });
|
|
11019
|
+
writeFileSync5(doorbell, String(Date.now()));
|
|
11013
11020
|
log(`[direct-chat] Doorbell rung for '${agent.codeName}' (msg=${msg.id}) \u2014 in-session MCP will pull via the cursor`);
|
|
11014
11021
|
return;
|
|
11015
11022
|
} catch (err) {
|
|
@@ -11053,11 +11060,11 @@ ${escapeXml(msg.content)}
|
|
|
11053
11060
|
log(`[direct-chat] One-shot spawn for '${agent.codeName}' (msg=${msg.id}; host in-flight=${directChatSpawnGate.hostInFlight}, queued=${directChatSpawnGate.queuedCount})`);
|
|
11054
11061
|
const { getProjectDir: ccProjectDir } = await import("../claude-scheduler-FATCLHDM.js");
|
|
11055
11062
|
const projDir = ccProjectDir(agent.codeName);
|
|
11056
|
-
const mcpConfigPath =
|
|
11063
|
+
const mcpConfigPath = join16(projDir, ".mcp.json");
|
|
11057
11064
|
const serverNames = [];
|
|
11058
11065
|
if (existsSync9(mcpConfigPath)) {
|
|
11059
11066
|
try {
|
|
11060
|
-
const d = JSON.parse(
|
|
11067
|
+
const d = JSON.parse(readFileSync14(mcpConfigPath, "utf-8"));
|
|
11061
11068
|
if (d.mcpServers) serverNames.push(...Object.keys(d.mcpServers));
|
|
11062
11069
|
} catch {
|
|
11063
11070
|
}
|
|
@@ -11076,15 +11083,15 @@ ${escapeXml(msg.content)}
|
|
|
11076
11083
|
"--allowedTools",
|
|
11077
11084
|
allowedTools
|
|
11078
11085
|
];
|
|
11079
|
-
const chatClaudeMd =
|
|
11086
|
+
const chatClaudeMd = join16(projDir, "CLAUDE.md");
|
|
11080
11087
|
if (existsSync9(chatClaudeMd)) {
|
|
11081
11088
|
chatArgs.push("--system-prompt-file", chatClaudeMd);
|
|
11082
11089
|
}
|
|
11083
|
-
const envIntPath =
|
|
11090
|
+
const envIntPath = join16(projDir, ".env.integrations");
|
|
11084
11091
|
const childEnv = { ...process.env };
|
|
11085
11092
|
if (existsSync9(envIntPath)) {
|
|
11086
11093
|
try {
|
|
11087
|
-
Object.assign(childEnv, parseEnvIntegrations(
|
|
11094
|
+
Object.assign(childEnv, parseEnvIntegrations(readFileSync14(envIntPath, "utf-8")));
|
|
11088
11095
|
} catch {
|
|
11089
11096
|
}
|
|
11090
11097
|
}
|
|
@@ -11680,8 +11687,8 @@ function parseMemoryFile(raw, fallbackName) {
|
|
|
11680
11687
|
};
|
|
11681
11688
|
}
|
|
11682
11689
|
async function syncMemories(agent, configDir, log2) {
|
|
11683
|
-
const projectDir =
|
|
11684
|
-
const memoryDir =
|
|
11690
|
+
const projectDir = join16(configDir, agent.code_name, "project");
|
|
11691
|
+
const memoryDir = join16(projectDir, "memory");
|
|
11685
11692
|
const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
|
|
11686
11693
|
if (isFreshSync) {
|
|
11687
11694
|
log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
|
|
@@ -11699,7 +11706,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
11699
11706
|
for (const file of readdirSync5(memoryDir)) {
|
|
11700
11707
|
if (!file.endsWith(".md")) continue;
|
|
11701
11708
|
try {
|
|
11702
|
-
const raw =
|
|
11709
|
+
const raw = readFileSync14(join16(memoryDir, file), "utf-8");
|
|
11703
11710
|
const fileHash = createHash6("sha256").update(raw).digest("hex").slice(0, 16);
|
|
11704
11711
|
currentHashes.set(file, fileHash);
|
|
11705
11712
|
if (prevHashes.get(file) === fileHash) continue;
|
|
@@ -11724,7 +11731,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
11724
11731
|
} catch (err) {
|
|
11725
11732
|
for (const mem of changedMemories) {
|
|
11726
11733
|
for (const [file] of currentHashes) {
|
|
11727
|
-
const parsed = parseMemoryFile(
|
|
11734
|
+
const parsed = parseMemoryFile(readFileSync14(join16(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
|
|
11728
11735
|
if (parsed?.name === mem.name) currentHashes.delete(file);
|
|
11729
11736
|
}
|
|
11730
11737
|
}
|
|
@@ -11752,14 +11759,14 @@ async function downloadMemories(agent, memoryDir, log2, { force }) {
|
|
|
11752
11759
|
lastDownloadHash.set(agent.agent_id, responseHash);
|
|
11753
11760
|
lastLocalFileHash.set(agent.agent_id, localListHash);
|
|
11754
11761
|
if (dbMemories.memories?.length) {
|
|
11755
|
-
|
|
11762
|
+
mkdirSync5(memoryDir, { recursive: true });
|
|
11756
11763
|
let written = 0;
|
|
11757
11764
|
let overwritten = 0;
|
|
11758
11765
|
for (let i = 0; i < dbMemories.memories.length; i++) {
|
|
11759
11766
|
const mem = dbMemories.memories[i];
|
|
11760
11767
|
const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
|
|
11761
11768
|
const slug = rawSlug || `memory-${i}`;
|
|
11762
|
-
const filePath =
|
|
11769
|
+
const filePath = join16(memoryDir, `${slug}.md`);
|
|
11763
11770
|
const desired = `---
|
|
11764
11771
|
name: ${JSON.stringify(mem.name)}
|
|
11765
11772
|
type: ${mem.type}
|
|
@@ -11771,14 +11778,14 @@ ${mem.content}
|
|
|
11771
11778
|
if (existsSync9(filePath)) {
|
|
11772
11779
|
let existing = "";
|
|
11773
11780
|
try {
|
|
11774
|
-
existing =
|
|
11781
|
+
existing = readFileSync14(filePath, "utf-8");
|
|
11775
11782
|
} catch {
|
|
11776
11783
|
}
|
|
11777
11784
|
if (existing === desired) continue;
|
|
11778
|
-
|
|
11785
|
+
writeFileSync5(filePath, desired);
|
|
11779
11786
|
overwritten++;
|
|
11780
11787
|
} else {
|
|
11781
|
-
|
|
11788
|
+
writeFileSync5(filePath, desired);
|
|
11782
11789
|
written++;
|
|
11783
11790
|
}
|
|
11784
11791
|
}
|
|
@@ -12046,7 +12053,7 @@ function startManager(opts) {
|
|
|
12046
12053
|
try {
|
|
12047
12054
|
const stateFile = getStateFile();
|
|
12048
12055
|
if (existsSync9(stateFile)) {
|
|
12049
|
-
const raw =
|
|
12056
|
+
const raw = readFileSync14(stateFile, "utf-8");
|
|
12050
12057
|
const parsed = JSON.parse(raw);
|
|
12051
12058
|
if (Array.isArray(parsed.agents)) {
|
|
12052
12059
|
state6.agents = parsed.agents;
|
|
@@ -12067,7 +12074,7 @@ function startManager(opts) {
|
|
|
12067
12074
|
log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
|
|
12068
12075
|
}
|
|
12069
12076
|
log(
|
|
12070
|
-
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${
|
|
12077
|
+
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join16(homedir9(), ".augmented", "manager.log")}`
|
|
12071
12078
|
);
|
|
12072
12079
|
deployMcpAssets();
|
|
12073
12080
|
reapOrphanChannelMcps({ log });
|
|
@@ -12088,7 +12095,7 @@ async function reapOrphanedClaudePids() {
|
|
|
12088
12095
|
const looksLikeClaude = (pid) => {
|
|
12089
12096
|
if (process.platform !== "linux") return true;
|
|
12090
12097
|
try {
|
|
12091
|
-
const comm =
|
|
12098
|
+
const comm = readFileSync14(`/proc/${pid}/comm`, "utf-8").trim().toLowerCase();
|
|
12092
12099
|
return comm.includes("claude");
|
|
12093
12100
|
} catch {
|
|
12094
12101
|
return false;
|
|
@@ -12198,18 +12205,18 @@ function restartRunningChannelMcps(basenames) {
|
|
|
12198
12205
|
}
|
|
12199
12206
|
}
|
|
12200
12207
|
function deployMcpAssets() {
|
|
12201
|
-
const targetDir =
|
|
12202
|
-
|
|
12203
|
-
const moduleDir =
|
|
12208
|
+
const targetDir = join16(homedir9(), ".augmented", "_mcp");
|
|
12209
|
+
mkdirSync5(targetDir, { recursive: true });
|
|
12210
|
+
const moduleDir = dirname4(fileURLToPath(import.meta.url));
|
|
12204
12211
|
let mcpSourceDir = "";
|
|
12205
12212
|
let dir = moduleDir;
|
|
12206
12213
|
for (let i = 0; i < 6; i++) {
|
|
12207
|
-
const candidate =
|
|
12208
|
-
if (existsSync9(
|
|
12214
|
+
const candidate = join16(dir, "dist", "mcp");
|
|
12215
|
+
if (existsSync9(join16(candidate, "index.js"))) {
|
|
12209
12216
|
mcpSourceDir = candidate;
|
|
12210
12217
|
break;
|
|
12211
12218
|
}
|
|
12212
|
-
const parent =
|
|
12219
|
+
const parent = dirname4(dir);
|
|
12213
12220
|
if (parent === dir) break;
|
|
12214
12221
|
dir = parent;
|
|
12215
12222
|
}
|
|
@@ -12221,7 +12228,7 @@ function deployMcpAssets() {
|
|
|
12221
12228
|
const fileHash = (p) => {
|
|
12222
12229
|
try {
|
|
12223
12230
|
if (!existsSync9(p)) return null;
|
|
12224
|
-
return createHash6("sha256").update(
|
|
12231
|
+
return createHash6("sha256").update(readFileSync14(p)).digest("hex");
|
|
12225
12232
|
} catch {
|
|
12226
12233
|
return null;
|
|
12227
12234
|
}
|
|
@@ -12248,8 +12255,8 @@ function deployMcpAssets() {
|
|
|
12248
12255
|
// natural session restart.
|
|
12249
12256
|
"augmented-admin.js"
|
|
12250
12257
|
]) {
|
|
12251
|
-
const src =
|
|
12252
|
-
const dst =
|
|
12258
|
+
const src = join16(mcpSourceDir, file);
|
|
12259
|
+
const dst = join16(targetDir, file);
|
|
12253
12260
|
if (!existsSync9(src)) continue;
|
|
12254
12261
|
const before = fileHash(dst);
|
|
12255
12262
|
try {
|
|
@@ -12267,23 +12274,23 @@ function deployMcpAssets() {
|
|
|
12267
12274
|
log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
|
|
12268
12275
|
restartRunningChannelMcps(changedBasenames);
|
|
12269
12276
|
}
|
|
12270
|
-
const localMcpPath =
|
|
12277
|
+
const localMcpPath = join16(targetDir, "index.js");
|
|
12271
12278
|
try {
|
|
12272
|
-
const agentsDir =
|
|
12279
|
+
const agentsDir = join16(homedir9(), ".augmented", "agents");
|
|
12273
12280
|
if (existsSync9(agentsDir)) {
|
|
12274
12281
|
for (const entry of readdirSync5(agentsDir, { withFileTypes: true })) {
|
|
12275
12282
|
if (!entry.isDirectory()) continue;
|
|
12276
12283
|
for (const subdir of ["provision", "project"]) {
|
|
12277
|
-
const mcpJsonPath =
|
|
12284
|
+
const mcpJsonPath = join16(agentsDir, entry.name, subdir, ".mcp.json");
|
|
12278
12285
|
try {
|
|
12279
|
-
const raw =
|
|
12286
|
+
const raw = readFileSync14(mcpJsonPath, "utf-8");
|
|
12280
12287
|
if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
|
|
12281
12288
|
const mcpConfig = JSON.parse(raw);
|
|
12282
12289
|
const augServer = mcpConfig.mcpServers?.["augmented"];
|
|
12283
12290
|
if (!augServer) continue;
|
|
12284
12291
|
augServer.command = "node";
|
|
12285
12292
|
augServer.args = [localMcpPath];
|
|
12286
|
-
|
|
12293
|
+
writeFileSync5(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
|
|
12287
12294
|
log(`[manager] Patched ${entry.name}/${subdir}/.mcp.json: npx \u2192 node`);
|
|
12288
12295
|
} catch {
|
|
12289
12296
|
}
|