@integrity-labs/agt-cli 0.28.1260 → 0.28.1261
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.
- package/dist/{api-client-PXVHBJBB.js → api-client-2YLFNHFZ.js} +3 -3
- package/dist/bin/agt.js +7 -7
- package/dist/{chunk-UKZ3NXB7.js → chunk-335HKIDZ.js} +2 -2
- package/dist/{chunk-7EEU3X3T.js → chunk-6NHFZYUP.js} +3 -3
- package/dist/{chunk-E7DKUEXC.js → chunk-I2NQQOMD.js} +3 -3
- package/dist/{chunk-LLVL6LIB.js → chunk-JYSPPCHG.js} +2 -2
- package/dist/{chunk-UQLSI3C7.js → chunk-QFLR5EFT.js} +97 -5
- package/dist/chunk-QFLR5EFT.js.map +1 -0
- package/dist/{chunk-NABJJPLW.js → chunk-ZEJUBTXJ.js} +441 -254
- package/dist/chunk-ZEJUBTXJ.js.map +1 -0
- package/dist/{claude-code-updater-OXTQF5E5.js → claude-code-updater-B2BWPRFE.js} +3 -3
- package/dist/{claude-pair-runtime-BBOAF76W.js → claude-pair-runtime-FNDHAPXR.js} +3 -3
- package/dist/lib/manager-worker.js +580 -427
- package/dist/lib/manager-worker.js.map +1 -1
- package/dist/mcp/direct-chat-channel.js +93 -1
- package/dist/mcp/index.js +93 -1
- package/dist/mcp/origami.js +93 -1
- package/dist/mcp/slack-channel.js +93 -1
- package/dist/mcp/telegram-channel.js +93 -1
- package/dist/{persistent-session-XPDKIBEM.js → persistent-session-LHQLLU4U.js} +4 -4
- package/dist/{responsiveness-probe-4B6Y2446.js → responsiveness-probe-KDSNPKUY.js} +4 -4
- package/dist/{session-auth-dead-4C7AK3A6.js → session-auth-dead-3IHR4M2B.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-NABJJPLW.js.map +0 -1
- package/dist/chunk-UQLSI3C7.js.map +0 -1
- /package/dist/{api-client-PXVHBJBB.js.map → api-client-2YLFNHFZ.js.map} +0 -0
- /package/dist/{chunk-UKZ3NXB7.js.map → chunk-335HKIDZ.js.map} +0 -0
- /package/dist/{chunk-7EEU3X3T.js.map → chunk-6NHFZYUP.js.map} +0 -0
- /package/dist/{chunk-E7DKUEXC.js.map → chunk-I2NQQOMD.js.map} +0 -0
- /package/dist/{chunk-LLVL6LIB.js.map → chunk-JYSPPCHG.js.map} +0 -0
- /package/dist/{claude-code-updater-OXTQF5E5.js.map → claude-code-updater-B2BWPRFE.js.map} +0 -0
- /package/dist/{claude-pair-runtime-BBOAF76W.js.map → claude-pair-runtime-FNDHAPXR.js.map} +0 -0
- /package/dist/{persistent-session-XPDKIBEM.js.map → persistent-session-LHQLLU4U.js.map} +0 -0
- /package/dist/{responsiveness-probe-4B6Y2446.js.map → responsiveness-probe-KDSNPKUY.js.map} +0 -0
- /package/dist/{session-auth-dead-4C7AK3A6.js.map → session-auth-dead-3IHR4M2B.js.map} +0 -0
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
exchangeApiKey,
|
|
3
3
|
getApiKey,
|
|
4
4
|
getHost
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-6NHFZYUP.js";
|
|
6
6
|
import {
|
|
7
7
|
LATE_BOUND_VARS,
|
|
8
8
|
PLATFORM_DENY_PERMISSIONS,
|
|
@@ -25,11 +25,11 @@ import {
|
|
|
25
25
|
shellQuote,
|
|
26
26
|
withheldRemoteMcpMessage,
|
|
27
27
|
withheldRemoteMcpReasonFor
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-I2NQQOMD.js";
|
|
29
29
|
import {
|
|
30
30
|
readDailySessionPin,
|
|
31
31
|
sessionTranscriptDir
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-JYSPPCHG.js";
|
|
33
33
|
import {
|
|
34
34
|
classifyUnanswerablePane,
|
|
35
35
|
isConsumerTermsDialogVisible,
|
|
@@ -101,7 +101,7 @@ import {
|
|
|
101
101
|
scanConfigForLiteralSecrets,
|
|
102
102
|
worseConnectivityOutcome,
|
|
103
103
|
wrapScheduledTaskPrompt
|
|
104
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-QFLR5EFT.js";
|
|
105
105
|
import {
|
|
106
106
|
claudeJsonPathFor,
|
|
107
107
|
effectiveClaudeJsonPath,
|
|
@@ -1148,15 +1148,152 @@ function orderTitlesForDescription(entries) {
|
|
|
1148
1148
|
}
|
|
1149
1149
|
|
|
1150
1150
|
// ../../packages/core/dist/provisioning/frameworks/claudecode/index.js
|
|
1151
|
-
import { readFileSync as readFileSync5, writeFileSync as writeFileSync5, mkdirSync as mkdirSync4, existsSync as existsSync4, chmodSync as chmodSync4, readdirSync, rmSync as rmSync2, copyFileSync, lstatSync, realpathSync, symlinkSync, readlinkSync, renameSync as renameSync4, opendirSync } from "fs";
|
|
1152
|
-
import { join as
|
|
1151
|
+
import { readFileSync as readFileSync5, writeFileSync as writeFileSync5, mkdirSync as mkdirSync4, existsSync as existsSync4, chmodSync as chmodSync4, readdirSync, rmSync as rmSync2, copyFileSync, lstatSync as lstatSync2, realpathSync as realpathSync2, symlinkSync, readlinkSync as readlinkSync2, renameSync as renameSync4, opendirSync as opendirSync2 } from "fs";
|
|
1152
|
+
import { join as join6, relative as relative2, dirname as dirname3 } from "path";
|
|
1153
|
+
|
|
1154
|
+
// ../../packages/core/dist/provisioning/frameworks/claudecode/scratch-file-sweep.js
|
|
1155
|
+
import { closeSync, constants, lstatSync, openSync, opendirSync, readlinkSync, realpathSync, rmdirSync, unlinkSync as unlinkSync2 } from "fs";
|
|
1156
|
+
import { join as join3, relative } from "path";
|
|
1157
|
+
var WHOLE_TREE_DIR_NAMES = /* @__PURE__ */ new Set(["node_modules", ".venv", "venv"]);
|
|
1158
|
+
var SCRATCH_FILE_SWEEP_ENTRY_BUDGET = 2e5;
|
|
1159
|
+
var lastChange = (s) => Math.max(s.mtimeMs, s.ctimeMs);
|
|
1160
|
+
function sweepScratchFiles(scratchDir, opts) {
|
|
1161
|
+
const result = { files: 0, bytes: 0, emptyDirs: 0, wholeTreesKept: 0, truncated: false };
|
|
1162
|
+
let budget = opts.entryBudget ?? SCRATCH_FILE_SWEEP_ENTRY_BUDGET;
|
|
1163
|
+
let realScratch;
|
|
1164
|
+
try {
|
|
1165
|
+
if (!lstatSync(scratchDir).isDirectory())
|
|
1166
|
+
return result;
|
|
1167
|
+
realScratch = realpathSync(scratchDir);
|
|
1168
|
+
} catch {
|
|
1169
|
+
return result;
|
|
1170
|
+
}
|
|
1171
|
+
const placeInScratch = (dir) => join3(realScratch, relative(scratchDir, dir));
|
|
1172
|
+
const stillInside = (dir) => {
|
|
1173
|
+
try {
|
|
1174
|
+
return realpathSync(dir) === placeInScratch(dir);
|
|
1175
|
+
} catch {
|
|
1176
|
+
return false;
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1179
|
+
const removeFrom = (dir, name, remove) => {
|
|
1180
|
+
if (!opts.remove)
|
|
1181
|
+
return stillInside(dir);
|
|
1182
|
+
let fd;
|
|
1183
|
+
try {
|
|
1184
|
+
fd = openSync(dir, constants.O_RDONLY | constants.O_DIRECTORY);
|
|
1185
|
+
} catch {
|
|
1186
|
+
return false;
|
|
1187
|
+
}
|
|
1188
|
+
try {
|
|
1189
|
+
const pinned = `/proc/self/fd/${fd}`;
|
|
1190
|
+
let actual;
|
|
1191
|
+
try {
|
|
1192
|
+
actual = readlinkSync(pinned);
|
|
1193
|
+
} catch {
|
|
1194
|
+
return false;
|
|
1195
|
+
}
|
|
1196
|
+
if (actual !== placeInScratch(dir))
|
|
1197
|
+
return false;
|
|
1198
|
+
opts.beforeRemove?.(join3(dir, name));
|
|
1199
|
+
remove(join3(pinned, name));
|
|
1200
|
+
return true;
|
|
1201
|
+
} finally {
|
|
1202
|
+
closeSync(fd);
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
const childrenOf = (dir) => {
|
|
1206
|
+
try {
|
|
1207
|
+
const handle = opendirSync(dir);
|
|
1208
|
+
const names = [];
|
|
1209
|
+
try {
|
|
1210
|
+
for (let entry = handle.readSync(); entry !== null; entry = handle.readSync()) {
|
|
1211
|
+
if (names.length >= budget) {
|
|
1212
|
+
result.truncated = true;
|
|
1213
|
+
break;
|
|
1214
|
+
}
|
|
1215
|
+
names.push(entry.name);
|
|
1216
|
+
}
|
|
1217
|
+
} finally {
|
|
1218
|
+
handle.closeSync();
|
|
1219
|
+
}
|
|
1220
|
+
return names;
|
|
1221
|
+
} catch {
|
|
1222
|
+
return null;
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1225
|
+
const walk = (dir) => {
|
|
1226
|
+
opts.beforeCheck?.(dir);
|
|
1227
|
+
if (!stillInside(dir))
|
|
1228
|
+
return 1;
|
|
1229
|
+
const names = childrenOf(dir);
|
|
1230
|
+
if (names === null)
|
|
1231
|
+
return 1;
|
|
1232
|
+
let left = names.length;
|
|
1233
|
+
if (names.includes(".git") || names.includes("pyvenv.cfg") || names.includes("HEAD") && names.includes("objects")) {
|
|
1234
|
+
result.wholeTreesKept += 1;
|
|
1235
|
+
return left || 1;
|
|
1236
|
+
}
|
|
1237
|
+
for (const name of names) {
|
|
1238
|
+
if (result.truncated || budget-- <= 0) {
|
|
1239
|
+
result.truncated = true;
|
|
1240
|
+
return left || 1;
|
|
1241
|
+
}
|
|
1242
|
+
const full = join3(dir, name);
|
|
1243
|
+
let stat;
|
|
1244
|
+
try {
|
|
1245
|
+
stat = lstatSync(full);
|
|
1246
|
+
} catch {
|
|
1247
|
+
continue;
|
|
1248
|
+
}
|
|
1249
|
+
if (!stat.isDirectory()) {
|
|
1250
|
+
if (lastChange(stat) >= opts.cutoff)
|
|
1251
|
+
continue;
|
|
1252
|
+
try {
|
|
1253
|
+
opts.beforeCheck?.(full);
|
|
1254
|
+
if (!removeFrom(dir, name, unlinkSync2))
|
|
1255
|
+
return left || 1;
|
|
1256
|
+
result.files += 1;
|
|
1257
|
+
result.bytes += stat.size;
|
|
1258
|
+
left -= 1;
|
|
1259
|
+
} catch {
|
|
1260
|
+
}
|
|
1261
|
+
continue;
|
|
1262
|
+
}
|
|
1263
|
+
if (WHOLE_TREE_DIR_NAMES.has(name)) {
|
|
1264
|
+
result.wholeTreesKept += 1;
|
|
1265
|
+
continue;
|
|
1266
|
+
}
|
|
1267
|
+
const removedBefore = result.files + result.emptyDirs;
|
|
1268
|
+
if (walk(full) > 0)
|
|
1269
|
+
continue;
|
|
1270
|
+
if (result.files + result.emptyDirs > removedBefore)
|
|
1271
|
+
continue;
|
|
1272
|
+
if (lastChange(stat) >= opts.cutoff)
|
|
1273
|
+
continue;
|
|
1274
|
+
try {
|
|
1275
|
+
opts.beforeCheck?.(full);
|
|
1276
|
+
if (!removeFrom(dir, name, rmdirSync))
|
|
1277
|
+
return left || 1;
|
|
1278
|
+
result.emptyDirs += 1;
|
|
1279
|
+
left -= 1;
|
|
1280
|
+
} catch {
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
return left;
|
|
1284
|
+
};
|
|
1285
|
+
walk(scratchDir);
|
|
1286
|
+
return result;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
// ../../packages/core/dist/provisioning/frameworks/claudecode/index.js
|
|
1153
1290
|
import { homedir as homedir3, tmpdir } from "os";
|
|
1154
1291
|
import { execFile } from "child_process";
|
|
1155
1292
|
|
|
1156
1293
|
// ../../packages/core/dist/integrations/xurl-config.js
|
|
1157
|
-
import { chmodSync as chmodSync2, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync as renameSync2, unlinkSync as
|
|
1294
|
+
import { chmodSync as chmodSync2, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync as renameSync2, unlinkSync as unlinkSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
1158
1295
|
import { homedir } from "os";
|
|
1159
|
-
import { dirname, join as
|
|
1296
|
+
import { dirname, join as join4 } from "path";
|
|
1160
1297
|
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
1161
1298
|
var XURL_FILE_MODE = 384;
|
|
1162
1299
|
var XURL_AGT_APP_PREFIX = "agt-";
|
|
@@ -1275,7 +1412,7 @@ function buildAgtXurlApps(integrations) {
|
|
|
1275
1412
|
}
|
|
1276
1413
|
function getXurlStorePath() {
|
|
1277
1414
|
const home = process.env["HOME"] ?? process.env["USERPROFILE"] ?? homedir();
|
|
1278
|
-
return
|
|
1415
|
+
return join4(home, ".xurl");
|
|
1279
1416
|
}
|
|
1280
1417
|
function writeXurlStoreForIntegrations(integrations, filePath = getXurlStorePath()) {
|
|
1281
1418
|
const agtApps = buildAgtXurlApps(integrations);
|
|
@@ -1303,7 +1440,7 @@ function writeXurlStoreForIntegrations(integrations, filePath = getXurlStorePath
|
|
|
1303
1440
|
renameSync2(tmpPath, filePath);
|
|
1304
1441
|
} catch (err) {
|
|
1305
1442
|
try {
|
|
1306
|
-
|
|
1443
|
+
unlinkSync3(tmpPath);
|
|
1307
1444
|
} catch {
|
|
1308
1445
|
}
|
|
1309
1446
|
throw err;
|
|
@@ -1316,9 +1453,9 @@ function writeXurlStoreForIntegrations(integrations, filePath = getXurlStorePath
|
|
|
1316
1453
|
}
|
|
1317
1454
|
|
|
1318
1455
|
// ../../packages/core/dist/integrations/framer-credentials.js
|
|
1319
|
-
import { chmodSync as chmodSync3, existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync3, rmSync, statSync, unlinkSync as
|
|
1456
|
+
import { chmodSync as chmodSync3, existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync3, rmSync, statSync, unlinkSync as unlinkSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
1320
1457
|
import { homedir as homedir2 } from "os";
|
|
1321
|
-
import { dirname as dirname2, join as
|
|
1458
|
+
import { dirname as dirname2, join as join5 } from "path";
|
|
1322
1459
|
var FRAMER_PROJECTS_CONFIG_VERSION = 2;
|
|
1323
1460
|
var BARE_PROJECT_ID = /^[A-Za-z0-9]{20}$/u;
|
|
1324
1461
|
var SLUGGED_PROJECT_ID = /^.+--([A-Za-z0-9]+)/u;
|
|
@@ -1417,7 +1554,7 @@ function mergeFramerProjectsConfig(existing, inputs, options = {}) {
|
|
|
1417
1554
|
var FRAMER_FILE_MODE = 384;
|
|
1418
1555
|
var MANAGED_SIDECAR_NAME = ".augmented-managed-projects.json";
|
|
1419
1556
|
function sidecarPathFor(projectsPath) {
|
|
1420
|
-
return
|
|
1557
|
+
return join5(dirname2(projectsPath), MANAGED_SIDECAR_NAME);
|
|
1421
1558
|
}
|
|
1422
1559
|
function readManagedIds(projectsPath) {
|
|
1423
1560
|
try {
|
|
@@ -1435,7 +1572,7 @@ function writeManagedIds(projectsPath, ids) {
|
|
|
1435
1572
|
try {
|
|
1436
1573
|
if (ids.length === 0) {
|
|
1437
1574
|
try {
|
|
1438
|
-
|
|
1575
|
+
unlinkSync4(target);
|
|
1439
1576
|
} catch {
|
|
1440
1577
|
}
|
|
1441
1578
|
return;
|
|
@@ -1493,9 +1630,9 @@ function asString2(value) {
|
|
|
1493
1630
|
function getFramerProjectsPath() {
|
|
1494
1631
|
const xdg = process.env["XDG_CONFIG_HOME"];
|
|
1495
1632
|
if (xdg)
|
|
1496
|
-
return
|
|
1633
|
+
return join5(xdg, "framer", "projects.json");
|
|
1497
1634
|
const home = process.env["HOME"] ?? process.env["USERPROFILE"] ?? homedir2();
|
|
1498
|
-
return
|
|
1635
|
+
return join5(home, ".config", "framer", "projects.json");
|
|
1499
1636
|
}
|
|
1500
1637
|
function buildFramerCredentialInputs(integrations) {
|
|
1501
1638
|
const inputs = [];
|
|
@@ -1545,7 +1682,7 @@ function writeFramerStoreForIntegrations(integrations, filePath = getFramerProje
|
|
|
1545
1682
|
renameSync3(tmpPath, filePath);
|
|
1546
1683
|
} catch (err) {
|
|
1547
1684
|
try {
|
|
1548
|
-
|
|
1685
|
+
unlinkSync4(tmpPath);
|
|
1549
1686
|
} catch {
|
|
1550
1687
|
}
|
|
1551
1688
|
throw err;
|
|
@@ -2355,7 +2492,7 @@ var VALID_CODE_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
|
2355
2492
|
var SECRET_FILE_MODE = 384;
|
|
2356
2493
|
function writeEnvIntegrationsForAgent(codeName, args) {
|
|
2357
2494
|
const agentDir = getAgentDir(codeName);
|
|
2358
|
-
const envPath =
|
|
2495
|
+
const envPath = join6(agentDir, ".env.integrations");
|
|
2359
2496
|
let existing = null;
|
|
2360
2497
|
try {
|
|
2361
2498
|
existing = readFileSync5(envPath, "utf-8");
|
|
@@ -2372,7 +2509,7 @@ function writeEnvIntegrationsForAgent(codeName, args) {
|
|
|
2372
2509
|
try {
|
|
2373
2510
|
const projectDir = getProjectDir2(codeName);
|
|
2374
2511
|
mkdirSync4(projectDir, { recursive: true });
|
|
2375
|
-
const dest =
|
|
2512
|
+
const dest = join6(projectDir, ".env.integrations");
|
|
2376
2513
|
writeFileSync5(dest, content, { mode: SECRET_FILE_MODE });
|
|
2377
2514
|
try {
|
|
2378
2515
|
chmodSync4(dest, SECRET_FILE_MODE);
|
|
@@ -2393,7 +2530,7 @@ var MIGRATABLE_FIELD_TO_ENV_VAR = {
|
|
|
2393
2530
|
AGT_API_KEY: "AGT_API_KEY"
|
|
2394
2531
|
};
|
|
2395
2532
|
function migrateExistingLiteralSecrets(codeName) {
|
|
2396
|
-
const mcpJsonPath =
|
|
2533
|
+
const mcpJsonPath = join6(getAgentDir(codeName), "provision", ".mcp.json");
|
|
2397
2534
|
let config;
|
|
2398
2535
|
try {
|
|
2399
2536
|
config = JSON.parse(readFileSync5(mcpJsonPath, "utf-8"));
|
|
@@ -2402,7 +2539,7 @@ function migrateExistingLiteralSecrets(codeName) {
|
|
|
2402
2539
|
}
|
|
2403
2540
|
let existingEnvKeys = /* @__PURE__ */ new Set();
|
|
2404
2541
|
try {
|
|
2405
|
-
existingEnvKeys = new Set(parseEnvFileEntries(readFileSync5(
|
|
2542
|
+
existingEnvKeys = new Set(parseEnvFileEntries(readFileSync5(join6(getAgentDir(codeName), ".env.integrations"), "utf-8")).keys());
|
|
2406
2543
|
} catch {
|
|
2407
2544
|
}
|
|
2408
2545
|
const updates = {};
|
|
@@ -2465,8 +2602,8 @@ function assertValidAgentId(agentId) {
|
|
|
2465
2602
|
}
|
|
2466
2603
|
function resolveRealAgentPath(codeNamePath) {
|
|
2467
2604
|
try {
|
|
2468
|
-
if (
|
|
2469
|
-
return
|
|
2605
|
+
if (lstatSync2(codeNamePath).isSymbolicLink()) {
|
|
2606
|
+
return realpathSync2(codeNamePath);
|
|
2470
2607
|
}
|
|
2471
2608
|
} catch {
|
|
2472
2609
|
}
|
|
@@ -2476,11 +2613,11 @@ function ensureIdKeyedLayout(codeName, agentId) {
|
|
|
2476
2613
|
assertValidCodeName(codeName);
|
|
2477
2614
|
assertValidAgentId(agentId);
|
|
2478
2615
|
const home = getHomeDir();
|
|
2479
|
-
const codeNamePath =
|
|
2480
|
-
const idPath =
|
|
2616
|
+
const codeNamePath = join6(home, ".augmented", codeName);
|
|
2617
|
+
const idPath = join6(home, ".augmented", agentId);
|
|
2481
2618
|
let state;
|
|
2482
2619
|
try {
|
|
2483
|
-
state =
|
|
2620
|
+
state = lstatSync2(codeNamePath).isSymbolicLink() ? "symlink" : "realdir";
|
|
2484
2621
|
} catch {
|
|
2485
2622
|
state = "absent";
|
|
2486
2623
|
}
|
|
@@ -2488,7 +2625,7 @@ function ensureIdKeyedLayout(codeName, agentId) {
|
|
|
2488
2625
|
return codeNamePath;
|
|
2489
2626
|
}
|
|
2490
2627
|
if (state === "symlink") {
|
|
2491
|
-
const target =
|
|
2628
|
+
const target = readlinkSync2(codeNamePath);
|
|
2492
2629
|
if (target !== agentId) {
|
|
2493
2630
|
throw new Error(`Codename symlink ${codeNamePath} points at "${target}", expected "${agentId}"; refusing to provision over a mismatched id-keyed layout.`);
|
|
2494
2631
|
}
|
|
@@ -2500,18 +2637,18 @@ function ensureIdKeyedLayout(codeName, agentId) {
|
|
|
2500
2637
|
return idPath;
|
|
2501
2638
|
}
|
|
2502
2639
|
function stagedMigrationLinkPath(home, codeName) {
|
|
2503
|
-
return
|
|
2640
|
+
return join6(home, ".augmented", `.${codeName}.migrating`);
|
|
2504
2641
|
}
|
|
2505
2642
|
function cleanupStaleStagedLink(staged) {
|
|
2506
2643
|
try {
|
|
2507
|
-
if (
|
|
2644
|
+
if (lstatSync2(staged).isSymbolicLink())
|
|
2508
2645
|
rmSync2(staged, { force: true });
|
|
2509
2646
|
} catch {
|
|
2510
2647
|
}
|
|
2511
2648
|
}
|
|
2512
2649
|
function isSymlinkTo(path, target) {
|
|
2513
2650
|
try {
|
|
2514
|
-
return
|
|
2651
|
+
return lstatSync2(path).isSymbolicLink() && readlinkSync2(path) === target;
|
|
2515
2652
|
} catch {
|
|
2516
2653
|
return false;
|
|
2517
2654
|
}
|
|
@@ -2520,18 +2657,18 @@ function migrateAgentDirToIdKeyed(codeName, agentId, opts = {}) {
|
|
|
2520
2657
|
assertValidCodeName(codeName);
|
|
2521
2658
|
assertValidAgentId(agentId);
|
|
2522
2659
|
const home = opts.home ?? getHomeDir();
|
|
2523
|
-
const codeNamePath =
|
|
2524
|
-
const idPath =
|
|
2660
|
+
const codeNamePath = join6(home, ".augmented", codeName);
|
|
2661
|
+
const idPath = join6(home, ".augmented", agentId);
|
|
2525
2662
|
const staged = stagedMigrationLinkPath(home, codeName);
|
|
2526
2663
|
let codeNameKind;
|
|
2527
2664
|
try {
|
|
2528
|
-
codeNameKind =
|
|
2665
|
+
codeNameKind = lstatSync2(codeNamePath).isSymbolicLink() ? "symlink" : "realdir";
|
|
2529
2666
|
} catch {
|
|
2530
2667
|
codeNameKind = "absent";
|
|
2531
2668
|
}
|
|
2532
2669
|
const idExists = existsSync4(idPath);
|
|
2533
2670
|
if (codeNameKind === "symlink") {
|
|
2534
|
-
const target =
|
|
2671
|
+
const target = readlinkSync2(codeNamePath);
|
|
2535
2672
|
if (target !== agentId) {
|
|
2536
2673
|
throw new Error(`Codename symlink ${codeNamePath} points at "${target}", expected "${agentId}"; refusing to migrate.`);
|
|
2537
2674
|
}
|
|
@@ -2559,14 +2696,14 @@ function migrateAgentDirToIdKeyed(codeName, agentId, opts = {}) {
|
|
|
2559
2696
|
}
|
|
2560
2697
|
function getAgentDir(codeName) {
|
|
2561
2698
|
assertValidCodeName(codeName);
|
|
2562
|
-
return resolveRealAgentPath(
|
|
2699
|
+
return resolveRealAgentPath(join6(getHomeDir(), ".augmented", codeName));
|
|
2563
2700
|
}
|
|
2564
2701
|
var migratedCodeNames = /* @__PURE__ */ new Set();
|
|
2565
2702
|
function migrateLegacyClaudecodeDir(codeName, log2) {
|
|
2566
2703
|
assertValidCodeName(codeName);
|
|
2567
2704
|
if (migratedCodeNames.has(codeName))
|
|
2568
2705
|
return;
|
|
2569
|
-
const legacyRoot =
|
|
2706
|
+
const legacyRoot = join6(getHomeDir(), ".augmented", codeName, "claudecode");
|
|
2570
2707
|
if (!existsSync4(legacyRoot)) {
|
|
2571
2708
|
migratedCodeNames.add(codeName);
|
|
2572
2709
|
return;
|
|
@@ -2579,8 +2716,8 @@ function migrateLegacyClaudecodeDir(codeName, log2) {
|
|
|
2579
2716
|
const walkAndMigrate = (srcDir, destDir) => {
|
|
2580
2717
|
mkdirSync4(destDir, { recursive: true });
|
|
2581
2718
|
for (const entry of readdirSync(srcDir, { withFileTypes: true })) {
|
|
2582
|
-
const src =
|
|
2583
|
-
const dest =
|
|
2719
|
+
const src = join6(srcDir, entry.name);
|
|
2720
|
+
const dest = join6(destDir, entry.name);
|
|
2584
2721
|
if (entry.isDirectory()) {
|
|
2585
2722
|
walkAndMigrate(src, dest);
|
|
2586
2723
|
continue;
|
|
@@ -2620,13 +2757,13 @@ function migrateLegacyClaudecodeDir(codeName, log2) {
|
|
|
2620
2757
|
}
|
|
2621
2758
|
}
|
|
2622
2759
|
function syncGitHubBrokerCredentialTooling(projectDir, enabled) {
|
|
2623
|
-
const binDir =
|
|
2760
|
+
const binDir = join6(projectDir, GITHUB_BROKER_BIN_DIR);
|
|
2624
2761
|
if (!enabled) {
|
|
2625
2762
|
rmSync2(binDir, { recursive: true, force: true });
|
|
2626
2763
|
return {};
|
|
2627
2764
|
}
|
|
2628
|
-
const helperPath =
|
|
2629
|
-
const shimPath =
|
|
2765
|
+
const helperPath = join6(binDir, GIT_CREDENTIAL_HELPER_BASENAME);
|
|
2766
|
+
const shimPath = join6(binDir, GH_SHIM_BASENAME);
|
|
2630
2767
|
mkdirSync4(binDir, { recursive: true });
|
|
2631
2768
|
writeFileSync5(helperPath, renderGitCredentialHelper(), { mode: BROKER_SCRIPT_MODE });
|
|
2632
2769
|
chmodSync4(helperPath, BROKER_SCRIPT_MODE);
|
|
@@ -2635,10 +2772,10 @@ function syncGitHubBrokerCredentialTooling(projectDir, enabled) {
|
|
|
2635
2772
|
return buildGitCredentialEnv(helperPath);
|
|
2636
2773
|
}
|
|
2637
2774
|
function getProjectDir2(codeName) {
|
|
2638
|
-
return
|
|
2775
|
+
return join6(getAgentDir(codeName), "project");
|
|
2639
2776
|
}
|
|
2640
2777
|
function reapLegacyTokenFile(codeName, onWarn = void 0) {
|
|
2641
|
-
const tokenFilePath =
|
|
2778
|
+
const tokenFilePath = join6(getAgentDir(codeName), ".tokens.json");
|
|
2642
2779
|
try {
|
|
2643
2780
|
rmSync2(tokenFilePath, { force: true });
|
|
2644
2781
|
return true;
|
|
@@ -2648,13 +2785,42 @@ function reapLegacyTokenFile(codeName, onWarn = void 0) {
|
|
|
2648
2785
|
}
|
|
2649
2786
|
}
|
|
2650
2787
|
function getScratchDir(codeName) {
|
|
2651
|
-
return
|
|
2788
|
+
return join6(getAgentDir(codeName), "scratch");
|
|
2652
2789
|
}
|
|
2653
2790
|
function getAgentTmpDir(codeName) {
|
|
2654
2791
|
return agentTmpDirFor(getAgentDir(codeName));
|
|
2655
2792
|
}
|
|
2656
|
-
|
|
2793
|
+
var TREE_RULE_ONLY = { held: false, perFile: false, dryRun: false };
|
|
2794
|
+
var scratchSweepPolicyResolver = () => TREE_RULE_ONLY;
|
|
2795
|
+
function setScratchSweepPolicyResolver(resolver) {
|
|
2796
|
+
scratchSweepPolicyResolver = resolver;
|
|
2797
|
+
}
|
|
2798
|
+
var SCRATCH_FILE_SWEEP_INTERVAL_MS = 60 * 60 * 1e3;
|
|
2799
|
+
var SCRATCH_DRY_RUN_INTERVAL_MS = 6 * 60 * 60 * 1e3;
|
|
2800
|
+
var lastFileSweepAt = /* @__PURE__ */ new Map();
|
|
2801
|
+
function runScratchFileSweep(codeName, now, cutoff, remove) {
|
|
2802
|
+
const last = lastFileSweepAt.get(codeName);
|
|
2803
|
+
if (last !== void 0 && now - last < (remove ? SCRATCH_FILE_SWEEP_INTERVAL_MS : SCRATCH_DRY_RUN_INTERVAL_MS))
|
|
2804
|
+
return 0;
|
|
2805
|
+
lastFileSweepAt.set(codeName, now);
|
|
2806
|
+
const r = sweepScratchFiles(getScratchDir(codeName), { cutoff, remove });
|
|
2807
|
+
process.stderr.write(`[scratch] [${remove ? "sweep-per-file" : "sweep-dry-run"}] agent=${codeName} ${remove ? "removed" : "would_remove"}_files=${r.files} ${remove ? "removed" : "would_remove"}_bytes=${r.bytes} empty_dirs=${r.emptyDirs} whole_trees_kept=${r.wholeTreesKept} truncated=${r.truncated}
|
|
2808
|
+
`);
|
|
2809
|
+
return remove ? r.files + r.emptyDirs : 0;
|
|
2810
|
+
}
|
|
2811
|
+
function sweepScratchDir(codeName, now = Date.now(), policy = scratchSweepPolicyResolver(codeName)) {
|
|
2812
|
+
if (policy.held)
|
|
2813
|
+
return 0;
|
|
2657
2814
|
const scratchDir = getScratchDir(codeName);
|
|
2815
|
+
try {
|
|
2816
|
+
if (lstatSync2(scratchDir).isSymbolicLink()) {
|
|
2817
|
+
process.stderr.write(`[scratch] [sweep-refused] agent=${codeName} reason=scratch-is-a-symlink
|
|
2818
|
+
`);
|
|
2819
|
+
return 0;
|
|
2820
|
+
}
|
|
2821
|
+
} catch {
|
|
2822
|
+
return 0;
|
|
2823
|
+
}
|
|
2658
2824
|
let removed = 0;
|
|
2659
2825
|
let entries;
|
|
2660
2826
|
try {
|
|
@@ -2664,7 +2830,7 @@ function sweepScratchDir(codeName, now = Date.now()) {
|
|
|
2664
2830
|
}
|
|
2665
2831
|
const cutoff = now - SCRATCH_RETENTION_DAYS * 24 * 60 * 60 * 1e3;
|
|
2666
2832
|
for (const entry of entries) {
|
|
2667
|
-
const full =
|
|
2833
|
+
const full = join6(scratchDir, entry);
|
|
2668
2834
|
try {
|
|
2669
2835
|
if (isFreshWithin(full, cutoff))
|
|
2670
2836
|
continue;
|
|
@@ -2673,6 +2839,8 @@ function sweepScratchDir(codeName, now = Date.now()) {
|
|
|
2673
2839
|
} catch {
|
|
2674
2840
|
}
|
|
2675
2841
|
}
|
|
2842
|
+
if (policy.perFile || policy.dryRun)
|
|
2843
|
+
removed += runScratchFileSweep(codeName, now, cutoff, policy.perFile);
|
|
2676
2844
|
return removed;
|
|
2677
2845
|
}
|
|
2678
2846
|
var STRANDED_ARTEFACT_TMP_PREFIXES = [
|
|
@@ -2692,7 +2860,7 @@ function sweepStrandedArtefactTmpDirs(now = Date.now()) {
|
|
|
2692
2860
|
for (const entry of entries) {
|
|
2693
2861
|
if (!STRANDED_ARTEFACT_TMP_PREFIXES.some((prefix) => entry.startsWith(prefix)))
|
|
2694
2862
|
continue;
|
|
2695
|
-
const full =
|
|
2863
|
+
const full = join6(root, entry);
|
|
2696
2864
|
try {
|
|
2697
2865
|
if (isFreshWithin(full, cutoff))
|
|
2698
2866
|
continue;
|
|
@@ -2713,7 +2881,7 @@ function isFreshWithin(path, cutoff) {
|
|
|
2713
2881
|
const current = queue.pop();
|
|
2714
2882
|
let stat;
|
|
2715
2883
|
try {
|
|
2716
|
-
stat =
|
|
2884
|
+
stat = lstatSync2(current);
|
|
2717
2885
|
} catch {
|
|
2718
2886
|
return true;
|
|
2719
2887
|
}
|
|
@@ -2723,7 +2891,7 @@ function isFreshWithin(path, cutoff) {
|
|
|
2723
2891
|
continue;
|
|
2724
2892
|
let dir;
|
|
2725
2893
|
try {
|
|
2726
|
-
dir =
|
|
2894
|
+
dir = opendirSync2(current);
|
|
2727
2895
|
} catch {
|
|
2728
2896
|
return true;
|
|
2729
2897
|
}
|
|
@@ -2732,7 +2900,7 @@ function isFreshWithin(path, cutoff) {
|
|
|
2732
2900
|
const child = dir.readSync();
|
|
2733
2901
|
if (child === null)
|
|
2734
2902
|
break;
|
|
2735
|
-
queue.push(
|
|
2903
|
+
queue.push(join6(current, child.name));
|
|
2736
2904
|
budget -= 1;
|
|
2737
2905
|
}
|
|
2738
2906
|
} catch {
|
|
@@ -2749,8 +2917,8 @@ function isFreshWithin(path, cutoff) {
|
|
|
2749
2917
|
function syncMcpToProject(codeName, provisionContent) {
|
|
2750
2918
|
const agentDir = getAgentDir(codeName);
|
|
2751
2919
|
const projectDir = getProjectDir2(codeName);
|
|
2752
|
-
const provisionMcpPath =
|
|
2753
|
-
const projectMcpPath =
|
|
2920
|
+
const provisionMcpPath = join6(agentDir, "provision", ".mcp.json");
|
|
2921
|
+
const projectMcpPath = join6(projectDir, ".mcp.json");
|
|
2754
2922
|
let content = provisionContent ?? null;
|
|
2755
2923
|
if (content === null) {
|
|
2756
2924
|
try {
|
|
@@ -2784,7 +2952,7 @@ function syncMcpToProject(codeName, provisionContent) {
|
|
|
2784
2952
|
}
|
|
2785
2953
|
var INTEGRATIONS_SUMMARY_FILE = "integrations-summary.json";
|
|
2786
2954
|
function integrationsSummaryPath(codeName) {
|
|
2787
|
-
return
|
|
2955
|
+
return join6(getAgentDir(codeName), "provision", INTEGRATIONS_SUMMARY_FILE);
|
|
2788
2956
|
}
|
|
2789
2957
|
function writeIntegrationsSummaryForAgent(codeName, summaries) {
|
|
2790
2958
|
const target = integrationsSummaryPath(codeName);
|
|
@@ -2806,7 +2974,7 @@ function readIntegrationsSummaryForAgent(codeName) {
|
|
|
2806
2974
|
function renderChannelMessageHandlerForAgent(codeName) {
|
|
2807
2975
|
const agentDir = getAgentDir(codeName);
|
|
2808
2976
|
const projectDir = getProjectDir2(codeName);
|
|
2809
|
-
const provisionMcpPath =
|
|
2977
|
+
const provisionMcpPath = join6(agentDir, "provision", ".mcp.json");
|
|
2810
2978
|
let mcpServerKeys;
|
|
2811
2979
|
try {
|
|
2812
2980
|
const config = JSON.parse(readFileSync5(provisionMcpPath, "utf-8"));
|
|
@@ -2817,7 +2985,7 @@ function renderChannelMessageHandlerForAgent(codeName) {
|
|
|
2817
2985
|
const integrations = readIntegrationsSummaryForAgent(codeName);
|
|
2818
2986
|
const content = buildChannelMessageHandlerAgent({ mcpServerKeys, integrations });
|
|
2819
2987
|
for (const baseDir of [agentDir, projectDir]) {
|
|
2820
|
-
const target =
|
|
2988
|
+
const target = join6(baseDir, ".claude", "agents", "channel-message-handler.md");
|
|
2821
2989
|
try {
|
|
2822
2990
|
mkdirSync4(dirname3(target), { recursive: true });
|
|
2823
2991
|
writeFileSync5(target, content);
|
|
@@ -2840,7 +3008,7 @@ function writeMcpJsonGuarded(codeName, path, config) {
|
|
|
2840
3008
|
return true;
|
|
2841
3009
|
}
|
|
2842
3010
|
function readExistingMcpEnvVar(codeName, serverId, envKey) {
|
|
2843
|
-
const mcpJsonPath =
|
|
3011
|
+
const mcpJsonPath = join6(getAgentDir(codeName), "provision", ".mcp.json");
|
|
2844
3012
|
try {
|
|
2845
3013
|
const raw = readFileSync5(mcpJsonPath, "utf-8");
|
|
2846
3014
|
const config = JSON.parse(raw);
|
|
@@ -2946,8 +3114,8 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
2946
3114
|
const SKILLS_START = SKILLS_INDEX_SECTION_START;
|
|
2947
3115
|
const SKILLS_END = SKILLS_INDEX_SECTION_END;
|
|
2948
3116
|
for (const file of artifactFiles) {
|
|
2949
|
-
const src =
|
|
2950
|
-
const dest =
|
|
3117
|
+
const src = join6(provisionDir, file);
|
|
3118
|
+
const dest = join6(projectDir, file);
|
|
2951
3119
|
try {
|
|
2952
3120
|
const srcContent = readFileSync5(src, "utf-8");
|
|
2953
3121
|
if (file === "CLAUDE.md" && existsSync4(dest)) {
|
|
@@ -2973,15 +3141,15 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
2973
3141
|
} catch {
|
|
2974
3142
|
}
|
|
2975
3143
|
}
|
|
2976
|
-
const skillsDir =
|
|
2977
|
-
const destSkillsDir =
|
|
3144
|
+
const skillsDir = join6(provisionDir, ".claude", "skills");
|
|
3145
|
+
const destSkillsDir = join6(projectDir, ".claude", "skills");
|
|
2978
3146
|
try {
|
|
2979
3147
|
if (existsSync4(destSkillsDir)) {
|
|
2980
3148
|
const srcFolders = existsSync4(skillsDir) ? new Set(readdirSync(skillsDir)) : /* @__PURE__ */ new Set();
|
|
2981
3149
|
for (const folder of readdirSync(destSkillsDir)) {
|
|
2982
3150
|
if (folder.startsWith("knowledge-") || folder === "core-knowledge" && !srcFolders.has(folder)) {
|
|
2983
3151
|
try {
|
|
2984
|
-
rmSync2(
|
|
3152
|
+
rmSync2(join6(destSkillsDir, folder), { recursive: true });
|
|
2985
3153
|
} catch {
|
|
2986
3154
|
}
|
|
2987
3155
|
}
|
|
@@ -2989,11 +3157,11 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
2989
3157
|
}
|
|
2990
3158
|
if (existsSync4(skillsDir)) {
|
|
2991
3159
|
for (const skillFolder of readdirSync(skillsDir)) {
|
|
2992
|
-
const srcSkillFile =
|
|
3160
|
+
const srcSkillFile = join6(skillsDir, skillFolder, "SKILL.md");
|
|
2993
3161
|
if (!existsSync4(srcSkillFile))
|
|
2994
3162
|
continue;
|
|
2995
|
-
const destFolder =
|
|
2996
|
-
const destFile =
|
|
3163
|
+
const destFolder = join6(destSkillsDir, skillFolder);
|
|
3164
|
+
const destFile = join6(destFolder, "SKILL.md");
|
|
2997
3165
|
const srcContent = readFileSync5(srcSkillFile, "utf-8");
|
|
2998
3166
|
try {
|
|
2999
3167
|
if (existsSync4(destFile) && readFileSync5(destFile, "utf-8") === srcContent)
|
|
@@ -3006,8 +3174,8 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3006
3174
|
}
|
|
3007
3175
|
} catch {
|
|
3008
3176
|
}
|
|
3009
|
-
const agentsDir =
|
|
3010
|
-
const destAgentsDir =
|
|
3177
|
+
const agentsDir = join6(provisionDir, ".claude", "agents");
|
|
3178
|
+
const destAgentsDir = join6(projectDir, ".claude", "agents");
|
|
3011
3179
|
try {
|
|
3012
3180
|
if (existsSync4(agentsDir)) {
|
|
3013
3181
|
const sourceAgentFiles = new Set(readdirSync(agentsDir).filter((f) => f.endsWith(".md")));
|
|
@@ -3018,14 +3186,14 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3018
3186
|
if (sourceAgentFiles.has(destFile))
|
|
3019
3187
|
continue;
|
|
3020
3188
|
try {
|
|
3021
|
-
rmSync2(
|
|
3189
|
+
rmSync2(join6(destAgentsDir, destFile));
|
|
3022
3190
|
} catch {
|
|
3023
3191
|
}
|
|
3024
3192
|
}
|
|
3025
3193
|
}
|
|
3026
3194
|
for (const agentFile of sourceAgentFiles) {
|
|
3027
|
-
const srcPath =
|
|
3028
|
-
const destPath =
|
|
3195
|
+
const srcPath = join6(agentsDir, agentFile);
|
|
3196
|
+
const destPath = join6(destAgentsDir, agentFile);
|
|
3029
3197
|
const srcContent = readFileSync5(srcPath, "utf-8");
|
|
3030
3198
|
try {
|
|
3031
3199
|
if (existsSync4(destPath) && readFileSync5(destPath, "utf-8") === srcContent)
|
|
@@ -3038,8 +3206,8 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3038
3206
|
}
|
|
3039
3207
|
} catch {
|
|
3040
3208
|
}
|
|
3041
|
-
const workflowsDir =
|
|
3042
|
-
const destWorkflowsDir =
|
|
3209
|
+
const workflowsDir = join6(provisionDir, ".claude", "workflows");
|
|
3210
|
+
const destWorkflowsDir = join6(projectDir, ".claude", "workflows");
|
|
3043
3211
|
try {
|
|
3044
3212
|
const sourceWorkflowFiles = existsSync4(workflowsDir) ? new Set(readdirSync(workflowsDir).filter((f) => f.endsWith(".js"))) : /* @__PURE__ */ new Set();
|
|
3045
3213
|
if (existsSync4(destWorkflowsDir)) {
|
|
@@ -3049,14 +3217,14 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3049
3217
|
if (sourceWorkflowFiles.has(destFile))
|
|
3050
3218
|
continue;
|
|
3051
3219
|
try {
|
|
3052
|
-
rmSync2(
|
|
3220
|
+
rmSync2(join6(destWorkflowsDir, destFile));
|
|
3053
3221
|
} catch {
|
|
3054
3222
|
}
|
|
3055
3223
|
}
|
|
3056
3224
|
}
|
|
3057
3225
|
for (const workflowFile of sourceWorkflowFiles) {
|
|
3058
|
-
const srcPath =
|
|
3059
|
-
const destPath =
|
|
3226
|
+
const srcPath = join6(workflowsDir, workflowFile);
|
|
3227
|
+
const destPath = join6(destWorkflowsDir, workflowFile);
|
|
3060
3228
|
const srcContent = readFileSync5(srcPath, "utf-8");
|
|
3061
3229
|
try {
|
|
3062
3230
|
if (existsSync4(destPath) && readFileSync5(destPath, "utf-8") === srcContent)
|
|
@@ -3068,8 +3236,8 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3068
3236
|
}
|
|
3069
3237
|
} catch {
|
|
3070
3238
|
}
|
|
3071
|
-
const agentMcpPath =
|
|
3072
|
-
const projectMcpPath =
|
|
3239
|
+
const agentMcpPath = join6(getAgentDir(codeName), "provision", ".mcp.json");
|
|
3240
|
+
const projectMcpPath = join6(projectDir, ".mcp.json");
|
|
3073
3241
|
try {
|
|
3074
3242
|
const agentMcp = JSON.parse(readFileSync5(agentMcpPath, "utf-8"));
|
|
3075
3243
|
let projectMcp;
|
|
@@ -3095,8 +3263,8 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3095
3263
|
const agentDir = getAgentDir(codeName);
|
|
3096
3264
|
for (const envFile of [".env", ".env.integrations"]) {
|
|
3097
3265
|
try {
|
|
3098
|
-
const content = readFileSync5(
|
|
3099
|
-
const envDest =
|
|
3266
|
+
const content = readFileSync5(join6(agentDir, envFile), "utf-8");
|
|
3267
|
+
const envDest = join6(projectDir, envFile);
|
|
3100
3268
|
writeFileSync5(envDest, content, { mode: SECRET_FILE_MODE });
|
|
3101
3269
|
try {
|
|
3102
3270
|
chmodSync4(envDest, SECRET_FILE_MODE);
|
|
@@ -3106,12 +3274,12 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3106
3274
|
}
|
|
3107
3275
|
}
|
|
3108
3276
|
try {
|
|
3109
|
-
const gitDir =
|
|
3110
|
-
const hookSrc =
|
|
3277
|
+
const gitDir = join6(projectDir, ".git");
|
|
3278
|
+
const hookSrc = join6(provisionDir, ".git-hooks", "pre-commit");
|
|
3111
3279
|
if (existsSync4(gitDir) && existsSync4(hookSrc)) {
|
|
3112
|
-
const hooksDir =
|
|
3280
|
+
const hooksDir = join6(gitDir, "hooks");
|
|
3113
3281
|
mkdirSync4(hooksDir, { recursive: true });
|
|
3114
|
-
const hookDest =
|
|
3282
|
+
const hookDest = join6(hooksDir, "pre-commit");
|
|
3115
3283
|
const srcContent = readFileSync5(hookSrc, "utf-8");
|
|
3116
3284
|
const upToDate = existsSync4(hookDest) && readFileSync5(hookDest, "utf-8") === srcContent;
|
|
3117
3285
|
if (!upToDate)
|
|
@@ -3123,9 +3291,9 @@ function deployArtifactsToProject(codeName, provisionDir) {
|
|
|
3123
3291
|
}
|
|
3124
3292
|
function provisionStopHook(codeName) {
|
|
3125
3293
|
const projectDir = getProjectDir2(codeName);
|
|
3126
|
-
const claudeDir =
|
|
3294
|
+
const claudeDir = join6(projectDir, ".claude");
|
|
3127
3295
|
mkdirSync4(claudeDir, { recursive: true });
|
|
3128
|
-
const hookScriptPath =
|
|
3296
|
+
const hookScriptPath = join6(claudeDir, "agt-stop-hook.sh");
|
|
3129
3297
|
const hookScript = [
|
|
3130
3298
|
"#!/bin/bash",
|
|
3131
3299
|
"# Auto-generated by Augmented \u2014 captures persistent session task results.",
|
|
@@ -3170,7 +3338,7 @@ function provisionStopHook(codeName) {
|
|
|
3170
3338
|
"exit 0"
|
|
3171
3339
|
].join("\n") + "\n";
|
|
3172
3340
|
writeFileSync5(hookScriptPath, hookScript, { mode: 493 });
|
|
3173
|
-
const ghostHookPath =
|
|
3341
|
+
const ghostHookPath = join6(claudeDir, "agt-ghost-reply-hook.sh");
|
|
3174
3342
|
const jqNormalizeContent = '(.message.content // .content // []) | if type == "string" then [{type: "text", text: .}] elif type == "array" then . else [] end';
|
|
3175
3343
|
const ghostHookScript = [
|
|
3176
3344
|
"#!/bin/bash",
|
|
@@ -4059,7 +4227,7 @@ function provisionStopHook(codeName) {
|
|
|
4059
4227
|
].join("\n") + "\n";
|
|
4060
4228
|
writeFileSync5(ghostHookPath, ghostHookScript, { mode: 493 });
|
|
4061
4229
|
const backlogHookPath = provisionBacklogPullHook(codeName);
|
|
4062
|
-
const settingsPath =
|
|
4230
|
+
const settingsPath = join6(claudeDir, "settings.local.json");
|
|
4063
4231
|
let settings = {};
|
|
4064
4232
|
try {
|
|
4065
4233
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -4080,25 +4248,25 @@ function provisionStopHook(codeName) {
|
|
|
4080
4248
|
}
|
|
4081
4249
|
function provisionIsolationHook(codeName, agentId) {
|
|
4082
4250
|
const homeDir = getHomeDir();
|
|
4083
|
-
const augmentedBase =
|
|
4251
|
+
const augmentedBase = join6(homeDir, ".augmented");
|
|
4084
4252
|
if (/["'$`\\\n]/.test(augmentedBase)) {
|
|
4085
4253
|
throw new Error(`provisionIsolationHook: home directory contains shell metacharacters: ${JSON.stringify(augmentedBase)}`);
|
|
4086
4254
|
}
|
|
4087
4255
|
const projectDir = getProjectDir2(codeName);
|
|
4088
|
-
const claudeDir =
|
|
4256
|
+
const claudeDir = join6(projectDir, ".claude");
|
|
4089
4257
|
mkdirSync4(claudeDir, { recursive: true });
|
|
4090
4258
|
const hasAgentId = agentId !== void 0;
|
|
4091
4259
|
if (hasAgentId)
|
|
4092
4260
|
assertValidAgentId(agentId);
|
|
4093
4261
|
const augmentedBaseRe = augmentedBase.replace(/[.[\]()*+?{}|^$]/g, "\\$&");
|
|
4094
|
-
const claudeProjectsBase =
|
|
4262
|
+
const claudeProjectsBase = join6(homeDir, ".claude", "projects");
|
|
4095
4263
|
const claudeProjectsBaseRe = claudeProjectsBase.replace(/[.[\]()*+?{}|^$]/g, "\\$&");
|
|
4096
4264
|
const mangledBase = augmentedBase.replace(/[^a-zA-Z0-9]/g, "-");
|
|
4097
4265
|
const ownAgentDir = getAgentDir(codeName);
|
|
4098
|
-
const logFile =
|
|
4266
|
+
const logFile = join6(ownAgentDir, "isolation.log");
|
|
4099
4267
|
const idAllowClause = hasAgentId ? ` && [ "$AGENT_DIR" != "${agentId}" ]` : "";
|
|
4100
4268
|
const idAllowClause2 = hasAgentId ? ` || [ "$OWNER" = "${agentId}" ]` : "";
|
|
4101
|
-
const hookScriptPath =
|
|
4269
|
+
const hookScriptPath = join6(claudeDir, "agt-isolation-hook.sh");
|
|
4102
4270
|
const hookScript = [
|
|
4103
4271
|
"#!/bin/bash",
|
|
4104
4272
|
"# Auto-generated by Augmented.",
|
|
@@ -4374,7 +4542,7 @@ function provisionIsolationHook(codeName, agentId) {
|
|
|
4374
4542
|
"exit 0"
|
|
4375
4543
|
].join("\n") + "\n";
|
|
4376
4544
|
writeFileSync5(hookScriptPath, hookScript, { mode: 493 });
|
|
4377
|
-
const settingsPath =
|
|
4545
|
+
const settingsPath = join6(claudeDir, "settings.local.json");
|
|
4378
4546
|
let settings = {};
|
|
4379
4547
|
try {
|
|
4380
4548
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -4396,9 +4564,9 @@ function provisionIsolationHook(codeName, agentId) {
|
|
|
4396
4564
|
}
|
|
4397
4565
|
function provisionBacklogPullHook(codeName) {
|
|
4398
4566
|
const projectDir = getProjectDir2(codeName);
|
|
4399
|
-
const claudeDir =
|
|
4567
|
+
const claudeDir = join6(projectDir, ".claude");
|
|
4400
4568
|
mkdirSync4(claudeDir, { recursive: true });
|
|
4401
|
-
const hookScriptPath =
|
|
4569
|
+
const hookScriptPath = join6(claudeDir, "agt-backlog-pull-hook.sh");
|
|
4402
4570
|
const hookScript = `#!/usr/bin/env bash
|
|
4403
4571
|
# Auto-generated by Augmented (CS-1549) \u2014 Stop hook: don't end a turn idle
|
|
4404
4572
|
# beside a non-empty backlog. Fail-open on every path; blocks at most once per
|
|
@@ -4574,9 +4742,9 @@ exit 0
|
|
|
4574
4742
|
}
|
|
4575
4743
|
function provisionAutoKanbanProgressHook(codeName) {
|
|
4576
4744
|
const projectDir = getProjectDir2(codeName);
|
|
4577
|
-
const claudeDir =
|
|
4745
|
+
const claudeDir = join6(projectDir, ".claude");
|
|
4578
4746
|
mkdirSync4(claudeDir, { recursive: true });
|
|
4579
|
-
const hookScriptPath =
|
|
4747
|
+
const hookScriptPath = join6(claudeDir, "agt-auto-kanban-progress-hook.sh");
|
|
4580
4748
|
const hookScript = `#!/usr/bin/env bash
|
|
4581
4749
|
# Auto-generated by Augmented (ENG-6179 / ENG-6241) \u2014 PostToolUse auto-progress.
|
|
4582
4750
|
# Maps the agent's latest tool action onto its active in-thread kanban progress
|
|
@@ -4692,7 +4860,7 @@ BODY="$(jq -nc --arg a "$AGENT_ID" --arg s "$STEP" '{agent_id:$a, step:$s}' 2>/d
|
|
|
4692
4860
|
exit 0
|
|
4693
4861
|
`;
|
|
4694
4862
|
writeFileSync5(hookScriptPath, hookScript, { mode: 493 });
|
|
4695
|
-
const settingsPath =
|
|
4863
|
+
const settingsPath = join6(claudeDir, "settings.local.json");
|
|
4696
4864
|
let settings = {};
|
|
4697
4865
|
try {
|
|
4698
4866
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -4711,9 +4879,9 @@ exit 0
|
|
|
4711
4879
|
}
|
|
4712
4880
|
function provisionChannelProgressHook(codeName) {
|
|
4713
4881
|
const projectDir = getProjectDir2(codeName);
|
|
4714
|
-
const claudeDir =
|
|
4882
|
+
const claudeDir = join6(projectDir, ".claude");
|
|
4715
4883
|
mkdirSync4(claudeDir, { recursive: true });
|
|
4716
|
-
const hookScriptPath =
|
|
4884
|
+
const hookScriptPath = join6(claudeDir, "agt-channel-progress-hook.sh");
|
|
4717
4885
|
const hookScript = `#!/usr/bin/env bash
|
|
4718
4886
|
# Auto-generated by Augmented (ENG-6567 Phase 2) \u2014 PostToolUse channel-progress
|
|
4719
4887
|
# heartbeat. Writes a throttled local {step, updated_at_ms} the channel MCP reads
|
|
@@ -4780,7 +4948,7 @@ fi
|
|
|
4780
4948
|
exit 0
|
|
4781
4949
|
`;
|
|
4782
4950
|
writeFileSync5(hookScriptPath, hookScript, { mode: 493 });
|
|
4783
|
-
const settingsPath =
|
|
4951
|
+
const settingsPath = join6(claudeDir, "settings.local.json");
|
|
4784
4952
|
let settings = {};
|
|
4785
4953
|
try {
|
|
4786
4954
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -5164,14 +5332,14 @@ function classifyCommand(words0, loop, depth) {
|
|
|
5164
5332
|
`;
|
|
5165
5333
|
var LONG_COMMAND_MAX_FOREGROUND_TIMEOUT_MS = 18e4;
|
|
5166
5334
|
function provisionRootRmHook(codeName) {
|
|
5167
|
-
provisionRootRmHookAt(
|
|
5335
|
+
provisionRootRmHookAt(join6(getProjectDir2(codeName), ".claude"));
|
|
5168
5336
|
}
|
|
5169
5337
|
function provisionLongCommandHook(codeName) {
|
|
5170
5338
|
const projectDir = getProjectDir2(codeName);
|
|
5171
|
-
const claudeDir =
|
|
5339
|
+
const claudeDir = join6(projectDir, ".claude");
|
|
5172
5340
|
mkdirSync4(claudeDir, { recursive: true });
|
|
5173
|
-
const hookScriptPath =
|
|
5174
|
-
const jsPath =
|
|
5341
|
+
const hookScriptPath = join6(claudeDir, LONG_COMMAND_HOOK_FILENAME);
|
|
5342
|
+
const jsPath = join6(claudeDir, LONG_COMMAND_HOOK_JS_FILENAME);
|
|
5175
5343
|
writeFileSync5(jsPath, LONG_COMMAND_HOOK_JS.replace("__BOUND__", String(LONG_COMMAND_BOUNDED_TIMEOUT_MS)), { mode: 420 });
|
|
5176
5344
|
const hookScript = [
|
|
5177
5345
|
"#!/usr/bin/env bash",
|
|
@@ -5181,7 +5349,7 @@ function provisionLongCommandHook(codeName) {
|
|
|
5181
5349
|
`exec node '${jsPath.replace(/'/g, `'\\''`)}'`
|
|
5182
5350
|
].join("\n") + "\n";
|
|
5183
5351
|
writeFileSync5(hookScriptPath, hookScript, { mode: 493 });
|
|
5184
|
-
const settingsPath =
|
|
5352
|
+
const settingsPath = join6(claudeDir, "settings.local.json");
|
|
5185
5353
|
let settings = {};
|
|
5186
5354
|
try {
|
|
5187
5355
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -5202,11 +5370,11 @@ function provisionLongCommandHook(codeName) {
|
|
|
5202
5370
|
}
|
|
5203
5371
|
function provisionOrientHook(codeName) {
|
|
5204
5372
|
const projectDir = getProjectDir2(codeName);
|
|
5205
|
-
const claudeDir =
|
|
5373
|
+
const claudeDir = join6(projectDir, ".claude");
|
|
5206
5374
|
mkdirSync4(claudeDir, { recursive: true });
|
|
5207
5375
|
const agentDir = getAgentDir(codeName);
|
|
5208
|
-
const codeRoots = [
|
|
5209
|
-
const hookScriptPath =
|
|
5376
|
+
const codeRoots = [join6(getHomeDir(), "code"), join6(agentDir, "code")];
|
|
5377
|
+
const hookScriptPath = join6(claudeDir, "agt-orient-hook.sh");
|
|
5210
5378
|
const hookScript = [
|
|
5211
5379
|
"#!/bin/bash",
|
|
5212
5380
|
"# Auto-generated by Augmented (ENG-5397) \u2014 SessionStart orientation hook.",
|
|
@@ -5479,7 +5647,7 @@ function provisionOrientHook(codeName) {
|
|
|
5479
5647
|
"exit 0"
|
|
5480
5648
|
].join("\n") + "\n";
|
|
5481
5649
|
writeFileSync5(hookScriptPath, hookScript, { mode: 493 });
|
|
5482
|
-
const settingsPath =
|
|
5650
|
+
const settingsPath = join6(claudeDir, "settings.local.json");
|
|
5483
5651
|
let settings = {};
|
|
5484
5652
|
try {
|
|
5485
5653
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -5506,11 +5674,11 @@ function provisionOrientHook(codeName) {
|
|
|
5506
5674
|
}
|
|
5507
5675
|
function provisionPreCompactHook(codeName) {
|
|
5508
5676
|
const projectDir = getProjectDir2(codeName);
|
|
5509
|
-
const claudeDir =
|
|
5677
|
+
const claudeDir = join6(projectDir, ".claude");
|
|
5510
5678
|
mkdirSync4(claudeDir, { recursive: true });
|
|
5511
5679
|
const agentDir = getAgentDir(codeName);
|
|
5512
5680
|
const jqNormalizeContent = '(.message.content // .content // []) | if type == "string" then [{type: "text", text: .}] elif type == "array" then . else [] end';
|
|
5513
|
-
const hookScriptPath =
|
|
5681
|
+
const hookScriptPath = join6(claudeDir, "agt-pre-compact-hook.sh");
|
|
5514
5682
|
const hookScript = [
|
|
5515
5683
|
"#!/bin/bash",
|
|
5516
5684
|
"# Auto-generated by Augmented (ENG-7339) - PreCompact courtesy notice.",
|
|
@@ -5616,7 +5784,7 @@ function provisionPreCompactHook(codeName) {
|
|
|
5616
5784
|
].join("\n") + "\n";
|
|
5617
5785
|
writeFileSync5(hookScriptPath, hookScript, { mode: 493 });
|
|
5618
5786
|
chmodSync4(hookScriptPath, 493);
|
|
5619
|
-
const settingsPath =
|
|
5787
|
+
const settingsPath = join6(claudeDir, "settings.local.json");
|
|
5620
5788
|
let settings = {};
|
|
5621
5789
|
try {
|
|
5622
5790
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -5643,10 +5811,10 @@ function provisionPreCompactHook(codeName) {
|
|
|
5643
5811
|
}
|
|
5644
5812
|
function provisionSessionStateHook(codeName) {
|
|
5645
5813
|
const projectDir = getProjectDir2(codeName);
|
|
5646
|
-
const claudeDir =
|
|
5814
|
+
const claudeDir = join6(projectDir, ".claude");
|
|
5647
5815
|
mkdirSync4(claudeDir, { recursive: true });
|
|
5648
5816
|
const agentDir = getAgentDir(codeName);
|
|
5649
|
-
const hookScriptPath =
|
|
5817
|
+
const hookScriptPath = join6(claudeDir, "agt-session-state-hook.sh");
|
|
5650
5818
|
const hookScript = `#!/usr/bin/env bash
|
|
5651
5819
|
# Auto-generated by Augmented (ENG-6233 / ENG-6268) \u2014 SessionStart session-state
|
|
5652
5820
|
# recorder. Writes the model + session origin (which only the agent's own
|
|
@@ -5724,7 +5892,7 @@ fi
|
|
|
5724
5892
|
exit 0
|
|
5725
5893
|
`;
|
|
5726
5894
|
writeFileSync5(hookScriptPath, hookScript, { mode: 493 });
|
|
5727
|
-
const settingsPath =
|
|
5895
|
+
const settingsPath = join6(claudeDir, "settings.local.json");
|
|
5728
5896
|
let settings = {};
|
|
5729
5897
|
try {
|
|
5730
5898
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -5846,7 +6014,7 @@ function buildSettingsJson(input) {
|
|
|
5846
6014
|
const projectDir = getProjectDir2(agent.code_name);
|
|
5847
6015
|
const agentDir = getAgentDir(agent.code_name);
|
|
5848
6016
|
const homeDir = getHomeDir();
|
|
5849
|
-
const codenameAliasDir =
|
|
6017
|
+
const codenameAliasDir = join6(homeDir, ".augmented", agent.code_name);
|
|
5850
6018
|
settings["allowedDirectories"] = [
|
|
5851
6019
|
.../* @__PURE__ */ new Set([
|
|
5852
6020
|
projectDir,
|
|
@@ -5855,7 +6023,7 @@ function buildSettingsJson(input) {
|
|
|
5855
6023
|
// Agent's config dir (.env, schedules, registration)
|
|
5856
6024
|
codenameAliasDir,
|
|
5857
6025
|
// Codename symlink alias (== agentDir for legacy agents)
|
|
5858
|
-
|
|
6026
|
+
join6(homeDir, ".augmented", "_mcp"),
|
|
5859
6027
|
// Shared MCP binaries
|
|
5860
6028
|
"/tmp"
|
|
5861
6029
|
// Temp files
|
|
@@ -5955,7 +6123,7 @@ ${integrationsBlock}`;
|
|
|
5955
6123
|
function renderAugmentedWorkerForAgent(codeName) {
|
|
5956
6124
|
const agentDir = getAgentDir(codeName);
|
|
5957
6125
|
const projectDir = getProjectDir2(codeName);
|
|
5958
|
-
const provisionMcpPath =
|
|
6126
|
+
const provisionMcpPath = join6(agentDir, "provision", ".mcp.json");
|
|
5959
6127
|
let mcpServerKeys;
|
|
5960
6128
|
try {
|
|
5961
6129
|
const config = JSON.parse(readFileSync5(provisionMcpPath, "utf-8"));
|
|
@@ -5966,7 +6134,7 @@ function renderAugmentedWorkerForAgent(codeName) {
|
|
|
5966
6134
|
const integrations = readIntegrationsSummaryForAgent(codeName);
|
|
5967
6135
|
const content = buildAugmentedWorkerAgent({ mcpServerKeys, integrations });
|
|
5968
6136
|
for (const baseDir of [agentDir, projectDir]) {
|
|
5969
|
-
const target =
|
|
6137
|
+
const target = join6(baseDir, ".claude", "agents", "augmented-worker.md");
|
|
5970
6138
|
try {
|
|
5971
6139
|
mkdirSync4(dirname3(target), { recursive: true });
|
|
5972
6140
|
writeFileSync5(target, content);
|
|
@@ -5995,8 +6163,8 @@ function buildPostizMcpEntry(integration) {
|
|
|
5995
6163
|
}
|
|
5996
6164
|
function buildMcpJson(input) {
|
|
5997
6165
|
const mcpServers = {};
|
|
5998
|
-
const turnInitiatorFile =
|
|
5999
|
-
const localMcpPath =
|
|
6166
|
+
const turnInitiatorFile = join6(getAgentDir(input.agent.code_name), ".current-turn-initiator.json");
|
|
6167
|
+
const localMcpPath = join6(getHomeDir(), ".augmented", "_mcp", "index.js");
|
|
6000
6168
|
mcpServers["augmented"] = {
|
|
6001
6169
|
command: "node",
|
|
6002
6170
|
args: [localMcpPath],
|
|
@@ -6049,7 +6217,7 @@ function buildMcpJson(input) {
|
|
|
6049
6217
|
const xeroIntegration = input.integrations?.find((i) => i.definition_id === "xero");
|
|
6050
6218
|
if (xeroIntegration) {
|
|
6051
6219
|
const brokerMode = Boolean(xeroIntegration.id);
|
|
6052
|
-
const localXeroMcpPath =
|
|
6220
|
+
const localXeroMcpPath = join6(getHomeDir(), ".augmented", "_mcp", "xero.js");
|
|
6053
6221
|
mcpServers["xero"] = {
|
|
6054
6222
|
command: "node",
|
|
6055
6223
|
args: [localXeroMcpPath],
|
|
@@ -6089,7 +6257,7 @@ function buildMcpJson(input) {
|
|
|
6089
6257
|
// getProjectDir (the ADR-0049 seam), not the MCP child's inherited
|
|
6090
6258
|
// cwd, so the path stays correct if Claude Code ever spawns the
|
|
6091
6259
|
// server from somewhere else.
|
|
6092
|
-
XERO_EXPORT_DIR:
|
|
6260
|
+
XERO_EXPORT_DIR: join6(getProjectDir2(input.agent.code_name), "xero-exports"),
|
|
6093
6261
|
PATH: process.env["PATH"] ?? "",
|
|
6094
6262
|
HOME: process.env["HOME"] ?? ""
|
|
6095
6263
|
}
|
|
@@ -6100,8 +6268,8 @@ function buildMcpJson(input) {
|
|
|
6100
6268
|
mcpServers["postiz"] = buildPostizMcpEntry(postizIntegration);
|
|
6101
6269
|
}
|
|
6102
6270
|
const remoteOAuthProxyPaths = {
|
|
6103
|
-
proxyPath:
|
|
6104
|
-
tokenFile:
|
|
6271
|
+
proxyPath: join6(getHomeDir(), ".augmented", "_mcp", "remote-oauth-proxy.js"),
|
|
6272
|
+
tokenFile: join6(getProjectDir2(input.agent.code_name), ".env.integrations")
|
|
6105
6273
|
};
|
|
6106
6274
|
for (const integration of input.integrations ?? []) {
|
|
6107
6275
|
const connectionKey = integration.connection_key;
|
|
@@ -6187,7 +6355,7 @@ function buildMcpJson(input) {
|
|
|
6187
6355
|
}
|
|
6188
6356
|
const hasAdminDebug = input.integrations?.some((i) => i.definition_id === "augmented-admin") ?? false;
|
|
6189
6357
|
if (hasAdminDebug) {
|
|
6190
|
-
const localAdminMcpPath =
|
|
6358
|
+
const localAdminMcpPath = join6(getHomeDir(), ".augmented", "_mcp", "augmented-admin.js");
|
|
6191
6359
|
mcpServers["augmented-admin"] = {
|
|
6192
6360
|
command: "node",
|
|
6193
6361
|
args: [localAdminMcpPath],
|
|
@@ -6201,7 +6369,7 @@ function buildMcpJson(input) {
|
|
|
6201
6369
|
}
|
|
6202
6370
|
const hasSupport = input.integrations?.some((i) => i.definition_id === "augmented-support") ?? false;
|
|
6203
6371
|
if (hasSupport) {
|
|
6204
|
-
const localSupportMcpPath =
|
|
6372
|
+
const localSupportMcpPath = join6(getHomeDir(), ".augmented", "_mcp", "augmented-support.js");
|
|
6205
6373
|
mcpServers["augmented-support"] = {
|
|
6206
6374
|
command: "node",
|
|
6207
6375
|
args: [localSupportMcpPath],
|
|
@@ -6215,7 +6383,7 @@ function buildMcpJson(input) {
|
|
|
6215
6383
|
}
|
|
6216
6384
|
const hasHelpKb = input.integrations?.some((i) => i.definition_id === "augmented-help-kb") ?? false;
|
|
6217
6385
|
if (hasHelpKb) {
|
|
6218
|
-
const localHelpKbMcpPath =
|
|
6386
|
+
const localHelpKbMcpPath = join6(getHomeDir(), ".augmented", "_mcp", "augmented-help-kb.js");
|
|
6219
6387
|
mcpServers["augmented-help-kb"] = {
|
|
6220
6388
|
command: "node",
|
|
6221
6389
|
args: [localHelpKbMcpPath],
|
|
@@ -6229,7 +6397,7 @@ function buildMcpJson(input) {
|
|
|
6229
6397
|
}
|
|
6230
6398
|
const origamiIntegration = input.integrations?.find((i) => i.definition_id === "origami");
|
|
6231
6399
|
if (origamiIntegration?.stdioMcp === true && origamiIntegration.id) {
|
|
6232
|
-
const localOrigamiMcpPath =
|
|
6400
|
+
const localOrigamiMcpPath = join6(getHomeDir(), ".augmented", "_mcp", "origami.js");
|
|
6233
6401
|
mcpServers["origami"] = {
|
|
6234
6402
|
command: "node",
|
|
6235
6403
|
args: [localOrigamiMcpPath],
|
|
@@ -6248,7 +6416,7 @@ function buildMcpJson(input) {
|
|
|
6248
6416
|
agentId: input.agent.agent_id,
|
|
6249
6417
|
agentCodeName: input.agent.code_name,
|
|
6250
6418
|
config: computerUseIntegration.config,
|
|
6251
|
-
proxyPath:
|
|
6419
|
+
proxyPath: join6(getHomeDir(), ".augmented", "_mcp", "computer-use-proxy.js"),
|
|
6252
6420
|
agentDir: getAgentDir(input.agent.code_name)
|
|
6253
6421
|
});
|
|
6254
6422
|
if (rendered.entry) {
|
|
@@ -6498,27 +6666,27 @@ ${sections}`
|
|
|
6498
6666
|
},
|
|
6499
6667
|
async getRegisteredAgents(_profile) {
|
|
6500
6668
|
const homeDir = getHomeDir();
|
|
6501
|
-
const augDir =
|
|
6669
|
+
const augDir = join6(homeDir, ".augmented");
|
|
6502
6670
|
const agents = /* @__PURE__ */ new Set();
|
|
6503
6671
|
try {
|
|
6504
6672
|
const entries = readdirSync(augDir);
|
|
6505
6673
|
for (const entry of entries) {
|
|
6506
6674
|
if (entry.startsWith("_") || entry.startsWith("."))
|
|
6507
6675
|
continue;
|
|
6508
|
-
const agentRoot =
|
|
6676
|
+
const agentRoot = join6(augDir, entry);
|
|
6509
6677
|
let st;
|
|
6510
6678
|
try {
|
|
6511
|
-
st =
|
|
6679
|
+
st = lstatSync2(agentRoot);
|
|
6512
6680
|
} catch {
|
|
6513
6681
|
continue;
|
|
6514
6682
|
}
|
|
6515
6683
|
if (st.isSymbolicLink() || !st.isDirectory())
|
|
6516
6684
|
continue;
|
|
6517
|
-
if (!existsSync4(
|
|
6685
|
+
if (!existsSync4(join6(agentRoot, "registration.json")))
|
|
6518
6686
|
continue;
|
|
6519
6687
|
let codeName = entry;
|
|
6520
6688
|
try {
|
|
6521
|
-
const reg = JSON.parse(readFileSync5(
|
|
6689
|
+
const reg = JSON.parse(readFileSync5(join6(agentRoot, "registration.json"), "utf8"));
|
|
6522
6690
|
if (reg && typeof reg.code_name === "string" && reg.code_name) {
|
|
6523
6691
|
codeName = reg.code_name;
|
|
6524
6692
|
}
|
|
@@ -6539,7 +6707,7 @@ ${sections}`
|
|
|
6539
6707
|
const projectDir = getProjectDir2(codeName);
|
|
6540
6708
|
mkdirSync4(agentDir, { recursive: true });
|
|
6541
6709
|
mkdirSync4(projectDir, { recursive: true });
|
|
6542
|
-
writeFileSync5(
|
|
6710
|
+
writeFileSync5(join6(agentDir, "registration.json"), JSON.stringify({
|
|
6543
6711
|
code_name: codeName,
|
|
6544
6712
|
agent_id: agentId ?? null,
|
|
6545
6713
|
team_dir: teamDir,
|
|
@@ -6558,10 +6726,10 @@ ${sections}`
|
|
|
6558
6726
|
async deregisterAgent(codeName) {
|
|
6559
6727
|
try {
|
|
6560
6728
|
const agentDir = getAgentDir(codeName);
|
|
6561
|
-
const regFile =
|
|
6729
|
+
const regFile = join6(agentDir, "registration.json");
|
|
6562
6730
|
if (existsSync4(regFile)) {
|
|
6563
|
-
const { unlinkSync:
|
|
6564
|
-
|
|
6731
|
+
const { unlinkSync: unlinkSync7 } = await import("fs");
|
|
6732
|
+
unlinkSync7(regFile);
|
|
6565
6733
|
}
|
|
6566
6734
|
return true;
|
|
6567
6735
|
} catch {
|
|
@@ -6584,7 +6752,7 @@ ${sections}`
|
|
|
6584
6752
|
}
|
|
6585
6753
|
}
|
|
6586
6754
|
if (envLines.length > 1) {
|
|
6587
|
-
const envPath =
|
|
6755
|
+
const envPath = join6(agentDir, ".env");
|
|
6588
6756
|
writeFileSync5(envPath, envLines.join("\n") + "\n");
|
|
6589
6757
|
chmodSync4(envPath, SECRET_FILE_MODE);
|
|
6590
6758
|
}
|
|
@@ -6648,7 +6816,7 @@ ${sections}`
|
|
|
6648
6816
|
if (!botToken)
|
|
6649
6817
|
return missingCredentialField("bot_token");
|
|
6650
6818
|
const allowedChats = config["allowed_chats"];
|
|
6651
|
-
const localTelegramChannel =
|
|
6819
|
+
const localTelegramChannel = join6(getHomeDir(), ".augmented", "_mcp", "telegram-channel.js");
|
|
6652
6820
|
const resolvedAgtHostForTelegram = process.env["AGT_HOST"]?.trim() || "https://api.augmented.team";
|
|
6653
6821
|
const resolvedAgtApiKeyForTelegram = process.env["AGT_API_KEY"]?.trim();
|
|
6654
6822
|
writeEnvIntegrationsForAgent(codeName, {
|
|
@@ -6663,7 +6831,7 @@ ${sections}`
|
|
|
6663
6831
|
...options?.agentId ? { AGT_AGENT_ID: options.agentId } : {},
|
|
6664
6832
|
...tzEnv,
|
|
6665
6833
|
// ENG-6582 (D16): stamp the verified turn initiator for broker MCPs.
|
|
6666
|
-
AGT_TURN_INITIATOR_FILE:
|
|
6834
|
+
AGT_TURN_INITIATOR_FILE: join6(getAgentDir(codeName), ".current-turn-initiator.json")
|
|
6667
6835
|
};
|
|
6668
6836
|
if (allowedChats && allowedChats.length > 0) {
|
|
6669
6837
|
telegramEnv.TELEGRAM_ALLOWED_CHATS = allowedChats.join(",");
|
|
@@ -6738,7 +6906,7 @@ ${sections}`
|
|
|
6738
6906
|
args: [localTelegramChannel],
|
|
6739
6907
|
env: telegramEnv
|
|
6740
6908
|
};
|
|
6741
|
-
const provisionMcpPath =
|
|
6909
|
+
const provisionMcpPath = join6(agentDir, "provision", ".mcp.json");
|
|
6742
6910
|
mkdirSync4(dirname3(provisionMcpPath), { recursive: true });
|
|
6743
6911
|
let mcpConfig2 = { mcpServers: {} };
|
|
6744
6912
|
try {
|
|
@@ -6756,13 +6924,13 @@ ${sections}`
|
|
|
6756
6924
|
}
|
|
6757
6925
|
if (isPersistent && (channelId === "discord" || channelId === "slack")) {
|
|
6758
6926
|
let wrotePersistentCredential = false;
|
|
6759
|
-
const channelDir =
|
|
6927
|
+
const channelDir = join6(getHomeDir(), ".claude", "channels", channelId);
|
|
6760
6928
|
if (channelId === "discord")
|
|
6761
6929
|
mkdirSync4(channelDir, { recursive: true });
|
|
6762
6930
|
if (channelId === "discord") {
|
|
6763
6931
|
const botToken = config["bot_token"];
|
|
6764
6932
|
if (botToken) {
|
|
6765
|
-
writeFileSync5(
|
|
6933
|
+
writeFileSync5(join6(channelDir, ".env"), `DISCORD_BOT_TOKEN=${botToken}
|
|
6766
6934
|
`);
|
|
6767
6935
|
wrotePersistentCredential = true;
|
|
6768
6936
|
}
|
|
@@ -6826,7 +6994,7 @@ ${sections}`
|
|
|
6826
6994
|
...appToken ? { SLACK_APP_TOKEN: appToken } : {}
|
|
6827
6995
|
}, ["SLACK_BOT_TOKEN", "SLACK_APP_TOKEN"])
|
|
6828
6996
|
});
|
|
6829
|
-
const localSlackChannel =
|
|
6997
|
+
const localSlackChannel = join6(getHomeDir(), ".augmented", "_mcp", "slack-channel.js");
|
|
6830
6998
|
const slackAvatarEnvUrl = resolveAvatarEnvUrl(options?.agentAvatarUrl).url;
|
|
6831
6999
|
const slackEntry = {
|
|
6832
7000
|
command: existsSync4(localSlackChannel) ? "node" : "npx",
|
|
@@ -6921,10 +7089,10 @@ ${sections}`
|
|
|
6921
7089
|
...pingAllowedUsers.length > 0 ? { SLACK_PING_ALLOWED_USERS: pingAllowedUsers.join(",") } : {},
|
|
6922
7090
|
// ENG-6563 (D16): stamp the verified turn initiator so broker MCPs
|
|
6923
7091
|
// can forward it when the agent files an approval mid-turn.
|
|
6924
|
-
AGT_TURN_INITIATOR_FILE:
|
|
7092
|
+
AGT_TURN_INITIATOR_FILE: join6(agentDir, ".current-turn-initiator.json")
|
|
6925
7093
|
}
|
|
6926
7094
|
};
|
|
6927
|
-
const provisionMcpPath =
|
|
7095
|
+
const provisionMcpPath = join6(agentDir, "provision", ".mcp.json");
|
|
6928
7096
|
mkdirSync4(dirname3(provisionMcpPath), { recursive: true });
|
|
6929
7097
|
let mcpConfig2 = { mcpServers: {} };
|
|
6930
7098
|
try {
|
|
@@ -6939,7 +7107,7 @@ ${sections}`
|
|
|
6939
7107
|
}
|
|
6940
7108
|
syncMcpToProject(codeName);
|
|
6941
7109
|
wrotePersistentCredential = true;
|
|
6942
|
-
const staleChannelsPath =
|
|
7110
|
+
const staleChannelsPath = join6(getProjectDir2(codeName), ".mcp-channels.json");
|
|
6943
7111
|
if (existsSync4(staleChannelsPath)) {
|
|
6944
7112
|
try {
|
|
6945
7113
|
rmSync2(staleChannelsPath, { force: true });
|
|
@@ -6953,7 +7121,7 @@ ${sections}`
|
|
|
6953
7121
|
}
|
|
6954
7122
|
return CHANNEL_WRITE_OK;
|
|
6955
7123
|
}
|
|
6956
|
-
const mcpJsonPath =
|
|
7124
|
+
const mcpJsonPath = join6(agentDir, "provision", ".mcp.json");
|
|
6957
7125
|
mkdirSync4(dirname3(mcpJsonPath), { recursive: true });
|
|
6958
7126
|
let mcpConfig;
|
|
6959
7127
|
try {
|
|
@@ -6976,7 +7144,7 @@ ${sections}`
|
|
|
6976
7144
|
const appToken = config["app_token"];
|
|
6977
7145
|
if (!botToken)
|
|
6978
7146
|
return missingCredentialField("bot_token");
|
|
6979
|
-
const localSlackChannel =
|
|
7147
|
+
const localSlackChannel = join6(getHomeDir(), ".augmented", "_mcp", "slack-channel.js");
|
|
6980
7148
|
const slackThreadAutoFollow = config["thread_auto_follow"];
|
|
6981
7149
|
const slackAutoFollowEnv = slackThreadAutoFollow && slackThreadAutoFollow !== "off" ? { SLACK_THREAD_AUTO_FOLLOW: slackThreadAutoFollow } : {};
|
|
6982
7150
|
const slackChannelResponseMode = config["channel_response_mode"];
|
|
@@ -7065,7 +7233,7 @@ ${sections}`
|
|
|
7065
7233
|
...slackAgtAuthEnv,
|
|
7066
7234
|
...tzEnv,
|
|
7067
7235
|
// ENG-6563 (D16): stamp the verified turn initiator for broker MCPs.
|
|
7068
|
-
AGT_TURN_INITIATOR_FILE:
|
|
7236
|
+
AGT_TURN_INITIATOR_FILE: join6(getAgentDir(codeName), ".current-turn-initiator.json"),
|
|
7069
7237
|
// ENG-6155: avatar URL → bot Slack profile photo (see persistent
|
|
7070
7238
|
// branch above). Mirrored here so oneshot-mode agents get it too.
|
|
7071
7239
|
// ENG-6245: slackAvatarEnvUrl is null for data-URI / oversized values.
|
|
@@ -7090,7 +7258,7 @@ ${sections}`
|
|
|
7090
7258
|
...slackAgtAuthEnv,
|
|
7091
7259
|
...tzEnv,
|
|
7092
7260
|
// ENG-6563 (D16): stamp the verified turn initiator for broker MCPs.
|
|
7093
|
-
AGT_TURN_INITIATOR_FILE:
|
|
7261
|
+
AGT_TURN_INITIATOR_FILE: join6(getAgentDir(codeName), ".current-turn-initiator.json"),
|
|
7094
7262
|
// ENG-6155: avatar URL → bot Slack profile photo (see persistent
|
|
7095
7263
|
// branch above). Mirrored here so oneshot-mode agents get it too.
|
|
7096
7264
|
// ENG-6245: slackAvatarEnvUrl is null for data-URI / oversized values.
|
|
@@ -7104,12 +7272,12 @@ ${sections}`
|
|
|
7104
7272
|
if (!appId || !clientSecret) {
|
|
7105
7273
|
return missingCredentialField(!appId ? "app_id" : "client_secret");
|
|
7106
7274
|
}
|
|
7107
|
-
const localTeamsChannel =
|
|
7275
|
+
const localTeamsChannel = join6(getHomeDir(), ".augmented", "_mcp", "teams-channel.js");
|
|
7108
7276
|
const agentDirMs = getAgentDir(codeName);
|
|
7109
7277
|
try {
|
|
7110
|
-
mkdirSync4(
|
|
7111
|
-
mkdirSync4(
|
|
7112
|
-
mkdirSync4(
|
|
7278
|
+
mkdirSync4(join6(agentDirMs, "msteams-pending-inbound", ".markers"), { recursive: true });
|
|
7279
|
+
mkdirSync4(join6(agentDirMs, "msteams-pending-interactions"), { recursive: true });
|
|
7280
|
+
mkdirSync4(join6(agentDirMs, "msteams-recovery-outbox"), { recursive: true });
|
|
7113
7281
|
} catch {
|
|
7114
7282
|
}
|
|
7115
7283
|
const tenantId = config["tenant_id"] ?? "common";
|
|
@@ -7191,7 +7359,7 @@ ${sections}`
|
|
|
7191
7359
|
}
|
|
7192
7360
|
if (channelId === "whatsapp") {
|
|
7193
7361
|
const provider = config["provider"] ?? "kapso";
|
|
7194
|
-
const localWhatsappChannel =
|
|
7362
|
+
const localWhatsappChannel = join6(getHomeDir(), ".augmented", "_mcp", "whatsapp-channel.js");
|
|
7195
7363
|
if (provider === "baileys") {
|
|
7196
7364
|
mcpServers["whatsapp"] = {
|
|
7197
7365
|
command: "node",
|
|
@@ -7211,7 +7379,7 @@ ${sections}`
|
|
|
7211
7379
|
const phoneNumberId = config["phone_number_id"];
|
|
7212
7380
|
if (projectApiKey && phoneNumberId) {
|
|
7213
7381
|
try {
|
|
7214
|
-
mkdirSync4(
|
|
7382
|
+
mkdirSync4(join6(getAgentDir(codeName), "whatsapp-pending-inbound"), { recursive: true });
|
|
7215
7383
|
} catch {
|
|
7216
7384
|
}
|
|
7217
7385
|
writeEnvIntegrationsForAgent(codeName, {
|
|
@@ -7243,7 +7411,7 @@ ${sections}`
|
|
|
7243
7411
|
return CHANNEL_WRITE_OK;
|
|
7244
7412
|
},
|
|
7245
7413
|
hasChannelCredentials(codeName, channelId) {
|
|
7246
|
-
const provisionMcpPath =
|
|
7414
|
+
const provisionMcpPath = join6(getAgentDir(codeName), "provision", ".mcp.json");
|
|
7247
7415
|
if (!existsSync4(provisionMcpPath))
|
|
7248
7416
|
return false;
|
|
7249
7417
|
try {
|
|
@@ -7255,7 +7423,7 @@ ${sections}`
|
|
|
7255
7423
|
},
|
|
7256
7424
|
removeChannelCredentials(codeName, channelId) {
|
|
7257
7425
|
const agentDir = getAgentDir(codeName);
|
|
7258
|
-
const mcpJsonPath =
|
|
7426
|
+
const mcpJsonPath = join6(agentDir, "provision", ".mcp.json");
|
|
7259
7427
|
modifyJsonConfig(mcpJsonPath, (config) => {
|
|
7260
7428
|
const mcpServers = config["mcpServers"];
|
|
7261
7429
|
if (!mcpServers || !(channelId in mcpServers))
|
|
@@ -7267,7 +7435,7 @@ ${sections}`
|
|
|
7267
7435
|
},
|
|
7268
7436
|
async updateAgentModel(codeName, model) {
|
|
7269
7437
|
const agentDir = getAgentDir(codeName);
|
|
7270
|
-
const settingsPath =
|
|
7438
|
+
const settingsPath = join6(agentDir, "provision", "settings.json");
|
|
7271
7439
|
let changed = false;
|
|
7272
7440
|
modifyJsonConfig(settingsPath, (config) => {
|
|
7273
7441
|
config["model"] = model;
|
|
@@ -7285,12 +7453,12 @@ ${sections}`
|
|
|
7285
7453
|
seedProfileConfig(codeName) {
|
|
7286
7454
|
const agentDir = getAgentDir(codeName);
|
|
7287
7455
|
const projectDir = getProjectDir2(codeName);
|
|
7288
|
-
mkdirSync4(
|
|
7456
|
+
mkdirSync4(join6(agentDir, "provision"), { recursive: true });
|
|
7289
7457
|
mkdirSync4(projectDir, { recursive: true });
|
|
7290
7458
|
},
|
|
7291
7459
|
syncScheduledTasks(codeName, tasks) {
|
|
7292
7460
|
const agentDir = getAgentDir(codeName);
|
|
7293
|
-
const schedulesPath =
|
|
7461
|
+
const schedulesPath = join6(agentDir, "schedules.json");
|
|
7294
7462
|
const mapped = mapScheduledTasks(tasks);
|
|
7295
7463
|
mkdirSync4(agentDir, { recursive: true });
|
|
7296
7464
|
writeFileSync5(schedulesPath, JSON.stringify({ schedules: mapped }, null, 2));
|
|
@@ -7413,7 +7581,7 @@ ${sections}`
|
|
|
7413
7581
|
xeroEnv.AGT_AGENT_ID = agentId;
|
|
7414
7582
|
xeroEnv.AGT_INTEGRATION_ID = xeroIntegration.id;
|
|
7415
7583
|
}
|
|
7416
|
-
const localXeroMcpPath =
|
|
7584
|
+
const localXeroMcpPath = join6(getHomeDir(), ".augmented", "_mcp", "xero.js");
|
|
7417
7585
|
this.writeMcpServer(codeName, "xero", {
|
|
7418
7586
|
command: "node",
|
|
7419
7587
|
args: [localXeroMcpPath],
|
|
@@ -7425,8 +7593,8 @@ ${sections}`
|
|
|
7425
7593
|
this.writeMcpServer(codeName, "postiz", buildPostizMcpEntry(postizIntegration));
|
|
7426
7594
|
}
|
|
7427
7595
|
const remoteOAuthProxyPaths = {
|
|
7428
|
-
proxyPath:
|
|
7429
|
-
tokenFile:
|
|
7596
|
+
proxyPath: join6(getHomeDir(), ".augmented", "_mcp", "remote-oauth-proxy.js"),
|
|
7597
|
+
tokenFile: join6(getProjectDir2(codeName), ".env.integrations")
|
|
7430
7598
|
};
|
|
7431
7599
|
for (const integration of integrations) {
|
|
7432
7600
|
const connectionKey = integration.connection_key;
|
|
@@ -7485,7 +7653,7 @@ ${sections}`
|
|
|
7485
7653
|
// ENG-6586 (D16): keep incremental cloud-broker wiring in sync with
|
|
7486
7654
|
// buildMcpJson so agents that add cloud-broker post-provision still
|
|
7487
7655
|
// forward the per-turn initiator.
|
|
7488
|
-
AGT_TURN_INITIATOR_FILE:
|
|
7656
|
+
AGT_TURN_INITIATOR_FILE: join6(getAgentDir(codeName), ".current-turn-initiator.json"),
|
|
7489
7657
|
PATH: process.env["PATH"] ?? "",
|
|
7490
7658
|
HOME: process.env["HOME"] ?? ""
|
|
7491
7659
|
}
|
|
@@ -7509,7 +7677,7 @@ ${sections}`
|
|
|
7509
7677
|
// ENG-6563 (D16): keep incremental xero-broker wiring in sync with
|
|
7510
7678
|
// buildMcpJson so agents that add xero-broker post-provision still
|
|
7511
7679
|
// forward the per-turn initiator.
|
|
7512
|
-
AGT_TURN_INITIATOR_FILE:
|
|
7680
|
+
AGT_TURN_INITIATOR_FILE: join6(getAgentDir(codeName), ".current-turn-initiator.json"),
|
|
7513
7681
|
PATH: process.env["PATH"] ?? "",
|
|
7514
7682
|
HOME: process.env["HOME"] ?? ""
|
|
7515
7683
|
}
|
|
@@ -7518,7 +7686,7 @@ ${sections}`
|
|
|
7518
7686
|
}
|
|
7519
7687
|
const hasAdminDebug = integrations.some((i) => i.definition_id === "augmented-admin");
|
|
7520
7688
|
if (hasAdminDebug) {
|
|
7521
|
-
const localAdminMcpPath =
|
|
7689
|
+
const localAdminMcpPath = join6(getHomeDir(), ".augmented", "_mcp", "augmented-admin.js");
|
|
7522
7690
|
this.writeMcpServer(codeName, "augmented-admin", {
|
|
7523
7691
|
command: "node",
|
|
7524
7692
|
args: [localAdminMcpPath],
|
|
@@ -7532,7 +7700,7 @@ ${sections}`
|
|
|
7532
7700
|
}
|
|
7533
7701
|
const hasSupport = integrations.some((i) => i.definition_id === "augmented-support");
|
|
7534
7702
|
if (hasSupport) {
|
|
7535
|
-
const localSupportMcpPath =
|
|
7703
|
+
const localSupportMcpPath = join6(getHomeDir(), ".augmented", "_mcp", "augmented-support.js");
|
|
7536
7704
|
this.writeMcpServer(codeName, "augmented-support", {
|
|
7537
7705
|
command: "node",
|
|
7538
7706
|
args: [localSupportMcpPath],
|
|
@@ -7546,7 +7714,7 @@ ${sections}`
|
|
|
7546
7714
|
}
|
|
7547
7715
|
const hasHelpKb = integrations.some((i) => i.definition_id === "augmented-help-kb");
|
|
7548
7716
|
if (hasHelpKb) {
|
|
7549
|
-
const localHelpKbMcpPath =
|
|
7717
|
+
const localHelpKbMcpPath = join6(getHomeDir(), ".augmented", "_mcp", "augmented-help-kb.js");
|
|
7550
7718
|
this.writeMcpServer(codeName, "augmented-help-kb", {
|
|
7551
7719
|
command: "node",
|
|
7552
7720
|
args: [localHelpKbMcpPath],
|
|
@@ -7562,7 +7730,7 @@ ${sections}`
|
|
|
7562
7730
|
const origamiStdioAgentId = resolveBrokerAgentId(codeName) ?? agentId;
|
|
7563
7731
|
const origamiStdioExpected = Boolean(origamiStdio?.stdioMcp === true && origamiStdio.id);
|
|
7564
7732
|
if (origamiStdioExpected && origamiStdioAgentId) {
|
|
7565
|
-
const localOrigamiMcpPath =
|
|
7733
|
+
const localOrigamiMcpPath = join6(getHomeDir(), ".augmented", "_mcp", "origami.js");
|
|
7566
7734
|
this.writeMcpServer(codeName, "origami", {
|
|
7567
7735
|
command: "node",
|
|
7568
7736
|
args: [localOrigamiMcpPath],
|
|
@@ -7583,7 +7751,7 @@ ${sections}`
|
|
|
7583
7751
|
agentId: computerUseAgentId,
|
|
7584
7752
|
agentCodeName: codeName,
|
|
7585
7753
|
config: computerUseRow.config,
|
|
7586
|
-
proxyPath:
|
|
7754
|
+
proxyPath: join6(getHomeDir(), ".augmented", "_mcp", "computer-use-proxy.js"),
|
|
7587
7755
|
agentDir: getAgentDir(codeName)
|
|
7588
7756
|
});
|
|
7589
7757
|
if (rendered.entry) {
|
|
@@ -7707,7 +7875,7 @@ ${sections}`
|
|
|
7707
7875
|
}
|
|
7708
7876
|
}
|
|
7709
7877
|
const projectDir = getProjectDir2(codeName);
|
|
7710
|
-
const claudeMdPath =
|
|
7878
|
+
const claudeMdPath = join6(projectDir, "CLAUDE.md");
|
|
7711
7879
|
try {
|
|
7712
7880
|
const existing = readFileSync5(claudeMdPath, "utf-8");
|
|
7713
7881
|
const renderSection = options?.renderClaudeMdSection === true;
|
|
@@ -7728,10 +7896,10 @@ ${sections}`
|
|
|
7728
7896
|
if (updated !== existing)
|
|
7729
7897
|
writeFileSync5(claudeMdPath, updated);
|
|
7730
7898
|
const agentDir2 = getAgentDir(codeName);
|
|
7731
|
-
const envSrc =
|
|
7899
|
+
const envSrc = join6(agentDir2, ".env.integrations");
|
|
7732
7900
|
try {
|
|
7733
7901
|
const envContent = readFileSync5(envSrc, "utf-8");
|
|
7734
|
-
const envDest =
|
|
7902
|
+
const envDest = join6(projectDir, ".env.integrations");
|
|
7735
7903
|
writeFileSync5(envDest, envContent, { mode: SECRET_FILE_MODE });
|
|
7736
7904
|
try {
|
|
7737
7905
|
chmodSync4(envDest, SECRET_FILE_MODE);
|
|
@@ -7746,8 +7914,8 @@ ${sections}`
|
|
|
7746
7914
|
},
|
|
7747
7915
|
writeMcpServer(codeName, serverId, config) {
|
|
7748
7916
|
const agentDir = getAgentDir(codeName);
|
|
7749
|
-
const mcpJsonPath =
|
|
7750
|
-
mkdirSync4(
|
|
7917
|
+
const mcpJsonPath = join6(agentDir, "provision", ".mcp.json");
|
|
7918
|
+
mkdirSync4(join6(agentDir, "provision"), { recursive: true });
|
|
7751
7919
|
let mcpConfig;
|
|
7752
7920
|
try {
|
|
7753
7921
|
mcpConfig = JSON.parse(readFileSync5(mcpJsonPath, "utf-8"));
|
|
@@ -7794,7 +7962,7 @@ ${sections}`
|
|
|
7794
7962
|
}
|
|
7795
7963
|
},
|
|
7796
7964
|
getMcpPath(codeName) {
|
|
7797
|
-
return
|
|
7965
|
+
return join6(getAgentDir(codeName), "provision", ".mcp.json");
|
|
7798
7966
|
},
|
|
7799
7967
|
/**
|
|
7800
7968
|
* ENG-7994: the declared servers from `provision/.mcp.json`. Mirrors what the
|
|
@@ -7805,7 +7973,7 @@ ${sections}`
|
|
|
7805
7973
|
readMcpServers(codeName) {
|
|
7806
7974
|
let parsed;
|
|
7807
7975
|
try {
|
|
7808
|
-
parsed = JSON.parse(readFileSync5(
|
|
7976
|
+
parsed = JSON.parse(readFileSync5(join6(getAgentDir(codeName), "provision", ".mcp.json"), "utf-8"));
|
|
7809
7977
|
} catch {
|
|
7810
7978
|
return {};
|
|
7811
7979
|
}
|
|
@@ -7817,13 +7985,13 @@ ${sections}`
|
|
|
7817
7985
|
return mcpServers;
|
|
7818
7986
|
},
|
|
7819
7987
|
syncMcpMirror(codeName) {
|
|
7820
|
-
const provisionMcpPath =
|
|
7988
|
+
const provisionMcpPath = join6(getAgentDir(codeName), "provision", ".mcp.json");
|
|
7821
7989
|
let content;
|
|
7822
7990
|
try {
|
|
7823
7991
|
content = readFileSync5(provisionMcpPath, "utf-8");
|
|
7824
7992
|
} catch (err) {
|
|
7825
7993
|
const missing = err.code === "ENOENT";
|
|
7826
|
-
if (!missing || existsSync4(
|
|
7994
|
+
if (!missing || existsSync4(join6(getProjectDir2(codeName), ".mcp.json"))) {
|
|
7827
7995
|
noteMcpWriteFailure(codeName);
|
|
7828
7996
|
process.stderr.write(`[claudecode] MCP mirror repair for '${codeName}': provision/.mcp.json ${missing ? "is missing" : "is unreadable"} while a project mirror exists; the mirror cannot be repaired from it
|
|
7829
7997
|
`);
|
|
@@ -7840,7 +8008,7 @@ ${sections}`
|
|
|
7840
8008
|
readMcpServersOrNull(codeName) {
|
|
7841
8009
|
let raw;
|
|
7842
8010
|
try {
|
|
7843
|
-
raw = readFileSync5(
|
|
8011
|
+
raw = readFileSync5(join6(getAgentDir(codeName), "provision", ".mcp.json"), "utf-8");
|
|
7844
8012
|
} catch (err) {
|
|
7845
8013
|
return err.code === "ENOENT" ? {} : null;
|
|
7846
8014
|
}
|
|
@@ -7861,7 +8029,7 @@ ${sections}`
|
|
|
7861
8029
|
},
|
|
7862
8030
|
removeMcpServer(codeName, serverId) {
|
|
7863
8031
|
const agentDir = getAgentDir(codeName);
|
|
7864
|
-
const mcpJsonPath =
|
|
8032
|
+
const mcpJsonPath = join6(agentDir, "provision", ".mcp.json");
|
|
7865
8033
|
let mcpConfig;
|
|
7866
8034
|
try {
|
|
7867
8035
|
mcpConfig = JSON.parse(readFileSync5(mcpJsonPath, "utf-8"));
|
|
@@ -7883,17 +8051,17 @@ ${sections}`
|
|
|
7883
8051
|
const READ_WRITE_MODE = 420;
|
|
7884
8052
|
const agentDir = getAgentDir(codeName);
|
|
7885
8053
|
const projectDir = getProjectDir2(codeName);
|
|
7886
|
-
for (const baseDir of [
|
|
7887
|
-
const skillDir =
|
|
8054
|
+
for (const baseDir of [join6(agentDir, "skills"), join6(projectDir, ".claude", "skills")]) {
|
|
8055
|
+
const skillDir = join6(baseDir, skillId);
|
|
7888
8056
|
mkdirSync4(skillDir, { recursive: true });
|
|
7889
8057
|
for (const file of files) {
|
|
7890
8058
|
assertSafeRelativePath(file.relativePath);
|
|
7891
|
-
const filePath =
|
|
7892
|
-
const rel =
|
|
8059
|
+
const filePath = join6(skillDir, file.relativePath);
|
|
8060
|
+
const rel = relative2(skillDir, filePath);
|
|
7893
8061
|
if (rel.startsWith("..") || rel === "") {
|
|
7894
8062
|
throw new Error(`Path traversal detected: ${file.relativePath} resolves outside ${skillDir}`);
|
|
7895
8063
|
}
|
|
7896
|
-
mkdirSync4(
|
|
8064
|
+
mkdirSync4(join6(filePath, ".."), { recursive: true });
|
|
7897
8065
|
if (isPluginManaged && existsSync4(filePath)) {
|
|
7898
8066
|
try {
|
|
7899
8067
|
chmodSync4(filePath, READ_WRITE_MODE);
|
|
@@ -7912,7 +8080,7 @@ ${sections}`
|
|
|
7912
8080
|
},
|
|
7913
8081
|
installPlugin(codeName, pluginId, pluginPath, pluginConfig) {
|
|
7914
8082
|
const agentDir = getAgentDir(codeName);
|
|
7915
|
-
const pluginsJsonPath =
|
|
8083
|
+
const pluginsJsonPath = join6(agentDir, "plugins.json");
|
|
7916
8084
|
mkdirSync4(agentDir, { recursive: true });
|
|
7917
8085
|
let pluginsConfig;
|
|
7918
8086
|
try {
|
|
@@ -7945,11 +8113,11 @@ ${sections}`
|
|
|
7945
8113
|
assertValidCodeName(codeName);
|
|
7946
8114
|
assertValidCodeName(plugin.slug);
|
|
7947
8115
|
const projectDir = getProjectDir2(codeName);
|
|
7948
|
-
const claudeDir =
|
|
8116
|
+
const claudeDir = join6(projectDir, ".claude");
|
|
7949
8117
|
mkdirSync4(claudeDir, { recursive: true });
|
|
7950
8118
|
const sourceSpec = options?.scriptSource ?? `augmented-plugin:${plugin.slug}`;
|
|
7951
8119
|
this.installPlugin(codeName, plugin.slug, sourceSpec, contextValues);
|
|
7952
|
-
const installedDir =
|
|
8120
|
+
const installedDir = join6(projectDir, ".claude", "plugins", plugin.slug);
|
|
7953
8121
|
for (const skill of plugin.skills) {
|
|
7954
8122
|
const skillId = skill.id;
|
|
7955
8123
|
assertValidCodeName(skillId);
|
|
@@ -7961,7 +8129,7 @@ ${sections}`
|
|
|
7961
8129
|
}
|
|
7962
8130
|
const scriptsConfig = plugin.scripts;
|
|
7963
8131
|
if (scriptsConfig?.hooks) {
|
|
7964
|
-
const settingsPath =
|
|
8132
|
+
const settingsPath = join6(claudeDir, "settings.local.json");
|
|
7965
8133
|
let settings = {};
|
|
7966
8134
|
try {
|
|
7967
8135
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -8001,7 +8169,7 @@ ${sections}`
|
|
|
8001
8169
|
writeFileSync5(settingsPath, JSON.stringify(settings, null, 2));
|
|
8002
8170
|
}
|
|
8003
8171
|
if (plugin.allowed_tools.length > 0) {
|
|
8004
|
-
const settingsPath =
|
|
8172
|
+
const settingsPath = join6(claudeDir, "settings.local.json");
|
|
8005
8173
|
let settings = {};
|
|
8006
8174
|
try {
|
|
8007
8175
|
settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
@@ -8019,14 +8187,14 @@ ${sections}`
|
|
|
8019
8187
|
writeFileSync5(settingsPath, JSON.stringify(settings, null, 2));
|
|
8020
8188
|
}
|
|
8021
8189
|
if (contextValues && Object.keys(contextValues).length > 0) {
|
|
8022
|
-
const configDir =
|
|
8190
|
+
const configDir = join6(projectDir, `.${plugin.slug}`);
|
|
8023
8191
|
mkdirSync4(configDir, { recursive: true });
|
|
8024
|
-
writeFileSync5(
|
|
8192
|
+
writeFileSync5(join6(configDir, "config.json"), JSON.stringify(contextValues, null, 2));
|
|
8025
8193
|
}
|
|
8026
8194
|
},
|
|
8027
8195
|
executePluginHook(ctx) {
|
|
8028
8196
|
assertValidCodeName(ctx.codeName);
|
|
8029
|
-
const agentRootDir =
|
|
8197
|
+
const agentRootDir = join6(getHomeDir(), ".augmented", ctx.codeName);
|
|
8030
8198
|
const projectDir = getProjectDir2(ctx.codeName);
|
|
8031
8199
|
mkdirSync4(agentRootDir, { recursive: true });
|
|
8032
8200
|
mkdirSync4(projectDir, { recursive: true });
|
|
@@ -8083,7 +8251,7 @@ function jsonOutput(data) {
|
|
|
8083
8251
|
}
|
|
8084
8252
|
|
|
8085
8253
|
// src/lib/atomic-write.ts
|
|
8086
|
-
import { closeSync, fchmodSync, fchownSync, fsyncSync, openSync, writeFileSync as writeFileSync6, renameSync as renameSync5, mkdirSync as mkdirSync5, unlinkSync as
|
|
8254
|
+
import { closeSync as closeSync2, fchmodSync, fchownSync, fsyncSync, openSync as openSync2, writeFileSync as writeFileSync6, renameSync as renameSync5, mkdirSync as mkdirSync5, unlinkSync as unlinkSync5 } from "fs";
|
|
8087
8255
|
import { dirname as dirname4 } from "path";
|
|
8088
8256
|
function atomicWriteFileSync(path, data, own) {
|
|
8089
8257
|
const dirPath = dirname4(path);
|
|
@@ -8092,7 +8260,7 @@ function atomicWriteFileSync(path, data, own) {
|
|
|
8092
8260
|
mkdirSync5(dirPath, { recursive: true });
|
|
8093
8261
|
} catch {
|
|
8094
8262
|
}
|
|
8095
|
-
const fd =
|
|
8263
|
+
const fd = openSync2(tmpPath, "w", 420);
|
|
8096
8264
|
try {
|
|
8097
8265
|
try {
|
|
8098
8266
|
writeFileSync6(fd, data);
|
|
@@ -8108,22 +8276,22 @@ function atomicWriteFileSync(path, data, own) {
|
|
|
8108
8276
|
} catch {
|
|
8109
8277
|
}
|
|
8110
8278
|
} finally {
|
|
8111
|
-
|
|
8279
|
+
closeSync2(fd);
|
|
8112
8280
|
}
|
|
8113
8281
|
renameSync5(tmpPath, path);
|
|
8114
8282
|
} catch (err) {
|
|
8115
8283
|
try {
|
|
8116
|
-
|
|
8284
|
+
unlinkSync5(tmpPath);
|
|
8117
8285
|
} catch {
|
|
8118
8286
|
}
|
|
8119
8287
|
throw err;
|
|
8120
8288
|
}
|
|
8121
8289
|
try {
|
|
8122
|
-
const dirFd =
|
|
8290
|
+
const dirFd = openSync2(dirPath, "r");
|
|
8123
8291
|
try {
|
|
8124
8292
|
fsyncSync(dirFd);
|
|
8125
8293
|
} finally {
|
|
8126
|
-
|
|
8294
|
+
closeSync2(dirFd);
|
|
8127
8295
|
}
|
|
8128
8296
|
} catch {
|
|
8129
8297
|
}
|
|
@@ -8132,9 +8300,9 @@ function atomicWriteFileSync(path, data, own) {
|
|
|
8132
8300
|
// src/lib/feature-flags-host.ts
|
|
8133
8301
|
import { existsSync as existsSync5, readFileSync as readFileSync6, rmSync as rmSync3, statSync as statSync2 } from "fs";
|
|
8134
8302
|
import { homedir as homedir4 } from "os";
|
|
8135
|
-
import { join as
|
|
8303
|
+
import { join as join7 } from "path";
|
|
8136
8304
|
function defaultFlagsCachePath(configDir) {
|
|
8137
|
-
return
|
|
8305
|
+
return join7(configDir, "flags-cache.json");
|
|
8138
8306
|
}
|
|
8139
8307
|
function readFlagsCache(path) {
|
|
8140
8308
|
try {
|
|
@@ -8192,6 +8360,7 @@ function resolveAllFlags(heartbeatFlags, env = process.env) {
|
|
|
8192
8360
|
(definition) => resolveFlagFromLayers(definition, heartbeatFlags, env)
|
|
8193
8361
|
);
|
|
8194
8362
|
}
|
|
8363
|
+
var PER_AGENT_FLAG_EVALUATION_MAX_AGE_MS = 5 * 60 * 1e3;
|
|
8195
8364
|
var HostFlagStore = class {
|
|
8196
8365
|
heartbeatFlags = {};
|
|
8197
8366
|
/**
|
|
@@ -8220,6 +8389,9 @@ var HostFlagStore = class {
|
|
|
8220
8389
|
* flag ships dark, so it stays empty and every agent resolves host-wide).
|
|
8221
8390
|
*/
|
|
8222
8391
|
booleanFlagsByAgent = {};
|
|
8392
|
+
/** ENG-11877: agents the latest heartbeat really evaluated. Null until one says, or when it failed. */
|
|
8393
|
+
perAgentFlagsEvaluated = null;
|
|
8394
|
+
perAgentFlagsEvaluatedAt = 0;
|
|
8223
8395
|
/**
|
|
8224
8396
|
* The `flags_schema_version` from the most recent heartbeat, retained so a
|
|
8225
8397
|
* per-agent-map write (which carries no schema version of its own) persists
|
|
@@ -8409,12 +8581,12 @@ var HostFlagStore = class {
|
|
|
8409
8581
|
* The in-memory state stays authoritative and the next heartbeat retries.
|
|
8410
8582
|
*/
|
|
8411
8583
|
persistPerAgentCaches(updatedAt) {
|
|
8412
|
-
const root =
|
|
8584
|
+
const root = join7(homedir4(), ".augmented");
|
|
8413
8585
|
for (const agentId of this.mirrorAgentIds) {
|
|
8414
8586
|
try {
|
|
8415
|
-
const dir =
|
|
8587
|
+
const dir = join7(root, agentId);
|
|
8416
8588
|
if (!existsSync5(dir)) continue;
|
|
8417
|
-
writeFlagsCache(
|
|
8589
|
+
writeFlagsCache(join7(dir, "flags-cache.json"), {
|
|
8418
8590
|
schema_version: this.lastSchemaVersion,
|
|
8419
8591
|
updated_at: updatedAt,
|
|
8420
8592
|
flags: this.flagsForAgent(agentId),
|
|
@@ -8428,7 +8600,7 @@ var HostFlagStore = class {
|
|
|
8428
8600
|
} catch (err) {
|
|
8429
8601
|
let removed = "left in place";
|
|
8430
8602
|
try {
|
|
8431
|
-
rmSync3(
|
|
8603
|
+
rmSync3(join7(root, agentId, "flags-cache.json"), { force: true, recursive: true });
|
|
8432
8604
|
removed = "stale mirror removed";
|
|
8433
8605
|
} catch (rmErr) {
|
|
8434
8606
|
removed = `stale mirror could NOT be removed: ${rmErr.message}`;
|
|
@@ -8500,6 +8672,18 @@ var HostFlagStore = class {
|
|
|
8500
8672
|
if (resolved && typeof resolved.value === "boolean") return resolved.value;
|
|
8501
8673
|
return definition?.flagType === "boolean" ? definition.defaultValue : false;
|
|
8502
8674
|
}
|
|
8675
|
+
/**
|
|
8676
|
+
* ENG-11877: can this agent's per-agent flags be trusted right now? `confirmed`:
|
|
8677
|
+
* the latest heartbeat evaluated it. `not-evaluated`: it evaluated others, not this
|
|
8678
|
+
* one (only active agents are evaluated). `unknown`: no evaluation to go on, or
|
|
8679
|
+
* the last one is too old. A failed heartbeat updates nothing here, so without the
|
|
8680
|
+
* age check an outage would leave stale answers trusted for as long as it lasted.
|
|
8681
|
+
*/
|
|
8682
|
+
perAgentFlagState(agentId, nowMs = Date.now()) {
|
|
8683
|
+
if (this.perAgentFlagsEvaluated === null) return "unknown";
|
|
8684
|
+
if (nowMs - this.perAgentFlagsEvaluatedAt > PER_AGENT_FLAG_EVALUATION_MAX_AGE_MS) return "unknown";
|
|
8685
|
+
return this.perAgentFlagsEvaluated.has(agentId) ? "confirmed" : "not-evaluated";
|
|
8686
|
+
}
|
|
8503
8687
|
/**
|
|
8504
8688
|
* ENG-7891 / ADR-0049 slice 3: resolve a BOOLEAN flag FOR A SPECIFIC AGENT.
|
|
8505
8689
|
* Precedence mirrors {@link getStringForAgent}:
|
|
@@ -8571,7 +8755,9 @@ var HostFlagStore = class {
|
|
|
8571
8755
|
* value until the next heartbeat rather than rehydrating a stale opt-in for a
|
|
8572
8756
|
* one-way-door migration.
|
|
8573
8757
|
*/
|
|
8574
|
-
applyBooleanFlagsByAgent(map) {
|
|
8758
|
+
applyBooleanFlagsByAgent(map, evaluatedAgentIds, nowMs = Date.now()) {
|
|
8759
|
+
this.perAgentFlagsEvaluated = Array.isArray(evaluatedAgentIds) ? new Set(evaluatedAgentIds.filter((id) => typeof id === "string")) : null;
|
|
8760
|
+
this.perAgentFlagsEvaluatedAt = nowMs;
|
|
8575
8761
|
if (!map || typeof map !== "object") {
|
|
8576
8762
|
const before = this.booleanFlagsByAgent;
|
|
8577
8763
|
this.booleanFlagsByAgent = {};
|
|
@@ -10327,7 +10513,7 @@ function verdictForUnavailableMcpConfig(cause, ctx) {
|
|
|
10327
10513
|
}
|
|
10328
10514
|
|
|
10329
10515
|
// src/lib/connectivity-probe-context.ts
|
|
10330
|
-
import { delimiter as pathDelimiter, join as
|
|
10516
|
+
import { delimiter as pathDelimiter, join as join8 } from "path";
|
|
10331
10517
|
import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
|
|
10332
10518
|
import { homedir as homedir5 } from "os";
|
|
10333
10519
|
|
|
@@ -11262,7 +11448,7 @@ function resolveHttpServerEntry(entry, env) {
|
|
|
11262
11448
|
}
|
|
11263
11449
|
function readMcpServerEntry(projectDir, serverKey) {
|
|
11264
11450
|
try {
|
|
11265
|
-
const raw = readFileSync7(
|
|
11451
|
+
const raw = readFileSync7(join8(projectDir, ".mcp.json"), "utf-8");
|
|
11266
11452
|
const servers = JSON.parse(raw).mcpServers ?? {};
|
|
11267
11453
|
return servers[serverKey] ?? null;
|
|
11268
11454
|
} catch {
|
|
@@ -11272,7 +11458,7 @@ function readMcpServerEntry(projectDir, serverKey) {
|
|
|
11272
11458
|
function readMcpHttpServerConfig(projectDir, serverKey, env) {
|
|
11273
11459
|
let servers;
|
|
11274
11460
|
try {
|
|
11275
|
-
const raw = readFileSync7(
|
|
11461
|
+
const raw = readFileSync7(join8(projectDir, ".mcp.json"), "utf-8");
|
|
11276
11462
|
servers = JSON.parse(raw).mcpServers ?? {};
|
|
11277
11463
|
} catch {
|
|
11278
11464
|
return { ok: false, cause: "file-unreadable" };
|
|
@@ -11284,7 +11470,7 @@ function readMcpHttpServerConfig(projectDir, serverKey, env) {
|
|
|
11284
11470
|
}
|
|
11285
11471
|
function resolveDeclaredServerKey(projectDir, definitionId, derivedKey) {
|
|
11286
11472
|
try {
|
|
11287
|
-
const raw = readFileSync7(
|
|
11473
|
+
const raw = readFileSync7(join8(projectDir, ".mcp.json"), "utf-8");
|
|
11288
11474
|
const servers = JSON.parse(raw).mcpServers ?? {};
|
|
11289
11475
|
const declared = Object.keys(servers);
|
|
11290
11476
|
if (derivedKey !== definitionId && derivedKey !== sanitizeServerKey(definitionId)) {
|
|
@@ -11326,7 +11512,7 @@ function resolveStdioServerEntry(entry, env) {
|
|
|
11326
11512
|
function readMcpStdioServerConfig(projectDir, serverKey, env) {
|
|
11327
11513
|
let servers;
|
|
11328
11514
|
try {
|
|
11329
|
-
const raw = readFileSync7(
|
|
11515
|
+
const raw = readFileSync7(join8(projectDir, ".mcp.json"), "utf-8");
|
|
11330
11516
|
servers = JSON.parse(raw).mcpServers ?? {};
|
|
11331
11517
|
} catch {
|
|
11332
11518
|
return { ok: false, cause: "file-unreadable" };
|
|
@@ -11354,13 +11540,13 @@ function toolkitPathDirs() {
|
|
|
11354
11540
|
const home = process.env.HOME?.trim() || homedir5();
|
|
11355
11541
|
return [
|
|
11356
11542
|
...PROBE_TOOLKIT_PATH_DIRS,
|
|
11357
|
-
...PROBE_HOME_RELATIVE_PATH_SEGMENTS.map((seg) =>
|
|
11543
|
+
...PROBE_HOME_RELATIVE_PATH_SEGMENTS.map((seg) => join8(home, seg))
|
|
11358
11544
|
];
|
|
11359
11545
|
}
|
|
11360
11546
|
function buildProbeEnv(projectDir, agentId) {
|
|
11361
11547
|
const probeEnv = { ...process.env };
|
|
11362
11548
|
try {
|
|
11363
|
-
const envIntPath =
|
|
11549
|
+
const envIntPath = join8(projectDir, ".env.integrations");
|
|
11364
11550
|
if (existsSync6(envIntPath)) {
|
|
11365
11551
|
Object.assign(probeEnv, parseEnvIntegrations(readFileSync7(envIntPath, "utf-8")));
|
|
11366
11552
|
}
|
|
@@ -11370,7 +11556,7 @@ function buildProbeEnv(projectDir, agentId) {
|
|
|
11370
11556
|
probeEnv.AGT_AGENT_ID = agentId.trim();
|
|
11371
11557
|
}
|
|
11372
11558
|
try {
|
|
11373
|
-
const agentBinDir =
|
|
11559
|
+
const agentBinDir = join8(projectDir, ".claude", "agt-bin");
|
|
11374
11560
|
if (existsSync6(agentBinDir)) {
|
|
11375
11561
|
const parts = probeEnv.PATH ? probeEnv.PATH.split(pathDelimiter) : [];
|
|
11376
11562
|
parts.unshift(agentBinDir);
|
|
@@ -11769,7 +11955,7 @@ var TunnelWatcher = class {
|
|
|
11769
11955
|
// src/lib/session-tool-bind-probe-host.ts
|
|
11770
11956
|
import { execFileSync as syncExecFile } from "child_process";
|
|
11771
11957
|
import { readFileSync as readFileSync8 } from "fs";
|
|
11772
|
-
import { join as
|
|
11958
|
+
import { join as join9 } from "path";
|
|
11773
11959
|
import { dirname as dirname5 } from "path";
|
|
11774
11960
|
function termsRestrictedServerKeys(integrations, isRestricted = isProbeRestrictedByProviderTerms) {
|
|
11775
11961
|
const keys = /* @__PURE__ */ new Set();
|
|
@@ -11813,7 +11999,7 @@ async function gatherSessionToolBindProbe(agent, integrations, projectDir, opts)
|
|
|
11813
11999
|
if (integrations.length === 0) return null;
|
|
11814
12000
|
let mcpRaw = null;
|
|
11815
12001
|
try {
|
|
11816
|
-
mcpRaw = readFileSync8(
|
|
12002
|
+
mcpRaw = readFileSync8(join9(projectDir, ".mcp.json"), "utf-8");
|
|
11817
12003
|
} catch {
|
|
11818
12004
|
mcpRaw = null;
|
|
11819
12005
|
}
|
|
@@ -11917,7 +12103,7 @@ var SLACK_MCP_SERVER_KEY = "slack";
|
|
|
11917
12103
|
function readSlackTransportDownKeys(projectDir) {
|
|
11918
12104
|
const none = /* @__PURE__ */ new Set();
|
|
11919
12105
|
try {
|
|
11920
|
-
const raw = readFileSync8(
|
|
12106
|
+
const raw = readFileSync8(join9(dirname5(projectDir), SLACK_SOCKET_STATE_FILENAME), "utf-8");
|
|
11921
12107
|
const state = parseSlackSocketState(raw, Date.now());
|
|
11922
12108
|
return isSlackInboundTransportDown(state, SLACK_TRANSPORT_DOWN_AFTER_MS) ? /* @__PURE__ */ new Set([SLACK_MCP_SERVER_KEY]) : none;
|
|
11923
12109
|
} catch {
|
|
@@ -12004,7 +12190,7 @@ function describeWorkerModuleFailure(err) {
|
|
|
12004
12190
|
// src/lib/drain-transcript-flush.ts
|
|
12005
12191
|
import { existsSync as existsSync7, readdirSync as readdirSync2 } from "fs";
|
|
12006
12192
|
import { homedir as homedir6 } from "os";
|
|
12007
|
-
import { dirname as dirname6, join as
|
|
12193
|
+
import { dirname as dirname6, join as join10, relative as relative3, sep } from "path";
|
|
12008
12194
|
import { spawn as spawn2 } from "child_process";
|
|
12009
12195
|
|
|
12010
12196
|
// src/lib/host-archive-address.ts
|
|
@@ -12048,7 +12234,7 @@ function readHostArchiveAddress(path) {
|
|
|
12048
12234
|
|
|
12049
12235
|
// src/lib/drain-transcript-flush.ts
|
|
12050
12236
|
function sessionsBaseDir() {
|
|
12051
|
-
return
|
|
12237
|
+
return join10(homedir6(), ".claude", "projects");
|
|
12052
12238
|
}
|
|
12053
12239
|
var PER_FILE_UPLOAD_TIMEOUT_MS = 3e4;
|
|
12054
12240
|
var UPLOAD_CONCURRENCY = 4;
|
|
@@ -12059,7 +12245,7 @@ function listJsonlFiles(dir) {
|
|
|
12059
12245
|
const out = [];
|
|
12060
12246
|
const walk = (d) => {
|
|
12061
12247
|
for (const entry of readdirSync2(d, { withFileTypes: true })) {
|
|
12062
|
-
const full =
|
|
12248
|
+
const full = join10(d, entry.name);
|
|
12063
12249
|
if (entry.isDirectory()) walk(full);
|
|
12064
12250
|
else if (entry.isFile() && entry.name.endsWith(".jsonl")) out.push(full);
|
|
12065
12251
|
}
|
|
@@ -12071,12 +12257,12 @@ function listJsonlFiles(dir) {
|
|
|
12071
12257
|
return out;
|
|
12072
12258
|
}
|
|
12073
12259
|
function transcriptObjectKey(keyPrefix, baseDir, file) {
|
|
12074
|
-
const rel =
|
|
12260
|
+
const rel = relative3(baseDir, file).split(sep).join("/");
|
|
12075
12261
|
if (!rel || rel.startsWith("../") || rel === "..") return null;
|
|
12076
12262
|
return `${keyPrefix.replace(/\/+$/, "")}/${rel}`;
|
|
12077
12263
|
}
|
|
12078
12264
|
function drainManifestObjectKey(keyPrefix, baseDir, transcriptDir) {
|
|
12079
|
-
return transcriptObjectKey(keyPrefix, baseDir,
|
|
12265
|
+
return transcriptObjectKey(keyPrefix, baseDir, join10(transcriptDir, DRAIN_MANIFEST_FILENAME));
|
|
12080
12266
|
}
|
|
12081
12267
|
async function flushAgentTranscriptsOnDrain(codeName, deps) {
|
|
12082
12268
|
const dir = deps.resolveTranscriptDir(codeName);
|
|
@@ -12228,7 +12414,7 @@ function drainTranscriptFlushDeps(log2) {
|
|
|
12228
12414
|
// tree — the thing host-archive-address.ts's header warns about.
|
|
12229
12415
|
readSourceLayout: (codeName) => {
|
|
12230
12416
|
const agentDir = dirname6(getProjectDir(codeName));
|
|
12231
|
-
const codeNameDir =
|
|
12417
|
+
const codeNameDir = join10(homedir6(), ".augmented", codeName);
|
|
12232
12418
|
return { layout: agentDir === codeNameDir ? "codename-keyed" : "id-keyed", agentDir };
|
|
12233
12419
|
},
|
|
12234
12420
|
readSessionPin: (codeName) => readDailySessionPin(codeName),
|
|
@@ -12315,7 +12501,7 @@ function decidePin(opts) {
|
|
|
12315
12501
|
|
|
12316
12502
|
// src/commands/setup.ts
|
|
12317
12503
|
import { existsSync as existsSync9, readFileSync as readFileSync11, writeFileSync as writeFileSync8, mkdirSync as mkdirSync7, accessSync, constants as fsConstants } from "fs";
|
|
12318
|
-
import { join as
|
|
12504
|
+
import { join as join12, dirname as dirname7 } from "path";
|
|
12319
12505
|
import { homedir as homedir7 } from "os";
|
|
12320
12506
|
import chalk3 from "chalk";
|
|
12321
12507
|
import ora from "ora";
|
|
@@ -12347,15 +12533,15 @@ function table(headers, rows) {
|
|
|
12347
12533
|
}
|
|
12348
12534
|
|
|
12349
12535
|
// src/lib/watchdog.ts
|
|
12350
|
-
import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, unlinkSync as
|
|
12351
|
-
import { join as
|
|
12536
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, unlinkSync as unlinkSync6, existsSync as existsSync8, mkdirSync as mkdirSync6, openSync as openSync3, closeSync as closeSync3, chmodSync as chmodSync5 } from "fs";
|
|
12537
|
+
import { join as join11 } from "path";
|
|
12352
12538
|
import { spawn as spawn3, execFileSync as execFileSync3 } from "child_process";
|
|
12353
|
-
var DEFAULT_CONFIG_DIR =
|
|
12539
|
+
var DEFAULT_CONFIG_DIR = join11(process.env["HOME"] ?? "/tmp", ".augmented");
|
|
12354
12540
|
function getManagerPaths(configDir) {
|
|
12355
12541
|
return {
|
|
12356
|
-
pidFile:
|
|
12357
|
-
stateFile:
|
|
12358
|
-
logFile:
|
|
12542
|
+
pidFile: join11(configDir, "manager.pid"),
|
|
12543
|
+
stateFile: join11(configDir, "manager-state.json"),
|
|
12544
|
+
logFile: join11(configDir, "manager.log")
|
|
12359
12545
|
};
|
|
12360
12546
|
}
|
|
12361
12547
|
function ensureDir(configDir) {
|
|
@@ -12378,7 +12564,7 @@ function readPidFile(configDir) {
|
|
|
12378
12564
|
}
|
|
12379
12565
|
function removePidFile(configDir) {
|
|
12380
12566
|
try {
|
|
12381
|
-
|
|
12567
|
+
unlinkSync6(getManagerPaths(configDir).pidFile);
|
|
12382
12568
|
} catch {
|
|
12383
12569
|
}
|
|
12384
12570
|
}
|
|
@@ -12423,7 +12609,7 @@ function readStateFile(configDir) {
|
|
|
12423
12609
|
}
|
|
12424
12610
|
function removeStateFile(configDir) {
|
|
12425
12611
|
try {
|
|
12426
|
-
|
|
12612
|
+
unlinkSync6(getManagerPaths(configDir).stateFile);
|
|
12427
12613
|
} catch {
|
|
12428
12614
|
}
|
|
12429
12615
|
}
|
|
@@ -12447,7 +12633,7 @@ function startWatchdog(opts) {
|
|
|
12447
12633
|
if (opts.detached) {
|
|
12448
12634
|
ensureDir(configDir);
|
|
12449
12635
|
const { logFile } = getManagerPaths(configDir);
|
|
12450
|
-
const logFd =
|
|
12636
|
+
const logFd = openSync3(logFile, "a", 384);
|
|
12451
12637
|
try {
|
|
12452
12638
|
chmodSync5(logFile, 384);
|
|
12453
12639
|
} catch {
|
|
@@ -12463,7 +12649,7 @@ function startWatchdog(opts) {
|
|
|
12463
12649
|
}
|
|
12464
12650
|
);
|
|
12465
12651
|
child.unref();
|
|
12466
|
-
|
|
12652
|
+
closeSync3(logFd);
|
|
12467
12653
|
if (!child.pid) {
|
|
12468
12654
|
throw new Error("Failed to spawn detached manager process");
|
|
12469
12655
|
}
|
|
@@ -12547,15 +12733,15 @@ function detectShellProfile() {
|
|
|
12547
12733
|
const shell = process.env["SHELL"] ?? "";
|
|
12548
12734
|
const home = homedir7();
|
|
12549
12735
|
if (shell.includes("zsh")) {
|
|
12550
|
-
return
|
|
12736
|
+
return join12(home, ".zshrc");
|
|
12551
12737
|
}
|
|
12552
12738
|
if (shell.includes("fish")) {
|
|
12553
|
-
const fishConfig =
|
|
12739
|
+
const fishConfig = join12(home, ".config", "fish", "config.fish");
|
|
12554
12740
|
return fishConfig;
|
|
12555
12741
|
}
|
|
12556
|
-
const bashrc =
|
|
12742
|
+
const bashrc = join12(home, ".bashrc");
|
|
12557
12743
|
if (existsSync9(bashrc)) return bashrc;
|
|
12558
|
-
return
|
|
12744
|
+
return join12(home, ".bash_profile");
|
|
12559
12745
|
}
|
|
12560
12746
|
function maybeWriteSystemWideEnv(apiUrl, apiKey, consoleUrl) {
|
|
12561
12747
|
const empty = { etcEnvironment: false, profileD: false, bashrc: false };
|
|
@@ -12830,7 +13016,7 @@ async function setupCommand(token, options = {}) {
|
|
|
12830
13016
|
const managerSpinner = ora({ text: "Starting manager daemon\u2026", isSilent: json });
|
|
12831
13017
|
managerSpinner.start();
|
|
12832
13018
|
try {
|
|
12833
|
-
const configDir =
|
|
13019
|
+
const configDir = join12(homedir7(), ".augmented");
|
|
12834
13020
|
const { pid } = startWatchdog({ intervalMs: 1e4, configDir, detached: true });
|
|
12835
13021
|
managerSpinner.succeed(`Manager started (PID ${pid})`);
|
|
12836
13022
|
} catch (err) {
|
|
@@ -12869,8 +13055,8 @@ async function setupCommand(token, options = {}) {
|
|
|
12869
13055
|
|
|
12870
13056
|
// src/commands/manager.ts
|
|
12871
13057
|
import chalk4 from "chalk";
|
|
12872
|
-
import { existsSync as existsSync10, realpathSync as
|
|
12873
|
-
import { join as
|
|
13058
|
+
import { existsSync as existsSync10, realpathSync as realpathSync3 } from "fs";
|
|
13059
|
+
import { join as join13 } from "path";
|
|
12874
13060
|
import { homedir as homedir8, userInfo } from "os";
|
|
12875
13061
|
import { spawn as spawn4 } from "child_process";
|
|
12876
13062
|
function normalizePinInEnv(env) {
|
|
@@ -12915,7 +13101,7 @@ function managerStartCommand(opts) {
|
|
|
12915
13101
|
process.exitCode = 1;
|
|
12916
13102
|
return;
|
|
12917
13103
|
}
|
|
12918
|
-
const configDir = opts.configDir ??
|
|
13104
|
+
const configDir = opts.configDir ?? join13(homedir8(), ".augmented");
|
|
12919
13105
|
if (opts.supervise) {
|
|
12920
13106
|
if (json) {
|
|
12921
13107
|
jsonOutput({ ok: false, error: "--supervise is not supported with --json" });
|
|
@@ -13011,7 +13197,7 @@ function runSupervisorLoop(intervalSec, configDir) {
|
|
|
13011
13197
|
}
|
|
13012
13198
|
async function managerStopCommand(opts = {}) {
|
|
13013
13199
|
const json = isJsonMode();
|
|
13014
|
-
const configDir = opts.configDir ??
|
|
13200
|
+
const configDir = opts.configDir ?? join13(homedir8(), ".augmented");
|
|
13015
13201
|
try {
|
|
13016
13202
|
const result = await stopWatchdog(configDir);
|
|
13017
13203
|
if (!result.stopped && !result.pid) {
|
|
@@ -13039,7 +13225,7 @@ async function managerStopCommand(opts = {}) {
|
|
|
13039
13225
|
}
|
|
13040
13226
|
function managerStatusCommand(opts = {}) {
|
|
13041
13227
|
const json = isJsonMode();
|
|
13042
|
-
const configDir = opts.configDir ??
|
|
13228
|
+
const configDir = opts.configDir ?? join13(homedir8(), ".augmented");
|
|
13043
13229
|
const status = getManagerStatus(configDir);
|
|
13044
13230
|
if (!status) {
|
|
13045
13231
|
if (json) {
|
|
@@ -13131,7 +13317,7 @@ function resolveStableAgtBin(rawPath) {
|
|
|
13131
13317
|
for (const candidate of candidates) {
|
|
13132
13318
|
if (!existsSync10(candidate)) continue;
|
|
13133
13319
|
try {
|
|
13134
|
-
|
|
13320
|
+
realpathSync3(candidate);
|
|
13135
13321
|
return candidate;
|
|
13136
13322
|
} catch {
|
|
13137
13323
|
}
|
|
@@ -13149,7 +13335,7 @@ async function managerInstallCommand(opts = {}) {
|
|
|
13149
13335
|
process.exitCode = 1;
|
|
13150
13336
|
return;
|
|
13151
13337
|
}
|
|
13152
|
-
const configDir = opts.configDir ??
|
|
13338
|
+
const configDir = opts.configDir ?? join13(homedir8(), ".augmented");
|
|
13153
13339
|
const rawAgtBin = process.argv[1];
|
|
13154
13340
|
if (!rawAgtBin) {
|
|
13155
13341
|
const msg = "Could not resolve the agt binary path from argv. Re-run via the installed `agt` command.";
|
|
@@ -13162,7 +13348,7 @@ async function managerInstallCommand(opts = {}) {
|
|
|
13162
13348
|
if (process.platform === "darwin") {
|
|
13163
13349
|
const home = homedir8();
|
|
13164
13350
|
const protectedRoots = ["Documents", "Downloads", "Desktop", "Movies", "Music", "Pictures"];
|
|
13165
|
-
const offending = protectedRoots.map((r) =>
|
|
13351
|
+
const offending = protectedRoots.map((r) => join13(home, r)).find((p) => agtBin === p || agtBin.startsWith(`${p}/`));
|
|
13166
13352
|
if (offending) {
|
|
13167
13353
|
const msg = `agt binary at ${agtBin} sits inside a macOS TCC-protected folder (${offending}). launchd-spawned processes cannot read files there and the manager would EPERM on startup. Either install agt globally (\`npm install -g @integrity-labs/agt-cli\`) or copy the dist outside protected folders before running this command.`;
|
|
13168
13354
|
if (json) jsonOutput({ ok: false, error: msg });
|
|
@@ -13228,7 +13414,7 @@ async function managerInstallSystemUnitCommand(opts = {}) {
|
|
|
13228
13414
|
return;
|
|
13229
13415
|
}
|
|
13230
13416
|
const user = opts.user ?? "root";
|
|
13231
|
-
const configDir = opts.configDir ?? (user === "root" ? "/root/.augmented" :
|
|
13417
|
+
const configDir = opts.configDir ?? (user === "root" ? "/root/.augmented" : join13("/home", user, ".augmented"));
|
|
13232
13418
|
const rawAgtBin = process.argv[1];
|
|
13233
13419
|
if (!rawAgtBin) {
|
|
13234
13420
|
const msg = "Could not resolve the agt binary path from argv. Re-run via the installed `agt` command.";
|
|
@@ -13455,6 +13641,7 @@ export {
|
|
|
13455
13641
|
parseRmPolicy,
|
|
13456
13642
|
migrateAgentDirToIdKeyed,
|
|
13457
13643
|
reapLegacyTokenFile,
|
|
13644
|
+
setScratchSweepPolicyResolver,
|
|
13458
13645
|
provisionStopHook,
|
|
13459
13646
|
provisionIsolationHook,
|
|
13460
13647
|
provisionAutoKanbanProgressHook,
|
|
@@ -13537,4 +13724,4 @@ export {
|
|
|
13537
13724
|
managerInstallSystemUnitCommand,
|
|
13538
13725
|
managerUninstallSystemUnitCommand
|
|
13539
13726
|
};
|
|
13540
|
-
//# sourceMappingURL=chunk-
|
|
13727
|
+
//# sourceMappingURL=chunk-ZEJUBTXJ.js.map
|