@integrity-labs/agt-cli 0.28.627 → 0.28.628
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.
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
safeWriteJsonAtomic,
|
|
55
55
|
setConfigHash,
|
|
56
56
|
tripClass
|
|
57
|
-
} from "../chunk-
|
|
57
|
+
} from "../chunk-G3FPZ4KK.js";
|
|
58
58
|
import {
|
|
59
59
|
getProjectDir as getProjectDir2,
|
|
60
60
|
getReadyTasks,
|
|
@@ -196,8 +196,8 @@ import {
|
|
|
196
196
|
import { createHash as createHash17 } from "crypto";
|
|
197
197
|
import { readFileSync as readFileSync28, writeFileSync as writeFileSync14, mkdirSync as mkdirSync11, existsSync as existsSync15, rmSync as rmSync5, readdirSync as readdirSync9, statSync as statSync8, copyFileSync } from "fs";
|
|
198
198
|
import { execFileSync as syncExecFile } from "child_process";
|
|
199
|
-
import { join as
|
|
200
|
-
import { homedir as
|
|
199
|
+
import { join as join35, dirname as dirname9, delimiter as pathDelimiter } from "path";
|
|
200
|
+
import { homedir as homedir17 } from "os";
|
|
201
201
|
import { fileURLToPath } from "url";
|
|
202
202
|
|
|
203
203
|
// src/lib/single-flight.ts
|
|
@@ -215,8 +215,8 @@ function createSingleFlight(task, opts = {}) {
|
|
|
215
215
|
}
|
|
216
216
|
running2 = true;
|
|
217
217
|
let markSettled;
|
|
218
|
-
settled = new Promise((
|
|
219
|
-
markSettled =
|
|
218
|
+
settled = new Promise((resolve2) => {
|
|
219
|
+
markSettled = resolve2;
|
|
220
220
|
});
|
|
221
221
|
const primary = (async () => {
|
|
222
222
|
try {
|
|
@@ -1556,6 +1556,62 @@ var DependencyRecoveryLedger = class {
|
|
|
1556
1556
|
}
|
|
1557
1557
|
};
|
|
1558
1558
|
|
|
1559
|
+
// src/lib/mcp-assets-ready.ts
|
|
1560
|
+
import { existsSync as nodeExistsSync, readFileSync as nodeReadFileSync } from "fs";
|
|
1561
|
+
import { homedir as homedir2 } from "os";
|
|
1562
|
+
import { join as join4, resolve, sep } from "path";
|
|
1563
|
+
function getSharedMcpDir(homeDir = homedir2()) {
|
|
1564
|
+
return join4(homeDir, ".augmented", "_mcp");
|
|
1565
|
+
}
|
|
1566
|
+
function isPathInsideDir(candidate, dir) {
|
|
1567
|
+
const resolvedDir = resolve(dir);
|
|
1568
|
+
const resolvedCandidate = resolve(candidate);
|
|
1569
|
+
if (resolvedCandidate === resolvedDir) return false;
|
|
1570
|
+
return resolvedCandidate.startsWith(resolvedDir.endsWith(sep) ? resolvedDir : resolvedDir + sep);
|
|
1571
|
+
}
|
|
1572
|
+
function findMissingMcpBundles(mcpConfigPath, deps = {}) {
|
|
1573
|
+
const existsSync16 = deps.existsSync ?? nodeExistsSync;
|
|
1574
|
+
const readFileSync29 = deps.readFileSync ?? nodeReadFileSync;
|
|
1575
|
+
const mcpDir = deps.mcpDir ?? getSharedMcpDir();
|
|
1576
|
+
let parsed;
|
|
1577
|
+
try {
|
|
1578
|
+
parsed = JSON.parse(readFileSync29(mcpConfigPath, "utf-8"));
|
|
1579
|
+
} catch {
|
|
1580
|
+
return [];
|
|
1581
|
+
}
|
|
1582
|
+
const servers = parsed?.mcpServers;
|
|
1583
|
+
if (!servers || typeof servers !== "object" || Array.isArray(servers)) return [];
|
|
1584
|
+
const missing = [];
|
|
1585
|
+
const seenPaths = /* @__PURE__ */ new Set();
|
|
1586
|
+
for (const [key, rawEntry] of Object.entries(servers)) {
|
|
1587
|
+
if (!rawEntry || typeof rawEntry !== "object" || Array.isArray(rawEntry)) continue;
|
|
1588
|
+
const entry = rawEntry;
|
|
1589
|
+
if (entry.command !== "node") continue;
|
|
1590
|
+
if (!Array.isArray(entry.args) || entry.args.length === 0) continue;
|
|
1591
|
+
const bundlePath = entry.args[0];
|
|
1592
|
+
if (typeof bundlePath !== "string" || bundlePath.length === 0) continue;
|
|
1593
|
+
if (!isPathInsideDir(bundlePath, mcpDir)) continue;
|
|
1594
|
+
const resolvedBundlePath = resolve(bundlePath);
|
|
1595
|
+
if (seenPaths.has(resolvedBundlePath)) continue;
|
|
1596
|
+
let present;
|
|
1597
|
+
try {
|
|
1598
|
+
present = existsSync16(bundlePath);
|
|
1599
|
+
} catch {
|
|
1600
|
+
continue;
|
|
1601
|
+
}
|
|
1602
|
+
if (!present) {
|
|
1603
|
+
seenPaths.add(resolvedBundlePath);
|
|
1604
|
+
missing.push({ key, path: bundlePath });
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
return missing.sort((a, b) => a.key.localeCompare(b.key));
|
|
1608
|
+
}
|
|
1609
|
+
function formatMissingMcpBundles(missing) {
|
|
1610
|
+
if (missing.length === 0) return "all declared MCP bundles present";
|
|
1611
|
+
const detail = missing.map((m) => `${m.key} (${m.path})`).join(", ");
|
|
1612
|
+
return `MCP bundle(s) not yet on disk in the host-shared _mcp mount: ${detail}`;
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1559
1615
|
// src/lib/self-update-coalesce.ts
|
|
1560
1616
|
import { readFileSync as readFileSync5, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3 } from "fs";
|
|
1561
1617
|
import { dirname as dirname3 } from "path";
|
|
@@ -1925,14 +1981,14 @@ function formatReaperBootLine(opts) {
|
|
|
1925
1981
|
}
|
|
1926
1982
|
|
|
1927
1983
|
// src/lib/direct-chat-delivery.ts
|
|
1928
|
-
import { join as
|
|
1984
|
+
import { join as join5 } from "path";
|
|
1929
1985
|
var DEFAULT_DIRECT_CHAT_MAX_AGE_MS = 30 * 6e4;
|
|
1930
1986
|
function directChatMaxAgeMs() {
|
|
1931
1987
|
const raw = parseInt(process.env["AGT_DIRECT_CHAT_MAX_AGE_MS"] ?? "", 10);
|
|
1932
1988
|
return Number.isFinite(raw) && raw >= 0 ? raw : DEFAULT_DIRECT_CHAT_MAX_AGE_MS;
|
|
1933
1989
|
}
|
|
1934
1990
|
function directChatDoorbellPath(agentId, home) {
|
|
1935
|
-
return
|
|
1991
|
+
return join5(home, ".augmented", agentId, "direct-chat-doorbell");
|
|
1936
1992
|
}
|
|
1937
1993
|
function isDirectChatMessageExpired(createdAt, nowMs, maxAgeMs) {
|
|
1938
1994
|
if (!maxAgeMs || maxAgeMs <= 0) return false;
|
|
@@ -1944,15 +2000,15 @@ function isDirectChatMessageExpired(createdAt, nowMs, maxAgeMs) {
|
|
|
1944
2000
|
|
|
1945
2001
|
// src/lib/id-keyed-migration.ts
|
|
1946
2002
|
import { existsSync as existsSync2, lstatSync, readlinkSync, renameSync } from "fs";
|
|
1947
|
-
import { join as
|
|
1948
|
-
import { homedir as
|
|
2003
|
+
import { join as join6 } from "path";
|
|
2004
|
+
import { homedir as homedir3 } from "os";
|
|
1949
2005
|
var ID_KEYED_MIGRATION_FLAG = "id-keyed-layout-migration";
|
|
1950
2006
|
function agentHasActiveWhatsapp(channelConfigs, codeNameDir) {
|
|
1951
2007
|
if (channelConfigs && Object.prototype.hasOwnProperty.call(channelConfigs, "whatsapp")) {
|
|
1952
2008
|
return true;
|
|
1953
2009
|
}
|
|
1954
2010
|
try {
|
|
1955
|
-
if (existsSync2(
|
|
2011
|
+
if (existsSync2(join6(codeNameDir, "whatsapp-pending-inbound"))) return true;
|
|
1956
2012
|
} catch {
|
|
1957
2013
|
}
|
|
1958
2014
|
return false;
|
|
@@ -1982,12 +2038,12 @@ function finishTranscriptMove(oldCwd, newCwd, codeName, log2) {
|
|
|
1982
2038
|
log2(`[id-keyed-migration] moved transcript store for '${codeName}' to the id-keyed key`);
|
|
1983
2039
|
}
|
|
1984
2040
|
function maybeMigrateAgentToIdKeyedLayout(agent, deps) {
|
|
1985
|
-
const home = deps.home ??
|
|
2041
|
+
const home = deps.home ?? homedir3();
|
|
1986
2042
|
const { code_name: codeName, agent_id: agentId } = agent;
|
|
1987
|
-
const codeNamePath =
|
|
1988
|
-
const idPath =
|
|
1989
|
-
const oldCwd =
|
|
1990
|
-
const newCwd =
|
|
2043
|
+
const codeNamePath = join6(home, ".augmented", codeName);
|
|
2044
|
+
const idPath = join6(home, ".augmented", agentId);
|
|
2045
|
+
const oldCwd = join6(home, ".augmented", codeName, "project");
|
|
2046
|
+
const newCwd = join6(idPath, "project");
|
|
1991
2047
|
let codeNameKind;
|
|
1992
2048
|
try {
|
|
1993
2049
|
codeNameKind = lstatSync(codeNamePath).isSymbolicLink() ? "symlink" : "realdir";
|
|
@@ -2115,7 +2171,7 @@ function collectEnvGates(env) {
|
|
|
2115
2171
|
|
|
2116
2172
|
// ../../packages/core/dist/direct-chat/cursor-advance-telemetry.js
|
|
2117
2173
|
import { readFileSync as readFileSync7, writeFileSync as writeFileSync4 } from "fs";
|
|
2118
|
-
import { join as
|
|
2174
|
+
import { join as join7 } from "path";
|
|
2119
2175
|
var CURSOR_SHORTFALL_COUNTER_SUFFIX = "-cursor-advance-classifications.json";
|
|
2120
2176
|
function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
|
|
2121
2177
|
if (!agentDir)
|
|
@@ -2123,7 +2179,7 @@ function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
|
|
|
2123
2179
|
const key = cursorAdvanceCounterKey(route, verdict);
|
|
2124
2180
|
if (key === null)
|
|
2125
2181
|
return;
|
|
2126
|
-
const path =
|
|
2182
|
+
const path = join7(agentDir, `${source}${CURSOR_SHORTFALL_COUNTER_SUFFIX}`);
|
|
2127
2183
|
const counts = {};
|
|
2128
2184
|
try {
|
|
2129
2185
|
const parsed = JSON.parse(readFileSync7(path, "utf-8"));
|
|
@@ -2143,8 +2199,8 @@ function recordCursorAdvanceOutcome(agentDir, source, route, verdict) {
|
|
|
2143
2199
|
}
|
|
2144
2200
|
|
|
2145
2201
|
// src/lib/artifact-stream.ts
|
|
2146
|
-
import { join as
|
|
2147
|
-
import { homedir as
|
|
2202
|
+
import { join as join8 } from "path";
|
|
2203
|
+
import { homedir as homedir4 } from "os";
|
|
2148
2204
|
import { readdir, stat, readFile } from "fs/promises";
|
|
2149
2205
|
var ARTEFACT_ENTRY_FILE = "index.html";
|
|
2150
2206
|
function errMessage(err) {
|
|
@@ -2229,7 +2285,7 @@ var ArtifactStreamScanner = class {
|
|
|
2229
2285
|
return;
|
|
2230
2286
|
}
|
|
2231
2287
|
for (const name of names) {
|
|
2232
|
-
const file =
|
|
2288
|
+
const file = join8(this.artifactsDir, name, ARTEFACT_ENTRY_FILE);
|
|
2233
2289
|
const mtime = await this.fsDeps.mtimeMs(file).catch(() => null);
|
|
2234
2290
|
if (mtime === null) continue;
|
|
2235
2291
|
if (this.seenMtime.get(name) === mtime) continue;
|
|
@@ -2260,7 +2316,7 @@ var ArtifactStreamScanner = class {
|
|
|
2260
2316
|
}
|
|
2261
2317
|
};
|
|
2262
2318
|
function artifactsDirFor(codeName) {
|
|
2263
|
-
return
|
|
2319
|
+
return join8(homedir4(), ".augmented", codeName, "artifacts");
|
|
2264
2320
|
}
|
|
2265
2321
|
var nodeArtifactFs = {
|
|
2266
2322
|
async listArtefactNames(artifactsDir) {
|
|
@@ -2370,13 +2426,13 @@ async function maybeReportUsageBanner(args) {
|
|
|
2370
2426
|
// src/lib/claude-account-fingerprint.ts
|
|
2371
2427
|
import { createHash as createHash6 } from "crypto";
|
|
2372
2428
|
import { readFile as readFile3, readdir as readdir3 } from "fs/promises";
|
|
2373
|
-
import { homedir as
|
|
2374
|
-
import { dirname as dirname4, join as
|
|
2429
|
+
import { homedir as homedir6, platform as platform2 } from "os";
|
|
2430
|
+
import { dirname as dirname4, join as join10 } from "path";
|
|
2375
2431
|
|
|
2376
2432
|
// src/lib/claude-auth-detect.ts
|
|
2377
2433
|
import { readFile as readFile2, readdir as readdir2 } from "fs/promises";
|
|
2378
|
-
import { homedir as
|
|
2379
|
-
import { join as
|
|
2434
|
+
import { homedir as homedir5, platform } from "os";
|
|
2435
|
+
import { join as join9 } from "path";
|
|
2380
2436
|
import { execFile } from "child_process";
|
|
2381
2437
|
import { promisify } from "util";
|
|
2382
2438
|
var execFileAsync = promisify(execFile);
|
|
@@ -2391,16 +2447,16 @@ async function detectClaudeAuth() {
|
|
|
2391
2447
|
}
|
|
2392
2448
|
async function findClaudeCredentialsPaths() {
|
|
2393
2449
|
const candidates = [
|
|
2394
|
-
|
|
2395
|
-
|
|
2450
|
+
join9(homedir5(), ".claude", ".credentials.json"),
|
|
2451
|
+
join9(homedir5(), ".claude", "credentials.json")
|
|
2396
2452
|
];
|
|
2397
2453
|
const isLinuxRoot = platform() === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
|
|
2398
2454
|
if (isLinuxRoot) {
|
|
2399
2455
|
try {
|
|
2400
2456
|
const entries = await readdir2("/home", { withFileTypes: true });
|
|
2401
2457
|
for (const entry of entries.filter((entry2) => entry2.isDirectory()).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
2402
|
-
candidates.push(
|
|
2403
|
-
candidates.push(
|
|
2458
|
+
candidates.push(join9("/home", entry.name, ".claude", ".credentials.json"));
|
|
2459
|
+
candidates.push(join9("/home", entry.name, ".claude", "credentials.json"));
|
|
2404
2460
|
}
|
|
2405
2461
|
} catch {
|
|
2406
2462
|
}
|
|
@@ -2478,13 +2534,13 @@ function parseExpiresAt(raw) {
|
|
|
2478
2534
|
|
|
2479
2535
|
// src/lib/claude-account-fingerprint.ts
|
|
2480
2536
|
async function candidateHomes() {
|
|
2481
|
-
const homes = [
|
|
2537
|
+
const homes = [homedir6()];
|
|
2482
2538
|
const isLinuxRoot = platform2() === "linux" && typeof process.getuid === "function" && process.getuid() === 0;
|
|
2483
2539
|
if (isLinuxRoot) {
|
|
2484
2540
|
try {
|
|
2485
2541
|
const entries = await readdir3("/home", { withFileTypes: true });
|
|
2486
2542
|
for (const entry of entries.filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
2487
|
-
homes.push(
|
|
2543
|
+
homes.push(join10("/home", entry.name));
|
|
2488
2544
|
}
|
|
2489
2545
|
} catch {
|
|
2490
2546
|
}
|
|
@@ -2504,11 +2560,11 @@ async function homeOfActiveCredentials() {
|
|
|
2504
2560
|
async function claudeConfigCandidatePaths() {
|
|
2505
2561
|
const paths = [];
|
|
2506
2562
|
const configDir = process.env["CLAUDE_CONFIG_DIR"]?.trim();
|
|
2507
|
-
if (configDir) paths.push(
|
|
2563
|
+
if (configDir) paths.push(join10(configDir, ".claude.json"));
|
|
2508
2564
|
const activeHome = await homeOfActiveCredentials();
|
|
2509
|
-
if (activeHome) paths.push(
|
|
2565
|
+
if (activeHome) paths.push(join10(activeHome, ".claude.json"));
|
|
2510
2566
|
for (const home of await candidateHomes()) {
|
|
2511
|
-
const path =
|
|
2567
|
+
const path = join10(home, ".claude.json");
|
|
2512
2568
|
if (!paths.includes(path)) paths.push(path);
|
|
2513
2569
|
}
|
|
2514
2570
|
return paths;
|
|
@@ -2606,10 +2662,10 @@ function diffAuthTuples(recorded, current) {
|
|
|
2606
2662
|
|
|
2607
2663
|
// src/lib/account-enforcement-marker.ts
|
|
2608
2664
|
import { mkdirSync as mkdirSync4, renameSync as renameSync2, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
|
|
2609
|
-
import { homedir as
|
|
2610
|
-
import { join as
|
|
2665
|
+
import { homedir as homedir7 } from "os";
|
|
2666
|
+
import { join as join11 } from "path";
|
|
2611
2667
|
function accountEnforcementMarkerPath(codeName) {
|
|
2612
|
-
return
|
|
2668
|
+
return join11(homedir7(), ".augmented", codeName, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
|
|
2613
2669
|
}
|
|
2614
2670
|
function syncAccountEnforcementMarker(codeName, level, log2 = (m) => process.stderr.write(`${m}
|
|
2615
2671
|
`), text) {
|
|
@@ -2617,8 +2673,8 @@ function syncAccountEnforcementMarker(codeName, level, log2 = (m) => process.std
|
|
|
2617
2673
|
clearAccountEnforcementMarker(codeName, log2);
|
|
2618
2674
|
return;
|
|
2619
2675
|
}
|
|
2620
|
-
const dir =
|
|
2621
|
-
const path =
|
|
2676
|
+
const dir = join11(homedir7(), ".augmented", codeName);
|
|
2677
|
+
const path = join11(dir, ACCOUNT_ENFORCEMENT_MARKER_FILENAME);
|
|
2622
2678
|
const tempPath = `${path}.${process.pid}.tmp`;
|
|
2623
2679
|
try {
|
|
2624
2680
|
mkdirSync4(dir, { recursive: true });
|
|
@@ -2644,7 +2700,7 @@ function clearAccountEnforcementMarker(codeName, log2 = (m) => process.stderr.wr
|
|
|
2644
2700
|
|
|
2645
2701
|
// src/lib/token-usage-monitor.ts
|
|
2646
2702
|
import { readdirSync, readFileSync as readFileSync8, statSync } from "fs";
|
|
2647
|
-
import { join as
|
|
2703
|
+
import { join as join12 } from "path";
|
|
2648
2704
|
var MIN_CHECK_INTERVAL_MS2 = 6e4;
|
|
2649
2705
|
var TRANSCRIPT_MTIME_WINDOW_MS = 2 * 24 * 60 * 60 * 1e3;
|
|
2650
2706
|
var MAX_ENTRIES_PER_POST = 200;
|
|
@@ -2673,7 +2729,7 @@ async function maybeReportTokenUsage(args) {
|
|
|
2673
2729
|
if (!name.endsWith(".jsonl")) continue;
|
|
2674
2730
|
const sessionId = name.slice(0, -".jsonl".length);
|
|
2675
2731
|
if (!sessionId) continue;
|
|
2676
|
-
const path =
|
|
2732
|
+
const path = join12(dir, name);
|
|
2677
2733
|
let st;
|
|
2678
2734
|
try {
|
|
2679
2735
|
st = statSync(path);
|
|
@@ -2771,7 +2827,7 @@ async function maybeReportTokenUsage(args) {
|
|
|
2771
2827
|
|
|
2772
2828
|
// src/lib/workflow-run-reconciler.ts
|
|
2773
2829
|
import { readdirSync as readdirSync2, readFileSync as readFileSync9, statSync as statSync2 } from "fs";
|
|
2774
|
-
import { join as
|
|
2830
|
+
import { join as join13 } from "path";
|
|
2775
2831
|
var MIN_CHECK_INTERVAL_MS3 = 5 * 6e4;
|
|
2776
2832
|
var SETTLE_MS = 3e4;
|
|
2777
2833
|
var TRANSCRIPT_MTIME_WINDOW_MS2 = 2 * 24 * 60 * 60 * 1e3;
|
|
@@ -2790,7 +2846,7 @@ function collectJsonlRecursive(dir, minMtimeMs, out, depth) {
|
|
|
2790
2846
|
return;
|
|
2791
2847
|
}
|
|
2792
2848
|
for (const name of entries) {
|
|
2793
|
-
const p =
|
|
2849
|
+
const p = join13(dir, name);
|
|
2794
2850
|
let st;
|
|
2795
2851
|
try {
|
|
2796
2852
|
st = statSync2(p);
|
|
@@ -2813,7 +2869,7 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
|
|
|
2813
2869
|
return out;
|
|
2814
2870
|
}
|
|
2815
2871
|
for (const name of entries) {
|
|
2816
|
-
const path =
|
|
2872
|
+
const path = join13(transcriptDir, name);
|
|
2817
2873
|
let st;
|
|
2818
2874
|
try {
|
|
2819
2875
|
st = statSync2(path);
|
|
@@ -2825,7 +2881,7 @@ function enumerateTranscriptFiles(transcriptDir, nowMs, minMtimeMs = nowMs - TRA
|
|
|
2825
2881
|
continue;
|
|
2826
2882
|
}
|
|
2827
2883
|
if (st.isDirectory()) {
|
|
2828
|
-
collectJsonlRecursive(
|
|
2884
|
+
collectJsonlRecursive(join13(path, "subagents"), minMtimeMs, out, 0);
|
|
2829
2885
|
}
|
|
2830
2886
|
}
|
|
2831
2887
|
return out;
|
|
@@ -2916,7 +2972,7 @@ async function maybeReconcileWorkflowRunTokens(args) {
|
|
|
2916
2972
|
|
|
2917
2973
|
// src/lib/conversation-evaluator.ts
|
|
2918
2974
|
import { readdirSync as readdirSync3, readFileSync as readFileSync10, statSync as statSync3 } from "fs";
|
|
2919
|
-
import { join as
|
|
2975
|
+
import { join as join14 } from "path";
|
|
2920
2976
|
var MIN_CHECK_INTERVAL_MS4 = 5 * 6e4;
|
|
2921
2977
|
var TRANSCRIPT_MTIME_WINDOW_MS3 = 7 * 24 * 60 * 60 * 1e3;
|
|
2922
2978
|
var WINDOW_PAD_MS = 5 * 6e4;
|
|
@@ -3352,7 +3408,7 @@ function readRecentTurns(dir, nowMs) {
|
|
|
3352
3408
|
return;
|
|
3353
3409
|
}
|
|
3354
3410
|
for (const ent of entries) {
|
|
3355
|
-
const full =
|
|
3411
|
+
const full = join14(d, ent.name);
|
|
3356
3412
|
if (ent.isDirectory()) {
|
|
3357
3413
|
visit(full);
|
|
3358
3414
|
continue;
|
|
@@ -3657,18 +3713,18 @@ async function reportSkip2(api2, agentId, conversationId, log2, codeName) {
|
|
|
3657
3713
|
}
|
|
3658
3714
|
|
|
3659
3715
|
// src/lib/tool-call-audit.ts
|
|
3660
|
-
import { homedir as
|
|
3661
|
-
import { join as
|
|
3716
|
+
import { homedir as homedir11 } from "os";
|
|
3717
|
+
import { join as join19 } from "path";
|
|
3662
3718
|
|
|
3663
3719
|
// src/lib/agent-logging-mode.ts
|
|
3664
3720
|
import { readFileSync as readFileSync11 } from "fs";
|
|
3665
|
-
import { homedir as
|
|
3666
|
-
import { join as
|
|
3721
|
+
import { homedir as homedir8 } from "os";
|
|
3722
|
+
import { join as join15 } from "path";
|
|
3667
3723
|
var LOGGING_MODES = ["hash-only", "redacted", "full-local"];
|
|
3668
3724
|
function charterPath(codeName, homeDir) {
|
|
3669
|
-
const home = homeDir ?? (process.env["HOME"]?.trim() ||
|
|
3725
|
+
const home = homeDir ?? (process.env["HOME"]?.trim() || homedir8());
|
|
3670
3726
|
const key = agentRuntimeKey(codeName, homeDir);
|
|
3671
|
-
return
|
|
3727
|
+
return join15(home, ".augmented", key, "provision", "CHARTER.md");
|
|
3672
3728
|
}
|
|
3673
3729
|
function readAgentLoggingMode(codeName, homeDir) {
|
|
3674
3730
|
let raw;
|
|
@@ -3698,14 +3754,14 @@ function loggingModeWithholdsTargets(reading) {
|
|
|
3698
3754
|
// src/lib/tool-call-path-salt.ts
|
|
3699
3755
|
import { randomBytes } from "crypto";
|
|
3700
3756
|
import { existsSync as existsSync3, mkdirSync as mkdirSync5, readFileSync as readFileSync12, renameSync as renameSync3, unlinkSync, writeFileSync as writeFileSync6 } from "fs";
|
|
3701
|
-
import { homedir as
|
|
3702
|
-
import { dirname as dirname5, join as
|
|
3757
|
+
import { homedir as homedir9 } from "os";
|
|
3758
|
+
import { dirname as dirname5, join as join16 } from "path";
|
|
3703
3759
|
var SALT_BYTES = 32;
|
|
3704
3760
|
var SALT_RE = /^[0-9a-f]{64}$/;
|
|
3705
3761
|
function pathSaltPath(codeName, homeDir) {
|
|
3706
|
-
const home = homeDir ?? (process.env["HOME"]?.trim() ||
|
|
3762
|
+
const home = homeDir ?? (process.env["HOME"]?.trim() || homedir9());
|
|
3707
3763
|
const key = agentRuntimeKey(codeName, homeDir);
|
|
3708
|
-
return
|
|
3764
|
+
return join16(home, ".augmented", key, "tool-call-path-salt");
|
|
3709
3765
|
}
|
|
3710
3766
|
function readToolCallPathSalt(codeName, homeDir) {
|
|
3711
3767
|
let file;
|
|
@@ -3782,7 +3838,7 @@ function readHostArchiveAddress(path) {
|
|
|
3782
3838
|
|
|
3783
3839
|
// src/lib/tool-call-extractor.ts
|
|
3784
3840
|
import { closeSync, fstatSync, openSync, readFileSync as readFileSync14, readSync, readdirSync as readdirSync4 } from "fs";
|
|
3785
|
-
import { basename, join as
|
|
3841
|
+
import { basename, join as join17, relative } from "path";
|
|
3786
3842
|
import { StringDecoder } from "string_decoder";
|
|
3787
3843
|
|
|
3788
3844
|
// src/lib/tool-call-redaction.ts
|
|
@@ -3911,7 +3967,7 @@ function redactToolTargetInner(toolName, input, ctx) {
|
|
|
3911
3967
|
var EXTRACTOR_VERSION = "e1";
|
|
3912
3968
|
function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
|
|
3913
3969
|
const files = [];
|
|
3914
|
-
const mainAbs =
|
|
3970
|
+
const mainAbs = join17(transcriptDir, `${sessionId}.jsonl`);
|
|
3915
3971
|
files.push({
|
|
3916
3972
|
absPath: mainAbs,
|
|
3917
3973
|
relPath: relative(projectsRoot, mainAbs),
|
|
@@ -3919,7 +3975,7 @@ function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
|
|
|
3919
3975
|
isSubagent: false,
|
|
3920
3976
|
subagentId: null
|
|
3921
3977
|
});
|
|
3922
|
-
const subDir =
|
|
3978
|
+
const subDir = join17(transcriptDir, sessionId, "subagents");
|
|
3923
3979
|
let entries;
|
|
3924
3980
|
try {
|
|
3925
3981
|
entries = readdirSync4(subDir);
|
|
@@ -3928,7 +3984,7 @@ function enumerateSessionTranscripts(transcriptDir, sessionId, projectsRoot) {
|
|
|
3928
3984
|
}
|
|
3929
3985
|
for (const name of entries) {
|
|
3930
3986
|
if (!name.endsWith(".jsonl")) continue;
|
|
3931
|
-
const abs =
|
|
3987
|
+
const abs = join17(subDir, name);
|
|
3932
3988
|
const stem = basename(name, ".jsonl");
|
|
3933
3989
|
files.push({
|
|
3934
3990
|
absPath: abs,
|
|
@@ -4127,8 +4183,8 @@ function extractTranscriptWindow(file, opts, from) {
|
|
|
4127
4183
|
|
|
4128
4184
|
// src/lib/tool-call-cursor.ts
|
|
4129
4185
|
import { existsSync as existsSync4, readFileSync as readFileSync15 } from "fs";
|
|
4130
|
-
import { homedir as
|
|
4131
|
-
import { join as
|
|
4186
|
+
import { homedir as homedir10 } from "os";
|
|
4187
|
+
import { join as join18 } from "path";
|
|
4132
4188
|
var COVERAGE_DISPOSITIONS = [
|
|
4133
4189
|
"ok",
|
|
4134
4190
|
"not_entitled",
|
|
@@ -4181,9 +4237,9 @@ function parseCursorKey(key) {
|
|
|
4181
4237
|
return { sessionId: sessionId.length > 0 ? sessionId : null, transcriptRef: key.slice(i + 1) };
|
|
4182
4238
|
}
|
|
4183
4239
|
function cursorStatePath(codeName, homeDir) {
|
|
4184
|
-
const home = homeDir ?? (process.env["HOME"]?.trim() ||
|
|
4240
|
+
const home = homeDir ?? (process.env["HOME"]?.trim() || homedir10());
|
|
4185
4241
|
const key = agentRuntimeKey(codeName, homeDir);
|
|
4186
|
-
return
|
|
4242
|
+
return join18(home, ".augmented", key, "tool-call-cursors.json");
|
|
4187
4243
|
}
|
|
4188
4244
|
function loadCursors(path) {
|
|
4189
4245
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -4595,8 +4651,8 @@ async function maybeScanToolCalls(args) {
|
|
|
4595
4651
|
if (!salt && !hashOnly) {
|
|
4596
4652
|
log2(`[tool-call-audit] ${codeName}: no path-hash salt available \u2014 file targets withheld`);
|
|
4597
4653
|
}
|
|
4598
|
-
const home = args.homeDir ?? (process.env["HOME"]?.trim() ||
|
|
4599
|
-
const projectsRoot = args.projectsRoot ??
|
|
4654
|
+
const home = args.homeDir ?? (process.env["HOME"]?.trim() || homedir11());
|
|
4655
|
+
const projectsRoot = args.projectsRoot ?? join19(home, ".claude", "projects");
|
|
4600
4656
|
const transcriptDir = args.transcriptDir ?? sessionTranscriptDir(getProjectDir(codeName));
|
|
4601
4657
|
const current = peekCurrentSession(codeName);
|
|
4602
4658
|
const sessionIds = current ? [current.sessionId] : [];
|
|
@@ -4626,10 +4682,10 @@ async function maybeScanToolCalls(args) {
|
|
|
4626
4682
|
|
|
4627
4683
|
// src/lib/activity-cache-monitor.ts
|
|
4628
4684
|
import { existsSync as existsSync5, readFileSync as readFileSync16 } from "fs";
|
|
4629
|
-
import { homedir as
|
|
4630
|
-
import { join as
|
|
4685
|
+
import { homedir as homedir12 } from "os";
|
|
4686
|
+
import { join as join20 } from "path";
|
|
4631
4687
|
var MIN_CHECK_INTERVAL_MS7 = 6e4;
|
|
4632
|
-
var STATS_CACHE_PATH =
|
|
4688
|
+
var STATS_CACHE_PATH = join20(homedir12(), ".claude", "stats-cache.json");
|
|
4633
4689
|
var ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
4634
4690
|
var state6 = { lastObservedDate: null, lastCheckedAt: 0 };
|
|
4635
4691
|
function selectNewDailyRows(raw, lastObservedDate) {
|
|
@@ -4910,10 +4966,10 @@ function computeChannelConfigHash(input) {
|
|
|
4910
4966
|
|
|
4911
4967
|
// src/lib/channel-hash-cache.ts
|
|
4912
4968
|
import { existsSync as existsSync6, readFileSync as readFileSync17, writeFileSync as writeFileSync7 } from "fs";
|
|
4913
|
-
import { join as
|
|
4969
|
+
import { join as join21 } from "path";
|
|
4914
4970
|
var CACHE_FILENAME = "channel-hash-cache.json";
|
|
4915
4971
|
function getChannelHashCacheFile(configDir) {
|
|
4916
|
-
return
|
|
4972
|
+
return join21(configDir, CACHE_FILENAME);
|
|
4917
4973
|
}
|
|
4918
4974
|
function loadChannelHashCache(target, configDir) {
|
|
4919
4975
|
const path = getChannelHashCacheFile(configDir);
|
|
@@ -4941,7 +4997,7 @@ function saveChannelHashCache(source, configDir) {
|
|
|
4941
4997
|
|
|
4942
4998
|
// src/lib/sender-policy-baseline.ts
|
|
4943
4999
|
import { existsSync as existsSync7, readFileSync as readFileSync18 } from "fs";
|
|
4944
|
-
import { join as
|
|
5000
|
+
import { join as join22 } from "path";
|
|
4945
5001
|
var BASELINE_FILENAME = "sender-policy-baseline.json";
|
|
4946
5002
|
var SENDER_POLICY_BASELINE_VERSION = 1;
|
|
4947
5003
|
var BASELINE_CONCERNS = ["senderPolicy", "slackBehaviour", "msteamsBehaviour"];
|
|
@@ -4953,7 +5009,7 @@ function createDeliveryBaselineMaps() {
|
|
|
4953
5009
|
};
|
|
4954
5010
|
}
|
|
4955
5011
|
function getSenderPolicyBaselineFile(configDir) {
|
|
4956
|
-
return
|
|
5012
|
+
return join22(configDir, BASELINE_FILENAME);
|
|
4957
5013
|
}
|
|
4958
5014
|
function loadSenderPolicyBaseline(target, configDir, log2) {
|
|
4959
5015
|
const path = getSenderPolicyBaselineFile(configDir);
|
|
@@ -5483,7 +5539,7 @@ function planGlobalSkillSync(globalSkills, prevIds, hashOf, knownHash, options)
|
|
|
5483
5539
|
}
|
|
5484
5540
|
|
|
5485
5541
|
// src/lib/manager/integration-skill-cache.ts
|
|
5486
|
-
import { join as
|
|
5542
|
+
import { join as join23 } from "path";
|
|
5487
5543
|
function integrationSkillHashKey(agentId, skillId) {
|
|
5488
5544
|
return `plugin-skill:${agentId}:${skillId}`;
|
|
5489
5545
|
}
|
|
@@ -5499,16 +5555,16 @@ function forgetIntegrationSkill(cache3, agentId, skillId) {
|
|
|
5499
5555
|
function removeIntegrationSkillFolder(opts) {
|
|
5500
5556
|
forgetIntegrationSkill(opts.cache, opts.agentId, opts.entry);
|
|
5501
5557
|
for (const dir of opts.dirs) {
|
|
5502
|
-
opts.removeDir(
|
|
5558
|
+
opts.removeDir(join23(dir, opts.entry));
|
|
5503
5559
|
}
|
|
5504
5560
|
}
|
|
5505
5561
|
|
|
5506
5562
|
// src/lib/manager/managed-skill-manifest.ts
|
|
5507
5563
|
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync19, writeFileSync as writeFileSync8 } from "fs";
|
|
5508
|
-
import { dirname as dirname6, join as
|
|
5564
|
+
import { dirname as dirname6, join as join24 } from "path";
|
|
5509
5565
|
var MANIFEST_VERSION = 1;
|
|
5510
5566
|
function managedSkillManifestPath(agentRootDir) {
|
|
5511
|
-
return
|
|
5567
|
+
return join24(agentRootDir, "managed-skills.json");
|
|
5512
5568
|
}
|
|
5513
5569
|
function readManagedSkillManifest(path) {
|
|
5514
5570
|
try {
|
|
@@ -5606,7 +5662,7 @@ function resolveModelChain(refreshData) {
|
|
|
5606
5662
|
const modelDefaults = refreshData.model_defaults;
|
|
5607
5663
|
const platform3 = modelDefaults?.platform ?? {};
|
|
5608
5664
|
const org = modelDefaults?.org ?? {};
|
|
5609
|
-
function
|
|
5665
|
+
function resolve2(tier) {
|
|
5610
5666
|
const agentField = `${tier}_model`;
|
|
5611
5667
|
const platformField = `default_${tier}_model`;
|
|
5612
5668
|
const agentVal = agent?.[agentField];
|
|
@@ -5618,16 +5674,16 @@ function resolveModelChain(refreshData) {
|
|
|
5618
5674
|
return void 0;
|
|
5619
5675
|
}
|
|
5620
5676
|
return {
|
|
5621
|
-
primary:
|
|
5622
|
-
secondary:
|
|
5623
|
-
tertiary:
|
|
5677
|
+
primary: resolve2("primary"),
|
|
5678
|
+
secondary: resolve2("secondary"),
|
|
5679
|
+
tertiary: resolve2("tertiary")
|
|
5624
5680
|
};
|
|
5625
5681
|
}
|
|
5626
5682
|
|
|
5627
5683
|
// src/lib/manager/claude-auth.ts
|
|
5628
5684
|
import { existsSync as existsSync9, rmSync as rmSync3 } from "fs";
|
|
5629
|
-
import { join as
|
|
5630
|
-
import { homedir as
|
|
5685
|
+
import { join as join25 } from "path";
|
|
5686
|
+
import { homedir as homedir13 } from "os";
|
|
5631
5687
|
async function applyClaudeAuthToEnv(childEnv, label) {
|
|
5632
5688
|
const apiKey = getApiKey();
|
|
5633
5689
|
if (!apiKey) {
|
|
@@ -5639,9 +5695,9 @@ async function applyClaudeAuthToEnv(childEnv, label) {
|
|
|
5639
5695
|
throw new Error("claude_auth_mode=api_key but /host/exchange returned no decrypted key");
|
|
5640
5696
|
}
|
|
5641
5697
|
childEnv.ANTHROPIC_API_KEY = exchange.anthropicApiKey;
|
|
5642
|
-
const claudeDir =
|
|
5698
|
+
const claudeDir = join25(homedir13(), ".claude");
|
|
5643
5699
|
for (const filename of [".credentials.json", "credentials.json"]) {
|
|
5644
|
-
const p =
|
|
5700
|
+
const p = join25(claudeDir, filename);
|
|
5645
5701
|
if (existsSync9(p)) {
|
|
5646
5702
|
try {
|
|
5647
5703
|
rmSync3(p, { force: true });
|
|
@@ -5724,7 +5780,7 @@ function heartbeatRuntimeAuthFields(probeVerdict) {
|
|
|
5724
5780
|
|
|
5725
5781
|
// src/lib/manager/kanban/parsers.ts
|
|
5726
5782
|
import { existsSync as existsSync10, readFileSync as readFileSync20 } from "fs";
|
|
5727
|
-
import { join as
|
|
5783
|
+
import { join as join26 } from "path";
|
|
5728
5784
|
var STANDUP_TEMPLATES = /* @__PURE__ */ new Set(["daily-standup", "end-of-day-summary"]);
|
|
5729
5785
|
var TASK_UPDATE_TEMPLATES = /* @__PURE__ */ new Set(["hourly-status", "task-update"]);
|
|
5730
5786
|
var PLAN_TEMPLATES = /* @__PURE__ */ new Set(["morning-plan"]);
|
|
@@ -5876,8 +5932,8 @@ function getBuiltInSkillContent(skillId) {
|
|
|
5876
5932
|
if (builtInSkillCache.has(skillId)) return builtInSkillCache.get(skillId);
|
|
5877
5933
|
try {
|
|
5878
5934
|
const candidates = [
|
|
5879
|
-
|
|
5880
|
-
|
|
5935
|
+
join26(process.cwd(), "skills", skillId, "SKILL.md"),
|
|
5936
|
+
join26(new URL(".", import.meta.url).pathname, "..", "..", "..", "..", "..", "..", "skills", skillId, "SKILL.md")
|
|
5881
5937
|
];
|
|
5882
5938
|
for (const candidate of candidates) {
|
|
5883
5939
|
if (existsSync10(candidate)) {
|
|
@@ -6023,11 +6079,11 @@ function formatBoardForPrompt(items, template) {
|
|
|
6023
6079
|
|
|
6024
6080
|
// src/lib/manager/kanban/nudge-state-cache.ts
|
|
6025
6081
|
import { existsSync as existsSync11, readFileSync as readFileSync21, writeFileSync as writeFileSync9 } from "fs";
|
|
6026
|
-
import { join as
|
|
6082
|
+
import { join as join27 } from "path";
|
|
6027
6083
|
var CACHE_FILENAME2 = "kanban-nudge-state.json";
|
|
6028
6084
|
var KANBAN_NUDGE_STATE_VERSION = 1;
|
|
6029
6085
|
function getKanbanNudgeStateFile(configDir) {
|
|
6030
|
-
return
|
|
6086
|
+
return join27(configDir, CACHE_FILENAME2);
|
|
6031
6087
|
}
|
|
6032
6088
|
function loadKanbanNudgeState(target, configDir) {
|
|
6033
6089
|
const path = getKanbanNudgeStateFile(configDir);
|
|
@@ -6244,7 +6300,7 @@ async function maybePostSlackThreadHint(agentCodeName, channelId, primaryTs) {
|
|
|
6244
6300
|
// src/lib/manager/channels/telegram.ts
|
|
6245
6301
|
import https from "https";
|
|
6246
6302
|
function telegramApiCall(botToken, method, body) {
|
|
6247
|
-
return new Promise((
|
|
6303
|
+
return new Promise((resolve2, reject) => {
|
|
6248
6304
|
const postData = JSON.stringify(body);
|
|
6249
6305
|
const req = https.request({
|
|
6250
6306
|
hostname: "api.telegram.org",
|
|
@@ -6261,7 +6317,7 @@ function telegramApiCall(botToken, method, body) {
|
|
|
6261
6317
|
});
|
|
6262
6318
|
res.on("end", () => {
|
|
6263
6319
|
try {
|
|
6264
|
-
|
|
6320
|
+
resolve2(JSON.parse(data));
|
|
6265
6321
|
} catch {
|
|
6266
6322
|
reject(new Error("Invalid JSON from Telegram API"));
|
|
6267
6323
|
}
|
|
@@ -6568,7 +6624,7 @@ async function finishRun(runId, outcome, options = {}) {
|
|
|
6568
6624
|
log(
|
|
6569
6625
|
`[runs] finish attempt ${attempt + 1}/${maxRetries + 1} failed for run_id=${runId} outcome=${outcome} status=${status} error_id=${errId} \u2014 retrying`
|
|
6570
6626
|
);
|
|
6571
|
-
await new Promise((
|
|
6627
|
+
await new Promise((resolve2) => setTimeout(resolve2, baseMs * 2 ** attempt));
|
|
6572
6628
|
continue;
|
|
6573
6629
|
}
|
|
6574
6630
|
log(
|
|
@@ -6653,8 +6709,8 @@ function closeSessionRunForCode(codeName, outcome, reason) {
|
|
|
6653
6709
|
// src/lib/manager/scheduler/kanban-route.ts
|
|
6654
6710
|
import { createHash as createHash12 } from "crypto";
|
|
6655
6711
|
import { writeFileSync as writeFileSync10, renameSync as renameSync4, mkdirSync as mkdirSync7, readFileSync as readFileSync22, unlinkSync as unlinkSync2 } from "fs";
|
|
6656
|
-
import { homedir as
|
|
6657
|
-
import { join as
|
|
6712
|
+
import { homedir as homedir14 } from "os";
|
|
6713
|
+
import { join as join28, dirname as dirname7 } from "path";
|
|
6658
6714
|
|
|
6659
6715
|
// src/lib/manager/scheduler/notify.ts
|
|
6660
6716
|
import { createHash as createHash11 } from "crypto";
|
|
@@ -7013,7 +7069,7 @@ function resolveScheduledSlackTarget(task) {
|
|
|
7013
7069
|
}
|
|
7014
7070
|
function stampScheduledTurnMarker(codeName, taskId, target) {
|
|
7015
7071
|
try {
|
|
7016
|
-
const file =
|
|
7072
|
+
const file = join28(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
|
|
7017
7073
|
const marker = { ts: Date.now(), task_id: taskId, ...target ? { target } : {} };
|
|
7018
7074
|
const tmp = `${file}.tmp`;
|
|
7019
7075
|
writeFileSync10(tmp, JSON.stringify(marker), "utf8");
|
|
@@ -7023,7 +7079,7 @@ function stampScheduledTurnMarker(codeName, taskId, target) {
|
|
|
7023
7079
|
}
|
|
7024
7080
|
}
|
|
7025
7081
|
function clearScheduledTurnMarkerForTask(codeName, taskId) {
|
|
7026
|
-
const file =
|
|
7082
|
+
const file = join28(homedir14(), ".augmented", codeName, SCHEDULED_TURN_MARKER_FILENAME);
|
|
7027
7083
|
try {
|
|
7028
7084
|
const raw = JSON.parse(readFileSync22(file, "utf8"));
|
|
7029
7085
|
if (typeof raw?.task_id !== "string" || raw.task_id !== taskId) return;
|
|
@@ -7085,7 +7141,7 @@ async function routeScheduledTaskViaKanban(codeName, agentId, task, prompt, dura
|
|
|
7085
7141
|
return false;
|
|
7086
7142
|
}
|
|
7087
7143
|
try {
|
|
7088
|
-
const doorbell = directChatDoorbellPath(agentId,
|
|
7144
|
+
const doorbell = directChatDoorbellPath(agentId, homedir14());
|
|
7089
7145
|
mkdirSync7(dirname7(doorbell), { recursive: true });
|
|
7090
7146
|
writeFileSync10(doorbell, String(Date.now()));
|
|
7091
7147
|
} catch (err) {
|
|
@@ -7237,12 +7293,12 @@ async function processClaudeTaskResult(codeName, agentId, templateId, rawOutput,
|
|
|
7237
7293
|
|
|
7238
7294
|
// src/lib/manager/scheduler/execution.ts
|
|
7239
7295
|
import { createHash as createHash13 } from "crypto";
|
|
7240
|
-
import { homedir as
|
|
7241
|
-
import { join as
|
|
7296
|
+
import { homedir as homedir15 } from "os";
|
|
7297
|
+
import { join as join30 } from "path";
|
|
7242
7298
|
|
|
7243
7299
|
// src/lib/agent-serving-probe.ts
|
|
7244
7300
|
import { readFileSync as readFileSync23, readdirSync as readdirSync5, statSync as statSync5 } from "fs";
|
|
7245
|
-
import { join as
|
|
7301
|
+
import { join as join29 } from "path";
|
|
7246
7302
|
var RATE_LIMIT_WINDOW_MS = 6 * 60 * 60 * 1e3;
|
|
7247
7303
|
function probeRateLimit(args) {
|
|
7248
7304
|
const now = args.now ?? /* @__PURE__ */ new Date();
|
|
@@ -7258,7 +7314,7 @@ function probeRateLimit(args) {
|
|
|
7258
7314
|
let newest = UNKNOWN_RATE_LIMIT;
|
|
7259
7315
|
for (const name of entries) {
|
|
7260
7316
|
if (!name.endsWith(".jsonl")) continue;
|
|
7261
|
-
const path =
|
|
7317
|
+
const path = join29(dir, name);
|
|
7262
7318
|
try {
|
|
7263
7319
|
const st = statSync5(path);
|
|
7264
7320
|
if (!st.isFile() || st.mtimeMs < startMs) continue;
|
|
@@ -7329,7 +7385,7 @@ function shouldLogUsageCapDeferral(site, codeName, limitedUntil) {
|
|
|
7329
7385
|
|
|
7330
7386
|
// src/lib/manager/scheduler/execution.ts
|
|
7331
7387
|
function claudePidFilePath() {
|
|
7332
|
-
return
|
|
7388
|
+
return join30(homedir15(), ".augmented", "manager-claude-pids.json");
|
|
7333
7389
|
}
|
|
7334
7390
|
var inFlightClaudePids = /* @__PURE__ */ new Map();
|
|
7335
7391
|
function registerClaudeSpawn(record) {
|
|
@@ -7400,7 +7456,7 @@ async function syncAndCheckClaudeScheduler(agent, tasks, boardItems, refreshData
|
|
|
7400
7456
|
|
|
7401
7457
|
// src/lib/occupancy-gate.ts
|
|
7402
7458
|
import { closeSync as closeSync2, openSync as openSync2, readdirSync as readdirSync6, readSync as readSync2, statSync as statSync6 } from "fs";
|
|
7403
|
-
import { join as
|
|
7459
|
+
import { join as join31 } from "path";
|
|
7404
7460
|
function rostersMeasuredZero(mode, attested, runtimeRunning) {
|
|
7405
7461
|
return mode === "enforce" && attested && runtimeRunning;
|
|
7406
7462
|
}
|
|
@@ -7489,10 +7545,10 @@ function candidateTranscriptPaths(dir) {
|
|
|
7489
7545
|
let complete = true;
|
|
7490
7546
|
for (const name of top) {
|
|
7491
7547
|
if (name.endsWith(".jsonl")) {
|
|
7492
|
-
paths.push(
|
|
7548
|
+
paths.push(join31(dir, name));
|
|
7493
7549
|
continue;
|
|
7494
7550
|
}
|
|
7495
|
-
const subDir =
|
|
7551
|
+
const subDir = join31(dir, name, "subagents");
|
|
7496
7552
|
let subs;
|
|
7497
7553
|
try {
|
|
7498
7554
|
subs = readdirSync6(subDir);
|
|
@@ -7501,7 +7557,7 @@ function candidateTranscriptPaths(dir) {
|
|
|
7501
7557
|
continue;
|
|
7502
7558
|
}
|
|
7503
7559
|
for (const sub of subs) {
|
|
7504
|
-
if (sub.endsWith(".jsonl")) paths.push(
|
|
7560
|
+
if (sub.endsWith(".jsonl")) paths.push(join31(subDir, sub));
|
|
7505
7561
|
}
|
|
7506
7562
|
}
|
|
7507
7563
|
return { paths, complete };
|
|
@@ -8985,7 +9041,7 @@ async function fireOpencodeScheduledTask(agent, task) {
|
|
|
8985
9041
|
import { createHash as createHash16 } from "crypto";
|
|
8986
9042
|
import { existsSync as existsSync13, mkdirSync as mkdirSync8, readFileSync as readFileSync25, renameSync as renameSync5, unlinkSync as unlinkSync3, writeFileSync as writeFileSync11 } from "fs";
|
|
8987
9043
|
import { randomUUID } from "crypto";
|
|
8988
|
-
import { join as
|
|
9044
|
+
import { join as join32 } from "path";
|
|
8989
9045
|
|
|
8990
9046
|
// src/lib/telegram-ingest.ts
|
|
8991
9047
|
import https2 from "https";
|
|
@@ -9207,7 +9263,7 @@ function buildTelegramPeerClassifierConfigFromEnv(env, opts) {
|
|
|
9207
9263
|
}
|
|
9208
9264
|
|
|
9209
9265
|
// src/lib/telegram-ingest.ts
|
|
9210
|
-
var nodeHttpsTelegramFetch = (url, init) => new Promise((
|
|
9266
|
+
var nodeHttpsTelegramFetch = (url, init) => new Promise((resolve2, reject) => {
|
|
9211
9267
|
const u = new URL(url);
|
|
9212
9268
|
const body = init?.body;
|
|
9213
9269
|
const headers = { ...init?.headers ?? {} };
|
|
@@ -9233,7 +9289,7 @@ var nodeHttpsTelegramFetch = (url, init) => new Promise((resolve, reject) => {
|
|
|
9233
9289
|
});
|
|
9234
9290
|
res.on("end", () => {
|
|
9235
9291
|
const status = res.statusCode ?? 0;
|
|
9236
|
-
|
|
9292
|
+
resolve2({
|
|
9237
9293
|
ok: status >= 200 && status < 300,
|
|
9238
9294
|
status,
|
|
9239
9295
|
json: async () => JSON.parse(data.length > 0 ? data : "{}")
|
|
@@ -9422,8 +9478,8 @@ function defaultAddReaction2(botToken, fetchImpl, log2) {
|
|
|
9422
9478
|
};
|
|
9423
9479
|
}
|
|
9424
9480
|
function sleep(ms) {
|
|
9425
|
-
return new Promise((
|
|
9426
|
-
setTimeout(
|
|
9481
|
+
return new Promise((resolve2) => {
|
|
9482
|
+
setTimeout(resolve2, ms).unref?.();
|
|
9427
9483
|
});
|
|
9428
9484
|
}
|
|
9429
9485
|
function startTelegramIngest(config2) {
|
|
@@ -9533,7 +9589,7 @@ function createFileOffsetStore(codeName, log2, currentBotId) {
|
|
|
9533
9589
|
let filePath;
|
|
9534
9590
|
try {
|
|
9535
9591
|
dir = getFramework("opencode").getAgentDir(codeName);
|
|
9536
|
-
filePath =
|
|
9592
|
+
filePath = join32(dir, "telegram-getupdates-offset-opencode.json");
|
|
9537
9593
|
} catch {
|
|
9538
9594
|
dir = null;
|
|
9539
9595
|
filePath = null;
|
|
@@ -9813,14 +9869,14 @@ function partitionActionableByPoison(actionable, states, config2) {
|
|
|
9813
9869
|
|
|
9814
9870
|
// src/lib/restart-flags.ts
|
|
9815
9871
|
import { existsSync as existsSync14, mkdirSync as mkdirSync9, readdirSync as readdirSync7, readFileSync as readFileSync26, renameSync as renameSync6, rmSync as rmSync4, writeFileSync as writeFileSync12 } from "fs";
|
|
9816
|
-
import { homedir as
|
|
9817
|
-
import { join as
|
|
9872
|
+
import { homedir as homedir16 } from "os";
|
|
9873
|
+
import { join as join33 } from "path";
|
|
9818
9874
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
9819
9875
|
function restartFlagsDir() {
|
|
9820
|
-
return
|
|
9876
|
+
return join33(homedir16(), ".augmented", "restart-flags");
|
|
9821
9877
|
}
|
|
9822
9878
|
function flagPath(codeName) {
|
|
9823
|
-
return
|
|
9879
|
+
return join33(restartFlagsDir(), `${codeName}.flag`);
|
|
9824
9880
|
}
|
|
9825
9881
|
function readRestartFlags() {
|
|
9826
9882
|
const dir = restartFlagsDir();
|
|
@@ -9829,7 +9885,7 @@ function readRestartFlags() {
|
|
|
9829
9885
|
for (const entry of readdirSync7(dir)) {
|
|
9830
9886
|
if (!entry.endsWith(".flag")) continue;
|
|
9831
9887
|
try {
|
|
9832
|
-
const raw = readFileSync26(
|
|
9888
|
+
const raw = readFileSync26(join33(dir, entry), "utf8");
|
|
9833
9889
|
const parsed = JSON.parse(raw);
|
|
9834
9890
|
if (typeof parsed.codeName !== "string" || parsed.codeName.length === 0) {
|
|
9835
9891
|
parsed.codeName = entry.replace(/\.flag$/, "");
|
|
@@ -9948,7 +10004,7 @@ async function sendError(flag, opts, text) {
|
|
|
9948
10004
|
|
|
9949
10005
|
// src/lib/restart-context.ts
|
|
9950
10006
|
import { readdirSync as readdirSync8, readFileSync as readFileSync27, writeFileSync as writeFileSync13, mkdirSync as mkdirSync10, unlinkSync as unlinkSync4 } from "fs";
|
|
9951
|
-
import { dirname as dirname8, join as
|
|
10007
|
+
import { dirname as dirname8, join as join34 } from "path";
|
|
9952
10008
|
var SLACK_PENDING_INBOUND_DIRNAME = "slack-pending-inbound";
|
|
9953
10009
|
var SLACK_RESTART_CONTEXT_DIRNAME = "slack-restart-context";
|
|
9954
10010
|
var MAX_TOPIC_CHARS = 140;
|
|
@@ -9960,10 +10016,10 @@ function augmentedAgentDir(codeName) {
|
|
|
9960
10016
|
return dirname8(getProjectDir(codeName));
|
|
9961
10017
|
}
|
|
9962
10018
|
function slackPendingInboundDir(codeName) {
|
|
9963
|
-
return
|
|
10019
|
+
return join34(augmentedAgentDir(codeName), SLACK_PENDING_INBOUND_DIRNAME);
|
|
9964
10020
|
}
|
|
9965
10021
|
function slackRestartContextDir(codeName) {
|
|
9966
|
-
return
|
|
10022
|
+
return join34(augmentedAgentDir(codeName), SLACK_RESTART_CONTEXT_DIRNAME);
|
|
9967
10023
|
}
|
|
9968
10024
|
function sanitizeTopic(raw) {
|
|
9969
10025
|
const cleaned = raw.replace(/\s+/g, " ").trim().replace(/[<>]/g, " ").replace(/\s+/g, " ").trim();
|
|
@@ -10023,7 +10079,7 @@ function pruneHintsExcept(codeName, freshFilenames) {
|
|
|
10023
10079
|
if (!filename.endsWith(".json")) continue;
|
|
10024
10080
|
if (freshFilenames.has(filename)) continue;
|
|
10025
10081
|
try {
|
|
10026
|
-
unlinkSync4(
|
|
10082
|
+
unlinkSync4(join34(ctxDir, filename));
|
|
10027
10083
|
} catch {
|
|
10028
10084
|
}
|
|
10029
10085
|
}
|
|
@@ -10044,7 +10100,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
|
|
|
10044
10100
|
}
|
|
10045
10101
|
const markers = [];
|
|
10046
10102
|
for (const filename of markerFilenames.slice(0, cap)) {
|
|
10047
|
-
const parsed = readStrandedMarker(
|
|
10103
|
+
const parsed = readStrandedMarker(join34(markerDir, filename));
|
|
10048
10104
|
if (parsed) markers.push({ filename, channel: parsed.channel, thread_ts: parsed.thread_ts });
|
|
10049
10105
|
}
|
|
10050
10106
|
if (markers.length === 0) {
|
|
@@ -10058,7 +10114,7 @@ function refreshSlackRestartContextHints(codeNames, opts = {}) {
|
|
|
10058
10114
|
const freshFilenames = /* @__PURE__ */ new Set();
|
|
10059
10115
|
for (const { filename, hint } of hints) {
|
|
10060
10116
|
try {
|
|
10061
|
-
writeHintFile(
|
|
10117
|
+
writeHintFile(join34(ctxDir, filename), ctxDir, hint);
|
|
10062
10118
|
freshFilenames.add(filename);
|
|
10063
10119
|
} catch (err) {
|
|
10064
10120
|
log2(`[restart-context] ${codeName}: hint write failed for ${filename}: ${err.message}`);
|
|
@@ -11660,7 +11716,7 @@ var runningChannelSecretHashes = /* @__PURE__ */ new Map();
|
|
|
11660
11716
|
var sessionLaunchManagedStructure = /* @__PURE__ */ new Map();
|
|
11661
11717
|
function projectMcpHash(_codeName, projectDir) {
|
|
11662
11718
|
try {
|
|
11663
|
-
const raw = readFileSync28(
|
|
11719
|
+
const raw = readFileSync28(join35(projectDir, ".mcp.json"), "utf-8");
|
|
11664
11720
|
return createHash17("sha256").update(canonicalJson(JSON.parse(raw))).digest("hex");
|
|
11665
11721
|
} catch {
|
|
11666
11722
|
return null;
|
|
@@ -11668,7 +11724,7 @@ function projectMcpHash(_codeName, projectDir) {
|
|
|
11668
11724
|
}
|
|
11669
11725
|
function projectMcpKeys(_codeName, projectDir) {
|
|
11670
11726
|
try {
|
|
11671
|
-
const raw = readFileSync28(
|
|
11727
|
+
const raw = readFileSync28(join35(projectDir, ".mcp.json"), "utf-8");
|
|
11672
11728
|
const parsed = JSON.parse(raw);
|
|
11673
11729
|
const servers = parsed.mcpServers;
|
|
11674
11730
|
if (!servers || typeof servers !== "object") return /* @__PURE__ */ new Set();
|
|
@@ -11686,7 +11742,7 @@ function seedSessionLaunchBaselines(codeName, projectDir) {
|
|
|
11686
11742
|
else runningMcpServerKeys.delete(codeName);
|
|
11687
11743
|
let launchStructure = null;
|
|
11688
11744
|
try {
|
|
11689
|
-
const raw = readFileSync28(
|
|
11745
|
+
const raw = readFileSync28(join35(projectDir, ".mcp.json"), "utf-8");
|
|
11690
11746
|
launchStructure = managedMcpStructureHashFromFile(
|
|
11691
11747
|
JSON.parse(raw),
|
|
11692
11748
|
isManagedMcpServerKey
|
|
@@ -11808,7 +11864,7 @@ async function runAgentSessionToolBindProbes(agent, integrations, projectDir, op
|
|
|
11808
11864
|
if (result && result.rebindCandidates.length > 0 && hostFlagStore().getBoolean("session-tool-rebind")) {
|
|
11809
11865
|
let mcpJsonForRebind = null;
|
|
11810
11866
|
try {
|
|
11811
|
-
mcpJsonForRebind = JSON.parse(readFileSync28(
|
|
11867
|
+
mcpJsonForRebind = JSON.parse(readFileSync28(join35(projectDir, ".mcp.json"), "utf-8"));
|
|
11812
11868
|
} catch {
|
|
11813
11869
|
mcpJsonForRebind = null;
|
|
11814
11870
|
}
|
|
@@ -11953,7 +12009,7 @@ function checkMcpConfigDriftAndScheduleRestart(codeName, projectDir) {
|
|
|
11953
12009
|
function projectChannelSecretHash(projectDir) {
|
|
11954
12010
|
try {
|
|
11955
12011
|
const entries = parseEnvIntegrations(
|
|
11956
|
-
readFileSync28(
|
|
12012
|
+
readFileSync28(join35(projectDir, ".env.integrations"), "utf-8")
|
|
11957
12013
|
);
|
|
11958
12014
|
return channelSecretValueHash(entries, CHANNEL_SECRET_ENV_KEYS);
|
|
11959
12015
|
} catch {
|
|
@@ -12049,7 +12105,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
|
|
|
12049
12105
|
var lastVersionCheckAt = 0;
|
|
12050
12106
|
var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
12051
12107
|
var lastResponsivenessProbeAt = 0;
|
|
12052
|
-
var agtCliVersion = true ? "0.28.
|
|
12108
|
+
var agtCliVersion = true ? "0.28.628" : "dev";
|
|
12053
12109
|
function resolveBrewPath(execFileSync3) {
|
|
12054
12110
|
try {
|
|
12055
12111
|
const out = execFileSync3("which", ["brew"], { timeout: 5e3 }).toString().trim();
|
|
@@ -12336,7 +12392,7 @@ async function reapSupersededRuntimeImages(imageUri, localTag) {
|
|
|
12336
12392
|
}
|
|
12337
12393
|
}
|
|
12338
12394
|
function runAsync(cmd, args, opts) {
|
|
12339
|
-
return new Promise((
|
|
12395
|
+
return new Promise((resolve2, reject) => {
|
|
12340
12396
|
import("child_process").then(({ spawn }) => {
|
|
12341
12397
|
const child = spawn(cmd, args, { stdio: ["ignore", "pipe", "pipe"], cwd: opts.cwd });
|
|
12342
12398
|
let stdout = "";
|
|
@@ -12370,7 +12426,7 @@ function runAsync(cmd, args, opts) {
|
|
|
12370
12426
|
if (settled) return;
|
|
12371
12427
|
settled = true;
|
|
12372
12428
|
clearTimeout(timer3);
|
|
12373
|
-
|
|
12429
|
+
resolve2({ code: code ?? -1, stdout, stderr });
|
|
12374
12430
|
});
|
|
12375
12431
|
}).catch(reject);
|
|
12376
12432
|
});
|
|
@@ -12437,7 +12493,7 @@ async function ensureOpencodeBinary() {
|
|
|
12437
12493
|
try {
|
|
12438
12494
|
const prefix = execFileSync3("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
12439
12495
|
if (prefix) {
|
|
12440
|
-
const npmBin =
|
|
12496
|
+
const npmBin = join35(prefix, "bin");
|
|
12441
12497
|
const current = (process.env.PATH ?? "").split(pathDelimiter);
|
|
12442
12498
|
if (!current.includes(npmBin)) {
|
|
12443
12499
|
process.env.PATH = [npmBin, ...current.filter(Boolean)].join(pathDelimiter);
|
|
@@ -12554,7 +12610,7 @@ ${r.stderr}`;
|
|
|
12554
12610
|
}
|
|
12555
12611
|
var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
12556
12612
|
function selfUpdateAppliedMarkerPath() {
|
|
12557
|
-
return
|
|
12613
|
+
return join35(homedir17(), ".augmented", ".last-self-update-applied");
|
|
12558
12614
|
}
|
|
12559
12615
|
var selfUpdateUpToDateLogged = false;
|
|
12560
12616
|
var selfUpdatePinnedLogged = false;
|
|
@@ -12583,7 +12639,7 @@ async function checkAndUpdateCli(opts) {
|
|
|
12583
12639
|
const isNpmGlobal = !isBrewFormula && resolvedPath.includes("node_modules");
|
|
12584
12640
|
if (!isBrewFormula && !isNpmGlobal) return "noop";
|
|
12585
12641
|
const { readFileSync: readF, writeFileSync: writeF } = await import("fs");
|
|
12586
|
-
const markerPath =
|
|
12642
|
+
const markerPath = join35(homedir17(), ".augmented", ".last-update-check");
|
|
12587
12643
|
if (!force) {
|
|
12588
12644
|
try {
|
|
12589
12645
|
const lastCheck = parseInt(readF(markerPath, "utf-8").trim(), 10);
|
|
@@ -12989,7 +13045,7 @@ async function runClaudeRuntimeAuthProbe() {
|
|
|
12989
13045
|
];
|
|
12990
13046
|
try {
|
|
12991
13047
|
const { stdout, stderr } = await execFilePromiseLong(resolveClaudeBinary(), args, {
|
|
12992
|
-
cwd:
|
|
13048
|
+
cwd: homedir17(),
|
|
12993
13049
|
timeout: RUNTIME_AUTH_PROBE_TIMEOUT_MS,
|
|
12994
13050
|
stdin: "ignore",
|
|
12995
13051
|
env: childEnv,
|
|
@@ -13036,12 +13092,12 @@ async function checkClaudeAuth() {
|
|
|
13036
13092
|
var evalEmptyMcpConfigPath = null;
|
|
13037
13093
|
function ensureEvalEmptyMcpConfig() {
|
|
13038
13094
|
if (evalEmptyMcpConfigPath && existsSync15(evalEmptyMcpConfigPath)) return evalEmptyMcpConfigPath;
|
|
13039
|
-
const dir =
|
|
13095
|
+
const dir = join35(homedir17(), ".augmented");
|
|
13040
13096
|
try {
|
|
13041
13097
|
mkdirSync11(dir, { recursive: true });
|
|
13042
13098
|
} catch {
|
|
13043
13099
|
}
|
|
13044
|
-
const p =
|
|
13100
|
+
const p = join35(dir, ".eval-empty-mcp.json");
|
|
13045
13101
|
writeFileSync14(p, JSON.stringify({ mcpServers: {} }));
|
|
13046
13102
|
evalEmptyMcpConfigPath = p;
|
|
13047
13103
|
return p;
|
|
@@ -13067,7 +13123,7 @@ async function runEvalClaude(prompt, model) {
|
|
|
13067
13123
|
""
|
|
13068
13124
|
];
|
|
13069
13125
|
const { stdout } = await execFilePromiseLong(resolveClaudeBinary(), args, {
|
|
13070
|
-
cwd:
|
|
13126
|
+
cwd: homedir17(),
|
|
13071
13127
|
timeout: 12e4,
|
|
13072
13128
|
stdin: "ignore",
|
|
13073
13129
|
env: childEnv,
|
|
@@ -13136,10 +13192,10 @@ function resolveConversationEvalBackend() {
|
|
|
13136
13192
|
return conversationEvalBackend;
|
|
13137
13193
|
}
|
|
13138
13194
|
function getStateFile() {
|
|
13139
|
-
return
|
|
13195
|
+
return join35(config?.configDir ?? join35(process.env["HOME"] ?? "/tmp", ".augmented"), "manager-state.json");
|
|
13140
13196
|
}
|
|
13141
13197
|
function channelHashCacheDir() {
|
|
13142
|
-
return config?.configDir ??
|
|
13198
|
+
return config?.configDir ?? join35(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
13143
13199
|
}
|
|
13144
13200
|
function loadChannelHashCache2() {
|
|
13145
13201
|
loadChannelHashCache(agentState.knownChannelConfigHashes, channelHashCacheDir());
|
|
@@ -13193,7 +13249,7 @@ function removeDeliveryBaselineEntries(agentId) {
|
|
|
13193
13249
|
var _channelQuarantineStore = null;
|
|
13194
13250
|
function channelQuarantineStore() {
|
|
13195
13251
|
if (!_channelQuarantineStore) {
|
|
13196
|
-
const dir = config?.configDir ??
|
|
13252
|
+
const dir = config?.configDir ?? join35(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
13197
13253
|
_channelQuarantineStore = new ChannelQuarantineStore(defaultQuarantinePath(dir));
|
|
13198
13254
|
}
|
|
13199
13255
|
return _channelQuarantineStore;
|
|
@@ -13210,7 +13266,7 @@ function claudeMdSizeFor(codeName) {
|
|
|
13210
13266
|
var _hostFlagStore = null;
|
|
13211
13267
|
function hostFlagStore() {
|
|
13212
13268
|
if (!_hostFlagStore) {
|
|
13213
|
-
const dir = config?.configDir ??
|
|
13269
|
+
const dir = config?.configDir ?? join35(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
13214
13270
|
_hostFlagStore = new HostFlagStore({ cachePath: defaultFlagsCachePath(dir), log });
|
|
13215
13271
|
}
|
|
13216
13272
|
return _hostFlagStore;
|
|
@@ -13284,12 +13340,12 @@ function parseSkillFrontmatter(content) {
|
|
|
13284
13340
|
}
|
|
13285
13341
|
async function refreshSkillsIndexInClaudeMd(configDir, codeName, log2) {
|
|
13286
13342
|
const { readdirSync: readdirSync10, readFileSync: rfs, existsSync: ex, writeFileSync: writeFileSync15 } = await import("fs");
|
|
13287
|
-
const skillsDir =
|
|
13288
|
-
const claudeMdPath =
|
|
13343
|
+
const skillsDir = join35(configDir, codeName, "project", ".claude", "skills");
|
|
13344
|
+
const claudeMdPath = join35(configDir, codeName, "project", "CLAUDE.md");
|
|
13289
13345
|
if (!ex(skillsDir) || !ex(claudeMdPath)) return;
|
|
13290
13346
|
const entries = [];
|
|
13291
13347
|
for (const dir of readdirSync10(skillsDir).sort()) {
|
|
13292
|
-
const skillFile =
|
|
13348
|
+
const skillFile = join35(skillsDir, dir, "SKILL.md");
|
|
13293
13349
|
if (!ex(skillFile)) continue;
|
|
13294
13350
|
try {
|
|
13295
13351
|
const { name, description } = parseSkillFrontmatter(rfs(skillFile, "utf-8"));
|
|
@@ -13793,10 +13849,10 @@ async function pollCycleInner() {
|
|
|
13793
13849
|
const paneTail = readFileSync28(paneLogPath(codeName), "utf8").slice(-65536);
|
|
13794
13850
|
const transient = detectTransientApiErrorInLog(paneTail);
|
|
13795
13851
|
if (transient) {
|
|
13796
|
-
const wedgeHome =
|
|
13852
|
+
const wedgeHome = join35(homedir17(), ".augmented", codeName);
|
|
13797
13853
|
if (existsSync15(wedgeHome)) {
|
|
13798
13854
|
atomicWriteFileSync(
|
|
13799
|
-
|
|
13855
|
+
join35(wedgeHome, "watchdog-give-up.json"),
|
|
13800
13856
|
JSON.stringify({
|
|
13801
13857
|
gave_up_at: wedgeNow.toISOString(),
|
|
13802
13858
|
reason: "transient_overload"
|
|
@@ -14090,7 +14146,7 @@ async function pollCycleInner() {
|
|
|
14090
14146
|
const adapter = resolveAgentFramework(prev.codeName);
|
|
14091
14147
|
stopAgentRuntime2(prev.codeName, "removed-from-host");
|
|
14092
14148
|
killAgentChannelProcesses(prev.codeName, { log });
|
|
14093
|
-
const agentDir =
|
|
14149
|
+
const agentDir = join35(adapter.getAgentDir(prev.codeName), "provision");
|
|
14094
14150
|
await cleanupAgentFiles(prev.codeName, agentDir);
|
|
14095
14151
|
clearAgentCaches(prev.agentId, prev.codeName);
|
|
14096
14152
|
}
|
|
@@ -14177,10 +14233,10 @@ async function pollCycleInner() {
|
|
|
14177
14233
|
// pending-inbound marker. Best-effort: a write failure is logged by
|
|
14178
14234
|
// the watchdog, never fails the poll cycle.
|
|
14179
14235
|
signalGiveUp: (codeName) => {
|
|
14180
|
-
const dir =
|
|
14236
|
+
const dir = join35(homedir17(), ".augmented", codeName);
|
|
14181
14237
|
if (!existsSync15(dir)) return;
|
|
14182
14238
|
atomicWriteFileSync(
|
|
14183
|
-
|
|
14239
|
+
join35(dir, "watchdog-give-up.json"),
|
|
14184
14240
|
JSON.stringify({ gave_up_at: (/* @__PURE__ */ new Date()).toISOString() })
|
|
14185
14241
|
);
|
|
14186
14242
|
}
|
|
@@ -14376,7 +14432,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
14376
14432
|
}
|
|
14377
14433
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
14378
14434
|
const adapter = resolveAgentFramework(agent.code_name);
|
|
14379
|
-
let agentDir =
|
|
14435
|
+
let agentDir = join35(adapter.getAgentDir(agent.code_name), "provision");
|
|
14380
14436
|
if (agent.status === "draft" || agent.status === "paused") {
|
|
14381
14437
|
if (previousKnownStatus !== agent.status) {
|
|
14382
14438
|
log(`Agent '${agent.code_name}' is ${agent.status}, skipping provisioning`);
|
|
@@ -14550,7 +14606,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
14550
14606
|
const frameworkId = refreshData.agent.framework ?? DEFAULT_FRAMEWORK;
|
|
14551
14607
|
agentFrameworkCache.set(agent.code_name, frameworkId);
|
|
14552
14608
|
const frameworkAdapter = getFramework(frameworkId);
|
|
14553
|
-
agentDir =
|
|
14609
|
+
agentDir = join35(frameworkAdapter.getAgentDir(agent.code_name), "provision");
|
|
14554
14610
|
cacheAgentDeliveryMetadata(agent.code_name, refreshData);
|
|
14555
14611
|
agentRestartTimezoneInputs.set(agent.code_name, {
|
|
14556
14612
|
agentTimezone: typeof refreshData.agent.timezone === "string" ? refreshData.agent.timezone : null,
|
|
@@ -14599,7 +14655,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
14599
14655
|
const changedFiles = [];
|
|
14600
14656
|
mkdirSync11(agentDir, { recursive: true });
|
|
14601
14657
|
for (const artifact of artifacts) {
|
|
14602
|
-
const filePath =
|
|
14658
|
+
const filePath = join35(agentDir, artifact.relativePath);
|
|
14603
14659
|
let existingHash;
|
|
14604
14660
|
let newHash;
|
|
14605
14661
|
let writeContent = artifact.content;
|
|
@@ -14618,7 +14674,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
14618
14674
|
};
|
|
14619
14675
|
newHash = sha256(stripDynamicSections(artifact.content));
|
|
14620
14676
|
try {
|
|
14621
|
-
const projectClaudeMd =
|
|
14677
|
+
const projectClaudeMd = join35(config.configDir, agent.code_name, "project", "CLAUDE.md");
|
|
14622
14678
|
const existing = readFileSync28(projectClaudeMd, "utf-8");
|
|
14623
14679
|
existingHash = sha256(stripDynamicSections(existing));
|
|
14624
14680
|
} catch {
|
|
@@ -14669,12 +14725,12 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
14669
14725
|
}
|
|
14670
14726
|
}
|
|
14671
14727
|
if (changedFiles.length > 0) {
|
|
14672
|
-
const isFirst = !existsSync15(
|
|
14728
|
+
const isFirst = !existsSync15(join35(agentDir, "CHARTER.md"));
|
|
14673
14729
|
const verb = isFirst ? "Provisioning" : "Updating";
|
|
14674
14730
|
const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
|
|
14675
14731
|
log(`${verb} '${agent.code_name}': ${fileNames}`);
|
|
14676
14732
|
for (const file of changedFiles) {
|
|
14677
|
-
const filePath =
|
|
14733
|
+
const filePath = join35(agentDir, file.relativePath);
|
|
14678
14734
|
mkdirSync11(dirname9(filePath), { recursive: true });
|
|
14679
14735
|
if (file.relativePath === ".mcp.json") {
|
|
14680
14736
|
safeWriteJsonAtomic(filePath, file.content, { mode: 384 });
|
|
@@ -14683,12 +14739,12 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
14683
14739
|
}
|
|
14684
14740
|
}
|
|
14685
14741
|
try {
|
|
14686
|
-
const provSkillsDir =
|
|
14742
|
+
const provSkillsDir = join35(agentDir, ".claude", "skills");
|
|
14687
14743
|
if (existsSync15(provSkillsDir)) {
|
|
14688
14744
|
for (const folder of readdirSync9(provSkillsDir)) {
|
|
14689
14745
|
if (folder.startsWith("knowledge-")) {
|
|
14690
14746
|
try {
|
|
14691
|
-
rmSync5(
|
|
14747
|
+
rmSync5(join35(provSkillsDir, folder), { recursive: true });
|
|
14692
14748
|
} catch {
|
|
14693
14749
|
}
|
|
14694
14750
|
}
|
|
@@ -14701,7 +14757,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
14701
14757
|
const trackedFiles2 = frameworkAdapter.driftTrackedFiles();
|
|
14702
14758
|
const hashes = /* @__PURE__ */ new Map();
|
|
14703
14759
|
for (const file of trackedFiles2) {
|
|
14704
|
-
const h = hashFile(
|
|
14760
|
+
const h = hashFile(join35(agentDir, file));
|
|
14705
14761
|
if (h) hashes.set(file, h);
|
|
14706
14762
|
}
|
|
14707
14763
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -14719,14 +14775,14 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
14719
14775
|
}
|
|
14720
14776
|
if (Array.isArray(refreshData.workflows)) {
|
|
14721
14777
|
try {
|
|
14722
|
-
const provWorkflowsDir =
|
|
14778
|
+
const provWorkflowsDir = join35(agentDir, ".claude", "workflows");
|
|
14723
14779
|
if (existsSync15(provWorkflowsDir)) {
|
|
14724
14780
|
const expected = new Set(refreshData.workflows.map((w) => `${w.name}.js`));
|
|
14725
14781
|
for (const file of readdirSync9(provWorkflowsDir)) {
|
|
14726
14782
|
if (!file.endsWith(".js")) continue;
|
|
14727
14783
|
if (expected.has(file)) continue;
|
|
14728
14784
|
try {
|
|
14729
|
-
rmSync5(
|
|
14785
|
+
rmSync5(join35(provWorkflowsDir, file));
|
|
14730
14786
|
} catch {
|
|
14731
14787
|
}
|
|
14732
14788
|
}
|
|
@@ -14808,7 +14864,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
14808
14864
|
if (written && existsSync15(agentDir)) {
|
|
14809
14865
|
const driftedFiles = [];
|
|
14810
14866
|
for (const [file, expectedHash] of written) {
|
|
14811
|
-
const localHash = hashFile(
|
|
14867
|
+
const localHash = hashFile(join35(agentDir, file));
|
|
14812
14868
|
if (localHash && localHash !== expectedHash) {
|
|
14813
14869
|
driftedFiles.push(file);
|
|
14814
14870
|
}
|
|
@@ -14819,7 +14875,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
14819
14875
|
try {
|
|
14820
14876
|
const localHashes = {};
|
|
14821
14877
|
for (const file of driftedFiles) {
|
|
14822
|
-
localHashes[file] = hashFile(
|
|
14878
|
+
localHashes[file] = hashFile(join35(agentDir, file));
|
|
14823
14879
|
}
|
|
14824
14880
|
await api.post("/host/drift", {
|
|
14825
14881
|
agent_id: agent.agent_id,
|
|
@@ -15021,7 +15077,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
15021
15077
|
const addedChannels = [...restartDecision.added];
|
|
15022
15078
|
const writeDmNoticeMarkers = isChannelAddRestart ? () => {
|
|
15023
15079
|
try {
|
|
15024
|
-
const agentAugmentedDir =
|
|
15080
|
+
const agentAugmentedDir = join35(homedir17(), ".augmented", agent.code_name);
|
|
15025
15081
|
mkdirSync11(agentAugmentedDir, { recursive: true });
|
|
15026
15082
|
const markerJson = JSON.stringify({
|
|
15027
15083
|
version: 1,
|
|
@@ -15029,7 +15085,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
15029
15085
|
added: addedChannels
|
|
15030
15086
|
});
|
|
15031
15087
|
for (const file of ["slack-channel-add-restart.json", "telegram-channel-add-restart.json"]) {
|
|
15032
|
-
atomicWriteFileSync(
|
|
15088
|
+
atomicWriteFileSync(join35(agentAugmentedDir, file), markerJson);
|
|
15033
15089
|
}
|
|
15034
15090
|
} catch (err) {
|
|
15035
15091
|
log(`[hot-reload] channel-add DM-notice marker write failed for '${agent.code_name}' (non-fatal): ${err.message}`);
|
|
@@ -15218,18 +15274,18 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
15218
15274
|
if (agentSessionMode === "persistent" && (agentFrameworkCache.get(agent.code_name) ?? DEFAULT_FRAMEWORK) === "claude-code") {
|
|
15219
15275
|
try {
|
|
15220
15276
|
const agentProvisionDir = agentDir;
|
|
15221
|
-
const projectDir =
|
|
15277
|
+
const projectDir = join35(homedir17(), ".augmented", agent.code_name, "project");
|
|
15222
15278
|
mkdirSync11(agentProvisionDir, { recursive: true });
|
|
15223
15279
|
mkdirSync11(projectDir, { recursive: true });
|
|
15224
|
-
const provisionMcpPath =
|
|
15225
|
-
const projectMcpPath =
|
|
15280
|
+
const provisionMcpPath = join35(agentProvisionDir, ".mcp.json");
|
|
15281
|
+
const projectMcpPath = join35(projectDir, ".mcp.json");
|
|
15226
15282
|
let mcpConfig = { mcpServers: {} };
|
|
15227
15283
|
try {
|
|
15228
15284
|
mcpConfig = JSON.parse(readFileSync28(provisionMcpPath, "utf-8"));
|
|
15229
15285
|
if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
|
|
15230
15286
|
} catch {
|
|
15231
15287
|
}
|
|
15232
|
-
const localDirectChatChannel =
|
|
15288
|
+
const localDirectChatChannel = join35(homedir17(), ".augmented", "_mcp", "direct-chat-channel.js");
|
|
15233
15289
|
const directChatTeamSettings = refreshData.team?.settings;
|
|
15234
15290
|
const directChatTz = (() => {
|
|
15235
15291
|
const tz = directChatTeamSettings?.["timezone"];
|
|
@@ -15255,7 +15311,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
15255
15311
|
// ~/.augmented/<codeName>/.current-turn-initiator.json. Note getAgentDir
|
|
15256
15312
|
// returns the agent root (NOT the /provision subdir `agentDir` points at),
|
|
15257
15313
|
// so it byte-matches the broker readers' path.
|
|
15258
|
-
AGT_TURN_INITIATOR_FILE:
|
|
15314
|
+
AGT_TURN_INITIATOR_FILE: join35(
|
|
15259
15315
|
frameworkAdapter.getAgentDir(agent.code_name),
|
|
15260
15316
|
".current-turn-initiator.json"
|
|
15261
15317
|
)
|
|
@@ -15275,7 +15331,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
15275
15331
|
log(`Channel credentials written for '${agent.code_name}/direct-chat'`);
|
|
15276
15332
|
}
|
|
15277
15333
|
}
|
|
15278
|
-
const staleChannelsPath =
|
|
15334
|
+
const staleChannelsPath = join35(projectDir, ".mcp-channels.json");
|
|
15279
15335
|
if (existsSync15(staleChannelsPath)) {
|
|
15280
15336
|
try {
|
|
15281
15337
|
rmSync5(staleChannelsPath, { force: true });
|
|
@@ -15365,7 +15421,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
15365
15421
|
}
|
|
15366
15422
|
if (hostFlagStore().getBoolean("connectivity-probe")) {
|
|
15367
15423
|
try {
|
|
15368
|
-
const probeProjectDir =
|
|
15424
|
+
const probeProjectDir = join35(homedir17(), ".augmented", agent.code_name, "project");
|
|
15369
15425
|
let probeSet = integrations;
|
|
15370
15426
|
try {
|
|
15371
15427
|
const quarantined = await api.post("/host/agent-integrations/quarantined", { agent_id: agent.agent_id });
|
|
@@ -15411,7 +15467,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
15411
15467
|
const forceDue = attemptsLeft > 0;
|
|
15412
15468
|
let probeRan = false;
|
|
15413
15469
|
try {
|
|
15414
|
-
const probeProjectDir =
|
|
15470
|
+
const probeProjectDir = join35(homedir17(), ".augmented", agent.code_name, "project");
|
|
15415
15471
|
probeRan = await runAgentSessionToolBindProbes(agent, integrations, probeProjectDir, { forceDue });
|
|
15416
15472
|
} catch (err) {
|
|
15417
15473
|
log(`Session-tool-bind probe failed for '${agent.code_name}': ${err.message}`);
|
|
@@ -15488,8 +15544,8 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
15488
15544
|
const intHash = computeIntegrationsHash(integrations);
|
|
15489
15545
|
const prevIntHash = agentState.knownIntegrationHashes.get(agent.agent_id);
|
|
15490
15546
|
if (intHash !== prevIntHash) {
|
|
15491
|
-
const projectDir =
|
|
15492
|
-
const envIntPath =
|
|
15547
|
+
const projectDir = join35(homedir17(), ".augmented", agent.code_name, "project");
|
|
15548
|
+
const envIntPath = join35(projectDir, ".env.integrations");
|
|
15493
15549
|
let preWriteEnv;
|
|
15494
15550
|
try {
|
|
15495
15551
|
preWriteEnv = readFileSync28(envIntPath, "utf-8");
|
|
@@ -15511,7 +15567,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
15511
15567
|
}
|
|
15512
15568
|
if (fw === "claude-code" && isSessionHealthy(agent.code_name)) {
|
|
15513
15569
|
try {
|
|
15514
|
-
const projectMcpPath =
|
|
15570
|
+
const projectMcpPath = join35(projectDir, ".mcp.json");
|
|
15515
15571
|
const postWriteEnv = readFileSync28(envIntPath, "utf-8");
|
|
15516
15572
|
const mcpContent = readFileSync28(projectMcpPath, "utf-8");
|
|
15517
15573
|
const changedVars = diffEnvIntegrations(preWriteEnv, postWriteEnv);
|
|
@@ -15776,16 +15832,16 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
15776
15832
|
}
|
|
15777
15833
|
try {
|
|
15778
15834
|
const { readdirSync: readdirSync10, rmSync: rmSync6 } = await import("fs");
|
|
15779
|
-
const { homedir:
|
|
15835
|
+
const { homedir: homedir18 } = await import("os");
|
|
15780
15836
|
const frameworkId2 = frameworkAdapter.id;
|
|
15781
15837
|
const candidateSkillDirs = [
|
|
15782
15838
|
// Claude Code — framework runtime tree
|
|
15783
|
-
|
|
15839
|
+
join35(homedir18(), ".augmented", agent.code_name, "skills"),
|
|
15784
15840
|
// Claude Code — project tree
|
|
15785
|
-
|
|
15841
|
+
join35(homedir18(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
15786
15842
|
// Defensive: legacy provision-side path, not currently an
|
|
15787
15843
|
// install target but cheap to sweep.
|
|
15788
|
-
|
|
15844
|
+
join35(agentDir, ".claude", "skills")
|
|
15789
15845
|
];
|
|
15790
15846
|
const existingDirs = candidateSkillDirs.filter((d) => existsSync15(d));
|
|
15791
15847
|
const discoveredEntries = /* @__PURE__ */ new Set();
|
|
@@ -15826,7 +15882,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
15826
15882
|
const sharedSkillsPayload = refreshAny.shared_skills;
|
|
15827
15883
|
const desiredResolved = globalSkillsPayload !== void 0 || sharedSkillsPayload !== void 0;
|
|
15828
15884
|
const manifestPath = managedSkillManifestPath(
|
|
15829
|
-
|
|
15885
|
+
join35(homedir17(), ".augmented", agent.code_name)
|
|
15830
15886
|
);
|
|
15831
15887
|
const prevIds = /* @__PURE__ */ new Set([
|
|
15832
15888
|
...agentState.knownGlobalSkillIds.get(agent.agent_id) ?? /* @__PURE__ */ new Set(),
|
|
@@ -15846,15 +15902,15 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
15846
15902
|
}
|
|
15847
15903
|
if (plan.removes.length) {
|
|
15848
15904
|
const globalSkillDirs = [
|
|
15849
|
-
|
|
15850
|
-
|
|
15851
|
-
|
|
15905
|
+
join35(homedir17(), ".augmented", agent.code_name, "skills"),
|
|
15906
|
+
join35(homedir17(), ".augmented", agent.code_name, "project", ".claude", "skills"),
|
|
15907
|
+
join35(agentDir, ".claude", "skills")
|
|
15852
15908
|
];
|
|
15853
15909
|
for (const id of plan.removes) {
|
|
15854
15910
|
let prunedAny = false;
|
|
15855
15911
|
for (const dir of globalSkillDirs) {
|
|
15856
|
-
const p =
|
|
15857
|
-
if (existsSync15(p) && existsSync15(
|
|
15912
|
+
const p = join35(dir, id);
|
|
15913
|
+
if (existsSync15(p) && existsSync15(join35(p, "SKILL.md"))) {
|
|
15858
15914
|
rmSync5(p, { recursive: true, force: true });
|
|
15859
15915
|
prunedAny = true;
|
|
15860
15916
|
}
|
|
@@ -16086,7 +16142,7 @@ async function processAgent(agent, agentStates, managedToolkits) {
|
|
|
16086
16142
|
const sess = getSessionState(agent.code_name);
|
|
16087
16143
|
let mcpJsonParsed = null;
|
|
16088
16144
|
try {
|
|
16089
|
-
const mcpPath =
|
|
16145
|
+
const mcpPath = join35(getProjectDir(agent.code_name), ".mcp.json");
|
|
16090
16146
|
mcpJsonParsed = JSON.parse(readFileSync28(mcpPath, "utf-8"));
|
|
16091
16147
|
} catch {
|
|
16092
16148
|
}
|
|
@@ -16521,7 +16577,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
|
|
|
16521
16577
|
if (trackedFiles.length > 0 && existsSync15(agentDir)) {
|
|
16522
16578
|
const hashes = /* @__PURE__ */ new Map();
|
|
16523
16579
|
for (const file of trackedFiles) {
|
|
16524
|
-
const h = hashFile(
|
|
16580
|
+
const h = hashFile(join35(agentDir, file));
|
|
16525
16581
|
if (h) hashes.set(file, h);
|
|
16526
16582
|
}
|
|
16527
16583
|
agentState.writtenHashes.set(agent.agent_id, hashes);
|
|
@@ -16536,7 +16592,7 @@ Retried to the limit after repeated stalls \u2014 needs a look.`).catch(() => {
|
|
|
16536
16592
|
refreshData.agent.onboarding_state
|
|
16537
16593
|
);
|
|
16538
16594
|
const obStep = obState.step;
|
|
16539
|
-
const markerPath =
|
|
16595
|
+
const markerPath = join35(homedir17(), ".augmented", agent.code_name, "onboarding-drive.json");
|
|
16540
16596
|
const marker = readOnboardingDriveMarker(markerPath);
|
|
16541
16597
|
const obContactRaw = refreshData.agent.manager_last_contacted_at;
|
|
16542
16598
|
const obContact = typeof obContactRaw === "string" && obContactRaw ? obContactRaw : null;
|
|
@@ -16638,7 +16694,7 @@ async function ensureOpencodeRuntime(agent, refreshData, agentTimezone) {
|
|
|
16638
16694
|
}
|
|
16639
16695
|
stopOpencodeSlackIngest(codeName, log);
|
|
16640
16696
|
stopOpencodeTelegramIngest(codeName, log);
|
|
16641
|
-
const opencodeProjectDir =
|
|
16697
|
+
const opencodeProjectDir = join35(getFramework("opencode").getAgentDir(codeName), "provision");
|
|
16642
16698
|
const serveEnv = {
|
|
16643
16699
|
AGT_HOST: requireHost(),
|
|
16644
16700
|
AGT_API_KEY: getApiKey() ?? void 0,
|
|
@@ -16693,8 +16749,8 @@ async function ensurePersistentSession(agent, tasks, boardItems, refreshData) {
|
|
|
16693
16749
|
});
|
|
16694
16750
|
}
|
|
16695
16751
|
const projectDir = getProjectDir(codeName);
|
|
16696
|
-
const mcpConfigPath =
|
|
16697
|
-
const claudeMdPath =
|
|
16752
|
+
const mcpConfigPath = join35(projectDir, ".mcp.json");
|
|
16753
|
+
const claudeMdPath = join35(projectDir, "CLAUDE.md");
|
|
16698
16754
|
if (restartBreaker.isTripped(codeName)) {
|
|
16699
16755
|
const trip = restartBreaker.getTrip(codeName);
|
|
16700
16756
|
return {
|
|
@@ -16704,6 +16760,21 @@ async function ensurePersistentSession(agent, tasks, boardItems, refreshData) {
|
|
|
16704
16760
|
detail: trip.statusMessage
|
|
16705
16761
|
};
|
|
16706
16762
|
}
|
|
16763
|
+
if ((agentFrameworkCache.get(codeName) ?? DEFAULT_FRAMEWORK) === "claude-code" && !isSessionHealthy(codeName)) {
|
|
16764
|
+
const missingMcpBundles = findMissingMcpBundles(mcpConfigPath);
|
|
16765
|
+
if (missingMcpBundles.length > 0) {
|
|
16766
|
+
const detail = formatMissingMcpBundles(missingMcpBundles);
|
|
16767
|
+
log(
|
|
16768
|
+
`[persistent-session] '${codeName}': deferring spawn \u2014 ${detail}. Not counted as a restart; will spawn once the host deploys them.`
|
|
16769
|
+
);
|
|
16770
|
+
return {
|
|
16771
|
+
decision: "skipped-mcp-assets-not-ready",
|
|
16772
|
+
spawnAttempted: false,
|
|
16773
|
+
sessionHealthyAfter: false,
|
|
16774
|
+
detail
|
|
16775
|
+
};
|
|
16776
|
+
}
|
|
16777
|
+
}
|
|
16707
16778
|
const teamSettingsForTz = refreshData.team?.settings;
|
|
16708
16779
|
const agentTimezone = (() => {
|
|
16709
16780
|
const ownTzRaw = refreshData.agent?.timezone;
|
|
@@ -17796,7 +17867,7 @@ async function processDirectChatMessage(agent, msg) {
|
|
|
17796
17867
|
const useDoorbell = hostFlagStore().getBoolean("direct-chat-doorbell") || isolationMode(agent.codeName) === "docker";
|
|
17797
17868
|
if (useDoorbell) {
|
|
17798
17869
|
try {
|
|
17799
|
-
const doorbell = directChatDoorbellPath(agent.agentId,
|
|
17870
|
+
const doorbell = directChatDoorbellPath(agent.agentId, homedir17());
|
|
17800
17871
|
mkdirSync11(dirname9(doorbell), { recursive: true });
|
|
17801
17872
|
writeFileSync14(doorbell, String(Date.now()));
|
|
17802
17873
|
log(`[direct-chat] Doorbell rung for '${agent.codeName}' (msg=${msg.id}) \u2014 in-session MCP will pull via the cursor`);
|
|
@@ -17925,7 +17996,7 @@ ${formatRunMarker(run_id)}` : KANBAN_CHECK_COMMAND;
|
|
|
17925
17996
|
}
|
|
17926
17997
|
if (run_id) openInjectedRunByCode.set(codeName, run_id);
|
|
17927
17998
|
try {
|
|
17928
|
-
const doorbell = directChatDoorbellPath(agentId,
|
|
17999
|
+
const doorbell = directChatDoorbellPath(agentId, homedir17());
|
|
17929
18000
|
mkdirSync11(dirname9(doorbell), { recursive: true });
|
|
17930
18001
|
writeFileSync14(doorbell, String(Date.now()));
|
|
17931
18002
|
} catch (err) {
|
|
@@ -18285,8 +18356,8 @@ function parseMemoryFile(raw, fallbackName) {
|
|
|
18285
18356
|
};
|
|
18286
18357
|
}
|
|
18287
18358
|
async function syncMemories(agent, configDir, log2) {
|
|
18288
|
-
const projectDir =
|
|
18289
|
-
const memoryDir =
|
|
18359
|
+
const projectDir = join35(configDir, agent.code_name, "project");
|
|
18360
|
+
const memoryDir = join35(projectDir, "memory");
|
|
18290
18361
|
const isFreshSync = pendingFreshMemorySync.has(agent.agent_id);
|
|
18291
18362
|
if (isFreshSync) {
|
|
18292
18363
|
log2(`[memory-sync] Fresh-sync requested for '${agent.code_name}' \u2014 pulling DB first`);
|
|
@@ -18304,7 +18375,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
18304
18375
|
for (const file of readdirSync9(memoryDir)) {
|
|
18305
18376
|
if (!file.endsWith(".md")) continue;
|
|
18306
18377
|
try {
|
|
18307
|
-
const raw = readFileSync28(
|
|
18378
|
+
const raw = readFileSync28(join35(memoryDir, file), "utf-8");
|
|
18308
18379
|
const fileHash = createHash17("sha256").update(raw).digest("hex").slice(0, 16);
|
|
18309
18380
|
currentHashes.set(file, fileHash);
|
|
18310
18381
|
if (prevHashes.get(file) === fileHash) continue;
|
|
@@ -18329,7 +18400,7 @@ async function syncMemories(agent, configDir, log2) {
|
|
|
18329
18400
|
} catch (err) {
|
|
18330
18401
|
for (const mem of changedMemories) {
|
|
18331
18402
|
for (const [file] of currentHashes) {
|
|
18332
|
-
const parsed = parseMemoryFile(readFileSync28(
|
|
18403
|
+
const parsed = parseMemoryFile(readFileSync28(join35(memoryDir, file), "utf-8"), file.replace(/\.md$/, ""));
|
|
18333
18404
|
if (parsed?.name === mem.name) currentHashes.delete(file);
|
|
18334
18405
|
}
|
|
18335
18406
|
}
|
|
@@ -18364,7 +18435,7 @@ async function downloadMemories(agent, memoryDir, log2, { force }) {
|
|
|
18364
18435
|
const mem = dbMemories.memories[i];
|
|
18365
18436
|
const rawSlug = mem.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 60);
|
|
18366
18437
|
const slug = rawSlug || `memory-${i}`;
|
|
18367
|
-
const filePath =
|
|
18438
|
+
const filePath = join35(memoryDir, `${slug}.md`);
|
|
18368
18439
|
const desired = `---
|
|
18369
18440
|
name: ${JSON.stringify(mem.name)}
|
|
18370
18441
|
type: ${mem.type}
|
|
@@ -18538,7 +18609,7 @@ async function reportSelfUpdateRestarts() {
|
|
|
18538
18609
|
});
|
|
18539
18610
|
})
|
|
18540
18611
|
).then(() => void 0);
|
|
18541
|
-
const deadline = new Promise((
|
|
18612
|
+
const deadline = new Promise((resolve2) => setTimeout(resolve2, 3e3));
|
|
18542
18613
|
await Promise.race([posts, deadline]);
|
|
18543
18614
|
}
|
|
18544
18615
|
function scheduleNext() {
|
|
@@ -18672,7 +18743,7 @@ function startManager(opts) {
|
|
|
18672
18743
|
log(`[startup] state rehydration failed (continuing with empty state): ${err.message}`);
|
|
18673
18744
|
}
|
|
18674
18745
|
log(
|
|
18675
|
-
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${
|
|
18746
|
+
`[startup] worker pid=${process.pid} ppid=${process.ppid} node=${process.version} log=${join35(homedir17(), ".augmented", "manager.log")}`
|
|
18676
18747
|
);
|
|
18677
18748
|
deployMcpAssets();
|
|
18678
18749
|
reapOrphanChannelMcps({ log });
|
|
@@ -18798,14 +18869,14 @@ function restartRunningChannelMcps(basenames) {
|
|
|
18798
18869
|
}
|
|
18799
18870
|
}
|
|
18800
18871
|
function deployMcpAssets() {
|
|
18801
|
-
const targetDir =
|
|
18872
|
+
const targetDir = join35(homedir17(), ".augmented", "_mcp");
|
|
18802
18873
|
mkdirSync11(targetDir, { recursive: true });
|
|
18803
18874
|
const moduleDir = dirname9(fileURLToPath(import.meta.url));
|
|
18804
18875
|
let mcpSourceDir = "";
|
|
18805
18876
|
let dir = moduleDir;
|
|
18806
18877
|
for (let i = 0; i < 6; i++) {
|
|
18807
|
-
const candidate =
|
|
18808
|
-
if (existsSync15(
|
|
18878
|
+
const candidate = join35(dir, "dist", "mcp");
|
|
18879
|
+
if (existsSync15(join35(candidate, "index.js"))) {
|
|
18809
18880
|
mcpSourceDir = candidate;
|
|
18810
18881
|
break;
|
|
18811
18882
|
}
|
|
@@ -18818,6 +18889,8 @@ function deployMcpAssets() {
|
|
|
18818
18889
|
return;
|
|
18819
18890
|
}
|
|
18820
18891
|
const changedBasenames = [];
|
|
18892
|
+
const attemptedFiles = [];
|
|
18893
|
+
const failedFiles = [];
|
|
18821
18894
|
const fileHash = (p) => {
|
|
18822
18895
|
try {
|
|
18823
18896
|
if (!existsSync15(p)) return null;
|
|
@@ -18892,9 +18965,10 @@ function deployMcpAssets() {
|
|
|
18892
18965
|
// needs restarting to pick up a token rotation.
|
|
18893
18966
|
"xero.js"
|
|
18894
18967
|
]) {
|
|
18895
|
-
const src =
|
|
18896
|
-
const dst =
|
|
18968
|
+
const src = join35(mcpSourceDir, file);
|
|
18969
|
+
const dst = join35(targetDir, file);
|
|
18897
18970
|
if (!existsSync15(src)) continue;
|
|
18971
|
+
attemptedFiles.push(file);
|
|
18898
18972
|
const before = fileHash(dst);
|
|
18899
18973
|
try {
|
|
18900
18974
|
copyFileSync(src, dst);
|
|
@@ -18903,22 +18977,29 @@ function deployMcpAssets() {
|
|
|
18903
18977
|
changedBasenames.push(file.replace(/\.js$/, ""));
|
|
18904
18978
|
}
|
|
18905
18979
|
} catch (err) {
|
|
18980
|
+
failedFiles.push(file);
|
|
18906
18981
|
log(`[manager] Failed to deploy ${file}: ${err.message}`);
|
|
18907
18982
|
}
|
|
18908
18983
|
}
|
|
18909
|
-
|
|
18984
|
+
if (failedFiles.length > 0) {
|
|
18985
|
+
log(
|
|
18986
|
+
`[manager] MCP asset deployment INCOMPLETE for ${targetDir} \u2014 ${failedFiles.length}/${attemptedFiles.length} bundle(s) failed to copy: ${failedFiles.join(", ")}. Agents declaring these bundles will be held out of spawn (ENG-9125) until this succeeds. A read-only target directory is the usual cause.`
|
|
18987
|
+
);
|
|
18988
|
+
} else {
|
|
18989
|
+
log(`[manager] MCP assets deployed to ${targetDir} (${attemptedFiles.length} bundle(s))`);
|
|
18990
|
+
}
|
|
18910
18991
|
if (changedBasenames.length > 0) {
|
|
18911
18992
|
log(`[manager] Bundle(s) updated: ${changedBasenames.join(", ")} \u2014 signalling running instances to restart`);
|
|
18912
18993
|
restartRunningChannelMcps(changedBasenames);
|
|
18913
18994
|
}
|
|
18914
|
-
const localMcpPath =
|
|
18995
|
+
const localMcpPath = join35(targetDir, "index.js");
|
|
18915
18996
|
try {
|
|
18916
|
-
const agentsDir =
|
|
18997
|
+
const agentsDir = join35(homedir17(), ".augmented", "agents");
|
|
18917
18998
|
if (existsSync15(agentsDir)) {
|
|
18918
18999
|
for (const entry of readdirSync9(agentsDir, { withFileTypes: true })) {
|
|
18919
19000
|
if (!entry.isDirectory()) continue;
|
|
18920
19001
|
for (const subdir of ["provision", "project"]) {
|
|
18921
|
-
const mcpJsonPath =
|
|
19002
|
+
const mcpJsonPath = join35(agentsDir, entry.name, subdir, ".mcp.json");
|
|
18922
19003
|
try {
|
|
18923
19004
|
const raw = readFileSync28(mcpJsonPath, "utf-8");
|
|
18924
19005
|
if (!raw.includes("@integrity-labs/augmented-mcp")) continue;
|